Kaydet (Commit) 414b118a authored tarafından Chris Sherlock's avatar Chris Sherlock Kaydeden (comit) Chris Sherlock

vcl: vcldemo now shows Arabic text

Change-Id: I7151341962457d46454c07d0a7a5c08b16c23791
Reviewed-on: https://gerrit.libreoffice.org/14186Reviewed-by: 's avatarChris Sherlock <chris.sherlock79@gmail.com>
Tested-by: 's avatarChris Sherlock <chris.sherlock79@gmail.com>
üst 786d5bce
...@@ -301,17 +301,46 @@ public: ...@@ -301,17 +301,46 @@ public:
RENDER_DETAILS(text,KEY_T,1) RENDER_DETAILS(text,KEY_T,1)
bool mbClip; bool mbClip;
bool mbArabicText;
DrawText() : DrawText()
mbClip (false) {} : mbClip (false)
, mbArabicText (false) {}
DrawText( bool bClip ) DrawText( bool bClip, bool bArabicText )
: mbClip (bClip) {} : mbClip (bClip)
, mbArabicText (bArabicText) {}
virtual void RenderRegion(OutputDevice &rDev, Rectangle r, virtual void RenderRegion(OutputDevice &rDev, Rectangle r,
const RenderContext &) SAL_OVERRIDE 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; std::vector<OUString> maFontNames;
sal_uInt32 nCols[] = { sal_uInt32 nCols[] = {
COL_BLACK, COL_BLUE, COL_GREEN, COL_CYAN, COL_RED, COL_MAGENTA, COL_BLACK, COL_BLUE, COL_GREEN, COL_CYAN, COL_RED, COL_MAGENTA,
...@@ -328,13 +357,12 @@ public: ...@@ -328,13 +357,12 @@ public:
if (mbClip) if (mbClip)
rDev.SetClipRegion( vcl::Region(r - Point(200, 200) ) ); rDev.SetClipRegion( vcl::Region(r - Point(200, 200) ) );
#define PRINT_N_TEXT 20 for (int i = 0; i < nPrintNumCopies; i++) {
for (int i = 0; i < PRINT_N_TEXT; i++) {
rDev.SetTextColor(Color(nCols[i % SAL_N_ELEMENTS(nCols)])); rDev.SetTextColor(Color(nCols[i % SAL_N_ELEMENTS(nCols)]));
// random font size to avoid buffering // 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.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) if (mbClip)
...@@ -347,7 +375,15 @@ public: ...@@ -347,7 +375,15 @@ public:
RENDER_DETAILS(cliptext,KEY_T,1) RENDER_DETAILS(cliptext,KEY_T,1)
DrawClipText() DrawClipText()
: DrawText( true ) {} : DrawText( true, false ) {}
};
struct DrawArabicText : public DrawText
{
RENDER_DETAILS(arabictext,KEY_T,1)
DrawArabicText()
: DrawText( false, true ) {}
}; };
struct DrawCheckered : public RegionRenderer struct DrawCheckered : public RegionRenderer
...@@ -1145,6 +1181,7 @@ void DemoRenderer::InitRenderers() ...@@ -1145,6 +1181,7 @@ void DemoRenderer::InitRenderers()
maRenderers.push_back(new DrawLines()); maRenderers.push_back(new DrawLines());
maRenderers.push_back(new DrawText()); maRenderers.push_back(new DrawText());
maRenderers.push_back(new DrawClipText()); maRenderers.push_back(new DrawClipText());
maRenderers.push_back(new DrawArabicText());
maRenderers.push_back(new DrawPoly()); maRenderers.push_back(new DrawPoly());
maRenderers.push_back(new DrawEllipse()); maRenderers.push_back(new DrawEllipse());
maRenderers.push_back(new DrawCheckered()); maRenderers.push_back(new DrawCheckered());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment