sw/inc/ndole.hxx                |    3 +++
 sw/source/core/doc/notxtfrm.cxx |   17 +++++++++++++++++
 sw/source/core/ole/ndole.cxx    |   19 +++++++++++++++++++
 3 files changed, 39 insertions(+)

New commits:
commit dee3cff90d5d5948e1f8dcba084f192af2e5eb07
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Sat Jan 27 22:00:15 2024 +0000
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Sun Jan 28 15:39:28 2024 +0100

    Set chart outliner background to the page bg to resolve 'auto' color
    
    when writer does this direct primitive rendering of the chart
    
    Change-Id: If3b31b3077dc6d7449e8a0102f3475884b3d754a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162650
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sw/inc/ndole.hxx b/sw/inc/ndole.hxx
index 5caa29ab43bf..6265160219f9 100644
--- a/sw/inc/ndole.hxx
+++ b/sw/inc/ndole.hxx
@@ -24,6 +24,7 @@
 #include <drawinglayer/primitive2d/Primitive2DContainer.hxx>
 #include <rtl/ref.hxx>
 
+class SvxDrawPage;
 class SwGrfFormatColl;
 class SwDoc;
 class SwOLENode;
@@ -81,6 +82,8 @@ public:
         bool bSynchron);
     void resetBufferedData();
 
+    SvxDrawPage* tryToGetChartDrawPage() const;
+
     void dumpAsXml(xmlTextWriterPtr pWriter) const;
 };
 
diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx
index b97ae500a021..362054bd592a 100644
--- a/sw/source/core/doc/notxtfrm.cxx
+++ b/sw/source/core/doc/notxtfrm.cxx
@@ -75,7 +75,10 @@
 
 // MM02 needed for VOC mechanism and getting the OC - may be moved to an own 
file
 #include <svx/sdrpagewindow.hxx>
+#include <svx/svdoutl.hxx>
+#include <svx/svdpage.hxx>
 #include <svx/svdpagv.hxx>
+#include <svx/unopage.hxx>
 #include <svx/sdr/contact/viewcontact.hxx>
 #include <svx/sdr/contact/viewobjectcontact.hxx>
 #include <svx/sdr/contact/objectcontact.hxx>
@@ -1385,11 +1388,25 @@ void SwNoTextFrame::ImplPaintPictureBitmap( 
vcl::RenderContext* pOut,
                 rAlignedGrfArea.Left(), rAlignedGrfArea.Top(),
                 rAlignedGrfArea.Right(), rAlignedGrfArea.Bottom());
 
+            Color aOldBackColor;
+            SvxDrawPage* pDrawPage = 
pOLENd->GetOLEObj().tryToGetChartDrawPage();
+            SdrPage* pPage = pDrawPage ? pDrawPage->GetSdrPage() : nullptr;
+            if (pPage)
+            {
+                SdrModel& rModel = pPage->getSdrModelFromSdrPage();
+                SdrOutliner& rOutl = rModel.GetDrawOutliner();
+                aOldBackColor = rOutl.GetBackgroundColor();
+                rOutl.SetBackgroundColor(pPage->GetPageBackgroundColor());
+            }
+
             bDone = paintUsingPrimitivesHelper(
                 *pOut,
                 aSequence,
                 aSourceRange,
                 aTargetRange);
+
+            if (pPage)
+                
pPage->getSdrModelFromSdrPage().GetDrawOutliner().SetBackgroundColor(aOldBackColor);
         }
     }
 
diff --git a/sw/source/core/ole/ndole.cxx b/sw/source/core/ole/ndole.cxx
index de94986797f3..00a727c72a6d 100644
--- a/sw/source/core/ole/ndole.cxx
+++ b/sw/source/core/ole/ndole.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
 #include <com/sun/star/embed/XEmbeddedObject.hpp>
 #include <com/sun/star/embed/XEmbedPersist.hpp>
 #include <com/sun/star/embed/XLinkageSupport.hpp>
@@ -47,11 +48,13 @@
 #include <IDocumentLayoutAccess.hxx>
 #include <comphelper/classids.hxx>
 #include <comphelper/propertyvalue.hxx>
+#include <comphelper/servicehelper.hxx>
 #include <vcl/graph.hxx>
 #include <sot/formats.hxx>
 #include <vcl/svapp.hxx>
 #include <strings.hrc>
 #include <svx/charthelper.hxx>
+#include <svx/unopage.hxx>
 #include <comphelper/threadpool.hxx>
 #include <atomic>
 #include <deque>
@@ -1235,6 +1238,22 @@ drawinglayer::primitive2d::Primitive2DContainer const & 
SwOLEObj::tryToGetChartC
     return m_aPrimitive2DSequence;
 }
 
+SvxDrawPage* SwOLEObj::tryToGetChartDrawPage() const
+{
+    if (!m_xOLERef.is() || !m_xOLERef.IsChart())
+        return nullptr;
+    const uno::Reference<frame::XModel> xModel(m_xOLERef->getComponent(), 
uno::UNO_QUERY);
+    if (!xModel.is())
+        return nullptr;
+    const uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xModel, 
uno::UNO_QUERY);
+    if (!xDrawPageSupplier)
+        return nullptr;
+    const uno::Reference<drawing::XDrawPage> 
xDrawPage(xDrawPageSupplier->getDrawPage());
+    if (!xDrawPage)
+        return nullptr;
+    return comphelper::getFromUnoTunnel<SvxDrawPage>(xDrawPage);
+}
+
 void SwOLEObj::resetBufferedData()
 {
     m_aPrimitive2DSequence = drawinglayer::primitive2d::Primitive2DContainer();

Reply via email to