chart2/inc/ChartView.hxx | 3 chart2/source/tools/DiagramHelper.cxx | 153 ++++---- chart2/source/view/main/ChartView.cxx | 589 ++++++++++++++++++---------------- 3 files changed, 396 insertions(+), 349 deletions(-)
New commits: commit be775a1ab40ccedfbc9659120b82867d6c128e6a Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Fri Sep 19 13:14:25 2014 -0400 Move the code that creates shapes for axis titles to own method. This change also creates a struct that keeps track of states during shape creation, to make it easier to extract methods as necessary. Change-Id: I0d84dbee9dba5b9c59d22e4a1be318c5e8c6c6c3 diff --git a/chart2/inc/ChartView.hxx b/chart2/inc/ChartView.hxx index cf217b7..51b6a48 100644 --- a/chart2/inc/ChartView.hxx +++ b/chart2/inc/ChartView.hxx @@ -56,6 +56,7 @@ class SeriesPlotterContainer; class VDataSeries; class GL3DPlotterBase; class GL2DRenderer; +struct CreateShapeParam2D; enum TimeBasedMode { @@ -204,6 +205,7 @@ private: //methods void createShapes(); void createShapes2D( const css::awt::Size& rPageSize ); + bool createAxisTitleShapes2D( const css::awt::Size& rPageSize, CreateShapeParam2D& rParam ); void createShapes3D(); bool isReal3DChart(); void getMetaFile( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutStream diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 7194c3c..34f0ee1 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -130,6 +130,32 @@ class theExplicitValueProviderUnoTunnelId : public rtl::Static<UnoTunnelIdInit, } +struct CreateShapeParam2D +{ + css::awt::Rectangle maRemainingSpace; + + boost::shared_ptr<VTitle> mpVTitleX; + boost::shared_ptr<VTitle> mpVTitleY; + boost::shared_ptr<VTitle> mpVTitleZ; + + boost::shared_ptr<VTitle> mpVTitleSecondX; + boost::shared_ptr<VTitle> mpVTitleSecondY; + + bool mbAutoPosTitleX; + bool mbAutoPosTitleY; + bool mbAutoPosTitleZ; + + bool mbAutoPosSecondTitleX; + bool mbAutoPosSecondTitleY; + + CreateShapeParam2D() : + mbAutoPosTitleX(true), + mbAutoPosTitleY(true), + mbAutoPosTitleZ(true), + mbAutoPosSecondTitleX(true), + mbAutoPosSecondTitleY(true) {} +}; + class GL2DRenderer : public IRenderer { public: @@ -2992,8 +3018,11 @@ void ChartView::createShapes2D( const awt::Size& rPageSize ) // but the draw page does not support XPropertySet formatPage( mrChartModel, rPageSize, mxRootShape, m_xShapeFactory ); - //sal_Int32 nYDistance = static_cast<sal_Int32>(aPageSize.Height*lcl_getPageLayoutDistancePercentage()); - awt::Rectangle aRemainingSpace( 0, 0, rPageSize.Width, rPageSize.Height ); + CreateShapeParam2D aParam; + aParam.maRemainingSpace.X = 0; + aParam.maRemainingSpace.Y = 0; + aParam.maRemainingSpace.Width = rPageSize.Width; + aParam.maRemainingSpace.Height = rPageSize.Height; //create the group shape for diagram and axes first to have title and legends on top of it uno::Reference< XDiagram > xDiagram( mrChartModel.getFirstDiagram() ); @@ -3013,14 +3042,16 @@ void ChartView::createShapes2D( const awt::Size& rPageSize ) bool bAutoPositionDummy = true; - lcl_createTitle( TitleHelper::MAIN_TITLE, mxRootShape, m_xShapeFactory, mrChartModel - , aRemainingSpace, rPageSize, ALIGN_TOP, bAutoPositionDummy ); - if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) + lcl_createTitle( + TitleHelper::MAIN_TITLE, mxRootShape, m_xShapeFactory, mrChartModel, + aParam.maRemainingSpace, rPageSize, ALIGN_TOP, bAutoPositionDummy); + if (aParam.maRemainingSpace.Width <= 0 || aParam.maRemainingSpace.Height <= 0) return; - lcl_createTitle( TitleHelper::SUB_TITLE, mxRootShape, m_xShapeFactory, mrChartModel - , aRemainingSpace, rPageSize, ALIGN_TOP, bAutoPositionDummy ); - if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) + lcl_createTitle( + TitleHelper::SUB_TITLE, mxRootShape, m_xShapeFactory, mrChartModel, + aParam.maRemainingSpace, rPageSize, ALIGN_TOP, bAutoPositionDummy ); + if (aParam.maRemainingSpace.Width <= 0|| aParam.maRemainingSpace.Height <= 0) return; SeriesPlotterContainer aSeriesPlotterContainer( m_aVCooSysList ); @@ -3045,63 +3076,24 @@ void ChartView::createShapes2D( const awt::Size& rPageSize ) } } - lcl_createLegend( LegendHelper::getLegend( mrChartModel ), mxRootShape, m_xShapeFactory, m_xCC - , aRemainingSpace, rPageSize, mrChartModel, aSeriesPlotterContainer.getLegendEntryProviderList() - , lcl_getDefaultWritingModeFromPool( m_pDrawModelWrapper ) ); - if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) - return; - - Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ); - sal_Int32 nDimension = DiagramHelper::getDimension( xDiagram ); - - bool bAutoPosition_XTitle = true; - boost::shared_ptr<VTitle> apVTitle_X; - if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 0 ) ) - apVTitle_X = lcl_createTitle( TitleHelper::TITLE_AT_STANDARD_X_AXIS_POSITION, mxRootShape, m_xShapeFactory, mrChartModel - , aRemainingSpace, rPageSize, ALIGN_BOTTOM, bAutoPosition_XTitle ); - if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) - return; - - bool bAutoPosition_YTitle = true; - boost::shared_ptr<VTitle> apVTitle_Y; - if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 1 ) ) - apVTitle_Y = lcl_createTitle( TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION, mxRootShape, m_xShapeFactory, mrChartModel - , aRemainingSpace, rPageSize, ALIGN_LEFT, bAutoPosition_YTitle ); - if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) - return; - - bool bAutoPosition_ZTitle = true; - boost::shared_ptr<VTitle> apVTitle_Z; - if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 2 ) ) - apVTitle_Z = lcl_createTitle( TitleHelper::Z_AXIS_TITLE, mxRootShape, m_xShapeFactory, mrChartModel - , aRemainingSpace, rPageSize, ALIGN_RIGHT, bAutoPosition_ZTitle ); - if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) - return; - - bool bDummy = false; - bool bIsVertical = DiagramHelper::getVertical( xDiagram, bDummy, bDummy ); - - bool bAutoPosition_SecondXTitle = true; - boost::shared_ptr<VTitle> apVTitle_SecondX; - if( ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimension, 0 ) ) - apVTitle_SecondX = lcl_createTitle( TitleHelper::SECONDARY_X_AXIS_TITLE, mxRootShape, m_xShapeFactory, mrChartModel - , aRemainingSpace, rPageSize, bIsVertical? ALIGN_RIGHT : ALIGN_TOP, bAutoPosition_SecondXTitle ); - if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) + lcl_createLegend( + LegendHelper::getLegend( mrChartModel ), mxRootShape, m_xShapeFactory, m_xCC, + aParam.maRemainingSpace, rPageSize, mrChartModel, aSeriesPlotterContainer.getLegendEntryProviderList(), + lcl_getDefaultWritingModeFromPool( m_pDrawModelWrapper ) ); + if (aParam.maRemainingSpace.Width <= 0 || aParam.maRemainingSpace.Height <= 0) return; - bool bAutoPosition_SecondYTitle = true; - boost::shared_ptr<VTitle> apVTitle_SecondY; - if( ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimension, 1 ) ) - apVTitle_SecondY = lcl_createTitle( TitleHelper::SECONDARY_Y_AXIS_TITLE, mxRootShape, m_xShapeFactory, mrChartModel - , aRemainingSpace, rPageSize, bIsVertical? ALIGN_TOP : ALIGN_RIGHT, bAutoPosition_SecondYTitle ); - if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) + if (!createAxisTitleShapes2D(rPageSize, aParam)) return; awt::Point aAvailablePosDia; awt::Size aAvailableSizeForDiagram; bool bUseFixedInnerSize = false; - if( getAvailablePosAndSizeForDiagram( aAvailablePosDia, aAvailableSizeForDiagram, aRemainingSpace, rPageSize - , mrChartModel.getFirstDiagram(), bUseFixedInnerSize ) ) + bool bDummy = false; + bool bIsVertical = DiagramHelper::getVertical(xDiagram, bDummy, bDummy); + + if (getAvailablePosAndSizeForDiagram( + aAvailablePosDia, aAvailableSizeForDiagram, aParam.maRemainingSpace, rPageSize, mrChartModel.getFirstDiagram(), bUseFixedInnerSize)) { awt::Rectangle aUsedOuterRect = impl_createDiagramAndContent( aSeriesPlotterContainer , xDiagramPlusAxes_Shapes @@ -3115,16 +3107,16 @@ void ChartView::createShapes2D( const awt::Size& rPageSize ) //correct axis title position awt::Rectangle aDiagramPlusAxesRect( aUsedOuterRect ); - if(bAutoPosition_XTitle) - changePositionOfAxisTitle( apVTitle_X.get(), ALIGN_BOTTOM, aDiagramPlusAxesRect, rPageSize ); - if(bAutoPosition_YTitle) - changePositionOfAxisTitle( apVTitle_Y.get(), ALIGN_LEFT, aDiagramPlusAxesRect, rPageSize ); - if(bAutoPosition_ZTitle) - changePositionOfAxisTitle( apVTitle_Z.get(), ALIGN_Z, aDiagramPlusAxesRect, rPageSize ); - if(bAutoPosition_SecondXTitle) - changePositionOfAxisTitle( apVTitle_SecondX.get(), bIsVertical? ALIGN_RIGHT : ALIGN_TOP, aDiagramPlusAxesRect, rPageSize ); - if(bAutoPosition_SecondYTitle) - changePositionOfAxisTitle( apVTitle_SecondY.get(), bIsVertical? ALIGN_TOP : ALIGN_RIGHT, aDiagramPlusAxesRect, rPageSize ); + if (aParam.mbAutoPosTitleX) + changePositionOfAxisTitle(aParam.mpVTitleX.get(), ALIGN_BOTTOM, aDiagramPlusAxesRect, rPageSize); + if (aParam.mbAutoPosTitleY) + changePositionOfAxisTitle(aParam.mpVTitleY.get(), ALIGN_LEFT, aDiagramPlusAxesRect, rPageSize); + if (aParam.mbAutoPosTitleZ) + changePositionOfAxisTitle(aParam.mpVTitleZ.get(), ALIGN_Z, aDiagramPlusAxesRect, rPageSize); + if (aParam.mbAutoPosSecondTitleX) + changePositionOfAxisTitle(aParam.mpVTitleSecondX.get(), bIsVertical? ALIGN_RIGHT : ALIGN_TOP, aDiagramPlusAxesRect, rPageSize); + if (aParam.mbAutoPosSecondTitleY) + changePositionOfAxisTitle(aParam.mpVTitleSecondY.get(), bIsVertical? ALIGN_TOP : ALIGN_RIGHT, aDiagramPlusAxesRect, rPageSize); } //cleanup: remove all empty group shapes to avoid grey border lines: @@ -3171,6 +3163,49 @@ void ChartView::createShapes2D( const awt::Size& rPageSize ) } } +bool ChartView::createAxisTitleShapes2D( const css::awt::Size& rPageSize, CreateShapeParam2D& rParam ) +{ + uno::Reference<XDiagram> xDiagram = mrChartModel.getFirstDiagram(); + + Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ); + sal_Int32 nDimension = DiagramHelper::getDimension( xDiagram ); + + if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 0 ) ) + rParam.mpVTitleX = lcl_createTitle( TitleHelper::TITLE_AT_STANDARD_X_AXIS_POSITION, mxRootShape, m_xShapeFactory, mrChartModel + , rParam.maRemainingSpace, rPageSize, ALIGN_BOTTOM, rParam.mbAutoPosTitleX ); + if (rParam.maRemainingSpace.Width <= 0 ||rParam.maRemainingSpace.Height <= 0) + return false; + + if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 1 ) ) + rParam.mpVTitleY = lcl_createTitle( TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION, mxRootShape, m_xShapeFactory, mrChartModel + , rParam.maRemainingSpace, rPageSize, ALIGN_LEFT, rParam.mbAutoPosTitleY ); + if (rParam.maRemainingSpace.Width <= 0 || rParam.maRemainingSpace.Height <= 0) + return false; + + if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 2 ) ) + rParam.mpVTitleZ = lcl_createTitle( TitleHelper::Z_AXIS_TITLE, mxRootShape, m_xShapeFactory, mrChartModel + , rParam.maRemainingSpace, rPageSize, ALIGN_RIGHT, rParam.mbAutoPosTitleZ ); + if (rParam.maRemainingSpace.Width <= 0 || rParam.maRemainingSpace.Height <= 0) + return false; + + bool bDummy = false; + bool bIsVertical = DiagramHelper::getVertical( xDiagram, bDummy, bDummy ); + + if( ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimension, 0 ) ) + rParam.mpVTitleSecondX = lcl_createTitle( TitleHelper::SECONDARY_X_AXIS_TITLE, mxRootShape, m_xShapeFactory, mrChartModel + , rParam.maRemainingSpace, rPageSize, bIsVertical? ALIGN_RIGHT : ALIGN_TOP, rParam.mbAutoPosSecondTitleX ); + if (rParam.maRemainingSpace.Width <= 0 || rParam.maRemainingSpace.Height <= 0) + return false; + + if( ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimension, 1 ) ) + rParam.mpVTitleSecondY = lcl_createTitle( TitleHelper::SECONDARY_Y_AXIS_TITLE, mxRootShape, m_xShapeFactory, mrChartModel + , rParam.maRemainingSpace, rPageSize, bIsVertical? ALIGN_TOP : ALIGN_RIGHT, rParam.mbAutoPosSecondTitleY ); + if (rParam.maRemainingSpace.Width <= 0 || rParam.maRemainingSpace.Height <= 0) + return false; + + return true; +} + void ChartView::createShapes3D() { OpenGLWindow* pWindow = mrChartModel.getOpenGLWindow(); commit e55fd119c0eb9ecbbda1a95902f888a795bf8345 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Fri Sep 19 11:53:18 2014 -0400 More scope reduction. Change-Id: Ibaabf1122fb3e828c1b7b71e846911d77f312445 diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index dec53af..765937b 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; } } } commit 4e58aa02bf7a61804a64626cf9b9d3f36a1959da Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Fri Sep 19 11:36:23 2014 -0400 Scope reduction. Change-Id: Id677971ccd6959356a781a2d8c35ab864b35a62e diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 9e75190..7194c3c 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -1384,15 +1384,15 @@ void lcl_setDefaultWritingMode( ::boost::shared_ptr< DrawModelWrapper > pDrawMod } } -sal_Int16 lcl_getDefaultWritingModeFromPool( ::boost::shared_ptr< DrawModelWrapper > pDrawModelWrapper ) +sal_Int16 lcl_getDefaultWritingModeFromPool( const boost::shared_ptr<DrawModelWrapper>& pDrawModelWrapper ) { sal_Int16 nWritingMode = text::WritingMode2::LR_TB; - if( pDrawModelWrapper.get() ) - { - const SfxPoolItem* pItem = &(pDrawModelWrapper->GetItemPool().GetDefaultItem( EE_PARA_WRITINGDIR )); - if( pItem ) - nWritingMode = static_cast< sal_Int16 >((static_cast< const SvxFrameDirectionItem * >( pItem ))->GetValue()); - } + if(!pDrawModelWrapper) + return nWritingMode; + + const SfxPoolItem* pItem = &(pDrawModelWrapper->GetItemPool().GetDefaultItem( EE_PARA_WRITINGDIR )); + if( pItem ) + nWritingMode = static_cast< sal_Int16 >((static_cast< const SvxFrameDirectionItem * >( pItem ))->GetValue()); return nWritingMode; } @@ -2327,17 +2327,16 @@ bool lcl_createLegend( const uno::Reference< XLegend > & xLegend , const std::vector< LegendEntryProvider* >& rLegendEntryProviderList , sal_Int16 nDefaultWritingMode ) { - if( VLegend::isVisible( xLegend )) - { - VLegend aVLegend( xLegend, xContext, rLegendEntryProviderList, - xPageShapes, xShapeFactory, rModel); - aVLegend.setDefaultWritingMode( nDefaultWritingMode ); - aVLegend.createShapes( awt::Size( rRemainingSpace.Width, rRemainingSpace.Height ), - rPageSize ); - aVLegend.changePosition( rRemainingSpace, rPageSize ); - return true; - } - return false; + if (!VLegend::isVisible(xLegend)) + return false; + + VLegend aVLegend( xLegend, xContext, rLegendEntryProviderList, + xPageShapes, xShapeFactory, rModel); + aVLegend.setDefaultWritingMode( nDefaultWritingMode ); + aVLegend.createShapes( awt::Size( rRemainingSpace.Width, rRemainingSpace.Height ), + rPageSize ); + aVLegend.changePosition( rRemainingSpace, rPageSize ); + return true; } void formatPage( commit b26b1f79b70fb0f7ee049033039925854259f227 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Fri Sep 19 11:23:14 2014 -0400 Reduce scope by early bailout. Change-Id: Icd344caf6e52ef568361078455d4e8d5cf0d40a8 diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 93a9b87..9e75190 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -2232,82 +2232,86 @@ boost::shared_ptr<VTitle> lcl_createTitle( TitleHelper::eTitleType eType } uno::Reference< XTitle > xTitle( TitleHelper::getTitle( eType, rModel ) ); - OUString aCompleteString( TitleHelper::getCompleteString( xTitle ) ); - if( !aCompleteString.isEmpty() ) - { - //create title - apVTitle.reset(new VTitle(xTitle)); - OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xTitle, rModel ) ); - apVTitle->init(xPageShapes,xShapeFactory,aCID); - apVTitle->createShapes( awt::Point(0,0), rPageSize ); - awt::Size aTitleUnrotatedSize = apVTitle->getUnrotatedSize(); - awt::Size aTitleSize = apVTitle->getFinalSize(); - - //position - rbAutoPosition=true; - awt::Point aNewPosition(0,0); - chart2::RelativePosition aRelativePosition; - uno::Reference< beans::XPropertySet > xProp(xTitle, uno::UNO_QUERY); - if( xProp.is() && (xProp->getPropertyValue( "RelativePosition" )>>=aRelativePosition) ) - { - rbAutoPosition = false; + OUString aCompleteString = TitleHelper::getCompleteString(xTitle); + if (aCompleteString.isEmpty()) + return apVTitle; + + //create title + apVTitle.reset(new VTitle(xTitle)); + OUString aCID = ObjectIdentifier::createClassifiedIdentifierForObject(xTitle, rModel); + apVTitle->init(xPageShapes, xShapeFactory, aCID); + apVTitle->createShapes(awt::Point(0,0), rPageSize); + awt::Size aTitleUnrotatedSize = apVTitle->getUnrotatedSize(); + awt::Size aTitleSize = apVTitle->getFinalSize(); + + //position + rbAutoPosition = true; + awt::Point aNewPosition(0,0); + chart2::RelativePosition aRelativePosition; + uno::Reference<beans::XPropertySet> xProp(xTitle, uno::UNO_QUERY); + if (xProp.is() && (xProp->getPropertyValue("RelativePosition") >>= aRelativePosition)) + { + rbAutoPosition = false; - //@todo decide whether x is primary or secondary - double fX = aRelativePosition.Primary*rPageSize.Width; - double fY = aRelativePosition.Secondary*rPageSize.Height; + //@todo decide whether x is primary or secondary + double fX = aRelativePosition.Primary*rPageSize.Width; + double fY = aRelativePosition.Secondary*rPageSize.Height; - double fAnglePi = apVTitle->getRotationAnglePi(); - aNewPosition = RelativePositionHelper::getCenterOfAnchoredObject( - awt::Point(static_cast<sal_Int32>(fX),static_cast<sal_Int32>(fY)) - , aTitleUnrotatedSize, aRelativePosition.Anchor, fAnglePi ); - } - else //auto position + double fAnglePi = apVTitle->getRotationAnglePi(); + aNewPosition = RelativePositionHelper::getCenterOfAnchoredObject( + awt::Point(static_cast<sal_Int32>(fX),static_cast<sal_Int32>(fY)) + , aTitleUnrotatedSize, aRelativePosition.Anchor, fAnglePi ); + } + else //auto position + { + switch( eAlignment ) { - switch( eAlignment ) - { - case ALIGN_TOP: - aNewPosition = awt::Point( rRemainingSpace.X + rRemainingSpace.Width/2 - , rRemainingSpace.Y + aTitleSize.Height/2 + nYDistance ); - break; - case ALIGN_BOTTOM: - aNewPosition = awt::Point( rRemainingSpace.X + rRemainingSpace.Width/2 - , rRemainingSpace.Y + rRemainingSpace.Height - aTitleSize.Height/2 - nYDistance ); - break; - case ALIGN_LEFT: - aNewPosition = awt::Point( rRemainingSpace.X + aTitleSize.Width/2 + nXDistance - , rRemainingSpace.Y + rRemainingSpace.Height/2 ); - break; - case ALIGN_RIGHT: - aNewPosition = awt::Point( rRemainingSpace.X + rRemainingSpace.Width - aTitleSize.Width/2 - nXDistance - , rRemainingSpace.Y + rRemainingSpace.Height/2 ); - break; - default: - break; + case ALIGN_TOP: + aNewPosition = awt::Point( rRemainingSpace.X + rRemainingSpace.Width/2 + , rRemainingSpace.Y + aTitleSize.Height/2 + nYDistance ); + break; + case ALIGN_BOTTOM: + aNewPosition = awt::Point( rRemainingSpace.X + rRemainingSpace.Width/2 + , rRemainingSpace.Y + rRemainingSpace.Height - aTitleSize.Height/2 - nYDistance ); + break; + case ALIGN_LEFT: + aNewPosition = awt::Point( rRemainingSpace.X + aTitleSize.Width/2 + nXDistance + , rRemainingSpace.Y + rRemainingSpace.Height/2 ); + break; + case ALIGN_RIGHT: + aNewPosition = awt::Point( rRemainingSpace.X + rRemainingSpace.Width - aTitleSize.Width/2 - nXDistance + , rRemainingSpace.Y + rRemainingSpace.Height/2 ); + break; + default: + break; - } } - apVTitle->changePosition( aNewPosition ); + } + apVTitle->changePosition( aNewPosition ); - //remaining space - switch( eAlignment ) - { - case ALIGN_TOP: - rRemainingSpace.Y += ( aTitleSize.Height + nYDistance ); - rRemainingSpace.Height -= ( aTitleSize.Height + nYDistance ); - break; - case ALIGN_BOTTOM: - rRemainingSpace.Height -= ( aTitleSize.Height + nYDistance ); - break; - case ALIGN_LEFT: - rRemainingSpace.X += ( aTitleSize.Width + nXDistance ); - rRemainingSpace.Width -= ( aTitleSize.Width + nXDistance ); - break; - case ALIGN_RIGHT: - rRemainingSpace.Width -= ( aTitleSize.Width + nXDistance ); - break; - default: - break; - } + //remaining space + switch( eAlignment ) + { + case ALIGN_TOP: + // Push the remaining space down from top. + rRemainingSpace.Y += ( aTitleSize.Height + nYDistance ); + rRemainingSpace.Height -= ( aTitleSize.Height + nYDistance ); + break; + case ALIGN_BOTTOM: + // Push the remaining space up from bottom. + rRemainingSpace.Height -= ( aTitleSize.Height + nYDistance ); + break; + case ALIGN_LEFT: + // Push the remaining space to the right from left edge. + rRemainingSpace.X += ( aTitleSize.Width + nXDistance ); + rRemainingSpace.Width -= ( aTitleSize.Width + nXDistance ); + break; + case ALIGN_RIGHT: + // Push the remaining space to the left from right edge. + rRemainingSpace.Width -= ( aTitleSize.Width + nXDistance ); + break; + default: + break; } return apVTitle; commit 6d0592b40ec8c6f7e36b58a21efc78927ceaa012 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Fri Sep 19 10:48:04 2014 -0400 Move the 2D shape creation code into a separate method. Change-Id: I38ccb7f98f404540f5cf3c32be27da19394475a0 diff --git a/chart2/inc/ChartView.hxx b/chart2/inc/ChartView.hxx index 4f2b961..cf217b7 100644 --- a/chart2/inc/ChartView.hxx +++ b/chart2/inc/ChartView.hxx @@ -203,6 +203,7 @@ private: //methods ChartView(); void createShapes(); + void createShapes2D( const css::awt::Size& rPageSize ); void createShapes3D(); bool isReal3DChart(); void getMetaFile( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutStream diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 77a70f8d..93a9b87 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -2504,191 +2504,7 @@ void ChartView::createShapes() } #endif - { - SolarMutexGuard aSolarGuard; - - // todo: it would be nicer to just pass the page m_xDrawPage and format it, - // but the draw page does not support XPropertySet - formatPage( mrChartModel, aPageSize, mxRootShape, m_xShapeFactory ); - - //sal_Int32 nYDistance = static_cast<sal_Int32>(aPageSize.Height*lcl_getPageLayoutDistancePercentage()); - awt::Rectangle aRemainingSpace( 0, 0, aPageSize.Width, aPageSize.Height ); - - //create the group shape for diagram and axes first to have title and legends on top of it - uno::Reference< XDiagram > xDiagram( mrChartModel.getFirstDiagram() ); - OUString aDiagramCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM, OUString::number( 0 ) ) );//todo: other index if more than one diagram is possible - uno::Reference< drawing::XShapes > xDiagramPlusAxesPlusMarkHandlesGroup_Shapes( - pShapeFactory->createGroup2D(mxRootShape,aDiagramCID) ); - - uno::Reference< drawing::XShape > xDiagram_MarkHandles( pShapeFactory->createInvisibleRectangle( - xDiagramPlusAxesPlusMarkHandlesGroup_Shapes, awt::Size(0,0) ) ); - AbstractShapeFactory::setShapeName( xDiagram_MarkHandles, "MarkHandles" ); - - uno::Reference< drawing::XShape > xDiagram_OuterRect( pShapeFactory->createInvisibleRectangle( - xDiagramPlusAxesPlusMarkHandlesGroup_Shapes, awt::Size(0,0) ) ); - AbstractShapeFactory::setShapeName( xDiagram_OuterRect, "PlotAreaIncludingAxes" ); - - uno::Reference< drawing::XShapes > xDiagramPlusAxes_Shapes( pShapeFactory->createGroup2D(xDiagramPlusAxesPlusMarkHandlesGroup_Shapes ) ); - - bool bAutoPositionDummy = true; - - lcl_createTitle( TitleHelper::MAIN_TITLE, mxRootShape, m_xShapeFactory, mrChartModel - , aRemainingSpace, aPageSize, ALIGN_TOP, bAutoPositionDummy ); - if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) - return; - - lcl_createTitle( TitleHelper::SUB_TITLE, mxRootShape, m_xShapeFactory, mrChartModel - , aRemainingSpace, aPageSize, ALIGN_TOP, bAutoPositionDummy ); - if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) - return; - - SeriesPlotterContainer aSeriesPlotterContainer( m_aVCooSysList ); - aSeriesPlotterContainer.initializeCooSysAndSeriesPlotter( mrChartModel ); - if(maTimeBased.bTimeBased && maTimeBased.nFrame != 0) - { - std::vector<VSeriesPlotter*>& rSeriesPlotter = - aSeriesPlotterContainer.getSeriesPlotterList(); - size_t n = rSeriesPlotter.size(); - for(size_t i = 0; i < n; ++i) - { - std::vector< VDataSeries* > aAllNewDataSeries = - rSeriesPlotter[i]->getAllSeries(); - std::vector< VDataSeries* >& rAllOldDataSeries = - maTimeBased.m_aDataSeriesList[i]; - size_t m = std::min(aAllNewDataSeries.size(), rAllOldDataSeries.size()); - for(size_t j = 0; j < m; ++j) - { - aAllNewDataSeries[j]->setOldTimeBased( - rAllOldDataSeries[j], (maTimeBased.nFrame % 60)/60.0); - } - } - } - - lcl_createLegend( LegendHelper::getLegend( mrChartModel ), mxRootShape, m_xShapeFactory, m_xCC - , aRemainingSpace, aPageSize, mrChartModel, aSeriesPlotterContainer.getLegendEntryProviderList() - , lcl_getDefaultWritingModeFromPool( m_pDrawModelWrapper ) ); - if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) - return; - - Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ); - sal_Int32 nDimension = DiagramHelper::getDimension( xDiagram ); - - bool bAutoPosition_XTitle = true; - boost::shared_ptr<VTitle> apVTitle_X; - if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 0 ) ) - apVTitle_X = lcl_createTitle( TitleHelper::TITLE_AT_STANDARD_X_AXIS_POSITION, mxRootShape, m_xShapeFactory, mrChartModel - , aRemainingSpace, aPageSize, ALIGN_BOTTOM, bAutoPosition_XTitle ); - if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) - return; - - bool bAutoPosition_YTitle = true; - boost::shared_ptr<VTitle> apVTitle_Y; - if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 1 ) ) - apVTitle_Y = lcl_createTitle( TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION, mxRootShape, m_xShapeFactory, mrChartModel - , aRemainingSpace, aPageSize, ALIGN_LEFT, bAutoPosition_YTitle ); - if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) - return; - - bool bAutoPosition_ZTitle = true; - boost::shared_ptr<VTitle> apVTitle_Z; - if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 2 ) ) - apVTitle_Z = lcl_createTitle( TitleHelper::Z_AXIS_TITLE, mxRootShape, m_xShapeFactory, mrChartModel - , aRemainingSpace, aPageSize, ALIGN_RIGHT, bAutoPosition_ZTitle ); - if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) - return; - - bool bDummy = false; - bool bIsVertical = DiagramHelper::getVertical( xDiagram, bDummy, bDummy ); - - bool bAutoPosition_SecondXTitle = true; - boost::shared_ptr<VTitle> apVTitle_SecondX; - if( ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimension, 0 ) ) - apVTitle_SecondX = lcl_createTitle( TitleHelper::SECONDARY_X_AXIS_TITLE, mxRootShape, m_xShapeFactory, mrChartModel - , aRemainingSpace, aPageSize, bIsVertical? ALIGN_RIGHT : ALIGN_TOP, bAutoPosition_SecondXTitle ); - if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) - return; - - bool bAutoPosition_SecondYTitle = true; - boost::shared_ptr<VTitle> apVTitle_SecondY; - if( ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimension, 1 ) ) - apVTitle_SecondY = lcl_createTitle( TitleHelper::SECONDARY_Y_AXIS_TITLE, mxRootShape, m_xShapeFactory, mrChartModel - , aRemainingSpace, aPageSize, bIsVertical? ALIGN_TOP : ALIGN_RIGHT, bAutoPosition_SecondYTitle ); - if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) - return; - - awt::Point aAvailablePosDia; - awt::Size aAvailableSizeForDiagram; - bool bUseFixedInnerSize = false; - if( getAvailablePosAndSizeForDiagram( aAvailablePosDia, aAvailableSizeForDiagram, aRemainingSpace, aPageSize - , mrChartModel.getFirstDiagram(), bUseFixedInnerSize ) ) - { - awt::Rectangle aUsedOuterRect = impl_createDiagramAndContent( aSeriesPlotterContainer - , xDiagramPlusAxes_Shapes - , aAvailablePosDia ,aAvailableSizeForDiagram, aPageSize, bUseFixedInnerSize, xDiagram_MarkHandles ); - - if( xDiagram_OuterRect.is() ) - { - xDiagram_OuterRect->setPosition( awt::Point( aUsedOuterRect.X, aUsedOuterRect.Y ) ); - xDiagram_OuterRect->setSize( awt::Size( aUsedOuterRect.Width, aUsedOuterRect.Height ) ); - } - - //correct axis title position - awt::Rectangle aDiagramPlusAxesRect( aUsedOuterRect ); - if(bAutoPosition_XTitle) - changePositionOfAxisTitle( apVTitle_X.get(), ALIGN_BOTTOM, aDiagramPlusAxesRect, aPageSize ); - if(bAutoPosition_YTitle) - changePositionOfAxisTitle( apVTitle_Y.get(), ALIGN_LEFT, aDiagramPlusAxesRect, aPageSize ); - if(bAutoPosition_ZTitle) - changePositionOfAxisTitle( apVTitle_Z.get(), ALIGN_Z, aDiagramPlusAxesRect, aPageSize ); - if(bAutoPosition_SecondXTitle) - changePositionOfAxisTitle( apVTitle_SecondX.get(), bIsVertical? ALIGN_RIGHT : ALIGN_TOP, aDiagramPlusAxesRect, aPageSize ); - if(bAutoPosition_SecondYTitle) - changePositionOfAxisTitle( apVTitle_SecondY.get(), bIsVertical? ALIGN_TOP : ALIGN_RIGHT, aDiagramPlusAxesRect, aPageSize ); - } - - //cleanup: remove all empty group shapes to avoid grey border lines: - lcl_removeEmptyGroupShapes( mxRootShape ); - - render(); - - if(maTimeBased.bTimeBased && maTimeBased.nFrame % 60 == 0) - { - // create copy of the data for next frame - std::vector<VSeriesPlotter*>& rSeriesPlotter = - aSeriesPlotterContainer.getSeriesPlotterList(); - size_t n = rSeriesPlotter.size(); - maTimeBased.m_aDataSeriesList.clear(); - maTimeBased.m_aDataSeriesList.resize(n); - for(size_t i = 0; i < n; ++i) - { - std::vector< VDataSeries* > aAllNewDataSeries = - rSeriesPlotter[i]->getAllSeries(); - std::vector< VDataSeries* >& rAllOldDataSeries = - maTimeBased.m_aDataSeriesList[i]; - size_t m = aAllNewDataSeries.size(); - for(size_t j = 0; j < m; ++j) - { - rAllOldDataSeries.push_back( aAllNewDataSeries[j]-> - createCopyForTimeBased() ); - } - } - - if(maTimeBased.eMode != MANUAL) - { - mrChartModel.setTimeBased(true); - mrChartModel.getNextTimePoint(); - } - else - maTimeBased.maTimer.Stop(); - } - - if(maTimeBased.bTimeBased && maTimeBased.eMode != MANUAL && !maTimeBased.maTimer.IsActive()) - { - maTimeBased.maTimer.SetTimeout(15); - maTimeBased.maTimer.SetTimeoutHdl(LINK(this, ChartView, UpdateTimeBased)); - maTimeBased.maTimer.Start(); - } - } + createShapes2D(aPageSize); // #i12587# support for shapes in chart if ( m_pDrawModelWrapper ) @@ -3163,6 +2979,195 @@ IMPL_LINK_NOARG(ChartView, UpdateTimeBased) return 0; } +void ChartView::createShapes2D( const awt::Size& rPageSize ) +{ + AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(m_xShapeFactory); + + SolarMutexGuard aSolarGuard; + + // todo: it would be nicer to just pass the page m_xDrawPage and format it, + // but the draw page does not support XPropertySet + formatPage( mrChartModel, rPageSize, mxRootShape, m_xShapeFactory ); + + //sal_Int32 nYDistance = static_cast<sal_Int32>(aPageSize.Height*lcl_getPageLayoutDistancePercentage()); + awt::Rectangle aRemainingSpace( 0, 0, rPageSize.Width, rPageSize.Height ); + + //create the group shape for diagram and axes first to have title and legends on top of it + uno::Reference< XDiagram > xDiagram( mrChartModel.getFirstDiagram() ); + OUString aDiagramCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM, OUString::number( 0 ) ) );//todo: other index if more than one diagram is possible + uno::Reference< drawing::XShapes > xDiagramPlusAxesPlusMarkHandlesGroup_Shapes( + pShapeFactory->createGroup2D(mxRootShape,aDiagramCID) ); + + uno::Reference< drawing::XShape > xDiagram_MarkHandles( pShapeFactory->createInvisibleRectangle( + xDiagramPlusAxesPlusMarkHandlesGroup_Shapes, awt::Size(0,0) ) ); + AbstractShapeFactory::setShapeName( xDiagram_MarkHandles, "MarkHandles" ); + + uno::Reference< drawing::XShape > xDiagram_OuterRect( pShapeFactory->createInvisibleRectangle( + xDiagramPlusAxesPlusMarkHandlesGroup_Shapes, awt::Size(0,0) ) ); + AbstractShapeFactory::setShapeName( xDiagram_OuterRect, "PlotAreaIncludingAxes" ); + + uno::Reference< drawing::XShapes > xDiagramPlusAxes_Shapes( pShapeFactory->createGroup2D(xDiagramPlusAxesPlusMarkHandlesGroup_Shapes ) ); + + bool bAutoPositionDummy = true; + + lcl_createTitle( TitleHelper::MAIN_TITLE, mxRootShape, m_xShapeFactory, mrChartModel + , aRemainingSpace, rPageSize, ALIGN_TOP, bAutoPositionDummy ); + if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) + return; + + lcl_createTitle( TitleHelper::SUB_TITLE, mxRootShape, m_xShapeFactory, mrChartModel + , aRemainingSpace, rPageSize, ALIGN_TOP, bAutoPositionDummy ); + if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) + return; + + SeriesPlotterContainer aSeriesPlotterContainer( m_aVCooSysList ); + aSeriesPlotterContainer.initializeCooSysAndSeriesPlotter( mrChartModel ); + if(maTimeBased.bTimeBased && maTimeBased.nFrame != 0) + { + std::vector<VSeriesPlotter*>& rSeriesPlotter = + aSeriesPlotterContainer.getSeriesPlotterList(); + size_t n = rSeriesPlotter.size(); + for(size_t i = 0; i < n; ++i) + { + std::vector< VDataSeries* > aAllNewDataSeries = + rSeriesPlotter[i]->getAllSeries(); + std::vector< VDataSeries* >& rAllOldDataSeries = + maTimeBased.m_aDataSeriesList[i]; + size_t m = std::min(aAllNewDataSeries.size(), rAllOldDataSeries.size()); + for(size_t j = 0; j < m; ++j) + { + aAllNewDataSeries[j]->setOldTimeBased( + rAllOldDataSeries[j], (maTimeBased.nFrame % 60)/60.0); + } + } + } + + lcl_createLegend( LegendHelper::getLegend( mrChartModel ), mxRootShape, m_xShapeFactory, m_xCC + , aRemainingSpace, rPageSize, mrChartModel, aSeriesPlotterContainer.getLegendEntryProviderList() + , lcl_getDefaultWritingModeFromPool( m_pDrawModelWrapper ) ); + if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) + return; + + Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ); + sal_Int32 nDimension = DiagramHelper::getDimension( xDiagram ); + + bool bAutoPosition_XTitle = true; + boost::shared_ptr<VTitle> apVTitle_X; + if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 0 ) ) + apVTitle_X = lcl_createTitle( TitleHelper::TITLE_AT_STANDARD_X_AXIS_POSITION, mxRootShape, m_xShapeFactory, mrChartModel + , aRemainingSpace, rPageSize, ALIGN_BOTTOM, bAutoPosition_XTitle ); + if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) + return; + + bool bAutoPosition_YTitle = true; + boost::shared_ptr<VTitle> apVTitle_Y; + if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 1 ) ) + apVTitle_Y = lcl_createTitle( TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION, mxRootShape, m_xShapeFactory, mrChartModel + , aRemainingSpace, rPageSize, ALIGN_LEFT, bAutoPosition_YTitle ); + if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) + return; + + bool bAutoPosition_ZTitle = true; + boost::shared_ptr<VTitle> apVTitle_Z; + if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 2 ) ) + apVTitle_Z = lcl_createTitle( TitleHelper::Z_AXIS_TITLE, mxRootShape, m_xShapeFactory, mrChartModel + , aRemainingSpace, rPageSize, ALIGN_RIGHT, bAutoPosition_ZTitle ); + if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) + return; + + bool bDummy = false; + bool bIsVertical = DiagramHelper::getVertical( xDiagram, bDummy, bDummy ); + + bool bAutoPosition_SecondXTitle = true; + boost::shared_ptr<VTitle> apVTitle_SecondX; + if( ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimension, 0 ) ) + apVTitle_SecondX = lcl_createTitle( TitleHelper::SECONDARY_X_AXIS_TITLE, mxRootShape, m_xShapeFactory, mrChartModel + , aRemainingSpace, rPageSize, bIsVertical? ALIGN_RIGHT : ALIGN_TOP, bAutoPosition_SecondXTitle ); + if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) + return; + + bool bAutoPosition_SecondYTitle = true; + boost::shared_ptr<VTitle> apVTitle_SecondY; + if( ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimension, 1 ) ) + apVTitle_SecondY = lcl_createTitle( TitleHelper::SECONDARY_Y_AXIS_TITLE, mxRootShape, m_xShapeFactory, mrChartModel + , aRemainingSpace, rPageSize, bIsVertical? ALIGN_TOP : ALIGN_RIGHT, bAutoPosition_SecondYTitle ); + if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) + return; + + awt::Point aAvailablePosDia; + awt::Size aAvailableSizeForDiagram; + bool bUseFixedInnerSize = false; + if( getAvailablePosAndSizeForDiagram( aAvailablePosDia, aAvailableSizeForDiagram, aRemainingSpace, rPageSize + , mrChartModel.getFirstDiagram(), bUseFixedInnerSize ) ) + { + awt::Rectangle aUsedOuterRect = impl_createDiagramAndContent( aSeriesPlotterContainer + , xDiagramPlusAxes_Shapes + , aAvailablePosDia ,aAvailableSizeForDiagram, rPageSize, bUseFixedInnerSize, xDiagram_MarkHandles ); + + if( xDiagram_OuterRect.is() ) + { + xDiagram_OuterRect->setPosition( awt::Point( aUsedOuterRect.X, aUsedOuterRect.Y ) ); + xDiagram_OuterRect->setSize( awt::Size( aUsedOuterRect.Width, aUsedOuterRect.Height ) ); + } + + //correct axis title position + awt::Rectangle aDiagramPlusAxesRect( aUsedOuterRect ); + if(bAutoPosition_XTitle) + changePositionOfAxisTitle( apVTitle_X.get(), ALIGN_BOTTOM, aDiagramPlusAxesRect, rPageSize ); + if(bAutoPosition_YTitle) + changePositionOfAxisTitle( apVTitle_Y.get(), ALIGN_LEFT, aDiagramPlusAxesRect, rPageSize ); + if(bAutoPosition_ZTitle) + changePositionOfAxisTitle( apVTitle_Z.get(), ALIGN_Z, aDiagramPlusAxesRect, rPageSize ); + if(bAutoPosition_SecondXTitle) + changePositionOfAxisTitle( apVTitle_SecondX.get(), bIsVertical? ALIGN_RIGHT : ALIGN_TOP, aDiagramPlusAxesRect, rPageSize ); + if(bAutoPosition_SecondYTitle) + changePositionOfAxisTitle( apVTitle_SecondY.get(), bIsVertical? ALIGN_TOP : ALIGN_RIGHT, aDiagramPlusAxesRect, rPageSize ); + } + + //cleanup: remove all empty group shapes to avoid grey border lines: + lcl_removeEmptyGroupShapes( mxRootShape ); + + render(); + + if(maTimeBased.bTimeBased && maTimeBased.nFrame % 60 == 0) + { + // create copy of the data for next frame + std::vector<VSeriesPlotter*>& rSeriesPlotter = + aSeriesPlotterContainer.getSeriesPlotterList(); + size_t n = rSeriesPlotter.size(); + maTimeBased.m_aDataSeriesList.clear(); + maTimeBased.m_aDataSeriesList.resize(n); + for(size_t i = 0; i < n; ++i) + { + std::vector< VDataSeries* > aAllNewDataSeries = + rSeriesPlotter[i]->getAllSeries(); + std::vector< VDataSeries* >& rAllOldDataSeries = + maTimeBased.m_aDataSeriesList[i]; + size_t m = aAllNewDataSeries.size(); + for(size_t j = 0; j < m; ++j) + { + rAllOldDataSeries.push_back( aAllNewDataSeries[j]-> + createCopyForTimeBased() ); + } + } + + if(maTimeBased.eMode != MANUAL) + { + mrChartModel.setTimeBased(true); + mrChartModel.getNextTimePoint(); + } + else + maTimeBased.maTimer.Stop(); + } + + if(maTimeBased.bTimeBased && maTimeBased.eMode != MANUAL && !maTimeBased.maTimer.IsActive()) + { + maTimeBased.maTimer.SetTimeout(15); + maTimeBased.maTimer.SetTimeoutHdl(LINK(this, ChartView, UpdateTimeBased)); + maTimeBased.maTimer.Start(); + } +} + void ChartView::createShapes3D() { OpenGLWindow* pWindow = mrChartModel.getOpenGLWindow(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits