diff options
Diffstat (limited to 'filter/source/flash')
-rw-r--r-- | filter/source/flash/swfdialog.cxx | 2 | ||||
-rw-r--r-- | filter/source/flash/swfexporter.cxx | 80 | ||||
-rw-r--r-- | filter/source/flash/swfexporter.hxx | 22 | ||||
-rw-r--r-- | filter/source/flash/swffilter.cxx | 90 | ||||
-rw-r--r-- | filter/source/flash/swfwriter.cxx | 2 | ||||
-rw-r--r-- | filter/source/flash/swfwriter1.cxx | 16 |
6 files changed, 178 insertions, 34 deletions
diff --git a/filter/source/flash/swfdialog.cxx b/filter/source/flash/swfdialog.cxx index 256dceac5c9f..4c4acf33f1ac 100644 --- a/filter/source/flash/swfdialog.cxx +++ b/filter/source/flash/swfdialog.cxx @@ -171,7 +171,7 @@ Dialog* SWFDialog::createDialog( Window* pParent ) if( mpResMgr && mxSrcDoc.is() ) { -/* TODO: From the controler we may get information what page is visible and what shapes +/* TODO: From the controller we may get information what page is visible and what shapes are selected, if we optionaly want to limit output to that Any aSelection; diff --git a/filter/source/flash/swfexporter.cxx b/filter/source/flash/swfexporter.cxx index 2e7b8ebe57ef..25fd96506e4e 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 6c7167f55579..03e5e6d06052 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 511c7be38b9f..aafbfe60eb1d 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) { } @@ -192,7 +211,7 @@ OUString exportBackground(FlashExporter &aFlashExporter, Reference< XDrawPage > OUString filename = STR("slide") + VAL(nPage+1) + STR(suffix) + STR(".swf"); OUString fullpath = sPath + STR("/") + filename; - // AS: If suffix is "o" then the last paramter is true (for exporting objects). + // AS: If suffix is "o" then the last parameter is true (for exporting objects). Reference<XOutputStream> xOutputStreamWrap(*(new OslOutputStreamWrapper(fullpath)), UNO_QUERY); sal_uInt16 nCached = aFlashExporter.exportBackgrounds( xDrawPage, xOutputStreamWrap, sal::static_int_cast<sal_uInt16>( nPage ), *suffix == 'o' ); aFlashExporter.Flush(); @@ -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 ); } diff --git a/filter/source/flash/swfwriter.cxx b/filter/source/flash/swfwriter.cxx index a6a2793b947e..f270a269b852 100644 --- a/filter/source/flash/swfwriter.cxx +++ b/filter/source/flash/swfwriter.cxx @@ -545,7 +545,7 @@ sal_Bool Writer::streamSound( const char * filename ) // not the sum of the number of samples in the L and R channels. // // The return code = number of bytes output in mp3buffer. This can be 0. -// If it is <0, an error occured. +// If it is <0, an error occurred. for (int samples_written = 0; samples_written < info.frames; samples_written += samples_per_frame) diff --git a/filter/source/flash/swfwriter1.cxx b/filter/source/flash/swfwriter1.cxx index 018cae8e2b7f..16b68d4b190b 100644 --- a/filter/source/flash/swfwriter1.cxx +++ b/filter/source/flash/swfwriter1.cxx @@ -607,7 +607,7 @@ void Writer::Impl_writeText( const Point& rPos, const String& rText, const sal_I // write text element -/* test code to create a bound rect, not realy working for rotated text +/* test code to create a bound rect, not really working for rotated text Size aTextSize( map( Size( mpVDev->GetTextWidth( rText ), mpVDev->GetTextHeight() ) ) ); Point aMetricPoint( map( Point( aMetric.GetLeading(), aMetric.GetAscent() ) ) ); @@ -710,7 +710,7 @@ void Writer::Impl_writeText( const Point& rPos, const String& rText, const sal_I maShapeIds.push_back( nTextId ); - // AS: Write strikeout and underline, if neccessary. This code was originally taken from the SVG + // AS: Write strikeout and underline, if necessary. This code was originally taken from the SVG // export facility, although the positioning had to be tweaked a little. I can't explain the // numbers, but the flash lines up very well with the original OOo document. All of this should // probably be converted to polygons as part of the meta file, though, as we don't handle any @@ -757,9 +757,9 @@ void Writer::Impl_writeText( const Point& rPos, const String& rText, const sal_I } // ----------------------------------------------------------------------------- -// AS: Because JPEGs require the alpha channel provided seperately (JPEG does not -// natively support alpha channel, but SWF lets you provide it seperately), we -// extract the alpha channel into a seperate array here. +// AS: Because JPEGs require the alpha channel provided separately (JPEG does not +// natively support alpha channel, but SWF lets you provide it separately), we +// extract the alpha channel into a separate array here. void getBitmapData( const BitmapEx& aBmpEx, sal_uInt8*& tgadata, sal_uInt8*& tgaAlphadata, sal_uInt32& nWidth, sal_uInt32& nHeight ) { if( !aBmpEx.IsEmpty() ) @@ -860,7 +860,7 @@ sal_uInt16 Writer::defineBitmap( const BitmapEx &bmpSource, sal_Int32 nJPEGQuali #endif // AS: SWF files let you provide an Alpha mask for JPEG images, but we have - // to ZLIB compress the alpha channel seperately. + // to ZLIB compress the alpha channel separately. uLong alpha_compressed_size = 0; sal_uInt8 *pAlphaCompressed = NULL; if (bmpSource.IsAlpha() || bmpSource.IsTransparent()) @@ -1043,7 +1043,7 @@ void Writer::Impl_writeBmp( sal_uInt16 nBitmapId, sal_uInt32 width, sal_uInt32 h void Writer::Impl_writeJPEG(sal_uInt16 nBitmapId, const sal_uInt8* pJpgData, sal_uInt32 nJpgDataLength, sal_uInt8 *pAlphaCompressed, sal_uInt32 alpha_compressed_size ) { - // AS: Go through the actuall JPEG bits, seperating out the + // AS: Go through the actuall JPEG bits, separating out the // header fields from the actual image fields. Fields are // identifed by 0xFFXX where XX is the field type. Both // the header and the image need start and stop (D8 and D9), @@ -1092,7 +1092,7 @@ void Writer::Impl_writeJPEG(sal_uInt16 nBitmapId, const sal_uInt8* pJpgData, sal nLength = 2 + (pJpgSearch[2]<<8) + pJpgSearch[3]; } - // AS: I'm refering to libjpeg for a list of what these + // AS: I'm referring to libjpeg for a list of what these // markers are. See jdmarker.c for a list. // AS: I'm ignoring application specific markers 0xE1...0xEF // and comments 0xFE. I don't know what |