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 mpAnnotationManager; std::unique_ptr mpViewOverlayManager; std::vector> m_ExternalEdits; - SdViewOptions maViewOptions; css::uno::Reference 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 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 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(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(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 #include #include +#include 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(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(pCurrentShell); if (!pShellBase) return; - if (DrawViewShell* pCurrentDrawShell = dynamic_cast(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(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()