[Libreoffice-commits] core.git: vcl/workben

Chris Sherlock chris.sherlock at collabora.com
Tue Jan 27 03:17:57 PST 2015


 vcl/workben/vcldemo.cxx |   57 +++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 47 insertions(+), 10 deletions(-)

New commits:
commit 414b118a80c81ef1737958d91331e5b46f4cd3c1
Author: Chris Sherlock <chris.sherlock at collabora.com>
Date:   Tue Jan 27 01:37:44 2015 +1100

    vcl: vcldemo now shows Arabic text
    
    Change-Id: I7151341962457d46454c07d0a7a5c08b16c23791
    Reviewed-on: https://gerrit.libreoffice.org/14186
    Reviewed-by: Chris Sherlock <chris.sherlock79 at gmail.com>
    Tested-by: Chris Sherlock <chris.sherlock79 at gmail.com>

diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index 4ddeb5c..99bac91 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -301,17 +301,46 @@ public:
         RENDER_DETAILS(text,KEY_T,1)
 
         bool mbClip;
+        bool mbArabicText;
 
-        DrawText() :
-            mbClip (false) {}
+        DrawText()
+            : mbClip (false)
+            , mbArabicText (false) {}
 
-        DrawText( bool bClip )
-            : mbClip (bClip) {}
+        DrawText( bool bClip, bool bArabicText )
+            : mbClip (bClip)
+            , mbArabicText (bArabicText) {}
 
         virtual void RenderRegion(OutputDevice &rDev, Rectangle r,
                                   const RenderContext &) SAL_OVERRIDE
         {
-            OUString aText("Click any rect to zoom!!!!");
+            OUString aLatinText("Click any rect to zoom!!!!");
+
+            const unsigned char pTextUTF8[] = {
+                0xd9, 0x88, 0xd8, 0xa7, 0xd8, 0xad, 0xd9, 0x90,
+                0xd8, 0xaf, 0xd9, 0x92, 0x20, 0xd8, 0xa5, 0xd8,
+                0xab, 0xd9, 0x8d, 0xd9, 0x86, 0xd9, 0x8a, 0xd9,
+                0x86, 0x20, 0xd8, 0xab, 0xd9, 0x84, 0xd8, 0xa7,
+                0xd8, 0xab, 0xd8, 0xa9, 0xd9, 0x8c, 0x00
+            };
+            OUString aArabicText( reinterpret_cast<char const *>(pTextUTF8),
+                            SAL_N_ELEMENTS( pTextUTF8 ) - 1,
+                            RTL_TEXTENCODING_UTF8 );
+
+            OUString aText;
+            int nPrintNumCopies;
+
+            if (mbArabicText)
+            {
+                aText = aArabicText;
+                nPrintNumCopies=2;
+            }
+            else
+            {
+                aText = aLatinText;
+                nPrintNumCopies=20;
+            }
+
             std::vector<OUString> maFontNames;
             sal_uInt32 nCols[] = {
                 COL_BLACK, COL_BLUE, COL_GREEN, COL_CYAN, COL_RED, COL_MAGENTA,
@@ -328,13 +357,12 @@ public:
             if (mbClip)
                 rDev.SetClipRegion( vcl::Region(r - Point(200, 200) ) );
 
-#define PRINT_N_TEXT 20
-            for (int i = 0; i < PRINT_N_TEXT; i++) {
+            for (int i = 0; i < nPrintNumCopies; i++) {
                 rDev.SetTextColor(Color(nCols[i % SAL_N_ELEMENTS(nCols)]));
                 // random font size to avoid buffering
-                vcl::Font aFont(maFontNames[i % maFontNames.size()], Size(0, 1 + i * (0.9 + comphelper::rng::uniform_real_distribution(0.0, std::nextafter(0.1, DBL_MAX))) * (r.Top() - r.Bottom())/PRINT_N_TEXT));
+                vcl::Font aFont(maFontNames[i % maFontNames.size()], Size(0, 1 + i * (0.9 + comphelper::rng::uniform_real_distribution(0.0, std::nextafter(0.1, DBL_MAX))) * (r.Top() - r.Bottom()) / nPrintNumCopies));
                 rDev.SetFont(aFont);
-                rDev.DrawText(r, aText.copy(0, 4 + (aText.getLength() - 4) * (PRINT_N_TEXT - i)/PRINT_N_TEXT));
+                rDev.DrawText(r, aText.copy(0, 4 + (aText.getLength() - 4) * (nPrintNumCopies - i) / nPrintNumCopies));
             }
 
             if (mbClip)
@@ -347,7 +375,15 @@ public:
         RENDER_DETAILS(cliptext,KEY_T,1)
 
         DrawClipText()
-            : DrawText( true ) {}
+            : DrawText( true, false ) {}
+    };
+
+    struct DrawArabicText : public DrawText
+    {
+        RENDER_DETAILS(arabictext,KEY_T,1)
+
+        DrawArabicText()
+            : DrawText( false, true ) {}
     };
 
     struct DrawCheckered : public RegionRenderer
@@ -1145,6 +1181,7 @@ void DemoRenderer::InitRenderers()
     maRenderers.push_back(new DrawLines());
     maRenderers.push_back(new DrawText());
     maRenderers.push_back(new DrawClipText());
+    maRenderers.push_back(new DrawArabicText());
     maRenderers.push_back(new DrawPoly());
     maRenderers.push_back(new DrawEllipse());
     maRenderers.push_back(new DrawCheckered());


More information about the Libreoffice-commits mailing list