bump product version to 5.0.4.1
[LibreOffice.git] / extensions / source / propctrlr / handlerhelper.hxx
blob14ff67f707eb0048e9e99459e54003adf6711e06
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX
21 #define INCLUDED_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>
31 #include <vector>
33 namespace vcl { class Window; }
34 namespace com { namespace sun { namespace star {
35 namespace inspection {
36 struct LineDescriptor;
38 } } }
40 namespace pcr
45 //= PropertyHandlerHelper
47 class PropertyHandlerHelper
49 public:
50 /** helper for implementing XPropertyHandler::describePropertyLine in a generic way
52 static void describePropertyLine(
53 const ::com::sun::star::beans::Property& _rProperty,
54 ::com::sun::star::inspection::LineDescriptor& /* [out] */ _out_rDescriptor,
55 const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory
58 /** helper for implementing XPropertyHandler::convertToPropertyValue
60 static ::com::sun::star::uno::Any convertToPropertyValue(
61 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
62 const ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter >& _rxTypeConverter,
63 const ::com::sun::star::beans::Property& _rProperty,
64 const ::com::sun::star::uno::Any& _rControlValue
67 /// helper for implementing XPropertyHandler::convertToControlValue
68 static ::com::sun::star::uno::Any convertToControlValue(
69 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
70 const ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter >& _rxTypeConverter,
71 const ::com::sun::star::uno::Any& _rPropertyValue,
72 const ::com::sun::star::uno::Type& _rControlValueType
75 /** creates an <member scope="com::sun::star::inspection">PropertyControlType::ListBox</member>-type control
76 and fills it with initial values
78 @param _rxControlFactory
79 A control factory. Must not be <NULL/>.
81 @param _rInitialListEntries
82 the initial values of the control
84 @param _bReadOnlyControl
85 determines whether the control should be read-only
87 @param _bSorted
88 determines whether the list entries should be sorted
90 @return
91 the newly created control
93 static ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
94 createListBoxControl(
95 const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory,
96 const ::std::vector< OUString >& _rInitialListEntries,
97 bool _bReadOnlyControl,
98 bool _bSorted
101 /** creates an <member scope="com::sun::star::inspection">PropertyControlType::ComboBox</member>-type control
102 and fills it with initial values
104 @param _rxControlFactory
105 A control factory. Must not be <NULL/>.
107 @param _rInitialListEntries
108 the initial values of the control
110 @param _bReadOnlyControl
111 determines whether the control should be read-only
113 @param _bSorted
114 determines whether the list entries should be sorted
116 @return
117 the newly created control
119 static ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
120 createComboBoxControl(
121 const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory,
122 const ::std::vector< OUString >& _rInitialListEntries,
123 bool _bReadOnlyControl,
124 bool _bSorted
127 /** creates an <member scope="com::sun::star::inspection">PropertyControlType::NumericField</member>-type control
128 and initializes it
130 @param _rxControlFactory
131 A control factory. Must not be <NULL/>.
132 @param _nDigits
133 number of decimal digits for the control
134 (<member scope="com::sun::star::inspection">XNumericControl::DecimalDigits</member>)
135 @param _rMinValue
136 minimum value which can be entered in the control
137 (<member scope="com::sun::star::inspection">XNumericControl::MinValue</member>)
138 @param _rMaxValue
139 maximum value which can be entered in the control
140 (<member scope="com::sun::star::inspection">XNumericControl::MaxValue</member>)
141 @param _bReadOnlyControl
142 determines whether the control should be read-only
144 @return
145 the newly created control
147 static ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
148 createNumericControl(
149 const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory,
150 sal_Int16 _nDigits,
151 const ::com::sun::star::beans::Optional< double >& _rMinValue,
152 const ::com::sun::star::beans::Optional< double >& _rMaxValue,
153 bool _bReadOnlyControl
156 /** marks the document passed in our UNO context as modified
158 The method looks up a value called "ContextDocument" in the given UNO component context,
159 queries it for the ->com::sun::star::util::XModifiable interface, and calls its
160 setModified method. If either of those steps fails, this is asserted in a non-product
161 version, and silently ignore otherwise.
163 @param _rContext
164 the component context which was used to create the component calling this method
166 static void setContextDocumentModified(
167 const css::uno::Reference< css::uno::XComponentContext > & _rContext
170 static css::uno::Reference< css::uno::XInterface > getContextDocument( const css::uno::Reference<css::uno::XComponentContext> & _rContext );
172 static css::uno::Reference< css::uno::XInterface > getContextDocument_throw( const css::uno::Reference<css::uno::XComponentContext> & _rContext ) throw (css::uno::RuntimeException);
174 /** gets the window of the ObjectInspector in which an property handler lives
176 The method looks up a value called "DialogParentWindow" in the given UNO copmonent context,
177 queries it for XWindow, and returns the respective vcl::Window*. If either of those steps fails,
178 this is asserted in a non-product version, and silently ignore otherwise.
180 @param _rContext
181 the component context which was used to create the component calling this method
183 static vcl::Window* getDialogParentWindow( const css::uno::Reference< css::uno::XComponentContext > & _rContext );
186 /** determines whether given PropertyAttributes require a to-be-created
187 <type scope="com::sun::star::inspection">XPropertyControl</type> to be read-only
189 @param _nPropertyAttributes
190 the attributes of the property which should be reflected by a to-be-created
191 <type scope="com::sun::star::inspection">XPropertyControl</type>
193 inline static bool requiresReadOnlyControl( sal_Int16 _nPropertyAttributes )
195 return ( _nPropertyAttributes & ::com::sun::star::beans::PropertyAttribute::READONLY ) != 0;
198 private:
199 PropertyHandlerHelper( const PropertyHandlerHelper& ) SAL_DELETED_FUNCTION;
200 PropertyHandlerHelper& operator=( const PropertyHandlerHelper& ) SAL_DELETED_FUNCTION;
204 } // namespace pcr
207 #endif // INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX
209 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */