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/07 16:58:01 UTC
svn commit: r1585498 - in /openoffice/trunk/main/filter/source/svg:
svgexport.cxx svgfilter.cxx svgfilter.hxx
Author: alg
Date: Mon Apr 7 14:58:01 2014
New Revision: 1585498
URL: http://svn.apache.org/r1585498
Log:
i124608 Added functionality to export only selected objects in SVG export
Modified:
openoffice/trunk/main/filter/source/svg/svgexport.cxx
openoffice/trunk/main/filter/source/svg/svgfilter.cxx
openoffice/trunk/main/filter/source/svg/svgfilter.hxx
Modified: openoffice/trunk/main/filter/source/svg/svgexport.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/filter/source/svg/svgexport.cxx?rev=1585498&r1=1585497&r2=1585498&view=diff
==============================================================================
--- openoffice/trunk/main/filter/source/svg/svgexport.cxx (original)
+++ openoffice/trunk/main/filter/source/svg/svgexport.cxx Mon Apr 7 14:58:01 2014
@@ -213,6 +213,11 @@ sal_Bool SVGFilter::implExport( const Se
{
pValue[ i ].Value >>= maFilterData;
}
+ else if( pValue[ i ].Name.equalsAscii( "ShapeSelection" ) )
+ {
+ // #124608# read selection if given
+ pValue[ i ].Value >>= maShapeSelection;
+ }
}
// if no filter data is given use stored/prepared ones
@@ -507,10 +512,19 @@ sal_Bool SVGFilter::implExportDocument(
if( -1 != nVisible )
{
- if( bSinglePage )
- implExportPages( rxMasterPages, nVisibleMaster, nVisibleMaster, nVisibleMaster, sal_True );
- else
- {
+ if(bSinglePage)
+ {
+ if(maShapeSelection.is() && maShapeSelection->getCount())
+ {
+ // #124608# export a given object selection, so no MasterPage export at all
+ }
+ else
+ {
+ implExportPages(rxMasterPages,nVisibleMaster,nVisibleMaster,nVisibleMaster,sal_True);
+ }
+ }
+ else
+ {
implGenerateMetaData( rxMasterPages, rxDrawPages );
implGenerateScript( rxMasterPages, rxDrawPages );
implExportPages( rxMasterPages, 0, rxMasterPages->getCount() - 1, nVisibleMaster, sal_True );
@@ -623,7 +637,17 @@ sal_Bool SVGFilter::implExportPages( con
if( xDrawPage.is() )
{
- Reference< XShapes > xShapes( xDrawPage, UNO_QUERY );
+ Reference< XShapes > xShapes;
+
+ if(maShapeSelection.is() && maShapeSelection->getCount())
+ {
+ // #124608# export a given object selection
+ xShapes = maShapeSelection;
+ }
+ else
+ {
+ xShapes = Reference< XShapes >( xDrawPage, UNO_QUERY );
+ }
if( xShapes.is() )
{
@@ -860,6 +884,7 @@ sal_Bool SVGFilter::implCreateObjects( c
{
if( SVG_EXPORT_ALLPAGES == nPageToExport )
{
+ // export the whole document
sal_Int32 i, nCount;
for( i = 0, nCount = rxMasterPages->getCount(); i < nCount; ++i )
@@ -899,34 +924,43 @@ sal_Bool SVGFilter::implCreateObjects( c
DBG_ASSERT( nPageToExport >= 0 && nPageToExport < rxDrawPages->getCount(),
"SVGFilter::implCreateObjects: invalid page number to export" );
- Reference< XDrawPage > xDrawPage;
-
- rxDrawPages->getByIndex( nPageToExport ) >>= xDrawPage;
+ if(maShapeSelection.is() && maShapeSelection->getCount())
+ {
+ // #124608# export a given object selection
+ implCreateObjectsFromShapes(maShapeSelection);
+ }
+ else
+ {
+ // export a given xDrawPage
+ Reference< XDrawPage > xDrawPage;
- if( xDrawPage.is() )
- {
- Reference< XMasterPageTarget > xMasterTarget( xDrawPage, UNO_QUERY );
+ rxDrawPages->getByIndex(nPageToExport) >>= xDrawPage;
- if( xMasterTarget.is() )
- {
- Reference< XDrawPage > xMasterPage( xMasterTarget->getMasterPage() );
+ if(xDrawPage.is())
+ {
+ Reference< XMasterPageTarget > xMasterTarget(xDrawPage,UNO_QUERY);
- if( xMasterPage.is() )
+ if(xMasterTarget.is())
{
- Reference< XShapes > xShapes( xMasterPage, UNO_QUERY );
+ Reference< XDrawPage > xMasterPage(xMasterTarget->getMasterPage());
- implCreateObjectsFromBackground( xMasterPage );
+ if(xMasterPage.is())
+ {
+ Reference< XShapes > xShapes(xMasterPage,UNO_QUERY);
+
+ implCreateObjectsFromBackground(xMasterPage);
- if( xShapes.is() )
- implCreateObjectsFromShapes( xShapes );
+ if(xShapes.is())
+ implCreateObjectsFromShapes(xShapes);
+ }
}
- }
-
- Reference< XShapes > xShapes( xDrawPage, UNO_QUERY );
- if( xShapes.is() )
- implCreateObjectsFromShapes( xShapes );
- }
+ Reference< XShapes > xShapes(xDrawPage,UNO_QUERY);
+
+ if(xShapes.is())
+ implCreateObjectsFromShapes(xShapes);
+ }
+ }
}
return sal_True;
Modified: openoffice/trunk/main/filter/source/svg/svgfilter.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/filter/source/svg/svgfilter.cxx?rev=1585498&r1=1585497&r2=1585498&view=diff
==============================================================================
--- openoffice/trunk/main/filter/source/svg/svgfilter.cxx (original)
+++ openoffice/trunk/main/filter/source/svg/svgfilter.cxx Mon Apr 7 14:58:01 2014
@@ -32,6 +32,7 @@
#include <com/sun/star/drawing/XDrawView.hpp>
#include <com/sun/star/frame/XDesktop.hdl>
#include <com/sun/star/frame/XController.hdl>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
#define SVG_FILTER_SERVICE_NAME "com.sun.star.comp.Draw.SVGFilter"
#define SVG_FILTER_IMPLEMENTATION_NAME SVG_FILTER_SERVICE_NAME
@@ -86,7 +87,21 @@ sal_Bool SAL_CALL SVGFilter::filter( con
#endif
if( mxSrcDoc.is() )
{
- uno::Reference< frame::XDesktop > xDesktop( mxMSF->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.frame.Desktop" ) ),
+ // #124608# detext selection
+ sal_Bool bSelectionOnly = sal_False;
+ bool bGotSelection(false);
+ Reference< drawing::XShapes > xShapes;
+
+ // #124608# extract Single selection wanted from dialog return values
+ for ( sal_Int32 nInd = 0; nInd < rDescriptor.getLength(); nInd++ )
+ {
+ if ( rDescriptor[nInd].Name.equalsAscii( "SelectionOnly" ) )
+ {
+ rDescriptor[nInd].Value >>= bSelectionOnly;
+ }
+ }
+
+ uno::Reference< frame::XDesktop > xDesktop( mxMSF->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.frame.Desktop" ) ),
uno::UNO_QUERY);
if( xDesktop.is() )
{
@@ -110,23 +125,67 @@ sal_Bool SAL_CALL SVGFilter::filter( con
getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Number" ) ) ) >>= nCurrentPageNumber;
}
}
- }
+
+ if(bSelectionOnly)
+ {
+ // #124608# when selection only is wanted, get the current object selection
+ // from the DrawView
+ Reference< view::XSelectionSupplier > xSelection (xController, UNO_QUERY);
+
+ if (xSelection.is())
+ {
+ uno::Any aSelection;
+
+ if(xSelection->getSelection() >>= aSelection)
+ {
+ bGotSelection = (sal_True == ( aSelection >>= xShapes ));
+ }
+ }
+ }
+ }
}
}
-
- Sequence< PropertyValue > aNewDescriptor( rDescriptor );
-
- if( nCurrentPageNumber > 0 )
- {
- const sal_uInt32 nOldLength = rDescriptor.getLength();
-
- aNewDescriptor.realloc( nOldLength + 1 );
- aNewDescriptor[ nOldLength ].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PagePos" ) );
- aNewDescriptor[ nOldLength ].Value <<= static_cast< sal_Int16 >( nCurrentPageNumber - 1 );
- }
-
- bRet = implExport( aNewDescriptor );
- }
+
+ if(bSelectionOnly && bGotSelection && 0 == xShapes->getCount())
+ {
+ // #124608# export selection, got xShapes but no shape selected -> nothing
+ // to export, we are done (maybe return true, but a hint that nothing was done
+ // may be useful; it may have happened by error)
+ bRet = sal_False;
+ }
+ else
+ {
+ Sequence< PropertyValue > aNewDescriptor(rDescriptor);
+ const bool bSinglePage(nCurrentPageNumber > 0);
+
+ if(bSinglePage || bGotSelection)
+ {
+ const sal_uInt32 nOldLength = rDescriptor.getLength();
+ sal_uInt32 nInsert(nOldLength);
+
+ aNewDescriptor.realloc(nOldLength + (bSinglePage ? 1 : 0) + (bGotSelection ? 1 : 0));
+
+ if(bSinglePage)
+ {
+ aNewDescriptor[nInsert].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PagePos"));
+ aNewDescriptor[nInsert].Value <<= static_cast<sal_Int16>(nCurrentPageNumber - 1);
+ nInsert++;
+ }
+
+ if(bGotSelection)
+ {
+ // #124608# add retrieved ShapeSelection if export of only selected shapes is wanted
+ // so that the filter implementation can use it
+ aNewDescriptor[nInsert].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShapeSelection"));
+ aNewDescriptor[nInsert].Value <<= xShapes;
+ // reactivate this when you add other properties to aNewDescriptor
+ // nInsert++;
+ }
+ }
+
+ bRet = implExport(aNewDescriptor);
+ }
+ }
else
bRet = sal_False;
Modified: openoffice/trunk/main/filter/source/svg/svgfilter.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/filter/source/svg/svgfilter.hxx?rev=1585498&r1=1585497&r2=1585498&view=diff
==============================================================================
--- openoffice/trunk/main/filter/source/svg/svgfilter.hxx (original)
+++ openoffice/trunk/main/filter/source/svg/svgfilter.hxx Mon Apr 7 14:58:01 2014
@@ -246,6 +246,10 @@ private:
#endif
Reference< XDrawPage > mxDefaultPage;
Sequence< PropertyValue > maFilterData;
+
+ // #124608# explicit ShapeSelection for export when export of the selection is wanted
+ Reference< XShapes > maShapeSelection;
+
UniqueIdVector maUniqueIdVector;
sal_Int32 mnMasterSlideId;
sal_Int32 mnSlideId;