[Libreoffice-commits] core.git: chart2/source
Michael Weghorn
m.weghorn at posteo.de
Sat Dec 6 14:30:16 PST 2014
chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx | 8 ++++----
chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx | 3 +--
chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx | 4 ++--
chart2/source/tools/AxisHelper.cxx | 2 +-
chart2/source/tools/ThreeDHelper.cxx | 2 +-
chart2/source/view/axes/Tickmarks_Equidistant.cxx | 3 +--
chart2/source/view/charttypes/Splines.cxx | 3 +--
chart2/source/view/main/GL3DRenderer.cxx | 8 +++-----
chart2/source/view/main/VDataSeries.cxx | 4 +---
9 files changed, 15 insertions(+), 22 deletions(-)
New commits:
commit 3948dee43526998b2e70dfe6ec2e4e46ef829abd
Author: Michael Weghorn <m.weghorn at posteo.de>
Date: Sat Dec 6 21:35:03 2014 +0100
reduce scope of local variables
This addresses some cppcheck warnings.
Change-Id: I864a4e84326633d33f09324247cbe439fba801c8
Reviewed-on: https://gerrit.libreoffice.org/13336
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
index a2c544f..38ff60a 100644
--- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
@@ -1539,11 +1539,11 @@ void WrappedVerticalProperty::setPropertyValue( const Any& rOuterValue, const Re
Any WrappedVerticalProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
{
- bool bFound = false;
- bool bAmbiguous = false;
Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
if( xDiagram.is() )
{
+ bool bFound = false;
+ bool bAmbiguous = false;
bool bVertical = DiagramHelper::getVertical( xDiagram, bFound, bAmbiguous );
if( bFound )
m_aOuterValue <<= bVertical;
@@ -1883,11 +1883,11 @@ void WrappedSolidTypeProperty::setPropertyValue( const Any& rOuterValue, const R
Any WrappedSolidTypeProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
{
- bool bFound = false;
- bool bAmbiguous = false;
Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
if( xDiagram.is() )
{
+ bool bFound = false;
+ bool bAmbiguous = false;
sal_Int32 nGeometry = DiagramHelper::getGeometry3D( xDiagram, bFound, bAmbiguous );
if( bFound )
m_aOuterValue <<= nGeometry;
diff --git a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx
index a4930b3..d9f3cca 100644
--- a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx
+++ b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx
@@ -130,12 +130,11 @@ ThreeD_SceneGeometry_TabPage::ThreeD_SceneGeometry_TabPage( vcl::Window* pWindow
m_pMFPerspective->Enable( m_pCbxPerspective->IsChecked() );
//RightAngledAxes
- bool bRightAngledAxes = false;
-
uno::Reference< chart2::XDiagram > xDiagram( m_xSceneProperties, uno::UNO_QUERY );
if( ChartTypeHelper::isSupportingRightAngledAxes(
DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ) )
{
+ bool bRightAngledAxes = false;
m_xSceneProperties->getPropertyValue( "RightAngledAxes" ) >>= bRightAngledAxes;
m_pCbxRightAngledAxes->SetToggleHdl( LINK( this, ThreeD_SceneGeometry_TabPage, RightAngledAxesToggled ));
m_pCbxRightAngledAxes->Check( bRightAngledAxes );
diff --git a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
index 362f3d9..52451c9 100644
--- a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
@@ -246,11 +246,11 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf
case SCHATTR_BAR_CONNECT:
{
- bool bOldConnectBars = false;
m_bConnectBars = static_cast< const SfxBoolItem & >(
rItemSet.Get( nWhichId )).GetValue();
if( m_bSupportingBarConnectors )
{
+ bool bOldConnectBars = false;
uno::Reference< beans::XPropertySet > xDiagramProperties( ChartModelHelper::findDiagram(m_xChartModel), uno::UNO_QUERY );
if( xDiagramProperties.is() &&
(xDiagramProperties->getPropertyValue( "ConnectBars" ) >>= bOldConnectBars) &&
@@ -265,11 +265,11 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf
case SCHATTR_GROUP_BARS_PER_AXIS:
{
- bool bOldGroupBarsPerAxis = true;
m_bGroupBarsPerAxis = static_cast< const SfxBoolItem & >(
rItemSet.Get( nWhichId )).GetValue();
if( m_bSupportingAxisSideBySide )
{
+ bool bOldGroupBarsPerAxis = true;
uno::Reference< beans::XPropertySet > xDiagramProperties( ChartModelHelper::findDiagram(m_xChartModel), uno::UNO_QUERY );
if( xDiagramProperties.is() &&
(xDiagramProperties->getPropertyValue( "GroupBarsPerAxis" ) >>= bOldGroupBarsPerAxis) &&
diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx
index d60b031..5da75f3 100644
--- a/chart2/source/tools/AxisHelper.cxx
+++ b/chart2/source/tools/AxisHelper.cxx
@@ -823,9 +823,9 @@ std::vector< Reference< XAxis > > AxisHelper::getAllAxesOfCoordinateSystem(
try
{
Reference< XAxis > xAxis( xCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ) );
- bool bAddAxis = true;
if( xAxis.is() )
{
+ bool bAddAxis = true;
if( bOnlyVisible )
{
Reference< beans::XPropertySet > xAxisProp( xAxis, uno::UNO_QUERY );
diff --git a/chart2/source/tools/ThreeDHelper.cxx b/chart2/source/tools/ThreeDHelper.cxx
index 068d3be..1ae9261 100644
--- a/chart2/source/tools/ThreeDHelper.cxx
+++ b/chart2/source/tools/ThreeDHelper.cxx
@@ -46,9 +46,9 @@ namespace
bool lcl_isRightAngledAxesSetAndSupported( const Reference< beans::XPropertySet >& xSceneProperties )
{
- bool bRightAngledAxes = false;
if( xSceneProperties.is() )
{
+ bool bRightAngledAxes = false;
xSceneProperties->getPropertyValue( "RightAngledAxes") >>= bRightAngledAxes;
if(bRightAngledAxes)
{
diff --git a/chart2/source/view/axes/Tickmarks_Equidistant.cxx b/chart2/source/view/axes/Tickmarks_Equidistant.cxx
index de3c7cf..a83a73f 100644
--- a/chart2/source/view/axes/Tickmarks_Equidistant.cxx
+++ b/chart2/source/view/axes/Tickmarks_Equidistant.cxx
@@ -325,10 +325,9 @@ void EquidistantTickFactory::getAllTicks( TickInfoArraysType& rAllTickInfos ) co
aAllTicks[0].realloc(nMaxMajorTickCount);
sal_Int32 nRealMajorTickCount = 0;
- double* pValue = NULL;
for( sal_Int32 nMajorTick=0; nMajorTick<nMaxMajorTickCount; nMajorTick++ )
{
- pValue = this->getMajorTick( nMajorTick );
+ double* pValue = this->getMajorTick( nMajorTick );
if(!pValue)
continue;
aAllTicks[0][nRealMajorTickCount] = *pValue;
diff --git a/chart2/source/view/charttypes/Splines.cxx b/chart2/source/view/charttypes/Splines.cxx
index ee814eb..aaf8454 100644
--- a/chart2/source/view/charttypes/Splines.cxx
+++ b/chart2/source/view/charttypes/Splines.cxx
@@ -481,10 +481,9 @@ void createKnotVector(const lcl_tSizeType n, const sal_uInt32 p, double* t, doub
{
u[j] = 0.0;
}
- double fSum = 0.0;
for (lcl_tSizeType j = 1; j <= n-p; ++j )
{
- fSum = 0.0;
+ double fSum = 0.0;
for (lcl_tSizeType i = j; i <= j+p-1; ++i)
{
fSum += t[i];
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 7fe634b..7d06d0d 100755
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -1938,17 +1938,15 @@ void OpenGL3DRenderer::RenderScreenTextShape()
for (size_t i = 0; i < m_ScreenTextInfoList.size(); i++)
{
TextInfo textInfo = m_ScreenTextInfoList[i];
- //calc the postition and check whether it can be displayed
- float xTrans = 0.0f;
- float yTrans = 0.0f;
+ //calc the position and check whether it can be displayed
if (textInfo.uniqueId)
{
glm::vec3 worldPos = glm::vec3(m_ScrollMoveMatrix * m_GlobalScaleMatrix * glm::vec4(textInfo.pos, 1));
if ((worldPos.x < m_fMinCoordX) || (worldPos.x > m_fMaxCoordX))
continue;
glm::vec4 pos = m_3DProjection * m_3DView * glm::vec4(worldPos, 1);
- xTrans = pos.x / pos.w;
- yTrans = pos.y / pos.w;
+ const float xTrans = pos.x / pos.w;
+ const float yTrans = pos.y / pos.w;
for (int j = 0; j < 12; j++)
{
if (j % 3 == 0)
diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx
index db15072..043cbaa 100644
--- a/chart2/source/view/main/VDataSeries.cxx
+++ b/chart2/source/view/main/VDataSeries.cxx
@@ -520,13 +520,11 @@ void VDataSeries::getMinMaxXValue(double& fMin, double& fMax) const
if(aValuesX.getLength() > 0)
{
- double aValue;
-
fMax = fMin = aValuesX[0];
for (sal_Int32 i = 1; i < aValuesX.getLength(); i++)
{
- aValue = aValuesX[i];
+ const double aValue = aValuesX[i];
if ( aValue > fMax)
{
fMax = aValue;
More information about the Libreoffice-commits
mailing list