2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include "PagePropertyPanel.hxx"
20 #include "PagePropertyPanel.hrc"
22 #include "PropertyPanel.hrc"
24 #include <svx/sidebar/PopupContainer.hxx>
25 #include "PageOrientationControl.hxx"
26 #include "PageMarginControl.hxx"
27 #include "PageSizeControl.hxx"
28 #include "PageColumnControl.hxx"
30 #include <swtypes.hxx>
33 #include <svl/intitem.hxx>
34 #include <editeng/sizeitem.hxx>
35 #include <editeng/paperinf.hxx>
36 #include <svx/svxids.hrc>
37 #include <svx/dlgutil.hxx>
38 #include <svx/rulritem.hxx>
40 #include <sfx2/sidebar/ControlFactory.hxx>
41 #include <sfx2/dispatch.hxx>
42 #include <sfx2/bindings.hxx>
43 #include <sfx2/viewsh.hxx>
44 #include <sfx2/objsh.hxx>
46 #include <boost/bind.hpp>
48 #include <com/sun/star/frame/XController.hpp>
49 #include <com/sun/star/frame/XModel.hpp>
50 #include <com/sun/star/document/XUndoManagerSupplier.hpp>
52 #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
55 const cssu::Reference
< css::document::XUndoManager
> getUndoManager( const cssu::Reference
< css::frame::XFrame
>& rxFrame
)
57 const cssu::Reference
< css::frame::XController
>& xController
= rxFrame
->getController();
58 if ( xController
.is() )
60 const cssu::Reference
< css::frame::XModel
>& xModel
= xController
->getModel();
63 const cssu::Reference
< css::document::XUndoManagerSupplier
> xSuppUndo( xModel
, cssu::UNO_QUERY_THROW
);
66 const cssu::Reference
< css::document::XUndoManager
> xUndoManager( xSuppUndo
->getUndoManager(), cssu::UNO_QUERY_THROW
);
72 return cssu::Reference
< css::document::XUndoManager
> ();
77 namespace sw
{ namespace sidebar
{
79 PagePropertyPanel
* PagePropertyPanel::Create (
81 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rxFrame
,
82 SfxBindings
* pBindings
)
85 throw ::com::sun::star::lang::IllegalArgumentException(A2S("no parent Window given to PagePropertyPanel::Create"), NULL
, 0);
87 throw ::com::sun::star::lang::IllegalArgumentException(A2S("no XFrame given to PagePropertyPanel::Create"), NULL
, 1);
88 if (pBindings
== NULL
)
89 throw ::com::sun::star::lang::IllegalArgumentException(A2S("no SfxBindings given to PagePropertyPanel::Create"), NULL
, 2);
91 return new PagePropertyPanel(
97 PagePropertyPanel::PagePropertyPanel(
99 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rxFrame
,
100 SfxBindings
* pBindings
)
101 : Control(pParent
, SW_RES(RID_PROPERTYPANEL_SWPAGE
))
102 , mpBindings(pBindings
)
104 , maFtOrientation( this, SW_RES(FT_ORIENTATION
) )
105 , mpToolBoxOrientationBackground( ::sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this) )
106 , mpToolBoxOrientation( ::sfx2::sidebar::ControlFactory::CreateToolBox( mpToolBoxOrientationBackground
.get(), SW_RES(TB_ORIENTATION
)) )
107 , maFtMargin( this, SW_RES(FT_MARGIN
) )
108 , mpToolBoxMarginBackground( ::sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this) )
109 , mpToolBoxMargin( ::sfx2::sidebar::ControlFactory::CreateToolBox( mpToolBoxMarginBackground
.get(), SW_RES(TB_MARGIN
)) )
110 , maFtSize( this, SW_RES(FT_SIZE
) )
111 , mpToolBoxSizeBackground( ::sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this) )
112 , mpToolBoxSize( ::sfx2::sidebar::ControlFactory::CreateToolBox( mpToolBoxSizeBackground
.get(), SW_RES(TB_SIZE
)) )
113 , maFtColumn( this, SW_RES(FT_COLUMN
) )
114 , mpToolBoxColumnBackground( ::sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this) )
115 , mpToolBoxColumn( ::sfx2::sidebar::ControlFactory::CreateToolBox( mpToolBoxColumnBackground
.get(), SW_RES(TB_COLUMN
)) )
119 , mImgPortrait (SW_RES(IMG_PAGE_PORTRAIT
))
120 , mImgLandscape (SW_RES(IMG_PAGE_LANDSCAPE
))
121 , mImgNarrow (SW_RES(IMG_PAGE_NARROW
))
122 , mImgNormal (SW_RES(IMG_PAGE_NORMAL
))
123 , mImgWide (SW_RES(IMG_PAGE_WIDE
))
124 , mImgMirrored (SW_RES(IMG_PAGE_MIRRORED
))
125 , mImgMarginCustom (SW_RES(IMG_PAGE_MARGIN_CUSTOM
))
126 , mImgNarrow_L (SW_RES(IMG_PAGE_NARROW_L
))
127 , mImgNormal_L (SW_RES(IMG_PAGE_NORMAL_L
))
128 , mImgWide_L (SW_RES(IMG_PAGE_WIDE_L
))
129 , mImgMirrored_L (SW_RES(IMG_PAGE_MIRRORED_L
))
130 , mImgMarginCustom_L (SW_RES(IMG_PAGE_MARGIN_CUSTOM_L
))
131 , mImgA3 (SW_RES(IMG_PAGE_A3
))
132 , mImgA4 (SW_RES(IMG_PAGE_A4
))
133 , mImgA5 (SW_RES(IMG_PAGE_A5
))
134 , mImgB4 (SW_RES(IMG_PAGE_B4
))
135 , mImgB5 (SW_RES(IMG_PAGE_B5
))
136 , mImgC5 (SW_RES(IMG_PAGE_C5
))
137 , mImgLetter (SW_RES(IMG_PAGE_LETTER
))
138 , mImgLegal (SW_RES(IMG_PAGE_LEGAL
))
139 , mImgSizeNone (SW_RES(IMG_PAGE_SIZE_NONE
))
140 , mImgA3_L (SW_RES(IMG_PAGE_A3_L
))
141 , mImgA4_L (SW_RES(IMG_PAGE_A4_L
))
142 , mImgA5_L (SW_RES(IMG_PAGE_A5_L
))
143 , mImgB4_L (SW_RES(IMG_PAGE_B4_L
))
144 , mImgB5_L (SW_RES(IMG_PAGE_B5_L
))
145 , mImgC5_L (SW_RES(IMG_PAGE_C5_L
))
146 , mImgLetter_L (SW_RES(IMG_PAGE_LETTER_L
))
147 , mImgLegal_L (SW_RES(IMG_PAGE_LEGAL_L
))
148 , mImgSizeNone_L (SW_RES(IMG_PAGE_SIZE_NONE_L
))
149 , mImgColumn1 (SW_RES(IMG_PAGE_COLUMN_1
))
150 , mImgColumn2 (SW_RES(IMG_PAGE_COLUMN_2
))
151 , mImgColumn3 (SW_RES(IMG_PAGE_COLUMN_3
))
152 , mImgLeft (SW_RES(IMG_PAGE_COLUMN_LEFT
))
153 , mImgRight (SW_RES(IMG_PAGE_COLUMN_RIGHT
))
154 , mImgColumnNone (SW_RES(IMG_PAGE_COLUMN_NONE
))
155 , mImgColumn1_L (SW_RES(IMG_PAGE_COLUMN_1_L
))
156 , mImgColumn2_L (SW_RES(IMG_PAGE_COLUMN_2_L
))
157 , mImgColumn3_L (SW_RES(IMG_PAGE_COLUMN_3_L
))
158 , mImgLeft_L (SW_RES(IMG_PAGE_COLUMN_LEFT_L
))
159 , mImgRight_L (SW_RES(IMG_PAGE_COLUMN_RIGHT_L
))
160 , mImgColumnNone_L (SW_RES(IMG_PAGE_COLUMN_NONE_L
))
162 , mpPageItem( new SvxPageItem(SID_ATTR_PAGE
) )
163 , mpPageLRMarginItem( new SvxLongLRSpaceItem( 0, 0, SID_ATTR_PAGE_LRSPACE
) )
164 , mpPageULMarginItem( new SvxLongULSpaceItem( 0, 0, SID_ATTR_PAGE_ULSPACE
) )
165 , mpPageSizeItem( new SvxSizeItem(SID_ATTR_PAGE_SIZE
) )
166 , mePaper( PAPER_USER
)
167 , mpPageColumnTypeItem( new SfxInt16Item(SID_ATTR_PAGE_COLUMN
) )
172 , m_aSwPagePgULControl(SID_ATTR_PAGE_ULSPACE
, *pBindings
, *this)
173 , m_aSwPagePgLRControl(SID_ATTR_PAGE_LRSPACE
, *pBindings
, *this)
174 , m_aSwPagePgSizeControl(SID_ATTR_PAGE_SIZE
, *pBindings
, *this)
175 , m_aSwPagePgControl(SID_ATTR_PAGE
, *pBindings
, *this)
176 , m_aSwPageColControl(SID_ATTR_PAGE_COLUMN
, *pBindings
, *this)
177 , m_aSwPagePgMetricControl(SID_ATTR_METRIC
, *pBindings
, *this)
179 , maOrientationPopup( this,
180 ::boost::bind( &PagePropertyPanel::CreatePageOrientationControl
, this, _1
),
181 A2S("Page orientation") )
182 , maMarginPopup( this,
183 ::boost::bind( &PagePropertyPanel::CreatePageMarginControl
, this, _1
),
184 A2S("Page margins") )
186 ::boost::bind( &PagePropertyPanel::CreatePageSizeControl
, this, _1
),
188 , maColumnPopup( this,
189 ::boost::bind( &PagePropertyPanel::CreatePageColumnControl
, this, _1
),
190 A2S("Page columns") )
192 , mxUndoManager( getUndoManager( rxFrame
) )
194 , mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify( false )
197 mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify
= true;
201 PagePropertyPanel::~PagePropertyPanel()
204 delete[] maImgSize_L
;
206 // destroy the toolbox windows.
207 mpToolBoxOrientation
.reset();
208 mpToolBoxMargin
.reset();
209 mpToolBoxSize
.reset();
210 mpToolBoxColumn
.reset();
212 // destroy the background windows of the toolboxes.
213 mpToolBoxOrientationBackground
.reset();
214 mpToolBoxMarginBackground
.reset();
215 mpToolBoxSizeBackground
.reset();
216 mpToolBoxColumnBackground
.reset();
219 void PagePropertyPanel::Initialize()
221 maFtOrientation
.SetBackground(Wallpaper());
222 maFtMargin
.SetBackground(Wallpaper());
223 maFtSize
.SetBackground(Wallpaper());
224 maFtColumn
.SetBackground(Wallpaper());
226 // popup for page orientation
227 Link aLink
= LINK( this, PagePropertyPanel
, ClickOrientationHdl
);
228 mpToolBoxOrientation
->SetDropdownClickHdl( aLink
);
229 mpToolBoxOrientation
->SetSelectHdl( aLink
);
230 mpToolBoxOrientation
->SetItemImage( TBI_ORIENTATION
, mImgPortrait
);
231 mpToolBoxOrientation
->SetItemBits( TBI_ORIENTATION
, mpToolBoxOrientation
->GetItemBits( TBI_ORIENTATION
) | TIB_DROPDOWNONLY
);
232 mpToolBoxOrientation
->SetQuickHelpText(TBI_ORIENTATION
,String(SW_RES(STR_QHELP_TB_ORIENTATION
)));
233 mpToolBoxOrientation
->SetOutputSizePixel( mpToolBoxOrientation
->CalcWindowSizePixel() );
234 mpToolBoxOrientation
->SetBackground( Wallpaper() );
235 mpToolBoxOrientation
->SetPaintTransparent( sal_True
);
237 // popup for page margins
238 aLink
= LINK( this, PagePropertyPanel
, ClickMarginHdl
);
239 mpToolBoxMargin
->SetDropdownClickHdl( aLink
);
240 mpToolBoxMargin
->SetSelectHdl( aLink
);
241 mpToolBoxMargin
->SetItemImage(TBI_MARGIN
, mImgNormal
);
242 mpToolBoxMargin
->SetItemBits( TBI_MARGIN
, mpToolBoxMargin
->GetItemBits( TBI_MARGIN
) | TIB_DROPDOWNONLY
);
243 mpToolBoxMargin
->SetQuickHelpText(TBI_MARGIN
,String(SW_RES(STR_QHELP_TB_MARGIN
)));
244 mpToolBoxMargin
->SetOutputSizePixel( mpToolBoxMargin
->CalcWindowSizePixel() );
245 mpToolBoxMargin
->SetBackground(Wallpaper());
246 mpToolBoxMargin
->SetPaintTransparent( sal_True
);
248 // popup for page size
249 aLink
= LINK( this, PagePropertyPanel
, ClickSizeHdl
);
250 mpToolBoxSize
->SetDropdownClickHdl( aLink
);
251 mpToolBoxSize
->SetSelectHdl( aLink
);
252 mpToolBoxSize
->SetItemImage(TBI_SIZE
, mImgLetter
);
253 mpToolBoxSize
->SetItemBits( TBI_SIZE
, mpToolBoxSize
->GetItemBits( TBI_SIZE
) | TIB_DROPDOWNONLY
);
254 mpToolBoxSize
->SetQuickHelpText(TBI_SIZE
,String(SW_RES(STR_QHELP_TB_SIZE
)));
255 mpToolBoxSize
->SetOutputSizePixel( mpToolBoxSize
->CalcWindowSizePixel() );
256 mpToolBoxSize
->SetBackground(Wallpaper());
257 mpToolBoxSize
->SetPaintTransparent( sal_True
);
258 maImgSize
= new Image
[8];
259 maImgSize
[0] = mImgA3
;
260 maImgSize
[1] = mImgA4
;
261 maImgSize
[2] = mImgA5
;
262 maImgSize
[3] = mImgB4
;
263 maImgSize
[4] = mImgB5
;
264 maImgSize
[5] = mImgC5
;
265 maImgSize
[6] = mImgLetter
;
266 maImgSize
[7] = mImgLegal
;
267 maImgSize_L
= new Image
[8];
268 maImgSize_L
[0] = mImgA3_L
;
269 maImgSize_L
[1] = mImgA4_L
;
270 maImgSize_L
[2] = mImgA5_L
;
271 maImgSize_L
[3] = mImgB4_L
;
272 maImgSize_L
[4] = mImgB5_L
;
273 maImgSize_L
[5] = mImgC5_L
;
274 maImgSize_L
[6] = mImgLetter_L
;
275 maImgSize_L
[7] = mImgLegal_L
;
277 // popup for page column property
278 aLink
= LINK( this, PagePropertyPanel
, ClickColumnHdl
);
279 mpToolBoxColumn
->SetDropdownClickHdl( aLink
);
280 mpToolBoxColumn
->SetSelectHdl( aLink
);
281 mpToolBoxColumn
->SetItemImage(TBI_COLUMN
, mImgColumn1
);
282 mpToolBoxColumn
->SetItemBits( TBI_COLUMN
, mpToolBoxColumn
->GetItemBits( TBI_COLUMN
) | TIB_DROPDOWNONLY
);
283 mpToolBoxColumn
->SetQuickHelpText(TBI_COLUMN
,String(SW_RES(STR_QHELP_TB_COLUMN
)));
284 mpToolBoxColumn
->SetOutputSizePixel( mpToolBoxColumn
->CalcWindowSizePixel() );
285 mpToolBoxColumn
->SetBackground(Wallpaper());
286 mpToolBoxColumn
->SetPaintTransparent( sal_True
);
288 meFUnit
= GetModuleFieldUnit();
289 meUnit
= m_aSwPagePgSizeControl
.GetCoreMetric();
291 // 'pull' for page style's attribute values
292 mpBindings
->Update( SID_ATTR_PAGE_LRSPACE
);
293 mpBindings
->Update( SID_ATTR_PAGE_ULSPACE
);
294 mpBindings
->Update( SID_ATTR_PAGE
);
295 mpBindings
->Update( SID_ATTR_PAGE_SIZE
);
299 ::svx::sidebar::PopupControl
* PagePropertyPanel::CreatePageOrientationControl( ::svx::sidebar::PopupContainer
* pParent
)
301 return new PageOrientationControl( pParent
, *this , mpPageItem
->IsLandscape() );
305 IMPL_LINK( PagePropertyPanel
, ClickOrientationHdl
, ToolBox
*, pToolBox
)
307 maOrientationPopup
.Show( *pToolBox
);
313 void PagePropertyPanel::ExecuteOrientationChange( const sal_Bool bLandscape
)
318 // set new page orientation
319 mpPageItem
->SetLandscape( bLandscape
);
321 // swap the width and height of the page size
322 mpPageSizeItem
->SetSize( Size( mpPageSizeItem
->GetSize().Height(), mpPageSizeItem
->GetSize().Width() ) );
324 // apply changed attributes
325 GetBindings()->GetDispatcher()->Execute( SID_ATTR_PAGE_SIZE
, SFX_CALLMODE_RECORD
, mpPageSizeItem
.get(), mpPageItem
.get(), 0L );
328 // check, if margin values still fit to the changed page size.
329 // if not, adjust margin values
331 const long nML
= mpPageLRMarginItem
->GetLeft();
332 const long nMR
= mpPageLRMarginItem
->GetRight();
333 const long nTmpPW
= nML
+ nMR
+ MINBODY
;
335 const long nPW
= mpPageSizeItem
->GetSize().Width();
341 ExecuteMarginLRChange( mpPageLRMarginItem
->GetLeft(), nMR
- (nTmpPW
- nPW
) );
345 ExecuteMarginLRChange( nML
- (nTmpPW
- nPW
), mpPageLRMarginItem
->GetRight() );
349 const long nMT
= mpPageULMarginItem
->GetUpper();
350 const long nMB
= mpPageULMarginItem
->GetLower();
351 const long nTmpPH
= nMT
+ nMB
+ MINBODY
;
353 const long nPH
= mpPageSizeItem
->GetSize().Height();
359 ExecuteMarginULChange( mpPageULMarginItem
->GetUpper(), nMB
- ( nTmpPH
- nPH
) );
363 ExecuteMarginULChange( nMT
- ( nTmpPH
- nPH
), mpPageULMarginItem
->GetLower() );
372 void PagePropertyPanel::ClosePageOrientationPopup()
374 maOrientationPopup
.Hide();
380 ::svx::sidebar::PopupControl
* PagePropertyPanel::CreatePageMarginControl( ::svx::sidebar::PopupContainer
* pParent
)
382 return new PageMarginControl(
385 *mpPageLRMarginItem
.get(),
386 *mpPageULMarginItem
.get(),
387 mpPageItem
->GetPageUsage() == SVX_PAGE_MIRROR
,
388 mpPageSizeItem
->GetSize(),
389 mpPageItem
->IsLandscape(),
395 void PagePropertyPanel::ExecuteMarginLRChange(
396 const long nPageLeftMargin
,
397 const long nPageRightMargin
)
399 mpPageLRMarginItem
->SetLeft( nPageLeftMargin
);
400 mpPageLRMarginItem
->SetRight( nPageRightMargin
);
401 GetBindings()->GetDispatcher()->Execute( SID_ATTR_PAGE_LRSPACE
, SFX_CALLMODE_RECORD
, mpPageLRMarginItem
.get(), 0L );
404 void PagePropertyPanel::ExecuteMarginULChange(
405 const long nPageTopMargin
,
406 const long nPageBottomMargin
)
408 mpPageULMarginItem
->SetUpper( nPageTopMargin
);
409 mpPageULMarginItem
->SetLower( nPageBottomMargin
);
410 GetBindings()->GetDispatcher()->Execute( SID_ATTR_PAGE_ULSPACE
, SFX_CALLMODE_RECORD
, mpPageULMarginItem
.get(), 0L );
414 void PagePropertyPanel::ExecutePageLayoutChange( const bool bMirrored
)
416 mpPageItem
->SetPageUsage( bMirrored
? SVX_PAGE_MIRROR
: SVX_PAGE_ALL
);
417 GetBindings()->GetDispatcher()->Execute( SID_ATTR_PAGE
, SFX_CALLMODE_RECORD
, mpPageItem
.get(), 0L );
421 IMPL_LINK( PagePropertyPanel
, ClickMarginHdl
, ToolBox
*, pToolBox
)
423 maMarginPopup
.Show( *pToolBox
);
429 void PagePropertyPanel::ClosePageMarginPopup()
431 maMarginPopup
.Hide();
437 ::svx::sidebar::PopupControl
* PagePropertyPanel::CreatePageSizeControl( ::svx::sidebar::PopupContainer
* pParent
)
439 return new PageSizeControl(
443 mpPageItem
->IsLandscape(),
448 void PagePropertyPanel::ExecuteSizeChange( const Paper ePaper
)
450 Size aPageSize
= SvxPaperInfo::GetPaperSize( ePaper
, (MapUnit
)(meUnit
) );
451 if ( mpPageItem
->IsLandscape() )
455 mpPageSizeItem
->SetSize( aPageSize
);
457 mpBindings
->GetDispatcher()->Execute(SID_ATTR_PAGE_SIZE
, SFX_CALLMODE_RECORD
, mpPageSizeItem
.get(), 0L );
461 IMPL_LINK( PagePropertyPanel
, ClickSizeHdl
, ToolBox
*, pToolBox
)
463 maSizePopup
.Show( *pToolBox
);
469 void PagePropertyPanel::ClosePageSizePopup()
477 ::svx::sidebar::PopupControl
* PagePropertyPanel::CreatePageColumnControl( ::svx::sidebar::PopupContainer
* pParent
)
479 return new PageColumnControl(
482 mpPageColumnTypeItem
->GetValue(),
483 mpPageItem
->IsLandscape() );
487 void PagePropertyPanel::ExecuteColumnChange( const sal_uInt16 nColumnType
)
489 mpPageColumnTypeItem
->SetValue( nColumnType
);
490 mpBindings
->GetDispatcher()->Execute(SID_ATTR_PAGE_COLUMN
, SFX_CALLMODE_RECORD
, mpPageColumnTypeItem
.get(), 0L );
494 IMPL_LINK( PagePropertyPanel
, ClickColumnHdl
, ToolBox
*, pToolBox
)
496 maColumnPopup
.Show( *pToolBox
);
502 void PagePropertyPanel::ClosePageColumnPopup()
504 maColumnPopup
.Hide();
510 void PagePropertyPanel::NotifyItemUpdate(
511 const sal_uInt16 nSId
,
512 const SfxItemState eState
,
513 const SfxPoolItem
* pState
,
514 const bool bIsEnabled
)
520 case SID_ATTR_PAGE_COLUMN
:
522 if ( eState
>= SFX_ITEM_AVAILABLE
&&
523 pState
&& pState
->ISA(SfxInt16Item
) )
525 mpPageColumnTypeItem
.reset( static_cast<SfxInt16Item
*>(pState
->Clone()) );
526 ChangeColumnImage( mpPageColumnTypeItem
->GetValue() );
530 case SID_ATTR_PAGE_LRSPACE
:
531 if ( eState
>= SFX_ITEM_AVAILABLE
&&
532 pState
&& pState
->ISA(SvxLongLRSpaceItem
) )
534 mpPageLRMarginItem
.reset( static_cast<SvxLongLRSpaceItem
*>(pState
->Clone()) );
539 case SID_ATTR_PAGE_ULSPACE
:
540 if ( eState
>= SFX_ITEM_AVAILABLE
&&
541 pState
&& pState
->ISA(SvxLongULSpaceItem
) )
543 mpPageULMarginItem
.reset( static_cast<SvxLongULSpaceItem
*>(pState
->Clone()) );
549 if ( eState
>= SFX_ITEM_AVAILABLE
&&
550 pState
&& pState
->ISA(SvxPageItem
) )
552 mpPageItem
.reset( static_cast<SvxPageItem
*>(pState
->Clone()) );
553 if ( mpPageItem
->IsLandscape() )
555 mpToolBoxOrientation
->SetItemImage(TBI_ORIENTATION
, mImgLandscape
);
559 mpToolBoxOrientation
->SetItemImage(TBI_ORIENTATION
, mImgPortrait
);
563 ChangeColumnImage( mpPageColumnTypeItem
->GetValue() );
567 case SID_ATTR_PAGE_SIZE
:
568 if ( mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify
)
570 mpBindings
->Invalidate( SID_ATTR_PAGE
, sal_True
, sal_False
);
572 if ( eState
>= SFX_ITEM_AVAILABLE
&&
573 pState
&& pState
->ISA(SvxSizeItem
) )
575 mpPageSizeItem
.reset( static_cast<SvxSizeItem
*>(pState
->Clone()) );
579 case SID_ATTR_METRIC
:
580 MetricState( eState
, pState
);
586 void PagePropertyPanel::MetricState( SfxItemState eState
, const SfxPoolItem
* pState
)
588 meFUnit
= FUNIT_NONE
;
589 if ( pState
&& eState
>= SFX_ITEM_DEFAULT
)
591 meFUnit
= (FieldUnit
)( (const SfxUInt16Item
*)pState
)->GetValue();
595 SfxViewFrame
* pFrame
= SfxViewFrame::Current();
596 SfxObjectShell
* pSh
= NULL
;
598 pSh
= pFrame
->GetObjectShell();
601 SfxModule
* pModule
= pSh
->GetModule();
604 const SfxPoolItem
* pItem
= pModule
->GetItem( SID_ATTR_METRIC
);
606 meFUnit
= (FieldUnit
)( (SfxUInt16Item
*)pItem
)->GetValue();
610 DBG_ERRORFILE( "<PagePropertyPanel::MetricState(..)>: no module found" );
619 void PagePropertyPanel::ChangeMarginImage()
621 if ( mpPageLRMarginItem
.get() == 0 ||
622 mpPageULMarginItem
.get() == 0 ||
623 mpPageItem
.get() == 0 )
628 const long cTolerance
= 5;
630 if( abs(mpPageLRMarginItem
->GetLeft() - SWPAGE_NARROW_VALUE
) <= cTolerance
&&
631 abs(mpPageLRMarginItem
->GetRight() - SWPAGE_NARROW_VALUE
) <= cTolerance
&&
632 abs(mpPageULMarginItem
->GetUpper() - SWPAGE_NARROW_VALUE
) <= cTolerance
&&
633 abs(mpPageULMarginItem
->GetLower() - SWPAGE_NARROW_VALUE
) <= cTolerance
&&
634 mpPageItem
->GetPageUsage() != SVX_PAGE_MIRROR
)
635 mpToolBoxMargin
->SetItemImage( TBI_MARGIN
, mpPageItem
->IsLandscape() ? mImgNarrow_L
: mImgNarrow
);
637 else if( abs(mpPageLRMarginItem
->GetLeft() - SWPAGE_NORMAL_VALUE
) <= cTolerance
&&
638 abs(mpPageLRMarginItem
->GetRight() - SWPAGE_NORMAL_VALUE
) <= cTolerance
&&
639 abs(mpPageULMarginItem
->GetUpper() - SWPAGE_NORMAL_VALUE
) <= cTolerance
&&
640 abs(mpPageULMarginItem
->GetLower() - SWPAGE_NORMAL_VALUE
) <= cTolerance
&&
641 mpPageItem
->GetPageUsage() != SVX_PAGE_MIRROR
)
642 mpToolBoxMargin
->SetItemImage(TBI_MARGIN
, mpPageItem
->IsLandscape() ? mImgNormal_L
: mImgNormal
);
644 else if( abs(mpPageLRMarginItem
->GetLeft() - SWPAGE_WIDE_VALUE2
) <= cTolerance
&&
645 abs(mpPageLRMarginItem
->GetRight() - SWPAGE_WIDE_VALUE2
) <= cTolerance
&&
646 abs(mpPageULMarginItem
->GetUpper() - SWPAGE_WIDE_VALUE1
) <= cTolerance
&&
647 abs(mpPageULMarginItem
->GetLower() - SWPAGE_WIDE_VALUE1
) <= cTolerance
&&
648 mpPageItem
->GetPageUsage() != SVX_PAGE_MIRROR
)
649 mpToolBoxMargin
->SetItemImage(TBI_MARGIN
, mpPageItem
->IsLandscape() ? mImgWide_L
: mImgWide
);
651 else if( abs(mpPageLRMarginItem
->GetLeft() - SWPAGE_WIDE_VALUE3
) <= cTolerance
&&
652 abs(mpPageLRMarginItem
->GetRight() - SWPAGE_WIDE_VALUE1
) <= cTolerance
&&
653 abs(mpPageULMarginItem
->GetUpper() - SWPAGE_WIDE_VALUE1
) <= cTolerance
&&
654 abs(mpPageULMarginItem
->GetLower() - SWPAGE_WIDE_VALUE1
) <= cTolerance
&&
655 mpPageItem
->GetPageUsage() == SVX_PAGE_MIRROR
)
656 mpToolBoxMargin
->SetItemImage(TBI_MARGIN
, mpPageItem
->IsLandscape() ? mImgMirrored_L
: mImgMirrored
);
659 mpToolBoxMargin
->SetItemImage(TBI_MARGIN
, mpPageItem
->IsLandscape() ? mImgMarginCustom_L
: mImgMarginCustom
);
663 void PagePropertyPanel::ChangeSizeImage()
665 if ( mpPageSizeItem
.get() == 0 ||
666 mpPageItem
.get() == 0 )
671 Size aTmpPaperSize
= mpPageSizeItem
->GetSize();
672 if ( mpPageItem
->IsLandscape() )
674 Swap( aTmpPaperSize
); // Swap(..) defined in editeng/paperinf.hxx
677 mePaper
= SvxPaperInfo::GetSvxPaper( aTmpPaperSize
, static_cast<MapUnit
>(meUnit
), sal_True
);
679 sal_uInt16 nImageIdx
= 0;
708 mePaper
= PAPER_USER
;
712 if ( nImageIdx
== 0 )
714 mpToolBoxSize
->SetItemImage( TBI_SIZE
,
715 ( mpPageItem
->IsLandscape() ? mImgSizeNone_L
: mImgSizeNone
) );
719 mpToolBoxSize
->SetItemImage( TBI_SIZE
,
720 ( mpPageItem
->IsLandscape() ? maImgSize_L
[nImageIdx
-1] : maImgSize
[nImageIdx
-1] ) );
725 void PagePropertyPanel::ChangeColumnImage( const sal_uInt16 nColumnType
)
727 if ( mpPageItem
.get() == 0 )
732 if ( !mpPageItem
->IsLandscape() )
734 switch( nColumnType
)
737 mpToolBoxColumn
->SetItemImage(TBI_COLUMN
, mImgColumn1
);
740 mpToolBoxColumn
->SetItemImage(TBI_COLUMN
, mImgColumn2
);
743 mpToolBoxColumn
->SetItemImage(TBI_COLUMN
, mImgColumn3
);
746 mpToolBoxColumn
->SetItemImage(TBI_COLUMN
, mImgLeft
);
749 mpToolBoxColumn
->SetItemImage(TBI_COLUMN
, mImgRight
);
752 mpToolBoxColumn
->SetItemImage(TBI_COLUMN
, mImgColumnNone
);
757 switch( nColumnType
)
760 mpToolBoxColumn
->SetItemImage(TBI_COLUMN
, mImgColumn1_L
);
763 mpToolBoxColumn
->SetItemImage(TBI_COLUMN
, mImgColumn2_L
);
766 mpToolBoxColumn
->SetItemImage(TBI_COLUMN
, mImgColumn3_L
);
769 mpToolBoxColumn
->SetItemImage(TBI_COLUMN
, mImgLeft_L
);
772 mpToolBoxColumn
->SetItemImage(TBI_COLUMN
, mImgRight_L
);
775 mpToolBoxColumn
->SetItemImage(TBI_COLUMN
, mImgColumnNone_L
);
781 void PagePropertyPanel::StartUndo()
783 if ( mxUndoManager
.is() )
785 mxUndoManager
->enterUndoContext( A2S("") );
790 void PagePropertyPanel::EndUndo()
792 if ( mxUndoManager
.is() )
794 mxUndoManager
->leaveUndoContext();
798 } } // end of namespace ::sw::sidebar