diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-09-13 15:31:28 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-09-13 16:02:05 +0100 |
commit | f10a116b146a5ee7b796556f5811dda8569dbefe (patch) | |
tree | da1a6c9d6870d9ab92e1010fb14528d0479b37f7 /tools | |
parent | Use saner permission on files. (diff) | |
download | core-f10a116b146a5ee7b796556f5811dda8569dbefe.tar.gz core-f10a116b146a5ee7b796556f5811dda8569dbefe.zip |
power up the chainsaw again
Diffstat (limited to 'tools')
-rw-r--r-- | tools/inc/tools/string.hxx | 2 | ||||
-rw-r--r-- | tools/source/string/strcvt.cxx | 192 |
2 files changed, 0 insertions, 194 deletions
diff --git a/tools/inc/tools/string.hxx b/tools/inc/tools/string.hxx index 091a5abb5745..40bf4e45fe72 100644 --- a/tools/inc/tools/string.hxx +++ b/tools/inc/tools/string.hxx @@ -161,8 +161,6 @@ private: TOOLS_DLLPRIVATE inline char * ImplCopyStringData(char *); TOOLS_DLLPRIVATE void ImplUpdateStringFromUniString( sal_Unicode const *, sal_Size, rtl_TextEncoding, sal_uInt32); - TOOLS_DLLPRIVATE void ImplStringConvert( - rtl_TextEncoding, rtl_TextEncoding, sal_Bool); ByteString( const int* pDummy ); // not implemented: to prevent ByteString( NULL ) ByteString(int); // not implemented; to detect misuses diff --git a/tools/source/string/strcvt.cxx b/tools/source/string/strcvt.cxx index b61b0079494a..2515ebfbf8b7 100644 --- a/tools/source/string/strcvt.cxx +++ b/tools/source/string/strcvt.cxx @@ -57,44 +57,6 @@ ByteString::ByteString( const UniString& rUniStr, rtl_TextEncoding eTextEncoding // ======================================================================= -static sal_uChar aImplByteTab[256] = -{ - 0, 1, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, 92, 93, 94, 95, - 96, 97, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127, - 128, 129, 130, 131, 132, 133, 134, 135, - 136, 137, 138, 139, 140, 141, 142, 143, - 144, 145, 146, 147, 148, 149, 150, 151, - 152, 153, 154, 155, 156, 157, 158, 159, - 160, 161, 162, 163, 164, 165, 166, 167, - 168, 169, 170, 171, 172, 173, 174, 175, - 176, 177, 178, 179, 180, 181, 182, 183, - 184, 185, 186, 187, 188, 189, 190, 191, - 192, 193, 194, 195, 196, 197, 198, 199, - 200, 201, 202, 203, 204, 205, 206, 207, - 208, 209, 210, 211, 212, 213, 214, 215, - 216, 217, 218, 219, 220, 221, 222, 223, - 224, 225, 226, 227, 228, 229, 230, 231, - 232, 233, 234, 235, 236, 237, 238, 239, - 240, 241, 242, 243, 244, 245, 246, 247, - 248, 249, 250, 251, 252, 253, 254, 255 -}; - -// ======================================================================= - struct Impl1ByteUnicodeTabData { rtl_TextEncoding meTextEncoding; @@ -113,103 +75,6 @@ struct Impl1ByteConvertTabData Impl1ByteConvertTabData* mpNext; }; -// ----------------------------------------------------------------------- - -static sal_uChar* ImplGet1ByteConvertTab( rtl_TextEncoding eSrcTextEncoding, - rtl_TextEncoding eDestTextEncoding, - sal_Bool bReplace ) -{ -#ifndef BOOTSTRAP - TOOLSINDATA* pToolsData = ImplGetToolsInData(); -#else - TOOLSINDATA* pToolsData = 0x0; -#endif - Impl1ByteConvertTabData* pTab = pToolsData->mpFirstConvertTabData; - - while ( pTab ) - { - if ( (pTab->meSrcTextEncoding == eSrcTextEncoding) && - (pTab->meDestTextEncoding == eDestTextEncoding) ) - { - if ( bReplace ) - return pTab->maRepConvertTab; - else - return pTab->maConvertTab; - } - pTab = pTab->mpNext; - } - - // get TextEncodingInfo - rtl_TextEncodingInfo aTextEncInfo1; - aTextEncInfo1.StructSize = sizeof( aTextEncInfo1 ); - rtl_getTextEncodingInfo( eSrcTextEncoding, &aTextEncInfo1 ); - rtl_TextEncodingInfo aTextEncInfo2; - aTextEncInfo2.StructSize = sizeof( aTextEncInfo2 ); - rtl_getTextEncodingInfo( eDestTextEncoding, &aTextEncInfo2 ); - - if ( (aTextEncInfo1.MaximumCharSize == 1) && - (aTextEncInfo2.MaximumCharSize == 1) ) - { - pTab = new Impl1ByteConvertTabData; - pTab->meSrcTextEncoding = eSrcTextEncoding; - pTab->meDestTextEncoding = eDestTextEncoding; - pTab->mpNext = pToolsData->mpFirstConvertTabData; - - rtl_TextToUnicodeConverter hConverter; - rtl_UnicodeToTextConverter hConverter2; - sal_uInt32 nInfo; - sal_Size nSrcBytes; - sal_Size nDestChars; - sal_Size nSrcChars; - sal_Size nDestBytes; - sal_Unicode aTempBuf[256]; - hConverter = rtl_createTextToUnicodeConverter( eSrcTextEncoding ); - nDestChars = rtl_convertTextToUnicode( hConverter, 0, - (const sal_Char*)aImplByteTab, 256, - aTempBuf, 256, - RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_DEFAULT | - RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT | - RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT, - &nInfo, &nSrcBytes ); - rtl_destroyTextToUnicodeConverter( hConverter ); - if ( (nSrcBytes != 256) || (nDestChars != 256) ) - delete pTab; - else - { - hConverter2 = rtl_createUnicodeToTextConverter( eDestTextEncoding ); - nDestBytes = rtl_convertUnicodeToText( hConverter2, 0, - aTempBuf, 256, - (sal_Char*)pTab->maConvertTab, 256, - RTL_UNICODETOTEXT_FLAGS_UNDEFINED_0 | - RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT, - &nInfo, &nSrcChars ); - if ( (nDestBytes == 256) || (nSrcChars == 256) ) - { - nDestBytes = rtl_convertUnicodeToText( hConverter2, 0, - aTempBuf, 256, - (sal_Char*)pTab->maRepConvertTab, 256, - RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT | - RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT | - RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE, - &nInfo, &nSrcChars ); - } - rtl_destroyUnicodeToTextConverter( hConverter2 ); - if ( (nDestBytes != 256) || (nSrcChars != 256) ) - delete pTab; - else - { - pToolsData->mpFirstConvertTabData = pTab; - if ( bReplace ) - return pTab->maRepConvertTab; - else - return pTab->maConvertTab; - } - } - } - - return NULL; -} - // ======================================================================= void ImplDeleteCharTabData() @@ -242,63 +107,6 @@ void ImplDeleteCharTabData() // ======================================================================= -void ByteString::ImplStringConvert( - rtl_TextEncoding eSource, rtl_TextEncoding eTarget, sal_Bool bReplace ) -{ - sal_uChar* pConvertTab = ImplGet1ByteConvertTab( eSource, eTarget, bReplace ); - if ( pConvertTab ) - { - char* pStr = mpData->maStr; - while ( *pStr ) - { - sal_uChar c = (sal_uChar)*pStr; - sal_uChar cConv = pConvertTab[c]; - if ( c != cConv ) - { - pStr = ImplCopyStringData( pStr ); - *pStr = (char)cConv; - } - - pStr++; - } - } - else - { - rtl_UnicodeToTextConverter hSrcConverter = rtl_createTextToUnicodeConverter( eSource ); - sal_uInt32 nInfo; - sal_Size nSrcBytes; - sal_Size nDestChars; - sal_Size nTempLen; - sal_Unicode* pTempBuf; - nTempLen = mpData->mnLen; - pTempBuf = new sal_Unicode[nTempLen]; - nDestChars = rtl_convertTextToUnicode( hSrcConverter, 0, - mpData->maStr, mpData->mnLen, - pTempBuf, nTempLen, - RTL_TEXTTOUNICODE_FLAGS_FLUSH | - RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MAPTOPRIVATE | - RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT | - RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT, - &nInfo, &nSrcBytes ); - rtl_destroyTextToUnicodeConverter( hSrcConverter ); - // Hier werten wir bReplace nicht aus, da fuer MultiByte-Textencodings - // sowieso keine Ersatzdarstellung moeglich ist. Da sich der String - // sowieso in der Laenge aendern kann, nehmen wir auch sonst keine - // Ruecksicht darauf, das die Laenge erhalten bleibt. - ImplUpdateStringFromUniString( pTempBuf, nDestChars, eTarget, - RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT | - RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT | - RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE | - RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACESTR | - RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 | - RTL_UNICODETOTEXT_FLAGS_NONSPACING_IGNORE | - RTL_UNICODETOTEXT_FLAGS_CONTROL_IGNORE ); - delete [] pTempBuf; - } -} - -// ======================================================================= - ByteString::ByteString( const rtl::OString& rStr ) : mpData(NULL) { |