[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - sw/qa writerfilter/source
Miklos Vajna
vmiklos at suse.cz
Mon Jul 8 01:53:27 PDT 2013
sw/qa/extras/rtfimport/data/fdo39001.rtf | 22 ++++++++++++++++++++++
sw/qa/extras/rtfimport/rtfimport.cxx | 8 ++++++++
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 12 +++++++-----
3 files changed, 37 insertions(+), 5 deletions(-)
New commits:
commit 5430b9e0f4082025ff9bf7621d18292db0361121
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Fri Jul 5 11:37:24 2013 +0200
fdo#39001 RTF import: fix fake empty page at the end of the doc
In case we have a \sect, there was no \sbknone (so it counts as a page
break as well) and there is nothing after it, we should not make extra
efforts to make that have some effect, but adding at least one empty
paragraph to that new page.
(cherry picked from commit 4108f285207ed4a60c8876a8206bc5f2d7f05620)
Conflicts:
sw/qa/extras/rtfimport/rtfimport.cxx
Change-Id: Ibcbecabcb590ed34ef96a97698e4ab8f638d3483
Reviewed-on: https://gerrit.libreoffice.org/4737
Reviewed-by: Fridrich Strba <fridrich at documentfoundation.org>
Tested-by: Fridrich Strba <fridrich at documentfoundation.org>
diff --git a/sw/qa/extras/rtfimport/data/fdo39001.rtf b/sw/qa/extras/rtfimport/data/fdo39001.rtf
new file mode 100644
index 0000000..939b21d
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo39001.rtf
@@ -0,0 +1,22 @@
+{\rtf1 \ansi
+{\*\generator Apache XML Graphics RTF Library;}
+\fet0 \ftnbj \paperw11905 \paperh16837 \margt2267 \margb1133 \margl1417 \margr1417 \headery2267 \footery1984 \itap0
+\sectd
+{\li0 \f3 \b0 \ql \ri0 \fs24 \cf1 \i0
+{\f3 \strike0 \ul0 \b0 \sa0 \sb0 \fs24 \cf1 \i0
+FIRST PAGE
+\par
+}
+}\sect \sbkpage
+{\li0 \f3 \b0 \ql \ri0 \fs24 \cf1 \i0
+{\f3 \strike0 \ul0 \b0 \sa0 \sb0 \fs24 \cf1 \i0
+NEXT PAGE
+\par
+}
+}
+{\li0 \f3 \sbkpage \b0 \ql \sect \ri0 \fs24 \cf1 \i0
+{\f3 \strike0 \ul0 \b0 \sa0 \sb0 \fs24 \cf1 \i0
+LAST PAGE
+\par
+}
+}\sect }
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 76967db..80b52ef 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -142,6 +142,7 @@ public:
void testN825305();
void testParaBottomMargin();
void testN823655();
+ void testFdo39001();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -272,6 +273,7 @@ void Test::run()
{"n825305.rtf", &Test::testN825305},
{"para-bottom-margin.rtf", &Test::testParaBottomMargin},
{"n823655.rtf", &Test::testN823655},
+ {"fdo39001.rtf", &Test::testFdo39001},
};
header();
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1310,6 +1312,12 @@ void Test::testN823655()
CPPUNIT_ASSERT_EQUAL(sal_Int32(286), aCoordinates[0].Second.Value.get<sal_Int32>());
}
+void Test::testFdo39001()
+{
+ // Document was of 4 pages, \sect at the end of the doc wasn't ignored.
+ CPPUNIT_ASSERT_EQUAL(3, getPages());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 80db68d..1e0803a 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -505,8 +505,11 @@ void RTFDocumentImpl::sectBreak(bool bFinal = false)
{
SAL_INFO("writerfilter", OSL_THIS_FUNC << ": final? " << bFinal << ", needed? " << m_bNeedSect);
bool bNeedSect = m_bNeedSect;
- // If there is no paragraph in this section, then insert a dummy one, as required by Writer
- if (m_bNeedPar)
+ RTFValue::Pointer_t pBreak = m_aStates.top().aSectionSprms.find(NS_sprm::LN_SBkc);
+ bool bContinuous = pBreak.get() && pBreak->getInt() == 0;
+ // If there is no paragraph in this section, then insert a dummy one, as required by Writer,
+ // unless this is the end of the doc, we had nothing since the last section break and this is not a continuous one.
+ if (m_bNeedPar && !(bFinal && !m_bNeedSect && !bContinuous))
dispatchSymbol(RTF_PAR);
// It's allowed to not have a non-table paragraph at the end of an RTF doc, add it now if required.
if (m_bNeedFinalPar && bFinal)
@@ -525,9 +528,8 @@ void RTFDocumentImpl::sectBreak(bool bFinal = false)
// last control word in the document is a section break itself.
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.
- if (bFinal && pBreak.get() && !pBreak->getInt())
+ // In case the last section is a continuous one, we don't need to output a section break.
+ if (bFinal && bContinuous)
m_aStates.top().aSectionSprms.erase(NS_sprm::LN_SBkc);
}
More information about the Libreoffice-commits
mailing list