diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-02-12 22:04:55 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-02-16 10:22:56 +0100 |
commit | 3779c742a52d8dde3fa7b74c2a8ca8bc7d071b4e (patch) | |
tree | 8c31e6d8049477fa65da6a67780bb48735ad3427 /writerfilter | |
parent | 33317afcb1c070bd4ff19d312964d78f2105a87e (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.
(cherry picked from commit f737c9386a605cb7d8c9dbc210c557f98f6cdc19)
Conflicts:
writerfilter/source/dmapper/DomainMapper.cxx
Change-Id: I9d99b9cfabae2c9a7c33eefefb5a9f008669e93d
Reviewed-on: https://gerrit.libreoffice.org/49626
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
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 83698f4553de..5569f91a23de 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -2170,7 +2170,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))); + } + } + } //apply numbering to paragraph if it was set at the style, but only if the paragraph itself //does not specify the numbering if( !rContext->isSet(PROP_NUMBERING_RULES) ) // !contains @@ -3080,6 +3100,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 ff412635b6fa..de2a959f019d 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -464,6 +464,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 ) { @@ -1309,6 +1313,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 807f80164342..29b0cc22086f 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -503,6 +503,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; @@ -593,6 +594,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 ); |