connectivity/source/drivers/dbase/DIndexIter.cxx | 14 +++++----- connectivity/source/drivers/dbase/DResultSet.cxx | 4 +-- editeng/source/editeng/textconv.cxx | 30 +++++++++++------------ sc/inc/compiler.hxx | 4 +-- sc/inc/global.hxx | 4 +-- sc/source/core/data/global.cxx | 9 +++--- sc/source/core/tool/address.cxx | 16 ++++++------ sc/source/core/tool/compiler.cxx | 24 +++++++++--------- sc/source/core/tool/interpr1.cxx | 2 - sc/source/ui/app/inputhdl.cxx | 20 +++++++-------- 10 files changed, 64 insertions(+), 63 deletions(-)
New commits: commit a18a92b1b0c4ff591bd83f190f11c196ed676e86 Author: Noel Grandin <[email protected]> Date: Fri Nov 8 14:49:47 2013 +0200 convert STRING_NOTFOUND in sc module ScGlobal::FindUnquoted - return -1 instead of STRING_NOTFOUND - change return type from xub_StrLen to sal_Int32 - remove last two parameters because noone was using them ScCompiler::GetDocTabPos - return -1 instead of STRING_NOTFOUND - change return type from xub_StrLen to sal_Int32 inputhdl.cxx/lcl_MatchParenthesis - return -1 instead of STRING_NOTFOUND - change return type from xub_StrLen to sal_Int32 - make function static, no-one outside this module is using it Change-Id: I141ab082db180ff2da5a7ca6813cd3607b9ea7f7 diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx index 0cd47c5..3b366c0 100644 --- a/sc/inc/compiler.hxx +++ b/sc/inc/compiler.hxx @@ -379,8 +379,8 @@ public: /** Analyzes a string for a 'Doc'#Tab construct, or 'Do''c'#Tab etc.. @returns the position of the unquoted # hash mark in 'Doc'#Tab, or - STRING_NOTFOUND if none. */ - static xub_StrLen GetDocTabPos( const OUString& rString ); + -1 if none. */ + static sal_Int32 GetDocTabPos( const OUString& rString ); static bool EnQuote( OUString& rStr ); sal_Unicode GetNativeAddressSymbol( Convention::SpecialSymbolType eType ) const; diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index 79ab13d..9babb88 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -650,9 +650,9 @@ SC_DLLPUBLIC static void EraseQuotes( OUString& rString, sal_Unic quotes have to be escaped by being doubled. Caller must ensure that nStart points into an unquoted range or the opening quote. Specialty: if cChar==cQuote the first cQuote character from nStart on is found. - @returns offset if found, else STRING_NOTFOUND + @returns offset if found, else -1 */ -SC_DLLPUBLIC static xub_StrLen FindUnquoted( const OUString& rString, sal_Unicode cChar, xub_StrLen nStart = 0, sal_Unicode cQuote = '\'' ); +SC_DLLPUBLIC static sal_Int32 FindUnquoted( const OUString& rString, sal_Unicode cChar); /** Finds an unquoted instance of cChar in null-terminated pString. Same semantics as FindUnquoted( const String&, ...) diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx index 534adf9..05ac79c 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -840,16 +840,17 @@ void ScGlobal::EraseQuotes( OUString& rString, sal_Unicode cQuote, bool bUnescap } } -xub_StrLen ScGlobal::FindUnquoted( const OUString& rString, sal_Unicode cChar, xub_StrLen nStart, sal_Unicode cQuote ) +sal_Int32 ScGlobal::FindUnquoted( const OUString& rString, sal_Unicode cChar) { + const sal_Unicode cQuote = '\''; const sal_Unicode* const pStart = rString.getStr(); const sal_Unicode* const pStop = pStart + rString.getLength(); - const sal_Unicode* p = pStart + nStart; + const sal_Unicode* p = pStart; bool bQuoted = false; while (p < pStop) { if (*p == cChar && !bQuoted) - return sal::static_int_cast< xub_StrLen >( p - pStart ); + return sal::static_int_cast< sal_Int32 >( p - pStart ); else if (*p == cQuote) { if (!bQuoted) @@ -861,7 +862,7 @@ xub_StrLen ScGlobal::FindUnquoted( const OUString& rString, sal_Unicode cChar, x } ++p; } - return STRING_NOTFOUND; + return -1; } const sal_Unicode* ScGlobal::FindUnquoted( const sal_Unicode* pString, sal_Unicode cChar, sal_Unicode cQuote ) diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx index ec9e088..bda4a5a 100644 --- a/sc/source/core/tool/address.cxx +++ b/sc/source/core/tool/address.cxx @@ -1309,7 +1309,7 @@ bool ConvertSingleRef( ScDocument* pDoc, const OUString& rRefString, ScAddress::ExternalInfo* pExtInfo /* = NULL */ ) { bool bRet = false; - if (pExtInfo || (ScGlobal::FindUnquoted( rRefString, SC_COMPILER_FILE_TAB_SEP) == STRING_NOTFOUND)) + if (pExtInfo || (ScGlobal::FindUnquoted( rRefString, SC_COMPILER_FILE_TAB_SEP) == -1)) { ScAddress aAddr( 0, 0, nDefTab ); sal_uInt16 nRes = aAddr.Parse( rRefString, pDoc, rDetails, pExtInfo); @@ -1331,7 +1331,7 @@ bool ConvertDoubleRef( ScDocument* pDoc, const OUString& rRefString, SCTAB nDefT ScAddress::ExternalInfo* pExtInfo /* = NULL */ ) { bool bRet = false; - if (pExtInfo || (ScGlobal::FindUnquoted( rRefString, SC_COMPILER_FILE_TAB_SEP) == STRING_NOTFOUND)) + if (pExtInfo || (ScGlobal::FindUnquoted( rRefString, SC_COMPILER_FILE_TAB_SEP) == -1)) { ScRange aRange( ScAddress( 0, 0, nDefTab)); sal_uInt16 nRes = aRange.Parse( rRefString, pDoc, rDetails, pExtInfo); @@ -1426,8 +1426,8 @@ static sal_uInt16 lcl_ScRange_Parse_OOo( ScRange &aRange, const OUString& r, ScDocument* pDoc, ScAddress::ExternalInfo* pExtInfo = NULL ) { sal_uInt16 nRes1 = 0, nRes2 = 0; - xub_StrLen nPos = ScGlobal::FindUnquoted( r, ':'); - if (nPos != STRING_NOTFOUND) + sal_Int32 nPos = ScGlobal::FindUnquoted( r, ':'); + if (nPos != -1) { OUStringBuffer aTmp(r); aTmp[nPos] = 0; @@ -1742,8 +1742,8 @@ OUString ScAddress::Format(sal_uInt16 nFlags, const ScDocument* pDoc, // External Reference, same as in ScCompiler::MakeTabStr() if( aTabName[0] == '\'' ) { // "'Doc'#Tab" - xub_StrLen nPos = ScCompiler::GetDocTabPos( aTabName); - if (nPos != STRING_NOTFOUND) + sal_Int32 nPos = ScCompiler::GetDocTabPos( aTabName); + if (nPos != -1) { aDocName = aTabName.copy( 0, nPos + 1 ); aTabName = aTabName.copy( nPos + 1 ); @@ -1817,8 +1817,8 @@ lcl_Split_DocTab( const ScDocument* pDoc, SCTAB nTab, // External reference, same as in ScCompiler::MakeTabStr() if ( rTabName[0] == '\'' ) { // "'Doc'#Tab" - xub_StrLen nPos = ScCompiler::GetDocTabPos( rTabName); - if (nPos != STRING_NOTFOUND) + sal_Int32 nPos = ScCompiler::GetDocTabPos( rTabName); + if (nPos != -1) { rDocName = rTabName.copy( 0, nPos + 1 ); rTabName = rTabName.copy( nPos + 1 ); diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index 9b77a7d..bcff41e 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -736,8 +736,8 @@ struct ConventionOOO_A1 : public Convention_A1 { aString = aTmp; // "'Doc'#Tab" - xub_StrLen nPos = ScCompiler::GetDocTabPos( aString ); - if ( nPos != STRING_NOTFOUND ) + sal_Int32 nPos = ScCompiler::GetDocTabPos( aString ); + if ( nPos != -1 ) { aDoc = aString.copy( 0, nPos + 1 ); aString = aString.copy( nPos + 1 ); @@ -1056,8 +1056,8 @@ struct ConventionXL rTabName = aTmp; // Cheesy hack to unparse the OOO style "'Doc'#Tab" - xub_StrLen nPos = ScCompiler::GetDocTabPos( rTabName); - if (nPos != STRING_NOTFOUND) + sal_Int32 nPos = ScCompiler::GetDocTabPos( rTabName); + if (nPos != -1) { rDocName = rTabName.copy( 0, nPos ); // TODO : More research into how XL escapes the doc path @@ -1716,14 +1716,14 @@ void ScCompiler::CheckTabQuotes( OUString& rString, } } -xub_StrLen ScCompiler::GetDocTabPos( const OUString& rString ) +sal_Int32 ScCompiler::GetDocTabPos( const OUString& rString ) { if (rString[0] != '\'') - return STRING_NOTFOUND; - xub_StrLen nPos = ScGlobal::FindUnquoted( rString, SC_COMPILER_FILE_TAB_SEP); + return -1; + sal_Int32 nPos = ScGlobal::FindUnquoted( rString, SC_COMPILER_FILE_TAB_SEP); // it must be 'Doc'# - if (nPos != STRING_NOTFOUND && rString[nPos-1] != '\'') - nPos = STRING_NOTFOUND; + if (nPos != -1 && rString[nPos-1] != '\'') + nPos = -1; return nPos; } @@ -2744,10 +2744,10 @@ bool ScCompiler::IsReference( const OUString& rName ) // something like 3:3, meaning entire row 3. do { - const xub_StrLen nPos = ScGlobal::FindUnquoted( rName, '.'); - if ( nPos == STRING_NOTFOUND ) + const sal_Int32 nPos = ScGlobal::FindUnquoted( rName, '.'); + if ( nPos == -1 ) { - if (ScGlobal::FindUnquoted( rName, ':') != STRING_NOTFOUND) + if (ScGlobal::FindUnquoted( rName, ':') != -1) break; // may be 3:3, continue as usual return false; } diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 3e8a537..cda08eb 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -7182,7 +7182,7 @@ void ScInterpreter::ScAddressFunc() { // Isolate Tab from 'Doc'#Tab sal_Int32 nPos = ScCompiler::GetDocTabPos( sTabStr); - if (nPos != STRING_NOTFOUND) + if (nPos != -1) { if (sTabStr[nPos+1] == '$') ++nPos; // also split 'Doc'#$Tab diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index c4dcb4b..26d16f1 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -395,7 +395,7 @@ static void lcl_RemoveLineEnd(OUString& rStr) removeChars(rStr, sal_Unicode('\n')); } -xub_StrLen lcl_MatchParenthesis( const OUString& rStr, xub_StrLen nPos ) +static sal_Int32 lcl_MatchParenthesis( const OUString& rStr, xub_StrLen nPos ) { int nDir; sal_Unicode c1, c2 = 0; @@ -438,7 +438,7 @@ xub_StrLen lcl_MatchParenthesis( const OUString& rStr, xub_StrLen nPos ) nDir = 0; } if ( !nDir ) - return STRING_NOTFOUND; + return -1; sal_Int32 nLen = rStr.getLength(); const sal_Unicode* p0 = rStr.getStr(); const sal_Unicode* p; @@ -483,8 +483,8 @@ xub_StrLen lcl_MatchParenthesis( const OUString& rStr, xub_StrLen nPos ) } } if ( nLevel ) - return STRING_NOTFOUND; - return (xub_StrLen) (p - p0); + return -1; + return (sal_Int32) (p - p0); } //================================================================== @@ -834,8 +834,8 @@ void ScInputHandler::ShowTipCursor() while( !bFound ) { aSelText += ")"; - xub_StrLen nLeftParentPos = lcl_MatchParenthesis( aSelText, aSelText.getLength()-1 ); - if( nLeftParentPos != STRING_NOTFOUND ) + sal_Int32 nLeftParentPos = lcl_MatchParenthesis( aSelText, aSelText.getLength()-1 ); + if( nLeftParentPos != -1 ) { sal_Unicode c = ( nLeftParentPos > 0 ) ? aSelText[ nLeftParentPos-1 ] : 0; if( !(comphelper::string::isalphaAscii(c)) ) @@ -1058,7 +1058,7 @@ void ScInputHandler::UseFormulaData() { xub_StrLen nPos = aSel.nEndPos; OUString aFormula = aTotal.copy( 0, nPos );; - xub_StrLen nLeftParentPos = 0; + sal_Int32 nLeftParentPos = 0; xub_StrLen nNextFStart = 0; xub_StrLen nNextFEnd = 0; xub_StrLen nArgPos = 0; @@ -1085,7 +1085,7 @@ void ScInputHandler::UseFormulaData() { aFormula += ")"; nLeftParentPos = lcl_MatchParenthesis( aFormula, aFormula.getLength()-1 ); - if( nLeftParentPos == STRING_NOTFOUND ) + if( nLeftParentPos == -1 ) break; // nLeftParentPos can be 0 if a parenthesis is inserted before the formula @@ -1692,8 +1692,8 @@ void ScInputHandler::UpdateParenthesis() sal_Unicode c = aFormula[nPos]; if ( c == '(' || c == ')' ) { - xub_StrLen nOther = lcl_MatchParenthesis( aFormula, nPos ); - if ( nOther != STRING_NOTFOUND ) + sal_Int32 nOther = lcl_MatchParenthesis( aFormula, nPos ); + if ( nOther != -1 ) { SfxItemSet aSet( pEngine->GetEmptyItemSet() ); aSet.Put( SvxWeightItem( WEIGHT_BOLD, EE_CHAR_WEIGHT ) ); commit 2c3042925b0a43da2ed50e49365ec8235c84660f Author: Noel Grandin <[email protected]> Date: Fri Nov 8 14:09:02 2013 +0200 convert STRING_NOTFOUND -> -1 in editeng And convert some xub_StrLen to sal_Int32 in the same patch of code. Change-Id: I72c92bf9413dbca14688cb8d46a023df49a5d41a diff --git a/editeng/source/editeng/textconv.cxx b/editeng/source/editeng/textconv.cxx index 1fb5848..bd86baf 100644 --- a/editeng/source/editeng/textconv.cxx +++ b/editeng/source/editeng/textconv.cxx @@ -451,16 +451,16 @@ void TextConvWrapper::ChangeText( const OUString &rNewText, pESelection->Adjust(); // remember cursor start position for later setting of the cursor - const xub_StrLen nStartIndex = pESelection->nStartPos; + const sal_Int32 nStartIndex = pESelection->nStartPos; const sal_Int32 nIndices = pOffsets->getLength(); const sal_Int32 *pIndices = pOffsets->getConstArray(); - sal_Int32 nConvTextLen = rNewText.getLength(); - xub_StrLen nPos = 0; - xub_StrLen nChgPos = STRING_NOTFOUND; - xub_StrLen nChgLen = 0; - xub_StrLen nConvChgPos = STRING_NOTFOUND; - xub_StrLen nConvChgLen = 0; + sal_Int32 nConvTextLen = rNewText.getLength(); + sal_Int32 nPos = 0; + sal_Int32 nChgPos = -1; + sal_Int32 nChgLen = 0; + sal_Int32 nConvChgPos = -1; + sal_Int32 nConvChgLen = 0; // offset to calculate the position in the text taking into // account that text may have been replaced with new text of @@ -474,20 +474,20 @@ void TextConvWrapper::ChangeText( const OUString &rNewText, while (true) { // get index in original text that matches nPos in new text - xub_StrLen nIndex; + sal_Int32 nIndex; if (nPos < nConvTextLen) - nIndex = (sal_Int32) nPos < nIndices ? (xub_StrLen) pIndices[nPos] : nPos; + nIndex = nPos < nIndices ? pIndices[nPos] : nPos; else { nPos = nConvTextLen; - nIndex = static_cast< xub_StrLen >( rOrigText.getLength() ); + nIndex = rOrigText.getLength(); } if (rOrigText[nIndex] == rNewText[nPos] || nPos == nConvTextLen /* end of string also terminates non-matching char sequence */) { // substring that needs to be replaced found? - if (nChgPos != STRING_NOTFOUND && nConvChgPos != STRING_NOTFOUND) + if (nChgPos != -1 && nConvChgPos != -1) { nChgLen = nIndex - nChgPos; nConvChgLen = nPos - nConvChgPos; @@ -498,7 +498,7 @@ void TextConvWrapper::ChangeText( const OUString &rNewText, // set selection to sub string to be replaced in original text ESelection aSel( *pESelection ); - xub_StrLen nChgInNodeStartIndex = static_cast< xub_StrLen >( nStartIndex + nCorrectionOffset + nChgPos ); + sal_Int32 nChgInNodeStartIndex = nStartIndex + nCorrectionOffset + nChgPos; aSel.nStartPos = nChgInNodeStartIndex; aSel.nEndPos = nChgInNodeStartIndex + nChgLen; m_pEditView->SetSelection( aSel ); @@ -513,14 +513,14 @@ void TextConvWrapper::ChangeText( const OUString &rNewText, nCorrectionOffset += nConvChgLen - nChgLen; - nChgPos = STRING_NOTFOUND; - nConvChgPos = STRING_NOTFOUND; + nChgPos = -1; + nConvChgPos = -1; } } else { // begin of non-matching char sequence found ? - if (nChgPos == STRING_NOTFOUND && nConvChgPos == STRING_NOTFOUND) + if (nChgPos == -1 && nConvChgPos == -1) { nChgPos = nIndex; nConvChgPos = nPos; commit 4283bc18366fff3d5a953ddd756f114e5a59216f Author: Noel Grandin <[email protected]> Date: Fri Nov 8 09:44:06 2013 +0200 convert STRING_NOTFOUND -> NODE_NOTFOUND in connectivity The code was interchangably using the two anyway. Change-Id: I4f3fe8f1d699a9725bbcce0138a9d978a1eff28a diff --git a/connectivity/source/drivers/dbase/DIndexIter.cxx b/connectivity/source/drivers/dbase/DIndexIter.cxx index efcc7b4..6fd9812 100644 --- a/connectivity/source/drivers/dbase/DIndexIter.cxx +++ b/connectivity/source/drivers/dbase/DIndexIter.cxx @@ -48,7 +48,7 @@ sal_uIntPtr OIndexIterator::Next() //------------------------------------------------------------------ sal_uIntPtr OIndexIterator::Find(sal_Bool bFirst) { - sal_uIntPtr nRes = STRING_NOTFOUND; + sal_uIntPtr nRes = NODE_NOTFOUND; if (bFirst) { @@ -69,7 +69,7 @@ sal_uIntPtr OIndexIterator::Find(sal_Bool bFirst) m_nCurNode = NODE_NOTFOUND; } ONDXKey* pKey = GetNextKey(); - nRes = pKey ? pKey->GetRecord() : STRING_NOTFOUND; + nRes = pKey ? pKey->GetRecord() : NODE_NOTFOUND; } else if (m_pOperator->IsA(TYPE(OOp_ISNOTNULL))) nRes = GetNotNull(bFirst); @@ -196,7 +196,7 @@ sal_uIntPtr OIndexIterator::GetCompare(sal_Bool bFirst) } } - return pKey ? pKey->GetRecord() : STRING_NOTFOUND; + return pKey ? pKey->GetRecord() : NODE_NOTFOUND; } //------------------------------------------------------------------ @@ -216,7 +216,7 @@ sal_uIntPtr OIndexIterator::GetLike(sal_Bool bFirst) ONDXKey* pKey; while ( ( ( pKey = GetNextKey() ) != NULL ) && !m_pOperator->operate(pKey,m_pOperand)) ; - return pKey ? pKey->GetRecord() : STRING_NOTFOUND; + return pKey ? pKey->GetRecord() : NODE_NOTFOUND; } //------------------------------------------------------------------ @@ -238,7 +238,7 @@ sal_uIntPtr OIndexIterator::GetNull(sal_Bool bFirst) pKey = NULL; m_aCurLeaf = NULL; } - return pKey ? pKey->GetRecord() : STRING_NOTFOUND; + return pKey ? pKey->GetRecord() : NODE_NOTFOUND; } //------------------------------------------------------------------ @@ -249,7 +249,7 @@ sal_uIntPtr OIndexIterator::GetNotNull(sal_Bool bFirst) { // go through all NULL values first for (sal_uIntPtr nRec = GetNull(bFirst); - nRec != STRING_NOTFOUND; + nRec != NODE_NOTFOUND; nRec = GetNull(sal_False)) ; pKey = m_aCurLeaf.Is() ? &(*m_aCurLeaf)[m_nCurNode].GetKey() : NULL; @@ -257,7 +257,7 @@ sal_uIntPtr OIndexIterator::GetNotNull(sal_Bool bFirst) else pKey = GetNextKey(); - return pKey ? pKey->GetRecord() : STRING_NOTFOUND; + return pKey ? pKey->GetRecord() : NODE_NOTFOUND; } //------------------------------------------------------------------ diff --git a/connectivity/source/drivers/dbase/DResultSet.cxx b/connectivity/source/drivers/dbase/DResultSet.cxx index dc5ac7d..4df2383 100644 --- a/connectivity/source/drivers/dbase/DResultSet.cxx +++ b/connectivity/source/drivers/dbase/DResultSet.cxx @@ -170,8 +170,8 @@ sal_Bool ODbaseResultSet::fillIndexValues(const Reference< XColumnsSupplier> &_x if (pIter) { - sal_uInt32 nRec = pIter->First(); - while (nRec != SQL_COLUMN_NOTFOUND) + sal_uIntPtr nRec = pIter->First(); + while (nRec != NODE_NOTFOUND) { if (m_aOrderbyAscending[0]) m_pFileSet->get().push_back(nRec); _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
