ScViewData: simplify constructors
After
commit d8ab8992bd35aedfc1d2b0debebab0d623aa8d09
Author: Xisco Fauli <[email protected]>
Date: Mon May 26 11:06:06 2025 +0200
ScViewData: pass ScDocShell by ref
Change-Id: Ifc661f7e5c841fb017003af53e357218f0aff3f8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185803
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <[email protected]>
diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index 3be7425..5efa161 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -105,7 +105,7 @@
tools::Rectangle aBound( Point(), pDev->GetOutputSize() ); //! use size from clip area?
ScViewData aViewData(rDoc);
ScViewData aViewData(*rDoc.GetDocumentShell(), nullptr);
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 1dcc845..5e8aa03 100644
--- a/sc/source/ui/inc/viewdata.hxx
+++ b/sc/source/ui/inc/viewdata.hxx
@@ -272,11 +272,11 @@
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,11 +346,8 @@
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 d6e2a9d..9d38d1b 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -2684,7 +2684,7 @@
tools::Rectangle aBound( Point(), pDev->GetOutputSize());
ScViewData aViewData(rDoc);
ScViewData aViewData(*rDoc.GetDocumentShell(), nullptr);
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 117bf66..44d582a 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -767,39 +767,15 @@
return eWhichActive;
}
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) :
ScViewData::ScViewData(ScDocShell& rDocSh, ScTabViewShell* pViewSh) :
nPPTX(0.0),
nPPTY(0.0),
maMarkData (pDocSh ? pDocSh->GetDocument().GetSheetLimits() : pDoc->GetSheetLimits()),
maHighlightData (pDocSh ? pDocSh->GetDocument().GetSheetLimits() : pDoc->GetSheetLimits()),
mrDocShell ( pDocSh ? *pDocSh : *pDoc->GetDocumentShell() ),
mrDoc (pDocSh ? pDocSh->GetDocument() : *pDoc),
mrDocShell ( rDocSh ),
mrDoc (rDocSh.GetDocument()),
maMarkData (mrDoc.GetSheetLimits()),
maHighlightData (mrDoc.GetSheetLimits()),
pView ( pViewSh ),
maOptions (pDocSh ? pDocSh->GetDocument().GetViewOptions() : DefaultOptions()),
maOptions (mrDoc.GetViewOptions()),
pSpellingView ( nullptr ),
aLogicMode ( MapUnit::Map100thMM ),
eDefZoomType( SvxZoomType::PERCENT ),
@@ -835,7 +811,6 @@
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),