summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-12-21 13:42:35 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-12-21 15:55:46 +0100
commit25298930bc86d1a449a7e5b139d65e49f695f8c1 (patch)
treeb3f28ef6b18b12347694a637b6785ecb5eedc1fe /chart2
parent1edaee2f03bce0efa409c592919458658d0aa751 (diff)
loplugin:flatten in canvas..cui
Change-Id: I208767eaa60d913fe2882403f1f9351eb08256f7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127224 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/controller/main/ChartController_TextEdit.cxx40
-rw-r--r--chart2/source/controller/main/ChartFrameloader.cxx72
-rw-r--r--chart2/source/tools/AxisHelper.cxx62
-rw-r--r--chart2/source/view/charttypes/PieChart.cxx83
-rw-r--r--chart2/source/view/main/ChartView.cxx57
5 files changed, 158 insertions, 156 deletions
diff --git a/chart2/source/controller/main/ChartController_TextEdit.cxx b/chart2/source/controller/main/ChartController_TextEdit.cxx
index 23b590907f67..524d57762292 100644
--- a/chart2/source/controller/main/ChartController_TextEdit.cxx
+++ b/chart2/source/controller/main/ChartController_TextEdit.cxx
@@ -121,32 +121,32 @@ bool ChartController::EndTextEdit()
SdrOutliner* pOutliner = m_pDrawViewWrapper->getOutliner();
OutlinerParaObject* pParaObj = pTextObject->GetOutlinerParaObject();
- if( pParaObj && pOutliner )
- {
- pOutliner->SetText( *pParaObj );
+ if( !pParaObj || !pOutliner )
+ return true;
- OUString aString = pOutliner->GetText(
- pOutliner->GetParagraph( 0 ),
- pOutliner->GetParagraphCount() );
+ pOutliner->SetText( *pParaObj );
- OUString aObjectCID = m_aSelection.getSelectedCID();
- if ( !aObjectCID.isEmpty() )
- {
- uno::Reference< beans::XPropertySet > xPropSet =
- ObjectIdentifier::getObjectPropertySet( aObjectCID, getModel() );
+ OUString aString = pOutliner->GetText(
+ pOutliner->GetParagraph( 0 ),
+ pOutliner->GetParagraphCount() );
- // lock controllers till end of block
- ControllerLockGuardUNO aCLGuard( getModel() );
+ OUString aObjectCID = m_aSelection.getSelectedCID();
+ if ( !aObjectCID.isEmpty() )
+ {
+ uno::Reference< beans::XPropertySet > xPropSet =
+ ObjectIdentifier::getObjectPropertySet( aObjectCID, getModel() );
- TitleHelper::setCompleteString( aString, uno::Reference<
- css::chart2::XTitle >::query( xPropSet ), m_xCC );
+ // lock controllers till end of block
+ ControllerLockGuardUNO aCLGuard( getModel() );
- OSL_ENSURE(m_pTextActionUndoGuard, "ChartController::EndTextEdit: no TextUndoGuard!");
- if (m_pTextActionUndoGuard)
- m_pTextActionUndoGuard->commit();
- }
- m_pTextActionUndoGuard.reset();
+ TitleHelper::setCompleteString( aString, uno::Reference<
+ css::chart2::XTitle >::query( xPropSet ), m_xCC );
+
+ OSL_ENSURE(m_pTextActionUndoGuard, "ChartController::EndTextEdit: no TextUndoGuard!");
+ if (m_pTextActionUndoGuard)
+ m_pTextActionUndoGuard->commit();
}
+ m_pTextActionUndoGuard.reset();
return true;
}
diff --git a/chart2/source/controller/main/ChartFrameloader.cxx b/chart2/source/controller/main/ChartFrameloader.cxx
index f598a7fff4a7..991c6a87e00f 100644
--- a/chart2/source/controller/main/ChartFrameloader.cxx
+++ b/chart2/source/controller/main/ChartFrameloader.cxx
@@ -134,49 +134,51 @@ sal_Bool SAL_CALL ChartFrameLoader::load( const uno::Sequence< beans::PropertyVa
}
// call initNew() or load() at XLoadable
- if(!bHaveLoadedModel)
- try
+ if(bHaveLoadedModel)
+ return true;
+
+ try
+ {
+ utl::MediaDescriptor::const_iterator aIt( aMediaDescriptor.find( utl::MediaDescriptor::PROP_URL));
+ if( aIt != aMediaDescriptor.end())
{
- utl::MediaDescriptor::const_iterator aIt( aMediaDescriptor.find( utl::MediaDescriptor::PROP_URL));
- if( aIt != aMediaDescriptor.end())
+ OUString aURL( (*aIt).second.get< OUString >());
+ if( aURL.startsWith( "private:factory/schart" ) )
+ {
+ // create new file
+ uno::Reference< frame::XLoadable > xLoadable( xModel, uno::UNO_QUERY_THROW );
+ xLoadable->initNew();
+ }
+ else
{
- OUString aURL( (*aIt).second.get< OUString >());
- if( aURL.startsWith( "private:factory/schart" ) )
+ // use the URL as BaseURL, similar to what SfxBaseModel effectively does
+ if (!aURL.isEmpty())
{
- // create new file
- uno::Reference< frame::XLoadable > xLoadable( xModel, uno::UNO_QUERY_THROW );
- xLoadable->initNew();
+ aMediaDescriptor[utl::MediaDescriptor::PROP_DOCUMENTBASEURL] <<= aURL;
}
- else
+ aMediaDescriptor.addInputStream();
+ uno::Sequence< beans::PropertyValue > aCompleteMediaDescriptor;
+ aMediaDescriptor >> aCompleteMediaDescriptor;
+ apphelper::MediaDescriptorHelper aMDHelper( aCompleteMediaDescriptor );
+
+ // load file
+ // @todo: replace: aMediaDescriptorHelper.getReducedForModel()
+ uno::Reference< frame::XLoadable > xLoadable( xModel, uno::UNO_QUERY_THROW );
+ xLoadable->load( aCompleteMediaDescriptor );
+
+ //resize standalone files to get correct size:
+ if( xComponentWindow.is() && aMDHelper.ISSET_FilterName && aMDHelper.FilterName == "StarChart 5.0" )
{
- // use the URL as BaseURL, similar to what SfxBaseModel effectively does
- if (!aURL.isEmpty())
- {
- aMediaDescriptor[utl::MediaDescriptor::PROP_DOCUMENTBASEURL] <<= aURL;
- }
- aMediaDescriptor.addInputStream();
- uno::Sequence< beans::PropertyValue > aCompleteMediaDescriptor;
- aMediaDescriptor >> aCompleteMediaDescriptor;
- apphelper::MediaDescriptorHelper aMDHelper( aCompleteMediaDescriptor );
-
- // load file
- // @todo: replace: aMediaDescriptorHelper.getReducedForModel()
- uno::Reference< frame::XLoadable > xLoadable( xModel, uno::UNO_QUERY_THROW );
- xLoadable->load( aCompleteMediaDescriptor );
-
- //resize standalone files to get correct size:
- if( xComponentWindow.is() && aMDHelper.ISSET_FilterName && aMDHelper.FilterName == "StarChart 5.0" )
- {
- awt::Rectangle aRect( xComponentWindow->getPosSize() );
- xComponentWindow->setPosSize( aRect.X, aRect.Y, aRect.Width, aRect.Height, 0 );
- }
+ awt::Rectangle aRect( xComponentWindow->getPosSize() );
+ xComponentWindow->setPosSize( aRect.X, aRect.Y, aRect.Width, aRect.Height, 0 );
}
}
}
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
return true;
}
diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx
index 4c6c5dd0e8cd..276abb5dbc47 100644
--- a/chart2/source/tools/AxisHelper.cxx
+++ b/chart2/source/tools/AxisHelper.cxx
@@ -743,23 +743,23 @@ bool AxisHelper::getIndicesForAxis(
rOutDimensionIndex = -1;
rOutAxisIndex = -1;
- if( xCooSys.is() && xAxis.is() )
+ if( !xCooSys || !xAxis )
+ return false;
+
+ Reference< XAxis > xCurrentAxis;
+ sal_Int32 nDimensionCount( xCooSys->getDimension() );
+ for( sal_Int32 nDimensionIndex = 0; nDimensionIndex < nDimensionCount; nDimensionIndex++ )
{
- Reference< XAxis > xCurrentAxis;
- sal_Int32 nDimensionCount( xCooSys->getDimension() );
- for( sal_Int32 nDimensionIndex = 0; nDimensionIndex < nDimensionCount; nDimensionIndex++ )
+ sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nDimensionIndex);
+ for( sal_Int32 nAxisIndex = 0; nAxisIndex <= nMaxAxisIndex; nAxisIndex++ )
{
- sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nDimensionIndex);
- for( sal_Int32 nAxisIndex = 0; nAxisIndex <= nMaxAxisIndex; nAxisIndex++ )
- {
- xCurrentAxis = xCooSys->getAxisByDimension(nDimensionIndex,nAxisIndex);
- if( xCurrentAxis == xAxis )
- {
- rOutDimensionIndex = nDimensionIndex;
- rOutAxisIndex = nAxisIndex;
- return true;
- }
- }
+ xCurrentAxis = xCooSys->getAxisByDimension(nDimensionIndex,nAxisIndex);
+ if( xCurrentAxis == xAxis )
+ {
+ rOutDimensionIndex = nDimensionIndex;
+ rOutAxisIndex = nAxisIndex;
+ return true;
+ }
}
}
return false;
@@ -904,25 +904,25 @@ void AxisHelper::getAxisOrGridPossibilities( Sequence< sal_Bool >& rPossibilityL
bool AxisHelper::isSecondaryYAxisNeeded( const Reference< XCoordinateSystem >& xCooSys )
{
Reference< chart2::XChartTypeContainer > xCTCnt( xCooSys, uno::UNO_QUERY );
- if( xCTCnt.is() )
+ if( !xCTCnt.is() )
+ return false;
+
+ const Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes() );
+ for( Reference< chart2::XChartType > const & chartType : aChartTypes )
{
- const Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes() );
- for( Reference< chart2::XChartType > const & chartType : aChartTypes )
- {
- Reference< XDataSeriesContainer > xSeriesContainer( chartType, uno::UNO_QUERY );
- if( !xSeriesContainer.is() )
- continue;
+ Reference< XDataSeriesContainer > xSeriesContainer( chartType, uno::UNO_QUERY );
+ if( !xSeriesContainer.is() )
+ continue;
- Sequence< Reference< XDataSeries > > aSeriesList( xSeriesContainer->getDataSeries() );
- for( sal_Int32 nS = aSeriesList.getLength(); nS-- ; )
+ Sequence< Reference< XDataSeries > > aSeriesList( xSeriesContainer->getDataSeries() );
+ for( sal_Int32 nS = aSeriesList.getLength(); nS-- ; )
+ {
+ Reference< beans::XPropertySet > xProp( aSeriesList[nS], uno::UNO_QUERY );
+ if(xProp.is())
{
- Reference< beans::XPropertySet > xProp( aSeriesList[nS], uno::UNO_QUERY );
- if(xProp.is())
- {
- sal_Int32 nAttachedAxisIndex = 0;
- if( ( xProp->getPropertyValue( "AttachedAxisIndex" ) >>= nAttachedAxisIndex ) && nAttachedAxisIndex>0 )
- return true;
- }
+ sal_Int32 nAttachedAxisIndex = 0;
+ if( ( xProp->getPropertyValue( "AttachedAxisIndex" ) >>= nAttachedAxisIndex ) && nAttachedAxisIndex>0 )
+ return true;
}
}
}
diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx
index 57dbab089e00..331b5e4da107 100644
--- a/chart2/source/view/charttypes/PieChart.cxx
+++ b/chart2/source/view/charttypes/PieChart.cxx
@@ -914,48 +914,49 @@ bool PieChart::PieLabelInfo::moveAwayFrom( const PieChart::PieLabelInfo* pFix, c
///boxes (`aOverlap`).
::basegfx::B2IRectangle aOverlap( lcl_getRect( xLabelGroupShape ) );
aOverlap.intersect( lcl_getRect( pFix->xLabelGroupShape ) );
- if( !aOverlap.isEmpty() )
- {
- //TODO: alternative move direction
-
- ///the label is shifted along the direction orthogonal to the vector
- ///starting at the pie/donut center and ending at this label anchor
- ///point;
-
- ///named `aTangentialDirection` the unit vector related to such a
- ///direction, the magnitude of the shift along such a direction is
- ///calculated in this way: if the horizontal component of
- ///`aTangentialDirection` is greater than the vertical component,
- ///the magnitude of the shift is equal to `aOverlap.Width` else to
- ///`aOverlap.Height`;
- basegfx::B2IVector aRadiusDirection = aFirstPosition - aOrigin;
- aRadiusDirection.setLength(1.0);
- basegfx::B2IVector aTangentialDirection( -aRadiusDirection.getY(), aRadiusDirection.getX() );
- bool bShiftHorizontal = abs(aTangentialDirection.getX()) > abs(aTangentialDirection.getY());
- sal_Int32 nShift = bShiftHorizontal ? static_cast<sal_Int32>(aOverlap.getWidth()) : static_cast<sal_Int32>(aOverlap.getHeight());
- ///the magnitude of the shift is also increased by 1/50-th of the width
- ///or the height of the document page;
- nShift += (bShiftHorizontal ? nLabelDistanceX : nLabelDistanceY);
- ///in case the `bMoveHalfWay` parameter is true the magnitude of
- ///the shift is halved.
- if( bMoveHalfWay )
- nShift/=2;
- ///in case the `bMoveClockwise` parameter is false the direction of
- ///`aTangentialDirection` is reversed;
- if(!bMoveClockwise)
- nShift*=-1;
- awt::Point aOldPos( xLabelGroupShape->getPosition() );
- basegfx::B2IVector aNewPos = basegfx::B2IVector( aOldPos.X, aOldPos.Y ) + nShift*aTangentialDirection;
-
- ///a final check is performed in order to be sure that the moved label
- ///is still inside the page document;
- awt::Point aNewAWTPos( aNewPos.getX(), aNewPos.getY() );
- if( !lcl_isInsidePage( aNewAWTPos, xLabelGroupShape->getSize(), rPageSize ) )
- return false;
+ if( aOverlap.isEmpty() )
+ return true;
+
+ //TODO: alternative move direction
+
+ ///the label is shifted along the direction orthogonal to the vector
+ ///starting at the pie/donut center and ending at this label anchor
+ ///point;
+
+ ///named `aTangentialDirection` the unit vector related to such a
+ ///direction, the magnitude of the shift along such a direction is
+ ///calculated in this way: if the horizontal component of
+ ///`aTangentialDirection` is greater than the vertical component,
+ ///the magnitude of the shift is equal to `aOverlap.Width` else to
+ ///`aOverlap.Height`;
+ basegfx::B2IVector aRadiusDirection = aFirstPosition - aOrigin;
+ aRadiusDirection.setLength(1.0);
+ basegfx::B2IVector aTangentialDirection( -aRadiusDirection.getY(), aRadiusDirection.getX() );
+ bool bShiftHorizontal = abs(aTangentialDirection.getX()) > abs(aTangentialDirection.getY());
+ sal_Int32 nShift = bShiftHorizontal ? static_cast<sal_Int32>(aOverlap.getWidth()) : static_cast<sal_Int32>(aOverlap.getHeight());
+ ///the magnitude of the shift is also increased by 1/50-th of the width
+ ///or the height of the document page;
+ nShift += (bShiftHorizontal ? nLabelDistanceX : nLabelDistanceY);
+ ///in case the `bMoveHalfWay` parameter is true the magnitude of
+ ///the shift is halved.
+ if( bMoveHalfWay )
+ nShift/=2;
+ ///in case the `bMoveClockwise` parameter is false the direction of
+ ///`aTangentialDirection` is reversed;
+ if(!bMoveClockwise)
+ nShift*=-1;
+ awt::Point aOldPos( xLabelGroupShape->getPosition() );
+ basegfx::B2IVector aNewPos = basegfx::B2IVector( aOldPos.X, aOldPos.Y ) + nShift*aTangentialDirection;
+
+ ///a final check is performed in order to be sure that the moved label
+ ///is still inside the page document;
+ awt::Point aNewAWTPos( aNewPos.getX(), aNewPos.getY() );
+ if( !lcl_isInsidePage( aNewAWTPos, xLabelGroupShape->getSize(), rPageSize ) )
+ return false;
+
+ xLabelGroupShape->setPosition( aNewAWTPos );
+ bMoved = true;
- xLabelGroupShape->setPosition( aNewAWTPos );
- bMoved = true;
- }
return true;
///note that no further test is performed in order to check that the
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 2387e297b54e..bc76dcf585ca 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -1684,39 +1684,38 @@ bool ChartView::getExplicitValuesForAxis(
sal_Int32 nDimensionIndex=-1;
sal_Int32 nAxisIndex=-1;
- if( AxisHelper::getIndicesForAxis( xAxis, xCooSys, nDimensionIndex, nAxisIndex ) )
+ if( !AxisHelper::getIndicesForAxis( xAxis, xCooSys, nDimensionIndex, nAxisIndex ) )
+ return false;
+
+ rExplicitScale = pVCooSys->getExplicitScale(nDimensionIndex,nAxisIndex);
+ rExplicitIncrement = pVCooSys->getExplicitIncrement(nDimensionIndex,nAxisIndex);
+ if( !rExplicitScale.m_bShiftedCategoryPosition )
+ return true;
+
+ //remove 'one' from max
+ if( rExplicitScale.AxisType == css::chart2::AxisType::DATE )
{
- rExplicitScale = pVCooSys->getExplicitScale(nDimensionIndex,nAxisIndex);
- rExplicitIncrement = pVCooSys->getExplicitIncrement(nDimensionIndex,nAxisIndex);
- if( rExplicitScale.m_bShiftedCategoryPosition )
+ Date aMaxDate(rExplicitScale.NullDate); aMaxDate.AddDays(::rtl::math::approxFloor(rExplicitScale.Maximum));
+ //for explicit scales with shifted categories we need one interval more
+ switch( rExplicitScale.TimeResolution )
{
- //remove 'one' from max
- if( rExplicitScale.AxisType == css::chart2::AxisType::DATE )
- {
- Date aMaxDate(rExplicitScale.NullDate); aMaxDate.AddDays(::rtl::math::approxFloor(rExplicitScale.Maximum));
- //for explicit scales with shifted categories we need one interval more
- switch( rExplicitScale.TimeResolution )
- {
- case css::chart::TimeUnit::DAY:
- --aMaxDate;
- break;
- case css::chart::TimeUnit::MONTH:
- aMaxDate = DateHelper::GetDateSomeMonthsAway(aMaxDate,-1);
- break;
- case css::chart::TimeUnit::YEAR:
- aMaxDate = DateHelper::GetDateSomeYearsAway(aMaxDate,-1);
- break;
- }
- rExplicitScale.Maximum = aMaxDate - rExplicitScale.NullDate;
- }
- else if( rExplicitScale.AxisType == css::chart2::AxisType::CATEGORY )
- rExplicitScale.Maximum -= 1.0;
- else if( rExplicitScale.AxisType == css::chart2::AxisType::SERIES )
- rExplicitScale.Maximum -= 1.0;
+ case css::chart::TimeUnit::DAY:
+ --aMaxDate;
+ break;
+ case css::chart::TimeUnit::MONTH:
+ aMaxDate = DateHelper::GetDateSomeMonthsAway(aMaxDate,-1);
+ break;
+ case css::chart::TimeUnit::YEAR:
+ aMaxDate = DateHelper::GetDateSomeYearsAway(aMaxDate,-1);
+ break;
}
- return true;
+ rExplicitScale.Maximum = aMaxDate - rExplicitScale.NullDate;
}
- return false;
+ else if( rExplicitScale.AxisType == css::chart2::AxisType::CATEGORY )
+ rExplicitScale.Maximum -= 1.0;
+ else if( rExplicitScale.AxisType == css::chart2::AxisType::SERIES )
+ rExplicitScale.Maximum -= 1.0;
+ return true;
}
SdrPage* ChartView::getSdrPage()