summaryrefslogtreecommitdiff
path: root/sw/source/core
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/core')
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx2
-rw-r--r--sw/source/core/doc/docnum.cxx98
-rw-r--r--sw/source/core/edit/ednumber.cxx17
3 files changed, 82 insertions, 35 deletions
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 95ecbac40ded..0ae7f5852c7a 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -4659,7 +4659,7 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos,
// #i86492# - use <SwDoc::SetNumRule(..)>, because it also handles the <ListId>
// Don't reset indent attributes, that would mean loss of direct
// formatting.
- pDoc->SetNumRule( *pCopyPam, *pNumRuleToPropagate, false,
+ pDoc->SetNumRule( *pCopyPam, *pNumRuleToPropagate, false, nullptr,
aListIdToPropagate, true, /*bResetIndentAttrs=*/false );
}
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index 8b0e19e29a62..ef9a8068ad13 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -84,6 +84,24 @@ namespace {
pDoc->ResetAttrs( rPam, false, aResetAttrsArray );
}
}
+
+ void ExpandPamForParaPropsNodes(SwPaM& rPam, SwRootFrame const*const pLayout)
+ {
+ if (pLayout)
+ { // ensure that selection from the Shell includes the para-props node
+ // to which the attributes should be applied
+ if (rPam.GetPoint()->nNode.GetNode().IsTextNode())
+ {
+ rPam.GetPoint()->nNode = *sw::GetParaPropsNode(*pLayout, rPam.GetPoint()->nNode);
+ rPam.GetPoint()->nContent.Assign(rPam.GetPoint()->nNode.GetNode().GetContentNode(), 0);
+ }
+ if (rPam.GetMark()->nNode.GetNode().IsTextNode())
+ {
+ rPam.GetMark()->nNode = *sw::GetParaPropsNode(*pLayout, rPam.GetMark()->nNode);
+ rPam.GetMark()->nContent.Assign(rPam.GetMark()->nNode.GetNode().GetContentNode(), 0);
+ }
+ }
+ }
}
static sal_uInt8 GetUpperLvlChg( sal_uInt8 nCurLvl, sal_uInt8 nLevel, sal_uInt16 nMask )
@@ -181,9 +199,11 @@ bool SwDoc::OutlineUpDown(const SwPaM& rPam, short nOffset,
return false;
// calculate the range
+ SwPaM aPam(rPam, nullptr);
+ ExpandPamForParaPropsNodes(aPam, pLayout);
const SwOutlineNodes& rOutlNds = GetNodes().GetOutLineNds();
- const SwNodePtr pSttNd = &rPam.Start()->nNode.GetNode();
- const SwNodePtr pEndNd = &rPam.End()->nNode.GetNode();
+ const SwNodePtr pSttNd = &aPam.Start()->nNode.GetNode();
+ const SwNodePtr pEndNd = &aPam.End()->nNode.GetNode();
SwOutlineNodes::size_type nSttPos, nEndPos;
if( !rOutlNds.Seek_Entry( pSttNd, &nSttPos ) &&
@@ -370,7 +390,7 @@ bool SwDoc::OutlineUpDown(const SwPaM& rPam, short nOffset,
{
GetIDocumentUndoRedo().StartUndo(SwUndoId::OUTLINE_LR, nullptr);
GetIDocumentUndoRedo().AppendUndo(
- o3tl::make_unique<SwUndoOutlineLeftRight>( rPam, nOffset ) );
+ o3tl::make_unique<SwUndoOutlineLeftRight>(aPam, nOffset) );
}
// 2. Apply the new style to all Nodes
@@ -830,18 +850,22 @@ static void lcl_ChgNumRule( SwDoc& rDoc, const SwNumRule& rRule )
OUString SwDoc::SetNumRule( const SwPaM& rPam,
const SwNumRule& rRule,
const bool bCreateNewList,
+ SwRootFrame const*const pLayout,
const OUString& sContinuedListId,
bool bSetItem,
const bool bResetIndentAttrs )
{
OUString sListId;
+ SwPaM aPam(rPam, nullptr);
+ ExpandPamForParaPropsNodes(aPam, pLayout);
+
SwUndoInsNum * pUndo = nullptr;
if (GetIDocumentUndoRedo().DoesUndo())
{
// Start/End for attributes!
GetIDocumentUndoRedo().StartUndo( SwUndoId::INSNUM, nullptr );
- pUndo = new SwUndoInsNum( rPam, rRule );
+ pUndo = new SwUndoInsNum( aPam, rRule );
GetIDocumentUndoRedo().AppendUndo(std::unique_ptr<SwUndo>(pUndo));
}
@@ -892,16 +916,17 @@ OUString SwDoc::SetNumRule( const SwPaM& rPam,
}
if (!sListId.isEmpty())
{
- getIDocumentContentOperations().InsertPoolItem( rPam, SfxStringItem( RES_PARATR_LIST_ID, sListId ) );
+ getIDocumentContentOperations().InsertPoolItem(aPam, SfxStringItem(RES_PARATR_LIST_ID, sListId));
}
}
- if ( !rPam.HasMark() )
+ if (!aPam.HasMark())
{
- SwTextNode * pTextNd = rPam.GetPoint()->nNode.GetNode().GetTextNode();
+ SwTextNode * pTextNd = aPam.GetPoint()->nNode.GetNode().GetTextNode();
// robust code: consider case that the PaM doesn't denote a text node - e.g. it denotes a graphic node
if ( pTextNd != nullptr )
{
+ assert(!pLayout || sw::IsParaPropsNode(*pLayout, *pTextNd));
SwNumRule * pRule = pTextNd->GetNumRule();
if (pRule && pRule->GetName() == pNewOrChangedNumRule->GetName())
@@ -932,13 +957,13 @@ OUString SwDoc::SetNumRule( const SwPaM& rPam,
if ( bSetItem )
{
- getIDocumentContentOperations().InsertPoolItem( rPam, SwNumRuleItem( pNewOrChangedNumRule->GetName() ) );
+ getIDocumentContentOperations().InsertPoolItem(aPam, SwNumRuleItem(pNewOrChangedNumRule->GetName()));
}
if ( bResetIndentAttrs
&& pNewOrChangedNumRule->Get( 0 ).GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
{
- ::lcl_ResetIndentAttrs(this, rPam, RES_LR_SPACE);
+ ::lcl_ResetIndentAttrs(this, aPam, RES_LR_SPACE);
}
if (GetIDocumentUndoRedo().DoesUndo())
@@ -1254,6 +1279,7 @@ void SwDoc::MakeUniqueNumRules(const SwPaM & rPaM)
SetNumRule( aPam,
*aListStyleData.pReplaceNumRule,
aListStyleData.bCreateNewList,
+ nullptr,
aListStyleData.sListId );
if ( aListStyleData.bCreateNewList )
{
@@ -1291,19 +1317,17 @@ bool SwDoc::NoNum( const SwPaM& rPam )
return bRet;
}
-void SwDoc::DelNumRules( const SwPaM& rPam )
+void SwDoc::DelNumRules(const SwPaM& rPam, SwRootFrame const*const pLayout)
{
- sal_uLong nStt = rPam.GetPoint()->nNode.GetIndex(),
- nEnd = rPam.GetMark()->nNode.GetIndex();
- if( nStt > nEnd )
- {
- sal_uLong nTmp = nStt; nStt = nEnd; nEnd = nTmp;
- }
+ SwPaM aPam(rPam, nullptr);
+ ExpandPamForParaPropsNodes(aPam, pLayout);
+ sal_uLong nStt = aPam.Start()->nNode.GetIndex();
+ sal_uLong const nEnd = aPam.End()->nNode.GetIndex();
SwUndoDelNum* pUndo;
if (GetIDocumentUndoRedo().DoesUndo())
{
- pUndo = new SwUndoDelNum( rPam );
+ pUndo = new SwUndoDelNum( aPam );
GetIDocumentUndoRedo().AppendUndo(std::unique_ptr<SwUndo>(pUndo));
}
else
@@ -1316,6 +1340,10 @@ void SwDoc::DelNumRules( const SwPaM& rPam )
for( ; nStt <= nEnd; ++nStt )
{
SwTextNode* pTNd = GetNodes()[ nStt ]->GetTextNode();
+ if (pLayout && pTNd)
+ {
+ pTNd = sw::GetParaPropsNode(*pLayout, *pTNd);
+ }
SwNumRule* pNumRuleOfTextNode = pTNd ? pTNd->GetNumRule() : nullptr;
if ( pTNd && pNumRuleOfTextNode )
{
@@ -1651,14 +1679,12 @@ bool SwDoc::GotoPrevNum(SwPosition& rPos, SwRootFrame const*const pLayout,
return ::lcl_GotoNextPrevNum(rPos, false, bOverUpper, nullptr, nullptr, pLayout);
}
-bool SwDoc::NumUpDown( const SwPaM& rPam, bool bDown )
+bool SwDoc::NumUpDown(const SwPaM& rPam, bool bDown, SwRootFrame const*const pLayout)
{
- sal_uLong nStt = rPam.GetPoint()->nNode.GetIndex(),
- nEnd = rPam.GetMark()->nNode.GetIndex();
- if( nStt > nEnd )
- {
- sal_uLong nTmp = nStt; nStt = nEnd; nEnd = nTmp;
- }
+ SwPaM aPam(rPam, nullptr);
+ ExpandPamForParaPropsNodes(aPam, pLayout);
+ sal_uLong nStt = aPam.Start()->nNode.GetIndex();
+ sal_uLong const nEnd = aPam.End()->nNode.GetIndex();
// -> outline nodes are promoted or demoted differently
bool bOnlyOutline = true;
@@ -1669,6 +1695,10 @@ bool SwDoc::NumUpDown( const SwPaM& rPam, bool bDown )
if (pTextNd)
{
+ if (pLayout)
+ {
+ pTextNd = sw::GetParaPropsNode(*pLayout, *pTextNd);
+ }
SwNumRule * pRule = pTextNd->GetNumRule();
if (pRule)
@@ -1685,7 +1715,7 @@ bool SwDoc::NumUpDown( const SwPaM& rPam, bool bDown )
sal_Int8 nDiff = bDown ? 1 : -1;
if (bOnlyOutline)
- bRet = OutlineUpDown(rPam, nDiff);
+ bRet = OutlineUpDown(rPam, nDiff, pLayout);
else if (bOnlyNonOutline)
{
/* #i24560#
@@ -1700,6 +1730,11 @@ bool SwDoc::NumUpDown( const SwPaM& rPam, bool bDown )
// text node.
if ( pTNd )
{
+ if (pLayout)
+ {
+ pTNd = sw::GetParaPropsNode(*pLayout, *pTNd);
+ }
+
SwNumRule * pRule = pTNd->GetNumRule();
if (pRule)
@@ -1717,15 +1752,26 @@ bool SwDoc::NumUpDown( const SwPaM& rPam, bool bDown )
if (GetIDocumentUndoRedo().DoesUndo())
{
GetIDocumentUndoRedo().AppendUndo(
- o3tl::make_unique<SwUndoNumUpDown>(rPam, nDiff) );
+ o3tl::make_unique<SwUndoNumUpDown>(aPam, nDiff) );
}
+ SwTextNode* pPrev = nullptr;
for(sal_uLong nTmp = nStt; nTmp <= nEnd; ++nTmp )
{
SwTextNode* pTNd = GetNodes()[ nTmp ]->GetTextNode();
if( pTNd)
{
+ if (pLayout)
+ {
+ pTNd = sw::GetParaPropsNode(*pLayout, *pTNd);
+ if (pTNd == pPrev)
+ {
+ continue;
+ }
+ pPrev = pTNd;
+ }
+
SwNumRule * pRule = pTNd->GetNumRule();
if (pRule)
diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx
index 6402f498290e..3e417e7f9fec 100644
--- a/sw/source/core/edit/ednumber.cxx
+++ b/sw/source/core/edit/ednumber.cxx
@@ -142,6 +142,7 @@ void SwEditShell::NoNum()
GetDoc()->GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr );
}
else
+ // sw_redlinehide: leave cursor as is, will be split at Point & apply to new node
bRet = GetDoc()->NoNum( *pCursor );
EndAllAction();
@@ -287,12 +288,12 @@ void SwEditShell::DelNumRules()
SwPaM aPam( *pCursor->GetPoint() );
for( size_t n = 0; n < aRangeArr.Count(); ++n )
{
- GetDoc()->DelNumRules( aRangeArr.SetPam( n, aPam ) );
+ GetDoc()->DelNumRules(aRangeArr.SetPam( n, aPam ), GetLayout());
}
GetDoc()->GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr );
}
else
- GetDoc()->DelNumRules( *pCursor );
+ GetDoc()->DelNumRules(*pCursor, GetLayout());
// Call AttrChangeNotify on the UI-side. Should actually be redundant but there was a bug once.
CallChgLnk();
@@ -312,14 +313,14 @@ void SwEditShell::NumUpDown( bool bDown )
bool bRet = true;
SwPaM* pCursor = GetCursor();
if( !pCursor->IsMultiSelection() )
- bRet = GetDoc()->NumUpDown( *pCursor, bDown );
+ bRet = GetDoc()->NumUpDown(*pCursor, bDown, GetLayout());
else
{
GetDoc()->GetIDocumentUndoRedo().StartUndo( SwUndoId::START, nullptr );
SwPamRanges aRangeArr( *pCursor );
SwPaM aPam( *pCursor->GetPoint() );
for( size_t n = 0; n < aRangeArr.Count(); ++n )
- bRet = bRet && GetDoc()->NumUpDown( aRangeArr.SetPam( n, aPam ), bDown );
+ bRet = bRet && GetDoc()->NumUpDown(aRangeArr.SetPam( n, aPam ), bDown, GetLayout());
GetDoc()->GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr );
}
GetDoc()->getIDocumentState().SetModified();
@@ -387,7 +388,7 @@ void SwEditShell::SetIndent(short nIndent, const SwPosition & rPos)
// change numbering rule - changed numbering rule is not applied at <aPaM>
SwPaM aPaM(pos);
- GetDoc()->SetNumRule( aPaM, aRule, false, OUString(), false );
+ GetDoc()->SetNumRule(aPaM, aRule, false, GetLayout(), OUString(), false);
}
EndAllAction();
@@ -513,7 +514,7 @@ bool SwEditShell::MoveNumParas( bool bUpperLower, bool bUpperLeft )
else if( (bUpperLeft ? nUpperLevel : nLowerLevel+1) < MAXLEVEL )
{
aCursor.Move( fnMoveBackward, GoInNode );
- bRet = GetDoc()->NumUpDown( aCursor, !bUpperLeft );
+ bRet = GetDoc()->NumUpDown(aCursor, !bUpperLeft, GetLayout());
}
}
@@ -759,7 +760,7 @@ void SwEditShell::SetCurNumRule( const SwNumRule& rRule,
{
aRangeArr.SetPam( n, aPam );
OUString sListId = GetDoc()->SetNumRule( aPam, rRule,
- bCreateNewList, sContinuedListId,
+ bCreateNewList, GetLayout(), sContinuedListId,
true, bResetIndentAttrs );
//tdf#87548 On creating a new list for a multi-selection only
@@ -776,7 +777,7 @@ void SwEditShell::SetCurNumRule( const SwNumRule& rRule,
else
{
GetDoc()->SetNumRule( *pCursor, rRule,
- bCreateNewList, rContinuedListId,
+ bCreateNewList, GetLayout(), rContinuedListId,
true, bResetIndentAttrs );
GetDoc()->SetCounted( *pCursor, true );
}