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 93e23b841e1c461f37c9a4f72462b5b2805a6300
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Sun Jan 7 13:37:57 2024 +0000
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Jan 9 09:47:21 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/+/161741
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 072db744c01b..18d007f02cec 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 18f8115f7a73..a7d154bfdf76 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 9c32230275f4..8a9b489833fc 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