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 #ifndef INCLUDED_SW_SOURCE_UIBASE_SIDEBAR_PAGEFORMATPANEL_HXX
20 #define INCLUDED_SW_SOURCE_UIBASE_SIDEBAR_PAGEFORMATPANEL_HXX
21 
22 #include <com/sun/star/frame/XFrame.hpp>
23 
24 #include <svx/sidebar/PanelLayout.hxx>
25 
26 #include <sfx2/sidebar/ControllerItem.hxx>
27 
28 #include <svx/pageitem.hxx>
29 #include <svx/rulritem.hxx>
30 #include <svx/papersizelistbox.hxx>
31 
32 #include <vcl/fixed.hxx>
33 #include <vcl/lstbox.hxx>
34 #include <tools/fldunit.hxx>
35 #include <svl/poolitem.hxx>
36 #include <svx/relfld.hxx>
37 
38 #include <memory>
39 
40 namespace sw { namespace sidebar {
41 
42 class PageFormatPanel:
43     public PanelLayout,
44     public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
45 {
46 public:
47     static VclPtr<vcl::Window> Create(
48         vcl::Window* pParent,
49         const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame,
50         SfxBindings* pBindings);
51 
52     virtual void NotifyItemUpdate(
53         const sal_uInt16 nSId,
54         const SfxItemState eState,
55         const SfxPoolItem* pState) override;
56 
57     PageFormatPanel(
58         vcl::Window* pParent,
59         const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame,
60         SfxBindings* pBindings);
61     virtual ~PageFormatPanel() override;
62     virtual void dispose() override;
63 
64     static FieldUnit GetCurrentUnit( SfxItemState eState, const SfxPoolItem* pState );
65 
66 private:
67 
68     SfxBindings* mpBindings;
69 
70     VclPtr<PaperSizeListBox> mpPaperSizeBox;
71     VclPtr<SvxRelativeField> mpPaperWidth;
72     VclPtr<SvxRelativeField> mpPaperHeight;
73     VclPtr<ListBox> mpPaperOrientation;
74     VclPtr<ListBox> mpMarginSelectBox;
75     VclPtr<FixedText> mpCustomEntry;
76 
77     ::sfx2::sidebar::ControllerItem maPaperSizeController;
78     ::sfx2::sidebar::ControllerItem maPaperOrientationController;
79     ::sfx2::sidebar::ControllerItem maMetricController;
80     ::sfx2::sidebar::ControllerItem maSwPageLRControl;
81     ::sfx2::sidebar::ControllerItem maSwPageULControl;
82 
83     std::unique_ptr<SvxPageItem>          mpPageItem;
84     std::unique_ptr<SvxLongLRSpaceItem> mpPageLRMarginItem;
85     std::unique_ptr<SvxLongULSpaceItem> mpPageULMarginItem;
86 
87     FieldUnit meFUnit;
88     MapUnit meUnit;
89 
90     long mnPageLeftMargin;
91     long mnPageRightMargin;
92     long mnPageTopMargin;
93     long mnPageBottomMargin;
94     OUString aCustomEntry;
95 
96     void Initialize();
97     void SetMarginFieldUnit();
98     void UpdateMarginBox();
99     void ExecuteMarginLRChange( const long nPageLeftMargin, const long nPageRightMargin );
100     void ExecuteMarginULChange( const long nPageTopMargin, const long  nPageBottomMargin);
101     DECL_LINK(PaperFormatModifyHdl, ListBox&, void);
102     DECL_LINK(PaperSizeModifyHdl, Edit&, void);
103     DECL_LINK(PaperModifyMarginHdl, ListBox&, void );
104 };
105 
106 } } //end of namespace sw::sidebar
107 
108 #endif
109 
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
111