svx/source/svdraw/svdmrkv.cxx | 71 +++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 35 deletions(-)
New commits: commit 5e930cdd29170b628810c0fb890db09fe05891e2 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sun Aug 25 23:00:53 2019 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Fri Sep 6 11:59:00 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 <qui...@gmail.com> (cherry picked from commit f876dc9e16b9c85ae85ed848865531a8be0e911c) Reviewed-on: https://gerrit.libreoffice.org/78685 Tested-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx index 5ce4ccc84518..0b9ed33ecf4a 100644 --- a/svx/source/svdraw/svdmrkv.cxx +++ b/svx/source/svdraw/svdmrkv.cxx @@ -742,6 +742,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. @@ -762,7 +764,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"); @@ -786,7 +788,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"); @@ -797,35 +799,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) @@ -837,14 +837,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); @@ -859,8 +858,6 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell) nRotAngle *= 10; } - sSelection += OString(", ") + OString::number(nRotAngle); - OStringBuffer aExtraInfo; if (bWriterGraphic) { @@ -994,27 +991,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); } } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits