summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-08-25 23:00:53 +0900
committerTomaž Vajngerl <quikee@gmail.com>2019-08-25 22:29:57 +0200
commitf876dc9e16b9c85ae85ed848865531a8be0e911c (patch)
treeb1efae08033f17eaa356abb7700e04f8ede64459 /svx
parent96513c0efb41f388c66f859b93a999a7467217e9 (diff)
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@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/svdraw/svdmrkv.cxx71
1 files changed, 36 insertions, 35 deletions
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);
}
}
}