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/qa/XDumper.hpp>
15 #include <test/xmldocptr.hxx>
17 using namespace com::sun::star
;
21 /// Tests for writerfilter/source/dmapper/SettingsTable.cxx.
22 class Test
: public UnoApiXmlTest
26 : UnoApiXmlTest("/writerfilter/qa/cppunittests/dmapper/data/")
31 CPPUNIT_TEST_FIXTURE(Test
, testDoNotBreakWrappedTables
)
33 // Given a document with <w:doNotBreakWrappedTables>:
34 // When importing that document:
35 loadFromURL(u
"do-not-break-wrapped-tables.docx");
37 // Then make sure that the matching compat flag is set:
38 uno::Reference
<lang::XMultiServiceFactory
> xDocument(mxComponent
, uno::UNO_QUERY
);
39 uno::Reference
<beans::XPropertySet
> xSettings(
40 xDocument
->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY
);
41 bool bDoNotBreakWrappedTables
{};
42 xSettings
->getPropertyValue("DoNotBreakWrappedTables") >>= bDoNotBreakWrappedTables
;
43 // Without the accompanying fix in place, this test would have failed, the compat flag was not
45 CPPUNIT_ASSERT(bDoNotBreakWrappedTables
);
48 CPPUNIT_TEST_FIXTURE(Test
, testAddVerticalFrameOffsetsRTF
)
50 // Given a document with a floating table, immediately followed by an inline table:
51 // When importing that document:
52 loadFromURL(u
"floattable-vertical-frame-offset.rtf");
54 // Then make sure the floating and the inline tables don't overlap:
55 uno::Reference
<frame::XModel
> xModel(mxComponent
, uno::UNO_QUERY
);
56 css::uno::Reference
<qa::XDumper
> xDumper(xModel
->getCurrentController(), uno::UNO_QUERY
);
57 OString aDump
= xDumper
->dump("layout").toUtf8();
58 auto pCharBuffer
= reinterpret_cast<const xmlChar
*>(aDump
.getStr());
59 xmlDocUniquePtr
pXmlDoc(xmlParseDoc(pCharBuffer
));
60 sal_Int32 nFlyBottom
= getXPath(pXmlDoc
, "//fly/infos/bounds", "bottom").toInt32();
61 sal_Int32 nTableFrameTop
= getXPath(pXmlDoc
, "//body/tab/infos/bounds", "top").toInt32();
62 sal_Int32 nTableTopMargin
= getXPath(pXmlDoc
, "//body/tab/infos/prtBounds", "top").toInt32();
63 sal_Int32 nTableTop
= nTableFrameTop
+ nTableTopMargin
;
64 // Without the accompanying fix in place, this test would have failed with:
65 // - Expected greater than: 2747
67 // i.e. table top should be ~2748, but was less, leading to an overlap.
68 CPPUNIT_ASSERT_GREATER(nFlyBottom
, nTableTop
);
72 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */