1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "formbrowsertools.hxx"
21 #include <com/sun/star/form/FormComponentType.hpp>
22 #include <com/sun/star/lang/XServiceInfo.hpp>
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include <osl/diagnose.h>
25 #include <strings.hrc>
26 #include "modulepcr.hxx"
27 #include "formstrings.hxx"
34 using namespace ::com::sun::star::uno
;
35 using namespace ::com::sun::star::form
;
36 using namespace ::com::sun::star::lang
;
37 using namespace ::com::sun::star::beans
;
40 OUString
GetUIHeadlineName(sal_Int16 nClassId
, const Any
& aUnoObj
)
45 case FormComponentType::TEXTFIELD
:
47 Reference
< XInterface
> xIFace
;
49 sClassName
= PcrRes(RID_STR_PROPTITLE_EDIT
);
51 { // we have a chance to check if it's a formatted field model
52 Reference
< XServiceInfo
> xInfo(xIFace
, UNO_QUERY
);
53 if (xInfo
.is() && (xInfo
->supportsService(SERVICE_COMPONENT_FORMATTEDFIELD
)))
54 sClassName
= PcrRes(RID_STR_PROPTITLE_FORMATTED
);
57 // couldn't distinguish between formatted and edit with the service name, so try with the properties
58 Reference
< XPropertySet
> xProps(xIFace
, UNO_QUERY
);
61 Reference
< XPropertySetInfo
> xPropsInfo
= xProps
->getPropertySetInfo();
62 if (xPropsInfo
.is() && xPropsInfo
->hasPropertyByName(PROPERTY_FORMATSSUPPLIER
))
63 sClassName
= PcrRes(RID_STR_PROPTITLE_FORMATTED
);
70 case FormComponentType::COMMANDBUTTON
:
71 sClassName
= PcrRes(RID_STR_PROPTITLE_PUSHBUTTON
); break;
72 case FormComponentType::RADIOBUTTON
:
73 sClassName
= PcrRes(RID_STR_PROPTITLE_RADIOBUTTON
); break;
74 case FormComponentType::CHECKBOX
:
75 sClassName
= PcrRes(RID_STR_PROPTITLE_CHECKBOX
); break;
76 case FormComponentType::LISTBOX
:
77 sClassName
= PcrRes(RID_STR_PROPTITLE_LISTBOX
); break;
78 case FormComponentType::COMBOBOX
:
79 sClassName
= PcrRes(RID_STR_PROPTITLE_COMBOBOX
); break;
80 case FormComponentType::GROUPBOX
:
81 sClassName
= PcrRes(RID_STR_PROPTITLE_GROUPBOX
); break;
82 case FormComponentType::IMAGEBUTTON
:
83 sClassName
= PcrRes(RID_STR_PROPTITLE_IMAGEBUTTON
); break;
84 case FormComponentType::FIXEDTEXT
:
85 sClassName
= PcrRes(RID_STR_PROPTITLE_FIXEDTEXT
); break;
86 case FormComponentType::GRIDCONTROL
:
87 sClassName
= PcrRes(RID_STR_PROPTITLE_DBGRID
); break;
88 case FormComponentType::FILECONTROL
:
89 sClassName
= PcrRes(RID_STR_PROPTITLE_FILECONTROL
); break;
91 case FormComponentType::DATEFIELD
:
92 sClassName
= PcrRes(RID_STR_PROPTITLE_DATEFIELD
); break;
93 case FormComponentType::TIMEFIELD
:
94 sClassName
= PcrRes(RID_STR_PROPTITLE_TIMEFIELD
); break;
95 case FormComponentType::NUMERICFIELD
:
96 sClassName
= PcrRes(RID_STR_PROPTITLE_NUMERICFIELD
); break;
97 case FormComponentType::CURRENCYFIELD
:
98 sClassName
= PcrRes(RID_STR_PROPTITLE_CURRENCYFIELD
); break;
99 case FormComponentType::PATTERNFIELD
:
100 sClassName
= PcrRes(RID_STR_PROPTITLE_PATTERNFIELD
); break;
101 case FormComponentType::IMAGECONTROL
:
102 sClassName
= PcrRes(RID_STR_PROPTITLE_IMAGECONTROL
); break;
103 case FormComponentType::HIDDENCONTROL
:
104 sClassName
= PcrRes(RID_STR_PROPTITLE_HIDDENCONTROL
); break;
106 case FormComponentType::CONTROL
:
108 sClassName
= PcrRes(RID_STR_PROPTITLE_UNKNOWNCONTROL
); break;
115 sal_Int16
classifyComponent( const Reference
< XInterface
>& _rxComponent
)
117 Reference
< XPropertySet
> xComponentProps( _rxComponent
, UNO_QUERY_THROW
);
118 Reference
< XPropertySetInfo
> xPSI( xComponentProps
->getPropertySetInfo(), UNO_SET_THROW
);
120 sal_Int16
nControlType( FormComponentType::CONTROL
);
121 if ( xPSI
->hasPropertyByName( PROPERTY_CLASSID
) )
123 OSL_VERIFY( xComponentProps
->getPropertyValue( PROPERTY_CLASSID
) >>= nControlType
);
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */