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