1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #ifndef EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX
21 #define EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX
23 #include <com/sun/star/beans/Property.hpp>
24 #include <com/sun/star/uno/XComponentContext.hpp>
25 #include <com/sun/star/script/XTypeConverter.hpp>
26 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
27 #include <com/sun/star/inspection/XPropertyControlFactory.hpp>
28 #include <com/sun/star/beans/PropertyAttribute.hpp>
29 #include <com/sun/star/beans/Optional.hpp>
34 namespace com
{ namespace sun
{ namespace star
{
35 namespace inspection
{
36 struct LineDescriptor
;
39 //........................................................................
42 //........................................................................
44 class ComponentContext
;
46 //====================================================================
47 //= PropertyHandlerHelper
48 //====================================================================
49 class PropertyHandlerHelper
52 /** helper for implementing XPropertyHandler::describePropertyLine in a generic way
54 static void describePropertyLine(
55 const ::com::sun::star::beans::Property
& _rProperty
,
56 ::com::sun::star::inspection::LineDescriptor
& /* [out] */ _out_rDescriptor
,
57 const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControlFactory
>& _rxControlFactory
60 /** helper for implementing XPropertyHandler::convertToPropertyValue
62 static ::com::sun::star::uno::Any
convertToPropertyValue(
63 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& _rxContext
,
64 const ::com::sun::star::uno::Reference
< ::com::sun::star::script::XTypeConverter
>& _rxTypeConverter
,
65 const ::com::sun::star::beans::Property
& _rProperty
,
66 const ::com::sun::star::uno::Any
& _rControlValue
69 /// helper for implementing XPropertyHandler::convertToControlValue
70 static ::com::sun::star::uno::Any
convertToControlValue(
71 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& _rxContext
,
72 const ::com::sun::star::uno::Reference
< ::com::sun::star::script::XTypeConverter
>& _rxTypeConverter
,
73 const ::com::sun::star::uno::Any
& _rPropertyValue
,
74 const ::com::sun::star::uno::Type
& _rControlValueType
77 /** creates an <member scope="com::sun::star::inspection">PropertyControlType::ListBox</member>-type control
78 and fills it with initial values
80 @param _rxControlFactory
81 A control factory. Must not be <NULL/>.
83 @param _rInitialListEntries
84 the initial values of the control
86 @param _bReadOnlyControl
87 determines whether the control should be read-only
90 determines whether the list entries should be sorted
93 the newly created control
95 static ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>
97 const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControlFactory
>& _rxControlFactory
,
98 const ::std::vector
< OUString
>& _rInitialListEntries
,
99 sal_Bool _bReadOnlyControl
,
103 /** creates an <member scope="com::sun::star::inspection">PropertyControlType::ComboBox</member>-type control
104 and fills it with initial values
106 @param _rxControlFactory
107 A control factory. Must not be <NULL/>.
109 @param _rInitialListEntries
110 the initial values of the control
112 @param _bReadOnlyControl
113 determines whether the control should be read-only
116 determines whether the list entries should be sorted
119 the newly created control
121 static ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>
122 createComboBoxControl(
123 const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControlFactory
>& _rxControlFactory
,
124 const ::std::vector
< OUString
>& _rInitialListEntries
,
125 sal_Bool _bReadOnlyControl
,
129 /** creates an <member scope="com::sun::star::inspection">PropertyControlType::NumericField</member>-type control
132 @param _rxControlFactory
133 A control factory. Must not be <NULL/>.
135 number of decimal digits for the control
136 (<member scope="com::sun::star::inspection">XNumericControl::DecimalDigits</member>)
138 minimum value which can be entered in the control
139 (<member scope="com::sun::star::inspection">XNumericControl::MinValue</member>)
141 maximum value which can be entered in the control
142 (<member scope="com::sun::star::inspection">XNumericControl::MaxValue</member>)
143 @param _bReadOnlyControl
144 determines whether the control should be read-only
147 the newly created control
149 static ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>
150 createNumericControl(
151 const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControlFactory
>& _rxControlFactory
,
153 const ::com::sun::star::beans::Optional
< double >& _rMinValue
,
154 const ::com::sun::star::beans::Optional
< double >& _rMaxValue
,
155 sal_Bool _bReadOnlyControl
158 /** marks the document passed in our UNO context as modified
160 The method looks up a value called "ContextDocument" in the given UNO component context,
161 queries it for the ->com::sun::star::util::XModifiable interface, and calls its
162 setModified method. If either of those steps fails, this is asserted in a non-product
163 version, and silently ignore otherwise.
166 the component context which was used to create the component calling this method
168 static void setContextDocumentModified(
169 const ComponentContext
& _rContext
172 /** gets the window of the ObjectInspector in which an property handler lives
174 The method looks up a value called "DialogParentWindow" in the given UNO copmonent context,
175 queries it for XWindow, and returns the respective Window*. If either of those steps fails,
176 this is asserted in a non-product version, and silently ignore otherwise.
179 the component context which was used to create the component calling this method
181 static Window
* getDialogParentWindow( const ComponentContext
& _rContext
);
184 /** determines whether given PropertyAttributes require a to-be-created
185 <type scope="com::sun::star::inspection">XPropertyControl</type> to be read-only
187 @param _nPropertyAttributes
188 the attributes of the property which should be reflected by a to-be-created
189 <type scope="com::sun::star::inspection">XPropertyControl</type>
191 inline static sal_Bool
requiresReadOnlyControl( sal_Int16 _nPropertyAttributes
)
193 return ( _nPropertyAttributes
& ::com::sun::star::beans::PropertyAttribute::READONLY
) != 0;
197 PropertyHandlerHelper(); // never implemented
198 PropertyHandlerHelper( const PropertyHandlerHelper
& ); // never implemented
199 PropertyHandlerHelper
& operator=( const PropertyHandlerHelper
& ); // never implemented
202 //........................................................................
204 //........................................................................
206 #endif // EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */