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_PROPERTY_PANEL_HXX
23 #define SW_SIDEBAR_PAGE_PROPERTY_PANEL_HXX
24 
25 #include <svx/sidebar/Popup.hxx>
26 
27 #include <sfx2/sidebar/ControllerItem.hxx>
28 
29 namespace svx { namespace sidebar {
30     class PopupControl;
31 } }
32 
33 #include <i18npool/paper.hxx>
34 
35 #include <svx/pageitem.hxx>
36 #include <svx/rulritem.hxx>
37 #include <editeng/sizeitem.hxx>
38 
39 #include <vcl/ctrl.hxx>
40 #include <vcl/fixed.hxx>
41 #include <vcl/button.hxx>
42 #include <vcl/toolbox.hxx>
43 #include <vcl/lstbox.hxx>
44 #include <vcl/field.hxx>
45 #include <svl/intitem.hxx>
46 
47 #include <boost/scoped_ptr.hpp>
48 
49 
50 namespace css = ::com::sun::star;
51 namespace cssu = ::com::sun::star::uno;
52 
53 namespace sw { namespace sidebar {
54 
55     class PagePropertyPanel
56         : public Control,
57           public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
58     {
59     public:
60         static PagePropertyPanel* Create(
61             Window* pParent,
62             SfxBindings* pBindings );
63 
64         // interface of ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
65         virtual void NotifyItemUpdate(
66             const sal_uInt16 nSId,
67             const SfxItemState eState,
68             const SfxPoolItem* pState,
69             const bool bIsEnabled);
70 
71         SfxBindings* GetBindings() const
72         {
73             return mpBindings;
74         }
75 
76 
77         ::svx::sidebar::PopupControl* CreatePageOrientationControl( ::svx::sidebar::PopupContainer* pParent );
78         void ExecuteOrientationChange( const sal_Bool bLandscape );
79         void ClosePageOrientationPopup();
80 
81         ::svx::sidebar::PopupControl* CreatePageMarginControl( ::svx::sidebar::PopupContainer* pParent );
82         void ExecuteMarginLRChange(
83             const long nPageLeftMargin,
84             const long nPageRightMargin );
85         void ExecuteMarginULChange(
86             const long nPageTopMargin,
87             const long nPageBottomMargin );
88         void ExecutePageLayoutChange( const bool bMirrored );
89         void ClosePageMarginPopup();
90 
91         ::svx::sidebar::PopupControl* CreatePageSizeControl( ::svx::sidebar::PopupContainer* pParent );
92         void ExecuteSizeChange( const Paper ePaper );
93         void ClosePageSizePopup();
94 
95         ::svx::sidebar::PopupControl* CreatePageColumnControl( ::svx::sidebar::PopupContainer* pParent );
96         void ExecuteColumnChange( const sal_uInt16 nColumnType );
97         void ClosePageColumnPopup();
98 
99     private:
100         PagePropertyPanel(
101             Window* pParent,
102             SfxBindings* pBindings );
103         virtual ~PagePropertyPanel(void);
104 
105         SfxBindings* mpBindings;
106 
107         // toolboxes - on click open corresponding popup
108         FixedText   maFtOrientation;
109         ::boost::scoped_ptr<Window> mpToolBoxOrientationBackground;
110         ::boost::scoped_ptr<ToolBox> mpToolBoxOrientation;
111         FixedText				maFtMargin;
112         ::boost::scoped_ptr<Window> mpToolBoxMarginBackground;
113         ::boost::scoped_ptr<ToolBox> mpToolBoxMargin;
114         FixedText				maFtSize;
115         ::boost::scoped_ptr<Window> mpToolBoxSizeBackground;
116         ::boost::scoped_ptr<ToolBox> mpToolBoxSize;
117         FixedText				maFtColumn;
118         ::boost::scoped_ptr<Window> mpToolBoxColumnBackground;
119         ::boost::scoped_ptr<ToolBox> mpToolBoxColumn;
120 
121         Image*					maImgSize;
122         Image*					maImgSize_L;
123         Image					mImgPortrait;
124         Image					mImgLandscape;
125         Image					mImgNarrow;
126         Image					mImgNormal;
127         Image					mImgWide;
128         Image					mImgMirrored;
129         Image					mImgMarginCustom;
130         Image					mImgNarrow_L;
131         Image					mImgNormal_L;
132         Image					mImgWide_L;
133         Image					mImgMirrored_L;
134         Image					mImgMarginCustom_L;
135         Image					mImgA3;
136         Image					mImgA4;
137         Image					mImgA5;
138         Image					mImgB4;
139         Image					mImgB5;
140         Image					mImgC5;
141         Image					mImgLetter;
142         Image					mImgLegal;
143         Image					mImgSizeNone;
144         Image					mImgA3_L;
145         Image					mImgA4_L;
146         Image					mImgA5_L;
147         Image					mImgB4_L;
148         Image					mImgB5_L;
149         Image					mImgC5_L;
150         Image					mImgLetter_L;
151         Image					mImgLegal_L;
152         Image					mImgSizeNone_L;
153         Image					mImgColumn1;
154         Image					mImgColumn2;
155         Image					mImgColumn3;
156         Image					mImgLeft;
157         Image					mImgRight;
158         Image					mImgColumnNone;
159         Image					mImgColumn1_L;
160         Image					mImgColumn2_L;
161         Image					mImgColumn3_L;
162         Image					mImgLeft_L;
163         Image					mImgRight_L;
164         Image					mImgColumnNone_L;
165 
166         // item keeping the following page style attributes:
167         // - page orientation
168         // - page usage - only left, only right, both, mirrored
169         // item also hold the numbering type for the page style which should
170         // be kept stable.
171         ::boost::scoped_ptr<SvxPageItem> mpPageItem;
172 
173         // item keeping the page style's left and right margins
174         ::boost::scoped_ptr<SvxLongLRSpaceItem> mpPageLRMarginItem;
175         // item keeping the page style's top and bottom margins
176         ::boost::scoped_ptr<SvxLongULSpaceItem> mpPageULMarginItem;
177 
178         // item keeping the page style's page size
179         ::boost::scoped_ptr<SvxSizeItem> mpPageSizeItem;
180         // Paper corresponding to the page style's page size
181         Paper mePaper;
182 
183         // item keeping the page column type
184         ::boost::scoped_ptr<SfxInt16Item> mpPageColumnTypeItem;
185 
186         FieldUnit 			meFUnit;
187         SfxMapUnit			meUnit;
188 
189         // controller items
190         ::sfx2::sidebar::ControllerItem m_aSwPagePgULControl;
191         ::sfx2::sidebar::ControllerItem m_aSwPagePgLRControl;
192         ::sfx2::sidebar::ControllerItem m_aSwPagePgSizeControl;
193         ::sfx2::sidebar::ControllerItem m_aSwPagePgControl;
194         ::sfx2::sidebar::ControllerItem m_aSwPageColControl;
195         ::sfx2::sidebar::ControllerItem m_aSwPagePgMetricControl;
196 
197         // popups
198         ::boost::scoped_ptr< ::svx::sidebar::Popup > mpOrientationPopup;
199         ::boost::scoped_ptr< ::svx::sidebar::Popup > mpMarginPopup;
200         ::boost::scoped_ptr< ::svx::sidebar::Popup > mpSizePopup;
201         ::boost::scoped_ptr< ::svx::sidebar::Popup > mpColumnPopup;
202 
203         bool mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify;
204 
205         // handler for popup toolboxes to show the popups
206         DECL_LINK(ClickOrientationHdl, ToolBox* );
207         DECL_LINK(ClickMarginHdl, ToolBox* );
208         DECL_LINK(ClickSizeHdl, ToolBox* );
209         DECL_LINK(ClickColumnHdl, ToolBox* );
210 
211         void Initialize();
212 
213         void MetricState( SfxItemState eState, const SfxPoolItem* pState );
214 
215         // helper to adjust popup toolbox' images
216         void ChangeMarginImage();
217         void ChangeSizeImage();
218         void ChangeColumnImage( const sal_uInt16 nColumnType );
219 
220     };
221 
222 } } // end of namespace ::sw::sidebar
223 
224 #endif
225