[Libreoffice-commits] core.git: canvas/source chart2/source

Noel (via logerrit) logerrit at kemper.freedesktop.org
Thu Oct 1 13:01:33 UTC 2020


 canvas/source/vcl/spritehelper.cxx                                  |    2 +-
 chart2/source/controller/dialogs/DataBrowser.cxx                    |    2 +-
 chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx  |    4 ++--
 chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx |    6 ++----
 chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx  |    4 ++--
 chart2/source/controller/sidebar/ChartAreaPanel.cxx                 |    3 +--
 chart2/source/view/charttypes/CandleStickChart.cxx                  |    3 +--
 chart2/source/view/main/ChartView.cxx                               |    2 +-
 chart2/source/view/main/VDataSeries.cxx                             |    4 ++--
 chart2/source/view/main/VLegend.cxx                                 |    2 +-
 10 files changed, 14 insertions(+), 18 deletions(-)

New commits:
commit 18d4e89fdd63479e20d096c3a578153aa4328aee
Author:     Noel <noelgrandin at gmail.com>
AuthorDate: Thu Oct 1 14:02:05 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Oct 1 15:00:52 2020 +0200

    loplugin:reducevarscope in canvas,chart2
    
    Change-Id: I6c73e609cc8ce0ed9cf0f5a6b68c6e299bf26a44
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103761
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/canvas/source/vcl/spritehelper.cxx b/canvas/source/vcl/spritehelper.cxx
index e52bb211020c..14be26c2aa6c 100644
--- a/canvas/source/vcl/spritehelper.cxx
+++ b/canvas/source/vcl/spritehelper.cxx
@@ -101,7 +101,6 @@ namespace vclcanvas
         if( !isActive() || ::basegfx::fTools::equalZero( fAlpha ) )
             return;
 
-        const Point                 aEmptyPoint;
         const ::basegfx::B2DVector& rOrigOutputSize( getSizePixel() );
 
         // might get changed below (e.g. adapted for
@@ -128,6 +127,7 @@ namespace vclcanvas
 
         if( bNeedBitmapUpdate )
         {
+            const Point aEmptyPoint;
             BitmapEx aBmp( mpBackBuffer->getOutDev().GetBitmapEx( aEmptyPoint,
                                                               aOutputSize ) );
 
diff --git a/chart2/source/controller/dialogs/DataBrowser.cxx b/chart2/source/controller/dialogs/DataBrowser.cxx
index 6f7ada12cbec..89036649c500 100644
--- a/chart2/source/controller/dialogs/DataBrowser.cxx
+++ b/chart2/source/controller/dialogs/DataBrowser.cxx
@@ -699,12 +699,12 @@ OUString DataBrowser::GetCellText( long nRow, sal_uInt16 nColumnId ) const
         if( m_apDataBrowserModel->getCellType( nColIndex ) == DataBrowserModel::NUMBER )
         {
             double fData( m_apDataBrowserModel->getCellNumber( nColIndex, nRow ));
-            Color nLabelColor;
 
             if( ! std::isnan( fData ) &&
                 m_spNumberFormatterWrapper )
             {
                 bool bColorChanged = false;
+                Color nLabelColor;
                 aResult = m_spNumberFormatterWrapper->getFormattedString(
                                       GetNumberFormatKey( nColumnId ),
                                       fData, nLabelColor, bColorChanged );
diff --git a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
index 302c56280fa0..9703f9dd398d 100644
--- a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
@@ -368,9 +368,9 @@ bool DataPointItemConverter::ApplySpecialItem(
         case SCHATTR_DATADESCR_SEPARATOR:
         {
             OUString aNewValue = static_cast< const SfxStringItem & >( rItemSet.Get( nWhichId )).GetValue();
-            OUString aOldValue;
             try
             {
+                OUString aOldValue;
                 GetPropertySet()->getPropertyValue( "LabelSeparator" ) >>= aOldValue;
                 if( m_bOverwriteLabelsForAttributedDataPointsAlso )
                 {
@@ -689,9 +689,9 @@ void DataPointItemConverter::FillSpecialItem(
 
         case SCHATTR_DATADESCR_SEPARATOR:
         {
-            OUString aValue;
             try
             {
+                OUString aValue;
                 GetPropertySet()->getPropertyValue( "LabelSeparator" ) >>= aValue;
                 rOutItemSet.Put( SfxStringItem( nWhichId, aValue ));
             }
diff --git a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
index b4c4405ff88b..c0691daf24cf 100644
--- a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
@@ -107,11 +107,10 @@ uno::Reference< beans::XPropertySet > lcl_getEquationProperties(
     // ensure that a trendline is on
     if( pItemSet )
     {
-        SvxChartRegress eRegress = SvxChartRegress::NONE;
         const SfxPoolItem *pPoolItem = nullptr;
         if( pItemSet->GetItemState( SCHATTR_REGRESSION_TYPE, true, &pPoolItem ) == SfxItemState::SET )
         {
-            eRegress = static_cast< const SvxChartRegressItem * >( pPoolItem )->GetValue();
+            SvxChartRegress eRegress = static_cast< const SvxChartRegressItem * >( pPoolItem )->GetValue();
             bEquationExists = ( eRegress != SvxChartRegress::NONE );
         }
     }
@@ -138,11 +137,10 @@ uno::Reference< beans::XPropertySet > lcl_getCurveProperties(
     // ensure that a trendline is on
     if( pItemSet )
     {
-        SvxChartRegress eRegress = SvxChartRegress::NONE;
         const SfxPoolItem *pPoolItem = nullptr;
         if( pItemSet->GetItemState( SCHATTR_REGRESSION_TYPE, true, &pPoolItem ) == SfxItemState::SET )
         {
-            eRegress = static_cast< const SvxChartRegressItem * >( pPoolItem )->GetValue();
+            SvxChartRegress eRegress = static_cast< const SvxChartRegressItem * >( pPoolItem )->GetValue();
             bExists = ( eRegress != SvxChartRegress::NONE );
         }
     }
diff --git a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
index 5fe31b1bcd5f..1ee04136f45c 100644
--- a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
@@ -314,9 +314,9 @@ bool TextLabelItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxIte
         case SCHATTR_DATADESCR_SEPARATOR:
         {
             OUString aNewValue = static_cast<const SfxStringItem&>(rItemSet.Get(nWhichId)).GetValue();
-            OUString aOldValue;
             try
             {
+                OUString aOldValue;
                 GetPropertySet()->getPropertyValue("LabelSeparator") >>= aOldValue;
                 if (mbDataSeries)
                 {
@@ -601,9 +601,9 @@ void TextLabelItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet& r
         break;
         case SCHATTR_DATADESCR_SEPARATOR:
         {
-            OUString aValue;
             try
             {
+                OUString aValue;
                 GetPropertySet()->getPropertyValue("LabelSeparator") >>= aValue;
                 rOutItemSet.Put(SfxStringItem(nWhichId, aValue));
             }
diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
index 1f6230709efb..de1c21af679a 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
@@ -459,10 +459,9 @@ void ChartAreaPanel::updateData()
         GraphicObject aBitmap = getXBitmapFromName(mxModel, aBitmapName);
         XFillBitmapItem aBitmapItem(aBitmapName, aBitmap);
         std::unique_ptr<XFillBitmapItem> pBitmapItem;
-        DrawModelWrapper* pModelWrapper = nullptr;
         try
         {
-            pModelWrapper = getDrawModelWrapper(mxModel);
+            DrawModelWrapper* pModelWrapper = getDrawModelWrapper(mxModel);
             if (pModelWrapper)
             {
                 pBitmapItem = aBitmapItem.checkForUniqueItem(&pModelWrapper->getSdrModel());
diff --git a/chart2/source/view/charttypes/CandleStickChart.cxx b/chart2/source/view/charttypes/CandleStickChart.cxx
index a82c8896592b..e13c24bf1f27 100644
--- a/chart2/source/view/charttypes/CandleStickChart.cxx
+++ b/chart2/source/view/charttypes/CandleStickChart.cxx
@@ -138,11 +138,10 @@ void CandleStickChart::createShapes()
     {
         for( auto const& rZSlot : m_aZSlots )
         {
-            sal_Int32 nAttachedAxisIndex = 0;
             BarPositionHelper* pPosHelper = m_pMainPosHelper.get();
             if( !rZSlot.empty() )
             {
-                nAttachedAxisIndex = rZSlot.front().getAttachedAxisIndexForFirstSeries();
+                sal_Int32 nAttachedAxisIndex = rZSlot.front().getAttachedAxisIndexForFirstSeries();
                 //2ND_AXIS_IN_BARS so far one can assume to have the same plotter for each z slot
                 pPosHelper = dynamic_cast<BarPositionHelper*>(&( getPlottingPositionHelper( nAttachedAxisIndex ) ) );
                 if(!pPosHelper)
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index bfb7ed2bda20..f713e8b86923 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -930,9 +930,9 @@ void SeriesPlotterContainer::AdaptScaleOfYAxisWithoutAttachedSeries( ChartModel&
             Reference< XAxis > xAxis( xCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ) );
             Reference< beans::XPropertySet > xCrossingMainAxis( AxisHelper::getCrossingMainAxis( xAxis, xCooSys ), uno::UNO_QUERY );
 
-            css::chart::ChartAxisPosition eCrossingMainAxisPos( css::chart::ChartAxisPosition_ZERO );
             if( xCrossingMainAxis.is() )
             {
+                css::chart::ChartAxisPosition eCrossingMainAxisPos( css::chart::ChartAxisPosition_ZERO );
                 xCrossingMainAxis->getPropertyValue("CrossoverPosition") >>= eCrossingMainAxisPos;
                 if( eCrossingMainAxisPos == css::chart::ChartAxisPosition_VALUE )
                 {
diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx
index db93d255fe21..e2f85b71fb83 100644
--- a/chart2/source/view/main/VDataSeries.cxx
+++ b/chart2/source/view/main/VDataSeries.cxx
@@ -554,9 +554,9 @@ bool VDataSeries::hasExplicitNumberFormat( sal_Int32 nPointIndex, bool bForPerce
     bool bHasNumberFormat = false;
     bool bLinkToSource = true;
     uno::Reference< beans::XPropertySet > xPointProp( getPropertiesOfPoint( nPointIndex ));
-    sal_Int32 nNumberFormat = -1;
     if( xPointProp.is() && (xPointProp->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkToSource))
     {
+        sal_Int32 nNumberFormat = -1;
         if( !bLinkToSource && (xPointProp->getPropertyValue(aPropName) >>= nNumberFormat))
             bHasNumberFormat = true;
     }
@@ -653,12 +653,12 @@ awt::Point VDataSeries::getLabelPosition( awt::Point aTextShapePos, sal_Int32 nP
 bool VDataSeries::isLabelCustomPos(sal_Int32 nPointIndex) const
 {
     bool bCustom = false;
-    RelativePosition aCustomLabelPosition;
     try
     {
         if( isAttributedDataPoint(nPointIndex) )
         {
             uno::Reference< beans::XPropertySet > xPointProps(m_xDataSeries->getDataPointByIndex(nPointIndex));
+            RelativePosition aCustomLabelPosition;
             if( xPointProps.is() && (xPointProps->getPropertyValue("CustomLabelPosition") >>= aCustomLabelPosition) )
                 bCustom = true;
         }
diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx
index d16495e426f3..afd4468ef1bf 100644
--- a/chart2/source/view/main/VLegend.cxx
+++ b/chart2/source/view/main/VLegend.cxx
@@ -66,13 +66,13 @@ double lcl_CalcViewFontSize(
 {
     double fResult = 10.0;
 
-    awt::Size aPropRefSize;
     float fFontHeight( 0.0 );
     if( xProp.is() && ( xProp->getPropertyValue( "CharHeight") >>= fFontHeight ))
     {
         fResult = fFontHeight;
         try
         {
+            awt::Size aPropRefSize;
             if( (xProp->getPropertyValue( "ReferencePageSize") >>= aPropRefSize) &&
                 (aPropRefSize.Height > 0))
             {


More information about the Libreoffice-commits mailing list