[Libreoffice-commits] core.git: sw/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri Jul 31 11:13:21 UTC 2020


 sw/source/core/txtnode/SwGrammarContact.cxx |   24 -
 sw/source/core/txtnode/atrfld.cxx           |  144 ++++----
 sw/source/core/txtnode/atrftn.cxx           |   62 +--
 sw/source/core/txtnode/fmtatr2.cxx          |   34 +-
 sw/source/core/txtnode/fntcap.cxx           |  102 +++---
 sw/source/core/txtnode/ndtxt.cxx            |  322 +++++++++----------
 sw/source/core/txtnode/thints.cxx           |  274 ++++++++--------
 sw/source/core/txtnode/txatritr.cxx         |   54 +--
 sw/source/core/txtnode/txtedt.cxx           |  456 ++++++++++++++--------------
 9 files changed, 736 insertions(+), 736 deletions(-)

New commits:
commit 443d24a27842f39b5bc833dbc03082fa52749a2d
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Jul 30 10:36:18 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Jul 31 13:12:45 2020 +0200

    loplugin:flatten in sw/core/txtnode
    
    Change-Id: I0003a190cbc42845274d71f8f157977e598a3fd4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99859
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/source/core/txtnode/SwGrammarContact.cxx b/sw/source/core/txtnode/SwGrammarContact.cxx
index d957bfbcc273..fc6883ca92ab 100644
--- a/sw/source/core/txtnode/SwGrammarContact.cxx
+++ b/sw/source/core/txtnode/SwGrammarContact.cxx
@@ -85,21 +85,21 @@ IMPL_LINK( SwGrammarContact, TimerRepaint, Timer *, pTimer, void )
 void SwGrammarContact::updateCursorPosition( const SwPosition& rNewPos )
 {
     SwTextNode* pTextNode = rNewPos.nNode.GetNode().GetTextNode();
-    if( pTextNode != GetRegisteredIn() ) // paragraph has been changed
+    if( pTextNode == GetRegisteredIn() ) // paragraph has been changed
+        return;
+
+    aTimer.Stop();
+    if( GetRegisteredIn() ) // My last paragraph has been left
     {
-        aTimer.Stop();
-        if( GetRegisteredIn() ) // My last paragraph has been left
-        {
-            if( mpProxyList )
-            {   // replace old list by the proxy list and repaint
-                getMyTextNode()->SetGrammarCheck( mpProxyList.release() );
-                SwTextFrame::repaintTextFrames( *getMyTextNode() );
-            }
-            EndListeningAll();
+        if( mpProxyList )
+        {   // replace old list by the proxy list and repaint
+            getMyTextNode()->SetGrammarCheck( mpProxyList.release() );
+            SwTextFrame::repaintTextFrames( *getMyTextNode() );
         }
-        if( pTextNode )
-            pTextNode->Add( this ); // welcome new paragraph
+        EndListeningAll();
     }
+    if( pTextNode )
+        pTextNode->Add( this ); // welcome new paragraph
 }
 
 /* deliver a grammar check list for the given text node */
diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx
index f8e055cf67e0..e13ea716932f 100644
--- a/sw/source/core/txtnode/atrfld.cxx
+++ b/sw/source/core/txtnode/atrfld.cxx
@@ -95,36 +95,36 @@ SwFormatField::SwFormatField( const SwFormatField& rAttr )
     , SfxBroadcaster()
     , mpTextField( nullptr )
 {
-    if ( rAttr.mpField )
+    if ( !rAttr.mpField )
+        return;
+
+    rAttr.mpField->GetTyp()->Add(this);
+    mpField = rAttr.mpField->CopyField();
+    if ( mpField->GetTyp()->Which() == SwFieldIds::Input )
     {
-        rAttr.mpField->GetTyp()->Add(this);
-        mpField = rAttr.mpField->CopyField();
-        if ( mpField->GetTyp()->Which() == SwFieldIds::Input )
+        // input field in-place editing
+        SetWhich( RES_TXTATR_INPUTFIELD );
+        SwInputField *pField = dynamic_cast<SwInputField*>(mpField.get());
+        assert(pField);
+        if (pField)
+            pField->SetFormatField( *this );
+    }
+    else if (mpField->GetTyp()->Which() == SwFieldIds::SetExp)
+    {
+        SwSetExpField *const pSetField(static_cast<SwSetExpField *>(mpField.get()));
+        if (pSetField->GetInputFlag()
+            && (static_cast<SwSetExpFieldType*>(pSetField->GetTyp())->GetType()
+                & nsSwGetSetExpType::GSE_STRING))
         {
-            // input field in-place editing
             SetWhich( RES_TXTATR_INPUTFIELD );
-            SwInputField *pField = dynamic_cast<SwInputField*>(mpField.get());
-            assert(pField);
-            if (pField)
-                pField->SetFormatField( *this );
-        }
-        else if (mpField->GetTyp()->Which() == SwFieldIds::SetExp)
-        {
-            SwSetExpField *const pSetField(static_cast<SwSetExpField *>(mpField.get()));
-            if (pSetField->GetInputFlag()
-                && (static_cast<SwSetExpFieldType*>(pSetField->GetTyp())->GetType()
-                    & nsSwGetSetExpType::GSE_STRING))
-            {
-                SetWhich( RES_TXTATR_INPUTFIELD );
-            }
-            // see SwWrtShell::StartInputFieldDlg
-            pSetField->SetFormatField(*this);
-        }
-        else if ( mpField->GetTyp()->Which() == SwFieldIds::Postit )
-        {
-            // text annotation field
-            SetWhich( RES_TXTATR_ANNOTATION );
         }
+        // see SwWrtShell::StartInputFieldDlg
+        pSetField->SetFormatField(*this);
+    }
+    else if ( mpField->GetTyp()->Which() == SwFieldIds::Postit )
+    {
+        // text annotation field
+        SetWhich( RES_TXTATR_ANNOTATION );
     }
 }
 
@@ -139,31 +139,31 @@ SwFormatField::~SwFormatField()
     mpField.reset();
 
     // some fields need to delete their field type
-    if( pType && pType->HasOnlyOneListener() )
-    {
-        bool bDel = false;
-        switch( pType->Which() )
-        {
-        case SwFieldIds::User:
-            bDel = static_cast<SwUserFieldType*>(pType)->IsDeleted();
-            break;
-
-        case SwFieldIds::SetExp:
-            bDel = static_cast<SwSetExpFieldType*>(pType)->IsDeleted();
-            break;
+    if( !(pType && pType->HasOnlyOneListener()) )
+        return;
 
-        case SwFieldIds::Dde:
-            bDel = static_cast<SwDDEFieldType*>(pType)->IsDeleted();
-            break;
-        default: break;
-        }
+    bool bDel = false;
+    switch( pType->Which() )
+    {
+    case SwFieldIds::User:
+        bDel = static_cast<SwUserFieldType*>(pType)->IsDeleted();
+        break;
+
+    case SwFieldIds::SetExp:
+        bDel = static_cast<SwSetExpFieldType*>(pType)->IsDeleted();
+        break;
+
+    case SwFieldIds::Dde:
+        bDel = static_cast<SwDDEFieldType*>(pType)->IsDeleted();
+        break;
+    default: break;
+    }
 
-        if( bDel )
-        {
-            // unregister before deleting
-            pType->Remove( this );
-            delete pType;
-        }
+    if( bDel )
+    {
+        // unregister before deleting
+        pType->Remove( this );
+        delete pType;
     }
 }
 
@@ -655,33 +655,33 @@ OUString SwTextInputField::GetFieldContent() const
 
 void SwTextInputField::UpdateFieldContent()
 {
-    if ( IsFieldInDoc()
-         && GetStart() != (*End()) )
-    {
-        assert( (*End()) - GetStart() >= 2 &&
-                "<SwTextInputField::UpdateFieldContent()> - Are CH_TXT_ATR_INPUTFIELDSTART and/or CH_TXT_ATR_INPUTFIELDEND missing?" );
-        // skip CH_TXT_ATR_INPUTFIELDSTART character
-        const sal_Int32 nIdx = GetStart() + 1;
-        // skip CH_TXT_ATR_INPUTFIELDEND character
-        const sal_Int32 nLen = static_cast<sal_Int32>(std::max<sal_Int32>( 0, ( (*End()) - 1 - nIdx ) ));
-        const OUString aNewFieldContent = GetTextNode().GetExpandText(nullptr, nIdx, nLen);
+    if ( !(IsFieldInDoc()
+         && GetStart() != (*End())) )
+        return;
 
-        const SwField* pField = GetFormatField().GetField();
-        const SwInputField* pInputField = dynamic_cast<const SwInputField*>(pField);
-        if (pInputField)
-            const_cast<SwInputField*>(pInputField)->applyFieldContent( aNewFieldContent );
+    assert( (*End()) - GetStart() >= 2 &&
+            "<SwTextInputField::UpdateFieldContent()> - Are CH_TXT_ATR_INPUTFIELDSTART and/or CH_TXT_ATR_INPUTFIELDEND missing?" );
+    // skip CH_TXT_ATR_INPUTFIELDSTART character
+    const sal_Int32 nIdx = GetStart() + 1;
+    // skip CH_TXT_ATR_INPUTFIELDEND character
+    const sal_Int32 nLen = static_cast<sal_Int32>(std::max<sal_Int32>( 0, ( (*End()) - 1 - nIdx ) ));
+    const OUString aNewFieldContent = GetTextNode().GetExpandText(nullptr, nIdx, nLen);
 
-        const SwSetExpField* pExpField = dynamic_cast<const SwSetExpField*>(pField);
-        if (pExpField)
-        {
-            assert(pExpField->GetInputFlag());
-            const_cast<SwSetExpField*>(pExpField)->SetPar2(aNewFieldContent);
-        }
-        assert(pInputField || pExpField);
+    const SwField* pField = GetFormatField().GetField();
+    const SwInputField* pInputField = dynamic_cast<const SwInputField*>(pField);
+    if (pInputField)
+        const_cast<SwInputField*>(pInputField)->applyFieldContent( aNewFieldContent );
 
-        // trigger update of fields for scenarios in which the Input Field's content is part of e.g. a table formula
-        GetTextNode().GetDoc()->getIDocumentFieldsAccess().GetUpdateFields().SetFieldsDirty(true);
+    const SwSetExpField* pExpField = dynamic_cast<const SwSetExpField*>(pField);
+    if (pExpField)
+    {
+        assert(pExpField->GetInputFlag());
+        const_cast<SwSetExpField*>(pExpField)->SetPar2(aNewFieldContent);
     }
+    assert(pInputField || pExpField);
+
+    // trigger update of fields for scenarios in which the Input Field's content is part of e.g. a table formula
+    GetTextNode().GetDoc()->getIDocumentFieldsAccess().GetUpdateFields().SetFieldsDirty(true);
 }
 
 void SwTextInputField::UpdateTextNodeContent( const OUString& rNewContent )
diff --git a/sw/source/core/txtnode/atrftn.cxx b/sw/source/core/txtnode/atrftn.cxx
index 4f76f4c0704c..913167342939 100644
--- a/sw/source/core/txtnode/atrftn.cxx
+++ b/sw/source/core/txtnode/atrftn.cxx
@@ -490,42 +490,42 @@ void SwTextFootnote::DelFrames(SwRootFrame const*const pRoot)
     }
     //JP 13.05.97: if the layout is deleted before the footnotes are deleted,
     //             try to delete the footnote's frames by another way
-    if ( !bFrameFnd && m_pStartNode )
-    {
-        SwNodeIndex aIdx( *m_pStartNode );
-        SwContentNode* pCNd = m_pTextNode->GetNodes().GoNext( &aIdx );
-        if( pCNd )
-        {
-            SwIterator<SwContentFrame, SwContentNode, sw::IteratorMode::UnwrapMulti> aIter(*pCNd);
-            for( SwContentFrame* pFnd = aIter.First(); pFnd; pFnd = aIter.Next() )
-            {
-                if( pRoot != pFnd->getRootFrame() && pRoot )
-                    continue;
-                SwPageFrame* pPage = pFnd->FindPageFrame();
+    if ( !(!bFrameFnd && m_pStartNode) )
+        return;
+
+    SwNodeIndex aIdx( *m_pStartNode );
+    SwContentNode* pCNd = m_pTextNode->GetNodes().GoNext( &aIdx );
+    if( !pCNd )
+        return;
 
-                SwFrame *pFrame = pFnd->GetUpper();
-                while ( pFrame && !pFrame->IsFootnoteFrame() )
-                    pFrame = pFrame->GetUpper();
+    SwIterator<SwContentFrame, SwContentNode, sw::IteratorMode::UnwrapMulti> aIter(*pCNd);
+    for( SwContentFrame* pFnd = aIter.First(); pFnd; pFnd = aIter.Next() )
+    {
+        if( pRoot != pFnd->getRootFrame() && pRoot )
+            continue;
+        SwPageFrame* pPage = pFnd->FindPageFrame();
 
-                SwFootnoteFrame *pFootnote = static_cast<SwFootnoteFrame*>(pFrame);
-                while ( pFootnote && pFootnote->GetMaster() )
-                    pFootnote = pFootnote->GetMaster();
-                OSL_ENSURE( pFootnote->GetAttr() == this, "Footnote mismatch error." );
+        SwFrame *pFrame = pFnd->GetUpper();
+        while ( pFrame && !pFrame->IsFootnoteFrame() )
+            pFrame = pFrame->GetUpper();
 
-                while ( pFootnote )
-                {
-                    SwFootnoteFrame *pFoll = pFootnote->GetFollow();
-                    pFootnote->Cut();
-                    SwFrame::DestroyFrame(pFootnote);
-                    pFootnote = pFoll;
-                }
+        SwFootnoteFrame *pFootnote = static_cast<SwFootnoteFrame*>(pFrame);
+        while ( pFootnote && pFootnote->GetMaster() )
+            pFootnote = pFootnote->GetMaster();
+        OSL_ENSURE( pFootnote->GetAttr() == this, "Footnote mismatch error." );
 
-                // #i20556# During hiding of a section, the connection
-                // to the layout is already lost. pPage may be 0:
-                if ( pPage )
-                    pPage->UpdateFootnoteNum();
-            }
+        while ( pFootnote )
+        {
+            SwFootnoteFrame *pFoll = pFootnote->GetFollow();
+            pFootnote->Cut();
+            SwFrame::DestroyFrame(pFootnote);
+            pFootnote = pFoll;
         }
+
+        // #i20556# During hiding of a section, the connection
+        // to the layout is already lost. pPage may be 0:
+        if ( pPage )
+            pPage->UpdateFootnoteNum();
     }
 }
 
diff --git a/sw/source/core/txtnode/fmtatr2.cxx b/sw/source/core/txtnode/fmtatr2.cxx
index e825a99a856c..5911474b5d3d 100644
--- a/sw/source/core/txtnode/fmtatr2.cxx
+++ b/sw/source/core/txtnode/fmtatr2.cxx
@@ -608,25 +608,25 @@ void SwFormatMeta::DoCopy(::sw::MetaFieldManager & i_rTargetDocManager,
         SwTextNode & i_rTargetTextNode)
 {
     OSL_ENSURE(m_pMeta, "DoCopy called for SwFormatMeta with no sw::Meta?");
-    if (m_pMeta)
+    if (!m_pMeta)
+        return;
+
+    const std::shared_ptr< ::sw::Meta> pOriginal( m_pMeta );
+    if (RES_TXTATR_META == Which())
     {
-        const std::shared_ptr< ::sw::Meta> pOriginal( m_pMeta );
-        if (RES_TXTATR_META == Which())
-        {
-            m_pMeta = std::make_shared<::sw::Meta>(this);
-        }
-        else
-        {
-            ::sw::MetaField *const pMetaField(
-                static_cast< ::sw::MetaField* >(pOriginal.get()));
-            m_pMeta = i_rTargetDocManager.makeMetaField( this,
-                pMetaField->m_nNumberFormat, pMetaField->IsFixedLanguage() );
-        }
-        // Meta must have a text node before calling RegisterAsCopyOf
-        m_pMeta->NotifyChangeTextNode(& i_rTargetTextNode);
-        // this cannot be done in Clone: a Clone is not necessarily a copy!
-        m_pMeta->RegisterAsCopyOf(*pOriginal);
+        m_pMeta = std::make_shared<::sw::Meta>(this);
+    }
+    else
+    {
+        ::sw::MetaField *const pMetaField(
+            static_cast< ::sw::MetaField* >(pOriginal.get()));
+        m_pMeta = i_rTargetDocManager.makeMetaField( this,
+            pMetaField->m_nNumberFormat, pMetaField->IsFixedLanguage() );
     }
+    // Meta must have a text node before calling RegisterAsCopyOf
+    m_pMeta->NotifyChangeTextNode(& i_rTargetTextNode);
+    // this cannot be done in Clone: a Clone is not necessarily a copy!
+    m_pMeta->RegisterAsCopyOf(*pOriginal);
 }
 
 namespace sw {
diff --git a/sw/source/core/txtnode/fntcap.cxx b/sw/source/core/txtnode/fntcap.cxx
index 8ab9cf830b98..3a64db9c82e6 100644
--- a/sw/source/core/txtnode/fntcap.cxx
+++ b/sw/source/core/txtnode/fntcap.cxx
@@ -185,35 +185,35 @@ void SwDoGetCapitalBreak::Init( SwFntObj *, SwFntObj * )
 
 void SwDoGetCapitalBreak::Do()
 {
-    if ( nTextWidth )
-    {
-        if ( rInf.GetSize().Width() < nTextWidth )
-            nTextWidth -= rInf.GetSize().Width();
-        else
-        {
-            TextFrameIndex nEnd = rInf.GetEnd();
-            m_nBreak = TextFrameIndex(GetOut().GetTextBreak(
-                           rInf.GetText(), nTextWidth, sal_Int32(rInf.GetIdx()),
-                           sal_Int32(rInf.GetLen()), rInf.GetKern()));
+    if ( !nTextWidth )
+        return;
 
-            if (m_nBreak > nEnd || m_nBreak < TextFrameIndex(0))
-                m_nBreak = nEnd;
+    if ( rInf.GetSize().Width() < nTextWidth )
+        nTextWidth -= rInf.GetSize().Width();
+    else
+    {
+        TextFrameIndex nEnd = rInf.GetEnd();
+        m_nBreak = TextFrameIndex(GetOut().GetTextBreak(
+                       rInf.GetText(), nTextWidth, sal_Int32(rInf.GetIdx()),
+                       sal_Int32(rInf.GetLen()), rInf.GetKern()));
 
-            // m_nBreak may be relative to the display string. It has to be
-            // calculated relative to the original string:
-            if ( GetCapInf()  )
-            {
-                if ( GetCapInf()->nLen != rInf.GetLen() )
-                    m_nBreak = sw_CalcCaseMap( *rInf.GetFont(),
-                                              GetCapInf()->rString,
-                                              GetCapInf()->nIdx,
-                                              GetCapInf()->nLen, m_nBreak );
-                else
-                    m_nBreak = m_nBreak + GetCapInf()->nIdx;
-            }
+        if (m_nBreak > nEnd || m_nBreak < TextFrameIndex(0))
+            m_nBreak = nEnd;
 
-            nTextWidth = 0;
+        // m_nBreak may be relative to the display string. It has to be
+        // calculated relative to the original string:
+        if ( GetCapInf()  )
+        {
+            if ( GetCapInf()->nLen != rInf.GetLen() )
+                m_nBreak = sw_CalcCaseMap( *rInf.GetFont(),
+                                          GetCapInf()->rString,
+                                          GetCapInf()->nIdx,
+                                          GetCapInf()->nLen, m_nBreak );
+            else
+                m_nBreak = m_nBreak + GetCapInf()->nIdx;
         }
+
+        nTextWidth = 0;
     }
 }
 
@@ -356,38 +356,38 @@ void SwDoCapitalCursorOfst::Init( SwFntObj *pUpperFont, SwFntObj *pLowerFont )
 
 void SwDoCapitalCursorOfst::Do()
 {
-    if ( nOfst )
+    if ( !nOfst )
+        return;
+
+    if ( static_cast<long>(nOfst) > rInf.GetSize().Width() )
+    {
+        nOfst -= rInf.GetSize().Width();
+        nCursor = nCursor + rInf.GetLen();
+    }
+    else
     {
-        if ( static_cast<long>(nOfst) > rInf.GetSize().Width() )
+        SwDrawTextInfo aDrawInf( rInf.GetShell(), *rInf.GetpOut(),
+                                 rInf.GetScriptInfo(),
+                                 rInf.GetText(),
+                                 rInf.GetIdx(),
+                                 rInf.GetLen(), 0, false );
+        aDrawInf.SetOffset( nOfst );
+        aDrawInf.SetKern( rInf.GetKern() );
+        aDrawInf.SetKanaComp( rInf.GetKanaComp() );
+        aDrawInf.SetFrame( rInf.GetFrame() );
+        aDrawInf.SetFont( rInf.GetFont() );
+
+        if ( rInf.GetUpper() )
         {
-            nOfst -= rInf.GetSize().Width();
-            nCursor = nCursor + rInf.GetLen();
+            aDrawInf.SetSpace( 0 );
+            nCursor = nCursor + pUpperFnt->GetModelPositionForViewPoint( aDrawInf );
         }
         else
         {
-            SwDrawTextInfo aDrawInf( rInf.GetShell(), *rInf.GetpOut(),
-                                     rInf.GetScriptInfo(),
-                                     rInf.GetText(),
-                                     rInf.GetIdx(),
-                                     rInf.GetLen(), 0, false );
-            aDrawInf.SetOffset( nOfst );
-            aDrawInf.SetKern( rInf.GetKern() );
-            aDrawInf.SetKanaComp( rInf.GetKanaComp() );
-            aDrawInf.SetFrame( rInf.GetFrame() );
-            aDrawInf.SetFont( rInf.GetFont() );
-
-            if ( rInf.GetUpper() )
-            {
-                aDrawInf.SetSpace( 0 );
-                nCursor = nCursor + pUpperFnt->GetModelPositionForViewPoint( aDrawInf );
-            }
-            else
-            {
-                aDrawInf.SetSpace( rInf.GetSpace() );
-                nCursor = nCursor + pLowerFnt->GetModelPositionForViewPoint( aDrawInf );
-            }
-            nOfst = 0;
+            aDrawInf.SetSpace( rInf.GetSpace() );
+            nCursor = nCursor + pLowerFnt->GetModelPositionForViewPoint( aDrawInf );
         }
+        nOfst = 0;
     }
 }
 
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 56fa589eaef5..df046a6f8e6a 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -281,73 +281,73 @@ sal_Int32 SwTextNode::Len() const
 static void lcl_ChangeFootnoteRef( SwTextNode &rNode )
 {
     SwpHints *pSwpHints = rNode.GetpSwpHints();
-    if( pSwpHints && rNode.GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell() )
-    {
-        SwContentFrame* pFrame = nullptr;
-        // OD 07.11.2002 #104840# - local variable to remember first footnote
-        // of node <rNode> in order to invalidate position of its first content.
-        // Thus, in its <MakeAll()> it will checked its position relative to its reference.
-        SwFootnoteFrame* pFirstFootnoteOfNode = nullptr;
-        for( size_t j = pSwpHints->Count(); j; )
-        {
-            SwTextAttr* pHt = pSwpHints->Get(--j);
-            if (RES_TXTATR_FTN == pHt->Which())
-            {
-                if( !pFrame )
-                {
-                    pFrame = SwIterator<SwContentFrame, SwTextNode, sw::IteratorMode::UnwrapMulti>(rNode).First();
-                    if (!pFrame)
-                        return;
-                }
-                SwTextFootnote *pAttr = static_cast<SwTextFootnote*>(pHt);
-                OSL_ENSURE( pAttr->GetStartNode(), "FootnoteAtr without StartNode." );
-                SwNodeIndex aIdx( *pAttr->GetStartNode(), 1 );
-                SwContentNode *pNd = aIdx.GetNode().GetContentNode();
-                if ( !pNd )
-                    pNd = pFrame->GetAttrSet()->GetDoc()->
-                            GetNodes().GoNextSection( &aIdx, true, false );
-                if ( !pNd )
-                    continue;
+    if( !(pSwpHints && rNode.GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell()) )
+        return;
+
+    SwContentFrame* pFrame = nullptr;
+    // OD 07.11.2002 #104840# - local variable to remember first footnote
+    // of node <rNode> in order to invalidate position of its first content.
+    // Thus, in its <MakeAll()> it will checked its position relative to its reference.
+    SwFootnoteFrame* pFirstFootnoteOfNode = nullptr;
+    for( size_t j = pSwpHints->Count(); j; )
+    {
+        SwTextAttr* pHt = pSwpHints->Get(--j);
+        if (RES_TXTATR_FTN == pHt->Which())
+        {
+            if( !pFrame )
+            {
+                pFrame = SwIterator<SwContentFrame, SwTextNode, sw::IteratorMode::UnwrapMulti>(rNode).First();
+                if (!pFrame)
+                    return;
+            }
+            SwTextFootnote *pAttr = static_cast<SwTextFootnote*>(pHt);
+            OSL_ENSURE( pAttr->GetStartNode(), "FootnoteAtr without StartNode." );
+            SwNodeIndex aIdx( *pAttr->GetStartNode(), 1 );
+            SwContentNode *pNd = aIdx.GetNode().GetContentNode();
+            if ( !pNd )
+                pNd = pFrame->GetAttrSet()->GetDoc()->
+                        GetNodes().GoNextSection( &aIdx, true, false );
+            if ( !pNd )
+                continue;
 
-                SwIterator<SwContentFrame, SwContentNode, sw::IteratorMode::UnwrapMulti> aIter(*pNd);
-                SwContentFrame* pContent = aIter.First();
-                if( pContent )
+            SwIterator<SwContentFrame, SwContentNode, sw::IteratorMode::UnwrapMulti> aIter(*pNd);
+            SwContentFrame* pContent = aIter.First();
+            if( pContent )
+            {
+                OSL_ENSURE( pContent->getRootFrame() == pFrame->getRootFrame(),
+                        "lcl_ChangeFootnoteRef: Layout double?" );
+                SwFootnoteFrame *pFootnote = pContent->FindFootnoteFrame();
+                if( pFootnote && pFootnote->GetAttr() == pAttr )
                 {
-                    OSL_ENSURE( pContent->getRootFrame() == pFrame->getRootFrame(),
-                            "lcl_ChangeFootnoteRef: Layout double?" );
-                    SwFootnoteFrame *pFootnote = pContent->FindFootnoteFrame();
-                    if( pFootnote && pFootnote->GetAttr() == pAttr )
+                    while( pFootnote->GetMaster() )
+                        pFootnote = pFootnote->GetMaster();
+                    // #104840# - remember footnote frame
+                    pFirstFootnoteOfNode = pFootnote;
+                    while ( pFootnote )
                     {
-                        while( pFootnote->GetMaster() )
-                            pFootnote = pFootnote->GetMaster();
-                        // #104840# - remember footnote frame
-                        pFirstFootnoteOfNode = pFootnote;
-                        while ( pFootnote )
-                        {
-                            pFootnote->SetRef( pFrame );
-                            pFootnote = pFootnote->GetFollow();
-                            static_cast<SwTextFrame*>(pFrame)->SetFootnote( true );
-                        }
+                        pFootnote->SetRef( pFrame );
+                        pFootnote = pFootnote->GetFollow();
+                        static_cast<SwTextFrame*>(pFrame)->SetFootnote( true );
                     }
+                }
 #if OSL_DEBUG_LEVEL > 0
-                    while( nullptr != (pContent = aIter.Next()) )
-                    {
-                        SwFootnoteFrame *pDbgFootnote = pContent->FindFootnoteFrame();
-                        OSL_ENSURE( !pDbgFootnote || pDbgFootnote->GetRef() == pFrame,
-                                "lcl_ChangeFootnoteRef: Who's that guy?" );
-                    }
-#endif
+                while( nullptr != (pContent = aIter.Next()) )
+                {
+                    SwFootnoteFrame *pDbgFootnote = pContent->FindFootnoteFrame();
+                    OSL_ENSURE( !pDbgFootnote || pDbgFootnote->GetRef() == pFrame,
+                            "lcl_ChangeFootnoteRef: Who's that guy?" );
                 }
+#endif
             }
-        } // end of for-loop on <SwpHints>
-        // #104840# - invalidate
-        if ( pFirstFootnoteOfNode )
+        }
+    } // end of for-loop on <SwpHints>
+    // #104840# - invalidate
+    if ( pFirstFootnoteOfNode )
+    {
+        SwContentFrame* pContent = pFirstFootnoteOfNode->ContainsContent();
+        if ( pContent )
         {
-            SwContentFrame* pContent = pFirstFootnoteOfNode->ContainsContent();
-            if ( pContent )
-            {
-                pContent->InvalidatePos_();
-            }
+            pContent->InvalidatePos_();
         }
     }
 }
@@ -1535,26 +1535,26 @@ void SwTextNode::Update(
     // Inform LOK clients about change in position of redlines (if any)
     // Don't emit notifications during save: redline flags are temporarily changed during save, but
     // it's not useful to let clients know about such changes.
-    if (comphelper::LibreOfficeKit::isActive() && !GetDoc()->IsInWriting())
+    if (!(comphelper::LibreOfficeKit::isActive() && !GetDoc()->IsInWriting()))
+        return;
+
+    const SwRedlineTable& rTable = GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
+    for (SwRedlineTable::size_type nRedlnPos = 0; nRedlnPos < rTable.size(); ++nRedlnPos)
     {
-        const SwRedlineTable& rTable = GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
-        for (SwRedlineTable::size_type nRedlnPos = 0; nRedlnPos < rTable.size(); ++nRedlnPos)
+        SwRangeRedline* pRedln = rTable[nRedlnPos];
+        if (pRedln->HasMark())
         {
-            SwRangeRedline* pRedln = rTable[nRedlnPos];
-            if (pRedln->HasMark())
+            if (this == &pRedln->End()->nNode.GetNode() && *pRedln->GetPoint() != *pRedln->GetMark())
             {
-                if (this == &pRedln->End()->nNode.GetNode() && *pRedln->GetPoint() != *pRedln->GetMark())
+                // Redline is changed only when some change occurs before it
+                if (nChangePos <= pRedln->Start()->nContent.GetIndex())
                 {
-                    // Redline is changed only when some change occurs before it
-                    if (nChangePos <= pRedln->Start()->nContent.GetIndex())
-                    {
-                        SwRedlineTable::LOKRedlineNotification(RedlineNotification::Modify, pRedln);
-                    }
+                    SwRedlineTable::LOKRedlineNotification(RedlineNotification::Modify, pRedln);
                 }
             }
-            else if (this == &pRedln->GetPoint()->nNode.GetNode())
-                SwRedlineTable::LOKRedlineNotification(RedlineNotification::Modify, pRedln);
         }
+        else if (this == &pRedln->GetPoint()->nNode.GetNode())
+            SwRedlineTable::LOKRedlineNotification(RedlineNotification::Modify, pRedln);
     }
 }
 
@@ -3330,43 +3330,43 @@ static void Replace0xFF(
     sal_Int32 & rTextStt,
     sal_Int32 nEndPos )
 {
-    if (rNode.GetpSwpHints())
+    if (!rNode.GetpSwpHints())
+        return;
+
+    sal_Unicode cSrchChr = CH_TXTATR_BREAKWORD;
+    for( int nSrchIter = 0; 2 > nSrchIter; ++nSrchIter, cSrchChr = CH_TXTATR_INWORD )
     {
-        sal_Unicode cSrchChr = CH_TXTATR_BREAKWORD;
-        for( int nSrchIter = 0; 2 > nSrchIter; ++nSrchIter, cSrchChr = CH_TXTATR_INWORD )
+        sal_Int32 nPos = rText.indexOf(cSrchChr);
+        while (-1 != nPos && nPos < nEndPos)
         {
-            sal_Int32 nPos = rText.indexOf(cSrchChr);
-            while (-1 != nPos && nPos < nEndPos)
+            const SwTextAttr* const pAttr =
+                rNode.GetTextAttrForCharAt(rTextStt + nPos);
+            if( pAttr )
             {
-                const SwTextAttr* const pAttr =
-                    rNode.GetTextAttrForCharAt(rTextStt + nPos);
-                if( pAttr )
-                {
-                    switch( pAttr->Which() )
-                    {
-                    case RES_TXTATR_FIELD:
-                    case RES_TXTATR_ANNOTATION:
-                        rText.remove(nPos, 1);
-                        ++rTextStt;
-                        break;
-
-                    case RES_TXTATR_FTN:
-                        rText.remove(nPos, 1);
-                        ++rTextStt;
-                        break;
-
-                    default:
-                        rText.remove(nPos, 1);
-                        ++rTextStt;
-                    }
-                }
-                else
+                switch( pAttr->Which() )
                 {
-                    ++nPos;
-                    ++nEndPos;
+                case RES_TXTATR_FIELD:
+                case RES_TXTATR_ANNOTATION:
+                    rText.remove(nPos, 1);
+                    ++rTextStt;
+                    break;
+
+                case RES_TXTATR_FTN:
+                    rText.remove(nPos, 1);
+                    ++rTextStt;
+                    break;
+
+                default:
+                    rText.remove(nPos, 1);
+                    ++rTextStt;
                 }
-                nPos = rText.indexOf(cSrchChr, nPos);
             }
+            else
+            {
+                ++nPos;
+                ++nEndPos;
+            }
+            nPos = rText.indexOf(cSrchChr, nPos);
         }
     }
 }
@@ -4163,18 +4163,18 @@ void SwTextNode::SetAttrListRestartValue( SwNumberTree::tSwNumTreeNumber nNumber
                          ? GetAttrListRestartValue() != nNumber
                          : nNumber != USHRT_MAX );
 
-    if ( bChanged || !HasAttrListRestartValue() )
+    if ( !(bChanged || !HasAttrListRestartValue()) )
+        return;
+
+    if ( nNumber == USHRT_MAX )
     {
-        if ( nNumber == USHRT_MAX )
-        {
-            ResetAttr( RES_PARATR_LIST_RESTARTVALUE );
-        }
-        else
-        {
-            SfxInt16Item aNewListRestartValueItem( RES_PARATR_LIST_RESTARTVALUE,
-                                                   static_cast<sal_Int16>(nNumber) );
-            SetAttr( aNewListRestartValueItem );
-        }
+        ResetAttr( RES_PARATR_LIST_RESTARTVALUE );
+    }
+    else
+    {
+        SfxInt16Item aNewListRestartValueItem( RES_PARATR_LIST_RESTARTVALUE,
+                                               static_cast<sal_Int16>(nNumber) );
+        SetAttr( aNewListRestartValueItem );
     }
 }
 
@@ -4289,23 +4289,23 @@ void SwTextNode::AddToList()
     }
 
     SwList *const pList(FindList(this));
-    if (pList && GetNodes().IsDocNodes()) // not for undo nodes
+    if (!(pList && GetNodes().IsDocNodes())) // not for undo nodes
+        return;
+
+    assert(!mpNodeNum);
+    mpNodeNum.reset(new SwNodeNum(this, false));
+    pList->InsertListItem(*mpNodeNum, false, GetAttrListLevel());
+    // iterate all frames & if there's one with hidden layout...
+    SwIterator<SwTextFrame, SwTextNode, sw::IteratorMode::UnwrapMulti> iter(*this);
+    for (SwTextFrame* pFrame = iter.First(); pFrame; pFrame = iter.Next())
     {
-        assert(!mpNodeNum);
-        mpNodeNum.reset(new SwNodeNum(this, false));
-        pList->InsertListItem(*mpNodeNum, false, GetAttrListLevel());
-        // iterate all frames & if there's one with hidden layout...
-        SwIterator<SwTextFrame, SwTextNode, sw::IteratorMode::UnwrapMulti> iter(*this);
-        for (SwTextFrame* pFrame = iter.First(); pFrame; pFrame = iter.Next())
+        if (pFrame->getRootFrame()->IsHideRedlines())
         {
-            if (pFrame->getRootFrame()->IsHideRedlines())
+            if (pFrame->GetTextNodeForParaProps() == this)
             {
-                if (pFrame->GetTextNodeForParaProps() == this)
-                {
-                    AddToListRLHidden();
-                }
-                break; // assume it's consistent, need to check only once
+                AddToListRLHidden();
             }
+            break; // assume it's consistent, need to check only once
         }
     }
 }
@@ -4879,22 +4879,22 @@ namespace {
         }
 
         // #i70748#
-        if (mbOutlineLevelSet)
+        if (!mbOutlineLevelSet)
+            return;
+
+        mrTextNode.GetNodes().UpdateOutlineNode(mrTextNode);
+        if (mrTextNode.GetAttrOutlineLevel() == 0)
+        {
+            mrTextNode.ResetEmptyListStyleDueToResetOutlineLevelAttr();
+        }
+        else
         {
-            mrTextNode.GetNodes().UpdateOutlineNode(mrTextNode);
-            if (mrTextNode.GetAttrOutlineLevel() == 0)
+            const SfxPoolItem* pItem = nullptr;
+            if ( mrTextNode.GetSwAttrSet().GetItemState( RES_PARATR_NUMRULE,
+                                                        true, &pItem )
+                                                            != SfxItemState::SET )
             {
-                mrTextNode.ResetEmptyListStyleDueToResetOutlineLevelAttr();
-            }
-            else
-            {
-                const SfxPoolItem* pItem = nullptr;
-                if ( mrTextNode.GetSwAttrSet().GetItemState( RES_PARATR_NUMRULE,
-                                                            true, &pItem )
-                                                                != SfxItemState::SET )
-                {
-                    mrTextNode.SetEmptyListStyleDueToSetOutlineLevelAttr();
-                }
+                mrTextNode.SetEmptyListStyleDueToSetOutlineLevelAttr();
             }
         }
     }
@@ -5103,29 +5103,29 @@ namespace {
             }
         }
 
-        if ( mrTextNode.IsInList() )
+        if ( !mrTextNode.IsInList() )
+            return;
+
+        if ( mbUpdateListLevel )
         {
-            if ( mbUpdateListLevel )
-            {
-                auto const nLevel(mrTextNode.GetAttrListLevel());
-                mrTextNode.DoNum(
-                    [nLevel](SwNodeNum & rNum) { rNum.SetLevelInListTree(nLevel); });
-            }
+            auto const nLevel(mrTextNode.GetAttrListLevel());
+            mrTextNode.DoNum(
+                [nLevel](SwNodeNum & rNum) { rNum.SetLevelInListTree(nLevel); });
+        }
 
-            if ( mbUpdateListRestart )
-            {
-                mrTextNode.DoNum(
-                    [](SwNodeNum & rNum) {
-                        rNum.InvalidateMe();
-                        rNum.NotifyInvalidSiblings();
-                    });
-            }
+        if ( mbUpdateListRestart )
+        {
+            mrTextNode.DoNum(
+                [](SwNodeNum & rNum) {
+                    rNum.InvalidateMe();
+                    rNum.NotifyInvalidSiblings();
+                });
+        }
 
-            if ( mbUpdateListCount )
-            {
-                mrTextNode.DoNum(
-                    [](SwNodeNum & rNum) { rNum.InvalidateAndNotifyTree(); });
-            }
+        if ( mbUpdateListCount )
+        {
+            mrTextNode.DoNum(
+                [](SwNodeNum & rNum) { rNum.InvalidateAndNotifyTree(); });
         }
     }
     // End of class <HandleResetAttrAtTextNode>
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index 51b3edd81cb6..48df59b19b3d 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -1146,110 +1146,110 @@ SwTextAttr* MakeTextAttr( SwDoc & rDoc, const SfxItemSet& rSet,
 // delete the text attribute and unregister its item at the pool
 void SwTextNode::DestroyAttr( SwTextAttr* pAttr )
 {
-    if( pAttr )
+    if( !pAttr )
+        return;
+
+    // some things need to be done before deleting the formatting attribute
+    SwDoc* pDoc = GetDoc();
+    switch( pAttr->Which() )
     {
-        // some things need to be done before deleting the formatting attribute
-        SwDoc* pDoc = GetDoc();
-        switch( pAttr->Which() )
+    case RES_TXTATR_FLYCNT:
         {
-        case RES_TXTATR_FLYCNT:
-            {
-                SwFrameFormat* pFormat = pAttr->GetFlyCnt().GetFrameFormat();
-                if( pFormat )      // set to 0 by Undo?
-                    pDoc->getIDocumentLayoutAccess().DelLayoutFormat( pFormat );
-            }
-            break;
+            SwFrameFormat* pFormat = pAttr->GetFlyCnt().GetFrameFormat();
+            if( pFormat )      // set to 0 by Undo?
+                pDoc->getIDocumentLayoutAccess().DelLayoutFormat( pFormat );
+        }
+        break;
 
-        case RES_CHRATR_HIDDEN:
-            SetCalcHiddenCharFlags();
-            break;
+    case RES_CHRATR_HIDDEN:
+        SetCalcHiddenCharFlags();
+        break;
 
-        case RES_TXTATR_FTN:
-            static_cast<SwTextFootnote*>(pAttr)->SetStartNode( nullptr );
-            static_cast<SwFormatFootnote&>(pAttr->GetAttr()).InvalidateFootnote();
-            break;
+    case RES_TXTATR_FTN:
+        static_cast<SwTextFootnote*>(pAttr)->SetStartNode( nullptr );
+        static_cast<SwFormatFootnote&>(pAttr->GetAttr()).InvalidateFootnote();
+        break;
 
-        case RES_TXTATR_FIELD:
-        case RES_TXTATR_ANNOTATION:
-        case RES_TXTATR_INPUTFIELD:
-            if( !pDoc->IsInDtor() )
-            {
-                SwTextField *const pTextField(static_txtattr_cast<SwTextField*>(pAttr));
-                SwFieldType* pFieldType = pAttr->GetFormatField().GetField()->GetTyp();
+    case RES_TXTATR_FIELD:
+    case RES_TXTATR_ANNOTATION:
+    case RES_TXTATR_INPUTFIELD:
+        if( !pDoc->IsInDtor() )
+        {
+            SwTextField *const pTextField(static_txtattr_cast<SwTextField*>(pAttr));
+            SwFieldType* pFieldType = pAttr->GetFormatField().GetField()->GetTyp();
 
-                //JP 06-08-95: DDE-fields are an exception
-                assert(SwFieldIds::Dde == pFieldType->Which() ||
-                       this == pTextField->GetpTextNode());
+            //JP 06-08-95: DDE-fields are an exception
+            assert(SwFieldIds::Dde == pFieldType->Which() ||
+                   this == pTextField->GetpTextNode());
 
-                // certain fields must update the SwDoc's calculation flags
+            // certain fields must update the SwDoc's calculation flags
 
-                // Certain fields (like HiddenParaField) must trigger recalculation of visible flag
-                if (GetDoc()->FieldCanHideParaWeight(pFieldType->Which()))
-                    SetCalcHiddenParaField();
+            // Certain fields (like HiddenParaField) must trigger recalculation of visible flag
+            if (GetDoc()->FieldCanHideParaWeight(pFieldType->Which()))
+                SetCalcHiddenParaField();
 
-                switch( pFieldType->Which() )
+            switch( pFieldType->Which() )
+            {
+            case SwFieldIds::HiddenPara:
+            case SwFieldIds::DbSetNumber:
+            case SwFieldIds::GetExp:
+            case SwFieldIds::Database:
+            case SwFieldIds::SetExp:
+            case SwFieldIds::HiddenText:
+            case SwFieldIds::DbNumSet:
+            case SwFieldIds::DbNextSet:
+                if( !pDoc->getIDocumentFieldsAccess().IsNewFieldLst() && GetNodes().IsDocNodes() )
+                    pDoc->getIDocumentFieldsAccess().InsDelFieldInFieldLst(false, *pTextField);
+                break;
+            case SwFieldIds::Dde:
+                if (GetNodes().IsDocNodes() && pTextField->GetpTextNode())
+                    static_cast<SwDDEFieldType*>(pFieldType)->DecRefCnt();
+                break;
+            case SwFieldIds::Postit:
                 {
-                case SwFieldIds::HiddenPara:
-                case SwFieldIds::DbSetNumber:
-                case SwFieldIds::GetExp:
-                case SwFieldIds::Database:
-                case SwFieldIds::SetExp:
-                case SwFieldIds::HiddenText:
-                case SwFieldIds::DbNumSet:
-                case SwFieldIds::DbNextSet:
-                    if( !pDoc->getIDocumentFieldsAccess().IsNewFieldLst() && GetNodes().IsDocNodes() )
-                        pDoc->getIDocumentFieldsAccess().InsDelFieldInFieldLst(false, *pTextField);
+                    const_cast<SwFormatField&>(pAttr->GetFormatField()).Broadcast(
+                        SwFormatFieldHint(&pTextField->GetFormatField(), SwFormatFieldHintWhich::REMOVED));
                     break;
-                case SwFieldIds::Dde:
-                    if (GetNodes().IsDocNodes() && pTextField->GetpTextNode())
-                        static_cast<SwDDEFieldType*>(pFieldType)->DecRefCnt();
-                    break;
-                case SwFieldIds::Postit:
-                    {
-                        const_cast<SwFormatField&>(pAttr->GetFormatField()).Broadcast(
-                            SwFormatFieldHint(&pTextField->GetFormatField(), SwFormatFieldHintWhich::REMOVED));
-                        break;
-                    }
-                default: break;
                 }
+            default: break;
             }
-            static_cast<SwFormatField&>(pAttr->GetAttr()).InvalidateField();
-            break;
+        }
+        static_cast<SwFormatField&>(pAttr->GetAttr()).InvalidateField();
+        break;
 
-        case RES_TXTATR_TOXMARK:
-            static_cast<SwTOXMark&>(pAttr->GetAttr()).InvalidateTOXMark();
-            break;
+    case RES_TXTATR_TOXMARK:
+        static_cast<SwTOXMark&>(pAttr->GetAttr()).InvalidateTOXMark();
+        break;
 
-        case RES_TXTATR_REFMARK:
-            static_cast<SwFormatRefMark&>(pAttr->GetAttr()).InvalidateRefMark();
-            break;
+    case RES_TXTATR_REFMARK:
+        static_cast<SwFormatRefMark&>(pAttr->GetAttr()).InvalidateRefMark();
+        break;
 
-        case RES_TXTATR_META:
-        case RES_TXTATR_METAFIELD:
+    case RES_TXTATR_META:
+    case RES_TXTATR_METAFIELD:
+    {
+        auto pTextMeta = static_txtattr_cast<SwTextMeta*>(pAttr);
+        SwFormatMeta & rFormatMeta( static_cast<SwFormatMeta &>(pTextMeta->GetAttr()) );
+        if (::sw::Meta* pMeta = rFormatMeta.GetMeta())
         {
-            auto pTextMeta = static_txtattr_cast<SwTextMeta*>(pAttr);
-            SwFormatMeta & rFormatMeta( static_cast<SwFormatMeta &>(pTextMeta->GetAttr()) );
-            if (::sw::Meta* pMeta = rFormatMeta.GetMeta())
+            if (SwDocShell* pDocSh = pDoc->GetDocShell())
             {
-                if (SwDocShell* pDocSh = pDoc->GetDocShell())
-                {
-                    static const OUString metaNS("urn:bails");
-                    const css::uno::Reference<css::rdf::XResource> xSubject = pMeta->MakeUnoObject();
-                    uno::Reference<frame::XModel> xModel = pDocSh->GetBaseModel();
-                    SwRDFHelper::clearStatements(xModel, metaNS, xSubject);
-                }
+                static const OUString metaNS("urn:bails");
+                const css::uno::Reference<css::rdf::XResource> xSubject = pMeta->MakeUnoObject();
+                uno::Reference<frame::XModel> xModel = pDocSh->GetBaseModel();
+                SwRDFHelper::clearStatements(xModel, metaNS, xSubject);
             }
-
-            static_txtattr_cast<SwTextMeta*>(pAttr)->ChgTextNode(nullptr);
         }
-            break;
 
-        default:
-            break;
-        }
+        static_txtattr_cast<SwTextMeta*>(pAttr)->ChgTextNode(nullptr);
+    }
+        break;
 
-        SwTextAttr::Destroy( pAttr, pDoc->GetAttrPool() );
+    default:
+        break;
     }
+
+    SwTextAttr::Destroy( pAttr, pDoc->GetAttrPool() );
 }
 
 SwTextAttr* SwTextNode::InsertItem(
@@ -1839,25 +1839,25 @@ void SwTextNode::TryCharSetExpandToNum(const SfxItemSet& aCharSet)
 
     int nLevel = GetActualListLevel();
 
-    if (nLevel != -1 && pCurrNum)
-    {
-        const SwNumFormat* pCurrNumFormat = pCurrNum->GetNumFormat(static_cast<sal_uInt16>(nLevel));
-        if (pCurrNumFormat)
-        {
-            if (pCurrNumFormat->IsItemize() && lcl_IsIgnoredCharFormatForBullets(nWhich))
-                return;
-            if (pCurrNumFormat->IsEnumeration() && SwTextNode::IsIgnoredCharFormatForNumbering(nWhich))
-                return;
-            SwCharFormat* pCurrCharFormat =pCurrNumFormat->GetCharFormat();
+    if (!(nLevel != -1 && pCurrNum))
+        return;
 
-            if (pCurrCharFormat && pCurrCharFormat->GetItemState(nWhich,false) != SfxItemState::SET)
-            {
-                pCurrCharFormat->SetFormatAttr(*pItem);
-                SwNumFormat aNewNumFormat(*pCurrNumFormat);
-                aNewNumFormat.SetCharFormat(pCurrCharFormat);
-                pCurrNum->Set(nLevel,aNewNumFormat);
-            }
-        }
+    const SwNumFormat* pCurrNumFormat = pCurrNum->GetNumFormat(static_cast<sal_uInt16>(nLevel));
+    if (!pCurrNumFormat)
+        return;
+
+    if (pCurrNumFormat->IsItemize() && lcl_IsIgnoredCharFormatForBullets(nWhich))
+        return;
+    if (pCurrNumFormat->IsEnumeration() && SwTextNode::IsIgnoredCharFormatForNumbering(nWhich))
+        return;
+    SwCharFormat* pCurrCharFormat =pCurrNumFormat->GetCharFormat();
+
+    if (pCurrCharFormat && pCurrCharFormat->GetItemState(nWhich,false) != SfxItemState::SET)
+    {
+        pCurrCharFormat->SetFormatAttr(*pItem);
+        SwNumFormat aNewNumFormat(*pCurrNumFormat);
+        aNewNumFormat.SetCharFormat(pCurrCharFormat);
+        pCurrNum->Set(nLevel,aNewNumFormat);
     }
 }
 
@@ -2074,19 +2074,19 @@ public:
 static void lcl_MergeListLevelIndentAsLRSpaceItem( const SwTextNode& rTextNode,
                                             SfxItemSet& rSet )
 {
-    if ( rTextNode.AreListLevelIndentsApplicable() )
+    if ( !rTextNode.AreListLevelIndentsApplicable() )
+        return;
+
+    const SwNumRule* pRule = rTextNode.GetNumRule();
+    if ( pRule && rTextNode.GetActualListLevel() >= 0 )
     {
-        const SwNumRule* pRule = rTextNode.GetNumRule();
-        if ( pRule && rTextNode.GetActualListLevel() >= 0 )
+        const SwNumFormat& rFormat = pRule->Get(static_cast<sal_uInt16>(rTextNode.GetActualListLevel()));
+        if ( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
         {
-            const SwNumFormat& rFormat = pRule->Get(static_cast<sal_uInt16>(rTextNode.GetActualListLevel()));
-            if ( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
-            {
-                SvxLRSpaceItem aLR( RES_LR_SPACE );
-                aLR.SetTextLeft( rFormat.GetIndentAt() );
-                aLR.SetTextFirstLineOffset( static_cast<short>(rFormat.GetFirstLineIndent()) );
-                rSet.Put( aLR );
-            }
+            SvxLRSpaceItem aLR( RES_LR_SPACE );
+            aLR.SetTextLeft( rFormat.GetIndentAt() );
+            aLR.SetTextFirstLineOffset( static_cast<short>(rFormat.GetFirstLineIndent()) );
+            rSet.Put( aLR );
         }
     }
 }
@@ -3364,38 +3364,38 @@ void SwpHints::Delete( SwTextAttr const * pTextHt )
 
 void SwTextNode::ClearSwpHintsArr( bool bDelFields )
 {
-    if ( HasHints() )
+    if ( !HasHints() )
+        return;
+
+    size_t nPos = 0;
+    while ( nPos < m_pSwpHints->Count() )
     {
-        size_t nPos = 0;
-        while ( nPos < m_pSwpHints->Count() )
-        {
-            SwTextAttr* pDel = m_pSwpHints->Get( nPos );
-            bool bDel = false;
+        SwTextAttr* pDel = m_pSwpHints->Get( nPos );
+        bool bDel = false;
 
-            switch( pDel->Which() )
-            {
-            case RES_TXTATR_FLYCNT:
-            case RES_TXTATR_FTN:
-                break;
+        switch( pDel->Which() )
+        {
+        case RES_TXTATR_FLYCNT:
+        case RES_TXTATR_FTN:
+            break;
 
-            case RES_TXTATR_FIELD:
-            case RES_TXTATR_ANNOTATION:
-            case RES_TXTATR_INPUTFIELD:
-                if( bDelFields )
-                    bDel = true;
-                break;
-            default:
-                bDel = true; break;
-            }
+        case RES_TXTATR_FIELD:
+        case RES_TXTATR_ANNOTATION:
+        case RES_TXTATR_INPUTFIELD:
+            if( bDelFields )
+                bDel = true;
+            break;
+        default:
+            bDel = true; break;
+        }
 
-            if( bDel )
-            {
-                m_pSwpHints->DeleteAtPos( nPos );
-                DestroyAttr( pDel );
-            }
-            else
-                ++nPos;
+        if( bDel )
+        {
+            m_pSwpHints->DeleteAtPos( nPos );
+            DestroyAttr( pDel );
         }
+        else
+            ++nPos;
     }
 }
 
diff --git a/sw/source/core/txtnode/txatritr.cxx b/sw/source/core/txtnode/txatritr.cxx
index b90f1060fd5e..883c09760c33 100644
--- a/sw/source/core/txtnode/txatritr.cxx
+++ b/sw/source/core/txtnode/txatritr.cxx
@@ -178,39 +178,39 @@ void SwLanguageIterator::SearchNextChg()
     m_pCurrentItem = m_pParaItem;
 
     const SwpHints* pHts = m_rTextNode.GetpSwpHints();
-    if( pHts )
+    if( !pHts )
+        return;
+
+    if( !nWh )
     {
-        if( !nWh )
-        {
-            nWh = GetWhichOfScript( RES_CHRATR_LANGUAGE, m_aScriptIter.GetCurrScript() );
-        }
+        nWh = GetWhichOfScript( RES_CHRATR_LANGUAGE, m_aScriptIter.GetCurrScript() );
+    }
 
-        const SfxPoolItem* pItem = nullptr;
-        for( ; m_nAttrPos < pHts->Count(); ++m_nAttrPos )
-        {
-            const SwTextAttr* pHt = pHts->Get( m_nAttrPos );
-            const sal_Int32* pEnd = pHt->End();
-            const sal_Int32 nHtStt = pHt->GetStart();
-            if( nHtStt < nStt && ( !pEnd || *pEnd <= nStt ))
-                continue;
+    const SfxPoolItem* pItem = nullptr;
+    for( ; m_nAttrPos < pHts->Count(); ++m_nAttrPos )
+    {
+        const SwTextAttr* pHt = pHts->Get( m_nAttrPos );
+        const sal_Int32* pEnd = pHt->End();
+        const sal_Int32 nHtStt = pHt->GetStart();
+        if( nHtStt < nStt && ( !pEnd || *pEnd <= nStt ))
+            continue;
 
-            if( nHtStt >= m_nChgPos )
-                break;
+        if( nHtStt >= m_nChgPos )
+            break;
 
-            pItem = CharFormat::GetItem( *pHt, nWh );
-            if ( pItem )
+        pItem = CharFormat::GetItem( *pHt, nWh );
+        if ( pItem )
+        {
+            if( nHtStt > nStt )
             {
-                if( nHtStt > nStt )
-                {
-                    if( m_nChgPos > nHtStt )
-                        m_nChgPos = nHtStt;
-                    break;
-                }
-                AddToStack( *pHt );
-                m_pCurrentItem = pItem;
-                if( *pEnd < m_nChgPos )
-                    m_nChgPos = *pEnd;
+                if( m_nChgPos > nHtStt )
+                    m_nChgPos = nHtStt;
+                break;
             }
+            AddToStack( *pHt );
+            m_pCurrentItem = pItem;
+            if( *pEnd < m_nChgPos )
+                m_nChgPos = *pEnd;
         }
     }
 }
diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index cbc5f4f396d7..f67324fd2ea1 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -622,23 +622,23 @@ void SwTextNode::RstTextAttr(
 
     TryDeleteSwpHints();
 
-    if (bChanged)
-    {
-        if ( HasHints() )
-        {   // possibly sometimes Resort would be sufficient, but...
-            m_pSwpHints->MergePortions(*this);
-        }
-
-        // TextFrame's respond to aHint, others to aNew
-        SwUpdateAttr aHint(
-            nMin,
-            nMax,
-            0);
+    if (!bChanged)
+        return;
 
-        NotifyClients( nullptr, &aHint );
-        SwFormatChg aNew( GetFormatColl() );
-        NotifyClients( nullptr, &aNew );
+    if ( HasHints() )
+    {   // possibly sometimes Resort would be sufficient, but...
+        m_pSwpHints->MergePortions(*this);
     }
+
+    // TextFrame's respond to aHint, others to aNew
+    SwUpdateAttr aHint(
+        nMin,
+        nMax,
+        0);
+
+    NotifyClients( nullptr, &aHint );
+    SwFormatChg aNew( GetFormatColl() );
+    NotifyClients( nullptr, &aNew );
 }
 
 static sal_Int32 clipIndexBounds(const OUString &rStr, sal_Int32 nPos)
@@ -1679,243 +1679,243 @@ void SwTextNode::TransliterateText(
     sal_Int32 nStt, sal_Int32 nEnd,
     SwUndoTransliterate* pUndo )
 {
-    if (nStt < nEnd)
-    {
-        // since we don't use Hiragana/Katakana or half-width/full-width transliterations here
-        // it is fine to use ANYWORD_IGNOREWHITESPACES. (ANY_WORD btw is broken and will
-        // occasionally miss words in consecutive sentences). Also with ANYWORD_IGNOREWHITESPACES
-        // text like 'just-in-time' will be converted to 'Just-In-Time' which seems to be the
-        // proper thing to do.
-        const sal_Int16 nWordType = WordType::ANYWORD_IGNOREWHITESPACES;
-
-        // In order to have less trouble with changing text size, e.g. because
-        // of ligatures or German small sz being resolved, we need to process
-        // the text replacements from end to start.
-        // This way the offsets for the yet to be changed words will be
-        // left unchanged by the already replaced text.
-        // For this we temporarily save the changes to be done in this vector
-        std::vector< swTransliterationChgData >   aChanges;
-        swTransliterationChgData                  aChgData;
-
-        if (rTrans.getType() == TransliterationFlags::TITLE_CASE)
+    if (nStt >= nEnd)
+        return;
+
+    // since we don't use Hiragana/Katakana or half-width/full-width transliterations here
+    // it is fine to use ANYWORD_IGNOREWHITESPACES. (ANY_WORD btw is broken and will
+    // occasionally miss words in consecutive sentences). Also with ANYWORD_IGNOREWHITESPACES
+    // text like 'just-in-time' will be converted to 'Just-In-Time' which seems to be the
+    // proper thing to do.
+    const sal_Int16 nWordType = WordType::ANYWORD_IGNOREWHITESPACES;
+
+    // In order to have less trouble with changing text size, e.g. because
+    // of ligatures or German small sz being resolved, we need to process
+    // the text replacements from end to start.
+    // This way the offsets for the yet to be changed words will be
+    // left unchanged by the already replaced text.
+    // For this we temporarily save the changes to be done in this vector
+    std::vector< swTransliterationChgData >   aChanges;
+    swTransliterationChgData                  aChgData;
+
+    if (rTrans.getType() == TransliterationFlags::TITLE_CASE)
+    {
+        // for 'capitalize every word' we need to iterate over each word
+
+        Boundary aSttBndry;
+        Boundary aEndBndry;
+        aSttBndry = g_pBreakIt->GetBreakIter()->getWordBoundary(
+                    GetText(), nStt,
+                    g_pBreakIt->GetLocale( GetLang( nStt ) ),
+                    nWordType,
+                    true /*prefer forward direction*/);
+        aEndBndry = g_pBreakIt->GetBreakIter()->getWordBoundary(
+                    GetText(), nEnd,
+                    g_pBreakIt->GetLocale( GetLang( nEnd ) ),
+                    nWordType,
+                    false /*prefer backward direction*/);
+
+        // prevent backtracking to the previous word if selection is at word boundary
+        if (aSttBndry.endPos <= nStt)
         {
-            // for 'capitalize every word' we need to iterate over each word
-
-            Boundary aSttBndry;
-            Boundary aEndBndry;
-            aSttBndry = g_pBreakIt->GetBreakIter()->getWordBoundary(
-                        GetText(), nStt,
-                        g_pBreakIt->GetLocale( GetLang( nStt ) ),
-                        nWordType,
-                        true /*prefer forward direction*/);
-            aEndBndry = g_pBreakIt->GetBreakIter()->getWordBoundary(
-                        GetText(), nEnd,
-                        g_pBreakIt->GetLocale( GetLang( nEnd ) ),
-                        nWordType,
-                        false /*prefer backward direction*/);
-
-            // prevent backtracking to the previous word if selection is at word boundary
-            if (aSttBndry.endPos <= nStt)
-            {
-                aSttBndry = g_pBreakIt->GetBreakIter()->nextWord(
-                        GetText(), aSttBndry.endPos,
-                        g_pBreakIt->GetLocale( GetLang( aSttBndry.endPos ) ),
-                        nWordType);
-            }
-            // prevent advancing to the next word if selection is at word boundary
-            if (aEndBndry.startPos >= nEnd)
+            aSttBndry = g_pBreakIt->GetBreakIter()->nextWord(
+                    GetText(), aSttBndry.endPos,
+                    g_pBreakIt->GetLocale( GetLang( aSttBndry.endPos ) ),
+                    nWordType);
+        }
+        // prevent advancing to the next word if selection is at word boundary
+        if (aEndBndry.startPos >= nEnd)
+        {
+            aEndBndry = g_pBreakIt->GetBreakIter()->previousWord(
+                    GetText(), aEndBndry.startPos,
+                    g_pBreakIt->GetLocale( GetLang( aEndBndry.startPos ) ),
+                    nWordType);
+        }
+
+        Boundary aCurWordBndry( aSttBndry );
+        while (aCurWordBndry.startPos <= aEndBndry.startPos)
+        {
+            nStt = aCurWordBndry.startPos;
+            nEnd = aCurWordBndry.endPos;
+            const sal_Int32 nLen = nEnd - nStt;
+            OSL_ENSURE( nLen > 0, "invalid word length of 0" );
+
+            Sequence <sal_Int32> aOffsets;
+            OUString const sChgd( rTrans.transliterate(
+                        GetText(), GetLang(nStt), nStt, nLen, &aOffsets) );
+
+            assert(nStt < m_Text.getLength());
+            if (0 != rtl_ustr_shortenedCompare_WithLength(
+                        m_Text.getStr() + nStt, m_Text.getLength() - nStt,
+                        sChgd.getStr(), sChgd.getLength(), nLen))
             {
-                aEndBndry = g_pBreakIt->GetBreakIter()->previousWord(
-                        GetText(), aEndBndry.startPos,
-                        g_pBreakIt->GetLocale( GetLang( aEndBndry.startPos ) ),
-                        nWordType);
+                aChgData.nStart     = nStt;
+                aChgData.nLen       = nLen;
+                aChgData.sChanged   = sChgd;
+                aChgData.aOffsets   = aOffsets;
+                aChanges.push_back( aChgData );
             }
 
-            Boundary aCurWordBndry( aSttBndry );
-            while (aCurWordBndry.startPos <= aEndBndry.startPos)
-            {
-                nStt = aCurWordBndry.startPos;
-                nEnd = aCurWordBndry.endPos;
-                const sal_Int32 nLen = nEnd - nStt;
-                OSL_ENSURE( nLen > 0, "invalid word length of 0" );
-
-                Sequence <sal_Int32> aOffsets;
-                OUString const sChgd( rTrans.transliterate(
-                            GetText(), GetLang(nStt), nStt, nLen, &aOffsets) );
-
-                assert(nStt < m_Text.getLength());
-                if (0 != rtl_ustr_shortenedCompare_WithLength(
-                            m_Text.getStr() + nStt, m_Text.getLength() - nStt,
-                            sChgd.getStr(), sChgd.getLength(), nLen))
-                {
-                    aChgData.nStart     = nStt;
-                    aChgData.nLen       = nLen;
-                    aChgData.sChanged   = sChgd;
-                    aChgData.aOffsets   = aOffsets;
-                    aChanges.push_back( aChgData );
-                }
+            aCurWordBndry = g_pBreakIt->GetBreakIter()->nextWord(
+                    GetText(), nStt,
+                    g_pBreakIt->GetLocale(GetLang(nStt, 1)),
+                    nWordType);
+        }
+    }
+    else if (rTrans.getType() == TransliterationFlags::SENTENCE_CASE)
+    {
+        // for 'sentence case' we need to iterate sentence by sentence
 
-                aCurWordBndry = g_pBreakIt->GetBreakIter()->nextWord(
-                        GetText(), nStt,
-                        g_pBreakIt->GetLocale(GetLang(nStt, 1)),
-                        nWordType);
-            }
+        sal_Int32 nLastStart = g_pBreakIt->GetBreakIter()->beginOfSentence(
+                GetText(), nEnd,
+                g_pBreakIt->GetLocale( GetLang( nEnd ) ) );
+        sal_Int32 nLastEnd = g_pBreakIt->GetBreakIter()->endOfSentence(
+                GetText(), nLastStart,
+                g_pBreakIt->GetLocale( GetLang( nLastStart ) ) );
+
+        // extend nStt, nEnd to the current sentence boundaries
+        sal_Int32 nCurrentStart = g_pBreakIt->GetBreakIter()->beginOfSentence(
+                GetText(), nStt,
+                g_pBreakIt->GetLocale( GetLang( nStt ) ) );
+        sal_Int32 nCurrentEnd = g_pBreakIt->GetBreakIter()->endOfSentence(
+                GetText(), nCurrentStart,
+                g_pBreakIt->GetLocale( GetLang( nCurrentStart ) ) );
+
+        // prevent backtracking to the previous sentence if selection starts at end of a sentence
+        if (nCurrentEnd <= nStt)
+        {
+            // now nCurrentStart is probably located on a non-letter word. (unless we
+            // are in Asian text with no spaces...)
+            // Thus to get the real sentence start we should locate the next real word,
+            // that is one found by DICTIONARY_WORD
+            i18n::Boundary aBndry = g_pBreakIt->GetBreakIter()->nextWord(
+                    GetText(), nCurrentEnd,
+                    g_pBreakIt->GetLocale( GetLang( nCurrentEnd ) ),
+                    i18n::WordType::DICTIONARY_WORD);
+
+            // now get new current sentence boundaries
+            nCurrentStart = g_pBreakIt->GetBreakIter()->beginOfSentence(
+                    GetText(), aBndry.startPos,
+                    g_pBreakIt->GetLocale( GetLang( aBndry.startPos) ) );
+            nCurrentEnd = g_pBreakIt->GetBreakIter()->endOfSentence(
+                    GetText(), nCurrentStart,
+                    g_pBreakIt->GetLocale( GetLang( nCurrentStart) ) );
         }
-        else if (rTrans.getType() == TransliterationFlags::SENTENCE_CASE)
+        // prevent advancing to the next sentence if selection ends at start of a sentence
+        if (nLastStart >= nEnd)
         {
-            // for 'sentence case' we need to iterate sentence by sentence
-
-            sal_Int32 nLastStart = g_pBreakIt->GetBreakIter()->beginOfSentence(
-                    GetText(), nEnd,
-                    g_pBreakIt->GetLocale( GetLang( nEnd ) ) );
-            sal_Int32 nLastEnd = g_pBreakIt->GetBreakIter()->endOfSentence(
+            // now nCurrentStart is probably located on a non-letter word. (unless we
+            // are in Asian text with no spaces...)
+            // Thus to get the real sentence start we should locate the previous real word,
+            // that is one found by DICTIONARY_WORD
+            i18n::Boundary aBndry = g_pBreakIt->GetBreakIter()->previousWord(
                     GetText(), nLastStart,
-                    g_pBreakIt->GetLocale( GetLang( nLastStart ) ) );
+                    g_pBreakIt->GetLocale( GetLang( nLastStart) ),
+                    i18n::WordType::DICTIONARY_WORD);
+            nLastEnd = g_pBreakIt->GetBreakIter()->endOfSentence(
+                    GetText(), aBndry.startPos,
+                    g_pBreakIt->GetLocale( GetLang( aBndry.startPos) ) );
+            if (nCurrentEnd > nLastEnd)
+                nCurrentEnd = nLastEnd;
+        }
 
-            // extend nStt, nEnd to the current sentence boundaries
-            sal_Int32 nCurrentStart = g_pBreakIt->GetBreakIter()->beginOfSentence(
-                    GetText(), nStt,
-                    g_pBreakIt->GetLocale( GetLang( nStt ) ) );
-            sal_Int32 nCurrentEnd = g_pBreakIt->GetBreakIter()->endOfSentence(
+        while (nCurrentStart < nLastEnd)
+        {
+            sal_Int32 nLen = nCurrentEnd - nCurrentStart;
+            OSL_ENSURE( nLen > 0, "invalid word length of 0" );
+
+            Sequence <sal_Int32> aOffsets;
+            OUString const sChgd( rTrans.transliterate(GetText(),
+                GetLang(nCurrentStart), nCurrentStart, nLen, &aOffsets) );
+
+            assert(nStt < m_Text.getLength());
+            if (0 != rtl_ustr_shortenedCompare_WithLength(
+                        m_Text.getStr() + nStt, m_Text.getLength() - nStt,
+                        sChgd.getStr(), sChgd.getLength(), nLen))
+            {
+                aChgData.nStart     = nCurrentStart;
+                aChgData.nLen       = nLen;
+                aChgData.sChanged   = sChgd;
+                aChgData.aOffsets   = aOffsets;
+                aChanges.push_back( aChgData );
+            }
+
+            Boundary aFirstWordBndry = g_pBreakIt->GetBreakIter()->nextWord(
+                    GetText(), nCurrentEnd,
+                    g_pBreakIt->GetLocale( GetLang( nCurrentEnd ) ),
+                    nWordType);
+            nCurrentStart = aFirstWordBndry.startPos;
+            nCurrentEnd = g_pBreakIt->GetBreakIter()->endOfSentence(
                     GetText(), nCurrentStart,
                     g_pBreakIt->GetLocale( GetLang( nCurrentStart ) ) );
+        }
+    }
+    else
+    {
+        // here we may transliterate over complete language portions...
+
+        std::unique_ptr<SwLanguageIterator> pIter;
+        if( rTrans.needLanguageForTheMode() )
+            pIter.reset(new SwLanguageIterator( *this, nStt ));
 
-            // prevent backtracking to the previous sentence if selection starts at end of a sentence
-            if (nCurrentEnd <= nStt)
+        sal_Int32 nEndPos = 0;
+        LanguageType nLang = LANGUAGE_NONE;
+        do {
+            if( pIter )
             {
-                // now nCurrentStart is probably located on a non-letter word. (unless we
-                // are in Asian text with no spaces...)
-                // Thus to get the real sentence start we should locate the next real word,
-                // that is one found by DICTIONARY_WORD
-                i18n::Boundary aBndry = g_pBreakIt->GetBreakIter()->nextWord(
-                        GetText(), nCurrentEnd,
-                        g_pBreakIt->GetLocale( GetLang( nCurrentEnd ) ),
-                        i18n::WordType::DICTIONARY_WORD);
-
-                // now get new current sentence boundaries
-                nCurrentStart = g_pBreakIt->GetBreakIter()->beginOfSentence(
-                        GetText(), aBndry.startPos,
-                        g_pBreakIt->GetLocale( GetLang( aBndry.startPos) ) );
-                nCurrentEnd = g_pBreakIt->GetBreakIter()->endOfSentence(
-                        GetText(), nCurrentStart,
-                        g_pBreakIt->GetLocale( GetLang( nCurrentStart) ) );
+                nLang = pIter->GetLanguage();
+                nEndPos = pIter->GetChgPos();
+                if( nEndPos > nEnd )
+                    nEndPos = nEnd;
             }
-            // prevent advancing to the next sentence if selection ends at start of a sentence
-            if (nLastStart >= nEnd)
+            else
             {
-                // now nCurrentStart is probably located on a non-letter word. (unless we
-                // are in Asian text with no spaces...)
-                // Thus to get the real sentence start we should locate the previous real word,
-                // that is one found by DICTIONARY_WORD
-                i18n::Boundary aBndry = g_pBreakIt->GetBreakIter()->previousWord(
-                        GetText(), nLastStart,
-                        g_pBreakIt->GetLocale( GetLang( nLastStart) ),
-                        i18n::WordType::DICTIONARY_WORD);
-                nLastEnd = g_pBreakIt->GetBreakIter()->endOfSentence(
-                        GetText(), aBndry.startPos,
-                        g_pBreakIt->GetLocale( GetLang( aBndry.startPos) ) );
-                if (nCurrentEnd > nLastEnd)
-                    nCurrentEnd = nLastEnd;
+                nLang = LANGUAGE_SYSTEM;
+                nEndPos = nEnd;
             }
+            const sal_Int32 nLen = nEndPos - nStt;
 
-            while (nCurrentStart < nLastEnd)
-            {
-                sal_Int32 nLen = nCurrentEnd - nCurrentStart;
-                OSL_ENSURE( nLen > 0, "invalid word length of 0" );
-
-                Sequence <sal_Int32> aOffsets;
-                OUString const sChgd( rTrans.transliterate(GetText(),
-                    GetLang(nCurrentStart), nCurrentStart, nLen, &aOffsets) );
-
-                assert(nStt < m_Text.getLength());
-                if (0 != rtl_ustr_shortenedCompare_WithLength(
-                            m_Text.getStr() + nStt, m_Text.getLength() - nStt,
-                            sChgd.getStr(), sChgd.getLength(), nLen))
-                {
-                    aChgData.nStart     = nCurrentStart;
-                    aChgData.nLen       = nLen;
-                    aChgData.sChanged   = sChgd;
-                    aChgData.aOffsets   = aOffsets;
-                    aChanges.push_back( aChgData );
-                }
+            Sequence <sal_Int32> aOffsets;
+            OUString const sChgd( rTrans.transliterate(
+                        m_Text, nLang, nStt, nLen, &aOffsets) );
 
-                Boundary aFirstWordBndry = g_pBreakIt->GetBreakIter()->nextWord(
-                        GetText(), nCurrentEnd,
-                        g_pBreakIt->GetLocale( GetLang( nCurrentEnd ) ),
-                        nWordType);
-                nCurrentStart = aFirstWordBndry.startPos;
-                nCurrentEnd = g_pBreakIt->GetBreakIter()->endOfSentence(
-                        GetText(), nCurrentStart,
-                        g_pBreakIt->GetLocale( GetLang( nCurrentStart ) ) );
+            assert(nStt < m_Text.getLength());
+            if (0 != rtl_ustr_shortenedCompare_WithLength(
+                        m_Text.getStr() + nStt, m_Text.getLength() - nStt,
+                        sChgd.getStr(), sChgd.getLength(), nLen))
+            {
+                aChgData.nStart     = nStt;
+                aChgData.nLen       = nLen;
+                aChgData.sChanged   = sChgd;
+                aChgData.aOffsets   = aOffsets;
+                aChanges.push_back( aChgData );
             }
-        }
-        else
-        {
-            // here we may transliterate over complete language portions...
 
-            std::unique_ptr<SwLanguageIterator> pIter;
-            if( rTrans.needLanguageForTheMode() )
-                pIter.reset(new SwLanguageIterator( *this, nStt ));
-
-            sal_Int32 nEndPos = 0;
-            LanguageType nLang = LANGUAGE_NONE;
-            do {
-                if( pIter )
-                {
-                    nLang = pIter->GetLanguage();
-                    nEndPos = pIter->GetChgPos();
-                    if( nEndPos > nEnd )
-                        nEndPos = nEnd;
-                }
-                else
-                {
-                    nLang = LANGUAGE_SYSTEM;
-                    nEndPos = nEnd;
-                }
-                const sal_Int32 nLen = nEndPos - nStt;
-
-                Sequence <sal_Int32> aOffsets;
-                OUString const sChgd( rTrans.transliterate(
-                            m_Text, nLang, nStt, nLen, &aOffsets) );
-
-                assert(nStt < m_Text.getLength());
-                if (0 != rtl_ustr_shortenedCompare_WithLength(
-                            m_Text.getStr() + nStt, m_Text.getLength() - nStt,
-                            sChgd.getStr(), sChgd.getLength(), nLen))
-                {
-                    aChgData.nStart     = nStt;
-                    aChgData.nLen       = nLen;
-                    aChgData.sChanged   = sChgd;
-                    aChgData.aOffsets   = aOffsets;
-                    aChanges.push_back( aChgData );
-                }
+            nStt = nEndPos;
+        } while( nEndPos < nEnd && pIter && pIter->Next() );
+    }
 
-                nStt = nEndPos;
-            } while( nEndPos < nEnd && pIter && pIter->Next() );
-        }
+    if (aChanges.empty())
+        return;
 
-        if (!aChanges.empty())
+    // now apply the changes from end to start to leave the offsets of the
+    // yet unchanged text parts remain the same.
+    size_t nSum(0);
+    for (size_t i = 0; i < aChanges.size(); ++i)
+    {   // check this here since AddChanges cannot be moved below
+        // call to ReplaceTextOnly
+        swTransliterationChgData & rData =
+            aChanges[ aChanges.size() - 1 - i ];
+        nSum += rData.sChanged.getLength() - rData.nLen;
+        if (nSum > o3tl::make_unsigned(GetSpaceLeft()))
         {
-            // now apply the changes from end to start to leave the offsets of the
-            // yet unchanged text parts remain the same.
-            size_t nSum(0);
-            for (size_t i = 0; i < aChanges.size(); ++i)
-            {   // check this here since AddChanges cannot be moved below
-                // call to ReplaceTextOnly
-                swTransliterationChgData & rData =
-                    aChanges[ aChanges.size() - 1 - i ];
-                nSum += rData.sChanged.getLength() - rData.nLen;
-                if (nSum > o3tl::make_unsigned(GetSpaceLeft()))
-                {
-                    SAL_WARN("sw.core", "SwTextNode::ReplaceTextOnly: "
-                            "node text with insertion > node capacity.");
-                    return;
-                }
-                if (pUndo)
-                    pUndo->AddChanges( *this, rData.nStart, rData.nLen, rData.aOffsets );
-                ReplaceTextOnly( rData.nStart, rData.nLen, rData.sChanged, rData.aOffsets );
-            }
+            SAL_WARN("sw.core", "SwTextNode::ReplaceTextOnly: "
+                    "node text with insertion > node capacity.");
+            return;
         }
+        if (pUndo)
+            pUndo->AddChanges( *this, rData.nStart, rData.nLen, rData.aOffsets );
+        ReplaceTextOnly( rData.nStart, rData.nLen, rData.sChanged, rData.aOffsets );
     }
 }
 


More information about the Libreoffice-commits mailing list