[Libreoffice-commits] .: 2 commits - sw/qa writerfilter/source
Miklos Vajna
vmiklos at kemper.freedesktop.org
Mon Apr 2 05:26:44 PDT 2012
sw/qa/extras/rtftok/data/fdo48104.rtf | 6 ++++++
sw/qa/extras/rtftok/rtftok.cxx | 25 ++++++++++++++++++++-----
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 18 +++++-------------
writerfilter/source/rtftok/rtfdocumentimpl.hxx | 2 --
4 files changed, 31 insertions(+), 20 deletions(-)
New commits:
commit 0f330ea25840690d05516adc20cfb3d1a9d33317
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Mon Apr 2 14:24:53 2012 +0200
RtfModelTest: introduce common getPages() method
diff --git a/sw/qa/extras/rtftok/rtftok.cxx b/sw/qa/extras/rtftok/rtftok.cxx
index 7f9b498..ac7a2e4 100644
--- a/sw/qa/extras/rtftok/rtftok.cxx
+++ b/sw/qa/extras/rtftok/rtftok.cxx
@@ -103,6 +103,8 @@ private:
void load(const OUString& rURL);
/// Get the length of the whole document.
int getLength();
+ /// Get page count.
+ int getPages();
uno::Reference<lang::XComponent> mxComponent;
};
@@ -130,6 +132,15 @@ int RtfModelTest::getLength()
return aBuf.getLength();
}
+int RtfModelTest::getPages()
+{
+ 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();
+ return xCursor->getPage();
+}
+
void RtfModelTest::setUp()
{
test::BootstrapFixture::setUp();
@@ -382,11 +393,7 @@ void RtfModelTest::testFdo43965()
CPPUNIT_ASSERT_EQUAL(sal_uInt32(26), aBorder.LineWidth);
// Finally, make sure that we have two pages
- 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_ASSERT_EQUAL(2, getPages());
}
void RtfModelTest::testN751020()
@@ -476,11 +483,7 @@ void RtfModelTest::testFdo45394()
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_ASSERT_EQUAL(2, getPages());
}
CPPUNIT_TEST_SUITE_REGISTRATION(RtfModelTest);
commit 7b58fc3dafc789aa55fff5ffef6ab83c3aa8b6e0
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Mon Apr 2 14:10:39 2012 +0200
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.
diff --git a/sw/qa/extras/rtftok/data/fdo48104.rtf b/sw/qa/extras/rtftok/data/fdo48104.rtf
new file mode 100644
index 0000000..64d5e59
--- /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 f13e15d..7f9b498 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 e63c451..038ead9 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 eb7e27a..461b88e 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.
More information about the Libreoffice-commits
mailing list