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