sc/source/filter/html/htmlpars.cxx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
New commits: commit 1dc579ae9cd7fcf504016ef510a9484173c9392d Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Mon Mar 18 17:06:33 2024 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Mon Mar 18 20:30:03 2024 +0100 calc html filter ScDocShell* deref for document properties ScDocShell is optional in other parts of this filter Change-Id: If219cfa6ef737a9695b85bf6db5d45e9750a7ed9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164974 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx index 830dac6f6615..846feda1ca85 100644 --- a/sc/source/filter/html/htmlpars.cxx +++ b/sc/source/filter/html/htmlpars.cxx @@ -1605,13 +1605,14 @@ void ScHTMLLayoutParser::ProcToken( HtmlImportInfo* pInfo ) switch ( pInfo->nToken ) { case HtmlTokenId::META: + if (ScDocShell* pDocSh = mpDoc->GetDocumentShell()) { HTMLParser* pParser = static_cast<HTMLParser*>(pInfo->pParser); uno::Reference<document::XDocumentPropertiesSupplier> xDPS( - static_cast<cppu::OWeakObject*>(mpDoc->GetDocumentShell()->GetModel()), uno::UNO_QUERY_THROW); + static_cast<cppu::OWeakObject*>(pDocSh->GetModel()), uno::UNO_QUERY_THROW); pParser->ParseMetaOptions( xDPS->getDocumentProperties(), - mpDoc->GetDocumentShell()->GetHeaderAttributes() ); + pDocSh->GetHeaderAttributes() ); } break; case HtmlTokenId::TITLE_ON: @@ -1622,12 +1623,13 @@ void ScHTMLLayoutParser::ProcToken( HtmlImportInfo* pInfo ) break; case HtmlTokenId::TITLE_OFF: { - if ( bInTitle && !aString.isEmpty() ) + ScDocShell* pDocSh = mpDoc->GetDocumentShell(); + if ( bInTitle && !aString.isEmpty() && pDocSh ) { // Remove blanks from line breaks aString = aString.trim(); uno::Reference<document::XDocumentPropertiesSupplier> xDPS( - static_cast<cppu::OWeakObject*>(mpDoc->GetDocumentShell()->GetModel()), + static_cast<cppu::OWeakObject*>(pDocSh->GetModel()), uno::UNO_QUERY_THROW); xDPS->getDocumentProperties()->setTitle(aString); }