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.
This commit is contained in:
parent
8866e1986d
commit
7b58fc3daf
4 changed files with 23 additions and 15 deletions
6
sw/qa/extras/rtftok/data/fdo48104.rtf
Normal file
6
sw/qa/extras/rtftok/data/fdo48104.rtf
Normal file
|
@ -0,0 +1,6 @@
|
|||
{\rtf1
|
||||
first page\par
|
||||
\page
|
||||
{second page first line\par}
|
||||
second page second line\par
|
||||
}
|
|
@ -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();
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue