summaryrefslogtreecommitdiff
path: root/editeng/source/items
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-08-07 09:13:47 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-08-07 16:14:45 +0100
commitaac04652fda01b0299e17087b151f07d6115e894 (patch)
tree26a71ba651eb138d81f538b0d43b66f8da8e305d /editeng/source/items
parentdb95e0b75903a34a1b88a3701334e154f32eeceb (diff)
String::AllocBuffer replacements
Change-Id: I278cd66fb4819721bb473796c28598aaf04eb123
Diffstat (limited to 'editeng/source/items')
-rw-r--r--editeng/source/items/flditem.cxx34
1 files changed, 19 insertions, 15 deletions
diff --git a/editeng/source/items/flditem.cxx b/editeng/source/items/flditem.cxx
index 6a42e4bb3716..632e00eb95b8 100644
--- a/editeng/source/items/flditem.cxx
+++ b/editeng/source/items/flditem.cxx
@@ -26,6 +26,7 @@
*
************************************************************************/
+#include <comphelper/string.hxx>
#include <vcl/metaact.hxx>
#include <svl/zforlist.hxx>
#include <tools/urlobj.hxx>
@@ -550,25 +551,28 @@ int SvxURLField::operator==( const SvxFieldData& rOther ) const
// -----------------------------------------------------------------------
-static void write_unicode( SvPersistStream & rStm, const String& rString )
+static void write_unicode( SvPersistStream & rStm, const rtl::OUString& rString )
{
- sal_uInt16 nL = rString.Len();
+ sal_uInt16 nL = sal::static_int_cast<sal_uInt16>(rString.getLength());
rStm << nL;
- rStm.Write( rString.GetBuffer(), nL*sizeof(sal_Unicode) );
+ //endian specific?, yipes!
+ rStm.Write( rString.getStr(), nL*sizeof(sal_Unicode) );
}
-static void read_unicode( SvPersistStream & rStm, rtl::OUString& rString )
+static rtl::OUString read_unicode( SvPersistStream & rStm )
{
+ rtl_uString *pStr = NULL;
sal_uInt16 nL = 0;
rStm >> nL;
- String aStr;
if ( nL )
{
- aStr.AllocBuffer( nL );
- rStm.Read( aStr.GetBufferAccess(), nL*sizeof(sal_Unicode) );
- aStr.ReleaseBufferAccess( nL );
+ using comphelper::string::rtl_uString_alloc;
+ pStr = rtl_uString_alloc(nL);
+ //endian specific?, yipes!
+ rStm.Read(pStr->buffer, nL*sizeof(sal_Unicode));
}
- rString = aStr;
+ //take ownership of buffer and return, otherwise return empty string
+ return pStr ? rtl::OUString(pStr, SAL_NO_ACQUIRE) : rtl::OUString();
}
void SvxURLField::Load( SvPersistStream & rStm )
@@ -578,9 +582,9 @@ void SvxURLField::Load( SvPersistStream & rStm )
rStm >> nFormat;
eFormat= (SvxURLFormat)nFormat;
- read_unicode( rStm, aURL );
- read_unicode( rStm, aRepresentation );
- read_unicode( rStm, aTargetFrame );
+ aURL = read_unicode( rStm );
+ aRepresentation = read_unicode( rStm );
+ aTargetFrame = read_unicode( rStm );
}
// -----------------------------------------------------------------------
@@ -1088,9 +1092,9 @@ void SvxAuthorField::Load( SvPersistStream & rStm )
{
sal_uInt16 nType = 0, nFormat = 0;
- read_unicode( rStm, aName );
- read_unicode( rStm, aFirstName );
- read_unicode( rStm, aShortName );
+ aName = read_unicode( rStm );
+ aFirstName = read_unicode( rStm );
+ aShortName = read_unicode( rStm );
rStm >> nType;
rStm >> nFormat;