filter/source/flash/swfexporter.cxx | 80 +++++++++++++++++++++++++++----- filter/source/flash/swfexporter.hxx | 22 +++++++-- filter/source/flash/swffilter.cxx | 88 +++++++++++++++++++++++++++++++++--- 3 files changed, 167 insertions(+), 23 deletions(-)
New commits: commit 9cfa6464411e39e1cbaef8f0c7c64bddbed4033b Author: Armin Le Grand <[email protected]> Date: Tue Apr 8 12:24:24 2014 +0000 i56084 added support for export selection in swf export diff --git a/filter/source/flash/swfexporter.cxx b/filter/source/flash/swfexporter.cxx index 2e7b8eb..25fd965 100644 --- a/filter/source/flash/swfexporter.cxx +++ b/filter/source/flash/swfexporter.cxx @@ -99,14 +99,33 @@ void PageInfo::addShape( ShapeInfo* pShapeInfo ) // ----------------------------------------------------------------------------- -FlashExporter::FlashExporter(const Reference< XMultiServiceFactory > &rxMSF, sal_Int32 nJPEGCompressMode, sal_Bool bExportOLEAsJPEG) -: mxMSF( rxMSF ), - mpWriter( NULL ), +FlashExporter::FlashExporter( + const Reference< XMultiServiceFactory > &rxMSF, + + // #56084# variables for selection export + const Reference< XShapes >& rxSelectedShapes, + const Reference< XDrawPage >& rxSelectedDrawPage, + + sal_Int32 nJPEGCompressMode, + sal_Bool bExportOLEAsJPEG) +: mxMSF(rxMSF), + + // #56084# variables for selection export + mxSelectedShapes(rxSelectedShapes), + mxSelectedDrawPage(rxSelectedDrawPage), + mbExportSelection(false), + + mpWriter(NULL), mnJPEGcompressMode(nJPEGCompressMode), mbExportOLEAsJPEG(bExportOLEAsJPEG), mbPresentation(true), - mnPageNumber( - 1 ) + mnPageNumber(-1) { + if(mxSelectedDrawPage.is() && mxSelectedShapes.is() && mxSelectedShapes->getCount()) + { + // #56084# determine export selection + mbExportSelection = true; + } } // ----------------------------------------------------------------------------- @@ -146,7 +165,16 @@ sal_Bool FlashExporter::exportAll( Reference< XComponent > xDoc, Reference< XOut return sal_False; Reference< XDrawPage > xDrawPage; - xDrawPages->getByIndex(0) >>= xDrawPage; + + // #56084# set xDrawPage directly when exporting selection + if(mbExportSelection) + { + xDrawPage = mxSelectedDrawPage; + } + else + { + xDrawPages->getByIndex(0) >>= xDrawPage; + } Reference< XPropertySet > xProp( xDrawPage, UNO_QUERY ); try @@ -165,17 +193,29 @@ sal_Bool FlashExporter::exportAll( Reference< XComponent > xDoc, Reference< XOut return false; // no writer, no cookies } - const sal_Int32 nPageCount = xDrawPages->getCount(); + // #56084# nPageCount is 1 when exporting selection + const sal_Int32 nPageCount = mbExportSelection ? 1 : xDrawPages->getCount(); sal_uInt16 nPage; + if ( xStatusIndicator.is() ) + { xStatusIndicator->start(OUString( RTL_CONSTASCII_USTRINGPARAM( "Macromedia Flash (SWF)" )), nPageCount); + } + for( nPage = 0; nPage < nPageCount; nPage++) { + // #56084# keep PageNumber? We could determine the PageNumber of the single to-be-eported page + // when exporting the selection, but this is only used for swf internal, so no need to do so (AFAIK) mnPageNumber = nPage + 1; if ( xStatusIndicator.is() ) xStatusIndicator->setValue( nPage ); - xDrawPages->getByIndex(nPage) >>= xDrawPage; + + // #56084# get current xDrawPage when not exporting selection; else alraedy set above + if(!mbExportSelection) + { + xDrawPages->getByIndex(nPage) >>= xDrawPage; + } if( !xDrawPage.is()) continue; @@ -189,11 +229,25 @@ sal_Bool FlashExporter::exportAll( Reference< XComponent > xDoc, Reference< XOut continue; } - exportBackgrounds( xDrawPage, nPage, false ); - exportBackgrounds( xDrawPage, nPage, true ); + // #56084# no background when exporting selection + if(!mbExportSelection) + { + exportBackgrounds( xDrawPage, nPage, false ); + exportBackgrounds( xDrawPage, nPage, true ); + } maPagesMap[nPage].mnForegroundID = mpWriter->startSprite(); - exportDrawPageContents( xDrawPage, false, false ); + + // #56084# directly export selection in export selection mode + if(mbExportSelection) + { + exportShapes( mxSelectedShapes, false, false ); + } + else + { + exportDrawPageContents( xDrawPage, false, false ); + } + mpWriter->endSprite(); // AS: If the background is different than the previous slide, @@ -490,7 +544,7 @@ sal_uInt16 FlashExporter::exportMasterPageObjects(sal_uInt16 nPage, Reference< X /** export's the definition of the shapes inside this drawing page and adds the shape infos to the current PageInfo */ -void FlashExporter::exportDrawPageContents( Reference< XDrawPage >& xPage, bool bStream, bool bMaster ) +void FlashExporter::exportDrawPageContents( const Reference< XDrawPage >& xPage, bool bStream, bool bMaster ) { Reference< XShapes > xShapes( xPage, UNO_QUERY ); exportShapes(xShapes, bStream, bMaster); @@ -500,7 +554,7 @@ void FlashExporter::exportDrawPageContents( Reference< XDrawPage >& xPage, bool /** export's the definition of the shapes inside this XShapes container and adds the shape infos to the current PageInfo */ -void FlashExporter::exportShapes( Reference< XShapes >& xShapes, bool bStream, bool bMaster ) +void FlashExporter::exportShapes( const Reference< XShapes >& xShapes, bool bStream, bool bMaster ) { OSL_ENSURE( (xShapes->getCount() <= 0xffff), "overflow in FlashExporter::exportDrawPageContents()" ); @@ -532,7 +586,7 @@ void FlashExporter::exportShapes( Reference< XShapes >& xShapes, bool bStream, b // ----------------------------------------------------------------------------- /** export this shape definition and adds it's info to the current PageInfo */ -void FlashExporter::exportShape( Reference< XShape >& xShape, bool bMaster ) +void FlashExporter::exportShape( const Reference< XShape >& xShape, bool bMaster ) { Reference< XPropertySet > xPropSet( xShape, UNO_QUERY ); if( !xPropSet.is() ) diff --git a/filter/source/flash/swfexporter.hxx b/filter/source/flash/swfexporter.hxx index 6c7167f..03e5e6d 100644 --- a/filter/source/flash/swfexporter.hxx +++ b/filter/source/flash/swfexporter.hxx @@ -155,7 +155,15 @@ typedef ::std::map<sal_uInt32, PageInfo> PageInfoMap; class FlashExporter { public: - FlashExporter( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxMSF, sal_Int32 nJPEGCompressMode = -1, sal_Bool bExportOLEAsJPEG = false); + FlashExporter( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxMSF, + + // #56084# variables for selection export + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxSelectedShapes, + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& rxSelectedDrawPage, + + sal_Int32 nJPEGCompressMode = -1, + sal_Bool bExportOLEAsJPEG = false); ~FlashExporter(); void Flush(); @@ -176,6 +184,12 @@ public: private: ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF; + + // #56084# variables for selection export + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > mxSelectedShapes; + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > mxSelectedDrawPage; + bool mbExportSelection; + ::com::sun::star::uno::Reference< ::com::sun::star::document::XExporter > mxGraphicExporter; PageInfoMap maPagesMap; @@ -183,9 +197,9 @@ private: sal_uInt16 exportDrawPageBackground(sal_uInt16 nPage, ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xPage); sal_uInt16 exportMasterPageObjects(sal_uInt16 nPage, ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xMasterPage); - void exportDrawPageContents( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xPage, bool bStream, bool bMaster ); - void exportShapes( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xShapes, bool bStream, bool bMaster ); - void exportShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape, bool bMaster); + void exportDrawPageContents( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xPage, bool bStream, bool bMaster ); + void exportShapes( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xShapes, bool bStream, bool bMaster ); + void exportShape( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape, bool bMaster); sal_uInt32 ActionSummer(::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape); sal_uInt32 ActionSummer(::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xShapes); diff --git a/filter/source/flash/swffilter.cxx b/filter/source/flash/swffilter.cxx index 511c7be..2d0fb40 100644 --- a/filter/source/flash/swffilter.cxx +++ b/filter/source/flash/swffilter.cxx @@ -35,6 +35,13 @@ #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/task/XStatusIndicatorFactory.hpp> #include <com/sun/star/io/XOutputStream.hpp> + +#include <com/sun/star/drawing/XDrawPage.hpp> +#include <com/sun/star/drawing/XShapes.hpp> +#include <com/sun/star/frame/XDesktop.hdl> +#include <com/sun/star/frame/XController.hdl> +#include <com/sun/star/view/XSelectionSupplier.hpp> + #include <cppuhelper/implbase1.hxx> #include <cppuhelper/implbase4.hxx> #include <osl/file.hxx> @@ -51,6 +58,7 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::drawing; using namespace ::com::sun::star::presentation; using namespace ::com::sun::star::task; +using namespace ::com::sun::star::view; using ::rtl::OUString; using ::rtl::OString; @@ -152,6 +160,11 @@ class FlashExportFilter : public cppu::WeakImplHelper4 Reference< XMultiServiceFactory > mxMSF; Reference< XStatusIndicator> mxStatusIndicator; + // #56084# variables for selection export + Reference< XShapes > mxSelectedShapes; + Reference< XDrawPage > mxSelectedDrawPage; + bool mbExportSelection; + osl::File* mpFile; public: @@ -180,7 +193,13 @@ public: // ----------------------------------------------------------------------------- FlashExportFilter::FlashExportFilter(const Reference< XMultiServiceFactory > &rxMSF) -: mxMSF( rxMSF ) +: mxDoc(), + mxMSF( rxMSF ), + mxStatusIndicator(), + mxSelectedShapes(), + mxSelectedDrawPage(), + mbExportSelection(false), + mpFile(0) { } @@ -238,7 +257,56 @@ sal_Bool SAL_CALL FlashExportFilter::filter( const ::com::sun::star::uno::Sequen Sequence< PropertyValue > aFilterData; aFilterData = findPropertyValue<Sequence< PropertyValue > >(aDescriptor, "FilterData", aFilterData); - if (findPropertyValue<sal_Bool>(aFilterData, "ExportMultipleFiles", false )) + // #56084# check if selection shall be exported only; if yes, get the selected page and the selection itself + if(findPropertyValue<sal_Bool>(aDescriptor, "SelectionOnly", sal_False)) + { + Reference< XDesktop > xDesktop(mxMSF->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop")), UNO_QUERY); + + if(xDesktop.is()) + { + Reference< XFrame > xFrame(xDesktop->getCurrentFrame()); + + if(xFrame.is()) + { + Reference< XController > xController(xFrame->getController()); + + if(xController.is()) + { + Reference< XDrawView > xDrawView(xController, UNO_QUERY); + + if(xDrawView.is()) + { + mxSelectedDrawPage = xDrawView->getCurrentPage(); + } + + if(mxSelectedDrawPage.is()) + { + Reference< XSelectionSupplier > xSelection(xController, UNO_QUERY); + + if(xSelection.is()) + { + Any aSelection; + + if(xSelection->getSelection() >>= aSelection) + { + aSelection >>= mxSelectedShapes; + } + } + } + } + } + } + } + + if(mxSelectedDrawPage.is() && mxSelectedShapes.is() && mxSelectedShapes->getCount()) + { + // #56084# to export selection we need the selected page and the selected shapes. + // There must be shapes selected, else fallback to regular export (export all) + mbExportSelection = true; + } + + // #56084# no multiple files (suppress) when selection since selection can only export a single page + if (!mbExportSelection && findPropertyValue<sal_Bool>(aFilterData, "ExportMultipleFiles", false )) { ExportAsMultipleFiles(aDescriptor); } @@ -332,8 +400,12 @@ sal_Bool FlashExportFilter::ExportAsMultipleFiles(const Sequence< PropertyValue err = osl_writeFile(xBackgroundConfig, "slides=", strlen("slides="), &bytesWritten); } - FlashExporter aFlashExporter( mxMSF, findPropertyValue<sal_Int32>(aFilterData, "CompressMode", 75), - findPropertyValue<sal_Bool>(aFilterData, "ExportOLEAsJPEG", false)); + FlashExporter aFlashExporter( + mxMSF, + mxSelectedShapes, + mxSelectedDrawPage, + findPropertyValue<sal_Int32>(aFilterData, "CompressMode", 75), + findPropertyValue<sal_Bool>(aFilterData, "ExportOLEAsJPEG", false)); const sal_Int32 nPageCount = xDrawPages->getCount(); if ( mxStatusIndicator.is() ) @@ -424,8 +496,12 @@ sal_Bool FlashExportFilter::ExportAsSingleFile(const Sequence< PropertyValue >& return sal_False; } - FlashExporter aFlashExporter( mxMSF, findPropertyValue<sal_Int32>(aFilterData, "CompressMode", 75), - findPropertyValue<sal_Bool>(aFilterData, "ExportOLEAsJPEG", false)); + FlashExporter aFlashExporter( + mxMSF, + mxSelectedShapes, + mxSelectedDrawPage, + findPropertyValue<sal_Int32>(aFilterData, "CompressMode", 75), + findPropertyValue<sal_Bool>(aFilterData, "ExportOLEAsJPEG", false)); return aFlashExporter.exportAll( mxDoc, xOutputStream, mxStatusIndicator ); } _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
