diff options
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/data/xlsx/groupShape.xlsx | bin | 0 -> 9499 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_export_test2.cxx | 13 | ||||
-rw-r--r-- | sc/source/filter/xcl97/xcl97rec.cxx | 30 |
3 files changed, 36 insertions, 7 deletions
diff --git a/sc/qa/unit/data/xlsx/groupShape.xlsx b/sc/qa/unit/data/xlsx/groupShape.xlsx Binary files differnew file mode 100644 index 000000000000..060b3fd2e377 --- /dev/null +++ b/sc/qa/unit/data/xlsx/groupShape.xlsx diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx index a49cb97f8376..7e9282e6a53c 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -68,6 +68,7 @@ public: virtual void setUp() override; virtual void tearDown() override; + void testGroupShape(); void testMatrixMultiplicationXLSX(); void testTdf121260(); void testTextDirectionXLSX(); @@ -194,6 +195,7 @@ public: CPPUNIT_TEST_SUITE(ScExportTest2); + CPPUNIT_TEST(testGroupShape); CPPUNIT_TEST(testMatrixMultiplicationXLSX); CPPUNIT_TEST(testTdf121260); CPPUNIT_TEST(testTextDirectionXLSX); @@ -349,6 +351,17 @@ void ScExportTest2::registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) XmlTestTools::registerODFNamespaces(pXmlXPathCtx); } +void ScExportTest2::testGroupShape() +{ + ScDocShellRef xDocSh = loadDoc(u"groupShape.", FORMAT_XLSX); + std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(*xDocSh, FORMAT_XLSX); + + xmlDocUniquePtr pDoc + = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/drawings/drawing1.xml"); + CPPUNIT_ASSERT(pDoc); + assertXPath(pDoc, "/xdr:wsDr/xdr:twoCellAnchor/xdr:grpSp/xdr:grpSpPr"); +} + void ScExportTest2::testMatrixMultiplicationXLSX() { ScDocShellRef xShell = loadDoc(u"matrix-multiplication.", FORMAT_XLSX); diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx index 3cc27e9e0bad..d4524b22e07b 100644 --- a/sc/source/filter/xcl97/xcl97rec.cxx +++ b/sc/source/filter/xcl97/xcl97rec.cxx @@ -223,13 +223,34 @@ bool IsValidObject( const XclObj& rObj ) void SaveDrawingMLObjects( XclExpObjList& rList, XclExpXmlStream& rStrm ) { std::vector<XclObj*> aList; - aList.reserve(rList.size()); + // do not add objects to the list that are in the group, + // because the group already contains them. For this, count + // the next skipped objects, i.e. objects of a group, + // including objects of its subgroups + size_t nSkipObj = 0; for (const auto& rxObj : rList) { + // FIXME: Can DrawingML objects be grouped with VML or not valid objects? if (IsVmlObject(rxObj.get()) || !IsValidObject(*rxObj)) continue; - aList.push_back(rxObj.get()); + if (nSkipObj == 0) + aList.push_back(rxObj.get()); + else + --nSkipObj; + + XclObjAny* pObj = nullptr; + if (rxObj->GetObjType() == 0) // group (it can be a subgroup) + pObj = dynamic_cast<XclObjAny*>(rxObj.get()); + if (pObj) + { + css::uno::Reference<css::drawing::XShapes> xShapes(pObj->GetShape(), UNO_QUERY); + if (xShapes) + { + // skip (also) the objects of this group + nSkipObj += xShapes->getCount(); + } + } } if (aList.empty()) @@ -1282,11 +1303,6 @@ bool ScURLTransformer::isExternalURL(const OUString& rURL) const void XclObjAny::SaveXml( XclExpXmlStream& rStrm ) { - // ignore group shapes at the moment, we don't process them correctly - // leading to ms2010 rejecting the content - if( !mxShape.is() || mxShape->getShapeType() == "com.sun.star.drawing.GroupShape" ) - return; - // Do not output any of the detective shapes and validation circles. SdrObject* pObject = SdrObject::getSdrObjectFromXShape(mxShape); if (pObject) |