Make sure views get new themes on .uno:ChangeTheme

It would be that sometimes .uno:ChangeTheme would not load the new
scheme because it was using EditableConfig::GetCurrentSchemeName which
uses a static name - normally great except for when you need different
views to have different color schemes in tiled rendering

Change-Id: I5b149bd1a4776337f76753c6de98d5386a899d34
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153939
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Paris Oplopoios <parisoplop@gmail.com>
(cherry picked from commit 77f5b9259864798b6efc213f6dfa685cd440f71a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154001
Tested-by: Jenkins
This commit is contained in:
Paris Oplopoios
2023-07-05 10:17:03 +02:00
committed by Paris Oplopoios
parent 1a561775a4
commit 63d019c678
11 changed files with 80 additions and 4 deletions
+2
View File
@@ -431,6 +431,8 @@ public:
virtual vcl::Window* GetEditWindowForActiveOLEObj() const override;
/// Get a color config color from this view
virtual ::Color GetColorConfigColor(svtools::ColorConfigEntry nColorType) const;
/// Get the color scheme name of this view
virtual OUString GetColorConfigName() const;
/// Set the LibreOfficeKit language of this view.
void SetLOKLanguageTag(const OUString& rBcp47LanguageTag);
+2
View File
@@ -397,6 +397,8 @@ public:
void NotifyCursor(SfxViewShell* pViewShell) const override;
/// See SfxViewShell::GetColorConfigColor().
::Color GetColorConfigColor(svtools::ColorConfigEntry nColorType) const override;
/// See SfxViewShell::GetColorConfigName().
OUString GetColorConfigName() const override;
/// Emits a LOK_CALLBACK_INVALIDATE_HEADER for all views whose current tab is equal to nCurrentTabIndex
static void notifyAllViewsHeaderInvalidation(const SfxViewShell* pForViewShell, HeaderType eHeaderType, SCTAB nCurrentTabIndex);
static bool isAnyEditViewInRange(const SfxViewShell* pForViewShell, bool bColumns, SCCOLROW nStart, SCCOLROW nEnd);
+5
View File
@@ -511,6 +511,11 @@ void ScTabViewShell::NotifyCursor(SfxViewShell* pOtherShell) const
}
}
OUString ScTabViewShell::GetColorConfigName() const
{
return GetViewData().GetOptions().GetColorSchemeName();
}
css::uno::Reference<css::datatransfer::XTransferable2> ScTabViewShell::GetClipData(vcl::Window* pWin)
{
SfxViewFrame* pViewFrame = nullptr;
+2
View File
@@ -223,6 +223,8 @@ public:
void NotifyCursor(SfxViewShell* pViewShell) const override;
/// See SfxViewShell::GetColorConfigColor().
::Color GetColorConfigColor(svtools::ColorConfigEntry nColorType) const override;
/// See SfxViewShell::GetColorConfigName().
OUString GetColorConfigName() const override;
void setLOKVisibleArea(const ::tools::Rectangle& rArea) { maLOKVisibleArea = rArea; }
virtual ::tools::Rectangle getLOKVisibleArea() const override { return maLOKVisibleArea; }
+12
View File
@@ -1084,6 +1084,18 @@ void ViewShellBase::NotifyCursor(SfxViewShell* pOtherShell) const
return {};
}
OUString ViewShellBase::GetColorConfigName() const
{
if (DrawViewShell* pCurrentDrawShell = dynamic_cast<DrawViewShell*>(GetMainViewShell().get()))
{
const SdViewOptions& rViewOptions = pCurrentDrawShell->GetViewOptions();
return rViewOptions.msColorSchemeName;
}
SAL_WARN("sd", "dynamic_cast to DrawViewShell failed");
return {};
}
//===== ViewShellBase::Implementation =========================================
ViewShellBase::Implementation::Implementation (ViewShellBase& rBase)
+18 -2
View File
@@ -583,10 +583,26 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
SAL_WARN("sfx.appl", "FN_CHANGE_THEME: no theme name");
break;
}
const OUString& rSchemeName = pNewThemeArg->GetValue();
svtools::EditableColorConfig aEditableConfig;
if (aEditableConfig.GetCurrentSchemeName() != rSchemeName)
aEditableConfig.LoadScheme(rSchemeName);
if (comphelper::LibreOfficeKit::isActive())
{
SfxViewShell* pCurrentShell = SfxViewShell::Current();
if (pCurrentShell && pCurrentShell->GetColorConfigName() != rSchemeName)
{
aEditableConfig.LoadScheme(rSchemeName);
}
}
else
{
if (aEditableConfig.GetCurrentSchemeName() != rSchemeName)
{
aEditableConfig.LoadScheme(rSchemeName);
}
}
break;
}
+6
View File
@@ -2323,6 +2323,12 @@ vcl::Window* SfxViewShell::GetEditWindowForActiveOLEObj() const
return {};
}
OUString SfxViewShell::GetColorConfigName() const
{
SAL_WARN("sfx.view", "SfxViewShell::GetColorConfigName not overriden!");
return {};
}
void SfxViewShell::SetLOKLanguageTag(const OUString& rBcp47LanguageTag)
{
LanguageTag aTag(rBcp47LanguageTag, true);
+2
View File
@@ -676,6 +676,8 @@ public:
void NotifyCursor(SfxViewShell* pViewShell) const override;
/// See SfxViewShell::GetColorConfigColor().
::Color GetColorConfigColor(svtools::ColorConfigEntry nColorType) const override;
/// See SfxViewShell::GetColorConfigName().
OUString GetColorConfigName() const override;
void ShowUIElement(const OUString& sElementURL) const;
+1 -1
View File
@@ -854,7 +854,7 @@ public:
inline bool SwViewOption::operator==( const SwViewOption &rOpt ) const
{
return IsEqualFlags( rOpt ) && m_nZoom == rOpt.GetZoom() && m_aColorConfig == rOpt.m_aColorConfig;
return IsEqualFlags( rOpt ) && m_nZoom == rOpt.GetZoom() && m_aColorConfig == rOpt.m_aColorConfig && m_sThemeName == rOpt.m_sThemeName;
}
inline void SwViewOption::SetUIOptions( const SwViewOption& rVOpt )
+16 -1
View File
@@ -42,6 +42,7 @@
#include <ndgrf.hxx>
#include <ndindex.hxx>
#include <accessibilityoptions.hxx>
#include <comphelper/lok.hxx>
void SwViewShell::Init( const SwViewOption *pNewOpt )
{
@@ -248,7 +249,21 @@ SwViewShell::SwViewShell( SwViewShell& rShell, vcl::Window *pWindow,
bool bModified = mxDoc->getIDocumentState().IsModified();
OutputDevice* pOrigOut = mpOut;
Init( rShell.GetViewOptions() ); // might change Outdev (InitPrt())
SwViewOption aNewOpt;
if ( rShell.GetViewOptions() )
{
aNewOpt = *rShell.GetViewOptions();
}
if ( comphelper::LibreOfficeKit::isActive() )
{
// Do not copy the color config in tiled rendering
aNewOpt.SetThemeName("Default");
}
Init( &aNewOpt ); // might change Outdev (InitPrt())
mpOut = pOrigOut;
if ( mbPreview )
+14
View File
@@ -316,6 +316,20 @@ void SwView::NotifyCursor(SfxViewShell* pViewShell) const
return {};
}
OUString SwView::GetColorConfigName() const
{
if (const SwViewOption* pViewOptions = GetWrtShell().GetViewOptions())
{
return pViewOptions->GetThemeName();
}
else
{
SAL_WARN("sw", "GetViewOptions() returned nullptr");
}
return {};
}
// Create page printer/additions for SwView and SwPagePreview
std::unique_ptr<SfxTabPage> CreatePrintOptionsPage(weld::Container* pPage, weld::DialogController* pController,