merged tag ooo/OOO330_m14
[LibreOffice.git] / extensions / source / propctrlr / handlerhelper.hxx
blobe55cbf2075269599195c6900e4b4d856e04dc78a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX
29 #define EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX
31 /** === begin UNO includes === **/
32 #include <com/sun/star/beans/Property.hpp>
33 #include <com/sun/star/uno/XComponentContext.hpp>
34 #include <com/sun/star/script/XTypeConverter.hpp>
35 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
36 #include <com/sun/star/inspection/XPropertyControlFactory.hpp>
37 #include <com/sun/star/beans/PropertyAttribute.hpp>
38 #include <com/sun/star/beans/Optional.hpp>
39 /** === end UNO includes === **/
41 #include <vector>
43 class Window;
44 namespace com { namespace sun { namespace star {
45 namespace inspection {
46 struct LineDescriptor;
48 } } }
49 //........................................................................
50 namespace pcr
52 //........................................................................
54 class ComponentContext;
56 //====================================================================
57 //= PropertyHandlerHelper
58 //====================================================================
59 class PropertyHandlerHelper
61 public:
62 /** helper for implementing XPropertyHandler::describePropertyLine in a generic way
64 static void describePropertyLine(
65 const ::com::sun::star::beans::Property& _rProperty,
66 ::com::sun::star::inspection::LineDescriptor& /* [out] */ _out_rDescriptor,
67 const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory
70 /** helper for implementing XPropertyHandler::convertToPropertyValue
72 static ::com::sun::star::uno::Any convertToPropertyValue(
73 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
74 const ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter >& _rxTypeConverter,
75 const ::com::sun::star::beans::Property& _rProperty,
76 const ::com::sun::star::uno::Any& _rControlValue
79 /// helper for implementing XPropertyHandler::convertToControlValue
80 static ::com::sun::star::uno::Any convertToControlValue(
81 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
82 const ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter >& _rxTypeConverter,
83 const ::com::sun::star::uno::Any& _rPropertyValue,
84 const ::com::sun::star::uno::Type& _rControlValueType
87 /** creates an <member scope="com::sun::star::inspection">PropertyControlType::ListBox</member>-type control
88 and fills it with initial values
90 @param _rxControlFactory
91 A control factory. Must not be <NULL/>.
93 @param _rInitialListEntries
94 the initial values of the control
96 @param _bReadOnlyControl
97 determines whether the control should be read-only
99 @param _bSorted
100 determines whether the list entries should be sorted
102 @return
103 the newly created control
105 static ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
106 createListBoxControl(
107 const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory,
108 const ::std::vector< ::rtl::OUString >& _rInitialListEntries,
109 sal_Bool _bReadOnlyControl,
110 sal_Bool _bSorted
113 /** creates an <member scope="com::sun::star::inspection">PropertyControlType::ComboBox</member>-type control
114 and fills it with initial values
116 @param _rxControlFactory
117 A control factory. Must not be <NULL/>.
119 @param _rInitialListEntries
120 the initial values of the control
122 @param _bReadOnlyControl
123 determines whether the control should be read-only
125 @param _bSorted
126 determines whether the list entries should be sorted
128 @return
129 the newly created control
131 static ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
132 createComboBoxControl(
133 const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory,
134 const ::std::vector< ::rtl::OUString >& _rInitialListEntries,
135 sal_Bool _bReadOnlyControl,
136 sal_Bool _bSorted
139 /** creates an <member scope="com::sun::star::inspection">PropertyControlType::NumericField</member>-type control
140 and initializes it
142 @param _rxControlFactory
143 A control factory. Must not be <NULL/>.
144 @param _nDigits
145 number of decimal digits for the control
146 (<member scope="com::sun::star::inspection">XNumericControl::DecimalDigits</member>)
147 @param _rMinValue
148 minimum value which can be entered in the control
149 (<member scope="com::sun::star::inspection">XNumericControl::MinValue</member>)
150 @param _rMaxValue
151 maximum value which can be entered in the control
152 (<member scope="com::sun::star::inspection">XNumericControl::MaxValue</member>)
153 @param _bReadOnlyControl
154 determines whether the control should be read-only
156 @return
157 the newly created control
159 static ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
160 createNumericControl(
161 const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory,
162 sal_Int16 _nDigits,
163 const ::com::sun::star::beans::Optional< double >& _rMinValue,
164 const ::com::sun::star::beans::Optional< double >& _rMaxValue,
165 sal_Bool _bReadOnlyControl
168 /** marks the document passed in our UNO context as modified
170 The method looks up a value called "ContextDocument" in the given UNO component context,
171 queries it for the ->com::sun::star::util::XModifiable interface, and calls its
172 setModified method. If either of those steps fails, this is asserted in a non-product
173 version, and silently ignore otherwise.
175 @param _rContext
176 the component context which was used to create the component calling this method
178 static void setContextDocumentModified(
179 const ComponentContext& _rContext
182 /** gets the window of the ObjectInspector in which an property handler lives
184 The method looks up a value called "DialogParentWindow" in the given UNO copmonent context,
185 queries it for XWindow, and returns the respective Window*. If either of those steps fails,
186 this is asserted in a non-product version, and silently ignore otherwise.
188 @param _rContext
189 the component context which was used to create the component calling this method
191 static Window* getDialogParentWindow( const ComponentContext& _rContext );
194 /** determines whether given PropertyAttributes require a to-be-created
195 <type scope="com::sun::star::inspection">XPropertyControl</type> to be read-only
197 @param _nPropertyAttributes
198 the attributes of the property which should be reflected by a to-be-created
199 <type scope="com::sun::star::inspection">XPropertyControl</type>
201 inline static sal_Bool requiresReadOnlyControl( sal_Int16 _nPropertyAttributes )
203 return ( _nPropertyAttributes & ::com::sun::star::beans::PropertyAttribute::READONLY ) != 0;
206 private:
207 PropertyHandlerHelper(); // never implemented
208 PropertyHandlerHelper( const PropertyHandlerHelper& ); // never implemented
209 PropertyHandlerHelper& operator=( const PropertyHandlerHelper& ); // never implemented
212 //........................................................................
213 } // namespace pcr
214 //........................................................................
216 #endif // EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX