merge the formfield patch from ooo-build
[ooovba.git] / extensions / source / propctrlr / handlerhelper.hxx
blob8e65c859490ee7e7a507ecd2970994db38bd3cda
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: handlerhelper.hxx,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 #ifndef EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX
32 #define EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX
34 /** === begin UNO includes === **/
35 #include <com/sun/star/beans/Property.hpp>
36 #include <com/sun/star/uno/XComponentContext.hpp>
37 #include <com/sun/star/script/XTypeConverter.hpp>
38 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
39 #include <com/sun/star/inspection/XPropertyControlFactory.hpp>
40 #include <com/sun/star/beans/PropertyAttribute.hpp>
41 #include <com/sun/star/beans/Optional.hpp>
42 /** === end UNO includes === **/
44 #include <vector>
46 class Window;
47 namespace com { namespace sun { namespace star {
48 namespace inspection {
49 struct LineDescriptor;
51 } } }
52 //........................................................................
53 namespace pcr
55 //........................................................................
57 class ComponentContext;
59 //====================================================================
60 //= PropertyHandlerHelper
61 //====================================================================
62 class PropertyHandlerHelper
64 public:
65 /** helper for implementing XPropertyHandler::describePropertyLine in a generic way
67 static void describePropertyLine(
68 const ::com::sun::star::beans::Property& _rProperty,
69 ::com::sun::star::inspection::LineDescriptor& /* [out] */ _out_rDescriptor,
70 const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory
73 /** helper for implementing XPropertyHandler::convertToPropertyValue
75 static ::com::sun::star::uno::Any convertToPropertyValue(
76 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
77 const ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter >& _rxTypeConverter,
78 const ::com::sun::star::beans::Property& _rProperty,
79 const ::com::sun::star::uno::Any& _rControlValue
82 /// helper for implementing XPropertyHandler::convertToControlValue
83 static ::com::sun::star::uno::Any convertToControlValue(
84 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
85 const ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter >& _rxTypeConverter,
86 const ::com::sun::star::uno::Any& _rPropertyValue,
87 const ::com::sun::star::uno::Type& _rControlValueType
90 /** creates an <member scope="com::sun::star::inspection">PropertyControlType::ListBox</member>-type control
91 and fills it with initial values
93 @param _rxControlFactory
94 A control factory. Must not be <NULL/>.
96 @param _rInitialListEntries
97 the initial values of the control
99 @param _bReadOnlyControl
100 determines whether the control should be read-only
102 @param _bSorted
103 determines whether the list entries should be sorted
105 @return
106 the newly created control
108 static ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
109 createListBoxControl(
110 const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory,
111 const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rInitialListEntries,
112 sal_Bool _bReadOnlyControl,
113 sal_Bool _bSorted
116 static ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
117 createListBoxControl(
118 const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory,
119 const ::std::vector< ::rtl::OUString >& _rInitialListEntries,
120 sal_Bool _bReadOnlyControl,
121 sal_Bool _bSorted
124 /** creates an <member scope="com::sun::star::inspection">PropertyControlType::ComboBox</member>-type control
125 and fills it with initial values
127 @param _rxControlFactory
128 A control factory. Must not be <NULL/>.
130 @param _rInitialListEntries
131 the initial values of the control
133 @param _bReadOnlyControl
134 determines whether the control should be read-only
136 @param _bSorted
137 determines whether the list entries should be sorted
139 @return
140 the newly created control
142 static ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
143 createComboBoxControl(
144 const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory,
145 const ::std::vector< ::rtl::OUString >& _rInitialListEntries,
146 sal_Bool _bReadOnlyControl,
147 sal_Bool _bSorted
150 /** creates an <member scope="com::sun::star::inspection">PropertyControlType::NumericField</member>-type control
151 and initializes it
153 @param _rxControlFactory
154 A control factory. Must not be <NULL/>.
155 @param _nDigits
156 number of decimal digits for the control
157 (<member scope="com::sun::star::inspection">XNumericControl::DecimalDigits</member>)
158 @param _rMinValue
159 minimum value which can be entered in the control
160 (<member scope="com::sun::star::inspection">XNumericControl::MinValue</member>)
161 @param _rMaxValue
162 maximum value which can be entered in the control
163 (<member scope="com::sun::star::inspection">XNumericControl::MaxValue</member>)
164 @param _bReadOnlyControl
165 determines whether the control should be read-only
167 @return
168 the newly created control
170 static ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
171 createNumericControl(
172 const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory,
173 sal_Int16 _nDigits,
174 const ::com::sun::star::beans::Optional< double >& _rMinValue,
175 const ::com::sun::star::beans::Optional< double >& _rMaxValue,
176 sal_Bool _bReadOnlyControl
179 /** marks the document passed in our UNO context as modified
181 The method looks up a value called "ContextDocument" in the given UNO component context,
182 queries it for the ->com::sun::star::util::XModifiable interface, and calls its
183 setModified method. If either of those steps fails, this is asserted in a non-product
184 version, and silently ignore otherwise.
186 @param _rContext
187 the component context which was used to create the component calling this method
189 static void setContextDocumentModified(
190 const ComponentContext& _rContext
193 /** gets the window of the ObjectInspector in which an property handler lives
195 The method looks up a value called "DialogParentWindow" in the given UNO copmonent context,
196 queries it for XWindow, and returns the respective Window*. If either of those steps fails,
197 this is asserted in a non-product version, and silently ignore otherwise.
199 @param _rContext
200 the component context which was used to create the component calling this method
202 static Window* getDialogParentWindow( const ComponentContext& _rContext );
205 /** determines whether given PropertyAttributes require a to-be-created
206 <type scope="com::sun::star::inspection">XPropertyControl</type> to be read-only
208 @param _nPropertyAttributes
209 the attributes of the property which should be reflected by a to-be-created
210 <type scope="com::sun::star::inspection">XPropertyControl</type>
212 inline static sal_Bool requiresReadOnlyControl( sal_Int16 _nPropertyAttributes )
214 return ( _nPropertyAttributes & ::com::sun::star::beans::PropertyAttribute::READONLY ) != 0;
217 private:
218 PropertyHandlerHelper(); // never implemented
219 PropertyHandlerHelper( const PropertyHandlerHelper& ); // never implemented
220 PropertyHandlerHelper& operator=( const PropertyHandlerHelper& ); // never implemented
223 //........................................................................
224 } // namespace pcr
225 //........................................................................
227 #endif // EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX