Bump for 3.6-28
[LibreOffice.git] / extensions / source / propctrlr / formbrowsertools.cxx
blobeba59542905b2bcc889b441aa773757b0f30f106
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "formbrowsertools.hxx"
30 #include <com/sun/star/form/FormComponentType.hpp>
31 #include <com/sun/star/lang/XServiceInfo.hpp>
32 #include <com/sun/star/beans/XPropertySet.hpp>
33 #include "formresid.hrc"
34 #include "modulepcr.hxx"
35 #include <tools/string.hxx>
36 #include "formstrings.hxx"
38 //............................................................................
39 namespace pcr
41 //............................................................................
43 using namespace ::com::sun::star::uno;
44 using namespace ::com::sun::star::form;
45 using namespace ::com::sun::star::lang;
46 using namespace ::com::sun::star::beans;
48 //------------------------------------------------------------------------
49 ::rtl::OUString GetUIHeadlineName(sal_Int16 nClassId, const Any& aUnoObj)
51 PcrClient aResourceAccess;
52 // this ensures that we have our resource file loaded
54 ::rtl::OUString sClassName;
55 switch (nClassId)
57 case FormComponentType::TEXTFIELD:
59 Reference< XInterface > xIFace;
60 aUnoObj >>= xIFace;
61 sClassName = String(PcrRes(RID_STR_PROPTITLE_EDIT));
62 if (xIFace.is())
63 { // we have a chance to check if it's a formatted field model
64 Reference< XServiceInfo > xInfo(xIFace, UNO_QUERY);
65 if (xInfo.is() && (xInfo->supportsService(SERVICE_COMPONENT_FORMATTEDFIELD)))
66 sClassName = String(PcrRes(RID_STR_PROPTITLE_FORMATTED));
67 else if (!xInfo.is())
69 // couldn't distinguish between formatted and edit with the service name, so try with the properties
70 Reference< XPropertySet > xProps(xIFace, UNO_QUERY);
71 if (xProps.is())
73 Reference< XPropertySetInfo > xPropsInfo = xProps->getPropertySetInfo();
74 if (xPropsInfo.is() && xPropsInfo->hasPropertyByName(PROPERTY_FORMATSSUPPLIER))
75 sClassName = String(PcrRes(RID_STR_PROPTITLE_FORMATTED));
80 break;
82 case FormComponentType::COMMANDBUTTON:
83 sClassName = String(PcrRes(RID_STR_PROPTITLE_PUSHBUTTON)); break;
84 case FormComponentType::RADIOBUTTON:
85 sClassName = String(PcrRes(RID_STR_PROPTITLE_RADIOBUTTON)); break;
86 case FormComponentType::CHECKBOX:
87 sClassName = String(PcrRes(RID_STR_PROPTITLE_CHECKBOX)); break;
88 case FormComponentType::LISTBOX:
89 sClassName = String(PcrRes(RID_STR_PROPTITLE_LISTBOX)); break;
90 case FormComponentType::COMBOBOX:
91 sClassName = String(PcrRes(RID_STR_PROPTITLE_COMBOBOX)); break;
92 case FormComponentType::GROUPBOX:
93 sClassName = String(PcrRes(RID_STR_PROPTITLE_GROUPBOX)); break;
94 case FormComponentType::IMAGEBUTTON:
95 sClassName = String(PcrRes(RID_STR_PROPTITLE_IMAGEBUTTON)); break;
96 case FormComponentType::FIXEDTEXT:
97 sClassName = String(PcrRes(RID_STR_PROPTITLE_FIXEDTEXT)); break;
98 case FormComponentType::GRIDCONTROL:
99 sClassName = String(PcrRes(RID_STR_PROPTITLE_DBGRID)); break;
100 case FormComponentType::FILECONTROL:
101 sClassName = String(PcrRes(RID_STR_PROPTITLE_FILECONTROL)); break;
103 case FormComponentType::DATEFIELD:
104 sClassName = String(PcrRes(RID_STR_PROPTITLE_DATEFIELD)); break;
105 case FormComponentType::TIMEFIELD:
106 sClassName = String(PcrRes(RID_STR_PROPTITLE_TIMEFIELD)); break;
107 case FormComponentType::NUMERICFIELD:
108 sClassName = String(PcrRes(RID_STR_PROPTITLE_NUMERICFIELD)); break;
109 case FormComponentType::CURRENCYFIELD:
110 sClassName = String(PcrRes(RID_STR_PROPTITLE_CURRENCYFIELD)); break;
111 case FormComponentType::PATTERNFIELD:
112 sClassName = String(PcrRes(RID_STR_PROPTITLE_PATTERNFIELD)); break;
113 case FormComponentType::IMAGECONTROL:
114 sClassName = String(PcrRes(RID_STR_PROPTITLE_IMAGECONTROL)); break;
115 case FormComponentType::HIDDENCONTROL:
116 sClassName = String(PcrRes(RID_STR_PROPTITLE_HIDDENCONTROL)); break;
118 case FormComponentType::CONTROL:
119 default:
120 sClassName = String(PcrRes(RID_STR_PROPTITLE_UNKNOWNCONTROL)); break;
123 return sClassName;
126 //------------------------------------------------------------------------
127 sal_Int16 classifyComponent( const Reference< XInterface >& _rxComponent )
129 Reference< XPropertySet > xComponentProps( _rxComponent, UNO_QUERY_THROW );
130 Reference< XPropertySetInfo > xPSI( xComponentProps->getPropertySetInfo(), UNO_SET_THROW );
132 sal_Int16 nControlType( FormComponentType::CONTROL );
133 if ( xPSI->hasPropertyByName( PROPERTY_CLASSID ) )
135 OSL_VERIFY( xComponentProps->getPropertyValue( PROPERTY_CLASSID ) >>= nControlType );
137 return nControlType;
140 //............................................................................
141 } // namespace pcr
142 //............................................................................
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */