sw/qa/extras/layout/layout.cxx             |   38 ++++++++++++++++-------------
 sw/qa/extras/ooxmlexport/ooxmlexport15.cxx |    6 ++--
 sw/source/core/text/xmldump.cxx            |    2 -
 3 files changed, 26 insertions(+), 20 deletions(-)

New commits:
commit 1e8c2068ec9d1551b84152d6cf66042dc2949594
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Tue Dec 6 20:07:07 2022 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Wed Dec 7 07:24:53 2022 +0000

    sw layout xml dump: avoid confusing content of SwParaPortion
    
    The problem is that the SwParaPortion is also the first line layout, so
    the string it presents is not the content of the paragraph but of the
    first line.
    
    Just remove it as we have better replacements:
    
    - in case really the whole paragraph is wanted, the (text) content of
      the parent SwTextFrame can be used
    
    - in case in fact the first line is wanted, then the first child
      SwLineLayout still has a portion attribute the provides the unchanged
      substring
    
    Change-Id: Ic4a0f64ecc40e9a74adc79c5205d5d92c882256b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143743
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 2707f940dfbf..587fa4d4294e 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -715,11 +715,10 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, 
TestNestedTableMoveFwd)
     CPPUNIT_ASSERT(pDoc);
     xmlDocUniquePtr pXmlDoc = parseLayoutDump();
     // the row with the nested table should not be split but be the first row 
on page 2
-    assertXPath(pXmlDoc, 
"/root/page[1]/body/tab[1]/row[last()]/cell[1]/txt[1]/SwParaPortion",
-                "portion", "Tabelle 1");
-    assertXPath(pXmlDoc,
-                
"/root/page[2]/body/tab[1]/row[1]/cell[1]/tab[1]/row[1]/cell[1]/txt/SwParaPortion",
-                "portion", "Tabelle 2");
+    assertXPathContent(pXmlDoc, 
"/root/page[1]/body/tab[1]/row[last()]/cell[1]/txt[1]",
+                       "Tabelle 1");
+    assertXPathContent(
+        pXmlDoc, 
"/root/page[2]/body/tab[1]/row[1]/cell[1]/tab[1]/row[1]/cell[1]/txt", "Tabelle 
2");
 }
 
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf136613)
@@ -827,19 +826,25 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, 
testRedlineFlysInHeader)
         CPPUNIT_ASSERT(pLayout->IsHideRedlines());
         discardDumpedLayout();
         xmlDocUniquePtr pXmlDoc = parseLayoutDump();
-        assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion[1]", 
"type",
+        assertXPath(pXmlDoc, 
"/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout", "type",
                     "PortionType::Para");
-        assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion[1]", 
"length", "0");
+        assertXPath(pXmlDoc, 
"/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "length",
+                    "0");
         assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/merged", 
"paraPropsNodeIndex", "6");
-        assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/SwParaPortion[1]", 
"type",
+        assertXPath(pXmlDoc, 
"/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout[1]", "type",
                     "PortionType::Para");
-        assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/SwParaPortion[1]", 
"portion", "foaz");
+        assertXPath(pXmlDoc, 
"/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout[1]", "portion",
+                    "foaz");
         assertXPath(pXmlDoc, 
"/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/merged",
                     "paraPropsNodeIndex", "11");
-        assertXPath(pXmlDoc, 
"/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion[1]",
-                    "type", "PortionType::Para");
-        assertXPath(pXmlDoc, 
"/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion[1]",
-                    "portion", "ahi");
+        assertXPath(
+            pXmlDoc,
+            
"/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout[1]",
+            "type", "PortionType::Para");
+        assertXPath(
+            pXmlDoc,
+            
"/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout[1]",
+            "portion", "ahi");
 
         dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
         CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
@@ -853,9 +858,10 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, 
testRedlineFlysInHeader)
             xmlXPathFreeObject(pXmlObj);
         }
 
-        assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion[1]", 
"type",
+        assertXPath(pXmlDoc, 
"/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "type",
                     "PortionType::Para");
-        assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion[1]", 
"length", "0");
+        assertXPath(pXmlDoc, 
"/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "length",
+                    "0");
         assertXPath(pXmlDoc,
                     
"/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
                     "type", "PortionType::Text");
@@ -3495,7 +3501,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf128611)
     // - Actual  : 14
     // i.e. there were multiple portions in the first paragraph of the A1 
cell, which means that the
     // rotated text was broken into multiple lines without a good reason.
-    assertXPath(pXmlDoc, "//tab/row/cell[1]/txt/SwParaPortion", "portion", 
"Abcd efghijkl");
+    assertXPathContent(pXmlDoc, "//tab/row/cell[1]/txt", "Abcd efghijkl");
 }
 
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf125893)
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
index 64478819f0b8..302c7a5dd1cd 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
@@ -684,7 +684,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf132149_pgBreak)
 
     //Page style change here must not be lost. This SHOULD be on page 4, but 
sadly it is not.
     assertXPathContent(pDump, "//page[6]/header/txt", "First Page Style");
-    CPPUNIT_ASSERT(getXPath(pDump, "//page[6]/body/txt[1]/SwParaPortion[1]", 
"portion").startsWith("Lorem ipsum"));
+    CPPUNIT_ASSERT(getXPathContent(pDump, 
"//page[6]/body/txt[1]").startsWith("Lorem ipsum"));
 }
 
 CPPUNIT_TEST_FIXTURE(Test, testTdf132149_pgBreakB)
@@ -695,7 +695,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf132149_pgBreakB)
     xmlDocUniquePtr pDump = parseLayoutDump();
 
     //Sanity check to ensure the correct page is being tested. This SHOULD be 
on page 3, but sadly it is not.
-    CPPUNIT_ASSERT(getXPath(pDump, "//page[5]/body/txt[1]/SwParaPortion[1]", 
"portion").startsWith("Lorem ipsum"));
+    CPPUNIT_ASSERT(getXPathContent(pDump, 
"//page[5]/body/txt[1]").startsWith("Lorem ipsum"));
     //Prior to this fix, the original alternation between portrait and 
landscape was completely lost.
     assertXPath(pDump, "//page[5]/infos/bounds", "width", "8391");  //landscape
 }
@@ -724,7 +724,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf136952_pgBreak3B)
 
     //page::breakAfter must not be lost.
     //Prior to this bug fix, the Lorem ipsum paragraph was in the middle of a 
portrait page, with no switch to landscape occurring.
-    CPPUNIT_ASSERT(getXPath(pDump, "//page[3]/body/txt[1]/SwParaPortion[1]", 
"portion").startsWith("Lorem ipsum"));
+    CPPUNIT_ASSERT(getXPathContent(pDump, 
"//page[3]/body/txt[1]").startsWith("Lorem ipsum"));
     assertXPath(pDump, "//page[3]/infos/bounds", "width", "8391");  //landscape
 }
 
diff --git a/sw/source/core/text/xmldump.cxx b/sw/source/core/text/xmldump.cxx
index 1a419a495bf8..569cbf1c2143 100644
--- a/sw/source/core/text/xmldump.cxx
+++ b/sw/source/core/text/xmldump.cxx
@@ -362,7 +362,7 @@ void SwFrame::dumpAsXml( xmlTextWriterPtr writer ) const
                 (void)xmlTextWriterStartElement(writer, 
BAD_CAST("SwParaPortion"));
                 TextFrameIndex nOffset(0);
                 const OUString& rText = pTextFrame->GetText();
-                pPara->dumpAsXmlAttributes(writer, rText, nOffset);
+                (void)xmlTextWriterWriteFormatAttribute(writer, 
BAD_CAST("ptr"), "%p", pPara);
                 const SwLineLayout* pLine = pPara;
                 if (pTextFrame->IsFollow())
                 {

Reply via email to