diff options
author | Caolán McNamara <caolanm@redhat.com> | 2013-10-08 10:06:59 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-10-08 14:05:58 +0100 |
commit | 832e5aadbff006ec24959162c29756fe2b1982be (patch) | |
tree | 9c258056fec29b0defaf012f8cb0945efed2b2e0 /sw | |
parent | c811c0706f0ecf3400e8fcc510ca283dd593237f (diff) |
Related: fdo#38838 remove UniString::SearchAndReplaceAll
Change-Id: I093c95b8700b628375d69293022f7d4b8da2af9c
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/doc/docfld.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/doc/doctxm.cxx | 20 | ||||
-rw-r--r-- | sw/source/filter/ascii/ascatr.cxx | 6 | ||||
-rw-r--r-- | sw/source/filter/html/wrthtml.cxx | 13 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 17 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8nds.cxx | 12 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8sty.cxx | 5 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 10 | ||||
-rw-r--r-- | sw/source/ui/dbui/dbui.cxx | 6 | ||||
-rw-r--r-- | sw/source/ui/dbui/mmlayoutpage.cxx | 4 | ||||
-rw-r--r-- | sw/source/ui/misc/redlndlg.cxx | 15 | ||||
-rw-r--r-- | sw/source/ui/uiview/viewport.cxx | 10 |
13 files changed, 58 insertions, 66 deletions
diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index 6b831110cbb2..ab25cf608fd7 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -284,9 +284,9 @@ SwFieldType* SwDoc::GetFldType( sal_uInt16 nResId, const String& rName, { SwFieldType* pFldType = (*mpFldTypes)[i]; - String aFldName( pFldType->GetName() ); + OUString aFldName( pFldType->GetName() ); if (bDbFieldMatching && nResId == RES_DBFLD) // #i51815# - aFldName.SearchAndReplaceAll(DB_DELIM, '.'); + aFldName = aFldName.replace(DB_DELIM, '.'); if( nResId == pFldType->Which() && rSCmp.isEqual( rName, aFldName )) diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index 0dbe2453e063..2ac32a6388a0 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -1539,28 +1539,28 @@ static String lcl_GetNumString( const SwTOXSortTabBase& rBase, bool bUsePrefix, /// Generate String with newlines changed to spaces, consecutive spaces changed /// to a single space, and trailing space removed. -String lcl_RemoveLineBreaks( String sRet ) +OUString lcl_RemoveLineBreaks(const OUString &rRet) { - if (!sRet.Len()) - return sRet; - xub_StrLen nOffset = 0; - sRet.SearchAndReplaceAll('\n', ' '); - for (xub_StrLen i = 1; i < sRet.Len(); i++) + if (rRet.isEmpty()) + return rRet; + sal_Int32 nOffset = 0; + OUStringBuffer sRet(rRet.replace('\n', ' ')); + for (sal_Int32 i = 1; i < sRet.getLength(); ++i) { - if ( sRet.GetChar(i - 1) == ' ' && sRet.GetChar(i) == ' ' ) + if ( sRet[i - 1] == ' ' && sRet[i] == ' ' ) { nOffset += 1; } else { - sRet.SetChar(i - nOffset, sRet.GetChar(i)); + sRet[i - nOffset] = sRet[i]; } } - if (sRet.GetChar(sRet.Len() - 1) == ' ') + if (sRet[sRet.getLength() - 1] == ' ') { nOffset += 1; } - return sRet.Copy(0, sRet.Len() - nOffset); + return sRet.copy(0, sRet.getLength() - nOffset).toString(); } // Add parameter <_TOXSectNdIdx> and <_pDefaultPageDesc> in order to control, diff --git a/sw/source/filter/ascii/ascatr.cxx b/sw/source/filter/ascii/ascatr.cxx index 87a4000c8a28..17f798352263 100644 --- a/sw/source/filter/ascii/ascatr.cxx +++ b/sw/source/filter/ascii/ascatr.cxx @@ -165,9 +165,9 @@ static Writer& OutASC_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ) } } - String aStr( rNd.GetTxt() ); + OUString aStr( rNd.GetTxt() ); if( rWrt.bASCII_ParaAsBlanc ) - aStr.SearchAndReplaceAll( 0x0A, ' ' ); + aStr = aStr.replace(0x0A, ' '); const bool bExportSoftHyphens = RTL_TEXTENCODING_UCS2 == rWrt.GetAsciiOptions().GetCharSet() || RTL_TEXTENCODING_UTF8 == rWrt.GetAsciiOptions().GetCharSet(); @@ -180,7 +180,7 @@ static Writer& OutASC_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ) if( !aAttrIter.OutAttr( nStrPos )) { - String aOutStr( aStr.Copy( nStrPos, nNextAttr - nStrPos ) ); + String aOutStr( aStr.copy( nStrPos, nNextAttr - nStrPos ) ); if ( !bExportSoftHyphens ) aOutStr = comphelper::string::remove(aOutStr, CHAR_SOFTHYPHEN); diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx index cf13747803a9..a2f8a6851b0f 100644 --- a/sw/source/filter/html/wrthtml.cxx +++ b/sw/source/filter/html/wrthtml.cxx @@ -1059,9 +1059,8 @@ void SwHTMLWriter::OutBookmarks() while( nPos < aOutlineMarkPoss.size() && aOutlineMarkPoss[nPos] == nNode ) { - String sMark( aOutlineMarks[nPos] ); - sMark.SearchAndReplaceAll( '?', '_' ); // '?' causes problems in IE/Netscape 5 - OutAnchor( sMark ); + OUString sMark( aOutlineMarks[nPos] ); + OutAnchor( sMark.replace('?', '_') ); // '?' causes problems in IE/Netscape 5 aOutlineMarkPoss.erase( aOutlineMarkPoss.begin()+nPos ); aOutlineMarks.erase( aOutlineMarks.begin() + nPos ); } @@ -1072,13 +1071,11 @@ void SwHTMLWriter::OutImplicitMark( const String& rMark, { if( rMark.Len() && !aImplicitMarks.empty() ) { - String sMark( rMark ); - sMark.Append( cMarkSeparator ); - sMark.AppendAscii( pMarkType ); + OUString sMark( rMark ); + sMark + OUString(cMarkSeparator) + OUString::createFromAscii(pMarkType); if( 0 != aImplicitMarks.erase( sMark ) ) { - sMark.SearchAndReplaceAll( '?', '_' ); // '?' causes problems in IE/Netscape 5 - OutAnchor( sMark ); + OutAnchor(sMark.replace('?', '_')); // '?' causes problems in IE/Netscape 5 } } } diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 1940fa2de26f..1bcedd3f8cce 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -890,9 +890,9 @@ void DocxAttributeOutput::StartField_Impl( FieldInfos& rInfos, bool bWriteRun ) } } -void DocxAttributeOutput::DoWriteCmd( String& rCmd ) +void DocxAttributeOutput::DoWriteCmd( const OUString& rCmd ) { - OUString sCmd = OUString(rCmd).trim(); + OUString sCmd = rCmd.trim(); if (sCmd.startsWith("SEQ")) { OUString sSeqName = msfilter::util::findQuotedText(sCmd, "SEQ ", '\\').trim(); @@ -900,7 +900,7 @@ void DocxAttributeOutput::DoWriteCmd( String& rCmd ) } // Write the Field command m_pSerializer->startElementNS( XML_w, XML_instrText, FSEND ); - m_pSerializer->writeEscaped( OUString( rCmd ) ); + m_pSerializer->writeEscaped( rCmd ); m_pSerializer->endElementNS( XML_w, XML_instrText ); } @@ -912,15 +912,15 @@ void DocxAttributeOutput::CmdField_Impl( FieldInfos& rInfos ) for ( xub_StrLen i = 0; i < nNbToken; i++ ) { - String sToken = rInfos.sCmd.GetToken( i, '\t' ); + OUString sToken = rInfos.sCmd.GetToken( i, '\t' ); if ( rInfos.eType == ww::eCREATEDATE || rInfos.eType == ww::eSAVEDATE || rInfos.eType == ww::ePRINTDATE || rInfos.eType == ww::eDATE || rInfos.eType == ww::eTIME ) { - sToken.SearchAndReplaceAll( String( "NNNN" ), String( "dddd" ) ); - sToken.SearchAndReplaceAll( String( "NN" ), String( "ddd" ) ); + sToken = sToken.replaceAll("NNNN", "dddd"); + sToken = sToken.replaceAll("NN", "ddd"); } // Write the Field command DoWriteCmd( sToken ); @@ -963,10 +963,9 @@ void DocxAttributeOutput::EndField_Impl( FieldInfos& rInfos ) // Write the Field latest value m_pSerializer->startElementNS( XML_w, XML_r, FSEND ); - String sExpand( rInfos.pField->ExpandField( true ) ); + OUString sExpand( rInfos.pField->ExpandField( true ) ); // newlines embedded in fields are 0x0B in MSO and 0x0A for us - sExpand.SearchAndReplaceAll( 0x0A, 0x0B ); - RunText( sExpand ); + RunText(sExpand.replace(0x0A, 0x0B)); m_pSerializer->endElementNS( XML_w, XML_r ); } diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 54d3c79558dd..16f17b7d5610 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -631,7 +631,7 @@ private: void WriteCommentRanges(); void StartField_Impl( FieldInfos& rInfos, bool bWriteRun = sal_False ); - void DoWriteCmd( String& rCmd ); + void DoWriteCmd( const OUString& rCmd ); void CmdField_Impl( FieldInfos& rInfos ); void EndField_Impl( FieldInfos& rInfos ); diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 5fce527fcf49..a7d97a1ec497 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -1397,16 +1397,16 @@ because word doesn't have the feature String SwWW8AttrIter::GetSnippet(const String &rStr, xub_StrLen nAktPos, xub_StrLen nLen) const { - String aSnippet(rStr, nAktPos, nLen); if (!nLen) - return aSnippet; + return OUString(); + OUString aSnippet(rStr.Copy(nAktPos, nLen)); // 0x0a ( Hard Line Break ) -> 0x0b // 0xad ( soft hyphen ) -> 0x1f // 0x2011 ( hard hyphen ) -> 0x1e - aSnippet.SearchAndReplaceAll(0x0A, 0x0B); - aSnippet.SearchAndReplaceAll(CHAR_HARDHYPHEN, 0x1e); - aSnippet.SearchAndReplaceAll(CHAR_SOFTHYPHEN, 0x1f); + aSnippet = aSnippet.replace(0x0A, 0x0B); + aSnippet = aSnippet.replace(CHAR_HARDHYPHEN, 0x1e); + aSnippet = aSnippet.replace(CHAR_SOFTHYPHEN, 0x1f); m_rExport.m_aCurrentCharPropStarts.push( nAktPos ); const SfxPoolItem &rItem = GetItem(RES_CHRATR_CASEMAP); @@ -1444,7 +1444,7 @@ String SwWW8AttrIter::GetSnippet(const String &rStr, xub_StrLen nAktPos, rStr, nAktPos, g_pBreakIt->GetLocale(nLanguage), i18n::WordType::ANYWORD_IGNOREWHITESPACES ) ) { - aSnippet.SetChar(0, rStr.GetChar(nAktPos)); + aSnippet = OUString(rStr.GetChar(nAktPos)) + aSnippet.copy(1); } } m_rExport.m_aCurrentCharPropStarts.pop(); diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx index 969b2b37388a..cf954bff5a3d 100644 --- a/sw/source/filter/ww8/wrtw8sty.cxx +++ b/sw/source/filter/ww8/wrtw8sty.cxx @@ -2087,9 +2087,8 @@ bool WW8_WrPlcSubDoc::WriteGenericTxt( WW8Export& rWrt, sal_uInt8 nTTyp, rWrt.WriteOutliner(*rAtn.mpRichText, nTTyp); else { - String sTxt(rAtn.msSimpleText); - sTxt.SearchAndReplaceAll(0x0A, 0x0B); - rWrt.WriteStringAsPara( sTxt ); + OUString sTxt(rAtn.msSimpleText); + rWrt.WriteStringAsPara(sTxt.replace(0x0A, 0x0B)); } } break; diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index dc3117a2dc0d..2d2c48ace377 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -1734,12 +1734,10 @@ static void InsertSpecialChar( WW8Export& rWrt, sal_uInt8 c, static String lcl_GetExpandedField(const SwField &rFld) { - String sRet(rFld.ExpandField(true)); + OUString sRet(rFld.ExpandField(true)); //replace LF 0x0A with VT 0x0B - sRet.SearchAndReplaceAll(0x0A, 0x0B); - - return sRet; + return sRet.replace(0x0A, 0x0B); } WW8_WrPlcFld* WW8Export::CurrentFieldPlc() const @@ -2405,10 +2403,10 @@ OUString FieldString(ww::eField eIndex) void WW8AttributeOutput::HiddenField( const SwField& rFld ) { - String sExpand(rFld.GetPar2()); + OUString sExpand(rFld.GetPar2()); //replace LF 0x0A with VT 0x0B - sExpand.SearchAndReplaceAll(0x0A, 0x0B); + sExpand = sExpand.replace(0x0A, 0x0B); m_rWW8Export.pChpPlc->AppendFkpEntry(m_rWW8Export.Strm().Tell()); if (m_rWW8Export.IsUnicode()) { diff --git a/sw/source/ui/dbui/dbui.cxx b/sw/source/ui/dbui/dbui.cxx index 09b235731120..f1b58e2975e7 100644 --- a/sw/source/ui/dbui/dbui.cxx +++ b/sw/source/ui/dbui/dbui.cxx @@ -66,9 +66,9 @@ CreateMonitor::CreateMonitor( Window *pParent ) void CreateMonitor::UpdateCountingText() { - String sText(m_sCountingPattern); - sText.SearchAndReplaceAll( m_sVariable_Total, OUString::number( m_nTotalCount ) ); - sText.SearchAndReplaceAll( m_sVariable_Position, OUString::number( m_nCurrentPosition ) ); + OUString sText(m_sCountingPattern); + sText = sText.replaceAll( m_sVariable_Total, OUString::number( m_nTotalCount ) ); + sText = sText.replaceAll( m_sVariable_Position, OUString::number( m_nCurrentPosition ) ); m_aCounting.SetText(sText); } diff --git a/sw/source/ui/dbui/mmlayoutpage.cxx b/sw/source/ui/dbui/mmlayoutpage.cxx index 34fafc218039..e213d70d8dfd 100644 --- a/sw/source/ui/dbui/mmlayoutpage.cxx +++ b/sw/source/ui/dbui/mmlayoutpage.cxx @@ -319,8 +319,8 @@ SwFrmFmt* SwMailMergeLayoutPage::InsertAddressFrame( sDBName += DB_DELIM; sDBName += String(rData.sCommand); sDBName += DB_DELIM; - String sDatabaseConditionPrefix(sDBName); - sDatabaseConditionPrefix.SearchAndReplaceAll(DB_DELIM, '.'); + OUString sDatabaseConditionPrefix(sDBName); + sDatabaseConditionPrefix = sDatabaseConditionPrefix.replace(DB_DELIM, '.'); sDBName += OUString::number(rData.nCommandType); sDBName += DB_DELIM; diff --git a/sw/source/ui/misc/redlndlg.cxx b/sw/source/ui/misc/redlndlg.cxx index 870ca9ace524..d4edaf0e4724 100644 --- a/sw/source/ui/misc/redlndlg.cxx +++ b/sw/source/ui/misc/redlndlg.cxx @@ -438,9 +438,8 @@ void SwRedlineAcceptDlg::Activate() if (pParent->pTLBParent) { // update only comment - String sComment(rRedln.GetComment()); - sComment.SearchAndReplaceAll((sal_Unicode)'\n',(sal_Unicode)' '); - pTable->SetEntryText(sComment, pParent->pTLBParent, 3); + OUString sComment(rRedln.GetComment()); + pTable->SetEntryText(sComment.replace('\n', ' '), pParent->pTLBParent, 3); } pParent->sComment = rRedln.GetComment(); } @@ -725,9 +724,8 @@ void SwRedlineAcceptDlg::InsertParents(sal_uInt16 nStart, sal_uInt16 nEnd) pRedlineParent = new SwRedlineDataParent; pRedlineParent->pData = pRedlineData; pRedlineParent->pNext = 0; - String sComment(rRedln.GetComment()); - sComment.SearchAndReplaceAll((sal_Unicode)'\n',(sal_Unicode)' '); - pRedlineParent->sComment = sComment; + OUString sComment(rRedln.GetComment()); + pRedlineParent->sComment = sComment.replace('\n', ' '); aRedlineParents.insert(aRedlineParents.begin() + i, pRedlineParent); pData = new RedlinData; @@ -1113,12 +1111,11 @@ IMPL_LINK_NOARG(SwRedlineAcceptDlg, CommandHdl) if ( pDlg->Execute() == RET_OK ) { const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); - String sMsg(((const SvxPostItTextItem&)pOutSet->Get(SID_ATTR_POSTIT_TEXT)).GetValue()); + OUString sMsg(((const SvxPostItTextItem&)pOutSet->Get(SID_ATTR_POSTIT_TEXT)).GetValue()); // insert / change comment pSh->SetRedlineComment(sMsg); - sMsg.SearchAndReplaceAll((sal_Unicode)'\n',(sal_Unicode)' '); - pTable->SetEntryText(sMsg, pEntry, 3); + pTable->SetEntryText(sMsg.replace('\n', ' '), pEntry, 3); } delete pDlg; diff --git a/sw/source/ui/uiview/viewport.cxx b/sw/source/ui/uiview/viewport.cxx index 77ccf025a903..c137db6ef685 100644 --- a/sw/source/ui/uiview/viewport.cxx +++ b/sw/source/ui/uiview/viewport.cxx @@ -695,15 +695,17 @@ IMPL_LINK( SwView, ScrollHdl, SwScrollbar *, pScrollbar ) aRect.Right() = aRect.Left(); aRect.Bottom() = aRect.Top(); - String sPageStr( GetPageStr( nPhNum, nVirtNum, sDisplay )); + OUString sPageStr( GetPageStr( nPhNum, nVirtNum, sDisplay )); SwContentAtPos aCnt( SwContentAtPos::SW_OUTLINE ); m_pWrtShell->GetContentAtPos( aPos, aCnt ); if( aCnt.sStr.Len() ) { sPageStr += OUString(" - "); - sPageStr.Insert( aCnt.sStr, 0, 80 ); - sPageStr.SearchAndReplaceAll( '\t', ' ' ); - sPageStr.SearchAndReplaceAll( 0x0a, ' ' ); + sal_Int32 nChunkLen = std::min<sal_Int32>(aCnt.sStr.Len(), 80); + OUString sChunk = aCnt.sStr.Copy(0, nChunkLen); + sPageStr = sChunk + sPageStr; + sPageStr = sPageStr.replace('\t', ' '); + sPageStr = sPageStr.replace(0x0a, ' '); } nPgNum = nPhNum; } |