From afb5143639598bdc7f78ba000569d80e10d0fbe4 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Tue, 16 Dec 2014 17:35:52 +0100 Subject: fdo#39440 reduce scope of local variables This addresses some cppcheck warnings. Change-Id: I1d037e87c69b1a7de019f1abf1f729bf7e28d762 Reviewed-on: https://gerrit.libreoffice.org/13494 Reviewed-by: Noel Grandin Tested-by: Noel Grandin --- forms/source/component/Grid.cxx | 3 +-- forms/source/runtime/formoperations.cxx | 2 +- forms/source/xforms/xpathlib/xpathlib.cxx | 9 +++------ 3 files changed, 5 insertions(+), 9 deletions(-) (limited to 'forms') diff --git a/forms/source/component/Grid.cxx b/forms/source/component/Grid.cxx index bb5469bbcd9a..a3e727b21caf 100644 --- a/forms/source/component/Grid.cxx +++ b/forms/source/component/Grid.cxx @@ -780,11 +780,10 @@ void OGridControlModel::write(const Reference& _rxOutStream // 2. Columns sal_Int32 nLen = getCount(); _rxOutStream->writeLong(nLen); - OGridColumn* pCol; for (sal_Int32 i = 0; i < nLen; i++) { // first the service name for the unerlying model - pCol = getColumnImplementation(m_aItems[i]); + OGridColumn* pCol = getColumnImplementation(m_aItems[i]); DBG_ASSERT(pCol != NULL, "OGridControlModel::write : such items should never reach it into my container !"); _rxOutStream << pCol->getModelName(); // then the object itself diff --git a/forms/source/runtime/formoperations.cxx b/forms/source/runtime/formoperations.cxx index a55451acad5a..74e97821e877 100644 --- a/forms/source/runtime/formoperations.cxx +++ b/forms/source/runtime/formoperations.cxx @@ -1040,11 +1040,11 @@ namespace frm if ( m_xCursor.is() && ( m_xCursor == _rEvent.Source ) ) { - bool bIs = false; if ( ( _rEvent.PropertyName == PROPERTY_ISMODIFIED ) || ( _rEvent.PropertyName == PROPERTY_ISNEW ) ) { + bool bIs = false; if ( ( _rEvent.NewValue >>= bIs ) && !bIs ) m_bActiveControlModified = false; } diff --git a/forms/source/xforms/xpathlib/xpathlib.cxx b/forms/source/xforms/xpathlib/xpathlib.cxx index 70c473e6c1ef..e8183c3c0246 100644 --- a/forms/source/xforms/xpathlib/xpathlib.cxx +++ b/forms/source/xforms/xpathlib/xpathlib.cxx @@ -153,10 +153,9 @@ void xforms_minFunction(xmlXPathParserContextPtr ctxt, int nargs) xmlNodeSetPtr pNodeSet = xmlXPathPopNodeSet(ctxt); if (xmlXPathCheckError(ctxt)) XP_ERROR(XPATH_INVALID_TYPE); double nMinimum = 0; - double nNumber = 0; for (int i = 0; i < xmlXPathNodeSetGetLength(pNodeSet); i++) { - nNumber = xmlXPathCastNodeToNumber(xmlXPathNodeSetItem(pNodeSet, i)); + double nNumber = xmlXPathCastNodeToNumber(xmlXPathNodeSetItem(pNodeSet, i)); if (xmlXPathIsNaN(nNumber)) { xmlXPathReturnNumber(ctxt, xmlXPathNAN); @@ -176,10 +175,9 @@ void xforms_maxFunction(xmlXPathParserContextPtr ctxt, int nargs) xmlNodeSetPtr pNodeSet = xmlXPathPopNodeSet(ctxt); if (xmlXPathCheckError(ctxt)) XP_ERROR(XPATH_INVALID_TYPE); double nMaximum = 0; - double nNumber = 0; for (int i = 0; i < xmlXPathNodeSetGetLength(pNodeSet); i++) { - nNumber = xmlXPathCastNodeToNumber(xmlXPathNodeSetItem(pNodeSet, i)); + double nNumber = xmlXPathCastNodeToNumber(xmlXPathNodeSetItem(pNodeSet, i)); if (xmlXPathIsNaN(nNumber)) { xmlXPathReturnNumber(ctxt, xmlXPathNAN); @@ -197,11 +195,10 @@ void xforms_countNonEmptyFunction(xmlXPathParserContextPtr ctxt, int nargs) if (nargs != 1) XP_ERROR(XPATH_INVALID_ARITY); xmlNodeSetPtr pNodeSet = xmlXPathPopNodeSet(ctxt); if (xmlXPathCheckError(ctxt)) XP_ERROR(XPATH_INVALID_TYPE); - xmlChar *aString; sal_Int32 nNotEmpty = 0; for (int i = 0; i < xmlXPathNodeSetGetLength(pNodeSet); i++) { - aString = xmlXPathCastNodeToString(xmlXPathNodeSetItem(pNodeSet, i)); + const xmlChar *aString = xmlXPathCastNodeToString(xmlXPathNodeSetItem(pNodeSet, i)); if (*aString != 0) nNotEmpty++; } xmlXPathReturnNumber(ctxt, nNotEmpty); -- cgit