diff options
Diffstat (limited to 'sw/qa/extras/layout/layout2.cxx')
-rw-r--r-- | sw/qa/extras/layout/layout2.cxx | 3649 |
1 files changed, 1459 insertions, 2190 deletions
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index 253783a9e146..0608c291e91c 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -8,242 +8,396 @@ */ #include <swmodeltestbase.hxx> -#include <comphelper/propertysequence.hxx> + #include <com/sun/star/linguistic2/XHyphenator.hpp> -#include <com/sun/star/text/WrapTextMode.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> +#include <com/sun/star/linguistic2/XSpellChecker1.hpp> + #include <comphelper/scopeguard.hxx> -#include <unotools/syslocaleoptions.hxx> +#include <comphelper/sequence.hxx> +#include <editeng/unolingu.hxx> #include <i18nlangtag/languagetag.hxx> -#include <vcl/event.hxx> +#include <o3tl/string_view.hxx> #include <vcl/scheduler.hxx> -#include <editeng/lrspitem.hxx> -#include <editeng/fontitem.hxx> -#include <editeng/fhgtitem.hxx> -#include <editeng/postitem.hxx> -#include <editeng/unolingu.hxx> -#include <editeng/outlobj.hxx> -#include <editeng/editobj.hxx> -#include <comphelper/sequence.hxx> -#include <fmtfsize.hxx> -#include <wrtsh.hxx> -#include <edtwin.hxx> -#include <view.hxx> -#include <txtfrm.hxx> +#include <rootfrm.hxx> #include <pagefrm.hxx> #include <bodyfrm.hxx> -#include <sortedobjs.hxx> -#include <anchoredobject.hxx> +#include <txtfrm.hxx> #include <ndtxt.hxx> -#include <frmatr.hxx> -#include <IDocumentSettingAccess.hxx> -#include <config_features.h> -#include <unotxdoc.hxx> -#include <rootfrm.hxx> -#include <docsh.hxx> +#include <wrtsh.hxx> #include <IDocumentLayoutAccess.hxx> -#include <IDocumentDrawModelAccess.hxx> -#include <textboxhelper.hxx> -#include <unoframe.hxx> -#include <drawdoc.hxx> -#include <svx/svdpage.hxx> -#include <svx/svdotext.hxx> -#include <dcontact.hxx> - -constexpr OUStringLiteral DATA_DIRECTORY = u"/sw/qa/extras/layout/data/"; +#include <IDocumentRedlineAccess.hxx> +#include <fmtanchr.hxx> +#include <redline.hxx> /// Test to assert layout / rendering result of Writer. class SwLayoutWriter2 : public SwModelTestBase { +public: + SwLayoutWriter2() + : SwModelTestBase(u"/sw/qa/extras/layout/data/"_ustr) + { + } + protected: void CheckRedlineCharAttributesHidden(); - - SwDoc* createDoc(const char* pName = nullptr); }; -SwDoc* SwLayoutWriter2::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 mainly tests that splitting portions across redlines in SwAttrIter works void SwLayoutWriter2::CheckRedlineCharAttributesHidden() { - discardDumpedLayout(); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "9"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "foobaz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/merged", "paraPropsNodeIndex", "10"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "Portion", "foobaz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/merged", "paraPropsNodeIndex", "11"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[2]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/merged", "paraPropsNodeIndex", "12"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/Text[2]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/merged", "paraPropsNodeIndex", "13"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/Text[2]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/merged", "paraPropsNodeIndex", "14"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/Text[2]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/merged", "paraPropsNodeIndex", "15"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/Text[2]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/merged", "paraPropsNodeIndex", "16"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/Text[2]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/merged", "paraPropsNodeIndex", "17"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/Text[1]", "Portion", "foobaz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/merged", "paraPropsNodeIndex", "18"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[1]", "Portion", "fo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[2]", "Portion", "ob"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[3]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[3]", "Portion", "az"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/merged", "paraPropsNodeIndex", "19"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/Text[1]", "nType", "PortionType::Para"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/Text[1]", "Portion", "foobaz"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", u"9"); + 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"foobaz"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/merged", "paraPropsNodeIndex", u"10"); + 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"foobaz"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/merged", "paraPropsNodeIndex", u"11"); + 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"foo"); + 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"baz"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/merged", "paraPropsNodeIndex", u"12"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"foo"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"baz"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/merged", "paraPropsNodeIndex", u"13"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"foo"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"baz"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/merged", "paraPropsNodeIndex", u"14"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"foo"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"baz"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/merged", "paraPropsNodeIndex", u"15"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"foo"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"baz"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/merged", "paraPropsNodeIndex", u"16"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"foo"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"baz"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/merged", "paraPropsNodeIndex", u"17"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"foobaz"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/merged", "paraPropsNodeIndex", u"18"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"fo"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"ob"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "portion", u"az"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/merged", "paraPropsNodeIndex", u"19"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "type", u"PortionType::Para"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/SwParaPortion/SwLineLayout/SwParaPortion[1]", + "portion", u"foobaz"); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf148897) +{ + createSwDoc("tdf148897.odt"); + + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + + assertXPath(pXmlDoc, "/root/page[1]/sorted_objs/fly", 1); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly", 1); + assertXPath(pXmlDoc, "/root/page[2]/sorted_objs/fly", 1); + assertXPath(pXmlDoc, "/root/page[2]/body/txt[3]/anchored/fly", 1); + assertXPath(pXmlDoc, "/root/page[3]/sorted_objs/fly", 0); + assertXPath(pXmlDoc, "/root/page[3]/body/txt/anchored/fly", 0); + assertXPath(pXmlDoc, "/root/page[4]/sorted_objs/fly", 1); + assertXPath(pXmlDoc, "/root/page[4]/body/txt[1]/anchored/fly", 1); + // fly portion exists, no overlapping text + assertXPath(pXmlDoc, "/root/page[4]/body/txt[1]/SwParaPortion/SwLineLayout[1]/SwFixPortion", + "height", u"5797"); + assertXPath(pXmlDoc, "/root/page[5]/sorted_objs/fly", 0); + assertXPath(pXmlDoc, "/root/page", 5); + + auto xModel = mxComponent.queryThrow<frame::XModel>(); + uno::Reference<drawing::XShape> xShape(getShapeByName(u"Image3")); + uno::Reference<view::XSelectionSupplier> xCtrl(xModel->getCurrentController(), uno::UNO_QUERY); + xCtrl->select(uno::Any(xShape)); + + dispatchCommand(mxComponent, u".uno:Delete"_ustr, {}); + + pXmlDoc = parseLayoutDump(); + + assertXPath(pXmlDoc, "/root/page[1]/sorted_objs/fly", 0); + assertXPath(pXmlDoc, "/root/page[1]/body/txt/anchored/fly", 0); + assertXPath(pXmlDoc, "/root/page[2]/sorted_objs/fly", 1); + assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/anchored/fly", 1); + assertXPath(pXmlDoc, "/root/page[3]/sorted_objs/fly", 1); + assertXPath(pXmlDoc, "/root/page[3]/body/txt[2]/anchored/fly", 1); + // fly portion exists, no overlapping text + assertXPath(pXmlDoc, "/root/page[3]/body/txt[1]/SwParaPortion/SwLineLayout[1]/SwFixPortion", + "height", u"5797"); + assertXPath(pXmlDoc, "/root/page[4]/sorted_objs/fly", 0); + assertXPath(pXmlDoc, "/root/page[4]/body/txt/anchored/fly", 0); + assertXPath(pXmlDoc, "/root/page", 4); + + dispatchCommand(mxComponent, u".uno:Undo"_ustr, {}); + + pXmlDoc = parseLayoutDump(); + + assertXPath(pXmlDoc, "/root/page[1]/sorted_objs/fly", 1); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/anchored/fly", 1); + assertXPath(pXmlDoc, "/root/page[2]/sorted_objs/fly", 1); + assertXPath(pXmlDoc, "/root/page[2]/body/txt[3]/anchored/fly", 1); + assertXPath(pXmlDoc, "/root/page[3]/sorted_objs/fly", 0); + assertXPath(pXmlDoc, "/root/page[3]/body/txt/anchored/fly", 0); + assertXPath(pXmlDoc, "/root/page[4]/sorted_objs/fly", 1); + assertXPath(pXmlDoc, "/root/page[4]/body/txt[1]/anchored/fly", 1); + // fly portion exists, no overlapping text + assertXPath(pXmlDoc, "/root/page[4]/body/txt[1]/SwParaPortion/SwLineLayout[1]/SwFixPortion", + "height", u"5797"); + assertXPath(pXmlDoc, "/root/page[5]/sorted_objs/fly", 0); + assertXPath(pXmlDoc, "/root/page", 5); + + dispatchCommand(mxComponent, u".uno:Redo"_ustr, {}); + + pXmlDoc = parseLayoutDump(); + + assertXPath(pXmlDoc, "/root/page[1]/sorted_objs/fly", 0); + assertXPath(pXmlDoc, "/root/page[1]/body/txt/anchored/fly", 0); + assertXPath(pXmlDoc, "/root/page[2]/sorted_objs/fly", 1); + assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/anchored/fly", 1); + assertXPath(pXmlDoc, "/root/page[3]/sorted_objs/fly", 1); + assertXPath(pXmlDoc, "/root/page[3]/body/txt[2]/anchored/fly", 1); + // fly portion exists, no overlapping text + assertXPath(pXmlDoc, "/root/page[3]/body/txt[1]/SwParaPortion/SwLineLayout[1]/SwFixPortion", + "height", u"5797"); + assertXPath(pXmlDoc, "/root/page[4]/sorted_objs/fly", 0); + assertXPath(pXmlDoc, "/root/page[4]/body/txt/anchored/fly", 0); + assertXPath(pXmlDoc, "/root/page", 4); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineCharAttributes) { - createDoc("redline_charatr.fodt"); - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc()); + createSwDoc("redline_charatr.fodt"); + SwDoc* pDoc(getSwDoc()); SwRootFrame* pLayout(pDoc->getIDocumentLayoutAccess().GetCurrentLayout()); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); // verify after load CheckRedlineCharAttributesHidden(); - 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", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[2]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[3]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[3]", "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", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[2]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[3]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[3]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[2]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[3]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[3]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/Text[2]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/Text[3]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/Text[3]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/Text[2]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/Text[3]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/Text[3]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/Text[2]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/Text[3]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/Text[3]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/Text[2]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/Text[3]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/Text[3]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/Text[2]", "Portion", "ba"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/Text[3]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/Text[3]", "Portion", "r"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/Text[4]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/Text[4]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/Text[2]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/Text[3]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/Text[3]", "Portion", "baz"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[1]", "Portion", "fo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[2]", "Portion", "o"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[3]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[3]", "Portion", "bar"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[4]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[4]", "Portion", "b"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[5]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/Text[5]", "Portion", "az"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/Text[1]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/Text[1]", "Portion", "foo"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/Text[2]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/Text[2]", "Portion", "b"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/Text[3]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/Text[3]", "Portion", "a"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/Text[4]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/Text[4]", "Portion", "r"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/Text[5]", "nType", "PortionType::Text"); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/Text[5]", "Portion", "baz"); + 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"foo"); + 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"bar"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "portion", u"baz"); + 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"foo"); + 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"bar"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "portion", u"baz"); + 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"foo"); + 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"bar"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "portion", u"baz"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"foo"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"bar"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "portion", u"baz"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"foo"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"bar"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "portion", u"baz"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"foo"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"bar"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "portion", u"baz"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"foo"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"bar"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "portion", u"baz"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"foo"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"ba"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "portion", u"r"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/SwParaPortion/SwLineLayout/SwLinePortion[4]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/SwParaPortion/SwLineLayout/SwLinePortion[4]", + "portion", u"baz"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"foo"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"bar"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "portion", u"baz"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"fo"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"o"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "portion", u"bar"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/SwParaPortion/SwLineLayout/SwLinePortion[4]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/SwParaPortion/SwLineLayout/SwLinePortion[4]", + "portion", u"b"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/SwParaPortion/SwLineLayout/SwLinePortion[5]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/SwParaPortion/SwLineLayout/SwLinePortion[5]", + "portion", u"az"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/SwParaPortion/SwLineLayout/SwLinePortion[1]", + "portion", u"foo"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/SwParaPortion/SwLineLayout/SwLinePortion[2]", + "portion", u"b"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/SwParaPortion/SwLineLayout/SwLinePortion[3]", + "portion", u"a"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/SwParaPortion/SwLineLayout/SwLinePortion[4]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/SwParaPortion/SwLineLayout/SwLinePortion[4]", + "portion", u"r"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/SwParaPortion/SwLineLayout/SwLinePortion[5]", + "type", u"PortionType::Text"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/SwParaPortion/SwLineLayout/SwLinePortion[5]", + "portion", u"baz"); // 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(); + calcLayout(); CheckRedlineCharAttributesHidden(); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineShowHideFootnotePagination) { - createDoc("redline_footnote_pagination.fodt"); - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc()); + createSwDoc("redline_footnote_pagination.fodt"); + SwDoc* pDoc(getSwDoc()); SwRootFrame* pLayout(pDoc->getIDocumentLayoutAccess().GetCurrentLayout()); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); @@ -253,57 +407,111 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineShowHideFootnotePagination) assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn", 6); assertXPath(pXmlDoc, "/root/page[2]/ftncont/ftn", 3); // check that first page ends with the y line and second page starts with z - assertXPath(pXmlDoc, "/root/page[1]/body/txt[last()]/LineBreak[last()]", "Line", - "yyyyyyyyy yyy yyyyyyyyyyyyyyyy yyyyyyy yyy yyyyy yyyyyyyyy yyy yyyyyyyyy "); - assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/LineBreak[1]", "Line", - "zzz. zzz zzzz zzzz7 zzz zzz zzzzzzz zzz zzzz zzzzzzzzzzzzzz zzzzzzzzzzzz "); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[last()]/SwParaPortion/SwLineLayout[last()]", + "portion", + u"yyyyyyyyy yyy yyyyyyyyyyyyyyyy yyyyyyy yyy yyyyy yyyyyyyyy yyy yyyyyyyyy "); + assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "portion", + u"zzz. zzz zzzz zzzz* zzz zzz zzzzzzz zzz zzzz zzzzzzzzzzzzzz zzzzzzzzzzzz "); // hide redlines - all still visible footnotes move to page 1 - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); - discardDumpedLayout(); pXmlDoc = parseLayoutDump(); assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn", 2); assertXPath(pXmlDoc, "/root/page[2]/ftncont/ftn", 0); // show again - should now get the same result as on loading - dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); - discardDumpedLayout(); pXmlDoc = parseLayoutDump(); // check footnotes assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn", 6); assertXPath(pXmlDoc, "/root/page[2]/ftncont/ftn", 3); // check that first page ends with the y line and second page starts with z - assertXPath(pXmlDoc, "/root/page[1]/body/txt[last()]/LineBreak[last()]", "Line", - "yyyyyyyyy yyy yyyyyyyyyyyyyyyy yyyyyyy yyy yyyyy yyyyyyyyy yyy yyyyyyyyy "); - assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/LineBreak[1]", "Line", - "zzz. zzz zzzz zzzz7 zzz zzz zzzzzzz zzz zzzz zzzzzzzzzzzzzz zzzzzzzzzzzz "); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[last()]/SwParaPortion/SwLineLayout[last()]", + "portion", + u"yyyyyyyyy yyy yyyyyyyyyyyyyyyy yyyyyyy yyy yyyyy yyyyyyyyy yyy yyyyyyyyy "); + assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "portion", + u"zzz. zzz zzzz zzzz* zzz zzz zzzzzzz zzz zzzz zzzzzzzzzzzzzz zzzzzzzzzzzz "); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineNumberInNumbering) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testtdf138951) { - SwDoc* pDoc = createDoc("tdf42748.fodt"); - SwDocShell* pShell = pDoc->GetDocShell(); + // Open the bugdoc + createSwDoc("tdf138951.odt"); - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; + // Get the only shape + uno::Reference<drawing::XShape> xShape(getShape(1), uno::UNO_QUERY); + CPPUNIT_ASSERT(xShape); - xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); + // Gather its formats: the shape and textbox + const SwFrameFormat* pTxFrm = SwTextBoxHelper::getOtherTextBoxFormat(xShape); + CPPUNIT_ASSERT(pTxFrm); + const SwFrameFormat* pShFrm = SwTextBoxHelper::getOtherTextBoxFormat(pTxFrm, RES_FLYFRMFMT); + CPPUNIT_ASSERT(pShFrm); - // Assert the tracked deletion of the number of joined list item and - // the tracked insertion of the number after a split list item as not black elements - assertXPath(pXmlDoc, "/metafile/push/push/push/textcolor[not(@color='#000000')]", 6); + calcLayout(); + + // Get the bound rectangle of the textframe + tools::Rectangle aTxtFrmRect(pTxFrm->FindRealSdrObject()->GetLogicRect()); + + // Get the bound rectangle of the shape + tools::Rectangle aShpRect(pShFrm->FindRealSdrObject()->GetLogicRect()); + + // Check the anchor the same and the textbox is inside the shape + const bool bIsAnchTheSame + = *pShFrm->GetAnchor().GetAnchorNode() == *pShFrm->GetAnchor().GetAnchorNode(); + CPPUNIT_ASSERT_MESSAGE("The anchor is different for the textbox and shape!", bIsAnchTheSame); + CPPUNIT_ASSERT_MESSAGE("The textbox has fallen apart!", aShpRect.Contains(aTxtFrmRect)); + // Without the fix the anchor differs, and the frame outside of the shape } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf125300) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf150717) { - SwDoc* pDoc = createDoc("tdf125300.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf150717.odt"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + // check bookmark colors defined in metadata + assertXPath(pXmlDoc, "/root/page/body/txt/SwParaPortion/SwLineLayout/child::*[2]", "colors", + u"#Bookmark1 Bookmark Start"); + assertXPath(pXmlDoc, "/root/page/body/txt/SwParaPortion/SwLineLayout/child::*[4]", "colors", + u"#Bookmark2 Bookmark Start"); + assertXPath(pXmlDoc, "/root/page/body/txt/SwParaPortion/SwLineLayout/child::*[6]", "colors", + u"#Bookmark2 Bookmark End#Bookmark1 Bookmark End"); + // full text, if bookmarks are visible + assertXPath(pXmlDoc, "/root/page/body/txt/SwParaPortion/SwLineLayout/child::*[1]", "portion", + u"Lorem "); + assertXPath(pXmlDoc, "/root/page/body/txt/SwParaPortion/SwLineLayout/child::*[3]", "portion", + u"ipsum dolor et "); + assertXPath(pXmlDoc, "/root/page/body/txt/SwParaPortion/SwLineLayout/child::*[5]", "portion", + u"ames"); + assertXPath(pXmlDoc, "/root/page/body/txt/SwParaPortion/SwLineLayout/child::*[7]", "portion", + u"."); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf150790) +{ + createSwDoc("tdf150790.fodt"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + // point bookmark is shown as I-beam (only its text dump is |, as before on the screen) + assertXPath(pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout/SwBookmarkPortion", + "colors", u"#Bookmark 1 Bookmark"); + // single start bookmark + assertXPath(pXmlDoc, "/root/page/body/txt[2]/SwParaPortion/SwLineLayout/SwBookmarkPortion[1]", + "colors", u"#Bookmark 2 Bookmark Start"); + // single end bookmark + assertXPath(pXmlDoc, "/root/page/body/txt[2]/SwParaPortion/SwLineLayout/SwBookmarkPortion[3]", + "colors", u"#Bookmark 3 Bookmark End"); + // This was |, as before the point bookmark (neighboring end and start bookmarks) + assertXPath(pXmlDoc, "/root/page/body/txt[2]/SwParaPortion/SwLineLayout/SwBookmarkPortion[2]", + "colors", u"#Bookmark 2 Bookmark End#Bookmark 3 Bookmark Start"); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf129357) +{ + createSwDoc("tdf129357.fodt"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); @@ -312,449 +520,749 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf125300) xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - // Keep line spacing before bottom cell border (it was 1892) - sal_Int32 y1 - = getXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[5]/polyline/point[1]", "y") - .toInt32(); - sal_Int32 y2 - = getXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[5]/polyline/point[2]", "y") - .toInt32(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2092, y1, 7); - CPPUNIT_ASSERT_EQUAL(y1, y2); + // visible soft hyphen + assertXPathContent(pXmlDoc, "/metafile/push/push/push/push/push/textarray[2]/text", u"-"); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf116830) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf165322) { - SwDoc* pDoc = createDoc("tdf116830.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("CT-formatted-deletion.docx"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); MetafileXmlDump dumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - // Assert that the yellow rectangle (cell background) is painted after the - // polypolygon (background shape). - // Background shape: 1.1.1.2 - // Cell background: 1.1.1.3 - assertXPath( - pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[2]/push[1]/push[1]/fillcolor[@color='#729fcf']", 1); - assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[2]/push[1]/push[1]/polypolygon", - 1); - - // This failed: cell background was painted before the background shape. + // paragraph with 2 redlines was not marked as deleted assertXPath(pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/fillcolor[@color='#ffff00']", 1); - assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/rect", 1); + "//text[text() = 'Nunc viverra imperdiet enim. Fusce est. Vivamus a " + "tellus.']/parent::textarray/preceding-sibling::font[1]", + "strikeout", u"1"); + + // Also check if the tooltip shows the delete, not the format + // Given a paragraph with both delete and format: + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + SwRootFrame* pLayout = pWrtShell->GetLayout(); + SwFrame* pPage = pLayout->GetLower(); + SwFrame* pBody = pPage->GetLower(); + SwFrame* pPara = pBody->GetLower()->GetNext(); + // When getting the content at a position for tooltip purposes: + Point aPoint = pPara->getFrameArea().Center(); + SwContentAtPos aContentAtPos(IsAttrAtPos::Redline); + CPPUNIT_ASSERT(pWrtShell->GetContentAtPos(aPoint, aContentAtPos)); + // Then make sure we find a delete redline: + CPPUNIT_ASSERT_EQUAL(IsAttrAtPos::Redline, aContentAtPos.eContentAtPos); + const SwRangeRedline* pRedline = aContentAtPos.aFnd.pRedl; + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 (RedlineType::Delete) + // - Actual : 5 (RedlineType::ParagraphFormat) + // i.e. the delete didn't have priority over para format, leading to a misleading tooltip. + CPPUNIT_ASSERT_EQUAL(RedlineType::Delete, pRedline->GetType()); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf114163) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineNumberInNumbering) { - SwDoc* pDoc = createDoc("tdf114163.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf42748.fodt"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); MetafileXmlDump dumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - assertXPathContent( + // Assert the tracked deletion of the number of joined list item and + // the tracked insertion of the number after a split list item as not black + // (and not COL_GREEN color of the tracked text movement, see testRedlineMoving) elements + assertXPath( pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/textarray[12]/text", - "Data3"); - // This failed, if the legend first label is not "Data3". The legend position is right. -} + "/metafile/push/push/push/textcolor[not(@color='#000000') and not(@color='#008000')]", 5); -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf131707) -{ - createDoc("tdf131707_flyWrap.doc"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - - assertXPath(pXmlDoc, "//body/tab/row[3]/cell[2]/txt/infos/bounds", "top", "2185"); - // the image should be inside of the cell boundary - so the same top or higher - assertXPath(pXmlDoc, "//body/tab/row[3]/cell[2]/txt/anchored/fly/infos/bounds", "top", "2185"); + // tdf#145068 numbering shows changes in the associated list item, not the next one + // This was 1 (black numbering of the first list item previously) + assertXPath(pXmlDoc, "/metafile/push/push/push/font[4][@color='#000000']", 0); } -#if HAVE_MORE_FONTS -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf122225) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineNumbering) { - SwDoc* pDoc = createDoc("tdf122225.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf115523.fodt"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); MetafileXmlDump dumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - assertXPathContent(pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray[8]/text", - "Advanced Diploma"); - // This failed, if the legend label is not "Advanced Diploma". + // Show the correct and the original line numbering instead of counting + // the deleted list items in Show Changes mode, as part of the list + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[1]/text", u"1."); + // This was "2." (deleted text node, now its text content is part of the first list item) + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[3]/text", u"[2.] "); + // This was "3." (now it's the second list item) + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[5]/text", u"2.[3.] "); } -#endif -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf125335) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineNumbering2) { - SwDoc* pDoc = createDoc("tdf125335.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf115524.fodt"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); MetafileXmlDump dumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - assertXPathContent( - pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/textarray[12]/text", - "Data3"); - // This failed, if the legend first label is not "Data3". The legend position is bottom. + // Show the correct and the original line numbering in Show Changes mode + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[1]/text", u"1."); + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[3]/text", u"2."); + // FIXME: show as 3.[2.] + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[5]/text", u"3."); + // This was "4." (not shown the original number) + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[7]/text", u"4.[3.] "); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf134247) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, tdf157596_paragraph_numbering) { - SwDoc* pDoc = createDoc("legend-itemorder-min.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); + createSwDoc("tdf157596_paragraph_numbering.docx"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - assertXPathContent(pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray[14]/text", - "1. adatsor"); - // This failed, if the legend first label is not "1. adatsor". + // show correct numbering during fileload. + assertXPath(pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion", + "expand", u"1."); + assertXPath(pXmlDoc, "/root/page/body/txt[2]/SwParaPortion/SwLineLayout/SwFieldPortion", + "expand", u"2."); + assertXPath(pXmlDoc, "/root/page/body/txt[3]/SwParaPortion/SwLineLayout/SwFieldPortion", + "expand", u"3."); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf75659) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf149710_RedlineNumberingEditing) { - SwDoc* pDoc = createDoc("tdf75659.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf149710.fodt"); + + // Show Changes + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + SwRootFrame* pLayout(pWrtShell->GetLayout()); + CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); + + // delete the paragraph mark of the first list item with change tracking + dispatchCommand(mxComponent, u".uno:GoToEndOfLine"_ustr, {}); + dispatchCommand(mxComponent, u".uno:TrackChanges"_ustr, {}); + dispatchCommand(mxComponent, u".uno:Delete"_ustr, {}); // Dump the rendering of the first page as an XML file. + SwDocShell* pShell = getSwDocShell(); std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); MetafileXmlDump dumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - assertXPathContent( - pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray[17]/text", "Series1"); + // Show the correct and the original line numbering instead of counting + // the deleted list items in Show Changes mode, as part of the list + // This was "1." + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[1]/text", u"[1.] "); + // This was "2." (deleted text node, now its text content is part of the first list item) + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[3]/text", u"1.[2.] "); + // This was "3." (now it's the second list item) + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[5]/text", u"2.[3.] "); - assertXPathContent( - pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray[18]/text", "Series2"); - - assertXPathContent( - pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray[19]/text", "Series3"); - // These failed, if the legend names are empty strings. + // remove the tracked deletion, and check the layout again + pWrtShell->Undo(); + xMetaFile = pShell->GetPreviewMetaFile(); + pXmlDoc = dumpAndParse(dumper, *xMetaFile); + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[1]/text", u"1."); + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[3]/text", u"2."); + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[5]/text", u"3."); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf136816) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf149709_RedlineNumberingLevel) { - SwDoc* pDoc = createDoc("tdf136816.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); + createSwDoc("tdf149709.fodt"); - // Check number of legend entries - assertXPath(pXmlDoc, "//text[contains(text(),\"Column\")]", 2); -} + // Show Changes + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + SwRootFrame* pLayout(pWrtShell->GetLayout()); + CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf126425) -{ - SwDoc* pDoc = createDoc("long_legendentry.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + // insert a new list item at start of the second list item "a)" + dispatchCommand(mxComponent, u".uno:TrackChanges"_ustr, {}); + pWrtShell->Down(false, 1); + pWrtShell->SplitNode(false); // Dump the rendering of the first page as an XML file. + SwDocShell* pShell = getSwDocShell(); std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); MetafileXmlDump dumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 14 - // - Actual : 12 - // i.e. the text of the chart legend lost. - assertXPath(pXmlDoc, "//textarray", 14); -} -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf123268) -{ - SwDoc* pDoc = createDoc("tdf123268.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); + // Show the correct and the original line numbering instead of counting + // the deleted list items in Show Changes mode, as part of the list + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[1]/text", u"1."); + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[3]/text", u"a)"); + // This was "b)[2.]" + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[4]/text", u"b)[a)] "); + // This was "c)[3.]" + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[6]/text", u"c)[b)] "); + // This was "4.[2.]" (after disabling Show Changes, and enabling again) + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[8]/text", u"2."); + + // remove the tracked deletion, and check the layout again + pWrtShell->Undo(); + xMetaFile = pShell->GetPreviewMetaFile(); + pXmlDoc = dumpAndParse(dumper, *xMetaFile); + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[1]/text", u"1."); + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[3]/text", u"a)"); + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[5]/text", u"b)"); + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[7]/text", u"2."); + + // check Redo + pWrtShell->Redo(); + xMetaFile = pShell->GetPreviewMetaFile(); + pXmlDoc = dumpAndParse(dumper, *xMetaFile); + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[1]/text", u"1."); + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[3]/text", u"a)"); + // TODO: show as b)[a)] + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[4]/text", u"b)"); + // FIXME: This must be "c)[b]" + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[6]/text", u"c)[a)] "); + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[8]/text", u"2."); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf149711_importDOCXMoveToParagraphMark) +{ + createSwDoc("tdf149711.docx"); + SwDoc* pDoc = getSwDoc(); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page[1]/body/txt", 6); - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 41 - // - Actual : 0 - // i.e. the chart lost. - assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/push", - 41); + // reject tracked insertion (moveTo) + SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); + CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(2), pEditShell->GetRedlineCount()); + pEditShell->RejectRedline(1); + + pXmlDoc = parseLayoutDump(); + // This was 6 (not tracked paragraph mark of the moveTo list item) + assertXPath(pXmlDoc, "/root/page[1]/body/txt", 5); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf133005) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf152872) { - SwDoc* pDoc = createDoc("tdf133005.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("hidden-para-separator.docx"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/root/page[1]/body/txt", 2); + assertXPath(pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout", "portion", u"C DE"); + // 5 is empty and hidden + assertXPath(pXmlDoc, "/root/page/body/txt[2]/infos/bounds", "height", u"0"); - sal_Int32 nXChartWall = getXPath(pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/" - "push[1]/push[1]/polyline[1]/point[2]", - "x") - .toInt32(); - sal_Int32 nXColumn = getXPath(pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/" - "push[1]/push[42]/polypolygon/polygon/point[1]", - "x") - .toInt32(); + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + SwViewOption aViewOptions(*pWrtShell->GetViewOptions()); + aViewOptions.SetShowHiddenChar(true); + aViewOptions.SetViewMetaChars(true); + pWrtShell->ApplyViewOptions(aViewOptions); - // This failed, if the value axis doesn't appear inside category. - CPPUNIT_ASSERT_DOUBLES_EQUAL(nXChartWall, nXColumn, 5); -} + pXmlDoc = parseLayoutDump(); -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf115630) -{ - SwDoc* pDoc = createDoc("tdf115630.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + assertXPath(pXmlDoc, "/root/page[1]/body/txt", 5); + assertXPath(pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout", "portion", u"C "); + assertXPath(pXmlDoc, "/root/page/body/txt[2]/SwParaPortion/SwLineLayout", "portion", u"D"); + // 3 is an empty paragraph with RES_CHRATR_HIDDEN + assertXPath(pXmlDoc, "/root/page/body/txt[3]/infos/bounds", "height", u"398"); + assertXPath(pXmlDoc, "/root/page/body/txt[4]/SwParaPortion/SwLineLayout", "portion", u"E"); + // 5 is an empty paragraph with RES_CHRATR_HIDDEN + assertXPath(pXmlDoc, "/root/page/body/txt[5]/infos/bounds", "height", u"398"); - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); + aViewOptions.SetViewMetaChars(false); + pWrtShell->ApplyViewOptions(aViewOptions); - // Test wide of inner chart area. - sal_Int32 nXRight - = getXPath(pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/push[3]/polyline[1]/point[1]", - "x") - .toInt32(); - sal_Int32 nXLeft - = getXPath(pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/push[3]/polyline[1]/point[2]", - "x") - .toInt32(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2895, nXRight - nXLeft, 50); + pXmlDoc = parseLayoutDump(); + + assertXPath(pXmlDoc, "/root/page[1]/body/txt", 2); + assertXPath(pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout", "portion", u"C DE"); + // 5 is empty and hidden + assertXPath(pXmlDoc, "/root/page/body/txt[2]/infos/bounds", "height", u"0"); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf108021) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testHiddenParaBreaks) { - SwDoc* pDoc = createDoc("tdf108021.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("section-break-hidden-paragraphs.rtf"); - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + SwViewOption aViewOptions(*pWrtShell->GetViewOptions()); + aViewOptions.SetShowHiddenChar(true); + aViewOptions.SetViewMetaChars(true); + pWrtShell->ApplyViewOptions(aViewOptions); + Scheduler::ProcessEventsToIdle(); - assertXPath( - pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/textarray[@length='22']", - 8); - // This failed, if the textarray length of the first axis label not 22. -} + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf125334) -{ - SwDoc* pDoc = createDoc("tdf125334.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); + assertXPath(pXmlDoc, "/root/page[1]/body/txt", 1); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout", "portion", + u"First"); + // actually Word shows an additional paragraph before the table + assertXPath(pXmlDoc, "/root/page[2]/body/txt", 3); + assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/SwParaPortion/SwLineLayout", "portion", u""); + assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/infos/bounds", "top", u"18846"); + assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/infos/bounds", "height", u"269"); + assertXPath(pXmlDoc, "/root/page[2]/body/txt[2]/infos/bounds", "top", u"19115"); + assertXPath(pXmlDoc, "/root/page[2]/body/txt[2]/infos/bounds", "height", u"450"); + assertXPath(pXmlDoc, "/root/page[2]/body/tab[1]/infos/bounds", "top", u"19565"); + assertXPath(pXmlDoc, "/root/page[2]/body/txt[3]/SwParaPortion/SwLineLayout", "portion", u"End"); + + aViewOptions.SetViewMetaChars(false); + pWrtShell->ApplyViewOptions(aViewOptions); + Scheduler::ProcessEventsToIdle(); - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); + pXmlDoc = parseLayoutDump(); - assertXPath( - pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/textarray[@length='17']", - 4); - // This failed, if the textarray length of the category axis label not 17. + assertXPath(pXmlDoc, "/root/page[1]/body/txt", 1); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout", "portion", + u"First"); + assertXPath(pXmlDoc, "/root/page[2]/body/txt", 2); + // this one is merged; if it were 2 0-height frames that would work too + assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/infos/bounds", "top", u"18846"); + assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/infos/bounds", "height", u"0"); + assertXPath(pXmlDoc, "/root/page[2]/body/tab[1]/infos/bounds", "top", u"18846"); + assertXPath(pXmlDoc, "/root/page[2]/body/txt[2]/SwParaPortion/SwLineLayout", "portion", u"End"); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf122800) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testHiddenParaLineHeight) { - SwDoc* pDoc = createDoc("tdf122800.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("merge_hidden_redline_lineheight.rtf"); - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + SwViewOption aViewOptions(*pWrtShell->GetViewOptions()); + aViewOptions.SetShowHiddenChar(true); + aViewOptions.SetViewMetaChars(true); + pWrtShell->ApplyViewOptions(aViewOptions); - assertXPath( - pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/textarray[@length='22']", - 9); - // This failed, if the textarray length of the first axis label not 22. + { + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/infos/bounds", "height", u"269"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/infos/bounds", "height", u"767"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/infos/bounds", "height", u"475"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/infos/bounds", "height", u"450"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/infos/bounds", "height", u"450"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/infos/bounds", "height", u"767"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/infos/bounds", "height", u"475"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/infos/bounds", "height", u"767"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/infos/bounds", "height", u"475"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/infos/bounds", "height", u"450"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/infos/bounds", "height", u"767"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[12]/infos/bounds", "height", u"475"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[13]/infos/bounds", "height", u"450"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[14]/infos/bounds", "height", u"450"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[15]/infos/bounds", "height", u"767"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[16]/infos/bounds", "height", u"475"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[17]/infos/bounds", "height", u"450"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[18]/infos/bounds", "height", u"767"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[19]/infos/bounds", "height", u"475"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[20]/infos/bounds", "height", u"767"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[21]/infos/bounds", "height", u"475"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[22]/infos/bounds", "height", u"450"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[23]/infos/bounds", "height", u"450"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[24]/infos/bounds", "height", u"767"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[25]/infos/bounds", "height", u"475"); + } + + aViewOptions.SetShowHiddenChar(false); + pWrtShell->ApplyViewOptions(aViewOptions); + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); + + { + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/infos/bounds", "height", u"269"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/infos/bounds", "height", u"450"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/infos/bounds", "height", u"450"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/infos/bounds", "height", u"767"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[5]/infos/bounds", "height", u"475"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/infos/bounds", "height", u"450"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[7]/infos/bounds", "height", u"475"); + // 4: this was using wrong node's character properties (height 767) + assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/infos/bounds", "height", u"450"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/infos/bounds", "height", u"475"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[10]/infos/bounds", "height", u"767"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[11]/infos/bounds", "height", u"475"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[12]/infos/bounds", "height", u"450"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[13]/infos/bounds", "height", u"475"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[14]/infos/bounds", "height", u"450"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[15]/infos/bounds", "height", u"450"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[16]/infos/bounds", "height", u"767"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[17]/infos/bounds", "height", u"475"); + } } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTruncatedAxisLabel) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testHiddenParaProps) { - SwDoc* pDoc = createDoc("testTruncatedAxisLabel.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("merge_hidden_redline.docx"); - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + SwViewOption aViewOptions(*pWrtShell->GetViewOptions()); + aViewOptions.SetShowHiddenChar(true); + aViewOptions.SetViewMetaChars(true); + pWrtShell->ApplyViewOptions(aViewOptions); - // test the X axis label visibility - assertXPathContent( - pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/textarray[1]/text", - "Long axis label truncated 1"); + // note: do not use layout dump here, because it doesn't work: + // SwTextFrame::Format doesn't actually create the SwMarginPortion for + // non-left-aligned frames; instead, it sets SetFormatAdj() flag and later + // *SwTextPainter* checks via GetAdjusted() if the flag is set and calls + // CalcAdjLine() which inserts the SwMarginPortion. - // test the Y axis label visibility - assertXPathContent( - pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/textarray[3]/text", - "-5.00"); + SwRootFrame* pRoot = pWrtShell->GetLayout(); + CPPUNIT_ASSERT(pRoot->GetLower()->IsPageFrame()); + SwPageFrame* pPage = static_cast<SwPageFrame*>(pRoot->GetLower()); + CPPUNIT_ASSERT(pPage->GetLower()->IsBodyFrame()); + SwBodyFrame* pBody = static_cast<SwBodyFrame*>(pPage->GetLower()); + CPPUNIT_ASSERT(pBody->GetLower()->IsTextFrame()); + SwTextFrame* pTextFrame = dynamic_cast<SwTextFrame*>(pBody->GetLower()); + + CPPUNIT_ASSERT_EQUAL(u"1 hidden, delete-merge"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + // TODO: redlines don't merge like in Word yet + CPPUNIT_ASSERT_EQUAL(u"Abcdef"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"ghi"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"2 visible, delete-merge"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"abcghi"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"def"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"3 delete-merge"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"def"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"ghi"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"4 delete-merge, delete-merge"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"abc"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"def"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u""_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"5 visible, hidden-merge, visible"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"abc"_ustr, pTextFrame->GetText()); + CPPUNIT_ASSERT_EQUAL( + SvxAdjust::Center, + pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"def"_ustr, pTextFrame->GetText()); + CPPUNIT_ASSERT_EQUAL( + SvxAdjust::Left, + pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"6 hidden-merge, visible"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"abc"_ustr, pTextFrame->GetText()); + CPPUNIT_ASSERT_EQUAL( + SvxAdjust::Center, + pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"def"_ustr, pTextFrame->GetText()); + CPPUNIT_ASSERT_EQUAL( + SvxAdjust::Left, + pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"7 visible, hidden-merge"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"abcdef"_ustr, pTextFrame->GetText()); + CPPUNIT_ASSERT_EQUAL( + SvxAdjust::Center, + pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"ghi"_ustr, pTextFrame->GetText()); + CPPUNIT_ASSERT_EQUAL( + SvxAdjust::Left, + pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"8 visible, delete-merge, visible, hidden-merge, visible"_ustr, + pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"abc"_ustr, pTextFrame->GetText()); + CPPUNIT_ASSERT_EQUAL( + SvxAdjust::Right, + pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"def"_ustr, pTextFrame->GetText()); + CPPUNIT_ASSERT_EQUAL( + SvxAdjust::Center, + pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"ghi"_ustr, pTextFrame->GetText()); + CPPUNIT_ASSERT_EQUAL( + SvxAdjust::Left, + pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"9 hidden-merge"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"abc"_ustr, pTextFrame->GetText()); + CPPUNIT_ASSERT_EQUAL( + SvxAdjust::Center, + pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"def"_ustr, pTextFrame->GetText()); + CPPUNIT_ASSERT_EQUAL( + SvxAdjust::Left, + pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"10 visible, hidden-merge, visible, delete-merge, visible"_ustr, + pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"abc"_ustr, pTextFrame->GetText()); + CPPUNIT_ASSERT_EQUAL( + SvxAdjust::Right, + pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"def"_ustr, pTextFrame->GetText()); + CPPUNIT_ASSERT_EQUAL( + SvxAdjust::Center, + pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"ghi"_ustr, pTextFrame->GetText()); + CPPUNIT_ASSERT_EQUAL( + SvxAdjust::Left, + pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); + + aViewOptions.SetShowHiddenChar(false); + pWrtShell->ApplyViewOptions(aViewOptions); + + // the problem was that the wrong SwTextNode was used for properties + pTextFrame = dynamic_cast<SwTextFrame*>(pBody->GetLower()); + CPPUNIT_ASSERT_EQUAL(u"1 hidden, delete-merge"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + // TODO: redlines don't merge like in Word yet + CPPUNIT_ASSERT_EQUAL(u"Abcdef"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"ghi"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"2 visible, delete-merge"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"abcghi"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"def"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"3 delete-merge"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"def"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"ghi"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"4 delete-merge, delete-merge"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"abc"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"def"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u""_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"5 visible, hidden-merge, visible"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"abcdef"_ustr, pTextFrame->GetText()); + CPPUNIT_ASSERT_EQUAL( + SvxAdjust::Center, + pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"6 hidden-merge, visible"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"abcdef"_ustr, pTextFrame->GetText()); + CPPUNIT_ASSERT_EQUAL( + SvxAdjust::Left, + pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"7 visible, hidden-merge"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"abcdefghi"_ustr, pTextFrame->GetText()); + CPPUNIT_ASSERT_EQUAL( + SvxAdjust::Center, + pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"8 visible, delete-merge, visible, hidden-merge, visible"_ustr, + pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"abc"_ustr, pTextFrame->GetText()); + CPPUNIT_ASSERT_EQUAL( + SvxAdjust::Right, + pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"defghi"_ustr, pTextFrame->GetText()); + CPPUNIT_ASSERT_EQUAL( + SvxAdjust::Center, + pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"9 hidden-merge"_ustr, pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"abcdef"_ustr, pTextFrame->GetText()); + CPPUNIT_ASSERT_EQUAL( + SvxAdjust::Left, + pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"10 visible, hidden-merge, visible, delete-merge, visible"_ustr, + pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"abcdef"_ustr, pTextFrame->GetText()); + CPPUNIT_ASSERT_EQUAL( + SvxAdjust::Right, + pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"ghi"_ustr, pTextFrame->GetText()); + CPPUNIT_ASSERT_EQUAL( + SvxAdjust::Left, + pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); + + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); + + pTextFrame = dynamic_cast<SwTextFrame*>(pBody->GetLower()); + for (int i = 0; i < 18; ++i) + { + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + } + // the problem was that this redline (following hidden) wasn't merged + CPPUNIT_ASSERT_EQUAL(u"10 visible, hidden-merge, visible, delete-merge, visible"_ustr, + pTextFrame->GetText()); + pTextFrame = dynamic_cast<SwTextFrame*>(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"abcdefghi"_ustr, pTextFrame->GetText()); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf128996) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf151954) { - SwDoc* pDoc = createDoc("tdf128996.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf151954.docx"); + SwDoc* pDoc = getSwDoc(); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page[1]/body/txt", 2); - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); + // accept tracked insertion (moveTo) + SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); + CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(3), pEditShell->GetRedlineCount()); + pEditShell->AcceptRedline(0); - assertXPathContent(pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray[1]/text", - "A very long category name 1"); + pXmlDoc = parseLayoutDump(); + // This was 1 (moveFrom was extended to the paragraph mark) + assertXPath(pXmlDoc, "/root/page[1]/body/txt", 2); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf126244) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf152952) { - SwDoc* pDoc = createDoc("tdf126244.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); - - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - // Test the first level of vertical category axis labels orientation. The first level orientation should be horizontal. - assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/font[1]", "orientation", - "0"); - // Test the second level of vertical category axis labels orientation. The second level orientation should be vertical. - sal_Int32 nRotation - = getXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/font[5]", - "orientation") - .toInt32(); - CPPUNIT_ASSERT(nRotation >= 899 && nRotation <= 900); - // Test the third level of vertical category axis labels orientation. The third level orientation should be vertical. - nRotation = getXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/font[7]", - "orientation") - .toInt32(); - CPPUNIT_ASSERT(nRotation >= 899 && nRotation <= 900); + createSwDoc("Hyphenated-link.rtf"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + // URL should not be hyphenated + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "portion", + u" NNNNNNNNNN NNNNNNNNNNNNNNN "); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[2]", "portion", + u"https://example.com/xxxxxxx/testtesttesttest/hyphenate/testtesttest "); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf127304) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf152952_compat) { - SwDoc* pDoc = createDoc("tdf127304.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); + uno::Reference<linguistic2::XHyphenator> xHyphenator = LinguMgr::GetHyphenator(); + if (!xHyphenator->hasLocale(lang::Locale(u"en"_ustr, u"US"_ustr, OUString()))) + return; - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - // Test the first level of horizontal category axis labels orientation. The first level orientation should be vertical. - sal_Int32 nRotation - = getXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/font[1]", - "orientation") - .toInt32(); - CPPUNIT_ASSERT(nRotation >= 899 && nRotation <= 900); - // Test the second level of horizontal category axis labels orientation. The second level orientation should be horizontal. - assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/font[5]", "orientation", - "0"); - // Test the third level of horizontal category axis labels orientation. The third level orientation should be horizontal. - assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/font[7]", "orientation", - "0"); + createSwDoc("Hyphenated-link.fodt"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + // URL hyphenated for backward compatibility + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "portion", + u" NNNNNNNNNN NNNNNNNNNNNNNNN https://example.com/xxxxxxx/testtesttesttest/hyphen"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[2]", "portion", + u"ate/testtesttest "); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testHorizontal_multilevel) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf158885_compound_remain) { - SwDoc* pDoc = createDoc("horizontal_multilevel.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); + uno::Reference<linguistic2::XHyphenator> xHyphenator = LinguMgr::GetHyphenator(); + if (!xHyphenator->hasLocale(lang::Locale(u"hu"_ustr, u"HU"_ustr, OUString()))) + return; - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - // Test the Y position of horizontal category axis label. - sal_Int32 nYposition - = getXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/textarray[7]", "y") - .toInt32(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7945, nYposition, 20); + uno::Reference<linguistic2::XSpellChecker1> xSpell = LinguMgr::GetSpellChecker(); + LanguageType eLang + = LanguageTag::convertToLanguageType(lang::Locale(u"hu"_ustr, u"HU"_ustr, OUString())); + if (!xSpell.is() || !xSpell->hasLanguage(static_cast<sal_uInt16>(eLang))) + return; + + createSwDoc("tdf158885_compound-remain.fodt"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + // hyphenate compound word with 3- or more character distance from the stem boundary + // This was "emberel=lenes" (now "ember=ellenes", i.e. hyphenating at the stem boundary) + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "portion", + u"emberellenes emberellenes emberellenes emberellenes emberellenes ember"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[2]", "portion", + u"ellenes emberellenes emberellenes emberellenes emberellenes emberellenes "); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf138194) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf158885_not_compound_remain) { - SwDoc* pDoc = createDoc("xaxis-labelbreak.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + uno::Reference<linguistic2::XHyphenator> xHyphenator = LinguMgr::GetHyphenator(); + if (!xHyphenator->hasLocale(lang::Locale(u"hu"_ustr, u"HU"_ustr, OUString()))) + return; - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 8 - // - Actual : 7 - // i.e. the X axis label flowed out of chart area. - assertXPath(pXmlDoc, "//textarray", 8); + uno::Reference<linguistic2::XSpellChecker1> xSpell = LinguMgr::GetSpellChecker(); + LanguageType eLang + = LanguageTag::convertToLanguageType(lang::Locale(u"hu"_ustr, u"HU"_ustr, OUString())); + if (!xSpell.is() || !xSpell->hasLanguage(static_cast<sal_uInt16>(eLang))) + return; + + createSwDoc("tdf158885_not_compound-remain.fodt"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + // hyphenate compound word with 2-character distance from the stem boundary, + // resulting less readable hyphenation "emberel=lenes" ("emberel" and "lenes" have + // different meanings, than the original word parts) + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "portion", + u"emberellenes emberellenes emberellenes emberellenes emberellenes emberel"); + assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout[2]", "portion", + u"lenes emberellenes emberellenes emberellenes emberellenes emberellenes "); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf138773) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineNumberInFootnote) { - SwDoc* pDoc = createDoc("tdf138773.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf85610.fodt"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); MetafileXmlDump dumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - const sal_Int32 nFirstLabelLines - = getXPathContent(pXmlDoc, "count(//text[contains(text(),\"2000-01\")])").toInt32(); - - // This failed, if the first X axis label broke to multiple lines. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), nFirstLabelLines); + // changed color of numbers of footnote 1 (deleted footnote) and footnote 2 (inserted footnote) + // decreased the black <font> elements by 2: + // This was 7 + assertXPath(pXmlDoc, "/metafile/push/push/push/font[@color='#000000']", 5); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf124796) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineMoving) { - SwDoc* pDoc = createDoc("tdf124796.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf42748.fodt"); + SwDoc* pDoc = getSwDoc(); + SwDocShell* pShell = getSwDocShell(); + + // create a 3-element list without change tracking + SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); + pEditShell->RejectRedline(0); + pEditShell->AcceptRedline(0); + + // move down first list item with track changes + dispatchCommand(mxComponent, u".uno:GoToStartOfDoc"_ustr, {}); + dispatchCommand(mxComponent, u".uno:TrackChanges"_ustr, {}); + dispatchCommand(mxComponent, u".uno:MoveDown"_ustr, {}); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); @@ -762,39 +1270,34 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf124796) xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - // This failed, if the minimum value of Y axis is not -10. - assertXPathContent( - pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/textarray[5]/text", - "-10"); - - // This failed, if the maximum value of Y axis is not 15. - assertXPathContent( - pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/textarray[10]/text", - "15"); + // text and numbering colors show moving of the list item + // tdf#157663: the moved text item "It" is detected as text moving again! + assertXPath(pXmlDoc, "/metafile/push/push/push/textcolor[@color='#008000']", 5); + assertXPath(pXmlDoc, "/metafile/push/push/push/font[@color='#008000']", 11); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf130969) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineMoving2) { - SwDoc* pDoc = createDoc("tdf130969.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf42748.fodt"); + SwDoc* pDoc = getSwDoc(); + SwDocShell* pShell = getSwDocShell(); - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); + // create a 3-element list without change tracking + SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); + pEditShell->RejectRedline(0); + pEditShell->AcceptRedline(0); - // This failed, if the minimum value of Y axis is not 0.35781 - assertXPathContent( - pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray[5]/text", "0.35781"); -} + // extend the first item to "An ItemIt", because detection of move needs + // at least 6 characters with an inner space after stripping white spaces + // of the redline + dispatchCommand(mxComponent, u".uno:GoToStartOfDoc"_ustr, {}); + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + pWrtShell->Insert(u"An Item"_ustr); -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf129054) -{ - SwDoc* pDoc = createDoc("tdf129054.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + // move down first list item with track changes + dispatchCommand(mxComponent, u".uno:TrackChanges"_ustr, {}); + dispatchCommand(mxComponent, u".uno:MoveDown"_ustr, {}); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); @@ -802,25 +1305,22 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf129054) xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - // Test the size of diameter of Pie chart. - sal_Int32 nYTop - = getXPath(pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/push[4]/polyline[1]/point[1]", - "y") - .toInt32(); - sal_Int32 nYBottom - = getXPath( - pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/push[4]/polyline[1]/point[31]", - "y") - .toInt32(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(4810, nYTop - nYBottom, 5); + // text and numbering colors show moving of the list item + // These were 0 (other color, not COL_GREEN, color of the tracked text movement) + assertXPath(pXmlDoc, "/metafile/push/push/push/textcolor[@color='#008000']", 5); + assertXPath(pXmlDoc, "/metafile/push/push/push/font[@color='#008000']", 11); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf129173) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineMovingDOCX) { - SwDoc* pDoc = createDoc("testAreaChartNumberFormat.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf104797.docx"); + SwDoc* pDoc = getSwDoc(); + SwDocShell* pShell = getSwDocShell(); + + SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); + // This was 2 (moveFrom and moveTo joined other redlines) + CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(5), pEditShell->GetRedlineCount()); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); @@ -828,15 +1328,55 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf129173) xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - // Check the first data label of area chart. - assertXPathContent( - pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray[22]/text", "56"); + // text colors show moved text + // These were 0 (other color, not COL_GREEN, color of the tracked text movement) + assertXPath(pXmlDoc, "/metafile/push/push/push/textcolor[@color='#008000']", 6); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf134866) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTableCellInvalidate) { - SwDoc* pDoc = createDoc("tdf134866.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + // note: must set Hidden property, so that SfxFrameViewWindow_Impl::Resize() + // does *not* forward initial VCL Window Resize and thereby triggers a + // layout which does not happen on soffice --convert-to pdf. + std::vector<beans::PropertyValue> aFilterOptions = { + { beans::PropertyValue(u"Hidden"_ustr, -1, uno::Any(true), + beans::PropertyState_DIRECT_VALUE) }, + }; + + // inline the loading because currently properties can't be passed... + OUString const url(createFileURL(u"table_cell_overlap.fodt")); + loadWithParams(url, comphelper::containerToSequence(aFilterOptions)); + save(u"writer_pdf_Export"_ustr); + + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + // somehow these 2 rows overlapped in the PDF unless CalcLayout() runs + assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[1]/infos/bounds", "top", u"6969"); + assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[1]/infos/bounds", "height", u"231"); + assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[1]/cell[1]/infos/bounds", "top", + u"6969"); + assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[1]/cell[1]/infos/bounds", "height", + u"231"); + assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[1]/cell[1]/txt[1]/infos/bounds", + "top", u"6969"); + assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[1]/cell[1]/txt[1]/infos/bounds", + "height", u"231"); + assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[2]/infos/bounds", "top", u"7200"); + assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[2]/infos/bounds", "height", u"231"); + // this was 6969, causing the overlap + assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[2]/cell[1]/infos/bounds", "top", + u"7200"); + assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[2]/cell[1]/infos/bounds", "height", + u"231"); + assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[2]/cell[1]/txt[1]/infos/bounds", + "top", u"7200"); + assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[2]/cell[1]/txt[1]/infos/bounds", + "height", u"231"); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf145719) +{ + createSwDoc("tdf145719.odt"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); @@ -844,119 +1384,168 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf134866) xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - // Check the data label of pie chart. - assertXPathContent( - pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray[2]/text", "100%"); + // text colors show moved text + // This was 0 (other color, not COL_GREEN, color of the tracked text movement) + assertXPath(pXmlDoc, "/metafile/push/push/push/textcolor[@color='#008000']", 4); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf137116) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testChangedTableRows) { - SwDoc* pDoc = createDoc("tdf137116.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("changed_table_rows.fodt"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); MetafileXmlDump dumper; xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - sal_Int32 nX2 = getXPath(pXmlDoc, "//textarray[2]", "x").toInt32(); // second data label - sal_Int32 nX4 = getXPath(pXmlDoc, "//textarray[4]", "x").toInt32(); // fourth data label - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 694 - // - Actual : -225 - // - Delta : 100 - // i.e. the second data label appeared inside the pie slice. - CPPUNIT_ASSERT_DOUBLES_EQUAL(694, nX2 - nX4, 100); + + // This was 0 (other color, not COL_AUTHOR_TABLE_DEL, color of the tracked row deletion) + assertXPath(pXmlDoc, "/metafile/push/push/push/push/push/fillcolor[@color='#fce6f4']", 1); + // This was 0 (other color, not COL_AUTHOR_TABLE_INS, color of the tracked row insertion) + assertXPath(pXmlDoc, "/metafile/push/push/push/push/push/fillcolor[@color='#e1f2fa']", 1); + // This was 3 (color of the cells of the last column, 2 of them disabled by change tracking ) + assertXPath(pXmlDoc, "/metafile/push/push/push/push/push/fillcolor[@color='#3faf46']", 1); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf137154) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf155187_TableInTextChange) { - SwDoc* pDoc = createDoc("tdf137154.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("table_in_text_change.fodt"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); MetafileXmlDump dumper; xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - sal_Int32 nX1 = getXPath(pXmlDoc, "//textarray[1]", "x").toInt32(); // first data label - sal_Int32 nX4 = getXPath(pXmlDoc, "//textarray[4]", "x").toInt32(); // fourth data label - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 10865 - // - Actual : 10252 - // - Delta : 50 - // i.e. the first data label appeared too close to the pie. - CPPUNIT_ASSERT_DOUBLES_EQUAL(nX4, nX1, 50); + + // This was 0 (other color, not COL_AUTHOR_TABLE_DEL, color of the tracked row deletion) + assertXPath(pXmlDoc, "/metafile/push/push/push/push/push/fillcolor[@color='#fce6f4']", 2); + // This was 0 (other color, not COL_AUTHOR_TABLE_INS, color of the tracked row insertion) + assertXPath(pXmlDoc, "/metafile/push/push/push/push/push/fillcolor[@color='#e1f2fa']", 2); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf138777) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf145225_RedlineMovingWithBadInsertion) { - SwDoc* pDoc = createDoc("outside_long_data_label.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf42748.fodt"); + SwDoc* pDoc = getSwDoc(); - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); + // create a 3-element list without change tracking + // (because the fixed problem depends on the own changes) + SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); + pEditShell->RejectRedline(0); + pEditShell->AcceptRedline(0); + CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(0), pEditShell->GetRedlineCount()); + + // Show Changes + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + SwRootFrame* pLayout(pWrtShell->GetLayout()); + CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); + + // insert a tracked paragraph break in middle of the second list item, i.e. split it + dispatchCommand(mxComponent, u".uno:GoToStartOfDoc"_ustr, {}); + dispatchCommand(mxComponent, u".uno:TrackChanges"_ustr, {}); + // positionate the cursor in the middle of the second list item + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 4, /*bBasicCall=*/false); + pWrtShell->SplitNode(false); + CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(1), pEditShell->GetRedlineCount()); + + // move up the last list item over the paragraph split + dispatchCommand(mxComponent, u".uno:GoToEndOfDoc"_ustr, {}); + dispatchCommand(mxComponent, u".uno:MoveUp"_ustr, {}); + dispatchCommand(mxComponent, u".uno:MoveUp"_ustr, {}); + // This was 2 (the tracked paragraph break joined with the moved list item, + // setting the not changed text of the second list item to tracked insertion) + CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(3), pEditShell->GetRedlineCount()); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf146964_ReappearingMovedTextInHideChangesMode) +{ + createSwDoc("tdf54819.fodt"); + SwDoc* pDoc = getSwDoc(); + + // enable Record Changes + dispatchCommand(mxComponent, u".uno:TrackChanges"_ustr, {}); + CPPUNIT_ASSERT_MESSAGE("redlining should be on", + pDoc->getIDocumentRedlineAccess().IsRedlineOn()); + + // set Hide Changes mode + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + SwRootFrame* pLayout(pWrtShell->GetLayout()); + CPPUNIT_ASSERT(pLayout->IsHideRedlines()); + + // delete and paste the deleted word again during Track Changes + dispatchCommand(mxComponent, u".uno:WordRightSel"_ustr, {}); + dispatchCommand(mxComponent, u".uno:Cut"_ustr, {}); + dispatchCommand(mxComponent, u".uno:Paste"_ustr, {}); - const sal_Int32 nFirstLabelLines - = getXPathContent(pXmlDoc, "count(//text[contains(text(),\"really\")])").toInt32(); + SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); + CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(2), pEditShell->GetRedlineCount()); - // This failed, if the first data label didn't break to multiple lines. - CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(1), nFirstLabelLines); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT(pXmlDoc); + // This was "Lorem Lorem ipsum" (reappearing deletion in Hide Changes mode) + assertXPath(pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion", + "portion", u"Lorem ipsum"); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf130031) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf125300) { - SwDoc* pDoc = createDoc("tdf130031.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf125300.docx"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); MetafileXmlDump dumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - sal_Int32 nY = getXPath(pXmlDoc, "//textarray[11]", "y").toInt32(); - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 4339 - // - Actual : 2182 - // - Delta : 50 - // i.e. the data label appeared above the data point. - CPPUNIT_ASSERT_DOUBLES_EQUAL(4339, nY, 50); + + // Keep line spacing before bottom cell border (it was 1892) + sal_Int32 y1 + = getXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[7]/polyline/point[1]", "y") + .toInt32(); + sal_Int32 y2 + = getXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[7]/polyline/point[2]", "y") + .toInt32(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(2092, y1, 7); + CPPUNIT_ASSERT_EQUAL(y1, y2); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf130242) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf116830) { - SwDoc* pDoc = createDoc("tdf130242.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf116830.odt"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); MetafileXmlDump dumper; xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - sal_Int32 nY = getXPath(pXmlDoc, "//textarray[11]", "y").toInt32(); - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 4958 - // - Actual : 3352 - // - Delta : 50 - // i.e. the data label appeared above the data point. - CPPUNIT_ASSERT_DOUBLES_EQUAL(4958, nY, 50); - nY = getXPath(pXmlDoc, "//textarray[13]", "y").toInt32(); - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 3018 - // - Actual : 2343 - // - Delta : 50 - // i.e. the data label appeared above the data point. - CPPUNIT_ASSERT_DOUBLES_EQUAL(3018, nY, 50); + // Assert that the yellow rectangle (cell background) is painted after the + // polypolygon (background shape). + // Background shape: 1.1.1.2 + // Cell background: 1.1.1.3 + assertXPath( + pXmlDoc, + "/metafile/push[1]/push[1]/push[1]/push[2]/push[1]/push[1]/fillcolor[@color='#729fcf']", 1); + assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[2]/push[1]/push[1]/polypolygon", + 1); + + // This failed: cell background was painted before the background shape. + assertXPath(pXmlDoc, + "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/fillcolor[@color='#ffff00']", 1); + assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/rect", 1); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf134121) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf114163) { - SwDoc* pDoc = createDoc("piechart_leaderline.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf114163.odt"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); @@ -964,54 +1553,49 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf134121) xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - // Check the custom leader line on pie chart. - assertXPath(pXmlDoc, "//polyline", 1); + assertXPathContent(pXmlDoc, "(//textarray)[12]/text", u"Data3"); + // This failed, if the legend first label is not "Data3". The legend position is right. } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf138018) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf131707) { - SwDoc* pDoc = createDoc("tdf138018.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf131707_flyWrap.doc"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - CPPUNIT_ASSERT(pXmlDoc); - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 2 - // - Actual : 3 - // i.e. the leader line was visible. - assertXPath(pXmlDoc, "//polyline", 2); + assertXPath(pXmlDoc, "//body/tab/row[3]/cell[2]/txt/infos/bounds", "top", u"2185"); + // the image should be inside of the cell boundary - so the same top or higher + assertXPath(pXmlDoc, "//body/tab/row[3]/cell[2]/txt/anchored/fly/infos/bounds", "top", u"2185"); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf130380) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf122225) { - SwDoc* pDoc = createDoc("tdf130380.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf122225.docx"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); MetafileXmlDump dumper; xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - sal_Int32 nY = getXPath(pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/push[1]/polypolygon/" - "polygon/point[1]", - "y") - .toInt32(); - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 6727 - // - Actual : 4411 - // - Delta : 50 - // i.e. the area chart shrank. - CPPUNIT_ASSERT_DOUBLES_EQUAL(6727, nY, 50); + + // Bug 122225 - FILEOPEN DOCX Textbox of Column chart legend reduces and text of legend disappears + const sal_Int32 nLegendLabelLines + = getXPathContent(pXmlDoc, "count(//text[contains(text(),\"Advanced Diploma\")])") + .toInt32(); + // This failed, if the legend label is not "Advanced Diploma". + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), nLegendLabelLines); + + // Bug 140623 - Fileopen DOCX: Text Orientation of X-Axis 0 instead of 45 degrees + const sal_Int32 nThirdLabelLines + = getXPathContent(pXmlDoc, "count(//text[contains(text(),\"Hispanic\")])").toInt32(); + // This failed, if the third X axis label broke to multiple lines. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), nThirdLabelLines); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf129095) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf125335) { - SwDoc* pDoc = createDoc("tdf129095.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf125335.odt"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); @@ -1019,15 +1603,14 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf129095) xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - // check the inner chart area (relative size) visibility with testing the X axis label - assertXPathContent(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray/text", - "Category 1"); + assertXPathContent(pXmlDoc, "(//textarray)[12]/text", u"Data3"); + // This failed, if the legend first label is not "Data3". The legend position is bottom. } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf132956) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf134247) { - SwDoc* pDoc = createDoc("tdf132956.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("legend-itemorder-min.docx"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); @@ -1035,38 +1618,14 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf132956) xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - // check the inner chart area (default size) visibility with testing the X axis label - assertXPathContent(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray/text", - "Category 1"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf137819) -{ - // Open the bugdoc and check if it went wrong - SwDoc* pDoc = createDoc("tdf137819.fodt"); - CPPUNIT_ASSERT(pDoc); - - // Change the anchor if the textbox to As_char - uno::Reference<beans::XPropertySet> xShapePropSet(getShape(1), uno::UNO_QUERY); - xShapePropSet->setPropertyValue( - "AnchorType", uno::Any(text::TextContentAnchorType::TextContentAnchorType_AS_CHARACTER)); - - // Make the layout xml dump after the change - auto pXml = parseLayoutDump(); - auto sTextRightSidePosition - = getXPath(pXml, "/root/page/body/txt[6]/anchored/fly/infos/bounds", "right"); - auto sShapeRightSidePosition - = getXPath(pXml, "/root/page/body/txt[6]/anchored/SwAnchoredDrawObject/bounds", "right"); - // Before the textframe did not follow the shape, now it supposed to - // so the right side of the shape must be greater than the right side of - // textframe: - CPPUNIT_ASSERT(sTextRightSidePosition.toInt32() < sShapeRightSidePosition.toInt32()); + assertXPathContent(pXmlDoc, "(//textarray)[14]/text", u"1. adatsor"); + // This failed, if the legend first label is not "1. adatsor". } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf122014) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf75659) { - SwDoc* pDoc = createDoc("tdf122014.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf75659.docx"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); @@ -1074,16 +1633,16 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf122014) xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - // This failed, if the chart title is aligned to left. - sal_Int32 nX1 = getXPath(pXmlDoc, "//textarray[13]", "x").toInt32(); - sal_Int32 nX2 = getXPath(pXmlDoc, "//textarray[14]", "x").toInt32(); - CPPUNIT_ASSERT_GREATER(nX1 + 100, nX2); + assertXPathContent(pXmlDoc, "(//textarray)[17]/text", u"Series1"); + assertXPathContent(pXmlDoc, "(//textarray)[18]/text", u"Series2"); + assertXPathContent(pXmlDoc, "(//textarray)[19]/text", u"Series3"); + // These failed, if the legend names are empty strings. } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf134659) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf136816) { - SwDoc* pDoc = createDoc("tdf134659.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf136816.odt"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); @@ -1091,16 +1650,14 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf134659) xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - // This failed, if the axis label is aligned to left. - sal_Int32 nX1 = getXPath(pXmlDoc, "//textarray[1]", "x").toInt32(); - sal_Int32 nX2 = getXPath(pXmlDoc, "//textarray[2]", "x").toInt32(); - CPPUNIT_ASSERT_GREATER(nX1 + 250, nX2); + // Check number of legend entries + assertXPath(pXmlDoc, "//text[contains(text(),\"Column\")]", 2); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf134235) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf126425) { - SwDoc* pDoc = createDoc("tdf134235.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("long_legendentry.docx"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); @@ -1109,65 +1666,75 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf134235) CPPUNIT_ASSERT(pXmlDoc); // Without the accompanying fix in place, this test would have failed with: // - Expected: 14 - // - Actual : 13 - // i.e. the chart title flowed out of chart area. + // - Actual : 12 + // i.e. the text of the chart legend lost. assertXPath(pXmlDoc, "//textarray", 14); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf134676) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testUnusedOLEprops) { - SwDoc* pDoc = createDoc("tdf134676.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf138465min.docx"); - // Dump the rendering of the first page as an XML file. - std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); - MetafileXmlDump dumper; - xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); CPPUNIT_ASSERT(pXmlDoc); // Without the accompanying fix in place, this test would have failed with: - // - Expected: 14 - // - Actual : 13 - // i.e. the X axis title didn't break to multiple lines. - assertXPath(pXmlDoc, "//textarray", 14); + // - Expected: >300 + // - Actual : 142 + // i.e. the formula squashed + CPPUNIT_ASSERT_GREATEREQUAL( + double(300), + getXPath(pXmlDoc, "/root/page/body/txt[2]/anchored/fly/notxt/infos/bounds", "height") + .toDouble()); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf134146) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf123268) { - SwDoc* pDoc = createDoc("tdf134146.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf123268.odt"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); MetafileXmlDump dumper; xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - - const sal_Int32 nTitleLines - = getXPathContent(pXmlDoc, "count(//text[contains(text(),\"Horizontal\")])").toInt32(); - - // Without the accompanying fix in place, this test would have failed. - // i.e. the Y axis title didn't break to multiple lines. - CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(1), nTitleLines); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 53 + // - Actual : 0 + // i.e. the chart lost. + assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/push", + 53); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf136061) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf133005) { - SwDoc* pDoc = createDoc("tdf136061.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf133005.odt"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); MetafileXmlDump dumper; xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - // This failed, if the custom text of data label is missing. - assertXPathContent(pXmlDoc, "//textarray[16]/text", "Customlabel"); + + sal_Int32 nXChartWall = getXPath(pXmlDoc, + "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/" + "push[1]/push[1]/polyline[1]/point[2]", + "x") + .toInt32(); + sal_Int32 nXColumn = getXPath(pXmlDoc, + "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/" + "push[1]/push[41]/polypolygon/polygon/point[1]", + "x") + .toInt32(); + + // This failed, if the value axis doesn't appear inside category. + CPPUNIT_ASSERT_DOUBLES_EQUAL(nXChartWall, nXColumn, 5); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf116925) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf115630) { - SwDoc* pDoc = createDoc("tdf116925.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf115630.docx"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); @@ -1175,19 +1742,24 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf116925) xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - assertXPathContent(pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/push[3]/textarray/text", - "hello"); - // This failed, text color was #000000. - assertXPath( - pXmlDoc, - "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/push[3]/textcolor[@color='#ffffff']", 1); + // Test wide of inner chart area. + sal_Int32 nXRight + = getXPath(pXmlDoc, + "/metafile/push[1]/push[1]/push[1]/push[6]/push[1]/push[3]/polyline[1]/point[1]", + "x") + .toInt32(); + sal_Int32 nXLeft + = getXPath(pXmlDoc, + "/metafile/push[1]/push[1]/push[1]/push[6]/push[1]/push[3]/polyline[1]/point[2]", + "x") + .toInt32(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(2895, nXRight - nXLeft, 50); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf117028) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf108021) { - SwDoc* pDoc = createDoc("tdf117028.docx"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf108021.odt"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); @@ -1195,530 +1767,63 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf117028) xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - // The only polypolygon in the rendering result was the white background we - // want to avoid. - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//polypolygon"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - CPPUNIT_ASSERT_EQUAL(0, xmlXPathNodeSetGetLength(pXmlNodes)); - xmlXPathFreeObject(pXmlObj); - - // Make sure the text is still rendered. - assertXPathContent(pXmlDoc, "//textarray/text", "Hello"); + assertXPath(pXmlDoc, "//textarray[@length='22']", 8); + // This failed, if the textarray length of the first axis label not 22. } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf106390) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf125334) { - SwDoc* pDoc = createDoc("tdf106390.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf125334.odt"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); MetafileXmlDump dumper; xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - sal_Int32 nBottom = getXPath(pXmlDoc, "//sectrectclipregion", "bottom").toInt32(); - - // No end point of line segments shall go below the bottom of the clipping area. - const OString sXPath = "//polyline/point[@y>" + OString::number(nBottom) + "]"; - assertXPath(pXmlDoc, sXPath, 0); + int nCount = countXPathNodes(pXmlDoc, "//textarray[@length='17']"); + CPPUNIT_ASSERT_EQUAL(4, nCount); + // This failed, if the textarray length of the category axis label not 17. } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTableExtrusion1) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf122800) { - SwDoc* pDoc = createDoc("table-extrusion1.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf122800.odt"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); MetafileXmlDump dumper; xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - sal_Int32 nRight = getXPath(pXmlDoc, "//sectrectclipregion", "right").toInt32(); - sal_Int32 nLeft = static_cast<sal_Int32>(nRight * 0.95); - // Expect table borders in right page margin. - const OString sXPath = "//polyline/point[@x>" + OString::number(nLeft) + " and @x<" - + OString::number(nRight) + "]"; - - assertXPath(pXmlDoc, sXPath, 4); + assertXPath(pXmlDoc, "//textarray[@length='22']", 9); + // This failed, if the textarray length of the first axis label not 22. } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTableExtrusion2) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTruncatedAxisLabel) { - SwDoc* pDoc = createDoc("table-extrusion2.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("testTruncatedAxisLabel.odt"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); MetafileXmlDump dumper; xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - // End point position of the outer table. - sal_Int32 nX = getXPath(pXmlDoc, "(//polyline[1]/point)[2]", "x").toInt32(); - - // Do not allow inner table extrude outer table. - const OString sXPath = "//polyline/point[@x>" + OString::number(nX) + "]"; - - assertXPath(pXmlDoc, sXPath, 0); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf116848) -{ - SwDoc* pDoc = createDoc("tdf116848.odt"); - // This resulted in a layout loop. - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf117245) -{ - createDoc("tdf117245.odt"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - // This was 2, TabOverMargin did not use a single line when there was - // enough space for the text. - assertXPath(pXmlDoc, "/root/page/body/txt[1]/LineBreak", 1); - - // This was 2, same problem elsewhere due to code duplication. - assertXPath(pXmlDoc, "/root/page/body/txt[2]/LineBreak", 1); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf118672) -{ - createDoc("tdf118672.odt"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - - // Check if we have hyphenation support, otherwise can't test SwHyphPortion. - uno::Reference<linguistic2::XHyphenator> xHyphenator = LinguMgr::GetHyphenator(); - if (!xHyphenator->hasLocale(lang::Locale("en", "US", OUString()))) - return; - - // This ended as "fol*1 2 3 4 5 6 7 8 9", i.e. "10con-" was moved to the next line. - assertXPath(pXmlDoc, "/root/page/body/txt[1]/LineBreak[1]", "Line", - "He heard quiet steps behind him. That didn't bode well. Who could be fol*1 2 " - "3 4 5 6 7 8 9 10con-"); - assertXPath(pXmlDoc, "/root/page/body/txt[1]/LineBreak[2]", "Line", "setetur"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf117923) -{ - createDoc("tdf117923.doc"); - // Ensure that all text portions are calculated before testing. - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - SwViewShell* pViewShell - = pTextDoc->GetDocShell()->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell(); - CPPUNIT_ASSERT(pViewShell); - pViewShell->Reformat(); - - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - - // Check that we actually test the line we need - assertXPathContent(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]", "GHI GHI GHI GHI"); - assertXPath(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]/Special", "nType", - "PortionType::Number"); - assertXPath(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]/Special", "rText", "2."); - // The numbering height was 960. - assertXPath(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]/Special", "nHeight", "220"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf127606) -{ - createDoc("tdf117923.docx"); - // Ensure that all text portions are calculated before testing. - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - SwViewShell* pViewShell - = pTextDoc->GetDocShell()->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell(); - CPPUNIT_ASSERT(pViewShell); - pViewShell->Reformat(); - - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - - // Check that we actually test the line we need - assertXPathContent(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]", "GHI GHI GHI GHI"); - assertXPath(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]/Special", "nType", - "PortionType::Number"); - assertXPath(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]/Special", "rText", "2."); - // The numbering height was 960 in DOC format. - assertXPath(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]/Special", "nHeight", "220"); - - // tdf#127606: now it's possible to change formatting of numbering - // increase font size (220 -> 260) - dispatchCommand(mxComponent, ".uno:SelectAll", {}); - dispatchCommand(mxComponent, ".uno:Grow", {}); - pViewShell->Reformat(); - discardDumpedLayout(); - pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]/Special", "nHeight", "260"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf127118) -{ - createDoc("tdf127118.docx"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - // This was Horizontal: merged cell split between pages didn't keep vertical writing direction - assertXPath(pXmlDoc, "/root/page[2]/body/tab/row[1]/cell[1]/txt[1]", "WritingMode", "VertBTLR"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf134685) -{ - createDoc("tdf134685.docx"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - sal_Int32 nWidth - = getXPath(pXmlDoc, "/root/page/body/tab/row[6]/cell[1]/infos/bounds", "width").toInt32(); - // This was 2223: the content was only partially visible according to the lost cell width - CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(14000), nWidth); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf109077) -{ - createDoc("tdf109077.docx"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - sal_Int32 nShapeTop - = getXPath(pXmlDoc, "//anchored/SwAnchoredDrawObject/bounds", "top").toInt32(); - sal_Int32 nTextBoxTop = getXPath(pXmlDoc, "//anchored/fly/infos/bounds", "top").toInt32(); - // This was 281: the top of the shape and its textbox should match, though - // tolerate differences <= 1px (about 15 twips). - CPPUNIT_ASSERT_LESS(static_cast<sal_Int32>(15), nTextBoxTop - nShapeTop); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testUserFieldTypeLanguage) -{ - // Set the system locale to German, the document will be English. - SvtSysLocaleOptions aOptions; - OUString sLocaleConfigString = aOptions.GetLanguageTag().getBcp47(); - aOptions.SetLocaleConfigString("de-DE"); - aOptions.Commit(); - comphelper::ScopeGuard g1([&aOptions, &sLocaleConfigString] { - aOptions.SetLocaleConfigString(sLocaleConfigString); - aOptions.Commit(); - }); - - SwDoc* pDoc = createDoc("user-field-type-language.fodt"); - SwViewShell* pViewShell = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(); - pViewShell->UpdateFields(); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - // This was "123,456.00", via a buggy 1234.56 -> 1234,56 -> 123456 -> - // 123,456.00 transform chain. - assertXPath(pXmlDoc, "/root/page/body/txt/Special[@nType='PortionType::Field']", "rText", - "1,234.56"); - - discardDumpedLayout(); - // Now change the system locale to English (before this was failing, 1234,56 -> 0.00) - aOptions.SetLocaleConfigString("en-GB"); - aOptions.Commit(); - comphelper::ScopeGuard g2([&aOptions, &sLocaleConfigString] { - aOptions.SetLocaleConfigString(sLocaleConfigString); - aOptions.Commit(); - }); - pViewShell->UpdateFields(); - pXmlDoc = parseLayoutDump(); - // We expect, that the field value is not changed. Otherwise there is a problem: - assertXPath(pXmlDoc, "/root/page/body/txt/Special[@nType='PortionType::Field']", "rText", - "1,234.56"); - discardDumpedLayout(); - // Now change the system locale to German - aOptions.SetLocaleConfigString("de-DE"); - aOptions.Commit(); - comphelper::ScopeGuard g3([&aOptions, &sLocaleConfigString] { - aOptions.SetLocaleConfigString(sLocaleConfigString); - aOptions.Commit(); - }); - pViewShell->UpdateFields(); - pXmlDoc = parseLayoutDump(); - // We expect, that the field value is not changed. Otherwise there is a problem: - assertXPath(pXmlDoc, "/root/page/body/txt/Special[@nType='PortionType::Field']", "rText", - "1,234.56"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf109137) -{ - createDoc("tdf109137.docx"); - uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); - utl::TempFile aTempFile; - aTempFile.EnableKillingFile(); - uno::Sequence<beans::PropertyValue> aDescriptor(comphelper::InitPropertySequence({ - { "FilterName", uno::Any(OUString("writer8")) }, - })); - xStorable->storeToURL(aTempFile.GetURL(), aDescriptor); - loadURL(aTempFile.GetURL(), "tdf109137.odt"); - 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(SwLayoutWriter2, testForcepoint72) { createDoc("forcepoint72-1.rtf"); } - -//just care it doesn't crash/assert -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testForcepoint75) { createDoc("forcepoint75-1.rtf"); } - -//just care it doesn't crash/assert -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testForcepointFootnoteFrame) -{ - createDoc("forcepoint-swfootnoteframe-1.rtf"); -} - -//FIXME: disabled after failing again with fixed layout -//CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testForcepoint76) { createDoc("forcepoint76-1.rtf"); } - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf118058) -{ - SwDoc* pDoc = createDoc("tdf118058.fodt"); - // This resulted in a layout loop. - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf128611) -{ - createDoc("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. - assertXPath(pXmlDoc, "//tab/row/cell[1]/txt/Text", "Portion", "Abcd efghijkl"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf125893) -{ - createDoc("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", "0"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf134463) -{ - createDoc("tdf134463.docx"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - // This was 621. The previous paragraph must have zero bottom border. - assertXPath(pXmlDoc, "/root/page/body/txt[3]/infos/prtBounds", "top", "21"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf117188) -{ - createDoc("tdf117188.docx"); - uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); - utl::TempFile aTempFile; - aTempFile.EnableKillingFile(); - uno::Sequence<beans::PropertyValue> aDescriptor(comphelper::InitPropertySequence({ - { "FilterName", uno::Any(OUString("writer8")) }, - })); - xStorable->storeToURL(aTempFile.GetURL(), aDescriptor); - loadURL(aTempFile.GetURL(), "tdf117188.odt"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - OUString sWidth = getXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/infos/bounds", "width"); - OUString sHeight = getXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/infos/bounds", "height"); - // The text box must have zero border distances - assertXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/infos/prtBounds", "left", "0"); - assertXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/infos/prtBounds", "top", "0"); - assertXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/infos/prtBounds", "width", sWidth); - assertXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/infos/prtBounds", "height", sHeight); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf117187) -{ - createDoc("tdf117187.odt"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - - // there should be no fly portions - assertXPath(pXmlDoc, "/root/page/body/txt/Special[@nType='PortionType::Fly']", 0); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf119875) -{ - createDoc("tdf119875.odt"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - sal_Int32 nFirstTop - = getXPath(pXmlDoc, "/root/page[2]/body/section[1]/infos/bounds", "top").toInt32(); - sal_Int32 nSecondTop - = getXPath(pXmlDoc, "/root/page[2]/body/section[2]/infos/bounds", "top").toInt32(); - // The first section had the same top value as the second one, so they - // overlapped. - CPPUNIT_ASSERT_LESS(nSecondTop, nFirstTop); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf120287) -{ - createDoc("tdf120287.fodt"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - // This was 2, TabOverMargin Word-specific compat flag did not imply - // default-in-Word printer-independent layout, resulting in an additional - // line break. - assertXPath(pXmlDoc, "/root/page/body/txt[1]/LineBreak", 1); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf106234) -{ - createDoc("tdf106234.fodt"); - // Ensure that all text portions are calculated before testing. - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - SwViewShell* pViewShell - = pTextDoc->GetDocShell()->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell(); - CPPUNIT_ASSERT(pViewShell); - pViewShell->Reformat(); - - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - // In justified paragraphs, there is justification between left tabulators and manual line breaks - assertXPath(pXmlDoc, "/root/page/body/txt[1]/Special", "nType", "PortionType::Margin"); - assertXPathNoAttribute(pXmlDoc, "/root/page/body/txt[1]/Special", "nWidth"); - // but not after centered, right and decimal tabulators - assertXPath(pXmlDoc, "/root/page/body/txt[2]/Special", "nType", "PortionType::Margin"); - // This was a justified line, without nWidth - assertXPath(pXmlDoc, "/root/page/body/txt[2]/Special", "nWidth", "7881"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf120287b) -{ - createDoc("tdf120287b.fodt"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - // This was 1418, TabOverMargin did the right split of the paragraph to two - // lines, but then calculated a too large tab portion size on the first - // line. - assertXPath(pXmlDoc, "/root/page/body/txt[1]/Text[@nType='PortionType::TabRight']", "nWidth", - "17"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf120287c) -{ - createDoc("tdf120287c.fodt"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - // This was 2, the second line was not broken into a 2nd and a 3rd one, - // rendering text outside the paragraph frame. - assertXPath(pXmlDoc, "/root/page/body/txt[1]/LineBreak", 3); -} -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf122878) -{ - createDoc("tdf122878.docx"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - // FIXME: the XPath should be adjusted when the proper floating table would be imported - const sal_Int32 nTblTop - = getXPath(pXmlDoc, "/root/page[1]/footer/txt/anchored/fly/tab/infos/bounds", "top") - .toInt32(); - const sal_Int32 nFirstPageParaCount - = getXPathContent(pXmlDoc, "count(/root/page[1]/body/txt)").toInt32(); - CPPUNIT_ASSERT_EQUAL(sal_Int32(30), nFirstPageParaCount); - for (sal_Int32 i = 1; i <= nFirstPageParaCount; ++i) - { - const OString xPath = "/root/page[1]/body/txt[" + OString::number(i) + "]/infos/bounds"; - const sal_Int32 nTxtBottom = getXPath(pXmlDoc, xPath.getStr(), "top").toInt32() - + getXPath(pXmlDoc, xPath.getStr(), "height").toInt32(); - // No body paragraphs should overlap the table in the footer - CPPUNIT_ASSERT_MESSAGE(OString("testing paragraph #" + OString::number(i)).getStr(), - nTxtBottom <= nTblTop); - } -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf115094) -{ - createDoc("tdf115094.docx"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - - sal_Int32 nTopOfD1 - = getXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/tab/row[1]/cell[4]/infos/bounds", - "top") - .toInt32(); - sal_Int32 nTopOfD1Anchored = getXPath(pXmlDoc, - "/root/page/body/txt/anchored/fly/tab/row[1]/cell[4]/" - "txt[2]/anchored/fly/infos/bounds", - "top") - .toInt32(); - CPPUNIT_ASSERT_LESS(nTopOfD1Anchored, nTopOfD1); - sal_Int32 nTopOfB2 - = getXPath(pXmlDoc, "/root/page/body/txt/anchored/fly/tab/row[2]/cell[2]/infos/bounds", - "top") - .toInt32(); - sal_Int32 nTopOfB2Anchored = getXPath(pXmlDoc, - "/root/page/body/txt/anchored/fly/tab/row[2]/cell[2]/" - "txt[1]/anchored/fly/infos/bounds", - "top") - .toInt32(); - CPPUNIT_ASSERT_LESS(nTopOfB2Anchored, nTopOfB2); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf112290) -{ - SwDoc* pDoc = createDoc("tdf112290.docx"); - CPPUNIT_ASSERT(pDoc); - auto pXml = parseLayoutDump(); - assertXPath(pXml, "/root/page/body/txt/LineBreak[2]", "Line", "Xxxx Xxxx"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf122607) -{ - createDoc("tdf122607.odt"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, - "/root/page[1]/anchored/fly/txt[1]/anchored/fly/tab/row[2]/cell/txt[7]/anchored/" - "fly/txt/Text[1]", - "nHeight", "253"); - assertXPath(pXmlDoc, - "/root/page[1]/anchored/fly/txt[1]/anchored/fly/tab/row[2]/cell/txt[7]/anchored/" - "fly/txt/Text[1]", - "nWidth", "428"); - assertXPath(pXmlDoc, - "/root/page[1]/anchored/fly/txt[1]/anchored/fly/tab/row[2]/cell/txt[7]/anchored/" - "fly/txt/Text[1]", - "Portion", "Fax:"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf122607_regression) -{ - discardDumpedLayout(); - if (mxComponent.is()) - mxComponent->dispose(); - - OUString const pName("tdf122607_leerzeile.odt"); - - OUString const url(m_directories.getURLFromSrc(DATA_DIRECTORY) + pName); - - // note: must set Hidden property, so that SfxFrameViewWindow_Impl::Resize() - // does *not* forward initial VCL Window Resize and thereby triggers a - // layout which does not happen on soffice --convert-to pdf. - std::vector<beans::PropertyValue> aFilterOptions = { - { beans::PropertyValue("Hidden", -1, uno::Any(true), beans::PropertyState_DIRECT_VALUE) }, - }; - - std::cout << pName << ":\n"; - - // inline the loading because currently properties can't be passed... - mxComponent = loadFromDesktop(url, "com.sun.star.text.TextDocument", - comphelper::containerToSequence(aFilterOptions)); - - CPPUNIT_ASSERT(mxComponent.is()); - - uno::Sequence<beans::PropertyValue> props(comphelper::InitPropertySequence({ - { "FilterName", uno::Any(OUString("writer_pdf_Export")) }, - })); - utl::TempFile aTempFile; - uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); - xStorable->storeToURL(aTempFile.GetURL(), props); + // test the X axis label visibility + assertXPathContent(pXmlDoc, "(//textarray)[1]/text", u"Long axis label truncated 1"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - // somehow these 2 rows overlapped in the PDF unless CalcLayout() runs - assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[1]/infos/bounds", "mbFixSize", - "false"); - assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[1]/infos/bounds", "top", "2977"); - assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[1]/infos/bounds", "height", "241"); - assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[2]/infos/bounds", "mbFixSize", - "true"); - // this was 3034, causing the overlap - assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[2]/infos/bounds", "top", "3218"); - assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[2]/infos/bounds", "height", "164"); - - aTempFile.EnableKillingFile(); + // test the Y axis label visibility + assertXPathContent(pXmlDoc, "(//textarray)[3]/text", u"-5.00"); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testBtlrCell) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf128996) { - SwDoc* pDoc = createDoc("btlr-cell.odt"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf128996.docx"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); @@ -1726,978 +1831,142 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testBtlrCell) xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - // Without the accompanying fix in place, this test would have failed, as - // the orientation was 0 (layout did not take btlr direction request from - // doc model). - assertXPath(pXmlDoc, "//font[1]", "orientation", "900"); - -#if !defined(MACOSX) && !defined(_WIN32) // macOS fails with x == 2662 for some reason. - // Without the accompanying fix in place, this test would have failed with 'Expected: 1915; - // Actual : 1756', i.e. the AAA1 text was too close to the left cell border due to an ascent vs - // descent mismatch when calculating the baseline offset of the text portion. - assertXPath(pXmlDoc, "//textarray[1]", "x", "1915"); - assertXPath(pXmlDoc, "//textarray[1]", "y", "2707"); - - // Without the accompanying fix in place, this test would have failed with 'Expected: 1979; - // Actual : 2129', i.e. the gray background of the "AAA2." text was too close to the right edge - // of the text portion. Now it's exactly behind the text portion. - assertXPath(pXmlDoc, "//rect[@top='2159']", "left", "1979"); - - // Without the accompanying fix in place, this test would have failed with 'Expected: 269; - // Actual : 0', i.e. the AAA2 frame was not visible due to 0 width. - pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/txt[2]/infos/bounds", "width", "269"); - - // Test the position of the cursor after doc load. - // We expect that it's inside the first text frame in the first cell. - // More precisely, this is a bottom to top vertical frame, so we expect it's at the start, which - // means it's at the lower half of the text frame rectangle (vertically). - SwWrtShell* pWrtShell = pShell->GetWrtShell(); - CPPUNIT_ASSERT(pWrtShell); - - const SwRect& rCharRect = pWrtShell->GetCharRect(); - SwTwips nFirstParaTop - = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/txt[1]/infos/bounds", "top").toInt32(); - SwTwips nFirstParaHeight - = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/txt[1]/infos/bounds", "height") - .toInt32(); - SwTwips nFirstParaMiddle = nFirstParaTop + nFirstParaHeight / 2; - SwTwips nFirstParaBottom = nFirstParaTop + nFirstParaHeight; - // Without the accompanying fix in place, this test would have failed: the lower half (vertical) - // range was 2273 -> 2835, the good vertical position is 2730, the bad one was 1830. - CPPUNIT_ASSERT_GREATER(nFirstParaMiddle, rCharRect.Top()); - CPPUNIT_ASSERT_LESS(nFirstParaBottom, rCharRect.Top()); - - // Save initial cursor position. - SwPosition aCellStart = *pWrtShell->GetCursor()->Start(); - - // Test that pressing "up" at the start of the cell goes to the next character position. - sal_uLong nNodeIndex = pWrtShell->GetCursor()->Start()->nNode.GetIndex(); - sal_Int32 nIndex = pWrtShell->GetCursor()->Start()->nContent.GetIndex(); - KeyEvent aKeyEvent(0, KEY_UP); - SwEditWin& rEditWin = pShell->GetView()->GetEditWin(); - rEditWin.KeyInput(aKeyEvent); - Scheduler::ProcessEventsToIdle(); - // Without the accompanying fix in place, this test would have failed: "up" was interpreted as - // logical "left", which does nothing if you're at the start of the text anyway. - CPPUNIT_ASSERT_EQUAL(nIndex + 1, pWrtShell->GetCursor()->Start()->nContent.GetIndex()); - - // Test that pressing "right" goes to the next paragraph (logical "down"). - sal_Int32 nContentIndex = pWrtShell->GetCursor()->Start()->nContent.GetIndex(); - aKeyEvent = KeyEvent(0, KEY_RIGHT); - rEditWin.KeyInput(aKeyEvent); - Scheduler::ProcessEventsToIdle(); - // Without the accompanying fix in place, this test would have failed: the cursor went to the - // paragraph after the table. - CPPUNIT_ASSERT_EQUAL(nNodeIndex + 1, pWrtShell->GetCursor()->Start()->nNode.GetIndex()); - - // Test that we have the correct character index after traveling to the next paragraph. - // Without the accompanying fix in place, this test would have failed: char position was 5, i.e. - // the cursor jumped to the end of the paragraph for no reason. - CPPUNIT_ASSERT_EQUAL(nContentIndex, pWrtShell->GetCursor()->Start()->nContent.GetIndex()); - - // Test that clicking "below" the second paragraph positions the cursor at the start of the - // second paragraph. - SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); - SwPosition aPosition(aCellStart); - SwTwips nSecondParaLeft - = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/txt[2]/infos/bounds", "left") - .toInt32(); - SwTwips nSecondParaWidth - = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/txt[2]/infos/bounds", "width") - .toInt32(); - SwTwips nSecondParaTop - = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/txt[2]/infos/bounds", "top").toInt32(); - SwTwips nSecondParaHeight - = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/txt[2]/infos/bounds", "height") - .toInt32(); - Point aPoint; - aPoint.setX(nSecondParaLeft + nSecondParaWidth / 2); - aPoint.setY(nSecondParaTop + nSecondParaHeight - 100); - SwCursorMoveState aState(CursorMoveState::NONE); - pLayout->GetModelPositionForViewPoint(&aPosition, aPoint, &aState); - CPPUNIT_ASSERT_EQUAL(aCellStart.nNode.GetIndex() + 1, aPosition.nNode.GetIndex()); - // Without the accompanying fix in place, this test would have failed: character position was 5, - // i.e. cursor was at the end of the paragraph. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), aPosition.nContent.GetIndex()); - - // Test that the selection rectangles are inside the cell frame if we select all the cell - // content. - SwTwips nCellLeft - = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/infos/bounds", "left").toInt32(); - SwTwips nCellWidth - = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/infos/bounds", "width").toInt32(); - SwTwips nCellTop - = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/infos/bounds", "top").toInt32(); - SwTwips nCellHeight - = getXPath(pXmlDoc, "/root/page/body/tab/row/cell[1]/infos/bounds", "height").toInt32(); - SwRect aCellRect(Point(nCellLeft, nCellTop), Size(nCellWidth, nCellHeight)); - pWrtShell->SelAll(); - SwShellCursor* pShellCursor = pWrtShell->getShellCursor(/*bBlock=*/false); - CPPUNIT_ASSERT(!pShellCursor->empty()); - // Without the accompanying fix in place, this test would have failed with: - // selection rectangle 269x2573@(1970,2172) is not inside cell rectangle 3207x1134@(1593,1701) - // i.e. the selection went past the bottom border of the cell frame. - for (const auto& rRect : *pShellCursor) - { - std::stringstream ss; - ss << "selection rectangle " << rRect << " is not inside cell rectangle " << aCellRect; - CPPUNIT_ASSERT_MESSAGE(ss.str(), aCellRect.IsInside(rRect)); - } - - // Make sure that the correct rectangle gets repainted on scroll. - SwFrame* pPageFrame = pLayout->GetLower(); - CPPUNIT_ASSERT(pPageFrame->IsPageFrame()); - - SwFrame* pBodyFrame = pPageFrame->GetLower(); - CPPUNIT_ASSERT(pBodyFrame->IsBodyFrame()); - - SwFrame* pTabFrame = pBodyFrame->GetLower(); - CPPUNIT_ASSERT(pTabFrame->IsTabFrame()); - - SwFrame* pRowFrame = pTabFrame->GetLower(); - CPPUNIT_ASSERT(pRowFrame->IsRowFrame()); - - SwFrame* pCellFrame = pRowFrame->GetLower(); - CPPUNIT_ASSERT(pCellFrame->IsCellFrame()); - - SwFrame* pFrame = pCellFrame->GetLower(); - CPPUNIT_ASSERT(pFrame->IsTextFrame()); - - SwTextFrame* pTextFrame = static_cast<SwTextFrame*>(pFrame); - pTextFrame->SwapWidthAndHeight(); - // Mimic what normally SwTextFrame::PaintSwFrame() does: - SwRect aRect(4207, 2273, 269, 572); - pTextFrame->SwitchVerticalToHorizontal(aRect); - // Without the accompanying fix in place, this test would have failed with: - // Expected: 572x269@(1691,4217) - // Actual : 572x269@(2263,4217) - // i.e. the paint rectangle position was incorrect, text was not painted on scrolling up. - CPPUNIT_ASSERT_EQUAL(SwRect(1691, 4217, 572, 269), aRect); -#endif + assertXPathContent(pXmlDoc, "(//textarray)[1]/text", u"A very long category name 1"); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf123898) -{ - createDoc("tdf123898.odt"); - - // Make sure spellchecker has done its job already - Scheduler::ProcessEventsToIdle(); - - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - // Make sure that the arrow on the left is not there (there are 43 children if it's there) - assertXPathChildren(pXmlDoc, "/root/page/body/txt/anchored/fly/txt", 42); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf123651) -{ - createDoc("tdf123651.docx"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - // Without the accompanying fix in place, this test would have failed with 'Expected: 7639; - // Actual: 12926'. The shape was below the second "Lorem ipsum" text, not above it. - const sal_Int32 nTopValue = getXPath(pXmlDoc, "//SwAnchoredDrawObject/bounds", "top").toInt32(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7639, nTopValue, 10); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf116501) -{ - //just care it doesn't freeze - createDoc("tdf116501.odt"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testAbi11870) -{ - //just care it doesn't assert - createDoc("abi11870-2.odt"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf118719) -{ - // Insert a page break. - SwDoc* pDoc = createDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - - // Enable hide whitespace mode. - SwViewOption aViewOptions(*pWrtShell->GetViewOptions()); - aViewOptions.SetHideWhitespaceMode(true); - pWrtShell->ApplyViewOptions(aViewOptions); - - pWrtShell->Insert("first"); - pWrtShell->InsertPageBreak(); - pWrtShell->Insert("second"); - - // Without the accompanying fix in place, this test would have failed, as the height of the - // first page was 15840 twips, instead of the much smaller 276. - sal_Int32 nOther = parseDump("/root/page[1]/infos/bounds", "height").toInt32(); - sal_Int32 nLast = parseDump("/root/page[2]/infos/bounds", "height").toInt32(); - CPPUNIT_ASSERT_GREATER(nOther, nLast); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTabOverMargin) -{ - createDoc("tab-over-margin.odt"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - - // 2nd paragraph has a tab over the right margin, and with the TabOverMargin compat option, - // there is enough space to have all content in a single line. - // Without the accompanying fix in place, this test would have failed, there were 2 lines. - assertXPath(pXmlDoc, "/root/page/body/txt[2]/LineBreak", 1); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testImageComment) -{ - // Load a document that has "aaa" in it, then a commented image (4th char is the as-char image, - // 5th char is the comment anchor). - SwDoc* pDoc = createDoc("image-comment.odt"); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - - // Look up a layout position which is on the right of the image. - SwRootFrame* pRoot = pWrtShell->GetLayout(); - CPPUNIT_ASSERT(pRoot->GetLower()->IsPageFrame()); - SwPageFrame* pPage = static_cast<SwPageFrame*>(pRoot->GetLower()); - CPPUNIT_ASSERT(pPage->GetLower()->IsBodyFrame()); - SwBodyFrame* pBody = static_cast<SwBodyFrame*>(pPage->GetLower()); - CPPUNIT_ASSERT(pBody->GetLower()->IsTextFrame()); - SwTextFrame* pTextFrame = static_cast<SwTextFrame*>(pBody->GetLower()); - CPPUNIT_ASSERT(pTextFrame->GetDrawObjs()); - SwSortedObjs& rDrawObjs = *pTextFrame->GetDrawObjs(); - CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rDrawObjs.size()); - SwAnchoredObject* pDrawObj = rDrawObjs[0]; - const SwRect& rDrawObjRect = pDrawObj->GetObjRect(); - Point aPoint = rDrawObjRect.Center(); - aPoint.setX(aPoint.getX() + rDrawObjRect.Width() / 2); - - // Ask for the doc model pos of this layout point. - SwPosition aPosition(*pTextFrame->GetTextNodeForFirstText()); - pTextFrame->GetModelPositionForViewPoint(&aPosition, aPoint); - - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 5 - // - Actual : 4 - // i.e. the cursor got positioned between the image and its comment, so typing extended the - // comment, instead of adding content after the commented image. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(5), aPosition.nContent.GetIndex()); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testCommentCursorPosition) -{ - // Load a document that has "aaa" in it, followed by three comments. - SwDoc* pDoc = createDoc("endOfLineComments.odt"); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - - SwRootFrame* pRoot = pWrtShell->GetLayout(); - CPPUNIT_ASSERT(pRoot->GetLower()->IsPageFrame()); - SwPageFrame* pPage = static_cast<SwPageFrame*>(pRoot->GetLower()); - CPPUNIT_ASSERT(pPage->GetLower()->IsBodyFrame()); - SwBodyFrame* pBody = static_cast<SwBodyFrame*>(pPage->GetLower()); - CPPUNIT_ASSERT(pBody->GetLower()->IsTextFrame()); - SwTextFrame* pTextFrame = static_cast<SwTextFrame*>(pBody->GetLower()); - - // Set a point in the whitespace past the end of the first line. - Point aPoint = pWrtShell->getShellCursor(false)->GetSttPos(); - aPoint.setX(aPoint.getX() + 10000); - - // Ask for the doc model pos of this layout point. - SwPosition aPosition(*pTextFrame->GetTextNodeForFirstText()); - pTextFrame->GetModelPositionForViewPoint(&aPosition, aPoint); - - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 6 - // - Actual : 3 or 4 - // i.e. the cursor got positioned before the comments, - // so typing extended the first comment instead of adding content after the comments. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(6), aPosition.nContent.GetIndex()); - // The second line is also important, but can't be auto-tested - // since the failing situation depends on GetViewWidth which is zero in the headless tests. - // bb<comment>| - the cursor should move behind the |, not before it. -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testCombiningCharacterCursorPosition) -{ - // Load a document that has "a" in it, followed by a combining acute in a separate rext span - SwDoc* pDoc = createDoc("tdf138592-a-acute.fodt"); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - - SwRootFrame* pRoot = pWrtShell->GetLayout(); - CPPUNIT_ASSERT(pRoot->GetLower()->IsPageFrame()); - SwPageFrame* pPage = static_cast<SwPageFrame*>(pRoot->GetLower()); - CPPUNIT_ASSERT(pPage->GetLower()->IsBodyFrame()); - SwBodyFrame* pBody = static_cast<SwBodyFrame*>(pPage->GetLower()); - CPPUNIT_ASSERT(pBody->GetLower()->IsTextFrame()); - SwTextFrame* pTextFrame = static_cast<SwTextFrame*>(pBody->GetLower()); - - // Set a point in the whitespace past the end of the first line. - Point aPoint = pWrtShell->getShellCursor(false)->GetSttPos(); - aPoint.AdjustX(10000); - - // Ask for the doc model pos of this layout point. - SwPosition aPosition(*pTextFrame->GetTextNodeForFirstText()); - pTextFrame->GetModelPositionForViewPoint(&aPosition, aPoint); - - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 2 - // - Actual : 1 - // i.e. the cursor got positioned before the acute, so typing shifted the acute (applying it - // to newly typed characters) instead of adding content after it. - CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aPosition.nContent.GetIndex()); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf64222) -{ - createDoc("tdf64222.docx"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, "/root/page/body/txt[2]/Special", "nHeight", "560"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf113014) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf126244) { - SwDoc* pDoc = createDoc("tdf113014.fodt"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf126244.docx"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); MetafileXmlDump dumper; xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - - // This failed, if numbering of cell A1 is missing - // (A1: left indent: 3 cm, first line indent: -3 cm - // A2: left indent: 0 cm, first line indent: 0 cm) - assertXPathContent(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/textarray[1]/text", "1."); - assertXPathContent(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/textarray[3]/text", "2."); - assertXPathContent(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/textarray[5]/text", "3."); + // Test the first level of vertical category axis labels orientation. The first level orientation should be horizontal. + assertXPath(pXmlDoc, "(//font)[1]", "orientation", u"0"); + // Test the second level of vertical category axis labels orientation. The second level orientation should be vertical. + sal_Int32 nRotation = getXPath(pXmlDoc, "(//font)[5]", "orientation").toInt32(); + CPPUNIT_ASSERT(nRotation >= 899); + CPPUNIT_ASSERT(nRotation <= 900); + // Test the third level of vertical category axis labels orientation. The third level orientation should be vertical. + nRotation = getXPath(pXmlDoc, "(//font)[7]", "orientation").toInt32(); + CPPUNIT_ASSERT(nRotation >= 899); + CPPUNIT_ASSERT(nRotation <= 900); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf130218) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf127304) { - SwDoc* pDoc = createDoc("tdf130218.fodt"); - SwDocShell* pShell = pDoc->GetDocShell(); + createSwDoc("tdf127304.odt"); + SwDocShell* pShell = getSwDocShell(); // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); MetafileXmlDump dumper; - xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - - // This failed, if hanging first line was hidden - assertXPathContent(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/textarray[1]/text", "Text"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf127235) -{ - SwDoc* pDoc = createDoc("tdf127235.odt"); - // This resulted in a layout loop. - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf138039) -{ - createDoc("tdf138039.odt"); - - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - - // there are 3 pages - assertXPath(pXmlDoc, "/root/page", 3); - // table on first page - assertXPath(pXmlDoc, "/root/page[1]/body/tab", 1); - assertXPath(pXmlDoc, "/root/page[1]/body/txt", 0); - // paragraph with large fly on second page - assertXPath(pXmlDoc, "/root/page[2]/body/tab", 0); - assertXPath(pXmlDoc, "/root/page[2]/body/txt", 1); - 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", "17915"); - assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/anchored/fly[1]/infos/bounds", "height", - "15819"); - // paragraph on third page - assertXPath(pXmlDoc, "/root/page[3]/body/tab", 0); - assertXPath(pXmlDoc, "/root/page[3]/body/txt", 1); - assertXPath(pXmlDoc, "/root/page[3]/body/txt[1]/anchored", 0); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf134298) -{ - createDoc("tdf134298.ott"); - - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - - // there are 2 pages - assertXPath(pXmlDoc, "/root/page", 2); - // table and first para on first page - assertXPath(pXmlDoc, "/root/page[1]/body/tab", 1); - assertXPath(pXmlDoc, "/root/page[1]/body/txt", 1); - assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/anchored", 0); - // paragraph with large fly on second page - assertXPath(pXmlDoc, "/root/page[2]/body/tab", 0); - assertXPath(pXmlDoc, "/root/page[2]/body/txt", 1); - 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", "17897"); - assertXPath(pXmlDoc, "/root/page[2]/body/txt[1]/anchored/fly[1]/infos/bounds", "height", - "15819"); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testShapeAllowOverlap) -{ -// Need to find out why this fails on macOS and why this is unstable on Windows. -#if !defined(MACOSX) && !defined(_WIN32) - // Create an empty document with two, intentionally overlapping shapes. - // Set their AllowOverlap property to false. - loadURL("private:factory/swriter", nullptr); - uno::Reference<lang::XMultiServiceFactory> xDocument(mxComponent, uno::UNO_QUERY); - awt::Point aPoint(1000, 1000); - awt::Size aSize(2000, 2000); - uno::Reference<drawing::XShape> xShape( - xDocument->createInstance("com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY); - xShape->setPosition(aPoint); - xShape->setSize(aSize); - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xDocument, uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY); - xShapeProperties->setPropertyValue("AllowOverlap", uno::makeAny(false)); - xShapeProperties->setPropertyValue("AnchorType", - uno::makeAny(text::TextContentAnchorType_AT_CHARACTER)); - xDrawPageSupplier->getDrawPage()->add(xShape); - - aPoint = awt::Point(2000, 2000); - xShape.set(xDocument->createInstance("com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY); - xShape->setPosition(aPoint); - xShape->setSize(aSize); - xShapeProperties.set(xShape, uno::UNO_QUERY); - xShapeProperties->setPropertyValue("AllowOverlap", uno::makeAny(false)); - xShapeProperties->setPropertyValue("AnchorType", - uno::makeAny(text::TextContentAnchorType_AT_CHARACTER)); - xDrawPageSupplier->getDrawPage()->add(xShape); - - // Now verify that the rectangle of the anchored objects don't overlap. - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); - SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); - SwFrame* pPageFrame = pLayout->GetLower(); - SwFrame* pBodyFrame = pPageFrame->GetLower(); - SwFrame* pTextFrame = pBodyFrame->GetLower(); - CPPUNIT_ASSERT(pTextFrame->GetDrawObjs()); - SwSortedObjs& rObjs = *pTextFrame->GetDrawObjs(); - CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rObjs.size()); - SwAnchoredObject* pFirst = rObjs[0]; - SwAnchoredObject* pSecond = rObjs[1]; - // Without the accompanying fix in place, this test would have failed: the layout dump was - // <bounds left="1984" top="1984" width="1137" height="1137"/> - // <bounds left="2551" top="2551" width="1137" height="1137"/> - // so there was a clear vertical overlap. (Allow for 1px tolerance.) - OString aMessage = "Unexpected overlap: first shape's bottom is " - + OString::number(pFirst->GetObjRect().Bottom()) + ", second shape's top is " - + OString::number(pSecond->GetObjRect().Top()); - CPPUNIT_ASSERT_MESSAGE(aMessage.getStr(), - std::abs(pFirst->GetObjRect().Bottom() - pSecond->GetObjRect().Top()) - < 15); -#endif -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testShapeAllowOverlapWrap) -{ - // Create an empty document with two, intentionally overlapping shapes. - // Set their AllowOverlap property to false and their wrap to through. - loadURL("private:factory/swriter", nullptr); - uno::Reference<lang::XMultiServiceFactory> xDocument(mxComponent, uno::UNO_QUERY); - awt::Point aPoint(1000, 1000); - awt::Size aSize(2000, 2000); - uno::Reference<drawing::XShape> xShape( - xDocument->createInstance("com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY); - xShape->setPosition(aPoint); - xShape->setSize(aSize); - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xDocument, uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY); - xShapeProperties->setPropertyValue("AllowOverlap", uno::makeAny(false)); - xShapeProperties->setPropertyValue("AnchorType", - uno::makeAny(text::TextContentAnchorType_AT_CHARACTER)); - xShapeProperties->setPropertyValue("Surround", uno::makeAny(text::WrapTextMode_THROUGH)); - xDrawPageSupplier->getDrawPage()->add(xShape); - - aPoint = awt::Point(2000, 2000); - xShape.set(xDocument->createInstance("com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY); - xShape->setPosition(aPoint); - xShape->setSize(aSize); - xShapeProperties.set(xShape, uno::UNO_QUERY); - xShapeProperties->setPropertyValue("AllowOverlap", uno::makeAny(false)); - xShapeProperties->setPropertyValue("AnchorType", - uno::makeAny(text::TextContentAnchorType_AT_CHARACTER)); - xShapeProperties->setPropertyValue("Surround", uno::makeAny(text::WrapTextMode_THROUGH)); - xDrawPageSupplier->getDrawPage()->add(xShape); - - // Now verify that the rectangle of the anchored objects do overlap. - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); - SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); - SwFrame* pPageFrame = pLayout->GetLower(); - SwFrame* pBodyFrame = pPageFrame->GetLower(); - SwFrame* pTextFrame = pBodyFrame->GetLower(); - CPPUNIT_ASSERT(pTextFrame->GetDrawObjs()); - SwSortedObjs& rObjs = *pTextFrame->GetDrawObjs(); - CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rObjs.size()); - SwAnchoredObject* pFirst = rObjs[0]; - SwAnchoredObject* pSecond = rObjs[1]; - // Without the accompanying fix in place, this test would have failed: AllowOverlap=no had - // priority over Surround=through (which is bad for Word compat). - CPPUNIT_ASSERT(pSecond->GetObjRect().IsOver(pFirst->GetObjRect())); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf124600) -{ - createDoc("tdf124600.docx"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 1 - // - Actual : 2 - // i.e. the last line in the body text had 2 lines, while it should have 1, as Word does (as the - // fly frame does not intersect with the print area of the paragraph.) - assertXPath(pXmlDoc, "/root/page/body/txt[2]/LineBreak", 1); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf124601) -{ - // This is a testcase for the ContinuousEndnotes compat flag. - // The document has 2 pages, the endnote anchor is on the first page. - // The endnote should be on the 2nd page together with the last page content. - createDoc("tdf124601.doc"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 2 - // - Actual : 3 - // i.e. there was a separate endnote page, even when the ContinuousEndnotes compat option was - // on. - assertXPath(pXmlDoc, "/root/page", 2); - assertXPath(pXmlDoc, "/root/page[2]/ftncont", 1); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf124601b) -{ - // Table has an image, which is anchored in the first row, but its vertical position is large - // enough to be rendered in the second row. - // The shape has layoutInCell=1, so should match what Word does here. - // Also the horizontal position should be in the last column, even if the anchor is in the - // last-but-one column. - createDoc("tdf124601b.doc"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - - sal_Int32 nFlyTop = getXPath(pXmlDoc, "//fly/infos/bounds", "top").toInt32(); - sal_Int32 nFlyLeft = getXPath(pXmlDoc, "//fly/infos/bounds", "left").toInt32(); - sal_Int32 nFlyRight = nFlyLeft + getXPath(pXmlDoc, "//fly/infos/bounds", "width").toInt32(); - sal_Int32 nSecondRowTop = getXPath(pXmlDoc, "//tab/row[2]/infos/bounds", "top").toInt32(); - sal_Int32 nLastCellLeft - = getXPath(pXmlDoc, "//tab/row[1]/cell[5]/infos/bounds", "left").toInt32(); - sal_Int32 nLastCellRight - = nLastCellLeft + getXPath(pXmlDoc, "//tab/row[1]/cell[5]/infos/bounds", "width").toInt32(); - // Without the accompanying fix in place, this test would have failed with: - // - Expected greater than: 3736 - // - Actual : 2852 - // i.e. the image was still inside the first row. - CPPUNIT_ASSERT_GREATER(nSecondRowTop, nFlyTop); - - // Without the accompanying fix in place, this test would have failed with: - // - Expected greater than: 9640 - // - Actual : 9639 - // i.e. the right edge of the image was not within the bounds of the last column, the right edge - // was in the last-but-one column. - CPPUNIT_ASSERT_GREATER(nLastCellLeft, nFlyRight); - CPPUNIT_ASSERT_LESS(nLastCellRight, nFlyRight); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf124770) -{ - // Enable content over margin. - SwDoc* pDoc = createDoc(); - pDoc->getIDocumentSettingAccess().set(DocumentSettingId::TAB_OVER_MARGIN, true); - - // Set page width. - SwPageDesc& rPageDesc = pDoc->GetPageDesc(0); - SwFrameFormat& rPageFormat = rPageDesc.GetMaster(); - const SwAttrSet& rPageSet = rPageFormat.GetAttrSet(); - SwFormatFrameSize aPageSize = rPageSet.GetFrameSize(); - aPageSize.SetWidth(3703); - rPageFormat.SetFormatAttr(aPageSize); - - // Set left and right margin. - SvxLRSpaceItem aLRSpace = rPageSet.GetLRSpace(); - aLRSpace.SetLeft(1418); - aLRSpace.SetRight(1418); - rPageFormat.SetFormatAttr(aLRSpace); - pDoc->ChgPageDesc(0, rPageDesc); - - // Set font to italic 20pt Liberation Serif. - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - SfxItemSet aTextSet(pWrtShell->GetView().GetPool(), - svl::Items<RES_CHRATR_BEGIN, RES_CHRATR_END - 1>{}); - SvxFontItem aFont(RES_CHRATR_FONT); - aFont.SetFamilyName("Liberation Serif"); - aTextSet.Put(aFont); - SvxFontHeightItem aHeight(400, 100, RES_CHRATR_FONTSIZE); - aTextSet.Put(aHeight); - SvxPostureItem aItalic(ITALIC_NORMAL, RES_CHRATR_POSTURE); - aTextSet.Put(aItalic); - pWrtShell->SetAttrSet(aTextSet); - - // Insert the text. - pWrtShell->Insert2("HHH"); - - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 1 - // - Actual : 2 - // i.e. the italic string was broken into 2 lines, while Word kept it in a single line. - assertXPath(pXmlDoc, "/root/page/body/txt[1]/LineBreak", 1); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testContinuousEndnotesInsertPageAtStart) -{ - // Create a new document with CONTINUOUS_ENDNOTES enabled. - SwDoc* pDoc = createDoc(); - pDoc->getIDocumentSettingAccess().set(DocumentSettingId::CONTINUOUS_ENDNOTES, true); - - // Insert a second page, and an endnote on the 2nd page (both the anchor and the endnote is on - // the 2nd page). - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - pWrtShell->InsertPageBreak(); - pWrtShell->InsertFootnote("endnote", /*bEndNote=*/true, /*bEdit=*/false); - - // Add a new page at the start of the document. - pWrtShell->SttEndDoc(/*bStart=*/true); - pWrtShell->InsertPageBreak(); - - // Make sure that the endnote is moved from the 2nd page to the 3rd one. - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - assertXPath(pXmlDoc, "/root/page", 3); - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 1 - // - Actual : 0 - // i.e. the footnote container remained on page 2. - assertXPath(pXmlDoc, "/root/page[3]/ftncont", 1); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testContinuousEndnotesDeletePageAtStart) -{ - // Create a new document with CONTINUOUS_ENDNOTES enabled. - SwDoc* pDoc = createDoc(); - pDoc->getIDocumentSettingAccess().set(DocumentSettingId::CONTINUOUS_ENDNOTES, true); - - // Insert a second page, and an endnote on the 2nd page (both the anchor and the endnote is on - // the 2nd page). - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - pWrtShell->InsertPageBreak(); - pWrtShell->InsertFootnote("endnote", /*bEndNote=*/true, /*bEdit=*/false); - - // Remove the empty page at the start of the document. - pWrtShell->SttEndDoc(/*bStart=*/true); - pWrtShell->DelRight(); - - // Make sure that the endnote is moved from the 2nd page to the 1st one. - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 1 - // - Actual : 2 - // i.e. the endnote remained on an (otherwise) empty 2nd page. - assertXPath(pXmlDoc, "/root/page", 1); - assertXPath(pXmlDoc, "/root/page[1]/ftncont", 1); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf128399) -{ - SwDoc* pDoc = createDoc("tdf128399.docx"); - SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); - SwFrame* pPage = pLayout->GetLower(); - SwFrame* pBody = pPage->GetLower(); - SwFrame* pTable = pBody->GetLower(); - SwFrame* pRow1 = pTable->GetLower(); - SwFrame* pRow2 = pRow1->GetNext(); - const SwRect& rRow2Rect = pRow2->getFrameArea(); - Point aPoint = rRow2Rect.Center(); - - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - SwPosition aPosition = *pWrtShell->GetCursor()->Start(); - SwPosition aFirstRow(aPosition); - SwCursorMoveState aState(CursorMoveState::NONE); - pLayout->GetModelPositionForViewPoint(&aPosition, aPoint, &aState); - // Second row is +3: end node, start node and the first text node in the 2nd row. - sal_uLong nExpected = aFirstRow.nNode.GetIndex() + 3; - - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 14 - // - Actual : 11 - // i.e. clicking on the center of the 2nd row placed the cursor in the 1st row. - CPPUNIT_ASSERT_EQUAL(nExpected, aPosition.nNode.GetIndex()); + // Test the first level of horizontal category axis labels orientation. The first level orientation should be vertical. + sal_Int32 nRotation = getXPath(pXmlDoc, "(//font)[1]", "orientation").toInt32(); + CPPUNIT_ASSERT(nRotation >= 899); + CPPUNIT_ASSERT(nRotation <= 900); + // Test the second level of horizontal category axis labels orientation. The second level orientation should be horizontal. + assertXPath(pXmlDoc, "(//font)[5]", "orientation", u"0"); + // Test the third level of horizontal category axis labels orientation. The third level orientation should be horizontal. + assertXPath(pXmlDoc, "(//font)[7]", "orientation", u"0"); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf105481) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testHorizontal_multilevel) { - createDoc("tdf105481.odt"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - CPPUNIT_ASSERT(pXmlDoc); + createSwDoc("horizontal_multilevel.odt"); + SwDocShell* pShell = getSwDocShell(); - // Without the accompanying fix in place, this test would have failed - // because the vertical position of the as-char shape object and the - // as-char math object will be wrong (below/beyond the text frame's bottom). - - SwTwips nTxtTop = getXPath(pXmlDoc, - "/root/page/anchored/fly/txt[2]" - "/infos/bounds", - "top") - .toInt32(); - SwTwips nTxtBottom = nTxtTop - + getXPath(pXmlDoc, - "/root/page/anchored/fly/txt[2]" - "/infos/bounds", - "height") - .toInt32(); - - SwTwips nFormula1Top = getXPath(pXmlDoc, - "/root/page/anchored/fly/txt[2]" - "/anchored/fly[1]/infos/bounds", - "top") - .toInt32(); - SwTwips nFormula1Bottom = nFormula1Top - + getXPath(pXmlDoc, - "/root/page/anchored/fly/txt[2]" - "/anchored/fly[1]/infos/bounds", - "height") - .toInt32(); - - SwTwips nFormula2Top = getXPath(pXmlDoc, - "/root/page/anchored/fly/txt[2]" - "/anchored/fly[2]/infos/bounds", - "top") - .toInt32(); - SwTwips nFormula2Bottom = nFormula2Top - + getXPath(pXmlDoc, - "/root/page/anchored/fly/txt[2]" - "/anchored/fly[2]/infos/bounds", - "height") - .toInt32(); - - // Ensure that the two formula positions are at least between top and bottom of the text frame. - // The below two are satisfied even without the fix. - CPPUNIT_ASSERT_GREATEREQUAL(nTxtTop, nFormula1Top); - CPPUNIT_ASSERT_GREATEREQUAL(nTxtTop, nFormula2Top); - - // Without the accompanying fix in place, this test would have failed with: - // - Expected less than or equal to : 14423 - // - Actual : 14828 - // that is, the formula is below the text-frame's y bound. - CPPUNIT_ASSERT_LESSEQUAL(nTxtBottom, nFormula1Bottom); - // Similarly for formula # 2 : - // - Expected less than or equal to : 14423 - // - Actual : 15035 - // that is, the formula is below the text-frame's y bound. - CPPUNIT_ASSERT_LESSEQUAL(nTxtBottom, nFormula2Bottom); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf117982) -{ - SwDoc* pDocument = createDoc("tdf117982.docx"); - SwDocShell* pShell = pDocument->GetDocShell(); + // Dump the rendering of the first page as an XML file. std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); MetafileXmlDump dumper; xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); - assertXPathContent(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/textarray[1]/text", "FOO AAA"); - //The first cell must be "FOO AAA". If not, this means the first cell content not visible in - //the source document. -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf128959) -{ - // no orphan/widow control in table cells - SwDoc* pDocument = createDoc("tdf128959.docx"); - CPPUNIT_ASSERT(pDocument); - discardDumpedLayout(); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - - // first two lines of the paragraph in the split table cell on the first page - // (these lines were completely lost) - assertXPath( - pXmlDoc, "/root/page[1]/body/tab[1]/row[1]/cell[1]/txt[1]/LineBreak[1]", "Line", - "a)Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue "); - assertXPath( - pXmlDoc, "/root/page[1]/body/tab[1]/row[1]/cell[1]/txt[1]/LineBreak[2]", "Line", - "massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit "); - // last line of the paragraph in the split table cell on the second page - assertXPath(pXmlDoc, "/root/page[2]/body/tab[1]/row[1]/cell[1]/txt[1]/LineBreak[1]", "Line", - "amet commodo magna eros quis urna."); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf121658) -{ - uno::Reference<linguistic2::XHyphenator> xHyphenator = LinguMgr::GetHyphenator(); - if (!xHyphenator->hasLocale(lang::Locale("en", "US", OUString()))) - return; - - createDoc("tdf121658.odt"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - - // Only 2 hyphenated words should appear in the document (in the lowercase words). - // Uppercase words should not be hyphenated. - assertXPath(pXmlDoc, "//Special[@nType='PortionType::Hyphen']", 2); + CPPUNIT_ASSERT(pXmlDoc); + // Test the Y position of horizontal category axis label. + sal_Int32 nYposition = getXPath(pXmlDoc, "(//textarray)[7]", "y").toInt32(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(11248, nYposition, 20); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testWriterImageNoCapture) +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf69648) { - createDoc("writer-image-no-capture.docx"); + createSwDoc("tdf69648.docx"); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); CPPUNIT_ASSERT(pXmlDoc); - sal_Int32 nPageLeft = getXPath(pXmlDoc, "//page/infos/bounds", "left").toInt32(); - sal_Int32 nImageLeft = getXPath(pXmlDoc, "//fly/infos/bounds", "left").toInt32(); - // Without the accompanying fix in place, this test would have failed with: - // - Expected less than: 284 - // - Actual : 284 - // i.e. the image position was modified to be inside the page frame ("captured"), even if Word - // does not do that. - CPPUNIT_ASSERT_LESS(nPageLeft, nImageLeft); -} -static SwRect lcl_getVisibleFlyObjRect(SwWrtShell* pWrtShell) -{ - SwRootFrame* pRoot = pWrtShell->GetLayout(); - SwPageFrame* pPage = static_cast<SwPageFrame*>(pRoot->GetLower()); - pPage = static_cast<SwPageFrame*>(pPage->GetNext()); - pPage = static_cast<SwPageFrame*>(pPage->GetNext()); - SwSortedObjs* pDrawObjs = pPage->GetDrawObjs(); - CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDrawObjs->size()); - SwAnchoredObject* pDrawObj = (*pDrawObjs)[0]; - CPPUNIT_ASSERT_EQUAL(OUString("Rahmen8"), pDrawObj->GetFrameFormat().GetName()); - pPage = static_cast<SwPageFrame*>(pPage->GetNext()); - pDrawObjs = pPage->GetDrawObjs(); - CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDrawObjs->size()); - pDrawObj = (*pDrawObjs)[0]; - CPPUNIT_ASSERT_EQUAL(OUString("Rahmen123"), pDrawObj->GetFrameFormat().GetName()); - SwRect aFlyRect = pDrawObj->GetObjRect(); - CPPUNIT_ASSERT(pPage->getFrameArea().IsInside(aFlyRect)); - return aFlyRect; -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testStableAtPageAnchoredFlyPosition) -{ - // this doc has two page-anchored frames: one tiny on page 3 and one large on page 4. - // it also has a style:master-page named "StandardEntwurf", which contains some fields. - // if you add a break to page 2, or append some text to page 4 (or just toggle display field names), - // the page anchored frame on page 4 vanishes, as it is incorrectly moved out of the page bounds. - SwDoc* pDoc = createDoc("stable-at-page-anchored-fly-position.odt"); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - - // look up the layout position of the page-bound frame on page four - SwRect aOrigRect = lcl_getVisibleFlyObjRect(pWrtShell); - - // append some text to the document to trigger bug / relayout - pWrtShell->SttEndDoc(false); - pWrtShell->Insert("foo"); - - // get the current position of the frame on page four - SwRect aRelayoutRect = lcl_getVisibleFlyObjRect(pWrtShell); - - // the anchored frame should not have moved - CPPUNIT_ASSERT_EQUAL(aOrigRect, aRelayoutRect); -} - -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf134548) -{ - createDoc("tdf134548.odt"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + const char* sShapeXPath[2] = { + "/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObjGroup/SdrObjList/SdrObject[1]", + "/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObjGroup/SdrObjList/SdrObject[2]" + }; + const char* sFrameXPath[2] = { "/root/page/body/txt/anchored/fly[1]/infos/bounds", + "/root/page/body/txt/anchored/fly[2]/infos/bounds" }; - // Second paragraph has two non zero width tabs in beginning of line + for (int i = 0; i < 2; ++i) { - OUString sNodeType = parseDump("/root/page/body/txt[2]/Text[1]", "nType"); - CPPUNIT_ASSERT_EQUAL(OUString("PortionType::TabLeft"), sNodeType); - sal_Int32 nWidth = parseDump("/root/page/body/txt[2]/Text[1]", "nWidth").toInt32(); - CPPUNIT_ASSERT_GREATER(sal_Int32(0), nWidth); - } - { - OUString sNodeType = parseDump("/root/page/body/txt[2]/Text[2]", "nType"); - CPPUNIT_ASSERT_EQUAL(OUString("PortionType::TabLeft"), sNodeType); - sal_Int32 nWidth = parseDump("/root/page/body/txt[2]/Text[2]", "nWidth").toInt32(); - CPPUNIT_ASSERT_GREATER(sal_Int32(0), nWidth); + const auto sDrawRect = getXPath(pXmlDoc, sShapeXPath[i], "aOutRect"); + const auto nComaPos1 = sDrawRect.indexOf(',', 0); + const auto nComaPos2 = sDrawRect.indexOf(',', nComaPos1 + 1); + const auto nComaPos3 = sDrawRect.indexOf(',', nComaPos2 + 1); + + const auto nDraw1 = o3tl::toInt64(sDrawRect.subView(0, nComaPos1)); + const auto nDraw2 = o3tl::toInt64(sDrawRect.subView(nComaPos1 + 1, nComaPos2 - nComaPos1)); + const auto nDraw3 = o3tl::toInt64(sDrawRect.subView(nComaPos2 + 1, nComaPos3 - nComaPos2)); + const auto nDraw4 = o3tl::toInt64( + sDrawRect.subView(nComaPos3 + 1, sDrawRect.getLength() - nComaPos3 - 1)); + const auto aChildShape = SwRect(nDraw1, nDraw2, nDraw3, nDraw4); + + const auto nFlyLeft = getXPath(pXmlDoc, sFrameXPath[i], "left").toInt64(); + const auto nFlyTop = getXPath(pXmlDoc, sFrameXPath[i], "top").toInt64(); + const auto nFlyWidth = getXPath(pXmlDoc, sFrameXPath[i], "width").toInt64(); + const auto nFlyHeight = getXPath(pXmlDoc, sFrameXPath[i], "height").toInt64(); + + const auto aFrame = SwRect(nFlyLeft, nFlyTop, nFlyWidth, nFlyHeight); + + CPPUNIT_ASSERT_MESSAGE("Textbox must be inside the shape!", aChildShape.Contains(aFrame)); } } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf124423) -{ - createDoc("tdf124423.docx"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - sal_Int32 nFly1Width = getXPath(pXmlDoc, "(//fly)[1]/infos/prtBounds", "width").toInt32(); - sal_Int32 nFly2Width = getXPath(pXmlDoc, "(//fly)[2]/infos/prtBounds", "width").toInt32(); - sal_Int32 nPageWidth = getXPath(pXmlDoc, "//page/infos/prtBounds", "width").toInt32(); - CPPUNIT_ASSERT_EQUAL(nPageWidth, nFly2Width); - CPPUNIT_ASSERT_LESS(nPageWidth / 2, nFly1Width); - - createDoc("tdf124423.odt"); - pXmlDoc = parseLayoutDump(); - nFly1Width = getXPath(pXmlDoc, "(//fly)[1]/infos/prtBounds", "width").toInt32(); - nFly2Width = getXPath(pXmlDoc, "(//fly)[2]/infos/prtBounds", "width").toInt32(); - nPageWidth = getXPath(pXmlDoc, "//page/infos/prtBounds", "width").toInt32(); - CPPUNIT_ASSERT_LESS(nPageWidth / 2, nFly2Width); - CPPUNIT_ASSERT_LESS(nPageWidth / 2, nFly1Width); -} +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf116256) +{ + // Open bugdoc + createSwDoc("tdf116256.docx"); + + // Get the textbox + uno::Reference<beans::XPropertySet> xTextBox(getShape(2), uno::UNO_QUERY_THROW); + + // Ensure that is a real textbox, and follows the text flow + CPPUNIT_ASSERT(xTextBox->getPropertyValue(u"TextBox"_ustr).get<bool>()); + CPPUNIT_ASSERT(xTextBox->getPropertyValue(u"IsFollowingTextFlow"_ustr).get<bool>()); + + // Parse the layout + auto pLayout = parseLayoutDump(); + // Get the position of the shape + const auto nCellLeft + = getXPath(pLayout, "//page/body/txt/anchored/fly/tab/row[1]/cell/infos/bounds", "left") + .toInt64(); + const auto nCellTop + = getXPath(pLayout, "//page/body/txt/anchored/fly/tab/row[1]/cell/infos/bounds", "top") + .toInt64(); + // Get the position of the textframe too. + const auto nTextBoxFrameLeft + = getXPath(pLayout, + "/root/page/body/txt/anchored/fly/tab/row[1]/cell/txt/anchored/fly/infos/bounds", + "left") + .toInt64(); + const auto nTextBoxFrameTop + = getXPath(pLayout, + "/root/page/body/txt/anchored/fly/tab/row[1]/cell/txt/anchored/fly/infos/bounds", + "top") + .toInt64(); -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf137185) -{ - // First load the sample bugdoc - load(DATA_DIRECTORY, "tdf137185.odt"); - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - // Get the doc shell - SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc()); - - // Get the DrawObject from page - auto pModel = pDoc->getIDocumentDrawModelAccess().GetDrawModel(); - CPPUNIT_ASSERT(pModel); - auto pPage = pModel->GetPage(0); - CPPUNIT_ASSERT(pModel); - auto pObj = pPage->GetObj(0); - CPPUNIT_ASSERT(pObj); - - // Get the format of the draw object - auto pShape = FindFrameFormat(pObj); - CPPUNIT_ASSERT(pShape); - - // Check the text of the shape - uno::Reference<text::XText> xTxt(getShape(1), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("Align me!"), xTxt->getText()->getString()); - - // Add a textbox to the shape - SwTextBoxHelper::create(pShape, true); - - // Check if the text moved from the shape to the frame - auto pFormat = SwTextBoxHelper::getOtherTextBoxFormat(getShape(1)); - auto xTextFrame = SwXTextFrame::CreateXTextFrame(*pFormat->GetDoc(), pFormat); - - CPPUNIT_ASSERT_EQUAL(OUString("Align me!"), xTextFrame->getText()->getString()); - SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(pObj); - CPPUNIT_ASSERT(pTextObj); - auto aOutStr = pTextObj->GetOutlinerParaObject()->GetTextObject(); - - CPPUNIT_ASSERT(aOutStr.GetText(0).isEmpty()); - // Before the patch it failed, because the text appeared 2 times on each other. + // Without the fix in place these were less than they supposed to. + CPPUNIT_ASSERT_GREATEREQUAL(nCellLeft, nTextBoxFrameLeft); + CPPUNIT_ASSERT_GREATEREQUAL(nCellTop, nTextBoxFrameTop); } -CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf135035) -{ - createDoc("tdf135035.docx"); - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - sal_Int32 nFly1Width = getXPath(pXmlDoc, "(//fly)[1]/infos/prtBounds", "width").toInt32(); - sal_Int32 nFly2Width = getXPath(pXmlDoc, "(//fly)[2]/infos/prtBounds", "width").toInt32(); - sal_Int32 nFly3Width = getXPath(pXmlDoc, "(//fly)[3]/infos/prtBounds", "width").toInt32(); - sal_Int32 nParentWidth = getXPath(pXmlDoc, "(//txt)[1]/infos/prtBounds", "width").toInt32(); - CPPUNIT_ASSERT_EQUAL(nParentWidth, nFly2Width); - CPPUNIT_ASSERT_EQUAL(nParentWidth, nFly3Width); - CPPUNIT_ASSERT_LESS(nParentWidth / 2, nFly1Width); - - createDoc("tdf135035.odt"); - pXmlDoc = parseLayoutDump(); - nFly1Width = getXPath(pXmlDoc, "(//fly)[1]/infos/prtBounds", "width").toInt32(); - nFly2Width = getXPath(pXmlDoc, "(//fly)[2]/infos/prtBounds", "width").toInt32(); - nFly3Width = getXPath(pXmlDoc, "(//fly)[3]/infos/prtBounds", "width").toInt32(); - nParentWidth = getXPath(pXmlDoc, "(//txt)[1]/infos/prtBounds", "width").toInt32(); - CPPUNIT_ASSERT_LESS(nParentWidth / 2, nFly2Width); - CPPUNIT_ASSERT_LESS(nParentWidth / 2, nFly1Width); - CPPUNIT_ASSERT_GREATER(nParentWidth, nFly3Width); -} +CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |