include/svx/svdobj.hxx                      |    3 ++-
 sd/source/ui/view/sdview.cxx                |   24 ++++++++++++++++++++----
 svx/source/svdraw/svdotextdecomposition.cxx |    4 +++-
 3 files changed, 25 insertions(+), 6 deletions(-)

New commits:
commit 76f8dbf386525ab33844a7fe71b978615247734f
Author:     Caolán McNamara <[email protected]>
AuthorDate: Tue Nov 8 11:33:38 2022 +0000
Commit:     Adolfo Jayme Barrientos <[email protected]>
CommitDate: Wed Nov 9 20:17:31 2022 +0100

    Resolves: tdf#148140 get text auto color right in impress edit mode
    
    Change-Id: I2695c86e9b749a4c38920af6d33e8e89f8ea3c62
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142436
    Tested-by: Jenkins
    Reviewed-by: Adolfo Jayme Barrientos <[email protected]>

diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index 2e350c49b0f4..474f751d1c59 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -875,7 +875,8 @@ public:
 
     const css::uno::WeakReference< css::drawing::XShape >& getWeakUnoShape() 
const { return maWeakUnoShape; }
 
-    void setSuitableOutlinerBg(Outliner& rOutliner) const;
+    // return true if a bg was set, false otherwise
+    bool setSuitableOutlinerBg(Outliner& rOutliner) const;
     // If fillstyle is drawing::FillStyle_BITMAP, returns the graphic.
     const Graphic* getFillGraphic() const;
 
diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx
index e6173fdb9a09..f27622fd139c 100644
--- a/sd/source/ui/view/sdview.cxx
+++ b/sd/source/ui/view/sdview.cxx
@@ -444,6 +444,20 @@ void ViewRedirector::createRedirectedPrimitive2DSequence(
     }
 }
 
+namespace
+{
+    void setOutlinerBgFromPage(::Outliner& rOutl, SdrPageView& rPgView, bool 
bScreenDisplay)
+    {
+        SdPage* pPage = static_cast<SdPage*>(rPgView.GetPage());
+        if (pPage)
+        {
+            // #i75566# Name change GetBackgroundColor -> 
GetPageBackgroundColor and
+            // hint value if screen display. Only then the AutoColor 
mechanisms shall be applied
+            rOutl.SetBackgroundColor(pPage->GetPageBackgroundColor(&rPgView, 
bScreenDisplay));
+        }
+    }
+}
+
 /**
  * The event will be forwarded to the View
  */
@@ -471,9 +485,7 @@ void View::CompleteRedraw(OutputDevice* pOutDev, const 
vcl::Region& rReg, sdr::c
                     || (OUTDEV_PDF == pOutDev->GetOutDevType())))
                 bScreenDisplay = false;
 
-            // #i75566# Name change GetBackgroundColor -> 
GetPageBackgroundColor and
-            // hint value if screen display. Only then the AutoColor 
mechanisms shall be applied
-            rOutl.SetBackgroundColor( pPage->GetPageBackgroundColor(pPgView, 
bScreenDisplay) );
+            setOutlinerBgFromPage(rOutl, *pPgView, bScreenDisplay);
         }
     }
 
@@ -719,7 +731,11 @@ bool View::SdrBeginTextEdit(
             }
             else
             {
-                pObj->setSuitableOutlinerBg(*pOL);
+                // tdf#148140 Set the background to determine autocolor.
+                // Use any explicit bg with fallback to underlying page if
+                // none found
+                if (!pObj->setSuitableOutlinerBg(*pOL) && pPV)
+                    setOutlinerBgFromPage(*pOL, *pPV, true);
             }
         }
 
diff --git a/svx/source/svdraw/svdotextdecomposition.cxx 
b/svx/source/svdraw/svdotextdecomposition.cxx
index 890f59f84264..522375b1ffc3 100644
--- a/svx/source/svdraw/svdotextdecomposition.cxx
+++ b/svx/source/svdraw/svdotextdecomposition.cxx
@@ -861,7 +861,7 @@ void SdrTextObj::impDecomposeAutoFitTextPrimitive(
 
 // Resolves: fdo#35779 set background color of this shape as the editeng 
background if there
 // is one. Check the shape itself, then the host page, then that page's master 
page.
-void SdrObject::setSuitableOutlinerBg(::Outliner& rOutliner) const
+bool SdrObject::setSuitableOutlinerBg(::Outliner& rOutliner) const
 {
     const SfxItemSet* pBackgroundFillSet = getBackgroundFillSet();
     if (drawing::FillStyle_NONE != 
pBackgroundFillSet->Get(XATTR_FILLSTYLE).GetValue())
@@ -869,7 +869,9 @@ void SdrObject::setSuitableOutlinerBg(::Outliner& 
rOutliner) const
         Color aColor(rOutliner.GetBackgroundColor());
         GetDraftFillColor(*pBackgroundFillSet, aColor);
         rOutliner.SetBackgroundColor(aColor);
+        return true;
     }
+    return false;
 }
 
 const SfxItemSet* SdrObject::getBackgroundFillSet() const

Reply via email to