1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: formbrowsertools.cxx,v $
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"
40 #ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
41 #include "modulepcr.hxx"
43 #include <tools/string.hxx>
44 #include "formstrings.hxx"
46 //............................................................................
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 //------------------------------------------------------------------------
57 ::rtl::OUString
GetUIHeadlineName(sal_Int16 nClassId
, const Any
& aUnoObj
)
59 PcrClient aResourceAccess
;
60 // this ensures that we have our resource file loaded
62 ::rtl::OUString sClassName
;
65 case FormComponentType::TEXTFIELD
:
67 Reference
< XInterface
> xIFace
;
69 sClassName
= String(PcrRes(RID_STR_PROPTITLE_EDIT
));
71 { // we have a chance to check if it's a formatted field model
72 Reference
< XServiceInfo
> xInfo(xIFace
, UNO_QUERY
);
73 if (xInfo
.is() && (xInfo
->supportsService(SERVICE_COMPONENT_FORMATTEDFIELD
)))
74 sClassName
= String(PcrRes(RID_STR_PROPTITLE_FORMATTED
));
77 // couldn't distinguish between formatted and edit with the service name, so try with the properties
78 Reference
< XPropertySet
> xProps(xIFace
, UNO_QUERY
);
81 Reference
< XPropertySetInfo
> xPropsInfo
= xProps
->getPropertySetInfo();
82 if (xPropsInfo
.is() && xPropsInfo
->hasPropertyByName(PROPERTY_FORMATSSUPPLIER
))
83 sClassName
= String(PcrRes(RID_STR_PROPTITLE_FORMATTED
));
90 case FormComponentType::COMMANDBUTTON
:
91 sClassName
= String(PcrRes(RID_STR_PROPTITLE_PUSHBUTTON
)); break;
92 case FormComponentType::RADIOBUTTON
:
93 sClassName
= String(PcrRes(RID_STR_PROPTITLE_RADIOBUTTON
)); break;
94 case FormComponentType::CHECKBOX
:
95 sClassName
= String(PcrRes(RID_STR_PROPTITLE_CHECKBOX
)); break;
96 case FormComponentType::LISTBOX
:
97 sClassName
= String(PcrRes(RID_STR_PROPTITLE_LISTBOX
)); break;
98 case FormComponentType::COMBOBOX
:
99 sClassName
= String(PcrRes(RID_STR_PROPTITLE_COMBOBOX
)); break;
100 case FormComponentType::GROUPBOX
:
101 sClassName
= String(PcrRes(RID_STR_PROPTITLE_GROUPBOX
)); break;
102 case FormComponentType::IMAGEBUTTON
:
103 sClassName
= String(PcrRes(RID_STR_PROPTITLE_IMAGEBUTTON
)); break;
104 case FormComponentType::FIXEDTEXT
:
105 sClassName
= String(PcrRes(RID_STR_PROPTITLE_FIXEDTEXT
)); break;
106 case FormComponentType::GRIDCONTROL
:
107 sClassName
= String(PcrRes(RID_STR_PROPTITLE_DBGRID
)); break;
108 case FormComponentType::FILECONTROL
:
109 sClassName
= String(PcrRes(RID_STR_PROPTITLE_FILECONTROL
)); break;
111 case FormComponentType::DATEFIELD
:
112 sClassName
= String(PcrRes(RID_STR_PROPTITLE_DATEFIELD
)); break;
113 case FormComponentType::TIMEFIELD
:
114 sClassName
= String(PcrRes(RID_STR_PROPTITLE_TIMEFIELD
)); break;
115 case FormComponentType::NUMERICFIELD
:
116 sClassName
= String(PcrRes(RID_STR_PROPTITLE_NUMERICFIELD
)); break;
117 case FormComponentType::CURRENCYFIELD
:
118 sClassName
= String(PcrRes(RID_STR_PROPTITLE_CURRENCYFIELD
)); break;
119 case FormComponentType::PATTERNFIELD
:
120 sClassName
= String(PcrRes(RID_STR_PROPTITLE_PATTERNFIELD
)); break;
121 case FormComponentType::IMAGECONTROL
:
122 sClassName
= String(PcrRes(RID_STR_PROPTITLE_IMAGECONTROL
)); break;
123 case FormComponentType::HIDDENCONTROL
:
124 sClassName
= String(PcrRes(RID_STR_PROPTITLE_HIDDENCONTROL
)); break;
126 case FormComponentType::CONTROL
:
128 sClassName
= String(PcrRes(RID_STR_PROPTITLE_UNKNOWNCONTROL
)); break;
134 //------------------------------------------------------------------------
135 sal_Int16
classifyComponent( const Reference
< XInterface
>& _rxComponent
)
137 Reference
< XPropertySet
> xComponentProps( _rxComponent
, UNO_QUERY_THROW
);
138 Reference
< XPropertySetInfo
> xPSI( xComponentProps
->getPropertySetInfo(), UNO_SET_THROW
);
140 sal_Int16
nControlType( FormComponentType::CONTROL
);
141 if ( xPSI
->hasPropertyByName( PROPERTY_CLASSID
) )
143 OSL_VERIFY( xComponentProps
->getPropertyValue( PROPERTY_CLASSID
) >>= nControlType
);
148 //............................................................................
150 //............................................................................