diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-08-07 09:13:47 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-08-07 16:14:45 +0100 |
commit | aac04652fda01b0299e17087b151f07d6115e894 (patch) | |
tree | 26a71ba651eb138d81f538b0d43b66f8da8e305d /editeng | |
parent | move UniString::GetQuotedToken to sc, you can keep it (diff) | |
download | core-aac04652fda01b0299e17087b151f07d6115e894.tar.gz core-aac04652fda01b0299e17087b151f07d6115e894.zip |
String::AllocBuffer replacements
Change-Id: I278cd66fb4819721bb473796c28598aaf04eb123
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/editobj.cxx | 16 | ||||
-rw-r--r-- | editeng/source/items/flditem.cxx | 34 |
2 files changed, 28 insertions, 22 deletions
diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx index ef84d0b8d5b1..605bf68c95a0 100644 --- a/editeng/source/editeng/editobj.cxx +++ b/editeng/source/editeng/editobj.cxx @@ -26,7 +26,7 @@ * ************************************************************************/ - +#include <comphelper/string.hxx> #include <rtl/strbuf.hxx> #include <vcl/wrkwin.hxx> #include <vcl/dialog.hxx> @@ -1444,6 +1444,8 @@ void BinTextObject::CreateData( SvStream& rIStream ) rIStream >> bUnicodeStrings; if ( bUnicodeStrings ) { + using comphelper::string::rtl_uString_alloc; + for ( sal_uInt16 nPara = 0; nPara < nParagraphs; nPara++ ) { ContentInfo& rC = aContents[nPara]; @@ -1453,18 +1455,18 @@ void BinTextObject::CreateData( SvStream& rIStream ) rIStream >> nL; if ( nL ) { - rC.GetText().AllocBuffer( nL ); - rIStream.Read(rC.GetText().GetBufferAccess(), nL*sizeof(sal_Unicode)); - rC.GetText().ReleaseBufferAccess(nL); + rtl_uString *pStr = rtl_uString_alloc(nL); + rIStream.Read(pStr->buffer, nL*sizeof(sal_Unicode)); + rC.GetText() = rtl::OUString(pStr, SAL_NO_ACQUIRE); } // StyleSheetName rIStream >> nL; if ( nL ) { - rC.GetStyle().AllocBuffer(nL); - rIStream.Read(rC.GetStyle().GetBufferAccess(), nL*sizeof(sal_Unicode) ); - rC.GetStyle().ReleaseBufferAccess(nL); + rtl_uString *pStr = rtl_uString_alloc(nL); + rIStream.Read(pStr->buffer, nL*sizeof(sal_Unicode) ); + rC.GetStyle() = rtl::OUString(pStr, SAL_NO_ACQUIRE); } } } 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; |