drawinglayer/source/processor2d/cairopixelprocessor2d.cxx |   14 ++-
 drawinglayer/source/processor2d/processor2dtools.cxx      |   58 +++++++-------
 2 files changed, 41 insertions(+), 31 deletions(-)

New commits:
commit 2119f7fa5a0b5526d32d0c668d63778c49a4ec00
Author:     Tor Lillqvist <[email protected]>
AuthorDate: Sun Jan 11 09:37:08 2026 +0200
Commit:     Tor Lillqvist <[email protected]>
CommitDate: Sun Jan 11 22:55:17 2026 +0100

    Build fix for Windows in an --enable-headless build, i.e. CODA-W
    
    No need to look up a cairo function dynamically as we know that in
    Windows we are using a cairo we build ourselves so we can be sure that
    it is has what we want.
    
    There is a TEXT() macro in winnt.h, and we use that (indirectly)
    elsewhere, so we can't just undefine it in postwin.h. Thus we can't
    initialise a variable calld TEXT using parentheses.
    
    Check USE_HEADLESS_CODE before checking _WIN32 to get the former code
    in the CODA-W case and the latter otherwise for Windows.
    
    Change-Id: I8987e3b33d51ea232f8262413d17a50910d8e7b5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197007
    Tested-by: Jenkins
    Reviewed-by: Tor Lillqvist <[email protected]>

diff --git a/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx 
b/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx
index 0561d9ec27d0..26871b351307 100644
--- a/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/cairopixelprocessor2d.cxx
@@ -60,7 +60,9 @@
 #include <com/sun/star/awt/XView.hpp>
 #include <com/sun/star/awt/XControl.hpp>
 #include <unordered_map>
+#ifndef _WIN32
 #include <dlfcn.h>
+#endif
 #include "vclhelperbufferdevice.hxx"
 #include <iostream>
 
@@ -72,6 +74,7 @@ void impl_cairo_set_hairline(cairo_t* pRT,
                              const drawinglayer::geometry::ViewInformation2D& 
rViewInformation,
                              bool bCairoCoordinateLimitWorkaroundActive)
 {
+#ifndef _WIN32
 #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 18, 0)
     void* addr(dlsym(nullptr, "cairo_set_hairline"));
     if (nullptr != addr)
@@ -93,6 +96,13 @@ void impl_cairo_set_hairline(cairo_t* pRT,
                 .getLength());
         cairo_set_line_width(pRT, fPx);
     }
+#else
+    // No system cairo on Windows, so cairo is by necessity one built by us, 
and we know that it is
+    // the right version with cairo_set_hairline().
+    (void)rViewInformation;
+    (void)bCairoCoordinateLimitWorkaroundActive;
+    cairo_set_hairline(pRT, true);
+#endif
 }
 
 void addB2DPolygonToPathGeometry(cairo_t* pRT, const basegfx::B2DPolygon& 
rPolygon)
@@ -4445,8 +4455,8 @@ basegfx::BColor CairoPixelProcessor2D::getFillColor(const 
basegfx::BColor& rColo
 
 basegfx::BColor CairoPixelProcessor2D::getTextColor(const basegfx::BColor& 
rColor) const
 {
-    constexpr DrawModeFlags TEXT(DrawModeFlags::BlackText | 
DrawModeFlags::GrayText
-                                 | DrawModeFlags::SettingsText);
+    constexpr DrawModeFlags TEXT
+        = DrawModeFlags::BlackText | DrawModeFlags::GrayText | 
DrawModeFlags::SettingsText;
     const DrawModeFlags 
aDrawModeFlags(getViewInformation2D().getDrawModeFlags());
 
     if (!(aDrawModeFlags & TEXT))
diff --git a/drawinglayer/source/processor2d/processor2dtools.cxx 
b/drawinglayer/source/processor2d/processor2dtools.cxx
index 7dd25c118edb..cfb9c3897909 100644
--- a/drawinglayer/source/processor2d/processor2dtools.cxx
+++ b/drawinglayer/source/processor2d/processor2dtools.cxx
@@ -22,11 +22,11 @@
 #include "vclmetafileprocessor2d.hxx"
 #include <config_vclplug.h>
 
-#if defined(_WIN32)
+#if USE_HEADLESS_CODE
+#include <drawinglayer/processor2d/cairopixelprocessor2d.hxx>
+#elif defined(_WIN32)
 #include <drawinglayer/processor2d/d2dpixelprocessor2d.hxx>
 #include <vcl/sysdata.hxx>
-#elif USE_HEADLESS_CODE
-#include <drawinglayer/processor2d/cairopixelprocessor2d.hxx>
 #endif
 
 using namespace com::sun::star;
@@ -77,32 +77,7 @@ std::unique_ptr<BaseProcessor2D> 
createPixelProcessor2DFromOutputDevice(
     OutputDevice& rTargetOutDev,
     const drawinglayer::geometry::ViewInformation2D& rViewInformation2D)
 {
-#if defined(_WIN32)
-    // Windows: make dependent on TEST_SYSTEM_PRIMITIVE_RENDERER
-    static bool bUsePrimitiveRenderer(nullptr != 
std::getenv("TEST_SYSTEM_PRIMITIVE_RENDERER"));
-
-    if (bUsePrimitiveRenderer)
-    {
-        drawinglayer::geometry::ViewInformation2D 
aViewInformation2D(rViewInformation2D);
-
-        // if mnOutOffX/mnOutOffY is set (a 'hack' to get a cheap additional 
offset), apply it additionally
-        // NOTE: This will also need to take extended size of target device 
into
-        //       consideration, using D2DPixelProcessor2D *will* have to clip
-        //       against that. Thus for now this is *not* sufficient (see 
tdf#163125)
-        if(0 != rTargetOutDev.GetOutOffXPixel() || 0 != 
rTargetOutDev.GetOutOffYPixel())
-        {
-            basegfx::B2DHomMatrix 
aTransform(aViewInformation2D.getViewTransformation());
-            aTransform.translate(rTargetOutDev.GetOutOffXPixel(), 
rTargetOutDev.GetOutOffYPixel());
-            aViewInformation2D.setViewTransformation(aTransform);
-        }
-
-        SystemGraphicsData aData(rTargetOutDev.GetSystemGfxData());
-        std::unique_ptr<D2DPixelProcessor2D> aRetval(
-            std::make_unique<D2DPixelProcessor2D>(aViewInformation2D, 
aData.hDC));
-        if (aRetval->valid())
-            return aRetval;
-    }
-#elif USE_HEADLESS_CODE
+#if USE_HEADLESS_CODE
     // Linux/Cairo: now globally activated in master. Leave a
     // possibility to deactivate for easy test/request testing
     static bool bUsePrimitiveRenderer(nullptr == 
std::getenv("DISABLE_SYSTEM_DEPENDENT_PRIMITIVE_RENDERER"));
@@ -130,6 +105,31 @@ std::unique_ptr<BaseProcessor2D> 
createPixelProcessor2DFromOutputDevice(
             }
         }
     }
+#elif defined(_WIN32)
+    // Windows: make dependent on TEST_SYSTEM_PRIMITIVE_RENDERER
+    static bool bUsePrimitiveRenderer(nullptr != 
std::getenv("TEST_SYSTEM_PRIMITIVE_RENDERER"));
+
+    if (bUsePrimitiveRenderer)
+    {
+        drawinglayer::geometry::ViewInformation2D 
aViewInformation2D(rViewInformation2D);
+
+        // if mnOutOffX/mnOutOffY is set (a 'hack' to get a cheap additional 
offset), apply it additionally
+        // NOTE: This will also need to take extended size of target device 
into
+        //       consideration, using D2DPixelProcessor2D *will* have to clip
+        //       against that. Thus for now this is *not* sufficient (see 
tdf#163125)
+        if(0 != rTargetOutDev.GetOutOffXPixel() || 0 != 
rTargetOutDev.GetOutOffYPixel())
+        {
+            basegfx::B2DHomMatrix 
aTransform(aViewInformation2D.getViewTransformation());
+            aTransform.translate(rTargetOutDev.GetOutOffXPixel(), 
rTargetOutDev.GetOutOffYPixel());
+            aViewInformation2D.setViewTransformation(aTransform);
+        }
+
+        SystemGraphicsData aData(rTargetOutDev.GetSystemGfxData());
+        std::unique_ptr<D2DPixelProcessor2D> aRetval(
+            std::make_unique<D2DPixelProcessor2D>(aViewInformation2D, 
aData.hDC));
+        if (aRetval->valid())
+            return aRetval;
+    }
 #endif
 
     // default: create VclPixelProcessor2D

Reply via email to