sc/inc/viewopti.hxx | 30 ++++++++++++++++++++---------- sc/source/core/data/patattr.cxx | 5 ++--- sc/source/core/tool/viewopti.cxx | 15 +++++++++++---- sc/source/ui/app/scmod.cxx | 15 +++++++-------- sc/source/ui/inc/tabview.hxx | 4 ++++ sc/source/ui/unoobj/docuno.cxx | 19 +++++++------------ sc/source/ui/view/gridwin4.cxx | 5 ++--- sc/source/ui/view/tabview.cxx | 7 +++++++ sc/source/ui/view/tabvwshc.cxx | 5 ++--- 9 files changed, 62 insertions(+), 43 deletions(-)
New commits: commit 754cd4309b5b055a05b57f5d25ed128c439f460b Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Mon Jan 8 15:04:07 2024 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Mon Jan 8 20:46:46 2024 +0100 Related: cool#7951 don't invalidate when creating a new view In writer the ViewOptions are in the ViewShell and are copied when a new ViewShell is created from that ViewShell so the dark/light-mode and doc color are the same in a new view as the old view. But in calc the ViewOptions exist in both the ViewShell and Document and a new ViewShell copies from the document not the old ViewShell. Setting the ViewOptions of a ViewShell in calc doesn't have an effect of having the same setting in a new view in calc. So if you create a new view from an old view you got the ViewOptions of the document, whose light/dark mode remained as "Default" when the old view dark/light more was set. So the mismatch triggered an invalidate. These additions to ViewOptions are relatively new in calc, and the desire is to get the same behaviour in calc as in writer, so move the new additions to a separate class that belongs to the ViewShell and copy them from the current ViewShell when creating a new ViewShell. Change-Id: Ie4b1dbb0437763ec4c8d067179c1fbef520161e6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161791 Reviewed-by: Michael Meeks <michael.me...@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sc/inc/viewopti.hxx b/sc/inc/viewopti.hxx index 4e00e068b134..7961cbc2126c 100644 --- a/sc/inc/viewopti.hxx +++ b/sc/inc/viewopti.hxx @@ -75,6 +75,26 @@ public: bool operator!= ( const ScGridOptions& rOpt ) const { return !(operator==(rOpt)); } }; +class SC_DLLPUBLIC ScViewRenderingOptions +{ +public: + ScViewRenderingOptions(); + + const OUString& GetColorSchemeName() const { return sColorSchemeName; } + void SetColorSchemeName( const OUString& rName ) { sColorSchemeName = rName; } + + const Color& GetDocColor() const { return aDocCol; } + void SetDocColor(const Color& rDocColor) { aDocCol = rDocColor; } + + bool operator==(const ScViewRenderingOptions& rOther) const; + +private: + // The name of the color scheme + OUString sColorSchemeName; + // The background color of the document + Color aDocCol; +}; + // Options - View class SC_DLLPUBLIC ScViewOptions @@ -99,12 +119,6 @@ public: void SetGridOptions( const ScGridOptions& rNew ) { aGridOpt = rNew; } std::unique_ptr<SvxGridItem> CreateGridItem() const; - const OUString& GetColorSchemeName() const { return sColorSchemeName; } - void SetColorSchemeName( const OUString& rName ) { sColorSchemeName = rName; } - - const Color& GetDocColor() const { return aDocCol; } - void SetDocColor(const Color& rDocColor) { aDocCol = rDocColor; } - ScViewOptions& operator= ( const ScViewOptions& rCpy ); bool operator== ( const ScViewOptions& rOpt ) const; bool operator!= ( const ScViewOptions& rOpt ) const { return !(operator==(rOpt)); } @@ -115,10 +129,6 @@ private: Color aGridCol; OUString aGridColName; ScGridOptions aGridOpt; - // The name of the color scheme - OUString sColorSchemeName = "Default"; - // The background color of the document - Color aDocCol; }; // Item for the options dialog - View diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx index bd4f54ab8c5e..34cfa1c52175 100644 --- a/sc/source/core/data/patattr.cxx +++ b/sc/source/core/data/patattr.cxx @@ -508,9 +508,8 @@ void ScPatternAttr::fillColor(model::ComplexColor& rComplexColor, const SfxItemS ScTabViewShell* pViewShell = dynamic_cast<ScTabViewShell*>(pSfxViewShell); if (pViewShell) { - const ScViewData& pViewData = pViewShell->GetViewData(); - const ScViewOptions& aViewOptions = pViewData.GetOptions(); - aBackColor = aViewOptions.GetDocColor(); + const ScViewRenderingOptions& rViewRenderingOptions = pViewShell->GetViewRenderingData(); + aBackColor = rViewRenderingOptions.GetDocColor(); } } } diff --git a/sc/source/core/tool/viewopti.cxx b/sc/source/core/tool/viewopti.cxx index 849d15d2412e..30606bd59b91 100644 --- a/sc/source/core/tool/viewopti.cxx +++ b/sc/source/core/tool/viewopti.cxx @@ -73,6 +73,17 @@ bool ScGridOptions::operator==( const ScGridOptions& rCpy ) const && bEqualGrid == rCpy.bEqualGrid ); } +ScViewRenderingOptions::ScViewRenderingOptions() + : sColorSchemeName("Default") + , aDocCol(SC_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor) +{ +} + +bool ScViewRenderingOptions::operator==(const ScViewRenderingOptions& rOther) const +{ + return sColorSchemeName == rOther.sColorSchemeName && + aDocCol == rOther.aDocCol; +} ScViewOptions::ScViewOptions() { @@ -114,8 +125,6 @@ void ScViewOptions::SetDefaults() aGridCol = SC_STD_GRIDCOLOR; - aDocCol = SC_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor; - aGridOpt.SetDefaults(); } @@ -140,8 +149,6 @@ bool ScViewOptions::operator==( const ScViewOptions& rOpt ) const bEqual = bEqual && (aGridCol == rOpt.aGridCol); bEqual = bEqual && (aGridColName == rOpt.aGridColName); bEqual = bEqual && (aGridOpt == rOpt.aGridOpt); - bEqual = bEqual && (sColorSchemeName == rOpt.sColorSchemeName); - bEqual = bEqual && (aDocCol == rOpt.aDocCol); return bEqual; } diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index 650cca1562d1..aa434960898a 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -218,14 +218,13 @@ void ScModule::ConfigurationChanged(utl::ConfigurationBroadcaster* p, Configurat if (pViewShell) { - ScViewData& pViewData = pViewShell->GetViewData(); - ScViewOptions aViewOptions = pViewData.GetOptions(); + ScViewRenderingOptions aViewRenderingOptions(pViewShell->GetViewRenderingData()); Color aFillColor(m_pColorConfig->GetColorValue(svtools::DOCCOLOR).nColor); - aViewOptions.SetDocColor(aFillColor); - aViewOptions.SetColorSchemeName(m_pColorConfig->GetCurrentSchemeName()); - const bool bChanged(aViewOptions != pViewData.GetOptions()); - if (bChanged) - pViewData.SetOptions(aViewOptions); + aViewRenderingOptions.SetDocColor(aFillColor); + aViewRenderingOptions.SetColorSchemeName(m_pColorConfig->GetCurrentSchemeName()); + const bool bUnchanged(aViewRenderingOptions == pViewShell->GetViewRenderingData()); + if (!bUnchanged) + pViewShell->SetViewRenderingData(aViewRenderingOptions); ScModelObj* pScModelObj = comphelper::getFromUnoTunnel<ScModelObj>(SfxObjectShell::Current()->GetModel()); SfxLokHelper::notifyViewRenderState(SfxViewShell::Current(), pScModelObj); // In Online, the document color is the one used for the background, contrary to @@ -234,7 +233,7 @@ void ScModule::ConfigurationChanged(utl::ConfigurationBroadcaster* p, Configurat aFillColor.AsRGBHexString().toUtf8().getStr()); // if nothing changed, and the hint was OnlyCurrentDocumentColorScheme we can skip invalidate - bSkipInvalidate = !bChanged && eHints == ConfigurationHints::OnlyCurrentDocumentColorScheme; + bSkipInvalidate = bUnchanged && eHints == ConfigurationHints::OnlyCurrentDocumentColorScheme; } } diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx index edb9dd991971..52686170030f 100644 --- a/sc/source/ui/inc/tabview.hxx +++ b/sc/source/ui/inc/tabview.hxx @@ -120,6 +120,7 @@ private: VclPtr<vcl::Window> pFrameWin; // First !!! ScViewData aViewData; // must be at the front ! + ScViewRenderingOptions aViewRenderingData; std::unique_ptr<ScViewSelectionEngine> pSelEngine; ScViewFunctionSet aFunctionSet; @@ -344,6 +345,9 @@ public: ScViewData& GetViewData() { return aViewData; } const ScViewData& GetViewData() const { return aViewData; } + const ScViewRenderingOptions& GetViewRenderingData() const { return aViewRenderingData; } + void SetViewRenderingData(const ScViewRenderingOptions& rViewRenderingData) { aViewRenderingData = rViewRenderingData; } + ScViewFunctionSet& GetFunctionSet() { return aFunctionSet; } ScViewSelectionEngine* GetSelEngine() { return pSelEngine.get(); } diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index dd1f6a2b1ef1..c8a56bc4df14 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -1262,25 +1262,20 @@ void ScModelObj::completeFunction(const OUString& rFunctionName) OString ScModelObj::getViewRenderState(SfxViewShell* pViewShell) { OStringBuffer aState; - ScViewData* pViewData = nullptr; - if (pViewShell) + ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell); + if (!pTabViewShell) { - ScTabViewShell* pTabViewShell = dynamic_cast< ScTabViewShell*>(pViewShell); - if (pTabViewShell) - pViewData = &pTabViewShell->GetViewData(); - } - else - { - pViewData = ScDocShell::GetViewData(); + ScViewData* pViewData = ScDocShell::GetViewData(); + pTabViewShell = pViewData ? pViewData->GetViewShell() : nullptr; } - if (pViewData) + if (pTabViewShell) { aState.append(';'); - const ScViewOptions& aViewOptions = pViewData->GetOptions(); - OString aThemeName = OUStringToOString(aViewOptions.GetColorSchemeName(), RTL_TEXTENCODING_UTF8); + const ScViewRenderingOptions& rViewRenderingOptions = pTabViewShell->GetViewRenderingData(); + OString aThemeName = OUStringToOString(rViewRenderingOptions.GetColorSchemeName(), RTL_TEXTENCODING_UTF8); aState.append(aThemeName); } diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 390c4b2bdb63..b91ecbefb875 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -1130,13 +1130,12 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI ScTabViewShell* pCurrentViewShell = dynamic_cast<ScTabViewShell*>(pSfxViewShell); if (pCurrentViewShell) { - const ScViewData& pViewData = pCurrentViewShell->GetViewData(); - const ScViewOptions& aViewOptions = pViewData.GetOptions(); const ScPatternAttr* pPattern = rDoc.GetPattern( nCol1, nRow1, nTab ); Color aCellColor = pPattern->GetItem(ATTR_BACKGROUND).GetColor(); if (aCellColor.IsTransparent()) { - aCellColor = aViewOptions.GetDocColor(); + const ScViewRenderingOptions& rViewRenderingOptions = pCurrentViewShell->GetViewRenderingData(); + aCellColor = rViewRenderingOptions.GetDocColor(); } rDevice.SetFillColor(aCellColor); pOtherEditView->SetBackgroundColor(aCellColor); diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx index aad41a9c1236..206c637e648e 100644 --- a/sc/source/ui/view/tabview.cxx +++ b/sc/source/ui/view/tabview.cxx @@ -169,11 +169,18 @@ bool lcl_HasRowOutline( const ScViewData& rViewData ) return false; } +ScViewRenderingOptions getViewRenderingOptions(ScDocShell& rDocShell) +{ + ScTabViewShell* pViewShell = rDocShell.GetBestViewShell(); + return pViewShell ? pViewShell->GetViewRenderingData() : ScViewRenderingOptions(); +} + } // anonymous namespace ScTabView::ScTabView( vcl::Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell ) : pFrameWin( pParent ), aViewData( rDocSh, pViewShell ), + aViewRenderingData(getViewRenderingOptions(rDocSh)), aFunctionSet( &aViewData ), aHdrFunc( &aViewData ), aVScrollTop( VclPtr<ScrollAdaptor>::Create( pFrameWin, false ) ), diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx index 35efe0f58744..34463e8dd963 100644 --- a/sc/source/ui/view/tabvwshc.cxx +++ b/sc/source/ui/view/tabvwshc.cxx @@ -505,13 +505,12 @@ void ScTabViewShell::NotifyCursor(SfxViewShell* pOtherShell) const ::Color ScTabViewShell::GetColorConfigColor(svtools::ColorConfigEntry nColorType) const { - const ScViewOptions& rViewOptions = GetViewData().GetOptions(); - switch (nColorType) { case svtools::ColorConfigEntry::DOCCOLOR: { - return rViewOptions.GetDocColor(); + const ScViewRenderingOptions& rViewRenderingOptions = GetViewRenderingData(); + return rViewRenderingOptions.GetDocColor(); } // Should never be called for an unimplemented color type default: