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

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Sun Aug 25 20:31:08 UTC 2019


 svx/source/svdraw/svdmrkv.cxx |   71 +++++++++++++++++++++---------------------
 1 file changed, 36 insertions(+), 35 deletions(-)

New commits:
commit f876dc9e16b9c85ae85ed848865531a8be0e911c
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Aug 25 23:00:53 2019 +0900
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Sun Aug 25 22:29:57 2019 +0200

    lok: cleanup and simplify graphic selection code
    
    Don't get SfxViewShell all the time, just one and ask if it is
    available (non-null).
    Rename sSelection to sSelectionText so it doesn't look similar
    to aSelection.
    Group more if statement together - especially to bring them under
    bTiledRendering "umbrella"
    
    Change-Id: Ic998f67a2e5de7482a0073a67ddffd721c012525
    Reviewed-on: https://gerrit.libreoffice.org/78082
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index 6e770eca7976..e49a00817582 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -738,6 +738,8 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
         }
     }
 
+    SfxViewShell* pViewShell = GetSfxViewShell();
+
     // check if text edit or ole is active and handles need to be suppressed. This may be the case
     // when a single object is selected
     // Using a strict return statement is okay here; no handles means *no* handles.
@@ -758,7 +760,7 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
                 if (bTiledRendering)
                 {
                     // Suppress handles -> empty graphic selection.
-                    if(SfxViewShell* pViewShell = GetSfxViewShell())
+                    if (pViewShell)
                     {
                         pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_GRAPHIC_SELECTION, "EMPTY");
                         SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", "EMPTY");
@@ -782,7 +784,7 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
             if (xController.is() && xController->hasSelectedCells())
             {
                 // The table shape has selected cells, which provide text selection already -> no graphic selection.
-                if(SfxViewShell* pViewShell = GetSfxViewShell())
+                if (pViewShell)
                 {
                     pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_GRAPHIC_SELECTION, "EMPTY");
                     SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", "EMPTY");
@@ -793,35 +795,33 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
     }
 
     tools::Rectangle aRect(GetMarkedObjRect());
-    tools::Rectangle aSelection(aRect);
 
-    bool bIsChart = false;
-    if (bTiledRendering && !aRect.IsEmpty())
+    if (bTiledRendering && pViewShell)
     {
-        sal_uInt32 nTotalPaintWindows = this->PaintWindowCount();
-        if (nTotalPaintWindows == 1)
+        tools::Rectangle aSelection(aRect);
+        bool bIsChart = false;
+
+        if (!aRect.IsEmpty())
         {
-            const vcl::Window* pWin = dynamic_cast<const vcl::Window*>(this->GetFirstOutputDevice());
-            if (pWin && pWin->IsChart())
+            sal_uInt32 nTotalPaintWindows = this->PaintWindowCount();
+            if (nTotalPaintWindows == 1)
             {
-                bIsChart = true;
-                const vcl::Window* pViewShellWindow = GetSfxViewShell()->GetEditWindowForActiveOLEObj();
-                if (pViewShellWindow && pViewShellWindow->IsAncestorOf(*pWin))
+                const vcl::Window* pWin = dynamic_cast<const vcl::Window*>(this->GetFirstOutputDevice());
+                if (pWin && pWin->IsChart())
                 {
-                    Point aOffsetPx = pWin->GetOffsetPixelFrom(*pViewShellWindow);
-                    Point aLogicOffset = pWin->PixelToLogic(aOffsetPx);
-                    aSelection.Move(aLogicOffset.getX(), aLogicOffset.getY());
+                    bIsChart = true;
+                    const vcl::Window* pViewShellWindow = GetSfxViewShell()->GetEditWindowForActiveOLEObj();
+                    if (pViewShellWindow && pViewShellWindow->IsAncestorOf(*pWin))
+                    {
+                        Point aOffsetPx = pWin->GetOffsetPixelFrom(*pViewShellWindow);
+                        Point aLogicOffset = pWin->PixelToLogic(aOffsetPx);
+                        aSelection.Move(aLogicOffset.getX(), aLogicOffset.getY());
+                    }
                 }
             }
         }
-    }
 
-    if (bTiledRendering)
-    {
-        OString sSelection;
-        if (aSelection.IsEmpty())
-            sSelection = "EMPTY";
-        else
+        if (!aSelection.IsEmpty())
         {
             // In case the map mode is in 100th MM, then need to convert the coordinates over to twips for LOK.
             if (mpMarkedPV)
@@ -833,14 +833,13 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
                 }
             }
 
-            sSelection = aSelection.toString();
-
             // hide the text selection too
-            if(SfxViewShell* pViewShell = GetSfxViewShell())
-                pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, "");
+            pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, "");
         }
-        if(SfxViewShell* pViewShell = GetSfxViewShell())
+
         {
+            OString sSelectionText;
+
             if (GetMarkedObjectCount())
             {
                 SdrMark* pM = GetSdrMarkByIndex(0);
@@ -855,8 +854,6 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
                     nRotAngle *= 10;
                 }
 
-                sSelection += OString(", ") + OString::number(nRotAngle);
-
                 OStringBuffer aExtraInfo;
                 if (bWriterGraphic)
                 {
@@ -990,27 +987,31 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
                         }
                     }
                 }
-
+                sSelectionText = aSelection.toString();
+                sSelectionText += OString(", ") + OString::number(nRotAngle);
                 if (!aExtraInfo.isEmpty())
                 {
-                    sSelection += ", ";
-                    sSelection += aExtraInfo.makeStringAndClear();
+                    sSelectionText += ", ";
+                    sSelectionText += aExtraInfo.makeStringAndClear();
                 }
             }
 
+            if (sSelectionText.isEmpty())
+                sSelectionText = "EMPTY";
+
             if (pOtherShell)
             {
                 // Another shell wants to know about our existing
                 // selection.
                 if (pViewShell != pOtherShell)
-                    SfxLokHelper::notifyOtherView(pViewShell, pOtherShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", sSelection);
+                    SfxLokHelper::notifyOtherView(pViewShell, pOtherShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", sSelectionText);
             }
             else
             {
                 // We have a new selection, so both pViewShell and the
                 // other views want to know about it.
-                pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_GRAPHIC_SELECTION, sSelection.getStr());
-                SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", sSelection);
+                pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_GRAPHIC_SELECTION, sSelectionText.getStr());
+                SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", sSelectionText);
             }
         }
     }


More information about the Libreoffice-commits mailing list