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