LibreOffice Module extensions (master) 1
usercontrol.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 "commoncontrol.hxx"
23#include <svtools/inettbc.hxx>
24#include <svl/zforlist.hxx>
25
27
28namespace pcr
29{
30 //= OFormatSampleControl
33 {
34 private:
35 std::unique_ptr<weld::FormattedSpinButton> m_xSpinButton;
36 std::unique_ptr<weld::Entry> m_xEntry;
37
38 DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
39
40 public:
41 OFormatSampleControl(std::unique_ptr<weld::Container> xWidget, std::unique_ptr<weld::Builder> xBuilder, bool bReadOnly);
42
43 // XPropertyControl
44 virtual css::uno::Any SAL_CALL getValue() override;
45 virtual void SAL_CALL setValue( const css::uno::Any& _value ) override;
46 virtual css::uno::Type SAL_CALL getValueType() override;
47
48 virtual void SAL_CALL disposing() override
49 {
50 m_xEntry.reset();
51 m_xSpinButton.reset();
53 }
54
55 virtual void SetModifyHandler() override
56 {
57 m_xEntry->connect_focus_in( LINK( this, CommonBehaviourControlHelper, GetFocusHdl ) );
58 m_xEntry->connect_focus_out( LINK( this, CommonBehaviourControlHelper, LoseFocusHdl ) );
59 m_xSpinButton->connect_value_changed(LINK(this, CommonBehaviourControlHelper, FormattedModifiedHdl));
60 m_xSpinButton->connect_changed(LINK(this, CommonBehaviourControlHelper, EditModifiedHdl));
61 }
62
63 void SetFormatSupplier(const SvNumberFormatsSupplierObj* pSupplier);
64
65 virtual weld::Widget* getWidget() override { return getTypedControlWindow(); }
66
73 static double getPreviewValue(SvNumberFormatter const * pNF, sal_Int32 nFormatKey);
74
75 private:
76 static double getPreviewValue( const SvNumberformat& i_rEntry );
77 };
78
79 //= FormatDescription
81 {
83 sal_Int32 nKey;
84 };
85
86 //= OFormattedNumericControl
89 {
90 public:
91 OFormattedNumericControl(std::unique_ptr<weld::FormattedSpinButton> xWidget, std::unique_ptr<weld::Builder> xBuilder, bool bReadOnly);
92
93 // XPropertyControl
94 virtual css::uno::Any SAL_CALL getValue() override;
95 virtual void SAL_CALL setValue( const css::uno::Any& _value ) override;
96 virtual css::uno::Type SAL_CALL getValueType() override;
97
98 void SetFormatDescription( const FormatDescription& rDesc );
99
100 // make some FormattedField methods available
101 void SetDecimalDigits(sal_uInt16 nPrecision) { getTypedControlWindow()->GetFormatter().SetDecimalDigits(nPrecision); }
102 void SetDefaultValue(double dDef) { getTypedControlWindow()->GetFormatter().SetDefaultValue(dDef); }
103
104 virtual void SetModifyHandler() override
105 {
107 getTypedControlWindow()->connect_value_changed(LINK(this, CommonBehaviourControlHelper, FormattedModifiedHdl));
108 getTypedControlWindow()->connect_changed(LINK(this, CommonBehaviourControlHelper, EditModifiedHdl));
109 }
110
111 virtual weld::Widget* getWidget() override { return getTypedControlWindow(); }
112
113 protected:
114 virtual ~OFormattedNumericControl() override;
115 };
116
117 //= OFileUrlControl
120 {
121 private:
122 DECL_LINK(URLModifiedHdl, weld::ComboBox&, void);
123 public:
124 OFileUrlControl(std::unique_ptr<SvtURLBox> xWidget, std::unique_ptr<weld::Builder> xBuilder, bool bReadOnly);
125
126 // XPropertyControl
127 virtual css::uno::Any SAL_CALL getValue() override;
128 virtual void SAL_CALL setValue( const css::uno::Any& _value ) override;
129 virtual css::uno::Type SAL_CALL getValueType() override;
130
131 virtual void SetModifyHandler() override
132 {
134 SvtURLBox* pControlWindow = getTypedControlWindow();
135 // tdf#140239 and tdf#141084 don't notify that the control has changed content until focus-out
136 pControlWindow->connect_focus_out(LINK(this, CommonBehaviourControlHelper, LoseFocusHdl));
137 pControlWindow->connect_changed(LINK(this, OFileUrlControl, URLModifiedHdl));
138 }
139
140 virtual weld::Widget* getWidget() override { return getTypedControlWindow()->getWidget(); }
141
142 protected:
143 virtual ~OFileUrlControl() override;
144 };
145
146} // namespace pcr
147
148/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void connect_changed(const Link< weld::ComboBox &, void > &rLink)
void connect_focus_out(const Link< weld::Widget &, void > &rLink)
A helper class for implementing the <type scope="css::inspection">XPropertyControl</type> or one of i...
implements a base class for <type scope="css::inspection">XPropertyControl</type> implementations
TControlWindow * getTypedControlWindow()
virtual void SAL_CALL disposing() override
DECL_LINK(URLModifiedHdl, weld::ComboBox &, void)
OFileUrlControl(std::unique_ptr< SvtURLBox > xWidget, std::unique_ptr< weld::Builder > xBuilder, bool bReadOnly)
virtual weld::Widget * getWidget() override
virtual css::uno::Any SAL_CALL getValue() override
virtual ~OFileUrlControl() override
virtual css::uno::Type SAL_CALL getValueType() override
virtual void SetModifyHandler() override
virtual void SAL_CALL setValue(const css::uno::Any &_value) override
void SetFormatSupplier(const SvNumberFormatsSupplierObj *pSupplier)
Definition: usercontrol.cxx:57
std::unique_ptr< weld::FormattedSpinButton > m_xSpinButton
Definition: usercontrol.hxx:35
DECL_LINK(KeyInputHdl, const KeyEvent &, bool)
virtual void SAL_CALL disposing() override
Definition: usercontrol.hxx:48
virtual weld::Widget * getWidget() override
Definition: usercontrol.hxx:65
virtual void SetModifyHandler() override
Definition: usercontrol.hxx:55
OFormatSampleControl(std::unique_ptr< weld::Container > xWidget, std::unique_ptr< weld::Builder > xBuilder, bool bReadOnly)
Definition: usercontrol.cxx:78
static double getPreviewValue(SvNumberFormatter const *pNF, sal_Int32 nFormatKey)
returns the default preview value for the given format key
std::unique_ptr< weld::Entry > m_xEntry
Definition: usercontrol.hxx:36
virtual css::uno::Type SAL_CALL getValueType() override
virtual void SAL_CALL setValue(const css::uno::Any &_value) override
Definition: usercontrol.cxx:90
virtual css::uno::Any SAL_CALL getValue() override
virtual css::uno::Type SAL_CALL getValueType() override
virtual weld::Widget * getWidget() override
virtual void SetModifyHandler() override
void SetFormatDescription(const FormatDescription &rDesc)
virtual void SAL_CALL setValue(const css::uno::Any &_value) override
OFormattedNumericControl(std::unique_ptr< weld::FormattedSpinButton > xWidget, std::unique_ptr< weld::Builder > xBuilder, bool bReadOnly)
void SetDecimalDigits(sal_uInt16 nPrecision)
virtual css::uno::Any SAL_CALL getValue() override
void SetDefaultValue(double dDef)
virtual ~OFormattedNumericControl() override
bool bReadOnly
a property handler for any virtual string properties
Definition: browserline.cxx:39
CommonBehaviourControl< css::inspection::XPropertyControl, weld::FormattedSpinButton > OFormattedNumericControl_Base
Definition: usercontrol.hxx:87
CommonBehaviourControl< css::inspection::XPropertyControl, weld::Container > OFormatSampleControl_Base
Definition: usercontrol.hxx:31
CommonBehaviourControl< css::inspection::XPropertyControl, SvtURLBox > OFileUrlControl_Base
SvNumberFormatsSupplierObj * pSupplier
Definition: usercontrol.hxx:82