PagePropertyPanel.cxx (45da7d5e) | PagePropertyPanel.cxx (550fbbbd) |
---|---|
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 --- 37 unchanged lines hidden (view full) --- 46#include <sfx2/sidebar/ControlFactory.hxx> 47#include <sfx2/dispatch.hxx> 48#include <sfx2/bindings.hxx> 49#include <sfx2/viewsh.hxx> 50#include <sfx2/objsh.hxx> 51 52#include <boost/bind.hpp> 53 | 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 --- 37 unchanged lines hidden (view full) --- 46#include <sfx2/sidebar/ControlFactory.hxx> 47#include <sfx2/dispatch.hxx> 48#include <sfx2/bindings.hxx> 49#include <sfx2/viewsh.hxx> 50#include <sfx2/objsh.hxx> 51 52#include <boost/bind.hpp> 53 |
54#include <com/sun/star/frame/XController.hpp> 55#include <com/sun/star/frame/XModel.hpp> 56#include <com/sun/star/document/XUndoManagerSupplier.hpp> 57 |
|
54#define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString))) 55 56#define SetFldVal(rField, lValue) (rField).SetValue((rField).Normalize(lValue), FUNIT_TWIP) 57 | 58#define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString))) 59 60#define SetFldVal(rField, lValue) (rField).SetValue((rField).Normalize(lValue), FUNIT_TWIP) 61 |
62namespace { 63 const cssu::Reference< css::document::XUndoManager > getUndoManager( const cssu::Reference< css::frame::XFrame >& rxFrame ) 64 { 65 const cssu::Reference< css::frame::XController >& xController = rxFrame->getController(); 66 if ( xController.is() ) 67 { 68 const cssu::Reference< css::frame::XModel >& xModel = xController->getModel(); 69 if ( xModel.is() ) 70 { 71 const cssu::Reference< css::document::XUndoManagerSupplier > xSuppUndo( xModel, cssu::UNO_QUERY_THROW ); 72 if ( xSuppUndo.is() ) 73 { 74 const cssu::Reference< css::document::XUndoManager > xUndoManager( xSuppUndo->getUndoManager(), cssu::UNO_QUERY_THROW ); 75 return xUndoManager; 76 } 77 } 78 } |
|
58 | 79 |
80 return cssu::Reference< css::document::XUndoManager > (); 81 } 82} 83 84 |
|
59namespace sw { namespace sidebar { 60 61PagePropertyPanel* PagePropertyPanel::Create ( 62 Window* pParent, | 85namespace sw { namespace sidebar { 86 87PagePropertyPanel* PagePropertyPanel::Create ( 88 Window* pParent, |
89 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame>& rxFrame, |
|
63 SfxBindings* pBindings) 64{ 65 if (pParent == NULL) 66 throw ::com::sun::star::lang::IllegalArgumentException(A2S("no parent Window given to PagePropertyPanel::Create"), NULL, 0); | 90 SfxBindings* pBindings) 91{ 92 if (pParent == NULL) 93 throw ::com::sun::star::lang::IllegalArgumentException(A2S("no parent Window given to PagePropertyPanel::Create"), NULL, 0); |
94 if ( ! rxFrame.is()) 95 throw ::com::sun::star::lang::IllegalArgumentException(A2S("no XFrame given to PagePropertyPanel::Create"), NULL, 1); |
|
67 if (pBindings == NULL) 68 throw ::com::sun::star::lang::IllegalArgumentException(A2S("no SfxBindings given to PagePropertyPanel::Create"), NULL, 2); 69 70 return new PagePropertyPanel( 71 pParent, | 96 if (pBindings == NULL) 97 throw ::com::sun::star::lang::IllegalArgumentException(A2S("no SfxBindings given to PagePropertyPanel::Create"), NULL, 2); 98 99 return new PagePropertyPanel( 100 pParent, |
101 rxFrame, |
|
72 pBindings); 73} 74 75PagePropertyPanel::PagePropertyPanel( 76 Window* pParent, | 102 pBindings); 103} 104 105PagePropertyPanel::PagePropertyPanel( 106 Window* pParent, |
107 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame>& rxFrame, |
|
77 SfxBindings* pBindings) 78 : Control(pParent, SW_RES(RID_PROPERTYPANEL_SWPAGE)) 79 , mpBindings(pBindings) 80 // visible controls 81 , maFtOrientation( this, SW_RES(FT_ORIENTATION) ) 82 , mpToolBoxOrientationBackground( ::sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this) ) 83 , mpToolBoxOrientation( ::sfx2::sidebar::ControlFactory::CreateToolBox( mpToolBoxOrientationBackground.get(), SW_RES(TB_ORIENTATION)) ) 84 , maFtMargin( this, SW_RES(FT_MARGIN) ) --- 63 unchanged lines hidden (view full) --- 148 149 , m_aSwPagePgULControl(SID_ATTR_PAGE_ULSPACE, *pBindings, *this) 150 , m_aSwPagePgLRControl(SID_ATTR_PAGE_LRSPACE, *pBindings, *this) 151 , m_aSwPagePgSizeControl(SID_ATTR_PAGE_SIZE, *pBindings, *this) 152 , m_aSwPagePgControl(SID_ATTR_PAGE, *pBindings, *this) 153 , m_aSwPageColControl(SID_ATTR_PAGE_COLUMN, *pBindings, *this) 154 , m_aSwPagePgMetricControl(SID_ATTR_METRIC, *pBindings, *this) 155 | 108 SfxBindings* pBindings) 109 : Control(pParent, SW_RES(RID_PROPERTYPANEL_SWPAGE)) 110 , mpBindings(pBindings) 111 // visible controls 112 , maFtOrientation( this, SW_RES(FT_ORIENTATION) ) 113 , mpToolBoxOrientationBackground( ::sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this) ) 114 , mpToolBoxOrientation( ::sfx2::sidebar::ControlFactory::CreateToolBox( mpToolBoxOrientationBackground.get(), SW_RES(TB_ORIENTATION)) ) 115 , maFtMargin( this, SW_RES(FT_MARGIN) ) --- 63 unchanged lines hidden (view full) --- 179 180 , m_aSwPagePgULControl(SID_ATTR_PAGE_ULSPACE, *pBindings, *this) 181 , m_aSwPagePgLRControl(SID_ATTR_PAGE_LRSPACE, *pBindings, *this) 182 , m_aSwPagePgSizeControl(SID_ATTR_PAGE_SIZE, *pBindings, *this) 183 , m_aSwPagePgControl(SID_ATTR_PAGE, *pBindings, *this) 184 , m_aSwPageColControl(SID_ATTR_PAGE_COLUMN, *pBindings, *this) 185 , m_aSwPagePgMetricControl(SID_ATTR_METRIC, *pBindings, *this) 186 |
156 , mpOrientationPopup() 157 , mpMarginPopup() 158 , mpSizePopup() 159 , mpColumnPopup() | 187 , maOrientationPopup( this, 188 ::boost::bind( &PagePropertyPanel::CreatePageOrientationControl, this, _1 ), 189 A2S("Page orientation") ) 190 , maMarginPopup( this, 191 ::boost::bind( &PagePropertyPanel::CreatePageMarginControl, this, _1 ), 192 A2S("Page margins") ) 193 , maSizePopup( this, 194 ::boost::bind( &PagePropertyPanel::CreatePageSizeControl, this, _1 ), 195 A2S("Page size") ) 196 , maColumnPopup( this, 197 ::boost::bind( &PagePropertyPanel::CreatePageColumnControl, this, _1 ), 198 A2S("Page columns") ) |
160 161 , mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify( false ) | 199 200 , mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify( false ) |
201 202 , mxUndoManager( getUndoManager( rxFrame ) ) |
|
162{ 163 Initialize(); 164 mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify = true; 165 FreeResource(); 166} 167 168PagePropertyPanel::~PagePropertyPanel() 169{ --- 96 unchanged lines hidden (view full) --- 266::svx::sidebar::PopupControl* PagePropertyPanel::CreatePageOrientationControl( ::svx::sidebar::PopupContainer* pParent ) 267{ 268 return new PageOrientationControl( pParent, *this , mpPageItem->IsLandscape() ); 269} 270 271 272IMPL_LINK( PagePropertyPanel, ClickOrientationHdl, ToolBox*, pToolBox ) 273{ | 203{ 204 Initialize(); 205 mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify = true; 206 FreeResource(); 207} 208 209PagePropertyPanel::~PagePropertyPanel() 210{ --- 96 unchanged lines hidden (view full) --- 307::svx::sidebar::PopupControl* PagePropertyPanel::CreatePageOrientationControl( ::svx::sidebar::PopupContainer* pParent ) 308{ 309 return new PageOrientationControl( pParent, *this , mpPageItem->IsLandscape() ); 310} 311 312 313IMPL_LINK( PagePropertyPanel, ClickOrientationHdl, ToolBox*, pToolBox ) 314{ |
274 if ( ! mpOrientationPopup) 275 { 276 mpOrientationPopup.reset( 277 new ::svx::sidebar::Popup( 278 this, 279 ::boost::bind(&PagePropertyPanel::CreatePageOrientationControl, this, _1), 280 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Page orientation")) ) ); 281 } 282 mpOrientationPopup->Show( *pToolBox ); 283 | 315 maOrientationPopup.Show( *pToolBox ); 316 |
284 return 0L; 285} 286 287 288void PagePropertyPanel::ExecuteOrientationChange( const sal_Bool bLandscape ) 289{ | 317 return 0L; 318} 319 320 321void PagePropertyPanel::ExecuteOrientationChange( const sal_Bool bLandscape ) 322{ |
323 StartUndo(); 324 |
|
290 { 291 // set new page orientation 292 mpPageItem->SetLandscape( bLandscape ); 293 294 // swap the width and height of the page size 295 mpPageSizeItem->SetSize( Size( mpPageSizeItem->GetSize().Height(), mpPageSizeItem->GetSize().Width() ) ); 296 297 // apply changed attributes --- 34 unchanged lines hidden (view full) --- 332 ExecuteMarginULChange( mpPageULMarginItem->GetUpper(), nMB - ( nTmpPH - nPH ) ); 333 } 334 else 335 { 336 ExecuteMarginULChange( nMT - ( nTmpPH - nPH ), mpPageULMarginItem->GetLower() ); 337 } 338 } 339 } | 325 { 326 // set new page orientation 327 mpPageItem->SetLandscape( bLandscape ); 328 329 // swap the width and height of the page size 330 mpPageSizeItem->SetSize( Size( mpPageSizeItem->GetSize().Height(), mpPageSizeItem->GetSize().Width() ) ); 331 332 // apply changed attributes --- 34 unchanged lines hidden (view full) --- 367 ExecuteMarginULChange( mpPageULMarginItem->GetUpper(), nMB - ( nTmpPH - nPH ) ); 368 } 369 else 370 { 371 ExecuteMarginULChange( nMT - ( nTmpPH - nPH ), mpPageULMarginItem->GetLower() ); 372 } 373 } 374 } |
375 376 EndUndo(); |
|
340} 341 342 343void PagePropertyPanel::ClosePageOrientationPopup() 344{ | 377} 378 379 380void PagePropertyPanel::ClosePageOrientationPopup() 381{ |
345 mpOrientationPopup->Hide(); | 382 maOrientationPopup.Hide(); |
346} 347 348 349 350 351::svx::sidebar::PopupControl* PagePropertyPanel::CreatePageMarginControl( ::svx::sidebar::PopupContainer* pParent ) 352{ 353 return new PageMarginControl( --- 32 unchanged lines hidden (view full) --- 386{ 387 mpPageItem->SetPageUsage( bMirrored ? SVX_PAGE_MIRROR : SVX_PAGE_ALL ); 388 GetBindings()->GetDispatcher()->Execute( SID_ATTR_PAGE, SFX_CALLMODE_RECORD, mpPageItem.get(), 0L ); 389} 390 391 392IMPL_LINK( PagePropertyPanel, ClickMarginHdl, ToolBox*, pToolBox ) 393{ | 383} 384 385 386 387 388::svx::sidebar::PopupControl* PagePropertyPanel::CreatePageMarginControl( ::svx::sidebar::PopupContainer* pParent ) 389{ 390 return new PageMarginControl( --- 32 unchanged lines hidden (view full) --- 423{ 424 mpPageItem->SetPageUsage( bMirrored ? SVX_PAGE_MIRROR : SVX_PAGE_ALL ); 425 GetBindings()->GetDispatcher()->Execute( SID_ATTR_PAGE, SFX_CALLMODE_RECORD, mpPageItem.get(), 0L ); 426} 427 428 429IMPL_LINK( PagePropertyPanel, ClickMarginHdl, ToolBox*, pToolBox ) 430{ |
394 if ( ! mpMarginPopup) 395 mpMarginPopup.reset( 396 new ::svx::sidebar::Popup( 397 this, 398 ::boost::bind(&PagePropertyPanel::CreatePageMarginControl, this, _1), 399 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Page margins")) ) ); 400 mpMarginPopup->Show( *pToolBox ); | 431 maMarginPopup.Show( *pToolBox ); |
401 402 return 0L; 403} 404 405 406void PagePropertyPanel::ClosePageMarginPopup() 407{ | 432 433 return 0L; 434} 435 436 437void PagePropertyPanel::ClosePageMarginPopup() 438{ |
408 mpMarginPopup->Hide(); | 439 maMarginPopup.Hide(); |
409} 410 411 412 413 414::svx::sidebar::PopupControl* PagePropertyPanel::CreatePageSizeControl( ::svx::sidebar::PopupContainer* pParent ) 415{ 416 return new PageSizeControl( --- 15 unchanged lines hidden (view full) --- 432 mpPageSizeItem->SetSize( aPageSize ); 433 434 mpBindings->GetDispatcher()->Execute(SID_ATTR_PAGE_SIZE, SFX_CALLMODE_RECORD, mpPageSizeItem.get(), 0L ); 435} 436 437 438IMPL_LINK( PagePropertyPanel, ClickSizeHdl, ToolBox*, pToolBox ) 439{ | 440} 441 442 443 444 445::svx::sidebar::PopupControl* PagePropertyPanel::CreatePageSizeControl( ::svx::sidebar::PopupContainer* pParent ) 446{ 447 return new PageSizeControl( --- 15 unchanged lines hidden (view full) --- 463 mpPageSizeItem->SetSize( aPageSize ); 464 465 mpBindings->GetDispatcher()->Execute(SID_ATTR_PAGE_SIZE, SFX_CALLMODE_RECORD, mpPageSizeItem.get(), 0L ); 466} 467 468 469IMPL_LINK( PagePropertyPanel, ClickSizeHdl, ToolBox*, pToolBox ) 470{ |
440 if ( ! mpSizePopup) 441 mpSizePopup.reset( 442 new ::svx::sidebar::Popup( 443 this, 444 ::boost::bind(&PagePropertyPanel::CreatePageSizeControl, this, _1), 445 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Page size")) ) ); 446 mpSizePopup->Show( *pToolBox ); | 471 maSizePopup.Show( *pToolBox ); |
447 448 return 0L; 449} 450 451 452void PagePropertyPanel::ClosePageSizePopup() 453{ | 472 473 return 0L; 474} 475 476 477void PagePropertyPanel::ClosePageSizePopup() 478{ |
454 mpSizePopup->Hide(); | 479 maSizePopup.Hide(); |
455} 456 457 458 459 460::svx::sidebar::PopupControl* PagePropertyPanel::CreatePageColumnControl( ::svx::sidebar::PopupContainer* pParent ) 461{ 462 return new PageColumnControl( --- 8 unchanged lines hidden (view full) --- 471{ 472 mpPageColumnTypeItem->SetValue( nColumnType ); 473 mpBindings->GetDispatcher()->Execute(SID_ATTR_PAGE_COLUMN, SFX_CALLMODE_RECORD, mpPageColumnTypeItem.get(), 0L ); 474} 475 476 477IMPL_LINK( PagePropertyPanel, ClickColumnHdl, ToolBox*, pToolBox ) 478{ | 480} 481 482 483 484 485::svx::sidebar::PopupControl* PagePropertyPanel::CreatePageColumnControl( ::svx::sidebar::PopupContainer* pParent ) 486{ 487 return new PageColumnControl( --- 8 unchanged lines hidden (view full) --- 496{ 497 mpPageColumnTypeItem->SetValue( nColumnType ); 498 mpBindings->GetDispatcher()->Execute(SID_ATTR_PAGE_COLUMN, SFX_CALLMODE_RECORD, mpPageColumnTypeItem.get(), 0L ); 499} 500 501 502IMPL_LINK( PagePropertyPanel, ClickColumnHdl, ToolBox*, pToolBox ) 503{ |
479 if ( ! mpColumnPopup) 480 mpColumnPopup.reset( 481 new ::svx::sidebar::Popup( 482 this, 483 ::boost::bind(&PagePropertyPanel::CreatePageColumnControl, this, _1), 484 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Page columns")) ) ); 485 mpColumnPopup->Show( *pToolBox ); | 504 maColumnPopup.Show( *pToolBox ); |
486 487 return 0L; 488} 489 490 491void PagePropertyPanel::ClosePageColumnPopup() 492{ | 505 506 return 0L; 507} 508 509 510void PagePropertyPanel::ClosePageColumnPopup() 511{ |
493 mpColumnPopup->Hide(); | 512 maColumnPopup.Hide(); |
494} 495 496 497 498 499void PagePropertyPanel::NotifyItemUpdate( 500 const sal_uInt16 nSId, 501 const SfxItemState eState, --- 259 unchanged lines hidden (view full) --- 761 mpToolBoxColumn->SetItemImage(TBI_COLUMN, mImgRight_L); 762 break; 763 default: 764 mpToolBoxColumn->SetItemImage(TBI_COLUMN, mImgColumnNone_L); 765 } 766 } 767} 768 | 513} 514 515 516 517 518void PagePropertyPanel::NotifyItemUpdate( 519 const sal_uInt16 nSId, 520 const SfxItemState eState, --- 259 unchanged lines hidden (view full) --- 780 mpToolBoxColumn->SetItemImage(TBI_COLUMN, mImgRight_L); 781 break; 782 default: 783 mpToolBoxColumn->SetItemImage(TBI_COLUMN, mImgColumnNone_L); 784 } 785 } 786} 787 |
788 789void PagePropertyPanel::StartUndo() 790{ 791 if ( mxUndoManager.is() ); 792 { 793 mxUndoManager->enterUndoContext( A2S("") ); 794 } 795} 796 797 798void PagePropertyPanel::EndUndo() 799{ 800 if ( mxUndoManager.is() ); 801 { 802 mxUndoManager->leaveUndoContext(); 803 } 804} 805 |
|
769} } // end of namespace ::sw::sidebar | 806} } // end of namespace ::sw::sidebar |