sc/source/filter/html/htmlpars.cxx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
New commits: commit b25a88677ce2d713b0f454ef2d4cf5a202a005a7 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Mon Mar 18 17:06:33 2024 +0000 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Mar 19 18:53:25 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> (cherry picked from commit 1dc579ae9cd7fcf504016ef510a9484173c9392d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164994 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx index c9d53d93bed7..e563ff60b8ea 100644 --- a/sc/source/filter/html/htmlpars.cxx +++ b/sc/source/filter/html/htmlpars.cxx @@ -1595,13 +1595,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: @@ -1612,12 +1613,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); }