ByteString -> rtl::OString

This commit is contained in:
Caolán McNamara 2011-06-14 13:58:39 +01:00
parent 78fc50f06e
commit 4a641de8e0
4 changed files with 18 additions and 15 deletions

View file

@ -447,7 +447,7 @@ void Export::InitForcedLanguages( bool bMergeMode ){
ByteString Export::GetFallbackLanguage( const ByteString nLanguage )
/*****************************************************************************/
{
ByteString sFallback=nLanguage;
rtl::OString sFallback=nLanguage;
GetIsoFallback( sFallback );
return sFallback;
}

View file

@ -57,7 +57,7 @@ void HelpParser::FillInFallbacks( LangHashMap& rElem_out, ByteString sLangIdx_in
XMLElement* pTmp2 = NULL;
sCur = sLangIdx_in;
ByteString sFallback( sCur );
rtl::OString sFallback( sCur );
GetIsoFallback( sFallback );
if( (rElem_out.find( sFallback ) != rElem_out.end()) && rElem_out[ sFallback ] != NULL ){
pTmp2 = rElem_out[ sFallback ];

View file

@ -29,11 +29,11 @@
#ifndef _ISOFALLBACK_HXX
#define _ISOFALLBACK_HXX
#include <tools/string.hxx>
#include <rtl/string.hxx>
#include "tools/toolsdllapi.h"
// Return true if valid fallback found
TOOLS_DLLPUBLIC sal_Bool GetIsoFallback( ByteString& rLanguage );
TOOLS_DLLPUBLIC bool GetIsoFallback(rtl::OString& rLanguage);
#endif //_ISOFALLBACK_HXX

View file

@ -34,35 +34,38 @@
// -----------------------------------------------------------------------
// Return true if valid fallback found
sal_Bool GetIsoFallback( ByteString& rLanguage )
bool GetIsoFallback(rtl::OString& rLanguage)
{
rLanguage.EraseLeadingAndTrailingChars();
if( rLanguage.Len() ){
xub_StrLen nSepPos = rLanguage.Search( '-' );
if ( nSepPos == STRING_NOTFOUND ){
if ( rLanguage.Equals("en"))
rLanguage = rLanguage.trim();
if (!rLanguage.isEmpty())
{
sal_Int32 nSepPos = rLanguage.indexOf('-');
if (nSepPos == -1)
{
if (rLanguage == rtl::OString(RTL_CONSTASCII_STRINGPARAM("en")))
{
// en -> ""
rLanguage.Erase();
rLanguage = rtl::OString();
return false;
}
else
{
// de -> en-US ;
rLanguage = ByteString("en-US");
rLanguage = rtl::OString(RTL_CONSTASCII_STRINGPARAM("en-US"));
return true;
}
}
else if( !( nSepPos == 1 && ( rLanguage.GetChar(0) == 'x' || rLanguage.GetChar(0) == 'X' ) ) )
else if( !(nSepPos == 1 && (rLanguage.toChar() == 'x' || rLanguage.toChar() == 'X')) )
{
// de-CH -> de ;
// try erase from -
rLanguage = rLanguage.GetToken( 0, '-');
sal_Int32 nIndex = 0;
rLanguage = rLanguage.getToken(0, '-', nIndex);
return true;
}
}
// "" -> ""; x-no-translate -> ""
rLanguage.Erase();
rLanguage = rtl::OString();
return false;
}