summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-04-02 14:10:39 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-04-02 14:27:05 +0200
commit7b58fc3dafc789aa55fff5ffef6ab83c3aa8b6e0 (patch)
treeddc04f0226971f3ebe2ff1f0b9471139bc5c2455
parent8866e1986d354f0eb7eb26d78e6b6a22c6fda632 (diff)
fdo#48104 fix RTF import of \page in inner groups
If we have a postponed page break and it's sent to dmapper during a new inner group, we'll still have the page break request after the parser state is popped, leading to duplicated page breaks. Instead of the earlier workaround, just send the proper token to the domain mapper, and it'll handle it properly.
-rw-r--r--sw/qa/extras/rtftok/data/fdo48104.rtf6
-rw-r--r--sw/qa/extras/rtftok/rtftok.cxx12
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx18
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx2
4 files changed, 23 insertions, 15 deletions
diff --git a/sw/qa/extras/rtftok/data/fdo48104.rtf b/sw/qa/extras/rtftok/data/fdo48104.rtf
new file mode 100644
index 000000000000..64d5e5979e4f
--- /dev/null
+++ b/sw/qa/extras/rtftok/data/fdo48104.rtf
@@ -0,0 +1,6 @@
+{\rtf1
+first page\par
+\page
+{second page first line\par}
+second page second line\par
+}
diff --git a/sw/qa/extras/rtftok/rtftok.cxx b/sw/qa/extras/rtftok/rtftok.cxx
index f13e15dc81b0..7f9b4989e20f 100644
--- a/sw/qa/extras/rtftok/rtftok.cxx
+++ b/sw/qa/extras/rtftok/rtftok.cxx
@@ -75,6 +75,7 @@ public:
void testFdo47036();
void testFdo46955();
void testFdo45394();
+ void testFdo48104();
CPPUNIT_TEST_SUITE(RtfModelTest);
#if !defined(MACOSX) && !defined(WNT)
@@ -93,6 +94,7 @@ public:
CPPUNIT_TEST(testFdo47036);
CPPUNIT_TEST(testFdo46955);
CPPUNIT_TEST(testFdo45394);
+ CPPUNIT_TEST(testFdo48104);
#endif
CPPUNIT_TEST_SUITE_END();
@@ -471,6 +473,16 @@ void RtfModelTest::testFdo45394()
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
}
+void RtfModelTest::testFdo48104()
+{
+ load(OUString(RTL_CONSTASCII_USTRINGPARAM("fdo48104.rtf")));
+ uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+ uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
+ uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
+ xCursor->jumpToLastPage();
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xCursor->getPage());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(RtfModelTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index e63c4512b843..038ead9792d7 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -280,7 +280,6 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
m_bFormField(false),
m_bWasInFrame(false),
m_bIsInFrame(false),
- m_bHasPage(false),
m_aUnicodeBuffer(),
m_aHexBuffer()
{
@@ -424,7 +423,6 @@ void RTFDocumentImpl::checkNeedPap()
{
dispatchSymbol(RTF_PAR);
m_bNeedPap = false;
- m_aStates.top().aParagraphSprms.erase(NS_sprm::LN_PFPageBreakBefore);
}
Mapper().props(pParagraphProperties);
if (hasBreakBeforeFrame)
@@ -1377,12 +1375,6 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
m_bWasInFrame = m_aStates.top().aFrame.inFrame();
if (!m_bWasInFrame)
m_bNeedPar = false;
- if (m_bHasPage)
- {
- // this has to be reset even without a pard, since it's a symbol in RTF terms
- m_aStates.top().aParagraphSprms.erase(NS_sprm::LN_PFPageBreakBefore);
- m_bHasPage = false;
- }
}
break;
case RTF_SECT:
@@ -1506,10 +1498,10 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
break;
case RTF_PAGE:
{
- RTFValue::Pointer_t pValue(new RTFValue(1));
- dispatchSymbol(RTF_PAR);
- m_aStates.top().aParagraphSprms->push_back(make_pair(NS_sprm::LN_PFPageBreakBefore, pValue));
- m_bHasPage = true;
+ sal_uInt8 sBreak[] = { 0xc };
+ Mapper().text(sBreak, 1);
+ if (!m_bNeedPap)
+ parBreak();
}
break;
default:
@@ -1728,7 +1720,7 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
case RTF_KEEP: if (m_pCurrentBuffer != &m_aTableBuffer) nParam = NS_sprm::LN_PFKeep; break;
case RTF_KEEPN: if (m_pCurrentBuffer != &m_aTableBuffer) nParam = NS_sprm::LN_PFKeepFollow; break;
case RTF_INTBL: m_pCurrentBuffer = &m_aTableBuffer; nParam = NS_sprm::LN_PFInTable; break;
- case RTF_PAGEBB: nParam = NS_sprm::LN_PFPageBreakBefore; m_bHasPage = false; break;
+ case RTF_PAGEBB: nParam = NS_sprm::LN_PFPageBreakBefore; break;
default: break;
}
if (nParam >= 0)
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index eb7e27a21fb8..461b88ec96d1 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -473,8 +473,6 @@ namespace writerfilter {
bool m_bWasInFrame;
/// If a frame start token is already sent to dmapper (nesting them is not OK).
bool m_bIsInFrame;
- /// If we should reset the page break property when we start the next paragraph.
- bool m_bHasPage;
// Unicode characters are collected here so we don't have to send them one by one.
rtl::OUStringBuffer m_aUnicodeBuffer;
/// Same for hex characters.