dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx | 52 ++++++--------- editeng/source/outliner/outliner.cxx | 15 ++-- extensions/source/propctrlr/standardcontrol.cxx | 22 ++++-- oox/source/ole/axcontrol.cxx | 33 +++++---- sc/source/core/data/globalx.cxx | 8 +- sc/source/core/tool/compiler.cxx | 4 - sc/source/filter/excel/xecontent.cxx | 35 +++++----- sc/source/filter/excel/xlformula.cxx | 19 +++-- sc/source/filter/html/htmlexp.cxx | 36 +++------- sc/source/filter/html/htmlimp.cxx | 25 +++---- sc/source/ui/app/inputhdl.cxx | 17 +++-- sc/source/ui/dbgui/asciiopt.cxx | 3 sc/source/ui/dbgui/csvgrid.cxx | 8 -- sc/source/ui/dbgui/csvruler.cxx | 24 ++++--- sc/source/ui/dbgui/scuiasciiopt.cxx | 47 ++++++++------ sc/source/ui/dbgui/scuiimoptdlg.cxx | 60 +++++++----------- sc/source/ui/dbgui/validate.cxx | 14 ++-- sc/source/ui/docshell/arealink.cxx | 25 +++---- sc/source/ui/docshell/docsh8.cxx | 26 +++---- sc/source/ui/miscdlgs/anyrefdg.cxx | 33 +++++---- sc/source/ui/miscdlgs/linkarea.cxx | 12 ++- sc/source/ui/optdlg/tpusrlst.cxx | 10 +-- sc/source/ui/pagedlg/areasdlg.cxx | 13 +-- 23 files changed, 275 insertions(+), 266 deletions(-)
New commits: commit a6589756916ae0e5f85c8320f602fa07b7291e73 Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Sep 9 20:01:03 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:08:02 2018 +0200 Avoid getTokenCount() Change-Id: I82fa0cca6cd14f92c11678fa7d416fcf629195b8 diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx index 57a888543cf2..fe4ae899fc47 100644 --- a/sc/source/ui/dbgui/scuiasciiopt.cxx +++ b/sc/source/ui/dbgui/scuiasciiopt.cxx @@ -34,7 +34,6 @@ #include <strings.hrc> #include <strings.hxx> #include <csvtablebox.hxx> -#include <comphelper/string.hxx> #include <osl/thread.h> #include <rtl/tencinfo.h> #include <unotools/transliterationwrapper.hxx> @@ -122,13 +121,19 @@ static sal_Unicode lcl_CharFromCombo( const ComboBox& rCombo, const OUString& rL { sal_Unicode c = 0; OUString aStr = rCombo.GetText(); - if ( !aStr.isEmpty() ) + if ( !aStr.isEmpty() && !rList.isEmpty() ) { - sal_Int32 nCount = comphelper::string::getTokenCount(rList, '\t'); - for ( sal_Int32 i=0; i<nCount; i+=2 ) + sal_Int32 nIdx {0}; + OUString sToken {rList.getToken(0, '\t', nIdx)}; + while (nIdx>0) { - if ( ScGlobal::GetpTransliteration()->isEqual( aStr, rList.getToken(i,'\t') ) ) - c = static_cast<sal_Unicode>(rList.getToken(i+1,'\t').toInt32()); + if ( ScGlobal::GetpTransliteration()->isEqual( aStr, sToken ) ) + { + sal_Int32 nTmpIdx {nIdx}; + c = static_cast<sal_Unicode>(rList.getToken(0, '\t', nTmpIdx).toInt32()); + } + // Skip to next token at even position + sToken = rList.getToken(1, '\t', nIdx); } if (!c) { commit a928e673c4b7cd40d6c903013517325249938a6e Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Sep 9 19:18:36 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:08:02 2018 +0200 Remove redundant check Change-Id: Ib35da3156a48d7421ba73a33baee8341dd05355f diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx index 706289ef6f7d..57a888543cf2 100644 --- a/sc/source/ui/dbgui/scuiasciiopt.cxx +++ b/sc/source/ui/dbgui/scuiasciiopt.cxx @@ -130,7 +130,7 @@ static sal_Unicode lcl_CharFromCombo( const ComboBox& rCombo, const OUString& rL if ( ScGlobal::GetpTransliteration()->isEqual( aStr, rList.getToken(i,'\t') ) ) c = static_cast<sal_Unicode>(rList.getToken(i+1,'\t').toInt32()); } - if (!c && !aStr.isEmpty()) + if (!c) { sal_Unicode cFirst = aStr[0]; // #i24235# first try the first character of the string directly commit 5b383e1feece636cce3e90eb6a49221dfa5a2a5a Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Sep 9 18:32:49 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:08:01 2018 +0200 Avoid getTokenCount() Change-Id: I4f0f921a177e10fc896a12b2bea8aaced1cacf0d diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx index e4c2e5622954..706289ef6f7d 100644 --- a/sc/source/ui/dbgui/scuiasciiopt.cxx +++ b/sc/source/ui/dbgui/scuiasciiopt.cxx @@ -95,17 +95,22 @@ CSVImportOptionsIndex getSkipEmptyCellsIndex( ScImportAsciiCall eCall ) static void lcl_FillCombo( ComboBox& rCombo, const OUString& rList, sal_Unicode cSelect ) { - sal_Int32 i; - sal_Int32 nCount = comphelper::string::getTokenCount(rList, '\t'); - for ( i=0; i<nCount; i+=2 ) - rCombo.InsertEntry( rList.getToken(i,'\t') ); + OUString aStr; + if (!rList.isEmpty()) + { + sal_Int32 nIdx {0}; + do + { + const OUString sEntry {rList.getToken(0, '\t', nIdx)}; + rCombo.InsertEntry( sEntry ); + if (nIdx>0 && static_cast<sal_Unicode>(rList.getToken(0, '\t', nIdx).toInt32()) == cSelect) + aStr = sEntry; + } + while (nIdx>0); + } if ( cSelect ) { - OUString aStr; - for ( i=0; i<nCount; i+=2 ) - if ( static_cast<sal_Unicode>(rList.getToken(i+1,'\t').toInt32()) == cSelect ) - aStr = rList.getToken(i,'\t'); if (aStr.isEmpty()) aStr = OUString(cSelect); // Ascii commit 31fca96e53e59e810da136e8448b8e6986c44afa Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Sep 9 12:30:06 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:08:01 2018 +0200 Avoid getTokenCount() Change-Id: I3d4ae7495f43cae35e8a149c6523bc0337621724 diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx index 65fd640ba363..178f90991727 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx @@ -945,7 +945,7 @@ bool OSelectionBrowseBox::SaveModified() sal_Int32 nPos = m_pFieldCell->GetEntryPos(aFieldName); OUString aAliasName = pEntry->GetAlias(); - if ( nPos != COMBOBOX_ENTRY_NOTFOUND && aAliasName.isEmpty() && comphelper::string::getTokenCount(aFieldName, '.') > 1 ) + if ( nPos != COMBOBOX_ENTRY_NOTFOUND && aAliasName.isEmpty() && aFieldName.indexOf('.') >= 0 ) { // special case, we have a table field so we must cut the table name OUString sTableAlias = aFieldName.getToken(0,'.'); pEntry->SetAlias(sTableAlias); commit 1b49ad9550ce69e29ad0fcdf32d2f345b58ff76d Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Sep 9 12:26:59 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:08:01 2018 +0200 Remove return variable Change-Id: I322386e103e21e2660716419dd0747765ee087de diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx index 97848337ffa4..65fd640ba363 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx @@ -2145,7 +2145,6 @@ OUString OSelectionBrowseBox::GetCellText(long nRow, sal_uInt16 nColId) const bool OSelectionBrowseBox::GetFunctionName(sal_uInt32 _nFunctionTokenId, OUString& rFkt) { - bool bErg=true; switch(_nFunctionTokenId) { case SQL_TOKEN_COUNT: @@ -2205,11 +2204,11 @@ bool OSelectionBrowseBox::GetFunctionName(sal_uInt32 _nFunctionTokenId, OUString return true; } } - bErg = false; + return false; } } - return bErg; + return true; } OUString OSelectionBrowseBox::GetCellContents(sal_Int32 nCellIndex, sal_uInt16 nColId) commit 7ce0fbe7e71cfde8a73f359fac5dd9ed02587be7 Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Sep 9 12:25:08 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:08:00 2018 +0200 Reduce OUString operations Change-Id: Ia95ced36201ee78d511604a33992be0eff4810df diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx index c99cfd24b64d..97848337ffa4 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx @@ -190,12 +190,9 @@ void OSelectionBrowseBox::initialize() for (IParseContext::InternationalKeyCode eFunction : eFunctions) { - m_aFunctionStrings += ";"; - m_aFunctionStrings += OStringToOUString(rContext.getIntlKeywordAscii(eFunction), - RTL_TEXTENCODING_UTF8); + m_aFunctionStrings += ";" + OStringToOUString(rContext.getIntlKeywordAscii(eFunction), RTL_TEXTENCODING_UTF8); } - m_aFunctionStrings += ";"; - m_aFunctionStrings += sGroup; + m_aFunctionStrings += ";" + sGroup; // Aggregate functions in general available only with Core SQL // We slip in a few optionals one, too. @@ -697,13 +694,12 @@ bool OSelectionBrowseBox::saveField(OUString& _sFieldName ,OTableFieldDescRef co bool bQuote = ( nPass <= 2 ); bool bInternational = ( nPass % 2 ) == 0; - OUString sSql; + OUString sSql {"SELECT "}; if ( bQuote ) sSql += sQuotedFullFieldName; else sSql += sFullFieldName; - sSql = "SELECT " + sSql; if ( !sFieldAlias.isEmpty() ) { // always quote the alias name: there cannot be a function in it sSql += " " + ::dbtools::quoteName( xMetaData->getIdentifierQuoteString(), sFieldAlias ); commit 0da6e8800b8188caae60707ed2c609d9a17c1dd8 Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Sep 9 11:29:29 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:08:00 2018 +0200 Avoid getTokenCount() Change-Id: Ib84104ea0c523729c3a7fe6019ed2e788ff7b189 diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx index fde2fd045af3..c99cfd24b64d 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx @@ -2199,18 +2199,17 @@ bool OSelectionBrowseBox::GetFunctionName(sal_uInt32 _nFunctionTokenId, OUString break; default: { - sal_Int32 nCount = comphelper::string::getTokenCount(m_aFunctionStrings, ';'); - sal_Int32 i; - for( i = 0; i < nCount-1; i++ ) // grouping is not counted + const sal_Int32 nStopIdx = m_aFunctionStrings.lastIndexOf(';'); // grouping is not counted + for (sal_Int32 nIdx {0}; nIdx<nStopIdx;) { - if(rFkt.equalsIgnoreAsciiCase(m_aFunctionStrings.getToken(i, ';'))) + const OUString sFunc {m_aFunctionStrings.getToken(0, ';', nIdx)}; + if (rFkt.equalsIgnoreAsciiCase(sFunc)) { - rFkt = m_aFunctionStrings.getToken(i, ';'); - break; + rFkt = sFunc; + return true; } } - if(i == nCount-1) - bErg = false; + bErg = false; } } commit d1bda6b0b0f2d42a76df822757d21130c401922e Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Sep 9 10:48:28 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:59 2018 +0200 Avoid getTokenCount() Change-Id: I30b9a9122a1e20f50471d1864b8c08af985fc5d7 diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx index 02096f44f68e..fde2fd045af3 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx @@ -185,7 +185,7 @@ void OSelectionBrowseBox::initialize() ,IParseContext::InternationalKeyCode::Intersection }; - OUString sGroup = m_aFunctionStrings.getToken(comphelper::string::getTokenCount(m_aFunctionStrings, ';') - 1, ';'); + OUString sGroup = m_aFunctionStrings.copy(m_aFunctionStrings.lastIndexOf(';')+1);; m_aFunctionStrings = m_aFunctionStrings.getToken(0, ';'); for (IParseContext::InternationalKeyCode eFunction : eFunctions) @@ -822,7 +822,7 @@ bool OSelectionBrowseBox::saveField(OUString& _sFieldName ,OTableFieldDescRef co aSelEntry->SetField(sParameters); if ( aSelEntry->IsGroupBy() ) { - sOldLocalizedFunctionName = m_aFunctionStrings.getToken(comphelper::string::getTokenCount(m_aFunctionStrings, ';')-1, ';'); + sOldLocalizedFunctionName = m_aFunctionStrings.copy(m_aFunctionStrings.lastIndexOf(';')+1); aSelEntry->SetGroupBy(false); } @@ -1040,7 +1040,7 @@ bool OSelectionBrowseBox::SaveModified() sal_Int32 nPos = m_pFunctionCell->GetSelectedEntryPos(); // these functions are only available in CORE OUString sFunctionName = m_pFunctionCell->GetEntry(nPos); - OUString sGroupFunctionName = m_aFunctionStrings.getToken(comphelper::string::getTokenCount(m_aFunctionStrings, ';')-1, ';'); + OUString sGroupFunctionName = m_aFunctionStrings.copy(m_aFunctionStrings.lastIndexOf(';')+1); bool bGroupBy = false; if ( sGroupFunctionName == sFunctionName ) // check if the function name is GROUP { @@ -2137,7 +2137,7 @@ OUString OSelectionBrowseBox::GetCellText(long nRow, sal_uInt16 nColId) const case BROW_FUNCTION_ROW: // we always show the group function at first if ( pEntry->IsGroupBy() ) - aText = m_aFunctionStrings.getToken(comphelper::string::getTokenCount(m_aFunctionStrings, ';')-1, ';'); + aText = m_aFunctionStrings.copy(m_aFunctionStrings.lastIndexOf(';')+1); else if ( pEntry->isNumericOrAggreateFunction() ) aText = pEntry->GetFunction(); break; @@ -2273,7 +2273,7 @@ void OSelectionBrowseBox::SetCellContents(sal_Int32 nRow, sal_uInt16 nColId, con break; case BROW_FUNCTION_ROW: { - OUString sGroupFunctionName = m_aFunctionStrings.getToken(comphelper::string::getTokenCount(m_aFunctionStrings, ';')-1, ';'); + OUString sGroupFunctionName = m_aFunctionStrings.copy(m_aFunctionStrings.lastIndexOf(';')+1); pEntry->SetFunction(strNewText); // first reset this two member sal_Int32 nFunctionType = pEntry->GetFunctionType(); commit 4f90bd648de91cfb803e94148e8ffcbc9502299e Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Sep 9 10:24:44 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:59 2018 +0200 Avoid getTokenCount() Change-Id: I13318d43d3c572bd81080d5bb164fdcd9cd7d27b diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx index 604f9bd66ec0..02096f44f68e 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx @@ -135,10 +135,9 @@ OSelectionBrowseBox::OSelectionBrowseBox( vcl::Window* pParent ) aTitleFont.SetFontSize(Size(0, 6)); SetTitleFont(aTitleFont); - OUString aTxt(DBA_RES(STR_QUERY_SORTTEXT)); - sal_Int32 nCount = comphelper::string::getTokenCount(aTxt, ';'); - for (sal_Int32 nIdx = 0; nIdx < nCount; nIdx++) - m_pOrderCell->InsertEntry(aTxt.getToken(nIdx, ';')); + const OUString aTxt(DBA_RES(STR_QUERY_SORTTEXT)); + for (sal_Int32 nIdx {0}; nIdx>=0;) + m_pOrderCell->InsertEntry(aTxt.getToken(0, ';', nIdx)); m_bVisibleRow.insert(m_bVisibleRow.end(), BROW_ROW_CNT, true); @@ -202,9 +201,8 @@ void OSelectionBrowseBox::initialize() // We slip in a few optionals one, too. if ( lcl_SupportsCoreSQLGrammar(xConnection) ) { - sal_Int32 nCount = comphelper::string::getTokenCount(m_aFunctionStrings, ';'); - for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++ ) - m_pFunctionCell->InsertEntry(m_aFunctionStrings.getToken(nIdx, ';')); + for (sal_Int32 nIdx {0}; nIdx>=0;) + m_pFunctionCell->InsertEntry(m_aFunctionStrings.getToken(0, ';', nIdx)); } else // else only COUNT(*) and COUNT("table".*) { commit d3596b7274934e124b6baf57a2fb2fe75d732598 Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Sep 9 02:05:50 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:58 2018 +0200 Handle trailing token separator without copying string Change-Id: I09770f343ed54645cfa1f56ed2604af5e18c1720 diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx index 0c97d71bd60a..01f4a218708a 100644 --- a/editeng/source/outliner/outliner.cxx +++ b/editeng/source/outliner/outliner.cxx @@ -423,15 +423,16 @@ void Outliner::SetText( const OUString& rText, Paragraph* pPara ) } else { - OUString aText(convertLineEnd(rText, LINEEND_LF)); - - if (aText.endsWith("\x0A")) - aText = aText.copy(0, aText.getLength()-1); // Delete the last break + const OUString aText(convertLineEnd(rText, LINEEND_LF)); sal_Int32 nPos = 0; sal_Int32 nInsPos = nPara+1; - sal_Int32 nIdx {aText.isEmpty() ? -1 : 0}; - while( nIdx>=0 ) + sal_Int32 nIdx {0}; + // Loop over all tokens, but ignore the last one if empty + // (i.e. if strings ends with the delimiter, detected by + // checking nIdx against string length). This check also + // handle empty strings. + while( nIdx>=0 && nIdx<aText.getLength() ) { OUString aStr = aText.getToken( 0, '\x0A', nIdx ); commit 82974d069bc35c0eaaae0dd1cbfe2a46bc237552 Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Sep 9 01:44:31 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:58 2018 +0200 Avoid getTokenCount() Change-Id: I6b90d09d37ed47f965110fb93138155a1271c7dc diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx index 186a1c17daca..0c97d71bd60a 100644 --- a/editeng/source/outliner/outliner.cxx +++ b/editeng/source/outliner/outliner.cxx @@ -428,12 +428,12 @@ void Outliner::SetText( const OUString& rText, Paragraph* pPara ) if (aText.endsWith("\x0A")) aText = aText.copy(0, aText.getLength()-1); // Delete the last break - sal_Int32 nCount = comphelper::string::getTokenCount(aText, '\x0A'); sal_Int32 nPos = 0; sal_Int32 nInsPos = nPara+1; - while( nCount > nPos ) + sal_Int32 nIdx {aText.isEmpty() ? -1 : 0}; + while( nIdx>=0 ) { - OUString aStr = aText.getToken( nPos, '\x0A' ); + OUString aStr = aText.getToken( 0, '\x0A', nIdx ); sal_Int16 nCurDepth; if( nPos ) commit 3ca649430c832be555b556fd045fa5d490e4da9e Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Sep 9 00:25:34 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:58 2018 +0200 Fix condition in f573402116937876cb0b80cf7af2a52bf2ccc31a Change-Id: I6b755c64da5050f69114f63c693ff25c7b12991f diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx index bc57fb52f413..e4c2e5622954 100644 --- a/sc/source/ui/dbgui/scuiasciiopt.cxx +++ b/sc/source/ui/dbgui/scuiasciiopt.cxx @@ -474,7 +474,7 @@ ScImportAsciiDlg::ScImportAsciiDlg( vcl::Window* pParent, const OUString& aDatNa pLbCustomLang->SelectLanguage(static_cast<LanguageType>(nLanguage)); // *** column type ListBox *** - for (sal_Int32 nIdx {0}; nIdx>0; ) + for (sal_Int32 nIdx {0}; nIdx>=0; ) { pLbType->InsertEntry( aColumnUser.getToken( 0, ';', nIdx ) ); } commit da37548dab2eeaae6a105574549c6e504ba49674 Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sat Sep 8 23:26:40 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:57 2018 +0200 Avoid getTokenCount() Change-Id: I783dc5a6b31c3a2be65a1dc50f69f86a29cca0ae diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 9351055540bb..2d56ce5f075a 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -52,7 +52,6 @@ #include <vcl/cursor.hxx> #include <vcl/settings.hxx> #include <tools/urlobj.hxx> -#include <comphelper/string.hxx> #include <formula/formulahelper.hxx> #include <formula/funcvarargs.h> #include <LibreOfficeKit/LibreOfficeKitEnums.h> @@ -875,6 +874,16 @@ void ScInputHandler::HideTipBelow() aManualTip.clear(); } +namespace +{ + +bool lcl_hasSingleToken(const OUString& s, sal_Unicode c) +{ + return !s.isEmpty() && s.indexOf(c)<0; +} + +} + void ScInputHandler::ShowArgumentsTip( OUString& rSelText ) { ScDocShell* pDocSh = pActiveViewSh->GetViewData().GetDocShell(); @@ -917,12 +926,10 @@ void ScInputHandler::ShowArgumentsTip( OUString& rSelText ) } if( bFlag ) { - sal_Int32 nCountSemicolon = comphelper::string::getTokenCount(aNew, cSep) - 1; - sal_Int32 nCountDot = comphelper::string::getTokenCount(aNew, cSheetSep) - 1; sal_Int32 nStartPosition = 0; sal_Int32 nEndPosition = 0; - if( !nCountSemicolon ) + if( lcl_hasSingleToken(aNew, cSep) ) { for (sal_Int32 i = 0; i < aNew.getLength(); ++i) { @@ -933,7 +940,7 @@ void ScInputHandler::ShowArgumentsTip( OUString& rSelText ) } } } - else if( !nCountDot ) + else if( lcl_hasSingleToken(aNew, cSheetSep) ) { sal_uInt16 nCount = 0; for (sal_Int32 i = 0; i < aNew.getLength(); ++i) commit 67e2acb013ebe0f716ee096f12ec63debcd1d814 Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sat Sep 8 19:15:25 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:57 2018 +0200 Avoid getTokenCount() Change-Id: I2fa4e9d36fa2707ba7fb6faa59fc8f4be906c04c diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx index 2e5be7e5528b..08c7d1caa616 100644 --- a/sc/source/filter/html/htmlexp.cxx +++ b/sc/source/filter/html/htmlexp.cxx @@ -18,7 +18,6 @@ */ #include <scitems.hxx> -#include <comphelper/string.hxx> #include <editeng/eeitem.hxx> #include <rtl/tencinfo.h> @@ -350,24 +349,17 @@ void ScHTMLExport::WriteHeader() .WriteCharPtr( OOO_STRING_SVTOOLS_HTML_tablerow ).WriteCharPtr( "," ).WriteCharPtr( OOO_STRING_SVTOOLS_HTML_tableheader ).WriteCharPtr( "," ) .WriteCharPtr( OOO_STRING_SVTOOLS_HTML_tabledata ).WriteCharPtr( "," ).WriteCharPtr( OOO_STRING_SVTOOLS_HTML_parabreak ) .WriteCharPtr( " { " ).WriteCharPtr( "font-family:" ); - sal_Int32 nFonts = comphelper::string::getTokenCount(aHTMLStyle.aFontFamilyName, ';'); - if ( nFonts == 1 ) + if (!aHTMLStyle.aFontFamilyName.isEmpty()) { - rStrm.WriteChar( '\"' ); - OUT_STR( aHTMLStyle.aFontFamilyName ); - rStrm.WriteChar( '\"' ); - } - else - { // Fontlist, VCL: Semicolon as separator - // CSS1: Comma as separator and every single font name quoted const OUString& rList = aHTMLStyle.aFontFamilyName; - for ( sal_Int32 j = 0, nPos = 0; j < nFonts; j++ ) + for(sal_Int32 nPos {0};;) { rStrm.WriteChar( '\"' ); OUT_STR( rList.getToken( 0, ';', nPos ) ); rStrm.WriteChar( '\"' ); - if ( j < nFonts-1 ) - rStrm.WriteCharPtr( ", " ); + if (nPos<0) + break; + rStrm.WriteCharPtr( ", " ); } } rStrm.WriteCharPtr( "; " ).WriteCharPtr( "font-size:" ) @@ -1104,26 +1096,22 @@ void ScHTMLExport::WriteCell( SCCOL nCol, SCROW nRow, SCTAB nTab ) { aStr.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_face). append("=\""); - sal_Int32 nFonts = comphelper::string::getTokenCount(rFontItem.GetFamilyName(), ';'); - if ( nFonts == 1 ) + + if (!rFontItem.GetFamilyName().isEmpty()) { - OString aTmpStr = HTMLOutFuncs::ConvertStringToHTML( - rFontItem.GetFamilyName(), eDestEnc, &aNonConvertibleChars); - aStr.append(aTmpStr); - } - else - { // Font list, VCL: Semicolon as separator, HTML: Comma const OUString& rList = rFontItem.GetFamilyName(); - for ( sal_Int32 j = 0, nPos = 0; j < nFonts; j++ ) + for (sal_Int32 nPos {0};;) { OString aTmpStr = HTMLOutFuncs::ConvertStringToHTML( rList.getToken( 0, ';', nPos ), eDestEnc, &aNonConvertibleChars); aStr.append(aTmpStr); - if ( j < nFonts-1 ) - aStr.append(','); + if (nPos<0) + break; + aStr.append(','); } } + aStr.append('\"'); } if ( nSetFontSizeNumber ) commit daf832451e49592096c1cc7926584d887000aca3 Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sat Sep 8 18:50:37 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:56 2018 +0200 Avoid getTokenCount() Change-Id: I3148f7fcd9db1511cf552f62b81ac6937302a160 diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx index db98865ca7f0..bc57fb52f413 100644 --- a/sc/source/ui/dbgui/scuiasciiopt.cxx +++ b/sc/source/ui/dbgui/scuiasciiopt.cxx @@ -474,9 +474,10 @@ ScImportAsciiDlg::ScImportAsciiDlg( vcl::Window* pParent, const OUString& aDatNa pLbCustomLang->SelectLanguage(static_cast<LanguageType>(nLanguage)); // *** column type ListBox *** - sal_Int32 nCount = comphelper::string::getTokenCount(aColumnUser, ';'); - for (sal_Int32 i=0; i<nCount; i++) - pLbType->InsertEntry( aColumnUser.getToken( i, ';' ) ); + for (sal_Int32 nIdx {0}; nIdx>0; ) + { + pLbType->InsertEntry( aColumnUser.getToken( 0, ';', nIdx ) ); + } pLbType->SetSelectHdl( LINK( this, ScImportAsciiDlg, LbColTypeHdl ) ); pFtType->Disable(); commit 2c1c0168e02e1efda51f8a0f71bf030da4f665f3 Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sat Sep 8 17:33:28 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:56 2018 +0200 Avoid getTokenCount() Change-Id: Idb1eff48c33a8bd9c5119c1caa6ee01202d1d374 diff --git a/sc/source/ui/dbgui/scuiimoptdlg.cxx b/sc/source/ui/dbgui/scuiimoptdlg.cxx index ab8371865a6b..632e297a4111 100644 --- a/sc/source/ui/dbgui/scuiimoptdlg.cxx +++ b/sc/source/ui/dbgui/scuiimoptdlg.cxx @@ -24,7 +24,6 @@ #include <scresid.hxx> #include <strings.hrc> #include <strings.hxx> -#include <comphelper/string.hxx> #include <officecfg/Office/Calc.hxx> #include <osl/thread.h> #include <rtl/tencinfo.h> @@ -36,65 +35,54 @@ class ScDelimiterTable public: explicit ScDelimiterTable( const OUString& rDelTab ) : theDelTab ( rDelTab ), - nCount ( comphelper::string::getTokenCount(rDelTab, '\t') ), - nIter ( 0 ) + nDelIdx ( 0 ) {} sal_uInt16 GetCode( const OUString& rDelimiter ) const; OUString GetDelimiter( sal_Unicode nCode ) const; - OUString FirstDel() { nIter = 0; return theDelTab.getToken( nIter, cSep ); } - OUString NextDel() { nIter +=2; return theDelTab.getToken( nIter, cSep ); } + OUString FirstDel() { nDelIdx = 0; return theDelTab.getToken( 0, cSep, nDelIdx ); } + OUString NextDel() { return theDelTab.getToken( 1, cSep, nDelIdx ); } private: const OUString theDelTab; - static const sal_Unicode cSep = '\t'; - const sal_Int32 nCount; - sal_Int32 nIter; + static constexpr sal_Unicode cSep {'\t'}; + sal_Int32 nDelIdx; }; sal_uInt16 ScDelimiterTable::GetCode( const OUString& rDel ) const { - sal_Unicode nCode = 0; - - if ( nCount >= 2 ) + if (!theDelTab.isEmpty()) { - sal_Int32 i = 0; - while ( i<nCount ) - { - if ( rDel == theDelTab.getToken( i, cSep ) ) - { - nCode = static_cast<sal_Unicode>(theDelTab.getToken( i+1, cSep ).toInt32()); - i = nCount; - } - else - i += 2; - } + sal_Int32 nIdx {0}; + + // Check even tokens: start from 0 and then skip 1 token at each iteration + if (rDel != theDelTab.getToken( 0, cSep, nIdx )) + while (nIdx>0 && rDel != theDelTab.getToken( 1, cSep, nIdx )); + + if (nIdx>0) + return static_cast<sal_Unicode>(theDelTab.getToken( 0, cSep, nIdx ).toInt32()); } - return nCode; + return 0; } OUString ScDelimiterTable::GetDelimiter( sal_Unicode nCode ) const { - OUString aStrDel; - - if ( nCount >= 2 ) + if (!theDelTab.isEmpty()) { - sal_Int32 i = 0; - while ( i<nCount ) + sal_Int32 nIdx {0}; + // Check odd tokens: start from 1 and then skip 1 token at each iteration + do { - if ( nCode == static_cast<sal_Unicode>(theDelTab.getToken( i+1, cSep ).toInt32()) ) - { - aStrDel = theDelTab.getToken( i, cSep ); - i = nCount; - } - else - i += 2; + sal_Int32 nPrevIdx {nIdx}; + if (nCode == static_cast<sal_Unicode>(theDelTab.getToken( 1, cSep, nIdx ).toInt32())) + return theDelTab.getToken( 0, cSep, nPrevIdx ); } + while (nIdx>0); } - return aStrDel; + return OUString(); } // ScImportOptionsDlg commit 41bcf6138c88ed413d557419b73d29a8526e5fb3 Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Sep 2 15:38:50 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:56 2018 +0200 Avoid getTokenCount() Change-Id: I3d9a1c4a6c57fca1179a08494b6d298d4aeffb05 diff --git a/sc/source/ui/dbgui/csvgrid.cxx b/sc/source/ui/dbgui/csvgrid.cxx index 32ac2515f7de..f5b63fd3a48f 100644 --- a/sc/source/ui/dbgui/csvgrid.cxx +++ b/sc/source/ui/dbgui/csvgrid.cxx @@ -22,7 +22,6 @@ #include <algorithm> #include <memory> -#include <comphelper/string.hxx> #include <svtools/colorcfg.hxx> #include <sal/macros.h> #include <tools/poly.hxx> @@ -1084,12 +1083,11 @@ void ScCsvGrid::ImplDrawCellText( const Point& rPos, const OUString& rText ) /* #i60296# If string contains mixed script types, the space character U+0020 may be drawn with a wrong width (from non-fixed-width Asian or Complex font). Now we draw every non-space portion separately. */ - sal_Int32 nTokenCount = comphelper::string::getTokenCount(aPlainText, ' '); - sal_Int32 nCharIxInt = 0; - for( sal_Int32 nToken = 0; nToken < nTokenCount; ++nToken ) + sal_Int32 nCharIxInt {aPlainText.isEmpty() ? -1 : 0}; + while (nCharIxInt>=0) { sal_Int32 nBeginIx = nCharIxInt; - OUString aToken = aPlainText.getToken( 0, ' ', nCharIxInt ); + const OUString aToken = aPlainText.getToken( 0, ' ', nCharIxInt ); if( !aToken.isEmpty() ) { sal_Int32 nX = rPos.X() + GetCharWidth() * nBeginIx; commit 559449ba62565966aa4a42a822a70b07e6c98079 Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Sep 2 15:34:55 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:55 2018 +0200 Avoid getTokenCount and temporaries, reduce scope Change-Id: Ic97e9952de387040bb87e854eb34a183f0cf60ec diff --git a/sc/source/ui/dbgui/csvruler.cxx b/sc/source/ui/dbgui/csvruler.cxx index 9370a3decc89..86acdc1ec807 100644 --- a/sc/source/ui/dbgui/csvruler.cxx +++ b/sc/source/ui/dbgui/csvruler.cxx @@ -34,9 +34,6 @@ using namespace com::sun::star::uno; static void load_FixedWidthList(ScCsvSplits &rSplits) { - OUString sSplits; - OUString sFixedWidthLists; - Sequence<Any>aValues; const Any *pProperties; Sequence<OUString> aNames { FIXED_WIDTH_LIST }; @@ -48,14 +45,23 @@ static void load_FixedWidthList(ScCsvSplits &rSplits) if( pProperties[0].hasValue() ) { rSplits.Clear(); - pProperties[0] >>= sFixedWidthLists; - sSplits = sFixedWidthLists; + OUString sFixedWidthLists; + pProperties[0] >>= sFixedWidthLists; - // String ends with a semi-colon so there is no 'int' after the last one. - sal_Int32 n = comphelper::string::getTokenCount(sSplits, ';') - 1; - for (sal_Int32 i = 0; i < n; ++i) - rSplits.Insert( sSplits.getToken(i, ';').toInt32() ); + sal_Int32 nIdx {0}; + for(;;) + { + const sal_Int32 n {sFixedWidthLists.getToken(0, ';', nIdx).toInt32()}; + if (nIdx<0) + { + // String ends with a semi-colon so there + // is no useful 'int' after the last one. + // This also works in case of empty string + break; + } + rSplits.Insert(n); + } } } static void save_FixedWidthList(const ScCsvSplits& rSplits) commit 42e961972a56a6508c9a38c2b80a996ee2e679e1 Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Sep 2 14:31:49 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:55 2018 +0200 Avoid temporary variable Change-Id: I0febc7c1b270a46460cf7a67ec269458974f70c5 diff --git a/sc/source/ui/dbgui/asciiopt.cxx b/sc/source/ui/dbgui/asciiopt.cxx index e580334f27c6..40f62a357e63 100644 --- a/sc/source/ui/dbgui/asciiopt.cxx +++ b/sc/source/ui/dbgui/asciiopt.cxx @@ -120,8 +120,7 @@ void ScAsciiOptions::ReadFromString( const OUString& rString ) if ( nPos >= 0 ) { const OUString aToken = rString.getToken(0, ',', nPos); - sal_Int32 nSub = comphelper::string::getTokenCount(aToken, '/'); - sal_Int32 nInfoCount = nSub / 2; + const sal_Int32 nInfoCount = comphelper::string::getTokenCount(aToken, '/')/2; mvColStart.resize(nInfoCount); mvColFormat.resize(nInfoCount); sal_Int32 nP = 0; commit 6d76610978733bf0add633670cb33504d6720122 Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sat Aug 25 20:57:28 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:55 2018 +0200 Use optimized OUString concatenation and avoid temporary Change-Id: I25cae27d9822a323167a8b202acc2bde660abc58 diff --git a/sc/source/ui/pagedlg/areasdlg.cxx b/sc/source/ui/pagedlg/areasdlg.cxx index 02815f104654..4025adcb0236 100644 --- a/sc/source/ui/pagedlg/areasdlg.cxx +++ b/sc/source/ui/pagedlg/areasdlg.cxx @@ -282,7 +282,6 @@ void ScPrintAreasDlg::Impl_Reset() // printing area aStrRange.clear(); - OUString aOne; const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention(); const sal_Unicode sep = ScCompiler::GetNativeSymbolChar(ocSep); sal_uInt16 nRangeCount = pDoc->GetPrintRangeCount( nCurTab ); @@ -293,8 +292,7 @@ void ScPrintAreasDlg::Impl_Reset() { if ( !aStrRange.isEmpty() ) aStrRange += OUStringLiteral1(sep); - aOne = pPrintRange->Format(ScRefFlags::RANGE_ABS, pDoc, eConv); - aStrRange += aOne; + aStrRange += pPrintRange->Format(ScRefFlags::RANGE_ABS, pDoc, eConv); } } pEdPrintArea->SetText( aStrRange ); commit 2d94bfbabf1948317ad85f9fa3be7d2fcb895a30 Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sat Aug 25 20:56:47 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:54 2018 +0200 Use optimized OUString concatenation Change-Id: I95e1a00caf2ef82f2931cc3a2709cbb3c6cc3d26 diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx index 9514e3b3f6ef..ce54a91532d9 100644 --- a/sc/source/ui/docshell/docsh8.cxx +++ b/sc/source/ui/docshell/docsh8.cxx @@ -119,8 +119,7 @@ namespace // get connection - OUString aConnUrl("sdbc:dbase:"); - aConnUrl += aPath; + const OUString aConnUrl{"sdbc:dbase:" + aPath}; // sdbc:dbase is based on the css.sdbc.FILEConnectionProperties UNOIDL service, so we can // transport the raw rtl_TextEncoding value instead of having to translate it into a IANA commit ecdca13805a2a7ded0f08208337509030d160c2c Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sat Aug 25 20:55:53 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:54 2018 +0200 Bail out early Change-Id: Ie5b34bfbfd45aaafbf0a64ee72f741066d1632e1 diff --git a/sc/source/filter/html/htmlimp.cxx b/sc/source/filter/html/htmlimp.cxx index ba4fc94344b7..e75f8421c9ad 100644 --- a/sc/source/filter/html/htmlimp.cxx +++ b/sc/source/filter/html/htmlimp.cxx @@ -214,22 +214,18 @@ OUString ScHTMLImport::GetHTMLRangeNameList( const ScDocument* pDoc, const OUStr if( pRangeNames && ScfTools::IsHTMLTablesName( aToken ) ) { // build list with all HTML tables sal_uLong nIndex = 1; - bool bLoop = true; - while( bLoop ) + for(;;) { aToken = ScfTools::GetNameFromHTMLIndex( nIndex++ ); const ScRangeData* pRangeData = pRangeNames->findByUpperName(ScGlobal::pCharClass->uppercase(aToken)); - if (pRangeData) + if (!pRangeData) + break; + ScRange aRange; + if( pRangeData->IsReference( aRange ) && !aRangeList.In( aRange ) ) { - ScRange aRange; - if( pRangeData->IsReference( aRange ) && !aRangeList.In( aRange ) ) - { - aNewName = ScGlobal::addToken(aNewName, aToken, ';'); - aRangeList.push_back( aRange ); - } + aNewName = ScGlobal::addToken(aNewName, aToken, ';'); + aRangeList.push_back( aRange ); } - else - bLoop = false; } } else commit c08c3807fe1a2c4a08b542125ee9f40f0f7f07fe Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sat Aug 25 20:52:48 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:54 2018 +0200 Reduce scope Change-Id: Id4f6e3dd2e9acdc8586e59a26b2d4ac6b13980dd diff --git a/sc/source/filter/excel/xlformula.cxx b/sc/source/filter/excel/xlformula.cxx index e5b5bc3061c3..4d1774d9aed7 100644 --- a/sc/source/filter/excel/xlformula.cxx +++ b/sc/source/filter/excel/xlformula.cxx @@ -873,7 +873,6 @@ bool XclTokenArrayHelper::GetString( OUString& rString, const ScTokenArray& rScT bool XclTokenArrayHelper::GetStringList( OUString& rStringList, const ScTokenArray& rScTokArr, sal_Unicode cSep ) { bool bRet = true; - OUString aString; XclTokenArrayIterator aIt( rScTokArr, true ); enum { STATE_START, STATE_STR, STATE_SEP, STATE_END } eState = STATE_START; while( eState != STATE_END ) switch( eState ) @@ -882,10 +881,13 @@ bool XclTokenArrayHelper::GetStringList( OUString& rStringList, const ScTokenArr eState = aIt.Is() ? STATE_STR : STATE_END; break; case STATE_STR: + { + OUString aString; bRet = GetTokenString( aString, *aIt ); if( bRet ) rStringList += aString ; eState = (bRet && (++aIt).Is()) ? STATE_SEP : STATE_END; - break; + break; + } case STATE_SEP: bRet = aIt->GetOpCode() == ocSep; if( bRet ) rStringList += OUStringLiteral1(cSep); commit d2fdf0610792f187f313e7ec64fa8049b814cb27 Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Aug 12 23:07:44 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:53 2018 +0200 Avoid getTokenCount and use indexed getToken Change-Id: Iaac598c9e56afa29db88237fecbe54d9cb4d4011 diff --git a/extensions/source/propctrlr/standardcontrol.cxx b/extensions/source/propctrlr/standardcontrol.cxx index f6bd2718c35e..40e283108339 100644 --- a/extensions/source/propctrlr/standardcontrol.cxx +++ b/extensions/source/propctrlr/standardcontrol.cxx @@ -1055,9 +1055,17 @@ namespace pcr { sal_Int32 nLines = comphelper::string::getTokenCount(_rCompsedTextWithLineBreaks, '\n'); StlSyntaxSequence< OUString > aStrings( nLines ); - StlSyntaxSequence< OUString >::iterator stringItem = aStrings.begin(); - for ( sal_Int32 token = 0; token < nLines; ++token, ++stringItem ) - *stringItem = _rCompsedTextWithLineBreaks.getToken( token, '\n' ); + if (nLines) + { + StlSyntaxSequence< OUString >::iterator stringItem = aStrings.begin(); + sal_Int32 nIdx {0}; + do + { + *stringItem = _rCompsedTextWithLineBreaks.getToken( 0, '\n', nIdx ); + ++stringItem; + } + while (nIdx>0); + } return aStrings; } @@ -1150,9 +1158,9 @@ namespace pcr if (!aStr.isEmpty()) { long nDiff=0; - sal_Int32 nCount = comphelper::string::getTokenCount(aStr, '\n'); - OUString aInput = aStr.getToken(0,'\n' ); + sal_Int32 nIdx {0}; + OUString aInput = aStr.getToken(0, '\n', nIdx ); if (!aInput.isEmpty()) { @@ -1168,9 +1176,9 @@ namespace pcr } else { - for (sal_Int32 i=1; i<nCount; ++i) + while (nIdx>0) { - aInput=aStr.getToken(static_cast<sal_uInt16>(i), '\n'); + aInput=aStr.getToken(0, '\n', nIdx); if (!aInput.isEmpty()) { aOutput += ";"; commit 088cb5c33fc78606e1db9fef6d33f77e63bf7b24 Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Aug 12 23:06:10 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:53 2018 +0200 Avoid getTokenCount Change-Id: I60d11dab9bc04462cf3cc0412a356ec51212fb6e diff --git a/oox/source/ole/axcontrol.cxx b/oox/source/ole/axcontrol.cxx index 3525e4f4d9a7..2eab7a0fa861 100644 --- a/oox/source/ole/axcontrol.cxx +++ b/oox/source/ole/axcontrol.cxx @@ -47,7 +47,6 @@ #include <com/sun/star/style/VerticalAlignment.hpp> #include <com/sun/star/table/CellAddress.hpp> #include <com/sun/star/table/CellRangeAddress.hpp> -#include <comphelper/string.hxx> #include <rtl/tencinfo.h> #include <osl/diagnose.h> #include <sal/log.hxx> @@ -2550,30 +2549,32 @@ HtmlSelectModel::HtmlSelectModel() bool HtmlSelectModel::importBinaryModel( BinaryInputStream& rInStrm ) { - OUString sStringContents = rInStrm.readUnicodeArray( rInStrm.size() ); + if (rInStrm.size()<=0) + return true; - OUString data = sStringContents; + OUString sStringContents = rInStrm.readUnicodeArray( rInStrm.size() ); // replace crlf with lf - data = data.replaceAll( "\x0D\x0A" , "\x0A" ); + OUString data = sStringContents.replaceAll( "\x0D\x0A" , "\x0A" ); + std::vector< OUString > listValues; std::vector< sal_Int16 > selectedIndices; // Ultra hacky parser for the info - sal_Int32 nTokenCount = comphelper::string::getTokenCount(data, '\n'); - - for ( sal_Int32 nToken = 0; nToken < nTokenCount; ++nToken ) + sal_Int32 nLineIdx {0}; + // first line will tell us if multiselect is enabled + if (data.getToken( 0, '\n', nLineIdx )=="<SELECT MULTIPLE") + mnMultiSelect = AX_SELECTION_MULTI; + // skip first and last lines, no data there + if (nLineIdx>0) { - OUString sLine( data.getToken( nToken, '\n' ) ); - if ( !nToken ) // first line will tell us if multiselect is enabled - { - if ( sLine == "<SELECT MULTIPLE" ) - mnMultiSelect = AX_SELECTION_MULTI; - } - // skip first and last lines, no data there - else if ( nToken < nTokenCount - 1) + for (;;) { - if ( comphelper::string::getTokenCount(sLine, '>') ) + OUString sLine( data.getToken( 0, '\n', nLineIdx ) ); + if (nLineIdx<0) + break; // skip last line + + if ( !sLine.isEmpty() ) { OUString displayValue = sLine.getToken( 1, '>' ); if ( displayValue.getLength() ) commit 8a5d742accb7ec316bfc66743d9c3cba0fa9a9b4 Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Aug 12 23:01:03 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:52 2018 +0200 Avoid getTokenCount and use indexed getToken Change-Id: If4aec143168febe9a0f48831752a4114bdea0cbd diff --git a/sc/source/core/data/globalx.cxx b/sc/source/core/data/globalx.cxx index cdd7acac3a71..a4a328313174 100644 --- a/sc/source/core/data/globalx.cxx +++ b/sc/source/core/data/globalx.cxx @@ -33,7 +33,6 @@ #include <com/sun/star/i18n/OrdinalSuffix.hpp> #include <comphelper/processfactory.hxx> -#include <comphelper/string.hxx> #include <unotools/configmgr.hxx> #include <unotools/localedatawrapper.hxx> @@ -52,10 +51,10 @@ void ScGlobal::InitAddIns() if (aMultiPath.isEmpty()) return; - sal_Int32 nTokens = comphelper::string::getTokenCount(aMultiPath, ';'); - for (sal_Int32 j = 0; j < nTokens; ++j) + sal_Int32 nIdx {0}; + do { - OUString aPath = aMultiPath.getToken(j, ';'); + OUString aPath = aMultiPath.getToken(0, ';', nIdx); if (aPath.isEmpty()) continue; @@ -114,6 +113,7 @@ void ScGlobal::InitAddIns() OSL_FAIL( "unexpected exception caught!" ); } } + while (nIdx>0); } OUString ScGlobal::GetOrdinalSuffix( sal_Int32 nNumber) commit 416bedb92a3e4f57f3da243e8befd42e1be101a1 Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Aug 12 22:43:40 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:52 2018 +0200 Avoid getTokenCount Change-Id: If9720800a5118d29b1d5d57aa06c21dd4db5b511 diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index e86e2d756e78..64622c674301 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -3942,13 +3942,13 @@ void ScCompiler::AutoCorrectParsedSymbol() else if ( (GetCharTableFlags( c1, 0 ) & ScCharFlags::CharValue) && (GetCharTableFlags( c2, c2p ) & ScCharFlags::CharValue) ) { - if ( comphelper::string::getTokenCount(aCorrectedSymbol, cx) > 1 ) + if ( aCorrectedSymbol.indexOf(cx) >= 0 ) // At least two tokens separated by cx { // x => * sal_Unicode c = mxSymbols->getSymbolChar(ocMul); aCorrectedSymbol = aCorrectedSymbol.replaceAll(OUStringLiteral1(cx), OUStringLiteral1(c)); bCorrected = true; } - if ( comphelper::string::getTokenCount(aCorrectedSymbol, cX) > 1 ) + if ( aCorrectedSymbol.indexOf(cX) >= 0 ) // At least two tokens separated by cX { // X => * sal_Unicode c = mxSymbols->getSymbolChar(ocMul); aCorrectedSymbol = aCorrectedSymbol.replaceAll(OUStringLiteral1(cX), OUStringLiteral1(c)); commit e2821c569e720ecf85e3773b9e411f8297301827 Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Aug 12 22:40:33 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:51 2018 +0200 Avoid getTokenCount Change-Id: If4609be33625fd1a9955d393c5c999aef75624ec diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx index 20217b48ef4e..9e97d3bbb2fc 100644 --- a/sc/source/filter/excel/xecontent.cxx +++ b/sc/source/filter/excel/xecontent.cxx @@ -25,7 +25,6 @@ #include <com/sun/star/sheet/XAreaLinks.hpp> #include <com/sun/star/sheet/XAreaLink.hpp> #include <com/sun/star/sheet/TableValidationVisibility.hpp> -#include <comphelper/string.hxx> #include <sfx2/objsh.hxx> #include <tools/urlobj.hxx> #include <svl/itemset.hxx> @@ -1739,18 +1738,19 @@ XclExpDV::XclExpDV( const XclExpRoot& rRoot, sal_uLong nScHandle ) : Data validity is BIFF8 only (important for the XclExpString object). Excel uses the NUL character as string list separator. */ mxString1.reset( new XclExpString( XclStrFlags::EightBitLength ) ); - sal_Int32 nTokenCnt = comphelper::string::getTokenCount(aString, '\n'); - sal_Int32 nStringIx = 0; - for( sal_Int32 nToken = 0; nToken < nTokenCnt; ++nToken ) + if (!aString.isEmpty()) { - OUString aToken( aString.getToken( 0, '\n', nStringIx ) ); - if( nToken > 0 ) + sal_Int32 nStringIx = 0; + for(;;) { + const OUString aToken( aString.getToken( 0, '\n', nStringIx ) ); + mxString1->Append( aToken ); + sFormulaBuf.append( aToken ); + if (nStringIx<0) + break; mxString1->Append(OUString(u'\0')); sFormulaBuf.append( ',' ); } - mxString1->Append( aToken ); - sFormulaBuf.append( aToken ); } ::set_flag( mnFlags, EXC_DV_STRINGLIST ); @@ -1992,18 +1992,21 @@ XclExpWebQuery::XclExpWebQuery( mbEntireDoc( false ) { // comma separated list of HTML table names or indexes - sal_Int32 nTokenCnt = comphelper::string::getTokenCount(rSource, ';'); OUString aNewTables; OUString aAppendTable; - sal_Int32 nStringIx = 0; bool bExitLoop = false; - for( sal_Int32 nToken = 0; (nToken < nTokenCnt) && !bExitLoop; ++nToken ) + if (!rSource.isEmpty()) { - OUString aToken( rSource.getToken( 0, ';', nStringIx ) ); - mbEntireDoc = ScfTools::IsHTMLDocName( aToken ); - bExitLoop = mbEntireDoc || ScfTools::IsHTMLTablesName( aToken ); - if( !bExitLoop && ScfTools::GetHTMLNameFromName( aToken, aAppendTable ) ) - aNewTables = ScGlobal::addToken( aNewTables, aAppendTable, ',' ); + sal_Int32 nStringIx = 0; + do + { + OUString aToken( rSource.getToken( 0, ';', nStringIx ) ); + mbEntireDoc = ScfTools::IsHTMLDocName( aToken ); + bExitLoop = mbEntireDoc || ScfTools::IsHTMLTablesName( aToken ); + if( !bExitLoop && ScfTools::GetHTMLNameFromName( aToken, aAppendTable ) ) + aNewTables = ScGlobal::addToken( aNewTables, aAppendTable, ',' ); + } + while (nStringIx>0 && !bExitLoop); } if( !bExitLoop ) // neither HTML_all nor HTML_tables found commit 42a4937c8b5e4ff97416966da827d94b8a115bb0 Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Aug 12 22:17:23 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:51 2018 +0200 Avoid getTokenCount Change-Id: I3aeef1208a579dd65eabeaadda3e7250cf333177 diff --git a/sc/source/filter/excel/xlformula.cxx b/sc/source/filter/excel/xlformula.cxx index a4a4e320b4e5..e5b5bc3061c3 100644 --- a/sc/source/filter/excel/xlformula.cxx +++ b/sc/source/filter/excel/xlformula.cxx @@ -903,15 +903,16 @@ void XclTokenArrayHelper::ConvertStringToList( if( GetString( aString, rScTokArr ) ) { rScTokArr.Clear(); - sal_Int32 nTokenCnt = comphelper::string::getTokenCount(aString, cStringSep); + if (aString.isEmpty()) + return; sal_Int32 nStringIx = 0; - for( sal_Int32 nToken = 0; nToken < nTokenCnt; ++nToken ) + for (;;) { OUString aToken( aString.getToken( 0, cStringSep, nStringIx ) ); - aToken = comphelper::string::stripStart(aToken, ' '); // trim leading spaces - if( nToken > 0 ) - rScTokArr.AddOpCode( ocSep ); - rScTokArr.AddString(rSPool.intern(aToken)); + rScTokArr.AddString(rSPool.intern(comphelper::string::stripStart(aToken, ' '))); + if (nStringIx<0) + break; + rScTokArr.AddOpCode( ocSep ); } } } commit cfabcee0a7765534b419451ec812838ac6a2a50d Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Aug 12 22:14:26 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:51 2018 +0200 Avoid getTokenCount Change-Id: I261311443edcf943d6f2849acc3042089080dee6 diff --git a/sc/source/filter/html/htmlimp.cxx b/sc/source/filter/html/htmlimp.cxx index 4957b2d381ad..ba4fc94344b7 100644 --- a/sc/source/filter/html/htmlimp.cxx +++ b/sc/source/filter/html/htmlimp.cxx @@ -201,12 +201,14 @@ OUString ScHTMLImport::GetHTMLRangeNameList( const ScDocument* pDoc, const OUStr { OSL_ENSURE( pDoc, "ScHTMLImport::GetHTMLRangeNameList - missing document" ); + if (rOrigName.isEmpty()) + return OUString(); + OUString aNewName; ScRangeName* pRangeNames = pDoc->GetRangeName(); ScRangeList aRangeList; - sal_Int32 nTokenCnt = comphelper::string::getTokenCount(rOrigName, ';'); sal_Int32 nStringIx = 0; - for( sal_Int32 nToken = 0; nToken < nTokenCnt; nToken++ ) + do { OUString aToken( rOrigName.getToken( 0, ';', nStringIx ) ); if( pRangeNames && ScfTools::IsHTMLTablesName( aToken ) ) @@ -233,6 +235,7 @@ OUString ScHTMLImport::GetHTMLRangeNameList( const ScDocument* pDoc, const OUStr else aNewName = ScGlobal::addToken(aNewName, aToken, ';'); } + while (nStringIx>0); return aNewName; } commit a9bcbd3dad16c69f1e7ebb52a30611150a49f298 Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Aug 12 22:13:15 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:50 2018 +0200 Avoid getTokenCount and use indexed getToken Change-Id: I1a52508c782c980d369a74f70fc8db5cbe1a0296 diff --git a/sc/source/ui/dbgui/validate.cxx b/sc/source/ui/dbgui/validate.cxx index 688ebe5b7043..78d2c154c319 100644 --- a/sc/source/ui/dbgui/validate.cxx +++ b/sc/source/ui/dbgui/validate.cxx @@ -277,12 +277,16 @@ ScConditionMode lclGetCondModeFromPos( sal_uInt16 nLbPos ) void lclGetFormulaFromStringList( OUString& rFmlaStr, const OUString& rStringList, sal_Unicode cFmlaSep ) { rFmlaStr.clear(); - sal_Int32 nTokenCnt = comphelper::string::getTokenCount(rStringList, '\n'); - for( sal_Int32 nToken = 0, nStringIx = 0; nToken < nTokenCnt; ++nToken ) + if (!rStringList.isEmpty()) { - OUString aToken( rStringList.getToken( 0, '\n', nStringIx ) ); - ScGlobal::AddQuotes( aToken, '"' ); - rFmlaStr = ScGlobal::addToken(rFmlaStr, aToken, cFmlaSep); + sal_Int32 nIdx {0}; + do + { + OUString aToken {rStringList.getToken( 0, '\n', nIdx )}; + ScGlobal::AddQuotes( aToken, '"' ); + rFmlaStr = ScGlobal::addToken(rFmlaStr, aToken, cFmlaSep); + } + while (nIdx>0); } if( rFmlaStr.isEmpty() ) rFmlaStr = "\"\""; commit c8796e9f1fe5a77953dd5089581b2e8569533de9 Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Aug 12 22:10:25 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:50 2018 +0200 Avoid getTokenCount and use indexed getToken Change-Id: I1cea711e1e22edfab8f90c30554135727b97a276 diff --git a/sc/source/ui/docshell/arealink.cxx b/sc/source/ui/docshell/arealink.cxx index c23c9308429a..d0797a453873 100644 --- a/sc/source/ui/docshell/arealink.cxx +++ b/sc/source/ui/docshell/arealink.cxx @@ -17,7 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <comphelper/string.hxx> #include <sfx2/app.hxx> #include <sfx2/docfile.hxx> #include <sfx2/fcontnr.hxx> @@ -286,20 +285,22 @@ bool ScAreaLink::Refresh( const OUString& rNewFile, const OUString& rNewFilter, } } - sal_Int32 nTokenCnt = comphelper::string::getTokenCount(aTempArea, ';'); - sal_Int32 nStringIx = 0; - for (sal_Int32 nToken = 0; nToken < nTokenCnt; ++nToken) + if (!aTempArea.isEmpty()) { - OUString aToken( aTempArea.getToken( 0, ';', nStringIx ) ); - ScRange aTokenRange; - if( FindExtRange( aTokenRange, &rSrcDoc, aToken ) ) + sal_Int32 nIdx {0}; + do { - aSourceRanges.push_back( aTokenRange); - // columns: find maximum - nWidth = std::max( nWidth, static_cast<SCCOL>(aTokenRange.aEnd.Col() - aTokenRange.aStart.Col() + 1) ); - // rows: add row range + 1 empty row - nHeight += aTokenRange.aEnd.Row() - aTokenRange.aStart.Row() + 2; + ScRange aTokenRange; + if( FindExtRange( aTokenRange, &rSrcDoc, aTempArea.getToken( 0, ';', nIdx ) ) ) + { + aSourceRanges.push_back( aTokenRange); + // columns: find maximum + nWidth = std::max( nWidth, static_cast<SCCOL>(aTokenRange.aEnd.Col() - aTokenRange.aStart.Col() + 1) ); + // rows: add row range + 1 empty row + nHeight += aTokenRange.aEnd.Row() - aTokenRange.aStart.Row() + 2; + } } + while (nIdx>0); } // remove the last empty row if( nHeight > 0 ) commit 0a2be735c37dd7d5c7ecf2aeb8f8fa2b689dba45 Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Aug 12 22:07:09 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:49 2018 +0200 Avoid getTokenCount and use indexed getToken Change-Id: I14c22a3f04bd9ee31d7261f48ed64bad2477f8fd diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx index 062c327ab9ee..9514e3b3f6ef 100644 --- a/sc/source/ui/docshell/docsh8.cxx +++ b/sc/source/ui/docshell/docsh8.cxx @@ -24,7 +24,6 @@ #include <svl/converter.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/propertysequence.hxx> -#include <comphelper/string.hxx> #include <comphelper/types.hxx> #include <ucbhelper/content.hxx> #include <svx/txenctab.hxx> @@ -470,20 +469,18 @@ void lcl_GetColumnTypes( sal_Int32 nPrecision = 0; sal_Int32 nDbType = sdbc::DataType::SQLNULL; OUString aFieldName; - OUString aString; // Fieldname[,Type[,Width[,Prec]]] // Type etc.: L; D; C[,W]; N[,W[,P]] if ( bHasFieldNames ) { - aString = rDoc.GetString(nCol, nFirstRow, nTab); - aString = aString.toAsciiUpperCase(); - sal_Int32 nToken = comphelper::string::getTokenCount(aString, ','); - if ( nToken > 1 ) + OUString aString {rDoc.GetString(nCol, nFirstRow, nTab).toAsciiUpperCase()}; + sal_Int32 nIdx {0}; + aFieldName = aString.getToken( 0, ',', nIdx); + if ( nIdx>0 ) { - aFieldName = aString.getToken( 0, ',' ); aString = aString.replaceAll(" ", ""); - switch ( aString.getToken( 1, ',' )[0] ) + switch ( aString.getToken( 0, ',', nIdx )[0] ) { case 'L' : nDbType = sdbc::DataType::BIT; @@ -514,12 +511,12 @@ void lcl_GetColumnTypes( bTypeDefined = true; break; } - if ( bTypeDefined && !nFieldLen && nToken > 2 ) + if ( bTypeDefined && !nFieldLen && nIdx>0 ) { - nFieldLen = aString.getToken( 2, ',' ).toInt32(); - if ( !bPrecDefined && nToken > 3 ) + nFieldLen = aString.getToken( 0, ',', nIdx ).toInt32(); + if ( !bPrecDefined && nIdx>0 ) { - OUString aTmp( aString.getToken( 3, ',' ) ); + OUString aTmp( aString.getToken( 0, ',', nIdx ) ); if ( CharClass::isAsciiNumeric(aTmp) ) { nPrecision = aTmp.toInt32(); @@ -530,8 +527,6 @@ void lcl_GetColumnTypes( } } } - else - aFieldName = aString; // Check field name and generate valid field name if necessary. // First character has to be alphabetical, subsequent characters commit 7224b69bd52bc3544e2b4d36ccf36965d3c3c45e Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Aug 12 21:59:56 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:49 2018 +0200 Early bailout Change-Id: I34cb0f151b35fe775008d449bf7efb72ae81f29d diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx index cc98f3d8d11e..6de58331021f 100644 --- a/sc/source/ui/miscdlgs/anyrefdg.cxx +++ b/sc/source/ui/miscdlgs/anyrefdg.cxx @@ -875,13 +875,15 @@ void ScRefHandler::SwitchToDocument() bool ScRefHandler::IsDocAllowed(SfxObjectShell* pDocSh) const // pDocSh may be 0 { - // default: allow only same document (overridden in function dialog) - OUString aCmpName; - if ( pDocSh ) - aCmpName = pDocSh->GetTitle(); - // if aDocName isn't initialized, allow - return ( m_aDocName.isEmpty() || m_aDocName == aCmpName ); + if ( m_aDocName.isEmpty() ) + return true; + + if ( !pDocSh ) + return false; + + // default: allow only same document (overridden in function dialog) + return m_aDocName==pDocSh->GetTitle(); } bool ScRefHandler::IsRefInputMode() const commit e3f3ce96d000c86d8f79d64ef99f07b2a60aa7ee Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Aug 12 20:43:11 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:49 2018 +0200 OUString: use optimized concatenation, make const Change-Id: I8b4f6d47852c2a42c55723c3a0757f2c144f6ef2 diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx index 9825eeb4bab8..cc98f3d8d11e 100644 --- a/sc/source/ui/miscdlgs/anyrefdg.cxx +++ b/sc/source/ui/miscdlgs/anyrefdg.cxx @@ -483,12 +483,10 @@ void ScFormulaReferenceHelper::RefInputStart( formula::RefEdit* pEdit, formula:: m_sOldDialogText = m_pWindow->GetText(); if (vcl::Window *pLabel = m_pRefEdit->GetLabelWidgetForShrinkMode()) { - OUString sLabel = pLabel->GetText(); + const OUString sLabel = pLabel->GetText(); if (!sLabel.isEmpty()) { - OUString sNewDialogText = m_sOldDialogText; - sNewDialogText += ": "; - sNewDialogText += comphelper::string::stripEnd(sLabel, ':'); + const OUString sNewDialogText = m_sOldDialogText + ": " + comphelper::string::stripEnd(sLabel, ':'); m_pWindow->SetText( MnemonicGenerator::EraseAllMnemonicChars( sNewDialogText ) ); } } commit 0e68209fe3e6dec0d6f5ecf919ceecd91d962129 Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Aug 12 19:10:14 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:48 2018 +0200 Avoid getTokenCount and use indexed getToken Change-Id: Ib459f491927518266288aaf2d982279dd47ebd39 diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx index 4ff02b2c1754..9825eeb4bab8 100644 --- a/sc/source/ui/miscdlgs/anyrefdg.cxx +++ b/sc/source/ui/miscdlgs/anyrefdg.cxx @@ -154,16 +154,20 @@ void ScFormulaReferenceHelper::ShowSimpleReference(const OUString& rStr) bool ScFormulaReferenceHelper::ParseWithNames( ScRangeList& rRanges, const OUString& rStr, const ScDocument* pDoc ) { - bool bError = false; rRanges.RemoveAll(); + if (rStr.isEmpty()) + return true; + ScAddress::Details aDetails(pDoc->GetAddressConvention(), 0, 0); ScRangeUtil aRangeUtil; - sal_Int32 nTokenCnt = comphelper::string::getTokenCount(rStr, ';'); - for( sal_Int32 nToken = 0; nToken < nTokenCnt; ++nToken ) + + bool bError = false; + sal_Int32 nIdx {0}; + do { ScRange aRange; - OUString aRangeStr( rStr.getToken( nToken, ';' ) ); + OUString aRangeStr( rStr.getToken( 0, ';', nIdx ) ); ScRefFlags nFlags = aRange.ParseAny( aRangeStr, pDoc, aDetails ); if ( nFlags & ScRefFlags::VALID ) @@ -179,6 +183,7 @@ bool ScFormulaReferenceHelper::ParseWithNames( ScRangeList& rRanges, const OUStr else bError = true; } + while (nIdx>0); return !bError; } commit 68b3eb1372aa9728673d3c334880d70a75e42b21 Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Aug 12 18:56:56 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:48 2018 +0200 Avoid getTokenCount and use indexed getToken Change-Id: Icd6253b09aacfdf63696f4292e1ac4ed8be8242c diff --git a/sc/source/ui/miscdlgs/linkarea.cxx b/sc/source/ui/miscdlgs/linkarea.cxx index e8eb369d39bc..d0909c63f34b 100644 --- a/sc/source/ui/miscdlgs/linkarea.cxx +++ b/sc/source/ui/miscdlgs/linkarea.cxx @@ -19,7 +19,6 @@ #undef SC_DLLIMPLEMENTATION -#include <comphelper/string.hxx> #include <sfx2/app.hxx> #include <sfx2/docfile.hxx> #include <sfx2/docfilt.hxx> @@ -149,11 +148,14 @@ void ScLinkedAreaDlg::InitFromOldLink( const OUString& rFile, const OUString& rF UpdateSourceRanges(); - sal_Int32 nRangeCount = comphelper::string::getTokenCount(rSource, ';'); - for ( sal_Int32 i=0; i<nRangeCount; i++ ) + if (!rSource.isEmpty()) { - OUString aRange = rSource.getToken(i,';'); - m_xLbRanges->select_text(aRange); + sal_Int32 nIdx {0}; + do + { + m_xLbRanges->select_text(rSource.getToken(0, ';', nIdx)); + } + while (nIdx>0); } bool bDoRefresh = (nRefresh != 0); commit 78c25a457bf62d38c31021f6fe6446dc16ecdb61 Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Aug 12 18:55:38 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:47 2018 +0200 Avoid getTokenCount and use indexed getToken Change-Id: I84141b9863225346d2bedfb702468f37bbeb9f64 diff --git a/sc/source/ui/optdlg/tpusrlst.cxx b/sc/source/ui/optdlg/tpusrlst.cxx index bc5b96ef428f..89a578dfed16 100644 --- a/sc/source/ui/optdlg/tpusrlst.cxx +++ b/sc/source/ui/optdlg/tpusrlst.cxx @@ -296,14 +296,14 @@ void ScTpUserLists::UpdateEntries( size_t nList ) void ScTpUserLists::MakeListStr( OUString& rListStr ) { - OUStringBuffer aStr; + if (rListStr.isEmpty()) + return; - sal_Int32 nToken = comphelper::string::getTokenCount(rListStr, LF); + OUStringBuffer aStr; - for(sal_Int32 i=0; i<nToken; i++) + for(sal_Int32 nIdx=0; nIdx>=0;) { - OUString aString = comphelper::string::strip(rListStr.getToken(i, LF), ' '); - aStr.append(aString); + aStr.append(comphelper::string::strip(rListStr.getToken(0, LF, nIdx), ' ')); aStr.append(cDelimiter); } commit e37992d8c00db08b2dbc64c1fccb0b12aa4d6e9f Author: Matteo Casalin <matteo.casa...@yahoo.com> AuthorDate: Sun Aug 12 18:53:09 2018 +0200 Commit: Matteo Casalin <matteo.casa...@yahoo.com> CommitDate: Sun Sep 9 21:07:47 2018 +0200 Avoid getTokenCount and use indexed getToken Change-Id: I2ad3e6bf35f53e83ccc570f8660a090e340ffa59 diff --git a/sc/source/ui/pagedlg/areasdlg.cxx b/sc/source/ui/pagedlg/areasdlg.cxx index 276303375b08..02815f104654 100644 --- a/sc/source/ui/pagedlg/areasdlg.cxx +++ b/sc/source/ui/pagedlg/areasdlg.cxx @@ -19,7 +19,6 @@ #include <rangelst.hxx> -#include <comphelper/string.hxx> #include <sfx2/dispatch.hxx> #include <svl/stritem.hxx> #include <vcl/weld.hxx> @@ -356,16 +355,18 @@ bool ScPrintAreasDlg::Impl_CheckRefStrings() ScAddress aAddr; ScRange aRange; - sal_Int32 nSepCount = comphelper::string::getTokenCount(aStrPrintArea, sep); - for ( sal_Int32 i = 0; i < nSepCount && bPrintAreaOk; ++i ) + for ( sal_Int32 nIdx = 0; nIdx >= 0; ) { - OUString aOne = aStrPrintArea.getToken(i, sep); + const OUString aOne = aStrPrintArea.getToken(0, sep, nIdx); ScRefFlags nResult = aRange.Parse( aOne, pDoc, eConv ); if ((nResult & nValidRange) != nValidRange) { ScRefFlags nAddrResult = aAddr.Parse( aOne, pDoc, eConv ); if ((nAddrResult & nValidAddr) != nValidAddr) + { bPrintAreaOk = false; + break; + } } } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits