diff options
author | Björn Milcke <bm@openoffice.org> | 2003-11-04 11:37:45 +0000 |
---|---|---|
committer | Björn Milcke <bm@openoffice.org> | 2003-11-04 11:37:45 +0000 |
commit | 759b3eb17c50b66794547ed560358678123bddf7 (patch) | |
tree | e7ea3c7c200523c737f18fd44310932771f17fcc /chart2/source/controller | |
parent | b001ff129865a183eab89f310e9b72ae8d1f68ca (diff) |
ChartType concept: the template creates the diagram. To determine with which
template an existing Diagram was probably created, the data series tree is
searched and according to the result the template is guessed.
OldApi chart type support
SubGrid added
Diffstat (limited to 'chart2/source/controller')
18 files changed, 651 insertions, 396 deletions
diff --git a/chart2/source/controller/dialogs/dlg_ChartType.cxx b/chart2/source/controller/dialogs/dlg_ChartType.cxx index 029663b0d9b7..1c47fc1541a3 100644 --- a/chart2/source/controller/dialogs/dlg_ChartType.cxx +++ b/chart2/source/controller/dialogs/dlg_ChartType.cxx @@ -2,9 +2,9 @@ * * $RCSfile: dlg_ChartType.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:25 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -93,14 +93,13 @@ #include "Bitmaps.hrc" #include "Bitmaps_HC.hrc" #include "Strings.hrc" +#include "DataSeriesTreeHelper.hxx" +#include "InlineContainer.hxx" +#include "macros.hxx" -#include "SchSfxItemIds.hxx" +#include <functional> -//#include "SchAllDefinesFor_svx_chrtitem.hxx" -#define ITEMID_CHARTSTYLE SCHATTR_DIAGRAM_STYLE -#ifndef _SVX_CHRTITEM_HXX -#include <svx/chrtitem.hxx> -#endif +#include "SchSfxItemIds.hxx" // header for class SfxInt32Item #ifndef _SFXINTITEM_HXX @@ -141,6 +140,175 @@ //#define CHTYPE_ADDIN 11 //............................................................................. +namespace +{ +typedef ::std::map< ::rtl::OUString, sal_Int32 > tTemplateServiceMap; + +const tTemplateServiceMap & lcl_GetChartTemplateServiceNameMap() +{ + static tTemplateServiceMap aTemplateMap( + ::comphelper::MakeMap< ::rtl::OUString, sal_Int32 > + ( C2U( "com.sun.star.chart2.template.Line" ), CHSTYLE_2D_LINE) + ( C2U( "com.sun.star.chart2.template.StackedLine" ), CHSTYLE_2D_STACKEDLINE) + ( C2U( "com.sun.star.chart2.template.PercentStackedLine" ), CHSTYLE_2D_PERCENTLINE) + ( C2U( "com.sun.star.chart2.template.LineSymbol" ), CHSTYLE_2D_LINESYMBOLS) + ( C2U( "com.sun.star.chart2.template.StackedLineSymbol" ), CHSTYLE_2D_STACKEDLINESYM) + ( C2U( "com.sun.star.chart2.template.PercentStackedLineSymbol" ), CHSTYLE_2D_PERCENTLINESYM) + ( C2U( "com.sun.star.chart2.template.CubicSpline" ), CHSTYLE_2D_CUBIC_SPLINE) + ( C2U( "com.sun.star.chart2.template.CubicSplineSymbol" ), CHSTYLE_2D_CUBIC_SPLINE_SYMBOL) + ( C2U( "com.sun.star.chart2.template.BSpline" ), CHSTYLE_2D_B_SPLINE) + ( C2U( "com.sun.star.chart2.template.BSplineSymbol" ), CHSTYLE_2D_B_SPLINE_SYMBOL) + ( C2U( "com.sun.star.chart2.template.ThreeDLine" ), CHSTYLE_3D_STRIPE) + ( C2U( "com.sun.star.chart2.template.Column" ), CHSTYLE_2D_COLUMN) + ( C2U( "com.sun.star.chart2.template.StackedColumn" ), CHSTYLE_2D_STACKEDCOLUMN) + ( C2U( "com.sun.star.chart2.template.PercentStackedColumn" ), CHSTYLE_2D_PERCENTCOLUMN) + ( C2U( "com.sun.star.chart2.template.Bar" ), CHSTYLE_2D_BAR) + ( C2U( "com.sun.star.chart2.template.StackedBar" ), CHSTYLE_2D_STACKEDBAR) + ( C2U( "com.sun.star.chart2.template.PercentStackedBar" ), CHSTYLE_2D_PERCENTBAR) + ( C2U( "com.sun.star.chart2.template.ThreeDColumnDeep" ), CHSTYLE_3D_COLUMN) + ( C2U( "com.sun.star.chart2.template.ThreeDColumnFlat" ), CHSTYLE_3D_FLATCOLUMN) + ( C2U( "com.sun.star.chart2.template.StackedThreeDColumnFlat" ), CHSTYLE_3D_STACKEDFLATCOLUMN) + ( C2U( "com.sun.star.chart2.template.PercentStackedThreeDColumnFlat" ), CHSTYLE_3D_PERCENTFLATCOLUMN) + ( C2U( "com.sun.star.chart2.template.ThreeDBarDeep" ), CHSTYLE_3D_BAR) + ( C2U( "com.sun.star.chart2.template.ThreeDBarFlat" ), CHSTYLE_3D_FLATBAR) + ( C2U( "com.sun.star.chart2.template.StackedThreeDBarFlat" ), CHSTYLE_3D_STACKEDFLATBAR) + ( C2U( "com.sun.star.chart2.template.PercentStackedThreeDBarFlat" ), CHSTYLE_3D_PERCENTFLATBAR) + ( C2U( "com.sun.star.chart2.template.ColumnWithLine" ), CHSTYLE_2D_LINE_COLUMN) + ( C2U( "com.sun.star.chart2.template.StackedColumnWithLine" ), CHSTYLE_2D_LINE_STACKEDCOLUMN) + ( C2U( "com.sun.star.chart2.template.Area" ), CHSTYLE_2D_AREA) + ( C2U( "com.sun.star.chart2.template.StackedArea" ), CHSTYLE_2D_STACKEDAREA) + ( C2U( "com.sun.star.chart2.template.PercentStackedArea" ), CHSTYLE_2D_PERCENTAREA) + ( C2U( "com.sun.star.chart2.template.ThreeDArea" ), CHSTYLE_3D_AREA) + ( C2U( "com.sun.star.chart2.template.StackedThreeDArea" ), CHSTYLE_3D_STACKEDAREA) + ( C2U( "com.sun.star.chart2.template.PercentStackedThreeDArea" ), CHSTYLE_3D_PERCENTAREA) + ( C2U( "com.sun.star.chart2.template.Pie" ), CHSTYLE_2D_PIE) + ( C2U( "com.sun.star.chart2.template.PieOneExploded" ), CHSTYLE_2D_PIE_SEGOF1) + ( C2U( "com.sun.star.chart2.template.PieAllExploded" ), CHSTYLE_2D_PIE_SEGOFALL) + ( C2U( "com.sun.star.chart2.template.Ring" ), CHSTYLE_2D_DONUT1) +// ( C2U( "com.sun.star.chart2.template.Ring" ), CHSTYLE_2D_DONUT2) + ( C2U( "com.sun.star.chart2.template.ThreeDPie" ), CHSTYLE_3D_PIE) + ( C2U( "com.sun.star.chart2.template.ScatterLineSymbol" ), CHSTYLE_2D_XY) + ( C2U( "com.sun.star.chart2.template.CubicSplineScatter" ), CHSTYLE_2D_CUBIC_SPLINE_XY) + ( C2U( "com.sun.star.chart2.template.CubicSplineScatterSymbol" ), CHSTYLE_2D_CUBIC_SPLINE_SYMBOL_XY) + ( C2U( "com.sun.star.chart2.template.BSplineScatter" ), CHSTYLE_2D_B_SPLINE_XY) + ( C2U( "com.sun.star.chart2.template.BSplineScatterSymbol" ), CHSTYLE_2D_B_SPLINE_SYMBOL_XY) + ( C2U( "com.sun.star.chart2.template.ScatterLine" ), CHSTYLE_2D_XY_LINE) + ( C2U( "com.sun.star.chart2.template.ScatterSymbol" ), CHSTYLE_2D_XYSYMBOLS) + ( C2U( "com.sun.star.chart2.template.Net" ), CHSTYLE_2D_NET) + ( C2U( "com.sun.star.chart2.template.NetSymbol" ), CHSTYLE_2D_NET_SYMBOLS) + ( C2U( "com.sun.star.chart2.template.StackedNet" ), CHSTYLE_2D_NET_STACK) + ( C2U( "com.sun.star.chart2.template.StackedNetSymbol" ), CHSTYLE_2D_NET_SYMBOLS_STACK) + ( C2U( "com.sun.star.chart2.template.PercentStackedNet" ), CHSTYLE_2D_NET_PERCENT) + ( C2U( "com.sun.star.chart2.template.PercentStackedNetSymbol" ), CHSTYLE_2D_NET_SYMBOLS_PERCENT) + ( C2U( "com.sun.star.chart2.template.StockLowHighClose" ), CHSTYLE_2D_STOCK_1) + ( C2U( "com.sun.star.chart2.template.StockOpenLowHighClose" ), CHSTYLE_2D_STOCK_2) + ( C2U( "com.sun.star.chart2.template.StockVolumeLowHighClose" ), CHSTYLE_2D_STOCK_3) + ( C2U( "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ), CHSTYLE_2D_STOCK_4) + ( C2U( "com.sun.star.chart2.template.Surface" ), CHSTYLE_3D_SURFACE) + ( C2U( "com.sun.star.chart2.template.ThreeDScatter" ), CHSTYLE_3D_XYZ) + ( C2U( "com.sun.star.chart2.template.ThreeDScatterSymbol" ), CHSTYLE_3D_XYZSYMBOLS) + ( C2U( "com.sun.star.chart2.template.Addin" ), CHSTYLE_ADDIN) + ); + + return aTemplateMap; +} + +SvxChartStyle lcl_GetChartStyleForTemplateServiceName( const ::rtl::OUString & rServiceName ) +{ + const tTemplateServiceMap & rMap = lcl_GetChartTemplateServiceNameMap(); + tTemplateServiceMap::const_iterator aIt( rMap.find( rServiceName )); + if( aIt != rMap.end()) + return static_cast< SvxChartStyle >( (*aIt).second ); + + return CHSTYLE_ADDIN; +} + +::rtl::OUString lcl_GetTemplateServiceNameForChartStyle( SvxChartStyle eStyle ) +{ + const tTemplateServiceMap & rMap = lcl_GetChartTemplateServiceNameMap(); + tTemplateServiceMap::const_iterator aIt( + ::std::find_if( rMap.begin(), rMap.end(), + ::std::compose1( ::std::bind2nd( + ::std::equal_to< tTemplateServiceMap::data_type >(), + static_cast< sal_Int32 >( eStyle ) ), + ::std::select2nd< tTemplateServiceMap::value_type >()))); + if( aIt != rMap.end()) + return (*aIt).first; + + return ::rtl::OUString(); +} + +bool lcl_IsBSplineChart( SvxChartStyle eStyle ) +{ + switch( eStyle ) + { + case CHSTYLE_2D_B_SPLINE : + case CHSTYLE_2D_B_SPLINE_SYMBOL : + case CHSTYLE_2D_B_SPLINE_XY : + case CHSTYLE_2D_B_SPLINE_SYMBOL_XY : + return true; + + default: + return false; + } + return false; +} + +bool lcl_IsCubicSplineChart( SvxChartStyle eStyle ) +{ + switch( eStyle ) + { + case CHSTYLE_2D_CUBIC_SPLINE : + case CHSTYLE_2D_CUBIC_SPLINE_SYMBOL : + case CHSTYLE_2D_CUBIC_SPLINE_XY : + case CHSTYLE_2D_CUBIC_SPLINE_SYMBOL_XY : + return true; + + default: + return false; + } + return false; +} + +bool lcl_IsShapeStyleChartType( SvxChartStyle eStyle ) +{ + switch( eStyle ) + { + case CHSTYLE_3D_COLUMN: + case CHSTYLE_3D_FLATCOLUMN: + case CHSTYLE_3D_STACKEDFLATCOLUMN: + case CHSTYLE_3D_PERCENTFLATCOLUMN: + case CHSTYLE_3D_BAR: + case CHSTYLE_3D_FLATBAR: + case CHSTYLE_3D_STACKEDFLATBAR: + case CHSTYLE_3D_PERCENTFLATBAR: + return true; + + default: + return false; + } + return false; +} + +bool lcl_IsCombiChart( SvxChartStyle eStyle ) +{ + switch( eStyle ) + { + case CHSTYLE_2D_LINE_COLUMN: + case CHSTYLE_2D_LINE_STACKEDCOLUMN: + return true; + default: + return false; + } + return false; +} + +} // anonymous namespace + +using namespace ::com::sun::star; +using namespace ::drafts::com::sun::star; + +//............................................................................. namespace chart { //............................................................................. @@ -149,30 +317,33 @@ namespace chart // bIsHighContrast must exist and reflect the correct state #define SELECT_BITMAP(name) Bitmap( SchResId( bIsHighContrast ? name ## _HC : name )) -SchDiagramTypeDlg::SchDiagramTypeDlg(Window* pWindow, - const SfxItemSet& rInAttrs) : - ModalDialog(pWindow, SchResId(DLG_DIAGRAM_TYPE)), - - n3DGeometry(CHART_SHAPE3D_ANY), - aRbt2D(this, ResId(RBT_2D)), - aRbt3D(this, ResId(RBT_3D)), - aFlDimension(this, ResId(FL_DIMENSION)), - aFtDeep( this, ResId( FT_DEEP ) ), - aMtrFldDeep( this, ResId( MTR_FLD_DEEP ) ), - aFtGran( this, ResId( FT_GRAN ) ), - aMtrFldGran( this, ResId( MTR_FLD_GRAN ) ), - aFtNumLines( this, ResId( FT_NUM_OF_LINES ) ), - aMtrFldNumLines( this, ResId( MTR_FLD_NUM_OF_LINES ) ), - - aFtType(this, ResId(FT_TYPE)), - aCtlType(this, ResId(CTL_TYPE)), - aFtVariant(this, ResId(FT_VARIANT)), - aCtlVariant(this, ResId(CTL_VARIANT)), - aBtnOK(this, ResId(BTN_OK)), - aBtnCancel(this, ResId(BTN_CANCEL)), - aBtnHelp(this, ResId(BTN_HELP)), - eDimension(CHDIM_2D), - rOutAttrs(rInAttrs) +SchDiagramTypeDlg::SchDiagramTypeDlg( + Window* pWindow, + const uno::Reference< chart2::XDiagram > & xDiagram, + const uno::Reference< lang::XMultiServiceFactory > & xTemplateManager ) : + ModalDialog(pWindow, SchResId(DLG_DIAGRAM_TYPE)), + + n3DGeometry(CHART_SHAPE3D_ANY), + aRbt2D(this, ResId(RBT_2D)), + aRbt3D(this, ResId(RBT_3D)), + aFlDimension(this, ResId(FL_DIMENSION)), + aFtDeep( this, ResId( FT_DEEP ) ), + aMtrFldDeep( this, ResId( MTR_FLD_DEEP ) ), + aFtGran( this, ResId( FT_GRAN ) ), + aMtrFldGran( this, ResId( MTR_FLD_GRAN ) ), + aFtNumLines( this, ResId( FT_NUM_OF_LINES ) ), + aMtrFldNumLines( this, ResId( MTR_FLD_NUM_OF_LINES ) ), + + aFtType(this, ResId(FT_TYPE)), + aCtlType(this, ResId(CTL_TYPE)), + aFtVariant(this, ResId(FT_VARIANT)), + aCtlVariant(this, ResId(CTL_VARIANT)), + aBtnOK(this, ResId(BTN_OK)), + aBtnCancel(this, ResId(BTN_CANCEL)), + aBtnHelp(this, ResId(BTN_HELP)), + eDimension(CHDIM_2D), + m_xDiagram( xDiagram ), + m_xTemplateManager( xTemplateManager ) { FreeResource(); @@ -203,8 +374,8 @@ SchDiagramTypeDlg::SchDiagramTypeDlg(Window* pWindow, Reset(); - //ToDo: This is just to have some default - SetMaximumNumberOfLines( 12 ); + // "- 1": at least one bar should remain + SetMaximumNumberOfLines( helper::DataSeriesTreeHelper::getDataSeriesFromDiagram( m_xDiagram ).getLength() - 1 ); } /************************************************************************* @@ -224,180 +395,169 @@ SchDiagramTypeDlg::~SchDiagramTypeDlg() void SchDiagramTypeDlg::Reset() { - const SfxPoolItem *pPoolItem = NULL; - - if (rOutAttrs.GetItemState(SCHATTR_STYLE_SHAPE, TRUE, &pPoolItem) - == SFX_ITEM_SET) - n3DGeometry=((const SfxInt32Item*)pPoolItem)->GetValue(); + if( ! m_xDiagram.is()) + return; - if (rOutAttrs.GetItemState(SCHATTR_DIAGRAM_STYLE, TRUE, &pPoolItem) - == SFX_ITEM_SET) - { - USHORT nType; - ChartDimension eDim; + uno::Reference< chart2::XDataSeriesTreeParent > xTree( m_xDiagram->getTree()); + SvxChartStyle eStyle = lcl_GetChartStyleForTemplateServiceName( + helper::DataSeriesTreeHelper::getChartTypeTemplateServiceName( xTree )); - //Hier sollte demnaechst folgendes ersatzweise stehen: - //nType=pDoc->GetBaseType(); - //eDim=(pDoc->GetDisplayDimension()==3)?CHDIM_3D:CHDIM_2D; - - switch (((const SvxChartStyleItem*)pPoolItem)->GetValue()) - { - case CHSTYLE_2D_B_SPLINE : - case CHSTYLE_2D_B_SPLINE_SYMBOL : - case CHSTYLE_2D_LINE: - case CHSTYLE_2D_STACKEDLINE: - case CHSTYLE_2D_PERCENTLINE: - case CHSTYLE_2D_LINESYMBOLS: - case CHSTYLE_2D_STACKEDLINESYM: - case CHSTYLE_2D_PERCENTLINESYM: - case CHSTYLE_2D_CUBIC_SPLINE : - case CHSTYLE_2D_CUBIC_SPLINE_SYMBOL : - nType = CHTYPE_LINE; - eDim = CHDIM_2D; - break; - - case CHSTYLE_2D_COLUMN: - case CHSTYLE_2D_STACKEDCOLUMN: - case CHSTYLE_2D_PERCENTCOLUMN: - case CHSTYLE_2D_LINE_COLUMN: - case CHSTYLE_2D_LINE_STACKEDCOLUMN: - - nType = CHTYPE_COLUMN; - eDim = CHDIM_2D; - break; + USHORT nType; + ChartDimension eDim; - case CHSTYLE_2D_BAR: - case CHSTYLE_2D_STACKEDBAR: - case CHSTYLE_2D_PERCENTBAR: - nType = CHTYPE_BAR; - eDim = CHDIM_2D; - break; - - case CHSTYLE_2D_AREA: - case CHSTYLE_2D_STACKEDAREA: - case CHSTYLE_2D_PERCENTAREA: - nType = CHTYPE_AREA; - eDim = CHDIM_2D; - break; + switch( eStyle ) + { + case CHSTYLE_2D_B_SPLINE : + case CHSTYLE_2D_B_SPLINE_SYMBOL : + case CHSTYLE_2D_LINE: + case CHSTYLE_2D_STACKEDLINE: + case CHSTYLE_2D_PERCENTLINE: + case CHSTYLE_2D_LINESYMBOLS: + case CHSTYLE_2D_STACKEDLINESYM: + case CHSTYLE_2D_PERCENTLINESYM: + case CHSTYLE_2D_CUBIC_SPLINE : + case CHSTYLE_2D_CUBIC_SPLINE_SYMBOL : + nType = CHTYPE_LINE; + eDim = CHDIM_2D; + break; - case CHSTYLE_2D_PIE: - case CHSTYLE_2D_PIE_SEGOF1: - case CHSTYLE_2D_PIE_SEGOFALL: - case CHSTYLE_2D_DONUT1: - case CHSTYLE_2D_DONUT2: - nType = CHTYPE_CIRCLE; - eDim = CHDIM_2D; - break; + case CHSTYLE_2D_COLUMN: + case CHSTYLE_2D_STACKEDCOLUMN: + case CHSTYLE_2D_PERCENTCOLUMN: + case CHSTYLE_2D_LINE_COLUMN: + case CHSTYLE_2D_LINE_STACKEDCOLUMN: - case CHSTYLE_2D_B_SPLINE_XY : - case CHSTYLE_2D_XY_LINE : - case CHSTYLE_2D_B_SPLINE_SYMBOL_XY : - case CHSTYLE_2D_XYSYMBOLS: - case CHSTYLE_2D_XY: - case CHSTYLE_2D_CUBIC_SPLINE_XY : - case CHSTYLE_2D_CUBIC_SPLINE_SYMBOL_XY : - nType = CHTYPE_XY; - eDim = CHDIM_2D; - break; + nType = CHTYPE_COLUMN; + eDim = CHDIM_2D; + break; - case CHSTYLE_2D_NET: - case CHSTYLE_2D_NET_SYMBOLS: - case CHSTYLE_2D_NET_STACK: - case CHSTYLE_2D_NET_SYMBOLS_STACK: - case CHSTYLE_2D_NET_PERCENT: - case CHSTYLE_2D_NET_SYMBOLS_PERCENT: - nType = CHTYPE_NET; - eDim = CHDIM_2D; - break; + case CHSTYLE_2D_BAR: + case CHSTYLE_2D_STACKEDBAR: + case CHSTYLE_2D_PERCENTBAR: + nType = CHTYPE_BAR; + eDim = CHDIM_2D; + break; - case CHSTYLE_3D_STRIPE: - nType = CHTYPE_LINE; - eDim = CHDIM_3D; - break; + case CHSTYLE_2D_AREA: + case CHSTYLE_2D_STACKEDAREA: + case CHSTYLE_2D_PERCENTAREA: + nType = CHTYPE_AREA; + eDim = CHDIM_2D; + break; - case CHSTYLE_3D_COLUMN: - case CHSTYLE_3D_FLATCOLUMN: - case CHSTYLE_3D_STACKEDFLATCOLUMN: - case CHSTYLE_3D_PERCENTFLATCOLUMN: - nType = CHTYPE_COLUMN; - eDim = CHDIM_3D; - break; + case CHSTYLE_2D_PIE: + case CHSTYLE_2D_PIE_SEGOF1: + case CHSTYLE_2D_PIE_SEGOFALL: + case CHSTYLE_2D_DONUT1: + case CHSTYLE_2D_DONUT2: + nType = CHTYPE_CIRCLE; + eDim = CHDIM_2D; + break; - case CHSTYLE_3D_BAR: - case CHSTYLE_3D_FLATBAR: - case CHSTYLE_3D_STACKEDFLATBAR: - case CHSTYLE_3D_PERCENTFLATBAR: - nType = CHTYPE_BAR; - eDim = CHDIM_3D; - break; + case CHSTYLE_2D_B_SPLINE_XY : + case CHSTYLE_2D_XY_LINE : + case CHSTYLE_2D_B_SPLINE_SYMBOL_XY : + case CHSTYLE_2D_XYSYMBOLS: + case CHSTYLE_2D_XY: + case CHSTYLE_2D_CUBIC_SPLINE_XY : + case CHSTYLE_2D_CUBIC_SPLINE_SYMBOL_XY : + nType = CHTYPE_XY; + eDim = CHDIM_2D; + break; - case CHSTYLE_3D_AREA: - case CHSTYLE_3D_STACKEDAREA: - case CHSTYLE_3D_PERCENTAREA: - nType = CHTYPE_AREA; - eDim = CHDIM_3D; - break; + case CHSTYLE_2D_NET: + case CHSTYLE_2D_NET_SYMBOLS: + case CHSTYLE_2D_NET_STACK: + case CHSTYLE_2D_NET_SYMBOLS_STACK: + case CHSTYLE_2D_NET_PERCENT: + case CHSTYLE_2D_NET_SYMBOLS_PERCENT: + nType = CHTYPE_NET; + eDim = CHDIM_2D; + break; - case CHSTYLE_3D_PIE: - nType = CHTYPE_CIRCLE; - eDim = CHDIM_3D; - break; + case CHSTYLE_3D_STRIPE: + nType = CHTYPE_LINE; + eDim = CHDIM_3D; + break; - case CHSTYLE_2D_STOCK_1: - case CHSTYLE_2D_STOCK_2: - case CHSTYLE_2D_STOCK_3: - case CHSTYLE_2D_STOCK_4: - nType = CHTYPE_STOCK; - eDim = CHDIM_2D; - break; + case CHSTYLE_3D_COLUMN: + case CHSTYLE_3D_FLATCOLUMN: + case CHSTYLE_3D_STACKEDFLATCOLUMN: + case CHSTYLE_3D_PERCENTFLATCOLUMN: + nType = CHTYPE_COLUMN; + eDim = CHDIM_3D; + break; - default: - DBG_ERROR("Invalid chart style given!"); - return; - } + case CHSTYLE_3D_BAR: + case CHSTYLE_3D_FLATBAR: + case CHSTYLE_3D_STACKEDFLATBAR: + case CHSTYLE_3D_PERCENTFLATBAR: + nType = CHTYPE_BAR; + eDim = CHDIM_3D; + break; - if (eDim == CHDIM_3D) - { - aRbt3D.Check(TRUE); - eDimension = CHDIM_2D; - SelectDimensionHdl(&aRbt3D); - } - else - { - aRbt2D.Check(TRUE); - eDimension = CHDIM_3D; - SelectDimensionHdl(&aRbt2D); - } + case CHSTYLE_3D_AREA: + case CHSTYLE_3D_STACKEDAREA: + case CHSTYLE_3D_PERCENTAREA: + nType = CHTYPE_AREA; + eDim = CHDIM_3D; + break; - aCtlType.SelectItem(nType); - SelectTypeHdl(&aCtlType); + case CHSTYLE_3D_PIE: + nType = CHTYPE_CIRCLE; + eDim = CHDIM_3D; + break; - USHORT nItemChartType = static_cast< USHORT >( - static_cast< const SvxChartStyleItem * >( pPoolItem )->GetValue() ); + case CHSTYLE_2D_STOCK_1: + case CHSTYLE_2D_STOCK_2: + case CHSTYLE_2D_STOCK_3: + case CHSTYLE_2D_STOCK_4: + nType = CHTYPE_STOCK; + eDim = CHDIM_2D; + break; - SwitchDepth( nItemChartType ); - SwitchNumLines( nItemChartType ); + default: + DBG_ERROR("Invalid chart style given!"); + return; } - if (rOutAttrs.GetItemState(SCHATTR_NUM_OF_LINES_FOR_BAR, TRUE, &pPoolItem) - == SFX_ITEM_SET) + if (eDim == CHDIM_3D) { - aMtrFldNumLines.SetValue( - reinterpret_cast< const SfxInt32Item * >( pPoolItem )->GetValue()); + aRbt3D.Check(TRUE); + eDimension = CHDIM_2D; + SelectDimensionHdl(&aRbt3D); } + else + { + aRbt2D.Check(TRUE); + eDimension = CHDIM_3D; + SelectDimensionHdl(&aRbt2D); + } + + aCtlType.SelectItem(nType); + SelectTypeHdl(&aCtlType); - if (rOutAttrs.GetItemState(SCHATTR_SPLINE_RESOLUTION, TRUE, &pPoolItem) - == SFX_ITEM_SET) + SwitchDepth( eStyle ); + SwitchNumLines( eStyle ); + + if( lcl_IsCombiChart( eStyle )) { - aMtrFldGran.SetValue( - reinterpret_cast< const SfxInt32Item * >( pPoolItem )->GetValue()); + sal_Int32 nNumLines = helper::DataSeriesTreeHelper::getNumberOfSeriesForChartTypeByIndex( + xTree, 1 ); + aMtrFldNumLines.SetValue( nNumLines ); } - if (rOutAttrs.GetItemState(SCHATTR_SPLINE_ORDER, TRUE, &pPoolItem) - ==SFX_ITEM_SET) + if( lcl_IsBSplineChart( eStyle ) || + lcl_IsCubicSplineChart( eStyle )) { - aMtrFldDeep.SetValue( - reinterpret_cast< const SfxInt32Item * >( pPoolItem )->GetValue()); + // todo: take model value (XChartType) + SetGranularity( 20 ); + + if( lcl_IsBSplineChart( eStyle )) + { + // todo: take model value (XChartType) + SetDepth( 3 ); + } } } @@ -806,35 +966,40 @@ void SchDiagramTypeDlg::FillVariantSet(USHORT nType) aCtlVariant.Show(); USHORT nSelId = aCtlVariant.GetItemId(0); - const SfxPoolItem *pPoolItem = NULL; - if( rOutAttrs.GetItemState(SCHATTR_DIAGRAM_STYLE, TRUE, &pPoolItem) == SFX_ITEM_SET ) - { - USHORT nId = (USHORT)((const SvxChartStyleItem*)pPoolItem)->GetValue() + 1; + uno::Reference< chart2::XDataSeriesTreeParent > xTree( m_xDiagram->getTree()); + SvxChartStyle eStyle = lcl_GetChartStyleForTemplateServiceName( + helper::DataSeriesTreeHelper::getChartTypeTemplateServiceName( xTree )); - if( aCtlVariant.GetItemPos(nId) != VALUESET_ITEM_NOTFOUND ) - { - nSelId = nId; - nDefaultOffset = 0; - } + USHORT nId = static_cast< USHORT >( eStyle ) + 1; +// (USHORT)((const SvxChartStyleItem*)pPoolItem)->GetValue() + 1; + + if( aCtlVariant.GetItemPos( nId ) != VALUESET_ITEM_NOTFOUND ) + { + nSelId = nId; + nDefaultOffset = 0; } + long nShape3dOffset = 0; - if( rOutAttrs.GetItemState(SCHATTR_STYLE_SHAPE, TRUE, &pPoolItem) == SFX_ITEM_SET ) + if( lcl_IsShapeStyleChartType( eStyle )) { -// long nId3D = ((const SfxInt32Item*)&pPoolItem)->GetValue(); - switch( n3DGeometry ) - { - case CHART_SHAPE3D_CYLINDER: - nShape3dOffset = OFFSET_ROUND; - break; - case CHART_SHAPE3D_CONE: - nShape3dOffset = OFFSET_CONE; - break; - case CHART_SHAPE3D_PYRAMID: - nShape3dOffset = OFFSET_PYRAMID; - break; - } + nShape3dOffset = OFFSET_CONE; } + +// long nId3D = ((const SfxInt32Item*)&pPoolItem)->GetValue(); +// switch( n3DGeometry ) +// { +// case CHART_SHAPE3D_CYLINDER: +// nShape3dOffset = OFFSET_ROUND; +// break; +// case CHART_SHAPE3D_CONE: +// nShape3dOffset = OFFSET_CONE; +// break; +// case CHART_SHAPE3D_PYRAMID: +// nShape3dOffset = OFFSET_PYRAMID; +// break; +// } + if( aCtlVariant.GetItemPos( nSelId + nShape3dOffset + nDefaultOffset ) != VALUESET_ITEM_NOTFOUND ) nSelId += (nShape3dOffset + nDefaultOffset); @@ -843,8 +1008,9 @@ void SchDiagramTypeDlg::FillVariantSet(USHORT nType) // make selected Item visible aCtlVariant.SetFirstLine( aCtlVariant.GetItemPos( aCtlVariant.GetSelectItemId() ) / aCtlVariant.GetColCount() ); - SwitchDepth( nSelId - 1 ); - SwitchNumLines( nSelId - 1 ); + eStyle = static_cast< SvxChartStyle >( nSelId - 1 ); + SwitchDepth( eStyle ); + SwitchNumLines( eStyle ); } /************************************************************************* @@ -889,36 +1055,36 @@ IMPL_LINK( SchDiagramTypeDlg, DoubleClickHdl, void *, EMPTYARG ) |* \*************************************************************************/ -void SchDiagramTypeDlg::GetAttr(SfxItemSet& rOutAttrs) -{ - long nId=aCtlVariant.GetSelectItemId() - 1; - long nGeo=CHART_SHAPE3D_ANY; - if(nId>OFFSET_CONE) - { - nId-=OFFSET_CONE; - nGeo=CHART_SHAPE3D_CONE; - } - if(nId>OFFSET_ROUND) - { - nId-=OFFSET_ROUND; - nGeo=CHART_SHAPE3D_CYLINDER; - } - if(nId>OFFSET_PYRAMID) - { - nId-=OFFSET_PYRAMID; - nGeo=CHART_SHAPE3D_PYRAMID; - } - if(nGeo != n3DGeometry) - rOutAttrs.Put(SfxInt32Item(SCHATTR_STYLE_SHAPE,nGeo)); - else - rOutAttrs.ClearItem(SCHATTR_STYLE_SHAPE); - - rOutAttrs.Put(SvxChartStyleItem((SvxChartStyle) (nId))); - - rOutAttrs.Put( SfxInt32Item( SCHATTR_NUM_OF_LINES_FOR_BAR, aMtrFldNumLines.GetValue())); - rOutAttrs.Put( SfxInt32Item( SCHATTR_SPLINE_RESOLUTION, aMtrFldGran.GetValue())); - rOutAttrs.Put( SfxInt32Item( SCHATTR_SPLINE_ORDER, aMtrFldDeep.GetValue())); -} +// void SchDiagramTypeDlg::GetAttr(SfxItemSet& rOutAttrs) +// { +// long nId=aCtlVariant.GetSelectItemId() - 1; +// long nGeo=CHART_SHAPE3D_ANY; +// if(nId>OFFSET_CONE) +// { +// nId-=OFFSET_CONE; +// nGeo=CHART_SHAPE3D_CONE; +// } +// if(nId>OFFSET_ROUND) +// { +// nId-=OFFSET_ROUND; +// nGeo=CHART_SHAPE3D_CYLINDER; +// } +// if(nId>OFFSET_PYRAMID) +// { +// nId-=OFFSET_PYRAMID; +// nGeo=CHART_SHAPE3D_PYRAMID; +// } +// if(nGeo != n3DGeometry) +// rOutAttrs.Put(SfxInt32Item(SCHATTR_STYLE_SHAPE,nGeo)); +// else +// rOutAttrs.ClearItem(SCHATTR_STYLE_SHAPE); + +// rOutAttrs.Put(SvxChartStyleItem((SvxChartStyle) (nId))); + +// rOutAttrs.Put( SfxInt32Item( SCHATTR_NUM_OF_LINES_FOR_BAR, aMtrFldNumLines.GetValue())); +// rOutAttrs.Put( SfxInt32Item( SCHATTR_SPLINE_RESOLUTION, aMtrFldGran.GetValue())); +// rOutAttrs.Put( SfxInt32Item( SCHATTR_SPLINE_ORDER, aMtrFldDeep.GetValue())); +// } /************************************************************************* |* @@ -926,10 +1092,10 @@ void SchDiagramTypeDlg::GetAttr(SfxItemSet& rOutAttrs) |* \************************************************************************/ -// int SchDiagramTypeDlg::GetDepth() -// { -// return aMtrFldDeep.GetValue(); -// } +sal_Int32 SchDiagramTypeDlg::GetDepth() +{ + return aMtrFldDeep.GetValue(); +} /************************************************************************* |* @@ -937,10 +1103,10 @@ void SchDiagramTypeDlg::GetAttr(SfxItemSet& rOutAttrs) |* \************************************************************************/ -// void SchDiagramTypeDlg::SetDepth( int nDepth ) -// { -// aMtrFldDeep.SetValue( nDepth ); -// } +void SchDiagramTypeDlg::SetDepth( sal_Int32 nDepth ) +{ + aMtrFldDeep.SetValue( nDepth ); +} /************************************************************************* |* @@ -948,32 +1114,23 @@ void SchDiagramTypeDlg::GetAttr(SfxItemSet& rOutAttrs) |* \************************************************************************/ -void SchDiagramTypeDlg::SwitchDepth (USHORT nID) +void SchDiagramTypeDlg::SwitchDepth( SvxChartStyle eID ) { - aFtDeep.Hide (); - aMtrFldDeep.Hide (); - aFtGran.Hide (); - aMtrFldGran.Hide (); + aFtDeep.Hide(); + aMtrFldDeep.Hide(); + aFtGran.Hide(); + aMtrFldGran.Hide(); - switch (nID) + if( lcl_IsBSplineChart( eID )) { - case CHSTYLE_2D_B_SPLINE : - case CHSTYLE_2D_B_SPLINE_SYMBOL : - case CHSTYLE_2D_B_SPLINE_XY : - case CHSTYLE_2D_B_SPLINE_SYMBOL_XY : - aFtDeep.Show (); - aMtrFldDeep.Show (); - - case CHSTYLE_2D_CUBIC_SPLINE : - case CHSTYLE_2D_CUBIC_SPLINE_SYMBOL : - case CHSTYLE_2D_CUBIC_SPLINE_XY : - case CHSTYLE_2D_CUBIC_SPLINE_SYMBOL_XY : - aFtGran.Show (); - aMtrFldGran.Show (); - break; + aFtDeep.Show (); + aMtrFldDeep.Show (); + } - default : - break; + if( lcl_IsCubicSplineChart( eID )) + { + aFtGran.Show (); + aMtrFldGran.Show (); } } @@ -985,8 +1142,11 @@ void SchDiagramTypeDlg::SwitchDepth (USHORT nID) IMPL_LINK( SchDiagramTypeDlg, ClickHdl, void *, EMPTYARG ) { - SwitchDepth (aCtlVariant.GetSelectItemId() - 1); - SwitchNumLines( aCtlVariant.GetSelectItemId() - 1 ); + SvxChartStyle eStyle = static_cast< SvxChartStyle >( + aCtlVariant.GetSelectItemId() - 1 ); + + SwitchDepth( eStyle ); + SwitchNumLines( eStyle ); return 0; } @@ -996,10 +1156,10 @@ IMPL_LINK( SchDiagramTypeDlg, ClickHdl, void *, EMPTYARG ) |* \************************************************************************/ -// int SchDiagramTypeDlg::GetGranularity() -// { -// return aMtrFldGran.GetValue(); -// } +sal_Int32 SchDiagramTypeDlg::GetGranularity() +{ + return aMtrFldGran.GetValue(); +} /************************************************************************* |* @@ -1007,10 +1167,10 @@ IMPL_LINK( SchDiagramTypeDlg, ClickHdl, void *, EMPTYARG ) |* \************************************************************************/ -// void SchDiagramTypeDlg::SetGranularity( int nGranularity ) -// { -// aMtrFldGran.SetValue( nGranularity ); -// } +void SchDiagramTypeDlg::SetGranularity( sal_Int32 nGranularity ) +{ + aMtrFldGran.SetValue( nGranularity ); +} void SchDiagramTypeDlg::FillValueSets() { @@ -1034,20 +1194,17 @@ void SchDiagramTypeDlg::DataChanged( const DataChangedEvent& rDCEvt ) } -void SchDiagramTypeDlg::SwitchNumLines( USHORT nID ) +void SchDiagramTypeDlg::SwitchNumLines( SvxChartStyle eID ) { - switch( nID ) + if( lcl_IsCombiChart( eID )) { - case CHSTYLE_2D_LINE_COLUMN: - case CHSTYLE_2D_LINE_STACKEDCOLUMN: - aFtNumLines.Show(); - aMtrFldNumLines.Show(); - break; - - default: - aFtNumLines.Hide(); - aMtrFldNumLines.Hide(); - break; + aFtNumLines.Show(); + aMtrFldNumLines.Show(); + } + else + { + aFtNumLines.Hide(); + aMtrFldNumLines.Hide(); } } @@ -1057,15 +1214,45 @@ void SchDiagramTypeDlg::SetMaximumNumberOfLines( long nMaxLines ) aMtrFldNumLines.SetMax( nMaxLines ); } +uno::Reference< chart2::XChartTypeTemplate > SchDiagramTypeDlg::getTemplate() const +{ + uno::Reference< chart2::XChartTypeTemplate > xResult; + + if( m_xTemplateManager.is()) + { + SvxChartStyle eStyle = static_cast< SvxChartStyle >( + aCtlVariant.GetSelectItemId() - 1 ); + + xResult.set( m_xTemplateManager->createInstance( + lcl_GetTemplateServiceNameForChartStyle( eStyle )), + uno::UNO_QUERY ); + + if( lcl_IsCombiChart( eStyle )) + { + try + { + uno::Reference< beans::XPropertySet > xProp( xResult, uno::UNO_QUERY_THROW ); + xProp->setPropertyValue( C2U( "NumberOfLines" ), uno::makeAny( GetNumberOfLines())); + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + } + + return xResult; +} + // void SchDiagramTypeDlg::SetNumberOfLines( long nLines ) // { // aMtrFldNumLines.SetValue( nLines ); // } -// long SchDiagramTypeDlg::GetNumberOfLines() const -// { -// return aMtrFldNumLines.GetValue(); -// } +sal_Int32 SchDiagramTypeDlg::GetNumberOfLines() const +{ + return aMtrFldNumLines.GetValue(); +} //............................................................................. } //namespace chart diff --git a/chart2/source/controller/inc/AxisItemConverter.hxx b/chart2/source/controller/inc/AxisItemConverter.hxx index 8f4115ed0cc1..5581e6a83e1c 100644 --- a/chart2/source/controller/inc/AxisItemConverter.hxx +++ b/chart2/source/controller/inc/AxisItemConverter.hxx @@ -2,9 +2,9 @@ * * $RCSfile: AxisItemConverter.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: bm $ $Date: 2003-10-17 14:30:08 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:13 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -106,7 +106,7 @@ protected: virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const throw( ::com::sun::star::uno::Exception ); - virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) const + virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) throw( ::com::sun::star::uno::Exception ); private: diff --git a/chart2/source/controller/inc/CharacterPropertyItemConverter.hxx b/chart2/source/controller/inc/CharacterPropertyItemConverter.hxx index 8810ef51de66..178940f58314 100644 --- a/chart2/source/controller/inc/CharacterPropertyItemConverter.hxx +++ b/chart2/source/controller/inc/CharacterPropertyItemConverter.hxx @@ -2,9 +2,9 @@ * * $RCSfile: CharacterPropertyItemConverter.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: bm $ $Date: 2003-10-17 14:30:09 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:13 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -91,7 +91,7 @@ protected: virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const throw( ::com::sun::star::uno::Exception ); - virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) const + virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) throw( ::com::sun::star::uno::Exception ); }; diff --git a/chart2/source/controller/inc/DataPointItemConverter.hxx b/chart2/source/controller/inc/DataPointItemConverter.hxx index bb5df88cf1a4..7f3781338b13 100644 --- a/chart2/source/controller/inc/DataPointItemConverter.hxx +++ b/chart2/source/controller/inc/DataPointItemConverter.hxx @@ -2,9 +2,9 @@ * * $RCSfile: DataPointItemConverter.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: bm $ $Date: 2003-10-17 14:30:09 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:13 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -97,7 +97,7 @@ protected: virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const throw( ::com::sun::star::uno::Exception ); - virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) const + virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) throw( ::com::sun::star::uno::Exception ); private: diff --git a/chart2/source/controller/inc/GraphicPropertyItemConverter.hxx b/chart2/source/controller/inc/GraphicPropertyItemConverter.hxx index 538b7f3f4f16..6156165f7dbf 100644 --- a/chart2/source/controller/inc/GraphicPropertyItemConverter.hxx +++ b/chart2/source/controller/inc/GraphicPropertyItemConverter.hxx @@ -2,9 +2,9 @@ * * $RCSfile: GraphicPropertyItemConverter.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: bm $ $Date: 2003-10-17 14:30:09 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:13 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -104,12 +104,12 @@ protected: virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const throw( ::com::sun::star::uno::Exception ); - virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) const + virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) throw( ::com::sun::star::uno::Exception ); void FillBitmapItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const throw( ::com::sun::star::beans::UnknownPropertyException ); - void ApplyBitmapItem( USHORT nWhichId, const SfxItemSet & rItemSet ) const + void ApplyBitmapItem( USHORT nWhichId, const SfxItemSet & rItemSet ) throw( ::com::sun::star::beans::UnknownPropertyException ); private: diff --git a/chart2/source/controller/inc/ItemConverter.hxx b/chart2/source/controller/inc/ItemConverter.hxx index cc438bd69c13..025eac3bb2af 100644 --- a/chart2/source/controller/inc/ItemConverter.hxx +++ b/chart2/source/controller/inc/ItemConverter.hxx @@ -2,9 +2,9 @@ * * $RCSfile: ItemConverter.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: bm $ $Date: 2003-10-17 14:30:10 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:14 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -166,6 +166,12 @@ public: */ bool IsValid() const; + /** Returns the XPropertySet that was given in the CTOR and is used to apply + items in ApplyItemSet(). + */ + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > GetPropertySet() const; + /** Invalidates all items in rDestSet, that are set (state SFX_ITEM_SET) in both item sets (rDestSet and rSourceSet) and have differing content. */ @@ -215,20 +221,21 @@ protected: @return true if the item changed a property, false otherwise. */ - virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) const + virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) throw( ::com::sun::star::uno::Exception ); + /** If the XPropertySet has to change during the converting (necessary for ChartType) + */ + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > + SetNewPropertySet( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & xNewProp ); + // ________ /// Returns the pool SfxItemPool & GetItemPool() const; - /** Returns the XPropertySet that was given in the CTOR and is used to apply - items in ApplyItemSet(). - */ - ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > GetPropertySet() const; - // ____ ::utl::OEventListenerAdapter ____ virtual void _disposing( const ::com::sun::star::lang::EventObject& _rSource ); diff --git a/chart2/source/controller/inc/LegendItemConverter.hxx b/chart2/source/controller/inc/LegendItemConverter.hxx index c583e04915fe..2fd3323386d1 100644 --- a/chart2/source/controller/inc/LegendItemConverter.hxx +++ b/chart2/source/controller/inc/LegendItemConverter.hxx @@ -2,9 +2,9 @@ * * $RCSfile: LegendItemConverter.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: bm $ $Date: 2003-10-17 14:30:10 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:14 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -92,7 +92,7 @@ protected: virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const throw( ::com::sun::star::uno::Exception ); - virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) const + virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) throw( ::com::sun::star::uno::Exception ); private: diff --git a/chart2/source/controller/inc/TitleItemConverter.hxx b/chart2/source/controller/inc/TitleItemConverter.hxx index eac217d814fb..8551991c7034 100644 --- a/chart2/source/controller/inc/TitleItemConverter.hxx +++ b/chart2/source/controller/inc/TitleItemConverter.hxx @@ -2,9 +2,9 @@ * * $RCSfile: TitleItemConverter.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: bm $ $Date: 2003-10-17 14:30:10 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:14 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -92,7 +92,7 @@ protected: virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const throw( ::com::sun::star::uno::Exception ); - virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) const + virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) throw( ::com::sun::star::uno::Exception ); private: diff --git a/chart2/source/controller/inc/dlg_ChartType.hxx b/chart2/source/controller/inc/dlg_ChartType.hxx index b5b047cb02ec..fee2df40b594 100644 --- a/chart2/source/controller/inc/dlg_ChartType.hxx +++ b/chart2/source/controller/inc/dlg_ChartType.hxx @@ -2,9 +2,9 @@ * * $RCSfile: dlg_ChartType.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:27 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:14 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -109,6 +109,20 @@ #ifndef _SFXITEMSET_HXX #include <svtools/itemset.hxx> #endif +// header for SvxChartStyle +#ifndef _SVX_CHRTITEM_HXX +#include <svx/chrtitem.hxx> +#endif + +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XDIAGRAM_HPP_ +#include <drafts/com/sun/star/chart2/XDiagram.hpp> +#endif +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XCHARTTYPETEMPLATE_HPP_ +#include <drafts/com/sun/star/chart2/XChartTypeTemplate.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif //............................................................................. namespace chart @@ -151,7 +165,12 @@ private: HelpButton aBtnHelp; ChartDimension eDimension; - const SfxItemSet& rOutAttrs; +// const SfxItemSet& rOutAttrs; + + ::com::sun::star::uno::Reference< + ::drafts::com::sun::star::chart2::XDiagram > m_xDiagram; + ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XMultiServiceFactory > m_xTemplateManager; void Reset(); @@ -163,31 +182,37 @@ private: DECL_LINK(DoubleClickHdl, void*); DECL_LINK(ClickHdl, void*); - void SwitchDepth (USHORT nID); + void SwitchDepth( SvxChartStyle eID ); /** Hides/Shows the controls for line/bar combination chart according to the chart type id given as nID. */ - void SwitchNumLines( USHORT nID ); + void SwitchNumLines( SvxChartStyle eID ); void FillValueSets(); public: - SchDiagramTypeDlg(Window* pWindow, const SfxItemSet& rInAttrs); + SchDiagramTypeDlg( + Window* pWindow, + const ::com::sun::star::uno::Reference< + ::drafts::com::sun::star::chart2::XDiagram > & xDiagram, + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XMultiServiceFactory > & xTemplateManager ); virtual ~SchDiagramTypeDlg(); - void GetAttr(SfxItemSet& rOutAttrs); -// int GetDepth(); -// void SetDepth( int nDeep ); +//BM void GetAttr(SfxItemSet& rOutAttrs); -// int GetGranularity(); -// void SetGranularity( int nGranularity ); + sal_Int32 GetDepth(); + void SetDepth( sal_Int32 nDeep ); + + sal_Int32 GetGranularity(); + void SetGranularity( sal_Int32 nGranularity ); /** The value set here determines the maximum number of lines in a line/bar combination chart. This should usually be one less than the number of series, such that at least one series remains a bar. */ - void SetMaximumNumberOfLines( long nMaxLines ); + void SetMaximumNumberOfLines( sal_Int32 nMaxLines ); /** set the current number of lines that are used in a line/bar combination chart. */ @@ -195,9 +220,13 @@ public: /** get the number of lines that should be used for a line/bar combination chart. This has to be set before to be meaningful */ -// long GetNumberOfLines() const; + sal_Int32 GetNumberOfLines() const; virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + ::com::sun::star::uno::Reference< + ::drafts::com::sun::star::chart2::XChartTypeTemplate > + getTemplate() const; }; //............................................................................. diff --git a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx index b4ec9d21085c..6577a07ccdd6 100644 --- a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx @@ -2,9 +2,9 @@ * * $RCSfile: AxisItemConverter.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: bm $ $Date: 2003-10-17 14:30:13 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:16 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -436,7 +436,7 @@ void AxisItemConverter::FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemS } } -bool AxisItemConverter::ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) const +bool AxisItemConverter::ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) throw( uno::Exception ) { if( ! ( m_xAxis.is() && diff --git a/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx b/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx index c5abbd41de63..099a8a75cd88 100644 --- a/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx @@ -2,9 +2,9 @@ * * $RCSfile: CharacterPropertyItemConverter.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: bm $ $Date: 2003-10-17 14:30:13 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -249,7 +249,7 @@ void CharacterPropertyItemConverter::FillSpecialItem( } bool CharacterPropertyItemConverter::ApplySpecialItem( - USHORT nWhichId, const SfxItemSet & rItemSet ) const + USHORT nWhichId, const SfxItemSet & rItemSet ) throw( uno::Exception ) { bool bChanged = false; diff --git a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx index 0bb4d256ab1f..cf2bfd899751 100644 --- a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx @@ -2,9 +2,9 @@ * * $RCSfile: DataPointItemConverter.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: bm $ $Date: 2003-10-17 14:30:14 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -162,7 +162,7 @@ bool DataPointItemConverter::GetItemPropertyName( USHORT nWhichId, ::rtl::OUStri bool DataPointItemConverter::ApplySpecialItem( - USHORT nWhichId, const SfxItemSet & rItemSet ) const + USHORT nWhichId, const SfxItemSet & rItemSet ) throw( uno::Exception ) { bool bChanged = false; diff --git a/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx b/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx index efb4ea7270fa..490b4b8c95f3 100644 --- a/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx @@ -2,9 +2,9 @@ * * $RCSfile: GraphicPropertyItemConverter.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: bm $ $Date: 2003-10-17 14:30:14 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -416,7 +416,7 @@ void GraphicPropertyItemConverter::FillSpecialItem( } bool GraphicPropertyItemConverter::ApplySpecialItem( - USHORT nWhichId, const SfxItemSet & rItemSet ) const + USHORT nWhichId, const SfxItemSet & rItemSet ) throw( uno::Exception ) { // if( m_eGraphicObjectType == LINE_DATA_POINT || @@ -631,7 +631,7 @@ void GraphicPropertyItemConverter::FillBitmapItem( } void GraphicPropertyItemConverter::ApplyBitmapItem( - USHORT nWhichId, const SfxItemSet & rItemSet ) const + USHORT nWhichId, const SfxItemSet & rItemSet ) throw( beans::UnknownPropertyException ) { static const ::rtl::OUString aBitmapPropName( diff --git a/chart2/source/controller/itemsetwrapper/ItemConverter.cxx b/chart2/source/controller/itemsetwrapper/ItemConverter.cxx index eed966a7279c..204fb74bcac6 100644 --- a/chart2/source/controller/itemsetwrapper/ItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/ItemConverter.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ItemConverter.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: bm $ $Date: 2003-10-17 14:30:14 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -127,6 +127,32 @@ uno::Reference< beans::XPropertySet > ItemConverter::GetPropertySet() const return m_xPropertySet; } +uno::Reference< beans::XPropertySet > ItemConverter::SetNewPropertySet( + const uno::Reference< beans::XPropertySet > & xNewProp ) +{ + uno::Reference< lang::XComponent > xComp( m_xPropertySet, uno::UNO_QUERY ); + if( xComp.is()) + { + // method of base class ::utl::OEventListenerAdapter + stopComponentListening( xComp ); + } + + m_xPropertySetInfo.set( NULL ); + m_xPropertySet.set( xNewProp ); + + if( m_xPropertySet.is()) + { + m_xPropertySetInfo.set( m_xPropertySet->getPropertySetInfo()); + + uno::Reference< lang::XComponent > xNewComp( m_xPropertySet, uno::UNO_QUERY ); + if( xNewComp.is()) + { + // method of base class ::utl::OEventListenerAdapter + startComponentListening( xNewComp ); + } + } +} + void ItemConverter::_disposing( const lang::EventObject& _rSource ) { if( _rSource.Source == m_xPropertySet ) @@ -221,7 +247,7 @@ void ItemConverter::FillSpecialItem( } bool ItemConverter::ApplySpecialItem( - USHORT nWhichId, const SfxItemSet & rItemSet ) const + USHORT nWhichId, const SfxItemSet & rItemSet ) throw( uno::Exception ) { OSL_ENSURE( false, "ItemConverter: Unhandled special item found!" ); diff --git a/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx b/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx index 9cb57ed67ab5..84c1dd2dfdb4 100644 --- a/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx @@ -2,9 +2,9 @@ * * $RCSfile: LegendItemConverter.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: bm $ $Date: 2003-10-17 14:30:14 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -166,7 +166,7 @@ bool LegendItemConverter::GetItemPropertyName( USHORT nWhichId, ::rtl::OUString bool LegendItemConverter::ApplySpecialItem( - USHORT nWhichId, const SfxItemSet & rItemSet ) const + USHORT nWhichId, const SfxItemSet & rItemSet ) throw( uno::Exception ) { bool bChanged = false; diff --git a/chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx b/chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx index 8a5b9d9c740c..592fe71d7031 100644 --- a/chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx @@ -2,9 +2,9 @@ * * $RCSfile: TitleItemConverter.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: bm $ $Date: 2003-10-17 14:30:15 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -209,7 +209,7 @@ bool TitleItemConverter::GetItemPropertyName( USHORT nWhichId, ::rtl::OUString & bool TitleItemConverter::ApplySpecialItem( - USHORT nWhichId, const SfxItemSet & rItemSet ) const + USHORT nWhichId, const SfxItemSet & rItemSet ) throw( uno::Exception ) { bool bChanged = false; diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index c21b4983e565..2fc602a1fa87 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ChartController.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: iha $ $Date: 2003-10-30 12:15:45 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:19 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -71,6 +71,7 @@ #include "ChartWindow.hxx" #include "DrawModelWrapper.hxx" #include "DrawViewWrapper.hxx" +#include "DataSeriesTreeHelper.hxx" #include "macros.hxx" @@ -90,6 +91,9 @@ #ifndef _DRAFTS_COM_SUN_STAR_CHART2_XSTACKABLESCALEGROUP_HPP_ #include <drafts/com/sun/star/chart2/XStackableScaleGroup.hpp> #endif +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XCHARTTYPETEMPLATE_HPP_ +#include <drafts/com/sun/star/chart2/XChartTypeTemplate.hpp> +#endif //------- // header for define RET_OK @@ -1077,52 +1081,55 @@ void SAL_CALL ChartController::executeDispatch_ChartType() //------------------------------------------------------------- //convert properties to ItemSet - uno::Reference< beans::XPropertySet > xProp; - uno::Reference< XChartDocument > xChartDoc( m_aModel->getModel(), uno::UNO_QUERY ); - if( xChartDoc.is()) - xProp.set( xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); - DBG_ASSERT( xProp.is(), "Invalid ChartTypeManager" ); + uno::Reference< XChartDocument > xChartDoc( m_aModel->getModel(), uno::UNO_QUERY ); + DBG_ASSERT( xChartDoc.is(), "Invalid XChartDocument" ); + if( !xChartDoc.is()) + return; + uno::Reference< XDiagram > xDia( xChartDoc->getDiagram() ); + DBG_ASSERT( xDia.is(), "No Diagram set!" ); + uno::Reference< XChartTypeTemplate > xTemplate; + if( xChartDoc.is()) { - wrapper::ChartTypeItemConverter aItemConverter( xProp, m_pDrawModelWrapper->GetItemPool() ); - SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet();//creates only an empty itemset - aItemConverter.FillItemSet( aItemSet ); + uno::Reference< lang::XMultiServiceFactory > xCTManager( xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); +// wrapper::ChartTypeItemConverter aItemConverter( xCTManager, xProp, m_pDrawModelWrapper->GetItemPool() ); +// SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet();//creates only an empty itemset +// aItemConverter.FillItemSet( aItemSet ); //------------------------------------------------------------- //prepare and open dialog Window* pParent( NULL ); - SchDiagramTypeDlg aDlg( pParent, aItemSet ); + SchDiagramTypeDlg aDlg( pParent, xDia, xCTManager ); if( aDlg.Execute() == RET_OK ) { - SfxItemSet aOutItemSet = aItemConverter.CreateEmptyItemSet(); - aDlg.GetAttr( aOutItemSet ); +// SfxItemSet aOutItemSet = aItemConverter.CreateEmptyItemSet(); +// aDlg.GetAttr( aOutItemSet ); + +// bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now - bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now +// // XPropertySet may have been changed +// uno::Reference< beans::XPropertySet > xNewProp( aItemConverter.GetPropertySet()); +// bChanged = bChanged || (xProp != xNewProp); +// xProp = xNewProp; + xTemplate.set( aDlg.getTemplate()); + bChanged = true; } } try { //make sure that all objects using m_pDrawModelWrapper or m_pChartView are already deleted - if(bChanged && - xChartDoc.is()) + if( bChanged && + xTemplate.is() ) { - uno::Reference< lang::XMultiServiceFactory > xFact( xProp, uno::UNO_QUERY ); - if( xFact.is() ) - { - ::rtl::OUString aServiceName; - if( xProp->getPropertyValue( C2U( "ChartStyleTemplateServiceName" )) >>= aServiceName ) - { - uno::Reference< XChartTypeTemplate > xTemplate( - xFact->createInstance( aServiceName ), uno::UNO_QUERY ); - xChartDoc->setChartTypeTemplate( xTemplate ); - if( xTemplate.is()) - xTemplate->changeDiagram( xChartDoc->getDiagram() ); - impl_rebuildView(); - } - } + xChartDoc->setDiagram( + xTemplate->createDiagram( + helper::DataSeriesTreeHelper::getDataSeriesFromDiagram( + xChartDoc->getDiagram()))); + + impl_rebuildView(); } } - catch( uno::RuntimeException& e) + catch( uno::Exception& e) { ASSERT_EXCEPTION( e ); } diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx index b29f63cad9db..e1a9b1df5f12 100644 --- a/chart2/source/controller/main/ChartController_Insert.cxx +++ b/chart2/source/controller/main/ChartController_Insert.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ChartController_Insert.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: iha $ $Date: 2003-10-28 15:54:47 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:19 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -75,9 +75,6 @@ #include "MultipleChartConverters.hxx" #include "LegendItemConverter.hxx" -//maybe superfluous in future: -#include "ChartTypeItemConverter.hxx" - #ifndef _DRAFTS_COM_SUN_STAR_CHART2_XAXISCONTAINER_HPP_ #include <drafts/com/sun/star/chart2/XAxisContainer.hpp> #endif @@ -522,8 +519,9 @@ void SAL_CALL ChartController::executeDispatch_InsertStatistic() uno::Reference< beans::XPropertySet > xProp=NULL; //@todo use correct ItemConverter if available - wrapper::ChartTypeItemConverter aItemConverter( xProp, m_pDrawModelWrapper->GetItemPool() ); - SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet(); +// wrapper::ChartTypeItemConverter aItemConverter( NULL, xProp, m_pDrawModelWrapper->GetItemPool() ); +// SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet(); + SfxItemSet aItemSet( m_pDrawModelWrapper->GetItemPool(), 1, 2 ); //aItemConverter.FillItemSet( aItemSet ); //prepare and open dialog @@ -531,10 +529,11 @@ void SAL_CALL ChartController::executeDispatch_InsertStatistic() SchDataStatisticsDlg aDlg( pParent, aItemSet); if( aDlg.Execute() == RET_OK ) { - SfxItemSet aOutItemSet = aItemConverter.CreateEmptyItemSet(); +// SfxItemSet aOutItemSet = aItemConverter.CreateEmptyItemSet(); + SfxItemSet aOutItemSet( m_pDrawModelWrapper->GetItemPool(), 1, 2 ); aDlg.GetAttr( aOutItemSet ); - bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now +// bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now } } catch( uno::RuntimeException& e) |