diff options
author | Oliver Bolte <obo@openoffice.org> | 2009-02-17 10:33:03 +0000 |
---|---|---|
committer | Oliver Bolte <obo@openoffice.org> | 2009-02-17 10:33:03 +0000 |
commit | def439bf61a0ee058cb99ec1895d052a10fa4a19 (patch) | |
tree | 1cbab88198474baf91b73e8bd52dc048127567b1 /svtools/source/misc | |
parent | 1b52154648707fd93d6c0147d243b803a1f25711 (diff) |
CWS-TOOLING: integrate CWS vcl99
2009-01-29 15:34:04 +0100 hdu r267149 : #i77520# fix AquaSalGraphics::GetGlyphBoundRect() result y-sign
2009-01-29 10:14:23 +0100 hdu r267099 : #i77520# implement AquaSalGraphics::GetGlyphBoundRect()
2009-01-28 17:31:17 +0100 hdu r267071 : #i79046# restore MultiSalLayout components after drawing them
2009-01-28 12:02:19 +0100 tl r267050 : #78466# default curreny listbox for Arabic builds fixed
2009-01-28 11:54:21 +0100 tl r267049 : #78466# default curreny listbox for Arabic builds fixed
2009-01-28 11:43:44 +0100 tl r267047 : #78466# default curreny listbox for Arabic builds fixed
2009-01-28 11:17:42 +0100 tl r267041 : #78466# default curreny listbox for Arabic builds fixed
2009-01-28 11:14:30 +0100 tl r267038 : #78466# default curreny listbox for Arabic builds fixed
2009-01-28 10:33:03 +0100 tl r267032 : #i72073# auto spellcheck markups in RTL context fixed
2009-01-28 09:26:00 +0100 tl r267027 : #78466# default curreny listbox for Arabic builds fixed
2009-01-28 09:25:31 +0100 tl r267026 : #78466# default curreny listbox for Arabic builds fixed
2009-01-27 16:55:14 +0100 tl r267009 : #78466# default curreny listbox for Arabic builds fixed
2009-01-27 16:54:46 +0100 tl r267008 : #78466# default curreny listbox for Arabic builds fixed
2009-01-27 16:52:23 +0100 tl r267007 : #78466# default curreny listbox for Arabic builds fixed
2009-01-27 16:46:52 +0100 tl r267006 : #i72073# auto spellcheck markups in RTL context fixed
2009-01-27 11:53:53 +0100 pl r266975 : #i98515# fix a buffer overflow
2009-01-26 19:13:28 +0100 pl r266946 : #i98119# add static vcl object helper
2009-01-26 18:11:06 +0100 pl r266940 : #i94040# catch a corner case (thanks af)
2009-01-23 10:54:42 +0100 pl r266793 : #i92102# fix some RTL UI issues
2009-01-23 10:53:35 +0100 pl r266790 : #i98169# one more case of DrawWaveLine
2009-01-23 08:38:32 +0100 hdu r266768 : #i98139# prefer Tools->Options->FontSubstitution over PreMatchHook
2009-01-21 17:30:57 +0100 pl r266694 : #i92102# adjust spin buttons
2009-01-21 13:54:16 +0100 pl r266667 : #i97130# add Click handler
2009-01-21 13:32:47 +0100 os r266662 : #158646# set SwWrtShell in C'tor of SwIndexMarkDlg
2009-01-21 12:14:03 +0100 pl r266649 : #i98196# fix autospellchecking in writer
2009-01-19 14:25:28 +0100 pl r266497 : #i97130# implement functionality of ExplainButton
Diffstat (limited to 'svtools/source/misc')
-rw-r--r-- | svtools/source/misc/langtab.cxx | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/svtools/source/misc/langtab.cxx b/svtools/source/misc/langtab.cxx index 6226992136c8..870e6378a216 100644 --- a/svtools/source/misc/langtab.cxx +++ b/svtools/source/misc/langtab.cxx @@ -36,12 +36,97 @@ #include <tools/shl.hxx> #include <tools/debug.hxx> +//#include <com/sun/star/i18n/XCharacterClassification.hpp> +#include <com/sun/star/i18n/DirectionProperty.hpp> + #include <i18npool/lang.h> #include <i18npool/mslangid.hxx> #include <svtools/svtools.hrc> #include <svtools/svtdata.hxx> #include <svtools/langtab.hxx> +#include <svtools/syslocale.hxx> + + +using namespace ::com::sun::star; + +//------------------------------------------------------------------------ + +SVT_DLLPUBLIC const String ApplyLreOrRleEmbedding( const String &rText ) +{ + const USHORT nLen = rText.Len(); + if (nLen == 0) + return String(); + + const sal_Unicode cLRE_Embedding = 0x202A; // the start char of an LRE embedding + const sal_Unicode cRLE_Embedding = 0x202B; // the start char of an RLE embedding + const sal_Unicode cPopDirectionalFormat = 0x202C; // the unicode PDF (POP_DIRECTIONAL_FORMAT) char that terminates an LRE/RLE embedding + + // check if there are alreay embedding characters at the strings start + // if so change nothing + const sal_Unicode cChar = rText.GetBuffer()[0]; + if (cChar == cLRE_Embedding || cChar == cRLE_Embedding) + return rText; + + // since we only call the function getCharacterDirection + // it does not matter which locale the CharClass is for. + // Thus we can readily make use of SvtSysLocale::GetCharClass() + // which should come at no cost... + SvtSysLocale aSysLocale; + const CharClass &rCharClass = aSysLocale.GetCharClass(); + + // we should look for the first non-neutral LTR or RTL character + // and use that to determine the embedding of the whole text... + // Thus we can avoid to check every character of the text. + bool bFound = false; + bool bIsRtlText = false; + for (USHORT i = 0; i < nLen && !bFound; ++i) + { + sal_Int16 nDirection = rCharClass.getCharacterDirection( rText, i ); + switch (nDirection) + { + case i18n::DirectionProperty_LEFT_TO_RIGHT : + case i18n::DirectionProperty_LEFT_TO_RIGHT_EMBEDDING : + case i18n::DirectionProperty_LEFT_TO_RIGHT_OVERRIDE : + case i18n::DirectionProperty_EUROPEAN_NUMBER : + case i18n::DirectionProperty_ARABIC_NUMBER : // yes! arabic numbers are written from left to right + { + bIsRtlText = false; + bFound = true; + break; + } + + case i18n::DirectionProperty_RIGHT_TO_LEFT : + case i18n::DirectionProperty_RIGHT_TO_LEFT_ARABIC : + case i18n::DirectionProperty_RIGHT_TO_LEFT_EMBEDDING : + case i18n::DirectionProperty_RIGHT_TO_LEFT_OVERRIDE : + { + bIsRtlText = true; + bFound = true; + break; + } + + default: + { + // nothing to be done, character is considered to be neutral we need to look further ... + } + } + } + + sal_Unicode cStart = cLRE_Embedding; // default is to use LRE embedding characters + if (bIsRtlText) + cStart = cRLE_Embedding; // then use RLE embedding + + // add embedding start and end chars to the text if the direction could be determined + String aRes( rText ); + if (bFound) + { + aRes.Insert( cStart, 0 ); + aRes.Insert( cPopDirectionalFormat ); + } + + return aRes; +} //------------------------------------------------------------------------ |