summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-09-08 16:34:47 +0100
committerCaolán McNamara <caolanm@redhat.com>2013-09-08 20:44:25 +0100
commit7fd6d43c1dae1548aca5ae4ed6d63cbf7e10b7ea (patch)
treebfb79a7732e4948b871856a89c3affdc0877cc2a
parenta77a573883ce49d045159bdf3f8735594d1e81b4 (diff)
Related: fdo#38838 String::GetBufferAccess is now no more
Change-Id: I9fdd600fd0a530c0763875109eee6600e4a77879
-rw-r--r--editeng/source/misc/svxacorr.cxx24
-rw-r--r--fpicker/source/office/iodlg.cxx10
-rw-r--r--include/tools/string.hxx1
-rw-r--r--sc/source/core/tool/address.cxx6
-rw-r--r--sw/source/core/undo/unovwr.cxx5
-rw-r--r--sw/source/ui/docvw/edtwin2.cxx13
-rw-r--r--sw/source/ui/inc/content.hxx2
-rw-r--r--sw/source/ui/inc/navipi.hxx2
-rw-r--r--sw/source/ui/utlui/content.cxx29
-rw-r--r--sw/source/ui/utlui/navipi.cxx16
-rw-r--r--tools/source/string/tustring.cxx12
11 files changed, 56 insertions, 64 deletions
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index d49c229ce4b6..8e6003072bcc 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -90,7 +90,7 @@ static const sal_Char
// These characters are allowed in words: (for FnCptlSttSntnc)
static const sal_Char sImplWordChars[] = "-'";
-void EncryptBlockName_Imp( String& rName );
+OUString EncryptBlockName_Imp(const OUString& rName);
TYPEINIT0(SvxAutoCorrect)
@@ -1626,16 +1626,16 @@ sal_Bool SvxAutoCorrect::PutText( const com::sun::star::uno::Reference < com::su
return sal_False;
}
-void EncryptBlockName_Imp( String& rName )
+OUString EncryptBlockName_Imp(const OUString& rName)
{
- xub_StrLen nLen, nPos = 1;
- rName.Insert( '#', 0 );
- sal_Unicode* pName = rName.GetBufferAccess();
- for ( nLen = rName.Len(), ++pName; nPos < nLen; ++nPos, ++pName )
+ OUStringBuffer aName;
+ aName.append('#').append(rName);
+ for (sal_Int32 nLen = rName.getLength(), nPos = 1; nPos < nLen; ++nPos)
{
- if( lcl_IsInAsciiArr( "!/:.\\", *pName ))
- *pName &= 0x0f;
+ if (lcl_IsInAsciiArr( "!/:.\\", aName[nPos]))
+ aName[nPos] &= 0x0f;
}
+ return aName.makeStringAndClear();
}
/* This code is copied from SwXMLTextBlocks::GeneratePackageName */
@@ -2440,7 +2440,7 @@ sal_Bool SvxAutoCorrectLanguageLists::MakeCombinedChanges( std::vector<SvxAutoco
{
String aName( aWordToDelete.GetShort() );
if (xStorage->IsOLEStorage())
- EncryptBlockName_Imp( aName );
+ aName = EncryptBlockName_Imp(aName);
else
GeneratePackageName ( aWordToDelete.GetShort(), aName );
@@ -2465,7 +2465,7 @@ sal_Bool SvxAutoCorrectLanguageLists::MakeCombinedChanges( std::vector<SvxAutoco
// Still have to remove the Storage
String sStorageName( pWordToAdd->GetShort() );
if (xStorage->IsOLEStorage())
- EncryptBlockName_Imp( sStorageName );
+ sStorageName = EncryptBlockName_Imp(sStorageName);
else
GeneratePackageName ( pWordToAdd->GetShort(), sStorageName);
@@ -2513,7 +2513,7 @@ sal_Bool SvxAutoCorrectLanguageLists::PutText( const String& rShort, const Strin
// Still have to remove the Storage
String sStgNm( rShort );
if (xStg->IsOLEStorage())
- EncryptBlockName_Imp( sStgNm );
+ sStgNm = EncryptBlockName_Imp(sStgNm);
else
GeneratePackageName ( rShort, sStgNm);
@@ -2593,7 +2593,7 @@ sal_Bool SvxAutoCorrectLanguageLists::DeleteText( const String& rShort )
{
String aName( rShort );
if (xStg->IsOLEStorage())
- EncryptBlockName_Imp( aName );
+ aName = EncryptBlockName_Imp(aName);
else
GeneratePackageName ( rShort, aName );
if( xStg->IsContained( aName ) )
diff --git a/fpicker/source/office/iodlg.cxx b/fpicker/source/office/iodlg.cxx
index 40693ab1ec89..d2f18376f510 100644
--- a/fpicker/source/office/iodlg.cxx
+++ b/fpicker/source/office/iodlg.cxx
@@ -3288,12 +3288,12 @@ void SvtFileDialog::appendDefaultExtension(String& _rFileName,
for ( nIndex = 0; nIndex < nWildCard; nIndex++ )
{
- String aExt(aType.GetToken( 0, FILEDIALOG_DEF_EXTSEP, nPos ));
+ OUString aExt(aType.GetToken( 0, FILEDIALOG_DEF_EXTSEP, nPos ));
// take care of a leading *
- sal_uInt16 nExtOffset = (aExt.GetBuffer()[0] == '*' ? 1 : 0);
- sal_Unicode* pExt = aExt.GetBufferAccess() + nExtOffset;
- xub_StrLen nExtLen = aExt.Len() - nExtOffset;
- xub_StrLen nOffset = aTemp.Len() - nExtLen;
+ sal_Int32 nExtOffset = (aExt[0] == '*' ? 1 : 0);
+ const sal_Unicode* pExt = aExt.getStr() + nExtOffset;
+ sal_Int32 nExtLen = aExt.getLength() - nExtOffset;
+ sal_Int32 nOffset = aTemp.Len() - nExtLen;
// minimize search by starting at last possible index
if ( aTemp.Search(pExt, nOffset) == nOffset )
break;
diff --git a/include/tools/string.hxx b/include/tools/string.hxx
index 03313273853a..b744f88e44e3 100644
--- a/include/tools/string.hxx
+++ b/include/tools/string.hxx
@@ -273,7 +273,6 @@ public:
UniString GetToken( xub_StrLen nToken, sal_Unicode cTok = ';' ) const;
const sal_Unicode* GetBuffer() const { return mpData->maStr; }
- sal_Unicode* GetBufferAccess();
friend sal_Bool operator == ( const UniString& rStr1, const UniString& rStr2 )
{ return rStr1.Equals( rStr2 ); }
diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index 0a3d919b98f1..f528b77b62f6 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -1398,9 +1398,9 @@ lcl_ScRange_Parse_OOo( ScRange &aRange, const String& r, ScDocument* pDoc, ScAdd
xub_StrLen nPos = ScGlobal::FindUnquoted( r, ':');
if (nPos != STRING_NOTFOUND)
{
- String aTmp( r );
- sal_Unicode* p = aTmp.GetBufferAccess();
- p[ nPos ] = 0;
+ OUStringBuffer aTmp(r);
+ aTmp[nPos] = 0;
+ const sal_Unicode* p = aTmp.getStr();
if( (nRes1 = lcl_ScAddress_Parse_OOo( p, pDoc, aRange.aStart, pExtInfo, NULL ) ) != 0 )
{
aRange.aEnd = aRange.aStart; // sheet must be initialized identical to first sheet
diff --git a/sw/source/core/undo/unovwr.cxx b/sw/source/core/undo/unovwr.cxx
index b223846b6eaf..b7559c2e3b06 100644
--- a/sw/source/core/undo/unovwr.cxx
+++ b/sw/source/core/undo/unovwr.cxx
@@ -200,9 +200,6 @@ void SwUndoOverwrite::UndoImpl(::sw::UndoRedoContext & rContext)
if( aDelStr.Len() )
{
- String aTmpStr = OUString('1');
- sal_Unicode* pTmpStr = aTmpStr.GetBufferAccess();
-
bool bOldExpFlg = pTxtNd->IsIgnoreDontExpand();
pTxtNd->SetIgnoreDontExpand( true );
@@ -210,7 +207,7 @@ void SwUndoOverwrite::UndoImpl(::sw::UndoRedoContext & rContext)
for( xub_StrLen n = 0; n < aDelStr.Len(); n++ )
{
// do it individually, to keep the attributes!
- *pTmpStr = aDelStr.GetChar( n );
+ OUString aTmpStr(aDelStr.GetChar(n));
OUString const ins( pTxtNd->InsertText(aTmpStr, rIdx) );
assert(ins.getLength() == 1); // cannot fail
rIdx -= 2;
diff --git a/sw/source/ui/docvw/edtwin2.cxx b/sw/source/ui/docvw/edtwin2.cxx
index 559aa1478507..57588811b65b 100644
--- a/sw/source/ui/docvw/edtwin2.cxx
+++ b/sw/source/ui/docvw/edtwin2.cxx
@@ -195,14 +195,15 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt)
if( sTxt.Len() )
{
- sTxt = comphelper::string::remove(sTxt, 0xad);
- for( sal_Unicode* p = sTxt.GetBufferAccess(); *p; ++p )
+ OUStringBuffer sTmp(comphelper::string::remove(sTxt, 0xad));
+ for (sal_Int32 i = 0; i < sTmp.getLength(); ++i)
{
- if( *p < 0x20 )
- *p = 0x20;
- else if(*p == 0x2011)
- *p = '-';
+ if (sTmp[i] < 0x20)
+ sTmp[i] = 0x20;
+ else if (sTmp[i] == 0x2011)
+ sTmp[i] = '-';
}
+ sTxt = sTmp.makeStringAndClear();
}
}
}
diff --git a/sw/source/ui/inc/content.hxx b/sw/source/ui/inc/content.hxx
index 57c292748db0..4e1cbcd77052 100644
--- a/sw/source/ui/inc/content.hxx
+++ b/sw/source/ui/inc/content.hxx
@@ -181,7 +181,7 @@ class SwContentType : public SwTypeNumber
bool bEdit: 1; // can this type be edited?
bool bDelete: 1; // can this type be deleted?
protected:
- void RemoveNewline(String&);
+ OUString RemoveNewline(const OUString&);
public:
SwContentType(SwWrtShell* pParent, sal_uInt16 nType, sal_uInt8 nLevel );
~SwContentType();
diff --git a/sw/source/ui/inc/navipi.hxx b/sw/source/ui/inc/navipi.hxx
index 4e339cf2eed3..0fb4bd0f3e23 100644
--- a/sw/source/ui/inc/navipi.hxx
+++ b/sw/source/ui/inc/navipi.hxx
@@ -156,7 +156,7 @@ public:
const SfxPoolItem* pState );
static String CreateDropFileName( TransferableDataHelper& rData );
- static void CleanEntry( String& rEntry );
+ static OUString CleanEntry(const OUString& rEntry);
sal_uInt16 GetRegionDropMode() const {return nRegionMode;}
void SetRegionDropMode(sal_uInt16 nNewMode);
diff --git a/sw/source/ui/utlui/content.cxx b/sw/source/ui/utlui/content.cxx
index 1a471c17e41e..6d5ea1f721c0 100644
--- a/sw/source/ui/utlui/content.cxx
+++ b/sw/source/ui/utlui/content.cxx
@@ -391,8 +391,8 @@ void SwContentType::Init(sal_Bool* pbInvalidateWindow)
if (aFmtFld->GetTxtFld() && aFmtFld->IsFldInDoc() &&
(*i)->mLayoutStatus!=SwPostItHelper::INVISIBLE )
{
- String sEntry = aFmtFld->GetFld()->GetPar2();
- RemoveNewline(sEntry);
+ OUString sEntry = aFmtFld->GetFld()->GetPar2();
+ sEntry = RemoveNewline(sEntry);
SwPostItContent* pCnt = new SwPostItContent(
this,
sEntry,
@@ -494,9 +494,9 @@ void SwContentType::FillMemberList(sal_Bool* pbLevelOrVisibilityChanged)
nMemberCount--;
else
{
- String aEntry(comphelper::string::stripStart(
+ OUString aEntry(comphelper::string::stripStart(
pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(i), ' '));
- SwNavigationPI::CleanEntry( aEntry );
+ aEntry = SwNavigationPI::CleanEntry(aEntry);
SwOutlineContent* pCnt = new SwOutlineContent(this, aEntry, i, nLevel,
pWrtShell->IsOutlineMovable( i ), nPos );
pMember->insert(pCnt);//, nPos);
@@ -717,8 +717,8 @@ void SwContentType::FillMemberList(sal_Bool* pbLevelOrVisibilityChanged)
if (aFmtFld->GetTxtFld() && aFmtFld->IsFldInDoc() &&
(*i)->mLayoutStatus!=SwPostItHelper::INVISIBLE )
{
- String sEntry = aFmtFld->GetFld()->GetPar2();
- RemoveNewline(sEntry);
+ OUString sEntry = aFmtFld->GetFld()->GetPar2();
+ sEntry = RemoveNewline(sEntry);
SwPostItContent* pCnt = new SwPostItContent(
this,
sEntry,
@@ -2677,14 +2677,17 @@ void SwContentTree::SetRootType(sal_uInt16 nType)
pConfig->SetRootType( nRootType );
}
-void SwContentType::RemoveNewline(String& rEntry)
+OUString SwContentType::RemoveNewline(const OUString& rEntry)
{
- sal_Unicode* pStr = rEntry.GetBufferAccess();
- for(xub_StrLen i = rEntry.Len(); i; --i, ++pStr )
- {
- if( *pStr == 10 || *pStr == 13 )
- *pStr = 0x20;
- }
+ if (rEntry.isEmpty())
+ return rEntry;
+
+ OUStringBuffer aEntry(rEntry);
+ for (sal_Int32 i = 0; i < rEntry.getLength(); ++i)
+ if(aEntry[i] == 10 || aEntry[i] == 13)
+ aEntry[i] = 0x20;
+
+ return aEntry.makeStringAndClear();
}
void SwContentTree::EditEntry(SvTreeListEntry* pEntry, sal_uInt8 nMode)
diff --git a/sw/source/ui/utlui/navipi.cxx b/sw/source/ui/utlui/navipi.cxx
index 95a6e2290588..45a53174b9fc 100644
--- a/sw/source/ui/utlui/navipi.cxx
+++ b/sw/source/ui/utlui/navipi.cxx
@@ -63,13 +63,17 @@ SFX_IMPL_CHILDWINDOW_CONTEXT( SwNavigationChild, SID_NAVIGATOR, SwView )
// Filter the control characters out of the Outline-Entry
-void SwNavigationPI::CleanEntry( String& rEntry )
+OUString SwNavigationPI::CleanEntry(const OUString& rEntry)
{
- sal_uInt16 i = rEntry.Len();
- if( i )
- for( sal_Unicode* pStr = rEntry.GetBufferAccess(); i; --i, ++pStr )
- if( *pStr == 10 || *pStr == 9 )
- *pStr = 0x20;
+ if (rEntry.isEmpty())
+ return rEntry;
+
+ OUStringBuffer aEntry(rEntry);
+ for (sal_Int32 i = 0; i < rEntry.getLength(); ++i)
+ if(aEntry[i] == 10 || aEntry[i] == 9)
+ aEntry[i] = 0x20;
+
+ return aEntry.makeStringAndClear();
}
// Execution of the drag operation with and without the children.
diff --git a/tools/source/string/tustring.cxx b/tools/source/string/tustring.cxx
index a23f0fcfa766..13b1e42400af 100644
--- a/tools/source/string/tustring.cxx
+++ b/tools/source/string/tustring.cxx
@@ -228,18 +228,6 @@ StringCompare STRING::CompareIgnoreCaseToAscii( const STRING& rStr,
return COMPARE_GREATER;
}
-STRCODE* STRING::GetBufferAccess()
-{
- DBG_CHKTHIS( STRING, DBGCHECKSTRING );
-
- // Copy data if necessary
- if ( mpData->mnLen )
- ImplCopyData();
-
- // return pointer to string data
- return mpData->maStr;
-}
-
STRING& STRING::Insert( STRCODE c, xub_StrLen nIndex )
{
DBG_CHKTHIS( STRING, DBGCHECKSTRING );