diff options
47 files changed, 1948 insertions, 769 deletions
diff --git a/chart2/prj/d.lst b/chart2/prj/d.lst index 968e228ac349..a2013d6f0beb 100644 --- a/chart2/prj/d.lst +++ b/chart2/prj/d.lst @@ -7,6 +7,7 @@ mkdir: %COMMON_DEST%\bin%_EXT%\hid ..\%__SRC%\lib\*.sl %_DEST%\lib%_EXT%\*.sl ..\%__SRC%\bin\*.bin %_DEST%\bin%_EXT%\*.bin ..\%__SRC%\bin\*.res %_DEST%\bin%_EXT%\*.res +..\%__SRC%\bin\*.rdb %_DEST%\rdb%_EXT%\*.rdb mkdir: %_DEST%\inc%_EXT%\chart2 diff --git a/chart2/qa/TestCaseOldAPI.java b/chart2/qa/TestCaseOldAPI.java index 05d3750a204e..208ea24cde9b 100644 --- a/chart2/qa/TestCaseOldAPI.java +++ b/chart2/qa/TestCaseOldAPI.java @@ -23,6 +23,7 @@ import drafts.com.sun.star.chart2.XTitled; import drafts.com.sun.star.chart2.XTitle; import drafts.com.sun.star.chart2.XDataProvider; import drafts.com.sun.star.chart2.XFormattedString; +import drafts.com.sun.star.chart2.XDiagramProvider; import com.sun.star.uno.AnyConverter; import com.sun.star.comp.helper.ComponentContext; @@ -57,13 +58,14 @@ public class TestCaseOldAPI extends ComplexTestCase { */ public String[] getTestMethodNames() { return new String[] { + "testChartType", "testTitle", "testSubTitle", "testDiagram", "testAxis", "testLegend", "testArea", - "testChartType" + "testAggregation" }; } @@ -71,9 +73,10 @@ public class TestCaseOldAPI extends ComplexTestCase { public void before() { - boolean bCreateView = false; + // change to "true" to get a view + mbCreateView = false; - if( bCreateView ) + if( mbCreateView ) mxChartModel = createDocument( "chart" ); else mxChartModel = createChartModel(); @@ -91,14 +94,18 @@ public class TestCaseOldAPI extends ComplexTestCase { XCloseable.class, mxChartModel ); assure( "document is no XCloseable", xCloseable != null ); - try - { - xCloseable.close( true ); - } - catch( CloseVetoException ex ) + // do not close document if there exists a view + if( ! mbCreateView ) { - failed( ex.getMessage() ); - ex.printStackTrace( (PrintWriter)log ); + try + { + xCloseable.close( true ); + } + catch( CloseVetoException ex ) + { + failed( ex.getMessage() ); + ex.printStackTrace( (PrintWriter)log ); + } } } @@ -209,7 +216,7 @@ public class TestCaseOldAPI extends ComplexTestCase { XPropertySet xProp = xDisp.getWall(); if( xProp != null ) { - log.println( "Testing wall" ); +// log.println( "Testing wall" ); int nColor = 0xffe1ff; // thistle1 @@ -220,7 +227,7 @@ public class TestCaseOldAPI extends ComplexTestCase { } assure( "Wrong Diagram Type", xDia.getDiagramType().equals( - "com.sun.star.chart.BarDiagram" )); + "com.sun.star.chart.AreaDiagram" )); } } catch( Exception ex ) @@ -375,9 +382,19 @@ public class TestCaseOldAPI extends ComplexTestCase { { XDiagram xDia = (XDiagram) UnoRuntime.queryInterface( XDiagram.class, xFact.createInstance( aMyServiceName )); - assure( "AreaDiagram could not be created", xDia != null ); + assure( aMyServiceName + " could not be created", xDia != null ); mxOldDoc.setDiagram( xDia ); + + XPropertySet xDiaProp = (XPropertySet) UnoRuntime.queryInterface( + XPropertySet.class, xDia ); + assure( "Diagram is no XPropertySet", xDiaProp != null ); + + xDiaProp.getPropertyValue( "Stacked" ); + xDiaProp.setPropertyValue( "Stacked", new Boolean( true )); + assure( "StackMode could not be set correctly", + AnyConverter.toBoolean( + xDiaProp.getPropertyValue( "Stacked" ))); } } catch( Exception ex ) @@ -387,10 +404,25 @@ public class TestCaseOldAPI extends ComplexTestCase { } } + // ------------ + + public void testAggregation() + { + // query to new type + XChartDocument xDiaProv = (XChartDocument) UnoRuntime.queryInterface( + XChartDocument.class, mxOldDoc ); + assure( "query to new interface failed", xDiaProv != null ); + + com.sun.star.chart.XChartDocument xDoc = (com.sun.star.chart.XChartDocument) UnoRuntime.queryInterface( + com.sun.star.chart.XChartDocument.class, xDiaProv ); + assure( "querying back to old interface failed", xDoc != null ); + } + // ================================================================================ private XModel mxChartModel; private XChartDocument mxOldDoc; + private boolean mbCreateView; // -------------------------------------------------------------------------------- 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) diff --git a/chart2/source/model/inc/Diagram.hxx b/chart2/source/model/inc/Diagram.hxx index b8247b65a15c..a7962f302b3b 100644 --- a/chart2/source/model/inc/Diagram.hxx +++ b/chart2/source/model/inc/Diagram.hxx @@ -2,9 +2,9 @@ * * $RCSfile: Diagram.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:30 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:21 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -178,6 +178,8 @@ protected: const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XDataSeriesTreeParent >& xTree ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); +// virtual ::rtl::OUString SAL_CALL getChartTypeTemplateServiceName() +// throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL getWall() throw (::com::sun::star::uno::RuntimeException); @@ -302,6 +304,8 @@ private: ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XLegend > m_xLegend; + + const ::rtl::OUString m_aTemplateServiceName; }; } // namespace chart diff --git a/chart2/source/model/main/Axis.cxx b/chart2/source/model/main/Axis.cxx index 6ee34b675bdd..a1c0ed79de73 100644 --- a/chart2/source/model/main/Axis.cxx +++ b/chart2/source/model/main/Axis.cxx @@ -2,9 +2,9 @@ * * $RCSfile: Axis.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: bm $ $Date: 2003-10-06 15:49:33 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:22 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -309,7 +309,13 @@ Axis::~Axis() // -------------------------------------------------------------------------------- // ____ XAxis ____ -// (nothing) +uno::Sequence< uno::Reference< beans::XPropertySet > > SAL_CALL Axis::getSubTickProperties() + throw (uno::RuntimeException) +{ + OSL_ENSURE( false, "Not implemented yet" ); + return uno::Sequence< uno::Reference< beans::XPropertySet > >(); +} + // ____ XMeter ____ void SAL_CALL Axis::attachCoordinateSystem( diff --git a/chart2/source/model/main/Axis.hxx b/chart2/source/model/main/Axis.hxx index 7ff3d0068691..3a69fac502dc 100644 --- a/chart2/source/model/main/Axis.hxx +++ b/chart2/source/model/main/Axis.hxx @@ -2,9 +2,9 @@ * * $RCSfile: Axis.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:30 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:22 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -144,8 +144,12 @@ protected: // throw (::com::sun::star::lang::IllegalArgumentException); // ____ XAxis ____ + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > > SAL_CALL getSubTickProperties() + throw (::com::sun::star::uno::RuntimeException); - // ____ XMeter ____ +// ____ XMeter ____ virtual void SAL_CALL attachCoordinateSystem( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XBoundedCoordinateSystem >& xCoordSys, diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index 847656233427..a07a5af186d7 100644 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ChartModel.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: bm $ $Date: 2003-10-17 14:48:14 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:22 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,6 +62,8 @@ #include "ImplChartModel.hxx" #include "servicenames.hxx" #include "MediaDescriptorHelper.hxx" +#include "macros.hxx" +#include "ChartDocumentWrapper.hxx" #ifndef _COM_SUN_STAR_UNO_REFERENCE_H_ #include <com/sun/star/uno/Reference.h> @@ -100,11 +102,15 @@ ChartModel::ChartModel(uno::Reference<uno::XComponentContext > const & xContext) , m_xCurrentController( NULL ) , m_nControllerLockCount(0) , m_pImplChartModel( new impl::ImplChartModel( xContext ) ) + , m_xContext( xContext ) { } ChartModel::~ChartModel() { + if( m_xOldModelAgg.is()) + m_xOldModelAgg->setDelegator( NULL ); + //@todo if ( m_pControllers ) @@ -783,8 +789,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME) void SAL_CALL ChartModel ::setDiagram( const uno::Reference< chart2::XDiagram >& xDiagram ) - throw (lang::IllegalArgumentException, - uno::RuntimeException) + throw (uno::RuntimeException) { OSL_ASSERT( m_pImplChartModel.get() != 0 ); // /-- @@ -839,28 +844,6 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME) // \-- } - void SAL_CALL ChartModel -::setChartTypeTemplate( const uno::Reference< chart2::XChartTypeTemplate >& xNewTemplate ) - throw (uno::RuntimeException) -{ - OSL_ASSERT( m_pImplChartModel.get() != 0 ); - // /-- - MutexGuard aGuard( m_aModelMutex ); - m_pImplChartModel->SetChartTypeTemplate( xNewTemplate ); - // \-- -} - - uno::Reference< chart2::XChartTypeTemplate > SAL_CALL ChartModel -::getChartTypeTemplate() - throw (uno::RuntimeException) -{ - OSL_ASSERT( m_pImplChartModel.get() != 0 ); - // /-- - MutexGuard aGuard( m_aModelMutex ); - return m_pImplChartModel->GetChartTypeTemplate(); - // \-- -} - // void SAL_CALL ChartModel // ::setSplitLayoutContainer( const uno::Reference< layout::XSplitLayoutContainer >& xLayoutCnt ) // throw (uno::RuntimeException) @@ -921,14 +904,30 @@ void SAL_CALL ChartModel::setTitle( uno::Any SAL_CALL ChartModel::queryInterface( const uno::Type& aType ) throw (uno::RuntimeException) { - // return old API wrapper - if( aType == - ::getCppuType( (uno::Reference< ::com::sun::star::chart::XChartDocument > *)0 )) + uno::Any aResult( impl::ChartModel_Base::queryInterface( aType )); + + if( ! aResult.hasValue()) { - return uno::makeAny( m_pImplChartModel->GetOldChartDocument( this )); + // try old API wrapper + try + { + if( ! m_xOldModelAgg.is()) + { + m_xOldModelAgg.set( + static_cast< uno::XWeak* >( + new wrapper::ChartDocumentWrapper( m_xContext )), uno::UNO_QUERY_THROW ); + m_xOldModelAgg->setDelegator( static_cast< ::cppu::OWeakObject* >( this )); + } + + aResult = m_xOldModelAgg->queryAggregation( aType ); + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } } - return impl::ChartModel_Base::queryInterface( aType ); + return aResult; } diff --git a/chart2/source/model/main/ChartModel.hxx b/chart2/source/model/main/ChartModel.hxx index 68cfff6f5bd9..553f0cb16c05 100644 --- a/chart2/source/model/main/ChartModel.hxx +++ b/chart2/source/model/main/ChartModel.hxx @@ -2,9 +2,9 @@ * * $RCSfile: ChartModel.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: bm $ $Date: 2003-10-17 14:48:14 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:22 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -208,6 +208,9 @@ private: ::std::auto_ptr< impl::ImplChartModel > m_pImplChartModel; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > m_xOldModelAgg; + private: //private methods @@ -467,8 +470,7 @@ public: virtual void SAL_CALL setDiagram( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XDiagram >& xDiagram ) - throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException); + throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL attachDataProvider( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XDataProvider >& xProvider ) @@ -484,13 +486,6 @@ public: virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XChartTypeManager > SAL_CALL getChartTypeManager() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL - setChartTypeTemplate( const ::com::sun::star::uno::Reference< - ::drafts::com::sun::star::chart2::XChartTypeTemplate >& xNewTemplate ) - throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XChartTypeTemplate > SAL_CALL - getChartTypeTemplate() - throw (::com::sun::star::uno::RuntimeException); // virtual void SAL_CALL setSplitLayoutContainer( // const ::com::sun::star::uno::Reference< // ::drafts::com::sun::star::layout::XSplitLayoutContainer >& xLayoutCnt ) @@ -502,7 +497,7 @@ public: getPageBackground() throw (::com::sun::star::uno::RuntimeException); -// ____ XTitled ____ + // ____ XTitled ____ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XTitle > SAL_CALL getTitle() throw (::com::sun::star::uno::RuntimeException); @@ -518,4 +513,3 @@ public: } // namespace chart #endif - diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx index 1ac3bcd359ef..4e55032f3b21 100644 --- a/chart2/source/model/main/Diagram.cxx +++ b/chart2/source/model/main/Diagram.cxx @@ -2,9 +2,9 @@ * * $RCSfile: Diagram.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: bm $ $Date: 2003-10-06 12:54:13 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -165,6 +165,11 @@ Diagram::Diagram( uno::Reference< uno::XComponentContext > const & xContext ) : m_xTitle( NULL ), m_aIdentifier( C2U( "@diagram" )) { + if( ! m_xContext.is() || + ! ( xContext->getValueByName( C2U( "TemplateServiceName" )) >>= m_aTemplateServiceName )) + { + OSL_ENSURE( false, "Missing argument TemplateServiceName" ); + } } Diagram::~Diagram() @@ -200,6 +205,12 @@ void SAL_CALL Diagram::setTree( } } +// ::rtl::OUString SAL_CALL Diagram::getChartTypeTemplateServiceName() +// throw (uno::RuntimeException) +// { +// return m_aTemplateServiceName; +// } + uno::Reference< beans::XPropertySet > SAL_CALL Diagram::getWall() throw (uno::RuntimeException) { @@ -484,6 +495,6 @@ IMPLEMENT_FORWARD_XTYPEPROVIDER2( Diagram, Diagram_Base, ::property::OPropertySe // implement XServiceInfo methods basing upon getSupportedServiceNames_Static APPHELPER_XSERVICEINFO_IMPL( Diagram, - C2U( "com.sun.star.comp.chart.Diagram" )); + C2U( "com.sun.star.comp.chart2.Diagram" )); } // namespace chart diff --git a/chart2/source/model/main/ImplChartModel.cxx b/chart2/source/model/main/ImplChartModel.cxx index 5b1659b5aaf7..5a1de910bddc 100644 --- a/chart2/source/model/main/ImplChartModel.cxx +++ b/chart2/source/model/main/ImplChartModel.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ImplChartModel.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: bm $ $Date: 2003-10-17 14:48:14 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -69,7 +69,6 @@ #include "ContextHelper.hxx" // #include "SplitLayoutContainer.hxx" #include "LayoutDefaults.hxx" -#include "ChartDocumentWrapper.hxx" #include "PageBackground.hxx" #ifndef _CPPUHELPER_COMPONENT_CONTEXT_HXX_ @@ -381,23 +380,6 @@ void ImplChartModel::SetTitle( const uno::Reference< chart2::XTitle >& rTitle ) m_xTitle = rTitle; } -uno::Reference< ::com::sun::star::chart::XChartDocument > ImplChartModel::GetOldChartDocument( - const uno::Reference< chart2::XChartDocument > & xNewModel ) -{ - // put weak reference into a strong one - uno::Reference< ::com::sun::star::chart::XChartDocument > xRef( m_xOldModel ); - - if( ! xRef.is()) - { - xRef.set( new wrapper::ChartDocumentWrapper( xNewModel, m_xContext )); - - // assing reference to weak reference - m_xOldModel = xRef; - } - - return xRef; -} - void ImplChartModel::dispose() { // exception is thrown by ChartModel diff --git a/chart2/source/model/main/ImplChartModel.hxx b/chart2/source/model/main/ImplChartModel.hxx index f09ac0f99666..20eb9d3bd7a6 100644 --- a/chart2/source/model/main/ImplChartModel.hxx +++ b/chart2/source/model/main/ImplChartModel.hxx @@ -2,9 +2,9 @@ * * $RCSfile: ImplChartModel.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: bm $ $Date: 2003-10-17 14:48:14 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -93,10 +93,6 @@ #include <com/sun/star/container/NoSuchElementException.hpp> #endif -#ifndef _COM_SUN_STAR_CHART_XCHARTDOCUMENT_HPP_ -#include <com/sun/star/chart/XChartDocument.hpp> -#endif - #ifndef _CPPUHELPER_WEAKREF_HXX_ #include <cppuhelper/weakref.hxx> #endif @@ -180,11 +176,6 @@ public: void SetTitle( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XTitle >& rTitle ); - ::com::sun::star::uno::Reference< - ::com::sun::star::chart::XChartDocument > GetOldChartDocument( - const ::com::sun::star::uno::Reference< - ::drafts::com::sun::star::chart2::XChartDocument > & xNewModel ); - /** Is called by the ChartModel's XComponent::dispose() to notify the impl-class to release resources */ @@ -226,8 +217,6 @@ private: ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XTitle > m_xTitle; - ::com::sun::star::uno::WeakReference< ::com::sun::star::chart::XChartDocument > - m_xOldModel; bool m_bIsDisposed; ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xPageBackground; diff --git a/chart2/source/model/main/makefile.mk b/chart2/source/model/main/makefile.mk index 65d340b36ac4..6e51963d017e 100644 --- a/chart2/source/model/main/makefile.mk +++ b/chart2/source/model/main/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.2 $ +# $Revision: 1.3 $ # -# last change: $Author: bm $ $Date: 2003-10-17 14:32:50 $ +# last change: $Author: bm $ $Date: 2003-11-04 12:37:25 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -106,6 +106,7 @@ SLOFILES= \ $(SLO)$/Scale.obj \ $(SLO)$/StyleFamilies.obj \ $(SLO)$/StyleFamily.obj \ + $(SLO)$/SubGrid.obj \ $(SLO)$/Title.obj \ $(SLO)$/UserDefinedProperties.obj \ $(SLO)$/Wall.obj \ diff --git a/chart2/source/model/template/AreaChartTypeTemplate.cxx b/chart2/source/model/template/AreaChartTypeTemplate.cxx index d84b17d09731..cca9d6f88728 100644 --- a/chart2/source/model/template/AreaChartTypeTemplate.cxx +++ b/chart2/source/model/template/AreaChartTypeTemplate.cxx @@ -2,9 +2,9 @@ * * $RCSfile: AreaChartTypeTemplate.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:31 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -60,29 +60,175 @@ ************************************************************************/ #include "AreaChartTypeTemplate.hxx" #include "AreaChartType.hxx" +#include "macros.hxx" +#include "algohelper.hxx" + +#ifndef CHART_PROPERTYHELPER_HXX +#include "PropertyHelper.hxx" +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ +#include <com/sun/star/beans/PropertyAttribute.hpp> +#endif + +#include <algorithm> using namespace ::com::sun::star; using namespace ::drafts::com::sun::star; +using ::rtl::OUString; +using ::com::sun::star::beans::Property; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Any; +using ::osl::MutexGuard; + +namespace +{ + +static const ::rtl::OUString lcl_aServiceName( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.AreaChartTypeTemplate" )); + +enum +{ + PROP_AREA_TEMPLATE_DIMENSION +}; + +void lcl_AddPropertiesToVector( + ::std::vector< Property > & rOutProperties ) +{ + rOutProperties.push_back( + Property( C2U( "Dimension" ), + PROP_AREA_TEMPLATE_DIMENSION, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); +} + +void lcl_AddDefaultsToMap( + ::chart::helper::tPropertyValueMap & rOutMap ) +{ + OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_AREA_TEMPLATE_DIMENSION )); + rOutMap[ PROP_AREA_TEMPLATE_DIMENSION ] = + uno::makeAny( sal_Int32( 2 ) ); +} + +const uno::Sequence< Property > & lcl_GetPropertySequence() +{ + static uno::Sequence< Property > aPropSeq; + + // /-- + MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( 0 == aPropSeq.getLength() ) + { + // get properties + ::std::vector< ::com::sun::star::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); + + // and sort them for access via bsearch + ::std::sort( aProperties.begin(), aProperties.end(), + ::chart::helper::PropertyNameLess() ); + + // transfer result to static Sequence + aPropSeq = ::chart::helper::VectorToSequence( aProperties ); + } + + return aPropSeq; +} + +::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +{ + static ::cppu::OPropertyArrayHelper aArrayHelper( + lcl_GetPropertySequence(), + /* bSorted = */ sal_True ); + + return aArrayHelper; +} + +} // anonymous namespace + namespace chart { AreaChartTypeTemplate::AreaChartTypeTemplate( uno::Reference< uno::XComponentContext > const & xContext, + const ::rtl::OUString & rServiceName, chart2::StackMode eStackMode, sal_Int32 nDim /* = 2 */ ) : - ChartTypeTemplate( xContext ), - m_eStackMode( eStackMode ), - m_nDim( nDim ) -{} + ChartTypeTemplate( xContext, rServiceName ), + ::property::OPropertySet( m_aMutex ), + m_eStackMode( eStackMode ) +{ + setFastPropertyValue_NoBroadcast( PROP_AREA_TEMPLATE_DIMENSION, uno::makeAny( nDim )); +} AreaChartTypeTemplate::~AreaChartTypeTemplate() {} +// ____ OPropertySet ____ +uno::Any AreaChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const + throw(beans::UnknownPropertyException) +{ + static helper::tPropertyValueMap aStaticDefaults; + + // /-- + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( 0 == aStaticDefaults.size() ) + { + // initialize defaults + lcl_AddDefaultsToMap( aStaticDefaults ); + } + + helper::tPropertyValueMap::const_iterator aFound( + aStaticDefaults.find( nHandle )); + + if( aFound == aStaticDefaults.end()) + return uno::Any(); + + return (*aFound).second; + // \-- +} + +::cppu::IPropertyArrayHelper & SAL_CALL AreaChartTypeTemplate::getInfoHelper() +{ + return lcl_getInfoHelper(); +} + + +// ____ XPropertySet ____ +uno::Reference< beans::XPropertySetInfo > SAL_CALL + AreaChartTypeTemplate::getPropertySetInfo() + throw (uno::RuntimeException) +{ + static uno::Reference< beans::XPropertySetInfo > xInfo; + + // /-- + MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( !xInfo.is()) + { + xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( + getInfoHelper()); + } + + return xInfo; + // \-- +} + sal_Int32 AreaChartTypeTemplate::getDimension() const { - return m_nDim; + sal_Int32 nDim = 2; + try + { + // note: UNO-methods are never const + const_cast< AreaChartTypeTemplate * >( this )-> + getFastPropertyValue( PROP_AREA_TEMPLATE_DIMENSION ) >>= nDim; + } + catch( beans::UnknownPropertyException & ex ) + { + ASSERT_EXCEPTION( ex ); + } + + return nDim; } chart2::StackMode AreaChartTypeTemplate::getStackMode() const @@ -90,11 +236,26 @@ chart2::StackMode AreaChartTypeTemplate::getStackMode() const return m_eStackMode; } -// ____ XChartTypeTemplate ____ -uno::Reference< chart2::XChartType > SAL_CALL AreaChartTypeTemplate::getChartTypeForAdditionalSeries() +uno::Reference< chart2::XChartType > AreaChartTypeTemplate::getDefaultChartType() throw (uno::RuntimeException) { - return new AreaChartType( m_nDim ); + return new AreaChartType( getDimension() ); } +// ---------------------------------------- + +uno::Sequence< ::rtl::OUString > AreaChartTypeTemplate::getSupportedServiceNames_Static() +{ + uno::Sequence< ::rtl::OUString > aServices( 2 ); + aServices[ 0 ] = lcl_aServiceName; + aServices[ 1 ] = C2U( "drafts.com.sun.star.chart2.ChartTypeTemplate" ); + return aServices; +} + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( AreaChartTypeTemplate, lcl_aServiceName ); + +IMPLEMENT_FORWARD_XINTERFACE2( AreaChartTypeTemplate, ChartTypeTemplate, OPropertySet ) +IMPLEMENT_FORWARD_XTYPEPROVIDER2( AreaChartTypeTemplate, ChartTypeTemplate, OPropertySet ) + } // namespace chart diff --git a/chart2/source/model/template/AreaChartTypeTemplate.hxx b/chart2/source/model/template/AreaChartTypeTemplate.hxx index 4c0dbdc1f09c..5c5b806110ea 100644 --- a/chart2/source/model/template/AreaChartTypeTemplate.hxx +++ b/chart2/source/model/template/AreaChartTypeTemplate.hxx @@ -2,9 +2,9 @@ * * $RCSfile: AreaChartTypeTemplate.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:31 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -63,6 +63,13 @@ #include "ChartTypeTemplate.hxx" +#include "OPropertySet.hxx" +#include "MutexContainer.hxx" + +#ifndef _COMPHELPER_UNO3_HXX_ +#include <comphelper/uno3.hxx> +#endif + #ifndef _DRAFTS_COM_SUN_STAR_CHART2_STACKMODE_HPP_ #include <drafts/com/sun/star/chart2/StackMode.hpp> #endif @@ -70,24 +77,44 @@ namespace chart { -class AreaChartTypeTemplate : public ChartTypeTemplate +class AreaChartTypeTemplate : + public helper::MutexContainer, + public ChartTypeTemplate, + public ::property::OPropertySet { public: explicit AreaChartTypeTemplate( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext, + const ::rtl::OUString & rServiceName, ::drafts::com::sun::star::chart2::StackMode eStackMode, sal_Int32 nDim = 2 ); virtual ~AreaChartTypeTemplate(); + /// XServiceInfo declarations + APPHELPER_XSERVICEINFO_DECL() + + /// merge XInterface implementations + DECLARE_XINTERFACE() + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + protected: + // ____ OPropertySet ____ + virtual ::com::sun::star::uno::Any GetDefaultValue( sal_Int32 nHandle ) const + throw(::com::sun::star::beans::UnknownPropertyException); + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + + // ____ XPropertySet ____ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + // ____ ChartTypeTemplate ____ virtual sal_Int32 getDimension() const; virtual ::drafts::com::sun::star::chart2::StackMode getStackMode() const; - - // ____ XChartTypeTemplate ____ virtual ::com::sun::star::uno::Reference< - ::drafts::com::sun::star::chart2::XChartType > SAL_CALL getChartTypeForAdditionalSeries() + ::drafts::com::sun::star::chart2::XChartType > getDefaultChartType() throw (::com::sun::star::uno::RuntimeException); private: diff --git a/chart2/source/model/template/BarChartTypeTemplate.cxx b/chart2/source/model/template/BarChartTypeTemplate.cxx index 91f988602939..387ba68402a8 100644 --- a/chart2/source/model/template/BarChartTypeTemplate.cxx +++ b/chart2/source/model/template/BarChartTypeTemplate.cxx @@ -2,9 +2,9 @@ * * $RCSfile: BarChartTypeTemplate.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:31 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -60,21 +60,115 @@ ************************************************************************/ #include "BarChartTypeTemplate.hxx" #include "BarChartType.hxx" +#include "ColumnChartType.hxx" +#include "algohelper.hxx" +#include "macros.hxx" + +#ifndef CHART_PROPERTYHELPER_HXX +#include "PropertyHelper.hxx" +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ +#include <com/sun/star/beans/PropertyAttribute.hpp> +#endif +#ifndef _COM_SUN_STAR_CHART_CHARTSOLIDTYPE_HPP_ +#include <com/sun/star/chart/ChartSolidType.hpp> +#endif + +#include <algorithm> using namespace ::com::sun::star; using namespace ::drafts::com::sun::star; +using ::com::sun::star::beans::Property; +using ::osl::MutexGuard; + +namespace +{ + +static const ::rtl::OUString lcl_aServiceName( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.BarChartTypeTemplate" )); + +enum +{ + PROP_BAR_TEMPLATE_DIMENSION, + PROP_BAR_TEMPLATE_SOLID_TYPE +}; + +void lcl_AddPropertiesToVector( + ::std::vector< Property > & rOutProperties ) +{ + rOutProperties.push_back( + Property( C2U( "Dimension" ), + PROP_BAR_TEMPLATE_DIMENSION, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "SolidType" ), + PROP_BAR_TEMPLATE_SOLID_TYPE, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); +} + +void lcl_AddDefaultsToMap( + ::chart::helper::tPropertyValueMap & rOutMap ) +{ + OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_BAR_TEMPLATE_DIMENSION )); + rOutMap[ PROP_BAR_TEMPLATE_DIMENSION ] = + uno::makeAny( sal_Int32( 2 ) ); + OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_BAR_TEMPLATE_SOLID_TYPE )); + rOutMap[ PROP_BAR_TEMPLATE_SOLID_TYPE ] = + uno::makeAny( ::com::sun::star::chart::ChartSolidType::RECTANGULAR_SOLID ); +} + +const uno::Sequence< Property > & lcl_GetPropertySequence() +{ + static uno::Sequence< Property > aPropSeq; + + // /-- + MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( 0 == aPropSeq.getLength() ) + { + // get properties + ::std::vector< ::com::sun::star::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); + + // and sort them for access via bsearch + ::std::sort( aProperties.begin(), aProperties.end(), + ::chart::helper::PropertyNameLess() ); + + // transfer result to static Sequence + aPropSeq = ::chart::helper::VectorToSequence( aProperties ); + } + + return aPropSeq; +} + +::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +{ + static ::cppu::OPropertyArrayHelper aArrayHelper( + lcl_GetPropertySequence(), + /* bSorted = */ sal_True ); + + return aArrayHelper; +} + +} // anonymous namespace + namespace chart { BarChartTypeTemplate::BarChartTypeTemplate( uno::Reference< uno::XComponentContext > const & xContext, + const ::rtl::OUString & rServiceName, chart2::StackMode eStackMode, BarDirection eDirection, sal_Int32 nDim /* = 2 */, ThreeDMode eThreeDMode /* = THREE_D_FLAT */ ) : - ChartTypeTemplate( xContext ), + ChartTypeTemplate( xContext, rServiceName ), + ::property::OPropertySet( m_aMutex ), m_eStackMode( eStackMode ), m_eBarDirection( eDirection ), m_nDim( nDim ), @@ -94,11 +188,81 @@ chart2::StackMode BarChartTypeTemplate::getStackMode() const return m_eStackMode; } -// ____ XChartTypeTemplate ____ -uno::Reference< chart2::XChartType > SAL_CALL BarChartTypeTemplate::getChartTypeForAdditionalSeries() +uno::Reference< chart2::XChartType > BarChartTypeTemplate::getDefaultChartType() throw (uno::RuntimeException) { - return new BarChartType( m_nDim ); + uno::Reference< chart2::XChartType > xResult; + if( m_eBarDirection == HORIZONTAL ) + xResult.set( new BarChartType( m_nDim )); + else + xResult.set( new ColumnChartType( m_nDim )); + + return xResult; } +// ____ OPropertySet ____ +uno::Any BarChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const + throw(beans::UnknownPropertyException) +{ + static helper::tPropertyValueMap aStaticDefaults; + + // /-- + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( 0 == aStaticDefaults.size() ) + { + // initialize defaults + lcl_AddDefaultsToMap( aStaticDefaults ); + } + + helper::tPropertyValueMap::const_iterator aFound( + aStaticDefaults.find( nHandle )); + + if( aFound == aStaticDefaults.end()) + return uno::Any(); + + return (*aFound).second; + // \-- +} + +::cppu::IPropertyArrayHelper & SAL_CALL BarChartTypeTemplate::getInfoHelper() +{ + return lcl_getInfoHelper(); +} + + +// ____ XPropertySet ____ +uno::Reference< beans::XPropertySetInfo > SAL_CALL + BarChartTypeTemplate::getPropertySetInfo() + throw (uno::RuntimeException) +{ + static uno::Reference< beans::XPropertySetInfo > xInfo; + + // /-- + MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( !xInfo.is()) + { + xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( + getInfoHelper()); + } + + return xInfo; + // \-- +} + +// ---------------------------------------- + +uno::Sequence< ::rtl::OUString > BarChartTypeTemplate::getSupportedServiceNames_Static() +{ + uno::Sequence< ::rtl::OUString > aServices( 2 ); + aServices[ 0 ] = lcl_aServiceName; + aServices[ 1 ] = C2U( "drafts.com.sun.star.chart2.ChartTypeTemplate" ); + return aServices; +} + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( BarChartTypeTemplate, lcl_aServiceName ); + +IMPLEMENT_FORWARD_XINTERFACE2( BarChartTypeTemplate, ChartTypeTemplate, OPropertySet ) +IMPLEMENT_FORWARD_XTYPEPROVIDER2( BarChartTypeTemplate, ChartTypeTemplate, OPropertySet ) + } // namespace chart diff --git a/chart2/source/model/template/BarChartTypeTemplate.hxx b/chart2/source/model/template/BarChartTypeTemplate.hxx index 6ca1e720e447..8117c6ab2052 100644 --- a/chart2/source/model/template/BarChartTypeTemplate.hxx +++ b/chart2/source/model/template/BarChartTypeTemplate.hxx @@ -2,9 +2,9 @@ * * $RCSfile: BarChartTypeTemplate.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:31 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -61,6 +61,13 @@ #ifndef CHART_BARCHARTTYPETEMPLATE_HXX #define CHART_BARCHARTTYPETEMPLATE_HXX +#include "OPropertySet.hxx" +#include "MutexContainer.hxx" + +#ifndef _COMPHELPER_UNO3_HXX_ +#include <comphelper/uno3.hxx> +#endif + #include "ChartTypeTemplate.hxx" #ifndef _DRAFTS_COM_SUN_STAR_CHART2_STACKMODE_HPP_ @@ -70,7 +77,10 @@ namespace chart { -class BarChartTypeTemplate : public ChartTypeTemplate +class BarChartTypeTemplate : + public helper::MutexContainer, + public ChartTypeTemplate, + public ::property::OPropertySet { public: enum BarDirection @@ -88,20 +98,37 @@ public: explicit BarChartTypeTemplate( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext, + const ::rtl::OUString & rServiceName, ::drafts::com::sun::star::chart2::StackMode eStackMode, BarDirection eDirection, sal_Int32 nDim = 2, ThreeDMode eThreeDMode = THREE_D_FLAT ); virtual ~BarChartTypeTemplate(); + /// XServiceInfo declarations + APPHELPER_XSERVICEINFO_DECL() + + /// merge XInterface implementations + DECLARE_XINTERFACE() + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + protected: + // ____ OPropertySet ____ + virtual ::com::sun::star::uno::Any GetDefaultValue( sal_Int32 nHandle ) const + throw(::com::sun::star::beans::UnknownPropertyException); + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + + // ____ XPropertySet ____ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + // ____ ChartTypeTemplate ____ virtual sal_Int32 getDimension() const; virtual ::drafts::com::sun::star::chart2::StackMode getStackMode() const; - - // ____ XChartTypeTemplate ____ virtual ::com::sun::star::uno::Reference< - ::drafts::com::sun::star::chart2::XChartType > SAL_CALL getChartTypeForAdditionalSeries() + ::drafts::com::sun::star::chart2::XChartType > getDefaultChartType() throw (::com::sun::star::uno::RuntimeException); private: diff --git a/chart2/source/model/template/ChartTypeManager.cxx b/chart2/source/model/template/ChartTypeManager.cxx index 4457ba879921..d02164bafa8c 100644 --- a/chart2/source/model/template/ChartTypeManager.cxx +++ b/chart2/source/model/template/ChartTypeManager.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ChartTypeManager.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:31 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -244,8 +244,8 @@ enum TemplateId TEMPLATE_THREEDBARFLAT, TEMPLATE_STACKEDTHREEDBARFLAT, TEMPLATE_PERCENTSTACKEDTHREEDBARFLAT, - TEMPLATE_COLUMNWITHONELINE, - TEMPLATE_STACKEDCOLUMNWITHONELINE, + TEMPLATE_COLUMNWITHLINE, + TEMPLATE_STACKEDCOLUMNWITHLINE, TEMPLATE_AREA, TEMPLATE_STACKEDAREA, TEMPLATE_PERCENTSTACKEDAREA, @@ -312,8 +312,8 @@ const tTemplateMapType & lcl_DefaultChartTypeMap() ( C2U( "com.sun.star.chart2.template.ThreeDBarFlat" ), TEMPLATE_THREEDBARFLAT ) ( C2U( "com.sun.star.chart2.template.StackedThreeDBarFlat" ), TEMPLATE_STACKEDTHREEDBARFLAT ) ( C2U( "com.sun.star.chart2.template.PercentStackedThreeDBarFlat" ), TEMPLATE_PERCENTSTACKEDTHREEDBARFLAT ) - ( C2U( "com.sun.star.chart2.template.ColumnWithOneLine" ), TEMPLATE_COLUMNWITHONELINE ) - ( C2U( "com.sun.star.chart2.template.StackedColumnWithOneLine" ), TEMPLATE_STACKEDCOLUMNWITHONELINE ) + ( C2U( "com.sun.star.chart2.template.ColumnWithLine" ), TEMPLATE_COLUMNWITHLINE ) + ( C2U( "com.sun.star.chart2.template.StackedColumnWithLine" ), TEMPLATE_STACKEDCOLUMNWITHLINE ) ( C2U( "com.sun.star.chart2.template.Area" ), TEMPLATE_AREA ) ( C2U( "com.sun.star.chart2.template.StackedArea" ), TEMPLATE_STACKEDAREA ) ( C2U( "com.sun.star.chart2.template.PercentStackedArea" ), TEMPLATE_PERCENTSTACKEDAREA ) @@ -399,167 +399,167 @@ uno::Reference< uno::XInterface > SAL_CALL ChartTypeManager::createInstance( { // Line case TEMPLATE_LINE: - xTemplate.set( new LineChartTypeTemplate( m_xContext, + xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, LineChartTypeTemplate::NO_SPLINE, false )); break; case TEMPLATE_STACKEDLINE: - xTemplate.set( new LineChartTypeTemplate( m_xContext, + xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED, LineChartTypeTemplate::NO_SPLINE, false )); break; case TEMPLATE_PERCENTSTACKEDLINE: - xTemplate.set( new LineChartTypeTemplate( m_xContext, + xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED_PERCENT, LineChartTypeTemplate::NO_SPLINE, false )); break; case TEMPLATE_LINESYMBOL: - xTemplate.set( new LineChartTypeTemplate( m_xContext, + xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, LineChartTypeTemplate::NO_SPLINE, true )); break; case TEMPLATE_STACKEDLINESYMBOL: - xTemplate.set( new LineChartTypeTemplate( m_xContext, + xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED, LineChartTypeTemplate::NO_SPLINE, true )); break; case TEMPLATE_PERCENTSTACKEDLINESYMBOL: - xTemplate.set( new LineChartTypeTemplate( m_xContext, + xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED_PERCENT, LineChartTypeTemplate::NO_SPLINE, true )); break; case TEMPLATE_CUBICSPLINE: - xTemplate.set( new LineChartTypeTemplate( m_xContext, + xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, LineChartTypeTemplate::CUBIC_SPLINE, false )); break; case TEMPLATE_CUBICSPLINESYMBOL: - xTemplate.set( new LineChartTypeTemplate( m_xContext, + xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, LineChartTypeTemplate::CUBIC_SPLINE, true )); break; case TEMPLATE_BSPLINE: - xTemplate.set( new LineChartTypeTemplate( m_xContext, + xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, LineChartTypeTemplate::B_SPLINE, false )); break; case TEMPLATE_BSPLINESYMBOL: - xTemplate.set( new LineChartTypeTemplate( m_xContext, + xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, LineChartTypeTemplate::B_SPLINE, true )); break; case TEMPLATE_THREEDLINE: - xTemplate.set( new LineChartTypeTemplate( m_xContext, + xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, LineChartTypeTemplate::NO_SPLINE, false, 3 )); break; // Bar/Column case TEMPLATE_COLUMN: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, BarChartTypeTemplate::VERTICAL )); break; case TEMPLATE_STACKEDCOLUMN: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED, BarChartTypeTemplate::VERTICAL )); break; case TEMPLATE_PERCENTSTACKEDCOLUMN: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED_PERCENT, BarChartTypeTemplate::VERTICAL )); break; case TEMPLATE_BAR: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, BarChartTypeTemplate::HORIZONTAL )); break; case TEMPLATE_STACKEDBAR: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED, BarChartTypeTemplate::HORIZONTAL )); break; case TEMPLATE_PERCENTSTACKEDBAR: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED_PERCENT, BarChartTypeTemplate::HORIZONTAL )); break; case TEMPLATE_THREEDCOLUMNDEEP: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, BarChartTypeTemplate::VERTICAL, 3, BarChartTypeTemplate::THREE_D_DEEP )); break; case TEMPLATE_THREEDCOLUMNFLAT: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, BarChartTypeTemplate::VERTICAL, 3, BarChartTypeTemplate::THREE_D_FLAT )); break; case TEMPLATE_STACKEDTHREEDCOLUMNFLAT: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED, BarChartTypeTemplate::VERTICAL, 3, BarChartTypeTemplate::THREE_D_FLAT )); case TEMPLATE_PERCENTSTACKEDTHREEDCOLUMNFLAT: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED_PERCENT, BarChartTypeTemplate::VERTICAL, 3, BarChartTypeTemplate::THREE_D_FLAT )); case TEMPLATE_THREEDBARDEEP: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, BarChartTypeTemplate::HORIZONTAL, 3, BarChartTypeTemplate::THREE_D_DEEP )); break; case TEMPLATE_THREEDBARFLAT: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, BarChartTypeTemplate::HORIZONTAL, 3, BarChartTypeTemplate::THREE_D_FLAT )); break; case TEMPLATE_STACKEDTHREEDBARFLAT: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED, BarChartTypeTemplate::HORIZONTAL, 3, BarChartTypeTemplate::THREE_D_FLAT )); break; case TEMPLATE_PERCENTSTACKEDTHREEDBARFLAT: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED_PERCENT, BarChartTypeTemplate::HORIZONTAL, 3, BarChartTypeTemplate::THREE_D_FLAT )); break; // Combi-Chart Line/Column - case TEMPLATE_COLUMNWITHONELINE: - case TEMPLATE_STACKEDCOLUMNWITHONELINE: + case TEMPLATE_COLUMNWITHLINE: + case TEMPLATE_STACKEDCOLUMNWITHLINE: { - chart2::StackMode eMode = ( nId == TEMPLATE_COLUMNWITHONELINE ) + chart2::StackMode eMode = ( nId == TEMPLATE_COLUMNWITHLINE ) ? chart2::StackMode_NONE : chart2::StackMode_STACKED; sal_Int32 nNumOfLines = 1; getFastPropertyValue( PROP_TEMPLATE_MANAGER_NUMBER_OF_LINES ) >>= nNumOfLines; - xTemplate.set( new ColumnLineChartTypeTemplate( m_xContext, eMode, nNumOfLines )); + xTemplate.set( new ColumnLineChartTypeTemplate( m_xContext, aServiceSpecifier, eMode, nNumOfLines )); } break; // Area case TEMPLATE_AREA: - xTemplate.set( new AreaChartTypeTemplate( m_xContext, chart2::StackMode_NONE )); + xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE )); break; case TEMPLATE_STACKEDAREA: - xTemplate.set( new AreaChartTypeTemplate( m_xContext, chart2::StackMode_STACKED )); + xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED )); break; case TEMPLATE_PERCENTSTACKEDAREA: - xTemplate.set( new AreaChartTypeTemplate( m_xContext, chart2::StackMode_STACKED_PERCENT )); + xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED_PERCENT )); break; case TEMPLATE_THREEDAREA: - xTemplate.set( new AreaChartTypeTemplate( m_xContext, chart2::StackMode_NONE, 3 )); + xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, 3 )); break; case TEMPLATE_STACKEDTHREEDAREA: - xTemplate.set( new AreaChartTypeTemplate( m_xContext, chart2::StackMode_STACKED, 3 )); + xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED, 3 )); break; case TEMPLATE_PERCENTSTACKEDTHREEDAREA: - xTemplate.set( new AreaChartTypeTemplate( m_xContext, chart2::StackMode_STACKED_PERCENT, 3 )); + xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED_PERCENT, 3 )); break; case TEMPLATE_PIE: - xTemplate.set( new PieChartTypeTemplate( m_xContext, - PieChartTypeTemplate::NO_OFFSET, false )); + xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier, + chart2::PieChartOffsetMode_NONE, false )); break; case TEMPLATE_PIEONEEXPLODED: - xTemplate.set( new PieChartTypeTemplate( m_xContext, - PieChartTypeTemplate::FIRST_EXPLODED, false )); + xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier, + chart2::PieChartOffsetMode_FIRST_EXPLODED, false )); break; case TEMPLATE_PIEALLEXPLODED: - xTemplate.set( new PieChartTypeTemplate( m_xContext, - PieChartTypeTemplate::ALL_EXPLODED, false )); + xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier, + chart2::PieChartOffsetMode_ALL_EXPLODED, false )); break; case TEMPLATE_RING: - xTemplate.set( new PieChartTypeTemplate( m_xContext, - PieChartTypeTemplate::NO_OFFSET, true )); + xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier, + chart2::PieChartOffsetMode_NONE, true )); break; case TEMPLATE_THREEDPIE: - xTemplate.set( new PieChartTypeTemplate( m_xContext, - PieChartTypeTemplate::NO_OFFSET, false, 3 )); + xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier, + chart2::PieChartOffsetMode_NONE, false, 3 )); break; case TEMPLATE_SCATTERLINESYMBOL: @@ -572,7 +572,7 @@ uno::Reference< uno::XInterface > SAL_CALL ChartTypeManager::createInstance( // TEST !!! case TEMPLATE_NET: - xTemplate.set( new DoubleStackedBarChartTypeTemplate( m_xContext, + xTemplate.set( new DoubleStackedBarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, chart2::StackMode_STACKED )); break; @@ -580,14 +580,14 @@ uno::Reference< uno::XInterface > SAL_CALL ChartTypeManager::createInstance( case TEMPLATE_NETSYMBOL: case TEMPLATE_STACKEDNET: case TEMPLATE_STACKEDNETSYMBOL: - xTemplate.set( new DoubleStackedBarChartTypeTemplate( m_xContext, + xTemplate.set( new DoubleStackedBarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED, chart2::StackMode_STACKED )); break; // TEST !!! case TEMPLATE_PERCENTSTACKEDNET: case TEMPLATE_PERCENTSTACKEDNETSYMBOL: - xTemplate.set( new DoubleStackedBarChartTypeTemplate( m_xContext, + xTemplate.set( new DoubleStackedBarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED_PERCENT, chart2::StackMode_STACKED )); break; diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx b/chart2/source/model/template/ChartTypeTemplate.cxx index 4ff84c4ecc41..e21eb8065562 100644 --- a/chart2/source/model/template/ChartTypeTemplate.cxx +++ b/chart2/source/model/template/ChartTypeTemplate.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ChartTypeTemplate.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: bm $ $Date: 2003-10-09 16:46:43 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -60,17 +60,17 @@ ************************************************************************/ #include "ChartTypeTemplate.hxx" #include "PropertyHelper.hxx" -#include "algohelper.hxx" #include "macros.hxx" #include "ContextHelper.hxx" #include "Scale.hxx" +#include "DataSeriesTreeHelper.hxx" -#include "Diagram.hxx" #include "Scaling.hxx" #include "CartesianCoordinateSystem.hxx" #include "BoundedCoordinateSystem.hxx" #include "MeterHelper.hxx" #include "LegendHelper.hxx" +#include "BarChartType.hxx" #ifndef _CPPUHELPER_COMPONENT_CONTEXT_HXX_ #include <cppuhelper/component_context.hxx> @@ -106,85 +106,6 @@ using ::com::sun::star::uno::Any; namespace { -bool lcl_SetStackModeAtTree( - const Reference< chart2::XDataSeriesTreeParent > & rTree, - chart2::StackMode eMode ) -{ - if( ! rTree.is()) - return false; - - bool bResult = false; - - // seek value stacking group - Sequence< Reference< chart2::XDataSeriesTreeNode > > aChildren( rTree->getChildren()); - for( sal_Int32 i = 0; - ( ! bResult ) && ( i < aChildren.getLength() ); - ++i ) - { - Reference< chart2::XStackableScaleGroup > xStackGroup( aChildren[ i ], uno::UNO_QUERY ); - if( xStackGroup.is()) - { - Reference< lang::XServiceInfo > xServInfo( aChildren[ i ], uno::UNO_QUERY ); - if( xServInfo.is() && - xServInfo->supportsService( - C2U( "drafts.com.sun.star.chart2.ContinuousScaleGroup" ))) - { - xStackGroup->setStackMode( eMode ); - bResult = true; - break; - } - } - - // recurse - Reference< chart2::XDataSeriesTreeParent > xNewParent( aChildren[ i ], uno::UNO_QUERY ); - if( xNewParent.is() && - lcl_SetStackModeAtTree( xNewParent, eMode )) - bResult = true; - } - - return bResult; -} - -// helping method for lcl_GetDataSeries() (see below) -void lcl_AddSeriesRecursive( - Reference< chart2::XDataSeriesTreeParent > xParent, - ::std::vector< Reference< chart2::XDataSeries > > & rOutSeriesVec ) -{ - if( xParent.is()) - { - Sequence< Reference< chart2::XDataSeriesTreeNode > > aChildren( xParent->getChildren()); - for( sal_Int32 i = 0; i < aChildren.getLength(); ++i ) - { - Reference< chart2::XDataSeries > aDataSeries( aChildren[ i ], uno::UNO_QUERY ); - if( aDataSeries.is()) - { - rOutSeriesVec.push_back( aDataSeries ); - } - else - { - Reference< chart2::XDataSeriesTreeParent > xNewParent( aChildren[ i ], uno::UNO_QUERY ); - if( xNewParent.is()) - lcl_AddSeriesRecursive( xNewParent, rOutSeriesVec ); - } - } - } -} -Sequence< Reference< chart2::XDataSeries > > - lcl_GetDataSeries( const Reference< chart2::XDiagram > & xDia ) -{ - ::std::vector< Reference< chart2::XDataSeries > > aSeriesVec; - - if( xDia.is()) - { - Reference< chart2::XDataSeriesTreeParent > aParent( xDia->getTree()); - - if( aParent.is()) - lcl_AddSeriesRecursive( aParent, aSeriesVec ); - } - - return ::chart::helper::VectorToSequence( aSeriesVec ); -} - void lcl_FlushLegend( const Reference< chart2::XLegend > & xLegend ) { if( xLegend.is()) @@ -213,8 +134,10 @@ namespace chart { ChartTypeTemplate::ChartTypeTemplate( - Reference< uno::XComponentContext > const & xContext ) : - m_xContext( xContext ) + Reference< uno::XComponentContext > const & xContext, + const ::rtl::OUString & rServiceName ) : + m_xContext( xContext ), + m_aServiceName( rServiceName ) { } @@ -227,35 +150,49 @@ Reference< chart2::XDiagram > SAL_CALL ChartTypeTemplate::createDiagram( const Sequence< Reference< chart2::XDataSeries > >& aSeriesSeq ) throw (uno::RuntimeException) { - // create diagram - Reference< chart2::XDiagram > xDia( new Diagram( m_xContext ) ); + Reference< chart2::XDiagram > xDia; - // modify diagram - FillDiagram( xDia, aSeriesSeq ); + try + { + // create diagram + ContextHelper::tContextEntryMapType aContextValues( + ContextHelper::MakeContextEntryMap + ( C2U( "TemplateServiceName" ), + uno::makeAny( getServiceName() )) + ); - // create and attach legend - Reference< chart2::XLegend > xLegend( - m_xContext->getServiceManager()->createInstanceWithContext( - C2U( "drafts.com.sun.star.chart2.Legend" ), - m_xContext ), - uno::UNO_QUERY ); + xDia.set( + m_xContext->getServiceManager()->createInstanceWithContext( + C2U( "drafts.com.sun.star.chart2.Diagram" ), + ContextHelper::createContext( aContextValues, m_xContext ) ), + uno::UNO_QUERY_THROW ); - xDia->setLegend( xLegend ); - LegendHelper::defaultFillEmptyLegend( xLegend, xDia ); + // modify diagram + FillDiagram( xDia, aSeriesSeq ); + + // create and attach legend + Reference< chart2::XLegend > xLegend( + m_xContext->getServiceManager()->createInstanceWithContext( + C2U( "drafts.com.sun.star.chart2.Legend" ), + m_xContext ), + uno::UNO_QUERY_THROW ); + + xDia->setLegend( xLegend ); + LegendHelper::defaultFillEmptyLegend( xLegend, xDia ); + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } return xDia; } -// simple first approach -void SAL_CALL ChartTypeTemplate::changeDiagram( const Reference< chart2::XDiagram >& xDiagram ) +// ____ XServiceName ____ + ::rtl::OUString SAL_CALL ChartTypeTemplate::getServiceName() throw (uno::RuntimeException) { - Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( lcl_GetDataSeries( xDiagram )); - FillDiagram( xDiagram, aSeriesSeq ); - - Reference< chart2::XLegend > xLegend( xDiagram->getLegend()); - lcl_FlushLegend( xLegend ); - LegendHelper::defaultFillEmptyLegend( xLegend, xDiagram ); + return m_aServiceName; } // ________________________________________ @@ -270,6 +207,12 @@ chart2::StackMode ChartTypeTemplate::getStackMode() const return chart2::StackMode_NONE; } +uno::Reference< chart2::XChartType > ChartTypeTemplate::getDefaultChartType() + throw (uno::RuntimeException) +{ + return new BarChartType( 2 ); +} + // ________________________________________ Reference< chart2::XBoundedCoordinateSystem > ChartTypeTemplate::createCoordinateSystem( @@ -528,7 +471,7 @@ Reference< chart2::XDataSeriesTreeParent > ChartTypeTemplate::createDataSeriesTr // chart type group Reference< chart2::XDataSeriesTreeNode > aChartTypeNode( - createChartTypeGroup( getChartTypeForAdditionalSeries())); + createChartTypeGroup( getDefaultChartType())); // 'x-axis' group Reference< chart2::XDataSeriesTreeNode > aCategoryNode( @@ -558,7 +501,7 @@ void ChartTypeTemplate::setStackModeAtTree( const Reference< chart2::XDataSeriesTreeParent > & rTree, chart2::StackMode eMode ) { - bool bResult = lcl_SetStackModeAtTree( rTree, eMode ); + bool bResult = helper::DataSeriesTreeHelper::setStackMode( rTree, eMode ); OSL_ENSURE( bResult, "stack-mode could not be set" ); } diff --git a/chart2/source/model/template/ChartTypeTemplate.hxx b/chart2/source/model/template/ChartTypeTemplate.hxx index f69bd610dd31..d59763872a90 100644 --- a/chart2/source/model/template/ChartTypeTemplate.hxx +++ b/chart2/source/model/template/ChartTypeTemplate.hxx @@ -2,9 +2,9 @@ * * $RCSfile: ChartTypeTemplate.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: bm $ $Date: 2003-10-09 16:46:43 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -61,8 +61,8 @@ #ifndef CHART_CHARTTYPETEMPLATE_HXX #define CHART_CHARTTYPETEMPLATE_HXX -#ifndef _CPPUHELPER_IMPLBASE1_HXX_ -#include <cppuhelper/implbase1.hxx> +#ifndef _CPPUHELPER_IMPLBASE2_HXX_ +#include <cppuhelper/implbase2.hxx> #endif #include "ServiceMacros.hxx" @@ -87,17 +87,25 @@ #ifndef _DRAFTS_COM_SUN_STAR_CHART2_XLEGEND_HPP_ #include <drafts/com/sun/star/chart2/XLegend.hpp> #endif +#ifndef _COM_SUN_STAR_LANG_XSERVICENAME_HPP_ +#include <com/sun/star/lang/XServiceName.hpp> +#endif +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XCHARTTYPE_HPP_ +#include <drafts/com/sun/star/chart2/XChartType.hpp> +#endif namespace chart { -class ChartTypeTemplate : public ::cppu::WeakImplHelper1< - ::drafts::com::sun::star::chart2::XChartTypeTemplate > +class ChartTypeTemplate : public ::cppu::WeakImplHelper2< + ::drafts::com::sun::star::chart2::XChartTypeTemplate, + ::com::sun::star::lang::XServiceName > { public: explicit ChartTypeTemplate( ::com::sun::star::uno::Reference< - ::com::sun::star::uno::XComponentContext > const & xContext ); + ::com::sun::star::uno::XComponentContext > const & xContext, + const ::rtl::OUString & rServiceName ); virtual ~ChartTypeTemplate(); APPHELPER_XSERVICEINFO_DECL() @@ -106,17 +114,14 @@ public: protected: // ____ XChartTypeTemplate ____ - // still abstract ! - virtual ::com::sun::star::uno::Reference< - ::drafts::com::sun::star::chart2::XChartType > SAL_CALL getChartTypeForAdditionalSeries() - throw (::com::sun::star::uno::RuntimeException) = 0; virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XDiagram > SAL_CALL createDiagram( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XDataSeries > >& aSeriesSeq ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL changeDiagram( - const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XDiagram >& xDiagram ) + + // ____ XServiceName ____ + virtual ::rtl::OUString SAL_CALL getServiceName() throw (::com::sun::star::uno::RuntimeException); // Methods to overload for automatic creation @@ -130,6 +135,10 @@ protected: */ virtual ::drafts::com::sun::star::chart2::StackMode getStackMode() const; + virtual ::com::sun::star::uno::Reference< + ::drafts::com::sun::star::chart2::XChartType > getDefaultChartType() + throw (::com::sun::star::uno::RuntimeException); + // Methods for creating the diagram piecewise // ------------------------------------------ @@ -252,6 +261,7 @@ protected: private: ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + const ::rtl::OUString m_aServiceName; /** modifies the given diagram */ diff --git a/chart2/source/model/template/ColumnChartType.cxx b/chart2/source/model/template/ColumnChartType.cxx new file mode 100644 index 000000000000..dfb3c98f579f --- /dev/null +++ b/chart2/source/model/template/ColumnChartType.cxx @@ -0,0 +1,83 @@ +/************************************************************************* + * + * $RCSfile: ColumnChartType.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: bm $ $Date: 2003-11-04 12:37:33 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2003 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#include "ColumnChartType.hxx" + +using namespace ::com::sun::star; +using namespace ::drafts::com::sun::star; + +namespace chart +{ + +ColumnChartType::ColumnChartType( sal_Int32 nDim /* = 2 */ ) : + ChartType( nDim ) +{} + +ColumnChartType::~ColumnChartType() +{} + +// ____ XChartType ____ +::rtl::OUString SAL_CALL ColumnChartType::getChartType() + throw (uno::RuntimeException) +{ + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.ColumnChart" )); +} + +} // namespace chart diff --git a/chart2/source/model/template/ColumnChartType.hxx b/chart2/source/model/template/ColumnChartType.hxx new file mode 100644 index 000000000000..2a56b9c95c0b --- /dev/null +++ b/chart2/source/model/template/ColumnChartType.hxx @@ -0,0 +1,84 @@ +/************************************************************************* + * + * $RCSfile: ColumnChartType.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: bm $ $Date: 2003-11-04 12:37:33 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2003 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef CHART_COLUMNCHARTTYPE_HXX +#define CHART_COLUMNCHARTTYPE_HXX + +#include "ChartType.hxx" + +namespace chart +{ + +class ColumnChartType : public ChartType +{ +public: + ColumnChartType( sal_Int32 nDim = 2 ); + virtual ~ColumnChartType(); + +protected: + // ____ XChartType ____ + virtual ::rtl::OUString SAL_CALL getChartType() + throw (::com::sun::star::uno::RuntimeException); +}; + +} // namespace chart + +// CHART_COLUMNCHARTTYPE_HXX +#endif diff --git a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx index 4a264b6d1a66..bff100afd7c4 100644 --- a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx +++ b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ColumnLineChartTypeTemplate.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:32 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,6 +62,14 @@ #include "macros.hxx" #include "LineChartType.hxx" #include "BarChartType.hxx" +#include "algohelper.hxx" + +#ifndef CHART_PROPERTYHELPER_HXX +#include "PropertyHelper.hxx" +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ +#include <com/sun/star/beans/PropertyAttribute.hpp> +#endif #include <algorithm> @@ -71,6 +79,74 @@ using namespace ::drafts::com::sun::star; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; using ::rtl::OUString; +using ::com::sun::star::beans::Property; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Any; +using ::osl::MutexGuard; + +namespace +{ + +static const ::rtl::OUString lcl_aServiceName( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.ColumnLineChartTypeTemplate" )); + +enum +{ + PROP_COL_LINE_NUMBER_OF_LINES +}; + +void lcl_AddPropertiesToVector( + ::std::vector< Property > & rOutProperties ) +{ + rOutProperties.push_back( + Property( C2U( "NumberOfLines" ), + PROP_COL_LINE_NUMBER_OF_LINES, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); +} + +void lcl_AddDefaultsToMap( + ::chart::helper::tPropertyValueMap & rOutMap ) +{ + OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_COL_LINE_NUMBER_OF_LINES )); + rOutMap[ PROP_COL_LINE_NUMBER_OF_LINES ] = + uno::makeAny( sal_Int32( 1 ) ); +} + +const uno::Sequence< Property > & lcl_GetPropertySequence() +{ + static uno::Sequence< Property > aPropSeq; + + // /-- + MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( 0 == aPropSeq.getLength() ) + { + // get properties + ::std::vector< ::com::sun::star::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); + + // and sort them for access via bsearch + ::std::sort( aProperties.begin(), aProperties.end(), + ::chart::helper::PropertyNameLess() ); + + // transfer result to static Sequence + aPropSeq = ::chart::helper::VectorToSequence( aProperties ); + } + + return aPropSeq; +} + +::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +{ + static ::cppu::OPropertyArrayHelper aArrayHelper( + lcl_GetPropertySequence(), + /* bSorted = */ sal_True ); + + return aArrayHelper; +} + +} // anonymous namespace namespace chart { @@ -78,16 +154,69 @@ namespace chart ColumnLineChartTypeTemplate::ColumnLineChartTypeTemplate( Reference< uno::XComponentContext > const & xContext, + const ::rtl::OUString & rServiceName, chart2::StackMode eStackMode, sal_Int32 nNumberOfLines ) : - ChartTypeTemplate( xContext ), - m_eStackMode( eStackMode ), - m_nNumberOfLines( nNumberOfLines ) -{} + ChartTypeTemplate( xContext, rServiceName ), + ::property::OPropertySet( m_aMutex ), + m_eStackMode( eStackMode ) +{ + setFastPropertyValue_NoBroadcast( PROP_COL_LINE_NUMBER_OF_LINES, uno::makeAny( nNumberOfLines )); +} ColumnLineChartTypeTemplate::~ColumnLineChartTypeTemplate() {} + +// ____ OPropertySet ____ +uno::Any ColumnLineChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const + throw(beans::UnknownPropertyException) +{ + static helper::tPropertyValueMap aStaticDefaults; + + // /-- + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( 0 == aStaticDefaults.size() ) + { + // initialize defaults + lcl_AddDefaultsToMap( aStaticDefaults ); + } + + helper::tPropertyValueMap::const_iterator aFound( + aStaticDefaults.find( nHandle )); + + if( aFound == aStaticDefaults.end()) + return uno::Any(); + + return (*aFound).second; + // \-- +} + +::cppu::IPropertyArrayHelper & SAL_CALL ColumnLineChartTypeTemplate::getInfoHelper() +{ + return lcl_getInfoHelper(); +} + + +// ____ XPropertySet ____ +uno::Reference< beans::XPropertySetInfo > SAL_CALL + ColumnLineChartTypeTemplate::getPropertySetInfo() + throw (uno::RuntimeException) +{ + static uno::Reference< beans::XPropertySetInfo > xInfo; + + // /-- + MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( !xInfo.is()) + { + xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( + getInfoHelper()); + } + + return xInfo; + // \-- +} + Reference< chart2::XDataSeriesTreeParent > ColumnLineChartTypeTemplate::createDataSeriesTree( const Sequence< Reference< chart2::XDataSeries > > & aSeriesSeq, const Reference< chart2::XBoundedCoordinateSystem > & rCoordSys ) @@ -97,7 +226,9 @@ Reference< chart2::XDataSeriesTreeParent > ColumnLineChartTypeTemplate::createDa Reference< chart2::XDataSeriesTreeParent > aRoot( createRootNode()); sal_Int32 nNumberOfBars = aSeriesSeq.getLength(); - sal_Int32 nNumberOfLines = m_nNumberOfLines; + sal_Int32 nNumberOfLines = 1; + getFastPropertyValue( PROP_COL_LINE_NUMBER_OF_LINES ) >>= nNumberOfLines; + if( nNumberOfLines >= nNumberOfBars ) { nNumberOfLines = 1; @@ -165,11 +296,26 @@ Reference< chart2::XDataSeriesTreeParent > ColumnLineChartTypeTemplate::createDa return aRoot; } -// ____ XChartTypeTemplate ____ -uno::Reference< chart2::XChartType > SAL_CALL ColumnLineChartTypeTemplate::getChartTypeForAdditionalSeries() +uno::Reference< chart2::XChartType > ColumnLineChartTypeTemplate::getDefaultChartType() throw (uno::RuntimeException) { return new LineChartType(); } +// ---------------------------------------- + +uno::Sequence< ::rtl::OUString > ColumnLineChartTypeTemplate::getSupportedServiceNames_Static() +{ + uno::Sequence< ::rtl::OUString > aServices( 2 ); + aServices[ 0 ] = lcl_aServiceName; + aServices[ 1 ] = C2U( "drafts.com.sun.star.chart2.ChartTypeTemplate" ); + return aServices; +} + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( ColumnLineChartTypeTemplate, lcl_aServiceName ); + +IMPLEMENT_FORWARD_XINTERFACE2( ColumnLineChartTypeTemplate, ChartTypeTemplate, OPropertySet ) +IMPLEMENT_FORWARD_XTYPEPROVIDER2( ColumnLineChartTypeTemplate, ChartTypeTemplate, OPropertySet ) + } // namespace chart diff --git a/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx b/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx index fed23a93aefc..0ea4dd39d5ed 100644 --- a/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx +++ b/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx @@ -2,9 +2,9 @@ * * $RCSfile: ColumnLineChartTypeTemplate.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:32 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -63,6 +63,13 @@ #include "ChartTypeTemplate.hxx" +#include "OPropertySet.hxx" +#include "MutexContainer.hxx" + +#ifndef _COMPHELPER_UNO3_HXX_ +#include <comphelper/uno3.hxx> +#endif + #ifndef _DRAFTS_COM_SUN_STAR_CHART2_STACKMODE_HPP_ #include <drafts/com/sun/star/chart2/StackMode.hpp> #endif @@ -70,20 +77,37 @@ namespace chart { -class ColumnLineChartTypeTemplate : public ChartTypeTemplate +class ColumnLineChartTypeTemplate : + public helper::MutexContainer, + public ChartTypeTemplate, + public ::property::OPropertySet { public: explicit ColumnLineChartTypeTemplate( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext, + const ::rtl::OUString & rServiceName, ::drafts::com::sun::star::chart2::StackMode eStackMode, sal_Int32 nNumberOfLines ); virtual ~ColumnLineChartTypeTemplate(); + /// XServiceInfo declarations + APPHELPER_XSERVICEINFO_DECL() + + /// merge XInterface implementations + DECLARE_XINTERFACE() + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + protected: - // ____ XChartTypeTemplate ____ - virtual ::com::sun::star::uno::Reference< - ::drafts::com::sun::star::chart2::XChartType > SAL_CALL getChartTypeForAdditionalSeries() + // ____ OPropertySet ____ + virtual ::com::sun::star::uno::Any GetDefaultValue( sal_Int32 nHandle ) const + throw(::com::sun::star::beans::UnknownPropertyException); + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + + // ____ XPropertySet ____ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() throw (::com::sun::star::uno::RuntimeException); // ____ ChartTypeTemplate ____ @@ -96,10 +120,13 @@ protected: ::drafts::com::sun::star::chart2::XBoundedCoordinateSystem > & rCoordSys ); + virtual ::com::sun::star::uno::Reference< + ::drafts::com::sun::star::chart2::XChartType > getDefaultChartType() + throw (::com::sun::star::uno::RuntimeException); + private: ::drafts::com::sun::star::chart2::StackMode m_eStackMode; - sal_Int32 m_nNumberOfLines; }; } // namespace chart diff --git a/chart2/source/model/template/LineChartTypeTemplate.cxx b/chart2/source/model/template/LineChartTypeTemplate.cxx index 1334b365c4bc..7e6dc44bfa9a 100644 --- a/chart2/source/model/template/LineChartTypeTemplate.cxx +++ b/chart2/source/model/template/LineChartTypeTemplate.cxx @@ -2,9 +2,9 @@ * * $RCSfile: LineChartTypeTemplate.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:32 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:35 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,11 +70,12 @@ namespace chart LineChartTypeTemplate::LineChartTypeTemplate( uno::Reference< uno::XComponentContext > const & xContext, + const ::rtl::OUString & rServiceName, chart2::StackMode eStackMode, SplineMode eSplineMode, bool bSymbols, sal_Int32 nDim /* = 2 */ ) : - ChartTypeTemplate( xContext ), + ChartTypeTemplate( xContext, rServiceName ), m_eStackMode( eStackMode ), m_eSplineMode( eSplineMode ), m_bHasSymbols( bSymbols ), @@ -94,8 +95,7 @@ chart2::StackMode LineChartTypeTemplate::getStackMode() const return m_eStackMode; } -// ____ XChartTypeTemplate ____ -uno::Reference< chart2::XChartType > SAL_CALL LineChartTypeTemplate::getChartTypeForAdditionalSeries() +uno::Reference< chart2::XChartType > LineChartTypeTemplate::getDefaultChartType() throw (uno::RuntimeException) { return new LineChartType( m_nDim ); diff --git a/chart2/source/model/template/LineChartTypeTemplate.hxx b/chart2/source/model/template/LineChartTypeTemplate.hxx index d8c2c939192c..f2f478142b48 100644 --- a/chart2/source/model/template/LineChartTypeTemplate.hxx +++ b/chart2/source/model/template/LineChartTypeTemplate.hxx @@ -2,9 +2,9 @@ * * $RCSfile: LineChartTypeTemplate.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:32 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:35 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -83,6 +83,7 @@ public: explicit LineChartTypeTemplate( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext, + const ::rtl::OUString & rServiceName, ::drafts::com::sun::star::chart2::StackMode eStackMode, SplineMode eSplineMode, bool bSymbols, sal_Int32 nDim = 2 ); virtual ~LineChartTypeTemplate(); @@ -91,10 +92,8 @@ protected: // ____ ChartTypeTemplate ____ virtual sal_Int32 getDimension() const; virtual ::drafts::com::sun::star::chart2::StackMode getStackMode() const; - - // ____ XChartTypeTemplate ____ virtual ::com::sun::star::uno::Reference< - ::drafts::com::sun::star::chart2::XChartType > SAL_CALL getChartTypeForAdditionalSeries() + ::drafts::com::sun::star::chart2::XChartType > getDefaultChartType() throw (::com::sun::star::uno::RuntimeException); private: diff --git a/chart2/source/model/template/PieChartTypeTemplate.cxx b/chart2/source/model/template/PieChartTypeTemplate.cxx index 01037b7d4d8c..11245487af7c 100644 --- a/chart2/source/model/template/PieChartTypeTemplate.cxx +++ b/chart2/source/model/template/PieChartTypeTemplate.cxx @@ -2,9 +2,9 @@ * * $RCSfile: PieChartTypeTemplate.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:32 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:35 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -65,6 +65,16 @@ #include "PieChartType.hxx" #include "Scale.hxx" #include "macros.hxx" +#include "algohelper.hxx" + +#ifndef CHART_PROPERTYHELPER_HXX +#include "PropertyHelper.hxx" +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ +#include <com/sun/star/beans/PropertyAttribute.hpp> +#endif + +#include <algorithm> using namespace ::com::sun::star; using namespace ::drafts::com::sun::star; @@ -76,27 +86,189 @@ using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Any; using ::osl::MutexGuard; +namespace +{ + +static const ::rtl::OUString lcl_aServiceName( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.PieChartTypeTemplate" )); + +enum +{ + PROP_PIE_TEMPLATE_DEFAULT_OFFSET, + PROP_PIE_TEMPLATE_OFFSET_MODE, + PROP_PIE_TEMPLATE_DIMENSION, + PROP_PIE_TEMPLATE_USE_RINGS +}; + +void lcl_AddPropertiesToVector( + ::std::vector< Property > & rOutProperties ) +{ + rOutProperties.push_back( + Property( C2U( "OffsetMode" ), + PROP_PIE_TEMPLATE_OFFSET_MODE, + ::getCppuType( reinterpret_cast< const chart2::PieChartOffsetMode * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "DefaultOffset" ), + PROP_PIE_TEMPLATE_DEFAULT_OFFSET, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "Dimension" ), + PROP_PIE_TEMPLATE_DIMENSION, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "UseRings" ), + PROP_PIE_TEMPLATE_USE_RINGS, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); +} + +void lcl_AddDefaultsToMap( + ::chart::helper::tPropertyValueMap & rOutMap ) +{ + OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_PIE_TEMPLATE_OFFSET_MODE )); + rOutMap[ PROP_PIE_TEMPLATE_OFFSET_MODE ] = + uno::makeAny( chart2::PieChartOffsetMode_NONE ); + OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_PIE_TEMPLATE_DEFAULT_OFFSET )); + rOutMap[ PROP_PIE_TEMPLATE_DEFAULT_OFFSET ] = + uno::makeAny( sal_Int32( 10 ) ); + OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_PIE_TEMPLATE_DIMENSION )); + rOutMap[ PROP_PIE_TEMPLATE_DIMENSION ] = + uno::makeAny( sal_Int32( 2 ) ); + OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_PIE_TEMPLATE_USE_RINGS )); + rOutMap[ PROP_PIE_TEMPLATE_USE_RINGS ] = + uno::makeAny( sal_False ); +} + +const uno::Sequence< Property > & lcl_GetPropertySequence() +{ + static uno::Sequence< Property > aPropSeq; + + // /-- + MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( 0 == aPropSeq.getLength() ) + { + // get properties + ::std::vector< ::com::sun::star::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); + + // and sort them for access via bsearch + ::std::sort( aProperties.begin(), aProperties.end(), + ::chart::helper::PropertyNameLess() ); + + // transfer result to static Sequence + aPropSeq = ::chart::helper::VectorToSequence( aProperties ); + } + + return aPropSeq; +} + +::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +{ + static ::cppu::OPropertyArrayHelper aArrayHelper( + lcl_GetPropertySequence(), + /* bSorted = */ sal_True ); + + return aArrayHelper; +} + +} // anonymous namespace + namespace chart { PieChartTypeTemplate::PieChartTypeTemplate( uno::Reference< uno::XComponentContext > const & xContext, - PieOffsetMode eMode, + const ::rtl::OUString & rServiceName, + chart2::PieChartOffsetMode eMode, bool bRings /* = false */, sal_Int32 nDim /* = 2 */ ) : - ChartTypeTemplate( xContext ), + ChartTypeTemplate( xContext, rServiceName ), + ::property::OPropertySet( m_aMutex ), m_ePieOffsetMode( eMode ), - m_nDim( nDim ), m_bIsRingChart( bRings ) -{} +{ + setFastPropertyValue_NoBroadcast( PROP_PIE_TEMPLATE_OFFSET_MODE, uno::makeAny( eMode )); + setFastPropertyValue_NoBroadcast( PROP_PIE_TEMPLATE_DIMENSION, uno::makeAny( nDim )); + setFastPropertyValue_NoBroadcast( PROP_PIE_TEMPLATE_USE_RINGS, uno::makeAny( sal_Bool( bRings ))); +} PieChartTypeTemplate::~PieChartTypeTemplate() {} +// ____ OPropertySet ____ +uno::Any PieChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const + throw(beans::UnknownPropertyException) +{ + static helper::tPropertyValueMap aStaticDefaults; + + // /-- + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( 0 == aStaticDefaults.size() ) + { + // initialize defaults + lcl_AddDefaultsToMap( aStaticDefaults ); + } + + helper::tPropertyValueMap::const_iterator aFound( + aStaticDefaults.find( nHandle )); + + if( aFound == aStaticDefaults.end()) + return uno::Any(); + + return (*aFound).second; + // \-- +} + +::cppu::IPropertyArrayHelper & SAL_CALL PieChartTypeTemplate::getInfoHelper() +{ + return lcl_getInfoHelper(); +} + + +// ____ XPropertySet ____ +uno::Reference< beans::XPropertySetInfo > SAL_CALL + PieChartTypeTemplate::getPropertySetInfo() + throw (uno::RuntimeException) +{ + static uno::Reference< beans::XPropertySetInfo > xInfo; + + // /-- + MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( !xInfo.is()) + { + xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( + getInfoHelper()); + } + + return xInfo; + // \-- +} + + +// ____ ChartTypeTemplate ____ sal_Int32 PieChartTypeTemplate::getDimension() const { - return m_nDim; + sal_Int32 nDim = 2; + try + { + // note: UNO-methods are never const + const_cast< PieChartTypeTemplate * >( this )-> + getFastPropertyValue( PROP_PIE_TEMPLATE_DIMENSION ) >>= nDim; + } + catch( beans::UnknownPropertyException & ex ) + { + ASSERT_EXCEPTION( ex ); + } + + return nDim; } uno::Reference< chart2::XBoundedCoordinateSystem > PieChartTypeTemplate::createCoordinateSystem( @@ -139,9 +311,12 @@ Reference< chart2::XDataSeriesTreeParent > PieChartTypeTemplate::createDataSerie const Sequence< Reference< chart2::XDataSeries > > & aSeriesSeq, const Reference< chart2::XBoundedCoordinateSystem > & rCoordSys ) { - sal_Int32 nOffset = (m_ePieOffsetMode == NO_OFFSET) + sal_Int32 nDefaultOffset = 10; + sal_Int32 nDim = getDimension(); + getFastPropertyValue( PROP_PIE_TEMPLATE_DEFAULT_OFFSET ) >>= nDefaultOffset; + sal_Int32 nOffset = (m_ePieOffsetMode == chart2::PieChartOffsetMode_NONE) ? 0 - : m_nDefaultOffset; + : nDefaultOffset; // create series tree nodes // root @@ -149,7 +324,7 @@ Reference< chart2::XDataSeriesTreeParent > PieChartTypeTemplate::createDataSerie // chart type group Reference< chart2::XDataSeriesTreeNode > aChartTypeNode( - createChartTypeGroup( new PieChartType( m_nDim, nOffset ))); + createChartTypeGroup( new PieChartType( nDim, nOffset ))); // 'x-axis' group Reference< chart2::XDataSeriesTreeNode > aCategoryNode( @@ -164,7 +339,7 @@ Reference< chart2::XDataSeriesTreeParent > PieChartTypeTemplate::createDataSerie // build tree // add series node to value node - if( m_ePieOffsetMode == FIRST_EXPLODED ) + if( m_ePieOffsetMode == chart2::PieChartOffsetMode_FIRST_EXPLODED ) { if( aSeriesSeq.getLength() >= 1 ) { @@ -176,7 +351,7 @@ Reference< chart2::XDataSeriesTreeParent > PieChartTypeTemplate::createDataSerie { // chart type group Reference< chart2::XDataSeriesTreeNode > aChartTypeNode2( - createChartTypeGroup( new PieChartType( m_nDim, 0 ))); + createChartTypeGroup( new PieChartType( nDim, 0 ))); // 'x-axis' group Reference< chart2::XDataSeriesTreeNode > aCategoryNode2( @@ -208,15 +383,33 @@ Reference< chart2::XDataSeriesTreeParent > PieChartTypeTemplate::createDataSerie return aRoot; } -// ____ XChartTypeTemplate ____ -uno::Reference< chart2::XChartType > SAL_CALL PieChartTypeTemplate::getChartTypeForAdditionalSeries() +uno::Reference< chart2::XChartType > PieChartTypeTemplate::getDefaultChartType() throw (uno::RuntimeException) { sal_Int32 nOffset = 0; - if( m_ePieOffsetMode == ALL_EXPLODED ) - nOffset = m_nDefaultOffset; + if( m_ePieOffsetMode == chart2::PieChartOffsetMode_ALL_EXPLODED ) + { + nOffset = 10; + getFastPropertyValue( PROP_PIE_TEMPLATE_DEFAULT_OFFSET ) >>= nOffset; + } + + return new PieChartType( getDimension(), nOffset ); +} - return new PieChartType( m_nDim, nOffset ); +// ---------------------------------------- + +uno::Sequence< ::rtl::OUString > PieChartTypeTemplate::getSupportedServiceNames_Static() +{ + uno::Sequence< ::rtl::OUString > aServices( 2 ); + aServices[ 0 ] = lcl_aServiceName; + aServices[ 1 ] = C2U( "drafts.com.sun.star.chart2.ChartTypeTemplate" ); + return aServices; } +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( PieChartTypeTemplate, lcl_aServiceName ); + +IMPLEMENT_FORWARD_XINTERFACE2( PieChartTypeTemplate, ChartTypeTemplate, OPropertySet ) +IMPLEMENT_FORWARD_XTYPEPROVIDER2( PieChartTypeTemplate, ChartTypeTemplate, OPropertySet ) + } // namespace chart diff --git a/chart2/source/model/template/PieChartTypeTemplate.hxx b/chart2/source/model/template/PieChartTypeTemplate.hxx index 8d2bbdd24904..010616b02fe7 100644 --- a/chart2/source/model/template/PieChartTypeTemplate.hxx +++ b/chart2/source/model/template/PieChartTypeTemplate.hxx @@ -2,9 +2,9 @@ * * $RCSfile: PieChartTypeTemplate.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:32 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -61,30 +61,56 @@ #ifndef CHART_PIECHARTTYPETEMPLATE_HXX #define CHART_PIECHARTTYPETEMPLATE_HXX +#include "OPropertySet.hxx" +#include "MutexContainer.hxx" + +#ifndef _COMPHELPER_UNO3_HXX_ +#include <comphelper/uno3.hxx> +#endif + #include "ChartTypeTemplate.hxx" +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_PIECHARTOFFSETMODE_HPP_ +#include <drafts/com/sun/star/chart2/PieChartOffsetMode.hpp> +#endif + namespace chart { -class PieChartTypeTemplate : public ChartTypeTemplate +class PieChartTypeTemplate : + public helper::MutexContainer, + public ChartTypeTemplate, + public ::property::OPropertySet { public: - enum PieOffsetMode - { - NO_OFFSET, - FIRST_EXPLODED, - ALL_EXPLODED - }; - PieChartTypeTemplate( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext, - PieOffsetMode eMode, + const ::rtl::OUString & rServiceName, + ::drafts::com::sun::star::chart2::PieChartOffsetMode eMode, bool bRings = false, sal_Int32 nDim = 2 ); virtual ~PieChartTypeTemplate(); + /// XServiceInfo declarations + APPHELPER_XSERVICEINFO_DECL() + + /// merge XInterface implementations + DECLARE_XINTERFACE() + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + protected: + // ____ OPropertySet ____ + virtual ::com::sun::star::uno::Any GetDefaultValue( sal_Int32 nHandle ) const + throw(::com::sun::star::beans::UnknownPropertyException); + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + + // ____ XPropertySet ____ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + // ____ ChartTypeTemplate ____ virtual sal_Int32 getDimension() const; @@ -109,18 +135,14 @@ protected: ::drafts::com::sun::star::chart2::XBoundedCoordinateSystem > & rCoordSys ); - // ____ XChartTypeTemplate ____ virtual ::com::sun::star::uno::Reference< - ::drafts::com::sun::star::chart2::XChartType > SAL_CALL getChartTypeForAdditionalSeries() + ::drafts::com::sun::star::chart2::XChartType > getDefaultChartType() throw (::com::sun::star::uno::RuntimeException); private: - PieOffsetMode m_ePieOffsetMode; - sal_Int32 m_nDim; - bool m_bIsRingChart; - - // same value as in old chart - static const sal_Int32 m_nDefaultOffset = 10; + ::drafts::com::sun::star::chart2::PieChartOffsetMode + m_ePieOffsetMode; + bool m_bIsRingChart; }; } // namespace chart diff --git a/chart2/source/model/template/makefile.mk b/chart2/source/model/template/makefile.mk index a24cb6d3eed0..bcfddc2fc99e 100644 --- a/chart2/source/model/template/makefile.mk +++ b/chart2/source/model/template/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.1.1.1 $ +# $Revision: 1.2 $ # -# last change: $Author: bm $ $Date: 2003-10-06 09:58:32 $ +# last change: $Author: bm $ $Date: 2003-11-04 12:37:36 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -83,6 +83,7 @@ SLOFILES= \ $(SLO)$/ChartType.obj \ $(SLO)$/ChartTypeManager.obj \ $(SLO)$/ChartTypeTemplate.obj \ + $(SLO)$/ColumnChartType.obj \ $(SLO)$/ColumnLineChartTypeTemplate.obj \ $(SLO)$/DoubleStackedBarChartTypeTemplate.obj \ $(SLO)$/LineChartType.obj \ diff --git a/chart2/source/tools/makefile.mk b/chart2/source/tools/makefile.mk index 1b67dc4988fe..8942992a9c4e 100644 --- a/chart2/source/tools/makefile.mk +++ b/chart2/source/tools/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.2 $ +# $Revision: 1.3 $ # -# last change: $Author: bm $ $Date: 2003-10-20 09:59:32 $ +# last change: $Author: bm $ $Date: 2003-11-04 12:37:44 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -85,6 +85,7 @@ SLOFILES= \ $(SLO)$/MediaDescriptorHelper.obj \ $(SLO)$/CommonConverters.obj \ $(SLO)$/ContextHelper.obj \ + $(SLO)$/DataSeriesTreeHelper.obj \ $(SLO)$/ImplOPropertySet.obj \ $(SLO)$/LayoutHelper.obj \ $(SLO)$/OChartElementContainerHelper.obj \ diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx index b90188f8be83..84d796009c4d 100644 --- a/chart2/source/view/main/VLegend.cxx +++ b/chart2/source/view/main/VLegend.cxx @@ -2,9 +2,9 @@ * * $RCSfile: VLegend.cxx,v $ * - * $Revision: 1.19 $ + * $Revision: 1.20 $ * - * last change: $Author: iha $ $Date: 2003-10-31 12:50:57 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:45 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -263,6 +263,19 @@ uno::Reference< drawing::XShape > else if( aChartType.equals( C2U( "com.sun.star.chart2.LineChart" ))) { eSymbolStyle = chart2::LegendSymbolStyle_LINE; + try + { + // use a box for 3d-line charts + sal_Int32 nDim; + uno::Reference< beans::XPropertySet > xCTProp( xChartType, uno::UNO_QUERY_THROW ); + if(( xCTProp->getPropertyValue( C2U( "Dimension" )) >>= nDim ) && + nDim == 3 ) + eSymbolStyle = chart2::LegendSymbolStyle_BOX; + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } } else if( aChartType.equals( C2U( "com.sun.star.chart2.PieChart" ))) { |