[Libreoffice-commits] core.git: Branch 'private/mst/sw_redlinehide_4a' - 6 commits - sw/inc sw/source sw/uiconfig

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Nov 27 18:00:00 UTC 2018


Rebased ref, commits from common ancestor:
commit c6e0ee9ef62ac8d9ec28f711c781c47d03e2c5d7
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Tue Nov 27 18:28:41 2018 +0100
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Tue Nov 27 18:56:04 2018 +0100

    sw_redlinehide_4a: SwAutoFormat iterates frames, not nodes
    
    In order to not require moving the delete redlines out of the document
    body, rely on the DeleteSel() implementation skipping over the redlines,
    and also pass the shell's layout to the various SwDoc functions that
    are called.
    
    Previously, the redlines were not deleted by DeleteSel() due to
    SwAutoFormat setting RedlineFlags::Ignore.
    
    Change-Id: Ib05ecb534993368d81f66e70124617968b4c8e9a

diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index 0b7d3a170ba1..253da644837f 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -1803,6 +1803,9 @@ void SwDoc::SetTextFormatCollByAutoFormat( const SwPosition& rPos, sal_uInt16 nP
     {
         aPam.SetMark();
         aPam.GetMark()->nContent.Assign(pTNd, pTNd->GetText().getLength());
+        // sw_redlinehide: don't need layout currently because the only caller
+        // passes in the properties node
+        assert(static_cast<SwTextFrame const*>(pTNd->getLayoutFrame(nullptr))->GetTextNodeForParaProps() == pTNd);
         getIDocumentContentOperations().InsertItemSet( aPam, *pSet );
     }
 }
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index 8a5f87eaf00e..a9d91ff5b16a 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -135,34 +135,37 @@ class SwAutoFormat
         { return (' ' == c || '\t' == c || 0x0a == c|| 0x3000 == c /* Jap. space */); }
 
     void SetColl( sal_uInt16 nId, bool bHdLineOrText = false );
-    OUString GoNextPara();
-    bool HasObjects( const SwNode& rNd );
+    void GoNextPara();
+    bool HasObjects(const SwTextFrame &);
 
     // TextNode methods
-    const SwTextNode* GetNextNode() const;
-    static bool IsEmptyLine( const SwTextNode& rNd )
-        {   return rNd.GetText().isEmpty() ||
-                rNd.GetText().getLength() == GetLeadingBlanks( rNd.GetText() ); }
-
-    bool IsOneLine( const SwTextNode& ) const;
-    bool IsFastFullLine( const SwTextNode& ) const;
-    bool IsNoAlphaLine( const SwTextNode&) const;
-    bool IsEnumericChar( const SwTextNode&) const;
-    static bool IsBlanksInString( const SwTextNode&);
-    sal_uInt16 CalcLevel( const SwTextNode&, sal_uInt16 *pDigitLvl = nullptr ) const;
-    sal_Int32 GetBigIndent( sal_Int32& rCurrentSpacePos ) const;
+    const SwTextFrame * GetNextNode(bool isCheckEnd = true) const;
+    static bool IsEmptyLine(const SwTextFrame & rFrame)
+    {
+        return rFrame.GetText().isEmpty()
+            || rFrame.GetText().getLength() == GetLeadingBlanks(rFrame.GetText());
+    }
+
+    bool IsOneLine(const SwTextFrame &) const;
+    bool IsFastFullLine(const SwTextFrame &) const;
+    bool IsNoAlphaLine(const SwTextFrame &) const;
+    bool IsEnumericChar(const SwTextFrame &) const;
+    static bool IsBlanksInString(const SwTextFrame&);
+    sal_uInt16 CalcLevel(const SwTextFrame&, sal_uInt16 *pDigitLvl = nullptr) const;
+    sal_Int32 GetBigIndent(TextFrameIndex & rCurrentSpacePos) const;
 
     static OUString DelLeadingBlanks(const OUString& rStr);
     static OUString DelTrailingBlanks( const OUString& rStr );
     static sal_Int32 GetLeadingBlanks( const OUString& rStr );
     static sal_Int32 GetTrailingBlanks( const OUString& rStr );
 
-    bool IsFirstCharCapital( const SwTextNode& rNd ) const;
-    sal_uInt16 GetDigitLevel( const SwTextNode& rTextNd, sal_Int32& rPos,
+    bool IsFirstCharCapital(const SwTextFrame & rNd) const;
+    sal_uInt16 GetDigitLevel(const SwTextFrame& rFrame, TextFrameIndex& rPos,
                             OUString* pPrefix = nullptr, OUString* pPostfix = nullptr,
                             OUString* pNumTypes = nullptr ) const;
     /// get the FORMATTED TextFrame
     SwTextFrame* GetFrame( const SwTextNode& rTextNd ) const;
+    SwTextFrame * EnsureFormatted(SwTextFrame const&) const;
 
     void BuildIndent();
     void BuildText();
@@ -171,11 +174,10 @@ class SwAutoFormat
     void BuildNegIndent( SwTwips nSpaces );
     void BuildHeadLine( sal_uInt16 nLvl );
 
-    static bool HasSelBlanks( SwPaM& rPam );
-    static bool HasBreakAttr( const SwTextNode& );
+    static bool HasBreakAttr(const SwTextFrame &);
     void DeleteSel( SwPaM& rPam );
     void DeleteSelImpl(SwPaM & rDelPam, SwPaM & rPamToCorrect);
-    bool DeleteJoinCurNextPara( const OUString& rNxtPara );
+    bool DeleteJoinCurNextPara(SwTextFrame const* pNextFrame, bool bIgnoreLeadingBlanks = false);
     /// delete in the node start and/or end
     void DeleteLeadingTrailingBlanks( bool bStart = true, bool bEnd = true );
     void DelEmptyLine( bool bTstNextPara = true );
@@ -187,19 +189,22 @@ class SwAutoFormat
     /// execute AutoCorrect on current TextNode
     void AutoCorrect( sal_Int32 nSttPos = 0 );
 
-    bool CanJoin( const SwTextNode* pTextNd ) const
+    bool CanJoin(const SwTextFrame * pNextFrame) const
     {
-        return !m_bEnd && pTextNd &&
-             !IsEmptyLine( *pTextNd ) &&
-             !IsNoAlphaLine( *pTextNd) &&
-             !IsEnumericChar( *pTextNd ) &&
-             ((COMPLETE_STRING - 50 - pTextNd->GetText().getLength()) >
-                    m_pCurTextNd->GetText().getLength()) &&
-             !HasBreakAttr( *pTextNd );
+        return !m_bEnd && pNextFrame &&
+             !IsEmptyLine(*pNextFrame) &&
+             !IsNoAlphaLine(*pNextFrame) &&
+             !IsEnumericChar(*pNextFrame) &&
+             // check the last / first nodes here...
+             ((COMPLETE_STRING - 50 - pNextFrame->GetTextNodeFirst()->GetText().getLength()) >
+                    (m_pCurTextFrame->GetMergedPara()
+                      ? m_pCurTextFrame->GetMergedPara()->pLastNode
+                      : m_pCurTextNd)->GetText().getLength()) &&
+             !HasBreakAttr(*pNextFrame);
     }
 
     /// is a dot at the end ??
-    static bool IsSentenceAtEnd( const SwTextNode& rTextNd );
+    static bool IsSentenceAtEnd(const SwTextFrame & rTextFrame);
 
     bool DoUnderline();
     bool DoTable();
@@ -231,8 +236,13 @@ SwTextFrame* SwAutoFormat::GetFrame( const SwTextNode& rTextNd ) const
 {
     // get the Frame
     const SwContentFrame *pFrame = rTextNd.getLayoutFrame( m_pEditShell->GetLayout() );
-    OSL_ENSURE( pFrame, "For Autoformat a Layout is needed" );
+    assert(pFrame && "For Autoformat a Layout is needed");
+    return EnsureFormatted(*static_cast<SwTextFrame const*>(pFrame));
+}
 
+SwTextFrame * SwAutoFormat::EnsureFormatted(SwTextFrame const& rFrame) const
+{
+    SwTextFrame *const pFrame(const_cast<SwTextFrame*>(&rFrame));
     if( m_aFlags.bAFormatByInput && !pFrame->isFrameAreaDefinitionValid() )
     {
         DisableCallbackAction a(const_cast<SwRootFrame&>(*pFrame->getRootFrame()));
@@ -247,7 +257,7 @@ SwTextFrame* SwAutoFormat::GetFrame( const SwTextNode& rTextNd ) const
         }
     }
 
-    return const_cast<SwTextFrame*>(static_cast<const SwTextFrame*>(pFrame))->GetFormatted();
+    return pFrame->GetFormatted();
 }
 
 void SwAutoFormat::SetRedlineText_( sal_uInt16 nActionId )
@@ -285,7 +295,7 @@ void SwAutoFormat::SetRedlineText_( sal_uInt16 nActionId )
     m_pDoc->GetDocumentRedlineManager().SetAutoFormatRedlineComment( &sText, nSeqNo );
 }
 
-OUString SwAutoFormat::GoNextPara()
+void SwAutoFormat::GoNextPara()
 {
     SwNode* pNewNd = nullptr;
     do {
@@ -293,14 +303,14 @@ OUString SwAutoFormat::GoNextPara()
         if( m_aNdIdx.GetIndex() >= m_aEndNdIdx.GetIndex() )
         {
             m_bEnd = true;
-            return OUString();
+            return;
         }
 
-        ++m_aNdIdx;
+        sw::GotoNextLayoutTextFrame(m_aNdIdx, m_pEditShell->GetLayout());
         if( m_aNdIdx.GetIndex() >= m_aEndNdIdx.GetIndex() )
         {
             m_bEnd = true;
-            return OUString();
+            return;
         }
         else
             pNewNd = &m_aNdIdx.GetNode();
@@ -312,7 +322,7 @@ OUString SwAutoFormat::GoNextPara()
         if( pNewNd->IsEndNode() )
         {
             m_bEnd = true;
-            return OUString();
+            return;
         }
         else if( pNewNd->IsTableNode() )
             m_aNdIdx = *pNewNd->EndOfSectionNode();
@@ -330,10 +340,9 @@ OUString SwAutoFormat::GoNextPara()
 
     m_pCurTextNd = static_cast<SwTextNode*>(pNewNd);
     m_pCurTextFrame = GetFrame( *m_pCurTextNd );
-    return m_pCurTextNd->GetText();
 }
 
-bool SwAutoFormat::HasObjects( const SwNode& rNd )
+bool SwAutoFormat::HasObjects(const SwTextFrame & rFrame)
 {
     // Is there something bound to the paragraph in the paragraph
     // like Frames, DrawObjects, ...
@@ -344,7 +353,7 @@ bool SwAutoFormat::HasObjects( const SwNode& rNd )
         const SwFormatAnchor& rAnchor = pFrameFormat->GetAnchor();
         if ((RndStdIds::FLY_AT_PAGE != rAnchor.GetAnchorId()) &&
             rAnchor.GetContentAnchor() &&
-            &rAnchor.GetContentAnchor()->nNode.GetNode() == &rNd )
+            sw::FrameContainsNode(rFrame, rAnchor.GetContentAnchor()->nNode.GetIndex()))
         {
             bRet = true;
             break;
@@ -353,57 +362,61 @@ bool SwAutoFormat::HasObjects( const SwNode& rNd )
     return bRet;
 }
 
-const SwTextNode* SwAutoFormat::GetNextNode() const
+const SwTextFrame* SwAutoFormat::GetNextNode(bool const isCheckEnd) const
 {
-    if( m_aNdIdx.GetIndex()+1 >= m_aEndNdIdx.GetIndex() )
+    SwNodeIndex tmp(m_aNdIdx);
+    sw::GotoNextLayoutTextFrame(tmp, m_pEditShell->GetLayout());
+    if ((isCheckEnd && m_aEndNdIdx <= tmp) || !tmp.GetNode().IsTextNode())
         return nullptr;
-    return m_pDoc->GetNodes()[ m_aNdIdx.GetIndex() + 1 ]->GetTextNode();
+    // note: the returned frame is not necessarily formatted, have to call
+    // EnsureFormatted for that
+    return static_cast<SwTextFrame*>(tmp.GetNode().GetTextNode()->getLayoutFrame(m_pEditShell->GetLayout()));
 }
 
-bool SwAutoFormat::IsOneLine( const SwTextNode& rNd ) const
+bool SwAutoFormat::IsOneLine(const SwTextFrame & rFrame) const
 {
-    SwTextFrameInfo aFInfo( GetFrame( rNd ) );
+    SwTextFrameInfo aFInfo( EnsureFormatted(rFrame) );
     return aFInfo.IsOneLine();
 }
 
-bool SwAutoFormat::IsFastFullLine( const SwTextNode& rNd ) const
+bool SwAutoFormat::IsFastFullLine(const SwTextFrame & rFrame) const
 {
     bool bRet = m_aFlags.bRightMargin;
     if( bRet )
     {
-        SwTextFrameInfo aFInfo( GetFrame( rNd ) );
+        SwTextFrameInfo aFInfo( EnsureFormatted(rFrame) );
         bRet = aFInfo.IsFilled( m_aFlags.nRightMargin );
     }
     return bRet;
 }
 
-bool SwAutoFormat::IsEnumericChar( const SwTextNode& rNd ) const
+bool SwAutoFormat::IsEnumericChar(const SwTextFrame& rFrame) const
 {
-    const OUString& rText = rNd.GetText();
-    sal_Int32 nBlnks = GetLeadingBlanks( rText );
-    const sal_Int32 nLen = rText.getLength() - nBlnks;
+    const OUString& rText = rFrame.GetText();
+    TextFrameIndex nBlanks(GetLeadingBlanks(rText));
+    const TextFrameIndex nLen = TextFrameIndex(rText.getLength()) - nBlanks;
     if( !nLen )
         return false;
 
     // -, +, * separated by blank ??
-    if (2 < nLen && IsSpace(rText[nBlnks + 1]))
+    if (TextFrameIndex(2) < nLen && IsSpace(rText[sal_Int32(nBlanks) + 1]))
     {
-        if (StrChr(pBulletChar, rText[nBlnks]))
+        if (StrChr(pBulletChar, rText[sal_Int32(nBlanks)]))
             return true;
         // Should there be a symbol font at the position?
-        SwTextFrameInfo aFInfo( GetFrame( rNd ) );
-        if( aFInfo.IsBullet( nBlnks ))
+        SwTextFrameInfo aFInfo( EnsureFormatted(rFrame) );
+        if (aFInfo.IsBullet(nBlanks))
             return true;
     }
 
     // 1.) / 1. / 1.1.1 / (1). / (1) / ....
-    return USHRT_MAX != GetDigitLevel( rNd, nBlnks );
+    return USHRT_MAX != GetDigitLevel(rFrame, nBlanks);
 }
 
-bool SwAutoFormat::IsBlanksInString( const SwTextNode& rNd )
+bool SwAutoFormat::IsBlanksInString(const SwTextFrame& rFrame)
 {
     // Search more than 5 consecutive blanks/tabs in the string.
-    OUString sTmp( DelLeadingBlanks(rNd.GetText()) );
+    OUString sTmp( DelLeadingBlanks(rFrame.GetText()) );
     const sal_Int32 nLen = sTmp.getLength();
     sal_Int32 nIdx = 0;
     while (nIdx < nLen)
@@ -422,21 +435,23 @@ bool SwAutoFormat::IsBlanksInString( const SwTextNode& rNd )
     return false;
 }
 
-sal_uInt16 SwAutoFormat::CalcLevel( const SwTextNode& rNd, sal_uInt16 *pDigitLvl ) const
+sal_uInt16 SwAutoFormat::CalcLevel(const SwTextFrame & rFrame,
+        sal_uInt16 *const pDigitLvl) const
 {
     sal_uInt16 nLvl = 0, nBlnk = 0;
-    const OUString& rText = rNd.GetText();
+    const OUString& rText = rFrame.GetText();
     if( pDigitLvl )
         *pDigitLvl = USHRT_MAX;
 
-    if( RES_POOLCOLL_TEXT_MOVE == rNd.GetTextColl()->GetPoolFormatId() )
+    if (RES_POOLCOLL_TEXT_MOVE == rFrame.GetTextNodeForParaProps()->GetTextColl()->GetPoolFormatId())
     {
         ++nLvl;
     }
 
-    for (sal_Int32 n = 0, nEnd = rText.getLength(); n < nEnd; ++n)
+    for (TextFrameIndex n = TextFrameIndex(0),
+                     nEnd = TextFrameIndex(rText.getLength()); n < nEnd; ++n)
     {
-        switch (rText[n])
+        switch (rText[sal_Int32(n)])
         {
         case ' ':   if( 3 == ++nBlnk )
                     {
@@ -450,44 +465,49 @@ sal_uInt16 SwAutoFormat::CalcLevel( const SwTextNode& rNd, sal_uInt16 *pDigitLvl
         default:
             if( pDigitLvl )
                 // test 1.) / 1. / 1.1.1 / (1). / (1) / ....
-                *pDigitLvl = GetDigitLevel( rNd, n );
+                *pDigitLvl = GetDigitLevel(rFrame, n);
             return nLvl;
         }
     }
     return nLvl;
 }
 
-sal_Int32 SwAutoFormat::GetBigIndent( sal_Int32& rCurrentSpacePos ) const
+sal_Int32 SwAutoFormat::GetBigIndent(TextFrameIndex & rCurrentSpacePos) const
 {
-    SwTextFrameInfo aFInfo( GetFrame( *m_pCurTextNd ) );
-    const SwTextFrame* pNxtFrame = nullptr;
+    SwTextFrameInfo aFInfo( m_pCurTextFrame );
+    const SwTextFrame* pNextFrame = nullptr;
 
     if( !m_bMoreLines )
     {
-        const SwTextNode* pNxtNd = GetNextNode();
-        if( !CanJoin( pNxtNd ) || !IsOneLine( *pNxtNd ) )
+        pNextFrame = GetNextNode();
+        if (!CanJoin(pNextFrame) || !IsOneLine(*pNextFrame))
             return 0;
 
-        pNxtFrame = GetFrame( *pNxtNd );
+        pNextFrame = EnsureFormatted(*pNextFrame);
     }
 
-    return aFInfo.GetBigIndent( rCurrentSpacePos, pNxtFrame );
+    return aFInfo.GetBigIndent( rCurrentSpacePos, pNextFrame );
 }
 
-bool SwAutoFormat::IsNoAlphaLine( const SwTextNode& rNd ) const
+bool SwAutoFormat::IsNoAlphaLine(const SwTextFrame & rFrame) const
 {
-    const OUString& rStr = rNd.GetText();
+    const OUString& rStr = rFrame.GetText();
     if( rStr.isEmpty() )
         return false;
     // or better: determine via number of AlphaNum and !AlphaNum characters
     sal_Int32 nANChar = 0, nBlnk = 0;
 
-    CharClass& rCC = GetCharClass( rNd.GetSwAttrSet().GetLanguage().GetLanguage() );
-    for( sal_Int32 n = 0, nEnd = rStr.getLength(); n < nEnd; ++n )
-        if( IsSpace( rStr[ n ] ) )
+    for (TextFrameIndex n = TextFrameIndex(0),
+                     nEnd = TextFrameIndex(rStr.getLength()); n < nEnd; ++n)
+        if (IsSpace(rStr[sal_Int32(n)]))
             ++nBlnk;
-        else if( rCC.isLetterNumeric( rStr, n ))
-            ++nANChar;
+        else
+        {
+            auto const pair = rFrame.MapViewToModel(n);
+            CharClass& rCC = GetCharClass(pair.first->GetSwAttrSet().GetLanguage().GetLanguage());
+            if (rCC.isLetterNumeric(rStr, sal_Int32(n)))
+                ++nANChar;
+        }
 
     // If there are 75% of non-alphanumeric characters, then true
     sal_uLong nLen = rStr.getLength() - nBlnk;
@@ -500,7 +520,7 @@ bool SwAutoFormat::DoUnderline()
     if( !m_aFlags.bSetBorder )
         return false;
 
-    OUString const& rText(m_pCurTextNd->GetText());
+    OUString const& rText(m_pCurTextFrame->GetText());
     int eState = 0;
     sal_Int32 nCnt = 0;
     while (nCnt < rText.getLength())
@@ -527,9 +547,9 @@ bool SwAutoFormat::DoUnderline()
     if( 2 < nCnt )
     {
         // then underline the previous paragraph if one exists
-        DelEmptyLine( false );
+        DelEmptyLine( false ); // -> point will be on end of current paragraph
         m_aDelPam.SetMark();
-        m_aDelPam.GetMark()->nContent = 0;
+        *m_aDelPam.GetMark() = m_pCurTextFrame->MapViewToModelPos(TextFrameIndex(0));
 
         editeng::SvxBorderLine aLine;
         switch( eState )
@@ -567,7 +587,8 @@ bool SwAutoFormat::DoUnderline()
         aBox.SetLine( &aLine, SvxBoxItemLine::BOTTOM );
         aBox.SetDistance(42, SvxBoxItemLine::BOTTOM );     // ~0,75 mm
         aSet.Put(aBox);
-        m_pDoc->getIDocumentContentOperations().InsertItemSet( m_aDelPam, aSet );
+        m_pDoc->getIDocumentContentOperations().InsertItemSet(m_aDelPam, aSet,
+                SetAttrMode::DEFAULT, m_pEditShell->GetLayout());
 
         m_aDelPam.DeleteMark();
     }
@@ -580,24 +601,24 @@ bool SwAutoFormat::DoTable()
         m_pCurTextNd->FindTableNode() )
         return false;
 
-    const OUString& rTmp = m_pCurTextNd->GetText();
-    sal_Int32 nSttPlus = GetLeadingBlanks( rTmp );
-    sal_Int32 nEndPlus = GetTrailingBlanks( rTmp );
+    const OUString& rTmp = m_pCurTextFrame->GetText();
+    TextFrameIndex nSttPlus(GetLeadingBlanks(rTmp));
+    TextFrameIndex nEndPlus(GetTrailingBlanks(rTmp));
     sal_Unicode cChar;
 
-    if( 2 > nEndPlus - nSttPlus ||
-        ( '+' != ( cChar = rTmp[nSttPlus]) && '|' != cChar ) ||
-        ( '+' != ( cChar = rTmp[nEndPlus - 1]) && '|' != cChar ))
+    if (TextFrameIndex(2) > nEndPlus - nSttPlus
+        || ('+' != (cChar = rTmp[sal_Int32(nSttPlus)]) && '|' != cChar)
+        || ('+' != (cChar = rTmp[sal_Int32(nEndPlus) - 1]) && '|' != cChar))
         return false;
 
     SwTextFrameInfo aInfo( m_pCurTextFrame );
 
-    sal_Int32 n = nSttPlus;
+    TextFrameIndex n = nSttPlus;
     std::vector<sal_uInt16> aPosArr;
 
-    while (n < rTmp.getLength())
+    while (n < TextFrameIndex(rTmp.getLength()))
     {
-        switch (rTmp[n])
+        switch (rTmp[sal_Int32(n)])
         {
         case '-':
         case '_':
@@ -624,7 +645,7 @@ bool SwAutoFormat::DoTable()
         sal_uInt16 nColCnt = aPosArr.size() - 1;
         SwTwips nSttPos = aPosArr[ 0 ];
         sal_Int16 eHori;
-        switch( m_pCurTextNd->GetSwAttrSet().GetAdjust().GetAdjust() )
+        switch (m_pCurTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().GetAdjust().GetAdjust())
         {
         case SvxAdjust::Center:     eHori = text::HoriOrientation::CENTER;    break;
         case SvxAdjust::Right:      eHori = text::HoriOrientation::RIGHT;     break;
@@ -697,15 +718,17 @@ sal_Int32 SwAutoFormat::GetTrailingBlanks( const OUString& rStr )
     return ++n;
 }
 
-bool SwAutoFormat::IsFirstCharCapital( const SwTextNode& rNd ) const
+bool SwAutoFormat::IsFirstCharCapital(const SwTextFrame& rFrame) const
 {
-    const OUString& rText = rNd.GetText();
-    for( sal_Int32 n = 0, nEnd = rText.getLength(); n < nEnd; ++n )
-        if (!IsSpace(rText[n]))
+    const OUString& rText = rFrame.GetText();
+    for (TextFrameIndex n = TextFrameIndex(0),
+                     nEnd = TextFrameIndex(rText.getLength()); n < nEnd; ++n)
+        if (!IsSpace(rText[sal_Int32(n)]))
         {
-            CharClass& rCC = GetCharClass( rNd.GetSwAttrSet().
+            auto const pair = rFrame.MapViewToModel(n);
+            CharClass& rCC = GetCharClass( pair.first->GetSwAttrSet().
                                         GetLanguage().GetLanguage() );
-            sal_Int32 nCharType = rCC.getCharacterType( rText, n );
+            sal_Int32 nCharType = rCC.getCharacterType(rText, sal_Int32(n));
             return CharClass::isLetterType( nCharType ) &&
                    0 != ( i18n::KCharacterType::UPPER &
                                                     nCharType );
@@ -713,12 +736,14 @@ bool SwAutoFormat::IsFirstCharCapital( const SwTextNode& rNd ) const
     return false;
 }
 
-sal_uInt16 SwAutoFormat::GetDigitLevel( const SwTextNode& rNd, sal_Int32& rPos,
+sal_uInt16
+SwAutoFormat::GetDigitLevel(const SwTextFrame& rFrame, TextFrameIndex& rPos,
         OUString* pPrefix, OUString* pPostfix, OUString* pNumTypes ) const
 {
+
     // check for 1.) / 1. / 1.1.1 / (1). / (1) / ....
-    const OUString& rText = rNd.GetText();
-    sal_Int32 nPos = rPos;
+    const OUString& rText = rFrame.GetText();
+    sal_Int32 nPos(rPos);
     int eScan = NONE;
 
     sal_uInt16 nStart = 0;
@@ -727,10 +752,10 @@ sal_uInt16 SwAutoFormat::GetDigitLevel( const SwTextNode& rNd, sal_Int32& rPos,
     sal_uInt16 nOpeningParentheses = 0;
     sal_uInt16 nClosingParentheses = 0;
 
-    CharClass& rCC = GetCharClass( rNd.GetSwAttrSet().GetLanguage().GetLanguage() );
-
     while (nPos < rText.getLength() && nDigitLvl < MAXLEVEL - 1)
     {
+        auto const pair = rFrame.MapViewToModel(TextFrameIndex(nPos));
+        CharClass& rCC = GetCharClass(pair.first->GetSwAttrSet().GetLanguage().GetLanguage());
         const sal_Unicode cCurrentChar = rText[nPos];
         if( ('0' <= cCurrentChar &&  '9' >= cCurrentChar) ||
             (0xff10 <= cCurrentChar &&  0xff19 >= cCurrentChar) )
@@ -949,7 +974,7 @@ CHECK_ROMAN_5:
             break;
         ++nPos;
     }
-    if( !( CHG & eScan ) || rPos == nPos ||
+    if (!( CHG & eScan ) || rPos == TextFrameIndex(nPos) ||
         nPos == rText.getLength() || !IsSpace(rText[nPos]) ||
         (nOpeningParentheses > nClosingParentheses))
         return USHRT_MAX;
@@ -957,15 +982,15 @@ CHECK_ROMAN_5:
     if( (NO_DELIM & eScan) && pPrefix )     // do not forget the last one
         *pPrefix += "\x01" + OUString::number( nStart );
 
-    rPos = nPos;
+    rPos = TextFrameIndex(nPos);
     return nDigitLvl;       // 0 .. 9 (MAXLEVEL - 1)
 }
 
 void SwAutoFormat::SetColl( sal_uInt16 nId, bool bHdLineOrText )
 {
     m_aDelPam.DeleteMark();
-    m_aDelPam.GetPoint()->nNode = m_aNdIdx;
-    m_aDelPam.GetPoint()->nContent.Assign( m_pCurTextNd, 0 );
+    m_aDelPam.GetPoint()->nNode = *m_pCurTextFrame->GetTextNodeForParaProps();
+    m_aDelPam.GetPoint()->nContent.Assign(m_aDelPam.GetPoint()->nNode.GetNode().GetContentNode(), 0);
 
     // keep hard tabs, alignment, language, hyphenation, DropCaps and nearly all frame attributes
     SfxItemSet aSet(
@@ -976,9 +1001,9 @@ void SwAutoFormat::SetColl( sal_uInt16 nId, bool bHdLineOrText )
             RES_PARATR_TABSTOP, RES_PARATR_DROP,
             RES_BACKGROUND, RES_SHADOW>{});
 
-    if( m_pCurTextNd->HasSwAttrSet() )
+    if (m_aDelPam.GetPoint()->nNode.GetNode().GetTextNode()->HasSwAttrSet())
     {
-        aSet.Put( *m_pCurTextNd->GetpSwAttrSet() );
+        aSet.Put(*m_aDelPam.GetPoint()->nNode.GetNode().GetTextNode()->GetpSwAttrSet());
         // take HeaderLine/TextBody only if centered or right aligned, otherwise only justification
         SvxAdjustItem const * pAdj;
         if( SfxItemState::SET == aSet.GetItemState( RES_PARATR_ADJUST,
@@ -995,33 +1020,29 @@ void SwAutoFormat::SetColl( sal_uInt16 nId, bool bHdLineOrText )
     m_pDoc->SetTextFormatCollByAutoFormat( *m_aDelPam.GetPoint(), nId, &aSet );
 }
 
-bool SwAutoFormat::HasSelBlanks( SwPaM& rPam )
+static bool HasSelBlanks(
+        SwTextFrame const*const pStartFrame, TextFrameIndex & rStartIndex,
+        SwTextFrame const*const pEndFrame, TextFrameIndex & rEndIndex)
 {
-    // Is there a Blank at the beginning or end?
-    // Do not delete it, it will be inserted again.
-    SwPosition * pPos = rPam.End();
-    sal_Int32 nBlnkPos = pPos->nContent.GetIndex();
-    SwTextNode* pTextNd = pPos->nNode.GetNode().GetTextNode();
-    if (nBlnkPos && nBlnkPos-- < pTextNd->GetText().getLength() &&
-        (' ' == pTextNd->GetText()[nBlnkPos]))
-        --pPos->nContent;
-    else
+    if (TextFrameIndex(0) < rEndIndex
+        && rEndIndex < TextFrameIndex(pEndFrame->GetText().getLength())
+        && ' ' == pEndFrame->GetText()[sal_Int32(rEndIndex) - 1])
     {
-        pPos = rPam.GetPoint() == pPos ? rPam.GetMark() : rPam.GetPoint();
-        nBlnkPos = pPos->nContent.GetIndex();
-        pTextNd = pPos->nNode.GetNode().GetTextNode();
-        if (nBlnkPos < pTextNd->GetText().getLength() &&
-            (' ' == pTextNd->GetText()[nBlnkPos]))
-            ++pPos->nContent;
-        else
-            return false;
+        --rEndIndex;
+        return true;
+    }
+    if (rStartIndex < TextFrameIndex(pStartFrame->GetText().getLength())
+        && ' ' == pStartFrame->GetText()[sal_Int32(rStartIndex)])
+    {
+        ++rStartIndex;
+        return true;
     }
-    return true;
+    return false;
 }
 
-bool SwAutoFormat::HasBreakAttr( const SwTextNode& rTextNd )
+bool SwAutoFormat::HasBreakAttr(const SwTextFrame& rTextFrame)
 {
-    const SfxItemSet* pSet = rTextNd.GetpSwAttrSet();
+    const SfxItemSet *const pSet = rTextFrame.GetTextNodeFirst()->GetpSwAttrSet();
     if( !pSet )
         return false;
 
@@ -1038,9 +1059,9 @@ bool SwAutoFormat::HasBreakAttr( const SwTextNode& rTextNd )
 }
 
 /// Is there a dot at the end?
-bool SwAutoFormat::IsSentenceAtEnd( const SwTextNode& rTextNd )
+bool SwAutoFormat::IsSentenceAtEnd(const SwTextFrame & rTextFrame)
 {
-    const OUString& rStr = rTextNd.GetText();
+    const OUString& rStr = rTextFrame.GetText();
     sal_Int32 n = rStr.getLength();
     if( !n )
         return true;
@@ -1059,23 +1080,22 @@ void SwAutoFormat::DeleteLeadingTrailingBlanks(bool bStart, bool bEnd)
     {
         // delete blanks at the end of the current and at the beginning of the next one
         m_aDelPam.DeleteMark();
-        m_aDelPam.GetPoint()->nNode = m_aNdIdx;
-        sal_Int32 nPos(0);
-        if( bStart && 0 != ( nPos = GetLeadingBlanks( m_pCurTextNd->GetText() )))
+        TextFrameIndex nPos(GetLeadingBlanks(m_pCurTextFrame->GetText()));
+        if (bStart && TextFrameIndex(0) != nPos)
         {
-            m_aDelPam.GetPoint()->nContent.Assign( m_pCurTextNd, 0 );
+            *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(TextFrameIndex(0));
             m_aDelPam.SetMark();
-            m_aDelPam.GetPoint()->nContent = nPos;
+            *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(nPos);
             DeleteSel( m_aDelPam );
             m_aDelPam.DeleteMark();
         }
-        if (bEnd && m_pCurTextNd->GetText().getLength() !=
-                    ( nPos = GetTrailingBlanks( m_pCurTextNd->GetText() )) )
+        nPos = TextFrameIndex(GetTrailingBlanks(m_pCurTextFrame->GetText()));
+        if (bEnd && TextFrameIndex(m_pCurTextFrame->GetText().getLength()) != nPos)
         {
-            m_aDelPam.GetPoint()->nContent.Assign(
-                    m_pCurTextNd, m_pCurTextNd->GetText().getLength());
+            *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(
+                    TextFrameIndex(m_pCurTextFrame->GetText().getLength()));
             m_aDelPam.SetMark();
-            m_aDelPam.GetPoint()->nContent = nPos;
+            *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(nPos);
             DeleteSel( m_aDelPam );
             m_aDelPam.DeleteMark();
         }
@@ -1154,39 +1174,43 @@ void SwAutoFormat::DeleteSelImpl(SwPaM & rDelPam, SwPaM & rPamToCorrect)
 
         m_aNdIdx = aTmp.GetPoint()->nNode;
         m_pCurTextNd = m_aNdIdx.GetNode().GetTextNode();
+        m_pCurTextFrame = GetFrame(*m_pCurTextNd); // keep it up to date
     }
     else
         m_pEditShell->DeleteSel( rDelPam );
 }
 
-bool SwAutoFormat::DeleteJoinCurNextPara( const OUString& rNxtPara )
+bool SwAutoFormat::DeleteJoinCurNextPara(SwTextFrame const*const pNextFrame,
+        bool const bIgnoreLeadingBlanks)
 {
     // delete blanks at the end of the current and at the beginning of the next one
     m_aDelPam.DeleteMark();
-    m_aDelPam.GetPoint()->nNode = m_aNdIdx;
-    m_aDelPam.GetPoint()->nContent.Assign( m_pCurTextNd,
-                    GetTrailingBlanks( m_pCurTextNd->GetText() ) );
-    m_aDelPam.SetMark();
+    TextFrameIndex nTrailingPos(GetTrailingBlanks(m_pCurTextFrame->GetText()));
 
-    ++m_aDelPam.GetPoint()->nNode;
-    SwTextNode* pTNd = m_aDelPam.GetNode().GetTextNode();
-    if( !pTNd )
+    SwTextFrame const*const pEndFrame(pNextFrame ? pNextFrame : m_pCurTextFrame);
+    TextFrameIndex nLeadingPos(0);
+    if (pNextFrame)
     {
-        // then delete only up to end of the paragraph
-        --m_aDelPam.GetPoint()->nNode;
-        m_aDelPam.GetPoint()->nContent = m_pCurTextNd->GetText().getLength();
+        nLeadingPos = TextFrameIndex(
+            bIgnoreLeadingBlanks ? 0 : GetLeadingBlanks(pNextFrame->GetText()));
     }
     else
-        m_aDelPam.GetPoint()->nContent.Assign( pTNd,
-                            GetLeadingBlanks( rNxtPara ));
+    {
+        nLeadingPos = TextFrameIndex(m_pCurTextFrame->GetText().getLength());
+    }
 
     // Is there a Blank at the beginning or end?
     // Do not delete it, it will be inserted again.
-    bool bHasBlnks = HasSelBlanks( m_aDelPam );
+    bool bHasBlnks = HasSelBlanks(m_pCurTextFrame, nTrailingPos, pEndFrame, nLeadingPos);
+
+    *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(nTrailingPos);
+    m_aDelPam.SetMark();
+    *m_aDelPam.GetPoint() = pEndFrame->MapViewToModelPos(nLeadingPos);
 
     if( *m_aDelPam.GetPoint() != *m_aDelPam.GetMark() )
         DeleteSel( m_aDelPam );
     m_aDelPam.DeleteMark();
+    // note: keep m_aDelPam point at insert pos. for clients
 
     return !bHasBlnks;
 }
@@ -1196,31 +1220,32 @@ void SwAutoFormat::DelEmptyLine( bool bTstNextPara )
     SetRedlineText( STR_AUTOFMTREDL_DEL_EMPTY_PARA );
     // delete blanks in empty paragraph
     m_aDelPam.DeleteMark();
-    m_aDelPam.GetPoint()->nNode = m_aNdIdx;
-    m_aDelPam.GetPoint()->nContent.Assign(
-            m_pCurTextNd, m_pCurTextNd->GetText().getLength() );
+    *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(
+            TextFrameIndex(m_pCurTextFrame->GetText().getLength()));
     m_aDelPam.SetMark();
 
-    --m_aDelPam.GetMark()->nNode;
+    m_aDelPam.GetMark()->nNode = m_pCurTextFrame->GetTextNodeFirst()->GetIndex() - 1;
     SwTextNode* pTNd = m_aDelPam.GetNode( false ).GetTextNode();
     if( pTNd )
         // first use the previous text node
         m_aDelPam.GetMark()->nContent.Assign(pTNd, pTNd->GetText().getLength());
     else if( bTstNextPara )
     {
-        // then try the next (at the beginning of a Doc, table cells, borders, ...)
-        m_aDelPam.GetMark()->nNode += 2;
+        // then try the next (at the beginning of a Doc, table cells, frames, ...)
+        m_aDelPam.GetMark()->nNode = (m_pCurTextFrame->GetMergedPara()
+                    ? m_pCurTextFrame->GetMergedPara()->pLastNode
+                    : m_pCurTextNd
+                )->GetIndex() + 1;
         pTNd = m_aDelPam.GetNode( false ).GetTextNode();
         if( pTNd )
         {
             m_aDelPam.GetMark()->nContent.Assign( pTNd, 0 );
-            m_aDelPam.GetPoint()->nContent = 0;
+            *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(TextFrameIndex(0));
         }
     }
     else
     {
-        m_aDelPam.GetMark()->nNode = m_aNdIdx;
-        m_aDelPam.GetMark()->nContent = 0;
+        *m_aDelPam.GetMark() = m_pCurTextFrame->MapViewToModelPos(TextFrameIndex(0));
         pTNd = m_pCurTextNd;
     }
     if( pTNd )
@@ -1238,38 +1263,38 @@ void SwAutoFormat::DelMoreLinesBlanks( bool bWithLineBreaks )
     {
         // delete all blanks on the left and right of the indentation
         m_aDelPam.DeleteMark();
-        m_aDelPam.GetPoint()->nNode = m_aNdIdx;
-        m_aDelPam.GetPoint()->nContent.Assign( m_pCurTextNd, 0 );
 
         SwTextFrameInfo aFInfo( m_pCurTextFrame );
-        aFInfo.GetSpaces( m_aDelPam, !m_aFlags.bAFormatByInput || bWithLineBreaks );
+        std::vector<std::pair<TextFrameIndex, TextFrameIndex>> spaces;
+        aFInfo.GetSpaces(spaces, !m_aFlags.bAFormatByInput || bWithLineBreaks);
 
-        do {
-            SwPaM* pNxt = m_aDelPam.GetNext();
-            if( pNxt->HasMark() && *pNxt->GetPoint() != *pNxt->GetMark() )
+        for (auto & rSpaceRange : spaces)
+        {
+            assert(rSpaceRange.first != rSpaceRange.second);
+            bool const bHasBlanks = HasSelBlanks(
+                    m_pCurTextFrame, rSpaceRange.first,
+                    m_pCurTextFrame, rSpaceRange.second);
+            if (rSpaceRange.first != rSpaceRange.second)
             {
-                bool bHasBlnks = HasSelBlanks( *pNxt );
-                DeleteSel( *pNxt );
-                if( !bHasBlnks )
+                *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(rSpaceRange.first);
+                m_aDelPam.SetMark();
+                *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(rSpaceRange.second);
+                DeleteSel(m_aDelPam);
+                if (!bHasBlanks)
                 {
-                    m_pDoc->getIDocumentContentOperations().InsertString( *pNxt, OUString(' ') );
+                    m_pDoc->getIDocumentContentOperations().InsertString(m_aDelPam, OUString(' '));
                 }
+                m_aDelPam.DeleteMark();
             }
-
-            if( pNxt == &m_aDelPam )
-                break;
-            delete pNxt;
-        } while( true );
-
-        m_aDelPam.DeleteMark();
+        }
     }
 }
 
 void SwAutoFormat::JoinPrevPara()
 {
     m_aDelPam.DeleteMark();
-    m_aDelPam.GetPoint()->nNode = m_aNdIdx;
-    m_aDelPam.GetPoint()->nContent.Assign( m_pCurTextNd, 0 );
+    m_aDelPam.GetPoint()->nNode = *m_pCurTextFrame->GetTextNodeFirst();
+    m_aDelPam.GetPoint()->nContent.Assign(m_pCurTextFrame->GetTextNodeFirst(), 0);
     m_aDelPam.SetMark();
 
     --m_aDelPam.GetPoint()->nNode;
@@ -1292,29 +1317,30 @@ void SwAutoFormat::BuildIndent()
     if( m_bMoreLines )
         DelMoreLinesBlanks( true );
     else
-        bBreak = !IsFastFullLine( *m_pCurTextNd ) ||
-                IsBlanksInString( *m_pCurTextNd ) ||
-                IsSentenceAtEnd( *m_pCurTextNd );
+        bBreak = !IsFastFullLine(*m_pCurTextFrame)
+                || IsBlanksInString(*m_pCurTextFrame)
+                || IsSentenceAtEnd(*m_pCurTextFrame);
     SetColl( RES_POOLCOLL_TEXT_IDENT );
     if( !bBreak )
     {
         SetRedlineText( STR_AUTOFMTREDL_DEL_MORELINES );
-        const SwTextNode* pNxtNd = GetNextNode();
-        if( pNxtNd && !m_bEnd )
+        const SwTextFrame * pNextFrame = GetNextNode();
+        if (pNextFrame && !m_bEnd)
         {
             do {
-                bBreak = !IsFastFullLine( *pNxtNd ) ||
-                        IsBlanksInString( *pNxtNd ) ||
-                        IsSentenceAtEnd( *pNxtNd );
-                if (DeleteJoinCurNextPara(pNxtNd->GetText()))
+                bBreak = !IsFastFullLine(*pNextFrame)
+                    || IsBlanksInString(*pNextFrame)
+                    || IsSentenceAtEnd(*pNextFrame);
+                if (DeleteJoinCurNextPara(pNextFrame))
                 {
                     m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') );
                 }
                 if( bBreak )
                     break;
-                pNxtNd = GetNextNode();
-            } while( CanJoin( pNxtNd ) &&
-                    !CalcLevel( *pNxtNd ) );
+                pNextFrame = GetNextNode();
+            }
+            while (CanJoin(pNextFrame)
+                && !CalcLevel(*pNextFrame));
         }
     }
     DeleteLeadingTrailingBlanks();
@@ -1329,33 +1355,34 @@ sal_uInt16 SwAutoFormat::BuildTextIndent()
     if( m_bMoreLines )
         DelMoreLinesBlanks( true );
     else
-        bBreak = !IsFastFullLine( *m_pCurTextNd ) ||
-                    IsBlanksInString( *m_pCurTextNd ) ||
-                    IsSentenceAtEnd( *m_pCurTextNd );
+        bBreak = !IsFastFullLine(*m_pCurTextFrame)
+               || IsBlanksInString(*m_pCurTextFrame)
+               || IsSentenceAtEnd(*m_pCurTextFrame);
 
     sal_uInt16 nRet(0);
     if( m_aFlags.bAFormatByInput )
     {
-        nRet = CalcLevel( *m_pCurTextNd );
+        nRet = CalcLevel(*m_pCurTextFrame);
     }
 
     SetColl( RES_POOLCOLL_TEXT_MOVE );
     if( !bBreak )
     {
         SetRedlineText( STR_AUTOFMTREDL_DEL_MORELINES );
-        const SwTextNode* pNxtNd = GetNextNode();
-        while(  CanJoin( pNxtNd ) &&
-                CalcLevel( *pNxtNd ) )
+        const SwTextFrame * pNextFrame = GetNextNode();
+        while (CanJoin(pNextFrame) &&
+               CalcLevel(*pNextFrame))
         {
-            bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) ||
-                    IsSentenceAtEnd( *pNxtNd );
-            if (DeleteJoinCurNextPara(pNxtNd->GetText()))
+            bBreak = !IsFastFullLine(*pNextFrame)
+                    || IsBlanksInString(*pNextFrame)
+                    || IsSentenceAtEnd(*pNextFrame);
+            if (DeleteJoinCurNextPara(pNextFrame))
             {
                 m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') );
             }
             if( bBreak )
                 break;
-            pNxtNd = GetNextNode();
+            pNextFrame = GetNextNode();
         }
     }
     DeleteLeadingTrailingBlanks();
@@ -1371,28 +1398,29 @@ void SwAutoFormat::BuildText()
     if( m_bMoreLines )
         DelMoreLinesBlanks();
     else
-        bBreak = !IsFastFullLine( *m_pCurTextNd ) ||
-                    IsBlanksInString( *m_pCurTextNd ) ||
-                    IsSentenceAtEnd( *m_pCurTextNd );
+        bBreak = !IsFastFullLine(*m_pCurTextFrame)
+                || IsBlanksInString(*m_pCurTextFrame)
+                || IsSentenceAtEnd(*m_pCurTextFrame);
     SetColl( RES_POOLCOLL_TEXT, true );
     if( !bBreak )
     {
         SetRedlineText( STR_AUTOFMTREDL_DEL_MORELINES );
-        const SwTextNode* pNxtNd = GetNextNode();
-        while(  CanJoin( pNxtNd ) &&
-                !CalcLevel( *pNxtNd ) )
+        const SwTextFrame * pNextFrame = GetNextNode();
+        while (CanJoin(pNextFrame) &&
+               !CalcLevel(*pNextFrame))
         {
-            bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) ||
-                    IsSentenceAtEnd( *pNxtNd );
-            if (DeleteJoinCurNextPara(pNxtNd->GetText()))
+            bBreak = !IsFastFullLine(*pNextFrame)
+                    || IsBlanksInString(*pNextFrame)
+                    || IsSentenceAtEnd(*pNextFrame);
+            if (DeleteJoinCurNextPara(pNextFrame))
             {
                 m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') );
             }
             if( bBreak )
                 break;
-            const SwTextNode* pCurrNode = pNxtNd;
-            pNxtNd = GetNextNode();
-            if(!pNxtNd || pCurrNode == pNxtNd)
+            const SwTextFrame *const pCurrNode = pNextFrame;
+            pNextFrame = GetNextNode();
+            if (!pNextFrame || pCurrNode == pNextFrame)
                 break;
         }
     }
@@ -1410,24 +1438,24 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel )
     SwTwips nFrameWidth = m_pCurTextFrame->getFramePrintArea().Width();
     SwTwips nLeftTextPos;
     {
-        sal_Int32 nPos(0);
-        while (nPos < m_pCurTextNd->GetText().getLength() &&
-               IsSpace(m_pCurTextNd->GetText()[nPos]))
+        TextFrameIndex nPos(0);
+        while (nPos < TextFrameIndex(m_pCurTextFrame->GetText().getLength())
+               && IsSpace(m_pCurTextFrame->GetText()[sal_Int32(nPos)]))
         {
             ++nPos;
         }
 
         SwTextFrameInfo aInfo( m_pCurTextFrame );
         nLeftTextPos = aInfo.GetCharPos(nPos);
-        nLeftTextPos -= m_pCurTextNd->GetSwAttrSet().GetLRSpace().GetLeft();
+        nLeftTextPos -= m_pCurTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().GetLRSpace().GetLeft();
     }
 
     if( m_bMoreLines )
         DelMoreLinesBlanks();
     else
-        bBreak = !IsFastFullLine( *m_pCurTextNd ) ||
-                    IsBlanksInString( *m_pCurTextNd ) ||
-                    IsSentenceAtEnd( *m_pCurTextNd );
+        bBreak = !IsFastFullLine(*m_pCurTextFrame)
+                || IsBlanksInString(*m_pCurTextFrame)
+                || IsSentenceAtEnd(*m_pCurTextFrame);
     bool bRTL = m_pEditShell->IsInRightToLeftText();
     DeleteLeadingTrailingBlanks();
 
@@ -1440,16 +1468,22 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel )
                      numfunc::GetDefaultPositionAndSpaceMode() );
 
     const SwNumRule* pCur = nullptr;
-    if( m_aFlags.bSetNumRule && nullptr != (pCur = m_pCurTextNd->GetNumRule()) )
-        aRule = *pCur;
+    if (m_aFlags.bSetNumRule)
+    {
+        pCur = m_pCurTextFrame->GetTextNodeForParaProps()->GetNumRule();
+        if (pCur)
+        {
+            aRule = *pCur;
+        }
+    }
 
     // replace bullet character with defined one
-    const OUString& rStr = m_pCurTextNd->GetText();
-    sal_Int32 nTextStt = 0;
+    const OUString& rStr = m_pCurTextFrame->GetText();
+    TextFrameIndex nTextStt(0);
     const sal_Unicode* pFndBulletChr = nullptr;
     if (m_aFlags.bChgEnumNum && 2 < rStr.getLength())
-        pFndBulletChr = StrChr(pBulletChar, rStr[nTextStt]);
-    if (nullptr != pFndBulletChr && IsSpace(rStr[nTextStt + 1]))
+        pFndBulletChr = StrChr(pBulletChar, rStr[sal_Int32(nTextStt)]);
+    if (nullptr != pFndBulletChr && IsSpace(rStr[sal_Int32(nTextStt) + 1]))
     {
         if( m_aFlags.bAFormatByInput )
         {
@@ -1526,8 +1560,9 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel )
         //             it is determined by the indentation level.
 
         OUString aPostfix, aPrefix, aNumTypes;
-        if( USHRT_MAX != ( nDigitLevel = GetDigitLevel( *m_pCurTextNd, nTextStt,
-                                        &aPrefix, &aPostfix, &aNumTypes )) )
+        nDigitLevel = GetDigitLevel(*m_pCurTextFrame, nTextStt,
+                                            &aPrefix, &aPostfix, &aNumTypes);
+        if (USHRT_MAX != nDigitLevel)
         {
             bChgEnum = true;
 
@@ -1618,37 +1653,41 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel )
     if ( bChgEnum || bChgBullet )
     {
         m_aDelPam.DeleteMark();
-        m_aDelPam.GetPoint()->nNode = m_aNdIdx;
+        m_aDelPam.GetPoint()->nNode = *m_pCurTextFrame->GetTextNodeForParaProps();
 
         if( m_aFlags.bSetNumRule )
         {
             if( m_aFlags.bAFormatByInput )
             {
                 m_aDelPam.SetMark();
-                ++m_aDelPam.GetMark()->nNode;
+                SwTextFrame const*const pNextFrame = GetNextNode(false);
+                assert(pNextFrame);
+                m_aDelPam.GetMark()->nNode = *pNextFrame->GetTextNodeForParaProps();
                 m_aDelPam.GetNode(false).GetTextNode()->SetAttrListLevel( nLvl );
             }
 
-            m_pCurTextNd->SetAttrListLevel(nLvl);
+            const_cast<SwTextNode*>(m_pCurTextFrame->GetTextNodeForParaProps())->SetAttrListLevel(nLvl);
 
             // start new list
-            m_pDoc->SetNumRule( m_aDelPam, aRule, true );
+            m_pDoc->SetNumRule(m_aDelPam, aRule, true, m_pEditShell->GetLayout());
             m_aDelPam.DeleteMark();
 
-            m_aDelPam.GetPoint()->nContent.Assign( m_pCurTextNd, 0 );
+            *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(TextFrameIndex(0));
         }
         else
-            m_aDelPam.GetPoint()->nContent.Assign( m_pCurTextNd,
-                        bChgEnum ? nTextStt : 0 );
+        {
+            *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(
+                        bChgEnum ? nTextStt : TextFrameIndex(0));
+        }
         m_aDelPam.SetMark();
 
         if ( bChgBullet )
-            nTextStt += 2;
+            nTextStt += TextFrameIndex(2);
 
-        while( nTextStt < rStr.getLength() && IsSpace( rStr[ nTextStt ] ))
+        while (nTextStt < TextFrameIndex(rStr.getLength()) && IsSpace(rStr[sal_Int32(nTextStt)]))
             nTextStt++;
 
-        m_aDelPam.GetPoint()->nContent = nTextStt;
+        *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(nTextStt);
         DeleteSel( m_aDelPam );
 
         if( !m_aFlags.bSetNumRule )
@@ -1659,11 +1698,12 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel )
             m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, sChgStr );
 
             SfxItemSet aSet( m_pDoc->GetAttrPool(), aTextNodeSetRange );
+            *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(TextFrameIndex(0));
+            assert(&m_aDelPam.GetPoint()->nNode.GetNode() == m_pCurTextFrame->GetTextNodeForParaProps());
             if( bChgBullet )
             {
-                m_aDelPam.GetPoint()->nContent = 0;
                 m_aDelPam.SetMark();
-                m_aDelPam.GetMark()->nContent = 1;
+                *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(TextFrameIndex(1));
                 SetAllScriptItem( aSet,
                      SvxFontItem( m_aFlags.aBulletFont.GetFamilyType(),
                                   m_aFlags.aBulletFont.GetFamilyName(),
@@ -1679,6 +1719,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel )
             SvxTabStopItem aTStops( RES_PARATR_TABSTOP );
             aTStops.Insert( SvxTabStop( 0 ) );
             aSet.Put( aTStops );
+            assert(&m_aDelPam.GetPoint()->nNode.GetNode() == m_pCurTextFrame->GetTextNodeForParaProps());
             m_pDoc->SetFormatItemByAutoFormat( m_aDelPam, aSet );
         }
     }
@@ -1689,22 +1730,23 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel )
         return;
     }
 
-    const SwTextNode* pNxtNd = GetNextNode();
-    while( CanJoin( pNxtNd ) &&
-            nLvl == CalcLevel( *pNxtNd ) )
+    const SwTextFrame * pNextFrame = GetNextNode();
+    while (CanJoin(pNextFrame)
+            && nLvl == CalcLevel(*pNextFrame))
     {
         SetRedlineText( STR_AUTOFMTREDL_DEL_MORELINES );
-        bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) ||
-                IsSentenceAtEnd( *pNxtNd );
-        if (DeleteJoinCurNextPara(pNxtNd->GetText()))
+        bBreak = !IsFastFullLine(*pNextFrame)
+                || IsBlanksInString(*pNextFrame)
+                || IsSentenceAtEnd(*pNextFrame);
+        if (DeleteJoinCurNextPara(pNextFrame))
         {
             m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') );
         }
         if( bBreak )
             break;
-        const SwTextNode* pCurrNode = pNxtNd;
-        pNxtNd = GetNextNode();
-        if(!pNxtNd || pCurrNode == pNxtNd)
+        const SwTextFrame *const pCurrNode = pNextFrame;
+        pNextFrame = GetNextNode();
+        if (!pNextFrame || pCurrNode == pNextFrame)
             break;
     }
     DeleteLeadingTrailingBlanks( false );
@@ -1718,14 +1760,14 @@ void SwAutoFormat::BuildNegIndent( SwTwips nSpaces )
 
     // read all succeeding paragraphs that belong to this enumeration
     bool bBreak = true;
-    sal_Int32 nSpacePos = 0;
+    TextFrameIndex nSpacePos(0);
     const sal_Int32 nTextPos = GetBigIndent( nSpacePos );
     if( m_bMoreLines )
         DelMoreLinesBlanks( true );
     else
-        bBreak = !IsFastFullLine( *m_pCurTextNd ) ||
-                    ( !nTextPos && IsBlanksInString( *m_pCurTextNd )) ||
-                    IsSentenceAtEnd( *m_pCurTextNd );
+        bBreak = !IsFastFullLine(*m_pCurTextFrame)
+            || (!nTextPos && IsBlanksInString(*m_pCurTextFrame))
+            || IsSentenceAtEnd(*m_pCurTextFrame);
 
     SetColl( static_cast<sal_uInt16>( nTextPos
                 ? RES_POOLCOLL_CONFRONTATION
@@ -1733,35 +1775,34 @@ void SwAutoFormat::BuildNegIndent( SwTwips nSpaces )
 
     if( nTextPos )
     {
-        const OUString& rStr = m_pCurTextNd->GetText();
+        const OUString& rStr = m_pCurTextFrame->GetText();
         bool bInsTab = true;
 
-        if ('\t' == rStr[nSpacePos+1]) // leave tab alone
+        if ('\t' == rStr[sal_Int32(nSpacePos) + 1]) // leave tab alone
         {
             --nSpacePos;
             bInsTab = false;
         }
 
-        sal_Int32 nSpaceStt = nSpacePos;
-        while (nSpaceStt && IsSpace(rStr[--nSpaceStt]))
+        TextFrameIndex nSpaceStt = nSpacePos;
+        while (nSpaceStt && IsSpace(rStr[sal_Int32(--nSpaceStt)]))
             ;
         ++nSpaceStt;
 
-        if (bInsTab && '\t' == rStr[nSpaceStt]) // leave tab alone
+        if (bInsTab && '\t' == rStr[sal_Int32(nSpaceStt)]) // leave tab alone
         {
             ++nSpaceStt;
             bInsTab = false;
         }
 
         m_aDelPam.DeleteMark();
-        m_aDelPam.GetPoint()->nNode = m_aNdIdx;
-        m_aDelPam.GetPoint()->nContent.Assign( m_pCurTextNd, nSpacePos );
+        *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(nSpacePos);
 
         // delete old Spaces, etc.
         if( nSpaceStt < nSpacePos )
         {
             m_aDelPam.SetMark();
-            m_aDelPam.GetMark()->nContent = nSpaceStt;
+            *m_aDelPam.GetMark() = m_pCurTextFrame->MapViewToModelPos(nSpaceStt);
             DeleteSel( m_aDelPam );
             if( bInsTab )
             {
@@ -1774,22 +1815,22 @@ void SwAutoFormat::BuildNegIndent( SwTwips nSpaces )
     {
         SetRedlineText( STR_AUTOFMTREDL_DEL_MORELINES );
         SwTextFrameInfo aFInfo( m_pCurTextFrame );
-        const SwTextNode* pNxtNd = GetNextNode();
-        while(  CanJoin( pNxtNd ) &&
+        const SwTextFrame * pNextFrame = GetNextNode();
+        while (CanJoin(pNextFrame) &&
                 20 < std::abs( static_cast<long>(nSpaces - aFInfo.SetFrame(
-                                GetFrame( *pNxtNd ) ).GetLineStart() ))
+                                EnsureFormatted(*pNextFrame)).GetLineStart()) )
             )
         {
-            bBreak = !IsFastFullLine( *pNxtNd ) ||
-                    IsBlanksInString( *pNxtNd ) ||
-                    IsSentenceAtEnd( *pNxtNd );
-            if (DeleteJoinCurNextPara(pNxtNd->GetText()))
+            bBreak = !IsFastFullLine(*pNextFrame)
+                   || IsBlanksInString(*pNextFrame)
+                   || IsSentenceAtEnd(*pNextFrame);
+            if (DeleteJoinCurNextPara(pNextFrame))
             {
                 m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') );
             }
             if( bBreak )
                 break;
-            pNxtNd = GetNextNode();
+            pNextFrame = GetNextNode();
         }
     }
     DeleteLeadingTrailingBlanks();
@@ -1809,15 +1850,16 @@ void SwAutoFormat::BuildHeadLine( sal_uInt16 nLvl )
     SetColl( static_cast<sal_uInt16>(RES_POOLCOLL_HEADLINE1 + nLvl ), true );
     if( m_aFlags.bAFormatByInput )
     {
-        SwTextFormatColl& rNxtColl = m_pCurTextNd->GetTextColl()->GetNextTextFormatColl();
+        SwTextFormatColl& rNxtColl = m_pCurTextFrame->GetTextNodeForParaProps()->GetTextColl()->GetNextTextFormatColl();
 
         JoinPrevPara();
 
         DeleteLeadingTrailingBlanks( true, false );
-        (void)DeleteJoinCurNextPara( OUString() );
+        const SwTextFrame *const pNextFrame = GetNextNode(false);
+        (void)DeleteJoinCurNextPara(pNextFrame, true);
 
         m_aDelPam.DeleteMark();
-        m_aDelPam.GetPoint()->nNode = m_aNdIdx.GetIndex() + 1;
+        m_aDelPam.GetPoint()->nNode = *pNextFrame->GetTextNodeForParaProps();
         m_aDelPam.GetPoint()->nContent.Assign( m_aDelPam.GetContentNode(), 0 );
         m_pDoc->SetTextFormatColl( m_aDelPam, &rNxtColl );
     }
@@ -2140,7 +2182,7 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags const &
 
     bool bReplaceStyles = !m_aFlags.bAFormatByInput || m_aFlags.bReplaceStyles;
 
-    const SwTextNode* pNxtNd = nullptr;
+    const SwTextFrame * pNextFrame = nullptr;
     bool bNxtEmpty = false;
     bool bNxtAlpha = false;
     sal_uInt16 nNxtLevel = 0;
@@ -2150,15 +2192,18 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags const &
     if( pSttNd )
     {
         m_aNdIdx = *pSttNd;
-        --m_aNdIdx;           // for GoNextPara, one paragraph prior to that
+        // for GoNextPara, one paragraph prior to that
+        sw::GotoPrevLayoutTextFrame(m_aNdIdx, m_pEditShell->GetLayout());
         m_aEndNdIdx = *pEndNd;
-        ++m_aEndNdIdx;
+        sw::GotoNextLayoutTextFrame(m_aEndNdIdx, m_pEditShell->GetLayout());
 
         // check the previous TextNode
-        pNxtNd = m_aNdIdx.GetNode().GetTextNode();
-        bEmptyLine = !pNxtNd ||
-                    IsEmptyLine( *pNxtNd ) ||
-                    IsNoAlphaLine( *pNxtNd );
+        SwTextFrame const*const pPrevFrame = m_aNdIdx.GetNode().GetTextNode()
+            ? static_cast<SwTextFrame const*>(m_aNdIdx.GetNode().GetTextNode()->getLayoutFrame(m_pEditShell->GetLayout()))
+            : nullptr;
+        bEmptyLine = !pPrevFrame
+                    || IsEmptyLine(*pPrevFrame)
+                    || IsNoAlphaLine(*pPrevFrame);
     }
     else
         bEmptyLine = true;      // at document beginning
@@ -2226,16 +2271,19 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags const &
             break;
 
         case TST_EMPTY_LINE:
-            if( IsEmptyLine( *m_pCurTextNd ) )
+            if (IsEmptyLine(*m_pCurTextFrame))
             {
-                if( m_aFlags.bDelEmptyNode && !HasObjects( *m_pCurTextNd ) )
+                if (m_aFlags.bDelEmptyNode && !HasObjects(*m_pCurTextFrame))
                 {
                     bEmptyLine = true;
                     sal_uLong nOldCnt = m_pDoc->GetNodes().Count();
                     DelEmptyLine();
                     // Was there really a deletion of a node?
                     if( nOldCnt != m_pDoc->GetNodes().Count() )
-                        --m_aNdIdx;       // do not skip the next paragraph
+                    {
+                        // do not skip the next paragraph
+                        sw::GotoPrevLayoutTextFrame(m_aNdIdx, m_pEditShell->GetLayout());
+                    }
                 }
                 eStat = READ_NEXT_PARA;
             }
@@ -2244,7 +2292,7 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags const &
             break;
 
         case TST_ALPHA_LINE:
-            if( IsNoAlphaLine( *m_pCurTextNd ))
+            if (IsNoAlphaLine(*m_pCurTextFrame))
             {
                 // recognize a table definition +---+---+
                 if( m_aFlags.bAFormatByInput && m_aFlags.bCreateTable && DoTable() )
@@ -2273,7 +2321,7 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags const &
 
         case GET_ALL_INFO:
             {
-                if( m_pCurTextNd->GetNumRule() )
+                if (m_pCurTextFrame->GetTextNodeForParaProps()->GetNumRule())
                 {
                     // do nothing in numbering, go to next
                     bEmptyLine = false;
@@ -2287,7 +2335,7 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags const &
                 aFInfo.SetFrame( m_pCurTextFrame );
 
                 // so far: if there were templates assigned, keep these and go to next node
-                sal_uInt16 nPoolId = m_pCurTextNd->GetTextColl()->GetPoolFormatId();
+                sal_uInt16 nPoolId = m_pCurTextFrame->GetTextNodeForParaProps()->GetTextColl()->GetPoolFormatId();
                 if( IsPoolUserFormat( nPoolId )
                         ? !m_aFlags.bChgUserColl
                         : ( RES_POOLCOLL_STANDARD != nPoolId &&
@@ -2307,16 +2355,16 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags const &
                 {
                     short nSz;
                     SvxLRSpaceItem const * pLRSpace;
-                    if( SfxItemState::SET == m_pCurTextNd->GetSwAttrSet().
+                    if (SfxItemState::SET == m_pCurTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().
                         GetItemState( RES_LR_SPACE, true,
                                         reinterpret_cast<const SfxPoolItem**>(&pLRSpace) ) &&
                         ( 0 != (nSz = pLRSpace->GetTextFirstLineOfst()) ||
                             0 != pLRSpace->GetTextLeft() ) )
                     {
                         // exception: numbering/enumeration can have an indentation
-                        if( IsEnumericChar( *m_pCurTextNd ))
+                        if (IsEnumericChar(*m_pCurTextFrame))
                         {
-                            nLevel = CalcLevel( *m_pCurTextNd, &nDigitLvl );
+                            nLevel = CalcLevel(*m_pCurTextFrame, &nDigitLvl);
                             if( nLevel >= MAXLEVEL )
                                 nLevel = MAXLEVEL-1;
                             BuildEnum( nLevel, nDigitLvl );
@@ -2349,19 +2397,21 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags const &
                 }
                 else
                 {
-                    nLevel = CalcLevel( *m_pCurTextNd, &nDigitLvl );
+                    nLevel = CalcLevel(*m_pCurTextFrame, &nDigitLvl);
                 }
-                m_bMoreLines = !IsOneLine( *m_pCurTextNd );
-                pNxtNd = GetNextNode();
-                if( pNxtNd )
+                m_bMoreLines = !IsOneLine(*m_pCurTextFrame);
+                // note: every use of pNextFrame in following states, until the
+                // next READ_NEXT_PARA, relies on this update
+                pNextFrame = GetNextNode();
+                if (pNextFrame)
                 {
-                    bNxtEmpty = IsEmptyLine( *pNxtNd );
-                    bNxtAlpha = IsNoAlphaLine( *pNxtNd );
-                    nNxtLevel = CalcLevel( *pNxtNd );
+                    bNxtEmpty = IsEmptyLine(*pNextFrame);
+                    bNxtAlpha = IsNoAlphaLine(*pNextFrame);
+                    nNxtLevel = CalcLevel(*pNextFrame);
 
-                    if( !bEmptyLine && HasBreakAttr( *m_pCurTextNd ) )
+                    if (!bEmptyLine && HasBreakAttr(*m_pCurTextFrame))
                         bEmptyLine = true;
-                    if( !bNxtEmpty && HasBreakAttr( *pNxtNd ) )
+                    if (!bNxtEmpty && HasBreakAttr(*pNextFrame))
                         bNxtEmpty = true;
 
                 }
@@ -2381,7 +2431,7 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags const &
                 if( !bReplaceStyles )
                     break;
 
-                const OUString sClrStr( DelLeadingBlanks(m_pCurTextNd->GetText()) );
+                const OUString sClrStr( DelLeadingBlanks(m_pCurTextFrame->GetText()) );
 
                 if( sClrStr.isEmpty() )
                 {
@@ -2391,8 +2441,8 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags const &
                 }
 
                 // check if headline
-                if( !bEmptyLine || !IsFirstCharCapital( *m_pCurTextNd ) ||
-                    IsBlanksInString( *m_pCurTextNd ) )
+                if (!bEmptyLine || !IsFirstCharCapital(*m_pCurTextFrame)
+                    || IsBlanksInString(*m_pCurTextFrame))
                     break;
 
                 bEmptyLine = false;
@@ -2409,9 +2459,7 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags const &
                 else if( 256 <= cLast || !strchr( ",.;", cLast ) )
                 {
                     if( bNxtEmpty || bNxtAlpha
-                        || ( pNxtNd && IsEnumericChar( *pNxtNd ))
-
-                        )
+                        || (pNextFrame && IsEnumericChar(*pNextFrame)))
                     {
 
                         // one level below?
@@ -2447,7 +2495,7 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags const &
         case TST_ENUMERIC:
             {
                 bEmptyLine = false;
-                if( IsEnumericChar( *m_pCurTextNd ))
+                if (IsEnumericChar(*m_pCurTextFrame))
                 {
                     if( nLevel >= MAXLEVEL )
                         nLevel = MAXLEVEL-1;
@@ -2474,9 +2522,9 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags const &
                     BuildTextIndent();
                 eStat = READ_NEXT_PARA;
             }
-            else if( nLevel && pNxtNd &&
+            else if (nLevel && pNextFrame &&
                      !bNxtEmpty && !bNxtAlpha && !nNxtLevel &&
-                     !IsEnumericChar( *pNxtNd ) )
+                     !IsEnumericChar(*pNextFrame))
             {
                 // is an indentation
                 BuildIndent();
@@ -2500,9 +2548,9 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags const &
                         BuildText();
                     eStat = READ_NEXT_PARA;
                 }
-                else if( !nLevel && pNxtNd &&
+                else if (!nLevel && pNextFrame &&
                          !bNxtEmpty && !bNxtAlpha && nNxtLevel &&
-                         !IsEnumericChar( *pNxtNd ) )
+                         !IsEnumericChar(*pNextFrame))
                 {
                     // is a negative indentation
                     BuildNegIndent( aFInfo.GetLineStart() );
@@ -2545,12 +2593,12 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags const &
                 DelMoreLinesBlanks();
 
                 // handle hard attributes
-                if( m_pCurTextNd->HasSwAttrSet() )
+                if (m_pCurTextFrame->GetTextNodeForParaProps()->HasSwAttrSet())
                 {
                     short nSz;
                     SvxLRSpaceItem const * pLRSpace;
                     if( bReplaceStyles &&
-                        SfxItemState::SET == m_pCurTextNd->GetSwAttrSet().
+                        SfxItemState::SET == m_pCurTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().
                         GetItemState( RES_LR_SPACE, false,
                                         reinterpret_cast<const SfxPoolItem**>(&pLRSpace) ) &&
                         ( 0 != (nSz = pLRSpace->GetTextFirstLineOfst()) ||
@@ -2649,7 +2697,8 @@ void SwEditShell::AutoFormatBySplitNode()
     else
     {
         // then go one node backwards
-        SwNodeIndex aNdIdx( pCursor->GetMark()->nNode, -1 );
+        SwNodeIndex aNdIdx(pCursor->GetMark()->nNode);
+        sw::GotoPrevLayoutTextFrame(aNdIdx, GetLayout());
         SwTextNode* pTextNd = aNdIdx.GetNode().GetTextNode();
         if (pTextNd && !pTextNd->GetText().isEmpty())
         {
diff --git a/sw/source/core/inc/frminf.hxx b/sw/source/core/inc/frminf.hxx
index 844e5bb4be87..e582745f154d 100644
--- a/sw/source/core/inc/frminf.hxx
+++ b/sw/source/core/inc/frminf.hxx
@@ -21,8 +21,11 @@
 #define INCLUDED_SW_SOURCE_CORE_INC_FRMINF_HXX
 
 #include <swtypes.hxx>
+
 #include "TextFrameIndex.hxx"
 
+#include <vector>
+
 class SwTextFrame;
 class SwPaM;
 class SwTextCursor;
@@ -50,7 +53,8 @@ public:
     SwTwips GetCharPos(TextFrameIndex nChar, bool bCenter = true) const;
 
     // collect all whitespaces at the beginning and end of a line in Pam
-    void GetSpaces( SwPaM &rPam, bool bWithLineBreak ) const;
+    void GetSpaces(std::vector<std::pair<TextFrameIndex, TextFrameIndex>> &,
+            bool bWithLineBreak) const;
 
     // Is a bullet point/symbol/etc. at the first text position?
     bool IsBullet(TextFrameIndex nTextPos) const;
diff --git a/sw/source/core/text/frminf.cxx b/sw/source/core/text/frminf.cxx
index 303ca595487d..7ee4fb43b8c2 100644
--- a/sw/source/core/text/frminf.cxx
+++ b/sw/source/core/text/frminf.cxx
@@ -131,39 +131,31 @@ SwTwips SwTextFrameInfo::GetCharPos(TextFrameIndex const nChar, bool bCenter) co
     return (( nNext + nStt ) / 2 ) - aRectFnSet.GetLeft(pFrame->getFrameArea());
 }
 
-static SwPaM *AddPam( SwPaM *pPam, const SwTextFrame* pTextFrame,
+void
+AddRange(std::vector<std::pair<TextFrameIndex, TextFrameIndex>> & rRanges,
             TextFrameIndex const nPos, TextFrameIndex const nLen)
 {
+    assert(rRanges.empty() || rRanges.back().second <= nPos);
     if( nLen )
     {
-        SwPosition const start(pTextFrame->MapViewToModelPos(nPos));
-        SwPosition const end(pTextFrame->MapViewToModelPos(nPos + nLen));
-        // It could be the first
-        if( pPam->HasMark() )
+        if (!rRanges.empty() && nPos == rRanges.back().second)
         {
-            // If the new position is right after the current one, then
-            // simply extend the Pam
-            if (start == *pPam->GetPoint())
-            {
-                *pPam->GetPoint() = end;
-                return pPam;
-            }
-            pPam = new SwPaM(*pPam, pPam);
+            rRanges.back().second += nLen;
+        }
+        else
+        {
+            rRanges.emplace_back(nPos, nPos + nLen);
         }
-
-        *pPam->GetPoint() = start;
-        pPam->SetMark();
-        *pPam->GetPoint() = end;
     }
-    return pPam;
 }
 
-// Accumulates the whitespace at line start and end in the Pam
-void SwTextFrameInfo::GetSpaces( SwPaM &rPam, bool bWithLineBreak ) const
+// Accumulates the whitespace at line start and end in the vector
+void SwTextFrameInfo::GetSpaces(
+    std::vector<std::pair<TextFrameIndex, TextFrameIndex>> & rRanges,
+    bool const bWithLineBreak) const
 {
     SwTextSizeInfo aInf( const_cast<SwTextFrame*>(pFrame) );
     SwTextMargin aLine( const_cast<SwTextFrame*>(pFrame), &aInf );
-    SwPaM *pPam = &rPam;
     bool bFirstLine = true;
     do {
 
@@ -173,8 +165,7 @@ void SwTextFrameInfo::GetSpaces( SwPaM &rPam, bool bWithLineBreak ) const
             // Do NOT include the blanks/tabs from the first line
             // in the selection
             if( !bFirstLine && nPos > aLine.GetStart() )
-                pPam = AddPam( pPam, pFrame, aLine.GetStart(),
-                                nPos - aLine.GetStart() );
+                AddRange( rRanges, aLine.GetStart(), nPos - aLine.GetStart() );
 
             // Do NOT include the blanks/tabs from the last line
             // in the selection
@@ -187,7 +178,7 @@ void SwTextFrameInfo::GetSpaces( SwPaM &rPam, bool bWithLineBreak ) const
                     TextFrameIndex const nOff( !bWithLineBreak && CH_BREAK ==
                         aLine.GetInfo().GetChar(aLine.GetEnd() - TextFrameIndex(1))
                                 ? 1 : 0 );
-                    pPam = AddPam( pPam, pFrame, nPos, aLine.GetEnd() - nPos - nOff );
+                    AddRange( rRanges, nPos, aLine.GetEnd() - nPos - nOff );
                 }
             }
         }
commit 2f9461d01e97cf5fac3db879d95dad32c61a5bd1
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Fri Nov 23 18:02:49 2018 +0100
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Tue Nov 27 18:54:10 2018 +0100

    sw_redlinehide_4a: SwAutoFormat: manually skip redlines when deleting
    
    Change-Id: I001e61305ee8416f851f834d3068bd91de8281f8

diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index 59ccb687e5d9..8a5f87eaf00e 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -38,6 +38,8 @@
 #include <IDocumentUndoRedo.hxx>
 #include <DocumentRedlineManager.hxx>
 #include <IDocumentStylePoolAccess.hxx>
+#include <redline.hxx>
+#include <unocrsr.hxx>
 #include <docary.hxx>
 #include <editsh.hxx>
 #include <index.hxx>
@@ -172,6 +174,7 @@ class SwAutoFormat
     static bool HasSelBlanks( SwPaM& rPam );
     static bool HasBreakAttr( const SwTextNode& );
     void DeleteSel( SwPaM& rPam );
+    void DeleteSelImpl(SwPaM & rDelPam, SwPaM & rPamToCorrect);
     bool DeleteJoinCurNextPara( const OUString& rNxtPara );
     /// delete in the node start and/or end
     void DeleteLeadingTrailingBlanks( bool bStart = true, bool bEnd = true );
@@ -1079,7 +1082,55 @@ void SwAutoFormat::DeleteLeadingTrailingBlanks(bool bStart, bool bEnd)
     }
 }
 
-void SwAutoFormat::DeleteSel( SwPaM& rDelPam )
+bool GetRanges(std::vector<std::shared_ptr<SwUnoCursor>> & rRanges,
+        SwDoc & rDoc, SwPaM const& rDelPam)
+{
+    bool isNoRedline(true);
+    SwRedlineTable::size_type tmp;
+    IDocumentRedlineAccess const& rIDRA(rDoc.getIDocumentRedlineAccess());
+    rIDRA.GetRedline(*rDelPam.Start(), &tmp);
+    SwPosition const* pCurrent(rDelPam.Start());
+    for ( ; tmp < rIDRA.GetRedlineTable().size(); ++tmp)
+    {
+        SwRangeRedline const*const pRedline(rIDRA.GetRedlineTable()[tmp]);
+        if (rDelPam.End() <= pRedline->Start())
+        {
+            break;
+        }
+        if (pRedline->GetType() == nsRedlineType_t::REDLINE_DELETE)
+        {
+            assert(*pRedline->Start() != *pRedline->End());
+            isNoRedline = false;
+            if (*pCurrent < *pRedline->Start())
+            {
+                rRanges.push_back(rDoc.CreateUnoCursor(*pCurrent, pRedline->Start()));
+            }
+            else
+            {
+                pCurrent = pRedline->End();
+            }
+        }
+    }
+    return isNoRedline;
+}
+
+void SwAutoFormat::DeleteSel(SwPaM & rDelPam)
+{
+    std::vector<std::shared_ptr<SwUnoCursor>> ranges; // need correcting cursor
+    if (GetRanges(ranges, *m_pDoc, rDelPam))
+    {
+        DeleteSelImpl(rDelPam, rDelPam);
+    }
+    else
+    {
+        for (auto const& pCursor : ranges)
+        {
+            DeleteSelImpl(*pCursor, rDelPam);
+        }
+    }
+}
+
+void SwAutoFormat::DeleteSelImpl(SwPaM & rDelPam, SwPaM & rPamToCorrect)
 {
     if( m_aFlags.bWithRedlining )
     {
@@ -1087,18 +1138,18 @@ void SwAutoFormat::DeleteSel( SwPaM& rDelPam )
         SwPaM* pShCursor = m_pEditShell->GetCursor_();
         SwPaM aTmp( *m_pCurTextNd, 0, pShCursor );
 
-        SwPaM* pPrev = rDelPam.GetPrev();
-        rDelPam.GetRingContainer().merge( pShCursor->GetRingContainer() );
+        SwPaM* pPrev = rPamToCorrect.GetPrev();
+        rPamToCorrect.GetRingContainer().merge( pShCursor->GetRingContainer() );
 
         m_pEditShell->DeleteSel( rDelPam );
 
         // and remove Pam again:
         SwPaM* p;
-        SwPaM* pNext = &rDelPam;
+        SwPaM* pNext = &rPamToCorrect;
         do {
             p = pNext;
             pNext = p->GetNext();
-            p->MoveTo( &rDelPam );
+            p->MoveTo( &rPamToCorrect );
         } while( p != pPrev );
 
         m_aNdIdx = aTmp.GetPoint()->nNode;
commit 6b35f7511153c96939e62e96403b3ec22898a0b0
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Fri Nov 23 14:14:17 2018 +0100
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Tue Nov 27 18:54:10 2018 +0100

    sw: fix wrong title of AutoFormat with redlining dialog
    
    (regression from 9fcef57a34dbd88a98621dfaf8668fa076dd98f1)
    
    Change-Id: Id6ea5841dd25a30519deb825c3ae0aaa7469c250

diff --git a/sw/uiconfig/swriter/ui/queryredlinedialog.ui b/sw/uiconfig/swriter/ui/queryredlinedialog.ui
index 946547f6fb43..490d09a7ebbc 100644
--- a/sw/uiconfig/swriter/ui/queryredlinedialog.ui
+++ b/sw/uiconfig/swriter/ui/queryredlinedialog.ui
@@ -4,7 +4,7 @@
   <requires lib="gtk+" version="3.18"/>
   <object class="GtkMessageDialog" id="QueryRedlineDialog">
     <property name="can_focus">False</property>
-    <property name="title" translatable="yes" context="queryredlinedialog|QueryRedlineDialog">Delete this theme?</property>
+    <property name="title" translatable="yes" context="queryredlinedialog|QueryRedlineDialog">AutoCorrect</property>
     <property name="resizable">False</property>
     <property name="modal">True</property>
     <property name="type_hint">dialog</property>
commit 25f6f9c9e2ffeb407460b14beb96f524e3694c9d
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Thu Nov 22 18:58:16 2018 +0100
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Tue Nov 27 18:54:10 2018 +0100

    sw: remove newly unused SwNode::m_nAFormatNumLvl
    
    Change-Id: I2a26d53ca5b8da3a413088e8b9319b9b04632df2

diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx
index 8f817d0b12bd..3c0842780c0f 100644
--- a/sw/inc/node.hxx
+++ b/sw/inc/node.hxx
@@ -83,8 +83,6 @@ class SW_DLLPUBLIC SwNode
 
     SwNodeType const m_nNodeType;
 
-    /// For text nodes: level of auto format. Was put here because we had still free bits.
-    sal_uInt8 m_nAFormatNumLvl : 3;
     bool m_bIgnoreDontExpand : 1;     ///< for Text Attributes - ignore the flag
 
 public:
@@ -135,9 +133,6 @@ public:
     inline const SwEndNode* EndOfSectionNode() const;
     inline         SwEndNode* EndOfSectionNode();
 
-    sal_uInt8 GetAutoFormatLvl() const     { return m_nAFormatNumLvl; }
-    void SetAutoFormatLvl( sal_uInt8 nVal )      { m_nAFormatNumLvl = nVal; }
-
     bool IsIgnoreDontExpand() const  { return m_bIgnoreDontExpand; }
     void SetIgnoreDontExpand( bool bNew )  { m_bIgnoreDontExpand = bNew; }
 
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index 19cafd55a313..7104499d97ce 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -284,7 +284,6 @@ long SwNode::s_nSerial = 0;
 
 SwNode::SwNode( const SwNodeIndex &rWhere, const SwNodeType nNdType )
     : m_nNodeType( nNdType )
-    , m_nAFormatNumLvl( 0 )
     , m_bIgnoreDontExpand( false)
     , m_eMerge(Merge::None)
 #ifdef DBG_UTIL
@@ -317,7 +316,6 @@ SwNode::SwNode( const SwNodeIndex &rWhere, const SwNodeType nNdType )
  */
 SwNode::SwNode( SwNodes& rNodes, sal_uLong nPos, const SwNodeType nNdType )
     : m_nNodeType( nNdType )
-    , m_nAFormatNumLvl( 0 )
     , m_bIgnoreDontExpand( false)
     , m_eMerge(Merge::None)
 #ifdef DBG_UTIL
commit 3e7221f22aab029f83c33d0801368e3c5c27464f
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Thu Nov 22 18:42:03 2018 +0100
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Tue Nov 27 18:54:10 2018 +0100

    sw: remove SetAutoFormatLvl calls in SwAutoFormat
    
    BuildTextIndent() calls SetAutoFormatLvl() if bAFormatByInput,
    while also setting the node's style to RES_POOLCOLL_TEXT_MOVE.
    
    Then CalcLevel short-cuts if the node has the style
    RES_POOLCOLL_TEXT_MOVE and bAFormatByInput is set, and it also
    resets via SetAutoFormatLvl(0).
    
    So BuildTextIndent() affects the next caller of CalcLevel() on that
    node, but not the 2nd or later callers.
    
    Of the callers of BuildTextIndent(), one of them will actually call
    CalcLevel() immediately, while the others all set the state to
    READ_NEXT_PARA; since the iteration is always forward, CalcLevel() will
    not be called on that node while the SwAutoFormat instance is alive.
    
    It doesn't make sense to affect the next SwAutoFormat invocation but not
    the one after that?  So just replace this with a return value from
    BuildTextIndent() that is checked in the one immediate use location.
    
    Change-Id: I548358c508ac65cc07d13da6708e285c910e1663

diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index 482375d372c5..59ccb687e5d9 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -164,7 +164,7 @@ class SwAutoFormat
 
     void BuildIndent();
     void BuildText();
-    void BuildTextIndent();
+    sal_uInt16 BuildTextIndent();
     void BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel );
     void BuildNegIndent( SwTwips nSpaces );
     void BuildHeadLine( sal_uInt16 nLvl );
@@ -428,13 +428,6 @@ sal_uInt16 SwAutoFormat::CalcLevel( const SwTextNode& rNd, sal_uInt16 *pDigitLvl
 
     if( RES_POOLCOLL_TEXT_MOVE == rNd.GetTextColl()->GetPoolFormatId() )
     {
-        if( m_aFlags.bAFormatByInput )
-        {
-            nLvl = rNd.GetAutoFormatLvl();
-            const_cast<SwTextNode&>(rNd).SetAutoFormatLvl( 0 );
-            if( nLvl )
-                return nLvl;
-        }
         ++nLvl;
     }
 
@@ -1277,7 +1270,7 @@ void SwAutoFormat::BuildIndent()
     AutoCorrect();
 }
 
-void SwAutoFormat::BuildTextIndent()
+sal_uInt16 SwAutoFormat::BuildTextIndent()
 {
     SetRedlineText( STR_AUTOFMTREDL_SET_TMPL_TEXT_INDENT);
     // read all succeeding paragraphs that belong to this indentation
@@ -1289,8 +1282,11 @@ void SwAutoFormat::BuildTextIndent()
                     IsBlanksInString( *m_pCurTextNd ) ||
                     IsSentenceAtEnd( *m_pCurTextNd );
 
+    sal_uInt16 nRet(0);
     if( m_aFlags.bAFormatByInput )
-        m_pCurTextNd->SetAutoFormatLvl( static_cast<sal_uInt8>(CalcLevel( *m_pCurTextNd )) );
+    {
+        nRet = CalcLevel( *m_pCurTextNd );
+    }
 
     SetColl( RES_POOLCOLL_TEXT_MOVE );
     if( !bBreak )
@@ -1313,6 +1309,7 @@ void SwAutoFormat::BuildTextIndent()
     }
     DeleteLeadingTrailingBlanks();
     AutoCorrect();
+    return nRet;
 }
 
 void SwAutoFormat::BuildText()
@@ -2251,6 +2248,8 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags const &
                     break;
                 }
 
+                sal_uInt16 nBuildTextIndentLevel(0);
+
                 // check for hard spaces or LRSpaces set by the template
                 if( IsPoolUserFormat( nPoolId ) ||
                     RES_POOLCOLL_STANDARD == nPoolId )
@@ -2285,14 +2284,22 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags const &
                             else if( 0 > nSz )      // negative 1st line indentation
                                 BuildNegIndent( aFInfo.GetLineStart() );
                             else if( pLRSpace->GetTextLeft() )   // is indentation
-                                BuildTextIndent();
+                                nBuildTextIndentLevel = BuildTextIndent();
                         }
                         eStat = READ_NEXT_PARA;
                         break;
                     }
                 }
 
-                nLevel = CalcLevel( *m_pCurTextNd, &nDigitLvl );
+                if (nBuildTextIndentLevel != 0)
+                {
+                    nLevel = nBuildTextIndentLevel;
+                    nDigitLvl = USHRT_MAX;
+                }
+                else
+                {
+                    nLevel = CalcLevel( *m_pCurTextNd, &nDigitLvl );
+                }
                 m_bMoreLines = !IsOneLine( *m_pCurTextNd );
                 pNxtNd = GetNextNode();
                 if( pNxtNd )
commit 2c6e740d848fa4fbfc5b14a8fe7f9532df90f6f3
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Thu Nov 22 17:47:08 2018 +0100
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Tue Nov 27 18:53:42 2018 +0100

    sw: rename misleading DeleteCurrentParagraph()
    
    Rename also DelPrevPara() and DeleteCurNxtPara().
    
    Also document the state transitions.
    
    Change-Id: I0b874852a4c1aab8d5d3a55b9dfef360e313089c

diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index 37865d7c9a98..482375d372c5 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -172,15 +172,15 @@ class SwAutoFormat
     static bool HasSelBlanks( SwPaM& rPam );
     static bool HasBreakAttr( const SwTextNode& );
     void DeleteSel( SwPaM& rPam );
-    bool DeleteCurNxtPara( const OUString& rNxtPara );
+    bool DeleteJoinCurNextPara( const OUString& rNxtPara );
     /// delete in the node start and/or end
-    void DeleteCurrentParagraph( bool bStart = true, bool bEnd = true );
+    void DeleteLeadingTrailingBlanks( bool bStart = true, bool bEnd = true );
     void DelEmptyLine( bool bTstNextPara = true );
     /// when using multiline paragraphs delete the "left" and/or
     /// "right" margins
     void DelMoreLinesBlanks( bool bWithLineBreaks = false );
-    /// delete the previous paragraph
-    void DelPrevPara();
+    /// join with the previous paragraph
+    void JoinPrevPara();
     /// execute AutoCorrect on current TextNode
     void AutoCorrect( sal_Int32 nSttPos = 0 );
 
@@ -333,7 +333,7 @@ OUString SwAutoFormat::GoNextPara()
 bool SwAutoFormat::HasObjects( const SwNode& rNd )
 {
     // Is there something bound to the paragraph in the paragraph
-    // like borders, DrawObjects, ...
+    // like Frames, DrawObjects, ...
     bool bRet = false;
     const SwFrameFormats& rFormats = *m_pDoc->GetSpzFrameFormats();
     for( auto pFrameFormat : rFormats )
@@ -1055,7 +1055,7 @@ bool SwAutoFormat::IsSentenceAtEnd( const SwTextNode& rTextNd )
 }
 
 /// Delete beginning and/or end in a node
-void SwAutoFormat::DeleteCurrentParagraph( bool bStart, bool bEnd )
+void SwAutoFormat::DeleteLeadingTrailingBlanks(bool bStart, bool bEnd)
 {
     if( m_aFlags.bAFormatByInput
         ? m_aFlags.bAFormatByInpDelSpacesAtSttEnd
@@ -1115,7 +1115,7 @@ void SwAutoFormat::DeleteSel( SwPaM& rDelPam )
         m_pEditShell->DeleteSel( rDelPam );
 }
 
-bool SwAutoFormat::DeleteCurNxtPara( const OUString& rNxtPara )
+bool SwAutoFormat::DeleteJoinCurNextPara( const OUString& rNxtPara )
 {
     // delete blanks at the end of the current and at the beginning of the next one
     m_aDelPam.DeleteMark();
@@ -1221,8 +1221,7 @@ void SwAutoFormat::DelMoreLinesBlanks( bool bWithLineBreaks )
     }
 }
 
-// delete the previous paragraph
-void SwAutoFormat::DelPrevPara()
+void SwAutoFormat::JoinPrevPara()
 {
     m_aDelPam.DeleteMark();
     m_aDelPam.GetPoint()->nNode = m_aNdIdx;
@@ -1263,7 +1262,7 @@ void SwAutoFormat::BuildIndent()
                 bBreak = !IsFastFullLine( *pNxtNd ) ||
                         IsBlanksInString( *pNxtNd ) ||
                         IsSentenceAtEnd( *pNxtNd );
-                if( DeleteCurNxtPara( pNxtNd->GetText() ))
+                if (DeleteJoinCurNextPara(pNxtNd->GetText()))
                 {
                     m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') );
                 }
@@ -1274,7 +1273,7 @@ void SwAutoFormat::BuildIndent()
                     !CalcLevel( *pNxtNd ) );
         }
     }
-    DeleteCurrentParagraph();
+    DeleteLeadingTrailingBlanks();
     AutoCorrect();
 }
 
@@ -1303,7 +1302,7 @@ void SwAutoFormat::BuildTextIndent()
         {
             bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) ||
                     IsSentenceAtEnd( *pNxtNd );
-            if( DeleteCurNxtPara( pNxtNd->GetText() ) )
+            if (DeleteJoinCurNextPara(pNxtNd->GetText()))
             {
                 m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') );
             }
@@ -1312,7 +1311,7 @@ void SwAutoFormat::BuildTextIndent()
             pNxtNd = GetNextNode();
         }
     }
-    DeleteCurrentParagraph();
+    DeleteLeadingTrailingBlanks();
     AutoCorrect();
 }
 
@@ -1337,7 +1336,7 @@ void SwAutoFormat::BuildText()
         {
             bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) ||
                     IsSentenceAtEnd( *pNxtNd );
-            if( DeleteCurNxtPara( pNxtNd->GetText() ) )
+            if (DeleteJoinCurNextPara(pNxtNd->GetText()))
             {
                 m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') );
             }
@@ -1349,7 +1348,7 @@ void SwAutoFormat::BuildText()
                 break;
         }
     }
-    DeleteCurrentParagraph();
+    DeleteLeadingTrailingBlanks();
     AutoCorrect();
 }
 
@@ -1382,7 +1381,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel )
                     IsBlanksInString( *m_pCurTextNd ) ||
                     IsSentenceAtEnd( *m_pCurTextNd );
     bool bRTL = m_pEditShell->IsInRightToLeftText();
-    DeleteCurrentParagraph();
+    DeleteLeadingTrailingBlanks();
 
     bool bChgBullet = false, bChgEnum = false;
     sal_Int32 nAutoCorrPos = 0;
@@ -1649,7 +1648,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel )
         SetRedlineText( STR_AUTOFMTREDL_DEL_MORELINES );
         bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) ||
                 IsSentenceAtEnd( *pNxtNd );
-        if( DeleteCurNxtPara( pNxtNd->GetText() ) )
+        if (DeleteJoinCurNextPara(pNxtNd->GetText()))
         {
             m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') );
         }
@@ -1660,7 +1659,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel )
         if(!pNxtNd || pCurrNode == pNxtNd)
             break;
     }
-    DeleteCurrentParagraph( false );
+    DeleteLeadingTrailingBlanks( false );
     AutoCorrect( nAutoCorrPos );
 }
 
@@ -1736,7 +1735,7 @@ void SwAutoFormat::BuildNegIndent( SwTwips nSpaces )
             bBreak = !IsFastFullLine( *pNxtNd ) ||
                     IsBlanksInString( *pNxtNd ) ||
                     IsSentenceAtEnd( *pNxtNd );
-            if( DeleteCurNxtPara( pNxtNd->GetText() ) )
+            if (DeleteJoinCurNextPara(pNxtNd->GetText()))
             {
                 m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') );
             }
@@ -1745,7 +1744,7 @@ void SwAutoFormat::BuildNegIndent( SwTwips nSpaces )
             pNxtNd = GetNextNode();
         }
     }
-    DeleteCurrentParagraph();
+    DeleteLeadingTrailingBlanks();
     AutoCorrect();
 }
 
@@ -1764,10 +1763,10 @@ void SwAutoFormat::BuildHeadLine( sal_uInt16 nLvl )
     {
         SwTextFormatColl& rNxtColl = m_pCurTextNd->GetTextColl()->GetNextTextFormatColl();
 
-        DelPrevPara();
+        JoinPrevPara();
 
-        DeleteCurrentParagraph( true, false );
-        (void)DeleteCurNxtPara( OUString() );
+        DeleteLeadingTrailingBlanks( true, false );
+        (void)DeleteJoinCurNextPara( OUString() );
 
         m_aDelPam.DeleteMark();
         m_aDelPam.GetPoint()->nNode = m_aNdIdx.GetIndex() + 1;
@@ -1776,7 +1775,7 @@ void SwAutoFormat::BuildHeadLine( sal_uInt16 nLvl )
     }
     else
     {
-        DeleteCurrentParagraph();
+        DeleteLeadingTrailingBlanks();
         AutoCorrect();
     }
 }
@@ -2152,16 +2151,16 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags const &
 
     enum Format_Status
     {
-        READ_NEXT_PARA,
-        TST_EMPTY_LINE,
-        TST_ALPHA_LINE,
-        GET_ALL_INFO,
-        IS_ONE_LINE,
-        TST_ENUMERIC,
-        TST_IDENT,
-        TST_NEG_IDENT,
-        TST_TXT_BODY,
-        HAS_FMTCOLL,
+        READ_NEXT_PARA, // -> ISEND, TST_EMPTY_LINE
+        TST_EMPTY_LINE, // -> READ_NEXT_PARA, TST_ALPHA_LINE
+        TST_ALPHA_LINE, // -> READ_NEXT_PARA, GET_ALL_INFO, IS_END
+        GET_ALL_INFO,   // -> READ_NEXT_PARA, IS_ONE_LINE, TST_ENUMERIC, HAS_FMTCOLL
+        IS_ONE_LINE,    // -> READ_NEXT_PARA, TST_ENUMERIC
+        TST_ENUMERIC,   // -> READ_NEXT_PARA, TST_IDENT, TST_NEG_IDENT
+        TST_IDENT,      // -> READ_NEXT_PARA, TST_TXT_BODY
+        TST_NEG_IDENT,  // -> READ_NEXT_PARA, TST_TXT_BODY
+        TST_TXT_BODY,   // -> READ_NEXT_PARA
+        HAS_FMTCOLL,    // -> READ_NEXT_PARA
         IS_END
     } eStat;
 


More information about the Libreoffice-commits mailing list