[Libreoffice-commits] .: vcl/generic

Michael Meeks michael at kemper.freedesktop.org
Tue Feb 28 06:24:47 PST 2012


 vcl/generic/print/glyphset.cxx |   76 +++++++----------------------------------
 vcl/generic/print/glyphset.hxx |    3 +
 2 files changed, 15 insertions(+), 64 deletions(-)

New commits:
commit 15cf249967a56e1d6b28b659c00e201161f2e98f
Author: Christina Rossmanith <ChrRossmanith at web.de>
Date:   Tue Feb 28 11:04:12 2012 +0100

    Reduced duplicate code (simian) / vcl/generic/print/glyphset.cxx

diff --git a/vcl/generic/print/glyphset.cxx b/vcl/generic/print/glyphset.cxx
index 5b03666..6d4cfde 100644
--- a/vcl/generic/print/glyphset.cxx
+++ b/vcl/generic/print/glyphset.cxx
@@ -479,7 +479,8 @@ void GlyphSet::DrawGlyphs(
                           const sal_uInt32* pGlyphIds,
                           const sal_Unicode* pUnicodes,
                           sal_Int16 nLen,
-                          const sal_Int32* pDeltaArray )
+                          const sal_Int32* pDeltaArray,
+                          const sal_Bool bUseGlyphs)
 {
     sal_uChar *pGlyphID    = (sal_uChar*)alloca (nLen * sizeof(sal_uChar));
     sal_Int32 *pGlyphSetID = (sal_Int32*)alloca (nLen * sizeof(sal_Int32));
@@ -488,7 +489,10 @@ void GlyphSet::DrawGlyphs(
     // convert unicode to font glyph id and font subset
     for (int nChar = 0; nChar < nLen; nChar++)
     {
-        GetGlyphID (pGlyphIds[nChar], pUnicodes[nChar], pGlyphID + nChar, pGlyphSetID + nChar);
+        if (bUseGlyphs)
+            GetGlyphID (pGlyphIds[nChar], pUnicodes[nChar], pGlyphID + nChar, pGlyphSetID + nChar);
+        else
+            GetCharID (pUnicodes[nChar], pGlyphID + nChar, pGlyphSetID + nChar);
         aGlyphSet.insert (pGlyphSetID[nChar]);
     }
 
@@ -536,7 +540,12 @@ void GlyphSet::DrawGlyphs(
         // show the text using the PrinterGfx text api
         aPoint.Move (nOffset, 0);
 
-        OString aGlyphSetName(GetGlyphSetName(*aSet));
+        OString aGlyphSetName;
+        if (bUseGlyphs)
+            aGlyphSetName = GetGlyphSetName(*aSet);
+        else
+            aGlyphSetName = GetCharSetName(*aSet);
+
         rGfx.PSSetFont  (aGlyphSetName, GetGlyphSetEncoding(*aSet));
         rGfx.PSMoveTo   (aPoint);
         rGfx.PSShowText (pGlyphSubset, nGlyphs, nGlyphs, nGlyphs > 1 ? pDeltaSubset : NULL);
@@ -614,66 +623,7 @@ GlyphSet::ImplDrawText (PrinterGfx &rGfx, const Point& rPoint,
         return;
     }
 
-    sal_uChar *pGlyphID    = (sal_uChar*)alloca (nLen * sizeof(sal_uChar));
-    sal_Int32 *pGlyphSetID = (sal_Int32*)alloca (nLen * sizeof(sal_Int32));
-    std::set< sal_Int32 > aGlyphSet;
-
-    // convert unicode to font glyph id and font subset
-    for (int nChar = 0; nChar < nLen; nChar++)
-    {
-        GetCharID (pStr[nChar], pGlyphID + nChar, pGlyphSetID + nChar);
-        aGlyphSet.insert (pGlyphSetID[nChar]);
-    }
-
-    // loop over all glyph sets to detect substrings that can be xshown together
-    // without changing the postscript font
-    sal_Int32 *pDeltaSubset = (sal_Int32*)alloca (nLen * sizeof(sal_Int32));
-    sal_uChar *pGlyphSubset = (sal_uChar*)alloca (nLen * sizeof(sal_uChar));
-
-    std::set< sal_Int32 >::iterator aSet;
-    for (aSet = aGlyphSet.begin(); aSet != aGlyphSet.end(); ++aSet)
-    {
-        Point     aPoint  = rPoint;
-        sal_Int32 nOffset = 0;
-        sal_Int32 nGlyphs = 0;
-        sal_Int32 nChar;
-
-        // get offset to first glyph
-        for (nChar = 0; (nChar < nLen) && (pGlyphSetID[nChar] != *aSet); nChar++)
-        {
-            nOffset = pDeltaArray [nChar];
-        }
-
-        // loop over all chars to extract those that share the current glyph set
-        for (nChar = 0; nChar < nLen; nChar++)
-        {
-            if (pGlyphSetID[nChar] == *aSet)
-            {
-                pGlyphSubset [nGlyphs] = pGlyphID [nChar];
-                // the offset to the next glyph is determined by the glyph in
-                // front of the next glyph with the same glyphset id
-                // most often, this will be the current glyph
-                while ((nChar + 1) < nLen)
-                {
-                    if (pGlyphSetID[nChar + 1] == *aSet)
-                        break;
-                    else
-                        nChar += 1;
-                }
-                pDeltaSubset [nGlyphs] = pDeltaArray[nChar] - nOffset;
-
-                nGlyphs += 1;
-            }
-        }
-
-        // show the text using the PrinterGfx text api
-        aPoint.Move (nOffset, 0);
-
-        OString aGlyphSetName(GetCharSetName(*aSet));
-        rGfx.PSSetFont  (aGlyphSetName, GetGlyphSetEncoding(*aSet));
-        rGfx.PSMoveTo   (aPoint);
-        rGfx.PSShowText (pGlyphSubset, nGlyphs, nGlyphs, nGlyphs > 1 ? pDeltaSubset : NULL);
-    }
+    DrawGlyphs( rGfx, rPoint, NULL, pStr, nLen, pDeltaArray, sal_False);
 }
 
 sal_Bool
diff --git a/vcl/generic/print/glyphset.hxx b/vcl/generic/print/glyphset.hxx
index d2d5a3f..1d6eb6f 100644
--- a/vcl/generic/print/glyphset.hxx
+++ b/vcl/generic/print/glyphset.hxx
@@ -121,7 +121,8 @@ public:
                                 const sal_uInt32* pGlyphIds,
                                 const sal_Unicode* pUnicodes,
                                 sal_Int16 nLen,
-                                const sal_Int32* pDeltaArray );
+                                const sal_Int32* pDeltaArray,
+                                sal_Bool bUseGlyphs=sal_True);
     sal_Bool        PSUploadEncoding(osl::File* pOutFile, PrinterGfx &rGfx);
     sal_Bool        PSUploadFont (osl::File& rOutFile, PrinterGfx &rGfx, bool bAsType42, std::list< rtl::OString >& rSuppliedFonts );
 };


More information about the Libreoffice-commits mailing list