include/test/xmltesttools.hxx | 5 +++++ sw/qa/extras/ooxmlexport/ooxmlexport13.cxx | 15 +++++++++++++++ test/source/xmltesttools.cxx | 28 ++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+)
New commits: commit 1b52d9c91129a9536160805aa4128d193ab181ba Author: Xisco Fauli <[email protected]> AuthorDate: Fri Jan 16 10:43:40 2026 +0100 Commit: Aron Budea <[email protected]> CommitDate: Tue Jan 20 09:15:58 2026 +0100 sw_ooxmlexport13: Add test for b2dd08c6af51 Change-Id: I0cae335f075b785de907c4aa8ec47c9ca086cd12 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197436 Tested-by: Jenkins Reviewed-by: Xisco Fauli <[email protected]> (cherry picked from commit eaca892394d5206e8a7062068b03df57353ac99f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197589 Tested-by: Aron Budea <[email protected]> Reviewed-by: Aron Budea <[email protected]> diff --git a/include/test/xmltesttools.hxx b/include/test/xmltesttools.hxx index 94f4cf18a816..76140972c85b 100644 --- a/include/test/xmltesttools.hxx +++ b/include/test/xmltesttools.hxx @@ -73,6 +73,11 @@ protected: * Useful for checking relative order of elements. */ int getXPathPosition(const xmlDocUniquePtr& pXmlDoc, const char* pXPath, const char* pChildName); + /** + * Get the position of the attribute named rName of the parent node specified by pXPath. + * Useful for checking relative order of elements. + */ + int getXPathAttributePosition(const xmlDocUniquePtr& pXmlDoc, const char* pXPath, const char* pAttributeName); /** * Get the number of the nodes returned by the pXPath. */ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx index 75e6ae776e66..4ada85283bde 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx @@ -756,6 +756,21 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf169802_hidden_shape) // Layout mustn't contain fly portion, without the fix it would contain several int nFlyNodes = countXPathNodes(pDump, "//*[contains(@type, 'PortionType::Fly')]"); CPPUNIT_ASSERT_EQUAL_MESSAGE("No fly portion nodes must exist in the layout", 0, nFlyNodes); + + save(TestFilter::DOCX); + + xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr); + const char* const sPath("/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor"); + CPPUNIT_ASSERT_EQUAL(0, getXPathAttributePosition(pXmlDoc, sPath, "distT")); + CPPUNIT_ASSERT_EQUAL(1, getXPathAttributePosition(pXmlDoc, sPath, "distB")); + CPPUNIT_ASSERT_EQUAL(2, getXPathAttributePosition(pXmlDoc, sPath, "distL")); + CPPUNIT_ASSERT_EQUAL(3, getXPathAttributePosition(pXmlDoc, sPath, "distR")); + CPPUNIT_ASSERT_EQUAL(4, getXPathAttributePosition(pXmlDoc, sPath, "simplePos")); + CPPUNIT_ASSERT_EQUAL(5, getXPathAttributePosition(pXmlDoc, sPath, "relativeHeight")); + CPPUNIT_ASSERT_EQUAL(6, getXPathAttributePosition(pXmlDoc, sPath, "behindDoc")); + CPPUNIT_ASSERT_EQUAL(7, getXPathAttributePosition(pXmlDoc, sPath, "locked")); + CPPUNIT_ASSERT_EQUAL(8, getXPathAttributePosition(pXmlDoc, sPath, "layoutInCell")); + CPPUNIT_ASSERT_EQUAL(9, getXPathAttributePosition(pXmlDoc, sPath, "allowOverlap")); } DECLARE_OOXMLEXPORT_TEST(testTdf124594, "tdf124594.docx") diff --git a/test/source/xmltesttools.cxx b/test/source/xmltesttools.cxx index aac5425cff55..70bd853bc785 100644 --- a/test/source/xmltesttools.cxx +++ b/test/source/xmltesttools.cxx @@ -329,6 +329,34 @@ int XmlTestTools::getXPathPosition(const xmlDocUniquePtr& pXmlDoc, const char* p return nRet; } +int XmlTestTools::getXPathAttributePosition(const xmlDocUniquePtr& pXmlDoc, const char* pXPath, const char* pAttributeName) +{ + xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, pXPath); + xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; + CPPUNIT_ASSERT(pXmlNodes); + CPPUNIT_ASSERT_EQUAL_MESSAGE(OString(OString::Concat("In <") + pXmlDoc->name + ">, XPath '" + pXPath + "' number of nodes is incorrect").getStr(), + 1, + xmlXPathNodeSetGetLength(pXmlNodes)); + xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0]; + int nRet = 0; + bool bFound = false; + for (xmlAttrPtr pAttribute = pXmlNode->properties; pAttribute; pAttribute = pAttribute->next) + { + if (oconvert(pAttribute->name) == pAttributeName) + { + bFound = true; + break; + } + ++nRet; + } + xmlXPathFreeObject(pXmlObj); + CPPUNIT_ASSERT_MESSAGE(OString(OString::Concat("In <") + pXmlDoc->name + ">, XPath '" + pXPath + + "' attribute '" + pAttributeName + "' not found") + .getStr(), + bFound); + return nRet; +} + void XmlTestTools::assertXPathNodeName(const xmlDocUniquePtr& pXmlDoc, const char* pXPath, std::string_view rExpectedName) {
