diff options
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/doc/DocumentContentOperationsManager.cxx | 24 | ||||
-rw-r--r-- | sw/source/core/txtnode/ndtxt.cxx | 11 |
2 files changed, 24 insertions, 11 deletions
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index c52221d7ca53..7df477784ba7 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -484,26 +484,28 @@ namespace } // #i86492# - bool lcl_ContainsOnlyParagraphsInList( const SwPaM& rPam ) + bool lcl_ShouldKeepSourceList( const SwPaM& rPam ) { - bool bRet = false; - const SwTextNode* pTextNd = rPam.Start()->GetNode().GetTextNode(); const SwTextNode* pEndTextNd = rPam.End()->GetNode().GetTextNode(); - if ( pTextNd && pTextNd->IsInList() && - pEndTextNd && pEndTextNd->IsInList() ) + bool bRet = pTextNd->IsInListFromStyle(); + //prefer list if it's a single paragraph with list from style + if (pTextNd == pEndTextNd && bRet) + return true; + + if (pTextNd && pTextNd->IsInList() && !pTextNd->IsInListFromStyle() && + pEndTextNd && pEndTextNd->IsInList() && !pEndTextNd->IsInListFromStyle()) { - bRet = true; + bRet = false; SwNodeIndex aIdx(rPam.Start()->GetNode()); - do { ++aIdx; pTextNd = aIdx.GetNode().GetTextNode(); - if ( !pTextNd || !pTextNd->IsInList() ) + if (!pTextNd || !pTextNd->IsInList() || pTextNd->IsInListFromStyle()) { - bRet = false; + bRet = true; break; } } while (pTextNd != pEndTextNd); @@ -5203,11 +5205,11 @@ bool DocumentContentOperationsManager::CopyImplImpl(SwPaM& rPam, SwPosition& rPo // or // - source is a table // - tdf#163340 overwrite list if source has a list + // - overwrite also if all source paragraphs have a list from a style if ( pNumRuleToPropagate && ((pDestTextNd && !pDestTextNd->GetText().getLength() && - (!pDestTextNd->IsInList() || rPam.GetPointNode().GetTextNode()->IsInList() ) && - !lcl_ContainsOnlyParagraphsInList(rPam)) || + (!pDestTextNd->IsInList() || lcl_ShouldKeepSourceList(rPam) )) || rPam.GetBound().nNode.GetNode().GetNodeType() == SwNodeType::Table) ) { pNumRuleToPropagate = nullptr; diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 38b034c7c24d..3c4c4fbd4561 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -4572,6 +4572,17 @@ bool SwTextNode::IsInList() const return GetNum() != nullptr && GetNum()->GetParent() != nullptr; } +bool SwTextNode::IsInListFromStyle() const +{ + if (IsInList()) + { + const SwFormatColl* pFormatColl = GetFormatColl(); + if (pFormatColl->GetItemState(RES_PARATR_NUMRULE, true) == SfxItemState::SET) + return true; + } + return false; + +} bool SwTextNode::IsFirstOfNumRule(SwRootFrame const& rLayout) const { bool bResult = false; |