include/svx/svdmrkv.hxx        |    2 +-
 svx/source/svdraw/svdedtv1.cxx |    9 +++++++--
 svx/source/svdraw/svdmrkv.cxx  |   25 +++++++++++++++----------
 3 files changed, 23 insertions(+), 13 deletions(-)

New commits:
commit cb982975c16e380f88282f03d07f8cfb8421ed77
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Fri May 31 13:47:04 2024 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Sun Jun 2 20:45:56 2024 +0200

    svx: use SAL_RET_MAYBENULL in GetSfxViewShell()
    
    Change-Id: I05e66544c08a1ed55a5571f6061b23346235224e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168293
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Tested-by: Jenkins

diff --git a/include/svx/svdmrkv.hxx b/include/svx/svdmrkv.hxx
index 4cffc9c3de88..b4958bb3f7fd 100644
--- a/include/svx/svdmrkv.hxx
+++ b/include/svx/svdmrkv.hxx
@@ -438,7 +438,7 @@ public:
     const Point& GetRef2() const { return maRef2; }
     SAL_DLLPRIVATE void SetRef2(const Point& rPt);
     /// Get access to the view shell owning this draw view, if any.
-    virtual SfxViewShell* GetSfxViewShell() const;
+    SAL_RET_MAYBENULL virtual SfxViewShell* GetSfxViewShell() const;
 };
 
 
diff --git a/svx/source/svdraw/svdedtv1.cxx b/svx/source/svdraw/svdedtv1.cxx
index cff6238b8005..bf1cc6f9a638 100644
--- a/svx/source/svdraw/svdedtv1.cxx
+++ b/svx/source/svdraw/svdedtv1.cxx
@@ -1035,8 +1035,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 1b44fb021edf..d79a899de4c8 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -257,12 +257,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());
+                    }
                 }
             }
         }
@@ -881,7 +884,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);
     }
 
     {
@@ -1022,7 +1026,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)
@@ -1199,7 +1203,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());
         }
 
@@ -1214,9 +1218,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);
         }

Reply via email to