| 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/unoapi_test.hxx> |
| 11 |
|
| 12 |
#include <com/sun/star/beans/XPropertySet.hpp> |
| 13 |
#include <com/sun/star/beans/XPropertyState.hpp> |
| 14 |
#include <com/sun/star/text/XTextDocument.hpp> |
| 15 |
|
| 16 |
using namespace ::com::sun::star; |
| 17 |
|
| 18 |
namespace |
| 19 |
{ |
| 20 |
/// Tests for sw/source/writerfilter/rtftok/rtfsprm.cxx. |
| 21 |
class Test : public UnoApiTest |
| 22 |
{ |
| 23 |
public: |
| 24 |
Test() |
| 25 |
: UnoApiTest(u"/sw/qa/writerfilter/rtftok/data/"_ustr) |
| 26 |
{ |
| 27 |
} |
| 28 |
}; |
| 29 |
|
| 30 |
CPPUNIT_TEST_FIXTURE(Test, testLeftMarginDedup) |
| 31 |
{ |
| 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(u"ParaLeftMargin"_ustr) >>= nLeftMargin; |
| 39 |
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1270), nLeftMargin); |
| 40 |
|
| 41 |
uno::Reference<beans::XPropertyState> xParagraphState(xParagraph, uno::UNO_QUERY); |
| 42 |
CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE, |
| 43 |
xParagraphState->getPropertyState(u"ParaLeftMargin"_ustr)); |
| 44 |
|
| 45 |
xParagraph.set(xParagraphs->nextElement(), uno::UNO_QUERY); |
| 46 |
nLeftMargin = 0; |
| 47 |
xParagraph->getPropertyValue(u"ParaLeftMargin"_ustr) >>= nLeftMargin; |
| 48 |
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1270), nLeftMargin); |
| 49 |
|
| 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 |
| 55 |
// was used instead. |
| 56 |
CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE, |
| 57 |
xParagraphState->getPropertyState(u"ParaLeftMargin"_ustr)); |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |