Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Hi,

an excursion from vcl to unotools was necessary. Could someone please review this little patch? xub_StrLen is replaced as well with sal_Int32.

Thank you,
Christina
From 77eca65e7d6e23206f21b3a569578a48330d1e43 Mon Sep 17 00:00:00 2001
From: Christina Rossmanith <ChrRossmanith@web.de>
Date: Tue, 17 Jan 2012 11:02:34 +0100
Subject: [PATCH] Replace (Byte)String with O(U)String

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

diff --git a/unotools/inc/unotools/fontdefs.hxx b/unotools/inc/unotools/fontdefs.hxx
index 12d9c43..9aec0f2 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, sal_Int32 nIndex, sal_Int32 nLen ) 
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..4d179ea 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,15 @@ 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, sal_Int32 nIndex, sal_Int32 nLen ) const
 {
-    sal_uLong nLastIndex = (sal_uLong)nIndex + nLen;
-    if( nLastIndex > rStr.Len() )
-        nLastIndex = rStr.Len();
+    sal_Int32 nLastIndex = nIndex + nLen;
+    if( nLastIndex > rStr.getLength() )
+        nLastIndex = rStr.getLength();
 
     for(; nIndex < nLastIndex; ++nIndex )
     {
-        sal_Unicode cOrig = rStr.GetChar( nIndex );
+        sal_Unicode cOrig = rStr[nIndex];
         // only recode symbols and their U+00xx aliases
         if( ((cOrig < 0x0020) || (cOrig > 0x00FF))
         &&  ((cOrig < 0xF020) || (cOrig > 0xF0FF)) )
@@ -1390,8 +1391,12 @@ 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 );
+        if( cOrig != cNew ) {
+            //            rStr[nIndex] = cNew;
+            rtl::OUStringBuffer aTmpStr(rStr.getStr());
+            aTmpStr[nIndex] = cNew;
+            rStr = aTmpStr.makeStringAndClear();
+        }
     }
 }
 
-- 
1.7.4.1


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.