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      |   20 ++++++++++++++++++++
 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, 110 insertions(+), 5 deletions(-)

New commits:
commit 069c7dc4e9706b40ca12d83d83f90f41cec948f8
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 22:12:21 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>
    (cherry picked from commit 7baa475342b67c10537e11da37b8862648679b02)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153073
    Tested-by: Jenkins

diff --git a/editeng/source/editeng/impedit3.cxx 
b/editeng/source/editeng/impedit3.cxx
index bcf0c044872f..e18562d3113f 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>
@@ -4686,15 +4688,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 b805f1cf99d4..08bc6cecc8cb 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -74,6 +74,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
 {
@@ -428,6 +429,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 de16f18eab13..9810aac0393d 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 a670c4429d53..d8434af53bc6 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -395,6 +395,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 fcafe6755242..5397d9f4383e 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>
 
@@ -491,6 +493,24 @@ 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;
+        }
+    }
+}
+
 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 7ef425416612..e31429f6e41a 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 9099988969d8..55ade0226213 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>
@@ -1057,6 +1058,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 e21afa252762..dcd522d61aee 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -2316,6 +2316,12 @@ vcl::Window* 
SfxViewShell::GetEditWindowForActiveOLEObj() const
     return pEditWin;
 }
 
+::Color SfxViewShell::GetColorConfigColor(svtools::ColorConfigEntry) 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 301ed1a92bb8..b1d2ea5b9e90 100644
--- a/sw/inc/view.hxx
+++ b/sw/inc/view.hxx
@@ -674,6 +674,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 be23c4861a63..bc9c5e19b840 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,

Reply via email to