[Libreoffice-commits] core.git: 18 commits - editeng/source filter/source include/tools sc/source svx/source sw/source tools/source xmlscript/source
Caolán McNamara
caolanm at redhat.com
Sat Oct 19 11:16:56 PDT 2013
editeng/source/editeng/impedit2.cxx | 6 +-
filter/source/graphicfilter/idxf/dxfgrprd.cxx | 21 +------
filter/source/graphicfilter/idxf/dxfgrprd.hxx | 2
filter/source/svg/svgwriter.cxx | 8 +-
include/tools/string.hxx | 4 -
sc/source/ui/undo/undotab.cxx | 1
sc/source/ui/unoobj/datauno.cxx | 3 -
svx/source/tbxctrls/tbunosearchcontrollers.cxx | 7 +-
sw/source/core/doc/number.cxx | 11 +++-
sw/source/core/edit/edattr.cxx | 10 +++
sw/source/filter/ww8/ww8atr.cxx | 3 -
sw/source/filter/ww8/ww8par.cxx | 4 +
sw/source/filter/ww8/ww8scan.cxx | 2
sw/source/ui/chrdlg/drpcps.cxx | 6 +-
tools/source/string/strimp.cxx | 63 -----------------------
xmlscript/source/xmlflat_imexp/xmlbas_import.cxx | 6 +-
16 files changed, 50 insertions(+), 107 deletions(-)
New commits:
commit 31ec3547085939d76b25e6794af0620d7d1a9171
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Oct 19 17:01:40 2013 +0100
fix CID#1038503 uninitializ
Change-Id: I7b85475d757695a0e3573627266b7756989f81a7
diff --git a/sw/source/ui/chrdlg/drpcps.cxx b/sw/source/ui/chrdlg/drpcps.cxx
index 2f30246..7df0858b 100644
--- a/sw/source/ui/chrdlg/drpcps.cxx
+++ b/sw/source/ui/chrdlg/drpcps.cxx
@@ -111,7 +111,7 @@ public:
, mnTotLineH(0)
, mnLineH(0)
, mnTextH(0)
- , mnDistance(00
+ , mnDistance(0)
, mpPrinter(NULL)
, mbDelPrinter(false)
{}
commit 7e2d03efbc831088643661b5b71de726a508353a
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Oct 19 16:06:45 2013 +0100
fix CID#1103762
Change-Id: I4bf0458bfdba2f53c685bba40d561a8211a28e66
diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx
index 0c4f881..4bb09ab 100644
--- a/sc/source/ui/undo/undotab.cxx
+++ b/sc/source/ui/undo/undotab.cxx
@@ -1039,8 +1039,8 @@ bool ScUndoImportTab::CanRepeat(SfxRepeatTarget& rTarget) const
ScUndoRemoveLink::ScUndoRemoveLink( ScDocShell* pShell, const OUString& rDoc ) :
ScSimpleUndo( pShell ),
aDocName( rDoc ),
- nCount( 0 ),
- nRefreshDelay( 0 )
+ nRefreshDelay( 0 ),
+ nCount( 0 )
{
ScDocument* pDoc = pDocShell->GetDocument();
SCTAB nTabCount = pDoc->GetTableCount();
commit 3194487d6287a401849521347fc41792cd88a662
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Oct 19 15:52:39 2013 +0100
CID#1038307 Negative loop bound
fix of coverity#1038307 Negative loop bound
d9ac156b2d651c1305135938a1e828144aa5742b wasn't complete, it assigned possible
-1 int32 to unsigned value before comparison, so -1 not detected.
Change-Id: I6c2805acae8e776902d74c641e01c036193ce3d8
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index e8cf38d4..e6c26e7 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -1909,16 +1909,16 @@ void ImpEditEngine::InitWritingDirections( sal_Int32 nPara )
ubidi_setPara( pBidi, reinterpret_cast<const UChar *>(aText.getStr()), aText.getLength(), nBidiLevel, NULL, &nError ); // UChar != sal_Unicode in MinGW
nError = U_ZERO_ERROR;
- size_t nCount = ubidi_countRuns( pBidi, &nError );
+ int32_t nCount = ubidi_countRuns( pBidi, &nError );
/* ubidi_countRuns can return -1 in case of error */
- if(nCount > 0)
+ if (nCount > 0)
{
int32_t nStart = 0;
int32_t nEnd;
UBiDiLevel nCurrDir;
- for ( size_t nIdx = 0; nIdx < nCount; ++nIdx )
+ for (int32_t nIdx = 0; nIdx < nCount; ++nIdx)
{
ubidi_getLogicalRun( pBidi, nStart, &nEnd, &nCurrDir );
rInfos.push_back( WritingDirectionInfo( nCurrDir, (sal_uInt16)nStart, (sal_uInt16)nEnd ) );
commit 415c1ce394a69ce49d3361f2e6cd6803ed6ee249
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Oct 19 15:47:05 2013 +0100
CID#1038502 uninitialized member
Change-Id: Ie69689748e6e38e3d269855a4c72e78d7979119b
diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx
index a171414..f2558d9 100644
--- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx
+++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx
@@ -625,9 +625,10 @@ void SAL_CALL UpDownSearchToolboxController::statusChanged( const css::frame::Fe
// MatchCaseToolboxController
MatchCaseToolboxController::MatchCaseToolboxController( const css::uno::Reference< css::uno::XComponentContext >& rxContext )
- :svt::ToolboxController( rxContext,
- css::uno::Reference< css::frame::XFrame >(),
- OUString(COMMAND_MATCHCASE) )
+ : svt::ToolboxController( rxContext,
+ css::uno::Reference< css::frame::XFrame >(),
+ OUString(COMMAND_MATCHCASE) )
+ , m_pMatchCaseControl(NULL)
{
}
commit 577c0818bcb43b4f281555af0c7c4724b3add03f
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Oct 19 15:45:44 2013 +0100
CID#1038503 uninitialized member
Change-Id: I4ceb50cf957b70a43848bb78aeaddc7957d3ffd7
diff --git a/sw/source/ui/chrdlg/drpcps.cxx b/sw/source/ui/chrdlg/drpcps.cxx
index 3b9d182..2f30246 100644
--- a/sw/source/ui/chrdlg/drpcps.cxx
+++ b/sw/source/ui/chrdlg/drpcps.cxx
@@ -107,11 +107,13 @@ public:
SwDropCapsPict(Window *pParent, WinBits nBits)
: Control(pParent, nBits)
, mpPage(NULL)
+ , mnLines(0)
, mnTotLineH(0)
, mnLineH(0)
, mnTextH(0)
- , mpPrinter( NULL )
- , mbDelPrinter( false )
+ , mnDistance(00
+ , mpPrinter(NULL)
+ , mbDelPrinter(false)
{}
void SetDropCapsPage(SwDropCapsPage* pPage) { mpPage = pPage; }
commit 5f911c416b26f88fdb75ded501c98f1b8738cec2
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Oct 19 15:38:43 2013 +0100
CID1078820 has already been dereferenced on all paths leading to the check
Change-Id: I5210d67259d445f6e7f52f176cd67af82d687e37
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 8e3e9b5..50354b3 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -5747,8 +5747,10 @@ sal_uLong WW8Reader::Read(SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPam, co
refStrm->SetBufferSize( nOldBuffSize );
refStrm.Clear();
}
- else if (pIn)
+ else
+ {
pIn->ResetError();
+ }
}
return nRet;
commit 6561a048c317f706b39f62bf8e727bcdf23e621e
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Oct 19 15:34:37 2013 +0100
CID#1103655 logically dead code, we check for < 4 already
Change-Id: I9e917530528d6e48f418f2b8fa417290a40c2403
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index 99640cb..d999f98 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -5919,10 +5919,8 @@ WW8Style::WW8Style(SvStream& rStream, WW8Fib& rFibPara)
{
sal_uInt16 a16Bit;
- if( 2 > nRead ) break;
rSt >> cstd;
- if( 4 > nRead ) break;
rSt >> cbSTDBaseInFile;
if( 6 > nRead ) break;
commit 984d10ca8d695013e01c8d9ab74b072a857e4cda
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Oct 19 15:29:10 2013 +0100
CID#1103675 use normal assert, as it's toast anyway
Change-Id: I065ce5f80f0c54443aca9378a653a9f25175feee
diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index 332b5d8..bed5b5c 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -1515,9 +1515,6 @@ void SVGTextWriter::implWriteTextPortion( const Point& rPos,
Color aTextColor,
sal_Bool bApplyMapping )
{
- if( !mpContext )
- OSL_FAIL( "SVGTextWriter::implWriteTextPortion: invalid context object." );
-
Point aPos;
Point aBaseLinePos( rPos );
const FontMetric aMetric( mpVDev->GetFontMetric() );
@@ -1601,6 +1598,8 @@ void SVGTextWriter::implWriteTextPortion( const Point& rPos,
}
addFontAttributes( /* isTexTContainer: */ false );
+ assert(mpContext); //invalid context object
+
mpContext->AddPaintAttr( COL_TRANSPARENT, aTextColor );
OUString sTextContent = rText;
commit 9f8a3e7329f2ce079f3b64d1f73d1097ed5aa025
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Oct 19 15:27:38 2013 +0100
CID#1103676 use normal assert, as it's toast anyway
Change-Id: I47340d71b5f3af9c06556965f240fb084440ea27
diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index 29812b3..332b5d8 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -1493,8 +1493,7 @@ void SVGTextWriter::writeTextPortion( const Point& rPos,
}
}
- if( !mpVDev )
- OSL_FAIL( "SVGTextWriter::writeTextPortion: invalid virtual device." );
+ assert(mpVDev); //invalid virtual device
const FontMetric aMetric( mpVDev->GetFontMetric() );
commit f69a5ff7ab8d0b7d166fb59f4717ca06d1d00812
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Oct 19 15:24:58 2013 +0100
CID#1103681 annotate as deliberate fallthrough
Change-Id: I731ea6aca73a81420e3d23cdb504a6151112d9a5
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 00690bd..1e02d13 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -2360,7 +2360,8 @@ void AttributeOutputBase::GetNumberPara( OUString& rStr, const SwField& rFld )
break;
default:
OSL_ENSURE(rFld.GetFormat() == SVX_NUM_ARABIC,
- "Unknown numbering type exported as default\n");
+ "Unknown numbering type exported as default of Arabic\n");
+ //fallthrough
case SVX_NUM_ARABIC:
rStr += "\\*Arabic ";
break;
commit 77b6b4a9c2f6125126438b2feb05f547e8e3a6ec
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Oct 19 15:18:52 2013 +0100
CID#1103755 unint members
Change-Id: Ic6961e3f18aed2f271f80c69d17a5c34a0c9fa8e
diff --git a/xmlscript/source/xmlflat_imexp/xmlbas_import.cxx b/xmlscript/source/xmlflat_imexp/xmlbas_import.cxx
index 261a756..08a2d54 100644
--- a/xmlscript/source/xmlflat_imexp/xmlbas_import.cxx
+++ b/xmlscript/source/xmlflat_imexp/xmlbas_import.cxx
@@ -407,8 +407,10 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const
// BasicImport
BasicImport::BasicImport( const Reference< frame::XModel >& rxModel, bool bOasis )
- :m_xModel( rxModel )
- ,m_bOasis( bOasis )
+ : XMLNS_UID(0)
+ , XMLNS_XLINK_UID(0)
+ , m_xModel(rxModel)
+ , m_bOasis(bOasis)
{
}
commit 8a241542a4b2ce76a8ea25d971f9937bbe66c6dd
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Oct 19 15:17:02 2013 +0100
CID#1103761 uninit member
Change-Id: I4212adb9c0cb8e1693df8725801188bc2154fffe
diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx
index 594561b..1522467 100644
--- a/sc/source/ui/unoobj/datauno.cxx
+++ b/sc/source/ui/unoobj/datauno.cxx
@@ -1661,7 +1661,8 @@ ScDatabaseRangeObj::ScDatabaseRangeObj(ScDocShell* pDocSh, const OUString& rNm)
pDocShell( pDocSh ),
aName( rNm ),
aPropSet( lcl_GetDBRangePropertyMap() ),
- bIsUnnamed(false)
+ bIsUnnamed(false),
+ aTab( 0 )
{
pDocShell->GetDocument()->AddUnoObject(*this);
}
commit ec2c07b8b7e9c949180ed1145ae112826696193a
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Oct 19 15:15:38 2013 +0100
CID#1103762 uninit member
Change-Id: Ie46df319bed04ad64275e2385b8e3abc0d41295d
diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx
index bba5cf6..0c4f881 100644
--- a/sc/source/ui/undo/undotab.cxx
+++ b/sc/source/ui/undo/undotab.cxx
@@ -1039,7 +1039,8 @@ bool ScUndoImportTab::CanRepeat(SfxRepeatTarget& rTarget) const
ScUndoRemoveLink::ScUndoRemoveLink( ScDocShell* pShell, const OUString& rDoc ) :
ScSimpleUndo( pShell ),
aDocName( rDoc ),
- nCount( 0 )
+ nCount( 0 ),
+ nRefreshDelay( 0 )
{
ScDocument* pDoc = pDocShell->GetDocument();
SCTAB nTabCount = pDoc->GetTableCount();
commit 0c28b1d5557027b55d288016e2e2f1b58f6f1bbe
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Oct 19 15:13:03 2013 +0100
CID#703918 ensure buffer is null terminated
Change-Id: If7937abf1ea51578187269a48af58bdede569ed6
diff --git a/filter/source/graphicfilter/idxf/dxfgrprd.cxx b/filter/source/graphicfilter/idxf/dxfgrprd.cxx
index 2056653..43fccca 100644
--- a/filter/source/graphicfilter/idxf/dxfgrprd.cxx
+++ b/filter/source/graphicfilter/idxf/dxfgrprd.cxx
@@ -243,7 +243,8 @@ void DXFGroupReader::SetF(sal_uInt16 nG, double fF)
void DXFGroupReader::SetS()
{
- strncpy(S0_9[0], "EOF", DXF_MAX_STRING_LEN + 1 );
+ strncpy(S0_9[0], "EOF", DXF_MAX_STRING_LEN);
+ S0_9[0][DXF_MAX_STRING_LEN] = 0;
}
commit e8c15a9c2050dc24f451eea1426b65df0fecd5a4
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Oct 19 15:09:21 2013 +0100
SetS only used once with constant values
Change-Id: I2223c22da5bee6d9f9741c96eafe4d65e15dcb55
diff --git a/filter/source/graphicfilter/idxf/dxfgrprd.cxx b/filter/source/graphicfilter/idxf/dxfgrprd.cxx
index 895f88b..2056653 100644
--- a/filter/source/graphicfilter/idxf/dxfgrprd.cxx
+++ b/filter/source/graphicfilter/idxf/dxfgrprd.cxx
@@ -162,7 +162,7 @@ sal_uInt16 DXFGroupReader::Read()
else
{
nG = 0;
- SetS( 0, "EOF" );
+ SetS();
if ( nGCount != 0xffffffff )
{
// InfoBox(NULL,String("Fehler ab Gruppe Nr ")+String(nGCount)).Execute();
@@ -241,23 +241,9 @@ void DXFGroupReader::SetF(sal_uInt16 nG, double fF)
}
-void DXFGroupReader::SetS(sal_uInt16 nG, const char * sS)
+void DXFGroupReader::SetS()
{
- char* pPtr = NULL;
- if ( nG < 10 )
- pPtr = S0_9[ nG ];
- else if ( nG == 100 )
- pPtr = S100;
- else if ( nG == 102 )
- pPtr = S102;
- else
- {
- nG -= 999;
- if ( nG < 11 )
- pPtr = S999_1009[ nG ];
- }
- if ( pPtr )
- strncpy( pPtr, sS, DXF_MAX_STRING_LEN + 1 );
+ strncpy(S0_9[0], "EOF", DXF_MAX_STRING_LEN + 1 );
}
diff --git a/filter/source/graphicfilter/idxf/dxfgrprd.hxx b/filter/source/graphicfilter/idxf/dxfgrprd.hxx
index e83d958d..0d16edb 100644
--- a/filter/source/graphicfilter/idxf/dxfgrprd.hxx
+++ b/filter/source/graphicfilter/idxf/dxfgrprd.hxx
@@ -77,7 +77,7 @@ public:
// (e.g. to set default values, before 'blindly' reading lots of groups)
void SetF(sal_uInt16 nG, double fF);
- void SetS(sal_uInt16 nG, const char * sS); // (will be copied)
+ void SetS(); // (will be copied)
private:
commit 6368338902f96f8f90dcf9d57ec81274a04be34c
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Oct 19 15:00:55 2013 +0100
CID#736189 out of bounds
Change-Id: Ieabdd6d551b2602ec08a2b2d9bc25037d73f4dd2
diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx
index 718a3ca..cfd9076 100644
--- a/sw/source/core/doc/number.cxx
+++ b/sw/source/core/doc/number.cxx
@@ -737,7 +737,16 @@ OUString SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
bool bMakeNumStringForPhantom( false );
if ( pWorkingNodeNum->IsPhantom() )
{
- SwNumFmt aFmt( Get( static_cast<sal_uInt16>(pWorkingNodeNum->GetLevelInListTree()) ) );
+ int nListLevel = pWorkingNodeNum->GetLevelInListTree();
+
+ if (nListLevel < 0)
+ nListLevel = 0;
+
+ if (nListLevel >= MAXLEVEL)
+ nListLevel = MAXLEVEL - 1;
+
+
+ SwNumFmt aFmt( Get( static_cast<sal_uInt16>(nListLevel) ) );
bMakeNumStringForPhantom = aFmt.IsEnumeration() &&
SVX_NUM_NUMBER_NONE != aFmt.GetNumberingType();
commit 894054ceffb7dfcb948c65e73269f1cc934dd418
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Oct 19 14:59:10 2013 +0100
CID#736191 out of bounds
Change-Id: Iaed9abdeb82e2f039020e95314603ad9d20aa3e4
diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx
index 3436271..d97be99 100644
--- a/sw/source/core/edit/edattr.cxx
+++ b/sw/source/core/edit/edattr.cxx
@@ -86,8 +86,16 @@ sal_Bool SwEditShell::GetPaMAttr( SwPaM* pPaM, SfxItemSet& rSet,
if (pNumRule)
{
+ int nListLevel = pTxtNd->GetActualListLevel();
+
+ if (nListLevel < 0)
+ nListLevel = 0;
+
+ if (nListLevel >= MAXLEVEL)
+ nListLevel = MAXLEVEL - 1;
+
const OUString & aCharFmtName =
- pNumRule->Get(static_cast<sal_uInt16>(pTxtNd->GetActualListLevel())).GetCharFmtName();
+ pNumRule->Get(static_cast<sal_uInt16>(nListLevel)).GetCharFmtName();
SwCharFmt * pCharFmt =
GetDoc()->FindCharFmtByName(aCharFmtName);
commit a6cdf1b2f638800318e0b8789bd991e04eef5cf5
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Oct 19 14:25:58 2013 +0100
Related: fdo#38838 remove String::Search
Change-Id: I92a50bc5f7b0cddcf2066cdac50439a3d5f1708b
diff --git a/include/tools/string.hxx b/include/tools/string.hxx
index 6c73882..d2e5088 100644
--- a/include/tools/string.hxx
+++ b/include/tools/string.hxx
@@ -141,7 +141,6 @@ private:
TOOLS_DLLPRIVATE UniString& Expand( xub_StrLen nCount, sal_Unicode cExpandChar );
TOOLS_DLLPRIVATE sal_Bool Equals( const sal_Unicode* pCharStr,
xub_StrLen nIndex, xub_StrLen nLen ) const;
- TOOLS_DLLPRIVATE xub_StrLen Search( const sal_Unicode* pCharStr, xub_StrLen nIndex = 0 ) const;
TOOLS_DLLPRIVATE UniString& operator +=( const sal_Unicode* pCharStr );
@@ -227,9 +226,6 @@ public:
sal_Bool Equals( const UniString& rStr,
xub_StrLen nIndex, xub_StrLen nLen ) const;
- xub_StrLen Search( sal_Unicode c, xub_StrLen nIndex = 0 ) const;
- xub_StrLen Search( const UniString& rStr, xub_StrLen nIndex = 0 ) const;
-
const sal_Unicode* GetBuffer() const { return mpData->maStr; }
friend sal_Bool operator == ( const UniString& rStr1, const UniString& rStr2 )
diff --git a/tools/source/string/strimp.cxx b/tools/source/string/strimp.cxx
index 99a2778..a0d6cca 100644
--- a/tools/source/string/strimp.cxx
+++ b/tools/source/string/strimp.cxx
@@ -244,67 +244,4 @@ STRING& STRING::Insert( const STRING& rStr, xub_StrLen nIndex )
return *this;
}
-xub_StrLen STRING::Search( STRCODE c, xub_StrLen nIndex ) const
-{
- DBG_CHKTHIS( STRING, DBGCHECKSTRING );
-
- sal_Int32 nLen = mpData->mnLen;
- const STRCODE* pStr = mpData->maStr;
- pStr += nIndex;
- while ( nIndex < nLen )
- {
- if ( *pStr == c )
- return nIndex;
- ++pStr,
- ++nIndex;
- }
-
- return STRING_NOTFOUND;
-}
-
-xub_StrLen STRING::Search( const STRING& rStr, xub_StrLen nIndex ) const
-{
- DBG_CHKTHIS( STRING, DBGCHECKSTRING );
- DBG_CHKOBJ( &rStr, STRING, DBGCHECKSTRING );
-
- sal_Int32 nLen = mpData->mnLen;
- sal_Int32 nStrLen = rStr.mpData->mnLen;
-
- // rStr was not found if its length is zero
- // or index is larger than searched string
- if ( !nStrLen || (nIndex >= nLen) )
- return STRING_NOTFOUND;
-
- const STRCODE* pStr1 = mpData->maStr;
- pStr1 += nIndex;
-
- if ( nStrLen == 1 )
- {
- STRCODE cSearch = rStr.mpData->maStr[0];
- while ( nIndex < nLen )
- {
- if ( *pStr1 == cSearch )
- return nIndex;
- ++pStr1,
- ++nIndex;
- }
- }
- else
- {
- const STRCODE* pStr2 = rStr.mpData->maStr;
-
- // search only within string
- while ( nLen - nIndex >= nStrLen )
- {
- // increase match if found
- if ( ImplStringCompareWithoutZero( pStr1, pStr2, nStrLen ) == 0 )
- return nIndex;
- ++pStr1,
- ++nIndex;
- }
- }
-
- return STRING_NOTFOUND;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list