diff options
author | Ingrid Halama [iha] <Ingrid.Halama@oracle.com> | 2011-01-28 17:43:26 +0100 |
---|---|---|
committer | Ingrid Halama [iha] <Ingrid.Halama@oracle.com> | 2011-01-28 17:43:26 +0100 |
commit | 770837b8b4d2786ff7925d7ad6be69e1d1587ac4 (patch) | |
tree | 4920319e7916388a5f411be3dc50fd4aadcb331c /chart2/source | |
parent | 796dfe2205b9a7735e7fb908b3b4fe7d74d76170 (diff) | |
parent | 6f68642b7b2310b902264849a5ffc5dca6c15510 (diff) |
chart46: merge with dev300m98
Diffstat (limited to 'chart2/source')
-rwxr-xr-x[-rw-r--r--] | chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx | 2 | ||||
-rw-r--r-- | chart2/source/controller/dialogs/dlg_ObjectProperties.cxx | 14 | ||||
-rw-r--r-- | chart2/source/controller/dialogs/tp_AxisLabel.cxx | 10 | ||||
-rw-r--r-- | chart2/source/controller/dialogs/tp_AxisLabel.hxx | 2 | ||||
-rw-r--r-- | chart2/source/controller/inc/dlg_ObjectProperties.hxx | 4 | ||||
-rw-r--r-- | chart2/source/view/axes/VCartesianAxis.cxx | 109 |
6 files changed, 124 insertions, 17 deletions
diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx index fd94ae0e3076..3498b812557a 100644..100755 --- a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx @@ -381,7 +381,7 @@ struct lcl_AnyColumnDescriptionsOperator : public lcl_Operator virtual bool setsCategories( bool bDataInColumns ) { - return !bDataInColumns; + return bDataInColumns; } virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx index 431616714c00..fd14db521416 100644 --- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx +++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx @@ -59,6 +59,7 @@ #include "NumberFormatterWrapper.hxx" #include "AxisIndexDefines.hxx" #include "AxisHelper.hxx" +#include "ExplicitCategoriesProvider.hxx" #include <com/sun/star/chart2/XAxis.hpp> #include <com/sun/star/chart2/XChartType.hpp> @@ -116,6 +117,7 @@ ObjectPropertiesDialogParameter::ObjectPropertiesDialogParameter( const rtl::OUS , m_bIsCrossingAxisIsCategoryAxis(false) , m_aCategories() , m_xChartDocument( 0 ) + , m_bComplexCategoriesAxis( false ) { rtl::OUString aParticleID = ObjectIdentifier::getParticleID( m_aObjectCID ); m_bAffectsMultipleObjects = aParticleID.equals(C2U("ALLELEMENTS")); @@ -206,6 +208,13 @@ void ObjectPropertiesDialogParameter::init( const uno::Reference< frame::XModel if( m_bIsCrossingAxisIsCategoryAxis ) m_aCategories = DiagramHelper::getExplicitSimpleCategories( Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY) ); } + + m_bComplexCategoriesAxis = false; + if ( nDimensionIndex == 0 && aData.AxisType == chart2::AxisType::CATEGORY ) + { + ExplicitCategoriesProvider aExplicitCategoriesProvider( xCooSys, xChartModel ); + m_bComplexCategoriesAxis = aExplicitCategoriesProvider.hasComplexCategories(); + } } } @@ -322,6 +331,10 @@ uno::Reference< chart2::XChartDocument > ObjectPropertiesDialogParameter::getDoc { return m_xChartDocument; } +bool ObjectPropertiesDialogParameter::IsComplexCategoriesAxis() const +{ + return m_bComplexCategoriesAxis; +} //const USHORT nNoArrowDlg = 1100; const USHORT nNoArrowNoShadowDlg = 1101; @@ -566,6 +579,7 @@ void SchAttribTabDlg::PageCreated(USHORT nId, SfxTabPage &rPage) { bool bShowStaggeringControls = m_pParameter->CanAxisLabelsBeStaggered(); ((SchAxisLabelTabPage&)rPage).ShowStaggeringControls( bShowStaggeringControls ); + ( dynamic_cast< SchAxisLabelTabPage& >( rPage ) ).SetComplexCategories( m_pParameter->IsComplexCategoriesAxis() ); break; } diff --git a/chart2/source/controller/dialogs/tp_AxisLabel.cxx b/chart2/source/controller/dialogs/tp_AxisLabel.cxx index 876cb0f78c91..58322534cba6 100644 --- a/chart2/source/controller/dialogs/tp_AxisLabel.cxx +++ b/chart2/source/controller/dialogs/tp_AxisLabel.cxx @@ -78,7 +78,8 @@ SchAxisLabelTabPage::SchAxisLabelTabPage( Window* pParent, const SfxItemSet& rIn m_nInitialDegrees( 0 ), m_bHasInitialDegrees( true ), m_bInitialStacking( false ), - m_bHasInitialStacking( true ) + m_bHasInitialStacking( true ), + m_bComplexCategories( false ) { FreeResource(); @@ -295,6 +296,11 @@ void SchAxisLabelTabPage::ShowStaggeringControls( BOOL bShowStaggeringControls ) } } +void SchAxisLabelTabPage::SetComplexCategories( bool bComplexCategories ) +{ + m_bComplexCategories = bComplexCategories; +} + // event handling routines // ----------------------- @@ -310,7 +316,7 @@ IMPL_LINK ( SchAxisLabelTabPage, ToggleShowLabel, void *, EMPTYARG ) aRbAuto.Enable( bEnable ); aFlTextFlow.Enable( bEnable ); - aCbTextOverlap.Enable( bEnable ); + aCbTextOverlap.Enable( bEnable && !m_bComplexCategories ); aCbTextBreak.Enable( bEnable ); m_aFtTextDirection.Enable( bEnable ); diff --git a/chart2/source/controller/dialogs/tp_AxisLabel.hxx b/chart2/source/controller/dialogs/tp_AxisLabel.hxx index 6043b16001ac..a1b8c7530743 100644 --- a/chart2/source/controller/dialogs/tp_AxisLabel.hxx +++ b/chart2/source/controller/dialogs/tp_AxisLabel.hxx @@ -76,6 +76,7 @@ private: bool m_bHasInitialDegrees; /// false = DialControl in tristate bool m_bInitialStacking; bool m_bHasInitialStacking; /// false = checkbox in tristate + bool m_bComplexCategories; DECL_LINK ( ToggleShowLabel, void* ); @@ -90,6 +91,7 @@ public: virtual void Reset( const SfxItemSet& rInAttrs ); void ShowStaggeringControls( BOOL bShowStaggeringControls ); + void SetComplexCategories( bool bComplexCategories ); }; //............................................................................. } //namespace chart diff --git a/chart2/source/controller/inc/dlg_ObjectProperties.hxx b/chart2/source/controller/inc/dlg_ObjectProperties.hxx index 8ceabdbe33b7..140c33389fe3 100644 --- a/chart2/source/controller/inc/dlg_ObjectProperties.hxx +++ b/chart2/source/controller/inc/dlg_ObjectProperties.hxx @@ -69,6 +69,8 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > getDocument() const; + bool IsComplexCategoriesAxis() const; + private: rtl::OUString m_aObjectCID; ObjectType m_eObjectType; @@ -96,6 +98,8 @@ private: ::com::sun::star::uno::Sequence< rtl::OUString > m_aCategories; ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > m_xChartDocument; + + bool m_bComplexCategoriesAxis; }; /************************************************************************* diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index a4cca736fe18..5a3ee4b78500 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -49,6 +49,8 @@ #include <com/sun/star/text/XText.hpp> #include <com/sun/star/text/WritingMode2.hpp> #include <editeng/unoprnms.hxx> +#include <svx/unoshape.hxx> +#include <svx/unoshtxt.hxx> #include <algorithm> #include <memory> @@ -111,7 +113,7 @@ Reference< drawing::XShape > createSingleLabel( //correctPositionForRotation LabelPositionHelper::correctPositionForRotation( xShape2DText - , rAxisProperties.m_aLabelAlignment, rAxisLabelProperties.fRotationAngleDegree, false ); + , rAxisProperties.m_aLabelAlignment, rAxisLabelProperties.fRotationAngleDegree, rAxisProperties.m_bComplexCategories ); return xShape2DText; } @@ -257,7 +259,7 @@ TickInfo* LabelIterator::nextInfo() return pTickInfo; } -B2DVector lcl_getLabelsDistance( TickIter& rIter, const B2DVector& rDistanceTickToText ) +B2DVector lcl_getLabelsDistance( TickIter& rIter, const B2DVector& rDistanceTickToText, double fRotationAngleDegree ) { //calculates the height or width of a line of labels //thus a following line of labels can be shifted for that distance @@ -280,7 +282,7 @@ B2DVector lcl_getLabelsDistance( TickIter& rIter, const B2DVector& rDistanceTick xShape2DText = pTickInfo->xTextShape; if( xShape2DText.is() ) { - awt::Size aSize = xShape2DText->getSize(); + awt::Size aSize = ShapeFactory::getSizeAfterRotation( xShape2DText, fRotationAngleDegree ); if(fabs(aStaggerDirection.getX())>fabs(aStaggerDirection.getY())) nDistance = ::std::max(nDistance,aSize.Width); else @@ -317,6 +319,47 @@ void lcl_shiftLables( TickIter& rIter, const B2DVector& rStaggerDistance ) } } +bool lcl_hasWordBreak( const Reference< drawing::XShape >& rxShape ) +{ + if ( rxShape.is() ) + { + SvxShape* pShape = SvxShape::getImplementation( rxShape ); + SvxShapeText* pShapeText = dynamic_cast< SvxShapeText* >( pShape ); + if ( pShapeText ) + { + SvxTextEditSource* pTextEditSource = dynamic_cast< SvxTextEditSource* >( pShapeText->GetEditSource() ); + if ( pTextEditSource ) + { + pTextEditSource->UpdateOutliner(); + SvxTextForwarder* pTextForwarder = pTextEditSource->GetTextForwarder(); + if ( pTextForwarder ) + { + USHORT nParaCount = pTextForwarder->GetParagraphCount(); + for ( USHORT nPara = 0; nPara < nParaCount; ++nPara ) + { + USHORT nLineCount = pTextForwarder->GetLineCount( nPara ); + for ( USHORT nLine = 0; nLine < nLineCount; ++nLine ) + { + USHORT nLineStart = 0; + USHORT nLineEnd = 0; + pTextForwarder->GetLineBoundaries( nLineStart, nLineEnd, nPara, nLine ); + USHORT nWordStart = 0; + USHORT nWordEnd = 0; + if ( pTextForwarder->GetWordIndices( nPara, nLineStart, nWordStart, nWordEnd ) && + ( nWordStart != nLineStart ) ) + { + return true; + } + } + } + } + } + } + } + + return false; +} + class MaxLabelTickIter : public TickIter { //iterate over first two and last two labels and the longest label @@ -704,10 +747,23 @@ bool VCartesianAxis::createTextShapes( recordMaximumTextSize( pTickInfo->xTextShape, rAxisLabelProperties.fRotationAngleDegree ); + //better rotate if single words are broken apart + if( nLimitedSpaceForText>0 && !rAxisLabelProperties.bOverlapAllowed + && ::rtl::math::approxEqual( rAxisLabelProperties.fRotationAngleDegree, 0.0 ) + && m_aAxisProperties.m_bComplexCategories + && lcl_hasWordBreak( pTickInfo->xTextShape ) ) + { + rAxisLabelProperties.fRotationAngleDegree = 90; + rAxisLabelProperties.bLineBreakAllowed = false; + m_aAxisLabelProperties.fRotationAngleDegree = rAxisLabelProperties.fRotationAngleDegree; + removeTextShapesFromTicks(); + return false; + } + //if NO OVERLAP -> remove overlapping shapes if( pLastVisibleNeighbourTickInfo && !rAxisLabelProperties.bOverlapAllowed ) { - if( doesOverlap( pLastVisibleNeighbourTickInfo->xTextShape, pTickInfo->xTextShape, m_aAxisLabelProperties.fRotationAngleDegree ) ) + if( doesOverlap( pLastVisibleNeighbourTickInfo->xTextShape, pTickInfo->xTextShape, rAxisLabelProperties.fRotationAngleDegree ) ) { bool bOverlapAlsoAfterSwitchingOnAutoStaggering = true; if( !bIsStaggered && isAutoStaggeringOfLabelsAllowed( rAxisLabelProperties, bIsHorizontalAxis, bIsVerticalAxis ) ) @@ -1276,10 +1332,15 @@ void VCartesianAxis::doStaggeringOfLabels( const AxisLabelProperties& rAxisLabel ::std::auto_ptr< TickIter > apTickIter = createLabelTickIterator( nTextLevel ); if(apTickIter.get()) { + double fRotationAngleDegree = m_aAxisLabelProperties.fRotationAngleDegree; if( nTextLevel>0 ) + { lcl_shiftLables( *apTickIter.get(), aCummulatedLabelsDistance ); + fRotationAngleDegree = 0.0; + } aCummulatedLabelsDistance += lcl_getLabelsDistance( *apTickIter.get() - , pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties ) ); + , pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties ) + , fRotationAngleDegree ); } } } @@ -1292,7 +1353,7 @@ void VCartesianAxis::doStaggeringOfLabels( const AxisLabelProperties& rAxisLabel lcl_shiftLables( aOuterIter , lcl_getLabelsDistance( aInnerIter - , pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties ) ) ); + , pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties ), 0.0 ) ); } } } @@ -1335,10 +1396,23 @@ void VCartesianAxis::createLabels() nScreenDistanceBetweenTicks*=2; //the above used tick iter does contain also the sub ticks -> thus the given distance is only the half } - AxisLabelProperties aCopy(m_aAxisLabelProperties); - aCopy.bRhythmIsFix = true; - aCopy.nRhythm = 1; - AxisLabelProperties& rAxisLabelProperties = nTextLevel==0 ? m_aAxisLabelProperties : aCopy; + AxisLabelProperties aComplexProps(m_aAxisLabelProperties); + if( m_aAxisProperties.m_bComplexCategories ) + { + if( nTextLevel==0 ) + { + aComplexProps.bLineBreakAllowed = true; + aComplexProps.bOverlapAllowed = !::rtl::math::approxEqual( aComplexProps.fRotationAngleDegree, 0.0 ); + } + else + { + aComplexProps.bOverlapAllowed = true; + aComplexProps.bRhythmIsFix = true; + aComplexProps.nRhythm = 1; + aComplexProps.fRotationAngleDegree = 0.0; + } + } + AxisLabelProperties& rAxisLabelProperties = m_aAxisProperties.m_bComplexCategories ? aComplexProps : m_aAxisLabelProperties; while( !createTextShapes( m_xTextTarget, *apTickIter.get(), rAxisLabelProperties, pTickFactory2D, nScreenDistanceBetweenTicks ) ) { }; @@ -1408,7 +1482,7 @@ void VCartesianAxis::updatePositions() ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = m_aAllTickInfos.begin(); const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = m_aAllTickInfos.end(); - for( ; aDepthIter != aDepthEnd; aDepthIter++ ) + 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(); @@ -1425,8 +1499,12 @@ void VCartesianAxis::updatePositions() static_cast<sal_Int32>(aTickScreenPos2D.getX()) ,static_cast<sal_Int32>(aTickScreenPos2D.getY())); + double fRotationAngleDegree = m_aAxisLabelProperties.fRotationAngleDegree; + if( nDepth>0 ) + fRotationAngleDegree = 0.0; + // #i78696# use mathematically correct rotation now - const double fRotationAnglePi(m_aAxisLabelProperties.fRotationAngleDegree * (F_PI / -180.0)); + const double fRotationAnglePi(fRotationAngleDegree * (F_PI / -180.0)); uno::Any aATransformation = ShapeFactory::makeTransformation(aAnchorScreenPosition2D, fRotationAnglePi); //set new position @@ -1445,7 +1523,7 @@ void VCartesianAxis::updatePositions() //correctPositionForRotation LabelPositionHelper::correctPositionForRotation( xShape2DText - , m_aAxisProperties.m_aLabelAlignment, m_aAxisLabelProperties.fRotationAngleDegree, false ); + , m_aAxisProperties.m_aLabelAlignment, fRotationAngleDegree, m_aAxisProperties.m_bComplexCategories ); } } } @@ -1517,7 +1595,10 @@ void VCartesianAxis::createShapes() ::std::auto_ptr< TickIter > apTickIter = createLabelTickIterator( nTextLevel ); if( apTickIter.get() ) { - B2DVector aLabelsDistance( lcl_getLabelsDistance( *apTickIter.get(), pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties, false ) ) ); + double fRotationAngleDegree = m_aAxisLabelProperties.fRotationAngleDegree; + if( nTextLevel>0 ) + fRotationAngleDegree = 0.0; + B2DVector aLabelsDistance( lcl_getLabelsDistance( *apTickIter.get(), pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties, false ), fRotationAngleDegree ) ); sal_Int32 nCurrentLength = static_cast<sal_Int32>(aLabelsDistance.getLength()); aTickmarkPropertiesList.push_back( m_aAxisProperties.makeTickmarkPropertiesForComplexCategories( nOffset + nCurrentLength, 0, nTextLevel ) ); nOffset += nCurrentLength; |