diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2012-08-28 11:21:50 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2012-08-28 11:54:37 +0200 |
commit | 1efa576ef88141c4deb5da9818537e053dc6517b (patch) | |
tree | 1d2ff3dbbe1fa82b67d021acdfd9811782893e9a /writerfilter | |
parent | SwModelTestBase: support extracting node contents from a layout dump (diff) | |
download | core-1efa576ef88141c4deb5da9818537e053dc6517b.tar.gz core-1efa576ef88141c4deb5da9818537e053dc6517b.zip |
fdo#52052 fix RTF import of page breaks on landscape pages
The problem was that we tried to insert a page break before reaching the
first section break, where section properties are sent.
Additionally, the continuous section break at the end of the doc caused
trouble, so ignore it explicitly.
Change-Id: I22bc355994991beeadb41d26b44ce3e2beedbdb2
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 51 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.hxx | 3 |
2 files changed, 48 insertions, 6 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 812054003135..330c34d6ec6e 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -270,7 +270,8 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x m_bFormField(false), m_bIsInFrame(false), m_aUnicodeBuffer(), - m_aHexBuffer() + m_aHexBuffer(), + m_bDeferredContSectBreak(false) { OSL_ASSERT(xInputStream.is()); m_pInStream.reset(utl::UcbStreamHelper::CreateStream(xInputStream, sal_True)); @@ -1093,6 +1094,7 @@ void RTFDocumentImpl::replayBuffer(RTFBuffer_t& rBuffer) int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) { checkUnicode(); + checkDeferredContSectBreak(); RTFSkipDestination aSkip(*this); switch (nKeyword) { @@ -1516,6 +1518,7 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) { if (nKeyword != RTF_HEXCHAR) checkUnicode(); + checkDeferredContSectBreak(); RTFSkipDestination aSkip(*this); sal_uInt8 cCh = 0; @@ -1572,7 +1575,17 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) } break; case RTF_SECT: - sectBreak(); + { + RTFValue::Pointer_t pBreak = m_aStates.top().aSectionSprms.find(NS_sprm::LN_SBkc); + if (pBreak.get() && !pBreak->getInt()) + { + // This is a continous section break, don't send it yet. + // It's possible that we'll have nothing after this token, and then we should ignore it. + m_bDeferredContSectBreak = true; + } + else + sectBreak(); + } break; case RTF_NOBREAK: { @@ -1693,10 +1706,21 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) break; case RTF_PAGE: { - sal_uInt8 sBreak[] = { 0xc }; - Mapper().text(sBreak, 1); - if (!m_bNeedPap) - parBreak(); + // If we're inside a continous section, we should send a section break, not a page one. + RTFValue::Pointer_t pBreak = m_aStates.top().aSectionSprms.find(NS_sprm::LN_SBkc); + if (pBreak.get() && !pBreak->getInt()) + { + dispatchFlag(RTF_SBKPAGE); + sectBreak(); + dispatchFlag(RTF_SBKNONE); + } + else + { + sal_uInt8 sBreak[] = { 0xc }; + Mapper().text(sBreak, 1); + if (!m_bNeedPap) + parBreak(); + } } break; case RTF_CHPGN: @@ -1719,6 +1743,7 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) { checkUnicode(); + checkDeferredContSectBreak(); RTFSkipDestination aSkip(*this); int nParam = -1; int nSprm = -1; @@ -2342,6 +2367,7 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) { checkUnicode(nKeyword != RTF_U, true); + checkDeferredContSectBreak(); RTFSkipDestination aSkip(*this); int nSprm = 0; RTFValue::Pointer_t pIntValue(new RTFValue(nParam)); @@ -3081,6 +3107,7 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) int RTFDocumentImpl::dispatchToggle(RTFKeyword nKeyword, bool bParam, int nParam) { checkUnicode(); + checkDeferredContSectBreak(); RTFSkipDestination aSkip(*this); int nSprm = -1; RTFValue::Pointer_t pBoolValue(new RTFValue(!bParam || nParam != 0)); @@ -3730,7 +3757,10 @@ int RTFDocumentImpl::popState() // This is the end of the doc, see if we need to close the last section. if (m_nGroup == 1 && !m_bFirstRun) + { + m_bDeferredContSectBreak = false; sectBreak(true); + } m_aStates.pop(); @@ -3947,6 +3977,15 @@ void RTFDocumentImpl::checkUnicode(bool bUnicode, bool bHex) } } +void RTFDocumentImpl::checkDeferredContSectBreak() +{ + if (m_bDeferredContSectBreak) + { + m_bDeferredContSectBreak = false; + sectBreak(); + } +} + RTFParserState::RTFParserState(RTFDocumentImpl *pDocumentImpl) : m_pDocumentImpl(pDocumentImpl), nInternalState(INTERNAL_NORMAL), diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index 0759a4c30b90..e3120b7aacdf 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -479,6 +479,8 @@ namespace writerfilter { void replayBuffer(RTFBuffer_t& rBuffer); /// If we have some unicode or hex characters to send. void checkUnicode(bool bUnicode = true, bool bHex = true); + /// If we have a pending continous section break. + void checkDeferredContSectBreak(); uno::Reference<uno::XComponentContext> const& m_xContext; uno::Reference<io::XInputStream> const& m_xInputStream; @@ -573,6 +575,7 @@ namespace writerfilter { rtl::OStringBuffer m_aHexBuffer; /// Formula import. oox::formulaimport::XmlStreamBuilder m_aMathBuffer; + bool m_bDeferredContSectBreak; }; } // namespace rtftok } // namespace writerfilter |