diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2024-05-31 13:47:04 +0200 |
---|---|---|
committer | Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> | 2024-06-28 13:41:53 +0200 |
commit | de732c870f04921803343578f0601aede389f00d (patch) | |
tree | 79239355a5f89577c75918894fcdd3333d32ecc2 | |
parent | 0309281387afb43c7f57709ad18f38e01c70edbc (diff) |
svx: use SAL_RET_MAYBENULL in GetSfxViewShell()
Change-Id: I05e66544c08a1ed55a5571f6061b23346235224e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168293
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
(cherry picked from commit cb982975c16e380f88282f03d07f8cfb8421ed77)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168316
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
-rw-r--r-- | svx/source/svdraw/svdedtv1.cxx | 9 | ||||
-rw-r--r-- | svx/source/svdraw/svdmrkv.cxx | 25 |
2 files changed, 22 insertions, 12 deletions
diff --git a/svx/source/svdraw/svdedtv1.cxx b/svx/source/svdraw/svdedtv1.cxx index ee8945a82149..a942af276ee5 100644 --- a/svx/source/svdraw/svdedtv1.cxx +++ b/svx/source/svdraw/svdedtv1.cxx @@ -1021,8 +1021,13 @@ void SdrEditView::MergeAttrFromMarked(SfxItemSet& rAttr, bool bOnlyHardAttr) con } if (!sPayload.isEmpty()) - GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, - OUStringToOString(sPayload, RTL_TEXTENCODING_ASCII_US)); + { + if (SfxViewShell* pViewShell = GetSfxViewShell()) + { + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, + OUStringToOString(sPayload, RTL_TEXTENCODING_ASCII_US)); + } + } } nWhich = aIter.NextWhich(); diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx index b0784449f159..3f38c066ee20 100644 --- a/svx/source/svdraw/svdmrkv.cxx +++ b/svx/source/svdraw/svdmrkv.cxx @@ -252,12 +252,15 @@ void SdrMarkView::modelHasChangedLOKit() const vcl::Window* pWin = pOut ? pOut->GetOwnerWindow() : nullptr; if (pWin && pWin->IsChart()) { - const vcl::Window* pViewShellWindow = GetSfxViewShell()->GetEditWindowForActiveOLEObj(); - if (pViewShellWindow && pViewShellWindow->IsAncestorOf(*pWin)) + if (SfxViewShell* pViewShell = GetSfxViewShell()) { - Point aOffsetPx = pWin->GetOffsetPixelFrom(*pViewShellWindow); - Point aLogicOffset = pWin->PixelToLogic(aOffsetPx); - aSelection.Move(aLogicOffset.getX(), aLogicOffset.getY()); + const vcl::Window* pViewShellWindow = pViewShell->GetEditWindowForActiveOLEObj(); + if (pViewShellWindow && pViewShellWindow->IsAncestorOf(*pWin)) + { + Point aOffsetPx = pWin->GetOffsetPixelFrom(*pViewShellWindow); + Point aLogicOffset = pWin->PixelToLogic(aOffsetPx); + aSelection.Move(aLogicOffset.getX(), aLogicOffset.getY()); + } } } } @@ -814,7 +817,8 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const S } // hide the text selection too - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, ""_ostr); + if (pViewShell) + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, ""_ostr); } { @@ -945,7 +949,7 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const S + "]"); // polygon approximating the pie segment or donut segment - if (pO->GetObjIdentifier() == SdrObjKind::PathFill) + if (pViewShell && pO->GetObjIdentifier() == SdrObjKind::PathFill) { const basegfx::B2DPolyPolygon aPolyPolygon(pO->TakeXorPoly()); if (aPolyPolygon.count() == 1) @@ -1122,7 +1126,7 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const S { sSelectionText = "EMPTY"_ostr; sSelectionTextView = "EMPTY"_ostr; - if (!pOtherShell) + if (!pOtherShell && pViewShell) pViewShell->NotifyOtherViews(LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection"_ostr, OString()); } @@ -1137,9 +1141,10 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const S std::stringstream aStream; boost::property_tree::write_json(aStream, aTableJsonTree); - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TABLE_SELECTED, OString(aStream.str())); + if (pViewShell) + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TABLE_SELECTED, OString(aStream.str())); } - else if (!getSdrModelFromSdrView().IsWriter()) + else if (!getSdrModelFromSdrView().IsWriter() && pViewShell) { pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TABLE_SELECTED, "{}"_ostr); } |