summaryrefslogtreecommitdiff
path: root/chart2/source/tools/DiagramHelper.cxx
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-09-19 11:53:18 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-09-19 13:46:08 -0400
commite55fd119c0eb9ecbbda1a95902f888a795bf8345 (patch)
tree2ad049e6a87a2912f06223f3bfad0a220f860b76 /chart2/source/tools/DiagramHelper.cxx
parent4e58aa02bf7a61804a64626cf9b9d3f36a1959da (diff)
More scope reduction.
Change-Id: Ibaabf1122fb3e828c1b7b71e846911d77f312445
Diffstat (limited to 'chart2/source/tools/DiagramHelper.cxx')
-rw-r--r--chart2/source/tools/DiagramHelper.cxx153
1 files changed, 77 insertions, 76 deletions
diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx
index dec53afaa768..765937b80a72 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -136,66 +136,67 @@ void DiagramHelper::setVertical(
try
{
Reference< XCoordinateSystemContainer > xCnt( xDiagram, uno::UNO_QUERY );
- if( xCnt.is())
+ if (!xCnt.is())
+ return;
+
+ Sequence< Reference<XCoordinateSystem> > aCooSys = xCnt->getCoordinateSystems();
+ uno::Any aValue;
+ aValue <<= bVertical;
+ for( sal_Int32 i=0; i<aCooSys.getLength(); ++i )
{
- Sequence< Reference< XCoordinateSystem > > aCooSys(
- xCnt->getCoordinateSystems());
- uno::Any aValue;
- aValue <<= bVertical;
- for( sal_Int32 i=0; i<aCooSys.getLength(); ++i )
+ uno::Reference< XCoordinateSystem > xCooSys( aCooSys[i] );
+ Reference< beans::XPropertySet > xProp( xCooSys, uno::UNO_QUERY );
+ bool bChanged = false;
+ if (xProp.is())
{
- uno::Reference< XCoordinateSystem > xCooSys( aCooSys[i] );
- Reference< beans::XPropertySet > xProp( xCooSys, uno::UNO_QUERY );
- bool bChanged = false;
- if( xProp.is() )
- {
- bool bOldSwap = false;
- if( !(xProp->getPropertyValue( "SwapXAndYAxis" ) >>= bOldSwap)
- || bVertical != bOldSwap )
- bChanged = true;
+ bool bOldSwap = false;
+ if( !(xProp->getPropertyValue("SwapXAndYAxis") >>= bOldSwap)
+ || bVertical != bOldSwap )
+ bChanged = true;
- if( bChanged )
- xProp->setPropertyValue( "SwapXAndYAxis", aValue );
- }
- if( xCooSys.is() )
+ if( bChanged )
+ xProp->setPropertyValue("SwapXAndYAxis", aValue);
+ }
+
+ if (!xCooSys.is())
+ continue;
+
+ const sal_Int32 nDimensionCount = xCooSys->getDimension();
+ sal_Int32 nDimIndex = 0;
+ for (nDimIndex=0; nDimIndex < nDimensionCount; ++nDimIndex)
+ {
+ const sal_Int32 nMaximumScaleIndex = xCooSys->getMaximumAxisIndexByDimension(nDimIndex);
+ for (sal_Int32 nI = 0; nI <= nMaximumScaleIndex; ++nI)
{
- const sal_Int32 nDimensionCount( xCooSys->getDimension() );
- sal_Int32 nDimIndex = 0;
- for(nDimIndex=0; nDimIndex<nDimensionCount; ++nDimIndex)
- {
- const sal_Int32 nMaximumScaleIndex = xCooSys->getMaximumAxisIndexByDimension(nDimIndex);
- for(sal_Int32 nI=0; nI<=nMaximumScaleIndex; ++nI)
- {
- Reference< chart2::XAxis > xAxis( xCooSys->getAxisByDimension( nDimIndex,nI ));
- if( xAxis.is() )
- {
- //adapt title rotation only when axis swapping has changed
- if( bChanged )
- {
- Reference< XTitled > xTitled( xAxis, uno::UNO_QUERY );
- if( xTitled.is())
- {
- Reference< beans::XPropertySet > xTitleProps( xTitled->getTitleObject(), uno::UNO_QUERY );
- if( !xTitleProps.is() )
- continue;
- double fAngleDegree = 0.0;
- xTitleProps->getPropertyValue( "TextRotation" ) >>= fAngleDegree;
- if( !::rtl::math::approxEqual( fAngleDegree, 0.0 )
- && !::rtl::math::approxEqual( fAngleDegree, 90.0 ) )
- continue;
-
- double fNewAngleDegree = 0.0;
- if( !bVertical && nDimIndex == 1 )
- fNewAngleDegree = 90.0;
- else if( bVertical && nDimIndex == 0 )
- fNewAngleDegree = 90.0;
-
- xTitleProps->setPropertyValue( "TextRotation", uno::makeAny( fNewAngleDegree ));
- }
- }
- }
- }
- }
+ Reference<chart2::XAxis> xAxis = xCooSys->getAxisByDimension(nDimIndex,nI);
+ if (!xAxis.is())
+ continue;
+
+ //adapt title rotation only when axis swapping has changed
+ if (!bChanged)
+ continue;
+
+ Reference< XTitled > xTitled( xAxis, uno::UNO_QUERY );
+ if (!xTitled.is())
+ continue;
+
+ Reference< beans::XPropertySet > xTitleProps( xTitled->getTitleObject(), uno::UNO_QUERY );
+ if (!xTitleProps.is())
+ continue;
+
+ double fAngleDegree = 0.0;
+ xTitleProps->getPropertyValue("TextRotation") >>= fAngleDegree;
+ if (!rtl::math::approxEqual(fAngleDegree, 0.0) &&
+ !rtl::math::approxEqual(fAngleDegree, 90.0))
+ continue;
+
+ double fNewAngleDegree = 0.0;
+ if( !bVertical && nDimIndex == 1 )
+ fNewAngleDegree = 90.0;
+ else if( bVertical && nDimIndex == 0 )
+ fNewAngleDegree = 90.0;
+
+ xTitleProps->setPropertyValue("TextRotation", uno::makeAny(fNewAngleDegree));
}
}
}
@@ -214,29 +215,29 @@ bool DiagramHelper::getVertical( const uno::Reference< chart2::XDiagram > & xDia
rbAmbiguous = false;
Reference< XCoordinateSystemContainer > xCnt( xDiagram, uno::UNO_QUERY );
- if( xCnt.is())
+ if (!xCnt.is())
+ return false;
+
+ Sequence< Reference<XCoordinateSystem> > aCooSys = xCnt->getCoordinateSystems();
+
+ for (sal_Int32 i = 0; i < aCooSys.getLength(); ++i)
{
- Sequence< Reference< XCoordinateSystem > > aCooSys(
- xCnt->getCoordinateSystems());
- for( sal_Int32 i=0; i<aCooSys.getLength(); ++i )
+ Reference<beans::XPropertySet> xProp(aCooSys[i], uno::UNO_QUERY);
+ if (!xProp.is())
+ continue;
+
+ bool bCurrent = false;
+ if (xProp->getPropertyValue("SwapXAndYAxis") >>= bCurrent)
{
- Reference< beans::XPropertySet > xProp( aCooSys[i], uno::UNO_QUERY );
- if( xProp.is())
+ if (!rbFound)
{
- bool bCurrent = false;
- if( xProp->getPropertyValue( "SwapXAndYAxis" ) >>= bCurrent )
- {
- if( !rbFound )
- {
- bValue = bCurrent;
- rbFound = true;
- }
- else if( bCurrent != bValue )
- {
- // ambiguous -> choose always first found
- rbAmbiguous = true;
- }
- }
+ bValue = bCurrent;
+ rbFound = true;
+ }
+ else if (bCurrent != bValue)
+ {
+ // ambiguous -> choose always first found
+ rbAmbiguous = true;
}
}
}