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 #pragma once
20 
21 #include <sfx2/sidebar/ControllerItem.hxx>
22 #include <sfx2/sidebar/IContextChangeReceiver.hxx>
23 #include <sfx2/sidebar/PanelLayout.hxx>
24 #include <svx/relfld.hxx>
25 
26 #include <com/sun/star/frame/XFrame.hpp>
27 #include <com/sun/star/ui/XSidebar.hpp>
28 
29 #include <svl/poolitem.hxx>
30 #include <tools/fldunit.hxx>
31 #include <vcl/EnumContext.hxx>
32 
33 class ToolbarUnoDispatcher;
34 
35 namespace svx::sidebar {
36 
37 class ParaPropertyPanel
38     : public PanelLayout,
39       public ::sfx2::sidebar::IContextChangeReceiver,
40       public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
41 {
42 public:
43     virtual ~ParaPropertyPanel() override;
44 
45     static std::unique_ptr<PanelLayout> Create (
46         weld::Widget* pParent,
47         const css::uno::Reference<css::frame::XFrame>& rxFrame,
48         SfxBindings* pBindings,
49         const css::uno::Reference<css::ui::XSidebar>& rxSidebar);
50 
GetBindings()51     SfxBindings* GetBindings() { return mpBindings;}
52 
53     virtual void HandleContextChange (
54         const vcl::EnumContext& rContext) override;
55 
56     virtual void NotifyItemUpdate(
57         const sal_uInt16 nSId,
58         const SfxItemState eState,
59         const SfxPoolItem* pState) override;
60 
GetControlState(const sal_uInt16,boost::property_tree::ptree &)61     virtual void GetControlState(
62         const sal_uInt16 /*nSId*/,
63         boost::property_tree::ptree& /*rState*/) override {};
64 
65     static FieldUnit GetCurrentUnit( SfxItemState eState, const SfxPoolItem* pState );
66 
67     ParaPropertyPanel (
68         weld::Widget* pParent,
69         const css::uno::Reference<css::frame::XFrame>& rxFrame,
70         SfxBindings* pBindings,
71         const css::uno::Reference<css::ui::XSidebar>& rxSidebar);
72 
73 private:
74     // UI controls
75     //Alignment
76     std::unique_ptr<weld::Toolbar> mxTBxHorzAlign;
77     std::unique_ptr<ToolbarUnoDispatcher> mxHorzAlignDispatch;
78     std::unique_ptr<weld::Toolbar> mxTBxVertAlign;
79     std::unique_ptr<ToolbarUnoDispatcher> mxVertAlignDispatch;
80     //NumBullet&Backcolor
81     std::unique_ptr<weld::Toolbar> mxTBxNumBullet;
82     std::unique_ptr<ToolbarUnoDispatcher> mxNumBulletDispatch;
83     std::unique_ptr<weld::Toolbar> mxTBxBackColor;
84     std::unique_ptr<ToolbarUnoDispatcher> mxBackColorDispatch;
85 
86     std::unique_ptr<weld::Toolbar> mxTBxWriteDirection;
87     std::unique_ptr<ToolbarUnoDispatcher> mxWriteDirectionDispatch;
88     std::unique_ptr<weld::Toolbar> mxTBxParaSpacing;
89     std::unique_ptr<ToolbarUnoDispatcher> mxParaSpacingDispatch;
90     std::unique_ptr<weld::Toolbar> mxTBxLineSpacing;
91     std::unique_ptr<ToolbarUnoDispatcher> mxLineSpacingDispatch;
92     std::unique_ptr<weld::Toolbar> mxTBxIndent;
93     std::unique_ptr<ToolbarUnoDispatcher> mxIndentDispatch;
94 
95     //Paragraph spacing
96     std::unique_ptr<SvxRelativeField> mxTopDist;
97     std::unique_ptr<SvxRelativeField> mxBottomDist;
98     std::unique_ptr<SvxRelativeField> mxLeftIndent;
99     std::unique_ptr<SvxRelativeField> mxRightIndent;
100     std::unique_ptr<SvxRelativeField> mxFLineIndent;
101 
102     // Data Member
103     tools::Long                maTxtLeft;
104     tools::Long                    maUpper;
105     tools::Long                    maLower;
106 
107     FieldUnit                       m_eMetricUnit;
108     FieldUnit                       m_last_eMetricUnit;
109     MapUnit                         m_eLRSpaceUnit;
110     MapUnit                         m_eULSpaceUnit;
111     // Control Items
112     ::sfx2::sidebar::ControllerItem  maLRSpaceControl;
113     ::sfx2::sidebar::ControllerItem  maULSpaceControl;
114     ::sfx2::sidebar::ControllerItem  m_aMetricCtl;
115 
116     vcl::EnumContext maContext;
117     SfxBindings* mpBindings;
118     css::uno::Reference<css::ui::XSidebar> mxSidebar;
119 
120     DECL_LINK(ModifyIndentHdl_Impl, weld::MetricSpinButton&, void);
121     DECL_LINK(ULSpaceHdl_Impl, weld::MetricSpinButton&, void);
122 
123     void StateChangedIndentImpl( SfxItemState eState, const SfxPoolItem* pState );
124     void StateChangedULImpl( SfxItemState eState, const SfxPoolItem* pState );
125 
126     void initial();
127     void ReSize();
128     void InitToolBoxIndent();
129     void InitToolBoxSpacing();
130     void limitMetricWidths();
131 };
132 
133 } // end of namespace svx::sidebar
134 
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
136