1*2a97ec55SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2a97ec55SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2a97ec55SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2a97ec55SAndrew Rist  * distributed with this work for additional information
6*2a97ec55SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2a97ec55SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2a97ec55SAndrew Rist  * "License"); you may not use this file except in compliance
9*2a97ec55SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2a97ec55SAndrew Rist  *
11*2a97ec55SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2a97ec55SAndrew Rist  *
13*2a97ec55SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2a97ec55SAndrew Rist  * software distributed under the License is distributed on an
15*2a97ec55SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2a97ec55SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2a97ec55SAndrew Rist  * specific language governing permissions and limitations
18*2a97ec55SAndrew Rist  * under the License.
19*2a97ec55SAndrew Rist  *
20*2a97ec55SAndrew Rist  *************************************************************/
21*2a97ec55SAndrew Rist 
22*2a97ec55SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_extensions.hxx"
26cdf0e10cSrcweir #include "formbrowsertools.hxx"
27cdf0e10cSrcweir #include <com/sun/star/form/FormComponentType.hpp>
28cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
29cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
30cdf0e10cSrcweir #ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
31cdf0e10cSrcweir #include "formresid.hrc"
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
34cdf0e10cSrcweir #include "modulepcr.hxx"
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #include <tools/string.hxx>
37cdf0e10cSrcweir #include "formstrings.hxx"
38cdf0e10cSrcweir 
39cdf0e10cSrcweir //............................................................................
40cdf0e10cSrcweir namespace pcr
41cdf0e10cSrcweir {
42cdf0e10cSrcweir //............................................................................
43cdf0e10cSrcweir 
44cdf0e10cSrcweir 	using namespace ::com::sun::star::uno;
45cdf0e10cSrcweir 	using namespace ::com::sun::star::form;
46cdf0e10cSrcweir 	using namespace ::com::sun::star::lang;
47cdf0e10cSrcweir 	using namespace ::com::sun::star::beans;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir     //------------------------------------------------------------------------
GetUIHeadlineName(sal_Int16 nClassId,const Any & aUnoObj)50cdf0e10cSrcweir 	::rtl::OUString GetUIHeadlineName(sal_Int16 nClassId, const Any& aUnoObj)
51cdf0e10cSrcweir 	{
52cdf0e10cSrcweir 		PcrClient aResourceAccess;
53cdf0e10cSrcweir 			// this ensures that we have our resource file loaded
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 		::rtl::OUString sClassName;
56cdf0e10cSrcweir 		switch (nClassId)
57cdf0e10cSrcweir 		{
58cdf0e10cSrcweir 			case FormComponentType::TEXTFIELD:
59cdf0e10cSrcweir 			{
60cdf0e10cSrcweir 				Reference< XInterface >  xIFace;
61cdf0e10cSrcweir 				aUnoObj >>= xIFace;
62cdf0e10cSrcweir 				sClassName = String(PcrRes(RID_STR_PROPTITLE_EDIT));
63cdf0e10cSrcweir 				if (xIFace.is())
64cdf0e10cSrcweir 				{	// we have a chance to check if it's a formatted field model
65cdf0e10cSrcweir 					Reference< XServiceInfo >  xInfo(xIFace, UNO_QUERY);
66cdf0e10cSrcweir 					if (xInfo.is() && (xInfo->supportsService(SERVICE_COMPONENT_FORMATTEDFIELD)))
67cdf0e10cSrcweir 						sClassName = String(PcrRes(RID_STR_PROPTITLE_FORMATTED));
68cdf0e10cSrcweir 					else if (!xInfo.is())
69cdf0e10cSrcweir 					{
70cdf0e10cSrcweir 						// couldn't distinguish between formatted and edit with the service name, so try with the properties
71cdf0e10cSrcweir 						Reference< XPropertySet >  xProps(xIFace, UNO_QUERY);
72cdf0e10cSrcweir 						if (xProps.is())
73cdf0e10cSrcweir 						{
74cdf0e10cSrcweir 							Reference< XPropertySetInfo >  xPropsInfo = xProps->getPropertySetInfo();
75cdf0e10cSrcweir 							if (xPropsInfo.is() && xPropsInfo->hasPropertyByName(PROPERTY_FORMATSSUPPLIER))
76cdf0e10cSrcweir 								sClassName = String(PcrRes(RID_STR_PROPTITLE_FORMATTED));
77cdf0e10cSrcweir 						}
78cdf0e10cSrcweir 					}
79cdf0e10cSrcweir 				}
80cdf0e10cSrcweir 			}
81cdf0e10cSrcweir 			break;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 			case FormComponentType::COMMANDBUTTON:
84cdf0e10cSrcweir 				sClassName = String(PcrRes(RID_STR_PROPTITLE_PUSHBUTTON)); break;
85cdf0e10cSrcweir 			case FormComponentType::RADIOBUTTON:
86cdf0e10cSrcweir 				sClassName = String(PcrRes(RID_STR_PROPTITLE_RADIOBUTTON)); break;
87cdf0e10cSrcweir 			case FormComponentType::CHECKBOX:
88cdf0e10cSrcweir 				sClassName = String(PcrRes(RID_STR_PROPTITLE_CHECKBOX)); break;
89cdf0e10cSrcweir 			case FormComponentType::LISTBOX:
90cdf0e10cSrcweir 				sClassName = String(PcrRes(RID_STR_PROPTITLE_LISTBOX)); break;
91cdf0e10cSrcweir 			case FormComponentType::COMBOBOX:
92cdf0e10cSrcweir 				sClassName = String(PcrRes(RID_STR_PROPTITLE_COMBOBOX)); break;
93cdf0e10cSrcweir 			case FormComponentType::GROUPBOX:
94cdf0e10cSrcweir 				sClassName = String(PcrRes(RID_STR_PROPTITLE_GROUPBOX)); break;
95cdf0e10cSrcweir 			case FormComponentType::IMAGEBUTTON:
96cdf0e10cSrcweir 				sClassName = String(PcrRes(RID_STR_PROPTITLE_IMAGEBUTTON)); break;
97cdf0e10cSrcweir 			case FormComponentType::FIXEDTEXT:
98cdf0e10cSrcweir 				sClassName = String(PcrRes(RID_STR_PROPTITLE_FIXEDTEXT)); break;
99cdf0e10cSrcweir 			case FormComponentType::GRIDCONTROL:
100cdf0e10cSrcweir 				sClassName = String(PcrRes(RID_STR_PROPTITLE_DBGRID)); break;
101cdf0e10cSrcweir 			case FormComponentType::FILECONTROL:
102cdf0e10cSrcweir 				sClassName = String(PcrRes(RID_STR_PROPTITLE_FILECONTROL)); break;
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 			case FormComponentType::DATEFIELD:
105cdf0e10cSrcweir 				sClassName = String(PcrRes(RID_STR_PROPTITLE_DATEFIELD)); break;
106cdf0e10cSrcweir 			case FormComponentType::TIMEFIELD:
107cdf0e10cSrcweir 				sClassName = String(PcrRes(RID_STR_PROPTITLE_TIMEFIELD)); break;
108cdf0e10cSrcweir 			case FormComponentType::NUMERICFIELD:
109cdf0e10cSrcweir 				sClassName = String(PcrRes(RID_STR_PROPTITLE_NUMERICFIELD)); break;
110cdf0e10cSrcweir 			case FormComponentType::CURRENCYFIELD:
111cdf0e10cSrcweir 				sClassName = String(PcrRes(RID_STR_PROPTITLE_CURRENCYFIELD)); break;
112cdf0e10cSrcweir 			case FormComponentType::PATTERNFIELD:
113cdf0e10cSrcweir 				sClassName = String(PcrRes(RID_STR_PROPTITLE_PATTERNFIELD)); break;
114cdf0e10cSrcweir 			case FormComponentType::IMAGECONTROL:
115cdf0e10cSrcweir 				sClassName = String(PcrRes(RID_STR_PROPTITLE_IMAGECONTROL)); break;
116cdf0e10cSrcweir 			case FormComponentType::HIDDENCONTROL:
117cdf0e10cSrcweir 				sClassName = String(PcrRes(RID_STR_PROPTITLE_HIDDENCONTROL)); break;
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 			case FormComponentType::CONTROL:
120cdf0e10cSrcweir 			default:
121cdf0e10cSrcweir 				sClassName = String(PcrRes(RID_STR_PROPTITLE_UNKNOWNCONTROL)); break;
122cdf0e10cSrcweir 		}
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 		return sClassName;
125cdf0e10cSrcweir 	}
126cdf0e10cSrcweir 
127cdf0e10cSrcweir     //------------------------------------------------------------------------
classifyComponent(const Reference<XInterface> & _rxComponent)128cdf0e10cSrcweir     sal_Int16 classifyComponent( const Reference< XInterface >& _rxComponent )
129cdf0e10cSrcweir     {
130cdf0e10cSrcweir         Reference< XPropertySet > xComponentProps( _rxComponent, UNO_QUERY_THROW );
131cdf0e10cSrcweir         Reference< XPropertySetInfo > xPSI( xComponentProps->getPropertySetInfo(), UNO_SET_THROW );
132cdf0e10cSrcweir 
133cdf0e10cSrcweir         sal_Int16 nControlType( FormComponentType::CONTROL );
134cdf0e10cSrcweir         if ( xPSI->hasPropertyByName( PROPERTY_CLASSID ) )
135cdf0e10cSrcweir         {
136cdf0e10cSrcweir             OSL_VERIFY( xComponentProps->getPropertyValue( PROPERTY_CLASSID ) >>= nControlType );
137cdf0e10cSrcweir         }
138cdf0e10cSrcweir         return nControlType;
139cdf0e10cSrcweir     }
140cdf0e10cSrcweir 
141cdf0e10cSrcweir //............................................................................
142cdf0e10cSrcweir } // namespace pcr
143cdf0e10cSrcweir //............................................................................
144cdf0e10cSrcweir 
145