sc/inc/document.hxx              |    4 ++--
 sc/source/core/data/documen8.cxx |    7 +++++--
 sc/source/ui/view/viewfun3.cxx   |    3 ---
 3 files changed, 7 insertions(+), 7 deletions(-)

New commits:
commit 3d8ab97760049c64b7bbadde1a0b89ef9acde690
Author:     Caolán McNamara <[email protected]>
AuthorDate: Sun Jan 7 13:37:57 2024 +0000
Commit:     Caolán McNamara <[email protected]>
CommitDate: Sun Jan 7 20:07:34 2024 +0100

    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/+/161740
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 03b070b3ed90..5a92140973a5 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -2712,8 +2712,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 );
 
@@ -2723,6 +2721,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 2163afc52446..e2522605c9c5 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -114,7 +114,7 @@ void ScDocument::ImplDeleteOptions()
 
 SfxPrinter* ScDocument::GetPrinter(bool bCreateIfNotExist)
 {
-    if ( !mpPrinter && bCreateIfNotExist )
+    if (!mpPrinter && bCreateIfNotExist && mxPoolHelper)
     {
         auto pSet =
             std::make_unique<SfxItemSetFixed
@@ -202,8 +202,11 @@ OutputDevice* ScDocument::GetRefDevice(bool bForceVirtDev)
     // Create printer like ref device, see Writer...
     OutputDevice* pRefDevice = nullptr;
     if ( !bForceVirtDev && 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 8aea1ebbd66d..7a6403237b89 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 ) );
     }

Reply via email to