[Libreoffice-commits] core.git: include/oox oox/source sd/qa
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Mar 11 16:38:33 UTC 2019
include/oox/drawingml/shape.hxx | 23 ++++++++------
oox/source/drawingml/shape.cxx | 35 +++++++++++++++-------
oox/source/ppt/pptshape.cxx | 4 ++
sd/qa/unit/data/pptx/smartart-interopgrabbag.pptx |binary
sd/qa/unit/import-tests-smartart.cxx | 21 +++++++++++++
5 files changed, 62 insertions(+), 21 deletions(-)
New commits:
commit dba1f992d0757b9c353dd41d55dd89ecafd70603
Author: Grzegorz Araminowicz <grzegorz.araminowicz at collabora.com>
AuthorDate: Fri Mar 8 12:45:24 2019 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Mar 11 17:38:07 2019 +0100
PPTX import: save SmartArt markup into InteropGrabBag
it will allow to preserve SmartArt when saving PPTX files
Change-Id: I9bb66c59d202b4ce426864599014d042d4aa04b0
Reviewed-on: https://gerrit.libreoffice.org/68916
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx
index 0e3263179fa6..4b25aa49e223 100644
--- a/include/oox/drawingml/shape.hxx
+++ b/include/oox/drawingml/shape.hxx
@@ -229,6 +229,15 @@ public:
protected:
+ enum FrameType
+ {
+ FRAMETYPE_GENERIC, ///< Generic shape, no special type.
+ FRAMETYPE_OLEOBJECT, ///< OLE object embedded in a shape.
+ FRAMETYPE_CHART, ///< Chart embedded in a shape.
+ FRAMETYPE_DIAGRAM, ///< Complex diagram drawing shape.
+ FRAMETYPE_TABLE ///< A table embedded in a shape.
+ };
+
css::uno::Reference< css::drawing::XShape > const &
createAndInsert(
::oox::core::XmlFilterBase& rFilterBase,
@@ -250,7 +259,8 @@ protected:
ShapeIdMap* pShapeMap,
const basegfx::B2DHomMatrix& aTransformation );
- void keepDiagramCompatibilityInfo( ::oox::core::XmlFilterBase const & rFilterBase );
+ void keepDiagramCompatibilityInfo();
+ void convertSmartArtToMetafile( ::oox::core::XmlFilterBase const& rFilterBase );
css::uno::Reference< css::drawing::XShape >
renderDiagramToGraphic( ::oox::core::XmlFilterBase const & rFilterBase );
@@ -310,20 +320,13 @@ protected:
::std::vector<OUString> maExtDrawings;
Color maFontRefColorForNodes;
+ FrameType meFrameType; ///< Type for graphic frame shapes.
+
private:
- enum FrameType
- {
- FRAMETYPE_GENERIC, ///< Generic shape, no special type.
- FRAMETYPE_OLEOBJECT, ///< OLE object embedded in a shape.
- FRAMETYPE_CHART, ///< Chart embedded in a shape.
- FRAMETYPE_DIAGRAM, ///< Complex diagram drawing shape.
- FRAMETYPE_TABLE ///< A table embedded in a shape.
- };
typedef std::shared_ptr< ::oox::vml::OleObjectInfo > OleObjectInfoRef;
typedef std::shared_ptr< ChartShapeInfo > ChartShapeInfoRef;
- FrameType meFrameType; ///< Type for graphic frame shapes.
OleObjectInfoRef mxOleObjectInfo; ///< Additional data for OLE objects.
ChartShapeInfoRef mxChartShapeInfo; ///< Additional data for chart shapes.
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index e35a9b2e7703..0c522bdfe63e 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -283,8 +283,9 @@ void Shape::addShape(
if( meFrameType == FRAMETYPE_DIAGRAM )
{
+ keepDiagramCompatibilityInfo();
if( !SvtFilterOptions::Get().IsSmartArt2Shape() )
- keepDiagramCompatibilityInfo( rFilterBase );
+ convertSmartArtToMetafile( rFilterBase );
}
}
}
@@ -1387,7 +1388,7 @@ Reference< XShape > const & Shape::createAndInsert(
return mxShape;
}
-void Shape::keepDiagramCompatibilityInfo( XmlFilterBase const & rFilterBase )
+void Shape::keepDiagramCompatibilityInfo()
{
try
{
@@ -1418,21 +1419,33 @@ void Shape::keepDiagramCompatibilityInfo( XmlFilterBase const & rFilterBase )
xSet->setPropertyValue( aGrabBagPropName, Any( aGrabBag ) );
} else
xSet->setPropertyValue( aGrabBagPropName, Any( maDiagramDoms ) );
+ }
+ catch( const Exception& e )
+ {
+ SAL_WARN( "oox.drawingml", "Shape::keepDiagramCompatibilityInfo: " << e );
+ }
+}
- xSet->setPropertyValue( "MoveProtect", Any( true ) );
- xSet->setPropertyValue( "SizeProtect", Any( true ) );
+void Shape::convertSmartArtToMetafile(XmlFilterBase const & rFilterBase)
+{
+ try
+ {
+ Reference<XPropertySet> xSet(mxShape, UNO_QUERY_THROW);
+
+ xSet->setPropertyValue("MoveProtect", Any(true));
+ xSet->setPropertyValue("SizeProtect", Any(true));
// Replace existing shapes with a new Graphic Object rendered
// from them
- Reference < XShape > xShape( renderDiagramToGraphic( rFilterBase ) );
- Reference < XShapes > xShapes( mxShape, UNO_QUERY_THROW );
- while( xShapes->hasElements() )
- xShapes->remove( Reference < XShape > ( xShapes->getByIndex( 0 ), UNO_QUERY_THROW ) );
- xShapes->add( xShape );
+ Reference<XShape> xShape(renderDiagramToGraphic(rFilterBase));
+ Reference<XShapes> xShapes(mxShape, UNO_QUERY_THROW);
+ while (xShapes->hasElements())
+ xShapes->remove(Reference<XShape>(xShapes->getByIndex(0), UNO_QUERY_THROW));
+ xShapes->add(xShape);
}
- catch( const Exception& e )
+ catch (const Exception& e)
{
- SAL_WARN( "oox.drawingml", "Shape::keepDiagramCompatibilityInfo: " << e );
+ SAL_WARN("oox.drawingml", "Shape::convertSmartArtToMetafile: " << e);
}
}
diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx
index 362801b8c438..52f9d5236612 100644
--- a/oox/source/ppt/pptshape.cxx
+++ b/oox/source/ppt/pptshape.cxx
@@ -33,6 +33,7 @@
#include <sal/log.hxx>
#include <oox/ppt/slidepersist.hxx>
#include <oox/token/tokens.hxx>
+#include <unotools/fltrcfg.hxx>
using namespace ::oox::core;
using namespace ::oox::drawingml;
@@ -397,6 +398,9 @@ void PPTShape::addShape(
Reference<XShapes> xShapes(xShape, UNO_QUERY);
if (xShapes.is())
addChildren( rFilterBase, *this, pTheme, xShapes, pShapeMap, aTransformation );
+
+ if (meFrameType == FRAMETYPE_DIAGRAM)
+ keepDiagramCompatibilityInfo();
}
}
catch (const Exception&)
diff --git a/sd/qa/unit/data/pptx/smartart-interopgrabbag.pptx b/sd/qa/unit/data/pptx/smartart-interopgrabbag.pptx
new file mode 100755
index 000000000000..ef678b6c3398
Binary files /dev/null and b/sd/qa/unit/data/pptx/smartart-interopgrabbag.pptx differ
diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx
index 22513adc312a..81474f2071ae 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -69,6 +69,7 @@ public:
void testOrgChart();
void testCycleMatrix();
void testPictureStrip();
+ void testInteropGrabBag();
CPPUNIT_TEST_SUITE(SdImportTestSmartArt);
@@ -102,6 +103,7 @@ public:
CPPUNIT_TEST(testOrgChart);
CPPUNIT_TEST(testCycleMatrix);
CPPUNIT_TEST(testPictureStrip);
+ CPPUNIT_TEST(testInteropGrabBag);
CPPUNIT_TEST_SUITE_END();
};
@@ -990,6 +992,25 @@ void SdImportTestSmartArt::testPictureStrip()
xDocShRef->DoClose();
}
+void SdImportTestSmartArt::testInteropGrabBag()
+{
+ sd::DrawDocShellRef xDocShRef = loadURL(
+ m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-interopgrabbag.pptx"), PPTX);
+ uno::Reference<drawing::XShape> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xGroup.is());
+
+ uno::Reference<beans::XPropertySet> xPropertySet(xGroup, uno::UNO_QUERY_THROW);
+ uno::Sequence<beans::PropertyValue> aGrabBagSeq;
+ xPropertySet->getPropertyValue("InteropGrabBag") >>= aGrabBagSeq;
+ comphelper::SequenceAsHashMap aGrabBag(aGrabBagSeq);
+ CPPUNIT_ASSERT(aGrabBag.find("OOXData") != aGrabBag.end());
+ CPPUNIT_ASSERT(aGrabBag.find("OOXLayout") != aGrabBag.end());
+ CPPUNIT_ASSERT(aGrabBag.find("OOXStyle") != aGrabBag.end());
+ CPPUNIT_ASSERT(aGrabBag.find("OOXColor") != aGrabBag.end());
+
+ xDocShRef->DoClose();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTestSmartArt);
CPPUNIT_PLUGIN_IMPLEMENT();
More information about the Libreoffice-commits
mailing list