Kaydet (Commit) e942fbfa authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Scope reduction.

Change-Id: Ie92743a05c857f0cbb5e812d8341127d29d18202
üst 1c16a1e6
...@@ -1381,50 +1381,50 @@ void VCartesianAxis::createLabels() ...@@ -1381,50 +1381,50 @@ void VCartesianAxis::createLabels()
return; return;
//create labels //create labels
if( m_aAxisProperties.m_bDisplayLabels ) if (!m_aAxisProperties.m_bDisplayLabels)
{ return;
boost::scoped_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() );
TickFactory_2D* pTickFactory2D = apTickFactory2D.get();
if( !pTickFactory2D )
return;
//get the transformed screen values for all tickmarks in aAllTickInfos boost::scoped_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() );
pTickFactory2D->updateScreenValues( m_aAllTickInfos ); TickFactory_2D* pTickFactory2D = apTickFactory2D.get();
//'hide' tickmarks with identical screen values in aAllTickInfos if( !pTickFactory2D )
hideIdenticalScreenValues( m_aAllTickInfos ); return;
removeTextShapesFromTicks(); //get the transformed screen values for all tickmarks in aAllTickInfos
pTickFactory2D->updateScreenValues( m_aAllTickInfos );
//'hide' tickmarks with identical screen values in aAllTickInfos
hideIdenticalScreenValues( m_aAllTickInfos );
//create tick mark text shapes removeTextShapesFromTicks();
sal_Int32 nTextLevelCount = getTextLevelCount();
sal_Int32 nScreenDistanceBetweenTicks = -1; //create tick mark text shapes
for( sal_Int32 nTextLevel=0; nTextLevel<nTextLevelCount; nTextLevel++ ) sal_Int32 nTextLevelCount = getTextLevelCount();
sal_Int32 nScreenDistanceBetweenTicks = -1;
for( sal_Int32 nTextLevel=0; nTextLevel<nTextLevelCount; nTextLevel++ )
{
boost::scoped_ptr< TickIter > apTickIter(createLabelTickIterator( nTextLevel ));
if(apTickIter)
{ {
boost::scoped_ptr< TickIter > apTickIter(createLabelTickIterator( nTextLevel )); if(nTextLevel==0)
if(apTickIter)
{ {
if(nTextLevel==0) nScreenDistanceBetweenTicks = TickFactory_2D::getTickScreenDistance( *apTickIter.get() );
{ if( nTextLevelCount>1 )
nScreenDistanceBetweenTicks = TickFactory_2D::getTickScreenDistance( *apTickIter.get() ); nScreenDistanceBetweenTicks*=2; //the above used tick iter does contain also the sub ticks -> thus the given distance is only the half
if( nTextLevelCount>1 ) }
nScreenDistanceBetweenTicks*=2; //the above used tick iter does contain also the sub ticks -> thus the given distance is only the half
}
AxisLabelProperties aComplexProps(m_aAxisLabelProperties); AxisLabelProperties aComplexProps(m_aAxisLabelProperties);
if( m_aAxisProperties.m_bComplexCategories ) if( m_aAxisProperties.m_bComplexCategories )
{ {
aComplexProps.bLineBreakAllowed = true; aComplexProps.bLineBreakAllowed = true;
aComplexProps.bOverlapAllowed = !::rtl::math::approxEqual( aComplexProps.fRotationAngleDegree, 0.0 ); aComplexProps.bOverlapAllowed = !::rtl::math::approxEqual( aComplexProps.fRotationAngleDegree, 0.0 );
}
AxisLabelProperties& rAxisLabelProperties = m_aAxisProperties.m_bComplexCategories ? aComplexProps : m_aAxisLabelProperties;
while( !createTextShapes( m_xTextTarget, *apTickIter.get(), rAxisLabelProperties, pTickFactory2D, nScreenDistanceBetweenTicks ) )
{
};
} }
AxisLabelProperties& rAxisLabelProperties = m_aAxisProperties.m_bComplexCategories ? aComplexProps : m_aAxisLabelProperties;
while( !createTextShapes( m_xTextTarget, *apTickIter.get(), rAxisLabelProperties, pTickFactory2D, nScreenDistanceBetweenTicks ) )
{
};
} }
doStaggeringOfLabels( m_aAxisLabelProperties, pTickFactory2D );
} }
doStaggeringOfLabels( m_aAxisLabelProperties, pTickFactory2D );
} }
void VCartesianAxis::createMaximumLabels() void VCartesianAxis::createMaximumLabels()
...@@ -1435,108 +1435,109 @@ void VCartesianAxis::createMaximumLabels() ...@@ -1435,108 +1435,109 @@ void VCartesianAxis::createMaximumLabels()
return; return;
//create labels //create labels
if( m_aAxisProperties.m_bDisplayLabels ) if (!m_aAxisProperties.m_bDisplayLabels)
return;
boost::scoped_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() );
TickFactory_2D* pTickFactory2D = apTickFactory2D.get();
if( !pTickFactory2D )
return;
//get the transformed screen values for all tickmarks in aAllTickInfos
pTickFactory2D->updateScreenValues( m_aAllTickInfos );
//create tick mark text shapes
//@todo: iterate through all tick depth which should be labeled
AxisLabelProperties aAxisLabelProperties( m_aAxisLabelProperties );
if( isAutoStaggeringOfLabelsAllowed( aAxisLabelProperties, pTickFactory2D->isHorizontalAxis(), pTickFactory2D->isVerticalAxis() ) )
aAxisLabelProperties.eStaggering = STAGGER_EVEN;
aAxisLabelProperties.bOverlapAllowed = true;
aAxisLabelProperties.bLineBreakAllowed = false;
sal_Int32 nTextLevelCount = getTextLevelCount();
for( sal_Int32 nTextLevel=0; nTextLevel<nTextLevelCount; nTextLevel++ )
{ {
boost::scoped_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() ); boost::scoped_ptr< TickIter > apTickIter(createMaximumLabelTickIterator( nTextLevel ));
TickFactory_2D* pTickFactory2D = apTickFactory2D.get(); if(apTickIter)
if( !pTickFactory2D )
return;
//get the transformed screen values for all tickmarks in aAllTickInfos
pTickFactory2D->updateScreenValues( m_aAllTickInfos );
//create tick mark text shapes
//@todo: iterate through all tick depth which should be labeled
AxisLabelProperties aAxisLabelProperties( m_aAxisLabelProperties );
if( isAutoStaggeringOfLabelsAllowed( aAxisLabelProperties, pTickFactory2D->isHorizontalAxis(), pTickFactory2D->isVerticalAxis() ) )
aAxisLabelProperties.eStaggering = STAGGER_EVEN;
aAxisLabelProperties.bOverlapAllowed = true;
aAxisLabelProperties.bLineBreakAllowed = false;
sal_Int32 nTextLevelCount = getTextLevelCount();
for( sal_Int32 nTextLevel=0; nTextLevel<nTextLevelCount; nTextLevel++ )
{ {
boost::scoped_ptr< TickIter > apTickIter(createMaximumLabelTickIterator( nTextLevel )); while( !createTextShapes( m_xTextTarget, *apTickIter.get(), aAxisLabelProperties, pTickFactory2D, -1 ) )
if(apTickIter)
{ {
while( !createTextShapes( m_xTextTarget, *apTickIter.get(), aAxisLabelProperties, pTickFactory2D, -1 ) ) };
{
};
}
} }
doStaggeringOfLabels( aAxisLabelProperties, pTickFactory2D );
} }
doStaggeringOfLabels( aAxisLabelProperties, pTickFactory2D );
} }
void VCartesianAxis::updatePositions() void VCartesianAxis::updatePositions()
{ {
//update positions of labels //update positions of labels
if( m_aAxisProperties.m_bDisplayLabels ) if (!m_aAxisProperties.m_bDisplayLabels)
{ return;
boost::scoped_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() );
TickFactory_2D* pTickFactory2D = apTickFactory2D.get(); boost::scoped_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() );
if( !pTickFactory2D ) TickFactory_2D* pTickFactory2D = apTickFactory2D.get();
return; if( !pTickFactory2D )
return;
//update positions of all existing text shapes //update positions of all existing text shapes
pTickFactory2D->updateScreenValues( m_aAllTickInfos ); pTickFactory2D->updateScreenValues( m_aAllTickInfos );
::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = m_aAllTickInfos.begin(); ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = m_aAllTickInfos.begin();
const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = m_aAllTickInfos.end(); const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = m_aAllTickInfos.end();
for( sal_Int32 nDepth=0; aDepthIter != aDepthEnd; ++aDepthIter, nDepth++ ) for( sal_Int32 nDepth=0; aDepthIter != aDepthEnd; ++aDepthIter, nDepth++ )
{
::std::vector< TickInfo >::iterator aTickIter = aDepthIter->begin();
const ::std::vector< TickInfo >::const_iterator aTickEnd = aDepthIter->end();
for( ; aTickIter != aTickEnd; ++aTickIter )
{ {
::std::vector< TickInfo >::iterator aTickIter = aDepthIter->begin(); TickInfo& rTickInfo = (*aTickIter);
const ::std::vector< TickInfo >::const_iterator aTickEnd = aDepthIter->end(); Reference< drawing::XShape > xShape2DText( rTickInfo.xTextShape );
for( ; aTickIter != aTickEnd; ++aTickIter ) if( xShape2DText.is() )
{ {
TickInfo& rTickInfo = (*aTickIter); B2DVector aTextToTickDistance( pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties, true ) );
Reference< drawing::XShape > xShape2DText( rTickInfo.xTextShape ); B2DVector aTickScreenPos2D( rTickInfo.aTickScreenPosition );
if( xShape2DText.is() ) aTickScreenPos2D += aTextToTickDistance;
awt::Point aAnchorScreenPosition2D(
static_cast<sal_Int32>(aTickScreenPos2D.getX())
,static_cast<sal_Int32>(aTickScreenPos2D.getY()));
double fRotationAngleDegree = m_aAxisLabelProperties.fRotationAngleDegree;
if( nDepth > 0 )
{ {
B2DVector aTextToTickDistance( pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties, true ) ); /* Multi-level Labels: default to 0 or 90 */
B2DVector aTickScreenPos2D( rTickInfo.aTickScreenPosition ); if( pTickFactory2D->isHorizontalAxis() )
aTickScreenPos2D += aTextToTickDistance; fRotationAngleDegree = 0.0;
awt::Point aAnchorScreenPosition2D( else
static_cast<sal_Int32>(aTickScreenPos2D.getX()) fRotationAngleDegree = 90;
,static_cast<sal_Int32>(aTickScreenPos2D.getY())); }
double fRotationAngleDegree = m_aAxisLabelProperties.fRotationAngleDegree; // #i78696# use mathematically correct rotation now
if( nDepth > 0 ) const double fRotationAnglePi(fRotationAngleDegree * (F_PI / -180.0));
uno::Any aATransformation = AbstractShapeFactory::makeTransformation(aAnchorScreenPosition2D, fRotationAnglePi);
//set new position
uno::Reference< beans::XPropertySet > xProp( xShape2DText, uno::UNO_QUERY );
if( xProp.is() )
{
try
{ {
/* Multi-level Labels: default to 0 or 90 */ xProp->setPropertyValue( "Transformation", aATransformation );
if( pTickFactory2D->isHorizontalAxis() )
fRotationAngleDegree = 0.0;
else
fRotationAngleDegree = 90;
} }
catch( const uno::Exception& e )
// #i78696# use mathematically correct rotation now
const double fRotationAnglePi(fRotationAngleDegree * (F_PI / -180.0));
uno::Any aATransformation = AbstractShapeFactory::makeTransformation(aAnchorScreenPosition2D, fRotationAnglePi);
//set new position
uno::Reference< beans::XPropertySet > xProp( xShape2DText, uno::UNO_QUERY );
if( xProp.is() )
{ {
try ASSERT_EXCEPTION( e );
{
xProp->setPropertyValue( "Transformation", aATransformation );
}
catch( const uno::Exception& e )
{
ASSERT_EXCEPTION( e );
}
} }
//correctPositionForRotation
LabelPositionHelper::correctPositionForRotation( xShape2DText
, m_aAxisProperties.m_aLabelAlignment, fRotationAngleDegree, m_aAxisProperties.m_bComplexCategories );
} }
//correctPositionForRotation
LabelPositionHelper::correctPositionForRotation( xShape2DText
, m_aAxisProperties.m_aLabelAlignment, fRotationAngleDegree, m_aAxisProperties.m_bComplexCategories );
} }
} }
doStaggeringOfLabels( m_aAxisLabelProperties, pTickFactory2D );
} }
doStaggeringOfLabels( m_aAxisLabelProperties, pTickFactory2D );
} }
void VCartesianAxis::createTickMarkLineShapes( ::std::vector< TickInfo >& rTickInfos, const TickmarkProperties& rTickmarkProperties, TickFactory_2D& rTickFactory2D, bool bOnlyAtLabels ) void VCartesianAxis::createTickMarkLineShapes( ::std::vector< TickInfo >& rTickInfos, const TickmarkProperties& rTickmarkProperties, TickFactory_2D& rTickFactory2D, bool bOnlyAtLabels )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment