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