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

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Tue Apr 14 18:46:44 UTC 2020


 editeng/source/accessibility/AccessibleContextBase.cxx      |   98 -
 editeng/source/accessibility/AccessibleEditableTextPara.cxx |  106 -
 editeng/source/accessibility/AccessibleImageBullet.cxx      |   24 
 editeng/source/editeng/editdoc.cxx                          |   22 
 editeng/source/editeng/editeng.cxx                          |  150 +-
 editeng/source/editeng/editobj.cxx                          |   40 
 editeng/source/editeng/editview.cxx                         |  550 +++++-----
 editeng/source/editeng/eehtml.cxx                           |   66 -
 editeng/source/editeng/impedit.cxx                          |  649 +++++-------
 editeng/source/editeng/impedit2.cxx                         |  354 +++---
 editeng/source/editeng/impedit3.cxx                         |  256 ++--
 editeng/source/editeng/impedit4.cxx                         |  355 +++---
 editeng/source/editeng/impedit5.cxx                         |   68 -
 editeng/source/items/legacyitem.cxx                         |   64 -
 editeng/source/items/numitem.cxx                            |   48 
 editeng/source/items/svxfont.cxx                            |   28 
 editeng/source/misc/acorrcfg.cxx                            |  431 +++----
 editeng/source/misc/hangulhanja.cxx                         |  158 +-
 editeng/source/misc/splwrap.cxx                             |   26 
 editeng/source/misc/svxacorr.cxx                            |   64 -
 editeng/source/misc/txtrange.cxx                            |   55 -
 editeng/source/misc/unolingu.cxx                            |   22 
 editeng/source/outliner/outleeng.cxx                        |   26 
 editeng/source/outliner/outliner.cxx                        |  414 +++----
 editeng/source/outliner/outlvw.cxx                          |   44 
 editeng/source/rtf/rtfitem.cxx                              |  168 +--
 editeng/source/rtf/svxrtf.cxx                               |  276 ++---
 editeng/source/uno/unoedhlp.cxx                             |  104 -
 editeng/source/uno/unotext.cxx                              |  413 +++----
 editeng/source/uno/unotext2.cxx                             |   86 -
 30 files changed, 2580 insertions(+), 2585 deletions(-)

New commits:
commit d72f963c0de0c2e48f1dc999cd8687e13a1f676f
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Apr 14 15:58:10 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Apr 14 20:45:59 2020 +0200

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

diff --git a/editeng/source/accessibility/AccessibleContextBase.cxx b/editeng/source/accessibility/AccessibleContextBase.cxx
index d99cfa031d76..72ac002c9940 100644
--- a/editeng/source/accessibility/AccessibleContextBase.cxx
+++ b/editeng/source/accessibility/AccessibleContextBase.cxx
@@ -347,19 +347,19 @@ lang::Locale SAL_CALL
 void SAL_CALL AccessibleContextBase::addAccessibleEventListener (
         const uno::Reference<XAccessibleEventListener >& rxListener)
 {
-    if (rxListener.is())
+    if (!rxListener.is())
+        return;
+
+    if (rBHelper.bDisposed || rBHelper.bInDispose)
     {
-        if (rBHelper.bDisposed || rBHelper.bInDispose)
-        {
-            uno::Reference<uno::XInterface> x (static_cast<lang::XComponent *>(this), uno::UNO_QUERY);
-            rxListener->disposing (lang::EventObject (x));
-        }
-        else
-        {
-            if (!mnClientId)
-                mnClientId = comphelper::AccessibleEventNotifier::registerClient( );
-            comphelper::AccessibleEventNotifier::addEventListener( mnClientId, rxListener );
-        }
+        uno::Reference<uno::XInterface> x (static_cast<lang::XComponent *>(this), uno::UNO_QUERY);
+        rxListener->disposing (lang::EventObject (x));
+    }
+    else
+    {
+        if (!mnClientId)
+            mnClientId = comphelper::AccessibleEventNotifier::registerClient( );
+        comphelper::AccessibleEventNotifier::addEventListener( mnClientId, rxListener );
     }
 }
 
@@ -368,18 +368,18 @@ void SAL_CALL AccessibleContextBase::removeAccessibleEventListener (
         const uno::Reference<XAccessibleEventListener >& rxListener )
 {
     ThrowIfDisposed ();
-    if (rxListener.is() && mnClientId)
+    if (!(rxListener.is() && mnClientId))
+        return;
+
+    sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, rxListener );
+    if ( !nListenerCount )
     {
-        sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, rxListener );
-        if ( !nListenerCount )
-        {
-            // no listeners anymore
-            // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
-            // and at least to us not firing any events anymore, in case somebody calls
-            // NotifyAccessibleEvent, again
-            comphelper::AccessibleEventNotifier::revokeClient( mnClientId );
-            mnClientId = 0;
-        }
+        // no listeners anymore
+        // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
+        // and at least to us not firing any events anymore, in case somebody calls
+        // NotifyAccessibleEvent, again
+        comphelper::AccessibleEventNotifier::revokeClient( mnClientId );
+        mnClientId = 0;
     }
 }
 
@@ -432,21 +432,21 @@ void AccessibleContextBase::SetAccessibleDescription (
     const OUString& rDescription,
     StringOrigin eDescriptionOrigin)
 {
-    if (eDescriptionOrigin < meDescriptionOrigin
-        || (eDescriptionOrigin == meDescriptionOrigin && msDescription != rDescription))
-    {
-        uno::Any aOldValue, aNewValue;
-        aOldValue <<= msDescription;
-        aNewValue <<= rDescription;
+    if (!(eDescriptionOrigin < meDescriptionOrigin
+        || (eDescriptionOrigin == meDescriptionOrigin && msDescription != rDescription)))
+        return;
 
-        msDescription = rDescription;
-        meDescriptionOrigin = eDescriptionOrigin;
+    uno::Any aOldValue, aNewValue;
+    aOldValue <<= msDescription;
+    aNewValue <<= rDescription;
 
-        CommitChange(
-            AccessibleEventId::DESCRIPTION_CHANGED,
-            aNewValue,
-            aOldValue);
-    }
+    msDescription = rDescription;
+    meDescriptionOrigin = eDescriptionOrigin;
+
+    CommitChange(
+        AccessibleEventId::DESCRIPTION_CHANGED,
+        aNewValue,
+        aOldValue);
 }
 
 
@@ -454,21 +454,21 @@ void AccessibleContextBase::SetAccessibleName (
     const OUString& rName,
     StringOrigin eNameOrigin)
 {
-    if (eNameOrigin < meNameOrigin
-        || (eNameOrigin == meNameOrigin && msName != rName))
-    {
-        uno::Any aOldValue, aNewValue;
-        aOldValue <<= msName;
-        aNewValue <<= rName;
+    if (!(eNameOrigin < meNameOrigin
+        || (eNameOrigin == meNameOrigin && msName != rName)))
+        return;
 
-        msName = rName;
-        meNameOrigin = eNameOrigin;
+    uno::Any aOldValue, aNewValue;
+    aOldValue <<= msName;
+    aNewValue <<= rName;
 
-        CommitChange(
-            AccessibleEventId::NAME_CHANGED,
-            aNewValue,
-            aOldValue);
-    }
+    msName = rName;
+    meNameOrigin = eNameOrigin;
+
+    CommitChange(
+        AccessibleEventId::NAME_CHANGED,
+        aNewValue,
+        aOldValue);
 }
 
 
diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
index 55f7940e5b10..43e4f628b191 100644
--- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx
+++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
@@ -294,18 +294,18 @@ namespace accessibility
         mpEditSource = nullptr;
 
         // notify listeners
-        if( nClientId != -1 )
+        if( nClientId == -1 )
+            return;
+
+        try
         {
-            try
-            {
-                uno::Reference < XAccessibleContext > xThis = getAccessibleContext();
+            uno::Reference < XAccessibleContext > xThis = getAccessibleContext();
 
-                // #106234# Delegate to EventNotifier
-                ::comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nClientId, xThis );
-            }
-            catch (const uno::Exception&)
-            {
-            }
+            // #106234# Delegate to EventNotifier
+            ::comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nClientId, xThis );
+        }
+        catch (const uno::Exception&)
+        {
         }
     }
 
@@ -976,19 +976,19 @@ namespace accessibility
 
     void SAL_CALL AccessibleEditableTextPara::removeAccessibleEventListener( const uno::Reference< XAccessibleEventListener >& xListener )
     {
-        if( getNotifierClientId() != -1 )
+        if( getNotifierClientId() == -1 )
+            return;
+
+        const sal_Int32 nListenerCount = ::comphelper::AccessibleEventNotifier::removeEventListener( getNotifierClientId(), xListener );
+        if ( !nListenerCount )
         {
-            const sal_Int32 nListenerCount = ::comphelper::AccessibleEventNotifier::removeEventListener( getNotifierClientId(), xListener );
-            if ( !nListenerCount )
-            {
-                // no listeners anymore
-                // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
-                // and at least to us not firing any events anymore, in case somebody calls
-                // NotifyAccessibleEvent, again
-                ::comphelper::AccessibleEventNotifier::TClientId nId( getNotifierClientId() );
-                mnNotifierClientId = -1;
-                ::comphelper::AccessibleEventNotifier::revokeClient( nId );
-            }
+            // no listeners anymore
+            // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
+            // and at least to us not firing any events anymore, in case somebody calls
+            // NotifyAccessibleEvent, again
+            ::comphelper::AccessibleEventNotifier::TClientId nId( getNotifierClientId() );
+            mnNotifierClientId = -1;
+            ::comphelper::AccessibleEventNotifier::revokeClient( nId );
         }
     }
 
@@ -1636,39 +1636,39 @@ namespace accessibility
                 }
             }
         }
-        if( nFoundFieldIndex >= 0 )
+        if( nFoundFieldIndex < 0 )
+            return;
+
+        bool bExtend = false;
+        if( Segment.SegmentEnd < reeEnd )
+        {
+            Segment.SegmentEnd  = reeEnd;
+            bExtend = true;
+        }
+        if( Segment.SegmentStart > reeBegin )
         {
-            bool bExtend = false;
-            if( Segment.SegmentEnd < reeEnd )
-            {
-                Segment.SegmentEnd  = reeEnd;
-                bExtend = true;
-            }
-            if( Segment.SegmentStart > reeBegin )
-            {
-                Segment.SegmentStart = reeBegin;
-                bExtend = true;
-            }
-            if( bExtend )
-            {
-                //If there is a bullet before the field, should add the bullet length into the segment.
-                EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo(nParaIndex);
-                sal_Int32 nBulletLen = aBulletInfo.aText.getLength();
-                if (nBulletLen > 0)
-                {
-                    Segment.SegmentEnd += nBulletLen;
-                    if (nFoundFieldIndex > 0)
-                        Segment.SegmentStart += nBulletLen;
-                    Segment.SegmentText = GetTextRange(Segment.SegmentStart, Segment.SegmentEnd);
-                    //After get the correct field name, should restore the offset value which don't contain the bullet.
-                    Segment.SegmentEnd -= nBulletLen;
-                    if (nFoundFieldIndex > 0)
-                        Segment.SegmentStart -= nBulletLen;
-                }
-                else
-                    Segment.SegmentText = GetTextRange(Segment.SegmentStart, Segment.SegmentEnd);
-            }
+            Segment.SegmentStart = reeBegin;
+            bExtend = true;
         }
+        if( !bExtend )
+            return;
+
+        //If there is a bullet before the field, should add the bullet length into the segment.
+        EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo(nParaIndex);
+        sal_Int32 nBulletLen = aBulletInfo.aText.getLength();
+        if (nBulletLen > 0)
+        {
+            Segment.SegmentEnd += nBulletLen;
+            if (nFoundFieldIndex > 0)
+                Segment.SegmentStart += nBulletLen;
+            Segment.SegmentText = GetTextRange(Segment.SegmentStart, Segment.SegmentEnd);
+            //After get the correct field name, should restore the offset value which don't contain the bullet.
+            Segment.SegmentEnd -= nBulletLen;
+            if (nFoundFieldIndex > 0)
+                Segment.SegmentStart -= nBulletLen;
+        }
+        else
+            Segment.SegmentText = GetTextRange(Segment.SegmentStart, Segment.SegmentEnd);
     }
 
     css::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType )
diff --git a/editeng/source/accessibility/AccessibleImageBullet.cxx b/editeng/source/accessibility/AccessibleImageBullet.cxx
index 63120433f256..6d5b660aa26b 100644
--- a/editeng/source/accessibility/AccessibleImageBullet.cxx
+++ b/editeng/source/accessibility/AccessibleImageBullet.cxx
@@ -190,19 +190,19 @@ namespace accessibility
     void SAL_CALL AccessibleImageBullet::removeAccessibleEventListener( const uno::Reference< XAccessibleEventListener >& xListener )
     {
 
-        if( getNotifierClientId() != -1 )
+        if( getNotifierClientId() == -1 )
+            return;
+
+        const sal_Int32 nListenerCount = ::comphelper::AccessibleEventNotifier::removeEventListener( getNotifierClientId(), xListener );
+        if ( !nListenerCount )
         {
-            const sal_Int32 nListenerCount = ::comphelper::AccessibleEventNotifier::removeEventListener( getNotifierClientId(), xListener );
-            if ( !nListenerCount )
-            {
-                // no listeners anymore
-                // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
-                // and at least to us not firing any events anymore, in case somebody calls
-                // NotifyAccessibleEvent, again
-                ::comphelper::AccessibleEventNotifier::TClientId nId( getNotifierClientId() );
-                mnNotifierClientId = -1;
-                ::comphelper::AccessibleEventNotifier::revokeClient( nId );
-            }
+            // no listeners anymore
+            // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
+            // and at least to us not firing any events anymore, in case somebody calls
+            // NotifyAccessibleEvent, again
+            ::comphelper::AccessibleEventNotifier::TClientId nId( getNotifierClientId() );
+            mnNotifierClientId = -1;
+            ::comphelper::AccessibleEventNotifier::revokeClient( nId );
         }
     }
 
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 9e9eb17e6177..6fa39bbddaf4 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -1825,18 +1825,18 @@ void ContentAttribs::SetStyleSheet( SfxStyleSheet* pS )
     bool bStyleChanged = ( pStyle != pS );
     pStyle = pS;
     // Only when other style sheet, not when current style sheet modified
-    if ( pStyle && bStyleChanged )
+    if ( !(pStyle && bStyleChanged) )
+        return;
+
+    // Selectively remove the attributes from the paragraph formatting
+    // which are specified in the style, so that the attributes of the
+    // style can have an affect.
+    const SfxItemSet& rStyleAttribs = pStyle->GetItemSet();
+    for ( sal_uInt16 nWhich = EE_PARA_START; nWhich <= EE_CHAR_END; nWhich++ )
     {
-        // Selectively remove the attributes from the paragraph formatting
-        // which are specified in the style, so that the attributes of the
-        // style can have an affect.
-        const SfxItemSet& rStyleAttribs = pStyle->GetItemSet();
-        for ( sal_uInt16 nWhich = EE_PARA_START; nWhich <= EE_CHAR_END; nWhich++ )
-        {
-            // Don't change bullet on/off
-            if ( ( nWhich != EE_PARA_BULLETSTATE ) && ( rStyleAttribs.GetItemState( nWhich ) == SfxItemState::SET ) )
-                aAttribSet.ClearItem( nWhich );
-        }
+        // Don't change bullet on/off
+        if ( ( nWhich != EE_PARA_BULLETSTATE ) && ( rStyleAttribs.GetItemState( nWhich ) == SfxItemState::SET ) )
+            aAttribSet.ClearItem( nWhich );
     }
 }
 
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx
index 5a6aee022a80..1b76d967b3ba 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -385,31 +385,31 @@ void EditEngine::SetPaperSize( const Size& rNewSize )
     Size aNewSize( pImpEditEngine->GetPaperSize() );
 
     bool bAutoPageSize = pImpEditEngine->GetStatus().AutoPageSize();
-    if ( bAutoPageSize || ( aNewSize.Width() != aOldSize.Width() ) )
+    if ( !(bAutoPageSize || ( aNewSize.Width() != aOldSize.Width() )) )
+        return;
+
+    for (EditView* pView : pImpEditEngine->aEditViews)
     {
-        for (EditView* pView : pImpEditEngine->aEditViews)
+        if ( bAutoPageSize )
+            pView->pImpEditView->RecalcOutputArea();
+        else if ( pView->pImpEditView->DoAutoSize() )
         {
-            if ( bAutoPageSize )
-                pView->pImpEditView->RecalcOutputArea();
-            else if ( pView->pImpEditView->DoAutoSize() )
-            {
-                pView->pImpEditView->ResetOutputArea( tools::Rectangle(
-                    pView->pImpEditView->GetOutputArea().TopLeft(), aNewSize ) );
-            }
+            pView->pImpEditView->ResetOutputArea( tools::Rectangle(
+                pView->pImpEditView->GetOutputArea().TopLeft(), aNewSize ) );
         }
+    }
 
-        if ( bAutoPageSize || pImpEditEngine->IsFormatted() )
-        {
-            // Changing the width has no effect for AutoPageSize, as this is
-            // determined by the text width.
-            // Optimization first after Vobis delivery was enabled ...
-            pImpEditEngine->FormatFullDoc();
+    if ( bAutoPageSize || pImpEditEngine->IsFormatted() )
+    {
+        // Changing the width has no effect for AutoPageSize, as this is
+        // determined by the text width.
+        // Optimization first after Vobis delivery was enabled ...
+        pImpEditEngine->FormatFullDoc();
 
-            pImpEditEngine->UpdateViews( pImpEditEngine->GetActiveView() );
+        pImpEditEngine->UpdateViews( pImpEditEngine->GetActiveView() );
 
-            if ( pImpEditEngine->GetUpdateMode() && pImpEditEngine->GetActiveView() )
-                pImpEditEngine->pActiveView->ShowCursor( false, false );
-        }
+        if ( pImpEditEngine->GetUpdateMode() && pImpEditEngine->GetActiveView() )
+            pImpEditEngine->pActiveView->ShowCursor( false, false );
     }
 }
 
@@ -1843,72 +1843,72 @@ bool EditEngine::IsFlatMode() const
 void EditEngine::SetControlWord( EEControlBits nWord )
 {
 
-    if ( nWord != pImpEditEngine->aStatus.GetControlWord() )
-    {
-        EEControlBits nPrev = pImpEditEngine->aStatus.GetControlWord();
-        pImpEditEngine->aStatus.GetControlWord() = nWord;
+    if ( nWord == pImpEditEngine->aStatus.GetControlWord() )
+        return;
 
-        EEControlBits nChanges = nPrev ^ nWord;
-        if ( pImpEditEngine->IsFormatted() )
+    EEControlBits nPrev = pImpEditEngine->aStatus.GetControlWord();
+    pImpEditEngine->aStatus.GetControlWord() = nWord;
+
+    EEControlBits nChanges = nPrev ^ nWord;
+    if ( pImpEditEngine->IsFormatted() )
+    {
+        // possibly reformat:
+        if ( ( nChanges & EEControlBits::USECHARATTRIBS ) ||
+             ( nChanges & EEControlBits::ONECHARPERLINE ) ||
+             ( nChanges & EEControlBits::STRETCHING ) ||
+             ( nChanges & EEControlBits::OUTLINER ) ||
+             ( nChanges & EEControlBits::NOCOLORS ) ||
+             ( nChanges & EEControlBits::OUTLINER2 ) )
         {
-            // possibly reformat:
-            if ( ( nChanges & EEControlBits::USECHARATTRIBS ) ||
-                 ( nChanges & EEControlBits::ONECHARPERLINE ) ||
-                 ( nChanges & EEControlBits::STRETCHING ) ||
-                 ( nChanges & EEControlBits::OUTLINER ) ||
-                 ( nChanges & EEControlBits::NOCOLORS ) ||
-                 ( nChanges & EEControlBits::OUTLINER2 ) )
+            if ( nChanges & EEControlBits::USECHARATTRIBS )
             {
-                if ( nChanges & EEControlBits::USECHARATTRIBS )
-                {
-                    pImpEditEngine->GetEditDoc().CreateDefFont( true );
-                }
-
-                pImpEditEngine->FormatFullDoc();
-                pImpEditEngine->UpdateViews( pImpEditEngine->GetActiveView() );
+                pImpEditEngine->GetEditDoc().CreateDefFont( true );
             }
+
+            pImpEditEngine->FormatFullDoc();
+            pImpEditEngine->UpdateViews( pImpEditEngine->GetActiveView() );
         }
+    }
 
-        bool bSpellingChanged = bool(nChanges & EEControlBits::ONLINESPELLING);
+    bool bSpellingChanged = bool(nChanges & EEControlBits::ONLINESPELLING);
+
+    if ( !bSpellingChanged )
+        return;
 
-        if ( bSpellingChanged )
+    pImpEditEngine->StopOnlineSpellTimer();
+    if (nWord & EEControlBits::ONLINESPELLING)
+    {
+        // Create WrongList, start timer...
+        sal_Int32 nNodes = pImpEditEngine->GetEditDoc().Count();
+        for ( sal_Int32 n = 0; n < nNodes; n++ )
         {
-            pImpEditEngine->StopOnlineSpellTimer();
-            if (nWord & EEControlBits::ONLINESPELLING)
-            {
-                // Create WrongList, start timer...
-                sal_Int32 nNodes = pImpEditEngine->GetEditDoc().Count();
-                for ( sal_Int32 n = 0; n < nNodes; n++ )
-                {
-                    ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( n );
-                    pNode->CreateWrongList();
-                }
-                if (pImpEditEngine->IsFormatted())
-                    pImpEditEngine->StartOnlineSpellTimer();
-            }
-            else
+            ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( n );
+            pNode->CreateWrongList();
+        }
+        if (pImpEditEngine->IsFormatted())
+            pImpEditEngine->StartOnlineSpellTimer();
+    }
+    else
+    {
+        long nY = 0;
+        sal_Int32 nNodes = pImpEditEngine->GetEditDoc().Count();
+        for ( sal_Int32 n = 0; n < nNodes; n++ )
+        {
+            ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( n );
+            const ParaPortion* pPortion = pImpEditEngine->GetParaPortions()[n];
+            bool bWrongs = false;
+            if (pNode->GetWrongList() != nullptr)
+                bWrongs = !pNode->GetWrongList()->empty();
+            pNode->DestroyWrongList();
+            if ( bWrongs )
             {
-                long nY = 0;
-                sal_Int32 nNodes = pImpEditEngine->GetEditDoc().Count();
-                for ( sal_Int32 n = 0; n < nNodes; n++ )
-                {
-                    ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( n );
-                    const ParaPortion* pPortion = pImpEditEngine->GetParaPortions()[n];
-                    bool bWrongs = false;
-                    if (pNode->GetWrongList() != nullptr)
-                        bWrongs = !pNode->GetWrongList()->empty();
-                    pNode->DestroyWrongList();
-                    if ( bWrongs )
-                    {
-                        pImpEditEngine->aInvalidRect.SetLeft( 0 );
-                        pImpEditEngine->aInvalidRect.SetRight( pImpEditEngine->GetPaperSize().Width() );
-                        pImpEditEngine->aInvalidRect.SetTop( nY+1 );
-                        pImpEditEngine->aInvalidRect.SetBottom( nY+pPortion->GetHeight()-1 );
-                        pImpEditEngine->UpdateViews( pImpEditEngine->pActiveView );
-                    }
-                    nY += pPortion->GetHeight();
-                }
+                pImpEditEngine->aInvalidRect.SetLeft( 0 );
+                pImpEditEngine->aInvalidRect.SetRight( pImpEditEngine->GetPaperSize().Width() );
+                pImpEditEngine->aInvalidRect.SetTop( nY+1 );
+                pImpEditEngine->aInvalidRect.SetBottom( nY+pPortion->GetHeight()-1 );
+                pImpEditEngine->UpdateViews( pImpEditEngine->pActiveView );
             }
+            nY += pPortion->GetHeight();
         }
     }
 }
diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index ec4e964f83fd..f93d4a6205ad 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -444,26 +444,26 @@ void EditTextObject::dumpAsXml(xmlTextWriterPtr pWriter) const
 // from SfxItemPoolUser
 void EditTextObjectImpl::ObjectInDestruction(const SfxItemPool& rSfxItemPool)
 {
-    if(!bOwnerOfPool && pPool == &rSfxItemPool)
-    {
-        // The pool we are based on gets destructed; get owner of pool by creating own one.
-        // No need to call RemoveSfxItemPoolUser(), this is done from the pool's destructor
-        // Base new pool on EditEnginePool; it would also be possible to clone the used
-        // pool if needed, but only text attributes should be used.
-        SfxItemPool* pNewPool = EditEngine::CreatePool();
-
-        pNewPool->SetDefaultMetric(pPool->GetMetric(DEF_METRIC));
-
-        ContentInfosType aReplaced;
-        aReplaced.reserve(aContents.size());
-        for (auto const& content : aContents)
-            aReplaced.push_back(std::unique_ptr<ContentInfo>(new ContentInfo(*content, *pNewPool)));
-        aReplaced.swap(aContents);
-
-        // set local variables
-        pPool = pNewPool;
-        bOwnerOfPool = true;
-    }
+    if(!(!bOwnerOfPool && pPool == &rSfxItemPool))
+        return;
+
+    // The pool we are based on gets destructed; get owner of pool by creating own one.
+    // No need to call RemoveSfxItemPoolUser(), this is done from the pool's destructor
+    // Base new pool on EditEnginePool; it would also be possible to clone the used
+    // pool if needed, but only text attributes should be used.
+    SfxItemPool* pNewPool = EditEngine::CreatePool();
+
+    pNewPool->SetDefaultMetric(pPool->GetMetric(DEF_METRIC));
+
+    ContentInfosType aReplaced;
+    aReplaced.reserve(aContents.size());
+    for (auto const& content : aContents)
+        aReplaced.push_back(std::unique_ptr<ContentInfo>(new ContentInfo(*content, *pNewPool)));
+    aReplaced.swap(aContents);
+
+    // set local variables
+    pPool = pNewPool;
+    bOwnerOfPool = true;
 }
 
 #if DEBUG_EDIT_ENGINE
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index 71f13298f511..531fad3e12c2 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -472,23 +472,23 @@ void EditView::Command( const CommandEvent& rCEvt )
 
 void EditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor, bool bActivate )
 {
-    if ( pImpEditView->pEditEngine->HasView( this ) )
-    {
-        // The control word is more important:
-        if ( !pImpEditView->DoAutoScroll() )
-            bGotoCursor = false;
-        pImpEditView->ShowCursor( bGotoCursor, bForceVisCursor );
+    if ( !pImpEditView->pEditEngine->HasView( this ) )
+        return;
 
-        if (pImpEditView->mpViewShell && !bActivate)
-        {
-            VclPtr<vcl::Window> pParent = pImpEditView->pOutWin->GetParentWithLOKNotifier();
-            if (pParent && pParent->GetLOKWindowId() != 0)
-                return;
+    // The control word is more important:
+    if ( !pImpEditView->DoAutoScroll() )
+        bGotoCursor = false;
+    pImpEditView->ShowCursor( bGotoCursor, bForceVisCursor );
 
-            static const OString aPayload = OString::boolean(true);
-            pImpEditView->mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, aPayload.getStr());
-            pImpEditView->mpViewShell->NotifyOtherViews(LOK_CALLBACK_VIEW_CURSOR_VISIBLE, "visible", aPayload);
-        }
+    if (pImpEditView->mpViewShell && !bActivate)
+    {
+        VclPtr<vcl::Window> pParent = pImpEditView->pOutWin->GetParentWithLOKNotifier();
+        if (pParent && pParent->GetLOKWindowId() != 0)
+            return;
+
+        static const OString aPayload = OString::boolean(true);
+        pImpEditView->mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, aPayload.getStr());
+        pImpEditView->mpViewShell->NotifyOtherViews(LOK_CALLBACK_VIEW_CURSOR_VISIBLE, "visible", aPayload);
     }
 }
 
@@ -893,308 +893,308 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link<SpellCallbackInfo
     EditPaM aPaM = pImpEditView->pEditEngine->GetPaM(aPos, false);
     Reference< linguistic2::XSpellChecker1 >  xSpeller( pImpEditView->pEditEngine->pImpEditEngine->GetSpeller() );
     ESelection aOldSel = GetSelection();
-    if ( xSpeller.is() && pImpEditView->IsWrongSpelledWord( aPaM, true ) )
+    if ( !(xSpeller.is() && pImpEditView->IsWrongSpelledWord( aPaM, true )) )
+        return;
+
+    VclBuilder aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "editeng/ui/spellmenu.ui", "");
+    VclPtr<PopupMenu> aPopupMenu(aBuilder.get_menu("menu"));
+    const sal_uInt16 nAutoCorrId = aPopupMenu->GetItemId("autocorrect");
+    PopupMenu *pAutoMenu = aPopupMenu->GetPopupMenu(nAutoCorrId);
+    const sal_uInt16 nInsertId = aPopupMenu->GetItemId("insert");
+    PopupMenu *pInsertMenu = aPopupMenu->GetPopupMenu(nInsertId);  // add word to user-dictionaries
+    pInsertMenu->SetMenuFlags( MenuFlags::NoAutoMnemonics );         //! necessary to retrieve the correct dictionary names later
+    const sal_uInt16 nAddId = aPopupMenu->GetItemId("add");
+    const sal_uInt16 nIgnoreId = aPopupMenu->GetItemId("ignore");
+    const sal_uInt16 nCheckId = aPopupMenu->GetItemId("check");
+    const sal_uInt16 nAutoCorrectDlgId = aPopupMenu->GetItemId("autocorrectdlg");
+
+    EditPaM aPaM2( aPaM );
+    aPaM2.SetIndex( aPaM2.GetIndex()+1 );
+
+    // Are there any replace suggestions?
+    OUString aSelected( GetSelected() );
+
+    // restrict the maximal number of suggestions displayed
+    // in the context menu.
+    // Note: That could of course be done by clipping the
+    // resulting sequence but the current third party
+    // implementations result differs greatly if the number of
+    // suggestions to be returned gets changed. Statistically
+    // it gets much better if told to return e.g. only 7 strings
+    // than returning e.g. 16 suggestions and using only the
+    // first 7. Thus we hand down the value to use to that
+    // implementation here by providing an additional parameter.
+    Sequence< PropertyValue > aPropVals(1);
+    PropertyValue &rVal = aPropVals.getArray()[0];
+    rVal.Name = UPN_MAX_NUMBER_OF_SUGGESTIONS;
+    rVal.Value <<= sal_Int16(7);
+
+    // Are there any replace suggestions?
+    Reference< linguistic2::XSpellAlternatives >  xSpellAlt =
+            xSpeller->spell( aSelected, static_cast<sal_uInt16>(pImpEditView->pEditEngine->pImpEditEngine->GetLanguage( aPaM2 )), aPropVals );
+
+    Reference< linguistic2::XLanguageGuessing >  xLangGuesser( EditDLL::Get().GetGlobalData()->GetLanguageGuesser() );
+
+    // check if text might belong to a different language...
+    LanguageType nGuessLangWord = LANGUAGE_NONE;
+    LanguageType nGuessLangPara = LANGUAGE_NONE;
+    if (xSpellAlt.is() && xLangGuesser.is())
     {
-        VclBuilder aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "editeng/ui/spellmenu.ui", "");
-        VclPtr<PopupMenu> aPopupMenu(aBuilder.get_menu("menu"));
-        const sal_uInt16 nAutoCorrId = aPopupMenu->GetItemId("autocorrect");
-        PopupMenu *pAutoMenu = aPopupMenu->GetPopupMenu(nAutoCorrId);
-        const sal_uInt16 nInsertId = aPopupMenu->GetItemId("insert");
-        PopupMenu *pInsertMenu = aPopupMenu->GetPopupMenu(nInsertId);  // add word to user-dictionaries
-        pInsertMenu->SetMenuFlags( MenuFlags::NoAutoMnemonics );         //! necessary to retrieve the correct dictionary names later
-        const sal_uInt16 nAddId = aPopupMenu->GetItemId("add");
-        const sal_uInt16 nIgnoreId = aPopupMenu->GetItemId("ignore");
-        const sal_uInt16 nCheckId = aPopupMenu->GetItemId("check");
-        const sal_uInt16 nAutoCorrectDlgId = aPopupMenu->GetItemId("autocorrectdlg");
-
-        EditPaM aPaM2( aPaM );
-        aPaM2.SetIndex( aPaM2.GetIndex()+1 );
-
-        // Are there any replace suggestions?
-        OUString aSelected( GetSelected() );
-
-        // restrict the maximal number of suggestions displayed
-        // in the context menu.
-        // Note: That could of course be done by clipping the
-        // resulting sequence but the current third party
-        // implementations result differs greatly if the number of
-        // suggestions to be returned gets changed. Statistically
-        // it gets much better if told to return e.g. only 7 strings
-        // than returning e.g. 16 suggestions and using only the
-        // first 7. Thus we hand down the value to use to that
-        // implementation here by providing an additional parameter.
-        Sequence< PropertyValue > aPropVals(1);
-        PropertyValue &rVal = aPropVals.getArray()[0];
-        rVal.Name = UPN_MAX_NUMBER_OF_SUGGESTIONS;
-        rVal.Value <<= sal_Int16(7);
-
-        // Are there any replace suggestions?
-        Reference< linguistic2::XSpellAlternatives >  xSpellAlt =
-                xSpeller->spell( aSelected, static_cast<sal_uInt16>(pImpEditView->pEditEngine->pImpEditEngine->GetLanguage( aPaM2 )), aPropVals );
-
-        Reference< linguistic2::XLanguageGuessing >  xLangGuesser( EditDLL::Get().GetGlobalData()->GetLanguageGuesser() );
-
-        // check if text might belong to a different language...
-        LanguageType nGuessLangWord = LANGUAGE_NONE;
-        LanguageType nGuessLangPara = LANGUAGE_NONE;
-        if (xSpellAlt.is() && xLangGuesser.is())
+        OUString aParaText;
+        ContentNode *pNode = aPaM.GetNode();
+        if (pNode)
         {
-            OUString aParaText;
-            ContentNode *pNode = aPaM.GetNode();
-            if (pNode)
-            {
-                aParaText = pNode->GetString();
-            }
-            else
-            {
-                OSL_FAIL( "content node is NULL" );
-            }
-
-            nGuessLangWord = CheckLanguage( xSpellAlt->getWord(), xSpeller, xLangGuesser, false );
-            nGuessLangPara = CheckLanguage( aParaText, xSpeller, xLangGuesser, true );
+            aParaText = pNode->GetString();
         }
-        if (nGuessLangWord != LANGUAGE_NONE || nGuessLangPara != LANGUAGE_NONE)
+        else
         {
-            // make sure LANGUAGE_NONE gets not used as menu entry
-            if (nGuessLangWord == LANGUAGE_NONE)
-                nGuessLangWord = nGuessLangPara;
-            if (nGuessLangPara == LANGUAGE_NONE)
-                nGuessLangPara = nGuessLangWord;
-
-            aPopupMenu->InsertSeparator();
-            OUString aTmpWord( SvtLanguageTable::GetLanguageString( nGuessLangWord ) );
-            OUString aTmpPara( SvtLanguageTable::GetLanguageString( nGuessLangPara ) );
-            OUString aWordStr( EditResId( RID_STR_WORD ) );
-            aWordStr = aWordStr.replaceFirst( "%x", aTmpWord );
-            OUString aParaStr( EditResId( RID_STR_PARAGRAPH ) );
-            aParaStr = aParaStr.replaceFirst( "%x", aTmpPara );
-            aPopupMenu->InsertItem( MN_WORDLANGUAGE, aWordStr );
-            aPopupMenu->SetHelpId( MN_WORDLANGUAGE, HID_EDITENG_SPELLER_WORDLANGUAGE );
-            aPopupMenu->InsertItem( MN_PARALANGUAGE, aParaStr );
-            aPopupMenu->SetHelpId( MN_PARALANGUAGE, HID_EDITENG_SPELLER_PARALANGUAGE );
+            OSL_FAIL( "content node is NULL" );
         }
 
-        // ## Create mnemonics here
-        aPopupMenu->CreateAutoMnemonics();
-        aPopupMenu->SetMenuFlags(aPopupMenu->GetMenuFlags() | MenuFlags::NoAutoMnemonics);
-
-        // Replace suggestions...
-        Sequence< OUString > aAlt;
-        if (xSpellAlt.is())
-            aAlt = xSpellAlt->getAlternatives();
-        const OUString *pAlt = aAlt.getConstArray();
-        sal_uInt16 nWords = static_cast<sal_uInt16>(aAlt.getLength());
-        if ( nWords )
+        nGuessLangWord = CheckLanguage( xSpellAlt->getWord(), xSpeller, xLangGuesser, false );
+        nGuessLangPara = CheckLanguage( aParaText, xSpeller, xLangGuesser, true );
+    }
+    if (nGuessLangWord != LANGUAGE_NONE || nGuessLangPara != LANGUAGE_NONE)
+    {
+        // make sure LANGUAGE_NONE gets not used as menu entry
+        if (nGuessLangWord == LANGUAGE_NONE)
+            nGuessLangWord = nGuessLangPara;
+        if (nGuessLangPara == LANGUAGE_NONE)
+            nGuessLangPara = nGuessLangWord;
+
+        aPopupMenu->InsertSeparator();
+        OUString aTmpWord( SvtLanguageTable::GetLanguageString( nGuessLangWord ) );
+        OUString aTmpPara( SvtLanguageTable::GetLanguageString( nGuessLangPara ) );
+        OUString aWordStr( EditResId( RID_STR_WORD ) );
+        aWordStr = aWordStr.replaceFirst( "%x", aTmpWord );
+        OUString aParaStr( EditResId( RID_STR_PARAGRAPH ) );
+        aParaStr = aParaStr.replaceFirst( "%x", aTmpPara );
+        aPopupMenu->InsertItem( MN_WORDLANGUAGE, aWordStr );
+        aPopupMenu->SetHelpId( MN_WORDLANGUAGE, HID_EDITENG_SPELLER_WORDLANGUAGE );
+        aPopupMenu->InsertItem( MN_PARALANGUAGE, aParaStr );
+        aPopupMenu->SetHelpId( MN_PARALANGUAGE, HID_EDITENG_SPELLER_PARALANGUAGE );
+    }
+
+    // ## Create mnemonics here
+    aPopupMenu->CreateAutoMnemonics();
+    aPopupMenu->SetMenuFlags(aPopupMenu->GetMenuFlags() | MenuFlags::NoAutoMnemonics);
+
+    // Replace suggestions...
+    Sequence< OUString > aAlt;
+    if (xSpellAlt.is())
+        aAlt = xSpellAlt->getAlternatives();
+    const OUString *pAlt = aAlt.getConstArray();
+    sal_uInt16 nWords = static_cast<sal_uInt16>(aAlt.getLength());
+    if ( nWords )
+    {
+        for ( sal_uInt16 nW = 0; nW < nWords; nW++ )
         {
-            for ( sal_uInt16 nW = 0; nW < nWords; nW++ )
-            {
-                OUString aAlternate( pAlt[nW] );
-                aPopupMenu->InsertItem( MN_ALTSTART+nW, aAlternate, MenuItemBits::NONE, OString(), nW );
-                pAutoMenu->InsertItem( MN_AUTOSTART+nW, aAlternate, MenuItemBits::NONE, OString(), nW );
-            }
-            aPopupMenu->InsertSeparator(OString(), nWords);
+            OUString aAlternate( pAlt[nW] );
+            aPopupMenu->InsertItem( MN_ALTSTART+nW, aAlternate, MenuItemBits::NONE, OString(), nW );
+            pAutoMenu->InsertItem( MN_AUTOSTART+nW, aAlternate, MenuItemBits::NONE, OString(), nW );
         }
-        else
-            aPopupMenu->RemoveItem(nAutoCorrId);   // delete?
+        aPopupMenu->InsertSeparator(OString(), nWords);
+    }
+    else
+        aPopupMenu->RemoveItem(nAutoCorrId);   // delete?
 
-        SvtLinguConfig aCfg;
+    SvtLinguConfig aCfg;
 
-        Reference< linguistic2::XSearchableDictionaryList >  xDicList( LinguMgr::GetDictionaryList() );
-        Sequence< Reference< linguistic2::XDictionary >  > aDics;
-        if (xDicList.is())
+    Reference< linguistic2::XSearchableDictionaryList >  xDicList( LinguMgr::GetDictionaryList() );
+    Sequence< Reference< linguistic2::XDictionary >  > aDics;
+    if (xDicList.is())
+    {
+        const Reference< linguistic2::XDictionary >  *pDic = nullptr;
+        // add the default positive dictionary to dic-list (if not already done).
+        // This is to ensure that there is at least one dictionary to which
+        // words could be added.
+        uno::Reference< linguistic2::XDictionary >  xDic( LinguMgr::GetStandardDic() );
+        if (xDic.is())
+            xDic->setActive( true );
+
+        aDics = xDicList->getDictionaries();
+        pDic  = aDics.getConstArray();
+        LanguageType nCheckedLanguage = pImpEditView->pEditEngine->pImpEditEngine->GetLanguage( aPaM2 );
+        sal_uInt16 nDicCount = static_cast<sal_uInt16>(aDics.getLength());
+        for (sal_uInt16 i = 0; i < nDicCount; i++)
         {
-            const Reference< linguistic2::XDictionary >  *pDic = nullptr;
-            // add the default positive dictionary to dic-list (if not already done).
-            // This is to ensure that there is at least one dictionary to which
-            // words could be added.
-            uno::Reference< linguistic2::XDictionary >  xDic( LinguMgr::GetStandardDic() );
-            if (xDic.is())
-                xDic->setActive( true );
-
-            aDics = xDicList->getDictionaries();
-            pDic  = aDics.getConstArray();
-            LanguageType nCheckedLanguage = pImpEditView->pEditEngine->pImpEditEngine->GetLanguage( aPaM2 );
-            sal_uInt16 nDicCount = static_cast<sal_uInt16>(aDics.getLength());
-            for (sal_uInt16 i = 0; i < nDicCount; i++)
+            uno::Reference< linguistic2::XDictionary >  xDicTmp = pDic[i];
+            if (!xDicTmp.is() || LinguMgr::GetIgnoreAllList() == xDicTmp)
+                continue;
+
+            uno::Reference< frame::XStorable > xStor( xDicTmp, uno::UNO_QUERY );
+            LanguageType nActLanguage = LanguageTag( xDicTmp->getLocale() ).getLanguageType();
+            if( xDicTmp->isActive()
+                &&  xDicTmp->getDictionaryType() != linguistic2::DictionaryType_NEGATIVE
+                && (nCheckedLanguage == nActLanguage || LANGUAGE_NONE == nActLanguage )
+                && (!xStor.is() || !xStor->isReadonly()) )
             {
-                uno::Reference< linguistic2::XDictionary >  xDicTmp = pDic[i];
-                if (!xDicTmp.is() || LinguMgr::GetIgnoreAllList() == xDicTmp)
-                    continue;
-
-                uno::Reference< frame::XStorable > xStor( xDicTmp, uno::UNO_QUERY );
-                LanguageType nActLanguage = LanguageTag( xDicTmp->getLocale() ).getLanguageType();
-                if( xDicTmp->isActive()
-                    &&  xDicTmp->getDictionaryType() != linguistic2::DictionaryType_NEGATIVE
-                    && (nCheckedLanguage == nActLanguage || LANGUAGE_NONE == nActLanguage )
-                    && (!xStor.is() || !xStor->isReadonly()) )
+                // the extra 1 is because of the (possible) external
+                // linguistic entry above
+                sal_uInt16 nPos = MN_DICTSTART + i;
+                pInsertMenu->InsertItem( nPos, xDicTmp->getName() );
+                aDicNameSingle = xDicTmp->getName();
+
+                uno::Reference< lang::XServiceInfo > xSvcInfo( xDicTmp, uno::UNO_QUERY );
+                if (xSvcInfo.is())
                 {
-                    // the extra 1 is because of the (possible) external
-                    // linguistic entry above
-                    sal_uInt16 nPos = MN_DICTSTART + i;
-                    pInsertMenu->InsertItem( nPos, xDicTmp->getName() );
-                    aDicNameSingle = xDicTmp->getName();
-
-                    uno::Reference< lang::XServiceInfo > xSvcInfo( xDicTmp, uno::UNO_QUERY );
-                    if (xSvcInfo.is())
+                    OUString aDictionaryImageUrl( aCfg.GetSpellAndGrammarContextDictionaryImage(
+                            xSvcInfo->getImplementationName()) );
+                    if (!aDictionaryImageUrl.isEmpty() )
                     {
-                        OUString aDictionaryImageUrl( aCfg.GetSpellAndGrammarContextDictionaryImage(
-                                xSvcInfo->getImplementationName()) );
-                        if (!aDictionaryImageUrl.isEmpty() )
-                        {
-                            Image aImage( aDictionaryImageUrl );
-                            pInsertMenu->SetItemImage( nPos, aImage );
-                        }
+                        Image aImage( aDictionaryImageUrl );
+                        pInsertMenu->SetItemImage( nPos, aImage );
                     }
                 }
             }
         }
+    }
 
-        if (pInsertMenu->GetItemCount() != 1)
-            aPopupMenu->EnableItem(nAddId, false);
-        if (pInsertMenu->GetItemCount() < 2)
-            aPopupMenu->EnableItem(nInsertId, false);
+    if (pInsertMenu->GetItemCount() != 1)
+        aPopupMenu->EnableItem(nAddId, false);
+    if (pInsertMenu->GetItemCount() < 2)
+        aPopupMenu->EnableItem(nInsertId, false);
 
-        aPopupMenu->RemoveDisabledEntries( true, true );
+    aPopupMenu->RemoveDisabledEntries( true, true );
 
-        tools::Rectangle aTempRect = pImpEditView->pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, GetCursorFlags::TextOnly );
-        Point aScreenPos = pImpEditView->GetWindowPos( aTempRect.TopLeft() );
-        aScreenPos = pImpEditView->GetWindow()->OutputToScreenPixel( aScreenPos );
-        aTempRect = pImpEditView->GetWindow()->LogicToPixel( tools::Rectangle(aScreenPos, aTempRect.GetSize() ));
+    tools::Rectangle aTempRect = pImpEditView->pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, GetCursorFlags::TextOnly );
+    Point aScreenPos = pImpEditView->GetWindowPos( aTempRect.TopLeft() );
+    aScreenPos = pImpEditView->GetWindow()->OutputToScreenPixel( aScreenPos );
+    aTempRect = pImpEditView->GetWindow()->LogicToPixel( tools::Rectangle(aScreenPos, aTempRect.GetSize() ));
 
-        //tdf#106123 store and restore the EditPaM around the menu Execute
-        //because the loss of focus in the current editeng causes writer
-        //annotations to save their contents, making the pContent of the
-        //current EditPams invalid
-        EPaM aP = pImpEditView->pEditEngine->pImpEditEngine->CreateEPaM(aPaM);
-        EPaM aP2 = pImpEditView->pEditEngine->pImpEditEngine->CreateEPaM(aPaM2);
+    //tdf#106123 store and restore the EditPaM around the menu Execute
+    //because the loss of focus in the current editeng causes writer
+    //annotations to save their contents, making the pContent of the
+    //current EditPams invalid
+    EPaM aP = pImpEditView->pEditEngine->pImpEditEngine->CreateEPaM(aPaM);
+    EPaM aP2 = pImpEditView->pEditEngine->pImpEditEngine->CreateEPaM(aPaM2);
 
 
-        if (comphelper::LibreOfficeKit::isActive())
+    if (comphelper::LibreOfficeKit::isActive())
+    {
+        // For mobile phones, send the context menu structure
+        if (comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView()))
         {
-            // For mobile phones, send the context menu structure
-            if (comphelper::LibreOfficeKit::isMobilePhone(SfxLokHelper::getView()))
-            {
-                LOKSendSpellPopupMenu(aPopupMenu, nGuessLangWord, nGuessLangPara, nWords);
-                return;
-            }
-            else // For desktop and tablets, we use the tunneled dialog
-                aPopupMenu->SetLOKNotifier(SfxViewShell::Current());
+            LOKSendSpellPopupMenu(aPopupMenu, nGuessLangWord, nGuessLangPara, nWords);
+            return;
         }
-        sal_uInt16 nId = aPopupMenu->Execute(pImpEditView->GetWindow(), aTempRect, PopupMenuFlags::NoMouseUpClose);
+        else // For desktop and tablets, we use the tunneled dialog
+            aPopupMenu->SetLOKNotifier(SfxViewShell::Current());
+    }
+    sal_uInt16 nId = aPopupMenu->Execute(pImpEditView->GetWindow(), aTempRect, PopupMenuFlags::NoMouseUpClose);
 
-        aPaM2 = pImpEditView->pEditEngine->pImpEditEngine->CreateEditPaM(aP2);
-        aPaM = pImpEditView->pEditEngine->pImpEditEngine->CreateEditPaM(aP);
+    aPaM2 = pImpEditView->pEditEngine->pImpEditEngine->CreateEditPaM(aP2);
+    aPaM = pImpEditView->pEditEngine->pImpEditEngine->CreateEditPaM(aP);
 
-        if (nId == nIgnoreId)
-        {
-            OUString aWord = pImpEditView->SpellIgnoreWord();
-            if ( pCallBack )
-            {
-                SpellCallbackInfo aInf( SpellCallbackCommand::IGNOREWORD, aWord );
-                pCallBack->Call( aInf );
-            }
-            SetSelection( aOldSel );
-        }
-        else if ( ( nId == MN_WORDLANGUAGE ) || ( nId == MN_PARALANGUAGE ) )
+    if (nId == nIgnoreId)
+    {
+        OUString aWord = pImpEditView->SpellIgnoreWord();
+        if ( pCallBack )
         {
-            LanguageType nLangToUse = (nId == MN_WORDLANGUAGE) ? nGuessLangWord : nGuessLangPara;
-            SvtScriptType nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nLangToUse );
-
-            SfxItemSet aAttrs = GetEditEngine()->GetEmptyItemSet();
-            if (nScriptType == SvtScriptType::LATIN)
-                aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE ) );
-            if (nScriptType == SvtScriptType::COMPLEX)
-                aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE_CTL ) );
-            if (nScriptType == SvtScriptType::ASIAN)
-                aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE_CJK ) );
-            if ( nId == MN_PARALANGUAGE )
-            {
-                ESelection aSel = GetSelection();
-                aSel.nStartPos = 0;
-                aSel.nEndPos = EE_TEXTPOS_ALL;
-                SetSelection( aSel );
-            }
-            SetAttribs( aAttrs );
-            pImpEditView->pEditEngine->pImpEditEngine->StartOnlineSpellTimer();
-
-            if ( pCallBack )
-            {
-                SpellCallbackInfo aInf( ( nId == MN_WORDLANGUAGE ) ? SpellCallbackCommand::WORDLANGUAGE : SpellCallbackCommand::PARALANGUAGE );
-                pCallBack->Call( aInf );
-            }
-            SetSelection( aOldSel );
+            SpellCallbackInfo aInf( SpellCallbackCommand::IGNOREWORD, aWord );
+            pCallBack->Call( aInf );
         }
-        else if (nId == nCheckId)
+        SetSelection( aOldSel );
+    }
+    else if ( ( nId == MN_WORDLANGUAGE ) || ( nId == MN_PARALANGUAGE ) )
+    {
+        LanguageType nLangToUse = (nId == MN_WORDLANGUAGE) ? nGuessLangWord : nGuessLangPara;
+        SvtScriptType nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nLangToUse );
+
+        SfxItemSet aAttrs = GetEditEngine()->GetEmptyItemSet();
+        if (nScriptType == SvtScriptType::LATIN)
+            aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE ) );
+        if (nScriptType == SvtScriptType::COMPLEX)
+            aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE_CTL ) );
+        if (nScriptType == SvtScriptType::ASIAN)
+            aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE_CJK ) );
+        if ( nId == MN_PARALANGUAGE )
         {
-            if ( !pCallBack )
-            {
-                // Set Cursor before word...
-                EditPaM aCursor = pImpEditView->GetEditSelection().Min();
-                pImpEditView->DrawSelectionXOR();
-                pImpEditView->SetEditSelection( EditSelection( aCursor, aCursor ) );
-                pImpEditView->DrawSelectionXOR();
-                // Crashes when no SfxApp
-                pImpEditView->pEditEngine->pImpEditEngine->Spell( this, false );
-            }
-            else
-            {
-                SpellCallbackInfo aInf( SpellCallbackCommand::STARTSPELLDLG, OUString() );
-                pCallBack->Call( aInf );
-            }
+            ESelection aSel = GetSelection();
+            aSel.nStartPos = 0;
+            aSel.nEndPos = EE_TEXTPOS_ALL;
+            SetSelection( aSel );
         }
-        else if (nId == nAutoCorrectDlgId && pCallBack)
+        SetAttribs( aAttrs );
+        pImpEditView->pEditEngine->pImpEditEngine->StartOnlineSpellTimer();
+
+        if ( pCallBack )
         {
-            SpellCallbackInfo aInf( SpellCallbackCommand::AUTOCORRECT_OPTIONS, OUString() );
+            SpellCallbackInfo aInf( ( nId == MN_WORDLANGUAGE ) ? SpellCallbackCommand::WORDLANGUAGE : SpellCallbackCommand::PARALANGUAGE );
             pCallBack->Call( aInf );
         }
-        else if ( nId >= MN_DICTSTART || nId == nAddId)
-        {
-            OUString aDicName;
-            if (nId >= MN_DICTSTART)
-                aDicName = pInsertMenu->GetItemText(nId);
-            else
-                aDicName = aDicNameSingle;
-
-            uno::Reference< linguistic2::XDictionary >      xDic;
-            if (xDicList.is())
-                xDic = xDicList->getDictionaryByName( aDicName );
-
-            if (xDic.is())
-                xDic->add( aSelected, false, OUString() );
-            // save modified user-dictionary if it is persistent
-            Reference< frame::XStorable >  xSavDic( xDic, UNO_QUERY );
-            if (xSavDic.is())
-                xSavDic->store();
-
-            aPaM.GetNode()->GetWrongList()->ResetInvalidRange(0, aPaM.GetNode()->Len());
-            pImpEditView->pEditEngine->pImpEditEngine->StartOnlineSpellTimer();
-
-            if ( pCallBack )
-            {
-                SpellCallbackInfo aInf( SpellCallbackCommand::ADDTODICTIONARY, aSelected );
-                pCallBack->Call( aInf );
-            }
-            SetSelection( aOldSel );
-        }
-        else if ( nId >= MN_AUTOSTART )
+        SetSelection( aOldSel );
+    }
+    else if (nId == nCheckId)
+    {
+        if ( !pCallBack )
         {
-            DBG_ASSERT(nId - MN_AUTOSTART < aAlt.getLength(), "index out of range");
-            OUString aWord = pAlt[nId - MN_AUTOSTART];
-            SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
-            if ( pAutoCorrect )
-                pAutoCorrect->PutText( aSelected, aWord, pImpEditView->pEditEngine->pImpEditEngine->GetLanguage( aPaM2 ) );
-            InsertText( aWord );
+            // Set Cursor before word...
+            EditPaM aCursor = pImpEditView->GetEditSelection().Min();
+            pImpEditView->DrawSelectionXOR();
+            pImpEditView->SetEditSelection( EditSelection( aCursor, aCursor ) );
+            pImpEditView->DrawSelectionXOR();
+            // Crashes when no SfxApp
+            pImpEditView->pEditEngine->pImpEditEngine->Spell( this, false );
         }
-        else if ( nId >= MN_ALTSTART )  // Replace
+        else
         {
-            DBG_ASSERT(nId - MN_ALTSTART < aAlt.getLength(), "index out of range");
-            OUString aWord = pAlt[nId - MN_ALTSTART];
-            InsertText( aWord );
+            SpellCallbackInfo aInf( SpellCallbackCommand::STARTSPELLDLG, OUString() );
+            pCallBack->Call( aInf );
         }
+    }
+    else if (nId == nAutoCorrectDlgId && pCallBack)
+    {
+        SpellCallbackInfo aInf( SpellCallbackCommand::AUTOCORRECT_OPTIONS, OUString() );
+        pCallBack->Call( aInf );
+    }
+    else if ( nId >= MN_DICTSTART || nId == nAddId)
+    {
+        OUString aDicName;
+        if (nId >= MN_DICTSTART)
+            aDicName = pInsertMenu->GetItemText(nId);
         else
+            aDicName = aDicNameSingle;
+
+        uno::Reference< linguistic2::XDictionary >      xDic;
+        if (xDicList.is())
+            xDic = xDicList->getDictionaryByName( aDicName );
+
+        if (xDic.is())
+            xDic->add( aSelected, false, OUString() );
+        // save modified user-dictionary if it is persistent
+        Reference< frame::XStorable >  xSavDic( xDic, UNO_QUERY );
+        if (xSavDic.is())
+            xSavDic->store();
+
+        aPaM.GetNode()->GetWrongList()->ResetInvalidRange(0, aPaM.GetNode()->Len());
+        pImpEditView->pEditEngine->pImpEditEngine->StartOnlineSpellTimer();
+
+        if ( pCallBack )
         {
-            SetSelection( aOldSel );
+            SpellCallbackInfo aInf( SpellCallbackCommand::ADDTODICTIONARY, aSelected );
+            pCallBack->Call( aInf );
         }
+        SetSelection( aOldSel );
+    }
+    else if ( nId >= MN_AUTOSTART )
+    {
+        DBG_ASSERT(nId - MN_AUTOSTART < aAlt.getLength(), "index out of range");
+        OUString aWord = pAlt[nId - MN_AUTOSTART];
+        SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
+        if ( pAutoCorrect )
+            pAutoCorrect->PutText( aSelected, aWord, pImpEditView->pEditEngine->pImpEditEngine->GetLanguage( aPaM2 ) );
+        InsertText( aWord );
+    }
+    else if ( nId >= MN_ALTSTART )  // Replace
+    {
+        DBG_ASSERT(nId - MN_ALTSTART < aAlt.getLength(), "index out of range");
+        OUString aWord = pAlt[nId - MN_ALTSTART];
+        InsertText( aWord );
+    }
+    else
+    {
+        SetSelection( aOldSel );
     }
 }
 
diff --git a/editeng/source/editeng/eehtml.cxx b/editeng/source/editeng/eehtml.cxx
index 39fbbb7aa221..ff84bfe4a260 100644
--- a/editeng/source/editeng/eehtml.cxx
+++ b/editeng/source/editeng/eehtml.cxx
@@ -742,48 +742,48 @@ bool EditHTMLParser::HasTextInCurrentPara()
 void EditHTMLParser::AnchorStart()
 {
     // ignore anchor in anchor
-    if ( !pCurAnchor )
+    if ( pCurAnchor )
+        return;
+
+    const HTMLOptions& aOptions = GetOptions();
+    OUString aRef;
+
+    for (const auto & aOption : aOptions)
     {
-        const HTMLOptions& aOptions = GetOptions();
-        OUString aRef;
+        if( aOption.GetToken() == HtmlOptionId::HREF)
+            aRef = aOption.GetString();
+    }
 
-        for (const auto & aOption : aOptions)
-        {
-            if( aOption.GetToken() == HtmlOptionId::HREF)
-                aRef = aOption.GetString();
-        }
+    if ( aRef.isEmpty() )
+        return;
 
-        if ( !aRef.isEmpty() )
-        {
-            OUString aURL = aRef;
-            if ( !aURL.isEmpty() && ( aURL[ 0 ] != '#' ) )
-            {
-                INetURLObject aTargetURL;
-                INetURLObject aRootURL( aBaseURL );
-                aRootURL.GetNewAbsURL( aRef, &aTargetURL );
-                aURL = aTargetURL.GetMainURL( INetURLObject::DecodeMechanism::ToIUri );
-            }
-            pCurAnchor.reset( new AnchorInfo );
-            pCurAnchor->aHRef = aURL;
-        }
+    OUString aURL = aRef;
+    if ( !aURL.isEmpty() && ( aURL[ 0 ] != '#' ) )
+    {
+        INetURLObject aTargetURL;
+        INetURLObject aRootURL( aBaseURL );
+        aRootURL.GetNewAbsURL( aRef, &aTargetURL );
+        aURL = aTargetURL.GetMainURL( INetURLObject::DecodeMechanism::ToIUri );
     }
+    pCurAnchor.reset( new AnchorInfo );
+    pCurAnchor->aHRef = aURL;
 }
 
 void EditHTMLParser::AnchorEnd()
 {
-    if ( pCurAnchor )
-    {
-        // Insert as URL-Field...
-        SvxFieldItem aFld( SvxURLField( pCurAnchor->aHRef, pCurAnchor->aText, SvxURLFormat::Repr ), EE_FEATURE_FIELD  );
-        aCurSel = mpEditEngine->InsertField(aCurSel, aFld);
-        bFieldsInserted = true;
-        pCurAnchor.reset();
+    if ( !pCurAnchor )
+        return;
 
-        if (mpEditEngine->IsHtmlImportHandlerSet())
-        {
-            HtmlImportInfo aImportInfo(HtmlImportState::InsertField, this, mpEditEngine->CreateESelection(aCurSel));
-            mpEditEngine->CallHtmlImportHandler(aImportInfo);
-        }
+    // Insert as URL-Field...
+    SvxFieldItem aFld( SvxURLField( pCurAnchor->aHRef, pCurAnchor->aText, SvxURLFormat::Repr ), EE_FEATURE_FIELD  );
+    aCurSel = mpEditEngine->InsertField(aCurSel, aFld);
+    bFieldsInserted = true;
+    pCurAnchor.reset();
+
+    if (mpEditEngine->IsHtmlImportHandlerSet())
+    {
+        HtmlImportInfo aImportInfo(HtmlImportState::InsertField, this, mpEditEngine->CreateESelection(aCurSel));
+        mpEditEngine->CallHtmlImportHandler(aImportInfo);
     }
 }
 
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 7616a6dc9ae7..e0ee7a52b24d 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -160,26 +160,26 @@ static void lcl_translateTwips(vcl::Window const & rParent, vcl::Window& rChild)
     // This prevents multiple translate calls that negate
     // one another.
     const Point aOrigin = rChild.GetMapMode().GetOrigin();
-    if (aOrigin.getX() == 0 && aOrigin.getY() == 0)
+    if (!(aOrigin.getX() == 0 && aOrigin.getY() == 0))
+        return;
+
+    // Set map mode, so that callback payloads will contain absolute coordinates instead of relative ones.
+    Point aOffset(rChild.GetOutOffXPixel() - rParent.GetOutOffXPixel(), rChild.GetOutOffYPixel() - rParent.GetOutOffYPixel());
+    if (!rChild.IsMapModeEnabled())
     {
-        // Set map mode, so that callback payloads will contain absolute coordinates instead of relative ones.
-        Point aOffset(rChild.GetOutOffXPixel() - rParent.GetOutOffXPixel(), rChild.GetOutOffYPixel() - rParent.GetOutOffYPixel());
-        if (!rChild.IsMapModeEnabled())
-        {
-            MapMode aMapMode(rChild.GetMapMode());
-            aMapMode.SetMapUnit(MapUnit::MapTwip);
-            aMapMode.SetScaleX(rParent.GetMapMode().GetScaleX());
-            aMapMode.SetScaleY(rParent.GetMapMode().GetScaleY());
-            rChild.SetMapMode(aMapMode);
-            rChild.EnableMapMode();
-        }
-        aOffset = rChild.PixelToLogic(aOffset);
         MapMode aMapMode(rChild.GetMapMode());
-        aMapMode.SetOrigin(aOffset);
-        aMapMode.SetMapUnit(rParent.GetMapMode().GetMapUnit());
+        aMapMode.SetMapUnit(MapUnit::MapTwip);
+        aMapMode.SetScaleX(rParent.GetMapMode().GetScaleX());
+        aMapMode.SetScaleY(rParent.GetMapMode().GetScaleY());
         rChild.SetMapMode(aMapMode);
-        rChild.EnableMapMode(false);
-    }
+        rChild.EnableMapMode();
+    }
+    aOffset = rChild.PixelToLogic(aOffset);
+    MapMode aMapMode(rChild.GetMapMode());
+    aMapMode.SetOrigin(aOffset);
+    aMapMode.SetMapUnit(rParent.GetMapMode().GetMapUnit());
+    rChild.SetMapMode(aMapMode);
+    rChild.EnableMapMode(false);
 }
 
 // EditView never had a central/secure place to react on SelectionChange since
@@ -524,51 +524,51 @@ void ImpEditView::GetSelectionRectangles(EditSelection aTmpSel, std::vector<tool
 
 void ImpEditView::ImplDrawHighlightRect( OutputDevice* _pTarget, const Point& rDocPosTopLeft, const Point& rDocPosBottomRight, tools::PolyPolygon* pPolyPoly )
 {
-    if ( rDocPosTopLeft.X() != rDocPosBottomRight.X() )
-    {
-        bool bPixelMode = _pTarget->GetMapMode().GetMapUnit() == MapUnit::MapPixel;
+    if ( rDocPosTopLeft.X() == rDocPosBottomRight.X() )
+        return;
 
-        Point aPnt1( GetWindowPos( rDocPosTopLeft ) );
-        Point aPnt2( GetWindowPos( rDocPosBottomRight ) );
+    bool bPixelMode = _pTarget->GetMapMode().GetMapUnit() == MapUnit::MapPixel;
 
-        if ( !IsVertical() )
-        {
-            lcl_AllignToPixel( aPnt1, _pTarget, +1, 0 );
-            lcl_AllignToPixel( aPnt2, _pTarget, 0, ( bPixelMode ? 0 : -1 ) );
-        }
-        else
-        {
-            lcl_AllignToPixel( aPnt1, _pTarget, 0, +1 );
-            lcl_AllignToPixel( aPnt2, _pTarget, ( bPixelMode ? 0 : +1 ), 0 );
-        }
+    Point aPnt1( GetWindowPos( rDocPosTopLeft ) );
+    Point aPnt2( GetWindowPos( rDocPosBottomRight ) );
+
+    if ( !IsVertical() )
+    {
+        lcl_AllignToPixel( aPnt1, _pTarget, +1, 0 );
+        lcl_AllignToPixel( aPnt2, _pTarget, 0, ( bPixelMode ? 0 : -1 ) );
+    }
+    else
+    {
+        lcl_AllignToPixel( aPnt1, _pTarget, 0, +1 );
+        lcl_AllignToPixel( aPnt2, _pTarget, ( bPixelMode ? 0 : +1 ), 0 );
+    }
 
-        tools::Rectangle aRect( aPnt1, aPnt2 );
-        if ( pPolyPoly )
+    tools::Rectangle aRect( aPnt1, aPnt2 );
+    if ( pPolyPoly )
+    {
+        tools::Polygon aTmpPoly( 4 );
+        aTmpPoly[0] = aRect.TopLeft();
+        aTmpPoly[1] = aRect.TopRight();
+        aTmpPoly[2] = aRect.BottomRight();
+        aTmpPoly[3] = aRect.BottomLeft();
+        pPolyPoly->Insert( aTmpPoly );
+    }
+    else
+    {
+        vcl::Window* pWindow = dynamic_cast< vcl::Window* >(_pTarget);
+
+        if(pWindow)
         {
-            tools::Polygon aTmpPoly( 4 );
-            aTmpPoly[0] = aRect.TopLeft();
-            aTmpPoly[1] = aRect.TopRight();
-            aTmpPoly[2] = aRect.BottomRight();
-            aTmpPoly[3] = aRect.BottomLeft();
-            pPolyPoly->Insert( aTmpPoly );
+            pWindow->Invert( aRect );
         }
         else
         {
-            vcl::Window* pWindow = dynamic_cast< vcl::Window* >(_pTarget);
-
-            if(pWindow)
-            {
-                pWindow->Invert( aRect );
-            }
-            else
-            {
-                _pTarget->Push(PushFlags::LINECOLOR|PushFlags::FILLCOLOR|PushFlags::RASTEROP);
-                _pTarget->SetLineColor();
-                _pTarget->SetFillColor(COL_BLACK);
-                _pTarget->SetRasterOp(RasterOp::Invert);
-                _pTarget->DrawRect(aRect);
-                _pTarget->Pop();
-            }
+            _pTarget->Push(PushFlags::LINECOLOR|PushFlags::FILLCOLOR|PushFlags::RASTEROP);
+            _pTarget->SetLineColor();
+            _pTarget->SetFillColor(COL_BLACK);
+            _pTarget->SetRasterOp(RasterOp::Invert);
+            _pTarget->DrawRect(aRect);
+            _pTarget->Pop();
         }
     }
 }
@@ -713,54 +713,54 @@ void ImpEditView::ResetOutputArea( const tools::Rectangle& rRect )
     SetOutputArea(rRect);
 
     // invalidate surrounding areas if update is true
-    if(!aOldArea.IsEmpty() && pEditEngine->pImpEditEngine->GetUpdateMode())
-    {
-        // #i119885# use grown area if needed; do when getting bigger OR smaller
-        const sal_Int32 nMore(DoInvalidateMore() ? GetWindow()->PixelToLogic(Size(nInvMore, 0)).Width() : 0);
+    if(!(!aOldArea.IsEmpty() && pEditEngine->pImpEditEngine->GetUpdateMode()))
+        return;
 
-        if(aOldArea.Left() > aOutArea.Left())
-        {
-            const tools::Rectangle aRect(aOutArea.Left() - nMore, aOldArea.Top() - nMore, aOldArea.Left(), aOldArea.Bottom() + nMore);
-            InvalidateAtWindow(aRect);
-        }
-        else if(aOldArea.Left() < aOutArea.Left())
-        {
-            const tools::Rectangle aRect(aOldArea.Left() - nMore, aOldArea.Top() - nMore, aOutArea.Left(), aOldArea.Bottom() + nMore);
-            InvalidateAtWindow(aRect);
-        }
+    // #i119885# use grown area if needed; do when getting bigger OR smaller
+    const sal_Int32 nMore(DoInvalidateMore() ? GetWindow()->PixelToLogic(Size(nInvMore, 0)).Width() : 0);
 
-        if(aOldArea.Right() > aOutArea.Right())
-        {
-            const tools::Rectangle aRect(aOutArea.Right(), aOldArea.Top() - nMore, aOldArea.Right() + nMore, aOldArea.Bottom() + nMore);
-            InvalidateAtWindow(aRect);
-        }
-        else if(aOldArea.Right() < aOutArea.Right())
-        {
-            const tools::Rectangle aRect(aOldArea.Right(), aOldArea.Top() - nMore, aOutArea.Right() + nMore, aOldArea.Bottom() + nMore);
-            InvalidateAtWindow(aRect);
-        }
+    if(aOldArea.Left() > aOutArea.Left())
+    {
+        const tools::Rectangle aRect(aOutArea.Left() - nMore, aOldArea.Top() - nMore, aOldArea.Left(), aOldArea.Bottom() + nMore);
+        InvalidateAtWindow(aRect);
+    }
+    else if(aOldArea.Left() < aOutArea.Left())
+    {
+        const tools::Rectangle aRect(aOldArea.Left() - nMore, aOldArea.Top() - nMore, aOutArea.Left(), aOldArea.Bottom() + nMore);
+        InvalidateAtWindow(aRect);
+    }
 
-        if(aOldArea.Top() > aOutArea.Top())
-        {
-            const tools::Rectangle aRect(aOldArea.Left() - nMore, aOutArea.Top() - nMore, aOldArea.Right() + nMore, aOldArea.Top());
-            InvalidateAtWindow(aRect);
-        }
-        else if(aOldArea.Top() < aOutArea.Top())
-        {
-            const tools::Rectangle aRect(aOldArea.Left() - nMore, aOldArea.Top() - nMore, aOldArea.Right() + nMore, aOutArea.Top());
-            InvalidateAtWindow(aRect);
-        }
+    if(aOldArea.Right() > aOutArea.Right())
+    {
+        const tools::Rectangle aRect(aOutArea.Right(), aOldArea.Top() - nMore, aOldArea.Right() + nMore, aOldArea.Bottom() + nMore);
+        InvalidateAtWindow(aRect);
+    }
+    else if(aOldArea.Right() < aOutArea.Right())
+    {
+        const tools::Rectangle aRect(aOldArea.Right(), aOldArea.Top() - nMore, aOutArea.Right() + nMore, aOldArea.Bottom() + nMore);
+        InvalidateAtWindow(aRect);
+    }
 
-        if(aOldArea.Bottom() > aOutArea.Bottom())
-        {
-            const tools::Rectangle aRect(aOldArea.Left() - nMore, aOutArea.Bottom(), aOldArea.Right() + nMore, aOldArea.Bottom() + nMore);
-            InvalidateAtWindow(aRect);
-        }
-        else if(aOldArea.Bottom() < aOutArea.Bottom())
-        {
-            const tools::Rectangle aRect(aOldArea.Left() - nMore, aOldArea.Bottom(), aOldArea.Right() + nMore, aOutArea.Bottom() + nMore);
-            InvalidateAtWindow(aRect);
-        }
+    if(aOldArea.Top() > aOutArea.Top())
+    {
+        const tools::Rectangle aRect(aOldArea.Left() - nMore, aOutArea.Top() - nMore, aOldArea.Right() + nMore, aOldArea.Top());
+        InvalidateAtWindow(aRect);
+    }
+    else if(aOldArea.Top() < aOutArea.Top())
+    {
+        const tools::Rectangle aRect(aOldArea.Left() - nMore, aOldArea.Top() - nMore, aOldArea.Right() + nMore, aOutArea.Top());
+        InvalidateAtWindow(aRect);
+    }
+
+    if(aOldArea.Bottom() > aOutArea.Bottom())
+    {
+        const tools::Rectangle aRect(aOldArea.Left() - nMore, aOutArea.Bottom(), aOldArea.Right() + nMore, aOldArea.Bottom() + nMore);
+        InvalidateAtWindow(aRect);
+    }
+    else if(aOldArea.Bottom() < aOutArea.Bottom())
+    {
+        const tools::Rectangle aRect(aOldArea.Left() - nMore, aOldArea.Bottom(), aOldArea.Right() + nMore, aOutArea.Bottom() + nMore);
+        InvalidateAtWindow(aRect);
     }
 }
 
@@ -1619,34 +1619,34 @@ bool ImpEditView::IsBulletArea( const Point& rPos, sal_Int32* pPara )
 
 void ImpEditView::CutCopy( css::uno::Reference< css::datatransfer::clipboard::XClipboard > const & rxClipboard, bool bCut )
 {
-    if ( rxClipboard.is() && HasSelection() )
-    {
-        uno::Reference<datatransfer::XTransferable> xData = pEditEngine->CreateTransferable( GetEditSelection() );
+    if ( !(rxClipboard.is() && HasSelection()) )
+        return;
 
-        {
-            SolarMutexReleaser aReleaser;
+    uno::Reference<datatransfer::XTransferable> xData = pEditEngine->CreateTransferable( GetEditSelection() );
 
-            try
-                {
-                    rxClipboard->setContents( xData, nullptr );
+    {
+        SolarMutexReleaser aReleaser;
 
-                    // #87756# FlushClipboard, but it would be better to become a TerminateListener to the Desktop and flush on demand...
-                    uno::Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( rxClipboard, uno::UNO_QUERY );
-                    if( xFlushableClipboard.is() )
-                        xFlushableClipboard->flushClipboard();
-                }
-            catch( const css::uno::Exception& )
-                {
-                }
+        try
+            {
+                rxClipboard->setContents( xData, nullptr );
 
-        }
+                // #87756# FlushClipboard, but it would be better to become a TerminateListener to the Desktop and flush on demand...
+                uno::Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( rxClipboard, uno::UNO_QUERY );
+                if( xFlushableClipboard.is() )
+                    xFlushableClipboard->flushClipboard();
+            }
+        catch( const css::uno::Exception& )
+            {
+            }
 
-        if (bCut)
-        {
-            pEditEngine->pImpEditEngine->UndoActionStart(EDITUNDO_CUT);
-            DeleteSelected();
-            pEditEngine->pImpEditEngine->UndoActionEnd();
-        }
+    }
+
+    if (bCut)
+    {
+        pEditEngine->pImpEditEngine->UndoActionStart(EDITUNDO_CUT);
+        DeleteSelected();
+        pEditEngine->pImpEditEngine->UndoActionEnd();
     }
 }
 
@@ -1870,56 +1870,56 @@ void ImpEditView::HideDDCursor()
 
 void ImpEditView::ShowDDCursor( const tools::Rectangle& rRect )
 {
-    if ( pDragAndDropInfo && !pDragAndDropInfo->bVisCursor )
-    {
-        if (pOutWin && pOutWin->GetCursor())
-            pOutWin->GetCursor()->Hide();
+    if ( !(pDragAndDropInfo && !pDragAndDropInfo->bVisCursor) )
+        return;
 
-        OutputDevice& rOutDev = getEditViewCallbacks() ? getEditViewCallbacks()->EditViewOutputDevice() : *GetWindow();
-        Color aOldFillColor = rOutDev.GetFillColor();
-        rOutDev.SetFillColor( Color(4210752) );    // GRAY BRUSH_50, OLDSV, change to DDCursor!
+    if (pOutWin && pOutWin->GetCursor())
+        pOutWin->GetCursor()->Hide();
+
+    OutputDevice& rOutDev = getEditViewCallbacks() ? getEditViewCallbacks()->EditViewOutputDevice() : *GetWindow();
+    Color aOldFillColor = rOutDev.GetFillColor();
+    rOutDev.SetFillColor( Color(4210752) );    // GRAY BRUSH_50, OLDSV, change to DDCursor!
 
-        // Save background ...
-        tools::Rectangle aSaveRect( rOutDev.LogicToPixel( rRect ) );
-        // prefer to save some more ...
-        aSaveRect.AdjustRight(1 );
-        aSaveRect.AdjustBottom(1 );
+    // Save background ...
+    tools::Rectangle aSaveRect( rOutDev.LogicToPixel( rRect ) );
+    // prefer to save some more ...
+    aSaveRect.AdjustRight(1 );
+    aSaveRect.AdjustBottom(1 );
 
 #ifdef DBG_UTIL
-        Size aNewSzPx( aSaveRect.GetSize() );
+    Size aNewSzPx( aSaveRect.GetSize() );
 #endif
-        if ( !pDragAndDropInfo->pBackground )
-        {
-            pDragAndDropInfo->pBackground = VclPtr<VirtualDevice>::Create(rOutDev);
-            MapMode aMapMode( rOutDev.GetMapMode() );
-            aMapMode.SetOrigin( Point( 0, 0 ) );
-            pDragAndDropInfo->pBackground->SetMapMode( aMapMode );
+    if ( !pDragAndDropInfo->pBackground )
+    {
+        pDragAndDropInfo->pBackground = VclPtr<VirtualDevice>::Create(rOutDev);
+        MapMode aMapMode( rOutDev.GetMapMode() );
+        aMapMode.SetOrigin( Point( 0, 0 ) );
+        pDragAndDropInfo->pBackground->SetMapMode( aMapMode );
 
-        }
+    }
 
 #ifdef DBG_UTIL
-        Size aCurSzPx( pDragAndDropInfo->pBackground->GetOutputSizePixel() );
-        if ( ( aCurSzPx.Width() < aNewSzPx.Width() ) ||( aCurSzPx.Height() < aNewSzPx.Height() ) )
-        {
-            bool bDone = pDragAndDropInfo->pBackground->SetOutputSizePixel( aNewSzPx );
-            DBG_ASSERT( bDone, "Virtual Device broken?" );
-        }
+    Size aCurSzPx( pDragAndDropInfo->pBackground->GetOutputSizePixel() );
+    if ( ( aCurSzPx.Width() < aNewSzPx.Width() ) ||( aCurSzPx.Height() < aNewSzPx.Height() ) )
+    {
+        bool bDone = pDragAndDropInfo->pBackground->SetOutputSizePixel( aNewSzPx );
+        DBG_ASSERT( bDone, "Virtual Device broken?" );
+    }
 #endif
 
-        aSaveRect = rOutDev.PixelToLogic( aSaveRect );
+    aSaveRect = rOutDev.PixelToLogic( aSaveRect );
 
-        pDragAndDropInfo->pBackground->DrawOutDev( Point(0,0), aSaveRect.GetSize(),
-                                    aSaveRect.TopLeft(), aSaveRect.GetSize(), rOutDev );
-        pDragAndDropInfo->aCurSavedCursor = aSaveRect;
+    pDragAndDropInfo->pBackground->DrawOutDev( Point(0,0), aSaveRect.GetSize(),
+                                aSaveRect.TopLeft(), aSaveRect.GetSize(), rOutDev );
+    pDragAndDropInfo->aCurSavedCursor = aSaveRect;
 
-        // Draw Cursor...
-        rOutDev.DrawRect( rRect );
+    // Draw Cursor...
+    rOutDev.DrawRect( rRect );
 
-        pDragAndDropInfo->bVisCursor = true;
-        pDragAndDropInfo->aCurCursor = rRect;
+    pDragAndDropInfo->bVisCursor = true;
+    pDragAndDropInfo->aCurCursor = rRect;
 
-        rOutDev.SetFillColor( aOldFillColor );
-    }
+    rOutDev.SetFillColor( aOldFillColor );
 }
 
 void ImpEditView::dragGestureRecognized(const css::datatransfer::dnd::DragGestureEvent& rDGE)
@@ -1981,27 +1981,26 @@ void ImpEditView::dragGestureRecognized(const css::datatransfer::dnd::DragGestur
         }
     }
 
-    if ( pDragAndDropInfo )
-    {
+    if ( !pDragAndDropInfo )
+        return;
 
-        pDragAndDropInfo->bStarterOfDD = true;
 
-        // Sensitive area to be scrolled.
-        Size aSz( 5, 0 );
-        aSz = GetWindow()->PixelToLogic( aSz );
-        pDragAndDropInfo->nSensibleRange = static_cast<sal_uInt16>(aSz.Width());
-        pDragAndDropInfo->nCursorWidth = static_cast<sal_uInt16>(aSz.Width()) / 2;
-        pDragAndDropInfo->aBeginDragSel = pEditEngine->pImpEditEngine->CreateESel( aCopySel );
+    pDragAndDropInfo->bStarterOfDD = true;
 
-        uno::Reference<datatransfer::XTransferable> xData = pEditEngine->CreateTransferable(aCopySel);
+    // Sensitive area to be scrolled.
+    Size aSz( 5, 0 );
+    aSz = GetWindow()->PixelToLogic( aSz );
+    pDragAndDropInfo->nSensibleRange = static_cast<sal_uInt16>(aSz.Width());
+    pDragAndDropInfo->nCursorWidth = static_cast<sal_uInt16>(aSz.Width()) / 2;
+    pDragAndDropInfo->aBeginDragSel = pEditEngine->pImpEditEngine->CreateESel( aCopySel );
 
-        sal_Int8 nActions = bReadOnly ? datatransfer::dnd::DNDConstants::ACTION_COPY : datatransfer::dnd::DNDConstants::ACTION_COPY_OR_MOVE;
+    uno::Reference<datatransfer::XTransferable> xData = pEditEngine->CreateTransferable(aCopySel);
 
-        rDGE.DragSource->startDrag( rDGE, nActions, 0 /*cursor*/, 0 /*image*/, xData, mxDnDListener );
-        // If Drag&Move in an Engine, then Copy&Del has to be optional!
-        GetCursor()->Hide();
+    sal_Int8 nActions = bReadOnly ? datatransfer::dnd::DNDConstants::ACTION_COPY : datatransfer::dnd::DNDConstants::ACTION_COPY_OR_MOVE;
 
-    }
+    rDGE.DragSource->startDrag( rDGE, nActions, 0 /*cursor*/, 0 /*image*/, xData, mxDnDListener );
+    // If Drag&Move in an Engine, then Copy&Del has to be optional!
+    GetCursor()->Hide();
 }
 
 void ImpEditView::dragDropEnd( const css::datatransfer::dnd::DragSourceDropEvent& rDSDE )
@@ -2011,89 +2010,89 @@ void ImpEditView::dragDropEnd( const css::datatransfer::dnd::DragSourceDropEvent
     DBG_ASSERT( pDragAndDropInfo, "ImpEditView::dragDropEnd: pDragAndDropInfo is NULL!" );
 
     // #123688# Shouldn't happen, but seems to happen...
-    if ( pDragAndDropInfo )
+    if ( !pDragAndDropInfo )
+        return;
+
+    if ( !bReadOnly && rDSDE.DropSuccess && !pDragAndDropInfo->bOutlinerMode && ( rDSDE.DropAction & datatransfer::dnd::DNDConstants::ACTION_MOVE ) )
     {
-        if ( !bReadOnly && rDSDE.DropSuccess && !pDragAndDropInfo->bOutlinerMode && ( rDSDE.DropAction & datatransfer::dnd::DNDConstants::ACTION_MOVE ) )
+        if ( pDragAndDropInfo->bStarterOfDD && pDragAndDropInfo->bDroppedInMe )
         {
-            if ( pDragAndDropInfo->bStarterOfDD && pDragAndDropInfo->bDroppedInMe )
+            // DropPos: Where was it dropped, irrespective of length.
+            ESelection aDropPos( pDragAndDropInfo->aDropSel.nStartPara, pDragAndDropInfo->aDropSel.nStartPos, pDragAndDropInfo->aDropSel.nStartPara, pDragAndDropInfo->aDropSel.nStartPos );
+            ESelection aToBeDelSel = pDragAndDropInfo->aBeginDragSel;
+            ESelection aNewSel( pDragAndDropInfo->aDropSel.nEndPara, pDragAndDropInfo->aDropSel.nEndPos,
+                                pDragAndDropInfo->aDropSel.nEndPara, pDragAndDropInfo->aDropSel.nEndPos );
+            bool bBeforeSelection = aDropPos < pDragAndDropInfo->aBeginDragSel;
+            sal_Int32 nParaDiff = pDragAndDropInfo->aBeginDragSel.nEndPara - pDragAndDropInfo->aBeginDragSel.nStartPara;
+            if ( bBeforeSelection )
             {
-                // DropPos: Where was it dropped, irrespective of length.
-                ESelection aDropPos( pDragAndDropInfo->aDropSel.nStartPara, pDragAndDropInfo->aDropSel.nStartPos, pDragAndDropInfo->aDropSel.nStartPara, pDragAndDropInfo->aDropSel.nStartPos );
-                ESelection aToBeDelSel = pDragAndDropInfo->aBeginDragSel;
-                ESelection aNewSel( pDragAndDropInfo->aDropSel.nEndPara, pDragAndDropInfo->aDropSel.nEndPos,
-                                    pDragAndDropInfo->aDropSel.nEndPara, pDragAndDropInfo->aDropSel.nEndPos );
-                bool bBeforeSelection = aDropPos < pDragAndDropInfo->aBeginDragSel;
-                sal_Int32 nParaDiff = pDragAndDropInfo->aBeginDragSel.nEndPara - pDragAndDropInfo->aBeginDragSel.nStartPara;
-                if ( bBeforeSelection )
-                {
-                    // Adjust aToBeDelSel.
-                    DBG_ASSERT( pDragAndDropInfo->aBeginDragSel.nStartPara >= pDragAndDropInfo->aDropSel.nStartPara, "But not before? ");
-                    aToBeDelSel.nStartPara = aToBeDelSel.nStartPara + nParaDiff;
-                    aToBeDelSel.nEndPara = aToBeDelSel.nEndPara + nParaDiff;
-                    // To correct the character?
-                    if ( aToBeDelSel.nStartPara == pDragAndDropInfo->aDropSel.nEndPara )
-                    {
-                        sal_uInt16 nMoreChars;
-                        if ( pDragAndDropInfo->aDropSel.nStartPara == pDragAndDropInfo->aDropSel.nEndPara )
-                            nMoreChars = pDragAndDropInfo->aDropSel.nEndPos - pDragAndDropInfo->aDropSel.nStartPos;
-                        else
-                            nMoreChars = pDragAndDropInfo->aDropSel.nEndPos;
-                        aToBeDelSel.nStartPos =
-                            aToBeDelSel.nStartPos + nMoreChars;
-                        if ( aToBeDelSel.nStartPara == aToBeDelSel.nEndPara )
-                            aToBeDelSel.nEndPos =
-                                aToBeDelSel.nEndPos + nMoreChars;
-                    }
-                }
-                else
+                // Adjust aToBeDelSel.
+                DBG_ASSERT( pDragAndDropInfo->aBeginDragSel.nStartPara >= pDragAndDropInfo->aDropSel.nStartPara, "But not before? ");
+                aToBeDelSel.nStartPara = aToBeDelSel.nStartPara + nParaDiff;
+                aToBeDelSel.nEndPara = aToBeDelSel.nEndPara + nParaDiff;
+                // To correct the character?
+                if ( aToBeDelSel.nStartPara == pDragAndDropInfo->aDropSel.nEndPara )
                 {
-                    // aToBeDelSel is ok, but the selection of the  View
-                    // has to be adapted, if it was deleted before!
-                    DBG_ASSERT( pDragAndDropInfo->aBeginDragSel.nStartPara <= pDragAndDropInfo->aDropSel.nStartPara, "But not before? ");
-                    aNewSel.nStartPara = aNewSel.nStartPara - nParaDiff;
-                    aNewSel.nEndPara = aNewSel.nEndPara - nParaDiff;
-                    // To correct the character?
-                    if ( pDragAndDropInfo->aBeginDragSel.nEndPara == pDragAndDropInfo->aDropSel.nStartPara )
-                    {
-                        sal_uInt16 nLessChars;
-                        if ( pDragAndDropInfo->aBeginDragSel.nStartPara == pDragAndDropInfo->aBeginDragSel.nEndPara )
-                            nLessChars = pDragAndDropInfo->aBeginDragSel.nEndPos - pDragAndDropInfo->aBeginDragSel.nStartPos;
-                        else
-                            nLessChars = pDragAndDropInfo->aBeginDragSel.nEndPos;
-                        aNewSel.nStartPos = aNewSel.nStartPos - nLessChars;
-                        if ( aNewSel.nStartPara == aNewSel.nEndPara )
-                            aNewSel.nEndPos = aNewSel.nEndPos - nLessChars;
-                    }
+                    sal_uInt16 nMoreChars;
+                    if ( pDragAndDropInfo->aDropSel.nStartPara == pDragAndDropInfo->aDropSel.nEndPara )
+                        nMoreChars = pDragAndDropInfo->aDropSel.nEndPos - pDragAndDropInfo->aDropSel.nStartPos;
+                    else
+                        nMoreChars = pDragAndDropInfo->aDropSel.nEndPos;
+                    aToBeDelSel.nStartPos =
+                        aToBeDelSel.nStartPos + nMoreChars;
+                    if ( aToBeDelSel.nStartPara == aToBeDelSel.nEndPara )
+                        aToBeDelSel.nEndPos =
+                            aToBeDelSel.nEndPos + nMoreChars;
                 }
-
-                DrawSelectionXOR();
-                EditSelection aDelSel( pEditEngine->pImpEditEngine->CreateSel( aToBeDelSel ) );
-                DBG_ASSERT( !aDelSel.DbgIsBuggy( pEditEngine->GetEditDoc() ), "ToBeDel is buggy!" );
-                pEditEngine->DeleteSelection(aDelSel);
-                if ( !bBeforeSelection )
+            }
+            else
+            {
+                // aToBeDelSel is ok, but the selection of the  View
+                // has to be adapted, if it was deleted before!
+                DBG_ASSERT( pDragAndDropInfo->aBeginDragSel.nStartPara <= pDragAndDropInfo->aDropSel.nStartPara, "But not before? ");
+                aNewSel.nStartPara = aNewSel.nStartPara - nParaDiff;
+                aNewSel.nEndPara = aNewSel.nEndPara - nParaDiff;
+                // To correct the character?
+                if ( pDragAndDropInfo->aBeginDragSel.nEndPara == pDragAndDropInfo->aDropSel.nStartPara )
                 {
-                    DBG_ASSERT( !pEditEngine->pImpEditEngine->CreateSel( aNewSel ).DbgIsBuggy(pEditEngine->GetEditDoc()), "Bad" );
-                    SetEditSelection( pEditEngine->pImpEditEngine->CreateSel( aNewSel ) );
+                    sal_uInt16 nLessChars;
+                    if ( pDragAndDropInfo->aBeginDragSel.nStartPara == pDragAndDropInfo->aBeginDragSel.nEndPara )
+                        nLessChars = pDragAndDropInfo->aBeginDragSel.nEndPos - pDragAndDropInfo->aBeginDragSel.nStartPos;
+                    else
+                        nLessChars = pDragAndDropInfo->aBeginDragSel.nEndPos;
+                    aNewSel.nStartPos = aNewSel.nStartPos - nLessChars;
+                    if ( aNewSel.nStartPara == aNewSel.nEndPara )
+                        aNewSel.nEndPos = aNewSel.nEndPos - nLessChars;
                 }
-                pEditEngine->pImpEditEngine->FormatAndUpdate( pEditEngine->pImpEditEngine->GetActiveView() );
-                DrawSelectionXOR();
             }
-            else
+
+            DrawSelectionXOR();
+            EditSelection aDelSel( pEditEngine->pImpEditEngine->CreateSel( aToBeDelSel ) );
+            DBG_ASSERT( !aDelSel.DbgIsBuggy( pEditEngine->GetEditDoc() ), "ToBeDel is buggy!" );
+            pEditEngine->DeleteSelection(aDelSel);
+            if ( !bBeforeSelection )
             {
-                // other EditEngine ...
-                if (pEditEngine->HasText())   // #88630# SC is removing the content when switching the task
-                    DeleteSelected();
+                DBG_ASSERT( !pEditEngine->pImpEditEngine->CreateSel( aNewSel ).DbgIsBuggy(pEditEngine->GetEditDoc()), "Bad" );
+                SetEditSelection( pEditEngine->pImpEditEngine->CreateSel( aNewSel ) );
             }
+            pEditEngine->pImpEditEngine->FormatAndUpdate( pEditEngine->pImpEditEngine->GetActiveView() );
+            DrawSelectionXOR();
+        }
+        else
+        {
+            // other EditEngine ...
+            if (pEditEngine->HasText())   // #88630# SC is removing the content when switching the task
+                DeleteSelected();
         }
+    }
 
-        if ( pDragAndDropInfo->bUndoAction )
-            pEditEngine->pImpEditEngine->UndoActionEnd();
+    if ( pDragAndDropInfo->bUndoAction )
+        pEditEngine->pImpEditEngine->UndoActionEnd();
 
-        HideDDCursor();
-        ShowCursor( DoAutoScroll(), true );
-        pDragAndDropInfo.reset();
-        pEditEngine->GetEndDropHdl().Call(GetEditViewPtr());
-    }
+    HideDDCursor();
+    ShowCursor( DoAutoScroll(), true );
+    pDragAndDropInfo.reset();
+    pEditEngine->GetEndDropHdl().Call(GetEditViewPtr());
 }
 
 void ImpEditView::drop( const css::datatransfer::dnd::DropTargetDropEvent& rDTDE )
@@ -2102,70 +2101,70 @@ void ImpEditView::drop( const css::datatransfer::dnd::DropTargetDropEvent& rDTDE
 
     DBG_ASSERT( pDragAndDropInfo, "Drop - No Drag&Drop info?!" );
 
-    if ( pDragAndDropInfo && pDragAndDropInfo->bDragAccepted )
-    {
-        pEditEngine->GetBeginDropHdl().Call(GetEditViewPtr());
-        bool bChanges = false;
+    if ( !(pDragAndDropInfo && pDragAndDropInfo->bDragAccepted) )
+        return;
 
-        HideDDCursor();
+    pEditEngine->GetBeginDropHdl().Call(GetEditViewPtr());
+    bool bChanges = false;
 
-        if ( pDragAndDropInfo->bStarterOfDD )
-        {
-            pEditEngine->pImpEditEngine->UndoActionStart( EDITUNDO_DRAGANDDROP );
-            pDragAndDropInfo->bUndoAction = true;
-        }
+    HideDDCursor();
+
+    if ( pDragAndDropInfo->bStarterOfDD )
+    {
+        pEditEngine->pImpEditEngine->UndoActionStart( EDITUNDO_DRAGANDDROP );
+        pDragAndDropInfo->bUndoAction = true;
+    }
 
-        if ( pDragAndDropInfo->bOutlinerMode )
+    if ( pDragAndDropInfo->bOutlinerMode )
+    {
+        bChanges = true;
+        GetEditViewPtr()->MoveParagraphs( Range( pDragAndDropInfo->aBeginDragSel.nStartPara, pDragAndDropInfo->aBeginDragSel.nEndPara ), pDragAndDropInfo->nOutlinerDropDest );
+    }
+    else
+    {
+        uno::Reference< datatransfer::XTransferable > xDataObj = rDTDE.Transferable;
+        if ( xDataObj.is() )
         {
             bChanges = true;
-            GetEditViewPtr()->MoveParagraphs( Range( pDragAndDropInfo->aBeginDragSel.nStartPara, pDragAndDropInfo->aBeginDragSel.nEndPara ), pDragAndDropInfo->nOutlinerDropDest );
-        }
-        else
-        {
-            uno::Reference< datatransfer::XTransferable > xDataObj = rDTDE.Transferable;
-            if ( xDataObj.is() )
-            {
-                bChanges = true;
-                // remove Selection ...
-                DrawSelectionXOR();
-                EditPaM aPaM( pDragAndDropInfo->aDropDest );
+            // remove Selection ...
+            DrawSelectionXOR();
+            EditPaM aPaM( pDragAndDropInfo->aDropDest );
 
-                PasteOrDropInfos aPasteOrDropInfos;
-                aPasteOrDropInfos.nStartPara = pEditEngine->GetEditDoc().GetPos( aPaM.GetNode() );
-                pEditEngine->HandleBeginPasteOrDrop(aPasteOrDropInfos);
+            PasteOrDropInfos aPasteOrDropInfos;
+            aPasteOrDropInfos.nStartPara = pEditEngine->GetEditDoc().GetPos( aPaM.GetNode() );
+            pEditEngine->HandleBeginPasteOrDrop(aPasteOrDropInfos);
 
-                EditSelection aNewSel = pEditEngine->InsertText(
-                    xDataObj, OUString(), aPaM, pEditEngine->GetInternalEditStatus().AllowPasteSpecial());
+            EditSelection aNewSel = pEditEngine->InsertText(
+                xDataObj, OUString(), aPaM, pEditEngine->GetInternalEditStatus().AllowPasteSpecial());
 
-                aPasteOrDropInfos.nEndPara = pEditEngine->GetEditDoc().GetPos( aNewSel.Max().GetNode() );
-                pEditEngine->HandleEndPasteOrDrop(aPasteOrDropInfos);
+            aPasteOrDropInfos.nEndPara = pEditEngine->GetEditDoc().GetPos( aNewSel.Max().GetNode() );
+            pEditEngine->HandleEndPasteOrDrop(aPasteOrDropInfos);
 
-                SetEditSelection( aNewSel );
-                pEditEngine->pImpEditEngine->FormatAndUpdate( pEditEngine->pImpEditEngine->GetActiveView() );
-                if ( pDragAndDropInfo->bStarterOfDD )
-                {
-                    // Only set if the same engine!
-                    pDragAndDropInfo->aDropSel.nStartPara = pEditEngine->GetEditDoc().GetPos( aPaM.GetNode() );
-                    pDragAndDropInfo->aDropSel.nStartPos = aPaM.GetIndex();
-                    pDragAndDropInfo->aDropSel.nEndPara = pEditEngine->GetEditDoc().GetPos( aNewSel.Max().GetNode() );
-                    pDragAndDropInfo->aDropSel.nEndPos = aNewSel.Max().GetIndex();
-                    pDragAndDropInfo->bDroppedInMe = true;
-                }
+            SetEditSelection( aNewSel );
+            pEditEngine->pImpEditEngine->FormatAndUpdate( pEditEngine->pImpEditEngine->GetActiveView() );
+            if ( pDragAndDropInfo->bStarterOfDD )
+            {
+                // Only set if the same engine!
+                pDragAndDropInfo->aDropSel.nStartPara = pEditEngine->GetEditDoc().GetPos( aPaM.GetNode() );
+                pDragAndDropInfo->aDropSel.nStartPos = aPaM.GetIndex();
+                pDragAndDropInfo->aDropSel.nEndPara = pEditEngine->GetEditDoc().GetPos( aNewSel.Max().GetNode() );
+                pDragAndDropInfo->aDropSel.nEndPos = aNewSel.Max().GetIndex();
+                pDragAndDropInfo->bDroppedInMe = true;
             }
         }
+    }
 
-        if ( bChanges )
-        {
-            rDTDE.Context->acceptDrop( rDTDE.DropAction );
-        }
-
-        if ( !pDragAndDropInfo->bStarterOfDD )
-        {
-            pDragAndDropInfo.reset();
-        }
+    if ( bChanges )
+    {
+        rDTDE.Context->acceptDrop( rDTDE.DropAction );
+    }
 
-        rDTDE.Context->dropComplete( bChanges );
+    if ( !pDragAndDropInfo->bStarterOfDD )
+    {
+        pDragAndDropInfo.reset();
     }
+
+    rDTDE.Context->dropComplete( bChanges );
 }
 
 void ImpEditView::dragEnter( const css::datatransfer::dnd::DropTargetDragEnterEvent& rDTDEE )
@@ -2369,25 +2368,25 @@ void ImpEditView::AddDragAndDropListeners()
     else if (GetWindow())
         xDropTarget = GetWindow()->GetDropTarget();
 
-    if (xDropTarget.is())
-    {
-        vcl::unohelper::DragAndDropWrapper* pDnDWrapper = new vcl::unohelper::DragAndDropWrapper(this);
-        mxDnDListener = pDnDWrapper;
-
-        css::uno::Reference<css::datatransfer::dnd::XDragGestureRecognizer> xDragGestureRecognizer(xDropTarget, uno::UNO_QUERY);
-        if (xDragGestureRecognizer.is())
-        {
-            uno::Reference<datatransfer::dnd::XDragGestureListener> xDGL(mxDnDListener, uno::UNO_QUERY);
-            xDragGestureRecognizer->addDragGestureListener(xDGL);
-        }
+    if (!xDropTarget.is())
+        return;
 
-        uno::Reference<datatransfer::dnd::XDropTargetListener> xDTL(mxDnDListener, uno::UNO_QUERY);
-        xDropTarget->addDropTargetListener(xDTL);
-        xDropTarget->setActive(true);
-        xDropTarget->setDefaultActions(datatransfer::dnd::DNDConstants::ACTION_COPY_OR_MOVE);
+    vcl::unohelper::DragAndDropWrapper* pDnDWrapper = new vcl::unohelper::DragAndDropWrapper(this);
+    mxDnDListener = pDnDWrapper;
 
-        bActiveDragAndDropListener = true;
+    css::uno::Reference<css::datatransfer::dnd::XDragGestureRecognizer> xDragGestureRecognizer(xDropTarget, uno::UNO_QUERY);
+    if (xDragGestureRecognizer.is())
+    {
+        uno::Reference<datatransfer::dnd::XDragGestureListener> xDGL(mxDnDListener, uno::UNO_QUERY);
+        xDragGestureRecognizer->addDragGestureListener(xDGL);
     }
+
+    uno::Reference<datatransfer::dnd::XDropTargetListener> xDTL(mxDnDListener, uno::UNO_QUERY);
+    xDropTarget->addDropTargetListener(xDTL);
+    xDropTarget->setActive(true);
+    xDropTarget->setDefaultActions(datatransfer::dnd::DNDConstants::ACTION_COPY_OR_MOVE);
+
+    bActiveDragAndDropListener = true;
 }
 
 void ImpEditView::RemoveDragAndDropListeners()
@@ -2401,26 +2400,26 @@ void ImpEditView::RemoveDragAndDropListeners()
     else if (GetWindow())
         xDropTarget = GetWindow()->GetDropTarget();
 
-    if (xDropTarget.is())
-    {
-        css::uno::Reference<css::datatransfer::dnd::XDragGestureRecognizer> xDragGestureRecognizer(xDropTarget, uno::UNO_QUERY);
-        if (xDragGestureRecognizer.is())
-        {
-            uno::Reference<datatransfer::dnd::XDragGestureListener> xDGL(mxDnDListener, uno::UNO_QUERY);
-            xDragGestureRecognizer->removeDragGestureListener(xDGL);
-        }
+    if (!xDropTarget.is())
+        return;
 
-        uno::Reference<datatransfer::dnd::XDropTargetListener> xDTL(mxDnDListener, uno::UNO_QUERY);
-        xDropTarget->removeDropTargetListener(xDTL);
+    css::uno::Reference<css::datatransfer::dnd::XDragGestureRecognizer> xDragGestureRecognizer(xDropTarget, uno::UNO_QUERY);
+    if (xDragGestureRecognizer.is())
+    {
+        uno::Reference<datatransfer::dnd::XDragGestureListener> xDGL(mxDnDListener, uno::UNO_QUERY);
+        xDragGestureRecognizer->removeDragGestureListener(xDGL);
+    }
 
-        if ( mxDnDListener.is() )
-        {
-            mxDnDListener->disposing( lang::EventObject() );  // #95154# Empty Source means it's the Client
-            mxDnDListener.clear();
-        }
+    uno::Reference<datatransfer::dnd::XDropTargetListener> xDTL(mxDnDListener, uno::UNO_QUERY);
+    xDropTarget->removeDropTargetListener(xDTL);
 
-        bActiveDragAndDropListener = false;
+    if ( mxDnDListener.is() )
+    {
+        mxDnDListener->disposing( lang::EventObject() );  // #95154# Empty Source means it's the Client
+        mxDnDListener.clear();
     }
+
+    bActiveDragAndDropListener = false;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 9c04370d9f08..ffa93a144efd 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -1613,131 +1613,131 @@ void ImpEditEngine::InitScriptTypes( sal_Int32 nPara )
     rTypes.clear();
 
     ContentNode* pNode = pParaPortion->GetNode();
-    if ( pNode->Len() )
-    {
-        uno::Reference < i18n::XBreakIterator > _xBI( ImplGetBreakIterator() );
+    if ( !pNode->Len() )
+        return;
 
-        OUString aText = pNode->GetString();
+    uno::Reference < i18n::XBreakIterator > _xBI( ImplGetBreakIterator() );
+
+    OUString aText = pNode->GetString();
 
-        // To handle fields put the character from the field in the string,
-        // because endOfScript( ... ) will skip the CH_FEATURE, because this is WEAK
-        const EditCharAttrib* pField = pNode->GetCharAttribs().FindNextAttrib( EE_FEATURE_FIELD, 0 );
-        while ( pField )
+    // To handle fields put the character from the field in the string,
+    // because endOfScript( ... ) will skip the CH_FEATURE, because this is WEAK
+    const EditCharAttrib* pField = pNode->GetCharAttribs().FindNextAttrib( EE_FEATURE_FIELD, 0 );
+    while ( pField )
+    {
+        const OUString aFldText = static_cast<const EditCharAttribField*>(pField)->GetFieldValue();
+        if ( !aFldText.isEmpty() )
         {
-            const OUString aFldText = static_cast<const EditCharAttribField*>(pField)->GetFieldValue();
-            if ( !aFldText.isEmpty() )
+            aText = aText.replaceAt( pField->GetStart(), 1, aFldText.copy(0,1) );
+            short nFldScriptType = _xBI->getScriptType( aFldText, 0 );
+
+            for ( sal_Int32 nCharInField = 1; nCharInField < aFldText.getLength(); nCharInField++ )
             {
-                aText = aText.replaceAt( pField->GetStart(), 1, aFldText.copy(0,1) );
-                short nFldScriptType = _xBI->getScriptType( aFldText, 0 );
+                short nTmpType = _xBI->getScriptType( aFldText, nCharInField );
 
-                for ( sal_Int32 nCharInField = 1; nCharInField < aFldText.getLength(); nCharInField++ )
+                // First char from field wins...
+                if ( nFldScriptType == i18n::ScriptType::WEAK )
                 {
-                    short nTmpType = _xBI->getScriptType( aFldText, nCharInField );
-
-                    // First char from field wins...
-                    if ( nFldScriptType == i18n::ScriptType::WEAK )
-                    {
-                        nFldScriptType = nTmpType;
-                        aText = aText.replaceAt( pField->GetStart(), 1, aFldText.copy(nCharInField,1) );
-                    }
+                    nFldScriptType = nTmpType;
+                    aText = aText.replaceAt( pField->GetStart(), 1, aFldText.copy(nCharInField,1) );
+                }
 
-                    // ...  but if the first one is LATIN, and there are CJK or CTL chars too,
-                    // we prefer that ScriptType because we need another font.
-                    if ( ( nTmpType == i18n::ScriptType::ASIAN ) || ( nTmpType == i18n::ScriptType::COMPLEX ) )
-                    {
-                        aText = aText.replaceAt( pField->GetStart(), 1, aFldText.copy(nCharInField,1) );
-                        break;
-                    }
+                // ...  but if the first one is LATIN, and there are CJK or CTL chars too,
+                // we prefer that ScriptType because we need another font.
+                if ( ( nTmpType == i18n::ScriptType::ASIAN ) || ( nTmpType == i18n::ScriptType::COMPLEX ) )
+                {
+                    aText = aText.replaceAt( pField->GetStart(), 1, aFldText.copy(nCharInField,1) );
+                    break;
                 }
             }
-            // #112831# Last Field might go from 0xffff to 0x0000
-            pField = pField->GetEnd() ? pNode->GetCharAttribs().FindNextAttrib( EE_FEATURE_FIELD, pField->GetEnd() ) : nullptr;
         }
+        // #112831# Last Field might go from 0xffff to 0x0000
+        pField = pField->GetEnd() ? pNode->GetCharAttribs().FindNextAttrib( EE_FEATURE_FIELD, pField->GetEnd() ) : nullptr;
+    }
 
-        sal_Int32 nTextLen = aText.getLength();
+    sal_Int32 nTextLen = aText.getLength();
 
-        sal_Int32 nPos = 0;
-        short nScriptType = _xBI->getScriptType( aText, nPos );
-        rTypes.emplace_back( nScriptType, nPos, nTextLen );
-        nPos = _xBI->endOfScript( aText, nPos, nScriptType );
-        while ( ( nPos != -1 ) && ( nPos < nTextLen ) )
-        {
-            rTypes.back().nEndPos = nPos;
+    sal_Int32 nPos = 0;
+    short nScriptType = _xBI->getScriptType( aText, nPos );
+    rTypes.emplace_back( nScriptType, nPos, nTextLen );

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list