1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX
30 #define EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX
32 /** === begin UNO includes === **/
33 #include <com/sun/star/beans/Property.hpp>
34 #include <com/sun/star/uno/XComponentContext.hpp>
35 #include <com/sun/star/script/XTypeConverter.hpp>
36 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
37 #include <com/sun/star/inspection/XPropertyControlFactory.hpp>
38 #include <com/sun/star/beans/PropertyAttribute.hpp>
39 #include <com/sun/star/beans/Optional.hpp>
40 /** === end UNO includes === **/
45 namespace com
{ namespace sun
{ namespace star
{
46 namespace inspection
{
47 struct LineDescriptor
;
50 //........................................................................
53 //........................................................................
55 class ComponentContext
;
57 //====================================================================
58 //= PropertyHandlerHelper
59 //====================================================================
60 class PropertyHandlerHelper
63 /** helper for implementing XPropertyHandler::describePropertyLine in a generic way
65 static void describePropertyLine(
66 const ::com::sun::star::beans::Property
& _rProperty
,
67 ::com::sun::star::inspection::LineDescriptor
& /* [out] */ _out_rDescriptor
,
68 const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControlFactory
>& _rxControlFactory
71 /** helper for implementing XPropertyHandler::convertToPropertyValue
73 static ::com::sun::star::uno::Any
convertToPropertyValue(
74 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& _rxContext
,
75 const ::com::sun::star::uno::Reference
< ::com::sun::star::script::XTypeConverter
>& _rxTypeConverter
,
76 const ::com::sun::star::beans::Property
& _rProperty
,
77 const ::com::sun::star::uno::Any
& _rControlValue
80 /// helper for implementing XPropertyHandler::convertToControlValue
81 static ::com::sun::star::uno::Any
convertToControlValue(
82 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& _rxContext
,
83 const ::com::sun::star::uno::Reference
< ::com::sun::star::script::XTypeConverter
>& _rxTypeConverter
,
84 const ::com::sun::star::uno::Any
& _rPropertyValue
,
85 const ::com::sun::star::uno::Type
& _rControlValueType
88 /** creates an <member scope="com::sun::star::inspection">PropertyControlType::ListBox</member>-type control
89 and fills it with initial values
91 @param _rxControlFactory
92 A control factory. Must not be <NULL/>.
94 @param _rInitialListEntries
95 the initial values of the control
97 @param _bReadOnlyControl
98 determines whether the control should be read-only
101 determines whether the list entries should be sorted
104 the newly created control
106 static ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>
107 createListBoxControl(
108 const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControlFactory
>& _rxControlFactory
,
109 const ::std::vector
< ::rtl::OUString
>& _rInitialListEntries
,
110 sal_Bool _bReadOnlyControl
,
114 /** creates an <member scope="com::sun::star::inspection">PropertyControlType::ComboBox</member>-type control
115 and fills it with initial values
117 @param _rxControlFactory
118 A control factory. Must not be <NULL/>.
120 @param _rInitialListEntries
121 the initial values of the control
123 @param _bReadOnlyControl
124 determines whether the control should be read-only
127 determines whether the list entries should be sorted
130 the newly created control
132 static ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>
133 createComboBoxControl(
134 const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControlFactory
>& _rxControlFactory
,
135 const ::std::vector
< ::rtl::OUString
>& _rInitialListEntries
,
136 sal_Bool _bReadOnlyControl
,
140 /** creates an <member scope="com::sun::star::inspection">PropertyControlType::NumericField</member>-type control
143 @param _rxControlFactory
144 A control factory. Must not be <NULL/>.
146 number of decimal digits for the control
147 (<member scope="com::sun::star::inspection">XNumericControl::DecimalDigits</member>)
149 minimum value which can be entered in the control
150 (<member scope="com::sun::star::inspection">XNumericControl::MinValue</member>)
152 maximum value which can be entered in the control
153 (<member scope="com::sun::star::inspection">XNumericControl::MaxValue</member>)
154 @param _bReadOnlyControl
155 determines whether the control should be read-only
158 the newly created control
160 static ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>
161 createNumericControl(
162 const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControlFactory
>& _rxControlFactory
,
164 const ::com::sun::star::beans::Optional
< double >& _rMinValue
,
165 const ::com::sun::star::beans::Optional
< double >& _rMaxValue
,
166 sal_Bool _bReadOnlyControl
169 /** marks the document passed in our UNO context as modified
171 The method looks up a value called "ContextDocument" in the given UNO component context,
172 queries it for the ->com::sun::star::util::XModifiable interface, and calls its
173 setModified method. If either of those steps fails, this is asserted in a non-product
174 version, and silently ignore otherwise.
177 the component context which was used to create the component calling this method
179 static void setContextDocumentModified(
180 const ComponentContext
& _rContext
183 /** gets the window of the ObjectInspector in which an property handler lives
185 The method looks up a value called "DialogParentWindow" in the given UNO copmonent context,
186 queries it for XWindow, and returns the respective Window*. If either of those steps fails,
187 this is asserted in a non-product version, and silently ignore otherwise.
190 the component context which was used to create the component calling this method
192 static Window
* getDialogParentWindow( const ComponentContext
& _rContext
);
195 /** determines whether given PropertyAttributes require a to-be-created
196 <type scope="com::sun::star::inspection">XPropertyControl</type> to be read-only
198 @param _nPropertyAttributes
199 the attributes of the property which should be reflected by a to-be-created
200 <type scope="com::sun::star::inspection">XPropertyControl</type>
202 inline static sal_Bool
requiresReadOnlyControl( sal_Int16 _nPropertyAttributes
)
204 return ( _nPropertyAttributes
& ::com::sun::star::beans::PropertyAttribute::READONLY
) != 0;
208 PropertyHandlerHelper(); // never implemented
209 PropertyHandlerHelper( const PropertyHandlerHelper
& ); // never implemented
210 PropertyHandlerHelper
& operator=( const PropertyHandlerHelper
& ); // never implemented
213 //........................................................................
215 //........................................................................
217 #endif // EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX
219 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */