sw/qa/extras/odfexport/odfexport2.cxx |   31 ++++++++++++++-----------------
 1 file changed, 14 insertions(+), 17 deletions(-)

New commits:
commit a00294a6d56ff7f4da8c6ae426eca95d39e38981
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Fri Apr 26 10:06:38 2024 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Fri Apr 26 08:16:22 2024 +0200

    Simplify a bit
    
    Change-Id: Ia724b8dcfbd3e1b3744bbc26e005831d30b5ce38
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166691
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins

diff --git a/sw/qa/extras/odfexport/odfexport2.cxx 
b/sw/qa/extras/odfexport/odfexport2.cxx
index 62098deccc08..0da0ca9ac69f 100644
--- a/sw/qa/extras/odfexport/odfexport2.cxx
+++ b/sw/qa/extras/odfexport/odfexport2.cxx
@@ -1583,26 +1583,23 @@ CPPUNIT_TEST_FIXTURE(Test, 
testTableInFrameAnchoredToPage)
     // it must not assert on export because of missing format for an exported 
table
     loadAndReload("table_in_frame_to_page.fodt");
 
+    xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
+    auto AutoStyleUsedIn = [this, &pXmlDoc](const OString& path, const 
OString& attr) -> OString
+    {
+        const OUString styleName = getXPath(pXmlDoc, path, attr);
+        return "//office:automatic-styles/style:style[@style:name='" + 
styleName.toUtf8() + "']";
+    };
+    constexpr OString xPathTextBox = 
"//office:body/office:text/draw:frame/draw:text-box"_ostr;
+
     // Check also, that autostyles defined inside that frame are stored 
correctly. If not, then
     // these paragraphs would refer to styles in <office::styles>, not in 
<office:automatic-styles>,
     // without the 'italic' and 'bold' attributes.
-    xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
-    OUString P1 = getXPath(
-        pXmlDoc,
-        
"//office:body/office:text/draw:frame/draw:text-box/table:table/table:table-row[1]/"
-        "table:table-cell[1]/text:p"_ostr,
-        "style-name"_ostr);
-    assertXPath(pXmlDoc,
-                "//office:automatic-styles/style:style[@style:name='"_ostr + 
P1.toUtf8()
-                    + "']/style:text-properties",
-                "font-style"_ostr, u"italic"_ustr);
-    OUString P2
-        = getXPath(pXmlDoc, 
"//office:body/office:text/draw:frame/draw:text-box/text:p"_ostr,
-                   "style-name"_ostr);
-    assertXPath(pXmlDoc,
-                "//office:automatic-styles/style:style[@style:name='"_ostr + 
P2.toUtf8()
-                    + "']/style:text-properties",
-                "font-weight"_ostr, u"bold"_ustr);
+    OString P = AutoStyleUsedIn(xPathTextBox + "/text:p", "style-name"_ostr);
+    assertXPath(pXmlDoc, P + "/style:text-properties", "font-weight"_ostr, 
u"bold"_ustr);
+
+    P = AutoStyleUsedIn(xPathTextBox + 
"/table:table/table:table-row[1]/table:table-cell[1]/text:p",
+                        "style-name"_ostr);
+    assertXPath(pXmlDoc, P + "/style:text-properties", "font-style"_ostr, 
u"italic"_ustr);
 }
 
 } // end of anonymous namespace

Reply via email to