[PATCH] Replace (Byte)String with O(U)String / simplify ConvertChar::RecodeString()

Christina Rossmanith ChrRossmanith at web.de
Tue Jan 17 02:02:34 PST 2012


---
 unotools/inc/unotools/fontdefs.hxx |    2 +-
 unotools/source/misc/fontcvt.cxx   |   16 ++++++++--------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/unotools/inc/unotools/fontdefs.hxx b/unotools/inc/unotools/fontdefs.hxx
index 12d9c43..ac02320 100644
--- a/unotools/inc/unotools/fontdefs.hxx
+++ b/unotools/inc/unotools/fontdefs.hxx
@@ -74,7 +74,7 @@ public:
     const char*         mpSubsFontName;
     sal_Unicode         (*mpCvtFunc)( sal_Unicode );
     sal_Unicode         RecodeChar( sal_Unicode c ) const;
-    void                RecodeString( String& rStra, xub_StrLen nIndex, xub_StrLen nLen ) const;
+    void                RecodeString( rtl::OUString& rStra ) const;
     static const ConvertChar* GetRecodeData( const String& rOrgFontName, const String& rMapFontName );
 };
 
diff --git a/unotools/source/misc/fontcvt.cxx b/unotools/source/misc/fontcvt.cxx
index cabdaf7..d81f725 100644
--- a/unotools/source/misc/fontcvt.cxx
+++ b/unotools/source/misc/fontcvt.cxx
@@ -29,6 +29,7 @@
 #include <unotools/fontcvt.hxx>
 #include <unotools/fontdefs.hxx>
 #include <sal/macros.h>
+#include <rtl/ustrbuf.hxx>
 
 #ifndef _STLP_MAP
 #include <map>
@@ -1374,15 +1375,12 @@ sal_Unicode ConvertChar::RecodeChar( sal_Unicode cChar ) const
 
 // recode the string assuming the character codes are symbol codes
 // from an traditional symbol font (i.e. U+F020..U+F0FF)
-void ConvertChar::RecodeString( String& rStr, xub_StrLen nIndex, xub_StrLen nLen ) const
+void ConvertChar::RecodeString( rtl::OUString& rStr ) const
 {
-    sal_uLong nLastIndex = (sal_uLong)nIndex + nLen;
-    if( nLastIndex > rStr.Len() )
-        nLastIndex = rStr.Len();
-
-    for(; nIndex < nLastIndex; ++nIndex )
+    rtl::OUStringBuffer aTmpStr(rStr.getStr());
+    for(sal_Int32 nIndex=0; nIndex < rStr.getLength(); ++nIndex )
     {
-        sal_Unicode cOrig = rStr.GetChar( nIndex );
+        sal_Unicode cOrig = aTmpStr[nIndex];
         // only recode symbols and their U+00xx aliases
         if( ((cOrig < 0x0020) || (cOrig > 0x00FF))
         &&  ((cOrig < 0xF020) || (cOrig > 0xF0FF)) )
@@ -1391,8 +1389,10 @@ void ConvertChar::RecodeString( String& rStr, xub_StrLen nIndex, xub_StrLen nLen
         // recode a symbol
         sal_Unicode cNew = RecodeChar( cOrig );
         if( cOrig != cNew )
-            rStr.SetChar( nIndex, cNew );
+            aTmpStr[nIndex] = cNew;
+
     }
+    rStr = aTmpStr.makeStringAndClear();
 }
 
 //=======================================================================
-- 
1.7.4.1


--------------020000020808040703060303--


More information about the LibreOffice mailing list