diff options
author | Caolán McNamara <caolanm@redhat.com> | 2013-10-09 13:31:44 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-10-09 16:59:42 +0100 |
commit | ae95703819348938bf9e44bd635365e3e48cd05d (patch) | |
tree | 673328fb2669241829e582e4d9824ef1ee7eb5e9 | |
parent | 36c1239ae14ab7861f89db8efef121d0b1448636 (diff) |
Related: fdo#38838 remove UniString::SetToken & UniString::SearchAscii
Change-Id: I5219578fbeb40a0fe363f03c64021a83f7e505fb
-rw-r--r-- | include/tools/string.hxx | 4 | ||||
-rw-r--r-- | sw/source/core/fields/authfld.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/unocore/unosect.cxx | 18 | ||||
-rw-r--r-- | sw/source/ui/app/applab.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/dbui/mmoutputpage.cxx | 24 | ||||
-rw-r--r-- | sw/source/ui/dialog/regionsw.cxx | 8 | ||||
-rw-r--r-- | sw/source/ui/envelp/envlop1.cxx | 4 | ||||
-rw-r--r-- | tools/source/string/strascii.cxx | 58 | ||||
-rw-r--r-- | tools/source/string/tustring.cxx | 38 | ||||
-rw-r--r-- | unusedcode.easy | 1 |
10 files changed, 32 insertions, 129 deletions
diff --git a/include/tools/string.hxx b/include/tools/string.hxx index 008a822262a2..3ab553269eb0 100644 --- a/include/tools/string.hxx +++ b/include/tools/string.hxx @@ -105,8 +105,6 @@ private: TOOLS_DLLPRIVATE inline void ImplCopyData(); TOOLS_DLLPRIVATE inline sal_Unicode * ImplCopyStringData(sal_Unicode *); - TOOLS_DLLPRIVATE xub_StrLen SearchAscii( const sal_Char* pAsciiStr, xub_StrLen nIndex ) const; - UniString( const int* pDummy ); // not implemented: to prevent UniString( NULL ) UniString(int); // not implemented; to detect misuses of // UniString(sal_Unicode) @@ -243,8 +241,6 @@ public: xub_StrLen SearchAndReplace( const UniString& rStr, const UniString& rRepStr, xub_StrLen nIndex = 0 ); - void SetToken( xub_StrLen nToken, sal_Unicode cTok, const UniString& rStr, - xub_StrLen nIndex = 0 ); UniString GetToken( xub_StrLen nToken, sal_Unicode cTok, sal_Int32& rIndex ) const; UniString GetToken( xub_StrLen nToken, sal_Unicode cTok = ';' ) const; diff --git a/sw/source/core/fields/authfld.cxx b/sw/source/core/fields/authfld.cxx index 7312a22c7fc7..9a86d3dec762 100644 --- a/sw/source/core/fields/authfld.cxx +++ b/sw/source/core/fields/authfld.cxx @@ -668,7 +668,7 @@ bool SwAuthorityField::PutValue( const Any& rAny, sal_uInt16 /*nWhichId*/ ) OUStringBuffer sBuf; comphelper::string::padToLength(sBuf, AUTH_FIELD_ISBN, TOX_STYLE_DELIMITER); - String sToSet(sBuf.makeStringAndClear()); + OUString sToSet(sBuf.makeStringAndClear()); const PropertyValue* pParam = aParam.getConstArray(); for(sal_Int32 i = 0; i < aParam.getLength(); i++) { @@ -684,7 +684,7 @@ bool SwAuthorityField::PutValue( const Any& rAny, sal_uInt16 /*nWhichId*/ ) } else pParam[i].Value >>= sContent; - sToSet.SetToken(nFound, TOX_STYLE_DELIMITER, sContent); + sToSet = comphelper::string::setToken(sToSet, nFound, TOX_STYLE_DELIMITER, sContent); } } diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index 644ba32891df..5f7be3d5e11d 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -614,9 +614,8 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, case WID_SECT_DDE_FILE: case WID_SECT_DDE_ELEMENT: { - OUString uTmp; - pValues[nProperty] >>= uTmp; - String sTmp(uTmp); + OUString sTmp; + pValues[nProperty] >>= sTmp; if (m_bIsDescriptor) { if (!m_pProps->m_bDDE) @@ -627,9 +626,9 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, m_pProps->m_sLinkFileName = buf.makeStringAndClear(); m_pProps->m_bDDE = true; } - String sLinkFileName(m_pProps->m_sLinkFileName); - sLinkFileName.SetToken(pEntry->nWID - WID_SECT_DDE_TYPE, - sfx2::cTokenSeparator, sTmp); + OUString sLinkFileName(m_pProps->m_sLinkFileName); + sLinkFileName = comphelper::string::setToken(sLinkFileName, + pEntry->nWID - WID_SECT_DDE_TYPE, sfx2::cTokenSeparator, sTmp); m_pProps->m_sLinkFileName = sLinkFileName; } else @@ -641,7 +640,8 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, sLinkFileName += sfx2::cTokenSeparator; pSectionData->SetType(DDE_LINK_SECTION); } - sLinkFileName.SetToken(pEntry->nWID - WID_SECT_DDE_TYPE, + sLinkFileName = comphelper::string::setToken(sLinkFileName, + pEntry->nWID - WID_SECT_DDE_TYPE, sfx2::cTokenSeparator, sTmp); pSectionData->SetLinkFileName(sLinkFileName); } @@ -725,12 +725,12 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, { pSectionData->SetType(FILE_LINK_SECTION); } - String sSectLink(pSectionData->GetLinkFileName()); + OUString sSectLink(pSectionData->GetLinkFileName()); while (3 < comphelper::string::getTokenCount(sSectLink, sfx2::cTokenSeparator)) { sSectLink += sfx2::cTokenSeparator; } - sSectLink.SetToken(2, sfx2::cTokenSeparator, sLink); + sSectLink = comphelper::string::setToken(sSectLink, 2, sfx2::cTokenSeparator, sLink); pSectionData->SetLinkFileName(sSectLink); if (sSectLink.Len() < 3) { diff --git a/sw/source/ui/app/applab.cxx b/sw/source/ui/app/applab.cxx index 064af8e66651..bfe3481adf14 100644 --- a/sw/source/ui/app/applab.cxx +++ b/sw/source/ui/app/applab.cxx @@ -142,7 +142,7 @@ static const SwFrmFmt *lcl_InsertLabText( SwWrtShell& rSh, const SwLabItem& rIte String sDBName; if( (!rItem.bSynchron || !(nCol|nRow)) && (sDBName = InsertLabEnvText( rSh, rFldMgr, rItem.aWriting )).Len() && !bLast ) { - sDBName.SetToken( 3, DB_DELIM, OUString("True")); + sDBName = comphelper::string::setToken(sDBName, 3, DB_DELIM, "True"); SwInsertFld_Data aData(TYP_DBNEXTSETFLD, 0, sDBName, aEmptyStr, 0, &rSh ); rFldMgr.InsertFld( aData ); } diff --git a/sw/source/ui/dbui/mmoutputpage.cxx b/sw/source/ui/dbui/mmoutputpage.cxx index da72f2d395ec..395f3ee6cc0c 100644 --- a/sw/source/ui/dbui/mmoutputpage.cxx +++ b/sw/source/ui/dbui/mmoutputpage.cxx @@ -896,17 +896,17 @@ IMPL_LINK(SwMailMergeOutputPage, SendTypeHdl_Impl, ListBox*, pBox) if(bEnable) { //add the correct extension - String sAttach(m_aAttachmentED.GetText()); + OUString sAttach(m_aAttachmentED.GetText()); //do nothing if the user has removed the name - the warning will come early enough - if(sAttach.Len()) + if (!sAttach.isEmpty()) { - xub_StrLen nTokenCount = comphelper::string::getTokenCount(sAttach, '.'); + sal_Int32 nTokenCount = comphelper::string::getTokenCount(sAttach, '.'); if( 2 > nTokenCount) { sAttach += '.'; ++nTokenCount; } - sAttach.SetToken( nTokenCount - 1, '.', lcl_GetExtensionForDocType( nDocType )); + sAttach = comphelper::string::setToken(sAttach, nTokenCount - 1, '.', lcl_GetExtensionForDocType( nDocType )); m_aAttachmentED.SetText(sAttach); } } @@ -1054,14 +1054,14 @@ IMPL_LINK(SwMailMergeOutputPage, SendDocumentsHdl_Impl, PushButton*, pButton) aQuery.SetIsEmptyTextAllowed(false); if(RET_OK == aQuery.Execute()) { - String sAttach(aQuery.GetValue()); - xub_StrLen nTokenCount = comphelper::string::getTokenCount(sAttach, '.'); - if( 2 > nTokenCount) + OUString sAttach(aQuery.GetValue()); + sal_Int32 nTokenCount = comphelper::string::getTokenCount(sAttach, '.'); + if (2 > nTokenCount) { sAttach += '.'; ++nTokenCount; } - sAttach.SetToken( nTokenCount - 1, '.', lcl_GetExtensionForDocType( + sAttach = comphelper::string::setToken(sAttach, nTokenCount - 1, '.', lcl_GetExtensionForDocType( (sal_uLong)m_aSendAsLB.GetEntryData(m_aSendAsLB.GetSelectEntryPos()))); m_aAttachmentED.SetText(sAttach); } @@ -1194,12 +1194,12 @@ IMPL_LINK(SwMailMergeOutputPage, SendDocumentsHdl_Impl, PushButton*, pButton) { sBody = m_sBody; aDesc.sAttachmentURL = aName.GetValue(); - String sAttachment(m_aAttachmentED.GetText()); - xub_StrLen nTokenCount = comphelper::string::getTokenCount(sAttachment, '.'); - if( 2 > nTokenCount) + OUString sAttachment(m_aAttachmentED.GetText()); + sal_Int32 nTokenCount = comphelper::string::getTokenCount(sAttachment, '.'); + if (2 > nTokenCount) { sAttachment += '.'; - sAttachment.SetToken( nTokenCount, '.', sExtension); + sAttachment = comphelper::string::setToken(sAttachment, nTokenCount, '.', sExtension); } else if(sAttachment.GetToken( nTokenCount - 1, '.') != sExtension) sAttachment += sExtension; diff --git a/sw/source/ui/dialog/regionsw.cxx b/sw/source/ui/dialog/regionsw.cxx index 26b9264a51ea..cf376fe08840 100644 --- a/sw/source/ui/dialog/regionsw.cxx +++ b/sw/source/ui/dialog/regionsw.cxx @@ -158,14 +158,16 @@ void SwBaseShell::InsertRegionDialog(SfxRequest& rReq) if(aFile.Len() || aSub.Len()) { - String sLinkFileName = OUString(sfx2::cTokenSeparator); + OUString sLinkFileName = OUString(sfx2::cTokenSeparator); sLinkFileName += sfx2::cTokenSeparator; - sLinkFileName.SetToken(0, sfx2::cTokenSeparator,aFile); + sLinkFileName = comphelper::string::setToken(sLinkFileName, 0, sfx2::cTokenSeparator, aFile); if(SFX_ITEM_SET == pSet->GetItemState(FN_PARAM_2, sal_True, &pItem)) - sLinkFileName.SetToken(1, sfx2::cTokenSeparator, + { + sLinkFileName = comphelper::string::setToken(sLinkFileName, 1, sfx2::cTokenSeparator, ((const SfxStringItem *)pItem)->GetValue()); + } sLinkFileName += aSub; aSection.SetType( FILE_LINK_SECTION ); diff --git a/sw/source/ui/envelp/envlop1.cxx b/sw/source/ui/envelp/envlop1.cxx index a85fe4126b82..0586e8ca1584 100644 --- a/sw/source/ui/envelp/envlop1.cxx +++ b/sw/source/ui/envelp/envlop1.cxx @@ -246,7 +246,9 @@ IMPL_LINK( SwEnvPage, DatabaseHdl, ListBox *, pListBox ) sActDBName += DB_DELIM; } else - sActDBName.SetToken(1, DB_DELIM, m_pTableLB->GetSelectEntry()); + { + sActDBName = comphelper::string::setToken(sActDBName, 1, DB_DELIM, m_pTableLB->GetSelectEntry()); + } pSh->GetNewDBMgr()->GetColumnNames(m_pDBFieldLB, m_pDatabaseLB->GetSelectEntry(), m_pTableLB->GetSelectEntry()); return 0; diff --git a/tools/source/string/strascii.cxx b/tools/source/string/strascii.cxx index 5ae3967badf0..83cf85a42c08 100644 --- a/tools/source/string/strascii.cxx +++ b/tools/source/string/strascii.cxx @@ -63,21 +63,6 @@ static sal_Int32 ImplStringCompareAscii( const sal_Unicode* pStr1, const sal_Cha return nRet; } -static sal_Int32 ImplStringCompareWithoutZeroAscii( const sal_Unicode* pStr1, const sal_Char* pStr2, - xub_StrLen nCount ) -{ - sal_Int32 nRet = 0; - while ( nCount && - ((nRet = ((sal_Int32)*pStr1)-((sal_Int32)((unsigned char)*pStr2))) == 0) ) - { - ++pStr1, - ++pStr2, - --nCount; - } - - return nRet; -} - UniString& UniString::AppendAscii( const sal_Char* pAsciiStr ) { DBG_CHKTHIS( UniString, DbgCheckUniString ); @@ -168,47 +153,4 @@ StringCompare UniString::CompareToAscii( const sal_Char* pAsciiStr, return COMPARE_GREATER; } -xub_StrLen UniString::SearchAscii( const sal_Char* pAsciiStr, xub_StrLen nIndex ) const -{ - DBG_CHKTHIS( UniString, DbgCheckUniString ); - DBG_ASSERT( ImplDbgCheckAsciiStr( pAsciiStr, STRING_LEN ), - "UniString::SearchAscii() - pAsciiStr include characters > 127" ); - - sal_Int32 nLen = mpData->mnLen; - xub_StrLen nStrLen = ImplStringLen( pAsciiStr ); - - // If length of pAsciiStr is 0 or index exceeds length, it was not found - if ( !nStrLen || (nIndex >= nLen) ) - return STRING_NOTFOUND; - - const sal_Unicode* pStr = mpData->maStr; - pStr += nIndex; - - if ( nStrLen == 1 ) - { - sal_Unicode cSearch = (unsigned char)*pAsciiStr; - while ( nIndex < nLen ) - { - if ( *pStr == cSearch ) - return nIndex; - ++pStr, - ++nIndex; - } - } - else - { - // Only search within string - while ( nLen - nIndex >= nStrLen ) - { - // Check if string matches - if ( ImplStringCompareWithoutZeroAscii( pStr, pAsciiStr, nStrLen ) == 0 ) - return nIndex; - ++pStr, - ++nIndex; - } - } - - return STRING_NOTFOUND; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/tools/source/string/tustring.cxx b/tools/source/string/tustring.cxx index 9b10bdebf985..c339941b2a3d 100644 --- a/tools/source/string/tustring.cxx +++ b/tools/source/string/tustring.cxx @@ -235,44 +235,6 @@ xub_StrLen STRING::Match( const STRING& rStr ) const return STRING_MATCH; } -void STRING::SetToken( xub_StrLen nToken, STRCODE cTok, const STRING& rStr, - xub_StrLen nIndex ) -{ - DBG_CHKTHIS( STRING, DBGCHECKSTRING ); - DBG_CHKOBJ( &rStr, STRING, DBGCHECKSTRING ); - - const STRCODE* pStr = mpData->maStr; - xub_StrLen nLen = (xub_StrLen)mpData->mnLen; - xub_StrLen nTok = 0; - xub_StrLen nFirstChar = nIndex; - xub_StrLen i = nFirstChar; - - // Determine token position and length - pStr += i; - while ( i < nLen ) - { - // Increase token count if match - if ( *pStr == cTok ) - { - ++nTok; - - if ( nTok == nToken ) - nFirstChar = i+1; - else - { - if ( nTok > nToken ) - break; - } - } - - ++pStr, - ++i; - } - - if ( nTok >= nToken ) - Replace( nFirstChar, i-nFirstChar, rStr ); -} - STRING STRING::GetToken( xub_StrLen nToken, STRCODE cTok, sal_Int32& rIndex ) const { DBG_CHKTHIS( STRING, DBGCHECKSTRING ); diff --git a/unusedcode.easy b/unusedcode.easy index d4daf9cbb6f8..a8f893fe9296 100644 --- a/unusedcode.easy +++ b/unusedcode.easy @@ -66,7 +66,6 @@ String::Append(unsigned short const*) String::Append(unsigned short const*, unsigned short) String::Assign(unsigned short const*) String::Insert(String const&, unsigned short, unsigned short, unsigned short) -String::SearchAscii(char const*, unsigned short) const String::String(char) SvdProgressInfo::ReportError() SvpSalInstance::PostEvent(SalFrame const*, void*, unsigned short) |