diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-02-12 22:04:55 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-02-13 09:58:09 +0100 |
commit | f737c9386a605cb7d8c9dbc210c557f98f6cdc19 (patch) | |
tree | c1fc00ab826300d725cba1ce492f40b063466edc /writerfilter | |
parent | b75609faa1a5ecde608146fcd7952e5efbcb40c6 (diff) |
tdf#113258 DOCX import: fix beforeAutospacing for shape first paragraph
Commit c761df1e42fd11acc5fc05b0baacd803c3788ca6 (tdf#84678 DOCX import:
fix handling of textbox margins, 2016-10-25) uncovered a previously
harder to notice problem that single-paragraph shapes have an incorrect
upper paragraph margin for the first paragraph. Now that the shape
margins are correct this problematic paragraph margin causes crop of the
shape text.
Fix the problem by adapting the DOCX import to the WW8 import's
SwWW8ImplReader::AppendTextNode() (the "If this is the first paragraph
in the document" part), where it seems the first paragraph is not only
the literally first paragraph in the document, but also the first
paragraph of shapes as well.
Change-Id: I9d99b9cfabae2c9a7c33eefefb5a9f008669e93d
Reviewed-on: https://gerrit.libreoffice.org/49617
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 22 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 7 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.hxx | 3 |
3 files changed, 32 insertions, 0 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 080bfdc6fb14..d31ca615de86 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -2114,7 +2114,27 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext ) StyleSheetTablePtr pStyleTable = m_pImpl->GetStyleSheetTable(); const OUString sConvertedStyleName = pStyleTable->ConvertStyleName( sStringValue, true ); if (m_pImpl->GetTopContext() && m_pImpl->GetTopContextType() != CONTEXT_SECTION) + { m_pImpl->GetTopContext()->Insert( PROP_PARA_STYLE_NAME, uno::makeAny( sConvertedStyleName )); + + if (m_pImpl->GetIsFirstParagraphInShape()) + { + // First paragraph in shape: see if we need to disable + // paragraph top margin from style. + StyleSheetEntryPtr pEntry + = m_pImpl->GetStyleSheetTable()->FindStyleSheetByConvertedStyleName( + sConvertedStyleName); + if (pEntry) + { + boost::optional<PropertyMap::Property> pParaAutoBefore + = pEntry->pProperties->getProperty( + PROP_PARA_TOP_MARGIN_BEFORE_AUTO_SPACING); + if (pParaAutoBefore) + m_pImpl->GetTopContext()->Insert(PROP_PARA_TOP_MARGIN, + uno::makeAny(static_cast<sal_Int32>(0))); + } + } + } } break; case NS_ooxml::LN_EG_RPrBase_rStyle: @@ -2978,6 +2998,8 @@ void DomainMapper::lcl_startShape(uno::Reference<drawing::XShape> const& xShape) // No context? Then this image should not appear directly inside the // document, just save it for later usage. m_pImpl->PushPendingShape(xShape); + + m_pImpl->SetIsFirstParagraphInShape(true); } void DomainMapper::lcl_endShape( ) diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 9060b3ce0dbd..bb15f12c824c 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -466,6 +466,10 @@ void DomainMapper_Impl::SetIsFirstParagraphInSection( bool bIsFirst ) m_bIsFirstParaInSection = bIsFirst; } +void DomainMapper_Impl::SetIsFirstParagraphInShape(bool bIsFirst) +{ + m_bIsFirstParaInShape = bIsFirst; +} void DomainMapper_Impl::SetIsDummyParaAddedForTableInSection( bool bIsAdded ) { @@ -1377,6 +1381,9 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap ) SetIsLastParagraphInSection(false); } + if (m_bIsFirstParaInShape) + m_bIsFirstParaInShape = false; + if (pParaContext) { // Reset the frame properties for the next paragraph diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index 19f2d80dbf15..d7fb9b4e8c40 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -490,6 +490,7 @@ private: /// If the current paragraph has any runs. bool m_bParaChanged; bool m_bIsFirstParaInSection; + bool m_bIsFirstParaInShape = false; bool m_bDummyParaAddedForTableInSection; bool m_bTextFrameInserted; bool m_bIsPreviousParagraphFramed; @@ -580,6 +581,8 @@ public: bool GetIsLastSectionGroup() { return m_bIsLastSectionGroup;} void SetIsFirstParagraphInSection( bool bIsFirst ); bool GetIsFirstParagraphInSection() { return m_bIsFirstParaInSection;} + void SetIsFirstParagraphInShape(bool bIsFirst); + bool GetIsFirstParagraphInShape() { return m_bIsFirstParaInShape; } void SetIsDummyParaAddedForTableInSection( bool bIsAdded ); bool GetIsDummyParaAddedForTableInSection() { return m_bDummyParaAddedForTableInSection;} void SetIsTextFrameInserted( bool bIsInserted ); |