Hello,
Here is a patch for some cppcheck cleaning in sc
Compiling was ok
Julien
PS : when cppcheck indicates that a boolean is not initialized, what is
recommended to choose ? true, false or it depends on the context ?
(LGPLv3+ / MPL)
commit dd245b64fb571acffb4dc580d0f6098a0cf5037b
Author: Julien Nabet <serval2...@yahoo.fr>
Date: Sun Jan 9 16:11:17 2011 +0100
some cppcheckcleaning
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index e18921c..574ab1f 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -234,14 +234,14 @@ BOOL ScAttrArray::Concat(SCSIZE nPos)
BOOL ScAttrArray::Search( SCROW nRow, SCSIZE& nIndex ) const
{
- long nLo = 0;
long nHi = static_cast<long>(nCount) - 1;
- long nStartRow = 0;
- long nEndRow = 0;
long i = 0;
BOOL bFound = (nCount == 1);
if (pData)
{
+ long nLo = 0;
+ long nStartRow = 0;
+ long nEndRow = 0;
while ( !bFound && nLo <= nHi )
{
i = (nLo + nHi) / 2;
diff --git a/sc/source/core/tool/chartlis.cxx b/sc/source/core/tool/chartlis.cxx
index bfb3d57..095fdbd 100644
--- a/sc/source/core/tool/chartlis.cxx
+++ b/sc/source/core/tool/chartlis.cxx
@@ -336,7 +336,6 @@ public:
endListening(aRange);
}
}
-
private:
void startListening(const ScRange& rRange)
{
@@ -353,7 +352,6 @@ private:
else
mpDoc->EndListeningArea(rRange, &mrParent);
}
-
private:
ScDocument* mpDoc;
ScChartListener& mrParent;
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 1c890b5..f88d332 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -4206,7 +4206,6 @@ static void lcl_GetLastMatch( SCSIZE& rIndex, const
VectorMatrixAccessor& rMat,
void ScInterpreter::ScMatch()
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScMatch"
);
- ScMatrixRef pMatSrc = NULL;
BYTE nParamCount = GetByte();
if ( MustHaveParamCount( nParamCount, 2, 3 ) )
@@ -4222,6 +4221,7 @@ void ScInterpreter::ScMatch()
SCCOL nCol2 = 0;
SCROW nRow2 = 0;
SCTAB nTab2 = 0;
+ ScMatrixRef pMatSrc = NULL;
switch (GetStackType())
{
diff --git a/sc/source/ui/dbgui/scuiimoptdlg.cxx
b/sc/source/ui/dbgui/scuiimoptdlg.cxx
index d187301..f3edeaa 100644
--- a/sc/source/ui/dbgui/scuiimoptdlg.cxx
+++ b/sc/source/ui/dbgui/scuiimoptdlg.cxx
@@ -69,10 +69,10 @@ private:
USHORT ScDelimiterTable::GetCode( const String& rDel ) const
{
sal_Unicode nCode = 0;
- xub_StrLen i = 0;
if ( nCount >= 2 )
{
+ xub_StrLen i = 0;
while ( i<nCount )
{
if ( rDel == theDelTab.GetToken( i, cSep ) )
@@ -93,10 +93,10 @@ USHORT ScDelimiterTable::GetCode( const String& rDel ) const
String ScDelimiterTable::GetDelimiter( sal_Unicode nCode ) const
{
String aStrDel;
- xub_StrLen i = 0;
if ( nCount >= 2 )
{
+ xub_StrLen i = 0;
while ( i<nCount )
{
if ( nCode == (sal_Unicode) theDelTab.GetToken( i+1, cSep
).ToInt32() )
diff --git a/sc/source/ui/vba/testvba/testvba.cxx
b/sc/source/ui/vba/testvba/testvba.cxx
index 3ca44cc..236fc19 100644
--- a/sc/source/ui/vba/testvba/testvba.cxx
+++ b/sc/source/ui/vba/testvba/testvba.cxx
@@ -120,7 +120,7 @@ mxCompLoader( _xCompLoader ), msOutDirPath( convertToURL(
_outDirPath ) )
return sLogLocation;
}
- void init()
+ void init() const
{
// blow away previous logs?
}
diff --git a/sc/source/ui/vba/vbachart.cxx b/sc/source/ui/vba/vbachart.cxx
index fb02586..d610ca0 100644
--- a/sc/source/ui/vba/vbachart.cxx
+++ b/sc/source/ui/vba/vbachart.cxx
@@ -96,7 +96,7 @@ ScVbaChart::getName() throw (css::uno::RuntimeException)
{
xProps->getPropertyValue( CHART_NAME ) >>= sName;
}
- catch( uno::Exception e ) // swallow exceptions
+ catch( uno::Exception &e ) // swallow exceptions
{
}
return sName;
diff --git a/sc/source/ui/vba/vbachart.hxx b/sc/source/ui/vba/vbachart.hxx
index 3602baa..45210a1 100644
--- a/sc/source/ui/vba/vbachart.hxx
+++ b/sc/source/ui/vba/vbachart.hxx
@@ -69,12 +69,12 @@ friend class ScVbaAxis;
bool hasMarkers() throw ( css::script::BasicErrorException );
sal_Int32 getMarkerType(sal_Int32 _nWithMarkers, sal_Int32
_nWithoutMarkers) throw ( css::script::BasicErrorException );
void assignDiagramAttributes();
- void setDefaultSeriesDescriptionLabels(){}
+ void setDefaultSeriesDescriptionLabels() const {}
public:
ScVbaChart( const css::uno::Reference< ov::XHelperInterface >& _xParent,
const css::uno::Reference< css::uno::XComponentContext >& _xContext, const
css::uno::Reference< css::lang::XComponent >& _xChartComponent, const
css::uno::Reference< css::table::XTableChart >& _xTableChart );
// Non-interface
- css::uno::Reference< css::beans::XPropertySet > xDiagramPropertySet() {
return mxDiagramPropertySet; }
+ css::uno::Reference< css::beans::XPropertySet > xDiagramPropertySet()
const { return mxDiagramPropertySet; }
bool isSeriesIndexValid(sal_Int32 _seriesindex) throw(
css::script::BasicErrorException );
bool areIndicesValid(sal_Int32 _seriesindex, sal_Int32 _valindex) throw (
css::script::BasicErrorException );
void setSeriesName(sal_Int32 _index, rtl::OUString _sname) throw (
css::script::BasicErrorException );
diff --git a/sc/source/ui/vba/vbaformatconditions.hxx
b/sc/source/ui/vba/vbaformatconditions.hxx
index e51ca23..4193332 100644
--- a/sc/source/ui/vba/vbaformatconditions.hxx
+++ b/sc/source/ui/vba/vbaformatconditions.hxx
@@ -50,7 +50,7 @@ public:
rtl::OUString getA1Formula(const css::uno::Any& _aFormula) throw (
css::script::BasicErrorException );
rtl::OUString getStyleName();
void removeFormatCondition( const rtl::OUString& _sStyleName, sal_Bool
_bRemoveStyle) throw ( css::script::BasicErrorException );
- css::uno::Reference< css::sheet::XSheetConditionalEntries >
getSheetConditionalEntries() { return mxSheetConditionalEntries; }
+ css::uno::Reference< css::sheet::XSheetConditionalEntries >
getSheetConditionalEntries() const { return mxSheetConditionalEntries; }
// XFormatConditions
virtual void SAL_CALL Delete( ) throw (css::script::BasicErrorException,
css::uno::RuntimeException);
virtual css::uno::Reference< ov::excel::XFormatCondition > SAL_CALL Add(
::sal_Int32 Type, const css::uno::Any& Operator, const css::uno::Any& Formula1,
const css::uno::Any& Formula2 ) throw (css::script::BasicErrorException,
css::uno::RuntimeException);
diff --git a/sc/source/ui/vba/vbaoutline.cxx b/sc/source/ui/vba/vbaoutline.cxx
index 3d00b80..410b4f0 100644
--- a/sc/source/ui/vba/vbaoutline.cxx
+++ b/sc/source/ui/vba/vbaoutline.cxx
@@ -32,9 +32,9 @@ using namespace ::ooo::vba;
void
ScVbaOutline::ShowLevels( const uno::Any& RowLevels, const uno::Any&
ColumnLevels ) throw (uno::RuntimeException)
{
- sal_Int16 nLevel = 0;
if (mxOutline.is())
{
+ sal_Int16 nLevel = 0;
if (RowLevels >>= nLevel)
{
mxOutline->showLevel(nLevel, table::TableOrientation_ROWS);
diff --git a/sc/source/ui/vba/vbapane.hxx b/sc/source/ui/vba/vbapane.hxx
index 841776a..c4dd653 100644
--- a/sc/source/ui/vba/vbapane.hxx
+++ b/sc/source/ui/vba/vbapane.hxx
@@ -44,7 +44,7 @@ public:
const css::uno::Reference< css::frame::XModel >& xModel,
const css::uno::Reference< css::sheet::XViewPane > xViewPane ) throw
(css::uno::RuntimeException);
- css::uno::Reference< css::sheet::XViewPane > getViewPane() { return
m_xViewPane; }
+ css::uno::Reference< css::sheet::XViewPane > getViewPane() const { return
m_xViewPane; }
// XPane attributes
virtual sal_Int32 SAL_CALL getScrollColumn() throw
(css::uno::RuntimeException);
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 445a08b..dd746eb 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -5394,10 +5394,10 @@ ScVbaRange::AutoFill( const uno::Reference<
excel::XRange >& Destination, const
// default to include the number of Rows in the source range;
SCCOLROW nSourceCount = ( sourceRange.aEnd.Row() -
sourceRange.aStart.Row() ) + 1;
- SCCOLROW nCount = 0;
if ( sourceRange != destRange )
{
+ SCCOLROW nCount = 0;
// Find direction of fill, vertical or horizontal
if ( sourceRange.aStart == destRange.aStart )
{
diff --git a/sc/source/ui/vba/vbarange.hxx b/sc/source/ui/vba/vbarange.hxx
index b619752..cb31b3c 100644
--- a/sc/source/ui/vba/vbarange.hxx
+++ b/sc/source/ui/vba/vbarange.hxx
@@ -197,8 +197,8 @@ public:
virtual void SAL_CALL setShowDetail(const css::uno::Any& aShowDetail)
throw (css::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::ooo::vba::excel::XQueryTable >
SAL_CALL getQueryTable() throw (::com::sun::star::uno::RuntimeException);
//09-09-16 add by limingl
// Methods
- sal_Bool IsRows() { return mbIsRows; }
- sal_Bool IsColumns() { return mbIsColumns; }
+ sal_Bool IsRows() const { return mbIsRows; }
+ sal_Bool IsColumns() const { return mbIsColumns; }
virtual css::uno::Reference< ov::excel::XComment > SAL_CALL AddComment(
const css::uno::Any& Text ) throw (css::uno::RuntimeException);
virtual void SAL_CALL Clear() throw (css::uno::RuntimeException);
virtual void SAL_CALL ClearComments() throw (css::uno::RuntimeException);
diff --git a/sc/source/ui/vba/vbastyle.cxx b/sc/source/ui/vba/vbastyle.cxx
index 2594eff..e9c1488 100644
--- a/sc/source/ui/vba/vbastyle.cxx
+++ b/sc/source/ui/vba/vbastyle.cxx
@@ -133,7 +133,7 @@ ScVbaStyle::getNameLocal() throw
(script::BasicErrorException, uno::RuntimeExcep
{
mxPropertySet->getPropertyValue(DISPLAYNAME) >>= sName;
}
- catch (uno::Exception e)
+ catch (uno::Exception &e)
{
DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
}
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 3e8d9a6..2f841f0 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -193,6 +193,7 @@ ScDrawStringsVars::ScDrawStringsVars(ScOutputData* pData,
BOOL bPTL) :
eAttrOrient ( SVX_ORIENTATION_STANDARD ),
eAttrHorJust( SVX_HOR_JUSTIFY_STANDARD ),
eAttrVerJust( SVX_VER_JUSTIFY_BOTTOM ),
+ nAscentPixel(0),
eAttrHorJustMethod( SVX_JUSTIFY_METHOD_AUTO ),
eAttrVerJustMethod( SVX_JUSTIFY_METHOD_AUTO ),
pMargin ( NULL ),
_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice