Kaydet (Commit) 3807fb7c authored tarafından Grzegorz Araminowicz's avatar Grzegorz Araminowicz Kaydeden (comit) Miklos Vajna

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: 's avatarMiklos Vajna <vmiklos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/72471
üst 5e3a3e7d
...@@ -227,6 +227,15 @@ public: ...@@ -227,6 +227,15 @@ public:
protected: 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 & css::uno::Reference< css::drawing::XShape > const &
createAndInsert( createAndInsert(
::oox::core::XmlFilterBase& rFilterBase, ::oox::core::XmlFilterBase& rFilterBase,
...@@ -247,7 +256,8 @@ protected: ...@@ -247,7 +256,8 @@ protected:
ShapeIdMap* pShapeMap, ShapeIdMap* pShapeMap,
const basegfx::B2DHomMatrix& aTransformation ); 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 > css::uno::Reference< css::drawing::XShape >
renderDiagramToGraphic( ::oox::core::XmlFilterBase const & rFilterBase ); renderDiagramToGraphic( ::oox::core::XmlFilterBase const & rFilterBase );
...@@ -306,20 +316,13 @@ protected: ...@@ -306,20 +316,13 @@ protected:
::std::vector<OUString> maExtDrawings; ::std::vector<OUString> maExtDrawings;
Color maFontRefColorForNodes; Color maFontRefColorForNodes;
FrameType meFrameType; ///< Type for graphic frame shapes.
private: 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< ::oox::vml::OleObjectInfo > OleObjectInfoRef;
typedef std::shared_ptr< ChartShapeInfo > ChartShapeInfoRef; typedef std::shared_ptr< ChartShapeInfo > ChartShapeInfoRef;
FrameType meFrameType; ///< Type for graphic frame shapes.
OleObjectInfoRef mxOleObjectInfo; ///< Additional data for OLE objects. OleObjectInfoRef mxOleObjectInfo; ///< Additional data for OLE objects.
ChartShapeInfoRef mxChartShapeInfo; ///< Additional data for chart shapes. ChartShapeInfoRef mxChartShapeInfo; ///< Additional data for chart shapes.
......
...@@ -284,8 +284,9 @@ void Shape::addShape( ...@@ -284,8 +284,9 @@ void Shape::addShape(
if( meFrameType == FRAMETYPE_DIAGRAM ) if( meFrameType == FRAMETYPE_DIAGRAM )
{ {
keepDiagramCompatibilityInfo();
if( !SvtFilterOptions::Get().IsSmartArt2Shape() ) if( !SvtFilterOptions::Get().IsSmartArt2Shape() )
keepDiagramCompatibilityInfo( rFilterBase ); convertSmartArtToMetafile( rFilterBase );
} }
} }
} }
...@@ -1393,7 +1394,7 @@ Reference< XShape > const & Shape::createAndInsert( ...@@ -1393,7 +1394,7 @@ Reference< XShape > const & Shape::createAndInsert(
return mxShape; return mxShape;
} }
void Shape::keepDiagramCompatibilityInfo( XmlFilterBase const & rFilterBase ) void Shape::keepDiagramCompatibilityInfo()
{ {
try try
{ {
...@@ -1424,21 +1425,33 @@ void Shape::keepDiagramCompatibilityInfo( XmlFilterBase const & rFilterBase ) ...@@ -1424,21 +1425,33 @@ void Shape::keepDiagramCompatibilityInfo( XmlFilterBase const & rFilterBase )
xSet->setPropertyValue( aGrabBagPropName, Any( aGrabBag ) ); xSet->setPropertyValue( aGrabBagPropName, Any( aGrabBag ) );
} else } else
xSet->setPropertyValue( aGrabBagPropName, Any( maDiagramDoms ) ); xSet->setPropertyValue( aGrabBagPropName, Any( maDiagramDoms ) );
}
catch( const Exception& e )
{
SAL_WARN( "oox.drawingml", "Shape::keepDiagramCompatibilityInfo: " << e );
}
}
xSet->setPropertyValue( "MoveProtect", Any( true ) ); void Shape::convertSmartArtToMetafile(XmlFilterBase const & rFilterBase)
xSet->setPropertyValue( "SizeProtect", Any( true ) ); {
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 // Replace existing shapes with a new Graphic Object rendered
// from them // from them
Reference < XShape > xShape( renderDiagramToGraphic( rFilterBase ) ); Reference<XShape> xShape(renderDiagramToGraphic(rFilterBase));
Reference < XShapes > xShapes( mxShape, UNO_QUERY_THROW ); Reference<XShapes> xShapes(mxShape, UNO_QUERY_THROW);
while( xShapes->hasElements() ) while (xShapes->hasElements())
xShapes->remove( Reference < XShape > ( xShapes->getByIndex( 0 ), UNO_QUERY_THROW ) ); xShapes->remove(Reference<XShape>(xShapes->getByIndex(0), UNO_QUERY_THROW));
xShapes->add( xShape ); 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);
} }
} }
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <sal/log.hxx> #include <sal/log.hxx>
#include <oox/ppt/slidepersist.hxx> #include <oox/ppt/slidepersist.hxx>
#include <oox/token/tokens.hxx> #include <oox/token/tokens.hxx>
#include <unotools/fltrcfg.hxx>
using namespace ::oox::core; using namespace ::oox::core;
using namespace ::oox::drawingml; using namespace ::oox::drawingml;
...@@ -397,6 +398,9 @@ void PPTShape::addShape( ...@@ -397,6 +398,9 @@ void PPTShape::addShape(
Reference<XShapes> xShapes(xShape, UNO_QUERY); Reference<XShapes> xShapes(xShape, UNO_QUERY);
if (xShapes.is()) if (xShapes.is())
addChildren( rFilterBase, *this, pTheme, xShapes, pShapeMap, aTransformation ); addChildren( rFilterBase, *this, pTheme, xShapes, pShapeMap, aTransformation );
if (meFrameType == FRAMETYPE_DIAGRAM)
keepDiagramCompatibilityInfo();
} }
} }
catch (const Exception&) catch (const Exception&)
......
...@@ -68,6 +68,7 @@ public: ...@@ -68,6 +68,7 @@ public:
void testOrgChart(); void testOrgChart();
void testCycleMatrix(); void testCycleMatrix();
void testPictureStrip(); void testPictureStrip();
void testInteropGrabBag();
CPPUNIT_TEST_SUITE(SdImportTestSmartArt); CPPUNIT_TEST_SUITE(SdImportTestSmartArt);
...@@ -100,6 +101,7 @@ public: ...@@ -100,6 +101,7 @@ public:
CPPUNIT_TEST(testOrgChart); CPPUNIT_TEST(testOrgChart);
CPPUNIT_TEST(testCycleMatrix); CPPUNIT_TEST(testCycleMatrix);
CPPUNIT_TEST(testPictureStrip); CPPUNIT_TEST(testPictureStrip);
CPPUNIT_TEST(testInteropGrabBag);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
}; };
...@@ -899,6 +901,25 @@ void SdImportTestSmartArt::testPictureStrip() ...@@ -899,6 +901,25 @@ void SdImportTestSmartArt::testPictureStrip()
xDocShRef->DoClose(); 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_TEST_SUITE_REGISTRATION(SdImportTestSmartArt);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
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