[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - 2 commits - include/oox oox/source sd/qa
Grzegorz Araminowicz (via logerrit)
logerrit at kemper.freedesktop.org
Tue May 21 07:30:56 UTC 2019
include/oox/drawingml/shape.hxx | 23 ++++++++------
oox/source/drawingml/shape.cxx | 35 +++++++++++++++-------
oox/source/ppt/extdrawingfragmenthandler.cxx | 6 ---
oox/source/ppt/extdrawingfragmenthandler.hxx | 1
oox/source/ppt/pptshape.cxx | 4 ++
oox/source/ppt/pptshapegroupcontext.cxx | 7 +++-
sd/qa/unit/data/pptx/smartart-interopgrabbag.pptx |binary
sd/qa/unit/data/xml/n819614_0.xml | 10 ------
sd/qa/unit/export-tests-ooxml1.cxx | 6 +--
sd/qa/unit/export-tests-ooxml2.cxx | 4 +-
sd/qa/unit/import-tests-smartart.cxx | 21 +++++++++++++
sd/qa/unit/import-tests.cxx | 1
12 files changed, 75 insertions(+), 43 deletions(-)
New commits:
commit f8586c223f07ddff4bba5d5c694cee33ac811412
Author: Grzegorz Araminowicz <grzegorz.araminowicz at collabora.com>
AuthorDate: Thu Mar 14 08:25:12 2019 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue May 21 09:29:50 2019 +0200
PPTX import: import SmartArt drawing into single GroupShape
before that there were imported two GroupShapes:
- empty one with properties like id, name, InteropGrapBag
- second one with actual shapes
also fixed tests that relyed on that behaviour
Change-Id: I2b94a53e21666b16725c4353448d75e916e4f9df
Reviewed-on: https://gerrit.libreoffice.org/69252
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/72472
diff --git a/oox/source/ppt/extdrawingfragmenthandler.cxx b/oox/source/ppt/extdrawingfragmenthandler.cxx
index a0d40ea0412c..cf8d8e50ed3c 100644
--- a/oox/source/ppt/extdrawingfragmenthandler.cxx
+++ b/oox/source/ppt/extdrawingfragmenthandler.cxx
@@ -29,7 +29,7 @@ ExtDrawingFragmentHandler::ExtDrawingFragmentHandler( XmlFilterBase& rFilter,
mpSlidePersistPtr (rSlidePersistPtr ),
meShapeLocation( eShapeLocation ),
mpGroupShapePtr( pGroupShapePtr ),
- mpOrgShapePtr( pShapePtr )
+ mpShapePtr( pShapePtr )
{
}
@@ -49,10 +49,6 @@ ExtDrawingFragmentHandler::onCreateContext( ::sal_Int32 aElement,
case DSP_TOKEN( drawing ):
break;
case DSP_TOKEN( spTree ):
- mpShapePtr = oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.GroupShape" ) );
- mpShapePtr->setPosition( mpOrgShapePtr->getPosition() );
- mpShapePtr->setName( mpOrgShapePtr->getName() );
-
return new PPTShapeGroupContext(
*this, mpSlidePersistPtr, meShapeLocation, mpGroupShapePtr,
mpShapePtr );
diff --git a/oox/source/ppt/extdrawingfragmenthandler.hxx b/oox/source/ppt/extdrawingfragmenthandler.hxx
index 83dfcd216e8f..cdde03777bc1 100644
--- a/oox/source/ppt/extdrawingfragmenthandler.hxx
+++ b/oox/source/ppt/extdrawingfragmenthandler.hxx
@@ -34,7 +34,6 @@ private:
const oox::ppt::SlidePersistPtr mpSlidePersistPtr;
const oox::ppt::ShapeLocation meShapeLocation;
oox::drawingml::ShapePtr const mpGroupShapePtr;
- oox::drawingml::ShapePtr mpOrgShapePtr; // Original Shape data, if any
oox::drawingml::ShapePtr mpShapePtr;
};
diff --git a/oox/source/ppt/pptshapegroupcontext.cxx b/oox/source/ppt/pptshapegroupcontext.cxx
index 1180af3f10fb..9a775655518f 100644
--- a/oox/source/ppt/pptshapegroupcontext.cxx
+++ b/oox/source/ppt/pptshapegroupcontext.cxx
@@ -71,9 +71,12 @@ ContextHandlerRef PPTShapeGroupContext::onCreateContext( sal_Int32 aElementToken
{
case PPT_TOKEN( cNvPr ):
{
+ // don't override SmartArt properties for embedded drawing's spTree
mpGroupShapePtr->setHidden( rAttribs.getBool( XML_hidden, false ) );
- mpGroupShapePtr->setId( rAttribs.getString( XML_id ).get() );
- mpGroupShapePtr->setName( rAttribs.getString( XML_name ).get() );
+ if (mpGroupShapePtr->getId().isEmpty())
+ mpGroupShapePtr->setId(rAttribs.getString(XML_id).get());
+ if (mpGroupShapePtr->getName().isEmpty())
+ mpGroupShapePtr->setName( rAttribs.getString( XML_name ).get() );
break;
}
case PPT_TOKEN( ph ):
diff --git a/sd/qa/unit/data/xml/n819614_0.xml b/sd/qa/unit/data/xml/n819614_0.xml
index e51b520d3130..fc109917c460 100644
--- a/sd/qa/unit/data/xml/n819614_0.xml
+++ b/sd/qa/unit/data/xml/n819614_0.xml
@@ -14,7 +14,7 @@
<Line3 column1="0.000000" column2="0.000000" column3="1.000000"/>
</Transformation>
</XShape>
- <XShape positionX="182" positionY="2544" sizeX="25125" sizeY="16293" type="com.sun.star.drawing.GroupShape">
+ <XShape positionX="182" positionY="2544" sizeX="25125" sizeY="16293" type="com.sun.star.drawing.GroupShape" name="Content Placeholder 4">
<XShapes>
<XShape positionX="10751" positionY="3496" sizeX="1563" sizeY="253" type="com.sun.star.drawing.CustomShape" fontHeight="18.000000" fontColor="ffffffff" textAutoGrowHeight="false" textAutoGrowWidth="false" textContourFrame="false" textFitToSize="NONE" textHorizontalAdjust="BLOCK" textVerticalAdjust="TOP" textLeftDistance="250" textRightDistance="250" textUpperDistance="125" textLowerDistance="125" textMaximumFrameHeight="0" textMaximumFrameWidth="0" textMinimumFrameHeight="0" textMinimumFrameWidth="0" textAnimationAmount="0" textAnimationCount="0" textAnimationDelay="0" textAnimationDirection="LEFT" textAnimationKind="NONE" textAnimationStartInside="false" textAnimationStopInside="false" textWritingMode="LR_TB" fillStyle="NONE" fillColor="729fcf" fillTransparence="0" fillTransparenceGradientName="">
<FillTransparenceGradient style="LINEAR" startColor="000000" endColor="ffffff" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/>
@@ -6824,12 +6824,4 @@
<Line3 column1="0.000000" column2="0.000000" column3="1.000000"/>
</Transformation>
</XShape>
- <XShape positionX="0" positionY="0" sizeX="100" sizeY="100" type="com.sun.star.drawing.GroupShape" name="Content Placeholder 4">
- <XShapes/>
- <Transformation>
- <Line1 column1="101.000000" column2="0.000000" column3="0.000000"/>
- <Line2 column1="0.000000" column2="101.000000" column3="0.000000"/>
- <Line3 column1="0.000000" column2="0.000000" column3="1.000000"/>
- </Transformation>
- </XShape>
</XShapes>
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx
index 7cc50e21f963..3e832aad4e3f 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -231,7 +231,7 @@ void SdOOXMLExportTest1::testBnc870233_2()
// Second smart art has "dk2" font color (style)
{
- const SdrObjGroup *pObjGroup = dynamic_cast<SdrObjGroup *>(pPage->GetObj(2)); // FIXME should be 1, smartart import creates an additional empty group for some reason
+ const SdrObjGroup *pObjGroup = dynamic_cast<SdrObjGroup *>(pPage->GetObj(1));
CPPUNIT_ASSERT(pObjGroup);
const SdrTextObj *pObj = dynamic_cast<SdrTextObj *>(pObjGroup->GetSubList()->GetObj(0));
checkFontAttributes<Color, SvxColorItem>( pObj, Color(0x1F497D) );
@@ -239,7 +239,7 @@ void SdOOXMLExportTest1::testBnc870233_2()
// Third smart art has white font color (style)
{
- const SdrObjGroup *pObjGroup = dynamic_cast<SdrObjGroup *>(pPage->GetObj(4)); // FIXME should be 2, smartart import creates an additional empty group for some reason
+ const SdrObjGroup *pObjGroup = dynamic_cast<SdrObjGroup *>(pPage->GetObj(2));
CPPUNIT_ASSERT(pObjGroup);
const SdrTextObj *pObj = dynamic_cast<SdrTextObj *>(pObjGroup->GetSubList()->GetObj(0));
checkFontAttributes<Color, SvxColorItem>(pObj, Color(0xffffff));
@@ -381,7 +381,7 @@ void SdOOXMLExportTest1::testBnc880763()
CPPUNIT_ASSERT_EQUAL( Color(0x0000ff),(static_cast< const XColorItem& >(pObj->GetMergedItem(XATTR_FILLCOLOR))).GetColorValue());
// Second object at the front has green background color
- pObj = pPage->GetObj(2); // FIXME should be 1, smartart import creates an additional empty group for some reason
+ pObj = pPage->GetObj(1);
CPPUNIT_ASSERT_MESSAGE( "no object", pObj != nullptr);
CPPUNIT_ASSERT_EQUAL( Color(0x00ff00),(static_cast< const XColorItem& >(pObj->GetMergedItem(XATTR_FILLCOLOR))).GetColorValue());
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx
index 80090c1656ae..7555ce0ea1e4 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -1417,10 +1417,10 @@ void SdOOXMLExportTest2::testGroupsPosition()
xDocShRef->DoClose();
xmlDocPtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
- assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[3]/p:spPr/a:xfrm/a:off", "x", "6796800");
- assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[3]/p:spPr/a:xfrm/a:off", "y", "4273920");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp[1]/p:sp[1]/p:spPr/a:xfrm/a:off", "x", "4040640");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp[1]/p:sp[1]/p:spPr/a:xfrm/a:off", "y", "4273920");
+ assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp[1]/p:sp[3]/p:spPr/a:xfrm/a:off", "x", "6796800");
+ assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp[1]/p:sp[3]/p:spPr/a:xfrm/a:off", "y", "4273920");
}
void SdOOXMLExportTest2::testGroupsRotatedPosition()
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 14a907316d70..6ca42293bf1c 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -444,6 +444,7 @@ void SdImportTest::testN862510_2()
const SdrPage *pPage = GetPage( 1, xDocShRef );
{
+ CPPUNIT_ASSERT_EQUAL(size_t(1), pPage->GetObjCount());
SdrObjGroup *pGrpObj = dynamic_cast<SdrObjGroup *>( pPage->GetObj( 0 ) );
CPPUNIT_ASSERT( pGrpObj );
SdrObjCustomShape *pObj = dynamic_cast<SdrObjCustomShape *>( pGrpObj->GetSubList()->GetObj( 0 ) );
commit 3807fb7c541632a4d21afba88c27865957036f0a
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: Tue May 21 09:29:26 2019 +0200
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>
Reviewed-on: https://gerrit.libreoffice.org/72471
diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx
index 88fe31d2dd02..aaade775c00c 100644
--- a/include/oox/drawingml/shape.hxx
+++ b/include/oox/drawingml/shape.hxx
@@ -227,6 +227,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,
@@ -247,7 +256,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 );
@@ -306,20 +316,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 d45a88a692cf..3e04f3b7494e 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -284,8 +284,9 @@ void Shape::addShape(
if( meFrameType == FRAMETYPE_DIAGRAM )
{
+ keepDiagramCompatibilityInfo();
if( !SvtFilterOptions::Get().IsSmartArt2Shape() )
- keepDiagramCompatibilityInfo( rFilterBase );
+ convertSmartArtToMetafile( rFilterBase );
}
}
}
@@ -1393,7 +1394,7 @@ Reference< XShape > const & Shape::createAndInsert(
return mxShape;
}
-void Shape::keepDiagramCompatibilityInfo( XmlFilterBase const & rFilterBase )
+void Shape::keepDiagramCompatibilityInfo()
{
try
{
@@ -1424,21 +1425,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 92c573b6f5ea..0121f8905e3d 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 100644
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 e4a2fafd9df3..fc09e270247f 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -68,6 +68,7 @@ public:
void testOrgChart();
void testCycleMatrix();
void testPictureStrip();
+ void testInteropGrabBag();
CPPUNIT_TEST_SUITE(SdImportTestSmartArt);
@@ -100,6 +101,7 @@ public:
CPPUNIT_TEST(testOrgChart);
CPPUNIT_TEST(testCycleMatrix);
CPPUNIT_TEST(testPictureStrip);
+ CPPUNIT_TEST(testInteropGrabBag);
CPPUNIT_TEST_SUITE_END();
};
@@ -899,6 +901,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