merged tag ooo/OOO330_m14
[LibreOffice.git] / extensions / source / propctrlr / formbrowsertools.cxx
blobed75149ac460af2ce860bc6b92efe7ac49c55f1f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_extensions.hxx"
30 #include "formbrowsertools.hxx"
31 #include <com/sun/star/form/FormComponentType.hpp>
32 #include <com/sun/star/lang/XServiceInfo.hpp>
33 #include <com/sun/star/beans/XPropertySet.hpp>
34 #ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
35 #include "formresid.hrc"
36 #endif
37 #ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
38 #include "modulepcr.hxx"
39 #endif
40 #include <tools/string.hxx>
41 #include "formstrings.hxx"
43 //............................................................................
44 namespace pcr
46 //............................................................................
48 using namespace ::com::sun::star::uno;
49 using namespace ::com::sun::star::form;
50 using namespace ::com::sun::star::lang;
51 using namespace ::com::sun::star::beans;
53 //------------------------------------------------------------------------
54 ::rtl::OUString GetUIHeadlineName(sal_Int16 nClassId, const Any& aUnoObj)
56 PcrClient aResourceAccess;
57 // this ensures that we have our resource file loaded
59 ::rtl::OUString sClassName;
60 switch (nClassId)
62 case FormComponentType::TEXTFIELD:
64 Reference< XInterface > xIFace;
65 aUnoObj >>= xIFace;
66 sClassName = String(PcrRes(RID_STR_PROPTITLE_EDIT));
67 if (xIFace.is())
68 { // we have a chance to check if it's a formatted field model
69 Reference< XServiceInfo > xInfo(xIFace, UNO_QUERY);
70 if (xInfo.is() && (xInfo->supportsService(SERVICE_COMPONENT_FORMATTEDFIELD)))
71 sClassName = String(PcrRes(RID_STR_PROPTITLE_FORMATTED));
72 else if (!xInfo.is())
74 // couldn't distinguish between formatted and edit with the service name, so try with the properties
75 Reference< XPropertySet > xProps(xIFace, UNO_QUERY);
76 if (xProps.is())
78 Reference< XPropertySetInfo > xPropsInfo = xProps->getPropertySetInfo();
79 if (xPropsInfo.is() && xPropsInfo->hasPropertyByName(PROPERTY_FORMATSSUPPLIER))
80 sClassName = String(PcrRes(RID_STR_PROPTITLE_FORMATTED));
85 break;
87 case FormComponentType::COMMANDBUTTON:
88 sClassName = String(PcrRes(RID_STR_PROPTITLE_PUSHBUTTON)); break;
89 case FormComponentType::RADIOBUTTON:
90 sClassName = String(PcrRes(RID_STR_PROPTITLE_RADIOBUTTON)); break;
91 case FormComponentType::CHECKBOX:
92 sClassName = String(PcrRes(RID_STR_PROPTITLE_CHECKBOX)); break;
93 case FormComponentType::LISTBOX:
94 sClassName = String(PcrRes(RID_STR_PROPTITLE_LISTBOX)); break;
95 case FormComponentType::COMBOBOX:
96 sClassName = String(PcrRes(RID_STR_PROPTITLE_COMBOBOX)); break;
97 case FormComponentType::GROUPBOX:
98 sClassName = String(PcrRes(RID_STR_PROPTITLE_GROUPBOX)); break;
99 case FormComponentType::IMAGEBUTTON:
100 sClassName = String(PcrRes(RID_STR_PROPTITLE_IMAGEBUTTON)); break;
101 case FormComponentType::FIXEDTEXT:
102 sClassName = String(PcrRes(RID_STR_PROPTITLE_FIXEDTEXT)); break;
103 case FormComponentType::GRIDCONTROL:
104 sClassName = String(PcrRes(RID_STR_PROPTITLE_DBGRID)); break;
105 case FormComponentType::FILECONTROL:
106 sClassName = String(PcrRes(RID_STR_PROPTITLE_FILECONTROL)); break;
108 case FormComponentType::DATEFIELD:
109 sClassName = String(PcrRes(RID_STR_PROPTITLE_DATEFIELD)); break;
110 case FormComponentType::TIMEFIELD:
111 sClassName = String(PcrRes(RID_STR_PROPTITLE_TIMEFIELD)); break;
112 case FormComponentType::NUMERICFIELD:
113 sClassName = String(PcrRes(RID_STR_PROPTITLE_NUMERICFIELD)); break;
114 case FormComponentType::CURRENCYFIELD:
115 sClassName = String(PcrRes(RID_STR_PROPTITLE_CURRENCYFIELD)); break;
116 case FormComponentType::PATTERNFIELD:
117 sClassName = String(PcrRes(RID_STR_PROPTITLE_PATTERNFIELD)); break;
118 case FormComponentType::IMAGECONTROL:
119 sClassName = String(PcrRes(RID_STR_PROPTITLE_IMAGECONTROL)); break;
120 case FormComponentType::HIDDENCONTROL:
121 sClassName = String(PcrRes(RID_STR_PROPTITLE_HIDDENCONTROL)); break;
123 case FormComponentType::CONTROL:
124 default:
125 sClassName = String(PcrRes(RID_STR_PROPTITLE_UNKNOWNCONTROL)); break;
128 return sClassName;
131 //------------------------------------------------------------------------
132 sal_Int16 classifyComponent( const Reference< XInterface >& _rxComponent )
134 Reference< XPropertySet > xComponentProps( _rxComponent, UNO_QUERY_THROW );
135 Reference< XPropertySetInfo > xPSI( xComponentProps->getPropertySetInfo(), UNO_SET_THROW );
137 sal_Int16 nControlType( FormComponentType::CONTROL );
138 if ( xPSI->hasPropertyByName( PROPERTY_CLASSID ) )
140 OSL_VERIFY( xComponentProps->getPropertyValue( PROPERTY_CLASSID ) >>= nControlType );
142 return nControlType;
145 //............................................................................
146 } // namespace pcr
147 //............................................................................