bump product version to 5.0.4.1
[LibreOffice.git] / extensions / source / propctrlr / formbrowsertools.cxx
blob12a5d4afec70584ea15395184e0357553c48c9c9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 "formstrings.hxx"
29 namespace pcr
33 using namespace ::com::sun::star::uno;
34 using namespace ::com::sun::star::form;
35 using namespace ::com::sun::star::lang;
36 using namespace ::com::sun::star::beans;
39 OUString GetUIHeadlineName(sal_Int16 nClassId, const Any& aUnoObj)
41 PcrClient aResourceAccess;
42 // this ensures that we have our resource file loaded
44 OUString sClassName;
45 switch (nClassId)
47 case FormComponentType::TEXTFIELD:
49 Reference< XInterface > xIFace;
50 aUnoObj >>= xIFace;
51 sClassName = PcrRes(RID_STR_PROPTITLE_EDIT).toString();
52 if (xIFace.is())
53 { // we have a chance to check if it's a formatted field model
54 Reference< XServiceInfo > xInfo(xIFace, UNO_QUERY);
55 if (xInfo.is() && (xInfo->supportsService(SERVICE_COMPONENT_FORMATTEDFIELD)))
56 sClassName = PcrRes(RID_STR_PROPTITLE_FORMATTED).toString();
57 else if (!xInfo.is())
59 // couldn't distinguish between formatted and edit with the service name, so try with the properties
60 Reference< XPropertySet > xProps(xIFace, UNO_QUERY);
61 if (xProps.is())
63 Reference< XPropertySetInfo > xPropsInfo = xProps->getPropertySetInfo();
64 if (xPropsInfo.is() && xPropsInfo->hasPropertyByName(PROPERTY_FORMATSSUPPLIER))
65 sClassName = PcrRes(RID_STR_PROPTITLE_FORMATTED).toString();
70 break;
72 case FormComponentType::COMMANDBUTTON:
73 sClassName = PcrRes(RID_STR_PROPTITLE_PUSHBUTTON).toString(); break;
74 case FormComponentType::RADIOBUTTON:
75 sClassName = PcrRes(RID_STR_PROPTITLE_RADIOBUTTON).toString(); break;
76 case FormComponentType::CHECKBOX:
77 sClassName = PcrRes(RID_STR_PROPTITLE_CHECKBOX).toString(); break;
78 case FormComponentType::LISTBOX:
79 sClassName = PcrRes(RID_STR_PROPTITLE_LISTBOX).toString(); break;
80 case FormComponentType::COMBOBOX:
81 sClassName = PcrRes(RID_STR_PROPTITLE_COMBOBOX).toString(); break;
82 case FormComponentType::GROUPBOX:
83 sClassName = PcrRes(RID_STR_PROPTITLE_GROUPBOX).toString(); break;
84 case FormComponentType::IMAGEBUTTON:
85 sClassName = PcrRes(RID_STR_PROPTITLE_IMAGEBUTTON).toString(); break;
86 case FormComponentType::FIXEDTEXT:
87 sClassName = PcrRes(RID_STR_PROPTITLE_FIXEDTEXT).toString(); break;
88 case FormComponentType::GRIDCONTROL:
89 sClassName = PcrRes(RID_STR_PROPTITLE_DBGRID).toString(); break;
90 case FormComponentType::FILECONTROL:
91 sClassName = PcrRes(RID_STR_PROPTITLE_FILECONTROL).toString(); break;
93 case FormComponentType::DATEFIELD:
94 sClassName = PcrRes(RID_STR_PROPTITLE_DATEFIELD).toString(); break;
95 case FormComponentType::TIMEFIELD:
96 sClassName = PcrRes(RID_STR_PROPTITLE_TIMEFIELD).toString(); break;
97 case FormComponentType::NUMERICFIELD:
98 sClassName = PcrRes(RID_STR_PROPTITLE_NUMERICFIELD).toString(); break;
99 case FormComponentType::CURRENCYFIELD:
100 sClassName = PcrRes(RID_STR_PROPTITLE_CURRENCYFIELD).toString(); break;
101 case FormComponentType::PATTERNFIELD:
102 sClassName = PcrRes(RID_STR_PROPTITLE_PATTERNFIELD).toString(); break;
103 case FormComponentType::IMAGECONTROL:
104 sClassName = PcrRes(RID_STR_PROPTITLE_IMAGECONTROL).toString(); break;
105 case FormComponentType::HIDDENCONTROL:
106 sClassName = PcrRes(RID_STR_PROPTITLE_HIDDENCONTROL).toString(); break;
108 case FormComponentType::CONTROL:
109 default:
110 sClassName = PcrRes(RID_STR_PROPTITLE_UNKNOWNCONTROL).toString(); break;
113 return sClassName;
117 sal_Int16 classifyComponent( const Reference< XInterface >& _rxComponent )
119 Reference< XPropertySet > xComponentProps( _rxComponent, UNO_QUERY_THROW );
120 Reference< XPropertySetInfo > xPSI( xComponentProps->getPropertySetInfo(), UNO_SET_THROW );
122 sal_Int16 nControlType( FormComponentType::CONTROL );
123 if ( xPSI->hasPropertyByName( PROPERTY_CLASSID ) )
125 OSL_VERIFY( xComponentProps->getPropertyValue( PROPERTY_CLASSID ) >>= nControlType );
127 return nControlType;
131 } // namespace pcr
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */