Resolves: tdf#159046 hang on export of math objects in cells
regression from:
commit a9d6b6ef049dd41c91a30c03df0ba38ba8dcada8
Date: Thu Oct 5 14:12:51 2023 +0100
crash copying text + chart to clipboard with InputOptions::TextWysiwyg
of true, the mxPoolHelper is still null when trying to create a
Printer to use as a reference device
revert that, and use a different simpler workaround for the original
crash case.
Change-Id: I74cec710aec033e1652e637ed056dae1c261aa98
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161741
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 072db74..18d007f 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -2705,8 +2705,6 @@ public:
const ScTable* FetchTable( SCTAB nTab ) const;
ScRefCellValue GetRefCellValue( const ScAddress& rPos );
void SharePooledResources( const ScDocument* pSrcDoc );
private:
ScRefCellValue GetRefCellValue( const ScAddress& rPos, sc::ColumnBlockPosition& rBlockPos );
@@ -2716,6 +2714,8 @@ private:
SCSIZE GetPatternCount( SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
void ReservePatternCount( SCTAB nTab, SCCOL nCol, SCSIZE nReserve );
void SharePooledResources( const ScDocument* pSrcDoc );
void EndListeningIntersectedGroup(
sc::EndListeningContext& rCxt, const ScAddress& rPos, std::vector<ScAddress>* pGroupPos );
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index 18f8115..a7d154b 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -113,7 +113,7 @@ void ScDocument::ImplDeleteOptions()
SfxPrinter* ScDocument::GetPrinter(bool bCreateIfNotExist)
{
if ( !mpPrinter && bCreateIfNotExist )
if (!mpPrinter && bCreateIfNotExist && mxPoolHelper)
{
auto pSet =
std::make_unique<SfxItemSetFixed
@@ -201,8 +201,11 @@ OutputDevice* ScDocument::GetRefDevice()
// Create printer like ref device, see Writer...
OutputDevice* pRefDevice = nullptr;
if ( SC_MOD()->GetInputOptions().GetTextWysiwyg() )
{
pRefDevice = GetPrinter();
else
SAL_WARN_IF(!pRefDevice, "sc", "unable to get a printer, fallback to virdev");
}
if (!pRefDevice)
pRefDevice = GetVirtualDevice_100th_mm();
return pRefDevice;
}
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index 9c32230..8a9b489 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -242,9 +242,6 @@ bool ScViewFunc::CopyToClipSingleRange( ScDocument* pClipDoc, const ScRangeList&
if ( pSysClipDoc && bIncludeObjects )
{
bool bAnyOle = rDoc.HasOLEObjectsInArea( aRange );
// There are optional paths (e.g. bAnyOle and InputOptions().GetTextWysiwyg true)
// which dereference pSysClipDoc->mxPoolHelper so ensure that is set here.
pSysClipDoc->SharePooledResources(&rDoc);
// Update ScGlobal::xDrawClipDocShellRef.
ScDrawLayer::SetGlobalDrawPersist( ScTransferObj::SetDrawClipDoc( bAnyOle, pSysClipDoc ) );
}