summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorTibor Nagy <nagy.tibor2@nisz.hu>2022-11-23 12:14:31 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2022-11-28 18:14:08 +0100
commit916bf965bf69784da68311040ba5520e58ca8321 (patch)
tree2f5e0fba3cdb897d39548c6164bedc57f08ed70b /sc
parent93dfe334529dac5fa4d44eac88e467db200bd14f (diff)
tdf#70293 XLSX export: fix lost grouping of shapes
SaveDrawingMLObjects() needs to skip all the grouped objects, including subgroups of a group to avoid of broken export. Fixing this and reverting the old workaround commit c323e60157422ae264e798b9a279a532fe9997af "ignore the (unsupported ) group customshape when exporting xlsx", Calc keeps the grouped state of the objects now. Change-Id: Ic320248a1c646d8adb9ce55bb2e5dcd880c1df6f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143142 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143306 Tested-by: Jenkins
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/data/xlsx/groupShape.xlsxbin0 -> 9499 bytes
-rw-r--r--sc/qa/unit/subsequent_export_test2.cxx13
-rw-r--r--sc/source/filter/xcl97/xcl97rec.cxx30
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
new file mode 100644
index 000000000000..060b3fd2e377
--- /dev/null
+++ b/sc/qa/unit/data/xlsx/groupShape.xlsx
Binary files differ
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)