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 fca3aa4eca5c406e882ecd9fdcd354d3938c6902
Author:     Xisco Fauli <[email protected]>
AuthorDate: Thu Nov 27 13:10:32 2025 +0100
Commit:     Xisco Fauli <[email protected]>
CommitDate: Thu Nov 27 22:08:24 2025 +0100

    Revert "ScViewData: simplify constructors"
    
    This reverts commit 52e3b2b040ac54c2a5661e3676b135170f028f50.
    
    Change-Id: I9ab9bc0e6ff909281370bb5d524375398b5a2c9c
    Signed-off-by: Xisco Fauli <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194725
    Tested-by: Jenkins

diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index 908e4836e02f..981786150d3e 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 0aa378dc73cd..6edc8dcdf2da 100644
--- a/sc/source/ui/inc/viewdata.hxx
+++ b/sc/source/ui/inc/viewdata.hxx
@@ -276,11 +276,11 @@ private:
     OUString            msOldWindowState;           // imported window size
 
     ::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;
@@ -354,8 +354,11 @@ private:
 
     bool IsValidTabNumber(SCTAB nTabNumber) 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 b2d71b55be57..a001f4930815 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -2716,7 +2716,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 9b5738263d78..81081e191480 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -763,15 +763,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(sc::ViewOption::GRID, true);
+    aOptions.SetOption(sc::ViewOption::SYNTAX, false);
+    aOptions.SetOption(sc::ViewOption::HEADER, true);
+    aOptions.SetOption(sc::ViewOption::TABCONTROLS, true);
+    aOptions.SetOption(sc::ViewOption::VSCROLL, true);
+    aOptions.SetOption(sc::ViewOption::HSCROLL, true);
+    aOptions.SetOption(sc::ViewOption::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 ),
@@ -807,6 +831,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 ea940b7985921883f8f75009186cae24846b1bd4
Author:     Xisco Fauli <[email protected]>
AuthorDate: Thu Nov 27 13:08:17 2025 +0100
Commit:     Xisco Fauli <[email protected]>
CommitDate: Thu Nov 27 22:08:13 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: Iaf5df6a30bf01db738c3b4eb0f9fee51cf0a957c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194724
    Reviewed-by: Xisco Fauli <[email protected]>
    Tested-by: Jenkins

diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index 2c797fb527b0..908e4836e02f 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 ) );
             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 );
 

Reply via email to