[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - svx/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Thu Sep 5 11:03:04 UTC 2019
svx/source/svdraw/svdmrkv.cxx | 82 ++++++++++++++++++++----------------------
1 file changed, 40 insertions(+), 42 deletions(-)
New commits:
commit f74846aa83b5285bd6b53cfb1ea75bcf80d7f74d
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: Thu Sep 5 13:02:19 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"
Reviewed-on: https://gerrit.libreoffice.org/78082
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
(cherry picked from commit f876dc9e16b9c85ae85ed848865531a8be0e911c)
Change-Id: Ic998f67a2e5de7482a0073a67ddffd721c012525
Reviewed-on: https://gerrit.libreoffice.org/78328
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index ffebad84a9c3..00a2e44e428b 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -757,6 +757,8 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
// correct position )
Point aGridOff = GetGridOffset();
+ 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.
@@ -777,7 +779,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");
@@ -790,14 +792,11 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
// formerly #i118524#: if inplace activated OLE is selected, suppress handles
const SdrOle2Obj* pSdrOle2Obj = dynamic_cast< const SdrOle2Obj* >(mpMarkedObj);
- if(pSdrOle2Obj && (pSdrOle2Obj->isInplaceActive() || pSdrOle2Obj->isUiActive()))
+ if (pSdrOle2Obj && (pSdrOle2Obj->isInplaceActive() || pSdrOle2Obj->isUiActive()))
{
- if(SfxViewShell* pViewShell = GetSfxViewShell())
- {
- pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_GRAPHIC_SELECTION, "INPLACE");
- SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", "INPLACE");
- return;
- }
+ pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_GRAPHIC_SELECTION, "INPLACE");
+ SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", "INPLACE");
+ return;
}
if (bTiledRendering && mpMarkedObj->GetObjIdentifier() == OBJ_TABLE)
@@ -806,7 +805,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");
@@ -817,35 +816,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)
@@ -857,14 +854,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);
@@ -879,8 +875,6 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
nRotAngle *= 10;
}
- sSelection += OString(", ") + OString::number(nRotAngle);
-
OStringBuffer aExtraInfo;
if (bWriterGraphic)
{
@@ -1014,27 +1008,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)
{
// An other 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