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 <memory>
23 #include <sfx2/sidebar/PanelLayout.hxx>
24 #include <sfx2/sidebar/ControllerItem.hxx>
25 #include <svl/intitem.hxx>
26 #include <svl/poolitem.hxx>
27 #include <svl/eitem.hxx>
28 #include <svx/rulritem.hxx>
29 
30 namespace sw::sidebar {
31 
32 class PageHeaderPanel :
33     public PanelLayout,
34     public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
35 {
36 public:
37     static std::unique_ptr<PanelLayout> Create(
38         weld::Widget* pParent,
39         SfxBindings* pBindings);
40 
41     virtual void NotifyItemUpdate(
42         const sal_uInt16 nSId,
43         const SfxItemState eState,
44         const SfxPoolItem* pState) override;
45 
GetControlState(const sal_uInt16,boost::property_tree::ptree &)46     virtual void GetControlState(
47         const sal_uInt16 /*nSId*/,
48         boost::property_tree::ptree& /*rState*/) override {};
49 
GetBindings() const50     SfxBindings* GetBindings() const { return mpBindings; }
51     PageHeaderPanel(
52         weld::Widget* pParent,
53         SfxBindings* pBindings);
54     virtual ~PageHeaderPanel() override;
55 
56 private:
57 
58     SfxBindings* mpBindings;
59 
60     ::sfx2::sidebar::ControllerItem maHFToggleController;
61     ::sfx2::sidebar::ControllerItem maMetricController;
62     ::sfx2::sidebar::ControllerItem maHeaderLRMarginController;
63     ::sfx2::sidebar::ControllerItem maHeaderSpacingController;
64     ::sfx2::sidebar::ControllerItem maHeaderLayoutController;
65 
66     FieldUnit meFUnit;
67 
68     OUString aCustomEntry;
69 
70     void Initialize();
71     void SetMarginsAndSpacingFieldUnit();
72     void UpdateHeaderCheck();
73     void UpdateMarginControl();
74     void UpdateSpacingControl();
75     void UpdateLayoutControl();
76 
77     ::std::unique_ptr<SfxBoolItem>        mpHeaderItem;
78     ::std::unique_ptr<SvxLongLRSpaceItem> mpHeaderLRMarginItem;
79     ::std::unique_ptr<SvxLongULSpaceItem> mpHeaderSpacingItem;
80     ::std::unique_ptr<SfxInt16Item>       mpHeaderLayoutItem;
81 
82     std::unique_ptr<weld::CheckButton> mxHeaderToggle;
83     std::unique_ptr<weld::ComboBox> mxHeaderSpacingLB;
84     std::unique_ptr<weld::ComboBox> mxHeaderMarginPresetLB;
85     std::unique_ptr<weld::ComboBox> mxHeaderLayoutLB;
86     std::unique_ptr<weld::Label> mxCustomEntry;
87 
88     static FieldUnit GetCurrentUnit(SfxItemState eState, const SfxPoolItem* pState);
89 
90     DECL_LINK( HeaderToggleHdl, weld::Toggleable&, void );
91     DECL_LINK( HeaderLRMarginHdl, weld::ComboBox&, void);
92     DECL_LINK( HeaderSpacingHdl, weld::ComboBox&, void);
93     DECL_LINK( HeaderLayoutHdl, weld::ComboBox&, void);
94 };
95 
96 } //end of namespace sw::sidebar
97 
98 
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
100