1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "formbrowsertools.hxx"
21 #include <com/sun/star/form/FormComponentType.hpp>
22 #include <com/sun/star/lang/XServiceInfo.hpp>
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include "formresid.hrc"
25 #include "modulepcr.hxx"
26 #include <tools/string.hxx>
27 #include "formstrings.hxx"
29 //............................................................................
32 //............................................................................
34 using namespace ::com::sun::star::uno
;
35 using namespace ::com::sun::star::form
;
36 using namespace ::com::sun::star::lang
;
37 using namespace ::com::sun::star::beans
;
39 //------------------------------------------------------------------------
40 OUString
GetUIHeadlineName(sal_Int16 nClassId
, const Any
& aUnoObj
)
42 PcrClient aResourceAccess
;
43 // this ensures that we have our resource file loaded
48 case FormComponentType::TEXTFIELD
:
50 Reference
< XInterface
> xIFace
;
52 sClassName
= String(PcrRes(RID_STR_PROPTITLE_EDIT
));
54 { // we have a chance to check if it's a formatted field model
55 Reference
< XServiceInfo
> xInfo(xIFace
, UNO_QUERY
);
56 if (xInfo
.is() && (xInfo
->supportsService(SERVICE_COMPONENT_FORMATTEDFIELD
)))
57 sClassName
= String(PcrRes(RID_STR_PROPTITLE_FORMATTED
));
60 // couldn't distinguish between formatted and edit with the service name, so try with the properties
61 Reference
< XPropertySet
> xProps(xIFace
, UNO_QUERY
);
64 Reference
< XPropertySetInfo
> xPropsInfo
= xProps
->getPropertySetInfo();
65 if (xPropsInfo
.is() && xPropsInfo
->hasPropertyByName(PROPERTY_FORMATSSUPPLIER
))
66 sClassName
= String(PcrRes(RID_STR_PROPTITLE_FORMATTED
));
73 case FormComponentType::COMMANDBUTTON
:
74 sClassName
= String(PcrRes(RID_STR_PROPTITLE_PUSHBUTTON
)); break;
75 case FormComponentType::RADIOBUTTON
:
76 sClassName
= String(PcrRes(RID_STR_PROPTITLE_RADIOBUTTON
)); break;
77 case FormComponentType::CHECKBOX
:
78 sClassName
= String(PcrRes(RID_STR_PROPTITLE_CHECKBOX
)); break;
79 case FormComponentType::LISTBOX
:
80 sClassName
= String(PcrRes(RID_STR_PROPTITLE_LISTBOX
)); break;
81 case FormComponentType::COMBOBOX
:
82 sClassName
= String(PcrRes(RID_STR_PROPTITLE_COMBOBOX
)); break;
83 case FormComponentType::GROUPBOX
:
84 sClassName
= String(PcrRes(RID_STR_PROPTITLE_GROUPBOX
)); break;
85 case FormComponentType::IMAGEBUTTON
:
86 sClassName
= String(PcrRes(RID_STR_PROPTITLE_IMAGEBUTTON
)); break;
87 case FormComponentType::FIXEDTEXT
:
88 sClassName
= String(PcrRes(RID_STR_PROPTITLE_FIXEDTEXT
)); break;
89 case FormComponentType::GRIDCONTROL
:
90 sClassName
= String(PcrRes(RID_STR_PROPTITLE_DBGRID
)); break;
91 case FormComponentType::FILECONTROL
:
92 sClassName
= String(PcrRes(RID_STR_PROPTITLE_FILECONTROL
)); break;
94 case FormComponentType::DATEFIELD
:
95 sClassName
= String(PcrRes(RID_STR_PROPTITLE_DATEFIELD
)); break;
96 case FormComponentType::TIMEFIELD
:
97 sClassName
= String(PcrRes(RID_STR_PROPTITLE_TIMEFIELD
)); break;
98 case FormComponentType::NUMERICFIELD
:
99 sClassName
= String(PcrRes(RID_STR_PROPTITLE_NUMERICFIELD
)); break;
100 case FormComponentType::CURRENCYFIELD
:
101 sClassName
= String(PcrRes(RID_STR_PROPTITLE_CURRENCYFIELD
)); break;
102 case FormComponentType::PATTERNFIELD
:
103 sClassName
= String(PcrRes(RID_STR_PROPTITLE_PATTERNFIELD
)); break;
104 case FormComponentType::IMAGECONTROL
:
105 sClassName
= String(PcrRes(RID_STR_PROPTITLE_IMAGECONTROL
)); break;
106 case FormComponentType::HIDDENCONTROL
:
107 sClassName
= String(PcrRes(RID_STR_PROPTITLE_HIDDENCONTROL
)); break;
109 case FormComponentType::CONTROL
:
111 sClassName
= String(PcrRes(RID_STR_PROPTITLE_UNKNOWNCONTROL
)); break;
117 //------------------------------------------------------------------------
118 sal_Int16
classifyComponent( const Reference
< XInterface
>& _rxComponent
)
120 Reference
< XPropertySet
> xComponentProps( _rxComponent
, UNO_QUERY_THROW
);
121 Reference
< XPropertySetInfo
> xPSI( xComponentProps
->getPropertySetInfo(), UNO_SET_THROW
);
123 sal_Int16
nControlType( FormComponentType::CONTROL
);
124 if ( xPSI
->hasPropertyByName( PROPERTY_CLASSID
) )
126 OSL_VERIFY( xComponentProps
->getPropertyValue( PROPERTY_CLASSID
) >>= nControlType
);
131 //............................................................................
133 //............................................................................
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */