bump product version to 6.3.0.0.beta1
[LibreOffice.git] / extensions / source / propctrlr / handlerhelper.hxx
blobe1eeed0460813a0ed26df45f5626ee3ecda0d30e
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 weld { class Window; }
35 namespace com { namespace sun { namespace star {
36 namespace inspection {
37 struct LineDescriptor;
39 } } }
41 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 css::beans::Property& _rProperty,
54 css::inspection::LineDescriptor& /* [out] */ _out_rDescriptor,
55 const css::uno::Reference< css::inspection::XPropertyControlFactory >& _rxControlFactory
58 /** helper for implementing XPropertyHandler::convertToPropertyValue
60 static css::uno::Any convertToPropertyValue(
61 const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
62 const css::uno::Reference< css::script::XTypeConverter >& _rxTypeConverter,
63 const css::beans::Property& _rProperty,
64 const css::uno::Any& _rControlValue
67 /// helper for implementing XPropertyHandler::convertToControlValue
68 static css::uno::Any convertToControlValue(
69 const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
70 const css::uno::Reference< css::script::XTypeConverter >& _rxTypeConverter,
71 const css::uno::Any& _rPropertyValue,
72 const css::uno::Type& _rControlValueType
75 /** creates an <member scope="css::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 css::uno::Reference< css::inspection::XPropertyControl >
94 createListBoxControl(
95 const css::uno::Reference< css::inspection::XPropertyControlFactory >& _rxControlFactory,
96 const std::vector< OUString >& _rInitialListEntries,
97 bool _bReadOnlyControl,
98 bool _bSorted
101 /** creates an <member scope="css::inspection">PropertyControlType::ListBox</member>-type control
102 and fills it with initial values.
104 @param _rxControlFactory
105 A control factory. Must not be <NULL/>.
107 @param pTransIds
108 the initial translation ids for the value of the control
110 @param nElements
111 the count of initial values of the control
113 @param _bReadOnlyControl
114 determines whether the control should be read-only
116 @return
117 the newly created control
119 static css::uno::Reference< css::inspection::XPropertyControl >
120 createListBoxControl(
121 const css::uno::Reference< css::inspection::XPropertyControlFactory >& _rxControlFactory,
122 const char** pTransIds, size_t nElements,
123 bool _bReadOnlyControl
126 /** creates an <member scope="css::inspection">PropertyControlType::ComboBox</member>-type control
127 and fills it with initial values
129 @param _rxControlFactory
130 A control factory. Must not be <NULL/>.
132 @param _rInitialListEntries
133 the initial values of the control
135 @param _bSorted
136 determines whether the list entries should be sorted
138 @return
139 the newly created control
141 static css::uno::Reference< css::inspection::XPropertyControl >
142 createComboBoxControl(
143 const css::uno::Reference< css::inspection::XPropertyControlFactory >& _rxControlFactory,
144 const std::vector< OUString >& _rInitialListEntries,
145 bool _bSorted
148 /** creates an <member scope="css::inspection">PropertyControlType::NumericField</member>-type control
149 and initializes it
151 @param _rxControlFactory
152 A control factory. Must not be <NULL/>.
153 @param _nDigits
154 number of decimal digits for the control
155 (<member scope="css::inspection">XNumericControl::DecimalDigits</member>)
156 @param _rMinValue
157 minimum value which can be entered in the control
158 (<member scope="css::inspection">XNumericControl::MinValue</member>)
159 @param _rMaxValue
160 maximum value which can be entered in the control
161 (<member scope="css::inspection">XNumericControl::MaxValue</member>)
163 @return
164 the newly created control
166 static css::uno::Reference< css::inspection::XPropertyControl >
167 createNumericControl(
168 const css::uno::Reference< css::inspection::XPropertyControlFactory >& _rxControlFactory,
169 sal_Int16 _nDigits,
170 const css::beans::Optional< double >& _rMinValue,
171 const css::beans::Optional< double >& _rMaxValue
174 /** marks the document passed in our UNO context as modified
176 The method looks up a value called "ContextDocument" in the given UNO component context,
177 queries it for the ->css::util::XModifiable interface, and calls its
178 setModified method. If either of those steps fails, this is asserted in a non-product
179 version, and silently ignore otherwise.
181 @param _rContext
182 the component context which was used to create the component calling this method
184 static void setContextDocumentModified(
185 const css::uno::Reference< css::uno::XComponentContext > & _rContext
188 static css::uno::Reference< css::uno::XInterface > getContextDocument( const css::uno::Reference<css::uno::XComponentContext> & _rContext );
190 /// @throws css::uno::RuntimeException
191 static css::uno::Reference< css::uno::XInterface > getContextDocument_throw( const css::uno::Reference<css::uno::XComponentContext> & _rContext );
193 /** gets the window of the ObjectInspector in which a property handler lives
195 The method looks up a value called "DialogParentWindow" in the given UNO component context,
196 queries it for XWindow, and returns the respective vcl::Window*. If either of those steps fails,
197 this is asserted in a non-product version, and silently ignore otherwise.
199 @param _rContext
200 the component context which was used to create the component calling this method
202 static vcl::Window* getDialogParentWindow( const css::uno::Reference< css::uno::XComponentContext > & _rContext );
203 static weld::Window* getDialogParentFrame( const css::uno::Reference< css::uno::XComponentContext > & _rContext );
206 /** determines whether given PropertyAttributes require a to-be-created
207 <type scope="css::inspection">XPropertyControl</type> to be read-only
209 @param _nPropertyAttributes
210 the attributes of the property which should be reflected by a to-be-created
211 <type scope="css::inspection">XPropertyControl</type>
213 static bool requiresReadOnlyControl( sal_Int16 _nPropertyAttributes )
215 return ( _nPropertyAttributes & css::beans::PropertyAttribute::READONLY ) != 0;
218 private:
219 PropertyHandlerHelper( const PropertyHandlerHelper& ) = delete;
220 PropertyHandlerHelper& operator=( const PropertyHandlerHelper& ) = delete;
224 } // namespace pcr
227 #endif // INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX
229 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */