sd/inc/viewopt.hxx | 4 +- sd/source/ui/inc/DrawViewShell.hxx | 4 +- sd/source/ui/inc/ViewShellBase.hxx | 4 ++ sd/source/ui/view/ViewShellBase.cxx | 66 ++++++++++++++++-------------------- sd/source/ui/view/drviewsa.cxx | 1 sd/source/ui/view/drviewsj.cxx | 11 ++++++ sd/source/ui/view/drviewsk.cxx | 19 ++++++---- 7 files changed, 63 insertions(+), 46 deletions(-)
New commits: commit 9f35c2b6cdc50de017aae3585fd9e55b0796d4e4 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Wed Nov 20 09:49:55 2024 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Mon Nov 25 13:40:31 2024 +0100 move SdViewOptions options down to ViewShellBase ViewShellBase is the SfxViewShell and is the analogue of the equivalent writer/calc SfxViewShell's, while a DrawViewShell is one of multiple sd::ViewShells that can exist inside that SfxViewShell Issue: * When creating new shell instances, background color is fetched from application configuration. * When multiple users are active on an Impress document, if one switches to notes view, a new shell is created. * Background color for the new shell is fetched from app colors. * If another user has switched to dark mode, the user which just switched to notes view, will see dark mode for their background. Moving the SdViewOptions options down the ViewShellBase means that multiple sd::ViewShells hosted within that ViewShellBase share the same view settings. Change-Id: Id875260dda89311ab8029ead08b47f80fd14604f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177253 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sd/inc/viewopt.hxx b/sd/inc/viewopt.hxx index eb9f16513624..cf75d6f06156 100644 --- a/sd/inc/viewopt.hxx +++ b/sd/inc/viewopt.hxx @@ -23,12 +23,14 @@ /// View options for the current view struct SdViewOptions { + SdViewOptions(); + // The color of the area behind the slide (used to be called "Wiese") Color mnAppBackgroundColor; // The color of the document background Color mnDocBackgroundColor; // The name of the color scheme - OUString msColorSchemeName = u"Default"_ustr; + OUString msColorSchemeName; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx index 989582749c0a..f382eff431d3 100644 --- a/sd/source/ui/inc/DrawViewShell.hxx +++ b/sd/source/ui/inc/DrawViewShell.hxx @@ -383,7 +383,8 @@ public: bool IsInSwitchPage() const { return mbIsInSwitchPage; } - const SdViewOptions& GetViewOptions() const { return maViewOptions; } + const SdViewOptions& GetViewOptions() const; + void SetViewOptions(const SdViewOptions& rOptions); //move this method to ViewShell. //void NotifyAccUpdate(); @@ -508,7 +509,6 @@ private: std::unique_ptr<AnnotationManager> mpAnnotationManager; std::unique_ptr<ViewOverlayManager> mpViewOverlayManager; std::vector<std::unique_ptr<SdrExternalToolEdit>> m_ExternalEdits; - SdViewOptions maViewOptions; css::uno::Reference<css::presentation::XSlideShow> mxSlideShow; }; diff --git a/sd/source/ui/inc/ViewShellBase.hxx b/sd/source/ui/inc/ViewShellBase.hxx index 1e1517eb6550..921865624ff7 100644 --- a/sd/source/ui/inc/ViewShellBase.hxx +++ b/sd/source/ui/inc/ViewShellBase.hxx @@ -24,6 +24,7 @@ #include <memory> class SdDrawDocument; +struct SdViewOptions; class SfxRequest; namespace sd::tools { @@ -227,6 +228,9 @@ public: void setLOKVisibleArea(const ::tools::Rectangle& rArea) { maLOKVisibleArea = rArea; } virtual ::tools::Rectangle getLOKVisibleArea() const override { return maLOKVisibleArea; } + const SdViewOptions& GetViewOptions() const; + void SetViewOptions(const SdViewOptions& rOptions) const; + protected: virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override; diff --git a/sd/source/ui/view/ViewShellBase.cxx b/sd/source/ui/view/ViewShellBase.cxx index 37d32df82f0f..bfbff51d1389 100644 --- a/sd/source/ui/view/ViewShellBase.cxx +++ b/sd/source/ui/view/ViewShellBase.cxx @@ -115,6 +115,8 @@ namespace sd { class ViewShellBase::Implementation { public: + SdViewOptions maViewOptions; + /** Main controller of the view shell. During the switching from one stacked shell to another this pointer may be NULL. */ @@ -922,6 +924,16 @@ OUString ViewShellBase::GetInitialViewShellType() const return sRequestedView; } +const SdViewOptions& ViewShellBase::GetViewOptions() const +{ + return mpImpl->maViewOptions; +} + +void ViewShellBase::SetViewOptions(const SdViewOptions& rOptions) const +{ + mpImpl->maViewOptions = rOptions; +} + std::shared_ptr<tools::EventMultiplexer> const & ViewShellBase::GetEventMultiplexer() const { OSL_ASSERT(mpImpl != nullptr); @@ -1138,48 +1150,24 @@ void ViewShellBase::NotifyCursor(SfxViewShell* pOtherShell) const ::Color ViewShellBase::GetColorConfigColor(svtools::ColorConfigEntry nColorType) const { - auto pViewShell = GetMainViewShell().get(); - if (DrawViewShell* pCurrentDrawShell = dynamic_cast<DrawViewShell*>(pViewShell)) + Color aColor; + + const SdViewOptions& rViewOptions = GetViewOptions(); + switch (nColorType) { - const SdViewOptions& rViewOptions = pCurrentDrawShell->GetViewOptions(); - switch (nColorType) + case svtools::ColorConfigEntry::DOCCOLOR: { - case svtools::ColorConfigEntry::DOCCOLOR: - { - return rViewOptions.mnDocBackgroundColor; - } - // Should never be called for an unimplemented color type - default: - { - O3TL_UNREACHABLE; - } + aColor = rViewOptions.mnDocBackgroundColor; + break; } - } - // IASS: also need to handle OutlineViewShell - else if (nullptr != dynamic_cast<OutlineViewShell*>(pViewShell)) - { - switch (nColorType) + // Should never be called for an unimplemented color type + default: { - case svtools::ColorConfigEntry::DOCCOLOR: - { - // IASS: OutlineViewShell does not have any SdViewOptions and no access - // to the (currently not shown) DrawViewShell. If that should be - // needed it may be added. For now, assume that DOCCOLOR is COL_WHITE - return COL_WHITE; - } - // Should never be called for an unimplemented color type - default: - { - O3TL_UNREACHABLE; - } + O3TL_UNREACHABLE; } } - SAL_WARN("sd", "Unknown ViewShell used: Consider adding a case for this to get correct colors, COL_WHITE is used as fallback."); - // NOTE: This returned COL_BLACK. For unknown ViewShells I would assume that - // returning COL_WHITE would be safer - a better default for an office - // application dealing with Paper as target - return COL_WHITE; + return aColor; } //===== ViewShellBase::Implementation ========================================= @@ -1566,6 +1554,14 @@ void CurrentPageSetter::operator() (bool) } // end of anonymous namespace +SdViewOptions::SdViewOptions() + : msColorSchemeName(u"Default"_ustr) +{ + const svtools::ColorConfig& rColorConfig = SdModule::get()->GetColorConfig(); + mnAppBackgroundColor = rColorConfig.GetColorValue(svtools::APPBACKGROUND).nColor; + mnDocBackgroundColor = rColorConfig.GetColorValue(svtools::DOCCOLOR).nColor; +} + //===== FocusForwardingWindow ================================================= namespace sd { diff --git a/sd/source/ui/view/drviewsa.cxx b/sd/source/ui/view/drviewsa.cxx index 78e86ff87e8a..a62467902968 100644 --- a/sd/source/ui/view/drviewsa.cxx +++ b/sd/source/ui/view/drviewsa.cxx @@ -134,7 +134,6 @@ DrawViewShell::DrawViewShell( ViewShellBase& rViewShellBase, vcl::Window* pParen ConfigureAppBackgroundColor(); SdModule* mod = SdModule::get(); mod->GetColorConfig().AddListener(this); - maViewOptions.mnDocBackgroundColor = mod->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor; if (comphelper::LibreOfficeKit::isActive()) { diff --git a/sd/source/ui/view/drviewsj.cxx b/sd/source/ui/view/drviewsj.cxx index 6422747d03e8..934a4e475d21 100644 --- a/sd/source/ui/view/drviewsj.cxx +++ b/sd/source/ui/view/drviewsj.cxx @@ -38,6 +38,7 @@ #include <anminfo.hxx> #include <drawdoc.hxx> #include <drawview.hxx> +#include <ViewShellBase.hxx> using namespace com::sun::star; @@ -563,6 +564,16 @@ void DrawViewShell::GetMenuStateSel( SfxItemSet &rSet ) } } +const SdViewOptions& DrawViewShell::GetViewOptions() const +{ + return GetViewShellBase().GetViewOptions(); +} + +void DrawViewShell::SetViewOptions(const SdViewOptions& rOptions) +{ + GetViewShellBase().SetViewOptions(rOptions); +} + } // end of namespace sd /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/view/drviewsk.cxx b/sd/source/ui/view/drviewsk.cxx index 54cb0ac55aca..3cab2bb1cea0 100644 --- a/sd/source/ui/view/drviewsk.cxx +++ b/sd/source/ui/view/drviewsk.cxx @@ -30,18 +30,21 @@ void DrawViewShell::ConfigurationChanged( utl::ConfigurationBroadcaster* pCb, Co svtools::ColorConfig *pColorConfig = dynamic_cast<svtools::ColorConfig*>(pCb); ConfigureAppBackgroundColor(pColorConfig); if (!comphelper::LibreOfficeKit::isActive()) - maViewOptions.mnDocBackgroundColor = pColorConfig->GetColorValue(svtools::DOCCOLOR).nColor; + { + SdViewOptions aViewOptions = GetViewOptions(); + aViewOptions.mnDocBackgroundColor = pColorConfig->GetColorValue(svtools::DOCCOLOR).nColor; + SetViewOptions(aViewOptions); + } else { SfxViewShell* pCurrentShell = SfxViewShell::Current(); ViewShellBase* pShellBase = dynamic_cast<ViewShellBase*>(pCurrentShell); if (!pShellBase) return; - if (DrawViewShell* pCurrentDrawShell = dynamic_cast<DrawViewShell*>(pShellBase->GetMainViewShell().get())) - { - pCurrentDrawShell->maViewOptions.mnDocBackgroundColor = pColorConfig->GetColorValue(svtools::DOCCOLOR).nColor; - pCurrentDrawShell->maViewOptions.msColorSchemeName = svtools::ColorConfig::GetCurrentSchemeName(); - } + SdViewOptions aViewOptions = pShellBase->GetViewOptions(); + aViewOptions.mnDocBackgroundColor = pColorConfig->GetColorValue(svtools::DOCCOLOR).nColor; + aViewOptions.msColorSchemeName = svtools::ColorConfig::GetCurrentSchemeName(); + pShellBase->SetViewOptions(aViewOptions); SdXImpressDocument* pDoc = comphelper::getFromUnoTunnel<SdXImpressDocument>(pCurrentShell->GetCurrentDocument()); SfxLokHelper::notifyViewRenderState(pCurrentShell, pDoc); Color aFillColor(pColorConfig->GetColorValue(svtools::APPBACKGROUND).nColor); @@ -60,7 +63,9 @@ void DrawViewShell::ConfigureAppBackgroundColor( svtools::ColorConfig *pColorCon // tdf#87905 Use darker background color for master view if (meEditMode == EditMode::MasterPage) aFillColor.DecreaseLuminance( 64 ); - maViewOptions.mnAppBackgroundColor = aFillColor; + SdViewOptions aViewOptions = GetViewOptions(); + aViewOptions.mnAppBackgroundColor = aFillColor; + SetViewOptions(aViewOptions); } void DrawViewShell::destroyXSlideShowInstance()