sd/source/ui/sidebar/SlideBackground.cxx | 106 ++++++++++++++++++++++++------- sd/source/ui/sidebar/SlideBackground.hxx | 6 + 2 files changed, 90 insertions(+), 22 deletions(-)
New commits: commit 833088b18015381dc8f90e4e868f96b7e882334f Author: Susobhan Ghosh <susobhan...@gmail.com> Date: Thu May 12 17:06:23 2016 +0530 tdf#89466 Fix update of elements and add listener in slidebg Handle Slide change event, removal of PaperOrientationModifyHdlâ Fixed sync and update of MasterSlides. Fixed Paper orientation. Change-Id: I63ece7a4717f216f897b265664758c2c14abb191 Reviewed-on: https://gerrit.libreoffice.org/24927 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Katarina Behrens <katarina.behr...@cib.de> diff --git a/sd/source/ui/sidebar/SlideBackground.cxx b/sd/source/ui/sidebar/SlideBackground.cxx index a772766..ed200e2 100644 --- a/sd/source/ui/sidebar/SlideBackground.cxx +++ b/sd/source/ui/sidebar/SlideBackground.cxx @@ -33,6 +33,7 @@ #include "DrawViewShell.hxx" #include "DrawController.hxx" #include <com/sun/star/beans/XPropertySet.hpp> +#include <boost/concept_check.hpp> #include "sdresid.hxx" #include <svtools/controldims.hrc> #include <svx/gallery.hxx> @@ -59,6 +60,7 @@ #include <sfx2/objface.hxx> #include <svx/dlgutil.hxx> #include <algorithm> +#include "EventMultiplexer.hxx" using namespace ::com::sun::star; @@ -147,6 +149,7 @@ SlideBackground::SlideBackground( get(mpFillLB, "fillattr"); get(mpDspMasterBackground, "displaymasterbackground"); get(mpDspMasterObjects, "displaymasterobjects"); + addListener(); Initialize(); } @@ -159,21 +162,9 @@ void SlideBackground::Initialize() { lcl_FillPaperSizeListbox( *mpPaperSizeBox ); mpPaperSizeBox->SetSelectHdl(LINK(this,SlideBackground,PaperSizeModifyHdl)); - mpPaperOrientation->SetSelectHdl(LINK(this,SlideBackground,PaperOrientationModifyHdl)); + mpPaperOrientation->SetSelectHdl(LINK(this,SlideBackground,PaperSizeModifyHdl)); - ::sd::DrawDocShell* pDocSh = dynamic_cast<::sd::DrawDocShell*>( SfxObjectShell::Current() ); - SdDrawDocument* pDoc = pDocSh ? pDocSh->GetDoc() : nullptr; - sal_uInt16 nCount = pDoc ? pDoc->GetMasterPageCount() : 0; - for( sal_uInt16 nLayout = 0; nLayout < nCount; nLayout++ ) - { - SdPage* pMaster = static_cast<SdPage*>(pDoc->GetMasterPage(nLayout)); - if( pMaster->GetPageKind() == PK_STANDARD) - { - OUString aLayoutName(pMaster->GetLayoutName()); - aLayoutName = aLayoutName.copy(0,aLayoutName.indexOf(SD_LT_SEPARATOR)); - mpMasterSlide->InsertEntry(aLayoutName); - } - } + populateMasterSlideDropdown(); meUnit = maPaperSizeController.GetCoreMetric(); @@ -294,8 +285,87 @@ void SlideBackground::Update() } } +void SlideBackground::addListener() +{ + Link<tools::EventMultiplexerEvent&,void> aLink( LINK(this, SlideBackground, EventMultiplexerListener) ); + mrBase.GetEventMultiplexer()->AddEventListener ( + aLink, + tools::EventMultiplexerEvent::EID_CURRENT_PAGE | + tools::EventMultiplexerEvent::EID_SHAPE_CHANGED ); +} + +void SlideBackground::removeListener() +{ + Link<tools::EventMultiplexerEvent&,void> aLink( LINK(this, SlideBackground, EventMultiplexerListener) ); + mrBase.GetEventMultiplexer()->RemoveEventListener( aLink ); +} + +IMPL_LINK_TYPED(SlideBackground, EventMultiplexerListener, + tools::EventMultiplexerEvent&, rEvent, void) +{ + switch (rEvent.meEventId) + { + // add more events as per requirement + // Master Page change triggers a shape change event. Solves sync problem. + case tools::EventMultiplexerEvent::EID_SHAPE_CHANGED: + populateMasterSlideDropdown(); + break; + case tools::EventMultiplexerEvent::EID_CURRENT_PAGE: + { + static sal_uInt16 SidArray[] = { + SID_ATTR_PAGE_COLOR, + SID_ATTR_PAGE_HATCH, + SID_ATTR_PAGE_BITMAP, + SID_ATTR_PAGE_GRADIENT, + SID_ATTR_PAGE_FILLSTYLE, + SID_DISPLAY_MASTER_BACKGROUND, + SID_DISPLAY_MASTER_OBJECTS, + 0 }; + updateMasterSlideSelection(); + GetBindings()->Invalidate( SidArray ); + } + break; + default: + break; + } +} + +void SlideBackground::populateMasterSlideDropdown() +{ + mpMasterSlide->Clear(); + ::sd::DrawDocShell* pDocSh = dynamic_cast<::sd::DrawDocShell*>( SfxObjectShell::Current() ); + SdDrawDocument* pDoc = pDocSh ? pDocSh->GetDoc() : nullptr; + sal_uInt16 nCount = pDoc ? pDoc->GetMasterPageCount() : 0; + for( sal_uInt16 nLayout = 0; nLayout < nCount; nLayout++ ) + { + SdPage* pMaster = static_cast<SdPage*>(pDoc->GetMasterPage(nLayout)); + if( pMaster->GetPageKind() == PK_STANDARD) + { + OUString aLayoutName(pMaster->GetLayoutName()); + aLayoutName = aLayoutName.copy(0,aLayoutName.indexOf(SD_LT_SEPARATOR)); + mpMasterSlide->InsertEntry(aLayoutName); + } + } + updateMasterSlideSelection(); +} + +void SlideBackground::updateMasterSlideSelection() +{ + SdPage* pPage = mrBase.GetMainViewShell().get()->getCurrentPage(); + if (pPage != nullptr && pPage->TRG_HasMasterPage()) + { + SdrPage& rMasterPage (pPage->TRG_GetMasterPage()); + SdPage* pMasterPage = static_cast<SdPage*>(&rMasterPage); + mpMasterSlide->SelectEntry(pMasterPage->GetName()); + } + else + mpMasterSlide->SetNoSelection(); +} + void SlideBackground::dispose() { + removeListener(); + mpPaperSizeBox.clear(); mpPaperOrientation.clear(); mpMasterSlide.clear(); @@ -603,14 +673,6 @@ IMPL_LINK_NOARG_TYPED(SlideBackground, PaperSizeModifyHdl, ListBox&, void) GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_SIZE, SfxCallMode::RECORD, { &aSizeItem }); } -IMPL_LINK_NOARG_TYPED(SlideBackground, PaperOrientationModifyHdl, ListBox&, void) -{ - SvxPageItem aPageItem(SID_ATTR_PAGE); - aPageItem.SetLandscape( mpPaperOrientation->GetSelectEntryPos() == 0 ); - - GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE, SfxCallMode::RECORD,{ &aPageItem }); -} - IMPL_LINK_NOARG_TYPED(SlideBackground, FillColorHdl, ListBox&, void) { const drawing::FillStyle eXFS = (drawing::FillStyle)mpFillStyle->GetSelectEntryPos(); diff --git a/sd/source/ui/sidebar/SlideBackground.hxx b/sd/source/ui/sidebar/SlideBackground.hxx index 45e3fc2..bd98393 100644 --- a/sd/source/ui/sidebar/SlideBackground.hxx +++ b/sd/source/ui/sidebar/SlideBackground.hxx @@ -41,6 +41,7 @@ #include <svx/xflbckit.hxx> #include <svx/xbtmpit.hxx> #include <svx/xflhtit.hxx> +#include "EventMultiplexer.hxx" namespace sd { namespace sidebar { @@ -109,6 +110,7 @@ private: DECL_LINK_TYPED(AssignMasterPage, ListBox&, void); DECL_LINK_TYPED(DspBackground, Button*, void); DECL_LINK_TYPED(DspObjects, Button*, void); + DECL_LINK_TYPED(EventMultiplexerListener, tools::EventMultiplexerEvent&, void ); void Initialize(); void Update(); @@ -116,6 +118,10 @@ private: XGradient GetGradientSetOrDefault(); const OUString GetHatchingSetOrDefault(); const OUString GetBitmapSetOrDefault(); + void addListener(); + void removeListener(); + void populateMasterSlideDropdown(); + void updateMasterSlideSelection(); }; }}
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits