summaryrefslogtreecommitdiff
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
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
-rw-r--r--filter/source/svg/svgfilter.cxx94
-rw-r--r--sd/source/ui/framework/factories/ViewShellWrapper.cxx91
-rw-r--r--sd/source/ui/inc/framework/ViewShellWrapper.hxx15
3 files changed, 163 insertions, 37 deletions
diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx
index 8907bb204940..b5b45840b132 100644
--- a/filter/source/svg/svgfilter.cxx
+++ b/filter/source/svg/svgfilter.cxx
@@ -32,6 +32,9 @@
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/drawing/framework/XControllerManager.hpp>
#include <com/sun/star/drawing/framework/XConfigurationController.hpp>
+#include <com/sun/star/drawing/framework/XConfiguration.hpp>
+#include <com/sun/star/drawing/framework/AnchorBindingMode.hpp>
+#include <com/sun/star/drawing/framework/XResourceId.hpp>
#include <com/sun/star/drawing/framework/XResource.hpp>
#include <com/sun/star/drawing/framework/XView.hpp>
#include <com/sun/star/drawing/framework/ResourceId.hpp>
@@ -77,7 +80,6 @@ SVGFilter::~SVGFilter()
// -----------------------------------------------------------------------------
-
sal_Bool SAL_CALL SVGFilter::filter( const Sequence< PropertyValue >& rDescriptor )
throw (RuntimeException)
{
@@ -92,49 +94,71 @@ sal_Bool SAL_CALL SVGFilter::filter( const Sequence< PropertyValue >& rDescripto
bRet = implImport( rDescriptor );
else if( mxSrcDoc.is() )
{
- if( !mbExportAll )
+ if( !mbExportAll && !mSelectedPages.hasElements() )
{
- uno::Reference< frame::XDesktop > xDesktop( mxMSF->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" )) ),
- uno::UNO_QUERY);
- if( xDesktop.is() )
+ uno::Reference< frame::XDesktop > xDesktop(mxMSF->createInstance( "com.sun.star.frame.Desktop" ),
+ uno::UNO_QUERY_THROW);
+ uno::Reference< frame::XFrame > xFrame(xDesktop->getCurrentFrame(),
+ uno::UNO_QUERY_THROW);
+ uno::Reference<frame::XController > xController(xFrame->getController(),
+ uno::UNO_QUERY_THROW);
+ uno::Reference<drawing::XDrawView > xDrawView(xController,
+ uno::UNO_QUERY_THROW);
+ uno::Reference<drawing::framework::XControllerManager> xManager(xController,
+ uno::UNO_QUERY_THROW);
+ uno::Reference<drawing::framework::XConfigurationController> xConfigController(xManager->getConfigurationController());
+
+ // which view configuration are we in?
+ //
+ // * traverse Impress resources to find slide preview pane, grab selection from there
+ // * otherwise, fallback to current slide
+ //
+ uno::Sequence<uno::Reference<drawing::framework::XResourceId> > aResIds(
+ xConfigController->getCurrentConfiguration()->getResources(
+ uno::Reference<drawing::framework::XResourceId>(),
+ "",
+ drawing::framework::AnchorBindingMode_INDIRECT));
+
+ for( sal_Int32 i=0; i<aResIds.getLength(); ++i )
{
- uno::Reference< frame::XFrame > xFrame( xDesktop->getCurrentFrame() );
-
- if( xFrame.is() )
+ // can we somehow obtain the slidesorter from the Impress framework?
+ if( aResIds[i]->getResourceURL() == "private:resource/view/SlideSorter" )
{
- uno::Reference< frame::XController > xController( xFrame->getController() );
-
- if( xController.is() )
+ // got it, grab current selection from there
+ uno::Reference<drawing::framework::XResource> xRes(
+ xConfigController->getResource(aResIds[i]));
+
+ uno::Reference< view::XSelectionSupplier > xSelectionSupplier(
+ xRes,
+ uno::UNO_QUERY );
+ if( xSelectionSupplier.is() )
{
- /*
- * Get the selection from the Slide Sorter Center Pane
- */
- if( !mSelectedPages.hasElements() )
+ uno::Any aSelection = xSelectionSupplier->getSelection();
+ if( aSelection.hasValue() )
{
- uno::Reference< beans::XPropertySet > xControllerPropertySet( xController, uno::UNO_QUERY );
- uno::Reference< drawing::XDrawSubController > xSubController;
- xControllerPropertySet->getPropertyValue(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SubController" ) ) )
- >>= xSubController;
-
- if( xSubController.is() )
+ ObjectSequence aSelectedPageSequence;
+ aSelection >>= aSelectedPageSequence;
+ mSelectedPages.realloc( aSelectedPageSequence.getLength() );
+ for( sal_Int32 j=0; j<mSelectedPages.getLength(); ++j )
{
- uno::Any aSelection = xSubController->getSelection();
- if( aSelection.hasValue() )
- {
- ObjectSequence aSelectedPageSequence;
- aSelection >>= aSelectedPageSequence;
- mSelectedPages.realloc( aSelectedPageSequence.getLength() );
- for( sal_Int32 i = 0; i < mSelectedPages.getLength(); ++i )
- {
- uno::Reference< drawing::XDrawPage > xDrawPage( aSelectedPageSequence[i], uno::UNO_QUERY );
- mSelectedPages[i] = xDrawPage;
- }
- }
+ uno::Reference< drawing::XDrawPage > xDrawPage( aSelectedPageSequence[j],
+ uno::UNO_QUERY );
+ mSelectedPages[j] = xDrawPage;
}
+
+ // and stop looping. it is likely not getting better
+ break;
}
}
}
}
+
+ if( !mSelectedPages.hasElements() )
+ {
+ // apparently failed to glean selection - fallback to current page
+ mSelectedPages.realloc( 1 );
+ mSelectedPages[0] = xDrawView->getCurrentPage();
+ }
}
/*
@@ -154,8 +178,8 @@ sal_Bool SAL_CALL SVGFilter::filter( const Sequence< PropertyValue >& rDescripto
}
}
- uno::Reference< drawing::XMasterPagesSupplier > xMasterPagesSupplier( mxSrcDoc, uno::UNO_QUERY );
- uno::Reference< drawing::XDrawPagesSupplier > xDrawPagesSupplier( mxSrcDoc, uno::UNO_QUERY );
+ uno::Reference< drawing::XMasterPagesSupplier > xMasterPagesSupplier( mxSrcDoc, uno::UNO_QUERY );
+ uno::Reference< drawing::XDrawPagesSupplier > xDrawPagesSupplier( mxSrcDoc, uno::UNO_QUERY );
if( xMasterPagesSupplier.is() && xDrawPagesSupplier.is() )
{
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;
};