sc/source/filter/xml/xmlexprt.cxx | 54 +++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 26 deletions(-)
New commits: commit 44104bd1025dfe1ed61b48489bc610ecad63861e Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Mon Dec 9 17:34:00 2024 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Tue Dec 10 10:17:39 2024 +0100 cid#1636669 Dereference after null check Change-Id: I56e9669058a79750f83bb99e682e25c3fea2a0bd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178170 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> (cherry picked from commit b012d206350f57bf4268d8cd8528c32647c6b933) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178198 diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 246a7fe8e3a1..e41e3ece60c4 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -5261,36 +5261,38 @@ void ScXMLExport::GetChangeTrackViewSettings(ScDocument& rDoc, uno::Sequence<bea void ScXMLExport::GetViewSettings(uno::Sequence<beans::PropertyValue>& rProps) { - if (GetModel().is()) + if (!GetModel().is()) + return; + + ScModelObj* pDocObj(comphelper::getFromUnoTunnel<ScModelObj>( GetModel() )); + if (!pDocObj) + return; + + SfxObjectShell* pEmbeddedObj = pDocObj->GetEmbeddedObject(); + if (pEmbeddedObj) { rProps.realloc(4); beans::PropertyValue* pProps(rProps.getArray()); - ScModelObj* pDocObj(comphelper::getFromUnoTunnel<ScModelObj>( GetModel() )); - if (pDocObj) - { - SfxObjectShell* pEmbeddedObj = pDocObj->GetEmbeddedObject(); - if (pEmbeddedObj) - { - tools::Rectangle aRect(pEmbeddedObj->GetVisArea()); - sal_uInt16 i(0); - pProps[i].Name = "VisibleAreaTop"; - pProps[i].Value <<= static_cast<sal_Int32>(aRect.Top()); - pProps[++i].Name = "VisibleAreaLeft"; - pProps[i].Value <<= static_cast<sal_Int32>(aRect.Left()); - pProps[++i].Name = "VisibleAreaWidth"; - pProps[i].Value <<= static_cast<sal_Int32>(aRect.getOpenWidth()); - pProps[++i].Name = "VisibleAreaHeight"; - pProps[i].Value <<= static_cast<sal_Int32>(aRect.getOpenHeight()); - } - } - ScDocument* pDoc = pDocObj->GetDocument(); - if (!pDoc) - { - SAL_WARN("sc", "no ScDocument!"); - return; - } - GetChangeTrackViewSettings(*pDoc, rProps); + + tools::Rectangle aRect(pEmbeddedObj->GetVisArea()); + sal_uInt16 i(0); + pProps[i].Name = "VisibleAreaTop"; + pProps[i].Value <<= static_cast<sal_Int32>(aRect.Top()); + pProps[++i].Name = "VisibleAreaLeft"; + pProps[i].Value <<= static_cast<sal_Int32>(aRect.Left()); + pProps[++i].Name = "VisibleAreaWidth"; + pProps[i].Value <<= static_cast<sal_Int32>(aRect.getOpenWidth()); + pProps[++i].Name = "VisibleAreaHeight"; + pProps[i].Value <<= static_cast<sal_Int32>(aRect.getOpenHeight()); + } + + ScDocument* pDoc = pDocObj->GetDocument(); + if (!pDoc) + { + SAL_WARN("sc", "no ScDocument!"); + return; } + GetChangeTrackViewSettings(*pDoc, rProps); } void ScXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>& rProps)