summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2024-01-08 15:04:07 +0000
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-01-10 13:45:16 +0100
commit961ffd72e2051490b3650348e97f99ef727a573b (patch)
tree2c92222ee8fe88c3cf75648598f9fa4fbd349765 /sc
parent212bbbe5cafab06b408ddde930bf9c8d37b7c3aa (diff)
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.meeks@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161880 Tested-by: Jenkins
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/viewopti.hxx30
-rw-r--r--sc/source/core/data/patattr.cxx5
-rw-r--r--sc/source/core/tool/viewopti.cxx15
-rw-r--r--sc/source/ui/app/scmod.cxx15
-rw-r--r--sc/source/ui/inc/tabview.hxx4
-rw-r--r--sc/source/ui/unoobj/docuno.cxx19
-rw-r--r--sc/source/ui/view/gridwin4.cxx5
-rw-r--r--sc/source/ui/view/tabview.cxx7
-rw-r--r--sc/source/ui/view/tabvwshc.cxx5
9 files changed, 62 insertions, 43 deletions
diff --git a/sc/inc/viewopti.hxx b/sc/inc/viewopti.hxx
index beb0530e88a5..25f7db7d8527 100644
--- a/sc/inc/viewopti.hxx
+++ b/sc/inc/viewopti.hxx
@@ -73,6 +73,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
@@ -97,12 +117,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)); }
@@ -113,10 +127,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 4d44e744d807..4d9c5887f8d8 100644
--- a/sc/source/core/data/patattr.cxx
+++ b/sc/source/core/data/patattr.cxx
@@ -735,9 +735,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 39e2e6e0e762..0a505408e6bf 100644
--- a/sc/source/core/tool/viewopti.cxx
+++ b/sc/source/core/tool/viewopti.cxx
@@ -68,6 +68,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()
{
@@ -110,8 +121,6 @@ void ScViewOptions::SetDefaults()
aGridCol = svtools::ColorConfig().GetColorValue( svtools::CALCGRID ).nColor;
- aDocCol = SC_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor;
-
aGridOpt.SetDefaults();
}
@@ -136,8 +145,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 3755aa7f7748..de444001d022 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -219,14 +219,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(svtools::ColorConfig::GetCurrentSchemeName());
- const bool bChanged(aViewOptions != pViewData.GetOptions());
- if (bChanged)
- pViewData.SetOptions(aViewOptions);
+ aViewRenderingOptions.SetDocColor(aFillColor);
+ aViewRenderingOptions.SetColorSchemeName(svtools::ColorConfig::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
@@ -235,7 +234,7 @@ void ScModule::ConfigurationChanged(utl::ConfigurationBroadcaster* p, Configurat
aFillColor.AsRGBHexString().toUtf8());
// 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 66bbc010eae1..d825eca1f1d8 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;
@@ -349,6 +350,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 747600e9af63..4b412e4f54c1 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -1264,25 +1264,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 95ed4d0c7600..301082c5754c 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1127,13 +1127,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 9eff50195e84..71a37ddce9da 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 f94850596731..0c214a02eb67 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -508,13 +508,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: