Kaydet (Commit) de37aa18 authored tarafından Armin Le Grand's avatar Armin Le Grand Kaydeden (comit) Caolán McNamara

Resolves: #i124608# functionality to export only selected objects...

in SVG export

(cherry picked from commit 42c2b0ce)

Conflicts:
	filter/source/svg/svgexport.cxx
	filter/source/svg/svgfilter.cxx
	filter/source/svg/svgfilter.hxx

Change-Id: Iac4fe6d93c95cc5ab25185245cf642703a02d0ed
üst b5e1693f
...@@ -816,6 +816,10 @@ sal_Bool SVGFilter::implExportDocument() ...@@ -816,6 +816,10 @@ sal_Bool SVGFilter::implExportDocument()
implEmbedBulletGlyphs(); implEmbedBulletGlyphs();
implExportTextEmbeddedBitmaps(); implExportTextEmbeddedBitmaps();
} }
bool bSelection = mbSinglePage && maShapeSelection.is() && maShapeSelection->getCount();
// #i124608# export a given object selection, so no MasterPage export at all
if (!bSelection)
implExportMasterPages( mMasterPageTargets, 0, mMasterPageTargets.getLength() - 1 ); implExportMasterPages( mMasterPageTargets, 0, mMasterPageTargets.getLength() - 1 );
implExportDrawPages( mSelectedPages, 0, nLastPage ); implExportDrawPages( mSelectedPages, 0, nLastPage );
...@@ -1401,7 +1405,7 @@ sal_Bool SVGFilter::implExportMasterPages( const SVGFilter::XDrawPageSequence & ...@@ -1401,7 +1405,7 @@ sal_Bool SVGFilter::implExportMasterPages( const SVGFilter::XDrawPageSequence &
sal_Int32 nFirstPage, sal_Int32 nLastPage ) sal_Int32 nFirstPage, sal_Int32 nLastPage )
{ {
DBG_ASSERT( nFirstPage <= nLastPage, DBG_ASSERT( nFirstPage <= nLastPage,
"SVGFilter::implExportPages: nFirstPage > nLastPage" ); "SVGFilter::implExportMasterPages: nFirstPage > nLastPage" );
// When the exported slides are more than one we wrap master page elements // When the exported slides are more than one we wrap master page elements
// with a svg <defs> element. // with a svg <defs> element.
...@@ -1434,7 +1438,7 @@ sal_Bool SVGFilter::implExportDrawPages( const SVGFilter::XDrawPageSequence & rx ...@@ -1434,7 +1438,7 @@ sal_Bool SVGFilter::implExportDrawPages( const SVGFilter::XDrawPageSequence & rx
sal_Int32 nFirstPage, sal_Int32 nLastPage ) sal_Int32 nFirstPage, sal_Int32 nLastPage )
{ {
DBG_ASSERT( nFirstPage <= nLastPage, DBG_ASSERT( nFirstPage <= nLastPage,
"SVGFilter::implExportPages: nFirstPage > nLastPage" ); "SVGFilter::implExportDrawPages: nFirstPage > nLastPage" );
// We wrap all slide in a group element with class name "SlideGroup". // We wrap all slide in a group element with class name "SlideGroup".
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", "SlideGroup" ); mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", "SlideGroup" );
...@@ -1443,7 +1447,17 @@ sal_Bool SVGFilter::implExportDrawPages( const SVGFilter::XDrawPageSequence & rx ...@@ -1443,7 +1447,17 @@ sal_Bool SVGFilter::implExportDrawPages( const SVGFilter::XDrawPageSequence & rx
sal_Bool bRet = sal_False; sal_Bool bRet = sal_False;
for( sal_Int32 i = nFirstPage; i <= nLastPage; ++i ) for( sal_Int32 i = nFirstPage; i <= nLastPage; ++i )
{ {
Reference< XShapes > xShapes( rxPages[i], UNO_QUERY ); Reference< XShapes > xShapes;
if (maShapeSelection.is() && maShapeSelection->getCount())
{
// #i124608# export a given object selection
xShapes = maShapeSelection;
}
else
{
xShapes = Reference< XShapes >( rxPages[i], UNO_QUERY );
}
if( xShapes.is() ) if( xShapes.is() )
{ {
...@@ -1780,6 +1794,17 @@ sal_Bool SVGFilter::implExportShape( const Reference< XShape >& rxShape, ...@@ -1780,6 +1794,17 @@ sal_Bool SVGFilter::implExportShape( const Reference< XShape >& rxShape,
sal_Bool SVGFilter::implCreateObjects() sal_Bool SVGFilter::implCreateObjects()
{ {
if (maShapeSelection.is() && maShapeSelection->getCount())
{
// #i124608# export a given object selection
if (mSelectedPages.getLength() && mSelectedPages[0].is())
{
implCreateObjectsFromShapes(mSelectedPages[0], maShapeSelection);
return sal_True;
}
return sal_False;
}
sal_Int32 i, nCount; sal_Int32 i, nCount;
for( i = 0, nCount = mMasterPageTargets.getLength(); i < nCount; ++i ) for( i = 0, nCount = mMasterPageTargets.getLength(); i < nCount; ++i )
......
...@@ -66,7 +66,6 @@ SVGFilter::SVGFilter( const Reference< XComponentContext >& rxCtx ) : ...@@ -66,7 +66,6 @@ SVGFilter::SVGFilter( const Reference< XComponentContext >& rxCtx ) :
mpDefaultSdrPage( NULL ), mpDefaultSdrPage( NULL ),
mpSdrModel( NULL ), mpSdrModel( NULL ),
mbPresentation( sal_False ), mbPresentation( sal_False ),
mbExportAll( sal_False ),
mbSinglePage( sal_False ), mbSinglePage( sal_False ),
mnVisiblePage( -1 ), mnVisiblePage( -1 ),
mpObjects( NULL ) mpObjects( NULL )
...@@ -97,13 +96,27 @@ sal_Bool SAL_CALL SVGFilter::filter( const Sequence< PropertyValue >& rDescripto ...@@ -97,13 +96,27 @@ sal_Bool SAL_CALL SVGFilter::filter( const Sequence< PropertyValue >& rDescripto
#ifndef DISABLE_EXPORT #ifndef DISABLE_EXPORT
else if( mxSrcDoc.is() ) else if( mxSrcDoc.is() )
{ {
if( !mbExportAll && !mSelectedPages.hasElements() ) // #i124608# detext selection
sal_Bool bSelectionOnly = sal_False;
bool bGotSelection(false);
// #i124608# extract Single selection wanted from dialog return values
for ( sal_Int32 nInd = 0; nInd < rDescriptor.getLength(); nInd++ )
{
if ( rDescriptor[nInd].Name == "SelectionOnly" )
{ {
rDescriptor[nInd].Value >>= bSelectionOnly;
}
}
uno::Reference< frame::XDesktop2 > xDesktop(frame::Desktop::create(mxContext)); uno::Reference< frame::XDesktop2 > xDesktop(frame::Desktop::create(mxContext));
uno::Reference< frame::XFrame > xFrame(xDesktop->getCurrentFrame(), uno::Reference< frame::XFrame > xFrame(xDesktop->getCurrentFrame(),
uno::UNO_QUERY_THROW); uno::UNO_QUERY_THROW);
uno::Reference<frame::XController > xController(xFrame->getController(), uno::Reference<frame::XController > xController(xFrame->getController(),
uno::UNO_QUERY_THROW); uno::UNO_QUERY_THROW);
if( !mSelectedPages.hasElements() )
{
uno::Reference<drawing::XDrawView > xDrawView(xController, uno::Reference<drawing::XDrawView > xDrawView(xController,
uno::UNO_QUERY_THROW); uno::UNO_QUERY_THROW);
uno::Reference<drawing::framework::XControllerManager> xManager(xController, uno::Reference<drawing::framework::XControllerManager> xManager(xController,
...@@ -211,6 +224,31 @@ sal_Bool SAL_CALL SVGFilter::filter( const Sequence< PropertyValue >& rDescripto ...@@ -211,6 +224,31 @@ sal_Bool SAL_CALL SVGFilter::filter( const Sequence< PropertyValue >& rDescripto
} }
} }
if (bSelectionOnly)
{
// #i124608# 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 >>= maShapeSelection ));
}
}
}
if(bSelectionOnly && bGotSelection && 0 == maShapeSelection->getCount())
{
// #i124608# export selection, got maShapeSelection 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 {
/* /*
* We get all master page that are targeted by at least one draw page. * We get all master page that are targeted by at least one draw page.
* The master page are put in an unordered set. * The master page are put in an unordered set.
...@@ -235,6 +273,7 @@ sal_Bool SAL_CALL SVGFilter::filter( const Sequence< PropertyValue >& rDescripto ...@@ -235,6 +273,7 @@ sal_Bool SAL_CALL SVGFilter::filter( const Sequence< PropertyValue >& rDescripto
bRet = implExport( rDescriptor ); bRet = implExport( rDescriptor );
} }
}
#endif #endif
else else
bRet = sal_False; bRet = sal_False;
......
...@@ -242,7 +242,6 @@ private: ...@@ -242,7 +242,6 @@ private:
SdrPage* mpDefaultSdrPage; SdrPage* mpDefaultSdrPage;
SdrModel* mpSdrModel; SdrModel* mpSdrModel;
sal_Bool mbPresentation; sal_Bool mbPresentation;
sal_Bool mbExportAll;
sal_Bool mbSinglePage; sal_Bool mbSinglePage;
sal_Int32 mnVisiblePage; sal_Int32 mnVisiblePage;
PagePropertySet mVisiblePagePropSet; PagePropertySet mVisiblePagePropSet;
...@@ -259,6 +258,8 @@ private: ...@@ -259,6 +258,8 @@ private:
Reference< XComponent > mxDstDoc; Reference< XComponent > mxDstDoc;
Reference< XDrawPage > mxDefaultPage; Reference< XDrawPage > mxDefaultPage;
Sequence< PropertyValue > maFilterData; Sequence< PropertyValue > maFilterData;
// #i124608# explicit ShapeSelection for export when export of the selection is wanted
Reference< XShapes > maShapeSelection;
XDrawPageSequence mSelectedPages; XDrawPageSequence mSelectedPages;
XDrawPageSequence mMasterPageTargets; XDrawPageSequence mMasterPageTargets;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment