1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #ifndef _SW_SIDEBAR_PAGE_MARGIN_CONTROL_HXX_
23 #define _SW_SIDEBAR_PAGE_MARGIN_CONTROL_HXX_
24 
25 #include <svx/sidebar/PopupControl.hxx>
26 
27 #include <tools/fldunit.hxx>
28 #include <svl/poolitem.hxx>
29 #include <unotools/viewoptions.hxx>
30 
31 #include <vector>
32 
33 #define SWPAGE_NARROW_VALUE    720
34 #define SWPAGE_NORMAL_VALUE    1136
35 #define SWPAGE_WIDE_VALUE1     1440
36 #define SWPAGE_WIDE_VALUE2	   2880
37 #define SWPAGE_WIDE_VALUE3	   1800
38 
39 
40 namespace svx { namespace sidebar {
41     class ValueSetWithTextControl;
42 } }
43 
44 static const long MINBODY = 284; //0.5 cm in twips
45 
46 namespace sw { namespace sidebar {
47 
48 class PagePropertyPanel;
49 
50 
51 class PageMarginControl
52     : public ::svx::sidebar::PopupControl
53 {
54 public:
55     PageMarginControl(
56         Window* pParent,
57         PagePropertyPanel& rPanel,
58         const SvxLongLRSpaceItem& aPageLRMargin,
59         const SvxLongULSpaceItem& aPageULMargin,
60         const bool bMirrored,
61         const Size aPageSize,
62         const sal_Bool bLandscape,
63         const FieldUnit eFUnit,
64         const SfxMapUnit eUnit );
65     ~PageMarginControl(void);
66 
67 private:
68     ::svx::sidebar::ValueSetWithTextControl* mpMarginValueSet;
69 
70     FixedText maCustom;
71     FixedText maLeft;
72     FixedText maInner;
73     MetricField maLeftMarginEdit;
74     FixedText maRight;
75     FixedText maOuter;
76     MetricField maRightMarginEdit;
77     FixedText maTop;
78     MetricField maTopMarginEdit;
79     FixedText maBottom;
80     MetricField maBottomMarginEdit;
81 
82     // hidden metric field
83     MetricField maWidthHeightField;
84 
85     long mnPageLeftMargin;
86     long mnPageRightMargin;
87     long mnPageTopMargin;
88     long mnPageBottomMargin;
89     bool mbMirrored;
90 
91     const SfxMapUnit meUnit;
92 
93     bool mbUserCustomValuesAvailable;
94     long mnUserCustomPageLeftMargin;
95     long mnUserCustomPageRightMargin;
96     long mnUserCustomPageTopMargin;
97     long mnUserCustomPageBottomMargin;
98     bool mbUserCustomMirrored;
99 
100     bool mbCustomValuesUsed;
101 
102     PagePropertyPanel& mrPagePropPanel;
103 
104     DECL_LINK( ImplMarginHdl, void* );
105     DECL_LINK( ModifyLRMarginHdl, MetricField* );
106     DECL_LINK( ModifyULMarginHdl, MetricField* );
107 
108     void SetMetricFieldMaxValues( const Size aPageSize );
109 
110     bool GetUserCustomValues();
111     void StoreUserCustomValues();
112 
113     void FillValueSet(
114         const bool bLandscape,
115         const bool bUserCustomValuesAvailable );
116     void SelectValueSetItem();
117 };
118 
119 } } // end of namespace sw::sidebar
120 
121 #endif
122