sw/source/core/inc/objectformatter.hxx | 3 sw/source/core/layout/fly.cxx | 6 - sw/source/core/layout/objectformatter.cxx | 5 - writerfilter/source/dmapper/DomainMapper.cxx | 130 ++++++++++++++------------- writerfilter/source/dmapper/DomainMapper.hxx | 1 5 files changed, 81 insertions(+), 64 deletions(-)
New commits: commit 09c03d962566d7d7b968f13feac578bd94109ca8 Author: Michael Stahl <[email protected]> AuthorDate: Thu Nov 16 13:31:10 2023 +0100 Commit: Xisco Fauli <[email protected]> CommitDate: Wed Nov 29 14:13:36 2023 +0100 writerfilter: DomainMapper: fix undetected merge conflict ... between commit fce18155052821756466ea043c638f4ed72f41d6 and commit 15b886f460919ea3dce425a621dc017c2992a96b - move the code from lcl_text() to lcl_utext(). Change-Id: Iaa515d2ebd9861e24b442b0d7b41f83662ed58df Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159501 Tested-by: Michael Stahl <[email protected]> Reviewed-by: Michael Stahl <[email protected]> (cherry picked from commit 7b3f68257b7b6781dd22830bc118cb0ef92fb113) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159530 Tested-by: Jenkins Reviewed-by: Xisco Fauli <[email protected]> diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 7a9379698a59..0aeb3337f6f3 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -3923,65 +3923,7 @@ void DomainMapper::lcl_text(const sal_uInt8 * data_, size_t len) pContext->Insert(PROP_BREAK_TYPE, uno::Any(style::BreakType_COLUMN_BEFORE)); m_pImpl->clearDeferredBreak(COLUMN_BREAK); } - if (IsRTFImport() && pContext) { - //reset paragraph style properties not repeated at the paragraph - std::optional<PropertyMap::Property> paraStyleName = pContext->getProperty(PROP_PARA_STYLE_NAME); - if (paraStyleName.has_value()) { - OUString uStyleName; - paraStyleName->second >>= uStyleName; - StyleSheetEntryPtr pStyleSheet = m_pImpl->GetStyleSheetTable()->FindStyleSheetByConvertedStyleName(uStyleName); - if (pStyleSheet != nullptr) - { - std::vector< PropertyIds > stylePropertyIds = pStyleSheet->m_pProperties->GetPropertyIds(); - std::vector< PropertyIds >::iterator stylePropertyIdsIt = stylePropertyIds.begin(); - while (stylePropertyIdsIt != stylePropertyIds.end()) - { - PropertyIds ePropertyId = *stylePropertyIdsIt; - std::optional< PropertyMap::Property > styleProperty = pStyleSheet->m_pProperties->getProperty(ePropertyId); - std::optional< PropertyMap::Property > paragraphProperty = pContext->getProperty(ePropertyId); - if (paragraphProperty.has_value()) { - if (paragraphProperty->second == styleProperty->second && - !isSPRMDeduplicateDenylist(ePropertyId, pContext)) - { - pContext->Erase(ePropertyId); - } - } - else - { - switch (ePropertyId) - { - case PROP_PARA_LEFT_MARGIN: - if (!pContext->getProperty(PROP_NUMBERING_RULES)) - { - pContext->Insert(ePropertyId, uno::Any(0l)); - } - break; - case PROP_PARA_RIGHT_MARGIN: - pContext->Insert(ePropertyId, uno::Any(0l)); - break; - case PROP_PARA_LAST_LINE_ADJUST: - case PROP_PARA_ADJUST: - pContext->Insert(ePropertyId, uno::Any(style::ParagraphAdjust_LEFT)); - break; - case PROP_PARA_TAB_STOPS: - pContext->Insert(ePropertyId, uno::Any(uno::Sequence< style::TabStop >())); - break; - case PROP_FILL_STYLE: - pContext->Insert(ePropertyId, uno::Any(drawing::FillStyle_NONE)); - break; - case PROP_FILL_COLOR: - pContext->Insert(ePropertyId, uno::Any(sal_Int32(COL_TRANSPARENT))); - break; - case INVALID: - default: - break; - } - } - ++stylePropertyIdsIt; - } - } - } - } + ResetStyleProperties(); finishParagraph(); return; } @@ -4101,6 +4043,71 @@ void DomainMapper::lcl_checkId(const sal_Int32 nId) } } +void DomainMapper::ResetStyleProperties() +{ + PropertyMapPtr pContext = m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH); + if (IsRTFImport() && pContext) + { + //reset paragraph style properties not repeated at the paragraph + std::optional<PropertyMap::Property> paraStyleName = pContext->getProperty(PROP_PARA_STYLE_NAME); + if (paraStyleName.has_value()) { + OUString uStyleName; + paraStyleName->second >>= uStyleName; + StyleSheetEntryPtr pStyleSheet = m_pImpl->GetStyleSheetTable()->FindStyleSheetByConvertedStyleName(uStyleName); + if (pStyleSheet != nullptr) + { + std::vector< PropertyIds > stylePropertyIds = pStyleSheet->m_pProperties->GetPropertyIds(); + std::vector< PropertyIds >::iterator stylePropertyIdsIt = stylePropertyIds.begin(); + while (stylePropertyIdsIt != stylePropertyIds.end()) + { + PropertyIds ePropertyId = *stylePropertyIdsIt; + std::optional< PropertyMap::Property > styleProperty = pStyleSheet->m_pProperties->getProperty(ePropertyId); + std::optional< PropertyMap::Property > paragraphProperty = pContext->getProperty(ePropertyId); + if (paragraphProperty.has_value()) { + if (paragraphProperty->second == styleProperty->second && + !isSPRMDeduplicateDenylist(ePropertyId, pContext)) + { + pContext->Erase(ePropertyId); + } + } + else + { + switch (ePropertyId) + { + case PROP_PARA_LEFT_MARGIN: + if (!pContext->getProperty(PROP_NUMBERING_RULES)) + { + pContext->Insert(ePropertyId, uno::Any(0l)); + } + break; + case PROP_PARA_RIGHT_MARGIN: + pContext->Insert(ePropertyId, uno::Any(0l)); + break; + case PROP_PARA_LAST_LINE_ADJUST: + case PROP_PARA_ADJUST: + pContext->Insert(ePropertyId, uno::Any(style::ParagraphAdjust_LEFT)); + break; + case PROP_PARA_TAB_STOPS: + pContext->Insert(ePropertyId, uno::Any(uno::Sequence< style::TabStop >())); + break; + case PROP_FILL_STYLE: + pContext->Insert(ePropertyId, uno::Any(drawing::FillStyle_NONE)); + break; + case PROP_FILL_COLOR: + pContext->Insert(ePropertyId, uno::Any(sal_Int32(COL_TRANSPARENT))); + break; + case INVALID: + default: + break; + } + } + ++stylePropertyIdsIt; + } + } + } + } +} + void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len) { // All these fixed values are defined as static const sal_Unicode codepoints in the fast parser, @@ -4119,6 +4126,11 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len) if (len == 1) { + if (sText[0] == 0x0d) + { + ResetStyleProperties(); + } + // preload all footnotes in separated footnotes if (sText[0] == 0x5) { diff --git a/writerfilter/source/dmapper/DomainMapper.hxx b/writerfilter/source/dmapper/DomainMapper.hxx index a452e2e6e9bc..4fcd55195c84 100644 --- a/writerfilter/source/dmapper/DomainMapper.hxx +++ b/writerfilter/source/dmapper/DomainMapper.hxx @@ -175,6 +175,7 @@ private: // Table virtual void lcl_entry(writerfilter::Reference<Properties>::Pointer_t ref) override; + void ResetStyleProperties(); void finishParagraph(const bool bRemove = false, const bool bNoNumbering = false); static void handleUnderlineType(const Id nId, const ::tools::SvRef<PropertyMap>& rContext); commit cb504500ec6b9ac8e5ed24a50552edb1e9d4d2d5 Author: Michael Stahl <[email protected]> AuthorDate: Thu Nov 16 19:45:05 2023 +0100 Commit: Xisco Fauli <[email protected]> CommitDate: Wed Nov 29 14:13:28 2023 +0100 sw: fix layout crash in SwObjectFormatterTextFrame::DoFormatObj() Since commit 15b886f460919ea3dce425a621dc017c2992a96b this is happening in testForcepoint93, but only on WNT. The crash is in SwObjectFormatterTextFrame::DoFormatObj() calling SwObjectFormatterTextFrame::InvalidateFollowObjs() and the mrPageFrame has been deleted; there is also the m_bAgain flag set in the SwLayAction up the stack, but the SwObjectFormatter::mpLayAction is null so DoFormatObj() cannot check this condition. In the caller CalcContent(), get the SwLayAction from the SwViewShell and pass it to the SwObjectFormatter, which appears to fix the problem. Change-Id: Ib3dc34ce39b4aad723251271c24bdd7a6598ab1c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159518 Tested-by: Jenkins Reviewed-by: Michael Stahl <[email protected]> (cherry picked from commit 191babee4f0ec643b80e96b0cd98c2d04ff96e4e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159555 Reviewed-by: Xisco Fauli <[email protected]> diff --git a/sw/source/core/inc/objectformatter.hxx b/sw/source/core/inc/objectformatter.hxx index 99d8644f2c29..f85c12dc5f2d 100644 --- a/sw/source/core/inc/objectformatter.hxx +++ b/sw/source/core/inc/objectformatter.hxx @@ -166,7 +166,8 @@ class SwObjectFormatter */ static bool FormatObj( SwAnchoredObject& _rAnchoredObj, SwFrame* _pAnchorFrame = nullptr, - const SwPageFrame* _pPageFrame = nullptr ); + const SwPageFrame* _pPageFrame = nullptr, + SwLayAction* pLayAction = nullptr ); }; #endif diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index 7fc0a566b9d5..6b4386a67300 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -1568,7 +1568,8 @@ void SwFlyFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorderA // Thus, <bNoCalcFollow> no longer used by <FormatWidthCols(..)>. void CalcContent( SwLayoutFrame *pLay, bool bNoColl ) { - vcl::RenderContext* pRenderContext = pLay->getRootFrame()->GetCurrShell()->GetOut(); + SwViewShell & rShell(*pLay->getRootFrame()->GetCurrShell()); + vcl::RenderContext* pRenderContext = rShell.GetOut(); SwSectionFrame* pSect; bool bCollect = false; if( pLay->IsSctFrame() ) @@ -1729,7 +1730,8 @@ void CalcContent( SwLayoutFrame *pLay, bool bNoColl ) } } - if ( !SwObjectFormatter::FormatObj( *pAnchoredObj, pAnchorFrame, pAnchorPageFrame ) ) + if (!SwObjectFormatter::FormatObj(*pAnchoredObj, pAnchorFrame, pAnchorPageFrame, + rShell.Imp()->IsAction() ? &rShell.Imp()->GetLayAction() : nullptr)) { bRestartLayoutProcess = true; break; diff --git a/sw/source/core/layout/objectformatter.cxx b/sw/source/core/layout/objectformatter.cxx index b99da6a0fe4b..6395d2f9e3a8 100644 --- a/sw/source/core/layout/objectformatter.cxx +++ b/sw/source/core/layout/objectformatter.cxx @@ -167,7 +167,8 @@ bool SwObjectFormatter::FormatObjsAtFrame( SwFrame& _rAnchorFrame, */ bool SwObjectFormatter::FormatObj( SwAnchoredObject& _rAnchoredObj, SwFrame* _pAnchorFrame, - const SwPageFrame* _pPageFrame ) + const SwPageFrame* _pPageFrame, + SwLayAction * pLayAction) { bool bSuccess( true ); @@ -181,7 +182,7 @@ bool SwObjectFormatter::FormatObj( SwAnchoredObject& _rAnchoredObj, // create corresponding object formatter std::unique_ptr<SwObjectFormatter> pObjFormatter = - SwObjectFormatter::CreateObjFormatter( rAnchorFrame, rPageFrame, nullptr/*_pLayAction*/ ); + SwObjectFormatter::CreateObjFormatter(rAnchorFrame, rPageFrame, pLayAction); if ( pObjFormatter ) {
