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/unoapi_test.hxx>
12 #include <com/sun/star/beans/XPropertySet.hpp>
13 #include <com/sun/star/beans/XPropertyState.hpp>
14 #include <com/sun/star/text/XTextDocument.hpp>
16 using namespace ::com::sun::star
;
20 /// Tests for writerfilter/source/rtftok/rtfsprm.cxx.
21 class Test
: public UnoApiTest
25 : UnoApiTest("/writerfilter/qa/cppunittests/rtftok/data/")
30 CPPUNIT_TEST_FIXTURE(Test
, testLeftMarginDedup
)
32 loadFromFile(u
"left-margin-dedup.rtf");
33 uno::Reference
<text::XTextDocument
> xTextDocument(mxComponent
, uno::UNO_QUERY
);
34 uno::Reference
<container::XEnumerationAccess
> xText(xTextDocument
->getText(), uno::UNO_QUERY
);
35 uno::Reference
<container::XEnumeration
> xParagraphs
= xText
->createEnumeration();
36 uno::Reference
<beans::XPropertySet
> xParagraph(xParagraphs
->nextElement(), uno::UNO_QUERY
);
37 sal_Int32 nLeftMargin
= 0;
38 xParagraph
->getPropertyValue("ParaLeftMargin") >>= nLeftMargin
;
39 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1270), nLeftMargin
);
41 uno::Reference
<beans::XPropertyState
> xParagraphState(xParagraph
, uno::UNO_QUERY
);
42 CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE
,
43 xParagraphState
->getPropertyState("ParaLeftMargin"));
45 xParagraph
.set(xParagraphs
->nextElement(), uno::UNO_QUERY
);
47 xParagraph
->getPropertyValue("ParaLeftMargin") >>= nLeftMargin
;
48 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1270), nLeftMargin
);
50 xParagraphState
.set(xParagraph
, uno::UNO_QUERY
);
51 // Without the accompanying fix in place, this test would have failed with:
52 // - Expected: 0 (DIRECT_VALUE)
53 // - Actual : 1 (DEFAULT_VALUE)
54 // i.e. the left margin was not a direct formatting, which means left margin from the numbering
56 CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE
,
57 xParagraphState
->getPropertyState("ParaLeftMargin"));
61 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */