diff options
author | Thorsten Behrens <tbehrens@suse.com> | 2012-10-10 10:57:35 +0200 |
---|---|---|
committer | Thorsten Behrens <tbehrens@suse.com> | 2012-10-10 12:03:33 +0200 |
commit | aa1927dc257b52edf96de220cc3797e02c83a0ae (patch) | |
tree | e02d675c33770c64b64f518b9278c0e27753211c /sd/source/ui/framework | |
parent | 7f69b4a5310667378fcb127795654f410dbaa7c6 (diff) |
Make svg export use slidesorter selection in most cases.
There was code previously that took the current selection, iff
Impress main view was in slidesorter mode. Extended this quite
helpful functionality to also work in other modes (as long as a
slidesorter pane is displayed & has up-to-date selection, it should
work).
Change-Id: Ibbfe630a4ca31aa52978501745c2eef0d79fb8e3
Diffstat (limited to 'sd/source/ui/framework')
-rw-r--r-- | sd/source/ui/framework/factories/ViewShellWrapper.cxx | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/sd/source/ui/framework/factories/ViewShellWrapper.cxx b/sd/source/ui/framework/factories/ViewShellWrapper.cxx index ad27974b580b..058577a36970 100644 --- a/sd/source/ui/framework/factories/ViewShellWrapper.cxx +++ b/sd/source/ui/framework/factories/ViewShellWrapper.cxx @@ -30,11 +30,22 @@ #include "framework/ViewShellWrapper.hxx" #include "framework/Pane.hxx" #include "taskpane/ToolPanelViewShell.hxx" +#include "sdpage.hxx" #include "ViewShell.hxx" #include "Window.hxx" +#include "SlideSorter.hxx" +#include "SlideSorterViewShell.hxx" +#include "controller/SlsPageSelector.hxx" +#include "controller/SlsCurrentSlideManager.hxx" +#include "controller/SlideSorterController.hxx" +#include "model/SlsPageEnumerationProvider.hxx" +#include "model/SlideSorterModel.hxx" +#include "model/SlsPageDescriptor.hxx" + #include <com/sun/star/drawing/framework/XPane.hpp> #include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> #include <toolkit/helper/vclunohelper.hxx> #include <comphelper/sequence.hxx> @@ -64,6 +75,8 @@ ViewShellWrapper::ViewShellWrapper ( const Reference<awt::XWindow>& rxWindow) : ViewShellWrapperInterfaceBase(MutexOwner::maMutex), mpViewShell(pViewShell), + mpSlideSorterViewShell( + ::boost::dynamic_pointer_cast< ::sd::slidesorter::SlideSorterViewShell >( pViewShell )), mxViewId(rxViewId), mxWindow(rxWindow) { @@ -94,6 +107,20 @@ void SAL_CALL ViewShellWrapper::disposing (void) mpViewShell.reset(); } +uno::Any SAL_CALL ViewShellWrapper::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException) +{ + if( mpSlideSorterViewShell && + rType == ::getCppuType( static_cast< uno::Reference< view::XSelectionSupplier > * >( 0 ) ) ) + { + uno::Any aAny; + uno::Reference<view::XSelectionSupplier> xSupplier( this ); + aAny <<= xSupplier; + + return aAny; + } + else + return ViewShellWrapperInterfaceBase::queryInterface( rType ); +} @@ -123,6 +150,70 @@ sal_Bool SAL_CALL ViewShellWrapper::isAnchorOnly (void) } +//----- XSelectionSupplier -------------------------------------------------- + +sal_Bool SAL_CALL ViewShellWrapper::select( const ::com::sun::star::uno::Any& aSelection ) throw(lang::IllegalArgumentException, uno::RuntimeException) +{ + bool bOk = true; + + ::sd::slidesorter::controller::SlideSorterController& rSlideSorterController + = mpSlideSorterViewShell->GetSlideSorter().GetController(); + ::sd::slidesorter::controller::PageSelector& rSelector (rSlideSorterController.GetPageSelector()); + rSelector.DeselectAllPages(); + Sequence<Reference<drawing::XDrawPage> > xPages; + aSelection >>= xPages; + const sal_uInt32 nCount = xPages.getLength(); + for (sal_uInt32 nIndex=0; nIndex<nCount; ++nIndex) + { + Reference<beans::XPropertySet> xSet (xPages[nIndex], UNO_QUERY); + if (xSet.is()) + { + try + { + Any aNumber = xSet->getPropertyValue("Number"); + sal_Int32 nPageNumber = 0; + aNumber >>= nPageNumber; + nPageNumber -=1; // Transform 1-based page numbers to 0-based ones. + rSelector.SelectPage(nPageNumber); + } + catch (const RuntimeException&) + { + } + } + } + + return bOk; +} + +uno::Any SAL_CALL ViewShellWrapper::getSelection() throw(uno::RuntimeException) +{ + Any aResult; + + slidesorter::model::PageEnumeration aSelectedPages ( + slidesorter::model::PageEnumerationProvider::CreateSelectedPagesEnumeration( + mpSlideSorterViewShell->GetSlideSorter().GetModel())); + int nSelectedPageCount ( + mpSlideSorterViewShell->GetSlideSorter().GetController().GetPageSelector().GetSelectedPageCount()); + + Sequence<Reference<XInterface> > aPages(nSelectedPageCount); + int nIndex = 0; + while (aSelectedPages.HasMoreElements() && nIndex<nSelectedPageCount) + { + slidesorter::model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement()); + aPages[nIndex++] = pDescriptor->GetPage()->getUnoPage(); + } + aResult <<= aPages; + + return aResult; +} + +void SAL_CALL ViewShellWrapper::addSelectionChangeListener( const uno::Reference< view::XSelectionChangeListener >& ) throw(uno::RuntimeException) +{ +} + +void SAL_CALL ViewShellWrapper::removeSelectionChangeListener( const uno::Reference< view::XSelectionChangeListener >& ) throw(uno::RuntimeException) +{ +} //----- XRelocatableResource -------------------------------------------------- |