diff options
author | Justin Luth <justin_luth@sil.org> | 2016-07-23 09:10:29 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-27 12:55:13 +0000 |
commit | 91ad1017b609be6fceccd392006dd9ab60724352 (patch) | |
tree | 95769925bb502e3fa7dfd318eb1e0cf9327bcdec | |
parent | 0d174c974819d781804026f4c7e916a8092315c5 (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.
Change-Id: I46988b40abe65e23a5c407dde38a951937978005
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>
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 2 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 5 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 11 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.hxx | 3 |
4 files changed, 19 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index b363c7ae2d2a..b904bdf88e15 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -1739,7 +1739,7 @@ DECLARE_OOXMLIMPORT_TEST(testTdf75573, "tdf75573_page1frame.docx") lcl_countTextFrames( mxComponent, 1 ); // the frame should be on page 1 -// CPPUNIT_ASSERT_EQUAL( OUString("lorem ipsum"), parseDump("/root/page[1]/body/section/txt/anchored/fly/txt[1]/text()") ); + CPPUNIT_ASSERT_EQUAL( OUString("lorem ipsum"), parseDump("/root/page[1]/body/section/txt/anchored/fly/txt[1]/text()") ); // the "Proprietary" style should set the vertical and horizontal anchors to the page uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY); diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 9a391490fb6d..ddaafd5031e5 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -3217,7 +3217,10 @@ 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(); + bool bRemove = !m_pImpl->GetParaChanged() && m_pImpl->GetParaSectpr() + && !bSingleParagraph + && !m_pImpl->GetIsDummyParaAddedForTableInSection() + && !m_pImpl->GetIsLastParagraphFramed(); if (bRemove) { // tdf#97417 delete numbering of the paragraph diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index b5dff72ac83b..5f6e05ded800 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -215,6 +215,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 ), @@ -1187,6 +1188,16 @@ void DomainMapper_Impl::finishParagraph( const 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 ec66b2015b97..5c34a23f8f2c 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -435,6 +435,7 @@ private: bool m_bIsFirstParaInSection; bool m_bDummyParaAddedForTableInSection; bool m_bTextFrameInserted; + bool m_bIsLastParagraphFramed; bool m_bIsLastParaInSection; bool m_bIsLastSectionGroup; bool m_bIsInComments; @@ -523,6 +524,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;} |