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 <svx/rulritem.hxx>
30 #include <unotools/viewoptions.hxx>
31 #include <vcl/fixed.hxx>
32 #include <vcl/field.hxx>
33 #include <svtools/unitconv.hxx>
34 #include <vector>
35 
36 #define SWPAGE_NARROW_VALUE    720
37 #define SWPAGE_NORMAL_VALUE    1136
38 #define SWPAGE_WIDE_VALUE1     1440
39 #define SWPAGE_WIDE_VALUE2	   2880
40 #define SWPAGE_WIDE_VALUE3	   1800
41 
42 
43 namespace svx { namespace sidebar {
44     class ValueSetWithTextControl;
45 } }
46 
47 static const long MINBODY = 284; //0.5 cm in twips
48 
49 namespace sw { namespace sidebar {
50 
51 class PagePropertyPanel;
52 
53 
54 class PageMarginControl
55     : public ::svx::sidebar::PopupControl
56 {
57 public:
58     PageMarginControl(
59         Window* pParent,
60         PagePropertyPanel& rPanel,
61         const SvxLongLRSpaceItem& aPageLRMargin,
62         const SvxLongULSpaceItem& aPageULMargin,
63         const bool bMirrored,
64         const Size aPageSize,
65         const sal_Bool bLandscape,
66         const FieldUnit eFUnit,
67         const SfxMapUnit eUnit );
68     ~PageMarginControl(void);
69 
70 private:
71     ::svx::sidebar::ValueSetWithTextControl* mpMarginValueSet;
72 
73     FixedText maCustom;
74     FixedText maLeft;
75     FixedText maInner;
76     MetricField maLeftMarginEdit;
77     FixedText maRight;
78     FixedText maOuter;
79     MetricField maRightMarginEdit;
80     FixedText maTop;
81     MetricField maTopMarginEdit;
82     FixedText maBottom;
83     MetricField maBottomMarginEdit;
84 
85     // hidden metric field
86     MetricField maWidthHeightField;
87 
88     long mnPageLeftMargin;
89     long mnPageRightMargin;
90     long mnPageTopMargin;
91     long mnPageBottomMargin;
92     bool mbMirrored;
93 
94     const SfxMapUnit meUnit;
95 
96     bool mbUserCustomValuesAvailable;
97     long mnUserCustomPageLeftMargin;
98     long mnUserCustomPageRightMargin;
99     long mnUserCustomPageTopMargin;
100     long mnUserCustomPageBottomMargin;
101     bool mbUserCustomMirrored;
102 
103     bool mbCustomValuesUsed;
104 
105     PagePropertyPanel& mrPagePropPanel;
106 
107     DECL_LINK( ImplMarginHdl, void* );
108     DECL_LINK( ModifyLRMarginHdl, MetricField* );
109     DECL_LINK( ModifyULMarginHdl, MetricField* );
110 
111     void SetMetricFieldMaxValues( const Size aPageSize );
112 
113     bool GetUserCustomValues();
114     void StoreUserCustomValues();
115 
116     void FillValueSet(
117         const bool bLandscape,
118         const bool bUserCustomValuesAvailable );
119     void SelectValueSetItem();
120 };
121 
122 } } // end of namespace sw::sidebar
123 
124 #endif
125