editeng/source/editeng/impedit3.cxx | 24 ++++++++++++++++++++---- include/sfx2/viewsh.hxx | 3 +++ include/svtools/colorcfg.hxx | 2 +- sc/source/ui/inc/tabvwsh.hxx | 2 ++ sc/source/ui/view/tabvwshc.cxx | 22 ++++++++++++++++++++++ sd/source/ui/inc/ViewShellBase.hxx | 2 ++ sd/source/ui/view/ViewShellBase.cxx | 27 +++++++++++++++++++++++++++ sfx2/source/view/viewsh.cxx | 6 ++++++ sw/inc/view.hxx | 2 ++ sw/source/uibase/uiview/viewprt.cxx | 27 +++++++++++++++++++++++++++ 10 files changed, 112 insertions(+), 5 deletions(-)
New commits: commit 0ed32277dc5c0f1989ae59fa05217ae793ae81d9 Author: Paris Oplopoios <paris.oplopo...@collabora.com> AuthorDate: Tue Jun 13 20:36:48 2023 +0300 Commit: Paris Oplopoios <parisop...@gmail.com> CommitDate: Wed Jun 14 17:57:16 2023 +0200 Add editengine view separation in tiled rendering Editengine now gets the background color from the current view instead from a global variable Change-Id: I98a0fccf4d0c83f4dabf8e534a9228b8a5e271d7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152996 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Paris Oplopoios <parisop...@gmail.com> diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index 11e12c66e7e8..8a6ff9d63e6e 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -52,6 +52,7 @@ #include <svl/asiancfg.hxx> #include <svx/compatflags.hxx> +#include <sfx2/viewsh.hxx> #include <editeng/hngpnctitem.hxx> #include <editeng/forbiddencharacterstable.hxx> @@ -67,6 +68,7 @@ #include <i18nlangtag/mslangid.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/lok.hxx> #include <rtl/ustrbuf.hxx> #include <sal/log.hxx> #include <o3tl/safeint.hxx> @@ -4696,15 +4698,29 @@ Reference < i18n::XExtendedInputSequenceChecker > const & ImpEditEngine::ImplGet Color ImpEditEngine::GetAutoColor() const { - Color aColor = GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor; + Color aColor; - if ( GetBackgroundColor() != COL_AUTO ) + if (comphelper::LibreOfficeKit::isActive() && SfxViewShell::Current()) { - if ( GetBackgroundColor().IsDark() && aColor.IsDark() ) + // Get document background color from current view instead + aColor = SfxViewShell::Current()->GetColorConfigColor(svtools::DOCCOLOR); + if (aColor.IsDark()) aColor = COL_WHITE; - else if ( GetBackgroundColor().IsBright() && aColor.IsBright() ) + else aColor = COL_BLACK; } + else + { + aColor = GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor; + + if ( GetBackgroundColor() != COL_AUTO ) + { + if ( GetBackgroundColor().IsDark() && aColor.IsDark() ) + aColor = COL_WHITE; + else if ( GetBackgroundColor().IsBright() && aColor.IsBright() ) + aColor = COL_BLACK; + } + } return aColor; } diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx index 0cbbfc64032d..2435caa52a47 100644 --- a/include/sfx2/viewsh.hxx +++ b/include/sfx2/viewsh.hxx @@ -72,6 +72,7 @@ namespace com::sun::star::ui { class XContextMenuInterceptor; } namespace com::sun::star::ui { struct ContextMenuExecuteEvent; } namespace com::sun::star::view { class XRenderable; } namespace tools { class Rectangle; } +namespace svtools { enum ColorConfigEntry : int; } enum class SfxPrinterChangeFlags { @@ -406,6 +407,8 @@ public: virtual void afterCallbackRegistered(); /// See OutlinerViewShell::GetEditWindowForActiveOLEObj(). virtual vcl::Window* GetEditWindowForActiveOLEObj() const override; + /// Get a color config color from this view + virtual ::Color GetColorConfigColor(svtools::ColorConfigEntry nColorType) const; /// Set the LibreOfficeKit language of this view. void SetLOKLanguageTag(const OUString& rBcp47LanguageTag); diff --git a/include/svtools/colorcfg.hxx b/include/svtools/colorcfg.hxx index 08f5d3000bed..5836ab1ea6f9 100644 --- a/include/svtools/colorcfg.hxx +++ b/include/svtools/colorcfg.hxx @@ -27,7 +27,7 @@ namespace svtools{ -enum ColorConfigEntry +enum ColorConfigEntry : int { DOCCOLOR , DOCBOUNDARIES , diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx index a1688fb11f83..ee3edd020def 100644 --- a/sc/source/ui/inc/tabvwsh.hxx +++ b/sc/source/ui/inc/tabvwsh.hxx @@ -393,6 +393,8 @@ public: void afterCallbackRegistered() override; /// See SfxViewShell::NotifyCursor(). void NotifyCursor(SfxViewShell* pViewShell) const override; + /// See SfxViewShell::GetColorConfigColor(). + ::Color GetColorConfigColor(svtools::ColorConfigEntry nColorType) 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); diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx index da2031ba40bb..3b50da7114cb 100644 --- a/sc/source/ui/view/tabvwshc.cxx +++ b/sc/source/ui/view/tabvwshc.cxx @@ -72,7 +72,9 @@ #include <SparklineDialog.hxx> #include <SparklineDataRangeDialog.hxx> +#include <svtools/colorcfg.hxx> #include <comphelper/lok.hxx> +#include <o3tl/unreachable.hxx> #include <o3tl/make_shared.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> @@ -494,6 +496,26 @@ void ScTabViewShell::NotifyCursor(SfxViewShell* pOtherShell) const pWin->updateKitCellCursor(pOtherShell); } +::Color ScTabViewShell::GetColorConfigColor(svtools::ColorConfigEntry nColorType) const +{ + const ScViewOptions& rViewOptions = GetViewData().GetOptions(); + + switch (nColorType) + { + case svtools::ColorConfigEntry::DOCCOLOR: + { + return rViewOptions.GetDocColor(); + } + // Should never be called for an unimplemented color type + default: + { + O3TL_UNREACHABLE; + } + } + + return {}; +} + css::uno::Reference<css::datatransfer::XTransferable2> ScTabViewShell::GetClipData(vcl::Window* pWin) { SfxViewFrame* pViewFrame = nullptr; diff --git a/sd/source/ui/inc/ViewShellBase.hxx b/sd/source/ui/inc/ViewShellBase.hxx index 67938dc4827a..aa0346ea5b2f 100644 --- a/sd/source/ui/inc/ViewShellBase.hxx +++ b/sd/source/ui/inc/ViewShellBase.hxx @@ -221,6 +221,8 @@ public: void afterCallbackRegistered() override; /// See SfxViewShell::NotifyCursor(). void NotifyCursor(SfxViewShell* pViewShell) const override; + /// See SfxViewShell::GetColorConfigColor(). + ::Color GetColorConfigColor(svtools::ColorConfigEntry nColorType) const override; void setLOKVisibleArea(const ::tools::Rectangle& rArea) { maLOKVisibleArea = rArea; } virtual ::tools::Rectangle getLOKVisibleArea() const override { return maLOKVisibleArea; } diff --git a/sd/source/ui/view/ViewShellBase.cxx b/sd/source/ui/view/ViewShellBase.cxx index 9f9f04789f4a..834e1d6cc3e2 100644 --- a/sd/source/ui/view/ViewShellBase.cxx +++ b/sd/source/ui/view/ViewShellBase.cxx @@ -73,6 +73,7 @@ #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <editeng/editview.hxx> #include <tools/svborder.hxx> +#include <o3tl/unreachable.hxx> #include <fubullet.hxx> #include <drawview.hxx> @@ -1064,6 +1065,32 @@ void ViewShellBase::NotifyCursor(SfxViewShell* pOtherShell) const } } +::Color ViewShellBase::GetColorConfigColor(svtools::ColorConfigEntry nColorType) const +{ + if (DrawViewShell* pCurrentDrawShell = dynamic_cast<DrawViewShell*>(GetMainViewShell().get())) + { + const SdViewOptions& rViewOptions = pCurrentDrawShell->GetViewOptions(); + switch (nColorType) + { + case svtools::ColorConfigEntry::DOCCOLOR: + { + return rViewOptions.mnDocBackgroundColor; + } + // Should never be called for an unimplemented color type + default: + { + O3TL_UNREACHABLE; + } + } + } + else + { + SAL_WARN("sd", "dynamic_cast to DrawViewShell failed"); + } + + return {}; +} + //===== ViewShellBase::Implementation ========================================= ViewShellBase::Implementation::Implementation (ViewShellBase& rBase) diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 6268efcd1f4b..5b4f1e44b152 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -2553,6 +2553,12 @@ vcl::Window* SfxViewShell::GetEditWindowForActiveOLEObj() const return pEditWin; } +::Color SfxViewShell::GetColorConfigColor(svtools::ColorConfigEntry nColorType) const +{ + SAL_WARN("sfx.view", "SfxViewShell::GetColorConfigColor not overriden!"); + return {}; +} + void SfxViewShell::SetLOKLanguageTag(const OUString& rBcp47LanguageTag) { LanguageTag aTag(rBcp47LanguageTag, true); diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx index 59a1e8914c8b..b556c2c53f39 100644 --- a/sw/inc/view.hxx +++ b/sw/inc/view.hxx @@ -672,6 +672,8 @@ public: void afterCallbackRegistered() override; /// See SfxViewShell::NotifyCursor(). void NotifyCursor(SfxViewShell* pViewShell) const override; + /// See SfxViewShell::GetColorConfigColor(). + ::Color GetColorConfigColor(svtools::ColorConfigEntry nColorType) const override; void ShowUIElement(const OUString& sElementURL) const; diff --git a/sw/source/uibase/uiview/viewprt.cxx b/sw/source/uibase/uiview/viewprt.cxx index 162d0469b868..2e6bc417b49e 100644 --- a/sw/source/uibase/uiview/viewprt.cxx +++ b/sw/source/uibase/uiview/viewprt.cxx @@ -36,6 +36,8 @@ #include <svl/flagitem.hxx> #include <sfx2/linkmgr.hxx> #include <osl/diagnose.h> +#include <svtools/colorcfg.hxx> +#include <o3tl/unreachable.hxx> #include <modcfg.hxx> #include <edtwin.hxx> @@ -289,6 +291,31 @@ void SwView::NotifyCursor(SfxViewShell* pViewShell) const m_pWrtShell->NotifyCursor(pViewShell); } +::Color SwView::GetColorConfigColor(svtools::ColorConfigEntry nColorType) const +{ + if (const SwViewOption* pViewOptions = GetWrtShell().GetViewOptions()) + { + switch (nColorType) + { + case svtools::ColorConfigEntry::DOCCOLOR: + { + return pViewOptions->GetDocColor(); + } + // Should never be called for an unimplemented color type + default: + { + O3TL_UNREACHABLE; + } + } + } + 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,