diff options
Diffstat (limited to 'writerfilter/qa/cppunittests/rtftok')
-rw-r--r-- | writerfilter/qa/cppunittests/rtftok/data/old-para-num-left-margin.rtf | 14 | ||||
-rw-r--r-- | writerfilter/qa/cppunittests/rtftok/rtfdocumentimpl.cxx | 25 |
2 files changed, 39 insertions, 0 deletions
diff --git a/writerfilter/qa/cppunittests/rtftok/data/old-para-num-left-margin.rtf b/writerfilter/qa/cppunittests/rtftok/data/old-para-num-left-margin.rtf new file mode 100644 index 000000000000..99825370e3b4 --- /dev/null +++ b/writerfilter/qa/cppunittests/rtftok/data/old-para-num-left-margin.rtf @@ -0,0 +1,14 @@ +{\rtf1\ansi +\margt1497\margb590\margl590\margr590\pgwsxn11906\pghsxn16838 +\pard\plain First\par +\pard\plain +{\*\pn \pnlvlbody +{\pntxtb \'78} +} +{\b\f7\fs22 Second\par} +\pard\plain\li1191 +{\*\pn \pnlvlbody +{\pntxtb \'78} +} +{\f7\fs22 Third, with left indent\par} +} diff --git a/writerfilter/qa/cppunittests/rtftok/rtfdocumentimpl.cxx b/writerfilter/qa/cppunittests/rtftok/rtfdocumentimpl.cxx index 6020453ba783..f33f0f0e58be 100644 --- a/writerfilter/qa/cppunittests/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/qa/cppunittests/rtftok/rtfdocumentimpl.cxx @@ -16,6 +16,7 @@ #include <com/sun/star/graphic/XGraphic.hpp> #include <com/sun/star/text/XTextTablesSupplier.hpp> #include <com/sun/star/text/XTextTable.hpp> +#include <com/sun/star/text/XTextDocument.hpp> #include <vcl/graph.hxx> @@ -119,6 +120,30 @@ CPPUNIT_TEST_FIXTURE(Test, testDuplicatedImage) // i.e. there was a 3rd, duplicated image. CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xDrawPage->getCount()); } + +CPPUNIT_TEST_FIXTURE(Test, testOldParaNumLeftMargin) +{ + // Given a document with 3 paragraphs, the third one with a left indent: + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "old-para-num-left-margin.rtf"; + + // When importing that document: + getComponent() = loadFromDesktop(aURL); + + // Then make sure that the third paragraph has a left indent: + uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xText(xTextDocument->getText(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParagraphs = xText->createEnumeration(); + xParagraphs->nextElement(); + xParagraphs->nextElement(); + uno::Reference<beans::XPropertySet> xParagraph(xParagraphs->nextElement(), uno::UNO_QUERY); + sal_Int32 nParaLeftMargin{}; + xParagraph->getPropertyValue("ParaLeftMargin") >>= nParaLeftMargin; + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 2101 + // - Actual : 0 + // i.e. the left indent was 0, not 1191 twips (from the file) in mm100. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2101), nParaLeftMargin); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |