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,7 +816,11 @@ sal_Bool SVGFilter::implExportDocument()
implEmbedBulletGlyphs();
implExportTextEmbeddedBitmaps();
}
implExportMasterPages( mMasterPageTargets, 0, mMasterPageTargets.getLength() - 1 );
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 );
implExportDrawPages( mSelectedPages, 0, nLastPage );
if( !mbSinglePage )
......@@ -1401,7 +1405,7 @@ sal_Bool SVGFilter::implExportMasterPages( const SVGFilter::XDrawPageSequence &
sal_Int32 nFirstPage, sal_Int32 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
// with a svg <defs> element.
......@@ -1434,7 +1438,7 @@ sal_Bool SVGFilter::implExportDrawPages( const SVGFilter::XDrawPageSequence & rx
sal_Int32 nFirstPage, sal_Int32 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".
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", "SlideGroup" );
......@@ -1443,7 +1447,17 @@ sal_Bool SVGFilter::implExportDrawPages( const SVGFilter::XDrawPageSequence & rx
sal_Bool bRet = sal_False;
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() )
{
......@@ -1780,6 +1794,17 @@ sal_Bool SVGFilter::implExportShape( const Reference< XShape >& rxShape,
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;
for( i = 0, nCount = mMasterPageTargets.getLength(); i < nCount; ++i )
......
......@@ -66,7 +66,6 @@ SVGFilter::SVGFilter( const Reference< XComponentContext >& rxCtx ) :
mpDefaultSdrPage( NULL ),
mpSdrModel( NULL ),
mbPresentation( sal_False ),
mbExportAll( sal_False ),
mbSinglePage( sal_False ),
mnVisiblePage( -1 ),
mpObjects( NULL )
......@@ -97,13 +96,27 @@ sal_Bool SAL_CALL SVGFilter::filter( const Sequence< PropertyValue >& rDescripto
#ifndef DISABLE_EXPORT
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++ )
{
uno::Reference< frame::XDesktop2 > xDesktop(frame::Desktop::create(mxContext));
uno::Reference< frame::XFrame > xFrame(xDesktop->getCurrentFrame(),
uno::UNO_QUERY_THROW);
uno::Reference<frame::XController > xController(xFrame->getController(),
if ( rDescriptor[nInd].Name == "SelectionOnly" )
{
rDescriptor[nInd].Value >>= bSelectionOnly;
}
}
uno::Reference< frame::XDesktop2 > xDesktop(frame::Desktop::create(mxContext));
uno::Reference< frame::XFrame > xFrame(xDesktop->getCurrentFrame(),
uno::UNO_QUERY_THROW);
uno::Reference<frame::XController > xController(xFrame->getController(),
uno::UNO_QUERY_THROW);
if( !mSelectedPages.hasElements() )
{
uno::Reference<drawing::XDrawView > xDrawView(xController,
uno::UNO_QUERY_THROW);
uno::Reference<drawing::framework::XControllerManager> xManager(xController,
......@@ -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.
* The master page are put in an unordered set.
......@@ -234,6 +272,7 @@ sal_Bool SAL_CALL SVGFilter::filter( const Sequence< PropertyValue >& rDescripto
}
bRet = implExport( rDescriptor );
}
}
#endif
else
......
......@@ -242,7 +242,6 @@ private:
SdrPage* mpDefaultSdrPage;
SdrModel* mpSdrModel;
sal_Bool mbPresentation;
sal_Bool mbExportAll;
sal_Bool mbSinglePage;
sal_Int32 mnVisiblePage;
PagePropertySet mVisiblePagePropSet;
......@@ -259,6 +258,8 @@ private:
Reference< XComponent > mxDstDoc;
Reference< XDrawPage > mxDefaultPage;
Sequence< PropertyValue > maFilterData;
// #i124608# explicit ShapeSelection for export when export of the selection is wanted
Reference< XShapes > maShapeSelection;
XDrawPageSequence mSelectedPages;
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