Re: [Libreoffice] [PATCH] Replace (Byte)String with O(U)String in sw

2011-10-04 Thread Stephan Bergmann

On 10/03/2011 04:48 PM, Chr. Rossmanith wrote:

One improvement suggested by Norbert on IRC: using OUString instead of
::rtl::OUString. What is the preferred syntax

using ::rtl::OUString at the beginning of the file and OUString
throughout the remaining source code

or

::rtl::OUString everywhere in the source code.


I would stick with a pattern that does use a namespace prefix (i.e., 
rtl::OUString rather than OUString).  Even if it is slightly longer, 
it helps avoid ambiguities should one of the #included headers in the 
future drag in another entity with the same plain name (probably 
unlikely for OUString, but it does happen, cf. rtl::Reference vs. 
com::sun::star::uno::Reference; another measure against this is to 
explicitly using rtl::OUString; instead of the more general using 
namespace rtl;).  The initial :: in ::rtl::OUString is probably not 
really worth it, more noise than of practical value.


But there's a lot of personal taste involved...

-Stephan
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [Libreoffice] [PATCH] Replace (Byte)String with O(U)String in sw

2011-10-03 Thread Michael Meeks
Hi Christina,

On Sun, 2011-10-02 at 20:52 +0200, Chr. Rossmanith wrote:
 could someone please review this small patch. I'll extend the 
 replacement (and push on my own) but want to be sure that there are no 
 mistakes. At least it seems to build  :-)

Looks great to me :-)

Thanks !

Michael.

-- 
michael.me...@suse.com  , Pseudo Engineer, itinerant idiot

___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [Libreoffice] [PATCH] Replace (Byte)String with O(U)String in sw

2011-10-03 Thread Caolán McNamara
On Mon, 2011-10-03 at 10:07 +0100, Michael Meeks wrote:
 Hi Christina,
 
 On Sun, 2011-10-02 at 20:52 +0200, Chr. Rossmanith wrote:
  could someone please review this small patch. I'll extend the 
  replacement (and push on my own) but want to be sure that there are no 
  mistakes. At least it seems to build  :-)
 
   Looks great to me :-)

yup, fine, no errors there.

FWIW, personally, I've tended towards...

rtl::OStringBuffer aError(RTL_CONSTASCII_STRINGPARAM(foo));
aError.append(::rtl::OUStringToOString(r.Message,
osl_getThreadTextEncoding());
OSL_FAIL(aError.getStr());

But its just an OSL_FAIL, so whatever titchy (if any) difference using a
OStringBuffer and RTL_CONSTASCII_STRINGPARAM makes is irrelevant there,
and the same goes for the output encoding really, its going to be ascii,
so ASCII, UTF-8, system encoding for the error message will all be
equivalent in the real world.

C.

___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [Libreoffice] [PATCH] Replace (Byte)String with O(U)String in sw

2011-10-03 Thread Chr. Rossmanith
One improvement suggested by Norbert on IRC: using OUString instead of 
::rtl::OUString. What is the preferred syntax


using ::rtl::OUString at the beginning of the file and OUString 
throughout the remaining source code


or

::rtl::OUString everywhere in the source code.

Christina

Am 03.10.2011 11:07, schrieb Michael Meeks:

Hi Christina,

On Sun, 2011-10-02 at 20:52 +0200, Chr. Rossmanith wrote:

could someone please review this small patch. I'll extend the
replacement (and push on my own) but want to be sure that there are no
mistakes. At least it seems to build  :-)

Looks great to me :-)

Thanks !

Michael.



___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [Libreoffice] [PATCH] Replace (Byte)String with O(U)String in sw

2011-10-03 Thread Norbert Thiebaud
On Mon, Oct 3, 2011 at 9:48 AM, Chr. Rossmanith chrrossman...@gmx.de wrote:
 One improvement suggested by Norbert on IRC: using OUString instead of
 ::rtl::OUString. What is the preferred syntax

Note: I don't know what is the 'preferred' way, I just noticed that
there was a mix of the 2 notations (actually 3 even ::rtl::Foo,
rtl::Foo and Foo) in the same function... which ever way is picked, I
think that way should be used homogeneously in a given source.

Norbert
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


[Libreoffice] [PATCH] Replace (Byte)String with O(U)String in sw

2011-10-02 Thread Chr. Rossmanith

Hi,

could someone please review this small patch. I'll extend the 
replacement (and push on my own) but want to be sure that there are no 
mistakes. At least it seems to build  :-)


Thank you,
Christina
From 4598efcf63b30b673794c8d8aaf99797ada3117c Mon Sep 17 00:00:00 2001
From: Christina Rossmanith chrrossman...@web.de
Date: Sat, 1 Oct 2011 19:48:07 +0200
Subject: [PATCH] Replace (Byte)String with O(U)String in sw

---
 sw/source/core/access/acccontext.cxx |   16 ++--
 sw/source/core/access/accmap.cxx |6 +++---
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/sw/source/core/access/acccontext.cxx b/sw/source/core/access/acccontext.cxx
index 47398be..ae77b95 100644
--- a/sw/source/core/access/acccontext.cxx
+++ b/sw/source/core/access/acccontext.cxx
@@ -54,6 +54,7 @@
 #include acccontext.hxx
 #include svx/AccessibleShape.hxx
 #include comphelper/accessibleeventnotifier.hxx
+#include comphelper/string.hxx
 #include PostItMgr.hxx
 
 using namespace sw::access;
@@ -1398,27 +1399,22 @@ OUString SwAccessibleContext::GetResource( sal_uInt16 nResId,
const OUString *pArg1,
const OUString *pArg2 )
 {
-String sStr;
+OUString sStr;
 {
 SolarMutexGuard aGuard;
-
-sStr = SW_RES( nResId );
+sStr = ResId::toString( SW_RES( nResId ) );
 }
 
 if( pArg1 )
 {
-sStr.SearchAndReplace( String::CreateFromAscii(
-RTL_CONSTASCII_STRINGPARAM( $(ARG1) )),
-   String( *pArg1 ) );
+sStr = comphelper::string::replace( sStr, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM($(ARG1)) ), *pArg1 );
 }
 if( pArg2 )
 {
-sStr.SearchAndReplace( String::CreateFromAscii(
-RTL_CONSTASCII_STRINGPARAM( $(ARG2) )),
-   String( *pArg2 ) );
+sStr = comphelper::string::replace( sStr, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM($(ARG2)) ), *pArg2 );
 }
 
-return OUString( sStr );
+return sStr;
 }
 
 void SwAccessibleContext::RemoveFrmFromAccessibleMap()
diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx
index 1dc2c8c..f25d480 100644
--- a/sw/source/core/access/accmap.cxx
+++ b/sw/source/core/access/accmap.cxx
@@ -185,9 +185,9 @@ void SwDrawModellListener_Impl::Notify( SfxBroadcaster /*rBC*/,
 {
 (void)r;
 #if OSL_DEBUG_LEVEL  1
-ByteString aError( Runtime exception caught while notifying shape.:\n );
-aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US );
-OSL_FAIL( aError.GetBuffer() );
+rtl::OString aError( Runtime exception caught while notifying shape.:\n );
+aError += ::rtl::OUStringToOString( rtl::OUString( r.Message), RTL_TEXTENCODING_UTF8 );
+OSL_FAIL( aError.getStr() );
 #endif
 }
 }
-- 
1.7.4.1

___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice