You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by al...@apache.org on 2014/04/08 14:24:24 UTC
svn commit: r1585706 - in /openoffice/trunk/main/filter/source/flash:
swfexporter.cxx swfexporter.hxx swffilter.cxx
Author: alg
Date: Tue Apr 8 12:24:24 2014
New Revision: 1585706
URL: http://svn.apache.org/r1585706
Log:
i56084 added support for export selection in swf export
Modified:
openoffice/trunk/main/filter/source/flash/swfexporter.cxx
openoffice/trunk/main/filter/source/flash/swfexporter.hxx
openoffice/trunk/main/filter/source/flash/swffilter.cxx
Modified: openoffice/trunk/main/filter/source/flash/swfexporter.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/filter/source/flash/swfexporter.cxx?rev=1585706&r1=1585705&r2=1585706&view=diff
==============================================================================
--- openoffice/trunk/main/filter/source/flash/swfexporter.cxx (original)
+++ openoffice/trunk/main/filter/source/flash/swfexporter.cxx Tue Apr 8 12:24:24 2014
@@ -99,14 +99,33 @@ void PageInfo::addShape( ShapeInfo* pSha
// -----------------------------------------------------------------------------
-FlashExporter::FlashExporter(const Reference< XMultiServiceFactory > &rxMSF, sal_Int32 nJPEGCompressMode, sal_Bool bExportOLEAsJPEG)
-: mxMSF( rxMSF ),
- mpWriter( NULL ),
- mnJPEGcompressMode(nJPEGCompressMode),
- mbExportOLEAsJPEG(bExportOLEAsJPEG),
- mbPresentation(true),
- mnPageNumber( - 1 )
+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)
{
+ if(mxSelectedDrawPage.is() && mxSelectedShapes.is() && mxSelectedShapes->getCount())
+ {
+ // #56084# determine export selection
+ mbExportSelection = true;
+ }
}
// -----------------------------------------------------------------------------
@@ -146,7 +165,16 @@ sal_Bool FlashExporter::exportAll( Refer
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( Refer
return false; // no writer, no cookies
}
- const sal_Int32 nPageCount = xDrawPages->getCount();
- sal_uInt16 nPage;
- if ( xStatusIndicator.is() )
- xStatusIndicator->start(OUString( RTL_CONSTASCII_USTRINGPARAM( "Macromedia Flash (SWF)" )), nPageCount);
+ // #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++)
{
- mnPageNumber = nPage + 1;
+ // #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( Refer
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::exportMasterPa
/** 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::exportDrawPageConten
/** 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( Refere
// -----------------------------------------------------------------------------
/** 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() )
Modified: openoffice/trunk/main/filter/source/flash/swfexporter.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/filter/source/flash/swfexporter.hxx?rev=1585706&r1=1585705&r2=1585706&view=diff
==============================================================================
--- openoffice/trunk/main/filter/source/flash/swfexporter.hxx (original)
+++ openoffice/trunk/main/filter/source/flash/swfexporter.hxx Tue Apr 8 12:24:24 2014
@@ -155,7 +155,15 @@ typedef ::std::map<sal_uInt32, PageInfo>
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,16 +184,22 @@ public:
private:
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
- ::com::sun::star::uno::Reference< ::com::sun::star::document::XExporter > mxGraphicExporter;
+
+ // #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;
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);
Modified: openoffice/trunk/main/filter/source/flash/swffilter.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/filter/source/flash/swffilter.cxx?rev=1585706&r1=1585705&r2=1585706&view=diff
==============================================================================
--- openoffice/trunk/main/filter/source/flash/swffilter.cxx (original)
+++ openoffice/trunk/main/filter/source/flash/swffilter.cxx Tue Apr 8 12:24:24 2014
@@ -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,7 +160,12 @@ class FlashExportFilter : public cppu::W
Reference< XMultiServiceFactory > mxMSF;
Reference< XStatusIndicator> mxStatusIndicator;
- osl::File* mpFile;
+ // #56084# variables for selection export
+ Reference< XShapes > mxSelectedShapes;
+ Reference< XDrawPage > mxSelectedDrawPage;
+ bool mbExportSelection;
+
+ osl::File* mpFile;
public:
FlashExportFilter( const Reference< XMultiServiceFactory > &rxMSF);
@@ -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::fil
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::ExportAsMult
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::ExportAsSing
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 );
}