LibreOffice Module extensions (master) 1
handlerhelper.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <com/sun/star/beans/Property.hpp>
23#include <com/sun/star/uno/XComponentContext.hpp>
24#include <com/sun/star/script/XTypeConverter.hpp>
25#include <com/sun/star/inspection/XPropertyControlFactory.hpp>
26#include <com/sun/star/beans/PropertyAttribute.hpp>
27#include <com/sun/star/beans/Optional.hpp>
28#include <unotools/resmgr.hxx>
29
30#include <memory>
31#include <vector>
32
33namespace weld { class Builder; class Widget; class Window; }
34namespace com::sun::star {
35 namespace inspection {
36 struct LineDescriptor;
37 }
38}
39
40namespace pcr
41{
42
43
44 //= PropertyHandlerHelper
45
47 {
48 public:
51 static void describePropertyLine(
52 const css::beans::Property& _rProperty,
53 css::inspection::LineDescriptor& /* [out] */ _out_rDescriptor,
54 const css::uno::Reference< css::inspection::XPropertyControlFactory >& _rxControlFactory
55 );
56
59 static css::uno::Any convertToPropertyValue(
60 const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
61 const css::uno::Reference< css::script::XTypeConverter >& _rxTypeConverter,
62 const css::beans::Property& _rProperty,
63 const css::uno::Any& _rControlValue
64 );
65
67 static css::uno::Any convertToControlValue(
68 const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
69 const css::uno::Reference< css::script::XTypeConverter >& _rxTypeConverter,
70 const css::uno::Any& _rPropertyValue,
71 const css::uno::Type& _rControlValueType
72 );
73
92 static css::uno::Reference< css::inspection::XPropertyControl >
94 const css::uno::Reference< css::inspection::XPropertyControlFactory >& _rxControlFactory,
95 std::vector< OUString >&& _rInitialListEntries,
96 bool _bReadOnlyControl,
97 bool _bSorted
98 );
99
118 static css::uno::Reference< css::inspection::XPropertyControl >
120 const css::uno::Reference< css::inspection::XPropertyControlFactory >& _rxControlFactory,
121 const TranslateId* pTransIds, size_t nElements,
122 bool _bReadOnlyControl
123 );
124
140 static css::uno::Reference< css::inspection::XPropertyControl >
142 const css::uno::Reference< css::inspection::XPropertyControlFactory >& _rxControlFactory,
143 std::vector< OUString >&& _rInitialListEntries,
144 bool _bSorted
145 );
146
165 static css::uno::Reference< css::inspection::XPropertyControl >
167 const css::uno::Reference< css::inspection::XPropertyControlFactory >& _rxControlFactory,
168 sal_Int16 _nDigits,
169 const css::beans::Optional< double >& _rMinValue,
170 const css::beans::Optional< double >& _rMaxValue
171 );
172
183 static void setContextDocumentModified(
184 const css::uno::Reference< css::uno::XComponentContext > & _rContext
185 );
186
187 static css::uno::Reference< css::uno::XInterface > getContextDocument( const css::uno::Reference<css::uno::XComponentContext> & _rContext );
188
190 static css::uno::Reference< css::uno::XInterface > getContextDocument_throw( const css::uno::Reference<css::uno::XComponentContext> & _rContext );
191
201 static weld::Window* getDialogParentFrame( const css::uno::Reference< css::uno::XComponentContext > & _rContext );
202
203
211 static bool requiresReadOnlyControl( sal_Int16 _nPropertyAttributes )
212 {
213 return ( _nPropertyAttributes & css::beans::PropertyAttribute::READONLY ) != 0;
214 }
215
216 static std::unique_ptr<weld::Builder> makeBuilder(const OUString& rUIFile, const css::uno::Reference<css::uno::XComponentContext>& rContext);
217
218 static void setBuilderParent(const css::uno::Reference<css::uno::XComponentContext>& rContext, weld::Widget* pParent);
219
220 static void clearBuilderParent(const css::uno::Reference<css::uno::XComponentContext>& rContext);
221
222 private:
225 };
226
227
228} // namespace pcr
229
230
231/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static css::uno::Reference< css::uno::XInterface > getContextDocument(const css::uno::Reference< css::uno::XComponentContext > &_rContext)
static css::uno::Reference< css::inspection::XPropertyControl > createComboBoxControl(const css::uno::Reference< css::inspection::XPropertyControlFactory > &_rxControlFactory, std::vector< OUString > &&_rInitialListEntries, bool _bSorted)
creates an <member scope="css::inspection">PropertyControlType::ComboBox</member>-type control and fi...
static css::uno::Reference< css::uno::XInterface > getContextDocument_throw(const css::uno::Reference< css::uno::XComponentContext > &_rContext)
static css::uno::Reference< css::inspection::XPropertyControl > createListBoxControl(const css::uno::Reference< css::inspection::XPropertyControlFactory > &_rxControlFactory, std::vector< OUString > &&_rInitialListEntries, bool _bReadOnlyControl, bool _bSorted)
creates an <member scope="css::inspection">PropertyControlType::ListBox</member>-type control and fil...
PropertyHandlerHelper(const PropertyHandlerHelper &)=delete
static css::uno::Any convertToPropertyValue(const css::uno::Reference< css::uno::XComponentContext > &_rxContext, const css::uno::Reference< css::script::XTypeConverter > &_rxTypeConverter, const css::beans::Property &_rProperty, const css::uno::Any &_rControlValue)
helper for implementing XPropertyHandler::convertToPropertyValue
static void setBuilderParent(const css::uno::Reference< css::uno::XComponentContext > &rContext, weld::Widget *pParent)
static weld::Window * getDialogParentFrame(const css::uno::Reference< css::uno::XComponentContext > &_rContext)
gets the window of the ObjectInspector in which a property handler lives
PropertyHandlerHelper & operator=(const PropertyHandlerHelper &)=delete
static void clearBuilderParent(const css::uno::Reference< css::uno::XComponentContext > &rContext)
static bool requiresReadOnlyControl(sal_Int16 _nPropertyAttributes)
determines whether given PropertyAttributes require a to-be-created <type scope="css::inspection">XPr...
static std::unique_ptr< weld::Builder > makeBuilder(const OUString &rUIFile, const css::uno::Reference< css::uno::XComponentContext > &rContext)
static void setContextDocumentModified(const css::uno::Reference< css::uno::XComponentContext > &_rContext)
marks the document passed in our UNO context as modified
static css::uno::Reference< css::inspection::XPropertyControl > createListBoxControl(const css::uno::Reference< css::inspection::XPropertyControlFactory > &_rxControlFactory, const TranslateId *pTransIds, size_t nElements, bool _bReadOnlyControl)
creates an <member scope="css::inspection">PropertyControlType::ListBox</member>-type control and fil...
static css::uno::Any convertToControlValue(const css::uno::Reference< css::uno::XComponentContext > &_rxContext, const css::uno::Reference< css::script::XTypeConverter > &_rxTypeConverter, const css::uno::Any &_rPropertyValue, const css::uno::Type &_rControlValueType)
helper for implementing XPropertyHandler::convertToControlValue
static void describePropertyLine(const css::beans::Property &_rProperty, css::inspection::LineDescriptor &_out_rDescriptor, const css::uno::Reference< css::inspection::XPropertyControlFactory > &_rxControlFactory)
helper for implementing XPropertyHandler::describePropertyLine in a generic way
static css::uno::Reference< css::inspection::XPropertyControl > createNumericControl(const css::uno::Reference< css::inspection::XPropertyControlFactory > &_rxControlFactory, sal_Int16 _nDigits, const css::beans::Optional< double > &_rMinValue, const css::beans::Optional< double > &_rMaxValue)
creates an <member scope="css::inspection">PropertyControlType::NumericField</member>-type control an...
a property handler for any virtual string properties
Definition: browserline.cxx:39