diff options
author | Justin Luth <justin_luth@sil.org> | 2016-07-23 09:10:29 +0300 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2016-10-10 19:31:52 +0200 |
commit | a895a7051f2cca37595f755212399843116678c9 (patch) | |
tree | 73c15f01b984e8c75e4178bb57e6efb595ac6bd6 | |
parent | b77b40eb02a196b0899fecc864c238458bbb7e52 (diff) |
tdf#75573 - docx don't remove frame anchor paragraph
frames anchor to the following paragraph. Don't remove
an empty paragraph if it follows a frame or else the frame
will jump to the next page.
This gets a bit complicated because headers/footers contain
paragraphs that aren't really "following" the frame paragraph,
and so wouldn't be used as anchor paragraphs.
There may be similar sub-paragraphs for comments etc, but
exceptions for those can be added when proof documents are found.
Reviewed-on: https://gerrit.libreoffice.org/27455
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
(cherry picked from commit 91ad1017b609be6fceccd392006dd9ab60724352)
Change-Id: I46988b40abe65e23a5c407dde38a951937978005
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 12 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 11 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.hxx | 3 |
3 files changed, 21 insertions, 5 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index ae201aaa797e..5a1bcd9abf9f 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -3221,16 +3221,18 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len) bool bSingleParagraph = m_pImpl->GetIsFirstParagraphInSection() && m_pImpl->GetIsLastParagraphInSection(); // If the paragraph contains only the section properties and it has // no runs, we should not create a paragraph for it in Writer, unless that would remove the whole section. - bool bRemove = !m_pImpl->GetParaChanged() && m_pImpl->GetParaSectpr() && !bSingleParagraph && !m_pImpl->GetIsDummyParaAddedForTableInSection(); - PropertyMapPtr xContext = bRemove ? m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH) : PropertyMapPtr(); - if (xContext) + bool bRemove = !m_pImpl->GetParaChanged() && m_pImpl->GetParaSectpr() + && !bSingleParagraph + && !m_pImpl->GetIsDummyParaAddedForTableInSection() + && !m_pImpl->GetIsLastParagraphFramed(); + if (bRemove) { // tdf#97417 delete numbering of the paragraph // it will be deleted anyway, and the numbering would be copied // to the next paragraph in sw SplitNode and then be applied to // every following paragraph - xContext->Erase(PROP_NUMBERING_RULES); - xContext->Erase(PROP_NUMBERING_LEVEL); + m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH)->Erase(PROP_NUMBERING_RULES); + m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH)->Erase(PROP_NUMBERING_LEVEL); } m_pImpl->SetParaSectpr(false); m_pImpl->finishParagraph(m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH)); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 83f9d9c210a6..28091d6100ac 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -216,6 +216,7 @@ DomainMapper_Impl::DomainMapper_Impl( m_bIsFirstParaInSection( true ), m_bDummyParaAddedForTableInSection( false ), m_bTextFrameInserted(false), + m_bIsLastParagraphFramed( false ), m_bIsLastParaInSection( false ), m_bIsLastSectionGroup( false ), m_bIsInComments( false ), @@ -1189,6 +1190,16 @@ void DomainMapper_Impl::finishParagraph( PropertyMapPtr pPropertyMap ) } } + if( (pParaContext && pParaContext->IsFrameMode()) + || (IsInHeaderFooter() && GetIsLastParagraphFramed()) ) + { + SetIsLastParagraphFramed(true); + } + else + { + SetIsLastParagraphFramed(false); + } + m_bParaChanged = false; if (!pParaContext || !pParaContext->IsFrameMode()) { // If the paragraph is in a frame, it's not a paragraph of the section itself. diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index b602a70a3c68..7204c5912a64 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -436,6 +436,7 @@ private: bool m_bIsFirstParaInSection; bool m_bDummyParaAddedForTableInSection; bool m_bTextFrameInserted; + bool m_bIsLastParagraphFramed; bool m_bIsLastParaInSection; bool m_bIsLastSectionGroup; bool m_bIsInComments; @@ -524,6 +525,8 @@ public: bool GetIsDummyParaAddedForTableInSection() { return m_bDummyParaAddedForTableInSection;} void SetIsTextFrameInserted( bool bIsInserted ); bool GetIsTextFrameInserted() { return m_bTextFrameInserted;} + void SetIsLastParagraphFramed( bool bIsFramed ) { m_bIsLastParagraphFramed = bIsFramed; } + bool GetIsLastParagraphFramed() { return m_bIsLastParagraphFramed; } void SetParaSectpr(bool bParaSectpr); bool GetParaSectpr() { return m_bParaSectpr;} |