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