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