summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-12-16 12:11:38 +0000
committerXisco Fauli <xiscofauli@libreoffice.org>2022-12-19 10:50:14 +0000
commite833729c71eac567be73158d640c717588dbe0a2 (patch)
treeb7e71e20a4718be6f4465aa101c333790e9056a4 /desktop
parentf88056b02164fee4b8ce56554f71daf33eb07482 (diff)
check SfxObjectShell::Current()
SfxObjectShell::Current() can return null, it's based on the equally vile SfxViewFrame::Current() Change-Id: Ia5c7783680e9d8e5d3075078f16a2c15cb6f7a47 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144355 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144457
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/lib/init.cxx8
1 files changed, 6 insertions, 2 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index ee35a421a6c8..ab55ce959330 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1187,6 +1187,8 @@ rtl::Reference<LOKClipboard> forceSetClipboardForCurrentView(LibreOfficeKitDocum
const vcl::Font* FindFont(std::u16string_view rFontName)
{
SfxObjectShell* pDocSh = SfxObjectShell::Current();
+ if (!pDocSh)
+ return nullptr;
const SvxFontListItem* pFonts
= static_cast<const SvxFontListItem*>(pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST));
const FontList* pList = pFonts ? pFonts->GetFontList() : nullptr;
@@ -4190,7 +4192,7 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma
{
// Check if saving a PDF file
OUString aMimeType = lcl_getCurrentDocumentMimeType(pDocument);
- if (pDocSh->IsModified() && aMimeType == "application/pdf")
+ if (pDocSh && pDocSh->IsModified() && aMimeType == "application/pdf")
{
// If we have a PDF file (for saving annotations for example), we need
// to run save-as to the same file as the opened document. Plain save
@@ -4231,7 +4233,7 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma
}), aPropertyValuesVector.end());
// skip saving and tell the result via UNO_COMMAND_RESULT
- if (bDontSaveIfUnmodified && !pDocSh->IsModified())
+ if (bDontSaveIfUnmodified && (!pDocSh || !pDocSh->IsModified()))
{
tools::JsonWriter aJson;
aJson.put("commandName", pCommand);
@@ -4997,6 +4999,8 @@ static char* getLanguages(const char* pCommand)
static char* getFonts (const char* pCommand)
{
SfxObjectShell* pDocSh = SfxObjectShell::Current();
+ if (!pDocSh)
+ return nullptr;
const SvxFontListItem* pFonts = static_cast<const SvxFontListItem*>(
pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST));
const FontList* pList = pFonts ? pFonts->GetFontList() : nullptr;