diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2011-03-10 16:55:21 -0500 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2011-03-10 20:21:13 -0500 |
commit | 12343c15568dcc2c9209d8ca41fda2263122448f (patch) | |
tree | 3212a89c6cd8ea2e0aee7103aa9669bbb8a6f307 /chart2/source/view/main | |
parent | 99745dbcbb25b61437914c9782475d0b67a4b0bd (diff) | |
parent | ce6308e4fad2281241bf4ca78280eba29f744d43 (diff) |
Merge commit 'ooo/DEV300_m101' into integration/dev300_m101
Diffstat (limited to 'chart2/source/view/main')
-rw-r--r-- | chart2/source/view/main/ChartItemPool.cxx | 104 | ||||
-rw-r--r-- | chart2/source/view/main/ChartItemPool.hxx | 2 | ||||
-rw-r--r-- | chart2/source/view/main/ChartView.cxx | 245 | ||||
-rw-r--r-- | chart2/source/view/main/ChartView.hxx | 4 | ||||
-rw-r--r-- | chart2/source/view/main/Clipping.cxx | 4 | ||||
-rw-r--r-- | chart2/source/view/main/DrawModelWrapper.cxx | 6 | ||||
-rw-r--r-- | chart2/source/view/main/NumberFormatterWrapper.cxx | 143 | ||||
-rw-r--r-- | chart2/source/view/main/PlotterBase.cxx | 9 | ||||
-rw-r--r-- | chart2/source/view/main/PlottingPositionHelper.cxx | 81 | ||||
-rw-r--r-- | chart2/source/view/main/VDataSeries.cxx | 16 | ||||
-rw-r--r-- | chart2/source/view/main/VLegend.cxx | 497 | ||||
-rw-r--r-- | chart2/source/view/main/VLegend.hxx | 2 | ||||
-rw-r--r-- | chart2/source/view/main/VLegendSymbolFactory.cxx | 288 | ||||
-rw-r--r-- | chart2/source/view/main/VTitle.cxx | 2 | ||||
-rw-r--r-- | chart2/source/view/main/VTitle.hxx | 2 | ||||
-rw-r--r-- | chart2/source/view/main/_serviceregistration_view.cxx | 7 | ||||
-rw-r--r-- | chart2/source/view/main/makefile.mk | 1 |
17 files changed, 625 insertions, 788 deletions
diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx index 042fc78b0486..c467634aff6d 100644 --- a/chart2/source/view/main/ChartItemPool.cxx +++ b/chart2/source/view/main/ChartItemPool.cxx @@ -44,6 +44,8 @@ #include <editeng/editids.hrc> #include <svx/svxids.hrc> +#include <com/sun/star/chart2/LegendPosition.hpp> + namespace chart { @@ -64,51 +66,18 @@ ChartItemPool::ChartItemPool(): SvULongs aTmp; ppPoolDefaults[SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS - SCHATTR_START] = new SfxIntegerListItem(SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS,aTmp); ppPoolDefaults[SCHATTR_DATADESCR_NO_PERCENTVALUE - SCHATTR_START] = new SfxBoolItem(SCHATTR_DATADESCR_NO_PERCENTVALUE); - - ppPoolDefaults[SCHATTR_LEGEND_POS - SCHATTR_START] = new SvxChartLegendPosItem( CHLEGEND_RIGHT, SCHATTR_LEGEND_POS ); - ppPoolDefaults[SCHATTR_TEXT_STACKED - SCHATTR_START] = new SfxBoolItem(SCHATTR_TEXT_STACKED,FALSE); - ppPoolDefaults[SCHATTR_TEXT_ORDER - SCHATTR_START] = new SvxChartTextOrderItem(CHTXTORDER_SIDEBYSIDE, SCHATTR_TEXT_ORDER); - - ppPoolDefaults[SCHATTR_Y_AXIS_AUTO_MIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_Y_AXIS_AUTO_MIN); - ppPoolDefaults[SCHATTR_Y_AXIS_MIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Y_AXIS_MIN); - ppPoolDefaults[SCHATTR_Y_AXIS_AUTO_MAX - SCHATTR_START] = new SfxBoolItem(SCHATTR_Y_AXIS_AUTO_MAX); - ppPoolDefaults[SCHATTR_Y_AXIS_MAX - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Y_AXIS_MAX); - ppPoolDefaults[SCHATTR_Y_AXIS_AUTO_STEP_MAIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_Y_AXIS_AUTO_STEP_MAIN); - ppPoolDefaults[SCHATTR_Y_AXIS_STEP_MAIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Y_AXIS_STEP_MAIN); - ppPoolDefaults[SCHATTR_Y_AXIS_AUTO_STEP_HELP - SCHATTR_START] = new SfxBoolItem(SCHATTR_Y_AXIS_AUTO_STEP_HELP); - ppPoolDefaults[SCHATTR_Y_AXIS_STEP_HELP - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Y_AXIS_STEP_HELP); - ppPoolDefaults[SCHATTR_Y_AXIS_LOGARITHM - SCHATTR_START] = new SfxBoolItem(SCHATTR_Y_AXIS_LOGARITHM); - ppPoolDefaults[SCHATTR_Y_AXIS_AUTO_ORIGIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_Y_AXIS_AUTO_ORIGIN); - ppPoolDefaults[SCHATTR_Y_AXIS_ORIGIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Y_AXIS_ORIGIN); - - ppPoolDefaults[SCHATTR_X_AXIS_AUTO_MIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_X_AXIS_AUTO_MIN); - ppPoolDefaults[SCHATTR_X_AXIS_MIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_X_AXIS_MIN); - ppPoolDefaults[SCHATTR_X_AXIS_AUTO_MAX - SCHATTR_START] = new SfxBoolItem(SCHATTR_X_AXIS_AUTO_MAX); - ppPoolDefaults[SCHATTR_X_AXIS_MAX - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_X_AXIS_MAX); - ppPoolDefaults[SCHATTR_X_AXIS_AUTO_STEP_MAIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_X_AXIS_AUTO_STEP_MAIN); - ppPoolDefaults[SCHATTR_X_AXIS_STEP_MAIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_X_AXIS_STEP_MAIN); - ppPoolDefaults[SCHATTR_X_AXIS_AUTO_STEP_HELP - SCHATTR_START] = new SfxBoolItem(SCHATTR_X_AXIS_AUTO_STEP_HELP); - ppPoolDefaults[SCHATTR_X_AXIS_STEP_HELP - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_X_AXIS_STEP_HELP); - ppPoolDefaults[SCHATTR_X_AXIS_LOGARITHM - SCHATTR_START] = new SfxBoolItem(SCHATTR_X_AXIS_LOGARITHM); - ppPoolDefaults[SCHATTR_X_AXIS_AUTO_ORIGIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_X_AXIS_AUTO_ORIGIN); - ppPoolDefaults[SCHATTR_X_AXIS_ORIGIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_X_AXIS_ORIGIN); - - ppPoolDefaults[SCHATTR_Z_AXIS_AUTO_MIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_Z_AXIS_AUTO_MIN); - ppPoolDefaults[SCHATTR_Z_AXIS_MIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Z_AXIS_MIN); - ppPoolDefaults[SCHATTR_Z_AXIS_AUTO_MAX - SCHATTR_START] = new SfxBoolItem(SCHATTR_Z_AXIS_AUTO_MAX); - ppPoolDefaults[SCHATTR_Z_AXIS_MAX - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Z_AXIS_MAX); - ppPoolDefaults[SCHATTR_Z_AXIS_AUTO_STEP_MAIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_Z_AXIS_AUTO_STEP_MAIN); - ppPoolDefaults[SCHATTR_Z_AXIS_STEP_MAIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Z_AXIS_STEP_MAIN); - ppPoolDefaults[SCHATTR_Z_AXIS_AUTO_STEP_HELP - SCHATTR_START] = new SfxBoolItem(SCHATTR_Z_AXIS_AUTO_STEP_HELP); - ppPoolDefaults[SCHATTR_Z_AXIS_STEP_HELP - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Z_AXIS_STEP_HELP); - ppPoolDefaults[SCHATTR_Z_AXIS_LOGARITHM - SCHATTR_START] = new SfxBoolItem(SCHATTR_Z_AXIS_LOGARITHM); - ppPoolDefaults[SCHATTR_Z_AXIS_AUTO_ORIGIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_Z_AXIS_AUTO_ORIGIN); - ppPoolDefaults[SCHATTR_Z_AXIS_ORIGIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_Z_AXIS_ORIGIN); - - ppPoolDefaults[SCHATTR_AXISTYPE - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXISTYPE, CHART_AXIS_X); - ppPoolDefaults[SCHATTR_PERCENT_NUMBERFORMAT_VALUE - SCHATTR_START] = new SfxInt32Item(SCHATTR_PERCENT_NUMBERFORMAT_VALUE, 0); + ppPoolDefaults[SCHATTR_PERCENT_NUMBERFORMAT_VALUE - SCHATTR_START] = new SfxUInt32Item(SCHATTR_PERCENT_NUMBERFORMAT_VALUE, 0); ppPoolDefaults[SCHATTR_PERCENT_NUMBERFORMAT_SOURCE - SCHATTR_START] = new SfxBoolItem(SCHATTR_PERCENT_NUMBERFORMAT_SOURCE); + //legend + ppPoolDefaults[SCHATTR_LEGEND_POS - SCHATTR_START] = new SfxInt32Item(SCHATTR_LEGEND_POS, ::com::sun::star::chart2::LegendPosition_LINE_END ); + ppPoolDefaults[SCHATTR_LEGEND_SHOW - SCHATTR_START] = new SfxBoolItem(SCHATTR_LEGEND_SHOW, sal_True); + + //text + ppPoolDefaults[SCHATTR_TEXT_DEGREES - SCHATTR_START] = new SfxInt32Item(SCHATTR_TEXT_DEGREES, 0); + ppPoolDefaults[SCHATTR_TEXT_STACKED - SCHATTR_START] = new SfxBoolItem(SCHATTR_TEXT_STACKED,sal_False); + + //statistic ppPoolDefaults[SCHATTR_STAT_AVERAGE - SCHATTR_START] = new SfxBoolItem (SCHATTR_STAT_AVERAGE); ppPoolDefaults[SCHATTR_STAT_KIND_ERROR - SCHATTR_START] = new SvxChartKindErrorItem (CHERROR_NONE, SCHATTR_STAT_KIND_ERROR); ppPoolDefaults[SCHATTR_STAT_PERCENT - SCHATTR_START] = new SvxDoubleItem (0.0, SCHATTR_STAT_PERCENT); @@ -119,9 +88,6 @@ ChartItemPool::ChartItemPool(): ppPoolDefaults[SCHATTR_STAT_RANGE_POS - SCHATTR_START] = new SfxStringItem (SCHATTR_STAT_RANGE_POS, String()); ppPoolDefaults[SCHATTR_STAT_RANGE_NEG - SCHATTR_START] = new SfxStringItem (SCHATTR_STAT_RANGE_NEG, String()); - ppPoolDefaults[SCHATTR_TEXT_DEGREES - SCHATTR_START] = new SfxInt32Item(SCHATTR_TEXT_DEGREES, 0); - ppPoolDefaults[SCHATTR_TEXT_OVERLAP - SCHATTR_START] = new SfxBoolItem(SCHATTR_TEXT_OVERLAP,FALSE); - ppPoolDefaults[SCHATTR_STYLE_DEEP - SCHATTR_START] = new SfxBoolItem (SCHATTR_STYLE_DEEP, 0); ppPoolDefaults[SCHATTR_STYLE_3D - SCHATTR_START] = new SfxBoolItem (SCHATTR_STYLE_3D, 0); ppPoolDefaults[SCHATTR_STYLE_VERTICAL - SCHATTR_START] = new SfxBoolItem (SCHATTR_STYLE_VERTICAL, 0); @@ -135,36 +101,44 @@ ChartItemPool::ChartItemPool(): ppPoolDefaults[SCHATTR_AXIS - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS,2); //2 = Y-Axis!!! + //axis scale + ppPoolDefaults[SCHATTR_AXISTYPE - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXISTYPE, CHART_AXIS_REALNUMBER); + ppPoolDefaults[SCHATTR_AXIS_REVERSE - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_REVERSE,0); ppPoolDefaults[SCHATTR_AXIS_AUTO_MIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_AUTO_MIN); ppPoolDefaults[SCHATTR_AXIS_MIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_AXIS_MIN); ppPoolDefaults[SCHATTR_AXIS_AUTO_MAX - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_AUTO_MAX); ppPoolDefaults[SCHATTR_AXIS_MAX - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_AXIS_MAX); ppPoolDefaults[SCHATTR_AXIS_AUTO_STEP_MAIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_MAIN); ppPoolDefaults[SCHATTR_AXIS_STEP_MAIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_AXIS_STEP_MAIN); + ppPoolDefaults[SCHATTR_AXIS_MAIN_TIME_UNIT - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_MAIN_TIME_UNIT,2); ppPoolDefaults[SCHATTR_AXIS_AUTO_STEP_HELP - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_HELP); // type changed from double to sal_Int32 ppPoolDefaults[SCHATTR_AXIS_STEP_HELP - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_STEP_HELP,0); + ppPoolDefaults[SCHATTR_AXIS_HELP_TIME_UNIT - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_HELP_TIME_UNIT,2); + ppPoolDefaults[SCHATTR_AXIS_AUTO_TIME_RESOLUTION - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_AUTO_TIME_RESOLUTION); + ppPoolDefaults[SCHATTR_AXIS_TIME_RESOLUTION - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_TIME_RESOLUTION,2); ppPoolDefaults[SCHATTR_AXIS_LOGARITHM - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_LOGARITHM); + ppPoolDefaults[SCHATTR_AXIS_AUTO_DATEAXIS - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_AUTO_DATEAXIS); + ppPoolDefaults[SCHATTR_AXIS_ALLOW_DATEAXIS - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_ALLOW_DATEAXIS); ppPoolDefaults[SCHATTR_AXIS_AUTO_ORIGIN - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_AUTO_ORIGIN); ppPoolDefaults[SCHATTR_AXIS_ORIGIN - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_AXIS_ORIGIN); + //axis position ppPoolDefaults[SCHATTR_AXIS_TICKS - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_TICKS,CHAXIS_MARK_OUTER); - ppPoolDefaults[SCHATTR_AXIS_NUMFMT - SCHATTR_START] = new SfxUInt32Item(SCHATTR_AXIS_NUMFMT,0); - ppPoolDefaults[SCHATTR_AXIS_NUMFMTPERCENT - SCHATTR_START] = new SfxUInt32Item(SCHATTR_AXIS_NUMFMTPERCENT,11); - ppPoolDefaults[SCHATTR_AXIS_SHOWAXIS - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_SHOWAXIS,0); - ppPoolDefaults[SCHATTR_AXIS_SHOWDESCR - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_SHOWDESCR,0); - ppPoolDefaults[SCHATTR_AXIS_SHOWMAINGRID - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_SHOWMAINGRID,0); - ppPoolDefaults[SCHATTR_AXIS_SHOWHELPGRID - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_SHOWHELPGRID,0); - ppPoolDefaults[SCHATTR_AXIS_TOPDOWN - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_TOPDOWN,0); ppPoolDefaults[SCHATTR_AXIS_HELPTICKS - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_HELPTICKS,0); - ppPoolDefaults[SCHATTR_AXIS_REVERSE - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_REVERSE,0); - ppPoolDefaults[SCHATTR_AXIS_POSITION - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_POSITION,0); ppPoolDefaults[SCHATTR_AXIS_POSITION_VALUE - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_AXIS_POSITION_VALUE); ppPoolDefaults[SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT - SCHATTR_START] = new SfxUInt32Item(SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT,0); ppPoolDefaults[SCHATTR_AXIS_LABEL_POSITION - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_LABEL_POSITION,0); ppPoolDefaults[SCHATTR_AXIS_MARK_POSITION - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_MARK_POSITION,0); + //axis label + ppPoolDefaults[SCHATTR_AXIS_SHOWDESCR - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_SHOWDESCR,0); + ppPoolDefaults[SCHATTR_AXIS_LABEL_ORDER - SCHATTR_START] = new SvxChartTextOrderItem(CHTXTORDER_SIDEBYSIDE, SCHATTR_AXIS_LABEL_ORDER); + ppPoolDefaults[SCHATTR_AXIS_LABEL_OVERLAP - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_LABEL_OVERLAP,sal_False); + ppPoolDefaults[SCHATTR_AXIS_LABEL_BREAK - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_LABEL_BREAK, sal_False ); + + //-- ppPoolDefaults[SCHATTR_SYMBOL_BRUSH - SCHATTR_START] = new SvxBrushItem(SCHATTR_SYMBOL_BRUSH); ppPoolDefaults[SCHATTR_STOCK_VOLUME - SCHATTR_START] = new SfxBoolItem(SCHATTR_STOCK_VOLUME,0); ppPoolDefaults[SCHATTR_STOCK_UPDOWN - SCHATTR_START] = new SfxBoolItem(SCHATTR_STOCK_UPDOWN,0); @@ -173,21 +147,21 @@ ChartItemPool::ChartItemPool(): // new for New Chart ppPoolDefaults[SCHATTR_BAR_OVERLAP - SCHATTR_START] = new SfxInt32Item(SCHATTR_BAR_OVERLAP,0); ppPoolDefaults[SCHATTR_BAR_GAPWIDTH - SCHATTR_START] = new SfxInt32Item(SCHATTR_BAR_GAPWIDTH,0); - ppPoolDefaults[SCHATTR_BAR_CONNECT - SCHATTR_START] = new SfxBoolItem(SCHATTR_BAR_CONNECT, FALSE); + ppPoolDefaults[SCHATTR_BAR_CONNECT - SCHATTR_START] = new SfxBoolItem(SCHATTR_BAR_CONNECT, sal_False); ppPoolDefaults[SCHATTR_NUM_OF_LINES_FOR_BAR - SCHATTR_START] = new SfxInt32Item( SCHATTR_NUM_OF_LINES_FOR_BAR, 0 ); ppPoolDefaults[SCHATTR_SPLINE_ORDER - SCHATTR_START] = new SfxInt32Item( SCHATTR_SPLINE_ORDER, 3 ); ppPoolDefaults[SCHATTR_SPLINE_RESOLUTION - SCHATTR_START] = new SfxInt32Item( SCHATTR_SPLINE_RESOLUTION, 20 ); ppPoolDefaults[SCHATTR_DIAGRAM_STYLE - SCHATTR_START] = new SvxChartStyleItem( CHSTYLE_2D_COLUMN, SCHATTR_DIAGRAM_STYLE ); - ppPoolDefaults[SCHATTR_TEXTBREAK - SCHATTR_START] = new SfxBoolItem( SCHATTR_TEXTBREAK, FALSE ); - ppPoolDefaults[SCHATTR_GROUP_BARS_PER_AXIS - SCHATTR_START] = new SfxBoolItem(SCHATTR_GROUP_BARS_PER_AXIS, FALSE); - ppPoolDefaults[SCHATTR_INCLUDE_HIDDEN_CELLS - SCHATTR_START] = new SfxBoolItem(SCHATTR_INCLUDE_HIDDEN_CELLS, TRUE); + ppPoolDefaults[SCHATTR_GROUP_BARS_PER_AXIS - SCHATTR_START] = new SfxBoolItem(SCHATTR_GROUP_BARS_PER_AXIS, sal_False); ppPoolDefaults[SCHATTR_STARTING_ANGLE - SCHATTR_START] = new SfxInt32Item( SCHATTR_STARTING_ANGLE, 90 ); - ppPoolDefaults[SCHATTR_CLOCKWISE - SCHATTR_START] = new SfxBoolItem( SCHATTR_CLOCKWISE, FALSE ); + ppPoolDefaults[SCHATTR_CLOCKWISE - SCHATTR_START] = new SfxBoolItem( SCHATTR_CLOCKWISE, sal_False ); ppPoolDefaults[SCHATTR_MISSING_VALUE_TREATMENT - SCHATTR_START] = new SfxInt32Item(SCHATTR_MISSING_VALUE_TREATMENT, 0); ppPoolDefaults[SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS - SCHATTR_START] = new SfxIntegerListItem(SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS,aTmp); + ppPoolDefaults[SCHATTR_INCLUDE_HIDDEN_CELLS - SCHATTR_START] = new SfxBoolItem(SCHATTR_INCLUDE_HIDDEN_CELLS, sal_True); ppPoolDefaults[SCHATTR_AXIS_FOR_ALL_SERIES - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_FOR_ALL_SERIES, 0); + ppPoolDefaults[SCHATTR_REGRESSION_TYPE - SCHATTR_START] = new SvxChartRegressItem (CHREGRESS_NONE, SCHATTR_REGRESSION_TYPE); ppPoolDefaults[SCHATTR_REGRESSION_SHOW_EQUATION - SCHATTR_START] = new SfxBoolItem(SCHATTR_REGRESSION_SHOW_EQUATION, 0); ppPoolDefaults[SCHATTR_REGRESSION_SHOW_COEFF - SCHATTR_START] = new SfxBoolItem(SCHATTR_REGRESSION_SHOW_COEFF, 0); @@ -197,8 +171,8 @@ ChartItemPool::ChartItemPool(): **************************************************************************/ pItemInfos = new SfxItemInfo[SCHATTR_END - SCHATTR_START + 1]; - const USHORT nMax = SCHATTR_END - SCHATTR_START + 1; - for( USHORT i = 0; i < nMax; i++ ) + sal_uInt16 i; + for( i = SCHATTR_START; i <= SCHATTR_END; i++ ) { pItemInfos[i]._nSID = 0; pItemInfos[i]._nFlags = SFX_ITEM_POOLABLE; @@ -224,8 +198,8 @@ ChartItemPool::~ChartItemPool() delete[] pItemInfos; - const USHORT nMax = SCHATTR_END - SCHATTR_START + 1; - for( USHORT i = 0; i < nMax; i++ ) + const sal_uInt16 nMax = SCHATTR_END - SCHATTR_START + 1; + for( sal_uInt16 i=0; i<nMax; ++i ) { SetRefCount(*ppPoolDefaults[i], 0); delete ppPoolDefaults[i]; @@ -239,7 +213,7 @@ SfxItemPool* ChartItemPool::Clone() const return new ChartItemPool(*this); } -SfxMapUnit ChartItemPool::GetMetric(USHORT /* nWhich */) const +SfxMapUnit ChartItemPool::GetMetric(sal_uInt16 /* nWhich */) const { return SFX_MAPUNIT_100TH_MM; } diff --git a/chart2/source/view/main/ChartItemPool.hxx b/chart2/source/view/main/ChartItemPool.hxx index 269bbfbff6be..cb13e29fe52a 100644 --- a/chart2/source/view/main/ChartItemPool.hxx +++ b/chart2/source/view/main/ChartItemPool.hxx @@ -47,7 +47,7 @@ protected: public: virtual SfxItemPool* Clone() const; - SfxMapUnit GetMetric( USHORT nWhich ) const; + SfxMapUnit GetMetric( sal_uInt16 nWhich ) const; /// creates a pure chart item pool static SfxItemPool* CreateChartItemPool(); diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 826210b9875a..ad7f4dfb7739 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -32,6 +32,7 @@ #include "ChartView.hxx" #include "chartview/DrawModelWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include "ViewDefines.hxx" #include "VDiagram.hxx" #include "VTitle.hxx" @@ -57,6 +58,7 @@ #include "ControllerLockGuard.hxx" #include "BaseGFXHelper.hxx" #include "DataSeriesHelper.hxx" +#include "DateHelper.hxx" #include <comphelper/scopeguard.hxx> #include <boost/bind.hpp> @@ -79,7 +81,6 @@ #include <com/sun/star/chart/ChartAxisPosition.hpp> #include <com/sun/star/chart/DataLabelPlacement.hpp> #include <com/sun/star/chart/MissingValueTreatment.hpp> -#include <com/sun/star/chart2/ExplicitSubIncrement.hpp> #include <com/sun/star/chart2/StackingDirection.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> @@ -201,7 +202,7 @@ void SAL_CALL ChartView::initialize( const uno::Sequence< uno::Any >& aArguments m_pDrawModelWrapper = ::boost::shared_ptr< DrawModelWrapper >( new DrawModelWrapper( m_xCC ) ); m_xShapeFactory = m_pDrawModelWrapper->getShapeFactory(); m_xDrawPage = m_pDrawModelWrapper->getMainDrawPage(); - StartListening( m_pDrawModelWrapper->getSdrModel(), FALSE /*bPreventDups*/ ); + StartListening( m_pDrawModelWrapper->getSdrModel(), false /*bPreventDups*/ ); } } @@ -209,7 +210,7 @@ ChartView::~ChartView() { if( m_pDrawModelWrapper.get() ) { - EndListening( m_pDrawModelWrapper->getSdrModel(), FALSE /*bAllDups*/ ); + EndListening( m_pDrawModelWrapper->getSdrModel(), false /*bAllDups*/ ); SolarMutexGuard aSolarGuard; m_pDrawModelWrapper.reset(); } @@ -470,7 +471,7 @@ private: }; AxisUsage::AxisUsage() - : aScaleAutomatism(AxisHelper::createDefaultScale()) + : aScaleAutomatism(AxisHelper::createDefaultScale(),Date()) { } @@ -548,7 +549,7 @@ public: ~SeriesPlotterContainer(); void initializeCooSysAndSeriesPlotter( const uno::Reference< frame::XModel >& xChartModel ); - void initAxisUsageList(); + void initAxisUsageList(const Date& rNullDate); void doAutoScaling( const uno::Reference< frame::XModel >& xChartModel ); void updateScalesAndIncrementsOnAxes(); void setScalesFromCooSysToPlotter(); @@ -566,13 +567,15 @@ private: std::vector< VCoordinateSystem* >& m_rVCooSysList; ::std::map< uno::Reference< XAxis >, AxisUsage > m_aAxisUsageList; sal_Int32 m_nMaxAxisIndex; - bool m_bChartTypeUsesShiftedXAxisTicksPerDefault; + bool m_bChartTypeUsesShiftedCategoryPositionPerDefault; + sal_Int32 m_nDefaultDateNumberFormat; }; SeriesPlotterContainer::SeriesPlotterContainer( std::vector< VCoordinateSystem* >& rVCooSysList ) : m_rVCooSysList( rVCooSysList ) , m_nMaxAxisIndex(0) - , m_bChartTypeUsesShiftedXAxisTicksPerDefault(false) + , m_bChartTypeUsesShiftedCategoryPositionPerDefault(false) + , m_nDefaultDateNumberFormat(0) { } @@ -610,6 +613,10 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter( return; uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( xChartModel, uno::UNO_QUERY ); + uno::Reference< chart2::XChartDocument > xChartDoc( xChartModel, uno::UNO_QUERY ); + if( xChartDoc.is() && xChartDoc->hasInternalDataProvider() + && DiagramHelper::isSupportingDateAxis( xDiagram ) ) + m_nDefaultDateNumberFormat=DiagramHelper::getDateNumberFormat( xNumberFormatsSupplier ); sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); if(!nDimensionCount) @@ -667,7 +674,7 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter( uno::Reference< XChartType > xChartType( aChartTypeList[nT] ); if(nT==0) - m_bChartTypeUsesShiftedXAxisTicksPerDefault = ChartTypeHelper::shiftTicksAtXAxisPerDefault( xChartType ); + m_bChartTypeUsesShiftedCategoryPositionPerDefault = ChartTypeHelper::shiftCategoryPosAtXAxisPerDefault( xChartType ); bool bExcludingPositioning = DiagramPositioningMode_EXCLUDING == DiagramHelper::getDiagramPositioningMode( xDiagram ); VSeriesPlotter* pPlotter = VSeriesPlotter::createSeriesPlotter( xChartType, nDimensionCount, bExcludingPositioning ); @@ -779,7 +786,7 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter( } } -void SeriesPlotterContainer::initAxisUsageList() +void SeriesPlotterContainer::initAxisUsageList(const Date& rNullDate) { m_aAxisUsageList.clear(); size_t nC; @@ -789,8 +796,10 @@ void SeriesPlotterContainer::initAxisUsageList() for(sal_Int32 nDimensionIndex=0; nDimensionIndex<3; nDimensionIndex++) { uno::Reference< XCoordinateSystem > xCooSys = pVCooSys->getModel(); - if( nDimensionIndex >= xCooSys->getDimension() ) + sal_Int32 nDimensionCount = xCooSys->getDimension(); + if( nDimensionIndex >= nDimensionCount ) continue; + bool bChartTypeAllowsDateAxis = ChartTypeHelper::isSupportingDateAxis( AxisHelper::getChartTypeByIndex( xCooSys, 0 ), nDimensionCount, nDimensionIndex ); const sal_Int32 nMaximumAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nDimensionIndex); for(sal_Int32 nAxisIndex=0; nAxisIndex<=nMaximumAxisIndex; ++nAxisIndex) { @@ -799,7 +808,20 @@ void SeriesPlotterContainer::initAxisUsageList() if( xAxis.is()) { if(m_aAxisUsageList.find(xAxis)==m_aAxisUsageList.end()) - m_aAxisUsageList[xAxis].aScaleAutomatism = ScaleAutomatism(xAxis->getScaleData()); + { + chart2::ScaleData aSourceScale = xAxis->getScaleData(); + ExplicitCategoriesProvider* pExplicitCategoriesProvider = pVCooSys->getExplicitCategoriesProvider(); + if( nDimensionIndex==0 ) + AxisHelper::checkDateAxis( aSourceScale, pExplicitCategoriesProvider, bChartTypeAllowsDateAxis ); + if( (aSourceScale.AxisType == AxisType::CATEGORY && m_bChartTypeUsesShiftedCategoryPositionPerDefault) + || (aSourceScale.AxisType==AxisType::CATEGORY && pExplicitCategoriesProvider && pExplicitCategoriesProvider->hasComplexCategories() ) + || aSourceScale.AxisType == AxisType::DATE + || aSourceScale.AxisType == AxisType::SERIES ) + aSourceScale.ShiftedCategoryPosition = true; + else + aSourceScale.ShiftedCategoryPosition = false; + m_aAxisUsageList[xAxis].aScaleAutomatism = ScaleAutomatism(aSourceScale,rNullDate); + } AxisUsage& rAxisUsage = m_aAxisUsageList[xAxis]; rAxisUsage.addCoordinateSystem(pVCooSys,nDimensionIndex,nAxisIndex); } @@ -872,6 +894,11 @@ void SeriesPlotterContainer::setNumberFormatsFromAxes() { aAxesNumberFormats.setFormat( nNumberFormatKey, nDimensionIndex, nAxisIndex ); } + else if( nDimensionIndex==0 ) + { + //provide a default date format for date axis with own data + aAxesNumberFormats.setFormat( m_nDefaultDateNumberFormat, nDimensionIndex, nAxisIndex ); + } } } catch( lang::IndexOutOfBoundsException& e ) @@ -922,13 +949,7 @@ void SeriesPlotterContainer::doAutoScaling( const uno::Reference< frame::XModel rAxisUsage.aScaleAutomatism.calculateExplicitScaleAndIncrement( aExplicitScale, aExplicitIncrement ); for( nC=0; nC < aVCooSysList_X.size(); nC++) - { - ExplicitCategoriesProvider* pExplicitCategoriesProvider = aVCooSysList_X[nC]->getExplicitCategoriesProvider(); - - if( m_bChartTypeUsesShiftedXAxisTicksPerDefault || (aExplicitScale.AxisType==AxisType::CATEGORY && pExplicitCategoriesProvider && pExplicitCategoriesProvider->hasComplexCategories() ) ) - aExplicitIncrement.ShiftedPosition = true; aVCooSysList_X[nC]->setExplicitScaleAndIncrement( 0, nAxisIndex, aExplicitScale, aExplicitIncrement ); - } for( nC=0; nC < aVCooSysList_Z.size(); nC++) aVCooSysList_Z[nC]->setExplicitScaleAndIncrement( 2, nAxisIndex, aExplicitScale, aExplicitIncrement ); } @@ -1013,7 +1034,6 @@ void SeriesPlotterContainer::AdaptScaleOfYAxisWithoutAttachedSeries( const uno:: aExplicitScaleDest.Orientation = aExplicitScaleSource.Orientation; aExplicitScaleDest.Scaling = aExplicitScaleSource.Scaling; - aExplicitScaleDest.Breaks = aExplicitScaleSource.Breaks; aExplicitScaleDest.AxisType = aExplicitScaleSource.AxisType; aExplicitIncrementDest.BaseValue = aExplicitIncrementSource.BaseValue; @@ -1051,7 +1071,7 @@ void SeriesPlotterContainer::AdaptScaleOfYAxisWithoutAttachedSeries( const uno:: bAutoMinorInterval = !( aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() ); if( bAutoMinorInterval ) { - if( aExplicitIncrementDest.SubIncrements.getLength() && aExplicitIncrementSource.SubIncrements.getLength() ) + if( !aExplicitIncrementDest.SubIncrements.empty() && !aExplicitIncrementSource.SubIncrements.empty() ) aExplicitIncrementDest.SubIncrements[0].IntervalCount = aExplicitIncrementSource.SubIncrements[0].IntervalCount; } @@ -1366,7 +1386,8 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( SeriesPlotterContainer& // - prepare list of all axis and how they are used - rSeriesPlotterContainer.initAxisUsageList(); + Date aNullDate = NumberFormatterWrapper( uno::Reference< util::XNumberFormatsSupplier >( m_xChartModel, uno::UNO_QUERY ) ).getNullDate(); + rSeriesPlotterContainer.initAxisUsageList(aNullDate); rSeriesPlotterContainer.doAutoScaling( m_xChartModel ); rSeriesPlotterContainer.setScalesFromCooSysToPlotter(); rSeriesPlotterContainer.setNumberFormatsFromAxes(); @@ -1629,6 +1650,31 @@ sal_Bool ChartView::getExplicitValuesForAxis( { rExplicitScale = pVCooSys->getExplicitScale(nDimensionIndex,nAxisIndex); rExplicitIncrement = pVCooSys->getExplicitIncrement(nDimensionIndex,nAxisIndex); + if( rExplicitScale.ShiftedCategoryPosition ) + { + //remove 'one' from max + if( rExplicitScale.AxisType == ::com::sun::star::chart2::AxisType::DATE ) + { + Date aMaxDate(rExplicitScale.NullDate); aMaxDate += static_cast<long>(::rtl::math::approxFloor(rExplicitScale.Maximum)); + //for explicit scales with shifted categories we need one interval more + switch( rExplicitScale.TimeResolution ) + { + case ::com::sun::star::chart::TimeUnit::DAY: + aMaxDate--;break; + case ::com::sun::star::chart::TimeUnit::MONTH: + aMaxDate = DateHelper::GetDateSomeMonthsAway(aMaxDate,-1); + break; + case ::com::sun::star::chart::TimeUnit::YEAR: + aMaxDate = DateHelper::GetDateSomeYearsAway(aMaxDate,-1); + break; + } + rExplicitScale.Maximum = aMaxDate - rExplicitScale.NullDate; + } + else if( rExplicitScale.AxisType == ::com::sun::star::chart2::AxisType::CATEGORY ) + rExplicitScale.Maximum -= 1.0; + else if( rExplicitScale.AxisType == ::com::sun::star::chart2::AxisType::SERIES ) + rExplicitScale.Maximum -= 1.0; + } return sal_True; } return sal_False; @@ -1757,166 +1803,15 @@ bool lcl_getPropertySwapXAndYAxis( const uno::Reference< XDiagram >& xDiagram ) } -sal_Int32 lcl_getExplicitNumberFormatKeyForAxis( - const Reference< chart2::XAxis >& xAxis - , const Reference< chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem - , const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier - , bool bSearchForParallelAxisIfNothingIsFound ) -{ - sal_Int32 nNumberFormatKey(0); - Reference< beans::XPropertySet > xProp( xAxis, uno::UNO_QUERY ); - if( xProp.is() && !( xProp->getPropertyValue( C2U( "NumberFormat" ) ) >>= nNumberFormatKey ) ) - { - bool bPercentFormatSet = false; - //check wether we have a percent scale -> use percent format - if( xNumberFormatsSupplier.is() ) - { - ScaleData aData = xAxis->getScaleData(); - if( aData.AxisType==AxisType::PERCENT ) - { - sal_Int32 nPercentFormat = ExplicitValueProvider::getPercentNumberFormat( xNumberFormatsSupplier ); - if( nPercentFormat != -1 ) - { - nNumberFormatKey = nPercentFormat; - bPercentFormatSet = true; - } - } - } - - if( !bPercentFormatSet ) - { - typedef ::std::map< sal_Int32, sal_Int32 > tNumberformatFrequency; - tNumberformatFrequency aKeyMap; - - bool bNumberFormatKeyFoundViaAttachedData = false; - sal_Int32 nAxisIndex = 0; - sal_Int32 nDimensionIndex = 1; - - try - { - Reference< XChartTypeContainer > xCTCnt( xCorrespondingCoordinateSystem, uno::UNO_QUERY_THROW ); - if( xCTCnt.is() ) - { - AxisHelper::getIndicesForAxis( xAxis, xCorrespondingCoordinateSystem, nDimensionIndex, nAxisIndex ); - ::rtl::OUString aRoleToMatch; - if( nDimensionIndex == 0 ) - aRoleToMatch = C2U("values-x"); - Sequence< Reference< XChartType > > aChartTypes( xCTCnt->getChartTypes()); - for( sal_Int32 nCTIdx=0; nCTIdx<aChartTypes.getLength(); ++nCTIdx ) - { - if( nDimensionIndex != 0 ) - aRoleToMatch = ChartTypeHelper::getRoleOfSequenceForYAxisNumberFormatDetection( aChartTypes[nCTIdx] ); - Reference< XDataSeriesContainer > xDSCnt( aChartTypes[nCTIdx], uno::UNO_QUERY_THROW ); - Sequence< Reference< XDataSeries > > aDataSeriesSeq( xDSCnt->getDataSeries()); - for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aDataSeriesSeq.getLength(); ++nSeriesIdx ) - { - Reference< chart2::XDataSeries > xDataSeries(aDataSeriesSeq[nSeriesIdx]); - Reference< data::XDataSource > xSource( xDataSeries, uno::UNO_QUERY_THROW ); - - if( nDimensionIndex == 1 ) - { - //only take those series into account that are attached to this axis - sal_Int32 nAttachedAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries); - if( nAttachedAxisIndex != nAxisIndex ) - continue; - } - - Sequence< Reference< data::XLabeledDataSequence > > aLabeledSeq( xSource->getDataSequences()); - for( sal_Int32 nLSeqIdx=0; nLSeqIdx<aLabeledSeq.getLength(); ++nLSeqIdx ) - { - if(!aLabeledSeq[nLSeqIdx].is()) - continue; - Reference< data::XDataSequence > xSeq( aLabeledSeq[nLSeqIdx]->getValues()); - if(!xSeq.is()) - continue; - Reference< beans::XPropertySet > xSeqProp( xSeq, uno::UNO_QUERY ); - ::rtl::OUString aRole; - bool bTakeIntoAccount = - ( xSeqProp.is() && (aRoleToMatch.getLength() > 0) && - (xSeqProp->getPropertyValue(C2U("Role")) >>= aRole ) && - aRole.equals( aRoleToMatch )); - - if( bTakeIntoAccount ) - { - sal_Int32 nKey = xSeq->getNumberFormatKeyByIndex( -1 ); - // initialize the value - if( aKeyMap.find( nKey ) == aKeyMap.end()) - aKeyMap[ nKey ] = 0; - // increase frequency - aKeyMap[ nKey ] = (aKeyMap[ nKey ] + 1); - } - } - } - } - } - } - catch( const uno::Exception & ex ) - { - ASSERT_EXCEPTION( ex ); - } - - if( ! aKeyMap.empty()) - { - sal_Int32 nMaxFreq = 0; - // find most frequent key - for( tNumberformatFrequency::const_iterator aIt = aKeyMap.begin(); - aIt != aKeyMap.end(); ++aIt ) - { - OSL_TRACE( "NumberFormatKey %d appears %d times", (*aIt).first, (*aIt).second ); - // all values must at least be 1 - if( (*aIt).second > nMaxFreq ) - { - nNumberFormatKey = (*aIt).first; - bNumberFormatKeyFoundViaAttachedData = true; - nMaxFreq = (*aIt).second; - } - } - } - - if( bSearchForParallelAxisIfNothingIsFound ) - { - //no format is set to this axis and no data is set to this axis - //--> try to obtain the format from the parallel y-axis - if( !bNumberFormatKeyFoundViaAttachedData && nDimensionIndex == 1 ) - { - sal_Int32 nParallelAxisIndex = (nAxisIndex==1) ?0 :1; - Reference< XAxis > xParallelAxis( AxisHelper::getAxis( 1, nParallelAxisIndex, xCorrespondingCoordinateSystem ) ); - nNumberFormatKey = lcl_getExplicitNumberFormatKeyForAxis( xParallelAxis, xCorrespondingCoordinateSystem, xNumberFormatsSupplier, false ); - } - } - } - } - return nNumberFormatKey; -} - sal_Int32 ExplicitValueProvider::getExplicitNumberFormatKeyForAxis( const Reference< chart2::XAxis >& xAxis , const Reference< chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem , const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier ) { - return lcl_getExplicitNumberFormatKeyForAxis( xAxis, xCorrespondingCoordinateSystem, xNumberFormatsSupplier + return AxisHelper::getExplicitNumberFormatKeyForAxis( xAxis, xCorrespondingCoordinateSystem, xNumberFormatsSupplier , true /*bSearchForParallelAxisIfNothingIsFound*/ ); } -sal_Int32 ExplicitValueProvider::getPercentNumberFormat( const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier ) -{ - sal_Int32 nRet=-1; - Reference< util::XNumberFormats > xNumberFormats( xNumberFormatsSupplier->getNumberFormats() ); - if( xNumberFormats.is() ) - { - sal_Bool bCreate = sal_True; - const LocaleDataWrapper& rLocaleDataWrapper = Application::GetSettings().GetLocaleDataWrapper(); - Sequence<sal_Int32> aKeySeq = xNumberFormats->queryKeys( util::NumberFormat::PERCENT, - rLocaleDataWrapper.getLocale(), bCreate ); - if( aKeySeq.getLength() ) - { - nRet = aKeySeq[0]; - } - } - return nRet; -} - - sal_Int32 ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( const uno::Reference< beans::XPropertySet >& xSeriesOrPointProp, const uno::Reference< XDataSeries >& xSeries, @@ -1969,7 +1864,7 @@ sal_Int32 ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabe return nFormat; if( !(xSeriesOrPointProp->getPropertyValue(C2U( "PercentageNumberFormat" )) >>= nFormat) ) { - nFormat = ExplicitValueProvider::getPercentNumberFormat( xNumberFormatsSupplier ); + nFormat = DiagramHelper::getPercentNumberFormat( xNumberFormatsSupplier ); } if(nFormat<0) nFormat=0; @@ -2544,7 +2439,7 @@ void ChartView::createShapes() { SolarMutexGuard aSolarGuard; // #i12587# support for shapes in chart - m_pDrawModelWrapper->getSdrModel().EnableUndo( FALSE ); + m_pDrawModelWrapper->getSdrModel().EnableUndo( sal_False ); m_pDrawModelWrapper->clearMainDrawPage(); } @@ -2707,7 +2602,7 @@ void ChartView::createShapes() if ( m_pDrawModelWrapper ) { SolarMutexGuard aSolarGuard; - m_pDrawModelWrapper->getSdrModel().EnableUndo( TRUE ); + m_pDrawModelWrapper->getSdrModel().EnableUndo( true ); } #if OSL_DEBUG_LEVEL > 0 diff --git a/chart2/source/view/main/ChartView.hxx b/chart2/source/view/main/ChartView.hxx index 94f65dc2d526..a7aec605e89b 100644 --- a/chart2/source/view/main/ChartView.hxx +++ b/chart2/source/view/main/ChartView.hxx @@ -104,8 +104,8 @@ public: // ___ExplicitValueProvider___ virtual sal_Bool getExplicitValuesForAxis( ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > xAxis - , ::com::sun::star::chart2::ExplicitScaleData& rExplicitScale - , ::com::sun::star::chart2::ExplicitIncrementData& rExplicitIncrement ); + , ExplicitScaleData& rExplicitScale + , ExplicitIncrementData& rExplicitIncrement ); virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > getShapeForCID( const rtl::OUString& rObjectCID ); diff --git a/chart2/source/view/main/Clipping.cxx b/chart2/source/view/main/Clipping.cxx index d13a6fd13faf..c44bea326173 100644 --- a/chart2/source/view/main/Clipping.cxx +++ b/chart2/source/view/main/Clipping.cxx @@ -87,7 +87,7 @@ bool lcl_CLIPt(double fDenom,double fNum, double & fTE, double & fTL) } /** @descr The line given by it's two endpoints rP0 and rP1 is clipped at the rectangle - rRectangle. If there is at least a part of it visible then TRUE is returned and + rRectangle. If there is at least a part of it visible then sal_True is returned and the endpoints of that part are stored in rP0 and rP1. The points rP0 and rP1 may have the same coordinates. @param rP0 Start point of the line to clip. Modified to contain a start point inside @@ -96,7 +96,7 @@ bool lcl_CLIPt(double fDenom,double fNum, double & fTE, double & fTL) the clipping area if possible. @param rRectangle Clipping area. @return If the line lies completely or partly inside the clipping area then TRUE - is returned. If the line lies completely outside then FALSE is returned and rP0 and + is returned. If the line lies completely outside then sal_False is returned and rP0 and rP1 are left unmodified. */ bool lcl_clip2d(B2DTuple& rPoint0, B2DTuple& rPoint1, const B2DRectangle& rRectangle) diff --git a/chart2/source/view/main/DrawModelWrapper.cxx b/chart2/source/view/main/DrawModelWrapper.cxx index 745996dc85e5..938ba9ea9758 100644 --- a/chart2/source/view/main/DrawModelWrapper.cxx +++ b/chart2/source/view/main/DrawModelWrapper.cxx @@ -136,7 +136,7 @@ DrawModelWrapper::DrawModelWrapper( SfxItemPool* pMasterPool = &GetItemPool(); pMasterPool->SetDefaultMetric(SFX_MAPUNIT_100TH_MM); - pMasterPool->SetPoolDefaultItem(SfxBoolItem(EE_PARA_HYPHENATE, TRUE) ); + pMasterPool->SetPoolDefaultItem(SfxBoolItem(EE_PARA_HYPHENATE, sal_True) ); pMasterPool->SetPoolDefaultItem(Svx3DPercentDiagonalItem (5)); SfxItemPool* pPool = pMasterPool; @@ -375,8 +375,8 @@ SdrObject* DrawModelWrapper::getNamedSdrObject( const String& rObjectCID, SdrObj { if(!pSearchList || rObjectCID.Len()==0) return 0; - ULONG nCount = pSearchList->GetObjCount(); - for( ULONG nN=0; nN<nCount; nN++ ) + sal_uLong nCount = pSearchList->GetObjCount(); + for( sal_uLong nN=0; nN<nCount; nN++ ) { SdrObject* pObj = pSearchList->GetObj(nN); if(!pObj) diff --git a/chart2/source/view/main/NumberFormatterWrapper.cxx b/chart2/source/view/main/NumberFormatterWrapper.cxx deleted file mode 100644 index ba109582aac9..000000000000 --- a/chart2/source/view/main/NumberFormatterWrapper.cxx +++ /dev/null @@ -1,143 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_chart2.hxx" -#include "chartview/NumberFormatterWrapper.hxx" -#include "macros.hxx" -#include <comphelper/processfactory.hxx> -// header for class SvNumberFormatsSupplierObj -#include <svl/numuno.hxx> -// header for class SvNumberformat -#include <svl/zformat.hxx> -#include <tools/color.hxx> -#include <i18npool/mslangid.hxx> -#include <tools/debug.hxx> -#include <com/sun/star/util/DateTime.hpp> - -//............................................................................. -namespace chart -{ -//............................................................................. -using namespace ::com::sun::star; - -FixedNumberFormatter::FixedNumberFormatter( - const uno::Reference< util::XNumberFormatsSupplier >& xSupplier - , sal_Int32 nNumberFormatKey ) - : m_aNumberFormatterWrapper(xSupplier) - , m_nNumberFormatKey( nNumberFormatKey ) -{ -} - -FixedNumberFormatter::~FixedNumberFormatter() -{ -} - -rtl::OUString FixedNumberFormatter::getFormattedString( double fValue, sal_Int32& rLabelColor, bool& rbColorChanged ) const -{ - return m_aNumberFormatterWrapper.getFormattedString( - m_nNumberFormatKey, fValue, rLabelColor, rbColorChanged ); -} - -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- - -NumberFormatterWrapper::NumberFormatterWrapper( const uno::Reference< util::XNumberFormatsSupplier >& xSupplier ) - : m_xNumberFormatsSupplier(xSupplier) - , m_pNumberFormatter(NULL) - -{ - uno::Reference<beans::XPropertySet> xProp(m_xNumberFormatsSupplier,uno::UNO_QUERY); - rtl::OUString sNullDate( RTL_CONSTASCII_USTRINGPARAM("NullDate")); - if ( xProp.is() && xProp->getPropertySetInfo()->hasPropertyByName(sNullDate) ) - m_aNullDate = xProp->getPropertyValue(sNullDate); - SvNumberFormatsSupplierObj* pSupplierObj = SvNumberFormatsSupplierObj::getImplementation( xSupplier ); - if( pSupplierObj ) - m_pNumberFormatter = pSupplierObj->GetNumberFormatter(); - DBG_ASSERT(m_pNumberFormatter,"need a numberformatter"); -} - -NumberFormatterWrapper::~NumberFormatterWrapper() -{ -} - -SvNumberFormatter* NumberFormatterWrapper::getSvNumberFormatter() const -{ - return m_pNumberFormatter; -} - -rtl::OUString NumberFormatterWrapper::getFormattedString( - sal_Int32 nNumberFormatKey, double fValue, sal_Int32& rLabelColor, bool& rbColorChanged ) const -{ - String aText; - Color* pTextColor = NULL; - if( !m_pNumberFormatter ) - { - OSL_FAIL("Need a NumberFormatter"); - return aText; - } - // i99104 handle null date correctly - USHORT nYear = 1899,nDay = 30,nMonth = 12; - if ( m_aNullDate.hasValue() ) - { - Date* pDate = m_pNumberFormatter->GetNullDate(); - if ( pDate ) - { - nYear = pDate->GetYear(); - nMonth = pDate->GetMonth(); - nDay = pDate->GetDay(); - } // if ( pDate ) - util::DateTime aNewNullDate; - m_aNullDate >>= aNewNullDate; - m_pNumberFormatter->ChangeNullDate(aNewNullDate.Day,aNewNullDate.Month,aNewNullDate.Year); - } - m_pNumberFormatter->GetOutputString( - fValue, nNumberFormatKey, aText, &pTextColor); - if ( m_aNullDate.hasValue() ) - { - m_pNumberFormatter->ChangeNullDate(nDay,nMonth,nYear); - } - rtl::OUString aRet( aText ); - - if(pTextColor) - { - rbColorChanged = true; - rLabelColor = pTextColor->GetColor(); - } - else - rbColorChanged = false; - - return aRet; -} - -//............................................................................. -} //namespace chart -//............................................................................. - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/main/PlotterBase.cxx b/chart2/source/view/main/PlotterBase.cxx index 3dab3c42c4be..9973c50d3bed 100644 --- a/chart2/source/view/main/PlotterBase.cxx +++ b/chart2/source/view/main/PlotterBase.cxx @@ -57,8 +57,7 @@ PlotterBase::PlotterBase( sal_Int32 nDimensionCount ) { } - void SAL_CALL PlotterBase -::initPlotter( const uno::Reference< drawing::XShapes >& xLogicTarget +void PlotterBase::initPlotter( const uno::Reference< drawing::XShapes >& xLogicTarget , const uno::Reference< drawing::XShapes >& xFinalTarget , const uno::Reference< lang::XMultiServiceFactory >& xShapeFactory , const rtl::OUString& rCID ) @@ -78,11 +77,9 @@ PlotterBase::~PlotterBase() delete m_pShapeFactory; } -void SAL_CALL PlotterBase::setScales( const uno::Sequence< ExplicitScaleData >& rScales - , sal_Bool bSwapXAndYAxis ) - throw (uno::RuntimeException) +void PlotterBase::setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ) { - DBG_ASSERT(m_nDimension<=rScales.getLength(),"Dimension of Plotter does not fit two dimension of given scale sequence"); + DBG_ASSERT(m_nDimension<=static_cast<sal_Int32>(rScales.size()),"Dimension of Plotter does not fit two dimension of given scale sequence"); m_pPosHelper->setScales( rScales, bSwapXAndYAxis ); } diff --git a/chart2/source/view/main/PlottingPositionHelper.cxx b/chart2/source/view/main/PlottingPositionHelper.cxx index 31749a0d9824..7a9dede36f09 100644 --- a/chart2/source/view/main/PlottingPositionHelper.cxx +++ b/chart2/source/view/main/PlottingPositionHelper.cxx @@ -33,12 +33,14 @@ #include "ViewDefines.hxx" #include "Linear3DTransformation.hxx" #include "VPolarTransformation.hxx" - #include "ShapeFactory.hxx" #include "PropertyMapper.hxx" +#include "DateHelper.hxx" + +#include <com/sun/star/chart/TimeUnit.hpp> +#include <com/sun/star/chart2/AxisType.hpp> #include <com/sun/star/drawing/DoubleSequence.hpp> #include <com/sun/star/drawing/Position3D.hpp> -#include <com/sun/star/chart2/AxisType.hpp> #include <rtl/math.hxx> @@ -58,6 +60,12 @@ PlottingPositionHelper::PlottingPositionHelper() , m_nYResolution( 1000 ) , m_nZResolution( 1000 ) , m_bMaySkipPointsInRegressionCalculation( true ) + , m_bDateAxis(false) + , m_nTimeResolution( ::com::sun::star::chart::TimeUnit::DAY ) + , m_aNullDate(30,12,1899) + , m_fScaledCategoryWidth(1.0) + , m_bAllowShiftXAxisPos(false) + , m_bAllowShiftZAxisPos(false) { } PlottingPositionHelper::PlottingPositionHelper( const PlottingPositionHelper& rSource ) @@ -69,6 +77,12 @@ PlottingPositionHelper::PlottingPositionHelper( const PlottingPositionHelper& rS , m_nYResolution( rSource.m_nYResolution ) , m_nZResolution( rSource.m_nZResolution ) , m_bMaySkipPointsInRegressionCalculation( rSource.m_bMaySkipPointsInRegressionCalculation ) + , m_bDateAxis( rSource.m_bDateAxis ) + , m_nTimeResolution( rSource.m_nTimeResolution ) + , m_aNullDate( rSource.m_aNullDate ) + , m_fScaledCategoryWidth( rSource.m_fScaledCategoryWidth ) + , m_bAllowShiftXAxisPos( rSource.m_bAllowShiftXAxisPos ) + , m_bAllowShiftZAxisPos( rSource.m_bAllowShiftZAxisPos ) { } @@ -96,13 +110,13 @@ void PlottingPositionHelper::setTransformationSceneToScreen( const drawing::Homo m_xTransformationLogicToScene = NULL; } -void PlottingPositionHelper::setScales( const uno::Sequence< ExplicitScaleData >& rScales, sal_Bool bSwapXAndYAxis ) +void PlottingPositionHelper::setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ) { m_aScales = rScales; m_bSwapXAndY = bSwapXAndYAxis; m_xTransformationLogicToScene = NULL; } -const uno::Sequence< ExplicitScaleData >& PlottingPositionHelper::getScales() const +const std::vector< ExplicitScaleData >& PlottingPositionHelper::getScales() const { return m_aScales; } @@ -130,8 +144,8 @@ uno::Reference< XTransformation > PlottingPositionHelper::getTransformationScale AxisOrientation nZAxisOrientation = m_aScales[2].Orientation; //apply scaling - doLogicScaling( &MinX, &MinY, &MinZ ); - doLogicScaling( &MaxX, &MaxY, &MaxZ); + doUnshiftedLogicScaling( &MinX, &MinY, &MinZ ); + doUnshiftedLogicScaling( &MaxX, &MaxY, &MaxZ); if(m_bSwapXAndY) { @@ -177,9 +191,9 @@ uno::Reference< XTransformation > PlottingPositionHelper::getTransformationScale drawing::Position3D PlottingPositionHelper::transformLogicToScene( double fX, double fY, double fZ, bool bClip ) const { - if(bClip) - this->clipLogicValues( &fX,&fY,&fZ ); this->doLogicScaling( &fX,&fY,&fZ ); + if(bClip) + this->clipScaledLogicValues( &fX,&fY,&fZ ); return this->transformScaledLogicToScene( fX, fY, fZ, false ); } @@ -255,8 +269,8 @@ void PlottingPositionHelper::clipScaledLogicValues( double* pX, double* pY, doub double MaxZ = getLogicMaxZ(); //apply scaling - doLogicScaling( &MinX, &MinY, &MinZ ); - doLogicScaling( &MaxX, &MaxY, &MaxZ); + doUnshiftedLogicScaling( &MinX, &MinY, &MinZ ); + doUnshiftedLogicScaling( &MaxX, &MaxY, &MaxZ); if(pX) { @@ -292,8 +306,8 @@ basegfx::B2DRectangle PlottingPositionHelper::getScaledLogicClipDoubleRect() con double MaxZ = getLogicMaxZ(); //apply scaling - doLogicScaling( &MinX, &MinY, &MinZ ); - doLogicScaling( &MaxX, &MaxY, &MaxZ); + doUnshiftedLogicScaling( &MinX, &MinY, &MinZ ); + doUnshiftedLogicScaling( &MaxX, &MaxY, &MaxZ); basegfx::B2DRectangle aRet( MinX, MaxY, MaxX, MinY ); return aRet; @@ -356,7 +370,7 @@ void PolarPlottingPositionHelper::setTransformationSceneToScreen( const drawing: PlottingPositionHelper::setTransformationSceneToScreen( rMatrix); m_aUnitCartesianToScene =impl_calculateMatrixUnitCartesianToScene( m_aMatrixScreenToScene ); } -void PolarPlottingPositionHelper::setScales( const uno::Sequence< ExplicitScaleData >& rScales, sal_Bool bSwapXAndYAxis ) +void PolarPlottingPositionHelper::setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis ) { PlottingPositionHelper::setScales( rScales, bSwapXAndYAxis ); m_aUnitCartesianToScene =impl_calculateMatrixUnitCartesianToScene( m_aMatrixScreenToScene ); @@ -366,7 +380,7 @@ void PolarPlottingPositionHelper::setScales( const uno::Sequence< ExplicitScaleD { ::basegfx::B3DHomMatrix aRet; - if( !m_aScales.getLength() ) + if( m_aScales.empty() ) return aRet; double fTranslate =1.0; @@ -630,8 +644,41 @@ double PlottingPositionHelper::getBaseValueY() const return m_aScales[1].Origin; } -//............................................................................. -} //namespace chart -//............................................................................. +void PlottingPositionHelper::setTimeResolution( long nTimeResolution, const Date& rNullDate ) +{ + m_nTimeResolution = nTimeResolution; + m_aNullDate = rNullDate; + + //adapt category width + double fCategoryWidth = 1.0; + if( !m_aScales.empty() ) + { + if( m_aScales[0].AxisType == ::com::sun::star::chart2::AxisType::DATE ) + { + m_bDateAxis = true; + if( nTimeResolution == ::com::sun::star::chart::TimeUnit::YEAR ) + { + const double fMonthCount = 12.0;//todo: this depends on the DateScaling and must be adjusted in case we use more generic calendars in future + fCategoryWidth = fMonthCount; + } + } + } + setScaledCategoryWidth(fCategoryWidth); +} + +void PlottingPositionHelper::setScaledCategoryWidth( double fScaledCategoryWidth ) +{ + m_fScaledCategoryWidth = fScaledCategoryWidth; +} +void PlottingPositionHelper::AllowShiftXAxisPos( bool bAllowShift ) +{ + m_bAllowShiftXAxisPos = bAllowShift; +} +void PlottingPositionHelper::AllowShiftZAxisPos( bool bAllowShift ) +{ + m_bAllowShiftZAxisPos = bAllowShift; +} + +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx index eea8c813b360..e0002ae641fa 100644 --- a/chart2/source/view/main/VDataSeries.cxx +++ b/chart2/source/view/main/VDataSeries.cxx @@ -352,6 +352,22 @@ void VDataSeries::setCategoryXAxis() m_bAllowPercentValueInDataLabel = true; } +void VDataSeries::setXValues( const Reference< chart2::data::XDataSequence >& xValues ) +{ + m_aValues_X.clear(); + m_aValues_X.init( xValues ); + m_bAllowPercentValueInDataLabel = true; +} + +void VDataSeries::setXValuesIfNone( const Reference< chart2::data::XDataSequence >& xValues ) +{ + if( m_aValues_X.is() ) + return; + + m_aValues_X.init( xValues ); + lcl_clearIfNoValuesButTextIsContained( m_aValues_X, xValues ); +} + void VDataSeries::setGlobalSeriesIndex( sal_Int32 nGlobalSeriesIndex ) { m_nGlobalSeriesIndex = nGlobalSeriesIndex; diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx index 48397464676f..2e9370cc91a7 100644 --- a/chart2/source/view/main/VLegend.cxx +++ b/chart2/source/view/main/VLegend.cxx @@ -37,13 +37,14 @@ #include "ShapeFactory.hxx" #include "RelativeSizeHelper.hxx" #include "LegendEntryProvider.hxx" +#include "chartview/DrawModelWrapper.hxx" #include <com/sun/star/text/XTextRange.hpp> #include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/drawing/TextHorizontalAdjust.hpp> #include <com/sun/star/drawing/LineJoint.hpp> -#include <com/sun/star/chart2/LegendExpansion.hpp> +#include <com/sun/star/chart/ChartLegendExpansion.hpp> #include <com/sun/star/chart2/LegendPosition.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> #include <rtl/ustrbuf.hxx> @@ -105,7 +106,6 @@ void lcl_getProperties( const Reference< beans::XPropertySet > & xLegendProp, tPropertyValues & rOutLineFillProperties, tPropertyValues & rOutTextProperties, - sal_Int32 nMaxLabelWidth, const awt::Size & rReferenceSize ) { // Get Line- and FillProperties from model legend @@ -128,7 +128,7 @@ void lcl_getProperties( aTextValueMap[ C2U("TextAutoGrowHeight") ] = uno::makeAny( sal_True ); aTextValueMap[ C2U("TextAutoGrowWidth") ] = uno::makeAny( sal_True ); aTextValueMap[ C2U("TextHorizontalAdjust") ] = uno::makeAny( eHorizAdjust ); - aTextValueMap[ C2U("TextMaximumFrameWidth") ] = uno::makeAny( nMaxLabelWidth ); + aTextValueMap[ C2U("TextMaximumFrameWidth") ] = uno::makeAny( rReferenceSize.Width ); //needs to be overwritten by actual available space in the legend // recalculate font size awt::Size aPropRefSize; @@ -175,16 +175,10 @@ awt::Size lcl_createTextShapes( try { // create label shape - Reference< drawing::XShape > xGroupShapeForSingleEntry( - xShapeFactory->createInstance( - C2U( "com.sun.star.drawing.GroupShape" )), uno::UNO_QUERY_THROW ); - Reference< drawing::XShape >xEntry( + Reference< drawing::XShape > xEntry( xShapeFactory->createInstance( C2U( "com.sun.star.drawing.TextShape" )), uno::UNO_QUERY_THROW ); - xTarget->add( xGroupShapeForSingleEntry ); - - Reference< drawing::XShapes > xGroup( xGroupShapeForSingleEntry, uno::UNO_QUERY_THROW ); - xGroup->add( xEntry ); + xTarget->add( xEntry ); // set label text Sequence< Reference< XFormattedString > > aLabelSeq = (*aIt).aLabel; @@ -212,7 +206,7 @@ awt::Size lcl_createTextShapes( aResult.Height = ::std::max( aResult.Height, aCurrSize.Height ); } - rOutTextShapes.push_back( xGroupShapeForSingleEntry ); + rOutTextShapes.push_back( xEntry ); } catch( uno::Exception & ex ) { @@ -223,57 +217,272 @@ awt::Size lcl_createTextShapes( return aResult; } +void lcl_collectColumnWidths( std::vector< sal_Int32 >& rColumnWidths, const sal_Int32 nNumberOfRows, const sal_Int32 nNumberOfColumns + , const ::std::vector< Reference< drawing::XShape > > aTextShapes, sal_Int32 nSymbolPlusDistanceWidth ) +{ + rColumnWidths.clear(); + sal_Int32 nRow = 0; + sal_Int32 nColumn = 0; + sal_Int32 nNumberOfEntries = aTextShapes.size(); + for( ; nRow < nNumberOfRows; ++nRow ) + { + for( nColumn = 0; nColumn < nNumberOfColumns; ++nColumn ) + { + sal_Int32 nEntry = (nColumn + nRow * nNumberOfColumns); + if( nEntry < nNumberOfEntries ) + { + awt::Size aTextSize( aTextShapes[ nEntry ]->getSize() ); + sal_Int32 nWidth = nSymbolPlusDistanceWidth + aTextSize.Width; + if( nRow==0 ) + rColumnWidths.push_back( nWidth ); + else + rColumnWidths[nColumn] = ::std::max( nWidth, rColumnWidths[nColumn] ); + } + } + } +} -void lcl_placeLegendEntries( - const tViewLegendEntryContainer & rEntries, - LegendExpansion eExpansion, +void lcl_collectRowHeighs( std::vector< sal_Int32 >& rRowHeights, const sal_Int32 nNumberOfRows, const sal_Int32 nNumberOfColumns + , const ::std::vector< Reference< drawing::XShape > > aTextShapes ) +{ + // calculate maximum height for each row + // and collect column widths + rRowHeights.clear(); + sal_Int32 nRow = 0; + sal_Int32 nColumn = 0; + sal_Int32 nNumberOfEntries = aTextShapes.size(); + for( ; nRow < nNumberOfRows; ++nRow ) + { + sal_Int32 nCurrentRowHeight = 0; + for( nColumn = 0; nColumn < nNumberOfColumns; ++nColumn ) + { + sal_Int32 nEntry = (nColumn + nRow * nNumberOfColumns); + if( nEntry < nNumberOfEntries ) + { + awt::Size aTextSize( aTextShapes[ nEntry ]->getSize() ); + nCurrentRowHeight = ::std::max( nCurrentRowHeight, aTextSize.Height ); + } + } + rRowHeights.push_back( nCurrentRowHeight ); + } +} + +sal_Int32 lcl_getTextLineHeight( const std::vector< sal_Int32 >& aRowHeights, const sal_Int32 nNumberOfRows, double fViewFontSize ) +{ + const sal_Int32 nFontHeight = static_cast< sal_Int32 >( fViewFontSize ); + sal_Int32 nTextLineHeight = nFontHeight; + for( sal_Int32 nR=0; nR<nNumberOfRows; nR++ ) + { + sal_Int32 nFullTextHeight = aRowHeights[ nR ]; + if( ( nFullTextHeight / nFontHeight ) <= 1 ) + { + nTextLineHeight = nFullTextHeight;//found an entry with one line-> have real text height + break; + } + } + return nTextLineHeight; +} + +//returns resulting legend size +awt::Size lcl_placeLegendEntries( + tViewLegendEntryContainer & rEntries, + ::com::sun::star::chart::ChartLegendExpansion eExpansion, bool bSymbolsLeftSide, - const Reference< beans::XPropertySet > & xProperties, + double fViewFontSize, + const awt::Size& rMaxSymbolExtent, tPropertyValues & rTextProperties, const Reference< drawing::XShapes > & xTarget, const Reference< lang::XMultiServiceFactory > & xShapeFactory, - const Reference< uno::XComponentContext > & /* xContext */, - const awt::Size & rAvailableSpace, - const awt::Size & rPageSize, - awt::Size & rOutLegendSize ) + const awt::Size & rAvailableSpace ) { - double fViewFontSize = lcl_CalcViewFontSize( xProperties, rPageSize ); + bool bIsCustomSize = (eExpansion == ::com::sun::star::chart::ChartLegendExpansion_CUSTOM); + awt::Size aResultingLegendSize(0,0); + if( bIsCustomSize ) + aResultingLegendSize = rAvailableSpace; - // padding as percentage of the font height // #i109336# Improve auto positioning in chart - double fXPadding = 0.1; - double fYPadding = 0.2; - double fXOffset = 0.15; - double fYOffset = 0.15; - - const sal_Int32 nXPadding = static_cast< sal_Int32 >( fViewFontSize * fXPadding ); - const sal_Int32 nYPadding = static_cast< sal_Int32 >( fViewFontSize * fYPadding ); - const sal_Int32 nXOffset = static_cast< sal_Int32 >( fViewFontSize * fXOffset ); - const sal_Int32 nYOffset = static_cast< sal_Int32 >( fViewFontSize * fYOffset ); + sal_Int32 nXPadding = static_cast< sal_Int32 >( std::max( 100.0, fViewFontSize * 0.33 ) ); + //sal_Int32 nXPadding = static_cast< sal_Int32 >( std::max( 200.0, fViewFontSize * 0.33 ) ); + sal_Int32 nXOffset = static_cast< sal_Int32 >( std::max( 100.0, fViewFontSize * 0.66 ) ); + sal_Int32 nYPadding = static_cast< sal_Int32 >( std::max( 100.0, fViewFontSize * 0.2 ) ); + sal_Int32 nYOffset = static_cast< sal_Int32 >( std::max( 100.0, fViewFontSize * 0.2 ) ); + //sal_Int32 nYOffset = static_cast< sal_Int32 >( std::max( 230.0, fViewFontSize * 0.45 ) ); + + const sal_Int32 nSymbolToTextDistance = static_cast< sal_Int32 >( std::max( 100.0, fViewFontSize * 0.22 ) );//minimum 1mm + const sal_Int32 nSymbolPlusDistanceWidth = rMaxSymbolExtent.Width + nSymbolToTextDistance; + sal_Int32 nMaxTextWidth = rAvailableSpace.Width - (2 * nXPadding) - nSymbolPlusDistanceWidth; + rtl::OUString aPropNameTextMaximumFrameWidth( C2U("TextMaximumFrameWidth") ); + uno::Any* pFrameWidthAny = PropertyMapper::getValuePointer( rTextProperties.second, rTextProperties.first, aPropNameTextMaximumFrameWidth); + if(pFrameWidthAny) + { + if( eExpansion == ::com::sun::star::chart::ChartLegendExpansion_HIGH ) + { + // limit the width of texts to 30% of the total available width + // #i109336# Improve auto positioning in chart + nMaxTextWidth = rAvailableSpace.Width * 3 / 10; + } + *pFrameWidthAny = uno::makeAny(nMaxTextWidth); + } ::std::vector< Reference< drawing::XShape > > aTextShapes; - awt::Size aMaxEntryExtent = lcl_createTextShapes( - rEntries, xShapeFactory, xTarget, aTextShapes, rTextProperties ); + awt::Size aMaxEntryExtent = lcl_createTextShapes( rEntries, xShapeFactory, xTarget, aTextShapes, rTextProperties ); OSL_ASSERT( aTextShapes.size() == rEntries.size()); - // #i109336# Improve auto positioning in chart - double fSymbolSizeFraction = 0.8; - awt::Size aMaxSymbolExtent( static_cast< sal_Int32 >( fViewFontSize * fSymbolSizeFraction * 3.0 / 2.0 ), - static_cast< sal_Int32 >( fViewFontSize * fSymbolSizeFraction ) ); - - sal_Int32 nCurrentXPos = nXPadding; - sal_Int32 nCurrentYPos = nYPadding; - sal_Int32 nMaxEntryWidth = 2 * nXOffset + aMaxSymbolExtent.Width + aMaxEntryExtent.Width; + sal_Int32 nMaxEntryWidth = nXOffset + nSymbolPlusDistanceWidth + aMaxEntryExtent.Width; sal_Int32 nMaxEntryHeight = nYOffset + aMaxEntryExtent.Height; sal_Int32 nNumberOfEntries = rEntries.size(); - if( !bSymbolsLeftSide ) - nCurrentXPos = -nXPadding; - sal_Int32 nNumberOfColumns = 0, nNumberOfRows = 0; + std::vector< sal_Int32 > aColumnWidths; + std::vector< sal_Int32 > aRowHeights; + + sal_Int32 nTextLineHeight = static_cast< sal_Int32 >( fViewFontSize ); // determine layout depending on LegendExpansion - if( eExpansion == LegendExpansion_HIGH ) + if( eExpansion == ::com::sun::star::chart::ChartLegendExpansion_CUSTOM ) + { + sal_Int32 nCurrentRow=0; + sal_Int32 nCurrentColumn=-1; + sal_Int32 nColumnCount=0; + sal_Int32 nMaxColumnCount=-1; + for( sal_Int32 nN=0; nN<static_cast<sal_Int32>(aTextShapes.size()); nN++ ) + { + Reference< drawing::XShape > xShape( aTextShapes[nN] ); + if( !xShape.is() ) + continue; + awt::Size aSize( xShape->getSize() ); + sal_Int32 nNewWidth = aSize.Width + nSymbolPlusDistanceWidth; + sal_Int32 nCurrentColumnCount = aColumnWidths.size(); + + //are we allowed to add a new column? + if( nMaxColumnCount==-1 || (nCurrentColumn+1) < nMaxColumnCount ) + { + //try add a new column + nCurrentColumn++; + if( nCurrentColumn < nCurrentColumnCount ) + { + //check wether the current column width is sufficient for the new entry + if( aColumnWidths[nCurrentColumn]>=nNewWidth ) + { + //all good proceed with next entry + continue; + } + } + if( nCurrentColumn < nCurrentColumnCount ) + aColumnWidths[nCurrentColumn] = std::max( nNewWidth, aColumnWidths[nCurrentColumn] ); + else + aColumnWidths.push_back(nNewWidth); + + //do the columns still fit into the given size? + nCurrentColumnCount = aColumnWidths.size();//update count + sal_Int32 nSumWidth = 0; + for( sal_Int32 nC=0; nC<nCurrentColumnCount; nC++ ) + nSumWidth += aColumnWidths[nC]; + + if( nSumWidth <= rAvailableSpace.Width || nCurrentColumnCount==1 ) + { + //all good proceed with next entry + continue; + } + else + { + //not enough space for the current amount of columns + //try again with less columns + nMaxColumnCount = nCurrentColumnCount-1; + nN=-1; + nCurrentRow=0; + nCurrentColumn=-1; + nColumnCount=0; + aColumnWidths.clear(); + } + } + else + { + //add a new row and try the same entry again + nCurrentRow++; + nCurrentColumn=-1; + nN--; + } + } + nNumberOfColumns = aColumnWidths.size(); + nNumberOfRows = nCurrentRow+1; + + //check if there is not enough space so that some entries must be removed + lcl_collectRowHeighs( aRowHeights, nNumberOfRows, nNumberOfColumns, aTextShapes ); + nTextLineHeight = lcl_getTextLineHeight( aRowHeights, nNumberOfRows, fViewFontSize ); + sal_Int32 nSumHeight = 0; + for( sal_Int32 nR=0; nR<nNumberOfRows; nR++ ) + nSumHeight += aRowHeights[nR]; + sal_Int32 nRemainingSpace = rAvailableSpace.Height - nSumHeight; + + if( nRemainingSpace<0 ) + { + //remove entries that are too big + for( sal_Int32 nR=nNumberOfRows; nR--; ) + { + for( sal_Int32 nC=nNumberOfColumns; nC--; ) + { + sal_Int32 nEntry = (nC + nR * nNumberOfColumns); + if( nEntry < static_cast<sal_Int32>(aTextShapes.size()) ) + { + DrawModelWrapper::removeShape( aTextShapes[nEntry] ); + aTextShapes.pop_back(); + } + if( nEntry < nNumberOfEntries ) + { + DrawModelWrapper::removeShape( rEntries[ nEntry ].aSymbol ); + rEntries.pop_back(); + nNumberOfEntries--; + } + } + nSumHeight -= aRowHeights[nR]; + aRowHeights.pop_back(); + nRemainingSpace = rAvailableSpace.Height - nSumHeight; + if( nRemainingSpace>=0 ) + break; + } + nNumberOfRows = static_cast<sal_Int32>(aRowHeights.size()); + } + if( nRemainingSpace > 0 ) + { + sal_Int32 nNormalSpacingHeight = 2*nYPadding+(nNumberOfRows-1)*nYOffset; + if( nRemainingSpace < nNormalSpacingHeight ) + { + //reduce spacing between the entries + nYPadding = nYOffset = nRemainingSpace/(nNumberOfRows+1); + } + else + { + //we have some space left that should be spread equally between all rows + sal_Int32 nRemainingSingleSpace = (nRemainingSpace-nNormalSpacingHeight)/(nNumberOfRows+1); + nYPadding += nRemainingSingleSpace; + nYOffset += nRemainingSingleSpace; + } + } + + //check spacing between columns + sal_Int32 nSumWidth = 0; + for( sal_Int32 nC=0; nC<nNumberOfColumns; nC++ ) + nSumWidth += aColumnWidths[nC]; + nRemainingSpace = rAvailableSpace.Width - nSumWidth; + if( nRemainingSpace>=0 ) + { + sal_Int32 nNormalSpacingWidth = 2*nXPadding+(nNumberOfColumns-1)*nXOffset; + if( nRemainingSpace < nNormalSpacingWidth ) + { + //reduce spacing between the entries + nXPadding = nXOffset = nRemainingSpace/(nNumberOfColumns+1); + } + else + { + //we have some space left that should be spread equally between all columns + sal_Int32 nRemainingSingleSpace = (nRemainingSpace-nNormalSpacingWidth)/(nNumberOfColumns+1); + nXPadding += nRemainingSingleSpace; + nXOffset += nRemainingSingleSpace; + } + } + } + else if( eExpansion == ::com::sun::star::chart::ChartLegendExpansion_HIGH ) { sal_Int32 nMaxNumberOfRows = nMaxEntryHeight ? (rAvailableSpace.Height - 2*nYPadding ) / nMaxEntryHeight @@ -290,7 +499,7 @@ void lcl_placeLegendEntries( static_cast< double >( nNumberOfColumns ) )) : 0; } - else if( eExpansion == LegendExpansion_WIDE ) + else if( eExpansion == ::com::sun::star::chart::ChartLegendExpansion_WIDE ) { sal_Int32 nMaxNumberOfColumns = nMaxEntryWidth ? (rAvailableSpace.Width - 2*nXPadding ) / nMaxEntryWidth @@ -307,7 +516,7 @@ void lcl_placeLegendEntries( static_cast< double >( nNumberOfRows ) )) : 0; } - else // LegendExpansion_BALANCED + else // ::com::sun::star::chart::ChartLegendExpansion_BALANCED { double fAspect = nMaxEntryHeight ? static_cast< double >( nMaxEntryWidth ) / static_cast< double >( nMaxEntryHeight ) @@ -323,93 +532,90 @@ void lcl_placeLegendEntries( } if(nNumberOfRows<=0) - return; + return aResultingLegendSize; - // calculate maximum height for current row - std::vector< sal_Int32 > nMaxHeights( nNumberOfRows ); - sal_Int32 nRow = 0; - sal_Int32 nColumn = 0; - for( ; nRow < nNumberOfRows; ++nRow ) + if( eExpansion != ::com::sun::star::chart::ChartLegendExpansion_CUSTOM ) { - sal_Int32 nMaxHeight = 0; - for( nColumn = 0; nColumn < nNumberOfColumns; ++nColumn ) - { - sal_Int32 nEntry = ( eExpansion == LegendExpansion_WIDE ) - ? (nColumn + nRow * nNumberOfColumns) - // HIGH or BALANCED - : (nRow + nColumn * nNumberOfRows); - if( nEntry < nNumberOfEntries ) - nMaxHeight = ::std::max( - nMaxHeight, nYOffset + aTextShapes[ nEntry ]->getSize().Height ); - } - nMaxHeights[ nRow ] = nMaxHeight; + lcl_collectColumnWidths( aColumnWidths, nNumberOfRows, nNumberOfColumns, aTextShapes, nSymbolPlusDistanceWidth ); + lcl_collectRowHeighs( aRowHeights, nNumberOfRows, nNumberOfColumns, aTextShapes ); + nTextLineHeight = lcl_getTextLineHeight( aRowHeights, nNumberOfRows, fViewFontSize ); } - // place entries ordered in optimal-width columns + sal_Int32 nCurrentXPos = nXPadding; + sal_Int32 nCurrentYPos = nYPadding; + if( !bSymbolsLeftSide ) + nCurrentXPos = -nXPadding; + + // place entries into column and rows sal_Int32 nMaxYPos = 0; + sal_Int32 nRow = 0; + sal_Int32 nColumn = 0; for( nColumn = 0; nColumn < nNumberOfColumns; ++nColumn ) { - sal_Int32 nMaxWidth = 0; nCurrentYPos = nYPadding; - for( nRow = 0; nRow < nNumberOfRows; ++nRow ) { - sal_Int32 nEntry = ( eExpansion == LegendExpansion_WIDE ) - ? (nColumn + nRow * nNumberOfColumns) - // HIGH or BALANCED - : (nRow + nColumn * nNumberOfRows); - + sal_Int32 nEntry = (nColumn + nRow * nNumberOfColumns); if( nEntry >= nNumberOfEntries ) break; + // text shape + Reference< drawing::XShape > xTextShape( aTextShapes[nEntry] ); + if( xTextShape.is() ) + { + awt::Size aTextSize( xTextShape->getSize() ); + sal_Int32 nTextXPos = nCurrentXPos + nSymbolPlusDistanceWidth; + if( !bSymbolsLeftSide ) + nTextXPos = nCurrentXPos - nSymbolPlusDistanceWidth - aTextSize.Width; + xTextShape->setPosition( awt::Point( nTextXPos, nCurrentYPos )); + } + // symbol Reference< drawing::XShape > xSymbol( rEntries[ nEntry ].aSymbol ); - if( xSymbol.is() ) { - // Note: aspect ratio should always be 3:2 - - // set symbol size to 75% of maximum space - awt::Size aSymbolSize( - aMaxSymbolExtent.Width * 75 / 100, - aMaxSymbolExtent.Height * 75 / 100 ); - xSymbol->setSize( aSymbolSize ); - sal_Int32 nSymbolXPos = nCurrentXPos + ((aMaxSymbolExtent.Width - aSymbolSize.Width) / 2); + awt::Size aSymbolSize( rMaxSymbolExtent ); + sal_Int32 nSymbolXPos = nCurrentXPos; if( !bSymbolsLeftSide ) - nSymbolXPos = nSymbolXPos - aMaxSymbolExtent.Width; - - // #i109336# Improve auto positioning in chart - sal_Int32 nTextHeight = nMaxHeights[ nRow ] - nYOffset; - sal_Int32 nFontSize = static_cast< sal_Int32 >( fViewFontSize ); - sal_Int32 nMaxRowHeight = ( ( ( nTextHeight / nFontSize ) <= 1 ) ? nTextHeight : nFontSize ); - sal_Int32 nSymbolYPos = nCurrentYPos + ( ( nMaxRowHeight - aSymbolSize.Height ) / 2 ); + nSymbolXPos = nCurrentXPos - rMaxSymbolExtent.Width; + sal_Int32 nSymbolYPos = nCurrentYPos + ( ( nTextLineHeight - aSymbolSize.Height ) / 2 ); xSymbol->setPosition( awt::Point( nSymbolXPos, nSymbolYPos ) ); } - // position text shape - awt::Size aTextSize( aTextShapes[ nEntry ]->getSize()); - nMaxWidth = ::std::max( nMaxWidth, 2 * nXOffset + aMaxSymbolExtent.Width + aTextSize.Width ); - sal_Int32 nTextXPos = nCurrentXPos + aMaxSymbolExtent.Width; - if( !bSymbolsLeftSide ) - nTextXPos = nCurrentXPos - aMaxSymbolExtent.Width - aTextSize.Width; - aTextShapes[ nEntry ]->setPosition( awt::Point( nTextXPos, nCurrentYPos )); - - nCurrentYPos += nMaxHeights[ nRow ]; + nCurrentYPos += aRowHeights[ nRow ]; + if( nRow+1 < nNumberOfRows ) + nCurrentYPos += nYOffset; nMaxYPos = ::std::max( nMaxYPos, nCurrentYPos ); } if( bSymbolsLeftSide ) - nCurrentXPos += nMaxWidth; + { + nCurrentXPos += aColumnWidths[nColumn]; + if( nColumn+1 < nNumberOfColumns ) + nCurrentXPos += nXOffset; + } else - nCurrentXPos -= nMaxWidth; + { + nCurrentXPos -= aColumnWidths[nColumn]; + if( nColumn+1 < nNumberOfColumns ) + nCurrentXPos -= nXOffset; + } } - if( bSymbolsLeftSide ) - rOutLegendSize.Width = nCurrentXPos + nXPadding; - else + if( !bIsCustomSize ) { - sal_Int32 nLegendWidth = -(nCurrentXPos-nXPadding); - rOutLegendSize.Width = nLegendWidth; + if( bSymbolsLeftSide ) + aResultingLegendSize.Width = nCurrentXPos + nXPadding; + else + { + sal_Int32 nLegendWidth = -(nCurrentXPos-nXPadding); + aResultingLegendSize.Width = nLegendWidth; + } + aResultingLegendSize.Height = nMaxYPos + nYPadding; + } + if( !bSymbolsLeftSide ) + { + sal_Int32 nLegendWidth = aResultingLegendSize.Width; awt::Point aPos(0,0); for( sal_Int32 nEntry=0; nEntry<nNumberOfEntries; nEntry++ ) { @@ -423,7 +629,8 @@ void lcl_placeLegendEntries( xText->setPosition( aPos ); } } - rOutLegendSize.Height = nMaxYPos + nYPadding; + + return aResultingLegendSize; } // #i109336# Improve auto positioning in chart @@ -565,14 +772,6 @@ awt::Point lcl_calculatePositionAndRemainingSpace( return aResult; } -template< class T > -void lcl_appendSeqToVector( const Sequence< T > & rSource, ::std::vector< T > & rDest ) -{ - const sal_Int32 nCount = rSource.getLength(); - for( sal_Int32 i = 0; i < nCount; ++i ) - rDest.push_back( rSource[ i ] ); -} - bool lcl_shouldSymbolsBePlacedOnTheLeftSide( const Reference< beans::XPropertySet >& xLegendProp, sal_Int16 nDefaultWritingMode ) { bool bSymbolsLeftSide = true; @@ -614,7 +813,7 @@ VLegend::VLegend( // ---------------------------------------- -void SAL_CALL VLegend::init( +void VLegend::init( const Reference< drawing::XShapes >& xTargetPage, const Reference< lang::XMultiServiceFactory >& xFactory, const Reference< frame::XModel >& xModel ) @@ -688,23 +887,26 @@ void VLegend::createShapes( tPropertyValues aLineFillProperties; tPropertyValues aTextProperties; - // limit the width of texts to 30% of the total available width - // #i109336# Improve auto positioning in chart - sal_Int32 nMaxLabelWidth = rAvailableSpace.Width * 3 / 10; Reference< beans::XPropertySet > xLegendProp( m_xLegend, uno::UNO_QUERY ); - LegendExpansion eExpansion = LegendExpansion_HIGH; + ::com::sun::star::chart::ChartLegendExpansion eExpansion = ::com::sun::star::chart::ChartLegendExpansion_HIGH; + awt::Size aLegendSize( rAvailableSpace ); + if( xLegendProp.is()) { // get Expansion property xLegendProp->getPropertyValue( C2U( "Expansion" )) >>= eExpansion; - if( eExpansion == LegendExpansion_WIDE ) + if( eExpansion == ::com::sun::star::chart::ChartLegendExpansion_CUSTOM ) { - //#i80377# - nMaxLabelWidth = (rAvailableSpace.Width * 5) / 6;//completely correct would be available width minus symbol size minus distances to page ... + RelativeSize aRelativeSize; + if ((xLegendProp->getPropertyValue( C2U( "RelativeSize" )) >>= aRelativeSize)) + { + aLegendSize.Width = aRelativeSize.Primary * rPageSize.Width; + aLegendSize.Height = aRelativeSize.Secondary * rPageSize.Height; + } + else + eExpansion = ::com::sun::star::chart::ChartLegendExpansion_HIGH; } - - lcl_getProperties( xLegendProp, aLineFillProperties, aTextProperties, nMaxLabelWidth, - rPageSize ); + lcl_getProperties( xLegendProp, aLineFillProperties, aTextProperties, rPageSize ); } if( xBorder.is()) @@ -721,32 +923,47 @@ void VLegend::createShapes( } // create entries - tViewLegendEntryContainer aViewEntries; + double fViewFontSize = lcl_CalcViewFontSize( xLegendProp, rPageSize );//todo + // #i109336# Improve auto positioning in chart + sal_Int32 nSymbolHeigth = static_cast< sal_Int32 >( fViewFontSize * 0.6 ); + sal_Int32 nSymbolWidth = static_cast< sal_Int32 >( nSymbolHeigth ); + + ::std::vector< LegendEntryProvider* >::const_iterator aIter = m_aLegendEntryProviderList.begin(); + const ::std::vector< LegendEntryProvider* >::const_iterator aEnd = m_aLegendEntryProviderList.end(); + for( aIter = m_aLegendEntryProviderList.begin(); aIter != aEnd; aIter++ ) { - ::std::vector< LegendEntryProvider* >::const_iterator aIter = m_aLegendEntryProviderList.begin(); - const ::std::vector< LegendEntryProvider* >::const_iterator aEnd = m_aLegendEntryProviderList.end(); - for( ; aIter != aEnd; aIter++ ) + LegendEntryProvider* pLegendEntryProvider( *aIter ); + if( pLegendEntryProvider ) { - LegendEntryProvider* pLegendEntryProvider( *aIter ); - if( pLegendEntryProvider ) + awt::Size aCurrentRatio = pLegendEntryProvider->getPreferredLegendKeyAspectRatio(); + sal_Int32 nCurrentWidth = aCurrentRatio.Width; + if( aCurrentRatio.Height > 0 ) { - lcl_appendSeqToVector< ViewLegendEntry >( - pLegendEntryProvider->createLegendEntries( eExpansion, xLegendProp, xLegendContainer, m_xShapeFactory, m_xContext ) - , aViewEntries ); + nCurrentWidth = nSymbolHeigth* aCurrentRatio.Width/aCurrentRatio.Height; } + nSymbolWidth = std::max( nSymbolWidth, nCurrentWidth ); + } + } + awt::Size aMaxSymbolExtent( nSymbolWidth, nSymbolHeigth ); + + tViewLegendEntryContainer aViewEntries; + for( aIter = m_aLegendEntryProviderList.begin(); aIter != aEnd; aIter++ ) + { + LegendEntryProvider* pLegendEntryProvider( *aIter ); + if( pLegendEntryProvider ) + { + std::vector< ViewLegendEntry > aNewEntries = pLegendEntryProvider->createLegendEntries( aMaxSymbolExtent, eExpansion, xLegendProp, xLegendContainer, m_xShapeFactory, m_xContext ); + aViewEntries.insert( aViewEntries.end(), aNewEntries.begin(), aNewEntries.end() ); } } bool bSymbolsLeftSide = lcl_shouldSymbolsBePlacedOnTheLeftSide( xLegendProp, m_nDefaultWritingMode ); // place entries - awt::Size aLegendSize; - lcl_placeLegendEntries( aViewEntries, eExpansion, bSymbolsLeftSide - , xLegendProp, aTextProperties - , xLegendContainer, m_xShapeFactory, m_xContext - , rAvailableSpace, rPageSize, aLegendSize ); + aLegendSize = lcl_placeLegendEntries( aViewEntries, eExpansion, bSymbolsLeftSide, fViewFontSize, aMaxSymbolExtent + , aTextProperties, xLegendContainer, m_xShapeFactory, aLegendSize ); - if( xBorder.is()) + if( xBorder.is() ) xBorder->setSize( aLegendSize ); } } diff --git a/chart2/source/view/main/VLegend.hxx b/chart2/source/view/main/VLegend.hxx index 74f49a08e1b9..9770730697be 100644 --- a/chart2/source/view/main/VLegend.hxx +++ b/chart2/source/view/main/VLegend.hxx @@ -57,7 +57,7 @@ public: ::com::sun::star::uno::XComponentContext > & xContext, const std::vector< LegendEntryProvider* >& rLegendEntryProviderList ); - void SAL_CALL init( const ::com::sun::star::uno::Reference< + void init( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTargetPage, const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory, diff --git a/chart2/source/view/main/VLegendSymbolFactory.cxx b/chart2/source/view/main/VLegendSymbolFactory.cxx index ffe47937eb56..373f482c438e 100644 --- a/chart2/source/view/main/VLegendSymbolFactory.cxx +++ b/chart2/source/view/main/VLegendSymbolFactory.cxx @@ -39,9 +39,6 @@ // header for define DBG_ASSERT #include <tools/debug.hxx> -// uncomment to disable line dashes at the border of boxes -// #define DISABLE_DASHES_AT_BORDER - using namespace ::com::sun::star; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; @@ -106,16 +103,16 @@ namespace chart { Reference< drawing::XShape > VLegendSymbolFactory::createSymbol( + const awt::Size& rEntryKeyAspectRatio, const Reference< drawing::XShapes > xSymbolContainer, - chart2::LegendSymbolStyle eStyle, + LegendSymbolStyle eStyle, const Reference< lang::XMultiServiceFactory > & xShapeFactory, const Reference< beans::XPropertySet > & xLegendEntryProperties, tPropertyType ePropertyType, const uno::Any& rExplicitSymbol ) { Reference< drawing::XShape > xResult; - if( ! (xSymbolContainer.is() && - xShapeFactory.is())) + if( ! (xSymbolContainer.is() && xShapeFactory.is())) return xResult; xResult.set( xShapeFactory->createInstance( @@ -125,247 +122,92 @@ Reference< drawing::XShape > VLegendSymbolFactory::createSymbol( if( ! xResultGroup.is()) return xResult; - // aspect ratio of symbols is always 3:2 - awt::Size aBoundSize( 3000, 2000 ); - bool bUseBox = false; - // add an invisible square box to maintain aspect ratio - switch( eStyle ) - { - case chart2::LegendSymbolStyle_BOX: - case chart2::LegendSymbolStyle_HORIZONTAL_LINE: - case chart2::LegendSymbolStyle_VERTICAL_LINE: - case chart2::LegendSymbolStyle_DIAGONAL_LINE: - case chart2::LegendSymbolStyle_LINE_WITH_BOX: - case chart2::LegendSymbolStyle_LINE_WITH_SYMBOL: - case chart2::LegendSymbolStyle_CIRCLE: - { - Reference< drawing::XShape > xBound( ShapeFactory(xShapeFactory).createInvisibleRectangle( - xResultGroup, aBoundSize )); - break; - } - - case chart2::LegendSymbolStyle_BAR: - case chart2::LegendSymbolStyle_RECTANGLE: - case chart2::LegendSymbolStyle_STRETCHED_RECTANGLE: - case chart2::LegendSymbolStyle_USER_DEFINED: - default: - break; - } + Reference< drawing::XShape > xBound( ShapeFactory(xShapeFactory).createInvisibleRectangle( + xResultGroup, rEntryKeyAspectRatio )); // create symbol - switch( eStyle ) + try { - case chart2::LegendSymbolStyle_BOX: - case chart2::LegendSymbolStyle_BAR: - case chart2::LegendSymbolStyle_RECTANGLE: - case chart2::LegendSymbolStyle_STRETCHED_RECTANGLE: - case chart2::LegendSymbolStyle_CIRCLE: + if( eStyle == LegendSymbolStyle_LINE ) { - try + Reference< drawing::XShape > xLine( xShapeFactory->createInstance( + C2U( "com.sun.star.drawing.LineShape" )), uno::UNO_QUERY ); + if( xLine.is()) { - Reference< drawing::XShape > xShape; + xResultGroup->add( xLine ); + xLine->setSize( awt::Size( rEntryKeyAspectRatio.Width, 0 )); + xLine->setPosition( awt::Point( 0, rEntryKeyAspectRatio.Height/2 )); - if( eStyle == chart2::LegendSymbolStyle_CIRCLE ) - xShape.set( xShapeFactory->createInstance( - C2U( "com.sun.star.drawing.EllipseShape" )), uno::UNO_QUERY ); - else - xShape.set( xShapeFactory->createInstance( - C2U( "com.sun.star.drawing.RectangleShape" )), uno::UNO_QUERY ); + lcl_setPropetiesToShape( xLegendEntryProperties, xLine, ePropertyType ); + } - if( xShape.is()) + Reference< drawing::XShape > xSymbol; + const sal_Int32 nSize = std::min(rEntryKeyAspectRatio.Width,rEntryKeyAspectRatio.Height); + chart2::Symbol aSymbol; + if( rExplicitSymbol >>= aSymbol ) + { + drawing::Direction3D aSymbolSize( nSize, nSize, 0 ); + drawing::Position3D aPos( rEntryKeyAspectRatio.Width/2, rEntryKeyAspectRatio.Height/2, 0 ); + ShapeFactory aFactory( xShapeFactory ); + if( aSymbol.Style == chart2::SymbolStyle_STANDARD ) { - xResultGroup->add( xShape ); - if( eStyle == chart2::LegendSymbolStyle_BOX || - eStyle == chart2::LegendSymbolStyle_CIRCLE ) - { - xShape->setSize( awt::Size( 2000, 2000 )); - xShape->setPosition( awt::Point( 500, 0 )); - } - else - { - xShape->setSize( aBoundSize ); - } + // take series color as fill color + xLegendEntryProperties->getPropertyValue( C2U("Color")) >>= aSymbol.FillColor; + // border of symbols always same as fill color + aSymbol.BorderColor = aSymbol.FillColor; + + xSymbol.set( aFactory.createSymbol2D( + xResultGroup, + aPos, + aSymbolSize, + aSymbol.StandardSymbol, + aSymbol.BorderColor, + aSymbol.FillColor )); } - - lcl_setPropetiesToShape( xLegendEntryProperties, xShape, ePropertyType ); // PROP_TYPE_FILLED_SERIES ); - -#ifdef DISABLE_DASHES_AT_BORDER - // don't allow dashed border style - Reference< beans::XPropertySet > xShapeProp( xShape, uno::UNO_QUERY ); - if( xShapeProp.is()) + else if( aSymbol.Style == chart2::SymbolStyle_GRAPHIC ) { - drawing::LineStyle aLineStyle; - if( ( xShapeProp->getPropertyValue( C2U("LineStyle")) >>= aLineStyle ) && - aLineStyle == drawing::LineStyle_DASH ) - { - aLineStyle = drawing::LineStyle_SOLID; - xShapeProp->setPropertyValue( C2U("LineStyle"), uno::makeAny( aLineStyle )); - } + xSymbol.set( aFactory.createGraphic2D( + xResultGroup, + aPos, + aSymbolSize, + aSymbol.Graphic )); } -#endif - } - catch( uno::Exception & ex ) - { - ASSERT_EXCEPTION( ex ); - } - break; - } - - case chart2::LegendSymbolStyle_HORIZONTAL_LINE: - { - try - { - Reference< drawing::XShape > xLine( - xShapeFactory->createInstance( - C2U( "com.sun.star.drawing.LineShape" )), uno::UNO_QUERY ); - if( xLine.is()) + else if( aSymbol.Style == chart2::SymbolStyle_AUTO ) { - xResultGroup->add( xLine ); - xLine->setSize( awt::Size( 3000, 0 )); - xLine->setPosition( awt::Point( 0, 1000 )); - - lcl_setPropetiesToShape( xLegendEntryProperties, xLine, ePropertyType ); // PROP_TYPE_LINE_SERIES ); + DBG_ERROR("the given parameter is not allowed to contain an automatic symbol style"); } } - catch( uno::Exception & ex ) - { - ASSERT_EXCEPTION( ex ); - } - break; } - - case chart2::LegendSymbolStyle_VERTICAL_LINE: + else if( eStyle == LegendSymbolStyle_CIRCLE ) { - try + Reference< drawing::XShape > xShape( xShapeFactory->createInstance( + C2U( "com.sun.star.drawing.EllipseShape" )), uno::UNO_QUERY ); + if( xShape.is() ) { - Reference< drawing::XShape > xLine( - xShapeFactory->createInstance( - C2U( "com.sun.star.drawing.LineShape" )), uno::UNO_QUERY ); - if( xLine.is()) - { - xResultGroup->add( xLine ); - xLine->setSize( awt::Size( 0, 2000 )); - xLine->setPosition( awt::Point( 1500, 0 )); - - lcl_setPropetiesToShape( xLegendEntryProperties, xLine, ePropertyType ); // PROP_TYPE_LINE_SERIES ); - } - } - catch( uno::Exception & ex ) - { - ASSERT_EXCEPTION( ex ); + xResultGroup->add( xShape ); + sal_Int32 nSize = std::min( rEntryKeyAspectRatio.Width, rEntryKeyAspectRatio.Height ); + xShape->setSize( awt::Size( nSize, nSize ) ); + xShape->setPosition( awt::Point( rEntryKeyAspectRatio.Width/2-nSize/2, rEntryKeyAspectRatio.Height/2-nSize/2 ) ); + lcl_setPropetiesToShape( xLegendEntryProperties, xShape, ePropertyType ); // PROP_TYPE_FILLED_SERIES ); } - break; } - - case chart2::LegendSymbolStyle_DIAGONAL_LINE: + else // eStyle == LegendSymbolStyle_BOX { - try + Reference< drawing::XShape > xShape( xShapeFactory->createInstance( + C2U( "com.sun.star.drawing.RectangleShape" )), uno::UNO_QUERY ); + if( xShape.is() ) { - Reference< drawing::XShape > xLine( - xShapeFactory->createInstance( - C2U( "com.sun.star.drawing.LineShape" )), uno::UNO_QUERY ); - if( xLine.is()) - { - xResultGroup->add( xLine ); - xLine->setSize( awt::Size( 2000, 2000 )); - xLine->setPosition( awt::Point( 500, 0 )); - - lcl_setPropetiesToShape( xLegendEntryProperties, xLine, ePropertyType ); // PROP_TYPE_LINE_SERIES ); - } - } - catch( uno::Exception & ex ) - { - ASSERT_EXCEPTION( ex ); + xResultGroup->add( xShape ); + xShape->setSize( rEntryKeyAspectRatio ); + xShape->setPosition( awt::Point( 0, 0 ) ); + lcl_setPropetiesToShape( xLegendEntryProperties, xShape, ePropertyType ); // PROP_TYPE_FILLED_SERIES ); } - break; } - - case chart2::LegendSymbolStyle_LINE_WITH_BOX: - bUseBox = true; - // fall-through intended - case chart2::LegendSymbolStyle_LINE_WITH_SYMBOL: - try - { - Reference< drawing::XShape > xLine( - xShapeFactory->createInstance( - C2U( "com.sun.star.drawing.LineShape" )), uno::UNO_QUERY ); - if( xLine.is()) - { - xResultGroup->add( xLine ); - xLine->setSize( awt::Size( 3000, 0 )); - xLine->setPosition( awt::Point( 0, 1000 )); - - lcl_setPropetiesToShape( xLegendEntryProperties, xLine, ePropertyType ); - } - - Reference< drawing::XShape > xSymbol; - const sal_Int32 nSize = 1500; - if( bUseBox ) - { - xSymbol.set( xShapeFactory->createInstance( - C2U( "com.sun.star.drawing.RectangleShape" )), uno::UNO_QUERY ); - xResultGroup->add( xSymbol ); - - if( xSymbol.is()) - { - xSymbol->setSize( awt::Size( nSize, nSize )); - xSymbol->setPosition( awt::Point( 1500 - nSize/2, 1000 - nSize/2 )); - - lcl_setPropetiesToShape( xLegendEntryProperties, xSymbol, ePropertyType ); - } - } - else - { - chart2::Symbol aSymbol; - - if( rExplicitSymbol >>= aSymbol ) - { - drawing::Direction3D aSymbolSize( nSize, nSize, 0 ); - drawing::Position3D aPos( 1500, 1000, 0 ); - ShapeFactory aFactory( xShapeFactory ); - if( aSymbol.Style == chart2::SymbolStyle_STANDARD ) - { - // take series color as fill color - xLegendEntryProperties->getPropertyValue( C2U("Color")) >>= aSymbol.FillColor; - // border of symbols always same as fill color - aSymbol.BorderColor = aSymbol.FillColor; - - xSymbol.set( aFactory.createSymbol2D( - xResultGroup, - aPos, - aSymbolSize, - aSymbol.StandardSymbol, - aSymbol.BorderColor, - aSymbol.FillColor )); - } - else if( aSymbol.Style == chart2::SymbolStyle_GRAPHIC ) - { - xSymbol.set( aFactory.createGraphic2D( - xResultGroup, - aPos, - aSymbolSize, - aSymbol.Graphic )); - } - else if( aSymbol.Style == chart2::SymbolStyle_AUTO ) - { - OSL_FAIL("the given parameter is not allowed to contain an automatic symbol style"); - } - } - } - } - catch( uno::Exception & ex ) - { - ASSERT_EXCEPTION( ex ); - } - break; - - case chart2::LegendSymbolStyle_USER_DEFINED: - break; - - default: - // just to remove warning (there is an auto-generated extra label) - break; + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); } return xResult; diff --git a/chart2/source/view/main/VTitle.cxx b/chart2/source/view/main/VTitle.cxx index b9b1d18b3c5b..6af228d02c11 100644 --- a/chart2/source/view/main/VTitle.cxx +++ b/chart2/source/view/main/VTitle.cxx @@ -66,7 +66,7 @@ VTitle::~VTitle() { } -void SAL_CALL VTitle::init( +void VTitle::init( const uno::Reference< drawing::XShapes >& xTargetPage , const uno::Reference< lang::XMultiServiceFactory >& xFactory , const rtl::OUString& rCID ) diff --git a/chart2/source/view/main/VTitle.hxx b/chart2/source/view/main/VTitle.hxx index a4db30a439e7..61b7cadafccd 100644 --- a/chart2/source/view/main/VTitle.hxx +++ b/chart2/source/view/main/VTitle.hxx @@ -48,7 +48,7 @@ public: ::com::sun::star::chart2::XTitle > & xTitle ); virtual ~VTitle(); - void SAL_CALL init( const ::com::sun::star::uno::Reference< + void init( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTargetPage , const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory , const rtl::OUString& rCID ); diff --git a/chart2/source/view/main/_serviceregistration_view.cxx b/chart2/source/view/main/_serviceregistration_view.cxx index 8e6059afce6a..828564bec31c 100644 --- a/chart2/source/view/main/_serviceregistration_view.cxx +++ b/chart2/source/view/main/_serviceregistration_view.cxx @@ -55,13 +55,6 @@ SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } //================================================================================================== -SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, void * pRegistryKey ) -{ - return ::cppu::component_writeInfoHelper( - pServiceManager, pRegistryKey, g_entries_chart2_view ); -} -//================================================================================================== SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) { diff --git a/chart2/source/view/main/makefile.mk b/chart2/source/view/main/makefile.mk index ec9c99f2a898..8675930aa107 100644 --- a/chart2/source/view/main/makefile.mk +++ b/chart2/source/view/main/makefile.mk @@ -43,7 +43,6 @@ ENABLE_EXCEPTIONS= TRUE SLOFILES = \ $(SLO)$/ChartItemPool.obj \ $(SLO)$/DrawModelWrapper.obj \ - $(SLO)$/NumberFormatterWrapper.obj \ $(SLO)$/PropertyMapper.obj \ $(SLO)$/Stripe.obj \ $(SLO)$/VLineProperties.obj \ |