From 7fd6d43c1dae1548aca5ae4ed6d63cbf7e10b7ea Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 8 Sep 2013 16:34:47 +0100 Subject: Related: fdo#38838 String::GetBufferAccess is now no more Change-Id: I9fdd600fd0a530c0763875109eee6600e4a77879 --- sw/source/ui/docvw/edtwin2.cxx | 13 +++++++------ sw/source/ui/inc/content.hxx | 2 +- sw/source/ui/inc/navipi.hxx | 2 +- sw/source/ui/utlui/content.cxx | 29 ++++++++++++++++------------- sw/source/ui/utlui/navipi.cxx | 16 ++++++++++------ 5 files changed, 35 insertions(+), 27 deletions(-) (limited to 'sw/source/ui') 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. -- cgit