sc/source/filter/xml/xmlimprt.cxx |    2 -
 sc/source/ui/docshell/docfunc.cxx |    8 +++----
 sc/source/ui/docshell/docsh.cxx   |    6 ++---
 sc/source/ui/docshell/docsh4.cxx  |    8 +++----
 sc/source/ui/docshell/docsh5.cxx  |    6 ++---
 sc/source/ui/docshell/sizedev.cxx |    6 ++---
 sc/source/ui/inc/pfuncache.hxx    |    4 +--
 sc/source/ui/inc/printfun.hxx     |   10 ++++-----
 sc/source/ui/inc/sizedev.hxx      |    2 -
 sc/source/ui/undo/undobase.cxx    |    2 -
 sc/source/ui/undo/undocell.cxx    |    2 -
 sc/source/ui/undo/undostyl.cxx    |    4 +--
 sc/source/ui/undo/undotab.cxx     |    2 -
 sc/source/ui/unoobj/cellsuno.cxx  |    8 +++----
 sc/source/ui/unoobj/docuno.cxx    |   20 +++++++++---------
 sc/source/ui/view/gridwin.cxx     |    4 +--
 sc/source/ui/view/pfuncache.cxx   |   20 +++++++++---------
 sc/source/ui/view/preview.cxx     |   16 +++++++-------
 sc/source/ui/view/prevwsh.cxx     |    2 -
 sc/source/ui/view/printfun.cxx    |   42 +++++++++++++++++++-------------------
 sc/source/ui/view/tabview2.cxx    |    4 +--
 sc/source/ui/view/tabvwsha.cxx    |    6 ++---
 sc/source/ui/view/viewfun2.cxx    |    6 ++---
 sc/source/ui/view/viewfunc.cxx    |    6 ++---
 24 files changed, 98 insertions(+), 98 deletions(-)

New commits:
commit 499edcd805b58d5922463b64f345d576c2347558
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Mon May 26 17:03:57 2025 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon May 26 20:38:35 2025 +0200

    ScPrintFunc, ScPrintFuncCache: pass ScDocShell by ref
    
    Change-Id: If71f61c9b5e75e4035c6066fe07aeb747a3d08bd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185811
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index da80bbb04ac6..c0fe9740f0e0 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -3146,7 +3146,7 @@ void ScDocShell::GetDocStat( ScDocStat& rDocStat )
     if ( pPrinter )
         for ( SCTAB i=0; i<rDocStat.nTableCount; i++ )
             rDocStat.nPageCount = sal::static_int_cast<sal_uInt16>( 
rDocStat.nPageCount +
-                static_cast<sal_uInt16>(ScPrintFunc( this, pPrinter, i 
).GetTotalPages()) );
+                static_cast<sal_uInt16>(ScPrintFunc( *this, pPrinter, i 
).GetTotalPages()) );
 }
 
 std::shared_ptr<SfxDocumentInfoDialog> 
ScDocShell::CreateDocumentInfoDialog(weld::Window* pParent, const SfxItemSet 
&rSet)
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index 172419f0421b..230327f357d3 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -1764,7 +1764,7 @@ void ScDocShell::NotifyStyle( const SfxStyleSheetHint& 
rHint )
                 if (m_pDocument->GetPageStyle(nTab) == aNewName)   // already 
adjusted to new
                 {
                     m_pDocument->PageStyleModified( nTab, aNewName );
-                    ScPrintFunc aPrintFunc( this, GetPrinter(), nTab );
+                    ScPrintFunc aPrintFunc( *this, GetPrinter(), nTab );
                     aPrintFunc.UpdatePages();
                 }
 
@@ -1833,7 +1833,7 @@ void ScDocShell::SetPrintZoom( SCTAB nTab, sal_uInt16 
nScale, sal_uInt16 nPages
     rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALE, nScale ) );
     rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALETOPAGES, nPages ) );
 
-    ScPrintFunc aPrintFunc( this, GetPrinter(), nTab );
+    ScPrintFunc aPrintFunc( *this, GetPrinter(), nTab );
     aPrintFunc.UpdatePages();
     aModificator.SetDocumentModified();
 
@@ -1898,7 +1898,7 @@ bool ScDocShell::AdjustPrintZoom( const ScRange& rRange )
 
         Size aPhysPage;
         tools::Long nHdr, nFtr;
-        ScPrintFunc aOldPrFunc( this, GetPrinter(), nTab );
+        ScPrintFunc aOldPrFunc( *this, GetPrinter(), nTab );
         aOldPrFunc.GetScaleData( aPhysPage, nHdr, nFtr );
         nBlkTwipsY += nHdr + nFtr;
 
@@ -1937,7 +1937,7 @@ void ScDocShell::PageStyleModified( std::u16string_view 
rStyleName, bool bApi )
     {
         bool bWarn = false;
 
-        ScPrintFunc aPrintFunc( this, GetPrinter(), nUseTab );  //! cope 
without CountPages
+        ScPrintFunc aPrintFunc( *this, GetPrinter(), nUseTab );  //! cope 
without CountPages
         if (!aPrintFunc.UpdatePages())                          //  sets 
breaks on all tabs
             bWarn = true;
 
diff --git a/sc/source/ui/inc/pfuncache.hxx b/sc/source/ui/inc/pfuncache.hxx
index 7eddedd258be..499256ca65e2 100644
--- a/sc/source/ui/inc/pfuncache.hxx
+++ b/sc/source/ui/inc/pfuncache.hxx
@@ -84,7 +84,7 @@ struct ScPrintPageLocation
 class ScPrintFuncCache
 {
     ScPrintSelectionStatus  aSelection;
-    ScDocShell*             pDocSh;
+    ScDocShell&             rDocSh;
     tools::Long                    nTotalPages;
     std::vector<tools::Long>       nPages;
     std::vector<tools::Long>       nFirstAttr;
@@ -92,7 +92,7 @@ class ScPrintFuncCache
     bool                    bLocInitialized;
 
 public:
-            ScPrintFuncCache(ScDocShell* pD, const ScMarkData& rMark, 
ScPrintSelectionStatus aStatus,
+            ScPrintFuncCache(ScDocShell& pShell, const ScMarkData& rMark, 
ScPrintSelectionStatus aStatus,
                              Size aPageSize = {}, bool bLandscape = false, 
bool bUse = false);
             ~ScPrintFuncCache();
 
diff --git a/sc/source/ui/inc/printfun.hxx b/sc/source/ui/inc/printfun.hxx
index 736b09def508..2fa314daed79 100644
--- a/sc/source/ui/inc/printfun.hxx
+++ b/sc/source/ui/inc/printfun.hxx
@@ -218,7 +218,7 @@ struct ScPrintState
 class ScPrintFunc
 {
 private:
-    ScDocShell*         pDocShell;
+    ScDocShell&         rDocShell;
     ScDocument&         rDoc;
     VclPtr<SfxPrinter>   pPrinter;
     VclPtr<OutputDevice> pDev;
@@ -307,7 +307,7 @@ private:
     bool                bUsePrintDialogSetting; // use Print dialog setting
 
 public:
-                    ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, 
SCTAB nTab,
+                    ScPrintFunc( ScDocShell& rShell, SfxPrinter* pNewPrinter, 
SCTAB nTab,
                                  tools::Long nPage = 0, tools::Long nDocP = 0,
                                  const ScRange* pArea = nullptr,
                                  const ScPrintOptions* pOptions = nullptr,
@@ -316,7 +316,7 @@ public:
                                  bool bPrintPageLandscape = false,
                                  bool bUsePrintDialogSetting = false );
 
-                    ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter,
+                    ScPrintFunc( ScDocShell& rShell, SfxPrinter* pNewPrinter,
                                 const ScPrintState& rState, const 
ScPrintOptions* pOptions,
                                 Size aPrintPageSize = {},
                                 bool bPrintPageLandscape = false,
@@ -324,12 +324,12 @@ public:
 
                     // ctors for device other than printer - for preview and 
pdf:
 
-                    ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, 
SCTAB nTab,
+                    ScPrintFunc( OutputDevice* pOutDev, ScDocShell& rShell, 
SCTAB nTab,
                                  tools::Long nPage = 0, tools::Long nDocP = 0,
                                  const ScRange* pArea = nullptr,
                                  const ScPrintOptions* pOptions = nullptr );
 
-                    ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell,
+                    ScPrintFunc( OutputDevice* pOutDev, ScDocShell& rShell,
                                  const ScPrintState& rState,
                                  const ScPrintOptions* pOptions, Size 
aPrintPageSize = {},
                                  bool bPrintPageLandscape = false,
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
index 688e55239bab..ac2619b9ff13 100644
--- a/sc/source/ui/undo/undocell.cxx
+++ b/sc/source/ui/undo/undocell.cxx
@@ -607,7 +607,7 @@ void ScUndoPrintZoom::DoChange( bool bUndo )
         rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALE, nScale ) );
         rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALETOPAGES, nPages ) );
 
-        ScPrintFunc aPrintFunc( &rDocShell, rDocShell.GetPrinter(), nTab );
+        ScPrintFunc aPrintFunc( rDocShell, rDocShell.GetPrinter(), nTab );
         aPrintFunc.UpdatePages();
     }
 }
diff --git a/sc/source/ui/undo/undostyl.cxx b/sc/source/ui/undo/undostyl.cxx
index 32bdad13b78b..9c4a0289602b 100644
--- a/sc/source/ui/undo/undostyl.cxx
+++ b/sc/source/ui/undo/undostyl.cxx
@@ -255,7 +255,7 @@ void ScUndoApplyPageStyle::Undo()
     for( const auto& rEntry : maEntries )
     {
         rDocShell.GetDocument().SetPageStyle( rEntry.mnTab, rEntry.maOldStyle 
);
-        ScPrintFunc( &rDocShell, rDocShell.GetPrinter(), rEntry.mnTab 
).UpdatePages();
+        ScPrintFunc( rDocShell, rDocShell.GetPrinter(), rEntry.mnTab 
).UpdatePages();
     }
     EndUndo();
 }
@@ -266,7 +266,7 @@ void ScUndoApplyPageStyle::Redo()
     for( const auto& rEntry : maEntries )
     {
         rDocShell.GetDocument().SetPageStyle( rEntry.mnTab, maNewStyle );
-        ScPrintFunc( &rDocShell, rDocShell.GetPrinter(), rEntry.mnTab 
).UpdatePages();
+        ScPrintFunc( rDocShell, rDocShell.GetPrinter(), rEntry.mnTab 
).UpdatePages();
     }
     EndRedo();
 }
diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx
index bbb3ffece7e1..8d907bfc24bd 100644
--- a/sc/source/ui/undo/undotab.cxx
+++ b/sc/source/ui/undo/undotab.cxx
@@ -1440,7 +1440,7 @@ void ScUndoPrintRange::DoChange(bool bUndo)
     if (pViewShell)
         pViewShell->SetTabNo( nTab );
 
-    ScPrintFunc( &rDocShell, rDocShell.GetPrinter(), nTab ).UpdatePages();
+    ScPrintFunc( rDocShell, rDocShell.GetPrinter(), nTab ).UpdatePages();
 
     if (pViewShell && comphelper::LibreOfficeKit::isActive())
     {
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index c2aa8646c902..0f2c66da6997 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -6608,7 +6608,7 @@ uno::Sequence<sheet::TablePageBreakData> SAL_CALL 
ScTableSheetObj::getColumnPage
         else
         {
             //  update breaks like in ScDocShell::PageStyleModified:
-            ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab );
+            ScPrintFunc aPrintFunc( *pDocSh, pDocSh->GetPrinter(), nTab );
             aPrintFunc.UpdatePages();
         }
 
@@ -6652,7 +6652,7 @@ uno::Sequence<sheet::TablePageBreakData> SAL_CALL 
ScTableSheetObj::getRowPageBre
         else
         {
             //  update breaks like in ScDocShell::PageStyleModified:
-            ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab );
+            ScPrintFunc aPrintFunc( *pDocSh, pDocSh->GetPrinter(), nTab );
             aPrintFunc.UpdatePages();
         }
         return rDoc.GetRowBreakData(nTab);
@@ -6853,7 +6853,7 @@ void ScTableSheetObj::PrintAreaUndo_Impl( 
std::unique_ptr<ScPrintRangeSaver> pOl
                 rDoc.CreatePrintRangeSaver())); // create new ranges
     }
 
-    ScPrintFunc(pDocSh, pDocSh->GetPrinter(), nTab).UpdatePages();
+    ScPrintFunc(*pDocSh, pDocSh->GetPrinter(), nTab).UpdatePages();
     SfxBindings* pBindings = pDocSh->GetViewBindings();
 
     if(pBindings)
@@ -7648,7 +7648,7 @@ void ScTableSheetObj::SetOnePropertyValue( const 
SfxItemPropertyMapEntry* pEntry
             rDoc.SetPageStyle( nTab, aNewStr );
             if (!rDoc.IsImportingXML())
             {
-                ScPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab 
).UpdatePages();
+                ScPrintFunc( *pDocSh, pDocSh->GetPrinter(), nTab 
).UpdatePages();
 
                 SfxBindings* pBindings = pDocSh->GetViewBindings();
                 if (pBindings)
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 741dac02950a..d6e2a9d0769d 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -1893,7 +1893,7 @@ sal_Int32 SAL_CALL ScModelObj::getRendererCount(const 
uno::Any& aSelection,
 
     if (!pPrintFuncCache || !pPrintFuncCache->IsSameSelection(aStatus) || 
bUsePrintDialogSetting)
     {
-        pPrintFuncCache.reset(new ScPrintFuncCache(pDocShell, aMark, 
std::move(aStatus), aPrintPageSize,
+        pPrintFuncCache.reset(new ScPrintFuncCache(*pDocShell, aMark, 
std::move(aStatus), aPrintPageSize,
                                                    bPrintPageLandscape, 
bUsePrintDialogSetting));
     }
     sal_Int32 nPages = pPrintFuncCache->GetPageCount();
@@ -1987,7 +1987,7 @@ uno::Sequence<beans::PropertyValue> SAL_CALL 
ScModelObj::getRenderer( sal_Int32
     {
         if ( !pPrintFuncCache || !pPrintFuncCache->IsSameSelection( aStatus ) )
         {
-            pPrintFuncCache.reset(new ScPrintFuncCache( pDocShell, aMark, 
aStatus ));
+            pPrintFuncCache.reset(new ScPrintFuncCache( *pDocShell, aMark, 
aStatus ));
         }
         nTotalPages = pPrintFuncCache->GetPageCount();
     }
@@ -2027,7 +2027,7 @@ uno::Sequence<beans::PropertyValue> SAL_CALL 
ScModelObj::getRenderer( sal_Int32
         else
         {
             SCTAB const nCurTab = 0;      //! use current sheet from view?
-            ScPrintFunc aDefaultFunc( pDocShell, pDocShell->GetPrinter(), 
nCurTab );
+            ScPrintFunc aDefaultFunc( *pDocShell, pDocShell->GetPrinter(), 
nCurTab );
             Size aTwips = aDefaultFunc.GetPageSize();
             aPageSize.Width = convertTwipToMm100(aTwips.Width());
             aPageSize.Height = convertTwipToMm100(aTwips.Height());
@@ -2136,12 +2136,12 @@ uno::Sequence<beans::PropertyValue> SAL_CALL 
ScModelObj::getRenderer( sal_Int32
 
         std::unique_ptr<ScPrintFunc, o3tl::default_delete<ScPrintFunc>> 
pPrintFunc;
         if (m_pPrintState && m_pPrintState->nPrintTab == nTab)
-            pPrintFunc.reset(new ScPrintFunc(pDocShell, 
pDocShell->GetPrinter(), *m_pPrintState,
+            pPrintFunc.reset(new ScPrintFunc(*pDocShell, 
pDocShell->GetPrinter(), *m_pPrintState,
                                              &aStatus.GetOptions(), 
aPrintPageSize,
                                              bPrintPageLandscape,
                                              bUsePrintDialogSetting));
         else
-            pPrintFunc.reset(new ScPrintFunc(pDocShell, 
pDocShell->GetPrinter(), nTab,
+            pPrintFunc.reset(new ScPrintFunc(*pDocShell, 
pDocShell->GetPrinter(), nTab,
                                              
pPrintFuncCache->GetFirstAttr(nTab), nTotalPages,
                                              pSelRange, &aStatus.GetOptions(), 
nullptr,
                                              aPrintPageSize, 
bPrintPageLandscape,
@@ -2568,7 +2568,7 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, 
const uno::Any& aSelec
 
     if ( !pPrintFuncCache || !pPrintFuncCache->IsSameSelection( aStatus ) )
     {
-        pPrintFuncCache.reset(new ScPrintFuncCache( pDocShell, aMark, aStatus 
));
+        pPrintFuncCache.reset(new ScPrintFuncCache( *pDocShell, aMark, aStatus 
));
     }
     tools::Long nTotalPages = pPrintFuncCache->GetPageCount();
 
@@ -2598,7 +2598,7 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, 
const uno::Any& aSelec
         aNewOptions.SetSkipEmpty(false);
         aStatus.SetOptions(aNewOptions);
 
-        pPrintFuncCache.reset(new ScPrintFuncCache( pDocShell, aMark, aStatus 
));
+        pPrintFuncCache.reset(new ScPrintFuncCache( *pDocShell, aMark, aStatus 
));
         nTotalPages = pPrintFuncCache->GetPageCount();
     }
 
@@ -2743,11 +2743,11 @@ void SAL_CALL ScModelObj::render( sal_Int32 
nSelRenderer, const uno::Any& aSelec
     std::unique_ptr<ScPrintFunc, o3tl::default_delete<ScPrintFunc>> pPrintFunc;
     if (m_pPrintState && m_pPrintState->nPrintTab == nTab
         && ! pSelRange) // tdf#120161 use selection to set required printed 
area
-        pPrintFunc.reset(new ScPrintFunc(pDev, pDocShell, *m_pPrintState, 
&aStatus.GetOptions(),
+        pPrintFunc.reset(new ScPrintFunc(pDev, *pDocShell, *m_pPrintState, 
&aStatus.GetOptions(),
                                          aPrintPageSize, bPrintPageLandscape,
                                          bUsePrintDialogSetting));
     else
-        pPrintFunc.reset(new ScPrintFunc(pDev, pDocShell, nTab, 
pPrintFuncCache->GetFirstAttr(nTab), nTotalPages, pSelRange, 
&aStatus.GetOptions()));
+        pPrintFunc.reset(new ScPrintFunc(pDev, *pDocShell, nTab, 
pPrintFuncCache->GetFirstAttr(nTab), nTotalPages, pSelRange, 
&aStatus.GetOptions()));
 
     pPrintFunc->SetDrawView( aDrawViewKeeper.mpDrawView.get() );
     pPrintFunc->SetRenderFlag( true );
@@ -2798,7 +2798,7 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, 
const uno::Any& aSelec
         {
             bUsePrintDialogSetting = false;
             if (m_pPrintState && m_pPrintState->nPrintTab == nTab && 
!pSelRange)
-                pPrintFunc.reset(new ScPrintFunc(pDev, pDocShell, 
*m_pPrintState,
+                pPrintFunc.reset(new ScPrintFunc(pDev, *pDocShell, 
*m_pPrintState,
                                                  &aStatus.GetOptions(), 
aPrintPageSize,
                                                  bPrintPageLandscape, 
bUsePrintDialogSetting));
         }
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 97617743b3d2..581a7104d3a6 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -2482,7 +2482,7 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt 
)
                         mrViewData.GetDocument().SetPageStyle( 
mrViewData.GetTabNo(),
                                                                
pStyleSheet->GetName() );
 
-                        ScPrintFunc( &mrViewData.GetDocShell(),
+                        ScPrintFunc( mrViewData.GetDocShell(),
                                      
mrViewData.GetViewShell()->GetPrinter(true),
                                      mrViewData.GetTabNo() ).UpdatePages();
 
diff --git a/sc/source/ui/view/pfuncache.cxx b/sc/source/ui/view/pfuncache.cxx
index aa6abd52e7ff..c76497ce3497 100644
--- a/sc/source/ui/view/pfuncache.cxx
+++ b/sc/source/ui/view/pfuncache.cxx
@@ -27,19 +27,19 @@
 #include <prevloc.hxx>
 #include <utility>
 
-ScPrintFuncCache::ScPrintFuncCache(ScDocShell* pD, const ScMarkData& rMark,
+ScPrintFuncCache::ScPrintFuncCache(ScDocShell& rShell, const ScMarkData& rMark,
                                    ScPrintSelectionStatus aStatus, Size 
aPrintPageSize, bool bPrintPageLandscape,
                                    bool bUsePrintDialogSetting)
     :
     aSelection(std::move( aStatus )),
-    pDocSh( pD ),
+    rDocSh( rShell ),
     nTotalPages( 0 ),
     bLocInitialized( false )
 {
     //  page count uses the stored cell widths for the printer anyway,
     //  so ScPrintFunc with the document's printer can be used to count
 
-    SfxPrinter* pPrinter = pDocSh->GetPrinter();
+    SfxPrinter* pPrinter = rDocSh.GetPrinter();
 
     ScRange aRange;
     const ScRange* pSelRange = nullptr;
@@ -49,12 +49,12 @@ ScPrintFuncCache::ScPrintFuncCache(ScDocShell* pD, const 
ScMarkData& rMark,
         pSelRange = &aRange;
     }
 
-    ScDocument& rDoc = pDocSh->GetDocument();
+    ScDocument& rDoc = rDocSh.GetDocument();
     SCTAB nTabCount = rDoc.GetTableCount();
 
     // avoid repeated progress bars if row heights for all sheets are needed
     if ( nTabCount > 1 && rMark.GetSelectCount() == nTabCount )
-        pDocSh->UpdatePendingRowHeights( nTabCount-1, true );
+        rDocSh.UpdatePendingRowHeights( nTabCount-1, true );
 
     SCTAB nTab;
     for ( nTab=0; nTab<nTabCount; nTab++ )
@@ -64,7 +64,7 @@ ScPrintFuncCache::ScPrintFuncCache(ScDocShell* pD, const 
ScMarkData& rMark,
         tools::Long nThisTab = 0;
         if ( rMark.GetTableSelect( nTab ) )
         {
-            ScPrintFunc aFunc(pDocSh, pPrinter, nTab, nAttrPage, 0, pSelRange,
+            ScPrintFunc aFunc(rDocSh, pPrinter, nTab, nAttrPage, 0, pSelRange,
                               &aSelection.GetOptions(), nullptr, 
aPrintPageSize,
                               bPrintPageLandscape, bUsePrintDialogSetting);
             nThisTab = aFunc.GetTotalPages();
@@ -98,13 +98,13 @@ void ScPrintFuncCache::InitLocations( const ScMarkData& 
rMark, OutputDevice* pDe
     tools::Long nRenderer = 0;     // 0-based physical page number across 
sheets
     tools::Long nTabStart = 0;
 
-    ScDocument& rDoc = pDocSh->GetDocument();
+    ScDocument& rDoc = rDocSh.GetDocument();
     SCTAB nTabCount = rDoc.GetTableCount();
     for (SCTAB nTab : rMark)
     {
         if (nTab >= nTabCount)
             break;
-        ScPrintFunc aFunc( pDev, pDocSh, nTab, nFirstAttr[nTab], nTotalPages, 
pSelRange, &aSelection.GetOptions() );
+        ScPrintFunc aFunc( pDev, rDocSh, nTab, nFirstAttr[nTab], nTotalPages, 
pSelRange, &aSelection.GetOptions() );
         aFunc.SetRenderFlag( true );
 
         tools::Long nDisplayStart = GetDisplayStart( nTab );
@@ -152,7 +152,7 @@ bool ScPrintFuncCache::IsSameSelection( const 
ScPrintSelectionStatus& rStatus )
 
 SCTAB ScPrintFuncCache::GetTabForPage( tools::Long nPage ) const
 {
-    ScDocument& rDoc = pDocSh->GetDocument();
+    ScDocument& rDoc = rDocSh.GetDocument();
     SCTAB nTabCount = rDoc.GetTableCount();
     SCTAB nTab = 0;
     while ( nTab < nTabCount && nPage >= nPages[nTab] )
@@ -176,7 +176,7 @@ tools::Long ScPrintFuncCache::GetDisplayStart( SCTAB nTab ) 
const
     //! merge with lcl_GetDisplayStart in preview?
 
     tools::Long nDisplayStart = 0;
-    ScDocument& rDoc = pDocSh->GetDocument();
+    ScDocument& rDoc = rDocSh.GetDocument();
     for (SCTAB i=0; i<nTab; i++)
     {
         if ( rDoc.NeedPageResetAfterTab(i) )
diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx
index f583fc4bd013..b8c9467b0df0 100644
--- a/sc/source/ui/view/preview.cxx
+++ b/sc/source/ui/view/preview.cxx
@@ -250,7 +250,7 @@ void ScPreview::CalcPages()
         tools::Long nAttrPage = i > 0 ? nFirstAttr[i-1] : 1;
 
         tools::Long nThisStart = nTotalPages;
-        ScPrintFunc aPrintFunc( GetOutDev(), pDocShell, i, nAttrPage, 0, 
nullptr, &aOptions );
+        ScPrintFunc aPrintFunc( GetOutDev(), *pDocShell, i, nAttrPage, 0, 
nullptr, &aOptions );
         tools::Long nThisTab = aPrintFunc.GetTotalPages();
         if (!aPrintFunc.HasPrintRange())
             mbHasEmptyRangeTable = true;
@@ -375,9 +375,9 @@ void ScPreview::DoPrint( ScPreviewLocationData* 
pFillLocation )
 
         std::unique_ptr<ScPrintFunc, o3tl::default_delete<ScPrintFunc>> 
pPrintFunc;
         if (bStateValid)
-            pPrintFunc.reset(new ScPrintFunc(GetOutDev(), pDocShell, aState, 
&aOptions));
+            pPrintFunc.reset(new ScPrintFunc(GetOutDev(), *pDocShell, aState, 
&aOptions));
         else
-            pPrintFunc.reset(new ScPrintFunc(GetOutDev(), pDocShell, nTab, 
nFirstAttr[nTab], nTotalPages, nullptr, &aOptions));
+            pPrintFunc.reset(new ScPrintFunc(GetOutDev(), *pDocShell, nTab, 
nFirstAttr[nTab], nTotalPages, nullptr, &aOptions));
 
         pPrintFunc->SetOffset(aOffset);
         pPrintFunc->SetManualZoom(nZoom);
@@ -1121,7 +1121,7 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt )
 
                     if ( ValidTab( nTab ) )
                     {
-                        ScPrintFunc aPrintFunc( GetOutDev(), pDocShell, nTab );
+                        ScPrintFunc aPrintFunc( GetOutDev(), *pDocShell, nTab 
);
                         aPrintFunc.UpdatePages();
                     }
 
@@ -1221,7 +1221,7 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt )
 
                     if ( ValidTab( nTab ) )
                     {
-                        ScPrintFunc aPrintFunc( GetOutDev(), pDocShell, nTab );
+                        ScPrintFunc aPrintFunc( GetOutDev(), *pDocShell, nTab 
);
                         aPrintFunc.UpdatePages();
                     }
 
@@ -1281,7 +1281,7 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt )
                 }
                 if ( ValidTab( nTab ) )
                 {
-                    ScPrintFunc aPrintFunc( GetOutDev(), pDocShell, nTab );
+                    ScPrintFunc aPrintFunc( GetOutDev(), *pDocShell, nTab );
                     aPrintFunc.UpdatePages();
                 }
                 tools::Rectangle aRect(0, 0, 10000, 10000);
@@ -1313,9 +1313,9 @@ void ScPreview::MouseMove( const MouseEvent& rMEvt )
 
         std::unique_ptr<ScPrintFunc, o3tl::default_delete<ScPrintFunc>> 
pPrintFunc;
         if (bStateValid)
-            pPrintFunc.reset(new ScPrintFunc( GetOutDev(), pDocShell, aState, 
&aOptions ));
+            pPrintFunc.reset(new ScPrintFunc( GetOutDev(), *pDocShell, aState, 
&aOptions ));
         else
-            pPrintFunc.reset(new ScPrintFunc( GetOutDev(), pDocShell, nTab, 
nFirstAttr[nTab], nTotalPages, nullptr, &aOptions ));
+            pPrintFunc.reset(new ScPrintFunc( GetOutDev(), *pDocShell, nTab, 
nFirstAttr[nTab], nTotalPages, nullptr, &aOptions ));
 
         nLeftMargin = o3tl::convert(pPrintFunc->GetLeftMargin(), 
o3tl::Length::twip, o3tl::Length::mm100) - aOffset.X();
         nRightMargin = o3tl::convert(pPrintFunc->GetRightMargin(), 
o3tl::Length::twip, o3tl::Length::mm100);
diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx
index e1e9dc2f0c5b..bd36929c7526 100644
--- a/sc/source/ui/view/prevwsh.cxx
+++ b/sc/source/ui/view/prevwsh.cxx
@@ -719,7 +719,7 @@ void ScPreviewShell::Execute( SfxRequest& rReq )
                     const sal_uInt16 nCurrentZoom   = pItem->GetValue();
                     SfxItemSet& rSet            = pStyleSheet->GetItemSet();
                     rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALE, nCurrentZoom ) );
-                    ScPrintFunc aPrintFunc( pDocShell, 
pDocShell->GetPrinter(), nTab );
+                    ScPrintFunc aPrintFunc( *pDocShell, 
pDocShell->GetPrinter(), nTab );
                     aPrintFunc.UpdatePages();
                     rReq.Done();
                 }
diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx
index a1c52b80ecb3..60055b9aed97 100644
--- a/sc/source/ui/view/printfun.cxx
+++ b/sc/source/ui/view/printfun.cxx
@@ -154,7 +154,7 @@ static tools::Long lcl_LineTotal(const 
::editeng::SvxBorderLine* pLine)
 
 void ScPrintFunc::Construct( const ScPrintOptions* pOptions )
 {
-    pDocShell->UpdatePendingRowHeights( nPrintTab );
+    rDocShell.UpdatePendingRowHeights( nPrintTab );
 
     SfxPrinter* pDocPrinter = rDoc.GetPrinter();   // use the printer, even 
for preview
     if (pDocPrinter)
@@ -195,11 +195,11 @@ void ScPrintFunc::Construct( const ScPrintOptions* 
pOptions )
     pPageData = nullptr;       // is only needed for initialisation
 }
 
-ScPrintFunc::ScPrintFunc(ScDocShell* pShell, SfxPrinter* pNewPrinter, SCTAB 
nTab, tools::Long nPage,
+ScPrintFunc::ScPrintFunc(ScDocShell& rShell, SfxPrinter* pNewPrinter, SCTAB 
nTab, tools::Long nPage,
                          tools::Long nDocP, const ScRange* pArea, const 
ScPrintOptions* pOptions,
                          ScPageBreakData* pData, Size aSize, bool 
bPrintLandscape, bool bUsed)
-    :   pDocShell           ( pShell ),
-        rDoc(pDocShell->GetDocument()),
+    :   rDocShell           ( rShell ),
+        rDoc(rDocShell.GetDocument()),
         pPrinter            ( pNewPrinter ),
         pDrawView           ( nullptr ),
         nPrintTab           ( nTab ),
@@ -227,11 +227,11 @@ ScPrintFunc::ScPrintFunc(ScDocShell* pShell, SfxPrinter* 
pNewPrinter, SCTAB nTab
     Construct( pOptions );
 }
 
-ScPrintFunc::ScPrintFunc(ScDocShell* pShell, SfxPrinter* pNewPrinter, const 
ScPrintState& rState,
+ScPrintFunc::ScPrintFunc(ScDocShell& rShell, SfxPrinter* pNewPrinter, const 
ScPrintState& rState,
                          const ScPrintOptions* pOptions, Size aSize, bool 
bPrintLandscape,
                          bool bUsed)
-    :   pDocShell           ( pShell ),
-        rDoc(pDocShell->GetDocument()),
+    :   rDocShell           ( rShell ),
+        rDoc(rDocShell.GetDocument()),
         pPrinter            ( pNewPrinter ),
         pDrawView           ( nullptr ),
         pUserArea           ( nullptr ),
@@ -264,11 +264,11 @@ ScPrintFunc::ScPrintFunc(ScDocShell* pShell, SfxPrinter* 
pNewPrinter, const ScPr
     Construct( pOptions );
 }
 
-ScPrintFunc::ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, SCTAB 
nTab,
+ScPrintFunc::ScPrintFunc( OutputDevice* pOutDev, ScDocShell& rShell, SCTAB 
nTab,
                             tools::Long nPage, tools::Long nDocP, const 
ScRange* pArea,
                             const ScPrintOptions* pOptions )
-    :   pDocShell           ( pShell ),
-        rDoc(pDocShell->GetDocument()),
+    :   rDocShell           ( rShell ),
+        rDoc(rDocShell.GetDocument()),
         pPrinter            ( nullptr ),
         pDrawView           ( nullptr ),
         nPrintTab           ( nTab ),
@@ -295,11 +295,11 @@ ScPrintFunc::ScPrintFunc( OutputDevice* pOutDev, 
ScDocShell* pShell, SCTAB nTab,
     Construct( pOptions );
 }
 
-ScPrintFunc::ScPrintFunc(OutputDevice* pOutDev, ScDocShell* pShell, const 
ScPrintState& rState,
+ScPrintFunc::ScPrintFunc(OutputDevice* pOutDev, ScDocShell& rShell, const 
ScPrintState& rState,
                          const ScPrintOptions* pOptions, Size aSize, bool 
bPrintLandscape,
                          bool bUsed)
-    :   pDocShell           ( pShell ),
-        rDoc(pDocShell->GetDocument()),
+    :   rDocShell           ( rShell ),
+        rDoc(rDocShell.GetDocument()),
         pPrinter            ( nullptr ),
         pDrawView           ( nullptr ),
         pUserArea           ( nullptr ),
@@ -1095,12 +1095,12 @@ void ScPrintFunc::InitParam( const ScPrintOptions* 
pOptions )
 
     SetDateTime( DateTime( DateTime::SYSTEM ) );
 
-    if( pDocShell->getDocProperties()->getTitle().getLength() != 0 )
-        aFieldData.aTitle = pDocShell->getDocProperties()->getTitle();
+    if( rDocShell.getDocProperties()->getTitle().getLength() != 0 )
+        aFieldData.aTitle = rDocShell.getDocProperties()->getTitle();
     else
-        aFieldData.aTitle = pDocShell->GetTitle();
+        aFieldData.aTitle = rDocShell.GetTitle();
 
-    const INetURLObject& rURLObj = pDocShell->GetMedium()->GetURLObject();
+    const INetURLObject& rURLObj = rDocShell.GetMedium()->GetURLObject();
     aFieldData.aLongDocName = rURLObj.GetMainURL( 
INetURLObject::DecodeMechanism::Unambiguous );
     if ( !aFieldData.aLongDocName.isEmpty() )
         aFieldData.aShortDocName = 
rURLObj.GetLastName(INetURLObject::DecodeMechanism::Unambiguous);
@@ -1327,8 +1327,8 @@ void ScPrintFunc::DrawBorder( tools::Long nScrX, 
tools::Long nScrY, tools::Long
             else
                 pRefDev = rDoc.GetPrinter();   // use printer also for preview
             OUString referer;
-            if (pDocShell->HasName()) {
-                referer = pDocShell->GetMedium()->GetName();
+            if (rDocShell.HasName()) {
+                referer = rDocShell.GetMedium()->GetName();
             }
             lcl_DrawGraphic(*pBackground, *pDev, pRefDev, aFrameRect, 
aFrameRect, referer);
         }
@@ -2476,7 +2476,7 @@ bool ScPrintFunc::UpdatePages()
 
             //  set breaks
             ResetBreaks(nTab);
-            pDocShell->PostPaint(0,0,nTab,rDoc.MaxCol(),rDoc.MaxRow(),nTab, 
PaintPartFlags::Grid);
+            rDocShell.PostPaint(0,0,nTab,rDoc.MaxCol(),rDoc.MaxRow(),nTab, 
PaintPartFlags::Grid);
         }
 
     return true;
@@ -2628,7 +2628,7 @@ void ScPrintFunc::InitModes()               // set 
MapModes from  nZoom etc.
 
     if ( !pPrinter && !bIsRender )                          // adjust scale 
for preview
     {
-        double nFact = pDocShell->GetOutputFactor();
+        double nFact = rDocShell.GetOutputFactor();
         aHorFract = Fraction( static_cast<tools::Long>( nEffZoom / nFact ), 
10000 );
     }
 
diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx
index 289995045973..63e335ddbc0f 100644
--- a/sc/source/ui/view/tabview2.cxx
+++ b/sc/source/ui/view/tabview2.cxx
@@ -1519,7 +1519,7 @@ sal_uInt16 ScTabView::CalcZoom( SvxZoomType eType, 
sal_uInt16 nOldZoom )
 
                     if ( pStyleSheet )
                     {
-                        ScPrintFunc aPrintFunc( &aViewData.GetDocShell(),
+                        ScPrintFunc aPrintFunc( aViewData.GetDocShell(),
                                                 
aViewData.GetViewShell()->GetPrinter(true),
                                                 nCurTab );
 
@@ -1690,7 +1690,7 @@ void ScTabView::UpdatePageBreakData( bool bForcePaint )
             nCount = 1;
         pNewData.reset( new ScPageBreakData(nCount) );
 
-        ScPrintFunc aPrintFunc( &rDocSh, rDocSh.GetPrinter(), nTab, 
0,0,nullptr, nullptr, pNewData.get() );
+        ScPrintFunc aPrintFunc( rDocSh, rDocSh.GetPrinter(), nTab, 
0,0,nullptr, nullptr, pNewData.get() );
         // ScPrintFunc fills the PageBreakData in ctor
         if ( nCount > 1 )
         {
diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx
index b09549bf321b..c96e9494d49d 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -1276,7 +1276,7 @@ void ScTabViewShell::ExecStyle( SfxRequest& rReq )
                     {
                         if ( rDoc.RemovePageStyleInUse( pStyleSheet->GetName() 
) )
                         {
-                            ScPrintFunc( &rDocSh, GetPrinter(true), nCurTab 
).UpdatePages();
+                            ScPrintFunc( rDocSh, GetPrinter(true), nCurTab 
).UpdatePages();
                             rBindings.Invalidate( SID_STATUS_PAGESTYLE );
                             rBindings.Invalidate( FID_RESET_PRINTZOOM );
                         }
@@ -1318,7 +1318,7 @@ void ScTabViewShell::ExecStyle( SfxRequest& rReq )
                             if ( aOldName != aStyleName )
                             {
                                 rDoc.SetPageStyle( rTab, aStyleName );
-                                ScPrintFunc( &rDocSh, GetPrinter(true), rTab 
).UpdatePages();
+                                ScPrintFunc( rDocSh, GetPrinter(true), rTab 
).UpdatePages();
                                 if( !pUndoAction )
                                     pUndoAction.reset(new 
ScUndoApplyPageStyle( rDocSh, aStyleName ));
                                 pUndoAction->AddSheetAction( rTab, aOldName );
@@ -1362,7 +1362,7 @@ void ScTabViewShell::ExecStyle( SfxRequest& rReq )
 
                         // If being used -> Update
                         if ( bUsed )
-                            ScPrintFunc( &rDocSh, GetPrinter(true), nInTab 
).UpdatePages();
+                            ScPrintFunc( rDocSh, GetPrinter(true), nInTab 
).UpdatePages();
 
                         xNewData->InitFromStyle( pStyleSheet );
                         bAddUndo = true;
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 35d42b0f3e8b..39f3b6a5fd9c 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -1152,7 +1152,7 @@ void ScViewFunc::SetPrintRanges( bool bEntireSheet, const 
OUString* pPrint,
     //  update page breaks
 
     for (const auto& rTab : rMark)
-        ScPrintFunc( &rDocSh, rDocSh.GetPrinter(), rTab ).UpdatePages();
+        ScPrintFunc( rDocSh, rDocSh.GetPrinter(), rTab ).UpdatePages();
 
     SfxBindings& rBindings = GetViewData().GetBindings();
     rBindings.Invalidate( SID_DELETE_PRINTAREA );
commit 1152da8289e5979063d0718bd23c9560197e9c0f
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Mon May 26 16:37:03 2025 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon May 26 20:38:27 2025 +0200

    ScSizeDeviceProvider: pass ScDocShell by ref
    
    fter
    commit d8ab8992bd35aedfc1d2b0debebab0d623aa8d09
    Author: Xisco Fauli <xiscofa...@libreoffice.org>
    Date:   Mon May 26 11:06:06 2025 +0200
    
        ScViewData: pass ScDocShell by ref
    
    Change-Id: Iea78d6d1dab657a0b526d58dd8519873c43ae272
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185809
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/source/filter/xml/xmlimprt.cxx 
b/sc/source/filter/xml/xmlimprt.cxx
index 4e72aa790d76..01ff78ec667f 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -1432,7 +1432,7 @@ void SAL_CALL ScXMLImport::endDocument()
                 mpDoc->UnlockAdjustHeight();
             }
 
-            ScSizeDeviceProvider aProv(mpDoc->GetDocumentShell());
+            ScSizeDeviceProvider aProv(*mpDoc->GetDocumentShell());
             ScDocRowHeightUpdater aUpdater(*mpDoc, aProv.GetDevice(), 
aProv.GetPPTX(), aProv.GetPPTY(), &maRecalcRowRanges);
             aUpdater.update();
 
diff --git a/sc/source/ui/docshell/docfunc.cxx 
b/sc/source/ui/docshell/docfunc.cxx
index 4565fde4b192..d5444001390f 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -168,7 +168,7 @@ bool ScDocFunc::AdjustRowHeight( const ScRange& rRange, 
bool bPaint, bool bApi )
     SCROW nStartRow = rRange.aStart.Row();
     SCROW nEndRow   = rRange.aEnd.Row();
 
-    ScSizeDeviceProvider aProv( &rDocShell );
+    ScSizeDeviceProvider aProv( rDocShell );
     Fraction aOne(1,1);
 
     sc::RowHeightContext aCxt(rDoc.MaxRow(), aProv.GetPPTX(), aProv.GetPPTY(), 
aOne, aOne, aProv.GetDevice());
@@ -678,7 +678,7 @@ tools::Long ScDocShell::GetTwipWidthHint(const ScAddress& 
rPos)
     if (!pViewData)
         return -1;
 
-    ScSizeDeviceProvider aProv(this);
+    ScSizeDeviceProvider aProv(*this);
     Fraction aZoomX, aZoomY;
     double nPPTX, nPPTY;
     pViewData->setupSizeDeviceProviderForColWidth(aProv, aZoomX, aZoomY, 
nPPTX, nPPTY);
@@ -3660,7 +3660,7 @@ bool ScDocFunc::SetTabBgColor(
 
 static sal_uInt16 lcl_GetOptimalColWidth( ScDocShell& rDocShell, SCCOL nCol, 
SCTAB nTab )
 {
-    ScSizeDeviceProvider aProv(&rDocShell);
+    ScSizeDeviceProvider aProv(rDocShell);
     OutputDevice* pDev = aProv.GetDevice();         // has pixel MapMode
     double nPPTX = aProv.GetPPTX();
     double nPPTY = aProv.GetPPTY();
@@ -3756,7 +3756,7 @@ bool ScDocFunc::SetWidthOrHeight(
                     }
                 }
 
-                ScSizeDeviceProvider aProv( &rDocShell );
+                ScSizeDeviceProvider aProv( rDocShell );
                 Fraction aOne(1,1);
                 sc::RowHeightContext aCxt(rDoc.MaxRow(), aProv.GetPPTX(), 
aProv.GetPPTY(), aOne, aOne, aProv.GetDevice());
                 aCxt.setForceAutoSize(bAll);
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 9d6c8aa614c4..da80bbb04ac6 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -1749,14 +1749,14 @@ bool ScDocShell::ConvertFrom( SfxMedium& rMedium )
         if (bSetRowHeights)
         {
             // Update all rows in all tables.
-            ScSizeDeviceProvider aProv(this);
+            ScSizeDeviceProvider aProv(*this);
             ScDocRowHeightUpdater aUpdater(*m_pDocument, aProv.GetDevice(), 
aProv.GetPPTX(), aProv.GetPPTY(), nullptr);
             aUpdater.update();
         }
         else if (!aRecalcRowRangesArray.empty())
         {
             // Update only specified row ranges for better performance.
-            ScSizeDeviceProvider aProv(this);
+            ScSizeDeviceProvider aProv(*this);
             ScDocRowHeightUpdater aUpdater(*m_pDocument, aProv.GetDevice(), 
aProv.GetPPTX(), aProv.GetPPTY(), &aRecalcRowRangesArray);
             aUpdater.update();
         }
diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx
index c2c9dc95b222..ab4cdd7b62cc 100644
--- a/sc/source/ui/docshell/docsh5.cxx
+++ b/sc/source/ui/docshell/docsh5.cxx
@@ -404,7 +404,7 @@ void ScDocShell::CancelAutoDBRange()
 
 bool ScDocShell::AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab )
 {
-    ScSizeDeviceProvider aProv(this);
+    ScSizeDeviceProvider aProv(*this);
     Fraction aZoom(1,1);
     sc::RowHeightContext aCxt(m_pDocument->MaxRow(), aProv.GetPPTX(), 
aProv.GetPPTY(), aZoom, aZoom, aProv.GetDevice());
     bool bChange = m_pDocument->SetOptimalHeight(aCxt, nStartRow,nEndRow, 
nTab, true);
@@ -424,7 +424,7 @@ void ScDocShell::UpdateAllRowHeights( const ScMarkData* 
pTabMark )
 {
     // update automatic row heights
 
-    ScSizeDeviceProvider aProv(this);
+    ScSizeDeviceProvider aProv(*this);
     Fraction aZoom(1,1);
     sc::RowHeightContext aCxt(m_pDocument->MaxRow(), aProv.GetPPTX(), 
aProv.GetPPTY(), aZoom, aZoom, aProv.GetDevice());
     m_pDocument->UpdateAllRowHeights(aCxt, pTabMark);
@@ -433,7 +433,7 @@ void ScDocShell::UpdateAllRowHeights( const ScMarkData* 
pTabMark )
 void ScDocShell::UpdateAllRowHeights(const bool bOnlyUsedRows)
 {
     // update automatic row heights on all sheets using the newer 
ScDocRowHeightUpdater
-    ScSizeDeviceProvider aProv(this);
+    ScSizeDeviceProvider aProv(*this);
     ScDocRowHeightUpdater aUpdater(*m_pDocument, aProv.GetDevice(), 
aProv.GetPPTX(),
                                    aProv.GetPPTY(), nullptr);
     aUpdater.update(bOnlyUsedRows);
diff --git a/sc/source/ui/docshell/sizedev.cxx 
b/sc/source/ui/docshell/sizedev.cxx
index c6e040bbb654..a288931a5968 100644
--- a/sc/source/ui/docshell/sizedev.cxx
+++ b/sc/source/ui/docshell/sizedev.cxx
@@ -25,12 +25,12 @@
 #include <scmod.hxx>
 #include <inputopt.hxx>
 
-ScSizeDeviceProvider::ScSizeDeviceProvider( ScDocShell* pDocSh )
+ScSizeDeviceProvider::ScSizeDeviceProvider( ScDocShell& rDocSh )
 {
     bool bTextWysiwyg = ScModule::get()->GetInputOptions().GetTextWysiwyg();
     if ( bTextWysiwyg )
     {
-        pDevice = pDocSh->GetPrinter();
+        pDevice = rDocSh.GetPrinter();
         bOwner = false;
 
         aOldMapMode = pDevice->GetMapMode();
@@ -49,7 +49,7 @@ ScSizeDeviceProvider::ScSizeDeviceProvider( ScDocShell* 
pDocSh )
     nPPTY = aLogic.Y() / 1000.0;
 
     if ( !bTextWysiwyg )
-        nPPTX /= pDocSh->GetOutputFactor();
+        nPPTX /= rDocSh.GetOutputFactor();
 }
 
 ScSizeDeviceProvider::~ScSizeDeviceProvider()
diff --git a/sc/source/ui/inc/sizedev.hxx b/sc/source/ui/inc/sizedev.hxx
index 8bf98be8ef0e..08aa4033887b 100644
--- a/sc/source/ui/inc/sizedev.hxx
+++ b/sc/source/ui/inc/sizedev.hxx
@@ -34,7 +34,7 @@ class ScSizeDeviceProvider
     MapMode              aOldMapMode;
 
 public:
-                ScSizeDeviceProvider( ScDocShell* pDocSh );
+                ScSizeDeviceProvider( ScDocShell& rDocSh );
                 ~ScSizeDeviceProvider();
 
     OutputDevice*   GetDevice() const   { return pDevice.get(); }
diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx
index a31a239b24fd..799699831d54 100644
--- a/sc/source/ui/undo/undobase.cxx
+++ b/sc/source/ui/undo/undobase.cxx
@@ -290,7 +290,7 @@ bool ScBlockUndo::AdjustHeight()
 {
     ScDocument& rDoc = rDocShell.GetDocument();
 
-    ScSizeDeviceProvider aProv(&rDocShell);
+    ScSizeDeviceProvider aProv(rDocShell);
     Fraction aZoomX( 1, 1 );
     Fraction aZoomY = aZoomX;
     double nPPTX, nPPTY;
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 9d531f98b6f8..97617743b3d2 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5790,7 +5790,7 @@ std::shared_ptr<ScFieldEditEngine> createEditEngine( 
ScDocShell& rDocSh, const S
     ScDocument& rDoc = rDocSh.GetDocument();
 
     auto pEngine = std::make_shared<ScFieldEditEngine>(&rDoc, 
rDoc.GetEditPool());
-    ScSizeDeviceProvider aProv(&rDocSh);
+    ScSizeDeviceProvider aProv(rDocSh);
     pEngine->SetRefDevice(aProv.GetDevice());
     pEngine->SetRefMapMode(MapMode(MapUnit::Map100thMM));
     SfxItemSet aDefault(pEngine->GetEmptyItemSet());
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 6aa0a342007a..35d42b0f3e8b 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -139,7 +139,7 @@ bool ScViewFunc::AdjustBlockHeight( bool bPaint, 
ScMarkData* pMarkData )
     Fraction aZoomX = GetViewData().GetZoomX();
     Fraction aZoomY = GetViewData().GetZoomY();
 
-    ScSizeDeviceProvider aProv(&rDocSh);
+    ScSizeDeviceProvider aProv(rDocSh);
     if (aProv.IsPrinter())
     {
         nPPTX = aProv.GetPPTX();
@@ -209,7 +209,7 @@ bool ScViewFunc::AdjustRowHeight( SCROW nStartRow, SCROW 
nEndRow, bool bApi )
     if (nStartRow == nEndRow)
         nOldPixel = static_cast<sal_uInt16>(rDoc.GetRowHeight(nStartRow,nTab) 
* nPPTY);
 
-    ScSizeDeviceProvider aProv(&rDocSh);
+    ScSizeDeviceProvider aProv(rDocSh);
     if (aProv.IsPrinter())
     {
         nPPTX = aProv.GetPPTX();
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 891cdc34b656..b00eee599775 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -330,7 +330,7 @@ sal_uInt16 ScViewFunc::GetOptimalColWidth( SCCOL nCol, 
SCTAB nTab, bool bFormula
     ScDocument& rDoc = rDocSh.GetDocument();
     ScMarkData& rMark = GetViewData().GetMarkData();
 
-    ScSizeDeviceProvider aProv(&rDocSh);
+    ScSizeDeviceProvider aProv(rDocSh);
 
     Fraction aZoomX, aZoomY;
     double nPPTX, nPPTY;
@@ -2432,7 +2432,7 @@ void ScViewFunc::SetWidthOrHeight(
                     Fraction aZoomX = GetViewData().GetZoomX();
                     Fraction aZoomY = GetViewData().GetZoomY();
 
-                    ScSizeDeviceProvider aProv(&rDocSh);
+                    ScSizeDeviceProvider aProv(rDocSh);
                     if (aProv.IsPrinter())
                     {
                         nPPTX = aProv.GetPPTX();
@@ -2693,7 +2693,7 @@ void ScViewFunc::ModifyCellSize( ScDirection eDir, bool 
bOptimal )
                 Fraction aZoomX = GetViewData().GetZoomX();
                 Fraction aZoomY = GetViewData().GetZoomY();
 
-                ScSizeDeviceProvider aProv(&rDocSh);
+                ScSizeDeviceProvider aProv(rDocSh);
                 if (aProv.IsPrinter())
                 {
                     nPPTX = aProv.GetPPTX();

Reply via email to