1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <test/unoapixml_test.hxx>
12 #include <com/sun/star/beans/XPropertySet.hpp>
13 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
14 #include <com/sun/star/drawing/ColorMode.hpp>
15 #include <com/sun/star/text/TextContentAnchorType.hpp>
16 #include <com/sun/star/qa/XDumper.hpp>
18 using namespace ::com::sun::star
;
22 /// Tests for writerfilter/source/filter/WriterFilter.cxx.
23 class Test
: public UnoApiXmlTest
27 : UnoApiXmlTest("/writerfilter/qa/cppunittests/filter/data/")
32 CPPUNIT_TEST_FIXTURE(Test
, testDoNotMirrorRtlDrawObjs
)
34 // Given a document with a shape, anchored in an RTL paragraph:
35 // When loading that document:
36 loadFromFile(u
"draw-obj-rtl-no-mirror.docx");
38 // Then make sure the shape is on the right margin:
39 uno::Reference
<frame::XModel
> xModel(mxComponent
, uno::UNO_QUERY
);
40 css::uno::Reference
<qa::XDumper
> xDumper(xModel
->getCurrentController(), uno::UNO_QUERY
);
41 OString aDump
= xDumper
->dump("layout").toUtf8();
42 auto pCharBuffer
= reinterpret_cast<const xmlChar
*>(aDump
.getStr());
43 xmlDocUniquePtr
pXmlDoc(xmlParseDoc(pCharBuffer
));
44 sal_Int32 nBodyRight
= getXPath(pXmlDoc
, "//body/infos/bounds"_ostr
, "right"_ostr
).toInt32();
46 = getXPath(pXmlDoc
, "//SwAnchoredDrawObject/bounds"_ostr
, "left"_ostr
).toInt32();
47 // Without the accompanying fix in place, this test would have failed with:
48 // - Expected greater than: 11083
50 // i.e. the shape was on the left margin.
51 CPPUNIT_ASSERT_GREATER(nBodyRight
, nShapeLeft
);
54 CPPUNIT_TEST_FIXTURE(Test
, testInlineEndnoteAndFootnoteDOCX
)
56 // Given a DOCX file with an endnote and then a footnote:
57 loadFromFile(u
"inline-endnote-and-footnote.docx");
59 // When laying out that document:
60 uno::Reference
<frame::XModel
> xModel(mxComponent
, uno::UNO_QUERY
);
61 css::uno::Reference
<qa::XDumper
> xDumper(xModel
->getCurrentController(), uno::UNO_QUERY
);
62 OString aDump
= xDumper
->dump("layout").toUtf8();
63 auto pCharBuffer
= reinterpret_cast<const xmlChar
*>(aDump
.getStr());
64 xmlDocUniquePtr
pXmlDoc(xmlParseDoc(pCharBuffer
));
66 // Then make sure the footnote is below the endnote:
67 // Without the accompanying fix in place, this test would have failed with:
68 // - xpath should match exactly 1 node
69 // i.e. the endnote was also in the footnote container, not at the end of the body text.
71 = getXPath(pXmlDoc
, "/root/page/body/section/column/ftncont/ftn/infos/bounds"_ostr
,
74 sal_Int32 nFootnoteTop
75 = getXPath(pXmlDoc
, "/root/page/ftncont/ftn/infos/bounds"_ostr
, "top"_ostr
).toInt32();
76 // Endnote at the end of body text, footnote at page bottom.
77 CPPUNIT_ASSERT_LESS(nFootnoteTop
, nEndnoteTop
);
81 CPPUNIT_PLUGIN_IMPLEMENT();
83 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */