[Libreoffice-commits] core.git: canvas/source

Caolán McNamara caolanm at redhat.com
Thu Mar 19 16:38:45 PDT 2015


 canvas/source/cairo/cairo_textlayout.cxx  |   43 +++++++++++++++++++++++++++++-
 canvas/source/cairo/cairo_win32_cairo.cxx |   38 --------------------------
 canvas/source/cairo/cairo_win32_cairo.hxx |    2 -
 3 files changed, 42 insertions(+), 41 deletions(-)

New commits:
commit b517c251a733692f39d02f986e5010f214aea697
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Mar 19 15:59:56 2015 +0000

    move ucs4toindex
    
    Change-Id: I8ae441a68ba74422c607a8830325c3afa954ad92
    Reviewed-on: https://gerrit.libreoffice.org/14908
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/canvas/source/cairo/cairo_textlayout.cxx b/canvas/source/cairo/cairo_textlayout.cxx
index 9b1fa47..936593a 100644
--- a/canvas/source/cairo/cairo_textlayout.cxx
+++ b/canvas/source/cairo/cairo_textlayout.cxx
@@ -325,6 +325,47 @@ namespace cairocanvas
         return true;
     }
 
+#ifdef CAIRO_HAS_WIN32_SURFACE
+    namespace
+    {
+        /**
+         * cairo::ucs4toindex: Convert ucs4 char to glyph index
+         * @param ucs4 an ucs4 char
+         * @param hfont current font
+         *
+         * @return true if successful
+         **/
+        unsigned long ucs4toindex(unsigned int ucs4, HFONT hfont)
+        {
+            wchar_t unicode[2];
+            WORD glyph_index;
+            HDC hdc = NULL;
+
+            hdc = CreateCompatibleDC (NULL);
+
+            if (!hdc) return 0;
+            if (!SetGraphicsMode (hdc, GM_ADVANCED))
+            {
+                DeleteDC (hdc);
+                return 0;
+            }
+
+            SelectObject (hdc, hfont);
+            SetMapMode (hdc, MM_TEXT);
+
+            unicode[0] = ucs4;
+            unicode[1] = 0;
+            if (GetGlyphIndicesW (hdc, unicode, 1, &glyph_index, 0) == GDI_ERROR)
+            {
+                glyph_index = 0;
+            }
+
+            DeleteDC (hdc);
+            return glyph_index;
+        }
+    }
+#endif
+
   /**
    * TextLayout::draw
    *
@@ -446,7 +487,7 @@ namespace cairocanvas
 #ifdef CAIRO_HAS_WIN32_SURFACE
                 // Cairo requires standard glyph indexes (ETO_GLYPH_INDEX), while vcl/win/* uses ucs4 chars.
                 // Convert to standard indexes
-                aGlyph.index = cairo::ucs4toindex((unsigned int) aGlyph.index, rSysFontData.hFont);
+                aGlyph.index = ucs4toindex((unsigned int) aGlyph.index, rSysFontData.hFont);
 #endif
                 aGlyph.x = systemGlyph.x;
                 aGlyph.y = systemGlyph.y;
diff --git a/canvas/source/cairo/cairo_win32_cairo.cxx b/canvas/source/cairo/cairo_win32_cairo.cxx
index a54c7e1..d6a4aba 100644
--- a/canvas/source/cairo/cairo_win32_cairo.cxx
+++ b/canvas/source/cairo/cairo_win32_cairo.cxx
@@ -249,44 +249,6 @@ namespace cairo
             return SurfaceSharedPtr();
     }
 
-
-    /**
-     * cairo::ucs4toindex: Convert ucs4 char to glyph index
-     * @param ucs4 an ucs4 char
-     * @param hfont current font
-     *
-     * @return true if successful
-     **/
-    unsigned long ucs4toindex(unsigned int ucs4, HFONT hfont)
-    {
-        wchar_t unicode[2];
-        WORD glyph_index;
-        HDC hdc = NULL;
-
-        hdc = CreateCompatibleDC (NULL);
-
-        if (!hdc) return 0;
-        if (!SetGraphicsMode (hdc, GM_ADVANCED))
-        {
-            DeleteDC (hdc);
-            return 0;
-        }
-
-        SelectObject (hdc, hfont);
-        SetMapMode (hdc, MM_TEXT);
-
-        unicode[0] = ucs4;
-        unicode[1] = 0;
-        if (GetGlyphIndicesW (hdc, unicode, 1, &glyph_index, 0) == GDI_ERROR)
-        {
-            glyph_index = 0;
-        }
-
-        DeleteDC (hdc);
-        return glyph_index;
-    }
-
-
 }  // namespace cairo
 
 #endif   // CAIRO_HAS_WIN32_SURFACE
diff --git a/canvas/source/cairo/cairo_win32_cairo.hxx b/canvas/source/cairo/cairo_win32_cairo.hxx
index 50bd137..6df30f5 100644
--- a/canvas/source/cairo/cairo_win32_cairo.hxx
+++ b/canvas/source/cairo/cairo_win32_cairo.hxx
@@ -49,8 +49,6 @@ namespace cairo {
 
         int getDepth() const;
     };
-
-    unsigned long ucs4toindex(unsigned int ucs4, HFONT hfont);
 }
 
 #endif


More information about the Libreoffice-commits mailing list