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 .
19 #ifndef INCLUDED_SVX_SOURCE_SIDEBAR_POSSIZE_POSSIZEPROPERTYPANEL_HXX
20 #define INCLUDED_SVX_SOURCE_SIDEBAR_POSSIZE_POSSIZEPROPERTYPANEL_HXX
22 #include <sfx2/sidebar/ControllerItem.hxx>
23 #include <sfx2/sidebar/IContextChangeReceiver.hxx>
24 #include <sfx2/weldutils.hxx>
25 #include <sfx2/sidebar/PanelLayout.hxx>
26 #include <svl/poolitem.hxx>
27 #include <tools/fldunit.hxx>
28 #include <tools/fract.hxx>
29 #include <com/sun/star/ui/XSidebar.hpp>
30 #include <basegfx/range/b2drange.hxx>
31 #include <vcl/EnumContext.hxx>
32 #include <vcl/customweld.hxx>
33 #include <vcl/weld.hxx>
41 namespace svx::sidebar
{
43 class PosSizePropertyPanel
45 public ::sfx2::sidebar::IContextChangeReceiver
,
46 public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
49 virtual ~PosSizePropertyPanel() override
;
51 static std::unique_ptr
<PanelLayout
> Create(
52 weld::Widget
* pParent
,
53 const css::uno::Reference
<css::frame::XFrame
>& rxFrame
,
54 SfxBindings
* pBindings
,
55 const css::uno::Reference
<css::ui::XSidebar
>& rxSidebar
);
57 virtual void HandleContextChange(
58 const vcl::EnumContext
& rContext
) override
;
60 virtual void NotifyItemUpdate(
61 const sal_uInt16 nSId
,
62 const SfxItemState eState
,
63 const SfxPoolItem
* pState
) override
;
65 virtual void DumpAsPropertyTree(tools::JsonWriter
&) override
;
67 SfxBindings
* GetBindings() { return mpBindings
;}
69 // constructor/destructor
71 weld::Widget
* pParent
,
72 const css::uno::Reference
<css::frame::XFrame
>& rxFrame
,
73 SfxBindings
* pBindings
,
74 css::uno::Reference
<css::ui::XSidebar
> xSidebar
);
76 virtual void GetControlState(
77 const sal_uInt16 nSId
,
78 boost::property_tree::ptree
& rState
) override
;
82 std::unique_ptr
<weld::Label
> mxFtPosX
;
83 std::unique_ptr
<weld::MetricSpinButton
> mxMtrPosX
;
84 std::unique_ptr
<weld::Label
> mxFtPosY
;
85 std::unique_ptr
<weld::MetricSpinButton
> mxMtrPosY
;
88 std::unique_ptr
<weld::Label
> mxFtWidth
;
89 std::unique_ptr
<weld::MetricSpinButton
> mxMtrWidth
;
90 std::unique_ptr
<weld::Label
> mxFtHeight
;
91 std::unique_ptr
<weld::MetricSpinButton
> mxMtrHeight
;
92 std::unique_ptr
<weld::CheckButton
> mxCbxScale
;
95 std::unique_ptr
<weld::Label
> mxFtAngle
;
96 std::unique_ptr
<weld::MetricSpinButton
> mxMtrAngle
;
99 std::unique_ptr
<svx::DialControl
> mxCtrlDial
;
100 std::unique_ptr
<weld::CustomWeld
> mxDial
;
103 std::unique_ptr
<weld::Label
> mxFtFlip
;
104 std::unique_ptr
<weld::Toolbar
> mxFlipTbx
;
105 std::unique_ptr
<ToolbarUnoDispatcher
> mxFlipDispatch
;
107 std::unique_ptr
<weld::Toolbar
> mxArrangeTbx
;
108 std::unique_ptr
<ToolbarUnoDispatcher
> mxArrangeDispatch
;
109 std::unique_ptr
<weld::Toolbar
> mxArrangeTbx2
;
110 std::unique_ptr
<ToolbarUnoDispatcher
> mxArrangeDispatch2
;
112 std::unique_ptr
<weld::Toolbar
> mxAlignTbx
;
113 std::unique_ptr
<ToolbarUnoDispatcher
> mxAlignDispatch
;
114 std::unique_ptr
<weld::Toolbar
> mxAlignTbx2
;
115 std::unique_ptr
<ToolbarUnoDispatcher
> mxAlignDispatch2
;
117 //edit objects button for online's mobile view
118 std::unique_ptr
<weld::Button
> mxBtnEditOLEObject
;
120 // Internal variables
121 basegfx::B2DRange maRect
;
122 basegfx::B2DRange maWorkArea
;
123 const SdrView
* mpView
;
124 sal_uInt32 mlOldWidth
;
125 sal_uInt32 mlOldHeight
;
131 bool mbFieldMetricOutDated
;
134 ::sfx2::sidebar::ControllerItem maTransfPosXControl
;
135 ::sfx2::sidebar::ControllerItem maTransfPosYControl
;
136 ::sfx2::sidebar::ControllerItem maTransfWidthControl
;
137 ::sfx2::sidebar::ControllerItem maTransfHeightControl
;
139 ::sfx2::sidebar::ControllerItem maSvxAngleControl
;
140 ::sfx2::sidebar::ControllerItem maRotXControl
;
141 ::sfx2::sidebar::ControllerItem maRotYControl
;
142 ::sfx2::sidebar::ControllerItem maProPosControl
;
143 ::sfx2::sidebar::ControllerItem maProSizeControl
;
144 ::sfx2::sidebar::ControllerItem maAutoWidthControl
;
145 ::sfx2::sidebar::ControllerItem maAutoHeightControl
;
146 ::sfx2::sidebar::ControllerItem m_aMetricCtl
;
148 vcl::EnumContext maContext
;
149 SfxBindings
* mpBindings
;
151 bool mbSizeProtected
: 1;
152 bool mbPositionProtected
: 1;
153 bool mbAutoWidth
: 1;
154 bool mbAutoHeight
: 1;
155 bool mbAdjustEnabled
: 1;
157 css::uno::Reference
<css::ui::XSidebar
> mxSidebar
;
159 DECL_LINK( ChangePosXHdl
, weld::MetricSpinButton
&, void );
160 DECL_LINK( ChangePosYHdl
, weld::MetricSpinButton
&, void );
161 DECL_LINK( ChangeWidthHdl
, weld::MetricSpinButton
&, void );
162 DECL_LINK( ChangeHeightHdl
, weld::MetricSpinButton
&, void );
163 DECL_LINK( ClickAutoHdl
, weld::Toggleable
&, void );
164 DECL_LINK( RotationHdl
, svx::DialControl
&, void );
165 DECL_STATIC_LINK( PosSizePropertyPanel
, ClickObjectEditHdl
, weld::Button
&, void );
170 void MetricState(SfxItemState eState
, const SfxPoolItem
* pState
, const Fraction
& rUIScale
);
171 static FieldUnit
GetCurrentUnit( SfxItemState eState
, const SfxPoolItem
* pState
);
172 void DisableControls();
173 void SetPosSizeMinMax(const Fraction
& rUIScale
);
175 /** Check if the UI scale has changed and handle such a change.
176 UI scale is an SD only feature. The UI scale is represented by items
177 ATTR_OPTIONS_SCALE_X and
178 ATTR_OPTIONS_SCALE_Y.
179 As we have no direct access (there is no dependency of svx on sd) we have to
180 use a small trick (aka hack):
181 a) call this method whenever a change of the metric item is notified,
182 b) check if the UI scale has changed (strangely, the UI scale value is available at the SdrModel.
183 c) invalidate the items for position and size to trigger notifications of their current values.
185 void UpdateUIScale(const Fraction
& rUIScale
);
189 } // end of namespace svx::sidebar
192 #endif // INCLUDED_SVX_SOURCE_SIDEBAR_POSSIZE_POSSIZEPROPERTYPANEL_HXX
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */