summaryrefslogtreecommitdiff
path: root/sw/source/core/doc/docnum.cxx
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2018-10-30 14:14:55 +0100
committerMichael Stahl <Michael.Stahl@cib.de>2018-11-10 19:47:00 +0100
commit00f341c701ba3aee69e20f05f2f8136ca4726b51 (patch)
treee0d2c8dea98e7ae4c9a49bb20ee39a8e4db7338d /sw/source/core/doc/docnum.cxx
parentba42b3d8f9fc79e8686ad360172fba36386fcd0d (diff)
sw_redlinehide_3: adapt setters in SwEditShell too
SwEditShell::SetNumRule(), DelNumRules(), NumUpDown() The selection could start in a different node than the props-node but the operation with hidden redlines should apply to the props-node. Change-Id: I307f6497c8fabdf8e12e352c6b9f2c4bf9101720
Diffstat (limited to 'sw/source/core/doc/docnum.cxx')
-rw-r--r--sw/source/core/doc/docnum.cxx98
1 files changed, 72 insertions, 26 deletions
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)