sc/source/ui/app/transobj.cxx | 2 +- sc/source/ui/inc/viewdata.hxx | 7 ++----- sc/source/ui/unoobj/docuno.cxx | 2 +- sc/source/ui/view/viewdata.cxx | 37 ++++++------------------------------- 4 files changed, 10 insertions(+), 38 deletions(-)
New commits: commit 52e3b2b040ac54c2a5661e3676b135170f028f50 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Mon May 26 16:06:12 2025 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue May 27 08:37:57 2025 +0200 ScViewData: simplify constructors After commit d8ab8992bd35aedfc1d2b0debebab0d623aa8d09 Author: Xisco Fauli <xiscofa...@libreoffice.org> 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 <xiscofa...@libreoffice.org> diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx index 3be74258a202..5efa161e749e 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); + 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 1dcc8453cf57..5e8aa03c82c7 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,11 +346,8 @@ 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 d6e2a9d0769d..9d38d1b080ec 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); + 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 117bf66d4be6..44d582a50d20 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -767,39 +767,15 @@ ScSplitPos ScViewDataTable::SanitizeWhichActive() const 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 @@ ScViewData::ScViewData(ScDocument* pDoc, ScDocShell* pDocSh, ScTabViewShell* pVi 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),