[Libreoffice-commits] .: Branch 'libreoffice-4-0' - sw/qa writerfilter/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sun Dec 23 07:36:51 PST 2012
sw/qa/extras/rtfimport/data/fdo58076.rtf | 5 +++++
sw/qa/extras/rtfimport/rtfimport.cxx | 12 ++++++++++++
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 6 ++++--
writerfilter/source/rtftok/rtfdocumentimpl.hxx | 2 ++
4 files changed, 23 insertions(+), 2 deletions(-)
New commits:
commit 99894610482eb8f631083c327ca2f0310391eb23
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Sun Dec 23 14:37:59 2012 +0100
fdo#58076 fix import of RTF page margins vs partial section props
The problem was that \sbknone (being a section property) triggered
creating a section, but the document doesn't have multiple sections.
Make sure we don't send section properties as long as no \sect control
words present.
(cherry picked from commit 07c80d23fadcc2334fe7c6f9ce7b5dafeb88d623)
diff --git a/sw/qa/extras/rtfimport/data/fdo58076.rtf b/sw/qa/extras/rtfimport/data/fdo58076.rtf
new file mode 100644
index 0000000..2acbfd8
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo58076.rtf
@@ -0,0 +1,5 @@
+{\rtf1
+\paperw11908\paperh16838\margl1276\margr993\margt360\margb360
+\sectd \sbknone\headery708\footery708
+\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index a2fdf22..da5794f 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -130,6 +130,7 @@ public:
void testFdo54473();
void testFdo49934();
void testFdo57886();
+ void testFdo58076();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -210,6 +211,7 @@ void Test::run()
{"fdo54473.rtf", &Test::testFdo54473},
{"fdo49934.rtf", &Test::testFdo49934},
{"fdo57886.rtf", &Test::testFdo57886},
+ {"fdo58076.rtf", &Test::testFdo58076},
};
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
{
@@ -966,6 +968,16 @@ void Test::testFdo57886()
CPPUNIT_ASSERT_EQUAL(OUString("int from {firstlower} to {firstupper} {firstbody}"), getFormula(getRun(getParagraph(1), 1)));
}
+void Test::testFdo58076()
+{
+ // An additional section was created, so the default page style didn't have the custom margins.
+ uno::Reference<beans::XPropertySet> xStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2251), getProperty<sal_Int32>(xStyle, "LeftMargin"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1752), getProperty<sal_Int32>(xStyle, "RightMargin"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(635), getProperty<sal_Int32>(xStyle, "TopMargin"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(635), getProperty<sal_Int32>(xStyle, "BottomMargin"));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 54390ea..19b02519 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -275,7 +275,8 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
m_bIgnoreNextContSectBreak(false),
m_bNeedSect(true),
m_bWasInFrame(false),
- m_bHadPicture(false)
+ m_bHadPicture(false),
+ m_bHadSect(false)
{
OSL_ASSERT(xInputStream.is());
m_pInStream.reset(utl::UcbStreamHelper::CreateStream(xInputStream, sal_True));
@@ -526,7 +527,7 @@ void RTFDocumentImpl::sectBreak(bool bFinal = false)
// Normally a section break at the end of the doc is necessary. Unless the
// last control word in the document is a section break itself.
- if (!bNeedSect)
+ if (!bNeedSect || !m_bHadSect)
{
RTFValue::Pointer_t pBreak = m_aStates.top().aSectionSprms.find(NS_sprm::LN_SBkc);
// In case the last section is a continous one, we don't need to output a section break.
@@ -1629,6 +1630,7 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
break;
case RTF_SECT:
{
+ m_bHadSect = true;
if (m_bIgnoreNextContSectBreak)
m_bIgnoreNextContSectBreak = false;
else
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 1df8de1..283faec 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -590,6 +590,8 @@ namespace writerfilter {
bool m_bWasInFrame;
/// A picture was seen in the current paragraph.
bool m_bHadPicture;
+ /// The document has multiple sections.
+ bool m_bHadSect;
};
} // namespace rtftok
} // namespace writerfilter
More information about the Libreoffice-commits
mailing list