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.mcnamara@collabora.com>
This commit is contained in:
Caolán McNamara
2024-11-25 13:40:31 +01:00
parent 3a00e589ce
commit 9f35c2b6cd
7 changed files with 63 additions and 46 deletions
+3 -1
View File
@@ -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: */
+2 -2
View File
@@ -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;
};
+4
View File
@@ -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;
+31 -35
View File
@@ -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 {
-1
View File
@@ -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())
{
+11
View File
@@ -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: */
+12 -7
View File
@@ -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()