[Libreoffice-commits] core.git: Branch 'private/mst/sw_redlinehide_3' - 8 commits - sw/inc sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Oct 26 15:29:27 UTC 2018


 sw/inc/doc.hxx                                          |   12 +-
 sw/source/core/crsr/crstrvl.cxx                         |    4 
 sw/source/core/doc/DocumentContentOperationsManager.cxx |    4 
 sw/source/core/doc/docnum.cxx                           |   92 ++++++++++++----
 sw/source/core/edit/ednumber.cxx                        |   81 ++++++++------
 sw/source/core/inc/txtfrm.hxx                           |    2 
 sw/source/core/text/txtfrm.cxx                          |   27 ++++
 sw/source/uibase/wrtsh/wrtsh1.cxx                       |    2 
 8 files changed, 167 insertions(+), 57 deletions(-)

New commits:
commit 26c8b4ddf978e4fce5c7906270497c52e8ad1aee
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Fri Oct 26 17:22:48 2018 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Fri Oct 26 17:25:49 2018 +0200

    sw_redlinehide_3: adapt even more SwEditShell Num
    
    IsNoNum(), GetNumLevel(), IsNumRuleStart(), GetNodeNumStart()
    
    Change-Id: I38e592835f3e6e3e7faa901e5b6533b2222fb35a

diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx
index 4e7261f8e368..d82a72c03b13 100644
--- a/sw/source/core/edit/ednumber.cxx
+++ b/sw/source/core/edit/ednumber.cxx
@@ -666,7 +666,7 @@ bool SwEditShell::IsNoNum( bool bChkStart ) const
          && !HasSelection()
          && ( !bChkStart || IsSttPara() ) )
     {
-        const SwTextNode* pTextNd = GetCursor()->GetNode().GetTextNode();
+        const SwTextNode* pTextNd = sw::GetParaPropsNode(*GetLayout(), GetCursor()->GetPoint()->nNode);
         if ( pTextNd != nullptr )
         {
             bResult =  !pTextNd->IsCountedInList();
@@ -682,7 +682,7 @@ sal_uInt8 SwEditShell::GetNumLevel() const
     sal_uInt8 nLevel = MAXLEVEL;
 
     SwPaM* pCursor = GetCursor();
-    const SwTextNode* pTextNd = pCursor->GetNode().GetTextNode();
+    const SwTextNode *const pTextNd = sw::GetParaPropsNode(*GetLayout(), pCursor->GetPoint()->nNode);
 
     OSL_ENSURE( pTextNd, "GetNumLevel() without text node" );
     if ( pTextNd == nullptr )
@@ -837,7 +837,7 @@ void SwEditShell::SetNumRuleStart( bool bFlag, SwPaM* pPaM )
 bool SwEditShell::IsNumRuleStart( SwPaM* pPaM ) const
 {
     SwPaM* pCursor = pPaM ? pPaM : GetCursor( );
-    const SwTextNode* pTextNd = pCursor->GetNode().GetTextNode();
+    const SwTextNode *const pTextNd = sw::GetParaPropsNode(*GetLayout(), pCursor->GetPoint()->nNode);
     return pTextNd && pTextNd->IsListRestart();
 }
 
@@ -870,7 +870,7 @@ void SwEditShell::SetNodeNumStart( sal_uInt16 nStt )
 sal_uInt16 SwEditShell::GetNodeNumStart( SwPaM* pPaM ) const
 {
     SwPaM* pCursor = pPaM ? pPaM : GetCursor();
-    const SwTextNode* pTextNd = pCursor->GetNode().GetTextNode();
+    const SwTextNode *const pTextNd = sw::GetParaPropsNode(*GetLayout(), pCursor->GetPoint()->nNode);
     // correction: check, if list restart value is set at text node and
     // use new method <SwTextNode::GetAttrListRestartValue()>.
     // return USHRT_MAX, if no list restart value is found.
commit f39631e225669b46b5df7ac74b601b8e51a6e85c
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Fri Oct 26 17:20:17 2018 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Fri Oct 26 17:24:29 2018 +0200

    sw_redlinehide_3: adapt more SwEditShell Num
    
    ReplaceNumRule(), SetNumRuleStart(), SetNodeNumStart()
    
    Change-Id: I7e58d477b02e0e242ce3c12eca0071856533debf

diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx
index 272a83e8122c..4e7261f8e368 100644
--- a/sw/source/core/edit/ednumber.cxx
+++ b/sw/source/core/edit/ednumber.cxx
@@ -804,7 +804,8 @@ void SwEditShell::ChgNumRuleFormats( const SwNumRule& rRule )
 void SwEditShell::ReplaceNumRule( const OUString& rOldRule, const OUString& rNewRule )
 {
     StartAllAction();
-    GetDoc()->ReplaceNumRule( *GetCursor()->GetPoint(), rOldRule, rNewRule );
+    SwPosition const pos(sw::GetParaPropsPos(*GetLayout(), *GetCursor()->GetPoint()));
+    GetDoc()->ReplaceNumRule( pos, rOldRule, rNewRule );
     EndAllAction();
 }
 
@@ -818,11 +819,17 @@ void SwEditShell::SetNumRuleStart( bool bFlag, SwPaM* pPaM )
         SwPamRanges aRangeArr( *pCursor );
         SwPaM aPam( *pCursor->GetPoint() );
         for( size_t n = 0; n < aRangeArr.Count(); ++n )
-            GetDoc()->SetNumRuleStart( *aRangeArr.SetPam( n, aPam ).GetPoint(), bFlag );
+        {
+            SwPosition const pos(sw::GetParaPropsPos(*GetLayout(), *aRangeArr.SetPam( n, aPam ).GetPoint()));
+            GetDoc()->SetNumRuleStart( pos, bFlag );
+        }
         GetDoc()->GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr );
     }
     else
-        GetDoc()->SetNumRuleStart( *pCursor->GetPoint(), bFlag );
+    {
+        SwPosition const pos(sw::GetParaPropsPos(*GetLayout(), *GetCursor()->GetPoint()));
+        GetDoc()->SetNumRuleStart(pos, bFlag);
+    }
 
     EndAllAction();
 }
@@ -845,11 +852,17 @@ void SwEditShell::SetNodeNumStart( sal_uInt16 nStt )
         SwPamRanges aRangeArr( *pCursor );
         SwPaM aPam( *pCursor->GetPoint() );
         for( size_t n = 0; n < aRangeArr.Count(); ++n )
-            GetDoc()->SetNodeNumStart( *aRangeArr.SetPam( n, aPam ).GetPoint(), nStt );
+        {
+            SwPosition const pos(sw::GetParaPropsPos(*GetLayout(), *aRangeArr.SetPam( n, aPam ).GetPoint()));
+            GetDoc()->SetNodeNumStart( pos, nStt );
+        }
         GetDoc()->GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr );
     }
     else
-        GetDoc()->SetNodeNumStart( *pCursor->GetPoint(), nStt );
+    {
+        SwPosition const pos(sw::GetParaPropsPos(*GetLayout(), *pCursor->GetPoint()));
+        GetDoc()->SetNodeNumStart( pos, nStt );
+    }
 
     EndAllAction();
 }
diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx
index bac7372cd27e..d74f5d4dd2d0 100644
--- a/sw/source/core/inc/txtfrm.hxx
+++ b/sw/source/core/inc/txtfrm.hxx
@@ -102,6 +102,7 @@ std::unique_ptr<sw::MergedPara> CheckParaRedlineMerge(SwTextFrame & rFrame, SwTe
 bool FrameContainsNode(SwContentFrame const& rFrame, sal_uLong nNodeIndex);
 bool IsParaPropsNode(SwRootFrame const& rLayout, SwTextNode const& rNode);
 SwTextNode * GetParaPropsNode(SwRootFrame const& rLayout, SwNodeIndex const& rNode);
+SwPosition GetParaPropsPos(SwRootFrame const& rLayout, SwPosition const& rPos);
 
 TextFrameIndex UpdateMergedParaForDelete(MergedPara & rMerged,
         bool isRealDelete,
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index e1f4beaefc3d..24d6b5fdb347 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -341,6 +341,19 @@ namespace sw {
         }
     }
 
+    SwPosition
+    GetParaPropsPos(SwRootFrame const& rLayout, SwPosition const& rPos)
+    {
+        SwPosition pos(rPos);
+        SwTextNode const*const pNode(pos.nNode.GetNode().GetTextNode());
+        if (pNode)
+        {
+            pos.nNode = *sw::GetParaPropsNode(rLayout, *pNode);
+            pos.nContent.Assign(pos.nNode.GetNode().GetContentNode(), 0);
+        }
+        return pos;
+    }
+
 } // namespace sw
 
 /// Switches width and height of the text frame
commit 106f51e17c057adba0de233a25a0c7c1ad1136bb
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Fri Oct 26 17:12:14 2018 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Fri Oct 26 17:13:42 2018 +0200

    sw_redlinehide_3: adapt SwEditShell::SearchNumRule()
    
    Change-Id: Ic7d07a1e4920d5776a8fec3893cd2cd2aff2c6fc

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 8072372e78e7..8ccee0b48349 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1100,6 +1100,7 @@ public:
                                     const bool bOutline,
                                     int nNonEmptyAllowed,
                                     OUString& sListId,
+                                    SwRootFrame const* pLayout,
                                     const bool bInvestigateStartNode = false );
 
     // Paragraphs without numbering but with indents.
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 85cef08f4698..e52356822ed4 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -4337,11 +4337,11 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos,
     // Keep also the <ListId> value for possible propagation.
     OUString aListIdToPropagate;
     const SwNumRule* pNumRuleToPropagate =
-        pDoc->SearchNumRule( rPos, false, true, false, 0, aListIdToPropagate, true );
+        pDoc->SearchNumRule( rPos, false, true, false, 0, aListIdToPropagate, nullptr, true );
     if ( !pNumRuleToPropagate )
     {
         pNumRuleToPropagate =
-            pDoc->SearchNumRule( rPos, false, false, false, 0, aListIdToPropagate, true );
+            pDoc->SearchNumRule( rPos, false, false, false, 0, aListIdToPropagate, nullptr, true );
     }
     // #i86492#
     // Do not propagate previous found list, if
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index db962dfd71a2..ff96eb5596e8 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -1236,7 +1236,7 @@ void SwDoc::MakeUniqueNumRules(const SwPaM & rPaM)
                             const_cast<SwNumRule *>
                             (SearchNumRule( aPos, false, pCNd->HasNumber(),
                                             false, 0,
-                                            aListStyleData.sListId, true ));
+                                    aListStyleData.sListId, nullptr, true ));
                     }
 
                     if ( aListStyleData.pReplaceNumRule == nullptr )
@@ -1571,10 +1571,15 @@ const SwNumRule *  SwDoc::SearchNumRule(const SwPosition & rPos,
                                         const bool bOutline,
                                         int nNonEmptyAllowed,
                                         OUString& sListId,
+                                        SwRootFrame const* pLayout,
                                         const bool bInvestigateStartNode)
 {
     const SwNumRule * pResult = nullptr;
     SwTextNode * pTextNd = rPos.nNode.GetNode().GetTextNode();
+    if (pLayout)
+    {
+        pTextNd = sw::GetParaPropsNode(*pLayout, rPos.nNode);
+    }
     SwNode * pStartFromNode = pTextNd;
 
     if (pTextNd)
@@ -1588,9 +1593,9 @@ const SwNumRule *  SwDoc::SearchNumRule(const SwPosition & rPos,
             if ( !bInvestigateStartNode )
             {
                 if (bForward)
-                    ++aIdx;
+                    lcl_GotoNextLayoutTextFrame(aIdx, pLayout);
                 else
-                    --aIdx;
+                    lcl_GotoPrevLayoutTextFrame(aIdx, pLayout);
             }
 
             if (aIdx.GetNode().IsTextNode())
@@ -1626,9 +1631,9 @@ const SwNumRule *  SwDoc::SearchNumRule(const SwPosition & rPos,
             if ( bInvestigateStartNode )
             {
                 if (bForward)
-                    ++aIdx;
+                    lcl_GotoNextLayoutTextFrame(aIdx, pLayout);
                 else
-                    --aIdx;
+                    lcl_GotoPrevLayoutTextFrame(aIdx, pLayout);
             }
 
             pNode = &aIdx.GetNode();
diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx
index 9068ba1bce49..272a83e8122c 100644
--- a/sw/source/core/edit/ednumber.cxx
+++ b/sw/source/core/edit/ednumber.cxx
@@ -873,7 +873,7 @@ const SwNumRule * SwEditShell::SearchNumRule( const bool bNum,
 {
     return GetDoc()->SearchNumRule( *(GetCursor()->Start()),
                                     false/*bForward*/, bNum, false/*bOutline*/, -1/*nNonEmptyAllowe*/,
-                                    sListId );
+                                    sListId, GetLayout() );
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx
index f97a0daf62ad..9ddfd9fe39e8 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -1122,7 +1122,7 @@ void SwWrtShell::NumOrBulletOn(bool bNum)
     {
         pNumRule = GetDoc()->SearchNumRule( *GetCursor()->GetPoint(),
                                             false, bNum, false, 0,
-                                            sContinuedListId );
+                                            sContinuedListId, GetLayout() );
         bContinueFoundNumRule = pNumRule != nullptr;
     }
 
commit e80304f652383e1212e1669f735cbd8e1af20927
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Fri Oct 26 14:39:23 2018 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Fri Oct 26 17:10:49 2018 +0200

    sw_redlinehide_3: adapt SwDoc::GotoNextNum()/GotoPrevNum()
    
    ... and callers in SwCursorShell / SwEditShell.
    
    Change-Id: Iffe4ca7893b97df8bd07f25c9e0e1dc908011e3f

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 4ef4f0e51a29..8072372e78e7 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1065,9 +1065,11 @@ public:
                         const OUString& rNewRule );
 
     // Goto next/previous on same level.
-    static bool GotoNextNum( SwPosition&, bool bOverUpper = true,
+    static bool GotoNextNum( SwPosition&, SwRootFrame const* pLayout,
+                        bool bOverUpper = true,
                         sal_uInt8* pUpper = nullptr, sal_uInt8* pLower = nullptr );
-    static bool GotoPrevNum( SwPosition&, bool bOverUpper = true );
+    static bool GotoPrevNum( SwPosition&, SwRootFrame const* pLayout,
+                        bool bOverUpper = true );
 
     /** Searches for a text node with a numbering rule.
 
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index 9b8f2e6c6bf3..05890b2e1803 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -112,14 +112,14 @@ void SwCursorShell::MoveCursorToNum()
 /// go to next/previous point on the same level
 void SwCursorShell::GotoNextNum()
 {
-    if (!SwDoc::GotoNextNum( *m_pCurrentCursor->GetPoint() ))
+    if (!SwDoc::GotoNextNum(*m_pCurrentCursor->GetPoint(), GetLayout()))
         return;
     MoveCursorToNum();
 }
 
 void SwCursorShell::GotoPrevNum()
 {
-    if (!SwDoc::GotoPrevNum( *m_pCurrentCursor->GetPoint() ))
+    if (!SwDoc::GotoPrevNum(*m_pCurrentCursor->GetPoint(), GetLayout()))
         return;
     MoveCursorToNum();
 }
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index f8ed4e468393..db962dfd71a2 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -42,6 +42,7 @@
 #include <docary.hxx>
 #include <mvsave.hxx>
 #include <txtfrm.hxx>
+#include <rootfrm.hxx>
 #include <pamtyp.hxx>
 #include <redline.hxx>
 #include <strings.hrc>
@@ -1407,10 +1408,47 @@ static bool lcl_IsValidPrevNextNumNode( const SwNodeIndex& rIdx )
     return bRet;
 }
 
+static void
+lcl_GotoPrevLayoutTextFrame(SwNodeIndex & rIndex, SwRootFrame const*const pLayout)
+{
+   if (pLayout && pLayout->IsHideRedlines()
+       && rIndex.GetNode().IsTextNode()
+       && rIndex.GetNode().GetRedlineMergeFlag() != SwNode::Merge::None)
+    {
+        rIndex = *static_cast<SwTextFrame*>(rIndex.GetNode().GetTextNode()->getLayoutFrame(pLayout))->GetMergedPara()->pFirstNode;
+    }
+    --rIndex;
+    if (pLayout && rIndex.GetNode().IsTextNode())
+    {
+        rIndex = *sw::GetParaPropsNode(*pLayout, *rIndex.GetNode().GetTextNode());
+    }
+}
+
+static void
+lcl_GotoNextLayoutTextFrame(SwNodeIndex & rIndex, SwRootFrame const*const pLayout)
+{
+   if (pLayout && pLayout->IsHideRedlines()
+       && rIndex.GetNode().IsTextNode()
+       && rIndex.GetNode().GetRedlineMergeFlag() != SwNode::Merge::None)
+    {
+        rIndex = *static_cast<SwTextFrame*>(rIndex.GetNode().GetTextNode()->getLayoutFrame(pLayout))->GetMergedPara()->pLastNode;
+    }
+    ++rIndex;
+    if (pLayout && rIndex.GetNode().IsTextNode())
+    {
+        rIndex = *sw::GetParaPropsNode(*pLayout, *rIndex.GetNode().GetTextNode());
+    }
+}
+
 static bool lcl_GotoNextPrevNum( SwPosition& rPos, bool bNext,
-                            bool bOverUpper, sal_uInt8* pUpper, sal_uInt8* pLower )
+        bool bOverUpper, sal_uInt8* pUpper, sal_uInt8* pLower,
+        SwRootFrame const*const pLayout)
 {
     const SwTextNode* pNd = rPos.nNode.GetNode().GetTextNode();
+    if (pNd && pLayout)
+    {
+        pNd = sw::GetParaPropsNode(*pLayout, *pNd);
+    }
     if( !pNd || nullptr == pNd->GetNumRule() )
         return false;
 
@@ -1422,7 +1460,7 @@ static bool lcl_GotoNextPrevNum( SwPosition& rPos, bool bNext,
         // If NO_NUMLEVEL is switched on, we search the preceding Node with Numbering
         bool bError = false;
         do {
-            --aIdx;
+            lcl_GotoPrevLayoutTextFrame(aIdx, pLayout);
             if( aIdx.GetNode().IsTextNode() )
             {
                 pNd = aIdx.GetNode().GetTextNode();
@@ -1454,12 +1492,12 @@ static bool lcl_GotoNextPrevNum( SwPosition& rPos, bool bNext,
     const SwTextNode* pLast;
     if( bNext )
     {
-        ++aIdx;
+        lcl_GotoNextLayoutTextFrame(aIdx, pLayout);
         pLast = pNd;
     }
     else
     {
-        --aIdx;
+        lcl_GotoPrevLayoutTextFrame(aIdx, pLayout);
         pLast = nullptr;
     }
 
@@ -1490,9 +1528,9 @@ static bool lcl_GotoNextPrevNum( SwPosition& rPos, bool bNext,
             break;
 
         if( bNext )
-            ++aIdx;
+            lcl_GotoNextLayoutTextFrame(aIdx, pLayout);
         else
-            --aIdx;
+            lcl_GotoPrevLayoutTextFrame(aIdx, pLayout);
     }
 
     if( !bRet && !bOverUpper && pLast )     // do not iterate over higher numbers, but still to the end
@@ -1521,10 +1559,10 @@ static bool lcl_GotoNextPrevNum( SwPosition& rPos, bool bNext,
     return bRet;
 }
 
-bool SwDoc::GotoNextNum( SwPosition& rPos, bool bOverUpper,
-                            sal_uInt8* pUpper, sal_uInt8* pLower  )
+bool SwDoc::GotoNextNum(SwPosition& rPos, SwRootFrame const*const pLayout,
+        bool bOverUpper, sal_uInt8* pUpper, sal_uInt8* pLower)
 {
-    return ::lcl_GotoNextPrevNum( rPos, true, bOverUpper, pUpper, pLower );
+    return ::lcl_GotoNextPrevNum(rPos, true, bOverUpper, pUpper, pLower, pLayout);
 }
 
 const SwNumRule *  SwDoc::SearchNumRule(const SwPosition & rPos,
@@ -1602,9 +1640,10 @@ const SwNumRule *  SwDoc::SearchNumRule(const SwPosition & rPos,
     return pResult;
 }
 
-bool SwDoc::GotoPrevNum( SwPosition& rPos, bool bOverUpper  )
+bool SwDoc::GotoPrevNum(SwPosition& rPos, SwRootFrame const*const pLayout,
+        bool bOverUpper)
 {
-    return ::lcl_GotoNextPrevNum( rPos, false, bOverUpper, nullptr, nullptr );
+    return ::lcl_GotoNextPrevNum(rPos, false, bOverUpper, nullptr, nullptr, pLayout);
 }
 
 bool SwDoc::NumUpDown( const SwPaM& rPam, bool bDown )
diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx
index f6394b08d808..9068ba1bce49 100644
--- a/sw/source/core/edit/ednumber.cxx
+++ b/sw/source/core/edit/ednumber.cxx
@@ -430,7 +430,7 @@ void SwEditShell::GetCurrentOutlineLevels( sal_uInt8& rUpper, sal_uInt8& rLower
     aCursor.SetMark();
     if( pCursor->HasMark() )
         *aCursor.GetPoint() = *pCursor->End();
-    SwDoc::GotoNextNum( *aCursor.GetPoint(), false, &rUpper, &rLower );
+    SwDoc::GotoNextNum(*aCursor.GetPoint(), GetLayout(), false, &rUpper, &rLower);
 }
 
 bool SwEditShell::MoveNumParas( bool bUpperLower, bool bUpperLeft )
@@ -447,7 +447,7 @@ bool SwEditShell::MoveNumParas( bool bUpperLower, bool bUpperLeft )
 
     bool bRet = false;
     sal_uInt8 nUpperLevel, nLowerLevel;
-    if( SwDoc::GotoNextNum( *aCursor.GetPoint(), false,
+    if (SwDoc::GotoNextNum( *aCursor.GetPoint(), GetLayout(), false,
                                 &nUpperLevel, &nLowerLevel ))
     {
         if( bUpperLower )
@@ -459,7 +459,7 @@ bool SwEditShell::MoveNumParas( bool bUpperLower, bool bUpperLeft )
             if( bUpperLeft ) // move up
             {
                 SwPosition aPos( *aCursor.GetMark() );
-                if( SwDoc::GotoPrevNum( aPos, false ) )
+                if (SwDoc::GotoPrevNum( aPos, GetLayout(), false ))
                     nOffset = aPos.nNode.GetIndex() -
                             aCursor.GetMark()->nNode.GetIndex();
                 else
@@ -475,7 +475,9 @@ bool SwEditShell::MoveNumParas( bool bUpperLower, bool bUpperLeft )
             }
             else             // move down
             {
-                const SwNumRule* pOrig = aCursor.GetNode(false).GetTextNode()->GetNumRule();
+                assert(!aCursor.GetNode().IsTextNode()
+                    || sw::IsParaPropsNode(*GetLayout(), *aCursor.GetNode().GetTextNode()));
+                const SwNumRule* pOrig = sw::GetParaPropsNode(*GetLayout(), *aCursor.GetNode(false).GetTextNode())->GetNumRule();
                 if( aCursor.GetNode().IsTextNode() &&
                     pOrig == aCursor.GetNode().GetTextNode()->GetNumRule() )
                 {
commit cf6555f33872e55718cc5a3ff9559c46b8ba0a71
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Fri Oct 26 12:48:46 2018 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Fri Oct 26 13:09:00 2018 +0200

    sw_redlinehide_3: SwEditShell::HasNumber, HasBullet etc.
    
    Change-Id: I6db8421a52f7a9bece5ebb95b377dd3bb0a39af4

diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx
index 28345c98147d..f6394b08d808 100644
--- a/sw/source/core/edit/ednumber.cxx
+++ b/sw/source/core/edit/ednumber.cxx
@@ -150,8 +150,7 @@ void SwEditShell::NoNum()
 bool SwEditShell::SelectionHasNumber() const
 {
     bool bResult = HasNumber();
-    const SwTextNode * pTextNd =
-        GetCursor()->GetPoint()->nNode.GetNode().GetTextNode();
+    const SwTextNode * pTextNd = sw::GetParaPropsNode(*GetLayout(), GetCursor()->GetPoint()->nNode);
     if (!bResult && pTextNd && pTextNd->Len()==0 && !pTextNd->GetNumRule()) {
         SwPamRanges aRangeArr( *GetCursor() );
         SwPaM aPam( *GetCursor()->GetPoint() );
@@ -168,6 +167,10 @@ bool SwEditShell::SelectionHasNumber() const
                 for (sal_uInt32 nPos = nStt; nPos<=nEnd; nPos++)
                 {
                     pTextNd = mxDoc->GetNodes()[nPos]->GetTextNode();
+                    if (pTextNd)
+                    {
+                        pTextNd = sw::GetParaPropsNode(*GetLayout(), SwNodeIndex(*pTextNd));
+                    }
                     if (pTextNd && pTextNd->Len()!=0)
                     {
                         bResult = pTextNd->HasNumber();
@@ -196,8 +199,7 @@ bool SwEditShell::SelectionHasNumber() const
 bool SwEditShell::SelectionHasBullet() const
 {
     bool bResult = HasBullet();
-    const SwTextNode * pTextNd =
-        GetCursor()->GetPoint()->nNode.GetNode().GetTextNode();
+    const SwTextNode * pTextNd = sw::GetParaPropsNode(*GetLayout(), GetCursor()->GetPoint()->nNode);
     if (!bResult && pTextNd && pTextNd->Len()==0 && !pTextNd->GetNumRule()) {
         SwPamRanges aRangeArr( *GetCursor() );
         SwPaM aPam( *GetCursor()->GetPoint() );
@@ -214,6 +216,10 @@ bool SwEditShell::SelectionHasBullet() const
                 for (sal_uInt32 nPos = nStt; nPos<=nEnd; nPos++)
                 {
                     pTextNd = mxDoc->GetNodes()[nPos]->GetTextNode();
+                    if (pTextNd)
+                    {
+                        pTextNd = sw::GetParaPropsNode(*GetLayout(), SwNodeIndex(*pTextNd));
+                    }
                     if (pTextNd && pTextNd->Len()!=0)
                     {
                         bResult = pTextNd->HasBullet();
@@ -235,8 +241,7 @@ bool SwEditShell::HasNumber() const
 {
     bool bResult = false;
 
-    const SwTextNode * pTextNd =
-        GetCursor()->GetPoint()->nNode.GetNode().GetTextNode();
+    const SwTextNode *const pTextNd = sw::GetParaPropsNode(*GetLayout(), GetCursor()->GetPoint()->nNode);
 
     if (pTextNd)
     {
@@ -258,8 +263,7 @@ bool SwEditShell::HasBullet() const
 {
     bool bResult = false;
 
-    const SwTextNode * pTextNd =
-        GetCursor()->GetPoint()->nNode.GetNode().GetTextNode();
+    const SwTextNode *const pTextNd = sw::GetParaPropsNode(*GetLayout(), GetCursor()->GetPoint()->nNode);
 
     if (pTextNd)
     {
commit bccac365f8373ca150d7625036557662a13112f1
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Fri Oct 26 12:48:16 2018 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Fri Oct 26 13:08:44 2018 +0200

    sw_redlinehide_3: fix GetCurrentParaOutlineLevel
    
    Change-Id: I1e4c79b78f644dcebf011757be6f5e85c8924441

diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx
index 2571533e9fff..28345c98147d 100644
--- a/sw/source/core/edit/ednumber.cxx
+++ b/sw/source/core/edit/ednumber.cxx
@@ -413,8 +413,8 @@ int SwEditShell::GetCurrentParaOutlineLevel( ) const
     int nLevel = 0;
 
     SwPaM* pCursor = GetCursor();
-    const SwTextNode* pTextNd = pCursor->GetNode().GetTextNode();
-    if (pTextNd && sw::IsParaPropsNode(*GetLayout(), *pTextNd))
+    const SwTextNode *const pTextNd = sw::GetParaPropsNode(*GetLayout(), pCursor->GetPoint()->nNode);
+    if (pTextNd)
         nLevel = pTextNd->GetAttrOutlineLevel();
     return nLevel;
 }
diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx
index 7e2c2aef044c..bac7372cd27e 100644
--- a/sw/source/core/inc/txtfrm.hxx
+++ b/sw/source/core/inc/txtfrm.hxx
@@ -101,6 +101,7 @@ std::unique_ptr<sw::MergedPara> CheckParaRedlineMerge(SwTextFrame & rFrame, SwTe
 
 bool FrameContainsNode(SwContentFrame const& rFrame, sal_uLong nNodeIndex);
 bool IsParaPropsNode(SwRootFrame const& rLayout, SwTextNode const& rNode);
+SwTextNode * GetParaPropsNode(SwRootFrame const& rLayout, SwNodeIndex const& rNode);
 
 TextFrameIndex UpdateMergedParaForDelete(MergedPara & rMerged,
         bool isRealDelete,
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index d550944252e0..e1f4beaefc3d 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -327,6 +327,20 @@ namespace sw {
         return true;
     }
 
+    SwTextNode *
+    GetParaPropsNode(SwRootFrame const& rLayout, SwNodeIndex const& rPos)
+    {
+        SwTextNode *const pTextNode(rPos.GetNode().GetTextNode());
+        if (pTextNode && !sw::IsParaPropsNode(rLayout, *pTextNode))
+        {
+            return static_cast<SwTextFrame*>(pTextNode->getLayoutFrame(&rLayout))->GetMergedPara()->pParaPropsNode;
+        }
+        else
+        {
+            return pTextNode;
+        }
+    }
+
 } // namespace sw
 
 /// Switches width and height of the text frame
commit 02eedffe53d98fd9c2c08c3d6b6dad7308ac8ec7
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Fri Oct 26 11:58:58 2018 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Fri Oct 26 11:58:58 2018 +0200

    sw_redlinehide_3: SwEditShell::IsFirstNumRuleAtPos()
    
    Change-Id: Ic6bd9adc909d7c325f5e450fd9e53a15f68e7a63

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 5acdb10dd8a1..4ef4f0e51a29 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1539,7 +1539,7 @@ public:
      */
     static OUString GetPaMDescr(const SwPaM & rPaM);
 
-    static bool IsFirstOfNumRuleAtPos( const SwPosition & rPos );
+    static bool IsFirstOfNumRuleAtPos(const SwPosition & rPos, SwRootFrame const* pLayout);
 
     // access methods for XForms model(s)
 
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index cb1baa96358e..f8ed4e468393 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -2323,13 +2323,18 @@ void SwDoc::MarkListLevel( const OUString& sListId,
     }
 }
 
-bool SwDoc::IsFirstOfNumRuleAtPos( const SwPosition & rPos )
+bool SwDoc::IsFirstOfNumRuleAtPos(const SwPosition & rPos,
+        SwRootFrame const*const pLayout)
 {
     bool bResult = false;
 
     const SwTextNode* pTextNode = rPos.nNode.GetNode().GetTextNode();
     if ( pTextNode != nullptr )
     {
+        if (pLayout && !sw::IsParaPropsNode(*pLayout, *pTextNode))
+        {
+            pTextNode = static_cast<SwTextFrame*>(pTextNode->getLayoutFrame(pLayout))->GetMergedPara()->pParaPropsNode;
+        }
         bResult = pTextNode->IsFirstOfNumRule();
     }
 
diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx
index 00b429349775..2571533e9fff 100644
--- a/sw/source/core/edit/ednumber.cxx
+++ b/sw/source/core/edit/ednumber.cxx
@@ -331,7 +331,7 @@ void SwEditShell::NumUpDown( bool bDown )
 
 bool SwEditShell::IsFirstOfNumRuleAtCursorPos() const
 {
-    return SwDoc::IsFirstOfNumRuleAtPos( *GetCursor()->GetPoint() );
+    return SwDoc::IsFirstOfNumRuleAtPos(*GetCursor()->GetPoint(), GetLayout());
 }
 
 // -> #i23725#, #i90078#
commit 9f3ac160629ea50d8f801c523d37dd90bbfb8168
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Fri Oct 26 11:29:16 2018 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Fri Oct 26 11:34:28 2018 +0200

    sw_redlinehide_3: adapt SwEditShell callers of SwDoc::GetNumRuleAtPos
    
    Change-Id: I192a9743300a77bc463319789064abd89d046b0a

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 2670ff98bd03..5acdb10dd8a1 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1032,7 +1032,8 @@ public:
     void SetNumRuleStart( const SwPosition& rPos, bool bFlag = true );
     void SetNodeNumStart( const SwPosition& rPos, sal_uInt16 nStt );
 
-    static SwNumRule* GetNumRuleAtPos( const SwPosition& rPos );
+    // sw_redlinehide: may set rPos to different node (the one with the NumRule)
+    static SwNumRule* GetNumRuleAtPos(SwPosition& rPos, SwRootFrame const* pLayout = nullptr);
 
     const SwNumRuleTable& GetNumRuleTable() const { return *mpNumRuleTable; }
 
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index 78696475537f..cb1baa96358e 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -2100,13 +2100,20 @@ bool SwDoc::NumOrNoNum( const SwNodeIndex& rIdx, bool bDel )
     return bResult;
 }
 
-SwNumRule* SwDoc::GetNumRuleAtPos( const SwPosition& rPos )
+SwNumRule* SwDoc::GetNumRuleAtPos(SwPosition& rPos,
+        SwRootFrame const*const pLayout)
 {
     SwNumRule* pRet = nullptr;
     SwTextNode* pTNd = rPos.nNode.GetNode().GetTextNode();
 
     if ( pTNd != nullptr )
     {
+        if (pLayout && !sw::IsParaPropsNode(*pLayout, *pTNd))
+        {
+            pTNd = static_cast<SwTextFrame*>(pTNd->getLayoutFrame(pLayout))->GetMergedPara()->pParaPropsNode;
+            rPos.nNode = *pTNd;
+            rPos.nContent.Assign(pTNd, 0);
+        }
         pRet = pTNd->GetNumRule();
     }
 
diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx
index 1ea0ace72e8d..00b429349775 100644
--- a/sw/source/core/edit/ednumber.cxx
+++ b/sw/source/core/edit/ednumber.cxx
@@ -361,7 +361,8 @@ void SwEditShell::SetIndent(short nIndent, const SwPosition & rPos)
 {
     StartAllAction();
 
-    SwNumRule *pCurNumRule = SwDoc::GetNumRuleAtPos(rPos);
+    SwPosition pos(rPos);
+    SwNumRule *pCurNumRule = SwDoc::GetNumRuleAtPos(pos, GetLayout());
 
     if (pCurNumRule)
     {
@@ -372,7 +373,7 @@ void SwEditShell::SetIndent(short nIndent, const SwPosition & rPos)
         }
         else
         {
-            const SwTextNode* pTextNode = rPos.nNode.GetNode().GetTextNode();
+            const SwTextNode* pTextNode = pos.nNode.GetNode().GetTextNode();
             if ( pTextNode != nullptr
                  && pTextNode->GetActualListLevel() >= 0 )
             {
@@ -381,7 +382,7 @@ void SwEditShell::SetIndent(short nIndent, const SwPosition & rPos)
         }
 
         // change numbering rule - changed numbering rule is not applied at <aPaM>
-        SwPaM aPaM(rPos);
+        SwPaM aPaM(pos);
         GetDoc()->SetNumRule( aPaM, aRule, false, OUString(), false );
     }
 
@@ -696,7 +697,7 @@ sal_uInt8 SwEditShell::GetNumLevel() const
 
 const SwNumRule* SwEditShell::GetNumRuleAtCurrCursorPos() const
 {
-    return SwDoc::GetNumRuleAtPos( *GetCursor()->GetPoint() );
+    return SwDoc::GetNumRuleAtPos( *GetCursor()->GetPoint(), GetLayout() );
 }
 
 const SwNumRule* SwEditShell::GetNumRuleAtCurrentSelection() const
@@ -710,7 +711,8 @@ const SwNumRule* SwEditShell::GetNumRuleAtCurrentSelection() const
 
         for ( SwNodeIndex aNode = rCurrentCursor.Start()->nNode; aNode <= aEndNode; ++aNode )
         {
-            const SwNumRule* pNumRule = SwDoc::GetNumRuleAtPos( SwPosition( aNode ) );
+            SwPosition pos(aNode);
+            const SwNumRule* pNumRule = SwDoc::GetNumRuleAtPos(pos, GetLayout());
             if ( pNumRule == nullptr )
             {
                 continue;


More information about the Libreoffice-commits mailing list