summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorThorsten Behrens <tbehrens@suse.com>2012-10-10 10:57:35 +0200
committerThorsten Behrens <tbehrens@suse.com>2012-10-10 12:03:33 +0200
commitaa1927dc257b52edf96de220cc3797e02c83a0ae (patch)
treee02d675c33770c64b64f518b9278c0e27753211c /sd
parent7f69b4a5310667378fcb127795654f410dbaa7c6 (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')
-rw-r--r--sd/source/ui/framework/factories/ViewShellWrapper.cxx91
-rw-r--r--sd/source/ui/inc/framework/ViewShellWrapper.hxx15
2 files changed, 104 insertions, 2 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 --------------------------------------------------
diff --git a/sd/source/ui/inc/framework/ViewShellWrapper.hxx b/sd/source/ui/inc/framework/ViewShellWrapper.hxx
index 87c2eb7a2ce2..b49147695342 100644
--- a/sd/source/ui/inc/framework/ViewShellWrapper.hxx
+++ b/sd/source/ui/inc/framework/ViewShellWrapper.hxx
@@ -23,18 +23,20 @@
#include "MutexOwner.hxx"
#include <com/sun/star/drawing/framework/XView.hpp>
#include <com/sun/star/drawing/framework/XRelocatableResource.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
#include <com/sun/star/awt/XWindow.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <osl/mutex.hxx>
-#include <cppuhelper/compbase4.hxx>
+#include <cppuhelper/compbase5.hxx>
#include <cppuhelper/implbase1.hxx>
#include <boost/shared_ptr.hpp>
namespace {
-typedef ::cppu::WeakComponentImplHelper4 < ::com::sun::star::lang::XUnoTunnel
+typedef ::cppu::WeakComponentImplHelper5 < ::com::sun::star::lang::XUnoTunnel
, ::com::sun::star::awt::XWindowListener
+ , ::com::sun::star::view::XSelectionSupplier
, ::com::sun::star::drawing::framework::XRelocatableResource
, ::com::sun::star::drawing::framework::XView
> ViewShellWrapperInterfaceBase;
@@ -42,6 +44,7 @@ typedef ::cppu::WeakComponentImplHelper4 < ::com::sun::star::lang::XUnoTunn
} // end of anonymous namespace.
namespace sd { class ViewShell; }
+namespace sd { namespace slidesorter { class SlideSorterViewShell; } }
namespace sd { namespace framework {
@@ -72,6 +75,7 @@ public:
virtual ~ViewShellWrapper (void);
virtual void SAL_CALL disposing (void);
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId (void);
@@ -95,6 +99,12 @@ public:
virtual sal_Bool SAL_CALL isAnchorOnly (void)
throw (com::sun::star::uno::RuntimeException);
+ // XSelectionSupplier
+
+ virtual sal_Bool SAL_CALL select( const ::com::sun::star::uno::Any& aSelection ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getSelection( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addSelectionChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeSelectionChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
// XRelocatableResource
@@ -131,6 +141,7 @@ public:
private:
::boost::shared_ptr< ViewShell > mpViewShell;
+ ::boost::shared_ptr< ::sd::slidesorter::SlideSorterViewShell > mpSlideSorterViewShell;
const ::com::sun::star::uno::Reference< com::sun::star::drawing::framework::XResourceId > mxViewId;
::com::sun::star::uno::Reference<com::sun::star::awt::XWindow > mxWindow;
};