diff options
Diffstat (limited to 'sw/qa/extras/layout/layout.cxx')
-rw-r--r-- | sw/qa/extras/layout/layout.cxx | 4418 |
1 files changed, 2964 insertions, 1454 deletions
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index 41fb0fec79ac..1ebaed27941d 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -8,211 +8,394 @@ */ #include <swmodeltestbase.hxx> -#include <com/sun/star/linguistic2/LinguServiceManager.hpp> + +#include <osl/process.h> #include <comphelper/scopeguard.hxx> +#include <comphelper/propertysequence.hxx> +#include <vcl/scheduler.hxx> +#include <svx/svddef.hxx> +#include <layouter.hxx> #include <fmtanchr.hxx> #include <fmtfsize.hxx> #include <fmtcntnt.hxx> #include <wrtsh.hxx> #include <unotxdoc.hxx> #include <rootfrm.hxx> -#include <docsh.hxx> #include <IDocumentLayoutAccess.hxx> -#include <textboxhelper.hxx> +#include <IDocumentRedlineAccess.hxx> #include <unoframe.hxx> +#include <fldmgr.hxx> -constexpr OUStringLiteral DATA_DIRECTORY = u"/sw/qa/extras/layout/data/"; +#include <officecfg/Office/Common.hxx> /// Test to assert layout / rendering result of Writer. class SwLayoutWriter : public SwModelTestBase { +public: + SwLayoutWriter() + : SwModelTestBase(u"/sw/qa/extras/layout/data/"_ustr) + { + } + protected: void CheckRedlineFootnotesHidden(); void CheckRedlineSectionsHidden(); - - SwDoc* createDoc(const char* pName = nullptr); }; -SwDoc* SwLayoutWriter::createDoc(const char* pName) -{ - if (!pName) - loadURL("private:factory/swriter", nullptr); - else - load(DATA_DIRECTORY, pName); - - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - return pTextDoc->GetDocShell()->GetDoc(); -} - // this is a member because our test classes have protected members :( void SwLayoutWriter::CheckRedlineFootnotesHidden() { - discardDumpedLayout(); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "24"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "nType", "PortionType::Footnote"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "rText", "1"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "foaz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[2]", "nType", "PortionType::Footnote"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[2]", "rText", "2"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/merged", "paraPropsNodeIndex", "13"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "nType", - "PortionType::FootnoteNum"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "rText", "1"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Text[1]", "Portion", "ac"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/merged", "paraPropsNodeIndex", "16"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Special[1]", "nType", - "PortionType::FootnoteNum"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Special[1]", "rText", "2"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Text[1]", "Portion", "mo"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", u"24"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "type", u"PortionType::Footnote"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "expand", u"1"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"foaz"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[2]", + "type", u"PortionType::Footnote"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[2]", + "expand", u"2"); + assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/merged", "paraPropsNodeIndex", u"13"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "type", u"PortionType::FootnoteNum"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "expand", u"1"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"ac"); + assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/merged", "paraPropsNodeIndex", u"16"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "type", u"PortionType::FootnoteNum"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "expand", u"2"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"mo"); } void SwLayoutWriter::CheckRedlineSectionsHidden() { - discardDumpedLayout(); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "12"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "folah"); - assertXPath(pXmlDoc, "/root/page[1]/body/section[1]/txt[1]/merged", "paraPropsNodeIndex", "20"); - assertXPath(pXmlDoc, "/root/page[1]/body/section[1]/txt[1]/Text[1]", "nType", - "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/section[1]/txt[1]/Text[1]", "Portion", "folah"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", u"12"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"folah"); + assertXPath(pXmlDoc, "/root/page[1]/body/section[1]/txt[1]/merged", "paraPropsNodeIndex", + u"20"); + assertXPath(pXmlDoc, + "/root/page[1]/body/section[1]/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/section[1]/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"folah"); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf156077) +{ + createSwDoc("s4_min2.fodt"); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Number of pages does not match!", 3, getPages()); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page[1]/anchored/fly", 3); + assertXPath(pXmlDoc, "/root/page[2]/anchored/fly", 1); + // this was 0, the at-page anchored flys were not displayed + assertXPath(pXmlDoc, "/root/page[3]/anchored/fly", 3); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFootnotes) { - createDoc("redline_footnotes.odt"); - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc()); + createSwDoc("redline_footnotes.odt"); + SwDoc* pDoc(getSwDoc()); SwRootFrame* pLayout(pDoc->getIDocumentLayoutAccess().GetCurrentLayout()); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); // verify after load CheckRedlineFootnotesHidden(); - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); - discardDumpedLayout(); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // show: nothing is merged - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//merged"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlNodes)); - xmlXPathFreeObject(pXmlObj); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "nType", "PortionType::Footnote"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "rText", "1"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "fo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[2]", "Portion", "o"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[2]", "nType", "PortionType::Footnote"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[2]", "rText", "2"); - - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "nType", - "PortionType::FootnoteNum"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "rText", "1"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Text[1]", "Portion", "a"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Text[2]", "Portion", "b"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Text[3]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Text[3]", "Portion", "c"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Special[1]", "nType", - "PortionType::FootnoteNum"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Special[1]", "rText", "2"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Text[1]", "Portion", "def"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "Portion", "b"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Special[1]", "nType", "PortionType::Footnote"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Special[1]", "rText", "3"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[2]", "Portion", "ar"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[3]/txt[1]/Special[1]", "nType", - "PortionType::FootnoteNum"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[3]/txt[1]/Special[1]", "rText", "3"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[3]/txt[1]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[3]/txt[1]/Text[1]", "Portion", "ghi"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Special[1]", "nType", "PortionType::Footnote"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Special[1]", "rText", "4"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "Portion", "b"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[2]", "Portion", "az"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Special[2]", "nType", "PortionType::Footnote"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Special[2]", "rText", "5"); - - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[4]/txt[1]/Special[1]", "nType", - "PortionType::FootnoteNum"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[4]/txt[1]/Special[1]", "rText", "4"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[4]/txt[1]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[4]/txt[1]/Text[1]", "Portion", "jkl"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[5]/txt[1]/Special[1]", "nType", - "PortionType::FootnoteNum"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[5]/txt[1]/Special[1]", "rText", "5"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[5]/txt[1]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[5]/txt[1]/Text[1]", "Portion", "m"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[5]/txt[1]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[5]/txt[1]/Text[2]", "Portion", "n"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[5]/txt[1]/Text[3]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[5]/txt[1]/Text[3]", "Portion", "o"); + assertXPath(pXmlDoc, "//merged", 0); + + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "type", u"PortionType::Footnote"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "expand", u"1"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"fo"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"o"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[2]", + "type", u"PortionType::Footnote"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[2]", + "expand", u"2"); + + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "type", u"PortionType::FootnoteNum"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "expand", u"1"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"a"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"b"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "portion", u"c"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "type", u"PortionType::FootnoteNum"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "expand", u"2"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"def"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"b"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "type", u"PortionType::Footnote"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "expand", u"3"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"ar"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[3]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "type", u"PortionType::FootnoteNum"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[3]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "expand", u"3"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[3]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[3]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"ghi"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "type", u"PortionType::Footnote"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "expand", u"4"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"b"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"az"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwFieldPortion[2]", + "type", u"PortionType::Footnote"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwFieldPortion[2]", + "expand", u"5"); + + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[4]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "type", u"PortionType::FootnoteNum"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[4]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "expand", u"4"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[4]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[4]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"jkl"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[5]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "type", u"PortionType::FootnoteNum"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[5]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "expand", u"5"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[5]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[5]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"m"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[5]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[5]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"n"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[5]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[5]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "portion", u"o"); // verify after hide - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); - discardDumpedLayout(); CheckRedlineFootnotesHidden(); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf136588) { - load(DATA_DIRECTORY, "tdf136588.docx"); + createSwDoc("tdf136588.docx"); auto pXMLLayoutDump = parseLayoutDump(); CPPUNIT_ASSERT(pXMLLayoutDump); //there was a bad line break before, the correct break layout is this: - assertXPath(pXMLLayoutDump, "/root/page/body/txt[2]/LineBreak[2]", "Line", - "effectively by modern-day small to "); + assertXPath(pXMLLayoutDump, "/root/page/body/txt[2]/SwParaPortion/SwLineLayout[2]", "portion", + u"effectively by modern-day small to "); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTableSplitBug) +{ + createSwDoc("table-split-bug.fodt"); + + { + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, + "/root/page[1]/body/section[3]/tab[1]/row[1]/cell[1]//txt[1]/infos/bounds", + "height", u"276"); + assertXPath(pXmlDoc, "/root/page[1]/body/section[3]/tab[1]/row[1]/cell[1]/infos/bounds", + "height", u"1274"); + } + + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + pWrtShell->Down(false, 1); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 1, /*bBasicCall=*/false); + pWrtShell->Delete(); + + { + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + // the problem was that the paragraph in the left cell had height 0 + assertXPath(pXmlDoc, + "/root/page[1]/body/section[3]/tab[1]/row[1]/cell[1]//txt[1]/infos/bounds", + "height", u"276"); + assertXPath(pXmlDoc, "/root/page[1]/body/section[3]/tab[1]/row[1]/cell[1]/infos/bounds", + "height", u"1688"); + } + + pWrtShell->Undo(); + + { + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + // the problem was that the paragraph in the left cell had height 0 + assertXPath(pXmlDoc, + "/root/page[1]/body/section[3]/tab[1]/row[1]/cell[1]//txt[1]/infos/bounds", + "height", u"276"); + assertXPath(pXmlDoc, "/root/page[1]/body/section[3]/tab[1]/row[1]/cell[1]/infos/bounds", + "height", u"1274"); + } +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTableInSectionTruncated) +{ + createSwDoc("table-in-section-truncated.fodt"); + + { + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page[1]/body/txt", 20); + assertXPath(pXmlDoc, "/root/page[1]/body/section/txt", 0); + assertXPath(pXmlDoc, "/root/page[1]/body/section/tab/row/cell/txt", 1); + assertXPath(pXmlDoc, "/root/page[2]/body/section/tab/row/cell/txt", 2); + assertXPath(pXmlDoc, "/root/page[2]/body/section/txt", 1); + assertXPath(pXmlDoc, "/root/page[2]/body/txt", 0); + + assertXPath(pXmlDoc, "/root/page[2]/body/section/infos/bounds", "bottom", u"11032"); + } + + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + pWrtShell->Down(false, 19); + dispatchCommand(mxComponent, u".uno:InsertPagebreak"_ustr, {}); + + { + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page[1]/body/txt", 20); + assertXPath(pXmlDoc, "/root/page[1]/body/section/txt", 0); + assertXPath(pXmlDoc, "/root/page[1]/body/section/tab/row/cell/txt", 0); + assertXPath(pXmlDoc, "/root/page[2]/body/txt", 1); + assertXPath(pXmlDoc, "/root/page[2]/body/section/tab/row/cell/txt", 3); + assertXPath(pXmlDoc, "/root/page[2]/body/section/txt", 1); + + assertXPath(pXmlDoc, "/root/page[2]/body/section/infos/bounds", "top", u"10369"); + assertXPath(pXmlDoc, "/root/page[2]/body/section/tab/infos/bounds", "top", u"10369"); + assertXPath(pXmlDoc, "/root/page[2]/body/section/tab/infos/bounds", "height", u"940"); + assertXPath(pXmlDoc, "/root/page[2]/body/section/txt/infos/bounds", "bottom", u"11584"); + // problem was that the section bottom did not grow enough (only 11309) + assertXPath(pXmlDoc, "/root/page[2]/body/section/infos/bounds", "bottom", u"11584"); + } +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTableInSectionSplitLoop) +{ + createSwDoc("table-in-section-split-loop.fodt"); + + static OUString constexpr var{ u"TEST_NO_LOOP_CONTROLS"_ustr }; + osl_setEnvironment(var.pData, u"1"_ustr.pData); + comphelper::ScopeGuard g([] { osl_clearEnvironment(var.pData); }); + + CPPUNIT_ASSERT_EQUAL(0, SwLayouter::GetLastLoopControlStage()); + + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 1, /*bBasicCall=*/false); + pWrtShell->Delete(); + + CPPUNIT_ASSERT_EQUAL(0, SwLayouter::GetLastLoopControlStage()); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInBody) { - loadURL("private:factory/swriter", nullptr); - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc()); - SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell(); + createSwDoc(); + SwDoc* pDoc(getSwDoc()); + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); SwRootFrame* pLayout(pWrtShell->GetLayout()); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); - pWrtShell->Insert("foo"); + pWrtShell->Insert(u"foo"_ustr); pWrtShell->SplitNode(false); - pWrtShell->Insert("bar"); + pWrtShell->Insert(u"bar"_ustr); pWrtShell->SplitNode(false); - pWrtShell->Insert("baz"); + pWrtShell->Insert(u"baz"_ustr); SfxItemSet flySet(pDoc->GetAttrPool(), - svl::Items<RES_FRM_SIZE, RES_FRM_SIZE, RES_ANCHOR, RES_ANCHOR>{}); + svl::Items<RES_FRM_SIZE, RES_FRM_SIZE, RES_ANCHOR, RES_ANCHOR>); SwFormatAnchor anchor(RndStdIds::FLY_AT_CHAR); pWrtShell->StartOfSection(false); - pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false); anchor.SetAnchor(pWrtShell->GetCursor()->GetPoint()); flySet.Put(anchor); SwFormatFrameSize size(SwFrameSize::Minimum, 1000, 1000); @@ -221,21 +404,21 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInBody) CPPUNIT_ASSERT(pFly != nullptr); // move inside fly pWrtShell->GotoFly(pFly->GetName(), FLYCNTTYPE_FRM, /*bSelFrame=*/false); - pWrtShell->Insert("abc"); + pWrtShell->Insert(u"abc"_ustr); pWrtShell->SplitNode(false); - pWrtShell->Insert("def"); + pWrtShell->Insert(u"def"_ustr); pWrtShell->SplitNode(false); - pWrtShell->Insert("ghi"); + pWrtShell->Insert(u"ghi"_ustr); - dispatchCommand(mxComponent, ".uno:TrackChanges", {}); + dispatchCommand(mxComponent, u".uno:TrackChanges"_ustr, {}); // delete redline inside fly - pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 2, /*bBasicCall=*/false); - pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 8, /*bBasicCall=*/false); + pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, /*bBasicCall=*/false); + pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/true, 8, /*bBasicCall=*/false); pWrtShell->Delete(); pWrtShell->SttEndDoc(true); // note: SttDoc actually moves to start of fly? - pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 2, /*bBasicCall=*/false); - pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 7, /*bBasicCall=*/false); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, /*bBasicCall=*/false); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 7, /*bBasicCall=*/false); pWrtShell->Delete(); for (int i = 0; i < 2; ++i) @@ -243,68 +426,110 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInBody) if (i == 1) // secondly, try with different anchor type { anchor.SetType(RndStdIds::FLY_AT_PARA); - SwPosition pos(*anchor.GetContentAnchor()); + SwPosition pos(*anchor.GetAnchorNode()); pos.nContent.Assign(nullptr, 0); anchor.SetAnchor(&pos); pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); } - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); - discardDumpedLayout(); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "14"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "foaz"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", u"14"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type", + u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"foaz"); assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/merged", - "paraPropsNodeIndex", "6"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Text[1]", "nType", - "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Text[1]", "Portion", - "ahi"); - - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + "paraPropsNodeIndex", u"6"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "portion", u"ahi"); + + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); - discardDumpedLayout(); pXmlDoc = parseLayoutDump(); - { // show: nothing is merged - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//merged"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlNodes)); - xmlXPathFreeObject(pXmlObj); - } - - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "fo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[2]", "Portion", "o"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Text[1]", "Portion", - "a"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Text[2]", "Portion", - "bc"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[2]/Text[1]", "nType", - "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[2]/Text[1]", "Portion", - "def"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/Text[1]", "Portion", - "g"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/Text[2]", "Portion", - "hi"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "Portion", "b"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[2]", "Portion", "az"); + // show: nothing is merged + assertXPath(pXmlDoc, "//merged", 0); + + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"fo"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"o"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "portion", u"a"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "portion", u"bc"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "portion", u"def"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "portion", u"g"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "portion", u"hi"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type", + u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"bar"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"b"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"az"); } // anchor to 2nd (deleted) paragraph @@ -319,69 +544,103 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInBody) if (i == 1) // secondly, try with different anchor type { anchor.SetType(RndStdIds::FLY_AT_PARA); - SwPosition pos(*anchor.GetContentAnchor()); + SwPosition pos(*anchor.GetAnchorNode()); pos.nContent.Assign(nullptr, 0); anchor.SetAnchor(&pos); pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); } - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); - discardDumpedLayout(); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "14"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "foaz"); - - { // hide: no anchored object shown - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//anchored"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlNodes)); - xmlXPathFreeObject(pXmlObj); - } - - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", u"14"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type", + u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"foaz"); + + // hide: no anchored object shown + assertXPath(pXmlDoc, "//anchored", 0); + + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); - discardDumpedLayout(); pXmlDoc = parseLayoutDump(); - { // show: nothing is merged - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//merged"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlNodes)); - xmlXPathFreeObject(pXmlObj); - } - - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "fo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[2]", "Portion", "o"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/Text[1]", "Portion", - "a"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/Text[2]", "Portion", - "bc"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/Text[1]", "nType", - "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/Text[1]", "Portion", - "def"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/Text[1]", "Portion", - "g"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/Text[2]", "Portion", - "hi"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "Portion", "b"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[2]", "Portion", "az"); + // show: nothing is merged + assertXPath(pXmlDoc, "//merged", 0); + + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"fo"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"o"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type", + u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"bar"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "portion", u"a"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "portion", u"bc"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "portion", u"def"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "portion", u"g"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "portion", u"hi"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"b"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"az"); } // anchor to 3rd paragraph @@ -395,84 +654,283 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInBody) if (i == 1) // secondly, try with different anchor type { anchor.SetType(RndStdIds::FLY_AT_PARA); - SwPosition pos(*anchor.GetContentAnchor()); + SwPosition pos(*anchor.GetAnchorNode()); pos.nContent.Assign(nullptr, 0); anchor.SetAnchor(&pos); pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); } - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); - discardDumpedLayout(); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "14"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "foaz"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", u"14"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type", + u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"foaz"); assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/merged", - "paraPropsNodeIndex", "6"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Text[1]", "nType", - "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Text[1]", "Portion", - "ahi"); - - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + "paraPropsNodeIndex", u"6"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "portion", u"ahi"); + + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); - discardDumpedLayout(); pXmlDoc = parseLayoutDump(); - { // show: nothing is merged - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//merged"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlNodes)); - xmlXPathFreeObject(pXmlObj); - } + // show: nothing is merged + assertXPath(pXmlDoc, "//merged", 0); + + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"fo"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"o"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type", + u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"bar"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"b"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"az"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "portion", u"a"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "portion", u"bc"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "portion", u"def"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "portion", u"g"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "portion", u"hi"); + } +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testFlyHiddenParagraph) +{ + // disable Field Names warning dialog + const bool bAsk = officecfg::Office::Common::Misc::QueryShowFieldName::get(); + std::shared_ptr<comphelper::ConfigurationChanges> xChanges; + if (bAsk) + { + xChanges = comphelper::ConfigurationChanges::create(); + officecfg::Office::Common::Misc::QueryShowFieldName::set(false, xChanges); + xChanges->commit(); + } + + createSwDoc("fly_hidden_paragraph.fodt"); + + // first, disable both so para gets hidden + uno::Sequence<beans::PropertyValue> argsSH( + comphelper::InitPropertySequence({ { "ShowHiddenParagraphs", uno::Any(false) } })); + dispatchCommand(mxComponent, ".uno:ShowHiddenParagraphs", argsSH); + + uno::Sequence<beans::PropertyValue> args( + comphelper::InitPropertySequence({ { "Fieldnames", uno::Any(false) } })); + + dispatchCommand(mxComponent, ".uno:Fieldnames", args); + Scheduler::ProcessEventsToIdle(); + + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly/txt/infos/bounds", "height", u"0"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly/infos/bounds", "height", u"448"); + + // the problem was that now the fly was the same height as before hiding + dispatchCommand(mxComponent, ".uno:Fieldnames", {}); + Scheduler::ProcessEventsToIdle(); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "fo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[2]", "Portion", "o"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "Portion", "b"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[2]", "Portion", "az"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[1]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[1]/Text[1]", "Portion", - "a"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[1]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[1]/Text[2]", "Portion", - "bc"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[2]/Text[1]", "nType", - "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[2]/Text[1]", "Portion", - "def"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/Text[1]", "Portion", - "g"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/Text[2]", "Portion", - "hi"); + pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly/txt/infos/bounds", "height", + u"828"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly/infos/bounds", "height", u"1000"); + + dispatchCommand(mxComponent, ".uno:Fieldnames", {}); + Scheduler::ProcessEventsToIdle(); + + pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly/txt/infos/bounds", "height", u"0"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly/infos/bounds", "height", u"448"); + + dispatchCommand(mxComponent, ".uno:Fieldnames", {}); + Scheduler::ProcessEventsToIdle(); + + pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly/txt/infos/bounds", "height", + u"828"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly/infos/bounds", "height", u"1000"); + + // other test like testTdf143239 and testTdf159101 depend on this; + // seems getting the previous value is only possible with a listener + // so just hardcode it... + dispatchCommand(mxComponent, ".uno:Fieldnames", args); + Scheduler::ProcessEventsToIdle(); + + if (bAsk) + { + officecfg::Office::Common::Misc::QueryShowFieldName::set(true, xChanges); + xChanges->commit(); + } +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testFieldHideSection) +{ + createSwDoc("field_hide_section.fodt"); + + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page[1]/body/section/tab/row", 1); + assertXPath(pXmlDoc, "/root/page[2]/body/section/tab/row", 1); + assertXPath(pXmlDoc, "/root/page", 2); + + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + ::std::unique_ptr<SwField> pField(pWrtShell->GetCurField()->CopyField()); + SwFieldMgr manager(pWrtShell); + + pWrtShell->StartAllAction(); + manager.UpdateCurField(10000 /*(?)*/, "Foo", "1", std::move(pField)); + pWrtShell->EndAllAction(); + Scheduler::ProcessEventsToIdle(); + + pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page[1]/body/section/tab/row", 2); + assertXPath(pXmlDoc, "/root/page[1]/body/section/tab/row[1]/infos/bounds", "height", u"0"); + assertXPath(pXmlDoc, "/root/page[1]/body/section/tab/row[2]/infos/bounds", "height", u"0"); + assertXPath(pXmlDoc, "/root/page[1]/body/section/infos/bounds", "height", u"0"); + // the problem was that there were 3 pages now + assertXPath(pXmlDoc, "/root/page", 1); + + pWrtShell->StartAllAction(); + manager.UpdateCurField(10000 /*(?)*/, "Foo", "0", std::move(pField)); + pWrtShell->EndAllAction(); + Scheduler::ProcessEventsToIdle(); + + pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page[1]/body/section/tab/row", 1); + assertXPath(pXmlDoc, "/root/page[2]/body/section/tab/row", 1); + assertXPath(pXmlDoc, "/root/page", 2); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestI94666) +{ + createSwDoc("i94666.odt"); + + { + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page", 2); + assertXPath( + pXmlDoc, + "/root/page[2]/body/section/txt[1]/SwParaPortion/SwLineLayout[1]/SwLinePortion[1]", + "portion", u"pulled off "); + } + + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + pWrtShell->GotoPage(2, false); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 11, /*bBasicCall=*/false); + pWrtShell->SetMark(); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 11, /*bBasicCall=*/false); + pWrtShell->DelToEndOfPara(); + + { + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + // the problem was that the last paragraph moved to page 3 + assertXPath( + pXmlDoc, + "/root/page[2]/body/section/txt[1]/SwParaPortion/SwLineLayout[1]/SwLinePortion[1]", + "portion", + u"Widows & orphans He heard quiet steps behind him. That didn't bode well. Who could " + u"be " + "following"); + assertXPath( + pXmlDoc, + "/root/page[2]/body/section/txt[1]/SwParaPortion/SwLineLayout[3]/SwLinePortion[1]", + "portion", u"pulled off "); + assertXPath( + pXmlDoc, + "/root/page[2]/body/section/txt[2]/SwParaPortion/SwLineLayout[1]/SwParaPortion[1]", + "portion", u"Moved paragraph"); + assertXPath(pXmlDoc, "/root/page[2]//txt", 3); + assertXPath(pXmlDoc, "/root/page", 2); } } CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf134272) { - SwDoc* pDoc = createDoc("tdf134472.odt"); - CPPUNIT_ASSERT(pDoc); + createSwDoc("tdf134472.odt"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page[1]/header/txt[2]/infos/bounds", "height", u"843"); + assertXPath(pXmlDoc, "/root/page[1]/header/txt[2]/infos/bounds", "bottom", u"2819"); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestNestedTableMoveFwd) +{ + createSwDoc("tabellen_test_windows_1.odt"); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[2]/infos/bounds", "height", "843"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[2]/infos/bounds", "bottom", "2819"); + // the row with the nested table should not be split but be the first row on page 2 + assertXPathContent(pXmlDoc, "/root/page[1]/body/tab[1]/row[last()]/cell[1]/txt[1]", + u"Tabelle 1"); + assertXPathContent(pXmlDoc, + "/root/page[2]/body/tab[1]/row[1]/cell[1]/tab[1]/row[1]/cell[1]/txt", + u"Tabelle 2"); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf136613) { - SwDoc* pDoc = createDoc("tdf136613.docx"); - CPPUNIT_ASSERT(pDoc); + createSwDoc("tdf136613.docx"); + SwDoc* pDoc = getSwDoc(); //get the flys and the root frame const auto vFlyFormats = pDoc->GetFlyFrameFormats(FLYCNTTYPE_ALL, true); @@ -492,18 +950,17 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf136613) for (auto pFlyFormat : vFlyFormats) { //...the rectangle of the fly location... - const SwRect& rRect = pFlyFormat->FindLayoutRect(); - CPPUNIT_ASSERT(!rRect.IsEmpty()); + const SwRect aRect = pFlyFormat->FindLayoutRect(); + CPPUNIT_ASSERT(!aRect.IsEmpty()); //...if it is on the page. This will fail if not. - CPPUNIT_ASSERT_MESSAGE("The pictures are outside the page!", rPageRect.IsInside(rRect)); + CPPUNIT_ASSERT_MESSAGE("The pictures are outside the page!", rPageRect.Contains(aRect)); } } CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf88496) { - SwDoc* pDoc = createDoc("tdf88496.docx"); - CPPUNIT_ASSERT(pDoc); + createSwDoc("tdf88496.docx"); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // This was 4, table fallback "switch off repeating header" started on a new page assertXPath(pXmlDoc, "/root/page", 3); @@ -511,27 +968,26 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf88496) CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInHeader) { - loadURL("private:factory/swriter", nullptr); - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc()); - SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell(); + createSwDoc(); + SwDoc* pDoc(getSwDoc()); + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); SwRootFrame* pLayout(pWrtShell->GetLayout()); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); - pWrtShell->ChangeHeaderOrFooter(u"Default Page Style", /*bHeader*/ true, /*bOn*/ true, false); + pWrtShell->ChangeHeaderOrFooter(UIName(u"Default Page Style"_ustr), /*bHeader*/ true, + /*bOn*/ true, false); CPPUNIT_ASSERT( pWrtShell ->IsInHeaderFooter()); // assume this is supposed to put cursor in the new header... - pWrtShell->Insert("foo"); + pWrtShell->Insert(u"foo"_ustr); pWrtShell->SplitNode(false); - pWrtShell->Insert("bar"); + pWrtShell->Insert(u"bar"_ustr); pWrtShell->SplitNode(false); - pWrtShell->Insert("baz"); + pWrtShell->Insert(u"baz"_ustr); SfxItemSet flySet(pDoc->GetAttrPool(), - svl::Items<RES_FRM_SIZE, RES_FRM_SIZE, RES_ANCHOR, RES_ANCHOR>{}); + svl::Items<RES_FRM_SIZE, RES_FRM_SIZE, RES_ANCHOR, RES_ANCHOR>); SwFormatAnchor anchor(RndStdIds::FLY_AT_CHAR); pWrtShell->StartOfSection(false); - pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false); anchor.SetAnchor(pWrtShell->GetCursor()->GetPoint()); flySet.Put(anchor); SwFormatFrameSize size(SwFrameSize::Minimum, 1000, 1000); @@ -540,21 +996,21 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInHeader) CPPUNIT_ASSERT(pFly != nullptr); // move inside fly pWrtShell->GotoFly(pFly->GetName(), FLYCNTTYPE_FRM, /*bSelFrame=*/false); - pWrtShell->Insert("abc"); + pWrtShell->Insert(u"abc"_ustr); pWrtShell->SplitNode(false); - pWrtShell->Insert("def"); + pWrtShell->Insert(u"def"_ustr); pWrtShell->SplitNode(false); - pWrtShell->Insert("ghi"); + pWrtShell->Insert(u"ghi"_ustr); - dispatchCommand(mxComponent, ".uno:TrackChanges", {}); + dispatchCommand(mxComponent, u".uno:TrackChanges"_ustr, {}); // delete redline inside fly - pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 2, /*bBasicCall=*/false); - pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 8, /*bBasicCall=*/false); + pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, /*bBasicCall=*/false); + pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/true, 8, /*bBasicCall=*/false); pWrtShell->Delete(); pWrtShell->GotoHeaderText(); - pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 2, /*bBasicCall=*/false); - pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 7, /*bBasicCall=*/false); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, /*bBasicCall=*/false); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 7, /*bBasicCall=*/false); pWrtShell->Delete(); for (int i = 0; i < 2; ++i) @@ -562,72 +1018,116 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInHeader) if (i == 1) // secondly, try with different anchor type { anchor.SetType(RndStdIds::FLY_AT_PARA); - SwPosition pos(*anchor.GetContentAnchor()); + SwPosition pos(*anchor.GetAnchorNode()); pos.nContent.Assign(nullptr, 0); anchor.SetAnchor(&pos); pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); } - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); - discardDumpedLayout(); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nLength", "0"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/merged", "paraPropsNodeIndex", "6"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/Text[1]", "Portion", "foaz"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout", "type", + u"PortionType::Para"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "length", + u"0"); + assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/merged", "paraPropsNodeIndex", u"6"); + assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout[1]", "type", + u"PortionType::Para"); + assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout[1]", "portion", + u"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]/Text[1]", "nType", - "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/Text[1]", - "Portion", "ahi"); + "paraPropsNodeIndex", u"11"); + assertXPath( + pXmlDoc, + "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout[1]", + "type", u"PortionType::Para"); + assertXPath( + pXmlDoc, + "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout[1]", + "portion", u"ahi"); - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); - discardDumpedLayout(); pXmlDoc = parseLayoutDump(); - { // show: nothing is merged - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//merged"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlNodes)); - xmlXPathFreeObject(pXmlObj); - } - - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nLength", "0"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/Text[1]", "Portion", "fo"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/Text[2]", "Portion", "o"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/Text[1]", - "Portion", "a"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/Text[2]", - "Portion", "bc"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[2]/Text[1]", "nType", - "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[2]/Text[1]", - "Portion", "def"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[3]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[3]/Text[1]", - "Portion", "g"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[3]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[3]/Text[2]", - "Portion", "hi"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[2]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[2]/Text[1]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[3]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[3]/Text[1]", "Portion", "b"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[3]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[3]/Text[2]", "Portion", "az"); + // show: nothing is merged + assertXPath(pXmlDoc, "//merged", 0); + + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "type", + u"PortionType::Para"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "length", + u"0"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"fo"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"o"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "portion", u"a"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "portion", u"bc"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "portion", u"def"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "portion", u"g"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "portion", u"hi"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"bar"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"b"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"az"); } // anchor to 2nd (deleted) paragraph @@ -642,74 +1142,112 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInHeader) if (i == 1) // secondly, try with different anchor type { anchor.SetType(RndStdIds::FLY_AT_PARA); - SwPosition pos(*anchor.GetContentAnchor()); + SwPosition pos(*anchor.GetAnchorNode()); pos.nContent.Assign(nullptr, 0); anchor.SetAnchor(&pos); pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); } - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); - discardDumpedLayout(); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // now the frame has no Text portion? not sure why it's a 0-length one first and now none? - // assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Para"); - // assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nLength", "0"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/merged", "paraPropsNodeIndex", "6"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/Text[1]", "Portion", "foaz"); - - { // hide: no anchored object shown - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//anchored"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlNodes)); - xmlXPathFreeObject(pXmlObj); - } - - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + // assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type", "PortionType::Para"); + // assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "length", "0"); + assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/merged", "paraPropsNodeIndex", u"6"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"foaz"); + + // hide: no anchored object shown + assertXPath(pXmlDoc, "//anchored", 0); + + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); - discardDumpedLayout(); pXmlDoc = parseLayoutDump(); - { // show: nothing is merged - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//merged"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlNodes)); - xmlXPathFreeObject(pXmlObj); - } - - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nLength", "0"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/Text[1]", "Portion", "fo"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/Text[2]", "Portion", "o"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[2]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[2]/Text[1]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[1]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[1]/Text[1]", - "Portion", "a"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[1]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[1]/Text[2]", - "Portion", "bc"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[2]/Text[1]", "nType", - "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[2]/Text[1]", - "Portion", "def"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[3]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[3]/Text[1]", - "Portion", "g"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[3]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[3]/Text[2]", - "Portion", "hi"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[3]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[3]/Text[1]", "Portion", "b"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[3]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[3]/Text[2]", "Portion", "az"); + // show: nothing is merged + assertXPath(pXmlDoc, "//merged", 0); + + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type", + u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "length", u"0"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"fo"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"o"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"bar"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "portion", u"a"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "portion", u"bc"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "portion", u"def"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "portion", u"g"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "portion", u"hi"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"b"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"az"); } // anchor to 3rd paragraph @@ -723,80 +1261,196 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInHeader) if (i == 1) // secondly, try with different anchor type { anchor.SetType(RndStdIds::FLY_AT_PARA); - SwPosition pos(*anchor.GetContentAnchor()); + SwPosition pos(*anchor.GetAnchorNode()); pos.nContent.Assign(nullptr, 0); anchor.SetAnchor(&pos); pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); } - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); - discardDumpedLayout(); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nLength", "0"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/merged", "paraPropsNodeIndex", "6"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/Text[1]", "Portion", "foaz"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type", + u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "length", u"0"); + assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/merged", "paraPropsNodeIndex", u"6"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"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]/Text[1]", "nType", - "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/Text[1]", - "Portion", "ahi"); - - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + "paraPropsNodeIndex", u"11"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "portion", u"ahi"); + + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); - discardDumpedLayout(); pXmlDoc = parseLayoutDump(); - { // show: nothing is merged - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//merged"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlNodes)); - xmlXPathFreeObject(pXmlObj); - } - - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nLength", "0"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/Text[1]", "Portion", "fo"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[1]/Text[2]", "Portion", "o"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[2]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[2]/Text[1]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[3]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[3]/Text[1]", "Portion", "b"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[3]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[3]/Text[2]", "Portion", "az"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[1]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[1]/Text[1]", - "Portion", "a"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[1]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[1]/Text[2]", - "Portion", "bc"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[2]/Text[1]", "nType", - "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[2]/Text[1]", - "Portion", "def"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[3]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[3]/Text[1]", - "Portion", "g"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[3]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[3]/Text[2]", - "Portion", "hi"); + // show: nothing is merged + assertXPath(pXmlDoc, "//merged", 0); + + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type", + u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "length", u"0"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"fo"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"o"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"bar"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"b"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"az"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "portion", u"a"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "portion", u"bc"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "portion", u"def"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "portion", u"g"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/header/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "portion", u"hi"); } } +#if !defined(MACOSX) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf150606) +{ + createSwDoc("tdf150606-1-min.odt"); + + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + + assertXPath(pXmlDoc, "/root/page[1]/body/section/column[1]/body/tab", 1); + assertXPath(pXmlDoc, "/root/page[1]/body/section/column[2]/body/tab", 1); + assertXPath(pXmlDoc, "/root/page[1]/body/section/column", 2); + assertXPath(pXmlDoc, "/root/page[2]/body/section/column[1]/body/tab", 1); + assertXPath(pXmlDoc, "/root/page[2]/body/section/column[2]/body/tab", 1); + assertXPath(pXmlDoc, "/root/page[2]/body/section/column", 2); + assertXPath(pXmlDoc, "/root/page[3]/body/section/column[1]/body/tab", 1); + assertXPath(pXmlDoc, "/root/page[3]/body/section/column[2]/body/tab", 1); + assertXPath(pXmlDoc, "/root/page[3]/body/section/column", 2); + assertXPath(pXmlDoc, "/root/page[4]/body/section/column[1]/body/tab", 1); + assertXPath(pXmlDoc, "/root/page[4]/body/section/column[2]/body/tab", 1); + assertXPath(pXmlDoc, "/root/page[4]/body/section/column", 2); + // on page 5 the table is split across balanced columns + assertXPath(pXmlDoc, "/root/page[5]/body/section/column[1]/body/tab", 1); + assertXPath(pXmlDoc, "/root/page[5]/body/section/column[2]/body/tab", 1); + assertXPath(pXmlDoc, "/root/page[5]/body/section/column", 2); + assertXPath(pXmlDoc, "/root/page", 5); + + pWrtShell->Down(false, 1); + dispatchCommand(mxComponent, u".uno:DeleteTable"_ustr, {}); + + pXmlDoc = parseLayoutDump(); + + assertXPath(pXmlDoc, "/root/page[1]/body/section/column/body/tab", 0); + assertXPath(pXmlDoc, "/root/page", 1); + + pWrtShell->Undo(); + Scheduler::ProcessEventsToIdle(); + + pXmlDoc = parseLayoutDump(); + + assertXPath(pXmlDoc, "/root/page[1]/body/section/column[1]/body/tab", 1); + assertXPath(pXmlDoc, "/root/page[1]/body/section/column[2]/body/tab", 1); + assertXPath(pXmlDoc, "/root/page[1]/body/section/column", 2); + assertXPath(pXmlDoc, "/root/page[2]/body/section/column[1]/body/tab", 1); + assertXPath(pXmlDoc, "/root/page[2]/body/section/column[2]/body/tab", 1); + assertXPath(pXmlDoc, "/root/page[2]/body/section/column", 2); + assertXPath(pXmlDoc, "/root/page[3]/body/section/column[1]/body/tab", 1); + assertXPath(pXmlDoc, "/root/page[3]/body/section/column[2]/body/tab", 1); + assertXPath(pXmlDoc, "/root/page[3]/body/section/column", 2); + assertXPath(pXmlDoc, "/root/page[4]/body/section/column[1]/body/tab", 1); + assertXPath(pXmlDoc, "/root/page[4]/body/section/column[2]/body/tab", 1); + assertXPath(pXmlDoc, "/root/page[4]/body/section/column", 2); + // on page 5 the table is split across balanced columns + // (problem was that there were empty pages and table was on page 10) + assertXPath(pXmlDoc, "/root/page[5]/body/section/column[1]/body/tab", 1); + assertXPath(pXmlDoc, "/root/page[5]/body/section/column[2]/body/tab", 1); + assertXPath(pXmlDoc, "/root/page[5]/body/section/column", 2); + assertXPath(pXmlDoc, "/root/page", 5); +} +#endif + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf152983) +{ + //just care it doesn't crash/assert + createSwDoc("tdf152983-1-min.docx"); +} + CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf137025) { // Check the padding of the textbox - SwDoc* pDoc = createDoc("tdf137025.docx"); - CPPUNIT_ASSERT(pDoc); + createSwDoc("tdf137025.docx"); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); CPPUNIT_ASSERT(pXmlDoc); @@ -804,23 +1458,31 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf137025) // SDRATTR_TEXT_LEFTDIST assertXPath(pXmlDoc, "/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObject" - "/DefaultProperties/SfxItemSet/SdrMetricItem/SfxInt32Item[@whichId='1071']", - "value", "567"); + "/DefaultProperties/SfxItemSet/SdrMetricItem/SfxInt32Item" + "[@whichId='" + + OString::number(SDRATTR_TEXT_LEFTDIST) + "']", + "value", u"567"); // SDRATTR_TEXT_RIGHTDIST assertXPath(pXmlDoc, "/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObject" - "/DefaultProperties/SfxItemSet/SdrMetricItem/SfxInt32Item[@whichId='1072']", - "value", "1134"); + "/DefaultProperties/SfxItemSet/SdrMetricItem/SfxInt32Item" + "[@whichId='" + + OString::number(SDRATTR_TEXT_RIGHTDIST) + "']", + "value", u"1134"); // SDRATTR_TEXT_UPPERDIST assertXPath(pXmlDoc, "/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObject" - "/DefaultProperties/SfxItemSet/SdrMetricItem/SfxInt32Item[@whichId='1073']", - "value", "1701"); + "/DefaultProperties/SfxItemSet/SdrMetricItem/SfxInt32Item" + "[@whichId='" + + OString::number(SDRATTR_TEXT_UPPERDIST) + "']", + "value", u"1701"); // SDRATTR_TEXT_LOWERDIST assertXPath(pXmlDoc, "/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObject" - "/DefaultProperties/SfxItemSet/SdrMetricItem/SfxInt32Item[@whichId='1074']", - "value", "2268"); + "/DefaultProperties/SfxItemSet/SdrMetricItem/SfxInt32Item" + "[@whichId='" + + OString::number(SDRATTR_TEXT_LOWERDIST) + "']", + "value", u"2268"); // Check the textbox-shape import too auto xShp = getShape(1); @@ -833,13 +1495,13 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf137025) // The shape has these values to copy to the associated text frame after modification:: const tools::Long nLPaddng - = xShapeProps->getPropertyValue("TextLeftDistance").get<tools::Long>(); + = xShapeProps->getPropertyValue(u"TextLeftDistance"_ustr).get<tools::Long>(); const tools::Long nRPaddng - = xShapeProps->getPropertyValue("TextRightDistance").get<tools::Long>(); + = xShapeProps->getPropertyValue(u"TextRightDistance"_ustr).get<tools::Long>(); const tools::Long nTPaddng - = xShapeProps->getPropertyValue("TextUpperDistance").get<tools::Long>(); + = xShapeProps->getPropertyValue(u"TextUpperDistance"_ustr).get<tools::Long>(); const tools::Long nBPaddng - = xShapeProps->getPropertyValue("TextLowerDistance").get<tools::Long>(); + = xShapeProps->getPropertyValue(u"TextLowerDistance"_ustr).get<tools::Long>(); CPPUNIT_ASSERT_EQUAL(tools::Long(1000), nLPaddng); CPPUNIT_ASSERT_EQUAL(tools::Long(2000), nRPaddng); @@ -848,18 +1510,17 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf137025) // TODO: modify shape distance via UNO with text frame synchronization // Check the textbox as well: - auto xTxFrm = SwXTextFrame::CreateXTextFrame(*pFrameFormat->GetDoc(), pFrameFormat); + auto xTxFrm = SwXTextFrame::CreateXTextFrame(pFrameFormat->GetDoc(), pFrameFormat); CPPUNIT_ASSERT(xTxFrm); - uno::Reference<beans::XPropertySet> xFrameProps(xTxFrm, uno::UNO_QUERY); const tools::Long nFrameLeftPaddng - = xFrameProps->getPropertyValue("LeftBorderDistance").get<tools::Long>(); + = xTxFrm->getPropertyValue(u"LeftBorderDistance"_ustr).get<tools::Long>(); const tools::Long nFrameRightPaddng - = xFrameProps->getPropertyValue("RightBorderDistance").get<tools::Long>(); + = xTxFrm->getPropertyValue(u"RightBorderDistance"_ustr).get<tools::Long>(); const tools::Long nFrameTopPaddng - = xFrameProps->getPropertyValue("TopBorderDistance").get<tools::Long>(); + = xTxFrm->getPropertyValue(u"TopBorderDistance"_ustr).get<tools::Long>(); const tools::Long nFrameBottomPaddng - = xFrameProps->getPropertyValue("BottomBorderDistance").get<tools::Long>(); + = xTxFrm->getPropertyValue(u"BottomBorderDistance"_ustr).get<tools::Long>(); // Check if the shape and frame have different setting CPPUNIT_ASSERT_EQUAL(nLPaddng, nFrameLeftPaddng); @@ -870,18 +1531,16 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf137025) CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFootnote) { - loadURL("private:factory/swriter", nullptr); - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc()); - SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell(); + createSwDoc(); + SwDoc* pDoc(getSwDoc()); + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); SwRootFrame* pLayout(pWrtShell->GetLayout()); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); - pWrtShell->InsertFootnote(""); + pWrtShell->InsertFootnote(u""_ustr); CPPUNIT_ASSERT(pWrtShell->IsCursorInFootnote()); SfxItemSet flySet(pDoc->GetAttrPool(), - svl::Items<RES_FRM_SIZE, RES_FRM_SIZE, RES_ANCHOR, RES_ANCHOR>{}); + svl::Items<RES_FRM_SIZE, RES_FRM_SIZE, RES_ANCHOR, RES_ANCHOR>); SwFormatFrameSize size(SwFrameSize::Minimum, 1000, 1000); flySet.Put(size); // set a size, else we get 1 char per line... SwFormatAnchor anchor(RndStdIds::FLY_AT_CHAR); @@ -889,21 +1548,21 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFootnote) flySet.Put(anchor); // first fly is in first footnote that will be deleted /* SwFrameFormat const* pFly1 =*/pWrtShell->NewFlyFrame(flySet, /*bAnchValid=*/true); - pWrtShell->Insert("quux"); + pWrtShell->Insert(u"quux"_ustr); pWrtShell->SttEndDoc(false); - pWrtShell->InsertFootnote(""); + pWrtShell->InsertFootnote(u""_ustr); CPPUNIT_ASSERT(pWrtShell->IsCursorInFootnote()); - pWrtShell->Insert("foo"); + pWrtShell->Insert(u"foo"_ustr); pWrtShell->SplitNode(false); - pWrtShell->Insert("bar"); + pWrtShell->Insert(u"bar"_ustr); pWrtShell->SplitNode(false); - pWrtShell->Insert("baz"); + pWrtShell->Insert(u"baz"_ustr); pWrtShell->StartOfSection(false); CPPUNIT_ASSERT(pWrtShell->IsCursorInFootnote()); - pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false); anchor.SetAnchor(pWrtShell->GetCursor()->GetPoint()); flySet.Put(anchor); // second fly is in second footnote that is not deleted @@ -911,29 +1570,29 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFootnote) CPPUNIT_ASSERT(pFly != nullptr); // move inside fly pWrtShell->GotoFly(pFly->GetName(), FLYCNTTYPE_FRM, /*bSelFrame=*/false); - pWrtShell->Insert("abc"); + pWrtShell->Insert(u"abc"_ustr); pWrtShell->SplitNode(false); - pWrtShell->Insert("def"); + pWrtShell->Insert(u"def"_ustr); pWrtShell->SplitNode(false); - pWrtShell->Insert("ghi"); + pWrtShell->Insert(u"ghi"_ustr); - dispatchCommand(mxComponent, ".uno:TrackChanges", {}); + dispatchCommand(mxComponent, u".uno:TrackChanges"_ustr, {}); // delete redline inside fly - pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 2, /*bBasicCall=*/false); - pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 8, /*bBasicCall=*/false); + pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, /*bBasicCall=*/false); + pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/true, 8, /*bBasicCall=*/false); pWrtShell->Delete(); // pWrtShell->GotoFlyAnchor(); // sigh... why, now we're in the body... pWrtShell->SttEndDoc(false); - pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false); + pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false); pWrtShell->GotoFootnoteText(); - pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 2, /*bBasicCall=*/false); - pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 7, /*bBasicCall=*/false); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, /*bBasicCall=*/false); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 7, /*bBasicCall=*/false); pWrtShell->Delete(); pWrtShell->EndSelect(); // ? // delete first footnote pWrtShell->SttEndDoc(true); - pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 1, /*bBasicCall=*/false); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 1, /*bBasicCall=*/false); pWrtShell->Delete(); for (int i = 0; i < 2; ++i) @@ -941,100 +1600,173 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFootnote) if (i == 1) // secondly, try with different anchor type { anchor.SetType(RndStdIds::FLY_AT_PARA); - SwPosition pos(*anchor.GetContentAnchor()); + SwPosition pos(*anchor.GetAnchorNode()); pos.nContent.Assign(nullptr, 0); anchor.SetAnchor(&pos); pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); } - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); - discardDumpedLayout(); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "25"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "nType", - "PortionType::Footnote"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "rText", "1"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", u"25"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/" + "child::*[@type='PortionType::Footnote']", + "type", u"PortionType::Footnote"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/" + "child::*[@type='PortionType::Footnote']", + "expand", u"1"); assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/merged", "paraPropsNodeIndex", - "7"); + u"7"); assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/merged", - "paraPropsNodeIndex", "17"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/Text[1]", - "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/Text[1]", - "Portion", "ahi"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "nType", - "PortionType::FootnoteNum"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "rText", "1"); - - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + "paraPropsNodeIndex", u"17"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwParaPortion[1]", + "portion", u"ahi"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "type", u"PortionType::FootnoteNum"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "expand", u"1"); + + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); - discardDumpedLayout(); pXmlDoc = parseLayoutDump(); - { // show: nothing is merged - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//merged"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlNodes)); - xmlXPathFreeObject(pXmlObj); - } - - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "nType", - "PortionType::Footnote"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "rText", "1"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[2]", "nType", - "PortionType::Footnote"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[2]", "rText", "2"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/Text[1]", - "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/Text[1]", - "Portion", "quux"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "nType", - "PortionType::FootnoteNum"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "rText", "1"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[1]/Text[1]", - "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[1]/Text[1]", - "Portion", "a"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[1]/Text[2]", - "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[1]/Text[2]", - "Portion", "bc"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[2]/Text[1]", - "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[2]/Text[1]", - "Portion", "def"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[3]/Text[1]", - "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[3]/Text[1]", - "Portion", "g"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[3]/Text[2]", - "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[3]/Text[2]", - "Portion", "hi"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Special[1]", "nType", - "PortionType::FootnoteNum"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Special[1]", "rText", "2"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Text[1]", "Portion", "fo"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Text[2]", "Portion", "o"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[2]/Text[1]", "nType", - "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[2]/Text[1]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[3]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[3]/Text[1]", "Portion", "b"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[3]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[3]/Text[2]", "Portion", "az"); + // show: nothing is merged + assertXPath(pXmlDoc, "//merged", 0); + + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "type", u"PortionType::Footnote"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "expand", u"1"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[2]", + "type", u"PortionType::Footnote"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[2]", + "expand", u"2"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwParaPortion[1]", + "portion", u"quux"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "type", u"PortionType::FootnoteNum"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "expand", u"1"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwLinePortion[1]", + "portion", u"a"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwLinePortion[2]", + "portion", u"bc"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[2]/SwParaPortion/" + "SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[2]/SwParaPortion/" + "SwLineLayout/SwParaPortion[1]", + "portion", u"def"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/" + "SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/" + "SwLineLayout/SwLinePortion[1]", + "portion", u"g"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/" + "SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/" + "SwLineLayout/SwLinePortion[2]", + "portion", u"hi"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "type", u"PortionType::FootnoteNum"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "expand", u"2"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"fo"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"o"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"bar"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"b"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"az"); } // anchor to 2nd (deleted) paragraph pWrtShell->SttEndDoc(false); - pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false); + pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false); pWrtShell->GotoFootnoteText(); pWrtShell->Down(false, 1); anchor.SetType(RndStdIds::FLY_AT_CHAR); @@ -1046,103 +1778,166 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFootnote) if (i == 1) // secondly, try with different anchor type { anchor.SetType(RndStdIds::FLY_AT_PARA); - SwPosition pos(*anchor.GetContentAnchor()); + SwPosition pos(*anchor.GetAnchorNode()); pos.nContent.Assign(nullptr, 0); anchor.SetAnchor(&pos); pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); } - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); - discardDumpedLayout(); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "25"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "nType", - "PortionType::Footnote"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "rText", "1"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", u"25"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "type", u"PortionType::Footnote"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "expand", u"1"); assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/merged", "paraPropsNodeIndex", - "7"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "nType", - "PortionType::FootnoteNum"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "rText", "1"); - - { // hide: no anchored object shown - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//anchored"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlNodes)); - xmlXPathFreeObject(pXmlObj); - } + u"7"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "type", u"PortionType::FootnoteNum"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "expand", u"1"); + + // hide: no anchored object shown + assertXPath(pXmlDoc, "//anchored", 0); - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); - discardDumpedLayout(); pXmlDoc = parseLayoutDump(); - { // show: nothing is merged - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//merged"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlNodes)); - xmlXPathFreeObject(pXmlObj); - } - - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "nType", - "PortionType::Footnote"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "rText", "1"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[2]", "nType", - "PortionType::Footnote"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[2]", "rText", "2"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/Text[1]", - "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/Text[1]", - "Portion", "quux"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "nType", - "PortionType::FootnoteNum"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "rText", "1"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Special[1]", "nType", - "PortionType::FootnoteNum"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Special[1]", "rText", "2"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Text[1]", "Portion", "fo"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Text[2]", "Portion", "o"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[1]/Text[1]", - "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[1]/Text[1]", - "Portion", "a"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[1]/Text[2]", - "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[1]/Text[2]", - "Portion", "bc"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[2]/Text[1]", - "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[2]/Text[1]", - "Portion", "def"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[3]/Text[1]", - "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[3]/Text[1]", - "Portion", "g"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[3]/Text[2]", - "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[3]/Text[2]", - "Portion", "hi"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[2]/Text[1]", "nType", - "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[2]/Text[1]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[3]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[3]/Text[1]", "Portion", "b"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[3]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[3]/Text[2]", "Portion", "az"); + // show: nothing is merged + assertXPath(pXmlDoc, "//merged", 0); + + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "type", u"PortionType::Footnote"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "expand", u"1"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[2]", + "type", u"PortionType::Footnote"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[2]", + "expand", u"2"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwParaPortion[1]", + "portion", u"quux"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "type", u"PortionType::FootnoteNum"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "expand", u"1"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "type", u"PortionType::FootnoteNum"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "expand", u"2"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"fo"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"o"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwLinePortion[1]", + "portion", u"a"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwLinePortion[2]", + "portion", u"bc"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[2]/SwParaPortion/" + "SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[2]/SwParaPortion/" + "SwLineLayout/SwParaPortion[1]", + "portion", u"def"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/" + "SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/" + "SwLineLayout/SwLinePortion[1]", + "portion", u"g"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/" + "SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/" + "SwLineLayout/SwLinePortion[2]", + "portion", u"hi"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"bar"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"b"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"az"); } // anchor to 3rd paragraph pWrtShell->EndOfSection(); pWrtShell->SttEndDoc(false); - pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false); + pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false); pWrtShell->GotoFootnoteText(); pWrtShell->EndOfSection(); anchor.SetType(RndStdIds::FLY_AT_CHAR); @@ -1154,95 +1949,226 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFootnote) if (i == 1) // secondly, try with different anchor type { anchor.SetType(RndStdIds::FLY_AT_PARA); - SwPosition pos(*anchor.GetContentAnchor()); + SwPosition pos(*anchor.GetAnchorNode()); pos.nContent.Assign(nullptr, 0); anchor.SetAnchor(&pos); pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); } - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); - discardDumpedLayout(); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "25"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "nType", - "PortionType::Footnote"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "rText", "1"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", u"25"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "type", u"PortionType::Footnote"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "expand", u"1"); assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/merged", "paraPropsNodeIndex", - "7"); + u"7"); assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/merged", - "paraPropsNodeIndex", "17"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/Text[1]", - "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/Text[1]", - "Portion", "ahi"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "nType", - "PortionType::FootnoteNum"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "rText", "1"); - - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + "paraPropsNodeIndex", u"17"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwParaPortion[1]", + "portion", u"ahi"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "type", u"PortionType::FootnoteNum"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "expand", u"1"); + + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); - discardDumpedLayout(); pXmlDoc = parseLayoutDump(); - { // show: nothing is merged - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//merged"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlNodes)); - xmlXPathFreeObject(pXmlObj); - } + // show: nothing is merged + assertXPath(pXmlDoc, "//merged", 0); + + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/" + "child::*[@type='PortionType::Footnote'][1]", + "type", u"PortionType::Footnote"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/" + "child::*[@type='PortionType::Footnote'][1]", + "expand", u"1"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/" + "child::*[@type='PortionType::Footnote'][2]", + "type", u"PortionType::Footnote"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/" + "child::*[@type='PortionType::Footnote'][2]", + "expand", u"2"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwParaPortion[1]", + "portion", u"quux"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "type", u"PortionType::FootnoteNum"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[1]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "expand", u"1"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "type", u"PortionType::FootnoteNum"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]", + "expand", u"2"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"fo"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"o"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"bar"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwLinePortion[1]", + "portion", u"a"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwLinePortion[2]", + "portion", u"bc"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[2]/SwParaPortion/" + "SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[2]/SwParaPortion/" + "SwLineLayout/SwParaPortion[1]", + "portion", u"def"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/" + "SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/" + "SwLineLayout/SwLinePortion[1]", + "portion", u"g"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/" + "SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/" + "SwLineLayout/SwLinePortion[2]", + "portion", u"hi"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"b"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath( + pXmlDoc, + "/root/page[1]/ftncont/ftn[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"az"); + } +} - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "nType", - "PortionType::Footnote"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "rText", "1"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[2]", "nType", - "PortionType::Footnote"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[2]", "rText", "2"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/Text[1]", - "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/Text[1]", - "Portion", "quux"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "nType", - "PortionType::FootnoteNum"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "rText", "1"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Special[1]", "nType", - "PortionType::FootnoteNum"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Special[1]", "rText", "2"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Text[1]", "Portion", "fo"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Text[2]", "Portion", "o"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[2]/Text[1]", "nType", - "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[2]/Text[1]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[1]/Text[1]", - "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[1]/Text[1]", - "Portion", "a"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[1]/Text[2]", - "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[1]/Text[2]", - "Portion", "bc"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[2]/Text[1]", - "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[2]/Text[1]", - "Portion", "def"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[3]/Text[1]", - "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[3]/Text[1]", - "Portion", "g"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[3]/Text[2]", - "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[3]/anchored/fly[1]/txt[3]/Text[2]", - "Portion", "hi"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[3]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[3]/Text[1]", "Portion", "b"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[3]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[3]/Text[2]", "Portion", "az"); +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf143239) +{ + createSwDoc("tdf143239-1-min.odt"); + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + + // These are unstable on macOS and Win64 builds, + // so only test that they restore original values for now + OUString p2txt1Left, p2txt2Left, p3txt1Left; + + { + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/anchored/fly", 1); + assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/anchored/fly[1]/infos/bounds", "top", + u"18540"); + p2txt1Left + = getXPath(pXmlDoc, "/root/page[2]/body/txt[1]/anchored/fly[1]/infos/bounds", "left"); + assertXPath(pXmlDoc, "/root/page[2]/body/txt[2]/anchored/fly", 1); + assertXPath(pXmlDoc, "/root/page[2]/body/txt[2]/anchored/fly[1]/infos/bounds", "top", + u"23894"); + p2txt2Left + = getXPath(pXmlDoc, "/root/page[2]/body/txt[2]/anchored/fly[1]/infos/bounds", "left"); + assertXPath(pXmlDoc, "/root/page[3]/body/txt[1]/anchored/fly", 1); + assertXPath(pXmlDoc, "/root/page[3]/body/txt[1]/anchored/fly[1]/infos/bounds", "top", + u"35662"); + p3txt1Left + = getXPath(pXmlDoc, "/root/page[3]/body/txt[1]/anchored/fly[1]/infos/bounds", "left"); + assertXPath(pXmlDoc, "/root/page", 3); + } + + pWrtShell->SelAll(); + pWrtShell->Delete(); + pWrtShell->Undo(); + Scheduler::ProcessEventsToIdle(); + + { + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + // now the 1st fly was on page 1, and the fly on page 2 was the 2nd one + assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/anchored/fly", 1); + assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/anchored/fly[1]/infos/bounds", "top", + u"18540"); + assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/anchored/fly[1]/infos/bounds", "left", + p2txt1Left); + assertXPath(pXmlDoc, "/root/page[2]/body/txt[2]/anchored/fly", 1); + assertXPath(pXmlDoc, "/root/page[2]/body/txt[2]/anchored/fly[1]/infos/bounds", "top", + u"23894"); + assertXPath(pXmlDoc, "/root/page[2]/body/txt[2]/anchored/fly[1]/infos/bounds", "left", + p2txt2Left); + assertXPath(pXmlDoc, "/root/page[3]/body/txt[1]/anchored/fly", 1); + assertXPath(pXmlDoc, "/root/page[3]/body/txt[1]/anchored/fly[1]/infos/bounds", "top", + u"35662"); + assertXPath(pXmlDoc, "/root/page[3]/body/txt[1]/anchored/fly[1]/infos/bounds", "left", + p3txt1Left); + assertXPath(pXmlDoc, "/root/page", 3); } } @@ -1250,29 +2176,35 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTableOverlapFooterFly) { // Load a document that has a fly anchored in the footer. // It also has a table which initially overlaps with the fly, but then moves to the next page. - load(DATA_DIRECTORY, "footer-fly-table.fodt"); + createSwDoc("footer-fly-table.fodt"); xmlDocUniquePtr pLayout = parseLayoutDump(); // no fly portions, was: 8 - assertXPath( - pLayout, - "/root/page[2]/body/tab[1]/row[5]/cell[5]/txt[1]/Special[@nType='PortionType::Fly']", 0); + assertXPath(pLayout, + "/root/page[2]/body/tab[1]/row[5]/cell[5]/txt[1]/SwParaPortion/SwLineLayout/" + "SwFixPortion[@type='PortionType::Fly'][@type='PortionType::Fly']", + 0); // one line break, was: 5 - assertXPath(pLayout, "/root/page[2]/body/tab[1]/row[5]/cell[5]/txt[1]/LineBreak", 1); + assertXPath(pLayout, + "/root/page[2]/body/tab[1]/row[5]/cell[5]/txt[1]/SwParaPortion/SwLineLayout", 1); // one text portion, was: 1 - assertXPath(pLayout, "/root/page[2]/body/tab[1]/row[5]/cell[5]/txt[1]/Text", 1); - assertXPath(pLayout, "/root/page[2]/body/tab[1]/row[5]/cell[5]/txt[1]/Text", "Portion", - "Abc def ghi jkl mno pqr stu vwx yz."); + assertXPath( + pLayout, + "/root/page[2]/body/tab[1]/row[5]/cell[5]/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion", + 1); + assertXPath( + pLayout, + "/root/page[2]/body/tab[1]/row[5]/cell[5]/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion", + "portion", u"Abc def ghi jkl mno pqr stu vwx yz."); // height was: 1517 // tdf#134782 height was: 379 assertXPath(pLayout, "/root/page[2]/body/tab[1]/row[5]/cell[5]/txt[1]/infos/bounds", "height", - "253"); + u"253"); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf134277) { - SwDoc* pDoc = createDoc("tdf134277.docx"); - CPPUNIT_ASSERT(pDoc); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf134277.docx"); + SwDocShell* pShell = getSwDocShell(); std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); MetafileXmlDump dumper; @@ -1280,76 +2212,90 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf134277) xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "/metafile/push/push/push/layoutmode[2]"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT_EQUAL_MESSAGE("Bad position of shape in page break!", 0, - xmlXPathNodeSetGetLength(pXmlNodes)); + assertXPath(pXmlDoc, "/metafile/push/push/push/layoutmode[2]", 0); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf116486) { - SwDoc* pDoc = createDoc("tdf116486.docx"); - CPPUNIT_ASSERT(pDoc); - OUString aTop = parseDump("/root/page/body/txt/Special", "nHeight"); - CPPUNIT_ASSERT_EQUAL(OUString("4006"), aTop); + createSwDoc("tdf116486.docx"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + OUString aTop = getXPath( + pXmlDoc, + "/root/page/body/txt/SwParaPortion/SwLineLayout[1]/child::*[@type='PortionType::Fly']", + "height"); + CPPUNIT_ASSERT_EQUAL(u"4006"_ustr, aTop); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf142080) +{ + // this caused an infinite loop + createSwDoc("fdo43573-2-min.docx"); + + xmlDocUniquePtr pLayout = parseLayoutDump(); + // check the first paragraph on page 9 with its fly; the column was empty too + assertXPath(pLayout, + "/root/page[9]/body/section[1]/column[1]/body/txt[1]/SwParaPortion/SwLineLayout[2]/" + "SwLinePortion", + "portion", + u"De kleur u (rood) in het rechtervlak (R), de kleur r (wit) beneden (D),"); + SwTwips nPage9Top = getXPath(pLayout, "/root/page[9]/infos/bounds", "top").toInt32(); + assertXPath( + pLayout, + "/root/page[9]/body/section[1]/column[1]/body/txt[1]/anchored/fly[1]/notxt/infos/bounds", + "top", OUString::number(nPage9Top + 1460)); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf152106) +{ + // this caused an infinite loop + createSwDoc("tdf152106.odt"); + + xmlDocUniquePtr pLayout = parseLayoutDump(); + + // frame on page 3 + assertXPath(pLayout, "/root/page[3]/sorted_objs/fly", 1); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf128198) { - SwDoc* pDoc = createDoc("tdf128198-1.docx"); - CPPUNIT_ASSERT(pDoc); + createSwDoc("tdf128198-1.docx"); xmlDocUniquePtr pLayout = parseLayoutDump(); // the problem was that line 5 was truncated at "this " // due to the fly anchored in previous paragraph - assertXPath(pLayout, "/root/page/body/txt[2]/LineBreak[5]", "Line", - "to access any service, any time, anywhere. From this perspective, satellite " + assertXPath(pLayout, "/root/page/body/txt[2]/SwParaPortion/SwLineLayout[5]", "portion", + u"to access any service, any time, anywhere. From this perspective, satellite " "boasts some "); - assertXPath(pLayout, "/root/page/body/txt[2]/LineBreak[6]", "Line", "significant advantages. "); + assertXPath(pLayout, "/root/page/body/txt[2]/SwParaPortion/SwLineLayout[6]", "portion", + u"significant advantages. "); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testNoLineBreakAtSlash) { - load(DATA_DIRECTORY, "no-line-break-at-slash.fodt"); + createSwDoc("no-line-break-at-slash.fodt"); xmlDocUniquePtr pLayout = parseLayoutDump(); // the line break was between "Foostrasse 13/c/" and "2" - xmlXPathObjectPtr pXmlObj = getXPathNode(pLayout, "/root/page[1]/body/txt[1]/child::*[2]"); - CPPUNIT_ASSERT_EQUAL(std::string("Text"), std::string(reinterpret_cast<char const*>( - pXmlObj->nodesetval->nodeTab[0]->name))); - xmlXPathFreeObject(pXmlObj); - pXmlObj = getXPathNode(pLayout, "/root/page[1]/body/txt[1]/child::*[3]"); - CPPUNIT_ASSERT_EQUAL(std::string("LineBreak"), std::string(reinterpret_cast<char const*>( - pXmlObj->nodesetval->nodeTab[0]->name))); - xmlXPathFreeObject(pXmlObj); - pXmlObj = getXPathNode(pLayout, "/root/page[1]/body/txt[1]/child::*[4]"); - CPPUNIT_ASSERT_EQUAL(std::string("Text"), std::string(reinterpret_cast<char const*>( - pXmlObj->nodesetval->nodeTab[0]->name))); - xmlXPathFreeObject(pXmlObj); - pXmlObj = getXPathNode(pLayout, "/root/page[1]/body/txt[1]/child::*[5]"); - CPPUNIT_ASSERT_EQUAL(std::string("Special"), std::string(reinterpret_cast<char const*>( - pXmlObj->nodesetval->nodeTab[0]->name))); - xmlXPathFreeObject(pXmlObj); - pXmlObj = getXPathNode(pLayout, "/root/page[1]/body/txt[1]/child::*[6]"); - CPPUNIT_ASSERT_EQUAL(std::string("Text"), std::string(reinterpret_cast<char const*>( - pXmlObj->nodesetval->nodeTab[0]->name))); - xmlXPathFreeObject(pXmlObj); - pXmlObj = getXPathNode(pLayout, "/root/page[1]/body/txt[1]/child::*[7]"); - CPPUNIT_ASSERT_EQUAL(std::string("LineBreak"), std::string(reinterpret_cast<char const*>( - pXmlObj->nodesetval->nodeTab[0]->name))); - xmlXPathFreeObject(pXmlObj); - pXmlObj = getXPathNode(pLayout, "/root/page[1]/body/txt[1]/child::*[8]"); - CPPUNIT_ASSERT_EQUAL(std::string("Finish"), std::string(reinterpret_cast<char const*>( - pXmlObj->nodesetval->nodeTab[0]->name))); - xmlXPathFreeObject(pXmlObj); - - assertXPath(pLayout, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "Blah blah bla bla bla "); - assertXPath(pLayout, "/root/page[1]/body/txt[1]/Text[2]", "Portion", "Foostrasse"); - assertXPath(pLayout, "/root/page[1]/body/txt[1]/Text[3]", "Portion", "13/c/2, etc."); + assertXPath(pLayout, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout", 2); + assertXPath(pLayout, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[1]/child::*", "type", + u"PortionType::Para"); + assertXPath(pLayout, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[2]/child::*[1]", + "type", u"PortionType::Text"); + assertXPath(pLayout, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[2]/child::*[2]", + "type", u"PortionType::Blank"); + assertXPath(pLayout, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[2]/child::*[3]", + "type", u"PortionType::Text"); + + assertXPath(pLayout, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "portion", + u"Blah blah bla bla bla "); + assertXPath(pLayout, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[2]/SwLinePortion[1]", + "portion", u"Foostrasse"); + assertXPath(pLayout, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[2]/SwLinePortion[2]", + "portion", u"13/c/2, etc."); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf106153) { - load(DATA_DIRECTORY, "tdf106153.docx"); + createSwDoc("tdf106153.docx"); xmlDocUniquePtr pDump = parseLayoutDump(); const sal_Int64 nPageValLeft = getXPath(pDump, "/root/page/infos/bounds", "left").toInt64(); @@ -1378,24 +2324,22 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf106153) CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFlys) { - loadURL("private:factory/swriter", nullptr); - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc()); - SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell(); + createSwDoc(); + SwDoc* pDoc(getSwDoc()); + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); SwRootFrame* pLayout(pWrtShell->GetLayout()); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); - pWrtShell->Insert("foo"); + pWrtShell->Insert(u"foo"_ustr); pWrtShell->SplitNode(false); - pWrtShell->Insert("bar"); + pWrtShell->Insert(u"bar"_ustr); pWrtShell->SplitNode(false); - pWrtShell->Insert("baz"); + pWrtShell->Insert(u"baz"_ustr); SfxItemSet flySet(pDoc->GetAttrPool(), - svl::Items<RES_FRM_SIZE, RES_FRM_SIZE, RES_ANCHOR, RES_ANCHOR>{}); + svl::Items<RES_FRM_SIZE, RES_FRM_SIZE, RES_ANCHOR, RES_ANCHOR>); SwFormatFrameSize size(SwFrameSize::Minimum, 1000, 1000); flySet.Put(size); // set a size, else we get 1 char per line... pWrtShell->StartOfSection(false); - pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false); SwFormatAnchor anchor1(RndStdIds::FLY_AT_CHAR); anchor1.SetAnchor(pWrtShell->GetCursor()->GetPoint()); flySet.Put(anchor1); @@ -1403,11 +2347,11 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFlys) CPPUNIT_ASSERT(pFly1 != nullptr); // move inside fly1 pWrtShell->GotoFly(pFly1->GetName(), FLYCNTTYPE_FRM, /*bSelFrame=*/false); - pWrtShell->Insert("abc"); + pWrtShell->Insert(u"abc"_ustr); pWrtShell->SplitNode(false); - pWrtShell->Insert("def"); + pWrtShell->Insert(u"def"_ustr); pWrtShell->SplitNode(false); - pWrtShell->Insert("ghi"); + pWrtShell->Insert(u"ghi"_ustr); SwFormatAnchor anchor2(RndStdIds::FLY_AT_CHAR); pWrtShell->StartOfSection(false); // start of fly... @@ -1417,28 +2361,28 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFlys) CPPUNIT_ASSERT(pFly2 != nullptr); // move inside fly2 pWrtShell->GotoFly(pFly2->GetName(), FLYCNTTYPE_FRM, /*bSelFrame=*/false); - pWrtShell->Insert("jkl"); + pWrtShell->Insert(u"jkl"_ustr); pWrtShell->SplitNode(false); - pWrtShell->Insert("mno"); + pWrtShell->Insert(u"mno"_ustr); pWrtShell->SplitNode(false); - pWrtShell->Insert("pqr"); + pWrtShell->Insert(u"pqr"_ustr); - dispatchCommand(mxComponent, ".uno:TrackChanges", {}); + dispatchCommand(mxComponent, u".uno:TrackChanges"_ustr, {}); // delete redline inside fly2 - pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 2, /*bBasicCall=*/false); - pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 8, /*bBasicCall=*/false); + pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, /*bBasicCall=*/false); + pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/true, 8, /*bBasicCall=*/false); pWrtShell->Delete(); // delete redline inside fly1 pWrtShell->GotoFly(pFly1->GetName(), FLYCNTTYPE_FRM, /*bSelFrame=*/false); - pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 2, /*bBasicCall=*/false); - pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 7, /*bBasicCall=*/false); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, /*bBasicCall=*/false); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 7, /*bBasicCall=*/false); pWrtShell->Delete(); pWrtShell->ClearMark(); // otherwise it refuses to leave the fly... pWrtShell->SttEndDoc(true); // note: SttDoc actually moves to start of fly? - pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 2, /*bBasicCall=*/false); - pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 7, /*bBasicCall=*/false); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, /*bBasicCall=*/false); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 7, /*bBasicCall=*/false); pWrtShell->Delete(); for (int i = 0; i < 2; ++i) @@ -1446,128 +2390,176 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFlys) if (i == 1) // secondly, try with different anchor type { anchor1.SetType(RndStdIds::FLY_AT_PARA); - SwPosition pos(*anchor1.GetContentAnchor()); + SwPosition pos(*anchor1.GetAnchorNode()); pos.nContent.Assign(nullptr, 0); anchor1.SetAnchor(&pos); pDoc->SetAttr(anchor1, *const_cast<SwFrameFormat*>(pFly1)); anchor2.SetType(RndStdIds::FLY_AT_PARA); - pos.nNode = anchor2.GetContentAnchor()->nNode; + pos.nNode = *anchor2.GetAnchorNode(); anchor2.SetAnchor(&pos); pDoc->SetAttr(anchor2, *const_cast<SwFrameFormat*>(pFly2)); } - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); - discardDumpedLayout(); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "19"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", u"19"); assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/merged", - "paraPropsNodeIndex", "6"); + "paraPropsNodeIndex", u"6"); assertXPath( pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/merged", - "paraPropsNodeIndex", "11"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/Text[1]", - "nType", "PortionType::Para"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/Text[1]", - "Portion", "jqr"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Special[1]", "nType", - "PortionType::Fly"); // remove??? - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Text[1]", "nType", - "PortionType::Lay"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Text[1]", "Portion", - "abhi"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "foaz"); - - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + "paraPropsNodeIndex", u"11"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/" + "SwParaPortion/SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/" + "SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"jqr"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwFixPortion[1]", + "type", + u"PortionType::Fly"); // remove??? + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLineLayout[1]", + "type", u"PortionType::Lay"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLineLayout[1]", + "portion", u"abhi"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type", + u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"foaz"); + + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); - discardDumpedLayout(); pXmlDoc = parseLayoutDump(); - { // show: nothing is merged - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//merged"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlNodes)); - xmlXPathFreeObject(pXmlObj); - } - - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/Text[1]", - "nType", "PortionType::Text"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/Text[1]", - "Portion", "j"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/Text[2]", - "nType", "PortionType::Text"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/Text[2]", - "Portion", "kl"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[2]/Text[1]", - "nType", "PortionType::Para"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[2]/Text[1]", - "Portion", "mno"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[3]/Text[1]", - "nType", "PortionType::Text"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[3]/Text[1]", - "Portion", "p"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[3]/Text[2]", - "nType", "PortionType::Text"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[3]/Text[2]", - "Portion", "qr"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Special[1]", "nType", - "PortionType::Fly"); // remove??? - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Text[1]", "Portion", - "ab"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Text[2]", "Portion", - "c"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[2]/Text[1]", "nType", - "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[2]/Text[1]", "Portion", - "def"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/Text[1]", "Portion", - "g"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/Text[2]", "Portion", - "hi"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "fo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[2]", "Portion", "o"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "Portion", "b"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[2]", "Portion", "az"); + // show: nothing is merged + assertXPath(pXmlDoc, "//merged", 0); + + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/" + "SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/" + "SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"j"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/" + "SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/" + "SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"kl"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[2]/" + "SwParaPortion/SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[2]/" + "SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"mno"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[3]/" + "SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[3]/" + "SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"p"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[3]/" + "SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[3]/" + "SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"qr"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwFixPortion[1]", + "type", + u"PortionType::Fly"); // remove??? + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "portion", u"ab"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "portion", u"c"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "portion", u"def"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "portion", u"g"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "portion", u"hi"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"fo"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"o"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type", + u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"bar"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"b"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"az"); } // anchor to 2nd (deleted) paragraph @@ -1588,115 +2580,152 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFlys) if (i == 1) // secondly, try with different anchor type { anchor1.SetType(RndStdIds::FLY_AT_PARA); - SwPosition pos(*anchor1.GetContentAnchor()); + SwPosition pos(*anchor1.GetAnchorNode()); pos.nContent.Assign(nullptr, 0); anchor1.SetAnchor(&pos); pDoc->SetAttr(anchor1, *const_cast<SwFrameFormat*>(pFly1)); anchor2.SetType(RndStdIds::FLY_AT_PARA); - pos.nNode = anchor2.GetContentAnchor()->nNode; + pos.nNode = *anchor2.GetAnchorNode(); anchor2.SetAnchor(&pos); pDoc->SetAttr(anchor2, *const_cast<SwFrameFormat*>(pFly2)); } - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); - discardDumpedLayout(); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "19"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "foaz"); - - { // hide: no anchored object shown - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//anchored"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlNodes)); - xmlXPathFreeObject(pXmlObj); - } - - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", u"19"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type", + u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"foaz"); + + // hide: no anchored object shown + assertXPath(pXmlDoc, "//anchored", 0); + + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); - discardDumpedLayout(); pXmlDoc = parseLayoutDump(); - { // show: nothing is merged - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//merged"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlNodes)); - xmlXPathFreeObject(pXmlObj); - } - - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "fo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[2]", "Portion", "o"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/Text[1]", "Portion", - "j"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/Text[2]", "Portion", - "kl"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[1]/Text[1]", - "nType", "PortionType::Text"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[1]/Text[1]", - "Portion", "ab"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[1]/Text[2]", - "nType", "PortionType::Text"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[1]/Text[2]", - "Portion", "c"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[2]/Text[1]", - "nType", "PortionType::Para"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[2]/Text[1]", - "Portion", "def"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[3]/Text[1]", - "nType", "PortionType::Text"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[3]/Text[1]", - "Portion", "g"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[3]/Text[2]", - "nType", "PortionType::Text"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[3]/Text[2]", - "Portion", "hi"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/Special[1]", "nType", - "PortionType::Fly"); // remove??? - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/Text[1]", "nType", - "PortionType::Lay"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/Text[1]", "Portion", - "mno"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/Text[1]", "Portion", - "p"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/Text[2]", "Portion", - "qr"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "Portion", "b"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[2]", "Portion", "az"); + // show: nothing is merged + assertXPath(pXmlDoc, "//merged", 0); + + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"fo"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"o"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "portion", u"j"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "portion", u"kl"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[1]/" + "SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[1]/" + "SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"ab"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[1]/" + "SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[1]/" + "SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"c"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[2]/" + "SwParaPortion/SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[2]/" + "SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"def"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[3]/" + "SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[3]/" + "SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"g"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[3]/" + "SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/anchored[1]/fly[1]/txt[3]/" + "SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"hi"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/" + "SwFixPortion[1]", + "type", + u"PortionType::Fly"); // remove??? + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/" + "SwLineLayout[1]", + "type", u"PortionType::Lay"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/" + "SwLineLayout[1]", + "portion", u"mno"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "portion", u"p"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "portion", u"qr"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type", + u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"bar"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"b"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"az"); } // anchor to 3rd paragraph @@ -1715,151 +2744,197 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFlys) if (i == 1) // secondly, try with different anchor type { anchor1.SetType(RndStdIds::FLY_AT_PARA); - SwPosition pos(*anchor1.GetContentAnchor()); + SwPosition pos(*anchor1.GetAnchorNode()); pos.nContent.Assign(nullptr, 0); anchor1.SetAnchor(&pos); pDoc->SetAttr(anchor1, *const_cast<SwFrameFormat*>(pFly1)); anchor2.SetType(RndStdIds::FLY_AT_PARA); - pos.nNode = anchor2.GetContentAnchor()->nNode; + pos.nNode = *anchor2.GetAnchorNode(); anchor2.SetAnchor(&pos); pDoc->SetAttr(anchor2, *const_cast<SwFrameFormat*>(pFly2)); } - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); - discardDumpedLayout(); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "19"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", u"19"); assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/merged", - "paraPropsNodeIndex", "6"); + "paraPropsNodeIndex", u"6"); assertXPath( pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/merged", - "paraPropsNodeIndex", "11"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/Text[1]", - "nType", "PortionType::Para"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/Text[1]", - "Portion", "jqr"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Special[1]", "nType", - "PortionType::Fly"); // remove??? - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Text[1]", "nType", - "PortionType::Lay"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Text[1]", "Portion", - "abhi"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "foaz"); - - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + "paraPropsNodeIndex", u"11"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/" + "SwParaPortion/SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/anchored[1]/fly[1]/txt[1]/" + "SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"jqr"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwFixPortion[1]", + "type", + u"PortionType::Fly"); // remove??? + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLineLayout[1]", + "type", u"PortionType::Lay"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLineLayout[1]", + "portion", u"abhi"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type", + u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"foaz"); + + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); - discardDumpedLayout(); pXmlDoc = parseLayoutDump(); - { // show: nothing is merged - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//merged"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlNodes)); - xmlXPathFreeObject(pXmlObj); - } - - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "fo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[2]", "Portion", "o"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[1]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[1]/Text[1]", "Portion", - "ab"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[1]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[1]/Text[2]", "Portion", - "c"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[2]/Text[1]", "nType", - "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[2]/Text[1]", "Portion", - "def"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[1]/Text[1]", - "nType", "PortionType::Text"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[1]/Text[1]", - "Portion", "j"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[1]/Text[2]", - "nType", "PortionType::Text"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[1]/Text[2]", - "Portion", "kl"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[2]/Text[1]", - "nType", "PortionType::Para"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[2]/Text[1]", - "Portion", "mno"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[3]/Text[1]", - "nType", "PortionType::Text"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[3]/Text[1]", - "Portion", "p"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[3]/Text[2]", - "nType", "PortionType::Text"); - assertXPath( - pXmlDoc, - "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[3]/Text[2]", - "Portion", "qr"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/Special[1]", "nType", - "PortionType::Fly"); // remove??? - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/Text[1]", "Portion", - "g"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/Text[2]", "Portion", - "hi"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "Portion", "b"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[2]", "Portion", "az"); + // show: nothing is merged + assertXPath(pXmlDoc, "//merged", 0); + + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"fo"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"o"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", "type", + u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"bar"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "portion", u"ab"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "portion", u"c"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "portion", u"def"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[1]/" + "SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[1]/" + "SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"j"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[1]/" + "SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[1]/" + "SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"kl"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[2]/" + "SwParaPortion/SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[2]/" + "SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"mno"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[3]/" + "SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[3]/" + "SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"p"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[3]/" + "SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/anchored[1]/fly[1]/txt[3]/" + "SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"qr"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwFixPortion[1]", + "type", + u"PortionType::Fly"); // remove??? + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "portion", u"g"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "portion", u"hi"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"b"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"az"); } } CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysAtFlys) { - loadURL("private:factory/swriter", nullptr); - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc()); - SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell(); + createSwDoc(); + SwDoc* pDoc(getSwDoc()); + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); SwRootFrame* pLayout(pWrtShell->GetLayout()); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); - pWrtShell->Insert("foo"); + pWrtShell->Insert(u"foo"_ustr); pWrtShell->SplitNode(false); - pWrtShell->Insert("bar"); + pWrtShell->Insert(u"bar"_ustr); pWrtShell->SplitNode(false); - pWrtShell->Insert("baz"); + pWrtShell->Insert(u"baz"_ustr); SfxItemSet flySet(pDoc->GetAttrPool(), - svl::Items<RES_FRM_SIZE, RES_FRM_SIZE, RES_ANCHOR, RES_ANCHOR>{}); + svl::Items<RES_FRM_SIZE, RES_FRM_SIZE, RES_ANCHOR, RES_ANCHOR>); SwFormatFrameSize size(SwFrameSize::Minimum, 1000, 1000); flySet.Put(size); // set a size, else we get 1 char per line... pWrtShell->StartOfSection(false); - pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false); SwFormatAnchor anchor1(RndStdIds::FLY_AT_CHAR); anchor1.SetAnchor(pWrtShell->GetCursor()->GetPoint()); flySet.Put(anchor1); @@ -1867,11 +2942,11 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysAtFlys) CPPUNIT_ASSERT(pFly1 != nullptr); // move inside fly1 pWrtShell->GotoFly(pFly1->GetName(), FLYCNTTYPE_FRM, /*bSelFrame=*/false); - pWrtShell->Insert("abc"); + pWrtShell->Insert(u"abc"_ustr); pWrtShell->SplitNode(false); - pWrtShell->Insert("def"); + pWrtShell->Insert(u"def"_ustr); pWrtShell->SplitNode(false); - pWrtShell->Insert("ghi"); + pWrtShell->Insert(u"ghi"_ustr); SwFormatAnchor anchor2(RndStdIds::FLY_AT_FLY); SwPosition pos(*pFly1->GetContent().GetContentIdx()); @@ -1881,129 +2956,177 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysAtFlys) CPPUNIT_ASSERT(pFly2 != nullptr); // move inside fly2 pWrtShell->GotoFly(pFly2->GetName(), FLYCNTTYPE_FRM, /*bSelFrame=*/false); - pWrtShell->Insert("jkl"); + pWrtShell->Insert(u"jkl"_ustr); pWrtShell->SplitNode(false); - pWrtShell->Insert("mno"); + pWrtShell->Insert(u"mno"_ustr); pWrtShell->SplitNode(false); - pWrtShell->Insert("pqr"); + pWrtShell->Insert(u"pqr"_ustr); - dispatchCommand(mxComponent, ".uno:TrackChanges", {}); + dispatchCommand(mxComponent, u".uno:TrackChanges"_ustr, {}); // delete redline inside fly2 - pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 2, /*bBasicCall=*/false); - pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 8, /*bBasicCall=*/false); + pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, /*bBasicCall=*/false); + pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/true, 8, /*bBasicCall=*/false); pWrtShell->Delete(); // delete redline inside fly1 pWrtShell->GotoFly(pFly1->GetName(), FLYCNTTYPE_FRM, /*bSelFrame=*/false); - pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 2, /*bBasicCall=*/false); - pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 7, /*bBasicCall=*/false); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, /*bBasicCall=*/false); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 7, /*bBasicCall=*/false); pWrtShell->Delete(); pWrtShell->ClearMark(); // otherwise it refuses to leave the fly... pWrtShell->SttEndDoc(true); // note: SttDoc actually moves to start of fly? - pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 2, /*bBasicCall=*/false); - pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 7, /*bBasicCall=*/false); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, /*bBasicCall=*/false); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 7, /*bBasicCall=*/false); pWrtShell->Delete(); - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); - discardDumpedLayout(); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "19"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", u"19"); assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/merged", - "paraPropsNodeIndex", "6"); + "paraPropsNodeIndex", u"6"); assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/merged", - "paraPropsNodeIndex", "11"); - assertXPath(pXmlDoc, - "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/Text[1]", - "nType", "PortionType::Para"); - assertXPath(pXmlDoc, - "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/Text[1]", - "Portion", "jqr"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Special[1]", "nType", - "PortionType::Fly"); // remove??? - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Text[1]", "nType", - "PortionType::Lay"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Text[1]", "Portion", - "abhi"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "foaz"); - - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + "paraPropsNodeIndex", u"11"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwParaPortion[1]", + "portion", u"jqr"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwFixPortion[1]", + "type", + u"PortionType::Fly"); // remove??? + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLineLayout[1]", + "type", u"PortionType::Lay"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLineLayout[1]", + "portion", u"abhi"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"foaz"); + + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); - discardDumpedLayout(); pXmlDoc = parseLayoutDump(); - { // show: nothing is merged - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//merged"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlNodes)); - xmlXPathFreeObject(pXmlObj); - } + // show: nothing is merged + assertXPath(pXmlDoc, "//merged", 0); assertXPath(pXmlDoc, - "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/Text[1]", - "nType", "PortionType::Text"); - assertXPath(pXmlDoc, - "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/Text[1]", - "Portion", "j"); - assertXPath(pXmlDoc, - "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/Text[2]", - "nType", "PortionType::Text"); - assertXPath(pXmlDoc, - "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/Text[2]", - "Portion", "kl"); - assertXPath(pXmlDoc, - "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[2]/Text[1]", - "nType", "PortionType::Para"); - assertXPath(pXmlDoc, - "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[2]/Text[1]", - "Portion", "mno"); - assertXPath(pXmlDoc, - "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[3]/Text[1]", - "nType", "PortionType::Text"); - assertXPath(pXmlDoc, - "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[3]/Text[1]", - "Portion", "p"); - assertXPath(pXmlDoc, - "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[3]/Text[2]", - "nType", "PortionType::Text"); - assertXPath(pXmlDoc, - "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[3]/Text[2]", - "Portion", "qr"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Special[1]", "nType", - "PortionType::Fly"); // remove??? - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Text[1]", "Portion", - "ab"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/Text[2]", "Portion", - "c"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[2]/Text[1]", "nType", - "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[2]/Text[1]", "Portion", - "def"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/Text[1]", "Portion", - "g"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/Text[2]", "Portion", - "hi"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "fo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[2]", "Portion", "o"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "Portion", "b"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[2]", "Portion", "az"); + "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwLinePortion[1]", + "portion", u"j"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwLinePortion[2]", + "portion", u"kl"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[2]/SwParaPortion/" + "SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[2]/SwParaPortion/" + "SwLineLayout/SwParaPortion[1]", + "portion", u"mno"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[3]/SwParaPortion/" + "SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[3]/SwParaPortion/" + "SwLineLayout/SwLinePortion[1]", + "portion", u"p"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[3]/SwParaPortion/" + "SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/anchored[1]/fly[1]/txt[3]/SwParaPortion/" + "SwLineLayout/SwLinePortion[2]", + "portion", u"qr"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwFixPortion[1]", + "type", + u"PortionType::Fly"); // remove??? + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "portion", u"ab"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "portion", u"c"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "portion", u"def"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "portion", u"g"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[1]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "portion", u"hi"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"fo"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"o"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"bar"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"b"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"az"); // anchor to 2nd (deleted) paragraph pWrtShell->StartOfSection(); @@ -2012,243 +3135,630 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysAtFlys) anchor1.SetAnchor(pWrtShell->GetCursor()->GetPoint()); pDoc->SetAttr(anchor1, *const_cast<SwFrameFormat*>(pFly1)); - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); - discardDumpedLayout(); pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "19"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "foaz"); - - { // hide: no anchored object shown - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//anchored"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlNodes)); - xmlXPathFreeObject(pXmlObj); - } + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", u"19"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"foaz"); - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + // hide: no anchored object shown + assertXPath(pXmlDoc, "//anchored", 0); + + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); - discardDumpedLayout(); pXmlDoc = parseLayoutDump(); - { // show: nothing is merged - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//merged"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlNodes)); - xmlXPathFreeObject(pXmlObj); - } - - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "fo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[2]", "Portion", "o"); - assertXPath(pXmlDoc, - "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/Text[1]", - "nType", "PortionType::Text"); - assertXPath(pXmlDoc, - "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/Text[1]", - "Portion", "j"); - assertXPath(pXmlDoc, - "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/Text[2]", - "nType", "PortionType::Text"); - assertXPath(pXmlDoc, - "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/Text[2]", - "Portion", "kl"); - assertXPath(pXmlDoc, - "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[2]/Text[1]", - "nType", "PortionType::Para"); - assertXPath(pXmlDoc, - "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[2]/Text[1]", - "Portion", "mno"); - assertXPath(pXmlDoc, - "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[3]/Text[1]", - "nType", "PortionType::Text"); - assertXPath(pXmlDoc, - "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[3]/Text[1]", - "Portion", "p"); - assertXPath(pXmlDoc, - "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[3]/Text[2]", - "nType", "PortionType::Text"); - assertXPath(pXmlDoc, - "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[3]/Text[2]", - "Portion", "qr"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/Special[1]", "nType", - "PortionType::Fly"); // remove??? - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/Text[1]", "Portion", - "ab"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/Text[2]", "Portion", - "c"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/Text[1]", "nType", - "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/Text[1]", "Portion", - "def"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/Text[1]", "Portion", - "g"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/Text[2]", "Portion", - "hi"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "Portion", "b"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[2]", "Portion", "az"); + // show: nothing is merged + assertXPath(pXmlDoc, "//merged", 0); + + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"fo"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"o"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwLinePortion[1]", + "portion", u"j"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/SwLinePortion[2]", + "portion", u"kl"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[2]/SwParaPortion/" + "SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[2]/SwParaPortion/" + "SwLineLayout/SwParaPortion[1]", + "portion", u"mno"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[3]/SwParaPortion/" + "SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[3]/SwParaPortion/" + "SwLineLayout/SwLinePortion[1]", + "portion", u"p"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[3]/SwParaPortion/" + "SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/anchored[1]/fly[1]/txt[3]/SwParaPortion/" + "SwLineLayout/SwLinePortion[2]", + "portion", u"qr"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwFixPortion[1]", + "type", + u"PortionType::Fly"); // remove??? + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "portion", u"ab"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "portion", u"c"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[2]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "portion", u"def"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[1]", + "portion", u"g"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/txt[2]/anchored/fly[1]/txt[3]/SwParaPortion/SwLineLayout/" + "SwLinePortion[2]", + "portion", u"hi"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"bar"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"b"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"az"); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineSections) { - createDoc("redline_sections.fodt"); - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc()); + createSwDoc("redline_sections.fodt"); + SwDoc* pDoc(getSwDoc()); SwRootFrame* pLayout(pDoc->getIDocumentLayoutAccess().GetCurrentLayout()); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); // verify after load CheckRedlineSectionsHidden(); - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); // why is this needed explicitly? - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); - discardDumpedLayout(); + calcLayout(); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // show: nothing is merged - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//merged"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlNodes)); - xmlXPathFreeObject(pXmlObj); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "fo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[2]", "Portion", "o"); - - assertXPath(pXmlDoc, "/root/page[1]/body/section[1]/txt[1]/anchored/fly[1]/txt[1]/Text[1]", - "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/section[1]/txt[1]/anchored/fly[1]/txt[1]/Text[1]", - "Portion", "FRAME"); - assertXPath(pXmlDoc, "/root/page[1]/body/section[1]/txt[1]/Text[1]", "nType", - "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/section[1]/txt[1]/Text[1]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/section[1]/txt[2]/Text[1]", "nType", - "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/section[1]/txt[2]/Text[1]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "Portion", "b"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[2]", "Portion", "lah"); - assertXPath(pXmlDoc, "/root/page[1]/body/section[2]/txt[1]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/section[2]/txt[1]/Text[1]", "Portion", "fo"); - assertXPath(pXmlDoc, "/root/page[1]/body/section[2]/txt[1]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/section[2]/txt[1]/Text[2]", "Portion", "o"); - assertXPath(pXmlDoc, "/root/page[1]/body/section[2]/txt[2]/Text[1]", "nType", - "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/section[2]/txt[2]/Text[1]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/section[2]/txt[3]/Text[1]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/section[2]/txt[3]/Text[1]", "Portion", "b"); - assertXPath(pXmlDoc, "/root/page[1]/body/section[2]/txt[3]/Text[2]", "nType", - "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/section[2]/txt[3]/Text[2]", "Portion", "lah"); + assertXPath(pXmlDoc, "//merged", 0); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/child::*[1]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/child::*[1]", + "portion", u"fo"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/child::*[2]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/child::*[2]", + "portion", u"o"); + + assertXPath(pXmlDoc, + "/root/page[1]/body/section[1]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/child::*[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/section[1]/txt[1]/anchored/fly[1]/txt[1]/SwParaPortion/" + "SwLineLayout/child::*[1]", + "portion", u"FRAME"); + assertXPath(pXmlDoc, + "/root/page[1]/body/section[1]/txt[1]/SwParaPortion/SwLineLayout/child::*[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/section[1]/txt[1]/SwParaPortion/SwLineLayout/child::*[1]", + "portion", u"bar"); + assertXPath(pXmlDoc, + "/root/page[1]/body/section[1]/txt[2]/SwParaPortion/SwLineLayout/child::*[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/section[1]/txt[2]/SwParaPortion/SwLineLayout/child::*[1]", + "portion", u"baz"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/child::*[1]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/child::*[1]", + "portion", u"b"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/child::*[2]", "type", + u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/child::*[2]", + "portion", u"lah"); + assertXPath(pXmlDoc, + "/root/page[1]/body/section[2]/txt[1]/SwParaPortion/SwLineLayout/child::*[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/section[2]/txt[1]/SwParaPortion/SwLineLayout/child::*[1]", + "portion", u"fo"); + assertXPath(pXmlDoc, + "/root/page[1]/body/section[2]/txt[1]/SwParaPortion/SwLineLayout/child::*[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/section[2]/txt[1]/SwParaPortion/SwLineLayout/child::*[2]", + "portion", u"o"); + assertXPath(pXmlDoc, + "/root/page[1]/body/section[2]/txt[2]/SwParaPortion/SwLineLayout/child::*[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/section[2]/txt[2]/SwParaPortion/SwLineLayout/child::*[1]", + "portion", u"bar"); + assertXPath(pXmlDoc, + "/root/page[1]/body/section[2]/txt[3]/SwParaPortion/SwLineLayout/child::*[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/section[2]/txt[3]/SwParaPortion/SwLineLayout/child::*[1]", + "portion", u"b"); + assertXPath(pXmlDoc, + "/root/page[1]/body/section[2]/txt[3]/SwParaPortion/SwLineLayout/child::*[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, + "/root/page[1]/body/section[2]/txt[3]/SwParaPortion/SwLineLayout/child::*[2]", + "portion", u"lah"); // verify after hide - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); // why is this needed explicitly? - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); - discardDumpedLayout(); + calcLayout(); CheckRedlineSectionsHidden(); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TDF69647_images) { - createDoc("tdf69647_images.odt"); - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); + createSwDoc("tdf69647_images.odt"); CPPUNIT_ASSERT_EQUAL_MESSAGE("Number of pages does not match!", 2, getPages()); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TDF69647_text) { - createDoc("tdf69647_text.docx"); - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); + createSwDoc("tdf69647_text.docx"); CPPUNIT_ASSERT_EQUAL_MESSAGE("Number of pages does not match!", 2, getPages()); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineTables) { - createDoc("redline_table.fodt"); - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc()); + createSwDoc("redline_table.fodt"); + SwDoc* pDoc(getSwDoc()); SwRootFrame* pLayout(pDoc->getIDocumentLayoutAccess().GetCurrentLayout()); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); // verify after load - discardDumpedLayout(); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "12"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "foar"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", u"12"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"foar"); - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); // why is this needed explicitly? - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); - discardDumpedLayout(); + calcLayout(); pXmlDoc = parseLayoutDump(); // show: nothing is merged - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//merged"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlNodes)); - xmlXPathFreeObject(pXmlObj); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "fo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[2]", "Portion", "o"); - - assertXPath(pXmlDoc, - "/root/page[1]/body/tab[1]/row[1]/cell[1]/txt[1]/anchored/fly[1]/txt[1]/Text[1]", - "nType", "PortionType::Para"); - assertXPath(pXmlDoc, - "/root/page[1]/body/tab[1]/row[1]/cell[1]/txt[1]/anchored/fly[1]/txt[1]/Text[1]", - "Portion", "FRAME"); - assertXPath(pXmlDoc, "/root/page[1]/body/tab[1]/row[1]/cell[1]/txt[1]/Text[1]", "nType", - "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/tab[1]/row[1]/cell[1]/txt[1]/Text[1]", "Portion", - "aaa"); - assertXPath(pXmlDoc, "/root/page[1]/body/tab[1]/row[2]/cell[2]/txt[1]/Text[1]", "nType", - "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/tab[1]/row[2]/cell[2]/txt[1]/Text[1]", "Portion", - "ddd"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "Portion", "b"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[2]", "Portion", "ar"); + assertXPath(pXmlDoc, "//merged", 0); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"fo"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"o"); + + assertXPath(pXmlDoc, + "/root/page[1]/body/tab[1]/row[1]/cell[1]/txt[1]/anchored/fly[1]/txt[1]/" + "SwParaPortion/SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/tab[1]/row[1]/cell[1]/txt[1]/anchored/fly[1]/txt[1]/" + "SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"FRAME"); + assertXPath(pXmlDoc, + "/root/page[1]/body/tab[1]/row[1]/cell[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/tab[1]/row[1]/cell[1]/txt[1]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "portion", u"aaa"); + assertXPath(pXmlDoc, + "/root/page[1]/body/tab[1]/row[2]/cell[2]/txt[1]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, + "/root/page[1]/body/tab[1]/row[2]/cell[2]/txt[1]/SwParaPortion/SwLineLayout/" + "SwParaPortion[1]", + "portion", u"ddd"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"b"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"ar"); // verify after hide - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); // why is this needed explicitly? - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); - discardDumpedLayout(); + calcLayout(); + pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", u"12"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"foar"); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf144057) +{ + createSwDoc("tdf144057.fodt"); + SwDoc* pDoc(getSwDoc()); + SwRootFrame* pLayout(pDoc->getIDocumentLayoutAccess().GetCurrentLayout()); + CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + // show tracked row deletions + assertXPath(pXmlDoc, "/root/page", 4); + assertXPath(pXmlDoc, + "/root/page[1]/body/tab/row[6]/cell/txt/SwParaPortion/SwLineLayout/SwParaPortion", + "portion", u"A6"); + assertXPath(pXmlDoc, + "/root/page[2]/body/tab/row[6]/cell/txt/SwParaPortion/SwLineLayout/SwParaPortion", + "portion", u"A12"); + assertXPath(pXmlDoc, + "/root/page[3]/body/tab/row[6]/cell/txt/SwParaPortion/SwLineLayout/SwParaPortion", + "portion", u"B6"); + assertXPath(pXmlDoc, + "/root/page[4]/body/tab/row[6]/cell/txt/SwParaPortion/SwLineLayout/SwParaPortion", + "portion", u"B12"); + + // hide tracked table and table row deletions + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); + CPPUNIT_ASSERT(pLayout->IsHideRedlines()); + calcLayout(); + pXmlDoc = parseLayoutDump(); + + // This was 4 (unhidden tracked table and table row deletions) + assertXPath(pXmlDoc, "/root/page", 1); + assertXPath(pXmlDoc, "/root/page[1]/body/tab", 1); + assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 5); + assertXPath(pXmlDoc, + "/root/page[1]/body/tab/row[5]/cell/txt/SwParaPortion/SwLineLayout/SwParaPortion", + "portion", u"B12"); + + // show tracked table and table row deletions again + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); + CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); + calcLayout(); + pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page", 4); + assertXPath(pXmlDoc, + "/root/page[1]/body/tab/row[6]/cell/txt/SwParaPortion/SwLineLayout/SwParaPortion", + "portion", u"A6"); + assertXPath(pXmlDoc, + "/root/page[2]/body/tab/row[6]/cell/txt/SwParaPortion/SwLineLayout/SwParaPortion", + "portion", u"A12"); + assertXPath(pXmlDoc, + "/root/page[3]/body/tab/row[6]/cell/txt/SwParaPortion/SwLineLayout/SwParaPortion", + "portion", u"B6"); + assertXPath(pXmlDoc, + "/root/page[4]/body/tab/row[6]/cell/txt/SwParaPortion/SwLineLayout/SwParaPortion", + "portion", u"B12"); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf144347) +{ + createSwDoc("tdf144057.fodt"); + SwDoc* pDoc(getSwDoc()); + SwRootFrame* pLayout(pDoc->getIDocumentLayoutAccess().GetCurrentLayout()); + + // enable redlining + dispatchCommand(mxComponent, u".uno:TrackChanges"_ustr, {}); + CPPUNIT_ASSERT_MESSAGE("redlining should be on", + pDoc->getIDocumentRedlineAccess().IsRedlineOn()); + CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); + + // remove first table + SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); + for (int i = 0; i < 12; ++i) + pEditShell->AcceptRedline(0); + + calcLayout(); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + // show tracked row deletions + assertXPath(pXmlDoc, "/root/page", 2); + assertXPath(pXmlDoc, "/root/page[1]/body/tab", 1); + + // select all the text, including the texts before and after the table + // Note: this table contains tracked changes, which was a + // problem for the original OOo implementation of track changes, + // resulting empty tables after accepting the deletion of these tables. + dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {}); + dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {}); + dispatchCommand(mxComponent, u".uno:Delete"_ustr, {}); + calcLayout(); + pXmlDoc = parseLayoutDump(); + + // table is deleted with change tracking: it still exists + assertXPath(pXmlDoc, "/root/page", 2); + assertXPath(pXmlDoc, "/root/page[1]/body/tab", 1); + + // accept all deletions, removing the table completely + while (pEditShell->GetRedlineCount() > 0) + pEditShell->AcceptRedline(0); + + calcLayout(); + pXmlDoc = parseLayoutDump(); + + assertXPath(pXmlDoc, "/root/page", 1); + // This was 1 (bad empty table) + assertXPath(pXmlDoc, "/root/page[1]/body/tab", 0); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf155345) +{ + createSwDoc("tdf144057.fodt"); + SwDoc* pDoc(getSwDoc()); + SwRootFrame* pLayout(pDoc->getIDocumentLayoutAccess().GetCurrentLayout()); + CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); + + // reject all deletions + dispatchCommand(mxComponent, u".uno:RejectAllTrackedChanges"_ustr, {}); + + // enable redlining + dispatchCommand(mxComponent, u".uno:TrackChanges"_ustr, {}); + CPPUNIT_ASSERT_MESSAGE("redlining should be on", + pDoc->getIDocumentRedlineAccess().IsRedlineOn()); + + // delete table column with track changes + dispatchCommand(mxComponent, u".uno:DeleteColumns"_ustr, {}); + + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + // show tracked column deletions + assertXPath(pXmlDoc, "/root/page", 4); + + // hide tracked table column deletions + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); + CPPUNIT_ASSERT(pLayout->IsHideRedlines()); + calcLayout(); + pXmlDoc = parseLayoutDump(); + + // This was 4 (unhidden tracked table column deletions) + assertXPath(pXmlDoc, "/root/page", 2); + + // show tracked table column deletions again + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); + CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); + calcLayout(); pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "12"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "foar"); + assertXPath(pXmlDoc, "/root/page", 4); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf109137) +{ + createSwDoc("tdf109137.docx"); + // FIXME: Error: attribute "text:start-value" has a bad value + skipValidation(); + saveAndReload(u"writer8"_ustr); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + // This was 0, the blue rectangle moved from the 1st to the 2nd page. + assertXPath(pXmlDoc, "/root/page[1]/body/txt/anchored/fly/notxt", + /*nNumberOfNodes=*/1); +} + +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint72) { createSwDoc("forcepoint72-1.rtf"); } + +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint75) { createSwDoc("forcepoint75-1.rtf"); } + +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testUXTSOREL) { createSwDoc("LIBREOFFICE-UXTSOREL.rtf"); } + +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepointFootnoteFrame) +{ + createSwDoc("forcepoint-swfootnoteframe-1.rtf"); +} + +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint76) { createSwDoc("forcepoint76-1.rtf"); } + +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testN4LA0OHZ) { createSwDoc("LIBREOFFICE-N4LA0OHZ.rtf"); } + +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint89) { createSwWebDoc("forcepoint89.html"); } + +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint90) { createSwDoc("forcepoint90.rtf"); } + +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint91) { createSwWebDoc("forcepoint91.html"); } + +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint92) { createSwDoc("forcepoint92.doc"); } + +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint93) +{ + createSwDoc("forcepoint93-1.rtf"); + createSwDoc("forcepoint93-2.rtf"); +} + +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint94) { createSwWebDoc("forcepoint94.html"); } + +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint98) { createSwWebDoc("forcepoint98.html"); } + +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint100) { createSwWebDoc("forcepoint100.html"); } + +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint102) { createSwDoc("forcepoint102.rtf"); } + +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint103) { createSwWebDoc("forcepoint103.html"); } + +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf147485Forcepoint) +{ + createSwDoc("tdf147485-forcepoint.docx"); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf118058) +{ + createSwDoc("tdf118058.fodt"); + // This resulted in a layout loop. + calcLayout(); +} + +//just care it doesn't crash/assert +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint99) { createSwWebDoc("forcepoint99.html"); } + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf128611) +{ + createSwDoc("tdf128611.fodt"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT(pXmlDoc); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 + // - 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. + assertXPathContent(pXmlDoc, "//tab/row/cell[1]/txt", u"Abcd efghijkl"); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf159101) +{ + createSwDoc("tdf159101.odt"); + + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, "/root/page/body/txt[2]/SwParaPortion/SwLineLayout[1]/SwFieldPortion", + "expand", u"One"); + + // Without the fix in place, this test would have failed with + // - Expected: two + // - Actual : two + assertXPath(pXmlDoc, "/root/page/body/txt[2]/SwParaPortion/SwLineLayout[2]/SwFieldPortion", + "expand", u"two"); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf157628) +{ + createSwDoc("tdf157628.docx"); + + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout[1]/SwLinePortion", + "portion", u"This is in first row"); + assertXPath(pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout[2]/SwLinePortion", + "portion", u"This is second row*"); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf142694) +{ + createSwDoc("tdf142694-1.odt"); + + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT(pXmlDoc); + + // the problem with this table is that the 3rd text frame (inside a nested + // table) contains an as-char fly that doesn't fit on a page with the + // repeated header row; currently it's split so that the 3rd text frame is + // on a page of its own and extends outside the table. + + assertXPathNoAttribute(pXmlDoc, "/root/page[4]/body/tab[1]", "precede"); + CPPUNIT_ASSERT(!getXPath(pXmlDoc, "/root/page[4]/body/tab[1]", "follow").isEmpty()); + assertXPath(pXmlDoc, "/root/page[4]/body/tab[1]/row[1]/cell[1]/tab", 1); + assertXPath(pXmlDoc, "/root/page[4]/body/tab[1]/row[2]/cell[1]/txt", 2); + CPPUNIT_ASSERT(!getXPath(pXmlDoc, "/root/page[5]/body/tab[1]", "precede").isEmpty()); + assertXPathNoAttribute(pXmlDoc, "/root/page[5]/body/tab[1]", "follow"); + assertXPath(pXmlDoc, "/root/page[5]/body/tab[1]/row[1]/cell[1]/tab", 1); + assertXPath(pXmlDoc, "/root/page[5]/body/tab[1]/row[2]/cell[1]/tab", 1); + assertXPathNoAttribute(pXmlDoc, "/root/page[5]/body/tab[1]/row[2]/cell[1]/tab", "follow"); + assertXPath(pXmlDoc, "/root/page[5]/body/tab[1]/row[2]/cell[1]/tab/row/cell/txt", 1); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf152413) +{ + createSwDoc("tdf152413.fodt"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + + // Without the fix in place, this test would have failed with + // - Expected: 1 + // - Actual : 2 + // - In <>, XPath '/root/page/body/txt/SwParaPortion/SwLineLayout/SwLinePortion' number of nodes is incorrect + assertXPath(pXmlDoc, "/root/page/body/txt/SwParaPortion/SwLineLayout/SwLinePortion", "portion", + u"صِرَ ٰطَ"); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf125893) +{ + createSwDoc("tdf125893.docx"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + // This was 400. The paragraph must have zero top border. + assertXPath(pXmlDoc, "/root/page/body/txt[4]/infos/prtBounds", "top", u"0"); } CPPUNIT_PLUGIN_IMPLEMENT(); |