| 1 |
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 |
/* |
| 3 |
* This file is part of the LibreOffice project. |
| 4 |
* |
| 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/. |
| 8 |
*/ |
| 9 |
|
| 10 |
#include <test/unoapixml_test.hxx> |
| 11 |
|
| 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> |
| 17 |
|
| 18 |
using namespace ::com::sun::star; |
| 19 |
|
| 20 |
namespace |
| 21 |
{ |
| 22 |
/// Tests for sw/source/writerfilter/filter/WriterFilter.cxx. |
| 23 |
class Test : public UnoApiXmlTest |
| 24 |
{ |
| 25 |
public: |
| 26 |
Test() |
| 27 |
: UnoApiXmlTest(u"/sw/qa/writerfilter/filter/data/"_ustr) |
| 28 |
{ |
| 29 |
} |
| 30 |
}; |
| 31 |
|
| 32 |
CPPUNIT_TEST_FIXTURE(Test, testDoNotMirrorRtlDrawObjs) |
| 33 |
{ |
| 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"); |
| 37 |
|
| 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(u"layout"_ustr).toUtf8(); |
| 42 |
auto pCharBuffer = reinterpret_cast<const xmlChar*>(aDump.getStr()); |
| 43 |
xmlDocUniquePtr pXmlDoc(xmlParseDoc(pCharBuffer)); |
| 44 |
sal_Int32 nBodyRight = getXPath(pXmlDoc, "//body/infos/bounds", "right").toInt32(); |
| 45 |
sal_Int32 nShapeLeft = getXPath(pXmlDoc, "//SwAnchoredDrawObject/bounds", "left").toInt32(); |
| 46 |
// Without the accompanying fix in place, this test would have failed with: |
| 47 |
// - Expected greater than: 11083 |
| 48 |
// - Actual : 722 |
| 49 |
// i.e. the shape was on the left margin. |
| 50 |
CPPUNIT_ASSERT_GREATER(nBodyRight, nShapeLeft); |
| 51 |
} |
| 52 |
|
| 53 |
CPPUNIT_TEST_FIXTURE(Test, testInlineEndnoteAndFootnoteDOCX) |
| 54 |
{ |
| 55 |
// Given a DOCX file with an endnote and then a footnote: |
| 56 |
loadFromFile(u"inline-endnote-and-footnote.docx"); |
| 57 |
|
| 58 |
// When laying out that document: |
| 59 |
uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); |
| 60 |
css::uno::Reference<qa::XDumper> xDumper(xModel->getCurrentController(), uno::UNO_QUERY); |
| 61 |
OString aDump = xDumper->dump(u"layout"_ustr).toUtf8(); |
| 62 |
auto pCharBuffer = reinterpret_cast<const xmlChar*>(aDump.getStr()); |
| 63 |
xmlDocUniquePtr pXmlDoc(xmlParseDoc(pCharBuffer)); |
| 64 |
|
| 65 |
// Then make sure the footnote is below the endnote: |
| 66 |
// Without the accompanying fix in place, this test would have failed with: |
| 67 |
// - xpath should match exactly 1 node |
| 68 |
// i.e. the endnote was also in the footnote container, not at the end of the body text. |
| 69 |
sal_Int32 nEndnoteTop |
| 70 |
= getXPath(pXmlDoc, "/root/page/body/section/column/ftncont/ftn/infos/bounds", "top") |
| 71 |
.toInt32(); |
| 72 |
sal_Int32 nFootnoteTop |
| 73 |
= getXPath(pXmlDoc, "/root/page/ftncont/ftn/infos/bounds", "top").toInt32(); |
| 74 |
// Endnote at the end of body text, footnote at page bottom. |
| 75 |
CPPUNIT_ASSERT_LESS(nFootnoteTop, nEndnoteTop); |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
CPPUNIT_PLUGIN_IMPLEMENT(); |
| 80 |
|
| 81 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |