sc/source/ui/app/transobj.cxx  |   13 ++++++++-----
 sc/source/ui/inc/transobj.hxx  |    2 +-
 sc/source/ui/inc/viewdata.hxx  |    7 +++++--
 sc/source/ui/unoobj/docuno.cxx |    2 +-
 sc/source/ui/view/viewdata.cxx |   37 +++++++++++++++++++++++++++++++------
 5 files changed, 46 insertions(+), 15 deletions(-)

New commits:
commit 450652fac898abe541478a4c89b88da1902e6e62
Author:     Xisco Fauli <[email protected]>
AuthorDate: Fri Nov 28 12:07:42 2025 +0100
Commit:     Christian Lohmaier <[email protected]>
CommitDate: Mon Dec 1 13:07:08 2025 +0100

    Revert "ScViewData: simplify constructors"
    
    This reverts commit 52e3b2b040ac54c2a5661e3676b135170f028f50.
    
    Change-Id: Iefad29b38b1bd5fd4de46a06e491fb3ecc1cebdd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194768
    Reviewed-by: Christian Lohmaier <[email protected]>
    Tested-by: Jenkins

diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index 112282e65a56..fa451562b077 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -105,7 +105,7 @@ void ScTransferObj::PaintToDev( OutputDevice* pDev, 
ScDocument& rDoc, double nPr
 
     tools::Rectangle aBound( Point(), pDev->GetOutputSize() );      //! use 
size from clip area?
 
-    ScViewData aViewData(*rDoc.GetDocumentShell(), nullptr);
+    ScViewData aViewData(rDoc);
 
     aViewData.SetTabNo( rBlock.aEnd.Tab() );
     aViewData.SetScreen( rBlock.aStart.Col(), rBlock.aStart.Row(),
diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx
index 5e8aa03c82c7..1dcc8453cf57 100644
--- a/sc/source/ui/inc/viewdata.hxx
+++ b/sc/source/ui/inc/viewdata.hxx
@@ -272,11 +272,11 @@ private:
     double              nPPTX, nPPTY;               // Scaling factors
 
     ::std::vector<std::unique_ptr<ScViewDataTable>> maTabData;
-    ScDocShell&         mrDocShell;
-    ScDocument&         mrDoc;
     ScMarkData          maMarkData;
     ScMarkData          maHighlightData;
     ScViewDataTable*    pThisTab;                   // Data of the displayed 
sheet
+    ScDocShell&         mrDocShell;
+    ScDocument&         mrDoc;
     ScTabViewShell*     pView;
     std::unique_ptr<EditView> pEditView[4];               // Belongs to the 
window
     ScViewOptions       maOptions;
@@ -346,8 +346,11 @@ private:
     void          UpdateCurrentTab();
     ScViewDataTable* FetchTableData(SCTAB) const;
 
+    ScViewData(ScDocument* pDoc, ScDocShell* pDocSh, ScTabViewShell* pViewSh);
+
 public:
     ScViewData( ScDocShell& rDocSh, ScTabViewShell* pViewSh );
+    ScViewData( ScDocument& rDoc );
     ~ScViewData() COVERITY_NOEXCEPT_FALSE;
 
     ScDocShell&     GetDocShell() const     { return mrDocShell; }
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 9d38d1b080ec..d6e2a9d0769d 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -2684,7 +2684,7 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, 
const uno::Any& aSelec
 
         tools::Rectangle aBound( Point(), pDev->GetOutputSize());
 
-        ScViewData aViewData(*rDoc.GetDocumentShell(), nullptr);
+        ScViewData aViewData(rDoc);
 
         aViewData.SetTabNo( aRange.aStart.Tab() );
         aViewData.SetScreen( aRange.aStart.Col(), aRange.aStart.Row(), 
aRange.aEnd.Col(), aRange.aEnd.Row() );
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 44d582a50d20..117bf66d4be6 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -767,15 +767,39 @@ ScSplitPos ScViewDataTable::SanitizeWhichActive() const
     return eWhichActive;
 }
 
-ScViewData::ScViewData(ScDocShell& rDocSh, ScTabViewShell* pViewSh) :
+ScViewData::ScViewData(ScDocShell& rDocSh, ScTabViewShell* pViewSh)
+    : ScViewData(nullptr, &rDocSh, pViewSh)
+{
+}
+
+ScViewData::ScViewData(ScDocument& rDoc)
+    : ScViewData(&rDoc, nullptr, nullptr)
+{
+}
+
+static ScViewOptions DefaultOptions()
+{
+    ScViewOptions aOptions;
+    aOptions.SetOption(VOPT_GRID, true);
+    aOptions.SetOption(VOPT_SYNTAX, false);
+    aOptions.SetOption(VOPT_HEADER, true);
+    aOptions.SetOption(VOPT_TABCONTROLS, true);
+    aOptions.SetOption(VOPT_VSCROLL, true);
+    aOptions.SetOption(VOPT_HSCROLL, true);
+    aOptions.SetOption(VOPT_OUTLINER, true);
+    return aOptions;
+}
+
+// Either pDoc or pDocSh must be valid
+ScViewData::ScViewData(ScDocument* pDoc, ScDocShell* pDocSh, ScTabViewShell* 
pViewSh) :
         nPPTX(0.0),
         nPPTY(0.0),
-        mrDocShell   ( rDocSh ),
-        mrDoc       (rDocSh.GetDocument()),
-        maMarkData  (mrDoc.GetSheetLimits()),
-        maHighlightData (mrDoc.GetSheetLimits()),
+        maMarkData  (pDocSh ? pDocSh->GetDocument().GetSheetLimits() : 
pDoc->GetSheetLimits()),
+        maHighlightData (pDocSh ? pDocSh->GetDocument().GetSheetLimits() : 
pDoc->GetSheetLimits()),
+        mrDocShell   ( pDocSh ? *pDocSh : *pDoc->GetDocumentShell() ),
+        mrDoc       (pDocSh ? pDocSh->GetDocument() : *pDoc),
         pView       ( pViewSh ),
-        maOptions   (mrDoc.GetViewOptions()),
+        maOptions   (pDocSh ? pDocSh->GetDocument().GetViewOptions() : 
DefaultOptions()),
         pSpellingView ( nullptr ),
         aLogicMode  ( MapUnit::Map100thMM ),
         eDefZoomType( SvxZoomType::PERCENT ),
@@ -811,6 +835,7 @@ ScViewData::ScViewData(ScDocShell& rDocSh, ScTabViewShell* 
pViewSh) :
         nFormulaBarLines(1),
         m_nLOKPageUpDownOffset( 0 )
 {
+    assert(bool(pDoc) != bool(pDocSh)); // either one or the other, not both
     maMarkData.SelectOneTable(0); // Sync with nTabNo
 
     aScrSize = Size( o3tl::convert(STD_COL_WIDTH * OLE_STD_CELLS_X, 
o3tl::Length::twip, o3tl::Length::px),
commit 894dbe5208bb40b7be11f1880f42c6efaf5a76c4
Author:     Xisco Fauli <[email protected]>
AuthorDate: Fri Nov 28 12:07:31 2025 +0100
Commit:     Christian Lohmaier <[email protected]>
CommitDate: Mon Dec 1 13:06:58 2025 +0100

    tdf#169554: Revert "tdf#167075: init doc shell before pasting as png/bmp
    
    (take 2)"
    
    This reverts commit 671564bce4541244ad3d67b5b98899321176231e.
    
    I can't reproduce the issue on Windows nor on Linux
    but two people confirmed that
    671564bce4541244ad3d67b5b98899321176231e introduced
    the regression in the report
    
    Change-Id: Iead1e460b8280883128b84c1be67209bbb3c6f4c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194767
    Tested-by: Jenkins
    Reviewed-by: Christian Lohmaier <[email protected]>

diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index bac4a53f8962..112282e65a56 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -97,17 +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 ) :
@@ -433,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 ) );
             BitmapEx aBmp = pVirtDev->GetBitmapEx( 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 );
 

Reply via email to