summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorelixir <prashant3.yishu@gmail.com>2013-03-07 19:35:49 +0530
committerFridrich Strba <fridrich@documentfoundation.org>2013-03-11 15:50:44 +0000
commit7d1f4cdec307bb1e761bb5dd3d8231bba5833e10 (patch)
tree106a20fe24e8935e9b4943f17dad49dba67aa013 /unotools
parentc9d7427707ca36f60079833f53efd435202fe231 (diff)
fdo#38838: Converting String/UniString to OUString
Change-Id: If64db96005fcd8a42e4fa24041867b99183965f9 Reviewed-on: https://gerrit.libreoffice.org/2586 Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
Diffstat (limited to 'unotools')
-rw-r--r--unotools/inc/unotools/fontdefs.hxx8
-rw-r--r--unotools/source/misc/fontcvt.cxx28
-rw-r--r--unotools/source/misc/fontdefs.cxx99
3 files changed, 75 insertions, 60 deletions
diff --git a/unotools/inc/unotools/fontdefs.hxx b/unotools/inc/unotools/fontdefs.hxx
index df79a0f26eb2..f92346440f57 100644
--- a/unotools/inc/unotools/fontdefs.hxx
+++ b/unotools/inc/unotools/fontdefs.hxx
@@ -37,9 +37,9 @@ namespace utl {
#define SUBSFONT_PS ((sal_uLong)0x00000004)
#define SUBSFONT_HTML ((sal_uLong)0x00000008)
-UNOTOOLS_DLLPUBLIC String GetSubsFontName( const String& rName, sal_uLong nFlags );
+UNOTOOLS_DLLPUBLIC OUString GetSubsFontName( const OUString& rName, sal_uLong nFlags );
-UNOTOOLS_DLLPUBLIC void AddTokenFontName( String& rName, const String& rNewToken );
+UNOTOOLS_DLLPUBLIC void AddTokenFontName( OUString& rName, const OUString& rNewToken );
struct UNOTOOLS_DLLPUBLIC FontNameHash { int operator()(const String&) const; };
@@ -84,9 +84,9 @@ public:
#define DEFAULTFONT_CTL_HEADING ((sal_uInt16)4003)
#define DEFAULTFONT_CTL_DISPLAY ((sal_uInt16)4004)
-UNOTOOLS_DLLPUBLIC String GetNextFontToken( const String& rTokenStr, xub_StrLen& rIndex );
+UNOTOOLS_DLLPUBLIC OUString GetNextFontToken( const OUString& rTokenStr, sal_Int32& rIndex );
-UNOTOOLS_DLLPUBLIC void GetEnglishSearchFontName( String& rName );
+UNOTOOLS_DLLPUBLIC void GetEnglishSearchFontName( OUString& rName );
#endif
diff --git a/unotools/source/misc/fontcvt.cxx b/unotools/source/misc/fontcvt.cxx
index a11148884854..fe870ed48d1f 100644
--- a/unotools/source/misc/fontcvt.cxx
+++ b/unotools/source/misc/fontcvt.cxx
@@ -1432,40 +1432,40 @@ static ConvertChar aImplStarSymbolCvt = { NULL, "StarBats", ImplStarSymbolToStar
const ConvertChar* ConvertChar::GetRecodeData( const String& rOrgFontName, const String& rMapFontName )
{
const ConvertChar* pCvt = NULL;
- String aOrgName( rOrgFontName );
+ OUString aOrgName( rOrgFontName );
GetEnglishSearchFontName( aOrgName );
- String aMapName( rMapFontName );
+ OUString aMapName( rMapFontName );
GetEnglishSearchFontName( aMapName );
- if( aMapName.EqualsAscii( "starsymbol" )
- || aMapName.EqualsAscii( "opensymbol" ) )
+ if( aMapName == "starsymbol"
+ || aMapName == "opensymbol" )
{
int nEntries = SAL_N_ELEMENTS(aStarSymbolRecodeTable);
for( int i = 0; i < nEntries; ++i)
{
RecodeTable& r = aStarSymbolRecodeTable[i];
- if( aOrgName.EqualsAscii( r.pOrgName ) )
+ if( aOrgName.equalsAscii( r.pOrgName ) )
{ pCvt = &r.aCvt; break; }
}
}
//It's plausible that it's better to implement this
//as an additional encoding alongside the existing
//adobe-symbol to unicode conversion in rtl instead
- else if( aMapName.EqualsAscii("applesymbol") )
+ else if( aMapName == "applesymbol" )
{
int nEntries = SAL_N_ELEMENTS(aAppleSymbolRecodeTable);
for( int i = 0; i < nEntries; ++i)
{
RecodeTable& r = aAppleSymbolRecodeTable[i];
- if( aOrgName.EqualsAscii( r.pOrgName ) )
+ if( aOrgName.equalsAscii( r.pOrgName ) )
{ pCvt = &r.aCvt; break; }
}
}
- else if( aMapName.EqualsAscii( "starbats" ) )
+ else if( aMapName == "starbats" )
{
- if( aOrgName.EqualsAscii( "starsymbol" ) )
+ if( aOrgName == "starsymbol" )
pCvt = &aImplStarSymbolCvt;
- else if( aOrgName.EqualsAscii( "opensymbol" ) )
+ else if( aOrgName == "opensymbol" )
pCvt = &aImplStarSymbolCvt;
}
@@ -1479,7 +1479,7 @@ FontToSubsFontConverter CreateFontToSubsFontConverter(
{
const ConvertChar* pCvt = NULL;
- String aName = rOrgName;
+ OUString aName = rOrgName;
GetEnglishSearchFontName( aName );
if ( nFlags & FONTTOSUBSFONT_IMPORT )
@@ -1490,15 +1490,15 @@ FontToSubsFontConverter CreateFontToSubsFontConverter(
for( int i = 0; i < nEntries; ++i )
{
RecodeTable& r = aStarSymbolRecodeTable[i];
- if( aName.EqualsAscii( r.pOrgName ) )
+ if( aName.equalsAscii( r.pOrgName ) )
{ pCvt = &r.aCvt; break; }
}
}
else
{
// TODO: FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS
- if( aName.EqualsAscii( "starsymbol" ) ) pCvt = &aImplStarSymbolCvt;
- else if( aName.EqualsAscii( "opensymbol" ) ) pCvt = &aImplStarSymbolCvt;
+ if( aName == "starsymbol" ) pCvt = &aImplStarSymbolCvt;
+ else if( aName == "opensymbol" ) pCvt = &aImplStarSymbolCvt;
}
return (FontToSubsFontConverter)pCvt;
diff --git a/unotools/source/misc/fontdefs.cxx b/unotools/source/misc/fontdefs.cxx
index 7785e80757e1..35fe5351e726 100644
--- a/unotools/source/misc/fontdefs.cxx
+++ b/unotools/source/misc/fontdefs.cxx
@@ -20,6 +20,7 @@
#include <unotools/fontdefs.hxx>
#include <unotools/fontcfg.hxx>
#include <boost/unordered_map.hpp>
+#include <rtl/ustrbuf.hxx>
struct ImplLocalizedFontName
{
@@ -321,42 +322,42 @@ static ImplLocalizedFontName aImplLocalizedNamesList[] =
// -----------------------------------------------------------------------
-void GetEnglishSearchFontName( String& rName )
+void GetEnglishSearchFontName( OUString& rName )
{
bool bNeedTranslation = false;
- xub_StrLen nLen = rName.Len();
+ sal_Int32 nLen = rName.getLength();
// Remove trailing whitespaces
- xub_StrLen i = nLen;
- while ( i && (rName.GetChar( i-1 ) < 32) )
+ sal_Int32 i = nLen;
+ while ( i && (rName[ i-1 ] < 32) )
i--;
if ( i != nLen )
- rName.Erase( i );
+ rName.copy( 0, i );
// Remove Script at the end
// Scriptname must be the last part of the fontname and
// looks like "fontname (scriptname)". So there can only be a
// script name at the and of the fontname, when the last char is ')'
- if ( (nLen >= 3) && rName.GetChar( nLen-1 ) == ')' )
+ if ( (nLen >= 3) && rName[ nLen-1 ] == ')' )
{
int nOpen = 1;
- xub_StrLen nTempLen = nLen-2;
+ sal_Int32 nTempLen = nLen-2;
while ( nTempLen )
{
- if ( rName.GetChar( nTempLen ) == '(' )
+ if ( rName[ nTempLen ] == '(' )
{
nOpen--;
if ( !nOpen )
{
// Remove Space at the end
- if ( nTempLen && (rName.GetChar( nTempLen-1 ) == ' ') )
+ if ( nTempLen && (rName[ nTempLen-1 ] == ' ') )
nTempLen--;
- rName.Erase( nTempLen );
+ rName.copy( 0, nTempLen );
nLen = nTempLen;
break;
}
}
- if ( rName.GetChar( nTempLen ) == ')' )
+ if ( rName[ nTempLen ] == ')' )
nOpen++;
nTempLen--;
}
@@ -367,7 +368,7 @@ void GetEnglishSearchFontName( String& rName )
i = 0;
while ( i < nLen )
{
- sal_Unicode c = rName.GetChar( i );
+ sal_Unicode c = rName[ i ];
if ( c > 127 )
{
// Translate to Lowercase-ASCII
@@ -378,8 +379,13 @@ void GetEnglishSearchFontName( String& rName )
// Upper to Lower
if ( (c >= 'A') && (c <= 'Z') )
c += 'a' - 'A';
- rName.SetChar( i, c );
- }
+ //rName[ i ] = c ;
+
+ OUStringBuffer aTmpStr( rName.getStr() ) ;
+ aTmpStr[ i ] = c ;
+ rName = aTmpStr.makeStringAndClear() ;
+
+ }
else
{
// Only Fontnames with None-Ascii-Characters must be translated
@@ -393,12 +399,21 @@ void GetEnglishSearchFontName( String& rName )
if ( (c >= 'A') && (c <= 'Z') )
{
c += 'a' - 'A';
- rName.SetChar( i, c );
+ //rName[ i ] = c ;
+
+ OUStringBuffer aTmpStr( rName.getStr() ) ;
+ aTmpStr[ i ] = c ;
+ rName = aTmpStr.makeStringAndClear() ;
+
}
else if( ((c < '0') || (c > '9')) && (c != ';') ) // not 0-9 or semicolon
{
// Remove white spaces and special characters
- rName.Erase( i, 1 );
+
+ OUStringBuffer aTmpStr( rName.getStr() ) ;
+ aTmpStr.remove(i,1);
+ rName = aTmpStr.makeStringAndClear() ;
+
nLen--;
continue;
}
@@ -423,41 +438,41 @@ void GetEnglishSearchFontName( String& rName )
FontNameDictionary::const_iterator it = aDictionary.find( rName );
if( it != aDictionary.end() )
- rName.AssignAscii( it->second );
+ rName = OUString::createFromAscii ( it->second ) ;
}
}
// -----------------------------------------------------------------------
-String GetNextFontToken( const String& rTokenStr, xub_StrLen& rIndex )
+OUString GetNextFontToken( const OUString& rTokenStr, sal_Int32& rIndex )
{
// check for valid start index
- int nStringLen = rTokenStr.Len();
+ int nStringLen = rTokenStr.getLength();
if( rIndex >= nStringLen )
{
- rIndex = STRING_NOTFOUND;
- return String();
+ rIndex = -1;
+ return OUString();
}
// find the next token delimiter and return the token substring
- const sal_Unicode* pStr = rTokenStr.GetBuffer() + rIndex;
- const sal_Unicode* pEnd = rTokenStr.GetBuffer() + nStringLen;
+ const sal_Unicode* pStr = rTokenStr.getStr() + rIndex;
+ const sal_Unicode* pEnd = rTokenStr.getStr() + nStringLen;
for(; pStr < pEnd; ++pStr )
if( (*pStr == ';') || (*pStr == ',') )
break;
- xub_StrLen nTokenStart = rIndex;
- xub_StrLen nTokenLen;
+ sal_Int32 nTokenStart = rIndex;
+ sal_Int32 nTokenLen;
if( pStr < pEnd )
{
- rIndex = sal::static_int_cast<xub_StrLen>(pStr - rTokenStr.GetBuffer());
+ rIndex = sal::static_int_cast<sal_Int32>(pStr - rTokenStr.getStr());
nTokenLen = rIndex - nTokenStart;
++rIndex; // skip over token separator
}
else
{
// no token delimiter found => handle last token
- rIndex = STRING_NOTFOUND;
+ rIndex = -1;
nTokenLen = STRING_LEN;
// optimize if the token string consists of just one token
@@ -470,35 +485,35 @@ String GetNextFontToken( const String& rTokenStr, xub_StrLen& rIndex )
// =======================================================================
-static bool ImplIsFontToken( const String& rName, const String& rToken )
+static bool ImplIsFontToken( const OUString& rName, const String& rToken )
{
- String aTempName;
- xub_StrLen nIndex = 0;
+ OUString aTempName;
+ sal_Int32 nIndex = 0;
do
{
aTempName = GetNextFontToken( rName, nIndex );
if ( rToken == aTempName )
return true;
}
- while ( nIndex != STRING_NOTFOUND );
+ while ( nIndex != -1 );
return false;
}
// -----------------------------------------------------------------------
-static void ImplAppendFontToken( String& rName, const String& rNewToken )
+static void ImplAppendFontToken( OUString& rName, const String& rNewToken )
{
- if ( rName.Len() )
+ if ( rName.getLength() )
{
- rName.Append( ';' );
- rName.Append( rNewToken );
+ rName += ";" ;
+ rName += rNewToken ;
}
else
rName = rNewToken;
}
-void AddTokenFontName( String& rName, const String& rNewToken )
+void AddTokenFontName( OUString& rName, const OUString& rNewToken )
{
if ( !ImplIsFontToken( rName, rNewToken ) )
ImplAppendFontToken( rName, rNewToken );
@@ -506,18 +521,18 @@ void AddTokenFontName( String& rName, const String& rNewToken )
// =======================================================================
-String GetSubsFontName( const String& rName, sal_uLong nFlags )
+OUString GetSubsFontName( const OUString& rName, sal_uLong nFlags )
{
- String aName;
+ OUString aName;
- xub_StrLen nIndex = 0;
- String aOrgName = GetNextFontToken( rName, nIndex );
+ sal_Int32 nIndex = 0;
+ OUString aOrgName = GetNextFontToken( rName, nIndex );
GetEnglishSearchFontName( aOrgName );
// #93662# do not try to replace StarSymbol with MS only font
if( nFlags == (SUBSFONT_MS|SUBSFONT_ONLYONE)
- && ( aOrgName.EqualsAscii( "starsymbol" )
- || aOrgName.EqualsAscii( "opensymbol" ) ) )
+ && ( aOrgName == "starsymbol"
+ || aOrgName == "opensymbol" ) )
return aName;
const utl::FontNameAttr* pAttr = utl::FontSubstConfiguration::get().getSubstInfo( aOrgName );