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: handlerhelper.hxx,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 #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 === **/
47 namespace com
{ namespace sun
{ namespace star
{
48 namespace inspection
{
49 struct LineDescriptor
;
52 //........................................................................
55 //........................................................................
57 class ComponentContext
;
59 //====================================================================
60 //= PropertyHandlerHelper
61 //====================================================================
62 class PropertyHandlerHelper
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
103 determines whether the list entries should be sorted
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
,
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
,
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
137 determines whether the list entries should be sorted
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
,
150 /** creates an <member scope="com::sun::star::inspection">PropertyControlType::NumericField</member>-type control
153 @param _rxControlFactory
154 A control factory. Must not be <NULL/>.
156 number of decimal digits for the control
157 (<member scope="com::sun::star::inspection">XNumericControl::DecimalDigits</member>)
159 minimum value which can be entered in the control
160 (<member scope="com::sun::star::inspection">XNumericControl::MinValue</member>)
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
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
,
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.
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.
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;
218 PropertyHandlerHelper(); // never implemented
219 PropertyHandlerHelper( const PropertyHandlerHelper
& ); // never implemented
220 PropertyHandlerHelper
& operator=( const PropertyHandlerHelper
& ); // never implemented
223 //........................................................................
225 //........................................................................
227 #endif // EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX