sc/source/ui/app/transobj.cxx | 12 +++++++----- sc/source/ui/inc/transobj.hxx | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-)
New commits: commit a708a3ec93ea4528224fb5f88efd9fab6f8c8fc2 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Mon Aug 11 17:33:10 2025 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Aug 11 18:58:04 2025 +0200 tdf#167901: Revert "tdf#167075: init doc shell before pasting as png/bmp" This reverts commit eb99e28a92517cac9534a6a52b9266777f735ce5. Reverting for now until I find a better solution, specially towards LibreOffice 25.8.0. The fix for tdf#167075 only works when working with one table but it crashes when working with more than one table, so it's better to have tdf#167075 reproducible than a crash I'll add a test in a follow-up commit Change-Id: I1407c430792f23ae51eafbe39ee52b13217842b2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189379 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx index 10fff1a47b04..fab4131a3095 100644 --- a/sc/source/ui/app/transobj.cxx +++ b/sc/source/ui/app/transobj.cxx @@ -97,18 +97,21 @@ void ScTransferObj::GetAreaSize( const ScDocument& rDoc, SCTAB nTab1, SCTAB nTab nCol = nMaxCol; } -void ScTransferObj::PaintToDev( OutputDevice* pDev, ScDocShell& rDocSh, double nPrintFactor, +void ScTransferObj::PaintToDev( OutputDevice* pDev, ScDocument& rDoc, double nPrintFactor, const ScRange& rBlock ) { + if (!rDoc.GetDocumentShell()) + return; + tools::Rectangle aBound( Point(), pDev->GetOutputSize() ); //! use size from clip area? - ScViewData aViewData(rDocSh, nullptr); + ScViewData aViewData(*rDoc.GetDocumentShell(), nullptr); aViewData.SetTabNo( rBlock.aEnd.Tab() ); aViewData.SetScreen( rBlock.aStart.Col(), rBlock.aStart.Row(), rBlock.aEnd.Col(), rBlock.aEnd.Row() ); - ScPrintFunc::DrawToDev( rDocSh.GetDocument(), pDev, nPrintFactor, aBound, aViewData, false/*bMetaFile*/ ); + ScPrintFunc::DrawToDev( rDoc, pDev, nPrintFactor, aBound, aViewData, false/*bMetaFile*/ ); } ScTransferObj::ScTransferObj( const std::shared_ptr<ScDocument>& pClipDoc, TransferableObjectDescriptor aDesc ) : @@ -434,8 +437,7 @@ bool ScTransferObj::GetData( const datatransfer::DataFlavor& rFlavor, const OUSt pVirtDev->SetOutputSizePixel(aPixelSize); - InitDocShell(true); - PaintToDev( pVirtDev, *m_aDocShellRef, 1.0, aReducedBlock ); + PaintToDev( pVirtDev, *m_pDoc, 1.0, aReducedBlock ); pVirtDev->SetMapMode( MapMode( MapUnit::MapPixel, Point(), aScale, aScale ) ); Bitmap aBmp( pVirtDev->GetBitmap( Point(), pVirtDev->GetOutputSize() ) ); diff --git a/sc/source/ui/inc/transobj.hxx b/sc/source/ui/inc/transobj.hxx index d84f5cb3e0df..4ad4a93be7f7 100644 --- a/sc/source/ui/inc/transobj.hxx +++ b/sc/source/ui/inc/transobj.hxx @@ -58,7 +58,7 @@ private: static void StripRefs( ScDocument& rDoc, SCCOL nStartX, SCROW nStartY, SCCOL nEndX, SCROW nEndY, ScDocument& rDestDoc ); - static void PaintToDev( OutputDevice* pDev, ScDocShell& rDocSh, double nPrintFactor, + static void PaintToDev( OutputDevice* pDev, ScDocument& rDoc, double nPrintFactor, const ScRange& rBlock ); static void GetAreaSize( const ScDocument& rDoc, SCTAB nTab1, SCTAB nTab2, SCROW& nRow, SCCOL& nCol );