summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chart2/prj/build.lst4
-rw-r--r--chart2/qa/unoapi/Test.java51
-rw-r--r--chart2/qa/unoapi/makefile.mk30
-rw-r--r--chart2/source/controller/accessibility/AccessibleBase.cxx65
-rw-r--r--chart2/source/controller/accessibility/AccessibleChartElement.cxx12
-rw-r--r--chart2/source/controller/accessibility/AccessibleChartShape.cxx289
-rw-r--r--chart2/source/controller/accessibility/AccessibleChartShape.hxx104
-rw-r--r--chart2/source/controller/accessibility/AccessibleChartView.cxx48
-rw-r--r--chart2/source/controller/accessibility/AccessibleViewForwarder.cxx116
-rw-r--r--chart2/source/controller/accessibility/AccessibleViewForwarder.hxx65
-rw-r--r--chart2/source/controller/accessibility/ChartElementFactory.cxx7
-rw-r--r--chart2/source/controller/accessibility/makefile.mk4
-rw-r--r--chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx595
-rw-r--r--chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx44
-rw-r--r--chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx152
-rw-r--r--chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx4
-rw-r--r--chart2/source/controller/controller.map8
-rw-r--r--chart2/source/controller/dialogs/ChangingResource.cxx4
-rw-r--r--chart2/source/controller/dialogs/ChangingResource.hxx1
-rw-r--r--chart2/source/controller/dialogs/ChartTypeTemplateProvider.hxx1
-rw-r--r--chart2/source/controller/dialogs/DataBrowser.cxx71
-rw-r--r--chart2/source/controller/dialogs/DataBrowser.hxx4
-rw-r--r--chart2/source/controller/dialogs/DataBrowserModel.cxx109
-rw-r--r--chart2/source/controller/dialogs/DataBrowserModel.hxx11
-rw-r--r--chart2/source/controller/dialogs/DialogModel.cxx2
-rw-r--r--chart2/source/controller/dialogs/ObjectNameProvider.cxx4
-rw-r--r--chart2/source/controller/dialogs/ResourceIds.hrc2
-rw-r--r--chart2/source/controller/dialogs/Strings.src5
-rw-r--r--chart2/source/controller/dialogs/dlg_DataEditor.cxx52
-rw-r--r--chart2/source/controller/dialogs/dlg_DataEditor.hrc9
-rw-r--r--chart2/source/controller/dialogs/dlg_DataEditor.src8
-rw-r--r--chart2/source/controller/dialogs/dlg_ObjectProperties.cxx4
-rw-r--r--chart2/source/controller/dialogs/dlg_ShapeFont.cxx92
-rw-r--r--chart2/source/controller/dialogs/dlg_ShapeFont.src62
-rw-r--r--chart2/source/controller/dialogs/dlg_ShapeParagraph.cxx93
-rw-r--r--chart2/source/controller/dialogs/dlg_ShapeParagraph.src67
-rw-r--r--chart2/source/controller/dialogs/makefile.mk6
-rw-r--r--chart2/source/controller/dialogs/tp_ChartType.cxx8
-rw-r--r--chart2/source/controller/drawinglayer/DrawViewWrapper.cxx21
-rw-r--r--chart2/source/controller/inc/AccessibleBase.hxx20
-rw-r--r--chart2/source/controller/inc/AccessibleChartView.hxx18
-rw-r--r--chart2/source/controller/inc/HelpIds.hrc11
-rw-r--r--chart2/source/controller/inc/MenuResIds.hrc (renamed from sc/inc/eetext.hxx)14
-rw-r--r--chart2/source/controller/inc/ObjectHierarchy.hxx30
-rw-r--r--chart2/source/controller/inc/ShapeController.hrc50
-rw-r--r--chart2/source/controller/inc/dlg_ShapeFont.hxx59
-rw-r--r--chart2/source/controller/inc/dlg_ShapeParagraph.hxx54
-rw-r--r--chart2/source/controller/main/ChartController.cxx104
-rw-r--r--chart2/source/controller/main/ChartController.hxx27
-rw-r--r--chart2/source/controller/main/ChartController_TextEdit.cxx58
-rw-r--r--chart2/source/controller/main/ChartController_Tools.cxx321
-rw-r--r--chart2/source/controller/main/ChartController_Window.cxx710
-rw-r--r--chart2/source/controller/main/ChartTransferable.cxx83
-rw-r--r--chart2/source/controller/main/ChartTransferable.hxx6
-rw-r--r--chart2/source/controller/main/CommandDispatchContainer.cxx64
-rw-r--r--chart2/source/controller/main/CommandDispatchContainer.hxx44
-rw-r--r--chart2/source/controller/main/ControllerCommandDispatch.cxx46
-rw-r--r--chart2/source/controller/main/ControllerCommandDispatch.hxx11
-rw-r--r--chart2/source/controller/main/DrawCommandDispatch.cxx674
-rw-r--r--chart2/source/controller/main/DrawCommandDispatch.hrc50
-rw-r--r--chart2/source/controller/main/DrawCommandDispatch.hxx93
-rw-r--r--chart2/source/controller/main/ElementSelector.cxx67
-rw-r--r--chart2/source/controller/main/ElementSelector.hxx3
-rw-r--r--chart2/source/controller/main/FeatureCommandDispatchBase.cxx114
-rw-r--r--chart2/source/controller/main/FeatureCommandDispatchBase.hxx115
-rw-r--r--chart2/source/controller/main/ImplUndoManager.cxx (renamed from chart2/source/tools/ImplUndoManager.cxx)40
-rw-r--r--chart2/source/controller/main/ImplUndoManager.hxx (renamed from chart2/source/tools/ImplUndoManager.hxx)16
-rw-r--r--chart2/source/controller/main/ObjectHierarchy.cxx259
-rw-r--r--chart2/source/controller/main/SelectionHelper.cxx246
-rw-r--r--chart2/source/controller/main/SelectionHelper.hxx18
-rw-r--r--chart2/source/controller/main/ShapeController.cxx738
-rw-r--r--chart2/source/controller/main/ShapeController.hxx100
-rw-r--r--chart2/source/controller/main/ShapeToolbarController.cxx298
-rw-r--r--chart2/source/controller/main/ShapeToolbarController.hxx103
-rw-r--r--chart2/source/controller/main/StatusBarCommandDispatch.cxx6
-rw-r--r--chart2/source/controller/main/StatusBarCommandDispatch.hxx3
-rw-r--r--chart2/source/controller/main/UndoGuard.cxx (renamed from chart2/source/tools/UndoGuard.cxx)0
-rw-r--r--chart2/source/controller/main/UndoManager.cxx (renamed from chart2/source/tools/UndoManager.cxx)100
-rw-r--r--chart2/source/controller/main/_serviceregistration_controller.cxx13
-rw-r--r--chart2/source/controller/main/makefile.mk9
-rw-r--r--chart2/source/controller/makefile.mk3
-rw-r--r--chart2/source/controller/menus/ShapeContextMenu.src124
-rw-r--r--chart2/source/controller/menus/ShapeEditContextMenu.src65
-rw-r--r--chart2/source/controller/menus/makefile.mk63
-rw-r--r--chart2/source/inc/AxisHelper.hxx3
-rw-r--r--chart2/source/inc/ChartModelHelper.hxx16
-rw-r--r--chart2/source/inc/CloneHelper.hxx1
-rw-r--r--chart2/source/inc/DataSourceHelper.hxx13
-rw-r--r--chart2/source/inc/DiagramHelper.hxx11
-rw-r--r--chart2/source/inc/ExplicitCategoriesProvider.hxx63
-rw-r--r--chart2/source/inc/InternalData.hxx109
-rw-r--r--chart2/source/inc/InternalDataProvider.hxx69
-rw-r--r--chart2/source/inc/ObjectIdentifier.hxx32
-rw-r--r--chart2/source/inc/Strings.hrc4
-rw-r--r--chart2/source/inc/UndoGuard.hxx11
-rw-r--r--chart2/source/inc/UndoManager.hxx22
-rw-r--r--chart2/source/inc/chartview/DrawModelWrapper.hxx2
-rw-r--r--chart2/source/inc/servicenames.hxx5
-rw-r--r--chart2/source/model/inc/Diagram.hxx10
-rw-r--r--chart2/source/model/main/Axis.cxx2
-rw-r--r--chart2/source/model/main/ChartData.cxx104
-rw-r--r--chart2/source/model/main/ChartData.hxx102
-rw-r--r--chart2/source/model/main/ChartModel.cxx477
-rw-r--r--chart2/source/model/main/ChartModel.hxx52
-rw-r--r--chart2/source/model/main/ChartModel_Persistence.cxx93
-rw-r--r--chart2/source/model/main/DataSeries.cxx2
-rw-r--r--chart2/source/model/main/Diagram.cxx12
-rw-r--r--chart2/source/model/main/ImplChartModel.cxx586
-rw-r--r--chart2/source/model/main/ImplChartModel.hxx250
-rw-r--r--chart2/source/model/main/InternalData.cxx257
-rw-r--r--chart2/source/model/main/InternalData.hxx118
-rw-r--r--chart2/source/model/main/Legend.cxx2
-rw-r--r--chart2/source/model/main/makefile.mk2
-rw-r--r--chart2/source/model/makefile.mk2
-rw-r--r--chart2/source/model/model.map8
-rw-r--r--chart2/source/model/template/AreaChartTypeTemplate.cxx40
-rw-r--r--chart2/source/model/template/BarChartTypeTemplate.cxx29
-rw-r--r--chart2/source/model/template/BubbleChartTypeTemplate.cxx11
-rw-r--r--chart2/source/model/template/BubbleChartTypeTemplate.hxx4
-rw-r--r--chart2/source/model/template/BubbleDataInterpreter.cxx14
-rw-r--r--chart2/source/model/template/ChartTypeTemplate.cxx39
-rw-r--r--chart2/source/model/template/ChartTypeTemplate.hxx6
-rw-r--r--chart2/source/model/template/ColumnLineChartTypeTemplate.cxx7
-rw-r--r--chart2/source/model/template/DataInterpreter.cxx36
-rw-r--r--chart2/source/model/template/PieChartTypeTemplate.cxx12
-rw-r--r--chart2/source/model/template/ScatterChartTypeTemplate.cxx12
-rw-r--r--chart2/source/model/template/ScatterChartTypeTemplate.hxx4
-rw-r--r--chart2/source/model/template/StockChartTypeTemplate.cxx11
-rw-r--r--chart2/source/model/template/StockDataInterpreter.cxx5
-rw-r--r--chart2/source/model/template/XYDataInterpreter.cxx13
-rw-r--r--chart2/source/tools/AxisHelper.cxx20
-rw-r--r--chart2/source/tools/ChartModelHelper.cxx45
-rw-r--r--chart2/source/tools/ChartTypeHelper.cxx41
-rw-r--r--chart2/source/tools/DataSeriesHelper.cxx2
-rw-r--r--chart2/source/tools/DataSourceHelper.cxx38
-rw-r--r--chart2/source/tools/DiagramHelper.cxx74
-rw-r--r--chart2/source/tools/ExplicitCategoriesProvider.cxx367
-rw-r--r--chart2/source/tools/InternalData.cxx530
-rw-r--r--chart2/source/tools/InternalDataProvider.cxx1430
-rw-r--r--chart2/source/tools/LineProperties.cxx2
-rw-r--r--chart2/source/tools/ObjectIdentifier.cxx158
-rw-r--r--chart2/source/tools/RangeHighlighter.cxx114
-rw-r--r--chart2/source/tools/WrappedIgnoreProperty.cxx2
-rw-r--r--chart2/source/tools/makefile.mk4
-rw-r--r--chart2/source/tools/tools.map8
-rw-r--r--chart2/source/view/axes/TickmarkHelper.cxx109
-rw-r--r--chart2/source/view/axes/TickmarkHelper.hxx39
-rw-r--r--chart2/source/view/axes/VAxisBase.cxx51
-rw-r--r--chart2/source/view/axes/VAxisBase.hxx3
-rw-r--r--chart2/source/view/axes/VAxisProperties.cxx29
-rw-r--r--chart2/source/view/axes/VAxisProperties.hxx14
-rw-r--r--chart2/source/view/axes/VCartesianAxis.cxx619
-rw-r--r--chart2/source/view/axes/VCartesianAxis.hxx19
-rw-r--r--chart2/source/view/axes/VCartesianCoordinateSystem.cxx10
-rw-r--r--chart2/source/view/axes/VCoordinateSystem.cxx10
-rw-r--r--chart2/source/view/axes/VPolarAngleAxis.cxx9
-rw-r--r--chart2/source/view/axes/VPolarAngleAxis.hxx2
-rw-r--r--chart2/source/view/axes/VPolarGrid.cxx2
-rw-r--r--chart2/source/view/axes/VPolarRadiusAxis.cxx3
-rw-r--r--chart2/source/view/charttypes/AreaChart.cxx19
-rw-r--r--chart2/source/view/charttypes/AreaChart.hxx3
-rwxr-xr-x[-rw-r--r--]chart2/source/view/charttypes/BarChart.cxx22
-rw-r--r--chart2/source/view/charttypes/VSeriesPlotter.cxx39
-rw-r--r--chart2/source/view/diagram/VDiagram.cxx83
-rw-r--r--chart2/source/view/inc/PropertyMapper.hxx5
-rw-r--r--chart2/source/view/inc/ShapeFactory.hxx11
-rw-r--r--chart2/source/view/inc/Stripe.hxx14
-rw-r--r--chart2/source/view/inc/VCoordinateSystem.hxx11
-rw-r--r--chart2/source/view/inc/VSeriesPlotter.hxx8
-rw-r--r--chart2/source/view/inc/ViewDefines.hxx1
-rw-r--r--chart2/source/view/main/ChartView.cxx217
-rw-r--r--chart2/source/view/main/ChartView.hxx21
-rw-r--r--chart2/source/view/main/DrawModelWrapper.cxx73
-rw-r--r--chart2/source/view/main/PropertyMapper.cxx10
-rw-r--r--chart2/source/view/main/ShapeFactory.cxx425
-rw-r--r--chart2/source/view/main/Stripe.cxx161
-rw-r--r--chart2/source/view/main/VDataSeries.cxx4
-rw-r--r--chart2/source/view/main/VLegend.cxx108
-rw-r--r--chart2/source/view/main/VLegendSymbolFactory.cxx14
-rw-r--r--chart2/source/view/main/VTitle.cxx15
-rw-r--r--chart2/source/view/view.map9
-rw-r--r--chart2/uiconfig/toolbar/arrowshapes.xml34
-rw-r--r--chart2/uiconfig/toolbar/basicshapes.xml29
-rw-r--r--chart2/uiconfig/toolbar/calloutshapes.xml11
-rw-r--r--chart2/uiconfig/toolbar/drawbar.xml20
-rw-r--r--chart2/uiconfig/toolbar/flowchartshapes.xml36
-rw-r--r--chart2/uiconfig/toolbar/starshapes.xml17
-rw-r--r--chart2/uiconfig/toolbar/symbolshapes.xml24
-rw-r--r--sc/addin/datefunc/makefile.mk4
-rw-r--r--sc/addin/makefile.mk5
-rw-r--r--sc/addin/rot13/exports.map2
-rw-r--r--sc/addin/rot13/makefile.mk5
-rw-r--r--sc/addin/util/makefile.mk4
-rw-r--r--sc/inc/attarray.hxx2
-rw-r--r--sc/inc/chart2uno.hxx18
-rw-r--r--sc/inc/charthelper.hxx13
-rw-r--r--sc/inc/chgtrack.hxx2
-rw-r--r--sc/inc/collect.hxx14
-rw-r--r--sc/inc/column.hxx6
-rw-r--r--sc/inc/dapiuno.hxx19
-rw-r--r--sc/inc/document.hxx49
-rw-r--r--sc/inc/dpcachetable.hxx134
-rwxr-xr-xsc/inc/dpglobal.hxx209
-rw-r--r--sc/inc/dpgroup.hxx52
-rw-r--r--sc/inc/dpobject.hxx42
-rw-r--r--sc/inc/dpsave.hxx19
-rw-r--r--sc/inc/dpsdbtab.hxx20
-rw-r--r--sc/inc/dpshttab.hxx33
-rw-r--r--sc/inc/dptabdat.hxx81
-rw-r--r--sc/inc/dptablecache.hxx122
-rw-r--r--sc/inc/dptabres.hxx261
-rw-r--r--sc/inc/dptabsrc.hxx53
-rw-r--r--sc/inc/drwlayer.hxx8
-rw-r--r--sc/inc/externalrefmgr.hxx13
-rw-r--r--sc/inc/filter.hxx8
-rw-r--r--sc/inc/global.hxx78
-rw-r--r--sc/inc/globstr.hrc10
-rw-r--r--sc/inc/hints.hxx12
-rw-r--r--sc/inc/optutil.hxx7
-rw-r--r--sc/inc/pivot.hxx1
-rw-r--r--sc/inc/rangelst.hxx6
-rw-r--r--sc/inc/sc.hrc9
-rw-r--r--sc/inc/scabstdlg.hxx12
-rw-r--r--sc/inc/scimpexpmsg.hxx105
-rw-r--r--sc/inc/scmatrix.hxx7
-rw-r--r--sc/inc/stringutil.hxx56
-rw-r--r--sc/inc/table.hxx19
-rw-r--r--sc/inc/unonames.hxx9
-rwxr-xr-xsc/prj/build.lst1
-rw-r--r--sc/qa/unoapi/Test.java51
-rw-r--r--sc/qa/unoapi/knownissues.xcl28
-rw-r--r--sc/qa/unoapi/makefile.mk30
-rw-r--r--sc/source/core/data/attarray.cxx40
-rw-r--r--sc/source/core/data/column.cxx2
-rw-r--r--sc/source/core/data/column3.cxx103
-rw-r--r--[-rwxr-xr-x]sc/source/core/data/dociter.cxx6
-rw-r--r--sc/source/core/data/documen3.cxx127
-rw-r--r--sc/source/core/data/documen5.cxx414
-rw-r--r--sc/source/core/data/documen9.cxx86
-rw-r--r--sc/source/core/data/document.cxx35
-rw-r--r--sc/source/core/data/dpcachetable.cxx534
-rwxr-xr-xsc/source/core/data/dpglobal.cxx150
-rw-r--r--sc/source/core/data/dpgroup.cxx655
-rwxr-xr-x[-rw-r--r--]sc/source/core/data/dpobject.cxx240
-rwxr-xr-x[-rw-r--r--]sc/source/core/data/dpoutput.cxx154
-rw-r--r--sc/source/core/data/dpsave.cxx335
-rw-r--r--sc/source/core/data/dpsdbtab.cxx243
-rwxr-xr-x[-rw-r--r--]sc/source/core/data/dpshttab.cxx224
-rwxr-xr-x[-rw-r--r--]sc/source/core/data/dptabdat.cxx194
-rwxr-xr-xsc/source/core/data/dptablecache.cxx1093
-rwxr-xr-x[-rw-r--r--]sc/source/core/data/dptabres.cxx704
-rw-r--r--sc/source/core/data/dptabresmember.cxx831
-rw-r--r--sc/source/core/data/dptabresmember.hxx161
-rwxr-xr-x[-rw-r--r--]sc/source/core/data/dptabsrc.cxx202
-rwxr-xr-x[-rw-r--r--]sc/source/core/data/drwlayer.cxx225
-rw-r--r--sc/source/core/data/global2.cxx92
-rwxr-xr-x[-rw-r--r--]sc/source/core/data/makefile.mk10
-rw-r--r--sc/source/core/data/scdpoutputimpl.cxx187
-rwxr-xr-xsc/source/core/data/scdpoutputimpl.hxx79
-rw-r--r--sc/source/core/data/scimpexpmsg.cxx113
-rw-r--r--sc/source/core/data/table1.cxx148
-rw-r--r--sc/source/core/data/table2.cxx90
-rw-r--r--sc/source/core/inc/core_pch.hxx1
-rw-r--r--sc/source/core/tool/address.cxx4
-rw-r--r--sc/source/core/tool/charthelper.cxx195
-rw-r--r--sc/source/core/tool/collect.cxx18
-rw-r--r--sc/source/core/tool/doubleref.cxx4
-rw-r--r--sc/source/core/tool/hints.cxx10
-rw-r--r--sc/source/core/tool/interpr1.cxx4
-rw-r--r--[-rwxr-xr-x]sc/source/core/tool/interpr4.cxx2
-rw-r--r--sc/source/core/tool/makefile.mk3
-rw-r--r--sc/source/core/tool/optutil.cxx4
-rw-r--r--sc/source/core/tool/rangelst.cxx36
-rw-r--r--sc/source/core/tool/scmatrix.cxx13
-rw-r--r--sc/source/core/tool/stringutil.cxx131
-rw-r--r--sc/source/filter/excel/excdoc.cxx36
-rw-r--r--sc/source/filter/excel/excform.cxx6
-rw-r--r--sc/source/filter/excel/excform8.cxx5
-rw-r--r--sc/source/filter/excel/excrecds.cxx5
-rw-r--r--sc/source/filter/excel/exctools.cxx3
-rw-r--r--sc/source/filter/excel/expop2.cxx7
-rw-r--r--sc/source/filter/excel/impop.cxx2
-rw-r--r--sc/source/filter/excel/makefile.mk1
-rw-r--r--sc/source/filter/excel/read.cxx31
-rw-r--r--sc/source/filter/excel/tokstack.cxx5
-rw-r--r--sc/source/filter/excel/xechart.cxx60
-rw-r--r--sc/source/filter/excel/xeescher.cxx367
-rw-r--r--sc/source/filter/excel/xelink.cxx427
-rw-r--r--sc/source/filter/excel/xepivot.cxx17
-rw-r--r--sc/source/filter/excel/xerecord.cxx15
-rw-r--r--sc/source/filter/excel/xeroot.cxx13
-rw-r--r--sc/source/filter/excel/xichart.cxx177
-rw-r--r--sc/source/filter/excel/xicontent.cxx26
-rw-r--r--sc/source/filter/excel/xiescher.cxx1013
-rw-r--r--sc/source/filter/excel/xihelper.cxx4
-rw-r--r--sc/source/filter/excel/xilink.cxx12
-rw-r--r--sc/source/filter/excel/xipage.cxx2
-rw-r--r--sc/source/filter/excel/xipivot.cxx2
-rw-r--r--sc/source/filter/excel/xiroot.cxx6
-rw-r--r--sc/source/filter/excel/xistyle.cxx67
-rw-r--r--sc/source/filter/excel/xlchart.cxx10
-rw-r--r--sc/source/filter/excel/xlescher.cxx58
-rw-r--r--sc/source/filter/excel/xlformula.cxx184
-rw-r--r--sc/source/filter/excel/xltools.cxx108
-rw-r--r--sc/source/filter/html/htmlimp.cxx10
-rw-r--r--sc/source/filter/inc/eeimport.hxx4
-rw-r--r--sc/source/filter/inc/ftools.hxx4
-rw-r--r--sc/source/filter/inc/htmlimp.hxx3
-rw-r--r--sc/source/filter/inc/root.hxx7
-rw-r--r--sc/source/filter/inc/tokstack.hxx2
-rw-r--r--sc/source/filter/inc/xcl97esc.hxx205
-rw-r--r--sc/source/filter/inc/xcl97rec.hxx118
-rw-r--r--sc/source/filter/inc/xechart.hxx22
-rw-r--r--sc/source/filter/inc/xeescher.hxx206
-rw-r--r--sc/source/filter/inc/xerecord.hxx3
-rw-r--r--sc/source/filter/inc/xeroot.hxx5
-rw-r--r--sc/source/filter/inc/xichart.hxx44
-rw-r--r--sc/source/filter/inc/xiescher.hxx327
-rw-r--r--sc/source/filter/inc/xihelper.hxx6
-rw-r--r--sc/source/filter/inc/xiroot.hxx3
-rw-r--r--sc/source/filter/inc/xistyle.hxx5
-rw-r--r--sc/source/filter/inc/xlchart.hxx3
-rw-r--r--sc/source/filter/inc/xlescher.hxx13
-rw-r--r--sc/source/filter/inc/xltools.hxx2
-rw-r--r--sc/source/filter/rtf/eeimpars.cxx14
-rw-r--r--sc/source/filter/xcl97/xcl97esc.cxx354
-rw-r--r--sc/source/filter/xcl97/xcl97rec.cxx291
-rw-r--r--sc/source/filter/xml/xmldpimp.cxx3
-rw-r--r--sc/source/ui/Accessibility/AccessibleDocument.cxx18
-rw-r--r--sc/source/ui/app/inputwin.cxx5
-rw-r--r--sc/source/ui/attrdlg/scdlgfact.cxx36
-rw-r--r--sc/source/ui/attrdlg/scdlgfact.hxx11
-rw-r--r--sc/source/ui/dbgui/asciiopt.cxx50
-rw-r--r--sc/source/ui/dbgui/asciiopt.hrc71
-rw-r--r--sc/source/ui/dbgui/asciiopt.src230
-rw-r--r--sc/source/ui/dbgui/csvgrid.cxx3
-rw-r--r--sc/source/ui/dbgui/csvruler.cxx76
-rw-r--r--sc/source/ui/dbgui/dapidata.cxx2
-rw-r--r--sc/source/ui/dbgui/makefile.mk2
-rw-r--r--sc/source/ui/dbgui/pvfundlg.cxx9
-rw-r--r--sc/source/ui/dbgui/pvfundlg.src4
-rw-r--r--sc/source/ui/dbgui/scuiasciiopt.cxx217
-rw-r--r--sc/source/ui/dbgui/textimportoptions.cxx121
-rw-r--r--sc/source/ui/dbgui/textimportoptions.src112
-rw-r--r--sc/source/ui/docshell/dbdocfun.cxx10
-rw-r--r--sc/source/ui/docshell/dbdocimp.cxx6
-rw-r--r--sc/source/ui/docshell/docsh.cxx63
-rw-r--r--sc/source/ui/docshell/docsh3.cxx10
-rw-r--r--sc/source/ui/docshell/docsh4.cxx5
-rw-r--r--sc/source/ui/docshell/docsh5.cxx37
-rw-r--r--sc/source/ui/docshell/externalrefmgr.cxx50
-rw-r--r--sc/source/ui/docshell/impex.cxx84
-rw-r--r--sc/source/ui/drawfunc/drawsh.cxx2
-rw-r--r--sc/source/ui/drawfunc/fudraw.cxx2
-rw-r--r--sc/source/ui/drawfunc/fuins2.cxx3
-rw-r--r--sc/source/ui/drawfunc/fusel.cxx2
-rw-r--r--sc/source/ui/formdlg/formula.cxx5
-rw-r--r--sc/source/ui/inc/asciiopt.hxx11
-rw-r--r--sc/source/ui/inc/csvruler.hxx1
-rw-r--r--sc/source/ui/inc/dbfunc.hxx10
-rw-r--r--sc/source/ui/inc/docsh.hxx9
-rwxr-xr-x[-rw-r--r--]sc/source/ui/inc/fieldwnd.hxx1
-rw-r--r--sc/source/ui/inc/gridwin.hxx2
-rw-r--r--sc/source/ui/inc/hdrcont.hxx2
-rw-r--r--sc/source/ui/inc/impex.hxx2
-rw-r--r--sc/source/ui/inc/scuiasciiopt.hxx12
-rw-r--r--sc/source/ui/inc/textimportoptions.hrc (renamed from sc/source/core/data/pivot.cxx)20
-rw-r--r--sc/source/ui/inc/textimportoptions.hxx76
-rw-r--r--sc/source/ui/inc/ui_pch.hxx1
-rw-r--r--sc/source/ui/miscdlgs/anyrefdg.cxx7
-rw-r--r--sc/source/ui/miscdlgs/autofmt.cxx2
-rw-r--r--sc/source/ui/miscdlgs/scuiautofmt.cxx2
-rw-r--r--sc/source/ui/miscdlgs/strindlg.cxx10
-rw-r--r--sc/source/ui/src/globstr.src14
-rw-r--r--sc/source/ui/src/miscdlgs.src8
-rw-r--r--sc/source/ui/undo/makefile.mk2
-rw-r--r--sc/source/ui/undo/undodat.cxx7
-rw-r--r--sc/source/ui/unoobj/cellsuno.cxx22
-rw-r--r--sc/source/ui/unoobj/chart2uno.cxx1714
-rw-r--r--sc/source/ui/unoobj/chartuno.cxx15
-rw-r--r--sc/source/ui/unoobj/cursuno.cxx6
-rwxr-xr-x[-rw-r--r--]sc/source/ui/unoobj/dapiuno.cxx267
-rw-r--r--sc/source/ui/unoobj/dispuno.cxx7
-rw-r--r--sc/source/ui/unoobj/filtuno.cxx35
-rw-r--r--sc/source/ui/unoobj/unodoc.cxx4
-rw-r--r--sc/source/ui/vba/vbahelper.cxx2
-rw-r--r--sc/source/ui/vba/vbawindow.cxx42
-rw-r--r--sc/source/ui/view/cellsh.cxx26
-rw-r--r--sc/source/ui/view/cellsh1.cxx2
-rw-r--r--sc/source/ui/view/cellsh2.cxx4
-rw-r--r--sc/source/ui/view/cellsh3.cxx4
-rw-r--r--sc/source/ui/view/dbfunc.cxx73
-rwxr-xr-x[-rw-r--r--]sc/source/ui/view/dbfunc3.cxx55
-rw-r--r--sc/source/ui/view/drawview.cxx17
-rw-r--r--sc/source/ui/view/gridwin.cxx58
-rw-r--r--sc/source/ui/view/hdrcont.cxx61
-rw-r--r--sc/source/ui/view/makefile.mk3
-rw-r--r--sc/source/ui/view/prevwsh.cxx3
-rw-r--r--sc/source/ui/view/spelldialog.cxx7
-rw-r--r--sc/source/ui/view/tabview.cxx19
-rw-r--r--sc/source/ui/view/tabview3.cxx16
-rw-r--r--sc/source/ui/view/tabview5.cxx14
-rw-r--r--sc/source/ui/view/tabvwsh2.cxx2
-rw-r--r--sc/source/ui/view/tabvwsh3.cxx8
-rw-r--r--sc/source/ui/view/tabvwsh4.cxx36
-rw-r--r--sc/source/ui/view/tabvwsha.cxx2
-rw-r--r--sc/source/ui/view/tabvwshb.cxx2
-rw-r--r--sc/source/ui/view/tabvwshc.cxx4
-rw-r--r--sc/source/ui/view/tabvwshd.cxx2
-rw-r--r--sc/source/ui/view/viewfun2.cxx6
-rw-r--r--sc/source/ui/view/viewfun5.cxx2
-rw-r--r--sc/source/ui/view/viewutil.cxx2
-rw-r--r--sc/util/hidother.src1
-rw-r--r--sc/util/makefile.mk5
-rw-r--r--sc/util/sc.map8
-rw-r--r--sc/util/scd.map8
-rw-r--r--sc/util/scfilt.map2
-rw-r--r--sc/util/scui.map2
-rw-r--r--sc/util/vbaobj.map9
-rw-r--r--scaddins/source/analysis/exports.map10
-rw-r--r--scaddins/source/analysis/makefile.mk2
-rw-r--r--scaddins/source/datefunc/exports.map10
-rw-r--r--scaddins/source/datefunc/makefile.mk2
-rw-r--r--sccomp/source/solver/exports.map9
-rw-r--r--sccomp/source/solver/makefile.mk2
425 files changed, 21795 insertions, 11291 deletions
diff --git a/chart2/prj/build.lst b/chart2/prj/build.lst
index 8a76f4a0513b..370eacebe0c2 100644
--- a/chart2/prj/build.lst
+++ b/chart2/prj/build.lst
@@ -14,7 +14,7 @@ ch chart2\source\view\axes nmake - all ch_source_view_axes ch_source_tools
ch chart2\source\view\charttypes nmake - all ch_source_view_charttypes ch_inc NULL
ch chart2\source\view\diagram nmake - all ch_source_view_diagram ch_inc NULL
ch chart2\source\view\main nmake - all ch_source_view_main ch_inc NULL
-ch chart2\source\controller nmake - all ch_source_controller ch_source_tools ch_source_view ch_source_controller_drawinglayer ch_source_controller_itemsetwrapper ch_source_controller_dialogs ch_source_controller_main ch_source_controller_chartapiwrapper ch_source_controller_accessibility ch_inc NULL
+ch chart2\source\controller nmake - all ch_source_controller ch_source_tools ch_source_view ch_source_controller_drawinglayer ch_source_controller_itemsetwrapper ch_source_controller_dialogs ch_source_controller_main ch_source_controller_chartapiwrapper ch_source_controller_accessibility ch_inc ch_source_controller_menus NULL
ch chart2\source\controller\inc get - all ch_source_controller_inc NULL
ch chart2\source\controller\accessibility nmake - all ch_source_controller_accessibility ch_inc NULL
ch chart2\source\controller\dialogs nmake - all ch_source_controller_dialogs ch_inc NULL
@@ -22,4 +22,6 @@ ch chart2\source\controller\drawinglayer nmake - all ch_source_controller_drawi
ch chart2\source\controller\itemsetwrapper nmake - all ch_source_controller_itemsetwrapper ch_inc NULL
ch chart2\source\controller\chartapiwrapper nmake - all ch_source_controller_chartapiwrapper ch_inc NULL
ch chart2\source\controller\main nmake - all ch_source_controller_main ch_inc NULL
+ch chart2\source\controller\menus nmake - all ch_source_controller_menus ch_inc NULL
ch chart2\prj get - all ch_prj NULL
+ch chart2\qa\unoapi nmake - all ch_qa_unoapi NULL
diff --git a/chart2/qa/unoapi/Test.java b/chart2/qa/unoapi/Test.java
new file mode 100644
index 000000000000..c1b6fd05983d
--- /dev/null
+++ b/chart2/qa/unoapi/Test.java
@@ -0,0 +1,51 @@
+/*************************************************************************
+* 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.
+************************************************************************/
+
+package org.openoffice.chart2.qa.unoapi;
+
+import org.openoffice.Runner;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+
+public final class Test {
+ @org.junit.Before public void setUp() throws Exception {
+ connection.setUp();
+ }
+
+ @org.junit.After public void tearDown()
+ throws InterruptedException, com.sun.star.uno.Exception
+ {
+ connection.tearDown();
+ }
+
+ @org.junit.Test public void test() {
+ assertTrue(
+ Runner.run(
+ "-sce", "sch.sce", "-xcl", "knownissues.xcl", "-tdoc",
+ "testdocuments", "-cs", connection.getDescription()));
+ }
+
+ private final OfficeConnection connection = new OfficeConnection();
+}
diff --git a/chart2/qa/unoapi/makefile.mk b/chart2/qa/unoapi/makefile.mk
index 517327aab0bf..de494ead5449 100644
--- a/chart2/qa/unoapi/makefile.mk
+++ b/chart2/qa/unoapi/makefile.mk
@@ -1,7 +1,6 @@
#*************************************************************************
-#
# 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
@@ -22,21 +21,28 @@
# version 3 along with OpenOffice.org. If not, see
# <http://www.openoffice.org/license.html>
# for a copy of the LGPLv3 License.
-#
-#*************************************************************************
+#***********************************************************************/
-EXTERNAL_WARNINGS_NOT_ERRORS := TRUE
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
+.ELSE
-PRJ=..$/..
+PRJ = ../..
+PRJNAME = chart2
+TARGET = qa_unoapi
-PRJNAME=sch
-TARGET=qa_unoapi
+.IF "$(OOO_JUNIT_JAR)" != ""
+PACKAGE = org/openoffice/chart2/qa/unoapi
+JAVATESTFILES = Test.java
+JAVAFILES = $(JAVATESTFILES)
+JARFILES = OOoRunner.jar ridl.jar test.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
+.END
.INCLUDE: settings.mk
-
.INCLUDE: target.mk
+.INCLUDE: installationtest.mk
-ALLTAR : UNOAPI_TEST
+ALLTAR : javatest
-UNOAPI_TEST:
- +$(SOLARENV)$/bin$/checkapi -sce sch.sce -xcl knownissues.xcl -tdoc $(PWD)$/testdocuments
+.END
diff --git a/chart2/source/controller/accessibility/AccessibleBase.cxx b/chart2/source/controller/accessibility/AccessibleBase.cxx
index cab7d3db0d62..00335eab296e 100644
--- a/chart2/source/controller/accessibility/AccessibleBase.cxx
+++ b/chart2/source/controller/accessibility/AccessibleBase.cxx
@@ -29,6 +29,7 @@
#include "precompiled_chart2.hxx"
#include "AccessibleBase.hxx"
+#include "AccessibleChartShape.hxx"
#include "ObjectHierarchy.hxx"
#include "ObjectIdentifier.hxx"
#include "chartview/ExplicitValueProvider.hxx"
@@ -269,15 +270,15 @@ bool AccessibleBase::ImplUpdateChildren()
{
ObjectHierarchy::tChildContainer aModelChildren(
m_aAccInfo.m_spObjectHierarchy->getChildren( GetId() ));
- ::std::vector< ChildCIDMap::key_type > aAccChildren;
+ ::std::vector< ChildOIDMap::key_type > aAccChildren;
aAccChildren.reserve( aModelChildren.size());
- ::std::transform( m_aChildCIDMap.begin(), m_aChildCIDMap.end(),
+ ::std::transform( m_aChildOIDMap.begin(), m_aChildOIDMap.end(),
::std::back_inserter( aAccChildren ),
- ::std::select1st< ChildCIDMap::value_type >());
+ ::std::select1st< ChildOIDMap::value_type >());
::std::sort( aModelChildren.begin(), aModelChildren.end());
- ::std::vector< OUString > aChildrenToRemove, aChildrenToAdd;
+ ::std::vector< ObjectHierarchy::tOID > aChildrenToRemove, aChildrenToAdd;
::std::set_difference( aModelChildren.begin(), aModelChildren.end(),
aAccChildren.begin(), aAccChildren.end(),
::std::back_inserter( aChildrenToAdd ));
@@ -285,10 +286,10 @@ bool AccessibleBase::ImplUpdateChildren()
aModelChildren.begin(), aModelChildren.end(),
::std::back_inserter( aChildrenToRemove ));
- ::std::vector< OUString >::const_iterator aIt( aChildrenToRemove.begin());
+ ::std::vector< ObjectHierarchy::tOID >::const_iterator aIt( aChildrenToRemove.begin());
for( ; aIt != aChildrenToRemove.end(); ++aIt )
{
- RemoveChildById( *aIt );
+ RemoveChildByOId( *aIt );
}
AccessibleElementInfo aAccInfo( GetInfo());
@@ -296,8 +297,15 @@ bool AccessibleBase::ImplUpdateChildren()
for( aIt = aChildrenToAdd.begin(); aIt != aChildrenToAdd.end(); ++aIt )
{
- aAccInfo.m_aCID = *aIt;
- AddChild( ChartElementFactory::CreateChartElement( aAccInfo ));
+ aAccInfo.m_aOID = *aIt;
+ if ( aIt->isAutoGeneratedObject() )
+ {
+ AddChild( ChartElementFactory::CreateChartElement( aAccInfo ) );
+ }
+ else if ( aIt->isAdditionalShape() )
+ {
+ AddChild( new AccessibleChartShape( aAccInfo, true, false ) );
+ }
}
bResult = true;
}
@@ -316,7 +324,7 @@ void AccessibleBase::AddChild( AccessibleBase * pChild )
Reference< XAccessible > xChild( pChild );
m_aChildList.push_back( xChild );
- m_aChildCIDMap[ pChild->GetId() ] = xChild;
+ m_aChildOIDMap[ pChild->GetId() ] = xChild;
// inform listeners of new child
if( m_bChildrenInitialized )
@@ -335,18 +343,18 @@ void AccessibleBase::AddChild( AccessibleBase * pChild )
/** in this method we imply that the Reference< XAccessible > elements in the
vector are AccessibleBase objects !
*/
-void AccessibleBase::RemoveChildById( const ::rtl::OUString & rId )
+void AccessibleBase::RemoveChildByOId( const ObjectIdentifier& rOId )
{
// /--
ClearableMutexGuard aGuard( GetMutex() );
- ChildCIDMap::iterator aIt( m_aChildCIDMap.find( rId ));
- if( aIt != m_aChildCIDMap.end())
+ ChildOIDMap::iterator aIt( m_aChildOIDMap.find( rOId ));
+ if( aIt != m_aChildOIDMap.end())
{
Reference< XAccessible > xChild( aIt->second );
// remove from map
- m_aChildCIDMap.erase( aIt );
+ m_aChildOIDMap.erase( aIt );
// search child in vector
ChildListVectorType::iterator aVecIter =
@@ -444,7 +452,7 @@ void AccessibleBase::KillAllChildren()
// remove all children
m_aChildList.clear();
- m_aChildCIDMap.clear();
+ m_aChildOIDMap.clear();
aGuard.clear();
// \--
@@ -485,7 +493,7 @@ void AccessibleBase::SetInfo( const AccessibleElementInfo & rNewInfo )
AccessibleUniqueId AccessibleBase::GetId() const
{
- return m_aAccInfo.m_aCID;
+ return m_aAccInfo.m_aOID;
}
// ____________________________________
@@ -662,14 +670,15 @@ Reference< XAccessibleStateSet > SAL_CALL AccessibleBase::getAccessibleStateSet(
{
if( ! m_bStateSetInitialized )
{
- OUString aSelCID;
Reference< view::XSelectionSupplier > xSelSupp( GetInfo().m_xSelectionSupplier );
- if( xSelSupp.is() &&
- ( xSelSupp->getSelection() >>= aSelCID ) &&
- GetId().equals( aSelCID ) )
+ if ( xSelSupp.is() )
{
- AddState( AccessibleStateType::SELECTED );
- AddState( AccessibleStateType::FOCUSED );
+ ObjectIdentifier aOID( xSelSupp->getSelection() );
+ if ( aOID.isValid() && GetId() == aOID )
+ {
+ AddState( AccessibleStateType::SELECTED );
+ AddState( AccessibleStateType::FOCUSED );
+ }
}
m_bStateSetInitialized = true;
}
@@ -752,7 +761,7 @@ awt::Rectangle SAL_CALL AccessibleBase::getBounds()
if( pExplicitValueProvider )
{
Window* pWindow( VCLUnoHelper::GetWindow( m_aAccInfo.m_xWindow ));
- awt::Rectangle aLogicRect( pExplicitValueProvider->getRectangleOfObject( m_aAccInfo.m_aCID ));
+ awt::Rectangle aLogicRect( pExplicitValueProvider->getRectangleOfObject( m_aAccInfo.m_aOID.getObjectCID() ));
if( pWindow )
{
Rectangle aRect( aLogicRect.X, aLogicRect.Y,
@@ -825,10 +834,11 @@ void SAL_CALL AccessibleBase::grabFocus()
{
CheckDisposeState();
- OUString aSelCID;
Reference< view::XSelectionSupplier > xSelSupp( GetInfo().m_xSelectionSupplier );
- if( xSelSupp.is())
- xSelSupp->select( uno::makeAny( GetId()));
+ if ( xSelSupp.is() )
+ {
+ xSelSupp->select( GetId().getAny() );
+ }
}
sal_Int32 SAL_CALL AccessibleBase::getForeground()
@@ -849,9 +859,10 @@ sal_Int32 AccessibleBase::getColor( eColorType eColType )
if( m_bAlwaysTransparent )
return nResult;
- ObjectType eType( ObjectIdentifier::getObjectType( m_aAccInfo.m_aCID ));
+ ObjectIdentifier aOID( m_aAccInfo.m_aOID );
+ ObjectType eType( aOID.getObjectType() );
Reference< beans::XPropertySet > xObjProp;
- OUString aObjectCID = m_aAccInfo.m_aCID;
+ OUString aObjectCID = aOID.getObjectCID();
if( eType == OBJECTTYPE_LEGEND_ENTRY )
{
// for colors get the data series/point properties
diff --git a/chart2/source/controller/accessibility/AccessibleChartElement.cxx b/chart2/source/controller/accessibility/AccessibleChartElement.cxx
index a2c7b7aa8261..2361cc62c389 100644
--- a/chart2/source/controller/accessibility/AccessibleChartElement.cxx
+++ b/chart2/source/controller/accessibility/AccessibleChartElement.cxx
@@ -101,7 +101,7 @@ bool AccessibleChartElement::ImplUpdateChildren()
bool bResult = false;
Reference< chart2::XTitle > xTitle(
ObjectIdentifier::getObjectPropertySet(
- GetInfo().m_aCID, Reference< chart2::XChartDocument >( GetInfo().m_xChartDocument )),
+ GetInfo().m_aOID.getObjectCID(), Reference< chart2::XChartDocument >( GetInfo().m_xChartDocument )),
uno::UNO_QUERY );
m_bHasText = xTitle.is();
@@ -136,7 +136,7 @@ void AccessibleChartElement::InitTextEdit()
{
Reference< lang::XInitialization > xInit( m_xTextHelper, uno::UNO_QUERY_THROW );
Sequence< uno::Any > aArgs( 3 );
- aArgs[0] <<= GetInfo().m_aCID;
+ aArgs[0] <<= GetInfo().m_aOID.getObjectCID();
aArgs[1] <<= Reference< XAccessible >( this );
aArgs[2] <<= Reference< awt::XWindow >( GetInfo().m_xWindow );
xInit->initialize( aArgs );
@@ -224,7 +224,7 @@ OUString SAL_CALL AccessibleChartElement::getAccessibleName()
throw (::com::sun::star::uno::RuntimeException)
{
return ObjectNameProvider::getNameForCID(
- GetInfo().m_aCID, GetInfo().m_xChartDocument );
+ GetInfo().m_aOID.getObjectCID(), GetInfo().m_xChartDocument );
}
// ________ AccessibleChartElement::XAccessibleContext (overloaded) ________
@@ -249,7 +249,7 @@ Reference< awt::XFont > SAL_CALL AccessibleChartElement::getFont()
{
Reference< beans::XMultiPropertySet > xObjProp(
ObjectIdentifier::getObjectPropertySet(
- GetInfo().m_aCID, Reference< chart2::XChartDocument >( GetInfo().m_xChartDocument )), uno::UNO_QUERY );
+ GetInfo().m_aOID.getObjectCID(), Reference< chart2::XChartDocument >( GetInfo().m_xChartDocument )), uno::UNO_QUERY );
awt::FontDescriptor aDescr(
CharacterProperties::createFontDescriptorFromPropertySet( xObjProp ));
xFont = xDevice->getFont( aDescr );
@@ -270,7 +270,7 @@ OUString SAL_CALL AccessibleChartElement::getToolTipText()
CheckDisposeState();
return ObjectNameProvider::getHelpText(
- GetInfo().m_aCID, Reference< chart2::XChartDocument >( GetInfo().m_xChartDocument ));
+ GetInfo().m_aOID.getObjectCID(), Reference< chart2::XChartDocument >( GetInfo().m_xChartDocument ));
}
// ________ XAccessibleComponent ________
@@ -280,7 +280,7 @@ sal_Bool SAL_CALL AccessibleChartElement::containsPoint( const awt::Point& aPoin
return AccessibleBase::containsPoint( aPoint );
}
-Reference< accessibility::XAccessible > SAL_CALL AccessibleChartElement::getAccessibleAtPoint( const awt::Point& aPoint )
+Reference< XAccessible > SAL_CALL AccessibleChartElement::getAccessibleAtPoint( const awt::Point& aPoint )
throw (uno::RuntimeException)
{
return AccessibleBase::getAccessibleAtPoint( aPoint );
diff --git a/chart2/source/controller/accessibility/AccessibleChartShape.cxx b/chart2/source/controller/accessibility/AccessibleChartShape.cxx
new file mode 100644
index 000000000000..bbf6176641da
--- /dev/null
+++ b/chart2/source/controller/accessibility/AccessibleChartShape.cxx
@@ -0,0 +1,289 @@
+/*************************************************************************
+ *
+ * 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 "AccessibleChartShape.hxx"
+#include "ObjectHierarchy.hxx"
+#include "ObjectIdentifier.hxx"
+
+#include <toolkit/helper/vclunohelper.hxx>
+#include <svx/ShapeTypeHandler.hxx>
+#include <svx/AccessibleShape.hxx>
+#include <svx/AccessibleShapeInfo.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::RuntimeException;
+
+
+namespace chart
+{
+
+AccessibleChartShape::AccessibleChartShape(
+ const AccessibleElementInfo& rAccInfo,
+ bool bMayHaveChildren, bool bAlwaysTransparent )
+ :impl::AccessibleChartShape_Base( rAccInfo, bMayHaveChildren, bAlwaysTransparent )
+ ,m_pAccShape( NULL )
+{
+ if ( rAccInfo.m_aOID.isAdditionalShape() )
+ {
+ Reference< drawing::XShape > xShape( rAccInfo.m_aOID.getAdditionalShape() );
+ Reference< XAccessible > xParent;
+ if ( rAccInfo.m_pParent )
+ {
+ xParent.set( rAccInfo.m_pParent );
+ }
+ sal_Int32 nIndex = -1;
+ if ( rAccInfo.m_spObjectHierarchy )
+ {
+ nIndex = rAccInfo.m_spObjectHierarchy->getIndexInParent( rAccInfo.m_aOID );
+ }
+ ::accessibility::AccessibleShapeInfo aShapeInfo( xShape, xParent, nIndex );
+
+ m_aShapeTreeInfo.SetSdrView( rAccInfo.m_pSdrView );
+ m_aShapeTreeInfo.SetController( NULL );
+ m_aShapeTreeInfo.SetWindow( VCLUnoHelper::GetWindow( rAccInfo.m_xWindow ) );
+ m_aShapeTreeInfo.SetViewForwarder( rAccInfo.m_pViewForwarder );
+
+ ::accessibility::ShapeTypeHandler& rShapeHandler = ::accessibility::ShapeTypeHandler::Instance();
+ m_pAccShape = rShapeHandler.CreateAccessibleObject( aShapeInfo, m_aShapeTreeInfo );
+ if ( m_pAccShape )
+ {
+ m_pAccShape->acquire();
+ m_pAccShape->Init();
+ }
+ }
+}
+
+AccessibleChartShape::~AccessibleChartShape()
+{
+ OSL_ASSERT( CheckDisposeState( false /* don't throw exceptions */ ) );
+
+ if ( m_pAccShape )
+ {
+ m_pAccShape->dispose();
+ m_pAccShape->release();
+ }
+}
+
+// ________ XServiceInfo ________
+::rtl::OUString AccessibleChartShape::getImplementationName()
+ throw (RuntimeException)
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AccessibleChartShape" ) );
+}
+
+// ________ XAccessibleContext ________
+sal_Int32 AccessibleChartShape::getAccessibleChildCount()
+ throw (RuntimeException)
+{
+ sal_Int32 nCount(0);
+ if ( m_pAccShape )
+ {
+ nCount = m_pAccShape->getAccessibleChildCount();
+ }
+ return nCount;
+}
+
+Reference< XAccessible > AccessibleChartShape::getAccessibleChild( sal_Int32 i )
+ throw (lang::IndexOutOfBoundsException, RuntimeException)
+{
+ Reference< XAccessible > xChild;
+ if ( m_pAccShape )
+ {
+ xChild = m_pAccShape->getAccessibleChild( i );
+ }
+ return xChild;
+}
+
+sal_Int16 AccessibleChartShape::getAccessibleRole()
+ throw (RuntimeException)
+{
+ sal_Int16 nRole(0);
+ if ( m_pAccShape )
+ {
+ nRole = m_pAccShape->getAccessibleRole();
+ }
+ return nRole;
+}
+
+::rtl::OUString AccessibleChartShape::getAccessibleDescription()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ ::rtl::OUString aDescription;
+ if ( m_pAccShape )
+ {
+ aDescription = m_pAccShape->getAccessibleDescription();
+ }
+ return aDescription;
+}
+
+::rtl::OUString AccessibleChartShape::getAccessibleName()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ ::rtl::OUString aName;
+ if ( m_pAccShape )
+ {
+ aName = m_pAccShape->getAccessibleName();
+ }
+ return aName;
+}
+
+// ________ XAccessibleComponent ________
+sal_Bool AccessibleChartShape::containsPoint( const awt::Point& aPoint )
+ throw (uno::RuntimeException)
+{
+ sal_Bool bReturn = sal_False;
+ if ( m_pAccShape )
+ {
+ bReturn = m_pAccShape->containsPoint( aPoint );
+ }
+ return bReturn;
+}
+
+Reference< XAccessible > AccessibleChartShape::getAccessibleAtPoint( const awt::Point& aPoint )
+ throw (uno::RuntimeException)
+{
+ Reference< XAccessible > xResult;
+ if ( m_pAccShape )
+ {
+ xResult.set( m_pAccShape->getAccessibleAtPoint( aPoint ) );
+ }
+ return xResult;
+}
+
+awt::Rectangle AccessibleChartShape::getBounds()
+ throw (uno::RuntimeException)
+{
+ awt::Rectangle aBounds;
+ if ( m_pAccShape )
+ {
+ aBounds = m_pAccShape->getBounds();
+ }
+ return aBounds;
+}
+
+awt::Point AccessibleChartShape::getLocation()
+ throw (uno::RuntimeException)
+{
+ awt::Point aLocation;
+ if ( m_pAccShape )
+ {
+ aLocation = m_pAccShape->getLocation();
+ }
+ return aLocation;
+}
+
+awt::Point AccessibleChartShape::getLocationOnScreen()
+ throw (uno::RuntimeException)
+{
+ awt::Point aLocation;
+ if ( m_pAccShape )
+ {
+ aLocation = m_pAccShape->getLocationOnScreen();
+ }
+ return aLocation;
+}
+
+awt::Size AccessibleChartShape::getSize()
+ throw (uno::RuntimeException)
+{
+ awt::Size aSize;
+ if ( m_pAccShape )
+ {
+ aSize = m_pAccShape->getSize();
+ }
+ return aSize;
+}
+
+void AccessibleChartShape::grabFocus()
+ throw (uno::RuntimeException)
+{
+ return AccessibleBase::grabFocus();
+}
+
+sal_Int32 AccessibleChartShape::getForeground()
+ throw (uno::RuntimeException)
+{
+ sal_Int32 nColor(0);
+ if ( m_pAccShape )
+ {
+ nColor = m_pAccShape->getForeground();
+ }
+ return nColor;
+}
+
+sal_Int32 AccessibleChartShape::getBackground()
+ throw (uno::RuntimeException)
+{
+ sal_Int32 nColor(0);
+ if ( m_pAccShape )
+ {
+ nColor = m_pAccShape->getBackground();
+ }
+ return nColor;
+}
+
+// ________ XAccessibleExtendedComponent ________
+Reference< awt::XFont > AccessibleChartShape::getFont()
+ throw (uno::RuntimeException)
+{
+ Reference< awt::XFont > xFont;
+ if ( m_pAccShape )
+ {
+ xFont.set( m_pAccShape->getFont() );
+ }
+ return xFont;
+}
+
+::rtl::OUString AccessibleChartShape::getTitledBorderText()
+ throw (uno::RuntimeException)
+{
+ ::rtl::OUString aText;
+ if ( m_pAccShape )
+ {
+ aText = m_pAccShape->getTitledBorderText();
+ }
+ return aText;
+}
+
+::rtl::OUString AccessibleChartShape::getToolTipText()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ ::rtl::OUString aText;
+ if ( m_pAccShape )
+ {
+ aText = m_pAccShape->getToolTipText();
+ }
+ return aText;
+}
+
+} // namespace chart
diff --git a/chart2/source/controller/accessibility/AccessibleChartShape.hxx b/chart2/source/controller/accessibility/AccessibleChartShape.hxx
new file mode 100644
index 000000000000..a1236b697a69
--- /dev/null
+++ b/chart2/source/controller/accessibility/AccessibleChartShape.hxx
@@ -0,0 +1,104 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _CHART2_ACCESSIBLECHARTSHAPE_HXX_
+#define _CHART2_ACCESSIBLECHARTSHAPE_HXX_
+
+#include "AccessibleBase.hxx"
+
+#include <com/sun/star/accessibility/XAccessibleExtendedComponent.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <svx/AccessibleShapeTreeInfo.hxx>
+
+
+namespace accessibility
+{
+class AccessibleShape;
+}
+
+namespace chart
+{
+
+namespace impl
+{
+typedef ::cppu::ImplInheritanceHelper1<
+ AccessibleBase,
+ ::com::sun::star::accessibility::XAccessibleExtendedComponent > AccessibleChartShape_Base;
+}
+
+class AccessibleChartShape :
+ public impl::AccessibleChartShape_Base
+{
+public:
+ AccessibleChartShape( const AccessibleElementInfo& rAccInfo,
+ bool bMayHaveChildren, bool bAlwaysTransparent = false );
+ virtual ~AccessibleChartShape();
+
+ // ________ XServiceInfo ________
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ________ XAccessibleContext ________
+ virtual sal_Int32 SAL_CALL getAccessibleChildCount()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
+ getAccessibleChild( sal_Int32 i )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getAccessibleRole()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleDescription()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleName()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ________ XAccessibleComponent ________
+ virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Point SAL_CALL getLocation() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Size SAL_CALL getSize() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL grabFocus() throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getForeground() throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getBackground() throw (::com::sun::star::uno::RuntimeException);
+
+ // ________ XAccessibleExtendedComponent ________
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont > SAL_CALL getFont()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTitledBorderText()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getToolTipText()
+ throw (::com::sun::star::uno::RuntimeException);
+
+private:
+ ::accessibility::AccessibleShape* m_pAccShape;
+ ::accessibility::AccessibleShapeTreeInfo m_aShapeTreeInfo;
+};
+
+} // namespace chart
+
+#endif
diff --git a/chart2/source/controller/accessibility/AccessibleChartView.cxx b/chart2/source/controller/accessibility/AccessibleChartView.cxx
index 611d75992832..4833991ad7cc 100644
--- a/chart2/source/controller/accessibility/AccessibleChartView.cxx
+++ b/chart2/source/controller/accessibility/AccessibleChartView.cxx
@@ -36,6 +36,7 @@
#include "ObjectIdentifier.hxx"
#include "ResId.hxx"
#include "Strings.hrc"
+#include "AccessibleViewForwarder.hxx"
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
@@ -66,19 +67,22 @@ namespace chart
//.............................................................................
AccessibleChartView::AccessibleChartView(
- const Reference<uno::XComponentContext> & xContext ) :
+ const Reference< uno::XComponentContext >& xContext, SdrView* pView ) :
impl::AccessibleChartView_Base(
AccessibleElementInfo(), // empty for now
true, // has children
true // always transparent
),
- m_xContext( xContext )
+ m_xContext( xContext ),
+ m_pSdrView( pView ),
+ m_pViewForwarder( NULL )
{
AddState( AccessibleStateType::OPAQUE );
}
AccessibleChartView::~AccessibleChartView()
{
+ delete m_pViewForwarder;
}
@@ -187,20 +191,6 @@ awt::Point SAL_CALL AccessibleChartView::getLocationOnScreen()
}
//-----------------------------------------------------------------
-// lang::XServiceInfo
-//-----------------------------------------------------------------
-
-APPHELPER_XSERVICEINFO_IMPL( AccessibleChartView, CHART2_ACCESSIBLE_SERVICE_IMPLEMENTATION_NAME )
-
-uno::Sequence< rtl::OUString > AccessibleChartView::getSupportedServiceNames_Static()
-{
- uno::Sequence< rtl::OUString > aSNS( 2 );
- aSNS.getArray()[ 0 ] = C2U("com.sun.star.accessibility.Accessible");
- aSNS.getArray()[ 1 ] = CHART2_ACCESSIBLE_SERVICE_NAME;
- return aSNS;
-}
-
-//-----------------------------------------------------------------
// lang::XInitialization
//-----------------------------------------------------------------
@@ -350,7 +340,7 @@ void SAL_CALL AccessibleChartView::initialize( const Sequence< Any >& rArguments
{
AccessibleElementInfo aAccInfo;
- aAccInfo.m_aCID = C2U("ROOT");
+ aAccInfo.m_aOID = ObjectIdentifier( C2U( "ROOT" ) );
aAccInfo.m_xChartDocument = uno::WeakReference< chart2::XChartDocument >(
uno::Reference< chart2::XChartDocument >( m_xChartModel.get(), uno::UNO_QUERY ));
aAccInfo.m_xSelectionSupplier = m_xSelectionSupplier;
@@ -358,6 +348,14 @@ void SAL_CALL AccessibleChartView::initialize( const Sequence< Any >& rArguments
aAccInfo.m_xWindow = m_xWindow;
aAccInfo.m_pParent = 0;
aAccInfo.m_spObjectHierarchy = m_spObjectHierarchy;
+ aAccInfo.m_pSdrView = m_pSdrView;
+ Window* pWindow = VCLUnoHelper::GetWindow( m_xWindow );
+ if ( m_pViewForwarder )
+ {
+ delete m_pViewForwarder;
+ }
+ m_pViewForwarder = new AccessibleViewForwarder( this, pWindow );
+ aAccInfo.m_pViewForwarder = m_pViewForwarder;
// broadcasts an INVALIDATE_ALL_CHILDREN event globally
SetInfo( aAccInfo );
}
@@ -384,16 +382,16 @@ void SAL_CALL AccessibleChartView::selectionChanged( const lang::EventObject& /*
if( xSelectionSupplier.is() )
{
- rtl::OUString aSelectedObjectCID;
- Any aSelection = xSelectionSupplier->getSelection();
- if(aSelection>>=aSelectedObjectCID)
+ ObjectIdentifier aSelectedOID( xSelectionSupplier->getSelection() );
+ if ( m_aCurrentSelectionOID.isValid() )
+ {
+ NotifyEvent( LOST_SELECTION, m_aCurrentSelectionOID );
+ }
+ if( aSelectedOID.isValid() )
{
- if( m_aCurrentSelectionCID.getLength())
- NotifyEvent( LOST_SELECTION, m_aCurrentSelectionCID );
- if( aSelectedObjectCID.getLength())
- NotifyEvent( GOT_SELECTION, aSelectedObjectCID );
- m_aCurrentSelectionCID = aSelectedObjectCID;
+ NotifyEvent( GOT_SELECTION, aSelectedOID );
}
+ m_aCurrentSelectionOID = aSelectedOID;
}
}
diff --git a/chart2/source/controller/accessibility/AccessibleViewForwarder.cxx b/chart2/source/controller/accessibility/AccessibleViewForwarder.cxx
new file mode 100644
index 000000000000..5014198761f8
--- /dev/null
+++ b/chart2/source/controller/accessibility/AccessibleViewForwarder.cxx
@@ -0,0 +1,116 @@
+/*************************************************************************
+ *
+ * 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 "AccessibleViewForwarder.hxx"
+#include "AccessibleChartView.hxx"
+
+#include <vcl/window.hxx>
+
+using namespace ::com::sun::star;
+
+
+namespace chart
+{
+
+AccessibleViewForwarder::AccessibleViewForwarder( AccessibleChartView* pAccChartView, Window* pWindow )
+ :m_pAccChartView( pAccChartView )
+ ,m_pWindow( pWindow )
+ ,m_aMapMode( MAP_100TH_MM )
+{
+}
+
+AccessibleViewForwarder::~AccessibleViewForwarder()
+{
+}
+
+// ________ IAccessibleViewforwarder ________
+
+BOOL AccessibleViewForwarder::IsValid() const
+{
+ return sal_True;
+}
+
+Rectangle AccessibleViewForwarder::GetVisibleArea() const
+{
+ Rectangle aVisibleArea;
+ if ( m_pWindow )
+ {
+ aVisibleArea.SetPos( Point( 0, 0 ) );
+ aVisibleArea.SetSize( m_pWindow->GetOutputSizePixel() );
+ aVisibleArea = m_pWindow->PixelToLogic( aVisibleArea, m_aMapMode );
+ }
+ return aVisibleArea;
+}
+
+Point AccessibleViewForwarder::LogicToPixel( const Point& rPoint ) const
+{
+ Point aPoint;
+ if ( m_pAccChartView && m_pWindow )
+ {
+ awt::Point aLocation = m_pAccChartView->getLocationOnScreen();
+ Point aTopLeft( aLocation.X, aLocation.Y );
+ aPoint = m_pWindow->LogicToPixel( rPoint, m_aMapMode ) + aTopLeft;
+ }
+ return aPoint;
+}
+
+Size AccessibleViewForwarder::LogicToPixel( const Size& rSize ) const
+{
+ Size aSize;
+ if ( m_pWindow )
+ {
+ aSize = m_pWindow->LogicToPixel( rSize, m_aMapMode );
+ }
+ return aSize;
+}
+
+Point AccessibleViewForwarder::PixelToLogic( const Point& rPoint ) const
+{
+ Point aPoint;
+ if ( m_pAccChartView && m_pWindow )
+ {
+ awt::Point aLocation = m_pAccChartView->getLocationOnScreen();
+ Point aTopLeft( aLocation.X, aLocation.Y );
+ aPoint = m_pWindow->PixelToLogic( rPoint - aTopLeft, m_aMapMode );
+ }
+ return aPoint;
+}
+
+Size AccessibleViewForwarder::PixelToLogic( const Size& rSize ) const
+{
+ Size aSize;
+ if ( m_pWindow )
+ {
+ aSize = m_pWindow->PixelToLogic( rSize, m_aMapMode );
+ }
+ return aSize;
+}
+
+} // namespace chart
diff --git a/chart2/source/controller/accessibility/AccessibleViewForwarder.hxx b/chart2/source/controller/accessibility/AccessibleViewForwarder.hxx
new file mode 100644
index 000000000000..e70aa58b8df7
--- /dev/null
+++ b/chart2/source/controller/accessibility/AccessibleViewForwarder.hxx
@@ -0,0 +1,65 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _CHART2_ACCESSIBLEVIEWFORWARDER_HXX_
+#define _CHART2_ACCESSIBLEVIEWFORWARDER_HXX_
+
+#include <vcl/mapmod.hxx>
+#include <svx/IAccessibleViewForwarder.hxx>
+
+class Window;
+
+namespace chart
+{
+
+class AccessibleChartView;
+
+class AccessibleViewForwarder : public ::accessibility::IAccessibleViewForwarder
+{
+public:
+ AccessibleViewForwarder( AccessibleChartView* pAccChartView, Window* pWindow );
+ virtual ~AccessibleViewForwarder();
+
+ // ________ IAccessibleViewforwarder ________
+ virtual BOOL IsValid() const;
+ virtual Rectangle GetVisibleArea() const;
+ virtual Point LogicToPixel( const Point& rPoint ) const;
+ virtual Size LogicToPixel( const Size& rSize ) const;
+ virtual Point PixelToLogic( const Point& rPoint ) const;
+ virtual Size PixelToLogic( const Size& rSize ) const;
+
+private:
+ AccessibleViewForwarder( AccessibleViewForwarder& );
+ AccessibleViewForwarder& operator=( AccessibleViewForwarder& );
+
+ AccessibleChartView* m_pAccChartView;
+ Window* m_pWindow;
+ MapMode m_aMapMode;
+};
+
+} // namespace chart
+
+#endif
diff --git a/chart2/source/controller/accessibility/ChartElementFactory.cxx b/chart2/source/controller/accessibility/ChartElementFactory.cxx
index 43535a0d7fc5..b2599fec0c74 100644
--- a/chart2/source/controller/accessibility/ChartElementFactory.cxx
+++ b/chart2/source/controller/accessibility/ChartElementFactory.cxx
@@ -30,7 +30,6 @@
#include "ChartElementFactory.hxx"
#include "ObjectIdentifier.hxx"
-
#include "AccessibleChartElement.hxx"
namespace chart
@@ -38,8 +37,8 @@ namespace chart
AccessibleBase* ChartElementFactory::CreateChartElement( const AccessibleElementInfo& rAccInfo )
{
- ObjectType eType(
- ObjectIdentifier::getObjectType( rAccInfo.m_aCID ));
+ ObjectIdentifier aOID( rAccInfo.m_aOID );
+ ObjectType eType( aOID.getObjectType() );
switch( eType )
{
@@ -72,6 +71,8 @@ AccessibleBase* ChartElementFactory::CreateChartElement( const AccessibleElement
return new AccessibleChartElement( rAccInfo, true, false );
case OBJECTTYPE_UNKNOWN:
break;
+ default:
+ break;
}
return 0;
diff --git a/chart2/source/controller/accessibility/makefile.mk b/chart2/source/controller/accessibility/makefile.mk
index e79019ba8602..44c816d90d0e 100644
--- a/chart2/source/controller/accessibility/makefile.mk
+++ b/chart2/source/controller/accessibility/makefile.mk
@@ -44,7 +44,9 @@ SLOFILES= $(SLO)$/AccessibleChartView.obj \
$(SLO)$/ChartElementFactory.obj \
$(SLO)$/AccessibleBase.obj \
$(SLO)$/AccessibleChartElement.obj \
- $(SLO)$/AccessibleTextHelper.obj
+ $(SLO)$/AccessibleChartShape.obj \
+ $(SLO)$/AccessibleTextHelper.obj \
+ $(SLO)$/AccessibleViewForwarder.obj
# --- Targets -----------------------------------------------------------------
diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx
index 375119ce521f..253699f4595c 100644
--- a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx
@@ -61,59 +61,18 @@
using namespace ::com::sun::star;
using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::rtl::OUString;
using ::osl::MutexGuard;
+using ::com::sun::star::chart::XComplexDescriptionAccess;
+using ::com::sun::star::chart::XChartData;
+using ::com::sun::star::chart::XChartDataArray;
namespace
{
static const ::rtl::OUString lcl_aServiceName(
RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.ChartData" ));
-struct lcl_DataSequenceToDoubleSeq : public ::std::unary_function<
- uno::Reference< chart2::data::XDataSequence >,
- uno::Sequence< double > >
-{
- uno::Sequence< double > operator() ( const uno::Reference< chart2::data::XDataSequence > & xSeq )
- {
- uno::Reference< chart2::data::XNumericalDataSequence > xNumSeq( xSeq, uno::UNO_QUERY );
- if( xNumSeq.is())
- {
- return xNumSeq->getNumericalData();
- }
- else if( xSeq.is())
- {
- uno::Sequence< uno::Any > aValues = xSeq->getData();
- uno::Sequence< double > aResult( aValues.getLength());
- const sal_Int32 nLength = aValues.getLength();
- for( sal_Int32 i = 0; i < nLength; ++i )
- {
- if( ! ( aValues[ i ] >>= aResult[ i ]) )
- {
- aResult[ i ] = DBL_MIN;
- }
- double& rValue = aResult[ i ];
- if( ::rtl::math::isNan( rValue ) )
- rValue = DBL_MIN;
- }
- return aResult;
- }
- return uno::Sequence< double >();
- }
-};
-
-void lcl_AddSequences( uno::Reference< chart2::data::XLabeledDataSequence > xLSeq,
- ::std::vector< uno::Reference< chart2::data::XDataSequence > > & rOutSeqVector,
- ::std::vector< ::rtl::OUString > & rOutLabelVector )
-{
- if( xLSeq.is() )
- {
- uno::Reference< chart2::data::XDataSequence > xSeq( xLSeq->getValues() );
- rOutSeqVector.push_back( xSeq );
-
- ::rtl::OUString aLabel( ::chart::DataSeriesHelper::getLabelForLabeledDataSequence( xLSeq ) );
- rOutLabelVector.push_back( aLabel );
- }
-}
-
uno::Sequence< uno::Sequence< double > > lcl_getNANInsteadDBL_MIN( const uno::Sequence< uno::Sequence< double > >& rData )
{
uno::Sequence< uno::Sequence< double > > aRet;
@@ -163,11 +122,197 @@ namespace chart
namespace wrapper
{
+//--------------------------------------------------------------------------------------
+
+struct lcl_Operator
+{
+ lcl_Operator()
+ {
+ }
+ virtual ~lcl_Operator()
+ {
+ }
+ virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess ) = 0;
+
+ virtual bool setsCategories( bool /*bDataInColumns*/ )
+ {
+ return false;
+ }
+};
+
+//--------------------------------------------------------------------------
+
+struct lcl_AllOperator : public lcl_Operator
+{
+ lcl_AllOperator( const Reference< XChartData >& xDataToApply )
+ : lcl_Operator()
+ , m_xDataToApply( xDataToApply )
+ {
+ }
+
+ virtual bool setsCategories( bool /*bDataInColumns*/ )
+ {
+ return true;
+ }
+
+ virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess )
+ {
+ if( !xDataAccess.is() )
+ return;
+
+ Reference< XComplexDescriptionAccess > xNewComplex( m_xDataToApply, uno::UNO_QUERY );
+ if( xNewComplex.is() )
+ {
+ xDataAccess->setData( xNewComplex->getData() );
+ xDataAccess->setComplexRowDescriptions( xNewComplex->getComplexRowDescriptions() );
+ xDataAccess->setComplexColumnDescriptions( xNewComplex->getComplexColumnDescriptions() );
+ }
+ else
+ {
+ Reference< XChartDataArray > xNew( m_xDataToApply, uno::UNO_QUERY );
+ if( xNew.is() )
+ {
+ xDataAccess->setData( xNew->getData() );
+ xDataAccess->setRowDescriptions( xNew->getRowDescriptions() );
+ xDataAccess->setColumnDescriptions( xNew->getColumnDescriptions() );
+ }
+ }
+ }
+
+ Reference< XChartData > m_xDataToApply;
+};
+
+//--------------------------------------------------------------------------
+
+struct lcl_DataOperator : public lcl_Operator
+{
+ lcl_DataOperator( const Sequence< Sequence< double > >& rData )
+ : lcl_Operator()
+ , m_rData( rData )
+ {
+ }
+
+ virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess )
+ {
+ if( xDataAccess.is() )
+ xDataAccess->setData( lcl_getNANInsteadDBL_MIN( m_rData ) );
+ }
+
+ const Sequence< Sequence< double > >& m_rData;
+};
+
+//--------------------------------------------------------------------------
+
+struct lcl_RowDescriptionsOperator : public lcl_Operator
+{
+ lcl_RowDescriptionsOperator( const Sequence< OUString >& rRowDescriptions )
+ : lcl_Operator()
+ , m_rRowDescriptions( rRowDescriptions )
+ {
+ }
+
+ virtual bool setsCategories( bool bDataInColumns )
+ {
+ return bDataInColumns;
+ }
+
+ virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess )
+ {
+ if( xDataAccess.is() )
+ xDataAccess->setRowDescriptions( m_rRowDescriptions );
+ }
+
+ const Sequence< OUString >& m_rRowDescriptions;
+};
+
+//--------------------------------------------------------------------------
+
+struct lcl_ComplexRowDescriptionsOperator : public lcl_Operator
+{
+ lcl_ComplexRowDescriptionsOperator( const Sequence< Sequence< OUString > >& rComplexRowDescriptions )
+ : lcl_Operator()
+ , m_rComplexRowDescriptions( rComplexRowDescriptions )
+ {
+ }
+
+ virtual bool setsCategories( bool bDataInColumns )
+ {
+ return !bDataInColumns;
+ }
+
+ virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess )
+ {
+ if( xDataAccess.is() )
+ xDataAccess->setComplexRowDescriptions( m_rComplexRowDescriptions );
+ }
+
+ const Sequence< Sequence< OUString > >& m_rComplexRowDescriptions;
+};
+
+//--------------------------------------------------------------------------
+
+struct lcl_ColumnDescriptionsOperator : public lcl_Operator
+{
+ lcl_ColumnDescriptionsOperator( const Sequence< OUString >& rColumnDescriptions )
+ : lcl_Operator()
+ , m_rColumnDescriptions( rColumnDescriptions )
+ {
+ }
+
+ virtual bool setsCategories( bool bDataInColumns )
+ {
+ return !bDataInColumns;
+ }
+
+ virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess )
+ {
+ if( xDataAccess.is() )
+ xDataAccess->setColumnDescriptions( m_rColumnDescriptions );
+ }
+
+ const Sequence< OUString >& m_rColumnDescriptions;
+};
+
+//--------------------------------------------------------------------------
+
+struct lcl_ComplexColumnDescriptionsOperator : public lcl_Operator
+{
+ lcl_ComplexColumnDescriptionsOperator( const Sequence< Sequence< OUString > >& rComplexColumnDescriptions )
+ : lcl_Operator()
+ , m_rComplexColumnDescriptions( rComplexColumnDescriptions )
+ {
+ }
+
+ virtual bool setsCategories( bool bDataInColumns )
+ {
+ return !bDataInColumns;
+ }
+
+ virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess )
+ {
+ if( xDataAccess.is() )
+ xDataAccess->setComplexColumnDescriptions( m_rComplexColumnDescriptions );
+ }
+
+ const Sequence< Sequence< OUString > >& m_rComplexColumnDescriptions;
+};
+
+//--------------------------------------------------------------------------
+
ChartDataWrapper::ChartDataWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) :
m_spChart2ModelContact( spChart2ModelContact ),
m_aEventListenerContainer( m_aMutex )
{
- refreshData();
+ initDataAccess();
+}
+
+ChartDataWrapper::ChartDataWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
+ const Reference< XChartData >& xNewData ) :
+ m_spChart2ModelContact( spChart2ModelContact ),
+ m_aEventListenerContainer( m_aMutex )
+{
+ lcl_AllOperator aOperator( xNewData );
+ applyData( aOperator );
}
ChartDataWrapper::~ChartDataWrapper()
@@ -179,87 +324,80 @@ ChartDataWrapper::~ChartDataWrapper()
// m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
}
-// ____ XChartDataArray ____
-uno::Sequence< uno::Sequence< double > > SAL_CALL ChartDataWrapper::getData()
+// ____ XChartDataArray (read)____
+Sequence< Sequence< double > > SAL_CALL ChartDataWrapper::getData()
throw (uno::RuntimeException)
{
- // until we have a data change notification mechanism we always have to
- // update the data here
- refreshData();
- // /--
- MutexGuard aGuard( GetMutex());
- return m_aData;
- // \--
+ initDataAccess();
+ if( m_xDataAccess.is() )
+ return lcl_getDBL_MINInsteadNAN( m_xDataAccess->getData() );
+ return Sequence< Sequence< double > >();
}
-
-void SAL_CALL ChartDataWrapper::setData(
- const uno::Sequence< uno::Sequence< double > >& aData )
+Sequence< OUString > SAL_CALL ChartDataWrapper::getRowDescriptions()
throw (uno::RuntimeException)
{
- refreshData();
- {
- // /--
- MutexGuard aGuard( GetMutex());
- m_aData = aData;
- // \--
- }
- applyData( true, false, false );
+ initDataAccess();
+ if( m_xDataAccess.is() )
+ return m_xDataAccess->getRowDescriptions();
+ return Sequence< OUString >();
}
-
-uno::Sequence< ::rtl::OUString > SAL_CALL ChartDataWrapper::getRowDescriptions()
+Sequence< OUString > SAL_CALL ChartDataWrapper::getColumnDescriptions()
throw (uno::RuntimeException)
{
- // until we have a data change notification mechanism we always have to
- // update the data here
- refreshData();
-
- // /--
- MutexGuard aGuard( GetMutex());
- return m_aRowDescriptions;
- // \--
+ initDataAccess();
+ if( m_xDataAccess.is() )
+ return m_xDataAccess->getColumnDescriptions();
+ return Sequence< OUString > ();
+}
+// ____ XComplexDescriptionAccess (read) ____
+Sequence< Sequence< OUString > > SAL_CALL ChartDataWrapper::getComplexRowDescriptions() throw (uno::RuntimeException)
+{
+ initDataAccess();
+ if( m_xDataAccess.is() )
+ return m_xDataAccess->getComplexRowDescriptions();
+ return Sequence< Sequence< OUString > >();
+}
+Sequence< Sequence< OUString > > SAL_CALL ChartDataWrapper::getComplexColumnDescriptions() throw (uno::RuntimeException)
+{
+ initDataAccess();
+ if( m_xDataAccess.is() )
+ return m_xDataAccess->getComplexColumnDescriptions();
+ return Sequence< Sequence< OUString > >();
}
-void SAL_CALL ChartDataWrapper::setRowDescriptions(
- const uno::Sequence< ::rtl::OUString >& aRowDescriptions )
+// ____ XChartDataArray (write)____
+void SAL_CALL ChartDataWrapper::setData( const Sequence< Sequence< double > >& rData )
throw (uno::RuntimeException)
{
- refreshData();
- {
- // /--
- MutexGuard aGuard( GetMutex());
- m_aRowDescriptions = aRowDescriptions;
- // \--
- }
- applyData( false, true, false );
+ lcl_DataOperator aOperator( rData );
+ applyData( aOperator );
}
-
-uno::Sequence<
- ::rtl::OUString > SAL_CALL ChartDataWrapper::getColumnDescriptions()
+void SAL_CALL ChartDataWrapper::setRowDescriptions( const Sequence< OUString >& rRowDescriptions )
throw (uno::RuntimeException)
{
- // until we have a data change notification mechanism we always have to
- // update the data here
- refreshData();
- // /--
- MutexGuard aGuard( GetMutex());
- return m_aColumnDescriptions;
- // \--
+ lcl_RowDescriptionsOperator aOperator( rRowDescriptions );
+ applyData( aOperator );
}
-
-void SAL_CALL ChartDataWrapper::setColumnDescriptions(
- const uno::Sequence< ::rtl::OUString >& aColumnDescriptions )
+void SAL_CALL ChartDataWrapper::setColumnDescriptions( const Sequence< OUString >& rColumnDescriptions )
throw (uno::RuntimeException)
{
- refreshData();
- {
- // /--
- MutexGuard aGuard( GetMutex());
- m_aColumnDescriptions = aColumnDescriptions;
- // \--
- }
- applyData( false, false, true );
+ lcl_ColumnDescriptionsOperator aOperator( rColumnDescriptions );
+ applyData( aOperator );
+}
+
+// ____ XComplexDescriptionAccess (write) ____
+void SAL_CALL ChartDataWrapper::setComplexRowDescriptions( const Sequence< Sequence< ::rtl::OUString > >& rRowDescriptions ) throw (uno::RuntimeException)
+{
+ lcl_ComplexRowDescriptionsOperator aOperator( rRowDescriptions );
+ applyData( aOperator );
+}
+void SAL_CALL ChartDataWrapper::setComplexColumnDescriptions( const Sequence< Sequence< ::rtl::OUString > >& rColumnDescriptions ) throw (uno::RuntimeException)
+{
+ lcl_ComplexColumnDescriptionsOperator aOperator( rColumnDescriptions );
+ applyData( aOperator );
}
+//--------------------------------------------------------------------------------------
// ____ XChartData (base of XChartDataArray) ____
void SAL_CALL ChartDataWrapper::addChartDataChangeEventListener(
@@ -297,13 +435,7 @@ void SAL_CALL ChartDataWrapper::dispose()
throw (uno::RuntimeException)
{
m_aEventListenerContainer.disposeAndClear( lang::EventObject( static_cast< ::cppu::OWeakObject* >( this )));
-
- // /--
- MutexGuard aGuard( GetMutex());
- m_aData.realloc( 0 );
- m_aColumnDescriptions.realloc( 0 );
- m_aRowDescriptions.realloc( 0 );
- // \--
+ m_xDataAccess=0;
}
void SAL_CALL ChartDataWrapper::addEventListener(
@@ -354,160 +486,39 @@ void ChartDataWrapper::fireChartDataChangeEvent(
}
}
-void ChartDataWrapper::refreshData()
+// --------------------------------------------------------------------------------
+
+void ChartDataWrapper::switchToInternalDataProvider()
+{
+ //create an internal data provider that is connected to the model
+ Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
+ if( xChartDoc.is() )
+ xChartDoc->createInternalDataProvider( true /*bCloneExistingData*/ );
+ initDataAccess();
+}
+
+void ChartDataWrapper::initDataAccess()
{
- //todo mutex...
Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
if( !xChartDoc.is() )
return;
- if( xChartDoc->hasInternalDataProvider())
- {
- try {
- uno::Reference< ::com::sun::star::chart::XChartDataArray > xInternalData( xChartDoc->getDataProvider(), uno::UNO_QUERY_THROW );
- m_aColumnDescriptions = xInternalData->getColumnDescriptions();
- m_aRowDescriptions = xInternalData->getRowDescriptions();
- m_aData = lcl_getDBL_MINInsteadNAN( xInternalData->getData() );
- }
- catch( const uno::Exception & ex ) {
- ASSERT_EXCEPTION( ex );
- }
- }
+ if( xChartDoc->hasInternalDataProvider() )
+ m_xDataAccess = Reference< XComplexDescriptionAccess >( xChartDoc->getDataProvider(), uno::UNO_QUERY_THROW );
else
{
- uno::Reference< chart2::XDiagram > xDia(
- xChartDoc->getFirstDiagram() );
- if( ! xDia.is())
- return;
-
- // get information about the segmentation of the assumed "rectangular" data
- // range
- ::rtl::OUString aRangeString;
- bool bUseColumns = true;
- bool bFirstCellAsLabel = true;
- bool bHasCategories = true;
- uno::Sequence< sal_Int32 > aSequenceMapping;
-
- DataSourceHelper::detectRangeSegmentation(
- uno::Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY ),
- aRangeString, aSequenceMapping, bUseColumns, bFirstCellAsLabel, bHasCategories );
-
-
- // get data values from data series
- // --------------------------------
- uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aLabeledSequences;
- uno::Reference< chart2::data::XDataSource > xRectangularDataSource(
- DataSourceHelper::pressUsedDataIntoRectangularFormat( xChartDoc, false /*bWithCategories*/ ) );
- if( xRectangularDataSource.is() )
- {
- aLabeledSequences = xRectangularDataSource->getDataSequences();
- }
-
- ::std::vector< uno::Reference< chart2::data::XDataSequence > > aSequenceVector;
- ::std::vector< ::rtl::OUString > aLabelVector;
- for( sal_Int32 nN=0; nN<aLabeledSequences.getLength(); nN++ )
- lcl_AddSequences( aLabeledSequences[nN], aSequenceVector, aLabelVector );
-
- if( aSequenceMapping.getLength() )
- {
- //aSequenceVector and aLabelVector contain changed positions; resort them to the original position
- ::std::vector< uno::Reference< chart2::data::XDataSequence > > aBackSortedSequences;
- ::std::vector< ::rtl::OUString > aBackSortedLabels;
-
- std::map< sal_Int32, sal_Int32 > aReverseMap;
- {
- sal_Int32 nNewIndex, nOldIndex;
- for( sal_Int32 nS=0; nS <aSequenceMapping.getLength(); nS++ )
- {
- nOldIndex = aSequenceMapping[nS];
- nNewIndex = nS;
- if( bHasCategories )
- nNewIndex--;
- if( nOldIndex >= 0 && nNewIndex >= 0 )
- aReverseMap[nOldIndex] = nNewIndex;
- }
- }
-
- std::map< sal_Int32, sal_Int32 >::iterator aMapIt = aReverseMap.begin();
- std::map< sal_Int32, sal_Int32 >::const_iterator aMapEnd = aReverseMap.end();
-
- for( ; aMapIt != aMapEnd; ++aMapIt )
- {
- size_t nNewIndex = static_cast< size_t >( aMapIt->second );
- if( nNewIndex < aSequenceVector.size() )
- aBackSortedSequences.push_back( aSequenceVector[nNewIndex] );
- if( nNewIndex < aLabelVector.size() )
- aBackSortedLabels.push_back( aLabelVector[nNewIndex] );
- }
-
- // note: assign( beg, end ) doesn't work on solaris
- aSequenceVector.clear();
- aSequenceVector.insert(
- aSequenceVector.begin(), aBackSortedSequences.begin(), aBackSortedSequences.end() );
- aLabelVector.clear();
- aLabelVector.insert(
- aLabelVector.begin(), aBackSortedLabels.begin(), aBackSortedLabels.end() );
- }
-
- if( bUseColumns )
- {
- const sal_Int32 nInnerSize = aSequenceVector.size();
- if( nInnerSize > 0 && aSequenceVector[0].is() )
- {
- // take the length of the first data series also as length for all
- // other series
- const sal_Int32 nOuterSize = aSequenceVector[0]->getData().getLength();
-
- m_aData.realloc( nOuterSize );
- for( sal_Int32 nOuter=0; nOuter<nOuterSize; ++nOuter )
- m_aData[nOuter].realloc( nInnerSize );
-
- for( sal_Int32 nInner=0; nInner<nInnerSize; ++nInner )
- {
- uno::Sequence< double > aValues = uno::Sequence< double > (
- lcl_DataSequenceToDoubleSeq() (aSequenceVector[nInner] ));
- sal_Int32 nMax = ::std::min( nOuterSize, aValues.getLength());
- for( sal_Int32 nOuter=0; nOuter<nMax; ++nOuter )
- m_aData[nOuter][nInner] = aValues[nOuter];
- }
- }
- }
- else
- {
- m_aData.realloc( static_cast< sal_Int32 >( aSequenceVector.size()));
- ::std::transform( aSequenceVector.begin(), aSequenceVector.end(),
- m_aData.getArray(),
- lcl_DataSequenceToDoubleSeq() );
- }
-
- // labels (values already filled during parsing of data values)
- if( bUseColumns )
- m_aColumnDescriptions = ::chart::ContainerHelper::ContainerToSequence( aLabelVector );
- else
- m_aRowDescriptions = ::chart::ContainerHelper::ContainerToSequence( aLabelVector );
-
- // get row-/column descriptions
- // ----------------------------
- // categories
- uno::Sequence< ::rtl::OUString > & rSequence =
- bUseColumns ? m_aRowDescriptions : m_aColumnDescriptions;
- rSequence = DiagramHelper::generateAutomaticCategories( xChartDoc );
+ //create a separate "internal data provider" that is not connected to the model
+ m_xDataAccess = Reference< XComplexDescriptionAccess >( ChartModelHelper::createInternalDataProvider(
+ xChartDoc, false /*bConnectToModel*/ ), uno::UNO_QUERY_THROW );
}
}
-void ChartDataWrapper::applyData( bool bSetValues, bool bSetRowDescriptions, bool bSetColumnDescriptions )
+void ChartDataWrapper::applyData( lcl_Operator& rDataOperator )
{
+ //bool bSetValues, bool bSetRowDescriptions, bool bSetColumnDescriptions
Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
if( !xChartDoc.is() )
return;
- // /-- locked controllers
- ControllerLockGuard aCtrlLockGuard( uno::Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY ));
- // should do nothing if we already have an internal data provider
- xChartDoc->createInternalDataProvider( sal_True /* bCloneExistingData */ );
-
- uno::Reference< chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider());
- uno::Reference< XChartDataArray > xDocDataArray( xDataProvider, uno::UNO_QUERY );
-
// remember some diagram properties to reset later
sal_Bool bStacked = sal_False;
sal_Bool bPercent = sal_False;
@@ -533,71 +544,24 @@ void ChartDataWrapper::applyData( bool bSetValues, bool bSetRowDescriptions, boo
uno::Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY ),
aRangeString, aSequenceMapping, bUseColumns, bFirstCellAsLabel, bHasCategories );
- if( !bFirstCellAsLabel )
- {
- if( bSetRowDescriptions && !bUseColumns )
- bFirstCellAsLabel = true;
- else if( bSetColumnDescriptions && bUseColumns )
- bFirstCellAsLabel = true;
- }
- if( !bHasCategories )
- {
- if( bSetColumnDescriptions && bUseColumns )
- bHasCategories = true;
- else if( bSetRowDescriptions && !bUseColumns )
- bHasCategories = true;
- }
+ if( !bHasCategories && rDataOperator.setsCategories( bUseColumns ) )
+ bHasCategories = true;
- aRangeString = C2U("all");
uno::Sequence< beans::PropertyValue > aArguments( DataSourceHelper::createArguments(
aRangeString, aSequenceMapping, bUseColumns, bFirstCellAsLabel, bHasCategories ) );
- // create and attach new data source
- uno::Reference< chart2::data::XDataSource > xSource;
- if( xDocDataArray.is() )
- {
- // we have an internal data provider that supports the XChartDataArray
- // interface
- if( bSetValues )
- xDocDataArray->setData( lcl_getNANInsteadDBL_MIN( m_aData ) );
- if( bSetRowDescriptions )
- xDocDataArray->setRowDescriptions( m_aRowDescriptions );
- if( bSetColumnDescriptions )
- xDocDataArray->setColumnDescriptions( m_aColumnDescriptions );
-
- xSource.set( xDataProvider->createDataSource( aArguments ));
- }
- else
- {
- uno::Reference< chart2::data::XDataReceiver > xReceiver( xChartDoc, uno::UNO_QUERY );
- OSL_ASSERT( xChartDoc.is());
- OSL_ASSERT( xReceiver.is());
- if( ! (xChartDoc.is() && xReceiver.is()))
- return;
- // create a data provider containing the new data
- uno::Reference< chart2::data::XDataProvider > xTempDataProvider(
- ChartModelHelper::createInternalDataProvider() );
- if( ! xTempDataProvider.is())
- throw uno::RuntimeException( C2U("Couldn't create temporary data provider"),
- static_cast< ::cppu::OWeakObject * >( this ));
+ // /-- locked controllers
+ ControllerLockGuard aCtrlLockGuard( uno::Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY ));
- uno::Reference< ::com::sun::star::chart::XChartDataArray > xDataArray( xTempDataProvider, uno::UNO_QUERY );
- OSL_ASSERT( xDataArray.is());
- if( xDataArray.is())
- {
- if( bSetValues )
- xDataArray->setData( lcl_getNANInsteadDBL_MIN( m_aData ) );
- if( bSetRowDescriptions )
- xDataArray->setRowDescriptions( m_aRowDescriptions );
- if( bSetColumnDescriptions )
- xDataArray->setColumnDescriptions( m_aColumnDescriptions );
-
- // removes existing data provider and attaches the new one
- xReceiver->attachDataProvider( xTempDataProvider );
- xSource.set( xTempDataProvider->createDataSource( aArguments));
- }
- }
+ // create and attach new data source
+ switchToInternalDataProvider();
+ rDataOperator.apply(m_xDataAccess);
+ uno::Reference< chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider() );
+ OSL_ASSERT( xDataProvider.is() );
+ if( !xDataProvider.is() )
+ return;
+ uno::Reference< chart2::data::XDataSource > xSource( xDataProvider->createDataSource( aArguments ) );
// determine a template
uno::Reference< lang::XMultiServiceFactory > xFact( xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
@@ -621,8 +585,7 @@ void ChartDataWrapper::applyData( bool bSetValues, bool bSetRowDescriptions, boo
// argument detection works with internal knowledge of the
// ArrayDataProvider
OSL_ASSERT( xDia.is());
- xTemplate->changeDiagramData(
- xDia, xSource, aArguments );
+ xTemplate->changeDiagramData( xDia, xSource, aArguments );
}
//correct stacking mode
diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx
index 6bdae0350184..d56397953d79 100644
--- a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx
+++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx
@@ -31,7 +31,7 @@
#include "MutexContainer.hxx"
#include <cppuhelper/implbase4.hxx>
#include <cppuhelper/interfacecontainer.hxx>
-#include <com/sun/star/chart/XChartDataArray.hpp>
+#include <com/sun/star/chart/XComplexDescriptionAccess.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
@@ -45,23 +45,40 @@ namespace wrapper
{
class Chart2ModelContact;
+struct lcl_Operator;
class ChartDataWrapper : public MutexContainer, public
::cppu::WeakImplHelper4<
- com::sun::star::chart::XChartDataArray,
+ com::sun::star::chart::XComplexDescriptionAccess,
com::sun::star::lang::XServiceInfo,
com::sun::star::lang::XEventListener,
com::sun::star::lang::XComponent >
{
public:
ChartDataWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact );
+ ChartDataWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact
+ , const ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartData >& xNewData );
virtual ~ChartDataWrapper();
/// XServiceInfo declarations
APPHELPER_XSERVICEINFO_DECL()
protected:
- // ____ XChartDataArray ____
+ // ____ XComplexDescriptionAccess ____
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL
+ getComplexRowDescriptions() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setComplexRowDescriptions(
+ const ::com::sun::star::uno::Sequence<
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > >& aRowDescriptions )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL
+ getComplexColumnDescriptions() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setComplexColumnDescriptions(
+ const ::com::sun::star::uno::Sequence<
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > >& aColumnDescriptions )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ XChartDataArray (base of XComplexDescriptionAccess) ____
virtual ::com::sun::star::uno::Sequence<
::com::sun::star::uno::Sequence<
double > > SAL_CALL getData()
@@ -112,20 +129,17 @@ protected:
void fireChartDataChangeEvent( ::com::sun::star::chart::ChartDataChangeEvent& aEvent );
-private:
- ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
- ::cppu::OInterfaceContainerHelper m_aEventListenerContainer;
-
- ::com::sun::star::uno::Sequence<
- ::com::sun::star::uno::Sequence< double > > m_aData;
- ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aColumnDescriptions;
- ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aRowDescriptions;
+private: //methods
+ void switchToInternalDataProvider();
+ void initDataAccess();
+ void applyData( lcl_Operator& rDataOperator );
- /// re-reads the data from the model
- void refreshData();
+private: //member
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart::XComplexDescriptionAccess > m_xDataAccess;
- /// applies changed data to model
- void applyData( bool bSetValues, bool bSetRowDescriptions, bool bSetColumnDescriptions );
+ ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ ::cppu::OInterfaceContainerHelper m_aEventListenerContainer;
};
} // namespace wrapper
diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
index 138a54a43036..14a20e133ff1 100644
--- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
@@ -45,6 +45,8 @@
#include "DataSourceHelper.hxx"
#include "ChartModelHelper.hxx"
#include "ContainerHelper.hxx"
+#include "AxisHelper.hxx"
+#include "ThreeDHelper.hxx"
#include "TitleWrapper.hxx"
#include "ChartDataWrapper.hxx"
@@ -54,15 +56,18 @@
#include "WrappedAddInProperty.hxx"
#include "WrappedIgnoreProperty.hxx"
#include "ChartRenderer.hxx"
+#include "UndoManager.hxx"
#include <com/sun/star/chart2/XTitled.hpp>
#include <com/sun/star/chart2/data/XDataReceiver.hpp>
#include <com/sun/star/chart/ChartDataRowSource.hpp>
-#include <com/sun/star/chart/XChartDataArray.hpp>
+#include <com/sun/star/chart/XComplexDescriptionAccess.hpp>
#include <comphelper/InlineContainer.hxx>
// header for function SvxShapeCollection_NewInstance
#include <svx/unoshcol.hxx>
// header for define DBG_ASSERT
#include <tools/debug.hxx>
+#include <vcl/svapp.hxx>
+
#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
@@ -76,6 +81,7 @@
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart;
+using ::com::sun::star::chart::XComplexDescriptionAccess;
using ::com::sun::star::uno::Any;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
@@ -829,7 +835,7 @@ void SAL_CALL ChartDocumentWrapper::setDiagram( const Reference< XDiagram >& xDi
Reference< XChartData > SAL_CALL ChartDocumentWrapper::getData()
throw (uno::RuntimeException)
{
- if( ! m_xChartData.is())
+ if( !m_xChartData.is() )
{
m_xChartData.set( new ChartDataWrapper( m_spChart2ModelContact ) );
}
@@ -838,128 +844,15 @@ Reference< XChartData > SAL_CALL ChartDocumentWrapper::getData()
return m_xChartData;
}
-void SAL_CALL ChartDocumentWrapper::attachData( const Reference< XChartData >& xData )
+void SAL_CALL ChartDocumentWrapper::attachData( const Reference< XChartData >& xNewData )
throw (uno::RuntimeException)
{
- if( !xData.is())
- return;
-
- Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
- if( !xChartDoc.is() )
+ if( !xNewData.is() )
return;
- uno::Reference< chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider());
- uno::Reference< XChartDataArray > xDocDataArray( xDataProvider, uno::UNO_QUERY );
- uno::Reference< XChartDataArray > xDataArray( xData, uno::UNO_QUERY );
- OSL_ASSERT( xDataArray.is());
- if( ! xDataArray.is() ||
- xDocDataArray == xDataArray )
- return;
-
- // remember some diagram properties to reset later
- ChartDataRowSource eSeriesSource = ChartDataRowSource_ROWS;
- sal_Bool bStacked = sal_False;
- sal_Bool bPercent = sal_False;
- sal_Bool bDeep = sal_False;
- Reference< beans::XPropertySet > xDiaProp( getDiagram(), uno::UNO_QUERY );
- if( xDiaProp.is())
- {
- xDiaProp->getPropertyValue( C2U("DataRowSource")) >>= eSeriesSource;
- xDiaProp->getPropertyValue( C2U("Stacked")) >>= bStacked;
- xDiaProp->getPropertyValue( C2U("Percent")) >>= bPercent;
- xDiaProp->getPropertyValue( C2U("Deep")) >>= bDeep;
- }
-
- // create and attach new data source
- uno::Reference< chart2::data::XDataSource > xSource;
- Sequence< beans::PropertyValue > aArguments( 4 );
- aArguments[0] = beans::PropertyValue(
- C2U("CellRangeRepresentation"), -1, uno::makeAny( C2U("all") ),
- beans::PropertyState_DIRECT_VALUE );
- aArguments[1] = beans::PropertyValue(
- C2U("DataRowSource"), -1, uno::makeAny( eSeriesSource ),
- beans::PropertyState_DIRECT_VALUE );
- aArguments[2] = beans::PropertyValue(
- C2U("FirstCellAsLabel"), -1, uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE );
- aArguments[3] = beans::PropertyValue(
- C2U("HasCategories"), -1, uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE );
-
// /-- locked controllers
- ControllerLockGuard aCtrlLockGuard( Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY ));
- if( xDocDataArray.is())
- {
- // we have an internal data provider that supports the XChartDataArray
- // interface
- xDocDataArray->setData( xDataArray->getData());
- xDocDataArray->setRowDescriptions( xDataArray->getRowDescriptions());
- xDocDataArray->setColumnDescriptions( xDataArray->getColumnDescriptions());
-
- xSource.set( xDataProvider->createDataSource( aArguments ));
- }
- else
- {
- uno::Reference< chart2::data::XDataReceiver > xReceiver( xChartDoc, uno::UNO_QUERY );
- OSL_ASSERT( xChartDoc.is());
- OSL_ASSERT( xReceiver.is());
- OSL_ASSERT( xDataArray.is());
- if( ! (xChartDoc.is() &&
- xReceiver.is()))
- return;
-
- // create a data provider containing the new data
- Reference< chart2::data::XDataProvider > xTempDataProvider(
- ChartModelHelper::createInternalDataProvider( xDataArray ));
-
- if( ! xTempDataProvider.is())
- throw uno::RuntimeException( C2U("Couldn't create temporary data provider"),
- static_cast< ::cppu::OWeakObject * >( this ));
-
- // removes existing data provider and attaches the new one
- xReceiver->attachDataProvider( xTempDataProvider );
- xSource.set( xTempDataProvider->createDataSource( aArguments));
- }
-
- // determine a template
- Reference< lang::XMultiServiceFactory > xFact( xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
- Reference< chart2::XDiagram > xDia( xChartDoc->getFirstDiagram());
- DiagramHelper::tTemplateWithServiceName aTemplateAndService =
- DiagramHelper::getTemplateForDiagram( xDia, xFact );
- OUString aServiceName( aTemplateAndService.second );
- Reference< chart2::XChartTypeTemplate > xTemplate = aTemplateAndService.first;
-
- // (fall-back)
- if( ! xTemplate.is())
- {
- if( aServiceName.getLength() == 0 )
- aServiceName = C2U("com.sun.star.chart2.template.Column");
- xTemplate.set( xFact->createInstance( aServiceName ), uno::UNO_QUERY );
- }
- OSL_ASSERT( xTemplate.is());
-
- if( xTemplate.is() && xSource.is())
- {
- // argument detection works with internal knowledge of the
- // ArrayDataProvider
- OSL_ASSERT( xDia.is());
- xTemplate->changeDiagramData(
- xDia, xSource, aArguments );
- }
-
- // should do nothing if we already have an internal data provider
- xChartDoc->createInternalDataProvider( sal_True /* bCloneExistingData */ );
-
- //correct stacking mode
- if( bStacked || bPercent || bDeep )
- {
- StackMode eStackMode = StackMode_Y_STACKED;
- if( bDeep )
- eStackMode = StackMode_Z_STACKED;
- else if( bPercent )
- eStackMode = StackMode_Y_STACKED_PERCENT;
- DiagramHelper::setStackMode( xDia, eStackMode );
- }
-
- m_xChartData = xData;
+ ControllerLockGuard aCtrlLockGuard( Reference< frame::XModel >( m_spChart2ModelContact->getChart2Document(), uno::UNO_QUERY ));
+ m_xChartData.set( new ChartDataWrapper( m_spChart2ModelContact, xNewData ) );
// \-- locked controllers
}
@@ -1419,8 +1312,19 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance(
if( xDia.is())
{
// /-- locked controllers
- ControllerLockGuard aCtrlLockGuard( Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY ));
- xTemplate->changeDiagram( xDia );
+ Reference< frame::XModel > xModel( xChartDoc, uno::UNO_QUERY );
+ ControllerLockGuard aCtrlLockGuard( xModel );
+ Reference< chart2::XDiagram > xDiagram = ChartModelHelper::findDiagram( xModel );
+ ThreeDLookScheme e3DScheme = ThreeDHelper::detectScheme( xDiagram );
+ Reference< lang::XMultiServiceFactory > xTemplateManager( xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
+ DiagramHelper::tTemplateWithServiceName aTemplateWithService(
+ DiagramHelper::getTemplateForDiagram( xDiagram, xTemplateManager ));
+ if( aTemplateWithService.first.is())
+ aTemplateWithService.first->resetStyles( xDiagram );//#i109371#
+ xTemplate->changeDiagram( xDiagram );
+ if( Application::GetSettings().GetLayoutRTL() )
+ AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 ) );
+ ThreeDHelper::setScheme( xDiagram, e3DScheme );
// \-- locked controllers
}
else
@@ -1489,6 +1393,12 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance(
xResult.set( m_xChartView );
bServiceFound = true;
}
+ else if ( aServiceSpecifier.equals( CHART_UNDOMANAGER_SERVICE_NAME ) )
+ {
+ Reference< chart2::XUndoManager > xUndoManager( new UndoManager() );
+ xResult.set( xUndoManager );
+ bServiceFound = true;
+ }
else
{
// try to create a shape
diff --git a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
index f099eaa8499a..d69212512ebe 100644
--- a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
@@ -285,7 +285,7 @@ void WrappedAttachedAxisProperty::setPropertyValue( const Any& rOuterValue, cons
{
Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
if( xDiagram.is() )
- ::chart::DiagramHelper::attachSeriesToAxis( bNewAttachedToMainAxis, xDataSeries, xDiagram, m_spChart2ModelContact->m_xContext );
+ ::chart::DiagramHelper::attachSeriesToAxis( bNewAttachedToMainAxis, xDataSeries, xDiagram, m_spChart2ModelContact->m_xContext, false );
}
}
@@ -746,7 +746,7 @@ const std::vector< WrappedProperty* > DataSeriesPointWrapper::createWrappedPrope
aWrappedProperties.push_back( new WrappedProperty( C2U( "FillStyle" ), C2U( "FillStyle" ) ) );
aWrappedProperties.push_back( new WrappedProperty( C2U( "FillTransparence" ), C2U( "Transparency" ) ) );
- aWrappedProperties.push_back( new WrappedIgnoreProperty( C2U( "LineJoint" ), uno::makeAny( drawing::LineJoint_NONE ) ) );
+ aWrappedProperties.push_back( new WrappedIgnoreProperty( C2U( "LineJoint" ), uno::makeAny( drawing::LineJoint_ROUND ) ) );
aWrappedProperties.push_back( new WrappedProperty( C2U( "FillTransparenceGradientName" ), C2U( "TransparencyGradientName" ) ) );
aWrappedProperties.push_back( new WrappedProperty( C2U( "FillGradientName" ), C2U( "GradientName" ) ) );
aWrappedProperties.push_back( new WrappedProperty( C2U( "FillGradientStepCount" ), C2U( "GradientStepCount" ) ) );
diff --git a/chart2/source/controller/controller.map b/chart2/source/controller/controller.map
deleted file mode 100644
index ac2c3750bfe0..000000000000
--- a/chart2/source/controller/controller.map
+++ /dev/null
@@ -1,8 +0,0 @@
-UDK_3_0_0 {
- global:
- component_getImplementationEnvironment;
- component_writeInfo;
- component_getFactory;
- local:
- *;
-};
diff --git a/chart2/source/controller/dialogs/ChangingResource.cxx b/chart2/source/controller/dialogs/ChangingResource.cxx
index e7461325e3be..22886c9b6108 100644
--- a/chart2/source/controller/dialogs/ChangingResource.cxx
+++ b/chart2/source/controller/dialogs/ChangingResource.cxx
@@ -35,6 +35,10 @@ namespace chart
{
//.............................................................................
+ResourceChangeListener::~ResourceChangeListener()
+{
+}
+
ChangingResource::ChangingResource()
: m_pChangeListener(0)
{
diff --git a/chart2/source/controller/dialogs/ChangingResource.hxx b/chart2/source/controller/dialogs/ChangingResource.hxx
index df69358b00b7..ed6be33b912e 100644
--- a/chart2/source/controller/dialogs/ChangingResource.hxx
+++ b/chart2/source/controller/dialogs/ChangingResource.hxx
@@ -42,6 +42,7 @@ class ResourceChangeListener
{
public:
virtual void stateChanged( ChangingResource* pResource ) = 0;
+ virtual ~ResourceChangeListener();
};
class ChangingResource
diff --git a/chart2/source/controller/dialogs/ChartTypeTemplateProvider.hxx b/chart2/source/controller/dialogs/ChartTypeTemplateProvider.hxx
index 6462d4897945..b2790a1678bb 100644
--- a/chart2/source/controller/dialogs/ChartTypeTemplateProvider.hxx
+++ b/chart2/source/controller/dialogs/ChartTypeTemplateProvider.hxx
@@ -44,6 +44,7 @@ class ChartTypeTemplateProvider
public:
virtual ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartTypeTemplate > getCurrentTemplate() const =0;
+ virtual ~ChartTypeTemplateProvider() {}
};
//.............................................................................
diff --git a/chart2/source/controller/dialogs/DataBrowser.cxx b/chart2/source/controller/dialogs/DataBrowser.cxx
index 1265f4412f2a..67930fc6f7a7 100644
--- a/chart2/source/controller/dialogs/DataBrowser.cxx
+++ b/chart2/source/controller/dialogs/DataBrowser.cxx
@@ -45,6 +45,8 @@
#include "DataSeriesHelper.hxx"
#include "DiagramHelper.hxx"
#include "ChartModelHelper.hxx"
+#include "CommonConverters.hxx"
+#include "macros.hxx"
#include "chartview/NumberFormatterWrapper.hxx"
#include "servicenames_charttypes.hxx"
#include "ResId.hxx"
@@ -187,6 +189,8 @@ public:
sal_Int32 GetStartColumn() const;
sal_Int32 GetEndColumn() const;
+ static sal_Int32 GetRelativeAppFontXPosForNameField();
+
void Show();
/** call this before destroying the class. This notifies the listeners to
@@ -262,23 +266,30 @@ void SeriesHeader::SetColor( const Color & rCol )
m_spColorBar->SetControlBackground( rCol );
}
+const sal_Int32 nSymbolHeight = 10;
+const sal_Int32 nSymbolDistance = 2;
+
+sal_Int32 SeriesHeader::GetRelativeAppFontXPosForNameField()
+{
+ return nSymbolHeight + nSymbolDistance;
+}
+
void SeriesHeader::SetPos( const Point & rPos )
{
m_aPos = rPos;
// chart type symbol
- sal_Int32 nHeight = 10;
Point aPos( rPos );
- aPos.setY( aPos.getY() + 2 );
- Size aSize( nHeight, nHeight );
+ aPos.setY( aPos.getY() + nSymbolDistance );
+ Size aSize( nSymbolHeight, nSymbolHeight );
m_spSymbol->SetPosPixel( m_pDevice->LogicToPixel( aPos, MAP_APPFONT ));
m_spSymbol->SetSizePixel( m_pDevice->LogicToPixel( aSize, MAP_APPFONT ));
- aPos.setY( aPos.getY() - 2 );
+ aPos.setY( aPos.getY() - nSymbolDistance );
// series name edit field
- aPos.setX( aPos.getX() + nHeight + 2 );
- aSize.setWidth( m_nWidth - nHeight - 2 );
- nHeight = 12;
+ aPos.setX( aPos.getX() + nSymbolHeight + nSymbolDistance );
+ aSize.setWidth( m_nWidth - nSymbolHeight - nSymbolDistance );
+ sal_Int32 nHeight = 12;
aSize.setHeight( nHeight );
m_spSeriesName->SetPosPixel( m_pDevice->LogicToPixel( aPos, MAP_APPFONT ));
m_spSeriesName->SetSizePixel( m_pDevice->LogicToPixel( aSize, MAP_APPFONT ));
@@ -553,25 +564,14 @@ bool DataBrowser::MaySwapColumns() const
return (static_cast< sal_uInt32 >( nColIndex ) < (m_aSeriesHeaders.size() - 1));
}
+ sal_Int32 nColIdx = lcl_getColumnInDataOrHeader( GetCurColumnId(), m_aSeriesHeaders );
return ! IsReadOnly()
- && ( GetCurColumnId() > 1 )
- && ( GetCurColumnId() < ColCount() - 1 );
+ && ( nColIdx > 0 )
+ && ( nColIdx < ColCount()-2 )
+ && m_apDataBrowserModel.get()
+ && !m_apDataBrowserModel->isCategoriesColumn( nColIdx );
}
-// bool DataBrowser::MaySortRow() const
-// {
-// // not implemented
-// return false;
-// // return ! IsReadOnly() && ( GetCurRow() >= 0 );
-// }
-
-// bool DataBrowser::MaySortColumn() const
-// {
-// // not implemented
-// return false;
-// // return ! IsReadOnly() && ( GetCurColumnId() > 1 );
-// }
-
void DataBrowser::clearHeaders()
{
::std::for_each( m_aSeriesHeaders.begin(), m_aSeriesHeaders.end(), impl::applyChangesFunctor());
@@ -601,9 +601,10 @@ void DataBrowser::RenewTable()
InsertHandleColumn( static_cast< sal_uInt16 >(
GetDataWindow().LogicToPixel( Size( 42, 0 )).getWidth() ));
- const sal_Int32 nDefaultColumnWidth = 94;
-
- sal_Int32 nColumnWidth( GetDataWindow().LogicToPixel( Size( nDefaultColumnWidth, 0 )).getWidth());
+ OUString aDefaultSeriesName( ::chart::SchResId::getResString( STR_COLUMN_LABEL ));
+ replaceParamterInString( aDefaultSeriesName, C2U("%COLUMNNUMBER"), OUString::valueOf( sal_Int32(24) ) );
+ sal_Int32 nColumnWidth = GetDataWindow().GetTextWidth( aDefaultSeriesName )
+ + GetDataWindow().LogicToPixel( Point( 4 + impl::SeriesHeader::GetRelativeAppFontXPosForNameField(), 0 ), MAP_APPFONT ).X();
sal_Int32 nColumnCount = m_apDataBrowserModel->getColumnCount();
// nRowCount is a member of a base class
sal_Int32 nRowCountLocal = m_apDataBrowserModel->getMaxRowCount();
@@ -882,6 +883,22 @@ void DataBrowser::InsertColumn()
}
}
+void DataBrowser::InsertTextColumn()
+{
+ sal_Int32 nColIdx = lcl_getColumnInDataOrHeader( GetCurColumnId(), m_aSeriesHeaders );
+
+ if( nColIdx >= 0 &&
+ m_apDataBrowserModel.get())
+ {
+ // save changes made to edit-field
+ if( IsModified() )
+ SaveModified();
+
+ m_apDataBrowserModel->insertComplexCategoryLevel( nColIdx );
+ RenewTable();
+ }
+}
+
void DataBrowser::RemoveColumn()
{
sal_Int32 nColIdx = lcl_getColumnInDataOrHeader( GetCurColumnId(), m_aSeriesHeaders );
@@ -894,7 +911,7 @@ void DataBrowser::RemoveColumn()
SaveModified();
m_bDataValid = true;
- m_apDataBrowserModel->removeDataSeries( nColIdx );
+ m_apDataBrowserModel->removeDataSeriesOrComplexCategoryLevel( nColIdx );
RenewTable();
}
}
diff --git a/chart2/source/controller/dialogs/DataBrowser.hxx b/chart2/source/controller/dialogs/DataBrowser.hxx
index 97c952c2cee9..3583db2770c0 100644
--- a/chart2/source/controller/dialogs/DataBrowser.hxx
+++ b/chart2/source/controller/dialogs/DataBrowser.hxx
@@ -121,12 +121,10 @@ public:
bool MaySwapRows() const;
bool MaySwapColumns() const;
-// bool MaySortRow() const;
-// bool MaySortColumn() const;
-
// mutators mutating data
void InsertRow();
void InsertColumn();
+ void InsertTextColumn();
void RemoveRow();
void RemoveColumn();
diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx b/chart2/source/controller/dialogs/DataBrowserModel.cxx
index decdda0f8793..c0b865536686 100644
--- a/chart2/source/controller/dialogs/DataBrowserModel.cxx
+++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx
@@ -40,6 +40,7 @@
#include "ContainerHelper.hxx"
#include "ChartTypeHelper.hxx"
#include "chartview/ExplicitValueProvider.hxx"
+#include "ExplicitCategoriesProvider.hxx"
#include <com/sun/star/container/XIndexReplace.hpp>
#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
@@ -51,6 +52,7 @@
#include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
#include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
#include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
#include <rtl/math.hxx>
@@ -322,6 +324,9 @@ void DataBrowserModel::insertDataSeries( sal_Int32 nAfterColumnIndex )
m_apDialogModel->getDataProvider(), uno::UNO_QUERY );
if( xDataProvider.is())
{
+ if( isCategoriesColumn(nAfterColumnIndex) )
+ nAfterColumnIndex = getCategoryColumnCount()-1;
+
sal_Int32 nStartCol = 0;
Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartDocument ));
Reference< chart2::XChartType > xChartType;
@@ -353,7 +358,7 @@ void DataBrowserModel::insertDataSeries( sal_Int32 nAfterColumnIndex )
{
sal_Int32 nOffset = 0;
if( xDiagram.is() && lcl_ShowCategories( xDiagram ))
- ++nOffset;
+ nOffset=getCategoryColumnCount();
// get shared sequences of current series
Reference< chart2::XDataSeriesContainer > xSeriesCnt( xChartType, uno::UNO_QUERY );
lcl_tSharedSeqVec aSharedSequences;
@@ -423,7 +428,31 @@ void DataBrowserModel::insertDataSeries( sal_Int32 nAfterColumnIndex )
}
}
-void DataBrowserModel::removeDataSeries( sal_Int32 nAtColumnIndex )
+void DataBrowserModel::insertComplexCategoryLevel( sal_Int32 nAfterColumnIndex )
+{
+ //create a new text column for complex categories
+
+ OSL_ASSERT( m_apDialogModel.get());
+ Reference< chart2::XInternalDataProvider > xDataProvider( m_apDialogModel->getDataProvider(), uno::UNO_QUERY );
+ if( xDataProvider.is() )
+ {
+ if( !isCategoriesColumn(nAfterColumnIndex) )
+ nAfterColumnIndex = getCategoryColumnCount()-1;
+
+ if(nAfterColumnIndex<0)
+ {
+ OSL_ENSURE( false, "wrong index for category level insertion" );
+ return;
+ }
+
+ m_apDialogModel->startControllerLockTimer();
+ ControllerLockGuard aLockedControllers( Reference< frame::XModel >( m_xChartDocument, uno::UNO_QUERY ) );
+ xDataProvider->insertComplexCategoryLevel( nAfterColumnIndex+1 );
+ updateFromModel();
+ }
+}
+
+void DataBrowserModel::removeDataSeriesOrComplexCategoryLevel( sal_Int32 nAtColumnIndex )
{
OSL_ASSERT( m_apDialogModel.get());
if( static_cast< tDataColumnVector::size_type >( nAtColumnIndex ) < m_aColumns.size())
@@ -474,6 +503,20 @@ void DataBrowserModel::removeDataSeries( sal_Int32 nAtColumnIndex )
}
updateFromModel();
}
+ else
+ {
+ //delete a category column if there is more than one level (in case of a single column we do not get here)
+ OSL_ENSURE(nAtColumnIndex>0, "wrong index for categories deletion" );
+
+ Reference< chart2::XInternalDataProvider > xDataProvider( m_apDialogModel->getDataProvider(), uno::UNO_QUERY );
+ if( xDataProvider.is() )
+ {
+ m_apDialogModel->startControllerLockTimer();
+ ControllerLockGuard aLockedControllers( Reference< frame::XModel >( m_xChartDocument, uno::UNO_QUERY ) );
+ xDataProvider->deleteComplexCategoryLevel( nAtColumnIndex );
+ updateFromModel();
+ }
+ }
}
}
@@ -614,6 +657,8 @@ bool DataBrowserModel::setCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow, const
bResult = true;
try
{
+ ControllerLockGuard aLockedControllers( Reference< frame::XModel >( m_xChartDocument, uno::UNO_QUERY ) );
+
// label
if( nAtRow == -1 )
{
@@ -627,6 +672,12 @@ bool DataBrowserModel::setCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow, const
m_aColumns[ nIndex ].m_xLabeledDataSequence->getValues(), uno::UNO_QUERY_THROW );
xIndexReplace->replaceByIndex( nAtRow, rValue );
}
+
+ m_apDialogModel->startControllerLockTimer();
+ //notify change directly to the model (this is necessary here as sequences for complex categories not known directly to the chart model so they do not notify their changes) (for complex categories see issue #i82971#)
+ Reference< util::XModifiable > xModifiable( m_xChartDocument, uno::UNO_QUERY );
+ if( xModifiable.is() )
+ xModifiable->setModified(true);
}
catch( const uno::Exception & ex )
{
@@ -683,11 +734,26 @@ OUString DataBrowserModel::getRoleOfColumn( sal_Int32 nColumnIndex ) const
return OUString();
}
-Reference< chart2::data::XLabeledDataSequence >
- DataBrowserModel::getCategories() const throw()
+bool DataBrowserModel::isCategoriesColumn( sal_Int32 nColumnIndex ) const
{
- OSL_ASSERT( m_apDialogModel.get());
- return m_apDialogModel->getCategories();
+ bool bIsCategories = false;
+ if( nColumnIndex>=0 && nColumnIndex<static_cast< sal_Int32 >(m_aColumns.size()) )
+ bIsCategories = !m_aColumns[ nColumnIndex ].m_xDataSeries.is();
+ return bIsCategories;
+}
+
+sal_Int32 DataBrowserModel::getCategoryColumnCount()
+{
+ sal_Int32 nLastTextColumnIndex = -1;
+ tDataColumnVector::const_iterator aIt = m_aColumns.begin();
+ for( ; aIt != m_aColumns.end(); ++aIt )
+ {
+ if( !aIt->m_xDataSeries.is() )
+ nLastTextColumnIndex++;
+ else
+ break;
+ }
+ return nLastTextColumnIndex+1;
}
const DataBrowserModel::tDataHeaderVector& DataBrowserModel::getDataHeaders() const
@@ -717,16 +783,27 @@ void DataBrowserModel::updateFromModel()
sal_Int32 nHeaderEnd = 0;
if( lcl_ShowCategories( xDiagram ))
{
- Reference< chart2::data::XLabeledDataSequence > xCategories( this->getCategories());
- tDataColumn aCategories;
- aCategories.m_xLabeledDataSequence.set( xCategories );
- if( lcl_ShowCategoriesAsDataLabel( xDiagram ))
- aCategories.m_aUIRoleName = DialogModel::GetRoleDataLabel();
- else
- aCategories.m_aUIRoleName = lcl_getUIRoleName( xCategories );
- aCategories.m_eCellType = TEXT;
- m_aColumns.push_back( aCategories );
- ++nHeaderStart;
+ Reference< frame::XModel > xChartModel( m_xChartDocument, uno::UNO_QUERY );
+ ExplicitCategoriesProvider aExplicitCategoriesProvider( ChartModelHelper::getFirstCoordinateSystem(xChartModel), xChartModel );
+
+ const Sequence< Reference< chart2::data::XLabeledDataSequence> >& rSplitCategoriesList( aExplicitCategoriesProvider.getSplitCategoriesList() );
+ sal_Int32 nLevelCount = rSplitCategoriesList.getLength();
+ for( sal_Int32 nL = 0; nL<nLevelCount; nL++ )
+ {
+ Reference< chart2::data::XLabeledDataSequence > xCategories( rSplitCategoriesList[nL] );
+ if( !xCategories.is() )
+ continue;
+
+ tDataColumn aCategories;
+ aCategories.m_xLabeledDataSequence.set( xCategories );
+ if( lcl_ShowCategoriesAsDataLabel( xDiagram ))
+ aCategories.m_aUIRoleName = DialogModel::GetRoleDataLabel();
+ else
+ aCategories.m_aUIRoleName = lcl_getUIRoleName( xCategories );
+ aCategories.m_eCellType = TEXT;
+ m_aColumns.push_back( aCategories );
+ ++nHeaderStart;
+ }
}
Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY );
diff --git a/chart2/source/controller/dialogs/DataBrowserModel.hxx b/chart2/source/controller/dialogs/DataBrowserModel.hxx
index 5b6a6e41c01b..a4378972f70f 100644
--- a/chart2/source/controller/dialogs/DataBrowserModel.hxx
+++ b/chart2/source/controller/dialogs/DataBrowserModel.hxx
@@ -60,10 +60,14 @@ public:
*/
void insertDataSeries( sal_Int32 nAfterColumnIndex );
+ /** Inserts a new text column for complex categories.
+ */
+ void insertComplexCategoryLevel( sal_Int32 nAfterColumnIndex );
+
/** Removes a data series to which the data column with index nAtColumnIndex
belongs.
*/
- void removeDataSeries( sal_Int32 nAtColumnIndex );
+ void removeDataSeriesOrComplexCategoryLevel( sal_Int32 nAtColumnIndex );
/** Swaps the series to which the data column with index nFirstIndex belongs
with the next series (which starts at an index >= nFirstIndex + 1)
@@ -97,6 +101,7 @@ public:
// returns the UI string of the corresponding role
::rtl::OUString getRoleOfColumn( sal_Int32 nColumnIndex ) const;
+ bool isCategoriesColumn( sal_Int32 nColumnIndex ) const;
struct tDataHeader
{
@@ -153,9 +158,7 @@ private:
sal_Int32 & rInOutSequenceIndex,
sal_Int32 & rInOutHeaderEnd );
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XLabeledDataSequence >
- getCategories() const throw();
+ sal_Int32 getCategoryColumnCount();
::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartDocument > m_xChartDocument;
diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx
index a8d9288e381f..f104045727bb 100644
--- a/chart2/source/controller/dialogs/DialogModel.cxx
+++ b/chart2/source/controller/dialogs/DialogModel.cxx
@@ -827,8 +827,6 @@ void DialogModel::applyInterpretedData(
DialogModel::setCategories(rNewData.Categories);
}
-
- OSL_ASSERT( ! rNewData.UnusedData.hasElements());
}
sal_Int32 DialogModel::countSeries() const
diff --git a/chart2/source/controller/dialogs/ObjectNameProvider.cxx b/chart2/source/controller/dialogs/ObjectNameProvider.cxx
index a29e91457c93..0836ab9ca93a 100644
--- a/chart2/source/controller/dialogs/ObjectNameProvider.cxx
+++ b/chart2/source/controller/dialogs/ObjectNameProvider.cxx
@@ -46,8 +46,6 @@
#include <tools/debug.hxx>
#include <tools/string.hxx>
-// #include <unotools/syslocale.hxx>
-
#include <com/sun/star/chart2/XTitle.hpp>
#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
@@ -197,7 +195,7 @@ OUString lcl_getDataPointValueText( const Reference< XDataSeries >& xSeries, sal
replaceParamterInString( aCategory
, C2U("%CATEGORYVALUE")
- , ExplicitCategoriesProvider::getCategoryByIndex( xCooSys, nPointIndex )
+ , ExplicitCategoriesProvider::getCategoryByIndex( xCooSys, xChartModel, nPointIndex )
);
aRet = aCategory;
diff --git a/chart2/source/controller/dialogs/ResourceIds.hrc b/chart2/source/controller/dialogs/ResourceIds.hrc
index 02edc1a6bd96..2ab544c77ab1 100644
--- a/chart2/source/controller/dialogs/ResourceIds.hrc
+++ b/chart2/source/controller/dialogs/ResourceIds.hrc
@@ -48,6 +48,8 @@
#define DLG_SPLINE_PROPERTIES 904
#define DLG_DATA_TRENDLINE 841
#define DLG_DATA_YERRORBAR 842
+#define DLG_SHAPE_FONT 921
+#define DLG_SHAPE_PARAGRAPH 922
//-----------------------------------------------------------------------------
//TabPage Ids:
diff --git a/chart2/source/controller/dialogs/Strings.src b/chart2/source/controller/dialogs/Strings.src
index 2d6fd9c04a66..4b4cec65426e 100644
--- a/chart2/source/controller/dialogs/Strings.src
+++ b/chart2/source/controller/dialogs/Strings.src
@@ -348,6 +348,11 @@ String STR_OBJECT_DIAGRAM_FLOOR
Text [ en-US ] = "Chart Floor" ;
};
+String STR_OBJECT_SHAPE
+{
+ Text [ en-US ] = "Drawing Object" ;
+};
+
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
diff --git a/chart2/source/controller/dialogs/dlg_DataEditor.cxx b/chart2/source/controller/dialogs/dlg_DataEditor.cxx
index 41539df061b9..f1d441921a6a 100644
--- a/chart2/source/controller/dialogs/dlg_DataEditor.cxx
+++ b/chart2/source/controller/dialogs/dlg_DataEditor.cxx
@@ -144,34 +144,22 @@ IMPL_LINK( DataEditor, ToolboxHdl, void *, EMPTYARG )
break;
case TBI_DATA_INSERT_COL:
m_apBrwData->InsertColumn();
-// ImplAdjustHeaderControls( true /* bRefreshFromModel */ );
+ break;
+ case TBI_DATA_INSERT_TEXT_COL:
+ m_apBrwData->InsertTextColumn();
break;
case TBI_DATA_DELETE_ROW:
m_apBrwData->RemoveRow();
break;
case TBI_DATA_DELETE_COL:
m_apBrwData->RemoveColumn();
-// ImplAdjustHeaderControls( true /* bRefreshFromModel */ );
break;
case TBI_DATA_SWAP_COL :
m_apBrwData->SwapColumn ();
-// ImplAdjustHeaderControls( true /* bRefreshFromModel */ );
break;
case TBI_DATA_SWAP_ROW :
m_apBrwData->SwapRow ();
break;
-// case TBI_DATA_SORT_COL :
-// m_apBrwData->QuickSortCol();
-// break;
-// case TBI_DATA_SORT_ROW :
-// m_apBrwData->QuickSortRow();
-// break;
-// case TBI_DATA_SORT_TABLE_COL :
-// m_apBrwData->QuickSortTableCols ();
-// break;
-// case TBI_DATA_SORT_TABLE_ROW :
-// m_apBrwData->QuickSortTableRows ();
-// break;
}
return 0;
@@ -183,27 +171,16 @@ IMPL_LINK( DataEditor, BrowserCursorMovedHdl, void *, EMPTYARG )
if( m_bReadOnly )
return 0;
- if( m_apBrwData->IsEnableItem() )
- {
- m_aTbxData.EnableItem( TBI_DATA_INSERT_ROW, m_apBrwData->MayInsertRow() );
- m_aTbxData.EnableItem( TBI_DATA_INSERT_COL, m_apBrwData->MayInsertColumn() );
- m_aTbxData.EnableItem( TBI_DATA_DELETE_ROW, m_apBrwData->MayDeleteRow() );
- m_aTbxData.EnableItem( TBI_DATA_DELETE_COL, m_apBrwData->MayDeleteColumn() );
+ bool bIsDataValid = m_apBrwData->IsEnableItem();
- m_aTbxData.EnableItem( TBI_DATA_SWAP_COL, m_apBrwData->MaySwapColumns() );
- m_aTbxData.EnableItem( TBI_DATA_SWAP_ROW, m_apBrwData->MaySwapRows() );
- }
- else
- {
- m_aTbxData.EnableItem( TBI_DATA_INSERT_ROW, FALSE );
- m_aTbxData.EnableItem( TBI_DATA_INSERT_COL, FALSE );
- m_aTbxData.EnableItem( TBI_DATA_SWAP_COL, FALSE );
- m_aTbxData.EnableItem( TBI_DATA_SWAP_ROW, FALSE );
- }
-// m_aTbxData.EnableItem( TBI_DATA_SORT_COL, m_apBrwData->MaySortColumn() );
-// m_aTbxData.EnableItem( TBI_DATA_SORT_ROW, m_apBrwData->MaySortRow() );
-// m_aTbxData.EnableItem( TBI_DATA_SORT_TABLE_COL, m_apBrwData->MaySortColumn() );
-// m_aTbxData.EnableItem( TBI_DATA_SORT_TABLE_ROW, m_apBrwData->MaySortRow() );
+ m_aTbxData.EnableItem( TBI_DATA_INSERT_ROW, bIsDataValid && m_apBrwData->MayInsertRow() );
+ m_aTbxData.EnableItem( TBI_DATA_INSERT_COL, bIsDataValid && m_apBrwData->MayInsertColumn() );
+ m_aTbxData.EnableItem( TBI_DATA_INSERT_TEXT_COL, bIsDataValid && m_apBrwData->MayInsertColumn() );
+ m_aTbxData.EnableItem( TBI_DATA_DELETE_ROW, m_apBrwData->MayDeleteRow() );
+ m_aTbxData.EnableItem( TBI_DATA_DELETE_COL, m_apBrwData->MayDeleteColumn() );
+
+ m_aTbxData.EnableItem( TBI_DATA_SWAP_COL, bIsDataValid && m_apBrwData->MaySwapColumns() );
+ m_aTbxData.EnableItem( TBI_DATA_SWAP_ROW, bIsDataValid && m_apBrwData->MaySwapRows() );
return 0;
}
@@ -216,14 +193,11 @@ void DataEditor::SetReadOnly( bool bReadOnly )
{
m_aTbxData.EnableItem( TBI_DATA_INSERT_ROW, FALSE );
m_aTbxData.EnableItem( TBI_DATA_INSERT_COL, FALSE );
+ m_aTbxData.EnableItem( TBI_DATA_INSERT_TEXT_COL, FALSE );
m_aTbxData.EnableItem( TBI_DATA_DELETE_ROW, FALSE );
m_aTbxData.EnableItem( TBI_DATA_DELETE_COL, FALSE );
m_aTbxData.EnableItem( TBI_DATA_SWAP_COL, FALSE );
m_aTbxData.EnableItem( TBI_DATA_SWAP_ROW, FALSE );
-// m_aTbxData.EnableItem( TBI_DATA_SORT_COL, FALSE );
-// m_aTbxData.EnableItem( TBI_DATA_SORT_ROW, FALSE );
-// m_aTbxData.EnableItem( TBI_DATA_SORT_TABLE_ROW, FALSE );
-// m_aTbxData.EnableItem( TBI_DATA_SORT_TABLE_COL, FALSE );
}
m_apBrwData->SetReadOnly( m_bReadOnly );
diff --git a/chart2/source/controller/dialogs/dlg_DataEditor.hrc b/chart2/source/controller/dialogs/dlg_DataEditor.hrc
index 8673f5e8cf80..d2675c5bb29e 100644
--- a/chart2/source/controller/dialogs/dlg_DataEditor.hrc
+++ b/chart2/source/controller/dialogs/dlg_DataEditor.hrc
@@ -33,19 +33,14 @@
#define CTL_DATA 1
// images for toolbox image list
+//the numbers correspond to the icon names: default_images\chart2\res\dataeditor_icon_xy
#define TBI_DATA_INSERT_ROW 1
#define TBI_DATA_INSERT_COL 2
#define TBI_DATA_DELETE_ROW 3
#define TBI_DATA_DELETE_COL 4
#define TBI_DATA_SWAP_COL 5
#define TBI_DATA_SWAP_ROW 6
-#define TBI_DATA_TRANSFER 7
-
-// #define TBI_DATA_SORT_ROW 7
-// #define TBI_DATA_SORT_COL 8
-// #define TBI_DATA_SORT_TABLE_ROW 9
-// #define TBI_DATA_SORT_TABLE_COL 10
-// #define TBI_DATA_TRANSFER 11
+#define TBI_DATA_INSERT_TEXT_COL 7
// image lists (normal and high-contrast) for toolbox
#define IL_DIAGRAM_DATA 1
diff --git a/chart2/source/controller/dialogs/dlg_DataEditor.src b/chart2/source/controller/dialogs/dlg_DataEditor.src
index ce774e8f5bd2..dadd1ac3098d 100644
--- a/chart2/source/controller/dialogs/dlg_DataEditor.src
+++ b/chart2/source/controller/dialogs/dlg_DataEditor.src
@@ -80,6 +80,12 @@ ModalDialog DLG_DIAGRAM_DATA
};
ToolBoxItem
{
+ HelpID = HID_SCH_TBI_DATA_INSERT_TEXT_COL ;
+ Identifier = TBI_DATA_INSERT_TEXT_COL ;
+ Text [ en-US ] = "Insert Text Column" ;
+ };
+ ToolBoxItem
+ {
HelpID = HID_SCH_TBI_DATA_DELETE_ROW ;
Identifier = TBI_DATA_DELETE_ROW ;
Text [ en-US ] = "Delete Row" ;
@@ -118,11 +124,11 @@ ModalDialog DLG_DIAGRAM_DATA
{ \
TBI_DATA_INSERT_ROW; \
TBI_DATA_INSERT_COL; \
+ TBI_DATA_INSERT_TEXT_COL; \
TBI_DATA_DELETE_ROW; \
TBI_DATA_DELETE_COL; \
TBI_DATA_SWAP_COL; \
TBI_DATA_SWAP_ROW; \
- TBI_DATA_TRANSFER; \
}; \
IdCount = { 7; }
diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx
index ec5f102bdaab..2a41d35313e8 100644
--- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx
+++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx
@@ -204,7 +204,7 @@ void ObjectPropertiesDialogParameter::init( const uno::Reference< frame::XModel
ScaleData aScale( xCrossingMainAxis->getScaleData() );
m_bIsCrossingAxisIsCategoryAxis = ( chart2::AxisType::CATEGORY == aScale.AxisType );
if( m_bIsCrossingAxisIsCategoryAxis )
- m_aCategories = DiagramHelper::generateAutomaticCategories( Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY) );
+ m_aCategories = DiagramHelper::getExplicitSimpleCategories( Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY) );
}
}
}
@@ -488,6 +488,8 @@ SchAttribTabDlg::SchAttribTabDlg(Window* pParent,
SchAlignmentTabPage::CreateWithoutRotation can be deleted. */
AddTabPage(TP_ALIGNMENT, String(SchResId(STR_PAGE_ALIGNMENT)), SchAlignmentTabPage::CreateWithoutRotation, NULL);
break;
+ default:
+ break;
}
// used to find out if user left the dialog with OK. When OK is pressed but
diff --git a/chart2/source/controller/dialogs/dlg_ShapeFont.cxx b/chart2/source/controller/dialogs/dlg_ShapeFont.cxx
new file mode 100644
index 000000000000..280a1adecba2
--- /dev/null
+++ b/chart2/source/controller/dialogs/dlg_ShapeFont.cxx
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * 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 "dlg_ShapeFont.hxx"
+#include "ViewElementListProvider.hxx"
+#include "ResId.hxx"
+#include "ResourceIds.hrc"
+
+#include <svl/intitem.hxx>
+#include <sfx2/objsh.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/flagsdef.hxx>
+#include <editeng/flstitem.hxx>
+
+using ::com::sun::star::uno::Reference;
+using namespace ::com::sun::star;
+
+//.............................................................................
+namespace chart
+{
+//.............................................................................
+
+ShapeFontDialog::ShapeFontDialog( Window* pParent, const SfxItemSet* pAttr,
+ const ViewElementListProvider* pViewElementListProvider )
+ :SfxTabDialog( pParent, SchResId( DLG_SHAPE_FONT ), pAttr )
+ ,m_pViewElementListProvider( pViewElementListProvider )
+{
+ FreeResource();
+
+ AddTabPage( RID_SVXPAGE_CHAR_NAME );
+ AddTabPage( RID_SVXPAGE_CHAR_EFFECTS );
+ AddTabPage( RID_SVXPAGE_CHAR_POSITION );
+}
+
+ShapeFontDialog::~ShapeFontDialog()
+{
+}
+
+void ShapeFontDialog::PageCreated( USHORT nId, SfxTabPage& rPage )
+{
+ SfxAllItemSet aSet( *( GetInputSetImpl()->GetPool() ) );
+ switch ( nId )
+ {
+ case RID_SVXPAGE_CHAR_NAME:
+ {
+ aSet.Put( SvxFontListItem( m_pViewElementListProvider->getFontList(), SID_ATTR_CHAR_FONTLIST ) );
+ rPage.PageCreated( aSet );
+ }
+ break;
+ case RID_SVXPAGE_CHAR_EFFECTS:
+ {
+ aSet.Put( SfxUInt16Item( SID_DISABLE_CTL, DISABLE_CASEMAP ) );
+ rPage.PageCreated( aSet );
+ }
+ break;
+ default:
+ {
+ }
+ break;
+ }
+}
+
+//.............................................................................
+} //namespace chart
+//.............................................................................
diff --git a/chart2/source/controller/dialogs/dlg_ShapeFont.src b/chart2/source/controller/dialogs/dlg_ShapeFont.src
new file mode 100644
index 000000000000..2065bd940988
--- /dev/null
+++ b/chart2/source/controller/dialogs/dlg_ShapeFont.src
@@ -0,0 +1,62 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+#include "ResourceIds.hrc"
+#include <svx/dialogs.hrc>
+
+TabDialog DLG_SHAPE_FONT
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 289 , 176 ) ;
+ Text [ en-US ] = "Character" ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ Pos = MAP_APPFONT ( 3 , 3 ) ;
+ Size = MAP_APPFONT ( 260 , 135 ) ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_CHAR_NAME ;
+ Text [ en-US ] = "Font";
+ };
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_CHAR_EFFECTS ;
+ Text [ en-US ] = "Font Effects";
+ };
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_CHAR_POSITION ;
+ Text [ en-US ] = "Font Position";
+ };
+ };
+ };
+};
diff --git a/chart2/source/controller/dialogs/dlg_ShapeParagraph.cxx b/chart2/source/controller/dialogs/dlg_ShapeParagraph.cxx
new file mode 100644
index 000000000000..2f0173fc8408
--- /dev/null
+++ b/chart2/source/controller/dialogs/dlg_ShapeParagraph.cxx
@@ -0,0 +1,93 @@
+/*************************************************************************
+ *
+ * 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 "dlg_ShapeParagraph.hxx"
+#include "ResId.hxx"
+#include "ResourceIds.hrc"
+
+#include <svl/cjkoptions.hxx>
+#include <svl/intitem.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/flagsdef.hxx>
+
+using ::com::sun::star::uno::Reference;
+using namespace ::com::sun::star;
+
+//.............................................................................
+namespace chart
+{
+//.............................................................................
+
+ShapeParagraphDialog::ShapeParagraphDialog( Window* pParent, const SfxItemSet* pAttr )
+ :SfxTabDialog( pParent, SchResId( DLG_SHAPE_PARAGRAPH ), pAttr )
+{
+ FreeResource();
+
+ SvtCJKOptions aCJKOptions;
+
+ AddTabPage( RID_SVXPAGE_STD_PARAGRAPH );
+ AddTabPage( RID_SVXPAGE_ALIGN_PARAGRAPH );
+ if ( aCJKOptions.IsAsianTypographyEnabled() )
+ {
+ AddTabPage( RID_SVXPAGE_PARA_ASIAN );
+ }
+ else
+ {
+ RemoveTabPage( RID_SVXPAGE_PARA_ASIAN );
+ }
+ AddTabPage( RID_SVXPAGE_TABULATOR );
+}
+
+ShapeParagraphDialog::~ShapeParagraphDialog()
+{
+}
+
+void ShapeParagraphDialog::PageCreated( USHORT nId, SfxTabPage& rPage )
+{
+ SfxAllItemSet aSet( *( GetInputSetImpl()->GetPool() ) );
+ switch ( nId )
+ {
+ case RID_SVXPAGE_TABULATOR:
+ {
+ aSet.Put( SfxUInt16Item( SID_SVXTABULATORTABPAGE_CONTROLFLAGS,
+ ( TABTYPE_ALL &~TABTYPE_LEFT ) | ( TABFILL_ALL &~TABFILL_NONE ) ) );
+ rPage.PageCreated( aSet );
+ }
+ break;
+ default:
+ {
+ }
+ break;
+ }
+}
+
+//.............................................................................
+} //namespace chart
+//.............................................................................
diff --git a/chart2/source/controller/dialogs/dlg_ShapeParagraph.src b/chart2/source/controller/dialogs/dlg_ShapeParagraph.src
new file mode 100644
index 000000000000..ff74fc1eef80
--- /dev/null
+++ b/chart2/source/controller/dialogs/dlg_ShapeParagraph.src
@@ -0,0 +1,67 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+#include "ResourceIds.hrc"
+#include <svx/dialogs.hrc>
+
+TabDialog DLG_SHAPE_PARAGRAPH
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 289 , 176 ) ;
+ Text [ en-US ] = "Paragraph" ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ Pos = MAP_APPFONT ( 3 , 3 ) ;
+ Size = MAP_APPFONT ( 260 , 135 ) ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_STD_PARAGRAPH ;
+ Text [ en-US ] = "Indents & Spacing";
+ };
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_ALIGN_PARAGRAPH ;
+ Text [ en-US ] = "Alignment";
+ };
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_PARA_ASIAN ;
+ Text [ en-US ] = "Asian Typography";
+ };
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_TABULATOR ;
+ Text [ en-US ] = "Tab";
+ };
+ };
+ };
+};
diff --git a/chart2/source/controller/dialogs/makefile.mk b/chart2/source/controller/dialogs/makefile.mk
index 955c1764b5aa..d22f5c83b081 100644
--- a/chart2/source/controller/dialogs/makefile.mk
+++ b/chart2/source/controller/dialogs/makefile.mk
@@ -98,6 +98,8 @@ SLOFILES= \
$(SLO)$/dlg_ChartType_UNO.obj \
$(SLO)$/dlg_ChartType.obj \
$(SLO)$/dlg_NumberFormat.obj \
+ $(SLO)$/dlg_ShapeFont.obj \
+ $(SLO)$/dlg_ShapeParagraph.obj \
$(SLO)$/RangeSelectionButton.obj \
$(SLO)$/RangeSelectionHelper.obj \
$(SLO)$/RangeSelectionListener.obj \
@@ -150,7 +152,9 @@ SRC1FILES= \
dlg_InsertErrorBars.src \
dlg_InsertTitle.src \
dlg_ChartType.src \
- dlg_CreationWizard.src
+ dlg_CreationWizard.src \
+ dlg_ShapeFont.src \
+ dlg_ShapeParagraph.src
SRS1NAME=$(TARGET)
diff --git a/chart2/source/controller/dialogs/tp_ChartType.cxx b/chart2/source/controller/dialogs/tp_ChartType.cxx
index f4b314de8a40..244d23ed8eff 100644
--- a/chart2/source/controller/dialogs/tp_ChartType.cxx
+++ b/chart2/source/controller/dialogs/tp_ChartType.cxx
@@ -987,8 +987,8 @@ IMPL_LINK( ChartTypeTabPage, SelectMainTypeHdl, void *, EMPTYARG )
commitToModel( aParameter );
//detect the new ThreeDLookScheme
aParameter.eThreeDLookScheme = ThreeDHelper::detectScheme( ChartModelHelper::findDiagram( m_xChartModel ) );
- if(!aParameter.b3DLook && aParameter.eThreeDLookScheme!=ThreeDLookScheme_Simple )
- aParameter.eThreeDLookScheme=ThreeDLookScheme_Simple;
+ if(!aParameter.b3DLook && aParameter.eThreeDLookScheme!=ThreeDLookScheme_Realistic )
+ aParameter.eThreeDLookScheme=ThreeDLookScheme_Realistic;
aParameter.bSortByXValues = lcl_getSortByXValues( m_xChartModel );
this->fillAllControls( aParameter );
@@ -1109,8 +1109,8 @@ void ChartTypeTabPage::initializePage()
//set ThreeDLookScheme
aParameter.eThreeDLookScheme = ThreeDHelper::detectScheme( xDiagram );
- if(!aParameter.b3DLook && aParameter.eThreeDLookScheme!=ThreeDLookScheme_Simple )
- aParameter.eThreeDLookScheme=ThreeDLookScheme_Simple;
+ if(!aParameter.b3DLook && aParameter.eThreeDLookScheme!=ThreeDLookScheme_Realistic )
+ aParameter.eThreeDLookScheme=ThreeDLookScheme_Realistic;
aParameter.bSortByXValues = lcl_getSortByXValues( m_xChartModel );
diff --git a/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx b/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx
index 299cd9efe859..fbcca6a26bde 100644
--- a/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx
+++ b/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx
@@ -31,6 +31,8 @@
#include "chartview/DrawModelWrapper.hxx"
#include "ConfigurationAccess.hxx"
+#include <unotools/lingucfg.hxx>
+#include <editeng/langitem.hxx>
// header for class SdrPage
#include <svx/svdpage.hxx>
//header for class SdrPageView
@@ -51,6 +53,7 @@
// header for class SvxShape
#include <svx/unoshape.hxx>
+#include <editeng/fhgtitem.hxx>
#include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
@@ -162,6 +165,24 @@ DrawViewWrapper::DrawViewWrapper( SdrModel* pSdrModel, OutputDevice* pOut, bool
SetPagePaintingAllowed(bPaintPageForEditMode);
+ // #i12587# support for shapes in chart
+ SdrOutliner* pOutliner = getOutliner();
+ SfxItemPool* pOutlinerPool = ( pOutliner ? pOutliner->GetEditTextObjectPool() : NULL );
+ if ( pOutlinerPool )
+ {
+ SvtLinguConfig aLinguConfig;
+ SvtLinguOptions aLinguOptions;
+ if ( aLinguConfig.GetOptions( aLinguOptions ) )
+ {
+ pOutlinerPool->SetPoolDefaultItem( SvxLanguageItem( aLinguOptions.nDefaultLanguage, EE_CHAR_LANGUAGE ) );
+ pOutlinerPool->SetPoolDefaultItem( SvxLanguageItem( aLinguOptions.nDefaultLanguage_CJK, EE_CHAR_LANGUAGE_CJK ) );
+ pOutlinerPool->SetPoolDefaultItem( SvxLanguageItem( aLinguOptions.nDefaultLanguage_CTL, EE_CHAR_LANGUAGE_CTL ) );
+ }
+
+ // set font height without changing SdrEngineDefaults
+ pOutlinerPool->SetPoolDefaultItem( SvxFontHeightItem( 423, 100, EE_CHAR_FONTHEIGHT ) ); // 12pt
+ }
+
ReInit();
}
diff --git a/chart2/source/controller/inc/AccessibleBase.hxx b/chart2/source/controller/inc/AccessibleBase.hxx
index 46d63927a9d7..ea52a29c614b 100644
--- a/chart2/source/controller/inc/AccessibleBase.hxx
+++ b/chart2/source/controller/inc/AccessibleBase.hxx
@@ -27,6 +27,8 @@
#ifndef _CHART2_ACCESSIBLEBASE_HXX_
#define _CHART2_ACCESSIBLEBASE_HXX_
+#include "ObjectIdentifier.hxx"
+
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/accessibility/XAccessible.hpp>
#include <com/sun/star/accessibility/XAccessibleContext.hpp>
@@ -50,6 +52,12 @@
class SfxItemSet;
class SdrObject;
+class SdrView;
+
+namespace accessibility
+{
+class IAccessibleViewForwarder;
+}
namespace chart
{
@@ -57,11 +65,11 @@ namespace chart
class AccessibleBase;
class ObjectHierarchy;
-typedef rtl::OUString AccessibleUniqueId;
+typedef ObjectIdentifier AccessibleUniqueId;
struct AccessibleElementInfo
{
- AccessibleUniqueId m_aCID;
+ AccessibleUniqueId m_aOID;
::com::sun::star::uno::WeakReference<
::com::sun::star::chart2::XChartDocument > m_xChartDocument;
@@ -75,6 +83,8 @@ struct AccessibleElementInfo
::boost::shared_ptr< ObjectHierarchy > m_spObjectHierarchy;
AccessibleBase * m_pParent;
+ SdrView* m_pSdrView;
+ ::accessibility::IAccessibleViewForwarder* m_pViewForwarder;
};
@@ -173,7 +183,7 @@ protected:
greater than the index of the removed element get an index one less than
before.
*/
- void RemoveChildById( const ::rtl::OUString & rId );
+ void RemoveChildByOId( const ObjectIdentifier& rOId );
/** Retrieve the pixel coordinates of logical coordinates (0,0) of the
current logic coordinate system. This can be used for
@@ -325,14 +335,14 @@ private:
/** type of the hash containing a vector index for every AccessibleUniqueId
of the object in the child list
*/
- typedef ::std::map< ::rtl::OUString, tAccessible > ChildCIDMap;
+ typedef ::std::map< ObjectIdentifier, tAccessible > ChildOIDMap;
bool m_bIsDisposed;
const bool m_bMayHaveChildren;
bool m_bChildrenInitialized;
ChildListVectorType m_aChildList;
- ChildCIDMap m_aChildCIDMap;
+ ChildOIDMap m_aChildOIDMap;
::comphelper::AccessibleEventNotifier::TClientId m_nEventNotifierId;
diff --git a/chart2/source/controller/inc/AccessibleChartView.hxx b/chart2/source/controller/inc/AccessibleChartView.hxx
index 435871dbf55a..2cc46825a5aa 100644
--- a/chart2/source/controller/inc/AccessibleChartView.hxx
+++ b/chart2/source/controller/inc/AccessibleChartView.hxx
@@ -44,13 +44,17 @@
#include <boost/shared_ptr.hpp>
+namespace accessibility
+{
+class IAccessibleViewForwarder;
+}
+
//.............................................................................
namespace chart
{
//.............................................................................
class ExplicitValueProvider;
-class ObjectHierarchy;
namespace impl
{
@@ -67,14 +71,9 @@ class AccessibleChartView :
public:
AccessibleChartView(
const ::com::sun::star::uno::Reference<
- ::com::sun::star::uno::XComponentContext > & xContext );
+ ::com::sun::star::uno::XComponentContext >& xContext, SdrView* pView );
virtual ~AccessibleChartView();
- // ____ lang::XServiceInfo ____
- APPHELPER_XSERVICEINFO_DECL()
- APPHELPER_SERVICE_FACTORY_HELPER( AccessibleChartView )
-
-protected:
// ____ WeakComponentHelper (called from XComponent::dispose()) ____
virtual void SAL_CALL disposing();
@@ -112,6 +111,7 @@ protected:
virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds() throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen() throw (::com::sun::star::uno::RuntimeException);
+protected:
// ________ AccessibleChartElement ________
virtual ::com::sun::star::awt::Point GetUpperLeftOnScreen() const;
@@ -141,7 +141,9 @@ private: // members
::com::sun::star::accessibility::XAccessible > m_xParent;
::boost::shared_ptr< ObjectHierarchy > m_spObjectHierarchy;
- AccessibleUniqueId m_aCurrentSelectionCID;
+ AccessibleUniqueId m_aCurrentSelectionOID;
+ SdrView* m_pSdrView;
+ ::accessibility::IAccessibleViewForwarder* m_pViewForwarder;
//no default constructor
AccessibleChartView();
diff --git a/chart2/source/controller/inc/HelpIds.hrc b/chart2/source/controller/inc/HelpIds.hrc
index 88cd1619bab8..1052b7ea962f 100644
--- a/chart2/source/controller/inc/HelpIds.hrc
+++ b/chart2/source/controller/inc/HelpIds.hrc
@@ -29,6 +29,7 @@
#include <svl/solar.hrc>
//next is 120
+//free: 20, 21, 22, 30, 31, 32, 33
//see old chart: schhids.h
@@ -61,21 +62,13 @@
//#define HID_SCH_CT_INDICATE2 (HID_SCH_START + 18)
//#define HID_SCH_CT_REGRESS2 (HID_SCH_START + 19)
-//#define HID_SCH_TBI_EDIT_CANCEL (HID_SCH_START + 20)
-//#define HID_SCH_TBI_EDIT_ACCEPT (HID_SCH_START + 21)
-#define HID_SCH_TBI_DATA_TRANSFER (HID_SCH_START + 22)
#define HID_SCH_TBI_DATA_INSERT_ROW (HID_SCH_START + 23)
#define HID_SCH_TBI_DATA_INSERT_COL (HID_SCH_START + 24)
#define HID_SCH_TBI_DATA_DELETE_ROW (HID_SCH_START + 25)
#define HID_SCH_TBI_DATA_DELETE_COL (HID_SCH_START + 26)
#define HID_SCH_TBI_DATA_SWAP_COL (HID_SCH_START + 27)
#define HID_SCH_TBI_DATA_SWAP_ROW (HID_SCH_START + 28)
-//#define HID_SCH_TBI_DATA_SORT_ROW (HID_SCH_START + 29)
-//#define HID_SCH_TBI_DATA_SORT_COL (HID_SCH_START + 30)
-//#define HID_SCH_TBI_DATA_SORT_TABLE_ROW (HID_SCH_START + 31)
-//#define HID_SCH_TBI_DATA_SORT_TABLE_COL (HID_SCH_START + 32)
-
-// #define HID_SCH_TBX_EDIT (HID_SCH_START + 33)
+#define HID_SCH_TBI_DATA_INSERT_TEXT_COL (HID_SCH_START + 29)
#define HID_SCH_TBX_DATA (HID_SCH_START + 34)
#define HID_SCH_ALIGNMENT_CTR_DIAL (HID_SCH_START + 35)
diff --git a/sc/inc/eetext.hxx b/chart2/source/controller/inc/MenuResIds.hrc
index 28ee0d5f09b2..38a09ad35ded 100644
--- a/sc/inc/eetext.hxx
+++ b/chart2/source/controller/inc/MenuResIds.hrc
@@ -24,10 +24,18 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+#ifndef CHART_MENURESIDS_HRC
+#define CHART_MENURESIDS_HRC
-#ifndef SC_EETEXT_HXX
-#define SC_EETEXT_HXX
-
+#ifndef _SOLAR_HRC
+#include <svl/solar.hrc>
#endif
+//-----------------------------------------------------------------------------
+// context menus
+
+#define RID_CONTEXTMENU_SHAPE (RID_APP_START + 1)
+#define RID_CONTEXTMENU_SHAPEEDIT (RID_APP_START + 2)
+// CHART_MENURESIDS_HRC
+#endif
diff --git a/chart2/source/controller/inc/ObjectHierarchy.hxx b/chart2/source/controller/inc/ObjectHierarchy.hxx
index f012fb500416..857b576fe6ef 100644
--- a/chart2/source/controller/inc/ObjectHierarchy.hxx
+++ b/chart2/source/controller/inc/ObjectHierarchy.hxx
@@ -27,6 +27,8 @@
#ifndef CHART2_OBJECTHIERARCHY_HXX
#define CHART2_OBJECTHIERARCHY_HXX
+#include "ObjectIdentifier.hxx"
+
#include <rtl/ustring.hxx>
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/awt/KeyEvent.hpp>
@@ -47,8 +49,8 @@ class ImplObjectHierarchy;
class ObjectHierarchy
{
public:
- typedef ::rtl::OUString tCID;
- typedef ::std::vector< tCID > tChildContainer;
+ typedef ObjectIdentifier tOID;
+ typedef ::std::vector< tOID > tChildContainer;
/** @param bFlattenDiagram
If <TRUE/>, the content of the diaram (data series, wall, floor,
@@ -63,20 +65,20 @@ public:
bool bOrderingForElementSelector = false );
~ObjectHierarchy();
- static tCID getRootNodeCID();
- static bool isRootNode( const tCID & rCID );
+ static tOID getRootNodeOID();
+ static bool isRootNode( const tOID& rOID );
- /// equal to getChildren( getRootNodeCID())
+ /// equal to getChildren( getRootNodeOID())
tChildContainer getTopLevelChildren() const;
- bool hasChildren( const tCID & rParent ) const;
- tChildContainer getChildren( const tCID & rParent ) const;
+ bool hasChildren( const tOID& rParent ) const;
+ tChildContainer getChildren( const tOID& rParent ) const;
- tChildContainer getSiblings( const tCID & rNode ) const;
+ tChildContainer getSiblings( const tOID& rNode ) const;
/// The result is empty, if the node cannot be found in the tree
- tCID getParent( const tCID & rNode ) const;
+ tOID getParent( const tOID& rNode ) const;
/// @returns -1, if no parent can be determined
- sal_Int32 getIndexInParent( const tCID & rNode ) const;
+ sal_Int32 getIndexInParent( const tOID& rNode ) const;
private:
@@ -86,16 +88,16 @@ private:
class ObjectKeyNavigation
{
public:
- explicit ObjectKeyNavigation( const ObjectHierarchy::tCID & rCurrentCID,
+ explicit ObjectKeyNavigation( const ObjectHierarchy::tOID & rCurrentOID,
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartDocument > & xChartDocument,
ExplicitValueProvider * pExplicitValueProvider = 0 );
bool handleKeyEvent( const ::com::sun::star::awt::KeyEvent & rEvent );
- ObjectHierarchy::tCID getCurrentSelection() const;
+ ObjectHierarchy::tOID getCurrentSelection() const;
private:
- void setCurrentSelection( const ObjectHierarchy::tCID & rCID );
+ void setCurrentSelection( const ObjectHierarchy::tOID& rOID );
bool first();
bool last();
bool next();
@@ -105,7 +107,7 @@ private:
bool veryFirst();
bool veryLast();
- ObjectHierarchy::tCID m_aCurrentCID;
+ ObjectHierarchy::tOID m_aCurrentOID;
::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartDocument > m_xChartDocument;
ExplicitValueProvider * m_pExplicitValueProvider;
diff --git a/chart2/source/controller/inc/ShapeController.hrc b/chart2/source/controller/inc/ShapeController.hrc
new file mode 100644
index 000000000000..6c7b43526d22
--- /dev/null
+++ b/chart2/source/controller/inc/ShapeController.hrc
@@ -0,0 +1,50 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef CHART_SHAPECONTROLLER_HRC
+#define CHART_SHAPECONTROLLER_HRC
+
+//-----------------------------------------------------------------------------
+//Command Ids:
+#define COMMAND_ID_FORMAT_LINE 1
+#define COMMAND_ID_FORMAT_AREA 2
+#define COMMAND_ID_TEXT_ATTRIBUTES 3
+#define COMMAND_ID_TRANSFORM_DIALOG 4
+#define COMMAND_ID_OBJECT_TITLE_DESCRIPTION 5
+#define COMMAND_ID_RENAME_OBJECT 6
+#define COMMAND_ID_ARRANGE_ROW 7
+#define COMMAND_ID_BRING_TO_FRONT 8
+#define COMMAND_ID_FORWARD 9
+#define COMMAND_ID_BACKWARD 10
+#define COMMAND_ID_SEND_TO_BACK 11
+#define COMMAND_ID_CUT 12
+#define COMMAND_ID_COPY 13
+#define COMMAND_ID_PASTE 14
+#define COMMAND_ID_FONT_DIALOG 15
+#define COMMAND_ID_PARAGRAPH_DIALOG 16
+
+// CHART_SHAPECONTROLLER_HRC
+#endif
diff --git a/chart2/source/controller/inc/dlg_ShapeFont.hxx b/chart2/source/controller/inc/dlg_ShapeFont.hxx
new file mode 100644
index 000000000000..ec1b6553bd64
--- /dev/null
+++ b/chart2/source/controller/inc/dlg_ShapeFont.hxx
@@ -0,0 +1,59 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef CHART2_DLG_SHAPEFONT_HXX
+#define CHART2_DLG_SHAPEFONT_HXX
+
+#include <sfx2/tabdlg.hxx>
+
+//.............................................................................
+namespace chart
+{
+//.............................................................................
+
+class ViewElementListProvider;
+
+/** dialog for font properties of shapes
+ */
+class ShapeFontDialog : public SfxTabDialog
+{
+public:
+ ShapeFontDialog( Window* pParent, const SfxItemSet* pAttr,
+ const ViewElementListProvider* pViewElementListProvider );
+ virtual ~ShapeFontDialog();
+
+private:
+ virtual void PageCreated( USHORT nId, SfxTabPage& rPage );
+
+ const ViewElementListProvider* m_pViewElementListProvider;
+};
+
+//.............................................................................
+} // namespace chart
+//.............................................................................
+
+// CHART2_DLG_SHAPEFONT_HXX
+#endif
diff --git a/chart2/source/controller/inc/dlg_ShapeParagraph.hxx b/chart2/source/controller/inc/dlg_ShapeParagraph.hxx
new file mode 100644
index 000000000000..2bc57bfcffc2
--- /dev/null
+++ b/chart2/source/controller/inc/dlg_ShapeParagraph.hxx
@@ -0,0 +1,54 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef CHART2_DLG_SHAPEPARAGRAPH_HXX
+#define CHART2_DLG_SHAPEPARAGRAPH_HXX
+
+#include <sfx2/tabdlg.hxx>
+
+//.............................................................................
+namespace chart
+{
+//.............................................................................
+
+/** dialog for paragraph properties of shapes
+ */
+class ShapeParagraphDialog : public SfxTabDialog
+{
+public:
+ ShapeParagraphDialog( Window* pParent, const SfxItemSet* pAttr );
+ virtual ~ShapeParagraphDialog();
+
+private:
+ virtual void PageCreated( USHORT nId, SfxTabPage& rPage );
+};
+
+//.............................................................................
+} // namespace chart
+//.............................................................................
+
+// CHART2_DLG_SHAPEPARAGRAPH_HXX
+#endif
diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx
index c2202b031a17..4c0c7dc38ae3 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -50,6 +50,10 @@
#include "dlg_CreationWizard.hxx"
#include "dlg_ChartType.hxx"
//#include "svx/ActionDescriptionProvider.hxx"
+#include "AccessibleChartView.hxx"
+#include "DrawCommandDispatch.hxx"
+#include "ShapeController.hxx"
+#include "UndoManager.hxx"
#include <comphelper/InlineContainer.hxx>
@@ -97,6 +101,7 @@ namespace chart
//.............................................................................
using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
using namespace ::com::sun::star::chart2;
using ::com::sun::star::uno::Any;
using ::com::sun::star::uno::Reference;
@@ -124,7 +129,8 @@ ChartController::ChartController(uno::Reference<uno::XComponentContext> const &
, m_bWaitingForMouseUp(false)
, m_bConnectingToView(false)
, m_xUndoManager( 0 )
- , m_aDispatchContainer( m_xCC )
+ , m_aDispatchContainer( m_xCC, this )
+ , m_eDrawMode( CHARTDRAW_SELECT )
{
DBG_CTOR(ChartController,NULL);
// m_aDispatchContainer.setUndoManager( m_xUndoManager );
@@ -438,6 +444,11 @@ APPHELPER_XSERVICEINFO_IMPL(ChartController,CHART_CONTROLLER_SERVICE_IMPLEMENTAT
//@todo: createElement should become unnecessary, remove when #i79198# is fixed
xLayoutManager->createElement( C2U( "private:resource/toolbar/toolbar" ) );
xLayoutManager->requestElement( C2U( "private:resource/toolbar/toolbar" ) );
+
+ // #i12587# support for shapes in chart
+ xLayoutManager->createElement( C2U( "private:resource/toolbar/drawbar" ) );
+ xLayoutManager->requestElement( C2U( "private:resource/toolbar/drawbar" ) );
+
xLayoutManager->requestElement( C2U( "private:resource/statusbar/statusbar" ) );
xLayoutManager->unlock();
@@ -559,13 +570,27 @@ void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent
// set new model at dispatchers
m_aDispatchContainer.setModel( aNewModelRef->getModel());
- ControllerCommandDispatch * pDispatch = new ControllerCommandDispatch( m_xCC, this );
+ ControllerCommandDispatch * pDispatch = new ControllerCommandDispatch( m_xCC, this, &m_aDispatchContainer );
pDispatch->initialize();
// the dispatch container will return "this" for all commands returned by
// impl_getAvailableCommands(). That means, for those commands dispatch()
// is called here at the ChartController.
- m_aDispatchContainer.setFallbackDispatch( pDispatch, impl_getAvailableCommands() );
+ m_aDispatchContainer.setChartDispatch( pDispatch, impl_getAvailableCommands() );
+
+ DrawCommandDispatch* pDrawDispatch = new DrawCommandDispatch( m_xCC, this );
+ if ( pDrawDispatch )
+ {
+ pDrawDispatch->initialize();
+ m_aDispatchContainer.setDrawCommandDispatch( pDrawDispatch );
+ }
+
+ ShapeController* pShapeController = new ShapeController( m_xCC, this );
+ if ( pShapeController )
+ {
+ pShapeController->initialize();
+ m_aDispatchContainer.setShapeController( pShapeController );
+ }
#ifdef TEST_ENABLE_MODIFY_LISTENER
uno::Reference< util::XModifyBroadcaster > xMBroadcaster( aNewModelRef->getModel(),uno::UNO_QUERY );
@@ -1061,7 +1086,7 @@ bool lcl_isFormatObjectCommand( const rtl::OString& aCommand )
void SAL_CALL ChartController
::dispatch( const util::URL& rURL
- , const uno::Sequence< beans::PropertyValue >& /* rArgs */ )
+ , const uno::Sequence< beans::PropertyValue >& rArgs )
throw (uno::RuntimeException)
{
//@todo avoid OString (see Mathias mail on bug #104387#)
@@ -1161,7 +1186,16 @@ bool lcl_isFormatObjectCommand( const rtl::OString& aCommand )
else if( aCommand.equals("FormatSelection") )
this->executeDispatch_ObjectProperties();
else if( aCommand.equals("TransformDialog"))
- this->executeDispatch_PositionAndSize();
+ {
+ if ( isShapeContext() )
+ {
+ this->impl_ShapeControllerDispatch( rURL, rArgs );
+ }
+ else
+ {
+ this->executeDispatch_PositionAndSize();
+ }
+ }
else if( lcl_isFormatObjectCommand(aCommand) )
this->executeDispatch_FormatObject(rURL.Path);
//more format
@@ -1171,10 +1205,28 @@ bool lcl_isFormatObjectCommand( const rtl::OString& aCommand )
this->executeDispatch_ChartType();
else if( aCommand.equals("View3D"))
this->executeDispatch_View3D();
- else if( aCommand.equals("Forward"))
- this->executeDispatch_MoveSeries( sal_True );
- else if( aCommand.equals("Backward"))
- this->executeDispatch_MoveSeries( sal_False );
+ else if ( aCommand.equals( "Forward" ) )
+ {
+ if ( isShapeContext() )
+ {
+ this->impl_ShapeControllerDispatch( rURL, rArgs );
+ }
+ else
+ {
+ this->executeDispatch_MoveSeries( sal_True );
+ }
+ }
+ else if ( aCommand.equals( "Backward" ) )
+ {
+ if ( isShapeContext() )
+ {
+ this->impl_ShapeControllerDispatch( rURL, rArgs );
+ }
+ else
+ {
+ this->executeDispatch_MoveSeries( sal_False );
+ }
+ }
else if( aCommand.equals("NewArrangement"))
this->executeDispatch_NewArrangement();
else if( aCommand.equals("ToggleLegend"))
@@ -1390,6 +1442,20 @@ void SAL_CALL ChartController::modified( const lang::EventObject& /* aEvent */ )
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
+IMPL_LINK( ChartController, NotifyUndoActionHdl, SdrUndoAction*, pUndoAction )
+{
+ ::rtl::OUString aObjectCID = m_aSelection.getSelectedCID();
+ if ( aObjectCID.getLength() == 0 )
+ {
+ UndoManager* pUndoManager = UndoManager::getImplementation( m_xUndoManager );
+ if ( pUndoManager )
+ {
+ pUndoManager->addShapeUndoAction( pUndoAction );
+ }
+ }
+ return 0L;
+}
+
DrawModelWrapper* ChartController::GetDrawModelWrapper()
{
if( !m_pDrawModelWrapper.get() )
@@ -1397,16 +1463,26 @@ DrawModelWrapper* ChartController::GetDrawModelWrapper()
ExplicitValueProvider* pProvider = ExplicitValueProvider::getExplicitValueProvider( m_xChartView );
if( pProvider )
m_pDrawModelWrapper = pProvider->getDrawModelWrapper();
+ if ( m_pDrawModelWrapper.get() )
+ {
+ m_pDrawModelWrapper->getSdrModel().SetNotifyUndoActionHdl( LINK( this, ChartController, NotifyUndoActionHdl ) );
+ }
}
return m_pDrawModelWrapper.get();
}
-uno::Reference< accessibility::XAccessible > ChartController::CreateAccessible()
+DrawViewWrapper* ChartController::GetDrawViewWrapper()
{
- uno::Reference< accessibility::XAccessible > xResult(
- m_xCC->getServiceManager()->createInstanceWithContext(
- CHART2_ACCESSIBLE_SERVICE_NAME, m_xCC ), uno::UNO_QUERY );
+ if ( !m_pDrawViewWrapper )
+ {
+ impl_createDrawViewController();
+ }
+ return m_pDrawViewWrapper;
+}
+uno::Reference< XAccessible > ChartController::CreateAccessible()
+{
+ uno::Reference< XAccessible > xResult = new AccessibleChartView( m_xCC, GetDrawViewWrapper() );
impl_initializeAccessible( uno::Reference< lang::XInitialization >( xResult, uno::UNO_QUERY ) );
return xResult;
}
@@ -1438,7 +1514,7 @@ void ChartController::impl_initializeAccessible( const uno::Reference< lang::XIn
uno::Reference<frame::XModel> xModel(m_aModel->getModel());
aArguments[1]=uno::makeAny(xModel);
aArguments[2]=uno::makeAny(m_xChartView);
- uno::Reference< accessibility::XAccessible > xParent;
+ uno::Reference< XAccessible > xParent;
if( m_pChartWindow )
{
Window* pParentWin( m_pChartWindow->GetAccessibleParentWindow());
diff --git a/chart2/source/controller/main/ChartController.hxx b/chart2/source/controller/main/ChartController.hxx
index 130e40cb6828..8deffe47396f 100644
--- a/chart2/source/controller/main/ChartController.hxx
+++ b/chart2/source/controller/main/ChartController.hxx
@@ -57,6 +57,7 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/util/XModifyListener.hpp>
#include <com/sun/star/util/XModeChangeListener.hpp>
+#include <com/sun/star/awt/Point.hpp>
#include <com/sun/star/awt/Size.hpp>
#include <com/sun/star/util/XURLTransformer.hpp>
#include <com/sun/star/frame/XLayoutManagerListener.hpp>
@@ -88,6 +89,8 @@ namespace chart
{
//.............................................................................
+enum ChartDrawMode { CHARTDRAW_INSERT, CHARTDRAW_SELECT };
+
class WindowController
{
public:
@@ -155,6 +158,9 @@ class ChartController : public ::cppu::WeakImplHelper12 <
>
, public WindowController
{
+ friend class DrawCommandDispatch;
+ friend class ShapeController;
+
public:
//no default constructor
ChartController(::com::sun::star::uno::Reference<
@@ -463,6 +469,13 @@ public:
static bool isObjectDeleteable( const ::com::sun::star::uno::Any& rSelection );
+ void setDrawMode( ChartDrawMode eMode ) { m_eDrawMode = eMode; }
+ ChartDrawMode getDrawMode() const { return m_eDrawMode; }
+
+ bool isShapeContext() const;
+
+ DECL_LINK( NotifyUndoActionHdl, SdrUndoAction* );
+
public:
//-----------------------------------------------------------------
//-----------------------------------------------------------------
@@ -477,6 +490,7 @@ public:
private:
DrawModelWrapper* GetDrawModelWrapper();
+ DrawViewWrapper* GetDrawViewWrapper();
private:
class TheModelRef;
@@ -577,6 +591,8 @@ private:
::com::sun::star::frame::XLayoutManagerEventBroadcaster >
m_xLayoutManagerEventBroadcaster;
+ ChartDrawMode m_eDrawMode;
+
private:
//private methods
@@ -637,11 +653,11 @@ private:
void executeDispatch_DeleteMinorGrid();
void SAL_CALL executeDispatch_InsertSpecialCharacter();
- void SAL_CALL executeDispatch_EditText();
+ void SAL_CALL executeDispatch_EditText( const Point* pMousePixel = NULL );
void SAL_CALL executeDispatch_SourceData();
void SAL_CALL executeDispatch_MoveSeries( sal_Bool bForward );
- void StartTextEdit();
+ void StartTextEdit( const Point* pMousePixel = NULL );
bool EndTextEdit();
void SAL_CALL executeDispatch_View3D();
@@ -659,9 +675,12 @@ private:
void executeDispatch_ToggleLegend();
void executeDispatch_ToggleGridHorizontal();
+ void impl_ShapeControllerDispatch( const ::com::sun::star::util::URL& rURL,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArgs );
+
//
DECL_LINK( DoubleClickWaitingHdl, void* );
- void execute_DoubleClick();
+ void execute_DoubleClick( const Point* pMousePixel = NULL );
void startDoubleClickWaiting();
void stopDoubleClickWaiting();
@@ -701,6 +720,8 @@ private:
void impl_PasteGraphic( ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > & xGraphic,
const ::Point & aPosition );
+ void impl_PasteShapes( SdrModel* pModel );
+ void impl_PasteStringAsTextShape( const ::rtl::OUString& rString, const ::com::sun::star::awt::Point& rPosition );
void impl_SetMousePointer( const MouseEvent & rEvent );
void impl_ClearSelection();
diff --git a/chart2/source/controller/main/ChartController_TextEdit.cxx b/chart2/source/controller/main/ChartController_TextEdit.cxx
index 4778f67f7bde..4df362ee80d2 100644
--- a/chart2/source/controller/main/ChartController_TextEdit.cxx
+++ b/chart2/source/controller/main/ChartController_TextEdit.cxx
@@ -64,15 +64,15 @@ using namespace ::com::sun::star;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-void SAL_CALL ChartController::executeDispatch_EditText()
+void SAL_CALL ChartController::executeDispatch_EditText( const Point* pMousePixel )
{
- this->StartTextEdit();
+ this->StartTextEdit( pMousePixel );
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-void ChartController::StartTextEdit()
+void ChartController::StartTextEdit( const Point* pMousePixel )
{
//the first marked object will be edited
@@ -111,6 +111,18 @@ void ChartController::StartTextEdit()
*/
m_pDrawViewWrapper->SetEditMode();
+ // #i12587# support for shapes in chart
+ if ( pMousePixel )
+ {
+ OutlinerView* pOutlinerView = m_pDrawViewWrapper->GetTextEditOutlinerView();
+ if ( pOutlinerView )
+ {
+ MouseEvent aEditEvt( *pMousePixel, 1, MOUSE_SYNTHETIC, MOUSE_LEFT, 0 );
+ pOutlinerView->MouseButtonDown( aEditEvt );
+ pOutlinerView->MouseButtonUp( aEditEvt );
+ }
+ }
+
//we invalidate the outliner region because the outliner has some
//paint problems (some characters are painted twice a little bit shifted)
m_pChartWindow->Invalidate( m_pDrawViewWrapper->GetMarkedObjBoundRect() );
@@ -139,22 +151,38 @@ bool ChartController::EndTextEdit()
String aString = pOutliner->GetText(
pOutliner->GetParagraph( 0 ),
pOutliner->GetParagraphCount() );
- uno::Reference< beans::XPropertySet > xPropSet =
- ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getModel() );
-
- // lock controllers till end of block
- ControllerLockGuard aCLGuard( m_aModel->getModel());
- //Paragraph* pPara =
- TitleHelper::setCompleteString( aString, uno::Reference<
- ::com::sun::star::chart2::XTitle >::query( xPropSet ), m_xCC );
- try
+ ::rtl::OUString aObjectCID = m_aSelection.getSelectedCID();
+ if ( aObjectCID.getLength() > 0 )
{
- m_xUndoManager->postAction( C2U("Edit Text") );
+ uno::Reference< beans::XPropertySet > xPropSet =
+ ObjectIdentifier::getObjectPropertySet( aObjectCID, getModel() );
+
+ // lock controllers till end of block
+ ControllerLockGuard aCLGuard( m_aModel->getModel());
+
+ TitleHelper::setCompleteString( aString, uno::Reference<
+ ::com::sun::star::chart2::XTitle >::query( xPropSet ), m_xCC );
+
+ try
+ {
+ m_xUndoManager->postAction( C2U("Edit Text") );
+ }
+ catch( uno::RuntimeException& e)
+ {
+ ASSERT_EXCEPTION( e );
+ }
}
- catch( uno::RuntimeException& e)
+ else
{
- ASSERT_EXCEPTION( e );
+ try
+ {
+ m_xUndoManager->cancelAction();
+ }
+ catch ( uno::RuntimeException& e )
+ {
+ ASSERT_EXCEPTION( e );
+ }
}
}
return true;
diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx
index 9edd2963aca4..ff567636ba0e 100644
--- a/chart2/source/controller/main/ChartController_Tools.cxx
+++ b/chart2/source/controller/main/ChartController_Tools.cxx
@@ -48,6 +48,8 @@
#include "LegendHelper.hxx"
#include "AxisHelper.hxx"
#include "RegressionCurveHelper.hxx"
+#include "ShapeController.hxx"
+#include "DiagramHelper.hxx"
#include <com/sun/star/chart2/DataPointLabel.hpp>
#include <com/sun/star/beans/XPropertyState.hpp>
@@ -59,8 +61,6 @@
#include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
#include <com/sun/star/chart/ErrorBarStyle.hpp>
-// #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
-
#include <svx/ActionDescriptionProvider.hxx>
// for TransferableDataHelper/TransferableHelper
#include <svtools/transfer.hxx>
@@ -77,8 +77,17 @@
// for SolarMutex
#include <vcl/svapp.hxx>
#include <vos/mutex.hxx>
+#include <svx/dialmgr.hxx>
+#include <svx/dialogs.hrc>
// for OutlinerView
#include <editeng/outliner.hxx>
+#include <svx/svditer.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdundo.hxx>
+#include <svx/unoapi.hxx>
+#include <svx/unopage.hxx>
+
+#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star;
@@ -107,7 +116,14 @@ bool lcl_deleteDataSeries(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, ::rtl::OUString( String( ::chart::SchResId( STR_OBJECT_DATASERIES )))),
xUndoManager, xModel );
+
+ Reference< chart2::XDiagram > xDiagram( ::chart::ChartModelHelper::findDiagram( xModel ) );
+ uno::Reference< chart2::XAxis > xAxis( ::chart::DiagramHelper::getAttachedAxis( xSeries, xDiagram ) );
+
::chart::DataSeriesHelper::deleteSeries( xSeries, xChartType );
+
+ ::chart::AxisHelper::hideAxisIfNoDataIsAttached( xAxis, xDiagram );
+
bResult = true;
aUndoGuard.commitAction();
}
@@ -184,50 +200,6 @@ bool lcl_deleteDataCurve(
} // anonymous namespace
-namespace
-{
-void lcl_InsertStringAsTextShapeIntoDrawPage(
- const Reference< lang::XMultiServiceFactory > & xShapeFactory,
- const Reference< drawing::XDrawPage > & xDrawPage,
- OUString & rString,
- const awt::Point & aPosition )
-{
- OSL_ASSERT( xShapeFactory.is() && xDrawPage.is());
- if( ! (xShapeFactory.is() && xDrawPage.is()))
- return;
-
- try
- {
- Reference< drawing::XShape > xTextShape(
- xShapeFactory->createInstance( C2U("com.sun.star.drawing.TextShape")), uno::UNO_QUERY_THROW );
- xDrawPage->add( xTextShape );
-
- Reference< text::XTextRange > xRange( xTextShape, uno::UNO_QUERY_THROW );
- xRange->setString( rString );
-
- float fCharHeight = 10.0;
- Reference< beans::XPropertySet > xProperties( xTextShape, uno::UNO_QUERY_THROW );
- xProperties->setPropertyValue( C2U("TextAutoGrowHeight"), uno::makeAny( true ));
- xProperties->setPropertyValue( C2U("TextAutoGrowWidth"), uno::makeAny( true ));
- xProperties->setPropertyValue( C2U("CharHeight"), uno::makeAny( fCharHeight ));
- xProperties->setPropertyValue( C2U("CharHeightAsian"), uno::makeAny( fCharHeight ));
- xProperties->setPropertyValue( C2U("CharHeightComplex"), uno::makeAny( fCharHeight ));
- xProperties->setPropertyValue( C2U("TextVerticalAdjust"), uno::makeAny( drawing::TextVerticalAdjust_CENTER ));
- xProperties->setPropertyValue( C2U("TextHorizontalAdjust"), uno::makeAny( drawing::TextHorizontalAdjust_CENTER ));
- xProperties->setPropertyValue( C2U("CharFontName"), uno::makeAny( C2U( "Albany" )));
-
- awt::Point aAdaptedPos( aPosition );
- aAdaptedPos.Y -= (xTextShape->getSize().Height / 2);
- aAdaptedPos.X -= (xTextShape->getSize().Width / 2);
- xTextShape->setPosition( aAdaptedPos );
- }
- catch( const uno::Exception & ex )
- {
- ASSERT_EXCEPTION( ex );
- }
-}
-
-} // anonymous namespace
namespace chart
{
@@ -334,22 +306,21 @@ void ChartController::executeDispatch_Paste()
TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( m_pChartWindow ));
if( aDataHelper.GetTransferable().is())
{
-// if( aDataHelper.HasFormat( SOT_FORMATSTR_ID_DRAWING ))
-// {
-// SotStorageStreamRef xStm;
-// if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_DRAWING, xStm ))
-// {
-// xStm->Seek( 0 );
-// uno::Reference< io::XInputStream > xInputStream( new utl::OInputStreamWrapper( *xStm ));
-// SdrModel * pModel = new SdrModel();
-// DrawModelWrapper * pDrawModelWrapper( this->GetDrawModelWrapper());
-// if( SvxDrawingLayerImport( pModel, xInputStream ))
-// lcl_CopyShapesToChart( *pModel, m_pDrawModelWrapper->getSdrModel());
-// delete pModel;
-// }
-// }
-// else
- if( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVXB ))
+ if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_DRAWING ) )
+ {
+ SotStorageStreamRef xStm;
+ if ( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_DRAWING, xStm ) )
+ {
+ xStm->Seek( 0 );
+ Reference< io::XInputStream > xInputStream( new utl::OInputStreamWrapper( *xStm ) );
+ ::boost::scoped_ptr< SdrModel > spModel( new SdrModel() );
+ if ( SvxDrawingLayerImport( spModel.get(), xInputStream ) )
+ {
+ impl_PasteShapes( spModel.get() );
+ }
+ }
+ }
+ else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVXB ) )
{
// graphic exchange format (graphic manager bitmap format?)
SotStorageStreamRef xStm;
@@ -382,14 +353,7 @@ void ChartController::executeDispatch_Paste()
pOutlinerView->InsertText( aString );
else
{
- awt::Point aTextPos;
- awt::Size aPageSize( ChartModelHelper::getPageSize( m_aModel->getModel()));
- aTextPos.X = (aPageSize.Width / 2);
- aTextPos.Y = (aPageSize.Height / 2);
- lcl_InsertStringAsTextShapeIntoDrawPage(
- m_pDrawModelWrapper->getShapeFactory(),
- m_pDrawModelWrapper->getMainDrawPage(),
- aString, aTextPos );
+ impl_PasteStringAsTextShape( aString, awt::Point( 0, 0 ) );
}
}
}
@@ -441,7 +405,6 @@ void ChartController::impl_PasteGraphic(
uno::Reference< beans::XPropertySet > xGraphicProp( xGraphic, uno::UNO_QUERY );
awt::Size aGraphicSize( 1000, 1000 );
- awt::Point aShapePos( 100,100 );
// first try size in 100th mm, then pixel size
if( ! ( xGraphicProp->getPropertyValue( C2U("Size100thMM")) >>= aGraphicSize ) &&
( ( xGraphicProp->getPropertyValue( C2U("SizePixel")) >>= aGraphicSize ) && m_pChartWindow ))
@@ -451,41 +414,158 @@ void ChartController::impl_PasteGraphic(
aGraphicSize.Height = aVCLSize.getHeight();
}
xGraphicShape->setSize( aGraphicSize );
-
- awt::Size aPageSize( ChartModelHelper::getPageSize( m_aModel->getModel()));
- aShapePos.X = (aPageSize.Width / 2) - (aGraphicSize.Width / 2);
- aShapePos.Y = (aPageSize.Height / 2) - (aGraphicSize.Height / 2);
- xGraphicShape->setPosition( aShapePos );
+ xGraphicShape->setPosition( awt::Point( 0, 0 ) );
}
}
-void ChartController::executeDispatch_Copy()
+void ChartController::impl_PasteShapes( SdrModel* pModel )
{
+ DrawModelWrapper* pDrawModelWrapper( this->GetDrawModelWrapper() );
+ if ( pDrawModelWrapper && m_pDrawViewWrapper )
+ {
+ Reference< drawing::XDrawPage > xDestPage( pDrawModelWrapper->getMainDrawPage() );
+ SdrPage* pDestPage = GetSdrPageFromXDrawPage( xDestPage );
+ if ( pDestPage )
+ {
+ Reference< drawing::XShape > xSelShape;
+ m_pDrawViewWrapper->BegUndo( SVX_RESSTR( RID_SVX_3D_UNDO_EXCHANGE_PASTE ) );
+ sal_uInt16 nCount = pModel->GetPageCount();
+ for ( sal_uInt16 i = 0; i < nCount; ++i )
+ {
+ const SdrPage* pPage = pModel->GetPage( i );
+ SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
+ while ( aIter.IsMore() )
+ {
+ SdrObject* pObj = aIter.Next();
+ SdrObject* pNewObj = ( pObj ? pObj->Clone() : NULL );
+ if ( pNewObj )
+ {
+ pNewObj->SetModel( &pDrawModelWrapper->getSdrModel() );
+ pNewObj->SetPage( pDestPage );
- Reference< datatransfer::XTransferable > xTransferable;
+ // set position
+ Reference< drawing::XShape > xShape( pNewObj->getUnoShape(), uno::UNO_QUERY );
+ if ( xShape.is() )
+ {
+ xShape->setPosition( awt::Point( 0, 0 ) );
+ }
+ pDestPage->InsertObject( pNewObj );
+ m_pDrawViewWrapper->AddUndo( new SdrUndoInsertObj( *pNewObj ) );
+ xSelShape = xShape;
+ }
+ }
+ }
+
+ Reference< util::XModifiable > xModifiable( m_aModel->getModel(), uno::UNO_QUERY );
+ if ( xModifiable.is() )
+ {
+ xModifiable->setModified( true );
+ }
+
+ // select last inserted shape
+ m_aSelection.setSelection( xSelShape );
+ m_aSelection.applySelection( m_pDrawViewWrapper );
+
+ m_pDrawViewWrapper->EndUndo();
+ }
+ }
+}
+
+void ChartController::impl_PasteStringAsTextShape( const OUString& rString, const awt::Point& rPosition )
+{
+ DrawModelWrapper* pDrawModelWrapper( this->GetDrawModelWrapper() );
+ if ( pDrawModelWrapper && m_pDrawViewWrapper )
{
- ::vos::OGuard aSolarGuard( Application::GetSolarMutex());
- SdrObject * pSelectedObj = 0;
- if( m_pDrawViewWrapper && m_pDrawModelWrapper )
- {
- if( m_aSelection.getSelectedCID().getLength() )
- pSelectedObj = m_pDrawModelWrapper->getNamedSdrObject( m_aSelection.getSelectedCID() );
- else
- pSelectedObj = DrawViewWrapper::getSdrObject( m_aSelection.getSelectedAdditionalShape() );
+ const Reference< lang::XMultiServiceFactory >& xShapeFactory( pDrawModelWrapper->getShapeFactory() );
+ const Reference< drawing::XDrawPage >& xDrawPage( pDrawModelWrapper->getMainDrawPage() );
+ OSL_ASSERT( xShapeFactory.is() && xDrawPage.is() );
- if( pSelectedObj )
+ if ( xShapeFactory.is() && xDrawPage.is() )
+ {
+ try
{
- xTransferable = Reference< datatransfer::XTransferable >( new ChartTransferable(
- & m_pDrawModelWrapper->getSdrModel(), pSelectedObj ));
+ Reference< drawing::XShape > xTextShape(
+ xShapeFactory->createInstance( C2U( "com.sun.star.drawing.TextShape" ) ), uno::UNO_QUERY_THROW );
+ xDrawPage->add( xTextShape );
+
+ Reference< text::XTextRange > xRange( xTextShape, uno::UNO_QUERY_THROW );
+ xRange->setString( rString );
+
+ float fCharHeight = 10.0;
+ Reference< beans::XPropertySet > xProperties( xTextShape, uno::UNO_QUERY_THROW );
+ xProperties->setPropertyValue( C2U( "TextAutoGrowHeight" ), uno::makeAny( true ) );
+ xProperties->setPropertyValue( C2U( "TextAutoGrowWidth" ), uno::makeAny( true ) );
+ xProperties->setPropertyValue( C2U( "CharHeight" ), uno::makeAny( fCharHeight ) );
+ xProperties->setPropertyValue( C2U( "CharHeightAsian" ), uno::makeAny( fCharHeight ) );
+ xProperties->setPropertyValue( C2U( "CharHeightComplex" ), uno::makeAny( fCharHeight ) );
+ xProperties->setPropertyValue( C2U( "TextVerticalAdjust" ), uno::makeAny( drawing::TextVerticalAdjust_CENTER ) );
+ xProperties->setPropertyValue( C2U( "TextHorizontalAdjust" ), uno::makeAny( drawing::TextHorizontalAdjust_CENTER ) );
+ xProperties->setPropertyValue( C2U( "CharFontName" ), uno::makeAny( C2U( "Albany" ) ) );
+
+ xTextShape->setPosition( rPosition );
+
+ m_aSelection.setSelection( xTextShape );
+ m_aSelection.applySelection( m_pDrawViewWrapper );
+
+ SdrObject* pObj = DrawViewWrapper::getSdrObject( xTextShape );
+ if ( pObj )
+ {
+ m_pDrawViewWrapper->BegUndo( SVX_RESSTR( RID_SVX_3D_UNDO_EXCHANGE_PASTE ) );
+ m_pDrawViewWrapper->AddUndo( new SdrUndoInsertObj( *pObj ) );
+ m_pDrawViewWrapper->EndUndo();
+ }
+ }
+ catch ( const uno::Exception& ex )
+ {
+ ASSERT_EXCEPTION( ex );
}
}
}
- if( xTransferable.is() )
+}
+
+void ChartController::executeDispatch_Copy()
+{
+ if ( m_pDrawViewWrapper )
{
- Reference< datatransfer::clipboard::XClipboard > xClipboard( TransferableHelper::GetSystemClipboard());
- if( xClipboard.is())
- xClipboard->setContents( xTransferable, Reference< datatransfer::clipboard::XClipboardOwner >() );
+ OutlinerView* pOutlinerView = m_pDrawViewWrapper->GetTextEditOutlinerView();
+ if ( pOutlinerView )
+ {
+ pOutlinerView->Copy();
+ }
+ else
+ {
+ Reference< datatransfer::XTransferable > xTransferable;
+ {
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ SdrObject* pSelectedObj = 0;
+ if ( m_pDrawModelWrapper )
+ {
+ ObjectIdentifier aSelOID( m_aSelection.getSelectedOID() );
+ if ( aSelOID.isAutoGeneratedObject() )
+ {
+ pSelectedObj = m_pDrawModelWrapper->getNamedSdrObject( aSelOID.getObjectCID() );
+ }
+ else if ( aSelOID.isAdditionalShape() )
+ {
+ pSelectedObj = DrawViewWrapper::getSdrObject( aSelOID.getAdditionalShape() );
+ }
+ if ( pSelectedObj )
+ {
+ xTransferable = Reference< datatransfer::XTransferable >( new ChartTransferable(
+ &m_pDrawModelWrapper->getSdrModel(), pSelectedObj, aSelOID.isAdditionalShape() ) );
+ }
+ }
+ }
+ if ( xTransferable.is() )
+ {
+ Reference< datatransfer::clipboard::XClipboard > xClipboard( TransferableHelper::GetSystemClipboard() );
+ if ( xClipboard.is() )
+ {
+ xClipboard->setContents( xTransferable, Reference< datatransfer::clipboard::XClipboardOwner >() );
+ }
+ }
+ }
}
}
@@ -498,12 +578,12 @@ void ChartController::executeDispatch_Cut()
//static
bool ChartController::isObjectDeleteable( const uno::Any& rSelection )
{
- OUString aSelObjCID;
- if( (rSelection >>= aSelObjCID) && aSelObjCID.getLength() > 0 )
+ ObjectIdentifier aSelOID( rSelection );
+ if ( aSelOID.isAutoGeneratedObject() )
{
+ OUString aSelObjCID( aSelOID.getObjectCID() );
ObjectType aObjectType(ObjectIdentifier::getObjectType( aSelObjCID ));
- if( (OBJECTTYPE_TITLE == aObjectType) || (OBJECTTYPE_LEGEND == aObjectType)
- || (OBJECTTYPE_DATA_SERIES == aObjectType) )
+ if( (OBJECTTYPE_TITLE == aObjectType) || (OBJECTTYPE_LEGEND == aObjectType) )
return true;
if( (OBJECTTYPE_DATA_SERIES == aObjectType) || (OBJECTTYPE_LEGEND_ENTRY == aObjectType) )
return true;
@@ -512,6 +592,24 @@ bool ChartController::isObjectDeleteable( const uno::Any& rSelection )
return true;
if( (OBJECTTYPE_DATA_LABELS == aObjectType) || (OBJECTTYPE_DATA_LABEL == aObjectType) )
return true;
+ if( (OBJECTTYPE_AXIS == aObjectType) || (OBJECTTYPE_GRID == aObjectType) || (OBJECTTYPE_SUBGRID == aObjectType) )
+ return true;
+ }
+ else if ( aSelOID.isAdditionalShape() )
+ {
+ return true;
+ }
+
+ return false;
+}
+
+bool ChartController::isShapeContext() const
+{
+ if ( m_aSelection.isAdditionalShapeSelected() ||
+ ( m_pDrawViewWrapper && m_pDrawViewWrapper->AreObjectsMarked() &&
+ ( m_pDrawViewWrapper->GetCurrentObjIdentifier() == OBJ_TEXT ) ) )
+ {
+ return true;
}
return false;
@@ -539,8 +637,6 @@ bool ChartController::executeDispatch_Delete()
return false;
//remove chart object
- impl_ClearSelection();
-
uno::Reference< chart2::XChartDocument > xChartDoc( m_aModel->getModel(), uno::UNO_QUERY );
if( !xChartDoc.is() )
return false;
@@ -697,6 +793,24 @@ bool ChartController::executeDispatch_Delete()
}
break;
}
+ case OBJECTTYPE_AXIS:
+ {
+ executeDispatch_DeleteAxis();
+ bReturn = true;
+ break;
+ }
+ case OBJECTTYPE_GRID:
+ {
+ executeDispatch_DeleteMajorGrid();
+ bReturn = true;
+ break;
+ }
+ case OBJECTTYPE_SUBGRID:
+ {
+ executeDispatch_DeleteMinorGrid();
+ bReturn = true;
+ break;
+ }
default:
{
@@ -779,4 +893,13 @@ void ChartController::executeDispatch_ToggleGridHorizontal()
}
}
+void ChartController::impl_ShapeControllerDispatch( const util::URL& rURL, const Sequence< beans::PropertyValue >& rArgs )
+{
+ Reference< frame::XDispatch > xDispatch( m_aDispatchContainer.getShapeController() );
+ if ( xDispatch.is() )
+ {
+ xDispatch->dispatch( rURL, rArgs );
+ }
+}
+
} // namespace chart
diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx
index f66352d5870b..7822c8c1cc21 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -55,6 +55,8 @@
#include "AxisHelper.hxx"
#include "LegendHelper.hxx"
#include "servicenames_charttypes.hxx"
+#include "MenuResIds.hrc"
+#include "DrawCommandDispatch.hxx"
#include <com/sun/star/chart2/RelativePosition.hpp>
#include <com/sun/star/chart2/RelativeSize.hpp>
@@ -623,7 +625,10 @@ void ChartController::execute_MouseButtonDown( const MouseEvent& rMEvt )
if( pDrawViewWrapper->IsTextEdit() )
{
- if( pDrawViewWrapper->IsTextEditHit( aMPos, HITPIX) )
+ SdrViewEvent aVEvt;
+ if ( pDrawViewWrapper->IsTextEditHit( aMPos, HITPIX ) ||
+ // #i12587# support for shapes in chart
+ ( rMEvt.IsRight() && pDrawViewWrapper->PickAnything( rMEvt, SDRMOUSEBUTTONDOWN, aVEvt ) == SDRHIT_MARKEDOBJECT ) )
{
pDrawViewWrapper->MouseButtonDown(rMEvt,m_pChartWindow);
return;
@@ -652,6 +657,39 @@ void ChartController::execute_MouseButtonDown( const MouseEvent& rMEvt )
//only change selection if no selection handles are hit
if( !pHitSelectionHdl )
{
+ // #i12587# support for shapes in chart
+ if ( m_eDrawMode == CHARTDRAW_INSERT &&
+ ( !pDrawViewWrapper->IsMarkedHit( aMPos ) || !m_aSelection.isDragableObjectSelected() ) )
+ {
+ if ( m_aSelection.hasSelection() )
+ {
+ m_aSelection.clearSelection();
+ }
+ if ( !pDrawViewWrapper->IsAction() )
+ {
+ if ( pDrawViewWrapper->GetCurrentObjIdentifier() == OBJ_CAPTION )
+ {
+ Size aCaptionSize( 2268, 1134 );
+ pDrawViewWrapper->BegCreateCaptionObj( aMPos, aCaptionSize );
+ }
+ else
+ {
+ pDrawViewWrapper->BegCreateObj( aMPos);
+ }
+ SdrObject* pObj = pDrawViewWrapper->GetCreateObj();
+ DrawCommandDispatch* pDrawCommandDispatch = m_aDispatchContainer.getDrawCommandDispatch();
+ if ( pObj && m_pDrawModelWrapper && pDrawCommandDispatch )
+ {
+ SfxItemSet aSet( m_pDrawModelWrapper->GetItemPool() );
+ pDrawCommandDispatch->setAttributes( pObj );
+ pDrawCommandDispatch->setLineEnds( aSet );
+ pObj->SetMergedItemSet( aSet );
+ }
+ }
+ impl_SetMousePointer( rMEvt );
+ return;
+ }
+
m_aSelection.adaptSelectionToNewPos( aMPos, pDrawViewWrapper
, rMEvt.IsRight(), m_bWaitingForDoubleClick );
@@ -754,7 +792,38 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt )
return;
}
- if(pDrawViewWrapper->IsDragObj())
+ // #i12587# support for shapes in chart
+ if ( m_eDrawMode == CHARTDRAW_INSERT && pDrawViewWrapper->IsCreateObj() )
+ {
+ pDrawViewWrapper->EndCreateObj( SDRCREATE_FORCEEND );
+ if ( pDrawViewWrapper->AreObjectsMarked() )
+ {
+ if ( pDrawViewWrapper->GetCurrentObjIdentifier() == OBJ_TEXT )
+ {
+ executeDispatch_EditText();
+ }
+ else
+ {
+ SdrObject* pObj = pDrawViewWrapper->getSelectedObject();
+ if ( pObj )
+ {
+ uno::Reference< drawing::XShape > xShape( pObj->getUnoShape(), uno::UNO_QUERY );
+ if ( xShape.is() )
+ {
+ m_aSelection.setSelection( xShape );
+ m_aSelection.applySelection( pDrawViewWrapper );
+ }
+ }
+ }
+ }
+ else
+ {
+ m_aSelection.adaptSelectionToNewPos( aMPos, pDrawViewWrapper, rMEvt.IsRight(), m_bWaitingForDoubleClick );
+ m_aSelection.applySelection( pDrawViewWrapper );
+ setDrawMode( CHARTDRAW_SELECT );
+ }
+ }
+ else if ( pDrawViewWrapper->IsDragObj() )
{
bool bDraggingDone = false;
SdrDragMethod* pDragMethod = pDrawViewWrapper->SdrView::GetDragMethod();
@@ -839,7 +908,11 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt )
m_aSelection.resetPossibleSelectionAfterSingleClickWasEnsured();
}
else if( isDoubleClick(rMEvt) )
- execute_DoubleClick();
+ {
+ // #i12587# support for shapes in chart
+ Point aMousePixel = rMEvt.GetPosPixel();
+ execute_DoubleClick( &aMousePixel );
+ }
//@todo ForcePointer(&rMEvt);
pWindow->ReleaseMouse();
@@ -854,13 +927,39 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt )
impl_notifySelectionChangeListeners();
}
-void ChartController::execute_DoubleClick()
+void ChartController::execute_DoubleClick( const Point* pMousePixel )
{
- ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() );
- if( OBJECTTYPE_TITLE==eObjectType )
- executeDispatch_EditText();
+ bool bEditText = false;
+ if ( m_aSelection.hasSelection() )
+ {
+ ::rtl::OUString aCID( m_aSelection.getSelectedCID() );
+ if ( aCID.getLength() )
+ {
+ ObjectType eObjectType = ObjectIdentifier::getObjectType( aCID );
+ if ( OBJECTTYPE_TITLE == eObjectType )
+ {
+ bEditText = true;
+ }
+ }
+ else
+ {
+ // #i12587# support for shapes in chart
+ SdrObject* pObj = DrawViewWrapper::getSdrObject( m_aSelection.getSelectedAdditionalShape() );
+ if ( pObj && pObj->ISA( SdrTextObj ) )
+ {
+ bEditText = true;
+ }
+ }
+ }
+
+ if ( bEditText )
+ {
+ executeDispatch_EditText( pMousePixel );
+ }
else
+ {
executeDispatch_ObjectProperties();
+ }
}
void ChartController::execute_Resize()
@@ -907,272 +1006,288 @@ void ChartController::execute_Command( const CommandEvent& rCEvt )
if( m_aSelection.isSelectionDifferentFromBeforeMouseDown() )
impl_notifySelectionChangeListeners();
- // todo: the context menu should be specified by an xml file in uiconfig
- uno::Reference< awt::XPopupMenu > xPopupMenu(
- m_xCC->getServiceManager()->createInstanceWithContext(
- C2U("com.sun.star.awt.PopupMenu"), m_xCC ), uno::UNO_QUERY );
- uno::Reference< awt::XMenuExtended > xMenuEx( xPopupMenu, uno::UNO_QUERY );
- if( xPopupMenu.is() && xMenuEx.is())
+ if ( isShapeContext() )
+ {
+ // #i12587# support for shapes in chart
+ PopupMenu aContextMenu( SchResId( m_pDrawViewWrapper->IsTextEdit() ?
+ RID_CONTEXTMENU_SHAPEEDIT : RID_CONTEXTMENU_SHAPE ) );
+ ::svt::ContextMenuHelper aContextMenuHelper( m_xFrame );
+ Point aPos( rCEvt.GetMousePosPixel() );
+ if( !rCEvt.IsMouseEvent() )
+ {
+ aPos = m_pChartWindow->GetPointerState().maPos;
+ }
+ aContextMenuHelper.completeAndExecute( aPos, aContextMenu );
+ }
+ else
{
- sal_Int16 nUniqueId = 1;
- ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() );
- Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( m_aModel->getModel() );
+ // todo: the context menu should be specified by an xml file in uiconfig
+ uno::Reference< awt::XPopupMenu > xPopupMenu(
+ m_xCC->getServiceManager()->createInstanceWithContext(
+ C2U("com.sun.star.awt.PopupMenu"), m_xCC ), uno::UNO_QUERY );
+ uno::Reference< awt::XMenuExtended > xMenuEx( xPopupMenu, uno::UNO_QUERY );
+ if( xPopupMenu.is() && xMenuEx.is())
+ {
+ sal_Int16 nUniqueId = 1;
+ ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() );
+ Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( m_aModel->getModel() );
- OUString aFormatCommand( lcl_getFormatCommandForObjectCID( m_aSelection.getSelectedCID() ) );
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, aFormatCommand );
+ OUString aFormatCommand( lcl_getFormatCommandForObjectCID( m_aSelection.getSelectedCID() ) );
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, aFormatCommand );
- //some commands for dataseries and points:
- //-----
- if( OBJECTTYPE_DATA_SERIES == eObjectType || OBJECTTYPE_DATA_POINT == eObjectType )
- {
- bool bIsPoint = ( OBJECTTYPE_DATA_POINT == eObjectType );
- uno::Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() );
- uno::Reference< chart2::XRegressionCurveContainer > xCurveCnt( xSeries, uno::UNO_QUERY );
- Reference< chart2::XRegressionCurve > xTrendline( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xCurveCnt ) );
- bool bHasEquation = RegressionCurveHelper::hasEquation( xTrendline );
- Reference< chart2::XRegressionCurve > xMeanValue( RegressionCurveHelper::getMeanValueLine( xCurveCnt ) );
- bool bHasYErrorBars = StatisticsHelper::hasErrorBars( xSeries, true );
- bool bHasDataLabelsAtSeries = DataSeriesHelper::hasDataLabelsAtSeries( xSeries );
- bool bHasDataLabelsAtPoints = DataSeriesHelper::hasDataLabelsAtPoints( xSeries );
- bool bHasDataLabelAtPoint = false;
- sal_Int32 nPointIndex = -1;
- if( bIsPoint )
+ //some commands for dataseries and points:
+ //-----
+ if( OBJECTTYPE_DATA_SERIES == eObjectType || OBJECTTYPE_DATA_POINT == eObjectType )
{
- nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( m_aSelection.getSelectedCID() );
- bHasDataLabelAtPoint = DataSeriesHelper::hasDataLabelAtPoint( xSeries, nPointIndex );
- }
- bool bSelectedPointIsFormatted = false;
- bool bHasFormattedDataPointsOtherThanSelected = false;
+ bool bIsPoint = ( OBJECTTYPE_DATA_POINT == eObjectType );
+ uno::Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() );
+ uno::Reference< chart2::XRegressionCurveContainer > xCurveCnt( xSeries, uno::UNO_QUERY );
+ Reference< chart2::XRegressionCurve > xTrendline( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xCurveCnt ) );
+ bool bHasEquation = RegressionCurveHelper::hasEquation( xTrendline );
+ Reference< chart2::XRegressionCurve > xMeanValue( RegressionCurveHelper::getMeanValueLine( xCurveCnt ) );
+ bool bHasYErrorBars = StatisticsHelper::hasErrorBars( xSeries, true );
+ bool bHasDataLabelsAtSeries = DataSeriesHelper::hasDataLabelsAtSeries( xSeries );
+ bool bHasDataLabelsAtPoints = DataSeriesHelper::hasDataLabelsAtPoints( xSeries );
+ bool bHasDataLabelAtPoint = false;
+ sal_Int32 nPointIndex = -1;
+ if( bIsPoint )
+ {
+ nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( m_aSelection.getSelectedCID() );
+ bHasDataLabelAtPoint = DataSeriesHelper::hasDataLabelAtPoint( xSeries, nPointIndex );
+ }
+ bool bSelectedPointIsFormatted = false;
+ bool bHasFormattedDataPointsOtherThanSelected = false;
- Reference< beans::XPropertySet > xSeriesProperties( xSeries, uno::UNO_QUERY );
- if( xSeriesProperties.is() )
- {
- uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
- if( xSeriesProperties->getPropertyValue( C2U( "AttributedDataPoints" ) ) >>= aAttributedDataPointIndexList )
+ Reference< beans::XPropertySet > xSeriesProperties( xSeries, uno::UNO_QUERY );
+ if( xSeriesProperties.is() )
{
- if( aAttributedDataPointIndexList.hasElements() )
+ uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
+ if( xSeriesProperties->getPropertyValue( C2U( "AttributedDataPoints" ) ) >>= aAttributedDataPointIndexList )
{
- if( bIsPoint )
+ if( aAttributedDataPointIndexList.hasElements() )
{
- ::std::vector< sal_Int32 > aIndices( ContainerHelper::SequenceToVector( aAttributedDataPointIndexList ) );
- ::std::vector< sal_Int32 >::iterator aIt = ::std::find( aIndices.begin(), aIndices.end(), nPointIndex );
- if( aIt != aIndices.end())
- bSelectedPointIsFormatted = true;
+ if( bIsPoint )
+ {
+ ::std::vector< sal_Int32 > aIndices( ContainerHelper::SequenceToVector( aAttributedDataPointIndexList ) );
+ ::std::vector< sal_Int32 >::iterator aIt = ::std::find( aIndices.begin(), aIndices.end(), nPointIndex );
+ if( aIt != aIndices.end())
+ bSelectedPointIsFormatted = true;
+ else
+ bHasFormattedDataPointsOtherThanSelected = true;
+ }
else
bHasFormattedDataPointsOtherThanSelected = true;
}
- else
- bHasFormattedDataPointsOtherThanSelected = true;
}
}
- }
- //const sal_Int32 nIdBeforeFormat = nUniqueId;
- if( bIsPoint )
- {
- if( bHasDataLabelAtPoint )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatDataLabel") );
- if( !bHasDataLabelAtPoint )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertDataLabel") );
- else
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteDataLabel") );
- if( bSelectedPointIsFormatted )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:ResetDataPoint"));
-
- xPopupMenu->insertSeparator( -1 );
-
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatDataSeries") );
- }
+ //const sal_Int32 nIdBeforeFormat = nUniqueId;
+ if( bIsPoint )
+ {
+ if( bHasDataLabelAtPoint )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatDataLabel") );
+ if( !bHasDataLabelAtPoint )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertDataLabel") );
+ else
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteDataLabel") );
+ if( bSelectedPointIsFormatted )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:ResetDataPoint"));
+
+ xPopupMenu->insertSeparator( -1 );
+
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatDataSeries") );
+ }
- Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) );
- if( xChartType->getChartType().equals(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
- {
- try
+ Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) );
+ if( xChartType->getChartType().equals(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
{
- Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY );
- if( xChartTypeProp.is() )
+ try
{
- bool bJapaneseStyle = false;
- xChartTypeProp->getPropertyValue( C2U( "Japanese" ) ) >>= bJapaneseStyle;
-
- if( bJapaneseStyle )
+ Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY );
+ if( xChartTypeProp.is() )
{
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatStockLoss") );
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatStockGain") );
+ bool bJapaneseStyle = false;
+ xChartTypeProp->getPropertyValue( C2U( "Japanese" ) ) >>= bJapaneseStyle;
+
+ if( bJapaneseStyle )
+ {
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatStockLoss") );
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatStockGain") );
+ }
}
}
+ catch( const uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
}
- catch( const uno::Exception & ex )
+
+ if( bHasDataLabelsAtSeries )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatDataLabels") );
+ if( xTrendline.is() )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatTrendline") );
+ if( bHasEquation )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatTrendlineEquation") );
+ if( xMeanValue.is() )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatMeanValue") );
+ if( bHasYErrorBars )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatYErrorBars") );
+
+ //if( nIdBeforeFormat != nUniqueId )
+ xPopupMenu->insertSeparator( -1 );
+
+ //const sal_Int32 nIdBeforeInsert = nUniqueId;
+
+ if( !bHasDataLabelsAtSeries )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertDataLabels") );
+ if( !xTrendline.is() )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendline") );
+ else if( !bHasEquation )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendlineEquation") );
+ if( !xMeanValue.is() )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertMeanValue") );
+ if( !bHasYErrorBars )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertYErrorBars") );
+
+ //if( nIdBeforeInsert != nUniqueId )
+ // xPopupMenu->insertSeparator( -1 );
+
+ //const sal_Int32 nIdBeforeDelete = nUniqueId;
+
+ if( bHasDataLabelsAtSeries || ( bHasDataLabelsAtPoints && bHasFormattedDataPointsOtherThanSelected ) )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteDataLabels") );
+ if( xTrendline.is() )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteTrendline") );
+ if( bHasEquation )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteTrendlineEquation") );
+ if( xMeanValue.is() )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteMeanValue") );
+ if( bHasYErrorBars )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteYErrorBars") );
+
+ if( bHasFormattedDataPointsOtherThanSelected )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:ResetAllDataPoints"));
+
+ //if( nIdBeforeDelete != nUniqueId )
+ xPopupMenu->insertSeparator( -1 );
+
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId, C2U(".uno:ArrangeRow"));
+ uno::Reference< awt::XPopupMenu > xArrangePopupMenu(
+ m_xCC->getServiceManager()->createInstanceWithContext(
+ C2U("com.sun.star.awt.PopupMenu"), m_xCC ), uno::UNO_QUERY );
+ uno::Reference< awt::XMenuExtended > xArrangeMenuEx( xArrangePopupMenu, uno::UNO_QUERY );
+ if( xArrangePopupMenu.is() && xArrangeMenuEx.is())
{
- ASSERT_EXCEPTION( ex );
+ sal_Int16 nSubId = nUniqueId + 1;
+ lcl_insertMenuCommand( xArrangePopupMenu, xArrangeMenuEx, nSubId++, C2U(".uno:Forward") );
+ lcl_insertMenuCommand( xArrangePopupMenu, xArrangeMenuEx, nSubId, C2U(".uno:Backward") );
+ xPopupMenu->setPopupMenu( nUniqueId, xArrangePopupMenu );
+ nUniqueId = nSubId;
}
+ ++nUniqueId;
}
-
- if( bHasDataLabelsAtSeries )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatDataLabels") );
- if( xTrendline.is() )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatTrendline") );
- if( bHasEquation )
+ else if( OBJECTTYPE_DATA_CURVE == eObjectType )
+ {
lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatTrendlineEquation") );
- if( xMeanValue.is() )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatMeanValue") );
- if( bHasYErrorBars )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatYErrorBars") );
-
- //if( nIdBeforeFormat != nUniqueId )
- xPopupMenu->insertSeparator( -1 );
-
- //const sal_Int32 nIdBeforeInsert = nUniqueId;
-
- if( !bHasDataLabelsAtSeries )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertDataLabels") );
- if( !xTrendline.is() )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendline") );
- else if( !bHasEquation )
lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendlineEquation") );
- if( !xMeanValue.is() )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertMeanValue") );
- if( !bHasYErrorBars )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertYErrorBars") );
-
- //if( nIdBeforeInsert != nUniqueId )
- // xPopupMenu->insertSeparator( -1 );
-
- //const sal_Int32 nIdBeforeDelete = nUniqueId;
-
- if( bHasDataLabelsAtSeries || ( bHasDataLabelsAtPoints && bHasFormattedDataPointsOtherThanSelected ) )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteDataLabels") );
- if( xTrendline.is() )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteTrendline") );
- if( bHasEquation )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendlineEquationAndR2") );
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertR2Value") );
lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteTrendlineEquation") );
- if( xMeanValue.is() )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteMeanValue") );
- if( bHasYErrorBars )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteYErrorBars") );
-
- if( bHasFormattedDataPointsOtherThanSelected )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:ResetAllDataPoints"));
-
- //if( nIdBeforeDelete != nUniqueId )
- xPopupMenu->insertSeparator( -1 );
-
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId, C2U(".uno:ArrangeRow"));
- uno::Reference< awt::XPopupMenu > xArrangePopupMenu(
- m_xCC->getServiceManager()->createInstanceWithContext(
- C2U("com.sun.star.awt.PopupMenu"), m_xCC ), uno::UNO_QUERY );
- uno::Reference< awt::XMenuExtended > xArrangeMenuEx( xArrangePopupMenu, uno::UNO_QUERY );
- if( xArrangePopupMenu.is() && xArrangeMenuEx.is())
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteR2Value") );
+ }
+ else if( OBJECTTYPE_DATA_CURVE_EQUATION == eObjectType )
{
- sal_Int16 nSubId = nUniqueId + 1;
- lcl_insertMenuCommand( xArrangePopupMenu, xArrangeMenuEx, nSubId++, C2U(".uno:Forward") );
- lcl_insertMenuCommand( xArrangePopupMenu, xArrangeMenuEx, nSubId, C2U(".uno:Backward") );
- xPopupMenu->setPopupMenu( nUniqueId, xArrangePopupMenu );
- nUniqueId = nSubId;
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertR2Value") );
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteR2Value") );
}
- ++nUniqueId;
- }
- else if( OBJECTTYPE_DATA_CURVE == eObjectType )
- {
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatTrendlineEquation") );
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendlineEquation") );
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendlineEquationAndR2") );
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertR2Value") );
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteTrendlineEquation") );
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteR2Value") );
- }
- else if( OBJECTTYPE_DATA_CURVE_EQUATION == eObjectType )
- {
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertR2Value") );
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteR2Value") );
- }
- //some commands for axes: and grids
- //-----
- else if( OBJECTTYPE_AXIS == eObjectType || OBJECTTYPE_GRID == eObjectType || OBJECTTYPE_SUBGRID == eObjectType )
- {
- Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() );
- if( xAxis.is() && xDiagram.is() )
+ //some commands for axes: and grids
+ //-----
+ else if( OBJECTTYPE_AXIS == eObjectType || OBJECTTYPE_GRID == eObjectType || OBJECTTYPE_SUBGRID == eObjectType )
{
- sal_Int32 nDimensionIndex = -1;
- sal_Int32 nCooSysIndex = -1;
- sal_Int32 nAxisIndex = -1;
- AxisHelper::getIndicesForAxis( xAxis, xDiagram, nCooSysIndex, nDimensionIndex, nAxisIndex );
- bool bIsSecondaryAxis = nAxisIndex!=0;
- bool bIsAxisVisible = AxisHelper::isAxisVisible( xAxis );
- bool bIsMajorGridVisible = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, true /*bMainGrid*/, xDiagram );
- bool bIsMinorGridVisible = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, false /*bMainGrid*/, xDiagram );
- bool bHasTitle = false;
- uno::Reference< XTitled > xTitled( xAxis, uno::UNO_QUERY );
- if( xTitled.is())
- bHasTitle = TitleHelper::getCompleteString( xTitled->getTitleObject() ).getLength()>0;
-
- if( OBJECTTYPE_AXIS != eObjectType && bIsAxisVisible )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatAxis") );
- if( OBJECTTYPE_GRID != eObjectType && bIsMajorGridVisible && !bIsSecondaryAxis )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatMajorGrid") );
- if( OBJECTTYPE_SUBGRID != eObjectType && bIsMinorGridVisible && !bIsSecondaryAxis )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatMinorGrid") );
-
- xPopupMenu->insertSeparator( -1 );
-
- if( OBJECTTYPE_AXIS != eObjectType && !bIsAxisVisible )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertAxis") );
- if( OBJECTTYPE_GRID != eObjectType && !bIsMajorGridVisible && !bIsSecondaryAxis )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertMajorGrid") );
- if( OBJECTTYPE_SUBGRID != eObjectType && !bIsMinorGridVisible && !bIsSecondaryAxis )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertMinorGrid") );
- if( !bHasTitle )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertAxisTitle") );
-
- if( bIsAxisVisible )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteAxis") );
- if( bIsMajorGridVisible && !bIsSecondaryAxis )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteMajorGrid") );
- if( bIsMinorGridVisible && !bIsSecondaryAxis )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteMinorGrid") );
+ Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() );
+ if( xAxis.is() && xDiagram.is() )
+ {
+ sal_Int32 nDimensionIndex = -1;
+ sal_Int32 nCooSysIndex = -1;
+ sal_Int32 nAxisIndex = -1;
+ AxisHelper::getIndicesForAxis( xAxis, xDiagram, nCooSysIndex, nDimensionIndex, nAxisIndex );
+ bool bIsSecondaryAxis = nAxisIndex!=0;
+ bool bIsAxisVisible = AxisHelper::isAxisVisible( xAxis );
+ bool bIsMajorGridVisible = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, true /*bMainGrid*/, xDiagram );
+ bool bIsMinorGridVisible = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, false /*bMainGrid*/, xDiagram );
+ bool bHasTitle = false;
+ uno::Reference< XTitled > xTitled( xAxis, uno::UNO_QUERY );
+ if( xTitled.is())
+ bHasTitle = TitleHelper::getCompleteString( xTitled->getTitleObject() ).getLength()>0;
+
+ if( OBJECTTYPE_AXIS != eObjectType && bIsAxisVisible )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatAxis") );
+ if( OBJECTTYPE_GRID != eObjectType && bIsMajorGridVisible && !bIsSecondaryAxis )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatMajorGrid") );
+ if( OBJECTTYPE_SUBGRID != eObjectType && bIsMinorGridVisible && !bIsSecondaryAxis )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatMinorGrid") );
+
+ xPopupMenu->insertSeparator( -1 );
+
+ if( OBJECTTYPE_AXIS != eObjectType && !bIsAxisVisible )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertAxis") );
+ if( OBJECTTYPE_GRID != eObjectType && !bIsMajorGridVisible && !bIsSecondaryAxis )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertMajorGrid") );
+ if( OBJECTTYPE_SUBGRID != eObjectType && !bIsMinorGridVisible && !bIsSecondaryAxis )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertMinorGrid") );
+ if( !bHasTitle )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertAxisTitle") );
+
+ if( bIsAxisVisible )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteAxis") );
+ if( bIsMajorGridVisible && !bIsSecondaryAxis )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteMajorGrid") );
+ if( bIsMinorGridVisible && !bIsSecondaryAxis )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteMinorGrid") );
+ }
}
- }
- if( OBJECTTYPE_DATA_STOCK_LOSS == eObjectType )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatStockGain") );
- else if( OBJECTTYPE_DATA_STOCK_GAIN == eObjectType )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatStockLoss") );
+ if( OBJECTTYPE_DATA_STOCK_LOSS == eObjectType )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatStockGain") );
+ else if( OBJECTTYPE_DATA_STOCK_GAIN == eObjectType )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatStockLoss") );
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:TransformDialog"));
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:TransformDialog"));
- if( OBJECTTYPE_PAGE == eObjectType || OBJECTTYPE_DIAGRAM == eObjectType
- || OBJECTTYPE_DIAGRAM_WALL == eObjectType
- || OBJECTTYPE_DIAGRAM_FLOOR == eObjectType
- || OBJECTTYPE_UNKNOWN == eObjectType )
- {
- if( OBJECTTYPE_UNKNOWN != eObjectType )
- xPopupMenu->insertSeparator( -1 );
- bool bHasLegend = LegendHelper::hasLegend( xDiagram );
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTitles") );
- if( !bHasLegend )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertLegend") );
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertRemoveAxes") );
- if( bHasLegend )
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteLegend") );
+ if( OBJECTTYPE_PAGE == eObjectType || OBJECTTYPE_DIAGRAM == eObjectType
+ || OBJECTTYPE_DIAGRAM_WALL == eObjectType
+ || OBJECTTYPE_DIAGRAM_FLOOR == eObjectType
+ || OBJECTTYPE_UNKNOWN == eObjectType )
+ {
+ if( OBJECTTYPE_UNKNOWN != eObjectType )
+ xPopupMenu->insertSeparator( -1 );
+ bool bHasLegend = LegendHelper::hasLegend( xDiagram );
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTitles") );
+ if( !bHasLegend )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertLegend") );
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertRemoveAxes") );
+ if( bHasLegend )
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteLegend") );
+ }
+ //-----
+
+ xPopupMenu->insertSeparator( -1 );
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DiagramType"));
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DataRanges"));
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DiagramData"));
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:View3D"));
+ xPopupMenu->insertSeparator( -1 );
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:Cut"));
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:Copy"));
+ lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:Paste"));
+
+ ::svt::ContextMenuHelper aContextMenuHelper( m_xFrame );
+ Point aPos( rCEvt.GetMousePosPixel() );
+ if( !rCEvt.IsMouseEvent() )
+ aPos = m_pChartWindow->GetPointerState().maPos;
+ aContextMenuHelper.completeAndExecute( aPos, xPopupMenu );
}
- //-----
-
- xPopupMenu->insertSeparator( -1 );
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DiagramType"));
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DataRanges"));
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DiagramData"));
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:View3D"));
- xPopupMenu->insertSeparator( -1 );
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:Cut"));
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:Copy"));
- lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:Paste"));
-
- ::svt::ContextMenuHelper aContextMenuHelper( m_xFrame );
- Point aPos( rCEvt.GetMousePosPixel() );
- if( !rCEvt.IsMouseEvent() )
- aPos = m_pChartWindow->GetPointerState().maPos;
- aContextMenuHelper.completeAndExecute( aPos, xPopupMenu );
}
}
else if( ( rCEvt.GetCommand() == COMMAND_STARTEXTTEXTINPUT ) ||
@@ -1235,17 +1350,21 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt )
{
// Natvigation (Tab/F3/Home/End)
uno::Reference< XChartDocument > xChartDoc( m_aModel->getModel(), uno::UNO_QUERY );
- ObjectKeyNavigation aObjNav( m_aSelection.getSelectedCID(), xChartDoc, ExplicitValueProvider::getExplicitValueProvider( m_xChartView ));
+ ObjectKeyNavigation aObjNav( m_aSelection.getSelectedOID(), xChartDoc, ExplicitValueProvider::getExplicitValueProvider( m_xChartView ));
awt::KeyEvent aKeyEvent( ::svt::AcceleratorExecute::st_VCLKey2AWTKey( aKeyCode ));
bReturn = aObjNav.handleKeyEvent( aKeyEvent );
if( bReturn )
{
- ::rtl::OUString aNewCID = aObjNav.getCurrentSelection();
+ ObjectIdentifier aNewOID = aObjNav.getCurrentSelection();
uno::Any aNewSelection;
- if( aNewCID.getLength()>0 && !ObjectHierarchy::isRootNode( aNewCID ))
- aNewSelection <<= aNewCID;
- if( m_eDragMode == SDRDRAG_ROTATE && !SelectionHelper::isRotateableObject( aNewCID, m_aModel->getModel() ) )
+ if ( aNewOID.isValid() && !ObjectHierarchy::isRootNode( aNewOID ) )
+ {
+ aNewSelection = aNewOID.getAny();
+ }
+ if ( m_eDragMode == SDRDRAG_ROTATE && !SelectionHelper::isRotateableObject( aNewOID.getObjectCID(), m_aModel->getModel() ) )
+ {
m_eDragMode = SDRDRAG_MOVE;
+ }
bReturn = select( aNewSelection );
}
}
@@ -1498,24 +1617,64 @@ bool ChartController::requestQuickHelp(
::select( const uno::Any& rSelection )
throw( lang::IllegalArgumentException )
{
- rtl::OUString aNewCID;
- if( rSelection.hasValue() &&
- ! (rSelection >>= aNewCID))
- return sal_False;
+ bool bSuccess = false;
+ if ( rSelection.hasValue() )
+ {
+ const uno::Type& rType = rSelection.getValueType();
+ if ( rType == ::getCppuType( static_cast< const ::rtl::OUString* >( 0 ) ) )
+ {
+ ::rtl::OUString aNewCID;
+ if ( ( rSelection >>= aNewCID ) && m_aSelection.setSelection( aNewCID ) )
+ {
+ bSuccess = true;
+ }
+ }
+ else if ( rType == ::getCppuType( static_cast< const uno::Reference< drawing::XShape >* >( 0 ) ) )
+ {
+ uno::Reference< drawing::XShape > xShape;
+ if ( ( rSelection >>= xShape ) && m_aSelection.setSelection( xShape ) )
+ {
+ bSuccess = true;
+ }
+ }
+ }
+ else
+ {
+ if ( m_aSelection.hasSelection() )
+ {
+ m_aSelection.clearSelection();
+ bSuccess = true;
+ }
+ }
- if( m_aSelection.setSelection( aNewCID ) )
+ if ( bSuccess )
{
this->impl_selectObjectAndNotiy();
return sal_True;
}
+
return sal_False;
}
uno::Any SAL_CALL ChartController
::getSelection() throw(uno::RuntimeException)
{
- return uno::makeAny(m_aSelection.getSelectedCID());
+ uno::Any aReturn;
+ if ( m_aSelection.hasSelection() )
+ {
+ ::rtl::OUString aCID( m_aSelection.getSelectedCID() );
+ if ( aCID.getLength() )
+ {
+ aReturn = uno::makeAny( aCID );
+ }
+ else
+ {
+ // #i12587# support for shapes in chart
+ aReturn = uno::makeAny( m_aSelection.getSelectedAdditionalShape() );
+ }
+ }
+ return aReturn;
}
void SAL_CALL ChartController
@@ -1701,7 +1860,7 @@ void ChartController::impl_SetMousePointer( const MouseEvent & rEvent )
sal_uInt16 nModifier = rEvent.GetModifier();
BOOL bLeftDown = rEvent.IsLeft();
- if( m_pDrawViewWrapper->IsTextEdit() )
+ if ( m_pDrawViewWrapper->IsTextEdit() )
{
if( m_pDrawViewWrapper->IsTextEditHit( aMousePos, HITPIX) )
{
@@ -1726,7 +1885,7 @@ void ChartController::impl_SetMousePointer( const MouseEvent & rEvent )
aMousePos, pWindow, nModifier, bLeftDown );
bool bForceArrowPointer = false;
- ::rtl::OUString aObjectCID = m_aSelection.getSelectedCID();
+ ObjectIdentifier aOID( m_aSelection.getSelectedOID() );
switch( aPointer.GetStyle())
{
@@ -1742,7 +1901,7 @@ void ChartController::impl_SetMousePointer( const MouseEvent & rEvent )
bForceArrowPointer = true;
break;
case POINTER_MOVE:
- if( ! ObjectIdentifier::isDragableObject( aObjectCID ))
+ if ( !aOID.isDragableObject() )
bForceArrowPointer = true;
break;
case POINTER_MOVEPOINT:
@@ -1762,6 +1921,55 @@ void ChartController::impl_SetMousePointer( const MouseEvent & rEvent )
}
else
{
+ // #i12587# support for shapes in chart
+ if ( m_eDrawMode == CHARTDRAW_INSERT &&
+ ( !m_pDrawViewWrapper->IsMarkedHit( aMousePos ) || !m_aSelection.isDragableObjectSelected() ) )
+ {
+ PointerStyle ePointerStyle = POINTER_DRAW_RECT;
+ SdrObjKind eKind = static_cast< SdrObjKind >( m_pDrawViewWrapper->GetCurrentObjIdentifier() );
+ switch ( eKind )
+ {
+ case OBJ_LINE:
+ {
+ ePointerStyle = POINTER_DRAW_LINE;
+ }
+ break;
+ case OBJ_RECT:
+ case OBJ_CUSTOMSHAPE:
+ {
+ ePointerStyle = POINTER_DRAW_RECT;
+ }
+ break;
+ case OBJ_CIRC:
+ {
+ ePointerStyle = POINTER_DRAW_ELLIPSE;
+ }
+ break;
+ case OBJ_FREELINE:
+ {
+ ePointerStyle = POINTER_DRAW_POLYGON;
+ }
+ break;
+ case OBJ_TEXT:
+ {
+ ePointerStyle = POINTER_DRAW_TEXT;
+ }
+ break;
+ case OBJ_CAPTION:
+ {
+ ePointerStyle = POINTER_DRAW_CAPTION;
+ }
+ break;
+ default:
+ {
+ ePointerStyle = POINTER_DRAW_RECT;
+ }
+ break;
+ }
+ pWindow->SetPointer( Pointer( ePointerStyle ) );
+ return;
+ }
+
::rtl::OUString aHitObjectCID(
SelectionHelper::getHitObjectCID(
aMousePos, *m_pDrawViewWrapper, true /*bGetDiagramInsteadOf_Wall*/ ));
diff --git a/chart2/source/controller/main/ChartTransferable.cxx b/chart2/source/controller/main/ChartTransferable.cxx
index d64f163f634c..80041d4c3818 100644
--- a/chart2/source/controller/main/ChartTransferable.cxx
+++ b/chart2/source/controller/main/ChartTransferable.cxx
@@ -30,12 +30,21 @@
#include "ChartTransferable.hxx"
+#include <unotools/streamwrap.hxx>
#include <vcl/graph.hxx>
+#include <svl/itempool.hxx>
+#include <editeng/eeitem.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <svx/svditer.hxx>
#include <svx/svdmodel.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/unomodel.hxx>
// header for class SdrView
#include <svx/svdview.hxx>
+#define CHARTTRANSFER_OBJECTTYPE_DRAWMODEL 1
+
using namespace ::com::sun::star;
using ::com::sun::star::uno::Reference;
@@ -45,7 +54,9 @@ using ::rtl::OUString;
namespace chart
{
-ChartTransferable::ChartTransferable( SdrModel * pDrawModel, SdrObject * pSelectedObj )
+ChartTransferable::ChartTransferable( SdrModel* pDrawModel, SdrObject* pSelectedObj, bool bDrawing )
+ :m_pMarkedObjModel( NULL )
+ ,m_bDrawing( bDrawing )
{
SdrExchangeView * pExchgView( new SdrView( pDrawModel ));
SdrPageView* pPv = pExchgView->ShowSdrPage( pDrawModel->GetPage( 0 ));
@@ -55,6 +66,10 @@ ChartTransferable::ChartTransferable( SdrModel * pDrawModel, SdrObject * pSelect
pExchgView->MarkAllObj( pPv );
Graphic aGraphic( pExchgView->GetMarkedObjMetaFile( TRUE ));
m_xMetaFileGraphic.set( aGraphic.GetXGraphic());
+ if ( m_bDrawing )
+ {
+ m_pMarkedObjModel = ( pExchgView ? pExchgView->GetAllMarkedModel() : NULL );
+ }
delete pExchgView;
}
@@ -63,6 +78,10 @@ ChartTransferable::~ChartTransferable()
void ChartTransferable::AddSupportedFormats()
{
+ if ( m_bDrawing )
+ {
+ AddFormat( SOT_FORMATSTR_ID_DRAWING );
+ }
AddFormat( SOT_FORMAT_GDIMETAFILE );
AddFormat( SOT_FORMAT_BITMAP );
}
@@ -74,7 +93,11 @@ sal_Bool ChartTransferable::GetData( const ::com::sun::star::datatransfer::DataF
if( HasFormat( nFormat ))
{
- if( nFormat == FORMAT_GDIMETAFILE )
+ if ( nFormat == SOT_FORMATSTR_ID_DRAWING )
+ {
+ bResult = SetObject( m_pMarkedObjModel, CHARTTRANSFER_OBJECTTYPE_DRAWMODEL, rFlavor );
+ }
+ else if ( nFormat == FORMAT_GDIMETAFILE )
{
Graphic aGraphic( m_xMetaFileGraphic );
bResult = SetGDIMetaFile( aGraphic.GetGDIMetaFile(), rFlavor );
@@ -89,5 +112,61 @@ sal_Bool ChartTransferable::GetData( const ::com::sun::star::datatransfer::DataF
return bResult;
}
+sal_Bool ChartTransferable::WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId,
+ const datatransfer::DataFlavor& /* rFlavor */ )
+{
+ // called from SetObject, put data into stream
+
+ sal_Bool bRet = sal_False;
+ switch ( nUserObjectId )
+ {
+ case CHARTTRANSFER_OBJECTTYPE_DRAWMODEL:
+ {
+ SdrModel* pMarkedObjModel = reinterpret_cast< SdrModel* >( pUserObject );
+ if ( pMarkedObjModel )
+ {
+ rxOStm->SetBufferSize( 0xff00 );
+
+ // #108584#
+ // for the changed pool defaults from drawing layer pool set those
+ // attributes as hard attributes to preserve them for saving
+ const SfxItemPool& rItemPool = pMarkedObjModel->GetItemPool();
+ const SvxFontHeightItem& rDefaultFontHeight = static_cast< const SvxFontHeightItem& >(
+ rItemPool.GetDefaultItem( EE_CHAR_FONTHEIGHT ) );
+ sal_uInt16 nCount = pMarkedObjModel->GetPageCount();
+ for ( sal_uInt16 i = 0; i < nCount; ++i )
+ {
+ const SdrPage* pPage = pMarkedObjModel->GetPage( i );
+ SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
+ while ( aIter.IsMore() )
+ {
+ SdrObject* pObj = aIter.Next();
+ const SvxFontHeightItem& rItem = static_cast< const SvxFontHeightItem& >(
+ pObj->GetMergedItem( EE_CHAR_FONTHEIGHT ) );
+ if ( rItem.GetHeight() == rDefaultFontHeight.GetHeight() )
+ {
+ pObj->SetMergedItem( rDefaultFontHeight );
+ }
+ }
+ }
+
+ Reference< io::XOutputStream > xDocOut( new utl::OOutputStreamWrapper( *rxOStm ) );
+ if ( SvxDrawingLayerExport( pMarkedObjModel, xDocOut ) )
+ {
+ rxOStm->Commit();
+ }
+
+ bRet = ( rxOStm->GetError() == ERRCODE_NONE );
+ }
+ }
+ break;
+ default:
+ {
+ DBG_ERROR( "ChartTransferable::WriteObject: unknown object id" );
+ }
+ break;
+ }
+ return bRet;
+}
} // namespace chart
diff --git a/chart2/source/controller/main/ChartTransferable.hxx b/chart2/source/controller/main/ChartTransferable.hxx
index 2ce4e811d809..401f43c6d1ae 100644
--- a/chart2/source/controller/main/ChartTransferable.hxx
+++ b/chart2/source/controller/main/ChartTransferable.hxx
@@ -44,7 +44,7 @@ namespace chart
class ChartTransferable : public TransferableHelper
{
public:
- explicit ChartTransferable( SdrModel * pDrawModel, SdrObject * pSelectedObj );
+ explicit ChartTransferable( SdrModel* pDrawModel, SdrObject* pSelectedObj, bool bDrawing = false );
virtual ~ChartTransferable();
protected:
@@ -52,9 +52,13 @@ protected:
// implementation of TransferableHelper methods
virtual void AddSupportedFormats();
virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
+ virtual sal_Bool WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId,
+ const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
private:
::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > m_xMetaFileGraphic;
+ SdrModel* m_pMarkedObjModel;
+ bool m_bDrawing;
};
} // namespace chart
diff --git a/chart2/source/controller/main/CommandDispatchContainer.cxx b/chart2/source/controller/main/CommandDispatchContainer.cxx
index 09da97b45014..3761d0c33ce0 100644
--- a/chart2/source/controller/main/CommandDispatchContainer.cxx
+++ b/chart2/source/controller/main/CommandDispatchContainer.cxx
@@ -33,6 +33,9 @@
#include "StatusBarCommandDispatch.hxx"
#include "DisposeHelper.hxx"
#include "macros.hxx"
+#include "ChartController.hxx"
+#include "DrawCommandDispatch.hxx"
+#include "ShapeController.hxx"
#include <comphelper/InlineContainer.hxx>
@@ -48,8 +51,11 @@ namespace chart
{
CommandDispatchContainer::CommandDispatchContainer(
- const Reference< uno::XComponentContext > & xContext ) :
- m_xContext( xContext )
+ const Reference< uno::XComponentContext > & xContext, ChartController* pController )
+ :m_xContext( xContext )
+ ,m_pChartController( pController )
+ ,m_pDrawCommandDispatch( NULL )
+ ,m_pShapeController( NULL )
{
m_aContainerDocumentCommands =
::comphelper::MakeSet< OUString >
@@ -75,21 +81,20 @@ void CommandDispatchContainer::setModel(
// m_xUndoManager = xUndoManager;
// }
-void CommandDispatchContainer::setFallbackDispatch(
- const Reference< frame::XDispatch > xFallbackDispatch,
- const ::std::set< OUString > & rFallbackCommands )
+void CommandDispatchContainer::setChartDispatch(
+ const Reference< frame::XDispatch > xChartDispatch,
+ const ::std::set< OUString > & rChartCommands )
{
- OSL_ENSURE(xFallbackDispatch.is(),"Invalid fall back dispatcher!");
- m_xFallbackDispatcher.set( xFallbackDispatch );
- m_aFallbackCommands = rFallbackCommands;
- m_aToBeDisposedDispatches.push_back( m_xFallbackDispatcher );
+ OSL_ENSURE(xChartDispatch.is(),"Invalid fall back dispatcher!");
+ m_xChartDispatcher.set( xChartDispatch );
+ m_aChartCommands = rChartCommands;
+ m_aToBeDisposedDispatches.push_back( m_xChartDispatcher );
}
Reference< frame::XDispatch > CommandDispatchContainer::getDispatchForURL(
const util::URL & rURL )
{
Reference< frame::XDispatch > xResult;
-
tDispatchMap::const_iterator aIt( m_aCachedDispatches.find( rURL.Complete ));
if( aIt != m_aCachedDispatches.end())
{
@@ -127,10 +132,24 @@ Reference< frame::XDispatch > CommandDispatchContainer::getDispatchForURL(
// ToDo: can those dispatches be cached?
m_aCachedDispatches[ rURL.Complete ].set( xResult );
}
- else if( m_xFallbackDispatcher.is() &&
- (m_aFallbackCommands.find( rURL.Path ) != m_aFallbackCommands.end()) )
+ else if( m_xChartDispatcher.is() &&
+ (m_aChartCommands.find( rURL.Path ) != m_aChartCommands.end()) )
+ {
+ xResult.set( m_xChartDispatcher );
+ m_aCachedDispatches[ rURL.Complete ].set( xResult );
+ }
+ // #i12587# support for shapes in chart
+ // Note, that the chart dispatcher must be queried first, because
+ // the chart dispatcher is the default dispatcher for all context
+ // sensitive commands.
+ else if ( m_pDrawCommandDispatch && m_pDrawCommandDispatch->isFeatureSupported( rURL.Complete ) )
+ {
+ xResult.set( m_pDrawCommandDispatch );
+ m_aCachedDispatches[ rURL.Complete ].set( xResult );
+ }
+ else if ( m_pShapeController && m_pShapeController->isFeatureSupported( rURL.Complete ) )
{
- xResult.set( m_xFallbackDispatcher );
+ xResult.set( m_pShapeController );
m_aCachedDispatches[ rURL.Complete ].set( xResult );
}
}
@@ -157,8 +176,11 @@ void CommandDispatchContainer::DisposeAndClear()
m_aCachedDispatches.clear();
DisposeHelper::DisposeAllElements( m_aToBeDisposedDispatches );
m_aToBeDisposedDispatches.clear();
- m_xFallbackDispatcher.clear();
- m_aFallbackCommands.clear();
+ m_xChartDispatcher.clear();
+ m_aChartCommands.clear();
+ m_pChartController = NULL;
+ m_pDrawCommandDispatch = NULL;
+ m_pShapeController = NULL;
}
Reference< frame::XDispatch > CommandDispatchContainer::getContainerDispatchForURL(
@@ -179,4 +201,16 @@ Reference< frame::XDispatch > CommandDispatchContainer::getContainerDispatchForU
return xResult;
}
+void CommandDispatchContainer::setDrawCommandDispatch( DrawCommandDispatch* pDispatch )
+{
+ m_pDrawCommandDispatch = pDispatch;
+ m_aToBeDisposedDispatches.push_back( Reference< frame::XDispatch >( pDispatch ) );
+}
+
+void CommandDispatchContainer::setShapeController( ShapeController* pController )
+{
+ m_pShapeController = pController;
+ m_aToBeDisposedDispatches.push_back( Reference< frame::XDispatch >( pController ) );
+}
+
} // namespace chart
diff --git a/chart2/source/controller/main/CommandDispatchContainer.hxx b/chart2/source/controller/main/CommandDispatchContainer.hxx
index 379e86481db1..2cee65405ef4 100644
--- a/chart2/source/controller/main/CommandDispatchContainer.hxx
+++ b/chart2/source/controller/main/CommandDispatchContainer.hxx
@@ -41,6 +41,10 @@
namespace chart
{
+class ChartController;
+class DrawCommandDispatch;
+class ShapeController;
+
/** @HTML
Helper class for implementing the <code>XDispatchProvider</code> interface
@@ -53,9 +57,9 @@ namespace chart
<li>Check if the command is handled by this class, e.g. Undo. If so,
return a corresponding <code>XDispatch</code> implementation, and cache
this implementation for later use</li>
- <li>Otherwise send the command to the fallback dispatch provider, if it
+ <li>Otherwise send the command to the chart dispatch provider, if it
can handle this dispatch (determined by the list of commands given in
- <code>setFallbackDispatch()</code>).</li>
+ <code>setChartDispatch()</code>).</li>
</ul>
<p>The <code>XDispatch</code>Provider is designed to return different
@@ -65,17 +69,18 @@ namespace chart
<p>As most commands need much information of the controller and are
implemented there, the controller handles most of the commands itself (it
also implements <code>XDispatch</code>). Therefore it is set here as
- fallback dispatch.</p>
+ chart dispatch.</p>
*/
class CommandDispatchContainer
{
public:
- // note: the fallback dispatcher should be removed when all commands are
- // handled by other dispatchers. (Fallback is currently the controller
+ // note: the chart dispatcher should be removed when all commands are
+ // handled by other dispatchers. (Chart is currently the controller
// itself)
explicit CommandDispatchContainer(
const ::com::sun::star::uno::Reference<
- ::com::sun::star::uno::XComponentContext > & xContext );
+ ::com::sun::star::uno::XComponentContext > & xContext,
+ ChartController* pController );
void setModel(
const ::com::sun::star::uno::Reference<
@@ -84,18 +89,18 @@ public:
// const ::com::sun::star::uno::Reference<
// ::com::sun::star::chart2::XUndoManager > & xUndoManager );
- /** Set a fallback dispatcher that is used for all commands contained in
- rFallbackCommands
+ /** Set a chart dispatcher that is used for all commands contained in
+ rChartCommands
*/
- void setFallbackDispatch(
+ void setChartDispatch(
const ::com::sun::star::uno::Reference<
- ::com::sun::star::frame::XDispatch > xFallbackDispatch,
- const ::std::set< ::rtl::OUString > & rFallbackCommands );
+ ::com::sun::star::frame::XDispatch > xChartDispatch,
+ const ::std::set< ::rtl::OUString > & rChartCommands );
/** Returns the dispatch that is able to do the command given in rURL, if
implemented here. If the URL is not implemented here, it should be
- checked whether the command is one of the commands given as fallback via
- the setFallbackDispatch() method. If so, call the fallback dispatch.
+ checked whether the command is one of the commands given via
+ the setChartDispatch() method. If so, call the chart dispatch.
<p>If all this fails, return an empty dispatch.</p>
*/
@@ -116,6 +121,11 @@ public:
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > & xChartController,
const ::com::sun::star::util::URL & rURL );
+ void setDrawCommandDispatch( DrawCommandDispatch* pDispatch );
+ DrawCommandDispatch* getDrawCommandDispatch() { return m_pDrawCommandDispatch; }
+ void setShapeController( ShapeController* pController );
+ ShapeController* getShapeController() { return m_pShapeController; }
+
private:
typedef
::std::map< ::rtl::OUString,
@@ -133,10 +143,14 @@ private:
::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModel;
::com::sun::star::uno::Reference< ::com::sun::star::chart2::XUndoManager > m_xUndoManager;
- ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > m_xFallbackDispatcher;
- ::std::set< ::rtl::OUString > m_aFallbackCommands;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > m_xChartDispatcher;
+ ::std::set< ::rtl::OUString > m_aChartCommands;
::std::set< ::rtl::OUString > m_aContainerDocumentCommands;
+
+ ChartController* m_pChartController;
+ DrawCommandDispatch* m_pDrawCommandDispatch;
+ ShapeController* m_pShapeController;
};
} // namespace chart
diff --git a/chart2/source/controller/main/ControllerCommandDispatch.cxx b/chart2/source/controller/main/ControllerCommandDispatch.cxx
index 5fc58307b7a0..2652aadfdb32 100644
--- a/chart2/source/controller/main/ControllerCommandDispatch.cxx
+++ b/chart2/source/controller/main/ControllerCommandDispatch.cxx
@@ -42,6 +42,7 @@
#include "RegressionCurveHelper.hxx"
#include "DataSeriesHelper.hxx"
#include "StatisticsHelper.hxx"
+#include "ShapeController.hxx"
#include <com/sun/star/util/XModifyBroadcaster.hpp>
#include <com/sun/star/frame/XStorable.hpp>
@@ -178,22 +179,22 @@ void ControllerState::update(
Reference< view::XSelectionSupplier > xSelectionSupplier(
xController, uno::UNO_QUERY );
- OUString aSelObjCID;
-
// Update ControllerState variables.
if( xSelectionSupplier.is())
{
uno::Any aSelObj( xSelectionSupplier->getSelection() );
+ ObjectIdentifier aSelOID( aSelObj );
+ OUString aSelObjCID( aSelOID.getObjectCID() );
- bHasSelectedObject = ((aSelObj >>= aSelObjCID) && aSelObjCID.getLength() > 0);
+ bHasSelectedObject = aSelOID.isValid();
ObjectType aObjectType(ObjectIdentifier::getObjectType( aSelObjCID ));
- bIsPositionableObject = (OBJECTTYPE_DATA_POINT != aObjectType) && ObjectIdentifier::isDragableObject( aSelObjCID );
+ bIsPositionableObject = (OBJECTTYPE_DATA_POINT != aObjectType) && aSelOID.isDragableObject();
bIsTextObject = OBJECTTYPE_TITLE == aObjectType;
uno::Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel ));
- bIsFormateableObjectSelected = bHasSelectedObject;
+ bIsFormateableObjectSelected = bHasSelectedObject && aSelOID.isAutoGeneratedObject();
if( OBJECTTYPE_DIAGRAM==aObjectType || OBJECTTYPE_DIAGRAM_WALL==aObjectType || OBJECTTYPE_DIAGRAM_FLOOR==aObjectType )
bIsFormateableObjectSelected = DiagramHelper::isSupportingFloorAndWall( xDiagram );
@@ -457,13 +458,15 @@ DBG_NAME(ControllerCommandDispatch)
ControllerCommandDispatch::ControllerCommandDispatch(
const Reference< uno::XComponentContext > & xContext,
- const Reference< frame::XController > & xController ) :
+ ChartController* pController, CommandDispatchContainer* pContainer ) :
impl::ControllerCommandDispatch_Base( xContext ),
- m_xController( xController ),
- m_xSelectionSupplier( xController, uno::UNO_QUERY ),
- m_xDispatch( xController, uno::UNO_QUERY ),
+ m_pChartController( pController ),
+ m_xController( Reference< frame::XController >( pController ) ),
+ m_xSelectionSupplier( Reference< view::XSelectionSupplier >( pController ) ),
+ m_xDispatch( Reference< frame::XDispatch >( pController ) ),
m_apModelState( new impl::ModelState() ),
- m_apControllerState( new impl::ControllerState() )
+ m_apControllerState( new impl::ControllerState() ),
+ m_pDispatchContainer( pContainer )
{
DBG_CTOR(ControllerCommandDispatch,NULL);
}
@@ -523,6 +526,8 @@ void ControllerCommandDispatch::updateCommandAvailability()
// @todo: determine correctly
bool bHasSuitableClipboardContent = true;
+ bool bShapeContext = ( m_pChartController ? m_pChartController->isShapeContext() : false );
+
// edit commands
m_aCommandAvailability[ C2U(".uno:Cut")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bIsDeleteableObjectSelected;
m_aCommandAvailability[ C2U(".uno:Copy")] = bControllerStateIsValid && m_apControllerState->bHasSelectedObject;
@@ -540,7 +545,8 @@ void ControllerCommandDispatch::updateCommandAvailability()
m_aCommandAvailability[ C2U(".uno:DefaultColors")] = bIsWritable;
m_aCommandAvailability[ C2U(".uno:BarWidth")] = bIsWritable;
m_aCommandAvailability[ C2U(".uno:NumberOfLines")] = bIsWritable;
- m_aCommandAvailability[ C2U(".uno:ArrangeRow")] = m_apControllerState->bMayMoveSeriesForward || m_apControllerState->bMayMoveSeriesBackward;
+ m_aCommandAvailability[ C2U(".uno:ArrangeRow")] =
+ bShapeContext || ( bIsWritable && bControllerStateIsValid && ( m_apControllerState->bMayMoveSeriesForward || m_apControllerState->bMayMoveSeriesBackward ) );
// insert objects
m_aCommandAvailability[ C2U(".uno:InsertTitles")] = m_aCommandAvailability[ C2U(".uno:InsertMenuTitles")] = bIsWritable;
@@ -574,6 +580,7 @@ void ControllerCommandDispatch::updateCommandAvailability()
m_aCommandAvailability[ C2U(".uno:Legend")] = bIsWritable && m_apModelState->bHasLegend;
m_aCommandAvailability[ C2U(".uno:DiagramWall")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasWall;
m_aCommandAvailability[ C2U(".uno:DiagramArea")] = bIsWritable;
+
m_aCommandAvailability[ C2U(".uno:TransformDialog")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bHasSelectedObject && m_apControllerState->bIsPositionableObject;
// 3d commands
@@ -623,8 +630,10 @@ void ControllerCommandDispatch::updateCommandAvailability()
m_aCommandAvailability[ C2U(".uno:DiagramGridAll")] = bIsWritable && bModelStateIsValid && m_apModelState->HasAnyGrid();
// series arrangement
- m_aCommandAvailability[ C2U(".uno:Forward")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesForward;
- m_aCommandAvailability[ C2U(".uno:Backward")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesBackward;
+ m_aCommandAvailability[ C2U(".uno:Forward")] = ( bShapeContext ? isShapeControllerCommandAvailable( C2U( ".uno:Forward" ) ) :
+ ( bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesForward ) );
+ m_aCommandAvailability[ C2U(".uno:Backward")] = ( bShapeContext ? isShapeControllerCommandAvailable( C2U( ".uno:Backward" ) ) :
+ ( bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesBackward ) );
m_aCommandAvailability[ C2U(".uno:InsertDataLabels")] = bIsWritable;
m_aCommandAvailability[ C2U(".uno:InsertDataLabel")] = bIsWritable;
@@ -667,6 +676,17 @@ bool ControllerCommandDispatch::commandAvailable( const OUString & rCommand )
return false;
}
+bool ControllerCommandDispatch::isShapeControllerCommandAvailable( const ::rtl::OUString& rCommand )
+{
+ ShapeController* pShapeController = ( m_pDispatchContainer ? m_pDispatchContainer->getShapeController() : NULL );
+ if ( pShapeController )
+ {
+ FeatureState aState( pShapeController->getState( rCommand ) );
+ return aState.bEnabled;
+ }
+ return false;
+}
+
void ControllerCommandDispatch::fireStatusEvent(
const OUString & rURL,
const Reference< frame::XStatusListener > & xSingleListener /* = 0 */ )
diff --git a/chart2/source/controller/main/ControllerCommandDispatch.hxx b/chart2/source/controller/main/ControllerCommandDispatch.hxx
index a37d8b059b57..08d57a0d6cbf 100644
--- a/chart2/source/controller/main/ControllerCommandDispatch.hxx
+++ b/chart2/source/controller/main/ControllerCommandDispatch.hxx
@@ -38,6 +38,9 @@
namespace chart
{
+class ChartController;
+class CommandDispatchContainer;
+
namespace impl
{
struct ModelState;
@@ -64,8 +67,7 @@ public:
explicit ControllerCommandDispatch(
const ::com::sun::star::uno::Reference<
::com::sun::star::uno::XComponentContext > & xContext,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::frame::XController > & xController );
+ ChartController* pController, CommandDispatchContainer* pContainer );
virtual ~ControllerCommandDispatch();
// late initialisation, especially for adding as listener
@@ -109,6 +111,9 @@ private:
bool commandAvailable( const ::rtl::OUString & rCommand );
void updateCommandAvailability();
+ bool isShapeControllerCommandAvailable( const ::rtl::OUString& rCommand );
+
+ ChartController* m_pChartController;
::com::sun::star::uno::Reference<
::com::sun::star::frame::XController > m_xController;
::com::sun::star::uno::Reference<
@@ -121,6 +126,8 @@ private:
mutable ::std::map< ::rtl::OUString, bool > m_aCommandAvailability;
mutable ::std::map< ::rtl::OUString, ::com::sun::star::uno::Any > m_aCommandArguments;
+
+ CommandDispatchContainer* m_pDispatchContainer;
};
} // namespace chart
diff --git a/chart2/source/controller/main/DrawCommandDispatch.cxx b/chart2/source/controller/main/DrawCommandDispatch.cxx
new file mode 100644
index 000000000000..aa28028c4861
--- /dev/null
+++ b/chart2/source/controller/main/DrawCommandDispatch.cxx
@@ -0,0 +1,674 @@
+/*************************************************************************
+ *
+ * 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 "DrawCommandDispatch.hxx"
+#include "DrawCommandDispatch.hrc"
+#include "ChartController.hxx"
+#include "DrawViewWrapper.hxx"
+#include "chartview/DrawModelWrapper.hxx"
+#include "macros.hxx"
+
+#include <vos/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <svl/itempool.hxx>
+#include <editeng/adjitem.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/dialmgr.hxx>
+#include <svx/fmmodel.hxx>
+#include <svx/gallery.hxx>
+#include <svx/svdoashp.hxx>
+#include <svx/svdocapt.hxx>
+#include <svx/svdopath.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/unoapi.hxx>
+#include <svx/xlnedit.hxx>
+#include <svx/xlnedwit.hxx>
+#include <svx/xlnwtit.hxx>
+#include <svx/xtable.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+
+#include <boost/bind.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::frame;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+
+
+//.............................................................................
+namespace
+{
+//.............................................................................
+
+ // comparing two PropertyValue instances
+ struct PropertyValueCompare : public ::std::binary_function< beans::PropertyValue, ::rtl::OUString, bool >
+ {
+ bool operator() ( const beans::PropertyValue& rPropValue, const ::rtl::OUString& rName ) const
+ {
+ return rPropValue.Name.equals( rName );
+ }
+ bool operator() ( const ::rtl::OUString& rName, const beans::PropertyValue& rPropValue ) const
+ {
+ return rName.equals( rPropValue.Name );
+ }
+ };
+
+//.............................................................................
+} // anonymous namespace
+//.............................................................................
+
+
+//.............................................................................
+namespace chart
+{
+//.............................................................................
+
+DrawCommandDispatch::DrawCommandDispatch( const Reference< uno::XComponentContext >& rxContext,
+ ChartController* pController )
+ :FeatureCommandDispatchBase( rxContext )
+ ,m_pChartController( pController )
+{
+}
+
+DrawCommandDispatch::~DrawCommandDispatch()
+{
+}
+
+void DrawCommandDispatch::initialize()
+{
+ FeatureCommandDispatchBase::initialize();
+}
+
+bool DrawCommandDispatch::isFeatureSupported( const ::rtl::OUString& rCommandURL )
+{
+ sal_uInt16 nFeatureId = 0;
+ ::rtl::OUString aBaseCommand;
+ ::rtl::OUString aCustomShapeType;
+ return parseCommandURL( rCommandURL, &nFeatureId, &aBaseCommand, &aCustomShapeType );
+}
+
+::basegfx::B2DPolyPolygon getPolygon( sal_uInt16 nResId, SdrModel& rModel )
+{
+ ::basegfx::B2DPolyPolygon aReturn;
+ XLineEndList* pLineEndList = rModel.GetLineEndList();
+ if ( pLineEndList )
+ {
+ String aName( SVX_RES( nResId ) );
+ long nCount = pLineEndList->Count();
+ for ( long nIndex = 0; nIndex < nCount; ++nIndex )
+ {
+ XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nIndex );
+ if ( pEntry->GetName() == aName )
+ {
+ aReturn = pEntry->GetLineEnd();
+ break;
+ }
+ }
+ }
+ return aReturn;
+}
+
+void DrawCommandDispatch::setAttributes( SdrObject* pObj )
+{
+ if ( m_pChartController )
+ {
+ DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper();
+ DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
+ if ( pDrawModelWrapper && pDrawViewWrapper && pDrawViewWrapper->GetCurrentObjIdentifier() == OBJ_CUSTOMSHAPE )
+ {
+ sal_Bool bAttributesAppliedFromGallery = sal_False;
+ if ( GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT ) )
+ {
+ ::std::vector< ::rtl::OUString > aObjList;
+ if ( GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT, aObjList ) )
+ {
+ for ( sal_uInt16 i = 0; i < aObjList.size(); ++i )
+ {
+ if ( aObjList[ i ].equalsIgnoreAsciiCase( m_aCustomShapeType ) )
+ {
+ FmFormModel aModel;
+ SfxItemPool& rPool = aModel.GetItemPool();
+ rPool.FreezeIdRanges();
+ if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aModel ) )
+ {
+ const SdrObject* pSourceObj = aModel.GetPage( 0 )->GetObj( 0 );
+ if ( pSourceObj )
+ {
+ const SfxItemSet& rSource = pSourceObj->GetMergedItemSet();
+ SfxItemSet aDest( pObj->GetModel()->GetItemPool(), // ranges from SdrAttrObj
+ SDRATTR_START, SDRATTR_SHADOW_LAST,
+ SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
+ SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
+ // Graphic Attributes
+ SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST,
+ // 3d Properties
+ SDRATTR_3D_FIRST, SDRATTR_3D_LAST,
+ // CustomShape properties
+ SDRATTR_CUSTOMSHAPE_FIRST, SDRATTR_CUSTOMSHAPE_LAST,
+ // range from SdrTextObj
+ EE_ITEMS_START, EE_ITEMS_END,
+ // end
+ 0, 0);
+ aDest.Set( rSource );
+ pObj->SetMergedItemSet( aDest );
+ sal_Int32 nAngle = pSourceObj->GetRotateAngle();
+ if ( nAngle )
+ {
+ double a = nAngle * F_PI18000;
+ pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle, sin( a ), cos( a ) );
+ }
+ bAttributesAppliedFromGallery = sal_True;
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+ if ( !bAttributesAppliedFromGallery )
+ {
+ pObj->SetMergedItem( SvxAdjustItem( SVX_ADJUST_CENTER, 0 ) );
+ pObj->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
+ pObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK ) );
+ pObj->SetMergedItem( SdrTextAutoGrowHeightItem( sal_False ) );
+ ( dynamic_cast< SdrObjCustomShape* >( pObj ) )->MergeDefaultAttributes( &m_aCustomShapeType );
+ }
+ }
+ }
+}
+
+void DrawCommandDispatch::setLineEnds( SfxItemSet& rAttr )
+{
+ if ( m_nFeatureId == COMMAND_ID_LINE_ARROW_END && m_pChartController )
+ {
+ DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper();
+ DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
+ if ( pDrawModelWrapper && pDrawViewWrapper )
+ {
+ ::basegfx::B2DPolyPolygon aArrow( getPolygon( RID_SVXSTR_ARROW, pDrawModelWrapper->getSdrModel() ) );
+ if ( !aArrow.count() )
+ {
+ ::basegfx::B2DPolygon aNewArrow;
+ aNewArrow.append( ::basegfx::B2DPoint( 10.0, 0.0 ) );
+ aNewArrow.append( ::basegfx::B2DPoint( 0.0, 30.0) );
+ aNewArrow.append( ::basegfx::B2DPoint( 20.0, 30.0 ) );
+ aNewArrow.setClosed( true );
+ aArrow.append( aNewArrow );
+ }
+
+ SfxItemSet aSet( pDrawViewWrapper->GetModel()->GetItemPool() );
+ pDrawViewWrapper->GetAttributes( aSet );
+
+ long nWidth = 300; // (1/100th mm)
+ if ( aSet.GetItemState( XATTR_LINEWIDTH ) != SFX_ITEM_DONTCARE )
+ {
+ long nValue = ( ( const XLineWidthItem& ) aSet.Get( XATTR_LINEWIDTH ) ).GetValue();
+ if ( nValue > 0 )
+ {
+ nWidth = nValue * 3;
+ }
+ }
+
+ rAttr.Put( XLineEndItem( SVX_RESSTR( RID_SVXSTR_ARROW ), aArrow ) );
+ rAttr.Put( XLineEndWidthItem( nWidth ) );
+ }
+ }
+}
+
+// WeakComponentImplHelperBase
+void DrawCommandDispatch::disposing()
+{
+}
+
+// XEventListener
+void DrawCommandDispatch::disposing( const lang::EventObject& /* Source */ )
+ throw (uno::RuntimeException)
+{
+}
+
+FeatureState DrawCommandDispatch::getState( const ::rtl::OUString& rCommand )
+{
+ FeatureState aReturn;
+ aReturn.bEnabled = false;
+ aReturn.aState <<= false;
+
+ sal_uInt16 nFeatureId = 0;
+ ::rtl::OUString aBaseCommand;
+ ::rtl::OUString aCustomShapeType;
+ if ( parseCommandURL( rCommand, &nFeatureId, &aBaseCommand, &aCustomShapeType ) )
+ {
+ switch ( nFeatureId )
+ {
+ case COMMAND_ID_OBJECT_SELECT:
+ case COMMAND_ID_DRAW_LINE:
+ case COMMAND_ID_LINE_ARROW_END:
+ case COMMAND_ID_DRAW_RECT:
+ case COMMAND_ID_DRAW_ELLIPSE:
+ case COMMAND_ID_DRAW_FREELINE_NOFILL:
+ case COMMAND_ID_DRAW_TEXT:
+ case COMMAND_ID_DRAW_CAPTION:
+ case COMMAND_ID_DRAWTBX_CS_BASIC:
+ case COMMAND_ID_DRAWTBX_CS_SYMBOL:
+ case COMMAND_ID_DRAWTBX_CS_ARROW:
+ case COMMAND_ID_DRAWTBX_CS_FLOWCHART:
+ case COMMAND_ID_DRAWTBX_CS_CALLOUT:
+ case COMMAND_ID_DRAWTBX_CS_STAR:
+ {
+ aReturn.bEnabled = true;
+ aReturn.aState <<= false;
+ }
+ break;
+ default:
+ {
+ aReturn.bEnabled = false;
+ aReturn.aState <<= false;
+ }
+ break;
+ }
+ }
+
+ return aReturn;
+}
+
+void DrawCommandDispatch::execute( const ::rtl::OUString& rCommand, const Sequence< beans::PropertyValue>& rArgs )
+{
+ (void)rArgs;
+
+ ChartDrawMode eDrawMode = CHARTDRAW_SELECT;
+ SdrObjKind eKind = OBJ_NONE;
+ bool bCreate = false;
+
+ sal_uInt16 nFeatureId = 0;
+ ::rtl::OUString aBaseCommand;
+ ::rtl::OUString aCustomShapeType;
+ if ( parseCommandURL( rCommand, &nFeatureId, &aBaseCommand, &aCustomShapeType ) )
+ {
+ m_nFeatureId = nFeatureId;
+ m_aCustomShapeType = aCustomShapeType;
+
+ switch ( nFeatureId )
+ {
+ case COMMAND_ID_OBJECT_SELECT:
+ {
+ eDrawMode = CHARTDRAW_SELECT;
+ eKind = OBJ_NONE;
+ }
+ break;
+ case COMMAND_ID_DRAW_LINE:
+ case COMMAND_ID_LINE_ARROW_END:
+ {
+ eDrawMode = CHARTDRAW_INSERT;
+ eKind = OBJ_LINE;
+ }
+ break;
+ case COMMAND_ID_DRAW_RECT:
+ {
+ eDrawMode = CHARTDRAW_INSERT;
+ eKind = OBJ_RECT;
+ }
+ break;
+ case COMMAND_ID_DRAW_ELLIPSE:
+ {
+ eDrawMode = CHARTDRAW_INSERT;
+ eKind = OBJ_CIRC;
+ }
+ break;
+ case COMMAND_ID_DRAW_FREELINE_NOFILL:
+ {
+ eDrawMode = CHARTDRAW_INSERT;
+ eKind = OBJ_FREELINE;
+ }
+ break;
+ case COMMAND_ID_DRAW_TEXT:
+ {
+ eDrawMode = CHARTDRAW_INSERT;
+ eKind = OBJ_TEXT;
+ bCreate = true;
+ }
+ break;
+ case COMMAND_ID_DRAW_CAPTION:
+ {
+ eDrawMode = CHARTDRAW_INSERT;
+ eKind = OBJ_CAPTION;
+ }
+ break;
+ case COMMAND_ID_DRAWTBX_CS_BASIC:
+ case COMMAND_ID_DRAWTBX_CS_SYMBOL:
+ case COMMAND_ID_DRAWTBX_CS_ARROW:
+ case COMMAND_ID_DRAWTBX_CS_FLOWCHART:
+ case COMMAND_ID_DRAWTBX_CS_CALLOUT:
+ case COMMAND_ID_DRAWTBX_CS_STAR:
+ {
+ eDrawMode = CHARTDRAW_INSERT;
+ eKind = OBJ_CUSTOMSHAPE;
+ }
+ break;
+ default:
+ {
+ eDrawMode = CHARTDRAW_SELECT;
+ eKind = OBJ_NONE;
+ }
+ break;
+ }
+
+ if ( m_pChartController )
+ {
+ DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
+ if ( pDrawViewWrapper )
+ {
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ m_pChartController->setDrawMode( eDrawMode );
+ setInsertObj( sal::static_int_cast< USHORT >( eKind ) );
+ if ( bCreate )
+ {
+ pDrawViewWrapper->SetCreateMode();
+ }
+
+ const ::rtl::OUString sKeyModifier( C2U( "KeyModifier" ) );
+ const beans::PropertyValue* pIter = rArgs.getConstArray();
+ const beans::PropertyValue* pEnd = pIter + rArgs.getLength();
+ const beans::PropertyValue* pKeyModifier = ::std::find_if(
+ pIter, pEnd, ::std::bind2nd( PropertyValueCompare(), boost::cref( sKeyModifier ) ) );
+ sal_Int16 nKeyModifier = 0;
+ if ( pKeyModifier && ( pKeyModifier->Value >>= nKeyModifier ) && nKeyModifier == KEY_MOD1 )
+ {
+ if ( eDrawMode == CHARTDRAW_INSERT )
+ {
+ SdrObject* pObj = createDefaultObject( nFeatureId );
+ if ( pObj )
+ {
+ SdrPageView* pPageView = pDrawViewWrapper->GetSdrPageView();
+ pDrawViewWrapper->InsertObjectAtView( pObj, *pPageView );
+ Reference< drawing::XShape > xShape( pObj->getUnoShape(), uno::UNO_QUERY );
+ if ( xShape.is() )
+ {
+ m_pChartController->m_aSelection.setSelection( xShape );
+ m_pChartController->m_aSelection.applySelection( pDrawViewWrapper );
+ }
+ if ( nFeatureId == SID_DRAW_TEXT )
+ {
+ m_pChartController->StartTextEdit();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void DrawCommandDispatch::describeSupportedFeatures()
+{
+ implDescribeSupportedFeature( ".uno:SelectObject", COMMAND_ID_OBJECT_SELECT, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:Line", COMMAND_ID_DRAW_LINE, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:LineArrowEnd", COMMAND_ID_LINE_ARROW_END, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:Rect", COMMAND_ID_DRAW_RECT, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:Ellipse", COMMAND_ID_DRAW_ELLIPSE, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:Freeline_Unfilled", COMMAND_ID_DRAW_FREELINE_NOFILL, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:DrawText", COMMAND_ID_DRAW_TEXT, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:DrawCaption", COMMAND_ID_DRAW_CAPTION, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:BasicShapes", COMMAND_ID_DRAWTBX_CS_BASIC, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:SymbolShapes", COMMAND_ID_DRAWTBX_CS_SYMBOL, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:ArrowShapes", COMMAND_ID_DRAWTBX_CS_ARROW, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:FlowChartShapes", COMMAND_ID_DRAWTBX_CS_FLOWCHART, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:CalloutShapes", COMMAND_ID_DRAWTBX_CS_CALLOUT, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:StarShapes", COMMAND_ID_DRAWTBX_CS_STAR, CommandGroup::INSERT );
+}
+
+void DrawCommandDispatch::setInsertObj( USHORT eObj )
+{
+ DrawViewWrapper* pDrawViewWrapper = ( m_pChartController ? m_pChartController->GetDrawViewWrapper() : NULL );
+ if ( pDrawViewWrapper )
+ {
+ pDrawViewWrapper->SetCurrentObj( eObj /*, Inventor */);
+ }
+}
+
+SdrObject* DrawCommandDispatch::createDefaultObject( const sal_uInt16 nID )
+{
+ SdrObject* pObj = NULL;
+ DrawViewWrapper* pDrawViewWrapper = ( m_pChartController ? m_pChartController->GetDrawViewWrapper() : NULL );
+ DrawModelWrapper* pDrawModelWrapper = ( m_pChartController ? m_pChartController->GetDrawModelWrapper() : NULL );
+
+ if ( pDrawViewWrapper && pDrawModelWrapper )
+ {
+ Reference< drawing::XDrawPage > xDrawPage( pDrawModelWrapper->getMainDrawPage() );
+ SdrPage* pPage = GetSdrPageFromXDrawPage( xDrawPage );
+ if ( pPage )
+ {
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ pObj = SdrObjFactory::MakeNewObject( pDrawViewWrapper->GetCurrentObjInventor(),
+ pDrawViewWrapper->GetCurrentObjIdentifier(), pPage );
+ if ( pObj )
+ {
+ long nDefaultObjectSizeWidth = 4000;
+ long nDefaultObjectSizeHeight = 2500;
+ Size aObjectSize( nDefaultObjectSizeWidth, nDefaultObjectSizeHeight );
+ Rectangle aPageRect( Rectangle( Point( 0, 0 ), pPage->GetSize() ) );
+ Point aObjectPos = aPageRect.Center();
+ aObjectPos.X() -= aObjectSize.Width() / 2;
+ aObjectPos.Y() -= aObjectSize.Height() / 2;
+ Rectangle aRect( aObjectPos, aObjectSize );
+
+ switch ( nID )
+ {
+ case COMMAND_ID_DRAW_LINE:
+ case COMMAND_ID_LINE_ARROW_END:
+ {
+ if ( pObj->ISA( SdrPathObj ) )
+ {
+ Point aStart = aRect.TopLeft();
+ Point aEnd = aRect.BottomRight();
+ sal_Int32 nYMiddle( ( aRect.Top() + aRect.Bottom() ) / 2 );
+ basegfx::B2DPolygon aPoly;
+ aPoly.append( basegfx::B2DPoint( aStart.X(), nYMiddle ) );
+ aPoly.append( basegfx::B2DPoint( aEnd.X(), nYMiddle ) );
+ ( dynamic_cast< SdrPathObj* >( pObj ) )->SetPathPoly( basegfx::B2DPolyPolygon( aPoly ) );
+ SfxItemSet aSet( pDrawModelWrapper->GetItemPool() );
+ setLineEnds( aSet );
+ pObj->SetMergedItemSet( aSet );
+ }
+ }
+ break;
+ case COMMAND_ID_DRAW_FREELINE_NOFILL:
+ {
+ if ( pObj->ISA( SdrPathObj ) )
+ {
+ basegfx::B2DPolygon aInnerPoly;
+ aInnerPoly.append( basegfx::B2DPoint( aRect.Left(), aRect.Bottom() ) );
+ aInnerPoly.appendBezierSegment(
+ basegfx::B2DPoint( aRect.Left(), aRect.Top() ),
+ basegfx::B2DPoint( aRect.Center().X(), aRect.Top() ),
+ basegfx::B2DPoint( aRect.Center().X(), aRect.Center().Y() ) );
+ aInnerPoly.appendBezierSegment(
+ basegfx::B2DPoint( aRect.Center().X(), aRect.Bottom() ),
+ basegfx::B2DPoint( aRect.Right(), aRect.Bottom() ),
+ basegfx::B2DPoint( aRect.Right(), aRect.Top() ) );
+ basegfx::B2DPolyPolygon aPoly;
+ aPoly.append( aInnerPoly );
+ ( dynamic_cast< SdrPathObj* >( pObj ) )->SetPathPoly( aPoly );
+ }
+ }
+ break;
+ case COMMAND_ID_DRAW_TEXT:
+ case COMMAND_ID_DRAW_TEXT_VERTICAL:
+ {
+ if ( pObj->ISA( SdrTextObj ) )
+ {
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj );
+ if ( pTextObj )
+ {
+ pTextObj->SetLogicRect( aRect );
+ BOOL bVertical = ( nID == SID_DRAW_TEXT_VERTICAL );
+ pTextObj->SetVerticalWriting( bVertical );
+ if ( bVertical )
+ {
+ SfxItemSet aSet( pDrawModelWrapper->GetItemPool() );
+ aSet.Put( SdrTextAutoGrowWidthItem( TRUE ) );
+ aSet.Put( SdrTextAutoGrowHeightItem( FALSE ) );
+ aSet.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_TOP ) );
+ aSet.Put( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_RIGHT ) );
+ pTextObj->SetMergedItemSet( aSet );
+ }
+ }
+ }
+ }
+ break;
+ case COMMAND_ID_DRAW_CAPTION:
+ case COMMAND_ID_DRAW_CAPTION_VERTICAL:
+ {
+ if ( pObj->ISA( SdrCaptionObj ) )
+ {
+ sal_Bool bIsVertical( SID_DRAW_CAPTION_VERTICAL == nID );
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj );
+ if ( pTextObj )
+ {
+ pTextObj->SetVerticalWriting( bIsVertical );
+ }
+ if ( bIsVertical )
+ {
+ SfxItemSet aSet( pObj->GetMergedItemSet() );
+ aSet.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
+ aSet.Put( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_RIGHT ) );
+ pObj->SetMergedItemSet( aSet );
+ }
+ SdrCaptionObj* pCaptionObj = dynamic_cast< SdrCaptionObj* >( pObj );
+ if ( pCaptionObj )
+ {
+ pCaptionObj->SetLogicRect( aRect );
+ pCaptionObj->SetTailPos(
+ aRect.TopLeft() - Point( aRect.GetWidth() / 2, aRect.GetHeight() / 2 ) );
+ }
+ }
+ }
+ break;
+ default:
+ {
+ pObj->SetLogicRect( aRect );
+ SfxItemSet aSet( pDrawModelWrapper->GetItemPool() );
+ setAttributes( pObj );
+ pObj->SetMergedItemSet( aSet );
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ return pObj;
+}
+
+bool DrawCommandDispatch::parseCommandURL( const ::rtl::OUString& rCommandURL, sal_uInt16* pnFeatureId,
+ ::rtl::OUString* pBaseCommand, ::rtl::OUString* pCustomShapeType )
+{
+ bool bFound = true;
+ sal_uInt16 nFeatureId = 0;
+ ::rtl::OUString aBaseCommand;
+ ::rtl::OUString aType;
+
+ sal_Int32 nIndex = 1;
+ ::rtl::OUString aToken = rCommandURL.getToken( 0, '.', nIndex );
+ if ( nIndex == -1 || !aToken.getLength() )
+ {
+ aBaseCommand = rCommandURL;
+ SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( aBaseCommand );
+ if ( aIter != m_aSupportedFeatures.end() )
+ {
+ nFeatureId = aIter->second.nFeatureId;
+
+ switch ( nFeatureId )
+ {
+ case COMMAND_ID_DRAWTBX_CS_BASIC:
+ {
+ aType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "diamond" ) );
+ }
+ break;
+ case COMMAND_ID_DRAWTBX_CS_SYMBOL:
+ {
+ aType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "smiley" ) );
+ }
+ break;
+ case COMMAND_ID_DRAWTBX_CS_ARROW:
+ {
+ aType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "left-right-arrow" ) );
+ }
+ break;
+ case COMMAND_ID_DRAWTBX_CS_FLOWCHART:
+ {
+ aType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "flowchart-internal-storage" ) );
+ }
+ break;
+ case COMMAND_ID_DRAWTBX_CS_CALLOUT:
+ {
+ aType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "round-rectangular-callout" ) );
+ }
+ break;
+ case COMMAND_ID_DRAWTBX_CS_STAR:
+ {
+ aType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "star5" ) );
+ }
+ break;
+ default:
+ {
+ }
+ break;
+ }
+ }
+ else
+ {
+ bFound = false;
+ }
+ }
+ else
+ {
+ aBaseCommand = rCommandURL.copy( 0, nIndex - 1 );
+ SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( aBaseCommand );
+ if ( aIter != m_aSupportedFeatures.end() )
+ {
+ nFeatureId = aIter->second.nFeatureId;
+ aType = rCommandURL.getToken( 0, '.', nIndex );
+ }
+ else
+ {
+ bFound = false;
+ }
+ }
+
+ *pnFeatureId = nFeatureId;
+ *pBaseCommand = aBaseCommand;
+ *pCustomShapeType = aType;
+
+ return bFound;
+}
+
+//.............................................................................
+} // namespace chart
+//.............................................................................
diff --git a/chart2/source/controller/main/DrawCommandDispatch.hrc b/chart2/source/controller/main/DrawCommandDispatch.hrc
new file mode 100644
index 000000000000..4e31fafaaf63
--- /dev/null
+++ b/chart2/source/controller/main/DrawCommandDispatch.hrc
@@ -0,0 +1,50 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef CHART_DRAWCOMMANDDISPATCH_HRC
+#define CHART_DRAWCOMMANDDISPATCH_HRC
+
+//-----------------------------------------------------------------------------
+//Command Ids:
+#define COMMAND_ID_OBJECT_SELECT 1
+#define COMMAND_ID_DRAW_LINE 2
+#define COMMAND_ID_LINE_ARROW_END 3
+#define COMMAND_ID_DRAW_RECT 4
+#define COMMAND_ID_DRAW_ELLIPSE 5
+#define COMMAND_ID_DRAW_FREELINE_NOFILL 6
+#define COMMAND_ID_DRAW_TEXT 7
+#define COMMAND_ID_DRAW_TEXT_VERTICAL 8
+#define COMMAND_ID_DRAW_CAPTION 9
+#define COMMAND_ID_DRAW_CAPTION_VERTICAL 10
+#define COMMAND_ID_DRAWTBX_CS_BASIC 11
+#define COMMAND_ID_DRAWTBX_CS_SYMBOL 12
+#define COMMAND_ID_DRAWTBX_CS_ARROW 13
+#define COMMAND_ID_DRAWTBX_CS_FLOWCHART 14
+#define COMMAND_ID_DRAWTBX_CS_CALLOUT 15
+#define COMMAND_ID_DRAWTBX_CS_STAR 16
+
+// CHART_DRAWCOMMANDDISPATCH_HRC
+#endif
diff --git a/chart2/source/controller/main/DrawCommandDispatch.hxx b/chart2/source/controller/main/DrawCommandDispatch.hxx
new file mode 100644
index 000000000000..38c886e29abb
--- /dev/null
+++ b/chart2/source/controller/main/DrawCommandDispatch.hxx
@@ -0,0 +1,93 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef CHART2_DRAWCOMMANDDISPATCH_HXX
+#define CHART2_DRAWCOMMANDDISPATCH_HXX
+
+#include "FeatureCommandDispatchBase.hxx"
+
+#include <tools/solar.h>
+
+class SfxItemSet;
+class SdrObject;
+
+//.............................................................................
+namespace chart
+{
+//.............................................................................
+
+class ChartController;
+
+/** This is a CommandDispatch implementation for drawing objects.
+ */
+class DrawCommandDispatch: public FeatureCommandDispatchBase
+{
+public:
+ DrawCommandDispatch( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XComponentContext >& rxContext, ChartController* pController );
+ virtual ~DrawCommandDispatch();
+
+ // late initialisation, especially for adding as listener
+ virtual void initialize();
+
+ virtual bool isFeatureSupported( const ::rtl::OUString& rCommandURL );
+
+ void setAttributes( SdrObject* pObj );
+ void setLineEnds( SfxItemSet& rAttr );
+
+protected:
+ // WeakComponentImplHelperBase
+ virtual void SAL_CALL disposing();
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // state of a feature
+ virtual FeatureState getState( const ::rtl::OUString& rCommand );
+
+ // execute a feature
+ virtual void execute( const ::rtl::OUString& rCommand, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rArgs );
+
+ // all the features which should be handled by this class
+ virtual void describeSupportedFeatures();
+
+private:
+ void setInsertObj( USHORT eObj );
+ SdrObject* createDefaultObject( const sal_uInt16 nID );
+
+ bool parseCommandURL( const ::rtl::OUString& rCommandURL, sal_uInt16* pnFeatureId, ::rtl::OUString* pBaseCommand, ::rtl::OUString* pCustomShapeType );
+
+ ChartController* m_pChartController;
+ ::rtl::OUString m_aCustomShapeType;
+};
+
+//.............................................................................
+} // namespace chart
+//.............................................................................
+
+// CHART2_DRAWCOMMANDDISPATCH_HXX
+#endif
diff --git a/chart2/source/controller/main/ElementSelector.cxx b/chart2/source/controller/main/ElementSelector.cxx
index 49a8736bb11b..3b41fd1b6b66 100644
--- a/chart2/source/controller/main/ElementSelector.cxx
+++ b/chart2/source/controller/main/ElementSelector.cxx
@@ -34,6 +34,9 @@
#include "ObjectHierarchy.hxx"
#include "servicenames.hxx"
#include <chartview/ExplicitValueProvider.hxx>
+#include "DrawViewWrapper.hxx"
+#include "ResId.hxx"
+#include "Strings.hrc"
#include <toolkit/helper/vclunohelper.hxx>
#include <vos/mutex.hxx>
@@ -71,20 +74,21 @@ SelectorListBox::~SelectorListBox()
{
}
-void lcl_addObjectsToList( const ObjectHierarchy& rHierarchy, const ObjectHierarchy::tCID & rParent, std::vector< ListBoxEntryData >& rEntries
+void lcl_addObjectsToList( const ObjectHierarchy& rHierarchy, const ObjectHierarchy::tOID & rParent, std::vector< ListBoxEntryData >& rEntries
, const sal_Int32 nHierarchyDepth, const Reference< chart2::XChartDocument >& xChartDoc )
{
ObjectHierarchy::tChildContainer aChildren( rHierarchy.getChildren(rParent) );
ObjectHierarchy::tChildContainer::const_iterator aIt( aChildren.begin());
while( aIt != aChildren.end() )
{
- ::rtl::OUString aCID = *aIt;
+ ObjectHierarchy::tOID aOID = *aIt;
+ ::rtl::OUString aCID = aOID.getObjectCID();
ListBoxEntryData aEntry;
- aEntry.CID = aCID;
+ aEntry.OID = aOID;
aEntry.UIName += ObjectNameProvider::getNameForCID( aCID, xChartDoc );
aEntry.nHierarchyDepth = nHierarchyDepth;
rEntries.push_back(aEntry);
- lcl_addObjectsToList( rHierarchy, aCID, rEntries, nHierarchyDepth+1, xChartDoc );
+ lcl_addObjectsToList( rHierarchy, aOID, rEntries, nHierarchyDepth+1, xChartDoc );
++aIt;
}
}
@@ -103,14 +107,18 @@ void SelectorListBox::UpdateChartElementsListAndSelection()
if( xChartController.is() )
{
Reference< view::XSelectionSupplier > xSelectionSupplier( xChartController, uno::UNO_QUERY);
+ ObjectHierarchy::tOID aSelectedOID;
rtl::OUString aSelectedCID;
if( xSelectionSupplier.is() )
- xSelectionSupplier->getSelection() >>= aSelectedCID;
+ {
+ aSelectedOID = ObjectIdentifier( xSelectionSupplier->getSelection() );
+ aSelectedCID = aSelectedOID.getObjectCID();
+ }
Reference< chart2::XChartDocument > xChartDoc( xChartController->getModel(), uno::UNO_QUERY );
- ObjectType eType( ObjectIdentifier::getObjectType( aSelectedCID ));
+ ObjectType eType( aSelectedOID.getObjectType() );
bool bAddSelectionToList = false;
- if( eType == OBJECTTYPE_DATA_POINT || eType == OBJECTTYPE_DATA_LABEL )
+ if ( eType == OBJECTTYPE_DATA_POINT || eType == OBJECTTYPE_DATA_LABEL || eType == OBJECTTYPE_SHAPE )
bAddSelectionToList = true;
Reference< uno::XInterface > xChartView;
@@ -119,27 +127,39 @@ void SelectorListBox::UpdateChartElementsListAndSelection()
xChartView = xFact->createInstance( CHART_VIEW_SERVICE_NAME );
ExplicitValueProvider* pExplicitValueProvider = 0;//ExplicitValueProvider::getExplicitValueProvider(xChartView); dies erzeugt alle sichtbaren datenpinkte, das ist zu viel
ObjectHierarchy aHierarchy( xChartDoc, pExplicitValueProvider, true /*bFlattenDiagram*/, true /*bOrderingForElementSelector*/ );
- lcl_addObjectsToList( aHierarchy, aHierarchy.getRootNodeCID(), m_aEntries, 0, xChartDoc );
+ lcl_addObjectsToList( aHierarchy, aHierarchy.getRootNodeOID(), m_aEntries, 0, xChartDoc );
std::vector< ListBoxEntryData >::iterator aIt( m_aEntries.begin() );
if( bAddSelectionToList )
{
- rtl::OUString aSeriesCID = ObjectIdentifier::createClassifiedIdentifierForParticle( ObjectIdentifier::getSeriesParticleFromCID( aSelectedCID ) );
- for( aIt = m_aEntries.begin(); aIt != m_aEntries.end(); ++aIt )
+ if ( aSelectedOID.isAutoGeneratedObject() )
{
- if( aIt->CID.match( aSeriesCID ) )
+ rtl::OUString aSeriesCID = ObjectIdentifier::createClassifiedIdentifierForParticle( ObjectIdentifier::getSeriesParticleFromCID( aSelectedCID ) );
+ for( aIt = m_aEntries.begin(); aIt != m_aEntries.end(); ++aIt )
{
- ListBoxEntryData aEntry;
- aEntry.UIName = ObjectNameProvider::getNameForCID( aSelectedCID, xChartDoc );
- aEntry.CID = aSelectedCID;
- ++aIt;
- if( aIt != m_aEntries.end() )
- m_aEntries.insert(aIt, aEntry);
- else
- m_aEntries.push_back( aEntry );
- break;
+ if( aIt->OID.getObjectCID().match( aSeriesCID ) )
+ {
+ ListBoxEntryData aEntry;
+ aEntry.UIName = ObjectNameProvider::getNameForCID( aSelectedCID, xChartDoc );
+ aEntry.OID = aSelectedOID;
+ ++aIt;
+ if( aIt != m_aEntries.end() )
+ m_aEntries.insert(aIt, aEntry);
+ else
+ m_aEntries.push_back( aEntry );
+ break;
+ }
}
}
+ else if ( aSelectedOID.isAdditionalShape() )
+ {
+ ListBoxEntryData aEntry;
+ SdrObject* pSelectedObj = DrawViewWrapper::getSdrObject( aSelectedOID.getAdditionalShape() );
+ ::rtl::OUString aName( pSelectedObj ? pSelectedObj->GetName() : String() );
+ aEntry.UIName = ( aName.getLength() > 0 ? aName : ::rtl::OUString( String( SchResId( STR_OBJECT_SHAPE ) ) ) );
+ aEntry.OID = aSelectedOID;
+ m_aEntries.push_back( aEntry );
+ }
}
USHORT nEntryPosToSelect = 0; bool bSelectionFound = false;
@@ -147,7 +167,7 @@ void SelectorListBox::UpdateChartElementsListAndSelection()
for( USHORT nN=0; aIt != m_aEntries.end(); ++aIt, ++nN )
{
InsertEntry( aIt->UIName );
- if( !bSelectionFound && aSelectedCID.equals( aIt->CID ) )
+ if ( !bSelectionFound && aSelectedOID == aIt->OID )
{
nEntryPosToSelect = nN;
bSelectionFound = true;
@@ -188,11 +208,10 @@ void SelectorListBox::Select()
USHORT nPos = GetSelectEntryPos();
if( nPos < m_aEntries.size() )
{
- rtl::OUString aCID = m_aEntries[nPos].CID;
- uno::Any aASelection( uno::makeAny(aCID) );
+ ObjectHierarchy::tOID aOID = m_aEntries[nPos].OID;
Reference< view::XSelectionSupplier > xSelectionSupplier( m_xChartController.get(), uno::UNO_QUERY );
if( xSelectionSupplier.is() )
- xSelectionSupplier->select(aASelection);
+ xSelectionSupplier->select( aOID.getAny() );
}
ReleaseFocus_Impl();
}
diff --git a/chart2/source/controller/main/ElementSelector.hxx b/chart2/source/controller/main/ElementSelector.hxx
index 6f51c1df0ce6..d85415d614e2 100644
--- a/chart2/source/controller/main/ElementSelector.hxx
+++ b/chart2/source/controller/main/ElementSelector.hxx
@@ -28,6 +28,7 @@
#define _CHART_ELEMENTSELECTOR_HXX
#include "ServiceMacros.hxx"
+#include "ObjectHierarchy.hxx"
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <cppuhelper/implbase1.hxx>
#include <svtools/toolboxcontroller.hxx>
@@ -45,7 +46,7 @@ namespace chart
struct ListBoxEntryData
{
rtl::OUString UIName;
- rtl::OUString CID;
+ ObjectHierarchy::tOID OID;
sal_Int32 nHierarchyDepth;
ListBoxEntryData() : nHierarchyDepth(0)
diff --git a/chart2/source/controller/main/FeatureCommandDispatchBase.cxx b/chart2/source/controller/main/FeatureCommandDispatchBase.cxx
new file mode 100644
index 000000000000..39b4e1d4a171
--- /dev/null
+++ b/chart2/source/controller/main/FeatureCommandDispatchBase.cxx
@@ -0,0 +1,114 @@
+/*************************************************************************
+ *
+ * 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 "FeatureCommandDispatchBase.hxx"
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+
+namespace chart
+{
+
+FeatureCommandDispatchBase::FeatureCommandDispatchBase( const Reference< uno::XComponentContext >& rxContext )
+ :CommandDispatch( rxContext )
+ ,m_nFeatureId( 0 )
+{
+}
+
+FeatureCommandDispatchBase::~FeatureCommandDispatchBase()
+{
+}
+
+void FeatureCommandDispatchBase::initialize()
+{
+ CommandDispatch::initialize();
+ fillSupportedFeatures();
+}
+
+bool FeatureCommandDispatchBase::isFeatureSupported( const ::rtl::OUString& rCommandURL )
+{
+ SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( rCommandURL );
+ if ( aIter != m_aSupportedFeatures.end() )
+ {
+ return true;
+ }
+ return false;
+}
+
+void FeatureCommandDispatchBase::fireStatusEvent( const ::rtl::OUString& rURL,
+ const Reference< frame::XStatusListener >& xSingleListener /* = 0 */ )
+{
+ if ( rURL.getLength() == 0 )
+ {
+ SupportedFeatures::const_iterator aEnd( m_aSupportedFeatures.end() );
+ for ( SupportedFeatures::const_iterator aIter( m_aSupportedFeatures.begin() ); aIter != aEnd; ++aIter )
+ {
+ FeatureState aFeatureState( getState( aIter->first ) );
+ fireStatusEventForURL( aIter->first, aFeatureState.aState, aFeatureState.bEnabled, xSingleListener );
+ }
+ }
+ else
+ {
+ FeatureState aFeatureState( getState( rURL ) );
+ fireStatusEventForURL( rURL, aFeatureState.aState, aFeatureState.bEnabled, xSingleListener );
+ }
+}
+
+// XDispatch
+void FeatureCommandDispatchBase::dispatch( const util::URL& URL,
+ const Sequence< beans::PropertyValue >& Arguments )
+ throw (uno::RuntimeException)
+{
+ ::rtl::OUString aCommand( URL.Complete );
+ if ( getState( aCommand ).bEnabled )
+ {
+ execute( aCommand, Arguments );
+ }
+}
+
+void FeatureCommandDispatchBase::implDescribeSupportedFeature( const sal_Char* pAsciiCommandURL,
+ sal_uInt16 nId, sal_Int16 nGroup )
+{
+ ControllerFeature aFeature;
+ aFeature.Command = ::rtl::OUString::createFromAscii( pAsciiCommandURL );
+ aFeature.nFeatureId = nId;
+ aFeature.GroupId = nGroup;
+
+ m_aSupportedFeatures[ aFeature.Command ] = aFeature;
+}
+
+void FeatureCommandDispatchBase::fillSupportedFeatures()
+{
+ describeSupportedFeatures();
+}
+
+} // namespace chart
diff --git a/chart2/source/controller/main/FeatureCommandDispatchBase.hxx b/chart2/source/controller/main/FeatureCommandDispatchBase.hxx
new file mode 100644
index 000000000000..b3e2a568d3b9
--- /dev/null
+++ b/chart2/source/controller/main/FeatureCommandDispatchBase.hxx
@@ -0,0 +1,115 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef CHART2_FEATURECOMMANDDISPATCHBASE_HXX
+#define CHART2_FEATURECOMMANDDISPATCHBASE_HXX
+
+#include "CommandDispatch.hxx"
+
+#include <com/sun/star/frame/CommandGroup.hpp>
+#include <com/sun/star/frame/DispatchInformation.hpp>
+#include <com/sun/star/util/URL.hpp>
+
+namespace chart
+{
+
+struct ControllerFeature: public ::com::sun::star::frame::DispatchInformation
+{
+ sal_uInt16 nFeatureId;
+};
+
+typedef ::std::map< ::rtl::OUString,
+ ControllerFeature,
+ ::std::less< ::rtl::OUString > > SupportedFeatures;
+
+struct FeatureState
+{
+ bool bEnabled;
+ ::com::sun::star::uno::Any aState;
+
+ FeatureState() : bEnabled( false ) { }
+};
+
+/** This is a base class for CommandDispatch implementations with feature support.
+ */
+class FeatureCommandDispatchBase: public CommandDispatch
+{
+public:
+ FeatureCommandDispatchBase( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XComponentContext >& rxContext );
+ virtual ~FeatureCommandDispatchBase();
+
+ // late initialisation, especially for adding as listener
+ virtual void initialize();
+
+ virtual bool isFeatureSupported( const ::rtl::OUString& rCommandURL );
+
+protected:
+ // XDispatch
+ virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& URL,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void fireStatusEvent( const ::rtl::OUString& rURL,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xSingleListener );
+
+ // state of a feature
+ virtual FeatureState getState( const ::rtl::OUString& rCommand ) = 0;
+
+ // execute a feature
+ virtual void execute( const ::rtl::OUString& rCommand, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rArgs ) = 0;
+
+ // all the features which should be handled by this class
+ virtual void describeSupportedFeatures() = 0;
+
+ /** describes a feature supported by the controller
+
+ Must not be called outside <member>describeSupportedFeatures</member>.
+
+ @param pAsciiCommandURL
+ the URL of the feature command
+ @param nId
+ the id of the feature. Later references to this feature usually happen by id, not by
+ URL.
+ @param nGroup
+ the command group of the feature. This is important for configuring the controller UI
+ by the user, see also <type scope="com::sun::star::frame">CommandGroup</type>.
+ */
+ void implDescribeSupportedFeature( const sal_Char* pAsciiCommandURL, sal_uInt16 nId,
+ sal_Int16 nGroup = ::com::sun::star::frame::CommandGroup::INTERNAL );
+
+ mutable SupportedFeatures m_aSupportedFeatures;
+
+ sal_uInt16 m_nFeatureId;
+
+private:
+ void fillSupportedFeatures();
+};
+
+} // namespace chart
+
+// CHART2_FEATURECOMMANDDISPATCHBASE_HXX
+#endif
diff --git a/chart2/source/tools/ImplUndoManager.cxx b/chart2/source/controller/main/ImplUndoManager.cxx
index 7d128bd2a9d1..57e8e7315334 100644
--- a/chart2/source/tools/ImplUndoManager.cxx
+++ b/chart2/source/controller/main/ImplUndoManager.cxx
@@ -36,7 +36,7 @@
#include "DataSourceHelper.hxx"
#include "ChartModelHelper.hxx"
-#include <com/sun/star/chart/XChartDataArray.hpp>
+#include <com/sun/star/chart/XComplexDescriptionAccess.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/chart2/XInternalDataProvider.hpp>
#include <com/sun/star/chart2/XTitled.hpp>
@@ -52,7 +52,7 @@ using namespace ::com::sun::star;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
using ::rtl::OUString;
-using ::com::sun::star::chart::XChartDataArray;
+using ::com::sun::star::chart::XComplexDescriptionAccess;
namespace chart
{
@@ -69,13 +69,13 @@ void ImplApplyDataToModel(
// copy data from stored internal data provider
if( xDoc.is() && xDoc->hasInternalDataProvider())
{
- Reference< XChartDataArray > xCurrentData( xDoc->getDataProvider(), uno::UNO_QUERY );
- Reference< XChartDataArray > xSavedData( xData, uno::UNO_QUERY );
+ Reference< XComplexDescriptionAccess > xCurrentData( xDoc->getDataProvider(), uno::UNO_QUERY );
+ Reference< XComplexDescriptionAccess > xSavedData( xData, uno::UNO_QUERY );
if( xCurrentData.is() && xSavedData.is())
{
xCurrentData->setData( xSavedData->getData());
- xCurrentData->setRowDescriptions( xSavedData->getRowDescriptions());
- xCurrentData->setColumnDescriptions( xSavedData->getColumnDescriptions());
+ xCurrentData->setComplexRowDescriptions( xSavedData->getComplexRowDescriptions());
+ xCurrentData->setComplexColumnDescriptions( xSavedData->getComplexColumnDescriptions());
}
}
}
@@ -107,7 +107,10 @@ UndoElement::~UndoElement()
void UndoElement::initialize( const Reference< frame::XModel > & xModel )
{
- m_xModel.set( UndoElement::cloneModel( xModel ));
+ if ( xModel.is() )
+ {
+ m_xModel.set( UndoElement::cloneModel( xModel ) );
+ }
}
void UndoElement::dispose()
@@ -353,6 +356,29 @@ UndoElement * UndoElementWithSelection::createFromModel(
return new UndoElementWithSelection( getActionString(), xModel );
}
+// ----------------------------------------
+
+ShapeUndoElement::ShapeUndoElement( const OUString& rActionString, SdrUndoAction* pAction )
+ :UndoElement( rActionString, Reference< frame::XModel >() )
+ ,m_pAction( pAction )
+{
+}
+
+ShapeUndoElement::ShapeUndoElement( const ShapeUndoElement& rOther )
+ :UndoElement( rOther )
+ ,m_pAction( rOther.m_pAction )
+{
+}
+
+ShapeUndoElement::~ShapeUndoElement()
+{
+}
+
+SdrUndoAction* ShapeUndoElement::getSdrUndoAction()
+{
+ return m_pAction;
+}
+
// ========================================
UndoStack::UndoStack() :
diff --git a/chart2/source/tools/ImplUndoManager.hxx b/chart2/source/controller/main/ImplUndoManager.hxx
index 8c6cfa48979f..4dde0bc65719 100644
--- a/chart2/source/tools/ImplUndoManager.hxx
+++ b/chart2/source/controller/main/ImplUndoManager.hxx
@@ -38,6 +38,9 @@
#include <utility>
#include <deque>
+
+class SdrUndoAction;
+
namespace com { namespace sun { namespace star {
namespace chart2 {
class XInternalDataProvider;
@@ -146,6 +149,19 @@ private:
::com::sun::star::uno::Any m_aSelection;
};
+class ShapeUndoElement : public UndoElement
+{
+public:
+ ShapeUndoElement( const ::rtl::OUString& rActionString, SdrUndoAction* pAction );
+ ShapeUndoElement( const ShapeUndoElement& rOther );
+ virtual ~ShapeUndoElement();
+
+ SdrUndoAction* getSdrUndoAction();
+
+private:
+ SdrUndoAction* m_pAction;
+};
+
/** Note that all models that are put into this container are at some point
disposed of inside this class. (At least in the destructor). That means
the models retrieved here should never be used, but instead their content
diff --git a/chart2/source/controller/main/ObjectHierarchy.cxx b/chart2/source/controller/main/ObjectHierarchy.cxx
index bb290425090c..0fefa3d52310 100644
--- a/chart2/source/controller/main/ObjectHierarchy.cxx
+++ b/chart2/source/controller/main/ObjectHierarchy.cxx
@@ -40,6 +40,7 @@
#include "ChartTypeHelper.hxx"
#include "DataSeriesHelper.hxx"
#include "LegendHelper.hxx"
+#include "chartview/DrawModelWrapper.hxx"
#include <map>
#include <algorithm>
@@ -63,24 +64,25 @@ using ::rtl::OUString;
namespace
{
-struct lcl_ObjectToCID : public ::std::unary_function< Reference< uno::XInterface >, OUString >
+
+struct lcl_ObjectToOID : public ::std::unary_function< Reference< uno::XInterface >, ::chart::ObjectIdentifier >
{
- explicit lcl_ObjectToCID( const Reference< chart2::XChartDocument > & xChartDoc ) :
+ explicit lcl_ObjectToOID( const Reference< chart2::XChartDocument > & xChartDoc ) :
m_xModel( xChartDoc, uno::UNO_QUERY )
{}
- OUString operator() ( const Reference< uno::XInterface > & xObj )
+ ::chart::ObjectIdentifier operator() ( const Reference< uno::XInterface > & xObj )
{
- return ::chart::ObjectIdentifier::createClassifiedIdentifierForObject( xObj, m_xModel );
+ return ::chart::ObjectIdentifier( ::chart::ObjectIdentifier::createClassifiedIdentifierForObject( xObj, m_xModel ) );
}
private:
Reference< frame::XModel > m_xModel;
};
-void lcl_getChildCIDs(
- ::chart::ObjectHierarchy::tChildContainer & rOutChildren,
- const Reference< container::XIndexAccess > & xShapes )
+void lcl_getChildOIDs(
+ ::chart::ObjectHierarchy::tChildContainer& rOutChildren,
+ const Reference< container::XIndexAccess >& xShapes )
{
if( xShapes.is())
{
@@ -98,11 +100,11 @@ void lcl_getChildCIDs(
aName.getLength() > 0 &&
::chart::ObjectIdentifier::isCID( aName ))
{
- rOutChildren.push_back( aName );
+ rOutChildren.push_back( ::chart::ObjectIdentifier( aName ) );
}
Reference< container::XIndexAccess > xNewShapes( xShapeProp, uno::UNO_QUERY );
if( xNewShapes.is())
- lcl_getChildCIDs( rOutChildren, xNewShapes );
+ lcl_getChildOIDs( rOutChildren, xNewShapes );
}
}
}
@@ -116,31 +118,31 @@ void lcl_addAxisTitle( const Reference< XAxis >& xAxis, ::chart::ObjectHierarchy
Reference< XTitle > xAxisTitle( xAxisTitled->getTitleObject());
if( xAxisTitle.is())
rContainer.push_back(
- ::chart::ObjectIdentifier::createClassifiedIdentifierForObject( xAxisTitle, xChartModel ));
+ ::chart::ObjectIdentifier( ::chart::ObjectIdentifier::createClassifiedIdentifierForObject( xAxisTitle, xChartModel ) ) );
}
}
} // anonymous namespace
-
namespace chart
{
namespace impl
{
+
class ImplObjectHierarchy
{
public:
explicit ImplObjectHierarchy(
- const Reference< XChartDocument > & xChartDocument,
- ExplicitValueProvider * pExplicitValueProvider,
+ const Reference< XChartDocument >& xChartDocument,
+ ExplicitValueProvider* pExplicitValueProvider,
bool bFlattenDiagram, bool bOrderingForElementSelector );
- bool hasChildren( const OUString & rParent );
- ObjectHierarchy::tChildContainer getChildren( const OUString & rParent );
- ObjectHierarchy::tChildContainer getSiblings( const OUString & rNode );
+ bool hasChildren( const ObjectHierarchy::tOID& rParent );
+ ObjectHierarchy::tChildContainer getChildren( const ObjectHierarchy::tOID& rParent );
+ ObjectHierarchy::tChildContainer getSiblings( const ObjectHierarchy::tOID& rNode );
- ObjectHierarchy::tCID getParent( const ObjectHierarchy::tCID & rCID );
+ ObjectHierarchy::tOID getParent( const ObjectHierarchy::tOID& rOID );
private:
void createTree( const Reference< XChartDocument > & xChartDocument );
@@ -149,9 +151,9 @@ private:
const Reference< XChartDocument > & xChartDoc,
const Reference< XDiagram > & xDiagram );
void createDiagramTree(
- ObjectHierarchy::tChildContainer & rContainer,
- const Reference< XChartDocument > & xChartDoc,
- const Reference< XDiagram > & xDiagram );
+ ObjectHierarchy::tChildContainer& rContainer,
+ const Reference< XChartDocument >& xChartDoc,
+ const Reference< XDiagram >& xDiagram );
void createDataSeriesTree(
ObjectHierarchy::tChildContainer & rOutDiagramSubContainer,
const Reference< XDiagram > & xDiagram );
@@ -162,22 +164,23 @@ private:
ObjectHierarchy::tChildContainer & rContainer,
const Reference< XChartDocument > & xChartDoc,
const Reference< XDiagram > & xDiagram );
+ void createAdditionalShapesTree( ObjectHierarchy::tChildContainer& rContainer );
- ObjectHierarchy::tCID getParentImpl(
- const ObjectHierarchy::tCID & rParentCID,
- const ObjectHierarchy::tCID & rCID );
+ ObjectHierarchy::tOID getParentImpl(
+ const ObjectHierarchy::tOID& rParentOID,
+ const ObjectHierarchy::tOID& rOID );
- typedef ::std::map< OUString, ObjectHierarchy::tChildContainer >
+ typedef ::std::map< ObjectHierarchy::tOID, ObjectHierarchy::tChildContainer >
tChildMap;
tChildMap m_aChildMap;
- ExplicitValueProvider * m_pExplicitValueProvider;
+ ExplicitValueProvider* m_pExplicitValueProvider;
bool m_bFlattenDiagram;
bool m_bOrderingForElementSelector;
};
ImplObjectHierarchy::ImplObjectHierarchy(
- const Reference< XChartDocument > & xChartDocument,
- ExplicitValueProvider * pExplicitValueProvider,
+ const Reference< XChartDocument >& xChartDocument,
+ ExplicitValueProvider* pExplicitValueProvider,
bool bFlattenDiagram,
bool bOrderingForElementSelector ) :
m_pExplicitValueProvider( pExplicitValueProvider ),
@@ -189,15 +192,15 @@ ImplObjectHierarchy::ImplObjectHierarchy(
m_pExplicitValueProvider = 0;
}
-void ImplObjectHierarchy::createTree( const Reference< XChartDocument > & xChartDocument )
+void ImplObjectHierarchy::createTree( const Reference< XChartDocument >& xChartDocument )
{
- if( !xChartDocument.is())
+ if( !xChartDocument.is() )
return;
//@todo: change ObjectIdentifier to take an XChartDocument rather than XModel
Reference< frame::XModel > xModel( xChartDocument, uno::UNO_QUERY );
Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartDocument ) );
- OUString aDiaCID( ObjectIdentifier::createClassifiedIdentifierForObject( xDiagram, xModel ));
+ ObjectHierarchy::tOID aDiaOID( ObjectIdentifier( ObjectIdentifier::createClassifiedIdentifierForObject( xDiagram, xModel ) ) );
ObjectHierarchy::tChildContainer aTopLevelContainer;
// First Level
@@ -205,8 +208,8 @@ void ImplObjectHierarchy::createTree( const Reference< XChartDocument > & xChart
// Chart Area
if( m_bOrderingForElementSelector )
{
- aTopLevelContainer.push_back( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, OUString() ) );
- aTopLevelContainer.push_back( aDiaCID );
+ aTopLevelContainer.push_back( ObjectIdentifier( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, OUString() ) ) );
+ aTopLevelContainer.push_back( aDiaOID );
createWallAndFloor( aTopLevelContainer, xDiagram );
createLegendTree( aTopLevelContainer, xChartDocument, xDiagram );
}
@@ -218,7 +221,7 @@ void ImplObjectHierarchy::createTree( const Reference< XChartDocument > & xChart
Reference< XTitle > xMainTitle( xDocTitled->getTitleObject());
if( xMainTitle.is())
aTopLevelContainer.push_back(
- ObjectIdentifier::createClassifiedIdentifierForObject( xMainTitle, xModel ));
+ ObjectIdentifier( ObjectIdentifier::createClassifiedIdentifierForObject( xMainTitle, xModel ) ) );
}
if( xDiagram.is())
@@ -230,7 +233,7 @@ void ImplObjectHierarchy::createTree( const Reference< XChartDocument > & xChart
Reference< XTitle > xSubTitle( xDiaTitled->getTitleObject());
if( xSubTitle.is())
aTopLevelContainer.push_back(
- ObjectIdentifier::createClassifiedIdentifierForObject( xSubTitle, xModel ));
+ ObjectIdentifier( ObjectIdentifier::createClassifiedIdentifierForObject( xSubTitle, xModel ) ) );
}
if( !m_bOrderingForElementSelector )
@@ -241,7 +244,7 @@ void ImplObjectHierarchy::createTree( const Reference< XChartDocument > & xChart
lcl_addAxisTitle( aAxes[i], aTopLevelContainer, xModel );
// Diagram
- aTopLevelContainer.push_back( aDiaCID );
+ aTopLevelContainer.push_back( aDiaOID );
}
if( m_bFlattenDiagram )
@@ -250,21 +253,27 @@ void ImplObjectHierarchy::createTree( const Reference< XChartDocument > & xChart
{
ObjectHierarchy::tChildContainer aSubContainer;
createDiagramTree( aSubContainer, xChartDocument, xDiagram );
- if( ! aSubContainer.empty())
- m_aChildMap[ aDiaCID ] = aSubContainer;
+ if( !aSubContainer.empty() )
+ m_aChildMap[ aDiaOID ] = aSubContainer;
}
if( !m_bOrderingForElementSelector )
createLegendTree( aTopLevelContainer, xChartDocument, xDiagram );
}
+ // #i12587# support for shapes in chart
+ if ( !m_bOrderingForElementSelector )
+ {
+ createAdditionalShapesTree( aTopLevelContainer );
+ }
+
// Chart Area
if( !m_bOrderingForElementSelector )
aTopLevelContainer.push_back(
- ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, OUString() ) );
+ ObjectIdentifier( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, OUString() ) ) );
if( ! aTopLevelContainer.empty())
- m_aChildMap[ ObjectHierarchy::getRootNodeCID() ] = aTopLevelContainer;
+ m_aChildMap[ ObjectHierarchy::getRootNodeOID() ] = aTopLevelContainer;
}
void ImplObjectHierarchy::createLegendTree(
@@ -274,18 +283,18 @@ void ImplObjectHierarchy::createLegendTree(
{
if( xDiagram.is() && LegendHelper::hasLegend( xDiagram ) )
{
- OUString aLegendCID( ObjectIdentifier::createClassifiedIdentifierForObject( xDiagram->getLegend(), Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY ) ));
- rContainer.push_back( aLegendCID );
+ ObjectHierarchy::tOID aLegendOID( ObjectIdentifier( ObjectIdentifier::createClassifiedIdentifierForObject( xDiagram->getLegend(), Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY ) ) ) );
+ rContainer.push_back( aLegendOID );
// iterate over child shapes of legend and search for matching CIDs
if( m_pExplicitValueProvider )
{
Reference< container::XIndexAccess > xLegendShapeContainer(
- m_pExplicitValueProvider->getShapeForCID( aLegendCID ), uno::UNO_QUERY );
- ObjectHierarchy::tChildContainer aLegendEntryCIDs;
- lcl_getChildCIDs( aLegendEntryCIDs, xLegendShapeContainer );
+ m_pExplicitValueProvider->getShapeForCID( aLegendOID.getObjectCID() ), uno::UNO_QUERY );
+ ObjectHierarchy::tChildContainer aLegendEntryOIDs;
+ lcl_getChildOIDs( aLegendEntryOIDs, xLegendShapeContainer );
- m_aChildMap[ aLegendCID ] = aLegendEntryCIDs;
+ m_aChildMap[ aLegendOID ] = aLegendEntryOIDs;
}
}
}
@@ -305,7 +314,7 @@ void ImplObjectHierarchy::createAxesTree(
if( !m_bOrderingForElementSelector )
::std::transform( aAxes.getConstArray(), aAxes.getConstArray() + aAxes.getLength(),
::std::back_inserter( rContainer ),
- lcl_ObjectToCID( xChartDoc ));
+ lcl_ObjectToOID( xChartDoc ));
// get all axes, also invisible ones
aAxes = AxisHelper::getAllAxesOfDiagram( xDiagram, /* bOnlyVisible = */ false );
@@ -329,7 +338,7 @@ void ImplObjectHierarchy::createAxesTree(
// axis
if( AxisHelper::isAxisVisible( xAxis ) )
rContainer.push_back(
- ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, xChartModel ) );
+ ObjectIdentifier( ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, xChartModel ) ) );
// axis title
lcl_addAxisTitle( aAxes[nA], rContainer, xChartModel );
@@ -340,7 +349,7 @@ void ImplObjectHierarchy::createAxesTree(
{
//main grid
rContainer.push_back(
- ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel ) );
+ ObjectIdentifier( ObjectIdentifier( ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel ) ) ) );
}
Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() );;
@@ -352,7 +361,7 @@ void ImplObjectHierarchy::createAxesTree(
{
//sub grid
rContainer.push_back(
- ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel, nSubGrid ) );
+ ObjectIdentifier( ObjectIdentifier( ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel, nSubGrid ) ) ) );
}
}
}
@@ -369,12 +378,12 @@ void ImplObjectHierarchy::createWallAndFloor(
if( bHasWall && bIsThreeD )
{
rContainer.push_back(
- ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, rtl::OUString()));
+ ObjectIdentifier( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, rtl::OUString() ) ) );
Reference< beans::XPropertySet > xFloor( xDiagram->getFloor());
if( xFloor.is())
rContainer.push_back(
- ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_FLOOR, rtl::OUString()));
+ ObjectIdentifier( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_FLOOR, rtl::OUString() ) ) );
}
}
@@ -426,9 +435,9 @@ void ImplObjectHierarchy::createDataSeriesTree(
OUString aSeriesParticle(
ObjectIdentifier::createParticleForSeries(
nDiagramIndex, nCooSysIdx, nCTIdx, nSeriesIdx ));
- ObjectHierarchy::tCID aSeriesCID(
- ObjectIdentifier::createClassifiedIdentifierForParticle( aSeriesParticle ));
- rOutDiagramSubContainer.push_back( aSeriesCID );
+ ObjectHierarchy::tOID aSeriesOID(
+ ObjectIdentifier( ObjectIdentifier::createClassifiedIdentifierForParticle( aSeriesParticle ) ) );
+ rOutDiagramSubContainer.push_back( aSeriesOID );
ObjectHierarchy::tChildContainer aSeriesSubContainer;
@@ -440,7 +449,7 @@ void ImplObjectHierarchy::createDataSeriesTree(
rtl::OUString aChildParticle( ObjectIdentifier::getStringForType( OBJECTTYPE_DATA_LABELS ) );
aChildParticle+=(C2U("="));
aSeriesSubContainer.push_back(
- ObjectIdentifier::createClassifiedIdentifierForParticles( aSeriesParticle, aChildParticle ));
+ ObjectIdentifier( ObjectIdentifier::createClassifiedIdentifierForParticles( aSeriesParticle, aChildParticle ) ) );
}
// Statistics
@@ -454,11 +463,11 @@ void ImplObjectHierarchy::createDataSeriesTree(
{
bool bIsAverageLine = RegressionCurveHelper::isMeanValueLine( aCurves[nCurveIdx] );
aSeriesSubContainer.push_back(
- ObjectIdentifier::createDataCurveCID( aSeriesParticle, nCurveIdx, bIsAverageLine ));
+ ObjectIdentifier( ObjectIdentifier::createDataCurveCID( aSeriesParticle, nCurveIdx, bIsAverageLine ) ) );
if( RegressionCurveHelper::hasEquation( aCurves[nCurveIdx] ) )
{
aSeriesSubContainer.push_back(
- ObjectIdentifier::createDataCurveEquationCID( aSeriesParticle, nCurveIdx ));
+ ObjectIdentifier( ObjectIdentifier::createDataCurveEquationCID( aSeriesParticle, nCurveIdx ) ) );
}
}
Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY );
@@ -472,8 +481,8 @@ void ImplObjectHierarchy::createDataSeriesTree(
( nStyle != ::com::sun::star::chart::ErrorBarStyle::NONE ) )
{
aSeriesSubContainer.push_back(
- ObjectIdentifier::createClassifiedIdentifierWithParent(
- OBJECTTYPE_DATA_ERRORS, OUString(), aSeriesParticle ));
+ ObjectIdentifier( ObjectIdentifier::createClassifiedIdentifierWithParent(
+ OBJECTTYPE_DATA_ERRORS, OUString(), aSeriesParticle ) ) );
}
}
}
@@ -484,12 +493,12 @@ void ImplObjectHierarchy::createDataSeriesTree(
if( m_pExplicitValueProvider )
{
Reference< container::XIndexAccess > xSeriesShapeContainer(
- m_pExplicitValueProvider->getShapeForCID( aSeriesCID ), uno::UNO_QUERY );
- lcl_getChildCIDs( aSeriesSubContainer, xSeriesShapeContainer );
+ m_pExplicitValueProvider->getShapeForCID( aSeriesOID.getObjectCID() ), uno::UNO_QUERY );
+ lcl_getChildOIDs( aSeriesSubContainer, xSeriesShapeContainer );
}
if( ! aSeriesSubContainer.empty())
- m_aChildMap[ aSeriesCID ] = aSeriesSubContainer;
+ m_aChildMap[ aSeriesOID ] = aSeriesSubContainer;
}
}
}
@@ -500,9 +509,38 @@ void ImplObjectHierarchy::createDataSeriesTree(
}
}
-bool ImplObjectHierarchy::hasChildren( const OUString & rParent )
+void ImplObjectHierarchy::createAdditionalShapesTree( ObjectHierarchy::tChildContainer& rContainer )
{
- if( rParent.getLength())
+ try
+ {
+ if ( m_pExplicitValueProvider )
+ {
+ Reference< drawing::XDrawPage > xDrawPage( m_pExplicitValueProvider->getDrawModelWrapper()->getMainDrawPage() );
+ Reference< drawing::XShapes > xDrawPageShapes( xDrawPage, uno::UNO_QUERY_THROW );
+ Reference< drawing::XShapes > xChartRoot( DrawModelWrapper::getChartRootShape( xDrawPage ) );
+ sal_Int32 nCount = xDrawPageShapes->getCount();
+ for ( sal_Int32 i = 0; i < nCount; ++i )
+ {
+ Reference< drawing::XShape > xShape;
+ if ( xDrawPageShapes->getByIndex( i ) >>= xShape )
+ {
+ if ( xShape.is() && xShape != xChartRoot )
+ {
+ rContainer.push_back( ObjectIdentifier( xShape ) );
+ }
+ }
+ }
+ }
+ }
+ catch ( uno::Exception& ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+}
+
+bool ImplObjectHierarchy::hasChildren( const ObjectHierarchy::tOID& rParent )
+{
+ if ( rParent.isValid() )
{
tChildMap::const_iterator aIt( m_aChildMap.find( rParent ));
if( aIt != m_aChildMap.end())
@@ -511,9 +549,9 @@ bool ImplObjectHierarchy::hasChildren( const OUString & rParent )
return false;
}
-ObjectHierarchy::tChildContainer ImplObjectHierarchy::getChildren( const OUString & rParent )
+ObjectHierarchy::tChildContainer ImplObjectHierarchy::getChildren( const ObjectHierarchy::tOID& rParent )
{
- if( rParent.getLength())
+ if ( rParent.isValid() )
{
tChildMap::const_iterator aIt( m_aChildMap.find( rParent ));
if( aIt != m_aChildMap.end())
@@ -522,9 +560,9 @@ ObjectHierarchy::tChildContainer ImplObjectHierarchy::getChildren( const OUStrin
return ObjectHierarchy::tChildContainer();
}
-ObjectHierarchy::tChildContainer ImplObjectHierarchy::getSiblings( const OUString & rNode )
+ObjectHierarchy::tChildContainer ImplObjectHierarchy::getSiblings( const ObjectHierarchy::tOID& rNode )
{
- if( rNode.getLength() && !ObjectHierarchy::isRootNode( rNode ))
+ if ( rNode.isValid() && !ObjectHierarchy::isRootNode( rNode ) )
{
for( tChildMap::const_iterator aIt( m_aChildMap.begin());
aIt != m_aChildMap.end(); ++aIt )
@@ -538,23 +576,23 @@ ObjectHierarchy::tChildContainer ImplObjectHierarchy::getSiblings( const OUStrin
return ObjectHierarchy::tChildContainer();
}
-ObjectHierarchy::tCID ImplObjectHierarchy::getParentImpl(
- const ObjectHierarchy::tCID & rParentCID,
- const ObjectHierarchy::tCID & rCID )
+ObjectHierarchy::tOID ImplObjectHierarchy::getParentImpl(
+ const ObjectHierarchy::tOID & rParentOID,
+ const ObjectHierarchy::tOID & rOID )
{
// search children
- ObjectHierarchy::tChildContainer aChildren( getChildren( rParentCID ));
+ ObjectHierarchy::tChildContainer aChildren( getChildren( rParentOID ));
ObjectHierarchy::tChildContainer::const_iterator aIt(
- ::std::find( aChildren.begin(), aChildren.end(), rCID ));
+ ::std::find( aChildren.begin(), aChildren.end(), rOID ));
// recursion end
if( aIt != aChildren.end())
- return rParentCID;
+ return rParentOID;
for( aIt = aChildren.begin(); aIt != aChildren.end(); ++aIt )
{
// recursion
- ObjectHierarchy::tCID aTempParent( getParentImpl( *aIt, rCID ));
- if( aTempParent.getLength())
+ ObjectHierarchy::tOID aTempParent( getParentImpl( *aIt, rOID ));
+ if ( aTempParent.isValid() )
{
// exit on success
return aTempParent;
@@ -562,17 +600,18 @@ ObjectHierarchy::tCID ImplObjectHierarchy::getParentImpl(
}
// exit on fail
- return ObjectHierarchy::tCID();
+ return ObjectHierarchy::tOID();
}
-ObjectHierarchy::tCID ImplObjectHierarchy::getParent(
- const ObjectHierarchy::tCID & rCID )
+ObjectHierarchy::tOID ImplObjectHierarchy::getParent(
+ const ObjectHierarchy::tOID & rOID )
{
- return getParentImpl( ObjectHierarchy::getRootNodeCID(), rCID );
+ return getParentImpl( ObjectHierarchy::getRootNodeOID(), rOID );
}
} // namespace impl
+
ObjectHierarchy::ObjectHierarchy(
const Reference< XChartDocument > & xChartDocument,
ExplicitValueProvider * pExplicitValueProvider /* = 0 */,
@@ -585,60 +624,60 @@ ObjectHierarchy::~ObjectHierarchy()
{}
// static
-ObjectHierarchy::tCID ObjectHierarchy::getRootNodeCID()
+ObjectHierarchy::tOID ObjectHierarchy::getRootNodeOID()
{
- return C2U("ROOT");
+ return ObjectIdentifier( C2U( "ROOT" ) );
}
// static
-bool ObjectHierarchy::isRootNode( const ObjectHierarchy::tCID & rCID )
+bool ObjectHierarchy::isRootNode( const ObjectHierarchy::tOID& rOID )
{
- return rCID.equals( ObjectHierarchy::getRootNodeCID());
+ return ( rOID == ObjectHierarchy::getRootNodeOID() );
}
ObjectHierarchy::tChildContainer ObjectHierarchy::getTopLevelChildren() const
{
- return m_apImpl->getChildren( ObjectHierarchy::getRootNodeCID());
+ return m_apImpl->getChildren( ObjectHierarchy::getRootNodeOID());
}
-bool ObjectHierarchy::hasChildren( const tCID & rParent ) const
+bool ObjectHierarchy::hasChildren( const tOID& rParent ) const
{
return m_apImpl->hasChildren( rParent );
}
ObjectHierarchy::tChildContainer ObjectHierarchy::getChildren(
- const ObjectHierarchy::tCID & rParent ) const
+ const ObjectHierarchy::tOID& rParent ) const
{
- if( rParent.getLength())
+ if ( rParent.isValid() )
return m_apImpl->getChildren( rParent );
return ObjectHierarchy::tChildContainer();
}
ObjectHierarchy::tChildContainer ObjectHierarchy::getSiblings(
- const ObjectHierarchy::tCID & rNode ) const
+ const ObjectHierarchy::tOID& rNode ) const
{
- if( rNode.getLength() && !isRootNode( rNode ))
+ if ( rNode.isValid() && !isRootNode( rNode ) )
return m_apImpl->getSiblings( rNode );
return ObjectHierarchy::tChildContainer();
}
-ObjectHierarchy::tCID ObjectHierarchy::getParent(
- const ObjectHierarchy::tCID & rNode ) const
+ObjectHierarchy::tOID ObjectHierarchy::getParent(
+ const ObjectHierarchy::tOID& rNode ) const
{
return m_apImpl->getParent( rNode );
}
sal_Int32 ObjectHierarchy::getIndexInParent(
- const ObjectHierarchy::tCID & rNode ) const
+ const ObjectHierarchy::tOID& rNode ) const
{
- tCID aParentCID( m_apImpl->getParent( rNode ));
- tChildContainer aChildren( m_apImpl->getChildren( aParentCID ));
- tChildContainer::const_iterator aIt( aChildren.begin());
+ tOID aParentOID( m_apImpl->getParent( rNode ));
+ tChildContainer aChildren( m_apImpl->getChildren( aParentOID ) );
+ tChildContainer::const_iterator aIt( aChildren.begin() );
for( sal_Int32 nIndex = 0; aIt != aChildren.end(); ++nIndex, ++aIt )
{
- if( aIt->equals( rNode ))
+ if ( *aIt == rNode )
return nIndex;
}
return -1;
@@ -647,16 +686,18 @@ sal_Int32 ObjectHierarchy::getIndexInParent(
// ================================================================================
ObjectKeyNavigation::ObjectKeyNavigation(
- const ObjectHierarchy::tCID & rCurrentCID,
+ const ObjectHierarchy::tOID & rCurrentOID,
const Reference< chart2::XChartDocument > & xChartDocument,
ExplicitValueProvider * pExplicitValueProvider /* = 0 */ ) :
- m_aCurrentCID( rCurrentCID ),
+ m_aCurrentOID( rCurrentOID ),
m_xChartDocument( xChartDocument ),
m_pExplicitValueProvider( pExplicitValueProvider ),
m_bStepDownInDiagram( true )
{
- if( m_aCurrentCID.getLength() == 0 )
- setCurrentSelection( ObjectHierarchy::getRootNodeCID());
+ if ( !m_aCurrentOID.isValid() )
+ {
+ setCurrentSelection( ObjectHierarchy::getRootNodeOID() );
+ }
}
bool ObjectKeyNavigation::handleKeyEvent(
@@ -685,7 +726,7 @@ bool ObjectKeyNavigation::handleKeyEvent(
bResult = down();
break;
case awt::Key::ESCAPE:
- setCurrentSelection( OUString());
+ setCurrentSelection( ObjectIdentifier() );
bResult = true;
break;
default:
@@ -695,20 +736,20 @@ bool ObjectKeyNavigation::handleKeyEvent(
return bResult;
}
-void ObjectKeyNavigation::setCurrentSelection( const ObjectHierarchy::tCID & rCID )
+void ObjectKeyNavigation::setCurrentSelection( const ObjectHierarchy::tOID& rOID )
{
- m_aCurrentCID = rCID;
+ m_aCurrentOID = rOID;
}
-ObjectHierarchy::tCID ObjectKeyNavigation::getCurrentSelection() const
+ObjectHierarchy::tOID ObjectKeyNavigation::getCurrentSelection() const
{
- return m_aCurrentCID;
+ return m_aCurrentOID;
}
bool ObjectKeyNavigation::first()
{
ObjectHierarchy aHierarchy( m_xChartDocument, m_pExplicitValueProvider, m_bStepDownInDiagram );
- ObjectHierarchy::tChildContainer aSiblings( aHierarchy.getSiblings( getCurrentSelection()));
+ ObjectHierarchy::tChildContainer aSiblings( aHierarchy.getSiblings( getCurrentSelection() ) );
bool bResult = !aSiblings.empty();
if( bResult )
setCurrentSelection( aSiblings.front());
@@ -720,7 +761,7 @@ bool ObjectKeyNavigation::first()
bool ObjectKeyNavigation::last()
{
ObjectHierarchy aHierarchy( m_xChartDocument, m_pExplicitValueProvider, m_bStepDownInDiagram );
- ObjectHierarchy::tChildContainer aSiblings( aHierarchy.getSiblings( getCurrentSelection()));
+ ObjectHierarchy::tChildContainer aSiblings( aHierarchy.getSiblings( getCurrentSelection() ) );
bool bResult = !aSiblings.empty();
if( bResult )
setCurrentSelection( aSiblings.back());
@@ -732,7 +773,7 @@ bool ObjectKeyNavigation::last()
bool ObjectKeyNavigation::next()
{
ObjectHierarchy aHierarchy( m_xChartDocument, m_pExplicitValueProvider, m_bStepDownInDiagram );
- ObjectHierarchy::tChildContainer aSiblings( aHierarchy.getSiblings( getCurrentSelection()));
+ ObjectHierarchy::tChildContainer aSiblings( aHierarchy.getSiblings( getCurrentSelection() ) );
bool bResult = !aSiblings.empty();
if( bResult )
{
diff --git a/chart2/source/controller/main/SelectionHelper.cxx b/chart2/source/controller/main/SelectionHelper.cxx
index 0d0dddef169d..567a36473a5b 100644
--- a/chart2/source/controller/main/SelectionHelper.cxx
+++ b/chart2/source/controller/main/SelectionHelper.cxx
@@ -80,25 +80,29 @@ void impl_selectObject( SdrObject* pObjectToSelect, DrawViewWrapper& rDrawViewWr
bool Selection::hasSelection()
{
- return m_aSelectedObjectCID.getLength() || m_xSelectAdditionalShape.is();
+ return m_aSelectedOID.isValid();
}
rtl::OUString Selection::getSelectedCID()
{
- return m_aSelectedObjectCID;
+ return m_aSelectedOID.getObjectCID();
}
uno::Reference< drawing::XShape > Selection::getSelectedAdditionalShape()
{
- return m_xSelectAdditionalShape;
+ return m_aSelectedOID.getAdditionalShape();
+}
+
+ObjectIdentifier Selection::getSelectedOID() const
+{
+ return m_aSelectedOID;
}
bool Selection::setSelection( const ::rtl::OUString& rCID )
{
- if( !rCID.equals( m_aSelectedObjectCID ) )
+ if ( !rCID.equals( m_aSelectedOID.getObjectCID() ) )
{
- m_aSelectedObjectCID = rCID;
- m_xSelectAdditionalShape.set(0);
+ m_aSelectedOID = ObjectIdentifier( rCID );
return true;
}
return false;
@@ -106,10 +110,10 @@ bool Selection::setSelection( const ::rtl::OUString& rCID )
bool Selection::setSelection( const uno::Reference< drawing::XShape >& xShape )
{
- if( !(m_xSelectAdditionalShape==xShape) )
+ if ( !( xShape == m_aSelectedOID.getAdditionalShape() ) )
{
clearSelection();
- m_xSelectAdditionalShape = xShape;
+ m_aSelectedOID = ObjectIdentifier( xShape );
return true;
}
return false;
@@ -117,18 +121,18 @@ bool Selection::setSelection( const uno::Reference< drawing::XShape >& xShape )
void Selection::clearSelection()
{
- m_aSelectedObjectCID = m_aSelectedObjectCID_beforeMouseDown
- = m_aSelectedObjectCID_selectOnlyIfNoDoubleClickIsFollowing = rtl::OUString();
- m_xSelectAdditionalShape.set(0);
+ m_aSelectedOID = ObjectIdentifier();
+ m_aSelectedOID_beforeMouseDown = ObjectIdentifier();
+ m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing = ObjectIdentifier();
}
bool Selection::maybeSwitchSelectionAfterSingleClickWasEnsured()
{
- if( m_aSelectedObjectCID_selectOnlyIfNoDoubleClickIsFollowing.getLength()
- && !m_aSelectedObjectCID_selectOnlyIfNoDoubleClickIsFollowing.equals(m_aSelectedObjectCID) )
+ if ( m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing.isValid()
+ && m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing != m_aSelectedOID )
{
- m_aSelectedObjectCID = m_aSelectedObjectCID_selectOnlyIfNoDoubleClickIsFollowing;
- m_aSelectedObjectCID_selectOnlyIfNoDoubleClickIsFollowing = C2U("");
+ m_aSelectedOID = m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing;
+ m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing = ObjectIdentifier();
return true;
}
return false;
@@ -136,18 +140,20 @@ bool Selection::maybeSwitchSelectionAfterSingleClickWasEnsured()
void Selection::resetPossibleSelectionAfterSingleClickWasEnsured()
{
- if( m_aSelectedObjectCID_selectOnlyIfNoDoubleClickIsFollowing.getLength() )
- m_aSelectedObjectCID_selectOnlyIfNoDoubleClickIsFollowing = C2U("");
+ if ( m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing.isValid() )
+ {
+ m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing = ObjectIdentifier();
+ }
}
void Selection::remindSelectionBeforeMouseDown()
{
- m_aSelectedObjectCID_beforeMouseDown = m_aSelectedObjectCID;
+ m_aSelectedOID_beforeMouseDown = m_aSelectedOID;
}
bool Selection::isSelectionDifferentFromBeforeMouseDown()
{
- return !ObjectIdentifier::areIdenticalObjects( m_aSelectedObjectCID, m_aSelectedObjectCID_beforeMouseDown );
+ return ( m_aSelectedOID != m_aSelectedOID_beforeMouseDown );
}
void Selection::applySelection( DrawViewWrapper* pDrawViewWrapper )
@@ -159,10 +165,14 @@ void Selection::applySelection( DrawViewWrapper* pDrawViewWrapper )
pDrawViewWrapper->UnmarkAll();
}
SdrObject* pObjectToSelect = 0;
- if( m_aSelectedObjectCID.getLength() )
- pObjectToSelect = pDrawViewWrapper->getNamedSdrObject( m_aSelectedObjectCID );
- else if( m_xSelectAdditionalShape.is() )
- pObjectToSelect = DrawViewWrapper::getSdrObject( m_xSelectAdditionalShape );
+ if ( m_aSelectedOID.isAutoGeneratedObject() )
+ {
+ pObjectToSelect = pDrawViewWrapper->getNamedSdrObject( m_aSelectedOID.getObjectCID() );
+ }
+ else if( m_aSelectedOID.isAdditionalShape() )
+ {
+ pObjectToSelect = DrawViewWrapper::getSdrObject( m_aSelectedOID.getAdditionalShape() );
+ }
impl_selectObject( pObjectToSelect, *pDrawViewWrapper );
}
@@ -176,7 +186,7 @@ void Selection::adaptSelectionToNewPos( const Point& rMousePos, DrawViewWrapper*
//do not toggel multiclick selection if right clicked on the selected object or waiting for double click
bool bAllowMultiClickSelectionChange = !bIsRightMouse && !bWaitingForDoubleClick;
- const rtl::OUString aNameOfLastSelectedObject( m_aSelectedObjectCID );
+ ObjectIdentifier aLastSelectedObject( m_aSelectedOID );
::vos::OGuard aSolarGuard( Application::GetSolarMutex());
@@ -185,86 +195,89 @@ void Selection::adaptSelectionToNewPos( const Point& rMousePos, DrawViewWrapper*
//get object to select:
SdrObject* pNewObj = 0;
{
- m_aSelectedObjectCID_selectOnlyIfNoDoubleClickIsFollowing = C2U("");
- m_xSelectAdditionalShape.set(0);
+ m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing = ObjectIdentifier();
//the search for the object to select starts with the hit object deepest in the grouping hierarchy (a leaf in the tree)
//further we travel along the grouping hierarchy from child to parent
pNewObj = pDrawViewWrapper->getHitObject(rMousePos);
- m_aSelectedObjectCID = lcl_getObjectName( pNewObj );//name of pNewObj
- rtl::OUString aTestFirstHit = m_aSelectedObjectCID;
+ m_aSelectedOID = ObjectIdentifier( lcl_getObjectName( pNewObj ) );//name of pNewObj
//ignore handle only objects for hit test
- while( pNewObj && m_aSelectedObjectCID.match(C2U("HandlesOnly")) )
+ while( pNewObj && m_aSelectedOID.getObjectCID().match( C2U( "HandlesOnly" ) ) )
{
pNewObj->SetMarkProtect(true);
pNewObj = pDrawViewWrapper->getHitObject(rMousePos);
- m_aSelectedObjectCID = lcl_getObjectName( pNewObj );
+ m_aSelectedOID = ObjectIdentifier( lcl_getObjectName( pNewObj ) );
}
//accept only named objects while searching for the object to select
- //this call may change m_aSelectedObjectCID
- if( SelectionHelper::findNamedParent( pNewObj, m_aSelectedObjectCID, true ) )
+ //this call may change m_aSelectedOID
+ if ( SelectionHelper::findNamedParent( pNewObj, m_aSelectedOID, true ) )
{
//if the so far found object is a multi click object further steps are necessary
- while( ObjectIdentifier::isMultiClickObject( m_aSelectedObjectCID ) )
+ while( ObjectIdentifier::isMultiClickObject( m_aSelectedOID.getObjectCID() ) )
{
- bool bSameObjectAsLastSelected = ObjectIdentifier::areIdenticalObjects( aNameOfLastSelectedObject, m_aSelectedObjectCID );
+ bool bSameObjectAsLastSelected = ( aLastSelectedObject == m_aSelectedOID );
if( bSameObjectAsLastSelected )
{
//if the same child is clicked again don't go up further
break;
}
- if( ObjectIdentifier::areSiblings(aNameOfLastSelectedObject,m_aSelectedObjectCID) )
+ if ( ObjectIdentifier::areSiblings( aLastSelectedObject.getObjectCID(), m_aSelectedOID.getObjectCID() ) )
{
//if a sibling of the last selected object is clicked don't go up further
break;
}
SdrObject* pLastChild = pNewObj;
- rtl::OUString aLastChildName = m_aSelectedObjectCID;
- if(!SelectionHelper::findNamedParent( pNewObj, m_aSelectedObjectCID, false ))
+ ObjectIdentifier aLastChild = m_aSelectedOID;
+ if ( !SelectionHelper::findNamedParent( pNewObj, m_aSelectedOID, false ) )
{
//take the one found so far
break;
}
//if the last selected object is found don't go up further
//but take the last child if selection change is allowed
- if( ObjectIdentifier::areIdenticalObjects( aNameOfLastSelectedObject, m_aSelectedObjectCID ) )
+ if ( aLastSelectedObject == m_aSelectedOID )
{
if( bAllowMultiClickSelectionChange )
{
pNewObj = pLastChild;
- m_aSelectedObjectCID = aLastChildName;
+ m_aSelectedOID = aLastChild;
}
else
- m_aSelectedObjectCID_selectOnlyIfNoDoubleClickIsFollowing = aLastChildName;
+ m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing = aLastChild;
break;
}
}
- DBG_ASSERT(pNewObj && m_aSelectedObjectCID.getLength(),"somehow lost selected object");
+ DBG_ASSERT( pNewObj && m_aSelectedOID.isValid(), "somehow lost selected object" );
}
else
{
//maybe an additional shape was hit
- m_aSelectedObjectCID = rtl::OUString();
- if( pNewObj )
+ if ( pNewObj )
+ {
+ m_aSelectedOID = ObjectIdentifier( uno::Reference< drawing::XShape >( pNewObj->getUnoShape(), uno::UNO_QUERY ) );
+ }
+ else
{
- m_xSelectAdditionalShape = uno::Reference< drawing::XShape >( pNewObj->getUnoShape(), uno::UNO_QUERY);
+ m_aSelectedOID = ObjectIdentifier();
}
}
- if(!m_xSelectAdditionalShape.is())
+ if ( !m_aSelectedOID.isAdditionalShape() )
{
rtl::OUString aPageCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, rtl::OUString() ) );//@todo read CID from model
- if( !m_aSelectedObjectCID.getLength() )
- m_aSelectedObjectCID = aPageCID;
+ if ( !m_aSelectedOID.isAutoGeneratedObject() )
+ {
+ m_aSelectedOID = ObjectIdentifier( aPageCID );
+ }
//check wether the diagram was hit but not selected (e.g. because it has no filling):
rtl::OUString aWallCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, rtl::OUString() ) );//@todo read CID from model
- if( m_aSelectedObjectCID.equals( aPageCID ) || m_aSelectedObjectCID.equals( aWallCID ) || !m_aSelectedObjectCID.getLength() )
+ if ( m_aSelectedOID.getObjectCID().equals( aPageCID ) || m_aSelectedOID.getObjectCID().equals( aWallCID ) || !m_aSelectedOID.isAutoGeneratedObject() )
{
rtl::OUString aDiagramCID = ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM, rtl::OUString::valueOf( sal_Int32(0) ) );
//todo: if more than one diagram is available in future do chack the list of all diagrams here
@@ -273,7 +286,7 @@ void Selection::adaptSelectionToNewPos( const Point& rMousePos, DrawViewWrapper*
{
if( pDrawViewWrapper->IsObjectHit( pDiagram, rMousePos ) )
{
- m_aSelectedObjectCID = aDiagramCID;
+ m_aSelectedOID = ObjectIdentifier( aDiagramCID );
pNewObj = pDiagram;
}
}
@@ -281,18 +294,21 @@ void Selection::adaptSelectionToNewPos( const Point& rMousePos, DrawViewWrapper*
}
}
- if( bIsRightMouse && m_aSelectedObjectCID_selectOnlyIfNoDoubleClickIsFollowing.getLength() )
- m_aSelectedObjectCID_selectOnlyIfNoDoubleClickIsFollowing = C2U("");
+ if ( bIsRightMouse && m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing.isValid() )
+ {
+ m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing = ObjectIdentifier();
+ }
}
}
bool Selection::isResizeableObjectSelected()
{
- ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelectedObjectCID );
+ ObjectType eObjectType = m_aSelectedOID.getObjectType();
switch( eObjectType )
{
case OBJECTTYPE_DIAGRAM:
case OBJECTTYPE_DIAGRAM_WALL:
+ case OBJECTTYPE_SHAPE:
return true;
default:
return false;
@@ -302,14 +318,17 @@ bool Selection::isResizeableObjectSelected()
bool Selection::isRotateableObjectSelected( const uno::Reference< frame::XModel >& xChartModel )
{
- return SelectionHelper::isRotateableObject( m_aSelectedObjectCID, xChartModel );
+ return SelectionHelper::isRotateableObject( m_aSelectedOID.getObjectCID(), xChartModel );
}
bool Selection::isDragableObjectSelected()
{
- if( m_aSelectedObjectCID.getLength() )
- return ObjectIdentifier::isDragableObject( m_aSelectedObjectCID );
- return m_xSelectAdditionalShape.is();
+ return m_aSelectedOID.isDragableObject();
+}
+
+bool Selection::isAdditionalShapeSelected() const
+{
+ return m_aSelectedOID.isAdditionalShape();
}
//-----------------------------------------------------------------------------
@@ -351,6 +370,20 @@ bool SelectionHelper::findNamedParent( SdrObject*& pInOutObject
}
//static
+bool SelectionHelper::findNamedParent( SdrObject*& pInOutObject
+ , ObjectIdentifier& rOutObject
+ , bool bGivenObjectMayBeResult )
+{
+ rtl::OUString aName;
+ if ( findNamedParent( pInOutObject, aName, bGivenObjectMayBeResult ) )
+ {
+ rOutObject = ObjectIdentifier( aName );
+ return true;
+ }
+ return false;
+}
+
+//static
bool SelectionHelper::isDragableObjectHitTwice( const Point& rMPos
, const rtl::OUString& rNameOfSelectedObject
, const DrawViewWrapper& rDrawViewWrapper )
@@ -366,107 +399,6 @@ bool SelectionHelper::isDragableObjectHitTwice( const Point& rMPos
return true;
}
-/*
-rtl::OUString lcl_getObjectCIDToSelect( const Point& rMPos
- , const rtl::OUString& rNameOfLastSelectedObject
- , DrawViewWrapper& rDrawViewWrapper
- , bool bAllowMultiClickSelectionChange
- , rtl::OUString& rObjectToSelectIfNoDoubleClickIsFollowing //out parameter only
- )
-{
- rtl::OUString aRet;
-
- ::vos::OGuard aSolarGuard( Application::GetSolarMutex());
-
- //bAllowMultiClickSelectionChange==true -> a second click on the same object can lead to a changed selection (e.g. series -> single data point)
-
- //get object to select:
- SdrObject* pNewObj = 0;
- {
- rObjectToSelectIfNoDoubleClickIsFollowing = C2U("");
-
- //the search for the object to select starts with the hit object deepest in the grouping hierarchy (a leaf in the tree)
- //further we travel along the grouping hierarchy from child to parent
- pNewObj = rDrawViewWrapper.getHitObject(rMPos);
- aRet = lcl_getObjectName( pNewObj );//name of pNewObj
- rtl::OUString aTestFirstHit = aRet;
-
- //ignore handle only objects for hit test
- while( pNewObj && aRet.match(C2U("HandlesOnly")) )
- {
- pNewObj->SetMarkProtect(true);
- pNewObj = rDrawViewWrapper.getHitObject(rMPos);
- aRet = lcl_getObjectName( pNewObj );
- }
-
- //accept only named objects while searching for the object to select
- //this call may change aRet
- if( !findNamedParent( pNewObj, aRet, true ) )
- {
- return C2U("");
- }
- //if the so far found object is a multi click object further steps are necessary
- while( ObjectIdentifier::isMultiClickObject( aRet ) )
- {
- bool bSameObjectAsLastSelected = ObjectIdentifier::areIdenticalObjects( rNameOfLastSelectedObject, aRet );
- if( bSameObjectAsLastSelected )
- {
- //if the same child is clicked again don't go up further
- break;
- }
- if( ObjectIdentifier::areSiblings(rNameOfLastSelectedObject,aRet) )
- {
- //if a sibling of the last selected object is clicked don't go up further
- break;
- }
- SdrObject* pLastChild = pNewObj;
- rtl::OUString aLastChildName = aRet;
- if(!findNamedParent( pNewObj, aRet, false ))
- {
- //take the one found so far
- break;
- }
- //if the last selected object is found don't go up further
- //but take the last child if selection change is allowed
- if( ObjectIdentifier::areIdenticalObjects( rNameOfLastSelectedObject, aRet ) )
- {
- if( bAllowMultiClickSelectionChange )
- {
- pNewObj = pLastChild;
- aRet = aLastChildName;
- }
- else
- rObjectToSelectIfNoDoubleClickIsFollowing = aLastChildName;
-
- break;
- }
- }
-
- //check wether the diagram was hit but not selected:
- rtl::OUString aPageCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, rtl::OUString() ) );//@todo read CID from model
- rtl::OUString aWallCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, rtl::OUString() ) );//@todo read CID from model
- if( aRet.equals( aPageCID ) || aRet.equals( aWallCID ) || !aRet.getLength() )
- {
- rtl::OUString aDiagramCID = ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM, rtl::OUString::valueOf( sal_Int32(0) ) );
- //todo: if more than one diagram is available in future do chack the list of all diagrams here
- SdrObject* pDiagram = rDrawViewWrapper.getNamedSdrObject( aDiagramCID );
- if( pDiagram )
- {
- if( rDrawViewWrapper.IsObjectHit( pDiagram, rMPos ) )
- {
- aRet = aDiagramCID;
- pNewObj = pDiagram;
- }
- }
- }
-
- DBG_ASSERT(pNewObj && aRet.getLength(),"somehow lost selected object");
- }
-
- return aRet;
-}
-*/
-
// static
::rtl::OUString SelectionHelper::getHitObjectCID(
const Point& rMPos,
diff --git a/chart2/source/controller/main/SelectionHelper.hxx b/chart2/source/controller/main/SelectionHelper.hxx
index 12b3ef9948ac..b3516e2326a4 100644
--- a/chart2/source/controller/main/SelectionHelper.hxx
+++ b/chart2/source/controller/main/SelectionHelper.hxx
@@ -28,6 +28,7 @@
#define _CHART2_SELECTIONHELPER_HXX
#include "DrawViewWrapper.hxx"
+#include "ObjectIdentifier.hxx"
class SdrObject;
// header for enum SdrDragMode
@@ -39,6 +40,8 @@ namespace chart
{
//.............................................................................
+class ObjectIdentifier;
+
//-----------------------------------------------------------------------------
/**
*/
@@ -50,12 +53,15 @@ public: //methods
rtl::OUString getSelectedCID();
::com::sun::star::uno::Reference<
::com::sun::star::drawing::XShape > getSelectedAdditionalShape();
+ ObjectIdentifier getSelectedOID() const;
bool isResizeableObjectSelected();
bool isRotateableObjectSelected( const ::com::sun::star::uno::Reference<
::com::sun::star::frame::XModel >& xChartModel );
bool isDragableObjectSelected();
+ bool isAdditionalShapeSelected() const;
+
//returns true if selection has changed
bool setSelection( const ::rtl::OUString& rCID );
bool setSelection( const ::com::sun::star::uno::Reference<
@@ -81,12 +87,9 @@ private: //member
//the content of m_xSelectedShape is ignored in that case
//the strings are used for autogenerated chart specific objects
//the shape reference is used for additional shapes
- ::rtl::OUString m_aSelectedObjectCID;//only single object selection so far
- ::rtl::OUString m_aSelectedObjectCID_beforeMouseDown;
- ::rtl::OUString m_aSelectedObjectCID_selectOnlyIfNoDoubleClickIsFollowing;
-
- ::com::sun::star::uno::Reference<
- ::com::sun::star::drawing::XShape > m_xSelectAdditionalShape;
+ ObjectIdentifier m_aSelectedOID; //only single object selection so far
+ ObjectIdentifier m_aSelectedOID_beforeMouseDown;
+ ObjectIdentifier m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing;
};
class SelectionHelper : public MarkHandleProvider
@@ -95,6 +98,9 @@ public:
static bool findNamedParent( SdrObject*& pInOutObject
, rtl::OUString& rOutName
, bool bGivenObjectMayBeResult );
+ static bool findNamedParent( SdrObject*& pInOutObject
+ , ObjectIdentifier& rOutObject
+ , bool bGivenObjectMayBeResult );
static SdrObject* getMarkHandlesObject( SdrObject* pObj );
static E3dScene* getSceneToRotate( SdrObject* pObj );
static bool isDragableObjectHitTwice( const Point& rMPos
diff --git a/chart2/source/controller/main/ShapeController.cxx b/chart2/source/controller/main/ShapeController.cxx
new file mode 100644
index 000000000000..b6adf9bf7477
--- /dev/null
+++ b/chart2/source/controller/main/ShapeController.cxx
@@ -0,0 +1,738 @@
+/*************************************************************************
+ *
+ * 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 "ShapeController.hxx"
+#include "ShapeController.hrc"
+#include "ChartController.hxx"
+#include "ChartWindow.hxx"
+#include "ViewElementListProvider.hxx"
+#include "dlg_ShapeFont.hxx"
+#include "dlg_ShapeParagraph.hxx"
+#include "chartview/DrawModelWrapper.hxx"
+#include "macros.hxx"
+
+#include <com/sun/star/frame/XStorable.hpp>
+
+#include <vos/mutex.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+#include <editeng/brkitem.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/drawitem.hxx>
+#include <editeng/eeitem.hxx>
+#include <editeng/hyznitem.hxx>
+#include <editeng/orphitem.hxx>
+#include <editeng/spltitem.hxx>
+#include <svx/svxdlg.hxx>
+#include <editeng/widwitem.hxx>
+
+#include <boost/scoped_ptr.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::frame;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+
+//.............................................................................
+namespace chart
+{
+//.............................................................................
+
+ShapeController::ShapeController( const Reference< uno::XComponentContext >& rxContext,
+ ChartController* pController )
+ :FeatureCommandDispatchBase( rxContext )
+ ,m_pChartController( pController )
+{
+}
+
+ShapeController::~ShapeController()
+{
+}
+
+void ShapeController::initialize()
+{
+ FeatureCommandDispatchBase::initialize();
+}
+
+// WeakComponentImplHelperBase
+void ShapeController::disposing()
+{
+}
+
+// XEventListener
+void ShapeController::disposing( const lang::EventObject& /* Source */ )
+ throw (uno::RuntimeException)
+{
+}
+
+FeatureState ShapeController::getState( const ::rtl::OUString& rCommand )
+{
+ FeatureState aReturn;
+ aReturn.bEnabled = false;
+ aReturn.aState <<= false;
+
+ bool bWritable = false;
+ if ( m_pChartController )
+ {
+ Reference< frame::XStorable > xStorable( m_pChartController->getModel(), uno::UNO_QUERY );
+ if ( xStorable.is() )
+ {
+ bWritable = !xStorable->isReadonly();
+ }
+ }
+
+ SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( rCommand );
+ if ( aIter != m_aSupportedFeatures.end() )
+ {
+ sal_uInt16 nFeatureId = aIter->second.nFeatureId;
+ switch ( nFeatureId )
+ {
+ case COMMAND_ID_FORMAT_LINE:
+ case COMMAND_ID_FORMAT_AREA:
+ case COMMAND_ID_TEXT_ATTRIBUTES:
+ case COMMAND_ID_TRANSFORM_DIALOG:
+ case COMMAND_ID_OBJECT_TITLE_DESCRIPTION:
+ case COMMAND_ID_RENAME_OBJECT:
+ {
+ aReturn.bEnabled = bWritable;
+ aReturn.aState <<= false;
+ }
+ break;
+ case COMMAND_ID_BRING_TO_FRONT:
+ case COMMAND_ID_FORWARD:
+ {
+ aReturn.bEnabled = ( bWritable && isForwardPossible() );
+ aReturn.aState <<= false;
+ }
+ break;
+ case COMMAND_ID_BACKWARD:
+ case COMMAND_ID_SEND_TO_BACK:
+ {
+
+ aReturn.bEnabled = ( bWritable && isBackwardPossible() );
+ aReturn.aState <<= false;
+ }
+ break;
+ case COMMAND_ID_FONT_DIALOG:
+ case COMMAND_ID_PARAGRAPH_DIALOG:
+ {
+ aReturn.bEnabled = bWritable;
+ aReturn.aState <<= false;
+ }
+ break;
+ default:
+ {
+ aReturn.bEnabled = false;
+ aReturn.aState <<= false;
+ }
+ break;
+ }
+ }
+
+ return aReturn;
+}
+
+void ShapeController::execute( const ::rtl::OUString& rCommand, const Sequence< beans::PropertyValue>& rArgs )
+{
+ (void)rArgs;
+
+ SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( rCommand );
+ if ( aIter != m_aSupportedFeatures.end() )
+ {
+ sal_uInt16 nFeatureId = aIter->second.nFeatureId;
+ switch ( nFeatureId )
+ {
+ case COMMAND_ID_FORMAT_LINE:
+ {
+ executeDispatch_FormatLine();
+ }
+ break;
+ case COMMAND_ID_FORMAT_AREA:
+ {
+ executeDispatch_FormatArea();
+ }
+ break;
+ case COMMAND_ID_TEXT_ATTRIBUTES:
+ {
+ executeDispatch_TextAttributes();
+ }
+ break;
+ case COMMAND_ID_TRANSFORM_DIALOG:
+ {
+ executeDispatch_TransformDialog();
+ }
+ break;
+ case COMMAND_ID_OBJECT_TITLE_DESCRIPTION:
+ {
+ executeDispatch_ObjectTitleDescription();
+ }
+ break;
+ case COMMAND_ID_RENAME_OBJECT:
+ {
+ executeDispatch_RenameObject();
+ }
+ break;
+ case COMMAND_ID_BRING_TO_FRONT:
+ case COMMAND_ID_FORWARD:
+ case COMMAND_ID_BACKWARD:
+ case COMMAND_ID_SEND_TO_BACK:
+ {
+ executeDispatch_ChangeZOrder( nFeatureId );
+ }
+ break;
+ case COMMAND_ID_FONT_DIALOG:
+ {
+ executeDispatch_FontDialog();
+ }
+ break;
+ case COMMAND_ID_PARAGRAPH_DIALOG:
+ {
+ executeDispatch_ParagraphDialog();
+ }
+ break;
+ default:
+ {
+ }
+ break;
+ }
+ }
+}
+
+void ShapeController::describeSupportedFeatures()
+{
+ implDescribeSupportedFeature( ".uno:FormatLine", COMMAND_ID_FORMAT_LINE, CommandGroup::FORMAT );
+ implDescribeSupportedFeature( ".uno:FormatArea", COMMAND_ID_FORMAT_AREA, CommandGroup::FORMAT );
+ implDescribeSupportedFeature( ".uno:TextAttributes", COMMAND_ID_TEXT_ATTRIBUTES, CommandGroup::FORMAT );
+ implDescribeSupportedFeature( ".uno:TransformDialog", COMMAND_ID_TRANSFORM_DIALOG, CommandGroup::FORMAT );
+ implDescribeSupportedFeature( ".uno:ObjectTitleDescription", COMMAND_ID_OBJECT_TITLE_DESCRIPTION, CommandGroup::FORMAT );
+ implDescribeSupportedFeature( ".uno:RenameObject", COMMAND_ID_RENAME_OBJECT, CommandGroup::FORMAT );
+ implDescribeSupportedFeature( ".uno:BringToFront", COMMAND_ID_BRING_TO_FRONT, CommandGroup::FORMAT );
+ implDescribeSupportedFeature( ".uno:Forward", COMMAND_ID_FORWARD, CommandGroup::FORMAT );
+ implDescribeSupportedFeature( ".uno:Backward", COMMAND_ID_BACKWARD, CommandGroup::FORMAT );
+ implDescribeSupportedFeature( ".uno:SendToBack", COMMAND_ID_SEND_TO_BACK, CommandGroup::FORMAT );
+ implDescribeSupportedFeature( ".uno:FontDialog", COMMAND_ID_FONT_DIALOG, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:ParagraphDialog", COMMAND_ID_PARAGRAPH_DIALOG, CommandGroup::EDIT );
+}
+
+IMPL_LINK( ShapeController, CheckNameHdl, AbstractSvxNameDialog*, pDialog )
+{
+ String aName;
+ if ( pDialog )
+ {
+ pDialog->GetName( aName );
+ }
+ if ( aName.Len() )
+ {
+ DrawViewWrapper* pDrawViewWrapper = ( m_pChartController ? m_pChartController->GetDrawViewWrapper() : NULL );
+ if ( pDrawViewWrapper && pDrawViewWrapper->getNamedSdrObject( aName ) )
+ {
+ return 0;
+ }
+ }
+ return 1;
+}
+
+void ShapeController::executeDispatch_FormatLine()
+{
+ if ( m_pChartController )
+ {
+ Window* pParent = dynamic_cast< Window* >( m_pChartController->m_pChartWindow );
+ DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper();
+ DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
+ if ( pParent && pDrawModelWrapper && pDrawViewWrapper )
+ {
+ SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject();
+ SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() );
+ BOOL bHasMarked = pDrawViewWrapper->AreObjectsMarked();
+ if ( bHasMarked )
+ {
+ pDrawViewWrapper->MergeAttrFromMarked( aAttr, FALSE );
+ }
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if ( pFact )
+ {
+ ::boost::scoped_ptr< SfxAbstractTabDialog > pDlg(
+ pFact->CreateSvxLineTabDialog( pParent, &aAttr, &pDrawModelWrapper->getSdrModel(),
+ pSelectedObj, bHasMarked ) );
+ if ( pDlg.get() && ( pDlg->Execute() == RET_OK ) )
+ {
+ const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
+ if ( bHasMarked )
+ {
+ pDrawViewWrapper->SetAttrToMarked( *pOutAttr, FALSE );
+ }
+ else
+ {
+ pDrawViewWrapper->SetDefaultAttr( *pOutAttr, FALSE );
+ }
+ }
+ }
+ }
+ }
+}
+
+void ShapeController::executeDispatch_FormatArea()
+{
+ if ( m_pChartController )
+ {
+ Window* pParent = dynamic_cast< Window* >( m_pChartController->m_pChartWindow );
+ DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper();
+ DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
+ if ( pParent && pDrawModelWrapper && pDrawViewWrapper )
+ {
+ SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() );
+ BOOL bHasMarked = pDrawViewWrapper->AreObjectsMarked();
+ if ( bHasMarked )
+ {
+ pDrawViewWrapper->MergeAttrFromMarked( aAttr, FALSE );
+ }
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if ( pFact )
+ {
+ ::boost::scoped_ptr< AbstractSvxAreaTabDialog > pDlg(
+ pFact->CreateSvxAreaTabDialog( pParent, &aAttr, &pDrawModelWrapper->getSdrModel(),
+ pDrawViewWrapper ) );
+ if ( pDlg.get() )
+ {
+ SfxItemPool& rItemPool = pDrawViewWrapper->GetModel()->GetItemPool();
+ SfxItemSet aSet( rItemPool, rItemPool.GetFirstWhich(), rItemPool.GetLastWhich() );
+ const SvxColorTableItem* pColorItem = static_cast< const SvxColorTableItem* >( aSet.GetItem( SID_COLOR_TABLE ) );
+ if ( pColorItem && pColorItem->GetColorTable() == XColorTable::GetStdColorTable() )
+ {
+ pDlg->DontDeleteColorTable();
+ }
+ if ( pDlg->Execute() == RET_OK )
+ {
+ const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
+ if ( bHasMarked )
+ {
+ pDrawViewWrapper->SetAttrToMarked( *pOutAttr, FALSE );
+ }
+ else
+ {
+ pDrawViewWrapper->SetDefaultAttr( *pOutAttr, FALSE );
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void ShapeController::executeDispatch_TextAttributes()
+{
+ if ( m_pChartController )
+ {
+ Window* pParent = dynamic_cast< Window* >( m_pChartController->m_pChartWindow );
+ DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
+ if ( pParent && pDrawViewWrapper )
+ {
+ SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() );
+ BOOL bHasMarked = pDrawViewWrapper->AreObjectsMarked();
+ if ( bHasMarked )
+ {
+ pDrawViewWrapper->MergeAttrFromMarked( aAttr, FALSE );
+ }
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if ( pFact )
+ {
+ ::boost::scoped_ptr< SfxAbstractTabDialog > pDlg(
+ pFact->CreateTextTabDialog( pParent, &aAttr, pDrawViewWrapper ) );
+ if ( pDlg.get() && ( pDlg->Execute() == RET_OK ) )
+ {
+ const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
+ if ( bHasMarked )
+ {
+ pDrawViewWrapper->SetAttributes( *pOutAttr );
+ }
+ else
+ {
+ pDrawViewWrapper->SetDefaultAttr( *pOutAttr, FALSE );
+ }
+ }
+ }
+ }
+ }
+}
+
+void ShapeController::executeDispatch_TransformDialog()
+{
+ if ( m_pChartController )
+ {
+ Window* pParent = dynamic_cast< Window* >( m_pChartController->m_pChartWindow );
+ DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
+ if ( pParent && pDrawViewWrapper )
+ {
+ SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject();
+ if ( pSelectedObj && pSelectedObj->GetObjIdentifier() == OBJ_CAPTION )
+ {
+ // item set for caption
+ SfxItemSet aAttr( pDrawViewWrapper->GetModel()->GetItemPool() );
+ pDrawViewWrapper->GetAttributes( aAttr );
+ // item set for position and size
+ SfxItemSet aGeoAttr( pDrawViewWrapper->GetGeoAttrFromMarked() );
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if ( pFact )
+ {
+ ::boost::scoped_ptr< SfxAbstractTabDialog > pDlg(
+ pFact->CreateCaptionDialog( pParent, pDrawViewWrapper ) );
+ if ( pDlg.get() )
+ {
+ const USHORT* pRange = pDlg->GetInputRanges( *aAttr.GetPool() );
+ SfxItemSet aCombAttr( *aAttr.GetPool(), pRange );
+ aCombAttr.Put( aAttr );
+ aCombAttr.Put( aGeoAttr );
+ pDlg->SetInputSet( &aCombAttr );
+ if ( pDlg->Execute() == RET_OK )
+ {
+ const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
+ pDrawViewWrapper->SetAttributes( *pOutAttr );
+ pDrawViewWrapper->SetGeoAttrToMarked( *pOutAttr );
+ }
+ }
+ }
+ }
+ else
+ {
+ SfxItemSet aGeoAttr( pDrawViewWrapper->GetGeoAttrFromMarked() );
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if ( pFact )
+ {
+ ::boost::scoped_ptr< SfxAbstractTabDialog > pDlg(
+ pFact->CreateSvxTransformTabDialog( pParent, &aGeoAttr, pDrawViewWrapper ) );
+ if ( pDlg.get() && ( pDlg->Execute() == RET_OK ) )
+ {
+ const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
+ pDrawViewWrapper->SetGeoAttrToMarked( *pOutAttr );
+ }
+ }
+ }
+ }
+ }
+}
+
+void ShapeController::executeDispatch_ObjectTitleDescription()
+{
+ if ( m_pChartController )
+ {
+ DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
+ if ( pDrawViewWrapper && pDrawViewWrapper->GetMarkedObjectCount() == 1 )
+ {
+ SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject();
+ if ( pSelectedObj )
+ {
+ String aTitle( pSelectedObj->GetTitle() );
+ String aDescription( pSelectedObj->GetDescription() );
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if ( pFact )
+ {
+ ::boost::scoped_ptr< AbstractSvxObjectTitleDescDialog > pDlg(
+ pFact->CreateSvxObjectTitleDescDialog( NULL, aTitle, aDescription ) );
+ if ( pDlg.get() && ( pDlg->Execute() == RET_OK ) )
+ {
+ pDlg->GetTitle( aTitle );
+ pDlg->GetDescription( aDescription );
+ pSelectedObj->SetTitle( aTitle );
+ pSelectedObj->SetDescription( aDescription );
+ }
+ }
+ }
+ }
+ }
+}
+
+void ShapeController::executeDispatch_RenameObject()
+{
+ if ( m_pChartController )
+ {
+ DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
+ if ( pDrawViewWrapper && pDrawViewWrapper->GetMarkedObjectCount() == 1 )
+ {
+ SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject();
+ if ( pSelectedObj )
+ {
+ String aName( pSelectedObj->GetName() );
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if ( pFact )
+ {
+ ::boost::scoped_ptr< AbstractSvxObjectNameDialog > pDlg(
+ pFact->CreateSvxObjectNameDialog( NULL, aName ) );
+ pDlg->SetCheckNameHdl( LINK( this, ShapeController, CheckNameHdl ) );
+ if ( pDlg.get() && ( pDlg->Execute() == RET_OK ) )
+ {
+ pDlg->GetName( aName );
+ if ( aName != pSelectedObj->GetName() )
+ {
+ pSelectedObj->SetName( aName );
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void ShapeController::executeDispatch_ChangeZOrder( sal_uInt16 nId )
+{
+ DrawViewWrapper* pDrawViewWrapper = ( m_pChartController ? m_pChartController->GetDrawViewWrapper() : NULL );
+ if ( pDrawViewWrapper )
+ {
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ switch ( nId )
+ {
+ case COMMAND_ID_BRING_TO_FRONT:
+ {
+ if ( isForwardPossible() )
+ {
+ pDrawViewWrapper->PutMarkedToTop();
+ }
+ }
+ break;
+ case COMMAND_ID_FORWARD:
+ {
+ if ( isForwardPossible() )
+ {
+ pDrawViewWrapper->MovMarkedToTop();
+ }
+ }
+ break;
+ case COMMAND_ID_BACKWARD:
+ {
+ if ( isBackwardPossible() )
+ {
+ pDrawViewWrapper->MovMarkedToBtm();
+ }
+ }
+ break;
+ case COMMAND_ID_SEND_TO_BACK:
+ {
+ if ( isBackwardPossible() )
+ {
+ SdrObject* pFirstObj = getFirstAdditionalShape();
+ pDrawViewWrapper->PutMarkedBehindObj( pFirstObj );
+ }
+ }
+ break;
+ default:
+ {
+ }
+ break;
+ }
+ }
+}
+
+void ShapeController::executeDispatch_FontDialog()
+{
+ if ( m_pChartController )
+ {
+ Window* pParent = dynamic_cast< Window* >( m_pChartController->m_pChartWindow );
+ DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper();
+ DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
+ if ( pParent && pDrawModelWrapper && pDrawViewWrapper )
+ {
+ SfxItemSet aAttr( pDrawViewWrapper->GetModel()->GetItemPool() );
+ pDrawViewWrapper->GetAttributes( aAttr );
+ ViewElementListProvider aViewElementListProvider( pDrawModelWrapper );
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ ::boost::scoped_ptr< ShapeFontDialog > pDlg( new ShapeFontDialog( pParent, &aAttr, &aViewElementListProvider ) );
+ if ( pDlg.get() && ( pDlg->Execute() == RET_OK ) )
+ {
+ const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
+ pDrawViewWrapper->SetAttributes( *pOutAttr );
+ }
+ }
+ }
+}
+
+void ShapeController::executeDispatch_ParagraphDialog()
+{
+ if ( m_pChartController )
+ {
+ Window* pParent = dynamic_cast< Window* >( m_pChartController->m_pChartWindow );
+ DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
+ if ( pParent && pDrawViewWrapper )
+ {
+ SfxItemPool& rPool = pDrawViewWrapper->GetModel()->GetItemPool();
+ SfxItemSet aAttr( rPool );
+ pDrawViewWrapper->GetAttributes( aAttr );
+
+ SfxItemSet aNewAttr( rPool,
+ EE_ITEMS_START, EE_ITEMS_END,
+ SID_ATTR_PARA_HYPHENZONE, SID_ATTR_PARA_HYPHENZONE,
+ SID_ATTR_PARA_PAGEBREAK, SID_ATTR_PARA_PAGEBREAK,
+ SID_ATTR_PARA_SPLIT, SID_ATTR_PARA_SPLIT,
+ SID_ATTR_PARA_WIDOWS, SID_ATTR_PARA_WIDOWS,
+ SID_ATTR_PARA_ORPHANS, SID_ATTR_PARA_ORPHANS,
+ 0 );
+ aNewAttr.Put( aAttr );
+ aNewAttr.Put( SvxHyphenZoneItem( sal_False, SID_ATTR_PARA_HYPHENZONE ) );
+ aNewAttr.Put( SvxFmtBreakItem( SVX_BREAK_NONE, SID_ATTR_PARA_PAGEBREAK ) );
+ aNewAttr.Put( SvxFmtSplitItem( sal_True, SID_ATTR_PARA_SPLIT) );
+ aNewAttr.Put( SvxWidowsItem( 0, SID_ATTR_PARA_WIDOWS) );
+ aNewAttr.Put( SvxOrphansItem( 0, SID_ATTR_PARA_ORPHANS) );
+
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ ::boost::scoped_ptr< ShapeParagraphDialog > pDlg( new ShapeParagraphDialog( pParent, &aNewAttr ) );
+ if ( pDlg.get() && ( pDlg->Execute() == RET_OK ) )
+ {
+ const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
+ pDrawViewWrapper->SetAttributes( *pOutAttr );
+ }
+ }
+ }
+}
+
+SdrObject* ShapeController::getFirstAdditionalShape()
+{
+ SdrObject* pFirstObj = NULL;
+
+ try
+ {
+ DrawModelWrapper* pDrawModelWrapper = ( m_pChartController ? m_pChartController->GetDrawModelWrapper() : NULL );
+ if ( pDrawModelWrapper )
+ {
+ Reference< drawing::XShape > xFirstShape;
+ Reference< drawing::XDrawPage > xDrawPage( pDrawModelWrapper->getMainDrawPage() );
+ Reference< drawing::XShapes > xDrawPageShapes( xDrawPage, uno::UNO_QUERY_THROW );
+ Reference< drawing::XShapes > xChartRoot( DrawModelWrapper::getChartRootShape( xDrawPage ) );
+ sal_Int32 nCount = xDrawPageShapes->getCount();
+ for ( sal_Int32 i = 0; i < nCount; ++i )
+ {
+ Reference< drawing::XShape > xShape;
+ if ( xDrawPageShapes->getByIndex( i ) >>= xShape )
+ {
+ if ( xShape.is() && xShape != xChartRoot )
+ {
+ xFirstShape = xShape;
+ break;
+ }
+ }
+ }
+ if ( xFirstShape.is() )
+ {
+ pFirstObj = DrawViewWrapper::getSdrObject( xFirstShape );
+ }
+ }
+ }
+ catch ( uno::Exception& ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+
+ return pFirstObj;
+}
+
+SdrObject* ShapeController::getLastAdditionalShape()
+{
+ SdrObject* pLastObj = NULL;
+
+ try
+ {
+ DrawModelWrapper* pDrawModelWrapper = ( m_pChartController ? m_pChartController->GetDrawModelWrapper() : NULL );
+ if ( pDrawModelWrapper )
+ {
+ Reference< drawing::XShape > xLastShape;
+ Reference< drawing::XDrawPage > xDrawPage( pDrawModelWrapper->getMainDrawPage() );
+ Reference< drawing::XShapes > xDrawPageShapes( xDrawPage, uno::UNO_QUERY_THROW );
+ Reference< drawing::XShapes > xChartRoot( DrawModelWrapper::getChartRootShape( xDrawPage ) );
+ sal_Int32 nCount = xDrawPageShapes->getCount();
+ for ( sal_Int32 i = nCount - 1; i >= 0; --i )
+ {
+ Reference< drawing::XShape > xShape;
+ if ( xDrawPageShapes->getByIndex( i ) >>= xShape )
+ {
+ if ( xShape.is() && xShape != xChartRoot )
+ {
+ xLastShape = xShape;
+ break;
+ }
+ }
+ }
+ if ( xLastShape.is() )
+ {
+ pLastObj = DrawViewWrapper::getSdrObject( xLastShape );
+ }
+ }
+ }
+ catch ( uno::Exception& ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+
+ return pLastObj;
+}
+
+bool ShapeController::isBackwardPossible()
+{
+ if ( m_pChartController && m_pChartController->m_aSelection.isAdditionalShapeSelected() )
+ {
+ DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
+ if ( pDrawViewWrapper )
+ {
+ SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject();
+ SdrObject* pFirstObj = getFirstAdditionalShape();
+ if ( pSelectedObj && pFirstObj && pSelectedObj != pFirstObj )
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+bool ShapeController::isForwardPossible()
+{
+ if ( m_pChartController && m_pChartController->m_aSelection.isAdditionalShapeSelected() )
+ {
+ DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
+ if ( pDrawViewWrapper )
+ {
+ SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject();
+ SdrObject* pLastObj = getLastAdditionalShape();
+ if ( pSelectedObj && pLastObj && pSelectedObj != pLastObj )
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+//.............................................................................
+} // namespace chart
+//.............................................................................
diff --git a/chart2/source/controller/main/ShapeController.hxx b/chart2/source/controller/main/ShapeController.hxx
new file mode 100644
index 000000000000..aea01d6c478d
--- /dev/null
+++ b/chart2/source/controller/main/ShapeController.hxx
@@ -0,0 +1,100 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef CHART2_SHAPECONTROLLER_HXX
+#define CHART2_SHAPECONTROLLER_HXX
+
+#include "FeatureCommandDispatchBase.hxx"
+#include <tools/link.hxx>
+
+class AbstractSvxNameDialog;
+class SdrObject;
+
+//.............................................................................
+namespace chart
+{
+//.............................................................................
+
+class ChartController;
+
+/** This is a CommandDispatch implementation for shapes.
+ */
+class ShapeController: public FeatureCommandDispatchBase
+{
+ friend class ControllerCommandDispatch;
+
+public:
+ ShapeController( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XComponentContext >& rxContext, ChartController* pController );
+ virtual ~ShapeController();
+
+ // late initialisation, especially for adding as listener
+ virtual void initialize();
+
+protected:
+ // WeakComponentImplHelperBase
+ virtual void SAL_CALL disposing();
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // state of a feature
+ virtual FeatureState getState( const ::rtl::OUString& rCommand );
+
+ // execute a feature
+ virtual void execute( const ::rtl::OUString& rCommand, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rArgs );
+
+ // all the features which should be handled by this class
+ virtual void describeSupportedFeatures();
+
+private:
+ DECL_LINK( CheckNameHdl, AbstractSvxNameDialog* );
+
+ void executeDispatch_FormatLine();
+ void executeDispatch_FormatArea();
+ void executeDispatch_TextAttributes();
+ void executeDispatch_TransformDialog();
+ void executeDispatch_ObjectTitleDescription();
+ void executeDispatch_RenameObject();
+ void executeDispatch_ChangeZOrder( sal_uInt16 nId );
+ void executeDispatch_FontDialog();
+ void executeDispatch_ParagraphDialog();
+
+ SdrObject* getFirstAdditionalShape();
+ SdrObject* getLastAdditionalShape();
+ bool isBackwardPossible();
+ bool isForwardPossible();
+
+ ChartController* m_pChartController;
+};
+
+//.............................................................................
+} // namespace chart
+//.............................................................................
+
+// CHART2_SHAPECONTROLLER_HXX
+#endif
diff --git a/chart2/source/controller/main/ShapeToolbarController.cxx b/chart2/source/controller/main/ShapeToolbarController.cxx
new file mode 100644
index 000000000000..a8a6cfba20ff
--- /dev/null
+++ b/chart2/source/controller/main/ShapeToolbarController.cxx
@@ -0,0 +1,298 @@
+/*************************************************************************
+ *
+ * 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 "ShapeToolbarController.hxx"
+
+#include <vos/mutex.hxx>
+#include <comphelper/sequence.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/toolbox.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <svx/svxids.hrc>
+#include <svx/tbxcustomshapes.hxx>
+
+
+using namespace com::sun::star;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+
+//.............................................................................
+namespace chart
+{
+//.............................................................................
+
+::rtl::OUString ShapeToolbarController::getImplementationName() throw (uno::RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+::rtl::OUString ShapeToolbarController::getImplementationName_Static() throw (uno::RuntimeException)
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.comp.ShapeToolbarController" ) );
+}
+
+Sequence< ::rtl::OUString > ShapeToolbarController::getSupportedServiceNames_Static() throw (uno::RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.ShapeToolbarController" ) );
+ return aSupported;
+}
+
+::sal_Bool ShapeToolbarController::supportsService( const ::rtl::OUString& ServiceName ) throw (uno::RuntimeException)
+{
+ return ::comphelper::existsValue( ServiceName, getSupportedServiceNames_Static() );
+}
+
+Sequence< ::rtl::OUString> ShapeToolbarController::getSupportedServiceNames() throw (uno::RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+Reference< uno::XInterface > ShapeToolbarController::create( const Reference< uno::XComponentContext >& xContext )
+{
+ return *( new ShapeToolbarController( Reference< lang::XMultiServiceFactory >( xContext->getServiceManager(), uno::UNO_QUERY ) ) );
+}
+
+ShapeToolbarController::ShapeToolbarController( const Reference< lang::XMultiServiceFactory >& rxFact )
+ :m_pToolbarController( NULL )
+ ,m_nToolBoxId( 1 )
+ ,m_nSlotId( 0 )
+{
+ osl_incrementInterlockedCount( &m_refCount );
+ m_xServiceManager = rxFact;
+ osl_decrementInterlockedCount( &m_refCount );
+}
+
+ShapeToolbarController::~ShapeToolbarController()
+{
+}
+
+// ::com::sun::star::uno::XInterface
+uno::Any ShapeToolbarController::queryInterface( const uno::Type& rType ) throw (uno::RuntimeException)
+{
+ uno::Any aReturn = ToolboxController::queryInterface( rType );
+ if ( !aReturn.hasValue() )
+ {
+ aReturn = ShapeToolbarController_Base::queryInterface( rType );
+ }
+ return aReturn;
+}
+
+void ShapeToolbarController::acquire() throw ()
+{
+ ToolboxController::acquire();
+}
+
+void ShapeToolbarController::release() throw ()
+{
+ ToolboxController::release();
+}
+
+// ::com::sun::star::lang::XInitialization
+void ShapeToolbarController::initialize( const Sequence< uno::Any >& rArguments ) throw (uno::Exception, uno::RuntimeException)
+{
+ ToolboxController::initialize( rArguments );
+ ::vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ToolBox* pToolBox = static_cast< ToolBox* >( VCLUnoHelper::GetWindow( getParent() ) );
+ if ( pToolBox )
+ {
+ const USHORT nCount = pToolBox->GetItemCount();
+ for ( USHORT nPos = 0; nPos < nCount; ++nPos )
+ {
+ const USHORT nItemId = pToolBox->GetItemId( nPos );
+ if ( pToolBox->GetItemCommand( nItemId ) == String( m_aCommandURL ) )
+ {
+ m_nToolBoxId = nItemId;
+ break;
+ }
+ }
+ if ( m_aCommandURL.equalsAscii( ".uno:BasicShapes" ) )
+ {
+ m_aStates.insert( TCommandState::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:BasicShapes" ) ), sal_True ) );
+ m_nSlotId = SID_DRAWTBX_CS_BASIC;
+ m_pToolbarController = TToolbarHelper::createFromQuery( new SvxTbxCtlCustomShapes( m_nSlotId, m_nToolBoxId, *pToolBox ) );
+ }
+ else if ( m_aCommandURL.equalsAscii( ".uno:SymbolShapes" ) )
+ {
+ m_aStates.insert( TCommandState::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:SymbolShapes" ) ), sal_True ) );
+ m_nSlotId = SID_DRAWTBX_CS_SYMBOL;
+ m_pToolbarController = TToolbarHelper::createFromQuery( new SvxTbxCtlCustomShapes( m_nSlotId, m_nToolBoxId, *pToolBox ) );
+ }
+ else if ( m_aCommandURL.equalsAscii( ".uno:ArrowShapes" ) )
+ {
+ m_aStates.insert( TCommandState::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ArrowShapes" ) ), sal_True ) );
+ m_nSlotId = SID_DRAWTBX_CS_ARROW;
+ m_pToolbarController = TToolbarHelper::createFromQuery( new SvxTbxCtlCustomShapes( m_nSlotId, m_nToolBoxId, *pToolBox) );
+ }
+ else if ( m_aCommandURL.equalsAscii( ".uno:FlowChartShapes" ) )
+ {
+ m_aStates.insert( TCommandState::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FlowChartShapes" ) ), sal_True ) );
+ m_nSlotId = SID_DRAWTBX_CS_FLOWCHART;
+ m_pToolbarController = TToolbarHelper::createFromQuery( new SvxTbxCtlCustomShapes( m_nSlotId, m_nToolBoxId, *pToolBox ) );
+ }
+ else if ( m_aCommandURL.equalsAscii( ".uno:CalloutShapes" ) )
+ {
+ m_aStates.insert( TCommandState::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CalloutShapes" ) ), sal_True ) );
+ m_nSlotId = SID_DRAWTBX_CS_CALLOUT;
+ m_pToolbarController = TToolbarHelper::createFromQuery( new SvxTbxCtlCustomShapes( m_nSlotId, m_nToolBoxId, *pToolBox ) );
+ }
+ else if ( m_aCommandURL.equalsAscii( ".uno:StarShapes" ) )
+ {
+ m_aStates.insert( TCommandState::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:StarShapes" ) ), sal_True ) );
+ m_nSlotId = SID_DRAWTBX_CS_STAR;
+ m_pToolbarController = TToolbarHelper::createFromQuery( new SvxTbxCtlCustomShapes( m_nSlotId, m_nToolBoxId, *pToolBox ) );
+ }
+
+ for ( TCommandState::iterator aIter( m_aStates.begin() ); aIter != m_aStates.end(); ++aIter )
+ {
+ addStatusListener( aIter->first );
+ }
+
+ if ( m_pToolbarController.is() )
+ {
+ m_pToolbarController->initialize( rArguments );
+ }
+
+ // check if paste special is allowed, when not don't add DROPDOWN
+ pToolBox->SetItemBits( m_nToolBoxId, pToolBox->GetItemBits( m_nToolBoxId ) | TIB_DROPDOWN );
+ }
+}
+
+// ::com::sun::star::frame::XStatusListener
+void ShapeToolbarController::statusChanged( const frame::FeatureStateEvent& Event ) throw ( uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ TCommandState::iterator aFind = m_aStates.find( Event.FeatureURL.Complete );
+ if ( aFind != m_aStates.end() )
+ {
+ aFind->second = Event.IsEnabled;
+ if ( m_pToolbarController.is() )
+ {
+ sal_Bool bCheckmark = sal_False;
+ ToolBox& rTb = m_pToolbarController->GetToolBox();
+
+ for ( USHORT i = 0; i < rTb.GetItemCount(); ++i )
+ {
+ USHORT nId = rTb.GetItemId( i );
+ if ( nId == 0 )
+ {
+ continue;
+ }
+ ::rtl::OUString aCmd = rTb.GetItemCommand( nId );
+ if ( aCmd == Event.FeatureURL.Complete )
+ {
+ rTb.EnableItem( nId, Event.IsEnabled );
+ if ( Event.State >>= bCheckmark )
+ {
+ rTb.CheckItem( nId, bCheckmark );
+ }
+ else
+ {
+ ::rtl::OUString aItemText;
+ if ( Event.State >>= aItemText )
+ {
+ rTb.SetItemText( nId, aItemText );
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+// ::com::sun::star::frame::XToolbarController
+Reference< awt::XWindow > ShapeToolbarController::createPopupWindow() throw (uno::RuntimeException)
+{
+ ::vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Reference< awt::XWindow > xRet;
+ if ( m_pToolbarController.is() )
+ {
+ xRet = m_pToolbarController.getRef()->createPopupWindow();
+ }
+
+ return xRet;
+}
+
+// ::com::sun::star::frame::XSubToolbarController
+::sal_Bool ShapeToolbarController::opensSubToolbar() throw (uno::RuntimeException)
+{
+ return ( m_nSlotId == SID_DRAWTBX_CS_BASIC ||
+ m_nSlotId == SID_DRAWTBX_CS_SYMBOL ||
+ m_nSlotId == SID_DRAWTBX_CS_ARROW ||
+ m_nSlotId == SID_DRAWTBX_CS_FLOWCHART ||
+ m_nSlotId == SID_DRAWTBX_CS_CALLOUT ||
+ m_nSlotId == SID_DRAWTBX_CS_STAR );
+}
+
+::rtl::OUString ShapeToolbarController::getSubToolbarName() throw (uno::RuntimeException)
+{
+ ::vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard(m_aMutex);
+ uno::Reference< frame::XSubToolbarController > xSub( m_pToolbarController.getRef(), uno::UNO_QUERY );
+ if ( xSub.is() )
+ {
+ return xSub->getSubToolbarName();
+ }
+ return ::rtl::OUString();
+}
+
+void ShapeToolbarController::functionSelected( const ::rtl::OUString& rCommand ) throw (uno::RuntimeException)
+{
+ ::vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ uno::Reference< frame::XSubToolbarController > xSub( m_pToolbarController.getRef(), uno::UNO_QUERY );
+ if ( xSub.is() )
+ {
+ m_aCommandURL = rCommand;
+ xSub->functionSelected( rCommand );
+ }
+}
+
+void ShapeToolbarController::updateImage() throw (uno::RuntimeException)
+{
+ ::vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ uno::Reference< frame::XSubToolbarController > xSub( m_pToolbarController.getRef(), uno::UNO_QUERY );
+ if ( xSub.is() )
+ {
+ xSub->updateImage();
+ }
+}
+
+//.............................................................................
+} // namespace chart
+//.............................................................................
diff --git a/chart2/source/controller/main/ShapeToolbarController.hxx b/chart2/source/controller/main/ShapeToolbarController.hxx
new file mode 100644
index 000000000000..544cac7f9831
--- /dev/null
+++ b/chart2/source/controller/main/ShapeToolbarController.hxx
@@ -0,0 +1,103 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef CHART2_SHAPETOOLBARCONTROLLER_HXX
+#define CHART2_SHAPETOOLBARCONTROLLER_HXX
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/frame/XSubToolbarController.hpp>
+
+#include <cppuhelper/implbase2.hxx>
+#include <comphelper/implementationreference.hxx>
+#include <comphelper/stl_types.hxx>
+#include <svtools/toolboxcontroller.hxx>
+
+class SfxToolBoxControl;
+
+//.............................................................................
+namespace chart
+{
+//.............................................................................
+
+typedef ::cppu::ImplHelper2 < ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::frame::XSubToolbarController> ShapeToolbarController_Base;
+
+typedef ::comphelper::ImplementationReference< SfxToolBoxControl, ::com::sun::star::frame::XToolbarController > TToolbarHelper;
+
+class ShapeToolbarController : public ::svt::ToolboxController
+ ,public ShapeToolbarController_Base
+{
+ DECLARE_STL_USTRINGACCESS_MAP( sal_Bool, TCommandState );
+ TCommandState m_aStates;
+ TToolbarHelper m_pToolbarController;
+ sal_uInt16 m_nToolBoxId;
+ sal_uInt16 m_nSlotId;
+ ShapeToolbarController( const ShapeToolbarController& );
+ void operator =( const ShapeToolbarController& );
+
+public:
+ ShapeToolbarController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFact );
+ virtual ~ShapeToolbarController();
+
+ // ::com::sun::star::uno::XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw ();
+ virtual void SAL_CALL release() throw ();
+
+ // ::com::sun::star::lang::XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // needed by registration
+ static ::rtl::OUString getImplementationName_Static() throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
+ create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext );
+ virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::lang::XInitialization
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::frame::XStatusListener
+ virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::frame::XToolbarController
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createPopupWindow() throw (::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::frame::XSubToolbarController
+ virtual ::sal_Bool SAL_CALL opensSubToolbar() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSubToolbarName() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL functionSelected( const ::rtl::OUString& aCommand ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateImage() throw (::com::sun::star::uno::RuntimeException);
+};
+
+//.............................................................................
+} // namespace chart
+//.............................................................................
+
+#endif //CHART2_SHAPETOOLBARCONTROLLER_HXX
+
diff --git a/chart2/source/controller/main/StatusBarCommandDispatch.cxx b/chart2/source/controller/main/StatusBarCommandDispatch.cxx
index 8522d96191e8..d80d37eff7da 100644
--- a/chart2/source/controller/main/StatusBarCommandDispatch.cxx
+++ b/chart2/source/controller/main/StatusBarCommandDispatch.cxx
@@ -95,7 +95,7 @@ void StatusBarCommandDispatch::fireStatusEvent(
{
uno::Any aArg;
Reference< chart2::XChartDocument > xDoc( m_xModifiable, uno::UNO_QUERY );
- aArg <<= ObjectNameProvider::getSelectedObjectText( m_aSelectedCID, xDoc );
+ aArg <<= ObjectNameProvider::getSelectedObjectText( m_aSelectedOID.getObjectCID(), xDoc );
fireStatusEventForURL( C2U(".uno:Context"), aArg, true, xSingleListener );
}
if( bFireModified )
@@ -147,9 +147,9 @@ void SAL_CALL StatusBarCommandDispatch::selectionChanged( const lang::EventObjec
throw (uno::RuntimeException)
{
if( m_xSelectionSupplier.is())
- m_xSelectionSupplier->getSelection() >>= m_aSelectedCID;
+ m_aSelectedOID = ObjectIdentifier( m_xSelectionSupplier->getSelection() );
else
- m_aSelectedCID = OUString();
+ m_aSelectedOID = ObjectIdentifier();
fireAllStatusEvents( 0 );
}
diff --git a/chart2/source/controller/main/StatusBarCommandDispatch.hxx b/chart2/source/controller/main/StatusBarCommandDispatch.hxx
index 23a394ecad6e..c84f81f83258 100644
--- a/chart2/source/controller/main/StatusBarCommandDispatch.hxx
+++ b/chart2/source/controller/main/StatusBarCommandDispatch.hxx
@@ -28,6 +28,7 @@
#define CHART2_STATUSBARCOMMANDDISPATCH_HXX
#include "CommandDispatch.hxx"
+#include "ObjectIdentifier.hxx"
#include <cppuhelper/implbase1.hxx>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/view/XSelectionSupplier.hpp>
@@ -100,7 +101,7 @@ private:
::com::sun::star::uno::Reference<
::com::sun::star::view::XSelectionSupplier > m_xSelectionSupplier;
bool m_bIsModified;
- ::rtl::OUString m_aSelectedCID;
+ ObjectIdentifier m_aSelectedOID;
};
} // namespace chart
diff --git a/chart2/source/tools/UndoGuard.cxx b/chart2/source/controller/main/UndoGuard.cxx
index 61bed4029db5..61bed4029db5 100644
--- a/chart2/source/tools/UndoGuard.cxx
+++ b/chart2/source/controller/main/UndoGuard.cxx
diff --git a/chart2/source/tools/UndoManager.cxx b/chart2/source/controller/main/UndoManager.cxx
index 8c6f191a1a19..34157503e629 100644
--- a/chart2/source/tools/UndoManager.cxx
+++ b/chart2/source/controller/main/UndoManager.cxx
@@ -41,6 +41,8 @@
#include <unotools/configitem.hxx>
#include <cppuhelper/compbase1.hxx>
+#include <rtl/uuid.h>
+#include <svx/svdundo.hxx>
#include <functional>
@@ -131,10 +133,31 @@ UndoManager::~UndoManager()
m_pLastRemeberedUndoElement = 0;
}
+void UndoManager::addShapeUndoAction( SdrUndoAction* pAction )
+{
+ if ( !pAction )
+ {
+ return;
+ }
+
+ impl::ShapeUndoElement* pShapeUndoElement = new impl::ShapeUndoElement( pAction->GetComment(), pAction );
+ if ( pShapeUndoElement )
+ {
+ m_apUndoStack->push( pShapeUndoElement );
+ m_apRedoStack->disposeAndClear();
+ if ( !m_apUndoStepsConfigItem.get() )
+ {
+ retrieveConfigUndoSteps();
+ }
+ fireModifyEvent();
+ }
+}
+
void UndoManager::impl_undoRedo(
Reference< frame::XModel > & xCurrentModel,
impl::UndoStack * pStackToRemoveFrom,
- impl::UndoStack * pStackToAddTo )
+ impl::UndoStack * pStackToAddTo,
+ bool bUndo )
{
if( pStackToRemoveFrom && ! pStackToRemoveFrom->empty() )
{
@@ -142,11 +165,32 @@ void UndoManager::impl_undoRedo(
impl::UndoElement * pTop( pStackToRemoveFrom->top());
if( pTop )
{
- // put a clone of current model into redo/undo stack with the same
- // action string as the undo/redo
- pStackToAddTo->push( pTop->createFromModel( xCurrentModel ));
- // change current model by properties of the model from undo
- pTop->applyToModel( xCurrentModel );
+ impl::ShapeUndoElement* pShapeUndoElement = dynamic_cast< impl::ShapeUndoElement* >( pTop );
+ if ( pShapeUndoElement )
+ {
+ impl::ShapeUndoElement* pNewShapeUndoElement = new impl::ShapeUndoElement( *pShapeUndoElement );
+ pStackToAddTo->push( pNewShapeUndoElement );
+ SdrUndoAction* pAction = pNewShapeUndoElement->getSdrUndoAction();
+ if ( pAction )
+ {
+ if ( bUndo )
+ {
+ pAction->Undo();
+ }
+ else
+ {
+ pAction->Redo();
+ }
+ }
+ }
+ else
+ {
+ // put a clone of current model into redo/undo stack with the same
+ // action string as the undo/redo
+ pStackToAddTo->push( pTop->createFromModel( xCurrentModel ));
+ // change current model by properties of the model from undo
+ pTop->applyToModel( xCurrentModel );
+ }
// remove the top undo element
pStackToRemoveFrom->pop(), pTop = 0;
ChartViewHelper::setViewToDirtyState( xCurrentModel );
@@ -287,14 +331,14 @@ void SAL_CALL UndoManager::undo( Reference< frame::XModel >& xCurrentModel )
throw (uno::RuntimeException)
{
OSL_ASSERT( m_apUndoStack.get() && m_apRedoStack.get());
- impl_undoRedo( xCurrentModel, m_apUndoStack.get(), m_apRedoStack.get());
+ impl_undoRedo( xCurrentModel, m_apUndoStack.get(), m_apRedoStack.get(), true );
}
void SAL_CALL UndoManager::redo( Reference< frame::XModel >& xCurrentModel )
throw (uno::RuntimeException)
{
OSL_ASSERT( m_apUndoStack.get() && m_apRedoStack.get());
- impl_undoRedo( xCurrentModel, m_apRedoStack.get(), m_apUndoStack.get());
+ impl_undoRedo( xCurrentModel, m_apRedoStack.get(), m_apUndoStack.get(), false );
}
::sal_Bool SAL_CALL UndoManager::undoPossible()
@@ -349,4 +393,44 @@ void SAL_CALL UndoManager::applyModelContent(
impl::UndoElement::applyModelContentToModel( xModelToChange, xModelToCopyFrom );
}
+// ____ XUnoTunnel ____
+sal_Int64 UndoManager::getSomething( const Sequence< sal_Int8 >& rId )
+ throw (uno::RuntimeException)
+{
+ if ( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ) );
+ }
+ return 0;
+}
+
+// static
+const Sequence< sal_Int8 >& UndoManager::getUnoTunnelId()
+{
+ static Sequence< sal_Int8 >* pSeq = 0;
+ if( !pSeq )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if( !pSeq )
+ {
+ static Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+// static
+UndoManager* UndoManager::getImplementation( const Reference< uno::XInterface > xObj )
+{
+ UndoManager* pRet = NULL;
+ Reference< lang::XUnoTunnel > xUT( xObj, uno::UNO_QUERY );
+ if ( xUT.is() )
+ {
+ pRet = reinterpret_cast< UndoManager* >( sal::static_int_cast< sal_IntPtr >( xUT->getSomething( getUnoTunnelId() ) ) );
+ }
+ return pRet;
+}
+
} // namespace chart
diff --git a/chart2/source/controller/main/_serviceregistration_controller.cxx b/chart2/source/controller/main/_serviceregistration_controller.cxx
index 904c642c8a20..cf8f5525e624 100644
--- a/chart2/source/controller/main/_serviceregistration_controller.cxx
+++ b/chart2/source/controller/main/_serviceregistration_controller.cxx
@@ -34,6 +34,7 @@
#include "ChartDocumentWrapper.hxx"
#include "AccessibleChartView.hxx"
#include "ElementSelector.hxx"
+#include "ShapeToolbarController.hxx"
#include <cppuhelper/implementationentry.hxx>
static struct ::cppu::ImplementationEntry g_entries_chart2_controller[] =
@@ -79,17 +80,17 @@ static struct ::cppu::ImplementationEntry g_entries_chart2_controller[] =
, 0
}
,{
- ::chart::AccessibleChartView::create
- , ::chart::AccessibleChartView::getImplementationName_Static
- , ::chart::AccessibleChartView::getSupportedServiceNames_Static
+ ::chart::ElementSelectorToolbarController::create
+ , ::chart::ElementSelectorToolbarController::getImplementationName_Static
+ , ::chart::ElementSelectorToolbarController::getSupportedServiceNames_Static
, ::cppu::createSingleComponentFactory
, 0
, 0
}
,{
- ::chart::ElementSelectorToolbarController::create
- , ::chart::ElementSelectorToolbarController::getImplementationName_Static
- , ::chart::ElementSelectorToolbarController::getSupportedServiceNames_Static
+ ::chart::ShapeToolbarController::create
+ , ::chart::ShapeToolbarController::getImplementationName_Static
+ , ::chart::ShapeToolbarController::getSupportedServiceNames_Static
, ::cppu::createSingleComponentFactory
, 0
, 0
diff --git a/chart2/source/controller/main/makefile.mk b/chart2/source/controller/main/makefile.mk
index 8fe7cc8f783d..729276d5bd0e 100644
--- a/chart2/source/controller/main/makefile.mk
+++ b/chart2/source/controller/main/makefile.mk
@@ -67,7 +67,14 @@ SLOFILES = \
$(SLO)$/_serviceregistration_controller.obj \
$(SLO)$/ChartDropTargetHelper.obj \
$(SLO)$/StatusBarCommandDispatch.obj \
- $(SLO)$/ChartTransferable.obj
+ $(SLO)$/ChartTransferable.obj \
+ $(SLO)$/FeatureCommandDispatchBase.obj \
+ $(SLO)$/DrawCommandDispatch.obj \
+ $(SLO)$/ShapeController.obj \
+ $(SLO)$/ShapeToolbarController.obj \
+ $(SLO)$/ImplUndoManager.obj \
+ $(SLO)$/UndoManager.obj \
+ $(SLO)$/UndoGuard.obj
# $(SLO)$/CommonConverters.obj \
# $(SLO)$/Scaling.obj \
diff --git a/chart2/source/controller/makefile.mk b/chart2/source/controller/makefile.mk
index b5a5975a2d03..b8a256181045 100644
--- a/chart2/source/controller/makefile.mk
+++ b/chart2/source/controller/makefile.mk
@@ -100,7 +100,7 @@ SHL1STDLIBS= $(CHARTTOOLS) \
#specifies the exported symbols for Windows only:
SHL1DEF= $(MISC)$/$(SHL1TARGET).def
-SHL1VERSIONMAP = controller.map
+SHL1VERSIONMAP = $(SOLARENV)/src/component.map
#--------definition file
@@ -112,6 +112,7 @@ DEF1NAME= $(SHL1TARGET)
# sfx.srs is needed for the strings for UNDO and REDO in the UndoCommandDispatch
RESLIB1LIST=\
$(SRS)$/chcdialogs.srs \
+ $(SRS)$/chcmenus.srs \
$(SOLARCOMMONRESDIR)$/sfx.srs
RESLIB1NAME= $(TARGET)
diff --git a/chart2/source/controller/menus/ShapeContextMenu.src b/chart2/source/controller/menus/ShapeContextMenu.src
new file mode 100644
index 000000000000..79e424707807
--- /dev/null
+++ b/chart2/source/controller/menus/ShapeContextMenu.src
@@ -0,0 +1,124 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+#include "MenuResIds.hrc"
+#include "ShapeController.hrc"
+
+
+Menu RID_CONTEXTMENU_SHAPE
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = COMMAND_ID_FORMAT_LINE;
+ Command = ".uno:FormatLine";
+ };
+ MenuItem
+ {
+ Identifier = COMMAND_ID_FORMAT_AREA;
+ Command = ".uno:FormatArea";
+ };
+ MenuItem
+ {
+ Identifier = COMMAND_ID_TEXT_ATTRIBUTES;
+ Command = ".uno:TextAttributes";
+ };
+ MenuItem
+ {
+ Identifier = COMMAND_ID_TRANSFORM_DIALOG;
+ Command = ".uno:TransformDialog";
+ };
+ MenuItem
+ {
+ Separator = TRUE;
+ };
+ MenuItem
+ {
+ Identifier = COMMAND_ID_OBJECT_TITLE_DESCRIPTION;
+ Command = ".uno:ObjectTitleDescription";
+ };
+ MenuItem
+ {
+ Identifier = COMMAND_ID_RENAME_OBJECT;
+ Command = ".uno:RenameObject";
+ };
+ MenuItem
+ {
+ Separator = TRUE;
+ };
+ MenuItem
+ {
+ Identifier = COMMAND_ID_ARRANGE_ROW;
+ Command = ".uno:ArrangeRow";
+ SubMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = COMMAND_ID_BRING_TO_FRONT;
+ Command = ".uno:BringToFront";
+ };
+ MenuItem
+ {
+ Identifier = COMMAND_ID_FORWARD;
+ Command = ".uno:Forward";
+ };
+ MenuItem
+ {
+ Identifier = COMMAND_ID_BACKWARD;
+ Command = ".uno:Backward";
+ };
+ MenuItem
+ {
+ Identifier = COMMAND_ID_SEND_TO_BACK;
+ Command = ".uno:SendToBack";
+ };
+ };
+ };
+ };
+ MenuItem
+ {
+ Separator = TRUE;
+ };
+ MenuItem
+ {
+ Identifier = COMMAND_ID_CUT;
+ Command = ".uno:Cut";
+ };
+ MenuItem
+ {
+ Identifier = COMMAND_ID_COPY;
+ Command = ".uno:Copy";
+ };
+ MenuItem
+ {
+ Identifier = COMMAND_ID_PASTE;
+ Command = ".uno:Paste";
+ };
+ };
+};
diff --git a/chart2/source/controller/menus/ShapeEditContextMenu.src b/chart2/source/controller/menus/ShapeEditContextMenu.src
new file mode 100644
index 000000000000..60f5d4eab5af
--- /dev/null
+++ b/chart2/source/controller/menus/ShapeEditContextMenu.src
@@ -0,0 +1,65 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+#include "MenuResIds.hrc"
+#include "ShapeController.hrc"
+
+
+Menu RID_CONTEXTMENU_SHAPEEDIT
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = COMMAND_ID_FONT_DIALOG;
+ Command = ".uno:FontDialog";
+ };
+ MenuItem
+ {
+ Identifier = COMMAND_ID_PARAGRAPH_DIALOG;
+ Command = ".uno:ParagraphDialog";
+ };
+ MenuItem
+ {
+ Separator = TRUE;
+ };
+ MenuItem
+ {
+ Identifier = COMMAND_ID_CUT;
+ Command = ".uno:Cut";
+ };
+ MenuItem
+ {
+ Identifier = COMMAND_ID_COPY;
+ Command = ".uno:Copy";
+ };
+ MenuItem
+ {
+ Identifier = COMMAND_ID_PASTE;
+ Command = ".uno:Paste";
+ };
+ };
+};
diff --git a/chart2/source/controller/menus/makefile.mk b/chart2/source/controller/menus/makefile.mk
new file mode 100644
index 000000000000..f97548963e38
--- /dev/null
+++ b/chart2/source/controller/menus/makefile.mk
@@ -0,0 +1,63 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ= ..$/..$/..
+PRJINC= $(PRJ)$/source
+PRJNAME= chart2
+TARGET= chcmenus
+
+ENABLE_EXCEPTIONS= TRUE
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE: settings.mk
+
+# i26518 the gcc-3.0.4 requires to enhance the template-depth
+# this seems to be a compiler issue, so we recommend not to use 3.0.x anymore
+.IF "$(COM)"=="GCC"
+ CFLAGS+=-ftemplate-depth-128
+.ENDIF
+
+# --- Resources ---------------------------------------------------------------
+
+SRC1FILES= \
+ ShapeContextMenu.src \
+ ShapeEditContextMenu.src
+
+SRS1NAME=$(TARGET)
+
+# --- Targets -----------------------------------------------------------------
+
+.INCLUDE: target.mk
+
+#dependencies:
+
+$(SRS)$/chcmenus.srs: \
+ ..$/inc$/MenuResIds.hrc
+
+#$(SRS)$/$(TARGET).srs: $(SOLARINCDIR)$/svx$/globlmn.hrc
diff --git a/chart2/source/inc/AxisHelper.hxx b/chart2/source/inc/AxisHelper.hxx
index be2a60bb63f7..75e69436a784 100644
--- a/chart2/source/inc/AxisHelper.hxx
+++ b/chart2/source/inc/AxisHelper.hxx
@@ -101,6 +101,9 @@ public:
static void makeAxisInvisible( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis );
static void makeGridInvisible( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xGridProperties );
+ static void hideAxisIfNoDataIsAttached( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis
+ , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram);
+
SAL_DLLPRIVATE static sal_Bool areAxisLabelsVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xAxisProperties );
static sal_Bool isAxisVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis );
static sal_Bool isGridVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xGridProperties );
diff --git a/chart2/source/inc/ChartModelHelper.hxx b/chart2/source/inc/ChartModelHelper.hxx
index a5c5085ff626..fb087abf15fd 100644
--- a/chart2/source/inc/ChartModelHelper.hxx
+++ b/chart2/source/inc/ChartModelHelper.hxx
@@ -34,7 +34,6 @@
#include <com/sun/star/chart2/XUndoManager.hpp>
#include <com/sun/star/chart2/data/XDataProvider.hpp>
#include <com/sun/star/chart2/data/XRangeHighlighter.hpp>
-#include <com/sun/star/chart/XChartDataArray.hpp>
#include <com/sun/star/view/XSelectionSupplier.hpp>
#include <com/sun/star/awt/Size.hpp>
@@ -55,18 +54,11 @@ namespace chart
class OOO_DLLPUBLIC_CHARTTOOLS ChartModelHelper
{
public:
- static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XUndoManager > createUndoManager();
-
static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XRangeHighlighter > createRangeHighlighter(
const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionSupplier >& xSelectionSupplier );
- static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider > createInternalDataProvider();
-
- static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider > createInternalDataProvider(
- const ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartDataArray >& xDataToCopy );
-
static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider > createInternalDataProvider(
- const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDoc );
+ const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDoc, bool bConnectToModel );
static ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram >
@@ -76,6 +68,10 @@ public:
::com::sun::star::chart2::XDiagram >
findDiagram( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDoc );
+ static ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XCoordinateSystem >
+ getFirstCoordinateSystem( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel );
+
SAL_DLLPRIVATE static ::std::vector< ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDataSeries > > getDataSeries(
const ::com::sun::star::uno::Reference<
@@ -93,6 +89,8 @@ public:
, const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDataSeries >& xGivenDataSeries );
+ static ::com::sun::star::awt::Size getDefaultPageSize();
+
static ::com::sun::star::awt::Size getPageSize(
const ::com::sun::star::uno::Reference<
::com::sun::star::frame::XModel >& xModel );
diff --git a/chart2/source/inc/CloneHelper.hxx b/chart2/source/inc/CloneHelper.hxx
index c78abe32da59..6747bd614d84 100644
--- a/chart2/source/inc/CloneHelper.hxx
+++ b/chart2/source/inc/CloneHelper.hxx
@@ -29,6 +29,7 @@
#include <com/sun/star/util/XCloneable.hpp>
+#include <map>
#include <functional>
#include <algorithm>
diff --git a/chart2/source/inc/DataSourceHelper.hxx b/chart2/source/inc/DataSourceHelper.hxx
index efb69df7f2b5..06888fe858d6 100644
--- a/chart2/source/inc/DataSourceHelper.hxx
+++ b/chart2/source/inc/DataSourceHelper.hxx
@@ -111,14 +111,12 @@ public:
static ::com::sun::star::uno::Reference<
::com::sun::star::chart2::data::XDataSource > getUsedData(
const ::com::sun::star::uno::Reference<
- ::com::sun::star::frame::XModel >& xChartModel,
- bool bIncludeUnusedData = false );
+ ::com::sun::star::frame::XModel >& xChartModel );
static ::com::sun::star::uno::Reference<
::com::sun::star::chart2::data::XDataSource > getUsedData(
const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XChartDocument >& xChartDoc,
- bool bIncludeUnusedData = false );
+ ::com::sun::star::chart2::XChartDocument >& xChartDoc );
static bool detectRangeSegmentation(
const ::com::sun::star::uno::Reference<
@@ -127,8 +125,7 @@ public:
, ::com::sun::star::uno::Sequence< sal_Int32 >& rSequenceMapping
, bool& rOutUseColumns
, bool& rOutFirstCellAsLabel
- , bool& rOutHasCategories
- , bool bIncludeUnusedData = false );
+ , bool& rOutHasCategories );
static void setRangeSegmentation(
const ::com::sun::star::uno::Reference<
@@ -152,6 +149,10 @@ public:
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::data::XLabeledDataSequence > & xLSeq );
+ SAL_DLLPRIVATE static ::rtl::OUString getRangeFromValues(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::data::XLabeledDataSequence > & xLSeq );
+
SAL_DLLPRIVATE static ::com::sun::star::uno::Sequence< ::rtl::OUString > getRangesFromDataSource(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::data::XDataSource > & xSource );
diff --git a/chart2/source/inc/DiagramHelper.hxx b/chart2/source/inc/DiagramHelper.hxx
index fe412366606b..14113e7396ca 100644
--- a/chart2/source/inc/DiagramHelper.hxx
+++ b/chart2/source/inc/DiagramHelper.hxx
@@ -172,7 +172,8 @@ public:
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram >& xDiagram,
const ::com::sun::star::uno::Reference<
- ::com::sun::star::uno::XComponentContext > & xContext );
+ ::com::sun::star::uno::XComponentContext > & xContext,
+ bool bAdaptAxes=true );
static ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XAxis > getAttachedAxis(
@@ -223,19 +224,15 @@ public:
::com::sun::star::chart2::XDiagram > & xDiagram );
static ::com::sun::star::uno::Sequence< rtl::OUString >
- generateAutomaticCategories(
+ getExplicitSimpleCategories(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartDocument > & xChartDoc );
SAL_DLLPRIVATE static ::com::sun::star::uno::Sequence< rtl::OUString >
- generateAutomaticCategories(
+ generateAutomaticCategoriesFromCooSys(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XCoordinateSystem > & xCooSys );
- SAL_DLLPRIVATE static void generateAutomaticCategoriesFromChartType(
- ::com::sun::star::uno::Sequence< rtl::OUString >& rRet,
- const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& xChartType );
-
static ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartType >
getChartTypeByIndex( const ::com::sun::star::uno::Reference<
diff --git a/chart2/source/inc/ExplicitCategoriesProvider.hxx b/chart2/source/inc/ExplicitCategoriesProvider.hxx
index 8195ae0d92f2..18d54eb6e2ad 100644
--- a/chart2/source/inc/ExplicitCategoriesProvider.hxx
+++ b/chart2/source/inc/ExplicitCategoriesProvider.hxx
@@ -35,36 +35,71 @@
#include <com/sun/star/frame/XModel.hpp>
#include "charttoolsdllapi.hxx"
+#include <vector>
+
namespace chart
{
-class OOO_DLLPUBLIC_CHARTTOOLS ExplicitCategoriesProvider :
- public ::cppu::WeakImplHelper1<
- ::com::sun::star::chart2::data::XTextualDataSequence
- >
+struct OOO_DLLPUBLIC_CHARTTOOLS ComplexCategory
+{
+ rtl::OUString Text;
+ sal_Int32 Count;
+
+ ComplexCategory( const rtl::OUString& rText, sal_Int32 nCount ) : Text( rText ), Count (nCount)
+ {}
+};
+
+class OOO_DLLPUBLIC_CHARTTOOLS SplitCategoriesProvider
+{
+public:
+ virtual ~SplitCategoriesProvider();
+
+ virtual sal_Int32 getLevelCount() const = 0;
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > getStringsForLevel( sal_Int32 nIndex ) const = 0;
+};
+
+class OOO_DLLPUBLIC_CHARTTOOLS ExplicitCategoriesProvider
{
public:
ExplicitCategoriesProvider( const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XCoordinateSystem >& xCooSysModel );
- SAL_DLLPRIVATE virtual ~ExplicitCategoriesProvider();
+ ::com::sun::star::chart2::XCoordinateSystem >& xCooSysModel
+ , const ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XModel >& xChartModel
+ );
+ virtual ~ExplicitCategoriesProvider();
+
+ void init();
- //XTextualDataSequence
- SAL_DLLPRIVATE virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getTextualData()
- throw (::com::sun::star::uno::RuntimeException);
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > getSimpleCategories();
+ ::std::vector< ComplexCategory > getCategoriesByLevel( sal_Int32 nLevel );
static ::rtl::OUString getCategoryByIndex(
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XCoordinateSystem >& xCooSysModel,
- sal_Int32 nIndex );
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XCoordinateSystem >& xCooSysModel
+ , const ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XModel >& xChartModel
+ , sal_Int32 nIndex );
+
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getExplicitSimpleCategories(
+ const SplitCategoriesProvider& rSplitCategoriesProvider );
+
+ bool hasComplexCategories() const;
+ sal_Int32 getCategoryLevelCount() const;
+
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::data::XLabeledDataSequence> >& getSplitCategoriesList();
private: //member
- ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aExplicitCategories;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aExplicitCategories;
+ ::std::vector< ::std::vector< ComplexCategory > > m_aComplexCats;
bool volatile m_bDirty;
::com::sun::star::uno::WeakReference<
::com::sun::star::chart2::XCoordinateSystem > m_xCooSysModel;
::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XLabeledDataSequence> m_xCategories;
+ ::com::sun::star::chart2::data::XLabeledDataSequence> m_xOriginalCategories;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::data::XLabeledDataSequence> > m_aSplitCategoriesList;
};
} // namespace chart
diff --git a/chart2/source/inc/InternalData.hxx b/chart2/source/inc/InternalData.hxx
new file mode 100644
index 000000000000..6b6590cffdac
--- /dev/null
+++ b/chart2/source/inc/InternalData.hxx
@@ -0,0 +1,109 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef CHART2_INTERNALDATA_HXX
+#define CHART2_INTERNALDATA_HXX
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <vector>
+#include <valarray>
+
+namespace chart
+{
+
+class InternalData
+{
+public:
+ InternalData();
+
+ void createDefaultData();
+
+ void setData( const ::com::sun::star::uno::Sequence<
+ ::com::sun::star::uno::Sequence< double > > & rDataInRows );
+ ::com::sun::star::uno::Sequence<
+ ::com::sun::star::uno::Sequence< double > > getData() const;
+
+ ::com::sun::star::uno::Sequence< double > getColumnValues( sal_Int32 nColumnIndex ) const;
+ ::com::sun::star::uno::Sequence< double > getRowValues( sal_Int32 nRowIndex ) const;
+
+ void setColumnValues( sal_Int32 nColumnIndex, const ::std::vector< double > & rNewData );
+ void setRowValues( sal_Int32 nRowIndex, const ::std::vector< double > & rNewData );
+
+ void setComplexColumnLabel( sal_Int32 nColumnIndex, const ::std::vector< ::rtl::OUString >& rComplexLabel );
+ void setComplexRowLabel( sal_Int32 nRowIndex, const ::std::vector< ::rtl::OUString >& rComplexLabel );
+
+ ::std::vector< ::rtl::OUString > getComplexColumnLabel( sal_Int32 nColumnIndex ) const;
+ ::std::vector< ::rtl::OUString > getComplexRowLabel( sal_Int32 nRowIndex ) const;
+
+ void swapRowWithNext( sal_Int32 nRowIndex );
+ void swapColumnWithNext( sal_Int32 nColumnIndex );
+
+ void insertColumn( sal_Int32 nAfterIndex );
+ void insertRow( sal_Int32 nAfterIndex );
+ void deleteColumn( sal_Int32 nAtIndex );
+ void deleteRow( sal_Int32 nAtIndex );
+
+ /// @return the index of the newly appended column
+ sal_Int32 appendColumn();
+ /// @return the index of the newly appended row
+ sal_Int32 appendRow();
+
+ sal_Int32 getRowCount() const;
+ sal_Int32 getColumnCount() const;
+
+ typedef ::std::valarray< double > tDataType;
+ typedef ::std::vector< ::std::vector< ::rtl::OUString > > tVecVecString; //inner index is hierarchical level
+
+ void setComplexRowLabels( const tVecVecString& rNewRowLabels );
+ tVecVecString getComplexRowLabels() const;
+ void setComplexColumnLabels( const tVecVecString& rNewColumnLabels );
+ tVecVecString getComplexColumnLabels() const;
+
+#if OSL_DEBUG_LEVEL > 2
+ void traceData() const;
+#endif
+
+private: //methods
+ /** resizes the data if at least one of the given dimensions is larger than
+ before. The data is never becoming smaller only larger.
+
+ @return </TRUE>, if the data was enlarged
+ */
+ bool enlargeData( sal_Int32 nColumnCount, sal_Int32 nRowCount );
+
+private:
+ sal_Int32 m_nColumnCount;
+ sal_Int32 m_nRowCount;
+
+ tDataType m_aData;
+ tVecVecString m_aRowLabels;//outer index is row index, inner index is category level
+ tVecVecString m_aColumnLabels;//outer index is column index
+};
+
+#endif
+
+} // namespace chart
diff --git a/chart2/source/inc/InternalDataProvider.hxx b/chart2/source/inc/InternalDataProvider.hxx
index 9100b32d5859..f5e12f87f505 100644
--- a/chart2/source/inc/InternalDataProvider.hxx
+++ b/chart2/source/inc/InternalDataProvider.hxx
@@ -27,8 +27,10 @@
#ifndef CHART2_INTERNALDATAPROVIDER_HXX
#define CHART2_INTERNALDATAPROVIDER_HXX
+#include "InternalData.hxx"
+
#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/chart/XChartDataArray.hpp>
+#include <com/sun/star/chart/XComplexDescriptionAccess.hpp>
#include <com/sun/star/chart2/data/XDataProvider.hpp>
#include <com/sun/star/chart2/XInternalDataProvider.hpp>
#include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
@@ -49,12 +51,11 @@ namespace chart
namespace impl
{
-class InternalData;
typedef ::cppu::WeakImplHelper6<
::com::sun::star::chart2::XInternalDataProvider,
::com::sun::star::chart2::data::XRangeXMLConversion,
- ::com::sun::star::chart::XChartDataArray,
+ ::com::sun::star::chart::XComplexDescriptionAccess,
::com::sun::star::util::XCloneable,
::com::sun::star::lang::XInitialization,
::com::sun::star::lang::XServiceInfo >
@@ -75,16 +76,9 @@ class InternalDataProvider :
public impl::InternalDataProvider_Base
{
public:
- explicit InternalDataProvider();
explicit InternalDataProvider(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & _xContext);
- /// sets the internal data to the given data
- explicit InternalDataProvider(
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart::XChartDataArray > & xDataToCopy );
- /// copies the data from the given data provider for all given used ranges
explicit InternalDataProvider( const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XChartDocument > & xChartDoc );
- // copy-CTOR
+ ::com::sun::star::chart2::XChartDocument > & xChartDoc, bool bConnectToModel );
explicit InternalDataProvider( const InternalDataProvider & rOther );
virtual ~InternalDataProvider();
@@ -110,6 +104,10 @@ public:
throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL appendSequence()
throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL insertComplexCategoryLevel( ::sal_Int32 nLevel )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL deleteComplexCategoryLevel( ::sal_Int32 nLevel )
+ throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL insertDataPointForAllSequences( ::sal_Int32 nAfterIndex )
throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL deleteDataPointForAllSequences( ::sal_Int32 nAtIndex )
@@ -151,7 +149,21 @@ public:
throw (::com::sun::star::lang::IllegalArgumentException,
::com::sun::star::uno::RuntimeException);
- // ____ XChartDataArray ____
+ // ____ XComplexDescriptionAccess ____
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL
+ getComplexRowDescriptions() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setComplexRowDescriptions(
+ const ::com::sun::star::uno::Sequence<
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > >& aRowDescriptions )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL
+ getComplexColumnDescriptions() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setComplexColumnDescriptions(
+ const ::com::sun::star::uno::Sequence<
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > >& aColumnDescriptions )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ XChartDataArray (base of XComplexDescriptionAccess) ____
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > > SAL_CALL getData()
throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setData(
@@ -189,29 +201,27 @@ public:
throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::uno::Exception);
private:
- impl::InternalData & getInternalData();
- const impl::InternalData & getInternalData() const;
-
- void addDataSequenceToMap(
+ void lcl_addDataSequenceToMap(
const ::rtl::OUString & rRangeRepresentation,
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::data::XDataSequence > & xSequence );
+
::com::sun::star::uno::Reference<
::com::sun::star::chart2::data::XDataSequence >
- createDataSequenceAndAddToMap( const ::rtl::OUString & rRangeRepresentation,
+ lcl_createDataSequenceAndAddToMap( const ::rtl::OUString & rRangeRepresentation,
const ::rtl::OUString & rRole );
::com::sun::star::uno::Reference<
::com::sun::star::chart2::data::XDataSequence >
- createDataSequenceAndAddToMap( const ::rtl::OUString & rRangeRepresentation );
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XDataSequence >
- createErrorBarDataSequenceAndAddToMap( const ::rtl::OUString & rRangeRepresentation );
- void deleteMapReferences( const ::rtl::OUString & rRangeRepresentation );
- void adaptMapReferences(
+ lcl_createDataSequenceAndAddToMap( const ::rtl::OUString & rRangeRepresentation );
+
+ void lcl_deleteMapReferences( const ::rtl::OUString & rRangeRepresentation );
+
+ void lcl_adaptMapReferences(
const ::rtl::OUString & rOldRangeRepresentation,
const ::rtl::OUString & rNewRangeRepresentation );
- void increaseMapReferences( sal_Int32 nBegin, sal_Int32 nEnd );
- void decreaseMapReferences( sal_Int32 nBegin, sal_Int32 nEnd );
+
+ void lcl_increaseMapReferences( sal_Int32 nBegin, sal_Int32 nEnd );
+ void lcl_decreaseMapReferences( sal_Int32 nBegin, sal_Int32 nEnd );
typedef ::std::multimap< ::rtl::OUString,
::com::sun::star::uno::WeakReference< ::com::sun::star::chart2::data::XDataSequence > >
@@ -225,14 +235,9 @@ private:
referred to by some component (weak reference is valid), the range will
be adapted.
*/
- mutable tSequenceMap m_aSequenceMap;
- mutable ::std::auto_ptr< impl::InternalData > m_apData;
+ tSequenceMap m_aSequenceMap;
+ InternalData m_aInternalData;
bool m_bDataInColumns;
-
-// typedef ::std::map< ::rtl::OUString,
-// ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence > >
-// tHardRefSequenceMap;
-// tHardRefSequenceMap m_aErrorBarSequences;
};
} // namespace chart
diff --git a/chart2/source/inc/ObjectIdentifier.hxx b/chart2/source/inc/ObjectIdentifier.hxx
index c122f4b872d8..0765c9acf94a 100644
--- a/chart2/source/inc/ObjectIdentifier.hxx
+++ b/chart2/source/inc/ObjectIdentifier.hxx
@@ -40,6 +40,7 @@
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/drawing/XShape.hpp>
//.............................................................................
namespace chart
@@ -76,6 +77,7 @@ enum ObjectType
OBJECTTYPE_DATA_STOCK_RANGE,
OBJECTTYPE_DATA_STOCK_LOSS,
OBJECTTYPE_DATA_STOCK_GAIN,
+ OBJECTTYPE_SHAPE,
OBJECTTYPE_UNKNOWN
};
@@ -99,6 +101,18 @@ class OOO_DLLPUBLIC_CHARTTOOLS ObjectIdentifier
//where Type: getStringForType( ObjectType eType ) or other string
public:
+ ObjectIdentifier();
+ ObjectIdentifier( const ::rtl::OUString& rObjectCID );
+ ObjectIdentifier( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape );
+ ObjectIdentifier( const ::com::sun::star::uno::Any& rAny );
+ virtual ~ObjectIdentifier();
+
+ ObjectIdentifier( const ObjectIdentifier& rOID );
+ ObjectIdentifier& operator=( const ObjectIdentifier& rOID );
+ bool operator==( const ObjectIdentifier& rOID ) const;
+ bool operator!=( const ObjectIdentifier& rOID ) const;
+ bool operator<( const ObjectIdentifier& rOID ) const;
+
static rtl::OUString createClassifiedIdentifierForObject(
const ::com::sun::star::uno::Reference<
::com::sun::star::uno::XInterface >& xObject
@@ -169,6 +183,7 @@ public:
static rtl::OUString getDragMethodServiceName( const rtl::OUString& rClassifiedIdentifier );
static rtl::OUString getDragParameterString( const rtl::OUString& rCID );
static bool isDragableObject( const rtl::OUString& rClassifiedIdentifier );
+ bool isDragableObject();
static bool isRotateableObject( const rtl::OUString& rClassifiedIdentifier );
static bool isMultiClickObject( const rtl::OUString& rClassifiedIdentifier );
static bool areSiblings( const rtl::OUString& rCID1, const rtl::OUString& rCID2 );//identical object is no sibling
@@ -176,6 +191,7 @@ public:
static rtl::OUString getStringForType( ObjectType eObjectType );
static ObjectType getObjectType( const rtl::OUString& rCID );
+ ObjectType getObjectType();
static rtl::OUString createSeriesSubObjectStub( ObjectType eSubObjectType
, const rtl::OUString& rSeriesParticle
@@ -238,6 +254,22 @@ public:
static TitleHelper::eTitleType getTitleTypeForCID( const ::rtl::OUString& rCID );
static ::rtl::OUString getMovedSeriesCID( const ::rtl::OUString& rObjectCID, sal_Bool bForward );
+
+ bool isValid() const;
+ bool isAutoGeneratedObject() const;
+ bool isAdditionalShape() const;
+ ::rtl::OUString getObjectCID() const;
+ ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > getAdditionalShape() const;
+ ::com::sun::star::uno::Any getAny() const;
+
+private:
+ // #i12587# support for shapes in chart
+ // For autogenerated chart objects a CID is specified in m_aObjectCID,
+ // for all other objects m_xAdditionalShape is set.
+ // Note, that if m_aObjectCID is set, m_xAdditionalShape must be empty
+ // and vice versa.
+ ::rtl::OUString m_aObjectCID;
+ ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > m_xAdditionalShape;
};
//.............................................................................
diff --git a/chart2/source/inc/Strings.hrc b/chart2/source/inc/Strings.hrc
index 870f1b9fd6c4..47ed75e80a9a 100644
--- a/chart2/source/inc/Strings.hrc
+++ b/chart2/source/inc/Strings.hrc
@@ -30,7 +30,7 @@
// this includes no link dependency
#include <svl/solar.hrc>
-//next free is 290
+//next free is 291
//single free is: 134
//#define RID_APP_START 30000
@@ -264,6 +264,8 @@
#define STR_OBJECT_CURVE_EQUATION (RID_APP_START + 268)
#define STR_STATISTICS_IN_LEGEND (RID_APP_START + 180)
+#define STR_OBJECT_SHAPE (RID_APP_START + 290)
+
//-----------------------------------------------------------------------------
//Titles for tabpages and dialogs
diff --git a/chart2/source/inc/UndoGuard.hxx b/chart2/source/inc/UndoGuard.hxx
index 247f2d3f559f..864d5ccff994 100644
--- a/chart2/source/inc/UndoGuard.hxx
+++ b/chart2/source/inc/UndoGuard.hxx
@@ -29,7 +29,6 @@
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/chart2/XUndoManager.hpp>
-#include "charttoolsdllapi.hxx"
// header for class OUString
#include <rtl/ustring.hxx>
@@ -48,7 +47,7 @@ public:
::com::sun::star::frame::XModel > & xModel );
virtual ~UndoGuard_Base();
-OOO_DLLPUBLIC_CHARTTOOLS void commitAction();
+ void commitAction();
protected:
::com::sun::star::uno::Reference<
@@ -64,7 +63,7 @@ protected:
cancelAction in the DTOR if no other method is called.
If commitAction is called the destructor does nothin anymore.
*/
-class OOO_DLLPUBLIC_CHARTTOOLS UndoGuard : public UndoGuard_Base
+class UndoGuard : public UndoGuard_Base
{
public:
explicit UndoGuard( const rtl::OUString& rUndoMessage
@@ -79,7 +78,7 @@ public:
cancelActionUndo in the DTOR if no other method is called.
If commitAction is called the destructor does nothin anymore.
*/
-class OOO_DLLPUBLIC_CHARTTOOLS UndoLiveUpdateGuard : public UndoGuard_Base
+class UndoLiveUpdateGuard : public UndoGuard_Base
{
public:
explicit UndoLiveUpdateGuard( const rtl::OUString& rUndoMessage
@@ -93,7 +92,7 @@ public:
/** Same as UndoLiveUpdateGuard but with additional storage of the chart's data.
Only use this if the data has internal data.
*/
-class OOO_DLLPUBLIC_CHARTTOOLS UndoLiveUpdateGuardWithData :
+class UndoLiveUpdateGuardWithData :
public UndoGuard_Base
{
public:
@@ -105,7 +104,7 @@ public:
virtual ~UndoLiveUpdateGuardWithData();
};
-class OOO_DLLPUBLIC_CHARTTOOLS UndoGuardWithSelection : public UndoGuard_Base
+class UndoGuardWithSelection : public UndoGuard_Base
{
public:
explicit UndoGuardWithSelection( const rtl::OUString& rUndoMessage
diff --git a/chart2/source/inc/UndoManager.hxx b/chart2/source/inc/UndoManager.hxx
index b5481715ad43..a28a0d78c470 100644
--- a/chart2/source/inc/UndoManager.hxx
+++ b/chart2/source/inc/UndoManager.hxx
@@ -36,8 +36,9 @@
#include <com/sun/star/util/XModifyListener.hpp>
#include <com/sun/star/chart2/XUndoManager.hpp>
#include <com/sun/star/chart2/XUndoHelper.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
-#include <cppuhelper/compbase3.hxx>
+#include <cppuhelper/compbase4.hxx>
#include <rtl/ustring.hxx>
// for pair
@@ -45,6 +46,8 @@
// for auto_ptr
#include <memory>
+class SdrUndoAction;
+
namespace com { namespace sun { namespace star {
namespace frame {
class XModel;
@@ -62,10 +65,11 @@ class UndoElement;
class UndoStack;
class ModifyBroadcaster;
-typedef ::cppu::WeakComponentImplHelper3<
+typedef ::cppu::WeakComponentImplHelper4<
::com::sun::star::util::XModifyBroadcaster,
::com::sun::star::chart2::XUndoManager,
- ::com::sun::star::chart2::XUndoHelper >
+ ::com::sun::star::chart2::XUndoHelper,
+ ::com::sun::star::lang::XUnoTunnel >
UndoManager_Base;
} // namespace impl
@@ -87,6 +91,15 @@ public:
explicit UndoManager();
virtual ~UndoManager();
+ void addShapeUndoAction( SdrUndoAction* pAction );
+
+ // ____ XUnoTunnel ____
+ virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
+ static UndoManager* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> xObj );
+
protected:
// ____ ConfigItemListener ____
virtual void notify( const ::rtl::OUString & rPropertyName );
@@ -145,7 +158,8 @@ private:
::com::sun::star::uno::Reference<
::com::sun::star::frame::XModel > & xCurrentModel,
impl::UndoStack * pStackToRemoveFrom,
- impl::UndoStack * pStackToAddTo );
+ impl::UndoStack * pStackToAddTo,
+ bool bUndo = true );
::std::auto_ptr< impl::UndoStack > m_apUndoStack;
::std::auto_ptr< impl::UndoStack > m_apRedoStack;
diff --git a/chart2/source/inc/chartview/DrawModelWrapper.hxx b/chart2/source/inc/chartview/DrawModelWrapper.hxx
index b2f4f412610e..5bcf67a8592b 100644
--- a/chart2/source/inc/chartview/DrawModelWrapper.hxx
+++ b/chart2/source/inc/chartview/DrawModelWrapper.hxx
@@ -95,8 +95,6 @@ public:
getUnoModel();
SdrModel& getSdrModel();
- SAL_DLLPRIVATE void updateTablesFromChartModel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel );
-
XColorTable* GetColorTable() const;
XDashList* GetDashList() const;
XLineEndList* GetLineEndList() const;
diff --git a/chart2/source/inc/servicenames.hxx b/chart2/source/inc/servicenames.hxx
index b6dbec2c76f0..d1af0edb3335 100644
--- a/chart2/source/inc/servicenames.hxx
+++ b/chart2/source/inc/servicenames.hxx
@@ -57,14 +57,13 @@ namespace chart
#define CHART_CHARTAPIWRAPPER_SERVICE_NAME ::rtl::OUString::createFromAscii("com.sun.star.chart2.ChartDocumentWrapper")
// accessibility
-#define CHART2_ACCESSIBLE_SERVICE_IMPLEMENTATION_NAME ::rtl::OUString::createFromAscii("com.sun.star.comp.chart2.AccessibleChartView")
-#define CHART2_ACCESSIBLE_SERVICE_NAME ::rtl::OUString::createFromAscii("com.sun.star.chart2.AccessibleChartView")
-
#define CHART_ACCESSIBLE_TEXT_IMPLEMENTATION_NAME ::rtl::OUString::createFromAscii("com.sun.star.comp.chart2.AccessibleTextComponent")
#define CHART_ACCESSIBLE_TEXT_SERVICE_NAME ::rtl::OUString::createFromAscii("com.sun.star.accessibility.AccessibleTextComponent")
#define CHART_RENDERER_SERVICE_IMPLEMENTATION_NAME ::rtl::OUString::createFromAscii("com.sun.star.comp.chart2.ChartRenderer")
+#define CHART_UNDOMANAGER_SERVICE_NAME ::rtl::OUString::createFromAscii( "com.sun.star.chart2.UndoManager" )
+
//.............................................................................
} //namespace chart
//.............................................................................
diff --git a/chart2/source/model/inc/Diagram.hxx b/chart2/source/model/inc/Diagram.hxx
index bf888775f337..fc672e29b24c 100644
--- a/chart2/source/model/inc/Diagram.hxx
+++ b/chart2/source/model/inc/Diagram.hxx
@@ -136,11 +136,6 @@ protected:
virtual void SAL_CALL setDefaultColorScheme(
const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XColorScheme >& xColorScheme )
throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setUnusedData(
- const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > >& aUnusedData )
- throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > > SAL_CALL getUnusedData()
- throw (::com::sun::star::uno::RuntimeException);
// ____ XCoordinateSystemContainer ____
@@ -237,11 +232,6 @@ private:
::com::sun::star::chart2::XColorScheme >
m_xColorScheme;
- ::com::sun::star::uno::Sequence<
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XLabeledDataSequence > >
- m_aUnusedData;
-
::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > m_xModifyEventForwarder;
};
diff --git a/chart2/source/model/main/Axis.cxx b/chart2/source/model/main/Axis.cxx
index 17d8fe9f3989..cab49e8d0149 100644
--- a/chart2/source/model/main/Axis.cxx
+++ b/chart2/source/model/main/Axis.cxx
@@ -207,7 +207,7 @@ void lcl_AddDefaultsToMap(
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_STACKED, false );
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_ARRANGE_ORDER, ::com::sun::star::chart::ChartAxisArrangeOrderType_AUTO );
- float fDefaultCharHeight = 8.0;
+ float fDefaultCharHeight = 10.0;
::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
diff --git a/chart2/source/model/main/ChartData.cxx b/chart2/source/model/main/ChartData.cxx
deleted file mode 100644
index 866d4c67e885..000000000000
--- a/chart2/source/model/main/ChartData.cxx
+++ /dev/null
@@ -1,104 +0,0 @@
-/*************************************************************************
- *
- * 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 "ChartData.hxx"
-#include "ChartModelHelper.hxx"
-
-#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/beans/NamedValue.hpp>
-
-using namespace ::com::sun::star;
-
-using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::Sequence;
-using ::rtl::OUString;
-
-namespace chart
-{
-
-ChartData::ChartData( const Reference< uno::XComponentContext > & xContext ) :
- m_xContext( xContext ),
- m_xDataProvider( 0 ),
- m_xInternalDataProvider( 0 )
-{}
-
-ChartData::~ChartData()
-{}
-
-void ChartData::setDataProvider(
- const Reference< chart2::data::XDataProvider > & xDataProvider ) throw()
-{
- m_xDataProvider.set( xDataProvider );
- m_xInternalDataProvider.clear();
-}
-
-Reference< chart2::data::XDataProvider > ChartData::getDataProvider() const throw()
-{
- return m_xDataProvider;
-}
-
-bool ChartData::createInternalData(
- bool bCloneOldData, const Reference< chart2::XChartDocument > & xChartDoc ) throw()
-{
- if( hasInternalData() )
- return false;
-
- if( bCloneOldData )
- m_xInternalDataProvider = ChartModelHelper::createInternalDataProvider( xChartDoc );
- else
- m_xInternalDataProvider = ChartModelHelper::createInternalDataProvider();
-
- m_xDataProvider.set( m_xInternalDataProvider );
- return true;
-}
-
-bool ChartData::hasInternalData() const
-{
- return (m_xDataProvider.is() && m_xInternalDataProvider.is());
-}
-
-bool ChartData::createDefaultData() throw()
-{
- if( hasInternalData() )
- {
- uno::Reference< lang::XInitialization > xIni(m_xInternalDataProvider,uno::UNO_QUERY);
- if ( xIni.is() )
- {
- uno::Sequence< uno::Any > aArgs(1);
- beans::NamedValue aParam(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CreateDefaultData")),uno::makeAny(sal_True));
- aArgs[0] <<= aParam;
- xIni->initialize(aArgs);
- return true;
- }
- }
- return false;
-}
-
-} // namespace chart
diff --git a/chart2/source/model/main/ChartData.hxx b/chart2/source/model/main/ChartData.hxx
deleted file mode 100644
index c2a528bc89d7..000000000000
--- a/chart2/source/model/main/ChartData.hxx
+++ /dev/null
@@ -1,102 +0,0 @@
-/*************************************************************************
- *
- * 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.
- *
- ************************************************************************/
-#ifndef CHART2_CHARTDATA_HXX
-#define CHART2_CHARTDATA_HXX
-
-#include <com/sun/star/uno/Reference.hxx>
-#include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
-#include <com/sun/star/chart2/XChartDocument.hpp>
-
-#include <memory>
-
-namespace com { namespace sun { namespace star {
- namespace uno {
- class XComponentContext;
- }
- namespace embed {
- class XStorage;
- class XEmbeddedObject;
- class XEmbeddedClient;
- }
- namespace chart2 {
- namespace data {
- class XDataProvider;
- }
- }
- namespace util {
- class XCloseBroadcaster;
- }
-}}}
-
-namespace chart
-{
-
-class ChartData
-{
-public:
- explicit ChartData(
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::uno::XComponentContext > & xContext );
- ~ChartData();
-
- void setDataProvider(
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XDataProvider > & xDataProvider ) throw();
-
- ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider >
- getDataProvider() const throw();
-
- /** @return </TRUE>, if a new internal data provider has been created
- */
- bool createInternalData(
- bool bCloneOldData,
- const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xChartDoc ) throw();
-
- bool hasInternalData() const;
-
- /** only works if currently an internal data provider is set
- */
- bool createDefaultData() throw();
-
-private:
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
- m_xContext;
-
- ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider >
- m_xDataProvider;
-
- /** is only valid if m_xDataProvider is set. If m_xDataProvider is set to an
- external data provider this reference must be set to 0
- */
- ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider >
- m_xInternalDataProvider;
-};
-
-} // namespace chart
-
-// CHART2_CHARTDATA_HXX
-#endif
diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx
index ae3f85a3be40..dc0931f41fc4 100644
--- a/chart2/source/model/main/ChartModel.cxx
+++ b/chart2/source/model/main/ChartModel.cxx
@@ -28,19 +28,22 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_chart2.hxx"
#include "ChartModel.hxx"
-#include "ImplChartModel.hxx"
#include "servicenames.hxx"
#include "MediaDescriptorHelper.hxx"
#include "macros.hxx"
-#include "InternalData.hxx"
#include "servicenames.hxx"
-#include "DataSourceHelper.hxx"
#include "NoWarningThisInCTOR.hxx"
+#include "DataSourceHelper.hxx"
#include "ChartModelHelper.hxx"
+#include "DiagramHelper.hxx"
#include "DisposeHelper.hxx"
#include "ControllerLockGuard.hxx"
#include "ObjectIdentifier.hxx"
-#include "ChartModelHelper.hxx"
+#include "PageBackground.hxx"
+#include "CloneHelper.hxx"
+#include "NameContainer.hxx"
+
+#include <com/sun/star/chart/ChartDataRowSource.hpp>
#include <comphelper/InlineContainer.hxx>
#include <comphelper/processfactory.hxx>
@@ -57,12 +60,16 @@
#include <com/sun/star/embed/XStorage.hpp>
#include <com/sun/star/embed/EmbedMapUnits.hpp>
#include <com/sun/star/embed/Aspects.hpp>
+#include <com/sun/star/awt/Gradient.hpp>
#include <com/sun/star/awt/XWindow.hpp>
#include <com/sun/star/awt/PosSize.hpp>
#include <com/sun/star/datatransfer/XTransferable.hpp>
+#include <com/sun/star/drawing/Hatch.hpp>
+#include <com/sun/star/drawing/LineDash.hpp>
+#include <com/sun/star/drawing/XShapes.hpp>
-#include <map>
-#include <algorithm>
+// header for class SvNumberFormatter
+#include <svl/zforlist.hxx>
using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::Reference;
@@ -72,6 +79,7 @@ using ::osl::MutexGuard;
using namespace ::com::sun::star;
using namespace ::apphelper;
+using namespace ::chart::CloneHelper;
namespace
{
@@ -98,13 +106,23 @@ ChartModel::ChartModel(uno::Reference<uno::XComponentContext > const & xContext)
, m_aControllers( m_aModelMutex )
, m_nControllerLockCount(0)
, m_xContext( xContext )
- // default visual area is 8 x 7 cm
- , m_aVisualAreaSize( 8000, 7000 )
+ , m_aVisualAreaSize( ChartModelHelper::getDefaultPageSize() )
+ , m_xDataProvider( 0 )
+ , m_xInternalDataProvider( 0 )
+ , m_xPageBackground( new PageBackground( m_xContext ) )
+ , m_xXMLNamespaceMap( createNameContainer( ::getCppuType( (const OUString*) 0 ),
+ C2U( "com.sun.star.xml.NamespaceMap" ), C2U( "com.sun.star.comp.chart.XMLNameSpaceMap" ) ), uno::UNO_QUERY)
{
OSL_TRACE( "ChartModel: CTOR called" );
+ osl_incrementInterlockedCount(&m_refCount);
+
+ ModifyListenerHelper::addListener( m_xPageBackground, this );
+ m_xChartTypeManager.set( xContext->getServiceManager()->createInstanceWithContext(
+ C2U( "com.sun.star.chart2.ChartTypeManager" ), m_xContext ), uno::UNO_QUERY );
+ m_xUndoManager = Reference< chart2::XUndoManager >(
+ this->createInstance( CHART_UNDOMANAGER_SERVICE_NAME ), uno::UNO_QUERY );
- // attention: passing this as reference to ImplChartModel
- m_pImplChartModel.reset( new impl::ImplChartModel( xContext, this ));
+ osl_decrementInterlockedCount(&m_refCount);
}
ChartModel::ChartModel( const ChartModel & rOther )
@@ -125,14 +143,23 @@ ChartModel::ChartModel( const ChartModel & rOther )
, m_xStorage( 0 ) //rOther.m_xStorage )
, m_aVisualAreaSize( rOther.m_aVisualAreaSize )
, m_aGraphicObjectVector( rOther.m_aGraphicObjectVector )
+ , m_xDataProvider( rOther.m_xDataProvider )
+ , m_xInternalDataProvider( rOther.m_xInternalDataProvider )
+ , m_xUndoManager( rOther.m_xUndoManager )
{
OSL_TRACE( "ChartModel: Copy-CTOR called" );
+ osl_incrementInterlockedCount(&m_refCount);
- // attention: passing this as reference to ImplChartModel
- if( rOther.m_pImplChartModel.get())
- m_pImplChartModel.reset( new impl::ImplChartModel( * rOther.m_pImplChartModel.get(), this ));
- else
- m_pImplChartModel.reset( new impl::ImplChartModel( m_xContext, this ));
+ m_xChartTypeManager.set( CreateRefClone< Reference< chart2::XChartTypeManager > >()( rOther.m_xChartTypeManager ));
+ m_xTitle.set( CreateRefClone< Reference< chart2::XTitle > >()( rOther.m_xTitle ));
+ ModifyListenerHelper::addListener( m_xTitle, this );
+ m_xPageBackground.set( CreateRefClone< Reference< beans::XPropertySet > >()( rOther.m_xPageBackground ));
+ ModifyListenerHelper::addListener( m_xPageBackground, this );
+
+ m_xXMLNamespaceMap.set( CreateRefClone< Reference< container::XNameAccess > >()( rOther.m_xXMLNamespaceMap ));
+
+ CloneRefVector< Reference< chart2::XDiagram > >( rOther.m_aDiagrams, m_aDiagrams );
+ osl_decrementInterlockedCount(&m_refCount);
}
ChartModel::~ChartModel()
@@ -147,8 +174,7 @@ ChartModel::~ChartModel()
// private methods
//-----------------------------------------------------------------
- ::rtl::OUString ChartModel
-::impl_g_getLocation()
+::rtl::OUString ChartModel::impl_g_getLocation()
{
LifeTimeGuard aGuard(m_aLifeTimeManager);
@@ -158,8 +184,7 @@ ChartModel::~ChartModel()
return m_aResource;
}
- sal_Bool ChartModel
-::impl_isControllerConnected( const uno::Reference< frame::XController >& xController )
+sal_Bool ChartModel::impl_isControllerConnected( const uno::Reference< frame::XController >& xController )
{
try
{
@@ -176,8 +201,7 @@ ChartModel::~ChartModel()
return sal_False;
}
- uno::Reference< frame::XController > ChartModel
-::impl_getCurrentController() throw(uno::RuntimeException)
+uno::Reference< frame::XController > ChartModel::impl_getCurrentController() throw(uno::RuntimeException)
{
//@todo? hold only weak references to controllers
@@ -196,8 +220,7 @@ ChartModel::~ChartModel()
return uno::Reference< frame::XController > ();
}
- void SAL_CALL ChartModel
-::impl_notifyCloseListeners()
+void SAL_CALL ChartModel::impl_notifyCloseListeners()
throw( uno::RuntimeException)
{
::cppu::OInterfaceContainerHelper* pIC = m_aLifeTimeManager.m_aListenerContainer
@@ -211,14 +234,50 @@ ChartModel::~ChartModel()
}
}
+void ChartModel::impl_adjustAdditionalShapesPositionAndSize( const awt::Size& aVisualAreaSize )
+{
+ uno::Reference< beans::XPropertySet > xProperties( static_cast< ::cppu::OWeakObject* >( this ), uno::UNO_QUERY );
+ if ( xProperties.is() )
+ {
+ uno::Reference< drawing::XShapes > xShapes;
+ xProperties->getPropertyValue( C2U( "AdditionalShapes" ) ) >>= xShapes;
+ if ( xShapes.is() )
+ {
+ sal_Int32 nCount = xShapes->getCount();
+ for ( sal_Int32 i = 0; i < nCount; ++i )
+ {
+ Reference< drawing::XShape > xShape;
+ if ( xShapes->getByIndex( i ) >>= xShape )
+ {
+ if ( xShape.is() )
+ {
+ awt::Point aPos( xShape->getPosition() );
+ awt::Size aSize( xShape->getSize() );
+
+ double fWidth = static_cast< double >( aVisualAreaSize.Width ) / m_aVisualAreaSize.Width;
+ double fHeight = static_cast< double >( aVisualAreaSize.Height ) / m_aVisualAreaSize.Height;
+
+ aPos.X = static_cast< long >( aPos.X * fWidth );
+ aPos.Y = static_cast< long >( aPos.Y * fHeight );
+ aSize.Width = static_cast< long >( aSize.Width * fWidth );
+ aSize.Height = static_cast< long >( aSize.Height * fHeight );
+
+ xShape->setPosition( aPos );
+ xShape->setSize( aSize );
+ }
+ }
+ }
+ }
+ }
+}
+
//-----------------------------------------------------------------
// lang::XServiceInfo
//-----------------------------------------------------------------
APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
- uno::Sequence< rtl::OUString > ChartModel
-::getSupportedServiceNames_Static()
+uno::Sequence< rtl::OUString > ChartModel::getSupportedServiceNames_Static()
{
uno::Sequence< rtl::OUString > aSNS( 3 );
aSNS[0] = CHART_MODEL_SERVICE_NAME;
@@ -232,8 +291,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
// frame::XModel (required interface)
//-----------------------------------------------------------------
- sal_Bool SAL_CALL ChartModel
-::attachResource( const ::rtl::OUString& rURL
+sal_Bool SAL_CALL ChartModel::attachResource( const ::rtl::OUString& rURL
, const uno::Sequence< beans::PropertyValue >& rMediaDescriptor )
throw(uno::RuntimeException)
{
@@ -259,14 +317,12 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
return sal_True;
}
- ::rtl::OUString SAL_CALL ChartModel
-::getURL() throw(uno::RuntimeException)
+::rtl::OUString SAL_CALL ChartModel::getURL() throw(uno::RuntimeException)
{
return impl_g_getLocation();
}
- uno::Sequence< beans::PropertyValue > SAL_CALL ChartModel
-::getArgs() throw(uno::RuntimeException)
+uno::Sequence< beans::PropertyValue > SAL_CALL ChartModel::getArgs() throw(uno::RuntimeException)
{
/*
The method getArgs() returns a sequence of property values
@@ -282,8 +338,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
return m_aMediaDescriptor;
}
- void SAL_CALL ChartModel
-::connectController( const uno::Reference< frame::XController >& xController )
+void SAL_CALL ChartModel::connectController( const uno::Reference< frame::XController >& xController )
throw(uno::RuntimeException)
{
//@todo? this method is declared as oneway -> ...?
@@ -297,8 +352,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
m_aControllers.addInterface(xController);
}
- void SAL_CALL ChartModel
-::disconnectController( const uno::Reference< frame::XController >& xController )
+void SAL_CALL ChartModel::disconnectController( const uno::Reference< frame::XController >& xController )
throw(uno::RuntimeException)
{
//@todo? this method is declared as oneway -> ...?
@@ -317,8 +371,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
DisposeHelper::DisposeAndClear( m_xRangeHighlighter );
}
- void SAL_CALL ChartModel
-::lockControllers() throw(uno::RuntimeException)
+void SAL_CALL ChartModel::lockControllers() throw(uno::RuntimeException)
{
/*
suspends some notifications to the controllers which are used for display updates.
@@ -336,8 +389,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
++m_nControllerLockCount;
}
- void SAL_CALL ChartModel
-::unlockControllers() throw(uno::RuntimeException)
+void SAL_CALL ChartModel::unlockControllers() throw(uno::RuntimeException)
{
/*
resumes the notifications which were suspended by lockControllers() .
@@ -365,8 +417,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
}
}
- sal_Bool SAL_CALL ChartModel
-::hasControllersLocked() throw(uno::RuntimeException)
+sal_Bool SAL_CALL ChartModel::hasControllersLocked() throw(uno::RuntimeException)
{
LifeTimeGuard aGuard(m_aLifeTimeManager);
if(!aGuard.startApiCall())
@@ -374,8 +425,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
return ( m_nControllerLockCount != 0 ) ;
}
- uno::Reference< frame::XController > SAL_CALL ChartModel
-::getCurrentController() throw(uno::RuntimeException)
+uno::Reference< frame::XController > SAL_CALL ChartModel::getCurrentController() throw(uno::RuntimeException)
{
LifeTimeGuard aGuard(m_aLifeTimeManager);
if(!aGuard.startApiCall())
@@ -386,8 +436,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
return impl_getCurrentController();
}
- void SAL_CALL ChartModel
-::setCurrentController( const uno::Reference< frame::XController >& xController )
+void SAL_CALL ChartModel::setCurrentController( const uno::Reference< frame::XController >& xController )
throw(container::NoSuchElementException, uno::RuntimeException)
{
LifeTimeGuard aGuard(m_aLifeTimeManager);
@@ -407,8 +456,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
DisposeHelper::DisposeAndClear( m_xRangeHighlighter );
}
- uno::Reference< uno::XInterface > SAL_CALL ChartModel
-::getCurrentSelection() throw(uno::RuntimeException)
+uno::Reference< uno::XInterface > SAL_CALL ChartModel::getCurrentSelection() throw(uno::RuntimeException)
{
LifeTimeGuard aGuard(m_aLifeTimeManager);
if(!aGuard.startApiCall())
@@ -441,8 +489,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
//-----------------------------------------------------------------
// lang::XComponent (base of XModel)
//-----------------------------------------------------------------
- void SAL_CALL ChartModel
-::dispose() throw(uno::RuntimeException)
+void SAL_CALL ChartModel::dispose() throw(uno::RuntimeException)
{
//This object should release all resources and references in the
//easiest possible manner
@@ -455,8 +502,17 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
//--release all resources and references
//// @todo
- if( m_pImplChartModel.get())
- m_pImplChartModel->dispose();
+
+ m_xDataProvider.clear();
+ m_xInternalDataProvider.clear();
+ m_xNumberFormatsSupplier.clear();
+ DisposeHelper::DisposeAndClear( m_xOwnNumberFormatsSupplier );
+ DisposeHelper::DisposeAndClear( m_xChartTypeManager );
+ DisposeHelper::DisposeAllElements( m_aDiagrams );
+ m_aDiagrams.clear();
+ DisposeHelper::DisposeAndClear( m_xTitle );
+ DisposeHelper::DisposeAndClear( m_xPageBackground );
+ DisposeHelper::DisposeAndClear( m_xXMLNamespaceMap );
// not owner of storage
// if( m_xStorage.is())
@@ -482,8 +538,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
OSL_TRACE( "ChartModel: dispose() called" );
}
- void SAL_CALL ChartModel
-::addEventListener( const uno::Reference< lang::XEventListener > & xListener )
+void SAL_CALL ChartModel::addEventListener( const uno::Reference< lang::XEventListener > & xListener )
throw(uno::RuntimeException)
{
if( m_aLifeTimeManager.impl_isDisposedOrClosed() )
@@ -492,8 +547,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
m_aLifeTimeManager.m_aListenerContainer.addInterface( ::getCppuType((const uno::Reference< lang::XEventListener >*)0), xListener );
}
- void SAL_CALL ChartModel
-::removeEventListener( const uno::Reference< lang::XEventListener > & xListener )
+void SAL_CALL ChartModel::removeEventListener( const uno::Reference< lang::XEventListener > & xListener )
throw(uno::RuntimeException)
{
if( m_aLifeTimeManager.impl_isDisposedOrClosed() )
@@ -506,15 +560,13 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
//-----------------------------------------------------------------
// util::XCloseBroadcaster (base of XCloseable)
//-----------------------------------------------------------------
- void SAL_CALL ChartModel
-::addCloseListener( const uno::Reference< util::XCloseListener > & xListener )
+void SAL_CALL ChartModel::addCloseListener( const uno::Reference< util::XCloseListener > & xListener )
throw(uno::RuntimeException)
{
m_aLifeTimeManager.g_addCloseListener( xListener );
}
- void SAL_CALL ChartModel
-::removeCloseListener( const uno::Reference< util::XCloseListener > & xListener )
+void SAL_CALL ChartModel::removeCloseListener( const uno::Reference< util::XCloseListener > & xListener )
throw(uno::RuntimeException)
{
if( m_aLifeTimeManager.impl_isDisposedOrClosed() )
@@ -527,8 +579,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
//-----------------------------------------------------------------
// util::XCloseable
//-----------------------------------------------------------------
- void SAL_CALL ChartModel
-::close( sal_Bool bDeliverOwnership )
+void SAL_CALL ChartModel::close( sal_Bool bDeliverOwnership )
throw( util::CloseVetoException,
uno::RuntimeException )
{
@@ -585,8 +636,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
//-----------------------------------------------------------------
// lang::XTypeProvider
//-----------------------------------------------------------------
- uno::Sequence< uno::Type > SAL_CALL ChartModel
-::getTypes()
+uno::Sequence< uno::Type > SAL_CALL ChartModel::getTypes()
throw (uno::RuntimeException)
{
uno::Reference< lang::XTypeProvider > xAggTypeProvider;
@@ -627,82 +677,121 @@ uno::Reference< document::XDocumentProperties > SAL_CALL
// chart2::XChartDocument
//-----------------------------------------------------------------
- uno::Reference< chart2::XDiagram > SAL_CALL ChartModel
-::getFirstDiagram()
+uno::Reference< chart2::XDiagram > SAL_CALL ChartModel::getFirstDiagram()
throw (uno::RuntimeException)
{
- OSL_ASSERT( m_pImplChartModel.get() != 0 );
// /--
MutexGuard aGuard( m_aModelMutex );
- try
- {
- return m_pImplChartModel->GetDiagram( 0 );
- }
- catch( container::NoSuchElementException )
- {
- }
-
+ if( m_aDiagrams.size() )
+ return m_aDiagrams[ 0 ];
return uno::Reference< chart2::XDiagram >();
// \--
}
- void SAL_CALL ChartModel
-::setFirstDiagram( const uno::Reference< chart2::XDiagram >& xDiagram )
+void ChartModel::impl_removeAllDiagrams()
+{
+ ModifyListenerHelper::removeListenerFromAllElements( m_aDiagrams, this );
+ m_aDiagrams.clear();
+}
+
+void ChartModel::impl_appendDiagram( const Reference< chart2::XDiagram > & xDiagram )
+{
+ Reference< util::XModifyBroadcaster > xBroadcaster( xDiagram, uno::UNO_QUERY );
+ ModifyListenerHelper::addListener( xDiagram, this );
+ m_aDiagrams.push_back( xDiagram );
+}
+
+
+void SAL_CALL ChartModel::setFirstDiagram( const uno::Reference< chart2::XDiagram >& xDiagram )
throw (uno::RuntimeException)
{
- OSL_ASSERT( m_pImplChartModel.get() != 0 );
{
// /--
MutexGuard aGuard( m_aModelMutex );
- m_pImplChartModel->RemoveAllDiagrams();
- m_pImplChartModel->AppendDiagram( xDiagram );
+ impl_removeAllDiagrams();
+ impl_appendDiagram( xDiagram );
// \--
}
setModified( sal_True );
}
- void SAL_CALL ChartModel
-::createInternalDataProvider( sal_Bool bCloneExistingData )
- throw (util::CloseVetoException,
- uno::RuntimeException)
+Reference< chart2::data::XDataSource > ChartModel::impl_createDefaultData()
+{
+ Reference< chart2::data::XDataSource > xDataSource;
+ if( hasInternalDataProvider() )
+ {
+ uno::Reference< lang::XInitialization > xIni(m_xInternalDataProvider,uno::UNO_QUERY);
+ if( xIni.is() )
+ {
+ //init internal dataprovider
+ {
+ uno::Sequence< uno::Any > aArgs(1);
+ beans::NamedValue aParam(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CreateDefaultData")),uno::makeAny(sal_True));
+ aArgs[0] <<= aParam;
+ xIni->initialize(aArgs);
+ }
+ //create data
+ uno::Sequence< beans::PropertyValue > aArgs( 4 );
+ aArgs[0] = beans::PropertyValue(
+ ::rtl::OUString::createFromAscii("CellRangeRepresentation"), -1,
+ uno::makeAny( C2U("all") ), beans::PropertyState_DIRECT_VALUE );
+ aArgs[1] = beans::PropertyValue(
+ ::rtl::OUString::createFromAscii("HasCategories"), -1,
+ uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE );
+ aArgs[2] = beans::PropertyValue(
+ ::rtl::OUString::createFromAscii("FirstCellAsLabel"), -1,
+ uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE );
+ aArgs[3] = beans::PropertyValue(
+ ::rtl::OUString::createFromAscii("DataRowSource"), -1,
+ uno::makeAny( ::com::sun::star::chart::ChartDataRowSource_COLUMNS ), beans::PropertyState_DIRECT_VALUE );
+ xDataSource = m_xInternalDataProvider->createDataSource( aArgs );
+ }
+ }
+ return xDataSource;
+}
+
+void SAL_CALL ChartModel::createInternalDataProvider( sal_Bool bCloneExistingData )
+ throw (util::CloseVetoException, uno::RuntimeException)
{
- OSL_ASSERT( m_pImplChartModel.get() != 0 );
// don't lock the mutex, because this call calls out to code that tries to
// lock the solar mutex. On the other hand, a paint locks the solar mutex
// and calls to the model lock the model's mutex => deadlock
// @todo: lock a separate mutex in the InternalData class
- m_pImplChartModel->CreateInternalDataProvider( bCloneExistingData, this );
+ if( !hasInternalDataProvider() )
+ {
+ if( bCloneExistingData )
+ m_xInternalDataProvider = ChartModelHelper::createInternalDataProvider( this, true );
+ else
+ m_xInternalDataProvider = ChartModelHelper::createInternalDataProvider( Reference<XChartDocument>(), true );
+ m_xDataProvider.set( m_xInternalDataProvider );
+ }
setModified( sal_True );
}
sal_Bool SAL_CALL ChartModel::hasInternalDataProvider()
throw (uno::RuntimeException)
{
- return m_pImplChartModel->HasInternalDataProvider();
+ return m_xDataProvider.is() && m_xInternalDataProvider.is();
}
- uno::Reference< chart2::data::XDataProvider > SAL_CALL ChartModel
-::getDataProvider()
+uno::Reference< chart2::data::XDataProvider > SAL_CALL ChartModel::getDataProvider()
throw (uno::RuntimeException)
{
- OSL_ASSERT( m_pImplChartModel.get() != 0 );
// /--
MutexGuard aGuard( m_aModelMutex );
- return m_pImplChartModel->GetDataProvider();
+ return m_xDataProvider;
// \--
}
// ____ XDataReceiver ____
- void SAL_CALL ChartModel
-::attachDataProvider( const uno::Reference< chart2::data::XDataProvider >& xProvider )
+void SAL_CALL ChartModel::attachDataProvider( const uno::Reference< chart2::data::XDataProvider >& xDataProvider )
throw (uno::RuntimeException)
{
- OSL_ASSERT( m_pImplChartModel.get() != 0 );
{
// /--
MutexGuard aGuard( m_aModelMutex );
- uno::Reference< beans::XPropertySet > xProp( xProvider, uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySet > xProp( xDataProvider, uno::UNO_QUERY );
if( xProp.is() )
{
try
@@ -715,41 +804,95 @@ sal_Bool SAL_CALL ChartModel::hasInternalDataProvider()
}
}
- m_pImplChartModel->SetDataProvider( xProvider );
+ m_xDataProvider.set( xDataProvider );
+ m_xInternalDataProvider.clear();
+
+ //the numberformatter is kept independent of the data provider!
// \--
}
setModified( sal_True );
}
- void SAL_CALL ChartModel
-::attachNumberFormatsSupplier( const uno::Reference< util::XNumberFormatsSupplier >& xSupplier )
+void SAL_CALL ChartModel::attachNumberFormatsSupplier( const uno::Reference< util::XNumberFormatsSupplier >& xNewSupplier )
throw (uno::RuntimeException)
{
- OSL_ASSERT( m_pImplChartModel.get() != 0 );
{
// /--
MutexGuard aGuard( m_aModelMutex );
- m_pImplChartModel->SetNumberFormatsSupplier( xSupplier );
+ if( xNewSupplier==m_xNumberFormatsSupplier )
+ return;
+ if( xNewSupplier==m_xOwnNumberFormatsSupplier )
+ return;
+ if( m_xOwnNumberFormatsSupplier.is() && xNewSupplier.is() )
+ {
+ //@todo
+ //merge missing numberformats from own to new formatter
+ }
+ else if( !xNewSupplier.is() )
+ {
+ if( m_xNumberFormatsSupplier.is() )
+ {
+ //@todo
+ //merge missing numberformats from old numberformatter to own numberformatter
+ //create own numberformatter if necessary
+ }
+ }
+
+ m_xNumberFormatsSupplier.set( xNewSupplier );
+ m_xOwnNumberFormatsSupplier.clear();
// \--
}
setModified( sal_True );
}
- void SAL_CALL ChartModel
-::setArguments( const Sequence< beans::PropertyValue >& aArguments )
+void SAL_CALL ChartModel::setArguments( const Sequence< beans::PropertyValue >& aArguments )
throw (lang::IllegalArgumentException,
uno::RuntimeException)
{
- OSL_ASSERT( m_pImplChartModel.get() != 0 );
{
// /--
MutexGuard aGuard( m_aModelMutex );
+ if( !m_xDataProvider.is() )
+ return;
lockControllers();
+
try
{
- m_pImplChartModel->SetArguments( aArguments, true /* bSetData */ );
+ Reference< chart2::data::XDataSource > xDataSource( m_xDataProvider->createDataSource( aArguments ) );
+ if( xDataSource.is() )
+ {
+ // set new data
+ Reference< chart2::XChartTypeTemplate > xTemplate;
+ Reference< chart2::XDiagram > xDia( getFirstDiagram() );
+ if( xDia.is())
+ {
+ // apply new data
+ DiagramHelper::tTemplateWithServiceName aTemplateAndService =
+ DiagramHelper::getTemplateForDiagram(
+ xDia, Reference< lang::XMultiServiceFactory >( m_xChartTypeManager, uno::UNO_QUERY ));
+ xTemplate.set( aTemplateAndService.first );
+ }
+
+ if( !xTemplate.is())
+ xTemplate.set( impl_createDefaultChartTypeTemplate() );
+
+ if( xTemplate.is())
+ {
+ if( xDia.is())
+ xTemplate->changeDiagramData( xDia, xDataSource, aArguments );
+ else
+ {
+ impl_removeAllDiagrams();
+ impl_appendDiagram( xTemplate->createDiagramByDataSource( xDataSource, aArguments ));
+ }
+ }
+ }
}
- catch( const uno::Exception & ex )
+ catch( lang::IllegalArgumentException & )
+ {
+ throw;
+ }
+ catch( uno::Exception & ex )
{
ASSERT_EXCEPTION( ex );
}
@@ -759,22 +902,19 @@ sal_Bool SAL_CALL ChartModel::hasInternalDataProvider()
setModified( sal_True );
}
- Sequence< OUString > SAL_CALL ChartModel
-::getUsedRangeRepresentations()
+Sequence< OUString > SAL_CALL ChartModel::getUsedRangeRepresentations()
throw (uno::RuntimeException)
{
return DataSourceHelper::getUsedDataRanges( Reference< frame::XModel >(this));
}
- Reference< chart2::data::XDataSource > SAL_CALL ChartModel
-::getUsedData()
+Reference< chart2::data::XDataSource > SAL_CALL ChartModel::getUsedData()
throw (uno::RuntimeException)
{
return DataSourceHelper::getUsedData( Reference< chart2::XChartDocument >(this));
}
- Reference< chart2::data::XRangeHighlighter > SAL_CALL ChartModel
-::getRangeHighlighter()
+Reference< chart2::data::XRangeHighlighter > SAL_CALL ChartModel::getRangeHighlighter()
throw (uno::RuntimeException)
{
if( ! m_xRangeHighlighter.is())
@@ -786,40 +926,42 @@ sal_Bool SAL_CALL ChartModel::hasInternalDataProvider()
return m_xRangeHighlighter;
}
+Reference< chart2::XChartTypeTemplate > ChartModel::impl_createDefaultChartTypeTemplate()
+{
+ Reference< chart2::XChartTypeTemplate > xTemplate;
+ Reference< lang::XMultiServiceFactory > xFact( m_xChartTypeManager, uno::UNO_QUERY );
+ if( xFact.is() )
+ xTemplate.set( xFact->createInstance( C2U( "com.sun.star.chart2.template.Column" ) ), uno::UNO_QUERY );
+ return xTemplate;
+}
- void SAL_CALL ChartModel
-::setChartTypeManager( const uno::Reference< chart2::XChartTypeManager >& xNewManager )
+void SAL_CALL ChartModel::setChartTypeManager( const uno::Reference< chart2::XChartTypeManager >& xNewManager )
throw (uno::RuntimeException)
{
- OSL_ASSERT( m_pImplChartModel.get() != 0 );
{
// /--
MutexGuard aGuard( m_aModelMutex );
- m_pImplChartModel->SetChartTypeManager( xNewManager );
+ m_xChartTypeManager = xNewManager;
// \--
}
setModified( sal_True );
}
- uno::Reference< chart2::XChartTypeManager > SAL_CALL ChartModel
-::getChartTypeManager()
+uno::Reference< chart2::XChartTypeManager > SAL_CALL ChartModel::getChartTypeManager()
throw (uno::RuntimeException)
{
- OSL_ASSERT( m_pImplChartModel.get() != 0 );
// /--
MutexGuard aGuard( m_aModelMutex );
- return m_pImplChartModel->GetChartTypeManager();
+ return m_xChartTypeManager;
// \--
}
- uno::Reference< beans::XPropertySet > SAL_CALL ChartModel
-::getPageBackground()
+uno::Reference< beans::XPropertySet > SAL_CALL ChartModel::getPageBackground()
throw (uno::RuntimeException)
{
- OSL_ASSERT( m_pImplChartModel.get() != 0 );
// /--
MutexGuard aGuard( m_aModelMutex );
- return m_pImplChartModel->GetPageBackground();
+ return m_xPageBackground;
// \--
}
@@ -827,23 +969,22 @@ sal_Bool SAL_CALL ChartModel::hasInternalDataProvider()
uno::Reference< chart2::XTitle > SAL_CALL ChartModel::getTitleObject()
throw (uno::RuntimeException)
{
- OSL_ASSERT( m_pImplChartModel.get() != 0 );
// /--
MutexGuard aGuard( m_aModelMutex );
- return m_pImplChartModel->GetTitle();
+ return m_xTitle;
// \--
}
-void SAL_CALL ChartModel::setTitleObject(
- const uno::Reference<
- chart2::XTitle >& Title )
+void SAL_CALL ChartModel::setTitleObject( const uno::Reference< chart2::XTitle >& xTitle )
throw (uno::RuntimeException)
{
- OSL_ASSERT( m_pImplChartModel.get() != 0 );
{
// /--
MutexGuard aGuard( m_aModelMutex );
- m_pImplChartModel->SetTitle( Title );
+ if( m_xTitle.is() )
+ ModifyListenerHelper::removeListener( m_xTitle, this );
+ m_xTitle = xTitle;
+ ModifyListenerHelper::addListener( m_xTitle, this );
// \--
}
setModified( sal_True );
@@ -904,6 +1045,13 @@ void SAL_CALL ChartModel::setVisualAreaSize( ::sal_Int64 nAspect, const awt::Siz
bool bChanged =
(m_aVisualAreaSize.Width != aSize.Width ||
m_aVisualAreaSize.Height != aSize.Height);
+
+ // #i12587# support for shapes in chart
+ if ( bChanged )
+ {
+ impl_adjustAdditionalShapesPositionAndSize( aSize );
+ }
+
m_aVisualAreaSize = aSize;
if( bChanged )
setModified( sal_True );
@@ -1074,9 +1222,6 @@ tServiceNameMap & lcl_getStaticServiceNameMap()
Reference< uno::XInterface > SAL_CALL ChartModel::createInstance( const OUString& rServiceSpecifier )
throw( uno::Exception, uno::RuntimeException )
{
- if( ! m_pImplChartModel.get() )
- return 0;
-
uno::Reference< uno::XInterface > xResult;
tServiceNameMap & rMap = lcl_getStaticServiceNameMap();
@@ -1086,22 +1231,22 @@ Reference< uno::XInterface > SAL_CALL ChartModel::createInstance( const OUString
switch( (*aIt).second )
{
case SERVICE_DASH_TABLE:
- return m_pImplChartModel->GetDashTable();
case SERVICE_GARDIENT_TABLE:
- return m_pImplChartModel->GetGradientTable();
case SERVICE_HATCH_TABLE:
- return m_pImplChartModel->GetHatchTable();
case SERVICE_BITMAP_TABLE:
- return m_pImplChartModel->GetBitmapTable();
case SERVICE_TRANSP_GRADIENT_TABLE:
- return m_pImplChartModel->GetTransparencyGradientTable();
case SERVICE_MARKER_TABLE:
- // not supported
- return 0;
+ {
+ uno::Reference< lang::XMultiServiceFactory > xFact(
+ this->createInstance( CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY );
+ if ( xFact.is() )
+ {
+ return xFact->createInstance( rServiceSpecifier );
+ }
+ }
+ break;
case SERVICE_NAMESPACE_MAP:
- // not yet supported, @todo
-// return 0;
- return m_pImplChartModel->GetXMLNameSpaceMap();
+ return Reference< uno::XInterface >( m_xXMLNamespaceMap );
}
}
else
@@ -1147,6 +1292,21 @@ Sequence< OUString > SAL_CALL ChartModel::getAvailableServiceNames()
return aResult;
}
+Reference< util::XNumberFormatsSupplier > ChartModel::impl_getNumberFormatsSupplier()
+{
+ if( !m_xNumberFormatsSupplier.is() )
+ {
+ if( !m_xOwnNumberFormatsSupplier.is() )
+ {
+ Reference< lang::XMultiServiceFactory > xFactory( m_xContext->getServiceManager(), uno::UNO_QUERY );
+ m_xOwnNumberFormatsSupplier = new SvNumberFormatsSupplierObj( new SvNumberFormatter( xFactory, LANGUAGE_SYSTEM ) );
+ //pOwnNumberFormatter->ChangeStandardPrec( 15 ); todo?
+ }
+ m_xNumberFormatsSupplier = m_xOwnNumberFormatsSupplier;
+ }
+ return m_xNumberFormatsSupplier;
+}
+
// ____ XUnoTunnel ___
::sal_Int64 SAL_CALL ChartModel::getSomething( const Sequence< ::sal_Int8 >& aIdentifier )
throw( uno::RuntimeException)
@@ -1154,14 +1314,9 @@ Sequence< OUString > SAL_CALL ChartModel::getAvailableServiceNames()
if( aIdentifier.getLength() == 16 && 0 == rtl_compareMemory( SvNumberFormatsSupplierObj::getUnoTunnelId().getConstArray(),
aIdentifier.getConstArray(), 16 ) )
{
- OSL_ENSURE( m_pImplChartModel.get(), "need a model implementation to provide a numberformatter" );
- if( m_pImplChartModel.get() )
- {
- Reference< lang::XUnoTunnel > xTunnel( m_pImplChartModel->GetNumberFormatsSupplier(), uno::UNO_QUERY );
- if( xTunnel.is() )
- return xTunnel->getSomething( aIdentifier );
- }
- return 0;
+ Reference< lang::XUnoTunnel > xTunnel( impl_getNumberFormatsSupplier(), uno::UNO_QUERY );
+ if( xTunnel.is() )
+ return xTunnel->getSomething( aIdentifier );
}
return 0;
}
@@ -1170,26 +1325,18 @@ Sequence< OUString > SAL_CALL ChartModel::getAvailableServiceNames()
uno::Reference< beans::XPropertySet > SAL_CALL ChartModel::getNumberFormatSettings()
throw (uno::RuntimeException)
{
- OSL_ENSURE( m_pImplChartModel.get(), "need a model implementation to provide a numberformatter" );
- if( m_pImplChartModel.get() )
- {
- Reference< util::XNumberFormatsSupplier > xSupplier( m_pImplChartModel->GetNumberFormatsSupplier() );
- if( xSupplier.is() )
- return xSupplier->getNumberFormatSettings();
- }
+ Reference< util::XNumberFormatsSupplier > xSupplier( impl_getNumberFormatsSupplier() );
+ if( xSupplier.is() )
+ return xSupplier->getNumberFormatSettings();
return uno::Reference< beans::XPropertySet >();
}
uno::Reference< util::XNumberFormats > SAL_CALL ChartModel::getNumberFormats()
throw (uno::RuntimeException)
{
- OSL_ENSURE( m_pImplChartModel.get(), "need a model implementation to provide a numberformatter" );
- if( m_pImplChartModel.get() )
- {
- Reference< util::XNumberFormatsSupplier > xSupplier( m_pImplChartModel->GetNumberFormatsSupplier() );
- if( xSupplier.is() )
- return xSupplier->getNumberFormats();
- }
+ Reference< util::XNumberFormatsSupplier > xSupplier( impl_getNumberFormatsSupplier() );
+ if( xSupplier.is() )
+ return xSupplier->getNumberFormats();
return uno::Reference< util::XNumberFormats >();
}
@@ -1212,7 +1359,7 @@ void SAL_CALL ChartModel::setParent( const Reference< uno::XInterface >& Parent
Reference< chart2::XUndoManager > SAL_CALL ChartModel::getUndoManager()
throw (uno::RuntimeException)
{
- return m_pImplChartModel->GetUndoManager();
+ return m_xUndoManager;
}
// ____ XDataSource ____
diff --git a/chart2/source/model/main/ChartModel.hxx b/chart2/source/model/main/ChartModel.hxx
index 7ca8ce34e7c3..860f71f909ea 100644
--- a/chart2/source/model/main/ChartModel.hxx
+++ b/chart2/source/model/main/ChartModel.hxx
@@ -47,6 +47,8 @@
#include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/chart2/XUndoSupplier.hpp>
#include <com/sun/star/chart2/data/XDataSource.hpp>
+#include <com/sun/star/chart2/XChartTypeTemplate.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
// public API
#include <com/sun/star/chart2/data/XDataProvider.hpp>
@@ -81,7 +83,6 @@ namespace chart
namespace impl
{
- class ImplChartModel;
// Note: needed for queryInterface (if it calls the base-class implementation)
typedef ::comphelper::WeakImplHelper20<
@@ -136,8 +137,6 @@ private:
// ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > m_aPrinterOptions;
- ::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;
@@ -148,6 +147,40 @@ private:
::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XRangeHighlighter > m_xRangeHighlighter;
::std::vector< GraphicObject > m_aGraphicObjectVector;
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider > m_xDataProvider;
+ /** is only valid if m_xDataProvider is set. If m_xDataProvider is set to an
+ external data provider this reference must be set to 0
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider > m_xInternalDataProvider;
+
+ ::com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier >
+ m_xOwnNumberFormatsSupplier;
+ ::com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier >
+ m_xNumberFormatsSupplier;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartTypeManager >
+ m_xChartTypeManager;
+
+ // Diagram Access
+ typedef ::std::vector< ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDiagram > >
+ tDiagramContainer;
+
+ tDiagramContainer m_aDiagrams;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTitle >
+ m_xTitle;
+
+ bool m_bIsDisposed;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xPageBackground;
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XUndoManager >
+ m_xUndoManager;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xXMLNamespaceMap;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > m_xModifyListener;
+
private:
//private methods
@@ -192,6 +225,19 @@ private:
impl_createFilter( const ::com::sun::star::uno::Sequence<
::com::sun::star::beans::PropertyValue > & rMediaDescriptor );
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartTypeTemplate > impl_createDefaultChartTypeTemplate();
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource > impl_createDefaultData();
+
+ void impl_adjustAdditionalShapesPositionAndSize(
+ const ::com::sun::star::awt::Size& aVisualAreaSize );
+
+ void impl_removeAllDiagrams();
+ void impl_appendDiagram( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDiagram > & xDiagram );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >
+ impl_getNumberFormatsSupplier();
+
public:
//no default constructor
ChartModel(::com::sun::star::uno::Reference<
diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx b/chart2/source/model/main/ChartModel_Persistence.cxx
index 82f1cdc2054a..4f864ae0fd1c 100644
--- a/chart2/source/model/main/ChartModel_Persistence.cxx
+++ b/chart2/source/model/main/ChartModel_Persistence.cxx
@@ -29,28 +29,36 @@
#include "precompiled_chart2.hxx"
#include "ChartModel.hxx"
-#include "ImplChartModel.hxx"
#include "MediaDescriptorHelper.hxx"
#include "ChartDebugTrace.hxx"
#include "macros.hxx"
#include "ChartViewHelper.hxx"
#include "ChartModelHelper.hxx"
+#include "AxisHelper.hxx"
+#include "ThreeDHelper.hxx"
+
+#include <com/sun/star/chart2/LegendPosition.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/document/XExporter.hpp>
#include <com/sun/star/document/XImporter.hpp>
#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
+#include <com/sun/star/drawing/LineStyle.hpp>
+#include <com/sun/star/drawing/ProjectionMode.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/embed/XStorage.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/io/XSeekable.hpp>
+
#include <ucbhelper/content.hxx>
#ifndef _UNOTOOLS_UCBSTREAMHELPER_HXX
#include <unotools/ucbstreamhelper.hxx>
#endif
#include <vcl/cvtgrf.hxx>
#include <comphelper/storagehelper.hxx>
+#include <vcl/svapp.hxx>
#include <algorithm>
#include <functional>
@@ -404,7 +412,88 @@ void SAL_CALL ChartModel::initNew()
createInternalDataProvider( sal_False );
try
{
- m_pImplChartModel->CreateDefaultChart();
+ // create default chart
+ impl_removeAllDiagrams();
+
+ Reference< chart2::XChartTypeTemplate > xTemplate( impl_createDefaultChartTypeTemplate() );
+ if( xTemplate.is())
+ {
+ try
+ {
+ Reference< chart2::data::XDataSource > xDataSource( impl_createDefaultData() );
+ Sequence< beans::PropertyValue > aParam;
+
+ bool bSupportsCategories = xTemplate->supportsCategories();
+ if( bSupportsCategories )
+ {
+ aParam.realloc( 1 );
+ aParam[0] = beans::PropertyValue( C2U("HasCategories"), -1, uno::makeAny( true ),
+ beans::PropertyState_DIRECT_VALUE );
+ }
+
+ Reference< chart2::XDiagram > xDiagram( xTemplate->createDiagramByDataSource( xDataSource, aParam ) );
+
+ impl_appendDiagram( xDiagram );
+
+ bool bIsRTL = Application::GetSettings().GetLayoutRTL();
+ //reverse x axis for rtl charts
+ if( bIsRTL )
+ AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 ) );
+
+ // create and attach legend
+ Reference< chart2::XLegend > xLegend(
+ m_xContext->getServiceManager()->createInstanceWithContext(
+ C2U( "com.sun.star.chart2.Legend" ), m_xContext ), uno::UNO_QUERY_THROW );
+ Reference< beans::XPropertySet > xLegendProperties( xLegend, uno::UNO_QUERY );
+ if( xLegendProperties.is() )
+ {
+ xLegendProperties->setPropertyValue( C2U( "FillStyle" ), uno::makeAny( drawing::FillStyle_NONE ));
+ xLegendProperties->setPropertyValue( C2U( "LineStyle" ), uno::makeAny( drawing::LineStyle_NONE ));
+ xLegendProperties->setPropertyValue( C2U( "LineColor" ), uno::makeAny( static_cast< sal_Int32 >( 0xb3b3b3 ) )); // gray30
+ xLegendProperties->setPropertyValue( C2U( "FillColor" ), uno::makeAny( static_cast< sal_Int32 >( 0xe6e6e6 ) ) ); // gray10
+
+ if( bIsRTL )
+ xLegendProperties->setPropertyValue( C2U( "AnchorPosition" ), uno::makeAny( chart2::LegendPosition_LINE_START ));
+ }
+ if(xDiagram.is())
+ xDiagram->setLegend( xLegend );
+
+ // set simple 3D look
+ Reference< beans::XPropertySet > xDiagramProperties( xDiagram, uno::UNO_QUERY );
+ if( xDiagramProperties.is() )
+ {
+ xDiagramProperties->setPropertyValue( C2U("RightAngledAxes"), uno::makeAny( sal_True ));
+ xDiagramProperties->setPropertyValue( C2U("D3DScenePerspective"), uno::makeAny( drawing::ProjectionMode_PARALLEL ));
+ ThreeDHelper::setScheme( xDiagram, ThreeDLookScheme_Realistic );
+ }
+
+ //set some new 'defaults' for wall and floor
+ if( xDiagram.is() )
+ {
+ Reference< beans::XPropertySet > xWall( xDiagram->getWall() );
+ if( xWall.is() )
+ {
+ xWall->setPropertyValue( C2U( "LineStyle" ), uno::makeAny( drawing::LineStyle_SOLID ) );
+ xWall->setPropertyValue( C2U( "FillStyle" ), uno::makeAny( drawing::FillStyle_NONE ) );
+ xWall->setPropertyValue( C2U( "LineColor" ), uno::makeAny( static_cast< sal_Int32 >( 0xb3b3b3 ) ) ); // gray30
+ xWall->setPropertyValue( C2U( "FillColor" ), uno::makeAny( static_cast< sal_Int32 >( 0xe6e6e6 ) ) ); // gray10
+ }
+ Reference< beans::XPropertySet > xFloor( xDiagram->getFloor() );
+ if( xFloor.is() )
+ {
+ xFloor->setPropertyValue( C2U( "LineStyle" ), uno::makeAny( drawing::LineStyle_NONE ) );
+ xFloor->setPropertyValue( C2U( "FillStyle" ), uno::makeAny( drawing::FillStyle_SOLID ) );
+ xFloor->setPropertyValue( C2U( "LineColor" ), uno::makeAny( static_cast< sal_Int32 >( 0xb3b3b3 ) ) ); // gray30
+ xFloor->setPropertyValue( C2U( "FillColor" ), uno::makeAny( static_cast< sal_Int32 >( 0xcccccc ) ) ); // gray20
+ }
+
+ }
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+ }
ChartModelHelper::setIncludeHiddenCells( false, this );
}
catch( uno::Exception & ex )
diff --git a/chart2/source/model/main/DataSeries.cxx b/chart2/source/model/main/DataSeries.cxx
index 2ef6be657f8c..4faca33e936c 100644
--- a/chart2/source/model/main/DataSeries.cxx
+++ b/chart2/source/model/main/DataSeries.cxx
@@ -265,7 +265,7 @@ uno::Any DataSeries::GetDefaultValue( sal_Int32 nHandle ) const
DataSeriesProperties::AddDefaultsToMap( aStaticDefaults );
CharacterProperties::AddDefaultsToMap( aStaticDefaults );
- float fDefaultCharHeight = 6.0;
+ float fDefaultCharHeight = 10.0;
::chart::PropertyHelper::setPropertyValue( aStaticDefaults, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
::chart::PropertyHelper::setPropertyValue( aStaticDefaults, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
::chart::PropertyHelper::setPropertyValue( aStaticDefaults, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx
index d5436ddc02eb..f74764c398ef 100644
--- a/chart2/source/model/main/Diagram.cxx
+++ b/chart2/source/model/main/Diagram.cxx
@@ -369,18 +369,6 @@ void SAL_CALL Diagram::setDefaultColorScheme( const Reference< chart2::XColorSch
fireModifyEvent();
}
-void SAL_CALL Diagram::setUnusedData( const Sequence< Reference< chart2::data::XLabeledDataSequence > >& aUnusedData )
- throw (uno::RuntimeException)
-{
- m_aUnusedData = aUnusedData;
-}
-
-Sequence< Reference< chart2::data::XLabeledDataSequence > > SAL_CALL Diagram::getUnusedData()
- throw (uno::RuntimeException)
-{
- return m_aUnusedData;
-}
-
// ____ XTitled ____
uno::Reference< chart2::XTitle > SAL_CALL Diagram::getTitleObject()
throw (uno::RuntimeException)
diff --git a/chart2/source/model/main/ImplChartModel.cxx b/chart2/source/model/main/ImplChartModel.cxx
deleted file mode 100644
index 2e84d2b4508f..000000000000
--- a/chart2/source/model/main/ImplChartModel.cxx
+++ /dev/null
@@ -1,586 +0,0 @@
-/*************************************************************************
- *
- * 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 "ImplChartModel.hxx"
-#include "DataSeries.hxx"
-#include "macros.hxx"
-#include "PageBackground.hxx"
-#include "DiagramHelper.hxx"
-#include "NameContainer.hxx"
-#include "CloneHelper.hxx"
-#include "ModifyListenerHelper.hxx"
-#include "DataSourceHelper.hxx"
-#include "DisposeHelper.hxx"
-#include "ChartModelHelper.hxx"
-#include "ThreeDHelper.hxx"
-#include "AxisHelper.hxx"
-
-// header for class SvNumberFormatter
-#include <svl/zforlist.hxx>
-// header for class SvNumberFormatsSupplierObj
-#include <svl/numuno.hxx>
-#include <vcl/svapp.hxx>
-#include <cppuhelper/component_context.hxx>
-
-#include <com/sun/star/chart2/LegendPosition.hpp>
-#include <com/sun/star/chart2/XDataSeries.hpp>
-#include <com/sun/star/chart/ChartDataRowSource.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/embed/XStorage.hpp>
-#include <com/sun/star/embed/ElementModes.hpp>
-#include <com/sun/star/document/XFilter.hpp>
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-#include <com/sun/star/util/XModifyBroadcaster.hpp>
-#include <com/sun/star/drawing/FillStyle.hpp>
-#include <com/sun/star/drawing/Hatch.hpp>
-#include <com/sun/star/drawing/LineDash.hpp>
-#include <com/sun/star/drawing/LineStyle.hpp>
-#include <com/sun/star/awt/Gradient.hpp>
-#include <com/sun/star/drawing/ProjectionMode.hpp>
-
-#include <vector>
-#include <algorithm>
-#include <functional>
-
-using namespace ::com::sun::star;
-using namespace ::chart::CloneHelper;
-
-using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::Sequence;
-
-using ::rtl::OUString;
-
-namespace
-{
-
-struct lcl_removeListener : public ::std::unary_function< Reference< chart2::XDiagram >, void >
-{
- explicit lcl_removeListener( const Reference< util::XModifyListener > & xListener ) :
- m_xListener( xListener )
- {}
-
- void operator() ( const Reference< chart2::XDiagram > & xDia )
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( xDia, uno::UNO_QUERY );
- if( xBroadcaster.is() && m_xListener.is())
- xBroadcaster->removeModifyListener( m_xListener );
- }
-private:
- Reference< util::XModifyListener > m_xListener;
-};
-
-} // anonymous namespace
-
-namespace chart
-{
-namespace impl
-{
-
-ImplChartModel::ImplChartModel(
- Reference< uno::XComponentContext > const & xContext,
- const Reference< util::XModifyListener > & xListener ) :
- m_xContext( xContext ),
- m_spChartData( new ChartData( m_xContext )),
- m_bIsDisposed( false ),
- m_xPageBackground( new PageBackground( m_xContext )),
- m_xUndoManager( ChartModelHelper::createUndoManager() ),
- m_xDashTable( createNameContainer( ::getCppuType( reinterpret_cast< const drawing::LineDash * >(0)),
- C2U( "com.sun.star.drawing.DashTable" ), C2U( "com.sun.star.comp.chart.DashTable" ) )),
- m_xGradientTable( createNameContainer( ::getCppuType( reinterpret_cast< const awt::Gradient * >(0)),
- C2U( "com.sun.star.drawing.GradientTable" ), C2U( "com.sun.star.comp.chart.GradientTable" ) )),
- m_xHatchTable( createNameContainer( ::getCppuType( reinterpret_cast< const drawing::Hatch * >(0)),
- C2U( "com.sun.star.drawing.HatchTable" ), C2U( "com.sun.star.comp.chart.HatchTable" ) )),
- m_xBitmapTable( createNameContainer( ::getCppuType( reinterpret_cast< const OUString * >(0)), // URL
- C2U( "com.sun.star.drawing.BitmapTable" ), C2U( "com.sun.star.comp.chart.BitmapTable" ) )),
- m_xTransparencyGradientTable( createNameContainer( ::getCppuType( reinterpret_cast< const awt::Gradient * >(0)),
- C2U( "com.sun.star.drawing.TransparencyGradientTable" ), C2U( "com.sun.star.comp.chart.TransparencyGradientTable" ) )),
- m_xXMLNamespaceMap( createNameContainer( ::getCppuType( (const OUString*) 0 ),
- C2U( "com.sun.star.xml.NamespaceMap" ), C2U( "com.sun.star.comp.chart.XMLNameSpaceMap" ) ), uno::UNO_QUERY),
- m_xModifyListener( xListener )
-{
- ModifyListenerHelper::addListener( m_xPageBackground, m_xModifyListener );
- m_xChartTypeManager.set(
- xContext->getServiceManager()->createInstanceWithContext(
- C2U( "com.sun.star.chart2.ChartTypeManager" ),
- xContext ), uno::UNO_QUERY );
-
- GetStyleFamilies();
- CreateDefaultChartTypeTemplate();
-}
-
-ImplChartModel::ImplChartModel( const ImplChartModel & rOther, const Reference< util::XModifyListener > & xListener ) :
- m_xContext( rOther.m_xContext ),
- m_spChartData( rOther.m_spChartData ),
- m_bIsDisposed( rOther.m_bIsDisposed ),
- m_xModifyListener( xListener )
-{
- m_xFamilies.set( CreateRefClone< Reference< container::XNameAccess > >()( rOther.m_xFamilies ));
- m_xChartTypeManager.set( CreateRefClone< Reference< chart2::XChartTypeManager > >()( rOther.m_xChartTypeManager ));
- m_xChartTypeTemplate.set( CreateRefClone< Reference< chart2::XChartTypeTemplate > >()( rOther.m_xChartTypeTemplate ));
- m_xTitle.set( CreateRefClone< Reference< chart2::XTitle > >()( rOther.m_xTitle ));
- ModifyListenerHelper::addListener( m_xTitle, m_xModifyListener );
- m_xPageBackground.set( CreateRefClone< Reference< beans::XPropertySet > >()( rOther.m_xPageBackground ));
- ModifyListenerHelper::addListener( m_xPageBackground, m_xModifyListener );
-
- m_xDashTable.set( CreateRefClone< Reference< container::XNameContainer > >()( rOther.m_xDashTable ));
- m_xGradientTable.set( CreateRefClone< Reference< container::XNameContainer > >()( rOther.m_xGradientTable ));
- m_xHatchTable.set( CreateRefClone< Reference< container::XNameContainer > >()( rOther.m_xHatchTable ));
- m_xBitmapTable.set( CreateRefClone< Reference< container::XNameContainer > >()( rOther.m_xBitmapTable ));
- m_xTransparencyGradientTable.set( CreateRefClone< Reference< container::XNameContainer > >()( rOther.m_xTransparencyGradientTable ));
-
- m_xXMLNamespaceMap.set( CreateRefClone< Reference< container::XNameAccess > >()( rOther.m_xXMLNamespaceMap ));
-
- CloneRefVector< Reference< chart2::XDiagram > >( rOther.m_aDiagrams, m_aDiagrams );
-}
-
-ImplChartModel::~ImplChartModel()
-{}
-
-Reference< container::XNameAccess > ImplChartModel::GetStyleFamilies()
-{
- return m_xFamilies;
-}
-
-// Diagram Access
-
-void ImplChartModel::RemoveAllDiagrams()
-{
- ModifyListenerHelper::removeListenerFromAllElements( m_aDiagrams, m_xModifyListener );
- m_aDiagrams.clear();
-}
-
-void ImplChartModel::AppendDiagram( const Reference< chart2::XDiagram > & xDiagram )
-{
- Reference< util::XModifyBroadcaster > xBroadcaster( xDiagram, uno::UNO_QUERY );
- ModifyListenerHelper::addListener( xDiagram, m_xModifyListener );
- m_aDiagrams.push_back( xDiagram );
-}
-
-Reference< chart2::XDiagram > ImplChartModel::GetDiagram( size_t nIndex ) const
- throw( container::NoSuchElementException )
-{
- if( nIndex >= m_aDiagrams.size() )
- throw container::NoSuchElementException();
-
- return m_aDiagrams[ nIndex ];
-}
-
-void ImplChartModel::SetDataProvider(
- const Reference< chart2::data::XDataProvider > & xProvider )
-{
- OSL_ASSERT( m_spChartData.get() );
-
- m_spChartData->setDataProvider( xProvider );
-
- //the numberformatter is kept independent of the data provider!
-
- // release other ressources
-
- // @todo: maybe we need to save some properties of the old diagrams. When
- // the data provider changes from an outside Calc to an internal Calc,
- // e.g. when copying a chart into the clipboard as "standalone" format
-// if( bDeleteDiagrams && ! m_aDiagrams.empty())
-// m_aDiagrams.clear();
-}
-
-Reference< chart2::data::XDataProvider > ImplChartModel::GetDataProvider() const
-{
- OSL_ASSERT( m_spChartData.get() );
-
- return m_spChartData->getDataProvider();
-}
-
-void ImplChartModel::CreateInternalDataProvider(
- bool bCloneExistingData,
- const Reference< chart2::XChartDocument > & xChartDoc )
-{
- m_spChartData->createInternalData( bCloneExistingData, xChartDoc );
-}
-
-bool ImplChartModel::HasInternalDataProvider() const
-{
- OSL_ASSERT( m_spChartData.get() );
-
- return m_spChartData->hasInternalData();
-}
-
-Reference< chart2::data::XDataSource > SAL_CALL ImplChartModel::SetArguments(
- const Sequence< beans::PropertyValue > & aArguments,
- bool bSetData )
- throw (lang::IllegalArgumentException)
-{
- Reference< chart2::data::XDataSource > xResult;
- try
- {
- OSL_ASSERT( m_spChartData.get() );
-
- Reference< chart2::data::XDataProvider > xDataProvider(
- m_spChartData->getDataProvider());
- if( xDataProvider.is() )
- {
- xResult.set( xDataProvider->createDataSource( aArguments ));
-
- if( bSetData && xResult.is())
- SetNewData( xResult, aArguments );
- }
- }
- catch( lang::IllegalArgumentException & )
- {
- throw;
- }
- catch( uno::Exception & ex )
- {
- ASSERT_EXCEPTION( ex );
- }
-
- return xResult;
-}
-
-Reference< chart2::data::XDataSource > SAL_CALL ImplChartModel::SetRangeRepresentation(
- const OUString & rRangeRepresentation, bool bSetData )
- throw (::com::sun::star::lang::IllegalArgumentException)
-{
- uno::Sequence< beans::PropertyValue > aArgs( 4 );
- aArgs[0] = beans::PropertyValue(
- ::rtl::OUString::createFromAscii("CellRangeRepresentation"), -1,
- uno::makeAny( rRangeRepresentation ), beans::PropertyState_DIRECT_VALUE );
- aArgs[1] = beans::PropertyValue(
- ::rtl::OUString::createFromAscii("HasCategories"), -1,
- uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE );
- aArgs[2] = beans::PropertyValue(
- ::rtl::OUString::createFromAscii("FirstCellAsLabel"), -1,
- uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE );
- aArgs[3] = beans::PropertyValue(
- ::rtl::OUString::createFromAscii("DataRowSource"), -1,
- uno::makeAny( ::com::sun::star::chart::ChartDataRowSource_COLUMNS ), beans::PropertyState_DIRECT_VALUE );
- return SetArguments( aArgs, bSetData );
- /*
- uno::Sequence< beans::PropertyValue > aArgs();
-
- Reference< chart2::data::XDataProvider > xDataProvider( this->GetDataProvider() );
- if( xDataProvider.is() )
- aArgs = xDataProvider->detectArguments( DataSourceHelper::getUsedData( xChartModel ) ),
-
- ::rtl::OUString aRangeString;
- uno::Sequence< sal_Int32 > aSequenceMapping;
- bool bUseColumns = true;
- bool bFirstCellAsLabel = true;
- bool bHasCategories = true;
-
- DataSourceHelper::detectRangeSegmentation(
- uno::Reference< frame::XModel >( m_xChartDoc, uno::UNO_QUERY ),
- aRangeString, aSequenceMapping, bUseColumns, bFirstCellAsLabel, bHasCategories );
-
- aArgs = createArguments( rRangeRepresentation, aSequenceMapping, bUseColumns, bFirstCellAsLabel, bHasCategories ) );
-
- return SetArguments( aArgs, bSetData );
- */
-}
-
-void ImplChartModel::SetChartTypeManager(
- const Reference< chart2::XChartTypeManager > & xManager )
-{
- m_xChartTypeManager = xManager;
-}
-
-Reference< chart2::XChartTypeManager > ImplChartModel::GetChartTypeManager()
-{
- return m_xChartTypeManager;
-}
-
-Reference< chart2::XChartTypeTemplate > ImplChartModel::GetChartTypeTemplate()
-{
- return m_xChartTypeTemplate;
-}
-
-void ImplChartModel::CreateDefaultChart()
-{
- CreateDefaultChartTypeTemplate();
-
- // clean up
- RemoveAllDiagrams();
-
- Reference< chart2::XChartTypeTemplate > xTemplate( GetChartTypeTemplate());
- if( xTemplate.is())
- {
- try
- {
- Reference< chart2::data::XDataSource > xDataSource( CreateDefaultData());
- Sequence< beans::PropertyValue > aParam;
-
- Sequence< OUString > aParamNames( xTemplate->getAvailableCreationParameterNames());
- const OUString * pBeg = aParamNames.getConstArray();
- const OUString * pEnd = pBeg + aParamNames.getLength();
- const OUString * pFound( ::std::find( pBeg, pEnd, C2U("HasCategories")));
- if( pFound != pEnd )
- {
- aParam.realloc( 1 );
- aParam[0] = beans::PropertyValue( C2U("HasCategories"), -1, uno::makeAny( true ),
- beans::PropertyState_DIRECT_VALUE );
- }
-
- Reference< chart2::XDiagram > xDiagram( xTemplate->createDiagramByDataSource( xDataSource, aParam ) );
-
- AppendDiagram( xDiagram );
-
- bool bIsRTL = Application::GetSettings().GetLayoutRTL();
- //reverse x axis for rtl charts
- if( bIsRTL )
- AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 ) );
-
- // create and attach legend
- Reference< chart2::XLegend > xLegend(
- m_xContext->getServiceManager()->createInstanceWithContext(
- C2U( "com.sun.star.chart2.Legend" ), m_xContext ), uno::UNO_QUERY_THROW );
- Reference< beans::XPropertySet > xLegendProperties( xLegend, uno::UNO_QUERY );
- if( xLegendProperties.is() )
- {
- xLegendProperties->setPropertyValue( C2U( "FillStyle" ), uno::makeAny( drawing::FillStyle_NONE ));
- xLegendProperties->setPropertyValue( C2U( "LineStyle" ), uno::makeAny( drawing::LineStyle_NONE ));
- xLegendProperties->setPropertyValue( C2U( "LineColor" ), uno::makeAny( static_cast< sal_Int32 >( 0xb3b3b3 ) )); // gray30
- xLegendProperties->setPropertyValue( C2U( "FillColor" ), uno::makeAny( static_cast< sal_Int32 >( 0xe6e6e6 ) ) ); // gray10
-
- if( bIsRTL )
- xLegendProperties->setPropertyValue( C2U( "AnchorPosition" ), uno::makeAny( chart2::LegendPosition_LINE_START ));
- }
- if(xDiagram.is())
- xDiagram->setLegend( xLegend );
-
- // set simple 3D look
- Reference< beans::XPropertySet > xDiagramProperties( xDiagram, uno::UNO_QUERY );
- if( xDiagramProperties.is() )
- {
- xDiagramProperties->setPropertyValue( C2U("RightAngledAxes"), uno::makeAny( sal_True ));
- xDiagramProperties->setPropertyValue( C2U("D3DScenePerspective"), uno::makeAny( drawing::ProjectionMode_PARALLEL ));
- ThreeDHelper::setScheme( xDiagram, ThreeDLookScheme_Simple );
- }
-
- //set some new 'defaults' for wall and floor
- if( xDiagram.is() )
- {
- Reference< beans::XPropertySet > xWall( xDiagram->getWall() );
- if( xWall.is() )
- {
- xWall->setPropertyValue( C2U( "LineStyle" ), uno::makeAny( drawing::LineStyle_SOLID ) );
- xWall->setPropertyValue( C2U( "FillStyle" ), uno::makeAny( drawing::FillStyle_NONE ) );
- xWall->setPropertyValue( C2U( "LineColor" ), uno::makeAny( static_cast< sal_Int32 >( 0xb3b3b3 ) ) ); // gray30
- xWall->setPropertyValue( C2U( "FillColor" ), uno::makeAny( static_cast< sal_Int32 >( 0xe6e6e6 ) ) ); // gray10
- }
- Reference< beans::XPropertySet > xFloor( xDiagram->getFloor() );
- if( xFloor.is() )
- {
- xFloor->setPropertyValue( C2U( "LineStyle" ), uno::makeAny( drawing::LineStyle_NONE ) );
- xFloor->setPropertyValue( C2U( "FillStyle" ), uno::makeAny( drawing::FillStyle_SOLID ) );
- xFloor->setPropertyValue( C2U( "LineColor" ), uno::makeAny( static_cast< sal_Int32 >( 0xb3b3b3 ) ) ); // gray30
- xFloor->setPropertyValue( C2U( "FillColor" ), uno::makeAny( static_cast< sal_Int32 >( 0xcccccc ) ) ); // gray20
- }
-
- }
- }
- catch( uno::Exception & ex )
- {
- ASSERT_EXCEPTION( ex );
- }
- }
-}
-
-Reference< chart2::XTitle > ImplChartModel::GetTitle()
-{
- return m_xTitle;
-}
-
-void ImplChartModel::SetTitle( const Reference< chart2::XTitle >& rTitle )
-{
- if( m_xTitle.is())
- ModifyListenerHelper::removeListener( m_xTitle, m_xModifyListener );
- m_xTitle = rTitle;
- ModifyListenerHelper::addListener( m_xTitle, m_xModifyListener );
-}
-
-void ImplChartModel::dispose()
-{
- // exception is thrown by ChartModel
- if( m_bIsDisposed )
- return;
-
- m_spChartData.reset();
- m_xNumberFormatsSupplier.clear();
-
- DisposeHelper::DisposeAndClear( m_xFamilies );
- DisposeHelper::DisposeAndClear( m_xOwnNumberFormatsSupplier );
- DisposeHelper::DisposeAndClear( m_xChartTypeManager );
- DisposeHelper::DisposeAndClear( m_xChartTypeTemplate );
- DisposeHelper::DisposeAllElements( m_aDiagrams );
- m_aDiagrams.clear();
- DisposeHelper::DisposeAndClear( m_xTitle );
- DisposeHelper::DisposeAndClear( m_xPageBackground );
- DisposeHelper::DisposeAndClear( m_xDashTable );
- DisposeHelper::DisposeAndClear( m_xGradientTable );
- DisposeHelper::DisposeAndClear( m_xHatchTable );
- DisposeHelper::DisposeAndClear( m_xBitmapTable );
- DisposeHelper::DisposeAndClear( m_xTransparencyGradientTable );
-
- DisposeHelper::DisposeAndClear( m_xXMLNamespaceMap );
-
- // note: m_xModifyListener is the ChartModel, so don't call dispose()
- m_xModifyListener.clear();
-
- m_bIsDisposed = true;
-}
-
-Reference< beans::XPropertySet > ImplChartModel::GetPageBackground()
-{
- return m_xPageBackground;
-}
-
-Reference< chart2::XUndoManager > ImplChartModel::GetUndoManager()
-{
- return m_xUndoManager;
-}
-
-void ImplChartModel::SetNewData( const Reference< chart2::data::XDataSource > & xDataSource,
- const Sequence< beans::PropertyValue > & rArgs )
-{
- Reference< chart2::XDiagram > xDia;
- if( m_aDiagrams.size() > 0 )
- xDia.set( GetDiagram(0));
- Reference< chart2::XChartTypeTemplate > xTemplate;
-
- if( xDia.is())
- {
- // apply new data
- DiagramHelper::tTemplateWithServiceName aTemplateAndService =
- DiagramHelper::getTemplateForDiagram(
- xDia, Reference< lang::XMultiServiceFactory >( m_xChartTypeManager, uno::UNO_QUERY ));
- xTemplate.set( aTemplateAndService.first );
- }
-
- if( !xTemplate.is())
- xTemplate.set( GetChartTypeTemplate());
-
- if( xTemplate.is())
- {
- if( xDia.is())
- xTemplate->changeDiagramData( xDia, xDataSource, rArgs );
- else
- {
- RemoveAllDiagrams();
- AppendDiagram( xTemplate->createDiagramByDataSource( xDataSource, rArgs ));
- }
- }
-}
-
-Reference< chart2::data::XDataSource > ImplChartModel::CreateDefaultData()
-{
- Reference< chart2::data::XDataSource > xResult;
- if( m_spChartData->createDefaultData())
- xResult.set( SetRangeRepresentation( C2U("all"), false /* bSetData */ ));
- return xResult;
-}
-
-void ImplChartModel::CreateDefaultChartTypeTemplate()
-{
- // set default chart type
- Reference< lang::XMultiServiceFactory > xFact( m_xChartTypeManager, uno::UNO_QUERY );
- if( xFact.is() )
- {
- m_xChartTypeTemplate.set(
- xFact->createInstance( C2U( "com.sun.star.chart2.template.Column" ) ), uno::UNO_QUERY );
- }
-}
-
-Reference< uno::XInterface > ImplChartModel::GetDashTable() const
-{
- return Reference< uno::XInterface >( m_xDashTable );
-}
-Reference< uno::XInterface > ImplChartModel::GetGradientTable() const
-{
- return Reference< uno::XInterface >( m_xGradientTable );
-}
-Reference< uno::XInterface > ImplChartModel::GetHatchTable() const
-{
- return Reference< uno::XInterface >( m_xHatchTable );
-}
-Reference< uno::XInterface > ImplChartModel::GetBitmapTable() const
-{
- return Reference< uno::XInterface >( m_xBitmapTable );
-}
-Reference< uno::XInterface > ImplChartModel::GetTransparencyGradientTable() const
-{
- return Reference< uno::XInterface >( m_xTransparencyGradientTable );
-}
-
-Reference< uno::XInterface > ImplChartModel::GetXMLNameSpaceMap() const
-{
- return Reference< uno::XInterface >( m_xXMLNamespaceMap );
-}
-
-void ImplChartModel::SetNumberFormatsSupplier(
- const Reference< util::XNumberFormatsSupplier > & xNew )
-{
- if( xNew==m_xNumberFormatsSupplier )
- return;
- if( xNew==m_xOwnNumberFormatsSupplier )
- return;
- if( m_xOwnNumberFormatsSupplier.is() && xNew.is() )
- {
- //@todo
- //merge missing numberformats from own to new formatter
- }
- else if( !xNew.is() )
- {
- if( m_xNumberFormatsSupplier.is() )
- {
- //@todo
- //merge missing numberformats from old numberformatter to own numberformatter
- //create own numberformatter if necessary
- }
- }
-
- m_xNumberFormatsSupplier.set( xNew );
- m_xOwnNumberFormatsSupplier.clear();
-}
-
-Reference< util::XNumberFormatsSupplier > ImplChartModel::GetNumberFormatsSupplier()
-{
- if( !m_xNumberFormatsSupplier.is() )
- {
- if( !m_xOwnNumberFormatsSupplier.is() )
- {
- Reference< lang::XMultiServiceFactory > xFactory( m_xContext->getServiceManager(), uno::UNO_QUERY );
- m_xOwnNumberFormatsSupplier = new SvNumberFormatsSupplierObj( new SvNumberFormatter( xFactory, LANGUAGE_SYSTEM ) );
- //pOwnNumberFormatter->ChangeStandardPrec( 15 ); todo?
- }
- m_xNumberFormatsSupplier = m_xOwnNumberFormatsSupplier;
- }
- return m_xNumberFormatsSupplier;
-}
-
-} // namespace impl
-} // namespace chart
diff --git a/chart2/source/model/main/ImplChartModel.hxx b/chart2/source/model/main/ImplChartModel.hxx
deleted file mode 100644
index aa56565176e3..000000000000
--- a/chart2/source/model/main/ImplChartModel.hxx
+++ /dev/null
@@ -1,250 +0,0 @@
-/*************************************************************************
- *
- * 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.
- *
- ************************************************************************/
-#ifndef CHART_IMPLCHARTMODEL_HXX
-#define CHART_IMPLCHARTMODEL_HXX
-
-#include <com/sun/star/chart2/data/XDataSource.hpp>
-#include <com/sun/star/chart2/XDataSeries.hpp>
-#include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
-#include <com/sun/star/chart2/XDiagram.hpp>
-#include <com/sun/star/chart2/data/XDataProvider.hpp>
-#include <com/sun/star/chart2/XChartTypeManager.hpp>
-#include <com/sun/star/chart2/XChartTypeTemplate.hpp>
-#include <com/sun/star/chart2/XTitle.hpp>
-#include <com/sun/star/chart2/XChartDocument.hpp>
-#include <com/sun/star/chart2/XUndoManager.hpp>
-
-#include <com/sun/star/container/XNameContainer.hpp>
-#include <com/sun/star/container/NoSuchElementException.hpp>
-#include <com/sun/star/io/IOException.hpp>
-#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
-
-#include <cppuhelper/weakref.hxx>
-
-#include "ChartData.hxx"
-
-#include <vector>
-#include <memory>
-#include <boost/shared_ptr.hpp>
-
-namespace com { namespace sun { namespace star {
- namespace container {
- class XNameAccess;
- }
- namespace uno {
- class XComponentContext;
- }
- namespace embed {
- class XStorage;
- }
- namespace document {
- class XFilter;
- }
- namespace util {
- class XModifyListener;
- }
-}}}
-
-class SvNumberFormatter;
-
-namespace chart
-{
-namespace impl
-{
-
-class ImplChartModel
-{
- typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource > tDataSourceType;
-
-public:
- ImplChartModel( ::com::sun::star::uno::Reference<
- ::com::sun::star::uno::XComponentContext > const & xContext,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::util::XModifyListener > & xListener );
- explicit ImplChartModel( const ImplChartModel & rOther,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::util::XModifyListener > & xListener );
- ~ImplChartModel();
-
-// ::com::sun::star::uno::Sequence<
-// ::com::sun::star::uno::Reference<
-// ::com::sun::star::chart2::XDataSeries > >
-// GetDataSeries() const;
-
- ::com::sun::star::uno::Reference<
- ::com::sun::star::container::XNameAccess >
- GetStyleFamilies();
-
- // Diagram Access
- void RemoveAllDiagrams();
- /** @return true, if the chart was found and removed, false otherwise.
- */
- void AppendDiagram( const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XDiagram > & xDiagram );
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XDiagram >
- GetDiagram( size_t nIndex ) const
- throw( ::com::sun::star::container::NoSuchElementException );
-
- void SetDataProvider( const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XDataProvider > & xProvider );
-
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XDataProvider > GetDataProvider() const;
-
- void CreateInternalDataProvider(
- bool bCloneExistingData,
- const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xChartDoc );
-
- bool HasInternalDataProvider() const;
-
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XDataSource > SAL_CALL SetArguments(
- const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & rArgs,
- bool bSetData )
- throw (::com::sun::star::lang::IllegalArgumentException);
-
- void SetChartTypeManager(
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XChartTypeManager > & xManager );
-
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XChartTypeManager >
- GetChartTypeManager();
-
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XChartTypeTemplate >
- GetChartTypeTemplate();
-
- ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTitle >
- GetTitle();
-
- void SetTitle( const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XTitle >& rTitle );
-
- /** Is called by the ChartModel's XComponent::dispose() to notify the
- impl-class to release resources
- */
- void dispose();
-
- ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
- GetPageBackground();
-
- ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XUndoManager >
- GetUndoManager();
-
- void CreateDefaultChart();
-
- ::com::sun::star::uno::Reference<
- ::com::sun::star::uno::XInterface > GetDashTable() const;
- ::com::sun::star::uno::Reference<
- ::com::sun::star::uno::XInterface > GetGradientTable() const;
- ::com::sun::star::uno::Reference<
- ::com::sun::star::uno::XInterface > GetHatchTable() const;
- ::com::sun::star::uno::Reference<
- ::com::sun::star::uno::XInterface > GetBitmapTable() const;
- ::com::sun::star::uno::Reference<
- ::com::sun::star::uno::XInterface > GetTransparencyGradientTable() const;
-
- ::com::sun::star::uno::Reference<
- ::com::sun::star::uno::XInterface > GetXMLNameSpaceMap() const;
-
- ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >
- GetNumberFormatsSupplier();
-
- void SetNumberFormatsSupplier(
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::util::XNumberFormatsSupplier > & xNumberFormatsSupplier );
-
-private:
- void CreateDefaultChartTypeTemplate();
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XDataSource > CreateDefaultData();
- void SetNewData( const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XDataSource > & xDataSource,
- const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & rArgs );
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XDataSource > SAL_CALL SetRangeRepresentation(
- const ::rtl::OUString & rRangeRepresentation, bool bSetData )
- throw (::com::sun::star::lang::IllegalArgumentException);
-
-// void CreateDefaultLayout();
-
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
- ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xFamilies;
-
- ::boost::shared_ptr< ChartData > m_spChartData;
-
- // Data Access (deprecated, temporary solution)
-// ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource > m_xChartData;
-// ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider > m_xDataProvider;
-
-// ::std::vector< ::com::sun::star::uno::Reference<
-// ::com::sun::star::chart2::XDataSeries > > m_aInterpretedData;
-
- ::com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier >
- m_xOwnNumberFormatsSupplier;
- ::com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier >
- m_xNumberFormatsSupplier;
-
- ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartTypeManager >
- m_xChartTypeManager;
- ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartTypeTemplate >
- m_xChartTypeTemplate;
-
- // Diagram Access
- typedef ::std::vector< ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XDiagram > >
- tDiagramContainer;
-
- tDiagramContainer m_aDiagrams;
-
- ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTitle >
- m_xTitle;
-
- bool m_bIsDisposed;
- ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
- m_xPageBackground;
- ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XUndoManager >
- m_xUndoManager;
-
- ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xDashTable;
- ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xGradientTable;
- ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xHatchTable;
- ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xBitmapTable;
- ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xTransparencyGradientTable;
-
- ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xXMLNamespaceMap;
-
- ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > m_xModifyListener;
-};
-
-} // namespace impl
-} // namespace chart
-
-// CHART_IMPLCHARTMODEL_HXX
-#endif
diff --git a/chart2/source/model/main/InternalData.cxx b/chart2/source/model/main/InternalData.cxx
deleted file mode 100644
index 860715825af4..000000000000
--- a/chart2/source/model/main/InternalData.cxx
+++ /dev/null
@@ -1,257 +0,0 @@
-/*************************************************************************
- *
- * 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 "InternalData.hxx"
-#include "macros.hxx"
-#include <com/sun/star/embed/XEmbedPersist.hpp>
-#include <com/sun/star/embed/XEmbedObjectCreator.hpp>
-#include <com/sun/star/chart2/data/XDataProvider.hpp>
-#include <com/sun/star/util/XCloseable.hpp>
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <sot/clsids.hxx>
-
-using namespace ::com::sun::star;
-
-using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::Sequence;
-using ::rtl::OUString;
-
-namespace
-{
-/** convert a class-id macro into a byte-sequence
- call e.g. lcl_GetSequenceClassID( SO3_SC_CLASSID_60 )
- */
-Sequence< sal_Int8 > lcl_GetSequenceClassID( sal_uInt32 n1, sal_uInt16 n2, sal_uInt16 n3,
- sal_uInt8 b8, sal_uInt8 b9, sal_uInt8 b10, sal_uInt8 b11,
- sal_uInt8 b12, sal_uInt8 b13, sal_uInt8 b14, sal_uInt8 b15 )
-{
- Sequence< sal_Int8 > aResult( 16 );
- aResult[0] = static_cast<sal_Int8>(n1 >> 24);
- aResult[1] = static_cast<sal_Int8>(( n1 << 8 ) >> 24);
- aResult[2] = static_cast<sal_Int8>(( n1 << 16 ) >> 24);
- aResult[3] = static_cast<sal_Int8>(( n1 << 24 ) >> 24);
- aResult[4] = n2 >> 8;
- aResult[5] = ( n2 << 8 ) >> 8;
- aResult[6] = n3 >> 8;
- aResult[7] = ( n3 << 8 ) >> 8;
- aResult[8] = b8;
- aResult[9] = b9;
- aResult[10] = b10;
- aResult[11] = b11;
- aResult[12] = b12;
- aResult[13] = b13;
- aResult[14] = b14;
- aResult[15] = b15;
-
- return aResult;
-}
-
-Reference< embed::XStorage > lcl_CreateTempStorage(
- const Reference< lang::XMultiServiceFactory > & rFactory )
-{
- Reference< embed::XStorage > xResult;
-
- try
- {
- Reference< lang::XSingleServiceFactory > xStorageFact(
- rFactory->createInstance( C2U( "com.sun.star.embed.StorageFactory" )),
- uno::UNO_QUERY_THROW );
- xResult.set( xStorageFact->createInstance(), uno::UNO_QUERY_THROW );
- }
- catch( uno::Exception & ex )
- {
- ASSERT_EXCEPTION( ex );
- }
-
- return xResult;
-}
-
-} // anonymous namespace
-
-
-
-namespace chart
-{
-
-//explicit
-InternalData::InternalData(
- const Reference< uno::XComponentContext > & xContext,
- const Reference< embed::XStorage > & xParentStorage ) :
- m_aDataStorageName( RTL_CONSTASCII_USTRINGPARAM("ChartData")),
- m_xContext( xContext ),
- m_xParentStorage( xParentStorage )
-{}
-
-InternalData::~InternalData()
-{
-}
-
-void SAL_CALL InternalData::saveObject()
- throw (embed::ObjectSaveVetoException,
- uno::Exception,
- uno::RuntimeException)
-{
- if( m_xInternalData.is())
- {
- try
- {
- Reference< embed::XEmbedPersist > xPersist( m_xInternalData, uno::UNO_QUERY_THROW );
- xPersist->storeOwn();
- }
- catch( uno::Exception & ex )
- {
- ASSERT_EXCEPTION( ex );
- }
- }
-}
-
-void SAL_CALL InternalData::visibilityChanged( sal_Bool bVisible )
- throw (embed::WrongStateException,
- uno::RuntimeException)
-{
- // ignore (this is for swapping OLE objects?)
-}
-
-Reference< util::XCloseable > SAL_CALL InternalData::getComponent()
- throw (uno::RuntimeException)
-{
- return Reference< util::XCloseable >( m_xInternalData, uno::UNO_QUERY );
-}
-
-// ____ XCloseListener ____
-void SAL_CALL InternalData::queryClosing( const lang::EventObject& Source, ::sal_Bool GetsOwnership )
- throw (util::CloseVetoException,
- uno::RuntimeException)
-{
- // empty
-}
-
-void SAL_CALL InternalData::notifyClosing( const lang::EventObject& Source )
- throw (uno::RuntimeException)
-{
- try
- {
- Reference< util::XCloseable > xCloseable( m_xInternalData, uno::UNO_QUERY );
- if( xCloseable.is())
- xCloseable->close( /* DeliverOwnership */ sal_False );
-
- Reference< lang::XComponent > xComp( m_xInternalData, uno::UNO_QUERY );
- if( xComp.is())
- xComp->dispose();
- m_xInternalData = 0;
- }
- catch( const util::CloseVetoException & )
- {
- throw;
- }
- catch( const uno::Exception & ex )
- {
- ASSERT_EXCEPTION( ex );
- }
-}
-
- // ____ XEventListener ____
-void SAL_CALL InternalData::disposing(
- const lang::EventObject& Source )
- throw (uno::RuntimeException)
-{
- // empty
-}
-
-Reference< chart2::data::XDataProvider > InternalData::createEmbeddedObject() throw()
-{
- OSL_ASSERT( m_xContext.is());
- Reference< chart2::data::XDataProvider > xResult;
-
- try
- {
- if( ! m_xInternalData.is() && m_xContext.is())
- {
- Reference< lang::XMultiServiceFactory > xFactory(
- m_xContext->getServiceManager(), uno::UNO_QUERY_THROW );
- Reference< embed::XEmbedObjectCreator > xCreator(
- xFactory->createInstance(
- C2U( "com.sun.star.embed.EmbeddedObjectCreator")), uno::UNO_QUERY_THROW );
-
- Reference< embed::XStorage > xStorage( m_xParentStorage );
- if( !xStorage.is())
- {
- // as we don't store the spreadsheet as substorage in the final
- // document, it is ok, or maybe even better to create a
- // temporary storage
-// OSL_ENSURE( false, "Using temporary storage for chart data!" );
- xStorage.set( lcl_CreateTempStorage( xFactory ));
- }
-
- m_xInternalData.set(
- xCreator->createInstanceInitNew(
- lcl_GetSequenceClassID( SO3_SC_CLASSID_60 ),
- C2U( "ChartDataEditor" ),
- xStorage,
- m_aDataStorageName,
- Sequence< beans::PropertyValue >() ), uno::UNO_QUERY_THROW );
-
- m_xInternalData->setClientSite( this );
-
- xFactory.set( m_xInternalData->getComponent(), uno::UNO_QUERY_THROW );
- xResult.set(
- xFactory->createInstance( C2U( "com.sun.star.chart2.data.DataProvider" )), uno::UNO_QUERY_THROW );
- }
- }
- catch( uno::Exception & ex )
- {
- ASSERT_EXCEPTION( ex );
- }
-
- return xResult;
-}
-
-void InternalData::removeEmbeddedObject() throw()
-{
- if( m_xParentStorage.is())
- {
- try
- {
- m_xParentStorage->removeElement( m_aDataStorageName );
- }
- catch( uno::Exception & ex )
- {
- ASSERT_EXCEPTION( ex );
- }
- }
-}
-
-Reference< embed::XEmbeddedObject > InternalData::getEmbeddedObject() const throw()
-{
- return m_xInternalData;
-}
-
-} // namespace chart
diff --git a/chart2/source/model/main/InternalData.hxx b/chart2/source/model/main/InternalData.hxx
deleted file mode 100644
index 15b3e9d0e8f0..000000000000
--- a/chart2/source/model/main/InternalData.hxx
+++ /dev/null
@@ -1,118 +0,0 @@
-/*************************************************************************
- *
- * 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.
- *
- ************************************************************************/
-#ifndef CHART2_INTERNALDATA_HXX
-#define CHART2_INTERNALDATA_HXX
-
-#include <com/sun/star/embed/XEmbeddedClient.hpp>
-#include <com/sun/star/embed/XEmbeddedObject.hpp>
-#include <com/sun/star/util/XCloseListener.hpp>
-#include <cppuhelper/implbase2.hxx>
-
-namespace com { namespace sun { namespace star {
- namespace uno {
- class XComponentContext;
- }
- namespace embed {
- class XStorage;
- class XEmbeddedObject;
- }
- namespace chart2 {
- namespace data {
- class XDataProvider;
- }
- }
-}}}
-
-namespace chart
-{
-
-class InternalData :
- public ::cppu::WeakImplHelper2<
- ::com::sun::star::embed::XEmbeddedClient,
- ::com::sun::star::util::XCloseListener >
-{
-public:
- explicit InternalData(
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::uno::XComponentContext > & xContext,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::embed::XStorage > & xParentStorage );
- virtual ~InternalData();
-
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XDataProvider > createEmbeddedObject() throw();
-
- void removeEmbeddedObject() throw();
-
- ::com::sun::star::uno::Reference<
- ::com::sun::star::embed::XEmbeddedObject > getEmbeddedObject() const throw();
-
- // ____ XEmbeddedClient ____
- virtual void SAL_CALL saveObject()
- throw (::com::sun::star::embed::ObjectSaveVetoException,
- ::com::sun::star::uno::Exception,
- ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL visibilityChanged( sal_Bool bVisible )
- throw (::com::sun::star::embed::WrongStateException,
- ::com::sun::star::uno::RuntimeException);
-
- // ____ XComponentSupplier ____
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > SAL_CALL getComponent()
- throw (::com::sun::star::uno::RuntimeException);
-
- // ____ XCloseListener ____
- virtual void SAL_CALL queryClosing(
- const ::com::sun::star::lang::EventObject& Source,
- ::sal_Bool GetsOwnership )
- throw (::com::sun::star::util::CloseVetoException,
- ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL notifyClosing(
- const ::com::sun::star::lang::EventObject& Source )
- throw (::com::sun::star::uno::RuntimeException);
-
- // ____ XEventListener ____
- virtual void SAL_CALL disposing(
- const ::com::sun::star::lang::EventObject& Source )
- throw (::com::sun::star::uno::RuntimeException);
-
-private:
- const ::rtl::OUString m_aDataStorageName;
-
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
- m_xContext;
-
- ::com::sun::star::uno::Reference< ::com::sun::star::embed::XEmbeddedObject >
- m_xInternalData;
-
- ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
- m_xParentStorage;
-};
-
-} // namespace chart
-
-// CHART2_INTERNALDATA_HXX
-#endif
diff --git a/chart2/source/model/main/Legend.cxx b/chart2/source/model/main/Legend.cxx
index e3d8a3107d4c..c1143ecdf77a 100644
--- a/chart2/source/model/main/Legend.cxx
+++ b/chart2/source/model/main/Legend.cxx
@@ -114,7 +114,7 @@ void lcl_AddDefaultsToMap(
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_PREFERRED_EXPANSION, chart2::LegendExpansion_HIGH );
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_SHOW, true );
- float fDefaultCharHeight = 8.0;
+ float fDefaultCharHeight = 10.0;
::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
diff --git a/chart2/source/model/main/makefile.mk b/chart2/source/model/main/makefile.mk
index b4d74a878584..8e963dfa0f5c 100644
--- a/chart2/source/model/main/makefile.mk
+++ b/chart2/source/model/main/makefile.mk
@@ -46,7 +46,6 @@ SLOFILES= \
$(SLO)$/GridProperties.obj \
$(SLO)$/BaseCoordinateSystem.obj \
$(SLO)$/CartesianCoordinateSystem.obj \
- $(SLO)$/ChartData.obj \
$(SLO)$/ChartModel.obj \
$(SLO)$/ChartModel_Persistence.obj \
$(SLO)$/DataPoint.obj \
@@ -55,7 +54,6 @@ SLOFILES= \
$(SLO)$/Diagram.obj \
$(SLO)$/DataSeriesProperties.obj \
$(SLO)$/FormattedString.obj \
- $(SLO)$/ImplChartModel.obj \
$(SLO)$/Legend.obj \
$(SLO)$/PageBackground.obj \
$(SLO)$/PolarCoordinateSystem.obj \
diff --git a/chart2/source/model/makefile.mk b/chart2/source/model/makefile.mk
index 701f47fb94b5..dfb5522a7879 100644
--- a/chart2/source/model/makefile.mk
+++ b/chart2/source/model/makefile.mk
@@ -86,7 +86,7 @@ SHL1STDLIBS= $(CHARTTOOLS) \
#specifies the exported symbols for Windows only:
SHL1DEF= $(MISC)$/$(SHL1TARGET).def
-SHL1VERSIONMAP = model.map
+SHL1VERSIONMAP = $(SOLARENV)/src/component.map
#--------definition file
diff --git a/chart2/source/model/model.map b/chart2/source/model/model.map
deleted file mode 100644
index 07b1790d5754..000000000000
--- a/chart2/source/model/model.map
+++ /dev/null
@@ -1,8 +0,0 @@
-CHART_1_0 {
- global:
- component_getImplementationEnvironment;
- component_writeInfo;
- component_getFactory;
- local:
- *;
-};
diff --git a/chart2/source/model/template/AreaChartTypeTemplate.cxx b/chart2/source/model/template/AreaChartTypeTemplate.cxx
index 072b16a07d26..5fe21cfb25e0 100644
--- a/chart2/source/model/template/AreaChartTypeTemplate.cxx
+++ b/chart2/source/model/template/AreaChartTypeTemplate.cxx
@@ -31,6 +31,7 @@
#include "macros.hxx"
#include "servicenames_charttypes.hxx"
#include "DiagramHelper.hxx"
+#include "DataSeriesHelper.hxx"
#include "ContainerHelper.hxx"
#include "PropertyHelper.hxx"
#include <com/sun/star/beans/PropertyAttribute.hpp>
@@ -208,41 +209,26 @@ void SAL_CALL AreaChartTypeTemplate::applyStyle(
throw (uno::RuntimeException)
{
ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
- if( getDimension() == 3 )
- {
- try
- {
- uno::Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY_THROW );
- xProp->setPropertyValue( C2U("BorderStyle"),
- uno::makeAny( drawing::LineStyle_NONE ));
- }
- catch( uno::Exception & ex )
- {
- ASSERT_EXCEPTION( ex );
- }
- }
+ DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, C2U( "BorderStyle" ), uno::makeAny( drawing::LineStyle_NONE ) );
}
void SAL_CALL AreaChartTypeTemplate::resetStyles( const Reference< chart2::XDiagram >& xDiagram )
throw (uno::RuntimeException)
{
ChartTypeTemplate::resetStyles( xDiagram );
- if( getDimension() == 3 )
+ ::std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
+ DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+ uno::Any aLineStyleAny( uno::makeAny( drawing::LineStyle_NONE ));
+ for( ::std::vector< Reference< chart2::XDataSeries > >::iterator aIt( aSeriesVec.begin());
+ aIt != aSeriesVec.end(); ++aIt )
{
- ::std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
- DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
- uno::Any aLineStyleAny( uno::makeAny( drawing::LineStyle_NONE ));
- for( ::std::vector< Reference< chart2::XDataSeries > >::iterator aIt( aSeriesVec.begin());
- aIt != aSeriesVec.end(); ++aIt )
+ Reference< beans::XPropertyState > xState( *aIt, uno::UNO_QUERY );
+ Reference< beans::XPropertySet > xProp( *aIt, uno::UNO_QUERY );
+ if( xState.is() &&
+ xProp.is() &&
+ xProp->getPropertyValue( C2U("BorderStyle")) == aLineStyleAny )
{
- Reference< beans::XPropertyState > xState( *aIt, uno::UNO_QUERY );
- Reference< beans::XPropertySet > xProp( *aIt, uno::UNO_QUERY );
- if( xState.is() &&
- xProp.is() &&
- xProp->getPropertyValue( C2U("BorderStyle")) == aLineStyleAny )
- {
- xState->setPropertyToDefault( C2U("BorderStyle"));
- }
+ xState->setPropertyToDefault( C2U("BorderStyle"));
}
}
}
diff --git a/chart2/source/model/template/BarChartTypeTemplate.cxx b/chart2/source/model/template/BarChartTypeTemplate.cxx
index 81f1337ccb29..01dc4c253d2b 100644
--- a/chart2/source/model/template/BarChartTypeTemplate.cxx
+++ b/chart2/source/model/template/BarChartTypeTemplate.cxx
@@ -279,6 +279,7 @@ void SAL_CALL BarChartTypeTemplate::applyStyle(
throw (uno::RuntimeException)
{
ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+ DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, C2U( "BorderStyle" ), uno::makeAny( drawing::LineStyle_NONE ) );
if( getDimension() == 3 )
{
try
@@ -300,24 +301,22 @@ void SAL_CALL BarChartTypeTemplate::resetStyles(
throw (uno::RuntimeException)
{
ChartTypeTemplate::resetStyles( xDiagram );
- if( getDimension() == 3 )
+ ::std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
+ DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+ uno::Any aLineStyleAny( uno::makeAny( drawing::LineStyle_NONE ));
+ for( ::std::vector< Reference< chart2::XDataSeries > >::iterator aIt( aSeriesVec.begin());
+ aIt != aSeriesVec.end(); ++aIt )
{
- ::std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
- DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
- uno::Any aLineStyleAny( uno::makeAny( drawing::LineStyle_NONE ));
- for( ::std::vector< Reference< chart2::XDataSeries > >::iterator aIt( aSeriesVec.begin());
- aIt != aSeriesVec.end(); ++aIt )
+ Reference< beans::XPropertyState > xState( *aIt, uno::UNO_QUERY );
+ if( xState.is())
{
- Reference< beans::XPropertyState > xState( *aIt, uno::UNO_QUERY );
- if( xState.is())
- {
+ if( getDimension() == 3 )
xState->setPropertyToDefault( C2U("Geometry3D"));
- Reference< beans::XPropertySet > xProp( xState, uno::UNO_QUERY );
- if( xProp.is() &&
- xProp->getPropertyValue( C2U("BorderStyle")) == aLineStyleAny )
- {
- xState->setPropertyToDefault( C2U("BorderStyle"));
- }
+ Reference< beans::XPropertySet > xProp( xState, uno::UNO_QUERY );
+ if( xProp.is() &&
+ xProp->getPropertyValue( C2U("BorderStyle")) == aLineStyleAny )
+ {
+ xState->setPropertyToDefault( C2U("BorderStyle"));
}
}
}
diff --git a/chart2/source/model/template/BubbleChartTypeTemplate.cxx b/chart2/source/model/template/BubbleChartTypeTemplate.cxx
index 706db07f8288..59b552cc8995 100644
--- a/chart2/source/model/template/BubbleChartTypeTemplate.cxx
+++ b/chart2/source/model/template/BubbleChartTypeTemplate.cxx
@@ -178,12 +178,6 @@ StackMode BubbleChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */
return StackMode_NONE;
}
-bool BubbleChartTypeTemplate::supportsCategories() const
-{
- return false;
-}
-
-
void SAL_CALL BubbleChartTypeTemplate::applyStyle(
const Reference< chart2::XDataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
@@ -192,6 +186,7 @@ void SAL_CALL BubbleChartTypeTemplate::applyStyle(
throw (uno::RuntimeException)
{
ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+ DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, C2U( "BorderStyle" ), uno::makeAny( drawing::LineStyle_NONE ) );
try
{
@@ -203,10 +198,10 @@ void SAL_CALL BubbleChartTypeTemplate::applyStyle(
}
// ____ XChartTypeTemplate ____
-Sequence< OUString > SAL_CALL BubbleChartTypeTemplate::getAvailableCreationParameterNames()
+sal_Bool SAL_CALL BubbleChartTypeTemplate::supportsCategories()
throw (uno::RuntimeException)
{
- return Sequence< OUString >();
+ return false;
}
sal_Bool SAL_CALL BubbleChartTypeTemplate::matchesTemplate(
diff --git a/chart2/source/model/template/BubbleChartTypeTemplate.hxx b/chart2/source/model/template/BubbleChartTypeTemplate.hxx
index 27259f877805..24d35c6acbb7 100644
--- a/chart2/source/model/template/BubbleChartTypeTemplate.hxx
+++ b/chart2/source/model/template/BubbleChartTypeTemplate.hxx
@@ -67,7 +67,7 @@ protected:
throw (::com::sun::star::uno::RuntimeException);
// ____ XChartTypeTemplate ____
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableCreationParameterNames()
+ virtual sal_Bool SAL_CALL supportsCategories()
throw (::com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL matchesTemplate(
const ::com::sun::star::uno::Reference<
@@ -93,8 +93,6 @@ protected:
getChartTypeForIndex( sal_Int32 nChartTypeIndex );
virtual sal_Int32 getDimension() const;
virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const;
-
- virtual bool supportsCategories() const;
};
} // namespace chart
diff --git a/chart2/source/model/template/BubbleDataInterpreter.cxx b/chart2/source/model/template/BubbleDataInterpreter.cxx
index b69055a9e632..1f26fff907e4 100644
--- a/chart2/source/model/template/BubbleDataInterpreter.cxx
+++ b/chart2/source/model/template/BubbleDataInterpreter.cxx
@@ -78,8 +78,6 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::interpretDataSource(
Reference< data::XLabeledDataSequence > xCategories;
bool bHasCategories = HasCategories( aArguments, aData );
- Sequence< Reference< data::XLabeledDataSequence > > aUnusedData;
-
bool bHasXValues = false;
sal_Int32 nDataSeqCount = aData.getLength();
@@ -170,7 +168,7 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::interpretDataSource(
Sequence< Sequence< Reference< XDataSeries > > > aSeries(1);
aSeries[0] = ContainerHelper::ContainerToSequence( aSeriesVec );
- return InterpretedData( aSeries, xCategories, aUnusedData );
+ return InterpretedData( aSeries, xCategories );
}
chart2::InterpretedData SAL_CALL BubbleDataInterpreter::reinterpretDataSeries(
@@ -178,8 +176,6 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::reinterpretDataSeries(
throw (uno::RuntimeException)
{
InterpretedData aResult( aInterpretedData );
- vector< Reference< data::XLabeledDataSequence > > aUnused(
- ContainerHelper::SequenceToVector( aInterpretedData.UnusedData ));
sal_Int32 i=0;
Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
@@ -266,17 +262,15 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::reinterpretDataSeries(
Sequence< Reference< data::XLabeledDataSequence > > aSeqs( xSeriesSource->getDataSequences());
if( aSeqs.getLength() != aNewSequences.getLength() )
{
+#if OSL_DEBUG_LEVEL > 1
sal_Int32 j=0;
for( ; j<aSeqs.getLength(); ++j )
{
- if( aSeqs[j] != xValuesY &&
- aSeqs[j] != xValuesX &&
- aSeqs[j] != xValuesSize )
- aUnused.push_back( aSeqs[j] );
+ OSL_ENSURE( aSeqs[j] == xValuesY || aSeqs[j] == xValuesX || aSeqs[j] == xValuesSize, "All sequences should be used" );
}
+#endif
Reference< data::XDataSink > xSink( xSeriesSource, uno::UNO_QUERY_THROW );
xSink->setData( aNewSequences );
- aResult.UnusedData = ContainerHelper::ContainerToSequence( aUnused );
}
}
catch( uno::Exception & ex )
diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx b/chart2/source/model/template/ChartTypeTemplate.cxx
index 2fd0ca2a1d89..393321a19d55 100644
--- a/chart2/source/model/template/ChartTypeTemplate.cxx
+++ b/chart2/source/model/template/ChartTypeTemplate.cxx
@@ -192,11 +192,10 @@ uno::Reference< XDiagram > SAL_CALL ChartTypeTemplate::createDiagramByDataSource
return xDia;
}
-Sequence< OUString > SAL_CALL ChartTypeTemplate::getAvailableCreationParameterNames()
+sal_Bool SAL_CALL ChartTypeTemplate::supportsCategories()
throw (uno::RuntimeException)
{
- OUString aHasCat( C2U("HasCategories"));
- return Sequence< OUString >( & aHasCat, 1 );
+ return sal_True;
}
void SAL_CALL ChartTypeTemplate::changeDiagram( const uno::Reference< XDiagram >& xDiagram )
@@ -217,10 +216,8 @@ void SAL_CALL ChartTypeTemplate::changeDiagram( const uno::Reference< XDiagram >
chart2::InterpretedData aData;
aData.Series = aSeriesSeq;
aData.Categories = DiagramHelper::getCategoriesFromDiagram( xDiagram );
- aData.UnusedData = xDiagram->getUnusedData();
- if( (aData.UnusedData.getLength() == 0) &&
- xInterpreter->isDataCompatible( aData ))
+ if( xInterpreter->isDataCompatible( aData ) )
{
aData = xInterpreter->reinterpretDataSeries( aData );
}
@@ -238,32 +235,9 @@ void SAL_CALL ChartTypeTemplate::changeDiagram( const uno::Reference< XDiagram >
aParam[0] = beans::PropertyValue( C2U("HasCategories"), -1, uno::makeAny( true ),
beans::PropertyState_DIRECT_VALUE );
}
- else if( aData.UnusedData.getLength())
- {
- for( sal_Int32 i=0; i<aData.UnusedData.getLength(); ++i )
- try
- {
- Reference< beans::XPropertySet > xProp( aData.UnusedData[i]->getValues(), uno::UNO_QUERY_THROW );
- OUString aRole;
- if( (xProp->getPropertyValue(C2U("Role")) >>= aRole) &
- aRole.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("categories")) )
- {
- aData.Categories = aData.UnusedData[i];
- for( ++i; i<aData.UnusedData.getLength(); ++i )
- aData.UnusedData[i-1] = aData.UnusedData[i];
- aData.UnusedData.realloc( aData.UnusedData.getLength() - 1 );
- break;
- }
- }
- catch( const uno::Exception & ex )
- {
- ASSERT_EXCEPTION( ex );
- }
- }
aData = xInterpreter->interpretDataSource( xSource, aParam, aFlatSeriesSeq );
}
aSeriesSeq = aData.Series;
- xDiagram->setUnusedData( aData.UnusedData );
sal_Int32 i, j, nIndex = 0;
for( i=0; i<aSeriesSeq.getLength(); ++i )
@@ -583,11 +557,6 @@ bool ChartTypeTemplate::isSwapXAndY() const
return false;
}
-bool ChartTypeTemplate::supportsCategories() const
-{
- return true;
-}
-
// ________________________________________
void ChartTypeTemplate::createCoordinateSystems(
@@ -661,7 +630,7 @@ void ChartTypeTemplate::adaptScales(
const Reference< data::XLabeledDataSequence > & xCategories //@todo: in future there may be more than one sequence of categories (e.g. charttype with categories at x and y axis )
)
{
- bool bSupportsCategories( supportsCategories());
+ bool bSupportsCategories( supportsCategories() );
for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); ++nCooSysIdx )
{
try
diff --git a/chart2/source/model/template/ChartTypeTemplate.hxx b/chart2/source/model/template/ChartTypeTemplate.hxx
index 2247c13ec940..3f43e0ca6038 100644
--- a/chart2/source/model/template/ChartTypeTemplate.hxx
+++ b/chart2/source/model/template/ChartTypeTemplate.hxx
@@ -100,7 +100,8 @@ protected:
const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource >& xDataSource,
const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArguments )
throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableCreationParameterNames()
+ /// denotes if the chart needs categories at the first scale
+ virtual sal_Bool SAL_CALL supportsCategories()
throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL changeDiagram(
const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram )
@@ -158,9 +159,6 @@ protected:
virtual bool isSwapXAndY() const;
- /// denotes if the chart needs categories at the first scale
- virtual bool supportsCategories() const;
-
// Methods for creating the diagram piecewise
// ------------------------------------------
diff --git a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx
index 70a0a633836a..663cad4c2fe4 100644
--- a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx
+++ b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx
@@ -39,6 +39,7 @@
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/chart2/XChartTypeContainer.hpp>
#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
+#include <com/sun/star/drawing/LineStyle.hpp>
#include <algorithm>
@@ -270,7 +271,11 @@ void SAL_CALL ColumnLineChartTypeTemplate::applyStyle(
{
ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
- if( nChartTypeIndex==1 ) // lines
+ if( nChartTypeIndex==0 ) // columns
+ {
+ DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, C2U( "BorderStyle" ), uno::makeAny( drawing::LineStyle_NONE ) );
+ }
+ else if( nChartTypeIndex==1 ) // lines
{
Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY );
if( xProp.is() )
diff --git a/chart2/source/model/template/DataInterpreter.cxx b/chart2/source/model/template/DataInterpreter.cxx
index 6d5b85fd3e4b..b619553ee959 100644
--- a/chart2/source/model/template/DataInterpreter.cxx
+++ b/chart2/source/model/template/DataInterpreter.cxx
@@ -149,7 +149,7 @@ InterpretedData SAL_CALL DataInterpreter::interpretDataSource(
Sequence< Sequence< Reference< XDataSeries > > > aSeries(1);
aSeries[0] = ContainerToSequence( aSeriesVec );
- return InterpretedData( aSeries, xCategories, Sequence< Reference< data::XLabeledDataSequence > >() );
+ return InterpretedData( aSeries, xCategories );
}
InterpretedData SAL_CALL DataInterpreter::reinterpretDataSeries(
@@ -157,8 +157,6 @@ InterpretedData SAL_CALL DataInterpreter::reinterpretDataSeries(
throw (uno::RuntimeException)
{
InterpretedData aResult( aInterpretedData );
- vector< Reference< data::XLabeledDataSequence > > aUnused(
- SequenceToVector( aInterpretedData.UnusedData ));
sal_Int32 i=0;
Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
@@ -190,14 +188,14 @@ InterpretedData SAL_CALL DataInterpreter::reinterpretDataSeries(
Sequence< Reference< data::XLabeledDataSequence > > aSeqs( xSeriesSource->getDataSequences());
if( aSeqs.getLength() != aNewSequences.getLength() )
{
+#if OSL_DEBUG_LEVEL > 1
sal_Int32 j=0;
for( ; j<aSeqs.getLength(); ++j )
{
- if( aSeqs[j] != xValuesY )
- aUnused.push_back( aSeqs[j] );
+ OSL_ENSURE( aSeqs[j] == xValuesY, "All sequences should be used" );
}
+#endif
Reference< data::XDataSink > xSink( xSeriesSource, uno::UNO_QUERY_THROW );
-
xSink->setData( aNewSequences );
}
}
@@ -207,8 +205,6 @@ InterpretedData SAL_CALL DataInterpreter::reinterpretDataSeries(
}
}
- aResult.UnusedData = ContainerToSequence( aUnused );
-
return aResult;
}
@@ -294,34 +290,13 @@ Reference< data::XDataSource > SAL_CALL DataInterpreter::mergeInterpretedData(
throw (uno::RuntimeException)
{
vector< Reference< data::XLabeledDataSequence > > aResultVec;
- vector< Reference< data::XLabeledDataSequence > > aUnusedDataVec;
aResultVec.reserve( aInterpretedData.Series.getLength() +
- aInterpretedData.UnusedData.getLength() +
1 // categories
);
if( aInterpretedData.Categories.is())
aResultVec.push_back( aInterpretedData.Categories );
- // add unused data that has the Role categories at front
- if( aInterpretedData.UnusedData.getLength())
- {
- sal_Int32 nSize = aInterpretedData.UnusedData.getLength();
- for( sal_Int32 i=0; i<nSize; ++i )
- {
- Reference< data::XLabeledDataSequence > xPotentialCategories( aInterpretedData.UnusedData[i] );
- if( xPotentialCategories.is() )
- {
- if( GetRole( xPotentialCategories->getValues()).equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("categories")))
- aResultVec.push_back( xPotentialCategories );
- else
- aUnusedDataVec.push_back( xPotentialCategories );
- }
- }
- }
- else
- aUnusedDataVec = SequenceToVector( aInterpretedData.UnusedData );
-
Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeries.getLength(); ++nSeriesIdx )
{
@@ -349,9 +324,6 @@ Reference< data::XDataSource > SAL_CALL DataInterpreter::mergeInterpretedData(
}
}
- // add unused data at end
- copy( aUnusedDataVec.begin(), aUnusedDataVec.end(), back_inserter( aResultVec ));
-
return Reference< data::XDataSource >( DataSourceHelper::createDataSource( ContainerToSequence( aResultVec ) ) );
}
diff --git a/chart2/source/model/template/PieChartTypeTemplate.cxx b/chart2/source/model/template/PieChartTypeTemplate.cxx
index a8f2fc12720a..c16682846d53 100644
--- a/chart2/source/model/template/PieChartTypeTemplate.cxx
+++ b/chart2/source/model/template/PieChartTypeTemplate.cxx
@@ -554,12 +554,7 @@ void SAL_CALL PieChartTypeTemplate::applyStyle(
}
// line style
- drawing::LineStyle eStyle = (getDimension() == 2)
- ? drawing::LineStyle_SOLID
- : drawing::LineStyle_NONE;
-
- xProp->setPropertyValue( C2U("BorderStyle"),
- uno::makeAny( eStyle ));
+ DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, C2U( "BorderStyle" ), uno::makeAny( drawing::LineStyle_NONE ) );
// vary colors by point
xProp->setPropertyValue( C2U("VaryColorsByPoint"), uno::makeAny( true ));
@@ -616,10 +611,7 @@ void SAL_CALL PieChartTypeTemplate::resetStyles( const Reference< chart2::XDiagr
// line style
::std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
- drawing::LineStyle eStyle = (getDimension() == 2)
- ? drawing::LineStyle_SOLID
- : drawing::LineStyle_NONE;
- uno::Any aLineStyleAny( uno::makeAny( eStyle ));
+ uno::Any aLineStyleAny( uno::makeAny( drawing::LineStyle_NONE ));
for( ::std::vector< Reference< chart2::XDataSeries > >::iterator aIt( aSeriesVec.begin());
aIt != aSeriesVec.end(); ++aIt )
{
diff --git a/chart2/source/model/template/ScatterChartTypeTemplate.cxx b/chart2/source/model/template/ScatterChartTypeTemplate.cxx
index 7c83e80d7234..a83d9a8a4ea3 100644
--- a/chart2/source/model/template/ScatterChartTypeTemplate.cxx
+++ b/chart2/source/model/template/ScatterChartTypeTemplate.cxx
@@ -219,12 +219,6 @@ StackMode ScatterChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex *
return StackMode_NONE;
}
-bool ScatterChartTypeTemplate::supportsCategories() const
-{
- return false;
-}
-
-
void SAL_CALL ScatterChartTypeTemplate::applyStyle(
const Reference< chart2::XDataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
@@ -241,6 +235,8 @@ void SAL_CALL ScatterChartTypeTemplate::applyStyle(
DataSeriesHelper::switchSymbolsOnOrOff( xProp, m_bHasSymbols, nSeriesIndex );
DataSeriesHelper::switchLinesOnOrOff( xProp, m_bHasLines );
DataSeriesHelper::makeLinesThickOrThin( xProp, m_nDim==2 );
+ if( m_nDim==3 )
+ DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, C2U( "BorderStyle" ), uno::makeAny( drawing::LineStyle_NONE ) );
}
catch( uno::Exception & ex )
{
@@ -249,10 +245,10 @@ void SAL_CALL ScatterChartTypeTemplate::applyStyle(
}
// ____ XChartTypeTemplate ____
-Sequence< OUString > SAL_CALL ScatterChartTypeTemplate::getAvailableCreationParameterNames()
+sal_Bool SAL_CALL ScatterChartTypeTemplate::supportsCategories()
throw (uno::RuntimeException)
{
- return Sequence< OUString >();
+ return sal_False;
}
sal_Bool SAL_CALL ScatterChartTypeTemplate::matchesTemplate(
diff --git a/chart2/source/model/template/ScatterChartTypeTemplate.hxx b/chart2/source/model/template/ScatterChartTypeTemplate.hxx
index 6cb15247a0d9..048cca73a92c 100644
--- a/chart2/source/model/template/ScatterChartTypeTemplate.hxx
+++ b/chart2/source/model/template/ScatterChartTypeTemplate.hxx
@@ -71,7 +71,7 @@ protected:
throw (::com::sun::star::uno::RuntimeException);
// ____ XChartTypeTemplate ____
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableCreationParameterNames()
+ virtual sal_Bool SAL_CALL supportsCategories()
throw (::com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL matchesTemplate(
const ::com::sun::star::uno::Reference<
@@ -98,8 +98,6 @@ protected:
virtual sal_Int32 getDimension() const;
virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const;
- virtual bool supportsCategories() const;
-
private:
bool m_bHasSymbols;
bool m_bHasLines;
diff --git a/chart2/source/model/template/StockChartTypeTemplate.cxx b/chart2/source/model/template/StockChartTypeTemplate.cxx
index 90a313b78c8a..00ace6c330ad 100644
--- a/chart2/source/model/template/StockChartTypeTemplate.cxx
+++ b/chart2/source/model/template/StockChartTypeTemplate.cxx
@@ -265,10 +265,14 @@ void SAL_CALL StockChartTypeTemplate::applyStyle(
if( xProp.is() )
xProp->setPropertyValue( C2U("AttachedAxisIndex"), uno::makeAny( nNewAxisIndex ) );
-
- //ensure that lines are on
- if( !bHasVolume || nChartTypeIndex==0 )
+ if( bHasVolume && nChartTypeIndex==0 )
{
+ //switch lines off for volume bars
+ DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, C2U( "BorderStyle" ), uno::makeAny( drawing::LineStyle_NONE ) );
+ }
+ else
+ {
+ //ensure that lines are on
if( xProp.is() )
{
drawing::LineStyle eStyle = drawing::LineStyle_NONE;
@@ -277,6 +281,7 @@ void SAL_CALL StockChartTypeTemplate::applyStyle(
xProp->setPropertyValue( C2U("LineStyle"), uno::makeAny( drawing::LineStyle_SOLID ));
}
}
+
}
catch( uno::Exception & ex )
{
diff --git a/chart2/source/model/template/StockDataInterpreter.cxx b/chart2/source/model/template/StockDataInterpreter.cxx
index d7da1e7ea04c..0d134516a1bb 100644
--- a/chart2/source/model/template/StockDataInterpreter.cxx
+++ b/chart2/source/model/template/StockDataInterpreter.cxx
@@ -268,8 +268,7 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
}
}
- const Sequence< Reference< data::XLabeledDataSequence > > aUnusedData;//@todo remove the unused data concept completely
- return InterpretedData( aResultSeries, xCategories, aUnusedData );
+ return InterpretedData( aResultSeries, xCategories );
}
// criterion: there must be two groups for stock-charts with volume and all
@@ -302,7 +301,7 @@ sal_Bool SAL_CALL StockDataInterpreter::isDataCompatible(
if( ! DataInterpreter::isDataCompatible(
InterpretedData( Sequence< Sequence< Reference< XDataSeries > > >(
aInterpretedData.Series.getConstArray(), 1 ),
- aInterpretedData.Categories, aInterpretedData.UnusedData )))
+ aInterpretedData.Categories )))
return sal_False;
}
diff --git a/chart2/source/model/template/XYDataInterpreter.cxx b/chart2/source/model/template/XYDataInterpreter.cxx
index 0bf1e73562e4..839c0cbac510 100644
--- a/chart2/source/model/template/XYDataInterpreter.cxx
+++ b/chart2/source/model/template/XYDataInterpreter.cxx
@@ -79,8 +79,6 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::interpretDataSource(
bool bHasCategories = HasCategories( aArguments, aData );
// parse data
- Sequence< Reference< data::XLabeledDataSequence > > aUnusedData;
-
bool bCategoriesUsed = false;
for( sal_Int32 nDataIdx= 0; nDataIdx < aData.getLength(); ++nDataIdx )
{
@@ -157,7 +155,7 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::interpretDataSource(
Sequence< Sequence< Reference< XDataSeries > > > aSeries(1);
aSeries[0] = ContainerHelper::ContainerToSequence( aSeriesVec );
- return InterpretedData( aSeries, xCategories, aUnusedData );
+ return InterpretedData( aSeries, xCategories );
}
chart2::InterpretedData SAL_CALL XYDataInterpreter::reinterpretDataSeries(
@@ -165,8 +163,6 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::reinterpretDataSeries(
throw (uno::RuntimeException)
{
InterpretedData aResult( aInterpretedData );
- vector< Reference< data::XLabeledDataSequence > > aUnused(
- ContainerHelper::SequenceToVector( aInterpretedData.UnusedData ));
sal_Int32 i=0;
Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
@@ -230,16 +226,15 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::reinterpretDataSeries(
Sequence< Reference< data::XLabeledDataSequence > > aSeqs( xSeriesSource->getDataSequences());
if( aSeqs.getLength() != aNewSequences.getLength() )
{
+#if OSL_DEBUG_LEVEL > 1
sal_Int32 j=0;
for( ; j<aSeqs.getLength(); ++j )
{
- if( aSeqs[j] != xValuesY &&
- aSeqs[j] != xValuesX )
- aUnused.push_back( aSeqs[j] );
+ OSL_ENSURE( aSeqs[j] == xValuesY || aSeqs[j] == xValuesX, "All sequences should be used" );
}
+#endif
Reference< data::XDataSink > xSink( xSeriesSource, uno::UNO_QUERY_THROW );
xSink->setData( aNewSequences );
- aResult.UnusedData = ContainerHelper::ContainerToSequence( aUnused );
}
}
catch( uno::Exception & ex )
diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx
index b2f7fb24e6f2..8cdd24e4dc05 100644
--- a/chart2/source/tools/AxisHelper.cxx
+++ b/chart2/source/tools/AxisHelper.cxx
@@ -284,6 +284,26 @@ void AxisHelper::makeAxisInvisible( const Reference< XAxis >& xAxis )
}
}
+//static
+void AxisHelper::hideAxisIfNoDataIsAttached( const Reference< XAxis >& xAxis, const Reference< XDiagram >& xDiagram )
+{
+ //axis is hidden if no data is attached anymore but data is available
+ bool bOtherSeriesAttachedToThisAxis = false;
+ ::std::vector< Reference< chart2::XDataSeries > > aSeriesVector( DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
+ ::std::vector< Reference< chart2::XDataSeries > >::const_iterator aIt = aSeriesVector.begin();
+ for( ; aIt != aSeriesVector.end(); ++aIt)
+ {
+ uno::Reference< chart2::XAxis > xCurrentAxis( DiagramHelper::getAttachedAxis( *aIt, xDiagram ), uno::UNO_QUERY );
+ if( xCurrentAxis==xAxis )
+ {
+ bOtherSeriesAttachedToThisAxis = true;
+ break;
+ }
+ }
+ if(!bOtherSeriesAttachedToThisAxis && !aSeriesVector.empty() )
+ AxisHelper::makeAxisInvisible( xAxis );
+}
+
void AxisHelper::hideGrid( sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid
, const Reference< XDiagram >& xDiagram )
{
diff --git a/chart2/source/tools/ChartModelHelper.cxx b/chart2/source/tools/ChartModelHelper.cxx
index 109b2d644433..a49b2abeac98 100644
--- a/chart2/source/tools/ChartModelHelper.cxx
+++ b/chart2/source/tools/ChartModelHelper.cxx
@@ -32,7 +32,6 @@
#include "DiagramHelper.hxx"
#include "DataSourceHelper.hxx"
#include "ControllerLockGuard.hxx"
-#include "UndoManager.hxx"
#include "RangeHighlighter.hxx"
#include "InternalDataProvider.hxx"
@@ -56,12 +55,6 @@ using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
//static
-uno::Reference< chart2::XUndoManager > ChartModelHelper::createUndoManager()
-{
- return new UndoManager();
-}
-
-//static
uno::Reference< chart2::data::XRangeHighlighter > ChartModelHelper::createRangeHighlighter(
const uno::Reference< view::XSelectionSupplier > & xSelectionSupplier )
{
@@ -69,23 +62,10 @@ uno::Reference< chart2::data::XRangeHighlighter > ChartModelHelper::createRangeH
}
//static
-uno::Reference< chart2::data::XDataProvider > ChartModelHelper::createInternalDataProvider()
-{
- return new InternalDataProvider();
-}
-
-//static
-uno::Reference< chart2::data::XDataProvider > ChartModelHelper::createInternalDataProvider(
- const uno::Reference< ::com::sun::star::chart::XChartDataArray >& xDataToCopy )
-{
- return new InternalDataProvider( xDataToCopy );
-}
-
-//static
uno::Reference< chart2::data::XDataProvider > ChartModelHelper::createInternalDataProvider(
- const uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDoc )
+ const uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDoc, bool bConnectToModel )
{
- return new InternalDataProvider( xChartDoc );
+ return new InternalDataProvider( xChartDoc, bConnectToModel );
}
//static
@@ -112,6 +92,20 @@ uno::Reference< XDiagram > ChartModelHelper::findDiagram( const uno::Reference<
return NULL;
}
+//static
+uno::Reference< XCoordinateSystem > ChartModelHelper::getFirstCoordinateSystem( const uno::Reference< frame::XModel >& xModel )
+{
+ uno::Reference< XCoordinateSystem > XCooSys;
+ uno::Reference< XCoordinateSystemContainer > xCooSysCnt( ChartModelHelper::findDiagram( xModel ), uno::UNO_QUERY );
+ if( xCooSysCnt.is() )
+ {
+ uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems() );
+ if( aCooSysSeq.getLength() )
+ XCooSys = aCooSysSeq[0];
+ }
+ return XCooSys;
+}
+
// static
::std::vector< uno::Reference< XDataSeries > > ChartModelHelper::getDataSeries(
const uno::Reference< XChartDocument > & xChartDoc )
@@ -140,9 +134,14 @@ uno::Reference< XChartType > ChartModelHelper::getChartTypeOfSeries(
return DiagramHelper::getChartTypeOfSeries( ChartModelHelper::findDiagram( xModel ), xGivenDataSeries );
}
+awt::Size ChartModelHelper::getDefaultPageSize()
+{
+ return awt::Size( 16000, 9000 );
+}
+
awt::Size ChartModelHelper::getPageSize( const uno::Reference< frame::XModel >& xModel )
{
- awt::Size aPageSize( 8000, 7000 );
+ awt::Size aPageSize( ChartModelHelper::getDefaultPageSize() );
uno::Reference< embed::XVisualObject > xVisualObject(xModel,uno::UNO_QUERY);
DBG_ASSERT(xVisualObject.is(),"need xVisualObject for page size");
if( xVisualObject.is() )
diff --git a/chart2/source/tools/ChartTypeHelper.cxx b/chart2/source/tools/ChartTypeHelper.cxx
index 9e0b22ba75ac..b851a3864b97 100644
--- a/chart2/source/tools/ChartTypeHelper.cxx
+++ b/chart2/source/tools/ChartTypeHelper.cxx
@@ -441,44 +441,45 @@ bool ChartTypeHelper::noBordersForSimpleScheme( const uno::Reference< chart2::XC
//static
sal_Int32 ChartTypeHelper::getDefaultDirectLightColor( bool bSimple, const uno::Reference< chart2::XChartType >& xChartType )
{
- if( bSimple )
+ sal_Int32 nRet = static_cast< sal_Int32 >( 0x808080 ); // grey
+ if( xChartType .is() )
{
- sal_Int32 nRet = static_cast< sal_Int32 >( 0x999999 ); // grey40
- if( xChartType .is() )
+ rtl::OUString aChartType = xChartType->getChartType();
+ if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
{
- rtl::OUString aChartType = xChartType->getChartType();
- if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
+ if( bSimple )
nRet = static_cast< sal_Int32 >( 0x333333 ); // grey80
- else if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_LINE)
- || aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
- nRet = static_cast< sal_Int32 >( 0x666666 ); // grey60
+ else
+ nRet = static_cast< sal_Int32 >( 0xb3b3b3 ); // grey30
}
- return nRet;
+ else if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_LINE)
+ || aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
+ nRet = static_cast< sal_Int32 >( 0x666666 ); // grey60
}
- return static_cast< sal_Int32 >( 0xb3b3b3 ); // grey30
+ return nRet;
}
//static
sal_Int32 ChartTypeHelper::getDefaultAmbientLightColor( bool bSimple, const uno::Reference< chart2::XChartType >& xChartType )
{
- if( bSimple )
+ sal_Int32 nRet = static_cast< sal_Int32 >( 0x999999 ); // grey40
+ if( xChartType .is() )
{
- sal_Int32 nRet = static_cast< sal_Int32 >( 0x999999 ); // grey40
- if( xChartType .is() )
+ rtl::OUString aChartType = xChartType->getChartType();
+ if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
{
- rtl::OUString aChartType = xChartType->getChartType();
- if( aChartType.equals(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
+ if( bSimple )
nRet = static_cast< sal_Int32 >( 0xcccccc ); // grey20
+ else
+ nRet = static_cast< sal_Int32 >( 0x666666 ); // grey60
}
- return nRet;
}
- return static_cast< sal_Int32 >( 0x666666 ); // grey60
+ return nRet;
}
drawing::Direction3D ChartTypeHelper::getDefaultSimpleLightDirection( const uno::Reference< chart2::XChartType >& xChartType )
{
- //drawing::Direction3D aRet(0.0, 0.0, 1.0);
- drawing::Direction3D aRet(-0.2, 0.7, 0.6);
+ drawing::Direction3D aRet(0.0, 0.0, 1.0);
if( xChartType .is() )
{
rtl::OUString aChartType = xChartType->getChartType();
@@ -493,7 +494,7 @@ drawing::Direction3D ChartTypeHelper::getDefaultSimpleLightDirection( const uno:
drawing::Direction3D ChartTypeHelper::getDefaultRealisticLightDirection( const uno::Reference< chart2::XChartType >& xChartType )
{
- drawing::Direction3D aRet(-0.1, 0.6, 0.8);
+ drawing::Direction3D aRet(0.0, 0.0, 1.0);
if( xChartType .is() )
{
rtl::OUString aChartType = xChartType->getChartType();
diff --git a/chart2/source/tools/DataSeriesHelper.cxx b/chart2/source/tools/DataSeriesHelper.cxx
index 538f2966105f..acff332d4229 100644
--- a/chart2/source/tools/DataSeriesHelper.cxx
+++ b/chart2/source/tools/DataSeriesHelper.cxx
@@ -595,7 +595,7 @@ void makeLinesThickOrThin( const Reference< beans::XPropertySet > & xSeriesPrope
if( !xSeriesProperties.is() )
return;
- sal_Int32 nNewValue = bThick ? 88 : 0;
+ sal_Int32 nNewValue = bThick ? 80 : 0;
sal_Int32 nOldValue = 0;
if( (xSeriesProperties->getPropertyValue( C2U( "LineWidth" )) >>= nOldValue ) &&
nOldValue != nNewValue )
diff --git a/chart2/source/tools/DataSourceHelper.cxx b/chart2/source/tools/DataSourceHelper.cxx
index 837f07432e32..0cc6ef4a4315 100644
--- a/chart2/source/tools/DataSourceHelper.cxx
+++ b/chart2/source/tools/DataSourceHelper.cxx
@@ -298,18 +298,13 @@ uno::Sequence< ::rtl::OUString > DataSourceHelper::getUsedDataRanges( const uno:
}
uno::Reference< chart2::data::XDataSource > DataSourceHelper::getUsedData(
- const uno::Reference< chart2::XChartDocument >& xChartDoc,
- bool bIncludeUnusedData /* = false */ )
+ const uno::Reference< chart2::XChartDocument >& xChartDoc )
{
- if( bIncludeUnusedData )
- return getUsedData( uno::Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY ), bIncludeUnusedData );
- else
- return pressUsedDataIntoRectangularFormat( xChartDoc );
+ return pressUsedDataIntoRectangularFormat( xChartDoc );
}
uno::Reference< chart2::data::XDataSource > DataSourceHelper::getUsedData(
- const uno::Reference< frame::XModel >& xChartModel,
- bool bIncludeUnusedData /* = false */ )
+ const uno::Reference< frame::XModel >& xChartModel )
{
::std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aResult;
@@ -330,14 +325,6 @@ uno::Reference< chart2::data::XDataSource > DataSourceHelper::getUsedData(
::std::back_inserter( aResult ));
}
- if( bIncludeUnusedData && xDiagram.is())
- {
- uno::Sequence< uno::Reference< data::XLabeledDataSequence > > aUnusedData( xDiagram->getUnusedData());
- ::std::copy( aUnusedData.getConstArray(),
- aUnusedData.getConstArray() + aUnusedData.getLength(),
- ::std::back_inserter( aResult ));
- }
-
return uno::Reference< chart2::data::XDataSource >(
new DataSource( ContainerHelper::ContainerToSequence( aResult )));
}
@@ -349,8 +336,7 @@ bool DataSourceHelper::detectRangeSegmentation(
, ::com::sun::star::uno::Sequence< sal_Int32 >& rSequenceMapping
, bool& rOutUseColumns
, bool& rOutFirstCellAsLabel
- , bool& rOutHasCategories
- , bool bIncludeUnusedData /* = false */)
+ , bool& rOutHasCategories )
{
bool bSomethingDetected = false;
@@ -361,9 +347,6 @@ bool DataSourceHelper::detectRangeSegmentation(
if( !xDataProvider.is() )
return bSomethingDetected;
- OSL_ASSERT( !bIncludeUnusedData ); //bIncludeUnusedData is not supported currently
- (void)(bIncludeUnusedData); // avoid warning in non-debug build
-
try
{
DataSourceHelper::readArguments(
@@ -531,6 +514,19 @@ Sequence< OUString > DataSourceHelper::getRangesFromLabeledDataSequence(
return aResult;
}
+OUString DataSourceHelper::getRangeFromValues(
+ const Reference< data::XLabeledDataSequence > & xLSeq )
+{
+ OUString aResult;
+ if( xLSeq.is() )
+ {
+ Reference< data::XDataSequence > xValues( xLSeq->getValues() );
+ if( xValues.is() )
+ aResult = xValues->getSourceRangeRepresentation();
+ }
+ return aResult;
+}
+
Sequence< OUString > DataSourceHelper::getRangesFromDataSource( const Reference< data::XDataSource > & xSource )
{
::std::vector< OUString > aResult;
diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx
index 31ac5f1ae4ec..b95e7522943e 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -35,7 +35,9 @@
#include "AxisHelper.hxx"
#include "ContainerHelper.hxx"
#include "ChartTypeHelper.hxx"
+#include "ChartModelHelper.hxx"
#include "CommonConverters.hxx"
+#include "ExplicitCategoriesProvider.hxx"
#include "servicenames_charttypes.hxx"
#include <com/sun/star/chart/MissingValueTreatment.hpp>
@@ -597,7 +599,7 @@ bool DiagramHelper::attachSeriesToAxis( bool bAttachToMainAxis
, const uno::Reference< chart2::XDataSeries >& xDataSeries
, const uno::Reference< chart2::XDiagram >& xDiagram
, const uno::Reference< uno::XComponentContext > & xContext
- )
+ , bool bAdaptAxes )
{
bool bChanged = false;
@@ -608,6 +610,7 @@ bool DiagramHelper::attachSeriesToAxis( bool bAttachToMainAxis
sal_Int32 nNewAxisIndex = bAttachToMainAxis ? 0 : 1;
sal_Int32 nOldAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries);
+ uno::Reference< chart2::XAxis > xOldAxis( DiagramHelper::getAttachedAxis( xDataSeries, xDiagram ) );
if( nOldAxisIndex != nNewAxisIndex )
{
@@ -627,6 +630,11 @@ bool DiagramHelper::attachSeriesToAxis( bool bAttachToMainAxis
uno::Reference< XAxis > xAxis( AxisHelper::getAxis( 1, bAttachToMainAxis, xDiagram ) );
if(!xAxis.is()) //create an axis if necessary
xAxis = AxisHelper::createAxis( 1, bAttachToMainAxis, xDiagram, xContext );
+ if( bAdaptAxes )
+ {
+ AxisHelper::makeAxisVisible( xAxis );
+ AxisHelper::hideAxisIfNoDataIsAttached( xOldAxis, xDiagram );
+ }
}
return bChanged;
@@ -955,8 +963,7 @@ Reference< data::XLabeledDataSequence >
return xResult;
}
-//static
-void DiagramHelper::generateAutomaticCategoriesFromChartType(
+void lcl_generateAutomaticCategoriesFromChartType(
Sequence< rtl::OUString >& rRet,
const Reference< XChartType >& xChartType )
{
@@ -986,64 +993,35 @@ void DiagramHelper::generateAutomaticCategoriesFromChartType(
}
}
-//static
-Sequence< rtl::OUString > DiagramHelper::generateAutomaticCategories(
- const Reference< XChartDocument >& xChartDoc )
+Sequence< rtl::OUString > DiagramHelper::generateAutomaticCategoriesFromCooSys( const Reference< XCoordinateSystem > & xCooSys )
{
Sequence< rtl::OUString > aRet;
- if(xChartDoc.is())
+
+ Reference< XChartTypeContainer > xTypeCntr( xCooSys, uno::UNO_QUERY );
+ if( xTypeCntr.is() )
{
- uno::Reference< chart2::XDiagram > xDia( xChartDoc->getFirstDiagram() );
- if(xDia.is())
+ Sequence< Reference< XChartType > > aChartTypes( xTypeCntr->getChartTypes() );
+ for( sal_Int32 nN=0; nN<aChartTypes.getLength(); nN++ )
{
- Reference< data::XLabeledDataSequence > xCategories( DiagramHelper::getCategoriesFromDiagram( xDia ) );
- if( xCategories.is() )
- aRet = DataSequenceToStringSequence(xCategories->getValues());
- if( !aRet.getLength() )
- {
- /*
- //unused ranges are very problematic as they bear the risk to damage the rectangular structure completly
- if( bUseUnusedDataAlso )
- {
- Sequence< Reference< chart2::data::XLabeledDataSequence > > aUnusedSequences( xDia->getUnusedData() );
- ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aUnusedCategoryVector(
- DataSeriesHelper::getAllDataSequencesByRole( aUnusedSequences, C2U("categories") ) );
- if( aUnusedCategoryVector.size() && aUnusedCategoryVector[0].is() )
- aRet = DataSequenceToStringSequence(aUnusedCategoryVector[0]->getValues());
- }
- */
- if( !aRet.getLength() )
- {
- Reference< XCoordinateSystemContainer > xCooSysCnt( xDia, uno::UNO_QUERY );
- if( xCooSysCnt.is() )
- {
- Sequence< Reference< XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems() );
- if( aCooSysSeq.getLength() )
- aRet = DiagramHelper::generateAutomaticCategories( aCooSysSeq[0] );
- }
- }
- }
+ lcl_generateAutomaticCategoriesFromChartType( aRet, aChartTypes[nN] );
+ if( aRet.getLength() )
+ return aRet;
}
}
return aRet;
}
//static
-Sequence< rtl::OUString > DiagramHelper::generateAutomaticCategories(
- const Reference< XCoordinateSystem > & xCooSys )
+Sequence< rtl::OUString > DiagramHelper::getExplicitSimpleCategories(
+ const Reference< XChartDocument >& xChartDoc )
{
Sequence< rtl::OUString > aRet;
-
- Reference< XChartTypeContainer > xTypeCntr( xCooSys, uno::UNO_QUERY );
- if( xTypeCntr.is() )
+ uno::Reference< frame::XModel > xChartModel( xChartDoc, uno::UNO_QUERY );
+ if(xChartModel.is())
{
- Sequence< Reference< XChartType > > aChartTypes( xTypeCntr->getChartTypes() );
- for( sal_Int32 nN=0; nN<aChartTypes.getLength(); nN++ )
- {
- DiagramHelper::generateAutomaticCategoriesFromChartType( aRet, aChartTypes[nN] );
- if( aRet.getLength() )
- return aRet;
- }
+ uno::Reference< chart2::XCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( xChartModel ) );
+ ExplicitCategoriesProvider aExplicitCategoriesProvider( xCooSys, xChartModel );
+ aRet = aExplicitCategoriesProvider.getSimpleCategories();
}
return aRet;
}
diff --git a/chart2/source/tools/ExplicitCategoriesProvider.cxx b/chart2/source/tools/ExplicitCategoriesProvider.cxx
index cd4b0334f117..bd1c1bb79813 100644
--- a/chart2/source/tools/ExplicitCategoriesProvider.cxx
+++ b/chart2/source/tools/ExplicitCategoriesProvider.cxx
@@ -31,6 +31,10 @@
#include "ExplicitCategoriesProvider.hxx"
#include "DiagramHelper.hxx"
#include "CommonConverters.hxx"
+#include "DataSourceHelper.hxx"
+#include "ChartModelHelper.hxx"
+#include "ContainerHelper.hxx"
+#include "macros.hxx"
//.............................................................................
namespace chart
@@ -41,18 +45,88 @@ using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
-using rtl::OUString;
+using ::rtl::OUString;
+using ::std::vector;
-ExplicitCategoriesProvider::ExplicitCategoriesProvider( const Reference< chart2::XCoordinateSystem >& xCooSysModel )
+
+ExplicitCategoriesProvider::ExplicitCategoriesProvider( const Reference< chart2::XCoordinateSystem >& xCooSysModel
+ , const uno::Reference< frame::XModel >& xChartModel )
: m_bDirty(true)
, m_xCooSysModel( xCooSysModel )
- , m_xCategories()
+ , m_xOriginalCategories()
{
- if( xCooSysModel.is() )
+ try
+ {
+ if( xCooSysModel.is() )
+ {
+ uno::Reference< XAxis > xAxis( xCooSysModel->getAxisByDimension(0,0) );
+ if( xAxis.is() )
+ m_xOriginalCategories = xAxis->getScaleData().Categories;
+ }
+
+ if( m_xOriginalCategories.is() )
+ {
+ Reference< chart2::XChartDocument > xChartDoc( xChartModel, uno::UNO_QUERY );
+ if( xChartDoc.is() )
+ {
+ uno::Reference< data::XDataProvider > xDataProvider( xChartDoc->getDataProvider() );
+
+ if( xDataProvider.is() )
+ {
+ OUString aCatgoriesRange( DataSourceHelper::getRangeFromValues( m_xOriginalCategories ) );
+ const bool bFirstCellAsLabel = false;
+ const bool bHasCategories = false;
+ const uno::Sequence< sal_Int32 > aSequenceMapping;
+
+ uno::Reference< data::XDataSource > xColumnCategoriesSource( xDataProvider->createDataSource(
+ DataSourceHelper::createArguments( aCatgoriesRange, aSequenceMapping, true /*bUseColumns*/
+ , bFirstCellAsLabel, bHasCategories ) ) );
+
+ uno::Reference< data::XDataSource > xRowCategoriesSource( xDataProvider->createDataSource(
+ DataSourceHelper::createArguments( aCatgoriesRange, aSequenceMapping, false /*bUseColumns*/
+ , bFirstCellAsLabel, bHasCategories ) ) );
+
+ if( xColumnCategoriesSource.is() && xRowCategoriesSource.is() )
+ {
+ Sequence< Reference< data::XLabeledDataSequence> > aColumns = xColumnCategoriesSource->getDataSequences();
+ Sequence< Reference< data::XLabeledDataSequence> > aRows = xRowCategoriesSource->getDataSequences();
+
+ sal_Int32 nColumnCount = aColumns.getLength();
+ sal_Int32 nRowCount = aRows.getLength();
+ if( nColumnCount>1 && nRowCount>1 )
+ {
+ //we have complex categories
+ //->split them in the direction of the first series
+ //detect whether the first series is a row or a column
+ bool bSeriesUsesColumns = true;
+ ::std::vector< Reference< XDataSeries > > aSeries( ChartModelHelper::getDataSeries( xChartModel ) );
+ if( !aSeries.empty() )
+ {
+ uno::Reference< data::XDataSource > xSeriesSource( aSeries.front(), uno::UNO_QUERY );
+ ::rtl::OUString aStringDummy;
+ bool bDummy;
+ uno::Sequence< sal_Int32 > aSeqDummy;
+ DataSourceHelper::readArguments( xDataProvider->detectArguments( xSeriesSource),
+ aStringDummy, aSeqDummy, bSeriesUsesColumns, bDummy, bDummy );
+ }
+ if( bSeriesUsesColumns )
+ m_aSplitCategoriesList=aColumns;
+ else
+ m_aSplitCategoriesList=aRows;
+ }
+ }
+ }
+ }
+ if( !m_aSplitCategoriesList.getLength() )
+ {
+ m_aSplitCategoriesList.realloc(1);
+ m_aSplitCategoriesList[0]=m_xOriginalCategories;
+ }
+ }
+ }
+ catch( const uno::Exception & ex )
{
- uno::Reference< XAxis > xAxis( xCooSysModel->getAxisByDimension(0,0) );
- if( xAxis.is() )
- m_xCategories = xAxis->getScaleData().Categories;
+ ASSERT_EXCEPTION( ex );
}
}
@@ -60,34 +134,285 @@ ExplicitCategoriesProvider::~ExplicitCategoriesProvider()
{
}
-//XTextualDataSequence
-Sequence< ::rtl::OUString > SAL_CALL ExplicitCategoriesProvider::getTextualData() throw( uno::RuntimeException)
+const Sequence< Reference< data::XLabeledDataSequence> >& ExplicitCategoriesProvider::getSplitCategoriesList()
+{
+ return m_aSplitCategoriesList;
+}
+
+bool ExplicitCategoriesProvider::hasComplexCategories() const
+{
+ return m_aSplitCategoriesList.getLength() > 1;
+}
+
+sal_Int32 ExplicitCategoriesProvider::getCategoryLevelCount() const
+{
+ sal_Int32 nCount = m_aSplitCategoriesList.getLength();
+ if(!nCount)
+ nCount = 1;
+ return nCount;
+}
+
+std::vector<sal_Int32> lcl_getLimitingBorders( const std::vector< ComplexCategory >& rComplexCategories )
+{
+ std::vector<sal_Int32> aLimitingBorders;
+ std::vector< ComplexCategory >::const_iterator aIt( rComplexCategories.begin() );
+ std::vector< ComplexCategory >::const_iterator aEnd( rComplexCategories.end() );
+ sal_Int32 nBorderIndex = 0; /*border below the index*/
+ for( ; aIt != aEnd; ++aIt )
+ {
+ ComplexCategory aComplexCategory(*aIt);
+ nBorderIndex += aComplexCategory.Count;
+ aLimitingBorders.push_back(nBorderIndex);
+ }
+ return aLimitingBorders;
+}
+
+uno::Sequence< rtl::OUString > lcl_DataToStringSequence( const uno::Reference< data::XDataSequence >& xDataSequence )
+{
+ uno::Sequence< rtl::OUString > aStrings;
+
+ OSL_ASSERT( xDataSequence.is());
+ if( !xDataSequence.is() )
+ return aStrings;
+
+
+ uno::Reference< data::XTextualDataSequence > xTextualDataSequence( xDataSequence, uno::UNO_QUERY );
+ if( xTextualDataSequence.is() )
+ {
+ aStrings = xTextualDataSequence->getTextualData();
+ }
+ else
+ {
+ uno::Sequence< uno::Any > aValues = xDataSequence->getData();
+ aStrings.realloc(aValues.getLength());
+
+ for(sal_Int32 nN=aValues.getLength();nN--;)
+ aValues[nN] >>= aStrings[nN];
+ }
+
+ return aStrings;
+}
+
+SplitCategoriesProvider::~SplitCategoriesProvider()
+{
+}
+
+class SplitCategoriesProvider_ForLabeledDataSequences : public SplitCategoriesProvider
+{
+public:
+
+ explicit SplitCategoriesProvider_ForLabeledDataSequences( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::data::XLabeledDataSequence> >& rSplitCategoriesList )
+ : m_rSplitCategoriesList( rSplitCategoriesList )
+ {}
+ virtual ~SplitCategoriesProvider_ForLabeledDataSequences()
+ {}
+
+ virtual sal_Int32 getLevelCount() const;
+ virtual uno::Sequence< rtl::OUString > getStringsForLevel( sal_Int32 nIndex ) const;
+
+private:
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::data::XLabeledDataSequence> >& m_rSplitCategoriesList;
+};
+
+sal_Int32 SplitCategoriesProvider_ForLabeledDataSequences::getLevelCount() const
+{
+ return m_rSplitCategoriesList.getLength();
+}
+uno::Sequence< rtl::OUString > SplitCategoriesProvider_ForLabeledDataSequences::getStringsForLevel( sal_Int32 nLevel ) const
+{
+ uno::Sequence< rtl::OUString > aRet;
+ Reference< data::XLabeledDataSequence > xLabeledDataSequence( m_rSplitCategoriesList[nLevel] );
+ if( xLabeledDataSequence.is() )
+ aRet = lcl_DataToStringSequence( xLabeledDataSequence->getValues() );
+ return aRet;
+}
+
+std::vector< ComplexCategory > lcl_DataSequenceToComplexCategoryVector(
+ const uno::Sequence< rtl::OUString >& rStrings
+ , const std::vector<sal_Int32>& rLimitingBorders, bool bCreateSingleCategories )
+{
+ std::vector< ComplexCategory > aResult;
+
+ sal_Int32 nMaxCount = rStrings.getLength();
+ OUString aPrevious;
+ sal_Int32 nCurrentCount=0;
+ for( sal_Int32 nN=0; nN<nMaxCount; nN++ )
+ {
+ OUString aCurrent = rStrings[nN];
+ if( bCreateSingleCategories || ::std::find( rLimitingBorders.begin(), rLimitingBorders.end(), nN ) != rLimitingBorders.end() )
+ {
+ aResult.push_back( ComplexCategory(aPrevious,nCurrentCount) );
+ nCurrentCount=1;
+ aPrevious = aCurrent;
+ }
+ else
+ {
+ if( aCurrent.getLength() && aPrevious != aCurrent )
+ {
+ aResult.push_back( ComplexCategory(aPrevious,nCurrentCount) );
+ nCurrentCount=1;
+ aPrevious = aCurrent;
+ }
+ else
+ nCurrentCount++;
+ }
+ }
+ if( nCurrentCount )
+ aResult.push_back( ComplexCategory(aPrevious,nCurrentCount) );
+
+ return aResult;
+}
+
+sal_Int32 lcl_getCategoryCount( std::vector< ComplexCategory >& rComplexCategories )
+{
+ sal_Int32 nCount = 0;
+ std::vector< ComplexCategory >::iterator aIt( rComplexCategories.begin() );
+ std::vector< ComplexCategory >::const_iterator aEnd( rComplexCategories.end() );
+ for( ; aIt != aEnd; ++aIt )
+ nCount+=aIt->Count;
+ return nCount;
+}
+
+Sequence< OUString > lcl_getExplicitSimpleCategories(
+ const SplitCategoriesProvider& rSplitCategoriesProvider,
+ ::std::vector< ::std::vector< ComplexCategory > >& rComplexCats )
+{
+ Sequence< OUString > aRet;
+
+ rComplexCats.clear();
+ sal_Int32 nLCount = rSplitCategoriesProvider.getLevelCount();
+ for( sal_Int32 nL = 0; nL < nLCount; nL++ )
+ {
+ std::vector<sal_Int32> aLimitingBorders;
+ if(nL>0)
+ aLimitingBorders = lcl_getLimitingBorders( rComplexCats.back() );
+ rComplexCats.push_back( lcl_DataSequenceToComplexCategoryVector(
+ rSplitCategoriesProvider.getStringsForLevel(nL), aLimitingBorders, nL==(nLCount-1) ) );
+ }
+
+ std::vector< std::vector< ComplexCategory > >::iterator aOuterIt( rComplexCats.begin() );
+ std::vector< std::vector< ComplexCategory > >::const_iterator aOuterEnd( rComplexCats.end() );
+
+ //ensure that the category count is the same on each level
+ sal_Int32 nMaxCategoryCount = 0;
+ {
+ for( aOuterIt=rComplexCats.begin(); aOuterIt != aOuterEnd; ++aOuterIt )
+ {
+ sal_Int32 nCurrentCount = lcl_getCategoryCount( *aOuterIt );
+ nMaxCategoryCount = std::max( nCurrentCount, nMaxCategoryCount );
+ }
+ for( aOuterIt=rComplexCats.begin(); aOuterIt != aOuterEnd; ++aOuterIt )
+ {
+ sal_Int32 nCurrentCount = lcl_getCategoryCount( *aOuterIt );
+ if( nCurrentCount< nMaxCategoryCount )
+ {
+ ComplexCategory& rComplexCategory = aOuterIt->back();
+ rComplexCategory.Count += (nMaxCategoryCount-nCurrentCount);
+ }
+ }
+ }
+
+ //create a list with an element for every index
+ std::vector< std::vector< ComplexCategory > > aComplexCatsPerIndex;
+ for( aOuterIt=rComplexCats.begin() ; aOuterIt != aOuterEnd; ++aOuterIt )
+ {
+ std::vector< ComplexCategory > aSingleLevel;
+ std::vector< ComplexCategory >::iterator aIt( aOuterIt->begin() );
+ std::vector< ComplexCategory >::const_iterator aEnd( aOuterIt->end() );
+ for( ; aIt != aEnd; ++aIt )
+ {
+ ComplexCategory aComplexCategory( *aIt );
+ sal_Int32 nCount = aComplexCategory.Count;
+ while( nCount-- )
+ aSingleLevel.push_back(aComplexCategory);
+ }
+ aComplexCatsPerIndex.push_back( aSingleLevel );
+ }
+
+ if(nMaxCategoryCount)
+ {
+ aRet.realloc(nMaxCategoryCount);
+ aOuterEnd = aComplexCatsPerIndex.end();
+ OUString aSpace(C2U(" "));
+ for(sal_Int32 nN=0; nN<nMaxCategoryCount; nN++)
+ {
+ OUString aText;
+ for( aOuterIt=aComplexCatsPerIndex.begin() ; aOuterIt != aOuterEnd; ++aOuterIt )
+ {
+ OUString aAddText = (*aOuterIt)[nN].Text;
+ if( aAddText.getLength() )
+ {
+ if(aText.getLength())
+ aText += aSpace;
+ aText += aAddText;
+ }
+ }
+ aRet[nN]=aText;
+ }
+ }
+ return aRet;
+}
+
+//static
+Sequence< OUString > ExplicitCategoriesProvider::getExplicitSimpleCategories(
+ const SplitCategoriesProvider& rSplitCategoriesProvider )
+{
+ vector< vector< ComplexCategory > > aComplexCats;
+ return lcl_getExplicitSimpleCategories( rSplitCategoriesProvider, aComplexCats );
+}
+
+void ExplicitCategoriesProvider::init()
{
if( m_bDirty )
{
- if( m_xCategories.is() )
- m_aExplicitCategories = DataSequenceToStringSequence(m_xCategories->getValues());
+ m_aExplicitCategories.realloc(0);
+ m_aComplexCats.clear();//not one per index
+
+ if( m_xOriginalCategories.is() )
+ {
+ if( !hasComplexCategories() )
+ m_aExplicitCategories = DataSequenceToStringSequence(m_xOriginalCategories->getValues());
+ else
+ m_aExplicitCategories = lcl_getExplicitSimpleCategories(
+ SplitCategoriesProvider_ForLabeledDataSequences( m_aSplitCategoriesList ), m_aComplexCats );
+ }
if(!m_aExplicitCategories.getLength())
- m_aExplicitCategories = DiagramHelper::generateAutomaticCategories( uno::Reference< chart2::XCoordinateSystem >( m_xCooSysModel.get(), uno::UNO_QUERY ) );
+ m_aExplicitCategories = DiagramHelper::generateAutomaticCategoriesFromCooSys( m_xCooSysModel );
m_bDirty = false;
}
+}
+
+
+Sequence< ::rtl::OUString > ExplicitCategoriesProvider::getSimpleCategories()
+{
+ init();
return m_aExplicitCategories;
}
+std::vector< ComplexCategory > ExplicitCategoriesProvider::getCategoriesByLevel( sal_Int32 nLevel )
+{
+ std::vector< ComplexCategory > aRet;
+ init();
+ sal_Int32 nMaxIndex = m_aComplexCats.size()-1;
+ if( nLevel >= 0 && nLevel <= nMaxIndex )
+ aRet = m_aComplexCats[nMaxIndex-nLevel];
+ return aRet;
+}
+
// static
OUString ExplicitCategoriesProvider::getCategoryByIndex(
- const Reference< XCoordinateSystem >& xCooSysModel,
- sal_Int32 nIndex )
+ const Reference< XCoordinateSystem >& xCooSysModel
+ , const uno::Reference< frame::XModel >& xChartModel
+ , sal_Int32 nIndex )
{
if( xCooSysModel.is())
{
- Reference< XTextualDataSequence > xTemp( new ExplicitCategoriesProvider( xCooSysModel ));
- if( xTemp.is())
- {
- Sequence< OUString > aCategories( xTemp->getTextualData());
- if( nIndex < aCategories.getLength())
- return aCategories[ nIndex ];
- }
+ ExplicitCategoriesProvider aExplicitCategoriesProvider( xCooSysModel, xChartModel );
+ Sequence< OUString > aCategories( aExplicitCategoriesProvider.getSimpleCategories());
+ if( nIndex < aCategories.getLength())
+ return aCategories[ nIndex ];
}
return OUString();
}
diff --git a/chart2/source/tools/InternalData.cxx b/chart2/source/tools/InternalData.cxx
new file mode 100644
index 000000000000..65fc97a04b38
--- /dev/null
+++ b/chart2/source/tools/InternalData.cxx
@@ -0,0 +1,530 @@
+/*************************************************************************
+ *
+ * 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 "InternalData.hxx"
+#include "ResId.hxx"
+#include "Strings.hrc"
+#include "macros.hxx"
+
+#include <rtl/math.hxx>
+
+using ::com::sun::star::uno::Sequence;
+using ::rtl::OUString;
+
+using namespace ::std;
+
+namespace chart
+{
+
+// ----------------------------------------
+namespace
+{
+struct lcl_NumberedStringGenerator
+{
+ lcl_NumberedStringGenerator( const OUString & rStub, const OUString & rWildcard ) :
+ m_aStub( rStub ),
+ m_nCounter( 0 ),
+ m_nStubStartIndex( rStub.indexOf( rWildcard )),
+ m_nWildcardLength( rWildcard.getLength())
+ {
+ }
+ vector< OUString > operator()()
+ {
+ vector< OUString > aRet(1);
+ aRet[0] = m_aStub.replaceAt( m_nStubStartIndex, m_nWildcardLength, OUString::valueOf( ++m_nCounter ));
+ return aRet;
+ }
+private:
+ OUString m_aStub;
+ sal_Int32 m_nCounter;
+ const sal_Int32 m_nStubStartIndex;
+ const sal_Int32 m_nWildcardLength;
+};
+
+template< typename T >
+ Sequence< T > lcl_ValarrayToSequence( const ::std::valarray< T > & rValarray )
+{
+ // is there a more elegant way of conversion?
+ Sequence< T > aResult( rValarray.size());
+ for( size_t i = 0; i < rValarray.size(); ++i )
+ aResult[i] = rValarray[i];
+ return aResult;
+}
+
+} // anonymous namespace
+// ----------------------------------------
+
+InternalData::InternalData()
+ : m_nColumnCount( 0 )
+ , m_nRowCount( 0 )
+ , m_aRowLabels( 0 )
+ , m_aColumnLabels( 0 )
+{}
+
+void InternalData::createDefaultData()
+{
+ const sal_Int32 nRowCount = 4;
+ const sal_Int32 nColumnCount = 3;
+
+ m_nRowCount = nRowCount;
+ m_nColumnCount = nColumnCount;
+ const sal_Int32 nSize = nColumnCount * nRowCount;
+ // @todo: localize this!
+ const OUString aRowName( ::chart::SchResId::getResString( STR_ROW_LABEL ));
+ const OUString aColName( ::chart::SchResId::getResString( STR_COLUMN_LABEL ));
+
+ const double fDefaultData[ nSize ] =
+ { 9.10, 3.20, 4.54,
+ 2.40, 8.80, 9.65,
+ 3.10, 1.50, 3.70,
+ 4.30, 9.02, 6.20 };
+
+ m_aData.resize( nSize );
+ for( sal_Int32 i=0; i<nSize; ++i )
+ m_aData[i] = fDefaultData[i];
+
+ m_aRowLabels.clear();
+ m_aRowLabels.reserve( m_nRowCount );
+ generate_n( back_inserter( m_aRowLabels ), m_nRowCount,
+ lcl_NumberedStringGenerator( aRowName, C2U("%ROWNUMBER") ));
+
+ m_aColumnLabels.clear();
+ m_aColumnLabels.reserve( m_nColumnCount );
+ generate_n( back_inserter( m_aColumnLabels ), m_nColumnCount,
+ lcl_NumberedStringGenerator( aColName, C2U("%COLUMNNUMBER") ));
+}
+
+void InternalData::setData( const Sequence< Sequence< double > >& rDataInRows )
+{
+ m_nRowCount = rDataInRows.getLength();
+ m_nColumnCount = (m_nRowCount ? rDataInRows[0].getLength() : 0);
+
+ if( m_aRowLabels.size() != static_cast< sal_uInt32 >( m_nRowCount ))
+ m_aRowLabels.resize( m_nRowCount );
+ if( m_aColumnLabels.size() != static_cast< sal_uInt32 >( m_nColumnCount ))
+ m_aColumnLabels.resize( m_nColumnCount );
+
+ m_aData.resize( m_nRowCount * m_nColumnCount );
+ double fNan;
+ ::rtl::math::setNan( & fNan );
+ // set all values to Nan
+ m_aData = fNan;
+
+ for( sal_Int32 nRow=0; nRow<m_nRowCount; ++nRow )
+ {
+ int nDataIdx = nRow*m_nColumnCount;
+ const sal_Int32 nMax = ::std::min( rDataInRows[nRow].getLength(), m_nColumnCount );
+ for( sal_Int32 nCol=0; nCol < nMax; ++nCol )
+ {
+ m_aData[nDataIdx] = rDataInRows[nRow][nCol];
+ nDataIdx += 1;
+ }
+ }
+}
+
+Sequence< Sequence< double > > InternalData::getData() const
+{
+ Sequence< Sequence< double > > aResult( m_nRowCount );
+
+ for( sal_Int32 i=0; i<m_nRowCount; ++i )
+ aResult[i] = lcl_ValarrayToSequence< tDataType::value_type >(
+ m_aData[ ::std::slice( i*m_nColumnCount, m_nColumnCount, 1 ) ] );
+
+ return aResult;
+}
+
+Sequence< double > InternalData::getColumnValues( sal_Int32 nColumnIndex ) const
+{
+ if( nColumnIndex >= 0 && nColumnIndex < m_nColumnCount )
+ return lcl_ValarrayToSequence< tDataType::value_type >(
+ m_aData[ ::std::slice( nColumnIndex, m_nRowCount, m_nColumnCount ) ] );
+ return Sequence< double >();
+}
+Sequence< double > InternalData::getRowValues( sal_Int32 nRowIndex ) const
+{
+ if( nRowIndex >= 0 && nRowIndex < m_nRowCount )
+ return lcl_ValarrayToSequence< tDataType::value_type >(
+ m_aData[ ::std::slice( nRowIndex*m_nColumnCount, m_nColumnCount, 1 ) ] );
+ return Sequence< double >();
+}
+
+void InternalData::setColumnValues( sal_Int32 nColumnIndex, const vector< double > & rNewData )
+{
+ if( nColumnIndex < 0 )
+ return;
+ enlargeData( nColumnIndex + 1, rNewData.size() );
+
+ tDataType aSlice = m_aData[ ::std::slice( nColumnIndex, m_nRowCount, m_nColumnCount ) ];
+ for( vector< double >::size_type i = 0; i < rNewData.size(); ++i )
+ aSlice[i] = rNewData[i];
+ m_aData[ ::std::slice( nColumnIndex, m_nRowCount, m_nColumnCount ) ] = aSlice;
+}
+
+void InternalData::setRowValues( sal_Int32 nRowIndex, const vector< double > & rNewData )
+{
+ if( nRowIndex < 0 )
+ return;
+ enlargeData( rNewData.size(), nRowIndex+1 );
+
+ tDataType aSlice = m_aData[ ::std::slice( nRowIndex*m_nColumnCount, m_nColumnCount, 1 ) ];
+ for( vector< double >::size_type i = 0; i < rNewData.size(); ++i )
+ aSlice[i] = rNewData[i];
+ m_aData[ ::std::slice( nRowIndex*m_nColumnCount, m_nColumnCount, 1 ) ]= aSlice;
+}
+
+void InternalData::setComplexColumnLabel( sal_Int32 nColumnIndex, const vector< OUString >& rComplexLabel )
+{
+ if( nColumnIndex < 0 )
+ return;
+ if( nColumnIndex >= static_cast< sal_Int32 >( m_aColumnLabels.size() ) )
+ {
+ m_aColumnLabels.resize(nColumnIndex+1);
+ enlargeData( nColumnIndex+1, 0 );
+ }
+
+ m_aColumnLabels[nColumnIndex]=rComplexLabel;
+}
+void InternalData::setComplexRowLabel( sal_Int32 nRowIndex, const vector< OUString >& rComplexLabel )
+{
+ if( nRowIndex < 0 )
+ return;
+ if( nRowIndex >= static_cast< sal_Int32 >( m_aRowLabels.size() ) )
+ {
+ m_aRowLabels.resize(nRowIndex+1);
+ enlargeData( 0, nRowIndex+1 );
+ }
+
+ m_aRowLabels[nRowIndex] = rComplexLabel;
+}
+
+vector< OUString > InternalData::getComplexColumnLabel( sal_Int32 nColumnIndex ) const
+{
+ if( nColumnIndex < static_cast< sal_Int32 >( m_aColumnLabels.size() ) )
+ return m_aColumnLabels[nColumnIndex];
+ else
+ return vector< OUString >();
+}
+vector< OUString > InternalData::getComplexRowLabel( sal_Int32 nRowIndex ) const
+{
+ if( nRowIndex < static_cast< sal_Int32 >( m_aRowLabels.size() ) )
+ return m_aRowLabels[nRowIndex];
+ else
+ return vector< OUString >();
+}
+
+void InternalData::swapRowWithNext( sal_Int32 nRowIndex )
+{
+ if( nRowIndex < m_nRowCount - 1 )
+ {
+ const sal_Int32 nMax = m_nColumnCount;
+ for( sal_Int32 nColIdx=0; nColIdx<nMax; ++nColIdx )
+ {
+ size_t nIndex1 = nColIdx + nRowIndex*m_nColumnCount;
+ size_t nIndex2 = nIndex1 + m_nColumnCount;
+ double fTemp = m_aData[nIndex1];
+ m_aData[nIndex1] = m_aData[nIndex2];
+ m_aData[nIndex2] = fTemp;
+ }
+
+ vector< OUString > aTemp( m_aRowLabels[nRowIndex] );
+ m_aRowLabels[nRowIndex] = m_aRowLabels[nRowIndex + 1];
+ m_aRowLabels[nRowIndex + 1] = aTemp;
+ }
+}
+
+void InternalData::swapColumnWithNext( sal_Int32 nColumnIndex )
+{
+ if( nColumnIndex < m_nColumnCount - 1 )
+ {
+ const sal_Int32 nMax = m_nRowCount;
+ for( sal_Int32 nRowIdx=0; nRowIdx<nMax; ++nRowIdx )
+ {
+ size_t nIndex1 = nColumnIndex + nRowIdx*m_nColumnCount;
+ size_t nIndex2 = nIndex1 + 1;
+ double fTemp = m_aData[nIndex1];
+ m_aData[nIndex1] = m_aData[nIndex2];
+ m_aData[nIndex2] = fTemp;
+ }
+
+ vector< OUString > aTemp( m_aColumnLabels[nColumnIndex] );
+ m_aColumnLabels[nColumnIndex] = m_aColumnLabels[nColumnIndex + 1];
+ m_aColumnLabels[nColumnIndex + 1] = aTemp;
+ }
+}
+
+bool InternalData::enlargeData( sal_Int32 nColumnCount, sal_Int32 nRowCount )
+{
+ sal_Int32 nNewColumnCount( ::std::max<sal_Int32>( m_nColumnCount, nColumnCount ) );
+ sal_Int32 nNewRowCount( ::std::max<sal_Int32>( m_nRowCount, nRowCount ) );
+ sal_Int32 nNewSize( nNewColumnCount*nNewRowCount );
+
+ bool bGrow = (nNewSize > m_nColumnCount*m_nRowCount);
+
+ if( bGrow )
+ {
+ double fNan;
+ ::rtl::math::setNan( &fNan );
+ tDataType aNewData( fNan, nNewSize );
+ // copy old data
+ for( int nCol=0; nCol<m_nColumnCount; ++nCol )
+ static_cast< tDataType >(
+ aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] ) =
+ m_aData[ ::std::slice( nCol, m_nRowCount, m_nColumnCount ) ];
+
+ m_aData.resize( nNewSize );
+ m_aData = aNewData;
+ }
+ m_nColumnCount = nNewColumnCount;
+ m_nRowCount = nNewRowCount;
+ return bGrow;
+}
+
+void InternalData::insertColumn( sal_Int32 nAfterIndex )
+{
+ // note: -1 is allowed, as we insert after the given index
+ OSL_ASSERT( nAfterIndex < m_nColumnCount && nAfterIndex >= -1 );
+ if( nAfterIndex >= m_nColumnCount || nAfterIndex < -1 )
+ return;
+ sal_Int32 nNewColumnCount = m_nColumnCount + 1;
+ sal_Int32 nNewSize( nNewColumnCount * m_nRowCount );
+
+ double fNan;
+ ::rtl::math::setNan( &fNan );
+ tDataType aNewData( fNan, nNewSize );
+
+ // copy old data
+ int nCol=0;
+ for( ; nCol<=nAfterIndex; ++nCol )
+ aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] =
+ static_cast< tDataType >(
+ m_aData[ ::std::slice( nCol, m_nRowCount, m_nColumnCount ) ] );
+ for( ++nCol; nCol<nNewColumnCount; ++nCol )
+ aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] =
+ static_cast< tDataType >(
+ m_aData[ ::std::slice( nCol - 1, m_nRowCount, m_nColumnCount ) ] );
+
+ m_nColumnCount = nNewColumnCount;
+ m_aData.resize( nNewSize );
+ m_aData = aNewData;
+
+ // labels
+ if( nAfterIndex < static_cast< sal_Int32 >( m_aColumnLabels.size()))
+ m_aColumnLabels.insert( m_aColumnLabels.begin() + (nAfterIndex + 1), vector< OUString >(1) );
+
+#if OSL_DEBUG_LEVEL > 2
+ traceData();
+#endif
+}
+
+sal_Int32 InternalData::appendColumn()
+{
+ insertColumn( getColumnCount() - 1 );
+ return getColumnCount() - 1;
+}
+
+sal_Int32 InternalData::appendRow()
+{
+ insertRow( getRowCount() - 1 );
+ return getRowCount() - 1;
+}
+
+void InternalData::insertRow( sal_Int32 nAfterIndex )
+{
+ // note: -1 is allowed, as we insert after the given index
+ OSL_ASSERT( nAfterIndex < m_nRowCount && nAfterIndex >= -1 );
+ if( nAfterIndex >= m_nRowCount || nAfterIndex < -1 )
+ return;
+ sal_Int32 nNewRowCount = m_nRowCount + 1;
+ sal_Int32 nNewSize( m_nColumnCount * nNewRowCount );
+
+ double fNan;
+ ::rtl::math::setNan( &fNan );
+ tDataType aNewData( fNan, nNewSize );
+
+ // copy old data
+ sal_Int32 nIndex = nAfterIndex + 1;
+ aNewData[ ::std::slice( 0, nIndex * m_nColumnCount, 1 ) ] =
+ static_cast< tDataType >(
+ m_aData[ ::std::slice( 0, nIndex * m_nColumnCount, 1 ) ] );
+
+ if( nIndex < m_nRowCount )
+ {
+ sal_Int32 nRemainingCount = m_nColumnCount * (m_nRowCount - nIndex);
+ aNewData[ ::std::slice( (nIndex + 1) * m_nColumnCount, nRemainingCount, 1 ) ] =
+ static_cast< tDataType >(
+ m_aData[ ::std::slice( nIndex * m_nColumnCount, nRemainingCount, 1 ) ] );
+ }
+
+ m_nRowCount = nNewRowCount;
+ m_aData.resize( nNewSize );
+ m_aData = aNewData;
+
+ // labels
+ if( nAfterIndex < static_cast< sal_Int32 >( m_aRowLabels.size()))
+ m_aRowLabels.insert( m_aRowLabels.begin() + nIndex, vector< OUString> (1));
+
+#if OSL_DEBUG_LEVEL > 2
+ traceData();
+#endif
+}
+
+void InternalData::deleteColumn( sal_Int32 nAtIndex )
+{
+ OSL_ASSERT( nAtIndex < m_nColumnCount && nAtIndex >= 0 );
+ if( nAtIndex >= m_nColumnCount || m_nColumnCount < 1 || nAtIndex < 0 )
+ return;
+ sal_Int32 nNewColumnCount = m_nColumnCount - 1;
+ sal_Int32 nNewSize( nNewColumnCount * m_nRowCount );
+
+ double fNan;
+ ::rtl::math::setNan( &fNan );
+ tDataType aNewData( fNan, nNewSize );
+
+ // copy old data
+ int nCol=0;
+ for( ; nCol<nAtIndex; ++nCol )
+ aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] =
+ static_cast< tDataType >(
+ m_aData[ ::std::slice( nCol, m_nRowCount, m_nColumnCount ) ] );
+ for( ; nCol<nNewColumnCount; ++nCol )
+ aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] =
+ static_cast< tDataType >(
+ m_aData[ ::std::slice( nCol + 1, m_nRowCount, m_nColumnCount ) ] );
+
+ m_nColumnCount = nNewColumnCount;
+ m_aData.resize( nNewSize );
+ m_aData = aNewData;
+
+ // labels
+ if( nAtIndex < static_cast< sal_Int32 >( m_aColumnLabels.size()))
+ m_aColumnLabels.erase( m_aColumnLabels.begin() + nAtIndex );
+
+#if OSL_DEBUG_LEVEL > 2
+ traceData();
+#endif
+}
+
+void InternalData::deleteRow( sal_Int32 nAtIndex )
+{
+ OSL_ASSERT( nAtIndex < m_nRowCount && nAtIndex >= 0 );
+ if( nAtIndex >= m_nRowCount || m_nRowCount < 1 || nAtIndex < 0 )
+ return;
+ sal_Int32 nNewRowCount = m_nRowCount - 1;
+ sal_Int32 nNewSize( m_nColumnCount * nNewRowCount );
+
+ double fNan;
+ ::rtl::math::setNan( &fNan );
+ tDataType aNewData( fNan, nNewSize );
+
+ // copy old data
+ sal_Int32 nIndex = nAtIndex;
+ if( nIndex )
+ aNewData[ ::std::slice( 0, nIndex * m_nColumnCount, 1 ) ] =
+ static_cast< tDataType >(
+ m_aData[ ::std::slice( 0, nIndex * m_nColumnCount, 1 ) ] );
+
+ if( nIndex < nNewRowCount )
+ {
+ sal_Int32 nRemainingCount = m_nColumnCount * (nNewRowCount - nIndex);
+ aNewData[ ::std::slice( nIndex * m_nColumnCount, nRemainingCount, 1 ) ] =
+ static_cast< tDataType >(
+ m_aData[ ::std::slice( (nIndex + 1) * m_nColumnCount, nRemainingCount, 1 ) ] );
+ }
+
+ m_nRowCount = nNewRowCount;
+ m_aData.resize( nNewSize );
+ m_aData = aNewData;
+
+ // labels
+ if( nAtIndex < static_cast< sal_Int32 >( m_aRowLabels.size()))
+ m_aRowLabels.erase( m_aRowLabels.begin() + nAtIndex );
+
+#if OSL_DEBUG_LEVEL > 2
+ traceData();
+#endif
+}
+
+sal_Int32 InternalData::getRowCount() const
+{
+ return m_nRowCount;
+}
+
+sal_Int32 InternalData::getColumnCount() const
+{
+ return m_nColumnCount;
+}
+
+void InternalData::setComplexRowLabels( const vector< vector< OUString > >& rNewRowLabels )
+{
+ m_aRowLabels = rNewRowLabels;
+ sal_Int32 nNewRowCount = static_cast< sal_Int32 >( m_aRowLabels.size() );
+ if( nNewRowCount < m_nRowCount )
+ m_aRowLabels.resize( m_nRowCount );
+ else
+ enlargeData( 0, nNewRowCount );
+}
+
+vector< vector< OUString > > InternalData::getComplexRowLabels() const
+{
+ return m_aRowLabels;
+}
+
+void InternalData::setComplexColumnLabels( const vector< vector< OUString > >& rNewColumnLabels )
+{
+ m_aColumnLabels = rNewColumnLabels;
+ sal_Int32 nNewColumnCount = static_cast< sal_Int32 >( m_aColumnLabels.size() );
+ if( nNewColumnCount < m_nColumnCount )
+ m_aColumnLabels.resize( m_nColumnCount );
+ else
+ enlargeData( nNewColumnCount, 0 );
+}
+
+vector< vector< OUString > > InternalData::getComplexColumnLabels() const
+{
+ return m_aColumnLabels;
+}
+
+#if OSL_DEBUG_LEVEL > 2
+void InternalData::traceData() const
+{
+ OSL_TRACE( "InternalData: Data in rows\n" );
+
+ for( sal_Int32 i=0; i<m_nRowCount; ++i )
+ {
+ tDataType aSlice( m_aData[ ::std::slice( i*m_nColumnCount, m_nColumnCount, 1 ) ] );
+ for( sal_Int32 j=0; j<m_nColumnCount; ++j )
+ OSL_TRACE( "%lf ", aSlice[j] );
+ OSL_TRACE( "\n" );
+ }
+ OSL_TRACE( "\n" );
+}
+#endif
+
+} // namespace chart
diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx
index 70215623840d..4abc51be31af 100644
--- a/chart2/source/tools/InternalDataProvider.cxx
+++ b/chart2/source/tools/InternalDataProvider.cxx
@@ -45,8 +45,8 @@
#include "DataSourceHelper.hxx"
#include "ChartModelHelper.hxx"
#include "DiagramHelper.hxx"
-#include "ResId.hxx"
-#include "Strings.hrc"
+#include "ExplicitCategoriesProvider.hxx"
+
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/chart2/data/XDataSequence.hpp>
#include <com/sun/star/chart/ChartDataRowSource.hpp>
@@ -67,774 +67,327 @@ using ::rtl::OUStringBuffer;
namespace chart
{
-namespace impl
-{
-
-
-struct OUStringBufferAppend : public unary_function< OUString, void >
-{
- OUStringBufferAppend( OUStringBuffer & rBuffer, const OUString & rSeparator ) :
- m_rBuffer( rBuffer ),
- m_aSep( rSeparator )
- {}
- void operator() ( const OUString & rStr )
- {
- m_rBuffer.append( m_aSep );
- m_rBuffer.append( rStr );
- }
-private:
- OUStringBuffer m_rBuffer;
- OUString m_aSep;
-};
-
-OUString FlattenStringSequence( const Sequence< OUString > & aSeq )
-{
- if( aSeq.getLength() == 0 )
- return OUString();
- OUStringBuffer aBuf( aSeq[0] );
- for_each( aSeq.getConstArray() + 1, aSeq.getConstArray() + aSeq.getLength(),
- OUStringBufferAppend( aBuf, OUString(RTL_CONSTASCII_USTRINGPARAM(" "))));
- return aBuf.makeStringAndClear();
-}
-
-class InternalData
-{
-public:
- InternalData();
-
- void createDefaultData();
-
- void setData( const Sequence< Sequence< double > > & rNewData, bool bDataInColumns );
- Sequence< Sequence< double > > getData( bool bDataInColumns ) const;
- Sequence< double > getDataAt( sal_Int32 nIndex, bool bDataInColumns ) const;
- void setDataAt( sal_Int32 nIndex, bool bDataInColumns, const ::std::vector< double > & rNewData );
- void swapAllDataAtIndexWithNext( sal_Int32 nAtIndex, bool bDataInColumns );
-
- /** resizes the data if at least one of the given dimensions is larger than
- before. The data is never becoming smaller only larger.
-
- @return </TRUE>, if the data was enlarged
- */
- bool enlargeData( sal_Int32 nColumnCount, sal_Int32 nRowCount );
-
- void insertColumn( sal_Int32 nAfterIndex );
- void insertRow( sal_Int32 nAfterIndex );
- void deleteColumn( sal_Int32 nAtIndex );
- void deleteRow( sal_Int32 nAtIndex );
-
- /// @return the index of the newly appended column
- sal_Int32 appendColumn();
- /// @return the index of the newly appended row
- sal_Int32 appendRow();
-
- sal_Int32 getRowCount() const;
- sal_Int32 getColumnCount() const;
-
- void setRowLabels( const ::std::vector< OUString > & rNewRowLabels );
- ::std::vector< OUString > getRowLabels() const;
- void setColumnLabels( const ::std::vector< OUString > & rNewColumnLabels );
- ::std::vector< OUString > getColumnLabels() const;
-
-#if OSL_DEBUG_LEVEL > 2
- void traceData() const;
-#endif
-private:
- sal_Int32 m_nColumnCount;
- sal_Int32 m_nRowCount;
-
- typedef ::std::valarray< double > tDataType;
- typedef ::std::vector< OUString > tLabelType;
-
- tDataType m_aData;
- tLabelType m_aRowLabels;
- tLabelType m_aColumnLabels;
-};
+// ================================================================================
-// ----------------------------------------
namespace
{
-struct lcl_NumberedStringGenerator
-{
- lcl_NumberedStringGenerator( const OUString & rStub, const OUString & rWildcard ) :
- m_aStub( rStub ),
- m_nCounter( 0 ),
- m_nStubStartIndex( rStub.indexOf( rWildcard )),
- m_nWildcardLength( rWildcard.getLength())
- {
- }
- OUString operator()() {
- return m_aStub.replaceAt( m_nStubStartIndex, m_nWildcardLength, OUString::valueOf( ++m_nCounter ));
- }
-private:
- OUString m_aStub;
- sal_Int32 m_nCounter;
- const sal_Int32 m_nStubStartIndex;
- const sal_Int32 m_nWildcardLength;
-};
-
-template< typename T >
- Sequence< T > lcl_ValarrayToSequence( const ::std::valarray< T > & rValarray )
-{
- // is there a more elegant way of conversion?
- Sequence< T > aResult( rValarray.size());
- for( size_t i = 0; i < rValarray.size(); ++i )
- aResult[i] = rValarray[i];
- return aResult;
-}
-
-struct lcl_ValuesOfLabeledSequence :
- public unary_function< Reference< chart2::data::XLabeledDataSequence >, Sequence< double > >
-{
- Sequence< double > operator() ( const Reference< chart2::data::XLabeledDataSequence > & xLSeq )
- {
- if( ! xLSeq.is())
- return Sequence< double >();
- return DataSequenceToDoubleSequence( xLSeq->getValues());
- }
-};
-
-struct lcl_LabelsOfLabeledSequence :
- public unary_function< Reference< chart2::data::XLabeledDataSequence >, Sequence< OUString > >
-{
- Sequence< OUString > operator() ( const Reference< chart2::data::XLabeledDataSequence > & xLSeq )
- {
- if( ! xLSeq.is())
- return Sequence< OUString >();
- return DataSequenceToStringSequence( xLSeq->getLabel());
- }
-};
-
-struct lcl_LabelOfLabeledSequence :
- public unary_function< Reference< chart2::data::XLabeledDataSequence >, OUString >
-{
- OUString operator() ( const Reference< chart2::data::XLabeledDataSequence > & xLSeq )
- {
- if( ! xLSeq.is())
- return OUString();
- return FlattenStringSequence( DataSequenceToStringSequence( xLSeq->getLabel()));
- }
-};
-} // anonymous namespace
-// ----------------------------------------
+// note: in xmloff this name is used to indicate usage of own data
+static const ::rtl::OUString lcl_aServiceName(
+ RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.InternalDataProvider" ));
-InternalData::InternalData() :
- m_nColumnCount( 0 ),
- m_nRowCount( 0 )
-{}
+static const ::rtl::OUString lcl_aCategoriesRangeName(
+ RTL_CONSTASCII_USTRINGPARAM( "categories" ));
+static const ::rtl::OUString lcl_aCategoriesLevelRangeNamePrefix(
+ RTL_CONSTASCII_USTRINGPARAM( "categoriesL " )); //L <-> level
+static const ::rtl::OUString lcl_aCategoriesPointRangeNamePrefix(
+ RTL_CONSTASCII_USTRINGPARAM( "categoriesP " )); //P <-> point
+static const ::rtl::OUString lcl_aCategoriesRoleName(
+ RTL_CONSTASCII_USTRINGPARAM( "categories" ));
+static const ::rtl::OUString lcl_aLabelRangePrefix(
+ RTL_CONSTASCII_USTRINGPARAM( "label " ));
+static const ::rtl::OUString lcl_aCompleteRange(
+ RTL_CONSTASCII_USTRINGPARAM( "all" ));
-void InternalData::createDefaultData()
-{
- const sal_Int32 nNumRows = 4;
- const sal_Int32 nNumColumns = 3;
- const sal_Int32 nSize = nNumColumns * nNumRows;
- // @todo: localize this!
- const OUString aRowName( ::chart::SchResId::getResString( STR_ROW_LABEL ));
- const OUString aColName( ::chart::SchResId::getResString( STR_COLUMN_LABEL ));
-
- const double fDefaultData[ nSize ] =
- { 9.10, 3.20, 4.54,
- 2.40, 8.80, 9.65,
- 3.10, 1.50, 3.70,
- 4.30, 9.02, 6.20 };
-
- m_aData.resize( nSize );
- for( sal_Int32 i=0; i<nSize; ++i )
- m_aData[i] = fDefaultData[i];
- m_nRowCount = nNumRows;
- m_nColumnCount = nNumColumns;
-
- vector< OUString > aRowLabels;
- aRowLabels.reserve( nNumRows );
- generate_n( back_inserter( aRowLabels ), nNumRows,
- lcl_NumberedStringGenerator( aRowName, C2U("%ROWNUMBER") ));
- setRowLabels( aRowLabels );
-
- vector< OUString > aColumnLabels;
- aColumnLabels.reserve( nNumColumns );
- generate_n( back_inserter( aColumnLabels ), nNumColumns,
- lcl_NumberedStringGenerator( aColName, C2U("%COLUMNNUMBER") ));
- setColumnLabels( aColumnLabels );
-}
+typedef ::std::multimap< OUString, uno::WeakReference< chart2::data::XDataSequence > >
+ lcl_tSequenceMap;
-void InternalData::setData( const Sequence< Sequence< double > > & rNewData, bool bDataInColumns )
+struct lcl_setModified : public ::std::unary_function< lcl_tSequenceMap, void >
{
- sal_Int32 nOuterSize = rNewData.getLength();
- sal_Int32 nInnerSize = (nOuterSize ? rNewData[0].getLength() : 0);
-
- m_nRowCount = (bDataInColumns ? nInnerSize : nOuterSize);
- m_nColumnCount = (bDataInColumns ? nOuterSize : nInnerSize);
-
- if( m_aRowLabels.size() != static_cast< sal_uInt32 >( m_nRowCount ))
- m_aRowLabels.resize( m_nRowCount );
- if( m_aColumnLabels.size() != static_cast< sal_uInt32 >( m_nColumnCount ))
- m_aColumnLabels.resize( m_nColumnCount );
-
- m_aData.resize( m_nRowCount * m_nColumnCount );
- double fNan;
- ::rtl::math::setNan( & fNan );
- // set all values to Nan
- m_aData = fNan;
-
- for( sal_Int32 nOuterIdx=0; nOuterIdx<nOuterSize; ++nOuterIdx )
+ void operator() ( const lcl_tSequenceMap::value_type & rMapEntry )
{
- int nDataIdx = (bDataInColumns ? nOuterIdx : nOuterIdx*nInnerSize);
- const sal_Int32 nMax = ::std::min( rNewData[nOuterIdx].getLength(), nInnerSize );
- sal_Int32 nInnerIdx=0;
- for( ; nInnerIdx < nMax; ++nInnerIdx )
+ // convert weak reference to reference
+ Reference< chart2::data::XDataSequence > xSeq( rMapEntry.second );
+ if( xSeq.is())
{
- m_aData[nDataIdx] = rNewData[nOuterIdx][nInnerIdx];
- nDataIdx += (bDataInColumns ? m_nColumnCount : 1);
+ Reference< util::XModifiable > xMod( xSeq, uno::UNO_QUERY );
+ if( xMod.is())
+ xMod->setModified( sal_True );
}
}
-}
-
-Sequence< Sequence< double > > InternalData::getData( bool bDataInColumns ) const
-{
- Sequence< Sequence< double > > aResult( bDataInColumns ? m_nColumnCount : m_nRowCount );
-
- if( bDataInColumns )
- {
- for( sal_Int32 i=0; i<m_nColumnCount; ++i )
- aResult[i] = lcl_ValarrayToSequence< tDataType::value_type >(
- m_aData[ ::std::slice( i, m_nRowCount, m_nColumnCount ) ] );
- }
- else
- {
- for( sal_Int32 i=0; i<m_nRowCount; ++i )
- aResult[i] = lcl_ValarrayToSequence< tDataType::value_type >(
- m_aData[ ::std::slice( i*m_nColumnCount, m_nColumnCount, 1 ) ] );
- }
-
- return aResult;
-}
-
-Sequence< double > InternalData::getDataAt( sal_Int32 nIndex, bool bDataInColumns ) const
-{
- Sequence< double > aResult( bDataInColumns ? m_nRowCount : m_nColumnCount );
-
- if( bDataInColumns )
- {
- if( nIndex < m_nColumnCount )
- return lcl_ValarrayToSequence< tDataType::value_type >(
- m_aData[ ::std::slice( nIndex, m_nRowCount, m_nColumnCount ) ] );
- }
- else
- {
- if( nIndex < m_nRowCount )
- return lcl_ValarrayToSequence< tDataType::value_type >(
- m_aData[ ::std::slice( nIndex*m_nColumnCount, m_nColumnCount, 1 ) ] );
- }
-
- return Sequence< double >();
-}
+};
-void InternalData::setDataAt( sal_Int32 nIndex, bool bDataInColumns, const ::std::vector< double > & rNewData )
+struct lcl_internalizeSeries : public ::std::unary_function< Reference< chart2::XDataSeries >, void >
{
- if( bDataInColumns )
- {
- if( nIndex < m_nColumnCount )
- {
- tDataType aSlice = m_aData[ ::std::slice( nIndex, m_nRowCount, m_nColumnCount ) ];
- for( ::std::vector< double >::size_type i = 0; i < rNewData.size(); ++i )
- aSlice[i] = rNewData[i];
- m_aData[ ::std::slice( nIndex, m_nRowCount, m_nColumnCount ) ] = aSlice;
- }
- }
- else
+ lcl_internalizeSeries( InternalData & rInternalData,
+ InternalDataProvider & rProvider,
+ bool bConnectToModel, bool bDataInColumns ) :
+ m_rInternalData( rInternalData ),
+ m_rProvider( rProvider ),
+ m_bConnectToModel( bConnectToModel ),
+ m_bDataInColumns( bDataInColumns )
+ {}
+ void operator() ( const Reference< chart2::XDataSeries > & xSeries )
{
- if( nIndex < m_nRowCount )
+ Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY );
+ Reference< chart2::data::XDataSink > xSink( xSeries, uno::UNO_QUERY );
+ if( xSource.is() && xSink.is() )
{
- tDataType aSlice = m_aData[ ::std::slice( nIndex*m_nColumnCount, m_nColumnCount, 1 ) ];
- for( ::std::vector< double >::size_type i = 0; i < rNewData.size(); ++i )
- aSlice[i] = rNewData[i];
- m_aData[ ::std::slice( nIndex*m_nColumnCount, m_nColumnCount, 1 ) ]= aSlice;
+ Sequence< Reference< chart2::data::XLabeledDataSequence > > aOldSeriesData = xSource->getDataSequences();
+ Sequence< Reference< chart2::data::XLabeledDataSequence > > aNewSeriesData( aOldSeriesData.getLength() );
+ for( sal_Int32 i=0; i<aOldSeriesData.getLength(); ++i )
+ {
+ sal_Int32 nNewIndex( m_bDataInColumns ? m_rInternalData.appendColumn() : m_rInternalData.appendRow() );
+ OUString aIdentifier( OUString::valueOf( nNewIndex ));
+ //@todo: deal also with genericXDataSequence
+ Reference< chart2::data::XNumericalDataSequence > xValues( aOldSeriesData[i]->getValues(), uno::UNO_QUERY );
+ Reference< chart2::data::XTextualDataSequence > xLabel( aOldSeriesData[i]->getLabel(), uno::UNO_QUERY );
+ Reference< chart2::data::XDataSequence > xNewValues;
+
+ if( xValues.is() )
+ {
+ ::std::vector< double > aValues( ContainerHelper::SequenceToVector( xValues->getNumericalData()));
+ if( m_bDataInColumns )
+ m_rInternalData.setColumnValues( nNewIndex, aValues );
+ else
+ m_rInternalData.setRowValues( nNewIndex, aValues );
+ if( m_bConnectToModel )
+ {
+ xNewValues.set( m_rProvider.createDataSequenceByRangeRepresentation( aIdentifier ));
+ comphelper::copyProperties(
+ Reference< beans::XPropertySet >( xValues, uno::UNO_QUERY ),
+ Reference< beans::XPropertySet >( xNewValues, uno::UNO_QUERY ));
+ }
+ }
+
+ if( xLabel.is() )
+ {
+ if( m_bDataInColumns )
+ m_rInternalData.setComplexColumnLabel( nNewIndex, ContainerHelper::SequenceToVector( xLabel->getTextualData() ) );
+ else
+ m_rInternalData.setComplexRowLabel( nNewIndex, ContainerHelper::SequenceToVector( xLabel->getTextualData() ) );
+ if( m_bConnectToModel )
+ {
+ Reference< chart2::data::XDataSequence > xNewLabel(
+ m_rProvider.createDataSequenceByRangeRepresentation( lcl_aLabelRangePrefix + aIdentifier ));
+ comphelper::copyProperties(
+ Reference< beans::XPropertySet >( xLabel, uno::UNO_QUERY ),
+ Reference< beans::XPropertySet >( xNewLabel, uno::UNO_QUERY ));
+ aNewSeriesData[i] = Reference< chart2::data::XLabeledDataSequence >(
+ new LabeledDataSequence( xNewValues, xNewLabel ));
+ }
+ }
+ else
+ {
+ if( m_bConnectToModel )
+ aNewSeriesData[i] = Reference< chart2::data::XLabeledDataSequence >(
+ new LabeledDataSequence( xNewValues ));
+ }
+ }
+ if( m_bConnectToModel )
+ xSink->setData( aNewSeriesData );
}
- }
-}
+ }
-void InternalData::swapAllDataAtIndexWithNext( sal_Int32 nAtIndex, bool bDataInColumns )
-{
- if( bDataInColumns && nAtIndex < m_nRowCount - 1 )
- {
- const sal_Int32 nMax = m_nColumnCount;
- for( sal_Int32 nColIdx=0; nColIdx<nMax; ++nColIdx )
- {
- size_t nIndex1 = nColIdx + nAtIndex*m_nColumnCount;
- size_t nIndex2 = nIndex1 + m_nColumnCount;
- double fTemp = m_aData[nIndex1];
- m_aData[nIndex1] = m_aData[nIndex2];
- m_aData[nIndex2] = fTemp;
- }
- OUString sTemp( m_aRowLabels[nAtIndex] );
- m_aRowLabels[nAtIndex] = m_aRowLabels[nAtIndex + 1];
- m_aRowLabels[nAtIndex + 1] = sTemp;
- }
- else if( nAtIndex < m_nColumnCount - 1 )
- {
- const sal_Int32 nMax = m_nRowCount;
- for( sal_Int32 nRowIdx=0; nRowIdx<nMax; ++nRowIdx )
- {
- size_t nIndex1 = nAtIndex + nRowIdx*m_nColumnCount;
- size_t nIndex2 = nIndex1 + 1;
- double fTemp = m_aData[nIndex1];
- m_aData[nIndex1] = m_aData[nIndex2];
- m_aData[nIndex2] = fTemp;
- }
- OUString sTemp( m_aColumnLabels[nAtIndex] );
- m_aColumnLabels[nAtIndex] = m_aColumnLabels[nAtIndex + 1];
- m_aColumnLabels[nAtIndex + 1] = sTemp;
- }
-}
+private:
+ InternalData & m_rInternalData;
+ InternalDataProvider & m_rProvider;
+ bool m_bConnectToModel;
+ bool m_bDataInColumns;
+};
-bool InternalData::enlargeData( sal_Int32 nColumnCount, sal_Int32 nRowCount )
+struct lcl_makeAnyFromLevelVector : public ::std::unary_function< vector< OUString >, uno::Any >
{
- sal_Int32 nNewColumnCount( ::std::max<sal_Int32>( m_nColumnCount, nColumnCount ) );
- sal_Int32 nNewRowCount( ::std::max<sal_Int32>( m_nRowCount, nRowCount ) );
- sal_Int32 nNewSize( nNewColumnCount*nNewRowCount );
+public:
- bool bGrow = (nNewSize > m_nColumnCount*m_nRowCount);
+ explicit lcl_makeAnyFromLevelVector( sal_Int32 nLevel ) : m_nLevel( nLevel )
+ {}
- if( bGrow )
+ uno::Any operator() ( const vector< OUString >& rVector )
{
- double fNan;
- ::rtl::math::setNan( &fNan );
- tDataType aNewData( fNan, nNewSize );
- // copy old data
- for( int nCol=0; nCol<m_nColumnCount; ++nCol )
- static_cast< tDataType >(
- aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] ) =
- m_aData[ ::std::slice( nCol, m_nRowCount, m_nColumnCount ) ];
-
- m_aData.resize( nNewSize );
- m_aData = aNewData;
+ OUString aString;
+ if( m_nLevel < static_cast< sal_Int32 >(rVector.size()) )
+ aString = rVector[m_nLevel];
+ return uno::makeAny( aString );
}
- m_nColumnCount = nNewColumnCount;
- m_nRowCount = nNewRowCount;
- return bGrow;
-}
-
-void InternalData::insertColumn( sal_Int32 nAfterIndex )
-{
- // note: -1 is allowed, as we insert after the given index
- OSL_ASSERT( nAfterIndex < m_nColumnCount && nAfterIndex >= -1 );
- if( nAfterIndex >= m_nColumnCount || nAfterIndex < -1 )
- return;
- sal_Int32 nNewColumnCount = m_nColumnCount + 1;
- sal_Int32 nNewSize( nNewColumnCount * m_nRowCount );
- double fNan;
- ::rtl::math::setNan( &fNan );
- tDataType aNewData( fNan, nNewSize );
-
- // copy old data
- int nCol=0;
- for( ; nCol<=nAfterIndex; ++nCol )
- aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] =
- static_cast< tDataType >(
- m_aData[ ::std::slice( nCol, m_nRowCount, m_nColumnCount ) ] );
- for( ++nCol; nCol<nNewColumnCount; ++nCol )
- aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] =
- static_cast< tDataType >(
- m_aData[ ::std::slice( nCol - 1, m_nRowCount, m_nColumnCount ) ] );
-
- m_nColumnCount = nNewColumnCount;
- m_aData.resize( nNewSize );
- m_aData = aNewData;
-
- // labels
- if( nAfterIndex < static_cast< sal_Int32 >( m_aColumnLabels.size()))
- m_aColumnLabels.insert( m_aColumnLabels.begin() + (nAfterIndex + 1), OUString());
-
-#if OSL_DEBUG_LEVEL > 2
- traceData();
-#endif
-}
-
-sal_Int32 InternalData::appendColumn()
-{
- insertColumn( getColumnCount() - 1 );
- return getColumnCount() - 1;
-}
-
-sal_Int32 InternalData::appendRow()
-{
- insertRow( getRowCount() - 1 );
- return getRowCount() - 1;
-}
+private:
+ sal_Int32 m_nLevel;
+};
-void InternalData::insertRow( sal_Int32 nAfterIndex )
+struct lcl_getStringFromLevelVector : public ::std::unary_function< vector< OUString >, OUString >
{
- // note: -1 is allowed, as we insert after the given index
- OSL_ASSERT( nAfterIndex < m_nRowCount && nAfterIndex >= -1 );
- if( nAfterIndex >= m_nRowCount || nAfterIndex < -1 )
- return;
- sal_Int32 nNewRowCount = m_nRowCount + 1;
- sal_Int32 nNewSize( m_nColumnCount * nNewRowCount );
-
- double fNan;
- ::rtl::math::setNan( &fNan );
- tDataType aNewData( fNan, nNewSize );
+public:
- // copy old data
- sal_Int32 nIndex = nAfterIndex + 1;
- aNewData[ ::std::slice( 0, nIndex * m_nColumnCount, 1 ) ] =
- static_cast< tDataType >(
- m_aData[ ::std::slice( 0, nIndex * m_nColumnCount, 1 ) ] );
+ explicit lcl_getStringFromLevelVector( sal_Int32 nLevel ) : m_nLevel( nLevel )
+ {}
- if( nIndex < m_nRowCount )
+ OUString operator() ( const vector< OUString >& rVector )
{
- sal_Int32 nRemainingCount = m_nColumnCount * (m_nRowCount - nIndex);
- aNewData[ ::std::slice( (nIndex + 1) * m_nColumnCount, nRemainingCount, 1 ) ] =
- static_cast< tDataType >(
- m_aData[ ::std::slice( nIndex * m_nColumnCount, nRemainingCount, 1 ) ] );
+ OUString aString;
+ if( m_nLevel < static_cast< sal_Int32 >(rVector.size()) )
+ aString = rVector[m_nLevel];
+ return aString;
}
- m_nRowCount = nNewRowCount;
- m_aData.resize( nNewSize );
- m_aData = aNewData;
-
- // labels
- if( nAfterIndex < static_cast< sal_Int32 >( m_aRowLabels.size()))
- m_aRowLabels.insert( m_aRowLabels.begin() + nIndex, OUString());
-
-#if OSL_DEBUG_LEVEL > 2
- traceData();
-#endif
-}
-
-void InternalData::deleteColumn( sal_Int32 nAtIndex )
-{
- OSL_ASSERT( nAtIndex < m_nColumnCount && nAtIndex >= 0 );
- if( nAtIndex >= m_nColumnCount || m_nColumnCount < 1 || nAtIndex < 0 )
- return;
- sal_Int32 nNewColumnCount = m_nColumnCount - 1;
- sal_Int32 nNewSize( nNewColumnCount * m_nRowCount );
+private:
+ sal_Int32 m_nLevel;
+};
- double fNan;
- ::rtl::math::setNan( &fNan );
- tDataType aNewData( fNan, nNewSize );
-
- // copy old data
- int nCol=0;
- for( ; nCol<nAtIndex; ++nCol )
- aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] =
- static_cast< tDataType >(
- m_aData[ ::std::slice( nCol, m_nRowCount, m_nColumnCount ) ] );
- for( ; nCol<nNewColumnCount; ++nCol )
- aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] =
- static_cast< tDataType >(
- m_aData[ ::std::slice( nCol + 1, m_nRowCount, m_nColumnCount ) ] );
-
- m_nColumnCount = nNewColumnCount;
- m_aData.resize( nNewSize );
- m_aData = aNewData;
-
- // labels
- if( nAtIndex < static_cast< sal_Int32 >( m_aColumnLabels.size()))
- m_aColumnLabels.erase( m_aColumnLabels.begin() + nAtIndex );
-
-#if OSL_DEBUG_LEVEL > 2
- traceData();
-#endif
-}
-void InternalData::deleteRow( sal_Int32 nAtIndex )
+struct lcl_setStringAtLevel : public ::std::binary_function< vector< OUString >, OUString, vector< OUString > >
{
- OSL_ASSERT( nAtIndex < m_nRowCount && nAtIndex >= 0 );
- if( nAtIndex >= m_nRowCount || m_nRowCount < 1 || nAtIndex < 0 )
- return;
- sal_Int32 nNewRowCount = m_nRowCount - 1;
- sal_Int32 nNewSize( m_nColumnCount * nNewRowCount );
-
- double fNan;
- ::rtl::math::setNan( &fNan );
- tDataType aNewData( fNan, nNewSize );
+public:
- // copy old data
- sal_Int32 nIndex = nAtIndex;
- if( nIndex )
- aNewData[ ::std::slice( 0, nIndex * m_nColumnCount, 1 ) ] =
- static_cast< tDataType >(
- m_aData[ ::std::slice( 0, nIndex * m_nColumnCount, 1 ) ] );
+ explicit lcl_setStringAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel )
+ {}
- if( nIndex < nNewRowCount )
+ vector< OUString > operator() ( const vector< OUString >& rVector, const OUString& rNewText )
{
- sal_Int32 nRemainingCount = m_nColumnCount * (nNewRowCount - nIndex);
- aNewData[ ::std::slice( nIndex * m_nColumnCount, nRemainingCount, 1 ) ] =
- static_cast< tDataType >(
- m_aData[ ::std::slice( (nIndex + 1) * m_nColumnCount, nRemainingCount, 1 ) ] );
+ vector< OUString > aRet( rVector );
+ if( m_nLevel >= static_cast< sal_Int32 >(aRet.size()) )
+ aRet.resize( m_nLevel+1 );
+ aRet[ m_nLevel ]=rNewText;
+ return aRet;
}
- m_nRowCount = nNewRowCount;
- m_aData.resize( nNewSize );
- m_aData = aNewData;
-
- // labels
- if( nAtIndex < static_cast< sal_Int32 >( m_aRowLabels.size()))
- m_aRowLabels.erase( m_aRowLabels.begin() + nAtIndex );
-
-#if OSL_DEBUG_LEVEL > 2
- traceData();
-#endif
-}
-
-sal_Int32 InternalData::getRowCount() const
-{
- return m_nRowCount;
-}
-
-sal_Int32 InternalData::getColumnCount() const
-{
- return m_nColumnCount;
-}
-
-void InternalData::setRowLabels( const ::std::vector< OUString > & rNewRowLabels )
-{
- m_aRowLabels = rNewRowLabels;
- if( m_aRowLabels.size() < static_cast< ::std::vector< OUString >::size_type >( m_nRowCount ))
- m_aRowLabels.resize( m_nRowCount );
- else
- enlargeData( 0, static_cast< sal_Int32 >( m_aRowLabels.size() ));
-}
-
-::std::vector< OUString > InternalData::getRowLabels() const
-{
- return m_aRowLabels;
-}
-
-void InternalData::setColumnLabels( const ::std::vector< OUString > & rNewColumnLabels )
-{
- m_aColumnLabels = rNewColumnLabels;
- if( m_aColumnLabels.size() < static_cast< ::std::vector< OUString >::size_type >( m_nColumnCount ))
- m_aColumnLabels.resize( m_nColumnCount );
- else
- enlargeData( static_cast< sal_Int32 >( m_aColumnLabels.size()), 0 );
-}
+private:
+ sal_Int32 m_nLevel;
+};
-::std::vector< OUString > InternalData::getColumnLabels() const
+struct lcl_insertStringAtLevel : public ::std::unary_function< vector< OUString >, void >
{
- return m_aColumnLabels;
-}
+public:
-#if OSL_DEBUG_LEVEL > 2
-void InternalData::traceData() const
-{
- OSL_TRACE( "InternalData: Data in rows\n" );
+ explicit lcl_insertStringAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel )
+ {}
- for( sal_Int32 i=0; i<m_nRowCount; ++i )
+ void operator() ( vector< OUString >& rVector )
{
- tDataType aSlice( m_aData[ ::std::slice( i*m_nColumnCount, m_nColumnCount, 1 ) ] );
- for( sal_Int32 j=0; j<m_nColumnCount; ++j )
- OSL_TRACE( "%lf ", aSlice[j] );
- OSL_TRACE( "\n" );
- }
- OSL_TRACE( "\n" );
-}
-#endif
+ if( m_nLevel > static_cast< sal_Int32 >(rVector.size()) )
+ rVector.resize( m_nLevel );
-} // namespace impl
+ vector< OUString >::iterator aIt( rVector.begin() );
+ for( sal_Int32 nN=0; aIt<rVector.end(); aIt++, nN++)
+ {
+ if( nN==m_nLevel )
+ break;
+ }
+ rVector.insert( aIt, OUString() );
+ }
-// ================================================================================
+private:
+ sal_Int32 m_nLevel;
+};
-namespace
+struct lcl_removeStringAtLevel : public ::std::unary_function< vector< OUString >, void >
{
+public:
-// note: in xmloff this name is used to indicate usage of own data
-static const ::rtl::OUString lcl_aServiceName(
- RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.InternalDataProvider" ));
-
-static const ::rtl::OUString lcl_aCategoriesRangeName(
- RTL_CONSTASCII_USTRINGPARAM( "categories" ));
-static const ::rtl::OUString lcl_aCategoriesRoleName(
- RTL_CONSTASCII_USTRINGPARAM( "categories" ));
-static const ::rtl::OUString lcl_aLabelRangePrefix(
- RTL_CONSTASCII_USTRINGPARAM( "label " ));
-static const ::rtl::OUString lcl_aCompleteRange(
- RTL_CONSTASCII_USTRINGPARAM( "all" ));
-
-
-struct lcl_DataProviderRangeCreator : public unary_function< OUString, Reference< chart2::data::XLabeledDataSequence > >
-{
- lcl_DataProviderRangeCreator( const Reference< chart2::data::XDataProvider > & xDataProvider ) :
- m_xDataProvider( xDataProvider )
+ explicit lcl_removeStringAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel )
{}
- Reference< chart2::data::XLabeledDataSequence > operator() ( const OUString & rRange )
+ void operator() ( vector< OUString >& rVector )
{
- Reference< chart2::data::XLabeledDataSequence > xResult;
- if( m_xDataProvider.is())
- try
- {
- xResult.set( new ::chart::LabeledDataSequence(
- m_xDataProvider->createDataSequenceByRangeRepresentation( rRange )));
- }
- catch( const lang::IllegalArgumentException & ex )
- {
- // data provider cannot create single data sequences, but then
- // detectArguments should work also with an empty data source
- (void)(ex);
- }
- catch( const uno::Exception & ex )
+ vector< OUString >::iterator aIt( rVector.begin() );
+ for( sal_Int32 nN=0; aIt<rVector.end(); aIt++, nN++)
+ {
+ if( nN==m_nLevel )
{
- ASSERT_EXCEPTION( ex );
+ rVector.erase( aIt );
+ break;
}
- return xResult;
+ }
}
private:
- Reference< chart2::data::XDataProvider > m_xDataProvider;
+ sal_Int32 m_nLevel;
};
-typedef ::std::multimap< OUString, uno::WeakReference< chart2::data::XDataSequence > >
- lcl_tSequenceMap;
-
-struct lcl_modifySeqMapValue : public ::std::unary_function< lcl_tSequenceMap, void >
+vector< OUString > lcl_AnyToStringVector( const Sequence< uno::Any >& aAnySeq )
{
- void operator() ( const lcl_tSequenceMap::value_type & rMapEntry )
- {
- // convert weak reference to reference
- Reference< chart2::data::XDataSequence > xSeq( rMapEntry.second );
- if( xSeq.is())
- {
- Reference< util::XModifiable > xMod( xSeq, uno::UNO_QUERY );
- if( xMod.is())
- xMod->setModified( sal_True );
- }
- }
-};
+ vector< OUString > aStringVec;
+ transform( aAnySeq.getConstArray(), aAnySeq.getConstArray() + aAnySeq.getLength(),
+ back_inserter( aStringVec ), CommonFunctors::AnyToString() );
+ return aStringVec;
+}
-Sequence< Reference< chart2::data::XLabeledDataSequence > >
- lcl_internalizeData(
- const Sequence< Reference< chart2::data::XLabeledDataSequence > > & rDataSeq,
- impl::InternalData & rInternalData,
- InternalDataProvider & rProvider )
+Sequence< OUString > lcl_AnyToStringSequence( const Sequence< uno::Any >& aAnySeq )
{
- Sequence< Reference< chart2::data::XLabeledDataSequence > > aResult( rDataSeq.getLength());
- for( sal_Int32 i=0; i<rDataSeq.getLength(); ++i )
- {
- sal_Int32 nNewIndex( rInternalData.appendColumn());
- OUString aIdentifier( OUString::valueOf( nNewIndex ));
- //@todo: deal also with genericXDataSequence
- Reference< chart2::data::XNumericalDataSequence > xValues( rDataSeq[i]->getValues(), uno::UNO_QUERY );
- Reference< chart2::data::XTextualDataSequence > xLabel( rDataSeq[i]->getLabel(), uno::UNO_QUERY );
- Reference< chart2::data::XDataSequence > xNewValues;
-
- if( xValues.is())
- {
- ::std::vector< double > aValues( ContainerHelper::SequenceToVector( xValues->getNumericalData()));
- rInternalData.enlargeData( nNewIndex + 1, aValues.size());
- rInternalData.setDataAt( nNewIndex, true, aValues );
- xNewValues.set( rProvider.createDataSequenceByRangeRepresentation( aIdentifier ));
- comphelper::copyProperties(
- Reference< beans::XPropertySet >( xValues, uno::UNO_QUERY ),
- Reference< beans::XPropertySet >( xNewValues, uno::UNO_QUERY ));
- }
-
- if( xLabel.is())
- {
- ::std::vector< OUString > aLabels( rInternalData.getColumnLabels());
- OSL_ASSERT( static_cast< size_t >( nNewIndex ) < aLabels.size());
- if( aLabels.size() <= static_cast< size_t >( nNewIndex ) )
- aLabels.resize( nNewIndex+1 );
- aLabels[nNewIndex] = impl::FlattenStringSequence( xLabel->getTextualData());
- rInternalData.setColumnLabels( aLabels );
- Reference< chart2::data::XDataSequence > xNewLabel(
- rProvider.createDataSequenceByRangeRepresentation( lcl_aLabelRangePrefix + aIdentifier ));
- comphelper::copyProperties(
- Reference< beans::XPropertySet >( xLabel, uno::UNO_QUERY ),
- Reference< beans::XPropertySet >( xNewLabel, uno::UNO_QUERY ));
- aResult[i] =
- Reference< chart2::data::XLabeledDataSequence >(
- new LabeledDataSequence( xNewValues, xNewLabel ));
- }
- else
- {
- aResult[i] =
- Reference< chart2::data::XLabeledDataSequence >(
- new LabeledDataSequence( xNewValues ));
- }
- }
+ Sequence< OUString > aResult;
+ aResult.realloc( aAnySeq.getLength() );
+ transform( aAnySeq.getConstArray(), aAnySeq.getConstArray() + aAnySeq.getLength(),
+ aResult.getArray(), CommonFunctors::AnyToString() );
return aResult;
}
-struct lcl_internalizeSeries : public ::std::unary_function< Reference< chart2::XDataSeries >, void >
-{
- lcl_internalizeSeries( impl::InternalData & rInternalData,
- InternalDataProvider & rProvider ) :
- m_rInternalData( rInternalData ),
- m_rProvider( rProvider )
- {}
- void operator() ( const Reference< chart2::XDataSeries > & xSeries )
- {
- Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY );
- Reference< chart2::data::XDataSink > xSink( xSeries, uno::UNO_QUERY );
- if( xSource.is() && xSink.is())
- xSink->setData( lcl_internalizeData( xSource->getDataSequences(), m_rInternalData, m_rProvider ));
- }
-
-private:
- impl::InternalData & m_rInternalData;
- InternalDataProvider & m_rProvider;
-};
-
} // anonymous namespace
-InternalDataProvider::InternalDataProvider(const Reference< uno::XComponentContext > & /*_xContext*/) :
- m_bDataInColumns( true )
-{}
// ================================================================================
-InternalDataProvider::InternalDataProvider() :
- m_bDataInColumns( true )
+InternalDataProvider::InternalDataProvider( const Reference< uno::XComponentContext > & /*_xContext*/)
+ : m_bDataInColumns( true )
{}
-InternalDataProvider::InternalDataProvider(
- const Reference< ::com::sun::star::chart::XChartDataArray > & xDataToCopy ) :
- m_bDataInColumns( true )
-{
- if( xDataToCopy.is())
- {
- setData( xDataToCopy->getData() );
- setColumnDescriptions( xDataToCopy->getColumnDescriptions() );
- setRowDescriptions( xDataToCopy->getRowDescriptions() );
- }
-}
-
-InternalDataProvider::InternalDataProvider(
- const Reference< chart2::XChartDocument > & xChartDoc ) :
- m_bDataInColumns( true )
+InternalDataProvider::InternalDataProvider( const Reference< chart2::XChartDocument > & xChartDoc, bool bConnectToModel )
+ : m_bDataInColumns( true )
{
try
{
Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartDoc ) );
if( xDiagram.is())
{
- impl::InternalData & rData( getInternalData());
+ Reference< frame::XModel > xChartModel( xChartDoc, uno::UNO_QUERY );
+
+ //data in columns?
+ {
+ ::rtl::OUString aRangeString;
+ bool bFirstCellAsLabel = true;
+ bool bHasCategories = true;
+ uno::Sequence< sal_Int32 > aSequenceMapping;
+ DataSourceHelper::detectRangeSegmentation( xChartModel, aRangeString, aSequenceMapping, m_bDataInColumns, bFirstCellAsLabel, bHasCategories );
+ }
+
// categories
- Reference< chart2::data::XLabeledDataSequence > xCategories( DiagramHelper::getCategoriesFromDiagram( xDiagram ));
- if( xCategories.is())
{
- // @todo: be able to deal with XDataSequence, too
- Reference< chart2::data::XTextualDataSequence > xSeq( xCategories->getValues(), uno::UNO_QUERY );
- if( xSeq.is())
- rData.setRowLabels( ContainerHelper::SequenceToVector( xSeq->getTextualData()));
- DiagramHelper::setCategoriesToDiagram(
- new LabeledDataSequence(
- createDataSequenceByRangeRepresentation( lcl_aCategoriesRangeName )),
- xDiagram );
+ vector< vector< OUString > > aNewCategories;//inner count is level
+ {
+ ExplicitCategoriesProvider aExplicitCategoriesProvider( ChartModelHelper::getFirstCoordinateSystem(xChartModel), xChartModel );
+ const Sequence< Reference< chart2::data::XLabeledDataSequence> >& rSplitCategoriesList( aExplicitCategoriesProvider.getSplitCategoriesList() );
+ sal_Int32 nLevelCount = rSplitCategoriesList.getLength();
+ for( sal_Int32 nL = 0; nL<nLevelCount; nL++ )
+ {
+ Reference< chart2::data::XLabeledDataSequence > xLDS( rSplitCategoriesList[nL] );
+ if( !xLDS.is() )
+ continue;
+ Reference< chart2::data::XTextualDataSequence > xSeq( xLDS->getValues(), uno::UNO_QUERY );
+ Sequence< OUString > aStringSeq;
+ if( xSeq.is() )
+ aStringSeq = xSeq->getTextualData(); // @todo: be able to deal with XDataSequence, too
+ sal_Int32 nLength = aStringSeq.getLength();
+ if( static_cast< sal_Int32 >(aNewCategories.size()) < nLength )
+ aNewCategories.resize( nLength );
+
+ transform( aNewCategories.begin(), aNewCategories.end(), aStringSeq.getConstArray(),
+ aNewCategories.begin(), lcl_setStringAtLevel(nL) );
+ }
+ if( !nLevelCount )
+ {
+ Sequence< OUString > aSimplecategories = aExplicitCategoriesProvider.getSimpleCategories();
+ sal_Int32 nLength = aSimplecategories.getLength();
+ aNewCategories.reserve( nLength );
+ for( sal_Int32 nN=0; nN<nLength; nN++)
+ {
+ vector< OUString > aStringVector(1);
+ aStringVector[0] = aSimplecategories[nN];
+ aNewCategories.push_back( aStringVector );
+ }
+ }
+ }
+
+ if( m_bDataInColumns )
+ m_aInternalData.setComplexRowLabels( aNewCategories );
+ else
+ m_aInternalData.setComplexColumnLabels( aNewCategories );
+ if( bConnectToModel )
+ DiagramHelper::setCategoriesToDiagram( new LabeledDataSequence(
+ createDataSequenceByRangeRepresentation( lcl_aCategoriesRangeName )), xDiagram );
}
// data series
::std::vector< Reference< chart2::XDataSeries > > aSeriesVector( ChartModelHelper::getDataSeries( xChartDoc ));
- ::std::for_each( aSeriesVector.begin(), aSeriesVector.end(),
- lcl_internalizeSeries( rData, *this ));
-
- // unused data
- Sequence< Reference< chart2::data::XLabeledDataSequence > > aUnusedData( xDiagram->getUnusedData());
- aUnusedData = lcl_internalizeData( aUnusedData, rData, *this );
- xDiagram->setUnusedData( aUnusedData );
+ ::std::for_each( aSeriesVector.begin(), aSeriesVector.end(), lcl_internalizeSeries( m_aInternalData, *this, bConnectToModel, m_bDataInColumns ) );
}
}
catch( const uno::Exception & ex )
@@ -847,14 +400,14 @@ InternalDataProvider::InternalDataProvider(
InternalDataProvider::InternalDataProvider( const InternalDataProvider & rOther ) :
impl::InternalDataProvider_Base(),
m_aSequenceMap( rOther.m_aSequenceMap ),
- m_apData( new impl::InternalData( rOther.getInternalData())),
+ m_aInternalData( rOther.m_aInternalData ),
m_bDataInColumns( rOther.m_bDataInColumns )
{}
InternalDataProvider::~InternalDataProvider()
{}
-void InternalDataProvider::addDataSequenceToMap(
+void InternalDataProvider::lcl_addDataSequenceToMap(
const OUString & rRangeRepresentation,
const Reference< chart2::data::XDataSequence > & xSequence )
{
@@ -864,7 +417,7 @@ void InternalDataProvider::addDataSequenceToMap(
uno::WeakReference< chart2::data::XDataSequence >( xSequence )));
}
-void InternalDataProvider::deleteMapReferences( const OUString & rRangeRepresentation )
+void InternalDataProvider::lcl_deleteMapReferences( const OUString & rRangeRepresentation )
{
// set sequence to deleted by setting its range to an empty string
tSequenceMapRange aRange( m_aSequenceMap.equal_range( rRangeRepresentation ));
@@ -882,7 +435,7 @@ void InternalDataProvider::deleteMapReferences( const OUString & rRangeRepresent
m_aSequenceMap.erase( aRange.first, aRange.second );
}
-void InternalDataProvider::adaptMapReferences(
+void InternalDataProvider::lcl_adaptMapReferences(
const OUString & rOldRangeRepresentation,
const OUString & rNewRangeRepresentation )
{
@@ -907,70 +460,52 @@ void InternalDataProvider::adaptMapReferences(
m_aSequenceMap.upper_bound( rNewRangeRepresentation )));
}
-void InternalDataProvider::increaseMapReferences(
+void InternalDataProvider::lcl_increaseMapReferences(
sal_Int32 nBegin, sal_Int32 nEnd )
{
for( sal_Int32 nIndex = nEnd - 1; nIndex >= nBegin; --nIndex )
{
- adaptMapReferences( OUString::valueOf( nIndex ),
+ lcl_adaptMapReferences( OUString::valueOf( nIndex ),
OUString::valueOf( nIndex + 1 ));
- adaptMapReferences( lcl_aLabelRangePrefix + OUString::valueOf( nIndex ),
+ lcl_adaptMapReferences( lcl_aLabelRangePrefix + OUString::valueOf( nIndex ),
lcl_aLabelRangePrefix + OUString::valueOf( nIndex + 1 ));
}
}
-void InternalDataProvider::decreaseMapReferences(
+void InternalDataProvider::lcl_decreaseMapReferences(
sal_Int32 nBegin, sal_Int32 nEnd )
{
for( sal_Int32 nIndex = nBegin; nIndex < nEnd; ++nIndex )
{
- adaptMapReferences( OUString::valueOf( nIndex ),
+ lcl_adaptMapReferences( OUString::valueOf( nIndex ),
OUString::valueOf( nIndex - 1 ));
- adaptMapReferences( lcl_aLabelRangePrefix + OUString::valueOf( nIndex ),
+ lcl_adaptMapReferences( lcl_aLabelRangePrefix + OUString::valueOf( nIndex ),
lcl_aLabelRangePrefix + OUString::valueOf( nIndex - 1 ));
}
}
-Reference< chart2::data::XDataSequence > InternalDataProvider::createDataSequenceAndAddToMap(
+Reference< chart2::data::XDataSequence > InternalDataProvider::lcl_createDataSequenceAndAddToMap(
const OUString & rRangeRepresentation )
{
Reference< chart2::data::XDataSequence > xSeq(
new UncachedDataSequence( this, rRangeRepresentation ));
- addDataSequenceToMap( rRangeRepresentation, xSeq );
+ lcl_addDataSequenceToMap( rRangeRepresentation, xSeq );
return xSeq;
}
-Reference< chart2::data::XDataSequence > InternalDataProvider::createDataSequenceAndAddToMap(
+Reference< chart2::data::XDataSequence > InternalDataProvider::lcl_createDataSequenceAndAddToMap(
const OUString & rRangeRepresentation,
const OUString & rRole )
{
Reference< chart2::data::XDataSequence > xSeq(
new UncachedDataSequence( this, rRangeRepresentation, rRole ));
- addDataSequenceToMap( rRangeRepresentation, xSeq );
+ lcl_addDataSequenceToMap( rRangeRepresentation, xSeq );
return xSeq;
}
-const impl::InternalData & InternalDataProvider::getInternalData() const
-{
- if( m_apData.get())
- return *(m_apData.get());
-
- m_apData.reset( new impl::InternalData());
- return *(m_apData.get());
-}
-
-impl::InternalData & InternalDataProvider::getInternalData()
-{
- if( m_apData.get())
- return *(m_apData.get());
-
- m_apData.reset( new impl::InternalData());
- return *(m_apData.get());
-}
-
void InternalDataProvider::createDefaultData()
{
- getInternalData().createDefaultData();
+ m_aInternalData.createDefaultData();
}
// ____ XDataProvider ____
@@ -980,6 +515,24 @@ void InternalDataProvider::createDefaultData()
return true;
}
+namespace
+{
+
+sal_Int32 lcl_getInnerLevelCount( const vector< vector< OUString > >& rLabels )
+{
+ sal_Int32 nCount = 1;//minimum is 1!
+ vector< vector< OUString > >::const_iterator aLevelIt( rLabels.begin() );
+ vector< vector< OUString > >::const_iterator aLevelEnd( rLabels.end() );
+ for( ;aLevelIt!=aLevelEnd; ++aLevelIt )
+ {
+ const vector< ::rtl::OUString >& rCurrentLevelLabels = *aLevelIt;
+ nCount = std::max<sal_Int32>( rCurrentLevelLabels.size(), nCount );
+ }
+ return nCount;
+}
+
+}//end anonymous namespace
+
Reference< chart2::data::XDataSource > SAL_CALL InternalDataProvider::createDataSource(
const Sequence< beans::PropertyValue >& aArguments )
throw (lang::IllegalArgumentException,
@@ -992,25 +545,51 @@ Reference< chart2::data::XDataSource > SAL_CALL InternalDataProvider::createData
uno::Sequence< sal_Int32 > aSequenceMapping;
DataSourceHelper::readArguments( aArguments, aRangeRepresentation, aSequenceMapping, bUseColumns, bFirstCellAsLabel, bHasCategories );
+ if( aRangeRepresentation.equals( lcl_aCategoriesRangeName ) )
+ {
+ //return split complex categories if we have any:
+ ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aComplexCategories;
+ vector< vector< OUString > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels());
+ if( bUseColumns==m_bDataInColumns )
+ {
+ sal_Int32 nLevelCount = lcl_getInnerLevelCount( aCategories );
+ for( sal_Int32 nL=0; nL<nLevelCount; nL++ )
+ aComplexCategories.push_back( new LabeledDataSequence(
+ new UncachedDataSequence( this
+ , lcl_aCategoriesLevelRangeNamePrefix + OUString::valueOf( nL )
+ , lcl_aCategoriesRoleName ) ) );
+ }
+ else
+ {
+ sal_Int32 nPointCount = m_bDataInColumns ? m_aInternalData.getRowCount() : m_aInternalData.getColumnCount();
+ for( sal_Int32 nP=0; nP<nPointCount; nP++ )
+ aComplexCategories.push_back( new LabeledDataSequence(
+ new UncachedDataSequence( this
+ , lcl_aCategoriesPointRangeNamePrefix + OUString::valueOf( nP )
+ , lcl_aCategoriesRoleName ) ) );
+ }
+ //don't add the created sequences to the map as they are used temporarily only ...
+ return new DataSource( ContainerHelper::ContainerToSequence(aComplexCategories) );
+ }
+
OSL_ASSERT( aRangeRepresentation.equals( lcl_aCompleteRange ));
::std::vector< Reference< chart2::data::XLabeledDataSequence > > aResultLSeqVec;
- impl::InternalData & rData( getInternalData());
// categories
- if ( bHasCategories )
+ if( bHasCategories )
aResultLSeqVec.push_back(
- new LabeledDataSequence( createDataSequenceAndAddToMap( lcl_aCategoriesRangeName, lcl_aCategoriesRoleName )));
+ new LabeledDataSequence( lcl_createDataSequenceAndAddToMap( lcl_aCategoriesRangeName, lcl_aCategoriesRoleName ) ) );
// data with labels
::std::vector< Reference< chart2::data::XLabeledDataSequence > > aDataVec;
- const sal_Int32 nCount = (bUseColumns ? rData.getColumnCount() : rData.getRowCount());
- for( sal_Int32 nIdx=0; nIdx<nCount; ++nIdx )
+ const sal_Int32 nCount = (bUseColumns ? m_aInternalData.getColumnCount() : m_aInternalData.getRowCount());
+ for( sal_Int32 nIdx=0; nIdx<nCount; ++nIdx )
{
aDataVec.push_back(
new LabeledDataSequence(
- createDataSequenceAndAddToMap( OUString::valueOf( nIdx )),
- createDataSequenceAndAddToMap( lcl_aLabelRangePrefix + OUString::valueOf( nIdx ))));
+ lcl_createDataSequenceAndAddToMap( OUString::valueOf( nIdx )),
+ lcl_createDataSequenceAndAddToMap( lcl_aLabelRangePrefix + OUString::valueOf( nIdx ))));
}
// attention: this data provider has the limitation that it stores
@@ -1082,29 +661,31 @@ Reference< chart2::data::XDataSequence > SAL_CALL InternalDataProvider::createDa
throw (lang::IllegalArgumentException,
uno::RuntimeException)
{
- if( aRangeRepresentation.equals( lcl_aCategoriesRangeName ))
+ if( aRangeRepresentation.match( lcl_aCategoriesRangeName ))
{
+ OSL_ASSERT( aRangeRepresentation.equals( lcl_aCategoriesRangeName ) );//it is not expected nor implmented that only parts of the categories are really requested
+
// categories
- return createDataSequenceAndAddToMap( lcl_aCategoriesRangeName, lcl_aCategoriesRoleName );
+ return lcl_createDataSequenceAndAddToMap( lcl_aCategoriesRangeName, lcl_aCategoriesRoleName );
}
else if( aRangeRepresentation.match( lcl_aLabelRangePrefix ))
{
// label
sal_Int32 nIndex = aRangeRepresentation.copy( lcl_aLabelRangePrefix.getLength()).toInt32();
- return createDataSequenceAndAddToMap( lcl_aLabelRangePrefix + OUString::valueOf( nIndex ));
+ return lcl_createDataSequenceAndAddToMap( lcl_aLabelRangePrefix + OUString::valueOf( nIndex ));
}
else if( aRangeRepresentation.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "last" )))
{
sal_Int32 nIndex = (m_bDataInColumns
- ? getInternalData().getColumnCount()
- : getInternalData().getRowCount()) - 1;
- return createDataSequenceAndAddToMap( OUString::valueOf( nIndex ));
+ ? m_aInternalData.getColumnCount()
+ : m_aInternalData.getRowCount()) - 1;
+ return lcl_createDataSequenceAndAddToMap( OUString::valueOf( nIndex ));
}
else if( aRangeRepresentation.getLength())
{
// data
sal_Int32 nIndex = aRangeRepresentation.toInt32();
- return createDataSequenceAndAddToMap( OUString::valueOf( nIndex ));
+ return lcl_createDataSequenceAndAddToMap( OUString::valueOf( nIndex ));
}
return Reference< chart2::data::XDataSequence >();
@@ -1122,21 +703,21 @@ Reference< sheet::XRangeSelection > SAL_CALL InternalDataProvider::getRangeSelec
throw (uno::RuntimeException)
{
sal_Bool bResult = false;
- const impl::InternalData & rData( getInternalData());
- if( aRange.equals( lcl_aCategoriesRangeName ))
+ if( aRange.match( lcl_aCategoriesRangeName ))
{
+ OSL_ASSERT( aRange.equals( lcl_aCategoriesRangeName ) );//it is not expected nor implmented that only parts of the categories are really requested
bResult = true;
}
else if( aRange.match( lcl_aLabelRangePrefix ))
{
sal_Int32 nIndex = aRange.copy( lcl_aLabelRangePrefix.getLength()).toInt32();
- bResult = (nIndex < (m_bDataInColumns ? rData.getColumnCount(): rData.getRowCount()));
+ bResult = (nIndex < (m_bDataInColumns ? m_aInternalData.getColumnCount(): m_aInternalData.getRowCount()));
}
else
{
sal_Int32 nIndex = aRange.toInt32();
- bResult = (nIndex < (m_bDataInColumns ? rData.getColumnCount(): rData.getRowCount()));
+ bResult = (nIndex < (m_bDataInColumns ? m_aInternalData.getColumnCount(): m_aInternalData.getRowCount()));
}
return bResult;
@@ -1146,34 +727,67 @@ Sequence< uno::Any > SAL_CALL InternalDataProvider::getDataByRangeRepresentation
throw (uno::RuntimeException)
{
Sequence< uno::Any > aResult;
- const impl::InternalData & rData( getInternalData());
- if( aRange.equals( lcl_aCategoriesRangeName ))
+ if( aRange.match( lcl_aLabelRangePrefix ) )
{
- vector< OUString > aCategories( m_bDataInColumns ? rData.getRowLabels() : rData.getColumnLabels());
- aResult.realloc( aCategories.size());
- transform( aCategories.begin(), aCategories.end(),
- aResult.getArray(), CommonFunctors::makeAny< OUString >());
+ sal_Int32 nIndex = aRange.copy( lcl_aLabelRangePrefix.getLength()).toInt32();
+ vector< OUString > aComplexLabel = m_bDataInColumns
+ ? m_aInternalData.getComplexColumnLabel( nIndex )
+ : m_aInternalData.getComplexRowLabel( nIndex );
+ if( !aComplexLabel.empty() )
+ {
+ aResult.realloc( aComplexLabel.size() );
+ transform( aComplexLabel.begin(), aComplexLabel.end(),
+ aResult.getArray(), CommonFunctors::makeAny< OUString >());
+ }
}
- else if( aRange.match( lcl_aLabelRangePrefix ))
+ else if( aRange.match( lcl_aCategoriesPointRangeNamePrefix ) )
{
- sal_Int32 nIndex = aRange.copy( lcl_aLabelRangePrefix.getLength()).toInt32();
- vector< OUString > aLabels( m_bDataInColumns ? rData.getColumnLabels() : rData.getRowLabels());
- if( nIndex < static_cast< sal_Int32 >( aLabels.size()))
+ sal_Int32 nPointIndex = aRange.copy( lcl_aCategoriesPointRangeNamePrefix.getLength() ).toInt32();
+ vector< OUString > aComplexCategory = m_bDataInColumns
+ ? m_aInternalData.getComplexRowLabel( nPointIndex )
+ : m_aInternalData.getComplexColumnLabel( nPointIndex );
+ if( !aComplexCategory.empty() )
{
- aResult.realloc( 1 );
- aResult[0] = uno::makeAny( aLabels[ nIndex ] );
+ aResult.realloc( aComplexCategory.size() );
+ transform( aComplexCategory.begin(), aComplexCategory.end(),
+ aResult.getArray(), CommonFunctors::makeAny< OUString >());
}
}
+ else if( aRange.match( lcl_aCategoriesLevelRangeNamePrefix ) )
+ {
+ sal_Int32 nLevel = aRange.copy( lcl_aCategoriesLevelRangeNamePrefix.getLength() ).toInt32();
+ vector< vector< OUString > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels());
+ if( nLevel < lcl_getInnerLevelCount( aCategories ) )
+ {
+ aResult.realloc( aCategories.size() );
+ transform( aCategories.begin(), aCategories.end(),
+ aResult.getArray(), lcl_makeAnyFromLevelVector(nLevel) );
+ }
+ }
+ else if( aRange.equals( lcl_aCategoriesRangeName ) )
+ {
+ Sequence< OUString > aLabels = m_bDataInColumns ? this->getRowDescriptions() : this->getColumnDescriptions();
+ aResult.realloc( aLabels.getLength() );
+ transform( aLabels.getConstArray(), aLabels.getConstArray() + aLabels.getLength(),
+ aResult.getArray(), CommonFunctors::makeAny< OUString >() );
+ }
else
{
sal_Int32 nIndex = aRange.toInt32();
- if( nIndex < (m_bDataInColumns ? rData.getColumnCount() : rData.getRowCount()))
+ if( nIndex >= 0 )
{
- Sequence< double > aData( rData.getDataAt( nIndex, m_bDataInColumns ));
- aResult.realloc( aData.getLength());
- transform( aData.getConstArray(), aData.getConstArray() + aData.getLength(),
- aResult.getArray(), CommonFunctors::makeAny< double >());
+ Sequence< double > aData;
+ if( m_bDataInColumns )
+ aData = m_aInternalData.getColumnValues(nIndex);
+ else
+ aData = m_aInternalData.getRowValues(nIndex);
+ if( aData.getLength() )
+ {
+ aResult.realloc( aData.getLength());
+ transform( aData.getConstArray(), aData.getConstArray() + aData.getLength(),
+ aResult.getArray(), CommonFunctors::makeAny< double >());
+ }
}
}
@@ -1184,61 +798,63 @@ void SAL_CALL InternalDataProvider::setDataByRangeRepresentation(
const OUString& aRange, const Sequence< uno::Any >& aNewData )
throw (uno::RuntimeException)
{
- impl::InternalData & rData( getInternalData());
-
- if( aRange.equals( lcl_aCategoriesRangeName ))
+ if( aRange.match( lcl_aLabelRangePrefix ) )
+ {
+ vector< OUString > aNewStrings( lcl_AnyToStringVector( aNewData ) );
+ sal_uInt32 nIndex = aRange.copy( lcl_aLabelRangePrefix.getLength()).toInt32();
+ if( m_bDataInColumns )
+ m_aInternalData.setComplexColumnLabel( nIndex, aNewStrings );
+ else
+ m_aInternalData.setComplexRowLabel( nIndex, aNewStrings );
+ }
+ else if( aRange.match( lcl_aCategoriesPointRangeNamePrefix ) )
{
- vector< OUString > aCategories;
- transform( aNewData.getConstArray(), aNewData.getConstArray() + aNewData.getLength(),
- back_inserter( aCategories ), CommonFunctors::AnyToString());
+ vector< OUString > aNewStrings( lcl_AnyToStringVector( aNewData ) );
+ sal_Int32 nPointIndex = aRange.copy( lcl_aCategoriesLevelRangeNamePrefix.getLength()).toInt32();
+ if( m_bDataInColumns )
+ m_aInternalData.setComplexRowLabel( nPointIndex, aNewStrings );
+ else
+ m_aInternalData.setComplexColumnLabel( nPointIndex, aNewStrings );
+ }
+ else if( aRange.match( lcl_aCategoriesLevelRangeNamePrefix ) )
+ {
+ vector< OUString > aNewStrings( lcl_AnyToStringVector( aNewData ) );
+ sal_Int32 nLevel = aRange.copy( lcl_aCategoriesLevelRangeNamePrefix.getLength()).toInt32();
+ vector< vector< OUString > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels();
+
+ //ensure equal length
+ if( aNewStrings.size() > aComplexCategories.size() )
+ aComplexCategories.resize( aNewStrings.size() );
+ else if( aNewStrings.size() < aComplexCategories.size() )
+ aNewStrings.resize( aComplexCategories.size() );
+
+ transform( aComplexCategories.begin(), aComplexCategories.end(), aNewStrings.begin(),
+ aComplexCategories.begin(), lcl_setStringAtLevel(nLevel) );
if( m_bDataInColumns )
- rData.setRowLabels( aCategories );
+ m_aInternalData.setComplexRowLabels( aComplexCategories );
else
- rData.setColumnLabels( aCategories );
+ m_aInternalData.setComplexColumnLabels( aComplexCategories );
}
- else if( aRange.match( lcl_aLabelRangePrefix ))
+ else if( aRange.equals( lcl_aCategoriesRangeName ) )
{
- sal_uInt32 nIndex = aRange.copy( lcl_aLabelRangePrefix.getLength()).toInt32();
- OUString aNewLabel;
- if( aNewData.getLength() &&
- (aNewData[0] >>= aNewLabel))
- {
- if( m_bDataInColumns )
- {
- vector< OUString > aLabels( rData.getColumnLabels());
- if ( aLabels.size() <= nIndex )
- aLabels.push_back(aNewLabel);
- else
- aLabels[ nIndex ] = aNewLabel;
- rData.setColumnLabels( aLabels );
- }
- else
- {
- vector< OUString > aLabels( rData.getRowLabels());
- if ( aLabels.size() <= nIndex )
- aLabels.push_back(aNewLabel);
- else
- aLabels[ nIndex ] = aNewLabel;
- rData.setRowLabels( aLabels );
- }
- }
+ if( m_bDataInColumns )
+ this->setRowDescriptions( lcl_AnyToStringSequence(aNewData) );
+ else
+ this->setColumnDescriptions( lcl_AnyToStringSequence(aNewData) );
}
else
{
sal_Int32 nIndex = aRange.toInt32();
- // ensure that the data is large enough
- if( m_bDataInColumns )
- rData.enlargeData( nIndex, 0 );
- else
- rData.enlargeData( 0, nIndex );
-
- if( nIndex < (m_bDataInColumns ? rData.getColumnCount() : rData.getRowCount()))
+ if( nIndex>=0 )
{
vector< double > aNewDataVec;
transform( aNewData.getConstArray(), aNewData.getConstArray() + aNewData.getLength(),
back_inserter( aNewDataVec ), CommonFunctors::AnyToDouble());
- rData.setDataAt( nIndex, m_bDataInColumns, aNewDataVec );
+ if( m_bDataInColumns )
+ m_aInternalData.setColumnValues( nIndex, aNewDataVec );
+ else
+ m_aInternalData.setRowValues( nIndex, aNewDataVec );
}
}
}
@@ -1248,30 +864,30 @@ void SAL_CALL InternalDataProvider::insertSequence( ::sal_Int32 nAfterIndex )
{
if( m_bDataInColumns )
{
- increaseMapReferences( nAfterIndex + 1, getInternalData().getColumnCount());
- getInternalData().insertColumn( nAfterIndex );
+ lcl_increaseMapReferences( nAfterIndex + 1, m_aInternalData.getColumnCount());
+ m_aInternalData.insertColumn( nAfterIndex );
}
else
{
- increaseMapReferences( nAfterIndex + 1, getInternalData().getRowCount());
- getInternalData().insertRow( nAfterIndex );
+ lcl_increaseMapReferences( nAfterIndex + 1, m_aInternalData.getRowCount());
+ m_aInternalData.insertRow( nAfterIndex );
}
}
void SAL_CALL InternalDataProvider::deleteSequence( ::sal_Int32 nAtIndex )
throw (uno::RuntimeException)
{
- deleteMapReferences( OUString::valueOf( nAtIndex ));
- deleteMapReferences( lcl_aLabelRangePrefix + OUString::valueOf( nAtIndex ));
+ lcl_deleteMapReferences( OUString::valueOf( nAtIndex ));
+ lcl_deleteMapReferences( lcl_aLabelRangePrefix + OUString::valueOf( nAtIndex ));
if( m_bDataInColumns )
{
- decreaseMapReferences( nAtIndex + 1, getInternalData().getColumnCount());
- getInternalData().deleteColumn( nAtIndex );
+ lcl_decreaseMapReferences( nAtIndex + 1, m_aInternalData.getColumnCount());
+ m_aInternalData.deleteColumn( nAtIndex );
}
else
{
- decreaseMapReferences( nAtIndex + 1, getInternalData().getRowCount());
- getInternalData().deleteRow( nAtIndex );
+ lcl_decreaseMapReferences( nAtIndex + 1, m_aInternalData.getRowCount());
+ m_aInternalData.deleteRow( nAtIndex );
}
}
@@ -1279,9 +895,44 @@ void SAL_CALL InternalDataProvider::appendSequence()
throw (uno::RuntimeException)
{
if( m_bDataInColumns )
- getInternalData().appendColumn();
+ m_aInternalData.appendColumn();
else
- getInternalData().appendRow();
+ m_aInternalData.appendRow();
+}
+
+void SAL_CALL InternalDataProvider::insertComplexCategoryLevel( sal_Int32 nLevel )
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE( nLevel> 0, "you can only insert category levels > 0" );//the first categories level cannot be deleted, check the calling code for error
+ if( nLevel>0 )
+ {
+ vector< vector< OUString > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels();
+ ::std::for_each( aComplexCategories.begin(), aComplexCategories.end(), lcl_insertStringAtLevel(nLevel) );
+ if( m_bDataInColumns )
+ m_aInternalData.setComplexRowLabels( aComplexCategories );
+ else
+ m_aInternalData.setComplexColumnLabels( aComplexCategories );
+
+ tSequenceMapRange aRange( m_aSequenceMap.equal_range( lcl_aCategoriesRangeName ));
+ ::std::for_each( aRange.first, aRange.second, lcl_setModified());
+ }
+}
+void SAL_CALL InternalDataProvider::deleteComplexCategoryLevel( sal_Int32 nLevel )
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE( nLevel>0, "you can only delete category levels > 0" );//the first categories level cannot be deleted, check the calling code for error
+ if( nLevel>0 )
+ {
+ vector< vector< OUString > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels();
+ ::std::for_each( aComplexCategories.begin(), aComplexCategories.end(), lcl_removeStringAtLevel(nLevel) );
+ if( m_bDataInColumns )
+ m_aInternalData.setComplexRowLabels( aComplexCategories );
+ else
+ m_aInternalData.setComplexColumnLabels( aComplexCategories );
+
+ tSequenceMapRange aRange( m_aSequenceMap.equal_range( lcl_aCategoriesRangeName ));
+ ::std::for_each( aRange.first, aRange.second, lcl_setModified());
+ }
}
void SAL_CALL InternalDataProvider::insertDataPointForAllSequences( ::sal_Int32 nAfterIndex )
@@ -1290,22 +941,22 @@ void SAL_CALL InternalDataProvider::insertDataPointForAllSequences( ::sal_Int32
sal_Int32 nMaxRep = 0;
if( m_bDataInColumns )
{
- getInternalData().insertRow( nAfterIndex );
- nMaxRep = getInternalData().getColumnCount();
+ m_aInternalData.insertRow( nAfterIndex );
+ nMaxRep = m_aInternalData.getColumnCount();
}
else
{
- getInternalData().insertColumn( nAfterIndex );
- nMaxRep = getInternalData().getRowCount();
+ m_aInternalData.insertColumn( nAfterIndex );
+ nMaxRep = m_aInternalData.getRowCount();
}
// notify change to all affected ranges
tSequenceMap::const_iterator aBegin( m_aSequenceMap.lower_bound( C2U("0")));
tSequenceMap::const_iterator aEnd( m_aSequenceMap.upper_bound( OUString::valueOf( nMaxRep )));
- ::std::for_each( aBegin, aEnd, lcl_modifySeqMapValue());
+ ::std::for_each( aBegin, aEnd, lcl_setModified());
tSequenceMapRange aRange( m_aSequenceMap.equal_range( lcl_aCategoriesRangeName ));
- ::std::for_each( aRange.first, aRange.second, lcl_modifySeqMapValue());
+ ::std::for_each( aRange.first, aRange.second, lcl_setModified());
}
void SAL_CALL InternalDataProvider::deleteDataPointForAllSequences( ::sal_Int32 nAtIndex )
@@ -1314,46 +965,49 @@ void SAL_CALL InternalDataProvider::deleteDataPointForAllSequences( ::sal_Int32
sal_Int32 nMaxRep = 0;
if( m_bDataInColumns )
{
- getInternalData().deleteRow( nAtIndex );
- nMaxRep = getInternalData().getColumnCount();
+ m_aInternalData.deleteRow( nAtIndex );
+ nMaxRep = m_aInternalData.getColumnCount();
}
else
{
- getInternalData().deleteColumn( nAtIndex );
- nMaxRep = getInternalData().getRowCount();
+ m_aInternalData.deleteColumn( nAtIndex );
+ nMaxRep = m_aInternalData.getRowCount();
}
// notify change to all affected ranges
tSequenceMap::const_iterator aBegin( m_aSequenceMap.lower_bound( C2U("0")));
tSequenceMap::const_iterator aEnd( m_aSequenceMap.upper_bound( OUString::valueOf( nMaxRep )));
- ::std::for_each( aBegin, aEnd, lcl_modifySeqMapValue());
+ ::std::for_each( aBegin, aEnd, lcl_setModified());
tSequenceMapRange aRange( m_aSequenceMap.equal_range( lcl_aCategoriesRangeName ));
- ::std::for_each( aRange.first, aRange.second, lcl_modifySeqMapValue());
+ ::std::for_each( aRange.first, aRange.second, lcl_setModified());
}
void SAL_CALL InternalDataProvider::swapDataPointWithNextOneForAllSequences( ::sal_Int32 nAtIndex )
throw (uno::RuntimeException)
{
- getInternalData().swapAllDataAtIndexWithNext( nAtIndex, m_bDataInColumns );
+ if( m_bDataInColumns )
+ m_aInternalData.swapRowWithNext( nAtIndex );
+ else
+ m_aInternalData.swapColumnWithNext( nAtIndex );
sal_Int32 nMaxRep = (m_bDataInColumns
- ? getInternalData().getColumnCount()
- : getInternalData().getRowCount());
+ ? m_aInternalData.getColumnCount()
+ : m_aInternalData.getRowCount());
// notify change to all affected ranges
tSequenceMap::const_iterator aBegin( m_aSequenceMap.lower_bound( C2U("0")));
tSequenceMap::const_iterator aEnd( m_aSequenceMap.upper_bound( OUString::valueOf( nMaxRep )));
- ::std::for_each( aBegin, aEnd, lcl_modifySeqMapValue());
+ ::std::for_each( aBegin, aEnd, lcl_setModified());
tSequenceMapRange aRange( m_aSequenceMap.equal_range( lcl_aCategoriesRangeName ));
- ::std::for_each( aRange.first, aRange.second, lcl_modifySeqMapValue());
+ ::std::for_each( aRange.first, aRange.second, lcl_setModified());
}
void SAL_CALL InternalDataProvider::registerDataSequenceForChanges( const Reference< chart2::data::XDataSequence >& xSeq )
throw (uno::RuntimeException)
{
if( xSeq.is())
- addDataSequenceToMap( xSeq->getSourceRangeRepresentation(), xSeq );
+ lcl_addDataSequenceToMap( xSeq->getSourceRangeRepresentation(), xSeq );
}
@@ -1364,28 +1018,28 @@ OUString SAL_CALL InternalDataProvider::convertRangeToXML( const OUString& aRang
{
XMLRangeHelper::CellRange aRange;
aRange.aTableName = OUString(RTL_CONSTASCII_USTRINGPARAM("local-table"));
- impl::InternalData & rData( getInternalData());
// attention: this data provider has the limitation that it stores
// internally if data comes from columns or rows. It is intended for
// creating only one used data source.
// @todo: add this information in the range representation strings
- if( aRangeRepresentation.equals( lcl_aCategoriesRangeName ))
+ if( aRangeRepresentation.match( lcl_aCategoriesRangeName ))
{
+ OSL_ASSERT( aRangeRepresentation.equals( lcl_aCategoriesRangeName ) );//it is not expected nor implmented that only parts of the categories are really requested
aRange.aUpperLeft.bIsEmpty = false;
if( m_bDataInColumns )
{
aRange.aUpperLeft.nColumn = 0;
aRange.aUpperLeft.nRow = 1;
aRange.aLowerRight = aRange.aUpperLeft;
- aRange.aLowerRight.nRow = rData.getRowCount();
+ aRange.aLowerRight.nRow = m_aInternalData.getRowCount();
}
else
{
aRange.aUpperLeft.nColumn = 1;
aRange.aUpperLeft.nRow = 0;
aRange.aLowerRight = aRange.aUpperLeft;
- aRange.aLowerRight.nColumn = rData.getColumnCount();
+ aRange.aLowerRight.nColumn = m_aInternalData.getColumnCount();
}
}
else if( aRangeRepresentation.match( lcl_aLabelRangePrefix ))
@@ -1410,8 +1064,8 @@ OUString SAL_CALL InternalDataProvider::convertRangeToXML( const OUString& aRang
aRange.aLowerRight.bIsEmpty = false;
aRange.aUpperLeft.nColumn = 0;
aRange.aUpperLeft.nRow = 0;
- aRange.aLowerRight.nColumn = rData.getColumnCount();
- aRange.aLowerRight.nRow = rData.getRowCount();
+ aRange.aLowerRight.nColumn = m_aInternalData.getColumnCount();
+ aRange.aLowerRight.nRow = m_aInternalData.getRowCount();
}
else
{
@@ -1422,14 +1076,14 @@ OUString SAL_CALL InternalDataProvider::convertRangeToXML( const OUString& aRang
aRange.aUpperLeft.nColumn = nIndex + 1;
aRange.aUpperLeft.nRow = 1;
aRange.aLowerRight = aRange.aUpperLeft;
- aRange.aLowerRight.nRow = rData.getRowCount();
+ aRange.aLowerRight.nRow = m_aInternalData.getRowCount();
}
else
{
aRange.aUpperLeft.nColumn = 1;
aRange.aUpperLeft.nRow = nIndex + 1;
aRange.aLowerRight = aRange.aUpperLeft;
- aRange.aLowerRight.nColumn = rData.getColumnCount();
+ aRange.aLowerRight.nColumn = m_aInternalData.getColumnCount();
}
}
@@ -1478,46 +1132,130 @@ OUString SAL_CALL InternalDataProvider::convertRangeFromXML( const OUString& aXM
return OUString::valueOf( aRange.aUpperLeft.nRow - 1 );
}
+namespace
+{
+Sequence< Sequence< OUString > > lcl_convertComplexVectorToSequence( const vector< vector< OUString > >& rIn )
+{
+ Sequence< Sequence< OUString > > aRet;
+ sal_Int32 nOuterCount = rIn.size();
+ if( nOuterCount )
+ {
+ aRet.realloc(nOuterCount);
+ for( sal_Int32 nN=0; nN<nOuterCount; nN++)
+ aRet[nN]=ContainerHelper::ContainerToSequence( rIn[nN] );
+ }
+ return aRet;
+}
+
+vector< vector< OUString > > lcl_convertComplexSequenceToVector( const Sequence< Sequence< OUString > >& rIn )
+{
+ vector< vector< OUString > > aRet;
+ sal_Int32 nOuterCount = rIn.getLength();
+ for( sal_Int32 nN=0; nN<nOuterCount; nN++)
+ aRet.push_back( ContainerHelper::SequenceToVector( rIn[nN] ) );
+ return aRet;
+}
+
+class SplitCategoriesProvider_ForComplexDescriptions : public SplitCategoriesProvider
+{
+public:
+
+ explicit SplitCategoriesProvider_ForComplexDescriptions( const ::std::vector< ::std::vector< ::rtl::OUString > >& rComplexDescriptions )
+ : m_rComplexDescriptions( rComplexDescriptions )
+ {}
+ virtual ~SplitCategoriesProvider_ForComplexDescriptions()
+ {}
+
+ virtual sal_Int32 getLevelCount() const;
+ virtual uno::Sequence< rtl::OUString > getStringsForLevel( sal_Int32 nIndex ) const;
+
+private:
+ const ::std::vector< ::std::vector< ::rtl::OUString > >& m_rComplexDescriptions;
+};
+
+sal_Int32 SplitCategoriesProvider_ForComplexDescriptions::getLevelCount() const
+{
+ return lcl_getInnerLevelCount( m_rComplexDescriptions );
+}
+uno::Sequence< rtl::OUString > SplitCategoriesProvider_ForComplexDescriptions::getStringsForLevel( sal_Int32 nLevel ) const
+{
+ uno::Sequence< rtl::OUString > aResult;
+ if( nLevel < lcl_getInnerLevelCount( m_rComplexDescriptions ) )
+ {
+ aResult.realloc( m_rComplexDescriptions.size() );
+ transform( m_rComplexDescriptions.begin(), m_rComplexDescriptions.end(),
+ aResult.getArray(), lcl_getStringFromLevelVector(nLevel) );
+ }
+ return aResult;
+}
+
+}//anonymous namespace
+
+// ____ XComplexDescriptionAccess ____
+Sequence< Sequence< OUString > > SAL_CALL InternalDataProvider::getComplexRowDescriptions() throw (uno::RuntimeException)
+{
+ return lcl_convertComplexVectorToSequence( m_aInternalData.getComplexRowLabels() );
+}
+void SAL_CALL InternalDataProvider::setComplexRowDescriptions( const Sequence< Sequence< ::rtl::OUString > >& aRowDescriptions ) throw (uno::RuntimeException)
+{
+ m_aInternalData.setComplexRowLabels( lcl_convertComplexSequenceToVector(aRowDescriptions) );
+}
+Sequence< Sequence< ::rtl::OUString > > SAL_CALL InternalDataProvider::getComplexColumnDescriptions() throw (uno::RuntimeException)
+{
+ return lcl_convertComplexVectorToSequence( m_aInternalData.getComplexColumnLabels() );
+}
+void SAL_CALL InternalDataProvider::setComplexColumnDescriptions( const Sequence< Sequence< ::rtl::OUString > >& aColumnDescriptions ) throw (uno::RuntimeException)
+{
+ m_aInternalData.setComplexColumnLabels( lcl_convertComplexSequenceToVector(aColumnDescriptions) );
+}
+
// ____ XChartDataArray ____
-// note: do not use m_bDataInColumns for all XChartDataArray-specific code
-// the chart-API assumes data is always in rows
Sequence< Sequence< double > > SAL_CALL InternalDataProvider::getData()
throw (uno::RuntimeException)
{
- return getInternalData().getData( false );
+ return m_aInternalData.getData();
}
-void SAL_CALL InternalDataProvider::setData( const Sequence< Sequence< double > >& aData )
+void SAL_CALL InternalDataProvider::setData( const Sequence< Sequence< double > >& rDataInRows )
throw (uno::RuntimeException)
{
- return getInternalData().setData( aData, false );
+ return m_aInternalData.setData( rDataInRows );
}
-Sequence< OUString > SAL_CALL InternalDataProvider::getRowDescriptions()
+void SAL_CALL InternalDataProvider::setRowDescriptions( const Sequence< OUString >& aRowDescriptions )
throw (uno::RuntimeException)
{
- return ContainerHelper::ContainerToSequence( getInternalData().getRowLabels());
+ vector< vector< OUString > > aComplexDescriptions( aRowDescriptions.getLength() );
+ transform( aComplexDescriptions.begin(), aComplexDescriptions.end(), aRowDescriptions.getConstArray(),
+ aComplexDescriptions.begin(), lcl_setStringAtLevel(0) );
+ m_aInternalData.setComplexRowLabels( aComplexDescriptions );
}
-void SAL_CALL InternalDataProvider::setRowDescriptions( const Sequence< OUString >& aRowDescriptions )
+void SAL_CALL InternalDataProvider::setColumnDescriptions( const Sequence< OUString >& aColumnDescriptions )
throw (uno::RuntimeException)
{
- getInternalData().setRowLabels( ContainerHelper::SequenceToVector( aRowDescriptions ));
+ vector< vector< OUString > > aComplexDescriptions( aColumnDescriptions.getLength() );
+ transform( aComplexDescriptions.begin(), aComplexDescriptions.end(), aColumnDescriptions.getConstArray(),
+ aComplexDescriptions.begin(), lcl_setStringAtLevel(0) );
+ m_aInternalData.setComplexColumnLabels( aComplexDescriptions );
}
-Sequence< OUString > SAL_CALL InternalDataProvider::getColumnDescriptions()
+Sequence< OUString > SAL_CALL InternalDataProvider::getRowDescriptions()
throw (uno::RuntimeException)
{
- return ContainerHelper::ContainerToSequence( getInternalData().getColumnLabels());
+ vector< vector< OUString > > aComplexLabels( m_aInternalData.getComplexRowLabels() );
+ SplitCategoriesProvider_ForComplexDescriptions aProvider( aComplexLabels );
+ return ExplicitCategoriesProvider::getExplicitSimpleCategories( aProvider );
}
-void SAL_CALL InternalDataProvider::setColumnDescriptions( const Sequence< OUString >& aColumnDescriptions )
+Sequence< OUString > SAL_CALL InternalDataProvider::getColumnDescriptions()
throw (uno::RuntimeException)
{
- getInternalData().setColumnLabels( ContainerHelper::SequenceToVector( aColumnDescriptions ));
+ vector< vector< OUString > > aComplexLabels( m_aInternalData.getComplexColumnLabels() );
+ SplitCategoriesProvider_ForComplexDescriptions aProvider( aComplexLabels );
+ return ExplicitCategoriesProvider::getExplicitSimpleCategories( aProvider );
}
-
// ____ XChartData (base of XChartDataArray) ____
void SAL_CALL InternalDataProvider::addChartDataChangeEventListener(
const Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& )
diff --git a/chart2/source/tools/LineProperties.cxx b/chart2/source/tools/LineProperties.cxx
index cb72d4336faa..95cf95e21a86 100644
--- a/chart2/source/tools/LineProperties.cxx
+++ b/chart2/source/tools/LineProperties.cxx
@@ -105,7 +105,7 @@ void LineProperties::AddDefaultsToMap(
::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINE_WIDTH, 0 );
::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINE_COLOR, 0x000000 ); // black
::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, PROP_LINE_TRANSPARENCE, 0 );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_JOINT, drawing::LineJoint_NONE );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_JOINT, drawing::LineJoint_ROUND );
}
//static
diff --git a/chart2/source/tools/ObjectIdentifier.cxx b/chart2/source/tools/ObjectIdentifier.cxx
index 59e608248167..0599f9317aed 100644
--- a/chart2/source/tools/ObjectIdentifier.cxx
+++ b/chart2/source/tools/ObjectIdentifier.cxx
@@ -59,6 +59,7 @@ using namespace ::com::sun::star::chart2;
using rtl::OUString;
using rtl::OUStringBuffer;
using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Any;
static OUString m_aMultiClick( C2U("MultiClick") );
static OUString m_aDragMethodEquals( C2U("DragMethod=") );
@@ -251,6 +252,94 @@ void lcl_getDiagramAndCooSys( const OUString& rObjectCID
} //anonymous namespace
+ObjectIdentifier::ObjectIdentifier()
+ :m_aObjectCID( OUString() )
+ ,m_xAdditionalShape( 0 )
+{
+}
+
+ObjectIdentifier::ObjectIdentifier( const OUString& rObjectCID )
+ :m_aObjectCID( rObjectCID )
+ ,m_xAdditionalShape( 0 )
+{
+}
+
+ObjectIdentifier::ObjectIdentifier( const Reference< drawing::XShape >& rxShape )
+ :m_aObjectCID( OUString() )
+ ,m_xAdditionalShape( rxShape )
+{
+}
+
+ObjectIdentifier::ObjectIdentifier( const Any& rAny )
+ :m_aObjectCID( OUString() )
+ ,m_xAdditionalShape( 0 )
+{
+ const uno::Type& rType = rAny.getValueType();
+ if ( rType == ::getCppuType( static_cast< const OUString* >( 0 ) ) )
+ {
+ rAny >>= m_aObjectCID;
+ }
+ else if ( rType == ::getCppuType( static_cast< const Reference< drawing::XShape >* >( 0 ) ) )
+ {
+ rAny >>= m_xAdditionalShape;
+ }
+}
+
+ObjectIdentifier::~ObjectIdentifier()
+{
+}
+
+ObjectIdentifier::ObjectIdentifier( const ObjectIdentifier& rOID )
+ :m_aObjectCID( rOID.m_aObjectCID )
+ ,m_xAdditionalShape( rOID.m_xAdditionalShape )
+{
+
+}
+
+ObjectIdentifier& ObjectIdentifier::operator=( const ObjectIdentifier& rOID )
+{
+ m_aObjectCID = rOID.m_aObjectCID;
+ m_xAdditionalShape = rOID.m_xAdditionalShape;
+ return *this;
+}
+
+bool ObjectIdentifier::operator==( const ObjectIdentifier& rOID ) const
+{
+ if ( areIdenticalObjects( m_aObjectCID, rOID.m_aObjectCID ) &&
+ ( m_xAdditionalShape == rOID.m_xAdditionalShape ) )
+ {
+ return true;
+ }
+ return false;
+}
+
+bool ObjectIdentifier::operator!=( const ObjectIdentifier& rOID ) const
+{
+ return !operator==( rOID );
+}
+
+bool ObjectIdentifier::operator<( const ObjectIdentifier& rOID ) const
+{
+ bool bReturn = false;
+ if ( m_aObjectCID.getLength() && rOID.m_aObjectCID.getLength() )
+ {
+ bReturn = ( m_aObjectCID.compareTo( rOID.m_aObjectCID ) < 0 );
+ }
+ else if ( m_aObjectCID.getLength() )
+ {
+ bReturn = true;
+ }
+ else if ( rOID.m_aObjectCID.getLength() )
+ {
+ bReturn = false;
+ }
+ else if ( m_xAdditionalShape.is() && rOID.m_xAdditionalShape.is() )
+ {
+ bReturn = ( m_xAdditionalShape < rOID.m_xAdditionalShape );
+ }
+ return bReturn;
+}
+
//static
OUString ObjectIdentifier::createClassifiedIdentifierForObject(
const Reference< uno::XInterface >& xObject
@@ -665,6 +754,20 @@ bool ObjectIdentifier::isDragableObject( const OUString& rClassifiedIdentifier )
return false;
}
+bool ObjectIdentifier::isDragableObject()
+{
+ bool bReturn = false;
+ if ( isAutoGeneratedObject() )
+ {
+ bReturn = isDragableObject( m_aObjectCID );
+ }
+ else if ( isAdditionalShape() )
+ {
+ bReturn = true;
+ }
+ return bReturn;
+}
+
//static
bool ObjectIdentifier::isRotateableObject( const OUString& rClassifiedIdentifier )
{
@@ -903,6 +1006,20 @@ ObjectType ObjectIdentifier::getObjectType( const OUString& rCID )
return eRet;
}
+ObjectType ObjectIdentifier::getObjectType()
+{
+ ObjectType eObjectType( OBJECTTYPE_UNKNOWN );
+ if ( isAutoGeneratedObject() )
+ {
+ eObjectType = getObjectType( m_aObjectCID );
+ }
+ else if ( isAdditionalShape() )
+ {
+ eObjectType = OBJECTTYPE_SHAPE;
+ }
+ return eObjectType;
+}
+
//static
OUString ObjectIdentifier::createDataCurveCID(
const OUString& rSeriesParticle
@@ -1329,7 +1446,46 @@ OUString ObjectIdentifier::getMovedSeriesCID( const ::rtl::OUString& rObjectCID,
OUString aRet = ObjectIdentifier::createParticleForSeries( nDiagramIndex, nCooSysIndex, nChartTypeIndex, nSeriesIndex );
return ObjectIdentifier::createClassifiedIdentifierForParticle( aRet );
}
-//static
+
+bool ObjectIdentifier::isValid() const
+{
+ return ( isAutoGeneratedObject() || isAdditionalShape() );
+}
+
+bool ObjectIdentifier::isAutoGeneratedObject() const
+{
+ return ( m_aObjectCID.getLength() > 0 );
+}
+
+bool ObjectIdentifier::isAdditionalShape() const
+{
+ return m_xAdditionalShape.is();
+}
+
+OUString ObjectIdentifier::getObjectCID() const
+{
+ return m_aObjectCID;
+}
+
+Reference< drawing::XShape > ObjectIdentifier::getAdditionalShape() const
+{
+ return m_xAdditionalShape;
+}
+
+Any ObjectIdentifier::getAny() const
+{
+ Any aAny;
+ if ( isAutoGeneratedObject() )
+ {
+ aAny = uno::makeAny( getObjectCID() );
+ }
+ else if ( isAdditionalShape() )
+ {
+ aAny = uno::makeAny( getAdditionalShape() );
+ }
+ return aAny;
+}
+
//.............................................................................
} //namespace chart
//.............................................................................
diff --git a/chart2/source/tools/RangeHighlighter.cxx b/chart2/source/tools/RangeHighlighter.cxx
index 73c8f064faf0..20359bfa6b4c 100644
--- a/chart2/source/tools/RangeHighlighter.cxx
+++ b/chart2/source/tools/RangeHighlighter.cxx
@@ -39,6 +39,7 @@
#include <com/sun/star/chart2/XDataSeries.hpp>
#include <com/sun/star/chart/ErrorBarStyle.hpp>
+#include <com/sun/star/drawing/XShape.hpp>
#define PREFERED_DEFAULT_COLOR 0x0000ff
@@ -106,66 +107,81 @@ void RangeHighlighter::determineRanges()
m_bIncludeHiddenCells = ChartModelHelper::isIncludeHiddenCells( xChartModel );
uno::Any aSelection( m_xSelectionSupplier->getSelection());
- OUString aCID;
- if(( aSelection >>= aCID ) &&
- aCID.getLength() > 0 )
+ const uno::Type& rType = aSelection.getValueType();
+
+ if ( rType == ::getCppuType( static_cast< const OUString* >( 0 ) ) )
{
// @todo??: maybe getSelection() should return a model object rather than a CID
- ObjectType eObjectType = ObjectIdentifier::getObjectType( aCID );
- sal_Int32 nIndex = ObjectIdentifier::getIndexFromParticleOrCID( aCID );
- Reference< chart2::XDataSeries > xDataSeries( ObjectIdentifier::getDataSeriesForCID( aCID, xChartModel ) );
- if( OBJECTTYPE_LEGEND_ENTRY == eObjectType )
+ OUString aCID;
+ aSelection >>= aCID;
+ if ( aCID.getLength() > 0 )
{
- OUString aParentParticel( ObjectIdentifier::getFullParentParticle( aCID ) );
- ObjectType eParentObjectType = ObjectIdentifier::getObjectType( aParentParticel );
- eObjectType = eParentObjectType;
- if( OBJECTTYPE_DATA_POINT == eObjectType )
- nIndex = ObjectIdentifier::getIndexFromParticleOrCID( aParentParticel );
- }
+ ObjectType eObjectType = ObjectIdentifier::getObjectType( aCID );
+ sal_Int32 nIndex = ObjectIdentifier::getIndexFromParticleOrCID( aCID );
+ Reference< chart2::XDataSeries > xDataSeries( ObjectIdentifier::getDataSeriesForCID( aCID, xChartModel ) );
+ if( OBJECTTYPE_LEGEND_ENTRY == eObjectType )
+ {
+ OUString aParentParticel( ObjectIdentifier::getFullParentParticle( aCID ) );
+ ObjectType eParentObjectType = ObjectIdentifier::getObjectType( aParentParticel );
+ eObjectType = eParentObjectType;
+ if( OBJECTTYPE_DATA_POINT == eObjectType )
+ nIndex = ObjectIdentifier::getIndexFromParticleOrCID( aParentParticel );
+ }
- if( OBJECTTYPE_DATA_POINT == eObjectType || OBJECTTYPE_DATA_LABEL == eObjectType )
- {
- // Data Point
- fillRangesForDataPoint( xDataSeries, nIndex );
- return;
- }
- else if( OBJECTTYPE_DATA_ERRORS == eObjectType )
- {
- // select error bar ranges, or data series, if the style is
- // not set to FROM_DATA
- fillRangesForErrorBars( ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ), xDataSeries );
- return;
- }
- else if( xDataSeries.is() )
- {
- // Data Series
- fillRangesForDataSeries( xDataSeries );
- return;
- }
- else if( OBJECTTYPE_AXIS == eObjectType )
- {
- // Axis (Categories)
- Reference< chart2::XAxis > xAxis( ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ), uno::UNO_QUERY );
- if( xAxis.is())
+ if( OBJECTTYPE_DATA_POINT == eObjectType || OBJECTTYPE_DATA_LABEL == eObjectType )
{
- fillRangesForCategories( xAxis );
+ // Data Point
+ fillRangesForDataPoint( xDataSeries, nIndex );
return;
}
- }
- else if( OBJECTTYPE_PAGE == eObjectType
- || OBJECTTYPE_DIAGRAM == eObjectType
- || OBJECTTYPE_DIAGRAM_WALL == eObjectType
- || OBJECTTYPE_DIAGRAM_FLOOR == eObjectType
- )
- {
- // Diagram
- Reference< chart2::XDiagram > xDia( ObjectIdentifier::getDiagramForCID( aCID, xChartModel ) );
- if( xDia.is())
+ else if( OBJECTTYPE_DATA_ERRORS == eObjectType )
{
- fillRangesForDiagram( xDia );
+ // select error bar ranges, or data series, if the style is
+ // not set to FROM_DATA
+ fillRangesForErrorBars( ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ), xDataSeries );
return;
}
+ else if( xDataSeries.is() )
+ {
+ // Data Series
+ fillRangesForDataSeries( xDataSeries );
+ return;
+ }
+ else if( OBJECTTYPE_AXIS == eObjectType )
+ {
+ // Axis (Categories)
+ Reference< chart2::XAxis > xAxis( ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ), uno::UNO_QUERY );
+ if( xAxis.is())
+ {
+ fillRangesForCategories( xAxis );
+ return;
+ }
+ }
+ else if( OBJECTTYPE_PAGE == eObjectType
+ || OBJECTTYPE_DIAGRAM == eObjectType
+ || OBJECTTYPE_DIAGRAM_WALL == eObjectType
+ || OBJECTTYPE_DIAGRAM_FLOOR == eObjectType
+ )
+ {
+ // Diagram
+ Reference< chart2::XDiagram > xDia( ObjectIdentifier::getDiagramForCID( aCID, xChartModel ) );
+ if( xDia.is())
+ {
+ fillRangesForDiagram( xDia );
+ return;
+ }
+ }
+ }
+ }
+ else if ( rType == ::getCppuType( static_cast< const Reference< drawing::XShape >* >( 0 ) ) )
+ {
+ // #i12587# support for shapes in chart
+ Reference< drawing::XShape > xShape;
+ aSelection >>= xShape;
+ if ( xShape.is() )
+ {
+ return;
}
}
else
diff --git a/chart2/source/tools/WrappedIgnoreProperty.cxx b/chart2/source/tools/WrappedIgnoreProperty.cxx
index bebbf77ceeef..aaa6c545a799 100644
--- a/chart2/source/tools/WrappedIgnoreProperty.cxx
+++ b/chart2/source/tools/WrappedIgnoreProperty.cxx
@@ -101,7 +101,7 @@ void WrappedIgnoreProperties::addIgnoreLineProperties( std::vector< WrappedPrope
rList.push_back( new WrappedIgnoreProperty( C2U( "LineColor" ), uno::makeAny( sal_Int32(0) ) ) );
rList.push_back( new WrappedIgnoreProperty( C2U( "LineTransparence" ), uno::makeAny( sal_Int16(0) ) ) );
rList.push_back( new WrappedIgnoreProperty( C2U( "LineWidth" ), uno::makeAny( sal_Int32(0) ) ) );
- rList.push_back( new WrappedIgnoreProperty( C2U( "LineJoint" ), uno::makeAny( drawing::LineJoint_NONE ) ) );
+ rList.push_back( new WrappedIgnoreProperty( C2U( "LineJoint" ), uno::makeAny( drawing::LineJoint_ROUND ) ) );
}
//static
diff --git a/chart2/source/tools/makefile.mk b/chart2/source/tools/makefile.mk
index b459d489e773..2f990af7adb0 100644
--- a/chart2/source/tools/makefile.mk
+++ b/chart2/source/tools/makefile.mk
@@ -64,6 +64,7 @@ SLOFILES= \
$(SLO)$/DiagramHelper.obj \
$(SLO)$/ExponentialRegressionCurveCalculator.obj \
$(SLO)$/ImplOPropertySet.obj \
+ $(SLO)$/InternalData.obj \
$(SLO)$/InternalDataProvider.obj \
$(SLO)$/LabeledDataSequence.obj \
$(SLO)$/LinearRegressionCurveCalculator.obj \
@@ -101,9 +102,6 @@ SLOFILES= \
$(SLO)$/ChartDebugTrace.obj \
$(SLO)$/_serviceregistration_tools.obj \
$(SLO)$/UncachedDataSequence.obj \
- $(SLO)$/UndoManager.obj \
- $(SLO)$/UndoGuard.obj \
- $(SLO)$/ImplUndoManager.obj \
$(SLO)$/XMLRangeHelper.obj \
$(SLO)$/ModifyListenerHelper.obj \
$(SLO)$/ModifyListenerCallBack.obj \
diff --git a/chart2/source/tools/tools.map b/chart2/source/tools/tools.map
deleted file mode 100644
index 07b1790d5754..000000000000
--- a/chart2/source/tools/tools.map
+++ /dev/null
@@ -1,8 +0,0 @@
-CHART_1_0 {
- global:
- component_getImplementationEnvironment;
- component_writeInfo;
- component_getFactory;
- local:
- *;
-};
diff --git a/chart2/source/view/axes/TickmarkHelper.cxx b/chart2/source/view/axes/TickmarkHelper.cxx
index 20f452431492..4d1f48795fa7 100644
--- a/chart2/source/view/axes/TickmarkHelper.cxx
+++ b/chart2/source/view/axes/TickmarkHelper.cxx
@@ -48,6 +48,7 @@ TickInfo::TickInfo()
, aTickScreenPosition(0.0,0.0)
, bPaintIt( true )
, xTextShape( NULL )
+, nFactorForLimitedTextWidth(1)
{
}
@@ -59,10 +60,45 @@ void TickInfo::updateUnscaledValue( const uno::Reference< XScaling >& xInverseSc
this->fUnscaledTickValue = this->fScaledTickValue;
}
-TickIter::TickIter( const uno::Sequence< uno::Sequence< double > >& rTicks
+sal_Int32 TickInfo::getScreenDistanceBetweenTicks( const TickInfo& rOherTickInfo ) const
+{
+ //return the positive distance between the two first tickmarks in screen values
+
+ B2DVector aDistance = rOherTickInfo.aTickScreenPosition - aTickScreenPosition;
+ sal_Int32 nRet = static_cast<sal_Int32>(aDistance.getLength());
+ if(nRet<0)
+ nRet *= -1;
+ return nRet;
+}
+
+PureTickIter::PureTickIter( ::std::vector< TickInfo >& rTickInfoVector )
+ : m_rTickVector(rTickInfoVector)
+ , m_aTickIter(m_rTickVector.begin())
+{
+}
+PureTickIter::~PureTickIter()
+{
+}
+TickInfo* PureTickIter::firstInfo()
+{
+ m_aTickIter = m_rTickVector.begin();
+ if(m_aTickIter!=m_rTickVector.end())
+ return &*m_aTickIter;
+ return 0;
+}
+TickInfo* PureTickIter::nextInfo()
+{
+ m_aTickIter++;
+ if(m_aTickIter!=m_rTickVector.end())
+ return &*m_aTickIter;
+ return 0;
+}
+
+EquidistantTickIter::EquidistantTickIter( const uno::Sequence< uno::Sequence< double > >& rTicks
, const ExplicitIncrementData& rIncrement
, sal_Int32 nMinDepth, sal_Int32 nMaxDepth )
- : m_pSimpleTicks(&rTicks), m_pInfoTicks(NULL)
+ : m_pSimpleTicks(&rTicks)
+ , m_pInfoTicks(0)
, m_rIncrement(rIncrement)
, m_nMinDepth(0), m_nMaxDepth(0)
, m_nTickCount(0), m_pnPositions(NULL)
@@ -72,10 +108,11 @@ TickIter::TickIter( const uno::Sequence< uno::Sequence< double > >& rTicks
initIter( nMinDepth, nMaxDepth );
}
-TickIter::TickIter( ::std::vector< ::std::vector< TickInfo > >& rTicks
+EquidistantTickIter::EquidistantTickIter( ::std::vector< ::std::vector< TickInfo > >& rTicks
, const ExplicitIncrementData& rIncrement
, sal_Int32 nMinDepth, sal_Int32 nMaxDepth )
- : m_pSimpleTicks(NULL), m_pInfoTicks(&rTicks)
+ : m_pSimpleTicks(NULL)
+ , m_pInfoTicks(&rTicks)
, m_rIncrement(rIncrement)
, m_nMinDepth(0), m_nMaxDepth(0)
, m_nTickCount(0), m_pnPositions(NULL)
@@ -85,7 +122,7 @@ TickIter::TickIter( ::std::vector< ::std::vector< TickInfo > >& rTicks
initIter( nMinDepth, nMaxDepth );
}
-void TickIter::initIter( sal_Int32 /*nMinDepth*/, sal_Int32 nMaxDepth )
+void EquidistantTickIter::initIter( sal_Int32 /*nMinDepth*/, sal_Int32 nMaxDepth )
{
m_nMaxDepth = nMaxDepth;
if(nMaxDepth<0 || m_nMaxDepth>getMaxDepth())
@@ -128,14 +165,14 @@ void TickIter::initIter( sal_Int32 /*nMinDepth*/, sal_Int32 nMaxDepth )
}
}
-TickIter::~TickIter()
+EquidistantTickIter::~EquidistantTickIter()
{
delete[] m_pnPositions;
delete[] m_pnPreParentCount;
delete[] m_pbIntervalFinished;
}
-sal_Int32 TickIter::getStartDepth() const
+sal_Int32 EquidistantTickIter::getStartDepth() const
{
//find the depth of the first visible tickmark:
//it is the depth of the smallest value
@@ -156,7 +193,7 @@ sal_Int32 TickIter::getStartDepth() const
return nReturnDepth;
}
-double* TickIter::firstValue()
+double* EquidistantTickIter::firstValue()
{
if( gotoFirst() )
{
@@ -166,14 +203,14 @@ double* TickIter::firstValue()
return NULL;
}
-TickInfo* TickIter::firstInfo()
+TickInfo* EquidistantTickIter::firstInfo()
{
if( m_pInfoTicks && gotoFirst() )
return &(*m_pInfoTicks)[m_nCurrentDepth][m_pnPositions[m_nCurrentDepth]];
return NULL;
}
-sal_Int32 TickIter::getIntervalCount( sal_Int32 nDepth )
+sal_Int32 EquidistantTickIter::getIntervalCount( sal_Int32 nDepth )
{
if(nDepth>m_rIncrement.SubIncrements.getLength() || nDepth<0)
return 0;
@@ -184,7 +221,7 @@ sal_Int32 TickIter::getIntervalCount( sal_Int32 nDepth )
return m_rIncrement.SubIncrements[nDepth-1].IntervalCount;
}
-bool TickIter::isAtLastPartTick()
+bool EquidistantTickIter::isAtLastPartTick()
{
if(!m_nCurrentDepth)
return false;
@@ -203,7 +240,7 @@ bool TickIter::isAtLastPartTick()
return bRet;
}
-bool TickIter::gotoFirst()
+bool EquidistantTickIter::gotoFirst()
{
if( m_nMaxDepth<0 )
return false;
@@ -219,7 +256,7 @@ bool TickIter::gotoFirst()
return true;
}
-bool TickIter::gotoNext()
+bool EquidistantTickIter::gotoNext()
{
if( m_nCurrentPos < 0 )
return false;
@@ -250,7 +287,7 @@ bool TickIter::gotoNext()
return true;
}
-bool TickIter::gotoIndex( sal_Int32 nTickIndex )
+bool EquidistantTickIter::gotoIndex( sal_Int32 nTickIndex )
{
if( nTickIndex < 0 )
return false;
@@ -268,16 +305,16 @@ bool TickIter::gotoIndex( sal_Int32 nTickIndex )
return true;
}
-sal_Int32 TickIter::getCurrentIndex() const
+sal_Int32 EquidistantTickIter::getCurrentIndex() const
{
return m_nCurrentPos;
}
-sal_Int32 TickIter::getMaxIndex() const
+sal_Int32 EquidistantTickIter::getMaxIndex() const
{
return m_nTickCount-1;
}
-double* TickIter::nextValue()
+double* EquidistantTickIter::nextValue()
{
if( gotoNext() )
{
@@ -287,7 +324,7 @@ double* TickIter::nextValue()
return NULL;
}
-TickInfo* TickIter::nextInfo()
+TickInfo* EquidistantTickIter::nextInfo()
{
if( m_pInfoTicks && gotoNext() &&
static_cast< sal_Int32 >(
@@ -646,7 +683,7 @@ void TickmarkHelper::getAllTicksShifted( ::std::vector< ::std::vector< TickInfo
void TickmarkHelper::addSubTicks( sal_Int32 nDepth, uno::Sequence< uno::Sequence< double > >& rParentTicks ) const
{
- TickIter aIter( rParentTicks, m_rIncrement, 0, nDepth-1 );
+ EquidistantTickIter aIter( rParentTicks, m_rIncrement, 0, nDepth-1 );
double* pfNextParentTick = aIter.firstValue();
if(!pfNextParentTick)
return;
@@ -753,11 +790,7 @@ sal_Int32 TickmarkHelper_2D::getTickScreenDistance( TickIter& rIter )
if(!pSecondTickInfo || !pFirstTickInfo)
return -1;
- B2DVector aDistance = pSecondTickInfo->aTickScreenPosition-pFirstTickInfo->aTickScreenPosition;
- sal_Int32 nRet = static_cast<sal_Int32>(aDistance.getLength());
- if(nRet<0)
- nRet *= -1;
- return nRet;
+ return pFirstTickInfo->getScreenDistanceBetweenTicks( *pSecondTickInfo );
}
B2DVector TickmarkHelper_2D::getTickScreenPosition2D( double fScaledLogicTickValue ) const
@@ -797,7 +830,7 @@ void TickmarkHelper_2D::addPointSequenceForTickLine( drawing::PointSequenceSeque
rPoints[nSequenceIndex][1].Y = static_cast<sal_Int32>(aEnd.getY());
}
-B2DVector TickmarkHelper_2D::getDistanceAxisTickToText( const AxisProperties& rAxisProperties ) const
+B2DVector TickmarkHelper_2D::getDistanceAxisTickToText( const AxisProperties& rAxisProperties, bool bIncludeFarAwayDistanceIfSo, bool bIncludeSpaceBetweenTickAndText ) const
{
bool bFarAwayLabels = false;
if( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START == rAxisProperties.m_eLabelPos
@@ -843,8 +876,9 @@ B2DVector TickmarkHelper_2D::getDistanceAxisTickToText( const AxisProperties& rA
if( rAxisProperties.m_fInnerDirectionSign != rAxisProperties.m_fLabelDirectionSign )
aOrthoLabelDirection*=-1.0;
aOrthoLabelDirection.normalize();
- aLabelDirection += aOrthoLabelDirection*AXIS2D_TICKLABELSPACING;
- if( bFarAwayLabels )
+ if( bIncludeSpaceBetweenTickAndText )
+ aLabelDirection += aOrthoLabelDirection*AXIS2D_TICKLABELSPACING;
+ if( bFarAwayLabels && bIncludeFarAwayDistanceIfSo )
aLabelDirection += m_aAxisLineToLabelLineShift;
return aLabelDirection;
}
@@ -876,27 +910,6 @@ void TickmarkHelper_2D::updateScreenValues( ::std::vector< ::std::vector< TickIn
}
}
-//'hide' tickmarks with identical screen values in aAllTickInfos
-void TickmarkHelper_2D::hideIdenticalScreenValues(
- ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const
-{
- TickIter aIter( rAllTickInfos, m_rIncrement );
-
- TickInfo* pPreviousTickInfo = aIter.firstInfo();
- if(!pPreviousTickInfo)
- return;
- pPreviousTickInfo->bPaintIt = true;
- for( TickInfo* pTickInfo = aIter.nextInfo(); pTickInfo; pTickInfo = aIter.nextInfo())
- {
- pTickInfo->bPaintIt =
- ( static_cast<sal_Int32>(pTickInfo->aTickScreenPosition.getX())
- != static_cast<sal_Int32>(pPreviousTickInfo->aTickScreenPosition.getX()) )
- ||
- ( static_cast<sal_Int32>(pTickInfo->aTickScreenPosition.getY())
- != static_cast<sal_Int32>(pPreviousTickInfo->aTickScreenPosition.getY()) );
- pPreviousTickInfo = pTickInfo;
- }
-}
//-----------------------------------------------------------------------------
// ___TickmarkHelper_3D___
//-----------------------------------------------------------------------------
diff --git a/chart2/source/view/axes/TickmarkHelper.hxx b/chart2/source/view/axes/TickmarkHelper.hxx
index 01ca56982b3e..78fc2fe1c502 100644
--- a/chart2/source/view/axes/TickmarkHelper.hxx
+++ b/chart2/source/view/axes/TickmarkHelper.hxx
@@ -59,23 +59,48 @@ struct TickInfo
::com::sun::star::uno::Reference<
::com::sun::star::drawing::XShape > xTextShape;
+ rtl::OUString aText;//used only for complex categories so far
+ sal_Int32 nFactorForLimitedTextWidth;//categories in higher levels of complex categories can have more place than a single simple category
+
//methods:
TickInfo();
void updateUnscaledValue( const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XScaling >& xInverseScaling );
-};
+ sal_Int32 getScreenDistanceBetweenTicks( const TickInfo& rOherTickInfo ) const;
+};
class TickIter
{
public:
- TickIter( const ::com::sun::star::uno::Sequence<
+ virtual ~TickIter(){};
+ virtual TickInfo* firstInfo()=0;
+ virtual TickInfo* nextInfo()=0;
+};
+
+class PureTickIter : public TickIter
+{
+public:
+ PureTickIter( ::std::vector< TickInfo >& rTickInfoVector );
+ virtual ~PureTickIter();
+ virtual TickInfo* firstInfo();
+ virtual TickInfo* nextInfo();
+
+private:
+ ::std::vector< TickInfo >& m_rTickVector;
+ ::std::vector< TickInfo >::iterator m_aTickIter;
+};
+
+class EquidistantTickIter : public TickIter
+{
+public:
+ EquidistantTickIter( const ::com::sun::star::uno::Sequence<
::com::sun::star::uno::Sequence< double > >& rTicks
, const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement
, sal_Int32 nMinDepth=0, sal_Int32 nMaxDepth=-1 );
- TickIter( ::std::vector< ::std::vector< TickInfo > >& rTickInfos
+ EquidistantTickIter( ::std::vector< ::std::vector< TickInfo > >& rTickInfos
, const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement
, sal_Int32 nMinDepth=0, sal_Int32 nMaxDepth=-1 );
- virtual ~TickIter();
+ virtual ~EquidistantTickIter();
virtual double* firstValue();
virtual double* nextValue();
@@ -171,7 +196,6 @@ protected: //methods
bool isWithinOuterBorder( double fScaledValue ) const; //all within the outer major tick marks
virtual void updateScreenValues( ::std::vector< ::std::vector< TickInfo > >& /*rAllTickInfos*/ ) const {}
- virtual void hideIdenticalScreenValues( ::std::vector< ::std::vector< TickInfo > >& /*rAllTickInfos*/ ) const {}
protected: //member
::com::sun::star::chart2::ExplicitScaleData m_rScale;
@@ -211,10 +235,11 @@ public:
, sal_Int32 nSequenceIndex
, double fScaledLogicTickValue, double fInnerDirectionSign
, const TickmarkProperties& rTickmarkProperties, bool bPlaceAtLabels ) const;
- ::basegfx::B2DVector getDistanceAxisTickToText( const AxisProperties& rAxisProperties ) const;
+ ::basegfx::B2DVector getDistanceAxisTickToText( const AxisProperties& rAxisProperties
+ , bool bIncludeFarAwayDistanceIfSo = false
+ , bool bIncludeSpaceBetweenTickAndText = true ) const;
virtual void updateScreenValues( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const;
- virtual void hideIdenticalScreenValues( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const;
bool isHorizontalAxis() const;
bool isVerticalAxis() const;
diff --git a/chart2/source/view/axes/VAxisBase.cxx b/chart2/source/view/axes/VAxisBase.cxx
index 79c2529873aa..0159fb20cad6 100644
--- a/chart2/source/view/axes/VAxisBase.cxx
+++ b/chart2/source/view/axes/VAxisBase.cxx
@@ -79,23 +79,31 @@ void SAL_CALL VAxisBase::initAxisLabelProperties( const ::com::sun::star::awt::S
if( !m_aAxisProperties.m_bDisplayLabels )
return;
- if( AxisType::CATEGORY==m_aAxisProperties.m_nAxisType
- || AxisType::SERIES==m_aAxisProperties.m_nAxisType )
+ if( AxisType::SERIES==m_aAxisProperties.m_nAxisType )
{
if( m_aAxisProperties.m_xAxisTextProvider.is() )
m_aTextLabels = m_aAxisProperties.m_xAxisTextProvider->getTextualData();
m_bUseTextLabels = true;
- if( m_aTextLabels.getLength() == 1 && AxisType::SERIES==m_aAxisProperties.m_nAxisType )
+ if( m_aTextLabels.getLength() == 1 )
{
//don't show a single series name
m_aAxisProperties.m_bDisplayLabels = false;
return;
}
}
+ else if( AxisType::CATEGORY==m_aAxisProperties.m_nAxisType )
+ {
+ if( m_aAxisProperties.m_pExplicitCategoriesProvider )
+ m_aTextLabels = m_aAxisProperties.m_pExplicitCategoriesProvider->getSimpleCategories();
+
+ m_bUseTextLabels = true;
+ }
m_aAxisLabelProperties.nNumberFormatKey = m_aAxisProperties.m_nNumberFormatKey;
m_aAxisLabelProperties.init(m_aAxisProperties.m_xAxisModel);
+ if( m_aAxisProperties.m_bComplexCategories && AxisType::CATEGORY == m_aAxisProperties.m_nAxisType )
+ m_aAxisLabelProperties.eStaggering = SIDE_BY_SIDE;
}
void VAxisBase::recordMaximumTextSize( const Reference< drawing::XShape >& xShape, double fRotationAngleDegree )
@@ -152,6 +160,12 @@ void SAL_CALL VAxisBase::setExplicitScaleAndIncrement(
m_aIncrement = rIncrement;
}
+void VAxisBase::createAllTickInfos( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos )
+{
+ std::auto_ptr< TickmarkHelper > apTickmarkHelper( this->createTickmarkHelper() );
+ apTickmarkHelper->getAllTicks( rAllTickInfos );
+}
+
bool VAxisBase::prepareShapeCreation()
{
//returns true if all is ready for further shape creation and any shapes need to be created
@@ -162,14 +176,9 @@ bool VAxisBase::prepareShapeCreation()
{
//-----------------------------------------
//create all scaled tickmark values
- if( m_xTextTarget.is() )
- {
- TickIter aRemoveIter( m_aAllTickInfos, m_aIncrement, 0, 0 );
- removeTextShapesFromTicks( aRemoveIter, m_xTextTarget );
- }
+ removeTextShapesFromTicks();
- std::auto_ptr< TickmarkHelper > apTickmarkHelper( this->createTickmarkHelper() );
- apTickmarkHelper->getAllTicks( m_aAllTickInfos );
+ createAllTickInfos(m_aAllTickInfos);
m_bReCreateAllTickInfos = false;
}
@@ -203,15 +212,25 @@ sal_Int32 VAxisBase::getIndexOfLongestLabel( const uno::Sequence< rtl::OUString
return nRet;
}
-void VAxisBase::removeTextShapesFromTicks( TickIter& rIter, const Reference< drawing::XShapes >& xTarget )
+void VAxisBase::removeTextShapesFromTicks()
{
- for( TickInfo* pTickInfo = rIter.firstInfo()
- ; pTickInfo; pTickInfo = rIter.nextInfo() )
+ if( m_xTextTarget.is() )
{
- if(pTickInfo->xTextShape.is())
+ ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = m_aAllTickInfos.begin();
+ const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = m_aAllTickInfos.end();
+ for( ; aDepthIter != aDepthEnd; aDepthIter++ )
{
- xTarget->remove(pTickInfo->xTextShape);
- pTickInfo->xTextShape = NULL;
+ ::std::vector< TickInfo >::iterator aTickIter = (*aDepthIter).begin();
+ const ::std::vector< TickInfo >::const_iterator aTickEnd = (*aDepthIter).end();
+ for( ; aTickIter != aTickEnd; aTickIter++ )
+ {
+ TickInfo& rTickInfo = (*aTickIter);
+ if(rTickInfo.xTextShape.is())
+ {
+ m_xTextTarget->remove(rTickInfo.xTextShape);
+ rTickInfo.xTextShape = NULL;
+ }
+ }
}
}
}
diff --git a/chart2/source/view/axes/VAxisBase.hxx b/chart2/source/view/axes/VAxisBase.hxx
index fba6d867c808..ba7e94b2070c 100644
--- a/chart2/source/view/axes/VAxisBase.hxx
+++ b/chart2/source/view/axes/VAxisBase.hxx
@@ -67,6 +67,7 @@ public:
throw (::com::sun::star::uno::RuntimeException);
virtual sal_Int32 estimateMaximumAutoMainIncrementCount();
+ virtual void createAllTickInfos( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos );
void setExrtaLinePositionAtOtherAxis( const double& fCrossingAt );
@@ -74,7 +75,7 @@ public:
//-------------------------------------------------------------------------
protected: //methods
sal_Int32 getIndexOfLongestLabel( const ::com::sun::star::uno::Sequence< rtl::OUString >& rLabels );
- void removeTextShapesFromTicks( TickIter& rIter, const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget );
+ void removeTextShapesFromTicks();
void updateUnscaledValuesAtTicks( TickIter& rIter );
virtual bool prepareShapeCreation();
diff --git a/chart2/source/view/axes/VAxisProperties.cxx b/chart2/source/view/axes/VAxisProperties.cxx
index e5c90f0eda4d..1e3e62894741 100644
--- a/chart2/source/view/axes/VAxisProperties.cxx
+++ b/chart2/source/view/axes/VAxisProperties.cxx
@@ -33,6 +33,7 @@
#include "CommonConverters.hxx"
#include "AxisHelper.hxx"
#include "DiagramHelper.hxx"
+#include "ChartModelHelper.hxx"
#include <tools/color.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
@@ -144,6 +145,18 @@ TickmarkProperties AxisProperties::makeTickmarkProperties(
return aTickmarkProperties;
}
+TickmarkProperties AxisProperties::makeTickmarkPropertiesForComplexCategories(
+ sal_Int32 nTickLength, sal_Int32 nTickStartDistanceToAxis, sal_Int32 /*nTextLevel*/ ) const
+{
+ sal_Int32 nTickmarkStyle = (m_fLabelDirectionSign==m_fInnerDirectionSign) ? 2/*outside*/ : 1/*inside*/;
+
+ TickmarkProperties aTickmarkProperties;
+ aTickmarkProperties.Length = nTickLength;// + nTextLevel*( lcl_calcTickLengthForDepth(0,nTickmarkStyle) );
+ aTickmarkProperties.RelativePos = static_cast<sal_Int32>(lcl_getTickOffset(aTickmarkProperties.Length+nTickStartDistanceToAxis,nTickmarkStyle));
+ aTickmarkProperties.aLineProperties = this->makeLinePropertiesForDepth( 0 );
+ return aTickmarkProperties;
+}
+
//static
TickmarkProperties AxisProperties::getBiggestTickmarkProperties()
{
@@ -158,7 +171,7 @@ TickmarkProperties AxisProperties::getBiggestTickmarkProperties()
//--------------------------------------------------------------------------
AxisProperties::AxisProperties( const uno::Reference< XAxis >& xAxisModel
- , const uno::Reference< data::XTextualDataSequence >& xAxisTextProvider )
+ , ExplicitCategoriesProvider* pExplicitCategoriesProvider )
: m_xAxisModel(xAxisModel)
, m_nDimensionIndex(0)
, m_bIsMainAxis(true)
@@ -173,7 +186,6 @@ AxisProperties::AxisProperties( const uno::Reference< XAxis >& xAxisModel
, m_bAxisBetweenCategories(false)
, m_fLabelDirectionSign(1.0)
, m_fInnerDirectionSign(1.0)
- , m_bLabelsOutside(true)
, m_aLabelAlignment(LABEL_ALIGN_RIGHT_TOP)
, m_bDisplayLabels( true )
, m_nNumberFormatKey(0)
@@ -183,8 +195,9 @@ AxisProperties::AxisProperties( const uno::Reference< XAxis >& xAxisModel
, m_aLineProperties()
//for category axes
, m_nAxisType(AxisType::REALNUMBER)
- , m_xAxisTextProvider(xAxisTextProvider)
- , m_bTickmarksAtIndicatedValue(false)
+ , m_bComplexCategories(false)
+ , m_pExplicitCategoriesProvider(pExplicitCategoriesProvider)
+ , m_xAxisTextProvider(0)
{
}
@@ -203,7 +216,6 @@ AxisProperties::AxisProperties( const AxisProperties& rAxisProperties )
, m_bAxisBetweenCategories( rAxisProperties.m_bAxisBetweenCategories )
, m_fLabelDirectionSign( rAxisProperties.m_fLabelDirectionSign )
, m_fInnerDirectionSign( rAxisProperties.m_fInnerDirectionSign )
- , m_bLabelsOutside( rAxisProperties.m_bLabelsOutside )
, m_aLabelAlignment( rAxisProperties.m_aLabelAlignment )
, m_bDisplayLabels( rAxisProperties.m_bDisplayLabels )
, m_nNumberFormatKey( rAxisProperties.m_nNumberFormatKey )
@@ -213,8 +225,9 @@ AxisProperties::AxisProperties( const AxisProperties& rAxisProperties )
, m_aLineProperties( rAxisProperties.m_aLineProperties )
//for category axes
, m_nAxisType( rAxisProperties.m_nAxisType )
+ , m_bComplexCategories( rAxisProperties.m_bComplexCategories )
+ , m_pExplicitCategoriesProvider( rAxisProperties.m_pExplicitCategoriesProvider )
, m_xAxisTextProvider( rAxisProperties.m_xAxisTextProvider )
- , m_bTickmarksAtIndicatedValue( rAxisProperties.m_bTickmarksAtIndicatedValue )
{
if( rAxisProperties.m_pfMainLinePositionAtOtherAxis )
m_pfMainLinePositionAtOtherAxis = new double(*rAxisProperties.m_pfMainLinePositionAtOtherAxis);
@@ -378,8 +391,8 @@ void AxisProperties::init( bool bCartesian )
//-----------------------------------------------------------------------------
AxisLabelProperties::AxisLabelProperties()
- : m_aFontReferenceSize( 8000, 7000 )
- , m_aMaximumSpaceForLabels( 0 , 0, 8000, 7000 )
+ : m_aFontReferenceSize( ChartModelHelper::getDefaultPageSize() )
+ , m_aMaximumSpaceForLabels( 0 , 0, m_aFontReferenceSize.Width, m_aFontReferenceSize.Height )
, nNumberFormatKey(0)
, eStaggering( SIDE_BY_SIDE )
, bLineBreakAllowed( false )
diff --git a/chart2/source/view/axes/VAxisProperties.hxx b/chart2/source/view/axes/VAxisProperties.hxx
index 8a83fb6bcf7c..5b6bfe98f777 100644
--- a/chart2/source/view/axes/VAxisProperties.hxx
+++ b/chart2/source/view/axes/VAxisProperties.hxx
@@ -30,6 +30,7 @@
#include "TickmarkProperties.hxx"
#include "PlottingPositionHelper.hxx"
#include "LabelAlignment.hxx"
+#include "ExplicitCategoriesProvider.hxx"
#include <com/sun/star/chart/ChartAxisLabelPosition.hpp>
#include <com/sun/star/chart/ChartAxisMarkPosition.hpp>
@@ -84,7 +85,7 @@ struct AxisLabelProperties
double fRotationAngleDegree;
sal_Int32 nRhythm; //show only each nth label with n==nRhythm
- bool bRhythmIsFix; //states wether the given rythm is fix or may be changed
+ bool bRhythmIsFix; //states wether the given rhythm is fix or may be changed
//methods:
void init( const ::com::sun::star::uno::Reference<
@@ -116,7 +117,6 @@ struct AxisProperties
double m_fLabelDirectionSign;
//this direction is used to indicate in which direction inner tickmarks are to be drawn
double m_fInnerDirectionSign;
- bool m_bLabelsOutside;
LabelAlignment m_aLabelAlignment;
sal_Bool m_bDisplayLabels;
@@ -133,19 +133,18 @@ struct AxisProperties
VLineProperties m_aLineProperties;
//for category axes ->
- sal_Int32 m_nAxisType;//REALNUMBER, CATEGORY etc. type ::com::sun::star::chart2::AxisType
+ sal_Int32 m_nAxisType;//REALNUMBER, CATEGORY etc. type ::com::sun::star::chart2::AxisType
+ bool m_bComplexCategories;
+ ExplicitCategoriesProvider* m_pExplicitCategoriesProvider;/*no ownership here*/
::com::sun::star::uno::Reference<
::com::sun::star::chart2::data::XTextualDataSequence >
m_xAxisTextProvider; //for categries or series names
- //position of main tickmarks in respect to the indicated value: at value or between neighboured indicated values
- bool m_bTickmarksAtIndicatedValue;
//<- category axes
//methods:
AxisProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxisModel
- , const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XTextualDataSequence >& xAxisTextProvider );
+ , ExplicitCategoriesProvider* pExplicitCategoriesProvider );
AxisProperties( const AxisProperties& rAxisProperties );
virtual ~AxisProperties();
virtual void init(bool bCartesian=false);//init from model data (m_xAxisModel)
@@ -153,6 +152,7 @@ struct AxisProperties
void initAxisPositioning( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xAxisProp );
static TickmarkProperties getBiggestTickmarkProperties();
+ TickmarkProperties makeTickmarkPropertiesForComplexCategories( sal_Int32 nTickLength, sal_Int32 nTickStartDistanceToAxis, sal_Int32 nTextLevel ) const;
private:
AxisProperties();
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx
index e06360b2b1b7..caadaa554091 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -118,19 +118,19 @@ Reference< drawing::XShape > createSingleLabel(
bool lcl_doesShapeOverlapWithTickmark( const Reference< drawing::XShape >& xShape
, double fRotationAngleDegree
, const basegfx::B2DVector& rTickScreenPosition
- , TickmarkHelper_2D* pTickmarkHelper )
+ , bool bIsHorizontalAxis, bool bIsVerticalAxis )
{
if(!xShape.is())
return false;
::basegfx::B2IRectangle aShapeRect = BaseGFXHelper::makeRectangle(xShape->getPosition(),ShapeFactory::getSizeAfterRotation( xShape, fRotationAngleDegree ));
- if( pTickmarkHelper->isVerticalAxis() )
+ if( bIsVerticalAxis )
{
return ( (rTickScreenPosition.getY() >= aShapeRect.getMinY())
&& (rTickScreenPosition.getY() <= aShapeRect.getMaxY()) );
}
- if( pTickmarkHelper->isHorizontalAxis() )
+ if( bIsHorizontalAxis )
{
return ( (rTickScreenPosition.getX() >= aShapeRect.getMinX())
&& (rTickScreenPosition.getX() <= aShapeRect.getMaxX()) );
@@ -154,7 +154,7 @@ bool doesOverlap( const Reference< drawing::XShape >& xShape1
return aRect1.overlaps(aRect2);
}
-void removeShapesAtWrongRythm( TickIter& rIter
+void removeShapesAtWrongRhythm( TickIter& rIter
, sal_Int32 nCorrectRhythm
, sal_Int32 nMaxTickToCheck
, const Reference< drawing::XShapes >& xTarget )
@@ -164,7 +164,7 @@ void removeShapesAtWrongRythm( TickIter& rIter
; pTickInfo && nTick <= nMaxTickToCheck
; pTickInfo = rIter.nextInfo(), nTick++ )
{
- //remove labels which does not fit into the rythm
+ //remove labels which does not fit into the rhythm
if( nTick%nCorrectRhythm != 0)
{
if(pTickInfo->xTextShape.is())
@@ -176,7 +176,7 @@ void removeShapesAtWrongRythm( TickIter& rIter
}
}
-class LabelIterator : private TickIter
+class EquidistantLabelIterator : public EquidistantTickIter
{
//this Iterator iterates over existing text labels
@@ -190,7 +190,7 @@ class LabelIterator : private TickIter
//we iterate through all labels
public:
- LabelIterator( ::std::vector< ::std::vector< TickInfo > >& rTickInfos
+ EquidistantLabelIterator( ::std::vector< ::std::vector< TickInfo > >& rTickInfos
, const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement
, const AxisLabelStaggering eAxisLabelStaggering
, bool bInnerLine
@@ -200,29 +200,29 @@ public:
virtual TickInfo* nextInfo();
private: //methods
- LabelIterator();
+ EquidistantLabelIterator();
private: //member
const AxisLabelStaggering m_eAxisLabelStaggering;
bool m_bInnerLine;
};
-LabelIterator::LabelIterator( ::std::vector< ::std::vector< TickInfo > >& rTickInfos
+EquidistantLabelIterator::EquidistantLabelIterator( ::std::vector< ::std::vector< TickInfo > >& rTickInfos
, const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement
, const AxisLabelStaggering eAxisLabelStaggering
, bool bInnerLine
, sal_Int32 nMinDepth, sal_Int32 nMaxDepth )
- : TickIter( rTickInfos, rIncrement, nMinDepth, nMaxDepth )
+ : EquidistantTickIter( rTickInfos, rIncrement, nMinDepth, nMaxDepth )
, m_eAxisLabelStaggering(eAxisLabelStaggering)
, m_bInnerLine(bInnerLine)
{
}
-TickInfo* LabelIterator::firstInfo()
+TickInfo* EquidistantLabelIterator::firstInfo()
{
- TickInfo* pTickInfo = TickIter::firstInfo();
+ TickInfo* pTickInfo = EquidistantTickIter::firstInfo();
while( pTickInfo && !pTickInfo->xTextShape.is() )
- pTickInfo = TickIter::nextInfo();
+ pTickInfo = EquidistantTickIter::nextInfo();
if(!pTickInfo)
return NULL;
if( (STAGGER_EVEN==m_eAxisLabelStaggering && m_bInnerLine)
@@ -232,7 +232,7 @@ TickInfo* LabelIterator::firstInfo()
{
//skip first label
do
- pTickInfo = TickIter::nextInfo();
+ pTickInfo = EquidistantTickIter::nextInfo();
while( pTickInfo && !pTickInfo->xTextShape.is() );
}
if(!pTickInfo)
@@ -240,12 +240,12 @@ TickInfo* LabelIterator::firstInfo()
return pTickInfo;
}
-TickInfo* LabelIterator::nextInfo()
+TickInfo* EquidistantLabelIterator::nextInfo()
{
TickInfo* pTickInfo = NULL;
//get next label
do
- pTickInfo = TickIter::nextInfo();
+ pTickInfo = EquidistantTickIter::nextInfo();
while( pTickInfo && !pTickInfo->xTextShape.is() );
if( STAGGER_EVEN==m_eAxisLabelStaggering
@@ -253,16 +253,16 @@ TickInfo* LabelIterator::nextInfo()
{
//skip one label
do
- pTickInfo = TickIter::nextInfo();
+ pTickInfo = EquidistantTickIter::nextInfo();
while( pTickInfo && !pTickInfo->xTextShape.is() );
}
return pTickInfo;
}
-B2DVector lcl_getStaggerDistance( LabelIterator& rIter, const B2DVector& rDistanceTickToText )
+B2DVector lcl_getLabelsDistance( TickIter& rIter, const B2DVector& rDistanceTickToText )
{
- //calculates the height or width of the first line of labels
- //thus the second line of labels needs to be shifted for that distance
+ //calculates the height or width of a line of labels
+ //thus a following line of labels can be shifted for that distance
B2DVector aRet(0,0);
@@ -280,13 +280,14 @@ B2DVector lcl_getStaggerDistance( LabelIterator& rIter, const B2DVector& rDistan
; pTickInfo = rIter.nextInfo() )
{
xShape2DText = pTickInfo->xTextShape;
- DBG_ASSERT(xShape2DText.is(),"LabelIterator does not work correctly");
-
- awt::Size aSize = xShape2DText->getSize();
- if(fabs(aStaggerDirection.getX())>fabs(aStaggerDirection.getY()))
- nDistance = ::std::max(nDistance,aSize.Width);
- else
- nDistance = ::std::max(nDistance,aSize.Height);
+ if( xShape2DText.is() )
+ {
+ awt::Size aSize = xShape2DText->getSize();
+ if(fabs(aStaggerDirection.getX())>fabs(aStaggerDirection.getY()))
+ nDistance = ::std::max(nDistance,aSize.Width);
+ else
+ nDistance = ::std::max(nDistance,aSize.Height);
+ }
}
aRet = aStaggerDirection*nDistance;
@@ -298,7 +299,7 @@ B2DVector lcl_getStaggerDistance( LabelIterator& rIter, const B2DVector& rDistan
return aRet;
}
-void lcl_correctPositionForStaggering( LabelIterator& rIter, const B2DVector& rStaggerDistance )
+void lcl_shiftLables( TickIter& rIter, const B2DVector& rStaggerDistance )
{
if(rStaggerDistance.getLength()==0.0)
return;
@@ -308,23 +309,24 @@ void lcl_correctPositionForStaggering( LabelIterator& rIter, const B2DVector& rS
; pTickInfo = rIter.nextInfo() )
{
xShape2DText = pTickInfo->xTextShape;
- DBG_ASSERT(xShape2DText.is(),"LabelIterator does not work correctly");
-
- awt::Point aPos = xShape2DText->getPosition();
- aPos.X += static_cast<sal_Int32>(rStaggerDistance.getX());
- aPos.Y += static_cast<sal_Int32>(rStaggerDistance.getY());
- xShape2DText->setPosition( aPos );
+ if( xShape2DText.is() )
+ {
+ awt::Point aPos = xShape2DText->getPosition();
+ aPos.X += static_cast<sal_Int32>(rStaggerDistance.getX());
+ aPos.Y += static_cast<sal_Int32>(rStaggerDistance.getY());
+ xShape2DText->setPosition( aPos );
+ }
}
}
-class MaxLabelTickIter : public TickIter
+class MaxLabelEquidistantTickIter : public EquidistantTickIter
{
//iterate over first two and last two labels and the longest label
public:
- MaxLabelTickIter( ::std::vector< ::std::vector< TickInfo > >& rTickInfos
+ MaxLabelEquidistantTickIter( ::std::vector< ::std::vector< TickInfo > >& rTickInfos
, const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement
, sal_Int32 nLongestLabelIndex );
- virtual ~MaxLabelTickIter();
+ virtual ~MaxLabelEquidistantTickIter();
virtual TickInfo* nextInfo();
@@ -332,10 +334,10 @@ private:
sal_Int32 m_nLongestLabelIndex;
};
-MaxLabelTickIter::MaxLabelTickIter( ::std::vector< ::std::vector< TickInfo > >& rTickInfos
+MaxLabelEquidistantTickIter::MaxLabelEquidistantTickIter( ::std::vector< ::std::vector< TickInfo > >& rTickInfos
, const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement
, sal_Int32 nLongestLabelIndex )
- : TickIter( rTickInfos, rIncrement, 0//nMinDepth
+ : EquidistantTickIter( rTickInfos, rIncrement, 0//nMinDepth
, 0//nMaxDepth
)
, m_nLongestLabelIndex( nLongestLabelIndex )
@@ -353,11 +355,11 @@ MaxLabelTickIter::MaxLabelTickIter( ::std::vector< ::std::vector< TickInfo > >&
if( m_nLongestLabelIndex+1==nMaxIndex )
m_nLongestLabelIndex = 0;
}
-MaxLabelTickIter::~MaxLabelTickIter()
+MaxLabelEquidistantTickIter::~MaxLabelEquidistantTickIter()
{
}
-TickInfo* MaxLabelTickIter::nextInfo()
+TickInfo* MaxLabelEquidistantTickIter::nextInfo()
{
sal_Int32 nCurrentPos = getCurrentIndex();
sal_Int32 nMaxIndex = getMaxIndex();
@@ -374,11 +376,11 @@ TickInfo* MaxLabelTickIter::nextInfo()
}
}
- return TickIter::nextInfo();
+ return EquidistantTickIter::nextInfo();
}
bool VCartesianAxis::isBreakOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties
- , TickmarkHelper_2D* pTickmarkHelper )
+ , bool bIsHorizontalAxis )
{
if( m_aTextLabels.getLength() > 100 )
return false;
@@ -392,13 +394,11 @@ bool VCartesianAxis::isBreakOfLabelsAllowed( const AxisLabelProperties& rAxisLab
if( !::rtl::math::approxEqual( rAxisLabelProperties.fRotationAngleDegree, 0.0 ) )
return false;
//break only for horizontal axis
- if( pTickmarkHelper )
- return pTickmarkHelper->isHorizontalAxis();
- return false;
+ return bIsHorizontalAxis;
}
bool VCartesianAxis::isAutoStaggeringOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties
- , TickmarkHelper_2D* pTickmarkHelper )
+ , bool bIsHorizontalAxis, bool bIsVerticalAxis )
{
if( rAxisLabelProperties.eStaggering != STAGGER_AUTO )
return false;
@@ -410,28 +410,163 @@ bool VCartesianAxis::isAutoStaggeringOfLabelsAllowed( const AxisLabelProperties&
return false;
//automatic staggering only for horizontal axis with horizontal text
//or vertical axis with vertical text
- if( pTickmarkHelper )
+ if( bIsHorizontalAxis )
+ return !rAxisLabelProperties.bStackCharacters;
+ if( bIsVerticalAxis )
+ return rAxisLabelProperties.bStackCharacters;
+ return false;
+}
+
+struct ComplexCategoryPlacement
+{
+ rtl::OUString Text;
+ sal_Int32 Count;
+ double TickValue;
+
+ ComplexCategoryPlacement( const rtl::OUString& rText, sal_Int32 nCount, double fTickValue )
+ : Text(rText), Count(nCount), TickValue(fTickValue)
+ {}
+};
+
+void VCartesianAxis::createAllTickInfosFromComplexCategories( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos, bool bShiftedPosition )
+{
+ //no minor tickmarks will be generated!
+ //order is: inner labels first , outer labels last (that is different to all other TickIter cases)
+ if(!bShiftedPosition)
{
- if( pTickmarkHelper->isHorizontalAxis() )
- return !rAxisLabelProperties.bStackCharacters;
- if( pTickmarkHelper->isVerticalAxis() )
- return rAxisLabelProperties.bStackCharacters;
+ rAllTickInfos.clear();
+ sal_Int32 nLevel=0;
+ sal_Int32 nLevelCount = m_aAxisProperties.m_pExplicitCategoriesProvider->getCategoryLevelCount();
+ for( ; nLevel<nLevelCount; nLevel++ )
+ {
+ ::std::vector< TickInfo > aTickInfoVector;
+ std::vector< ComplexCategory > aComplexCategories( m_aAxisProperties.m_pExplicitCategoriesProvider->getCategoriesByLevel( nLevel ) );
+ sal_Int32 nCatIndex = 0;
+ std::vector< ComplexCategory >::const_iterator aIt(aComplexCategories.begin());
+ std::vector< ComplexCategory >::const_iterator aEnd(aComplexCategories.end());
+ for(;aIt!=aEnd;++aIt)
+ {
+ TickInfo aTickInfo;
+ ComplexCategory aCat(*aIt);
+ sal_Int32 nCount = aCat.Count;
+ if( nCatIndex + 0.5 + nCount >= m_aScale.Maximum )
+ {
+ nCount = m_aScale.Maximum - 0.5 - nCatIndex;
+ if( nCount <= 0 )
+ nCount = 1;
+ }
+ aTickInfo.fScaledTickValue = nCatIndex + 0.5 + nCount/2.0;
+ aTickInfo.nFactorForLimitedTextWidth = nCount;
+ aTickInfo.aText = aCat.Text;
+ aTickInfoVector.push_back(aTickInfo);
+ nCatIndex += nCount;
+ if( nCatIndex + 0.5 >= m_aScale.Maximum )
+ break;
+ }
+ rAllTickInfos.push_back(aTickInfoVector);
+ }
}
- return false;
+ else //bShiftedPosition==true
+ {
+ rAllTickInfos.clear();
+ sal_Int32 nLevel=0;
+ sal_Int32 nLevelCount = m_aAxisProperties.m_pExplicitCategoriesProvider->getCategoryLevelCount();
+ for( ; nLevel<nLevelCount; nLevel++ )
+ {
+ ::std::vector< TickInfo > aTickInfoVector;
+ std::vector< ComplexCategory > aComplexCategories( m_aAxisProperties.m_pExplicitCategoriesProvider->getCategoriesByLevel( nLevel ) );
+ sal_Int32 nCatIndex = 0;
+ std::vector< ComplexCategory >::const_iterator aIt(aComplexCategories.begin());
+ std::vector< ComplexCategory >::const_iterator aEnd(aComplexCategories.end());
+ for(;aIt!=aEnd;++aIt)
+ {
+ TickInfo aTickInfo;
+ ComplexCategory aCat(*aIt);
+ aTickInfo.fScaledTickValue = nCatIndex + 0.5;
+ aTickInfoVector.push_back(aTickInfo);
+ nCatIndex += aCat.Count;
+ if( nCatIndex + 0.5 > m_aScale.Maximum )
+ break;
+ }
+ //fill up with single ticks until maximum scale
+ while( nCatIndex + 0.5 < m_aScale.Maximum )
+ {
+ TickInfo aTickInfo;
+ aTickInfo.fScaledTickValue = nCatIndex + 0.5;
+ aTickInfoVector.push_back(aTickInfo);
+ nCatIndex ++;
+ if( nLevel>0 )
+ break;
+ }
+ //add an additional tick at the end
+ {
+ TickInfo aTickInfo;
+ aTickInfo.fScaledTickValue = m_aScale.Maximum;
+ aTickInfoVector.push_back(aTickInfo);
+ }
+ rAllTickInfos.push_back(aTickInfoVector);
+ }
+ }
+}
+
+void VCartesianAxis::createAllTickInfos( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos )
+{
+ if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels )
+ createAllTickInfosFromComplexCategories( rAllTickInfos, false );
+ else
+ VAxisBase::createAllTickInfos(rAllTickInfos);
+}
+
+::std::auto_ptr< TickIter > VCartesianAxis::createLabelTickIterator( sal_Int32 nTextLevel )
+{
+ if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels )
+ {
+ if( nTextLevel>=0 && nTextLevel < static_cast< sal_Int32 >(m_aAllTickInfos.size()) )
+ return ::std::auto_ptr< TickIter >( new PureTickIter( m_aAllTickInfos[nTextLevel] ) );
+ }
+ else
+ {
+ if(nTextLevel==0)
+ return ::std::auto_ptr< TickIter >( new EquidistantTickIter( m_aAllTickInfos, m_aIncrement, 0, 0 ) );
+ }
+ return ::std::auto_ptr< TickIter >();
+}
+::std::auto_ptr< TickIter > VCartesianAxis::createMaximumLabelTickIterator( sal_Int32 nTextLevel )
+{
+ if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels )
+ {
+ return createLabelTickIterator( nTextLevel ); //mmmm maybe todo: create less than all texts here
+ }
+ else
+ {
+ if(nTextLevel==0)
+ {
+ sal_Int32 nLongestLabelIndex = m_bUseTextLabels ? this->getIndexOfLongestLabel( m_aTextLabels ) : 0;
+ return ::std::auto_ptr< TickIter >( new MaxLabelEquidistantTickIter( m_aAllTickInfos, m_aIncrement, nLongestLabelIndex ) );
+ }
+ }
+ return ::std::auto_ptr< TickIter >();
+}
+
+sal_Int32 VCartesianAxis::getTextLevelCount() const
+{
+ sal_Int32 nTextLevelCount = 1;
+ if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels )
+ nTextLevelCount = m_aAxisProperties.m_pExplicitCategoriesProvider->getCategoryLevelCount();
+ return nTextLevelCount;
}
bool VCartesianAxis::createTextShapes(
const Reference< drawing::XShapes >& xTarget
, TickIter& rTickIter
, AxisLabelProperties& rAxisLabelProperties
- , TickmarkHelper_2D* pTickmarkHelper )
+ , TickmarkHelper_2D* pTickmarkHelper
+ , sal_Int32 nScreenDistanceBetweenTicks )
{
//returns true if the text shapes have been created succesfully
//otherwise false - in this case the AxisLabelProperties have changed
//and contain new instructions for the next try for text shape creation
- uno::Sequence< rtl::OUString >* pCategories = m_bUseTextLabels? &m_aTextLabels : 0;
-
Reference< XScaling > xInverseScaling( NULL );
if( m_aScale.Scaling.is() )
xInverseScaling = m_aScale.Scaling->getInverseScaling();
@@ -439,40 +574,44 @@ bool VCartesianAxis::createTextShapes(
FixedNumberFormatter aFixedNumberFormatter(
m_xNumberFormatsSupplier, rAxisLabelProperties.nNumberFormatKey );
- B2DVector aTextToTickDistance( pTickmarkHelper->getDistanceAxisTickToText( m_aAxisProperties ) );
-
- TickInfo* pPreviousVisibleTickInfo = NULL;
- TickInfo* pPREPreviousVisibleTickInfo = NULL;
- TickInfo* pLastVisibleNeighbourTickInfo = NULL;
+ const bool bIsHorizontalAxis = pTickmarkHelper->isHorizontalAxis();
+ const bool bIsVerticalAxis = pTickmarkHelper->isVerticalAxis();
bool bIsStaggered = rAxisLabelProperties.getIsStaggered();
- sal_Int32 nLimitedSpace = -1;
- if( isBreakOfLabelsAllowed( rAxisLabelProperties, pTickmarkHelper ) )
+ B2DVector aTextToTickDistance( pTickmarkHelper->getDistanceAxisTickToText( m_aAxisProperties, true ) );
+ sal_Int32 nLimitedSpaceForText = -1;
+ if( isBreakOfLabelsAllowed( rAxisLabelProperties, bIsHorizontalAxis ) )
{
- nLimitedSpace = TickmarkHelper_2D::getTickScreenDistance( rTickIter );
+ nLimitedSpaceForText = nScreenDistanceBetweenTicks;
if( bIsStaggered )
- nLimitedSpace *= 2;
+ nLimitedSpaceForText *= 2;
- if( nLimitedSpace > 0 )
+ if( nLimitedSpaceForText > 0 )
{ //reduce space for a small amount to have a visible distance between the labels:
- sal_Int32 nReduce = (nLimitedSpace*5)/100;
+ sal_Int32 nReduce = (nLimitedSpaceForText*5)/100;
if(!nReduce)
nReduce = 1;
- nLimitedSpace -= nReduce;
+ nLimitedSpaceForText -= nReduce;
}
- //maybe @todo in future:
- //if the labeled tickmarks are not equidistant [this is not considered to be a relevant case so far]
- //the limited space maybe needs to be calculated for each tickmark seperatly
- //or the staggering could be ignored in that case
}
+ std::vector< ComplexCategoryPlacement > aComplexCategoryPlacements;
+ uno::Sequence< rtl::OUString >* pCategories = 0;
+ if( m_bUseTextLabels && !m_aAxisProperties.m_bComplexCategories )
+ pCategories = &m_aTextLabels;
+
+ TickInfo* pPreviousVisibleTickInfo = NULL;
+ TickInfo* pPREPreviousVisibleTickInfo = NULL;
+ TickInfo* pLastVisibleNeighbourTickInfo = NULL;
+
//------------------------------------------------
//prepare properties for multipropertyset-interface of shape
tNameSequence aPropNames;
tAnySequence aPropValues;
+ bool bLimitedHeight = fabs(aTextToTickDistance.getX()) > fabs(aTextToTickDistance.getY());
Reference< beans::XPropertySet > xProps( m_aAxisProperties.m_xAxisModel, uno::UNO_QUERY );
PropertyMapper::getTextLabelMultiPropertyLists( xProps, aPropNames, aPropValues, false
- , nLimitedSpace, fabs(aTextToTickDistance.getX()) > fabs(aTextToTickDistance.getY()) );
+ , nLimitedSpaceForText, bLimitedHeight );
LabelPositionHelper::doDynamicFontResize( aPropValues, aPropNames, xProps
, m_aAxisLabelProperties.m_aFontReferenceSize );
LabelPositionHelper::changeTextAdjustment( aPropValues, aPropNames, m_aAxisProperties.m_aLabelAlignment );
@@ -481,6 +620,8 @@ bool VCartesianAxis::createTextShapes(
sal_Int32 nColor = Color( COL_AUTO ).GetColor();
if(pColorAny)
*pColorAny >>= nColor;
+
+ uno::Any* pLimitedSpaceAny = PropertyMapper::getValuePointerForLimitedSpace(aPropValues,aPropNames,bLimitedHeight);
//------------------------------------------------
sal_Int32 nTick = 0;
@@ -491,7 +632,7 @@ bool VCartesianAxis::createTextShapes(
pLastVisibleNeighbourTickInfo = bIsStaggered ?
pPREPreviousVisibleTickInfo : pPreviousVisibleTickInfo;
- //don't create labels which does not fit into the rythm
+ //don't create labels which does not fit into the rhythm
if( nTick%rAxisLabelProperties.nRhythm != 0)
continue;
@@ -505,10 +646,11 @@ bool VCartesianAxis::createTextShapes(
{
if( lcl_doesShapeOverlapWithTickmark( pLastVisibleNeighbourTickInfo->xTextShape
, rAxisLabelProperties.fRotationAngleDegree
- , pTickInfo->aTickScreenPosition, pTickmarkHelper ) )
+ , pTickInfo->aTickScreenPosition
+ , bIsHorizontalAxis, bIsVerticalAxis ) )
{
bool bOverlapAlsoAfterSwitchingOnAutoStaggering = true;
- if( !bIsStaggered && isAutoStaggeringOfLabelsAllowed( rAxisLabelProperties, pTickmarkHelper ) )
+ if( !bIsStaggered && isAutoStaggeringOfLabelsAllowed( rAxisLabelProperties, bIsHorizontalAxis, bIsVerticalAxis ) )
{
bIsStaggered = true;
rAxisLabelProperties.eStaggering = STAGGER_EVEN;
@@ -516,7 +658,8 @@ bool VCartesianAxis::createTextShapes(
if( !pLastVisibleNeighbourTickInfo ||
!lcl_doesShapeOverlapWithTickmark( pLastVisibleNeighbourTickInfo->xTextShape
, rAxisLabelProperties.fRotationAngleDegree
- , pTickInfo->aTickScreenPosition, pTickmarkHelper ) )
+ , pTickInfo->aTickScreenPosition
+ , bIsHorizontalAxis, bIsVerticalAxis ) )
bOverlapAlsoAfterSwitchingOnAutoStaggering = false;
}
if( bOverlapAlsoAfterSwitchingOnAutoStaggering )
@@ -524,8 +667,7 @@ bool VCartesianAxis::createTextShapes(
if( rAxisLabelProperties.bRhythmIsFix )
continue;
rAxisLabelProperties.nRhythm++;
- TickIter aRemoveIter( m_aAllTickInfos, m_aIncrement, 0, 0 );
- removeShapesAtWrongRythm( aRemoveIter, rAxisLabelProperties.nRhythm, nTick, xTarget );
+ removeShapesAtWrongRhythm( rTickIter, rAxisLabelProperties.nRhythm, nTick, xTarget );
return false;
}
}
@@ -543,11 +685,17 @@ bool VCartesianAxis::createTextShapes(
if( nIndex>=0 && nIndex<pCategories->getLength() )
aLabel = (*pCategories)[nIndex];
}
+ else if( m_aAxisProperties.m_bComplexCategories )
+ {
+ aLabel = pTickInfo->aText;
+ }
else
aLabel = aFixedNumberFormatter.getFormattedString( pTickInfo->fUnscaledTickValue, nExtraColor, bHasExtraColor );
if(pColorAny)
*pColorAny = uno::makeAny(bHasExtraColor?nExtraColor:nColor);
+ if(pLimitedSpaceAny)
+ *pLimitedSpaceAny = uno::makeAny(sal_Int32(nLimitedSpaceForText*pTickInfo->nFactorForLimitedTextWidth));
B2DVector aTickScreenPos2D( pTickInfo->aTickScreenPosition );
aTickScreenPos2D += aTextToTickDistance;
@@ -572,7 +720,7 @@ bool VCartesianAxis::createTextShapes(
if( doesOverlap( pLastVisibleNeighbourTickInfo->xTextShape, pTickInfo->xTextShape, m_aAxisLabelProperties.fRotationAngleDegree ) )
{
bool bOverlapAlsoAfterSwitchingOnAutoStaggering = true;
- if( !bIsStaggered && isAutoStaggeringOfLabelsAllowed( rAxisLabelProperties, pTickmarkHelper ) )
+ if( !bIsStaggered && isAutoStaggeringOfLabelsAllowed( rAxisLabelProperties, bIsHorizontalAxis, bIsVerticalAxis ) )
{
bIsStaggered = true;
rAxisLabelProperties.eStaggering = STAGGER_EVEN;
@@ -580,7 +728,8 @@ bool VCartesianAxis::createTextShapes(
if( !pLastVisibleNeighbourTickInfo ||
!lcl_doesShapeOverlapWithTickmark( pLastVisibleNeighbourTickInfo->xTextShape
, rAxisLabelProperties.fRotationAngleDegree
- , pTickInfo->aTickScreenPosition, pTickmarkHelper ) )
+ , pTickInfo->aTickScreenPosition
+ , bIsHorizontalAxis, bIsVerticalAxis ) )
bOverlapAlsoAfterSwitchingOnAutoStaggering = false;
}
if( bOverlapAlsoAfterSwitchingOnAutoStaggering )
@@ -592,8 +741,7 @@ bool VCartesianAxis::createTextShapes(
continue;
}
rAxisLabelProperties.nRhythm++;
- TickIter aRemoveIter( m_aAllTickInfos, m_aIncrement, 0, 0 );
- removeShapesAtWrongRythm( aRemoveIter, rAxisLabelProperties.nRhythm, nTick, xTarget );
+ removeShapesAtWrongRhythm( rTickIter, rAxisLabelProperties.nRhythm, nTick, xTarget );
return false;
}
}
@@ -1057,6 +1205,43 @@ TickmarkHelper_2D* VCartesianAxis::createTickmarkHelper2D()
return new TickmarkHelper_2D( m_aScale, m_aIncrement, aStart, aEnd, aLabelLineStart-aStart );
}
+void lcl_hideIdenticalScreenValues( TickIter& rTickIter )
+{
+ TickInfo* pPreviousTickInfo = rTickIter.firstInfo();
+ if(!pPreviousTickInfo)
+ return;
+ pPreviousTickInfo->bPaintIt = true;
+ for( TickInfo* pTickInfo = rTickIter.nextInfo(); pTickInfo; pTickInfo = rTickIter.nextInfo())
+ {
+ pTickInfo->bPaintIt =
+ ( static_cast<sal_Int32>(pTickInfo->aTickScreenPosition.getX())
+ != static_cast<sal_Int32>(pPreviousTickInfo->aTickScreenPosition.getX()) )
+ ||
+ ( static_cast<sal_Int32>(pTickInfo->aTickScreenPosition.getY())
+ != static_cast<sal_Int32>(pPreviousTickInfo->aTickScreenPosition.getY()) );
+ pPreviousTickInfo = pTickInfo;
+ }
+}
+
+//'hide' tickmarks with identical screen values in aAllTickInfos
+void VCartesianAxis::hideIdenticalScreenValues( ::std::vector< ::std::vector< TickInfo > >& rTickInfos ) const
+{
+ if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels )
+ {
+ sal_Int32 nCount = rTickInfos.size();
+ for( sal_Int32 nN=0; nN<nCount; nN++ )
+ {
+ PureTickIter aTickIter( rTickInfos[nN] );
+ lcl_hideIdenticalScreenValues( aTickIter );
+ }
+ }
+ else
+ {
+ EquidistantTickIter aTickIter( rTickInfos, m_aIncrement, 0, -1 );
+ lcl_hideIdenticalScreenValues( aTickIter );
+ }
+}
+
sal_Int32 VCartesianAxis::estimateMaximumAutoMainIncrementCount()
{
sal_Int32 nRet = 10;
@@ -1092,15 +1277,31 @@ void VCartesianAxis::doStaggeringOfLabels( const AxisLabelProperties& rAxisLabel
if( !pTickmarkHelper2D )
return;
- if( rAxisLabelProperties.getIsStaggered() )
+ if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels )
{
- LabelIterator aInnerIter( m_aAllTickInfos, m_aIncrement
+ sal_Int32 nTextLevelCount = getTextLevelCount();
+ B2DVector aCummulatedLabelsDistance(0,0);
+ for( sal_Int32 nTextLevel=0; nTextLevel<nTextLevelCount; nTextLevel++ )
+ {
+ ::std::auto_ptr< TickIter > apTickIter = createLabelTickIterator( nTextLevel );
+ if(apTickIter.get())
+ {
+ if( nTextLevel>0 )
+ lcl_shiftLables( *apTickIter.get(), aCummulatedLabelsDistance );
+ aCummulatedLabelsDistance += lcl_getLabelsDistance( *apTickIter.get()
+ , pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties ) );
+ }
+ }
+ }
+ else if( rAxisLabelProperties.getIsStaggered() )
+ {
+ EquidistantLabelIterator aInnerIter( m_aAllTickInfos, m_aIncrement
, rAxisLabelProperties.eStaggering, true, 0, 0 );
- LabelIterator aOuterIter( m_aAllTickInfos, m_aIncrement
+ EquidistantLabelIterator aOuterIter( m_aAllTickInfos, m_aIncrement
, rAxisLabelProperties.eStaggering, false, 0, 0 );
- lcl_correctPositionForStaggering( aOuterIter
- , lcl_getStaggerDistance( aInnerIter
+ lcl_shiftLables( aOuterIter
+ , lcl_getLabelsDistance( aInnerIter
, pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties ) ) );
}
}
@@ -1124,18 +1325,34 @@ void SAL_CALL VCartesianAxis::createLabels()
pTickmarkHelper2D->updateScreenValues( m_aAllTickInfos );
//-----------------------------------------
//'hide' tickmarks with identical screen values in aAllTickInfos
- pTickmarkHelper2D->hideIdenticalScreenValues( m_aAllTickInfos );
+ hideIdenticalScreenValues( m_aAllTickInfos );
- TickIter aRemoveIter( m_aAllTickInfos, m_aIncrement, 0, 0 );
- removeTextShapesFromTicks( aRemoveIter, m_xTextTarget );
+ removeTextShapesFromTicks();
//create tick mark text shapes
- TickIter aTickIter( m_aAllTickInfos, m_aIncrement, 0, 0 );
- while( !createTextShapes( m_xTextTarget, aTickIter
- , m_aAxisLabelProperties, pTickmarkHelper2D ) )
+ sal_Int32 nTextLevelCount = getTextLevelCount();
+ sal_Int32 nScreenDistanceBetweenTicks = -1;
+ for( sal_Int32 nTextLevel=0; nTextLevel<nTextLevelCount; nTextLevel++ )
{
- };
+ ::std::auto_ptr< TickIter > apTickIter = createLabelTickIterator( nTextLevel );
+ if(apTickIter.get())
+ {
+ if(nTextLevel==0)
+ {
+ nScreenDistanceBetweenTicks = TickmarkHelper_2D::getTickScreenDistance( *apTickIter.get() );
+ if( nTextLevelCount>1 )
+ nScreenDistanceBetweenTicks*=2; //the above used tick iter does contain also the sub ticks -> thus the given distance is only the half
+ }
+ AxisLabelProperties aCopy(m_aAxisLabelProperties);
+ aCopy.bRhythmIsFix = true;
+ aCopy.nRhythm = 1;
+ AxisLabelProperties& rAxisLabelProperties = nTextLevel==0 ? m_aAxisLabelProperties : aCopy;
+ while( !createTextShapes( m_xTextTarget, *apTickIter.get(), rAxisLabelProperties, pTickmarkHelper2D, nScreenDistanceBetweenTicks ) )
+ {
+ };
+ }
+ }
doStaggeringOfLabels( m_aAxisLabelProperties, pTickmarkHelper2D );
}
}
@@ -1163,19 +1380,22 @@ void SAL_CALL VCartesianAxis::createMaximumLabels()
//create tick mark text shapes
//@todo: iterate through all tick depth wich should be labeled
- sal_Int32 nLongestLabelIndex = m_bUseTextLabels
- ? this->getIndexOfLongestLabel( m_aTextLabels ) : 0;
- MaxLabelTickIter aTickIter( m_aAllTickInfos, m_aIncrement, nLongestLabelIndex );
AxisLabelProperties aAxisLabelProperties( m_aAxisLabelProperties );
- if( isAutoStaggeringOfLabelsAllowed( aAxisLabelProperties, pTickmarkHelper2D ) )
+ if( isAutoStaggeringOfLabelsAllowed( aAxisLabelProperties, pTickmarkHelper2D->isHorizontalAxis(), pTickmarkHelper2D->isVerticalAxis() ) )
aAxisLabelProperties.eStaggering = STAGGER_EVEN;
aAxisLabelProperties.bOverlapAllowed = true;
aAxisLabelProperties.bLineBreakAllowed = false;
- while( !createTextShapes( m_xTextTarget, aTickIter
- , aAxisLabelProperties, pTickmarkHelper2D ) )
+ sal_Int32 nTextLevelCount = getTextLevelCount();
+ for( sal_Int32 nTextLevel=0; nTextLevel<nTextLevelCount; nTextLevel++ )
{
- };
-
+ ::std::auto_ptr< TickIter > apTickIter = createMaximumLabelTickIterator( nTextLevel );
+ if(apTickIter.get())
+ {
+ while( !createTextShapes( m_xTextTarget, *apTickIter.get(), aAxisLabelProperties, pTickmarkHelper2D, -1 ) )
+ {
+ };
+ }
+ }
doStaggeringOfLabels( aAxisLabelProperties, pTickmarkHelper2D );
}
}
@@ -1195,46 +1415,47 @@ void SAL_CALL VCartesianAxis::updatePositions()
//update positions of all existing text shapes
pTickmarkHelper2D->updateScreenValues( m_aAllTickInfos );
- TickIter aTickIter( m_aAllTickInfos, m_aIncrement, 0, 0 );
-
- Reference< drawing::XShape > xShape2DText;
- for( TickInfo* pTickInfo = aTickIter.firstInfo()
- ; pTickInfo; pTickInfo = aTickIter.nextInfo() )
+ ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = m_aAllTickInfos.begin();
+ const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = m_aAllTickInfos.end();
+ for( ; aDepthIter != aDepthEnd; aDepthIter++ )
{
- if( !pTickInfo )
- continue;
-
- xShape2DText = pTickInfo->xTextShape;
- if( xShape2DText.is() )
+ ::std::vector< TickInfo >::iterator aTickIter = aDepthIter->begin();
+ const ::std::vector< TickInfo >::const_iterator aTickEnd = aDepthIter->end();
+ for( ; aTickIter != aTickEnd; aTickIter++ )
{
- B2DVector aTextToTickDistance( pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties ) );
- B2DVector aTickScreenPos2D( pTickInfo->aTickScreenPosition );
- aTickScreenPos2D += aTextToTickDistance;
- awt::Point aAnchorScreenPosition2D(
- static_cast<sal_Int32>(aTickScreenPos2D.getX())
- ,static_cast<sal_Int32>(aTickScreenPos2D.getY()));
-
- // #i78696# use mathematically correct rotation now
- const double fRotationAnglePi(m_aAxisLabelProperties.fRotationAngleDegree * (F_PI / -180.0));
- uno::Any aATransformation = ShapeFactory::makeTransformation(aAnchorScreenPosition2D, fRotationAnglePi);
-
- //set new position
- uno::Reference< beans::XPropertySet > xProp( xShape2DText, uno::UNO_QUERY );
- if( xProp.is() )
+ TickInfo& rTickInfo = (*aTickIter);
+ Reference< drawing::XShape > xShape2DText( rTickInfo.xTextShape );
+ if( xShape2DText.is() )
{
- try
+ B2DVector aTextToTickDistance( pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties, true ) );
+ B2DVector aTickScreenPos2D( rTickInfo.aTickScreenPosition );
+ aTickScreenPos2D += aTextToTickDistance;
+ awt::Point aAnchorScreenPosition2D(
+ static_cast<sal_Int32>(aTickScreenPos2D.getX())
+ ,static_cast<sal_Int32>(aTickScreenPos2D.getY()));
+
+ // #i78696# use mathematically correct rotation now
+ const double fRotationAnglePi(m_aAxisLabelProperties.fRotationAngleDegree * (F_PI / -180.0));
+ uno::Any aATransformation = ShapeFactory::makeTransformation(aAnchorScreenPosition2D, fRotationAnglePi);
+
+ //set new position
+ uno::Reference< beans::XPropertySet > xProp( xShape2DText, uno::UNO_QUERY );
+ if( xProp.is() )
{
- xProp->setPropertyValue( C2U( "Transformation" ), aATransformation );
+ try
+ {
+ xProp->setPropertyValue( C2U( "Transformation" ), aATransformation );
+ }
+ catch( uno::Exception& e )
+ {
+ ASSERT_EXCEPTION( e );
+ }
}
- catch( uno::Exception& e )
- {
- ASSERT_EXCEPTION( e );
- }
- }
- //correctPositionForRotation
- LabelPositionHelper::correctPositionForRotation( xShape2DText
- , m_aAxisProperties.m_aLabelAlignment, m_aAxisLabelProperties.fRotationAngleDegree, false );
+ //correctPositionForRotation
+ LabelPositionHelper::correctPositionForRotation( xShape2DText
+ , m_aAxisProperties.m_aLabelAlignment, m_aAxisLabelProperties.fRotationAngleDegree, false );
+ }
}
}
@@ -1242,6 +1463,37 @@ void SAL_CALL VCartesianAxis::updatePositions()
}
}
+void VCartesianAxis::createTickMarkLineShapes( ::std::vector< TickInfo >& rTickInfos, const TickmarkProperties& rTickmarkProperties, TickmarkHelper_2D& rTickmarkHelper2D, bool bOnlyAtLabels )
+{
+ sal_Int32 nPointCount = rTickInfos.size();
+ drawing::PointSequenceSequence aPoints(2*nPointCount);
+
+ ::std::vector< TickInfo >::const_iterator aTickIter = rTickInfos.begin();
+ const ::std::vector< TickInfo >::const_iterator aTickEnd = rTickInfos.end();
+ sal_Int32 nN = 0;
+ for( ; aTickIter != aTickEnd; aTickIter++ )
+ {
+ if( !(*aTickIter).bPaintIt )
+ continue;
+
+ bool bTicksAtLabels = ( m_aAxisProperties.m_eTickmarkPos != ::com::sun::star::chart::ChartAxisMarkPosition_AT_AXIS );
+ double fInnerDirectionSign = m_aAxisProperties.m_fInnerDirectionSign;
+ if( bTicksAtLabels && m_aAxisProperties.m_eLabelPos == ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END )
+ fInnerDirectionSign *= -1.0;
+ bTicksAtLabels = bTicksAtLabels || bOnlyAtLabels;
+ //add ticks at labels:
+ rTickmarkHelper2D.addPointSequenceForTickLine( aPoints, nN++, (*aTickIter).fScaledTickValue
+ , fInnerDirectionSign , rTickmarkProperties, bTicksAtLabels );
+ //add ticks at axis (without lables):
+ if( !bOnlyAtLabels && m_aAxisProperties.m_eTickmarkPos == ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS )
+ rTickmarkHelper2D.addPointSequenceForTickLine( aPoints, nN++, (*aTickIter).fScaledTickValue
+ , m_aAxisProperties.m_fInnerDirectionSign, rTickmarkProperties, !bTicksAtLabels );
+ }
+ aPoints.realloc(nN);
+ m_pShapeFactory->createLine2D( m_xGroupShape_Shapes, aPoints
+ , &rTickmarkProperties.aLineProperties );
+}
+
void SAL_CALL VCartesianAxis::createShapes()
{
if( !prepareShapeCreation() )
@@ -1253,55 +1505,64 @@ void SAL_CALL VCartesianAxis::createShapes()
return;
//-----------------------------------------
- //create tick mark line shapes
+ //create line shapes
if(2==m_nDimension)
{
- ::std::vector< ::std::vector< TickInfo > > aAllShiftedTickInfos;
- if( m_aIncrement.ShiftedPosition )
- {
- pTickmarkHelper2D->getAllTicksShifted( aAllShiftedTickInfos );
- pTickmarkHelper2D->updateScreenValues( aAllShiftedTickInfos );
- pTickmarkHelper2D->hideIdenticalScreenValues( aAllShiftedTickInfos );
- }
- ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos = m_aIncrement.ShiftedPosition ? aAllShiftedTickInfos : m_aAllTickInfos;
-
- ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = rAllTickInfos.begin();
- const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = rAllTickInfos.end();
-
- if(aDepthIter == aDepthEnd)//no tickmarks at all
- return;
-
- sal_Int32 nTickmarkPropertiesCount = m_aAxisProperties.m_aTickmarkPropertiesList.size();
- for( sal_Int32 nDepth=0
- ; aDepthIter != aDepthEnd && nDepth < nTickmarkPropertiesCount
- ; aDepthIter++, nDepth++ )
+ //-----------------------------------------
+ //create extra long ticks to separate complex categories (create them only there where the labels are)
+ if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels )
{
- const TickmarkProperties& rTickmarkProperties = m_aAxisProperties.m_aTickmarkPropertiesList[nDepth];
-
- sal_Int32 nPointCount = (*aDepthIter).size();
- drawing::PointSequenceSequence aPoints(2*nPointCount);
+ ::std::vector< ::std::vector< TickInfo > > aComplexTickInfos;
+ createAllTickInfosFromComplexCategories( aComplexTickInfos, true );
+ pTickmarkHelper2D->updateScreenValues( aComplexTickInfos );
+ hideIdenticalScreenValues( aComplexTickInfos );
+
+ ::std::vector<TickmarkProperties> aTickmarkPropertiesList;
+ static bool bIncludeSpaceBetweenTickAndText = false;
+ sal_Int32 nOffset = pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties, false, bIncludeSpaceBetweenTickAndText ).getLength();
+ sal_Int32 nTextLevelCount = getTextLevelCount();
+ for( sal_Int32 nTextLevel=0; nTextLevel<nTextLevelCount; nTextLevel++ )
+ {
+ ::std::auto_ptr< TickIter > apTickIter = createLabelTickIterator( nTextLevel );
+ if( apTickIter.get() )
+ {
+ B2DVector aLabelsDistance( lcl_getLabelsDistance( *apTickIter.get(), pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties, false ) ) );
+ sal_Int32 nCurrentLength = aLabelsDistance.getLength();
+ aTickmarkPropertiesList.push_back( m_aAxisProperties.makeTickmarkPropertiesForComplexCategories( nOffset + nCurrentLength, 0, nTextLevel ) );
+ nOffset += nCurrentLength;
+ }
+ }
- ::std::vector< TickInfo >::const_iterator aTickIter = (*aDepthIter).begin();
- const ::std::vector< TickInfo >::const_iterator aTickEnd = (*aDepthIter).end();
- sal_Int32 nN = 0;
- for( ; aTickIter != aTickEnd; aTickIter++ )
+ sal_Int32 nTickmarkPropertiesCount = aTickmarkPropertiesList.size();
+ ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = aComplexTickInfos.begin();
+ const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = aComplexTickInfos.end();
+ for( sal_Int32 nDepth=0; aDepthIter != aDepthEnd && nDepth < nTickmarkPropertiesCount; aDepthIter++, nDepth++ )
{
- if( !(*aTickIter).bPaintIt )
+ if(nDepth==0 && !m_aAxisProperties.m_nMajorTickmarks)
continue;
-
- bool bTicksAtLabels = ( m_aAxisProperties.m_eTickmarkPos != ::com::sun::star::chart::ChartAxisMarkPosition_AT_AXIS );
- double fInnerDirectionSign = m_aAxisProperties.m_fInnerDirectionSign;
- if( bTicksAtLabels && m_aAxisProperties.m_eLabelPos == ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END )
- fInnerDirectionSign *= -1.0;
- apTickmarkHelper2D->addPointSequenceForTickLine( aPoints, nN++, (*aTickIter).fScaledTickValue
- , fInnerDirectionSign , rTickmarkProperties, bTicksAtLabels );
- if( m_aAxisProperties.m_eTickmarkPos == ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS )
- apTickmarkHelper2D->addPointSequenceForTickLine( aPoints, nN++, (*aTickIter).fScaledTickValue
- , m_aAxisProperties.m_fInnerDirectionSign, rTickmarkProperties, !bTicksAtLabels );
+ createTickMarkLineShapes( *aDepthIter, aTickmarkPropertiesList[nDepth], *pTickmarkHelper2D, true /*bOnlyAtLabels*/ );
+ }
+ }
+ //-----------------------------------------
+ //create normal ticks for major and minor intervals
+ {
+ ::std::vector< ::std::vector< TickInfo > > aAllShiftedTickInfos;
+ if( m_aIncrement.ShiftedPosition || ( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels ) )
+ {
+ pTickmarkHelper2D->getAllTicksShifted( aAllShiftedTickInfos );
+ pTickmarkHelper2D->updateScreenValues( aAllShiftedTickInfos );
+ hideIdenticalScreenValues( aAllShiftedTickInfos );
}
- aPoints.realloc(nN);
- m_pShapeFactory->createLine2D( m_xGroupShape_Shapes, aPoints
- , &rTickmarkProperties.aLineProperties );
+ ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos = m_aIncrement.ShiftedPosition ? aAllShiftedTickInfos : m_aAllTickInfos;
+
+ ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = rAllTickInfos.begin();
+ const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = rAllTickInfos.end();
+ if(aDepthIter == aDepthEnd)//no tickmarks at all
+ return;
+
+ sal_Int32 nTickmarkPropertiesCount = m_aAxisProperties.m_aTickmarkPropertiesList.size();
+ for( sal_Int32 nDepth=0; aDepthIter != aDepthEnd && nDepth < nTickmarkPropertiesCount; aDepthIter++, nDepth++ )
+ createTickMarkLineShapes( *aDepthIter, m_aAxisProperties.m_aTickmarkPropertiesList[nDepth], *pTickmarkHelper2D, false /*bOnlyAtLabels*/ );
}
//-----------------------------------------
//create axis main lines
diff --git a/chart2/source/view/axes/VCartesianAxis.hxx b/chart2/source/view/axes/VCartesianAxis.hxx
index f23560eaad9c..4fbcd2409196 100644
--- a/chart2/source/view/axes/VCartesianAxis.hxx
+++ b/chart2/source/view/axes/VCartesianAxis.hxx
@@ -30,6 +30,8 @@
#include "VAxisBase.hxx"
#include <basegfx/vector/b2dvector.hxx>
+#include <memory>
+
//.............................................................................
namespace chart
{
@@ -69,6 +71,12 @@ public:
virtual void SAL_CALL createShapes();
virtual sal_Int32 estimateMaximumAutoMainIncrementCount();
+ virtual void createAllTickInfos( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos );
+ void createAllTickInfosFromComplexCategories( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos, bool bShiftedPosition );
+
+ ::std::auto_ptr< TickIter > createLabelTickIterator( sal_Int32 nTextLevel );
+ ::std::auto_ptr< TickIter > createMaximumLabelTickIterator( sal_Int32 nTextLevel );
+ sal_Int32 getTextLevelCount() const;
//-------------------------------------------------------------------------
virtual TickmarkHelper* createTickmarkHelper();
@@ -114,16 +122,19 @@ protected: //methods
::com::sun::star::drawing::XShapes >& xTarget
, TickIter& rTickIter
, AxisLabelProperties& rAxisLabelProperties
- , TickmarkHelper_2D* pTickmarkHelper );
+ , TickmarkHelper_2D* pTickmarkHelper
+ , sal_Int32 nScreenDistanceBetweenTicks );
+
+ void createTickMarkLineShapes( ::std::vector< TickInfo >& rTickInfos, const TickmarkProperties& rTickmarkProperties, TickmarkHelper_2D& rTickmarkHelper2D, bool bOnlyAtLabels );
TickmarkHelper_2D* createTickmarkHelper2D();
+ void hideIdenticalScreenValues( ::std::vector< ::std::vector< TickInfo > >& rTickInfos ) const;
void doStaggeringOfLabels( const AxisLabelProperties& rAxisLabelProperties
, TickmarkHelper_2D* pTickmarkHelper2D );
bool isAutoStaggeringOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties
- , TickmarkHelper_2D* pTickmarkHelper);
- bool isBreakOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties
- , TickmarkHelper_2D* pTickmarkHelper );
+ , bool bIsHorizontalAxis, bool bIsVerticalAxis );
+ bool isBreakOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties, bool bIsHorizontalAxis );
::basegfx::B2DVector getScreenPosition( double fLogicX, double fLogicY, double fLogicZ ) const;
ScreenPosAndLogicPos getScreenPosAndLogicPos( double fLogicX, double fLogicY, double fLogicZ ) const;
diff --git a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
index 01358b3a932f..a196397e0e9f 100644
--- a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
+++ b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
@@ -153,7 +153,8 @@ void VCartesianCoordinateSystem::createVAxisList(
if( aCrossingScale.AxisType == AxisType::CATEGORY )
{
aAxisProperties.m_bCrossingAxisIsCategoryAxes = true;
- aAxisProperties.m_bAxisBetweenCategories = ChartTypeHelper::shiftTicksAtXAxisPerDefault( AxisHelper::getChartTypeByIndex( m_xCooSysModel, 0 ) );
+ aAxisProperties.m_bAxisBetweenCategories = ChartTypeHelper::shiftTicksAtXAxisPerDefault( AxisHelper::getChartTypeByIndex( m_xCooSysModel, 0 ) )
+ || ( aAxisProperties.m_pExplicitCategoriesProvider && aAxisProperties.m_pExplicitCategoriesProvider->hasComplexCategories() );
}
}
@@ -168,6 +169,13 @@ void VCartesianCoordinateSystem::createVAxisList(
aAxisProperties.init(true);
if(aAxisProperties.m_bDisplayLabels)
aAxisProperties.m_nNumberFormatKey = this->getNumberFormatKeyForAxis( xAxis, xNumberFormatsSupplier );
+
+ if( nDimensionIndex == 0 && aAxisProperties.m_nAxisType == AxisType::CATEGORY
+ && aAxisProperties.m_pExplicitCategoriesProvider )
+ {
+ if( aAxisProperties.m_pExplicitCategoriesProvider->hasComplexCategories() )
+ aAxisProperties.m_bComplexCategories = true;
+ }
//-------------------
::boost::shared_ptr< VAxisBase > apVAxis( new VCartesianAxis(aAxisProperties,xNumberFormatsSupplier,nDimensionIndex,nDimensionCount) );
tFullAxisIndex aFullAxisIndex( nDimensionIndex, nAxisIndex );
diff --git a/chart2/source/view/axes/VCoordinateSystem.cxx b/chart2/source/view/axes/VCoordinateSystem.cxx
index 22ec914fa938..bc908acdf85a 100644
--- a/chart2/source/view/axes/VCoordinateSystem.cxx
+++ b/chart2/source/view/axes/VCoordinateSystem.cxx
@@ -94,7 +94,7 @@ VCoordinateSystem::VCoordinateSystem( const Reference< XCoordinateSystem >& xCoo
, m_aMergedMinimumAndMaximumSupplier()
, m_aExplicitScales(3)
, m_aExplicitIncrements(3)
- , m_aExplicitCategoriesProvider( new ExplicitCategoriesProvider( m_xCooSysModel ) )
+ , m_apExplicitCategoriesProvider(NULL)
{
if( !m_xCooSysModel.is() || m_xCooSysModel->getDimension()<3 )
{
@@ -261,10 +261,14 @@ void VCoordinateSystem::impl_adjustDimensionAndIndex( sal_Int32& rDimensionIndex
rAxisIndex = 0;
}
+void VCoordinateSystem::setExplicitCategoriesProvider( ExplicitCategoriesProvider* pExplicitCategoriesProvider /*takes ownership*/ )
+{
+ m_apExplicitCategoriesProvider = ::std::auto_ptr< ExplicitCategoriesProvider >(pExplicitCategoriesProvider);
+}
-Reference< data::XTextualDataSequence > VCoordinateSystem::getExplicitCategoriesProvider()
+ExplicitCategoriesProvider* VCoordinateSystem::getExplicitCategoriesProvider()
{
- return m_aExplicitCategoriesProvider.getRef();
+ return m_apExplicitCategoriesProvider.get();
}
Sequence< ExplicitScaleData > VCoordinateSystem::getExplicitScales( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const
diff --git a/chart2/source/view/axes/VPolarAngleAxis.cxx b/chart2/source/view/axes/VPolarAngleAxis.cxx
index 7a273e22f128..865a7848aa9a 100644
--- a/chart2/source/view/axes/VPolarAngleAxis.cxx
+++ b/chart2/source/view/axes/VPolarAngleAxis.cxx
@@ -62,7 +62,7 @@ VPolarAngleAxis::~VPolarAngleAxis()
bool VPolarAngleAxis::createTextShapes_ForAngleAxis(
const uno::Reference< drawing::XShapes >& xTarget
- , TickIter& rTickIter
+ , EquidistantTickIter& rTickIter
, AxisLabelProperties& rAxisLabelProperties
, double fLogicRadius
, double fLogicZ )
@@ -99,7 +99,7 @@ bool VPolarAngleAxis::createTextShapes_ForAngleAxis(
; pTickInfo
; pTickInfo = rTickIter.nextInfo(), nTick++ )
{
- //don't create labels which does not fit into the rythm
+ //don't create labels which does not fit into the rhythm
if( nTick%rAxisLabelProperties.nRhythm != 0)
continue;
@@ -189,11 +189,10 @@ void SAL_CALL VPolarAngleAxis::createLabels()
//create tick mark text shapes
//@todo: iterate through all tick depth wich should be labeled
- TickIter aTickIter( m_aAllTickInfos, m_aIncrement, 0, 0 );
+ EquidistantTickIter aTickIter( m_aAllTickInfos, m_aIncrement, 0, 0 );
this->updateUnscaledValuesAtTicks( aTickIter );
- TickIter aRemoveIter( m_aAllTickInfos, m_aIncrement, 0, 0 );
- removeTextShapesFromTicks( aRemoveIter, m_xTextTarget );
+ removeTextShapesFromTicks();
AxisLabelProperties aAxisLabelProperties( m_aAxisLabelProperties );
aAxisLabelProperties.bOverlapAllowed = true;
diff --git a/chart2/source/view/axes/VPolarAngleAxis.hxx b/chart2/source/view/axes/VPolarAngleAxis.hxx
index 9a27c94e3095..c03cf533e22c 100644
--- a/chart2/source/view/axes/VPolarAngleAxis.hxx
+++ b/chart2/source/view/axes/VPolarAngleAxis.hxx
@@ -55,7 +55,7 @@ public:
private: //methods
bool createTextShapes_ForAngleAxis(
const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
- , TickIter& rTickIter
+ , EquidistantTickIter& rTickIter
, AxisLabelProperties& rAxisLabelProperties
, double fLogicRadius, double fLogicZ );
};
diff --git a/chart2/source/view/axes/VPolarGrid.cxx b/chart2/source/view/axes/VPolarGrid.cxx
index b9099906deb0..0bd98b642acb 100644
--- a/chart2/source/view/axes/VPolarGrid.cxx
+++ b/chart2/source/view/axes/VPolarGrid.cxx
@@ -90,7 +90,7 @@ void VPolarGrid::createLinePointSequence_ForAngleAxis(
xInverseScaling = rScale.Scaling->getInverseScaling();
sal_Int32 nTick = 0;
- TickIter aIter( rAllTickInfos, rIncrement, 0, 0 );
+ EquidistantTickIter aIter( rAllTickInfos, rIncrement, 0, 0 );
for( TickInfo* pTickInfo = aIter.firstInfo()
; pTickInfo
; pTickInfo = aIter.nextInfo(), nTick++ )
diff --git a/chart2/source/view/axes/VPolarRadiusAxis.cxx b/chart2/source/view/axes/VPolarRadiusAxis.cxx
index 7970d051e7b1..2206d4d8f559 100644
--- a/chart2/source/view/axes/VPolarRadiusAxis.cxx
+++ b/chart2/source/view/axes/VPolarRadiusAxis.cxx
@@ -49,7 +49,6 @@ VPolarRadiusAxis::VPolarRadiusAxis( const AxisProperties& rAxisProperties
{
m_aAxisProperties.m_fLabelDirectionSign=0.0;
m_aAxisProperties.m_fInnerDirectionSign=0.0;
- m_aAxisProperties.m_bLabelsOutside=true;
m_aAxisProperties.m_bIsMainAxis=false;
m_aAxisProperties.m_aLabelAlignment=LABEL_ALIGN_RIGHT;
m_aAxisProperties.init();
@@ -156,7 +155,7 @@ void SAL_CALL VPolarRadiusAxis::createShapes()
AxisProperties aAxisProperties(m_aAxisProperties);
sal_Int32 nTick = 0;
- TickIter aIter( aAngleTickInfos, rAngleIncrement, 0, 0 );
+ EquidistantTickIter aIter( aAngleTickInfos, rAngleIncrement, 0, 0 );
for( TickInfo* pTickInfo = aIter.firstInfo()
; pTickInfo; pTickInfo = aIter.nextInfo(), nTick++ )
{
diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx
index 1774d9828e91..fd1aaa81c3a0 100644
--- a/chart2/source/view/charttypes/AreaChart.cxx
+++ b/chart2/source/view/charttypes/AreaChart.cxx
@@ -72,7 +72,6 @@ AreaChart::AreaChart( const uno::Reference<XChartType>& xChartTypeModel
, bool bNoArea
, PlottingPositionHelper* pPlottingPositionHelper
, bool bConnectLastToFirstPoint
- , bool bAddOneToXMax
, bool bExpandIfValuesCloseToBorder
, sal_Int32 nKeepAspectRatio
, const drawing::Direction3D& rAspectRatio
@@ -84,7 +83,6 @@ AreaChart::AreaChart( const uno::Reference<XChartType>& xChartTypeModel
, m_bSymbol( ChartTypeHelper::isSupportingSymbolProperties(xChartTypeModel,nDimensionCount) )
, m_bIsPolarCooSys( bConnectLastToFirstPoint )
, m_bConnectLastToFirstPoint( bConnectLastToFirstPoint )
- , m_bAddOneToXMax(bAddOneToXMax)
, m_bExpandIfValuesCloseToBorder( bExpandIfValuesCloseToBorder )
, m_nKeepAspectRatio(nKeepAspectRatio)
, m_aGivenAspectRatio(rAspectRatio)
@@ -123,14 +121,17 @@ AreaChart::~AreaChart()
delete m_pMainPosHelper;
}
+double AreaChart::getMinimumX()
+{
+ if( m_bCategoryXAxis && m_bIsPolarCooSys )//the angle axis in net charts needs a different autoscaling
+ return 1.0;//first category (index 0) matches with real number 1.0
+ return VSeriesPlotter::getMinimumX();
+}
+
double AreaChart::getMaximumX()
{
- if( m_bAddOneToXMax )
- {
- //return category count
- sal_Int32 nPointCount = getPointCount();
- return nPointCount+1;
- }
+ if( m_bCategoryXAxis && m_bIsPolarCooSys )//the angle axis in net charts needs a different autoscaling
+ return getPointCount()+1;
return VSeriesPlotter::getMaximumX();
}
@@ -402,7 +403,7 @@ bool AreaChart::impl_createLine( VDataSeries* pSeries
m_pShapeFactory->createStripe(xSeriesGroupShape_Shapes
, Stripe( aPoint1, aPoint2, fDepth )
- , pSeries->getPropertiesOfSeries(), PropertyMapper::getPropertyNameMapForFilledSeriesProperties(), true );
+ , pSeries->getPropertiesOfSeries(), PropertyMapper::getPropertyNameMapForFilledSeriesProperties(), true, 1 );
}
}
}
diff --git a/chart2/source/view/charttypes/AreaChart.hxx b/chart2/source/view/charttypes/AreaChart.hxx
index afe9908b3bfe..6924509a62a1 100644
--- a/chart2/source/view/charttypes/AreaChart.hxx
+++ b/chart2/source/view/charttypes/AreaChart.hxx
@@ -49,7 +49,6 @@ public:
, bool bCategoryXAxis, bool bNoArea=false
, PlottingPositionHelper* pPlottingPositionHelper=NULL //takes owner ship
, bool bConnectLastToFirstPoint=false
- , bool bAddOneToXMax=false
, bool bExpandIfValuesCloseToBorder=true
, sal_Int32 nKeepAspectRatio=-1 //0->no 1->yes other value->automatic
, const ::com::sun::star::drawing::Direction3D& rAspectRatio=::com::sun::star::drawing::Direction3D(1,1,1)//only taken into account if nKeepAspectRatio==1
@@ -76,6 +75,7 @@ public:
//-------------------------------------------------------------------------
// MinimumAndMaximumSupplier
//-------------------------------------------------------------------------
+ virtual double getMinimumX();
virtual double getMaximumX();
virtual bool isExpandIfValuesCloseToBorder( sal_Int32 nDimensionIndex );
virtual bool isSeperateStackingForDifferentSigns( sal_Int32 nDimensionIndex );
@@ -109,7 +109,6 @@ private: //member
bool m_bSymbol;
bool m_bIsPolarCooSys;//used e.g. for net chart (the data labels need to be placed different)
bool m_bConnectLastToFirstPoint;//used e.g. for net chart
- bool m_bAddOneToXMax;//used e.g. for net chart (the angle axis needs a different autoscaling)
bool m_bExpandIfValuesCloseToBorder; // e.g. false for net charts
sal_Int32 m_nKeepAspectRatio; //0->no 1->yes other value->automatic
diff --git a/chart2/source/view/charttypes/BarChart.cxx b/chart2/source/view/charttypes/BarChart.cxx
index 470796f8fc1e..0d7ef403f87d 100644..100755
--- a/chart2/source/view/charttypes/BarChart.cxx
+++ b/chart2/source/view/charttypes/BarChart.cxx
@@ -110,9 +110,16 @@ drawing::Direction3D BarChart::getPreferredDiagramAspectRatio() const
if( m_nDimension == 3 )
{
aRet = drawing::Direction3D(1.0,-1.0,1.0);
- drawing::Direction3D aScale( this->getPlottingPositionHelper(MAIN_AXIS_INDEX).getScaledLogicWidth() );
+ BarPositionHelper* pPosHelper = dynamic_cast<BarPositionHelper*>(&( this->getPlottingPositionHelper( MAIN_AXIS_INDEX) ) );
+ drawing::Direction3D aScale( pPosHelper->getScaledLogicWidth() );
if(aScale.DirectionX!=0.0)
- aRet.DirectionZ = aScale.DirectionZ/aScale.DirectionX;
+ {
+ double fXSlotCount = 1.0;
+ if(!m_aZSlots.empty())
+ fXSlotCount = m_aZSlots.begin()->size();
+
+ aRet.DirectionZ = aScale.DirectionZ/(aScale.DirectionX + aScale.DirectionX*(fXSlotCount-1.0)*pPosHelper->getSlotWidth());
+ }
else
return VSeriesPlotter::getPreferredDiagramAspectRatio();
if(aRet.DirectionZ<0.05)
@@ -357,7 +364,8 @@ uno::Reference< drawing::XShape > BarChart::createDataPoint3D_Bar(
xShape = m_pShapeFactory->createCone( xTarget, rPosition, rSize, fTopHeight, nRotateZAngleHundredthDegree );
break;
case DataPointGeometry3D::PYRAMID:
- xShape = m_pShapeFactory->createPyramid( xTarget, rPosition, rSize, fTopHeight, nRotateZAngleHundredthDegree );
+ xShape = m_pShapeFactory->createPyramid( xTarget, rPosition, rSize, fTopHeight, nRotateZAngleHundredthDegree>0
+ , xObjectProperties, PropertyMapper::getPropertyNameMapForFilledSeriesProperties() );
break;
case DataPointGeometry3D::CUBOID:
default:
@@ -366,7 +374,8 @@ uno::Reference< drawing::XShape > BarChart::createDataPoint3D_Bar(
, PropertyMapper::getPropertyNameMapForFilledSeriesProperties(), bRoundedEdges );
return xShape;
}
- this->setMappedProperties( xShape, xObjectProperties, PropertyMapper::getPropertyNameMapForFilledSeriesProperties() );
+ if( nGeometry3D != DataPointGeometry3D::PYRAMID )
+ this->setMappedProperties( xShape, xObjectProperties, PropertyMapper::getPropertyNameMapForFilledSeriesProperties() );
return xShape;
}
@@ -734,6 +743,7 @@ void BarChart::createShapes()
double fMiddleHeight = fUpperYValue-fLowerYValue;
if(!bPositive)
fMiddleHeight*=-1.0;
+ double fLogicBarDepth = 0.5;
if(m_nDimension==3)
{
if( lcl_hasGeometry3DVariableWidth(nGeometry3D) && fCompleteHeight!=0.0 )
@@ -744,9 +754,11 @@ void BarChart::createShapes()
fLogicBarWidth = fLogicBaseWidth*fHeight/(fCompleteHeight);
if(fLogicBarWidth<=0.0)
fLogicBarWidth=fLogicBaseWidth;
+ fLogicBarDepth = fLogicBarDepth*fHeight/(fCompleteHeight);
+ if(fLogicBarDepth<=0.0)
+ fLogicBarDepth*=-1.0;
}
}
- double fLogicBarDepth = fLogicBarWidth;
//better performance for big data
FormerBarPoint aFormerPoint( aSeriesFormerPointMap[pSeries] );
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index a6ab71df15f5..37888c8f0a9b 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -156,7 +156,7 @@ VSeriesPlotter::VSeriesPlotter( const uno::Reference<XChartType>& xChartTypeMode
, m_aZSlots()
, m_bCategoryXAxis(bCategoryXAxis)
, m_xColorScheme()
- , m_xExplicitCategoriesProvider()
+ , m_pExplicitCategoriesProvider(0)
, m_bPointsWereSkipped(false)
{
DBG_ASSERT(m_xChartTypeModel.is(),"no XChartType available in view, fallback to default values may be wrong");
@@ -477,9 +477,9 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re
{
if(pLabel->ShowCategoryName)
{
- if( m_xExplicitCategoriesProvider.is() )
+ if( m_pExplicitCategoriesProvider )
{
- Sequence< OUString > aCategories( m_xExplicitCategoriesProvider->getTextualData() );
+ Sequence< OUString > aCategories( m_pExplicitCategoriesProvider->getSimpleCategories() );
if( nPointIndex >= 0 && nPointIndex < aCategories.getLength() )
{
aText.append( aCategories[nPointIndex] );
@@ -560,11 +560,17 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re
sal_Int32 nYDiff = aTextSize.Height/nLineCountForSymbolsize;
sal_Int32 nXDiff = aSymbolSize.Width * nYDiff/aSymbolSize.Height;
+ // #i109336# Improve auto positioning in chart
+ nXDiff = nXDiff * 80 / 100;
+ nYDiff = nYDiff * 80 / 100;
+
aSymbolSize.Width = nXDiff * 75/100;
aSymbolSize.Height = nYDiff * 75/100;
awt::Point aSymbolPosition( aUnrotatedTextPos );
- aSymbolPosition.Y += (nYDiff * 25/200);
+
+ // #i109336# Improve auto positioning in chart
+ aSymbolPosition.Y += ( nYDiff / 4 );
if(LABEL_ALIGN_LEFT==eAlignment
|| LABEL_ALIGN_LEFT_TOP==eAlignment
@@ -1127,7 +1133,12 @@ void VSeriesPlotter::setMappedProperties(
double VSeriesPlotter::getMinimumX()
{
if( m_bCategoryXAxis )
- return 1.0;//first category (index 0) matches with real number 1.0
+ {
+ double fRet = 1.0;//first category (index 0) matches with real number 1.0
+ if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->hasComplexCategories() )
+ fRet -= 0.5;
+ return fRet;
+ }
double fMinimum, fMaximum;
this->getMinimumAndMaximiumX( fMinimum, fMaximum );
@@ -1138,8 +1149,10 @@ double VSeriesPlotter::getMaximumX()
if( m_bCategoryXAxis )
{
//return category count
- sal_Int32 nPointCount = getPointCount();
- return nPointCount;//first category (index 0) matches with real number 1.0
+ double fRet = getPointCount();//first category (index 0) matches with real number 1.0
+ if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->hasComplexCategories() )
+ fRet += 0.5;
+ return fRet;
}
double fMinimum, fMaximum;
@@ -1356,9 +1369,9 @@ void VSeriesPlotter::setColorScheme( const uno::Reference< XColorScheme >& xColo
m_xColorScheme = xColorScheme;
}
-void VSeriesPlotter::setExplicitCategoriesProvider( const uno::Reference< data::XTextualDataSequence >& xExplicitCategoriesProvider )
+void VSeriesPlotter::setExplicitCategoriesProvider( ExplicitCategoriesProvider* pExplicitCategoriesProvider )
{
- m_xExplicitCategoriesProvider = xExplicitCategoriesProvider;
+ m_pExplicitCategoriesProvider = pExplicitCategoriesProvider;
}
sal_Int32 VDataSeriesGroup::getPointCount() const
@@ -1929,8 +1942,8 @@ std::vector< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntriesForSe
if( bVaryColorsByPoint )
{
Sequence< OUString > aCategoryNames;
- if( m_xExplicitCategoriesProvider.is() )
- aCategoryNames = m_xExplicitCategoriesProvider->getTextualData();
+ if( m_pExplicitCategoriesProvider )
+ aCategoryNames = m_pExplicitCategoriesProvider->getSimpleCategories();
for( sal_Int32 nIdx=0; nIdx<aCategoryNames.getLength(); ++nIdx )
{
@@ -2074,9 +2087,9 @@ VSeriesPlotter* VSeriesPlotter::createSeriesPlotter(
else if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
pRet = new PieChart(xChartTypeModel,nDimensionCount);
else if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
- pRet = new AreaChart(xChartTypeModel,nDimensionCount,true,true,new PolarPlottingPositionHelper(),true,true,false,1,drawing::Direction3D(1,1,1) );
+ pRet = new AreaChart(xChartTypeModel,nDimensionCount,true,true,new PolarPlottingPositionHelper(),true,false,1,drawing::Direction3D(1,1,1) );
else if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
- pRet = new AreaChart(xChartTypeModel,nDimensionCount,true,false,new PolarPlottingPositionHelper(),true,true,false,1,drawing::Direction3D(1,1,1) );
+ pRet = new AreaChart(xChartTypeModel,nDimensionCount,true,false,new PolarPlottingPositionHelper(),true,false,1,drawing::Direction3D(1,1,1) );
else if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
pRet = new CandleStickChart(xChartTypeModel,nDimensionCount);
else
diff --git a/chart2/source/view/diagram/VDiagram.cxx b/chart2/source/view/diagram/VDiagram.cxx
index 51775cdde85b..5ffec22969a0 100644
--- a/chart2/source/view/diagram/VDiagram.cxx
+++ b/chart2/source/view/diagram/VDiagram.cxx
@@ -534,6 +534,9 @@ void VDiagram::createShapes_3d()
bool bAddFloorAndWall = DiagramHelper::isSupportingFloorAndWall( m_xDiagram );
+ const bool bDoubleSided = false;
+ const bool bFlatNormals = true;
+
//add walls
{
uno::Reference< beans::XPropertySet > xWallProp( NULL );
@@ -544,19 +547,31 @@ void VDiagram::createShapes_3d()
if( !bAddFloorAndWall )
aWallCID = rtl::OUString();
uno::Reference< drawing::XShapes > xWallGroup_Shapes( m_pShapeFactory->createGroup3D( xOuterGroup_Shapes, aWallCID ) );
+
+ CuboidPlanePosition eLeftWallPos( ThreeDHelper::getAutomaticCuboidPlanePositionForStandardLeftWall( uno::Reference< beans::XPropertySet >( m_xDiagram, uno::UNO_QUERY ) ) );
+ CuboidPlanePosition eBackWallPos( ThreeDHelper::getAutomaticCuboidPlanePositionForStandardBackWall( uno::Reference< beans::XPropertySet >( m_xDiagram, uno::UNO_QUERY ) ) );
+
//add left wall
{
+ short nRotatedTexture = ( CuboidPlanePosition_Front==eBackWallPos ) ? 3 : 1;
double xPos = 0.0;
- CuboidPlanePosition eLeftWallPos( ThreeDHelper::getAutomaticCuboidPlanePositionForStandardLeftWall( uno::Reference< beans::XPropertySet >( m_xDiagram, uno::UNO_QUERY ) ) );
if( CuboidPlanePosition_Right==eLeftWallPos )
xPos = FIXED_SIZE_FOR_3D_CHART_VOLUME;
Stripe aStripe( drawing::Position3D(xPos,FIXED_SIZE_FOR_3D_CHART_VOLUME,0)
- , drawing::Direction3D(0,-FIXED_SIZE_FOR_3D_CHART_VOLUME,0)
- , drawing::Direction3D(0,0,FIXED_SIZE_FOR_3D_CHART_VOLUME) );
+ , drawing::Direction3D(0,0,FIXED_SIZE_FOR_3D_CHART_VOLUME)
+ , drawing::Direction3D(0,-FIXED_SIZE_FOR_3D_CHART_VOLUME,0) );
+ if( CuboidPlanePosition_Right==eLeftWallPos )
+ {
+ nRotatedTexture = ( CuboidPlanePosition_Front==eBackWallPos ) ? 2 : 0;
+ aStripe = Stripe( drawing::Position3D(xPos,FIXED_SIZE_FOR_3D_CHART_VOLUME,0)
+ , drawing::Direction3D(0,-FIXED_SIZE_FOR_3D_CHART_VOLUME,0)
+ , drawing::Direction3D(0,0,FIXED_SIZE_FOR_3D_CHART_VOLUME) );
+ }
+ aStripe.InvertNormal(true);
uno::Reference< drawing::XShape > xShape =
m_pShapeFactory->createStripe( xWallGroup_Shapes, aStripe
- , xWallProp, PropertyMapper::getPropertyNameMapForFillAndLineProperties(), true, true );
+ , xWallProp, PropertyMapper::getPropertyNameMapForFillAndLineProperties(), bDoubleSided, nRotatedTexture, bFlatNormals );
if( !bAddFloorAndWall )
{
//we always need this object as dummy object for correct scene dimensions
@@ -566,17 +581,25 @@ void VDiagram::createShapes_3d()
}
//add back wall
{
+ short nRotatedTexture = 0;
double zPos = 0.0;
- CuboidPlanePosition eBackWallPos( ThreeDHelper::getAutomaticCuboidPlanePositionForStandardBackWall( uno::Reference< beans::XPropertySet >( m_xDiagram, uno::UNO_QUERY ) ) );
if( CuboidPlanePosition_Front==eBackWallPos )
zPos = FIXED_SIZE_FOR_3D_CHART_VOLUME;
Stripe aStripe( drawing::Position3D(0,FIXED_SIZE_FOR_3D_CHART_VOLUME,zPos)
+ , drawing::Direction3D(0,-FIXED_SIZE_FOR_3D_CHART_VOLUME,0)
+ , drawing::Direction3D(FIXED_SIZE_FOR_3D_CHART_VOLUME,0,0) );
+ if( CuboidPlanePosition_Front==eBackWallPos )
+ {
+ aStripe = Stripe( drawing::Position3D(0,FIXED_SIZE_FOR_3D_CHART_VOLUME,zPos)
, drawing::Direction3D(FIXED_SIZE_FOR_3D_CHART_VOLUME,0,0)
, drawing::Direction3D(0,-FIXED_SIZE_FOR_3D_CHART_VOLUME,0) );
+ nRotatedTexture = 3;
+ }
+ aStripe.InvertNormal(true);
uno::Reference< drawing::XShape > xShape =
m_pShapeFactory->createStripe(xWallGroup_Shapes, aStripe
- , xWallProp, PropertyMapper::getPropertyNameMapForFillAndLineProperties(), true );
+ , xWallProp, PropertyMapper::getPropertyNameMapForFillAndLineProperties(), bDoubleSided, nRotatedTexture, bFlatNormals );
if( !bAddFloorAndWall )
{
//we always need this object as dummy object for correct scene dimensions
@@ -643,44 +666,14 @@ void VDiagram::createShapes_3d()
if( m_xDiagram.is() )
xFloorProp=uno::Reference< beans::XPropertySet >( m_xDiagram->getFloor());
- uno::Reference< drawing::XShape > xShape(
- m_xShapeFactory->createInstance( C2U(
- "com.sun.star.drawing.Shape3DExtrudeObject") ), uno::UNO_QUERY );
- xOuterGroup_Shapes->add(xShape);
- uno::Reference< beans::XPropertySet > xShapeProp( xShape, uno::UNO_QUERY );
- if( xShapeProp.is())
- {
- //depth
- xShapeProp->setPropertyValue( C2U( UNO_NAME_3D_EXTRUDE_DEPTH )
- , uno::makeAny((sal_Int32)FLOOR_THICKNESS) );
- //PercentDiagonal
- xShapeProp->setPropertyValue( C2U( UNO_NAME_3D_PERCENT_DIAGONAL )
- , uno::makeAny( sal_Int32(0) ) );
-
- drawing::Direction3D aSize(FIXED_SIZE_FOR_3D_CHART_VOLUME,FIXED_SIZE_FOR_3D_CHART_VOLUME,FLOOR_THICKNESS);
-
- //Polygon
- drawing::PolyPolygonShape3D aPoly;
- AddPointToPoly( aPoly, drawing::Position3D(0,0,0) );
- AddPointToPoly( aPoly, drawing::Position3D(FIXED_SIZE_FOR_3D_CHART_VOLUME,0,0) );
- AddPointToPoly( aPoly, drawing::Position3D(FIXED_SIZE_FOR_3D_CHART_VOLUME,FIXED_SIZE_FOR_3D_CHART_VOLUME,0) );
- AddPointToPoly( aPoly, drawing::Position3D(0,FIXED_SIZE_FOR_3D_CHART_VOLUME,0) );
- AddPointToPoly( aPoly, drawing::Position3D(0,0,0) );
- xShapeProp->setPropertyValue( C2U( UNO_NAME_3D_POLYPOLYGON3D ), uno::makeAny( aPoly ) );
-
- //Matrix for position
- {
- ::basegfx::B3DHomMatrix aM;
- aM.rotate(F_PI/2.0,0.0,0.0);
- aM.translate(0.0,FLOOR_THICKNESS, 0.0);
- drawing::HomogenMatrix aHM = B3DHomMatrixToHomogenMatrix(aM);
- E3DModifySceneSnapRectUpdater aUpdater(lcl_getE3dScene( m_xOuterGroupShape ));
- xShapeProp->setPropertyValue( C2U( UNO_NAME_3D_TRANSFORM_MATRIX )
- , uno::makeAny(aHM) );
- }
+ Stripe aStripe( drawing::Position3D(0,0,0)
+ , drawing::Direction3D(0,0,FIXED_SIZE_FOR_3D_CHART_VOLUME)
+ , drawing::Direction3D(FIXED_SIZE_FOR_3D_CHART_VOLUME,0,0) );
+ aStripe.InvertNormal(true);
- PropertyMapper::setMappedProperties( xShapeProp, xFloorProp, PropertyMapper::getPropertyNameMapForFillAndLineProperties() );
- }
+ uno::Reference< drawing::XShape > xShape =
+ m_pShapeFactory->createStripe(xOuterGroup_Shapes, aStripe
+ , xFloorProp, PropertyMapper::getPropertyNameMapForFillAndLineProperties(), bDoubleSided, 0, bFlatNormals );
CuboidPlanePosition eBottomPos( ThreeDHelper::getAutomaticCuboidPlanePositionForStandardBottom( uno::Reference< beans::XPropertySet >( m_xDiagram, uno::UNO_QUERY ) ) );
if( !bAddFloorAndWall || (CuboidPlanePosition_Bottom!=eBottomPos) )
@@ -709,11 +702,11 @@ void VDiagram::createShapes_3d()
try
{
double fXScale = (FIXED_SIZE_FOR_3D_CHART_VOLUME -GRID_TO_WALL_DISTANCE) /FIXED_SIZE_FOR_3D_CHART_VOLUME;
- double fYScale = (FIXED_SIZE_FOR_3D_CHART_VOLUME -FLOOR_THICKNESS-GRID_TO_WALL_DISTANCE ) /FIXED_SIZE_FOR_3D_CHART_VOLUME;
+ double fYScale = (FIXED_SIZE_FOR_3D_CHART_VOLUME -GRID_TO_WALL_DISTANCE) /FIXED_SIZE_FOR_3D_CHART_VOLUME;
double fZScale = (FIXED_SIZE_FOR_3D_CHART_VOLUME -GRID_TO_WALL_DISTANCE) /FIXED_SIZE_FOR_3D_CHART_VOLUME;
::basegfx::B3DHomMatrix aM;
- aM.translate(GRID_TO_WALL_DISTANCE/fXScale, (FLOOR_THICKNESS+GRID_TO_WALL_DISTANCE)/fYScale, GRID_TO_WALL_DISTANCE/fZScale);
+ aM.translate(GRID_TO_WALL_DISTANCE/fXScale, GRID_TO_WALL_DISTANCE/fYScale, GRID_TO_WALL_DISTANCE/fZScale);
aM.scale( fXScale, fYScale, fZScale );
E3DModifySceneSnapRectUpdater aUpdater(lcl_getE3dScene( m_xOuterGroupShape ));
xShapeProp->setPropertyValue( C2U( UNO_NAME_3D_TRANSFORM_MATRIX )
diff --git a/chart2/source/view/inc/PropertyMapper.hxx b/chart2/source/view/inc/PropertyMapper.hxx
index fbdebb4fa1a2..c0871b94f835 100644
--- a/chart2/source/view/inc/PropertyMapper.hxx
+++ b/chart2/source/view/inc/PropertyMapper.hxx
@@ -88,6 +88,11 @@ public:
, const tNameSequence& rPropNames
, const rtl::OUString& rPropName );
+ static ::com::sun::star::uno::Any*
+ getValuePointerForLimitedSpace( tAnySequence& rPropValues
+ , const tNameSequence& rPropNames
+ , bool bLimitedHeight );
+
static void setMultiProperties(
const tNameSequence& rNames
, const tAnySequence& rValues
diff --git a/chart2/source/view/inc/ShapeFactory.hxx b/chart2/source/view/inc/ShapeFactory.hxx
index e16310a71ce7..ef75f3a323af 100644
--- a/chart2/source/view/inc/ShapeFactory.hxx
+++ b/chart2/source/view/inc/ShapeFactory.hxx
@@ -90,7 +90,11 @@ public:
::com::sun::star::drawing::XShapes >& xTarget
, const ::com::sun::star::drawing::Position3D& rPosition
, const ::com::sun::star::drawing::Direction3D& rSize
- , double fTopHeight, sal_Int32 nRotateZAngleHundredthDegree );
+ , double fTopHeight
+ , bool bRotateZ
+ , const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet >& xSourceProp
+ , const tPropertyNameMap& rPropertyNameMap);
::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
createCone( const ::com::sun::star::uno::Reference<
@@ -119,7 +123,9 @@ public:
, const Stripe& rStripe
, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xSourceProp
, const tPropertyNameMap& rPropertyNameMap
- , sal_Bool bDoubleSided = true, bool bRotatedTexture=false );
+ , sal_Bool bDoubleSided = true
+ , short nRotatedTexture = 0 //0 to 7 are the different possibilities
+ , bool bFlatNormals=true );
::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
createArea3D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
@@ -235,7 +241,6 @@ private:
, const ::com::sun::star::drawing::Position3D& rPosition
, const ::com::sun::star::drawing::Direction3D& rSize
, double fTopHeight, sal_Int32 nRotateZAngleHundredthDegree
- , sal_Int32 nSegments
, bool bCylinder = false);
//member:
diff --git a/chart2/source/view/inc/Stripe.hxx b/chart2/source/view/inc/Stripe.hxx
index b176685aefb5..ca1aaf155d1e 100644
--- a/chart2/source/view/inc/Stripe.hxx
+++ b/chart2/source/view/inc/Stripe.hxx
@@ -53,16 +53,19 @@ public:
, const ::com::sun::star::drawing::Position3D& rPoint2
, double fDepth );
-/*
Stripe( const ::com::sun::star::drawing::Position3D& rPoint1
, const ::com::sun::star::drawing::Position3D& rPoint2
, const ::com::sun::star::drawing::Position3D& rPoint3
- , const ::com::sun::star::drawing::Position3D& rPoint4 );*/
+ , const ::com::sun::star::drawing::Position3D& rPoint4 );
+ void SetManualNormal( const ::com::sun::star::drawing::Direction3D& rNormal );
+ ::com::sun::star::drawing::Direction3D getNormal() const;
+
+ void InvertNormal( bool bInvertNormal );
::com::sun::star::uno::Any getPolyPolygonShape3D() const;
::com::sun::star::uno::Any getNormalsPolygon() const;
- ::com::sun::star::uno::Any getTexturePolygon( bool bRotatedTexture ) const;
+ ::com::sun::star::uno::Any getTexturePolygon( short nRotatedTexture ) const; //0 to 7 are the different possibilities
::com::sun::star::drawing::Position3D GetPosition1() const { return m_aPoint1; }
::com::sun::star::drawing::Position3D GetPosition2() const { return m_aPoint2; }
@@ -75,8 +78,9 @@ private:
::com::sun::star::drawing::Position3D m_aPoint3;
::com::sun::star::drawing::Position3D m_aPoint4;
- ::com::sun::star::drawing::Direction3D
- getNormal() const;
+ bool m_bInvertNormal;
+ bool m_bManualNormalSet;
+ ::com::sun::star::drawing::Direction3D m_aManualNormal;
};
//.............................................................................
diff --git a/chart2/source/view/inc/VCoordinateSystem.hxx b/chart2/source/view/inc/VCoordinateSystem.hxx
index 4a3d52203545..e884af865d6e 100644
--- a/chart2/source/view/inc/VCoordinateSystem.hxx
+++ b/chart2/source/view/inc/VCoordinateSystem.hxx
@@ -30,11 +30,11 @@
#include "MinimumAndMaximumSupplier.hxx"
#include "ScaleAutomatism.hxx"
#include "ThreeDHelper.hxx"
+#include "ExplicitCategoriesProvider.hxx"
#include <com/sun/star/chart2/ExplicitIncrementData.hpp>
#include <com/sun/star/chart2/ExplicitScaleData.hpp>
#include <com/sun/star/chart2/XCoordinateSystem.hpp>
-#include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
#include "comphelper/implementationreference.hxx"
#include <com/sun/star/awt/Rectangle.hpp>
#include <com/sun/star/drawing/HomogenMatrix.hpp>
@@ -51,8 +51,6 @@ namespace chart
{
//.............................................................................
-class ExplicitCategoriesProvider;
-
//-----------------------------------------------------------------------------
/**
*/
@@ -87,7 +85,9 @@ public:
::com::sun::star::chart2::ExplicitScaleData getExplicitScale( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const;
::com::sun::star::chart2::ExplicitIncrementData getExplicitIncrement( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const;
- ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XTextualDataSequence > getExplicitCategoriesProvider();
+
+ void setExplicitCategoriesProvider( ExplicitCategoriesProvider* /*takes ownership*/ );
+ ExplicitCategoriesProvider* getExplicitCategoriesProvider();
// returns a coplete scale set for a given dimension and index; for example if nDimensionIndex==1 and nAxisIndex==2 you get returned the secondary x axis, main y axis and main z axis
::com::sun::star::uno::Sequence< ::com::sun::star::chart2::ExplicitScaleData > getExplicitScales( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const;
@@ -203,8 +203,7 @@ private:
tFullExplicitScaleMap m_aSecondaryExplicitScales;
tFullExplicitIncrementMap m_aSecondaryExplicitIncrements;
- comphelper::ImplementationReference< ExplicitCategoriesProvider, ::com::sun::star::chart2::data::XTextualDataSequence >
- m_aExplicitCategoriesProvider;
+ ::std::auto_ptr< ExplicitCategoriesProvider > m_apExplicitCategoriesProvider;
};
//.............................................................................
diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx b/chart2/source/view/inc/VSeriesPlotter.hxx
index 95093db1bfaf..02c1f3b044e9 100644
--- a/chart2/source/view/inc/VSeriesPlotter.hxx
+++ b/chart2/source/view/inc/VSeriesPlotter.hxx
@@ -32,9 +32,9 @@
#include "LabelAlignment.hxx"
#include "MinimumAndMaximumSupplier.hxx"
#include "LegendEntryProvider.hxx"
+#include "ExplicitCategoriesProvider.hxx"
#include <com/sun/star/chart2/LegendSymbolStyle.hpp>
#include <com/sun/star/chart2/XChartType.hpp>
-#include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
#include <com/sun/star/drawing/Direction3D.hpp>
@@ -275,8 +275,7 @@ public:
void setColorScheme( const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XColorScheme >& xColorScheme );
- void setExplicitCategoriesProvider( const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XTextualDataSequence >& xExplicitCategoriesProvider );
+ void setExplicitCategoriesProvider( ExplicitCategoriesProvider* pExplicitCategoriesProvider );
//get series names for the z axis labels
::com::sun::star::uno::Sequence< rtl::OUString > getSeriesNames() const;
@@ -431,8 +430,7 @@ protected: //member
::com::sun::star::uno::Reference<
::com::sun::star::chart2::XColorScheme > m_xColorScheme;
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XTextualDataSequence > m_xExplicitCategoriesProvider;
+ ExplicitCategoriesProvider* m_pExplicitCategoriesProvider;
//better performance for big data
::com::sun::star::uno::Sequence< sal_Int32 > m_aCoordinateSystemResolution;
diff --git a/chart2/source/view/inc/ViewDefines.hxx b/chart2/source/view/inc/ViewDefines.hxx
index e520522e2389..623e46e64fb7 100644
--- a/chart2/source/view/inc/ViewDefines.hxx
+++ b/chart2/source/view/inc/ViewDefines.hxx
@@ -37,7 +37,6 @@ namespace chart
#define FIXED_SIZE_FOR_3D_CHART_VOLUME (10000.0)
//There needs to be a little distance betweengrid lines and walls in 3D, otherwise the lines are partly hidden by the walls
#define GRID_TO_WALL_DISTANCE (1.0)
-#define FLOOR_THICKNESS (100.0)
const double ZDIRECTION = 1.0;
const sal_Int32 AXIS2D_TICKLENGTH = 150;//value like in old chart
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 51504db2a396..549ef0273595 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -71,6 +71,7 @@
// header for class Application
#include <vcl/svapp.hxx>
#include <vos/mutex.hxx>
+#include <svx/unofill.hxx>
#include <time.h>
@@ -100,6 +101,7 @@
#include <com/sun/star/text/XTextDocument.hpp>
#include <com/sun/star/text/WritingMode2.hpp>
#include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
#include <svl/languageoptions.hxx>
#include <sot/clsids.hxx>
@@ -216,13 +218,15 @@ ChartView::~ChartView()
void ChartView::impl_deleteCoordinateSystems()
{
//delete all coordinate systems
- ::std::vector< VCoordinateSystem* >::const_iterator aIter = m_aVCooSysList.begin();
- const ::std::vector< VCoordinateSystem* >::const_iterator aEnd = m_aVCooSysList.end();
+ ::std::vector< VCoordinateSystem* > aVectorToDeleteObjects;
+ ::std::swap( aVectorToDeleteObjects, m_aVCooSysList );//#i109770#
+ ::std::vector< VCoordinateSystem* >::const_iterator aIter = aVectorToDeleteObjects.begin();
+ const ::std::vector< VCoordinateSystem* >::const_iterator aEnd = aVectorToDeleteObjects.end();
for( ; aIter != aEnd; aIter++ )
{
delete *aIter;
}
- m_aVCooSysList.clear();
+ aVectorToDeleteObjects.clear();
}
@@ -422,6 +426,8 @@ VCoordinateSystem* addCooSysToList( std::vector< VCoordinateSystem* >& rVCooSysL
rtl::OUString aCooSysParticle( ObjectIdentifier::createParticleForCoordinateSystem( xCooSys, xChartModel ) );
pVCooSys->setParticle(aCooSysParticle);
+ pVCooSys->setExplicitCategoriesProvider( new ExplicitCategoriesProvider(xCooSys,xChartModel) );
+
rVCooSysList.push_back( pVCooSys );
}
}
@@ -572,13 +578,13 @@ private:
std::vector< VCoordinateSystem* >& m_rVCooSysList;
::std::map< uno::Reference< XAxis >, AxisUsage > m_aAxisUsageList;
sal_Int32 m_nMaxAxisIndex;
- bool m_bShiftXAxisTicks;
+ bool m_bChartTypeUsesShiftedXAxisTicksPerDefault;
};
SeriesPlotterContainer::SeriesPlotterContainer( std::vector< VCoordinateSystem* >& rVCooSysList )
: m_rVCooSysList( rVCooSysList )
, m_nMaxAxisIndex(0)
- , m_bShiftXAxisTicks(false)
+ , m_bChartTypeUsesShiftedXAxisTicksPerDefault(false)
{
}
@@ -673,7 +679,7 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(
uno::Reference< XChartType > xChartType( aChartTypeList[nT] );
if(nT==0)
- m_bShiftXAxisTicks = ChartTypeHelper::shiftTicksAtXAxisPerDefault( xChartType );
+ m_bChartTypeUsesShiftedXAxisTicksPerDefault = ChartTypeHelper::shiftTicksAtXAxisPerDefault( xChartType );
VSeriesPlotter* pPlotter = VSeriesPlotter::createSeriesPlotter( xChartType, nDimensionCount );
if( !pPlotter )
@@ -927,7 +933,9 @@ void SeriesPlotterContainer::doAutoScaling( const uno::Reference< frame::XModel
for( nC=0; nC < aVCooSysList_X.size(); nC++)
{
- if( m_bShiftXAxisTicks )
+ 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 );
}
@@ -1773,7 +1781,8 @@ sal_Int32 lcl_getExplicitNumberFormatKeyForAxis(
if(!aLabeledSeq[nLSeqIdx].is())
continue;
Reference< data::XDataSequence > xSeq( aLabeledSeq[nLSeqIdx]->getValues());
- OSL_ASSERT( xSeq.is());
+ if(!xSeq.is())
+ continue;
Reference< beans::XPropertySet > xSeqProp( xSeq, uno::UNO_QUERY );
::rtl::OUString aRole;
bool bTakeIntoAccount =
@@ -2148,7 +2157,7 @@ void changePositionOfAxisTitle( VTitle* pVTitle, TitleAlignment eAlignment
pVTitle->changePosition( aNewPosition );
}
-std::auto_ptr<VTitle> lcl_createTitle( const uno::Reference< XTitle >& xTitle
+std::auto_ptr<VTitle> lcl_createTitle( TitleHelper::eTitleType eType
, const uno::Reference< drawing::XShapes>& xPageShapes
, const uno::Reference< lang::XMultiServiceFactory>& xShapeFactory
, const uno::Reference< frame::XModel >& xChartModel
@@ -2158,10 +2167,32 @@ std::auto_ptr<VTitle> lcl_createTitle( const uno::Reference< XTitle >& xTitle
, bool& rbAutoPosition )
{
std::auto_ptr<VTitle> apVTitle;
+
+ // #i109336# Improve auto positioning in chart
+ double fPercentage = lcl_getPageLayoutDistancePercentage();
+ sal_Int32 nXDistance = static_cast< sal_Int32 >( rPageSize.Width * fPercentage );
+ sal_Int32 nYDistance = static_cast< sal_Int32 >( rPageSize.Height * fPercentage );
+ if ( eType == TitleHelper::MAIN_TITLE )
+ {
+ sal_Int32 nYOffset = 135; // 1/100 mm
+ nYDistance += nYOffset;
+ }
+ else if ( eType == TitleHelper::TITLE_AT_STANDARD_X_AXIS_POSITION )
+ {
+ sal_Int32 nYOffset = 420; // 1/100 mm
+ nYDistance = nYOffset;
+ }
+ else if ( eType == TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION )
+ {
+ sal_Int32 nXOffset = 450; // 1/100 mm
+ nXDistance = nXOffset;
+ }
+
+ uno::Reference< XTitle > xTitle( TitleHelper::getTitle( eType, xChartModel ) );
if(xTitle.is())
{
rtl::OUString aCompleteString( TitleHelper::getCompleteString( xTitle ) );
- if( aCompleteString.getLength()==0 )
+ if ( aCompleteString.getLength() == 0 )
return apVTitle;//don't create empty titles as the resulting diagram position is wrong then
//create title
@@ -2175,8 +2206,6 @@ std::auto_ptr<VTitle> lcl_createTitle( const uno::Reference< XTitle >& xTitle
//position
rbAutoPosition=true;
awt::Point aNewPosition(0,0);
- sal_Int32 nYDistance = static_cast<sal_Int32>(rPageSize.Height*lcl_getPageLayoutDistancePercentage());
- sal_Int32 nXDistance = static_cast<sal_Int32>(rPageSize.Width*lcl_getPageLayoutDistancePercentage());
chart2::RelativePosition aRelativePosition;
uno::Reference< beans::XPropertySet > xProp(xTitle, uno::UNO_QUERY);
if( xProp.is() && (xProp->getPropertyValue( C2U( "RelativePosition" ) )>>=aRelativePosition) )
@@ -2240,6 +2269,37 @@ std::auto_ptr<VTitle> lcl_createTitle( const uno::Reference< XTitle >& xTitle
break;
}
}
+ else
+ {
+ // #i109336# Improve auto positioning in chart
+ switch ( eAlignment )
+ {
+ case ALIGN_TOP:
+ {
+ rRemainingSpace.Y += nYDistance;
+ rRemainingSpace.Height -= nYDistance;
+ }
+ break;
+ case ALIGN_BOTTOM:
+ {
+ rRemainingSpace.Height -= nYDistance;
+ }
+ break;
+ case ALIGN_LEFT:
+ {
+ rRemainingSpace.X += nXDistance;
+ rRemainingSpace.Width -= nXDistance;
+ }
+ break;
+ case ALIGN_RIGHT:
+ {
+ rRemainingSpace.Width -= nXDistance;
+ }
+ break;
+ default:
+ break;
+ }
+ }
return apVTitle;
}
@@ -2423,6 +2483,8 @@ void ChartView::createShapes()
{
// /--
::vos::OGuard aSolarGuard( Application::GetSolarMutex());
+ // #i12587# support for shapes in chart
+ m_pDrawModelWrapper->getSdrModel().EnableUndo( FALSE );
m_pDrawModelWrapper->clearMainDrawPage();
// \--
}
@@ -2467,13 +2529,13 @@ void ChartView::createShapes()
bool bAutoPositionDummy = true;
//------------ create main title shape
- lcl_createTitle( TitleHelper::getTitle( TitleHelper::MAIN_TITLE, m_xChartModel ), xPageShapes, m_xShapeFactory, m_xChartModel
+ lcl_createTitle( TitleHelper::MAIN_TITLE, xPageShapes, m_xShapeFactory, m_xChartModel
, aRemainingSpace, aPageSize, ALIGN_TOP, bAutoPositionDummy );
if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0)
return;
//------------ create sub title shape
- lcl_createTitle( TitleHelper::getTitle( TitleHelper::SUB_TITLE, m_xChartModel ), xPageShapes, m_xShapeFactory, m_xChartModel
+ lcl_createTitle( TitleHelper::SUB_TITLE, xPageShapes, m_xShapeFactory, m_xChartModel
, aRemainingSpace, aPageSize, ALIGN_TOP, bAutoPositionDummy );
if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0)
return;
@@ -2497,7 +2559,7 @@ void ChartView::createShapes()
bool bAutoPosition_XTitle = true;
std::auto_ptr<VTitle> apVTitle_X;
if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 0 ) )
- apVTitle_X = lcl_createTitle( TitleHelper::getTitle( TitleHelper::TITLE_AT_STANDARD_X_AXIS_POSITION, m_xChartModel ), xPageShapes, m_xShapeFactory, m_xChartModel
+ apVTitle_X = lcl_createTitle( TitleHelper::TITLE_AT_STANDARD_X_AXIS_POSITION, xPageShapes, m_xShapeFactory, m_xChartModel
, aRemainingSpace, aPageSize, ALIGN_BOTTOM, bAutoPosition_XTitle );
if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0)
return;
@@ -2506,7 +2568,7 @@ void ChartView::createShapes()
bool bAutoPosition_YTitle = true;
std::auto_ptr<VTitle> apVTitle_Y;
if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 1 ) )
- apVTitle_Y = lcl_createTitle( TitleHelper::getTitle( TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION, m_xChartModel ), xPageShapes, m_xShapeFactory, m_xChartModel
+ apVTitle_Y = lcl_createTitle( TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION, xPageShapes, m_xShapeFactory, m_xChartModel
, aRemainingSpace, aPageSize, ALIGN_LEFT, bAutoPosition_YTitle );
if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0)
return;
@@ -2515,7 +2577,7 @@ void ChartView::createShapes()
bool bAutoPosition_ZTitle = true;
std::auto_ptr<VTitle> apVTitle_Z;
if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 2 ) )
- apVTitle_Z = lcl_createTitle( TitleHelper::getTitle( TitleHelper::Z_AXIS_TITLE, m_xChartModel ), xPageShapes, m_xShapeFactory, m_xChartModel
+ apVTitle_Z = lcl_createTitle( TitleHelper::Z_AXIS_TITLE, xPageShapes, m_xShapeFactory, m_xChartModel
, aRemainingSpace, aPageSize, ALIGN_RIGHT, bAutoPosition_ZTitle );
if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0)
return;
@@ -2527,7 +2589,7 @@ void ChartView::createShapes()
bool bAutoPosition_SecondXTitle = true;
std::auto_ptr<VTitle> apVTitle_SecondX;
if( ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimension, 0 ) )
- apVTitle_SecondX = lcl_createTitle( TitleHelper::getTitle( TitleHelper::SECONDARY_X_AXIS_TITLE, m_xChartModel ), xPageShapes, m_xShapeFactory, m_xChartModel
+ apVTitle_SecondX = lcl_createTitle( TitleHelper::SECONDARY_X_AXIS_TITLE, xPageShapes, m_xShapeFactory, m_xChartModel
, aRemainingSpace, aPageSize, bIsVertical? ALIGN_RIGHT : ALIGN_TOP, bAutoPosition_SecondXTitle );
if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0)
return;
@@ -2536,7 +2598,7 @@ void ChartView::createShapes()
bool bAutoPosition_SecondYTitle = true;
std::auto_ptr<VTitle> apVTitle_SecondY;
if( ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimension, 1 ) )
- apVTitle_SecondY = lcl_createTitle( TitleHelper::getTitle( TitleHelper::SECONDARY_Y_AXIS_TITLE, m_xChartModel ), xPageShapes, m_xShapeFactory, m_xChartModel
+ apVTitle_SecondY = lcl_createTitle( TitleHelper::SECONDARY_Y_AXIS_TITLE, xPageShapes, m_xShapeFactory, m_xChartModel
, aRemainingSpace, aPageSize, bIsVertical? ALIGN_TOP : ALIGN_RIGHT, bAutoPosition_SecondYTitle );
if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0)
return;
@@ -2575,6 +2637,13 @@ void ChartView::createShapes()
lcl_removeEmptyGroupShapes( xPageShapes );
}
+ // #i12587# support for shapes in chart
+ if ( m_pDrawModelWrapper )
+ {
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ m_pDrawModelWrapper->getSdrModel().EnableUndo( TRUE );
+ }
+
#if OSL_DEBUG_LEVEL > 0
clock_t nEnd = clock();
double fDuration =(double(nEnd-nStart)*1000.0)/double(CLOCKS_PER_SEC);
@@ -2597,6 +2666,12 @@ void ChartView::impl_updateView()
if( !m_xChartModel.is() || !m_pDrawModelWrapper )
return;
+ // #i12587# support for shapes in chart
+ if ( m_bSdrViewIsInEditMode )
+ {
+ return;
+ }
+
if( m_bViewDirty && !m_bInViewUpdate )
{
m_bInViewUpdate = true;
@@ -2611,7 +2686,6 @@ void ChartView::impl_updateView()
// /--
::vos::OGuard aSolarGuard( Application::GetSolarMutex());
m_pDrawModelWrapper->lockControllers();
- m_pDrawModelWrapper->updateTablesFromChartModel( m_xChartModel );
// \--
}
@@ -2686,8 +2760,22 @@ void ChartView::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
//#i77362 change notification for changes on additional shapes are missing
if( m_bInViewUpdate )
return;
- if( m_bSdrViewIsInEditMode )
- return;
+
+ // #i12587# support for shapes in chart
+ if ( m_bSdrViewIsInEditMode && m_xChartModel.is() )
+ {
+ uno::Reference< view::XSelectionSupplier > xSelectionSupplier( m_xChartModel->getCurrentController(), uno::UNO_QUERY );
+ if ( xSelectionSupplier.is() )
+ {
+ ::rtl::OUString aSelObjCID;
+ uno::Any aSelObj( xSelectionSupplier->getSelection() );
+ aSelObj >>= aSelObjCID;
+ if ( aSelObjCID.getLength() > 0 )
+ {
+ return;
+ }
+ }
+ }
const SdrHint* pSdrHint = dynamic_cast< const SdrHint* >(&rHint);
if( !pSdrHint )
@@ -2708,6 +2796,9 @@ void ChartView::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
case HINT_MODELCLEARED:
bShapeChanged = true;
break;
+ case HINT_ENDEDIT:
+ bShapeChanged = true;
+ break;
default:
break;
}
@@ -2879,6 +2970,88 @@ void SAL_CALL ChartView::removeVetoableChangeListener( const ::rtl::OUString& /*
OSL_ENSURE(false,"not implemented");
}
+// ____ XMultiServiceFactory ____
+
+Reference< uno::XInterface > ChartView::createInstance( const ::rtl::OUString& aServiceSpecifier )
+ throw (uno::Exception, uno::RuntimeException)
+{
+ SdrModel* pModel = ( m_pDrawModelWrapper ? &m_pDrawModelWrapper->getSdrModel() : NULL );
+ if ( pModel )
+ {
+ if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.DashTable" ) ) == 0 )
+ {
+ if ( !m_xDashTable.is() )
+ {
+ m_xDashTable = SvxUnoDashTable_createInstance( pModel );
+ }
+ return m_xDashTable;
+ }
+ else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.GradientTable" ) ) == 0 )
+ {
+ if ( !m_xGradientTable.is() )
+ {
+ m_xGradientTable = SvxUnoGradientTable_createInstance( pModel );
+ }
+ return m_xGradientTable;
+ }
+ else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.HatchTable" ) ) == 0 )
+ {
+ if ( !m_xHatchTable.is() )
+ {
+ m_xHatchTable = SvxUnoHatchTable_createInstance( pModel );
+ }
+ return m_xHatchTable;
+ }
+ else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.BitmapTable" ) ) == 0 )
+ {
+ if ( !m_xBitmapTable.is() )
+ {
+ m_xBitmapTable = SvxUnoBitmapTable_createInstance( pModel );
+ }
+ return m_xBitmapTable;
+ }
+ else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.TransparencyGradientTable" ) ) == 0 )
+ {
+ if ( !m_xTransGradientTable.is() )
+ {
+ m_xTransGradientTable = SvxUnoTransGradientTable_createInstance( pModel );
+ }
+ return m_xTransGradientTable;
+ }
+ else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.MarkerTable" ) ) == 0 )
+ {
+ if ( !m_xMarkerTable.is() )
+ {
+ m_xMarkerTable = SvxUnoMarkerTable_createInstance( pModel );
+ }
+ return m_xMarkerTable;
+ }
+ }
+
+ return 0;
+}
+
+Reference< uno::XInterface > ChartView::createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const uno::Sequence< uno::Any >& Arguments )
+ throw (uno::Exception, uno::RuntimeException)
+{
+ OSL_ENSURE( Arguments.getLength(), "ChartView::createInstanceWithArguments: arguments are ignored" );
+ (void) Arguments; // avoid warning
+ return createInstance( ServiceSpecifier );
+}
+
+uno::Sequence< ::rtl::OUString > ChartView::getAvailableServiceNames() throw (uno::RuntimeException)
+{
+ uno::Sequence< ::rtl::OUString > aServiceNames( 6 );
+
+ aServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.DashTable" ) );
+ aServiceNames[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GradientTable" ) );
+ aServiceNames[2] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.HatchTable" ) );
+ aServiceNames[3] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.BitmapTable" ) );
+ aServiceNames[4] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.TransparencyGradientTable" ) );
+ aServiceNames[5] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.MarkerTable" ) );
+
+ return aServiceNames;
+}
//.............................................................................
} //namespace chart
diff --git a/chart2/source/view/main/ChartView.hxx b/chart2/source/view/main/ChartView.hxx
index 706dd4548940..f56da298c5df 100644
--- a/chart2/source/view/main/ChartView.hxx
+++ b/chart2/source/view/main/ChartView.hxx
@@ -29,7 +29,7 @@
#include "chartview/ExplicitValueProvider.hxx"
#include "ServiceMacros.hxx"
-#include <cppuhelper/implbase8.hxx>
+#include <cppuhelper/implbase9.hxx>
#include <cppuhelper/interfacecontainer.hxx>
// header for class SfxListener
@@ -69,7 +69,7 @@ The view than changes to state dirty. The view can be updated with call 'update'
The View is not responsible to handle single user events (that is instead done by the ChartWindow).
*/
-class ChartView : public ::cppu::WeakImplHelper8<
+class ChartView : public ::cppu::WeakImplHelper9<
::com::sun::star::lang::XInitialization
, ::com::sun::star::lang::XServiceInfo
, ::com::sun::star::datatransfer::XTransferable
@@ -82,6 +82,7 @@ class ChartView : public ::cppu::WeakImplHelper8<
,::com::sun::star::util::XModeChangeBroadcaster
,::com::sun::star::util::XUpdatable
,::com::sun::star::beans::XPropertySet
+ ,::com::sun::star::lang::XMultiServiceFactory
>
, public ExplicitValueProvider
, private SfxListener
@@ -163,6 +164,15 @@ public:
virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ //-----------------------------------------------------------------
+ // ::com::sun::star::lang::XMultiServiceFactory
+ //-----------------------------------------------------------------
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( const ::rtl::OUString& aServiceSpecifier )
+ throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments(
+ const ::rtl::OUString& ServiceSpecifier, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments )
+ throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableServiceNames() throw (::com::sun::star::uno::RuntimeException);
// for ExplicitValueProvider
// ____ XUnoTunnel ___
@@ -206,6 +216,13 @@ private: //member
::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage>
m_xDrawPage;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xDashTable;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xGradientTable;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xHatchTable;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xBitmapTable;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xTransGradientTable;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xMarkerTable;
+
::boost::shared_ptr< DrawModelWrapper > m_pDrawModelWrapper;
std::vector< VCoordinateSystem* > m_aVCooSysList;
diff --git a/chart2/source/view/main/DrawModelWrapper.cxx b/chart2/source/view/main/DrawModelWrapper.cxx
index 81e0e94736ce..577f450172b5 100644
--- a/chart2/source/view/main/DrawModelWrapper.cxx
+++ b/chart2/source/view/main/DrawModelWrapper.cxx
@@ -131,7 +131,7 @@ DrawModelWrapper::DrawModelWrapper(
SetScaleUnit(MAP_100TH_MM);
SetScaleFraction(Fraction(1, 1));
- SetDefaultFontHeight(847); // 24pt
+ SetDefaultFontHeight(423); // 12pt
SfxItemPool* pMasterPool = &GetItemPool();
pMasterPool->SetDefaultMetric(SFX_MAPUNIT_100TH_MM);
@@ -390,77 +390,6 @@ SdrObject* DrawModelWrapper::getNamedSdrObject( const String& rObjectCID, SdrObj
return 0;
}
-namespace
-{
- void impl_addOrExchangeElements( const uno::Reference< uno::XInterface >& xSource
- , const uno::Reference< uno::XInterface >& xTarget )
- {
- uno::Reference< container::XNameContainer > xSourceContainer( xSource, uno::UNO_QUERY );
- uno::Reference< container::XNameContainer > xTargetContainer( xTarget, uno::UNO_QUERY );
-
- if(!xSourceContainer.is()||!xTargetContainer.is())
- return;
-
- try
- {
- //put each element of xSourceContainer to xTargetContainer
- uno::Sequence< rtl::OUString > aNames( xSourceContainer->getElementNames() );
- for( sal_Int32 nN = aNames.getLength(); nN--; )
- {
- rtl::OUString aName(aNames[nN]);
- uno::Any aNewValue( xSourceContainer->getByName( aName ) );
- if( xTargetContainer->hasByName(aName) )
- {
- uno::Any aOldValue( xTargetContainer->getByName( aName ) );
- if( aOldValue != aNewValue )
- xTargetContainer->replaceByName(aName,aNewValue);
- }
- else
- xTargetContainer->insertByName( aName, aNewValue );
- }
- }
- catch( const uno::Exception & ex )
- {
- ASSERT_EXCEPTION( ex );
- }
- }
-}
-
-void DrawModelWrapper::updateTablesFromChartModel( const uno::Reference< frame::XModel >& xChartModel )
-{
- //all gradients, etc contained in the model need to be offered fot the view and GUI also:
-
- DBG_ASSERT( xChartModel.is(),"need a chart model for updateTablesFromChartModel");
- if( !xChartModel.is() )
- return;
-
- uno::Reference< lang::XMultiServiceFactory > xTableFactory( xChartModel, uno::UNO_QUERY );
- DBG_ASSERT( xTableFactory.is(), "new model is expected to implement service factory for gradient table etc" );
- if( !xTableFactory.is() )
- return;
-
- //todo? colorTable...
- //impl_addOrExchangeElements( xTableFactory->createInstance( C2U("com.sun.star.drawing.XXX") )
- // , SvxUnoXColorTable_createInstance( this->GetColorTable() ) );
- impl_addOrExchangeElements( xTableFactory->createInstance( C2U("com.sun.star.drawing.DashTable") )
- , SvxUnoXDashTable_createInstance( this->GetDashList() ) );
- impl_addOrExchangeElements( xTableFactory->createInstance( C2U("com.sun.star.drawing.MarkerTable") )
- , SvxUnoXLineEndTable_createInstance( this->GetLineEndList() ) );
- impl_addOrExchangeElements( xTableFactory->createInstance( C2U("com.sun.star.drawing.GradientTable") )
- , SvxUnoXGradientTable_createInstance( this->GetGradientList() ) );
- impl_addOrExchangeElements( xTableFactory->createInstance( C2U("com.sun.star.drawing.HatchTable") )
- , SvxUnoXHatchTable_createInstance( this->GetHatchList() ) );
- impl_addOrExchangeElements( xTableFactory->createInstance( C2U("com.sun.star.drawing.BitmapTable") )
- , SvxUnoXBitmapTable_createInstance( this->GetBitmapList() ) );
-
- // transparency gradients
- uno::Reference< uno::XInterface > xSource(
- xTableFactory->createInstance( C2U("com.sun.star.drawing.TransparencyGradientTable")));
- uno::Reference< uno::XInterface > xTarget(
- this->getShapeFactory()->createInstance( C2U("com.sun.star.drawing.TransparencyGradientTable")));
- impl_addOrExchangeElements( xSource, xTarget );
-}
-
//static
bool DrawModelWrapper::removeShape( const uno::Reference< drawing::XShape >& xShape )
{
diff --git a/chart2/source/view/main/PropertyMapper.cxx b/chart2/source/view/main/PropertyMapper.cxx
index 68368808f66a..1979582763fa 100644
--- a/chart2/source/view/main/PropertyMapper.cxx
+++ b/chart2/source/view/main/PropertyMapper.cxx
@@ -165,6 +165,14 @@ uno::Any* PropertyMapper::getValuePointer( tAnySequence& rPropValues
return NULL;
}
+uno::Any* PropertyMapper::getValuePointerForLimitedSpace( tAnySequence& rPropValues
+ , const tNameSequence& rPropNames
+ , bool bLimitedHeight)
+{
+ return PropertyMapper::getValuePointer( rPropValues, rPropNames
+ , bLimitedHeight ? C2U("TextMaximumFrameHeight") : C2U("TextMaximumFrameWidth") );
+}
+
/*
//set some properties from service style::CharacterProperties:
//-------- tabpage: Zeichen -----------
@@ -521,7 +529,7 @@ void PropertyMapper::getPreparedTextShapePropertyLists(
// use a line-joint showing the border of thick lines like two rectangles
// filled in between.
- aValueMap[C2U("LineJoint")] <<= drawing::LineJoint_MITER;
+ aValueMap[C2U("LineJoint")] <<= drawing::LineJoint_ROUND;
PropertyMapper::getMultiPropertyListsFromValueMap( rPropNames, rPropValues, aValueMap );
}
diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx
index 0be0c04c18d9..721cabd15d83 100644
--- a/chart2/source/view/main/ShapeFactory.cxx
+++ b/chart2/source/view/main/ShapeFactory.cxx
@@ -67,6 +67,7 @@
#include <algorithm>
using namespace ::com::sun::star;
+using ::com::sun::star::uno::Reference;
//.............................................................................
namespace chart
@@ -268,110 +269,99 @@ uno::Any createPolyPolygon_Cube(
uno::Any createPolyPolygon_Cylinder(
double fHeight
, double fRadius
- , double fRoundedEdge
, sal_Int32& nVerticalSegmentCount )
{
- //@todo consider offset if Height is negative
-
-// DBG_ASSERT(fHeight>0, "The height of a cylinder needs to be > 0");
+ //fHeight may be negative
DBG_ASSERT(fRadius>0, "The radius of a cylinder needs to be > 0");
- DBG_ASSERT(fRoundedEdge>=0, "fRoundedEdge needs to be >= 0");
-
- // always use extra points, so set percent diagonal to 0.4 which is 0% in the UI (old Chart comment)
- if( fRoundedEdge == 0.0 )
- fRoundedEdge = 0.4 / 200.0;
-
-// const double fWidth = fRadius;
-
- fRoundedEdge = 0.0;
- const double fOffset = (fRadius * 2.0 * fRoundedEdge) * 1.05; // increase by 5% for safety
- const bool bRoundEdges = fRoundedEdge && fOffset < fRadius && 2.0 * fOffset < fHeight;
- const sal_Int32 nPointCount = bRoundEdges ? 8 : 4;
- nVerticalSegmentCount = nPointCount-1;
//--------------------------------------
drawing::PolyPolygonShape3D aPP;
- aPP.SequenceX.realloc(1);
- aPP.SequenceY.realloc(1);
- aPP.SequenceZ.realloc(1);
+ nVerticalSegmentCount=1;
+
+ aPP.SequenceX.realloc(3);
+ aPP.SequenceY.realloc(3);
+ aPP.SequenceZ.realloc(3);
drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray();
drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray();
drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray();
- pOuterSequenceX->realloc(nPointCount);
- pOuterSequenceY->realloc(nPointCount);
- pOuterSequenceZ->realloc(nPointCount);
+ pOuterSequenceX->realloc(2);
+ pOuterSequenceY->realloc(2);
+ pOuterSequenceZ->realloc(2);
double* pInnerSequenceX = pOuterSequenceX->getArray();
double* pInnerSequenceY = pOuterSequenceY->getArray();
double* pInnerSequenceZ = pOuterSequenceZ->getArray();
- for(sal_Int32 nN = nPointCount; nN--;)
+ double fY1 = 0.0;
+ double fY2 = fHeight;
+
+ if( fHeight<0.0 )
+ ::std::swap(fY1,fY2);
+
+ //----------------------------
+ for(sal_Int32 nN = 2; nN--;)
*pInnerSequenceZ++ = 0.0;
- if(nPointCount == 4)
- {
- *pInnerSequenceY++ = 0.0;
- *pInnerSequenceY++ = 0.0;
- *pInnerSequenceY++ = fHeight;
- *pInnerSequenceY++ = fHeight;
+ *pInnerSequenceX++ = 0.0;
+ *pInnerSequenceY++ = fY1;
- *pInnerSequenceX++ = 0.0;
- *pInnerSequenceX++ = fRadius;
- *pInnerSequenceX++ = fRadius;
- *pInnerSequenceX++ = 0.0;
- }
- else
- {
- *pInnerSequenceY++ = 0.0; //1.
- *pInnerSequenceY++ = 0.0;
- *pInnerSequenceY++ = 0.0;
- *pInnerSequenceY++ = fOffset;
- *pInnerSequenceY++ = fHeight - fOffset;
- *pInnerSequenceY++ = fHeight; //6.
- *pInnerSequenceY++ = fHeight;
- *pInnerSequenceY++ = fHeight;
+ *pInnerSequenceX++ = fRadius;
+ *pInnerSequenceY++ = fY1;
+ //----------------------------
+
+ pOuterSequenceX++;pOuterSequenceY++;pOuterSequenceZ++;
+ pOuterSequenceX->realloc(2);
+ pOuterSequenceY->realloc(2);
+ pOuterSequenceZ->realloc(2);
+
+ pInnerSequenceX = pOuterSequenceX->getArray();
+ pInnerSequenceY = pOuterSequenceY->getArray();
+ pInnerSequenceZ = pOuterSequenceZ->getArray();
+
+ //----------------------------
+ for(sal_Int32 nN = 2; nN--;)
+ *pInnerSequenceZ++ = 0.0;
+
+ *pInnerSequenceX++ = fRadius;
+ *pInnerSequenceY++ = fY1;
+
+ *pInnerSequenceX++ = fRadius;
+ *pInnerSequenceY++ = fY2;
+ //----------------------------
+
+ pOuterSequenceX++;pOuterSequenceY++;pOuterSequenceZ++;
+ pOuterSequenceX->realloc(2);
+ pOuterSequenceY->realloc(2);
+ pOuterSequenceZ->realloc(2);
+
+ pInnerSequenceX = pOuterSequenceX->getArray();
+ pInnerSequenceY = pOuterSequenceY->getArray();
+ pInnerSequenceZ = pOuterSequenceZ->getArray();
+
+ //----------------------------
+ for(sal_Int32 nN = 2; nN--;)
+ *pInnerSequenceZ++ = 0.0;
+
+ *pInnerSequenceX++ = fRadius;
+ *pInnerSequenceY++ = fY2;
+
+ *pInnerSequenceX++ = 0.0;
+ *pInnerSequenceY++ = fY2;
+ //----------------------------
- *pInnerSequenceX++ = 0.0; //1.
- *pInnerSequenceX++ = fRadius - fOffset;
- *pInnerSequenceX++ = fRadius;
- *pInnerSequenceX++ = fRadius;
- *pInnerSequenceX++ = fRadius;
- *pInnerSequenceX++ = fRadius; //6.
- *pInnerSequenceX++ = fRadius - fOffset;
- *pInnerSequenceX++ = 0.0;
- }
return uno::Any( &aPP, ::getCppuType((const drawing::PolyPolygonShape3D*)0) );
}
-uno::Any createPolyPolygon_Cone(
- double fHeight
- , double fRadius
- , double fTopHeight
- , double fRoundedEdge
+uno::Any createPolyPolygon_Cone( double fHeight, double fRadius, double fTopHeight
, sal_Int32& nVerticalSegmentCount )
{
- //@todo consider offset if Height is negative
-/*
- DBG_ASSERT(fHeight>0, "The height of a cone needs to be > 0");
- DBG_ASSERT(fTopHeight>=0, "The height of the cutted top of a cone needs to be >= 0");
-*/
-
DBG_ASSERT(fRadius>0, "The radius of a cone needs to be > 0");
- DBG_ASSERT(fRoundedEdge>=0, "fRoundedEdge needs to be >= 0");
//for stacked charts we need cones without top -> fTopHeight != 0 resp. bTopless == true
//fTopHeight indicates the high of the cutted top only (not the full height)
-
- // always use extra points, so set percent diagonal to 0.4 which is 0% in the UI (old Chart comment)
- if( fRoundedEdge == 0.0 )
- fRoundedEdge = 0.4 / 200.0;
-
- fRoundedEdge = 0.0;
-
- // ::rtl::math::approxEqual cannot compare to 0.0
bool bTopless = !::rtl::math::approxEqual( fHeight, fHeight + fTopHeight );
double r1= 0.0, r2 = fRadius;
@@ -379,82 +369,69 @@ uno::Any createPolyPolygon_Cone(
// #i63212# fHeight may be negative, fTopHeight is always positive -> use fabs(fHeight)
r1 = fRadius * (fTopHeight)/(fabs(fHeight)+fTopHeight);
- const double fMinimumDimension = ::std::min(r2*2.0,fHeight);
- const double fOffset = (fMinimumDimension * fRoundedEdge) * 1.05; // increase by 5% for safety
- const bool bRoundEdges = fRoundedEdge && fOffset < r2 && 2.0 * fOffset < fHeight
- && ( bTopless ? fOffset < r1 : true );
- sal_Int32 nPointCount = 8;
- if(bTopless)
- {
- if(!bRoundEdges)
- nPointCount = 4;
- }
- else
- {
- if(bRoundEdges)
- nPointCount = 6;
- else
- nPointCount = 3;
- }
- nVerticalSegmentCount = nPointCount-1;
-
- //--------------------------------------
+ nVerticalSegmentCount=1;
drawing::PolyPolygonShape3D aPP;
- aPP.SequenceX.realloc(1);
- aPP.SequenceY.realloc(1);
- aPP.SequenceZ.realloc(1);
+ aPP.SequenceX.realloc(2);
+ aPP.SequenceY.realloc(2);
+ aPP.SequenceZ.realloc(2);
drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray();
drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray();
drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray();
- pOuterSequenceX->realloc(nPointCount);
- pOuterSequenceY->realloc(nPointCount);
- pOuterSequenceZ->realloc(nPointCount);
+ pOuterSequenceX->realloc(2);
+ pOuterSequenceY->realloc(2);
+ pOuterSequenceZ->realloc(2);
double* pInnerSequenceX = pOuterSequenceX->getArray();
double* pInnerSequenceY = pOuterSequenceY->getArray();
double* pInnerSequenceZ = pOuterSequenceZ->getArray();
- for(sal_Int32 nN = nPointCount; nN--;)
- *pInnerSequenceZ++ = 0.0;
+ double fX1 = 0.0;
+ double fX2 = r2;
+ double fX3 = r1;
- if(bTopless)
- {
- *pInnerSequenceY++ = fHeight; //1.
- *pInnerSequenceX++ = 0.0; //1.
+ double fY1 = 0.0;
+ double fY2 = 0.0;
+ double fY3 = fHeight;
- if(bRoundEdges)
- {
- *pInnerSequenceY++ = fHeight; //2.
- *pInnerSequenceX++ = r1 - fOffset; //2.
- }
+ if( fHeight<0.0 )
+ {
+ ::std::swap(fX1,fX3);
+ ::std::swap(fY1,fY3);
}
- *pInnerSequenceY++ = fHeight; //3.
- *pInnerSequenceX++ = r1; //3.
+ //----------------------------
+ for(sal_Int32 nN = 2; nN--;)
+ *pInnerSequenceZ++ = 0.0;
- if(bRoundEdges)
- {
- *pInnerSequenceY++ = fHeight - fOffset; //4.
- *pInnerSequenceX++ = r1 + fOffset; //4.
+ *pInnerSequenceY++ = fY1;
+ *pInnerSequenceX++ = fX1;
- *pInnerSequenceY++ = fOffset; //5.
- *pInnerSequenceX++ = r2 - fOffset; //5.
- }
+ *pInnerSequenceY++ = fY2;
+ *pInnerSequenceX++ = fX2;
+ //----------------------------
- *pInnerSequenceY++ = 0.0; //6.
- *pInnerSequenceX++ = r2; //6.
+ pOuterSequenceX++;pOuterSequenceY++;pOuterSequenceZ++;
+ pOuterSequenceX->realloc(2);
+ pOuterSequenceY->realloc(2);
+ pOuterSequenceZ->realloc(2);
- if(bRoundEdges)
- {
- *pInnerSequenceY++ = 0.0; //7.
- *pInnerSequenceX++ = r2 - fOffset; //7.
- }
+ pInnerSequenceX = pOuterSequenceX->getArray();
+ pInnerSequenceY = pOuterSequenceY->getArray();
+ pInnerSequenceZ = pOuterSequenceZ->getArray();
- *pInnerSequenceY++ = 0.0; //8.
- *pInnerSequenceX++ = 0.0; //8.
+ //----------------------------
+ for(sal_Int32 nN = 2; nN--;)
+ *pInnerSequenceZ++ = 0.0;
+
+ *pInnerSequenceY++ = fY2;
+ *pInnerSequenceX++ = fX2;
+
+ *pInnerSequenceY++ = fY3;
+ *pInnerSequenceX++ = fX3;
+ //----------------------------
return uno::Any( &aPP, ::getCppuType((const drawing::PolyPolygonShape3D*)0) );
}
@@ -567,16 +544,167 @@ uno::Reference<drawing::XShape>
, sal_Int32 nRotateZAngleHundredthDegree )
{
return impl_createConeOrCylinder(
- xTarget, rPosition, rSize, 0.0, nRotateZAngleHundredthDegree, CHART_3DOBJECT_SEGMENTCOUNT, true );
+ xTarget, rPosition, rSize, 0.0, nRotateZAngleHundredthDegree, true );
}
uno::Reference<drawing::XShape>
ShapeFactory::createPyramid(
const uno::Reference<drawing::XShapes>& xTarget
, const drawing::Position3D& rPosition, const drawing::Direction3D& rSize
- , double fTopHeight, sal_Int32 nRotateZAngleHundredthDegree )
+ , double fTopHeight, bool bRotateZ
+ , const uno::Reference< beans::XPropertySet >& xSourceProp
+ , const tPropertyNameMap& rPropertyNameMap )
{
- return impl_createConeOrCylinder( xTarget, rPosition, rSize, fTopHeight, nRotateZAngleHundredthDegree, 4 );
+ if( !xTarget.is() )
+ return 0;
+
+ Reference< drawing::XShapes > xGroup( ShapeFactory::createGroup3D( xTarget, rtl::OUString() ) );
+
+ sal_Bool bDoubleSided = false;
+ short nRotatedTexture = 0;
+
+ const double fWidth = rSize.DirectionX;
+ const double fDepth = rSize.DirectionZ;
+ const double fHeight = rSize.DirectionY;
+
+ drawing::Position3D aBottomP1( rPosition.PositionX, rPosition.PositionY, rPosition.PositionZ - fDepth/2.0 );
+ if(bRotateZ)
+ aBottomP1.PositionY -= fWidth/2.0;
+ else
+ aBottomP1.PositionX -= fWidth/2.0;
+ drawing::Position3D aBottomP2( aBottomP1 );
+ if(bRotateZ)
+ aBottomP2.PositionY += fWidth;
+ else
+ aBottomP2.PositionX += fWidth;
+ drawing::Position3D aBottomP3( aBottomP2 );
+ drawing::Position3D aBottomP4( aBottomP1 );
+ aBottomP3.PositionZ += fDepth;
+ aBottomP4.PositionZ += fDepth;
+
+ const double fTopFactor = (fTopHeight)/(fabs(fHeight)+fTopHeight);
+ drawing::Position3D aTopP1( rPosition.PositionX, rPosition.PositionY, rPosition.PositionZ - fDepth*fTopFactor/2.0 );
+ if(bRotateZ)
+ {
+ aTopP1.PositionY -= fWidth*fTopFactor/2.0;
+ aTopP1.PositionX += fHeight;
+ }
+ else
+ {
+ aTopP1.PositionX -= fWidth*fTopFactor/2.0;
+ aTopP1.PositionY += fHeight;
+ }
+ drawing::Position3D aTopP2( aTopP1 );
+ if(bRotateZ)
+ aTopP2.PositionY += fWidth*fTopFactor;
+ else
+ aTopP2.PositionX += fWidth*fTopFactor;
+ drawing::Position3D aTopP3( aTopP2 );
+ drawing::Position3D aTopP4( aTopP1 );
+ aTopP3.PositionZ += fDepth*fTopFactor;
+ aTopP4.PositionZ += fDepth*fTopFactor;
+
+ Stripe aStripeBottom( aBottomP1, aBottomP4, aBottomP3, aBottomP2 );
+
+ drawing::Position3D aNormalsBottomP1( aBottomP1 );
+ drawing::Position3D aNormalsBottomP2( aBottomP2 );
+ drawing::Position3D aNormalsBottomP3( aBottomP3 );
+ drawing::Position3D aNormalsBottomP4( aBottomP4 );
+ drawing::Position3D aNormalsTopP1( aBottomP1 );
+ drawing::Position3D aNormalsTopP2( aBottomP2 );
+ drawing::Position3D aNormalsTopP3( aBottomP3 );
+ drawing::Position3D aNormalsTopP4( aBottomP4 );
+ if( bRotateZ )
+ {
+ aNormalsTopP1.PositionX += fHeight;
+ aNormalsTopP2.PositionX += fHeight;
+ aNormalsTopP3.PositionX += fHeight;
+ aNormalsTopP4.PositionX += fHeight;
+ }
+ else
+ {
+ aNormalsTopP1.PositionY += fHeight;
+ aNormalsTopP2.PositionY += fHeight;
+ aNormalsTopP3.PositionY += fHeight;
+ aNormalsTopP4.PositionY += fHeight;
+ }
+
+ bool bInvertPolygon = false;
+ bool bInvertNormals = false;
+
+ if(bRotateZ)
+ {
+ //bars
+ if(fHeight>=0.0)
+ {
+ nRotatedTexture = 2;
+ bInvertNormals = true;
+ aStripeBottom = Stripe( aBottomP1, aBottomP4, aBottomP3, aBottomP2 );
+ }
+ else
+ {
+ bInvertPolygon = true;
+ nRotatedTexture = 1;
+ aStripeBottom = Stripe( aBottomP2, aBottomP3, aBottomP4, aBottomP1 );
+ }
+ }
+ else
+ {
+ //columns
+ if(fHeight>=0.0)
+ {
+ bInvertPolygon = true;
+ nRotatedTexture = 2;
+ aStripeBottom = Stripe( aBottomP2, aBottomP3, aBottomP4, aBottomP1 );
+ }
+ else
+ {
+ nRotatedTexture = 3;
+ bInvertNormals = true;
+ aStripeBottom = Stripe( aBottomP4, aBottomP3, aBottomP2, aBottomP1 );
+ }
+ }
+ aStripeBottom.InvertNormal(true);
+
+ Stripe aStripe1( aTopP2, aTopP1, aBottomP1, aBottomP2 );
+ Stripe aStripe2( aTopP3, aTopP2, aBottomP2, aBottomP3 );
+ Stripe aStripe3( aTopP4, aTopP3, aBottomP3, aBottomP4 );
+ Stripe aStripe4( aTopP1, aTopP4, aBottomP4, aBottomP1 );
+
+ if( bInvertPolygon )
+ {
+ aStripe1 = Stripe( aBottomP1, aTopP1, aTopP2, aBottomP2 );
+ aStripe2 = Stripe( aBottomP2, aTopP2, aTopP3, aBottomP3 );
+ aStripe3 = Stripe( aBottomP3, aTopP3, aTopP4, aBottomP4 );
+ aStripe4 = Stripe( aBottomP4, aTopP4, aTopP1, aBottomP1 );
+ }
+
+ Stripe aNormalsStripe1( aNormalsTopP1, aNormalsBottomP1, aNormalsBottomP2, aNormalsTopP2 );
+ Stripe aNormalsStripe2( aNormalsTopP2, aNormalsBottomP2, aNormalsBottomP3, aNormalsTopP3 );
+ Stripe aNormalsStripe3( aNormalsTopP3, aNormalsBottomP3, aNormalsBottomP4, aNormalsTopP4 );
+ Stripe aNormalsStripe4( aNormalsTopP4, aNormalsBottomP4, aNormalsBottomP1, aNormalsTopP1 );
+
+ if( bInvertNormals )
+ {
+ aNormalsStripe1 = Stripe( aNormalsTopP2, aNormalsBottomP2, aNormalsBottomP1, aNormalsTopP1 );
+ aNormalsStripe2 = Stripe( aNormalsTopP3, aNormalsBottomP3, aNormalsBottomP2, aNormalsTopP2 );
+ aNormalsStripe3 = Stripe( aNormalsTopP4, aNormalsBottomP4, aNormalsBottomP3, aNormalsTopP3 );
+ aNormalsStripe4 = Stripe( aNormalsTopP1, aNormalsBottomP1, aNormalsBottomP4, aNormalsTopP4 );
+ }
+
+ aStripe1.SetManualNormal( aNormalsStripe1.getNormal() );
+ aStripe2.SetManualNormal( aNormalsStripe2.getNormal() );
+ aStripe3.SetManualNormal( aNormalsStripe3.getNormal() );
+ aStripe4.SetManualNormal( aNormalsStripe4.getNormal() );
+
+ const bool bFlatNormals = false;
+ ShapeFactory::createStripe( xGroup, aStripe1, xSourceProp, rPropertyNameMap, bDoubleSided, nRotatedTexture, bFlatNormals );
+ ShapeFactory::createStripe( xGroup, aStripe2, xSourceProp, rPropertyNameMap, bDoubleSided, nRotatedTexture, bFlatNormals );
+ ShapeFactory::createStripe( xGroup, aStripe3, xSourceProp, rPropertyNameMap, bDoubleSided, nRotatedTexture, bFlatNormals );
+ ShapeFactory::createStripe( xGroup, aStripe4, xSourceProp, rPropertyNameMap, bDoubleSided, nRotatedTexture, bFlatNormals );
+ ShapeFactory::createStripe( xGroup, aStripeBottom, xSourceProp, rPropertyNameMap, bDoubleSided, nRotatedTexture, bFlatNormals );
+
+ return Reference< drawing::XShape >( xGroup, uno::UNO_QUERY );
}
uno::Reference<drawing::XShape>
@@ -585,7 +713,7 @@ uno::Reference<drawing::XShape>
, const drawing::Position3D& rPosition, const drawing::Direction3D& rSize
, double fTopHeight, sal_Int32 nRotateZAngleHundredthDegree )
{
- return impl_createConeOrCylinder( xTarget, rPosition, rSize, fTopHeight, nRotateZAngleHundredthDegree, CHART_3DOBJECT_SEGMENTCOUNT );
+ return impl_createConeOrCylinder( xTarget, rPosition, rSize, fTopHeight, nRotateZAngleHundredthDegree );
}
uno::Reference<drawing::XShape>
@@ -593,7 +721,6 @@ uno::Reference<drawing::XShape>
const uno::Reference<drawing::XShapes>& xTarget
, const drawing::Position3D& rPosition, const drawing::Direction3D& rSize
, double fTopHeight, sal_Int32 nRotateZAngleHundredthDegree
- , sal_Int32 nSegments
, bool bCylinder )
{
if( !xTarget.is() )
@@ -605,19 +732,8 @@ uno::Reference<drawing::XShape>
"com.sun.star.drawing.Shape3DLatheObject") ), uno::UNO_QUERY );
xTarget->add(xShape);
-
- double fYRotateAnglePi = -ZDIRECTION*(F_PI/2.0 - F_PI/(double)nSegments); // alwayas rotate edge to front (important for pyramids)
- //or: ZDIRECTION*(F_PI/2.0 - F_PI/(double)nSegments); // rotate edge to front for even segment count otherwise rotate corner to front
- double fAngle = fYRotateAnglePi;
- {
- while(fAngle<0.0)
- fAngle+=F_PI/2.0;
- while(fAngle>F_PI/2.0)
- fAngle-=F_PI/2.0;
- }
double fWidth = rSize.DirectionX/2.0; //The depth will be corrrected within Matrix
double fRadius = fWidth; //!!!!!!!! problem in drawing layer: rotation object calculates wrong needed size -> wrong camera (it's a problem with bounding boxes)
-// double fRadius = fWidth/cos(fAngle); llllllllllllllllllll
double fHeight = rSize.DirectionY;
//set properties
@@ -635,15 +751,14 @@ uno::Reference<drawing::XShape>
//Polygon
sal_Int32 nVerticalSegmentCount = 0;
uno::Any aPPolygon = bCylinder ? createPolyPolygon_Cylinder(
- fHeight, fRadius, double(nPercentDiagonal)/200.0, nVerticalSegmentCount)
+ fHeight, fRadius, nVerticalSegmentCount)
: createPolyPolygon_Cone(
- fHeight, fRadius, fTopHeight, double(nPercentDiagonal)/200.0, nVerticalSegmentCount);
+ fHeight, fRadius, fTopHeight, nVerticalSegmentCount);
xProp->setPropertyValue( C2U( UNO_NAME_3D_POLYPOLYGON3D ), aPPolygon );
//Matrix for position
{
::basegfx::B3DHomMatrix aM;
- //aM.RotateY( fYRotateAnglePi );
if(nRotateZAngleHundredthDegree!=0)
aM.rotate(0.0,0.0,-nRotateZAngleHundredthDegree/18000.00*F_PI);
//stretch the symmetric objects to given depth
@@ -656,7 +771,7 @@ uno::Reference<drawing::XShape>
//Segments
xProp->setPropertyValue( C2U( UNO_NAME_3D_HORZ_SEGS )
- , uno::makeAny(nSegments) );
+ , uno::makeAny(CHART_3DOBJECT_SEGMENTCOUNT) );
xProp->setPropertyValue( C2U( UNO_NAME_3D_VERT_SEGS )
, uno::makeAny((sal_Int32)nVerticalSegmentCount) );//depends on point count of the used polygon
@@ -1021,7 +1136,8 @@ uno::Reference< drawing::XShape >
, const uno::Reference< beans::XPropertySet >& xSourceProp
, const tPropertyNameMap& rPropertyNameMap
, sal_Bool bDoubleSided
- , bool bRotatedTexture )
+ , short nRotatedTexture
+ , bool bFlatNormals )
{
if( !xTarget.is() )
return 0;
@@ -1045,16 +1161,15 @@ uno::Reference< drawing::XShape >
//TexturePolygon
xProp->setPropertyValue( C2U( UNO_NAME_3D_TEXTUREPOLYGON3D )
- , rStripe.getTexturePolygon( bRotatedTexture ) );
-
+ , rStripe.getTexturePolygon( nRotatedTexture ) );
//Normals Polygon
xProp->setPropertyValue( C2U( UNO_NAME_3D_NORMALSPOLYGON3D )
, rStripe.getNormalsPolygon() );
-
//NormalsKind
- xProp->setPropertyValue( C2U( UNO_NAME_3D_NORMALS_KIND )
- , uno::makeAny( drawing::NormalsKind_FLAT ) );
+ if(bFlatNormals)
+ xProp->setPropertyValue( C2U( UNO_NAME_3D_NORMALS_KIND )
+ , uno::makeAny( drawing::NormalsKind_FLAT ) );
//LineOnly
xProp->setPropertyValue( C2U( UNO_NAME_3D_LINEONLY )
diff --git a/chart2/source/view/main/Stripe.cxx b/chart2/source/view/main/Stripe.cxx
index 7f282e3d5559..2df78e2a8e91 100644
--- a/chart2/source/view/main/Stripe.cxx
+++ b/chart2/source/view/main/Stripe.cxx
@@ -48,8 +48,9 @@ Stripe::Stripe( const drawing::Position3D& rPoint1
, m_aPoint2(rPoint1+rDirectionToPoint2)
, m_aPoint3(m_aPoint2+rDirectionToPoint4)
, m_aPoint4(rPoint1+rDirectionToPoint4)
+ , m_bInvertNormal(false)
+ , m_bManualNormalSet(false)
{
-
}
Stripe::Stripe( const drawing::Position3D& rPoint1
@@ -59,12 +60,13 @@ Stripe::Stripe( const drawing::Position3D& rPoint1
, m_aPoint2(rPoint2)
, m_aPoint3(rPoint2)
, m_aPoint4(rPoint1)
+ , m_bInvertNormal(false)
+ , m_bManualNormalSet(false)
{
m_aPoint3.PositionZ += fDepth;
m_aPoint4.PositionZ += fDepth;
}
-/*
Stripe::Stripe( const drawing::Position3D& rPoint1
, const drawing::Position3D& rPoint2
, const drawing::Position3D& rPoint3
@@ -73,10 +75,21 @@ Stripe::Stripe( const drawing::Position3D& rPoint1
, m_aPoint2(rPoint2)
, m_aPoint3(rPoint3)
, m_aPoint4(rPoint4)
+ , m_bInvertNormal(false)
+ , m_bManualNormalSet(false)
+{
+}
+
+void Stripe::SetManualNormal( const drawing::Direction3D& rNormal )
{
+ m_aManualNormal = rNormal;
+ m_bManualNormalSet = true;
+}
+void Stripe::InvertNormal( bool bInvertNormal )
+{
+ m_bInvertNormal = bInvertNormal;
}
-*/
uno::Any Stripe::getPolyPolygonShape3D() const
{
@@ -119,12 +132,28 @@ uno::Any Stripe::getPolyPolygonShape3D() const
drawing::Direction3D Stripe::getNormal() const
{
- ::basegfx::B3DPolygon aPolygon3D;
- aPolygon3D.append(Position3DToB3DPoint( m_aPoint1 ));
- aPolygon3D.append(Position3DToB3DPoint( m_aPoint2 ));
- aPolygon3D.append(Position3DToB3DPoint( m_aPoint3 ));
- ::basegfx::B3DVector aNormal(::basegfx::tools::getNormal(aPolygon3D));
- return B3DVectorToDirection3D(aNormal);
+ drawing::Direction3D aRet(1.0,0.0,0.0);
+
+ if( m_bManualNormalSet )
+ aRet = m_aManualNormal;
+ else
+ {
+ ::basegfx::B3DPolygon aPolygon3D;
+ aPolygon3D.append(Position3DToB3DPoint( m_aPoint1 ));
+ aPolygon3D.append(Position3DToB3DPoint( m_aPoint2 ));
+ aPolygon3D.append(Position3DToB3DPoint( m_aPoint3 ));
+ aPolygon3D.append(Position3DToB3DPoint( m_aPoint4 ));
+ ::basegfx::B3DVector aNormal(::basegfx::tools::getNormal(aPolygon3D));
+ aRet = B3DVectorToDirection3D(aNormal);
+ }
+
+ if( m_bInvertNormal )
+ {
+ aRet.DirectionX *= -1.0;
+ aRet.DirectionY *= -1.0;
+ aRet.DirectionZ *= -1.0;
+ }
+ return aRet;
}
uno::Any Stripe::getNormalsPolygon() const
@@ -158,7 +187,7 @@ uno::Any Stripe::getNormalsPolygon() const
return uno::Any( &aPP, ::getCppuType((const drawing::PolyPolygonShape3D*)0) );
}
-uno::Any Stripe::getTexturePolygon( bool bRotatedTexture ) const
+uno::Any Stripe::getTexturePolygon( short nRotatedTexture ) const
{
drawing::PolyPolygonShape3D aPP;
@@ -178,26 +207,124 @@ uno::Any Stripe::getTexturePolygon( bool bRotatedTexture ) const
double* pInnerSequenceY = pOuterSequenceY->getArray();
double* pInnerSequenceZ = pOuterSequenceZ->getArray();
- if( !bRotatedTexture )
+ if( nRotatedTexture==0 )
{
*pInnerSequenceX++ = 0.0;
*pInnerSequenceY++ = 0.0;
*pInnerSequenceZ++ = 0.0;
+ *pInnerSequenceX++ = 0.0;
+ *pInnerSequenceY++ = 1.0;
+ *pInnerSequenceZ++ = 0.0;
+
+ *pInnerSequenceX++ = 1.0;
+ *pInnerSequenceY++ = 1.0;
+ *pInnerSequenceZ++ = 0.0;
+
+ *pInnerSequenceX++ = 1.0;
+ *pInnerSequenceY++ = 0.0;
+ *pInnerSequenceZ++ = 0.0;
+ }
+ else if( nRotatedTexture==1 )
+ {
*pInnerSequenceX++ = 1.0;
*pInnerSequenceY++ = 0.0;
*pInnerSequenceZ++ = 0.0;
+ *pInnerSequenceX++ = 0.0;
+ *pInnerSequenceY++ = 0.0;
+ *pInnerSequenceZ++ = 0.0;
+
+ *pInnerSequenceX++ = 0.0;
+ *pInnerSequenceY++ = 1.0;
+ *pInnerSequenceZ++ = 0.0;
+
+ *pInnerSequenceX++ = 1.0;
+ *pInnerSequenceY++ = 1.0;
+ *pInnerSequenceZ++ = 0.0;
+ }
+ else if( nRotatedTexture==2 )
+ {
*pInnerSequenceX++ = 1.0;
*pInnerSequenceY++ = 1.0;
*pInnerSequenceZ++ = 0.0;
+ *pInnerSequenceX++ = 1.0;
+ *pInnerSequenceY++ = 0.0;
+ *pInnerSequenceZ++ = 0.0;
+
+ *pInnerSequenceX++ = 0.0;
+ *pInnerSequenceY++ = 0.0;
+ *pInnerSequenceZ++ = 0.0;
+
*pInnerSequenceX++ = 0.0;
*pInnerSequenceY++ = 1.0;
*pInnerSequenceZ++ = 0.0;
}
- else
+ else if( nRotatedTexture==3 )
+ {
+ *pInnerSequenceX++ = 0.0;
+ *pInnerSequenceY++ = 1.0;
+ *pInnerSequenceZ++ = 0.0;
+
+ *pInnerSequenceX++ = 1.0;
+ *pInnerSequenceY++ = 1.0;
+ *pInnerSequenceZ++ = 0.0;
+
+ *pInnerSequenceX++ = 1.0;
+ *pInnerSequenceY++ = 0.0;
+ *pInnerSequenceZ++ = 0.0;
+
+ *pInnerSequenceX++ = 0.0;
+ *pInnerSequenceY++ = 0.0;
+ *pInnerSequenceZ++ = 0.0;
+ }
+ else if( nRotatedTexture==4 )
+ {
+ *pInnerSequenceX++ = 1.0;
+ *pInnerSequenceY++ = 0.0;
+ *pInnerSequenceZ++ = 0.0;
+
+ *pInnerSequenceX++ = 1.0;
+ *pInnerSequenceY++ = 1.0;
+ *pInnerSequenceZ++ = 0.0;
+
+ *pInnerSequenceX++ = 0.0;
+ *pInnerSequenceY++ = 1.0;
+ *pInnerSequenceZ++ = 0.0;
+
+ *pInnerSequenceX++ = 0.0;
+ *pInnerSequenceY++ = 0.0;
+ *pInnerSequenceZ++ = 0.0;
+ }
+ else if( nRotatedTexture==5 )
+ {
+ *pInnerSequenceX++ = 0.0;
+ *pInnerSequenceY++ = 0.0;
+ *pInnerSequenceZ++ = 0.0;
+
+ *pInnerSequenceX++ = 1.0;
+ *pInnerSequenceY++ = 0.0;
+ *pInnerSequenceZ++ = 0.0;
+
+ *pInnerSequenceX++ = 1.0;
+ *pInnerSequenceY++ = 1.0;
+ *pInnerSequenceZ++ = 0.0;
+
+ *pInnerSequenceX++ = 0.0;
+ *pInnerSequenceY++ = 1.0;
+ *pInnerSequenceZ++ = 0.0;
+ }
+ else if( nRotatedTexture==6 )
{
+ *pInnerSequenceX++ = 0.0;
+ *pInnerSequenceY++ = 1.0;
+ *pInnerSequenceZ++ = 0.0;
+
+ *pInnerSequenceX++ = 0.0;
+ *pInnerSequenceY++ = 0.0;
+ *pInnerSequenceZ++ = 0.0;
+
*pInnerSequenceX++ = 1.0;
*pInnerSequenceY++ = 0.0;
*pInnerSequenceZ++ = 0.0;
@@ -205,6 +332,12 @@ uno::Any Stripe::getTexturePolygon( bool bRotatedTexture ) const
*pInnerSequenceX++ = 1.0;
*pInnerSequenceY++ = 1.0;
*pInnerSequenceZ++ = 0.0;
+ }
+ else if( nRotatedTexture==7 )
+ {
+ *pInnerSequenceX++ = 1.0;
+ *pInnerSequenceY++ = 1.0;
+ *pInnerSequenceZ++ = 0.0;
*pInnerSequenceX++ = 0.0;
*pInnerSequenceY++ = 1.0;
@@ -213,6 +346,10 @@ uno::Any Stripe::getTexturePolygon( bool bRotatedTexture ) const
*pInnerSequenceX++ = 0.0;
*pInnerSequenceY++ = 0.0;
*pInnerSequenceZ++ = 0.0;
+
+ *pInnerSequenceX++ = 1.0;
+ *pInnerSequenceY++ = 0.0;
+ *pInnerSequenceZ++ = 0.0;
}
return uno::Any( &aPP, ::getCppuType((const drawing::PolyPolygonShape3D*)0) );
diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx
index c94193c5a7c8..8bb6a11b4baf 100644
--- a/chart2/source/view/main/VDataSeries.cxx
+++ b/chart2/source/view/main/VDataSeries.cxx
@@ -734,10 +734,10 @@ double VDataSeries::getYMeanValue() const
{
if( xProp->getPropertyValue( C2U( "Symbol" ) ) >>= *apSymbolProps )
{
- // border of symbols always black
- apSymbolProps->BorderColor = 0x000000;
//use main color to fill symbols
xProp->getPropertyValue( C2U( "Color" ) ) >>= apSymbolProps->FillColor;
+ // border of symbols always same as fill color
+ apSymbolProps->BorderColor = apSymbolProps->FillColor;
}
else
apSymbolProps.reset();
diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx
index 1b6abd9bb812..f0bcc12c0440 100644
--- a/chart2/source/view/main/VLegend.cxx
+++ b/chart2/source/view/main/VLegend.cxx
@@ -258,10 +258,11 @@ void lcl_placeLegendEntries(
double fViewFontSize = lcl_CalcViewFontSize( xProperties, rPageSize );
// padding as percentage of the font height
- double fXPadding = (1.0 / 5.0);
- double fYPadding = (1.0 / 3.0);
- double fXOffset = (1.0 / 5.0);
- double fYOffset = (1.0 / 5.0);
+ // #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 );
@@ -273,8 +274,11 @@ void lcl_placeLegendEntries(
rEntries, xShapeFactory, xTarget, aTextShapes, rTextProperties );
OSL_ASSERT( aTextShapes.size() == rEntries.size());
- awt::Size aMaxSymbolExtent( static_cast< sal_Int32 >( fViewFontSize * 3.0 / 2.0 ),
- static_cast< sal_Int32 >( fViewFontSize ));
+ // #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;
@@ -391,8 +395,13 @@ void lcl_placeLegendEntries(
sal_Int32 nSymbolXPos = nCurrentXPos + ((aMaxSymbolExtent.Width - aSymbolSize.Width) / 2);
if( !bSymbolsLeftSide )
nSymbolXPos = nSymbolXPos - aMaxSymbolExtent.Width;
- xSymbol->setPosition( awt::Point( nSymbolXPos,
- nCurrentYPos + ((aMaxSymbolExtent.Height - aSymbolSize.Height) / 2)));
+
+ // #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 );
+ xSymbol->setPosition( awt::Point( nSymbolXPos, nSymbolYPos ) );
}
// position text shape
@@ -435,37 +444,60 @@ void lcl_placeLegendEntries(
rOutLegendSize.Height = nMaxYPos + nYPadding;
}
-double lcl_getPageLayoutDistancePercentage()
+// #i109336# Improve auto positioning in chart
+sal_Int32 lcl_getLegendLeftRightMargin()
{
- return 0.02;
+ return 210; // 1/100 mm
+}
+
+// #i109336# Improve auto positioning in chart
+sal_Int32 lcl_getLegendTopBottomMargin()
+{
+ return 185; // 1/100 mm
}
chart2::RelativePosition lcl_getDefaultPosition( LegendPosition ePos, const awt::Rectangle& rOutAvailableSpace, const awt::Size & rPageSize )
{
- // shift legend about 2% of page size into the primary direction by default
- const double fDefaultDistance = lcl_getPageLayoutDistancePercentage();
chart2::RelativePosition aResult;
switch( ePos )
{
case LegendPosition_LINE_START:
- aResult = chart2::RelativePosition(
- fDefaultDistance, 0.5, drawing::Alignment_LEFT );
+ {
+ // #i109336# Improve auto positioning in chart
+ const double fDefaultDistance = ( static_cast< double >( lcl_getLegendLeftRightMargin() ) /
+ static_cast< double >( rPageSize.Width ) );
+ aResult = chart2::RelativePosition(
+ fDefaultDistance, 0.5, drawing::Alignment_LEFT );
+ }
break;
case LegendPosition_LINE_END:
- aResult = chart2::RelativePosition(
- 1.0 - fDefaultDistance, 0.5, drawing::Alignment_RIGHT );
+ {
+ // #i109336# Improve auto positioning in chart
+ const double fDefaultDistance = ( static_cast< double >( lcl_getLegendLeftRightMargin() ) /
+ static_cast< double >( rPageSize.Width ) );
+ aResult = chart2::RelativePosition(
+ 1.0 - fDefaultDistance, 0.5, drawing::Alignment_RIGHT );
+ }
break;
case LegendPosition_PAGE_START:
{
+ // #i109336# Improve auto positioning in chart
+ const double fDefaultDistance = ( static_cast< double >( lcl_getLegendTopBottomMargin() ) /
+ static_cast< double >( rPageSize.Height ) );
double fDistance = (static_cast<double>(rOutAvailableSpace.Y)/static_cast<double>(rPageSize.Height)) + fDefaultDistance;
aResult = chart2::RelativePosition(
0.5, fDistance, drawing::Alignment_TOP );
}
break;
case LegendPosition_PAGE_END:
- aResult = chart2::RelativePosition(
- 0.5, 1.0 - fDefaultDistance, drawing::Alignment_BOTTOM );
+ {
+ // #i109336# Improve auto positioning in chart
+ const double fDefaultDistance = ( static_cast< double >( lcl_getLegendTopBottomMargin() ) /
+ static_cast< double >( rPageSize.Height ) );
+ aResult = chart2::RelativePosition(
+ 0.5, 1.0 - fDefaultDistance, drawing::Alignment_BOTTOM );
+ }
break;
case LegendPosition_CUSTOM:
@@ -498,31 +530,34 @@ awt::Point lcl_calculatePositionAndRemainingSpace(
aResult, aLegendSize, aRelPos.Anchor );
// adapt rRemainingSpace if LegendPosition is not CUSTOM
- sal_Int32 nYDistance = static_cast<sal_Int32>(rPageSize.Height*lcl_getPageLayoutDistancePercentage());
- sal_Int32 nXDistance = static_cast<sal_Int32>(rPageSize.Width*lcl_getPageLayoutDistancePercentage());
- rRemainingSpace.Width-=nXDistance;
- rRemainingSpace.Height-=nYDistance;
+ // #i109336# Improve auto positioning in chart
+ sal_Int32 nXDistance = lcl_getLegendLeftRightMargin();
+ sal_Int32 nYDistance = lcl_getLegendTopBottomMargin();
switch( ePos )
{
case LegendPosition_LINE_START:
- {
- sal_Int32 nExtent = aLegendSize.Width;
- rRemainingSpace.Width -= nExtent;
- rRemainingSpace.X += ( nExtent + nXDistance );
- }
+ {
+ sal_Int32 nExtent = aLegendSize.Width;
+ rRemainingSpace.Width -= ( nExtent + nXDistance );
+ rRemainingSpace.X += ( nExtent + nXDistance );
+ }
break;
case LegendPosition_LINE_END:
- rRemainingSpace.Width -= ( aLegendSize.Width );
+ {
+ rRemainingSpace.Width -= ( aLegendSize.Width + nXDistance );
+ }
break;
case LegendPosition_PAGE_START:
- {
- sal_Int32 nExtent = aLegendSize.Height;
- rRemainingSpace.Height -= nExtent;
- rRemainingSpace.Y += ( nExtent + nYDistance );
- }
+ {
+ sal_Int32 nExtent = aLegendSize.Height;
+ rRemainingSpace.Height -= ( nExtent + nYDistance );
+ rRemainingSpace.Y += ( nExtent + nYDistance );
+ }
break;
case LegendPosition_PAGE_END:
- rRemainingSpace.Height -= ( aLegendSize.Height );
+ {
+ rRemainingSpace.Height -= ( aLegendSize.Height + nYDistance );
+ }
break;
default:
@@ -672,8 +707,9 @@ void VLegend::createShapes(
tPropertyValues aLineFillProperties;
tPropertyValues aTextProperties;
- // limit the width of texts to 20% of the total available width
- sal_Int32 nMaxLabelWidth = rAvailableSpace.Width / 5;
+ // 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;
if( xLegendProp.is())
diff --git a/chart2/source/view/main/VLegendSymbolFactory.cxx b/chart2/source/view/main/VLegendSymbolFactory.cxx
index 682ff7fb7a5b..958a8defe0b6 100644
--- a/chart2/source/view/main/VLegendSymbolFactory.cxx
+++ b/chart2/source/view/main/VLegendSymbolFactory.cxx
@@ -85,6 +85,16 @@ void lcl_setPropetiesToShape(
::chart::tNameSequence aPropNames;
::chart::tAnySequence aPropValues;
::chart::PropertyMapper::getMultiPropertyListsFromValueMap( aPropNames, aPropValues, aValueMap );
+
+ uno::Any* pLineWidthAny = ::chart::PropertyMapper::getValuePointer(aPropValues,aPropNames,C2U("LineWidth"));
+ sal_Int32 nLineWidth = 0;
+ if( pLineWidthAny && (*pLineWidthAny>>=nLineWidth) )
+ {
+ const sal_Int32 nMaxLineWidthForLegend = 50;/*1/100 mm*///todo: make this dependent from legend entry height
+ if( nLineWidth>nMaxLineWidthForLegend )
+ *pLineWidthAny = uno::makeAny( nMaxLineWidthForLegend );
+ }
+
::chart::PropertyMapper::setMultiProperties( aPropNames, aPropValues, xShapeProp );
}
}
@@ -316,10 +326,10 @@ Reference< drawing::XShape > VLegendSymbolFactory::createSymbol(
ShapeFactory aFactory( xShapeFactory );
if( aSymbol.Style == chart2::SymbolStyle_STANDARD )
{
- // border of symbols always black
- aSymbol.BorderColor = 0x000000;
// 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,
diff --git a/chart2/source/view/main/VTitle.cxx b/chart2/source/view/main/VTitle.cxx
index f804a505219f..f62142735b7c 100644
--- a/chart2/source/view/main/VTitle.cxx
+++ b/chart2/source/view/main/VTitle.cxx
@@ -253,6 +253,21 @@ void VTitle::createShapes(
}
}
+ // #i109336# Improve auto positioning in chart
+ float fFontHeight = 0.0;
+ if ( xShapeProp.is() && ( xShapeProp->getPropertyValue( C2U( "CharHeight" ) ) >>= fFontHeight ) )
+ {
+ fFontHeight *= ( 2540. / 72. ); // pt -> 1/100 mm
+ float fXFraction = 0.18;
+ sal_Int32 nXDistance = static_cast< sal_Int32 >( ::rtl::math::round( fFontHeight * fXFraction ) );
+ float fYFraction = 0.30;
+ sal_Int32 nYDistance = static_cast< sal_Int32 >( ::rtl::math::round( fFontHeight * fYFraction ) );
+ xShapeProp->setPropertyValue( C2U( "TextLeftDistance" ), uno::makeAny( nXDistance ) );
+ xShapeProp->setPropertyValue( C2U( "TextRightDistance" ), uno::makeAny( nXDistance ) );
+ xShapeProp->setPropertyValue( C2U( "TextUpperDistance" ), uno::makeAny( nYDistance ) );
+ xShapeProp->setPropertyValue( C2U( "TextLowerDistance" ), uno::makeAny( nYDistance ) );
+ }
+
try
{
double fAngleDegree = 0;
diff --git a/chart2/source/view/view.map b/chart2/source/view/view.map
deleted file mode 100644
index d86ffaa9bdd4..000000000000
--- a/chart2/source/view/view.map
+++ /dev/null
@@ -1,9 +0,0 @@
-CHART_1_0 {
- global:
- component_getImplementationEnvironment;
- component_writeInfo;
- component_getFactory;
-
- local:
- *;
-};
diff --git a/chart2/uiconfig/toolbar/arrowshapes.xml b/chart2/uiconfig/toolbar/arrowshapes.xml
new file mode 100644
index 000000000000..4a53519494ea
--- /dev/null
+++ b/chart2/uiconfig/toolbar/arrowshapes.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE toolbar:toolbar PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "toolbar.dtd">
+<toolbar:toolbar xmlns:toolbar="http://openoffice.org/2001/toolbar" xmlns:xlink="http://www.w3.org/1999/xlink" toolbar:id="toolbar">
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes.left-arrow" toolbar:helpid="helpid:11004" />
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes.right-arrow" toolbar:helpid="helpid:11004" />
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes.up-arrow" toolbar:helpid="helpid:11004" />
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes.down-arrow" toolbar:helpid="helpid:11004" />
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes.left-right-arrow" toolbar:helpid="helpid:11004" />
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes.up-down-arrow" toolbar:helpid="helpid:11004" />
+ <toolbar:toolbarbreak/>
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes.up-right-arrow" toolbar:helpid="helpid:11004" />
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes.up-right-down-arrow" toolbar:helpid="helpid:11004" />
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes.quad-arrow" toolbar:helpid="helpid:11004" />
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes.corner-right-arrow" toolbar:helpid="helpid:11004" />
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes.split-arrow" toolbar:helpid="helpid:11004" />
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes.striped-right-arrow" toolbar:helpid="helpid:11004" />
+ <toolbar:toolbarbreak/>
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes.notched-right-arrow" toolbar:helpid="helpid:11004" />
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes.pentagon-right" toolbar:helpid="helpid:11004" />
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes.chevron" toolbar:helpid="helpid:11004" />
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes.right-arrow-callout" toolbar:helpid="helpid:11004" />
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes.left-arrow-callout" toolbar:helpid="helpid:11004" />
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes.up-arrow-callout" toolbar:helpid="helpid:11004" />
+ <toolbar:toolbarbreak/>
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes.down-arrow-callout" toolbar:helpid="helpid:11004" />
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes.left-right-arrow-callout" toolbar:helpid="helpid:11004" />
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes.up-down-arrow-callout" toolbar:helpid="helpid:11004" />
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes.up-right-arrow-callout" toolbar:helpid="helpid:11004" />
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes.quad-arrow-callout" toolbar:helpid="helpid:11004" />
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes.circular-arrow" toolbar:helpid="helpid:11004" />
+ <toolbar:toolbarbreak/>
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes.split-round-arrow" toolbar:helpid="helpid:11004" />
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes.s-sharped-arrow" toolbar:helpid="helpid:11004" />
+</toolbar:toolbar> \ No newline at end of file
diff --git a/chart2/uiconfig/toolbar/basicshapes.xml b/chart2/uiconfig/toolbar/basicshapes.xml
new file mode 100644
index 000000000000..e65778305788
--- /dev/null
+++ b/chart2/uiconfig/toolbar/basicshapes.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE toolbar:toolbar PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "toolbar.dtd">
+<toolbar:toolbar xmlns:toolbar="http://openoffice.org/2001/toolbar" xmlns:xlink="http://www.w3.org/1999/xlink" toolbar:id="toolbar">
+ <toolbar:toolbaritem xlink:href=".uno:BasicShapes.rectangle" toolbar:helpid="helpid:11002" />
+ <toolbar:toolbaritem xlink:href=".uno:BasicShapes.round-rectangle" toolbar:helpid="helpid:11002" />
+ <toolbar:toolbaritem xlink:href=".uno:BasicShapes.quadrat" toolbar:helpid="helpid:11002" />
+ <toolbar:toolbaritem xlink:href=".uno:BasicShapes.round-quadrat" toolbar:helpid="helpid:11002" />
+ <toolbar:toolbaritem xlink:href=".uno:BasicShapes.circle" toolbar:helpid="helpid:11002" />
+ <toolbar:toolbaritem xlink:href=".uno:BasicShapes.ellipse" toolbar:helpid="helpid:11002" />
+ <toolbar:toolbarbreak/>
+ <toolbar:toolbaritem xlink:href=".uno:BasicShapes.circle-pie" toolbar:helpid="helpid:11002" />
+ <toolbar:toolbaritem xlink:href=".uno:BasicShapes.isosceles-triangle" toolbar:helpid="helpid:11002" />
+ <toolbar:toolbaritem xlink:href=".uno:BasicShapes.right-triangle" toolbar:helpid="helpid:11002" />
+ <toolbar:toolbaritem xlink:href=".uno:BasicShapes.trapezoid" toolbar:helpid="helpid:11002" />
+ <toolbar:toolbaritem xlink:href=".uno:BasicShapes.diamond" toolbar:helpid="helpid:11002" />
+ <toolbar:toolbaritem xlink:href=".uno:BasicShapes.parallelogram" toolbar:helpid="helpid:11002" />
+ <toolbar:toolbarbreak/>
+ <toolbar:toolbaritem xlink:href=".uno:BasicShapes.pentagon" toolbar:helpid="helpid:11002" />
+ <toolbar:toolbaritem xlink:href=".uno:BasicShapes.hexagon" toolbar:helpid="helpid:11002" />
+ <toolbar:toolbaritem xlink:href=".uno:BasicShapes.octagon" toolbar:helpid="helpid:11002" />
+ <toolbar:toolbaritem xlink:href=".uno:BasicShapes.cross" toolbar:helpid="helpid:11002" />
+ <toolbar:toolbaritem xlink:href=".uno:BasicShapes.ring" toolbar:helpid="helpid:11002" />
+ <toolbar:toolbaritem xlink:href=".uno:BasicShapes.block-arc" toolbar:helpid="helpid:11002" />
+ <toolbar:toolbarbreak/>
+ <toolbar:toolbaritem xlink:href=".uno:BasicShapes.can" toolbar:helpid="helpid:11002" />
+ <toolbar:toolbaritem xlink:href=".uno:BasicShapes.cube" toolbar:helpid="helpid:11002" />
+ <toolbar:toolbaritem xlink:href=".uno:BasicShapes.paper" toolbar:helpid="helpid:11002" />
+ <toolbar:toolbaritem xlink:href=".uno:BasicShapes.frame" toolbar:helpid="helpid:11002" />
+</toolbar:toolbar> \ No newline at end of file
diff --git a/chart2/uiconfig/toolbar/calloutshapes.xml b/chart2/uiconfig/toolbar/calloutshapes.xml
new file mode 100644
index 000000000000..91b957fa697a
--- /dev/null
+++ b/chart2/uiconfig/toolbar/calloutshapes.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE toolbar:toolbar PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "toolbar.dtd">
+<toolbar:toolbar xmlns:toolbar="http://openoffice.org/2001/toolbar" xmlns:xlink="http://www.w3.org/1999/xlink" toolbar:id="toolbar">
+ <toolbar:toolbaritem xlink:href=".uno:CalloutShapes.rectangular-callout" toolbar:helpid="helpid:11006" />
+ <toolbar:toolbaritem xlink:href=".uno:CalloutShapes.round-rectangular-callout" toolbar:helpid="helpid:11006" />
+ <toolbar:toolbaritem xlink:href=".uno:CalloutShapes.round-callout" toolbar:helpid="helpid:11006" />
+ <toolbar:toolbaritem xlink:href=".uno:CalloutShapes.cloud-callout" toolbar:helpid="helpid:11006" />
+ <toolbar:toolbaritem xlink:href=".uno:CalloutShapes.line-callout-1" toolbar:helpid="helpid:11006" />
+ <toolbar:toolbaritem xlink:href=".uno:CalloutShapes.line-callout-2" toolbar:helpid="helpid:11006" />
+ <toolbar:toolbaritem xlink:href=".uno:CalloutShapes.line-callout-3" toolbar:helpid="helpid:11006" />
+</toolbar:toolbar> \ No newline at end of file
diff --git a/chart2/uiconfig/toolbar/drawbar.xml b/chart2/uiconfig/toolbar/drawbar.xml
new file mode 100644
index 000000000000..f4017835635c
--- /dev/null
+++ b/chart2/uiconfig/toolbar/drawbar.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE toolbar:toolbar PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "toolbar.dtd">
+<toolbar:toolbar xmlns:toolbar="http://openoffice.org/2001/toolbar" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <toolbar:toolbaritem xlink:href=".uno:SelectObject" toolbar:helpid="10128"/>
+ <toolbar:toolbarseparator/>
+ <toolbar:toolbaritem xlink:href=".uno:Line" toolbar:helpid="10102"/>
+ <toolbar:toolbaritem xlink:href=".uno:LineArrowEnd" toolbar:helpid="27173"/>
+ <toolbar:toolbaritem xlink:href=".uno:Rect" toolbar:helpid="10104"/>
+ <toolbar:toolbaritem xlink:href=".uno:Ellipse" toolbar:helpid="10110"/>
+ <toolbar:toolbaritem xlink:href=".uno:Freeline_Unfilled" toolbar:helpid="10464"/>
+ <toolbar:toolbaritem xlink:href=".uno:DrawText" toolbar:helpid="10253"/>
+ <toolbar:toolbaritem xlink:href=".uno:DrawCaption" toolbar:helpid="10254"/>
+ <toolbar:toolbarseparator/>
+ <toolbar:toolbaritem xlink:href=".uno:BasicShapes" toolbar:style="dropdown" toolbar:helpid="11002"/>
+ <toolbar:toolbaritem xlink:href=".uno:SymbolShapes" toolbar:style="dropdown" toolbar:helpid="11003"/>
+ <toolbar:toolbaritem xlink:href=".uno:ArrowShapes" toolbar:style="dropdown" toolbar:helpid="11004"/>
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes" toolbar:style="dropdown" toolbar:helpid="11005"/>
+ <toolbar:toolbaritem xlink:href=".uno:CalloutShapes" toolbar:style="dropdown" toolbar:helpid="11006"/>
+ <toolbar:toolbaritem xlink:href=".uno:StarShapes" toolbar:style="dropdown" toolbar:helpid="11007"/>
+</toolbar:toolbar> \ No newline at end of file
diff --git a/chart2/uiconfig/toolbar/flowchartshapes.xml b/chart2/uiconfig/toolbar/flowchartshapes.xml
new file mode 100644
index 000000000000..bb1d1099dbd4
--- /dev/null
+++ b/chart2/uiconfig/toolbar/flowchartshapes.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE toolbar:toolbar PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "toolbar.dtd">
+<toolbar:toolbar xmlns:toolbar="http://openoffice.org/2001/toolbar" xmlns:xlink="http://www.w3.org/1999/xlink" toolbar:id="toolbar">
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-process" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-alternate-process" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-decision" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-data" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-predefined-process" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-internal-storage" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbarbreak/>
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-document" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-multidocument" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-terminator" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-preparation" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-manual-input" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-manual-operation" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbarbreak/>
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-connector" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-off-page-connector" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-card" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-punched-tape" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-summing-junction" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-or" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbarbreak/>
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-collate" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-sort" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-extract" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-merge" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-stored-data" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-delay" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbarbreak/>
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-sequential-access" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-magnetic-disk" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-direct-access-storage" toolbar:helpid="helpid:11005" />
+ <toolbar:toolbaritem xlink:href=".uno:FlowChartShapes.flowchart-display" toolbar:helpid="helpid:11005" />
+</toolbar:toolbar> \ No newline at end of file
diff --git a/chart2/uiconfig/toolbar/starshapes.xml b/chart2/uiconfig/toolbar/starshapes.xml
new file mode 100644
index 000000000000..a2ff874d2fe7
--- /dev/null
+++ b/chart2/uiconfig/toolbar/starshapes.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE toolbar:toolbar PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "toolbar.dtd">
+<toolbar:toolbar xmlns:toolbar="http://openoffice.org/2001/toolbar" xmlns:xlink="http://www.w3.org/1999/xlink" toolbar:id="toolbar">
+ <toolbar:toolbaritem xlink:href=".uno:StarShapes.bang" toolbar:helpid="helpid:11007" />
+ <toolbar:toolbaritem xlink:href=".uno:StarShapes.star4" toolbar:helpid="helpid:11007" />
+ <toolbar:toolbaritem xlink:href=".uno:StarShapes.star5" toolbar:helpid="helpid:11007" />
+ <toolbar:toolbaritem xlink:href=".uno:StarShapes.star6" toolbar:helpid="helpid:11007" />
+ <toolbar:toolbaritem xlink:href=".uno:StarShapes.star8" toolbar:helpid="helpid:11007" />
+ <toolbar:toolbaritem xlink:href=".uno:StarShapes.star12" toolbar:helpid="helpid:11007" />
+ <toolbar:toolbarbreak/>
+ <toolbar:toolbaritem xlink:href=".uno:StarShapes.star24" toolbar:helpid="helpid:11007" />
+ <toolbar:toolbaritem xlink:href=".uno:StarShapes.concave-star6" toolbar:helpid="helpid:11007" />
+ <toolbar:toolbaritem xlink:href=".uno:StarShapes.vertical-scroll" toolbar:helpid="helpid:11007" />
+ <toolbar:toolbaritem xlink:href=".uno:StarShapes.horizontal-scroll" toolbar:helpid="helpid:11007" />
+ <toolbar:toolbaritem xlink:href=".uno:StarShapes.signet" toolbar:helpid="helpid:11007" />
+ <toolbar:toolbaritem xlink:href=".uno:StarShapes.doorplate" toolbar:helpid="helpid:11007" />
+</toolbar:toolbar> \ No newline at end of file
diff --git a/chart2/uiconfig/toolbar/symbolshapes.xml b/chart2/uiconfig/toolbar/symbolshapes.xml
new file mode 100644
index 000000000000..0fa6aee313db
--- /dev/null
+++ b/chart2/uiconfig/toolbar/symbolshapes.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE toolbar:toolbar PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "toolbar.dtd">
+<toolbar:toolbar xmlns:toolbar="http://openoffice.org/2001/toolbar" xmlns:xlink="http://www.w3.org/1999/xlink" toolbar:id="toolbar">
+ <toolbar:toolbaritem xlink:href=".uno:SymbolShapes.smiley" toolbar:helpid="helpid:11003" />
+ <toolbar:toolbaritem xlink:href=".uno:SymbolShapes.sun" toolbar:helpid="helpid:11003" />
+ <toolbar:toolbaritem xlink:href=".uno:SymbolShapes.moon" toolbar:helpid="helpid:11003" />
+ <toolbar:toolbaritem xlink:href=".uno:SymbolShapes.lightning" toolbar:helpid="helpid:11003" />
+ <toolbar:toolbaritem xlink:href=".uno:SymbolShapes.heart" toolbar:helpid="helpid:11003" />
+ <toolbar:toolbaritem xlink:href=".uno:SymbolShapes.flower" toolbar:helpid="helpid:11003" />
+ <toolbar:toolbarbreak/>
+ <toolbar:toolbaritem xlink:href=".uno:SymbolShapes.cloud" toolbar:helpid="helpid:11003" />
+ <toolbar:toolbaritem xlink:href=".uno:SymbolShapes.forbidden" toolbar:helpid="helpid:11003" />
+ <toolbar:toolbaritem xlink:href=".uno:SymbolShapes.puzzle" toolbar:helpid="helpid:11003" />
+ <toolbar:toolbaritem xlink:href=".uno:SymbolShapes.bracket-pair" toolbar:helpid="helpid:11003" />
+ <toolbar:toolbaritem xlink:href=".uno:SymbolShapes.left-bracket" toolbar:helpid="helpid:11003" />
+ <toolbar:toolbaritem xlink:href=".uno:SymbolShapes.right-bracket" toolbar:helpid="helpid:11003" />
+ <toolbar:toolbarbreak/>
+ <toolbar:toolbaritem xlink:href=".uno:SymbolShapes.brace-pair" toolbar:helpid="helpid:11003" />
+ <toolbar:toolbaritem xlink:href=".uno:SymbolShapes.left-brace" toolbar:helpid="helpid:11003" />
+ <toolbar:toolbaritem xlink:href=".uno:SymbolShapes.right-brace" toolbar:helpid="helpid:11003" />
+ <toolbar:toolbaritem xlink:href=".uno:SymbolShapes.quad-bevel" toolbar:helpid="helpid:11003" />
+ <toolbar:toolbaritem xlink:href=".uno:SymbolShapes.octagon-bevel" toolbar:helpid="helpid:11003" />
+ <toolbar:toolbaritem xlink:href=".uno:SymbolShapes.diamond-bevel" toolbar:helpid="helpid:11003" />
+</toolbar:toolbar> \ No newline at end of file
diff --git a/sc/addin/datefunc/makefile.mk b/sc/addin/datefunc/makefile.mk
index 4e4966720261..f781b3835833 100644
--- a/sc/addin/datefunc/makefile.mk
+++ b/sc/addin/datefunc/makefile.mk
@@ -86,11 +86,7 @@ $(MISC)$/$(TARGET).lst : \
$(INCCOM)$/xlang.h \
..$/inc$/$(TARGET).hrc \
..$/inc$/addin.h
-.IF "$(GUI)"=="UNX" || "$(USE_SHELL)"!="4nt"
echo $< > $@
-.ELSE
- echo $(<:+"\n":s/ //) > $@
-.ENDIF
# --- Def-File ---
diff --git a/sc/addin/makefile.mk b/sc/addin/makefile.mk
index c9505e29d4d4..e716a8d8477a 100644
--- a/sc/addin/makefile.mk
+++ b/sc/addin/makefile.mk
@@ -41,10 +41,5 @@ TARGET=addin
ALLTAR: $(MISC)$/cl2c.pl
$(MISC)$/cl2c.pl: util/cl2c.pl
-.IF "$(GUI)"=="UNX" || "$(USE_SHELL)"!="4nt"
tr -d "\015" < util$/cl2c.pl > $@
chmod +rw $@
-.ELSE
- @$(COPY) util$/cl2c.pl $@
-.ENDIF
-
diff --git a/sc/addin/rot13/exports.map b/sc/addin/rot13/exports.map
index fa447824beda..c662c9148aba 100644
--- a/sc/addin/rot13/exports.map
+++ b/sc/addin/rot13/exports.map
@@ -1,4 +1,4 @@
-SC_1_0 {
+UDK_3_0_0 {
global:
GetFunctionCount;
GetFunctionData;
diff --git a/sc/addin/rot13/makefile.mk b/sc/addin/rot13/makefile.mk
index 128d8f10b6f8..a33c50d2a725 100644
--- a/sc/addin/rot13/makefile.mk
+++ b/sc/addin/rot13/makefile.mk
@@ -85,9 +85,4 @@ $(MISC)$/rot.lst : \
$(INCCOM)$/xlang.h \
..$/inc$/rot13.hrc \
..$/inc$/addin.h
-.IF "$(GUI)"=="UNX" || "$(USE_SHELL)"!="4nt"
@echo $< > $@
-.ELSE
- @echo $(<:+"\n":s/ //) > $@
-.ENDIF
-
diff --git a/sc/addin/util/makefile.mk b/sc/addin/util/makefile.mk
index e415cf7631d7..2bd75148f80a 100644
--- a/sc/addin/util/makefile.mk
+++ b/sc/addin/util/makefile.mk
@@ -37,13 +37,9 @@ TARGET=autil
$(BIN)$/addin.zip : \
$(MISC)$/rot.lst \
$(MISC)$/dfa.lst
-.IF "$(GUI)"=="UNX" || "$(USE_SHELL)"!="4nt"
$(TYPE) $(MISC)$/rot.lst | tr -s " " "\n" | zip -@ -u -j -ll $(BIN)$/addin.zip $(CHECKZIPRESULT)
$(TYPE) $(MISC)$/dfa.lst | tr -s " " "\n" | zip -@ -u -j -ll $(BIN)$/addin.zip $(CHECKZIPRESULT)
chmod +rw $(BIN)$/addin.zip
-.ELSE
- $(TYPE) $< | zip -@ -u -j $(BIN)$/addin.zip $(CHECKZIPRESULT)
-.ENDIF
.INCLUDE: target.mk
diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx
index 6d7b7f48c2d7..c82d607577bf 100644
--- a/sc/inc/attarray.hxx
+++ b/sc/inc/attarray.hxx
@@ -148,7 +148,7 @@ public:
BOOL HasLines( SCROW nRow1, SCROW nRow2, Rectangle& rSizes,
BOOL bLeft, BOOL bRight ) const;
- BOOL HasAttrib( SCROW nRow1, SCROW nRow2, USHORT nMask ) const;
+ bool HasAttrib( SCROW nRow1, SCROW nRow2, USHORT nMask ) const;
BOOL ExtendMerge( SCCOL nThisCol, SCROW nStartRow, SCROW nEndRow,
SCCOL& rPaintCol, SCROW& rPaintRow,
BOOL bRefresh, BOOL bAttrs );
diff --git a/sc/inc/chart2uno.hxx b/sc/inc/chart2uno.hxx
index d63e47d642b9..44737e711090 100644
--- a/sc/inc/chart2uno.hxx
+++ b/sc/inc/chart2uno.hxx
@@ -188,24 +188,6 @@ public:
getSupportedServiceNames() throw(
::com::sun::star::uno::RuntimeException);
- /**
- * Check the current list of reference tokens, and add the upper left
- * corner of the minimum range that encloses all ranges if certain
- * conditions are met.
- *
- * @param rRefTokens list of reference tokens
- *
- * @return true if the corner was added, false otherwise.
- */
- static bool addUpperLeftCornerIfMissing(::std::vector<ScSharedTokenRef>& rRefTokens);
-
-private:
-
- void detectRangesFromDataSource(::std::vector<ScSharedTokenRef>& rRefTokens,
- ::com::sun::star::chart::ChartDataRowSource& rRowSource,
- bool& rRowSourceDetected,
- const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource >& xDataSource);
-
private:
ScDocument* m_pDocument;
diff --git a/sc/inc/charthelper.hxx b/sc/inc/charthelper.hxx
index b4c677d7c3c6..50b8586bdace 100644
--- a/sc/inc/charthelper.hxx
+++ b/sc/inc/charthelper.hxx
@@ -29,9 +29,12 @@
#define SC_CHARTHELPER_HXX
#include <tools/solar.h>
+#include "address.hxx"
+#include "global.hxx"
-class ScDocument;
-class ScAddress;
+#include <com/sun/star/chart2/XChartDocument.hpp>
+
+class SdrObject;
/** Use this to handle charts in a calc document
*/
@@ -40,6 +43,12 @@ class ScChartHelper
public:
static USHORT DoUpdateAllCharts( ScDocument* pDoc );
static USHORT DoUpdateCharts( const ScAddress& rPos, ScDocument* pDoc ); //use this to replace ScDBFunc::DoUpdateCharts in future
+ static void AdjustRangesOfChartsOnDestinationPage( ScDocument* pSrcDoc, ScDocument* pDestDoc, const SCTAB nSrcTab, const SCTAB nDestTab );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > GetChartFromSdrObject( SdrObject* pObject );
+ static void GetChartRanges( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDoc,
+ ::com::sun::star::uno::Sequence< rtl::OUString >& rRanges );
+ static void SetChartRanges( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDoc,
+ const ::com::sun::star::uno::Sequence< rtl::OUString >& rRanges );
};
#endif
diff --git a/sc/inc/chgtrack.hxx b/sc/inc/chgtrack.hxx
index ffe248bb3f65..6cf3d59314ef 100644
--- a/sc/inc/chgtrack.hxx
+++ b/sc/inc/chgtrack.hxx
@@ -308,7 +308,6 @@ protected:
GetDeletedInAddress(), p );
}
BOOL RemoveDeletedIn( const ScChangeAction* );
- void RemoveAllDeletedIn();
void SetDeletedIn( ScChangeAction* );
ScChangeActionLinkEntry* AddDeleted( ScChangeAction* p )
@@ -414,6 +413,7 @@ public:
{ return IsDeleteType() || IsDeletedIn(); }
BOOL IsDeletedIn( const ScChangeAction* ) const;
BOOL IsDeletedInDelType( ScChangeActionType ) const;
+ void RemoveAllDeletedIn();
const ScChangeActionLinkEntry* GetFirstDeletedEntry() const
{ return pLinkDeleted; }
diff --git a/sc/inc/collect.hxx b/sc/inc/collect.hxx
index e8b9bed60865..167ab5929c6a 100644
--- a/sc/inc/collect.hxx
+++ b/sc/inc/collect.hxx
@@ -184,20 +184,18 @@ private:
BOOL bCaseSensitive;
public:
- TypedScStrCollection( USHORT nLim = 4, USHORT nDel = 4, BOOL bDup = FALSE )
- : ScSortedCollection( nLim, nDel, bDup ) { bCaseSensitive = FALSE; }
+ TypedScStrCollection( USHORT nLim = 4, USHORT nDel = 4, BOOL bDup = FALSE );
- TypedScStrCollection( const TypedScStrCollection& rCpy )
- : ScSortedCollection( rCpy ) { bCaseSensitive = rCpy.bCaseSensitive; }
- ~TypedScStrCollection();
+ TypedScStrCollection( const TypedScStrCollection& rCpy )
+ : ScSortedCollection( rCpy ) { bCaseSensitive = rCpy.bCaseSensitive; }
+ ~TypedScStrCollection();
virtual ScDataObject* Clone() const;
virtual short Compare( ScDataObject* pKey1, ScDataObject* pKey2 ) const;
- TypedStrData* operator[]( const USHORT nIndex) const
- { return (TypedStrData*)At(nIndex); }
+ TypedStrData* operator[]( const USHORT nIndex) const;
- void SetCaseSensitive( BOOL bSet ) { bCaseSensitive = bSet; }
+ void SetCaseSensitive( BOOL bSet );
BOOL FindText( const String& rStart, String& rResult, USHORT& rPos, BOOL bBack ) const;
BOOL GetExactMatch( String& rString ) const;
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 08f3d1f7b1e3..85567a2a656d 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -142,7 +142,7 @@ public:
//UNUSED2009-05 BOOL HasLines( SCROW nRow1, SCROW nRow2, Rectangle& rSizes,
//UNUSED2009-05 BOOL bLeft, BOOL bRight ) const;
- BOOL HasAttrib( SCROW nRow1, SCROW nRow2, USHORT nMask ) const;
+ bool HasAttrib( SCROW nRow1, SCROW nRow2, USHORT nMask ) const;
BOOL HasAttribSelection( const ScMarkData& rMark, USHORT nMask ) const;
BOOL ExtendMerge( SCCOL nThisCol, SCROW nStartRow, SCROW nEndRow,
SCCOL& rPaintCol, SCROW& rPaintRow,
@@ -235,7 +235,9 @@ public:
// TRUE = Zahlformat gesetzt
BOOL SetString( SCROW nRow, SCTAB nTab, const String& rString,
- formula::FormulaGrammar::AddressConvention conv = formula::FormulaGrammar::CONV_OOO );
+ formula::FormulaGrammar::AddressConvention conv = formula::FormulaGrammar::CONV_OOO,
+ SvNumberFormatter* pFormatter = NULL,
+ bool bDetectNumberFormat = true );
void SetValue( SCROW nRow, const double& rVal);
void SetError( SCROW nRow, const USHORT nError);
diff --git a/sc/inc/dapiuno.hxx b/sc/inc/dapiuno.hxx
index ba695d8784bc..c9a5305a05ca 100644
--- a/sc/inc/dapiuno.hxx
+++ b/sc/inc/dapiuno.hxx
@@ -31,6 +31,8 @@
#include "global.hxx"
#include "dpobject.hxx"
#include "rangeutl.hxx" // ScArea
+#include "cellsuno.hxx" // for XModifyListenerArr_Impl
+
#include <svl/lstner.hxx>
#include <svl/itemprop.hxx>
@@ -39,6 +41,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/container/XEnumerationAccess.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/util/XModifyBroadcaster.hpp>
#include <com/sun/star/sheet/DataPilotFieldAutoShowInfo.hpp>
#include <com/sun/star/sheet/DataPilotFieldGroupInfo.hpp>
@@ -313,11 +316,15 @@ public:
// ============================================================================
class ScDataPilotTableObj : public ScDataPilotDescriptorBase,
- public com::sun::star::sheet::XDataPilotTable2
+ public com::sun::star::sheet::XDataPilotTable2,
+ public com::sun::star::util::XModifyBroadcaster
{
private:
SCTAB nTab;
String aName;
+ XModifyListenerArr_Impl aModifyListeners;
+
+ void Refreshed_Impl();
public:
ScDataPilotTableObj(ScDocShell* pDocSh, SCTAB nT, const String& rN);
@@ -329,6 +336,8 @@ public:
virtual void SAL_CALL acquire() throw();
virtual void SAL_CALL release() throw();
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
virtual ScDPObject* GetDPObject() const;
virtual void SetDPObject(ScDPObject* pDPObj);
@@ -361,6 +370,14 @@ public:
throw(::com::sun::star::lang::IllegalArgumentException,
::com::sun::star::uno::RuntimeException);
+ // XModifyBroadcaster
+ virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::util::XModifyListener >& aListener )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::util::XModifyListener >& aListener )
+ throw (::com::sun::star::uno::RuntimeException);
+
// XTypeProvider (overloaded)
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
throw(::com::sun::star::uno::RuntimeException);
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 28b2ac55706a..96c73670608d 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -45,6 +45,13 @@
#include <memory>
#include <map>
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+#include <list>
+#include "dpobject.hxx"
+#include "dptabdat.hxx"
+// End Comments
+
class KeyEvent;
class OutputDevice;
class SdrObject;
@@ -256,6 +263,11 @@ private:
ScRangeName* pRangeName;
ScDBCollection* pDBCollection;
ScDPCollection* pDPCollection;
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ std::list<ScDPObject> m_listDPObjectsInClip;
+ std::list<ScDPTableDataCache*> m_listDPObjectsCaches;
+ // End Comments
ScChartCollection* pChartCollection;
std::auto_ptr< ScTemporaryChartLock > apTemporaryChartLock;
ScPatternAttr* pSelectionAttr; // Attribute eines Blocks
@@ -492,6 +504,17 @@ public:
SC_DLLPUBLIC ScDPCollection* GetDPCollection();
ScDPObject* GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
ScDPObject* GetDPAtBlock( const ScRange& rBlock ) const;
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ SC_DLLPUBLIC ScDPTableDataCache* GetDPObjectCache( long nID );
+ SC_DLLPUBLIC ScDPTableDataCache* GetUsedDPObjectCache ( ScRange rRange );
+ SC_DLLPUBLIC long AddDPObjectCache( ScDPTableDataCache* pData );
+ SC_DLLPUBLIC void RemoveDPObjectCache( long nID );
+ SC_DLLPUBLIC void RemoveUnusedDPObjectCaches();
+ SC_DLLPUBLIC void GetUsedDPObjectCache( std::list<ScDPTableDataCache*>& usedlist );
+ SC_DLLPUBLIC long GetNewDPObjectCacheId ();
+ // End Comments
+
SC_DLLPUBLIC ScChartCollection* GetChartCollection() const;
void StopTemporaryChartLock();
@@ -730,7 +753,9 @@ public:
SC_DLLPUBLIC void PutCell(SCCOL nCol, SCROW nRow, SCTAB nTab, ScBaseCell* pCell,
ULONG nFormatIndex, BOOL bForceTab = FALSE);
// return TRUE = Zahlformat gesetzt
- SC_DLLPUBLIC BOOL SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rString );
+ SC_DLLPUBLIC BOOL SetString(
+ SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rString,
+ SvNumberFormatter* pFormatter = NULL, bool bDetectNumberFormat = true );
SC_DLLPUBLIC void SetValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& rVal );
void SetError( SCCOL nCol, SCROW nRow, SCTAB nTab, const USHORT nError);
@@ -825,9 +850,9 @@ public:
BOOL IsHorOverlapped( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
BOOL IsVerOverlapped( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
- SC_DLLPUBLIC BOOL HasAttrib( SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
- SCCOL nCol2, SCROW nRow2, SCTAB nTab2, USHORT nMask );
- SC_DLLPUBLIC BOOL HasAttrib( const ScRange& rRange, USHORT nMask );
+ SC_DLLPUBLIC bool HasAttrib( SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
+ SCCOL nCol2, SCROW nRow2, SCTAB nTab2, USHORT nMask );
+ SC_DLLPUBLIC bool HasAttrib( const ScRange& rRange, USHORT nMask );
void GetBorderLines( SCCOL nCol, SCROW nRow, SCTAB nTab,
const SvxBorderLine** ppLeft,
@@ -874,10 +899,17 @@ public:
USHORT GetErrCode( const ScAddress& ) const;
- bool ShrinkToDataArea(SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow) const;
+ /** Shrink a range to only include data area.
+ This is not the actually used area within the
+ selection, but the bounds of the sheet's data area
+ instead. */
+ bool ShrinkToDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow ) const;
+
+ /** Shrink a range to only include used data area. */
+ bool ShrinkToUsedDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly ) const;
void GetDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
- SCCOL& rEndCol, SCROW& rEndRow, BOOL bIncludeOld );
+ SCCOL& rEndCol, SCROW& rEndRow, BOOL bIncludeOld, bool bOnlyDown );
SC_DLLPUBLIC BOOL GetCellArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const;
SC_DLLPUBLIC BOOL GetTableArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const;
SC_DLLPUBLIC BOOL GetPrintArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow,
@@ -1073,7 +1105,8 @@ public:
void UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
- ScDocument* pUndoDoc = NULL, BOOL bIncludeDraw = TRUE );
+ ScDocument* pUndoDoc = NULL, BOOL bIncludeDraw = TRUE,
+ bool bUpdateNoteCaptionPos = true );
SC_DLLPUBLIC void UpdateTranspose( const ScAddress& rDestPos, ScDocument* pClipDoc,
const ScMarkData& rMark, ScDocument* pUndoDoc = NULL );
@@ -1629,7 +1662,7 @@ public:
BOOL IsExpandRefs() { return bExpandRefs; }
SC_DLLPUBLIC void IncSizeRecalcLevel( SCTAB nTab );
- SC_DLLPUBLIC void DecSizeRecalcLevel( SCTAB nTab );
+ SC_DLLPUBLIC void DecSizeRecalcLevel( SCTAB nTab, bool bUpdateNoteCaptionPos = true );
ULONG GetXMLImportedFormulaCount() const { return nXMLImportedFormulaCount; }
void IncXMLImportedFormulaCount( ULONG nVal )
diff --git a/sc/inc/dpcachetable.hxx b/sc/inc/dpcachetable.hxx
index 60dba0bc27db..eab01d078081 100644
--- a/sc/inc/dpcachetable.hxx
+++ b/sc/inc/dpcachetable.hxx
@@ -55,33 +55,38 @@ class ScRange;
class ScDPDimension;
class ScDPCollection;
struct ScDPCacheCell;
-struct ScDPItemData;
struct ScQueryParam;
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+class ScDPItemData;
+// End Comments
class Date;
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+class ScDPTableDataCache;
+struct ScDPValueData;
+// End Comments
// ----------------------------------------------------------------------------
-class ScDPCacheTable
+class SC_DLLPUBLIC ScDPCacheTable
{
public:
-
- struct Cell
- {
- SCROW mnCategoryRef;
- ScDPCacheCell* mpContent;
-
- Cell();
- ~Cell();
- };
-
/** individual filter item used in SingleFilter and GroupFilter. */
struct FilterItem
{
- sal_Int32 mnMatchStrId;
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ String maString;
+ // End Comments
double mfValue;
bool mbHasValue;
FilterItem();
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+ bool match( const ScDPItemData& rCellData ) const;
+// End Comments
};
/** interface class used for filtering of rows. */
@@ -90,19 +95,26 @@ public:
public:
/** returns true if the matching condition is met for a single cell
value, or false otherwise. */
- virtual bool match(const ScDPCacheCell& rCell) const = 0;
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+ virtual bool match( const ScDPItemData& rCellData ) const = 0;
+// End Comments
};
/** ordinary single-item filter. */
class SingleFilter : public FilterBase
{
public:
- explicit SingleFilter(ScSimpleSharedString& rSharedString,
- sal_Int32 nMatchStrId, double fValue, bool bHasValue);
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ explicit SingleFilter(String aString, double fValue, bool bHasValue);
+ // End Comments
virtual ~SingleFilter(){}
- virtual bool match(const ScDPCacheCell& rCell) const;
-
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ virtual bool match(const ScDPItemData& rCellData) const;
+ // End Comments
const String getMatchString();
double getMatchValue() const;
bool hasValue() const;
@@ -111,25 +123,27 @@ public:
explicit SingleFilter();
FilterItem maItem;
- ScSimpleSharedString mrSharedString;
};
/** multi-item (group) filter. */
class GroupFilter : public FilterBase
{
public:
- GroupFilter(ScSimpleSharedString& rSharedString);
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ GroupFilter();
+ // End Comments
virtual ~GroupFilter(){}
- virtual bool match(const ScDPCacheCell& rCell) const;
-
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ virtual bool match( const ScDPItemData& rCellData ) const;
+ // End Comments
void addMatchItem(const String& rStr, double fVal, bool bHasValue);
size_t getMatchItemCount() const;
private:
- GroupFilter();
::std::vector<FilterItem> maItems;
- ScSimpleSharedString mrSharedString;
};
/** single filtering criterion. */
@@ -140,22 +154,26 @@ public:
Criterion();
};
-
- ScDPCacheTable(ScDPCollection* pCollection);
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ ScDPCacheTable( ScDocument* pDoc,long nId );
+ // End Comments
~ScDPCacheTable();
sal_Int32 getRowSize() const;
sal_Int32 getColSize() const;
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ ScDPTableDataCache* GetCache() const;
/** Fill the internal table from the cell range provided. This function
- assumes that the first row is the column header. */
- void fillTable(ScDocument* pDoc, const ScRange& rRange, const ScQueryParam& rQuery, BOOL* pSpecial,
- bool bIgnoreEmptyRows);
-
+ assumes that the first row is the column header. */
+ void fillTable( const ScQueryParam& rQuery, BOOL* pSpecial,
+ bool bIgnoreEmptyRows, bool bRepeatIfEmpty );
/** Fill the internal table from database connection object. This function
assumes that the first row is the column header. */
- void fillTable(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& xRowSet,
- const Date& rNullDate);
+ void fillTable();
+ // End Comments
/** Check whether a specified row is active or not. When a row is active,
it is used in calculation of the results data. A row becomes inactive
@@ -169,15 +187,23 @@ public:
/** Get the cell instance at specified location within the data grid. Note
that the data grid doesn't include the header row. Don't delete the
returned object! */
- const ScDPCacheCell* getCell(SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const;
-
- const String* getFieldName(sal_Int32 nIndex) const;
-
- /** Get the unique entries for a field specified by index. The caller must
+ const ScDPItemData* getCell(SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const;
+ void getValue( ScDPValueData& rVal, SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const;
+ String getFieldName( SCCOL nIndex) const;
+ //End Comments
+
+ /** Get the field index (i.e. column ID in the original data source) based
+ on the string value that corresponds with the column title. It returns
+ -1 if no field matching the string value exists. */
+ sal_Int32 getFieldIndex(const String& rStr) const;
+
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ /** Get the unique entries for a field specified by index. The caller must
make sure that the table is filled before calling function, or it will
get an empty collection. */
- const TypedScStrCollection& getFieldEntries(sal_Int32 nIndex) const;
-
+ const ::std::vector<SCROW>& getFieldEntries( sal_Int32 nColumn ) const;
+ // End Comments
/** Filter the table based on the specified criteria, and copy the
result to rTabData. This method is used, for example, to generate
a drill-down data table. */
@@ -186,6 +212,7 @@ public:
const ::std::hash_set<sal_Int32>& rRepeatIfEmptyDims);
void clear();
+ void swap(ScDPCacheTable& rOther);
bool empty() const;
private:
@@ -200,26 +227,23 @@ private:
*/
bool isRowQualified(sal_Int32 nRow, const ::std::vector<Criterion>& rCriteria, const ::std::hash_set<sal_Int32>& rRepeatIfEmptyDims) const;
void getValueData(ScDocument* pDoc, const ScAddress& rPos, ScDPCacheCell& rCell);
-
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ void InitNoneCache( ScDocument* pDoc );
+ // End Comments
private:
- typedef ::boost::shared_ptr<TypedScStrCollection> TypedScStrCollectionPtr;
-
- /** main data table. */
- ::std::vector< ::std::vector< ::ScDPCacheTable::Cell > > maTable;
-
- /** header string IDs */
- ::std::vector<sal_Int32> maHeader;
-
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
/** unique field entires for each field (column). */
- ::std::vector<TypedScStrCollectionPtr> maFieldEntries;
-
+ ::std::vector< ::std::vector<SCROW> > maFieldEntries;
+ // End Comments
/** used to track visibility of rows. The first row below the header row
has the index of 0. */
::std::vector<bool> maRowsVisible;
-
- ScSimpleSharedString& mrSharedString;
- ScDPCollection* mpCollection;
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ ScDPTableDataCache* mpCache;
+ ScDPTableDataCache* mpNoneCache;
+ // End Comments
};
-
-
#endif
diff --git a/sc/inc/dpglobal.hxx b/sc/inc/dpglobal.hxx
new file mode 100755
index 000000000000..7de5947cc969
--- /dev/null
+++ b/sc/inc/dpglobal.hxx
@@ -0,0 +1,209 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright IBM Corporation 2009.
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: dpglobal.hxx,v $
+ * $Revision: 1.0 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+// Wang Xu Ming - DataPilot migration
+// Buffer&&Performance
+//
+#ifndef _SC_DPGLOBAL_HXX
+#define _SC_DPGLOBAL_HXX
+
+#include <algorithm>
+#include <list>
+#include <tools/gen.hxx>
+#include <tools/debug.hxx>
+#include <global.hxx>
+
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/sheet/XDimensionsSupplier.hpp>
+
+#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
+#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
+#include <com/sun/star/sheet/DataPilotTableHeaderData.hpp>
+#include <com/sun/star/sheet/DataPilotTablePositionData.hpp>
+#include <com/sun/star/sheet/DataPilotTablePositionType.hpp>
+#include <com/sun/star/sheet/DataPilotTableResultData.hpp>
+#include <com/sun/star/sheet/DataResultFlags.hpp>
+#include <com/sun/star/sheet/GeneralFunction.hpp>
+#include <com/sun/star/sheet/MemberResultFlags.hpp>
+#include <com/sun/star/sheet/TableFilterField.hpp>
+#include <com/sun/star/sheet/XDataPilotMemberResults.hpp>
+#include <com/sun/star/sheet/XDataPilotResults.hpp>
+#include <com/sun/star/sheet/XHierarchiesSupplier.hpp>
+#include <com/sun/star/sheet/XLevelsSupplier.hpp>
+
+
+// moved from fieldwnd.hxx, see also SC_DAPI_MAXFIELDS
+#define MAX_LABELS 256
+
+#define MAX_PAGEFIELDS 10 // maximum count of fields for page area
+
+#define PIVOT_MAXFUNC 11
+#define PIVOT_FUNC_NONE 0x0000
+#define PIVOT_FUNC_SUM 0x0001
+#define PIVOT_FUNC_COUNT 0x0002
+#define PIVOT_FUNC_AVERAGE 0x0004
+#define PIVOT_FUNC_MAX 0x0008
+#define PIVOT_FUNC_MIN 0x0010
+#define PIVOT_FUNC_PRODUCT 0x0020
+#define PIVOT_FUNC_COUNT_NUM 0x0040
+#define PIVOT_FUNC_STD_DEV 0x0080
+#define PIVOT_FUNC_STD_DEVP 0x0100
+#define PIVOT_FUNC_STD_VAR 0x0200
+#define PIVOT_FUNC_STD_VARP 0x0400
+#define PIVOT_FUNC_AUTO 0x1000
+
+#define DATA_RENAME_SEPARATOR "_"
+#define __MAX_NUM_LEN 64
+#define __DECIMALPLACE 18
+
+#define DP_PROP_COLUMNGRAND "ColumnGrand"
+#define DP_PROP_FUNCTION "Function"
+#define DP_PROP_IGNOREEMPTY "IgnoreEmptyRows"
+#define DP_PROP_ISDATALAYOUT "IsDataLayoutDimension"
+#define DP_PROP_ISVISIBLE "IsVisible"
+#define DP_PROP_ORIENTATION "Orientation"
+#define DP_PROP_REPEATIFEMPTY "RepeatIfEmpty"
+#define DP_PROP_ROWGRAND "RowGrand"
+#define DP_PROP_SHOWDETAILS "ShowDetails"
+#define DP_PROP_SHOWEMPTY "ShowEmpty"
+#define DP_PROP_SUBTOTALS "SubTotals"
+#define DP_PROP_USEDHIERARCHY "UsedHierarchy"
+#define DP_PROP_FILTER "Filter"
+#define DP_PROP_POSITION "Position"
+
+#define DBG_TRACESTR( x ) \
+ {\
+ ByteString aTemp( x , RTL_TEXTENCODING_UTF8 ); \
+ DBG_TRACE( aTemp.GetBuffer() );\
+ }
+
+class TypedStrData;
+class ScDPObject;
+
+class SC_DLLPUBLIC ScDPItemData
+{
+public:
+ enum { MK_VAL = 0x01, MK_DATA = MK_VAL<<1, MK_ERR = MK_DATA<<1, MK_DATE = MK_ERR<<1, MK_DATEPART = MK_DATE<<1 };
+private:
+ union
+ {
+ ULONG nNumFormat;
+ sal_Int32 mnDatePart;
+ };
+
+ String aString;
+ double fValue;
+ BYTE mbFlag;
+ //BOOL bHasValue: 1 ;
+ //BOOL bHasData: 1;
+ //BOOL bErr: 1;
+
+ friend class ScDPTableDataCache;
+public:
+ ScDPItemData() : nNumFormat( 0 ), fValue(0.0), mbFlag( 0 ){}
+ ScDPItemData( ULONG nNF, const String & rS, double fV, BYTE bF ):nNumFormat(nNF), aString(rS), fValue(fV), mbFlag( bF ){}
+ ScDPItemData( const String& rS, double fV = 0.0, BOOL bHV = FALSE, const ULONG nNumFormat = 0 , BOOL bData = TRUE) ;
+ ScDPItemData( ScDocument* pDoc, SCROW nRow, USHORT nCol, USHORT nDocTab );
+
+ void SetString( const String& rS ) { aString = rS; mbFlag &= ~(MK_VAL|MK_DATE); nNumFormat = 0; mbFlag |= MK_DATA; }
+// void SetValue ( double value , ULONG nNumFormat = 0 ) { bHasValue = TRUE; nNumFormat = 0;bHasData = TRUE; bDate = FALSE; fValue = value ;}
+ BOOL IsCaseInsEqual( const ScDPItemData& r ) const;
+
+ size_t Hash() const;
+
+ // exact equality
+ BOOL operator==( const ScDPItemData& r ) const;
+ // case insensitive equality
+ static sal_Int32 Compare( const ScDPItemData& rA, const ScDPItemData& rB );
+
+#ifdef DEBUG
+ void dump() const;
+#endif
+
+public:
+ BOOL IsHasData() const ;
+ BOOL IsHasErr() const ;
+ BOOL IsValue() const;
+ String GetString() const ;
+ double GetValue() const ;
+ ULONG GetNumFormat() const ;
+ BOOL HasStringData() const ;
+ BOOL IsDate() const;
+ BOOL HasDatePart() const;
+ void SetDate( BOOL b ) ;
+
+ TypedStrData* CreateTypeString( );
+ sal_uInt8 GetType() const;
+ BYTE & GetFlag() throw() { return mbFlag; }
+ const BYTE & GetFlag() const throw() { return const_cast<ScDPItemData*>(this)->GetFlag(); }
+};
+
+class SC_DLLPUBLIC ScDPItemDataPool
+{
+public:
+ // construct
+ ScDPItemDataPool(void);
+ ScDPItemDataPool(const ScDPItemDataPool& r);
+
+ virtual ~ScDPItemDataPool(void);
+ virtual const ScDPItemData* getData( sal_Int32 nId );
+ virtual sal_Int32 getDataId( const ScDPItemData& aData );
+ virtual sal_Int32 insertData( const ScDPItemData& aData );
+protected:
+ struct DataHashFunc : public std::unary_function< const ScDPItemData &, size_t >
+ {
+ size_t operator() (const ScDPItemData &rData) const { return rData.Hash(); }
+ };
+
+ typedef ::std::hash_multimap< ScDPItemData, sal_Int32, DataHashFunc > DataHash;
+
+ ::std::vector< ScDPItemData > maItems;
+ DataHash maItemIds;
+};
+
+class ScDPInfoWnd;
+class ScDocShell;
+class ScTabViewShell;
+namespace ScDPGlobal
+{
+// used for core data
+ String GetFieldFuncString( const String& rSourceName, USHORT &rFuncMask, BOOL bIsValue );
+ String GetFuncString( const String &rString, const USHORT nIndex );
+ com::sun::star::uno::Reference<com::sun::star::container::XNameAccess> DP_GetMembers( const com::sun::star::uno::Reference<
+ com::sun::star::sheet::XDimensionsSupplier>&rSrc, long nField );
+// common operation
+ String operator + ( const String & rL, const String &rR );
+ Rectangle operator *( const Rectangle &rLeft, const std::pair<double,double> & rRight );
+// used for DataPilot Panel
+ ScDPInfoWnd* GetDPInfoWnd( ScTabViewShell *pViewShell );
+ bool ChkDPTableOverlap( ScDocument *pDestDoc, std::list<ScDPObject> & rClipboard, SCCOL nClipStartCol, SCROW nClipStartRow, SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, USHORT nEndTab, BOOL bExcludeClip = FALSE );
+
+}
+#endif
diff --git a/sc/inc/dpgroup.hxx b/sc/inc/dpgroup.hxx
index 39770d2adffd..2a66f8b45555 100644
--- a/sc/inc/dpgroup.hxx
+++ b/sc/inc/dpgroup.hxx
@@ -34,7 +34,10 @@
#include "dptabdat.hxx"
#include "scdllapi.h"
-
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+#include "dpglobal.hxx"
+// End Comments
class ScDocument;
class SvNumberFormatter;
@@ -73,8 +76,11 @@ public:
sal_Int32 GetDatePart() const { return nDatePart; }
const ScDPNumGroupInfo& GetNumInfo() const { return aNumInfo; }
- void FillColumnEntries( TypedScStrCollection& rEntries, const TypedScStrCollection& rOriginal,
- SvNumberFormatter* pFormatter ) const;
+ // Wang Xu Ming -- 2009-9-8
+ // DataPilot Migration - Cache&&Performance
+ void FillColumnEntries( SCCOL nSourceDim, ScDPTableDataCache* pCahe , std::vector< SCROW >& rEntries,
+ const std::vector< SCROW >& rOriginal ) const;
+ // End Comments
};
// --------------------------------------------------------------------
@@ -108,8 +114,10 @@ class ScDPGroupDimension
String aGroupName;
ScDPDateGroupHelper* pDateHelper;
ScDPGroupItemVec aItems;
- mutable TypedScStrCollection* pCollection; // collection of item names (cached)
-
+ // Wang Xu Ming -- 2009-9-4
+ // DataPilot Migration - Cache&&Performance
+ mutable ::std::vector< SCROW > maMemberEntries;
+ // End Comments
public:
ScDPGroupDimension( long nSource, const String& rNewName );
ScDPGroupDimension( const ScDPGroupDimension& rOther );
@@ -122,9 +130,12 @@ public:
long GetSourceDim() const { return nSourceDim; }
long GetGroupDim() const { return nGroupDim; }
- const String& GetName() const { return aGroupName; }
+ const String& GetName() const { return aGroupName; }
- const TypedScStrCollection& GetColumnEntries( const TypedScStrCollection& rOriginal, ScDocument* pDoc ) const;
+// Wang Xu Ming -- 2009-9-2
+// DataPilot Migration - Cache&&Performance
+ const std::vector< SCROW >& GetColumnEntries( const ScDPCacheTable& rCacheTable, const std::vector< SCROW >& rOriginal ) const;
+// End Comments
const ScDPGroupItem* GetGroupForData( const ScDPItemData& rData ) const; // rData = entry in original dim.
const ScDPGroupItem* GetGroupForName( const ScDPItemData& rName ) const; // rName = entry in group dim.
const ScDPGroupItem* GetGroupByIndex( size_t nIndex ) const;
@@ -146,7 +157,10 @@ class SC_DLLPUBLIC ScDPNumGroupDimension
{
ScDPNumGroupInfo aGroupInfo; // settings
ScDPDateGroupHelper* pDateHelper;
- mutable TypedScStrCollection* pCollection; // collection of item names (cached)
+// Wang Xu Ming -- 2009-9-4
+// DataPilot Migration - Cache&&Performance
+ mutable ::std::vector< SCROW > maMemberEntries;
+// End Comments
mutable bool bHasNonInteger; // initialized in GetNumEntries
mutable sal_Unicode cDecSeparator; // initialized in GetNumEntries
@@ -158,14 +172,15 @@ public:
ScDPNumGroupDimension& operator=( const ScDPNumGroupDimension& rOther );
- const TypedScStrCollection& GetNumEntries( const TypedScStrCollection& rOriginal, ScDocument* pDoc ) const;
-
const ScDPNumGroupInfo& GetInfo() const { return aGroupInfo; }
bool HasNonInteger() const { return bHasNonInteger; }
sal_Unicode GetDecSeparator() const { return cDecSeparator; }
const ScDPDateGroupHelper* GetDateHelper() const { return pDateHelper; }
+ const std::vector< SCROW >& GetNumEntries( SCCOL nSourceDim, ScDPTableDataCache* pCache,
+ const std::vector< SCROW >& rOriginal ) const;
+
void MakeDateHelper( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart );
void DisposeData();
@@ -187,7 +202,11 @@ class ScDPGroupTableData : public ScDPTableData
ScDocument* pDoc;
StringHashSet aGroupNames;
- void FillGroupValues( ScDPItemData* pItemData, long nCount, const long* pDims );
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+ void FillGroupValues( SCROW* pItemDataIndex, long nCount, const long* pDims );
+ virtual long GetSourceDim( long nDim );
+// End Comments
void CopyFields(const ::std::vector<long>& rFieldDims, ::std::vector<long>& rNewFieldDims);
bool IsNumGroupDimension( long nDimension ) const;
@@ -208,11 +227,18 @@ public:
ScDocument* GetDocument() { return pDoc; }
virtual long GetColumnCount();
- virtual const TypedScStrCollection& GetColumnEntries(long nColumn);
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+ virtual long GetMembersCount( long nDim );
+ virtual const std::vector< SCROW >& GetColumnEntries( long nColumn ) ;
+ virtual const ScDPItemData* GetMemberById( long nDim, long nId);
+ virtual long Compare( long nDim, long nDataId1, long nDataId2);
+
+// End Comments
virtual String getDimensionName(long nColumn);
virtual BOOL getIsDataLayoutDimension(long nColumn);
virtual BOOL IsDateDimension(long nDim);
- virtual UINT32 GetNumberFormat(long nDim);
+ virtual ULONG GetNumberFormat(long nDim);
virtual void DisposeData();
virtual void SetEmptyFlags( BOOL bIgnoreEmptyRows, BOOL bRepeatIfEmpty );
diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index 917d62f38bfe..65e89ec75d41 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -115,8 +115,18 @@ private:
SC_DLLPRIVATE ScDPTableData* GetTableData();
SC_DLLPRIVATE void CreateObjects();
SC_DLLPRIVATE void CreateOutput();
+ BOOL bRefresh;
+ long mnCacheId;
public:
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ inline void SetRefresh() { bRefresh = TRUE; }
+ const ScDPTableDataCache* GetCache() const;
+ long GetCacheId() const;
+ void SetCacheId( long nCacheId );
+ ULONG RefreshCache();
+ // End Comments
ScDPObject( ScDocument* pD );
ScDPObject(const ScDPObject& r);
virtual ~ScDPObject();
@@ -251,19 +261,6 @@ public:
PivotField* pRefPageFields = NULL, SCSIZE nRefPageCount = 0 );
};
-// ============================================================================
-
-struct ScDPCacheCell
-{
- sal_Int32 mnStrId;
- sal_uInt8 mnType;
- double mfValue;
- bool mbNumeric;
-
- ScDPCacheCell();
- ScDPCacheCell(const ScDPCacheCell& r);
- ~ScDPCacheCell();
-};
// ============================================================================
@@ -271,20 +268,6 @@ class ScDPCollection : public ScCollection
{
private:
ScDocument* pDoc;
- ScSimpleSharedString maSharedString;
-
- struct CacheCellHash
- {
- size_t operator()(const ScDPCacheCell* pCell) const;
- };
- struct CacheCellEqual
- {
- bool operator()(const ScDPCacheCell* p1, const ScDPCacheCell* p2) const;
- };
- typedef ::std::hash_set<ScDPCacheCell*, CacheCellHash, CacheCellEqual> CacheCellPoolType;
-
- CacheCellPoolType maCacheCellPool;
-
public:
ScDPCollection(ScDocument* pDocument);
ScDPCollection(const ScDPCollection& r);
@@ -303,15 +286,10 @@ public:
String CreateNewName( USHORT nMin = 1 ) const;
- ScSimpleSharedString& GetSharedString();
-
void FreeTable(ScDPObject* pDPObj);
SC_DLLPUBLIC bool InsertNewTable(ScDPObject* pDPObj);
bool HasDPTable(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
-
- ScDPCacheCell* getCacheCellFromPool(const ScDPCacheCell& rCell);
- void clearCacheCellPool();
};
diff --git a/sc/inc/dpsave.hxx b/sc/inc/dpsave.hxx
index 587e23d8109b..bfff0b97a168 100644
--- a/sc/inc/dpsave.hxx
+++ b/sc/inc/dpsave.hxx
@@ -88,6 +88,9 @@ public:
};
+bool operator == (const ::com::sun::star::sheet::DataPilotFieldSortInfo &l, const ::com::sun::star::sheet::DataPilotFieldSortInfo &r );
+bool operator == (const ::com::sun::star::sheet::DataPilotFieldAutoShowInfo &l, const ::com::sun::star::sheet::DataPilotFieldAutoShowInfo &r );
+bool operator == (const ::com::sun::star::sheet::DataPilotFieldReference &l, const ::com::sun::star::sheet::DataPilotFieldReference &r );
class SC_DLLPUBLIC ScDPSaveDimension
{
private:
@@ -175,6 +178,9 @@ public:
void WriteToSource( const com::sun::star::uno::Reference<
com::sun::star::uno::XInterface>& xDim );
+ void Refresh( const com::sun::star::uno::Reference<
+ com::sun::star::sheet::XDimensionsSupplier>& xSource ,
+ const std::list<String> & deletedDims);
void UpdateMemberVisibility(const ::std::hash_map< ::rtl::OUString, bool, ::rtl::OUStringHash>& rData);
@@ -193,6 +199,10 @@ private:
USHORT nRepeatEmptyMode;
BOOL bFilterButton; // not passed to DataPilotSource
BOOL bDrillDown; // not passed to DataPilotSource
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ long mnCacheId;
+ // End Comments
/** if true, all dimensions already have all of their member instances
* created. */
@@ -248,10 +258,15 @@ public:
BOOL GetDrillDown() const { return bDrillDown; }
void WriteToSource( const com::sun::star::uno::Reference<
+ com::sun::star::sheet::XDimensionsSupplier>& xSource );
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ void Refresh( const com::sun::star::uno::Reference<
com::sun::star::sheet::XDimensionsSupplier>& xSource );
-
BOOL IsEmpty() const;
-
+ inline long GetCacheId() const{ return mnCacheId; }
+ inline void SetCacheId( long nCacheId ){ mnCacheId = nCacheId; }
+ // End Comments
const ScDPDimensionSaveData* GetExistingDimensionData() const { return pDimensionData; }
SC_DLLPUBLIC ScDPDimensionSaveData* GetDimensionData(); // create if not there
void SetDimensionData( const ScDPDimensionSaveData* pNew ); // copied
diff --git a/sc/inc/dpsdbtab.hxx b/sc/inc/dpsdbtab.hxx
index 1f980bdec3bf..732e3d30e8df 100644
--- a/sc/inc/dpsdbtab.hxx
+++ b/sc/inc/dpsdbtab.hxx
@@ -50,28 +50,32 @@ struct ScImportSourceDesc
USHORT nType; // enum DataImportMode
BOOL bNative;
+ ScImportSourceDesc() : nType(0), bNative(FALSE) {}
+
BOOL operator== ( const ScImportSourceDesc& rOther ) const
{ return aDBName == rOther.aDBName &&
aObject == rOther.aObject &&
nType == rOther.nType &&
bNative == rOther.bNative; }
-};
-class ScDatabaseDPData_Impl;
+ // Wang Xu Ming -- 2009-9-15
+ // DataPilot Migration - Cache&&Performance
+ ScDPTableDataCache* GetExistDPObjectCache( ScDocument* pDoc ) const;
+ ScDPTableDataCache* CreateCache( ScDocument* pDoc , long nID ) const;
+ ScDPTableDataCache* GetCache( ScDocument* pDoc, long nID ) const;
+ long GetCacheId( ScDocument* pDoc, long nID ) const;
+ // End Comments
+};
class ScDatabaseDPData : public ScDPTableData
{
private:
- ScDatabaseDPData_Impl* pImpl;
-
- BOOL OpenDatabase();
-
+ ScDPCacheTable aCacheTable;
public:
- ScDatabaseDPData(ScDocument* pDoc, const ScImportSourceDesc& rImport);
+ ScDatabaseDPData(ScDocument* pDoc, const ScImportSourceDesc& rImport, long nCacheId = -1);
virtual ~ScDatabaseDPData();
virtual long GetColumnCount();
- virtual const TypedScStrCollection& GetColumnEntries(long nColumn);
virtual String getDimensionName(long nColumn);
virtual BOOL getIsDataLayoutDimension(long nColumn);
virtual BOOL IsDateDimension(long nDim);
diff --git a/sc/inc/dpshttab.hxx b/sc/inc/dpshttab.hxx
index a0e67371eff1..a8d80072c68a 100644
--- a/sc/inc/dpshttab.hxx
+++ b/sc/inc/dpshttab.hxx
@@ -41,8 +41,10 @@ namespace com { namespace sun { namespace star { namespace sheet {
}}}}
class ScDPDimension;
-struct ScDPItemData;
-
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+class ScDPItemData;
+// End Comments
// --------------------------------------------------------------------
//
// implementation of ScDPTableData with sheet data
@@ -56,25 +58,38 @@ struct ScSheetSourceDesc
BOOL operator== ( const ScSheetSourceDesc& rOther ) const
{ return aSourceRange == rOther.aSourceRange &&
aQueryParam == rOther.aQueryParam; }
+// Wang Xu Ming - DataPilot migration
+// Buffer&&Performance
+ ScDPTableDataCache* CreateCache( ScDocument* pDoc, long nID = -1) const;
+ ULONG CheckValidate( ScDocument* pDoc ) const;
+ ScDPTableDataCache* GetCache( ScDocument* pDoc, long nID ) const;
+ ScDPTableDataCache* GetExistDPObjectCache ( ScDocument* pDoc ) const;
+ long GetCacheId( ScDocument* pDoc, long nID ) const;
+
+// End Comments
};
-class ScSheetDPData_Impl;
-
class SC_DLLPUBLIC ScSheetDPData : public ScDPTableData
{
private:
- ScSheetDPData_Impl* pImpl;
+ ScQueryParam aQuery;
+ BOOL* pSpecial;
+ BOOL bIgnoreEmptyRows;
+ BOOL bRepeatIfEmpty;
+
+ ScDPCacheTable aCacheTable;
public:
- ScSheetDPData( ScDocument* pD, const ScSheetSourceDesc& rDesc );
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ ScSheetDPData( ScDocument* pD, const ScSheetSourceDesc& rDesc, long nCacheId = -1 );
virtual ~ScSheetDPData();
-
+ // End Comments
virtual long GetColumnCount();
- virtual const TypedScStrCollection& GetColumnEntries(long nColumn);
virtual String getDimensionName(long nColumn);
virtual BOOL getIsDataLayoutDimension(long nColumn);
virtual BOOL IsDateDimension(long nDim);
- virtual UINT32 GetNumberFormat(long nDim);
+ virtual ULONG GetNumberFormat(long nDim);
virtual void DisposeData();
virtual void SetEmptyFlags( BOOL bIgnoreEmptyRows, BOOL bRepeatIfEmpty );
diff --git a/sc/inc/dptabdat.hxx b/sc/inc/dptabdat.hxx
index 43c719e9ee16..6323434ca4ad 100644
--- a/sc/inc/dptabdat.hxx
+++ b/sc/inc/dptabdat.hxx
@@ -31,7 +31,10 @@
#include "address.hxx"
#include "dpoutput.hxx"
#include "dpcachetable.hxx"
-
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+#include "dptablecache.hxx"
+// End Comments
#include <tools/string.hxx>
#include <vector>
@@ -43,8 +46,6 @@ namespace com { namespace sun { namespace star { namespace sheet {
struct DataPilotFieldFilter;
}}}}
-class TypedScStrCollection;
-class ScSimpleSharedString;
// -----------------------------------------------------------------------
@@ -71,28 +72,6 @@ class ScSimpleSharedString;
// base class ScDPTableData to allow implementation with tabular data
// by deriving only of this
//
-
-struct ScDPItemData
-{
- String aString;
- double fValue;
- BOOL bHasValue;
-
- ScDPItemData() : fValue(0.0), bHasValue(FALSE) {}
- ScDPItemData( const String& rS, double fV = 0.0, BOOL bHV = FALSE ) :
- aString(rS), fValue(fV), bHasValue( bHV ) {}
-
- void SetString( const String& rS ) { aString = rS; bHasValue = FALSE; }
- BOOL IsCaseInsEqual( const ScDPItemData& r ) const;
-
- size_t Hash() const;
-
- // exact equality
- BOOL operator==( const ScDPItemData& r ) const;
- // case insensitive equality
- static sal_Int32 Compare( const ScDPItemData& rA, const ScDPItemData& rB );
-};
-
#define SC_VALTYPE_EMPTY 0
#define SC_VALTYPE_VALUE 1
#define SC_VALTYPE_STRING 2
@@ -113,15 +92,18 @@ class ScDPInitState;
class ScDPResultMember;
class ScDocument;
-class ScDPTableData
+ class SC_DLLPUBLIC ScDPTableData
{
// cached data for GetDatePart
long nLastDateVal;
long nLastHier;
long nLastLevel;
long nLastRet;
- ScSimpleSharedString& mrSharedString;
-
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ long mnCacheId;
+ const ScDocument* mpDoc;
+ // End Comments
public:
/** This structure stores dimension information used when calculating
@@ -147,7 +129,10 @@ public:
CalcInfo();
};
- ScDPTableData(ScDocument* pDoc);
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ ScDPTableData(ScDocument* pDoc, long nCacheId );
+ // End Comments
virtual ~ScDPTableData();
long GetDatePart( long nDateVal, long nHierarchy, long nLevel );
@@ -156,11 +141,16 @@ public:
//! or separate Str and ValueCollection
virtual long GetColumnCount() = 0;
- virtual const TypedScStrCollection& GetColumnEntries(long nColumn) = 0;
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ virtual const std::vector< SCROW >& GetColumnEntries( long nColumn ) ;
+ long GetCacheId() const;
+ // End Comments
virtual String getDimensionName(long nColumn) = 0;
virtual BOOL getIsDataLayoutDimension(long nColumn) = 0;
virtual BOOL IsDateDimension(long nDim) = 0;
- virtual UINT32 GetNumberFormat(long nDim);
+ virtual ULONG GetNumberFormat(long nDim);
+ virtual UINT32 GetNumberFormatByIdx( NfIndexTableOffset );
virtual void DisposeData() = 0;
virtual void SetEmptyFlags( BOOL bIgnoreEmptyRows, BOOL bRepeatIfEmpty ) = 0;
@@ -176,23 +166,33 @@ public:
// overloaded in ScDPGroupTableData:
virtual BOOL IsBaseForGroup(long nDim) const;
- virtual long GetGroupBase(long nGroupDim) const;
+ virtual long GetGroupBase(long nGroupDim) const;
virtual BOOL IsNumOrDateGroup(long nDim) const;
virtual BOOL IsInGroup( const ScDPItemData& rGroupData, long nGroupIndex,
const ScDPItemData& rBaseData, long nBaseIndex ) const;
virtual BOOL HasCommonElement( const ScDPItemData& rFirstData, long nFirstIndex,
const ScDPItemData& rSecondData, long nSecondIndex ) const;
- ScSimpleSharedString& GetSharedString();
-
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ virtual long GetMembersCount( long nDim );
+ virtual const ScDPItemData* GetMemberByIndex( long nDim, long nIndex );
+ virtual const ScDPItemData* GetMemberById( long nDim, long nId);
+ virtual SCROW GetIdOfItemData( long nDim, const ScDPItemData& rData );
+ virtual long GetSourceDim( long nDim );
+ virtual long Compare( long nDim, long nDataId1, long nDataId2);
+ // End Comments
protected:
/** This structure stores vector arrays that hold intermediate data for
each row during cache table iteration. */
struct CalcRowData
{
- ::std::vector<ScDPItemData> aColData;
- ::std::vector<ScDPItemData> aRowData;
- ::std::vector<ScDPItemData> aPageData;
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ ::std::vector< SCROW > aColData;
+ ::std::vector< SCROW > aRowData;
+ ::std::vector< SCROW > aPageData;
+ // End Comments
::std::vector<ScDPValueData> aValues;
};
@@ -201,10 +201,11 @@ protected:
void CalcResultsFromCacheTable(const ScDPCacheTable& rCacheTable, CalcInfo& rInfo, bool bAutoShow);
private:
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
void GetItemData(const ScDPCacheTable& rCacheTable, sal_Int32 nRow,
- const ::std::vector<long>& rDims, ::std::vector<ScDPItemData>& rItemData);
+ const ::std::vector<long>& rDims, ::std::vector< SCROW >& rItemData);
+ // End Comments
};
-
-
#endif
diff --git a/sc/inc/dptablecache.hxx b/sc/inc/dptablecache.hxx
new file mode 100644
index 000000000000..953c793093be
--- /dev/null
+++ b/sc/inc/dptablecache.hxx
@@ -0,0 +1,122 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright IBM Corporation 2009.
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: dptablecache.hxx,v $
+ * $Revision: 1.0 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DPTABLECACHE_HXX
+#define DPTABLECACHE_HXX
+// Wang Xu Ming -- 12/21/2008
+// Add Data Cache Support.
+#ifndef SC_SCGLOB_HXX
+#include "global.hxx"
+#endif
+//Added by PengYunQuan for SODC_16015
+#include <svl/zforlist.hxx>
+//end
+#include <vector>
+#include "dpglobal.hxx"
+
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+
+class ScDPTableDataCache;
+class TypedStrData;
+struct ScQueryParam;
+
+// --------------------------------------------------------------------
+//
+// base class ScDPTableData to allow implementation with tabular data
+// by deriving only of this
+//
+
+class SC_DLLPUBLIC ScDPTableDataCache
+{
+ long mnID;
+ ScDocument* mpDoc;
+
+ long mnColumnCount; // Column count
+
+ std::vector<ScDPItemData*>* mpTableDataValues; //Data Pilot Table's index - value map
+ std::vector<SCROW>* mpSourceData; //Data Pilot Table's Source data
+ std::vector<SCROW>* mpGlobalOrder; //Sorted members index
+ std::vector<SCROW>* mpIndexOrder; //Index the sorted number
+ std::vector<ScDPItemData*> mrLabelNames; //Source Label data
+ std::vector<BOOL> mbEmptyRow; //If empty row?
+ mutable ScDPItemDataPool maAdditionalDatas;
+public:
+ SCROW GetOrder( long nDim, SCROW nIndex ) const;
+ SCROW GetIdByItemData( long nDim, String sItemData ) const;
+ SCROW GetIdByItemData( long nDim, const ScDPItemData& rData ) const;
+
+ SCROW GetAdditionalItemID ( String sItemData );
+ SCROW GetAdditionalItemID( const ScDPItemData& rData );
+
+ SCCOL GetDimensionIndex( String sName) const;
+ const ScDPItemData* GetSortedItemData( SCCOL nDim, SCROW nOrder ) const;
+ ULONG GetNumType ( ULONG nFormat ) const;
+ ULONG GetNumberFormat( long nDim ) const;
+ BOOL IsDateDimension( long nDim ) const ;
+ ULONG GetDimNumType( SCCOL nDim) const;
+ SCROW GetDimMemberCount( SCCOL nDim ) const;
+
+ SCROW GetSortedItemDataId( SCCOL nDim, SCROW nOrder ) const;
+ const std::vector<ScDPItemData*>& GetDimMemberValues( SCCOL nDim )const;
+ void SetId( long nId ){ mnID = nId;}
+ void AddRow( ScDPItemData* pRow, USHORT nCount );
+ bool InitFromDoc( ScDocument* pDoc, const ScRange& rRange );
+ bool InitFromDataBase (const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& xRowSet, const Date& rNullDate);
+
+ SCROW GetRowCount() const;
+ SCROW GetItemDataId( USHORT nDim, SCROW nRow, BOOL bRepeatIfEmpty ) const;
+ String GetDimensionName( USHORT nColumn ) const;
+ bool IsEmptyMember( SCROW nRow, USHORT nColumn ) const;
+ bool IsRowEmpty( SCROW nRow ) const;
+ bool IsValid() const;
+ bool ValidQuery( SCROW nRow, const ScQueryParam& rQueryParam, BOOL* pSpecial );
+
+ ScDocument* GetDoc() const;//ms-cache-core
+ long GetColumnCount() const;
+ long GetId() const;
+
+ const ScDPItemData* GetItemDataById( long nDim, SCROW nId ) const;
+
+ BOOL operator== ( const ScDPTableDataCache& r ) const;
+
+//construction
+ ScDPTableDataCache( ScDocument* pDoc );
+//deconstruction
+ virtual ~ScDPTableDataCache();
+
+protected:
+private:
+ void AddLabel( ScDPItemData* pData);
+ BOOL AddData( long nDim, ScDPItemData* itemData );
+};
+
+#endif //DPTABLECACHE_HXX
diff --git a/sc/inc/dptabres.hxx b/sc/inc/dptabres.hxx
index d4e8807d4a3b..e35975ab170f 100644
--- a/sc/inc/dptabres.hxx
+++ b/sc/inc/dptabres.hxx
@@ -57,8 +57,10 @@ class ScDPResultMember;
class ScDPResultVisibilityData;
struct ScDPValueData;
-struct ScDPItemData;
-
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+class ScDPItemData;
+// End Comments
//
// Member names that are being processed for InitFrom/LateInitFrom
// (needed for initialization of grouped items)
@@ -67,21 +69,26 @@ struct ScDPItemData;
class ScDPInitState
{
long* pIndex; // array
- ScDPItemData* pData; // array
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+ SCROW* pData; // array
+ // End Comments
long nCount;
public:
ScDPInitState();
~ScDPInitState();
- void AddMember( long nSourceIndex, const ScDPItemData& rName );
+ void AddMember( long nSourceIndex,SCROW nMember);
void RemoveMember();
long GetCount() const { return nCount; }
const long* GetSource() const { return pIndex; }
- const ScDPItemData* GetNames() const { return pData; }
-
- const ScDPItemData* GetNameForIndex( long nIndexValue ) const;
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+ const SCROW* GetNameIds() const { return pData; }
+ const SCROW GetNameIdForIndex( long nIndexValue ) const;
+// End Comments
};
typedef ::std::vector<sal_Int32> ScMemberSortOrder;
@@ -230,6 +237,68 @@ class ScDPDataMember;
#define SC_DPMEASURE_ALL -1
#define SC_DPMEASURE_ANY -2
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+
+struct MemberHashIndexFunc : public std::unary_function< const SCROW &, size_t >
+{
+ size_t operator() (const SCROW &rDataIndex) const { return rDataIndex; }
+};
+
+class ScDPParentDimData
+{
+public:
+ const SCROW mnOrder; //! Ref
+ const ScDPDimension* mpParentDim; //! Ref
+ const ScDPLevel* mpParentLevel; //! Ref
+ const ScDPMember* mpMemberDesc; //! Ref
+
+ ScDPParentDimData():mnOrder(-1), mpParentDim( NULL), mpParentLevel( NULL ), mpMemberDesc( NULL ){}
+ ScDPParentDimData( const SCROW nIndex, ScDPDimension* pDim, const ScDPLevel* pLev, const ScDPMember* pMember ): mnOrder( nIndex ), mpParentDim( pDim), mpParentLevel( pLev ), mpMemberDesc( pMember ){}
+};
+
+typedef std::vector <ScDPParentDimData *> DimMemberArray;
+typedef std::hash_map < SCROW, ScDPParentDimData *, MemberHashIndexFunc> DimMemberHash;
+
+class ResultMembers
+{
+ DimMemberHash maMemberHash;
+ BOOL mbHasHideDetailsMember;
+public:
+ ScDPParentDimData* FindMember( const SCROW& nIndex ) const;
+ void InsertMember( ScDPParentDimData* pNew );
+ BOOL IsHasHideDetailsMembers() const { return mbHasHideDetailsMember; }
+ void SetHasHideDetailsMembers( BOOL b ) { mbHasHideDetailsMember=b; }
+ ResultMembers();
+ virtual ~ResultMembers();
+};
+
+class LateInitParams
+{
+private:
+ const ::std::vector<ScDPDimension*>& mppDim;
+ const ::std::vector<ScDPLevel*>& mppLev;
+
+ BOOL mbRow;
+ BOOL mbInitChild;
+ BOOL mbAllChildren;
+public:
+ LateInitParams( const ::std::vector<ScDPDimension*>& ppDim, const ::std::vector<ScDPLevel*>& ppLev,
+ BOOL bRow, BOOL bInitChild = TRUE , BOOL bAllChildren = FALSE);
+ ~LateInitParams();
+
+ void SetInitChild( BOOL b ) { mbInitChild = b; }
+ void SetInitAllChildren( BOOL b ) { mbAllChildren = b; }
+
+ inline ScDPDimension* GetDim( size_t nPos ) const { return mppDim[nPos];}
+ inline ScDPLevel* GetLevel( size_t nPos ) const { return mppLev[nPos];}
+
+ inline BOOL GetInitChild() const {return mbInitChild; }
+ inline BOOL GetInitAllChild() const { return mbAllChildren; }
+ inline BOOL IsRow() const { return mbRow; }
+ BOOL IsEnd( size_t nPos ) const ;
+};
+// End Comments
class ScDPResultData
{
@@ -247,7 +316,7 @@ private:
BOOL bDataAtRow;
//! add "displayed values" settings
-
+ mutable std::vector< ResultMembers* > mpDimMembers;
public:
ScDPResultData( ScDPSource* pSrc ); //! Ref
~ScDPResultData();
@@ -278,11 +347,18 @@ public:
BOOL IsBaseForGroup( long nDim ) const; // any group
long GetGroupBase( long nGroupDim ) const;
BOOL IsNumOrDateGroup( long nDim ) const;
+ // Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
BOOL IsInGroup( const ScDPItemData& rGroupData, long nGroupIndex,
- const ScDPItemData& rBaseData, long nBaseIndex ) const;
- BOOL HasCommonElement( const ScDPItemData& rFirstData, long nFirstIndex,
+ long nBaseDataId, long nBaseIndex ) const;
+ BOOL IsInGroup( SCROW nGroupDataId, long nGroupIndex,
+ const ScDPItemData& rBaseData, long nBaseIndex ) const;
+ BOOL HasCommonElement( SCROW nFirstDataId, long nFirstIndex,
const ScDPItemData& rSecondData, long nSecondIndex ) const;
+ ResultMembers* GetDimResultMembers( long nDim , ScDPDimension* pDim , ScDPLevel* pLevel) const ;
+
+// End Comments
const ScDPSource* GetSource() const;
};
@@ -291,9 +367,10 @@ class ScDPResultMember
{
private:
const ScDPResultData* pResultData;
- const ScDPDimension* pParentDim; //! Ref
- const ScDPLevel* pParentLevel; //! Ref
- const ScDPMember* pMemberDesc; //! Ref
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ ScDPParentDimData aParentDimData;
+ // End Comments
ScDPResultDimension* pChildDimension;
ScDPDataMember* pDataRoot;
BOOL bHasElements;
@@ -303,21 +380,30 @@ private:
BOOL bAutoHidden;
ScDPAggData aColTotal; // to store column totals
+ USHORT nMemberStep; // step to show details
public:
- ScDPResultMember( const ScDPResultData* pData, const ScDPDimension* pDim,
- const ScDPLevel* pLev, const ScDPMember* pDesc,
- BOOL bForceSub ); //! Ref
- ~ScDPResultMember();
-
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ ScDPResultMember( const ScDPResultData* pData, const ScDPParentDimData& rParentDimData,
+ BOOL bForceSub ); //! Ref
+ ScDPResultMember( const ScDPResultData* pData, BOOL bForceSub );
+ // End Comments
+ ~ScDPResultMember();
+
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
void InitFrom( const ::std::vector<ScDPDimension*>& ppDim,
- const ::std::vector<ScDPLevel*>& ppLev,
- size_t nPos,
- ScDPInitState& rInitState );
- void LateInitFrom( const ::std::vector<ScDPDimension*>& ppDim,
- const ::std::vector<ScDPLevel*>& ppLev,
- const ::std::vector<ScDPItemData>& pItemData,
- size_t nPos,
- ScDPInitState& rInitState );
+ const ::std::vector<ScDPLevel*>& ppLev,
+ size_t nPos,
+ ScDPInitState& rInitState,
+ BOOL bInitChild = TRUE );
+ void LateInitFrom(
+ LateInitParams& rParams,
+ const ::std::vector< SCROW >& pItemData,
+ size_t nPos,
+ ScDPInitState& rInitState);
+ void CheckShowEmpty( BOOL bShow = FALSE );
+ // End Comments
String GetName() const;
void FillItemData( ScDPItemData& rData ) const;
BOOL IsValid() const;
@@ -329,17 +415,22 @@ public:
// BOOL SubTotalEnabled() const;
long GetSubTotalCount( long* pUserSubStart = NULL ) const;
- BOOL IsNamedItem( const ScDPItemData& r ) const;
- bool IsValidEntry( const ::std::vector<ScDPItemData>& aMembers ) const;
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ BOOL IsNamedItem( SCROW nIndex ) const;
+ bool IsValidEntry( const ::std::vector< SCROW >& aMembers ) const;
+ // End Comments
void SetHasElements() { bHasElements = TRUE; }
void SetAutoHidden() { bAutoHidden = TRUE; }
- void ProcessData( const ::std::vector<ScDPItemData>& aChildMembers,
- const ScDPResultDimension* pDataDim,
- const ::std::vector<ScDPItemData>& aDataMembers,
- const ::std::vector<ScDPValueData>& aValues );
-
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ void ProcessData( const ::std::vector<SCROW>& aChildMembers,
+ const ScDPResultDimension* pDataDim,
+ const ::std::vector<SCROW>& aDataMembers,
+ const ::std::vector<ScDPValueData>& aValues );
+ // End Comments
void FillMemberResults( com::sun::star::uno::Sequence<
com::sun::star::sheet::MemberResult>* pSequences,
long& rPos, long nMeasure, BOOL bRoot,
@@ -369,9 +460,15 @@ public:
ScDPDataMember* GetDataRoot() const { return pDataRoot; }
- const ScDPDimension* GetParentDim() const { return pParentDim; } //! Ref
- const ScDPLevel* GetParentLevel() const { return pParentLevel; } //! Ref
-
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ const ScDPDimension* GetParentDim() const { return aParentDimData.mpParentDim; } //! Ref
+ const ScDPLevel* GetParentLevel() const { return aParentDimData.mpParentLevel; } //! Ref
+ const ScDPMember* GetDPMember()const { return aParentDimData.mpMemberDesc; } //! Ref
+ inline SCROW GetOrder() const { return aParentDimData.mnOrder; } //! Ref
+ inline BOOL IsRoot() const { return GetParentLevel() == NULL; }
+ SCROW GetDataId( ) const ;
+ // End Comments
ScDPAggData* GetColTotal( long nMeasure ) const;
void FillVisibilityData(ScDPResultVisibilityData& rData) const;
@@ -397,13 +494,17 @@ public:
BOOL IsVisible() const;
BOOL HasData( long nMeasure, const ScDPSubTotalState& rSubState ) const;
- BOOL IsNamedItem( const ScDPItemData& r ) const;
-
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ BOOL IsNamedItem( SCROW r ) const;
+ // End Comments
BOOL HasHiddenDetails() const;
- void ProcessData( const ::std::vector<ScDPItemData>& aChildMembers, const ::std::vector<ScDPValueData>& aValues,
- const ScDPSubTotalState& rSubState );
-
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ void ProcessData( const ::std::vector< SCROW >& aChildMembers, const ::std::vector<ScDPValueData>& aValues,
+ const ScDPSubTotalState& rSubState );
+ // End Comments
BOOL HasError( long nMeasure, const ScDPSubTotalState& rSubState ) const;
double GetAggregate( long nMeasure, const ScDPSubTotalState& rSubState ) const;
const ScDPAggData* GetConstAggData( long nMeasure, const ScDPSubTotalState& rSubState ) const;
@@ -443,15 +544,13 @@ SV_DECL_PTRARR_DEL(ScDPDataMembers, ScDPDataMemberPtr, SC_DP_RES_GROW, SC_DP_RES
class ScDPResultDimension
{
public :
- struct MemberHashFunc : public std::unary_function< const ScDPItemData &, size_t >
- {
- size_t operator() (const ScDPItemData &rData) const { return rData.Hash(); }
- };
- typedef std::vector <ScDPResultMember *> MemberArray;
- typedef std::hash_map <ScDPItemData, ScDPResultMember *, MemberHashFunc> MemberHash;
-
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ typedef std::vector <ScDPResultMember *> MemberArray;
+ typedef std::map < SCROW , ScDPResultMember *> MemberHash;
+ // End Comments
private:
- const ScDPResultData* pResultData;
+ const ScDPResultData* pResultData;
MemberArray maMemberArray;
MemberHash maMemberHash;
BOOL bInitialized;
@@ -466,31 +565,47 @@ private:
long nAutoMeasure;
long nAutoCount;
- ScDPResultMember* FindMember( const ScDPItemData& rData ) const;
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ ScDPResultMember* FindMember( SCROW iData ) const;
+ ScDPResultMember* AddMember( const ScDPParentDimData& aData );
+ ScDPResultMember* InsertMember( ScDPParentDimData* pMemberData );
+ ResultMembers* GetResultMember( ScDPDimension* pDim, ScDPLevel* pLevel );
+ void InitWithMembers( LateInitParams& rParams,
+ const ::std::vector< SCROW >& pItemData,
+ size_t nPos,
+ ScDPInitState& rInitState );
+ // End Comments
public:
- ScDPResultDimension( const ScDPResultData* pData );
- ~ScDPResultDimension();
+ ScDPResultDimension( const ScDPResultData* pData );
+ ~ScDPResultDimension();
// allocates new members
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
void InitFrom( const ::std::vector<ScDPDimension*>& ppDim,
- const ::std::vector<ScDPLevel*>& ppLev,
- size_t nPos,
- ScDPInitState& rInitState );
- void LateInitFrom( const ::std::vector<ScDPDimension*>& ppDim,
- const ::std::vector<ScDPLevel*>& ppLev,
- const ::std::vector<ScDPItemData>& pItemData,
- size_t nPos,
- ScDPInitState& rInitState );
-
+ const ::std::vector<ScDPLevel*>& ppLev,
+ size_t nPos,
+ ScDPInitState& rInitState , BOOL bInitChild = TRUE );
+ void LateInitFrom( LateInitParams& rParams,
+ const ::std::vector< SCROW >& pItemData,
+ size_t nPos,
+ ScDPInitState& rInitState );
+ void CheckShowEmpty( BOOL bShow = FALSE );
+
+ // End Comments
long GetSize(long nMeasure) const;
- bool IsValidEntry( const ::std::vector<ScDPItemData>& aMembers ) const;
- // modifies existing members, allocates data dimensions
- void ProcessData( const ::std::vector<ScDPItemData>& aMembers,
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ bool IsValidEntry( const ::std::vector<SCROW>& aMembers ) const;
+
+ // modifies existing members, allocates data dimensions
+ void ProcessData( const ::std::vector<SCROW>& aMembers,
const ScDPResultDimension* pDataDim,
- const ::std::vector<ScDPItemData>& aDataMembers,
+ const ::std::vector<SCROW>& aDataMembers,
const ::std::vector<ScDPValueData>& aValues ) const; //! Test
-
+ // End Comments
void FillMemberResults( com::sun::star::uno::Sequence<
com::sun::star::sheet::MemberResult>* pSequences,
long nStart, long nMeasure );
@@ -560,9 +675,11 @@ public:
~ScDPDataDimension();
void InitFrom( const ScDPResultDimension* pDim ); // recursive
- void ProcessData( const ::std::vector<ScDPItemData>& aDataMembers, const ::std::vector<ScDPValueData>& aValues,
- const ScDPSubTotalState& rSubState );
-
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ void ProcessData( const ::std::vector< SCROW >& aDataMembers, const ::std::vector<ScDPValueData>& aValues,
+ const ScDPSubTotalState& rSubState );
+ // End Comments
void FillDataRow( const ScDPResultDimension* pRefDim,
com::sun::star::uno::Sequence<com::sun::star::sheet::DataResult>& rSequence,
long nCol, long nMeasure, BOOL bIsSubTotalRow,
@@ -596,7 +713,10 @@ public:
class ScDPResultVisibilityData
{
public:
- ScDPResultVisibilityData(ScSimpleSharedString& rSharedString, ScDPSource* pSource);
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ ScDPResultVisibilityData( ScDPSource* pSource);
+ // End Comments
~ScDPResultVisibilityData();
void addVisibleMember(const String& rDimName, const ScDPItemData& rMemberItem);
@@ -611,7 +731,6 @@ private:
typedef ::std::hash_map<String, VisibleMemberType, ScStringHashCode> DimMemberType;
DimMemberType maDimensions;
- ScSimpleSharedString& mrSharedString;
ScDPSource* mpSource;
};
diff --git a/sc/inc/dptabsrc.hxx b/sc/inc/dptabsrc.hxx
index d2884281e1b8..18210f38e80e 100644
--- a/sc/inc/dptabsrc.hxx
+++ b/sc/inc/dptabsrc.hxx
@@ -30,6 +30,10 @@
#include <vector>
#include <hash_map>
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+#include <list>
+// End Comments
#include <memory>
#include <tools/string.hxx>
#include <tools/list.hxx>
@@ -57,7 +61,10 @@
#include <cppuhelper/implbase3.hxx>
#include <cppuhelper/implbase5.hxx>
#include <cppuhelper/implbase6.hxx>
-
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+#include "dpglobal.hxx"
+// End Comments
#include "dptabdat.hxx"
namespace com { namespace sun { namespace star {
@@ -71,7 +78,10 @@ namespace com { namespace sun { namespace star {
class ScDPResultMember;
class ScDPResultData;
-struct ScDPItemData;
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+class ScDPItemData;
+// End Comments
class ScDPTableData;
// ------------------------------------------------------------------------
@@ -172,10 +182,18 @@ public:
long GetDataDimensionCount();
ScDPDimension* GetDataDimension(long nIndex);
String GetDataDimName(long nIndex);
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ ScDPTableDataCache* GetCache();
+ const ScDPItemData* GetItemDataById( long nDim, long nId );
+ long GetDataLayoutDim(){ return pData->GetColumnCount(); }
+ SCROW GetMemberId( long nDim, const ScDPItemData& rData );
+ // End Comments
BOOL IsDataLayoutDimension(long nDim);
USHORT GetDataLayoutOrientation();
BOOL IsDateDimension(long nDim);
+ UINT32 GetNumberFormat(long nDim);
BOOL SubTotalAllowed(long nColumn); //! move to ScDPResultData
@@ -439,6 +457,10 @@ public:
const ::com::sun::star::sheet::DataPilotFieldReference& GetReferenceValue() const;
//UNUSED2009-05 BOOL IsValidPage( const ScDPItemData& rData );
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+ BOOL IsVisible( const ScDPItemData& rData );
+// End Comments
};
class ScDPHierarchies : public cppu::WeakImplHelper2<
@@ -732,6 +754,12 @@ public:
long getMinMembers() const;
sal_Int32 GetIndexFromName( const ::rtl::OUString& rName ) const; // <0 if not found
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ const std::vector<sal_Int32>& GetGlobalOrder();
+ const ScDPItemData* GetSrcItemDataByIndex( SCROW nIndex);
+ SCROW GetSrcItemsCount();
+ // End Comments
};
class ScDPMember : public cppu::WeakImplHelper3<
@@ -745,7 +773,11 @@ private:
long nHier;
long nLev;
- ScDPItemData maData;
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ SCROW mnDataId;
+ // End Comments
+// String aCaption; // visible name (changeable by user)
::std::auto_ptr<rtl::OUString> mpLayoutName;
sal_Int32 nPosition; // manual sorting
@@ -753,13 +785,24 @@ private:
BOOL bShowDet;
public:
- ScDPMember( ScDPSource* pSrc, long nD, long nH, long nL,
- const String& rN, double fV, BOOL bHV );
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ ScDPMember( ScDPSource* pSrc, long nD, long nH, long nL,
+ SCROW nIndex /*const String& rN, double fV, BOOL bHV */);
+ // End Comments
virtual ~ScDPMember();
BOOL IsNamedItem( const ScDPItemData& r ) const;
String GetNameStr() const;
void FillItemData( ScDPItemData& rData ) const;
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ // const ScDPItemData& GetItemData() const{ return maData; }
+ const ScDPItemData& GetItemData() const;
+ inline SCROW GetItemDataId() const { return mnDataId; }
+ BOOL IsNamedItem( SCROW nIndex ) const;
+ // End Comments
+
SC_DLLPUBLIC const ::rtl::OUString* GetLayoutName() const;
sal_Int32 Compare( const ScDPMember& rOther ) const; // visible order
diff --git a/sc/inc/drwlayer.hxx b/sc/inc/drwlayer.hxx
index 563cf768b5ae..7dd9903f82a1 100644
--- a/sc/inc/drwlayer.hxx
+++ b/sc/inc/drwlayer.hxx
@@ -110,9 +110,9 @@ private:
void MoveAreaTwips( SCTAB nTab, const Rectangle& rArea, const Point& rMove,
const Point& rTopLeft );
void MoveCells( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2,
- SCsCOL nDx,SCsROW nDy );
+ SCsCOL nDx,SCsROW nDy, bool bUpdateNoteCaptionPos );
- void RecalcPos( SdrObject* pObj, const ScDrawObjData& rData, bool bNegativePage );
+ void RecalcPos( SdrObject* pObj, const ScDrawObjData& rData, bool bNegativePage, bool bUpdateNoteCaptionPos );
public:
ScDrawLayer( ScDocument* pDocument, const String& rName );
@@ -155,7 +155,7 @@ public:
void AddCalcUndo( SdrUndoAction* pUndo );
void MoveArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2,
- SCsCOL nDx,SCsROW nDy, BOOL bInsDel );
+ SCsCOL nDx,SCsROW nDy, BOOL bInsDel, bool bUpdateNoteCaptionPos = true );
void WidthChanged( SCTAB nTab, SCCOL nCol, long nDifTwips );
void HeightChanged( SCTAB nTab, SCROW nRow, long nDifTwips );
@@ -173,7 +173,7 @@ public:
SCTAB nSourceTab, const Rectangle& rSourceRange,
const ScAddress& rDestPos, const Rectangle& rDestRange );
- void SetPageSize( USHORT nPageNo, const Size& rSize );
+ void SetPageSize( USHORT nPageNo, const Size& rSize, bool bUpdateNoteCaptionPos = true );
// mirror or move between positive and negative positions for RTL
void MirrorRTL( SdrObject* pObj );
diff --git a/sc/inc/externalrefmgr.hxx b/sc/inc/externalrefmgr.hxx
index ae37b710a074..f47d99097b39 100644
--- a/sc/inc/externalrefmgr.hxx
+++ b/sc/inc/externalrefmgr.hxx
@@ -141,7 +141,7 @@ public:
~Table();
SC_DLLPUBLIC void setCell(SCCOL nCol, SCROW nRow, TokenRef pToken, sal_uInt32 nFmtIndex = 0);
- TokenRef getCell(SCCOL nCol, SCROW nRow, sal_uInt32* pnFmtIndex = NULL) const;
+ SC_DLLPUBLIC TokenRef getCell(SCCOL nCol, SCROW nRow, sal_uInt32* pnFmtIndex = NULL) const;
bool hasRow( SCROW nRow ) const;
/** Set/clear referenced status flag only if current status is not
REFERENCED_PERMANENT. */
@@ -152,8 +152,12 @@ public:
bool isReferenced() const;
/// Obtain a sorted vector of rows.
void getAllRows(::std::vector<SCROW>& rRows) const;
+ /// Returns the half-open range of used rows in this table. Returns [0,0) if table is empty.
+ SC_DLLPUBLIC ::std::pair< SCROW, SCROW > getRowRange() const;
/// Obtain a sorted vector of columns.
void getAllCols(SCROW nRow, ::std::vector<SCCOL>& rCols) const;
+ /// Returns the half-open range of used columns in the specified row. Returns [0,0) if row is empty.
+ SC_DLLPUBLIC ::std::pair< SCCOL, SCCOL > getColRange( SCROW nRow ) const;
void getAllNumberFormats(::std::vector<sal_uInt32>& rNumFmts) const;
private:
@@ -467,6 +471,13 @@ public:
* @return shared_ptr to the cache table instance
*/
ScExternalRefCache::TableTypeRef getCacheTable(sal_uInt16 nFileId, const String& rTabName, bool bCreateNew, size_t* pnIndex = 0);
+
+ /** Returns a vector containing all (real) table names and cache tables of
+ the specified file.
+
+ The index in the returned vector corresponds to the table index used to
+ access the cache table, e.g. in getCacheTable().
+ */
void getAllCachedTableNames(sal_uInt16 nFileId, ::std::vector<String>& rTabNames) const;
/**
diff --git a/sc/inc/filter.hxx b/sc/inc/filter.hxx
index 8e3e540c9038..ae0fd92f6858 100644
--- a/sc/inc/filter.hxx
+++ b/sc/inc/filter.hxx
@@ -39,6 +39,7 @@ class SvStream;
class ScAddress;
class ScDocument;
class ScRange;
+class SvNumberFormatter;
// Return-Werte Im-/Exportfilter (ULONG)
@@ -89,7 +90,9 @@ class ScEEAbsImport {
virtual ~ScEEAbsImport() {}
virtual ULONG Read( SvStream& rStream, const String& rBaseURL ) = 0;
virtual ScRange GetRange() = 0;
- virtual void WriteToDocument( BOOL bSizeColsRows = FALSE, double nOutputFactor = 1.0 ) = 0;
+ virtual void WriteToDocument(
+ BOOL bSizeColsRows = FALSE, double nOutputFactor = 1.0,
+ SvNumberFormatter* pFormatter = NULL, bool bConvertDate = true ) = 0;
};
class ScFormatFilterPlugin {
@@ -106,7 +109,8 @@ class ScFormatFilterPlugin {
virtual FltError ScImportDif( SvStream&, ScDocument*, const ScAddress& rInsPos,
const CharSet eSrc = RTL_TEXTENCODING_DONTKNOW, UINT32 nDifOption = SC_DIFOPT_EXCEL ) = 0;
virtual FltError ScImportRTF( SvStream&, const String& rBaseURL, ScDocument*, ScRange& rRange ) = 0;
- virtual FltError ScImportHTML( SvStream&, const String& rBaseURL, ScDocument*, ScRange& rRange, double nOutputFactor = 1.0, BOOL bCalcWidthHeight = TRUE ) = 0;
+ virtual FltError ScImportHTML( SvStream&, const String& rBaseURL, ScDocument*, ScRange& rRange, double nOutputFactor = 1.0,
+ BOOL bCalcWidthHeight = TRUE, SvNumberFormatter* pFormatter = NULL, bool bConvertDate = true ) = 0;
// various import helpers
virtual ScEEAbsImport *CreateRTFImport( ScDocument* pDoc, const ScRange& rRange ) = 0;
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index 8bcbd50b0f3c..b85205741334 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -414,6 +414,29 @@ enum ScGetDBMode
SC_DB_OLD // nicht neu anlegen
};
+/// For ScDBFunc::GetDBData()
+enum ScGetDBSelection
+{
+ /** Keep selection as is, expand to used data area if no selection. */
+ SC_DBSEL_KEEP,
+
+ /** Shrink selection to sheet's data area. */
+ SC_DBSEL_SHRINK_TO_SHEET_DATA,
+
+ /** Shrink selection to actually used data area within the selection. */
+ SC_DBSEL_SHRINK_TO_USED_DATA,
+
+ /** If only one row or portion thereof is selected, shrink row to used data
+ columns and select further rows down until end of data. If an area is
+ selected, shrink rows to actually used columns. Else, no selection,
+ expand to used data area. */
+ SC_DBSEL_ROW_DOWN,
+
+ /** Behave as if the range corresponding to a ScDBData area was selected,
+ for API use. */
+ SC_DBSEL_FORCE_MARK
+};
+
enum ScLkUpdMode
{ //Verknuepfungen
LM_ALWAYS, //immer aktualisieren
@@ -758,21 +781,6 @@ enum ScSubTotalFunc
};
-#define PIVOT_MAXFUNC 11
-#define PIVOT_FUNC_NONE 0x0000
-#define PIVOT_FUNC_SUM 0x0001
-#define PIVOT_FUNC_COUNT 0x0002
-#define PIVOT_FUNC_AVERAGE 0x0004
-#define PIVOT_FUNC_MAX 0x0008
-#define PIVOT_FUNC_MIN 0x0010
-#define PIVOT_FUNC_PRODUCT 0x0020
-#define PIVOT_FUNC_COUNT_NUM 0x0040
-#define PIVOT_FUNC_STD_DEV 0x0080
-#define PIVOT_FUNC_STD_DEVP 0x0100
-#define PIVOT_FUNC_STD_VAR 0x0200
-#define PIVOT_FUNC_STD_VARP 0x0400
-#define PIVOT_FUNC_AUTO 0x1000
-
// -----------------------------------------------------------------------
/*
@@ -876,46 +884,6 @@ struct ScConsolidateParam
};
// -----------------------------------------------------------------------
-
-class ScSimpleSharedString
-{
-public:
- static const sal_Int32 EMPTY = 0;
-
- ScSimpleSharedString();
- ScSimpleSharedString(const ScSimpleSharedString& r);
- ~ScSimpleSharedString();
-
- const String* getString(sal_Int32 nId);
- sal_Int32 getStringId(const String& aStr);
- sal_Int32 insertString(const String& aStr);
-
-private:
-
- /** internal shared string table implementation */
- class StringTable
- {
- public:
- sal_Int32 insertString(const String& aStr);
- sal_Int32 getStringId(const String& aStr);
- const String* getString(sal_Int32 nId) const;
-
- StringTable();
- StringTable(const StringTable& r);
- ~StringTable();
-
- private:
- typedef ::std::hash_map< String, sal_Int32, ScStringHashCode, ::std::equal_to< String > > SharedStrMap;
-
- ::std::vector<String> maSharedStrings;
- SharedStrMap maSharedStringIds;
- sal_Int32 mnStrCount;
- };
-
- StringTable maStringTable;
-};
-
-// -----------------------------------------------------------------------
extern ::utl::TransliterationWrapper* GetScGlobalpTransliteration();//CHINA001
extern const LocaleDataWrapper* GetScGlobalpLocaleData();
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index d605f0a62694..b03512015e76 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -570,10 +570,14 @@
#define STR_STYLE_FAMILY_CELL 433
#define STR_STYLE_FAMILY_PAGE 434
-#define STR_UNDO_SET_TAB_BG_COLOR 435
-#define STR_UNDO_SET_MULTI_TAB_BG_COLOR 436
+#define STR_ERR_DATAPILOTSOURCE 435
+#define STR_PIVOT_FIRSTROWEMPTYERR 436
+#define STR_PIVOT_ONLYONEROWERR 437
-#define STR_COUNT 437
+#define STR_UNDO_SET_TAB_BG_COLOR 438
+#define STR_UNDO_SET_MULTI_TAB_BG_COLOR 439
+
+#define STR_COUNT 440
#endif
diff --git a/sc/inc/hints.hxx b/sc/inc/hints.hxx
index 00791921527d..fca3d184a4a2 100644
--- a/sc/inc/hints.hxx
+++ b/sc/inc/hints.hxx
@@ -170,4 +170,16 @@ public:
const ScImportParam& GetImportParam() const { return aParam; }
};
+class ScDataPilotModifiedHint : public SfxHint
+{
+ String maName;
+
+public:
+ TYPEINFO();
+ ScDataPilotModifiedHint( const String& rName );
+ ~ScDataPilotModifiedHint();
+
+ const String& GetName() const { return maName; }
+};
+
#endif
diff --git a/sc/inc/optutil.hxx b/sc/inc/optutil.hxx
index c197076ee642..83b23a3c9ef9 100644
--- a/sc/inc/optutil.hxx
+++ b/sc/inc/optutil.hxx
@@ -30,6 +30,7 @@
#include <unotools/configitem.hxx>
#include <tools/link.hxx>
+#include "scdllapi.h"
class ScOptionsUtil
@@ -41,13 +42,13 @@ public:
// ConfigItem for classes that use items from several sub trees
-class ScLinkConfigItem : public utl::ConfigItem
+class SC_DLLPUBLIC ScLinkConfigItem : public utl::ConfigItem
{
Link aCommitLink;
public:
- ScLinkConfigItem( const rtl::OUString rSubTree );
- ScLinkConfigItem( const rtl::OUString rSubTree, sal_Int16 nMode );
+ ScLinkConfigItem( const rtl::OUString& rSubTree );
+ ScLinkConfigItem( const rtl::OUString& rSubTree, sal_Int16 nMode );
void SetCommitLink( const Link& rLink );
virtual void Notify( const com::sun::star::uno::Sequence<rtl::OUString>& aPropertyNames );
diff --git a/sc/inc/pivot.hxx b/sc/inc/pivot.hxx
index 2a1f17846afd..915a311411c4 100644
--- a/sc/inc/pivot.hxx
+++ b/sc/inc/pivot.hxx
@@ -48,6 +48,7 @@
#include "global.hxx"
#include "address.hxx"
+#include "dpglobal.hxx"
#include <vector>
#include <boost/shared_ptr.hpp>
diff --git a/sc/inc/rangelst.hxx b/sc/inc/rangelst.hxx
index 2350cea085f0..e00fce10da1c 100644
--- a/sc/inc/rangelst.hxx
+++ b/sc/inc/rangelst.hxx
@@ -40,6 +40,7 @@ class SC_DLLPUBLIC ScRangeList : public ScRangeListBase, public SvRefBase
{
private:
using ScRangeListBase::operator==;
+ using ScRangeListBase::operator!=;
public:
ScRangeList() {}
@@ -55,16 +56,17 @@ public:
USHORT Parse( const String&, ScDocument* = NULL,
USHORT nMask = SCA_VALID,
formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO,
- char cDelimiter = 0 );
+ sal_Unicode cDelimiter = 0 );
void Format( String&, USHORT nFlags = 0, ScDocument* = NULL,
formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO,
- char cDelimiter = 0 ) const;
+ sal_Unicode cDelimiter = 0 ) const;
void Join( const ScRange&, BOOL bIsInList = FALSE );
BOOL UpdateReference( UpdateRefMode, ScDocument*,
const ScRange& rWhere,
SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
ScRange* Find( const ScAddress& ) const;
BOOL operator==( const ScRangeList& ) const;
+ BOOL operator!=( const ScRangeList& r ) const;
BOOL Intersects( const ScRange& ) const;
BOOL In( const ScRange& ) const;
ULONG GetCellCount() const;
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index 8316462a3433..8cf7e040c9eb 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -262,6 +262,8 @@
#define HID_SC_RENAME_OBJECT ( HID_SC_TOOLBOX_START + 9 )
+#define HID_SC_REN_AFMT_DLG ( HID_SC_TOOLBOX_START + 10 )
+
// Hilfe IDs fuer Submenus (max.50) ------------------------------------------
#define HID_SCMENU_EDIT ( HID_SC_MENU_START )
#define HID_SCMENU_FILL ( HID_SC_MENU_START + 1 )
@@ -1636,10 +1638,11 @@
#define RID_SCDLG_DOCPROTECTION (SC_DIALOGS_START + 149)
#define RID_SCDLG_RETYPEPASS (SC_DIALOGS_START + 150)
#define RID_SCDLG_RETYPEPASS_INPUT (SC_DIALOGS_START + 151)
-#define RID_POPUP_FILTER (SC_DIALOGS_START + 152)
-#define RID_SCDLG_TAB_BG_COLOR (SC_DIALOGS_START + 153)
+#define RID_SCDLG_TEXT_IMPORT_OPTIONS (SC_DIALOGS_START + 152)
+#define RID_POPUP_FILTER (SC_DIALOGS_START + 153)
+#define RID_SCDLG_TAB_BG_COLOR (SC_DIALOGS_START + 154)
-#define SC_DIALOGS_END (SC_DIALOGS_START + 154)
+#define SC_DIALOGS_END (SC_DIALOGS_START + 155)
#ifndef STD_MASKCOLOR
#define STD_MASKCOLOR Color { Red = 0xFF00; Green = 0x0000; Blue = 0xFF00; }
diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx
index 3350475854e1..442e62bdd9cb 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -38,6 +38,7 @@
#include "sc.hrc"
#include "global.hxx"
#include "pivot.hxx"
+#include "i18npool/lang.h"
class ScAsciiOptions;
class ScAutoFormat;
@@ -65,6 +66,7 @@ class AbstractScImportAsciiDlg : public VclAbstractDialog //add for ScImportAsc
public:
virtual void GetOptions( ScAsciiOptions& rOpt ) = 0;
virtual void SetTextToColumnsMode() = 0;
+ virtual void SaveParameters() = 0;
};
@@ -295,6 +297,14 @@ class AbstractScImportOptionsDlg : public VclAbstractDialog //add for ScImportO
public:
virtual void GetImportOptions( ScImportOptions& rOptions ) const = 0;
};
+
+class AbstractScTextImportOptionsDlg : public VclAbstractDialog //add for ScLangChooserDlg
+{
+public:
+ virtual LanguageType GetLanguageType() const = 0;
+ virtual bool IsDateConversionSet() const = 0;
+};
+
//-------Scabstract fractory ---------------------------
class ScAbstractDialogFactory
{
@@ -305,6 +315,8 @@ public:
SvStream* pInStream, int nId,
sal_Unicode cSep = '\t') = 0;
+ virtual AbstractScTextImportOptionsDlg * CreateScTextImportOptionsDlg( Window* pParent, int nId ) = 0;
+
virtual AbstractScAutoFormatDlg * CreateScAutoFormatDlg( Window* pParent, //add for ScAutoFormatDlg
ScAutoFormat* pAutoFormat,
const ScAutoFormatData* pSelFormatData,
diff --git a/sc/inc/scimpexpmsg.hxx b/sc/inc/scimpexpmsg.hxx
deleted file mode 100644
index 5574edd12083..000000000000
--- a/sc/inc/scimpexpmsg.hxx
+++ /dev/null
@@ -1,105 +0,0 @@
-/*************************************************************************
- *
- * 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.
- *
- ************************************************************************/
-
-#ifndef SC_SCIMPEXPMSG_HXX
-#define SC_SCIMPEXPMSG_HXX
-
-
-#include <tools/string.hxx>
-#include <tools/solar.h>
-
-//UNUSED2008-05 enum ScImpExpMsg
-//UNUSED2008-05 {
-//UNUSED2008-05 SC_IMPEXPMSG_UNKNOWN
-//UNUSED2008-05 };
-//UNUSED2008-05
-//UNUSED2008-05
-//UNUSED2008-05 class String;
-//UNUSED2008-05
-//UNUSED2008-05
-//UNUSED2008-05 class ScImpExpLogMsg
-//UNUSED2008-05 {
-//UNUSED2008-05 private:
-//UNUSED2008-05 ScImpExpMsg eId;
-//UNUSED2008-05 String* pPos;
-//UNUSED2008-05 String* pHint;
-//UNUSED2008-05 protected:
-//UNUSED2008-05 public:
-//UNUSED2008-05 ScImpExpLogMsg( ScImpExpMsg eId );
-//UNUSED2008-05 ScImpExpLogMsg( ScImpExpMsg eId, const String& rPosition );
-//UNUSED2008-05 ScImpExpLogMsg( ScImpExpMsg eId, const String& rPosition, const String& rAdditionalHint );
-//UNUSED2008-05 ScImpExpLogMsg( const ScImpExpLogMsg& rCpy );
-//UNUSED2008-05 virtual ~ScImpExpLogMsg();
-//UNUSED2008-05
-//UNUSED2008-05 ScImpExpLogMsg& operator =( const ScImpExpLogMsg& rCpy );
-//UNUSED2008-05
-//UNUSED2008-05 void Set( ScImpExpMsg eId, const String* pPos = NULL, const String* pHint = NULL );
-//UNUSED2008-05
-//UNUSED2008-05 inline ScImpExpMsg GetId( void ) const;
-//UNUSED2008-05 inline const String* GetPos( void ) const;
-//UNUSED2008-05 inline const String* GetHint( void ) const;
-//UNUSED2008-05
-//UNUSED2008-05 static String GetMsg( ScImpExpMsg eId );
-//UNUSED2008-05 inline String GetMsg( void ) const;
-//UNUSED2008-05 };
-//UNUSED2008-05
-//UNUSED2008-05
-//UNUSED2008-05
-//UNUSED2008-05
-//UNUSED2008-05 inline ScImpExpLogMsg& ScImpExpLogMsg::operator =( const ScImpExpLogMsg& r )
-//UNUSED2008-05 {
-//UNUSED2008-05 Set( r.eId, r.pPos, r.pHint );
-//UNUSED2008-05 return *this;
-//UNUSED2008-05 }
-//UNUSED2008-05
-//UNUSED2008-05
-//UNUSED2008-05 inline ScImpExpMsg ScImpExpLogMsg::GetId( void ) const
-//UNUSED2008-05 {
-//UNUSED2008-05 return eId;
-//UNUSED2008-05 }
-//UNUSED2008-05
-//UNUSED2008-05
-//UNUSED2008-05 inline const String* ScImpExpLogMsg::GetPos( void ) const
-//UNUSED2008-05 {
-//UNUSED2008-05 return pPos;
-//UNUSED2008-05 }
-//UNUSED2008-05
-//UNUSED2008-05
-//UNUSED2008-05 inline const String* ScImpExpLogMsg::GetHint( void ) const
-//UNUSED2008-05 {
-//UNUSED2008-05 return pHint;
-//UNUSED2008-05 }
-//UNUSED2008-05
-//UNUSED2008-05
-//UNUSED2008-05 inline String ScImpExpLogMsg::GetMsg( void ) const
-//UNUSED2008-05 {
-//UNUSED2008-05 return GetMsg( eId );
-//UNUSED2008-05 }
-
-#endif
-
-
diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index 494ab86b0c74..9857d675b7ab 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -103,6 +103,7 @@ class SC_DLLPUBLIC ScMatrix
void ResetIsString();
void DeleteIsString();
void CreateMatrix( SCSIZE nC, SCSIZE nR);
+ void Clear();
// pStr may be NULL, bFlag MUST NOT be 0
void PutStringEntry( const String* pStr, BYTE bFlag, SCSIZE nIndex );
@@ -175,6 +176,12 @@ public:
/** Clone the matrix. */
ScMatrix* Clone() const;
+ /**
+ * Resize the matrix to specified new dimension. Note that this operation
+ * clears all stored values.
+ */
+ void Resize( SCSIZE nC, SCSIZE nR);
+
/** Clone the matrix and extend it to the new size. nNewCols and nNewRows
MUST be at least of the size of the original matrix. */
ScMatrix* CloneAndExtend( SCSIZE nNewCols, SCSIZE nNewRows ) const;
diff --git a/sc/inc/stringutil.hxx b/sc/inc/stringutil.hxx
new file mode 100644
index 000000000000..c50c0d8cf156
--- /dev/null
+++ b/sc/inc/stringutil.hxx
@@ -0,0 +1,56 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: table.hxx,v $
+ * $Revision: 1.35 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef SC_STRINGUTIL_HXX
+#define SC_STRINGUTIL_HXX
+
+#include "rtl/ustring.hxx"
+
+class ScStringUtil
+{
+public:
+ /**
+ * Check if a given string is a simple decimal number (e.g. 12.345). We
+ * don't do any elaborate parsing here; we only check for the simplest
+ * case of decimal number format.
+ *
+ * @param rStr string to parse
+ * @param dsep decimal separator
+ * @param gsep group separator (aka thousands separator)
+ * @param rVal value of successfully parsed number
+ *
+ * @return true if the string is a valid number, false otherwise.
+ */
+ static bool parseSimpleNumber(
+ const ::rtl::OUString& rStr, sal_Unicode dsep, sal_Unicode gsep, double& rVal);
+};
+
+
+#endif
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 650af8b3c857..935eb33e6e24 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -268,7 +268,8 @@ public:
void PutCell( SCCOL nCol, SCROW nRow, ScBaseCell* pCell );
void PutCell(SCCOL nCol, SCROW nRow, ULONG nFormatIndex, ScBaseCell* pCell);
// TRUE = Zahlformat gesetzt
- BOOL SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rString );
+ BOOL SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rString,
+ SvNumberFormatter* pFormatter = NULL, bool bDetectNumberFormat = true );
void SetValue( SCCOL nCol, SCROW nRow, const double& rVal );
void SetError( SCCOL nCol, SCROW nRow, USHORT nError);
@@ -382,7 +383,9 @@ public:
SCCOL nStartCol, SCROW nStartRow, SCCOL& rEndCol, SCROW nEndRow );
void GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow,
- BOOL bIncludeOld );
+ BOOL bIncludeOld, bool bOnlyDown ) const;
+
+ bool ShrinkToUsedDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly ) const;
SCSIZE GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow,
SCCOL nEndCol, SCROW nEndRow, ScDirection eDir );
@@ -424,11 +427,11 @@ public:
void UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
- ScDocument* pUndoDoc = NULL, BOOL bIncludeDraw = TRUE );
+ ScDocument* pUndoDoc = NULL, BOOL bIncludeDraw = TRUE, bool bUpdateNoteCaptionPos = true );
void UpdateDrawRef( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
- SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
+ SCsCOL nDx, SCsROW nDy, SCsTAB nDz, bool bUpdateNoteCaptionPos = true );
void UpdateTranspose( const ScRange& rSource, const ScAddress& rDest,
ScDocument* pUndoDoc );
@@ -471,7 +474,7 @@ public:
const SvxBorderLine** ppRight, const SvxBorderLine** ppBottom ) const;
//UNUSED2009-05 BOOL HasLines( const ScRange& rRange, Rectangle& rSizes ) const;
- BOOL HasAttrib( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, USHORT nMask ) const;
+ bool HasAttrib( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, USHORT nMask ) const;
BOOL HasAttribSelection( const ScMarkData& rMark, USHORT nMask ) const;
BOOL ExtendMerge( SCCOL nStartCol, SCROW nStartRow,
SCCOL& rEndCol, SCROW& rEndRow,
@@ -662,8 +665,8 @@ public:
void FindConditionalFormat( ULONG nKey, ScRangeList& rRanges );
- void IncRecalcLevel() { ++nRecalcLvl; }
- void DecRecalcLevel() { if (!--nRecalcLvl) SetDrawPageSize(); }
+ void IncRecalcLevel() { ++nRecalcLvl; }
+ void DecRecalcLevel( bool bUpdateNoteCaptionPos = true ) { if (!--nRecalcLvl) SetDrawPageSize(true, bUpdateNoteCaptionPos); }
BOOL IsSortCollatorGlobal() const;
void InitSortCollator( const ScSortParam& rPar );
@@ -737,7 +740,7 @@ private:
BOOL GetNextSpellingCell(SCCOL& rCol, SCROW& rRow, BOOL bInSel,
const ScMarkData& rMark) const;
BOOL GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark );
- void SetDrawPageSize(bool bResetStreamValid = true);
+ void SetDrawPageSize( bool bResetStreamValid = true, bool bUpdateNoteCaptionPos = true );
BOOL TestTabRefAbs(SCTAB nTable);
void CompileDBFormula();
void CompileDBFormula( BOOL bCreateFormulaString );
diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx
index e1801c37fcc1..ec4216da62c2 100644
--- a/sc/inc/unonames.hxx
+++ b/sc/inc/unonames.hxx
@@ -576,6 +576,15 @@
#define SC_UNO_RPTEMPTY "RepeatIfEmpty"
#define SC_UNO_DRILLDOWN "DrillDownOnDoubleClick"
#define SC_UNO_SHOWFILT "ShowFilterButton"
+#define SC_UNO_IMPORTDESC "ImportDescriptor"
+#define SC_UNO_SOURCESERV "SourceServiceName"
+#define SC_UNO_SERVICEARG "ServiceArguments"
+
+// properties in data pilot descriptor ServiceArguments
+#define SC_UNO_SOURCENAME "SourceName"
+#define SC_UNO_OBJECTNAME "ObjectName"
+#define SC_UNO_USERNAME "UserName"
+#define SC_UNO_PASSWORD "Password"
// range selection
#define SC_UNONAME_INITVAL "InitialValue"
diff --git a/sc/prj/build.lst b/sc/prj/build.lst
index 115e92990f3c..e32d8938afc4 100755
--- a/sc/prj/build.lst
+++ b/sc/prj/build.lst
@@ -48,3 +48,4 @@ sc sc\addin\datefunc nmake - all sc_addfu sc_add sc_sdi sc_inc NULL
sc sc\addin\rot13 nmake - all sc_adrot sc_add sc_sdi sc_inc NULL
sc sc\addin\util nmake - all sc_adutil sc_addfu sc_adrot sc_sdi sc_inc NULL
sc sc\util nmake - all sc_util sc_addfu sc_adrot sc_adutil sc_app sc_attr sc_cctrl sc_cosrc sc_data sc_dbgui sc_dif sc_docsh sc_drfnc sc_excel sc_form sc_html sc_lotus sc_qpro sc_misc sc_name sc_nvipi sc_opt sc_page sc_rtf sc_scalc sc_style sc_tool sc_uisrc sc_undo sc_unobj sc_view sc_xcl97 sc_xml sc_acc sc_ftools sc_inc sc_vba NULL
+sc sc\qa\unoapi nmake - all sc_qa_unoapi NULL
diff --git a/sc/qa/unoapi/Test.java b/sc/qa/unoapi/Test.java
new file mode 100644
index 000000000000..27d048b8bf51
--- /dev/null
+++ b/sc/qa/unoapi/Test.java
@@ -0,0 +1,51 @@
+/*************************************************************************
+* 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.
+************************************************************************/
+
+package org.openoffice.sc.qa.unoapi;
+
+import org.openoffice.Runner;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+
+public final class Test {
+ @org.junit.Before public void setUp() throws Exception {
+ connection.setUp();
+ }
+
+ @org.junit.After public void tearDown()
+ throws InterruptedException, com.sun.star.uno.Exception
+ {
+ connection.tearDown();
+ }
+
+ @org.junit.Test public void test() {
+ assertTrue(
+ Runner.run(
+ "-sce", "sc.sce", "-xcl", "knownissues.xcl", "-tdoc",
+ "testdocuments", "-cs", connection.getDescription()));
+ }
+
+ private final OfficeConnection connection = new OfficeConnection();
+}
diff --git a/sc/qa/unoapi/knownissues.xcl b/sc/qa/unoapi/knownissues.xcl
index d84379c1ac5b..e6863cd75cab 100644
--- a/sc/qa/unoapi/knownissues.xcl
+++ b/sc/qa/unoapi/knownissues.xcl
@@ -164,4 +164,30 @@ sc.ScAccessibleCsvGrid
### i91045 ###
sc.ScAccessibleDocumentPagePreview
-#-> disabled in sc.sce \ No newline at end of file
+#-> disabled in sc.sce
+
+### i109517 ###
+sc.AccessibleEditableTextPara_PreviewCell::com::sun::star::accessibility::XAccessibleComponent
+sc.ScAccessiblePageHeaderArea::com::sun::star::accessibility::XAccessibleEventBroadcaster
+sc.ScAnnotationObj::com::sun::star::sheet::XSheetAnnotation
+sc.ScAnnotationObj::com::sun::star::text::XSimpleText
+sc.ScAnnotationObj::com::sun::star::text::XTextRange
+sc.ScAnnotationShapeObj::com::sun::star::beans::XPropertySet
+sc.ScAnnotationShapeObj::com::sun::star::drawing::CaptionShape
+sc.ScAnnotationShapeObj::com::sun::star::drawing::LineProperties
+sc.ScAnnotationShapeObj::com::sun::star::drawing::RotationDescriptor
+sc.ScAnnotationShapeObj::com::sun::star::drawing::ShadowProperties
+sc.ScAnnotationShapeObj::com::sun::star::drawing::Shape
+sc.ScAnnotationShapeObj::com::sun::star::drawing::XShape
+sc.ScAnnotationShapeObj::com::sun::star::drawing::XShapeDescriptor
+sc.ScAnnotationShapeObj::com::sun::star::lang::XComponent
+sc.ScAnnotationShapeObj::com::sun::star::style::CharacterProperties
+sc.ScAnnotationShapeObj::com::sun::star::style::CharacterPropertiesAsian
+sc.ScAnnotationShapeObj::com::sun::star::style::CharacterPropertiesComplex
+sc.ScAnnotationShapeObj::com::sun::star::style::ParagraphPropertiesAsian
+sc.ScAnnotationShapeObj::com::sun::star::style::ParagraphPropertiesComplex
+sc.ScAnnotationShapeObj::com::sun::star::text::XSimpleText
+sc.ScAnnotationShapeObj::com::sun::star::text::XTextRange
+sc.ScAnnotationsObj::com::sun::star::container::XElementAccess
+sc.ScCellObj::com::sun::star::sheet::XSheetAnnotationAnchor
+sc.ScDataPilotFieldObj::com::sun::star::sheet::XDataPilotFieldGrouping
diff --git a/sc/qa/unoapi/makefile.mk b/sc/qa/unoapi/makefile.mk
index b5506881fb2a..a4781282a0b3 100644
--- a/sc/qa/unoapi/makefile.mk
+++ b/sc/qa/unoapi/makefile.mk
@@ -1,7 +1,6 @@
#*************************************************************************
-#
# 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
@@ -22,19 +21,28 @@
# version 3 along with OpenOffice.org. If not, see
# <http://www.openoffice.org/license.html>
# for a copy of the LGPLv3 License.
-#
-#*************************************************************************
+#***********************************************************************/
-PRJ=..$/..
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
+.ELSE
-PRJNAME=sc
-TARGET=qa_unoapi
+PRJ = ../..
+PRJNAME = sc
+TARGET = qa_unoapi
-.INCLUDE: settings.mk
+.IF "$(OOO_JUNIT_JAR)" != ""
+PACKAGE = org/openoffice/sc/qa/unoapi
+JAVATESTFILES = Test.java
+JAVAFILES = $(JAVATESTFILES)
+JARFILES = OOoRunner.jar ridl.jar test.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
+.END
+.INCLUDE: settings.mk
.INCLUDE: target.mk
+.INCLUDE: installationtest.mk
-ALLTAR : UNOAPI_TEST
+ALLTAR : javatest
-UNOAPI_TEST:
- +$(SOLARENV)$/bin$/checkapi -sce sc.sce -xcl knownissues.xcl -tdoc $(PWD)$/testdocuments
+.END
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index 67be752fd8c8..53df13b4cd62 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -1228,13 +1228,13 @@ BOOL ScAttrArray::HasLines( SCROW nRow1, SCROW nRow2, Rectangle& rSizes,
// Testen, ob Bereich bestimmtes Attribut enthaelt
-BOOL ScAttrArray::HasAttrib( SCROW nRow1, SCROW nRow2, USHORT nMask ) const
+bool ScAttrArray::HasAttrib( SCROW nRow1, SCROW nRow2, USHORT nMask ) const
{
SCSIZE nStartIndex;
SCSIZE nEndIndex;
Search( nRow1, nStartIndex );
Search( nRow2, nEndIndex );
- BOOL bFound = FALSE;
+ bool bFound = false;
for (SCSIZE i=nStartIndex; i<=nEndIndex && !bFound; i++)
{
@@ -1244,46 +1244,46 @@ BOOL ScAttrArray::HasAttrib( SCROW nRow1, SCROW nRow2, USHORT nMask ) const
const ScMergeAttr* pMerge =
(const ScMergeAttr*) &pPattern->GetItem( ATTR_MERGE );
if ( pMerge->GetColMerge() > 1 || pMerge->GetRowMerge() > 1 )
- bFound = TRUE;
+ bFound = true;
}
if ( nMask & ( HASATTR_OVERLAPPED | HASATTR_NOTOVERLAPPED | HASATTR_AUTOFILTER ) )
{
const ScMergeFlagAttr* pMergeFlag =
(const ScMergeFlagAttr*) &pPattern->GetItem( ATTR_MERGE_FLAG );
if ( (nMask & HASATTR_OVERLAPPED) && pMergeFlag->IsOverlapped() )
- bFound = TRUE;
+ bFound = true;
if ( (nMask & HASATTR_NOTOVERLAPPED) && !pMergeFlag->IsOverlapped() )
- bFound = TRUE;
+ bFound = true;
if ( (nMask & HASATTR_AUTOFILTER) && pMergeFlag->HasAutoFilter() )
- bFound = TRUE;
+ bFound = true;
}
if ( nMask & HASATTR_LINES )
{
const SvxBoxItem* pBox =
(const SvxBoxItem*) &pPattern->GetItem( ATTR_BORDER );
if ( pBox->GetLeft() || pBox->GetRight() || pBox->GetTop() || pBox->GetBottom() )
- bFound = TRUE;
+ bFound = true;
}
if ( nMask & HASATTR_SHADOW )
{
const SvxShadowItem* pShadow =
(const SvxShadowItem*) &pPattern->GetItem( ATTR_SHADOW );
if ( pShadow->GetLocation() != SVX_SHADOW_NONE )
- bFound = TRUE;
+ bFound = true;
}
if ( nMask & HASATTR_CONDITIONAL )
{
const SfxUInt32Item* pConditional =
(const SfxUInt32Item*) &pPattern->GetItem( ATTR_CONDITIONAL );
if ( pConditional->GetValue() != 0 )
- bFound = TRUE;
+ bFound = true;
}
if ( nMask & HASATTR_PROTECTED )
{
const ScProtectionAttr* pProtect =
(const ScProtectionAttr*) &pPattern->GetItem( ATTR_PROTECTION );
if ( pProtect->GetProtection() || pProtect->GetHideCell() )
- bFound = TRUE;
+ bFound = true;
}
if ( nMask & HASATTR_ROTATE )
{
@@ -1293,21 +1293,21 @@ BOOL ScAttrArray::HasAttrib( SCROW nRow1, SCROW nRow2, USHORT nMask ) const
// (see ScPatternAttr::GetCellOrientation)
INT32 nAngle = pRotate->GetValue();
if ( nAngle != 0 && nAngle != 9000 && nAngle != 27000 )
- bFound = TRUE;
+ bFound = true;
}
if ( nMask & HASATTR_NEEDHEIGHT )
{
if (pPattern->GetCellOrientation() != SVX_ORIENTATION_STANDARD)
- bFound = TRUE;
+ bFound = true;
else if (((const SfxBoolItem&)pPattern->GetItem( ATTR_LINEBREAK )).GetValue())
- bFound = TRUE;
+ bFound = true;
else if ((SvxCellHorJustify)((const SvxHorJustifyItem&)pPattern->
GetItem( ATTR_HOR_JUSTIFY )).GetValue() == SVX_HOR_JUSTIFY_BLOCK)
- bFound = TRUE;
+ bFound = true;
else if (((const SfxUInt32Item&)pPattern->GetItem( ATTR_CONDITIONAL )).GetValue())
- bFound = TRUE;
+ bFound = true;
else if (((const SfxInt32Item&)pPattern->GetItem( ATTR_ROTATE_VALUE )).GetValue())
- bFound = TRUE;
+ bFound = true;
}
if ( nMask & ( HASATTR_SHADOW_RIGHT | HASATTR_SHADOW_DOWN ) )
{
@@ -1316,17 +1316,17 @@ BOOL ScAttrArray::HasAttrib( SCROW nRow1, SCROW nRow2, USHORT nMask ) const
SvxShadowLocation eLoc = pShadow->GetLocation();
if ( nMask & HASATTR_SHADOW_RIGHT )
if ( eLoc == SVX_SHADOW_TOPRIGHT || eLoc == SVX_SHADOW_BOTTOMRIGHT )
- bFound = TRUE;
+ bFound = true;
if ( nMask & HASATTR_SHADOW_DOWN )
if ( eLoc == SVX_SHADOW_BOTTOMLEFT || eLoc == SVX_SHADOW_BOTTOMRIGHT )
- bFound = TRUE;
+ bFound = true;
}
if ( nMask & HASATTR_RTL )
{
const SvxFrameDirectionItem& rDirection =
(const SvxFrameDirectionItem&) pPattern->GetItem( ATTR_WRITINGDIR );
if ( rDirection.GetValue() == FRMDIR_HORI_RIGHT_TOP )
- bFound = TRUE;
+ bFound = true;
}
if ( nMask & HASATTR_RIGHTORCENTER )
{
@@ -1334,7 +1334,7 @@ BOOL ScAttrArray::HasAttrib( SCROW nRow1, SCROW nRow2, USHORT nMask ) const
SvxCellHorJustify eHorJust = (SvxCellHorJustify)
((const SvxHorJustifyItem&) pPattern->GetItem( ATTR_HOR_JUSTIFY )).GetValue();
if ( eHorJust == SVX_HOR_JUSTIFY_RIGHT || eHorJust == SVX_HOR_JUSTIFY_CENTER )
- bFound = TRUE;
+ bFound = true;
}
}
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 49ae4a98b1c6..ee670d5ba0ef 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -244,7 +244,7 @@ BOOL ScColumn::HasSelectionMatrixFragment(const ScMarkData& rMark) const
//UNUSED2009-05 }
-BOOL ScColumn::HasAttrib( SCROW nRow1, SCROW nRow2, USHORT nMask ) const
+bool ScColumn::HasAttrib( SCROW nRow1, SCROW nRow2, USHORT nMask ) const
{
return pAttrArray->HasAttrib( nRow1, nRow2, nMask );
}
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 30081a6bf402..dc206950b3ea 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -51,6 +51,13 @@
#include "markdata.hxx"
#include "detfunc.hxx" // fuer Notizen bei DeleteRange
#include "postit.hxx"
+#include "stringutil.hxx"
+
+#include <com/sun/star/i18n/LocaleDataItem.hpp>
+
+using ::com::sun::star::i18n::LocaleDataItem;
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
// Err527 Workaround
extern const ScFormulaCell* pLastFormulaTreeTop; // in cellform.cxx
@@ -1241,7 +1248,8 @@ void ScColumn::StartListeningInArea( SCROW nRow1, SCROW nRow2 )
// TRUE = Zahlformat gesetzt
BOOL ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString,
- formula::FormulaGrammar::AddressConvention eConv )
+ formula::FormulaGrammar::AddressConvention eConv,
+ SvNumberFormatter* pFormatter, bool bDetectNumberFormat )
{
BOOL bNumFmtSet = FALSE;
if (VALIDROW(nRow))
@@ -1253,7 +1261,8 @@ BOOL ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString,
double nVal;
sal_uInt32 nIndex, nOldIndex = 0;
sal_Unicode cFirstChar;
- SvNumberFormatter* pFormatter = pDocument->GetFormatTable();
+ if (!pFormatter)
+ pFormatter = pDocument->GetFormatTable();
SfxObjectShell* pDocSh = pDocument->GetDocumentShell();
if ( pDocSh )
bIsLoading = pDocSh->IsLoading();
@@ -1320,46 +1329,78 @@ BOOL ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString,
if ( !bIsText )
nIndex = nOldIndex = pFormatter->GetStandardIndex();
}
- if ( !bIsText &&
- pFormatter->IsNumberFormat(rString, nIndex, nVal) )
- { // Zahl
- pNewCell = new ScValueCell( nVal );
- if ( nIndex != nOldIndex)
+
+ do
+ {
+ if (bIsText)
+ break;
+
+ if (bDetectNumberFormat)
{
- // #i22345# New behavior: Apply the detected number format only if
- // the old one was the default number, date, time or boolean format.
- // Exception: If the new format is boolean, always apply it.
+ if (!pFormatter->IsNumberFormat(rString, nIndex, nVal))
+ break;
- BOOL bOverwrite = FALSE;
- const SvNumberformat* pOldFormat = pFormatter->GetEntry( nOldIndex );
- if ( pOldFormat )
+ pNewCell = new ScValueCell( nVal );
+ if ( nIndex != nOldIndex)
{
- short nOldType = pOldFormat->GetType() & ~NUMBERFORMAT_DEFINED;
- if ( nOldType == NUMBERFORMAT_NUMBER || nOldType == NUMBERFORMAT_DATE ||
- nOldType == NUMBERFORMAT_TIME || nOldType == NUMBERFORMAT_LOGICAL )
+ // #i22345# New behavior: Apply the detected number format only if
+ // the old one was the default number, date, time or boolean format.
+ // Exception: If the new format is boolean, always apply it.
+
+ BOOL bOverwrite = FALSE;
+ const SvNumberformat* pOldFormat = pFormatter->GetEntry( nOldIndex );
+ if ( pOldFormat )
{
- if ( nOldIndex == pFormatter->GetStandardFormat(
- nOldType, pOldFormat->GetLanguage() ) )
+ short nOldType = pOldFormat->GetType() & ~NUMBERFORMAT_DEFINED;
+ if ( nOldType == NUMBERFORMAT_NUMBER || nOldType == NUMBERFORMAT_DATE ||
+ nOldType == NUMBERFORMAT_TIME || nOldType == NUMBERFORMAT_LOGICAL )
{
- bOverwrite = TRUE; // default of these types can be overwritten
+ if ( nOldIndex == pFormatter->GetStandardFormat(
+ nOldType, pOldFormat->GetLanguage() ) )
+ {
+ bOverwrite = TRUE; // default of these types can be overwritten
+ }
}
}
- }
- if ( !bOverwrite && pFormatter->GetType( nIndex ) == NUMBERFORMAT_LOGICAL )
- {
- bOverwrite = TRUE; // overwrite anything if boolean was detected
- }
+ if ( !bOverwrite && pFormatter->GetType( nIndex ) == NUMBERFORMAT_LOGICAL )
+ {
+ bOverwrite = TRUE; // overwrite anything if boolean was detected
+ }
- if ( bOverwrite )
- {
- ApplyAttr( nRow, SfxUInt32Item( ATTR_VALUE_FORMAT,
- (UINT32) nIndex) );
- bNumFmtSet = TRUE;
+ if ( bOverwrite )
+ {
+ ApplyAttr( nRow, SfxUInt32Item( ATTR_VALUE_FORMAT,
+ (UINT32) nIndex) );
+ bNumFmtSet = TRUE;
+ }
}
}
+ else
+ {
+ // Only check if the string is a regular number.
+ const LocaleDataWrapper* pLocale = pFormatter->GetLocaleData();
+ if (!pLocale)
+ break;
+
+ LocaleDataItem aLocaleItem = pLocale->getLocaleItem();
+ const OUString& rDecSep = aLocaleItem.decimalSeparator;
+ const OUString& rGroupSep = aLocaleItem.thousandSeparator;
+ if (rDecSep.getLength() != 1 || rGroupSep.getLength() != 1)
+ break;
+
+ sal_Unicode dsep = rDecSep.getStr()[0];
+ sal_Unicode gsep = rGroupSep.getStr()[0];
+
+ if (!ScStringUtil::parseSimpleNumber(rString, dsep, gsep, nVal))
+ break;
+
+ pNewCell = new ScValueCell(nVal);
+ }
}
- else // Text
- pNewCell = new ScStringCell( rString );
+ while (false);
+
+ if (!pNewCell)
+ pNewCell = new ScStringCell(rString);
}
}
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index bdd36061564e..da1f20433d1f 100755..100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -591,7 +591,11 @@ bool ScDBQueryDataIterator::DataAccessInternal::getCurrent(Value& rValue)
if (ScDBQueryDataIterator::IsQueryValid(*mpDoc, *mpParam, nTab, nRow, pCell))
{
- switch (pCell->GetCellType())
+ // #i109812# get cell here if it wasn't done above
+ if (nCol != static_cast<SCCOL>(nFirstQueryField))
+ pCell = ScDBQueryDataIterator::GetCellByColEntryIndex(*mpDoc, nTab, nCol, nColRow);
+
+ switch (pCell ? pCell->GetCellType() : CELLTYPE_NONE)
{
case CELLTYPE_VALUE:
{
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 3f484520ae6a..b31d124d88ff 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -75,6 +75,11 @@
#include "drwlayer.hxx"
#include "unoreflist.hxx"
#include "listenercalls.hxx"
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+#include "dpshttab.hxx"
+#include "dptablecache.hxx"
+// End Comments
#include "tabprotection.hxx"
#include "formulaparserpool.hxx"
#include "clipparam.hxx"
@@ -800,7 +805,8 @@ void ScDocument::UpdateReference( UpdateRefMode eUpdateRefMode,
SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
- ScDocument* pUndoDoc, BOOL bIncludeDraw )
+ ScDocument* pUndoDoc, BOOL bIncludeDraw,
+ bool bUpdateNoteCaptionPos )
{
PutInOrder( nCol1, nCol2 );
PutInOrder( nRow1, nRow2 );
@@ -844,7 +850,7 @@ void ScDocument::UpdateReference( UpdateRefMode eUpdateRefMode,
if (pTab[i])
pTab[i]->UpdateReference(
eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2,
- nDx, nDy, nDz, pUndoDoc, bIncludeDraw );
+ nDx, nDy, nDz, pUndoDoc, bIncludeDraw, bUpdateNoteCaptionPos );
if ( bIsEmbedded )
{
@@ -1915,12 +1921,125 @@ void ScDocument::IncSizeRecalcLevel( SCTAB nTab )
pTab[nTab]->IncRecalcLevel();
}
-void ScDocument::DecSizeRecalcLevel( SCTAB nTab )
+void ScDocument::DecSizeRecalcLevel( SCTAB nTab, bool bUpdateNoteCaptionPos )
{
if ( ValidTab(nTab) && pTab[nTab] )
- pTab[nTab]->DecRecalcLevel();
+ pTab[nTab]->DecRecalcLevel( bUpdateNoteCaptionPos );
}
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+ScDPTableDataCache* ScDocument::GetDPObjectCache( long nID )
+{
+ for ( std::list<ScDPTableDataCache*>::iterator iter = m_listDPObjectsCaches.begin(); iter!=m_listDPObjectsCaches.end(); iter++ )
+ { //
+ if ( nID == (*iter)->GetId() )
+ return *iter;
+ }
+ return NULL;
+}
+
+ScDPTableDataCache* ScDocument::GetUsedDPObjectCache ( ScRange rRange )
+{
+ ScDPTableDataCache* pCache = NULL;
+ USHORT nCount = GetDPCollection()->GetCount();
+ for ( short i=nCount-1; i>=0 ; i--)
+ {
+ if ( const ScSheetSourceDesc* pUsedSheetDesc = (*pDPCollection)[i]->GetSheetDesc() )
+ if ( rRange == pUsedSheetDesc->aSourceRange )
+ {
+ long nID = (*pDPCollection)[i]->GetCacheId();
+ if ( nID >= 0 )
+ pCache= GetDPObjectCache( nID );
+ if ( pCache )
+ return pCache;
+ }
+ }
+ return pCache;
+}
+long ScDocument::AddDPObjectCache( ScDPTableDataCache* pData )
+{
+ if ( pData->GetId() < 0 )
+ { //create a id for it
+ pData->SetId( GetNewDPObjectCacheId() );
+ }
+ m_listDPObjectsCaches.push_back( pData );
+ return pData->GetId();
+}
+long ScDocument::GetNewDPObjectCacheId()
+{
+ long nID = 0;
+ bool bFound = false;
+ std::list<ScDPTableDataCache*>::iterator iter;
+ do {
+ for ( iter = m_listDPObjectsCaches.begin(); iter!=m_listDPObjectsCaches.end(); iter++ )
+ { //Get a new Id
+ if ( nID == (*iter)->GetId() )
+ {
+ nID++;
+ bFound = true;
+ break;
+ }
+ }
+ if ( iter == m_listDPObjectsCaches.end() )
+ bFound = false;
+ } while ( bFound );
+
+ return nID;
+}
+
+void ScDocument::RemoveDPObjectCache( long nID )
+{
+ for ( std::list<ScDPTableDataCache*>::iterator iter = m_listDPObjectsCaches.begin(); iter!=m_listDPObjectsCaches.end(); iter++ )
+ {
+ if ( nID == (*iter)->GetId() )
+ {
+ ScDPTableDataCache* pCache = *iter;
+ m_listDPObjectsCaches.erase( iter );
+ delete pCache;
+ break;
+ }
+ }
+
+}
+
+void ScDocument::RemoveUnusedDPObjectCaches()
+{
+ for ( std::list<ScDPTableDataCache*>::iterator iter = m_listDPObjectsCaches.begin(); iter!=m_listDPObjectsCaches.end(); iter++ )
+ {
+ long nID = (*iter)->GetId();
+ USHORT nCount = GetDPCollection()->GetCount();
+ USHORT i ;
+ for ( i=0; i<nCount; i++)
+ {
+ if ( nID == (*pDPCollection)[i]->GetCacheId() )
+ break;
+ }
+ if ( i == nCount )
+ {
+ ScDPTableDataCache* pCache = *iter;
+ m_listDPObjectsCaches.erase( iter );
+ delete pCache;
+ continue;
+ }
+ }
+}
+
+void ScDocument::GetUsedDPObjectCache( std::list<ScDPTableDataCache*>& usedlist )
+{
+ for ( std::list<ScDPTableDataCache*>::iterator iter = m_listDPObjectsCaches.begin(); iter!=m_listDPObjectsCaches.end(); iter++ )
+ {
+ long nID = (*iter)->GetId();
+ USHORT nCount = GetDPCollection()->GetCount();
+ USHORT i=0;
+ for ( i=0; i<nCount; i++)
+ if ( nID == (*pDPCollection)[i]->GetCacheId() )
+ break;
+ if ( i != nCount )
+ usedlist.push_back( *iter );
+ }
+}
+// End Comments
diff --git a/sc/source/core/data/documen5.cxx b/sc/source/core/data/documen5.cxx
index 14a88abd32ca..d6653402c46a 100644
--- a/sc/source/core/data/documen5.cxx
+++ b/sc/source/core/data/documen5.cxx
@@ -64,107 +64,12 @@
#include "miscuno.hxx"
#include "chart2uno.hxx"
+#include "charthelper.hxx"
using namespace ::com::sun::star;
// -----------------------------------------------------------------------
-void lcl_GetChartRanges( const uno::Reference< chart2::XChartDocument >& xChartDoc,
- uno::Sequence< rtl::OUString >& rRanges )
-{
- rRanges.realloc(0);
- uno::Reference< chart2::data::XDataSource > xDataSource( xChartDoc, uno::UNO_QUERY );
- if( !xDataSource.is() )
- return;
- //uno::Reference< chart2::data::XDataProvider > xProvider = xChartDoc->getDataProvider();
-
- uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aLabeledDataSequences( xDataSource->getDataSequences() );
- rRanges.realloc(2*aLabeledDataSequences.getLength());
- sal_Int32 nRealCount=0;
- for( sal_Int32 nN=0;nN<aLabeledDataSequences.getLength();nN++)
- {
- uno::Reference< chart2::data::XLabeledDataSequence > xLabeledSequence( aLabeledDataSequences[nN] );
- if(!xLabeledSequence.is())
- continue;
- uno::Reference< chart2::data::XDataSequence > xLabel( xLabeledSequence->getLabel());
- uno::Reference< chart2::data::XDataSequence > xValues( xLabeledSequence->getValues());
-
- if( xLabel.is())
- rRanges[nRealCount++] = xLabel->getSourceRangeRepresentation();
- if( xValues.is())
- rRanges[nRealCount++] = xValues->getSourceRangeRepresentation();
- }
- rRanges.realloc(nRealCount);
-}
-
-void lcl_SetChartRanges( const uno::Reference< chart2::XChartDocument >& xChartDoc,
- const uno::Sequence< rtl::OUString >& rRanges )
-{
- uno::Reference< chart2::data::XDataSource > xDataSource( xChartDoc, uno::UNO_QUERY );
- if( !xDataSource.is() )
- return;
- uno::Reference< chart2::data::XDataProvider > xDataProvider = xChartDoc->getDataProvider();
- if( !xDataProvider.is() )
- return;
-
- uno::Reference< frame::XModel > xModel( xChartDoc, uno::UNO_QUERY );
- if( xModel.is() )
- xModel->lockControllers();
-
- try
- {
- rtl::OUString aPropertyNameRole( ::rtl::OUString::createFromAscii("Role") );
-
- uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aLabeledDataSequences( xDataSource->getDataSequences() );
- sal_Int32 nRange=0;
- for( sal_Int32 nN=0; (nN<aLabeledDataSequences.getLength()) && (nRange<rRanges.getLength()); nN++ )
- {
- uno::Reference< chart2::data::XLabeledDataSequence > xLabeledSequence( aLabeledDataSequences[nN] );
- if(!xLabeledSequence.is())
- continue;
- uno::Reference< beans::XPropertySet > xLabel( xLabeledSequence->getLabel(), uno::UNO_QUERY );
- uno::Reference< beans::XPropertySet > xValues( xLabeledSequence->getValues(), uno::UNO_QUERY );
-
- if( xLabel.is())
- {
- // the range string must be in Calc A1 format.
- uno::Reference< chart2::data::XDataSequence > xNewSeq(
- xDataProvider->createDataSequenceByRangeRepresentation( rRanges[nRange++] ));
-
- uno::Reference< beans::XPropertySet > xNewProps( xNewSeq, uno::UNO_QUERY );
- if( xNewProps.is() )
- xNewProps->setPropertyValue( aPropertyNameRole, xLabel->getPropertyValue( aPropertyNameRole ) );
-
- xLabeledSequence->setLabel( xNewSeq );
- }
-
- if( !(nRange<rRanges.getLength()) )
- break;
-
- if( xValues.is())
- {
- // the range string must be in Calc A1 format.
- uno::Reference< chart2::data::XDataSequence > xNewSeq(
- xDataProvider->createDataSequenceByRangeRepresentation( rRanges[nRange++] ));
-
- uno::Reference< beans::XPropertySet > xNewProps( xNewSeq, uno::UNO_QUERY );
- if( xNewProps.is() )
- xNewProps->setPropertyValue( aPropertyNameRole, xValues->getPropertyValue( aPropertyNameRole ) );
-
- xLabeledSequence->setValues( xNewSeq );
- }
- }
- }
- catch ( uno::Exception& ex )
- {
- (void)ex;
- DBG_ERROR("Exception in lcl_SetChartRanges - invalid range string?");
- }
-
- if( xModel.is() )
- xModel->unlockControllers();
-}
-
void lcl_GetChartParameters( const uno::Reference< chart2::XChartDocument >& xChartDoc,
rtl::OUString& rRanges, chart::ChartDataRowSource& rDataRowSource,
bool& rHasCategories, bool& rFirstCellAsLabel )
@@ -363,14 +268,7 @@ uno::Reference< chart2::XChartDocument > ScDocument::GetChartByName( const Strin
if ( pObject->GetObjIdentifier() == OBJ_OLE2 &&
((SdrOle2Obj*)pObject)->GetPersistName() == rChartName )
{
- uno::Reference< embed::XEmbeddedObject > xIPObj = ((SdrOle2Obj*)pObject)->GetObjRef();
- if ( xIPObj.is() )
- {
- svt::EmbeddedObjectRef::TryRunningState( xIPObj );
-
- uno::Reference< util::XCloseable > xComponent = xIPObj->getComponent();
- xReturn.set( uno::Reference< chart2::XChartDocument >( xComponent, uno::UNO_QUERY ) );
- }
+ xReturn.set( ScChartHelper::GetChartFromSdrObject( pObject ) );
return xReturn;
}
pObject = aIter.Next();
@@ -386,7 +284,7 @@ void ScDocument::GetChartRanges( const String& rChartName, ::std::vector< ScRang
if ( xChartDoc.is() )
{
uno::Sequence< rtl::OUString > aRangeStrings;
- lcl_GetChartRanges( xChartDoc, aRangeStrings );
+ ScChartHelper::GetChartRanges( xChartDoc, aRangeStrings );
for( sal_Int32 nN=0; nN<aRangeStrings.getLength(); nN++ )
{
ScRangeList aRanges;
@@ -410,7 +308,7 @@ void ScDocument::SetChartRanges( const String& rChartName, const ::std::vector<
aScRangeList.Format( sRangeStr, SCR_ABS_3D, this );
aRangeStrings[nN]=sRangeStr;
}
- lcl_SetChartRanges( xChartDoc, aRangeStrings );
+ ScChartHelper::SetChartRanges( xChartDoc, aRangeStrings );
}
}
@@ -435,32 +333,25 @@ void ScDocument::GetOldChartParameters( const String& rName,
if ( pObject->GetObjIdentifier() == OBJ_OLE2 &&
((SdrOle2Obj*)pObject)->GetPersistName() == rName )
{
- uno::Reference< embed::XEmbeddedObject > xIPObj = ((SdrOle2Obj*)pObject)->GetObjRef();
- if ( xIPObj.is() )
+ uno::Reference< chart2::XChartDocument > xChartDoc( ScChartHelper::GetChartFromSdrObject( pObject ) );
+ if ( xChartDoc.is() )
{
- svt::EmbeddedObjectRef::TryRunningState( xIPObj );
-
- uno::Reference< util::XCloseable > xComponent = xIPObj->getComponent();
- uno::Reference< chart2::XChartDocument > xChartDoc( xComponent, uno::UNO_QUERY );
- if ( xChartDoc.is() )
+ chart::ChartDataRowSource eDataRowSource = chart::ChartDataRowSource_COLUMNS;
+ bool bHasCategories = false;
+ bool bFirstCellAsLabel = false;
+ rtl::OUString aRangesStr;
+ lcl_GetChartParameters( xChartDoc, aRangesStr, eDataRowSource, bHasCategories, bFirstCellAsLabel );
+
+ rRanges.Parse( aRangesStr, this );
+ if ( eDataRowSource == chart::ChartDataRowSource_COLUMNS )
{
- chart::ChartDataRowSource eDataRowSource = chart::ChartDataRowSource_COLUMNS;
- bool bHasCategories = false;
- bool bFirstCellAsLabel = false;
- rtl::OUString aRangesStr;
- lcl_GetChartParameters( xChartDoc, aRangesStr, eDataRowSource, bHasCategories, bFirstCellAsLabel );
-
- rRanges.Parse( aRangesStr, this );
- if ( eDataRowSource == chart::ChartDataRowSource_COLUMNS )
- {
- rRowHeaders = bHasCategories;
- rColHeaders = bFirstCellAsLabel;
- }
- else
- {
- rColHeaders = bHasCategories;
- rRowHeaders = bFirstCellAsLabel;
- }
+ rRowHeaders = bHasCategories;
+ rColHeaders = bFirstCellAsLabel;
+ }
+ else
+ {
+ rColHeaders = bHasCategories;
+ rRowHeaders = bFirstCellAsLabel;
}
}
return;
@@ -489,75 +380,68 @@ void ScDocument::UpdateChartArea( const String& rChartName,
if ( pObject->GetObjIdentifier() == OBJ_OLE2 &&
((SdrOle2Obj*)pObject)->GetPersistName() == rChartName )
{
- uno::Reference< embed::XEmbeddedObject > xIPObj = ((SdrOle2Obj*)pObject)->GetObjRef();
- if ( xIPObj.is() )
+ uno::Reference< chart2::XChartDocument > xChartDoc( ScChartHelper::GetChartFromSdrObject( pObject ) );
+ uno::Reference< chart2::data::XDataReceiver > xReceiver( xChartDoc, uno::UNO_QUERY );
+ if ( xChartDoc.is() && xReceiver.is() )
{
- svt::EmbeddedObjectRef::TryRunningState( xIPObj );
+ ScRangeListRef aNewRanges;
+ chart::ChartDataRowSource eDataRowSource = chart::ChartDataRowSource_COLUMNS;
+ bool bHasCategories = false;
+ bool bFirstCellAsLabel = false;
+ rtl::OUString aRangesStr;
+ lcl_GetChartParameters( xChartDoc, aRangesStr, eDataRowSource, bHasCategories, bFirstCellAsLabel );
- uno::Reference< util::XCloseable > xComponent = xIPObj->getComponent();
- uno::Reference< chart2::XChartDocument > xChartDoc( xComponent, uno::UNO_QUERY );
- uno::Reference< chart2::data::XDataReceiver > xReceiver( xComponent, uno::UNO_QUERY );
- if ( xChartDoc.is() && xReceiver.is() )
- {
- ScRangeListRef aNewRanges;
- chart::ChartDataRowSource eDataRowSource = chart::ChartDataRowSource_COLUMNS;
- bool bHasCategories = false;
- bool bFirstCellAsLabel = false;
- rtl::OUString aRangesStr;
- lcl_GetChartParameters( xChartDoc, aRangesStr, eDataRowSource, bHasCategories, bFirstCellAsLabel );
+ sal_Bool bInternalData = xChartDoc->hasInternalDataProvider();
- sal_Bool bInternalData = xChartDoc->hasInternalDataProvider();
+ if ( bAdd && !bInternalData )
+ {
+ // append to old ranges, keep other settings
- if ( bAdd && !bInternalData )
- {
- // append to old ranges, keep other settings
+ aNewRanges = new ScRangeList;
+ aNewRanges->Parse( aRangesStr, this );
- aNewRanges = new ScRangeList;
- aNewRanges->Parse( aRangesStr, this );
+ ULONG nAddCount = rNewList->Count();
+ for ( ULONG nAdd=0; nAdd<nAddCount; nAdd++ )
+ aNewRanges->Append( *rNewList->GetObject(nAdd) );
+ }
+ else
+ {
+ // directly use new ranges (only eDataRowSource is used from old settings)
- ULONG nAddCount = rNewList->Count();
- for ( ULONG nAdd=0; nAdd<nAddCount; nAdd++ )
- aNewRanges->Append( *rNewList->GetObject(nAdd) );
+ if ( eDataRowSource == chart::ChartDataRowSource_COLUMNS )
+ {
+ bHasCategories = bRowHeaders;
+ bFirstCellAsLabel = bColHeaders;
}
else
{
- // directly use new ranges (only eDataRowSource is used from old settings)
-
- if ( eDataRowSource == chart::ChartDataRowSource_COLUMNS )
- {
- bHasCategories = bRowHeaders;
- bFirstCellAsLabel = bColHeaders;
- }
- else
- {
- bHasCategories = bColHeaders;
- bFirstCellAsLabel = bRowHeaders;
- }
- aNewRanges = rNewList;
+ bHasCategories = bColHeaders;
+ bFirstCellAsLabel = bRowHeaders;
}
+ aNewRanges = rNewList;
+ }
- if ( bInternalData && pShell )
- {
- // Calc -> DataProvider
- uno::Reference< chart2::data::XDataProvider > xDataProvider = new ScChart2DataProvider( this );
- xReceiver->attachDataProvider( xDataProvider );
- uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier(
- pShell->GetModel(), uno::UNO_QUERY );
- xReceiver->attachNumberFormatsSupplier( xNumberFormatsSupplier );
- }
+ if ( bInternalData && pShell )
+ {
+ // Calc -> DataProvider
+ uno::Reference< chart2::data::XDataProvider > xDataProvider = new ScChart2DataProvider( this );
+ xReceiver->attachDataProvider( xDataProvider );
+ uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier(
+ pShell->GetModel(), uno::UNO_QUERY );
+ xReceiver->attachNumberFormatsSupplier( xNumberFormatsSupplier );
+ }
- String sRangeStr;
- aNewRanges->Format( sRangeStr, SCR_ABS_3D, this, GetAddressConvention() );
+ String sRangeStr;
+ aNewRanges->Format( sRangeStr, SCR_ABS_3D, this, GetAddressConvention() );
- lcl_SetChartParameters( xReceiver, sRangeStr, eDataRowSource, bHasCategories, bFirstCellAsLabel );
+ lcl_SetChartParameters( xReceiver, sRangeStr, eDataRowSource, bHasCategories, bFirstCellAsLabel );
- pChartListenerCollection->ChangeListening( rChartName, aNewRanges );
+ pChartListenerCollection->ChangeListening( rChartName, aNewRanges );
- // ((SdrOle2Obj*)pObject)->GetNewReplacement();
- // pObject->ActionChanged();
+ // ((SdrOle2Obj*)pObject)->GetNewReplacement();
+ // pObject->ActionChanged();
- return; // nicht weitersuchen
- }
+ return; // nicht weitersuchen
}
}
pObject = aIter.Next();
@@ -569,124 +453,25 @@ void ScDocument::UpdateChart( const String& rChartName )
{
if (!pDrawLayer || bInDtorClear)
return;
-
- for (SCTAB nTab=0; nTab<=MAXTAB && pTab[nTab]; nTab++)
+ uno::Reference< chart2::XChartDocument > xChartDoc( GetChartByName( rChartName ) );
+ if( xChartDoc.is() )
{
- SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
- DBG_ASSERT(pPage,"Page ?");
-
- SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
- SdrObject* pObject = aIter.Next();
- while (pObject)
+ try
+ {
+ uno::Reference< util::XModifiable > xModif( xChartDoc, uno::UNO_QUERY_THROW );
+ if( apTemporaryChartLock.get() )
+ apTemporaryChartLock->AlsoLockThisChart( uno::Reference< frame::XModel >( xModif, uno::UNO_QUERY ) );
+ xModif->setModified( sal_True );
+ }
+ catch ( uno::Exception& )
{
- if ( pObject->GetObjIdentifier() == OBJ_OLE2 &&
- ((SdrOle2Obj*)pObject)->GetPersistName() == rChartName )
- {
- //@todo?: maybe we need a notification
- //from the calc to the chart in future
- //that calc content has changed
- // ((SdrOle2Obj*)pObject)->GetNewReplacement();
-
- // Load the object and set modified
-
- uno::Reference< embed::XEmbeddedObject > xIPObj = ((SdrOle2Obj*)pObject)->GetObjRef();
- if ( xIPObj.is() )
- {
- svt::EmbeddedObjectRef::TryRunningState( xIPObj );
-
- try
- {
- uno::Reference< util::XModifiable > xModif( xIPObj->getComponent(), uno::UNO_QUERY_THROW );
- if( apTemporaryChartLock.get() )
- apTemporaryChartLock->AlsoLockThisChart( uno::Reference< frame::XModel >( xModif, uno::UNO_QUERY ) );
- xModif->setModified( sal_True );
- }
- catch ( uno::Exception& )
- {
- }
- }
-
- // repaint
-
- pObject->ActionChanged();
-
- // After the update, chart keeps track of its own data source ranges,
- // the listener doesn't need to listen anymore.
-
- pChartListenerCollection->ChangeListening( rChartName, new ScRangeList );
-
- return;
-
- /* old chart:
- uno::Reference< embed::XEmbeddedObject > xIPObj = ((SdrOle2Obj*)pObject)->GetObjRef();
- if ( xIPObj.is() )
- {
- const SchMemChart* pChartData = SchDLL::GetChartData(xIPObj);
- if ( pChartData )
- {
- ScChartArray aArray( this, *pChartData );
-
- SchMemChart* pMemChart = aArray.CreateMemChart();
- ScChartArray::CopySettings( *pMemChart, *pChartData );
-
- // #57655# Chart-Update ohne geaenderte Einstellungen (MemChart)
- // soll das Dokument nicht auf modified setzen (z.B. in frisch
- // geladenem Dokument durch initiales Recalc)
-
- // #72576# disable SetModified for readonly documents only
-
- sal_Bool bEnabled = ( (pShell && pShell->IsReadOnly()) || IsImportingXML() );
- sal_Bool bModified = sal_False;
- uno::Reference< util::XModifiable > xModif;
-
- if ( bEnabled )
- {
- try
- {
- xModif =
- uno::Reference< util::XModifiable >( xIPObj->getComponent(), uno::UNO_QUERY_THROW );
- bModified = xModif->isModified();
- }
- catch( uno::Exception& )
- {
- bEnabled = sal_False;
- }
- }
-
- SchDLL::Update( xIPObj, pMemChart, pWindow );
- ((SdrOle2Obj*)pObject)->GetNewReplacement();
- delete pMemChart;
-
- // Dies veranlaesst Chart zum sofortigen Update
- //SvData aEmpty;
- //aIPObj->SendDataChanged( aEmpty );
-
- // the method below did nothing in SO7
-//REMOVE aIPObj->SendViewChanged();
-
- // redraw only
- pObject->ActionChanged();
- // pObject->SendRepaintBroadcast();
-
- if ( bEnabled && xModif.is() )
- {
- try
- {
- if ( xModif->isModified() != bModified )
- xModif->setModified( bModified );
- }
- catch ( uno::Exception& )
- {}
- }
-
- return; // nicht weitersuchen
- }
- }
- */
- }
- pObject = aIter.Next();
}
}
+
+ // After the update, chart keeps track of its own data source ranges,
+ // the listener doesn't need to listen anymore.
+ if(pChartListenerCollection)
+ pChartListenerCollection->ChangeListening( rChartName, new ScRangeList );
}
void ScDocument::RestoreChartListener( const String& rName )
@@ -823,31 +608,24 @@ void ScDocument::SetChartRangeList( const String& rChartName,
if ( pObject->GetObjIdentifier() == OBJ_OLE2 &&
((SdrOle2Obj*)pObject)->GetPersistName() == rChartName )
{
- uno::Reference< embed::XEmbeddedObject > xIPObj = ((SdrOle2Obj*)pObject)->GetObjRef();
- if ( xIPObj.is() )
+ uno::Reference< chart2::XChartDocument > xChartDoc( ScChartHelper::GetChartFromSdrObject( pObject ) );
+ uno::Reference< chart2::data::XDataReceiver > xReceiver( xChartDoc, uno::UNO_QUERY );
+ if ( xChartDoc.is() && xReceiver.is() )
{
- svt::EmbeddedObjectRef::TryRunningState( xIPObj );
-
- uno::Reference< util::XCloseable > xComponent = xIPObj->getComponent();
- uno::Reference< chart2::XChartDocument > xChartDoc( xComponent, uno::UNO_QUERY );
- uno::Reference< chart2::data::XDataReceiver > xReceiver( xComponent, uno::UNO_QUERY );
- if ( xChartDoc.is() && xReceiver.is() )
- {
- ScRangeListRef aNewRanges;
- chart::ChartDataRowSource eDataRowSource = chart::ChartDataRowSource_COLUMNS;
- bool bHasCategories = false;
- bool bFirstCellAsLabel = false;
- rtl::OUString aRangesStr;
- lcl_GetChartParameters( xChartDoc, aRangesStr, eDataRowSource, bHasCategories, bFirstCellAsLabel );
+ ScRangeListRef aNewRanges;
+ chart::ChartDataRowSource eDataRowSource = chart::ChartDataRowSource_COLUMNS;
+ bool bHasCategories = false;
+ bool bFirstCellAsLabel = false;
+ rtl::OUString aRangesStr;
+ lcl_GetChartParameters( xChartDoc, aRangesStr, eDataRowSource, bHasCategories, bFirstCellAsLabel );
- String sRangeStr;
- rNewRangeListRef->Format( sRangeStr, SCR_ABS_3D, this, GetAddressConvention() );
+ String sRangeStr;
+ rNewRangeListRef->Format( sRangeStr, SCR_ABS_3D, this, GetAddressConvention() );
- lcl_SetChartParameters( xReceiver, sRangeStr, eDataRowSource, bHasCategories, bFirstCellAsLabel );
+ lcl_SetChartParameters( xReceiver, sRangeStr, eDataRowSource, bHasCategories, bFirstCellAsLabel );
- // don't modify pChartListenerCollection here, called from there
- return;
- }
+ // don't modify pChartListenerCollection here, called from there
+ return;
}
}
pObject = aIter.Next();
diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx
index b9abe0839279..9da788fca01c 100644
--- a/sc/source/core/data/documen9.cxx
+++ b/sc/source/core/data/documen9.cxx
@@ -28,10 +28,6 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sc.hxx"
-#include <com/sun/star/embed/XEmbeddedObject.hpp>
-#include <com/sun/star/embed/XClassifiedObject.hpp>
-#include <com/sun/star/chart2/data/XDataReceiver.hpp>
-
// INCLUDE ---------------------------------------------------------------
#include "scitems.hxx"
@@ -65,10 +61,10 @@
#include "rechead.hxx"
#include "poolhelp.hxx"
#include "docpool.hxx"
-#include "chartarr.hxx"
#include "detfunc.hxx" // for UpdateAllComments
#include "editutil.hxx"
#include "postit.hxx"
+#include "charthelper.hxx"
using namespace ::com::sun::star;
@@ -102,37 +98,6 @@ XColorTable* ScDocument::GetColorTable()
}
}
-BOOL lcl_AdjustRanges( ScRangeList& rRanges, SCTAB nSource, SCTAB nDest, SCTAB nTabCount )
-{
- //! if multiple sheets are copied, update references into the other copied sheets?
-
- BOOL bChanged = FALSE;
-
- ULONG nCount = rRanges.Count();
- for (ULONG i=0; i<nCount; i++)
- {
- ScRange* pRange = rRanges.GetObject(i);
- if ( pRange->aStart.Tab() == nSource && pRange->aEnd.Tab() == nSource )
- {
- pRange->aStart.SetTab( nDest );
- pRange->aEnd.SetTab( nDest );
- bChanged = TRUE;
- }
- if ( pRange->aStart.Tab() >= nTabCount )
- {
- pRange->aStart.SetTab( nTabCount > 0 ? ( nTabCount - 1 ) : 0 );
- bChanged = TRUE;
- }
- if ( pRange->aEnd.Tab() >= nTabCount )
- {
- pRange->aEnd.SetTab( nTabCount > 0 ? ( nTabCount - 1 ) : 0 );
- bChanged = TRUE;
- }
- }
-
- return bChanged;
-}
-
void ScDocument::TransferDrawPage(ScDocument* pSrcDoc, SCTAB nSrcPos, SCTAB nDestPos)
{
if (pDrawLayer && pSrcDoc->pDrawLayer)
@@ -158,53 +123,14 @@ void ScDocument::TransferDrawPage(ScDocument* pSrcDoc, SCTAB nSrcPos, SCTAB nDes
if (pDrawLayer->IsRecording())
pDrawLayer->AddCalcUndo( new SdrUndoInsertObj( *pNewObject ) );
- // #71726# if it's a chart, make sure the data references are valid
- // (this must be after InsertObject!)
-
- if ( pNewObject->GetObjIdentifier() == OBJ_OLE2 )
- {
- uno::Reference< embed::XEmbeddedObject > xIPObj = ((SdrOle2Obj*)pNewObject)->GetObjRef();
- uno::Reference< embed::XClassifiedObject > xClassified( xIPObj, uno::UNO_QUERY );
- SvGlobalName aObjectClassName;
- if ( xClassified.is() )
- {
- try {
- aObjectClassName = SvGlobalName( xClassified->getClassID() );
- } catch( uno::Exception& )
- {
- // TODO: handle error?
- }
- }
-
- if ( xIPObj.is() && SotExchange::IsChart( aObjectClassName ) )
- {
- String aChartName = ((SdrOle2Obj*)pNewObject)->GetPersistName();
-
- uno::Reference< chart2::XChartDocument > xChartDoc( GetChartByName( aChartName ) );
- uno::Reference< chart2::data::XDataReceiver > xReceiver( xChartDoc, uno::UNO_QUERY );
- if( xChartDoc.is() && xReceiver.is() )
- {
- if( !xChartDoc->hasInternalDataProvider() )
- {
- ::std::vector< ScRangeList > aRangesVector;
- GetChartRanges( aChartName, aRangesVector, pSrcDoc );
-
- ::std::vector< ScRangeList >::iterator aIt( aRangesVector.begin() );
- for( ; aIt!=aRangesVector.end(); aIt++ )
- {
- ScRangeList& rScRangeList( *aIt );
- lcl_AdjustRanges( rScRangeList, nSrcPos, nDestPos, GetTableCount() );
- }
- SetChartRanges( aChartName, aRangesVector );
- }
- }
- }
- }
-
pOldObject = aIter.Next();
}
}
}
+
+ // #71726# make sure the data references of charts are adapted
+ // (this must be after InsertObject!)
+ ScChartHelper::AdjustRangesOfChartsOnDestinationPage( pSrcDoc, this, nSrcPos, nDestPos );
}
void ScDocument::InitDrawLayer( SfxObjectShell* pDocShell )
@@ -242,7 +168,7 @@ void ScDocument::InitDrawLayer( SfxObjectShell* pDocShell )
pTab[nTab]->GetName(aTabName);
pDrawLayer->ScRenamePage( nTab, aTabName );
- pTab[nTab]->SetDrawPageSize(false); // #54782# set the right size immediately
+ pTab[nTab]->SetDrawPageSize(false,false); // #54782# set the right size immediately
#if 0
ULONG nx = (ULONG) ((double) (MAXCOL+1) * STD_COL_WIDTH * HMM_PER_TWIPS );
ULONG ny = (ULONG) ((double) (MAXROW+1) * ScGlobal::nStdRowHeight * HMM_PER_TWIPS );
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index fa4fb296d9a7..3f25ad5a310e 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -696,14 +696,22 @@ bool ScDocument::ShrinkToDataArea(SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow
return true; // success!
}
+bool ScDocument::ShrinkToUsedDataArea( SCTAB nTab, SCCOL& rStartCol,
+ SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly ) const
+{
+ if (!ValidTab(nTab) || !pTab[nTab])
+ return false;
+ return pTab[nTab]->ShrinkToUsedDataArea( rStartCol, rStartRow, rEndCol, rEndRow, bColumnsOnly);
+}
+
// zusammenhaengender Bereich
void ScDocument::GetDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
- SCCOL& rEndCol, SCROW& rEndRow, BOOL bIncludeOld )
+ SCCOL& rEndCol, SCROW& rEndRow, BOOL bIncludeOld, bool bOnlyDown )
{
if (VALIDTAB(nTab))
if (pTab[nTab])
- pTab[nTab]->GetDataArea( rStartCol, rStartRow, rEndCol, rEndRow, bIncludeOld );
+ pTab[nTab]->GetDataArea( rStartCol, rStartRow, rEndCol, rEndRow, bIncludeOld, bOnlyDown );
}
@@ -953,7 +961,7 @@ void ScDocument::DeleteRow( SCCOL nStartCol, SCTAB nStartTab,
{
UpdateReference( URM_INSDEL, nStartCol, nStartRow+nSize, nTabRangeStart,
nEndCol, MAXROW, nTabRangeEnd,
- 0, -(static_cast<SCsROW>(nSize)), 0, pRefUndoDoc );
+ 0, -(static_cast<SCsROW>(nSize)), 0, pRefUndoDoc, TRUE, false );
}
while ( lcl_GetNextTabRange( nTabRangeStart, nTabRangeEnd, pTabMark ) );
}
@@ -1054,7 +1062,7 @@ BOOL ScDocument::InsertCol( SCROW nStartRow, SCTAB nStartTab,
{
UpdateReference( URM_INSDEL, nStartCol, nStartRow, nTabRangeStart,
MAXCOL, nEndRow, nTabRangeEnd,
- static_cast<SCsCOL>(nSize), 0, 0, pRefUndoDoc );
+ static_cast<SCsCOL>(nSize), 0, 0, pRefUndoDoc, TRUE, false );
}
while ( lcl_GetNextTabRange( nTabRangeStart, nTabRangeEnd, pTabMark ) );
@@ -1143,7 +1151,7 @@ void ScDocument::DeleteCol(SCROW nStartRow, SCTAB nStartTab, SCROW nEndRow, SCTA
{
UpdateReference( URM_INSDEL, sal::static_int_cast<SCCOL>(nStartCol+nSize), nStartRow, nTabRangeStart,
MAXCOL, nEndRow, nTabRangeEnd,
- -static_cast<SCsCOL>(nSize), 0, 0, pRefUndoDoc );
+ -static_cast<SCsCOL>(nSize), 0, 0, pRefUndoDoc, TRUE, false );
}
while ( lcl_GetNextTabRange( nTabRangeStart, nTabRangeEnd, pTabMark ) );
}
@@ -2644,10 +2652,11 @@ void ScDocument::PutCell( const ScAddress& rPos, ScBaseCell* pCell, BOOL bForceT
}
-BOOL ScDocument::SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rString )
+BOOL ScDocument::SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rString,
+ SvNumberFormatter* pFormatter, bool bDetectNumberFormat )
{
if ( ValidTab(nTab) && pTab[nTab] )
- return pTab[nTab]->SetString( nCol, nRow, nTab, rString );
+ return pTab[nTab]->SetString( nCol, nRow, nTab, rString, pFormatter, bDetectNumberFormat );
else
return FALSE;
}
@@ -3906,7 +3915,7 @@ void ScDocument::GetSelectionFrame( const ScMarkData& rMark,
}
-BOOL ScDocument::HasAttrib( SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
+bool ScDocument::HasAttrib( SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
SCCOL nCol2, SCROW nRow2, SCTAB nTab2, USHORT nMask )
{
if ( nMask & HASATTR_ROTATE )
@@ -3960,16 +3969,16 @@ BOOL ScDocument::HasAttrib( SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
}
if (!nMask)
- return FALSE;
+ return false;
- BOOL bFound = FALSE;
+ bool bFound = false;
for (SCTAB i=nTab1; i<=nTab2 && !bFound; i++)
if (pTab[i])
{
if ( nMask & HASATTR_RTL )
{
if ( GetEditTextDirection(i) == EE_HTEXTDIR_R2L ) // sheet default
- bFound = TRUE;
+ bFound = true;
}
if ( nMask & HASATTR_RIGHTORCENTER )
{
@@ -3978,7 +3987,7 @@ BOOL ScDocument::HasAttrib( SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
// That way, ScAttrArray::HasAttrib doesn't have to handle RTL sheets.
if ( IsLayoutRTL(i) )
- bFound = TRUE;
+ bFound = true;
}
if ( !bFound )
@@ -3988,7 +3997,7 @@ BOOL ScDocument::HasAttrib( SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
return bFound;
}
-BOOL ScDocument::HasAttrib( const ScRange& rRange, USHORT nMask )
+bool ScDocument::HasAttrib( const ScRange& rRange, USHORT nMask )
{
return HasAttrib( rRange.aStart.Col(), rRange.aStart.Row(), rRange.aStart.Tab(),
rRange.aEnd.Col(), rRange.aEnd.Row(), rRange.aEnd.Tab(),
diff --git a/sc/source/core/data/dpcachetable.cxx b/sc/source/core/data/dpcachetable.cxx
index 237d7ffd16db..ad5e921cb278 100644
--- a/sc/source/core/data/dpcachetable.cxx
+++ b/sc/source/core/data/dpcachetable.cxx
@@ -65,7 +65,6 @@ using ::com::sun::star::uno::UNO_QUERY;
using ::com::sun::star::uno::UNO_QUERY_THROW;
using ::com::sun::star::sheet::DataPilotFieldFilter;
-const double D_TIMEFACTOR = 86400.0;
static BOOL lcl_HasQueryEntry( const ScQueryParam& rParam )
{
@@ -75,56 +74,35 @@ static BOOL lcl_HasQueryEntry( const ScQueryParam& rParam )
// ----------------------------------------------------------------------------
-static ScDPCacheCell EmptyCellContent = ScDPCacheCell();
-
-// ----------------------------------------------------------------------------
-
-ScDPCacheTable::Cell::Cell() :
- mnCategoryRef(0),
- mpContent(NULL)
-{
-}
-
-ScDPCacheTable::Cell::~Cell()
-{
-}
-
-// ----------------------------------------------------------------------------
-
ScDPCacheTable::FilterItem::FilterItem() :
- mnMatchStrId(ScSimpleSharedString::EMPTY),
mfValue(0.0),
mbHasValue(false)
{
}
-
+bool ScDPCacheTable::FilterItem::match( const ScDPItemData& rCellData ) const
+{
+ if (rCellData.GetString()!= maString &&
+ (!rCellData.IsValue()|| rCellData.GetValue()!= mfValue))
+ return false;
+ return true;
+}
// ----------------------------------------------------------------------------
-ScDPCacheTable::SingleFilter::SingleFilter(ScSimpleSharedString& rSharedString,
- sal_Int32 nMatchStrId, double fValue, bool bHasValue) :
- mrSharedString(rSharedString)
+ScDPCacheTable::SingleFilter::SingleFilter(String aString, double fValue, bool bHasValue)
{
- maItem.mnMatchStrId = nMatchStrId;
+ maItem.maString = aString;
maItem.mfValue = fValue;
maItem.mbHasValue = bHasValue;
}
-bool ScDPCacheTable::SingleFilter::match(const ScDPCacheCell& rCell) const
+bool ScDPCacheTable::SingleFilter::match( const ScDPItemData& rCellData ) const
{
- if (rCell.mnStrId != maItem.mnMatchStrId &&
- (!rCell.mbNumeric || rCell.mfValue != maItem.mfValue))
- return false;
-
- return true;
+ return maItem.match(rCellData);
}
const String ScDPCacheTable::SingleFilter::getMatchString()
{
- const String* pStr = mrSharedString.getString(maItem.mnMatchStrId);
- if (pStr)
- return *pStr;
-
- return String();
+ return maItem.maString;
}
double ScDPCacheTable::SingleFilter::getMatchValue() const
@@ -139,33 +117,26 @@ bool ScDPCacheTable::SingleFilter::hasValue() const
// ----------------------------------------------------------------------------
-ScDPCacheTable::GroupFilter::GroupFilter(ScSimpleSharedString& rSharedString) :
- mrSharedString(rSharedString)
+ScDPCacheTable::GroupFilter::GroupFilter()
{
}
-bool ScDPCacheTable::GroupFilter::match(const ScDPCacheCell& rCell) const
+bool ScDPCacheTable::GroupFilter::match( const ScDPItemData& rCellData ) const
{
vector<FilterItem>::const_iterator itrEnd = maItems.end();
- for (vector<FilterItem>::const_iterator itr = maItems.begin(); itr != itrEnd; ++itr)
- {
- bool bMatch = false;
- if (rCell.mbNumeric)
- bMatch = (itr->mfValue == rCell.mfValue);
- else
- bMatch = (itr->mnMatchStrId == rCell.mnStrId);
-
- if (bMatch)
- return true;
- }
- return false;
+ for (vector<FilterItem>::const_iterator itr = maItems.begin(); itr != itrEnd; ++itr)
+ {
+ bool bMatch = itr->match( rCellData);
+ if (bMatch)
+ return true;
+ }
+ return false;
}
void ScDPCacheTable::GroupFilter::addMatchItem(const String& rStr, double fVal, bool bHasValue)
{
- sal_Int32 nStrId = mrSharedString.getStringId(rStr);
FilterItem aItem;
- aItem.mnMatchStrId = nStrId;
+ aItem.maString = rStr;
aItem.mfValue = fVal;
aItem.mbHasValue = bHasValue;
maItems.push_back(aItem);
@@ -186,10 +157,16 @@ ScDPCacheTable::Criterion::Criterion() :
// ----------------------------------------------------------------------------
-ScDPCacheTable::ScDPCacheTable(ScDPCollection* pCollection) :
- mrSharedString(pCollection->GetSharedString()),
- mpCollection(pCollection)
+ScDPCacheTable::ScDPCacheTable( ScDocument* pDoc,long nId ) :
+ mpCache( NULL ),
+ mpNoneCache( NULL )
{
+ if ( nId >= 0 )
+ mpCache = pDoc->GetDPObjectCache( nId );
+ else
+ { //create a temp cache object
+ InitNoneCache( NULL );
+ }
}
ScDPCacheTable::~ScDPCacheTable()
@@ -198,12 +175,12 @@ ScDPCacheTable::~ScDPCacheTable()
sal_Int32 ScDPCacheTable::getRowSize() const
{
- return maTable.size();
+ return GetCache()->GetRowCount();
}
sal_Int32 ScDPCacheTable::getColSize() const
{
- return maTable.empty() ? 0 : maTable[0].size();
+ return GetCache()->GetColumnCount();
}
namespace {
@@ -230,276 +207,114 @@ private:
}
-void ScDPCacheTable::fillTable(ScDocument* pDoc, const ScRange& rRange, const ScQueryParam& rQuery, BOOL* pSpecial,
- bool bIgnoreEmptyRows)
+void ScDPCacheTable::fillTable( const ScQueryParam& rQuery, BOOL* pSpecial,
+ bool bIgnoreEmptyRows, bool bRepeatIfEmpty )
{
// Make sure the formula cells within the data range are interpreted
// during this call, for this method may be called from the interpretation
// of GETPIVOTDATA, which disables nested formula interpretation without
// increasing the macro level.
- MacroInterpretIncrementer aMacroInc(pDoc);
-
- SCTAB nTab = rRange.aStart.Tab();
- SCCOL nStartCol = rRange.aStart.Col();
- SCROW nStartRow = rRange.aStart.Row();
- SCCOL nColCount = rRange.aEnd.Col() - rRange.aStart.Col() + 1;
- SCROW nRowCount = rRange.aEnd.Row() - rRange.aStart.Row() + 1;
-
- if (nRowCount <= 1 || nColCount <= 0)
+ MacroInterpretIncrementer aMacroInc(GetCache()->GetDoc());
+
+ if ( mpCache == NULL )
+ InitNoneCache( NULL );
+//check cache
+ const SCROW nRowCount = getRowSize();
+ const SCCOL nColCount = (SCCOL) getColSize();
+ if ( nRowCount <= 0 || nColCount <= 0)
return;
- maTable.clear();
- maTable.reserve(nRowCount);
- maHeader.clear();
- maHeader.reserve(nColCount);
maRowsVisible.clear();
maRowsVisible.reserve(nRowCount);
- // Header row
- for (SCCOL nCol = 0; nCol < nColCount; ++nCol)
- {
- String aStr;
- pDoc->GetString(nCol + nStartCol, nStartRow, nTab, aStr);
- sal_Int32 nStrId = mrSharedString.insertString(aStr);
- maHeader.push_back(nStrId);
- }
// Initialize field entries container.
maFieldEntries.clear();
maFieldEntries.reserve(nColCount);
- for (SCCOL nCol = 0; nCol < nColCount; ++nCol)
- {
- TypedScStrCollectionPtr p(new TypedScStrCollection);
- maFieldEntries.push_back(p);
- }
-
- vector<SCROW> aLastNonEmptyRows(nColCount, 0);
// Data rows
- for (SCROW nRow = 1; nRow < nRowCount; ++nRow)
+ for (SCCOL nCol = 0; nCol < nColCount; ++nCol)
{
- if ( lcl_HasQueryEntry(rQuery) && !pDoc->ValidQuery(nRow + nStartRow, nTab, rQuery, pSpecial) )
- // filtered out by standard filter.
- continue;
-
- if ( bIgnoreEmptyRows &&
- pDoc->IsBlockEmpty(nTab, nStartCol, nRow + nStartRow,
- nStartCol + nColCount - 1, nRow + nStartRow) )
- // skip an empty row.
- continue;
-
- // Insert a new row into cache table.
- maRowsVisible.push_back(true);
- maTable.push_back( vector<Cell>() );
- maTable.back().reserve(nColCount);
-
- for (SCCOL nCol = 0; nCol < nColCount; ++nCol)
+ SCROW nMemCount = GetCache()->GetDimMemberCount( nCol );
+ if ( nMemCount )
{
- maTable.back().push_back( ScDPCacheTable::Cell() );
- Cell& rCell = maTable.back().back();
- rCell.mnCategoryRef = maTable.size()-1;
+ std::vector< SCROW > pAdded( nMemCount, -1 );
- String aCellStr;
- bool bReadCell = nRow == 0 || pDoc->HasData(nStartCol + nCol, nStartRow + nRow, nTab);
- if (bReadCell)
+ for (SCROW nRow = 0; nRow < nRowCount; ++nRow )
{
- aLastNonEmptyRows[nCol] = maTable.size()-1;
- ScDPCacheCell aCell;
- pDoc->GetString(nStartCol + nCol, nStartRow + nRow, nTab, aCellStr);
- aCell.mnStrId = mrSharedString.insertString(aCellStr);
- aCell.mnType = SC_VALTYPE_STRING;
- aCell.mbNumeric = false;
- ScAddress aPos(nStartCol + nCol, nStartRow + nRow, nTab);
- getValueData(pDoc, aPos, aCell);
- rCell.mpContent = mpCollection->getCacheCellFromPool(aCell);
+ SCROW nIndex = GetCache()->GetItemDataId( nCol, nRow, bRepeatIfEmpty );
+ SCROW nOrder = GetCache()->GetOrder( nCol, nIndex );
+
+ if ( nCol == 0 )
+ maRowsVisible.push_back(false);
+
+ if ( lcl_HasQueryEntry(rQuery) &&
+ !GetCache()->ValidQuery( nRow , rQuery, pSpecial ) )
+ continue;
+ if ( bIgnoreEmptyRows && GetCache()->IsRowEmpty( nRow ) )
+ continue;
+ // Insert a new row into cache table.
+ if ( nCol == 0 )
+ maRowsVisible.back() = true;
+
+ pAdded[nOrder] = nIndex;
+ }
+ maFieldEntries.push_back( vector<SCROW>() );
+ for ( SCROW nRow = 0; nRow < nMemCount; nRow++ )
+ {
+ if ( pAdded[nRow] != -1 )
+ maFieldEntries.back().push_back( pAdded[nRow] );
}
- else
- rCell.mnCategoryRef = aLastNonEmptyRows[nCol];
-
- TypedStrData* pNew;
- if (rCell.mpContent && rCell.mpContent->mbNumeric)
- pNew = new TypedStrData(aCellStr, rCell.mpContent->mfValue, SC_STRTYPE_VALUE);
- else
- pNew = new TypedStrData(aCellStr);
-
- if (!maFieldEntries[nCol]->Insert(pNew))
- delete pNew;
}
}
}
-void lcl_GetCellValue(const Reference<sdbc::XRow>& xRow, sal_Int32 nType, long nCol,
- const Date& rNullDate, ScDPCacheCell& rCell, String& rStr,
- ScSimpleSharedString& rSharedString)
+void ScDPCacheTable::fillTable()
{
- short nNumType = NUMBERFORMAT_NUMBER;
- BOOL bEmptyFlag = FALSE;
- try
- {
- rStr = xRow->getString(nCol);
- rCell.mnStrId = rSharedString.getStringId(rStr);
- rCell.mnType = SC_VALTYPE_STRING;
-
- switch (nType)
- {
- case sdbc::DataType::BIT:
- case sdbc::DataType::BOOLEAN:
- {
- nNumType = NUMBERFORMAT_LOGICAL;
- rCell.mfValue = xRow->getBoolean(nCol) ? 1 : 0;
- bEmptyFlag = (rCell.mfValue == 0.0 && xRow->wasNull());
- rCell.mbNumeric = true;
- rCell.mnType = SC_VALTYPE_VALUE;
- }
- break;
-
- case sdbc::DataType::TINYINT:
- case sdbc::DataType::SMALLINT:
- case sdbc::DataType::INTEGER:
- case sdbc::DataType::BIGINT:
- case sdbc::DataType::FLOAT:
- case sdbc::DataType::REAL:
- case sdbc::DataType::DOUBLE:
- case sdbc::DataType::NUMERIC:
- case sdbc::DataType::DECIMAL:
- {
- //! do the conversion here?
- rCell.mfValue = xRow->getDouble(nCol);
- bEmptyFlag = (rCell.mfValue == 0.0 && xRow->wasNull());
- rCell.mbNumeric = true;
- rCell.mnType = SC_VALTYPE_VALUE;
- }
- break;
-
- case sdbc::DataType::CHAR:
- case sdbc::DataType::VARCHAR:
- case sdbc::DataType::LONGVARCHAR:
- bEmptyFlag = (rStr.Len() == 0 && xRow->wasNull());
- break;
+ if ( mpCache == NULL )
+ InitNoneCache( NULL );
+//check cache
+ const SCROW nRowCount = getRowSize();
+ const SCCOL nColCount = (SCCOL) getColSize();
+ if ( nRowCount <= 0 || nColCount <= 0)
+ return;
- case sdbc::DataType::DATE:
- {
- nNumType = NUMBERFORMAT_DATE;
+ maRowsVisible.clear();
+ maRowsVisible.reserve(nRowCount);
- util::Date aDate = xRow->getDate(nCol);
- rCell.mfValue = Date(aDate.Day, aDate.Month, aDate.Year) - rNullDate;
- bEmptyFlag = xRow->wasNull();
- rCell.mbNumeric = true;
- rCell.mnType = SC_VALTYPE_VALUE;
- }
- break;
- case sdbc::DataType::TIME:
- {
- nNumType = NUMBERFORMAT_TIME;
-
- util::Time aTime = xRow->getTime(nCol);
- rCell.mfValue = ( aTime.Hours * 3600 + aTime.Minutes * 60 +
- aTime.Seconds + aTime.HundredthSeconds / 100.0 ) / D_TIMEFACTOR;
- bEmptyFlag = xRow->wasNull();
- rCell.mbNumeric = true;
- rCell.mnType = SC_VALTYPE_VALUE;
- }
- break;
+ // Initialize field entries container.
+ maFieldEntries.clear();
+ maFieldEntries.reserve(nColCount);
- case sdbc::DataType::TIMESTAMP:
- {
- nNumType = NUMBERFORMAT_DATETIME;
-
- util::DateTime aStamp = xRow->getTimestamp(nCol);
- rCell.mfValue = ( Date( aStamp.Day, aStamp.Month, aStamp.Year ) - rNullDate ) +
- ( aStamp.Hours * 3600 + aStamp.Minutes * 60 +
- aStamp.Seconds + aStamp.HundredthSeconds / 100.0 ) / D_TIMEFACTOR;
- bEmptyFlag = xRow->wasNull();
- rCell.mbNumeric = true;
- rCell.mnType = SC_VALTYPE_VALUE;
- }
- break;
-
- case sdbc::DataType::SQLNULL:
- case sdbc::DataType::BINARY:
- case sdbc::DataType::VARBINARY:
- case sdbc::DataType::LONGVARBINARY:
- default:
- break;
- }
- }
- catch (uno::Exception&)
+ // Data rows
+ for (SCCOL nCol = 0; nCol < nColCount; ++nCol)
{
- }
-}
+ SCROW nMemCount = GetCache()->GetDimMemberCount( nCol );
+ if ( nMemCount )
+ {
+ std::vector< SCROW > pAdded( nMemCount, -1 );
-void ScDPCacheTable::fillTable(const Reference<sdbc::XRowSet>& xRowSet, const Date& rNullDate)
-{
- if (!xRowSet.is())
- // Dont' even waste time to go any further.
- return;
+ for (SCROW nRow = 0; nRow < nRowCount; ++nRow )
+ {
+ SCROW nIndex = GetCache()->GetItemDataId( nCol, nRow, false );
+ SCROW nOrder = GetCache()->GetOrder( nCol, nIndex );
- try
- {
- Reference<sdbc::XResultSetMetaDataSupplier> xMetaSupp(xRowSet, UNO_QUERY_THROW);
- Reference<sdbc::XResultSetMetaData> xMeta = xMetaSupp->getMetaData();
- if (!xMeta.is())
- return;
-
- sal_Int32 nColCount = xMeta->getColumnCount();
-
- // Get column titles and types.
- vector<sal_Int32> aColTypes(nColCount);
- maHeader.clear();
- maHeader.reserve(nColCount);
- for (sal_Int32 nCol = 0; nCol < nColCount; ++nCol)
- {
- String aColTitle = xMeta->getColumnLabel(nCol+1);
- aColTypes[nCol] = xMeta->getColumnType(nCol+1);
- maHeader.push_back( mrSharedString.getStringId(aColTitle) );
- }
+ if ( nCol == 0 )
+ maRowsVisible.push_back(true);
- // Initialize field entries container.
- maFieldEntries.clear();
- maFieldEntries.reserve(nColCount);
- for (SCCOL nCol = 0; nCol < nColCount; ++nCol)
- {
- TypedScStrCollectionPtr p(new TypedScStrCollection);
- maFieldEntries.push_back(p);
- }
- // Now get the data rows.
- Reference<sdbc::XRow> xRow(xRowSet, UNO_QUERY_THROW);
- xRowSet->first();
- maTable.clear();
- maRowsVisible.clear();
- do
- {
- maRowsVisible.push_back(true);
- maTable.push_back( vector<Cell>() );
- maTable.back().reserve(nColCount);
- for (sal_Int32 nCol = 0; nCol < nColCount; ++nCol)
+ pAdded[nOrder] = nIndex;
+ }
+ maFieldEntries.push_back( vector<SCROW>() );
+ for ( SCROW nRow = 0; nRow < nMemCount; nRow++ )
{
- maTable.back().push_back( Cell() );
- Cell& rCell = maTable.back().back();
- ScDPCacheCell aCellContent;
- String aStr;
- lcl_GetCellValue(xRow, aColTypes[nCol], nCol+1, rNullDate, aCellContent, aStr, mrSharedString);
- rCell.mpContent = mpCollection->getCacheCellFromPool(aCellContent);
-
- TypedStrData* pNew;
- if (rCell.mpContent->mbNumeric)
- pNew = new TypedStrData(aStr, rCell.mpContent->mfValue, SC_STRTYPE_VALUE);
- else
- pNew = new TypedStrData(aStr);
-
- if (!maFieldEntries[nCol]->Insert(pNew))
- delete pNew;
+ if ( pAdded[nRow] != -1 )
+ maFieldEntries.back().push_back( pAdded[nRow] );
}
}
- while (xRowSet->next());
-
- xRowSet->beforeFirst();
- }
- catch (const Exception&)
- {
}
+ return;
}
bool ScDPCacheTable::isRowActive(sal_Int32 nRow) const
@@ -524,41 +339,43 @@ void ScDPCacheTable::filterByPageDimension(const vector<Criterion>& rCriteria, c
maRowsVisible[nRow] = isRowQualified(nRow, rCriteria, rRepeatIfEmptyDims);
}
-const ScDPCacheCell* ScDPCacheTable::getCell(SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const
+const ScDPItemData* ScDPCacheTable::getCell(SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const
{
- if ( nRow >= static_cast<SCROW>(maTable.size()) )
- return NULL;
-
- const vector<Cell>& rRow = maTable[nRow];
- if ( nCol < 0 || static_cast<size_t>(nCol) >= rRow.size() )
- return NULL;
+ SCROW nId= GetCache()->GetItemDataId(nCol, nRow, bRepeatIfEmpty);
+ return GetCache()->GetItemDataById( nCol, nId );
+}
- const Cell& rCell = rRow[nCol];
- const ScDPCacheCell* pCell = rCell.mpContent;
- if (bRepeatIfEmpty && !pCell)
- pCell = getCell(nCol, rCell.mnCategoryRef, false);
+void ScDPCacheTable::getValue( ScDPValueData& rVal, SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const
+{
+ const ScDPItemData* pData = getCell( nCol, nRow, bRepeatIfEmpty );
- return pCell ? pCell : &EmptyCellContent;
+ if (pData)
+ {
+ rVal.fValue = pData->IsValue() ? pData->GetValue() : 0.0;
+ rVal.nType = pData->GetType();
+ }
+ else
+ rVal.Set(0.0, SC_VALTYPE_EMPTY);
}
-
-const String* ScDPCacheTable::getFieldName(sal_Int32 nIndex) const
+String ScDPCacheTable::getFieldName(SCCOL nIndex) const
{
- if (nIndex >= static_cast<sal_Int32>(maHeader.size()))
- return NULL;
+ return (GetCache()->GetDimensionName( nIndex ));
+}
- return mrSharedString.getString(maHeader[nIndex]);
+sal_Int32 ScDPCacheTable::getFieldIndex(const String& rStr) const
+{
+ return GetCache()->GetDimensionIndex( rStr );
}
-const TypedScStrCollection& ScDPCacheTable::getFieldEntries(sal_Int32 nIndex) const
+const ::std::vector<SCROW>& ScDPCacheTable::getFieldEntries( sal_Int32 nColumn ) const
{
- if (nIndex < 0 || static_cast<size_t>(nIndex) >= maFieldEntries.size())
+ if (nColumn < 0 || static_cast<size_t>(nColumn) >= maFieldEntries.size())
{
// index out of bound. Hopefully this code will never be reached.
- static const TypedScStrCollection emptyCollection;
- return emptyCollection;
+ static const ::std::vector<SCROW> emptyEntries;
+ return emptyEntries;
}
-
- return *maFieldEntries[nIndex].get();
+ return maFieldEntries[nColumn];
}
void ScDPCacheTable::filterTable(const vector<Criterion>& rCriteria, Sequence< Sequence<Any> >& rTabData,
@@ -577,13 +394,10 @@ void ScDPCacheTable::filterTable(const vector<Criterion>& rCriteria, Sequence< S
// Header first.
Sequence<Any> headerRow(nColSize);
- for (sal_Int32 nCol = 0; nCol < nColSize; ++nCol)
+ for (SCCOL nCol = 0; nCol < nColSize; ++nCol)
{
OUString str;
- const String* pStr = mrSharedString.getString(maHeader[nCol]);
- if (pStr)
- str = *pStr;
-
+ str = getFieldName( nCol);
Any any;
any <<= str;
headerRow[nCol] = any;
@@ -607,26 +421,14 @@ void ScDPCacheTable::filterTable(const vector<Criterion>& rCriteria, Sequence< S
{
Any any;
bool bRepeatIfEmpty = rRepeatIfEmptyDims.count(nCol) > 0;
- const ScDPCacheCell* pCell = getCell(nCol, nRow, bRepeatIfEmpty);
- if (!pCell)
- {
- // This should never happen, but in case this happens, just
- // stick in an empty string.
- OUString str;
- any <<= str;
- row[nCol] = any;
- continue;
- }
-
- if (pCell->mbNumeric)
- any <<= pCell->mfValue;
+ // Wang Xu Ming - DataPilot migration
+ const ScDPItemData* pData= getCell(nCol, nRow, bRepeatIfEmpty);
+ if ( pData->IsValue() )
+ any <<= pData->GetValue();
else
{
- OUString str;
- const String* pStr = mrSharedString.getString(pCell->mnStrId);
- if (pStr)
- str = *pStr;
- any <<= str;
+ OUString string (pData->GetString() );
+ any <<= string;
}
row[nCol] = any;
}
@@ -642,15 +444,19 @@ void ScDPCacheTable::filterTable(const vector<Criterion>& rCriteria, Sequence< S
void ScDPCacheTable::clear()
{
- maTable.clear();
- maHeader.clear();
maFieldEntries.clear();
maRowsVisible.clear();
}
+void ScDPCacheTable::swap(ScDPCacheTable& rOther)
+{
+ maFieldEntries.swap(rOther.maFieldEntries);
+ maRowsVisible.swap(rOther.maRowsVisible);
+}
+
bool ScDPCacheTable::empty() const
{
- return maTable.empty();
+ return ( mpCache == NULL&& mpNoneCache == NULL ) || maFieldEntries.size()==0;
}
bool ScDPCacheTable::isRowQualified(sal_Int32 nRow, const vector<Criterion>& rCriteria,
@@ -667,52 +473,26 @@ bool ScDPCacheTable::isRowQualified(sal_Int32 nRow, const vector<Criterion>& rCr
// Check if the 'repeat if empty' flag is set for this field.
bool bRepeatIfEmpty = rRepeatIfEmptyDims.count(itr->mnFieldIndex) > 0;
- const ScDPCacheCell* pCell = getCell(static_cast<SCCOL>(itr->mnFieldIndex), nRow, bRepeatIfEmpty);
- if (!pCell)
- // This should never happen, but just in case...
- return false;
-
- if (!itr->mpFilter->match(*pCell))
+ const ScDPItemData* pCellData = getCell(static_cast<SCCOL>(itr->mnFieldIndex), nRow, bRepeatIfEmpty);
+ if (!itr->mpFilter->match(*pCellData))
return false;
}
return true;
}
-void ScDPCacheTable::getValueData(ScDocument* pDoc, const ScAddress& rPos, ScDPCacheCell& rCell)
-{
- ScBaseCell* pCell = pDoc->GetCell(rPos);
- if (!pCell)
- {
- rCell.mnType = SC_VALTYPE_EMPTY;
- return;
- }
-
- CellType eType = pCell->GetCellType();
- if (eType == CELLTYPE_NOTE)
- {
- // note cell
- rCell.mnType = SC_VALTYPE_EMPTY;
- return;
- }
- if (eType == CELLTYPE_FORMULA && static_cast<ScFormulaCell*>(pCell)->GetErrCode())
- {
- // formula cell with error
- rCell.mnType = SC_VALTYPE_ERROR;
- return;
- }
-
- if ( pCell->HasValueData() )
- {
- if (eType == CELLTYPE_VALUE)
- // value cell
- rCell.mfValue = static_cast<ScValueCell*>(pCell)->GetValue();
- else if (eType == CELLTYPE_FORMULA)
- // formula cell
- rCell.mfValue = static_cast<ScFormulaCell*>(pCell)->GetValue();
-
- rCell.mbNumeric = true;
- rCell.mnType = SC_VALTYPE_VALUE;
- }
+void ScDPCacheTable::InitNoneCache( ScDocument* pDoc )
+{
+ mpCache = NULL;
+ if ( mpNoneCache )
+ delete mpNoneCache;
+ mpNoneCache = new ScDPTableDataCache( pDoc );
}
+ScDPTableDataCache* ScDPCacheTable::GetCache() const
+{
+ if ( mpCache )
+ return mpCache;
+ return mpNoneCache;
+}
+// End Comments
diff --git a/sc/source/core/data/dpglobal.cxx b/sc/source/core/data/dpglobal.cxx
new file mode 100755
index 000000000000..6b84d37d8d0f
--- /dev/null
+++ b/sc/source/core/data/dpglobal.cxx
@@ -0,0 +1,150 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright IBM Corporation 2009.
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: dpglobal.cxx,v $
+ * $Revision: 1.0 $
+ *
+ * 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_sc.hxx"
+
+#include "dpglobal.hxx"
+#include "document.hxx"
+
+#include <stdio.h>
+
+namespace ScDPGlobal
+{
+ Rectangle operator *( const Rectangle &rLeft, const std::pair<double,double> & rRight )
+ {
+ Rectangle rcResult( rLeft );
+ rcResult.Bottom() = rcResult.Top() + static_cast<long>( rcResult.GetHeight() * rRight.second );
+ rcResult.Right() = rcResult.Left() + static_cast<long>( rcResult.GetWidth() * rRight.first);
+ return rcResult;
+ }
+
+ String GetFuncString( const String &rString, const USHORT nIndex )
+ {
+ if ( nIndex <= 1 ) return rString;
+ ULONG uch = rString.Len() ? rString.GetChar( rString.Len()-1 ) : (L'9'+1);
+ bool bEndWithDigital = ( L'0'<=uch && uch<=L'9');
+ char szTemp[__MAX_NUM_LEN+1];
+ int nLen = sprintf( szTemp, bEndWithDigital ? DATA_RENAME_SEPARATOR"%hu" : "%hu", nIndex );
+ String strRet = rString;
+ strRet.Append( String::CreateFromAscii( szTemp, static_cast<USHORT>(nLen) ));
+ return strRet;
+ }
+
+ bool ChkDPTableOverlap( ScDocument *pDestDoc, std::list<ScDPObject> & rClipboard, SCCOL nClipStartCol, SCROW nClipStartRow, SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, USHORT nEndTab, BOOL bExcludeClip /*= FALSE*/ )
+ {
+ if ( ScDPCollection* pDPCollection = pDestDoc->GetDPCollection() )
+ {
+ USHORT nCount = pDPCollection->GetCount();
+ SCsCOL nOffsetX = nStartCol - nClipStartCol;
+ SCsROW nOffsetY = nStartRow - nClipStartRow;
+
+ for( std::list<ScDPObject>::iterator iter = rClipboard.begin(); iter!=rClipboard.end(); iter++ )
+ {
+ ScRange aRange = iter->GetOutRange();
+
+ for( USHORT nCurrTab = nStartTab; nCurrTab<=nEndTab; nCurrTab++ )
+ {
+ SCsTAB nOffsetZ = nCurrTab - aRange.aStart.Tab();
+ aRange.Move( nOffsetX, nOffsetY, nOffsetZ );
+
+ for ( USHORT i = 0; i<nCount; i++)
+ {
+ if ( (*pDPCollection)[i] && aRange.Intersects( (*pDPCollection)[i]->GetOutRange()))
+ {
+ if ( bExcludeClip && iter->GetOutRange() == (*pDPCollection)[i]->GetOutRange() )
+ {
+ continue;
+ }
+ return false;
+ }
+ }
+ }
+ }
+ }
+ return true;
+}
+//end
+
+}
+// --------------------------------------------------------------------
+// ScDPItemDataPool
+// Construct
+ScDPItemDataPool::ScDPItemDataPool(void)
+{
+}
+//
+ScDPItemDataPool::ScDPItemDataPool(const ScDPItemDataPool& r):
+ maItems(r.maItems),
+ maItemIds(r.maItemIds)
+{
+}
+
+ScDPItemDataPool::~ScDPItemDataPool(void)
+{
+}
+
+
+const ScDPItemData* ScDPItemDataPool::getData( sal_Int32 nId )
+{
+ if ( nId >= static_cast<sal_Int32>(maItems.size()) )
+ return NULL;
+ else
+ return &(maItems[nId]);
+}
+
+sal_Int32 ScDPItemDataPool::getDataId( const ScDPItemData& aData )
+{
+ DataHash::const_iterator itr = maItemIds.find( aData),
+ itrEnd = maItemIds.end();
+ if ( itr == itrEnd )
+ // not exist
+ return -1;
+
+ else //exist
+ return itr->second;
+
+}
+
+sal_Int32 ScDPItemDataPool::insertData( const ScDPItemData& aData )
+{
+ sal_Int32 nResult = getDataId( aData );
+
+ if( nResult < 0 )
+ {
+ maItemIds.insert( DataHash::value_type( aData, nResult = maItems.size() ) );
+ maItems.push_back( aData );
+ }
+
+ return nResult;
+}
+
+
diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx
index 1bc888100a9f..e71ec5c8b82c 100644
--- a/sc/source/core/data/dpgroup.cxx
+++ b/sc/source/core/data/dpgroup.cxx
@@ -47,6 +47,7 @@
#include "dptabsrc.hxx"
#include "dptabres.hxx"
#include "dpobject.hxx"
+#include "dpglobal.hxx"
#include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
@@ -78,6 +79,202 @@ const sal_Int32 SC_DP_DATE_FIRST = -1;
const sal_Int32 SC_DP_DATE_LAST = 10000;
// ============================================================================
+namespace
+{
+ BOOL lcl_Search( SCCOL nSourceDim, ScDPTableDataCache* pCache , const std::vector< SCROW >& vIdx, SCROW nNew , SCROW& rIndex)
+ {
+ rIndex = vIdx.size();
+ BOOL bFound = FALSE;
+ SCROW nLo = 0;
+ SCROW nHi = vIdx.size() - 1;
+ SCROW nIndex;
+ long nCompare;
+ while (nLo <= nHi)
+ {
+ nIndex = (nLo + nHi) / 2;
+
+ const ScDPItemData* pData = pCache->GetItemDataById( nSourceDim, vIdx[nIndex] );
+ const ScDPItemData* pDataInsert = pCache->GetItemDataById( nSourceDim, nNew );
+
+ nCompare = ScDPItemData::Compare( *pData, *pDataInsert );
+ if (nCompare < 0)
+ nLo = nIndex + 1;
+ else
+ {
+ nHi = nIndex - 1;
+ if (nCompare == 0)
+ {
+ bFound = TRUE;
+ nLo = nIndex;
+ }
+ }
+ }
+ rIndex = nLo;
+ return bFound;
+ }
+
+ void lcl_Insert( SCCOL nSourceDim, ScDPTableDataCache* pCache , std::vector< SCROW >& vIdx, SCROW nNew )
+ {
+ SCROW nIndex = 0;
+ if ( !lcl_Search( nSourceDim, pCache, vIdx, nNew ,nIndex ) )
+ vIdx.insert( vIdx.begin()+nIndex, nNew );
+ }
+
+ template<bool bUpdateData>
+ SCROW lcl_InsertValue( SCCOL nSourceDim, ScDPTableDataCache* pCache , std::vector< SCROW >& vIdx, const ScDPItemData & rData );
+
+ template<>
+ SCROW lcl_InsertValue<false>( SCCOL nSourceDim, ScDPTableDataCache* pCache , std::vector< SCROW >& vIdx, const ScDPItemData & rData )
+ {
+ SCROW nNewID = pCache->GetAdditionalItemID( rData );
+ lcl_Insert( nSourceDim, pCache, vIdx, nNewID );
+ return nNewID;
+ }
+
+ template<>
+ SCROW lcl_InsertValue<true>( SCCOL nSourceDim, ScDPTableDataCache* pCache , std::vector< SCROW >& vIdx, const ScDPItemData & rData )
+ {
+ SCROW nItemId = lcl_InsertValue<false>( nSourceDim, pCache, vIdx, rData );
+
+ if( const ScDPItemData *pData = pCache->GetItemDataById( nSourceDim, nItemId ) )
+ const_cast<ScDPItemData&>(*pData) = rData;
+
+ return nItemId;
+ }
+
+ template<bool bUpdateData>
+ void lcl_InsertValue ( SCCOL nSourceDim, ScDPTableDataCache* pCache , std::vector< SCROW >& vIdx, const String& rString, const double& fValue )
+ {
+ lcl_InsertValue<bUpdateData>( nSourceDim, pCache, vIdx, ScDPItemData( rString, fValue, TRUE ) );
+ }
+
+ template<bool bUpdateData>
+ void lcl_InsertValue ( SCCOL nSourceDim, ScDPTableDataCache* pCache , std::vector< SCROW >& vIdx, const String& rString, const double& fValue, sal_Int32 nDatePart )
+ {
+ lcl_InsertValue<bUpdateData>( nSourceDim, pCache, vIdx, ScDPItemData( nDatePart, rString, fValue, ScDPItemData::MK_DATA|ScDPItemData::MK_VAL|ScDPItemData::MK_DATEPART ) );
+ }
+
+ void lcl_AppendDateStr( rtl::OUStringBuffer& rBuffer, double fValue, SvNumberFormatter* pFormatter )
+ {
+ ULONG nFormat = pFormatter->GetStandardFormat( NUMBERFORMAT_DATE, ScGlobal::eLnge );
+ String aString;
+ pFormatter->GetInputLineString( fValue, nFormat, aString );
+ rBuffer.append( aString );
+ }
+
+ String lcl_GetNumGroupName( double fStartValue, const ScDPNumGroupInfo& rInfo,
+ bool bHasNonInteger, sal_Unicode cDecSeparator, SvNumberFormatter* pFormatter )
+ {
+ DBG_ASSERT( cDecSeparator != 0, "cDecSeparator not initialized" );
+
+ double fStep = rInfo.Step;
+ double fEndValue = fStartValue + fStep;
+ if ( !bHasNonInteger && ( rInfo.DateValues || !rtl::math::approxEqual( fEndValue, rInfo.End ) ) )
+ {
+ // The second number of the group label is
+ // (first number + size - 1) if there are only integer numbers,
+ // (first number + size) if any non-integer numbers are involved.
+ // Exception: The last group (containing the end value) is always
+ // shown as including the end value (but not for dates).
+
+ fEndValue -= 1.0;
+ }
+
+ if ( fEndValue > rInfo.End && !rInfo.AutoEnd )
+ {
+ // limit the last group to the end value
+
+ fEndValue = rInfo.End;
+ }
+
+ rtl::OUStringBuffer aBuffer;
+ if ( rInfo.DateValues )
+ {
+ lcl_AppendDateStr( aBuffer, fStartValue, pFormatter );
+ aBuffer.appendAscii( " - " ); // with spaces
+ lcl_AppendDateStr( aBuffer, fEndValue, pFormatter );
+ }
+ else
+ {
+ rtl::math::doubleToUStringBuffer( aBuffer, fStartValue, rtl_math_StringFormat_Automatic,
+ rtl_math_DecimalPlaces_Max, cDecSeparator, true );
+ aBuffer.append( (sal_Unicode) '-' );
+ rtl::math::doubleToUStringBuffer( aBuffer, fEndValue, rtl_math_StringFormat_Automatic,
+ rtl_math_DecimalPlaces_Max, cDecSeparator, true );
+ }
+
+ return aBuffer.makeStringAndClear();
+ }
+
+ String lcl_GetSpecialNumGroupName( double fValue, bool bFirst, sal_Unicode cDecSeparator,
+ bool bDateValues, SvNumberFormatter* pFormatter )
+ {
+ DBG_ASSERT( cDecSeparator != 0, "cDecSeparator not initialized" );
+
+ rtl::OUStringBuffer aBuffer;
+ aBuffer.append((sal_Unicode)( bFirst ? '<' : '>' ));
+ if ( bDateValues )
+ lcl_AppendDateStr( aBuffer, fValue, pFormatter );
+ else
+ rtl::math::doubleToUStringBuffer( aBuffer, fValue, rtl_math_StringFormat_Automatic,
+ rtl_math_DecimalPlaces_Max, cDecSeparator, true );
+ return aBuffer.makeStringAndClear();
+ }
+
+ inline bool IsInteger( double fValue )
+ {
+ return rtl::math::approxEqual( fValue, rtl::math::approxFloor(fValue) );
+ }
+
+ String lcl_GetNumGroupForValue( double fValue, const ScDPNumGroupInfo& rInfo, bool bHasNonInteger,
+ sal_Unicode cDecSeparator, double& rGroupValue, ScDocument* pDoc )
+ {
+ SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+
+ if ( fValue < rInfo.Start && !rtl::math::approxEqual( fValue, rInfo.Start ) )
+ {
+ rGroupValue = rInfo.Start - rInfo.Step;
+ return lcl_GetSpecialNumGroupName( rInfo.Start, true, cDecSeparator, rInfo.DateValues, pFormatter );
+ }
+
+ if ( fValue > rInfo.End && !rtl::math::approxEqual( fValue, rInfo.End ) )
+ {
+ rGroupValue = rInfo.End + rInfo.Step;
+ return lcl_GetSpecialNumGroupName( rInfo.End, false, cDecSeparator, rInfo.DateValues, pFormatter );
+ }
+
+ double fDiff = fValue - rInfo.Start;
+ double fDiv = rtl::math::approxFloor( fDiff / rInfo.Step );
+ double fGroupStart = rInfo.Start + fDiv * rInfo.Step;
+
+ if ( rtl::math::approxEqual( fGroupStart, rInfo.End ) &&
+ !rtl::math::approxEqual( fGroupStart, rInfo.Start ) )
+ {
+ if ( !rInfo.DateValues )
+ {
+ // A group that would consist only of the end value is not created,
+ // instead the value is included in the last group before. So the
+ // previous group is used if the calculated group start value is the
+ // selected end value.
+
+ fDiv -= 1.0;
+ fGroupStart = rInfo.Start + fDiv * rInfo.Step;
+ }
+ else
+ {
+ // For date values, the end value is instead treated as above the limit
+ // if it would be a group of its own.
+
+ rGroupValue = rInfo.End + rInfo.Step;
+ return lcl_GetSpecialNumGroupName( rInfo.End, false, cDecSeparator, rInfo.DateValues, pFormatter );
+ }
+ }
+
+ rGroupValue = fGroupStart;
+
+ return lcl_GetNumGroupName( fGroupStart, rInfo, bHasNonInteger, cDecSeparator, pFormatter );
+ }
+}
class ScDPGroupDateFilter : public ScDPCacheTable::FilterBase
{
@@ -85,7 +282,10 @@ public:
ScDPGroupDateFilter(double fMatchValue, sal_Int32 nDatePart,
const Date* pNullDate, const ScDPNumGroupInfo* pNumInfo);
- virtual bool match(const ScDPCacheCell &rCell) const;
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ virtual bool match(const ScDPItemData & rCellData) const;
+ // End Comments
private:
ScDPGroupDateFilter(); // disabled
@@ -108,26 +308,25 @@ ScDPGroupDateFilter::ScDPGroupDateFilter(double fMatchValue, sal_Int32 nDatePart
// fprintf(stdout, "ScDPCacheTable:DateGroupFilter::DateGroupFilter: match value = %g; date part = %ld\n",
// mfMatchValue, mnDatePart);
}
-
-bool ScDPGroupDateFilter::match(const ScDPCacheCell& rCell) const
+bool ScDPGroupDateFilter::match( const ScDPItemData & rCellData ) const
{
using namespace ::com::sun::star::sheet;
using ::rtl::math::approxFloor;
using ::rtl::math::approxEqual;
- if (!rCell.mbNumeric)
+ if ( !rCellData.IsValue() )
return false;
-
+// ScDPCacheCell rCell( rCellData.fValue );
if (!mpNumInfo)
return false;
// Start and end dates are inclusive. (An end date without a time value
// is included, while an end date with a time value is not.)
- if ( rCell.mfValue < mpNumInfo->Start && !approxEqual(rCell.mfValue, mpNumInfo->Start) )
+ if ( rCellData.GetValue() < mpNumInfo->Start && !approxEqual(rCellData.GetValue(), mpNumInfo->Start) )
return static_cast<sal_Int32>(mfMatchValue) == SC_DP_DATE_FIRST;
- if ( rCell.mfValue > mpNumInfo->End && !approxEqual(rCell.mfValue, mpNumInfo->End) )
+ if ( rCellData.GetValue() > mpNumInfo->End && !approxEqual(rCellData.GetValue(), mpNumInfo->End) )
return static_cast<sal_Int32>(mfMatchValue) == SC_DP_DATE_LAST;
if (mnDatePart == DataPilotFieldGroupBy::HOURS || mnDatePart == DataPilotFieldGroupBy::MINUTES ||
@@ -136,7 +335,7 @@ bool ScDPGroupDateFilter::match(const ScDPCacheCell& rCell) const
// handle time
// (as in the cell functions, ScInterpreter::ScGetHour etc.: seconds are rounded)
- double time = rCell.mfValue - approxFloor(rCell.mfValue);
+ double time = rCellData.GetValue() - approxFloor(rCellData.GetValue());
long seconds = static_cast<long>(approxFloor(time*D_TIMEFACTOR + 0.5));
switch (mnDatePart)
@@ -165,7 +364,7 @@ bool ScDPGroupDateFilter::match(const ScDPCacheCell& rCell) const
return false;
}
- Date date = *mpNullDate + static_cast<long>(approxFloor(rCell.mfValue));
+ Date date = *mpNullDate + static_cast<long>(approxFloor(rCellData.GetValue()));
switch (mnDatePart)
{
case DataPilotFieldGroupBy::YEARS:
@@ -204,17 +403,6 @@ bool ScDPGroupDateFilter::match(const ScDPCacheCell& rCell) const
return false;
}
-
-// ============================================================================
-
-void lcl_AppendDateStr( rtl::OUStringBuffer& rBuffer, double fValue, SvNumberFormatter* pFormatter )
-{
- ULONG nFormat = pFormatter->GetStandardFormat( NUMBERFORMAT_DATE, ScGlobal::eLnge );
- String aString;
- pFormatter->GetInputLineString( fValue, nFormat, aString );
- rBuffer.append( aString );
-}
-
// -----------------------------------------------------------------------
ScDPDateGroupHelper::ScDPDateGroupHelper( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart ) :
@@ -354,15 +542,18 @@ sal_Int32 lcl_GetDatePartValue( double fValue, sal_Int32 nDatePart, SvNumberForm
BOOL lcl_DateContained( sal_Int32 nGroupPart, const ScDPItemData& rGroupData,
sal_Int32 nBasePart, const ScDPItemData& rBaseData )
{
- if ( !rGroupData.bHasValue || !rBaseData.bHasValue )
+ if ( !rGroupData.IsValue() || !rBaseData.IsValue() )
{
// non-numeric entries involved: only match equal entries
return rGroupData.IsCaseInsEqual( rBaseData );
}
// no approxFloor needed, values were created from integers
- sal_Int32 nGroupValue = (sal_Int32) rGroupData.fValue;
- sal_Int32 nBaseValue = (sal_Int32) rBaseData.fValue;
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+ sal_Int32 nGroupValue = (sal_Int32) rGroupData.GetValue();
+ sal_Int32 nBaseValue = (sal_Int32) rBaseData.GetValue();
+// End Comments
if ( nBasePart > nGroupPart )
{
// switch, so the base part is the smaller (inner) part
@@ -417,28 +608,25 @@ String lcl_GetSpecialDateName( double fValue, bool bFirst, SvNumberFormatter* pF
return aBuffer.makeStringAndClear();
}
-void ScDPDateGroupHelper::FillColumnEntries( TypedScStrCollection& rEntries, const TypedScStrCollection& rOriginal,
- SvNumberFormatter* pFormatter ) const
+void ScDPDateGroupHelper::FillColumnEntries( SCCOL nSourceDim, ScDPTableDataCache* pCache, std::vector< SCROW >& rEntries, const std::vector< SCROW >& rOriginal ) const
{
// auto min/max is only used for "Years" part, but the loop is always needed
double fSourceMin = 0.0;
double fSourceMax = 0.0;
bool bFirst = true;
- USHORT nOriginalCount = rOriginal.GetCount();
- for (USHORT nOriginalPos=0; nOriginalPos<nOriginalCount; nOriginalPos++)
+ size_t nOriginalCount = rOriginal.size();
+ for (size_t nOriginalPos=0; nOriginalPos<nOriginalCount; nOriginalPos++)
{
- const TypedStrData& rStrData = *rOriginal[nOriginalPos];
- if ( rStrData.IsStrData() )
+ const ScDPItemData* pItemData = pCache->GetItemDataById( nSourceDim, rOriginal[nOriginalPos] );
+ if ( pItemData->HasStringData() )
{
// string data: just copy
- TypedStrData* pNew = new TypedStrData( rStrData );
- if ( !rEntries.Insert( pNew ) )
- delete pNew;
+ lcl_Insert( nSourceDim, pCache , rEntries, rOriginal[nOriginalPos] );
}
else
{
- double fSourceValue = rStrData.GetValue();
+ double fSourceValue = pItemData->GetValue();
if ( bFirst )
{
fSourceMin = fSourceMax = fSourceValue;
@@ -462,6 +650,7 @@ void ScDPDateGroupHelper::FillColumnEntries( TypedScStrCollection& rEntries, con
const_cast<ScDPDateGroupHelper*>(this)->aNumInfo.End = rtl::math::approxFloor( fSourceMax ) + 1;
//! if not automatic, limit fSourceMin/fSourceMax for list of year values?
+ SvNumberFormatter* pFormatter = pCache->GetDoc()->GetFormatTable();
long nStart = 0;
long nEnd = 0; // including
@@ -485,22 +674,15 @@ void ScDPDateGroupHelper::FillColumnEntries( TypedScStrCollection& rEntries, con
for ( sal_Int32 nValue = nStart; nValue <= nEnd; nValue++ )
{
String aName = lcl_GetDateGroupName( nDatePart, nValue, pFormatter );
- TypedStrData* pNew = new TypedStrData( aName, nValue, SC_STRTYPE_VALUE );
- if ( !rEntries.Insert( pNew ) )
- delete pNew;
+ lcl_InsertValue<false>( nSourceDim, pCache, rEntries, aName, nValue, nDatePart );
}
// add first/last entry (min/max)
-
String aFirstName = lcl_GetSpecialDateName( aNumInfo.Start, true, pFormatter );
- TypedStrData* pFirstEntry = new TypedStrData( aFirstName, SC_DP_DATE_FIRST, SC_STRTYPE_VALUE );
- if ( !rEntries.Insert( pFirstEntry ) )
- delete pFirstEntry;
+ lcl_InsertValue<true>( nSourceDim, pCache, rEntries, aFirstName, SC_DP_DATE_FIRST, nDatePart );
String aLastName = lcl_GetSpecialDateName( aNumInfo.End, false, pFormatter );
- TypedStrData* pLastEntry = new TypedStrData( aLastName, SC_DP_DATE_LAST, SC_STRTYPE_VALUE );
- if ( !rEntries.Insert( pLastEntry ) )
- delete pLastEntry;
+ lcl_InsertValue<true>( nSourceDim, pCache, rEntries, aLastName, SC_DP_DATE_LAST, nDatePart );
}
// -----------------------------------------------------------------------
@@ -541,7 +723,10 @@ void ScDPGroupItem::FillGroupFilter( ScDPCacheTable::GroupFilter& rFilter ) cons
{
ScDPItemDataVec::const_iterator itrEnd = aElements.end();
for (ScDPItemDataVec::const_iterator itr = aElements.begin(); itr != itrEnd; ++itr)
- rFilter.addMatchItem(itr->aString, itr->fValue, itr->bHasValue);
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+ rFilter.addMatchItem(itr->GetString(), itr->GetValue(), itr->IsValue());
+// End Comments
}
// -----------------------------------------------------------------------
@@ -550,15 +735,15 @@ ScDPGroupDimension::ScDPGroupDimension( long nSource, const String& rNewName ) :
nSourceDim( nSource ),
nGroupDim( -1 ),
aGroupName( rNewName ),
- pDateHelper( NULL ),
- pCollection( NULL )
+ pDateHelper( NULL )/*,
+ pCollection( NULL )*/
{
}
ScDPGroupDimension::~ScDPGroupDimension()
{
delete pDateHelper;
- delete pCollection;
+ maMemberEntries.clear();
}
ScDPGroupDimension::ScDPGroupDimension( const ScDPGroupDimension& rOther ) :
@@ -566,8 +751,7 @@ ScDPGroupDimension::ScDPGroupDimension( const ScDPGroupDimension& rOther ) :
nGroupDim( rOther.nGroupDim ),
aGroupName( rOther.aGroupName ),
pDateHelper( NULL ),
- aItems( rOther.aItems ),
- pCollection( NULL ) // collection isn't copied - allocated on demand
+ aItems( rOther.aItems )
{
if ( rOther.pDateHelper )
pDateHelper = new ScDPDateGroupHelper( *rOther.pDateHelper );
@@ -586,8 +770,6 @@ ScDPGroupDimension& ScDPGroupDimension::operator=( const ScDPGroupDimension& rOt
else
pDateHelper = NULL;
- delete pCollection; // collection isn't copied - allocated on demand
- pCollection = NULL;
return *this;
}
@@ -606,44 +788,42 @@ void ScDPGroupDimension::SetGroupDim( long nDim )
{
nGroupDim = nDim;
}
-
-const TypedScStrCollection& ScDPGroupDimension::GetColumnEntries(
- const TypedScStrCollection& rOriginal, ScDocument* pDoc ) const
+// Wang Xu Ming -- 2009-9-2
+// DataPilot Migration - Cache&&Performance
+const std::vector< SCROW >& ScDPGroupDimension::GetColumnEntries( const ScDPCacheTable& rCacheTable, const std::vector< SCROW >& rOriginal ) const
{
- if ( !pCollection )
+ if ( maMemberEntries.empty() )
{
- pCollection = new TypedScStrCollection();
if ( pDateHelper )
- pDateHelper->FillColumnEntries( *pCollection, rOriginal, pDoc->GetFormatTable() );
+ {
+ pDateHelper->FillColumnEntries( (SCCOL)GetSourceDim(), rCacheTable.GetCache(), maMemberEntries, rOriginal );
+ }
else
{
- long nCount = aItems.size();
- for (long i=0; i<nCount; i++)
+ for (size_t i =0; i < rOriginal.size( ); i ++)
{
- //! numeric entries?
- TypedStrData* pNew = new TypedStrData( aItems[i].GetName().aString );
- if ( !pCollection->Insert( pNew ) )
- delete pNew;
- }
-
- USHORT nOriginalCount = rOriginal.GetCount();
- for (USHORT nOriginalPos=0; nOriginalPos<nOriginalCount; nOriginalPos++)
- {
- const TypedStrData& rStrData = *rOriginal[nOriginalPos];
- ScDPItemData aItemData( rStrData.GetString(), rStrData.GetValue(), !rStrData.IsStrData() );
- if ( !GetGroupForData( aItemData ) )
+ const ScDPItemData* pItemData = rCacheTable.GetCache()->GetItemDataById( (SCCOL)GetSourceDim(), rOriginal[i] );
+ if ( !pItemData || !GetGroupForData( *pItemData ) )
{
// not in any group -> add as its own group
- TypedStrData* pNew = new TypedStrData( rStrData );
- if ( !pCollection->Insert( pNew ) )
- delete pNew;
+ maMemberEntries.push_back( rOriginal[i] );
}
}
+
+ long nCount = aItems.size();
+ for (long i=0; i<nCount; i++)
+ {
+ SCROW nNew = rCacheTable.GetCache()->GetAdditionalItemID( aItems[i].GetName() );
+ lcl_Insert ( (SCCOL)GetSourceDim(), rCacheTable.GetCache(), maMemberEntries, nNew );
+ }
}
}
- return *pCollection;
+ return maMemberEntries;
}
+// End Comments
+
+
const ScDPGroupItem* ScDPGroupDimension::GetGroupForData( const ScDPItemData& rData ) const
{
for ( ScDPGroupItemVec::const_iterator aIter(aItems.begin()); aIter != aItems.end(); aIter++ )
@@ -672,15 +852,13 @@ const ScDPGroupItem* ScDPGroupDimension::GetGroupByIndex( size_t nIndex ) const
void ScDPGroupDimension::DisposeData()
{
- delete pCollection;
- pCollection = NULL;
+ maMemberEntries.clear();
}
// -----------------------------------------------------------------------
ScDPNumGroupDimension::ScDPNumGroupDimension() :
pDateHelper( NULL ),
- pCollection( NULL ),
bHasNonInteger( false ),
cDecSeparator( 0 )
{
@@ -689,7 +867,6 @@ ScDPNumGroupDimension::ScDPNumGroupDimension() :
ScDPNumGroupDimension::ScDPNumGroupDimension( const ScDPNumGroupInfo& rInfo ) :
aGroupInfo( rInfo ),
pDateHelper( NULL ),
- pCollection( NULL ),
bHasNonInteger( false ),
cDecSeparator( 0 )
{
@@ -698,7 +875,6 @@ ScDPNumGroupDimension::ScDPNumGroupDimension( const ScDPNumGroupInfo& rInfo ) :
ScDPNumGroupDimension::ScDPNumGroupDimension( const ScDPNumGroupDimension& rOther ) :
aGroupInfo( rOther.aGroupInfo ),
pDateHelper( NULL ),
- pCollection( NULL ), // collection isn't copied - allocated on demand
bHasNonInteger( false ),
cDecSeparator( 0 )
{
@@ -716,23 +892,19 @@ ScDPNumGroupDimension& ScDPNumGroupDimension::operator=( const ScDPNumGroupDimen
else
pDateHelper = NULL;
- delete pCollection; // collection isn't copied - allocated on demand
- pCollection = NULL;
bHasNonInteger = false;
return *this;
}
void ScDPNumGroupDimension::DisposeData()
{
- delete pCollection;
- pCollection = NULL;
bHasNonInteger = false;
+ maMemberEntries.clear();
}
ScDPNumGroupDimension::~ScDPNumGroupDimension()
{
delete pDateHelper;
- delete pCollection;
}
void ScDPNumGroupDimension::MakeDateHelper( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart )
@@ -743,80 +915,15 @@ void ScDPNumGroupDimension::MakeDateHelper( const ScDPNumGroupInfo& rInfo, sal_I
aGroupInfo.Enable = sal_True; //! or query both?
}
-String lcl_GetNumGroupName( double fStartValue, const ScDPNumGroupInfo& rInfo,
- bool bHasNonInteger, sal_Unicode cDecSeparator, SvNumberFormatter* pFormatter )
-{
- DBG_ASSERT( cDecSeparator != 0, "cDecSeparator not initialized" );
-
- double fStep = rInfo.Step;
- double fEndValue = fStartValue + fStep;
- if ( !bHasNonInteger && ( rInfo.DateValues || !rtl::math::approxEqual( fEndValue, rInfo.End ) ) )
- {
- // The second number of the group label is
- // (first number + size - 1) if there are only integer numbers,
- // (first number + size) if any non-integer numbers are involved.
- // Exception: The last group (containing the end value) is always
- // shown as including the end value (but not for dates).
-
- fEndValue -= 1.0;
- }
-
- if ( fEndValue > rInfo.End && !rInfo.AutoEnd )
- {
- // limit the last group to the end value
-
- fEndValue = rInfo.End;
- }
-
- rtl::OUStringBuffer aBuffer;
- if ( rInfo.DateValues )
- {
- lcl_AppendDateStr( aBuffer, fStartValue, pFormatter );
- aBuffer.appendAscii( " - " ); // with spaces
- lcl_AppendDateStr( aBuffer, fEndValue, pFormatter );
- }
- else
- {
- rtl::math::doubleToUStringBuffer( aBuffer, fStartValue, rtl_math_StringFormat_Automatic,
- rtl_math_DecimalPlaces_Max, cDecSeparator, true );
- aBuffer.append( (sal_Unicode) '-' );
- rtl::math::doubleToUStringBuffer( aBuffer, fEndValue, rtl_math_StringFormat_Automatic,
- rtl_math_DecimalPlaces_Max, cDecSeparator, true );
- }
-
- return aBuffer.makeStringAndClear();
-}
-
-String lcl_GetSpecialNumGroupName( double fValue, bool bFirst, sal_Unicode cDecSeparator,
- bool bDateValues, SvNumberFormatter* pFormatter )
+const std::vector< SCROW >& ScDPNumGroupDimension::GetNumEntries( SCCOL nSourceDim, ScDPTableDataCache* pCache,
+ const std::vector< SCROW >& rOriginal ) const
{
- DBG_ASSERT( cDecSeparator != 0, "cDecSeparator not initialized" );
-
- rtl::OUStringBuffer aBuffer;
- aBuffer.append((sal_Unicode)( bFirst ? '<' : '>' ));
- if ( bDateValues )
- lcl_AppendDateStr( aBuffer, fValue, pFormatter );
- else
- rtl::math::doubleToUStringBuffer( aBuffer, fValue, rtl_math_StringFormat_Automatic,
- rtl_math_DecimalPlaces_Max, cDecSeparator, true );
- return aBuffer.makeStringAndClear();
-}
-
-inline bool IsInteger( double fValue )
-{
- return rtl::math::approxEqual( fValue, rtl::math::approxFloor(fValue) );
-}
-
-const TypedScStrCollection& ScDPNumGroupDimension::GetNumEntries(
- const TypedScStrCollection& rOriginal, ScDocument* pDoc ) const
-{
- if ( !pCollection )
+ if ( maMemberEntries.empty() )
{
- SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+ SvNumberFormatter* pFormatter = pCache->GetDoc()->GetFormatTable();
- pCollection = new TypedScStrCollection();
if ( pDateHelper )
- pDateHelper->FillColumnEntries( *pCollection, rOriginal, pFormatter );
+ pDateHelper->FillColumnEntries( nSourceDim, pCache, maMemberEntries,rOriginal );
else
{
// Copy textual entries.
@@ -835,39 +942,37 @@ const TypedScStrCollection& ScDPNumGroupDimension::GetNumEntries(
double fSourceMax = 0.0;
bool bFirst = true;
- USHORT nOriginalCount = rOriginal.GetCount();
- for (USHORT nOriginalPos=0; nOriginalPos<nOriginalCount; nOriginalPos++)
+ size_t nOriginalCount = rOriginal.size();
+ for (size_t nOriginalPos=0; nOriginalPos<nOriginalCount; nOriginalPos++)
{
- const TypedStrData& rStrData = *rOriginal[nOriginalPos];
- if ( rStrData.IsStrData() )
- {
- // string data: just copy
- TypedStrData* pNew = new TypedStrData( rStrData );
- if ( !pCollection->Insert( pNew ) )
- delete pNew;
- }
- else
- {
- double fSourceValue = rStrData.GetValue();
- if ( bFirst )
- {
- fSourceMin = fSourceMax = fSourceValue;
- bFirst = false;
- }
- else
- {
- if ( fSourceValue < fSourceMin )
- fSourceMin = fSourceValue;
- if ( fSourceValue > fSourceMax )
- fSourceMax = fSourceValue;
- }
- if ( !bHasNonInteger && !IsInteger( fSourceValue ) )
- {
- // if any non-integer numbers are involved, the group labels are
- // shown including their upper limit
- bHasNonInteger = true;
- }
- }
+ const ScDPItemData* pItemData = pCache->GetItemDataById( nSourceDim , rOriginal[nOriginalPos] );
+
+ if ( pItemData && pItemData ->HasStringData() )
+ {
+ lcl_Insert( nSourceDim, pCache, maMemberEntries, rOriginal[nOriginalPos] );
+ }
+ else
+ {
+ double fSourceValue = pItemData->GetValue();
+ if ( bFirst )
+ {
+ fSourceMin = fSourceMax = fSourceValue;
+ bFirst = false;
+ }
+ else
+ {
+ if ( fSourceValue < fSourceMin )
+ fSourceMin = fSourceValue;
+ if ( fSourceValue > fSourceMax )
+ fSourceMax = fSourceValue;
+ }
+ if ( !bHasNonInteger && !IsInteger( fSourceValue ) )
+ {
+ // if any non-integer numbers are involved, the group labels are
+ // shown including their upper limit
+ bHasNonInteger = true;
+ }
+ }
}
if ( aGroupInfo.DateValues )
@@ -899,10 +1004,7 @@ const TypedScStrCollection& ScDPNumGroupDimension::GetNumEntries(
String aName = lcl_GetNumGroupName( fLoop, aGroupInfo, bHasNonInteger, cDecSeparator, pFormatter );
// create a numerical entry to ensure proper sorting
// (in FillMemberResults this needs special handling)
- TypedStrData* pNew = new TypedStrData( aName, fLoop, SC_STRTYPE_VALUE );
- if ( !pCollection->Insert( pNew ) )
- delete pNew;
-
+ lcl_InsertValue<true>( nSourceDim, pCache, maMemberEntries, aName, fLoop );
++nLoopCount;
fLoop = aGroupInfo.Start + nLoopCount * aGroupInfo.Step;
bFirstGroup = false;
@@ -911,72 +1013,17 @@ const TypedScStrCollection& ScDPNumGroupDimension::GetNumEntries(
}
String aFirstName = lcl_GetSpecialNumGroupName( aGroupInfo.Start, true, cDecSeparator, aGroupInfo.DateValues, pFormatter );
- TypedStrData* pFirstEntry = new TypedStrData( aFirstName, aGroupInfo.Start - aGroupInfo.Step, SC_STRTYPE_VALUE );
- if ( !pCollection->Insert( pFirstEntry ) )
- delete pFirstEntry;
+ lcl_InsertValue<true>( nSourceDim, pCache, maMemberEntries, aFirstName, aGroupInfo.Start - aGroupInfo.Step );
String aLastName = lcl_GetSpecialNumGroupName( aGroupInfo.End, false, cDecSeparator, aGroupInfo.DateValues, pFormatter );
- TypedStrData* pLastEntry = new TypedStrData( aLastName, aGroupInfo.End + aGroupInfo.Step, SC_STRTYPE_VALUE );
- if ( !pCollection->Insert( pLastEntry ) )
- delete pLastEntry;
- }
- }
- return *pCollection;
-}
-
-// -----------------------------------------------------------------------
-
-String lcl_GetNumGroupForValue( double fValue, const ScDPNumGroupInfo& rInfo, bool bHasNonInteger,
- sal_Unicode cDecSeparator, double& rGroupValue, ScDocument* pDoc )
-{
- SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
-
- if ( fValue < rInfo.Start && !rtl::math::approxEqual( fValue, rInfo.Start ) )
- {
- rGroupValue = rInfo.Start - rInfo.Step;
- return lcl_GetSpecialNumGroupName( rInfo.Start, true, cDecSeparator, rInfo.DateValues, pFormatter );
- }
-
- if ( fValue > rInfo.End && !rtl::math::approxEqual( fValue, rInfo.End ) )
- {
- rGroupValue = rInfo.End + rInfo.Step;
- return lcl_GetSpecialNumGroupName( rInfo.End, false, cDecSeparator, rInfo.DateValues, pFormatter );
- }
-
- double fDiff = fValue - rInfo.Start;
- double fDiv = rtl::math::approxFloor( fDiff / rInfo.Step );
- double fGroupStart = rInfo.Start + fDiv * rInfo.Step;
-
- if ( rtl::math::approxEqual( fGroupStart, rInfo.End ) &&
- !rtl::math::approxEqual( fGroupStart, rInfo.Start ) )
- {
- if ( !rInfo.DateValues )
- {
- // A group that would consist only of the end value is not created,
- // instead the value is included in the last group before. So the
- // previous group is used if the calculated group start value is the
- // selected end value.
-
- fDiv -= 1.0;
- fGroupStart = rInfo.Start + fDiv * rInfo.Step;
- }
- else
- {
- // For date values, the end value is instead treated as above the limit
- // if it would be a group of its own.
-
- rGroupValue = rInfo.End + rInfo.Step;
- return lcl_GetSpecialNumGroupName( rInfo.End, false, cDecSeparator, rInfo.DateValues, pFormatter );
+ lcl_InsertValue<true>( nSourceDim, pCache, maMemberEntries, aLastName, aGroupInfo.End + aGroupInfo.Step );
}
}
-
- rGroupValue = fGroupStart;
-
- return lcl_GetNumGroupName( fGroupStart, rInfo, bHasNonInteger, cDecSeparator, pFormatter );
+ return maMemberEntries;
}
ScDPGroupTableData::ScDPGroupTableData( const shared_ptr<ScDPTableData>& pSource, ScDocument* pDocument ) :
- ScDPTableData(pDocument),
+ ScDPTableData(pDocument, pSource->GetCacheId() ),
pSourceData( pSource ),
pDoc( pDocument )
{
@@ -1015,7 +1062,6 @@ long ScDPGroupTableData::GetDimensionIndex( const String& rName )
for (long i=0; i<nSourceCount; i++) // nSourceCount excludes data layout
if ( pSourceData->getDimensionName(i) == rName ) //! ignore case?
return i;
-
return -1; // none
}
@@ -1039,36 +1085,53 @@ void ScDPGroupTableData::GetNumGroupInfo( long nDimension, ScDPNumGroupInfo& rIn
rDecimal = pNumGroups[nDimension].GetDecSeparator();
}
}
-
-const TypedScStrCollection& ScDPGroupTableData::GetColumnEntries(long nColumn)
+// Wang Xu Ming - DataPilot migration
+long ScDPGroupTableData::GetMembersCount( long nDim )
+{
+ const std::vector< SCROW >& members = GetColumnEntries( nDim );
+ return members.size();
+}
+const std::vector< SCROW >& ScDPGroupTableData::GetColumnEntries( long nColumn )
{
- // date handling is in ScDPGroupDimension::GetColumnEntries / ScDPNumGroupDimension::GetNumEntries
- // (to use the pCollection members)
-
if ( nColumn >= nSourceCount )
{
- if ( nColumn == sal::static_int_cast<long>( nSourceCount + aGroups.size() ) ) // data layout dimension?
+ if ( getIsDataLayoutDimension( nColumn) ) // data layout dimension?
nColumn = nSourceCount; // index of data layout in source data
else
{
const ScDPGroupDimension& rGroupDim = aGroups[nColumn - nSourceCount];
long nSourceDim = rGroupDim.GetSourceDim();
// collection is cached at pSourceData, GetColumnEntries can be called every time
- const TypedScStrCollection& rOriginal = pSourceData->GetColumnEntries( nSourceDim );
- return rGroupDim.GetColumnEntries( rOriginal, pDoc );
+ const std::vector< SCROW >& rOriginal = pSourceData->GetColumnEntries( nSourceDim );
+ return rGroupDim.GetColumnEntries( GetCacheTable(), rOriginal );
}
}
if ( IsNumGroupDimension( nColumn ) )
{
// dimension number is unchanged for numerical groups
- const TypedScStrCollection& rOriginal = pSourceData->GetColumnEntries( nColumn );
- return pNumGroups[nColumn].GetNumEntries( rOriginal, pDoc );
+ const std::vector< SCROW >& rOriginal = pSourceData->GetColumnEntries( nColumn );
+ return pNumGroups[nColumn].GetNumEntries( (SCCOL)nColumn, GetCacheTable().GetCache(), rOriginal );
}
return pSourceData->GetColumnEntries( nColumn );
}
+const ScDPItemData* ScDPGroupTableData::GetMemberById( long nDim, long nId )
+{
+ if ( nDim >= nSourceCount )
+ {
+ if ( getIsDataLayoutDimension( nDim) )
+ nDim = nSourceCount;
+ else
+ {
+ const ScDPGroupDimension& rGroupDim = aGroups[nDim - nSourceCount];
+ nDim = rGroupDim.GetSourceDim();
+ }
+ }
+ return pSourceData->GetMemberById( nDim, nId );
+}
+
String ScDPGroupTableData::getDimensionName(long nColumn)
{
if ( nColumn >= nSourceCount )
@@ -1101,7 +1164,7 @@ BOOL ScDPGroupTableData::IsDateDimension(long nDim)
return pSourceData->IsDateDimension( nDim );
}
-UINT32 ScDPGroupTableData::GetNumberFormat(long nDim)
+ULONG ScDPGroupTableData::GetNumberFormat(long nDim)
{
if ( nDim >= nSourceCount )
{
@@ -1220,16 +1283,19 @@ void ScDPGroupTableData::ModifyFilterCriteria(vector<ScDPCacheTable::Criterion>&
for (size_t i = 0; i < nGroupItemCount; ++i)
{
const ScDPGroupItem* pGrpItem = pGrpDim->GetGroupByIndex(i);
- ScDPItemData aName;
- aName.aString = pFilter->getMatchString();
+ // Wang Xu Ming -- 2009-6-9
+ // DataPilot Migration
+ ScDPItemData aName( pFilter->getMatchString(),pFilter->getMatchValue(),pFilter->hasValue()) ;
+ /*aName.aString = pFilter->getMatchString();
aName.fValue = pFilter->getMatchValue();
- aName.bHasValue = pFilter->hasValue();
- if (!pGrpItem || !pGrpItem->GetName().IsCaseInsEqual(aName))
+ aName.bHasValue = pFilter->hasValue();*/
+ // End Comments
+ if (!pGrpItem || !pGrpItem->GetName().IsCaseInsEqual(aName))
continue;
ScDPCacheTable::Criterion aCri;
aCri.mnFieldIndex = nSrcDim;
- aCri.mpFilter.reset(new ScDPCacheTable::GroupFilter(GetSharedString()));
+ aCri.mpFilter.reset(new ScDPCacheTable::GroupFilter());
ScDPCacheTable::GroupFilter* pGrpFilter =
static_cast<ScDPCacheTable::GroupFilter*>(aCri.mpFilter.get());
@@ -1321,25 +1387,27 @@ void ScDPGroupTableData::CopyFields(const vector<long>& rFieldDims, vector<long>
}
}
-void ScDPGroupTableData::FillGroupValues( ScDPItemData* pItemData, long nCount, const long* pDims )
+void ScDPGroupTableData::FillGroupValues( /*ScDPItemData* pItemData*/ SCROW* pItemDataIndex, long nCount, const long* pDims )
{
long nGroupedColumns = aGroups.size();
+ ScDPTableDataCache* pCache = GetCacheTable().GetCache();
for (long nDim=0; nDim<nCount; nDim++)
{
const ScDPDateGroupHelper* pDateHelper = NULL;
long nColumn = pDims[nDim];
+ long nSourceDim = nColumn;
if ( nColumn >= nSourceCount && nColumn < nSourceCount + nGroupedColumns )
{
const ScDPGroupDimension& rGroupDim = aGroups[nColumn - nSourceCount];
+ nSourceDim= rGroupDim.GetSourceDim();
pDateHelper = rGroupDim.GetDateHelper();
if ( !pDateHelper ) // date is handled below
{
- const ScDPGroupItem* pGroupItem = rGroupDim.GetGroupForData( pItemData[nDim] );
- if ( pGroupItem )
- pItemData[nDim] = pGroupItem->GetName();
- // if no group is found, keep the original name
+ const ScDPGroupItem* pGroupItem = rGroupDim.GetGroupForData( *GetMemberById( nSourceDim, pItemDataIndex[nDim] ));
+ if ( pGroupItem )
+ pItemDataIndex[nDim] = pCache->GetAdditionalItemID( pGroupItem->GetName() );
}
}
else if ( IsNumGroupDimension( nColumn ) )
@@ -1347,18 +1415,18 @@ void ScDPGroupTableData::FillGroupValues( ScDPItemData* pItemData, long nCount,
pDateHelper = pNumGroups[nColumn].GetDateHelper();
if ( !pDateHelper ) // date is handled below
{
- if ( pItemData[nDim].bHasValue )
+ const ScDPItemData* pData = pCache->GetItemDataById( (SCCOL)nSourceDim, pItemDataIndex[nDim]);
+ if ( pData ->IsValue() )
{
ScDPNumGroupInfo aNumInfo;
bool bHasNonInteger = false;
sal_Unicode cDecSeparator = 0;
GetNumGroupInfo( nColumn, aNumInfo, bHasNonInteger, cDecSeparator );
double fGroupValue;
- String aGroupName = lcl_GetNumGroupForValue( pItemData[nDim].fValue,
- aNumInfo, bHasNonInteger, cDecSeparator, fGroupValue, pDoc );
-
- // consistent with TypedStrData in GetNumEntries
- pItemData[nDim] = ScDPItemData( aGroupName, fGroupValue, TRUE );
+ String aGroupName = lcl_GetNumGroupForValue( pData->GetValue(),
+ aNumInfo, bHasNonInteger, cDecSeparator, fGroupValue, pDoc );
+ ScDPItemData aItemData ( aGroupName, fGroupValue, TRUE ) ;
+ pItemDataIndex[nDim] = pCache->GetAdditionalItemID( aItemData );
}
// else (textual) keep original value
}
@@ -1366,12 +1434,18 @@ void ScDPGroupTableData::FillGroupValues( ScDPItemData* pItemData, long nCount,
if ( pDateHelper )
{
- if ( pItemData[nDim].bHasValue )
+ const ScDPItemData* pData = GetCacheTable().GetCache()->GetItemDataById( (SCCOL)nSourceDim, pItemDataIndex[nDim]);
+ if ( pData ->IsValue() )
{
sal_Int32 nPartValue = lcl_GetDatePartValue(
- pItemData[nDim].fValue, pDateHelper->GetDatePart(), pDoc->GetFormatTable(),
- &pDateHelper->GetNumInfo() );
- pItemData[nDim] = ScDPItemData( String(), nPartValue, TRUE );
+ pData->GetValue(), pDateHelper->GetDatePart(), pDoc->GetFormatTable(),
+ &pDateHelper->GetNumInfo() );
+// Wang Xu Ming -- 2009-9-7
+// DataPilot Migration - Cache&&Performance
+ //String aName = lcl_GetDateGroupName( pDateHelper, nPartValue, pDoc->GetFormatTable() );
+ ScDPItemData aItemData( pDateHelper->GetDatePart(), String(), nPartValue, ScDPItemData::MK_DATA|ScDPItemData::MK_VAL|ScDPItemData::MK_DATEPART );
+ pItemDataIndex[nDim] = GetCacheTable().GetCache()->GetAdditionalItemID( aItemData );
+// End Comments
}
}
}
@@ -1527,5 +1601,22 @@ BOOL ScDPGroupTableData::HasCommonElement( const ScDPItemData& rFirstData, long
return TRUE;
}
+long ScDPGroupTableData::GetSourceDim( long nDim )
+{
+ if ( getIsDataLayoutDimension( nDim ) )
+ return nSourceCount;
+ if ( nDim >= nSourceCount && nDim < nSourceCount +(long) aGroups.size() )
+ {
+ const ScDPGroupDimension& rGroupDim = aGroups[nDim - nSourceCount];
+ return rGroupDim.GetSourceDim();
+ }
+ return nDim;
+}
+ long ScDPGroupTableData::Compare( long nDim, long nDataId1, long nDataId2)
+{
+ if ( getIsDataLayoutDimension(nDim) )
+ return 0;
+ return ScDPItemData::Compare( *GetMemberById(nDim, nDataId1),*GetMemberById(nDim, nDataId2) );
+}
// -----------------------------------------------------------------------
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 66ac3a4bedbb..44c998fb4ede 100644..100755
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -52,7 +52,11 @@
#include "attrib.hxx"
#include "scitems.hxx"
#include "unonames.hxx"
-
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+#include "dpglobal.hxx"
+#include "globstr.hrc"
+// End Comments
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/sheet/GeneralFunction.hpp>
#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
@@ -86,9 +90,6 @@ using ::com::sun::star::sheet::DataPilotTablePositionData;
using ::com::sun::star::beans::XPropertySet;
using ::rtl::OUString;
-// -----------------------------------------------------------------------
-
-#define MAX_LABELS 256 //!!! from fieldwnd.hxx, must be moved to global.hxx
// -----------------------------------------------------------------------
@@ -168,7 +169,9 @@ ScDPObject::ScDPObject( ScDocument* pD ) :
mnAutoFormatIndex( 65535 ),
bAllowMove( FALSE ),
nHeaderRows( 0 ),
- mbHeaderLayout(false)
+ mbHeaderLayout(false),
+ bRefresh( FALSE ), // Wang Xu Ming - DataPilot migration
+ mnCacheId( -1) // Wang Xu Ming - DataPilot migration
{
}
@@ -189,7 +192,9 @@ ScDPObject::ScDPObject(const ScDPObject& r) :
mnAutoFormatIndex( r.mnAutoFormatIndex ),
bAllowMove( FALSE ),
nHeaderRows( r.nHeaderRows ),
- mbHeaderLayout( r.mbHeaderLayout )
+ mbHeaderLayout( r.mbHeaderLayout ),
+ bRefresh( r.bRefresh ), // Wang Xu Ming - DataPilot migration
+ mnCacheId ( r.mnCacheId ) // Wang Xu Ming - DataPilot migration
{
if (r.pSaveData)
pSaveData = new ScDPSaveData(*r.pSaveData);
@@ -209,6 +214,7 @@ ScDPObject::~ScDPObject()
delete pSheetDesc;
delete pImpDesc;
delete pServDesc;
+ mnCacheId = -1; // Wang Xu Ming - DataPilot migration
}
ScDataObject* ScDPObject::Clone() const
@@ -232,6 +238,13 @@ void ScDPObject::SetSaveData(const ScDPSaveData& rData)
{
delete pSaveData;
pSaveData = new ScDPSaveData( rData );
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ if ( rData.GetCacheId() >= 0 )
+ mnCacheId = rData.GetCacheId();
+ else if ( mnCacheId >= 0 )
+ pSaveData->SetCacheId( mnCacheId );
+ // End Comments
}
InvalidateData(); // re-init source from SaveData
@@ -411,10 +424,11 @@ ScDPTableData* ScDPObject::GetTableData()
{
if (!mpTableData)
{
+ shared_ptr<ScDPTableData> pData;
if ( pImpDesc )
{
// database data
- mpTableData.reset(new ScDatabaseDPData(pDoc, *pImpDesc));
+ pData.reset(new ScDatabaseDPData(pDoc, *pImpDesc, GetCacheId()));
}
else
{
@@ -424,16 +438,27 @@ ScDPTableData* ScDPObject::GetTableData()
DBG_ERROR("no source descriptor");
pSheetDesc = new ScSheetSourceDesc; // dummy defaults
}
- mpTableData.reset(new ScSheetDPData(pDoc, *pSheetDesc));
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ pData.reset(new ScSheetDPData(pDoc, *pSheetDesc, GetCacheId()));
+ // End Comments
}
// grouping (for cell or database data)
if ( pSaveData && pSaveData->GetExistingDimensionData() )
{
- shared_ptr<ScDPGroupTableData> pGroupData(new ScDPGroupTableData(mpTableData, pDoc));
+ shared_ptr<ScDPGroupTableData> pGroupData(new ScDPGroupTableData(pData, pDoc));
pSaveData->GetExistingDimensionData()->WriteToData(*pGroupData);
- mpTableData = pGroupData;
+ pData = pGroupData;
}
+
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ if ( pData )
+ SetCacheId( pData->GetCacheId()); // resets mpTableData
+ // End Comments
+
+ mpTableData = pData; // after SetCacheId
}
return mpTableData.get();
@@ -462,11 +487,17 @@ void ScDPObject::CreateObjects()
{
DBG_ASSERT( !pServDesc, "DPSource could not be created" );
ScDPTableData* pData = GetTableData();
+
ScDPSource* pSource = new ScDPSource( pData );
xSource = pSource;
- }
- if (pSaveData)
+ if ( pSaveData && bRefresh )
+ {
+ pSaveData->Refresh( xSource );
+ bRefresh = FALSE;
+ }
+ }
+ if (pSaveData )
pSaveData->WriteToSource( xSource );
}
else if (bSettingsChanged)
@@ -784,13 +815,10 @@ bool ScDPObject::IsDimNameInUse(const OUString& rName) const
if (!xPropSet.is())
continue;
- Any any = xPropSet->getPropertyValue(OUString::createFromAscii(SC_UNO_LAYOUTNAME));
- OUString aLayoutName;
- if (any >>= aLayoutName)
- {
- if (aLayoutName.equalsIgnoreAsciiCase(rName))
- return true;
- }
+ OUString aLayoutName = ScUnoHelpFunctions::GetStringProperty(
+ xPropSet, OUString::createFromAscii(SC_UNO_LAYOUTNAME), OUString());
+ if (aLayoutName.equalsIgnoreAsciiCase(rName))
+ return true;
}
return false;
}
@@ -2301,48 +2329,6 @@ uno::Reference<sheet::XDimensionsSupplier> ScDPObject::CreateSource( const ScDPS
return xRet;
}
-// ============================================================================
-
-ScDPCacheCell::ScDPCacheCell() :
- mnStrId(ScSimpleSharedString::EMPTY),
- mnType(SC_VALTYPE_EMPTY),
- mfValue(0.0),
- mbNumeric(false)
-{
-}
-
-ScDPCacheCell::ScDPCacheCell(const ScDPCacheCell& r) :
- mnStrId(r.mnStrId),
- mnType(r.mnType),
- mfValue(r.mfValue),
- mbNumeric(r.mbNumeric)
-{
-}
-
-ScDPCacheCell::~ScDPCacheCell()
-{
-}
-
-// ============================================================================
-
-size_t ScDPCollection::CacheCellHash::operator()(const ScDPCacheCell* pCell) const
-{
- return pCell->mnStrId + static_cast<size_t>(pCell->mnType) +
- static_cast<size_t>(pCell->mfValue) + static_cast<size_t>(pCell->mbNumeric);
-}
-
-bool ScDPCollection::CacheCellEqual::operator()(const ScDPCacheCell* p1, const ScDPCacheCell* p2) const
-{
- if (!p1 && !p2)
- return true;
-
- if ((!p1 && p2) || (p1 && !p2))
- return false;
-
- return p1->mnStrId == p2->mnStrId && p1->mfValue == p2->mfValue &&
- p1->mbNumeric == p2->mbNumeric && p1->mnType == p2->mnType;
-}
-
// ----------------------------------------------------------------------------
ScDPCollection::ScDPCollection(ScDocument* pDocument) :
@@ -2352,15 +2338,12 @@ ScDPCollection::ScDPCollection(ScDocument* pDocument) :
ScDPCollection::ScDPCollection(const ScDPCollection& r) :
ScCollection(r),
- pDoc(r.pDoc),
- maSharedString(r.maSharedString),
- maCacheCellPool() // #i101725# don't copy hash_set with pointers from the other collection
+ pDoc(r.pDoc)
{
}
ScDPCollection::~ScDPCollection()
{
- clearCacheCellPool();
}
ScDataObject* ScDPCollection::Clone() const
@@ -2465,10 +2448,83 @@ String ScDPCollection::CreateNewName( USHORT nMin ) const
return String(); // should not happen
}
-ScSimpleSharedString& ScDPCollection::GetSharedString()
+
+
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+long ScDPObject::GetCacheId() const
{
- return maSharedString;
+ if ( GetSaveData() )
+ return GetSaveData()->GetCacheId();
+ else
+ return mnCacheId;
}
+ULONG ScDPObject::RefreshCache()
+{
+ if ( pServDesc )
+ {
+ // cache table isn't used for external service - do nothing, no error
+ return 0;
+ }
+
+ CreateObjects();
+ ULONG nErrId = 0;
+ if ( pSheetDesc)
+ nErrId = pSheetDesc->CheckValidate( pDoc );
+ if ( nErrId == 0 )
+ {
+ long nOldId = GetCacheId();
+ long nNewId = pDoc->GetNewDPObjectCacheId();
+ if ( nOldId >= 0 )
+ pDoc->RemoveDPObjectCache( nOldId );
+
+ ScDPTableDataCache* pCache = NULL;
+ if ( pSheetDesc )
+ pCache = pSheetDesc->CreateCache( pDoc, nNewId );
+ else if ( pImpDesc )
+ pCache = pImpDesc->CreateCache( pDoc, nNewId );
+
+ if ( pCache == NULL )
+ {
+ //cache failed
+ DBG_ASSERT( pCache , " pCache == NULL" );
+ return STR_ERR_DATAPILOTSOURCE;
+ }
+
+ nNewId = pCache->GetId();
+
+ bRefresh = TRUE;
+ ScDPCollection* pDPCollection = pDoc->GetDPCollection();
+ USHORT nCount = pDPCollection->GetCount();
+ for (USHORT i=0; i<nCount; i++)
+ { //set new cache id
+ if ( (*pDPCollection)[i]->GetCacheId() == nOldId )
+ {
+ (*pDPCollection)[i]->SetCacheId( nNewId );
+ (*pDPCollection)[i]->SetRefresh();
+
+ }
+ }
+ DBG_ASSERT( GetCacheId() >= 0, " GetCacheId() >= 0 " );
+ }
+ return nErrId;
+}
+void ScDPObject::SetCacheId( long nCacheId )
+{
+ if ( GetCacheId() != nCacheId )
+ {
+ InvalidateSource();
+ if ( GetSaveData() )
+ GetSaveData()->SetCacheId( nCacheId );
+
+ mnCacheId = nCacheId;
+ }
+}
+const ScDPTableDataCache* ScDPObject::GetCache() const
+{
+ return pDoc->GetDPObjectCache( GetCacheId() );
+}
+// End Comments
void ScDPCollection::FreeTable(ScDPObject* pDPObj)
{
@@ -2503,54 +2559,4 @@ bool ScDPCollection::HasDPTable(SCCOL nCol, SCROW nRow, SCTAB nTab) const
return pMergeAttr->HasDPTable();
}
-ScDPCacheCell* ScDPCollection::getCacheCellFromPool(const ScDPCacheCell& rCell)
-{
- ScDPCacheCell aCell(rCell);
- CacheCellPoolType::iterator itr = maCacheCellPool.find(&aCell);
- if (itr == maCacheCellPool.end())
- {
- // Insert a new instance.
- ScDPCacheCell* p = new ScDPCacheCell(rCell);
- ::std::pair<CacheCellPoolType::iterator, bool> r =
- maCacheCellPool.insert(p);
- if (!r.second)
- delete p;
-
- ScDPCacheCell* p2 = r.second ? *r.first : NULL;
- DBG_ASSERT(p == p2, "ScDPCollection::getCacheCellFromPool: pointer addresses differ");
- return p2;
- }
- return *itr;
-}
-
-namespace {
-
-class DeleteCacheCells : public ::std::unary_function<ScDPCacheCell*, void>
-{
-public:
- void operator()(ScDPCacheCell* p) const
- {
- delete p;
- }
-};
-
-}
-
-void ScDPCollection::clearCacheCellPool()
-{
- // Transferring all stored pointers to a vector first. For some unknown
- // reason, deleting cell content instances by directly iterating through
- // the hash set causes the iteration to return an identical pointer
- // value twice, causing a double-delete. I have no idea why this happens.
-
- using ::std::copy;
- using ::std::back_inserter;
-
- vector<ScDPCacheCell*> ps;
- ps.reserve(maCacheCellPool.size());
- copy(maCacheCellPool.begin(), maCacheCellPool.end(), back_inserter(ps));
- maCacheCellPool.clear();
- // for correctness' sake, delete the elements after clearing the hash_set
- for_each(ps.begin(), ps.end(), DeleteCacheCells());
-}
diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index 7ecdc3d34702..ec384874aa69 100644..100755
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -56,22 +56,11 @@
#include "scresid.hxx"
#include "unonames.hxx"
#include "sc.hrc"
-
-#include <com/sun/star/container/XNamed.hpp>
-#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
-#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
-#include <com/sun/star/sheet/DataPilotTableHeaderData.hpp>
-#include <com/sun/star/sheet/DataPilotTablePositionData.hpp>
-#include <com/sun/star/sheet/DataPilotTablePositionType.hpp>
-#include <com/sun/star/sheet/DataPilotTableResultData.hpp>
-#include <com/sun/star/sheet/DataResultFlags.hpp>
-#include <com/sun/star/sheet/GeneralFunction.hpp>
-#include <com/sun/star/sheet/MemberResultFlags.hpp>
-#include <com/sun/star/sheet/TableFilterField.hpp>
-#include <com/sun/star/sheet/XDataPilotMemberResults.hpp>
-#include <com/sun/star/sheet/XDataPilotResults.hpp>
-#include <com/sun/star/sheet/XHierarchiesSupplier.hpp>
-#include <com/sun/star/sheet/XLevelsSupplier.hpp>
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+#include "scdpoutputimpl.hxx"
+#include "dpglobal.hxx"
+// End Comments
#include <com/sun/star/beans/XPropertySet.hpp>
#include <vector>
@@ -451,14 +440,12 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
if ( xLevNam.is() && xLevRes.is() )
{
String aName = xLevNam->getName();
- OUString aCaption = aName; // Caption equals the field name by default.
Reference<XPropertySet> xPropSet(xLevel, UNO_QUERY);
- if (xPropSet.is())
- {
- Any any = xPropSet->getPropertyValue(
- OUString::createFromAscii(SC_UNO_LAYOUTNAME));
- any >>= aCaption;
- }
+ // Caption equals the field name by default.
+ // #i108948# use ScUnoHelpFunctions::GetStringProperty, because
+ // LayoutName is new and may not be present in external implementation
+ OUString aCaption = ScUnoHelpFunctions::GetStringProperty( xPropSet,
+ OUString::createFromAscii(SC_UNO_LAYOUTNAME), aName );
bool bRowFieldHasMember = false;
switch ( eDimOrient )
@@ -653,11 +640,21 @@ void ScDPOutput::HeaderCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
if ( nFlags & sheet::MemberResultFlags::SUBTOTAL )
{
// SvxWeightItem aItem( WEIGHT_BOLD ); // weight is in the style
-
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ OutputImpl outputimp( pDoc, nTab,
+ nTabStartCol, nTabStartRow, nMemberStartCol, nMemberStartRow,
+ nDataStartCol, nDataStartRow, nTabEndCol, nTabEndRow );
+ // End Comments
//! limit frames to horizontal or vertical?
if (bColHeader)
{
- lcl_SetFrame( pDoc,nTab, nCol,nMemberStartRow+(SCROW)nLevel, nCol,nTabEndRow, 20 );
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ //lcl_SetFrame( pDoc,nTab, nCol,nMemberStartRow+(SCROW)nLevel, nCol,nTabEndRow, SC_DP_FRAME_INNER_BOLD );
+ outputimp.OutputBlockFrame( nCol,nMemberStartRow+(SCROW)nLevel, nCol,nDataStartRow-1 );
+ // End Comments
+
lcl_SetStyleById( pDoc,nTab, nCol,nMemberStartRow+(SCROW)nLevel, nCol,nDataStartRow-1,
STR_PIVOT_STYLE_TITLE );
lcl_SetStyleById( pDoc,nTab, nCol,nDataStartRow, nCol,nTabEndRow,
@@ -665,7 +662,11 @@ void ScDPOutput::HeaderCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
}
else
{
- lcl_SetFrame( pDoc,nTab, nMemberStartCol+(SCCOL)nLevel,nRow, nTabEndCol,nRow, 20 );
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ //lcl_SetFrame( pDoc,nTab, nMemberStartCol+(USHORT)nLevel,nRow, nTabEndCol,nRow, SC_DP_FRAME_INNER_BOLD );
+ outputimp.OutputBlockFrame( nMemberStartCol+(SCCOL)nLevel,nRow, nDataStartCol-1,nRow );
+ // End Comments
lcl_SetStyleById( pDoc,nTab, nMemberStartCol+(SCCOL)nLevel,nRow, nDataStartCol-1,nRow,
STR_PIVOT_STYLE_TITLE );
lcl_SetStyleById( pDoc,nTab, nDataStartCol,nRow, nTabEndCol,nRow,
@@ -814,6 +815,20 @@ void ScDPOutput::Output()
if ( bDoFilter )
lcl_DoFilterButton( pDoc, aStartPos.Col(), aStartPos.Row(), nTab );
+ // output data results:
+
+ for (long nRow=0; nRow<nRowCount; nRow++)
+ {
+ SCROW nRowPos = nDataStartRow + (SCROW)nRow; //! check for overflow
+ const sheet::DataResult* pColAry = pRowAry[nRow].getConstArray();
+ long nThisColCount = pRowAry[nRow].getLength();
+ DBG_ASSERT( nThisColCount == nColCount, "count mismatch" ); //! ???
+ for (long nCol=0; nCol<nThisColCount; nCol++)
+ {
+ SCCOL nColPos = nDataStartCol + (SCCOL)nCol; //! check for overflow
+ DataCell( nColPos, nRowPos, nTab, pColAry[nCol] );
+ }
+ }
// output page fields:
for (nField=0; nField<nPageFieldCount; nField++)
@@ -856,7 +871,12 @@ void ScDPOutput::Output()
STR_PIVOT_STYLE_INNER );
// output column headers:
-
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ OutputImpl outputimp( pDoc, nTab,
+ nTabStartCol, nTabStartRow, nMemberStartCol, nMemberStartRow,
+ nDataStartCol, nDataStartRow, nTabEndCol, nTabEndRow );
+ // End Comments
for (nField=0; nField<nColFieldCount; nField++)
{
SCCOL nHdrCol = nDataStartCol + (SCCOL)nField; //! check for overflow
@@ -871,28 +891,44 @@ void ScDPOutput::Output()
{
SCCOL nColPos = nDataStartCol + (SCCOL)nCol; //! check for overflow
HeaderCell( nColPos, nRowPos, nTab, pArray[nCol], TRUE, nField );
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
if ( ( pArray[nCol].Flags & sheet::MemberResultFlags::HASMEMBER ) &&
!( pArray[nCol].Flags & sheet::MemberResultFlags::SUBTOTAL ) )
{
+ long nEnd = nCol;
+ while ( nEnd+1 < nThisColCount && ( pArray[nEnd+1].Flags & sheet::MemberResultFlags::CONTINUE ) )
+ ++nEnd;
+ SCCOL nEndColPos = nDataStartCol + (SCCOL)nEnd; //! check for overflow
if ( nField+1 < nColFieldCount )
{
- long nEnd = nCol;
- while ( nEnd+1 < nThisColCount && ( pArray[nEnd+1].Flags & sheet::MemberResultFlags::CONTINUE ) )
- ++nEnd;
- SCCOL nEndColPos = nDataStartCol + (SCCOL)nEnd; //! check for overflow
- lcl_SetFrame( pDoc,nTab, nColPos,nRowPos, nEndColPos,nRowPos, 20 );
- lcl_SetFrame( pDoc,nTab, nColPos,nRowPos, nEndColPos,nTabEndRow, 20 );
+ // lcl_SetFrame( pDoc,nTab, nColPos,nRowPos, nEndColPos,nRowPos, SC_DP_FRAME_INNER_BOLD );
+ // lcl_SetFrame( pDoc,nTab, nColPos,nRowPos, nEndColPos,nTabEndRow, SC_DP_FRAME_INNER_BOLD );
+ if ( nField == nColFieldCount - 2 )
+ {
+ outputimp.AddCol( nColPos );
+ if ( nColPos + 1 == nEndColPos )
+ outputimp.OutputBlockFrame( nColPos,nRowPos, nEndColPos,nRowPos+1, TRUE );
+ }
+ else
+ outputimp.OutputBlockFrame( nColPos,nRowPos, nEndColPos,nRowPos );
lcl_SetStyleById( pDoc, nTab, nColPos,nRowPos, nEndColPos,nDataStartRow-1, STR_PIVOT_STYLE_CATEGORY );
}
else
lcl_SetStyleById( pDoc, nTab, nColPos,nRowPos, nColPos,nDataStartRow-1, STR_PIVOT_STYLE_CATEGORY );
}
+ else if ( pArray[nCol].Flags & sheet::MemberResultFlags::SUBTOTAL )
+ outputimp.AddCol( nColPos );
}
+ if ( nField== 0 && nColFieldCount == 1 )
+ outputimp.OutputBlockFrame( nDataStartCol,nTabStartRow, nTabEndCol,nRowPos-1 );
+ // End Comments
}
// output row headers:
-
+ std::vector<BOOL> vbSetBorder;
+ vbSetBorder.resize( nTabEndRow - nDataStartRow + 1, FALSE );
for (nField=0; nField<nRowFieldCount; nField++)
{
bool bDataLayout = mbHasDataLayout && (nField == nRowFieldCount-1);
@@ -920,41 +956,39 @@ void ScDPOutput::Output()
while ( nEnd+1 < nThisRowCount && ( pArray[nEnd+1].Flags & sheet::MemberResultFlags::CONTINUE ) )
++nEnd;
SCROW nEndRowPos = nDataStartRow + (SCROW)nEnd; //! check for overflow
- lcl_SetFrame( pDoc,nTab, nColPos,nRowPos, nColPos,nEndRowPos, 20 );
- lcl_SetFrame( pDoc,nTab, nColPos,nRowPos, nTabEndCol,nEndRowPos, 20 );
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ // lcl_SetFrame( pDoc,nTab, nColPos,nRowPos, nColPos,nEndRowPos, SC_DP_FRAME_INNER_BOLD );
+ //lcl_SetFrame( pDoc,nTab, nColPos,nRowPos, nTabEndCol,nEndRowPos, SC_DP_FRAME_INNER_BOLD );
+ outputimp.AddRow( nRowPos );
+ if ( vbSetBorder[ nRow ] == FALSE )
+ {
+ outputimp.OutputBlockFrame( nColPos, nRowPos, nTabEndCol, nEndRowPos );
+ vbSetBorder[ nRow ] = TRUE;
+ }
+ outputimp.OutputBlockFrame( nColPos, nRowPos, nColPos, nEndRowPos );
+
+ if ( nField == nRowFieldCount - 2 )
+ outputimp.OutputBlockFrame( nColPos+1, nRowPos, nColPos+1, nEndRowPos );
+ // End Comments
lcl_SetStyleById( pDoc, nTab, nColPos,nRowPos, nDataStartCol-1,nEndRowPos, STR_PIVOT_STYLE_CATEGORY );
}
else
lcl_SetStyleById( pDoc, nTab, nColPos,nRowPos, nDataStartCol-1,nRowPos, STR_PIVOT_STYLE_CATEGORY );
}
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ else if ( pArray[nRow].Flags & sheet::MemberResultFlags::SUBTOTAL )
+ outputimp.AddRow( nRowPos );
+ // End Comments
}
}
- // output data results:
-
- for (long nRow=0; nRow<nRowCount; nRow++)
- {
- SCROW nRowPos = nDataStartRow + (SCROW)nRow; //! check for overflow
- const sheet::DataResult* pColAry = pRowAry[nRow].getConstArray();
- long nThisColCount = pRowAry[nRow].getLength();
- DBG_ASSERT( nThisColCount == nColCount, "count mismatch" ); //! ???
- for (long nCol=0; nCol<nThisColCount; nCol++)
- {
- SCCOL nColPos = nDataStartCol + (SCCOL)nCol; //! check for overflow
- DataCell( nColPos, nRowPos, nTab, pColAry[nCol] );
- }
- }
-
- // frame around the whole table
-
- lcl_SetFrame( pDoc,nTab, nDataStartCol,nDataStartRow, nTabEndCol,nTabEndRow, 20 );
- if ( nDataStartCol > nMemberStartCol )
- lcl_SetFrame( pDoc,nTab, nMemberStartCol,nDataStartRow, nDataStartCol-1,nTabEndRow, 20 );
- if ( nDataStartRow > nMemberStartRow )
- lcl_SetFrame( pDoc,nTab, nDataStartCol,nMemberStartRow, nTabEndCol,nDataStartRow-1, 20 );
-
- lcl_SetFrame( pDoc,nTab, nTabStartCol,nTabStartRow, nTabEndCol,nTabEndRow, 40 );
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+ outputimp.OutputDataArea();
+// End Comments
}
ScRange ScDPOutput::GetOutputRange( sal_Int32 nRegionType )
diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index 58a9e112ab7d..72cf15285310 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -54,6 +54,19 @@
#include <com/sun/star/sheet/XMembersSupplier.hpp>
#include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/util/XCloneable.hpp>
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+#include "dptabsrc.hxx"
+#include "dpglobal.hxx"
+using namespace ScDPGlobal;
+#ifndef _COM_SUN_STAR_SHEET_DATAPILOTFIELDREFERENCETYPE_HPP_
+#include <com/sun/star/sheet/DataPilotFieldReferenceType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SHEET_DATAPILOTFIELDREFERENCEITEMTYPE_HPP_
+#include <com/sun/star/sheet/DataPilotFieldReferenceItemType.hpp>
+#endif
+using namespace com::sun::star::sheet;
+// End Comments
#include <hash_map>
@@ -73,25 +86,6 @@ using ::std::auto_ptr;
// -----------------------------------------------------------------------
-//! move to a header file
-//! use names from unonames.hxx?
-#define DP_PROP_COLUMNGRAND "ColumnGrand"
-#define DP_PROP_FUNCTION "Function"
-#define DP_PROP_IGNOREEMPTY "IgnoreEmptyRows"
-#define DP_PROP_ISDATALAYOUT "IsDataLayoutDimension"
-#define DP_PROP_ISVISIBLE "IsVisible"
-#define DP_PROP_ORIENTATION "Orientation"
-#define DP_PROP_REPEATIFEMPTY "RepeatIfEmpty"
-#define DP_PROP_ROWGRAND "RowGrand"
-#define DP_PROP_SHOWDETAILS "ShowDetails"
-#define DP_PROP_SHOWEMPTY "ShowEmpty"
-#define DP_PROP_SUBTOTALS "SubTotals"
-#define DP_PROP_USEDHIERARCHY "UsedHierarchy"
-#define DP_PROP_FILTER "Filter"
-#define DP_PROP_POSITION "Position"
-
-// -----------------------------------------------------------------------
-
void lcl_SetBoolProperty( const uno::Reference<beans::XPropertySet>& xProp,
const rtl::OUString& rName, sal_Bool bValue )
{
@@ -320,6 +314,51 @@ BOOL ScDPSaveDimension::operator== ( const ScDPSaveDimension& r ) const
if (!(**a == **b))
return FALSE;
+ if ( this->HasCurrentPage() && r.HasCurrentPage() )
+ {
+ if ( this->GetCurrentPage() != r.GetCurrentPage() )
+ {
+ return FALSE;
+ }
+ }
+ else if ( this->HasCurrentPage() || r.HasCurrentPage() )
+ {
+ return FALSE;
+ }
+ if( pReferenceValue && r.pReferenceValue )
+ {
+ if ( !(*pReferenceValue == *r.pReferenceValue) )
+ {
+ return FALSE;
+ }
+ }
+ else if ( pReferenceValue || r.pReferenceValue )
+ {
+ return FALSE;
+ }
+ if( this->pSortInfo && r.pSortInfo )
+ {
+ if ( !(*this->pSortInfo == *r.pSortInfo) )
+ {
+ return FALSE;
+ }
+ }
+ else if ( this->pSortInfo || r.pSortInfo )
+ {
+ return FALSE;
+ }
+ if( this->pAutoShowInfo && r.pAutoShowInfo )
+ {
+ if ( !(*this->pAutoShowInfo == *r.pAutoShowInfo) )
+ {
+ return FALSE;
+ }
+ }
+ else if ( this->pAutoShowInfo || r.pAutoShowInfo )
+ {
+ return FALSE;
+ }
+
return TRUE;
}
@@ -709,6 +748,10 @@ ScDPSaveData::ScDPSaveData() :
nRepeatEmptyMode( SC_DPSAVEMODE_DONTKNOW ),
bFilterButton( TRUE ),
bDrillDown( TRUE ),
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ mnCacheId( -1),
+ // End Comments
mbDimensionMembersBuilt(false),
mpGrandTotalName(NULL)
{
@@ -721,6 +764,10 @@ ScDPSaveData::ScDPSaveData(const ScDPSaveData& r) :
nRepeatEmptyMode( r.nRepeatEmptyMode ),
bFilterButton( r.bFilterButton ),
bDrillDown( r.bDrillDown ),
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ mnCacheId( r.mnCacheId ),
+ // End Comments
mbDimensionMembersBuilt(r.mbDimensionMembersBuilt),
mpGrandTotalName(NULL)
{
@@ -744,40 +791,11 @@ ScDPSaveData& ScDPSaveData::operator= ( const ScDPSaveData& r )
{
if ( &r != this )
{
- delete pDimensionData;
- if ( r.pDimensionData )
- pDimensionData = new ScDPDimensionSaveData( *r.pDimensionData );
- else
- pDimensionData = NULL;
-
- nColumnGrandMode = r.nColumnGrandMode;
- nRowGrandMode = r.nRowGrandMode;
- nIgnoreEmptyMode = r.nIgnoreEmptyMode;
- nRepeatEmptyMode = r.nRepeatEmptyMode;
- bFilterButton = r.bFilterButton;
- bDrillDown = r.bDrillDown;
- mbDimensionMembersBuilt = r.mbDimensionMembersBuilt;
-
- // remove old dimensions
-
- long nCount = aDimList.Count();
- long i;
- for (i=0; i<nCount; i++)
- delete (ScDPSaveDimension*)aDimList.GetObject(i);
- aDimList.Clear();
-
- // copy new dimensions
-
- nCount = r.aDimList.Count();
- for (i=0; i<nCount; i++)
- {
- ScDPSaveDimension* pNew =
- new ScDPSaveDimension( *(ScDPSaveDimension*)r.aDimList.GetObject(i) );
- aDimList.Insert( pNew, LIST_APPEND );
- }
-
- if (r.mpGrandTotalName.get())
- mpGrandTotalName.reset(new OUString(*r.mpGrandTotalName));
+ // Wang Xu Ming -- 2009-8-17
+ // DataPilot Migration - Cache&&Performance
+ this->~ScDPSaveData();
+ new( this ) ScDPSaveData ( r );
+ // End Comments
}
return *this;
}
@@ -789,6 +807,7 @@ BOOL ScDPSaveData::operator== ( const ScDPSaveData& r ) const
nIgnoreEmptyMode != r.nIgnoreEmptyMode ||
nRepeatEmptyMode != r.nRepeatEmptyMode ||
bFilterButton != r.bFilterButton ||
+ mnCacheId != r.mnCacheId ||/// Wang Xu Ming -- 2009-6-18 DataPilot Migration
bDrillDown != r.bDrillDown ||
mbDimensionMembersBuilt != r.mbDimensionMembersBuilt)
return FALSE;
@@ -1089,6 +1108,7 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie
// reset all orientations
//! "forgetSettings" or similar at source ?????
//! reset all duplicated dimensions, or reuse them below !!!
+ DBG_TRACE( "ScDPSaveData::WriteToSource" );
lcl_ResetOrient( xSource );
@@ -1097,6 +1117,9 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie
{
ScDPSaveDimension* pDim = (ScDPSaveDimension*)aDimList.GetObject(i);
rtl::OUString aName = pDim->GetName();
+
+ DBG_TRACESTR(pDim->GetName());
+
BOOL bData = pDim->IsDataLayout();
//! getByName for ScDPSource, including DataLayoutDimension !!!!!!!!
@@ -1228,16 +1251,17 @@ void ScDPSaveData::BuildAllDimensionMembers(ScDPTableData* pData)
continue;
long nDimIndex = itr->second;
- const TypedScStrCollection& rMembers = pData->GetColumnEntries(nDimIndex);
- sal_uInt16 nMemberCount = rMembers.GetCount();
- for (sal_uInt16 j = 0; j < nMemberCount; ++j)
+ const std::vector<SCROW>& rMembers = pData->GetColumnEntries(nDimIndex);
+ size_t mMemberCount = rMembers.size();
+ for (size_t j = 0; j < mMemberCount; ++j)
{
- const String& rMemName = rMembers[j]->GetString();
- if (pDim->GetExistingMemberByName(rMemName))
+ const ScDPItemData* pMemberData = pData->GetMemberById( nDimIndex, rMembers[j] );
+ String aMemName = pMemberData->GetString();
+ if (pDim->GetExistingMemberByName(aMemName))
// this member instance already exists. nothing to do.
continue;
- auto_ptr<ScDPSaveMember> pNewMember(new ScDPSaveMember(rMemName));
+ auto_ptr<ScDPSaveMember> pNewMember(new ScDPSaveMember(aMemName));
pNewMember->SetIsVisible(true);
pDim->AddMember(pNewMember.release());
}
@@ -1254,3 +1278,196 @@ bool ScDPSaveData::HasInvisibleMember(const OUString& rDimName) const
return pDim->HasInvisibleMember();
}
+
+void ScDPSaveData::Refresh( const uno::Reference<sheet::XDimensionsSupplier>& xSource )
+{
+ try
+ {
+ long nCount = aDimList.Count();
+ std::list<String> deletedDims;
+ for (long i=nCount-1; i >=0 ; i--)
+ {
+ ScDPSaveDimension* pDim = (ScDPSaveDimension*)aDimList.GetObject(i);
+
+ rtl::OUString aName = pDim->GetName();
+ if ( pDim->IsDataLayout() )
+ continue;
+
+ uno::Reference<container::XNameAccess> xDimsName = xSource->getDimensions();
+ uno::Reference<container::XIndexAccess> xIntDims = new ScNameToIndexAccess( xDimsName );
+ long nIntCount = xIntDims->getCount();
+ BOOL bFound = FALSE;
+ for (long nIntDim=0; nIntDim<nIntCount && !bFound; nIntDim++)
+ {
+ uno::Reference<uno::XInterface> xIntDim = ScUnoHelpFunctions::AnyToInterface( xIntDims->getByIndex(nIntDim) );
+ uno::Reference<container::XNamed> xDimName( xIntDim, uno::UNO_QUERY );
+ if ( xDimName.is() && xDimName->getName() == aName )
+ bFound = TRUE;
+ }
+ if ( !bFound )
+ {
+ deletedDims.push_back( aName );
+ aDimList.Remove(i);
+ DBG_TRACE( "\n Remove dim: \t" );
+ DBG_TRACESTR( String( aName ) );
+ }
+
+ }
+
+ nCount = aDimList.Count();
+ for (long i=nCount-1; i >=0 ; i--) //check every dimension ??
+ {
+ ScDPSaveDimension* pDim = (ScDPSaveDimension*)aDimList.GetObject(i);
+
+ rtl::OUString aName = pDim->GetName();
+ if ( pDim->IsDataLayout() )
+ continue;
+ pDim->Refresh( xSource, deletedDims );
+
+ }
+ }
+ catch(uno::Exception&)
+ {
+ DBG_ERROR("error in ScDPSaveData::Refresh");
+ }
+
+}
+void ScDPSaveDimension::Refresh( const com::sun::star::uno::Reference<
+ com::sun::star::sheet::XDimensionsSupplier>& xSource ,
+ const std::list<String>& deletedDims)
+{
+ if ( xSource.is() )
+ {
+ ScDPSource* pTabSource = static_cast<ScDPSource*>( xSource.get() );
+ ScDPTableDataCache* pCache = pTabSource->GetCache();
+ if ( pCache->GetId() == -1 )
+ return;
+
+ SCCOL nSrcDim = pCache->GetDimensionIndex( GetName() );
+
+ if ( nSrcDim == -1 )
+ return;
+ if ( pSelectedPage )
+ {//check pSelected page
+ DBG_TRACESTR( (*pSelectedPage) );
+ if ( pCache->GetIdByItemData( nSrcDim, *pSelectedPage ) == -1 )
+ {
+ delete pSelectedPage;
+ pSelectedPage = NULL;
+ }
+
+ };
+
+ if ( pReferenceValue && pReferenceValue->ReferenceItemType == DataPilotFieldReferenceItemType::NAMED )
+ {//check pReferenceValue
+#ifdef DEBUG
+ switch( pReferenceValue->ReferenceType)
+ {
+ case sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE: //both
+ DBG_TRACE( "\n sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE \n" );
+ break;
+ case sheet::DataPilotFieldReferenceType::ITEM_DIFFERENCE: //both
+ DBG_TRACE( "\n sheet::DataPilotFieldReferenceType::ITEM_DIFFERENCE \n" );
+ break;
+ case sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE: //both
+ DBG_TRACE( "\n sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE \n" );
+ break;
+ case sheet::DataPilotFieldReferenceType::RUNNING_TOTAL:
+ DBG_TRACE( "\n sheet::DataPilotFieldReferenceType::RUNNING_TOTAL \n" ); //enable name
+ break;
+ }
+#endif
+ switch( pReferenceValue->ReferenceType)
+ {
+ case sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE:
+ case sheet::DataPilotFieldReferenceType::ITEM_DIFFERENCE:
+ case sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE:
+ case sheet::DataPilotFieldReferenceType::RUNNING_TOTAL:
+ {
+ if( pReferenceValue->ReferenceItemType == DataPilotFieldReferenceItemType::NAMED )
+ {
+ const String& sReferenceFieldName = pReferenceValue->ReferenceField;
+ DBG_TRACESTR( sReferenceFieldName );
+ SCCOL nRefDim = pCache->GetDimensionIndex( sReferenceFieldName );
+ bool bValid = true;
+ if ( nRefDim == -1 )
+ bValid = false;
+ else if ( pReferenceValue->ReferenceType != sheet::DataPilotFieldReferenceType::RUNNING_TOTAL )
+ { //running total has not reference item
+ const String& sReferenceItemName = pReferenceValue->ReferenceItemName;
+ DBG_TRACESTR( sReferenceItemName );
+ if ( pCache->GetIdByItemData( nRefDim, sReferenceItemName ) == -1 )
+ bValid = false;
+ }
+ if ( !bValid )
+ {
+ delete pReferenceValue;
+ pReferenceValue = NULL;
+ }
+ }
+ }
+ break;
+ }
+
+ };
+
+ if ( pSortInfo )
+ { //check sortinfo
+ if ( pSortInfo->Mode == DataPilotFieldSortMode::DATA )
+ {
+ DBG_TRACE( "\n DataPilotFieldSortMode::DATA \n" );
+ const String& sFieldDimName = pSortInfo->Field;
+ std::list<String>::const_iterator iter = std::find( deletedDims.begin(), deletedDims.end(), sFieldDimName );
+ if ( iter != deletedDims.end() && pCache->GetDimensionIndex( sFieldDimName ) == -1 )
+ {
+ pSortInfo->Mode = DataPilotFieldSortMode::MANUAL;
+ pSortInfo->Field = GetName();
+ }
+ }
+
+ };
+
+ if ( pAutoShowInfo )
+ { //check autoshow
+ const String& sFieldDimName = pAutoShowInfo->DataField;
+ std::list<String>::const_iterator iter = std::find( deletedDims.begin(), deletedDims.end(), sFieldDimName );
+ if ( iter != deletedDims.end() && pCache->GetDimensionIndex( sFieldDimName ) == -1 )
+ {
+ delete pAutoShowInfo;
+ pAutoShowInfo = NULL;
+ }
+
+ };
+
+ //remove unused members
+ //SODC_19124
+ for (MemberList::iterator i=maMemberList.begin(); i != maMemberList.end() ; )
+ {
+ rtl::OUString aMemberName = (*i)->GetName();
+ if ( pCache->GetIdByItemData( nSrcDim, aMemberName ) == -1 )
+ i = maMemberList.erase( i );
+ else
+ i++;
+ }
+ }
+}
+// End Comments
+bool operator == (const ::com::sun::star::sheet::DataPilotFieldSortInfo &l, const ::com::sun::star::sheet::DataPilotFieldSortInfo &r )
+{
+ return l.Field == r.Field && l.IsAscending == r.IsAscending && l.Mode == r.Mode;
+}
+bool operator == (const ::com::sun::star::sheet::DataPilotFieldAutoShowInfo &l, const ::com::sun::star::sheet::DataPilotFieldAutoShowInfo &r )
+{
+ return l.IsEnabled == r.IsEnabled &&
+ l.ShowItemsMode == r.ShowItemsMode &&
+ l.ItemCount == r.ItemCount &&
+ l.DataField == r.DataField;
+}
+bool operator == (const ::com::sun::star::sheet::DataPilotFieldReference &l, const ::com::sun::star::sheet::DataPilotFieldReference &r )
+{
+ return l.ReferenceType == r.ReferenceType &&
+ l.ReferenceField == r.ReferenceField &&
+ l.ReferenceItemType == r.ReferenceItemType &&
+ l.ReferenceItemName == r.ReferenceItemName;
+}
+
diff --git a/sc/source/core/data/dpsdbtab.cxx b/sc/source/core/data/dpsdbtab.cxx
index be8eca58ce95..aae5797211b0 100644
--- a/sc/source/core/data/dpsdbtab.cxx
+++ b/sc/source/core/data/dpsdbtab.cxx
@@ -69,169 +69,181 @@ using ::com::sun::star::uno::Any;
using ::com::sun::star::uno::UNO_QUERY;
#define SC_SERVICE_ROWSET "com.sun.star.sdb.RowSet"
-#define SC_SERVICE_INTHANDLER "com.sun.star.sdb.InteractionHandler"
+#define SC_SERVICE_INTHANDLER "com.sun.star.task.InteractionHandler"
//! move to a header file?
#define SC_DBPROP_DATASOURCENAME "DataSourceName"
#define SC_DBPROP_COMMAND "Command"
#define SC_DBPROP_COMMANDTYPE "CommandType"
-
// -----------------------------------------------------------------------
-
-class ScDatabaseDPData_Impl
+// Wang Xu Ming -- 2009-9-15
+// DataPilot Migration - Cache&&Performance
+ ScDPTableDataCache* ScImportSourceDesc::GetExistDPObjectCache( ScDocument* pDoc ) const
{
-public:
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceManager;
- ScImportSourceDesc aDesc;
- long nColCount;
- uno::Reference<sdbc::XRowSet> xRowSet;
- sal_Int32* pTypes;
- SvNumberFormatter* pFormatter;
-
- ScDPCacheTable aCacheTable;
-
- ScDatabaseDPData_Impl(ScDPCollection* p) :
- aCacheTable(p)
+ ScDPTableDataCache* pCache = NULL;
+ ScDPCollection* pDPCollection= pDoc->GetDPCollection();
+ USHORT nCount = pDPCollection->GetCount();
+
+ for ( short i=nCount-1; i>=0 ; i--)
{
+ if ( const ScImportSourceDesc* pUsedDesc = (*pDPCollection)[i]->GetImportSourceDesc() )
+ if ( *this == *pUsedDesc )
+ {
+ long nID = (*pDPCollection)[i]->GetCacheId();
+ if ( nID >= 0 )
+ pCache= pDoc->GetDPObjectCache( nID );
+ if ( pCache )
+ return pCache;
+ }
}
-};
-
-// -----------------------------------------------------------------------
-
-ScDatabaseDPData::ScDatabaseDPData(
- ScDocument* pDoc,
- const ScImportSourceDesc& rImport ) :
- ScDPTableData(pDoc)
-{
- pImpl = new ScDatabaseDPData_Impl(pDoc->GetDPCollection());
- pImpl->xServiceManager = pDoc->GetServiceManager();
- pImpl->aDesc = rImport;
- pImpl->nColCount = 0;
- pImpl->pTypes = NULL;
- pImpl->pFormatter = NULL; // created on demand
-
- OpenDatabase();
- CreateCacheTable();
-}
-
-ScDatabaseDPData::~ScDatabaseDPData()
-{
- ::comphelper::disposeComponent( pImpl->xRowSet );
-
- delete[] pImpl->pTypes;
- delete pImpl->pFormatter; // NumberFormatter is local for this object
- delete pImpl;
+ return NULL;
}
-void ScDatabaseDPData::DisposeData()
+ScDPTableDataCache* ScImportSourceDesc::CreateCache( ScDocument* pDoc , long nID ) const
{
- //! use OpenDatabase here?
- pImpl->aCacheTable.clear();
-}
+ if ( !pDoc )
+ return NULL;
-BOOL ScDatabaseDPData::OpenDatabase()
-{
sal_Int32 nSdbType = -1;
- switch ( pImpl->aDesc.nType )
+
+ switch ( nType )
{
- case sheet::DataImportMode_SQL: nSdbType = sdb::CommandType::COMMAND; break;
- case sheet::DataImportMode_TABLE: nSdbType = sdb::CommandType::TABLE; break;
- case sheet::DataImportMode_QUERY: nSdbType = sdb::CommandType::QUERY; break;
- default:
- return FALSE;
+ case sheet::DataImportMode_SQL: nSdbType = sdb::CommandType::COMMAND; break;
+ case sheet::DataImportMode_TABLE: nSdbType = sdb::CommandType::TABLE; break;
+ case sheet::DataImportMode_QUERY: nSdbType = sdb::CommandType::QUERY; break;
+ default:
+ return NULL;
}
- BOOL bSuccess = FALSE;
+
+ ScDPTableDataCache* pCache = GetExistDPObjectCache( pDoc );
+
+ if ( pCache && ( nID < 0 || nID == pCache->GetId() ) )
+ return pCache;
+
+ if ( pCache == NULL )
+ pCache = new ScDPTableDataCache( pDoc );
+
+ uno::Reference<sdbc::XRowSet> xRowSet ;
try
{
- pImpl->xRowSet = uno::Reference<sdbc::XRowSet>(
- comphelper::getProcessServiceFactory()->createInstance(
- rtl::OUString::createFromAscii( SC_SERVICE_ROWSET ) ),
- uno::UNO_QUERY);
- uno::Reference<beans::XPropertySet> xRowProp( pImpl->xRowSet, uno::UNO_QUERY );
+ xRowSet = uno::Reference<sdbc::XRowSet>(
+ comphelper::getProcessServiceFactory()->createInstance(
+ rtl::OUString::createFromAscii( SC_SERVICE_ROWSET ) ),
+ uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xRowProp( xRowSet, uno::UNO_QUERY );
DBG_ASSERT( xRowProp.is(), "can't get RowSet" );
if ( xRowProp.is() )
{
//
// set source parameters
//
-
uno::Any aAny;
-
- aAny <<= rtl::OUString( pImpl->aDesc.aDBName );
+ aAny <<= rtl::OUString( aDBName );
xRowProp->setPropertyValue(
- rtl::OUString::createFromAscii(SC_DBPROP_DATASOURCENAME), aAny );
+ rtl::OUString::createFromAscii(SC_DBPROP_DATASOURCENAME), aAny );
- aAny <<= rtl::OUString( pImpl->aDesc.aObject );
+ aAny <<= rtl::OUString( aObject );
xRowProp->setPropertyValue(
- rtl::OUString::createFromAscii(SC_DBPROP_COMMAND), aAny );
+ rtl::OUString::createFromAscii(SC_DBPROP_COMMAND), aAny );
aAny <<= nSdbType;
xRowProp->setPropertyValue(
- rtl::OUString::createFromAscii(SC_DBPROP_COMMANDTYPE), aAny );
+ rtl::OUString::createFromAscii(SC_DBPROP_COMMANDTYPE), aAny );
- uno::Reference<sdb::XCompletedExecution> xExecute( pImpl->xRowSet, uno::UNO_QUERY );
+ uno::Reference<sdb::XCompletedExecution> xExecute( xRowSet, uno::UNO_QUERY );
if ( xExecute.is() )
{
uno::Reference<task::XInteractionHandler> xHandler(
- comphelper::getProcessServiceFactory()->createInstance(
- rtl::OUString::createFromAscii( SC_SERVICE_INTHANDLER ) ),
- uno::UNO_QUERY);
+ comphelper::getProcessServiceFactory()->createInstance(
+ rtl::OUString::createFromAscii( SC_SERVICE_INTHANDLER ) ),
+ uno::UNO_QUERY);
xExecute->executeWithCompletion( xHandler );
}
else
- pImpl->xRowSet->execute();
-
- //
- // get column descriptions
- //
-
- pImpl->nColCount = 0;
- uno::Reference<sdbc::XResultSetMetaData> xMeta;
- uno::Reference<sdbc::XResultSetMetaDataSupplier> xMetaSupp( pImpl->xRowSet, uno::UNO_QUERY );
- if ( xMetaSupp.is() )
- xMeta = xMetaSupp->getMetaData();
- if ( xMeta.is() )
- pImpl->nColCount = xMeta->getColumnCount(); // this is the number of real columns
-
- uno::Reference<sdbc::XResultSet> xResSet( pImpl->xRowSet, uno::UNO_QUERY );
- if ( pImpl->nColCount > 0 && xResSet.is() )
- {
- pImpl->pTypes = new sal_Int32[pImpl->nColCount];
- for (long nCol=0; nCol<pImpl->nColCount; nCol++)
- pImpl->pTypes[nCol] = xMeta->getColumnType( nCol+1 );
-
- bSuccess = TRUE;
- }
+ xRowSet->execute();
+ SvNumberFormatter aFormat( pDoc->GetServiceManager(), ScGlobal::eLnge);
+ pCache->InitFromDataBase( xRowSet, *aFormat.GetNullDate() );
+ pCache->SetId( nID );
+ pDoc->AddDPObjectCache( pCache );
+ DBG_TRACE1("Create a cache id = %d \n", pCache->GetId() );
}
}
catch ( sdbc::SQLException& rError )
{
//! store error message
+ delete pCache;
+ pCache = NULL;
InfoBox aInfoBox( 0, String(rError.Message) );
aInfoBox.Execute();
}
catch ( uno::Exception& )
{
+ delete pCache;
+ pCache = NULL;
DBG_ERROR("Unexpected exception in database");
}
- if (!bSuccess)
- ::comphelper::disposeComponent( pImpl->xRowSet );
+ ::comphelper::disposeComponent( xRowSet );
+ return pCache;
+}
- return bSuccess;
+ScDPTableDataCache* ScImportSourceDesc::GetCache( ScDocument* pDoc, long nID ) const
+{
+ ScDPTableDataCache* pCache = pDoc->GetDPObjectCache( nID );
+ if ( NULL == pCache && pDoc )
+ pCache = GetExistDPObjectCache( pDoc);
+ if ( NULL == pCache )
+ pCache = CreateCache( pDoc , nID );
+ return pCache;
}
-long ScDatabaseDPData::GetColumnCount()
+long ScImportSourceDesc:: GetCacheId( ScDocument* pDoc, long nID ) const
+{
+ ScDPTableDataCache* pCache = GetCache( pDoc, nID);
+ if ( NULL == pCache )
+ return -1;
+ else
+ return pCache->GetId();
+}
+
+// -----------------------------------------------------------------------
+
+ScDatabaseDPData::ScDatabaseDPData(
+ ScDocument* pDoc,
+ const ScImportSourceDesc& rImport, long nCacheId /*=-1 */ ) :
+ ScDPTableData(pDoc, rImport.GetCacheId( pDoc, nCacheId) ),
+ aCacheTable( pDoc, rImport.GetCacheId( pDoc, nCacheId))
+{
+
+}
+
+ScDatabaseDPData::~ScDatabaseDPData()
+{
+}
+
+void ScDatabaseDPData::DisposeData()
{
- return pImpl->nColCount;
+ //! use OpenDatabase here?
+ aCacheTable.clear();
}
-const TypedScStrCollection& ScDatabaseDPData::GetColumnEntries(long nColumn)
+long ScDatabaseDPData::GetColumnCount()
{
CreateCacheTable();
- return pImpl->aCacheTable.getFieldEntries(nColumn);
+ return GetCacheTable().getColSize();
+}
+
+// End Comments
+
+void lcl_Reset( const uno::Reference<sdbc::XRowSet>& xRowSet )
+ throw(sdbc::SQLException, uno::RuntimeException)
+{
+ // isBeforeFirst / beforeFirst is not always available
+ //! query if it is allowed
+
+ xRowSet->execute(); // restart
}
String ScDatabaseDPData::getDimensionName(long nColumn)
@@ -244,17 +256,12 @@ String ScDatabaseDPData::getDimensionName(long nColumn)
}
CreateCacheTable();
- const String* pStr = pImpl->aCacheTable.getFieldName(nColumn);
- if (pStr)
- return *pStr;
-
- DBG_ERROR("getDimensionName: invalid dimension");
- return String();
+ return aCacheTable.getFieldName((SCCOL)nColumn);
}
BOOL ScDatabaseDPData::getIsDataLayoutDimension(long nColumn)
{
- return ( nColumn == pImpl->nColCount );
+ return ( nColumn == GetCacheTable().getColSize());
}
BOOL ScDatabaseDPData::IsDateDimension(long /* nDim */)
@@ -271,43 +278,39 @@ void ScDatabaseDPData::SetEmptyFlags( BOOL /* bIgnoreEmptyRows */, BOOL /* bRepe
void ScDatabaseDPData::CreateCacheTable()
{
- if (!pImpl->aCacheTable.empty())
+ if (!aCacheTable.empty())
return;
- // Get null date.
- if (!pImpl->pFormatter)
- pImpl->pFormatter = new SvNumberFormatter(pImpl->xServiceManager, ScGlobal::eLnge);
-
- pImpl->aCacheTable.fillTable(pImpl->xRowSet, *pImpl->pFormatter->GetNullDate());
+ aCacheTable.fillTable();
}
void ScDatabaseDPData::FilterCacheTable(const vector<ScDPCacheTable::Criterion>& rCriteria, const hash_set<sal_Int32>& rCatDims)
{
CreateCacheTable();
- pImpl->aCacheTable.filterByPageDimension(
+ aCacheTable.filterByPageDimension(
rCriteria, (IsRepeatIfEmpty() ? rCatDims : hash_set<sal_Int32>()));
}
void ScDatabaseDPData::GetDrillDownData(const vector<ScDPCacheTable::Criterion>& rCriteria, const hash_set<sal_Int32>& rCatDims, Sequence< Sequence<Any> >& rData)
{
CreateCacheTable();
- sal_Int32 nRowSize = pImpl->aCacheTable.getRowSize();
+ sal_Int32 nRowSize = aCacheTable.getRowSize();
if (!nRowSize)
return;
- pImpl->aCacheTable.filterTable(
+ aCacheTable.filterTable(
rCriteria, rData, IsRepeatIfEmpty() ? rCatDims : hash_set<sal_Int32>());
}
void ScDatabaseDPData::CalcResults(CalcInfo& rInfo, bool bAutoShow)
{
CreateCacheTable();
- CalcResultsFromCacheTable(pImpl->aCacheTable, rInfo, bAutoShow);
+ CalcResultsFromCacheTable( aCacheTable, rInfo, bAutoShow);
}
const ScDPCacheTable& ScDatabaseDPData::GetCacheTable() const
{
- return pImpl->aCacheTable;
+ return aCacheTable;
}
// -----------------------------------------------------------------------
diff --git a/sc/source/core/data/dpshttab.cxx b/sc/source/core/data/dpshttab.cxx
index c7e75f438ce1..6254e3861db5 100644..100755
--- a/sc/source/core/data/dpshttab.cxx
+++ b/sc/source/core/data/dpshttab.cxx
@@ -43,7 +43,10 @@
#include "dpcachetable.hxx"
#include "dpobject.hxx"
#include "globstr.hrc"
-
+// Wang Xu Ming -- 2009-8-17
+// DataPilot Migration - Cache&&Performance
+#include "dpglobal.hxx"
+// End Comments
#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
#include <vector>
@@ -58,55 +61,27 @@ using ::std::hash_set;
// -----------------------------------------------------------------------
-class ScSheetDPData_Impl
-{
-public:
- ScDocument* pDoc;
- ScRange aRange;
- ScQueryParam aQuery;
- BOOL* pSpecial; // to flag special handling of query parameters in ValidQuery.
- BOOL bIgnoreEmptyRows;
- BOOL bRepeatIfEmpty;
- BOOL* pDateDim;
- SCROW nNextRow; // for iterator, within range
-
- ScDPCacheTable aCacheTable;
-
- ScSheetDPData_Impl(ScDPCollection* p) :
- pSpecial(NULL),
- aCacheTable(p)
- {
- }
-};
-
-// -----------------------------------------------------------------------
-
-ScSheetDPData::ScSheetDPData( ScDocument* pD, const ScSheetSourceDesc& rDesc ) :
- ScDPTableData(pD)
+ScSheetDPData::ScSheetDPData( ScDocument* pD, const ScSheetSourceDesc& rDesc , long nCacheId) :
+ ScDPTableData(pD, rDesc.GetCacheId( pD, nCacheId) ), // DataPilot Migration - Cache&&Performance
+ aQuery ( rDesc.aQueryParam ),
+ pSpecial(NULL),
+ bIgnoreEmptyRows( FALSE ),
+ bRepeatIfEmpty(FALSE),
+ aCacheTable( pD, rDesc.GetCacheId( pD, nCacheId))
{
- pImpl = new ScSheetDPData_Impl(pD->GetDPCollection());
- pImpl->pDoc = pD;
- pImpl->aRange = rDesc.aSourceRange;
- pImpl->aQuery = rDesc.aQueryParam;
- pImpl->bIgnoreEmptyRows = FALSE;
- pImpl->bRepeatIfEmpty = FALSE;
- pImpl->pDateDim = NULL;
-
- pImpl->nNextRow = pImpl->aRange.aStart.Row() + 1;
-
- SCSIZE nEntryCount(pImpl->aQuery.GetEntryCount());
- pImpl->pSpecial = new BOOL[nEntryCount];
+ SCSIZE nEntryCount( aQuery.GetEntryCount());
+ pSpecial = new BOOL[nEntryCount];
for (SCSIZE j = 0; j < nEntryCount; ++j )
{
- ScQueryEntry& rEntry = pImpl->aQuery.GetEntry(j);
+ ScQueryEntry& rEntry = aQuery.GetEntry(j);
if (rEntry.bDoQuery)
{
- pImpl->pSpecial[j] = false;
+ pSpecial[j] = false;
if (!rEntry.bQueryByString)
{
if (*rEntry.pStr == EMPTY_STRING &&
((rEntry.nVal == SC_EMPTYFIELDS) || (rEntry.nVal == SC_NONEMPTYFIELDS)))
- pImpl->pSpecial[j] = true;
+ pSpecial[j] = true;
}
else
{
@@ -121,27 +96,24 @@ ScSheetDPData::ScSheetDPData( ScDocument* pD, const ScSheetSourceDesc& rDesc ) :
ScSheetDPData::~ScSheetDPData()
{
- delete[] pImpl->pDateDim;
- delete[] pImpl->pSpecial;
- delete pImpl;
+ delete[] pSpecial;
}
void ScSheetDPData::DisposeData()
{
- pImpl->aCacheTable.clear();
+ aCacheTable.clear();
}
long ScSheetDPData::GetColumnCount()
{
CreateCacheTable();
- return pImpl->aCacheTable.getColSize();
+ return aCacheTable.getColSize();
}
-const TypedScStrCollection& ScSheetDPData::GetColumnEntries(long nColumn)
+BOOL lcl_HasQuery( const ScQueryParam& rParam )
{
- DBG_ASSERT(nColumn>=0 && nColumn < pImpl->aCacheTable.getColSize(), "ScSheetDPData: wrong column");
- CreateCacheTable();
- return pImpl->aCacheTable.getFieldEntries(nColumn);
+ return rParam.GetEntryCount() > 0 &&
+ rParam.GetEntry(0).bDoQuery;
}
String ScSheetDPData::getDimensionName(long nColumn)
@@ -153,35 +125,21 @@ String ScSheetDPData::getDimensionName(long nColumn)
//return "Data";
return ScGlobal::GetRscString(STR_PIVOT_DATA);
}
- else if (nColumn >= pImpl->aCacheTable.getColSize())
+ else if (nColumn >= aCacheTable.getColSize())
{
DBG_ERROR("getDimensionName: invalid dimension");
return String();
}
else
{
- const String* pStr = pImpl->aCacheTable.getFieldName(nColumn);
- if (pStr)
- return *pStr;
- else return String();
+ return aCacheTable.getFieldName((SCCOL)nColumn);
}
}
-BOOL lcl_HasDateFormat( ScDocument* pDoc, const ScRange& rRange )
-{
- //! iterate formats in range?
-
- ScAddress aPos = rRange.aStart;
- aPos.SetRow( aPos.Row() + 1 ); // below title
- ULONG nFormat = pDoc->GetNumberFormat( aPos );
- SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
- return ( pFormatter->GetType(nFormat) & NUMBERFORMAT_DATE ) != 0;
-}
-
BOOL ScSheetDPData::IsDateDimension(long nDim)
{
CreateCacheTable();
- long nColCount = pImpl->aCacheTable.getColSize();
+ long nColCount = aCacheTable.getColSize();
if (getIsDataLayoutDimension(nDim))
{
return FALSE;
@@ -193,101 +151,165 @@ BOOL ScSheetDPData::IsDateDimension(long nDim)
}
else
{
- if (!pImpl->pDateDim)
- {
- pImpl->pDateDim = new BOOL[nColCount];
- ScRange aTestRange = pImpl->aRange;
- for (long i = 0; i < nColCount; ++i)
- {
- SCCOL nCol = (SCCOL)( pImpl->aRange.aStart.Col() + i );
- aTestRange.aStart.SetCol(nCol);
- aTestRange.aEnd.SetCol(nCol);
- pImpl->pDateDim[i] = lcl_HasDateFormat( pImpl->pDoc, aTestRange );
- }
- }
- return pImpl->pDateDim[nDim];
+ return aCacheTable.GetCache()->IsDateDimension( nDim);
}
}
-UINT32 ScSheetDPData::GetNumberFormat(long nDim)
+ULONG ScSheetDPData::GetNumberFormat(long nDim)
{
CreateCacheTable();
if (getIsDataLayoutDimension(nDim))
{
return 0;
}
- else if (nDim >= pImpl->aCacheTable.getColSize())
+ else if (nDim >= GetCacheTable().getColSize())
{
DBG_ERROR("GetNumberFormat: invalid dimension");
return 0;
}
else
{
- // is queried only once per dimension from ScDPOutput -> no need to cache
-
- ScAddress aPos = pImpl->aRange.aStart;
- aPos.SetCol( sal::static_int_cast<SCCOL>( aPos.Col() + nDim ) );
- aPos.SetRow( aPos.Row() + 1 ); // below title
- return pImpl->pDoc->GetNumberFormat( aPos );
+ return GetCacheTable().GetCache()->GetNumberFormat( nDim );
}
}
+UINT32 ScDPTableData::GetNumberFormatByIdx( NfIndexTableOffset eIdx )
+{
+ if( !mpDoc )
+ return 0;
+
+ if ( SvNumberFormatter* pFormatter = mpDoc->GetFormatTable() )
+ return pFormatter->GetFormatIndex( eIdx, LANGUAGE_SYSTEM );
+
+ return 0;
+}
BOOL ScSheetDPData::getIsDataLayoutDimension(long nColumn)
{
CreateCacheTable();
- return (nColumn == pImpl->aCacheTable.getColSize());
+ return (nColumn ==(long)( aCacheTable.getColSize()));
}
-void ScSheetDPData::SetEmptyFlags( BOOL bIgnoreEmptyRows, BOOL bRepeatIfEmpty )
+void ScSheetDPData::SetEmptyFlags( BOOL bIgnoreEmptyRowsP, BOOL bRepeatIfEmptyP )
{
- pImpl->bIgnoreEmptyRows = bIgnoreEmptyRows;
- pImpl->bRepeatIfEmpty = bRepeatIfEmpty;
+ bIgnoreEmptyRows = bIgnoreEmptyRowsP;
+ bRepeatIfEmpty = bRepeatIfEmptyP;
}
bool ScSheetDPData::IsRepeatIfEmpty()
{
- return pImpl->bRepeatIfEmpty;
+ return bRepeatIfEmpty;
}
void ScSheetDPData::CreateCacheTable()
{
// Scan and store the data from the source range.
- if (!pImpl->aCacheTable.empty())
+ if (!aCacheTable.empty())
// already cached.
return;
- pImpl->aCacheTable.fillTable(pImpl->pDoc, pImpl->aRange, pImpl->aQuery, pImpl->pSpecial,
- pImpl->bIgnoreEmptyRows);
+ aCacheTable.fillTable( aQuery, pSpecial,
+ bIgnoreEmptyRows, bRepeatIfEmpty );
}
void ScSheetDPData::FilterCacheTable(const vector<ScDPCacheTable::Criterion>& rCriteria, const hash_set<sal_Int32>& rCatDims)
{
CreateCacheTable();
- pImpl->aCacheTable.filterByPageDimension(
+ aCacheTable.filterByPageDimension(
rCriteria, (IsRepeatIfEmpty() ? rCatDims : hash_set<sal_Int32>()));
}
void ScSheetDPData::GetDrillDownData(const vector<ScDPCacheTable::Criterion>& rCriteria, const hash_set<sal_Int32>& rCatDims, Sequence< Sequence<Any> >& rData)
{
CreateCacheTable();
- sal_Int32 nRowSize = pImpl->aCacheTable.getRowSize();
+ sal_Int32 nRowSize = aCacheTable.getRowSize();
if (!nRowSize)
return;
- pImpl->aCacheTable.filterTable(
+ aCacheTable.filterTable(
rCriteria, rData, IsRepeatIfEmpty() ? rCatDims : hash_set<sal_Int32>());
}
void ScSheetDPData::CalcResults(CalcInfo& rInfo, bool bAutoShow)
{
CreateCacheTable();
- CalcResultsFromCacheTable(pImpl->aCacheTable, rInfo, bAutoShow);
+ CalcResultsFromCacheTable(aCacheTable, rInfo, bAutoShow);
}
const ScDPCacheTable& ScSheetDPData::GetCacheTable() const
{
- return pImpl->aCacheTable;
+ return aCacheTable;
+}
+
+
+// Wang Xu Ming -- 2009-8-5
+// DataPilot Migration - Cache&&Performance
+ScDPTableDataCache* ScSheetSourceDesc::CreateCache( ScDocument* pDoc , long nID ) const
+{
+ if ( pDoc )
+ {
+ ScDPTableDataCache* pCache = GetExistDPObjectCache( pDoc );
+ if ( pCache && ( nID < 0 || nID == pCache->GetId() ) )
+ return pCache;
+
+ ULONG nErrId = CheckValidate( pDoc );
+ if ( !nErrId )
+ {
+ pCache = new ScDPTableDataCache( pDoc );
+
+ pCache->InitFromDoc( pDoc, aSourceRange );
+ pCache->SetId( nID );
+ pDoc->AddDPObjectCache( pCache );
+
+ DBG_TRACE1("Create a cache id = %d \n", pCache->GetId() );
+ }
+ else
+ DBG_ERROR( "\n Error Create Cache" );
+ return pCache;
+ }
+ return NULL;
+}
+
+ScDPTableDataCache* ScSheetSourceDesc::GetExistDPObjectCache ( ScDocument* pDoc ) const
+{
+ return pDoc->GetUsedDPObjectCache( aSourceRange );
+}
+ScDPTableDataCache* ScSheetSourceDesc::GetCache( ScDocument* pDoc, long nID ) const
+{
+ ScDPTableDataCache* pCache = pDoc->GetDPObjectCache( nID );
+ if ( NULL == pCache && pDoc )
+ pCache = GetExistDPObjectCache( pDoc );
+ if ( NULL == pCache )
+ pCache = CreateCache( pDoc );
+ return pCache;
+}
+
+long ScSheetSourceDesc:: GetCacheId( ScDocument* pDoc, long nID ) const
+{
+ ScDPTableDataCache* pCache = GetCache( pDoc, nID);
+ if ( NULL == pCache )
+ return -1;
+ else
+ return pCache->GetId();
+}
+
+ULONG ScSheetSourceDesc::CheckValidate( ScDocument* pDoc ) const
+{
+ ScRange aSrcRange( aSourceRange);
+ if ( !pDoc )
+ return STR_ERR_DATAPILOTSOURCE;
+ for(USHORT i= aSrcRange.aStart.Col();i <= aSrcRange.aEnd.Col();i++)
+ {
+ if ( pDoc->IsBlockEmpty( aSrcRange.aStart.Tab(),
+ i, aSrcRange.aStart.Row(),i, aSrcRange.aStart.Row()))
+ return STR_PIVOT_FIRSTROWEMPTYERR;
+ }
+ if( pDoc->IsBlockEmpty( aSrcRange.aStart.Tab(), aSrcRange.aStart.Col(), aSrcRange.aStart.Row()+1, aSrcRange.aEnd.Col(), aSrcRange.aEnd.Row() ) )
+ {
+ return STR_PIVOT_ONLYONEROWERR;
+ }
+ return 0;
}
+// End Comments
// -----------------------------------------------------------------------
diff --git a/sc/source/core/data/dptabdat.cxx b/sc/source/core/data/dptabdat.cxx
index 530f1c44123f..cff18ef925d9 100644..100755
--- a/sc/source/core/data/dptabdat.cxx
+++ b/sc/source/core/data/dptabdat.cxx
@@ -52,69 +52,6 @@ using namespace ::com::sun::star;
using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::Any;
using ::std::vector;
-using ::std::set;
-using ::std::hash_map;
-
-// -----------------------------------------------------------------------
-
-BOOL ScDPItemData::IsCaseInsEqual( const ScDPItemData& r ) const
-{
- //! pass Transliteration?
- //! inline?
- return bHasValue ? ( r.bHasValue && rtl::math::approxEqual( fValue, r.fValue ) ) :
- ( !r.bHasValue &&
- ScGlobal::GetpTransliteration()->isEqual( aString, r.aString ) );
-}
-
-size_t ScDPItemData::Hash() const
-{
- if ( bHasValue )
- return (size_t) rtl::math::approxFloor( fValue );
- else
- // If we do unicode safe case insensitive hash we can drop
- // ScDPItemData::operator== and use ::IsCasInsEqual
- return rtl_ustr_hashCode_WithLength( aString.GetBuffer(), aString.Len() );
-}
-
-BOOL ScDPItemData::operator==( const ScDPItemData& r ) const
-{
- if ( bHasValue )
- {
- if ( r.bHasValue )
- return rtl::math::approxEqual( fValue, r.fValue );
- else
- return FALSE;
- }
- else if ( r.bHasValue )
- return FALSE;
- else
- // need exact equality until we have a safe case insensitive string hash
- return aString == r.aString;
-}
-
-sal_Int32 ScDPItemData::Compare( const ScDPItemData& rA,
- const ScDPItemData& rB )
-{
- if ( rA.bHasValue )
- {
- if ( rB.bHasValue )
- {
- if ( rtl::math::approxEqual( rA.fValue, rB.fValue ) )
- return 0;
- else if ( rA.fValue < rB.fValue )
- return -1;
- else
- return 1;
- }
- else
- return -1; // values first
- }
- else if ( rB.bHasValue )
- return 1; // values first
- else
- return ScGlobal::GetCollator()->compareString( rA.aString, rB.aString );
-}
-
// ---------------------------------------------------------------------------
ScDPTableData::CalcInfo::CalcInfo() :
@@ -124,8 +61,9 @@ ScDPTableData::CalcInfo::CalcInfo() :
// ---------------------------------------------------------------------------
-ScDPTableData::ScDPTableData(ScDocument* pDoc) :
- mrSharedString(pDoc->GetDPCollection()->GetSharedString())
+ScDPTableData::ScDPTableData(ScDocument* pDoc, long nCacheId ) :
+ mnCacheId( nCacheId ),
+ mpDoc ( pDoc )
{
nLastDateVal = nLastHier = nLastLevel = nLastRet = -1; // invalid
@@ -186,7 +124,7 @@ bool ScDPTableData::IsRepeatIfEmpty()
return false;
}
-UINT32 ScDPTableData::GetNumberFormat(long)
+ULONG ScDPTableData::GetNumberFormat(long)
{
return 0; // default format
}
@@ -219,12 +157,6 @@ BOOL ScDPTableData::HasCommonElement( const ScDPItemData&, long,
DBG_ERROR("HasCommonElement shouldn't be called for non-group data");
return FALSE;
}
-
-ScSimpleSharedString& ScDPTableData::GetSharedString()
-{
- return mrSharedString;
-}
-
void ScDPTableData::FillRowDataFromCacheTable(sal_Int32 nRow, const ScDPCacheTable& rCacheTable,
const CalcInfo& rInfo, CalcRowData& rData)
{
@@ -243,25 +175,28 @@ void ScDPTableData::FillRowDataFromCacheTable(sal_Int32 nRow, const ScDPCacheTab
long nDim = rInfo.aDataSrcCols[i];
rData.aValues.push_back( ScDPValueData() );
ScDPValueData& rVal = rData.aValues.back();
- const ScDPCacheCell* pCell = rCacheTable.getCell(
- static_cast<SCCOL>(nDim), static_cast<SCROW>(nRow), false);
- if (pCell)
- {
- rVal.fValue = pCell->mbNumeric ? pCell->mfValue : 0.0;
- rVal.nType = pCell->mnType;
- }
- else
- rVal.Set(0.0, SC_VALTYPE_EMPTY);
+ rCacheTable.getValue( rVal, static_cast<SCCOL>(nDim), static_cast<SCROW>(nRow), false);
}
}
void ScDPTableData::ProcessRowData(CalcInfo& rInfo, CalcRowData& rData, bool bAutoShow)
{
+ // Wang Xu Ming -- 2009-6-16
+ // DataPilot Migration
if (!bAutoShow)
{
- rInfo.pColRoot->LateInitFrom(rInfo.aColDims, rInfo.aColLevels, rData.aColData, 0, *rInfo.pInitState);
- rInfo.pRowRoot->LateInitFrom(rInfo.aRowDims, rInfo.aRowLevels, rData.aRowData, 0, *rInfo.pInitState);
+ LateInitParams aColParams( rInfo.aColDims, rInfo.aColLevels, FALSE );
+ LateInitParams aRowParams ( rInfo.aRowDims, rInfo.aRowLevels, TRUE );
+ // root always init child
+ aColParams.SetInitChild( TRUE );
+ aColParams.SetInitAllChildren( FALSE);
+ aRowParams.SetInitChild( TRUE );
+ aRowParams.SetInitAllChildren( FALSE);
+
+ rInfo.pColRoot->LateInitFrom( aColParams, rData.aColData,0, *rInfo.pInitState);
+ rInfo.pRowRoot->LateInitFrom( aRowParams, rData.aRowData, 0, *rInfo.pInitState);
}
+ // End Comments
if ( ( !rInfo.pColRoot->GetChildDimension() || rInfo.pColRoot->GetChildDimension()->IsValidEntry(rData.aColData) ) &&
( !rInfo.pRowRoot->GetChildDimension() || rInfo.pRowRoot->GetChildDimension()->IsValidEntry(rData.aRowData) ) )
@@ -269,8 +204,11 @@ void ScDPTableData::ProcessRowData(CalcInfo& rInfo, CalcRowData& rData, bool bAu
//! single process method with ColMembers, RowMembers and data !!!
if (rInfo.pColRoot->GetChildDimension())
{
- vector<ScDPItemData> aEmptyData;
+// Wang Xu Ming -- 2009-6-10
+// DataPilot Migration
+ vector</*ScDPItemData*/ SCROW > aEmptyData;
rInfo.pColRoot->GetChildDimension()->ProcessData(rData.aColData, NULL, aEmptyData, rData.aValues);
+// End Comments
}
rInfo.pRowRoot->ProcessData(rData.aRowData, rInfo.pColRoot->GetChildDimension(),
@@ -292,42 +230,94 @@ void ScDPTableData::CalcResultsFromCacheTable(const ScDPCacheTable& rCacheTable,
}
}
+// Wang Xu Ming -- 2009-6-10
+// DataPilot Migration
void ScDPTableData::GetItemData(const ScDPCacheTable& rCacheTable, sal_Int32 nRow,
- const vector<long>& rDims, vector<ScDPItemData>& rItemData)
+ const vector<long>& rDims, vector< SCROW/*ScDPItemData*/>& rItemData)
+// End Comments
{
sal_Int32 nDimSize = rDims.size();
for (sal_Int32 i = 0; i < nDimSize; ++i)
{
long nDim = rDims[i];
- rItemData.push_back( ScDPItemData() );
- ScDPItemData& rData = rItemData.back();
+
if (getIsDataLayoutDimension(nDim))
{
- rData.SetString(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("x")));
+ rItemData.push_back( -1 );
continue;
}
- const ScDPCacheCell* pCell = rCacheTable.getCell(
- static_cast<SCCOL>(nDim), static_cast<SCROW>(nRow), IsRepeatIfEmpty());
- if (!pCell || pCell->mnType == SC_VALTYPE_EMPTY)
- continue;
+ nDim = GetSourceDim( nDim );
+ if ( nDim >= rCacheTable.GetCache()->GetColumnCount() )
+ continue;
- const String* pString = GetSharedString().getString(pCell->mnStrId);
- if (!pString)
- continue;
+ SCROW nId= rCacheTable.GetCache()->GetItemDataId( static_cast<SCCOL>(nDim), static_cast<SCROW>(nRow), IsRepeatIfEmpty());
+ rItemData.push_back( nId );
- rData.aString = *pString;
- rData.bHasValue = false;
- if (pCell->mbNumeric)
- {
- rData.bHasValue = true;
- rData.fValue = pCell->mfValue;
- }
}
}
// -----------------------------------------------------------------------
+// Wang Xu Ming -- 2009-6-8
+// DataPilot Migration
+long ScDPTableData::GetMembersCount( long nDim )
+{
+ if ( nDim > MAXCOL )
+ return 0;
+ return GetCacheTable().getFieldEntries( nDim ).size();
+}
+
+long ScDPTableData::GetCacheId() const
+{
+ return mnCacheId;
+}
+
+const ScDPItemData* ScDPTableData::GetMemberByIndex( long nDim, long nIndex )
+{
+ if ( nIndex >= GetMembersCount( nDim ) )
+ return NULL;
+
+ const ::std::vector<SCROW>& nMembers = GetCacheTable().getFieldEntries( nDim );
+
+ return GetCacheTable().GetCache()->GetItemDataById( (SCCOL) nDim, (SCROW)nMembers[nIndex] );
+}
+
+const ScDPItemData* ScDPTableData::GetMemberById( long nDim, long nId)
+{
+
+ return GetCacheTable().GetCache()->GetItemDataById( (SCCOL) nDim, (SCROW)nId);
+}
+SCROW ScDPTableData::GetIdOfItemData( long nDim, const ScDPItemData& rData )
+{
+ return GetCacheTable().GetCache()->GetIdByItemData((SCCOL) nDim, rData );
+ }
+const std::vector< SCROW >& ScDPTableData::GetColumnEntries( long nColumn )
+{
+ return GetCacheTable().getFieldEntries( nColumn );
+}
+long ScDPTableData::GetSourceDim( long nDim )
+{
+ return nDim;
+
+}
+
+ long ScDPTableData::Compare( long nDim, long nDataId1, long nDataId2)
+{
+ if ( getIsDataLayoutDimension(nDim) )
+ return 0;
+
+ long n1 = GetCacheTable().GetCache()->GetOrder( nDim, nDataId1);
+ long n2 = GetCacheTable().GetCache()->GetOrder( nDim, nDataId2);
+ if ( n1 > n2 )
+ return 1;
+ else if ( n1 == n2 )
+ return 0;
+ else
+ return -1;
+}
+// End Comments
+// -----------------------------------------------------------------------
diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx
new file mode 100755
index 000000000000..42090e5203a2
--- /dev/null
+++ b/sc/source/core/data/dptablecache.cxx
@@ -0,0 +1,1093 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright IBM Corporation 2009.
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: dptablecache.cxx,v $
+ * $Revision: 1.0 $
+ *
+ * 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_sc.hxx"
+// INCLUDE ---------------------------------------------------------------
+#include "dptablecache.hxx"
+#include "document.hxx"
+#include "cell.hxx"
+#include "globstr.hrc"
+
+#include <rtl/math.hxx>
+#include "queryparam.hxx"
+#include "dpglobal.hxx"
+
+#include "docoptio.hxx" //for ValidQuery
+#include <unotools/textsearch.hxx> //for ValidQuery
+
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+const double D_TIMEFACTOR = 86400.0;
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::uno::Exception;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::UNO_QUERY;
+using ::com::sun::star::uno::UNO_QUERY_THROW;
+// -----------------------------------------------------------------------
+namespace
+{
+ BOOL lcl_isDate( ULONG nNumType )
+ {
+ return ( (nNumType & NUMBERFORMAT_DATE) != 0 )? 1:0 ;
+ }
+
+ BOOL lcl_Search( const std::vector<ScDPItemData*>& list, const ::std::vector<SCROW>& rOrder, const ScDPItemData& item, SCROW& rIndex)
+ {
+ rIndex = list.size();
+ BOOL bFound = FALSE;
+ SCROW nLo = 0;
+ SCROW nHi = list.size() - 1;
+ SCROW nIndex;
+ long nCompare;
+ while (nLo <= nHi)
+ {
+ nIndex = (nLo + nHi) / 2;
+ nCompare = ScDPItemData::Compare( *list[rOrder[nIndex]], item );
+ if (nCompare < 0)
+ nLo = nIndex + 1;
+ else
+ {
+ nHi = nIndex - 1;
+ if (nCompare == 0)
+ {
+ bFound = TRUE;
+ nLo = nIndex;
+ }
+ }
+ }
+ rIndex = nLo;
+ return bFound;
+ }
+
+ ScDPItemData* lcl_GetItemValue(const Reference<sdbc::XRow>& xRow, sal_Int32 nType, long nCol,
+ const Date& rNullDate )
+ {
+ short nNumType = NUMBERFORMAT_NUMBER;
+ try
+ {
+ String rStr = xRow->getString(nCol);
+ double fValue = 0.0;
+ switch (nType)
+ {
+ case sdbc::DataType::BIT:
+ case sdbc::DataType::BOOLEAN:
+ {
+ nNumType = NUMBERFORMAT_LOGICAL;
+ fValue = xRow->getBoolean(nCol) ? 1 : 0;
+ return new ScDPItemData( rStr, fValue,TRUE,nNumType);
+ }
+ //break;
+
+ case sdbc::DataType::TINYINT:
+ case sdbc::DataType::SMALLINT:
+ case sdbc::DataType::INTEGER:
+ case sdbc::DataType::BIGINT:
+ case sdbc::DataType::FLOAT:
+ case sdbc::DataType::REAL:
+ case sdbc::DataType::DOUBLE:
+ case sdbc::DataType::NUMERIC:
+ case sdbc::DataType::DECIMAL:
+ {
+ //! do the conversion here?
+ fValue = xRow->getDouble(nCol);
+ return new ScDPItemData( rStr, fValue,TRUE);
+ }
+ //break;
+
+ case sdbc::DataType::DATE:
+ {
+ nNumType = NUMBERFORMAT_DATE;
+
+ util::Date aDate = xRow->getDate(nCol);
+ fValue = Date(aDate.Day, aDate.Month, aDate.Year) - rNullDate;
+ return new ScDPItemData( rStr, fValue, TRUE, nNumType );
+ }
+ //break;
+
+ case sdbc::DataType::TIME:
+ {
+ nNumType = NUMBERFORMAT_TIME;
+
+ util::Time aTime = xRow->getTime(nCol);
+ fValue = ( aTime.Hours * 3600 + aTime.Minutes * 60 +
+ aTime.Seconds + aTime.HundredthSeconds / 100.0 ) / D_TIMEFACTOR;
+ return new ScDPItemData( rStr,fValue, TRUE, nNumType );
+ }
+ //break;
+
+ case sdbc::DataType::TIMESTAMP:
+ {
+ nNumType = NUMBERFORMAT_DATETIME;
+
+ util::DateTime aStamp = xRow->getTimestamp(nCol);
+ fValue = ( Date( aStamp.Day, aStamp.Month, aStamp.Year ) - rNullDate ) +
+ ( aStamp.Hours * 3600 + aStamp.Minutes * 60 +
+ aStamp.Seconds + aStamp.HundredthSeconds / 100.0 ) / D_TIMEFACTOR;
+ return new ScDPItemData( rStr,fValue, TRUE, nNumType );
+ }
+ //break;
+ case sdbc::DataType::CHAR:
+ case sdbc::DataType::VARCHAR:
+ case sdbc::DataType::LONGVARCHAR:
+ case sdbc::DataType::SQLNULL:
+ case sdbc::DataType::BINARY:
+ case sdbc::DataType::VARBINARY:
+ case sdbc::DataType::LONGVARBINARY:
+ default:
+ return new ScDPItemData ( rStr );
+ //break;
+ }
+ }
+ catch (uno::Exception&)
+ {
+ }
+ catch ( ... )
+ {
+
+ }
+ return NULL;
+ }
+}
+// Wang Xu Ming -- 12/23/2008
+//Refactor cache data
+ScDPItemData::ScDPItemData( const String& rS, double fV/* = 0.0*/, BOOL bHV/* = FALSE*/, const ULONG nNumFormatP /*= 0*/ , BOOL bData/* = TRUE*/) :
+nNumFormat( nNumFormatP ), aString(rS), fValue(fV),
+mbFlag( (MK_VAL*!!bHV) | (MK_DATA*!!bData) | (MK_ERR*!!FALSE) | (MK_DATE*!!lcl_isDate( nNumFormat ) ) )
+{
+}
+
+ScDPItemData::ScDPItemData( ScDocument* pDoc, SCROW nRow, USHORT nCol, USHORT nDocTab ):
+ nNumFormat( 0 ), fValue(0.0), mbFlag( 0 )
+{
+ String aDocStr;
+ pDoc->GetString( nCol, nRow, nDocTab, aDocStr );
+
+ SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+
+ ScAddress aPos( nCol, nRow, nDocTab );
+ ScBaseCell* pCell = pDoc->GetCell( aPos );
+
+ if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA && ((ScFormulaCell*)pCell)->GetErrCode() )
+ SetString ( aDocStr ); //[SODC_19347] add liyi
+ //bErr = TRUE; //[SODC_19347] del liyi
+ else if ( pDoc->HasValueData( nCol, nRow, nDocTab ) )
+ {
+ double fVal = pDoc->GetValue(ScAddress(nCol, nRow, nDocTab));
+ ULONG nFormat = NUMBERFORMAT_NUMBER;
+ if ( pFormatter )
+ nFormat = pFormatter->GetType( pDoc->GetNumberFormat( ScAddress( nCol, nRow, nDocTab ) ) );
+ aString = aDocStr;
+ fValue = fVal;
+ mbFlag |= MK_VAL|MK_DATA;
+ nNumFormat = pDoc->GetNumberFormat( ScAddress( nCol, nRow, nDocTab ) );
+ lcl_isDate( nFormat ) ? ( mbFlag |= MK_DATE ) : (mbFlag &= ~MK_DATE);
+ }
+ else if ( pDoc->HasData( nCol,nRow, nDocTab ) )
+ SetString ( aDocStr );
+}
+// End Comments
+
+BOOL ScDPItemData::IsCaseInsEqual( const ScDPItemData& r ) const
+{ //TODO: indified Date?
+ //! pass Transliteration?
+ //! inline?
+ return IsValue() ? ( r.IsValue() && rtl::math::approxEqual( fValue, r.fValue ) ) :
+ ( !r.IsValue() &&
+ ScGlobal::GetpTransliteration()->isEqual( aString, r.aString ) );
+}
+
+size_t ScDPItemData::Hash() const
+{
+ if ( IsValue() )
+ return (size_t) rtl::math::approxFloor( fValue );
+ else
+ // If we do unicode safe case insensitive hash we can drop
+ // ScDPItemData::operator== and use ::IsCasInsEqual
+ return rtl_ustr_hashCode_WithLength( aString.GetBuffer(), aString.Len() );
+}
+
+BOOL ScDPItemData::operator==( const ScDPItemData& r ) const
+{
+ if ( IsValue() )
+ {
+ if( HasDatePart() != r.HasDatePart() || HasDatePart() && mnDatePart != r.mnDatePart )
+ return FALSE;
+
+// Wang Xu Ming -- 1/9/2009
+// Add Data Cache Support.
+// Identify date
+ if ( IsDate() != r.IsDate() )
+ return FALSE;
+ else
+ if ( r.IsValue() )
+ return rtl::math::approxEqual( fValue, r.fValue );
+ else
+ return FALSE;
+// End Comments
+ }
+ else if ( r.IsValue() )
+ return FALSE;
+ else
+ // need exact equality until we have a safe case insensitive string hash
+ return aString == r.aString;
+}
+
+sal_Int32 ScDPItemData::Compare( const ScDPItemData& rA,
+ const ScDPItemData& rB )
+{
+ if ( rA.IsValue() )
+ {
+ if ( rB.IsValue() )
+ {
+ if ( rtl::math::approxEqual( rA.fValue, rB.fValue ) )
+ {
+// Wang Xu Ming -- 1/9/2009
+// Add Data Cache Support.
+// Date > number
+ if ( rA.IsDate() == rB.IsDate() )
+ return 0;
+ else
+ return rA.IsDate() ? 1: -1;
+// End Comments
+ }
+ else if ( rA.fValue < rB.fValue )
+ return -1;
+ else
+ return 1;
+ }
+ else
+ return -1; // values first
+ }
+ else if ( rB.IsValue() )
+ return 1; // values first
+ else
+ return ScGlobal::GetCollator()->compareString( rA.aString, rB.aString );
+}
+//
+//Wang Xu Ming SODC_17561
+#ifdef DEBUG
+void ScDPItemData::dump() const
+{
+ DBG_TRACE1( "Numberformat= %o", nNumFormat );
+ DBG_TRACESTR(aString );
+ DBG_TRACE1( "fValue= %f", fValue );
+ DBG_TRACE1( "bHasValue= %d", bHasValue ? 1:0);
+}
+#endif
+//End
+
+TypedStrData* ScDPItemData::CreateTypeString( )
+{
+ if ( IsValue() )
+ return new TypedStrData( aString, fValue, SC_STRTYPE_VALUE );
+ else
+ return new TypedStrData( aString );
+}
+
+sal_uInt8 ScDPItemData::GetType() const
+{
+
+ if ( IsHasErr() )
+ return SC_VALTYPE_ERROR;
+ else if ( !IsHasData() )
+ return SC_VALTYPE_EMPTY;
+ else if ( IsValue())
+ return SC_VALTYPE_VALUE;
+ else
+ return SC_VALTYPE_STRING;
+
+}
+
+BOOL ScDPItemData::IsHasData() const
+{
+ return !!(mbFlag&MK_DATA);
+}
+
+BOOL ScDPItemData::IsHasErr() const
+{
+ return !!(mbFlag&MK_ERR);
+}
+
+BOOL ScDPItemData::IsValue() const
+{
+ return !!(mbFlag&MK_VAL);
+}
+
+String ScDPItemData::GetString() const
+{
+
+ return aString;
+}
+
+double ScDPItemData::GetValue() const
+{
+ return fValue;
+}
+ULONG ScDPItemData::GetNumFormat() const
+{
+ return nNumFormat;
+}
+
+BOOL ScDPItemData::HasStringData() const
+
+{
+ return IsHasData()&&!IsHasErr()&&!IsValue();
+}
+BOOL ScDPItemData::IsDate() const
+{
+ return !!(mbFlag&MK_DATE);
+}
+BOOL ScDPItemData::HasDatePart() const
+{
+ return !!(mbFlag&MK_DATEPART);
+}
+void ScDPItemData::SetDate( BOOL b )
+{
+ b ? ( mbFlag |= MK_DATE ) : ( mbFlag &= ~MK_DATE );
+}
+
+// -----------------------------------------------------------------------
+//class ScDPTableDataCache
+//To cache the pivot table data source
+
+BOOL ScDPTableDataCache::operator== ( const ScDPTableDataCache& r ) const
+{
+ if ( GetColumnCount() == r.GetColumnCount() )
+ {
+ for ( SCCOL i = 0 ; i < GetColumnCount(); i++ )
+ { //check dim names
+ if ( GetDimensionName( i ) != r.GetDimensionName( i ) )
+ return FALSE;
+ //check rows count
+ if ( GetRowCount() != r.GetRowCount() )
+ return FALSE;
+ //check dim member values
+ size_t nMembersCount = GetDimMemberValues( i ).size();
+ if ( GetDimMemberValues( i ).size() == r. GetDimMemberValues( i ).size() )
+ {
+ for ( size_t j = 0; j < nMembersCount; j++ )
+ {
+ if ( *( GetDimMemberValues( i )[j] ) == *( r.GetDimMemberValues( i )[j] ) )
+ continue;
+ else
+ return FALSE;
+ }
+ }
+ else
+ return FALSE;
+ //check source table index
+ for ( SCROW k=0 ; k < GetRowCount(); k ++ )
+ {
+ if ( GetItemDataId( i, k, FALSE ) == r.GetItemDataId( i,k,FALSE) )
+ continue;
+ else
+ return FALSE;
+ }
+ }
+ }
+ return TRUE;
+}
+
+ScDPTableDataCache::ScDPTableDataCache( ScDocument* pDoc ) :
+mpDoc( pDoc ),
+mnColumnCount ( 0 ),
+mpTableDataValues ( NULL ),
+mpSourceData ( NULL ),
+mpGlobalOrder( NULL ),
+mpIndexOrder( NULL)
+{
+ mnID = -1;
+}
+
+ScDPTableDataCache::~ScDPTableDataCache()
+{
+ if ( IsValid() )
+ {
+// Wang Xu Ming -- 2/17/2009
+// Performance issue
+ USHORT nCol;
+ for ( nCol=0; nCol < GetColumnCount() ; nCol++ )
+ {
+ for ( ULONG row = 0 ; row < mpTableDataValues[nCol].size(); row++ )
+ delete mpTableDataValues[nCol][row];
+ }
+ for ( nCol =0; nCol < mrLabelNames.size(); nCol++ )
+ delete mrLabelNames[nCol];
+// End Comments
+
+ mnColumnCount = 0;
+ delete [] mpTableDataValues;
+ mpTableDataValues = NULL;
+ delete [] mpSourceData;
+ mpSourceData = NULL;
+ delete [] mpGlobalOrder;
+ mpGlobalOrder = NULL;
+ delete [] mpIndexOrder;
+ mpIndexOrder = NULL;
+ }
+}
+
+// -----------------------------------------------------------------------
+void ScDPTableDataCache::AddRow( ScDPItemData* pRow, USHORT nCount )
+{
+ DBG_ASSERT( pRow , " empty pointer" );
+ if ( !mrLabelNames.size() )
+ {
+ mnColumnCount= nCount;
+ mpTableDataValues = new std::vector<ScDPItemData*>[ mnColumnCount ];
+ mpSourceData = new std::vector<SCROW>[ mnColumnCount ];
+ mpGlobalOrder = new std::vector<SCROW>[ mnColumnCount ];
+ mpIndexOrder = new std::vector<SCROW>[ mnColumnCount ];
+
+ for ( USHORT i = 0; i < nCount ; i ++ )
+ AddLabel( new ScDPItemData( pRow[i] ) );
+ }
+ else
+ {
+ for ( USHORT i = 0; i < nCount && i < mnColumnCount; i ++ )
+ AddData( i, new ScDPItemData( pRow[i] ) );
+ }
+}
+
+// -----------------------------------------------------------------------
+bool ScDPTableDataCache::IsValid() const
+{ //TODO: continue check valid
+ return mpTableDataValues!=NULL && mpSourceData!= NULL && mnColumnCount>0;
+}
+
+// -----------------------------------------------------------------------
+bool ScDPTableDataCache::InitFromDoc( ScDocument* pDoc, const ScRange& rRange )
+{
+ //
+ SCROW nStartRow = rRange.aStart.Row(); // start of data
+ SCROW nEndRow = rRange.aEnd.Row();
+ USHORT nStartCol = rRange.aStart.Col();
+ USHORT nEndCol = rRange.aEnd.Col();
+ USHORT nDocTab = rRange.aStart.Tab();
+
+ //init
+ long nOldColumCount = mnColumnCount;
+ mnColumnCount = nEndCol - nStartCol + 1;
+ if ( IsValid() )
+ {
+ for ( USHORT nCol=0; nCol < nOldColumCount ; nCol++ )
+ {
+ for ( ULONG row = 0 ; row < mpTableDataValues[nCol].size(); row++ )
+ delete mpTableDataValues[nCol][row];
+ delete mrLabelNames[nCol];
+ }
+ delete [] mpTableDataValues;
+ delete [] mpSourceData;
+ delete [] mpGlobalOrder;
+ delete [] mpIndexOrder;
+ mrLabelNames.clear();
+ }
+
+ mpTableDataValues = new std::vector<ScDPItemData*>[ mnColumnCount ];
+ mpSourceData = new std::vector<SCROW>[ mnColumnCount ];
+ mpGlobalOrder = new std::vector<SCROW>[ mnColumnCount ];
+ mpIndexOrder = new std::vector<SCROW>[ mnColumnCount ];
+ //check valid
+ for ( SCROW nRow = nStartRow; nRow <= nEndRow; nRow ++ )
+ {
+ for ( USHORT nCol = nStartCol; nCol <= nEndCol; nCol++ )
+ {
+ if ( nRow == nStartRow )
+ AddLabel( new ScDPItemData( pDoc, nRow, nCol, nDocTab ) );
+ else
+ AddData( nCol - nStartCol, new ScDPItemData( pDoc, nRow, nCol, nDocTab ) );
+ }
+ }
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+bool ScDPTableDataCache::InitFromDataBase (const Reference<sdbc::XRowSet>& xRowSet, const Date& rNullDate)
+{
+ if (!xRowSet.is())
+ // Dont' even waste time to go any further.
+ return false;
+ try
+ {
+ Reference<sdbc::XResultSetMetaDataSupplier> xMetaSupp(xRowSet, UNO_QUERY_THROW);
+ Reference<sdbc::XResultSetMetaData> xMeta = xMetaSupp->getMetaData();
+ if (!xMeta.is())
+ return false;
+
+ long nOldColumCount = mnColumnCount;
+ mnColumnCount = xMeta->getColumnCount();
+ if ( IsValid() )
+ {
+ for ( USHORT nCol=0; nCol < nOldColumCount ; nCol++ )
+ {
+ for ( ULONG row = 0 ; row < mpTableDataValues[nCol].size(); row++ )
+ delete mpTableDataValues[nCol][row];
+ delete mrLabelNames[nCol];
+ }
+ delete [] mpTableDataValues;
+ delete [] mpSourceData;
+ delete [] mpGlobalOrder;
+ delete [] mpIndexOrder;
+ mrLabelNames.clear();
+ }
+ // Get column titles and types.
+ mrLabelNames.reserve(mnColumnCount);
+ mpTableDataValues = new std::vector<ScDPItemData*>[ mnColumnCount ];
+ mpSourceData = new std::vector<SCROW>[ mnColumnCount ];
+ mpGlobalOrder = new std::vector<SCROW>[ mnColumnCount ];
+ mpIndexOrder = new std::vector<SCROW>[ mnColumnCount ];
+
+ std::vector<sal_Int32> aColTypes(mnColumnCount);
+
+ for (sal_Int32 nCol = 0; nCol < mnColumnCount; ++nCol)
+ {
+ String aColTitle = xMeta->getColumnLabel(nCol+1);
+ aColTypes[nCol] = xMeta->getColumnType(nCol+1);
+ AddLabel( new ScDPItemData( aColTitle) );
+ }
+
+ // Now get the data rows.
+ Reference<sdbc::XRow> xRow(xRowSet, UNO_QUERY_THROW);
+ xRowSet->first();
+ do
+ {
+ for (sal_Int32 nCol = 0; nCol < mnColumnCount; ++nCol)
+ {
+ ScDPItemData * pNew = lcl_GetItemValue( xRow, aColTypes[nCol], nCol+1, rNullDate );
+ if ( pNew )
+ AddData( nCol , pNew );
+ }
+ }
+ while (xRowSet->next());
+
+ xRowSet->beforeFirst();
+
+ return true;
+ }
+ catch (const Exception&)
+ {
+ return false;
+ }
+}
+// -----------------------------------------------------------------------
+ULONG ScDPTableDataCache::GetDimNumType( SCCOL nDim) const
+{
+ DBG_ASSERT( IsValid(), " IsValid() == false " );
+ DBG_ASSERT( nDim < mnColumnCount && nDim >=0, " dimention out of bound " );
+ if ( mpTableDataValues[nDim].size()==0 )
+ return NUMBERFORMAT_UNDEFINED;
+ else
+ return GetNumType(mpTableDataValues[nDim][0]->nNumFormat);
+}
+
+// -----------------------------------------------------------------------
+bool ScDPTableDataCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam, BOOL *pSpecial)
+{ //Copied and modified from ScTable::ValidQuery
+ if (!rParam.GetEntry(0).bDoQuery)
+ return TRUE;
+ BOOL bMatchWholeCell = mpDoc->GetDocOptions().IsMatchWholeCell();
+
+ //---------------------------------------------------------------
+
+ const SCSIZE nFixedBools = 32;
+ BOOL aBool[nFixedBools];
+ BOOL aTest[nFixedBools];
+ SCSIZE nEntryCount = rParam.GetEntryCount();
+ BOOL* pPasst = ( nEntryCount <= nFixedBools ? &aBool[0] : new BOOL[nEntryCount] );
+ BOOL* pTest = ( nEntryCount <= nFixedBools ? &aTest[0] : new BOOL[nEntryCount] );
+
+ long nPos = -1;
+ SCSIZE i = 0;
+ CollatorWrapper* pCollator = (rParam.bCaseSens ? ScGlobal::GetCaseCollator() :
+ ScGlobal::GetCollator() );
+ ::utl::TransliterationWrapper* pTransliteration = (rParam.bCaseSens ?
+ ScGlobal::GetCaseTransliteration() : ScGlobal::GetpTransliteration());
+
+ while ( (i < nEntryCount) && rParam.GetEntry(i).bDoQuery )
+ {
+ ScQueryEntry& rEntry = rParam.GetEntry(i);
+ // we can only handle one single direct query
+ SCROW nId = GetItemDataId( (SCCOL)rEntry.nField, nRow, FALSE );
+ const ScDPItemData* pCellData = GetItemDataById( (SCCOL)rEntry.nField, nId);
+
+ BOOL bOk = FALSE;
+ BOOL bTestEqual = FALSE;
+
+ if ( pSpecial && pSpecial[i] )
+ {
+ if (rEntry.nVal == SC_EMPTYFIELDS)
+ bOk = ! pCellData->IsHasData();
+ else // if (rEntry.nVal == SC_NONEMPTYFIELDS)
+ bOk = pCellData->IsHasData();
+ }
+ else if ( !rEntry.bQueryByString && pCellData->IsValue() )
+ { // by Value
+ double nCellVal = pCellData->GetValue();
+
+ switch (rEntry.eOp)
+ {
+ case SC_EQUAL :
+ bOk = ::rtl::math::approxEqual( nCellVal, rEntry.nVal );
+ break;
+ case SC_LESS :
+ bOk = (nCellVal < rEntry.nVal) && !::rtl::math::approxEqual( nCellVal, rEntry.nVal );
+ break;
+ case SC_GREATER :
+ bOk = (nCellVal > rEntry.nVal) && !::rtl::math::approxEqual( nCellVal, rEntry.nVal );
+ break;
+ case SC_LESS_EQUAL :
+ bOk = (nCellVal < rEntry.nVal) || ::rtl::math::approxEqual( nCellVal, rEntry.nVal );
+ break;
+ case SC_GREATER_EQUAL :
+ bOk = (nCellVal > rEntry.nVal) || ::rtl::math::approxEqual( nCellVal, rEntry.nVal );
+ break;
+ case SC_NOT_EQUAL :
+ bOk = !::rtl::math::approxEqual( nCellVal, rEntry.nVal );
+ break;
+ default:
+ bOk= FALSE;
+ break;
+ }
+ }
+ else if ( (rEntry.eOp == SC_EQUAL || rEntry.eOp == SC_NOT_EQUAL)
+ || (rEntry.bQueryByString
+ && pCellData->HasStringData() )
+ )
+ { // by String
+ String aCellStr = pCellData->GetString();
+
+ BOOL bRealRegExp = (rParam.bRegExp && ((rEntry.eOp == SC_EQUAL)
+ || (rEntry.eOp == SC_NOT_EQUAL)));
+ BOOL bTestRegExp = FALSE;
+ if ( bRealRegExp || bTestRegExp )
+ {
+ xub_StrLen nStart = 0;
+ xub_StrLen nEnd = aCellStr.Len();
+ BOOL bMatch = (BOOL) rEntry.GetSearchTextPtr( rParam.bCaseSens )
+ ->SearchFrwrd( aCellStr, &nStart, &nEnd );
+ // from 614 on, nEnd is behind the found text
+ if ( bMatch && bMatchWholeCell
+ && (nStart != 0 || nEnd != aCellStr.Len()) )
+ bMatch = FALSE; // RegExp must match entire cell string
+ if ( bRealRegExp )
+ bOk = ((rEntry.eOp == SC_NOT_EQUAL) ? !bMatch : bMatch);
+ else
+ bTestEqual = bMatch;
+ }
+ if ( !bRealRegExp )
+ {
+ if ( rEntry.eOp == SC_EQUAL || rEntry.eOp == SC_NOT_EQUAL )
+ {
+ if ( bMatchWholeCell )
+ {
+ bOk = pTransliteration->isEqual( aCellStr, *rEntry.pStr );
+ //Added by zhaosz,for sodc_2702,20060808
+ String aStr = *rEntry.pStr;//"f*"
+ //modified by weihuaw,for SODC_16698
+ //use another way to find "*" in aStr
+ sal_Bool bHasStar = sal_False;
+ xub_StrLen nIndex;
+ if( ( nIndex = aStr.Search('*') ) != STRING_NOTFOUND )
+ bHasStar = sal_True;
+ if(bHasStar && (nIndex>0))
+ {
+ for(i=0;(i<nIndex) && (i< aCellStr.Len()) ; i++)
+ {
+ if(aCellStr.GetChar( (USHORT)i ) == aStr.GetChar((USHORT) i ))
+ {
+ bOk=1;
+ }
+ else
+ {
+ bOk=0;
+ break;
+ }
+ }
+ }
+ //end modified
+ //Added end,20060808
+ }
+ else
+ {
+ ::com::sun::star::uno::Sequence< sal_Int32 > xOff;
+ String aCell( pTransliteration->transliterate(
+ aCellStr, ScGlobal::eLnge, 0, aCellStr.Len(),
+ &xOff ) );
+ String aQuer( pTransliteration->transliterate(
+ *rEntry.pStr, ScGlobal::eLnge, 0, rEntry.pStr->Len(),
+ &xOff ) );
+ bOk = (aCell.Search( aQuer ) != STRING_NOTFOUND);
+ }
+ if ( rEntry.eOp == SC_NOT_EQUAL )
+ bOk = !bOk;
+ }
+ else
+ { // use collator here because data was probably sorted
+ sal_Int32 nCompare = pCollator->compareString(
+ aCellStr, *rEntry.pStr );
+ switch (rEntry.eOp)
+ {
+ case SC_LESS :
+ bOk = (nCompare < 0);
+ break;
+ case SC_GREATER :
+ bOk = (nCompare > 0);
+ break;
+ case SC_LESS_EQUAL :
+ bOk = (nCompare <= 0);
+ break;
+ case SC_GREATER_EQUAL :
+ bOk = (nCompare >= 0);
+ break;
+ case SC_NOT_EQUAL:
+ DBG_ASSERT( false , "SC_NOT_EQUAL");
+ break;
+ case SC_TOPVAL:
+ case SC_BOTVAL:
+ case SC_TOPPERC:
+ case SC_BOTPERC:
+ default:
+ break;
+ }
+ }
+ }
+ }
+
+ if (nPos == -1)
+ {
+ nPos++;
+ pPasst[nPos] = bOk;
+ pTest[nPos] = bTestEqual;
+ }
+ else
+ {
+ if (rEntry.eConnect == SC_AND)
+ {
+ pPasst[nPos] = pPasst[nPos] && bOk;
+ pTest[nPos] = pTest[nPos] && bTestEqual;
+ }
+ else
+ {
+ nPos++;
+ pPasst[nPos] = bOk;
+ pTest[nPos] = bTestEqual;
+ }
+ }
+ i++;
+ }
+
+ for ( long j=1; j <= nPos; j++ )
+ {
+ pPasst[0] = pPasst[0] || pPasst[j];
+ pTest[0] = pTest[0] || pTest[j];
+ }
+
+ BOOL bRet = pPasst[0];
+ if ( pPasst != &aBool[0] )
+ delete [] pPasst;
+ if ( pTest != &aTest[0] )
+ delete [] pTest;
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------
+bool ScDPTableDataCache::IsRowEmpty( SCROW nRow ) const
+{
+ return mbEmptyRow[ nRow ];
+
+}
+
+// -----------------------------------------------------------------------
+bool ScDPTableDataCache::IsEmptyMember( SCROW nRow, USHORT nColumn ) const
+{
+ return !GetItemDataById( nColumn, GetItemDataId( nColumn, nRow, FALSE ) )->IsHasData();
+}
+
+BOOL ScDPTableDataCache::AddData(long nDim, ScDPItemData* pitemData)
+{
+ DBG_ASSERT( IsValid(), " IsValid() == false " );
+ DBG_ASSERT( nDim < mnColumnCount && nDim >=0 , "dimension out of bound" );
+ SCROW nIndex = 0;
+
+ BOOL bInserted = FALSE;
+
+ pitemData->SetDate( lcl_isDate( GetNumType( pitemData->nNumFormat ) ) );
+
+ if ( !lcl_Search( mpTableDataValues[nDim], mpGlobalOrder[nDim], *pitemData, nIndex ) )
+ {
+ mpTableDataValues[nDim].push_back( pitemData );
+ mpGlobalOrder[nDim].insert( mpGlobalOrder[nDim].begin()+nIndex, mpTableDataValues[nDim].size()-1 );
+ DBG_ASSERT( (size_t) mpGlobalOrder[nDim][nIndex] == mpTableDataValues[nDim].size()-1 ,"ScDPTableDataCache::AddData ");
+ mpSourceData[nDim].push_back( mpTableDataValues[nDim].size()-1 );
+ bInserted = TRUE;
+ }
+ else
+ mpSourceData[nDim].push_back( mpGlobalOrder[nDim][nIndex] );
+//init empty row tag
+ size_t nCurRow = mpSourceData[nDim].size() -1 ;
+
+ while ( mbEmptyRow.size() <= nCurRow )
+ mbEmptyRow.push_back( TRUE );
+
+ if ( pitemData->IsHasData() )
+ mbEmptyRow[ nCurRow ] = FALSE;
+
+ if ( !bInserted )
+ delete pitemData;
+
+ return TRUE;
+}
+
+
+String ScDPTableDataCache::GetDimensionName( USHORT nColumn ) const
+{
+ DBG_ASSERT( /* nColumn>=0 && */ nColumn < mrLabelNames.size()-1 , "ScDPTableDataCache::GetDimensionName");
+ DBG_ASSERT( mrLabelNames.size() == static_cast <USHORT> (mnColumnCount+1), "ScDPTableDataCache::GetDimensionName");
+ if ( static_cast<size_t>(nColumn+1) < mrLabelNames.size() )
+ {
+ return mrLabelNames[nColumn+1]->aString;
+ }
+ else
+ return String();
+}
+
+void ScDPTableDataCache::AddLabel(ScDPItemData *pData)
+{
+ DBG_ASSERT( IsValid(), " IsValid() == false " );
+
+ if ( mrLabelNames.size() == 0 )
+ mrLabelNames.push_back( new ScDPItemData( ScGlobal::GetRscString(STR_PIVOT_DATA) ) );
+
+
+ //reset name if needed
+ String strNewName = pData->aString;
+ BOOL bFound = FALSE;
+ long nIndex = 1;
+ do
+ {
+ for ( long i= mrLabelNames.size()-1; i>=0; i-- )
+ {
+ if( mrLabelNames[i]->aString == strNewName )
+ {
+ strNewName = pData->aString;
+ strNewName += String::CreateFromInt32( nIndex );
+ nIndex ++ ;
+ bFound = TRUE;
+ }
+ }
+ bFound = !bFound;
+ }
+ while ( !bFound );
+
+ pData->aString = strNewName;
+ mrLabelNames.push_back( pData );
+}
+
+SCROW ScDPTableDataCache::GetItemDataId(USHORT nDim, SCROW nRow, BOOL bRepeatIfEmpty) const
+{ //
+ DBG_ASSERT( IsValid(), " IsValid() == false " );
+ DBG_ASSERT( /* nDim >= 0 && */ nDim < mnColumnCount, "ScDPTableDataCache::GetItemDataId " );
+
+ if ( bRepeatIfEmpty )
+ {
+ while ( nRow >0 && !mpTableDataValues[nDim][ mpSourceData[nDim][nRow] ]->IsHasData() )
+ --nRow;
+ }
+
+ return mpSourceData[nDim][nRow];
+}
+
+const ScDPItemData* ScDPTableDataCache::GetItemDataById(long nDim, SCROW nId) const
+{
+ if ( nId >= GetRowCount() )
+ return maAdditionalDatas.getData( nId - GetRowCount() );
+
+ if ( (size_t)nId >= mpTableDataValues[nDim].size() || nDim >= mnColumnCount || nId < 0 )
+ return NULL;
+ else
+ return mpTableDataValues[nDim][nId];
+}
+
+SCROW ScDPTableDataCache::GetRowCount() const
+{
+ if ( IsValid() )
+ return mpSourceData[0].size();
+ else
+ return 0;
+}
+
+const std::vector<ScDPItemData*>& ScDPTableDataCache::GetDimMemberValues(SCCOL nDim) const
+{
+ DBG_ASSERT( nDim>=0 && nDim < mnColumnCount ," nDim < mnColumnCount ");
+ return mpTableDataValues[nDim];
+}
+
+SCROW ScDPTableDataCache::GetSortedItemDataId(SCCOL nDim, SCROW nOrder) const
+{
+ DBG_ASSERT ( IsValid(), "IsValid");
+ DBG_ASSERT( nDim>=0 && nDim < mnColumnCount, "nDim < mnColumnCount");
+ DBG_ASSERT( nOrder >= 0 && (size_t) nOrder < mpGlobalOrder[nDim].size(), "nOrder < mpGlobalOrder[nDim].size()" );
+
+ return mpGlobalOrder[nDim][nOrder];
+}
+
+ULONG ScDPTableDataCache::GetNumType(ULONG nFormat) const
+{
+ SvNumberFormatter* pFormatter = mpDoc->GetFormatTable();
+ ULONG nType = NUMBERFORMAT_NUMBER;
+ if ( pFormatter )
+ nType = pFormatter->GetType( nFormat );
+ return nType;
+}
+
+ULONG ScDPTableDataCache::GetNumberFormat( long nDim ) const
+{
+ if ( nDim >= mnColumnCount )
+ return 0;
+ if ( mpTableDataValues[nDim].size()==0 )
+ return 0;
+ else
+ return mpTableDataValues[nDim][0]->nNumFormat;
+}
+
+BOOL ScDPTableDataCache::IsDateDimension( long nDim ) const
+{
+ if ( nDim >= mnColumnCount )
+ return false;
+ else if ( mpTableDataValues[nDim].size()==0 )
+ return false;
+ else
+ return mpTableDataValues[nDim][0]->IsDate();
+
+}
+
+SCROW ScDPTableDataCache::GetDimMemberCount( SCCOL nDim ) const
+{
+ DBG_ASSERT( nDim>=0 && nDim < mnColumnCount ," ScDPTableDataCache::GetDimMemberCount : out of bound ");
+ return mpTableDataValues[nDim].size();
+}
+
+const ScDPItemData* ScDPTableDataCache::GetSortedItemData(SCCOL nDim, SCROW nOrder) const
+{
+ SCROW n = GetSortedItemDataId( nDim, nOrder );
+ return GetItemDataById( nDim, n );
+}
+
+SCCOL ScDPTableDataCache::GetDimensionIndex(String sName) const
+{
+ for ( size_t n = 1; n < mrLabelNames.size(); n ++ ) //defects, label name map wrong SODC_17590, SODC_18932,SODC_18827,SODC_18960,SODC_18923
+ {
+ if ( mrLabelNames[n]->GetString() == sName )
+ return (SCCOL)(n-1);
+ }
+ return -1;
+}
+
+SCROW ScDPTableDataCache::GetIdByItemData(long nDim, String sItemData ) const
+{
+ if ( nDim < mnColumnCount && nDim >=0 )
+ {
+ for ( size_t n = 0; n< mpTableDataValues[nDim].size(); n++ )
+ {
+ if ( mpTableDataValues[nDim][n]->GetString() == sItemData )
+ return n;
+ }
+ }
+
+ ScDPItemData rData ( sItemData );
+ return GetRowCount() +maAdditionalDatas.getDataId(rData);
+}
+
+SCROW ScDPTableDataCache::GetIdByItemData( long nDim, const ScDPItemData& rData ) const
+{
+ if ( nDim < mnColumnCount && nDim >=0 )
+ {
+ for ( size_t n = 0; n< mpTableDataValues[nDim].size(); n++ )
+ {
+ if ( *mpTableDataValues[nDim][n] == rData )
+ return n;
+ }
+ }
+ return GetRowCount() + maAdditionalDatas.getDataId(rData);
+}
+
+SCROW ScDPTableDataCache::GetAdditionalItemID ( String sItemData )
+{
+ ScDPItemData rData ( sItemData );
+ return GetAdditionalItemID( rData );
+}
+
+SCROW ScDPTableDataCache::GetAdditionalItemID( const ScDPItemData& rData )
+{
+ return GetRowCount() + maAdditionalDatas.insertData( rData );
+}
+
+
+SCROW ScDPTableDataCache::GetOrder(long nDim, SCROW nIndex) const
+{
+ DBG_ASSERT( IsValid(), " IsValid() == false " );
+ DBG_ASSERT( nDim >=0 && nDim < mnColumnCount, "ScDPTableDataCache::GetOrder : out of bound" );
+
+ if ( mpIndexOrder[nDim].size() != mpGlobalOrder[nDim].size() )
+ { //not inited
+ SCROW i = 0;
+ mpIndexOrder[nDim].resize( mpGlobalOrder[nDim].size(), 0 );
+ for ( size_t n = 0 ; n< mpGlobalOrder[nDim].size(); n++ )
+ {
+ i = mpGlobalOrder[nDim][n];
+ mpIndexOrder[nDim][ i ] = n;
+ }
+ }
+
+ DBG_ASSERT( nIndex>=0 && (size_t)nIndex < mpIndexOrder[nDim].size() , "ScDPTableDataCache::GetOrder");
+ return mpIndexOrder[nDim][nIndex];
+}
+
+ScDocument* ScDPTableDataCache::GetDoc() const
+{
+ return mpDoc;
+};
+
+long ScDPTableDataCache::GetColumnCount() const
+{
+ return mnColumnCount;
+}
+long ScDPTableDataCache::GetId() const
+{
+ return mnID;
+}
+
diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx
index 63f5da3290d7..55f9fb771061 100644..100755
--- a/sc/source/core/data/dptabres.cxx
+++ b/sc/source/core/data/dptabres.cxx
@@ -87,7 +87,44 @@ static USHORT nFuncStrIds[12] = // passend zum enum ScSubTotalFunc
STR_FUN_TEXT_VAR, // SUBTOTAL_FUNC_VAR
STR_FUN_TEXT_VAR // SUBTOTAL_FUNC_VARP
};
+namespace {
+ template < typename T >
+ void lcl_ResizePointVector( T & vec, size_t nSize )
+ {
+ for ( size_t i = 0 ; i < vec.size(); i++ )
+ {
+ if ( vec[i] )
+ delete vec[i];
+ }
+ vec.resize( nSize, NULL );
+ }
+ BOOL lcl_SearchMember( const std::vector <ScDPResultMember *>& list, SCROW nOrder, SCROW& rIndex)
+ {
+ rIndex = list.size();
+ BOOL bFound = FALSE;
+ SCROW nLo = 0;
+ SCROW nHi = list.size() - 1;
+ SCROW nIndex;
+ while (nLo <= nHi)
+ {
+ nIndex = (nLo + nHi) / 2;
+ if ( list[nIndex]->GetOrder() < nOrder )
+ nLo = nIndex + 1;
+ else
+ {
+ nHi = nIndex - 1;
+ if ( list[nIndex]->GetOrder() == nOrder )
+ {
+ bFound = TRUE;
+ nLo = nIndex;
+ }
+ }
+ }
+ rIndex = nLo;
+ return bFound;
+ }
+}
// -----------------------------------------------------------------------
//
@@ -194,12 +231,16 @@ BOOL ScDPRowMembersOrder::operator()( sal_Int32 nIndex1, sal_Int32 nIndex2 ) con
{
const ScDPResultMember* pMember1 = rDimension.GetMember(nIndex1);
const ScDPResultMember* pMember2 = rDimension.GetMember(nIndex2);
-
+// Wang Xu Ming -- 3/17/2009
+
+// make the hide item to the largest order.
+ if ( !pMember1->IsVisible() || !pMember2->IsVisible() )
+ return pMember1->IsVisible();
+ const ScDPDataMember* pDataMember1 = pMember1->GetDataRoot() ;
+ const ScDPDataMember* pDataMember2 = pMember2->GetDataRoot();
+// End Comments
// GetDataRoot can be NULL if there was no data.
// IsVisible == FALSE can happen after AutoShow.
- const ScDPDataMember* pDataMember1 = pMember1->IsVisible() ? pMember1->GetDataRoot() : NULL;
- const ScDPDataMember* pDataMember2 = pMember2->IsVisible() ? pMember2->GetDataRoot() : NULL;
-
return lcl_IsLess( pDataMember1, pDataMember2, nMeasure, bAscending );
}
@@ -207,12 +248,12 @@ BOOL ScDPColMembersOrder::operator()( sal_Int32 nIndex1, sal_Int32 nIndex2 ) con
{
ScDPDataMember* pDataMember1 = rDimension.GetMember(nIndex1);
ScDPDataMember* pDataMember2 = rDimension.GetMember(nIndex2);
-
- if ( pDataMember1 && !pDataMember1->IsVisible() ) //! IsColVisible?
- pDataMember1 = NULL;
- if ( pDataMember2 && !pDataMember2->IsVisible() )
- pDataMember2 = NULL;
-
+ // Wang Xu Ming -- 2009-6-17
+ BOOL bHide1 = pDataMember1 && !pDataMember1->IsVisible();
+ BOOL bHide2 = pDataMember2 && !pDataMember2->IsVisible();
+ if ( bHide1 || bHide2 )
+ return !bHide1;
+ // End Comments
return lcl_IsLess( pDataMember1, pDataMember2, nMeasure, bAscending );
}
@@ -222,7 +263,7 @@ ScDPInitState::ScDPInitState() :
nCount( 0 )
{
pIndex = new long[SC_DAPI_MAXFIELDS];
- pData = new ScDPItemData[SC_DAPI_MAXFIELDS];
+ pData = new SCROW[SC_DAPI_MAXFIELDS];
}
ScDPInitState::~ScDPInitState()
@@ -231,13 +272,13 @@ ScDPInitState::~ScDPInitState()
delete[] pData;
}
-void ScDPInitState::AddMember( long nSourceIndex, const ScDPItemData& rName )
+void ScDPInitState::AddMember( long nSourceIndex, SCROW nMember )
{
DBG_ASSERT( nCount < SC_DAPI_MAXFIELDS, "too many InitState members" );
if ( nCount < SC_DAPI_MAXFIELDS )
{
pIndex[nCount] = nSourceIndex;
- pData[nCount] = rName;
+ pData[nCount] = nMember;
++nCount;
}
}
@@ -249,13 +290,13 @@ void ScDPInitState::RemoveMember()
--nCount;
}
-const ScDPItemData* ScDPInitState::GetNameForIndex( long nIndexValue ) const
+const SCROW ScDPInitState::GetNameIdForIndex( long nIndexValue ) const
{
for (long i=0; i<nCount; i++)
if ( pIndex[i] == nIndexValue )
- return &pData[i];
+ return pData[i];
- return NULL; // not found
+ return -1; // not found
}
// -----------------------------------------------------------------------
@@ -735,6 +776,8 @@ ScDPResultData::ScDPResultData( ScDPSource* pSrc ) : //! Ref
bDataAtCol( FALSE ),
bDataAtRow( FALSE )
{
+
+ lcl_ResizePointVector( mpDimMembers , SC_DAPI_MAXFIELDS );
}
ScDPResultData::~ScDPResultData()
@@ -743,6 +786,8 @@ ScDPResultData::~ScDPResultData()
delete[] pMeasRefs;
delete[] pMeasRefOrient;
delete[] pMeasNames;
+
+ lcl_ResizePointVector( mpDimMembers , 0 );
}
void ScDPResultData::SetMeasureData( long nCount, const ScSubTotalFunc* pFunctions,
@@ -890,15 +935,32 @@ BOOL ScDPResultData::IsNumOrDateGroup( long nDim ) const
}
BOOL ScDPResultData::IsInGroup( const ScDPItemData& rGroupData, long nGroupIndex,
- const ScDPItemData& rBaseData, long nBaseIndex ) const
+ long nBaseDataId, long nBaseIndex ) const
{
- return pSource->GetData()->IsInGroup( rGroupData, nGroupIndex, rBaseData, nBaseIndex );
+ const ScDPItemData* pData = pSource->GetItemDataById( nGroupIndex , nBaseDataId);
+ if ( pData )
+ return pSource->GetData()->IsInGroup( rGroupData, nGroupIndex, *pData , nBaseIndex );
+ else
+ return FALSE;
+}
+BOOL ScDPResultData::IsInGroup( SCROW nGroupDataId, long nGroupIndex,
+ const ScDPItemData& rBaseData, long nBaseIndex ) const
+{
+ const ScDPItemData* pGroupData = pSource->GetItemDataById( nGroupIndex , nGroupDataId);
+ if ( pGroupData )
+ return pSource->GetData()->IsInGroup( *pGroupData, nGroupIndex, rBaseData , nBaseIndex );
+ else
+ return FALSE;
}
-BOOL ScDPResultData::HasCommonElement( const ScDPItemData& rFirstData, long nFirstIndex,
+BOOL ScDPResultData::HasCommonElement(/* const ScDPItemData& rFirstData*/SCROW nFirstDataId, long nFirstIndex,
const ScDPItemData& rSecondData, long nSecondIndex ) const
{
- return pSource->GetData()->HasCommonElement( rFirstData, nFirstIndex, rSecondData, nSecondIndex );
+ const ScDPItemData* pFirstData = pSource->GetItemDataById( nFirstIndex , nFirstDataId);
+ if ( pFirstData )
+ return pSource->GetData()->HasCommonElement( *pFirstData, nFirstIndex, rSecondData, nSecondIndex );
+ else
+ return FALSE;
}
const ScDPSource* ScDPResultData::GetSource() const
@@ -906,27 +968,68 @@ const ScDPSource* ScDPResultData::GetSource() const
return pSource;
}
+ResultMembers* ScDPResultData::GetDimResultMembers( long nDim , ScDPDimension* pDim, ScDPLevel* pLevel) const
+{
+ if ( mpDimMembers[ nDim ] == NULL )
+ {
+
+ //long nDimSource = pDim->GetDimension();
+
+ ResultMembers* pResultMembers = new ResultMembers();
+ // global order is used to initialize aMembers, so it doesn't have to be looked at later
+ const ScMemberSortOrder& rGlobalOrder = pLevel->GetGlobalOrder();
+
+ ScDPMembers* pMembers = pLevel->GetMembersObject();
+ long nMembCount = pMembers->getCount();
+ for ( long i=0; i<nMembCount; i++ )
+ {
+ long nSorted = rGlobalOrder.empty() ? i : rGlobalOrder[i];
+ ScDPMember* pMember = pMembers->getByIndex(nSorted);
+ if ( NULL == pResultMembers->FindMember( pMember->GetItemDataId() ) )
+ {
+ ScDPParentDimData* pNew = new ScDPParentDimData( i, pDim, pLevel, pMember );
+ pResultMembers->InsertMember( pNew );
+ }
+ }
+
+ mpDimMembers[ nDim ] = pResultMembers;
+ }
+ return mpDimMembers[ nDim ];
+
+}
+
// -----------------------------------------------------------------------
-ScDPResultMember::ScDPResultMember( const ScDPResultData* pData, const ScDPDimension* pDim,
- const ScDPLevel* pLev, const ScDPMember* pDesc,
+ScDPResultMember::ScDPResultMember( const ScDPResultData* pData, const ScDPParentDimData& rParentDimData ,
BOOL bForceSub ) :
pResultData( pData ),
- pParentDim( pDim ),
- pParentLevel( pLev ),
- pMemberDesc( pDesc ),
+ aParentDimData( rParentDimData ),
pChildDimension( NULL ),
pDataRoot( NULL ),
bHasElements( FALSE ),
bForceSubTotal( bForceSub ),
bHasHiddenDetails( FALSE ),
bInitialized( FALSE ),
- bAutoHidden( FALSE )
+ bAutoHidden( FALSE ),
+ nMemberStep( 1 )
{
// pParentLevel/pMemberDesc is 0 for root members
}
+ScDPResultMember::ScDPResultMember( const ScDPResultData* pData,
+ BOOL bForceSub ) :
+ pResultData( pData ),
+ pChildDimension( NULL ),
+ pDataRoot( NULL ),
+ bHasElements( FALSE ),
+ bForceSubTotal( bForceSub ),
+ bHasHiddenDetails( FALSE ),
+ bInitialized( FALSE ),
+ bAutoHidden( FALSE ),
+ nMemberStep( 1 )
+{
+}
ScDPResultMember::~ScDPResultMember()
{
delete pChildDimension;
@@ -935,6 +1038,7 @@ ScDPResultMember::~ScDPResultMember()
String ScDPResultMember::GetName() const
{
+ const ScDPMember* pMemberDesc = GetDPMember();
if (pMemberDesc)
return pMemberDesc->GetNameStr();
else
@@ -943,22 +1047,23 @@ String ScDPResultMember::GetName() const
void ScDPResultMember::FillItemData( ScDPItemData& rData ) const
{
+ const ScDPMember* pMemberDesc = GetDPMember();
if (pMemberDesc)
pMemberDesc->FillItemData( rData );
else
rData.SetString( ScGlobal::GetRscString(STR_PIVOT_TOTAL) ); // root member
}
-BOOL ScDPResultMember::IsNamedItem( const ScDPItemData& r ) const
+BOOL ScDPResultMember::IsNamedItem( SCROW nIndex ) const
{
//! store ScDPMember pointer instead of ScDPMember ???
-
+ const ScDPMember* pMemberDesc = GetDPMember();
if (pMemberDesc)
- return ((ScDPMember*)pMemberDesc)->IsNamedItem( r );
+ return ((ScDPMember*)pMemberDesc)->IsNamedItem( nIndex );
return FALSE;
}
-bool ScDPResultMember::IsValidEntry( const vector<ScDPItemData>& aMembers ) const
+bool ScDPResultMember::IsValidEntry( const vector< SCROW >& aMembers ) const
{
if ( !IsValid() )
return false;
@@ -969,8 +1074,8 @@ bool ScDPResultMember::IsValidEntry( const vector<ScDPItemData>& aMembers ) cons
if (aMembers.size() < 2)
return false;
- vector<ScDPItemData>::const_iterator itr = aMembers.begin();
- vector<ScDPItemData> aChildMembers(++itr, aMembers.end());
+ vector<SCROW>::const_iterator itr = aMembers.begin();
+ vector<SCROW> aChildMembers(++itr, aMembers.end());
return pChildDim->IsValidEntry(aChildMembers);
}
else
@@ -978,7 +1083,8 @@ bool ScDPResultMember::IsValidEntry( const vector<ScDPItemData>& aMembers ) cons
}
void ScDPResultMember::InitFrom( const vector<ScDPDimension*>& ppDim, const vector<ScDPLevel*>& ppLev,
- size_t nPos, ScDPInitState& rInitState )
+ size_t nPos, ScDPInitState& rInitState ,
+ BOOL bInitChild /*= TRUE */)
{
// with LateInit, initialize only those members that have data
if ( pResultData->IsLateInit() )
@@ -990,18 +1096,40 @@ void ScDPResultMember::InitFrom( const vector<ScDPDimension*>& ppDim, const vect
return;
// skip child dimension if details are not shown
- if ( pMemberDesc && !pMemberDesc->getShowDetails() )
+ if ( GetDPMember() && !GetDPMember()->getShowDetails() )
{
+ // Wang Xu Ming -- 2009-6-16
+ // Show DataLayout dimention
+ nMemberStep = 1;
+ while ( nPos < ppDim.size() )
+ {
+ if ( ppDim[nPos] ->getIsDataLayoutDimension() )
+ {
+ if ( !pChildDimension )
+ pChildDimension = new ScDPResultDimension( pResultData );
+ pChildDimension->InitFrom( ppDim, ppLev, nPos, rInitState , FALSE );
+ return;
+ }
+ else
+ { //find next dim
+ nPos ++;
+ nMemberStep ++;
+ }
+ }
+ // End Comments
bHasHiddenDetails = TRUE; // only if there is a next dimension
return;
}
- pChildDimension = new ScDPResultDimension( pResultData );
- pChildDimension->InitFrom( ppDim, ppLev, nPos, rInitState );
+ if ( bInitChild )
+ {
+ pChildDimension = new ScDPResultDimension( pResultData );
+ pChildDimension->InitFrom( ppDim, ppLev, nPos, rInitState, TRUE );
+ }
}
-void ScDPResultMember::LateInitFrom( const vector<ScDPDimension*>& ppDim, const vector<ScDPLevel*>& ppLev,
- const vector<ScDPItemData>& pItemData, size_t nPos,
+void ScDPResultMember::LateInitFrom( LateInitParams& rParams/*const vector<ScDPDimension*>& ppDim, const vector<ScDPLevel*>& ppLev*/,
+ const vector< SCROW >& pItemData, size_t nPos,
ScDPInitState& rInitState )
{
// without LateInit, everything has already been initialized
@@ -1010,29 +1138,52 @@ void ScDPResultMember::LateInitFrom( const vector<ScDPDimension*>& ppDim, const
bInitialized = TRUE;
- if (nPos >= ppDim.size())
+ if ( rParams.IsEnd( nPos ) /*nPos >= ppDim.size()*/)
// No next dimension. Bail out.
return;
// skip child dimension if details are not shown
- if ( pMemberDesc && !pMemberDesc->getShowDetails() )
+ if ( GetDPMember() && !GetDPMember()->getShowDetails() )
{
+ // Wang Xu Ming -- 2009-6-16
+ // DataPilot Migration
+ // Show DataLayout dimention
+ nMemberStep = 1;
+ while ( !rParams.IsEnd( nPos ) )
+ {
+ if ( rParams.GetDim( nPos ) ->getIsDataLayoutDimension() )
+ {
+ if ( !pChildDimension )
+ pChildDimension = new ScDPResultDimension( pResultData );
+ rParams.SetInitChild( FALSE );
+ pChildDimension->LateInitFrom( rParams, pItemData, nPos, rInitState );
+ return;
+ }
+ else
+ { //find next dim
+ nPos ++;
+ nMemberStep ++;
+ }
+ }
+ // End Comments
bHasHiddenDetails = TRUE; // only if there is a next dimension
return;
}
// LateInitFrom is called several times...
- if ( !pChildDimension )
- pChildDimension = new ScDPResultDimension( pResultData );
-
- pChildDimension->LateInitFrom( ppDim, ppLev, pItemData, nPos, rInitState );
+ if ( rParams.GetInitChild() )
+ {
+ if ( !pChildDimension )
+ pChildDimension = new ScDPResultDimension( pResultData );
+ pChildDimension->LateInitFrom( rParams, pItemData, nPos, rInitState );
+ }
}
BOOL ScDPResultMember::IsSubTotalInTitle(long nMeasure) const
{
BOOL bRet = FALSE;
- if ( pChildDimension && pParentLevel &&
- pParentLevel->IsOutlineLayout() && pParentLevel->IsSubtotalsAtTop() )
+ if ( pChildDimension && /*pParentLevel*/GetParentLevel() &&
+ /*pParentLevel*/GetParentLevel()->IsOutlineLayout() && /*pParentLevel*/GetParentLevel()->IsSubtotalsAtTop() )
{
long nUserSubStart;
long nSubTotals = GetSubTotalCount( &nUserSubStart );
@@ -1054,7 +1205,7 @@ long ScDPResultMember::GetSize(long nMeasure) const
{
if ( !IsVisible() )
return 0;
-
+ const ScDPLevel* pParentLevel = GetParentLevel();
long nExtraSpace = 0;
if ( pParentLevel && pParentLevel->IsAddEmpty() )
++nExtraSpace;
@@ -1091,7 +1242,7 @@ BOOL ScDPResultMember::IsVisible() const
{
// not initialized -> shouldn't be there at all
// (allocated only to preserve ordering)
-
+ const ScDPLevel* pParentLevel = GetParentLevel();
return ( bHasElements || ( pParentLevel && pParentLevel->getShowEmpty() ) ) && IsValid() && bInitialized;
}
@@ -1100,6 +1251,7 @@ BOOL ScDPResultMember::IsValid() const
// non-Valid members are left out of calculation
// was member set no invisible at the DataPilotSource?
+ const ScDPMember* pMemberDesc =GetDPMember();
if ( pMemberDesc && !pMemberDesc->getIsVisible() )
return FALSE;
@@ -1122,6 +1274,8 @@ long ScDPResultMember::GetSubTotalCount( long* pUserSubStart ) const
if ( pUserSubStart )
*pUserSubStart = 0; // default
+ const ScDPLevel* pParentLevel = GetParentLevel();
+
if ( bForceSubTotal ) // set if needed for root members
return 1; // grand total is always "automatic"
else if ( pParentLevel )
@@ -1145,8 +1299,8 @@ long ScDPResultMember::GetSubTotalCount( long* pUserSubStart ) const
return 0;
}
-void ScDPResultMember::ProcessData( const vector<ScDPItemData>& aChildMembers, const ScDPResultDimension* pDataDim,
- const vector<ScDPItemData>& aDataMembers, const vector<ScDPValueData>& aValues )
+void ScDPResultMember::ProcessData( const vector< SCROW >& aChildMembers, const ScDPResultDimension* pDataDim,
+ const vector< SCROW >& aDataMembers, const vector<ScDPValueData>& aValues )
{
SetHasElements();
@@ -1169,6 +1323,8 @@ void ScDPResultMember::ProcessData( const vector<ScDPItemData>& aChildMembers, c
if ( !nUserSubCount || !pChildDimension )
nUserSubCount = 1;
+ const ScDPLevel* pParentLevel = GetParentLevel();
+
for (long nUserPos=0; nUserPos<nUserSubCount; nUserPos++) // including hidden "automatic"
{
// #i68338# if nUserSubCount is 1 (automatic only), don't set nRowSubTotalFunc
@@ -1229,10 +1385,10 @@ void ScDPResultMember::FillMemberResults( uno::Sequence<sheet::MemberResult>* pS
{
ScDPItemData aItemData;
FillItemData( aItemData );
- aName = aItemData.aString;
- bIsNumeric = aItemData.bHasValue;
+ aName = aItemData.GetString();
+ bIsNumeric = aItemData.IsValue();
}
-
+ const ScDPDimension* pParentDim = GetParentDim();
if ( bIsNumeric && pParentDim && pResultData->IsNumOrDateGroup( pParentDim->GetDimension() ) )
{
// Numeric group dimensions use numeric entries for proper sorting,
@@ -1241,6 +1397,7 @@ void ScDPResultMember::FillMemberResults( uno::Sequence<sheet::MemberResult>* pS
}
String aCaption = aName;
+ const ScDPMember* pMemberDesc = GetDPMember();
if (pMemberDesc)
{
const OUString* pLayoutName = pMemberDesc->GetLayoutName();
@@ -1272,6 +1429,7 @@ void ScDPResultMember::FillMemberResults( uno::Sequence<sheet::MemberResult>* pS
pArray[rPos+i].Flags |= sheet::MemberResultFlags::CONTINUE;
}
+ const ScDPLevel* pParentLevel = GetParentLevel();
long nExtraSpace = 0;
if ( pParentLevel && pParentLevel->IsAddEmpty() )
++nExtraSpace;
@@ -1293,7 +1451,8 @@ void ScDPResultMember::FillMemberResults( uno::Sequence<sheet::MemberResult>* pS
if (bRoot) // same sequence for root member
pChildDimension->FillMemberResults( pSequences, rPos, nMeasure );
else
- pChildDimension->FillMemberResults( pSequences + 1, rPos, nMeasure );
+ //pChildDimension->FillMemberResults( pSequences + 1, rPos, nMeasure );
+ pChildDimension->FillMemberResults( pSequences + nMemberStep/*1*/, rPos, nMeasure );
if ( bTitleLine ) // title row is included in GetSize, so the following
--rPos; // positions are calculated with the normal values
@@ -1389,7 +1548,7 @@ void ScDPResultMember::FillDataResults( const ScDPResultMember* pRefMember,
{
// IsVisible() test is in ScDPResultDimension::FillDataResults
// (not on data layout dimension)
-
+ const ScDPLevel* pParentLevel = GetParentLevel();
long nStartRow = rRow;
long nExtraSpace = 0;
@@ -1409,7 +1568,7 @@ void ScDPResultMember::FillDataResults( const ScDPResultMember* pRefMember,
++rRow; // -> fill child dimension one row below
pChildDimension->FillDataResults( pRefMember, rSequence, rRow, nMeasure ); // doesn't modify rRow
- rRow += (USHORT) GetSize( nMeasure );
+ rRow += GetSize( nMeasure );
if ( bTitleLine ) // title row is included in GetSize, so the following
--rRow; // positions are calculated with the normal values
@@ -1451,7 +1610,7 @@ void ScDPResultMember::FillDataResults( const ScDPResultMember* pRefMember,
if ( bHasChild && nUserSubCount > 1 )
{
aSubState.nRowSubTotalFunc = nUserPos;
- aSubState.eRowForce = lcl_GetForceFunc( pParentLevel, nUserPos );
+ aSubState.eRowForce = lcl_GetForceFunc( /*pParentLevel*/GetParentLevel() , nUserPos );
}
for ( long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
@@ -1509,7 +1668,7 @@ void ScDPResultMember::UpdateDataResults( const ScDPResultMember* pRefMember, lo
if ( bHasChild && nUserSubCount > 1 )
{
aSubState.nRowSubTotalFunc = nUserPos;
- aSubState.eRowForce = lcl_GetForceFunc( pParentLevel, nUserPos );
+ aSubState.eRowForce = lcl_GetForceFunc( /*pParentLevel*/GetParentLevel() , nUserPos );
}
for ( long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
@@ -1537,8 +1696,7 @@ void ScDPResultMember::SortMembers( ScDPResultMember* pRefMember )
if (bHasChild)
pChildDimension->SortMembers( pRefMember ); // sorting is done at the dimension
- BOOL bIsRoot = ( pParentLevel == NULL );
- if ( bIsRoot && pDataRoot )
+ if ( IsRoot() && pDataRoot )
{
// use the row root member to sort columns
// sub total count is always 1
@@ -1553,8 +1711,7 @@ void ScDPResultMember::DoAutoShow( ScDPResultMember* pRefMember )
if (bHasChild)
pChildDimension->DoAutoShow( pRefMember ); // sorting is done at the dimension
- BOOL bIsRoot = ( pParentLevel == NULL );
- if ( bIsRoot && pDataRoot )
+ if ( IsRoot()&& pDataRoot )
{
// use the row root member to sort columns
// sub total count is always 1
@@ -1563,7 +1720,7 @@ void ScDPResultMember::DoAutoShow( ScDPResultMember* pRefMember )
}
}
-void ScDPResultMember::ResetResults( BOOL bRoot )
+void ScDPResultMember::ResetResults( BOOL /*bRoot*/ )
{
if (pDataRoot)
pDataRoot->ResetResults();
@@ -1571,8 +1728,8 @@ void ScDPResultMember::ResetResults( BOOL bRoot )
if (pChildDimension)
pChildDimension->ResetResults();
- if (!bRoot)
- bHasElements = FALSE;
+ // if (!bRoot)
+ // bHasElements = FALSE;
}
void ScDPResultMember::UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure,
@@ -1581,13 +1738,12 @@ void ScDPResultMember::UpdateRunningTotals( const ScDPResultMember* pRefMember,
// IsVisible() test is in ScDPResultDimension::FillDataResults
// (not on data layout dimension)
- BOOL bIsRoot = ( pParentLevel == NULL );
- rTotals.SetInColRoot( bIsRoot );
+ rTotals.SetInColRoot( IsRoot() );
BOOL bHasChild = ( pChildDimension != NULL );
long nUserSubCount = GetSubTotalCount();
- if ( nUserSubCount || !bHasChild )
+ //if ( nUserSubCount || !bHasChild )
{
// Calculate at least automatic if no subtotals are selected,
// show only own values if there's no child dimension (innermost).
@@ -1606,7 +1762,7 @@ void ScDPResultMember::UpdateRunningTotals( const ScDPResultMember* pRefMember,
if ( bHasChild && nUserSubCount > 1 )
{
aSubState.nRowSubTotalFunc = nUserPos;
- aSubState.eRowForce = lcl_GetForceFunc( pParentLevel, nUserPos );
+ aSubState.eRowForce = lcl_GetForceFunc( /*pParentLevel*/GetParentLevel(), nUserPos );
}
for ( long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
@@ -1685,7 +1841,7 @@ BOOL ScDPDataMember::IsVisible() const
return FALSE;
}
-BOOL ScDPDataMember::IsNamedItem( const ScDPItemData& r ) const
+BOOL ScDPDataMember::IsNamedItem( /*const ScDPItemData& r*/SCROW r ) const
{
if (pResultMember)
return pResultMember->IsNamedItem(r);
@@ -1752,7 +1908,7 @@ void ScDPDataMember::UpdateValues( const vector<ScDPValueData>& aValues, const S
}
}
-void ScDPDataMember::ProcessData( const vector<ScDPItemData>& aChildMembers, const vector<ScDPValueData>& aValues,
+void ScDPDataMember::ProcessData( const vector< SCROW >& aChildMembers, const vector<ScDPValueData>& aValues,
const ScDPSubTotalState& rSubState )
{
if ( pResultData->IsLateInit() && !pChildDimension && pResultMember && pResultMember->GetChildDimension() )
@@ -2107,7 +2263,7 @@ void ScDPDataMember::UpdateRunningTotals( const ScDPResultMember* pRefMember,
BOOL bHasChild = ( pRefChild != NULL );
long nUserSubCount = pRefMember->GetSubTotalCount();
- if ( nUserSubCount || !bHasChild )
+ //if ( nUserSubCount || !bHasChild )
{
// Calculate at least automatic if no subtotals are selected,
// show only own values if there's no child dimension (innermost).
@@ -2496,8 +2652,10 @@ private:
BOOL bIncludeAll;
BOOL bIsBase;
long nGroupBase;
- const ScDPItemData* pBaseData;
-
+ // Wang Xu Ming -- 2009-8-6
+ // DataPilot Migration - Cache&&Performance
+ SCROW nBaseDataId;
+ // End Comments
public:
ScDPGroupCompare( const ScDPResultData* pData, const ScDPInitState& rState, long nDimension );
~ScDPGroupCompare() {}
@@ -2510,12 +2668,12 @@ ScDPGroupCompare::ScDPGroupCompare( const ScDPResultData* pData, const ScDPInitS
pResultData( pData ),
rInitState( rState ),
nDimSource( nDimension ),
- pBaseData( NULL )
+ nBaseDataId( -1 )
{
bIsBase = pResultData->IsBaseForGroup( nDimSource );
nGroupBase = pResultData->GetGroupBase( nDimSource ); //! get together in one call?
if ( nGroupBase >= 0 )
- pBaseData = rInitState.GetNameForIndex( nGroupBase );
+ nBaseDataId = rInitState.GetNameIdForIndex( nGroupBase );
// if bIncludeAll is set, TestIncluded doesn't need to be called
bIncludeAll = !( bIsBase || nGroupBase >= 0 );
@@ -2524,11 +2682,11 @@ ScDPGroupCompare::ScDPGroupCompare( const ScDPResultData* pData, const ScDPInitS
BOOL ScDPGroupCompare::TestIncluded( const ScDPMember& rMember )
{
BOOL bInclude = TRUE;
- if ( pBaseData )
+ if ( nBaseDataId >=0 )
{
ScDPItemData aMemberData;
rMember.FillItemData( aMemberData );
- bInclude = pResultData->IsInGroup( aMemberData, nDimSource, *pBaseData, nGroupBase );
+ bInclude = pResultData->IsInGroup( aMemberData, nDimSource, nBaseDataId, nGroupBase );
}
else if ( bIsBase )
{
@@ -2538,7 +2696,8 @@ BOOL ScDPGroupCompare::TestIncluded( const ScDPMember& rMember )
rMember.FillItemData( aMemberData );
long nInitCount = rInitState.GetCount();
const long* pInitSource = rInitState.GetSource();
- const ScDPItemData* pInitNames = rInitState.GetNames();
+ /*const ScDPItemData* pInitNames = rInitState.GetNames();*/
+ const SCROW* pInitNames = rInitState.GetNameIds();
for (long nInitPos=0; nInitPos<nInitCount && bInclude; nInitPos++)
if ( pResultData->GetGroupBase( pInitSource[nInitPos] ) == nDimSource )
{
@@ -2556,7 +2715,8 @@ BOOL ScDPGroupCompare::TestIncluded( const ScDPMember& rMember )
rMember.FillItemData( aMemberData );
long nInitCount = rInitState.GetCount();
const long* pInitSource = rInitState.GetSource();
- const ScDPItemData* pInitNames = rInitState.GetNames();
+ /*const ScDPItemData* pInitNames = rInitState.GetNames();*/
+ const SCROW* pInitNames = rInitState.GetNameIds();
for (long nInitPos=0; nInitPos<nInitCount && bInclude; nInitPos++)
if ( pResultData->GetGroupBase( pInitSource[nInitPos] ) == nGroupBase )
{
@@ -2591,14 +2751,14 @@ ScDPResultDimension::~ScDPResultDimension()
delete maMemberArray[i];
}
-ScDPResultMember *ScDPResultDimension::FindMember( const ScDPItemData& rData ) const
+ScDPResultMember *ScDPResultDimension::FindMember( SCROW iData ) const
{
if( bIsDataLayout )
return maMemberArray[0];
- MemberHash::const_iterator aRes = maMemberHash.find( rData );
+ MemberHash::const_iterator aRes = maMemberHash.find( iData );
if( aRes != maMemberHash.end()) {
- if ( aRes->second->IsNamedItem( rData ) )
+ if ( aRes->second->IsNamedItem( iData ) )
return aRes->second;
DBG_ERROR("problem! hash result is not the same as IsNamedItem");
}
@@ -2609,14 +2769,14 @@ ScDPResultMember *ScDPResultDimension::FindMember( const ScDPItemData& rData ) c
for( i = 0; i < nCount ; i++ )
{
pResultMember = maMemberArray[i];
- if ( pResultMember->IsNamedItem( rData ) )
+ if ( pResultMember->IsNamedItem( iData ) )
return pResultMember;
}
return NULL;
}
void ScDPResultDimension::InitFrom( const vector<ScDPDimension*>& ppDim, const vector<ScDPLevel*>& ppLev,
- size_t nPos, ScDPInitState& rInitState )
+ size_t nPos, ScDPInitState& rInitState, BOOL bInitChild /*= TRUE */ )
{
if (nPos >= ppDim.size() || nPos >= ppLev.size())
{
@@ -2671,46 +2831,41 @@ void ScDPResultDimension::InitFrom( const vector<ScDPDimension*>& ppDim, const v
ScDPMember* pMember = pMembers->getByIndex(nSorted);
if ( aCompare.IsIncluded( *pMember ) )
{
- ScDPResultMember* pNew = new ScDPResultMember( pResultData, pThisDim,
- pThisLevel, pMember, FALSE );
- maMemberArray.push_back( pNew );
+ ScDPParentDimData aData( i, pThisDim, pThisLevel, pMember);
+ ScDPResultMember* pNew = AddMember( aData );
- ScDPItemData aMemberData;
- pMember->FillItemData( aMemberData );
-
- // honour order of maMemberArray and only insert if it does not
- // already exist
- if ( maMemberHash.end() == maMemberHash.find( aMemberData ) )
- maMemberHash.insert( std::pair< const ScDPItemData, ScDPResultMember *>( aMemberData, pNew ) );
-
- rInitState.AddMember( nDimSource, aMemberData );
- pNew->InitFrom( ppDim, ppLev, nPos+1, rInitState );
+ rInitState.AddMember( nDimSource, /*aMemberData*/pNew->GetDataId() );
+ pNew->InitFrom( ppDim, ppLev, nPos+1, rInitState, bInitChild );
rInitState.RemoveMember();
}
}
bInitialized = TRUE;
}
-void ScDPResultDimension::LateInitFrom( const vector<ScDPDimension*>& ppDim, const vector<ScDPLevel*>& ppLev,
- const vector<ScDPItemData>& pItemData, size_t nPos,
+void ScDPResultDimension::LateInitFrom( LateInitParams& rParams/* const vector<ScDPDimension*>& ppDim, const vector<ScDPLevel*>& ppLev*/,
+ const vector<SCROW>& pItemData, size_t nPos,
ScDPInitState& rInitState )
+// End Comments
{
- if (nPos >= ppDim.size() || nPos >= ppLev.size() || nPos >= pItemData.size())
+ if ( rParams.IsEnd( nPos ) )
return;
-
- ScDPDimension* pThisDim = ppDim[nPos];
- ScDPLevel* pThisLevel = ppLev[nPos];
- const ScDPItemData& rThisData = pItemData[nPos];
+#ifdef DBG_UTIL
+ DBG_ASSERT( nPos <= pItemData.size(), ByteString::CreateFromInt32( pItemData.size()).GetBuffer() );
+#endif
+ ScDPDimension* pThisDim = rParams.GetDim( nPos );
+ ScDPLevel* pThisLevel = rParams.GetLevel( nPos );
+ SCROW rThisData = pItemData[nPos];
if (!pThisDim || !pThisLevel)
return;
long nDimSource = pThisDim->GetDimension(); //! check GetSourceDim?
- if ( !bInitialized )
- {
- // create all members at the first call (preserve order)
+ BOOL bShowEmpty = pThisLevel->getShowEmpty();
+ if ( !bInitialized )
+ { // init some values
+ // create all members at the first call (preserve order)
bIsDataLayout = pThisDim->getIsDataLayoutDimension();
aDimensionName = pThisDim->getName();
@@ -2730,65 +2885,86 @@ void ScDPResultDimension::LateInitFrom( const vector<ScDPDimension*>& ppDim, con
bSortAscending = rSortInfo.IsAscending;
nSortMeasure = pThisLevel->GetSortMeasure();
}
+ }
- // global order is used to initialize aMembers, so it doesn't have to be looked at later
- const ScMemberSortOrder& rGlobalOrder = pThisLevel->GetGlobalOrder();
+ bool bLateInitAllMembers= bIsDataLayout || rParams.GetInitAllChild() || bShowEmpty;
- ScDPGroupCompare aCompare( pResultData, rInitState, nDimSource );
+ if ( !bLateInitAllMembers )
+ {
+ ResultMembers* pMembers = pResultData->GetDimResultMembers(nDimSource, pThisDim, pThisLevel);
+ bLateInitAllMembers = pMembers->IsHasHideDetailsMembers();
+#ifdef DBG_UTIL
+ DBG_TRACESTR( aDimensionName )
+ if ( pMembers->IsHasHideDetailsMembers() )
+ DBG_TRACE ( "HasHideDetailsMembers" );
+#endif
+ pMembers->SetHasHideDetailsMembers( FALSE );
+ }
- ScDPMembers* pMembers = pThisLevel->GetMembersObject();
- long nMembCount = pMembers->getCount();
- for ( long i=0; i<nMembCount; i++ )
- {
- long nSorted = rGlobalOrder.empty() ? i : rGlobalOrder[i];
+ bool bNewAllMembers =(!rParams.IsRow()) || nPos == 0 || bLateInitAllMembers ;
- ScDPMember* pMember = pMembers->getByIndex(nSorted);
- if ( aCompare.IsIncluded( *pMember ) )
+ if (bNewAllMembers )
+ {
+ // global order is used to initialize aMembers, so it doesn't have to be looked at later
+ if ( !bInitialized )
+ { //init all members
+ const ScMemberSortOrder& rGlobalOrder = pThisLevel->GetGlobalOrder();
+
+ ScDPGroupCompare aCompare( pResultData, rInitState, nDimSource );
+ ScDPMembers* pMembers = pThisLevel->GetMembersObject();
+ long nMembCount = pMembers->getCount();
+ for ( long i=0; i<nMembCount; i++ )
{
- ScDPResultMember* pNew = new ScDPResultMember( pResultData, pThisDim,
- pThisLevel, pMember, FALSE );
- maMemberArray.push_back( pNew );
+ long nSorted = rGlobalOrder.empty() ? i : rGlobalOrder[i];
- ScDPItemData aMemberData;
- pMember->FillItemData( aMemberData );
-
- // honour order of maMemberArray and only insert if it does not
- // already exist
- if ( maMemberHash.end() == maMemberHash.find( aMemberData ) )
- maMemberHash.insert( std::pair< const ScDPItemData, ScDPResultMember *>( aMemberData, pNew ) );
+ ScDPMember* pMember = pMembers->getByIndex(nSorted);
+ if ( aCompare.IsIncluded( *pMember ) )
+ { // add all members
+ ScDPParentDimData aData( i, pThisDim, pThisLevel, pMember );
+ AddMember( aData );
+ }
}
+ bInitialized = TRUE; // don't call again, even if no members were included
}
- bInitialized = TRUE; // don't call again, even if no members were included
- }
-
// initialize only specific member (or all if "show empty" flag is set)
-
- BOOL bShowEmpty = pThisLevel->getShowEmpty();
- if ( bIsDataLayout || bShowEmpty )
- {
- long nCount = maMemberArray.size();
- for (long i=0; i<nCount; i++)
+ if ( bLateInitAllMembers )
{
- ScDPResultMember* pResultMember = maMemberArray[i];
- ScDPItemData aMemberData;
- pResultMember->FillItemData( aMemberData );
- rInitState.AddMember( nDimSource, aMemberData );
- pResultMember->LateInitFrom( ppDim, ppLev, pItemData, nPos+1, rInitState );
- rInitState.RemoveMember();
+ long nCount = maMemberArray.size();
+ for (long i=0; i<nCount; i++)
+ {
+ ScDPResultMember* pResultMember = maMemberArray[i];
+
+ // check show empty
+ BOOL bAllChildren = FALSE;
+ if( bShowEmpty )
+ {
+ if ( pResultMember->IsNamedItem( rThisData ) )
+ bAllChildren = FALSE;
+ else
+ bAllChildren = TRUE;
+ }
+ rParams.SetInitAllChildren( bAllChildren );
+ rInitState.AddMember( nDimSource, pResultMember->GetDataId() );
+ pResultMember->LateInitFrom( rParams, pItemData, nPos+1, rInitState );
+ rInitState.RemoveMember();
+ }
}
- }
- else
- {
- ScDPResultMember* pResultMember = FindMember( rThisData );
- if( NULL != pResultMember )
+ else
{
- ScDPItemData aMemberData;
- pResultMember->FillItemData( aMemberData );
- rInitState.AddMember( nDimSource, aMemberData );
- pResultMember->LateInitFrom( ppDim, ppLev, pItemData, nPos+1, rInitState );
- rInitState.RemoveMember();
+ ScDPResultMember* pResultMember = FindMember( rThisData );
+ if( NULL != pResultMember )
+ {
+ //DBG_TRACE( "ScDPResultDimension::LateInitFrom");
+ // DBG_TRACESTR( pResultMember->GetDPMember()->GetNameStr());
+
+ rInitState.AddMember( nDimSource, pResultMember->GetDataId() );
+ pResultMember->LateInitFrom( rParams, pItemData, nPos+1, rInitState );
+ rInitState.RemoveMember();
+ }
}
}
+ else
+ InitWithMembers( rParams, pItemData, nPos, rInitState );
}
long ScDPResultDimension::GetSize(long nMeasure) const
@@ -2811,7 +2987,7 @@ long ScDPResultDimension::GetSize(long nMeasure) const
return nTotal;
}
-bool ScDPResultDimension::IsValidEntry( const vector<ScDPItemData>& aMembers ) const
+bool ScDPResultDimension::IsValidEntry( const vector< SCROW >& aMembers ) const
{
if (aMembers.empty())
return false;
@@ -2819,14 +2995,18 @@ bool ScDPResultDimension::IsValidEntry( const vector<ScDPItemData>& aMembers ) c
const ScDPResultMember* pMember = FindMember( aMembers[0] );
if ( NULL != pMember )
return pMember->IsValidEntry( aMembers );
-
- DBG_ERROR("IsValidEntry: Member not found");
+#ifdef DBG_UTIL
+ ByteString strTemp ("IsValidEntry: Member not found, DimName = " );
+ strTemp += ByteString( GetName(), RTL_TEXTENCODING_UTF8 );
+ DBG_TRACE( strTemp.GetBuffer() );
+ // DBG_ERROR("IsValidEntry: Member not found");
+#endif
return false;
}
-void ScDPResultDimension::ProcessData( const vector<ScDPItemData>& aMembers,
+void ScDPResultDimension::ProcessData( const vector< SCROW >& aMembers,
const ScDPResultDimension* pDataDim,
- const vector<ScDPItemData>& aDataMembers,
+ const vector< SCROW >& aDataMembers,
const vector<ScDPValueData>& aValues ) const
{
if (aMembers.empty())
@@ -2835,11 +3015,11 @@ void ScDPResultDimension::ProcessData( const vector<ScDPItemData>& aMembers,
ScDPResultMember* pMember = FindMember( aMembers[0] );
if ( NULL != pMember )
{
- vector<ScDPItemData> aChildMembers;
+ vector</*ScDPItemData*/SCROW > aChildMembers;
if (aMembers.size() > 1)
{
- vector<ScDPItemData>::const_iterator itr = aMembers.begin();
- aChildMembers.assign(++itr, aMembers.end());
+ vector</*ScDPItemData*/SCROW >::const_iterator itr = aMembers.begin();
+ aChildMembers.insert(aChildMembers.begin(), ++itr, aMembers.end());
}
pMember->ProcessData( aChildMembers, pDataDim, aDataMembers, aValues );
return;
@@ -3372,7 +3552,7 @@ void ScDPDataDimension::InitFrom( const ScDPResultDimension* pDim )
}
}
-void ScDPDataDimension::ProcessData( const vector<ScDPItemData>& aDataMembers, const vector<ScDPValueData>& aValues,
+void ScDPDataDimension::ProcessData( const vector< SCROW >& aDataMembers, const vector<ScDPValueData>& aValues,
const ScDPSubTotalState& rSubState )
{
// the ScDPItemData array must contain enough entries for all dimensions - this isn't checked
@@ -3385,11 +3565,11 @@ void ScDPDataDimension::ProcessData( const vector<ScDPItemData>& aDataMembers, c
// always first member for data layout dim
if ( bIsDataLayout || ( !aDataMembers.empty() && pMember->IsNamedItem(aDataMembers[0]) ) )
{
- vector<ScDPItemData> aChildDataMembers;
+ vector</*ScDPItemData*/SCROW> aChildDataMembers;
if (aDataMembers.size() > 1)
{
- vector<ScDPItemData>::const_iterator itr = aDataMembers.begin();
- aChildDataMembers.assign(++itr, aDataMembers.end());
+ vector</*ScDPItemData*/SCROW >::const_iterator itr = aDataMembers.begin();
+ aChildDataMembers.insert(aChildDataMembers.begin(), ++itr, aDataMembers.end());
}
pMember->ProcessData( aChildDataMembers, aValues, rSubState );
return;
@@ -3660,8 +3840,7 @@ ScDPDataMember* ScDPDataDimension::GetMember(long n) const
// ----------------------------------------------------------------------------
ScDPResultVisibilityData::ScDPResultVisibilityData(
- ScSimpleSharedString& rSharedString, ScDPSource* pSource) :
- mrSharedString(rSharedString),
+ ScDPSource* pSource) :
mpSource(pSource)
{
}
@@ -3715,7 +3894,8 @@ void ScDPResultVisibilityData::fillFieldFilters(vector<ScDPCacheTable::Criterion
long nDimIndex = itrField->second;
aCri.mnFieldIndex = static_cast<sal_Int32>(nDimIndex);
- aCri.mpFilter.reset(new ScDPCacheTable::GroupFilter(mrSharedString));
+ aCri.mpFilter.reset(new ScDPCacheTable::GroupFilter(/*mrSharedString*/));
+
ScDPCacheTable::GroupFilter* pGrpFilter =
static_cast<ScDPCacheTable::GroupFilter*>(aCri.mpFilter.get());
@@ -3724,7 +3904,7 @@ void ScDPResultVisibilityData::fillFieldFilters(vector<ScDPCacheTable::Criterion
itrMem != itrMemEnd; ++itrMem)
{
const ScDPItemData& rMemItem = *itrMem;
- pGrpFilter->addMatchItem(rMemItem.aString, rMemItem.fValue, rMemItem.bHasValue);
+ pGrpFilter->addMatchItem(rMemItem.GetString(), rMemItem.GetValue(), rMemItem.IsValue());
}
ScDPDimension* pDim = pDims->getByIndex(nDimIndex);
@@ -3737,8 +3917,188 @@ void ScDPResultVisibilityData::fillFieldFilters(vector<ScDPCacheTable::Criterion
size_t ScDPResultVisibilityData::MemberHash::operator() (const ScDPItemData& r) const
{
- if (r.bHasValue)
- return static_cast<size_t>(::rtl::math::approxFloor(r.fValue));
+ if (r.IsValue())
+ return static_cast<size_t>(::rtl::math::approxFloor(r.GetValue()));
else
- return rtl_ustr_hashCode_WithLength(r.aString.GetBuffer(), r.aString.Len());
+ return rtl_ustr_hashCode_WithLength(r.GetString().GetBuffer(), r.GetString().Len());
+}
+// Wang Xu Ming -- 2009-6-10
+// DataPilot Migration
+SCROW ScDPResultMember::GetDataId( ) const
+{
+ const ScDPMember* pMemberDesc = GetDPMember();
+ if (pMemberDesc)
+ return pMemberDesc->GetItemDataId();
+ return -1;
+}
+
+ScDPResultMember* ScDPResultDimension::AddMember(const ScDPParentDimData &aData )
+{
+ ScDPResultMember* pMember = new ScDPResultMember( pResultData, aData, FALSE );
+ SCROW nDataIndex = pMember->GetDataId();
+ maMemberArray.push_back( pMember );
+
+ if ( maMemberHash.end() == maMemberHash.find( nDataIndex ) )
+ maMemberHash.insert( std::pair< SCROW, ScDPResultMember *>( nDataIndex, pMember ) );
+ return pMember;
+}
+
+ResultMembers* ScDPResultDimension::GetResultMember( ScDPDimension* pThisDim, ScDPLevel* pThisLevel )
+{
+ ResultMembers* pResultMembers = new ResultMembers();
+ // global order is used to initialize aMembers, so it doesn't have to be looked at later
+ const ScMemberSortOrder& rGlobalOrder = pThisLevel->GetGlobalOrder();
+
+ ScDPMembers* pMembers = pThisLevel->GetMembersObject();
+ long nMembCount = pMembers->getCount();
+ for ( long i=0; i<nMembCount; i++ )
+ {
+ long nSorted = rGlobalOrder.empty() ? i : rGlobalOrder[i];
+ ScDPMember* pMember = pMembers->getByIndex(nSorted);
+ if ( NULL == pResultMembers->FindMember( pMember->GetItemDataId() ) )
+ {
+ ScDPParentDimData* pNew = new ScDPParentDimData( i, pThisDim, pThisLevel, pMember );
+ pResultMembers->InsertMember( pNew );
+ }
+ }
+ return pResultMembers;
}
+
+ScDPResultMember* ScDPResultDimension::InsertMember(ScDPParentDimData *pMemberData)
+{
+ SCROW nInsert = 0;
+ if ( !lcl_SearchMember( maMemberArray, pMemberData->mnOrder , nInsert ) )
+ { //Member not exist
+ ScDPResultMember* pNew = new ScDPResultMember( pResultData, *pMemberData, FALSE );
+ maMemberArray.insert( maMemberArray.begin()+nInsert, pNew );
+
+ SCROW nDataIndex = pMemberData->mpMemberDesc->GetItemDataId();
+ if ( maMemberHash.end() == maMemberHash.find( nDataIndex ) )
+ maMemberHash.insert( std::pair< SCROW, ScDPResultMember *>( nDataIndex, pNew ) );
+ return pNew;
+ }
+ return maMemberArray[ nInsert ];
+}
+
+void ScDPResultDimension:: InitWithMembers( LateInitParams& rParams,
+ const ::std::vector< SCROW >& pItemData,
+ size_t nPos,
+ ScDPInitState& rInitState )
+{
+ if ( rParams.IsEnd( nPos ) )
+ return;
+ ScDPDimension* pThisDim = rParams.GetDim( nPos );
+ ScDPLevel* pThisLevel = rParams.GetLevel( nPos );
+ SCROW nDataID = pItemData[nPos];
+
+ if (pThisDim && pThisLevel)
+ {
+ long nDimSource = pThisDim->GetDimension(); //! check GetSourceDim?
+
+ // create all members at the first call (preserve order)
+ ResultMembers* pMembers = pResultData->GetDimResultMembers(nDimSource, pThisDim, pThisLevel);
+ ScDPGroupCompare aCompare( pResultData, rInitState, nDimSource );
+ // initialize only specific member (or all if "show empty" flag is set)
+ ScDPResultMember* pResultMember = NULL;
+ if ( bInitialized )
+ pResultMember = FindMember( nDataID );
+ else
+ bInitialized = TRUE;
+
+ if ( pResultMember == NULL )
+ { //only insert found item
+ ScDPParentDimData* pMemberData = pMembers->FindMember( nDataID );
+ if ( pMemberData && aCompare.IsIncluded( *( pMemberData->mpMemberDesc ) ) )
+ pResultMember = InsertMember( pMemberData );
+ }
+ if ( pResultMember )
+ {
+ // DBG_TRACE( "ScDPResultDimension::InitWithMembers");
+ // DBG_TRACESTR( pResultMember->GetDPMember()->GetNameStr());
+ rInitState.AddMember( nDimSource, pResultMember->GetDataId() );
+ pResultMember->LateInitFrom( rParams /*ppDim, ppLev*/, pItemData, nPos+1 , rInitState );
+ rInitState.RemoveMember();
+ }
+ }
+}
+
+ScDPParentDimData* ResultMembers::FindMember( const SCROW& nIndex ) const
+{
+ DimMemberHash::const_iterator aRes = maMemberHash.find( nIndex );
+ if( aRes != maMemberHash.end()) {
+ if ( aRes->second->mpMemberDesc && aRes->second->mpMemberDesc->GetItemDataId()==nIndex )
+ return aRes->second;
+ }
+ return NULL;
+}
+void ResultMembers::InsertMember( ScDPParentDimData* pNew )
+{
+ if ( !pNew->mpMemberDesc->getShowDetails() )
+ mbHasHideDetailsMember = TRUE;
+ maMemberHash.insert( std::pair< const SCROW, ScDPParentDimData *>( pNew->mpMemberDesc->GetItemDataId(), pNew ) );
+}
+
+ResultMembers::ResultMembers():
+ mbHasHideDetailsMember( FALSE )
+{
+}
+ResultMembers::~ResultMembers()
+{
+ for ( DimMemberHash::const_iterator iter = maMemberHash.begin(); iter != maMemberHash.end(); iter++ )
+ delete iter->second;
+}
+// -----------------------------------------------------------------------
+LateInitParams::LateInitParams( const vector<ScDPDimension*>& ppDim, const vector<ScDPLevel*>& ppLev, BOOL bRow, BOOL bInitChild, BOOL bAllChildren ):
+ mppDim( ppDim ),
+ mppLev( ppLev ),
+ mbRow( bRow ),
+ mbInitChild( bInitChild ),
+ mbAllChildren( bAllChildren )
+{
+}
+
+LateInitParams::~LateInitParams()
+{
+}
+
+BOOL LateInitParams::IsEnd( size_t nPos ) const
+{
+ return nPos >= mppDim.size();
+}
+
+// End Comments
+// Wang Xu Ming -- 2009-8-4
+// DataPilot Migration - old defects merge
+void ScDPResultDimension::CheckShowEmpty( BOOL bShow )
+{
+ long nCount = maMemberArray.size();
+
+ ScDPResultMember* pMember = NULL;
+ for (long i=0; i<nCount; i++)
+ {
+ pMember = maMemberArray.at(i);
+ pMember->CheckShowEmpty( bShow );
+ }
+
+}
+
+void ScDPResultMember::CheckShowEmpty( BOOL bShow )
+{
+ if ( bHasElements )
+ {
+ ScDPResultDimension* pChildDim = GetChildDimension();
+ if (pChildDim )
+ pChildDim->CheckShowEmpty();
+ }
+ else if ( IsValid() && bInitialized )
+ {
+ bShow = bShow || ( GetParentLevel() && GetParentLevel()->getShowEmpty() );
+ if ( bShow )
+ {
+ SetHasElements();
+ ScDPResultDimension* pChildDim = GetChildDimension();
+ if (pChildDim )
+ pChildDim->CheckShowEmpty( TRUE );
+ }
+ }
+}// End Comments
diff --git a/sc/source/core/data/dptabresmember.cxx b/sc/source/core/data/dptabresmember.cxx
new file mode 100644
index 000000000000..8c3b7b164bc3
--- /dev/null
+++ b/sc/source/core/data/dptabresmember.cxx
@@ -0,0 +1,831 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright IBM Corporation 2009.
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: dptabresmember.cxx,v $
+ * $Revision: 1.0 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#include "dptabresmember.hxx"
+// -----------------------------------------------------------------------
+ScDPResultMember( const ScDPResultData* pData, const ScDPParentDimData& rParentDimData ,
+ BOOL bForceSub ) :
+ pResultData( pData ),
+ aParentDimData( rParentDimData ),
+ /* pParentDim( pDim ),
+ pParentLevel( pLev ),
+ pMemberDesc( pDesc ),*/
+ pChildDimension( NULL ),
+ pDataRoot( NULL ),
+ bHasElements( FALSE ),
+ bForceSubTotal( bForceSub ),
+ bHasHiddenDetails( FALSE ),
+ bInitialized( FALSE ),
+ nMemberStep( 1 ),
+ bAutoHidden( FALSE )
+{
+ // pParentLevel/pMemberDesc is 0 for root members
+}
+
+ScDPNormalResultMember::ScDPNormalResultMember( const ScDPResultData* pData,
+ BOOL bForceSub ) :
+ pResultData( pData ),
+ pChildDimension( NULL ),
+ pDataRoot( NULL ),
+ bHasElements( FALSE ),
+ bForceSubTotal( bForceSub ),
+ bHasHiddenDetails( FALSE ),
+ bInitialized( FALSE ),
+ nMemberStep( 1 ),
+ bAutoHidden( FALSE )
+{
+}
+
+ScDPNormalResultMember::~ScDPNormalResultMember()
+{
+ delete pChildDimension;
+ delete pDataRoot;
+}
+
+String ScDPNormalResultMember::GetName() const
+{
+// Wang Xu Ming -- 2009-6-10
+// DataPilot Migration
+ const ScDPMember* pMemberDesc = GetDPMember();
+ // End Comments
+ if (pMemberDesc)
+ return pMemberDesc->GetNameStr();
+ else
+ return ScGlobal::GetRscString(STR_PIVOT_TOTAL); // root member
+}
+
+void ScDPNormalResultMember::FillItemData( ScDPItemData& rData ) const
+{
+// Wang Xu Ming -- 2009-6-10
+// DataPilot Migration
+ const ScDPMember* pMemberDesc = GetDPMember();
+// End Comments
+ if (pMemberDesc)
+ pMemberDesc->FillItemData( rData );
+ else
+ rData.SetString( ScGlobal::GetRscString(STR_PIVOT_TOTAL) ); // root member
+}
+
+BOOL ScDPNormalResultMember::IsNamedItem( /*const ScDPItemData& r */SCROW nIndex ) const
+{
+ //! store ScDPMember pointer instead of ScDPMember ???
+ const ScDPMember* pMemberDesc = GetDPMember();
+ if (pMemberDesc)
+ return ((ScDPMember*)pMemberDesc)->IsNamedItem(/* r*/ nIndex );
+ return FALSE;
+}
+
+// Wang Xu Ming -- 2009-5-27
+// DataPilot Migration
+bool ScDPNormalResultMember::IsValidEntry( const vector< SCROW >& aMembers ) const
+{
+ return GetEntryStatus( aMembers ) != ENTRY_INVALID;
+}
+// End Comments
+
+ENTRYSTATUS ScDPNormalResultMember::GetEntryStatus( const vector< SCROW >& aMembers ) const
+{
+ if ( !IsValid() )
+ return ENTRY_INVALID;
+
+ const ScDPResultDimension* pChildDim = GetChildDimension();
+ if (pChildDim)
+ {
+ if (aMembers.size() < 2)
+ return ENTRY_INVALID;
+
+ vector</*ScDPItemData*/SCROW>::const_iterator itr = aMembers.begin();
+ vector</*ScDPItemData*/SCROW> aChildMembers(++itr, aMembers.end());
+ return pChildDim->GetEntryStatus(aChildMembers);
+ }
+ else if( bHasHiddenDetails )
+ return ENTRY_HASHIDDENDETAIL;
+ else
+ return ENTRY_VALID;
+}
+
+void ScDPNormalResultMember::InitFrom( const vector<ScDPDimension*>& ppDim, const vector<ScDPLevel*>& ppLev,
+ size_t nPos, ScDPInitState& rInitState ,
+ BOOL bInitChild /*= TRUE */)
+ {
+ // with LateInit, initialize only those members that have data
+ if ( pResultData->IsLateInit() )
+ return;
+
+ bInitialized = TRUE;
+
+ if (nPos >= ppDim.size() )
+ return;
+
+ // skip child dimension if details are not shown
+ if ( GetDPMember() && !GetDPMember()->getShowDetails() )
+ {
+ // Wang Xu Ming -- 2009-6-16
+ // Show DataLayout dimention
+ nMemberStep = 1;
+ while ( nPos < ppDim.size() )
+ {
+ if ( ppDim[nPos] ->getIsDataLayoutDimension() )
+ {
+ if ( !pChildDimension )
+ pChildDimension = new ScDPResultDimension( pResultData );
+ pChildDimension->InitFrom( ppDim, ppLev, nPos, rInitState , FALSE );
+ return;
+ }
+ else
+ { //find next dim
+ nPos ++;
+ nMemberStep ++;
+ }
+ }
+ // End Comments
+ bHasHiddenDetails = TRUE; // only if there is a next dimension
+ return;
+ }
+
+ if ( bInitChild )
+ {
+ pChildDimension = new ScDPResultDimension( pResultData );
+ pChildDimension->InitFrom( ppDim, ppLev, nPos, rInitState, TRUE );
+ }
+}
+
+// Wang Xu Ming -- 2009-6-10
+// DataPilot Migration
+void ScDPNormalResultMember::LateInitFrom( LateInitParams& rParams/*const vector<ScDPDimension*>& ppDim, const vector<ScDPLevel*>& ppLev*/,
+ const vector< SCROW >& pItemData, size_t nPos,
+ ScDPInitState& rInitState )
+// End Comments
+{
+ // without LateInit, everything has already been initialized
+ if ( !pResultData->IsLateInit() )
+ return;
+
+ bInitialized = TRUE;
+
+ if ( rParams.IsEnd( nPos ) /*nPos >= ppDim.size()*/)
+ // No next dimension. Bail out.
+ return;
+
+ // skip child dimension if details are not shown
+ if ( GetDPMember() && !GetDPMember()->getShowDetails() )
+ {
+ // Wang Xu Ming -- 2009-6-16
+ // DataPilot Migration
+ // Show DataLayout dimention
+ nMemberStep = 1;
+ while ( !rParams.IsEnd( nPos ) )
+ {
+ if ( rParams.GetDim( nPos ) ->getIsDataLayoutDimension() )
+ {
+ if ( !pChildDimension )
+ pChildDimension = new ScDPResultDimension( pResultData );
+ rParams.SetInitChild( FALSE );
+ pChildDimension->LateInitFrom( rParams, pItemData, nPos, rInitState );
+ return;
+ }
+ else
+ { //find next dim
+ nPos ++;
+ nMemberStep ++;
+ }
+ }
+ // End Comments
+ bHasHiddenDetails = TRUE; // only if there is a next dimension
+ return;
+ }
+
+ // LateInitFrom is called several times...
+ if ( rParams.GetInitChild() )
+ {
+ if ( !pChildDimension )
+ pChildDimension = new ScDPResultDimension( pResultData );
+ pChildDimension->LateInitFrom( rParams, pItemData, nPos, rInitState );
+ }
+}
+
+BOOL ScDPNormalResultMember::IsSubTotalInTitle(long nMeasure) const
+{
+ BOOL bRet = FALSE;
+ if ( pChildDimension && /*pParentLevel*/GetParentLevel() &&
+ /*pParentLevel*/GetParentLevel()->IsOutlineLayout() && /*pParentLevel*/GetParentLevel()->IsSubtotalsAtTop() )
+ {
+ long nUserSubStart;
+ long nSubTotals = GetSubTotalCount( &nUserSubStart );
+ nSubTotals -= nUserSubStart; // visible count
+ if ( nSubTotals )
+ {
+ if ( nMeasure == SC_DPMEASURE_ALL )
+ nSubTotals *= pResultData->GetMeasureCount(); // number of subtotals that will be inserted
+
+ // only a single subtotal row will be shown in the outline title row
+ if ( nSubTotals == 1 )
+ bRet = TRUE;
+ }
+ }
+ return bRet;
+}
+
+long ScDPNormalResultMember::GetSize(long nMeasure) const
+{
+ if ( !IsVisible() )
+ return 0;
+ const ScDPLevel* pParentLevel = GetParentLevel();
+ long nExtraSpace = 0;
+ if ( pParentLevel && pParentLevel->IsAddEmpty() )
+ ++nExtraSpace;
+
+ if ( pChildDimension )
+ {
+ // outline layout takes up an extra row for the title only if subtotals aren't shown in that row
+ if ( pParentLevel && pParentLevel->IsOutlineLayout() && !IsSubTotalInTitle( nMeasure ) )
+ ++nExtraSpace;
+
+ long nSize = pChildDimension->GetSize(nMeasure);
+ long nUserSubStart;
+ long nUserSubCount = GetSubTotalCount( &nUserSubStart );
+ nUserSubCount -= nUserSubStart; // for output size, use visible count
+ if ( nUserSubCount )
+ {
+ if ( nMeasure == SC_DPMEASURE_ALL )
+ nSize += pResultData->GetMeasureCount() * nUserSubCount;
+ else
+ nSize += nUserSubCount;
+ }
+ return nSize + nExtraSpace;
+ }
+ else
+ {
+ if ( nMeasure == SC_DPMEASURE_ALL )
+ return pResultData->GetMeasureCount() + nExtraSpace;
+ else
+ return 1 + nExtraSpace;
+ }
+}
+
+
+BOOL ScDPNormalResultMember::IsVisible() const
+{
+ // not initialized -> shouldn't be there at all
+ // (allocated only to preserve ordering)
+ const ScDPLevel* pParentLevel = GetParentLevel();
+ return ( bHasElements || ( pParentLevel && pParentLevel->getShowEmpty() ) ) && IsValid() && bInitialized;
+}
+
+BOOL ScDPNormalResultMember::IsValid() const
+{
+ // non-Valid members are left out of calculation
+
+ // was member set no invisible at the DataPilotSource?
+ const ScDPMember* pMemberDesc =GetDPMember();
+ if ( pMemberDesc && !pMemberDesc->getIsVisible() )
+ return FALSE;
+
+ if ( bAutoHidden )
+ return FALSE;
+
+ return TRUE;
+}
+
+BOOL ScDPNormalResultMember::HasHiddenDetails() const
+{
+ // bHasHiddenDetails is set only if the "show details" flag is off,
+ // and there was a child dimension to skip
+
+ return bHasHiddenDetails;
+}
+
+long ScDPNormalResultMember::GetSubTotalCount( long* pUserSubStart ) const
+{
+ if ( pUserSubStart )
+ *pUserSubStart = 0; // default
+
+ const ScDPLevel* pParentLevel = GetParentLevel();
+
+ if ( bForceSubTotal ) // set if needed for root members
+ return 1; // grand total is always "automatic"
+ else if ( pParentLevel )
+ {
+ //! direct access via ScDPLevel
+
+ uno::Sequence<sheet::GeneralFunction> aSeq = pParentLevel->getSubTotals();
+ long nSequence = aSeq.getLength();
+ if ( nSequence && aSeq[0] != sheet::GeneralFunction_AUTO )
+ {
+ // For manual subtotals, always add "automatic" as first function
+ // (used for calculation, but not for display, needed for sorting, see lcl_GetForceFunc)
+
+ ++nSequence;
+ if ( pUserSubStart )
+ *pUserSubStart = 1; // visible subtotals start at 1
+ }
+ return nSequence;
+ }
+ else
+ return 0;
+}
+
+void ScDPNormalResultMember::ProcessData( const vector< SCROW >& aChildMembers, const ScDPResultDimension* pDataDim,
+ const vector< SCROW >& aDataMembers, const vector<ScDPValueData>& aValues )
+{
+ SetHasElements();
+
+ if (pChildDimension)
+ pChildDimension->ProcessData( aChildMembers, pDataDim, aDataMembers, aValues );
+
+ if ( !pDataRoot )
+ {
+ pDataRoot = new ScDPDataMember( pResultData, NULL );
+ if ( pDataDim )
+ pDataRoot->InitFrom( pDataDim ); // recursive
+ }
+
+ ScDPSubTotalState aSubState; // initial state
+
+ long nUserSubCount = GetSubTotalCount();
+
+ // Calculate at least automatic if no subtotals are selected,
+ // show only own values if there's no child dimension (innermost).
+ if ( !nUserSubCount || !pChildDimension )
+ nUserSubCount = 1;
+
+ const ScDPLevel* pParentLevel = GetParentLevel();
+
+ for (long nUserPos=0; nUserPos<nUserSubCount; nUserPos++) // including hidden "automatic"
+ {
+ // #i68338# if nUserSubCount is 1 (automatic only), don't set nRowSubTotalFunc
+ if ( pChildDimension && nUserSubCount > 1 )
+ {
+ aSubState.nRowSubTotalFunc = nUserPos;
+ aSubState.eRowForce = lcl_GetForceFunc( pParentLevel, nUserPos );
+ }
+
+ pDataRoot->ProcessData( aDataMembers, aValues, aSubState );
+ }
+}
+
+void ScDPNormalResultMember::FillMemberResults( uno::Sequence<sheet::MemberResult>* pSequences,
+ long& rPos, long nMeasure, BOOL bRoot,
+ const String* pMemberName,
+ const String* pMemberCaption )
+{
+ // IsVisible() test is in ScDPResultDimension::FillMemberResults
+ // (not on data layout dimension)
+
+ long nSize = GetSize(nMeasure);
+ sheet::MemberResult* pArray = pSequences->getArray();
+ DBG_ASSERT( rPos+nSize <= pSequences->getLength(), "bumm" );
+
+ BOOL bIsNumeric = FALSE;
+ String aName;
+ if ( pMemberName ) // if pMemberName != NULL, use instead of real member name
+ aName = *pMemberName;
+ else
+ {
+ ScDPItemData aItemData;
+ FillItemData( aItemData );
+ aName = aItemData.GetString();
+ bIsNumeric = aItemData.IsValue();
+ }
+ const ScDPDimension* pParentDim = GetParentDim();
+ if ( bIsNumeric && pParentDim && pResultData->IsNumOrDateGroup( pParentDim->GetDimension() ) )
+ {
+ // Numeric group dimensions use numeric entries for proper sorting,
+ // but the group titles must be output as text.
+ bIsNumeric = FALSE;
+ }
+
+ String aCaption = aName;
+ if ( pMemberCaption ) // use pMemberCaption if != NULL
+ aCaption = *pMemberCaption;
+ if (!aCaption.Len())
+ aCaption = ScGlobal::GetRscString(STR_EMPTYDATA);
+
+ if ( !bIsNumeric )
+ {
+ // add a "'" character so a string isn't parsed as value in the output cell
+ //! have a separate bit in Flags (MemberResultFlags) instead?
+ aCaption.Insert( (sal_Unicode) '\'', 0 );
+ }
+
+ if ( nSize && !bRoot ) // root is overwritten by first dimension
+ {
+ pArray[rPos].Name = rtl::OUString(aName);
+ pArray[rPos].Caption = rtl::OUString(aCaption);
+ pArray[rPos].Flags |= sheet::MemberResultFlags::HASMEMBER;
+
+ // set "continue" flag (removed for subtotals later)
+ for (long i=1; i<nSize; i++)
+ pArray[rPos+i].Flags |= sheet::MemberResultFlags::CONTINUE;
+ }
+
+ const ScDPLevel* pParentLevel = GetParentLevel();
+ long nExtraSpace = 0;
+ if ( pParentLevel && pParentLevel->IsAddEmpty() )
+ ++nExtraSpace;
+
+ BOOL bTitleLine = FALSE;
+ if ( pParentLevel && pParentLevel->IsOutlineLayout() )
+ bTitleLine = TRUE;
+
+ // if the subtotals are shown at the top (title row) in outline layout,
+ // no extra row for the subtotals is needed
+ BOOL bSubTotalInTitle = IsSubTotalInTitle( nMeasure );
+
+ BOOL bHasChild = ( pChildDimension != NULL );
+ if (bHasChild)
+ {
+ if ( bTitleLine ) // in tabular layout the title is on a separate row
+ ++rPos; // -> fill child dimension one row below
+
+ if (bRoot) // same sequence for root member
+ pChildDimension->FillMemberResults( pSequences, rPos, nMeasure );
+ else
+ // Wang Xu Ming -- 2009-6-16
+ // DataPilot Migration
+ // for show details
+ pChildDimension->FillMemberResults( pSequences + nMemberStep/*1*/, rPos, nMeasure );
+ // End Comments
+
+ if ( bTitleLine ) // title row is included in GetSize, so the following
+ --rPos; // positions are calculated with the normal values
+ }
+
+ rPos += nSize;
+
+ long nUserSubStart;
+ long nUserSubCount = GetSubTotalCount(&nUserSubStart);
+ if ( nUserSubCount && pChildDimension && !bSubTotalInTitle )
+ {
+ long nMemberMeasure = nMeasure;
+ long nSubSize = pResultData->GetCountForMeasure(nMeasure);
+
+ rPos -= nSubSize * (nUserSubCount - nUserSubStart); // GetSize includes space for SubTotal
+ rPos -= nExtraSpace; // GetSize includes the empty line
+
+ for (long nUserPos=nUserSubStart; nUserPos<nUserSubCount; nUserPos++)
+ {
+ for ( long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
+ {
+ if ( nMeasure == SC_DPMEASURE_ALL )
+ nMemberMeasure = nSubCount;
+
+ ScSubTotalFunc eForce = SUBTOTAL_FUNC_NONE;
+ if (bHasChild)
+ eForce = lcl_GetForceFunc( pParentLevel, nUserPos );
+
+ String aSubStr = aName; //! caption?
+ aSubStr += ' ';
+ aSubStr += pResultData->GetMeasureString(nMemberMeasure, FALSE, eForce);
+
+ pArray[rPos].Name = rtl::OUString(aName);
+ pArray[rPos].Caption = rtl::OUString(aSubStr);
+ pArray[rPos].Flags = ( pArray[rPos].Flags |
+ ( sheet::MemberResultFlags::HASMEMBER | sheet::MemberResultFlags::SUBTOTAL) ) &
+ ~sheet::MemberResultFlags::CONTINUE;
+
+ if ( nMeasure == SC_DPMEASURE_ALL )
+ {
+ // data layout dimension is (direct/indirect) child of this.
+ // data layout dimension must have name for all entries.
+
+ uno::Sequence<sheet::MemberResult>* pLayoutSeq = pSequences;
+ if (!bRoot)
+ ++pLayoutSeq;
+ ScDPResultDimension* pLayoutDim = pChildDimension;
+ while ( pLayoutDim && !pLayoutDim->IsDataLayout() )
+ {
+ pLayoutDim = pLayoutDim->GetFirstChildDimension();
+ ++pLayoutSeq;
+ }
+ if ( pLayoutDim )
+ {
+ sheet::MemberResult* pLayoutArray = pLayoutSeq->getArray();
+ String aDataName = pResultData->GetMeasureDimensionName(nMemberMeasure);
+ pLayoutArray[rPos].Name = rtl::OUString(aDataName);
+ }
+ }
+
+ rPos += 1;
+ }
+ }
+
+ rPos += nExtraSpace; // add again (subtracted above)
+ }
+}
+
+void ScDPNormalResultMember::FillDataResults( const ScDPResultMember* pRefMember,
+ uno::Sequence< uno::Sequence<sheet::DataResult> >& rSequence,
+ long& rRow, long nMeasure ) const
+{
+ // IsVisible() test is in ScDPResultDimension::FillDataResults
+ // (not on data layout dimension)
+ const ScDPLevel* pParentLevel = GetParentLevel();
+ long nStartRow = rRow;
+
+ long nExtraSpace = 0;
+ if ( pParentLevel && pParentLevel->IsAddEmpty() )
+ ++nExtraSpace;
+
+ BOOL bTitleLine = FALSE;
+ if ( pParentLevel && pParentLevel->IsOutlineLayout() )
+ bTitleLine = TRUE;
+
+ BOOL bSubTotalInTitle = IsSubTotalInTitle( nMeasure );
+
+ BOOL bHasChild = ( pChildDimension != NULL );
+ if (bHasChild)
+ {
+ if ( bTitleLine ) // in tabular layout the title is on a separate row
+ ++rRow; // -> fill child dimension one row below
+
+ pChildDimension->FillDataResults( pRefMember, rSequence, rRow, nMeasure ); // doesn't modify rRow
+ rRow += (USHORT) GetSize( nMeasure );
+
+ if ( bTitleLine ) // title row is included in GetSize, so the following
+ --rRow; // positions are calculated with the normal values
+ }
+
+ long nUserSubStart;
+ long nUserSubCount = GetSubTotalCount(&nUserSubStart);
+ if ( nUserSubCount || !bHasChild )
+ {
+ // Calculate at least automatic if no subtotals are selected,
+ // show only own values if there's no child dimension (innermost).
+ if ( !nUserSubCount || !bHasChild )
+ {
+ nUserSubCount = 1;
+ nUserSubStart = 0;
+ }
+
+ long nMemberMeasure = nMeasure;
+ long nSubSize = pResultData->GetCountForMeasure(nMeasure);
+ if (bHasChild)
+ {
+ rRow -= nSubSize * ( nUserSubCount - nUserSubStart ); // GetSize includes space for SubTotal
+ rRow -= nExtraSpace; // GetSize includes the empty line
+ }
+
+ long nMoveSubTotal = 0;
+ if ( bSubTotalInTitle )
+ {
+ nMoveSubTotal = rRow - nStartRow; // force to first (title) row
+ rRow = nStartRow;
+ }
+
+ if ( pDataRoot )
+ {
+ ScDPSubTotalState aSubState; // initial state
+
+ for (long nUserPos=nUserSubStart; nUserPos<nUserSubCount; nUserPos++)
+ {
+ if ( bHasChild && nUserSubCount > 1 )
+ {
+ aSubState.nRowSubTotalFunc = nUserPos;
+ aSubState.eRowForce = lcl_GetForceFunc( /*pParentLevel*/GetParentLevel() , nUserPos );
+ }
+
+ for ( long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
+ {
+ if ( nMeasure == SC_DPMEASURE_ALL )
+ nMemberMeasure = nSubCount;
+ else if ( pResultData->GetColStartMeasure() == SC_DPMEASURE_ALL )
+ nMemberMeasure = SC_DPMEASURE_ALL;
+
+ DBG_ASSERT( rRow < rSequence.getLength(), "bumm" );
+ uno::Sequence<sheet::DataResult>& rSubSeq = rSequence.getArray()[rRow];
+ long nSeqCol = 0;
+ pDataRoot->FillDataRow( pRefMember, rSubSeq, nSeqCol, nMemberMeasure, bHasChild, aSubState );
+
+ rRow += 1;
+ }
+ }
+ }
+ else
+ rRow += nSubSize * ( nUserSubCount - nUserSubStart ); // empty rows occur when ShowEmpty is true
+
+ // add extra space again if subtracted from GetSize above,
+ // add to own size if no children
+ rRow += nExtraSpace;
+
+ rRow += nMoveSubTotal;
+ }
+}
+
+void ScDPNormalResultMember::UpdateDataResults( const ScDPResultMember* pRefMember, long nMeasure ) const
+{
+ // IsVisible() test is in ScDPResultDimension::FillDataResults
+ // (not on data layout dimension)
+
+ BOOL bHasChild = ( pChildDimension != NULL );
+
+ long nUserSubCount = GetSubTotalCount();
+ // process subtotals even if not shown
+// if ( nUserSubCount || !bHasChild )
+ {
+ // Calculate at least automatic if no subtotals are selected,
+ // show only own values if there's no child dimension (innermost).
+ if ( !nUserSubCount || !bHasChild )
+ nUserSubCount = 1;
+
+ long nMemberMeasure = nMeasure;
+ long nSubSize = pResultData->GetCountForMeasure(nMeasure);
+
+ if ( pDataRoot )
+ {
+ ScDPSubTotalState aSubState; // initial state
+
+ for (long nUserPos=0; nUserPos<nUserSubCount; nUserPos++) // including hidden "automatic"
+ {
+ if ( bHasChild && nUserSubCount > 1 )
+ {
+ aSubState.nRowSubTotalFunc = nUserPos;
+ aSubState.eRowForce = lcl_GetForceFunc( /*pParentLevel*/GetParentLevel() , nUserPos );
+ }
+
+ for ( long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
+ {
+ if ( nMeasure == SC_DPMEASURE_ALL )
+ nMemberMeasure = nSubCount;
+ else if ( pResultData->GetColStartMeasure() == SC_DPMEASURE_ALL )
+ nMemberMeasure = SC_DPMEASURE_ALL;
+
+ pDataRoot->UpdateDataRow( pRefMember, nMemberMeasure, bHasChild, aSubState );
+ }
+ }
+ }
+ }
+
+ if (bHasChild) // child dimension must be processed last, so the column total is known
+ {
+ pChildDimension->UpdateDataResults( pRefMember, nMeasure );
+ }
+}
+
+void ScDPNormalResultMember::SortMembers( ScDPResultMember* pRefMember )
+{
+ BOOL bHasChild = ( pChildDimension != NULL );
+ if (bHasChild)
+ pChildDimension->SortMembers( pRefMember ); // sorting is done at the dimension
+
+ if ( IsRoot() && pDataRoot )
+ {
+ // use the row root member to sort columns
+ // sub total count is always 1
+
+ pDataRoot->SortMembers( pRefMember );
+ }
+}
+
+void ScDPNormalResultMember::DoAutoShow( ScDPResultMember* pRefMember )
+{
+ BOOL bHasChild = ( pChildDimension != NULL );
+ if (bHasChild)
+ pChildDimension->DoAutoShow( pRefMember ); // sorting is done at the dimension
+
+ if ( IsRoot()&& pDataRoot )
+ {
+ // use the row root member to sort columns
+ // sub total count is always 1
+
+ pDataRoot->DoAutoShow( pRefMember );
+ }
+}
+
+void ScDPNormalResultMember::ResetResults( BOOL bRoot )
+{
+ if (pDataRoot)
+ pDataRoot->ResetResults();
+
+ if (pChildDimension)
+ pChildDimension->ResetResults();
+
+// Wang Xu Ming -- 3/4/2009
+// Dim refresh and filter. SODC_19023
+ // if (!bRoot)
+ // bHasElements = FALSE;
+// End Comments
+}
+
+void ScDPNormalResultMember::UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure,
+ ScDPRunningTotalState& rRunning, ScDPRowTotals& rTotals ) const
+{
+ // IsVisible() test is in ScDPResultDimension::FillDataResults
+ // (not on data layout dimension)
+
+ rTotals.SetInColRoot( IsRoot() );
+
+ BOOL bHasChild = ( pChildDimension != NULL );
+
+ long nUserSubCount = GetSubTotalCount();
+ if ( nUserSubCount || !bHasChild )
+ {
+ // Calculate at least automatic if no subtotals are selected,
+ // show only own values if there's no child dimension (innermost).
+ if ( !nUserSubCount || !bHasChild )
+ nUserSubCount = 1;
+
+ long nMemberMeasure = nMeasure;
+ long nSubSize = pResultData->GetCountForMeasure(nMeasure);
+
+ if ( pDataRoot )
+ {
+ ScDPSubTotalState aSubState; // initial state
+
+ for (long nUserPos=0; nUserPos<nUserSubCount; nUserPos++) // including hidden "automatic"
+ {
+ if ( bHasChild && nUserSubCount > 1 )
+ {
+ aSubState.nRowSubTotalFunc = nUserPos;
+ aSubState.eRowForce = lcl_GetForceFunc( /*pParentLevel*/GetParentLevel(), nUserPos );
+ }
+
+ for ( long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
+ {
+ if ( nMeasure == SC_DPMEASURE_ALL )
+ nMemberMeasure = nSubCount;
+ else if ( pResultData->GetColStartMeasure() == SC_DPMEASURE_ALL )
+ nMemberMeasure = SC_DPMEASURE_ALL;
+
+ pDataRoot->UpdateRunningTotals( pRefMember, nMemberMeasure,
+ bHasChild, aSubState, rRunning, rTotals, *this );
+ }
+ }
+ }
+ }
+
+ if (bHasChild) // child dimension must be processed last, so the column total is known
+ {
+ pChildDimension->UpdateRunningTotals( pRefMember, nMeasure, rRunning, rTotals );
+ }
+}
+
+void ScDPNormalResultMember::DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const
+{
+ lcl_DumpRow( String::CreateFromAscii("ScDPResultMember"), GetName(), NULL, pDoc, rPos );
+ SCROW nStartRow = rPos.Row();
+
+ if (pDataRoot)
+ pDataRoot->DumpState( pRefMember, pDoc, rPos );
+
+ if (pChildDimension)
+ pChildDimension->DumpState( pRefMember, pDoc, rPos );
+
+ lcl_Indent( pDoc, nStartRow, rPos );
+}
+
+ScDPAggData* ScDPNormalResultMember::GetColTotal( long nMeasure ) const
+{
+ return lcl_GetChildTotal( const_cast<ScDPAggData*>(&aColTotal), nMeasure );
+}
+
+void ScDPNormalResultMember::FillVisibilityData(ScDPResultVisibilityData& rData) const
+{
+ if (pChildDimension)
+ pChildDimension->FillVisibilityData(rData);
+}
+// Wang Xu Ming -- 2009-6-10
+// DataPilot Migration
+SCROW ScDPNormalResultMember::GetDataId( ) const
+{
+// TODO:
+ const ScDPMember* pMemberDesc = GetDPMember();
+ if (pMemberDesc)
+ return pMemberDesc->GetItemDataId();
+ return -1;
+}
+
+// -----------------------------------------------------------------------
+ScDPHideDetailsMember:: ScDPHideDetailsMember( const ScDPResultData* pData, const ScDPParentDimData& rParentDimData,
+ BOOL bForceSub ):ScDPResultMember(pData,rParentDimData, bForceSub)
+{
+ pOrigMember = new ScDPNormalResultMember(pData,rParentDimData, bForceSub);
+
+} \ No newline at end of file
diff --git a/sc/source/core/data/dptabresmember.hxx b/sc/source/core/data/dptabresmember.hxx
new file mode 100644
index 000000000000..72657167d07d
--- /dev/null
+++ b/sc/source/core/data/dptabresmember.hxx
@@ -0,0 +1,161 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright IBM Corporation 2009.
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: dptabresmember.hxx,v $
+ * $Revision: 1.0 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DPTABRESMEMBER_HXX
+#define DPTABRESMEMBER_HXX
+
+class ScDPNormalResultMember: public ScDPResultMember
+{
+private:
+ // Wang Xu Ming -- 2009-6-9
+ // DataPilot Migration
+ ScDPParentDimData aParentDimData;
+ // End Comments
+ BOOL bHasElements:1;
+ BOOL bForceSubTotal:1;
+ BOOL bHasHiddenDetails:1;
+ BOOL bInitialized:1;
+ BOOL bAutoHidden:1;
+ ScDPAggData aColTotal; // to store column totals
+
+// Wang Xu Ming -- 2009-6-9
+// DataPilot Migration
+ USHORT nMemberStep; // step to show details
+// End Comments
+public:
+ // Wang Xu Ming -- 2009-6-9
+ // DataPilot Migration
+ ScDPNormalResultMember( const ScDPResultData* pData, const ScDPParentDimData& rParentDimData,
+ BOOL bForceSub ); //! Ref
+ ScDPNormalResultMember( const ScDPResultData* pData, BOOL bForceSub );
+ // End Comments
+ ~ScDPNormalResultMember();
+
+ // Wang Xu Ming -- 2009-6-9
+ // DataPilot Migration
+ // Add parameter: BOOL bInitChild
+ void InitFrom( const ::std::vector<ScDPDimension*>& ppDim,
+ const ::std::vector<ScDPLevel*>& ppLev,
+ size_t nPos,
+ ScDPInitState& rInitState,
+ BOOL bInitChild = TRUE );
+ // End Comments
+ // Wang Xu Ming -- 2009-6-9
+ // DataPilot Migration
+ void LateInitFrom(
+ LateInitParams& rParams,
+ const ::std::vector< SCROW >& pItemData,
+ size_t nPos,
+ ScDPInitState& rInitState);
+ // End Comments
+
+ String GetName() const;
+ void FillItemData( ScDPItemData& rData ) const;
+ BOOL IsValid() const;
+ BOOL IsVisible() const;
+ long GetSize(long nMeasure) const;
+ BOOL HasHiddenDetails() const;
+ BOOL IsSubTotalInTitle(long nMeasure) const;
+
+// BOOL SubTotalEnabled() const;
+ long GetSubTotalCount( long* pUserSubStart = NULL ) const;
+
+// Wang Xu Ming -- 2009-6-9
+// DataPilot Migration
+// Use item index
+// BOOL IsNamedItem( const ScDPItemData& r ) const;
+ BOOL IsNamedItem( SCROW nIndex ) const;
+// End Comments
+ bool IsValidEntry( const ::std::vector< SCROW >& aMembers ) const;
+ ENTRYSTATUS GetEntryStatus( const ::std::vector<SCROW>& aMembers ) const;
+
+ void SetHasElements() { bHasElements = TRUE; }
+ void SetAutoHidden() { bAutoHidden = TRUE; }
+
+ void ProcessData( const ::std::vector<SCROW>& aChildMembers,
+ const ScDPResultDimension* pDataDim,
+ const ::std::vector<SCROW>& aDataMembers,
+ const ::std::vector<ScDPValueData>& aValues );
+
+ void FillMemberResults( com::sun::star::uno::Sequence<
+ com::sun::star::sheet::MemberResult>* pSequences,
+ long& rPos, long nMeasure, BOOL bRoot,
+ const String* pMemberName,
+ const String* pMemberCaption );
+
+ void FillDataResults( const ScDPResultMember* pRefMember,
+ com::sun::star::uno::Sequence<
+ com::sun::star::uno::Sequence<
+ com::sun::star::sheet::DataResult> >& rSequence,
+ long& rRow, long nMeasure ) const;
+
+ void UpdateDataResults( const ScDPResultMember* pRefMember, long nMeasure ) const;
+ void UpdateRunningTotals( const ScDPResultMember* pRefMember, long nMeasure,
+ ScDPRunningTotalState& rRunning, ScDPRowTotals& rTotals ) const;
+
+ void SortMembers( ScDPResultMember* pRefMember );
+ void DoAutoShow( ScDPResultMember* pRefMember );
+
+ void ResetResults( BOOL bRoot );
+
+ void DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const;
+
+ // Wang Xu Ming -- 2009-6-9
+ // DataPilot Migration
+ const ScDPDimension* GetParentDim() const { return aParentDimData.mpParentDim; } //! Ref
+ const ScDPLevel* GetParentLevel() const { return aParentDimData.mpParentLevel; } //! Ref
+ const ScDPMember* GetDPMember()const { return aParentDimData.mpMemberDesc; } //! Ref
+ inline SCROW GetOrder() const { return aParentDimData.mnOrder; } //! Ref
+ inline BOOL IsRoot() const { return GetParentLevel() == NULL; }
+ // End Comments
+
+ ScDPAggData* GetColTotal( long nMeasure ) const;
+
+ void FillVisibilityData(ScDPResultVisibilityData& rData) const;
+// Wang Xu Ming -- 2009-6-10
+// DataPilot Migration
+ SCROW GetDataId( ) const ;
+// End Comments
+};
+
+class ScDPHideDetailsMember: public ScDPResultMember
+{
+private:
+ ScDPNormalResultMember * pOrigMember;
+public:
+ ScDPHideDetailsMember( const ScDPResultData* pData, const ScDPParentDimData& rParentDimData,
+ BOOL bForceSub );
+
+
+};
+
+
+#endif //DPTABRESMEMBER_HXX
diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx
index 205c14021444..da40e6e230c4 100644..100755
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -300,10 +300,11 @@ void ScDPSource::SetOrientation(long nColumn, USHORT nNew)
case sheet::DataPilotFieldOrientation_PAGE:
nPageDims[nPageDimCount++] = nColumn;
break;
+ // Wang Xu Ming -- 2009-9-1
+ // DataPilot Migration - Cache&&Performance
case sheet::DataPilotFieldOrientation_HIDDEN:
- /* Do not assert HIDDEN as it occurs e.g. while using the
- csss.XDataPilotTables.createDataPilotDescriptor() function. */
break;
+ // End Comments
default:
DBG_ERROR( "ScDPSource::SetOrientation: unexpected orientation" );
break;
@@ -325,6 +326,11 @@ BOOL ScDPSource::IsDateDimension(long nDim)
return pData->IsDateDimension(nDim);
}
+UINT32 ScDPSource::GetNumberFormat(long nDim)
+{
+ return pData->GetNumberFormat( nDim );
+}
+
ScDPDimensions* ScDPSource::GetDimensionsObject()
{
if (!pDimensions)
@@ -442,7 +448,6 @@ Sequence< Sequence<Any> > SAL_CALL ScDPSource::getDrillDownData(const Sequence<s
throw (uno::RuntimeException)
{
long nColumnCount = GetData()->GetColumnCount();
- ScSimpleSharedString& rSharedString = GetData()->GetSharedString();
typedef hash_map<String, long, ScStringHashCode> FieldNameMapType;
FieldNameMapType aFieldNames;
@@ -472,17 +477,16 @@ Sequence< Sequence<Any> > SAL_CALL ScDPSource::getDrillDownData(const Sequence<s
ScDPItemData aItem;
pMembers->getByIndex(nIndex)->FillItemData( aItem );
aFilterCriteria.push_back( ScDPCacheTable::Criterion() );
- sal_Int32 nMatchStrId = rSharedString.getStringId(aItem.aString);
aFilterCriteria.back().mnFieldIndex = nCol;
aFilterCriteria.back().mpFilter.reset(
- new ScDPCacheTable::SingleFilter(rSharedString, nMatchStrId, aItem.fValue, aItem.bHasValue) );
+ new ScDPCacheTable::SingleFilter(aItem.GetString()/*rSharedString, nMatchStrId*/, aItem.GetValue(), aItem.IsValue()) );
}
}
}
}
// Take into account the visibilities of field members.
- ScDPResultVisibilityData aResVisData(rSharedString, this);
+ ScDPResultVisibilityData aResVisData(/*rSharedString, */this);
pRowResRoot->FillVisibilityData(aResVisData);
pColResRoot->FillVisibilityData(aResVisData);
aResVisData.fillFieldFilters(aFilterCriteria);
@@ -737,7 +741,6 @@ void ScDPSource::GetCategoryDimensionIndices(hash_set<sal_Int32>& rCatDims)
void ScDPSource::FilterCacheTableByPageDimensions()
{
- ScSimpleSharedString& rSharedString = GetData()->GetSharedString();
// filter table by page dimensions.
vector<ScDPCacheTable::Criterion> aCriteria;
@@ -752,7 +755,7 @@ void ScDPSource::FilterCacheTableByPageDimensions()
long nMemCount = pMems->getCount();
ScDPCacheTable::Criterion aFilter;
aFilter.mnFieldIndex = static_cast<sal_Int32>(nField);
- aFilter.mpFilter.reset(new ScDPCacheTable::GroupFilter(rSharedString));
+ aFilter.mpFilter.reset(new ScDPCacheTable::GroupFilter(/*rSharedString*/));
ScDPCacheTable::GroupFilter* pGrpFilter =
static_cast<ScDPCacheTable::GroupFilter*>(aFilter.mpFilter.get());
for (long j = 0; j < nMemCount; ++j)
@@ -762,7 +765,7 @@ void ScDPSource::FilterCacheTableByPageDimensions()
{
ScDPItemData aData;
pMem->FillItemData(aData);
- pGrpFilter->addMatchItem(aData.aString, aData.fValue, aData.bHasValue);
+ pGrpFilter->addMatchItem(aData.GetString(), aData.GetValue(), aData.IsValue());
}
}
if (pGrpFilter->getMatchItemCount() < static_cast<size_t>(nMemCount))
@@ -776,9 +779,8 @@ void ScDPSource::FilterCacheTableByPageDimensions()
aCriteria.push_back(ScDPCacheTable::Criterion());
ScDPCacheTable::Criterion& r = aCriteria.back();
r.mnFieldIndex = static_cast<sal_Int32>(nField);
- sal_Int32 nStrId = rSharedString.getStringId(rData.aString);
r.mpFilter.reset(
- new ScDPCacheTable::SingleFilter(rSharedString, nStrId, rData.fValue, rData.bHasValue));
+ new ScDPCacheTable::SingleFilter(rData.GetString()/*rSharedString, nStrId*/, rData.GetValue(), rData.IsValue()));
}
if (!aCriteria.empty())
{
@@ -900,11 +902,11 @@ void ScDPSource::CreateRes_Impl()
{
ScDPDimension* pDim = GetDimensionsObject()->getByIndex( nPageDims[i] );
if ( pDim->HasSelectedPage() )
- aInitState.AddMember( nPageDims[i], pDim->GetSelectedData() );
+ aInitState.AddMember( nPageDims[i], GetMemberId( nPageDims[i], pDim->GetSelectedData() ) );
}
- pColResRoot = new ScDPResultMember( pResData, NULL, NULL, NULL, bColumnGrand );
- pRowResRoot = new ScDPResultMember( pResData, NULL, NULL, NULL, bRowGrand );
+ pColResRoot = new ScDPResultMember( pResData, /*NULL, NULL, NULL, */bColumnGrand );
+ pRowResRoot = new ScDPResultMember( pResData, /*NULL, NULL, NULL, */bRowGrand );
FillCalcInfo(false, aInfo, bHasAutoShow);
long nColLevelCount = aInfo.aColLevels.size();
@@ -944,7 +946,7 @@ void ScDPSource::CreateRes_Impl()
long nMinColMembers = lcl_CountMinMembers( aInfo.aColDims, aInfo.aColLevels, nColLevelCount );
long nMinRowMembers = lcl_CountMinMembers( aInfo.aRowDims, aInfo.aRowLevels, nRowLevelCount );
- if ( nMinColMembers > SC_MINCOUNT_LIMIT || nMinRowMembers > SC_MINCOUNT_LIMIT )
+ if ( nMinColMembers > MAXCOLCOUNT/*SC_MINCOUNT_LIMIT*/ || nMinRowMembers > SC_MINCOUNT_LIMIT )
{
// resulting table is too big -> abort before calculating
// (this relies on late init, so no members are allocated in InitFrom above)
@@ -964,6 +966,8 @@ void ScDPSource::CreateRes_Impl()
aInfo.pRowRoot = pRowResRoot;
pData->CalcResults(aInfo, false);
+ pColResRoot->CheckShowEmpty();
+ pRowResRoot->CheckShowEmpty();
// ----------------------------------------------------------------
// With all data processed, calculate the final results:
@@ -1549,6 +1553,19 @@ const ScDPItemData& ScDPDimension::GetSelectedData()
//UNUSED2009-05 return TRUE; // no selection -> all data
//UNUSED2009-05 }
+BOOL ScDPDimension::IsVisible( const ScDPItemData& rData )
+{
+ if( ScDPMembers* pMembers = this->GetHierarchiesObject()->getByIndex(0)->
+ GetLevelsObject()->getByIndex(0)->GetMembersObject() )
+ {
+ for( long i = pMembers->getCount()-1; i>=0; i-- )
+ if( ScDPMember *pDPMbr = pMembers->getByIndex( i ) )
+ if( rData.IsCaseInsEqual( pDPMbr->GetItemData() ) && !pDPMbr->getIsVisible() )
+ return FALSE;
+ }
+
+ return TRUE;
+}
// XPropertySet
uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDPDimension::getPropertySetInfo()
@@ -1692,6 +1709,23 @@ uno::Any SAL_CALL ScDPDimension::getPropertyValue( const rtl::OUString& aPropert
// #i63745# don't use source format for "count"
if ( eFunc != sheet::GeneralFunction_COUNT && eFunc != sheet::GeneralFunction_COUNTNUMS )
nFormat = pSource->GetData()->GetNumberFormat( ( nSourceDim >= 0 ) ? nSourceDim : nDim );
+
+ switch ( aReferenceValue.ReferenceType )
+ {
+ case sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE:
+ case sheet::DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE:
+ case sheet::DataPilotFieldReferenceType::ROW_PERCENTAGE:
+ case sheet::DataPilotFieldReferenceType::COLUMN_PERCENTAGE:
+ case sheet::DataPilotFieldReferenceType::TOTAL_PERCENTAGE:
+ nFormat = pSource->GetData()->GetNumberFormatByIdx( (NfIndexTableOffset)NF_PERCENT_DEC2 );
+ break;
+ case sheet::DataPilotFieldReferenceType::INDEX:
+ nFormat = pSource->GetData()->GetNumberFormatByIdx( (NfIndexTableOffset)NF_NUMBER_SYSTEM );
+ break;
+ default:
+ break;
+ }
+
aRet <<= nFormat;
}
else if ( aNameStr.EqualsAscii( SC_UNO_ORIGINAL ) )
@@ -2355,15 +2389,6 @@ SC_IMPL_DUMMY_PROPERTY_LISTENER( ScDPLevel )
// -----------------------------------------------------------------------
-USHORT lcl_GetFirstStringPos( const TypedScStrCollection& rColl )
-{
- USHORT nPos = 0;
- USHORT nCount = rColl.GetCount();
- while ( nPos < nCount && !rColl[nPos]->IsStrData() )
- ++nPos;
- return nPos;
-}
-
ScDPMembers::ScDPMembers( ScDPSource* pSrc, long nD, long nH, long nL ) :
pSource( pSrc ),
nDim( nD ),
@@ -2385,12 +2410,23 @@ ScDPMembers::ScDPMembers( ScDPSource* pSrc, long nD, long nH, long nL ) :
{
case SC_DAPI_LEVEL_YEAR:
{
- const TypedScStrCollection& rStrings = pSource->GetData()->GetColumnEntries(nSrcDim);
- USHORT nFirstString = lcl_GetFirstStringPos( rStrings );
- if ( nFirstString > 0 )
+ // Wang Xu Ming - DataPilot migration
+ const ScDPItemData* pLastNumData = NULL;
+ for ( SCROW n = 0 ;n <GetSrcItemsCount() ; n-- )
{
- double fFirstVal = rStrings[0]->GetValue();
- double fLastVal = rStrings[nFirstString-1]->GetValue();
+ const ScDPItemData* pData = GetSrcItemDataByIndex( n );
+ if ( pData && pData->HasStringData() )
+ break;
+ else
+ pLastNumData = pData;
+ }
+ // End Comments
+
+ if ( pLastNumData )
+ {
+ const ScDPItemData* pFirstData = GetSrcItemDataByIndex( 0 );
+ double fFirstVal = pFirstData->GetValue();
+ double fLastVal = pLastNumData->GetValue();
long nFirstYear = pSource->GetData()->GetDatePart(
(long)::rtl::math::approxFloor( fFirstVal ),
@@ -2427,11 +2463,7 @@ ScDPMembers::ScDPMembers( ScDPSource* pSrc, long nD, long nH, long nL ) :
}
}
else
- {
- // StringCollection is cached at TableData
- const TypedScStrCollection& rStrings = pSource->GetData()->GetColumnEntries(nSrcDim);
- nMbrCount = rStrings.GetCount();
- }
+ nMbrCount = pSource->GetData()->GetMembersCount( nSrcDim );
}
ScDPMembers::~ScDPMembers()
@@ -2567,8 +2599,7 @@ ScDPMember* ScDPMembers::getByIndex(long nIndex) const
if ( pSource->IsDataLayoutDimension(nSrcDim) )
{
// empty name (never shown, not used for lookup)
- pNew = new ScDPMember( pSource, nDim, nHier, nLev,
- String(), 0.0, FALSE );
+ pNew = new ScDPMember( pSource, nDim, nHier, nLev, 0 );
}
else if ( nHier != SC_DAPI_HIERARCHY_FLAT && pSource->IsDateDimension( nSrcDim ) )
{
@@ -2579,12 +2610,13 @@ ScDPMember* ScDPMembers::getByIndex(long nIndex) const
{
//! cache year range here!
- const TypedScStrCollection& rStrings = pSource->GetData()->GetColumnEntries(nSrcDim);
- double fFirstVal = rStrings[0]->GetValue();
+ // Wang Xu Ming - DataPilot migration
+ double fFirstVal = pSource->GetData()->GetMemberByIndex( nSrcDim, 0 )->GetValue();
long nFirstYear = pSource->GetData()->GetDatePart(
(long)::rtl::math::approxFloor( fFirstVal ),
nHier, nLev );
+ // End Comments
nVal = nFirstYear + nIndex;
}
else if ( nHier == SC_DAPI_HIERARCHY_WEEK && nLev == SC_DAPI_LEVEL_WEEKDAY )
@@ -2607,19 +2639,20 @@ ScDPMember* ScDPMembers::getByIndex(long nIndex) const
if ( !aName.Len() )
aName = String::CreateFromInt32(nVal);
- pNew = new ScDPMember( pSource, nDim, nHier, nLev, aName, nVal, TRUE );
+ ScDPItemData rData( aName, nVal, TRUE, 0 ) ;
+ pNew = new ScDPMember( pSource, nDim, nHier, nLev, pSource->GetCache()->GetAdditionalItemID(rData));
}
else
{
- const TypedScStrCollection& rStrings = pSource->GetData()->GetColumnEntries(nSrcDim);
- const TypedStrData* pData = rStrings[(USHORT)nIndex];
- pNew = new ScDPMember( pSource, nDim, nHier, nLev,
- pData->GetString(), pData->GetValue(), !pData->IsStrData() );
+ const std::vector< SCROW >& memberIndexs = pSource->GetData()->GetColumnEntries( nSrcDim );
+ pNew = new ScDPMember( pSource, nDim, nHier, nLev, memberIndexs[nIndex] );
}
pNew->acquire(); // ref-counted
ppMbrs[nIndex] = pNew;
}
+ DBG_ASSERT( ppMbrs[nIndex] ," member is not initialized " );
+
return ppMbrs[nIndex];
}
@@ -2629,12 +2662,12 @@ ScDPMember* ScDPMembers::getByIndex(long nIndex) const
// -----------------------------------------------------------------------
ScDPMember::ScDPMember( ScDPSource* pSrc, long nD, long nH, long nL,
- const String& rN, double fV, BOOL bHV ) :
+ SCROW nIndex /*const String& rN, double fV, BOOL bHV*/ ) :
pSource( pSrc ),
nDim( nD ),
nHier( nH ),
nLev( nL ),
- maData( rN, fV, bHV ),
+ mnDataId( nIndex ),
mpLayoutName(NULL),
nPosition( -1 ),
bVisible( TRUE ),
@@ -2651,17 +2684,36 @@ ScDPMember::~ScDPMember()
BOOL ScDPMember::IsNamedItem( const ScDPItemData& r ) const
{
long nSrcDim = pSource->GetSourceDim( nDim );
- if ( nHier != SC_DAPI_HIERARCHY_FLAT && pSource->IsDateDimension( nSrcDim ) && r.bHasValue )
+ if ( nHier != SC_DAPI_HIERARCHY_FLAT && pSource->IsDateDimension( nSrcDim ) && r.IsValue() )
{
long nComp = pSource->GetData()->GetDatePart(
- (long)::rtl::math::approxFloor( r.fValue ),
+ (long)::rtl::math::approxFloor( r.GetValue() ),
nHier, nLev );
// fValue is converted from integer, so simple comparison works
- return nComp == maData.fValue;
+ return nComp == GetItemData().GetValue();
}
- return r.IsCaseInsEqual( maData );
+ return r.IsCaseInsEqual( GetItemData() );
+}
+
+BOOL ScDPMember::IsNamedItem( SCROW nIndex ) const
+{
+ long nSrcDim = pSource->GetSourceDim( nDim );
+ if ( nHier != SC_DAPI_HIERARCHY_FLAT && pSource->IsDateDimension( nSrcDim ) )
+ {
+ const ScDPItemData* pData = pSource->GetCache()->GetItemDataById( (SCCOL) nSrcDim, nIndex );
+ if ( pData->IsValue() )
+ {
+ long nComp = pSource->GetData()->GetDatePart(
+ (long)::rtl::math::approxFloor( pData->GetValue() ),
+ nHier, nLev );
+ // fValue is converted from integer, so simple comparison works
+ return nComp == GetItemData().GetValue();
+ }
+ }
+
+ return nIndex == mnDataId;
}
sal_Int32 ScDPMember::Compare( const ScDPMember& rOther ) const
@@ -2686,14 +2738,14 @@ sal_Int32 ScDPMember::Compare( const ScDPMember& rOther ) const
}
// no positions set - compare names
- return ScDPItemData::Compare( maData, rOther.maData );
+ return pSource->GetData()->Compare( pSource->GetSourceDim(nDim),mnDataId,rOther.GetItemDataId());
}
void ScDPMember::FillItemData( ScDPItemData& rData ) const
{
//! handle date hierarchy...
- rData = maData;
+ rData = GetItemData() ;
}
const OUString* ScDPMember::GetLayoutName() const
@@ -2703,12 +2755,12 @@ const OUString* ScDPMember::GetLayoutName() const
String ScDPMember::GetNameStr() const
{
- return maData.aString;
+ return GetItemData().GetString();
}
::rtl::OUString SAL_CALL ScDPMember::getName() throw(uno::RuntimeException)
{
- return maData.aString;
+ return GetItemData().GetString();
}
void SAL_CALL ScDPMember::setName( const ::rtl::OUString& /* rNewName */ ) throw(uno::RuntimeException)
@@ -2822,4 +2874,48 @@ uno::Any SAL_CALL ScDPMember::getPropertyValue( const rtl::OUString& aPropertyNa
SC_IMPL_DUMMY_PROPERTY_LISTENER( ScDPMember )
+ScDPTableDataCache* ScDPSource::GetCache()
+{
+ DBG_ASSERT( GetData() , "empty ScDPTableData pointer");
+ return ( GetData()!=NULL) ? GetData()->GetCacheTable().GetCache() : NULL ;
+}
+
+const ScDPItemData& ScDPMember::GetItemData() const
+{
+ return *pSource->GetItemDataById( (SCCOL)nDim, mnDataId );//ms-cache-core
+}
+
+const ScDPItemData* ScDPSource::GetItemDataById(long nDim, long nId)
+{
+ long nSrcDim = GetSourceDim( nDim );
+ const ScDPItemData* pItemData = GetData()->GetMemberById( nSrcDim, nId );
+ if ( !pItemData )
+ { //todo:
+ ScDPItemData item;
+ nId = GetCache()->GetAdditionalItemID( item );
+ pItemData = GetData()->GetMemberById( nSrcDim, nId );
+ }
+ return pItemData;
+}
+
+SCROW ScDPSource::GetMemberId( long nDim, const ScDPItemData& rData )
+{
+ long nSrcDim = GetSourceDim( nDim );
+ return GetCache()->GetIdByItemData( nSrcDim, rData );
+}
+
+const ScDPItemData* ScDPMembers::GetSrcItemDataByIndex( SCROW nIndex)
+{
+ const std::vector< SCROW >& memberIds = pSource->GetData()->GetColumnEntries( nDim );
+ if ( nIndex >= (long )(memberIds.size()) || nIndex < 0 )
+ return NULL;
+ SCROW nId = memberIds[ nIndex ];
+ return pSource->GetItemDataById( nDim, nId );
+}
+
+ SCROW ScDPMembers::GetSrcItemsCount()
+ {
+ return pSource->GetData()->GetColumnEntries( nDim ).size();
+ }
+// End Comments
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index 4e9de6179809..3d7fc007818b 100644..100755
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -28,6 +28,7 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sc.hxx"
#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/chart/XChartDocument.hpp>
#include <com/sun/star/embed/XEmbeddedObject.hpp>
#include <com/sun/star/embed/XVisualObject.hpp>
#include <com/sun/star/embed/XClassifiedObject.hpp>
@@ -79,6 +80,7 @@
#include "chartarr.hxx"
#include "postit.hxx"
#include "attrib.hxx"
+#include "charthelper.hxx"
#define DET_ARROW_OFFSET 1000
@@ -454,7 +456,7 @@ inline BOOL IsInBlock( const ScAddress& rPos, SCCOL nCol1,SCROW nRow1, SCCOL nCo
}
void ScDrawLayer::MoveCells( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2,
- SCsCOL nDx,SCsROW nDy )
+ SCsCOL nDx,SCsROW nDy, bool bUpdateNoteCaptionPos )
{
SdrPage* pPage = GetPage(static_cast<sal_uInt16>(nTab));
DBG_ASSERT(pPage,"Page nicht gefunden");
@@ -490,13 +492,13 @@ void ScDrawLayer::MoveCells( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SC
if ( pObj->ISA( SdrRectObj ) && pData->maStart.IsValid() && pData->maEnd.IsValid() )
pData->maStart.PutInOrder( pData->maEnd );
AddCalcUndo( new ScUndoObjData( pObj, aOldStt, aOldEnd, pData->maStart, pData->maEnd ) );
- RecalcPos( pObj, *pData, bNegativePage );
+ RecalcPos( pObj, *pData, bNegativePage, bUpdateNoteCaptionPos );
}
}
}
}
-void ScDrawLayer::SetPageSize( USHORT nPageNo, const Size& rSize )
+void ScDrawLayer::SetPageSize( USHORT nPageNo, const Size& rSize, bool bUpdateNoteCaptionPos )
{
SdrPage* pPage = GetPage(nPageNo);
if (pPage)
@@ -519,34 +521,31 @@ void ScDrawLayer::SetPageSize( USHORT nPageNo, const Size& rSize )
SdrObject* pObj = pPage->GetObj( i );
ScDrawObjData* pData = GetObjDataTab( pObj, static_cast<SCTAB>(nPageNo) );
if( pData )
- RecalcPos( pObj, *pData, bNegativePage );
+ RecalcPos( pObj, *pData, bNegativePage, bUpdateNoteCaptionPos );
}
}
}
-void ScDrawLayer::RecalcPos( SdrObject* pObj, const ScDrawObjData& rData, bool bNegativePage )
+void ScDrawLayer::RecalcPos( SdrObject* pObj, const ScDrawObjData& rData, bool bNegativePage, bool bUpdateNoteCaptionPos )
{
DBG_ASSERT( pDoc, "ScDrawLayer::RecalcPos - missing document" );
if( !pDoc )
return;
- /* TODO CleanUp: Updating note position works just by chance currently...
- When inserting rows/columns, this function is called after the
- insertion, and the note is located at the new position contained in the
- passed ScDrawObjData already. But when deleting rows/columns, this
- function is called *before* the deletion, so the note is still at the
- old cell position, and ScDocument::GetNote() will fail to get the note
- or will get another note. But after the rows/columns are deleted, a
- call to ScDrawLayer::SetPageSize() will call this function again, and
- now the note is at the expected position in the document. */
if( rData.mbNote )
{
DBG_ASSERT( rData.maStart.IsValid(), "ScDrawLayer::RecalcPos - invalid position for cell note" );
- /* When inside an undo action, there may be pending note captions
- where cell note is already deleted. The caption will be deleted
- later with drawing undo. */
- if( ScPostIt* pNote = pDoc->GetNote( rData.maStart ) )
- pNote->UpdateCaptionPos( rData.maStart );
+ /* #i109372# On insert/remove rows/columns/cells: Updating the caption
+ position must not be done, if the cell containing the note has not
+ been moved yet in the document. The calling code now passes an
+ additional boolean stating if the cells are already moved. */
+ if( bUpdateNoteCaptionPos )
+ /* When inside an undo action, there may be pending note captions
+ where cell note is already deleted (thus document cannot find
+ the note object anymore). The caption will be deleted later
+ with drawing undo. */
+ if( ScPostIt* pNote = pDoc->GetNote( rData.maStart ) )
+ pNote->UpdateCaptionPos( rData.maStart );
return;
}
@@ -1018,7 +1017,7 @@ void ScDrawLayer::MoveAreaTwips( SCTAB nTab, const Rectangle& rArea,
}
void ScDrawLayer::MoveArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2,
- SCsCOL nDx,SCsROW nDy, BOOL bInsDel )
+ SCsCOL nDx,SCsROW nDy, BOOL bInsDel, bool bUpdateNoteCaptionPos )
{
DBG_ASSERT( pDoc, "ScDrawLayer::MoveArea without document" );
if ( !pDoc )
@@ -1067,7 +1066,7 @@ void ScDrawLayer::MoveArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCR
// Detektiv-Pfeile: Zellpositionen anpassen
//
- MoveCells( nTab, nCol1,nRow1, nCol2,nRow2, nDx,nDy );
+ MoveCells( nTab, nCol1,nRow1, nCol2,nRow2, nDx,nDy, bUpdateNoteCaptionPos );
}
void ScDrawLayer::WidthChanged( SCTAB nTab, SCCOL nCol, long nDifTwips )
@@ -1386,7 +1385,9 @@ void ScDrawLayer::CopyToClip( ScDocument* pClipDoc, SCTAB nTab, const Rectangle&
pNewObject->SetModel(pDestModel);
pNewObject->SetPage(pDestPage);
- pNewObject->NbcMove(Size(0,0));
+ uno::Reference< chart2::XChartDocument > xOldChart( ScChartHelper::GetChartFromSdrObject( pOldObject ) );
+ if(!xOldChart.is())//#i110034# do not move charts as they loose all their data references otherwise
+ pNewObject->NbcMove(Size(0,0));
pDestPage->InsertObject( pNewObject );
// no undo needed in clipboard document
@@ -1399,38 +1400,48 @@ void ScDrawLayer::CopyToClip( ScDocument* pClipDoc, SCTAB nTab, const Rectangle&
}
}
-BOOL lcl_IsAllInRange( const ScRangeList& rRanges, const ScRange& rClipRange )
+BOOL lcl_IsAllInRange( const ::std::vector< ScRangeList >& rRangesVector, const ScRange& rClipRange )
{
- // check if every range of rRanges is completely in rClipRange
+ // check if every range of rRangesVector is completely in rClipRange
- ULONG nCount = rRanges.Count();
- for (ULONG i=0; i<nCount; i++)
+ ::std::vector< ScRangeList >::const_iterator aIt = rRangesVector.begin();
+ for( ;aIt!=rRangesVector.end(); ++aIt )
{
- ScRange aRange = *rRanges.GetObject(i);
- if ( !rClipRange.In( aRange ) )
+ const ScRangeList& rRanges = *aIt;
+ ULONG nCount = rRanges.Count();
+ for (ULONG i=0; i<nCount; i++)
{
- return FALSE; // at least one range is not valid
+ ScRange aRange = *rRanges.GetObject(i);
+ if ( !rClipRange.In( aRange ) )
+ {
+ return FALSE; // at least one range is not valid
+ }
}
}
return TRUE; // everything is fine
}
-BOOL lcl_MoveRanges( ScRangeList& rRanges, const ScRange& rSourceRange, const ScAddress& rDestPos )
+BOOL lcl_MoveRanges( ::std::vector< ScRangeList >& rRangesVector, const ScRange& rSourceRange, const ScAddress& rDestPos )
{
BOOL bChanged = FALSE;
- ULONG nCount = rRanges.Count();
- for (ULONG i=0; i<nCount; i++)
+ ::std::vector< ScRangeList >::iterator aIt = rRangesVector.begin();
+ for( ;aIt!=rRangesVector.end(); ++aIt )
{
- ScRange* pRange = rRanges.GetObject(i);
- if ( rSourceRange.In( *pRange ) )
+ ScRangeList& rRanges = *aIt;
+ ULONG nCount = rRanges.Count();
+ for (ULONG i=0; i<nCount; i++)
{
- SCsCOL nDiffX = rDestPos.Col() - (SCsCOL)rSourceRange.aStart.Col();
- SCsROW nDiffY = rDestPos.Row() - (SCsROW)rSourceRange.aStart.Row();
- SCsTAB nDiffZ = rDestPos.Tab() - (SCsTAB)rSourceRange.aStart.Tab();
- pRange->Move( nDiffX, nDiffY, nDiffZ );
- bChanged = TRUE;
+ ScRange* pRange = rRanges.GetObject(i);
+ if ( rSourceRange.In( *pRange ) )
+ {
+ SCsCOL nDiffX = rDestPos.Col() - (SCsCOL)rSourceRange.aStart.Col();
+ SCsROW nDiffY = rDestPos.Row() - (SCsROW)rSourceRange.aStart.Row();
+ SCsTAB nDiffZ = rDestPos.Tab() - (SCsTAB)rSourceRange.aStart.Tab();
+ pRange->Move( nDiffX, nDiffY, nDiffZ );
+ bChanged = TRUE;
+ }
}
}
@@ -1469,6 +1480,37 @@ void ScDrawLayer::CopyFromClip( ScDrawLayer* pClipModel, SCTAB nSourceTab, const
if ( !pSrcPage || !pDestPage )
return;
+ SdrObjListIter aIter( *pSrcPage, IM_FLAT );
+ SdrObject* pOldObject = aIter.Next();
+
+ ScDocument* pClipDoc = pClipModel->GetDocument();
+ // a clipboard document and its source share the same document item pool,
+ // so the pointers can be compared to see if this is copy&paste within
+ // the same document
+ BOOL bSameDoc = pDoc && pClipDoc && pDoc->GetPool() == pClipDoc->GetPool();
+ BOOL bDestClip = pDoc && pDoc->IsClipboard();
+
+ //#i110034# charts need correct sheet names for xml range conversion during load
+ //so the target sheet name is temporarily renamed (if we have any SdrObjects)
+ String aDestTabName;
+ BOOL bRestoreDestTabName = FALSE;
+ if( pOldObject && !bSameDoc && !bDestClip )
+ {
+ if( pDoc && pClipDoc )
+ {
+ String aSourceTabName;
+ if( pClipDoc->GetName( nSourceTab, aSourceTabName )
+ && pDoc->GetName( nDestTab, aDestTabName ) )
+ {
+ if( !(aSourceTabName==aDestTabName) &&
+ pDoc->ValidNewTabName(aSourceTabName) )
+ {
+ bRestoreDestTabName = pDoc->RenameTab( nDestTab, aSourceTabName ); //BOOL bUpdateRef = TRUE, BOOL bExternalDocument = FALSE
+ }
+ }
+ }
+ }
+
// first mirror, then move
Size aMove( rDestRange.Left() - aMirroredSource.Left(), rDestRange.Top() - aMirroredSource.Top() );
@@ -1497,8 +1539,6 @@ void ScDrawLayer::CopyFromClip( ScDrawLayer* pClipModel, SCTAB nSourceTab, const
}
Point aRefPos = rDestRange.TopLeft(); // for resizing (after moving)
- SdrObjListIter aIter( *pSrcPage, IM_FLAT );
- SdrObject* pOldObject = aIter.Next();
while (pOldObject)
{
Rectangle aObjRect = pOldObject->GetCurrentBoundRect();
@@ -1522,7 +1562,7 @@ void ScDrawLayer::CopyFromClip( ScDrawLayer* pClipModel, SCTAB nSourceTab, const
if (bRecording)
AddCalcUndo( new SdrUndoInsertObj( *pNewObject ) );
- // handle chart data references (after InsertObject)
+ //#i110034# handle chart data references (after InsertObject)
if ( pNewObject->GetObjIdentifier() == OBJ_OLE2 )
{
@@ -1541,73 +1581,63 @@ void ScDrawLayer::CopyFromClip( ScDrawLayer* pClipModel, SCTAB nSourceTab, const
if ( xIPObj.is() && SotExchange::IsChart( aObjectClassName ) )
{
- String aNewName = ((SdrOle2Obj*)pNewObject)->GetPersistName();
-
- //! need to set new DataProvider, or does Chart handle this itself?
-
- ScRangeListRef xRanges( new ScRangeList );
- BOOL bColHeaders = FALSE;
- BOOL bRowHeaders = FALSE;
- pDoc->GetOldChartParameters( aNewName, *xRanges, bColHeaders, bRowHeaders );
-
- if ( xRanges->Count() > 0 )
+ uno::Reference< chart2::XChartDocument > xNewChart( ScChartHelper::GetChartFromSdrObject( pNewObject ) );
+ if( xNewChart.is() && !xNewChart->hasInternalDataProvider() )
{
- ScDocument* pClipDoc = pClipModel->GetDocument();
-
- // a clipboard document and its source share the same document item pool,
- // so the pointers can be compared to see if this is copy&paste within
- // the same document
- BOOL bSameDoc = pDoc && pClipDoc && pDoc->GetPool() == pClipDoc->GetPool();
-
- BOOL bDestClip = pDoc && pDoc->IsClipboard();
-
- BOOL bInSourceRange = FALSE;
- ScRange aClipRange;
- if ( pClipDoc )
+ String aChartName = ((SdrOle2Obj*)pNewObject)->GetPersistName();
+ ::std::vector< ScRangeList > aRangesVector;
+ pDoc->GetChartRanges( aChartName, aRangesVector, pDoc );
+ if( !aRangesVector.empty() )
{
- SCCOL nClipStartX;
- SCROW nClipStartY;
- SCCOL nClipEndX;
- SCROW nClipEndY;
- pClipDoc->GetClipStart( nClipStartX, nClipStartY );
- pClipDoc->GetClipArea( nClipEndX, nClipEndY, TRUE );
- nClipEndX = nClipEndX + nClipStartX;
- nClipEndY += nClipStartY; // GetClipArea returns the difference
-
- aClipRange = ScRange( nClipStartX, nClipStartY, nSourceTab,
- nClipEndX, nClipEndY, nSourceTab );
-
- bInSourceRange = lcl_IsAllInRange( *xRanges, aClipRange );
- }
+ BOOL bInSourceRange = FALSE;
+ ScRange aClipRange;
+ if ( pClipDoc )
+ {
+ SCCOL nClipStartX;
+ SCROW nClipStartY;
+ SCCOL nClipEndX;
+ SCROW nClipEndY;
+ pClipDoc->GetClipStart( nClipStartX, nClipStartY );
+ pClipDoc->GetClipArea( nClipEndX, nClipEndY, TRUE );
+ nClipEndX = nClipEndX + nClipStartX;
+ nClipEndY += nClipStartY; // GetClipArea returns the difference
+
+ SCTAB nClipTab = bRestoreDestTabName ? nDestTab : nSourceTab;
+ aClipRange = ScRange( nClipStartX, nClipStartY, nClipTab,
+ nClipEndX, nClipEndY, nClipTab );
+
+ bInSourceRange = lcl_IsAllInRange( aRangesVector, aClipRange );
+ }
- // always lose references when pasting into a clipboard document (transpose)
- if ( ( bInSourceRange || bSameDoc ) && !bDestClip )
- {
- if ( bInSourceRange )
+ // always lose references when pasting into a clipboard document (transpose)
+ if ( ( bInSourceRange || bSameDoc ) && !bDestClip )
{
- if ( rDestPos != aClipRange.aStart )
+ if ( bInSourceRange )
{
- // update the data ranges to the new (copied) position
- ScRangeListRef xNewRanges = new ScRangeList( *xRanges );
- if ( lcl_MoveRanges( *xNewRanges, aClipRange, rDestPos ) )
+ if ( rDestPos != aClipRange.aStart )
{
- pDoc->UpdateChartArea( aNewName, xNewRanges, bColHeaders, bRowHeaders, FALSE );
+ // update the data ranges to the new (copied) position
+ if ( lcl_MoveRanges( aRangesVector, aClipRange, rDestPos ) )
+ pDoc->SetChartRanges( aChartName, aRangesVector );
}
}
+ else
+ {
+ // leave the ranges unchanged
+ }
}
else
{
- // leave the ranges unchanged
- }
- }
- else
- {
- // pasting into a new document without the complete source data
- // -> break connection to source data
+ // pasting into a new document without the complete source data
+ // -> break connection to source data and switch to own data
- // (see ScDocument::UpdateChartListenerCollection, PastingDrawFromOtherDoc)
+ uno::Reference< chart::XChartDocument > xOldChartDoc( ScChartHelper::GetChartFromSdrObject( pOldObject ), uno::UNO_QUERY );
+ uno::Reference< chart::XChartDocument > xNewChartDoc( xNewChart, uno::UNO_QUERY );
+ if( xOldChartDoc.is() && xNewChartDoc.is() )
+ xNewChartDoc->attachData( xOldChartDoc->getData() );
- //! need chart interface to switch to own data
+ // (see ScDocument::UpdateChartListenerCollection, PastingDrawFromOtherDoc)
+ }
}
}
}
@@ -1616,6 +1646,9 @@ void ScDrawLayer::CopyFromClip( ScDrawLayer* pClipModel, SCTAB nSourceTab, const
pOldObject = aIter.Next();
}
+
+ if( bRestoreDestTabName )
+ pDoc->RenameTab( nDestTab, aDestTabName );
}
void ScDrawLayer::MirrorRTL( SdrObject* pObj )
diff --git a/sc/source/core/data/global2.cxx b/sc/source/core/data/global2.cxx
index 21c09688aeee..d32ebdafbf78 100644
--- a/sc/source/core/data/global2.cxx
+++ b/sc/source/core/data/global2.cxx
@@ -49,6 +49,10 @@
#include "rechead.hxx"
#include "compiler.hxx"
#include "paramisc.hxx"
+// Wang Xu Ming -- 2009-5-18
+// DataPilot Migration
+#include "dpglobal.hxx"
+// End Comments
#include "sc.hrc"
#include "globstr.hrc"
@@ -59,7 +63,6 @@ using ::std::vector;
-#define MAX_LABELS 256 //!!! aus fieldwnd.hxx, muss noch nach global.hxx ???
//------------------------------------------------------------------------
// struct ScImportParam:
@@ -905,90 +908,3 @@ String ScGlobal::GetDocTabName( const String& rFileName,
return aDocTab;
}
-// ============================================================================
-
-ScSimpleSharedString::StringTable::StringTable() :
- mnStrCount(0)
-{
- // empty string (ID = 0)
- maSharedStrings.push_back(String());
- maSharedStringIds.insert( SharedStrMap::value_type(String(), mnStrCount++) );
-}
-
-ScSimpleSharedString::StringTable::StringTable(const ScSimpleSharedString::StringTable& r) :
- maSharedStrings(r.maSharedStrings),
- maSharedStringIds(r.maSharedStringIds),
- mnStrCount(r.mnStrCount)
-{
-}
-
-ScSimpleSharedString::StringTable::~StringTable()
-{
-}
-
-sal_Int32 ScSimpleSharedString::StringTable::insertString(const String& aStr)
-{
- SharedStrMap::const_iterator itr = maSharedStringIds.find(aStr),
- itrEnd = maSharedStringIds.end();
-
- if (itr == itrEnd)
- {
- // new string.
- maSharedStrings.push_back(aStr);
- maSharedStringIds.insert( SharedStrMap::value_type(aStr, mnStrCount) );
- return mnStrCount++;
- }
-
- // existing string.
- return itr->second;
-}
-
-sal_Int32 ScSimpleSharedString::StringTable::getStringId(const String& aStr)
-{
- SharedStrMap::const_iterator itr = maSharedStringIds.find(aStr),
- itrEnd = maSharedStringIds.end();
- if (itr == itrEnd)
- {
- // string not found.
- return insertString(aStr);
- }
- return itr->second;
-}
-
-const String* ScSimpleSharedString::StringTable::getString(sal_Int32 nId) const
-{
- if (nId >= mnStrCount)
- return NULL;
-
- return &maSharedStrings[nId];
-}
-
-// ----------------------------------------------------------------------------
-
-ScSimpleSharedString::ScSimpleSharedString()
-{
-}
-
-ScSimpleSharedString::ScSimpleSharedString(const ScSimpleSharedString& r) :
- maStringTable(r.maStringTable)
-{
-}
-
-ScSimpleSharedString::~ScSimpleSharedString()
-{
-}
-
-sal_Int32 ScSimpleSharedString::insertString(const String& aStr)
-{
- return maStringTable.insertString(aStr);
-}
-
-const String* ScSimpleSharedString::getString(sal_Int32 nId)
-{
- return maStringTable.getString(nId);
-}
-
-sal_Int32 ScSimpleSharedString::getStringId(const String& aStr)
-{
- return maStringTable.getStringId(aStr);
-}
diff --git a/sc/source/core/data/makefile.mk b/sc/source/core/data/makefile.mk
index 858a3835c58d..189e2e568b88 100644..100755
--- a/sc/source/core/data/makefile.mk
+++ b/sc/source/core/data/makefile.mk
@@ -72,6 +72,7 @@ SLOFILES = \
$(SLO)$/document.obj \
$(SLO)$/dpcachetable.obj \
$(SLO)$/dpdimsave.obj \
+ $(SLO)$/dpglobal.obj \
$(SLO)$/dpgroup.obj \
$(SLO)$/dpobject.obj \
$(SLO)$/dpoutput.obj \
@@ -82,6 +83,8 @@ SLOFILES = \
$(SLO)$/dptabdat.obj \
$(SLO)$/dptabres.obj \
$(SLO)$/dptabsrc.obj \
+ $(SLO)$/dptablecache.obj\
+ $(SLO)$/scdpoutputimpl.obj\
$(SLO)$/drawpage.obj \
$(SLO)$/drwlayer.obj \
$(SLO)$/fillinfo.obj \
@@ -93,10 +96,8 @@ SLOFILES = \
$(SLO)$/olinetab.obj \
$(SLO)$/pagepar.obj \
$(SLO)$/patattr.obj \
- $(SLO)$/pivot.obj \
$(SLO)$/pivot2.obj \
$(SLO)$/poolhelp.obj \
- $(SLO)$/scimpexpmsg.obj \
$(SLO)$/sortparam.obj \
$(SLO)$/stlpool.obj \
$(SLO)$/stlsheet.obj \
@@ -122,6 +123,7 @@ EXCEPTIONSFILES= \
$(SLO)$/documen2.obj \
$(SLO)$/document.obj \
$(SLO)$/dpdimsave.obj \
+ $(SLO)$/dpglobal.obj \
$(SLO)$/dpgroup.obj \
$(SLO)$/dpshttab.obj \
$(SLO)$/dptabres.obj \
@@ -137,7 +139,9 @@ EXCEPTIONSFILES= \
$(SLO)$/documen5.obj \
$(SLO)$/documen6.obj \
$(SLO)$/documen9.obj \
- $(SLO)$/dpcachetable.obj \
+ $(SLO)$/dpcachetable.obj \
+ $(SLO)$/dptablecache.obj \
+ $(SLO)$/scdpoutputimpl.obj \
$(SLO)$/dpsdbtab.obj \
$(SLO)$/dpobject.obj \
$(SLO)$/dpoutput.obj \
diff --git a/sc/source/core/data/scdpoutputimpl.cxx b/sc/source/core/data/scdpoutputimpl.cxx
new file mode 100644
index 000000000000..6a667806e097
--- /dev/null
+++ b/sc/source/core/data/scdpoutputimpl.cxx
@@ -0,0 +1,187 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright IBM Corporation 2009.
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: scdpoutputimpl.cxx,v $
+ * $Revision: 1.0 $
+ *
+ * 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_sc.hxx"
+
+// INCLUDE ---------------------------------------------------------------
+#include "scdpoutputimpl.hxx"
+#include "scitems.hxx"
+#include <editeng/boxitem.hxx>
+// -----------------------------------------------------------------------
+
+namespace
+{
+ bool lcl_compareColfuc ( SCCOL i, SCCOL j) { return (i<j); }
+ bool lcl_compareRowfuc ( SCROW i, SCROW j) { return (i<j); }
+}
+
+
+void OutputImpl::OutputDataArea()
+{
+ AddRow( mnDataStartRow );
+ AddCol( mnDataStartCol );
+
+ mnCols.push_back( mnTabEndCol+1); //set last row bottom
+ mnRows.push_back( mnTabEndRow+1); //set last col bottom
+
+ BOOL bAllRows = ( ( mnTabEndRow - mnDataStartRow + 2 ) == (SCROW) mnRows.size() );
+
+ std::sort( mnCols.begin(), mnCols.end(), lcl_compareColfuc );
+ std::sort( mnRows.begin(), mnRows.end(), lcl_compareRowfuc );
+
+ for( SCCOL nCol = 0; nCol < (SCCOL)mnCols.size()-1; nCol ++ )
+ {
+ if ( !bAllRows )
+ {
+ if ( nCol < (SCCOL)mnCols.size()-2)
+ {
+ for ( SCROW i = nCol%2; i < (SCROW)mnRows.size()-2; i +=2 )
+ OutputBlockFrame( mnCols[nCol], mnRows[i], mnCols[nCol+1]-1, mnRows[i+1]-1 );
+ if ( mnRows.size()>=2 )
+ OutputBlockFrame( mnCols[nCol], mnRows[mnRows.size()-2], mnCols[nCol+1]-1, mnRows[mnRows.size()-1]-1 );
+ }
+ else
+ {
+ for ( SCROW i = 0 ; i < (SCROW)mnRows.size()-1; i++ )
+ OutputBlockFrame( mnCols[nCol], mnRows[i], mnCols[nCol+1]-1, mnRows[i+1]-1 );
+ }
+ }
+ else
+ OutputBlockFrame( mnCols[nCol], mnRows.front(), mnCols[nCol+1]-1, mnRows.back()-1, bAllRows );
+ }
+ //out put rows area outer framer
+ if ( mnTabStartCol != mnDataStartCol )
+ {
+ if ( mnTabStartRow != mnDataStartRow )
+ OutputBlockFrame( mnTabStartCol, mnTabStartRow, mnDataStartCol-1, mnDataStartRow-1 );
+ OutputBlockFrame( mnTabStartCol, mnDataStartRow, mnDataStartCol-1, mnTabEndRow );
+ }
+ //out put cols area outer framer
+ OutputBlockFrame( mnDataStartCol, mnTabStartRow, mnTabEndCol, mnDataStartRow-1 );
+}
+
+OutputImpl::OutputImpl( ScDocument* pDoc, USHORT nTab,
+ SCCOL nTabStartCol,
+ SCROW nTabStartRow,
+ SCCOL nMemberStartCol,
+ SCROW nMemberStartRow,
+ SCCOL nDataStartCol,
+ SCROW nDataStartRow,
+ SCCOL nTabEndCol,
+ SCROW nTabEndRow ):
+ mpDoc( pDoc ),
+ mnTab( nTab ),
+ mnTabStartCol( nTabStartCol ),
+ mnTabStartRow( nTabStartRow ),
+ mnMemberStartCol( nMemberStartCol),
+ mnMemberStartRow( nMemberStartRow),
+ mnDataStartCol ( nDataStartCol ),
+ mnDataStartRow ( nDataStartRow ),
+ mnTabEndCol( nTabEndCol ),
+ mnTabEndRow( nTabEndRow )
+{
+ mbNeedLineCols.resize( nTabEndCol-nDataStartCol+1, false );
+ mbNeedLineRows.resize( nTabEndRow-nDataStartRow+1, false );
+
+}
+
+BOOL OutputImpl::AddRow( SCROW nRow )
+{
+ if ( !mbNeedLineRows[ nRow - mnDataStartRow ] )
+ {
+ mbNeedLineRows[ nRow - mnDataStartRow ] = true;
+ mnRows.push_back( nRow );
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+BOOL OutputImpl::AddCol( SCCOL nCol )
+{
+
+ if ( !mbNeedLineCols[ nCol - mnDataStartCol ] )
+ {
+ mbNeedLineCols[ nCol - mnDataStartCol ] = true;
+ mnCols.push_back( nCol );
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+void OutputImpl::OutputBlockFrame ( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, BOOL bHori )
+{
+
+ SvxBorderLine aLine, aOutLine;
+ aLine.SetColor( SC_DP_FRAME_COLOR );
+ aLine.SetOutWidth( SC_DP_FRAME_INNER_BOLD );
+ aOutLine.SetColor( SC_DP_FRAME_COLOR );
+ aOutLine.SetOutWidth( SC_DP_FRAME_OUTER_BOLD );
+
+ SvxBoxItem aBox( ATTR_BORDER );
+
+ if ( nStartCol == mnTabStartCol )
+ aBox.SetLine(&aOutLine, BOX_LINE_LEFT);
+ else
+ aBox.SetLine(&aLine, BOX_LINE_LEFT);
+
+ if ( nStartRow == mnTabStartRow )
+ aBox.SetLine(&aOutLine, BOX_LINE_TOP);
+ else
+ aBox.SetLine(&aLine, BOX_LINE_TOP);
+
+ if ( nEndCol == mnTabEndCol ) //bottom row
+ aBox.SetLine(&aOutLine, BOX_LINE_RIGHT);
+ else
+ aBox.SetLine(&aLine, BOX_LINE_RIGHT);
+
+ if ( nEndRow == mnTabEndRow ) //bottom
+ aBox.SetLine(&aOutLine, BOX_LINE_BOTTOM);
+ else
+ aBox.SetLine(&aLine, BOX_LINE_BOTTOM);
+
+
+ SvxBoxInfoItem aBoxInfo( ATTR_BORDER_INNER );
+ aBoxInfo.SetValid(VALID_VERT,FALSE );
+ if ( bHori )
+ {
+ aBoxInfo.SetValid(VALID_HORI,TRUE);
+ aBoxInfo.SetLine( &aLine, BOXINFO_LINE_HORI );
+ }
+ else
+ aBoxInfo.SetValid(VALID_HORI,FALSE );
+
+ aBoxInfo.SetValid(VALID_DISTANCE,FALSE);
+
+ mpDoc->ApplyFrameAreaTab( ScRange( nStartCol, nStartRow, mnTab, nEndCol, nEndRow , mnTab ), &aBox, &aBoxInfo );
+
+}
diff --git a/sc/source/core/data/scdpoutputimpl.hxx b/sc/source/core/data/scdpoutputimpl.hxx
new file mode 100755
index 000000000000..9148fe91ba02
--- /dev/null
+++ b/sc/source/core/data/scdpoutputimpl.hxx
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright IBM Corporation 2009.
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: scdpoutputimpl.hxx,v $
+ * $Revision: 1.0 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef SCDPOUTPUTIMPL_HXX
+#define SCDPOUTPUTIMPL_HXX
+
+#include "document.hxx"
+
+#define SC_DP_FRAME_INNER_BOLD 20
+#define SC_DP_FRAME_OUTER_BOLD 40
+
+#define SC_DP_FRAME_COLOR Color(0,0,0) //( 0x20, 0x40, 0x68 )
+
+class OutputImpl
+{
+ ScDocument* mpDoc;
+ USHORT mnTab;
+ ::std::vector< bool > mbNeedLineCols;
+ ::std::vector< SCCOL > mnCols;
+
+ ::std::vector< bool > mbNeedLineRows;
+ ::std::vector< SCROW > mnRows;
+
+ SCCOL mnTabStartCol;
+ SCROW mnTabStartRow;
+ SCCOL mnMemberStartCol;
+ SCROW mnMemberStartRow;
+
+ SCCOL mnDataStartCol;
+ SCROW mnDataStartRow;
+ SCCOL mnTabEndCol;
+ SCROW mnTabEndRow;
+
+public:
+ OutputImpl( ScDocument* pDoc, USHORT nTab,
+ SCCOL nTabStartCol,
+ SCROW nTabStartRow,
+ SCCOL nMemberStartCol,
+ SCROW nMemberStartRow,
+ SCCOL nDataStartCol,
+ SCROW nDataStartRow,
+ SCCOL nTabEndCol,
+ SCROW nTabEndRow );
+ BOOL AddRow( SCROW nRow );
+ BOOL AddCol( SCCOL nCol );
+
+ void OutputDataArea();
+ void OutputBlockFrame ( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, BOOL bHori = FALSE );
+
+};
+
+#endif
diff --git a/sc/source/core/data/scimpexpmsg.cxx b/sc/source/core/data/scimpexpmsg.cxx
deleted file mode 100644
index 0d883fe5535a..000000000000
--- a/sc/source/core/data/scimpexpmsg.cxx
+++ /dev/null
@@ -1,113 +0,0 @@
-/*************************************************************************
- *
- * 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_sc.hxx"
-
-
-
-// INCLUDE ---------------------------------------------------------------
-
-#include "document.hxx"
-#include "scimpexpmsg.hxx"
-
-#include <tools/string.hxx>
-
-//UNUSED2008-05 ScImpExpLogMsg::ScImpExpLogMsg( ScImpExpMsg e ) : eId( e ), pPos( NULL ), pHint( NULL )
-//UNUSED2008-05 {
-//UNUSED2008-05 }
-//UNUSED2008-05
-//UNUSED2008-05
-//UNUSED2008-05 ScImpExpLogMsg::ScImpExpLogMsg( ScImpExpMsg e, const String& r ) : eId( e ), pHint( NULL )
-//UNUSED2008-05 {
-//UNUSED2008-05 pPos = new String( r );
-//UNUSED2008-05 }
-//UNUSED2008-05
-//UNUSED2008-05
-//UNUSED2008-05 ScImpExpLogMsg::ScImpExpLogMsg( ScImpExpMsg e, const String& rP, const String& rH ) : eId( e )
-//UNUSED2008-05 {
-//UNUSED2008-05 pPos = new String( rP );
-//UNUSED2008-05 pHint = new String( rH );
-//UNUSED2008-05 }
-//UNUSED2008-05
-//UNUSED2008-05 ScImpExpLogMsg::ScImpExpLogMsg( const ScImpExpLogMsg& r ) : eId( r.eId )
-//UNUSED2008-05 {
-//UNUSED2008-05 if( r.pPos )
-//UNUSED2008-05 pPos = new String( *r.pPos );
-//UNUSED2008-05 else
-//UNUSED2008-05 pPos = NULL;
-//UNUSED2008-05
-//UNUSED2008-05 if( r.pHint )
-//UNUSED2008-05 pHint = new String( *r.pHint );
-//UNUSED2008-05 else
-//UNUSED2008-05 pHint = NULL;
-//UNUSED2008-05 }
-//UNUSED2008-05
-//UNUSED2008-05
-//UNUSED2008-05 ScImpExpLogMsg::~ScImpExpLogMsg()
-//UNUSED2008-05 {
-//UNUSED2008-05 if( pPos )
-//UNUSED2008-05 delete pPos;
-//UNUSED2008-05
-//UNUSED2008-05 if( pHint )
-//UNUSED2008-05 delete pHint;
-//UNUSED2008-05 }
-//UNUSED2008-05
-//UNUSED2008-05
-//UNUSED2008-05 void ScImpExpLogMsg::Set( ScImpExpMsg e, const String* pP, const String* pH )
-//UNUSED2008-05 {
-//UNUSED2008-05 eId = e;
-//UNUSED2008-05 if( pPos )
-//UNUSED2008-05 delete pPos;
-//UNUSED2008-05
-//UNUSED2008-05 if( pHint )
-//UNUSED2008-05 delete pHint;
-//UNUSED2008-05
-//UNUSED2008-05 if( pP )
-//UNUSED2008-05 pPos = new String( *pP );
-//UNUSED2008-05 else
-//UNUSED2008-05 pPos = NULL;
-//UNUSED2008-05
-//UNUSED2008-05 if( pH )
-//UNUSED2008-05 pHint = new String( *pH );
-//UNUSED2008-05 }
-//UNUSED2008-05
-//UNUSED2008-05
-//UNUSED2008-05 String ScImpExpLogMsg::GetMsg( ScImpExpMsg e )
-//UNUSED2008-05 {
-//UNUSED2008-05 const sal_Char* p;
-//UNUSED2008-05 switch( e )
-//UNUSED2008-05 {
-//UNUSED2008-05 case SC_IMPEXPMSG_UNKNOWN: p = "unknown log message"; break;
-//UNUSED2008-05 default: p = "Not specified type of log message";
-//UNUSED2008-05 }
-//UNUSED2008-05
-//UNUSED2008-05 String aRet;
-//UNUSED2008-05 aRet.AssignAscii( p );
-//UNUSED2008-05 return aRet;
-//UNUSED2008-05 }
-
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index fafff6edcd13..bf1f0fb95666 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -191,7 +191,7 @@ ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const String& rNewName,
pDrawLayer->ScRenamePage( nTab, aName );
ULONG nx = (ULONG) ((double) (MAXCOL+1) * STD_COL_WIDTH * HMM_PER_TWIPS );
ULONG ny = (ULONG) ((double) (MAXROW+1) * ScGlobal::nStdRowHeight * HMM_PER_TWIPS );
- pDrawLayer->SetPageSize( static_cast<sal_uInt16>(nTab), Size( nx, ny ) );
+ pDrawLayer->SetPageSize( static_cast<sal_uInt16>(nTab), Size( nx, ny ), false );
}
}
@@ -700,7 +700,7 @@ BOOL ScTable::GetDataStart( SCCOL& rStartCol, SCROW& rStartRow ) const
}
void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow,
- BOOL bIncludeOld )
+ BOOL bIncludeOld, bool bOnlyDown ) const
{
BOOL bLeft = FALSE;
BOOL bRight = FALSE;
@@ -715,26 +715,44 @@ void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, S
{
bChanged = FALSE;
- SCROW nStart = rStartRow;
- SCROW nEnd = rEndRow;
- if (nStart>0) --nStart;
- if (nEnd<MAXROW) ++nEnd;
+ if (!bOnlyDown)
+ {
+ SCROW nStart = rStartRow;
+ SCROW nEnd = rEndRow;
+ if (nStart>0) --nStart;
+ if (nEnd<MAXROW) ++nEnd;
- if (rEndCol < MAXCOL)
- if (!aCol[rEndCol+1].IsEmptyBlock(nStart,nEnd))
- {
- ++rEndCol;
- bChanged = TRUE;
- bRight = TRUE;
- }
+ if (rEndCol < MAXCOL)
+ if (!aCol[rEndCol+1].IsEmptyBlock(nStart,nEnd))
+ {
+ ++rEndCol;
+ bChanged = TRUE;
+ bRight = TRUE;
+ }
- if (rStartCol > 0)
- if (!aCol[rStartCol-1].IsEmptyBlock(nStart,nEnd))
+ if (rStartCol > 0)
+ if (!aCol[rStartCol-1].IsEmptyBlock(nStart,nEnd))
+ {
+ --rStartCol;
+ bChanged = TRUE;
+ bLeft = TRUE;
+ }
+
+ if (rStartRow > 0)
{
- --rStartCol;
- bChanged = TRUE;
- bLeft = TRUE;
+ nTest = rStartRow-1;
+ bFound = FALSE;
+ for (i=rStartCol; i<=rEndCol && !bFound; i++)
+ if (aCol[i].HasDataAt(nTest))
+ bFound = TRUE;
+ if (bFound)
+ {
+ --rStartRow;
+ bChanged = TRUE;
+ bTop = TRUE;
+ }
}
+ }
if (rEndRow < MAXROW)
{
@@ -750,21 +768,6 @@ void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, S
bBottom = TRUE;
}
}
-
- if (rStartRow > 0)
- {
- nTest = rStartRow-1;
- bFound = FALSE;
- for (i=rStartCol; i<=rEndCol && !bFound; i++)
- if (aCol[i].HasDataAt(nTest))
- bFound = TRUE;
- if (bFound)
- {
- --rStartRow;
- bChanged = TRUE;
- bTop = TRUE;
- }
- }
}
while( bChanged );
@@ -797,6 +800,77 @@ void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, S
}
}
+
+bool ScTable::ShrinkToUsedDataArea( SCCOL& rStartCol, SCROW& rStartRow,
+ SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly ) const
+{
+ bool bRet = false;
+ bool bChanged;
+
+ do
+ {
+ bChanged = false;
+
+ bool bCont = true;
+ while (rEndCol > 0 && bCont && rStartCol < rEndCol)
+ {
+ if (aCol[rEndCol].IsEmptyBlock( rStartRow, rEndRow))
+ {
+ --rEndCol;
+ bChanged = true;
+ }
+ else
+ bCont = false;
+ }
+
+ bCont = true;
+ while (rStartCol < MAXCOL && bCont && rStartCol < rEndCol)
+ {
+ if (aCol[rStartCol].IsEmptyBlock( rStartRow, rEndRow))
+ {
+ ++rStartCol;
+ bChanged = true;
+ }
+ else
+ bCont = false;
+ }
+
+ if (!bColumnsOnly)
+ {
+ if (rStartRow < MAXROW && rStartRow < rEndRow)
+ {
+ bool bFound = false;
+ for (SCCOL i=rStartCol; i<=rEndCol && !bFound; i++)
+ if (aCol[i].HasDataAt( rStartRow))
+ bFound = true;
+ if (!bFound)
+ {
+ ++rStartRow;
+ bChanged = true;
+ }
+ }
+
+ if (rEndRow > 0 && rStartRow < rEndRow)
+ {
+ bool bFound = false;
+ for (SCCOL i=rStartCol; i<=rEndCol && !bFound; i++)
+ if (aCol[i].HasDataAt( rEndRow))
+ bFound = true;
+ if (!bFound)
+ {
+ --rEndRow;
+ bChanged = true;
+ }
+ }
+ }
+
+ if (bChanged)
+ bRet = true;
+ } while( bChanged );
+ return bRet;
+}
+
+
SCSIZE ScTable::GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow,
SCCOL nEndCol, SCROW nEndRow, ScDirection eDir )
{
@@ -1134,7 +1208,7 @@ BOOL ScTable::GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, const ScMarkData& rMa
void ScTable::UpdateDrawRef( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
- SCsCOL nDx, SCsROW nDy, SCsTAB nDz )
+ SCsCOL nDx, SCsROW nDy, SCsTAB nDz, bool bUpdateNoteCaptionPos )
{
if ( nTab >= nTab1 && nTab <= nTab2 && nDz == 0 ) // only within the table
{
@@ -1150,14 +1224,14 @@ void ScTable::UpdateDrawRef( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nR
nRow2 = sal::static_int_cast<SCROW>( nRow2 - nDy );
}
pDrawLayer->MoveArea( nTab, nCol1,nRow1, nCol2,nRow2, nDx,nDy,
- (eUpdateRefMode == URM_INSDEL) );
+ (eUpdateRefMode == URM_INSDEL), bUpdateNoteCaptionPos );
}
}
}
void ScTable::UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
SCCOL nCol2, SCROW nRow2, SCTAB nTab2, SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
- ScDocument* pUndoDoc, BOOL bIncludeDraw )
+ ScDocument* pUndoDoc, BOOL bIncludeDraw, bool bUpdateNoteCaptionPos )
{
SCCOL i;
SCCOL iMax;
@@ -1176,7 +1250,7 @@ void ScTable::UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW
nDx, nDy, nDz, pUndoDoc );
if ( bIncludeDraw )
- UpdateDrawRef( eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, nDx, nDy, nDz );
+ UpdateDrawRef( eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, nDx, nDy, nDz, bUpdateNoteCaptionPos );
if ( nTab >= nTab1 && nTab <= nTab2 && nDz == 0 ) // print ranges: only within the table
{
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 5b3f6078d489..4dc7dddcaba1 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -113,7 +113,7 @@ BOOL ScTable::TestInsertRow( SCCOL nStartCol, SCCOL nEndCol, SCSIZE nSize )
void ScTable::InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize )
{
- nRecalcLvl++;
+ IncRecalcLevel();
InitializeNoteCaptions();
if (nStartCol==0 && nEndCol==MAXCOL)
{
@@ -132,15 +132,14 @@ void ScTable::InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE
for (SCCOL j=nStartCol; j<=nEndCol; j++)
aCol[j].InsertRow( nStartRow, nSize );
- if( !--nRecalcLvl )
- SetDrawPageSize();
+ DecRecalcLevel( false );
}
void ScTable::DeleteRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize,
BOOL* pUndoOutline )
{
- nRecalcLvl++;
+ IncRecalcLevel();
InitializeNoteCaptions();
if (nStartCol==0 && nEndCol==MAXCOL)
{
@@ -160,8 +159,7 @@ void ScTable::DeleteRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE
for (SCCOL j=nStartCol; j<=nEndCol; j++)
aCol[j].DeleteRow( nStartRow, nSize );
}
- if( !--nRecalcLvl )
- SetDrawPageSize();
+ DecRecalcLevel();
}
@@ -184,7 +182,7 @@ BOOL ScTable::TestInsertCol( SCROW nStartRow, SCROW nEndRow, SCSIZE nSize )
void ScTable::InsertCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE nSize )
{
- nRecalcLvl++;
+ IncRecalcLevel();
InitializeNoteCaptions();
if (nStartRow==0 && nEndRow==MAXROW)
{
@@ -227,15 +225,14 @@ void ScTable::InsertCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE
aCol[nStartCol+i].ClearItems( nStartRow, nEndRow, nWhichArray );
}
}
- if( !--nRecalcLvl )
- SetDrawPageSize();
+ DecRecalcLevel();
}
void ScTable::DeleteCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE nSize,
BOOL* pUndoOutline )
{
- nRecalcLvl++;
+ IncRecalcLevel();
InitializeNoteCaptions();
if (nStartRow==0 && nEndRow==MAXROW)
{
@@ -270,8 +267,7 @@ void ScTable::DeleteCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE
for (SCSIZE i=0; static_cast<SCCOL>(i+nSize)+nStartCol <= MAXCOL; i++)
aCol[nStartCol + nSize + i].MoveTo(nStartRow, nEndRow, aCol[nStartCol + i]);
}
- if( !--nRecalcLvl )
- SetDrawPageSize();
+ DecRecalcLevel();
}
@@ -281,7 +277,7 @@ void ScTable::DeleteArea(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, USH
if (nRow2 > MAXROW) nRow2 = MAXROW;
if (ValidColRow(nCol1, nRow1) && ValidColRow(nCol2, nRow2))
{
-// nRecalcLvl++;
+// IncRecalcLevel();
{ // scope for bulk broadcast
ScBulkBroadcast aBulkBroadcast( pDocument->GetBASM());
@@ -300,9 +296,7 @@ void ScTable::DeleteArea(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, USH
ApplyPatternArea( nCol1, nRow1, nCol2, nRow2, aPattern );
}
-/* if( !--nRecalcLvl )
- SetDrawPageSize();
-*/
+// DecRecalcLevel();
}
}
@@ -389,7 +383,7 @@ void ScTable::CopyFromClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
if (nRow2 > MAXROW) nRow2 = MAXROW;
if (ValidColRow(nCol1, nRow1) && ValidColRow(nCol2, nRow2))
{
- nRecalcLvl++;
+ IncRecalcLevel();
for ( i = nCol1; i <= nCol2; i++)
aCol[i].CopyFromClip(nRow1, nRow2, nDy, nInsFlag, bAsLink, bSkipAttrForEmpty, pTable->aCol[i - nDx]);
@@ -424,8 +418,7 @@ void ScTable::CopyFromClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
ApplyPatternArea( nCol1, nRow1, nCol2, nRow2, aPattern );
}
}
- if( !--nRecalcLvl )
- SetDrawPageSize();
+ DecRecalcLevel();
}
}
@@ -691,7 +684,7 @@ void ScTable::UndoToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
BOOL bHeight = (nCol1==0 && nCol2==MAXCOL && pRowHeight && pDestTab->pRowHeight);
if (bWidth||bHeight)
- nRecalcLvl++;
+ IncRecalcLevel();
for ( SCCOL i = 0; i <= MAXCOL; i++)
{
@@ -709,8 +702,7 @@ void ScTable::UndoToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
pDestTab->pColWidth[i] = pColWidth[i];
if (bHeight)
pDestTab->pRowHeight->CopyFrom( *pRowHeight, nRow1, nRow2);
- if( !--nRecalcLvl )
- SetDrawPageSize();
+ DecRecalcLevel();
}
}
}
@@ -853,10 +845,12 @@ void ScTable::PutCell( const ScAddress& rPos, ScBaseCell* pCell )
//UNUSED2009-05 }
-BOOL ScTable::SetString( SCCOL nCol, SCROW nRow, SCTAB nTabP, const String& rString )
+BOOL ScTable::SetString( SCCOL nCol, SCROW nRow, SCTAB nTabP, const String& rString,
+ SvNumberFormatter* pFormatter, bool bDetectNumberFormat )
{
if (ValidColRow(nCol,nRow))
- return aCol[nCol].SetString( nRow, nTabP, rString );
+ return aCol[nCol].SetString(
+ nRow, nTabP, rString, pDocument->GetAddressConvention(), pFormatter, bDetectNumberFormat );
else
return FALSE;
}
@@ -1188,9 +1182,9 @@ const ScPatternAttr* ScTable::GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, S
}
-BOOL ScTable::HasAttrib( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, USHORT nMask ) const
+bool ScTable::HasAttrib( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, USHORT nMask ) const
{
- BOOL bFound=FALSE;
+ bool bFound = false;
for (SCCOL i=nCol1; i<=nCol2 && !bFound; i++)
bFound |= aCol[i].HasAttrib( nRow1, nRow2, nMask );
return bFound;
@@ -1958,14 +1952,13 @@ void ScTable::SetColWidth( SCCOL nCol, USHORT nNewWidth )
if ( nNewWidth != pColWidth[nCol] )
{
- nRecalcLvl++;
+ IncRecalcLevel();
InitializeNoteCaptions();
ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer();
if (pDrawLayer)
pDrawLayer->WidthChanged( nTab, nCol, ((long) nNewWidth) - (long) pColWidth[nCol] );
pColWidth[nCol] = nNewWidth;
- if( !--nRecalcLvl )
- SetDrawPageSize();
+ DecRecalcLevel();
}
}
else
@@ -1988,14 +1981,13 @@ void ScTable::SetRowHeight( SCROW nRow, USHORT nNewHeight )
USHORT nOldHeight = pRowHeight->GetValue(nRow);
if ( nNewHeight != nOldHeight )
{
- nRecalcLvl++;
+ IncRecalcLevel();
InitializeNoteCaptions();
ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer();
if (pDrawLayer)
pDrawLayer->HeightChanged( nTab, nRow, ((long) nNewHeight) - (long) nOldHeight );
pRowHeight->SetValue( nRow, nNewHeight);
- if( !--nRecalcLvl )
- SetDrawPageSize();
+ DecRecalcLevel();
}
}
else
@@ -2011,7 +2003,7 @@ BOOL ScTable::SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, USHORT nNewHeig
BOOL bChanged = FALSE;
if (VALIDROW(nStartRow) && VALIDROW(nEndRow) && pRowHeight)
{
- nRecalcLvl++;
+ IncRecalcLevel();
InitializeNoteCaptions();
if (!nNewHeight)
{
@@ -2094,8 +2086,7 @@ BOOL ScTable::SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, USHORT nNewHeig
} while (!bChanged && aIter.NextRange());
pRowHeight->SetValue( nStartRow, nEndRow, nNewHeight);
}
- if( !--nRecalcLvl )
- SetDrawPageSize();
+ DecRecalcLevel();
}
else
{
@@ -2278,7 +2269,7 @@ void ScTable::ShowCol(SCCOL nCol, BOOL bShow)
BOOL bWasVis = ( pColFlags[nCol] & CR_HIDDEN ) == 0;
if (bWasVis != bShow)
{
- nRecalcLvl++;
+ IncRecalcLevel();
InitializeNoteCaptions();
ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer();
if (pDrawLayer)
@@ -2293,8 +2284,7 @@ void ScTable::ShowCol(SCCOL nCol, BOOL bShow)
pColFlags[nCol] &= ~CR_HIDDEN;
else
pColFlags[nCol] |= CR_HIDDEN;
- if( !--nRecalcLvl )
- SetDrawPageSize();
+ DecRecalcLevel();
ScChartListenerCollection* pCharts = pDocument->GetChartListenerCollection();
if ( pCharts )
@@ -2316,7 +2306,7 @@ void ScTable::ShowRow(SCROW nRow, BOOL bShow)
BOOL bWasVis = ( nFlags & CR_HIDDEN ) == 0;
if (bWasVis != bShow)
{
- nRecalcLvl++;
+ IncRecalcLevel();
InitializeNoteCaptions();
ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer();
if (pDrawLayer)
@@ -2331,8 +2321,7 @@ void ScTable::ShowRow(SCROW nRow, BOOL bShow)
pRowFlags->SetValue( nRow, nFlags & ~(CR_HIDDEN | CR_FILTERED));
else
pRowFlags->SetValue( nRow, nFlags | CR_HIDDEN);
- if( !--nRecalcLvl )
- SetDrawPageSize();
+ DecRecalcLevel();
ScChartListenerCollection* pCharts = pDocument->GetChartListenerCollection();
if ( pCharts )
@@ -2352,7 +2341,7 @@ void ScTable::DBShowRow(SCROW nRow, BOOL bShow)
{
BYTE nFlags = pRowFlags->GetValue(nRow);
BOOL bWasVis = ( nFlags & CR_HIDDEN ) == 0;
- nRecalcLvl++;
+ IncRecalcLevel();
InitializeNoteCaptions();
if (bWasVis != bShow)
{
@@ -2371,8 +2360,7 @@ void ScTable::DBShowRow(SCROW nRow, BOOL bShow)
pRowFlags->SetValue( nRow, nFlags & ~(CR_HIDDEN | CR_FILTERED));
else
pRowFlags->SetValue( nRow, nFlags | (CR_HIDDEN | CR_FILTERED));
- if( !--nRecalcLvl )
- SetDrawPageSize();
+ DecRecalcLevel();
if (bWasVis != bShow)
{
@@ -2394,7 +2382,7 @@ void ScTable::DBShowRow(SCROW nRow, BOOL bShow)
void ScTable::DBShowRows(SCROW nRow1, SCROW nRow2, BOOL bShow)
{
SCROW nStartRow = nRow1;
- nRecalcLvl++;
+ IncRecalcLevel();
InitializeNoteCaptions();
while (nStartRow <= nRow2)
{
@@ -2439,15 +2427,14 @@ void ScTable::DBShowRows(SCROW nRow1, SCROW nRow2, BOOL bShow)
if (pOutlineTable)
UpdateOutlineRow( nRow1, nRow2, bShow );
- if( !--nRecalcLvl )
- SetDrawPageSize();
+ DecRecalcLevel();
}
void ScTable::ShowRows(SCROW nRow1, SCROW nRow2, BOOL bShow)
{
SCROW nStartRow = nRow1;
- nRecalcLvl++;
+ IncRecalcLevel();
InitializeNoteCaptions();
while (nStartRow <= nRow2)
{
@@ -2485,8 +2472,7 @@ void ScTable::ShowRows(SCROW nRow1, SCROW nRow2, BOOL bShow)
nStartRow = nEndRow + 1;
}
- if( !--nRecalcLvl )
- SetDrawPageSize();
+ DecRecalcLevel();
}
@@ -2852,7 +2838,7 @@ void ScTable::GetUpperCellString(SCCOL nCol, SCROW nRow, String& rStr)
// Berechnen der Groesse der Tabelle und setzen der Groesse an der DrawPage
-void ScTable::SetDrawPageSize(bool bResetStreamValid)
+void ScTable::SetDrawPageSize(bool bResetStreamValid, bool bUpdateNoteCaptionPos)
{
ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer();
if( pDrawLayer )
@@ -2865,7 +2851,7 @@ void ScTable::SetDrawPageSize(bool bResetStreamValid)
if ( IsLayoutRTL() ) // IsNegativePage
x = -x;
- pDrawLayer->SetPageSize( static_cast<sal_uInt16>(nTab), Size( x, y ) );
+ pDrawLayer->SetPageSize( static_cast<sal_uInt16>(nTab), Size( x, y ), bUpdateNoteCaptionPos );
}
// #i102616# actions that modify the draw page size count as sheet modification
diff --git a/sc/source/core/inc/core_pch.hxx b/sc/source/core/inc/core_pch.hxx
index 3e637550cd64..899169154d8d 100644
--- a/sc/source/core/inc/core_pch.hxx
+++ b/sc/source/core/inc/core_pch.hxx
@@ -158,7 +158,6 @@
#include <svtools/compat.hxx>
#include <svl/inetdef.hxx>
#include <svl/inethist.hxx>
-#include <svl/cancel.hxx>
#include <vcl/accel.hxx>
#include <sfx2/sfxdefs.hxx>
#include <sfx2/module.hxx>
diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index 509a9fe293fb..ccbecd52d9f2 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -634,7 +634,9 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
{
const sal_Unicode* pTmp = NULL;
String aExternDocName, aStartTabName, aEndTabName;
- USHORT nFlags = SCA_VALID | SCA_VALID_TAB, nFlags2 = SCA_VALID_TAB2;
+ USHORT nFlags = SCA_VALID | SCA_VALID_TAB;
+ // Keep in mind that nFlags2 gets left-shifted by 4 bits before being merged.
+ USHORT nFlags2 = SCA_VALID_TAB;
#if 0
{
diff --git a/sc/source/core/tool/charthelper.cxx b/sc/source/core/tool/charthelper.cxx
index 756493cc86e9..1b2cde3d4a6d 100644
--- a/sc/source/core/tool/charthelper.cxx
+++ b/sc/source/core/tool/charthelper.cxx
@@ -31,17 +31,18 @@
#include "charthelper.hxx"
#include "document.hxx"
#include "drwlayer.hxx"
+#include "rangelst.hxx"
+#include "chartlis.hxx"
//#include <vcl/svapp.hxx>
#include <svx/svditer.hxx>
#include <svx/svdoole2.hxx>
#include <svx/svdpage.hxx>
-/*
+#include <com/sun/star/chart2/data/XDataReceiver.hpp>
+
using namespace com::sun::star;
using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::WeakReference;
-*/
// ====================================================================
@@ -92,6 +93,37 @@ USHORT lcl_DoUpdateCharts( const ScAddress& rPos, ScDocument* pDoc, BOOL bAllCha
return nFound;
}
+BOOL lcl_AdjustRanges( ScRangeList& rRanges, SCTAB nSourceTab, SCTAB nDestTab, SCTAB nTabCount )
+{
+ //! if multiple sheets are copied, update references into the other copied sheets?
+
+ BOOL bChanged = FALSE;
+
+ ULONG nCount = rRanges.Count();
+ for (ULONG i=0; i<nCount; i++)
+ {
+ ScRange* pRange = rRanges.GetObject(i);
+ if ( pRange->aStart.Tab() == nSourceTab && pRange->aEnd.Tab() == nSourceTab )
+ {
+ pRange->aStart.SetTab( nDestTab );
+ pRange->aEnd.SetTab( nDestTab );
+ bChanged = TRUE;
+ }
+ if ( pRange->aStart.Tab() >= nTabCount )
+ {
+ pRange->aStart.SetTab( nTabCount > 0 ? ( nTabCount - 1 ) : 0 );
+ bChanged = TRUE;
+ }
+ if ( pRange->aEnd.Tab() >= nTabCount )
+ {
+ pRange->aEnd.SetTab( nTabCount > 0 ? ( nTabCount - 1 ) : 0 );
+ bChanged = TRUE;
+ }
+ }
+
+ return bChanged;
+}
+
}//end anonymous namespace
// === ScChartHelper ======================================
@@ -107,3 +139,160 @@ USHORT ScChartHelper::DoUpdateAllCharts( ScDocument* pDoc )
{
return lcl_DoUpdateCharts( ScAddress(), pDoc, TRUE );
}
+
+//static
+void ScChartHelper::AdjustRangesOfChartsOnDestinationPage( ScDocument* pSrcDoc, ScDocument* pDestDoc, const SCTAB nSrcTab, const SCTAB nDestTab )
+{
+ if( !pSrcDoc || !pDestDoc )
+ return;
+ ScDrawLayer* pDrawLayer = pDestDoc->GetDrawLayer();
+ if( !pDrawLayer )
+ return;
+
+ SdrPage* pDestPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nDestTab));
+ if( pDestPage )
+ {
+ SdrObjListIter aIter( *pDestPage, IM_FLAT );
+ SdrObject* pObject = aIter.Next();
+ while( pObject )
+ {
+ if( pObject->GetObjIdentifier() == OBJ_OLE2 && ((SdrOle2Obj*)pObject)->IsChart() )
+ {
+ String aChartName = ((SdrOle2Obj*)pObject)->GetPersistName();
+
+ Reference< chart2::XChartDocument > xChartDoc( pDestDoc->GetChartByName( aChartName ) );
+ Reference< chart2::data::XDataReceiver > xReceiver( xChartDoc, uno::UNO_QUERY );
+ if( xChartDoc.is() && xReceiver.is() && !xChartDoc->hasInternalDataProvider() )
+ {
+ ::std::vector< ScRangeList > aRangesVector;
+ pDestDoc->GetChartRanges( aChartName, aRangesVector, pSrcDoc );
+
+ ::std::vector< ScRangeList >::iterator aIt( aRangesVector.begin() );
+ for( ; aIt!=aRangesVector.end(); aIt++ )
+ {
+ ScRangeList& rScRangeList( *aIt );
+ lcl_AdjustRanges( rScRangeList, nSrcTab, nDestTab, pDestDoc->GetTableCount() );
+ }
+ pDestDoc->SetChartRanges( aChartName, aRangesVector );
+ }
+ }
+ pObject = aIter.Next();
+ }
+ }
+}
+
+//static
+uno::Reference< chart2::XChartDocument > ScChartHelper::GetChartFromSdrObject( SdrObject* pObject )
+{
+ uno::Reference< chart2::XChartDocument > xReturn;
+ if( pObject )
+ {
+ if( pObject->GetObjIdentifier() == OBJ_OLE2 && ((SdrOle2Obj*)pObject)->IsChart() )
+ {
+ uno::Reference< embed::XEmbeddedObject > xIPObj = ((SdrOle2Obj*)pObject)->GetObjRef();
+ if( xIPObj.is() )
+ {
+ svt::EmbeddedObjectRef::TryRunningState( xIPObj );
+ uno::Reference< util::XCloseable > xComponent = xIPObj->getComponent();
+ xReturn.set( uno::Reference< chart2::XChartDocument >( xComponent, uno::UNO_QUERY ) );
+ }
+ }
+ }
+ return xReturn;
+}
+
+void ScChartHelper::GetChartRanges( const uno::Reference< chart2::XChartDocument >& xChartDoc,
+ uno::Sequence< rtl::OUString >& rRanges )
+{
+ rRanges.realloc(0);
+ uno::Reference< chart2::data::XDataSource > xDataSource( xChartDoc, uno::UNO_QUERY );
+ if( !xDataSource.is() )
+ return;
+ //uno::Reference< chart2::data::XDataProvider > xProvider = xChartDoc->getDataProvider();
+
+ uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aLabeledDataSequences( xDataSource->getDataSequences() );
+ rRanges.realloc(2*aLabeledDataSequences.getLength());
+ sal_Int32 nRealCount=0;
+ for( sal_Int32 nN=0;nN<aLabeledDataSequences.getLength();nN++)
+ {
+ uno::Reference< chart2::data::XLabeledDataSequence > xLabeledSequence( aLabeledDataSequences[nN] );
+ if(!xLabeledSequence.is())
+ continue;
+ uno::Reference< chart2::data::XDataSequence > xLabel( xLabeledSequence->getLabel());
+ uno::Reference< chart2::data::XDataSequence > xValues( xLabeledSequence->getValues());
+
+ if( xLabel.is())
+ rRanges[nRealCount++] = xLabel->getSourceRangeRepresentation();
+ if( xValues.is())
+ rRanges[nRealCount++] = xValues->getSourceRangeRepresentation();
+ }
+ rRanges.realloc(nRealCount);
+}
+
+void ScChartHelper::SetChartRanges( const uno::Reference< chart2::XChartDocument >& xChartDoc,
+ const uno::Sequence< rtl::OUString >& rRanges )
+{
+ uno::Reference< chart2::data::XDataSource > xDataSource( xChartDoc, uno::UNO_QUERY );
+ if( !xDataSource.is() )
+ return;
+ uno::Reference< chart2::data::XDataProvider > xDataProvider = xChartDoc->getDataProvider();
+ if( !xDataProvider.is() )
+ return;
+
+ uno::Reference< frame::XModel > xModel( xChartDoc, uno::UNO_QUERY );
+ if( xModel.is() )
+ xModel->lockControllers();
+
+ try
+ {
+ rtl::OUString aPropertyNameRole( ::rtl::OUString::createFromAscii("Role") );
+
+ uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aLabeledDataSequences( xDataSource->getDataSequences() );
+ sal_Int32 nRange=0;
+ for( sal_Int32 nN=0; (nN<aLabeledDataSequences.getLength()) && (nRange<rRanges.getLength()); nN++ )
+ {
+ uno::Reference< chart2::data::XLabeledDataSequence > xLabeledSequence( aLabeledDataSequences[nN] );
+ if(!xLabeledSequence.is())
+ continue;
+ uno::Reference< beans::XPropertySet > xLabel( xLabeledSequence->getLabel(), uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySet > xValues( xLabeledSequence->getValues(), uno::UNO_QUERY );
+
+ if( xLabel.is())
+ {
+ // the range string must be in Calc A1 format.
+ uno::Reference< chart2::data::XDataSequence > xNewSeq(
+ xDataProvider->createDataSequenceByRangeRepresentation( rRanges[nRange++] ));
+
+ uno::Reference< beans::XPropertySet > xNewProps( xNewSeq, uno::UNO_QUERY );
+ if( xNewProps.is() )
+ xNewProps->setPropertyValue( aPropertyNameRole, xLabel->getPropertyValue( aPropertyNameRole ) );
+
+ xLabeledSequence->setLabel( xNewSeq );
+ }
+
+ if( !(nRange<rRanges.getLength()) )
+ break;
+
+ if( xValues.is())
+ {
+ // the range string must be in Calc A1 format.
+ uno::Reference< chart2::data::XDataSequence > xNewSeq(
+ xDataProvider->createDataSequenceByRangeRepresentation( rRanges[nRange++] ));
+
+ uno::Reference< beans::XPropertySet > xNewProps( xNewSeq, uno::UNO_QUERY );
+ if( xNewProps.is() )
+ xNewProps->setPropertyValue( aPropertyNameRole, xValues->getPropertyValue( aPropertyNameRole ) );
+
+ xLabeledSequence->setValues( xNewSeq );
+ }
+ }
+ }
+ catch ( uno::Exception& ex )
+ {
+ (void)ex;
+ DBG_ERROR("Exception in ScChartHelper::SetChartRanges - invalid range string?");
+ }
+
+ if( xModel.is() )
+ xModel->unlockControllers();
+}
diff --git a/sc/source/core/tool/collect.cxx b/sc/source/core/tool/collect.cxx
index 13df9307bc11..c7aa72343fbb 100644
--- a/sc/source/core/tool/collect.cxx
+++ b/sc/source/core/tool/collect.cxx
@@ -352,10 +352,18 @@ ScDataObject* ScStrCollection::Clone() const
//UNUSED2008-05 }
//UNUSED2008-05 }
+
ScDataObject* TypedStrData::Clone() const
{
return new TypedStrData(*this);
}
+
+TypedScStrCollection::TypedScStrCollection( USHORT nLim , USHORT nDel , BOOL bDup )
+ : ScSortedCollection( nLim, nDel, bDup )
+{
+ bCaseSensitive = FALSE;
+}
+
TypedScStrCollection::~TypedScStrCollection()
{}
ScDataObject* TypedScStrCollection::Clone() const
@@ -363,6 +371,16 @@ ScDataObject* TypedScStrCollection::Clone() const
return new TypedScStrCollection(*this);
}
+TypedStrData* TypedScStrCollection::operator[]( const USHORT nIndex) const
+{
+ return (TypedStrData*)At(nIndex);
+}
+
+void TypedScStrCollection::SetCaseSensitive( BOOL bSet )
+{
+ bCaseSensitive = bSet;
+}
+
short TypedScStrCollection::Compare( ScDataObject* pKey1, ScDataObject* pKey2 ) const
{
short nResult = 0;
diff --git a/sc/source/core/tool/doubleref.cxx b/sc/source/core/tool/doubleref.cxx
index 455eab50e953..740413ea8533 100644
--- a/sc/source/core/tool/doubleref.cxx
+++ b/sc/source/core/tool/doubleref.cxx
@@ -332,7 +332,9 @@ OUString ScDBInternalRange::getString(SCCOL nCol, SCROW nRow) const
{
String aStr;
const ScAddress& s = maRange.aStart;
- getDoc()->GetString(s.Col() + nCol, s.Row() + nRow, maRange.aStart.Tab(), aStr);
+ // #i109200# this is used in formula calculation, use GetInputString, not GetString
+ // (consistent with ScDBInternalRange::getCellString)
+ getDoc()->GetInputString(s.Col() + nCol, s.Row() + nRow, maRange.aStart.Tab(), aStr);
return aStr;
}
diff --git a/sc/source/core/tool/hints.cxx b/sc/source/core/tool/hints.cxx
index e2bcb11fc573..b2a8266705c7 100644
--- a/sc/source/core/tool/hints.cxx
+++ b/sc/source/core/tool/hints.cxx
@@ -40,6 +40,7 @@ TYPEINIT1(ScPointerChangedHint, SfxHint);
TYPEINIT1(ScLinkRefreshedHint, SfxHint);
TYPEINIT1(ScAutoStyleHint, SfxHint);
TYPEINIT1(ScDBRangeRefreshedHint, SfxHint);
+TYPEINIT1(ScDataPilotModifiedHint, SfxHint);
// -----------------------------------------------------------------------
// ScPaintHint - Angabe, was neu gezeichnet werden muss
@@ -150,3 +151,12 @@ ScDBRangeRefreshedHint::~ScDBRangeRefreshedHint()
}
+ScDataPilotModifiedHint::ScDataPilotModifiedHint( const String& rName )
+ : maName(rName)
+{
+}
+ScDataPilotModifiedHint::~ScDataPilotModifiedHint()
+{
+}
+
+
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 166261b98ffd..94cd5c1a02e9 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -6053,6 +6053,10 @@ void ScInterpreter::ScDBCount()
// iterators.
ScDBQueryParamInternal* p = static_cast<ScDBQueryParamInternal*>(pQueryParam.get());
SCTAB nTab = p->nTab;
+ // ScQueryCellIterator doesn't make use of ScDBQueryParamBase::mnField,
+ // so the source range has to be restricted, like before the introduction
+ // of ScDBQueryParamBase.
+ p->nCol1 = p->nCol2 = p->mnField;
ScQueryCellIterator aCellIter( pDok, nTab, *p);
if ( aCellIter.GetFirst() )
{
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 8a6c0df0db16..ffba9aafc511 100755..100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -3115,7 +3115,7 @@ void ScInterpreter::ScColRowNameAuto()
(SCROW&) aRefData.Ref1.nRow,
(SCCOL&) aRefData.Ref2.nCol,
(SCROW&) aRefData.Ref2.nRow,
- TRUE );
+ TRUE, false );
// DataArea im Ursprung begrenzen
aRefData.Ref1.nCol = nStartCol;
aRefData.Ref1.nRow = nStartRow;
diff --git a/sc/source/core/tool/makefile.mk b/sc/source/core/tool/makefile.mk
index 0bc433a7b187..6c730f3a1743 100644
--- a/sc/source/core/tool/makefile.mk
+++ b/sc/source/core/tool/makefile.mk
@@ -105,6 +105,7 @@ SLOFILES = \
$(SLO)$/refupdat.obj \
$(SLO)$/scmatrix.obj \
$(SLO)$/sctictac.obj \
+ $(SLO)$/stringutil.obj \
$(SLO)$/subtotal.obj \
$(SLO)$/token.obj \
$(SLO)$/unitconv.obj \
@@ -115,6 +116,7 @@ SLOFILES = \
EXCEPTIONSFILES= \
$(SLO)$/addincol.obj \
$(SLO)$/cellkeytranslator.obj \
+ $(SLO)$/charthelper.obj \
$(SLO)$/chartarr.obj \
$(SLO)$/chartlis.obj \
$(SLO)$/chartlock.obj \
@@ -131,6 +133,7 @@ EXCEPTIONSFILES= \
$(SLO)$/prnsave.obj \
$(SLO)$/queryparam.obj \
$(SLO)$/reftokenhelper.obj \
+ $(SLO)$/stringutil.obj \
$(SLO)$/token.obj
# [kh] POWERPC compiler problem
diff --git a/sc/source/core/tool/optutil.cxx b/sc/source/core/tool/optutil.cxx
index 4de458f698da..dc63c7819eff 100644
--- a/sc/source/core/tool/optutil.cxx
+++ b/sc/source/core/tool/optutil.cxx
@@ -51,12 +51,12 @@ BOOL ScOptionsUtil::IsMetricSystem()
//------------------------------------------------------------------
-ScLinkConfigItem::ScLinkConfigItem( const rtl::OUString rSubTree ) :
+ScLinkConfigItem::ScLinkConfigItem( const rtl::OUString& rSubTree ) :
ConfigItem( rSubTree )
{
}
-ScLinkConfigItem::ScLinkConfigItem( const rtl::OUString rSubTree, sal_Int16 nMode ) :
+ScLinkConfigItem::ScLinkConfigItem( const rtl::OUString& rSubTree, sal_Int16 nMode ) :
ConfigItem( rSubTree, nMode )
{
}
diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx
index d0dd8ec9c163..1ab978866c67 100644
--- a/sc/source/core/tool/rangelst.cxx
+++ b/sc/source/core/tool/rangelst.cxx
@@ -41,7 +41,7 @@
#include "document.hxx"
#include "refupdat.hxx"
#include "rechead.hxx"
-
+#include "compiler.hxx"
// === ScRangeList ====================================================
@@ -58,32 +58,14 @@ void ScRangeList::RemoveAll()
Clear();
}
-static void defaultDelimiter( char& cDelimiter, formula::FormulaGrammar::AddressConvention eConv)
-{
- if( cDelimiter == 0)
- {
- switch( eConv )
- {
- default :
- case formula::FormulaGrammar::CONV_OOO :
- cDelimiter = ';';
- break;
-
- case formula::FormulaGrammar::CONV_XL_A1 :
- case formula::FormulaGrammar::CONV_XL_R1C1 :
- cDelimiter = ',';
- break;
- }
- }
-}
-
USHORT ScRangeList::Parse( const String& rStr, ScDocument* pDoc, USHORT nMask,
formula::FormulaGrammar::AddressConvention eConv,
- char cDelimiter )
+ sal_Unicode cDelimiter )
{
if ( rStr.Len() )
{
- defaultDelimiter( cDelimiter, eConv);
+ if (!cDelimiter)
+ cDelimiter = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
nMask |= SCA_VALID; // falls das jemand vergessen sollte
USHORT nResult = (USHORT)~0; // alle Bits setzen
@@ -123,11 +105,12 @@ USHORT ScRangeList::Parse( const String& rStr, ScDocument* pDoc, USHORT nMask,
void ScRangeList::Format( String& rStr, USHORT nFlags, ScDocument* pDoc,
formula::FormulaGrammar::AddressConvention eConv,
- char cDelimiter ) const
+ sal_Unicode cDelimiter ) const
{
rStr.Erase();
- defaultDelimiter( cDelimiter, eConv);
+ if (!cDelimiter)
+ cDelimiter = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
ULONG nCnt = Count();
for ( ULONG nIdx = 0; nIdx < nCnt; nIdx++ )
@@ -246,6 +229,11 @@ BOOL ScRangeList::operator==( const ScRangeList& r ) const
return TRUE;
}
+BOOL ScRangeList::operator!=( const ScRangeList& r ) const
+{
+ return !operator==( r );
+}
+
BOOL ScRangeList::UpdateReference( UpdateRefMode eUpdateRefMode,
ScDocument* pDoc, const ScRange& rWhere,
SCsCOL nDx, SCsROW nDy, SCsTAB nDz )
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 326fda49eb30..fbb859b64ebf 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -62,12 +62,17 @@ void ScMatrix::CreateMatrix(SCSIZE nC, SCSIZE nR) // nur fuer ctor
mnNonValue = 0;
}
-ScMatrix::~ScMatrix()
+void ScMatrix::Clear()
{
DeleteIsString();
delete [] pMat;
}
+ScMatrix::~ScMatrix()
+{
+ Clear();
+}
+
ScMatrix* ScMatrix::Clone() const
{
ScMatrix* pScMat = new ScMatrix( nColCount, nRowCount);
@@ -76,6 +81,12 @@ ScMatrix* ScMatrix::Clone() const
return pScMat;
}
+void ScMatrix::Resize( SCSIZE nC, SCSIZE nR)
+{
+ Clear();
+ CreateMatrix(nC, nR);
+}
+
ScMatrix* ScMatrix::CloneAndExtend( SCSIZE nNewCols, SCSIZE nNewRows ) const
{
ScMatrix* pScMat = new ScMatrix( nNewCols, nNewRows);
diff --git a/sc/source/core/tool/stringutil.cxx b/sc/source/core/tool/stringutil.cxx
new file mode 100644
index 000000000000..28a4bc6755c2
--- /dev/null
+++ b/sc/source/core/tool/stringutil.cxx
@@ -0,0 +1,131 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: table.hxx,v $
+ * $Revision: 1.35 $
+ *
+ * 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_sc.hxx"
+
+// System - Includes -----------------------------------------------------
+
+#include "stringutil.hxx"
+#include "rtl/ustrbuf.hxx"
+#include "rtl/math.hxx"
+
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+
+bool ScStringUtil::parseSimpleNumber(
+ const OUString& rStr, sal_Unicode dsep, sal_Unicode gsep, double& rVal)
+{
+ if (gsep == 0x00A0)
+ // unicode space to ascii space
+ gsep = 0x0020;
+
+ OUStringBuffer aBuf;
+ sal_Int32 n = rStr.getLength();
+ const sal_Unicode* p = rStr.getStr();
+ sal_Int32 nPosDSep = -1, nPosGSep = -1;
+ sal_uInt32 nDigitCount = 0;
+
+ for (sal_Int32 i = 0; i < n; ++i)
+ {
+ sal_Unicode c = p[i];
+ if (c == 0x00A0)
+ // unicode space to ascii space
+ c = 0x0020;
+
+ if (sal_Unicode('0') <= c && c <= sal_Unicode('9'))
+ {
+ // this is a digit.
+ aBuf.append(c);
+ ++nDigitCount;
+ }
+ else if (c == dsep)
+ {
+ // this is a decimal separator.
+
+ if (nPosDSep >= 0)
+ // a second decimal separator -> not a valid number.
+ return false;
+
+ if (nPosGSep >= 0 && i - nPosGSep != 4)
+ // the number has a group separator and the decimal sep is not
+ // positioned correctly.
+ return false;
+
+ nPosDSep = i;
+ nPosGSep = -1;
+ aBuf.append(c);
+ nDigitCount = 0;
+ }
+ else if (c == gsep)
+ {
+ // this is a group (thousand) separator.
+
+ if (i == 0)
+ // not allowed as the first character.
+ return false;
+
+ if (nPosDSep >= 0)
+ // not allowed after the decimal separator.
+ return false;
+
+ if (nPosGSep >= 0 && nDigitCount != 3)
+ // must be exactly 3 digits since the last group separator.
+ return false;
+
+ nPosGSep = i;
+ nDigitCount = 0;
+ }
+ else if (c == sal_Unicode('-') || c == sal_Unicode('+'))
+ {
+ // A sign must be the first character if it's given.
+ if (i == 0)
+ aBuf.append(c);
+ else
+ return false;
+ }
+ else
+ return false;
+ }
+
+ // finished parsing the number.
+
+ if (nPosGSep >= 0 && nDigitCount != 3)
+ // must be exactly 3 digits since the last group separator.
+ return false;
+
+ rtl_math_ConversionStatus eStatus = rtl_math_ConversionStatus_Ok;
+ sal_Int32 nParseEnd = 0;
+ rVal = ::rtl::math::stringToDouble(aBuf.makeStringAndClear(), dsep, gsep, &eStatus, &nParseEnd);
+ if (eStatus != rtl_math_ConversionStatus_Ok)
+ return false;
+
+ return true;
+}
diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx
index b5e0f25f516c..bba1543dd403 100644
--- a/sc/source/filter/excel/excdoc.cxx
+++ b/sc/source/filter/excel/excdoc.cxx
@@ -200,8 +200,6 @@ void ExcTable::FillAsHeader( ExcBoundsheetList& rBoundsheetList )
UINT16 nExcTabCount = rTabInfo.GetXclTabCount();
UINT16 nCodenames = static_cast< UINT16 >( GetExtDocOptions().GetCodeNameCount() );
- rR.pObjRecs = NULL; // per sheet
-
sal_uInt16 nWriteProtHash = 0;
if( SfxObjectShell* pDocShell = GetDocShell() )
{
@@ -416,7 +414,7 @@ void ExcTable::FillAsHeader( ExcBoundsheetList& rBoundsheetList )
Add( new XclExpRecalcId );
// MSODRAWINGGROUP per-document data
- Add( new XclMsodrawinggroup( rR, ESCHER_DggContainer ) );
+ aRecList.AppendRecord( GetObjectManager().CreateDrawingGroup() );
// Shared string table: SST, EXTSST
aRecList.AppendRecord( CreateRecord( EXC_ID_SST ) );
@@ -438,9 +436,8 @@ void ExcTable::FillAsTable( size_t nCodeNameIdx )
DBG_ASSERT( (mnScTab >= 0L) && (mnScTab <= MAXTAB), "-ExcTable::Table(): mnScTab - no ordinary table!" );
DBG_ASSERT( nExcTab <= static_cast<sal_uInt16>(MAXTAB), "-ExcTable::Table(): nExcTab - no ordinary table!" );
- if ( eBiff == EXC_BIFF8 )
- // list holding OBJ records and creating MSODRAWING per-sheet data
- rR.pObjRecs = new XclObjList( GetRoot() );
+ // create a new OBJ list for this sheet (may be used by notes, autofilter, data validation)
+ GetObjectManager().StartSheet();
// cell table: DEFROWHEIGHT, DEFCOLWIDTH, COLINFO, DIMENSIONS, ROW, cell records
mxCellTable.reset( new XclExpCellTable( GetRoot() ) );
@@ -512,13 +509,8 @@ void ExcTable::FillAsTable( size_t nCodeNameIdx )
if( eBiff == EXC_BIFF8 )
{
- rR.pEscher->AddSdrPage();
- //! close Escher group shape and ESCHER_DgContainer
- //! opened by XclObjList ctor MSODRAWING
- rR.pObjRecs->EndSheet();
// all MSODRAWING and OBJ stuff of this sheet goes here
- Add( rR.pObjRecs );
-
+ aRecList.AppendRecord( GetObjectManager().ProcessDrawing( GetSdrPage( mnScTab ) ) );
// pivot tables
aRecList.AppendRecord( GetPivotTableManager().CreatePivotTablesRecord( mnScTab ) );
}
@@ -590,12 +582,13 @@ void ExcTable::FillAsXmlTable( size_t nCodeNameIdx )
// label ranges
Add( new XclExpLabelranges( GetRoot() ) );
- rR.pEscher->AddSdrPage();
- //! close Escher group shape and ESCHER_DgContainer
- //! opened by XclObjList ctor MSODRAWING
- rR.pObjRecs->EndSheet();
- // all MSODRAWING and OBJ stuff of this sheet goes here
- Add( rR.pObjRecs );
+ // DFF not needed in MSOOXML export
+// GetObjectManager().AddSdrPage();
+// //! close Escher group shape and ESCHER_DgContainer
+// //! opened by XclExpObjList ctor MSODRAWING
+// rR.pObjRecs->EndSheet();
+// // all MSODRAWING and OBJ stuff of this sheet goes here
+// Add( rR.pObjRecs );
// pivot tables
aRecList.AppendRecord( GetPivotTableManager().CreatePivotTablesRecord( mnScTab ) );
@@ -756,7 +749,7 @@ void ExcDocument::ReadDoc( void )
if ( GetBiff() == EXC_BIFF8 )
{
// complete temporary Escher stream
- GetOldRoot().pEscher->GetEx()->EndDocument();
+ GetObjectManager().EndDocument();
// change tracking
if ( GetDoc().GetChangeTrack() )
@@ -771,9 +764,6 @@ void ExcDocument::Write( SvStream& rSvStrm )
{
InitializeSave();
- if ( GetBiff() == EXC_BIFF8 )
- GetOldRoot().pEscher->GetStrm().Seek(0); // ready for take off
-
XclExpStream aXclStrm( rSvStrm, GetRoot() );
aHeader.Write( aXclStrm );
@@ -807,8 +797,6 @@ void ExcDocument::WriteXml( SvStream& rStrm )
XclExpXmlStream aStrm( ::comphelper::getProcessServiceFactory(), rStrm, GetRoot() );
- GetOldRoot().pEscher->GetStrm().Seek(0); // ready for take off
-
sax_fastparser::FSHelperPtr& rWorkbook = aStrm.GetCurrentStream();
rWorkbook->startElement( XML_workbook,
XML_xmlns, "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx
index 5642c098027e..0652363e8822 100644
--- a/sc/source/filter/excel/excform.cxx
+++ b/sc/source/filter/excel/excform.cxx
@@ -471,10 +471,7 @@ ConvErr ExcelToSc::Convert( const ScTokenArray*& pErgebnis, XclImpStream& aIn, s
aIn.Ignore( (meBiff == EXC_BIFF2) ? 3 : 4 );
if( bAllowArrays )
{
- SCSIZE nC = nByte ? nByte : 256;
- SCSIZE nR = nUINT16;
-
- aStack << aPool.StoreMatrix( nC, nR );
+ aStack << aPool.StoreMatrix();
aExtensions.push_back( EXTENSION_ARRAY );
}
else
@@ -1892,6 +1889,7 @@ void ExcelToSc::ReadExtensionArray( unsigned int n, XclImpStream& aIn )
if( NULL != pMatrix )
{
+ pMatrix->Resize(nCols, nRows);
pMatrix->GetDimensions( nC, nR);
if( nC != nCols || nR != nRows )
{
diff --git a/sc/source/filter/excel/excform8.cxx b/sc/source/filter/excel/excform8.cxx
index 608d65dfc801..148b1542913a 100644
--- a/sc/source/filter/excel/excform8.cxx
+++ b/sc/source/filter/excel/excform8.cxx
@@ -392,10 +392,7 @@ ConvErr ExcelToSc8::Convert( const ScTokenArray*& rpTokArray, XclImpStream& aIn,
aIn.Ignore( 4 );
if( bAllowArrays )
{
- SCSIZE nC = nByte + 1;
- SCSIZE nR = nUINT16 + 1;
-
- aStack << aPool.StoreMatrix( nC, nR );
+ aStack << aPool.StoreMatrix();
aExtensions.push_back( EXTENSION_ARRAY );
}
else
diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx
index d49c04624cdf..9a66325db419 100644
--- a/sc/source/filter/excel/excrecds.cxx
+++ b/sc/source/filter/excel/excrecds.cxx
@@ -88,6 +88,7 @@
#include "formula/errorcodes.hxx"
#include "excdoc.hxx"
+#include "xeescher.hxx"
#include "xeformula.hxx"
#include "xelink.hxx"
#include "xename.hxx"
@@ -976,8 +977,8 @@ void ExcAutoFilterRecs::AddObjRecs()
ScAddress aAddr( pFilterInfo->GetStartPos() );
for( SCCOL nObj = 0, nCount = pFilterInfo->GetColCount(); nObj < nCount; nObj++ )
{
- XclObjDropDown* pObj = new XclObjDropDown( GetRoot(), aAddr, IsFiltered( nObj ) );
- GetOldRoot().pObjRecs->Add( pObj );
+ XclObj* pObjRec = new XclObjDropDown( GetObjectManager(), aAddr, IsFiltered( nObj ) );
+ GetObjectManager().AddObj( pObjRec );
aAddr.IncCol( 1 );
}
}
diff --git a/sc/source/filter/excel/exctools.cxx b/sc/source/filter/excel/exctools.cxx
index ba4a8339c829..e6453c2f11e2 100644
--- a/sc/source/filter/excel/exctools.cxx
+++ b/sc/source/filter/excel/exctools.cxx
@@ -76,9 +76,6 @@ RootData::RootData( void )
pTabId = NULL;
pUserBViewList = NULL;
- pObjRecs = NULL;
- pEscher = NULL;
-
pIR = NULL;
pER = NULL;
}
diff --git a/sc/source/filter/excel/expop2.cxx b/sc/source/filter/excel/expop2.cxx
index d28fa2063c91..dbe70ae6a0ee 100644
--- a/sc/source/filter/excel/expop2.cxx
+++ b/sc/source/filter/excel/expop2.cxx
@@ -141,14 +141,11 @@ ExportBiff8::ExportBiff8( XclExpRootData& rExpData, SvStream& rStrm ) :
ExportBiff5( rExpData, rStrm )
{
pExcRoot->eDateiTyp = Biff8;
- pExcRoot->pEscher = new XclEscher( GetRoot(), GetDoc().GetTableCount() );
}
ExportBiff8::~ExportBiff8()
{
- delete pExcRoot->pEscher;
- pExcRoot->pEscher = NULL;
}
@@ -159,16 +156,12 @@ ExportXml2007::ExportXml2007( XclExpRootData& rExpData, SvStream& rStrm )
pExcRoot = &GetOldRoot();
pExcRoot->pER = this;
pExcRoot->eDateiTyp = Biff8;
- pExcRoot->pEscher = new XclEscher( *pExcRoot->pER, GetDoc().GetTableCount() );
pExcDoc = new ExcDocument( *this );
}
ExportXml2007::~ExportXml2007()
{
- delete pExcRoot->pEscher;
- pExcRoot->pEscher = NULL;
-
delete pExcDoc;
}
diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx
index dfb3a69c219a..e62f050f2351 100644
--- a/sc/source/filter/excel/impop.cxx
+++ b/sc/source/filter/excel/impop.cxx
@@ -1241,7 +1241,7 @@ void ImportExcel::PostDocLoad( void )
}
// #111099# open forms in alive mode (has no effect, if no controls in document)
- pDocObj->setPropertyValue( CREATE_OUSTRING( SC_UNO_APPLYFMDES ), ::comphelper::makeBoolAny( sal_False ) );
+ pDocObj->setPropertyValue( CREATE_OUSTRING( SC_UNO_APPLYFMDES ), uno::Any( false ) );
}
// enables extended options to be set to the view after import
diff --git a/sc/source/filter/excel/makefile.mk b/sc/source/filter/excel/makefile.mk
index 33a5babda815..04ba76d4a68a 100644
--- a/sc/source/filter/excel/makefile.mk
+++ b/sc/source/filter/excel/makefile.mk
@@ -151,6 +151,7 @@ EXCEPTIONSFILES = \
$(SLO)$/xlpivot.obj \
$(SLO)$/xlroot.obj \
$(SLO)$/xlstyle.obj \
+ $(SLO)$/xltools.obj \
$(SLO)$/xlview.obj
# --- Targets -------------------------------------------------------
diff --git a/sc/source/filter/excel/read.cxx b/sc/source/filter/excel/read.cxx
index 63c6512bd21e..99d722692a5e 100644
--- a/sc/source/filter/excel/read.cxx
+++ b/sc/source/filter/excel/read.cxx
@@ -64,6 +64,8 @@ FltError ImportExcel::Read( void )
XclImpXFBuffer& rXFBfr = GetXFBuffer();
XclImpNameManager& rNameMgr = GetNameManager();
XclImpObjectManager& rObjMgr = GetObjectManager();
+ (void)rObjMgr;
+ // call to GetCurrSheetDrawing() cannot be cached (changes in new sheets)
enum Zustand {
Z_BiffNull, // Nicht in gueltigem Biff-Format
@@ -246,7 +248,7 @@ FltError ImportExcel::Read( void )
case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
case 0x18: rNameMgr.ReadName( maStrm ); break;
- case 0x1C: rObjMgr.ReadNote( maStrm ); break;
+ case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break;
case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
case 0x1E: rNumFmtBfr.ReadFormat( maStrm ); break;
case 0x20: Columndefault(); break; // COLUMNDEFAULT[ 2 ]
@@ -309,7 +311,7 @@ FltError ImportExcel::Read( void )
case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
case 0x1A:
case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break;
- case 0x1C: rObjMgr.ReadNote( maStrm ); break;
+ case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break;
case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
case 0x1E: rNumFmtBfr.ReadFormat( maStrm ); break;
case 0x22: Rec1904(); break; // 1904 [ 2345]
@@ -328,7 +330,7 @@ FltError ImportExcel::Read( void )
case 0x41: rTabViewSett.ReadPane( maStrm ); break;
case 0x42: Codepage(); break; // CODEPAGE [ 2345]
case 0x56: Builtinfmtcnt(); break; // BUILTINFMTCNT[ 34 ]
- case 0x5D: rObjMgr.ReadObj( maStrm ); break;
+ case 0x5D: GetCurrSheetDrawing().ReadObj( maStrm );break;
case 0x7D: Colinfo(); break; // COLINFO [ 345]
case 0x8C: Country(); break; // COUNTRY [ 345]
case 0x92: rPal.ReadPalette( maStrm ); break;
@@ -380,7 +382,7 @@ FltError ImportExcel::Read( void )
case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
case 0x1A:
case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break;
- case 0x1C: rObjMgr.ReadNote( maStrm ); break;
+ case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break;
case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
case 0x22: Rec1904(); break; // 1904 [ 2345]
case 0x26:
@@ -399,7 +401,7 @@ FltError ImportExcel::Read( void )
case 0x42: Codepage(); break; // CODEPAGE [ 2345]
case 0x55: DefColWidth(); break;
case 0x56: Builtinfmtcnt(); break; // BUILTINFMTCNT[ 34 ]
- case 0x5D: rObjMgr.ReadObj( maStrm ); break;
+ case 0x5D: GetCurrSheetDrawing().ReadObj( maStrm );break;
case 0x7D: Colinfo(); break; // COLINFO [ 345]
case 0x8C: Country(); break; // COUNTRY [ 345]
case 0x92: rPal.ReadPalette( maStrm ); break;
@@ -496,7 +498,7 @@ FltError ImportExcel::Read( void )
case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
case 0x1A:
case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break;
- case 0x1C: rObjMgr.ReadNote( maStrm ); break;
+ case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break;
case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
case 0x2F: // FILEPASS [ 2345]
eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
@@ -507,7 +509,7 @@ FltError ImportExcel::Read( void )
case 0x42: Codepage(); break; // CODEPAGE [ 2345]
case 0x55: DefColWidth(); break;
case 0x56: Builtinfmtcnt(); break; // BUILTINFMTCNT[ 34 ]
- case 0x5D: rObjMgr.ReadObj( maStrm ); break;
+ case 0x5D: GetCurrSheetDrawing().ReadObj( maStrm );break;
case 0x7D: Colinfo(); break; // COLINFO [ 345]
case 0x8C: Country(); break; // COUNTRY [ 345]
case 0x8F: Bundleheader(); break; // BUNDLEHEADER [ 4 ]
@@ -666,7 +668,7 @@ FltError ImportExcel::Read( void )
case 0x14:
case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
- case 0x1C: rObjMgr.ReadNote( maStrm ); break;
+ case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break;
case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
case 0x23: Externname25(); break; // EXTERNNAME [ 2 5]
case 0x26:
@@ -680,7 +682,7 @@ FltError ImportExcel::Read( void )
if( eLastErr != ERRCODE_NONE )
eAkt = Z_Ende;
break;
- case 0x5D: rObjMgr.ReadObj( maStrm ); break;
+ case 0x5D: GetCurrSheetDrawing().ReadObj( maStrm );break;
case 0x83:
case 0x84: rPageSett.ReadCenter( maStrm ); break;
case 0xA0: rTabViewSett.ReadScl( maStrm ); break;
@@ -714,7 +716,7 @@ FltError ImportExcel::Read( void )
aIn.StoreGlobalPosition(); // und Position merken
break;
case Biff5C: // chart sheet
- GetObjectManager().ReadTabChart( maStrm );
+ GetCurrSheetDrawing().ReadTabChart( maStrm );
Eof();
GetTracer().TraceChartOnlySheet();
break;
@@ -799,6 +801,7 @@ FltError ImportExcel8::Read( void )
XclImpNameManager& rNameMgr = GetNameManager();
XclImpLinkManager& rLinkMgr = GetLinkManager();
XclImpObjectManager& rObjMgr = GetObjectManager();
+ // call to GetCurrSheetDrawing() cannot be cached (changes in new sheets)
XclImpCondFormatManager& rCondFmtMgr = GetCondFormatManager();
XclImpPivotTableManager& rPTableMgr = GetPivotTableManager();
XclImpWebQueryBuffer& rWQBfr = GetWebQueryBuffer();
@@ -1040,7 +1043,7 @@ FltError ImportExcel8::Read( void )
aIn.StoreGlobalPosition();
break;
case Biff8C: // chart sheet
- rObjMgr.ReadTabChart( maStrm );
+ GetCurrSheetDrawing().ReadTabChart( maStrm );
Eof();
GetTracer().TraceChartOnlySheet();
break;
@@ -1161,10 +1164,10 @@ FltError ImportExcel8::Read( void )
case EXC_ID_SETUP: rPageSett.ReadSetup( maStrm ); break;
case EXC_ID8_IMGDATA: rPageSett.ReadImgData( maStrm ); break;
- case EXC_ID_MSODRAWING: rObjMgr.ReadMsoDrawing( maStrm ); break;
+ case EXC_ID_MSODRAWING: GetCurrSheetDrawing().ReadMsoDrawing( maStrm ); break;
// #i61786# weird documents: OBJ without MSODRAWING -> read in BIFF5 format
- case EXC_ID_OBJ: rObjMgr.ReadObj( maStrm ); break;
- case EXC_ID_NOTE: rObjMgr.ReadNote( maStrm ); break;
+ case EXC_ID_OBJ: GetCurrSheetDrawing().ReadObj( maStrm ); break;
+ case EXC_ID_NOTE: GetCurrSheetDrawing().ReadNote( maStrm ); break;
case EXC_ID_HLINK: XclImpHyperlink::ReadHlink( maStrm ); break;
case EXC_ID_LABELRANGES: XclImpLabelranges::ReadLabelranges( maStrm ); break;
diff --git a/sc/source/filter/excel/tokstack.cxx b/sc/source/filter/excel/tokstack.cxx
index 8685f404543a..b61a844d02a5 100644
--- a/sc/source/filter/excel/tokstack.cxx
+++ b/sc/source/filter/excel/tokstack.cxx
@@ -737,7 +737,7 @@ const TokenId TokenPool::StoreNlf( const ScSingleRefData& rTr )
return ( const TokenId ) nElementAkt;
}
-const TokenId TokenPool::StoreMatrix( SCSIZE nC, SCSIZE nR )
+const TokenId TokenPool::StoreMatrix()
{
ScMatrix* pM;
@@ -750,8 +750,7 @@ const TokenId TokenPool::StoreMatrix( SCSIZE nC, SCSIZE nR )
pElement[ nElementAkt ] = nP_MatrixAkt;
pType[ nElementAkt ] = T_Matrix;
- pM = new ScMatrix( nC, nR );
- pM->FillDouble( 0., 0,0, nC-1, nR-1 );
+ pM = new ScMatrix( 0, 0 );
pM->IncRef( );
ppP_Matrix[ nP_MatrixAkt ] = pM;
diff --git a/sc/source/filter/excel/xechart.cxx b/sc/source/filter/excel/xechart.cxx
index 637aacd4e722..1564b2db834e 100644
--- a/sc/source/filter/excel/xechart.cxx
+++ b/sc/source/filter/excel/xechart.cxx
@@ -33,6 +33,7 @@
#include <com/sun/star/i18n/XBreakIterator.hpp>
#include <com/sun/star/i18n/ScriptType.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
+#include <com/sun/star/drawing/XShapes.hpp>
#include <com/sun/star/chart/ChartAxisLabelPosition.hpp>
#include <com/sun/star/chart/ChartAxisPosition.hpp>
#include <com/sun/star/chart/DataLabelPlacement.hpp>
@@ -63,6 +64,7 @@
#include "compiler.hxx"
#include "tokenarray.hxx"
#include "token.hxx"
+#include "xeescher.hxx"
#include "xeformula.hxx"
#include "xehelper.hxx"
#include "xepage.hxx"
@@ -77,6 +79,7 @@ using ::com::sun::star::uno::Exception;
using ::com::sun::star::beans::XPropertySet;
using ::com::sun::star::i18n::XBreakIterator;
using ::com::sun::star::frame::XModel;
+using ::com::sun::star::drawing::XShapes;
using ::com::sun::star::chart2::XChartDocument;
using ::com::sun::star::chart2::XDiagram;
using ::com::sun::star::chart2::XCoordinateSystemContainer;
@@ -97,7 +100,6 @@ using ::com::sun::star::chart2::XTitled;
using ::com::sun::star::chart2::XTitle;
using ::com::sun::star::chart2::XFormattedString;
using ::com::sun::star::chart2::XColorScheme;
-
using ::com::sun::star::chart2::data::XDataSource;
using ::com::sun::star::chart2::data::XLabeledDataSequence;
using ::com::sun::star::chart2::data::XDataSequence;
@@ -2766,6 +2768,15 @@ XclExpChAxesSet::XclExpChAxesSet( const XclExpChRoot& rRoot, sal_uInt16 nAxesSet
{
maData.mnAxesSetId = nAxesSetId;
SetFutureRecordContext( 0, nAxesSetId );
+
+ /* Need to set a reasonable size for the plot area, otherwise Excel will
+ move away embedded shapes while auto-sizing the plot area. This is just
+ a wild guess, but will be fixed with implementing manual positioning of
+ chart elements. */
+ maData.maRect.mnX = 262;
+ maData.maRect.mnY = 626;
+ maData.maRect.mnWidth = 3187;
+ maData.maRect.mnHeight = 2633;
}
sal_uInt16 XclExpChAxesSet::Convert( Reference< XDiagram > xDiagram, sal_uInt16 nFirstGroupIdx )
@@ -2904,6 +2915,14 @@ bool XclExpChAxesSet::Is3dChart() const
void XclExpChAxesSet::WriteSubRecords( XclExpStream& rStrm )
{
+ /* Need to set a reasonable size for the plot area, otherwise Excel will
+ move away embedded shapes while auto-sizing the plot area. This is just
+ a wild guess, but will be fixed with implementing manual positioning of
+ chart elements. */
+ rStrm.StartRecord( EXC_ID_CHFRAMEPOS, 20 );
+ rStrm << sal_uInt16(2) << sal_uInt16(2) << sal_uInt32(66) << sal_uInt32(626) << sal_uInt32(3384) << sal_uInt32(3231);
+ rStrm.EndRecord();
+
lclSaveRecord( rStrm, mxXAxis );
lclSaveRecord( rStrm, mxYAxis );
lclSaveRecord( rStrm, mxZAxis );
@@ -2965,8 +2984,8 @@ XclExpChChart::XclExpChChart( const XclExpRoot& rRoot,
maRect.mnHeight = static_cast< sal_Int32 >( aPtSize.Height() << 16 );
// global chart properties (default values)
- ::set_flag( maProps.mnFlags, EXC_CHPROPS_MANSERIES );
::set_flag( maProps.mnFlags, EXC_CHPROPS_SHOWVISIBLEONLY, false );
+ ::set_flag( maProps.mnFlags, EXC_CHPROPS_MANPLOTAREA );
maProps.mnEmptyMode = EXC_CHPROPS_EMPTY_SKIP;
// always create both axes set objects
@@ -3073,12 +3092,49 @@ void XclExpChChart::WriteBody( XclExpStream& rStrm )
// ----------------------------------------------------------------------------
+XclExpChartDrawing::XclExpChartDrawing( const XclExpRoot& rRoot,
+ const Reference< XModel >& rxModel, const Size& rChartSize ) :
+ XclExpRoot( rRoot )
+{
+ if( (rChartSize.Width() > 0) && (rChartSize.Height() > 0) )
+ {
+ ScfPropertySet aPropSet( rxModel );
+ Reference< XShapes > xShapes;
+ if( aPropSet.GetProperty( xShapes, EXC_CHPROP_ADDITIONALSHAPES ) && xShapes.is() && (xShapes->getCount() > 0) )
+ {
+ /* Create a new independent object manager with own DFF stream for the
+ DGCONTAINER, pass global manager as parent for shared usage of
+ global DFF data (picture container etc.). */
+ mxObjMgr.reset( new XclExpEmbeddedObjectManager( GetObjectManager(), rChartSize, EXC_CHART_UNIT, EXC_CHART_UNIT ) );
+ // initialize the drawing object list
+ mxObjMgr->StartSheet();
+ // process the draw page (convert all shapes)
+ mxObjRecs = mxObjMgr->ProcessDrawing( xShapes );
+ // finalize the DFF stream
+ mxObjMgr->EndDocument();
+ }
+ }
+}
+
+XclExpChartDrawing::~XclExpChartDrawing()
+{
+}
+
+void XclExpChartDrawing::Save( XclExpStream& rStrm )
+{
+ if( mxObjRecs.is() )
+ mxObjRecs->Save( rStrm );
+}
+
+// ----------------------------------------------------------------------------
+
XclExpChart::XclExpChart( const XclExpRoot& rRoot, Reference< XModel > xModel, const Size& rSize ) :
XclExpSubStream( EXC_BOF_CHART ),
XclExpRoot( rRoot )
{
AppendNewRecord( new XclExpChartPageSettings( rRoot ) );
AppendNewRecord( new XclExpBoolRecord( EXC_ID_PROTECT, false ) );
+ AppendNewRecord( new XclExpChartDrawing( rRoot, xModel, rSize ) );
AppendNewRecord( new XclExpUInt16Record( EXC_ID_CHUNITS, EXC_CHUNITS_TWIPS ) );
Reference< XChartDocument > xChartDoc( xModel, UNO_QUERY );
diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx
index 1f46bdb66178..2df531a9b932 100644
--- a/sc/source/filter/excel/xeescher.cxx
+++ b/sc/source/filter/excel/xeescher.cxx
@@ -28,9 +28,6 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sc.hxx"
-#include <set>
-#include <iterator>
-
#include "xeescher.hxx"
#include <com/sun/star/lang/XServiceInfo.hpp>
@@ -45,12 +42,15 @@
#include <com/sun/star/form/binding/XListEntrySource.hpp>
#include <com/sun/star/script/ScriptEventDescriptor.hpp>
+#include <set>
#include <rtl/ustrbuf.h>
#include <vcl/bmpacc.hxx>
#include <svx/svdoole2.hxx>
#include <svx/svdocapt.hxx>
#include <editeng/outlobj.hxx>
#include <editeng/editobj.hxx>
+#include <unotools/tempfile.hxx>
+#include <unotools/ucbstreamhelper.hxx>
#include "editutil.hxx"
#include "unonames.hxx"
@@ -75,6 +75,7 @@ using ::com::sun::star::uno::Sequence;
using ::com::sun::star::lang::XServiceInfo;
using ::com::sun::star::beans::XPropertySet;
using ::com::sun::star::drawing::XShape;
+using ::com::sun::star::drawing::XShapes;
using ::com::sun::star::frame::XModel;
using ::com::sun::star::embed::XEmbeddedObject;
using ::com::sun::star::awt::XControlModel;
@@ -86,6 +87,163 @@ using ::com::sun::star::script::ScriptEventDescriptor;
using ::com::sun::star::table::CellAddress;
using ::com::sun::star::table::CellRangeAddress;
+// Escher client anchor =======================================================
+
+XclExpDffAnchorBase::XclExpDffAnchorBase( const XclExpRoot& rRoot, sal_uInt16 nFlags ) :
+ XclExpRoot( rRoot ),
+ mnFlags( nFlags )
+{
+}
+
+void XclExpDffAnchorBase::SetFlags( const SdrObject& rSdrObj )
+{
+ ImplSetFlags( rSdrObj );
+}
+
+void XclExpDffAnchorBase::SetSdrObject( const SdrObject& rSdrObj )
+{
+ ImplSetFlags( rSdrObj );
+ ImplCalcAnchorRect( rSdrObj.GetCurrentBoundRect(), MAP_100TH_MM );
+}
+
+void XclExpDffAnchorBase::WriteDffData( EscherEx& rEscherEx ) const
+{
+ rEscherEx.AddAtom( 18, ESCHER_ClientAnchor );
+ rEscherEx.GetStream() << mnFlags << maAnchor;
+}
+
+void XclExpDffAnchorBase::WriteData( EscherEx& rEscherEx, const Rectangle& rRect )
+{
+ // the passed rectangle is in twips
+ ImplCalcAnchorRect( rRect, MAP_TWIP );
+ WriteDffData( rEscherEx );
+}
+
+void XclExpDffAnchorBase::ImplSetFlags( const SdrObject& )
+{
+ OSL_ENSURE( false, "XclExpDffAnchorBase::ImplSetFlags - not implemented" );
+}
+
+void XclExpDffAnchorBase::ImplCalcAnchorRect( const Rectangle&, MapUnit )
+{
+ OSL_ENSURE( false, "XclExpDffAnchorBase::ImplCalcAnchorRect - not implemented" );
+}
+
+// ----------------------------------------------------------------------------
+
+XclExpDffSheetAnchor::XclExpDffSheetAnchor( const XclExpRoot& rRoot ) :
+ XclExpDffAnchorBase( rRoot ),
+ mnScTab( rRoot.GetCurrScTab() )
+{
+}
+
+void XclExpDffSheetAnchor::ImplSetFlags( const SdrObject& rSdrObj )
+{
+ // Special case "page anchor" (X==0,Y==1) -> lock pos and size.
+ const Point& rPos = rSdrObj.GetAnchorPos();
+ mnFlags = ((rPos.X() == 0) && (rPos.Y() == 1)) ? EXC_ESC_ANCHOR_LOCKED : 0;
+}
+
+void XclExpDffSheetAnchor::ImplCalcAnchorRect( const Rectangle& rRect, MapUnit eMapUnit )
+{
+ maAnchor.SetRect( GetDoc(), mnScTab, rRect, eMapUnit );
+}
+
+// ----------------------------------------------------------------------------
+
+XclExpDffEmbeddedAnchor::XclExpDffEmbeddedAnchor( const XclExpRoot& rRoot,
+ const Size& rPageSize, sal_Int32 nScaleX, sal_Int32 nScaleY ) :
+ XclExpDffAnchorBase( rRoot ),
+ maPageSize( rPageSize ),
+ mnScaleX( nScaleX ),
+ mnScaleY( nScaleY )
+{
+}
+
+void XclExpDffEmbeddedAnchor::ImplSetFlags( const SdrObject& /*rSdrObj*/ )
+{
+ // TODO (unsupported feature): fixed size
+}
+
+void XclExpDffEmbeddedAnchor::ImplCalcAnchorRect( const Rectangle& rRect, MapUnit eMapUnit )
+{
+ maAnchor.SetRect( maPageSize, mnScaleX, mnScaleY, rRect, eMapUnit, true );
+}
+
+// ----------------------------------------------------------------------------
+
+XclExpDffNoteAnchor::XclExpDffNoteAnchor( const XclExpRoot& rRoot, const Rectangle& rRect ) :
+ XclExpDffAnchorBase( rRoot, EXC_ESC_ANCHOR_SIZELOCKED )
+{
+ maAnchor.SetRect( GetDoc(), rRoot.GetCurrScTab(), rRect, MAP_100TH_MM );
+}
+
+// ----------------------------------------------------------------------------
+
+XclExpDffDropDownAnchor::XclExpDffDropDownAnchor( const XclExpRoot& rRoot, const ScAddress& rScPos ) :
+ XclExpDffAnchorBase( rRoot, EXC_ESC_ANCHOR_POSLOCKED )
+{
+ GetAddressConverter().ConvertAddress( maAnchor.maFirst, rScPos, true );
+ maAnchor.maLast.mnCol = maAnchor.maFirst.mnCol + 1;
+ maAnchor.maLast.mnRow = maAnchor.maFirst.mnRow + 1;
+ maAnchor.mnLX = maAnchor.mnTY = maAnchor.mnRX = maAnchor.mnBY = 0;
+}
+
+// MSODRAWING* records ========================================================
+
+XclExpMsoDrawingBase::XclExpMsoDrawingBase( XclEscherEx& rEscherEx, sal_uInt16 nRecId ) :
+ XclExpRecord( nRecId ),
+ mrEscherEx( rEscherEx ),
+ mnFragmentKey( rEscherEx.InitNextDffFragment() )
+{
+}
+
+void XclExpMsoDrawingBase::WriteBody( XclExpStream& rStrm )
+{
+ OSL_ENSURE( mrEscherEx.GetStreamPos() == mrEscherEx.GetDffFragmentPos( mnFragmentKey ),
+ "XclExpMsoDrawingBase::WriteBody - DFF stream position mismatch" );
+ rStrm.CopyFromStream( mrEscherEx.GetStream(), mrEscherEx.GetDffFragmentSize( mnFragmentKey ) );
+}
+
+// ----------------------------------------------------------------------------
+
+XclExpMsoDrawingGroup::XclExpMsoDrawingGroup( XclEscherEx& rEscherEx ) :
+ XclExpMsoDrawingBase( rEscherEx, EXC_ID_MSODRAWINGGROUP )
+{
+ SvStream& rDffStrm = mrEscherEx.GetStream();
+
+ // write the DGGCONTAINER with some default settings
+ mrEscherEx.OpenContainer( ESCHER_DggContainer );
+
+ // TODO: stuff the OPT atom with our own document defaults?
+ static const sal_uInt8 spnDffOpt[] = {
+ 0xBF, 0x00, 0x08, 0x00, 0x08, 0x00, 0x81, 0x01,
+ 0x09, 0x00, 0x00, 0x08, 0xC0, 0x01, 0x40, 0x00,
+ 0x00, 0x08
+ };
+ mrEscherEx.AddAtom( sizeof( spnDffOpt ), ESCHER_OPT, 3, 3 );
+ rDffStrm.Write( spnDffOpt, sizeof( spnDffOpt ) );
+
+ // SPLITMENUCOLORS contains colors in toolbar
+ static const sal_uInt8 spnDffSplitMenuColors[] = {
+ 0x0D, 0x00, 0x00, 0x08, 0x0C, 0x00, 0x00, 0x08,
+ 0x17, 0x00, 0x00, 0x08, 0xF7, 0x00, 0x00, 0x10
+ };
+ mrEscherEx.AddAtom( sizeof( spnDffSplitMenuColors ), ESCHER_SplitMenuColors, 0, 4 );
+ rDffStrm.Write( spnDffSplitMenuColors, sizeof( spnDffSplitMenuColors ) );
+
+ // close the DGGCONTAINER
+ mrEscherEx.CloseContainer();
+ mrEscherEx.UpdateDffFragmentEnd();
+}
+
+// ----------------------------------------------------------------------------
+
+XclExpMsoDrawing::XclExpMsoDrawing( XclEscherEx& rEscherEx ) :
+ XclExpMsoDrawingBase( rEscherEx, EXC_ID_MSODRAWING )
+{
+}
+
// ============================================================================
XclExpImgData::XclExpImgData( const Graphic& rGraphic, sal_uInt16 nRecId ) :
@@ -221,10 +379,10 @@ void XclExpControlHelper::WriteFormulaSubRec( XclExpStream& rStrm, sal_uInt16 nS
#if EXC_EXP_OCX_CTRL
-XclExpOcxControlObj::XclExpOcxControlObj( const XclExpRoot& rRoot, Reference< XShape > xShape,
- const String& rClassName, sal_uInt32 nStrmStart, sal_uInt32 nStrmSize ) :
- XclObj( rRoot, EXC_OBJTYPE_PICTURE, true ),
- XclExpControlHelper( rRoot ),
+XclExpOcxControlObj::XclExpOcxControlObj( XclExpObjectManager& rObjMgr, Reference< XShape > xShape,
+ const Rectangle* pChildAnchor, const String& rClassName, sal_uInt32 nStrmStart, sal_uInt32 nStrmSize ) :
+ XclObj( rObjMgr, EXC_OBJTYPE_PICTURE, true ),
+ XclExpControlHelper( rObjMgr.GetRoot() ),
maClassName( rClassName ),
mnStrmStart( nStrmStart ),
mnStrmSize( nStrmSize )
@@ -238,11 +396,10 @@ XclExpOcxControlObj::XclExpOcxControlObj( const XclExpRoot& rRoot, Reference< XS
SetAutoLine( FALSE );
// fill DFF property set
- XclEscherEx& rEscherEx = *pMsodrawing->GetEscherEx();
- rEscherEx.OpenContainer( ESCHER_SpContainer );
- rEscherEx.AddShape( ESCHER_ShpInst_HostControl, SHAPEFLAG_HAVESPT | SHAPEFLAG_HAVEANCHOR | SHAPEFLAG_OLESHAPE );
+ mrEscherEx.OpenContainer( ESCHER_SpContainer );
+ mrEscherEx.AddShape( ESCHER_ShpInst_HostControl, SHAPEFLAG_HAVESPT | SHAPEFLAG_HAVEANCHOR | SHAPEFLAG_OLESHAPE );
Rectangle aDummyRect;
- EscherPropertyContainer aPropOpt( rEscherEx, rEscherEx.QueryPicStream(), aDummyRect );
+ EscherPropertyContainer aPropOpt( mrEscherEx, mrEscherEx.QueryPicStream(), aDummyRect );
aPropOpt.AddOpt( ESCHER_Prop_FitTextToShape, 0x00080008 ); // bool field
aPropOpt.AddOpt( ESCHER_Prop_lineColor, 0x08000040 );
aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x00080000 ); // bool field
@@ -263,15 +420,14 @@ XclExpOcxControlObj::XclExpOcxControlObj( const XclExpRoot& rRoot, Reference< XS
}
// write DFF property set to stream
- aPropOpt.Commit( rEscherEx.GetStream() );
+ aPropOpt.Commit( mrEscherEx.GetStream() );
// anchor
- if( SdrObject* pSdrObj = SdrObject::getSdrObjectFromXShape( xShape ) )
- XclExpDffAnchor( rRoot, *pSdrObj ).WriteData( rEscherEx );
- rEscherEx.AddAtom( 0, ESCHER_ClientData ); // OBJ record
- rEscherEx.CloseContainer(); // ESCHER_SpContainer
+ ImplWriteAnchor( GetRoot(), SdrObject::getSdrObjectFromXShape( xShape ), pChildAnchor );
- pMsodrawing->UpdateStopPos();
+ mrEscherEx.AddAtom( 0, ESCHER_ClientData ); // OBJ record
+ mrEscherEx.CloseContainer(); // ESCHER_SpContainer
+ mrEscherEx.UpdateDffFragmentEnd();
// spreadsheet links
ConvertSheetLinks( xShape );
@@ -328,9 +484,9 @@ void XclExpOcxControlObj::WriteSubRecs( XclExpStream& rStrm )
#else
-XclExpTbxControlObj::XclExpTbxControlObj( const XclExpRoot& rRoot, Reference< XShape > xShape ) :
- XclObj( rRoot, EXC_OBJTYPE_UNKNOWN, true ),
- XclExpControlHelper( rRoot ),
+XclExpTbxControlObj::XclExpTbxControlObj( XclExpObjectManager& rObjMgr, Reference< XShape > xShape, const Rectangle* pChildAnchor ) :
+ XclObj( rObjMgr, EXC_OBJTYPE_UNKNOWN, true ),
+ XclExpControlHelper( rObjMgr.GetRoot() ),
mnHeight( 0 ),
mnState( 0 ),
mnLineCount( 0 ),
@@ -384,9 +540,8 @@ XclExpTbxControlObj::XclExpTbxControlObj( const XclExpRoot& rRoot, Reference< XS
SetAutoLine( FALSE );
// fill DFF property set
- XclEscherEx& rEscherEx = *pMsodrawing->GetEscherEx();
- rEscherEx.OpenContainer( ESCHER_SpContainer );
- rEscherEx.AddShape( ESCHER_ShpInst_HostControl, SHAPEFLAG_HAVEANCHOR | SHAPEFLAG_HAVESPT );
+ mrEscherEx.OpenContainer( ESCHER_SpContainer );
+ mrEscherEx.AddShape( ESCHER_ShpInst_HostControl, SHAPEFLAG_HAVEANCHOR | SHAPEFLAG_HAVESPT );
EscherPropertyContainer aPropOpt;
bool bVisible = aCtrlProp.GetBoolProperty( CREATE_OUSTRING( "EnableVisible" ) );
aPropOpt.AddOpt( ESCHER_Prop_fPrint, bVisible ? 0x00080000 : 0x00080002 ); // visible flag
@@ -404,13 +559,13 @@ XclExpTbxControlObj::XclExpTbxControlObj( const XclExpRoot& rRoot, Reference< XS
aPropOpt.AddOpt( ESCHER_Prop_wzName, aCtrlName );
// write DFF property set to stream
- aPropOpt.Commit( rEscherEx.GetStream() );
+ aPropOpt.Commit( mrEscherEx.GetStream() );
// anchor
- if( SdrObject* pSdrObj = SdrObject::getSdrObjectFromXShape( xShape ) )
- XclExpDffAnchor( rRoot, *pSdrObj ).WriteData( rEscherEx );
- rEscherEx.AddAtom( 0, ESCHER_ClientData ); // OBJ record
- pMsodrawing->UpdateStopPos();
+ ImplWriteAnchor( GetRoot(), SdrObject::getSdrObjectFromXShape( xShape ), pChildAnchor );
+
+ mrEscherEx.AddAtom( 0, ESCHER_ClientData ); // OBJ record
+ mrEscherEx.UpdateDffFragmentEnd();
// control label
OUString aString;
@@ -419,9 +574,9 @@ XclExpTbxControlObj::XclExpTbxControlObj( const XclExpRoot& rRoot, Reference< XS
/* Be sure to construct the MSODRAWING record containing the
ClientTextbox atom after the base OBJ's MSODRAWING record data is
completed. */
- pClientTextbox = new XclMsodrawing( GetRoot() );
- pClientTextbox->GetEscherEx()->AddAtom( 0, ESCHER_ClientTextbox ); // TXO record
- pClientTextbox->UpdateStopPos();
+ pClientTextbox = new XclExpMsoDrawing( mrEscherEx );
+ mrEscherEx.AddAtom( 0, ESCHER_ClientTextbox ); // TXO record
+ mrEscherEx.UpdateDffFragmentEnd();
sal_uInt16 nXclFont = EXC_FONT_APP;
if( aString.getLength() > 0 )
@@ -437,7 +592,7 @@ XclExpTbxControlObj::XclExpTbxControlObj( const XclExpRoot& rRoot, Reference< XS
pTxo->SetVerAlign( EXC_OBJ_VER_CENTER );
}
- rEscherEx.CloseContainer(); // ESCHER_SpContainer
+ mrEscherEx.CloseContainer(); // ESCHER_SpContainer
// other properties
aCtrlProp.GetProperty( mnLineCount, CREATE_OUSTRING( "LineCount" ) );
@@ -763,14 +918,13 @@ void XclExpTbxControlObj::WriteSbs( XclExpStream& rStrm )
// ----------------------------------------------------------------------------
-XclExpChartObj::XclExpChartObj( const XclExpRoot& rRoot, Reference< XShape > xShape ) :
- XclObj( rRoot, EXC_OBJTYPE_CHART ),
- XclExpRoot( rRoot )
+XclExpChartObj::XclExpChartObj( XclExpObjectManager& rObjMgr, Reference< XShape > xShape, const Rectangle* pChildAnchor ) :
+ XclObj( rObjMgr, EXC_OBJTYPE_CHART ),
+ XclExpRoot( rObjMgr.GetRoot() )
{
// create the MSODRAWING record contents for the chart object
- XclEscherEx& rEscherEx = *pMsodrawing->GetEscherEx();
- rEscherEx.OpenContainer( ESCHER_SpContainer );
- rEscherEx.AddShape( ESCHER_ShpInst_HostControl, SHAPEFLAG_HAVEANCHOR | SHAPEFLAG_HAVESPT );
+ mrEscherEx.OpenContainer( ESCHER_SpContainer );
+ mrEscherEx.AddShape( ESCHER_ShpInst_HostControl, SHAPEFLAG_HAVEANCHOR | SHAPEFLAG_HAVESPT );
EscherPropertyContainer aPropOpt;
aPropOpt.AddOpt( ESCHER_Prop_LockAgainstGrouping, 0x01040104 );
aPropOpt.AddOpt( ESCHER_Prop_FitTextToShape, 0x00080008 );
@@ -781,17 +935,16 @@ XclExpChartObj::XclExpChartObj( const XclExpRoot& rRoot, Reference< XShape > xSh
aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x00080008 );
aPropOpt.AddOpt( ESCHER_Prop_fshadowObscured, 0x00020000 );
aPropOpt.AddOpt( ESCHER_Prop_fPrint, 0x00080000 );
- aPropOpt.Commit( rEscherEx.GetStream() );
+ aPropOpt.Commit( mrEscherEx.GetStream() );
- // client anchor
+ // anchor
SdrObject* pSdrObj = SdrObject::getSdrObjectFromXShape( xShape );
- if( pSdrObj )
- XclExpDffAnchor( rRoot, *pSdrObj ).WriteData( rEscherEx );
+ ImplWriteAnchor( GetRoot(), pSdrObj, pChildAnchor );
// client data (the following OBJ record)
- rEscherEx.AddAtom( 0, ESCHER_ClientData );
- rEscherEx.CloseContainer(); // ESCHER_SpContainer
- pMsodrawing->UpdateStopPos();
+ mrEscherEx.AddAtom( 0, ESCHER_ClientData );
+ mrEscherEx.CloseContainer(); // ESCHER_SpContainer
+ mrEscherEx.UpdateDffFragmentEnd();
// load the chart OLE object
if( SdrOle2Obj* pSdrOleObj = dynamic_cast< SdrOle2Obj* >( pSdrObj ) )
@@ -804,7 +957,7 @@ XclExpChartObj::XclExpChartObj( const XclExpRoot& rRoot, Reference< XShape > xSh
::com::sun::star::awt::Rectangle aBoundRect;
aShapeProp.GetProperty( aBoundRect, CREATE_OUSTRING( "BoundRect" ) );
Size aSize( aBoundRect.Width, aBoundRect.Height );
- mxChart.reset( new XclExpChart( rRoot, xModel, aSize ) );
+ mxChart.reset( new XclExpChart( GetRoot(), xModel, aSize ) );
}
XclExpChartObj::~XclExpChartObj()
@@ -849,7 +1002,7 @@ XclExpNote::XclExpNote( const XclExpRoot& rRoot, const ScAddress& rScPos,
if( pScNote )
if( SdrCaptionObj* pCaption = pScNote->GetOrCreateCaption( maScPos ) )
if( const OutlinerParaObject* pOPO = pCaption->GetOutlinerParaObject() )
- mnObjId = rRoot.GetOldRoot().pObjRecs->Add( new XclObjComment( rRoot, pCaption->GetLogicRect(), pOPO->GetTextObject(), pCaption, mbVisible ) );
+ mnObjId = rRoot.GetObjectManager().AddObj( new XclObjComment( rRoot.GetObjectManager(), pCaption->GetLogicRect(), pOPO->GetTextObject(), pCaption, mbVisible ) );
SetRecSize( 9 + maAuthor.GetSize() );
}
@@ -1007,5 +1160,125 @@ void XclExpComments::SaveXml( XclExpXmlStream& rStrm )
rStrm.PopStream();
}
+// object manager =============================================================
+
+XclExpObjectManager::XclExpObjectManager( const XclExpRoot& rRoot ) :
+ XclExpRoot( rRoot )
+{
+ InitStream( true );
+ mxEscherEx.reset( new XclEscherEx( GetRoot(), *this, *mxDffStrm ) );
+}
+
+XclExpObjectManager::XclExpObjectManager( const XclExpObjectManager& rParent ) :
+ XclExpRoot( rParent.GetRoot() )
+{
+ InitStream( false );
+ mxEscherEx.reset( new XclEscherEx( GetRoot(), *this, *mxDffStrm, rParent.mxEscherEx.get() ) );
+}
+
+XclExpObjectManager::~XclExpObjectManager()
+{
+}
+
+XclExpDffAnchorBase* XclExpObjectManager::CreateDffAnchor() const
+{
+ return new XclExpDffSheetAnchor( GetRoot() );
+}
+
+ScfRef< XclExpRecordBase > XclExpObjectManager::CreateDrawingGroup()
+{
+ return ScfRef< XclExpRecordBase >( new XclExpMsoDrawingGroup( *mxEscherEx ) );
+}
+
+void XclExpObjectManager::StartSheet()
+{
+ mxObjList.reset( new XclExpObjList( GetRoot(), *mxEscherEx ) );
+}
+
+ScfRef< XclExpRecordBase > XclExpObjectManager::ProcessDrawing( SdrPage* pSdrPage )
+{
+ if( pSdrPage )
+ mxEscherEx->AddSdrPage( *pSdrPage );
+ // #106213# the first dummy object may still be open
+ DBG_ASSERT( mxEscherEx->GetGroupLevel() <= 1, "XclExpObjectManager::ProcessDrawing - still groups open?" );
+ while( mxEscherEx->GetGroupLevel() )
+ mxEscherEx->LeaveGroup();
+ mxObjList->EndSheet();
+ return mxObjList;
+}
+
+ScfRef< XclExpRecordBase > XclExpObjectManager::ProcessDrawing( const Reference< XShapes >& rxShapes )
+{
+ if( rxShapes.is() )
+ mxEscherEx->AddUnoShapes( rxShapes );
+ // #106213# the first dummy object may still be open
+ DBG_ASSERT( mxEscherEx->GetGroupLevel() <= 1, "XclExpObjectManager::ProcessDrawing - still groups open?" );
+ while( mxEscherEx->GetGroupLevel() )
+ mxEscherEx->LeaveGroup();
+ mxObjList->EndSheet();
+ return mxObjList;
+}
+
+void XclExpObjectManager::EndDocument()
+{
+ mxEscherEx->EndDocument();
+}
+
+XclExpMsoDrawing* XclExpObjectManager::GetMsodrawingPerSheet()
+{
+ return mxObjList->GetMsodrawingPerSheet();
+}
+
+bool XclExpObjectManager::HasObj() const
+{
+ return mxObjList->Count() > 0;
+}
+
+sal_uInt16 XclExpObjectManager::AddObj( XclObj* pObjRec )
+{
+ return mxObjList->Add( pObjRec );
+}
+
+XclObj* XclExpObjectManager::RemoveLastObj()
+{
+ XclObj* pLastObj = static_cast< XclObj* >( mxObjList->Last() );
+ mxObjList->Remove(); // remove current, which is the Last()
+ return pLastObj;
+}
+
+void XclExpObjectManager::InitStream( bool bTempFile )
+{
+ if( bTempFile )
+ {
+ mxTempFile.reset( new ::utl::TempFile );
+ if( mxTempFile->IsValid() )
+ {
+ mxTempFile->EnableKillingFile();
+ mxDffStrm.reset( ::utl::UcbStreamHelper::CreateStream( mxTempFile->GetURL(), STREAM_STD_READWRITE ) );
+ }
+ }
+
+ if( !mxDffStrm.get() )
+ mxDffStrm.reset( new SvMemoryStream );
+
+ mxDffStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+}
+
+// ----------------------------------------------------------------------------
+
+XclExpEmbeddedObjectManager::XclExpEmbeddedObjectManager(
+ const XclExpObjectManager& rParent, const Size& rPageSize, sal_Int32 nScaleX, sal_Int32 nScaleY ) :
+ XclExpObjectManager( rParent ),
+ maPageSize( rPageSize ),
+ mnScaleX( nScaleX ),
+ mnScaleY( nScaleY )
+{
+}
+
+XclExpDffAnchorBase* XclExpEmbeddedObjectManager::CreateDffAnchor() const
+{
+ return new XclExpDffEmbeddedAnchor( GetRoot(), maPageSize, mnScaleX, mnScaleY );
+}
+
// ============================================================================
diff --git a/sc/source/filter/excel/xelink.cxx b/sc/source/filter/excel/xelink.cxx
index 421a15b6da95..fcf738527025 100644
--- a/sc/source/filter/excel/xelink.cxx
+++ b/sc/source/filter/excel/xelink.cxx
@@ -43,7 +43,8 @@
using ::std::auto_ptr;
using ::std::find_if;
using ::std::vector;
-using namespace formula;
+using ::rtl::OUString;
+using ::com::sun::star::uno::Any;
// ============================================================================
// *** Helper classes ***
@@ -166,105 +167,59 @@ private:
// Cached external cells ======================================================
-/** Base class to store the contents of one external cell (record CRN). */
+/** Stores the contents of a consecutive row of external cells (record CRN). */
class XclExpCrn : public XclExpRecord
{
-protected:
- /** @param nAddSize The size of additional data derived classes will write. */
- explicit XclExpCrn( SCCOL nScCol, SCROW nScRow, sal_uInt8 nId, sal_uInt32 nAddLen = 0 );
-
-private:
- /** Writes the start of the record that is equal in all CRN records and calls WriteAddData(). */
- virtual void WriteBody( XclExpStream& rStrm );
-
- /** Called to write additional data following the common record contents.
- @descr Derived classes should overwrite this function to write their data. */
- virtual void WriteAddData( XclExpStream& rStrm ) = 0;
-
-private:
- sal_uInt16 mnXclCol; /// Column index of the external cell.
- sal_uInt16 mnXclRow; /// Row index of the external cell.
- sal_uInt8 mnId; /// Identifier for data type (EXC_CACHEDVAL_***).
-};
-
-// ----------------------------------------------------------------------------
-
-/** Cached data of an external value cell. */
-class XclExpCrnDouble : public XclExpCrn
-{
public:
- explicit XclExpCrnDouble( SCCOL nScCol, SCROW nScRow, double fVal );
+ explicit XclExpCrn( SCCOL nScCol, SCROW nScRow, const Any& rValue );
-private:
- /** Writes the double value following the common record contents. */
- virtual void WriteAddData( XclExpStream& rStrm );
+ /** Returns true, if the passed value could be appended to this record. */
+ bool InsertValue( SCCOL nScCol, SCROW nScRow, const Any& rValue );
private:
- double mfVal; /// Value of the cached cell.
-};
-
-// ----------------------------------------------------------------------------
+ virtual void WriteBody( XclExpStream& rStrm );
-/** Cached data of an external text cell. */
-class XclExpCrnString : public XclExpCrn
-{
-public:
- explicit XclExpCrnString( SCCOL nScCol, SCROW nScRow, const String& rText );
+ void WriteBool( XclExpStream& rStrm, bool bValue );
+ void WriteDouble( XclExpStream& rStrm, double fValue );
+ void WriteString( XclExpStream& rStrm, const OUString& rValue );
+ void WriteError( XclExpStream& rStrm, sal_uInt8 nErrCode );
+ void WriteEmpty( XclExpStream& rStrm );
private:
- /** Writes the string following the common record contents. */
- virtual void WriteAddData( XclExpStream& rStrm );
+ typedef ::std::vector< Any > CachedValues;
-private:
- XclExpString maText; /// Text of the cached cell.
+ CachedValues maValues; /// All cached values.
+ SCCOL mnScCol; /// Column index of the first external cell.
+ SCROW mnScRow; /// Row index of the external cells.
};
// ----------------------------------------------------------------------------
-/// Cached data of an external Boolean cell. */
-class XclExpCrnBool : public XclExpCrn
-{
-public:
- explicit XclExpCrnBool( SCCOL nScCol, SCROW nScRow, bool bBoolVal );
-
-private:
- /** Writes the Boolean value following the common record contents. */
- virtual void WriteAddData( XclExpStream& rStrm );
-
-private:
- sal_uInt16 mnBool; /// Boolean value of the cached cell.
-};
-
-// Cached cells of a sheet ====================================================
-
-/// Represents the record XCT which is the header record of a CRN record list. */
-class XclExpXct : public XclExpRecord
+/** Represents the record XCT which is the header record of a CRN record list.
+ */
+class XclExpXct : public XclExpRecordBase, protected XclExpRoot
{
public:
- explicit XclExpXct( const String& rTabName, sal_uInt16 nSBTab );
+ explicit XclExpXct( const XclExpRoot& rRoot,
+ const String& rTabName, sal_uInt16 nSBTab,
+ ScExternalRefCache::TableTypeRef xCacheTable );
/** Returns the external sheet name. */
inline const XclExpString& GetTabName() const { return maTabName; }
/** Stores all cells in the given range in the CRN list. */
- void StoreCellRange( const XclExpRoot& rRoot, const ScRange& rRange );
+ void StoreCellRange( const ScRange& rRange );
- void StoreCell( const XclExpRoot& rRoot, const ScAddress& rCell, const formula::FormulaToken& rToken );
- void StoreCellRange( const XclExpRoot& rRoot, const ScRange& rRange, const formula::FormulaToken& rToken );
+ void StoreCell( const ScAddress& rCell, const ::formula::FormulaToken& rToken );
+ void StoreCellRange( const ScRange& rRange, const ::formula::FormulaToken& rToken );
/** Writes the XCT and all CRN records. */
virtual void Save( XclExpStream& rStrm );
private:
- /** Writes the XCT record contents. */
- virtual void WriteBody( XclExpStream& rStrm );
-
-private:
- typedef XclExpRecordList< XclExpCrn > XclExpCrnList;
- typedef XclExpCrnList::RecordRefType XclExpCrnRef;
-
- XclExpCrnList maCrnList; /// CRN records that follow this record.
+ ScExternalRefCache::TableTypeRef mxCacheTable;
ScMarkData maUsedCells; /// Contains addresses of all stored cells.
+ ScRange maBoundRange; /// Bounding box of maUsedCells.
XclExpString maTabName; /// Sheet name of the external sheet.
sal_uInt16 mnSBTab; /// Referred sheet index in SUPBOOK record.
};
@@ -353,14 +308,14 @@ public:
/** Stores all cells in the given range in the CRN list of the specified SUPBOOK sheet. */
void StoreCellRange( const ScRange& rRange, sal_uInt16 nSBTab );
- void StoreCell( sal_uInt16 nSBTab, const ScAddress& rCell, const formula::FormulaToken& rToken );
- void StoreCellRange( sal_uInt16 nSBTab, const ScRange& rRange, const formula::FormulaToken& rToken );
+ void StoreCell( sal_uInt16 nSBTab, const ScAddress& rCell, const ::formula::FormulaToken& rToken );
+ void StoreCellRange( sal_uInt16 nSBTab, const ScRange& rRange, const ::formula::FormulaToken& rToken );
sal_uInt16 GetTabIndex( const String& rTabName ) const;
sal_uInt16 GetTabCount() const;
/** Inserts a new sheet name into the SUPBOOK and returns the SUPBOOK internal sheet index. */
- sal_uInt16 InsertTabName( const String& rTabName );
+ sal_uInt16 InsertTabName( const String& rTabName, ScExternalRefCache::TableTypeRef xCacheTable );
/** Finds or inserts an EXTERNNAME record for add-ins.
@return The 1-based EXTERNNAME record index; or 0, if the record list is full. */
sal_uInt16 InsertAddIn( const String& rName );
@@ -1006,6 +961,7 @@ void XclExpExtName::WriteAddData( XclExpStream& rStrm )
// range address. Excel just writes '02 00 1C 17' for all the other types
// of external names.
+ using namespace ::formula;
do
{
if (mpArray->GetLen() != 1)
@@ -1162,209 +1118,200 @@ sal_uInt16 XclExpExtNameBuffer::AppendNew( XclExpExtNameBase* pExtName )
// Cached external cells ======================================================
-XclExpCrn::XclExpCrn( SCCOL nScCol, SCROW nScRow, sal_uInt8 nId, sal_uInt32 nAddLen ) :
- XclExpRecord( EXC_ID_CRN, 5 + nAddLen ),
- mnXclCol( static_cast< sal_uInt16 >( nScCol ) ),
- mnXclRow( static_cast< sal_uInt16 >( nScRow ) ),
- mnId( nId )
+XclExpCrn::XclExpCrn( SCCOL nScCol, SCROW nScRow, const Any& rValue ) :
+ XclExpRecord( EXC_ID_CRN, 4 ),
+ mnScCol( nScCol ),
+ mnScRow( nScRow )
{
+ maValues.push_back( rValue );
}
-void XclExpCrn::WriteBody( XclExpStream& rStrm )
+bool XclExpCrn::InsertValue( SCCOL nScCol, SCROW nScRow, const Any& rValue )
{
- rStrm << static_cast< sal_uInt8 >( mnXclCol )
- << static_cast< sal_uInt8 >( mnXclCol )
- << mnXclRow
- << mnId;
- WriteAddData( rStrm );
+ if( (nScRow != mnScRow) || (nScCol != static_cast< SCCOL >( mnScCol + maValues.size() )) )
+ return false;
+ maValues.push_back( rValue );
+ return true;
}
-// ----------------------------------------------------------------------------
-
-XclExpCrnDouble::XclExpCrnDouble( SCCOL nScCol, SCROW nScRow, double fVal ) :
- XclExpCrn( nScCol, nScRow, EXC_CACHEDVAL_DOUBLE, 8 ),
- mfVal( fVal )
+void XclExpCrn::WriteBody( XclExpStream& rStrm )
{
+ rStrm << static_cast< sal_uInt8 >( mnScCol + maValues.size() - 1 )
+ << static_cast< sal_uInt8 >( mnScCol )
+ << static_cast< sal_uInt16 >( mnScRow );
+ for( CachedValues::iterator aIt = maValues.begin(), aEnd = maValues.end(); aIt != aEnd; ++aIt )
+ {
+ if( aIt->has< bool >() )
+ WriteBool( rStrm, aIt->get< bool >() );
+ else if( aIt->has< double >() )
+ WriteDouble( rStrm, aIt->get< double >() );
+ else if( aIt->has< OUString >() )
+ WriteString( rStrm, aIt->get< OUString >() );
+ else
+ WriteEmpty( rStrm );
+ }
}
-void XclExpCrnDouble::WriteAddData( XclExpStream& rStrm )
+void XclExpCrn::WriteBool( XclExpStream& rStrm, bool bValue )
{
- rStrm << mfVal;
+ rStrm << EXC_CACHEDVAL_BOOL << sal_uInt8( bValue ? 1 : 0);
+ rStrm.WriteZeroBytes( 7 );
}
-// ----------------------------------------------------------------------------
-
-XclExpCrnString::XclExpCrnString( SCCOL nScCol, SCROW nScRow, const String& rText ) :
- XclExpCrn( nScCol, nScRow, EXC_CACHEDVAL_STRING ),
- maText( rText )
+void XclExpCrn::WriteDouble( XclExpStream& rStrm, double fValue )
{
- // set correct size after maText is initialized
- AddRecSize( maText.GetSize() );
+ if( ::rtl::math::isNan( fValue ) )
+ {
+ USHORT nScError = static_cast< USHORT >( reinterpret_cast< const sal_math_Double* >( &fValue )->nan_parts.fraction_lo );
+ WriteError( rStrm, XclTools::GetXclErrorCode( nScError ) );
+ }
+ else
+ {
+ rStrm << EXC_CACHEDVAL_DOUBLE << fValue;
+ }
}
-void XclExpCrnString::WriteAddData( XclExpStream& rStrm )
+void XclExpCrn::WriteString( XclExpStream& rStrm, const OUString& rValue )
{
- rStrm << maText;
+ rStrm << EXC_CACHEDVAL_STRING << XclExpString( rValue );
}
-// ----------------------------------------------------------------------------
-
-XclExpCrnBool::XclExpCrnBool( SCCOL nScCol, SCROW nScRow, bool bBoolVal ) :
- XclExpCrn( nScCol, nScRow, EXC_CACHEDVAL_BOOL, 8 ),
- mnBool( bBoolVal ? 1 : 0 )
+void XclExpCrn::WriteError( XclExpStream& rStrm, sal_uInt8 nErrCode )
{
+ rStrm << EXC_CACHEDVAL_ERROR << nErrCode;
+ rStrm.WriteZeroBytes( 7 );
}
-void XclExpCrnBool::WriteAddData( XclExpStream& rStrm )
+void XclExpCrn::WriteEmpty( XclExpStream& rStrm )
{
- rStrm << mnBool;
- rStrm.WriteZeroBytes( 6 );
+ rStrm << EXC_CACHEDVAL_EMPTY;
+ rStrm.WriteZeroBytes( 8 );
}
// Cached cells of a sheet ====================================================
-XclExpXct::XclExpXct( const String& rTabName, sal_uInt16 nSBTab ) :
- XclExpRecord( EXC_ID_XCT, 4 ),
+XclExpXct::XclExpXct( const XclExpRoot& rRoot, const String& rTabName,
+ sal_uInt16 nSBTab, ScExternalRefCache::TableTypeRef xCacheTable ) :
+ XclExpRoot( rRoot ),
+ mxCacheTable( xCacheTable ),
+ maBoundRange( ScAddress::INITIALIZE_INVALID ),
maTabName( rTabName ),
mnSBTab( nSBTab )
{
}
-void XclExpXct::StoreCellRange( const XclExpRoot& rRoot, const ScRange& rRange )
+void XclExpXct::StoreCellRange( const ScRange& rRange )
{
// #i70418# restrict size of external range to prevent memory overflow
if( (rRange.aEnd.Col() - rRange.aStart.Col()) * (rRange.aEnd.Row() - rRange.aStart.Row()) > 1024 )
return;
- ScDocument& rDoc = rRoot.GetDoc();
- SvNumberFormatter& rFormatter = rRoot.GetFormatter();
- SCTAB nScTab = rRange.aStart.Tab();
- SCCOL nScLastCol = rRange.aEnd.Col();
- SCROW nScLastRow = rRange.aEnd.Row();
+ maUsedCells.SetMultiMarkArea( rRange );
+ maBoundRange.ExtendTo( rRange );
+}
- for( SCROW nScRow = rRange.aStart.Row(); nScRow <= nScLastRow; ++nScRow )
- {
- for( SCCOL nScCol = rRange.aStart.Col(); nScCol <= nScLastCol; ++nScCol )
- {
- if( !maUsedCells.IsCellMarked( nScCol, nScRow, TRUE ) )
- {
- XclExpCrnRef xCrn;
- if( rDoc.HasValueData( nScCol, nScRow, nScTab ) )
- {
- ScAddress aAddr( nScCol, nScRow, nScTab );
- double fVal = rDoc.GetValue( aAddr );
- ULONG nFormat = rDoc.GetNumberFormat( aAddr );
- short nType = rFormatter.GetType( nFormat );
- bool bIsBool = (nType == NUMBERFORMAT_LOGICAL);
-
- if( !bIsBool && ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0) &&
- (rDoc.GetCellType( aAddr ) == CELLTYPE_FORMULA) )
- if( ScFormulaCell* pCell = static_cast< ScFormulaCell* >( rDoc.GetCell( aAddr ) ) )
- bIsBool = (pCell->GetFormatType() == NUMBERFORMAT_LOGICAL);
-
- if( bIsBool && ((fVal == 0.0) || (fVal == 1.0)) )
- xCrn.reset( new XclExpCrnBool( nScCol, nScRow, (fVal == 1.0) ) );
- else
- xCrn.reset( new XclExpCrnDouble( nScCol, nScRow, fVal ) );
- }
- else
- {
- String aText;
- rDoc.GetString( nScCol, nScRow, nScTab, aText );
- xCrn.reset( new XclExpCrnString( nScCol, nScRow, aText ) );
- }
- maCrnList.AppendRecord( xCrn );
- }
- }
- }
+void XclExpXct::StoreCell( const ScAddress& rCell, const ::formula::FormulaToken& rToken )
+{
+ maUsedCells.SetMultiMarkArea( ScRange( rCell ) );
+ maBoundRange.ExtendTo( ScRange( rCell ) );
+ (void)rToken;
+}
+void XclExpXct::StoreCellRange( const ScRange& rRange, const ::formula::FormulaToken& rToken )
+{
maUsedCells.SetMultiMarkArea( rRange );
+ maBoundRange.ExtendTo( rRange );
+ (void)rToken;
}
-void XclExpXct::StoreCell( const XclExpRoot& /*rRoot*/, const ScAddress& rCell, const formula::FormulaToken& rToken )
+namespace {
+
+class XclExpCrnList : public XclExpRecordList< XclExpCrn >
{
- switch (rToken.GetType())
- {
- case svString:
- {
- XclExpCrnRef xCrn(
- new XclExpCrnString(rCell.Col(), rCell.Row(), rToken.GetString()));
- maCrnList.AppendRecord(xCrn);
- }
- break;
- case svDouble:
- {
- XclExpCrnRef xCrn(
- new XclExpCrnDouble(rCell.Col(), rCell.Row(), rToken.GetDouble()));
- maCrnList.AppendRecord(xCrn);
- }
- break;
- case svEmptyCell:
- {
- XclExpCrnRef xCrn(
- new XclExpCrnDouble(rCell.Col(), rCell.Row(), 0.0));
- maCrnList.AppendRecord(xCrn);
- }
- break;
- default:
- ; // nothing
- }
+public:
+ /** Inserts the passed value into an existing or new CRN record.
+ @return True = value inserted successfully, false = CRN list is full. */
+ bool InsertValue( SCCOL nScCol, SCROW nScRow, const Any& rValue );
+};
+
+bool XclExpCrnList::InsertValue( SCCOL nScCol, SCROW nScRow, const Any& rValue )
+{
+ RecordRefType xLastRec = GetLastRecord();
+ if( xLastRec.is() && xLastRec->InsertValue( nScCol, nScRow, rValue ) )
+ return true;
+ if( GetSize() == SAL_MAX_UINT16 )
+ return false;
+ AppendNewRecord( new XclExpCrn( nScCol, nScRow, rValue ) );
+ return true;
}
-void XclExpXct::StoreCellRange( const XclExpRoot& /*rRoot*/, const ScRange& rRange, const formula::FormulaToken& rToken )
+} // namespace
+
+void XclExpXct::Save( XclExpStream& rStrm )
{
- if (rToken.GetType() != svMatrix)
+ if( !mxCacheTable )
return;
- if (rRange.aStart.Tab() != rRange.aEnd.Tab())
- // multi-table range is not supported here.
+ /* Get the range of used rows in the cache table. This may help to
+ optimize building the CRN record list if the cache table does not
+ contain all referred cells, e.g. if big empty ranges are used in the
+ formulas. */
+ ::std::pair< SCROW, SCROW > aRowRange = mxCacheTable->getRowRange();
+ if( aRowRange.first >= aRowRange.second )
return;
- const ScMatrix* pMtx = static_cast<const ScToken*>(&rToken)->GetMatrix();
- if (!pMtx)
+ /* Crop the bounding range of used cells in this table to Excel limits.
+ Return if there is no external cell inside these limits. */
+ if( !GetAddressConverter().ValidateRange( maBoundRange, false ) )
return;
- SCSIZE nCols, nRows;
- pMtx->GetDimensions(nCols, nRows);
- const ScAddress& s = rRange.aStart;
- const ScAddress& e = rRange.aEnd;
- if (static_cast<SCCOL>(nCols) != e.Col() - s.Col() + 1 ||
- static_cast<SCROW>(nRows) != e.Row() - s.Row() + 1)
- {
- // size mis-match!
+ /* Find the resulting row range that needs to be processed. */
+ SCROW nScRow1 = ::std::max( aRowRange.first, maBoundRange.aStart.Row() );
+ SCROW nScRow2 = ::std::min( aRowRange.second - 1, maBoundRange.aEnd.Row() );
+ if( nScRow1 > nScRow2 )
return;
- }
- for (SCCOL nCol = 0; nCol < static_cast< SCCOL >( nCols ); ++nCol)
+ /* Build and collect all CRN records before writing the XCT record. This
+ is needed to determine the total number of CRN records which must be
+ known when writing the XCT record (possibly encrypted, so seeking the
+ output strem back after writing the CRN records is not an option). */
+ XclExpCrnList aCrnRecs;
+ SvNumberFormatter& rFormatter = GetFormatter();
+ bool bValid = true;
+ for( SCROW nScRow = nScRow1; bValid && (nScRow <= nScRow2); ++nScRow )
{
- for (SCROW nRow = 0; nRow < static_cast< SCROW >( nRows ); ++nRow)
+ ::std::pair< SCCOL, SCCOL > aColRange = mxCacheTable->getColRange( nScRow );
+ for( SCCOL nScCol = aColRange.first; bValid && (nScCol < aColRange.second); ++nScCol )
{
- if (pMtx->IsString(nCol, nRow))
+ if( maUsedCells.IsCellMarked( nScCol, nScRow, TRUE ) )
{
- XclExpCrnRef xCrn(new XclExpCrnString(
- s.Col() + nCol, s.Row() + nRow, pMtx->GetString(nCol, nRow)));
- maCrnList.AppendRecord(xCrn);
- }
- else if (pMtx->IsValueOrEmpty(nCol, nRow))
- {
- XclExpCrnRef xCrn(new XclExpCrnDouble(
- s.Col() + nCol, s.Row() + nRow, pMtx->GetDouble(nCol, nRow)));
- maCrnList.AppendRecord(xCrn);
+ sal_uInt32 nScNumFmt = 0;
+ ScExternalRefCache::TokenRef xToken = mxCacheTable->getCell( nScCol, nScRow, &nScNumFmt );
+ using namespace ::formula;
+ if( xToken.get() ) switch( xToken->GetType() )
+ {
+ case svDouble:
+ bValid = (rFormatter.GetType( nScNumFmt ) == NUMBERFORMAT_LOGICAL) ?
+ aCrnRecs.InsertValue( nScCol, nScRow, Any( xToken->GetDouble() != 0 ) ) :
+ aCrnRecs.InsertValue( nScCol, nScRow, Any( xToken->GetDouble() ) );
+ break;
+ case svString:
+ // do not save empty strings (empty cells) to cache
+ if( xToken->GetString().Len() > 0 )
+ bValid = aCrnRecs.InsertValue( nScCol, nScRow, Any( OUString( xToken->GetString() ) ) );
+ break;
+ default:
+ break;
+ }
}
}
}
-}
-void XclExpXct::Save( XclExpStream& rStrm )
-{
- XclExpRecord::Save( rStrm );
- maCrnList.Save( rStrm );
-}
-
-void XclExpXct::WriteBody( XclExpStream& rStrm )
-{
- sal_uInt16 nCount = ulimit_cast< sal_uInt16 >( maCrnList.GetSize() );
- rStrm << nCount << mnSBTab;
+ // write the XCT record and the list of CRN records
+ rStrm.StartRecord( EXC_ID_XCT, 4 );
+ rStrm << static_cast< sal_uInt16 >( aCrnRecs.GetSize() ) << mnSBTab;
+ rStrm.EndRecord();
+ aCrnRecs.Save( rStrm );
}
// External documents (EXTERNSHEET/SUPBOOK), base class =======================
@@ -1471,15 +1418,11 @@ XclExpSupbook::XclExpSupbook( const XclExpRoot& rRoot, const String& rUrl ) :
// We need to create all tables up front to ensure the correct table order.
ScExternalRefManager* pRefMgr = rRoot.GetDoc().GetExternalRefManager();
- sal_uInt16 nFileId = pRefMgr->getExternalFileId(rUrl);
- vector<String> aTabNames;
- pRefMgr->getAllCachedTableNames(nFileId, aTabNames);
- if (aTabNames.empty())
- return;
-
- vector<String>::const_iterator itr = aTabNames.begin(), itrEnd = aTabNames.end();
- for (; itr != itrEnd; ++itr)
- InsertTabName(*itr);
+ sal_uInt16 nFileId = pRefMgr->getExternalFileId( rUrl );
+ ScfStringVec aTabNames;
+ pRefMgr->getAllCachedTableNames( nFileId, aTabNames );
+ for( ScfStringVec::const_iterator aBeg = aTabNames.begin(), aIt = aBeg, aEnd = aTabNames.end(); aIt != aEnd; ++aIt )
+ InsertTabName( *aIt, pRefMgr->getCacheTable( nFileId, aIt - aBeg ) );
}
XclExpSupbook::XclExpSupbook( const XclExpRoot& rRoot, const String& rApplic, const String& rTopic ) :
@@ -1513,31 +1456,22 @@ void XclExpSupbook::FillRefLogEntry( XclExpRefLogEntry& rRefLogEntry,
void XclExpSupbook::StoreCellRange( const ScRange& rRange, sal_uInt16 nSBTab )
{
- XclExpXctRef xXct = maXctList.GetRecord( nSBTab );
- if( xXct.is() )
- xXct->StoreCellRange( GetRoot(), rRange );
+ if( XclExpXct* pXct = maXctList.GetRecord( nSBTab ).get() )
+ pXct->StoreCellRange( rRange );
}
void XclExpSupbook::StoreCell( sal_uInt16 nSBTab, const ScAddress& rCell, const formula::FormulaToken& rToken )
{
- XclExpXctRef xXct = maXctList.GetRecord(nSBTab);
- if (!xXct.is())
- return;
-
- xXct->StoreCell(GetRoot(), rCell, rToken);
+ if( XclExpXct* pXct = maXctList.GetRecord( nSBTab ).get() )
+ pXct->StoreCell( rCell, rToken );
}
void XclExpSupbook::StoreCellRange( sal_uInt16 nSBTab, const ScRange& rRange, const formula::FormulaToken& rToken )
{
- if (rRange.aStart.Tab() != rRange.aEnd.Tab())
- // multi-table range is not allowed!
- return;
-
- XclExpXctRef xXct = maXctList.GetRecord(nSBTab);
- if (!xXct.is())
- return;
-
- xXct->StoreCellRange(GetRoot(), rRange, rToken);
+ // multi-table range is not allowed!
+ if( rRange.aStart.Tab() == rRange.aEnd.Tab() )
+ if( XclExpXct* pXct = maXctList.GetRecord( nSBTab ).get() )
+ pXct->StoreCellRange( rRange, rToken );
}
sal_uInt16 XclExpSupbook::GetTabIndex( const String& rTabName ) const
@@ -1558,11 +1492,11 @@ sal_uInt16 XclExpSupbook::GetTabCount() const
return ulimit_cast<sal_uInt16>(maXctList.GetSize());
}
-sal_uInt16 XclExpSupbook::InsertTabName( const String& rTabName )
+sal_uInt16 XclExpSupbook::InsertTabName( const String& rTabName, ScExternalRefCache::TableTypeRef xCacheTable )
{
DBG_ASSERT( meType == EXC_SBTYPE_EXTERN, "XclExpSupbook::InsertTabName - don't insert sheet names here" );
sal_uInt16 nSBTab = ulimit_cast< sal_uInt16 >( maXctList.GetSize() );
- XclExpXctRef xXct( new XclExpXct( rTabName, nSBTab ) );
+ XclExpXctRef xXct( new XclExpXct( GetRoot(), rTabName, nSBTab, xCacheTable ) );
AddRecSize( xXct->GetTabName().GetSize() );
maXctList.AppendRecord( xXct );
return nSBTab;
@@ -1786,6 +1720,7 @@ void XclExpSupbookBuffer::StoreCellRange( sal_uInt16 nFileId, const String& rTab
SCTAB nTabCount = rRange.aEnd.Tab() - rRange.aStart.Tab() + 1;
// If this is a multi-table range, get token for each table.
+ using namespace ::formula;
vector<FormulaToken*> aMatrixList;
aMatrixList.reserve(nTabCount);
diff --git a/sc/source/filter/excel/xepivot.cxx b/sc/source/filter/excel/xepivot.cxx
index cb248f0eaf76..ddcdb3243167 100644
--- a/sc/source/filter/excel/xepivot.cxx
+++ b/sc/source/filter/excel/xepivot.cxx
@@ -538,16 +538,21 @@ void XclExpPCField::InsertNumDateGroupItems( const ScDPObject& rDPObj, const ScD
{
// get the string collection with original source elements
ScSheetDPData aDPData( GetDocPtr(), *pSrcDesc );
- const TypedScStrCollection& rOrigColl = aDPData.GetColumnEntries( static_cast< long >( GetBaseFieldIndex() ) );
-
+ // Wang Xu Ming - DataPilot migration
+ // 2009-05-08
+ const std::vector< SCROW > aOrignial = aDPData.GetColumnEntries( static_cast< long >( GetBaseFieldIndex() ) );
// get the string collection with generated grouping elements
ScDPNumGroupDimension aTmpDim( rNumInfo );
if( nDatePart != 0 )
aTmpDim.MakeDateHelper( rNumInfo, nDatePart );
- const TypedScStrCollection& rGroupColl = aTmpDim.GetNumEntries( rOrigColl, GetDocPtr() );
- for( USHORT nIdx = 0, nCount = rGroupColl.GetCount(); nIdx < nCount; ++nIdx )
- if( const TypedStrData* pStrData = rGroupColl[ nIdx ] )
- InsertGroupItem( new XclExpPCItem( pStrData->GetString() ) );
+ const std::vector< SCROW > aMemberIds = aTmpDim.GetNumEntries( static_cast< SCCOL >( GetBaseFieldIndex() ), aDPData.GetCacheTable().GetCache(), aOrignial );
+ for ( size_t nIdx = 0 ; nIdx < aMemberIds.size(); nIdx++ )
+ {
+ const ScDPItemData* pData = aDPData.GetMemberById( static_cast< long >( GetBaseFieldIndex() ) , aMemberIds[ nIdx] );
+ if ( pData )
+ InsertGroupItem( new XclExpPCItem( pData->GetString() ) );
+ }
+// End Comments
}
}
diff --git a/sc/source/filter/excel/xerecord.cxx b/sc/source/filter/excel/xerecord.cxx
index 853a0e52bc8b..fed58411aa5c 100644
--- a/sc/source/filter/excel/xerecord.cxx
+++ b/sc/source/filter/excel/xerecord.cxx
@@ -46,16 +46,10 @@ void XclExpRecordBase::SaveXml( XclExpXmlStream& /*rStrm*/ )
{
}
-//UNUSED2008-05 void XclExpRecordBase::SaveRepeated( XclExpStream& rStrm, size_t nCount )
-//UNUSED2008-05 {
-//UNUSED2008-05 for( size_t nIndex = 0; nIndex < nCount; ++nIndex )
-//UNUSED2008-05 Save( rStrm );
-//UNUSED2008-05 }
-
// ----------------------------------------------------------------------------
-XclExpDelegatingRecord::XclExpDelegatingRecord( XclExpRecordBase* pRecord )
- : mpRecord( pRecord )
+XclExpDelegatingRecord::XclExpDelegatingRecord( XclExpRecordBase* pRecord ) :
+ mpRecord( pRecord )
{
}
@@ -67,9 +61,8 @@ XclExpDelegatingRecord::~XclExpDelegatingRecord()
void XclExpDelegatingRecord::SaveXml( XclExpXmlStream& rStrm )
{
- if( !mpRecord )
- return;
- mpRecord->SaveXml( rStrm );
+ if( mpRecord )
+ mpRecord->SaveXml( rStrm );
}
// ----------------------------------------------------------------------------
diff --git a/sc/source/filter/excel/xeroot.cxx b/sc/source/filter/excel/xeroot.cxx
index 922adceb061b..834873740d68 100644
--- a/sc/source/filter/excel/xeroot.cxx
+++ b/sc/source/filter/excel/xeroot.cxx
@@ -27,6 +27,7 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sc.hxx"
+
#include <sfx2/docfile.hxx>
#include <sfx2/sfxsids.hrc>
#include <unotools/saveopt.hxx>
@@ -35,12 +36,13 @@
#include <svl/eitem.hxx>
#include "xecontent.hxx"
#include "xltracer.hxx"
-#include "xehelper.hxx"
+#include "xeescher.hxx"
#include "xeformula.hxx"
+#include "xehelper.hxx"
#include "xelink.hxx"
#include "xename.hxx"
-#include "xestyle.hxx"
#include "xepivot.hxx"
+#include "xestyle.hxx"
#include "xeroot.hxx"
#include "excrecds.hxx" // for filter manager
@@ -142,6 +144,12 @@ XclExpNameManager& XclExpRoot::GetNameManager() const
return *mrExpData.mxNameMgr;
}
+XclExpObjectManager& XclExpRoot::GetObjectManager() const
+{
+ DBG_ASSERT( mrExpData.mxObjMgr.is(), "XclExpRoot::GetObjectManager - missing object (wrong BIFF?)" );
+ return *mrExpData.mxObjMgr;
+}
+
XclExpFilterManager& XclExpRoot::GetFilterManager() const
{
DBG_ASSERT( mrExpData.mxFilterMgr.is(), "XclExpRoot::GetFilterManager - missing object (wrong BIFF?)" );
@@ -181,6 +189,7 @@ void XclExpRoot::InitializeGlobals()
if( GetBiff() == EXC_BIFF8 )
{
mrExpData.mxSst.reset( new XclExpSst );
+ mrExpData.mxObjMgr.reset( new XclExpObjectManager( GetRoot() ) );
mrExpData.mxFilterMgr.reset( new XclExpFilterManager( GetRoot() ) );
mrExpData.mxPTableMgr.reset( new XclExpPivotTableManager( GetRoot() ) );
// BIFF8: only one link manager for all sheets
diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx
index 5ec414a82ebe..1e386510b580 100644
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -37,6 +37,7 @@
#include <com/sun/star/drawing/Direction3D.hpp>
#include <com/sun/star/drawing/ProjectionMode.hpp>
#include <com/sun/star/drawing/ShadeMode.hpp>
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
#include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp>
#include <com/sun/star/chart/ChartAxisLabelPosition.hpp>
#include <com/sun/star/chart/ChartAxisMarkPosition.hpp>
@@ -63,6 +64,8 @@
#include <com/sun/star/chart/MissingValueTreatment.hpp>
#include <sfx2/objsh.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/unoapi.hxx>
#include "document.hxx"
#include "drwlayer.hxx"
@@ -79,7 +82,6 @@
#include "xistyle.hxx"
#include "xipage.hxx"
#include "xiview.hxx"
-#include "xiescher.hxx"
using ::rtl::OUString;
using ::rtl::OUStringBuffer;
@@ -88,11 +90,14 @@ using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::UNO_QUERY;
using ::com::sun::star::uno::UNO_QUERY_THROW;
+using ::com::sun::star::uno::UNO_SET_THROW;
using ::com::sun::star::uno::Exception;
using ::com::sun::star::beans::XPropertySet;
using ::com::sun::star::lang::XMultiServiceFactory;
using ::com::sun::star::frame::XModel;
using ::com::sun::star::util::XNumberFormatsSupplier;
+using ::com::sun::star::drawing::XDrawPage;
+using ::com::sun::star::drawing::XDrawPageSupplier;
using ::com::sun::star::chart2::XChartDocument;
using ::com::sun::star::chart2::XDiagram;
@@ -123,8 +128,6 @@ using ::com::sun::star::chart2::data::XDataSequence;
using ::formula::FormulaToken;
using ::formula::StackVar;
-using ::std::vector;
-
// Helpers ====================================================================
namespace {
@@ -248,14 +251,14 @@ void XclImpChRoot::InitConversion( Reference< XChartDocument > xChartDoc ) const
}
}
-void XclImpChRoot::FinishConversion( ScfProgressBar& rProgress ) const
+void XclImpChRoot::FinishConversion( XclImpDffConverter& rDffConv ) const
{
- rProgress.Progress( EXC_CHART_PROGRESS_SIZE );
+ rDffConv.Progress( EXC_CHART_PROGRESS_SIZE );
// unlock the model
Reference< XModel > xModel( mxChData->GetChartDoc(), UNO_QUERY );
if( xModel.is() )
xModel->unlockControllers();
- rProgress.Progress( EXC_CHART_PROGRESS_SIZE );
+ rDffConv.Progress( EXC_CHART_PROGRESS_SIZE );
mxChData->FinishConversion();
}
@@ -793,9 +796,9 @@ Sequence< Reference< XFormattedString > > XclImpChSourceLink::CreateStringSequen
return ScfApiHelper::VectorToSequence( aStringVec );
}
-void XclImpChSourceLink::FillSourceLink(vector<ScSharedTokenRef>& rTokens) const
+void XclImpChSourceLink::FillSourceLink( ::std::vector< ScSharedTokenRef >& rTokens ) const
{
- if (!mxTokenArray.is())
+ if( !mxTokenArray.is() )
// no links to fill.
return;
@@ -1855,16 +1858,16 @@ Reference< XDataSeries > XclImpChSeries::CreateDataSeries() const
return xDataSeries;
}
-void XclImpChSeries::FillAllSourceLinks(vector<ScSharedTokenRef>& rTokens) const
+void XclImpChSeries::FillAllSourceLinks( ::std::vector< ScSharedTokenRef >& rTokens ) const
{
- if (mxValueLink.is())
- mxValueLink->FillSourceLink(rTokens);
- if (mxCategLink.is())
- mxCategLink->FillSourceLink(rTokens);
- if (mxTitleLink.is())
- mxTitleLink->FillSourceLink(rTokens);
- if (mxBubbleLink.is())
- mxBubbleLink->FillSourceLink(rTokens);
+ if( mxValueLink.is() )
+ mxValueLink->FillSourceLink( rTokens );
+ if( mxCategLink.is() )
+ mxCategLink->FillSourceLink( rTokens );
+ if( mxTitleLink.is() )
+ mxTitleLink->FillSourceLink( rTokens );
+ if( mxBubbleLink.is() )
+ mxBubbleLink->FillSourceLink( rTokens );
}
void XclImpChSeries::ReadChSourceLink( XclImpStream& rStrm )
@@ -3513,7 +3516,7 @@ XclImpChTextRef XclImpChChart::GetDefaultText( XclChTextType eTextType ) const
return maDefTexts.get( nDefTextId );
}
-void XclImpChChart::Convert( Reference< XChartDocument > xChartDoc, ScfProgressBar& rProgress, const OUString& rObjName ) const
+void XclImpChChart::Convert( Reference< XChartDocument > xChartDoc, XclImpDffConverter& rDffConv, const OUString& rObjName ) const
{
// initialize conversion (locks the model to suppress any internal updates)
InitConversion( xChartDoc );
@@ -3555,27 +3558,21 @@ void XclImpChChart::Convert( Reference< XChartDocument > xChartDoc, ScfProgressB
}
// unlock the model
- FinishConversion( rProgress );
+ FinishConversion( rDffConv );
- ScDocument* pDoc = &GetRoot().GetDoc();
- ScChartListenerCollection* pChartCollection = pDoc->GetChartListenerCollection();
- if (pChartCollection)
+ // start listening to this chart
+ ScDocument& rDoc = GetRoot().GetDoc();
+ if( ScChartListenerCollection* pChartCollection = rDoc.GetChartListenerCollection() )
{
- // Now, start listening to this chart.
- ::std::auto_ptr< vector<ScSharedTokenRef> > pRefTokens(new vector<ScSharedTokenRef>);
- for (XclImpChSeriesVec::const_iterator itr = maSeries.begin(), itrEnd = maSeries.end(); itr != itrEnd; ++itr)
- {
- const XclImpChSeriesRef& rSeries = *itr;
- rSeries->FillAllSourceLinks(*pRefTokens);
- }
- if (!pRefTokens->empty())
+ ::std::auto_ptr< ::std::vector< ScSharedTokenRef > > xRefTokens( new ::std::vector< ScSharedTokenRef > );
+ for( XclImpChSeriesVec::const_iterator aIt = maSeries.begin(), aEnd = maSeries.end(); aIt != aEnd; ++aIt )
+ (*aIt)->FillAllSourceLinks( *xRefTokens );
+ if( !xRefTokens->empty() )
{
- ::std::auto_ptr<ScChartListener> pListener(
- new ScChartListener(rObjName, pDoc, pRefTokens.release()));
- pListener->SetUsed(true);
- pListener->StartListeningTo();
- pChartCollection->Insert(pListener.release());
-
+ ::std::auto_ptr< ScChartListener > xListener( new ScChartListener( rObjName, &rDoc, xRefTokens.release() ) );
+ xListener->SetUsed( true );
+ xListener->StartListeningTo();
+ pChartCollection->Insert( xListener.release() );
}
}
}
@@ -3733,6 +3730,68 @@ Reference< XDiagram > XclImpChChart::CreateDiagram() const
// ----------------------------------------------------------------------------
+XclImpChartDrawing::XclImpChartDrawing( const XclImpRoot& rRoot, bool bOwnTab ) :
+ XclImpDrawing( rRoot, bOwnTab ), // sheet charts may contain OLE objects
+ mnScTab( rRoot.GetCurrScTab() ),
+ mbOwnTab( bOwnTab )
+{
+}
+
+void XclImpChartDrawing::ConvertObjects( XclImpDffConverter& rDffConv,
+ const Reference< XModel >& rxModel, const Rectangle& rChartRect )
+{
+ maChartRect = rChartRect; // needed in CalcAnchorRect() callback
+
+ SdrModel* pSdrModel = 0;
+ SdrPage* pSdrPage = 0;
+ if( mbOwnTab )
+ {
+ // chart sheet: insert all shapes into the sheet, not into the chart object
+ pSdrModel = GetDoc().GetDrawLayer();
+ pSdrPage = GetSdrPage( mnScTab );
+ }
+ else
+ {
+ // embedded chart object: insert all shapes into the chart
+ try
+ {
+ Reference< XDrawPageSupplier > xDrawPageSupp( rxModel, UNO_QUERY_THROW );
+ Reference< XDrawPage > xDrawPage( xDrawPageSupp->getDrawPage(), UNO_SET_THROW );
+ pSdrPage = ::GetSdrPageFromXDrawPage( xDrawPage );
+ pSdrModel = pSdrPage ? pSdrPage->GetModel() : 0;
+ }
+ catch( Exception& )
+ {
+ }
+ }
+
+ if( pSdrModel && pSdrPage )
+ ImplConvertObjects( rDffConv, *pSdrModel, *pSdrPage );
+}
+
+Rectangle XclImpChartDrawing::CalcAnchorRect( const XclObjAnchor& rAnchor, bool bDffAnchor ) const
+{
+ /* In objects with DFF client anchor, the position of the shape is stored
+ in the cell address components of the client anchor. In old BIFF3-BIFF5
+ objects, the position is stored in the offset components of the anchor. */
+ Rectangle aRect(
+ static_cast< long >( static_cast< double >( bDffAnchor ? rAnchor.maFirst.mnCol : rAnchor.mnLX ) / EXC_CHART_UNIT * maChartRect.GetWidth() + 0.5 ),
+ static_cast< long >( static_cast< double >( bDffAnchor ? rAnchor.maFirst.mnRow : rAnchor.mnTY ) / EXC_CHART_UNIT * maChartRect.GetHeight() + 0.5 ),
+ static_cast< long >( static_cast< double >( bDffAnchor ? rAnchor.maLast.mnCol : rAnchor.mnRX ) / EXC_CHART_UNIT * maChartRect.GetWidth() + 0.5 ),
+ static_cast< long >( static_cast< double >( bDffAnchor ? rAnchor.maLast.mnRow : rAnchor.mnBY ) / EXC_CHART_UNIT * maChartRect.GetHeight() + 0.5 ) );
+ aRect.Justify();
+ // move shapes into chart area for sheet charts
+ if( mbOwnTab )
+ aRect.Move( maChartRect.Left(), maChartRect.Top() );
+ return aRect;
+}
+
+void XclImpChartDrawing::OnObjectInserted( const XclImpDrawObjBase& )
+{
+}
+
+// ----------------------------------------------------------------------------
+
XclImpChart::XclImpChart( const XclImpRoot& rRoot, bool bOwnTab ) :
XclImpRoot( rRoot ),
mbOwnTab( bOwnTab ),
@@ -3740,6 +3799,10 @@ XclImpChart::XclImpChart( const XclImpRoot& rRoot, bool bOwnTab ) :
{
}
+XclImpChart::~XclImpChart()
+{
+}
+
void XclImpChart::ReadChartSubStream( XclImpStream& rStrm )
{
XclImpPageSettings& rPageSett = GetPageSettings();
@@ -3776,6 +3839,7 @@ void XclImpChart::ReadChartSubStream( XclImpStream& rStrm )
break;
}
+ // common records
switch( rStrm.GetRecId() )
{
case EXC_ID_EOF: bLoop = false; break;
@@ -3787,12 +3851,29 @@ void XclImpChart::ReadChartSubStream( XclImpStream& rStrm )
case EXC_ID5_BOF: XclTools::SkipSubStream( rStrm ); break;
case EXC_ID_CHCHART: ReadChChart( rStrm ); break;
- case EXC_ID_OBJ: GetTracer().TraceChartEmbeddedObj(); break;
case EXC_ID8_CHPIVOTREF:
GetTracer().TracePivotChartExists();
mbIsPivotChart = true;
break;
+
+ // BIFF specific records
+ default: switch( GetBiff() )
+ {
+ case EXC_BIFF5: switch( rStrm.GetRecId() )
+ {
+ case EXC_ID_OBJ: GetChartDrawing().ReadObj( rStrm ); break;
+ }
+ break;
+ case EXC_BIFF8: switch( rStrm.GetRecId() )
+ {
+ case EXC_ID_MSODRAWING: GetChartDrawing().ReadMsoDrawing( rStrm ); break;
+ // #i61786# weird documents: OBJ without MSODRAWING -> read in BIFF5 format
+ case EXC_ID_OBJ: GetChartDrawing().ReadObj( rStrm ); break;
+ }
+ break;
+ default:;
+ }
}
}
}
@@ -3806,14 +3887,28 @@ void XclImpChart::UpdateObjFrame( const XclObjLineData& rLineData, const XclObjF
sal_Size XclImpChart::GetProgressSize() const
{
- return mxChartData.is() ? mxChartData->GetProgressSize() : 0;
+ return
+ (mxChartData.is() ? mxChartData->GetProgressSize() : 0) +
+ (mxChartDrawing.is() ? mxChartDrawing->GetProgressSize() : 0);
}
-void XclImpChart::Convert( Reference< XModel > xModel, ScfProgressBar& rProgress, const OUString& rObjName ) const
+void XclImpChart::Convert( Reference< XModel > xModel, XclImpDffConverter& rDffConv, const OUString& rObjName, const Rectangle& rChartRect ) const
{
Reference< XChartDocument > xChartDoc( xModel, UNO_QUERY );
- if( mxChartData.is() && xChartDoc.is() )
- mxChartData->Convert( xChartDoc, rProgress, rObjName );
+ if( xChartDoc.is() )
+ {
+ if( mxChartData.is() )
+ mxChartData->Convert( xChartDoc, rDffConv, rObjName );
+ if( mxChartDrawing.is() )
+ mxChartDrawing->ConvertObjects( rDffConv, xModel, rChartRect );
+ }
+}
+
+XclImpChartDrawing& XclImpChart::GetChartDrawing()
+{
+ if( !mxChartDrawing )
+ mxChartDrawing.reset( new XclImpChartDrawing( GetRoot(), mbOwnTab ) );
+ return *mxChartDrawing;
}
void XclImpChart::ReadChChart( XclImpStream& rStrm )
diff --git a/sc/source/filter/excel/xicontent.cxx b/sc/source/filter/excel/xicontent.cxx
index 9c130d2ebb78..fb1eb9a3bf44 100644
--- a/sc/source/filter/excel/xicontent.cxx
+++ b/sc/source/filter/excel/xicontent.cxx
@@ -710,7 +710,7 @@ void XclImpValidation::ReadDval( XclImpStream& rStrm )
if( nObjId != EXC_DVAL_NOOBJ )
{
DBG_ASSERT( nObjId <= 0xFFFF, "XclImpValidation::ReadDval - invalid object ID" );
- rRoot.GetObjectManager().SetSkipObj( rRoot.GetCurrScTab(), static_cast< sal_uInt16 >( nObjId ) );
+ rRoot.GetCurrSheetDrawing().SetSkipObj( static_cast< sal_uInt16 >( nObjId ) );
}
}
@@ -1213,7 +1213,29 @@ void XclImpSheetProtectBuffer::ReadProtect( XclImpStream& rStrm, SCTAB nTab )
void XclImpSheetProtectBuffer::ReadOptions( XclImpStream& rStrm, SCTAB nTab )
{
- rStrm.Ignore(19);
+ rStrm.Ignore(12);
+
+ // feature type can be either 2 or 4. If 2, this record stores flag for
+ // enhanced protection, whereas if 4 it stores flag for smart tag.
+ sal_uInt16 nFeatureType;
+ rStrm >> nFeatureType;
+ if (nFeatureType != 2)
+ // We currently only support import of enhanced protection data.
+ return;
+
+ rStrm.Ignore(1); // always 1
+
+ // The flag size specifies the size of bytes that follows that stores
+ // feature data. If -1 it depends on the feature type imported earlier.
+ // For enhanced protection data, the size is always 4. For the most xls
+ // documents out there this value is almost always -1.
+ sal_Int32 nFlagSize;
+ rStrm >> nFlagSize;
+ if (nFlagSize != -1)
+ return;
+
+ // There are actually 4 bytes to read, but the upper 2 bytes currently
+ // don't store any bits.
sal_uInt16 nOptions;
rStrm >> nOptions;
diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx
index e963495a3f4b..64ed79e3d3b2 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -118,13 +118,13 @@
using ::rtl::OUString;
using ::rtl::OUStringBuffer;
-using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::Any;
-using ::com::sun::star::uno::XInterface;
using ::com::sun::star::uno::Exception;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::UNO_QUERY;
using ::com::sun::star::uno::UNO_QUERY_THROW;
+using ::com::sun::star::uno::UNO_SET_THROW;
using ::com::sun::star::beans::NamedValue;
using ::com::sun::star::lang::XMultiServiceFactory;
using ::com::sun::star::container::XIndexContainer;
@@ -193,10 +193,11 @@ typedef TSdrObjectPtr< SdrObject > SdrObjectPtr;
XclImpDrawObjBase::XclImpDrawObjBase( const XclImpRoot& rRoot ) :
XclImpRoot( rRoot ),
- maObjId( rRoot.GetCurrScTab(), EXC_OBJ_INVALID_ID ),
+ mnObjId( EXC_OBJ_INVALID_ID ),
mnObjType( EXC_OBJTYPE_UNKNOWN ),
mnDffShapeId( 0 ),
mnDffFlags( 0 ),
+ mbHasAnchor( false ),
mbHidden( false ),
mbVisible( true ),
mbPrintable( true ),
@@ -213,9 +214,8 @@ XclImpDrawObjBase::~XclImpDrawObjBase()
{
}
-XclImpDrawObjRef XclImpDrawObjBase::ReadObj3( XclImpStream& rStrm )
+/*static*/ XclImpDrawObjRef XclImpDrawObjBase::ReadObj3( const XclImpRoot& rRoot, XclImpStream& rStrm )
{
- const XclImpRoot& rRoot = rStrm.GetRoot();
XclImpDrawObjRef xDrawObj;
if( rStrm.GetRecLeft() >= 30 )
@@ -245,9 +245,8 @@ XclImpDrawObjRef XclImpDrawObjBase::ReadObj3( XclImpStream& rStrm )
return xDrawObj;
}
-XclImpDrawObjRef XclImpDrawObjBase::ReadObj4( XclImpStream& rStrm )
+/*static*/ XclImpDrawObjRef XclImpDrawObjBase::ReadObj4( const XclImpRoot& rRoot, XclImpStream& rStrm )
{
- const XclImpRoot& rRoot = rStrm.GetRoot();
XclImpDrawObjRef xDrawObj;
if( rStrm.GetRecLeft() >= 30 )
@@ -278,9 +277,8 @@ XclImpDrawObjRef XclImpDrawObjBase::ReadObj4( XclImpStream& rStrm )
return xDrawObj;
}
-XclImpDrawObjRef XclImpDrawObjBase::ReadObj5( XclImpStream& rStrm )
+/*static*/ XclImpDrawObjRef XclImpDrawObjBase::ReadObj5( const XclImpRoot& rRoot, XclImpStream& rStrm )
{
- const XclImpRoot& rRoot = rStrm.GetRoot();
XclImpDrawObjRef xDrawObj;
if( rStrm.GetRecLeft() >= 34 )
@@ -321,9 +319,8 @@ XclImpDrawObjRef XclImpDrawObjBase::ReadObj5( XclImpStream& rStrm )
return xDrawObj;
}
-XclImpDrawObjRef XclImpDrawObjBase::ReadObj8( XclImpStream& rStrm )
+/*static*/ XclImpDrawObjRef XclImpDrawObjBase::ReadObj8( const XclImpRoot& rRoot, XclImpStream& rStrm )
{
- const XclImpRoot& rRoot = rStrm.GetRoot();
XclImpDrawObjRef xDrawObj;
if( rStrm.GetRecLeft() >= 10 )
@@ -380,6 +377,12 @@ XclImpDrawObjRef XclImpDrawObjBase::ReadObj8( XclImpStream& rStrm )
return xDrawObj;
}
+void XclImpDrawObjBase::SetAnchor( const XclObjAnchor& rAnchor )
+{
+ maAnchor = rAnchor;
+ mbHasAnchor = true;
+}
+
void XclImpDrawObjBase::SetDffData( const DffObjData& rDffObjData, const String& rObjName, const String& rHyperlink, bool bVisible, bool bAutoMargin )
{
mnDffShapeId = rDffObjData.nShapeId;
@@ -390,11 +393,6 @@ void XclImpDrawObjBase::SetDffData( const DffObjData& rDffObjData, const String&
mbAutoMargin = bAutoMargin;
}
-void XclImpDrawObjBase::SetAnchor( const XclObjAnchor& rAnchor )
-{
- mxAnchor.reset( new XclObjAnchor( rAnchor ) );
-}
-
String XclImpDrawObjBase::GetObjName() const
{
/* #118053# #i51348# Always return a non-empty name. Create English
@@ -404,6 +402,11 @@ String XclImpDrawObjBase::GetObjName() const
return (maObjName.Len() > 0) ? maObjName : GetObjectManager().GetDefaultObjName( *this );
}
+const XclObjAnchor* XclImpDrawObjBase::GetAnchor() const
+{
+ return mbHasAnchor ? &maAnchor : 0;
+}
+
bool XclImpDrawObjBase::IsValidSize( const Rectangle& rAnchorRect ) const
{
// XclObjAnchor rounds up the width, width of 3 is the result of an Excel width of 0
@@ -412,56 +415,45 @@ bool XclImpDrawObjBase::IsValidSize( const Rectangle& rAnchorRect ) const
((rAnchorRect.GetWidth() > 3) || (rAnchorRect.GetHeight() > 1));
}
-ScRange XclImpDrawObjBase::GetUsedArea() const
+ScRange XclImpDrawObjBase::GetUsedArea( SCTAB nScTab ) const
{
ScRange aScUsedArea( ScAddress::INITIALIZE_INVALID );
- if( mxAnchor.is() )
+ // #i44077# object inserted -> update used area for OLE object import
+ if( mbHasAnchor && GetAddressConverter().ConvertRange( aScUsedArea, maAnchor, nScTab, nScTab, false ) )
{
- // #i44077# object inserted -> update used area for OLE object import
- if( GetAddressConverter().ConvertRange( aScUsedArea, *mxAnchor, GetScTab(), GetScTab(), false ) )
- {
- // reduce range, if object ends directly on borders between two columns or rows
- if( (mxAnchor->mnRX == 0) && (aScUsedArea.aStart.Col() < aScUsedArea.aEnd.Col()) )
- aScUsedArea.aEnd.IncCol( -1 );
- if( (mxAnchor->mnBY == 0) && (aScUsedArea.aStart.Row() < aScUsedArea.aEnd.Row()) )
- aScUsedArea.aEnd.IncRow( -1 );
- }
+ // reduce range, if object ends directly on borders between two columns or rows
+ if( (maAnchor.mnRX == 0) && (aScUsedArea.aStart.Col() < aScUsedArea.aEnd.Col()) )
+ aScUsedArea.aEnd.IncCol( -1 );
+ if( (maAnchor.mnBY == 0) && (aScUsedArea.aStart.Row() < aScUsedArea.aEnd.Row()) )
+ aScUsedArea.aEnd.IncRow( -1 );
}
return aScUsedArea;
}
-Rectangle XclImpDrawObjBase::GetAnchorRect() const
-{
- Rectangle aAnchorRect;
- if( mxAnchor.is() )
- aAnchorRect = mxAnchor->GetRect( GetDoc(), MAP_100TH_MM );
- return aAnchorRect;
-}
-
sal_Size XclImpDrawObjBase::GetProgressSize() const
{
return DoGetProgressSize();
}
-SdrObject* XclImpDrawObjBase::CreateSdrObject( const Rectangle& rAnchorRect, ScfProgressBar& rProgress, bool bDffImport ) const
+SdrObject* XclImpDrawObjBase::CreateSdrObject( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect, bool bIsDff ) const
{
SdrObjectPtr xSdrObj;
- if( bDffImport && !mbCustomDff )
+ if( bIsDff && !mbCustomDff )
{
- rProgress.Progress( GetProgressSize() );
+ rDffConv.Progress( GetProgressSize() );
}
else
{
- xSdrObj.reset( DoCreateSdrObj( rAnchorRect, rProgress ) );
+ xSdrObj.reset( DoCreateSdrObj( rDffConv, rAnchorRect ) );
if( xSdrObj.is() )
- xSdrObj->SetModel( GetDoc().GetDrawLayer() );
+ xSdrObj->SetModel( rDffConv.GetModel() );
}
return xSdrObj.release();
}
-void XclImpDrawObjBase::ProcessSdrObject( SdrObject& rSdrObj ) const
+void XclImpDrawObjBase::PreProcessSdrObject( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const
{
- // default: front layer, derived classes may have to set other layer in DoProcessSdrObj()
+ // default: front layer, derived classes may have to set other layer in DoPreProcessSdrObj()
rSdrObj.NbcSetLayer( SC_LAYER_FRONT );
// set object name (GetObjName() will always return a non-empty name)
@@ -473,7 +465,7 @@ void XclImpDrawObjBase::ProcessSdrObject( SdrObject& rSdrObj ) const
// automatic text margin
if( mbAutoMargin )
{
- sal_Int32 nMargin = GetObjectManager().GetDffManager().GetDefaultTextMargin();
+ sal_Int32 nMargin = rDffConv.GetDefaultTextMargin();
rSdrObj.SetMergedItem( SdrTextLeftDistItem( nMargin ) );
rSdrObj.SetMergedItem( SdrTextRightDistItem( nMargin ) );
rSdrObj.SetMergedItem( SdrTextUpperDistItem( nMargin ) );
@@ -497,7 +489,13 @@ void XclImpDrawObjBase::ProcessSdrObject( SdrObject& rSdrObj ) const
#endif
// call virtual function for object type specific processing
- DoProcessSdrObj( rSdrObj );
+ DoPreProcessSdrObj( rDffConv, rSdrObj );
+}
+
+void XclImpDrawObjBase::PostProcessSdrObject( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const
+{
+ // call virtual function for object type specific processing
+ DoPostProcessSdrObj( rDffConv, rSdrObj );
}
// protected ------------------------------------------------------------------
@@ -759,68 +757,69 @@ sal_Size XclImpDrawObjBase::DoGetProgressSize() const
return 1;
}
-SdrObject* XclImpDrawObjBase::DoCreateSdrObj( const Rectangle&, ScfProgressBar& rProgress ) const
+SdrObject* XclImpDrawObjBase::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& ) const
{
- rProgress.Progress( GetProgressSize() );
+ rDffConv.Progress( GetProgressSize() );
return 0;
}
-void XclImpDrawObjBase::DoProcessSdrObj( SdrObject& /*rSdrObj*/ ) const
+void XclImpDrawObjBase::DoPreProcessSdrObj( XclImpDffConverter&, SdrObject& ) const
{
// trace if object is not printable
if( !IsPrintable() )
GetTracer().TraceObjectNotPrintable();
}
-void XclImpDrawObjBase::ImplReadObj3( XclImpStream& rStrm )
+void XclImpDrawObjBase::DoPostProcessSdrObj( XclImpDffConverter&, SdrObject& ) const
{
- sal_uInt16 nObjFlags, nMacroSize;
- XclObjAnchor aAnchor( GetCurrScTab() );
+}
+void XclImpDrawObjBase::ImplReadObj3( XclImpStream& rStrm )
+{
// back to offset 4 (ignore object count field)
rStrm.Seek( 4 );
- rStrm >> mnObjType >> maObjId.mnObjId >> nObjFlags >> aAnchor >> nMacroSize;
+
+ sal_uInt16 nObjFlags, nMacroSize;
+ rStrm >> mnObjType >> mnObjId >> nObjFlags >> maAnchor >> nMacroSize;
rStrm.Ignore( 2 );
+ mbHasAnchor = true;
mbHidden = ::get_flag( nObjFlags, EXC_OBJ_HIDDEN );
mbVisible = ::get_flag( nObjFlags, EXC_OBJ_VISIBLE );
- SetAnchor( aAnchor );
DoReadObj3( rStrm, nMacroSize );
}
void XclImpDrawObjBase::ImplReadObj4( XclImpStream& rStrm )
{
- sal_uInt16 nObjFlags, nMacroSize;
- XclObjAnchor aAnchor( GetCurrScTab() );
-
// back to offset 4 (ignore object count field)
rStrm.Seek( 4 );
- rStrm >> mnObjType >> maObjId.mnObjId >> nObjFlags >> aAnchor >> nMacroSize;
+
+ sal_uInt16 nObjFlags, nMacroSize;
+ rStrm >> mnObjType >> mnObjId >> nObjFlags >> maAnchor >> nMacroSize;
rStrm.Ignore( 2 );
+ mbHasAnchor = true;
mbHidden = ::get_flag( nObjFlags, EXC_OBJ_HIDDEN );
mbVisible = ::get_flag( nObjFlags, EXC_OBJ_VISIBLE );
mbPrintable = ::get_flag( nObjFlags, EXC_OBJ_PRINTABLE );
- SetAnchor( aAnchor );
DoReadObj4( rStrm, nMacroSize );
}
void XclImpDrawObjBase::ImplReadObj5( XclImpStream& rStrm )
{
- sal_uInt16 nObjFlags, nMacroSize, nNameLen;
- XclObjAnchor aAnchor( GetCurrScTab() );
-
// back to offset 4 (ignore object count field)
rStrm.Seek( 4 );
- rStrm >> mnObjType >> maObjId.mnObjId >> nObjFlags >> aAnchor >> nMacroSize;
+
+ sal_uInt16 nObjFlags, nMacroSize, nNameLen;
+ rStrm >> mnObjType >> mnObjId >> nObjFlags >> maAnchor >> nMacroSize;
rStrm.Ignore( 2 );
rStrm >> nNameLen;
rStrm.Ignore( 2 );
+ mbHasAnchor = true;
mbHidden = ::get_flag( nObjFlags, EXC_OBJ_HIDDEN );
mbVisible = ::get_flag( nObjFlags, EXC_OBJ_VISIBLE );
mbPrintable = ::get_flag( nObjFlags, EXC_OBJ_PRINTABLE );
- SetAnchor( aAnchor );
DoReadObj5( rStrm, nNameLen, nMacroSize );
}
@@ -845,7 +844,7 @@ void XclImpDrawObjBase::ImplReadObj8( XclImpStream& rStrm )
if( (rStrm.GetRecPos() == 4) && (nSubRecSize >= 6) )
{
sal_uInt16 nObjFlags;
- rStrm >> mnObjType >> maObjId.mnObjId >> nObjFlags;
+ rStrm >> mnObjType >> mnObjId >> nObjFlags;
mbPrintable = ::get_flag( nObjFlags, EXC_OBJCMO_PRINTABLE );
}
break;
@@ -928,7 +927,7 @@ XclImpGroupObj::XclImpGroupObj( const XclImpRoot& rRoot ) :
bool XclImpGroupObj::TryInsert( XclImpDrawObjRef xDrawObj )
{
- if( (xDrawObj->GetScTab() != GetScTab()) || (xDrawObj->GetObjId().mnObjId == mnFirstUngrouped) )
+ if( xDrawObj->GetObjId() == mnFirstUngrouped )
return false;
// insert into own list or into nested group
maChildren.InsertGrouped( xDrawObj );
@@ -965,13 +964,14 @@ sal_Size XclImpGroupObj::DoGetProgressSize() const
return XclImpDrawObjBase::DoGetProgressSize() + maChildren.GetProgressSize();
}
-SdrObject* XclImpGroupObj::DoCreateSdrObj( const Rectangle& /*rAnchorRect*/, ScfProgressBar& rProgress ) const
+SdrObject* XclImpGroupObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& /*rAnchorRect*/ ) const
{
TSdrObjectPtr< SdrObjGroup > xSdrObj( new SdrObjGroup );
// child objects in BIFF2-BIFF5 have absolute size, not needed to pass own anchor rectangle
+ SdrObjList& rObjList = *xSdrObj->GetSubList(); // SdrObjGroup always returns existing sublist
for( XclImpDrawObjVector::const_iterator aIt = maChildren.begin(), aEnd = maChildren.end(); aIt != aEnd; ++aIt )
- GetObjectManager().GetDffManager().ProcessObject( xSdrObj->GetSubList(), **aIt );
- rProgress.Progress();
+ rDffConv.ProcessObject( rObjList, **aIt );
+ rDffConv.Progress();
return xSdrObj.release();
}
@@ -1007,7 +1007,7 @@ void XclImpLineObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uI
ReadMacro5( rStrm, nMacroSize );
}
-SdrObject* XclImpLineObj::DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const
+SdrObject* XclImpLineObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const
{
::basegfx::B2DPolygon aB2DPolygon;
switch( mnStartPoint )
@@ -1100,7 +1100,7 @@ SdrObject* XclImpLineObj::DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgr
xSdrObj->SetMergedItem( XLineEndCenterItem( FALSE ) );
}
}
- rProgress.Progress();
+ rDffConv.Progress();
return xSdrObj.release();
}
@@ -1144,11 +1144,11 @@ void XclImpRectObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uI
ReadMacro5( rStrm, nMacroSize );
}
-SdrObject* XclImpRectObj::DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const
+SdrObject* XclImpRectObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const
{
SdrObjectPtr xSdrObj( new SdrRectObj( rAnchorRect ) );
ConvertRectStyle( *xSdrObj );
- rProgress.Progress();
+ rDffConv.Progress();
return xSdrObj.release();
}
@@ -1159,11 +1159,11 @@ XclImpOvalObj::XclImpOvalObj( const XclImpRoot& rRoot ) :
{
}
-SdrObject* XclImpOvalObj::DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const
+SdrObject* XclImpOvalObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const
{
SdrObjectPtr xSdrObj( new SdrCircObj( OBJ_CIRC, rAnchorRect ) );
ConvertRectStyle( *xSdrObj );
- rProgress.Progress();
+ rDffConv.Progress();
return xSdrObj.release();
}
@@ -1198,7 +1198,7 @@ void XclImpArcObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uIn
ReadMacro5( rStrm, nMacroSize );
}
-SdrObject* XclImpArcObj::DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const
+SdrObject* XclImpArcObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const
{
Rectangle aNewRect = rAnchorRect;
long nStartAngle = 0;
@@ -1235,7 +1235,7 @@ SdrObject* XclImpArcObj::DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgre
SdrObjectPtr xSdrObj( new SdrCircObj( eObjKind, aNewRect, nStartAngle, nEndAngle ) );
ConvertFillStyle( *xSdrObj, maFillData );
ConvertLineStyle( *xSdrObj, maLineData );
- rProgress.Progress();
+ rDffConv.Progress();
return xSdrObj.release();
}
@@ -1297,7 +1297,7 @@ namespace {
} // namespace
-SdrObject* XclImpPolygonObj::DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const
+SdrObject* XclImpPolygonObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const
{
SdrObjectPtr xSdrObj;
if( maCoords.size() >= 2 )
@@ -1314,7 +1314,7 @@ SdrObject* XclImpPolygonObj::DoCreateSdrObj( const Rectangle& rAnchorRect, ScfPr
xSdrObj.reset( new SdrPathObj( eObjKind, ::basegfx::B2DPolyPolygon( aB2DPolygon ) ) );
ConvertRectStyle( *xSdrObj );
}
- rProgress.Progress();
+ rDffConv.Progress();
return xSdrObj.release();
}
@@ -1375,7 +1375,7 @@ void XclImpTextObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uI
maTextData.ReadFormats( rStrm );
}
-SdrObject* XclImpTextObj::DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const
+SdrObject* XclImpTextObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const
{
TSdrObjectPtr< SdrObjCustomShape > xSdrObj( new SdrObjCustomShape );
xSdrObj->NbcSetSnapRect( rAnchorRect );
@@ -1386,11 +1386,11 @@ SdrObject* XclImpTextObj::DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgr
xSdrObj->SetMergedItem( SdrTextAutoGrowWidthItem( bAutoSize ) );
xSdrObj->SetMergedItem( SdrTextAutoGrowHeightItem( bAutoSize ) );
xSdrObj->SetMergedItem( SdrTextWordWrapItem( TRUE ) );
- rProgress.Progress();
+ rDffConv.Progress();
return xSdrObj.release();
}
-void XclImpTextObj::DoProcessSdrObj( SdrObject& rSdrObj ) const
+void XclImpTextObj::DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const
{
// set text data
if( SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( &rSdrObj ) )
@@ -1469,7 +1469,7 @@ void XclImpTextObj::DoProcessSdrObj( SdrObject& rSdrObj ) const
case EXC_OBJ_HOR_RIGHT: eVerAlign = SDRTEXTVERTADJUST_BOTTOM; break;
case EXC_OBJ_HOR_JUSTIFY: eVerAlign = SDRTEXTVERTADJUST_BLOCK; break;
}
- MSO_Anchor eTextAnchor = (MSO_Anchor)GetObjectManager().GetDffManager().GetPropertyValue( DFF_Prop_anchorText, mso_anchorTop );
+ MSO_Anchor eTextAnchor = (MSO_Anchor)rDffConv.GetPropertyValue( DFF_Prop_anchorText, mso_anchorTop );
switch( eTextAnchor )
{
case mso_anchorTopCentered :
@@ -1508,7 +1508,7 @@ void XclImpTextObj::DoProcessSdrObj( SdrObject& rSdrObj ) const
case EXC_OBJ_HOR_RIGHT: eVerAlign = SDRTEXTVERTADJUST_TOP; break;
case EXC_OBJ_HOR_JUSTIFY: eVerAlign = SDRTEXTVERTADJUST_BLOCK; break;
}
- MSO_Anchor eTextAnchor = (MSO_Anchor)GetObjectManager().GetDffManager().GetPropertyValue( DFF_Prop_anchorText, mso_anchorTop );
+ MSO_Anchor eTextAnchor = (MSO_Anchor)rDffConv.GetPropertyValue( DFF_Prop_anchorText, mso_anchorTop );
switch ( eTextAnchor )
{
case mso_anchorTopCentered :
@@ -1539,7 +1539,7 @@ void XclImpTextObj::DoProcessSdrObj( SdrObject& rSdrObj ) const
}
}
// base class processing
- XclImpRectObj::DoProcessSdrObj( rSdrObj );
+ XclImpRectObj::DoPreProcessSdrObj( rDffConv, rSdrObj );
}
// ----------------------------------------------------------------------------
@@ -1633,11 +1633,11 @@ sal_Size XclImpChartObj::DoGetProgressSize() const
return mxChart.is() ? mxChart->GetProgressSize() : 1;
}
-SdrObject* XclImpChartObj::DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const
+SdrObject* XclImpChartObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const
{
SdrObjectPtr xSdrObj;
SfxObjectShell* pDocShell = GetDocShell();
- if( SvtModuleOptions().IsChart() && pDocShell && mxChart.is() && !mxChart->IsPivotChart() )
+ if( rDffConv.SupportsOleObjects() && SvtModuleOptions().IsChart() && pDocShell && mxChart.is() && !mxChart->IsPivotChart() )
{
// create embedded chart object
OUString aEmbObjName;
@@ -1655,20 +1655,28 @@ SdrObject* XclImpChartObj::DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProg
// create the container OLE object
xSdrObj.reset( new SdrOle2Obj( svt::EmbeddedObjectRef( xEmbObj, nAspect ), aEmbObjName, rAnchorRect ) );
+ }
- // convert Excel chart to OOo Chart
- if( svt::EmbeddedObjectRef::TryRunningState( xEmbObj ) )
- {
- Reference< XModel > xModel( xEmbObj->getComponent(), UNO_QUERY );
- mxChart->Convert( xModel, rProgress, aEmbObjName );
+ return xSdrObj.release();
+}
- Reference< XEmbedPersist > xPers( xEmbObj, UNO_QUERY );
- if( xPers.is() )
- xPers->storeOwn();
+void XclImpChartObj::DoPostProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const
+{
+ const SdrOle2Obj* pSdrOleObj = dynamic_cast< const SdrOle2Obj* >( &rSdrObj );
+ if( mxChart.is() && pSdrOleObj )
+ {
+ Reference< XEmbeddedObject > xEmbObj = pSdrOleObj->GetObjRef();
+ if( xEmbObj.is() && ::svt::EmbeddedObjectRef::TryRunningState( xEmbObj ) ) try
+ {
+ Reference< XEmbedPersist > xPersist( xEmbObj, UNO_QUERY_THROW );
+ Reference< XModel > xModel( xEmbObj->getComponent(), UNO_QUERY_THROW );
+ mxChart->Convert( xModel, rDffConv, xPersist->getEntryName(), rSdrObj.GetLogicRect() );
+ xPersist->storeOwn();
+ }
+ catch( Exception& )
+ {
}
}
-
- return xSdrObj.release();
}
void XclImpChartObj::FinalizeTabChart()
@@ -1683,12 +1691,12 @@ void XclImpChartObj::FinalizeTabChart()
// calculate size of the chart object
const XclPageData& rPageData = GetPageSettings().GetPageData();
- Size aPaperSize( rPageData.GetScPaperSize() );
+ Size aPaperSize = rPageData.GetScPaperSize();
long nWidth = XclTools::GetHmmFromTwips( aPaperSize.Width() );
long nHeight = XclTools::GetHmmFromTwips( aPaperSize.Height() );
- // subtract page margins, give 1cm extra space
+ // subtract page margins, give some more extra space
nWidth -= (XclTools::GetHmmFromInch( rPageData.mfLeftMargin + rPageData.mfRightMargin ) + 2000);
nHeight -= (XclTools::GetHmmFromInch( rPageData.mfTopMargin + rPageData.mfBottomMargin ) + 1000);
@@ -1700,8 +1708,8 @@ void XclImpChartObj::FinalizeTabChart()
}
// create the object anchor
- XclObjAnchor aAnchor( GetScTab() );
- aAnchor.SetRect( GetDoc(), Rectangle( 1000, 500, nWidth, nHeight ), MAP_100TH_MM );
+ XclObjAnchor aAnchor;
+ aAnchor.SetRect( GetDoc(), GetCurrScTab(), Rectangle( 1000, 500, nWidth, nHeight ), MAP_100TH_MM );
SetAnchor( aAnchor );
}
@@ -1723,10 +1731,10 @@ void XclImpNoteObj::SetNoteData( const ScAddress& rScPos, sal_uInt16 nNoteFlags
mnNoteFlags = nNoteFlags;
}
-void XclImpNoteObj::DoProcessSdrObj( SdrObject& rSdrObj ) const
+void XclImpNoteObj::DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const
{
// create formatted text
- XclImpTextObj::DoProcessSdrObj( rSdrObj );
+ XclImpTextObj::DoPreProcessSdrObj( rDffConv, rSdrObj );
OutlinerParaObject* pOutlinerObj = rSdrObj.GetOutlinerParaObject();
if( maScPos.IsValid() && pOutlinerObj )
{
@@ -1970,16 +1978,16 @@ void XclImpTbxObjBase::ConvertLabel( ScfPropertySet& rPropSet ) const
ConvertFont( rPropSet );
}
-SdrObject* XclImpTbxObjBase::DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const
+SdrObject* XclImpTbxObjBase::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const
{
- SdrObjectPtr xSdrObj( GetObjectManager().GetDffManager().CreateSdrObject( *this, rAnchorRect ) );
- rProgress.Progress();
+ SdrObjectPtr xSdrObj( rDffConv.CreateSdrObject( *this, rAnchorRect ) );
+ rDffConv.Progress();
return xSdrObj.release();
}
-void XclImpTbxObjBase::DoProcessSdrObj( SdrObject& /*rSdrObj*/ ) const
+void XclImpTbxObjBase::DoPreProcessSdrObj( XclImpDffConverter& /*rDffConv*/, SdrObject& /*rSdrObj*/ ) const
{
- // do not call DoProcessSdrObj() from base class (to skip text processing)
+ // do not call DoPreProcessSdrObj() from base class (to skip text processing)
ProcessControl( *this );
}
@@ -2740,7 +2748,7 @@ void XclImpPictureObj::DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize )
ReadPictFmla( rStrm, nLinkSize );
if( (rStrm.GetNextRecId() == EXC_ID3_IMGDATA) && rStrm.StartNextRecord() )
- maGraphic = XclImpObjectManager::ReadImgData( rStrm );
+ maGraphic = XclImpDrawing::ReadImgData( GetRoot(), rStrm );
}
void XclImpPictureObj::DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize )
@@ -2755,7 +2763,7 @@ void XclImpPictureObj::DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize )
ReadPictFmla( rStrm, nLinkSize );
if( (rStrm.GetNextRecId() == EXC_ID3_IMGDATA) && rStrm.StartNextRecord() )
- maGraphic = XclImpObjectManager::ReadImgData( rStrm );
+ maGraphic = XclImpDrawing::ReadImgData( GetRoot(), rStrm );
}
void XclImpPictureObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize )
@@ -2777,7 +2785,7 @@ void XclImpPictureObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal
if( IsHidden() && (GetObjName() == CREATE_STRING( "__BkgndObj" )) )
GetPageSettings().ReadImgData( rStrm );
else
- maGraphic = XclImpObjectManager::ReadImgData( rStrm );
+ maGraphic = XclImpDrawing::ReadImgData( GetRoot(), rStrm );
}
}
@@ -2796,10 +2804,10 @@ void XclImpPictureObj::DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRec
}
}
-SdrObject* XclImpPictureObj::DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const
+SdrObject* XclImpPictureObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const
{
// try to create an OLE object or form control
- SdrObjectPtr xSdrObj( GetObjectManager().GetDffManager().CreateSdrObject( *this, rAnchorRect ) );
+ SdrObjectPtr xSdrObj( rDffConv.CreateSdrObject( *this, rAnchorRect ) );
// no OLE - create a plain picture from IMGDATA record data
if( !xSdrObj && (maGraphic.GetType() != GRAPHIC_NONE) )
@@ -2808,21 +2816,21 @@ SdrObject* XclImpPictureObj::DoCreateSdrObj( const Rectangle& rAnchorRect, ScfPr
ConvertRectStyle( *xSdrObj );
}
- rProgress.Progress();
+ rDffConv.Progress();
return xSdrObj.release();
}
-void XclImpPictureObj::DoProcessSdrObj( SdrObject& rSdrObj ) const
+void XclImpPictureObj::DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const
{
if( IsOcxControl() )
{
- // do not call XclImpRectObj::DoProcessSdrObj(), it would trace missing "printable" feature
+ // do not call XclImpRectObj::DoPreProcessSdrObj(), it would trace missing "printable" feature
ProcessControl( *this );
}
else if( mbEmbedded || mbLinked )
{
// trace missing "printable" feature
- XclImpRectObj::DoProcessSdrObj( rSdrObj );
+ XclImpRectObj::DoPreProcessSdrObj( rDffConv, rSdrObj );
SfxObjectShell* pDocShell = GetDocShell();
SdrOle2Obj* pOleSdrObj = dynamic_cast< SdrOle2Obj* >( &rSdrObj );
@@ -3062,18 +3070,18 @@ void XclImpSolverContainer::UpdateConnection( sal_uInt32 nDffShapeId, SdrObject*
// ----------------------------------------------------------------------------
-XclImpSimpleDffManager::XclImpSimpleDffManager( const XclImpRoot& rRoot, SvStream& rDffStrm ) :
+XclImpSimpleDffConverter::XclImpSimpleDffConverter( const XclImpRoot& rRoot, SvStream& rDffStrm ) :
SvxMSDffManager( rDffStrm, rRoot.GetBasePath(), 0, 0, rRoot.GetDoc().GetDrawLayer(), 1440, COL_DEFAULT, 24, 0, &rRoot.GetTracer().GetBaseTracer() ),
XclImpRoot( rRoot )
{
SetSvxMSDffSettings( SVXMSDFF_SETTINGS_CROP_BITMAPS | SVXMSDFF_SETTINGS_IMPORT_EXCEL );
}
-XclImpSimpleDffManager::~XclImpSimpleDffManager()
+XclImpSimpleDffConverter::~XclImpSimpleDffConverter()
{
}
-FASTBOOL XclImpSimpleDffManager::GetColorFromPalette( USHORT nIndex, Color& rColor ) const
+FASTBOOL XclImpSimpleDffConverter::GetColorFromPalette( USHORT nIndex, Color& rColor ) const
{
ColorData nColor = GetPalette().GetColorData( static_cast< sal_uInt16 >( nIndex ) );
@@ -3086,14 +3094,23 @@ FASTBOOL XclImpSimpleDffManager::GetColorFromPalette( USHORT nIndex, Color& rCol
// ----------------------------------------------------------------------------
-XclImpDffManager::XclImpDffManager(
- const XclImpRoot& rRoot, XclImpObjectManager& rObjManager, SvStream& rDffStrm ) :
- XclImpSimpleDffManager( rRoot, rDffStrm ),
- SvxMSConvertOCXControls( rRoot.GetDocShell(), 0 ),
- mrObjManager( rObjManager ),
- mnOleImpFlags( 0 ),
+XclImpDffConverter::XclImpDffConvData::XclImpDffConvData(
+ XclImpDrawing& rDrawing, SdrModel& rSdrModel, SdrPage& rSdrPage ) :
+ mrDrawing( rDrawing ),
+ mrSdrModel( rSdrModel ),
+ mrSdrPage( rSdrPage ),
mnLastCtrlIndex( -1 ),
- mnCurrFormScTab( -1 )
+ mbHasCtrlForm( false )
+{
+}
+
+// ----------------------------------------------------------------------------
+
+XclImpDffConverter::XclImpDffConverter( const XclImpRoot& rRoot, SvStream& rDffStrm ) :
+ XclImpSimpleDffConverter( rRoot, rDffStrm ),
+ SvxMSConvertOCXControls( rRoot.GetDocShell(), 0 ),
+ maStdFormName( CREATE_OUSTRING( "Standard" ) ),
+ mnOleImpFlags( 0 )
{
if( SvtFilterOptions* pFilterOpt = SvtFilterOptions::Get() )
{
@@ -3113,81 +3130,104 @@ XclImpDffManager::XclImpDffManager(
ScaleEmu( mnDefTextMargin );
}
-XclImpDffManager::~XclImpDffManager()
+XclImpDffConverter::~XclImpDffConverter()
{
}
-void XclImpDffManager::StartProgressBar( sal_Size nProgressSize )
+void XclImpDffConverter::StartProgressBar( sal_Size nProgressSize )
{
mxProgress.reset( new ScfProgressBar( GetDocShell(), STR_PROGRESS_CALCULATING ) );
mxProgress->AddSegment( nProgressSize );
mxProgress->Activate();
}
-void XclImpDffManager::ProcessObject( SdrObjList* pObjList, const XclImpDrawObjBase& rDrawObj )
+void XclImpDffConverter::Progress( sal_Size nDelta )
{
- Rectangle aAnchorRect = rDrawObj.GetAnchorRect();
- if( rDrawObj.IsProcessSdrObj() && rDrawObj.IsValidSize( aAnchorRect ) )
- {
- // CreateSdrObject() recursively creates embedded child objects
- SdrObjectPtr xSdrObj( rDrawObj.CreateSdrObject( aAnchorRect, *mxProgress, false ) );
- if( xSdrObj.is() )
- rDrawObj.ProcessSdrObject( *xSdrObj );
- // call InsertSdrObject() also, if SdrObject is missing
- InsertSdrObject( pObjList, rDrawObj, xSdrObj.release() );
- UpdateUsedArea( rDrawObj );
- }
+ DBG_ASSERT( mxProgress.is(), "XclImpDffConverter::Progress - invalid call, no progress bar" );
+ mxProgress->Progress( nDelta );
}
-void XclImpDffManager::ProcessDrawingGroup( SvStream& rDffStrm )
+void XclImpDffConverter::InitializeDrawing( XclImpDrawing& rDrawing, SdrModel& rSdrModel, SdrPage& rSdrPage )
{
- rDffStrm.Seek( STREAM_SEEK_TO_BEGIN );
- DffRecordHeader aHeader;
- rDffStrm >> aHeader;
- if( aHeader.nRecType == DFF_msofbtDggContainer )
- ProcessDggContainer( rDffStrm, aHeader );
- else
+ XclImpDffConvDataRef xConvData( new XclImpDffConvData( rDrawing, rSdrModel, rSdrPage ) );
+ maDataStack.push_back( xConvData );
+ SetModel( &xConvData->mrSdrModel, 1440 );
+}
+
+void XclImpDffConverter::ProcessObject( SdrObjList& rObjList, const XclImpDrawObjBase& rDrawObj )
+{
+ if( rDrawObj.IsProcessSdrObj() )
{
- DBG_ERRORFILE( "XclImpDffManager::ProcessDrawingGroup - unexpected record" );
+ if( const XclObjAnchor* pAnchor = rDrawObj.GetAnchor() )
+ {
+ Rectangle aAnchorRect = GetConvData().mrDrawing.CalcAnchorRect( *pAnchor, false );
+ if( rDrawObj.IsValidSize( aAnchorRect ) )
+ {
+ // CreateSdrObject() recursively creates embedded child objects
+ SdrObjectPtr xSdrObj( rDrawObj.CreateSdrObject( *this, aAnchorRect, false ) );
+ if( xSdrObj.is() )
+ rDrawObj.PreProcessSdrObject( *this, *xSdrObj );
+ // call InsertSdrObject() also, if SdrObject is missing
+ InsertSdrObject( rObjList, rDrawObj, xSdrObj.release() );
+ }
+ }
}
}
-void XclImpDffManager::ProcessDrawing( SvStream& rDffStrm, sal_Size nStrmPos )
+void XclImpDffConverter::ProcessDrawing( const XclImpDrawObjVector& rDrawObjs )
{
- rDffStrm.Seek( nStrmPos );
- DffRecordHeader aHeader;
- rDffStrm >> aHeader;
- if( aHeader.nRecType == DFF_msofbtDgContainer )
- ProcessDgContainer( rDffStrm, aHeader );
- else
+ SdrPage& rSdrPage = GetConvData().mrSdrPage;
+ for( XclImpDrawObjVector::const_iterator aIt = rDrawObjs.begin(), aEnd = rDrawObjs.end(); aIt != aEnd; ++aIt )
+ ProcessObject( rSdrPage, **aIt );
+}
+
+void XclImpDffConverter::ProcessDrawing( SvStream& rDffStrm )
+{
+ rDffStrm.Seek( STREAM_SEEK_TO_END );
+ if( rDffStrm.Tell() > 0 )
{
- DBG_ERRORFILE( "XclImpDffManager::ProcessDrawing - unexpected record" );
+ rDffStrm.Seek( STREAM_SEEK_TO_BEGIN );
+ DffRecordHeader aHeader;
+ rDffStrm >> aHeader;
+ DBG_ASSERT( aHeader.nRecType == DFF_msofbtDgContainer, "XclImpDffConverter::ProcessDrawing - unexpected record" );
+ if( aHeader.nRecType == DFF_msofbtDgContainer )
+ ProcessDgContainer( rDffStrm, aHeader );
}
}
-SdrObject* XclImpDffManager::CreateSdrObject( const XclImpTbxObjBase& rTbxObj, const Rectangle& rAnchorRect )
+void XclImpDffConverter::FinalizeDrawing()
+{
+ DBG_ASSERT( !maDataStack.empty(), "XclImpDffConverter::FinalizeDrawing - no drawing manager on stack" );
+ maDataStack.pop_back();
+ // restore previous model at core DFF converter
+ if( !maDataStack.empty() )
+ SetModel( &maDataStack.back()->mrSdrModel, 1440 );
+}
+
+SdrObject* XclImpDffConverter::CreateSdrObject( const XclImpTbxObjBase& rTbxObj, const Rectangle& rAnchorRect )
{
SdrObjectPtr xSdrObj;
OUString aServiceName = rTbxObj.GetServiceName();
- if( aServiceName.getLength() > 0 ) try
+ if( SupportsOleObjects() && (aServiceName.getLength() > 0) ) try
{
// create the form control from scratch
Reference< XFormComponent > xFormComp( ScfApiHelper::CreateInstance( GetDocShell(), aServiceName ), UNO_QUERY_THROW );
- // set current controls form, needed in virtual function InsertControl()
- SetCurrentForm( rTbxObj.GetScTab() );
+ // set controls form, needed in virtual function InsertControl()
+ InitControlForm();
// try to insert the control into the form
::com::sun::star::awt::Size aDummySize;
Reference< XShape > xShape;
- if( mxCurrForm.is() && InsertControl( xFormComp, aDummySize, &xShape, TRUE ) )
+ XclImpDffConvData& rConvData = GetConvData();
+ if( rConvData.mxCtrlForm.is() && InsertControl( xFormComp, aDummySize, &xShape, TRUE ) )
{
xSdrObj.reset( rTbxObj.CreateSdrObjectFromShape( xShape, rAnchorRect ) );
// try to attach a macro to the control
ScriptEventDescriptor aDescriptor;
- if( (mnLastCtrlIndex >= 0) && rTbxObj.FillMacroDescriptor( aDescriptor ) )
+ if( (rConvData.mnLastCtrlIndex >= 0) && rTbxObj.FillMacroDescriptor( aDescriptor ) )
{
- Reference< XEventAttacherManager > xEventMgr( mxCurrForm, UNO_QUERY_THROW );
- xEventMgr->registerScriptEvent( mnLastCtrlIndex, aDescriptor );
+ Reference< XEventAttacherManager > xEventMgr( rConvData.mxCtrlForm, UNO_QUERY_THROW );
+ xEventMgr->registerScriptEvent( rConvData.mnLastCtrlIndex, aDescriptor );
}
}
}
@@ -3198,52 +3238,55 @@ SdrObject* XclImpDffManager::CreateSdrObject( const XclImpTbxObjBase& rTbxObj, c
return xSdrObj.release();
}
-SdrObject* XclImpDffManager::CreateSdrObject( const XclImpPictureObj& rPicObj, const Rectangle& rAnchorRect )
+SdrObject* XclImpDffConverter::CreateSdrObject( const XclImpPictureObj& rPicObj, const Rectangle& rAnchorRect )
{
SdrObjectPtr xSdrObj;
- if( rPicObj.IsOcxControl() )
- {
- if( mxCtlsStrm.Is() ) try
- {
- /* set current controls form, needed in virtual function InsertControl()
- called from ReadOCXExcelKludgeStream() */
- SetCurrentForm( rPicObj.GetScTab() );
- // seek to stream position of the extra data for this control
- mxCtlsStrm->Seek( rPicObj.GetCtlsStreamPos() );
- // read from mxCtlsStrm into xShape, insert the control model into the form
- Reference< XShape > xShape;
- if( mxCurrForm.is() && ReadOCXExcelKludgeStream( mxCtlsStrm, &xShape, TRUE ) )
- xSdrObj.reset( rPicObj.CreateSdrObjectFromShape( xShape, rAnchorRect ) );
- }
- catch( Exception& )
- {
- }
- }
- else
+ if( SupportsOleObjects() )
{
- SfxObjectShell* pDocShell = GetDocShell();
- SotStorageRef xSrcStrg = GetRootStorage();
- String aStrgName = rPicObj.GetOleStorageName();
- if( pDocShell && xSrcStrg.Is() && (aStrgName.Len() > 0) )
+ if( rPicObj.IsOcxControl() )
{
- // first try to resolve graphic from DFF storage
- Graphic aGraphic;
- Rectangle aVisArea;
- if( !GetBLIP( GetPropertyValue( DFF_Prop_pib ), aGraphic, &aVisArea ) )
+ if( mxCtlsStrm.Is() ) try
{
- // if not found, use graphic from object (imported from IMGDATA record)
- aGraphic = rPicObj.GetGraphic();
- aVisArea = rPicObj.GetVisArea();
+ /* set controls form, needed in virtual function InsertControl()
+ called from ReadOCXExcelKludgeStream() */
+ InitControlForm();
+ // seek to stream position of the extra data for this control
+ mxCtlsStrm->Seek( rPicObj.GetCtlsStreamPos() );
+ // read from mxCtlsStrm into xShape, insert the control model into the form
+ Reference< XShape > xShape;
+ if( GetConvData().mxCtrlForm.is() && ReadOCXExcelKludgeStream( mxCtlsStrm, &xShape, TRUE ) )
+ xSdrObj.reset( rPicObj.CreateSdrObjectFromShape( xShape, rAnchorRect ) );
}
- if( aGraphic.GetType() != GRAPHIC_NONE )
+ catch( Exception& )
{
- ErrCode nError = ERRCODE_NONE;
- namespace cssea = ::com::sun::star::embed::Aspects;
- sal_Int64 nAspects = rPicObj.IsSymbol() ? cssea::MSOLE_ICON : cssea::MSOLE_CONTENT;
- xSdrObj.reset( CreateSdrOLEFromStorage(
- aStrgName, xSrcStrg, pDocShell->GetStorage(), aGraphic,
- rAnchorRect, aVisArea, 0, nError, mnOleImpFlags, nAspects ) );
+ }
+ }
+ else
+ {
+ SfxObjectShell* pDocShell = GetDocShell();
+ SotStorageRef xSrcStrg = GetRootStorage();
+ String aStrgName = rPicObj.GetOleStorageName();
+ if( pDocShell && xSrcStrg.Is() && (aStrgName.Len() > 0) )
+ {
+ // first try to resolve graphic from DFF storage
+ Graphic aGraphic;
+ Rectangle aVisArea;
+ if( !GetBLIP( GetPropertyValue( DFF_Prop_pib ), aGraphic, &aVisArea ) )
+ {
+ // if not found, use graphic from object (imported from IMGDATA record)
+ aGraphic = rPicObj.GetGraphic();
+ aVisArea = rPicObj.GetVisArea();
+ }
+ if( aGraphic.GetType() != GRAPHIC_NONE )
+ {
+ ErrCode nError = ERRCODE_NONE;
+ namespace cssea = ::com::sun::star::embed::Aspects;
+ sal_Int64 nAspects = rPicObj.IsSymbol() ? cssea::MSOLE_ICON : cssea::MSOLE_CONTENT;
+ xSdrObj.reset( CreateSdrOLEFromStorage(
+ aStrgName, xSrcStrg, pDocShell->GetStorage(), aGraphic,
+ rAnchorRect, aVisArea, 0, nError, mnOleImpFlags, nAspects ) );
+ }
}
}
}
@@ -3251,44 +3294,43 @@ SdrObject* XclImpDffManager::CreateSdrObject( const XclImpPictureObj& rPicObj, c
return xSdrObj.release();
}
-ScRange XclImpDffManager::GetUsedArea( SCTAB nScTab ) const
+bool XclImpDffConverter::SupportsOleObjects() const
{
- ScRange aScUsedArea( ScAddress::INITIALIZE_INVALID );
- ScRangeMap::const_iterator aIt = maUsedAreaMap.find( nScTab );
- if( aIt != maUsedAreaMap.end() )
- aScUsedArea = aIt->second;
- return aScUsedArea;
+ return GetConvData().mrDrawing.SupportsOleObjects();
}
// virtual functions ----------------------------------------------------------
-void XclImpDffManager::ProcessClientAnchor2( SvStream& rDffStrm,
+void XclImpDffConverter::ProcessClientAnchor2( SvStream& rDffStrm,
DffRecordHeader& rHeader, void* /*pClientData*/, DffObjData& rObjData )
{
// find the OBJ record data related to the processed shape
- if( XclImpDrawObjBase* pDrawObj = mrObjManager.FindDrawObj( rObjData.rSpHd ).get() )
+ XclImpDffConvData& rConvData = GetConvData();
+ if( XclImpDrawObjBase* pDrawObj = rConvData.mrDrawing.FindDrawObj( rObjData.rSpHd ).get() )
{
- DBG_ASSERT( rHeader.nRecType == DFF_msofbtClientAnchor, "XclImpDffManager::ProcessClientAnchor2 - no client anchor record" );
- XclObjAnchor aAnchor( pDrawObj->GetScTab() );
+ DBG_ASSERT( rHeader.nRecType == DFF_msofbtClientAnchor, "XclImpDffConverter::ProcessClientAnchor2 - no client anchor record" );
+ XclObjAnchor aAnchor;
rHeader.SeekToContent( rDffStrm );
rDffStrm.SeekRel( 2 ); // flags
rDffStrm >> aAnchor; // anchor format equal to BIFF5 OBJ records
pDrawObj->SetAnchor( aAnchor );
- rObjData.aChildAnchor = pDrawObj->GetAnchorRect();
+ rObjData.aChildAnchor = rConvData.mrDrawing.CalcAnchorRect( aAnchor, true );
rObjData.bChildAnchor = sal_True;
}
}
-SdrObject* XclImpDffManager::ProcessObj( SvStream& rDffStrm,
- DffObjData& rDffObjData, void* pClientData, Rectangle& /*rTextRect*/, SdrObject* pOldSdrObj )
+SdrObject* XclImpDffConverter::ProcessObj( SvStream& rDffStrm, DffObjData& rDffObjData,
+ void* pClientData, Rectangle& /*rTextRect*/, SdrObject* pOldSdrObj )
{
+ XclImpDffConvData& rConvData = GetConvData();
+
/* pOldSdrObj passes a generated SdrObject. This function owns this object
and can modify it. The function has either to return it back to caller
or to delete it by itself. */
SdrObjectPtr xSdrObj( pOldSdrObj );
// find the OBJ record data related to the processed shape
- XclImpDrawObjRef xDrawObj = mrObjManager.FindDrawObj( rDffObjData.rSpHd );
+ XclImpDrawObjRef xDrawObj = rConvData.mrDrawing.FindDrawObj( rDffObjData.rSpHd );
const Rectangle& rAnchorRect = rDffObjData.aChildAnchor;
// #102378# Do not process the global page group shape (flag SP_FPATRIARCH)
@@ -3326,7 +3368,7 @@ SdrObject* XclImpDffManager::ProcessObj( SvStream& rDffStrm,
/* Connect textbox data (string, alignment, text orientation) to object.
#98132# don't ask for a text-ID, DFF export doesn't set one. */
if( XclImpTextObj* pTextObj = dynamic_cast< XclImpTextObj* >( xDrawObj.get() ) )
- if( const XclImpObjTextData* pTextData = mrObjManager.FindTextData( rDffObjData.rSpHd ) )
+ if( const XclImpObjTextData* pTextData = rConvData.mrDrawing.FindTextData( rDffObjData.rSpHd ) )
pTextObj->SetTextData( *pTextData );
// copy line and fill formatting of TBX form controls from DFF properties
@@ -3334,7 +3376,7 @@ SdrObject* XclImpDffManager::ProcessObj( SvStream& rDffStrm,
pTbxObj->SetDffProperties( *this );
// try to create a custom SdrObject that overwrites the passed object
- SdrObjectPtr xNewSdrObj( xDrawObj->CreateSdrObject( rAnchorRect, *mxProgress, true ) );
+ SdrObjectPtr xNewSdrObj( xDrawObj->CreateSdrObject( *this, rAnchorRect, true ) );
if( xNewSdrObj.is() )
xSdrObj.reset( xNewSdrObj.release() );
@@ -3346,40 +3388,50 @@ SdrObject* XclImpDffManager::ProcessObj( SvStream& rDffStrm,
xSdrObj->SetMergedItem( XFillColorItem( EMPTY_STRING, GetPalette().GetColor( EXC_COLOR_WINDOWBACK ) ) );
// additional processing on the SdrObject
- xDrawObj->ProcessSdrObject( *xSdrObj );
-
- // add the area used by this object to the internal map of used areas
- UpdateUsedArea( *xDrawObj );
+ xDrawObj->PreProcessSdrObject( *this, *xSdrObj );
/* If the SdrObject will not be inserted into the draw page, delete it
- here. Happens e.g. for notes: The ProcessSdrObject() call above has
- inserted the note into the document, and the SdrObject is not
+ here. Happens e.g. for notes: The PreProcessSdrObject() call above
+ has inserted the note into the document, and the SdrObject is not
needed anymore. */
if( !xDrawObj->IsInsertSdrObj() )
xSdrObj.reset();
}
- /* Store the relation between shape ID and SdrObject for connectors. Must
- be done here (and not in InsertSdrObject() function), otherwise all
- SdrObjects embedded in groups would be lost. */
if( xSdrObj.is() )
- maSolverCont.InsertSdrObjectInfo( *xSdrObj, xDrawObj->GetDffShapeId(), xDrawObj->GetDffFlags() );
+ {
+ /* Store the relation between shape ID and SdrObject for connectors.
+ Must be done here (and not in InsertSdrObject() function),
+ otherwise all SdrObjects embedded in groups would be lost. */
+ rConvData.maSolverCont.InsertSdrObjectInfo( *xSdrObj, xDrawObj->GetDffShapeId(), xDrawObj->GetDffFlags() );
+
+ /* If the drawing object is embedded in a group object, call
+ PostProcessSdrObject() here. For top-level objects this will be
+ done automatically in InsertSdrObject() but grouped shapes are
+ inserted into their groups somewhere in the SvxMSDffManager base
+ class without chance of notification. Unfortunately, now this is
+ called before the object is really inserted into its group object,
+ but that should not have any effect for grouped objects. */
+ if( !bIsTopLevel )
+ xDrawObj->PostProcessSdrObject( *this, *xSdrObj );
+ }
return xSdrObj.release();
}
-ULONG XclImpDffManager::Calc_nBLIPPos( ULONG /*nOrgVal*/, ULONG nStreamPos ) const
+ULONG XclImpDffConverter::Calc_nBLIPPos( ULONG /*nOrgVal*/, ULONG nStreamPos ) const
{
return nStreamPos + 4;
}
-sal_Bool XclImpDffManager::InsertControl( const Reference< XFormComponent >& rxFormComp,
+sal_Bool XclImpDffConverter::InsertControl( const Reference< XFormComponent >& rxFormComp,
const ::com::sun::star::awt::Size& /*rSize*/, Reference< XShape >* pxShape,
BOOL /*bFloatingCtrl*/ )
{
if( GetDocShell() ) try
{
- Reference< XIndexContainer > xFormIC( mxCurrForm, UNO_QUERY_THROW );
+ XclImpDffConvData& rConvData = GetConvData();
+ Reference< XIndexContainer > xFormIC( rConvData.mxCtrlForm, UNO_QUERY_THROW );
Reference< XControlModel > xCtrlModel( rxFormComp, UNO_QUERY_THROW );
// create the control shape
@@ -3390,7 +3442,7 @@ sal_Bool XclImpDffManager::InsertControl( const Reference< XFormComponent >& rxF
sal_Int32 nNewIndex = xFormIC->getCount();
xFormIC->insertByIndex( nNewIndex, Any( rxFormComp ) );
// on success: store new index of the control for later use (macro events)
- mnLastCtrlIndex = nNewIndex;
+ rConvData.mnLastCtrlIndex = nNewIndex;
// set control model at control shape and pass back shape to caller
xCtrlShape->setControl( xCtrlModel );
@@ -3399,7 +3451,7 @@ sal_Bool XclImpDffManager::InsertControl( const Reference< XFormComponent >& rxF
}
catch( Exception& )
{
- DBG_ERRORFILE( "XclImpDffManager::InsertControl - cannot create form control" );
+ DBG_ERRORFILE( "XclImpDffConverter::InsertControl - cannot create form control" );
}
return sal_False;
@@ -3407,7 +3459,19 @@ sal_Bool XclImpDffManager::InsertControl( const Reference< XFormComponent >& rxF
// private --------------------------------------------------------------------
-String XclImpDffManager::ReadHlinkProperty( SvStream& rDffStrm ) const
+XclImpDffConverter::XclImpDffConvData& XclImpDffConverter::GetConvData()
+{
+ DBG_ASSERT( !maDataStack.empty(), "XclImpDffConverter::GetConvData - no drawing manager on stack" );
+ return *maDataStack.back();
+}
+
+const XclImpDffConverter::XclImpDffConvData& XclImpDffConverter::GetConvData() const
+{
+ DBG_ASSERT( !maDataStack.empty(), "XclImpDffConverter::GetConvData - no drawing manager on stack" );
+ return *maDataStack.back();
+}
+
+String XclImpDffConverter::ReadHlinkProperty( SvStream& rDffStrm ) const
{
/* Reads hyperlink data from a complex DFF property. Contents of this
property are equal to the HLINK record, import of this record is
@@ -3438,13 +3502,7 @@ String XclImpDffManager::ReadHlinkProperty( SvStream& rDffStrm ) const
return aString;
}
-void XclImpDffManager::ProcessDggContainer( SvStream& rDffStrm, const DffRecordHeader& rDggHeader )
-{
- // seek to end of drawing group container
- rDggHeader.SeekToEndOfRecord( rDffStrm );
-}
-
-void XclImpDffManager::ProcessDgContainer( SvStream& rDffStrm, const DffRecordHeader& rDgHeader )
+void XclImpDffConverter::ProcessDgContainer( SvStream& rDffStrm, const DffRecordHeader& rDgHeader )
{
sal_Size nEndPos = rDgHeader.GetRecEndFilePos();
while( rDffStrm.Tell() < nEndPos )
@@ -3467,12 +3525,13 @@ void XclImpDffManager::ProcessDgContainer( SvStream& rDffStrm, const DffRecordHe
rDgHeader.SeekToEndOfRecord( rDffStrm );
// #i12638# #i37900# connector rules
- maSolverCont.UpdateConnectorRules();
- SolveSolver( maSolverCont );
- maSolverCont.RemoveConnectorRules();
+ XclImpSolverContainer& rSolverCont = GetConvData().maSolverCont;
+ rSolverCont.UpdateConnectorRules();
+ SolveSolver( rSolverCont );
+ rSolverCont.RemoveConnectorRules();
}
-void XclImpDffManager::ProcessShGrContainer( SvStream& rDffStrm, const DffRecordHeader& rShGrHeader )
+void XclImpDffConverter::ProcessShGrContainer( SvStream& rDffStrm, const DffRecordHeader& rShGrHeader )
{
sal_Size nEndPos = rShGrHeader.GetRecEndFilePos();
while( rDffStrm.Tell() < nEndPos )
@@ -3493,17 +3552,17 @@ void XclImpDffManager::ProcessShGrContainer( SvStream& rDffStrm, const DffRecord
rShGrHeader.SeekToEndOfRecord( rDffStrm );
}
-void XclImpDffManager::ProcessSolverContainer( SvStream& rDffStrm, const DffRecordHeader& rSolverHeader )
+void XclImpDffConverter::ProcessSolverContainer( SvStream& rDffStrm, const DffRecordHeader& rSolverHeader )
{
// solver container wants to read the solver container header again
rSolverHeader.SeekToBegOfRecord( rDffStrm );
// read the entire solver container
- rDffStrm >> maSolverCont;
+ rDffStrm >> GetConvData().maSolverCont;
// seek to end of solver container
rSolverHeader.SeekToEndOfRecord( rDffStrm );
}
-void XclImpDffManager::ProcessShContainer( SvStream& rDffStrm, const DffRecordHeader& rShHeader )
+void XclImpDffConverter::ProcessShContainer( SvStream& rDffStrm, const DffRecordHeader& rShHeader )
{
rShHeader.SeekToBegOfRecord( rDffStrm );
Rectangle aDummy;
@@ -3516,112 +3575,70 @@ void XclImpDffManager::ProcessShContainer( SvStream& rDffStrm, const DffRecordHe
the pointer to the related draw object data (OBJ record) into pDrawObj. */
SdrObjectPtr xSdrObj( ImportObj( rDffStrm, &pDrawObj, aDummy, aDummy, 0, 0 ) );
if( pDrawObj && xSdrObj.is() )
- InsertSdrObject( GetSdrPage( pDrawObj->GetScTab() ), *pDrawObj, xSdrObj.release() );
+ InsertSdrObject( GetConvData().mrSdrPage, *pDrawObj, xSdrObj.release() );
rShHeader.SeekToEndOfRecord( rDffStrm );
}
-void XclImpDffManager::InsertSdrObject( SdrObjList* pObjList, const XclImpDrawObjBase& rDrawObj, SdrObject* pSdrObj )
+void XclImpDffConverter::InsertSdrObject( SdrObjList& rObjList, const XclImpDrawObjBase& rDrawObj, SdrObject* pSdrObj )
{
+ XclImpDffConvData& rConvData = GetConvData();
/* Take ownership of the passed object. If insertion fails (e.g. rDrawObj
- states to skip insertion, or missing draw page), the object is
- automatically deleted. */
+ states to skip insertion), the object is automatically deleted. */
SdrObjectPtr xSdrObj( pSdrObj );
- if( pObjList && xSdrObj.is() && rDrawObj.IsInsertSdrObj() )
- pObjList->NbcInsertObject( xSdrObj.release() );
- // SdrObject still here? Insertion failed, remove data from shape ID map.
+ if( xSdrObj.is() && rDrawObj.IsInsertSdrObj() )
+ {
+ rObjList.NbcInsertObject( xSdrObj.release() );
+ // callback to drawing manager for e.g. tracking of used sheet area
+ rConvData.mrDrawing.OnObjectInserted( rDrawObj );
+ // callback to drawing object for post processing (use pSdrObj, xSdrObj already released)
+ rDrawObj.PostProcessSdrObject( *this, *pSdrObj );
+ }
+ /* SdrObject still here? Insertion failed, remove data from shape ID map.
+ The SdrObject will be destructed then. */
if( xSdrObj.is() )
- maSolverCont.RemoveSdrObjectInfo( *xSdrObj );
+ rConvData.maSolverCont.RemoveSdrObjectInfo( *xSdrObj );
}
-void XclImpDffManager::SetCurrentForm( SCTAB nScTab )
+void XclImpDffConverter::InitControlForm()
{
- if( nScTab != mnCurrFormScTab )
- {
- mxCurrForm.clear();
- mnCurrFormScTab = nScTab;
+ XclImpDffConvData& rConvData = GetConvData();
+ if( rConvData.mbHasCtrlForm )
+ return;
- SdrPage* pSdrPage = GetSdrPage( nScTab );
- if( GetDocShell() && pSdrPage ) try
+ rConvData.mbHasCtrlForm = true;
+ if( SupportsOleObjects() ) try
+ {
+ Reference< XFormsSupplier > xFormsSupplier( rConvData.mrSdrPage.getUnoPage(), UNO_QUERY_THROW );
+ Reference< XNameContainer > xFormsNC( xFormsSupplier->getForms(), UNO_SET_THROW );
+ // find or create the Standard form used to insert the imported controls
+ if( xFormsNC->hasByName( maStdFormName ) )
{
- Reference< XFormsSupplier > xFormsSupplier( pSdrPage->getUnoPage(), UNO_QUERY_THROW );
- Reference< XNameContainer > xFormsNC = xFormsSupplier->getForms();
- if( xFormsNC.is() )
- {
- // find or create the Standard form used to insert the imported controls
- OUString aFormName = CREATE_OUSTRING( "Standard" );
- if( xFormsNC->hasByName( aFormName ) )
- {
- xFormsNC->getByName( aFormName ) >>= mxCurrForm;
- }
- else
- {
- mxCurrForm.set( ScfApiHelper::CreateInstance( GetDocShell(), CREATE_OUSTRING( "com.sun.star.form.component.Form" ) ), UNO_QUERY_THROW );
- xFormsNC->insertByName( aFormName, Any( mxCurrForm ) );
- }
- }
+ xFormsNC->getByName( maStdFormName ) >>= rConvData.mxCtrlForm;
}
- catch( Exception& )
+ else if( SfxObjectShell* pDocShell = GetDocShell() )
{
+ rConvData.mxCtrlForm.set( ScfApiHelper::CreateInstance( pDocShell, CREATE_OUSTRING( "com.sun.star.form.component.Form" ) ), UNO_QUERY_THROW );
+ xFormsNC->insertByName( maStdFormName, Any( rConvData.mxCtrlForm ) );
}
}
-}
-
-void XclImpDffManager::UpdateUsedArea( const XclImpDrawObjBase& rDrawObj )
-{
- ScRange aScObjArea = rDrawObj.GetUsedArea();
- if( aScObjArea.IsValid() )
+ catch( Exception& )
{
- ScRange* pScTabArea = 0;
- ScRangeMap::iterator aIt = maUsedAreaMap.find( rDrawObj.GetScTab() );
- if( aIt == maUsedAreaMap.end() )
- {
- pScTabArea = &maUsedAreaMap[ rDrawObj.GetScTab() ];
- pScTabArea->SetInvalid();
- }
- else
- pScTabArea = &aIt->second;
-
- if( pScTabArea )
- pScTabArea->ExtendTo( aScObjArea );
}
}
-// The object manager =========================================================
+// Drawing manager ============================================================
-XclImpObjectManager::XclImpObjectManager( const XclImpRoot& rRoot ) :
- XclImpRoot( rRoot )
+XclImpDrawing::XclImpDrawing( const XclImpRoot& rRoot, bool bOleObjects ) :
+ XclImpRoot( rRoot ),
+ mbOleObjs( bOleObjects )
{
- maDefObjNames[ EXC_OBJTYPE_GROUP ] = CREATE_STRING( "Group" );
- maDefObjNames[ EXC_OBJTYPE_LINE ] = CREATE_STRING( "Line" );
- maDefObjNames[ EXC_OBJTYPE_RECTANGLE ] = CREATE_STRING( "Rectangle" );
- maDefObjNames[ EXC_OBJTYPE_OVAL ] = CREATE_STRING( "Oval" );
- maDefObjNames[ EXC_OBJTYPE_ARC ] = CREATE_STRING( "Arc" );
- maDefObjNames[ EXC_OBJTYPE_CHART ] = CREATE_STRING( "Chart" );
- maDefObjNames[ EXC_OBJTYPE_TEXT ] = CREATE_STRING( "Text" );
- maDefObjNames[ EXC_OBJTYPE_BUTTON ] = CREATE_STRING( "Button" );
- maDefObjNames[ EXC_OBJTYPE_PICTURE ] = CREATE_STRING( "Picture" );
- maDefObjNames[ EXC_OBJTYPE_POLYGON ] = CREATE_STRING( "Freeform" );
- maDefObjNames[ EXC_OBJTYPE_CHECKBOX ] = CREATE_STRING( "Check Box" );
- maDefObjNames[ EXC_OBJTYPE_OPTIONBUTTON ] = CREATE_STRING( "Option Button" );
- maDefObjNames[ EXC_OBJTYPE_EDIT ] = CREATE_STRING( "Edit Box" );
- maDefObjNames[ EXC_OBJTYPE_LABEL ] = CREATE_STRING( "Label" );
- maDefObjNames[ EXC_OBJTYPE_DIALOG ] = CREATE_STRING( "Dialog Frame" );
- maDefObjNames[ EXC_OBJTYPE_SPIN ] = CREATE_STRING( "Spinner" );
- maDefObjNames[ EXC_OBJTYPE_SCROLLBAR ] = CREATE_STRING( "Scroll Bar" );
- maDefObjNames[ EXC_OBJTYPE_LISTBOX ] = CREATE_STRING( "List Box" );
- maDefObjNames[ EXC_OBJTYPE_GROUPBOX ] = CREATE_STRING( "Group Box" );
- maDefObjNames[ EXC_OBJTYPE_DROPDOWN ] = CREATE_STRING( "Drop Down" );
- maDefObjNames[ EXC_OBJTYPE_NOTE ] = CREATE_STRING( "Comment" );
- maDefObjNames[ EXC_OBJTYPE_DRAWING ] = CREATE_STRING( "AutoShape" );
}
-XclImpObjectManager::~XclImpObjectManager()
+XclImpDrawing::~XclImpDrawing()
{
}
-// *** Read Excel records *** -------------------------------------------------
-
-Graphic XclImpObjectManager::ReadImgData( XclImpStream& rStrm ) // static helper
+/*static*/ Graphic XclImpDrawing::ReadImgData( const XclImpRoot& rRoot, XclImpStream& rStrm )
{
Graphic aGraphic;
sal_uInt16 nFormat, nEnv;
@@ -3631,33 +3648,33 @@ Graphic XclImpObjectManager::ReadImgData( XclImpStream& rStrm ) // static helper
{
switch( nFormat )
{
- case EXC_IMGDATA_WMF: ReadWmf( aGraphic, rStrm ); break;
- case EXC_IMGDATA_BMP: ReadBmp( aGraphic, rStrm ); break;
- default: DBG_ERRORFILE( "XclImpObjectManager::ReadImgData - unknown image format" );
+ case EXC_IMGDATA_WMF: ReadWmf( aGraphic, rRoot, rStrm ); break;
+ case EXC_IMGDATA_BMP: ReadBmp( aGraphic, rRoot, rStrm ); break;
+ default: DBG_ERRORFILE( "XclImpDrawing::ReadImgData - unknown image format" );
}
}
return aGraphic;
}
-void XclImpObjectManager::ReadObj( XclImpStream& rStrm )
+void XclImpDrawing::ReadObj( XclImpStream& rStrm )
{
XclImpDrawObjRef xDrawObj;
/* #i61786# In BIFF8 streams, OBJ records may occur without MSODRAWING
records. In this case, the OBJ records are in BIFF5 format. Do a sanity
check here that there is no DFF data loaded before. */
- DBG_ASSERT( maDffStrm.Tell() == 0, "XclImpObjectManager::ReadObj - unexpected DFF stream data, OBJ will be ignored" );
+ DBG_ASSERT( maDffStrm.Tell() == 0, "XclImpDrawing::ReadObj - unexpected DFF stream data, OBJ will be ignored" );
if( maDffStrm.Tell() == 0 ) switch( GetBiff() )
{
case EXC_BIFF3:
- xDrawObj = XclImpDrawObjBase::ReadObj3( rStrm );
+ xDrawObj = XclImpDrawObjBase::ReadObj3( GetRoot(), rStrm );
break;
case EXC_BIFF4:
- xDrawObj = XclImpDrawObjBase::ReadObj4( rStrm );
+ xDrawObj = XclImpDrawObjBase::ReadObj4( GetRoot(), rStrm );
break;
case EXC_BIFF5:
case EXC_BIFF8:
- xDrawObj = XclImpDrawObjBase::ReadObj5( rStrm );
+ xDrawObj = XclImpDrawObjBase::ReadObj5( GetRoot(), rStrm );
break;
default:
DBG_ERROR_BIFF();
@@ -3672,30 +3689,11 @@ void XclImpObjectManager::ReadObj( XclImpStream& rStrm )
}
}
-void XclImpObjectManager::ReadMsoDrawingGroup( XclImpStream& rStrm )
-{
- DBG_ASSERT_BIFF( GetBiff() == EXC_BIFF8 );
- // Excel continues this record with MSODRAWINGGROUP and CONTINUE records, hmm.
- rStrm.ResetRecord( true, EXC_ID_MSODRAWINGGROUP );
- ReadDffRecord( rStrm );
-}
-
-void XclImpObjectManager::ReadMsoDrawing( XclImpStream& rStrm )
+void XclImpDrawing::ReadMsoDrawing( XclImpStream& rStrm )
{
DBG_ASSERT_BIFF( GetBiff() == EXC_BIFF8 );
// disable internal CONTINUE handling
rStrm.ResetRecord( false );
- /* #i60510# real life: MSODRAWINGSELECTION record may contain garbage -
- this makes it impossible to process the DFF stream in one run.
- Store stream start position for every sheet separately, will be used
- to seek the stream to these positions later, when processing the next
- sheet. */
- size_t nTabIdx = static_cast< size_t >( GetCurrScTab() );
- if( nTabIdx >= maTabStrmPos.size() )
- {
- maTabStrmPos.resize( nTabIdx, STREAM_SEEK_TO_END );
- maTabStrmPos.push_back( maDffStrm.Tell() );
- }
// read leading MSODRAWING record
ReadDffRecord( rStrm );
@@ -3725,36 +3723,7 @@ void XclImpObjectManager::ReadMsoDrawing( XclImpStream& rStrm )
rStrm.ResetRecord( true );
}
-void XclImpObjectManager::ReadNote( XclImpStream& rStrm )
-{
- switch( GetBiff() )
- {
- case EXC_BIFF2:
- case EXC_BIFF3:
- case EXC_BIFF4:
- case EXC_BIFF5:
- ReadNote3( rStrm );
- break;
- case EXC_BIFF8:
- ReadNote8( rStrm );
- break;
- default:
- DBG_ERROR_BIFF();
- }
-}
-
-void XclImpObjectManager::ReadTabChart( XclImpStream& rStrm )
-{
- DBG_ASSERT_BIFF( GetBiff() >= EXC_BIFF5 );
- ScfRef< XclImpChartObj > xChartObj( new XclImpChartObj( GetRoot(), true ) );
- xChartObj->ReadChartSubStream( rStrm );
- // insert the chart as raw object without connected DFF data
- maRawObjs.push_back( xChartObj );
-}
-
-// *** Drawing objects *** ----------------------------------------------------
-
-XclImpDrawObjRef XclImpObjectManager::FindDrawObj( const DffRecordHeader& rHeader ) const
+XclImpDrawObjRef XclImpDrawing::FindDrawObj( const DffRecordHeader& rHeader ) const
{
/* maObjMap stores objects by position of the client data (OBJ record) in
the DFF stream, which is always behind shape start position of the
@@ -3769,16 +3738,16 @@ XclImpDrawObjRef XclImpObjectManager::FindDrawObj( const DffRecordHeader& rHeade
return xDrawObj;
}
-XclImpDrawObjRef XclImpObjectManager::FindDrawObj( const XclObjId& rObjId ) const
+XclImpDrawObjRef XclImpDrawing::FindDrawObj( sal_uInt16 nObjId ) const
{
XclImpDrawObjRef xDrawObj;
- XclImpObjMapById::const_iterator aIt = maObjMapId.find( rObjId );
+ XclImpObjMapById::const_iterator aIt = maObjMapId.find( nObjId );
if( aIt != maObjMapId.end() )
xDrawObj = aIt->second;
return xDrawObj;
}
-const XclImpObjTextData* XclImpObjectManager::FindTextData( const DffRecordHeader& rHeader ) const
+const XclImpObjTextData* XclImpDrawing::FindTextData( const DffRecordHeader& rHeader ) const
{
/* maTextMap stores textbox data by position of the client data (TXO
record) in the DFF stream, which is always behind shape start position
@@ -3792,75 +3761,46 @@ const XclImpObjTextData* XclImpObjectManager::FindTextData( const DffRecordHeade
return 0;
}
-void XclImpObjectManager::SetSkipObj( SCTAB nScTab, sal_uInt16 nObjId )
+void XclImpDrawing::SetSkipObj( sal_uInt16 nObjId )
{
- maSkipObjs.push_back( XclObjId( nScTab, nObjId ) );
+ maSkipObjs.push_back( nObjId );
}
-// *** Drawing object conversion *** ------------------------------------------
-
-XclImpDffManager& XclImpObjectManager::GetDffManager()
+sal_Size XclImpDrawing::GetProgressSize() const
{
- if( !mxDffManager )
- mxDffManager.reset( new XclImpDffManager( GetRoot(), *this, maDffStrm ) );
- return *mxDffManager;
+ sal_Size nProgressSize = maRawObjs.GetProgressSize();
+ for( XclImpObjMap::const_iterator aIt = maObjMap.begin(), aEnd = maObjMap.end(); aIt != aEnd; ++aIt )
+ nProgressSize += aIt->second->GetProgressSize();
+ return nProgressSize;
}
-void XclImpObjectManager::ConvertObjects()
+void XclImpDrawing::ImplConvertObjects( XclImpDffConverter& rDffConv, SdrModel& rSdrModel, SdrPage& rSdrPage )
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "sc", "dr104026", "XclImpObjectManager::ConvertObjects" );
-
- // do nothing if the document does not contain a drawing layer
- if( GetDoc().GetDrawLayer() )
- {
- // process list of identifiers of objects to be skipped
- for( XclObjIdVec::const_iterator aVIt = maSkipObjs.begin(), aVEnd = maSkipObjs.end(); aVIt != aVEnd; ++aVIt )
- if( XclImpDrawObjBase* pDrawObj = FindDrawObj( *aVIt ).get() )
- pDrawObj->SetProcessSdrObj( false );
-
- // get progress bar size for all valid objects
- sal_Size nProgressSize = GetProgressSize();
- if( nProgressSize > 0 )
- {
- XclImpDffManager& rDffManager = GetDffManager();
- rDffManager.StartProgressBar( nProgressSize );
- // process drawing objects without DFF data
- for( XclImpDrawObjVector::const_iterator aVIt = maRawObjs.begin(), aVEnd = maRawObjs.end(); aVIt != aVEnd; ++aVIt )
- rDffManager.ProcessObject( GetSdrPage( (*aVIt)->GetScTab() ), **aVIt );
- // process the global DFF container, contains pictures
- if( !maTabStrmPos.empty() && (maTabStrmPos.front() > 0) )
- rDffManager.ProcessDrawingGroup( maDffStrm );
- // process the sheet records, this inserts the objects into the drawing layer
- for( StreamPosVec::const_iterator aPIt = maTabStrmPos.begin(), aPEnd = maTabStrmPos.end(); aPIt != aPEnd; ++aPIt )
- if( *aPIt != STREAM_SEEK_TO_END )
- rDffManager.ProcessDrawing( maDffStrm, *aPIt );
- }
- }
- ScChartListenerCollection* pChartListeners = GetDoc().GetChartListenerCollection();
- if (pChartListeners && pChartListeners->GetCount())
- pChartListeners->SetDirty();
+ // register this drawing manager at the passed (global) DFF manager
+ rDffConv.InitializeDrawing( *this, rSdrModel, rSdrPage );
+ // process list of objects to be skipped
+ for( ScfUInt16Vec::const_iterator aIt = maSkipObjs.begin(), aEnd = maSkipObjs.end(); aIt != aEnd; ++aIt )
+ if( XclImpDrawObjBase* pDrawObj = FindDrawObj( *aIt ).get() )
+ pDrawObj->SetProcessSdrObj( false );
+ // process drawing objects without DFF data
+ rDffConv.ProcessDrawing( maRawObjs );
+ // process all objects in the DFF stream
+ rDffConv.ProcessDrawing( maDffStrm );
+ // unregister this drawing manager at the passed (global) DFF manager
+ rDffConv.FinalizeDrawing();
}
-String XclImpObjectManager::GetDefaultObjName( const XclImpDrawObjBase& rDrawObj ) const
-{
- String aDefName;
- DefObjNameMap::const_iterator aIt = maDefObjNames.find( rDrawObj.GetObjType() );
- if( aIt != maDefObjNames.end() )
- aDefName.Append( aIt->second );
- return aDefName.Append( sal_Unicode( ' ' ) ).Append( String::CreateFromInt32( rDrawObj.GetObjId().mnObjId ) );
-}
+// protected ------------------------------------------------------------------
-ScRange XclImpObjectManager::GetUsedArea( SCTAB nScTab ) const
+void XclImpDrawing::AppendRawObject( const XclImpDrawObjRef& rxDrawObj )
{
- ScRange aScUsedArea( ScAddress::INITIALIZE_INVALID );
- if( mxDffManager.is() )
- aScUsedArea = mxDffManager->GetUsedArea( nScTab );
- return aScUsedArea;
+ DBG_ASSERT( rxDrawObj.is(), "XclImpDrawing::AppendRawObject - unexpected empty reference" );
+ maRawObjs.push_back( rxDrawObj );
}
// private --------------------------------------------------------------------
-void XclImpObjectManager::ReadWmf( Graphic& rGraphic, XclImpStream& rStrm ) // static helper
+void XclImpDrawing::ReadWmf( Graphic& rGraphic, const XclImpRoot&, XclImpStream& rStrm ) // static helper
{
// extract graphic data from IMGDATA and following CONTINUE records
rStrm.Ignore( 8 );
@@ -3873,7 +3813,7 @@ void XclImpObjectManager::ReadWmf( Graphic& rGraphic, XclImpStream& rStrm ) // s
rGraphic = aGDIMetaFile;
}
-void XclImpObjectManager::ReadBmp( Graphic& rGraphic, XclImpStream& rStrm ) // static helper
+void XclImpDrawing::ReadBmp( Graphic& rGraphic, const XclImpRoot& rRoot, XclImpStream& rStrm ) // static helper
{
// extract graphic data from IMGDATA and following CONTINUE records
SvMemoryStream aMemStrm;
@@ -3883,7 +3823,7 @@ void XclImpObjectManager::ReadBmp( Graphic& rGraphic, XclImpStream& rStrm ) // s
pixel depth = 32 bit. After that, 3 unused bytes are added before the
actual pixel data. This does even confuse Excel 5 and later, which
cannot read the image data correctly. */
- if( rStrm.GetRoot().GetBiff() <= EXC_BIFF4 )
+ if( rRoot.GetBiff() <= EXC_BIFF4 )
{
rStrm.PushPosition();
sal_uInt32 nHdrSize;
@@ -3910,21 +3850,21 @@ void XclImpObjectManager::ReadBmp( Graphic& rGraphic, XclImpStream& rStrm ) // s
rGraphic = aBitmap;
}
-void XclImpObjectManager::ReadDffRecord( XclImpStream& rStrm )
+void XclImpDrawing::ReadDffRecord( XclImpStream& rStrm )
{
maDffStrm.Seek( STREAM_SEEK_TO_END );
rStrm.CopyRecordToStream( maDffStrm );
}
-void XclImpObjectManager::ReadObj8( XclImpStream& rStrm )
+void XclImpDrawing::ReadObj8( XclImpStream& rStrm )
{
- XclImpDrawObjRef xDrawObj = XclImpDrawObjBase::ReadObj8( rStrm );
+ XclImpDrawObjRef xDrawObj = XclImpDrawObjBase::ReadObj8( GetRoot(), rStrm );
// store the new object in the internal containers
maObjMap[ maDffStrm.Tell() ] = xDrawObj;
maObjMapId[ xDrawObj->GetObjId() ] = xDrawObj;
}
-void XclImpObjectManager::ReadTxo( XclImpStream& rStrm )
+void XclImpDrawing::ReadTxo( XclImpStream& rStrm )
{
XclImpObjTextRef xTextData( new XclImpObjTextData );
maTextMap[ maDffStrm.Tell() ] = xTextData;
@@ -3938,7 +3878,7 @@ void XclImpObjectManager::ReadTxo( XclImpStream& rStrm )
if( xTextData->maData.mnTextLen > 0 )
{
bValid = (rStrm.GetNextRecId() == EXC_ID_CONT) && rStrm.StartNextRecord();
- DBG_ASSERT( bValid, "XclImpObjectManager::ReadTxo - missing CONTINUE record" );
+ DBG_ASSERT( bValid, "XclImpDrawing::ReadTxo - missing CONTINUE record" );
if( bValid )
xTextData->mxString.reset( new XclImpString( rStrm.ReadUniString( xTextData->maData.mnTextLen ) ) );
}
@@ -3947,21 +3887,78 @@ void XclImpObjectManager::ReadTxo( XclImpStream& rStrm )
if( xTextData->maData.mnFormatSize > 0 )
{
bValid = (rStrm.GetNextRecId() == EXC_ID_CONT) && rStrm.StartNextRecord();
- DBG_ASSERT( bValid, "XclImpObjectManager::ReadTxo - missing CONTINUE record" );
+ DBG_ASSERT( bValid, "XclImpDrawing::ReadTxo - missing CONTINUE record" );
if( bValid )
xTextData->ReadFormats( rStrm );
}
}
-void XclImpObjectManager::ReadNote3( XclImpStream& rStrm )
+// ----------------------------------------------------------------------------
+
+XclImpSheetDrawing::XclImpSheetDrawing( const XclImpRoot& rRoot, SCTAB nScTab ) :
+ XclImpDrawing( rRoot, true ),
+ maScUsedArea( ScAddress::INITIALIZE_INVALID )
+{
+ maScUsedArea.aStart.SetTab( nScTab );
+ maScUsedArea.aEnd.SetTab( nScTab );
+}
+
+void XclImpSheetDrawing::ReadNote( XclImpStream& rStrm )
+{
+ switch( GetBiff() )
+ {
+ case EXC_BIFF2:
+ case EXC_BIFF3:
+ case EXC_BIFF4:
+ case EXC_BIFF5:
+ ReadNote3( rStrm );
+ break;
+ case EXC_BIFF8:
+ ReadNote8( rStrm );
+ break;
+ default:
+ DBG_ERROR_BIFF();
+ }
+}
+
+void XclImpSheetDrawing::ReadTabChart( XclImpStream& rStrm )
+{
+ DBG_ASSERT_BIFF( GetBiff() >= EXC_BIFF5 );
+ ScfRef< XclImpChartObj > xChartObj( new XclImpChartObj( GetRoot(), true ) );
+ xChartObj->ReadChartSubStream( rStrm );
+ // insert the chart as raw object without connected DFF data
+ AppendRawObject( xChartObj );
+}
+
+void XclImpSheetDrawing::ConvertObjects( XclImpDffConverter& rDffConv )
+{
+ if( SdrModel* pSdrModel = GetDoc().GetDrawLayer() )
+ if( SdrPage* pSdrPage = GetSdrPage( maScUsedArea.aStart.Tab() ) )
+ ImplConvertObjects( rDffConv, *pSdrModel, *pSdrPage );
+}
+
+Rectangle XclImpSheetDrawing::CalcAnchorRect( const XclObjAnchor& rAnchor, bool /*bDffAnchor*/ ) const
+{
+ return rAnchor.GetRect( GetDoc(), maScUsedArea.aStart.Tab(), MAP_100TH_MM );
+}
+
+void XclImpSheetDrawing::OnObjectInserted( const XclImpDrawObjBase& rDrawObj )
+{
+ ScRange aScObjArea = rDrawObj.GetUsedArea( maScUsedArea.aStart.Tab() );
+ if( aScObjArea.IsValid() )
+ maScUsedArea.ExtendTo( aScObjArea );
+}
+
+// private --------------------------------------------------------------------
+
+void XclImpSheetDrawing::ReadNote3( XclImpStream& rStrm )
{
XclAddress aXclPos;
sal_uInt16 nTotalLen;
rStrm >> aXclPos >> nTotalLen;
- SCTAB nScTab = GetCurrScTab();
ScAddress aScNotePos( ScAddress::UNINITIALIZED );
- if( GetAddressConverter().ConvertAddress( aScNotePos, aXclPos, nScTab, true ) )
+ if( GetAddressConverter().ConvertAddress( aScNotePos, aXclPos, maScUsedArea.aStart.Tab(), true ) )
{
sal_uInt16 nPartLen = ::std::min( nTotalLen, static_cast< sal_uInt16 >( rStrm.GetRecLeft() ) );
String aNoteText = rStrm.ReadRawByteString( nPartLen );
@@ -3988,33 +3985,117 @@ void XclImpObjectManager::ReadNote3( XclImpStream& rStrm )
}
}
-void XclImpObjectManager::ReadNote8( XclImpStream& rStrm )
+void XclImpSheetDrawing::ReadNote8( XclImpStream& rStrm )
{
XclAddress aXclPos;
sal_uInt16 nFlags, nObjId;
rStrm >> aXclPos >> nFlags >> nObjId;
- SCTAB nScTab = GetCurrScTab();
ScAddress aScNotePos( ScAddress::UNINITIALIZED );
- if( GetAddressConverter().ConvertAddress( aScNotePos, aXclPos, nScTab, true ) )
+ if( GetAddressConverter().ConvertAddress( aScNotePos, aXclPos, maScUsedArea.aStart.Tab(), true ) )
if( nObjId != EXC_OBJ_INVALID_ID )
- if( XclImpNoteObj* pNoteObj = dynamic_cast< XclImpNoteObj* >( FindDrawObj( XclObjId( nScTab, nObjId ) ).get() ) )
+ if( XclImpNoteObj* pNoteObj = dynamic_cast< XclImpNoteObj* >( FindDrawObj( nObjId ).get() ) )
pNoteObj->SetNoteData( aScNotePos, nFlags );
}
-sal_Size XclImpObjectManager::GetProgressSize() const
+// The object manager =========================================================
+
+XclImpObjectManager::XclImpObjectManager( const XclImpRoot& rRoot ) :
+ XclImpRoot( rRoot )
{
- sal_Size nProgressSize = maRawObjs.GetProgressSize();
- for( XclImpObjMap::const_iterator aMIt = maObjMap.begin(), aMEnd = maObjMap.end(); aMIt != aMEnd; ++aMIt )
- nProgressSize += aMIt->second->GetProgressSize();
- return nProgressSize;
+ maDefObjNames[ EXC_OBJTYPE_GROUP ] = CREATE_STRING( "Group" );
+ maDefObjNames[ EXC_OBJTYPE_LINE ] = CREATE_STRING( "Line" );
+ maDefObjNames[ EXC_OBJTYPE_RECTANGLE ] = CREATE_STRING( "Rectangle" );
+ maDefObjNames[ EXC_OBJTYPE_OVAL ] = CREATE_STRING( "Oval" );
+ maDefObjNames[ EXC_OBJTYPE_ARC ] = CREATE_STRING( "Arc" );
+ maDefObjNames[ EXC_OBJTYPE_CHART ] = CREATE_STRING( "Chart" );
+ maDefObjNames[ EXC_OBJTYPE_TEXT ] = CREATE_STRING( "Text" );
+ maDefObjNames[ EXC_OBJTYPE_BUTTON ] = CREATE_STRING( "Button" );
+ maDefObjNames[ EXC_OBJTYPE_PICTURE ] = CREATE_STRING( "Picture" );
+ maDefObjNames[ EXC_OBJTYPE_POLYGON ] = CREATE_STRING( "Freeform" );
+ maDefObjNames[ EXC_OBJTYPE_CHECKBOX ] = CREATE_STRING( "Check Box" );
+ maDefObjNames[ EXC_OBJTYPE_OPTIONBUTTON ] = CREATE_STRING( "Option Button" );
+ maDefObjNames[ EXC_OBJTYPE_EDIT ] = CREATE_STRING( "Edit Box" );
+ maDefObjNames[ EXC_OBJTYPE_LABEL ] = CREATE_STRING( "Label" );
+ maDefObjNames[ EXC_OBJTYPE_DIALOG ] = CREATE_STRING( "Dialog Frame" );
+ maDefObjNames[ EXC_OBJTYPE_SPIN ] = CREATE_STRING( "Spinner" );
+ maDefObjNames[ EXC_OBJTYPE_SCROLLBAR ] = CREATE_STRING( "Scroll Bar" );
+ maDefObjNames[ EXC_OBJTYPE_LISTBOX ] = CREATE_STRING( "List Box" );
+ maDefObjNames[ EXC_OBJTYPE_GROUPBOX ] = CREATE_STRING( "Group Box" );
+ maDefObjNames[ EXC_OBJTYPE_DROPDOWN ] = CREATE_STRING( "Drop Down" );
+ maDefObjNames[ EXC_OBJTYPE_NOTE ] = CREATE_STRING( "Comment" );
+ maDefObjNames[ EXC_OBJTYPE_DRAWING ] = CREATE_STRING( "AutoShape" );
+}
+
+XclImpObjectManager::~XclImpObjectManager()
+{
+}
+
+void XclImpObjectManager::ReadMsoDrawingGroup( XclImpStream& rStrm )
+{
+ DBG_ASSERT_BIFF( GetBiff() == EXC_BIFF8 );
+ // Excel continues this record with MSODRAWINGGROUP and CONTINUE records, hmm.
+ rStrm.ResetRecord( true, EXC_ID_MSODRAWINGGROUP );
+ maDggStrm.Seek( STREAM_SEEK_TO_END );
+ rStrm.CopyRecordToStream( maDggStrm );
+}
+
+XclImpSheetDrawing& XclImpObjectManager::GetSheetDrawing( SCTAB nScTab )
+{
+ XclImpSheetDrawingRef& rxDrawing = maSheetDrawings[ nScTab ];
+ if( !rxDrawing )
+ rxDrawing.reset( new XclImpSheetDrawing( GetRoot(), nScTab ) );
+ return *rxDrawing;
+}
+
+void XclImpObjectManager::ConvertObjects()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "sc", "dr104026", "XclImpObjectManager::ConvertObjects" );
+
+ // do nothing if the document does not contain a drawing layer
+ if( !GetDoc().GetDrawLayer() )
+ return;
+
+ // get total progress bar size for all sheet drawing managers
+ sal_Size nProgressSize = 0;
+ for( XclImpSheetDrawingMap::iterator aIt = maSheetDrawings.begin(), aEnd = maSheetDrawings.end(); aIt != aEnd; ++aIt )
+ nProgressSize += aIt->second->GetProgressSize();
+ // nothing to do if progress bar is zero (no objects present)
+ if( nProgressSize == 0 )
+ return;
+
+ XclImpDffConverter aDffConv( GetRoot(), maDggStrm );
+ aDffConv.StartProgressBar( nProgressSize );
+ for( XclImpSheetDrawingMap::iterator aIt = maSheetDrawings.begin(), aEnd = maSheetDrawings.end(); aIt != aEnd; ++aIt )
+ aIt->second->ConvertObjects( aDffConv );
+
+ ScChartListenerCollection* pChartListeners = GetDoc().GetChartListenerCollection();
+ if( pChartListeners && (pChartListeners->GetCount() > 0) )
+ pChartListeners->SetDirty();
+}
+
+String XclImpObjectManager::GetDefaultObjName( const XclImpDrawObjBase& rDrawObj ) const
+{
+ String aDefName;
+ DefObjNameMap::const_iterator aIt = maDefObjNames.find( rDrawObj.GetObjType() );
+ if( aIt != maDefObjNames.end() )
+ aDefName.Append( aIt->second );
+ return aDefName.Append( sal_Unicode( ' ' ) ).Append( String::CreateFromInt32( rDrawObj.GetObjId() ) );
+}
+
+ScRange XclImpObjectManager::GetUsedArea( SCTAB nScTab ) const
+{
+ XclImpSheetDrawingMap::const_iterator aIt = maSheetDrawings.find( nScTab );
+ if( aIt != maSheetDrawings.end() )
+ return aIt->second->GetUsedArea();
+ return ScRange( ScAddress::INITIALIZE_INVALID );
}
// DFF property set helper ====================================================
XclImpDffPropSet::XclImpDffPropSet( const XclImpRoot& rRoot ) :
XclImpRoot( rRoot ),
- maDffManager( rRoot, maDummyStrm )
+ maDffConv( rRoot, maDummyStrm )
{
}
@@ -4030,18 +4111,18 @@ void XclImpDffPropSet::Read( XclImpStream& rStrm )
mxMemStrm.reset( new SvMemoryStream );
rStrm.CopyToStream( *mxMemStrm, 8 + nPropSetSize );
mxMemStrm->Seek( STREAM_SEEK_TO_BEGIN );
- maDffManager.ReadPropSet( *mxMemStrm, 0 );
+ maDffConv.ReadPropSet( *mxMemStrm, 0 );
}
sal_uInt32 XclImpDffPropSet::GetPropertyValue( sal_uInt16 nPropId, sal_uInt32 nDefault ) const
{
- return maDffManager.GetPropertyValue( nPropId, nDefault );
+ return maDffConv.GetPropertyValue( nPropId, nDefault );
}
void XclImpDffPropSet::FillToItemSet( SfxItemSet& rItemSet ) const
{
if( mxMemStrm.get() )
- maDffManager.ApplyAttributes( *mxMemStrm, rItemSet );
+ maDffConv.ApplyAttributes( *mxMemStrm, rItemSet );
}
XclImpStream& operator>>( XclImpStream& rStrm, XclImpDffPropSet& rPropSet )
diff --git a/sc/source/filter/excel/xihelper.cxx b/sc/source/filter/excel/xihelper.cxx
index 1afcba154c4a..ad04a1f3930c 100644
--- a/sc/source/filter/excel/xihelper.cxx
+++ b/sc/source/filter/excel/xihelper.cxx
@@ -837,7 +837,7 @@ XclImpCachedValue::~XclImpCachedValue()
{
}
-USHORT XclImpCachedValue::GetError() const
+USHORT XclImpCachedValue::GetScError() const
{
return (mnType == EXC_CACHEDVAL_ERROR) ? XclTools::GetScErrorCode( mnBoolErr ) : 0;
}
@@ -901,7 +901,7 @@ ScMatrixRef XclImpCachedMatrix::CreateScMatrix() const
xScMatrix->PutBoolean( pValue->GetBool(), nScCol, nScRow );
break;
case EXC_CACHEDVAL_ERROR:
- xScMatrix->PutError( pValue->GetError(), nScCol, nScRow );
+ xScMatrix->PutError( pValue->GetScError(), nScCol, nScRow );
break;
default:
DBG_ERRORFILE( "XclImpCachedMatrix::CreateScMatrix - unknown value type" );
diff --git a/sc/source/filter/excel/xilink.cxx b/sc/source/filter/excel/xilink.cxx
index 1183b077b626..45eed0fd98a9 100644
--- a/sc/source/filter/excel/xilink.cxx
+++ b/sc/source/filter/excel/xilink.cxx
@@ -413,6 +413,11 @@ void XclImpSupbookTab::LoadCachedValues(ScExternalRefCache::TableTypeRef pCacheT
switch (p->GetType())
{
case EXC_CACHEDVAL_BOOL:
+ {
+ bool b = p->GetBool();
+ ScExternalRefCache::TokenRef pToken(new formula::FormulaDoubleToken(b ? 1.0 : 0.0));
+ pCacheTable->setCell(rAddr.mnCol, rAddr.mnRow, pToken);
+ }
break;
case EXC_CACHEDVAL_DOUBLE:
{
@@ -421,9 +426,12 @@ void XclImpSupbookTab::LoadCachedValues(ScExternalRefCache::TableTypeRef pCacheT
pCacheTable->setCell(rAddr.mnCol, rAddr.mnRow, pToken);
}
break;
- case EXC_CACHEDVAL_EMPTY:
- break;
case EXC_CACHEDVAL_ERROR:
+ {
+ double fError = XclTools::ErrorToDouble( p->GetXclError() );
+ ScExternalRefCache::TokenRef pToken(new formula::FormulaDoubleToken(fError));
+ pCacheTable->setCell(rAddr.mnCol, rAddr.mnRow, pToken);
+ }
break;
case EXC_CACHEDVAL_STRING:
{
diff --git a/sc/source/filter/excel/xipage.cxx b/sc/source/filter/excel/xipage.cxx
index 75ec91626cf6..c689d0eb7feb 100644
--- a/sc/source/filter/excel/xipage.cxx
+++ b/sc/source/filter/excel/xipage.cxx
@@ -168,7 +168,7 @@ void XclImpPageSettings::ReadPrintGridLines( XclImpStream& rStrm )
void XclImpPageSettings::ReadImgData( XclImpStream& rStrm )
{
- Graphic aGraphic = XclImpObjectManager::ReadImgData( rStrm );
+ Graphic aGraphic = XclImpDrawing::ReadImgData( GetRoot(), rStrm );
if( aGraphic.GetType() != GRAPHIC_NONE )
maData.mxBrushItem.reset( new SvxBrushItem( aGraphic, GPOS_TILED, ATTR_BACKGROUND ) );
}
diff --git a/sc/source/filter/excel/xipivot.cxx b/sc/source/filter/excel/xipivot.cxx
index ac184224c611..29e27a698a42 100644
--- a/sc/source/filter/excel/xipivot.cxx
+++ b/sc/source/filter/excel/xipivot.cxx
@@ -1311,7 +1311,7 @@ void XclImpPivotTable::ReadSxpi( XclImpStream& rStrm )
maPageFields.push_back( aPageInfo.mnField );
pField->SetPageFieldInfo( aPageInfo );
}
- GetObjectManager().SetSkipObj( GetCurrScTab(), aPageInfo.mnObjId );
+ GetCurrSheetDrawing().SetSkipObj( aPageInfo.mnObjId );
}
}
diff --git a/sc/source/filter/excel/xiroot.cxx b/sc/source/filter/excel/xiroot.cxx
index 7b03d56408c9..3384cf248c87 100644
--- a/sc/source/filter/excel/xiroot.cxx
+++ b/sc/source/filter/excel/xiroot.cxx
@@ -206,6 +206,12 @@ XclImpObjectManager& XclImpRoot::GetObjectManager() const
return *mrImpData.mxObjMgr;
}
+XclImpSheetDrawing& XclImpRoot::GetCurrSheetDrawing() const
+{
+ DBG_ASSERT( !IsInGlobals(), "XclImpRoot::GetCurrSheetDrawing - must not be called from workbook globals" );
+ return mrImpData.mxObjMgr->GetSheetDrawing( GetCurrScTab() );
+}
+
XclImpCondFormatManager& XclImpRoot::GetCondFormatManager() const
{
DBG_ASSERT( mrImpData.mxCondFmtMgr.is(), "XclImpRoot::GetCondFormatManager - invalid call, wrong BIFF" );
diff --git a/sc/source/filter/excel/xistyle.cxx b/sc/source/filter/excel/xistyle.cxx
index 4e0ff5079471..1559ef5530f5 100644
--- a/sc/source/filter/excel/xistyle.cxx
+++ b/sc/source/filter/excel/xistyle.cxx
@@ -701,7 +701,6 @@ void XclImpCellAlign::FillToItemSet( SfxItemSet& rItemSet, const XclImpFont* pFo
sal_uInt8 nXclRot = (mnOrient == EXC_ORIENT_NONE) ? mnRotation : XclTools::GetXclRotFromOrient( mnOrient );
bool bStacked = (nXclRot == EXC_ROT_STACKED);
ScfTools::PutItem( rItemSet, SfxBoolItem( ATTR_STACKED, bStacked ), bSkipPoolDefs );
- ScfTools::PutItem( rItemSet, SvxRotateModeItem( SVX_ROTATE_MODE_STANDARD, ATTR_ROTATE_MODE ), bSkipPoolDefs );
// set an angle in the range from -90 to 90 degrees
sal_Int32 nAngle = XclTools::GetScRotation( nXclRot, 0 );
ScfTools::PutItem( rItemSet, SfxInt32Item( ATTR_ROTATE_VALUE, nAngle ), bSkipPoolDefs );
@@ -799,6 +798,15 @@ void XclImpCellBorder::FillFromCF8( sal_uInt16 nLineStyle, sal_uInt32 nLineColor
mbDiagUsed = false;
}
+bool XclImpCellBorder::HasAnyOuterBorder() const
+{
+ return
+ (mbLeftUsed && (mnLeftLine != EXC_LINE_NONE)) ||
+ (mbRightUsed && (mnRightLine != EXC_LINE_NONE)) ||
+ (mbTopUsed && (mnTopLine != EXC_LINE_NONE)) ||
+ (mbBottomUsed && (mnBottomLine != EXC_LINE_NONE));
+}
+
namespace {
/** Converts the passed line style to a SvxBorderLine, or returns false, if style is "no line". */
@@ -1091,13 +1099,32 @@ const ScPatternAttr& XclImpXF::CreatePattern( bool bSkipPoolDefs )
// create new pattern attribute set
mpPattern.reset( new ScPatternAttr( GetDoc().GetPool() ) );
SfxItemSet& rItemSet = mpPattern->GetItemSet();
+ XclImpXF* pParentXF = IsCellXF() ? GetXFBuffer().GetXF( mnParent ) : 0;
// parent cell style
if( IsCellXF() && !mpStyleSheet )
{
mpStyleSheet = GetXFBuffer().CreateStyleSheet( mnParent );
- if( XclImpXF* pParentXF = GetXFBuffer().GetXF( mnParent ) )
- UpdateUsedFlags( *pParentXF );
+
+ /* Enables mb***Used flags, if the formatting attributes differ from
+ the passed XF record. In cell XFs Excel uses the cell attributes,
+ if they differ from the parent style XF.
+ #109899# ...or if the respective flag is not set in parent style XF. */
+ if( pParentXF )
+ {
+ if( !mbProtUsed )
+ mbProtUsed = !pParentXF->mbProtUsed || !(maProtection == pParentXF->maProtection);
+ if( !mbFontUsed )
+ mbFontUsed = !pParentXF->mbFontUsed || (mnXclFont != pParentXF->mnXclFont);
+ if( !mbFmtUsed )
+ mbFmtUsed = !pParentXF->mbFmtUsed || (mnXclNumFmt != pParentXF->mnXclNumFmt);
+ if( !mbAlignUsed )
+ mbAlignUsed = !pParentXF->mbAlignUsed || !(maAlignment == pParentXF->maAlignment);
+ if( !mbBorderUsed )
+ mbBorderUsed = !pParentXF->mbBorderUsed || !(maBorder == pParentXF->maBorder);
+ if( !mbAreaUsed )
+ mbAreaUsed = !pParentXF->mbAreaUsed || !(maArea == pParentXF->maArea);
+ }
}
// cell protection
@@ -1137,6 +1164,20 @@ const ScPatternAttr& XclImpXF::CreatePattern( bool bSkipPoolDefs )
maArea.mnPattern != EXC_PATT_SOLID);
}
+ /* #i38709# Decide which rotation reference mode to use. If any outer
+ border line of the cell is set (either explicitly or via cell style),
+ and the cell contents are rotated, set rotation reference to bottom of
+ cell. This causes the borders to be painted rotated with the text. */
+ if( mbAlignUsed || mbBorderUsed )
+ {
+ SvxRotateMode eRotateMode = SVX_ROTATE_MODE_STANDARD;
+ const XclImpCellAlign* pAlign = mbAlignUsed ? &maAlignment : (pParentXF ? &pParentXF->maAlignment : 0);
+ const XclImpCellBorder* pBorder = mbBorderUsed ? &maBorder : (pParentXF ? &pParentXF->maBorder : 0);
+ if( pAlign && pBorder && (0 < pAlign->mnRotation) && (pAlign->mnRotation <= 180) && pBorder->HasAnyOuterBorder() )
+ eRotateMode = SVX_ROTATE_MODE_BOTTOM;
+ ScfTools::PutItem( rItemSet, SvxRotateModeItem( eRotateMode, ATTR_ROTATE_MODE ), bSkipPoolDefs );
+ }
+
return *mpPattern;
}
@@ -1180,26 +1221,6 @@ void XclImpXF::SetUsedFlags( sal_uInt8 nUsedFlags )
mbAreaUsed = (mbCellXF == ::get_flag( nUsedFlags, EXC_XF_DIFF_AREA ));
}
-void XclImpXF::UpdateUsedFlags( const XclImpXF& rParentXF )
-{
- /* Enables mb***Used flags, if the formatting attributes differ from
- the passed XF record. In cell XFs Excel uses the cell attributes,
- if they differ from the parent style XF.
- #109899# ...or if the respective flag is not set in parent style XF. */
- if( !mbProtUsed )
- mbProtUsed = !rParentXF.mbProtUsed || !(maProtection == rParentXF.maProtection);
- if( !mbFontUsed )
- mbFontUsed = !rParentXF.mbFontUsed || (mnXclFont != rParentXF.mnXclFont);
- if( !mbFmtUsed )
- mbFmtUsed = !rParentXF.mbFmtUsed || (mnXclNumFmt != rParentXF.mnXclNumFmt);
- if( !mbAlignUsed )
- mbAlignUsed = !rParentXF.mbAlignUsed || !(maAlignment == rParentXF.maAlignment);
- if( !mbBorderUsed )
- mbBorderUsed = !rParentXF.mbBorderUsed || !(maBorder == rParentXF.maBorder);
- if( !mbAreaUsed )
- mbAreaUsed = !rParentXF.mbAreaUsed || !(maArea == rParentXF.maArea);
-}
-
// ----------------------------------------------------------------------------
XclImpStyle::XclImpStyle( const XclImpRoot& rRoot ) :
diff --git a/sc/source/filter/excel/xlchart.cxx b/sc/source/filter/excel/xlchart.cxx
index 2391eb7ef92e..41e682f85808 100644
--- a/sc/source/filter/excel/xlchart.cxx
+++ b/sc/source/filter/excel/xlchart.cxx
@@ -308,7 +308,7 @@ XclChTypeGroup::XclChTypeGroup() :
// ----------------------------------------------------------------------------
XclChProperties::XclChProperties() :
- mnFlags( EXC_CHPROPS_MANSERIES ),
+ mnFlags( 0 ),
mnEmptyMode( EXC_CHPROPS_EMPTY_SKIP )
{
}
@@ -988,8 +988,8 @@ void XclChPropSetHelper::ReadLegendProperties( XclChLegend& rLegend, const ScfPr
cssc::RelativePosition aRelPos;
if( aRelPosAny >>= aRelPos )
{
- rLegend.maRect.mnX = limit_cast< sal_Int32 >( aRelPos.Primary * 4000.0, 0, 4000 );
- rLegend.maRect.mnY = limit_cast< sal_Int32 >( aRelPos.Secondary * 4000.0, 0, 4000 );
+ rLegend.maRect.mnX = limit_cast< sal_Int32 >( aRelPos.Primary * EXC_CHART_UNIT, 0, EXC_CHART_UNIT );
+ rLegend.maRect.mnY = limit_cast< sal_Int32 >( aRelPos.Secondary * EXC_CHART_UNIT, 0, EXC_CHART_UNIT );
}
else
rLegend.mnDockMode = EXC_CHLEGEND_LEFT;
@@ -1240,8 +1240,8 @@ void XclChPropSetHelper::WriteLegendProperties(
eApiExpand = cssc::LegendExpansion_BALANCED;
// set position
cssc::RelativePosition aRelPos;
- aRelPos.Primary = rLegend.maRect.mnX / 4000.0;
- aRelPos.Secondary = rLegend.maRect.mnY / 4000.0;
+ aRelPos.Primary = static_cast< double >( rLegend.maRect.mnX ) / EXC_CHART_UNIT;
+ aRelPos.Secondary = static_cast< double >( rLegend.maRect.mnY ) / EXC_CHART_UNIT;
aRelPos.Anchor = cssd::Alignment_TOP_LEFT;
aRelPosAny <<= aRelPos;
}
diff --git a/sc/source/filter/excel/xlescher.cxx b/sc/source/filter/excel/xlescher.cxx
index 5d74346608fd..538fd7fd7242 100644
--- a/sc/source/filter/excel/xlescher.cxx
+++ b/sc/source/filter/excel/xlescher.cxx
@@ -159,12 +159,16 @@ void lclMirrorRectangle( Rectangle& rRect )
rRect.Right() = -nLeft;
}
+sal_uInt16 lclGetEmbeddedScale( long nPageSize, sal_Int32 nPageScale, long nPos, double fPosScale )
+{
+ return static_cast< sal_uInt16 >( nPos * fPosScale / nPageSize * nPageScale + 0.5 );
+}
+
} // namespace
// ----------------------------------------------------------------------------
-XclObjAnchor::XclObjAnchor( SCTAB nScTab ) :
- mnScTab( nScTab ),
+XclObjAnchor::XclObjAnchor() :
mnLX( 0 ),
mnTY( 0 ),
mnRX( 0 ),
@@ -172,35 +176,61 @@ XclObjAnchor::XclObjAnchor( SCTAB nScTab ) :
{
}
-Rectangle XclObjAnchor::GetRect( ScDocument& rDoc, MapUnit eMapUnit ) const
+Rectangle XclObjAnchor::GetRect( ScDocument& rDoc, SCTAB nScTab, MapUnit eMapUnit ) const
{
double fScale = lclGetTwipsScale( eMapUnit );
Rectangle aRect(
- lclGetXFromCol( rDoc, mnScTab, maFirst.mnCol, mnLX, fScale ),
- lclGetYFromRow( rDoc, mnScTab, maFirst.mnRow, mnTY, fScale ),
- lclGetXFromCol( rDoc, mnScTab, maLast.mnCol, mnRX + 1, fScale ),
- lclGetYFromRow( rDoc, mnScTab, maLast.mnRow, mnBY, fScale ) );
+ lclGetXFromCol( rDoc, nScTab, maFirst.mnCol, mnLX, fScale ),
+ lclGetYFromRow( rDoc, nScTab, maFirst.mnRow, mnTY, fScale ),
+ lclGetXFromCol( rDoc, nScTab, maLast.mnCol, mnRX + 1, fScale ),
+ lclGetYFromRow( rDoc, nScTab, maLast.mnRow, mnBY, fScale ) );
// #106948# adjust coordinates in mirrored sheets
- if( rDoc.IsLayoutRTL( mnScTab ) )
+ if( rDoc.IsLayoutRTL( nScTab ) )
lclMirrorRectangle( aRect );
return aRect;
}
-void XclObjAnchor::SetRect( ScDocument& rDoc, const Rectangle& rRect, MapUnit eMapUnit )
+void XclObjAnchor::SetRect( ScDocument& rDoc, SCTAB nScTab, const Rectangle& rRect, MapUnit eMapUnit )
{
Rectangle aRect( rRect );
// #106948# adjust coordinates in mirrored sheets
- if( rDoc.IsLayoutRTL( mnScTab ) )
+ if( rDoc.IsLayoutRTL( nScTab ) )
lclMirrorRectangle( aRect );
double fScale = lclGetTwipsScale( eMapUnit );
long nDummy = 0;
- lclGetColFromX( rDoc, mnScTab, maFirst.mnCol, mnLX, 0, nDummy, aRect.Left(), fScale );
- lclGetColFromX( rDoc, mnScTab, maLast.mnCol, mnRX, maFirst.mnCol, nDummy, aRect.Right(), fScale );
+ lclGetColFromX( rDoc, nScTab, maFirst.mnCol, mnLX, 0, nDummy, aRect.Left(), fScale );
+ lclGetColFromX( rDoc, nScTab, maLast.mnCol, mnRX, maFirst.mnCol, nDummy, aRect.Right(), fScale );
nDummy = 0;
- lclGetRowFromY( rDoc, mnScTab, maFirst.mnRow, mnTY, 0, nDummy, aRect.Top(), fScale );
- lclGetRowFromY( rDoc, mnScTab, maLast.mnRow, mnBY, maFirst.mnRow, nDummy, aRect.Bottom(), fScale );
+ lclGetRowFromY( rDoc, nScTab, maFirst.mnRow, mnTY, 0, nDummy, aRect.Top(), fScale );
+ lclGetRowFromY( rDoc, nScTab, maLast.mnRow, mnBY, maFirst.mnRow, nDummy, aRect.Bottom(), fScale );
+}
+
+void XclObjAnchor::SetRect( const Size& rPageSize, sal_Int32 nScaleX, sal_Int32 nScaleY,
+ const Rectangle& rRect, MapUnit eMapUnit, bool bDffAnchor )
+{
+ double fScale = 1.0;
+ switch( eMapUnit )
+ {
+ case MAP_TWIP: fScale = HMM_PER_TWIPS; break; // Calc twips -> 1/100mm
+ case MAP_100TH_MM: fScale = 1.0; break; // Calc 1/100mm -> 1/100mm
+ default: DBG_ERRORFILE( "XclObjAnchor::SetRect - map unit not implemented" );
+ }
+
+ /* In objects with DFF client anchor, the position of the shape is stored
+ in the cell address components of the client anchor. In old BIFF3-BIFF5
+ objects, the position is stored in the offset components of the anchor. */
+ (bDffAnchor ? maFirst.mnCol : mnLX) = lclGetEmbeddedScale( rPageSize.Width(), nScaleX, rRect.Left(), fScale );
+ (bDffAnchor ? maFirst.mnRow : mnTY) = lclGetEmbeddedScale( rPageSize.Height(), nScaleY, rRect.Top(), fScale );
+ (bDffAnchor ? maLast.mnCol : mnRX) = lclGetEmbeddedScale( rPageSize.Width(), nScaleX, rRect.Right(), fScale );
+ (bDffAnchor ? maLast.mnRow : mnBY) = lclGetEmbeddedScale( rPageSize.Height(), nScaleY, rRect.Bottom(), fScale );
+
+ // for safety, clear the other members
+ if( bDffAnchor )
+ mnLX = mnTY = mnRX = mnBY = 0;
+ else
+ Set( 0, 0, 0, 0 );
}
// ----------------------------------------------------------------------------
diff --git a/sc/source/filter/excel/xlformula.cxx b/sc/source/filter/excel/xlformula.cxx
index c46df189ab74..d613f1279242 100644
--- a/sc/source/filter/excel/xlformula.cxx
+++ b/sc/source/filter/excel/xlformula.cxx
@@ -68,22 +68,28 @@ const sal_uInt8 A = EXC_TOKCLASS_ARR;
#define VR_E { EXC_PARAM_EXCELONLY, EXC_PARAMCONV_RPT, true }
#define C { EXC_PARAM_CALCONLY, EXC_PARAMCONV_ORG, false }
+const sal_uInt16 NOID = SAL_MAX_UINT16; /// No BIFF/OOBIN function identifier available.
+const sal_uInt8 MX = 30; /// Maximum parameter count.
+
+#define EXC_FUNCNAME( ascii ) "_xlfn." ascii
+#define EXC_FUNCNAME_ODF( ascii ) "_xlfnodf." ascii
+
/** Functions new in BIFF2. */
static const XclFunctionInfo saFuncTable_2[] =
{
- { ocCount, 0, 0, 30, V, { RX }, 0, 0 },
+ { ocCount, 0, 0, MX, V, { RX }, 0, 0 },
{ ocIf, 1, 2, 3, R, { VO, RO }, 0, 0 },
{ ocIsNA, 2, 1, 1, V, { VR }, 0, 0 },
{ ocIsError, 3, 1, 1, V, { VR }, 0, 0 },
- { ocSum, 4, 0, 30, V, { RX }, 0, 0 },
- { ocAverage, 5, 1, 30, V, { RX }, 0, 0 },
- { ocMin, 6, 1, 30, V, { RX }, 0, 0 },
- { ocMax, 7, 1, 30, V, { RX }, 0, 0 },
+ { ocSum, 4, 0, MX, V, { RX }, 0, 0 },
+ { ocAverage, 5, 1, MX, V, { RX }, 0, 0 },
+ { ocMin, 6, 1, MX, V, { RX }, 0, 0 },
+ { ocMax, 7, 1, MX, V, { RX }, 0, 0 },
{ ocRow, 8, 0, 1, V, { RO }, 0, 0 },
{ ocColumn, 9, 0, 1, V, { RO }, 0, 0 },
{ ocNotAvail, 10, 0, 0, V, {}, 0, 0 },
- { ocNPV, 11, 2, 30, V, { VR, RX }, 0, 0 },
- { ocStDev, 12, 1, 30, V, { RX }, 0, 0 },
+ { ocNPV, 11, 2, MX, V, { VR, RX }, 0, 0 },
+ { ocStDev, 12, 1, MX, V, { RX }, 0, 0 },
{ ocCurrency, 13, 1, 2, V, { VR }, 0, 0 },
{ ocFixed, 14, 1, 2, V, { VR, VR, C }, 0, 0 },
{ ocSin, 15, 1, 1, V, { VR }, 0, 0 },
@@ -109,8 +115,8 @@ static const XclFunctionInfo saFuncTable_2[] =
{ ocValue, 33, 1, 1, V, { VR }, 0, 0 },
{ ocTrue, 34, 0, 0, V, {}, 0, 0 },
{ ocFalse, 35, 0, 0, V, {}, 0, 0 },
- { ocAnd, 36, 1, 30, V, { RX }, 0, 0 },
- { ocOr, 37, 1, 30, V, { RX }, 0, 0 },
+ { ocAnd, 36, 1, MX, V, { RX }, 0, 0 },
+ { ocOr, 37, 1, MX, V, { RX }, 0, 0 },
{ ocNot, 38, 1, 1, V, { VR }, 0, 0 },
{ ocMod, 39, 2, 2, V, { VR }, 0, 0 },
{ ocDBCount, 40, 3, 3, V, { RO, RR }, 0, 0 },
@@ -119,7 +125,7 @@ static const XclFunctionInfo saFuncTable_2[] =
{ ocDBMin, 43, 3, 3, V, { RO, RR }, 0, 0 },
{ ocDBMax, 44, 3, 3, V, { RO, RR }, 0, 0 },
{ ocDBStdDev, 45, 3, 3, V, { RO, RR }, 0, 0 },
- { ocVar, 46, 1, 30, V, { RX }, 0, 0 },
+ { ocVar, 46, 1, MX, V, { RX }, 0, 0 },
{ ocDBVar, 47, 3, 3, V, { RO, RR }, 0, 0 },
{ ocText, 48, 2, 2, V, { VR }, 0, 0 },
{ ocRGP, 49, 1, 2, A, { RA, RA, C, C }, 0, 0 },
@@ -155,7 +161,7 @@ static const XclFunctionInfo saFuncTable_2[] =
{ ocArcTan2, 97, 2, 2, V, { VR }, 0, 0 },
{ ocArcSin, 98, 1, 1, V, { VR }, 0, 0 },
{ ocArcCos, 99, 1, 1, V, { VR }, 0, 0 },
- { ocChose, 100, 2, 30, R, { VO, RO }, 0, 0 },
+ { ocChose, 100, 2, MX, R, { VO, RO }, 0, 0 },
{ ocHLookup, 101, 3, 3, V, { VV, RO, RO, C }, 0, 0 },
{ ocVLookup, 102, 3, 3, V, { VV, RO, RO, C }, 0, 0 },
{ ocIsRef, 105, 1, 1, V, { RX }, 0, 0 },
@@ -191,13 +197,13 @@ static const XclFunctionInfo saFuncTable_2[] =
{ ocMatMult, 165, 2, 2, A, { VA }, 0, 0 },
{ ocZinsZ, 167, 4, 6, V, { VR }, 0, 0 },
{ ocKapz, 168, 4, 6, V, { VR }, 0, 0 },
- { ocCount2, 169, 0, 30, V, { RX }, 0, 0 },
- { ocProduct, 183, 0, 30, V, { RX }, 0, 0 },
+ { ocCount2, 169, 0, MX, V, { RX }, 0, 0 },
+ { ocProduct, 183, 0, MX, V, { RX }, 0, 0 },
{ ocFact, 184, 1, 1, V, { VR }, 0, 0 },
{ ocDBProduct, 189, 3, 3, V, { RO, RR }, 0, 0 },
{ ocIsNonString, 190, 1, 1, V, { VR }, 0, 0 },
- { ocStDevP, 193, 1, 30, V, { RX }, 0, 0 },
- { ocVarP, 194, 1, 30, V, { RX }, 0, 0 },
+ { ocStDevP, 193, 1, MX, V, { RX }, 0, 0 },
+ { ocVarP, 194, 1, MX, V, { RX }, 0, 0 },
{ ocDBStdDevP, 195, 3, 3, V, { RO, RR }, 0, 0 },
{ ocDBVarP, 196, 3, 3, V, { RO, RR }, 0, 0 },
{ ocTrunc, 197, 1, 1, V, { VR, C }, 0, 0 },
@@ -206,7 +212,7 @@ static const XclFunctionInfo saFuncTable_2[] =
{ ocCurrency, 204, 1, 2, V, { VR }, EXC_FUNCFLAG_IMPORTONLY, 0 },
{ ocRoundUp, 212, 2, 2, V, { VR }, 0, 0 },
{ ocRoundDown, 213, 2, 2, V, { VR }, 0, 0 },
- { ocExternal, 255, 1, 30, R, { RO_E, RO }, EXC_FUNCFLAG_IMPORTONLY, 0 }
+ { ocExternal, 255, 1, MX, R, { RO_E, RO }, EXC_FUNCFLAG_IMPORTONLY, 0 }
};
/** Functions new in BIFF3. */
@@ -221,8 +227,8 @@ static const XclFunctionInfo saFuncTable_3[] =
{ ocGetDiffDate360, 220, 2, 2, V, { VR, VR, C }, 0, 0 },
{ ocGetActDate, 221, 0, 0, V, {}, EXC_FUNCFLAG_VOLATILE, 0 },
{ ocVBD, 222, 5, 7, V, { VR }, 0, 0 },
- { ocMedian, 227, 1, 30, V, { RX }, 0, 0 },
- { ocSumProduct, 228, 1, 30, V, { VA }, 0, 0 },
+ { ocMedian, 227, 1, MX, V, { RX }, 0, 0 },
+ { ocSumProduct, 228, 1, MX, V, { VA }, 0, 0 },
{ ocSinHyp, 229, 1, 1, V, { VR }, 0, 0 },
{ ocCosHyp, 230, 1, 1, V, { VR }, 0, 0 },
{ ocTanHyp, 231, 1, 1, V, { VR }, 0, 0 },
@@ -245,7 +251,7 @@ static const XclFunctionInfo saFuncTable_4[] =
{ ocGDA2, 247, 4, 5, V, { VR }, 0, 0 },
{ ocFrequency, 252, 2, 2, A, { RA }, 0, 0 },
{ ocErrorType, 261, 1, 1, V, { VR }, 0, 0 },
- { ocAveDev, 269, 1, 30, V, { RX }, 0, 0 },
+ { ocAveDev, 269, 1, MX, V, { RX }, 0, 0 },
{ ocBetaDist, 270, 3, 5, V, { VR }, 0, 0 },
{ ocGammaLn, 271, 1, 1, V, { VR }, 0, 0 },
{ ocBetaInv, 272, 3, 5, V, { VR }, 0, 0 },
@@ -294,19 +300,19 @@ static const XclFunctionInfo saFuncTable_4[] =
{ ocSlope, 315, 2, 2, V, { VA }, 0, 0 },
{ ocTTest, 316, 4, 4, V, { VA, VA, VR }, 0, 0 },
{ ocProb, 317, 3, 4, V, { VA, VA, VR }, 0, 0 },
- { ocDevSq, 318, 1, 30, V, { RX }, 0, 0 },
- { ocGeoMean, 319, 1, 30, V, { RX }, 0, 0 },
- { ocHarMean, 320, 1, 30, V, { RX }, 0, 0 },
- { ocSumSQ, 321, 0, 30, V, { RX }, 0, 0 },
- { ocKurt, 322, 1, 30, V, { RX }, 0, 0 },
- { ocSchiefe, 323, 1, 30, V, { RX }, 0, 0 },
+ { ocDevSq, 318, 1, MX, V, { RX }, 0, 0 },
+ { ocGeoMean, 319, 1, MX, V, { RX }, 0, 0 },
+ { ocHarMean, 320, 1, MX, V, { RX }, 0, 0 },
+ { ocSumSQ, 321, 0, MX, V, { RX }, 0, 0 },
+ { ocKurt, 322, 1, MX, V, { RX }, 0, 0 },
+ { ocSchiefe, 323, 1, MX, V, { RX }, 0, 0 },
{ ocZTest, 324, 2, 3, V, { RX, VR }, 0, 0 },
{ ocLarge, 325, 2, 2, V, { RX, VR }, 0, 0 },
{ ocSmall, 326, 2, 2, V, { RX, VR }, 0, 0 },
{ ocQuartile, 327, 2, 2, V, { RX, VR }, 0, 0 },
{ ocPercentile, 328, 2, 2, V, { RX, VR }, 0, 0 },
{ ocPercentrank, 329, 2, 3, V, { RX, VR, VR_E }, 0, 0 },
- { ocModalValue, 330, 1, 30, V, { VA }, 0, 0 },
+ { ocModalValue, 330, 1, MX, V, { VA }, 0, 0 },
{ ocTrimMean, 331, 2, 2, V, { RX, VR }, 0, 0 },
{ ocTInv, 332, 2, 2, V, { VR }, 0, 0 }
};
@@ -318,13 +324,13 @@ static const XclFunctionInfo saFuncTable_5[] =
{ ocHLookup, 101, 3, 4, V, { VV, RO, RO, VV }, 0, 0 }, // BIFF2-4: 3, BIFF5: 3-4
{ ocVLookup, 102, 3, 4, V, { VV, RO, RO, VV }, 0, 0 }, // BIFF2-4: 3, BIFF5: 3-4
{ ocGetDiffDate360, 220, 2, 3, V, { VR }, 0, 0 }, // BIFF3-4: 2, BIFF5: 2-3
- { ocMacro, 255, 1, 30, R, { RO_E, RO }, EXC_FUNCFLAG_EXPORTONLY, 0 },
- { ocExternal, 255, 1, 30, R, { RO_E, RO }, EXC_FUNCFLAG_EXPORTONLY, 0 },
- { ocConcat, 336, 0, 30, V, { VR }, 0, 0 },
+ { ocMacro, 255, 1, MX, R, { RO_E, RO }, EXC_FUNCFLAG_EXPORTONLY, 0 },
+ { ocExternal, 255, 1, MX, R, { RO_E, RO }, EXC_FUNCFLAG_EXPORTONLY, 0 },
+ { ocConcat, 336, 0, MX, V, { VR }, 0, 0 },
{ ocPower, 337, 2, 2, V, { VR }, 0, 0 },
{ ocRad, 342, 1, 1, V, { VR }, 0, 0 },
{ ocDeg, 343, 1, 1, V, { VR }, 0, 0 },
- { ocSubTotal, 344, 2, 30, V, { VR, RO }, 0, 0 },
+ { ocSubTotal, 344, 2, MX, V, { VR, RO }, 0, 0 },
{ ocSumIf, 345, 2, 3, V, { RO, VR, RO }, 0, 0 },
{ ocCountIf, 346, 2, 2, V, { RO, VR }, 0, 0 },
{ ocCountEmptyCells, 347, 1, 1, V, { RO }, 0, 0 },
@@ -335,66 +341,90 @@ static const XclFunctionInfo saFuncTable_5[] =
{ ocRoman, 354, 1, 2, V, { VR }, 0, 0 }
};
-#define EXC_FUNCNAME_PREFIX "_xlfn."
-
-const sal_Char* const EXC_FUNCNAME_BAHTTEXT = EXC_FUNCNAME_PREFIX "BAHTTEXT";
-
/** Functions new in BIFF8. Unsupported functions: PHONETIC. */
static const XclFunctionInfo saFuncTable_8[] =
{
- { ocGetPivotData, 358, 2, 30, V, { RR, RR, VR }, 0, 0 },
+ { ocGetPivotData, 358, 2, MX, V, { RR, RR, VR }, 0, 0 },
{ ocHyperLink, 359, 1, 2, V, { VV, VO }, 0, 0 },
{ ocNoName, 360, 1, 1, V, { RO }, EXC_FUNCFLAG_IMPORTONLY, 0 }, // PHONETIC
- { ocAverageA, 361, 1, 30, V, { RX }, 0, 0 },
- { ocMaxA, 362, 1, 30, V, { RX }, 0, 0 },
- { ocMinA, 363, 1, 30, V, { RX }, 0, 0 },
- { ocStDevPA, 364, 1, 30, V, { RX }, 0, 0 },
- { ocVarPA, 365, 1, 30, V, { RX }, 0, 0 },
- { ocStDevA, 366, 1, 30, V, { RX }, 0, 0 },
- { ocVarA, 367, 1, 30, V, { RX }, 0, 0 },
- { ocBahtText, 368, 1, 1, V, { VR }, EXC_FUNCFLAG_IMPORTONLY, EXC_FUNCNAME_BAHTTEXT },
- { ocBahtText, 255, 2, 2, V, { RO_E, RO }, EXC_FUNCFLAG_EXPORTONLY, EXC_FUNCNAME_BAHTTEXT },
+ { ocAverageA, 361, 1, MX, V, { RX }, 0, 0 },
+ { ocMaxA, 362, 1, MX, V, { RX }, 0, 0 },
+ { ocMinA, 363, 1, MX, V, { RX }, 0, 0 },
+ { ocStDevPA, 364, 1, MX, V, { RX }, 0, 0 },
+ { ocVarPA, 365, 1, MX, V, { RX }, 0, 0 },
+ { ocStDevA, 366, 1, MX, V, { RX }, 0, 0 },
+ { ocVarA, 367, 1, MX, V, { RX }, 0, 0 },
+ { ocBahtText, 368, 1, 1, V, { VR }, EXC_FUNCFLAG_IMPORTONLY, EXC_FUNCNAME( "BAHTTEXT" ) },
+ { ocBahtText, 255, 2, 2, V, { RO_E, RO }, EXC_FUNCFLAG_EXPORTONLY, EXC_FUNCNAME( "BAHTTEXT" ) },
{ ocEuroConvert, 255, 4, 6, V, { RO_E, RO }, EXC_FUNCFLAG_EXPORTONLY, "EUROCONVERT" }
};
+#define EXC_FUNCENTRY_ODF( opcode, minparam, maxparam, flags, asciiname ) \
+ { opcode, NOID, minparam, maxparam, V, { VR }, EXC_FUNCFLAG_IMPORTONLY|(flags), EXC_FUNCNAME_ODF( asciiname ) }, \
+ { opcode, 255, (minparam)+1, (maxparam)+1, V, { RO_E, RO }, EXC_FUNCFLAG_EXPORTONLY|(flags), EXC_FUNCNAME_ODF( asciiname ) }
+
+/** Functions defined by OpenFormula, but not supported by Calc (ocNoName) or by Excel (defined op-code). */
+static const XclFunctionInfo saFuncTable_Odf[] =
+{
+ EXC_FUNCENTRY_ODF( ocArabic, 1, 1, 0, "ARABIC" ),
+ EXC_FUNCENTRY_ODF( ocB, 3, 4, 0, "B" ),
+ EXC_FUNCENTRY_ODF( ocBase, 2, 3, 0, "BASE" ),
+ EXC_FUNCENTRY_ODF( ocNoName, 2, 2, 0, "BITAND" ),
+ EXC_FUNCENTRY_ODF( ocNoName, 2, 2, 0, "BITLSHIFT" ),
+ EXC_FUNCENTRY_ODF( ocNoName, 2, 2, 0, "BITOR" ),
+ EXC_FUNCENTRY_ODF( ocNoName, 2, 2, 0, "BITRSHIFT" ),
+ EXC_FUNCENTRY_ODF( ocNoName, 2, 2, 0, "BITXOR" ),
+ EXC_FUNCENTRY_ODF( ocChiSqDist, 2, 3, 0, "CHISQDIST" ),
+ EXC_FUNCENTRY_ODF( ocChiSqInv, 2, 2, 0, "CHISQINV" ),
+ EXC_FUNCENTRY_ODF( ocKombin2, 2, 2, 0, "COMBINA" ),
+ EXC_FUNCENTRY_ODF( ocGetDiffDate, 2, 2, 0, "DAYS" ),
+ EXC_FUNCENTRY_ODF( ocDecimal, 2, 2, 0, "DECIMAL" ),
+ EXC_FUNCENTRY_ODF( ocFDist, 3, 4, 0, "FDIST" ),
+ EXC_FUNCENTRY_ODF( ocFInv, 3, 3, 0, "FINV" ),
+ EXC_FUNCENTRY_ODF( ocFormula, 1, 1, 0, "FORMULA" ),
+ EXC_FUNCENTRY_ODF( ocGamma, 1, 1, 0, "GAMMA" ),
+ EXC_FUNCENTRY_ODF( ocGauss, 1, 1, 0, "GAUSS" ),
+ EXC_FUNCENTRY_ODF( ocNoName, 2, 2, 0, "IFNA" ),
+ EXC_FUNCENTRY_ODF( ocIsFormula, 1, 1, 0, "ISFORMULA" ),
+ EXC_FUNCENTRY_ODF( ocWeek, 1, 2, 0, "ISOWEEKNUM" ),
+ EXC_FUNCENTRY_ODF( ocMatrixUnit, 1, 1, 0, "MUNIT" ),
+ EXC_FUNCENTRY_ODF( ocNumberValue, 2, 2, 0, "NUMBERVALUE" ),
+ EXC_FUNCENTRY_ODF( ocLaufz, 3, 3, 0, "PDURATION" ),
+ EXC_FUNCENTRY_ODF( ocVariationen2, 2, 2, 0, "PERMUTATIONA" ),
+ EXC_FUNCENTRY_ODF( ocPhi, 1, 1, 0, "PHI" ),
+ EXC_FUNCENTRY_ODF( ocZGZ, 3, 3, 0, "RRI" ),
+ EXC_FUNCENTRY_ODF( ocTable, 1, 1, 0, "SHEET" ),
+ EXC_FUNCENTRY_ODF( ocTables, 0, 1, 0, "SHEETS" ),
+ EXC_FUNCENTRY_ODF( ocNoName, 1, MX, 0, "SKEWP" ),
+ EXC_FUNCENTRY_ODF( ocUnichar, 1, 1, 0, "UNICHAR" ),
+ EXC_FUNCENTRY_ODF( ocUnicode, 1, 1, 0, "UNICODE" ),
+ EXC_FUNCENTRY_ODF( ocNoName, 1, MX, 0, "XOR" )
+};
+
+#undef EXC_FUNCENTRY_ODF
+
// ----------------------------------------------------------------------------
XclFunctionProvider::XclFunctionProvider( const XclRoot& rRoot )
{
- XclBiff eBiff = rRoot.GetBiff();
+ void (XclFunctionProvider::*pFillFunc)( const XclFunctionInfo*, const XclFunctionInfo* ) =
+ rRoot.IsImport() ? &XclFunctionProvider::FillXclFuncMap : &XclFunctionProvider::FillScFuncMap;
- if( rRoot.IsImport() )
- {
- /* Import: only read functions supported in the current BIFF version.
- Function tables from later BIFF versions may overwrite single
- functions from earlier tables. */
- if( eBiff >= EXC_BIFF2 )
- FillXclFuncMap( saFuncTable_2, STATIC_TABLE_END( saFuncTable_2 ) );
- if( eBiff >= EXC_BIFF3 )
- FillXclFuncMap( saFuncTable_3, STATIC_TABLE_END( saFuncTable_3 ) );
- if( eBiff >= EXC_BIFF4 )
- FillXclFuncMap( saFuncTable_4, STATIC_TABLE_END( saFuncTable_4 ) );
- if( eBiff >= EXC_BIFF5 )
- FillXclFuncMap( saFuncTable_5, STATIC_TABLE_END( saFuncTable_5 ) );
- if( eBiff >= EXC_BIFF8 )
- FillXclFuncMap( saFuncTable_8, STATIC_TABLE_END( saFuncTable_8 ) );
- }
- else
- {
- /* Export: only write functions supported in the current BIFF version.
- Function tables from later BIFF versions may overwrite single
- functions from earlier tables. */
- if( eBiff >= EXC_BIFF2 )
- FillScFuncMap( saFuncTable_2, STATIC_TABLE_END( saFuncTable_2 ) );
- if( eBiff >= EXC_BIFF3 )
- FillScFuncMap( saFuncTable_3, STATIC_TABLE_END( saFuncTable_3 ) );
- if( eBiff >= EXC_BIFF4 )
- FillScFuncMap( saFuncTable_4, STATIC_TABLE_END( saFuncTable_4 ) );
- if( eBiff >= EXC_BIFF5 )
- FillScFuncMap( saFuncTable_5, STATIC_TABLE_END( saFuncTable_5 ) );
- if( eBiff >= EXC_BIFF8 )
- FillScFuncMap( saFuncTable_8, STATIC_TABLE_END( saFuncTable_8 ) );
- }
+ /* Only read/write functions supported in the current BIFF version.
+ Function tables from later BIFF versions may overwrite single functions
+ from earlier tables. */
+ XclBiff eBiff = rRoot.GetBiff();
+ if( eBiff >= EXC_BIFF2 )
+ (this->*pFillFunc)( saFuncTable_2, STATIC_TABLE_END( saFuncTable_2 ) );
+ if( eBiff >= EXC_BIFF3 )
+ (this->*pFillFunc)( saFuncTable_3, STATIC_TABLE_END( saFuncTable_3 ) );
+ if( eBiff >= EXC_BIFF4 )
+ (this->*pFillFunc)( saFuncTable_4, STATIC_TABLE_END( saFuncTable_4 ) );
+ if( eBiff >= EXC_BIFF5 )
+ (this->*pFillFunc)( saFuncTable_5, STATIC_TABLE_END( saFuncTable_5 ) );
+ if( eBiff >= EXC_BIFF8 )
+ (this->*pFillFunc)( saFuncTable_8, STATIC_TABLE_END( saFuncTable_8 ) );
+ (this->*pFillFunc)( saFuncTable_Odf, STATIC_TABLE_END( saFuncTable_Odf ) );
}
const XclFunctionInfo* XclFunctionProvider::GetFuncInfoFromXclFunc( sal_uInt16 nXclFunc ) const
diff --git a/sc/source/filter/excel/xltools.cxx b/sc/source/filter/excel/xltools.cxx
index 926eb3e54fdc..90393ae6a787 100644
--- a/sc/source/filter/excel/xltools.cxx
+++ b/sc/source/filter/excel/xltools.cxx
@@ -113,7 +113,12 @@ const XclGuid XclTools::maGuidFileMoniker(
double XclTools::GetDoubleFromRK( sal_Int32 nRKValue )
{
- double fVal = 0.0;
+ union
+ {
+ double fVal;
+ sal_math_Double smD;
+ };
+ fVal = 0.0;
if( ::get_flag( nRKValue, EXC_RK_INTFLAG ) )
{
@@ -123,8 +128,7 @@ double XclTools::GetDoubleFromRK( sal_Int32 nRKValue )
}
else
{
- sal_math_Double* pDouble = reinterpret_cast< sal_math_Double* >( &fVal );
- pDouble->w32_parts.msw = nRKValue & EXC_RK_VALUEMASK;
+ smD.w32_parts.msw = nRKValue & EXC_RK_VALUEMASK;
}
if( ::get_flag( nRKValue, EXC_RK_100FLAG ) )
@@ -161,50 +165,6 @@ bool XclTools::GetRKFromDouble( sal_Int32& rnRKValue, double fValue )
return false;
}
-
-sal_uInt8 XclTools::GetXclErrorCode( USHORT nScError )
-{
- using namespace ScErrorCodes;
- switch( nScError )
- {
- case errIllegalArgument: return EXC_ERR_VALUE;
- case errIllegalFPOperation: return EXC_ERR_NUM; // maybe DIV/0 or NUM...
- case errDivisionByZero: return EXC_ERR_DIV0;
- case errIllegalParameter: return EXC_ERR_VALUE;
- case errPairExpected: return EXC_ERR_VALUE;
- case errOperatorExpected: return EXC_ERR_VALUE;
- case errVariableExpected: return EXC_ERR_VALUE;
- case errParameterExpected: return EXC_ERR_VALUE;
- case errNoValue: return EXC_ERR_VALUE;
- case errCircularReference: return EXC_ERR_VALUE;
- case errNoCode: return EXC_ERR_NULL;
- case errNoRef: return EXC_ERR_REF;
- case errNoName: return EXC_ERR_NAME;
- case errNoAddin: return EXC_ERR_NAME;
- case errNoMacro: return EXC_ERR_NAME;
- case NOTAVAILABLE: return EXC_ERR_NA;
- }
- return EXC_ERR_NA;
-}
-
-USHORT XclTools::GetScErrorCode( sal_uInt8 nXclError )
-{
- using namespace ScErrorCodes;
- switch( nXclError )
- {
- case EXC_ERR_NULL: return errNoCode;
- case EXC_ERR_DIV0: return errDivisionByZero;
- case EXC_ERR_VALUE: return errNoValue;
- case EXC_ERR_REF: return errNoRef;
- case EXC_ERR_NAME: return errNoName;
- case EXC_ERR_NUM: return errIllegalFPOperation;
- case EXC_ERR_NA: return NOTAVAILABLE;
- default: DBG_ERRORFILE( "XclTools::GetScErrorCode - unknown error code" );
- }
- return NOTAVAILABLE;
-}
-
-
sal_Int32 XclTools::GetScRotation( sal_uInt16 nXclRot, sal_Int32 nRotForStacked )
{
if( nXclRot == EXC_ROT_STACKED )
@@ -252,6 +212,59 @@ sal_uInt8 XclTools::GetXclOrientFromRot( sal_uInt16 nXclRot )
return EXC_ORIENT_NONE;
}
+sal_uInt8 XclTools::GetXclErrorCode( USHORT nScError )
+{
+ using namespace ScErrorCodes;
+ switch( nScError )
+ {
+ case errIllegalArgument: return EXC_ERR_VALUE;
+ case errIllegalFPOperation: return EXC_ERR_NUM; // maybe DIV/0 or NUM...
+ case errDivisionByZero: return EXC_ERR_DIV0;
+ case errIllegalParameter: return EXC_ERR_VALUE;
+ case errPairExpected: return EXC_ERR_VALUE;
+ case errOperatorExpected: return EXC_ERR_VALUE;
+ case errVariableExpected: return EXC_ERR_VALUE;
+ case errParameterExpected: return EXC_ERR_VALUE;
+ case errNoValue: return EXC_ERR_VALUE;
+ case errCircularReference: return EXC_ERR_VALUE;
+ case errNoCode: return EXC_ERR_NULL;
+ case errNoRef: return EXC_ERR_REF;
+ case errNoName: return EXC_ERR_NAME;
+ case errNoAddin: return EXC_ERR_NAME;
+ case errNoMacro: return EXC_ERR_NAME;
+ case NOTAVAILABLE: return EXC_ERR_NA;
+ }
+ return EXC_ERR_NA;
+}
+
+USHORT XclTools::GetScErrorCode( sal_uInt8 nXclError )
+{
+ using namespace ScErrorCodes;
+ switch( nXclError )
+ {
+ case EXC_ERR_NULL: return errNoCode;
+ case EXC_ERR_DIV0: return errDivisionByZero;
+ case EXC_ERR_VALUE: return errNoValue;
+ case EXC_ERR_REF: return errNoRef;
+ case EXC_ERR_NAME: return errNoName;
+ case EXC_ERR_NUM: return errIllegalFPOperation;
+ case EXC_ERR_NA: return NOTAVAILABLE;
+ default: DBG_ERRORFILE( "XclTools::GetScErrorCode - unknown error code" );
+ }
+ return NOTAVAILABLE;
+}
+
+double XclTools::ErrorToDouble( sal_uInt8 nXclError )
+{
+ union
+ {
+ double fVal;
+ sal_math_Double smD;
+ };
+ ::rtl::math::setNan( &fVal );
+ smD.nan_parts.fraction_lo = GetScErrorCode( nXclError );
+ return fVal;
+}
XclBoolError XclTools::ErrorToEnum( double& rfDblValue, sal_uInt8 bErrOrBool, sal_uInt8 nValue )
{
@@ -281,7 +294,6 @@ XclBoolError XclTools::ErrorToEnum( double& rfDblValue, sal_uInt8 bErrOrBool, sa
return eType;
}
-
sal_uInt16 XclTools::GetTwipsFromInch( double fInches )
{
return static_cast< sal_uInt16 >(
diff --git a/sc/source/filter/html/htmlimp.cxx b/sc/source/filter/html/htmlimp.cxx
index ad3a5e041151..1c0b9fc8ec33 100644
--- a/sc/source/filter/html/htmlimp.cxx
+++ b/sc/source/filter/html/htmlimp.cxx
@@ -60,13 +60,14 @@
//------------------------------------------------------------------------
FltError ScFormatFilterPluginImpl::ScImportHTML( SvStream &rStream, const String& rBaseURL, ScDocument *pDoc,
- ScRange& rRange, double nOutputFactor, BOOL bCalcWidthHeight )
+ ScRange& rRange, double nOutputFactor, BOOL bCalcWidthHeight, SvNumberFormatter* pFormatter,
+ bool bConvertDate )
{
ScHTMLImport aImp( pDoc, rBaseURL, rRange, bCalcWidthHeight );
FltError nErr = (FltError) aImp.Read( rStream, rBaseURL );
ScRange aR = aImp.GetRange();
rRange.aEnd = aR.aEnd;
- aImp.WriteToDocument( TRUE, nOutputFactor );
+ aImp.WriteToDocument( TRUE, nOutputFactor, pFormatter, bConvertDate );
return nErr;
}
@@ -134,9 +135,10 @@ void ScHTMLImport::InsertRangeName( ScDocument* pDoc, const String& rName, const
delete pRangeData;
}
-void ScHTMLImport::WriteToDocument( BOOL bSizeColsRows, double nOutputFactor )
+void ScHTMLImport::WriteToDocument(
+ BOOL bSizeColsRows, double nOutputFactor, SvNumberFormatter* pFormatter, bool bConvertDate )
{
- ScEEImport::WriteToDocument( bSizeColsRows, nOutputFactor );
+ ScEEImport::WriteToDocument( bSizeColsRows, nOutputFactor, pFormatter, bConvertDate );
const ScHTMLParser* pParser = GetParser();
const ScHTMLTable* pGlobTable = pParser->GetGlobalTable();
diff --git a/sc/source/filter/inc/eeimport.hxx b/sc/source/filter/inc/eeimport.hxx
index 59225a5a7138..634dfd1b4a33 100644
--- a/sc/source/filter/inc/eeimport.hxx
+++ b/sc/source/filter/inc/eeimport.hxx
@@ -60,7 +60,9 @@ public:
virtual ULONG Read( SvStream& rStream, const String& rBaseURL );
virtual ScRange GetRange() { return maRange; }
virtual void WriteToDocument( BOOL bSizeColsRows = FALSE,
- double nOutputFactor = 1.0 );
+ double nOutputFactor = 1.0,
+ SvNumberFormatter* pFormatter = NULL,
+ bool bConvertDate = true );
};
#endif
diff --git a/sc/source/filter/inc/ftools.hxx b/sc/source/filter/inc/ftools.hxx
index bdb17178d75c..c17aaa70445c 100644
--- a/sc/source/filter/inc/ftools.hxx
+++ b/sc/source/filter/inc/ftools.hxx
@@ -517,7 +517,9 @@ class ScFormatFilterPluginImpl : public ScFormatFilterPlugin {
virtual FltError ScImportDif( SvStream&, ScDocument*, const ScAddress& rInsPos,
const CharSet eSrc = RTL_TEXTENCODING_DONTKNOW, UINT32 nDifOption = SC_DIFOPT_EXCEL );
virtual FltError ScImportRTF( SvStream&, const String& rBaseURL, ScDocument*, ScRange& rRange );
- virtual FltError ScImportHTML( SvStream&, const String& rBaseURL, ScDocument*, ScRange& rRange, double nOutputFactor = 1.0, BOOL bCalcWidthHeight = TRUE );
+ virtual FltError ScImportHTML( SvStream&, const String& rBaseURL, ScDocument*, ScRange& rRange,
+ double nOutputFactor = 1.0, BOOL bCalcWidthHeight = TRUE,
+ SvNumberFormatter* pFormatter = NULL, bool bConvertDate = true );
virtual ScEEAbsImport *CreateRTFImport( ScDocument* pDoc, const ScRange& rRange );
virtual ScEEAbsImport *CreateHTMLImport( ScDocument* pDocP, const String& rBaseURL, const ScRange& rRange, BOOL bCalcWidthHeight );
diff --git a/sc/source/filter/inc/htmlimp.hxx b/sc/source/filter/inc/htmlimp.hxx
index 8a1d1c41b4fd..0376b3cd72f5 100644
--- a/sc/source/filter/inc/htmlimp.hxx
+++ b/sc/source/filter/inc/htmlimp.hxx
@@ -42,7 +42,8 @@ public:
virtual ~ScHTMLImport();
const ScHTMLParser* GetParser() const { return (ScHTMLParser*)mpParser; }
- virtual void WriteToDocument( BOOL bSizeColsRows = FALSE, double nOutputFactor = 1.0 );
+ virtual void WriteToDocument( BOOL bSizeColsRows = FALSE, double nOutputFactor = 1.0,
+ SvNumberFormatter* pFormatter = NULL, bool bConvertDate = true );
static String GetHTMLRangeNameList( ScDocument* pDoc, const String& rOrigName );
};
diff --git a/sc/source/filter/inc/root.hxx b/sc/source/filter/inc/root.hxx
index fcac4da4be62..facc8b1b2fa0 100644
--- a/sc/source/filter/inc/root.hxx
+++ b/sc/source/filter/inc/root.hxx
@@ -52,9 +52,6 @@ class _ScRangeListTabs;
class XclExpChTrTabId;
class XclExpUserBViewList;
-class XclObjList;
-class XclEscher;
-
class XclImpRoot;
class XclExpRoot;
@@ -78,10 +75,6 @@ struct RootData // -> Inkarnation jeweils im ImportExcel-Objekt!
XclExpChTrTabId* pTabId; // pointer to rec list, do not destroy
XclExpUserBViewList* pUserBViewList; // pointer to rec list, do not destroy
- // Biff8
- XclObjList* pObjRecs;
- XclEscher* pEscher;
-
XclImpRoot* pIR;
XclExpRoot* pER;
diff --git a/sc/source/filter/inc/tokstack.hxx b/sc/source/filter/inc/tokstack.hxx
index 80c94c729270..06a37639be89 100644
--- a/sc/source/filter/inc/tokstack.hxx
+++ b/sc/source/filter/inc/tokstack.hxx
@@ -207,7 +207,7 @@ class TokenPool
const TokenId Store( const DefTokenId eId, const String& rName );
// 4 externals (e.g. AddIns, Makros...)
const TokenId StoreNlf( const ScSingleRefData& rTr );
- const TokenId StoreMatrix( SCSIZE nC, SCSIZE nR );
+ const TokenId StoreMatrix();
const TokenId StoreExtName( sal_uInt16 nFileId, const String& rName );
const TokenId StoreExtRef( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef );
const TokenId StoreExtRef( sal_uInt16 nFileId, const String& rTabName, const ScComplexRefData& rRef );
diff --git a/sc/source/filter/inc/xcl97esc.hxx b/sc/source/filter/inc/xcl97esc.hxx
index 2aa7c824af99..fde03337cc0f 100644
--- a/sc/source/filter/inc/xcl97esc.hxx
+++ b/sc/source/filter/inc/xcl97esc.hxx
@@ -28,9 +28,10 @@
#ifndef SC_XCL97ESC_HXX
#define SC_XCL97ESC_HXX
-#include <filter/msfilter/escherex.hxx>
+#include <memory>
#include <tools/table.hxx>
#include <tools/stack.hxx>
+#include <filter/msfilter/escherex.hxx>
#include "xlescher.hxx"
#include "xeroot.hxx"
@@ -39,10 +40,28 @@
namespace utl { class TempFile; }
-// --- class XclEscherEx ---------------------------------------------
+// ============================================================================
class SvStream;
+
+class XclEscherExGlobal : public EscherExGlobal, protected XclExpRoot
+{
+public:
+ explicit XclEscherExGlobal( const XclExpRoot& rRoot );
+
+private:
+ /** Overloaded to create a new temporary file and return its stream. */
+ virtual SvStream* ImplQueryPictureStream();
+
+private:
+ ::std::auto_ptr< ::utl::TempFile > mxPicTempFile;
+ ::std::auto_ptr< SvStream > mxPicStrm;
+};
+
+// ============================================================================
+
class XclObj;
+class XclExpDffAnchorBase;
class XclEscherHostAppData;
class XclEscherClientData;
class XclEscherClientTextbox;
@@ -54,56 +73,56 @@ class XclExpTbxControlObj;
class XclEscherEx : public EscherEx, protected XclExpRoot
{
-private:
- List aOffsetMap;
- Stack aStack;
- utl::TempFile* pPicTempFile;
- SvStream* pPicStrm;
- XclObj* pCurrXclObj;
- XclEscherHostAppData* pCurrAppData;
- XclEscherClientData* pTheClientData; // always the same
- XclEscherClientTextbox* pAdditionalText;
- USHORT nAdditionalText;
-
- void DeleteCurrAppData();
-
public:
- XclEscherEx( const XclExpRoot& rRoot, SvStream& rStrm, UINT32 nDrawings );
- virtual ~XclEscherEx();
-
- /// maintains OffsetMap
- virtual void InsertAtCurrentPos( UINT32 nBytes, BOOL bCont = FALSE );
-
- virtual SvStream* QueryPicStream();
- virtual EscherExHostAppData* StartShape( const com::sun::star::uno::Reference<
- com::sun::star::drawing::XShape>& rShape );
+ explicit XclEscherEx(
+ const XclExpRoot& rRoot,
+ XclExpObjectManager& rObjMgr,
+ SvStream& rStrm,
+ const XclEscherEx* pParent = 0 );
+ virtual ~XclEscherEx();
+
+ /** Called by MSODRAWING record constructors to initialize the DFF stream
+ fragment they will own. returns the DFF fragment identifier. */
+ sal_uInt32 InitNextDffFragment();
+ /** Called after some data has been written to the DFF stream, to update
+ the end position of the DFF fragment owned by an MSODRAWING record. */
+ void UpdateDffFragmentEnd();
+
+ /** Returns the position of the specified DFF stream fragment. */
+ sal_uInt32 GetDffFragmentPos( sal_uInt32 nFragmentKey );
+ /** Returns the size of the specified DFF stream fragment. */
+ sal_uInt32 GetDffFragmentSize( sal_uInt32 nFragmentKey );
+ /** Returns true, if there is more data left in the DFF stream than owned
+ by the last MSODRAWING record. */
+ bool HasPendingDffData();
+
+ /** Creates a new DFF client anchor object and calculates the anchor
+ position of the passed object. Caller takes ownership! */
+ XclExpDffAnchorBase* CreateDffAnchor( const SdrObject& rSdrObj ) const;
+
+ virtual EscherExHostAppData* StartShape(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape>& rxShape,
+ const Rectangle* pChildAnchor );
virtual void EndShape( UINT16 nShapeType, UINT32 nShapeID );
virtual EscherExHostAppData* EnterAdditionalTextGroup();
- /// appends stream offset to list and returns position in list
- ULONG AddCurrentOffsetToMap();
- /// replaces position in list with current stream offset
- void ReplaceCurrentOffsetInMap( ULONG nPos );
- /// returns stream offset for position in list
- inline ULONG GetOffsetFromMap( ULONG nPos ) const;
- /// last position in list (count-1)
- inline ULONG GetLastOffsetMapPos() const;
-
/// Flush and merge PicStream into EscherStream
void EndDocument();
#if EXC_EXP_OCX_CTRL
/** Creates an OCX form control OBJ record from the passed form control.
@descr Writes the form control data to the 'Ctls' stream. */
- XclExpOcxControlObj* CreateCtrlObj( ::com::sun::star::uno::Reference<
- ::com::sun::star::drawing::XShape > xShape );
+ XclExpOcxControlObj* CreateCtrlObj(
+ ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape,
+ const Rectangle* pChildAnchor );
private:
SotStorageStreamRef mxCtlsStrm; /// The 'Ctls' stream.
#else
/** Creates a TBX form control OBJ record from the passed form control. */
- XclExpTbxControlObj* CreateCtrlObj( ::com::sun::star::uno::Reference<
- ::com::sun::star::drawing::XShape > xShape );
+ XclExpTbxControlObj* CreateCtrlObj(
+ ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape,
+ const Rectangle* pChildAnchor );
private:
/** Tries to get the name of a Basic macro from a control. */
@@ -112,43 +131,21 @@ private:
::com::sun::star::uno::Reference<
::com::sun::star::awt::XControlModel > xCtrlModel );
#endif
-};
-
-
-inline ULONG XclEscherEx::GetOffsetFromMap( ULONG nPos ) const
-{
- return (ULONG) aOffsetMap.GetObject( nPos );
-}
-
-
-inline ULONG XclEscherEx::GetLastOffsetMapPos() const
-{
- return aOffsetMap.Count() - 1;
-}
-
-// --- class XclEscher -----------------------------------------------
+ void DeleteCurrAppData();
-struct RootData;
-
-class XclEscher : protected XclExpRoot
-{
private:
- utl::TempFile* pTempFile;
- SvStream* pStrm;
- XclEscherEx* pEx;
-
-public:
- XclEscher( const XclExpRoot& rRoot, UINT32 nDrawings );
- ~XclEscher();
-
- inline XclEscherEx* GetEx() const { return pEx; }
- inline SvStream& GetStrm() const { return *pStrm; }
-
- void AddSdrPage();
+ XclExpObjectManager& mrObjMgr;
+ Stack aStack;
+ XclObj* pCurrXclObj;
+ XclEscherHostAppData* pCurrAppData;
+ XclEscherClientData* pTheClientData; // always the same
+ XclEscherClientTextbox* pAdditionalText;
+ USHORT nAdditionalText;
+ sal_uInt32 mnNextKey;
+ bool mbIsRootDff;
};
-
// --- class XclEscherHostAppData ------------------------------------
class XclEscherHostAppData : public EscherExHostAppData
@@ -164,55 +161,6 @@ public:
};
-// DFF client anchor ==========================================================
-
-class Rectangle;
-class SdrObject;
-class ScAddress;
-
-/** Represents the position (anchor) of an object in a Calc document. */
-class XclExpDffAnchor : public EscherExClientAnchor_Base, protected XclExpRoot
-{
-public:
- /** Constructs a dummy client anchor. */
- explicit XclExpDffAnchor( const XclExpRoot& rRoot, sal_uInt16 nFlags = 0 );
- /** Constructs a client anchor directly from an SdrObject. */
- explicit XclExpDffAnchor( const XclExpRoot& rRoot, const SdrObject& rSdrObj );
-
- /** Sets the flags according to the passed SdrObject. */
- void SetFlags( const SdrObject& rSdrObj );
-
- /** Called from SVX Escher exporter.
- @param rRect The object anchor rectangle to be exported (in twips). */
- virtual void WriteData( EscherEx& rEx, const Rectangle& rRect );
-
- /** Writes the anchor structure with the current anchor position. */
- void WriteData( EscherEx& rEx ) const;
-
-protected: // for access in derived classes
- XclObjAnchor maAnchor; /// The client anchor data.
- sal_uInt16 mnFlags; /// Flags for DFF stream export.
-};
-
-// ----------------------------------------------------------------------------
-
-/** Represents the position (anchor) of a note object. */
-class XclExpDffNoteAnchor : public XclExpDffAnchor
-{
-public:
- explicit XclExpDffNoteAnchor( const XclExpRoot& rRoot, const Rectangle& rRect );
-};
-
-
-// ----------------------------------------------------------------------------
-
-/** Represents the position (anchor) of a cell dropdown object. */
-class XclExpDffDropDownAnchor : public XclExpDffAnchor
-{
-public:
- explicit XclExpDffDropDownAnchor( const XclExpRoot& rRoot, const ScAddress& rScPos );
-};
-
// ============================================================================
@@ -221,8 +169,8 @@ public:
class XclEscherClientData : public EscherExClientRecord_Base
{
public:
- XclEscherClientData() {}
- virtual void WriteData( EscherEx& rEx ) const;
+ XclEscherClientData() {}
+ virtual void WriteData( EscherEx& rEx ) const;
};
@@ -233,20 +181,19 @@ class SdrTextObj;
class XclEscherClientTextbox : public EscherExClientRecord_Base, protected XclExpRoot
{
private:
- const SdrTextObj& rTextObj;
- XclObj* pXclObj;
+ const SdrTextObj& rTextObj;
+ XclObj* pXclObj;
public:
- XclEscherClientTextbox(
- const XclExpRoot& rRoot,
- const SdrTextObj& rObj,
- XclObj* pObj
- );
+ XclEscherClientTextbox(
+ const XclExpRoot& rRoot,
+ const SdrTextObj& rObj,
+ XclObj* pObj );
//! ONLY for the AdditionalText mimic
- inline void SetXclObj( XclObj* p ) { pXclObj = p; }
+ inline void SetXclObj( XclObj* p ) { pXclObj = p; }
- virtual void WriteData( EscherEx& rEx ) const;
+ virtual void WriteData( EscherEx& rEx ) const;
};
diff --git a/sc/source/filter/inc/xcl97rec.hxx b/sc/source/filter/inc/xcl97rec.hxx
index 2c6ae2f9ab0c..7a2a33795520 100644
--- a/sc/source/filter/inc/xcl97rec.hxx
+++ b/sc/source/filter/inc/xcl97rec.hxx
@@ -32,88 +32,35 @@
#include "xcl97esc.hxx"
#include "xlstyle.hxx"
-#include <vector>
-
-// --- class XclMsodrawing_Base --------------------------------------
-
-class XclMsodrawing_Base
-{
-protected:
- XclEscher* pEscher;
- sal_Size nStartPos; // position in OffsetMap
- sal_Size nStopPos; // position in OffsetMap
-
-public:
- XclMsodrawing_Base( XclEscher& rEscher, sal_Size nInitialSize = 0 );
- virtual ~XclMsodrawing_Base();
-
- inline XclEscher* GetEscher() const { return pEscher; }
- inline XclEscherEx* GetEscherEx() const { return pEscher->GetEx(); }
- void UpdateStopPos();
- sal_Size GetDataLen() const;
-};
-
-
-// --- class XclMsodrawinggroup --------------------------------------
-
-class XclMsodrawinggroup : public XclMsodrawing_Base, public XclExpRecord
-{
-private:
-
- virtual void WriteBody( XclExpStream& rStrm );
-
-public:
- XclMsodrawinggroup( RootData& rRoot,
- UINT16 nEscherType = 0 );
- virtual ~XclMsodrawinggroup();
-};
-
-
-// --- class XclMsodrawing -------------------------------------------
-
-class XclMsodrawing : public XclMsodrawing_Base, public XclExpRecord
-{
-private:
-
- virtual void WriteBody( XclExpStream& rStrm );
-
-public:
- XclMsodrawing(
- const XclExpRoot& rRoot,
- UINT16 nEscherType = 0,
- sal_Size nInitialSize = 0 );
- virtual ~XclMsodrawing();
-};
-
-
-// --- class XclObjList ----------------------------------------------
+// ============================================================================
class XclObj;
-class XclMsodrawing;
+class XclExpMsoDrawing;
-class XclObjList : public List, public ExcEmptyRec, protected XclExpRoot
+class XclExpObjList : public List, public ExcEmptyRec, protected XclExpRoot
{
-private:
- XclMsodrawing* pMsodrawingPerSheet;
- XclMsodrawing* pSolverContainer;
-
public:
- XclObjList( const XclExpRoot& rRoot );
- virtual ~XclObjList();
+ explicit XclExpObjList( const XclExpRoot& rRoot, XclEscherEx& rEscherEx );
+ virtual ~XclExpObjList();
- XclObj* First() { return (XclObj*) List::First(); }
- XclObj* Next() { return (XclObj*) List::Next(); }
+ XclObj* First() { return (XclObj*) List::First(); }
+ XclObj* Next() { return (XclObj*) List::Next(); }
- /// return: 1-based ObjId
- ///! count>=0xFFFF: Obj will be deleted, return 0
- UINT16 Add( XclObj* );
+ /// return: 1-based ObjId
+ ///! count>=0xFFFF: Obj will be deleted, return 0
+ UINT16 Add( XclObj* );
- inline XclMsodrawing* GetMsodrawingPerSheet() { return pMsodrawingPerSheet; }
+ inline XclExpMsoDrawing* GetMsodrawingPerSheet() { return pMsodrawingPerSheet; }
/// close groups and DgContainer opened in ctor
- void EndSheet();
+ void EndSheet();
- virtual void Save( XclExpStream& rStrm );
+ virtual void Save( XclExpStream& rStrm );
+
+private:
+ XclEscherEx& mrEscherEx;
+ XclExpMsoDrawing* pMsodrawingPerSheet;
+ XclExpMsoDrawing* pSolverContainer;
};
@@ -125,8 +72,9 @@ class SdrTextObj;
class XclObj : public XclExpRecord
{
protected:
- XclMsodrawing* pMsodrawing;
- XclMsodrawing* pClientTextbox;
+ XclEscherEx& mrEscherEx;
+ XclExpMsoDrawing* pMsodrawing;
+ XclExpMsoDrawing* pClientTextbox;
XclTxo* pTxo;
sal_uInt16 mnObjType;
UINT16 nObjId;
@@ -137,7 +85,9 @@ protected:
/** @param bOwnEscher If set to true, this object will create its escher data.
See SetOwnEscher() for details. */
- explicit XclObj( const XclExpRoot& rRoot, sal_uInt16 nObjType, bool bOwnEscher = false );
+ explicit XclObj( XclExpObjectManager& rObjMgr, sal_uInt16 nObjType, bool bOwnEscher = false );
+
+ void ImplWriteAnchor( const XclExpRoot& rRoot, const SdrObject* pSdrObj, const Rectangle* pChildAnchor );
// overwritten for writing MSODRAWING record
virtual void WriteBody( XclExpStream& rStrm );
@@ -179,27 +129,15 @@ public:
//! actually writes ESCHER_ClientTextbox
void SetText( const XclExpRoot& rRoot, const SdrTextObj& rObj );
- inline void UpdateStopPos();
-
virtual void Save( XclExpStream& rStrm );
};
-
-inline void XclObj::UpdateStopPos()
-{
- if ( pClientTextbox )
- pClientTextbox->UpdateStopPos();
- else
- pMsodrawing->UpdateStopPos();
-}
-
-
// --- class XclObjComment -------------------------------------------
class XclObjComment : public XclObj
{
public:
- XclObjComment( const XclExpRoot& rRoot,
+ XclObjComment( XclExpObjectManager& rObjMgr,
const Rectangle& rRect, const EditTextObject& rEditObj, SdrObject* pCaption, bool bVisible );
virtual ~XclObjComment();
@@ -224,7 +162,7 @@ private:
protected:
public:
- XclObjDropDown( const XclExpRoot& rRoot, const ScAddress& rPos, BOOL bFilt );
+ XclObjDropDown( XclExpObjectManager& rObjMgr, const ScAddress& rPos, BOOL bFilt );
virtual ~XclObjDropDown();
};
@@ -271,7 +209,7 @@ private:
virtual void WriteSubRecs( XclExpStream& rStrm );
public:
- XclObjOle( const XclExpRoot& rRoot, const SdrObject& rObj );
+ XclObjOle( XclExpObjectManager& rObjMgr, const SdrObject& rObj );
virtual ~XclObjOle();
virtual void Save( XclExpStream& rStrm );
@@ -286,7 +224,7 @@ private:
virtual void WriteSubRecs( XclExpStream& rStrm );
public:
- XclObjAny( const XclExpRoot& rRoot );
+ XclObjAny( XclExpObjectManager& rObjMgr );
virtual ~XclObjAny();
virtual void Save( XclExpStream& rStrm );
diff --git a/sc/source/filter/inc/xechart.hxx b/sc/source/filter/inc/xechart.hxx
index eb6026a82e9a..2cf976b11efe 100644
--- a/sc/source/filter/inc/xechart.hxx
+++ b/sc/source/filter/inc/xechart.hxx
@@ -28,6 +28,7 @@
#ifndef SC_XECHART_HXX
#define SC_XECHART_HXX
+#include <tools/gen.hxx>
#include "xerecord.hxx"
#include "xlchart.hxx"
#include "xlformula.hxx"
@@ -1194,6 +1195,27 @@ private:
// ----------------------------------------------------------------------------
+/** Represents the group of DFF and OBJ records containing all drawing shapes
+ embedded in the chart object.
+ */
+class XclExpChartDrawing : public XclExpRecordBase, protected XclExpRoot
+{
+public:
+ explicit XclExpChartDrawing(
+ const XclExpRoot& rRoot,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxModel,
+ const Size& rChartSize );
+ virtual ~XclExpChartDrawing();
+
+ virtual void Save( XclExpStream& rStrm );
+
+private:
+ ScfRef< XclExpObjectManager > mxObjMgr;
+ ScfRef< XclExpRecordBase > mxObjRecs;
+};
+
+// ----------------------------------------------------------------------------
+
/** Represents the entire chart substream (all records in BOF/EOF block). */
class XclExpChart : public XclExpSubStream, protected XclExpRoot
{
diff --git a/sc/source/filter/inc/xeescher.hxx b/sc/source/filter/inc/xeescher.hxx
index 6448ccb4853e..d227db184f1a 100644
--- a/sc/source/filter/inc/xeescher.hxx
+++ b/sc/source/filter/inc/xeescher.hxx
@@ -29,6 +29,7 @@
#define SC_XEESCHER_HXX
#include <vcl/graph.hxx>
+#include <filter/msfilter/escherex.hxx>
#include "xcl97rec.hxx"
#include "xlescher.hxx"
@@ -36,6 +37,127 @@ namespace com { namespace sun { namespace star {
namespace script { struct ScriptEventDescriptor; }
} } }
+// DFF client anchor ==========================================================
+
+/** Base class for DFF client anchor atoms used in spreadsheets. */
+class XclExpDffAnchorBase : public EscherExClientAnchor_Base, protected XclExpRoot
+{
+public:
+ /** Constructs a dummy client anchor. */
+ explicit XclExpDffAnchorBase( const XclExpRoot& rRoot, sal_uInt16 nFlags = 0 );
+
+ /** Sets the flags according to the passed SdrObject. */
+ void SetFlags( const SdrObject& rSdrObj );
+ /** Sets the anchor position and flags according to the passed SdrObject. */
+ void SetSdrObject( const SdrObject& rSdrObj );
+
+ /** Writes the DFF client anchor structure with the current anchor position. */
+ void WriteDffData( EscherEx& rEscherEx ) const;
+
+ /** Called from SVX DFF converter.
+ @param rRect The object anchor rectangle to be exported (in twips). */
+ virtual void WriteData( EscherEx& rEscherEx, const Rectangle& rRect );
+
+private:
+ virtual void ImplSetFlags( const SdrObject& rSdrObj );
+ virtual void ImplCalcAnchorRect( const Rectangle& rRect, MapUnit eMapUnit );
+
+protected: // for access in derived classes
+ XclObjAnchor maAnchor; /// The client anchor data.
+ sal_uInt16 mnFlags; /// Flags for DFF stream export.
+};
+
+// ----------------------------------------------------------------------------
+
+/** Represents the position (anchor) of an object in a Calc sheet. */
+class XclExpDffSheetAnchor : public XclExpDffAnchorBase
+{
+public:
+ explicit XclExpDffSheetAnchor( const XclExpRoot& rRoot );
+
+private:
+ virtual void ImplSetFlags( const SdrObject& rSdrObj );
+ virtual void ImplCalcAnchorRect( const Rectangle& rRect, MapUnit eMapUnit );
+
+private:
+ SCTAB mnScTab; /// Calc sheet index.
+};
+
+// ----------------------------------------------------------------------------
+
+/** Represents the position (anchor) of a shape in an embedded draw page. */
+class XclExpDffEmbeddedAnchor : public XclExpDffAnchorBase
+{
+public:
+ explicit XclExpDffEmbeddedAnchor( const XclExpRoot& rRoot,
+ const Size& rPageSize, sal_Int32 nScaleX, sal_Int32 nScaleY );
+
+private:
+ virtual void ImplSetFlags( const SdrObject& rSdrObj );
+ virtual void ImplCalcAnchorRect( const Rectangle& rRect, MapUnit eMapUnit );
+
+private:
+ Size maPageSize;
+ sal_Int32 mnScaleX;
+ sal_Int32 mnScaleY;
+};
+
+// ----------------------------------------------------------------------------
+
+/** Represents the position (anchor) of a note object. */
+class XclExpDffNoteAnchor : public XclExpDffAnchorBase
+{
+public:
+ explicit XclExpDffNoteAnchor( const XclExpRoot& rRoot, const Rectangle& rRect );
+};
+
+// ----------------------------------------------------------------------------
+
+/** Represents the position (anchor) of a cell dropdown object. */
+class XclExpDffDropDownAnchor : public XclExpDffAnchorBase
+{
+public:
+ explicit XclExpDffDropDownAnchor( const XclExpRoot& rRoot, const ScAddress& rScPos );
+};
+
+// MSODRAWING* records ========================================================
+
+/** Base class for records holding DFF stream fragments. */
+class XclExpMsoDrawingBase : public XclExpRecord
+{
+public:
+ explicit XclExpMsoDrawingBase( XclEscherEx& rEscherEx, sal_uInt16 nRecId );
+
+private:
+ virtual void WriteBody( XclExpStream& rStrm );
+
+protected:
+ XclEscherEx& mrEscherEx; /// Reference to the DFF converter containing the DFF stream.
+ sal_uInt32 mnFragmentKey; /// The key of the DFF stream fragment to be written by this record.
+};
+
+// ----------------------------------------------------------------------------
+
+/** The MSODRAWINGGROUP record contains the DGGCONTAINER with global DFF data
+ such as the picture container.
+ */
+class XclExpMsoDrawingGroup : public XclExpMsoDrawingBase
+{
+public:
+ explicit XclExpMsoDrawingGroup( XclEscherEx& rEscherEx );
+};
+
+// ----------------------------------------------------------------------------
+
+/** One or more MSODRAWING records contain the DFF stream data for a drawing
+ shape.
+ */
+class XclExpMsoDrawing : public XclExpMsoDrawingBase
+{
+public:
+ explicit XclExpMsoDrawing( XclEscherEx& rEscherEx );
+};
+
// ============================================================================
/** Provides export of bitmap data to an IMGDATA record. */
@@ -94,8 +216,9 @@ class XclExpOcxControlObj : public XclObj, public XclExpControlHelper
{
public:
explicit XclExpOcxControlObj(
- const XclExpRoot& rRoot,
+ XclExpObjectManager& rObjMgr,
::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape,
+ const Rectangle* pChildAnchor,
const String& rClassName,
sal_uInt32 nStrmStart, sal_uInt32 nStrmSize );
@@ -115,8 +238,9 @@ class XclExpTbxControlObj : public XclObj, public XclExpControlHelper
{
public:
explicit XclExpTbxControlObj(
- const XclExpRoot& rRoot,
- ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
+ XclExpObjectManager& rObjMgr,
+ ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape,
+ const Rectangle* pChildAnchor );
/** Sets the name of a macro attached to this control.
@return true = The passed event descriptor was valid, macro name has been found. */
@@ -161,10 +285,10 @@ class XclExpChart;
class XclExpChartObj : public XclObj, protected XclExpRoot
{
public:
- typedef ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > XShapeRef;
-
-public:
- explicit XclExpChartObj( const XclExpRoot& rRoot, XShapeRef xShape );
+ explicit XclExpChartObj(
+ XclExpObjectManager& rObjMgr,
+ ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape,
+ const Rectangle* pChildAnchor );
virtual ~XclExpChartObj();
/** Writes the OBJ record and the entire chart substream. */
@@ -237,6 +361,74 @@ private:
XclExpNoteList& mrNotes;
};
+// object manager =============================================================
+
+class XclExpObjectManager : public XclExpRoot
+{
+public:
+ explicit XclExpObjectManager( const XclExpRoot& rRoot );
+ virtual ~XclExpObjectManager();
+
+ /** Creates a new DFF client anchor object. Caller takes ownership! May be
+ overwritten in derived classes. */
+ virtual XclExpDffAnchorBase* CreateDffAnchor() const;
+
+ /** Creates and returns the MSODRAWINGGROUP record containing global DFF
+ data in the DGGCONTAINER. */
+ ScfRef< XclExpRecordBase > CreateDrawingGroup();
+
+ /** Initializes the object manager for a new sheet. */
+ void StartSheet();
+
+ /** Processes a drawing page and returns the record block containing all
+ related records (MSODRAWING, OBJ, TXO, charts, etc.). */
+ ScfRef< XclExpRecordBase > ProcessDrawing( SdrPage* pSdrPage );
+ /** Processes a collection of UNO shapes and returns the record block
+ containing all related records (MSODRAWING, OBJ, TXO, charts, etc.). */
+ ScfRef< XclExpRecordBase > ProcessDrawing( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes );
+
+ /** Finalizes the object manager after conversion of all sheets. */
+ void EndDocument();
+
+ inline XclEscherEx& GetEscherEx() { return *mxEscherEx; }
+ XclExpMsoDrawing* GetMsodrawingPerSheet();
+ bool HasObj() const;
+ sal_uInt16 AddObj( XclObj* pObjRec );
+ XclObj* RemoveLastObj();
+
+protected:
+ explicit XclExpObjectManager( const XclExpObjectManager& rParent );
+
+private:
+ void InitStream( bool bTempFile );
+
+private:
+ ScfRef< ::utl::TempFile > mxTempFile;
+ ScfRef< SvStream > mxDffStrm;
+ ScfRef< XclEscherEx > mxEscherEx;
+ ScfRef< XclExpObjList > mxObjList;
+};
+
+// ----------------------------------------------------------------------------
+
+class XclExpEmbeddedObjectManager : public XclExpObjectManager
+{
+public:
+ explicit XclExpEmbeddedObjectManager(
+ const XclExpObjectManager& rParent,
+ const Size& rPageSize,
+ sal_Int32 nScaleX, sal_Int32 nScaleY );
+
+ /** Creates a new DFF client anchor object for embedded objects according
+ to the scaling data passed to the constructor. Caller takes ownership! */
+ virtual XclExpDffAnchorBase* CreateDffAnchor() const;
+
+private:
+ Size maPageSize;
+ sal_Int32 mnScaleX;
+ sal_Int32 mnScaleY;
+};
+
// ============================================================================
#endif
diff --git a/sc/source/filter/inc/xerecord.hxx b/sc/source/filter/inc/xerecord.hxx
index fa3810c0e92b..a191cd9b1c20 100644
--- a/sc/source/filter/inc/xerecord.hxx
+++ b/sc/source/filter/inc/xerecord.hxx
@@ -48,9 +48,6 @@ public:
/** Overwrite this method to do any operation while saving the record. */
virtual void Save( XclExpStream& rStrm );
virtual void SaveXml( XclExpXmlStream& rStrm );
-
-//UNUSED2008-05 /** Calls Save(XclExpStream&) nCount times. */
-//UNUSED2008-05 void SaveRepeated( XclExpStream& rStrm, size_t nCount );
};
// ----------------------------------------------------------------------------
diff --git a/sc/source/filter/inc/xeroot.hxx b/sc/source/filter/inc/xeroot.hxx
index ce32a46cbc66..f9d3a6ab2f95 100644
--- a/sc/source/filter/inc/xeroot.hxx
+++ b/sc/source/filter/inc/xeroot.hxx
@@ -52,6 +52,7 @@ class XclExpNumFmtBuffer;
class XclExpXFBuffer;
class XclExpLinkManager;
class XclExpNameManager;
+class XclExpObjectManager;
class XclExpFilterManager;
class XclExpPivotTableManager;
@@ -70,6 +71,7 @@ struct XclExpRootData : public XclRootData
typedef ScfRef< XclExpXFBuffer > XclExpXFBfrRef;
typedef ScfRef< XclExpNameManager > XclExpNameMgrRef;
typedef ScfRef< XclExpLinkManager > XclExpLinkMgrRef;
+ typedef ScfRef< XclExpObjectManager > XclExpObjectMgrRef;
typedef ScfRef< XclExpFilterManager > XclExpFilterMgrRef;
typedef ScfRef< XclExpPivotTableManager > XclExpPTableMgrRef;
@@ -86,6 +88,7 @@ struct XclExpRootData : public XclRootData
XclExpNameMgrRef mxNameMgr; /// Internal defined names.
XclExpLinkMgrRef mxGlobLinkMgr; /// Global link manager for defined names.
XclExpLinkMgrRef mxLocLinkMgr; /// Local link manager for a sheet.
+ XclExpObjectMgrRef mxObjMgr; /// All drawing objects.
XclExpFilterMgrRef mxFilterMgr; /// Manager for filtered areas in all sheets.
XclExpPTableMgrRef mxPTableMgr; /// All pivot tables and pivot caches.
@@ -134,6 +137,8 @@ public:
XclExpLinkManager& GetLocalLinkManager() const;
/** Returns the buffer that contains internal defined names. */
XclExpNameManager& GetNameManager() const;
+ /** Returns the drawing object manager. */
+ XclExpObjectManager& GetObjectManager() const;
/** Returns the filter manager. */
XclExpFilterManager& GetFilterManager() const;
/** Returns the pivot table manager. */
diff --git a/sc/source/filter/inc/xichart.hxx b/sc/source/filter/inc/xichart.hxx
index 25e52f3f0168..5d03c99b124a 100644
--- a/sc/source/filter/inc/xichart.hxx
+++ b/sc/source/filter/inc/xichart.hxx
@@ -39,8 +39,8 @@
#include "token.hxx"
#include "xlchart.hxx"
#include "xlstyle.hxx"
+#include "xiescher.hxx"
#include "xistring.hxx"
-#include "xiroot.hxx"
namespace com { namespace sun { namespace star {
namespace frame
@@ -111,7 +111,7 @@ public:
/** Starts the API chart document conversion. Must be called once before all API conversion. */
void InitConversion( XChartDocRef xChartDoc ) const;
/** Finishes the API chart document conversion. Must be called once after all API conversion. */
- void FinishConversion( ScfProgressBar& rProgress ) const;
+ void FinishConversion( XclImpDffConverter& rDffConv ) const;
/** Returns the data provider for the chart document. */
XDataProviderRef GetDataProvider() const;
@@ -1355,7 +1355,9 @@ public:
inline sal_Size GetProgressSize() const { return 2 * EXC_CHART_PROGRESS_SIZE; }
/** Converts and writes all properties to the passed chart. */
- void Convert( XChartDocRef xChartDoc, ScfProgressBar& rProgress, const ::rtl::OUString& rObjName ) const;
+ void Convert( XChartDocRef xChartDoc,
+ XclImpDffConverter& rDffConv,
+ const ::rtl::OUString& rObjName ) const;
private:
/** Reads a CHSERIES group (data series source and formatting). */
@@ -1400,6 +1402,31 @@ typedef ScfRef< XclImpChChart > XclImpChChartRef;
// ----------------------------------------------------------------------------
+/** Drawing container of a chart. */
+class XclImpChartDrawing : public XclImpDrawing
+{
+public:
+ explicit XclImpChartDrawing( const XclImpRoot& rRoot, bool bOwnTab );
+
+ /** Converts all objects and inserts them into the chart drawing page. */
+ void ConvertObjects(
+ XclImpDffConverter& rDffConv,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxModel,
+ const Rectangle& rChartRect );
+
+ /** Calculate the resulting rectangle of the passed anchor. */
+ virtual Rectangle CalcAnchorRect( const XclObjAnchor& rAnchor, bool bDffAnchor ) const;
+ /** Called whenever an object has been inserted into the draw page. */
+ virtual void OnObjectInserted( const XclImpDrawObjBase& rDrawObj );
+
+private:
+ Rectangle maChartRect; /// Position and size of the chart shape in 1/100 mm.
+ SCTAB mnScTab; /// Index of the sheet that contains the chart.
+ bool mbOwnTab; /// True = own sheet, false = embedded object.
+};
+
+// ----------------------------------------------------------------------------
+
/** Represents the entire chart substream (all records in BOF/EOF block). */
class XclImpChart : protected XclImpRoot
{
@@ -1410,6 +1437,7 @@ public:
/** Constructs a new chart object.
@param bOwnTab True = chart is on an own sheet; false = chart is an embedded object. */
explicit XclImpChart( const XclImpRoot& rRoot, bool bOwnTab );
+ virtual ~XclImpChart();
/** Reads the complete chart substream (BOF/EOF block).
@descr The passed stream must be located in the BOF record of the chart substream. */
@@ -1423,14 +1451,22 @@ public:
inline bool IsPivotChart() const { return mbIsPivotChart; }
/** Creates the chart object in the passed component. */
- void Convert( XModelRef xModel, ScfProgressBar& rProgress, const ::rtl::OUString& rObjName ) const;
+ void Convert( XModelRef xModel,
+ XclImpDffConverter& rDffConv,
+ const ::rtl::OUString& rObjName,
+ const Rectangle& rChartRect ) const;
private:
+ /** Returns (initially creates) the drawing container for embedded shapes. **/
+ XclImpChartDrawing& GetChartDrawing();
/** Reads the CHCHART group (entire chart data). */
void ReadChChart( XclImpStream& rStrm );
private:
+ typedef ScfRef< XclImpChartDrawing > XclImpChartDrawingRef;
+
XclImpChChartRef mxChartData; /// The chart data (CHCHART group).
+ XclImpChartDrawingRef mxChartDrawing; /// Drawing container for embedded shapes.
bool mbOwnTab; /// true = own sheet; false = embedded object.
bool mbIsPivotChart; /// true = chart is based on a pivot table.
};
diff --git a/sc/source/filter/inc/xiescher.hxx b/sc/source/filter/inc/xiescher.hxx
index 258720e89584..0167d160f297 100644
--- a/sc/source/filter/inc/xiescher.hxx
+++ b/sc/source/filter/inc/xiescher.hxx
@@ -42,9 +42,12 @@ namespace com { namespace sun { namespace star {
namespace form { class XForm; }
} } }
+class SdrObjList;
class ScfProgressBar;
class ScfPropertySet;
class XclImpChart;
+class XclImpDffConverter;
+class XclImpDrawing;
// Drawing objects ============================================================
@@ -59,23 +62,23 @@ public:
virtual ~XclImpDrawObjBase();
/** Reads the BIFF3 OBJ record, returns a new drawing object. */
- static XclImpDrawObjRef ReadObj3( XclImpStream& rStrm );
+ static XclImpDrawObjRef ReadObj3( const XclImpRoot& rRoot, XclImpStream& rStrm );
/** Reads the BIFF4 OBJ record, returns a new drawing object. */
- static XclImpDrawObjRef ReadObj4( XclImpStream& rStrm );
+ static XclImpDrawObjRef ReadObj4( const XclImpRoot& rRoot, XclImpStream& rStrm );
/** Reads the BIFF5 OBJ record, returns a new drawing object. */
- static XclImpDrawObjRef ReadObj5( XclImpStream& rStrm );
+ static XclImpDrawObjRef ReadObj5( const XclImpRoot& rRoot, XclImpStream& rStrm );
/** Reads the BIFF8 OBJ record, returns a new drawing object. */
- static XclImpDrawObjRef ReadObj8( XclImpStream& rStrm );
+ static XclImpDrawObjRef ReadObj8( const XclImpRoot& rRoot, XclImpStream& rStrm );
/** Sets whether this is an area object (then its width and height must be greater than 0). */
inline void SetAreaObj( bool bAreaObj ) { mbAreaObj = bAreaObj; }
/** If set to true, a new SdrObject will be created while in DFF import. */
inline void SetSimpleMacro( bool bMacro ) { mbSimpleMacro = bMacro; }
- /** Sets shape data from DFF stream. */
- void SetDffData( const DffObjData& rDffObjData, const String& rObjName, const String& rHyperlink, bool bVisible, bool bAutoMargin );
/** Sets the object anchor explicitly. */
void SetAnchor( const XclObjAnchor& rAnchor );
+ /** Sets shape data from DFF stream. */
+ void SetDffData( const DffObjData& rDffObjData, const String& rObjName, const String& rHyperlink, bool bVisible, bool bAutoMargin );
/** If set to false, the SdrObject will not be created, processed, or inserted into the draw page. */
inline void SetProcessSdrObj( bool bProcess ) { mbProcessSdr = bProcess; }
@@ -84,10 +87,8 @@ public:
/** If set to true, a new SdrObject will be created while in DFF import. */
inline void SetCustomDffObj( bool bCustom ) { mbCustomDff = bCustom; }
- /** Returns the Calc sheet index of this object. */
- inline SCTAB GetScTab() const { return maObjId.mnScTab; }
/** Returns the sheet index and Excel object identifier from OBJ record. */
- inline const XclObjId& GetObjId() const { return maObjId; }
+ inline sal_uInt16 GetObjId() const { return mnObjId; }
/** Returns the Excel object type from OBJ record. */
inline sal_uInt16 GetObjType() const { return mnObjType; }
/** Returns the name of this object, may generate a default name. */
@@ -107,14 +108,14 @@ public:
/** Returns true, if the object is printable. */
inline bool IsPrintable() const { return mbPrintable; }
+ /** Returns the object anchor if existing, null otherwise. */
+ const XclObjAnchor* GetAnchor() const;
/** Returns true, if the passed size is valid for this object. */
bool IsValidSize( const Rectangle& rAnchorRect ) const;
- /** Returns the area in the sheet used by this object. */
- ScRange GetUsedArea() const;
- /** Returns the area on the drawing layer for this object. */
- Rectangle GetAnchorRect() const;
+ /** Returns the range in the sheet covered by this object. */
+ ScRange GetUsedArea( SCTAB nScTab ) const;
- /** Returns true, if the object is valid and will be processed.. */
+ /** Returns true, if the object is valid and will be processed. */
inline bool IsProcessSdrObj() const { return mbProcessSdr && !mbHidden; }
/** Returns true, if the SdrObject will be created or processed, but not be inserted into the draw page. */
inline bool IsInsertSdrObj() const { return mbInsertSdr; }
@@ -122,9 +123,13 @@ public:
/** Returns the needed size on the progress bar (calls virtual DoGetProgressSize() function). */
sal_Size GetProgressSize() const;
/** Creates and returns an SdrObject from the contained data. Caller takes ownership! */
- SdrObject* CreateSdrObject( const Rectangle& rAnchorRect, ScfProgressBar& rProgress, bool bDffImport ) const;
- /** Additional processing for the passed SdrObject (calls virtual DoProcessSdrObj() function). */
- void ProcessSdrObject( SdrObject& rSdrObj ) const;
+ SdrObject* CreateSdrObject( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect, bool bIsDff ) const;
+ /** Additional processing for the passed SdrObject before insertion into
+ the drawing page (calls virtual DoPreProcessSdrObj() function). */
+ void PreProcessSdrObject( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
+ /** Additional processing for the passed SdrObject after insertion into the
+ drawing page (calls virtual DoPostProcessSdrObj() function). */
+ void PostProcessSdrObject( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
protected:
/** Reads the object name in a BIFF5 OBJ record. */
@@ -162,9 +167,11 @@ protected:
/** Derived classes may return a progress bar size different from 1. */
virtual sal_Size DoGetProgressSize() const;
/** Derived classes create and return a new SdrObject from the contained data. Caller takes ownership! */
- virtual SdrObject* DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const;
- /** Derived classes may perform additional processing for the passed SdrObject. */
- virtual void DoProcessSdrObj( SdrObject& rSdrObj ) const;
+ virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
+ /** Derived classes may perform additional processing for the passed SdrObject before insertion. */
+ virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
+ /** Derived classes may perform additional processing for the passed SdrObject after insertion. */
+ virtual void DoPostProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
private:
/** Reads the contents of a BIFF3 OBJ record. */
@@ -177,16 +184,15 @@ private:
void ImplReadObj8( XclImpStream& rStrm );
private:
- typedef ScfRef< XclObjAnchor > XclObjAnchorRef;
-
- XclObjAnchorRef mxAnchor; /// The position of the object in the containing sheet.
- XclObjId maObjId; /// Sheet index and object identifier.
+ XclObjAnchor maAnchor; /// The position of the object in its parent.
+ sal_uInt16 mnObjId; /// The object identifier (unique per drawing).
sal_uInt16 mnObjType; /// The Excel object type from OBJ record.
sal_uInt32 mnDffShapeId; /// Shape ID from DFF stream.
sal_uInt32 mnDffFlags; /// Shape flags from DFF stream.
String maObjName; /// Name of the object.
String maMacroName; /// Name of an attached macro.
String maHyperlink; /// On-click hyperlink URL.
+ bool mbHasAnchor; /// true = maAnchor is initialized.
bool mbHidden; /// true = Object is hidden.
bool mbVisible; /// true = Object is visible.
bool mbPrintable; /// true = Object is printable.
@@ -242,7 +248,7 @@ protected:
/** Returns a progress bar size that takes all group children into account. */
virtual sal_Size DoGetProgressSize() const;
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
- virtual SdrObject* DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const;
+ virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
protected:
XclImpDrawObjVector maChildren; /// Grouped objects.
@@ -265,7 +271,7 @@ protected:
/** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
- virtual SdrObject* DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const;
+ virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
protected:
XclObjLineData maLineData; /// BIFF5 line formatting.
@@ -295,7 +301,7 @@ protected:
/** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
- virtual SdrObject* DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const;
+ virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
protected:
XclObjFillData maFillData; /// BIFF5 fill formatting.
@@ -313,7 +319,7 @@ public:
protected:
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
- virtual SdrObject* DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const;
+ virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
};
// ----------------------------------------------------------------------------
@@ -332,7 +338,7 @@ protected:
/** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
- virtual SdrObject* DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const;
+ virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
protected:
XclObjFillData maFillData; /// BIFF5 fill formatting.
@@ -357,7 +363,7 @@ protected:
/** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
- virtual SdrObject* DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const;
+ virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
protected:
typedef ::std::vector< Point > PointVector;
@@ -398,9 +404,9 @@ protected:
/** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
- virtual SdrObject* DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const;
+ virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
/** Inserts the contained text data at the passed object. */
- virtual void DoProcessSdrObj( SdrObject& rSdrObj ) const;
+ virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
protected:
XclImpObjTextData maTextData; /// Textbox data from BIFF5 OBJ or BIFF8 TXO record.
@@ -430,7 +436,9 @@ protected:
/** Returns the needed size on the progress bar. */
virtual sal_Size DoGetProgressSize() const;
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
- virtual SdrObject* DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const;
+ virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
+ /** Converts the chart document. */
+ virtual void DoPostProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
private:
/** Calculates the object anchor of a sheet chart (chart fills one page). */
@@ -456,7 +464,7 @@ public:
protected:
/** Inserts the note into the document, sets visibility. */
- virtual void DoProcessSdrObj( SdrObject& rSdrObj ) const;
+ virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
private:
ScAddress maScPos; /// Cell position of the note object.
@@ -533,9 +541,9 @@ protected:
void ConvertLabel( ScfPropertySet& rPropSet ) const;
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
- virtual SdrObject* DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const;
+ virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
/** Additional processing on the SdrObject, calls new virtual function DoProcessControl(). */
- virtual void DoProcessSdrObj( SdrObject& rSdrObj ) const;
+ virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
/** Derived classes return the service name of the control component to be created. */
virtual ::rtl::OUString DoGetServiceName() const = 0;
@@ -882,9 +890,9 @@ protected:
/** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
- virtual SdrObject* DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const;
+ virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
/** Overloaded to do additional processing on the SdrObject. */
- virtual void DoProcessSdrObj( SdrObject& rSdrObj ) const;
+ virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
private:
/** Reads and sets the picture flags from a BIFF3-BIFF5 OBJ picture record. */
@@ -955,13 +963,13 @@ private:
// ----------------------------------------------------------------------------
/** Simple implementation of the SVX DFF manager. Implements resolving palette
- colors. Used by XclImpDffPropSet (as is), extended by XclImpDffManager.
+ colors. Used by XclImpDffPropSet (as is), extended by XclImpDffConverter.
*/
-class XclImpSimpleDffManager : public SvxMSDffManager, protected XclImpRoot
+class XclImpSimpleDffConverter : public SvxMSDffManager, protected XclImpRoot
{
public:
- explicit XclImpSimpleDffManager( const XclImpRoot& rRoot, SvStream& rDffStrm );
- virtual ~XclImpSimpleDffManager();
+ explicit XclImpSimpleDffConverter( const XclImpRoot& rRoot, SvStream& rDffStrm );
+ virtual ~XclImpSimpleDffConverter();
protected:
/** Returns a color from the Excel color palette. */
@@ -970,42 +978,46 @@ protected:
// ----------------------------------------------------------------------------
-class XclImpObjectManager;
-class SdrObjList;
+/** This is the central instance for converting binary DFF data into shape
+ objects. Used for all sheet shapes and shapes embedded in chart objects.
-/** Derived from SvxMSDffManager and SvxMSConvertOCXControls, contains core
- implementation of DFF stream import and OCX form control import.
+ The class derives from SvxMSDffManager and SvxMSConvertOCXControls and
+ contains core implementation of DFF stream import and OCX form control
+ import.
*/
-class XclImpDffManager : public XclImpSimpleDffManager, protected SvxMSConvertOCXControls
+class XclImpDffConverter : public XclImpSimpleDffConverter, private SvxMSConvertOCXControls
{
public:
- explicit XclImpDffManager(
- const XclImpRoot& rRoot,
- XclImpObjectManager& rObjManager,
- SvStream& rDffStrm );
- virtual ~XclImpDffManager();
+ explicit XclImpDffConverter( const XclImpRoot& rRoot, SvStream& rDffStrm );
+ virtual ~XclImpDffConverter();
/** Initializes the internal progress bar with the passed size and starts it. */
void StartProgressBar( sal_Size nProgressSize );
+ /** Increase the progress bar by the passed value. */
+ void Progress( sal_Size nDelta = 1 );
+ /** Initially called before the objects of the passed drawing manager are converted. */
+ void InitializeDrawing( XclImpDrawing& rDrawing, SdrModel& rSdrModel, SdrPage& rSdrPage );
/** Processes BIFF5 drawing objects without DFF data, inserts into the passed object list. */
- void ProcessObject( SdrObjList* pObjList, const XclImpDrawObjBase& rDrawObj );
- /** Processes the leading drawing group container in the DFF stream. */
- void ProcessDrawingGroup( SvStream& rDffStrm );
- /** Processes a drawing container for a sheet in the DFF stream, converts all objects. */
- void ProcessDrawing( SvStream& rDffStrm, sal_Size nStrmPos );
+ void ProcessObject( SdrObjList& rObjList, const XclImpDrawObjBase& rDrawObj );
+ /** Processes all objects in the passed list. */
+ void ProcessDrawing( const XclImpDrawObjVector& rDrawObjs );
+ /** Processes a drawing container in the passed DFF stream, converts all objects. */
+ void ProcessDrawing( SvStream& rDffStrm );
+ /** Finally called after the objects of the passed drawing manager have been converted. */
+ void FinalizeDrawing();
/** Creates the SdrObject for the passed Excel TBX form control object. */
SdrObject* CreateSdrObject( const XclImpTbxObjBase& rTbxObj, const Rectangle& rAnchorRect );
/** Creates the SdrObject for the passed Excel OLE object or OCX form control object. */
SdrObject* CreateSdrObject( const XclImpPictureObj& rPicObj, const Rectangle& rAnchorRect );
+ /** Returns true, if the conversion of OLE objects is supported. */
+ bool SupportsOleObjects() const;
/** Returns the default text margin in drawing layer units. */
inline sal_Int32 GetDefaultTextMargin() const { return mnDefTextMargin; }
- /** Returns the used area in the sheet with the passed index. */
- ScRange GetUsedArea( SCTAB nScTab ) const;
-protected:
+private:
// virtual functions of SvxMSDffManager
/** Reads the client anchor from the DFF stream and sets it at the correct object. */
@@ -1036,11 +1048,30 @@ protected:
BOOL bFloatingCtrl );
private:
+ /** Data per registered drawing manager, will be stacked for recursive calls. */
+ struct XclImpDffConvData
+ {
+ XclImpDrawing& mrDrawing; /// Current drawing container with all drawing objects.
+ SdrModel& mrSdrModel; /// The SdrModel of the drawing manager.
+ SdrPage& mrSdrPage; /// The SdrPage of the drawing manager.
+ XclImpSolverContainer maSolverCont; /// The solver container for connector rules.
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >
+ mxCtrlForm; /// Controls form of current drawing page.
+ sal_Int32 mnLastCtrlIndex; /// Last insertion index of a form control (for macro events).
+ bool mbHasCtrlForm; /// True = mxCtrlForm is initialized (but maybe still null).
+
+ explicit XclImpDffConvData( XclImpDrawing& rDrawing,
+ SdrModel& rSdrModel, SdrPage& rSdrPage );
+ };
+
+ /** Returns the current drawing manager data struct from top of the stack. */
+ XclImpDffConvData& GetConvData();
+ /** Returns the current drawing manager data struct from top of the stack. */
+ const XclImpDffConvData& GetConvData() const;
+
/** Reads contents of a hyperlink property and returns the extracted URL. */
String ReadHlinkProperty( SvStream& rDffStrm ) const;
- /** Processes a drawing group container (global drawing data). */
- void ProcessDggContainer( SvStream& rDffStrm, const DffRecordHeader& rDggHeader );
/** Processes a drawing container (all drawing data of a sheet). */
void ProcessDgContainer( SvStream& rDffStrm, const DffRecordHeader& rDgHeader );
/** Processes the global shape group container (all shapes of a sheet). */
@@ -1051,87 +1082,71 @@ private:
void ProcessShContainer( SvStream& rDffStrm, const DffRecordHeader& rShHeader );
/** Inserts the passed SdrObject into the document. This function takes ownership of pSdrObj! */
- void InsertSdrObject( SdrObjList* pObjList, const XclImpDrawObjBase& rDrawObj, SdrObject* pSdrObj );
- /** Stores the standard controls form for the passed sheet in mxCurrForm member. */
- void SetCurrentForm( SCTAB nScTab );
-
- /** Updates the used area of a sheet with the position and size of the passed object. */
- void UpdateUsedArea( const XclImpDrawObjBase& rDrawObj );
+ void InsertSdrObject( SdrObjList& rObjList, const XclImpDrawObjBase& rDrawObj, SdrObject* pSdrObj );
+ /** Initializes the mxCtrlForm referring to the standard controls form. */
+ void InitControlForm();
private:
- typedef ::std::map< SCTAB, ScRange > ScRangeMap;
- typedef ScfRef< ScfProgressBar > ScfProgressBarRef;
+ typedef ScfRef< ScfProgressBar > ScfProgressBarRef;
+ typedef ScfRef< XclImpDffConvData > XclImpDffConvDataRef;
+ typedef ::std::vector< XclImpDffConvDataRef > XclImpDffConvDataStack;
- XclImpObjectManager& mrObjManager; /// The Excel object manager.
- XclImpSolverContainer maSolverCont; /// The solver container for connector rules.
+ const ::rtl::OUString maStdFormName; /// Standard name of control forms.
SotStorageStreamRef mxCtlsStrm; /// The 'Ctls' stream for OCX form controls.
- ScRangeMap maUsedAreaMap; /// Used ranges for all sheets.
ScfProgressBarRef mxProgress; /// The progress bar used in ProcessObj().
- ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >
- mxCurrForm; /// Controls form of current sheet (needed in virtual functions).
+ XclImpDffConvDataStack maDataStack; /// Stack for registered drawing managers.
sal_uInt32 mnOleImpFlags; /// Application OLE import settings.
sal_Int32 mnDefTextMargin; /// Default margin in text boxes.
- sal_Int32 mnLastCtrlIndex; /// Last insertion index of a form control (for macro events).
- SCTAB mnCurrFormScTab; /// Sheet index of form stored in mxCurrForm.
};
-// The object manager =========================================================
+// Drawing manager ============================================================
-/** Stores all drawing and OLE objects and additional data related to these objects. */
-class XclImpObjectManager : protected XclImpRoot
+/** Base class for a container for all objects on a drawing (spreadsheet or
+ embedded chart object). */
+class XclImpDrawing : protected XclImpRoot
{
public:
- explicit XclImpObjectManager( const XclImpRoot& rRoot );
- virtual ~XclImpObjectManager();
-
- // *** Read Excel records *** ---------------------------------------------
+ explicit XclImpDrawing( const XclImpRoot& rRoot, bool bOleObjects );
+ virtual ~XclImpDrawing();
/** Reads and returns a bitmap from the IMGDATA record. */
- static Graphic ReadImgData( XclImpStream& rStrm );
+ static Graphic ReadImgData( const XclImpRoot& rRoot, XclImpStream& rStrm );
/** Reads a plain OBJ record (without leading DFF data). */
void ReadObj( XclImpStream& rStrm );
- /** Reads the MSODRAWINGGROUP record. */
- void ReadMsoDrawingGroup( XclImpStream& rStrm );
/** Reads the MSODRAWING or MSODRAWINGSELECTION record. */
void ReadMsoDrawing( XclImpStream& rStrm );
- /** Reads the NOTE record. */
- void ReadNote( XclImpStream& rStrm );
-
- /** Inserts a new chart object and reads the chart substream (BOF/EOF block).
- @descr Used to import chart sheets, which do not have a corresponding OBJ record. */
- void ReadTabChart( XclImpStream& rStrm );
-
- // *** Drawing objects *** ------------------------------------------------
+ /** Returns true, if the conversion of OLE objects is supported. */
+ inline bool SupportsOleObjects() const { return mbOleObjs; }
/** Finds the OBJ record data related to the DFF shape at the passed position. */
XclImpDrawObjRef FindDrawObj( const DffRecordHeader& rHeader ) const;
/** Finds the OBJ record data specified by the passed object identifier. */
- XclImpDrawObjRef FindDrawObj( const XclObjId& rObjId ) const;
+ XclImpDrawObjRef FindDrawObj( sal_uInt16 nObjId ) const;
/** Finds the textbox data related to the DFF shape at the passed position. */
const XclImpObjTextData* FindTextData( const DffRecordHeader& rHeader ) const;
/** Sets the object with the passed identification to be skipped on import. */
- void SetSkipObj( SCTAB nScTab, sal_uInt16 nObjId );
-
- // *** Drawing object conversion *** --------------------------------------
+ void SetSkipObj( sal_uInt16 nObjId );
+ /** Returns the size of the progress bar shown while processing all objects. */
+ sal_Size GetProgressSize() const;
- /** Returns the DFF manager (DFF stream converter). Don't call before the DFF stream is read. */
- XclImpDffManager& GetDffManager();
- /** Inserts all objects into the Calc document. */
- void ConvertObjects();
+ /** Derived classes calculate the resulting rectangle of the passed anchor. */
+ virtual Rectangle CalcAnchorRect( const XclObjAnchor& rAnchor, bool bDffAnchor ) const = 0;
+ /** Called whenever an object has been inserted into the draw page. */
+ virtual void OnObjectInserted( const XclImpDrawObjBase& rDrawObj ) = 0;
- /** Returns the default name for the passed object. */
- String GetDefaultObjName( const XclImpDrawObjBase& rDrawObj ) const;
- /** Returns the used area in the sheet with the passed index. */
- ScRange GetUsedArea( SCTAB nScTab ) const;
+protected:
+ /** Appends a new drawing object to the list of raw objects (without DFF data). */
+ void AppendRawObject( const XclImpDrawObjRef& rxDrawObj );
+ /** Converts all objects and inserts them into the current drawing page. */
+ void ImplConvertObjects( XclImpDffConverter& rDffConv, SdrModel& rSdrModel, SdrPage& rSdrPage );
- // ------------------------------------------------------------------------
private:
/** Reads and returns a bitmap from WMF/PICT format. */
- static void ReadWmf( Graphic& rGraphic, XclImpStream& rStrm );
+ static void ReadWmf( Graphic& rGraphic, const XclImpRoot& rRoot, XclImpStream& rStrm );
/** Reads and returns a bitmap from BMP format. */
- static void ReadBmp( Graphic& rGraphic, XclImpStream& rStrm );
+ static void ReadBmp( Graphic& rGraphic, const XclImpRoot& rRoot, XclImpStream& rStrm );
/** Reads contents of an DFF record and append data to internal DFF stream. */
void ReadDffRecord( XclImpStream& rStrm );
@@ -1140,36 +1155,86 @@ private:
/** Reads the TXO record and following CONTINUE records containing string and formatting. */
void ReadTxo( XclImpStream& rStrm );
+private:
+ typedef ::std::map< sal_Size, XclImpDrawObjRef > XclImpObjMap;
+ typedef ::std::map< sal_uInt16, XclImpDrawObjRef > XclImpObjMapById;
+ typedef ScfRef< XclImpObjTextData > XclImpObjTextRef;
+ typedef ::std::map< sal_Size, XclImpObjTextRef > XclImpObjTextMap;
+
+ XclImpDrawObjVector maRawObjs; /// BIFF5 objects without DFF data.
+ SvMemoryStream maDffStrm; /// Copy of the DFF page stream in memory.
+ XclImpObjMap maObjMap; /// Maps BIFF8 drawing objects to DFF stream position.
+ XclImpObjMapById maObjMapId; /// Maps BIFF8 drawing objects to object ID.
+ XclImpObjTextMap maTextMap; /// Maps BIFF8 TXO textbox data to DFF stream position.
+ ScfUInt16Vec maSkipObjs; /// IDs of all objects to be skipped.
+ bool mbOleObjs; /// True = draw model supports OLE objects.
+};
+
+// ----------------------------------------------------------------------------
+
+/** Drawing manager of a single sheet. */
+class XclImpSheetDrawing : public XclImpDrawing
+{
+public:
+ explicit XclImpSheetDrawing( const XclImpRoot& rRoot, SCTAB nScTab );
+
+ /** Reads the NOTE record. */
+ void ReadNote( XclImpStream& rStrm );
+ /** Inserts a new chart object and reads the chart substream (BOF/EOF block).
+ @descr Used to import chart sheets, which do not have a corresponding OBJ record. */
+ void ReadTabChart( XclImpStream& rStrm );
+
+ /** Returns the total cell range covered by any shapes in the sheet. */
+ inline const ScRange& GetUsedArea() const { return maScUsedArea; }
+ /** Converts all objects and inserts them into the sheet drawing page. */
+ void ConvertObjects( XclImpDffConverter& rDffConv );
+
+ /** Calculate the resulting rectangle of the passed anchor. */
+ virtual Rectangle CalcAnchorRect( const XclObjAnchor& rAnchor, bool bDffAnchor ) const;
+ /** On call, updates the used area of the sheet. */
+ virtual void OnObjectInserted( const XclImpDrawObjBase& rDrawObj );
+
+private:
/** Reads a BIFF3-BIFF5 NOTE record. */
void ReadNote3( XclImpStream& rStrm );
/** Reads a BIFF8 NOTE record. */
void ReadNote8( XclImpStream& rStrm );
- /** Returns the size of the progress bar shown while processing all objects. */
- sal_Size GetProgressSize() const;
+private:
+ ScRange maScUsedArea; /// Sheet index and used area in this sheet.
+};
+
+// The object manager =========================================================
+
+/** Stores all drawing and OLE objects and additional data related to these objects. */
+class XclImpObjectManager : protected XclImpRoot
+{
+public:
+ explicit XclImpObjectManager( const XclImpRoot& rRoot );
+ virtual ~XclImpObjectManager();
+
+ /** Reads the MSODRAWINGGROUP record. */
+ void ReadMsoDrawingGroup( XclImpStream& rStrm );
+
+ /** Returns (initially creates) the drawing manager of the specified sheet. */
+ XclImpSheetDrawing& GetSheetDrawing( SCTAB nScTab );
+ /** Inserts all objects into the Calc document. */
+ void ConvertObjects();
+
+ /** Returns the default name for the passed object. */
+ String GetDefaultObjName( const XclImpDrawObjBase& rDrawObj ) const;
+ /** Returns the used area in the sheet with the passed index. */
+ ScRange GetUsedArea( SCTAB nScTab ) const;
// ------------------------------------------------------------------------
private:
- typedef ::std::map< sal_Size, XclImpDrawObjRef > XclImpObjMap;
- typedef ::std::map< XclObjId, XclImpDrawObjRef > XclImpObjMapById;
- typedef ScfRef< XclImpObjTextData > XclImpObjTextRef;
- typedef ::std::map< sal_Size, XclImpObjTextRef > XclImpObjTextMap;
- typedef ::std::vector< XclObjId > XclObjIdVec;
-
typedef ::std::map< sal_uInt16, String > DefObjNameMap;
- typedef ::std::vector< sal_Size > StreamPosVec;
- typedef ScfRef< XclImpDffManager > XclImpDffMgrRef;
-
- XclImpDrawObjVector maRawObjs; /// BIFF5 objects without DFF data.
- XclImpObjMap maObjMap; /// Maps BIFF8 drawing objects to DFF stream position.
- XclImpObjMapById maObjMapId; /// Maps BIFF8 drawing objects to sheet index and object ID.
- XclImpObjTextMap maTextMap; /// Maps BIFF8 TXO textbox data to DFF stream position.
- XclObjIdVec maSkipObjs; /// All objects to be skipped.
+ typedef ScfRef< XclImpSheetDrawing > XclImpSheetDrawingRef;
+ typedef ::std::map< SCTAB, XclImpSheetDrawingRef > XclImpSheetDrawingMap;
DefObjNameMap maDefObjNames; /// Default base names for all object types.
- SvMemoryStream maDffStrm; /// Copy of DFF stream in memory.
- StreamPosVec maTabStrmPos; /// Start positions of DFF stream fragments for all sheets.
- XclImpDffMgrRef mxDffManager; /// The DFF stream converter.
+ SvMemoryStream maDggStrm; /// Copy of global DFF data (DGG container) in memory.
+ XclImpSheetDrawingMap maSheetDrawings; /// Drawing managers of all sheets.
};
// DFF property set helper ====================================================
@@ -1197,8 +1262,8 @@ public:
private:
typedef ::std::auto_ptr< SvMemoryStream > SvMemoryStreamPtr;
- SvMemoryStream maDummyStrm; /// Dummy stream for DFF manager.
- XclImpSimpleDffManager maDffManager;/// DFF manager used to resolve palette colors.
+ SvMemoryStream maDummyStrm; /// Dummy DGG stream for DFF manager.
+ XclImpSimpleDffConverter maDffConv; /// DFF converter used to resolve palette colors.
SvMemoryStreamPtr mxMemStrm; /// Helper stream.
};
diff --git a/sc/source/filter/inc/xihelper.hxx b/sc/source/filter/inc/xihelper.hxx
index 9a836c8844db..05412c306c0c 100644
--- a/sc/source/filter/inc/xihelper.hxx
+++ b/sc/source/filter/inc/xihelper.hxx
@@ -320,13 +320,15 @@ public:
/** Returns the type of the cached value (EXC_CACHEDVAL_*). */
inline sal_uInt8 GetType() const { return mnType; }
/** Returns the cached string value, if this value is a string, else an empty string. */
- inline const String& GetString() const { return mxStr.get() ? *mxStr : EMPTY_STRING; }
+ inline const String& GetString() const { return mxStr.get() ? *mxStr : EMPTY_STRING; }
/** Returns the cached number, if this value has number type, else 0.0. */
inline double GetValue() const { return mfValue; }
/** Returns the cached Boolean value, if this value has Boolean type, else false. */
inline bool GetBool() const { return (mnType == EXC_CACHEDVAL_BOOL) && (mnBoolErr != 0); }
/** Returns the cached Calc error code, if this value has Error type, else 0. */
- USHORT GetError() const;
+ inline sal_uInt8 GetXclError() const { return (mnType == EXC_CACHEDVAL_ERROR) ? mnBoolErr : EXC_ERR_NA; }
+ /** Returns the cached Calc error code, if this value has Error type, else 0. */
+ USHORT GetScError() const;
/** Returns the token array if this is a Boolean value or error value, else 0. */
inline const ScTokenArray* GetBoolErrFmla() const { return mxTokArr.get(); }
diff --git a/sc/source/filter/inc/xiroot.hxx b/sc/source/filter/inc/xiroot.hxx
index 3881adaaf911..0e06b31b650d 100644
--- a/sc/source/filter/inc/xiroot.hxx
+++ b/sc/source/filter/inc/xiroot.hxx
@@ -51,6 +51,7 @@ class XclImpTabInfo;
class XclImpNameManager;
class XclImpLinkManager;
class XclImpObjectManager;
+class XclImpSheetDrawing;
class XclImpCondFormatManager;
class XclImpAutoFilterBuffer;
class XclImpWebQueryBuffer;
@@ -176,6 +177,8 @@ public:
/** Returns the drawing object manager. */
XclImpObjectManager& GetObjectManager() const;
+ /** Returns the drawing container of the current sheet. */
+ XclImpSheetDrawing& GetCurrSheetDrawing() const;
/** Returns the conditional formattings manager. */
XclImpCondFormatManager& GetCondFormatManager() const;
/** Returns the filter manager. */
diff --git a/sc/source/filter/inc/xistyle.hxx b/sc/source/filter/inc/xistyle.hxx
index 4a347062905c..104002542a17 100644
--- a/sc/source/filter/inc/xistyle.hxx
+++ b/sc/source/filter/inc/xistyle.hxx
@@ -316,6 +316,9 @@ struct XclImpCellBorder : public XclCellBorder
/** Fills this struct with BIFF8 CF (conditional format) record data. */
void FillFromCF8( sal_uInt16 nLineStyle, sal_uInt32 nLineColor, sal_uInt32 nFlags );
+ /** Returns true, if any of the outer border lines is visible. */
+ bool HasAnyOuterBorder() const;
+
/** Inserts a box item representing this border style into the item set.
@param bSkipPoolDefs true = Do not put items equal to pool default; false = Put all items. */
void FillToItemSet(
@@ -423,8 +426,6 @@ private:
@descr In cell XFs, a set bit represents "used", in style XFs it is a cleared bit.
Therefore mbCellXF must be set correctly before calling this method. */
void SetUsedFlags( sal_uInt8 nUsedFlags );
- /** Sets own "attribute used" flags, if attributes are different from passed parent XF. */
- void UpdateUsedFlags( const XclImpXF& rParentXF );
private:
typedef ::std::auto_ptr< ScPatternAttr > ScPatternAttrPtr;
diff --git a/sc/source/filter/inc/xlchart.hxx b/sc/source/filter/inc/xlchart.hxx
index 7e5f90fda4a7..f6711211bc13 100644
--- a/sc/source/filter/inc/xlchart.hxx
+++ b/sc/source/filter/inc/xlchart.hxx
@@ -71,6 +71,7 @@ namespace com { namespace sun { namespace star {
#define SERVICE_CHART2_TITLE CREATE_OUSTRING( "com.sun.star.chart2.Title" )
// property names
+#define EXC_CHPROP_ADDITIONALSHAPES CREATE_OUSTRING( "AdditionalShapes" )
#define EXC_CHPROP_ARRANGEORDER CREATE_OUSTRING( "ArrangeOrder" )
#define EXC_CHPROP_ATTAXISINDEX CREATE_OUSTRING( "AttachedAxisIndex" )
#define EXC_CHPROP_ATTRIBDATAPOINTS CREATE_OUSTRING( "AttributedDataPoints" )
@@ -168,6 +169,8 @@ const sal_Int32 EXC_CHART_AXESSET_NONE = -1; /// For internal use
const sal_Int32 EXC_CHART_AXESSET_PRIMARY = 0; /// API primary axes set index.
const sal_Int32 EXC_CHART_AXESSET_SECONDARY = 1; /// API secondary axes set index.
+const sal_Int32 EXC_CHART_UNIT = 4000; /// Chart objects are positioned in 1/4000 of chart area.
+
// (0x0850) CHFRINFO ----------------------------------------------------------
const sal_uInt16 EXC_ID_CHFRINFO = 0x0850;
diff --git a/sc/source/filter/inc/xlescher.hxx b/sc/source/filter/inc/xlescher.hxx
index f60d6d3a5ee5..33b75af8cd2c 100644
--- a/sc/source/filter/inc/xlescher.hxx
+++ b/sc/source/filter/inc/xlescher.hxx
@@ -312,18 +312,21 @@ bool operator<( const XclObjId& rL, const XclObjId& rR );
/** Represents the position (anchor) of an object in a Calc document. */
struct XclObjAnchor : public XclRange
{
- SCTAB mnScTab; /// Calc sheet index.
sal_uInt16 mnLX; /// X offset in left column (1/1024 of column width).
sal_uInt16 mnTY; /// Y offset in top row (1/256 of row height).
sal_uInt16 mnRX; /// X offset in right column (1/1024 of column width).
sal_uInt16 mnBY; /// Y offset in bottom row (1/256 of row height).
- explicit XclObjAnchor( SCTAB nScTab );
+ explicit XclObjAnchor();
/** Calculates a rectangle from the contained coordinates. */
- Rectangle GetRect( ScDocument& rDoc, MapUnit eMapUnit ) const;
- /** Initializes the anchor coordinates from a rectangle. */
- void SetRect( ScDocument& rDoc, const Rectangle& rRect, MapUnit eMapUnit );
+ Rectangle GetRect( ScDocument& rDoc, SCTAB nScTab, MapUnit eMapUnit ) const;
+ /** Initializes the anchor coordinates for a sheet. */
+ void SetRect( ScDocument& rDoc, SCTAB nScTab, const Rectangle& rRect, MapUnit eMapUnit );
+
+ /** Initializes the anchor coordinates for an embedded draw page. */
+ void SetRect( const Size& rPageSize, sal_Int32 nScaleX, sal_Int32 nScaleY,
+ const Rectangle& rRect, MapUnit eMapUnit, bool bDffAnchor );
};
template< typename StreamType >
diff --git a/sc/source/filter/inc/xltools.hxx b/sc/source/filter/inc/xltools.hxx
index b2519a51d156..e8ceed8248d6 100644
--- a/sc/source/filter/inc/xltools.hxx
+++ b/sc/source/filter/inc/xltools.hxx
@@ -121,6 +121,8 @@ public:
/** Converts an Excel error code to a Calc error code. */
static USHORT GetScErrorCode( sal_uInt8 nXclError );
+ /** Converts the passed BIFF error to a double containing the respective Calc error code. */
+ static double ErrorToDouble( sal_uInt8 nXclError );
/** Gets a translated error code or Boolean value from Excel error codes.
@param rfDblValue Returns 0.0 for error codes or the value of a Boolean (0.0 or 1.0).
@param bErrorOrBool false = nError is a Boolean value; true = is an error value.
diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx
index 756b384b7f11..86a347970ff6 100644
--- a/sc/source/filter/rtf/eeimpars.cxx
+++ b/sc/source/filter/rtf/eeimpars.cxx
@@ -126,7 +126,7 @@ ULONG ScEEImport::Read( SvStream& rStream, const String& rBaseURL )
}
-void ScEEImport::WriteToDocument( BOOL bSizeColsRows, double nOutputFactor )
+void ScEEImport::WriteToDocument( BOOL bSizeColsRows, double nOutputFactor, SvNumberFormatter* pFormatter, bool bConvertDate )
{
ScProgress* pProgress = new ScProgress( mpDoc->GetDocumentShell(),
ScGlobal::GetRscString( STR_LOAD_DOC ), mpParser->Count() );
@@ -147,10 +147,12 @@ void ScEEImport::WriteToDocument( BOOL bSizeColsRows, double nOutputFactor )
nLastMergedRow = SCROW_MAX;
BOOL bHasGraphics = FALSE;
ScEEParseEntry* pE;
- SvNumberFormatter* pFormatter = mpDoc->GetFormatTable();
- bool bNumbersEnglishUS = (pFormatter->GetLanguage() != LANGUAGE_ENGLISH_US);
- if (bNumbersEnglishUS)
+ if (!pFormatter)
+ pFormatter = mpDoc->GetFormatTable();
+ bool bNumbersEnglishUS = false;
+ if (pFormatter->GetLanguage() == LANGUAGE_SYSTEM)
{
+ // Automatic language option selected. Check for the global 'use US English' option.
SvxHtmlOptions aOpt;
bNumbersEnglishUS = aOpt.IsNumbersEnglishUS();
}
@@ -332,7 +334,7 @@ void ScEEImport::WriteToDocument( BOOL bSizeColsRows, double nOutputFactor )
else if ( !pE->aSel.HasRange() )
{
// maybe ALT text of IMG or similar
- mpDoc->SetString( nCol, nRow, nTab, pE->aAltText );
+ mpDoc->SetString( nCol, nRow, nTab, pE->aAltText, pFormatter );
// wenn SelRange komplett leer kann nachfolgender Text im gleichen Absatz liegen!
}
else
@@ -377,7 +379,7 @@ void ScEEImport::WriteToDocument( BOOL bSizeColsRows, double nOutputFactor )
if (bNumbersEnglishUS && !bEnUsRecognized)
mpDoc->PutCell( nCol, nRow, nTab, new ScStringCell( aStr));
else
- mpDoc->SetString( nCol, nRow, nTab, aStr );
+ mpDoc->SetString( nCol, nRow, nTab, aStr, pFormatter, bConvertDate );
}
}
else
diff --git a/sc/source/filter/xcl97/xcl97esc.cxx b/sc/source/filter/xcl97/xcl97esc.cxx
index 2c5a30f085d3..a7c6dee67dc5 100644
--- a/sc/source/filter/xcl97/xcl97esc.cxx
+++ b/sc/source/filter/xcl97/xcl97esc.cxx
@@ -59,9 +59,11 @@
#include "xechart.hxx"
#include "xcl97esc.hxx"
+using ::rtl::OUString;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Exception;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
-using ::com::sun::star::uno::Exception;
using ::com::sun::star::uno::UNO_QUERY;
using ::com::sun::star::uno::UNO_QUERY_THROW;
using ::com::sun::star::container::XIndexAccess;
@@ -72,24 +74,40 @@ using ::com::sun::star::form::XFormsSupplier;
using ::com::sun::star::script::ScriptEventDescriptor;
using ::com::sun::star::script::XEventAttacherManager;
-// --- class XclEscherEx ---------------------------------------------
+// ============================================================================
-XclEscherEx::XclEscherEx( const XclExpRoot& rRoot, SvStream& rStrm, UINT32 nDrawings )
- :
- EscherEx( rStrm, nDrawings ),
- XclExpRoot( rRoot ),
- pPicTempFile( NULL ),
- pPicStrm( NULL ),
- pCurrXclObj( NULL ),
- pCurrAppData( NULL ),
- pTheClientData( new XclEscherClientData ),
- pAdditionalText( NULL ),
- nAdditionalText( 0 )
+XclEscherExGlobal::XclEscherExGlobal( const XclExpRoot& rRoot ) :
+ XclExpRoot( rRoot )
+{
+}
+
+SvStream* XclEscherExGlobal::ImplQueryPictureStream()
+{
+ mxPicTempFile.reset( new ::utl::TempFile );
+ if( mxPicTempFile->IsValid() )
+ {
+ mxPicTempFile->EnableKillingFile();
+ mxPicStrm.reset( ::utl::UcbStreamHelper::CreateStream( mxPicTempFile->GetURL(), STREAM_STD_READWRITE ) );
+ mxPicStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+ }
+ return mxPicStrm.get();
+}
+
+// ============================================================================
+
+XclEscherEx::XclEscherEx( const XclExpRoot& rRoot, XclExpObjectManager& rObjMgr, SvStream& rStrm, const XclEscherEx* pParent ) :
+ EscherEx( pParent ? pParent->mxGlobal : EscherExGlobalRef( new XclEscherExGlobal( rRoot ) ), rStrm ),
+ XclExpRoot( rRoot ),
+ mrObjMgr( rObjMgr ),
+ pCurrXclObj( NULL ),
+ pCurrAppData( NULL ),
+ pTheClientData( new XclEscherClientData ),
+ pAdditionalText( NULL ),
+ nAdditionalText( 0 ),
+ mnNextKey( 0 ),
+ mbIsRootDff( pParent == 0 )
{
- aOffsetMap.Insert( (void*) 0, LIST_APPEND ); // start of stream
- // Xcl forgets OLE objects completely if the Escher object is not EMF and
- // the corresponding OLE application is opened and nothing is changed.
- SetOleEmf( TRUE );
+ InsertPersistOffset( mnNextKey, 0 );
}
@@ -98,86 +116,83 @@ XclEscherEx::~XclEscherEx()
DBG_ASSERT( !aStack.Count(), "~XclEscherEx: stack not empty" );
DeleteCurrAppData();
delete pTheClientData;
- if ( pPicStrm )
- {
- delete pPicStrm;
- }
- if ( pPicTempFile )
- delete pPicTempFile;
}
-SvStream* XclEscherEx::QueryPicStream()
+sal_uInt32 XclEscherEx::InitNextDffFragment()
{
- if ( !pPicStrm )
- {
- if ( !pPicTempFile )
- {
- pPicTempFile = new utl::TempFile;
- if ( pPicTempFile->IsValid() )
- pPicTempFile->EnableKillingFile();
- else
- {
- delete pPicTempFile;
- pPicTempFile = NULL;
- }
- }
- if ( pPicTempFile )
- {
- pPicStrm = utl::UcbStreamHelper::CreateStream( pPicTempFile->GetURL(), STREAM_STD_READWRITE );
- pPicStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
- }
- }
- return pPicStrm;
+ /* Current value of mnNextKey will be used by caller to refer to the
+ starting point of the DFF fragment. The key exists already in the
+ PersistTable (has been inserted by c'tor of previous call of
+ InitNextDffFragment(), has been updated by UpdateDffFragmentEnd(). */
+ sal_uInt32 nPersistKey = mnNextKey;
+
+ /* Prepare the next key that is used by caller as end point of the DFF
+ fragment. Will be updated by caller when writing to the DFF stream,
+ using the UpdateDffFragmentEnd() function. This is needed to find DFF
+ data written by the SVX base class implementation without interaction,
+ e.g. the solver container that will be written after the last shape. */
+ ++mnNextKey;
+ InsertPersistOffset( mnNextKey, mpOutStrm->Tell() );
+
+ return nPersistKey;
}
-
-void XclEscherEx::InsertAtCurrentPos( UINT32 nBytes, BOOL bCont )
+void XclEscherEx::UpdateDffFragmentEnd()
{
- ULONG nPos = GetStreamPos();
- ULONG nCnt = aOffsetMap.Count();
- ULONG j, nOff;
- for ( j=0, nOff = (ULONG) aOffsetMap.First(); j<nCnt;
- j++, nOff = (ULONG) aOffsetMap.Next() )
- {
- if ( nOff >= nPos )
- aOffsetMap.Replace( (void*) (nOff + nBytes) );
- }
- EscherEx::InsertAtCurrentPos( nBytes, bCont );
+ // update existing fragment key with new stream position
+ ReplacePersistOffset( mnNextKey, mpOutStrm->Tell() );
}
-
-ULONG XclEscherEx::AddCurrentOffsetToMap()
+sal_uInt32 XclEscherEx::GetDffFragmentPos( sal_uInt32 nFragmentKey )
{
- aOffsetMap.Insert( (void*) GetStreamPos(), LIST_APPEND );
- return aOffsetMap.Count() - 1;
+ /* TODO: this function is non-const because PersistTable::PtGetOffsetByID()
+ is non-const due to tools/List usage. */
+ return GetPersistOffset( nFragmentKey );
}
+sal_uInt32 XclEscherEx::GetDffFragmentSize( sal_uInt32 nFragmentKey )
+{
+ /* TODO: this function is non-const because PersistTable::PtGetOffsetByID()
+ is non-const due to tools/List usage. */
+ return GetDffFragmentPos( nFragmentKey + 1 ) - GetDffFragmentPos( nFragmentKey );
+}
-void XclEscherEx::ReplaceCurrentOffsetInMap( ULONG nPos )
+bool XclEscherEx::HasPendingDffData()
{
- aOffsetMap.Replace( (void*) GetStreamPos(), nPos );
+ /* TODO: this function is non-const because PersistTable::PtGetOffsetByID()
+ is non-const due to tools/List usage. */
+ return GetDffFragmentPos( mnNextKey ) < GetStreamPos();
}
-sal_Bool ImplXclEscherExIsFontwork( const SdrObject* pObj )
+XclExpDffAnchorBase* XclEscherEx::CreateDffAnchor( const SdrObject& rSdrObj ) const
{
- const rtl::OUString sTextPath( RTL_CONSTASCII_USTRINGPARAM ( "TextPath" ) );
+ // the object manager creates the correct anchor type according to context
+ XclExpDffAnchorBase* pAnchor = mrObjMgr.CreateDffAnchor();
+ // pass the drawing object, that will calculate the anchor position
+ pAnchor->SetSdrObject( rSdrObj );
+ return pAnchor;
+}
- sal_Bool bIsFontwork = sal_False;
- if ( pObj->GetObjIdentifier() == OBJ_CUSTOMSHAPE )
+namespace {
+
+bool lcl_IsFontwork( const SdrObject* pObj )
+{
+ bool bIsFontwork = false;
+ if( pObj->GetObjIdentifier() == OBJ_CUSTOMSHAPE )
{
+ const OUString aTextPath = CREATE_OUSTRING( "TextPath" );
SdrCustomShapeGeometryItem& rGeometryItem = (SdrCustomShapeGeometryItem&)
pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
-
- com::sun::star::uno::Any* pAny = rGeometryItem.GetPropertyValueByName( sTextPath, sTextPath );
- if ( pAny )
+ if( Any* pAny = rGeometryItem.GetPropertyValueByName( aTextPath, aTextPath ) )
*pAny >>= bIsFontwork;
}
return bIsFontwork;
}
-EscherExHostAppData* XclEscherEx::StartShape( const com::sun::star::uno::Reference<
- com::sun::star::drawing::XShape >& rShape )
+} // namespace
+
+EscherExHostAppData* XclEscherEx::StartShape( const Reference< XShape >& rxShape, const Rectangle* pChildAnchor )
{
if ( nAdditionalText )
nAdditionalText++;
@@ -185,17 +200,17 @@ EscherExHostAppData* XclEscherEx::StartShape( const com::sun::star::uno::Referen
if ( bInGroup )
{ // stacked recursive group object
if ( !pCurrAppData->IsStackedGroup() )
- { //! UpdateStopPos only once
+ { //! UpdateDffFragmentEnd only once
pCurrAppData->SetStackedGroup( TRUE );
- pCurrXclObj->UpdateStopPos();
+ UpdateDffFragmentEnd();
}
}
aStack.Push( pCurrXclObj );
aStack.Push( pCurrAppData );
pCurrAppData = new XclEscherHostAppData;
- SdrObject* pObj = GetSdrObjectFromXShape( rShape );
+ SdrObject* pObj = GetSdrObjectFromXShape( rxShape );
if ( !pObj )
- pCurrXclObj = new XclObjAny( GetRoot() ); // just what is it?!?
+ pCurrXclObj = new XclObjAny( mrObjMgr ); // just what is it?!?
else
{
pCurrXclObj = NULL;
@@ -203,38 +218,50 @@ EscherExHostAppData* XclEscherEx::StartShape( const com::sun::star::uno::Referen
if( nObjType == OBJ_OLE2 )
{
- //! not-const because GetObjRef may load the OLE object
- Reference < XClassifiedObject > xObj( ((SdrOle2Obj*)pObj)->GetObjRef(), UNO_QUERY );
- if ( xObj.is() )
+ // no OLE objects in embedded drawings (chart shapes)
+ if( mbIsRootDff )
{
- SvGlobalName aObjClsId( xObj->getClassID() );
- if ( SotExchange::IsChart( aObjClsId ) )
- { // yes, it's a chart diagram
- GetOldRoot().pObjRecs->Add( new XclExpChartObj( GetRoot(), rShape ) );
- pCurrXclObj = NULL; // no metafile or whatsoever
+ //! not-const because GetObjRef may load the OLE object
+ Reference < XClassifiedObject > xObj( ((SdrOle2Obj*)pObj)->GetObjRef(), UNO_QUERY );
+ if ( xObj.is() )
+ {
+ SvGlobalName aObjClsId( xObj->getClassID() );
+ if ( SotExchange::IsChart( aObjClsId ) )
+ { // yes, it's a chart diagram
+ mrObjMgr.AddObj( new XclExpChartObj( mrObjMgr, rxShape, pChildAnchor ) );
+ pCurrXclObj = NULL; // no metafile or whatsoever
+ }
+ else // metafile and OLE object
+ pCurrXclObj = new XclObjOle( mrObjMgr, *pObj );
}
- else // metafile and OLE object
- pCurrXclObj = new XclObjOle( GetRoot(), *pObj );
+ else // just a metafile
+ pCurrXclObj = new XclObjAny( mrObjMgr );
}
- else // just a metafile
- pCurrXclObj = new XclObjAny( GetRoot() );
+ else
+ pCurrXclObj = new XclObjAny( mrObjMgr );
}
else if( nObjType == OBJ_UNO )
{
- pCurrXclObj = CreateCtrlObj( rShape );
+#if EXC_EXP_OCX_CTRL
+ // no ActiveX controls in embedded drawings (chart shapes)
+ if( mbIsRootDff )
+ pCurrXclObj = CreateCtrlObj( rxShape, pChildAnchor );
+#else
+ pCurrXclObj = CreateCtrlObj( rxShape, pChildAnchor );
+#endif
if( !pCurrXclObj )
- pCurrXclObj = new XclObjAny( GetRoot() ); // just a metafile
+ pCurrXclObj = new XclObjAny( mrObjMgr ); // just a metafile
}
else if( !ScDrawLayer::IsNoteCaption( pObj ) )
{
// #107540# ignore permanent note shapes
// #i12190# do not ignore callouts (do not filter by object type ID)
- pCurrXclObj = new XclObjAny( GetRoot() ); // just a metafile
+ pCurrXclObj = new XclObjAny( mrObjMgr ); // just a metafile
}
}
if ( pCurrXclObj )
{
- if ( !GetOldRoot().pObjRecs->Add( pCurrXclObj ) )
+ if ( !mrObjMgr.AddObj( pCurrXclObj ) )
{ // maximum count reached, object got deleted
pCurrXclObj = NULL;
}
@@ -247,14 +274,15 @@ EscherExHostAppData* XclEscherEx::StartShape( const com::sun::star::uno::Referen
{
if ( !bInGroup )
{
- /* Create a dummy anchor carrying the flags. Real coordinates are
- calculated later in WriteData(EscherEx&,const Rectangle&). */
- XclExpDffAnchor* pAnchor = new XclExpDffAnchor( GetRoot() );
+ /* Create a dummy anchor carrying the flags. Real
+ coordinates are calculated later in virtual call of
+ WriteData(EscherEx&,const Rectangle&). */
+ XclExpDffAnchorBase* pAnchor = mrObjMgr.CreateDffAnchor();
pAnchor->SetFlags( *pObj );
pCurrAppData->SetClientAnchor( pAnchor );
}
const SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, pObj );
- if ( pTextObj && !ImplXclEscherExIsFontwork( pTextObj ) && ( pObj->GetObjIdentifier() != OBJ_CAPTION ) )
+ if( pTextObj && !lcl_IsFontwork( pTextObj ) && (pObj->GetObjIdentifier() != OBJ_CAPTION) )
{
const OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
if( pParaObj )
@@ -265,7 +293,7 @@ EscherExHostAppData* XclEscherEx::StartShape( const com::sun::star::uno::Referen
else
{
if ( !bInGroup )
- pCurrAppData->SetClientAnchor( new XclExpDffAnchor( GetRoot() ) );
+ pCurrAppData->SetClientAnchor( mrObjMgr.CreateDffAnchor() );
}
}
else if ( nAdditionalText == 3 )
@@ -295,13 +323,10 @@ void XclEscherEx::EndShape( UINT16 nShapeType, UINT32 nShapeID )
// escher data of last shape not written? -> delete it from object list
if( nShapeID == 0 )
{
- XclObj* pLastObj = static_cast< XclObj* >( GetOldRoot().pObjRecs->Last() );
+ XclObj* pLastObj = mrObjMgr.RemoveLastObj();
DBG_ASSERT( pLastObj == pCurrXclObj, "XclEscherEx::EndShape - wrong object" );
- if ( pLastObj == pCurrXclObj )
- {
- GetOldRoot().pObjRecs->Remove();
- DELETEZ( pCurrXclObj );
- }
+ DELETEZ( pLastObj );
+ pCurrXclObj = 0;
}
if( pCurrXclObj )
@@ -312,7 +337,7 @@ void XclEscherEx::EndShape( UINT16 nShapeType, UINT32 nShapeID )
else
{
pCurrXclObj->SetEscherShapeType( nShapeType );
- pCurrXclObj->UpdateStopPos();
+ UpdateDffFragmentEnd();
}
}
}
@@ -335,26 +360,18 @@ EscherExHostAppData* XclEscherEx::EnterAdditionalTextGroup()
}
-void XclEscherEx::DeleteCurrAppData()
-{
- if ( pCurrAppData )
- {
- delete pCurrAppData->GetClientAnchor();
-// delete pCurrAppData->GetClientData();
- delete pCurrAppData->GetClientTextbox();
- delete pCurrAppData;
- }
-}
-
-
void XclEscherEx::EndDocument()
{
- Flush( pPicStrm );
+ if( mbIsRootDff )
+ Flush( static_cast< XclEscherExGlobal& >( *mxGlobal ).GetPictureStream() );
+
+ // seek back DFF stream to prepare saving the MSODRAWING[GROUP] records
+ mpOutStrm->Seek( 0 );
}
#if EXC_EXP_OCX_CTRL
-XclExpOcxControlObj* XclEscherEx::CreateCtrlObj( Reference< XShape > xShape )
+XclExpOcxControlObj* XclEscherEx::CreateCtrlObj( Reference< XShape > xShape, const Rectangle* pChildAnchor )
{
::std::auto_ptr< XclExpOcxControlObj > xOcxCtrl;
@@ -375,7 +392,7 @@ XclExpOcxControlObj* XclEscherEx::CreateCtrlObj( Reference< XShape > xShape )
sal_uInt32 nStrmSize = static_cast< sal_uInt32 >( mxCtlsStrm->Tell() - nStrmStart );
// adjust the class name to "Forms.***.1"
aClassName.InsertAscii( "Forms.", 0 ).AppendAscii( ".1" );
- xOcxCtrl.reset( new XclExpOcxControlObj( GetRoot(), xShape, aClassName, nStrmStart, nStrmSize ) );
+ xOcxCtrl.reset( new XclExpOcxControlObj( mrObjMgr, xShape, pChildAnchor, aClassName, nStrmStart, nStrmSize ) );
}
}
}
@@ -384,9 +401,9 @@ XclExpOcxControlObj* XclEscherEx::CreateCtrlObj( Reference< XShape > xShape )
#else
-XclExpTbxControlObj* XclEscherEx::CreateCtrlObj( Reference< XShape > xShape )
+XclExpTbxControlObj* XclEscherEx::CreateCtrlObj( Reference< XShape > xShape, const Rectangle* pChildAnchor )
{
- ::std::auto_ptr< XclExpTbxControlObj > xTbxCtrl( new XclExpTbxControlObj( GetRoot(), xShape ) );
+ ::std::auto_ptr< XclExpTbxControlObj > xTbxCtrl( new XclExpTbxControlObj( mrObjMgr, xShape, pChildAnchor ) );
if( xTbxCtrl->GetObjType() == EXC_OBJTYPE_UNKNOWN )
xTbxCtrl.reset();
@@ -454,98 +471,17 @@ void XclEscherEx::ConvertTbxMacro( XclExpTbxControlObj& rTbxCtrlObj, Reference<
#endif
-// --- class XclEscher -----------------------------------------------
-
-XclEscher::XclEscher( const XclExpRoot& rRoot, UINT32 nDrawings ) :
- XclExpRoot( rRoot )
-{
- pTempFile = new utl::TempFile;
- pTempFile->EnableKillingFile();
- pStrm = utl::UcbStreamHelper::CreateStream( pTempFile->GetURL(), STREAM_STD_READWRITE );
- pStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
- pEx = new XclEscherEx( rRoot, *pStrm, nDrawings );
-}
-
-
-XclEscher::~XclEscher()
-{
- delete pEx;
- delete pStrm;
- delete pTempFile;
-}
-
-
-void XclEscher::AddSdrPage()
-{
- if( SdrPage* pPage = GetSdrPage( GetCurrScTab() ) )
- pEx->AddSdrPage( *pPage );
- // #106213# the first dummy object may still be open
- DBG_ASSERT( pEx->GetGroupLevel() <= 1, "XclEscher::AddSdrPage - still groups open?" );
- while( pEx->GetGroupLevel() )
- pEx->LeaveGroup();
-}
-
-
-// Escher client anchor =======================================================
-
-XclExpDffAnchor::XclExpDffAnchor( const XclExpRoot& rRoot, sal_uInt16 nFlags ) :
- XclExpRoot( rRoot ),
- maAnchor( rRoot.GetCurrScTab() ),
- mnFlags( nFlags )
-{
-}
-
-XclExpDffAnchor::XclExpDffAnchor( const XclExpRoot& rRoot, const SdrObject& rSdrObj ) :
- XclExpRoot( rRoot ),
- maAnchor( rRoot.GetCurrScTab() )
-{
- SetFlags( rSdrObj );
- maAnchor.SetRect( GetDoc(), rSdrObj.GetCurrentBoundRect(), MAP_100TH_MM );
-}
-
-void XclExpDffAnchor::SetFlags( const SdrObject& rSdrObj )
-{
- // Special case "page anchor" (X==0,Y==1) -> lock pos and size.
- const Point& rPos = rSdrObj.GetAnchorPos();
- mnFlags = ((rPos.X() == 0) && (rPos.Y() == 1)) ? EXC_ESC_ANCHOR_LOCKED : 0;
-}
-
-void XclExpDffAnchor::WriteData( EscherEx& rEx, const Rectangle& rRect )
-{
- // the rectangle is already in twips
- maAnchor.SetRect( GetDoc(), rRect, MAP_TWIP );
- WriteData( rEx );
-}
-
-
-void XclExpDffAnchor::WriteData( EscherEx& rEx ) const
-{
- rEx.AddAtom( 18, ESCHER_ClientAnchor );
- rEx.GetStream() << mnFlags << maAnchor;
-}
-
-
-// ----------------------------------------------------------------------------
-
-XclExpDffNoteAnchor::XclExpDffNoteAnchor( const XclExpRoot& rRoot, const Rectangle& rRect ) :
- XclExpDffAnchor( rRoot, EXC_ESC_ANCHOR_SIZELOCKED )
-{
- maAnchor.SetRect( GetDoc(), rRect, MAP_100TH_MM );
-}
-
-
-// ----------------------------------------------------------------------------
-
-XclExpDffDropDownAnchor::XclExpDffDropDownAnchor( const XclExpRoot& rRoot, const ScAddress& rScPos ) :
- XclExpDffAnchor( rRoot, EXC_ESC_ANCHOR_POSLOCKED )
+void XclEscherEx::DeleteCurrAppData()
{
- GetAddressConverter().ConvertAddress( maAnchor.maFirst, rScPos, true );
- maAnchor.maLast.mnCol = maAnchor.maFirst.mnCol + 1;
- maAnchor.maLast.mnRow = maAnchor.maFirst.mnRow + 1;
- maAnchor.mnLX = maAnchor.mnTY = maAnchor.mnRX = maAnchor.mnBY = 0;
+ if ( pCurrAppData )
+ {
+ delete pCurrAppData->GetClientAnchor();
+// delete pCurrAppData->GetClientData();
+ delete pCurrAppData->GetClientTextbox();
+ delete pCurrAppData;
+ }
}
-
// ============================================================================
// --- class XclEscherClientData -------------------------------------
diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx
index e4c4443ea56e..67a295ccec8b 100644
--- a/sc/source/filter/xcl97/xcl97rec.cxx
+++ b/sc/source/filter/xcl97/xcl97rec.cxx
@@ -49,6 +49,7 @@
#include "xcl97esc.hxx"
#include "editutil.hxx"
#include "xecontent.hxx"
+#include "xeescher.hxx"
#include "xestyle.hxx"
#include "xelink.hxx"
@@ -86,158 +87,22 @@ using ::com::sun::star::uno::UNO_QUERY;
using ::com::sun::star::beans::XPropertySet;
using ::com::sun::star::drawing::XShape;
+// ============================================================================
-//___________________________________________________________________
-
-// --- class XclMsodrawing_Base --------------------------------------
-
-XclMsodrawing_Base::XclMsodrawing_Base( XclEscher& rEscher, sal_Size nInitialSize )
- :
- pEscher( &rEscher ),
- nStartPos( rEscher.GetEx()->GetLastOffsetMapPos() )
-{
- // for safety's sake add this now
- nStopPos = GetEscherEx()->AddCurrentOffsetToMap();
- (void)nInitialSize; // avoid compiler warning
- DBG_ASSERT( GetDataLen() == nInitialSize, "XclMsodrawing_Base ctor: do I really own that data?" );
-}
-
-
-XclMsodrawing_Base::~XclMsodrawing_Base()
-{
-}
-
-
-void XclMsodrawing_Base::UpdateStopPos()
-{
- if ( nStopPos > 0 )
- GetEscherEx()->ReplaceCurrentOffsetInMap( nStopPos );
- else
- nStopPos = GetEscherEx()->AddCurrentOffsetToMap();
-}
-
-
-sal_Size XclMsodrawing_Base::GetDataLen() const
-{
- if ( nStartPos < nStopPos )
- {
- XclEscherEx* pEx = GetEscherEx();
- return pEx->GetOffsetFromMap( nStopPos ) - pEx->GetOffsetFromMap( nStartPos );
- }
- DBG_ERRORFILE( "XclMsodrawing_Base::GetDataLen: position mismatch" );
- return 0;
-}
-
-
-
-// --- class XclMsodrawinggroup --------------------------------------
-
-XclMsodrawinggroup::XclMsodrawinggroup( RootData& rRoot, UINT16 nEscherType ) :
- XclMsodrawing_Base( *rRoot.pEscher ),
- XclExpRecord(0x00EB, 2) // bogus record size since we don't know the actual size yet.
-{
- if ( nEscherType )
- {
- XclEscherEx* pEx = GetEscherEx();
- SvStream& rOut = pEx->GetStream();
- switch ( nEscherType )
- {
- case ESCHER_DggContainer :
- { // per-document data
- pEx->OpenContainer( nEscherType );
-//2do: stuff it with our own document defaults?
-#if 0
- pEx->BeginCount();
- pEx->AddOpt( ... );
- pEx->EndCount( ESCHER_OPT, 3 );
-#else
- BYTE pDummyOPT[] = {
- 0xBF, 0x00, 0x08, 0x00, 0x08, 0x00, 0x81, 0x01,
- 0x09, 0x00, 0x00, 0x08, 0xC0, 0x01, 0x40, 0x00,
- 0x00, 0x08
- };
- pEx->AddAtom( sizeof(pDummyOPT), ESCHER_OPT, 3, 3 );
- rOut.Write( pDummyOPT, sizeof(pDummyOPT) );
-#endif
- BYTE pDummySplitMenuColors[] = {
- 0x0D, 0x00, 0x00, 0x08, 0x0C, 0x00, 0x00, 0x08,
- 0x17, 0x00, 0x00, 0x08, 0xF7, 0x00, 0x00, 0x10
- };
- pEx->AddAtom( sizeof(pDummySplitMenuColors), ESCHER_SplitMenuColors, 0, 4 );
- rOut.Write( pDummySplitMenuColors, sizeof(pDummySplitMenuColors) );
- pEx->CloseContainer(); // ESCHER_DggContainer
- }
- break;
- }
- UpdateStopPos();
- }
-}
-
-
-XclMsodrawinggroup::~XclMsodrawinggroup()
-{
-}
-
-
-void XclMsodrawinggroup::WriteBody( XclExpStream& rStrm )
-{
- DBG_ASSERT( GetEscherEx()->GetStreamPos() == GetEscherEx()->GetOffsetFromMap( nStartPos ),
- "XclMsodrawinggroup::SaveCont: Escher stream position mismatch" );
- rStrm.CopyFromStream( pEscher->GetStrm(), GetDataLen() );
-}
-
-
-// --- class XclMsodrawing --------------------------------------
-
-XclMsodrawing::XclMsodrawing( const XclExpRoot& rRoot, UINT16 nEscherType, sal_Size nInitialSize ) :
- XclMsodrawing_Base( *rRoot.GetOldRoot().pEscher, nInitialSize ),
- XclExpRecord( 0x00EC, nInitialSize )
-{
- if ( nEscherType )
- {
- XclEscherEx* pEx = GetEscherEx();
- switch ( nEscherType )
- {
- case ESCHER_DgContainer :
- { // per-sheet data
- pEx->OpenContainer( nEscherType );
- // open group shape container
- Rectangle aRect( 0, 0, 0, 0 );
- pEx->EnterGroup( &aRect );
- }
- break;
- }
- UpdateStopPos();
- }
-}
-
-
-XclMsodrawing::~XclMsodrawing()
-{
-}
-
-
-void XclMsodrawing::WriteBody( XclExpStream& rStrm )
-{
- DBG_ASSERT( GetEscherEx()->GetStreamPos() == GetEscherEx()->GetOffsetFromMap( nStartPos ),
- "XclMsodrawing::SaveCont: Escher stream position mismatch" );
- rStrm.CopyFromStream( pEscher->GetStrm(), GetDataLen() );
-}
-
-
-
-
-// --- class XclObjList ----------------------------------------------
-
-XclObjList::XclObjList( const XclExpRoot& rRoot ) :
+XclExpObjList::XclExpObjList( const XclExpRoot& rRoot, XclEscherEx& rEscherEx ) :
XclExpRoot( rRoot ),
- pMsodrawingPerSheet( new XclMsodrawing( rRoot, ESCHER_DgContainer ) ),
- pSolverContainer( NULL )
+ mrEscherEx( rEscherEx ),
+ pSolverContainer( 0 )
{
+ pMsodrawingPerSheet = new XclExpMsoDrawing( rEscherEx );
+ // open the DGCONTAINER and the patriarch group shape
+ mrEscherEx.OpenContainer( ESCHER_DgContainer );
+ Rectangle aRect( 0, 0, 0, 0 );
+ mrEscherEx.EnterGroup( &aRect );
+ mrEscherEx.UpdateDffFragmentEnd();
}
-
-XclObjList::~XclObjList()
+XclExpObjList::~XclExpObjList()
{
for ( XclObj* p = First(); p; p = Next() )
delete p;
@@ -245,10 +110,9 @@ XclObjList::~XclObjList()
delete pSolverContainer;
}
-
-UINT16 XclObjList::Add( XclObj* pObj )
+UINT16 XclExpObjList::Add( XclObj* pObj )
{
- DBG_ASSERT( Count() < 0xFFFF, "XclObjList::Add: too much for Xcl" );
+ DBG_ASSERT( Count() < 0xFFFF, "XclExpObjList::Add: too much for Xcl" );
if ( Count() < 0xFFFF )
{
Insert( pObj, LIST_APPEND );
@@ -263,22 +127,17 @@ UINT16 XclObjList::Add( XclObj* pObj )
}
}
-
-void XclObjList::EndSheet()
+void XclExpObjList::EndSheet()
{
- XclEscherEx* pEx = pMsodrawingPerSheet->GetEscherEx();
-
// Is there still something in the stream? -> The solver container
- sal_Size nSolverSize = pEx->GetStreamPos() - pEx->GetOffsetFromMap( pEx->GetLastOffsetMapPos() );
- if( nSolverSize > 0 )
- pSolverContainer = new XclMsodrawing( GetRoot(), ESCHER_SolverContainer, nSolverSize );
+ if( mrEscherEx.HasPendingDffData() )
+ pSolverContainer = new XclExpMsoDrawing( mrEscherEx );
- //! close ESCHER_DgContainer created by XclObjList ctor MSODRAWING
- pEx->CloseContainer();
+ // close the DGCONTAINER created by XclExpObjList ctor MSODRAWING
+ mrEscherEx.CloseContainer();
}
-
-void XclObjList::Save( XclExpStream& rStrm )
+void XclExpObjList::Save( XclExpStream& rStrm )
{
//! Escher must be written, even if there are no objects
pMsodrawingPerSheet->Save( rStrm );
@@ -290,28 +149,26 @@ void XclObjList::Save( XclExpStream& rStrm )
pSolverContainer->Save( rStrm );
}
-
-
// --- class XclObj --------------------------------------------------
-XclObj::XclObj( const XclExpRoot& rRoot, sal_uInt16 nObjType, bool bOwnEscher ) :
+XclObj::XclObj( XclExpObjectManager& rObjMgr, sal_uInt16 nObjType, bool bOwnEscher ) :
XclExpRecord( EXC_ID_OBJ, 26 ),
+ mrEscherEx( rObjMgr.GetEscherEx() ),
pClientTextbox( NULL ),
pTxo( NULL ),
mnObjType( nObjType ),
nObjId(0),
nGrbit( 0x6011 ), // AutoLine, AutoFill, Printable, Locked
- bFirstOnSheet( rRoot.GetOldRoot().pObjRecs->Count() == 0 ),
+ bFirstOnSheet( !rObjMgr.HasObj() ),
mbOwnEscher( bOwnEscher )
{
//! first object continues the first MSODRAWING record
if ( bFirstOnSheet )
- pMsodrawing = rRoot.GetOldRoot().pObjRecs->GetMsodrawingPerSheet();
+ pMsodrawing = rObjMgr.GetMsodrawingPerSheet();
else
- pMsodrawing = new XclMsodrawing( rRoot );
+ pMsodrawing = new XclExpMsoDrawing( mrEscherEx );
}
-
XclObj::~XclObj()
{
if ( !bFirstOnSheet )
@@ -320,6 +177,18 @@ XclObj::~XclObj()
delete pTxo;
}
+void XclObj::ImplWriteAnchor( const XclExpRoot& /*rRoot*/, const SdrObject* pSdrObj, const Rectangle* pChildAnchor )
+{
+ if( pChildAnchor )
+ {
+ mrEscherEx.AddChildAnchor( *pChildAnchor );
+ }
+ else if( pSdrObj )
+ {
+ ::std::auto_ptr< XclExpDffAnchorBase > xDffAnchor( mrEscherEx.CreateDffAnchor( *pSdrObj ) );
+ xDffAnchor->WriteDffData( mrEscherEx );
+ }
+}
void XclObj::SetEscherShapeType( UINT16 nType )
{
@@ -350,21 +219,19 @@ void XclObj::SetEscherShapeType( UINT16 nType )
}
}
-
void XclObj::SetText( const XclExpRoot& rRoot, const SdrTextObj& rObj )
{
DBG_ASSERT( !pClientTextbox, "XclObj::SetText: already set" );
if ( !pClientTextbox )
{
- pMsodrawing->UpdateStopPos();
- pClientTextbox = new XclMsodrawing( rRoot );
- pClientTextbox->GetEscherEx()->AddAtom( 0, ESCHER_ClientTextbox ); // TXO record
- pClientTextbox->UpdateStopPos();
+ mrEscherEx.UpdateDffFragmentEnd();
+ pClientTextbox = new XclExpMsoDrawing( mrEscherEx );
+ mrEscherEx.AddAtom( 0, ESCHER_ClientTextbox ); // TXO record
+ mrEscherEx.UpdateDffFragmentEnd();
pTxo = new XclTxo( rRoot, rObj );
}
}
-
void XclObj::WriteBody( XclExpStream& rStrm )
{
DBG_ASSERT( mnObjType != EXC_OBJTYPE_UNKNOWN, "XclObj::WriteBody - unknown type" );
@@ -392,7 +259,6 @@ void XclObj::WriteBody( XclExpStream& rStrm )
rStrm.CopyFromStream( aMemStrm );
}
-
void XclObj::Save( XclExpStream& rStrm )
{
// MSODRAWING record (msofbtSpContainer)
@@ -406,7 +272,6 @@ void XclObj::Save( XclExpStream& rStrm )
SaveTextRecs( rStrm );
}
-
void XclObj::WriteSubRecs( XclExpStream& /*rStrm*/ )
{
}
@@ -421,17 +286,14 @@ void XclObj::SaveTextRecs( XclExpStream& rStrm )
pTxo->Save( rStrm );
}
-
// --- class XclObjComment -------------------------------------------
-
-XclObjComment::XclObjComment( const XclExpRoot& rRoot, const Rectangle& rRect, const EditTextObject& rEditObj, SdrObject* pCaption, bool bVisible )
- :
- XclObj( rRoot, EXC_OBJTYPE_NOTE, true )
+XclObjComment::XclObjComment( XclExpObjectManager& rObjMgr, const Rectangle& rRect, const EditTextObject& rEditObj, SdrObject* pCaption, bool bVisible ) :
+ XclObj( rObjMgr, EXC_OBJTYPE_NOTE, true )
{
- ProcessEscherObj(rRoot, rRect, pCaption, bVisible);
+ ProcessEscherObj( rObjMgr.GetRoot(), rRect, pCaption, bVisible);
// TXO
- pTxo = new XclTxo( rRoot, rEditObj, pCaption );
+ pTxo = new XclTxo( rObjMgr.GetRoot(), rEditObj, pCaption );
}
void XclObjComment::ProcessEscherObj( const XclExpRoot& rRoot, const Rectangle& rRect, SdrObject* pCaption, const bool bVisible )
@@ -482,66 +344,62 @@ void XclObjComment::ProcessEscherObj( const XclExpRoot& rRoot, const Rectangle&
}
nGrbit = 0; // all off: AutoLine, AutoFill, Printable, Locked
- XclEscherEx* pEx = pMsodrawing->GetEscherEx();
- pEx->OpenContainer( ESCHER_SpContainer );
- pEx->AddShape( ESCHER_ShpInst_TextBox, SHAPEFLAG_HAVEANCHOR | SHAPEFLAG_HAVESPT );
+ mrEscherEx.OpenContainer( ESCHER_SpContainer );
+ mrEscherEx.AddShape( ESCHER_ShpInst_TextBox, SHAPEFLAG_HAVEANCHOR | SHAPEFLAG_HAVESPT );
sal_uInt32 nFlags = 0x000A0000;
::set_flag( nFlags, sal_uInt32(2), !bVisible );
aPropOpt.AddOpt( ESCHER_Prop_fPrint, nFlags ); // bool field
- aPropOpt.Commit( pEx->GetStream() );
+ aPropOpt.Commit( mrEscherEx.GetStream() );
- XclExpDffNoteAnchor( rRoot, rRect ).WriteData( *pEx);
+ XclExpDffNoteAnchor( rRoot, rRect ).WriteDffData( mrEscherEx );
+
+ mrEscherEx.AddAtom( 0, ESCHER_ClientData ); // OBJ record
+ mrEscherEx.UpdateDffFragmentEnd();
- pEx->AddAtom( 0, ESCHER_ClientData ); // OBJ record
- pMsodrawing->UpdateStopPos();
//! Be sure to construct the MSODRAWING ClientTextbox record _after_ the
//! base OBJ's MSODRAWING record Escher data is completed.
- pClientTextbox = new XclMsodrawing( rRoot );
- pClientTextbox->GetEscherEx()->AddAtom( 0, ESCHER_ClientTextbox ); // TXO record
- pClientTextbox->UpdateStopPos();
- pEx->CloseContainer(); // ESCHER_SpContainer
+ pClientTextbox = new XclExpMsoDrawing( mrEscherEx );
+ mrEscherEx.AddAtom( 0, ESCHER_ClientTextbox ); // TXO record
+ mrEscherEx.UpdateDffFragmentEnd();
+ mrEscherEx.CloseContainer(); // ESCHER_SpContainer
}
-
XclObjComment::~XclObjComment()
{
}
-
void XclObjComment::Save( XclExpStream& rStrm )
{
// content of this record
XclObj::Save( rStrm );
}
-
// --- class XclObjDropDown ------------------------------------------
-XclObjDropDown::XclObjDropDown( const XclExpRoot& rRoot, const ScAddress& rPos, BOOL bFilt ) :
- XclObj( rRoot, EXC_OBJTYPE_DROPDOWN, true ),
- bIsFiltered( bFilt )
+XclObjDropDown::XclObjDropDown( XclExpObjectManager& rObjMgr, const ScAddress& rPos, BOOL bFilt ) :
+ XclObj( rObjMgr, EXC_OBJTYPE_DROPDOWN, true ),
+ bIsFiltered( bFilt )
{
SetLocked( TRUE );
SetPrintable( FALSE );
SetAutoFill( TRUE );
SetAutoLine( FALSE );
nGrbit |= 0x0100; // undocumented
- XclEscherEx* pEx = pMsodrawing->GetEscherEx();
- pEx->OpenContainer( ESCHER_SpContainer );
- pEx->AddShape( ESCHER_ShpInst_HostControl, SHAPEFLAG_HAVEANCHOR | SHAPEFLAG_HAVESPT );
+ mrEscherEx.OpenContainer( ESCHER_SpContainer );
+ mrEscherEx.AddShape( ESCHER_ShpInst_HostControl, SHAPEFLAG_HAVEANCHOR | SHAPEFLAG_HAVESPT );
EscherPropertyContainer aPropOpt;
aPropOpt.AddOpt( ESCHER_Prop_LockAgainstGrouping, 0x01040104 ); // bool field
aPropOpt.AddOpt( ESCHER_Prop_FitTextToShape, 0x00080008 ); // bool field
aPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x00010000 ); // bool field
aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x00080000 ); // bool field
aPropOpt.AddOpt( ESCHER_Prop_fPrint, 0x000A0000 ); // bool field
- aPropOpt.Commit( pEx->GetStream() );
+ aPropOpt.Commit( mrEscherEx.GetStream() );
- XclExpDffDropDownAnchor( rRoot, rPos ).WriteData( *pEx );
+ XclExpDffDropDownAnchor( rObjMgr.GetRoot(), rPos ).WriteDffData( mrEscherEx );
- pEx->AddAtom( 0, ESCHER_ClientData ); // OBJ record
- pMsodrawing->UpdateStopPos();
- pEx->CloseContainer(); // ESCHER_SpContainer
+ mrEscherEx.AddAtom( 0, ESCHER_ClientData ); // OBJ record
+ mrEscherEx.UpdateDffFragmentEnd();
+ mrEscherEx.CloseContainer(); // ESCHER_SpContainer
// old size + ftSbs + ftLbsData
AddRecSize( 24 + 20 );
@@ -568,7 +426,6 @@ void XclObjDropDown::WriteSubRecs( XclExpStream& rStrm )
rStrm.EndRecord();
}
-
// --- class XclTxo --------------------------------------------------
sal_uInt8 lcl_GetHorAlignFromItemSet( const SfxItemSet& rItemSet )
@@ -725,22 +582,19 @@ sal_Size XclTxo::GetLen() const
return 18;
}
-
// --- class XclObjOle -------------------------------------------
-XclObjOle::XclObjOle( const XclExpRoot& rRoot, const SdrObject& rObj ) :
- XclObj( rRoot, EXC_OBJTYPE_PICTURE ),
+XclObjOle::XclObjOle( XclExpObjectManager& rObjMgr, const SdrObject& rObj ) :
+ XclObj( rObjMgr, EXC_OBJTYPE_PICTURE ),
rOleObj( rObj ),
- pRootStorage( rRoot.GetRootStorage() )
+ pRootStorage( rObjMgr.GetRoot().GetRootStorage() )
{
}
-
XclObjOle::~XclObjOle()
{
}
-
void XclObjOle::WriteSubRecs( XclExpStream& rStrm )
{
// write only as embedded, not linked
@@ -810,18 +664,16 @@ void XclObjOle::WriteSubRecs( XclExpStream& rStrm )
}
}
-
void XclObjOle::Save( XclExpStream& rStrm )
{
// content of this record
XclObj::Save( rStrm );
}
-
// --- class XclObjAny -------------------------------------------
-XclObjAny::XclObjAny( const XclExpRoot& rRoot ) :
- XclObj( rRoot, EXC_OBJTYPE_UNKNOWN )
+XclObjAny::XclObjAny( XclExpObjectManager& rObjMgr ) :
+ XclObj( rObjMgr, EXC_OBJTYPE_UNKNOWN )
{
}
@@ -846,7 +698,6 @@ void XclObjAny::Save( XclExpStream& rStrm )
XclObj::Save( rStrm );
}
-
// --- class ExcBof8_Base --------------------------------------------
ExcBof8_Base::ExcBof8_Base()
diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx
index 580dd2ee0791..93e529c4ceca 100644
--- a/sc/source/filter/xml/xmldpimp.cxx
+++ b/sc/source/filter/xml/xmldpimp.cxx
@@ -428,7 +428,7 @@ void ScXMLDataPilotTableContext::EndElement()
break;
case SERVICE :
{
- ScDPServiceDesc aServiceDesk(sServiceName, sServiceSourceObject, sServiceSourceName,
+ ScDPServiceDesc aServiceDesk(sServiceName, sServiceSourceName, sServiceSourceObject,
sServiceUsername, sServicePassword);
pDPObject->SetServiceData(aServiceDesk);
}
@@ -1453,6 +1453,7 @@ ScXMLDataPilotSubTotalContext::ScXMLDataPilotSubTotalContext( ScXMLImport& rImpo
pDataPilotSubTotals->AddFunction( sal::static_int_cast<sal_Int16>(
ScXMLConverter::GetFunctionFromString( sValue ) ) );
}
+ break;
case XML_TOK_DATA_PILOT_SUBTOTAL_ATTR_DISPLAY_NAME:
case XML_TOK_DATA_PILOT_SUBTOTAL_ATTR_DISPLAY_NAME_EXT:
pDataPilotSubTotals->SetDisplayName(sValue);
diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx
index 1c1126e07640..4c65632fb45e 100644
--- a/sc/source/ui/Accessibility/AccessibleDocument.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx
@@ -963,18 +963,14 @@ void ScChildrenShapes::FillSelectionSupplier() const
SfxViewFrame* pViewFrame = mpViewShell->GetViewFrame();
if (pViewFrame)
{
- SfxFrame* pFrame = pViewFrame->GetFrame();
- if (pFrame)
+ xSelectionSupplier = uno::Reference<view::XSelectionSupplier>(pViewFrame->GetFrame().GetController(), uno::UNO_QUERY);
+ if (xSelectionSupplier.is())
{
- xSelectionSupplier = uno::Reference<view::XSelectionSupplier>(pFrame->GetController(), uno::UNO_QUERY);
- if (xSelectionSupplier.is())
- {
- if (mpAccessibleDocument)
- xSelectionSupplier->addSelectionChangeListener(mpAccessibleDocument);
- uno::Reference<drawing::XShapes> xShapes (xSelectionSupplier->getSelection(), uno::UNO_QUERY);
- if (xShapes.is())
- mnShapesSelected = xShapes->getCount();
- }
+ if (mpAccessibleDocument)
+ xSelectionSupplier->addSelectionChangeListener(mpAccessibleDocument);
+ uno::Reference<drawing::XShapes> xShapes (xSelectionSupplier->getSelection(), uno::UNO_QUERY);
+ if (xShapes.is())
+ mnShapesSelected = xShapes->getCount();
}
}
}
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 5ea8c4d78e0f..f6fc2cb27b71 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -768,8 +768,9 @@ __EXPORT ScTextWnd::~ScTextWnd()
{
delete pEditView;
delete pEditEngine;
- for( AccTextDataVector::reverse_iterator aIt = maAccTextDatas.rbegin(), aEnd = maAccTextDatas.rend(); aIt != aEnd; ++aIt )
- (*aIt)->Dispose();
+ while (!maAccTextDatas.empty()) {
+ maAccTextDatas.back()->Dispose();
+ }
}
void __EXPORT ScTextWnd::Paint( const Rectangle& rRec )
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index a6be71a99426..73a5f1a1c4ee 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -72,6 +72,7 @@
#include "validate.hxx" //add for ScValidationDlg
#include "validate.hrc" //add for ScValidationDlg
#include "sortdlg.hxx" //add for ScSortDlg
+#include "textimportoptions.hxx"
#include "opredlin.hxx" //add for ScRedlineOptionsTabPage
#include "tpcalc.hxx" //add for ScTpCalcOptions
#include "tpprint.hxx" //add for ScTpPrintOptions
@@ -114,6 +115,7 @@ IMPL_ABSTDLG_BASE(AbstractScShowTabDlg_Impl); //add for ScShowTabDlg
IMPL_ABSTDLG_BASE(AbstractScStringInputDlg_Impl); //add for ScStringInputDlg
IMPL_ABSTDLG_BASE(AbstractScTabBgColorDlg_Impl); //add for ScTabBgColorDlg
IMPL_ABSTDLG_BASE(AbstractScImportOptionsDlg_Impl); //add for ScImportOptionsDlg
+IMPL_ABSTDLG_BASE(AbstractScTextImportOptionsDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractTabDialog_Impl); //add for ScAttrDlg, ScHFEditDlg, ScStyleDlg, ScSubTotalDlg,ScCharDlg, ScParagraphDlg, ScValidationDlg, ScSortDlg
// AbstractTabDialog_Impl begin
@@ -195,6 +197,11 @@ void AbstractScImportAsciiDlg_Impl::SetTextToColumnsMode()
pDlg->SetTextToColumnsMode();
}
+void AbstractScImportAsciiDlg_Impl::SaveParameters()
+{
+ pDlg->SaveParameters();
+}
+
// AbstractScImportAsciiDlg_Impl end
//AbstractScAutoFormatDlg_Impl begin
@@ -627,6 +634,20 @@ void AbstractScImportOptionsDlg_Impl::GetImportOptions( ScImportOptions& rOption
pDlg->GetImportOptions(rOptions);
}
// add for AbstractScImportOptionsDlg_Impl end
+
+//add for AbstractScLangChooserDlg_Impl begin
+LanguageType AbstractScTextImportOptionsDlg_Impl::GetLanguageType() const
+{
+ return pDlg->getLanguageType();
+}
+
+bool AbstractScTextImportOptionsDlg_Impl::IsDateConversionSet() const
+{
+ return pDlg->isDateConversionSet();
+}
+
+//add for AbstractScLangChooserDlg_Impl end
+
// =========================Factories for createdialog ===================
//add for ScImportAsciiDlg begin
@@ -649,6 +670,21 @@ AbstractScImportAsciiDlg * ScAbstractDialogFactory_Impl::CreateScImportAsciiDlg
}
// ScImportAsciiDlg end
+AbstractScTextImportOptionsDlg * ScAbstractDialogFactory_Impl::CreateScTextImportOptionsDlg( Window* pParent, int nId )
+{
+ ScTextImportOptionsDlg* pDlg = NULL;
+ switch (nId)
+ {
+ case RID_SCDLG_TEXT_IMPORT_OPTIONS:
+ pDlg = new ScTextImportOptionsDlg(pParent);
+ break;
+ default:
+ ;
+ }
+
+ return pDlg ? new AbstractScTextImportOptionsDlg_Impl(pDlg) : NULL;
+}
+
//add for ScAutoFormatDlg begin
AbstractScAutoFormatDlg * ScAbstractDialogFactory_Impl::CreateScAutoFormatDlg( Window* pParent, //add for ScAutoFormatDlg
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index ba7dd15d8937..cd0f79dd1598 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -62,6 +62,7 @@ class ScTabBgColorDlg;
class ScImportOptionsDlg;
class SfxTabDialog;
class ScSortWarningDlg;
+class ScTextImportOptionsDlg;
#define DECL_ABSTDLG_BASE(Class,DialogClass) \
DialogClass* pDlg; \
@@ -117,6 +118,7 @@ class AbstractScImportAsciiDlg_Impl : public AbstractScImportAsciiDlg //add for
DECL_ABSTDLG_BASE(AbstractScImportAsciiDlg_Impl, ScImportAsciiDlg)
virtual void GetOptions( ScAsciiOptions& rOpt );
virtual void SetTextToColumnsMode();
+ virtual void SaveParameters();
};
class AbstractScAutoFormatDlg_Impl : public AbstractScAutoFormatDlg //add for ScAutoFormatDlg
@@ -347,6 +349,13 @@ class AbstractScImportOptionsDlg_Impl : public AbstractScImportOptionsDlg //add
virtual void GetImportOptions( ScImportOptions& rOptions ) const;
};
+class AbstractScTextImportOptionsDlg_Impl : public AbstractScTextImportOptionsDlg
+{
+ DECL_ABSTDLG_BASE( AbstractScTextImportOptionsDlg_Impl, ScTextImportOptionsDlg)
+ virtual LanguageType GetLanguageType() const;
+ virtual bool IsDateConversionSet() const;
+};
+
//add for ScAttrDlg , ScHFEditDlg, ScStyleDlg, ScSubTotalDlg, ScCharDlg, ScParagraphDlg, ScValidationDlg, ScSortDlg
class AbstractTabDialog_Impl : public SfxAbstractTabDialog
{
@@ -388,6 +397,8 @@ public:
SvStream* pInStream, int nId,
sal_Unicode cSep = '\t');
+ virtual AbstractScTextImportOptionsDlg * CreateScTextImportOptionsDlg( Window* pParent, int nId );
+
virtual AbstractScAutoFormatDlg * CreateScAutoFormatDlg( Window* pParent, //add for ScAutoFormatDlg
ScAutoFormat* pAutoFormat,
const ScAutoFormatData* pSelFormatData,
diff --git a/sc/source/ui/dbgui/asciiopt.cxx b/sc/source/ui/dbgui/asciiopt.cxx
index a40a5fb994ea..cd1f85fb99cc 100644
--- a/sc/source/ui/dbgui/asciiopt.cxx
+++ b/sc/source/ui/dbgui/asciiopt.cxx
@@ -53,8 +53,11 @@ ScAsciiOptions::ScAsciiOptions() :
bFixedLen ( FALSE ),
aFieldSeps ( ';' ),
bMergeFieldSeps ( FALSE ),
+ bQuotedFieldAsText(false),
+ bDetectSpecialNumber(false),
cTextSep ( cDefaultTextSep ),
eCharSet ( gsl_getSystemTextEncoding() ),
+ eLang ( LANGUAGE_SYSTEM ),
bCharSetSystem ( FALSE ),
nStartRow ( 1 ),
nInfoCount ( 0 ),
@@ -68,8 +71,11 @@ ScAsciiOptions::ScAsciiOptions(const ScAsciiOptions& rOpt) :
bFixedLen ( rOpt.bFixedLen ),
aFieldSeps ( rOpt.aFieldSeps ),
bMergeFieldSeps ( rOpt.bMergeFieldSeps ),
+ bQuotedFieldAsText(rOpt.bQuotedFieldAsText),
+ bDetectSpecialNumber(rOpt.bDetectSpecialNumber),
cTextSep ( rOpt.cTextSep ),
eCharSet ( rOpt.eCharSet ),
+ eLang ( rOpt.eLang ),
bCharSetSystem ( rOpt.bCharSetSystem ),
nStartRow ( rOpt.nStartRow ),
nInfoCount ( rOpt.nInfoCount )
@@ -152,6 +158,7 @@ ScAsciiOptions& ScAsciiOptions::operator=( const ScAsciiOptions& rCpy )
bFixedLen = rCpy.bFixedLen;
aFieldSeps = rCpy.aFieldSeps;
bMergeFieldSeps = rCpy.bMergeFieldSeps;
+ bQuotedFieldAsText = rCpy.bQuotedFieldAsText;
cTextSep = rCpy.cTextSep;
eCharSet = rCpy.eCharSet;
bCharSetSystem = rCpy.bCharSetSystem;
@@ -166,6 +173,7 @@ BOOL ScAsciiOptions::operator==( const ScAsciiOptions& rCmp ) const
if ( bFixedLen == rCmp.bFixedLen &&
aFieldSeps == rCmp.aFieldSeps &&
bMergeFieldSeps == rCmp.bMergeFieldSeps &&
+ bQuotedFieldAsText == rCmp.bQuotedFieldAsText &&
cTextSep == rCmp.cTextSep &&
eCharSet == rCmp.eCharSet &&
bCharSetSystem == rCmp.bCharSetSystem &&
@@ -245,13 +253,20 @@ void ScAsciiOptions::ReadFromString( const String& rString )
eCharSet = ScGlobal::GetCharsetValue( aToken );
}
+ // Language
+ if (nCount >= 4)
+ {
+ aToken = rString.GetToken(3, ',');
+ eLang = static_cast<LanguageType>(aToken.ToInt32());
+ }
+
//
// Startzeile
//
- if ( nCount >= 4 )
+ if ( nCount >= 5 )
{
- aToken = rString.GetToken(3,',');
+ aToken = rString.GetToken(4,',');
nStartRow = aToken.ToInt32();
}
@@ -259,12 +274,12 @@ void ScAsciiOptions::ReadFromString( const String& rString )
// Spalten-Infos
//
- if ( nCount >= 5 )
+ if ( nCount >= 6 )
{
delete[] pColStart;
delete[] pColFormat;
- aToken = rString.GetToken(4,',');
+ aToken = rString.GetToken(5,',');
nSub = aToken.GetTokenCount('/');
nInfoCount = nSub / 2;
if (nInfoCount)
@@ -283,6 +298,20 @@ void ScAsciiOptions::ReadFromString( const String& rString )
pColFormat = NULL;
}
}
+
+ // Import quoted field as text.
+ if (nCount >= 7)
+ {
+ aToken = rString.GetToken(6, ',');
+ bQuotedFieldAsText = aToken.EqualsAscii("true") ? true : false;
+ }
+
+ // Detect special nubmers.
+ if (nCount >= 8)
+ {
+ aToken = rString.GetToken(7, ',');
+ bDetectSpecialNumber = aToken.EqualsAscii("true") ? true : false;
+ }
}
@@ -333,6 +362,10 @@ String ScAsciiOptions::WriteToString() const
aOutStr += ScGlobal::GetCharsetString( eCharSet );
aOutStr += ','; // Token-Ende
+ // Language
+ aOutStr += String::CreateFromInt32(eLang);
+ aOutStr += ',';
+
//
// Startzeile
//
@@ -354,6 +387,15 @@ String ScAsciiOptions::WriteToString() const
aOutStr += String::CreateFromInt32(pColFormat[nInfo]);
}
+ aOutStr += ',';
+
+ // Import quoted field as text.
+ aOutStr += String::CreateFromAscii(bQuotedFieldAsText ? "true" : "false");
+ aOutStr += ',';
+
+ // Detect special nubmers.
+ aOutStr += String::CreateFromAscii(bDetectSpecialNumber ? "true" : "false");
+
return aOutStr;
}
diff --git a/sc/source/ui/dbgui/asciiopt.hrc b/sc/source/ui/dbgui/asciiopt.hrc
index 275de80f5972..7bf6d42d6e2f 100644
--- a/sc/source/ui/dbgui/asciiopt.hrc
+++ b/sc/source/ui/dbgui/asciiopt.hrc
@@ -26,31 +26,46 @@
************************************************************************/
#include "sc.hrc"
//#define RID_SCDLG_ASCII 256
-#define RB_SEPARATED 1
-#define RB_FIXED 2
-#define FT_CHARSET 3
-#define LB_CHARSET 4
-#define FL_SEPOPT 5
-#define FT_FIELDSEP 6
-#define CB_FIELDSEP 7
-#define FT_TEXTSEP 8
-#define CB_TEXTSEP 9
-#define FL_FIELDOPT 10
-#define FT_TYPE 12
-#define FT_PREVIEW 13
-#define LB_TYPE1 23
-#define FL_WIDTH 30
-#define BTN_OK 31
-#define BTN_CANCEL 32
-#define BTN_HELP 33
-#define CTR_TABLEBOX 41
-#define CKB_TAB 51
-#define CKB_SPACE 52
-#define CKB_SEMICOLON 53
-#define CKB_COMMA 54
-#define CKB_OTHER 55
-#define ED_OTHER 56
-#define FT_AT_ROW 59
-#define NF_AT_ROW 60
-#define CB_ASONCE 90
-#define STR_TEXTTOCOLUMNS 100
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 3
+
+#define FL_FIELDOPT 4
+#define FT_CHARSET 5
+#define LB_CHARSET 6
+#define FT_CUSTOMLANG 7
+#define LB_CUSTOMLANG 8
+#define FT_AT_ROW 9
+#define NF_AT_ROW 10
+
+#define FL_SEPOPT 11
+#define RB_FIXED 12
+#define RB_SEPARATED 13
+#define CKB_TAB 14
+#define CKB_COMMA 15
+#define CKB_OTHER 16
+#define ED_OTHER 17
+#define CKB_SEMICOLON 18
+#define CKB_SPACE 19
+#define CB_ASONCE 20
+#define CB_TEXTSEP 21
+#define FT_TEXTSEP 22
+
+#define FL_OTHER_OPTIONS 23
+#define CB_QUOTED_AS_TEXT 24
+#define CB_DETECT_SPECIAL_NUMBER 25
+
+#define FL_WIDTH 26
+#define FT_TYPE 27
+#define LB_TYPE1 28
+#define CTR_TABLEBOX 29
+#define STR_TEXTTOCOLUMNS 30
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/dbgui/asciiopt.src b/sc/source/ui/dbgui/asciiopt.src
index b527719cb6de..9efbfe0f557f 100644
--- a/sc/source/ui/dbgui/asciiopt.src
+++ b/sc/source/ui/dbgui/asciiopt.src
@@ -31,55 +31,44 @@ ModalDialog RID_SCDLG_ASCII
{
OutputSize = TRUE ;
SVLook = TRUE ;
- Size = MAP_APPFONT ( 320 , 247 ) ;
+ Size = MAP_APPFONT ( 320 , 305 ) ;
Text [ en-US ] = "Text Import" ;
Moveable = TRUE ;
- FixedLine FL_WIDTH
- {
- Pos = MAP_APPFONT ( 6 , 132 ) ;
- Size = MAP_APPFONT ( 252 , 8 ) ;
- Text [ en-US ] = "Fields" ;
- };
- FixedText FT_TYPE
- {
- Pos = MAP_APPFONT ( 12 , 145 ) ;
- Size = MAP_APPFONT ( 60 , 8 ) ;
- Text [ en-US ] = "Column t~ype";
- };
- ListBox LB_TYPE1
+
+ OKButton BTN_OK
{
- Pos = MAP_APPFONT ( 76 , 143 ) ;
- Size = MAP_APPFONT ( 60 , 68 ) ;
+ Pos = MAP_APPFONT ( 264 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
TabStop = TRUE ;
- DropDown = TRUE ;
+ DefButton = TRUE ;
};
- FixedLine FL_SEPOPT
+ CancelButton BTN_CANCEL
{
- Pos = MAP_APPFONT ( 6 , 48 ) ;
- Size = MAP_APPFONT ( 252 , 8 ) ;
- Text [ en-US ] = "Separator options" ;
+ Pos = MAP_APPFONT ( 264 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
};
- RadioButton RB_FIXED
+ HelpButton BTN_HELP
{
- Pos = MAP_APPFONT ( 12 , 59 ) ;
- Size = MAP_APPFONT ( 243 , 10 ) ;
- Text [ en-US ] = "~Fixed width" ;
+ Pos = MAP_APPFONT ( 264 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
TabStop = TRUE ;
};
- RadioButton RB_SEPARATED
+
+ FixedLine FL_FIELDOPT
{
- Pos = MAP_APPFONT ( 12 , 73 ) ;
- Size = MAP_APPFONT ( 243 , 10 ) ;
- Text [ en-US ] = "~Separated by" ;
- TabStop = TRUE ;
- Check = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 252 , 8 ) ;
+ Text [ en-US ] = "Import" ;
};
+
FixedText FT_CHARSET
{
Pos = MAP_APPFONT ( 12 , 16 ) ;
Size = MAP_APPFONT ( 60 , 8 ) ;
Text [ en-US ] = "Ch~aracter set" ;
};
+
ListBox LB_CHARSET
{
Pos = MAP_APPFONT ( 76 , 14 ) ;
@@ -88,119 +77,182 @@ ModalDialog RID_SCDLG_ASCII
DropDown = TRUE ;
Sort = TRUE;
};
- FixedLine FL_FIELDOPT
- {
- Pos = MAP_APPFONT ( 6 , 3 ) ;
- Size = MAP_APPFONT ( 252 , 8 ) ;
- Text [ en-US ] = "Import" ;
- };
- FixedText FT_TEXTSEP
+
+ FixedText FT_CUSTOMLANG
{
- Pos = MAP_APPFONT ( 156 , 114 ) ;
+ Pos = MAP_APPFONT ( 12 , 32 ) ;
Size = MAP_APPFONT ( 60 , 8 ) ;
- Text [ en-US ] = "Te~xt delimiter" ;
+ Text [ en-US ] = "Language" ;
};
- ComboBox CB_TEXTSEP
+
+ ListBox LB_CUSTOMLANG
{
- Pos = MAP_APPFONT ( 218 , 112 ) ;
- Size = MAP_APPFONT ( 37 , 94 ) ;
+ Pos = MAP_APPFONT ( 76 , 30 ) ;
+ Size = MAP_APPFONT ( 130 , 61 ) ;
TabStop = TRUE ;
DropDown = TRUE ;
+ Sort = TRUE;
};
- OKButton BTN_OK
+
+ FixedText FT_AT_ROW
{
- Pos = MAP_APPFONT ( 264 , 6 ) ;
- Size = MAP_APPFONT ( 50 , 14 ) ;
+ Pos = MAP_APPFONT ( 12 , 48 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "From ro~w" ;
+ };
+
+ NumericField NF_AT_ROW
+ {
+ Border = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 76 , 46 ) ;
+ Size = MAP_APPFONT ( 30 , 12 ) ;
TabStop = TRUE ;
- DefButton = TRUE ;
+ Spin = TRUE ;
+ Repeat = TRUE ;
+ Minimum = 1 ;
};
- CancelButton BTN_CANCEL
+
+ FixedLine FL_SEPOPT
{
- Pos = MAP_APPFONT ( 264 , 23 ) ;
- Size = MAP_APPFONT ( 50 , 14 ) ;
+ Pos = MAP_APPFONT ( 6 , 63 ) ;
+ Size = MAP_APPFONT ( 252 , 8 ) ;
+ Text [ en-US ] = "Separator options" ;
+ };
+ RadioButton RB_FIXED
+ {
+ Pos = MAP_APPFONT ( 12 , 75 ) ;
+ Size = MAP_APPFONT ( 243 , 10 ) ;
+ Text [ en-US ] = "~Fixed width" ;
TabStop = TRUE ;
};
- HelpButton BTN_HELP
+ RadioButton RB_SEPARATED
{
- Pos = MAP_APPFONT ( 264 , 43 ) ;
- Size = MAP_APPFONT ( 50 , 14 ) ;
+ Pos = MAP_APPFONT ( 12 , 89 ) ;
+ Size = MAP_APPFONT ( 243 , 10 ) ;
+ Text [ en-US ] = "~Separated by" ;
TabStop = TRUE ;
+ Check = TRUE ;
};
+
CheckBox CKB_TAB
{
- Pos = MAP_APPFONT ( 20 , 86 ) ;
+ Pos = MAP_APPFONT ( 20 , 102 ) ;
Size = MAP_APPFONT ( 68 , 10 ) ;
TabStop = TRUE ;
Text [ en-US ] = "~Tab" ;
};
- CheckBox CKB_SEMICOLON
+ CheckBox CKB_COMMA
{
- Pos = MAP_APPFONT ( 20 , 99 ) ;
+ Pos = MAP_APPFONT ( 92 , 102 ) ;
Size = MAP_APPFONT ( 68 , 10 ) ;
TabStop = TRUE ;
- Text [ en-US ] = "S~emicolon" ;
+ Text [ en-US ] = "~Comma" ;
};
- CheckBox CKB_COMMA
+ CheckBox CKB_OTHER
+ {
+ Pos = MAP_APPFONT ( 164 , 102 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Other" ;
+ };
+ Edit ED_OTHER
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 218 , 100 ) ;
+ Size = MAP_APPFONT ( 37 , 12 ) ;
+ TabStop = TRUE ;
+ MaxTextLength = 10 ;
+ };
+
+ CheckBox CKB_SEMICOLON
{
- Pos = MAP_APPFONT ( 92 , 86 ) ;
+ Pos = MAP_APPFONT ( 20 , 115 ) ;
Size = MAP_APPFONT ( 68 , 10 ) ;
TabStop = TRUE ;
- Text [ en-US ] = "~Comma" ;
+ Text [ en-US ] = "S~emicolon" ;
};
CheckBox CKB_SPACE
{
- Pos = MAP_APPFONT ( 92 , 99 ) ;
+ Pos = MAP_APPFONT ( 92 , 115 ) ;
Size = MAP_APPFONT ( 68 , 10 ) ;
TabStop = TRUE ;
Text [ en-US ] = "S~pace" ;
};
- CheckBox CKB_OTHER
+
+ CheckBox CB_ASONCE
{
- Pos = MAP_APPFONT ( 164 , 86 ) ;
- Size = MAP_APPFONT ( 50 , 10 ) ;
+ Pos = MAP_APPFONT ( 20 , 130 ) ;
+ Size = MAP_APPFONT ( 130 , 10 ) ;
TabStop = TRUE ;
- Text [ en-US ] = "~Other" ;
+ Text [ en-US ] = "Merge ~delimiters" ;
};
- Edit ED_OTHER
+
+ ComboBox CB_TEXTSEP
{
- Border = TRUE ;
- Pos = MAP_APPFONT ( 218 , 84 ) ;
- Size = MAP_APPFONT ( 37 , 12 ) ;
+ Pos = MAP_APPFONT ( 218 , 128 ) ;
+ Size = MAP_APPFONT ( 37 , 94 ) ;
TabStop = TRUE ;
- MaxTextLength = 10 ;
+ DropDown = TRUE ;
};
- FixedText FT_AT_ROW
+ FixedText FT_TEXTSEP
{
- Pos = MAP_APPFONT ( 12 , 32 ) ;
+ Pos = MAP_APPFONT ( 156 , 130 ) ;
Size = MAP_APPFONT ( 60 , 8 ) ;
- Text [ en-US ] = "From ro~w" ;
+ Text [ en-US ] = "Te~xt delimiter" ;
};
- NumericField NF_AT_ROW
+
+ FixedLine FL_OTHER_OPTIONS
{
- Border = TRUE ;
- SVLook = TRUE ;
- Pos = MAP_APPFONT ( 76 , 30 ) ;
- Size = MAP_APPFONT ( 30 , 12 ) ;
+ Pos = MAP_APPFONT ( 6 , 146 ) ;
+ Size = MAP_APPFONT ( 252 , 8 ) ;
+ Text [ en-US ] = "Other options" ;
+ };
+
+ CheckBox CB_QUOTED_AS_TEXT
+ {
+ Pos = MAP_APPFONT ( 12 , 158 ) ;
+ Size = MAP_APPFONT ( 130 , 10 ) ;
TabStop = TRUE ;
- Spin = TRUE ;
- Repeat = TRUE ;
- Minimum = 1 ;
+ Text [ en-US ] = "~Quoted field as text" ;
+ };
+
+ CheckBox CB_DETECT_SPECIAL_NUMBER
+ {
+ Pos = MAP_APPFONT ( 12 , 171 ) ;
+ Size = MAP_APPFONT ( 130 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Detect special numbers" ;
+ };
+
+ FixedLine FL_WIDTH
+ {
+ Pos = MAP_APPFONT ( 6 , 187 ) ;
+ Size = MAP_APPFONT ( 252 , 8 ) ;
+ Text [ en-US ] = "Fields" ;
+ };
+ FixedText FT_TYPE
+ {
+ Pos = MAP_APPFONT ( 12 , 200 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "Column t~ype";
+ };
+ ListBox LB_TYPE1
+ {
+ Pos = MAP_APPFONT ( 76 , 198 ) ;
+ Size = MAP_APPFONT ( 60 , 68 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
};
Control CTR_TABLEBOX
{
HelpId = HID_SC_ASCII_TABCTR ;
Border = TRUE ;
DialogControl = TRUE ;
- Pos = MAP_APPFONT ( 12 , 159 ) ;
+ Pos = MAP_APPFONT ( 12 , 216 ) ;
Size = MAP_APPFONT ( 243 , 82 ) ;
};
- CheckBox CB_ASONCE
- {
- Pos = MAP_APPFONT ( 20 , 114 ) ;
- Size = MAP_APPFONT ( 130 , 10 ) ;
- TabStop = TRUE ;
- Text [ en-US ] = "Merge ~delimiters" ;
- };
+
String STR_TEXTTOCOLUMNS
{
Text [ en-US ] = "Text to Columns" ;
diff --git a/sc/source/ui/dbgui/csvgrid.cxx b/sc/source/ui/dbgui/csvgrid.cxx
index 2ec05af2f72e..d271022a987c 100644
--- a/sc/source/ui/dbgui/csvgrid.cxx
+++ b/sc/source/ui/dbgui/csvgrid.cxx
@@ -734,7 +734,8 @@ void ScCsvGrid::ImplSetTextLineSep(
while( *pChar && (nColIx < sal::static_int_cast<sal_uInt32>(CSV_MAXCOLCOUNT)) )
{
// scan for next cell text
- pChar = ScImportExport::ScanNextFieldFromString( pChar, aCellText, cTextSep, pSepChars, bMergeSep );
+ bool bIsQuoted = false;
+ pChar = ScImportExport::ScanNextFieldFromString( pChar, aCellText, cTextSep, pSepChars, bMergeSep, bIsQuoted );
// update column width
sal_Int32 nWidth = Max( CSV_MINCOLWIDTH, aCellText.Len() + sal_Int32( 1 ) );
diff --git a/sc/source/ui/dbgui/csvruler.cxx b/sc/source/ui/dbgui/csvruler.cxx
index d84c938bfd14..56aa2a50a835 100644
--- a/sc/source/ui/dbgui/csvruler.cxx
+++ b/sc/source/ui/dbgui/csvruler.cxx
@@ -34,8 +34,77 @@
#include "AccessibleCsvControl.hxx"
+#include <optutil.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include "miscuno.hxx"
+
+using namespace rtl;
+using namespace com::sun::star::uno;
+
+
+
+// ============================================================================
+#define SEP_PATH "Office.Calc/Dialogs/CSVImport"
+#define FIXED_WIDTH_LIST "FixedWidthList"
+
+
// ============================================================================
+static void load_FixedWidthList(ScCsvSplits &aSplits)
+{
+ String sSplits;
+ OUString sFixedWidthLists;
+
+ Sequence<Any>aValues;
+ const Any *pProperties;
+ Sequence<OUString> aNames(1);
+ OUString* pNames = aNames.getArray();
+ ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) );
+
+ pNames[0] = OUString::createFromAscii( FIXED_WIDTH_LIST );
+ aValues = aItem.GetProperties( aNames );
+ pProperties = aValues.getConstArray();
+
+ if( pProperties[0].hasValue() )
+ {
+ aSplits.Clear();
+ pProperties[0] >>= sFixedWidthLists;
+
+ sSplits = String( sFixedWidthLists );
+
+ // String ends with a semi-colon so there is no 'int' after the last one.
+ xub_StrLen n = sSplits.GetTokenCount() - 1;
+ for (xub_StrLen i = 0; i < n; ++i)
+ aSplits.Insert( sSplits.GetToken(i).ToInt32() );
+ }
+}
+static void save_FixedWidthList(ScCsvSplits aSplits)
+{
+ String sSplits;
+ // Create a semi-colon separated string to save the splits
+ sal_uInt32 n = aSplits.Count();
+ for (sal_uInt32 i = 0; i < n; ++i)
+ {
+ sSplits.Append( String::CreateFromInt32( aSplits[i] ) );
+ sSplits.Append((char)';');
+ }
+
+ OUString sFixedWidthLists = OUString( sSplits );
+ Sequence<Any> aValues;
+ Any *pProperties;
+ Sequence<OUString> aNames(1);
+ OUString* pNames = aNames.getArray();
+ ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) );
+
+ pNames[0] = OUString::createFromAscii( FIXED_WIDTH_LIST );
+ aValues = aItem.GetProperties( aNames );
+ pProperties = aValues.getArray();
+ pProperties[0] <<= sFixedWidthLists;
+
+ aItem.PutProperties(aNames, aValues);
+}
+
ScCsvRuler::ScCsvRuler( ScCsvControl& rParent ) :
ScCsvControl( rParent ),
mnPosCursorLast( 1 )
@@ -45,6 +114,13 @@ ScCsvRuler::ScCsvRuler( ScCsvControl& rParent ) :
InitSizeData();
maBackgrDev.SetFont( GetFont() );
maRulerDev.SetFont( GetFont() );
+
+ load_FixedWidthList( maSplits );
+}
+
+ScCsvRuler::~ScCsvRuler()
+{
+ save_FixedWidthList( maSplits );
}
diff --git a/sc/source/ui/dbgui/dapidata.cxx b/sc/source/ui/dbgui/dapidata.cxx
index 87de71767a17..976e0ae23039 100644
--- a/sc/source/ui/dbgui/dapidata.cxx
+++ b/sc/source/ui/dbgui/dapidata.cxx
@@ -56,7 +56,7 @@ using namespace com::sun::star;
//-------------------------------------------------------------------------
#define DP_SERVICE_DBCONTEXT "com.sun.star.sdb.DatabaseContext"
-#define SC_SERVICE_INTHANDLER "com.sun.star.sdb.InteractionHandler"
+#define SC_SERVICE_INTHANDLER "com.sun.star.task.InteractionHandler"
// entries in the "type" ListBox
#define DP_TYPELIST_TABLE 0
diff --git a/sc/source/ui/dbgui/makefile.mk b/sc/source/ui/dbgui/makefile.mk
index ee855d22aef1..2d4fa71f690e 100644
--- a/sc/source/ui/dbgui/makefile.mk
+++ b/sc/source/ui/dbgui/makefile.mk
@@ -49,6 +49,7 @@ SLOFILES = \
$(SLO)$/pfiltdlg.obj \
$(SLO)$/dbnamdlg.obj \
$(SLO)$/expftext.obj \
+ $(SLO)$/textimportoptions.obj \
$(SLO)$/subtdlg.obj \
$(SLO)$/tpsubt.obj \
$(SLO)$/fieldwnd.obj \
@@ -83,6 +84,7 @@ EXCEPTIONSFILES= \
SRS1NAME=$(TARGET)
SRC1FILES = \
+ textimportoptions.src \
pivot.src \
pvfundlg.src \
dpgroupdlg.src \
diff --git a/sc/source/ui/dbgui/pvfundlg.cxx b/sc/source/ui/dbgui/pvfundlg.cxx
index 8609bfcbfb0a..03de0b8914a3 100644
--- a/sc/source/ui/dbgui/pvfundlg.cxx
+++ b/sc/source/ui/dbgui/pvfundlg.cxx
@@ -739,9 +739,12 @@ ScDPShowDetailDlg::ScDPShowDetailDlg( Window* pParent, ScDPObject& rDPObj, USHOR
const ScDPSaveDimension* pDimension = pSaveData ? pSaveData->GetExistingDimensionByName(aName) : 0;
if ( !pDimension || (pDimension->GetOrientation() != nOrient) )
{
- const OUString* pLayoutName = pDimension->GetLayoutName();
- if (pLayoutName)
- aName = *pLayoutName;
+ if (pDimension)
+ {
+ const OUString* pLayoutName = pDimension->GetLayoutName();
+ if (pLayoutName)
+ aName = *pLayoutName;
+ }
maLbDims.InsertEntry( aName );
maNameIndexMap.insert(DimNameIndexMap::value_type(aName, nDim));
}
diff --git a/sc/source/ui/dbgui/pvfundlg.src b/sc/source/ui/dbgui/pvfundlg.src
index 70bce3ed30e9..ed00f6a65fa5 100644
--- a/sc/source/ui/dbgui/pvfundlg.src
+++ b/sc/source/ui/dbgui/pvfundlg.src
@@ -227,8 +227,8 @@ ModalDialog RID_SCDLG_PIVOTSUBT
};
CheckBox CB_SHOWALL
{
- Pos = MAP_APPFONT ( 12 , 127 ) ;
- Size = MAP_APPFONT ( 140 , 10 ) ;
+ Pos = MAP_APPFONT ( 6 , 127 ) ;
+ Size = MAP_APPFONT ( 152 , 10 ) ;
Text [ en-US ] = "Show it~ems without data";
TabStop = TRUE ;
};
diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx
index e4e568e00882..171daa0ca882 100644
--- a/sc/source/ui/dbgui/scuiasciiopt.cxx
+++ b/sc/source/ui/dbgui/scuiasciiopt.cxx
@@ -41,6 +41,12 @@
// ause
#include "editutil.hxx"
+#include <optutil.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include "miscuno.hxx"
+
+
//! TODO make dynamic
#ifdef WIN
const SCSIZE ASCIIDLG_MAXROWS = 10000;
@@ -48,6 +54,22 @@ const SCSIZE ASCIIDLG_MAXROWS = 10000;
const SCSIZE ASCIIDLG_MAXROWS = MAXROWCOUNT;
#endif
+
+using namespace rtl;
+using namespace com::sun::star::uno;
+
+// Defines - CSV Import Preserve Options
+#define FIXED_WIDTH "FixedWidth"
+#define FROM_ROW "FromRow"
+#define CHAR_SET "CharSet"
+#define SEPARATORS "Separators"
+#define TEXT_SEPARATORS "TextSeparators"
+#define MERGE_DELIMITERS "MergeDelimiters"
+#define QUOTED_AS_TEXT "QuotedFieldAsText"
+#define DETECT_SPECIAL_NUM "DetectSpecialNumbers"
+#define LANGUAGE "Language"
+#define SEP_PATH "Office.Calc/Dialogs/CSVImport"
+
// ============================================================================
void lcl_FillCombo( ComboBox& rCombo, const String& rList, sal_Unicode cSelect )
@@ -95,11 +117,96 @@ sal_Unicode lcl_CharFromCombo( ComboBox& rCombo, const String& rList )
return c;
}
+static void load_Separators( OUString &sFieldSeparators, OUString &sTextSeparators,
+ bool &bMergeDelimiters, bool& bQuotedAsText, bool& bDetectSpecialNum,
+ bool &bFixedWidth, sal_Int32 &nFromRow, sal_Int32 &nCharSet,
+ sal_Int32& nLanguage )
+{
+ Sequence<Any>aValues;
+ const Any *pProperties;
+ Sequence<OUString> aNames(9);
+ OUString* pNames = aNames.getArray();
+ ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) );
+
+ pNames[0] = OUString::createFromAscii( MERGE_DELIMITERS );
+ pNames[1] = OUString::createFromAscii( SEPARATORS );
+ pNames[2] = OUString::createFromAscii( TEXT_SEPARATORS );
+ pNames[3] = OUString::createFromAscii( FIXED_WIDTH );
+ pNames[4] = OUString::createFromAscii( FROM_ROW );
+ pNames[5] = OUString::createFromAscii( CHAR_SET );
+ pNames[6] = OUString::createFromAscii( QUOTED_AS_TEXT );
+ pNames[7] = OUString::createFromAscii( DETECT_SPECIAL_NUM );
+ pNames[8] = OUString::createFromAscii( LANGUAGE );
+ aValues = aItem.GetProperties( aNames );
+ pProperties = aValues.getConstArray();
+ if( pProperties[1].hasValue() )
+ pProperties[1] >>= sFieldSeparators;
+
+ if( pProperties[2].hasValue() )
+ pProperties[2] >>= sTextSeparators;
+
+ if( pProperties[0].hasValue() )
+ bMergeDelimiters = ScUnoHelpFunctions::GetBoolFromAny( pProperties[0] );
+
+ if( pProperties[3].hasValue() )
+ bFixedWidth = ScUnoHelpFunctions::GetBoolFromAny( pProperties[3] );
+
+ if( pProperties[4].hasValue() )
+ pProperties[4] >>= nFromRow;
+
+ if( pProperties[5].hasValue() )
+ pProperties[5] >>= nCharSet;
+
+ if ( pProperties[6].hasValue() )
+ pProperties[6] >>= bQuotedAsText;
+
+ if ( pProperties[7].hasValue() )
+ pProperties[7] >>= bDetectSpecialNum;
+
+ if ( pProperties[8].hasValue() )
+ pProperties[8] >>= nLanguage;
+}
+
+static void save_Separators(
+ String maSeparators, String maTxtSep, bool bMergeDelimiters, bool bQuotedAsText,
+ bool bDetectSpecialNum, bool bFixedWidth, sal_Int32 nFromRow, sal_Int32 nCharSet, sal_Int32 nLanguage )
+{
+ OUString sFieldSeparators = OUString( maSeparators );
+ OUString sTextSeparators = OUString( maTxtSep );
+ Sequence<Any> aValues;
+ Any *pProperties;
+ Sequence<OUString> aNames(9);
+ OUString* pNames = aNames.getArray();
+ ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) );
+
+ pNames[0] = OUString::createFromAscii( MERGE_DELIMITERS );
+ pNames[1] = OUString::createFromAscii( SEPARATORS );
+ pNames[2] = OUString::createFromAscii( TEXT_SEPARATORS );
+ pNames[3] = OUString::createFromAscii( FIXED_WIDTH );
+ pNames[4] = OUString::createFromAscii( FROM_ROW );
+ pNames[5] = OUString::createFromAscii( CHAR_SET );
+ pNames[6] = OUString::createFromAscii( QUOTED_AS_TEXT );
+ pNames[7] = OUString::createFromAscii( DETECT_SPECIAL_NUM );
+ pNames[8] = OUString::createFromAscii( LANGUAGE );
+ aValues = aItem.GetProperties( aNames );
+ pProperties = aValues.getArray();
+ pProperties[1] <<= sFieldSeparators;
+ pProperties[2] <<= sTextSeparators;
+ ScUnoHelpFunctions::SetBoolInAny( pProperties[0], bMergeDelimiters );
+ ScUnoHelpFunctions::SetBoolInAny( pProperties[3], bFixedWidth );
+ pProperties[4] <<= nFromRow;
+ pProperties[5] <<= nCharSet;
+ pProperties[6] <<= static_cast<sal_Bool>(bQuotedAsText);
+ pProperties[7] <<= static_cast<sal_Bool>(bDetectSpecialNum);
+ pProperties[8] <<= nLanguage;
+
+ aItem.PutProperties(aNames, aValues);
+}
// ----------------------------------------------------------------------------
ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
- SvStream* pInStream, sal_Unicode cSep ) :
+ SvStream* pInStream, sal_Unicode /*cSep*/ ) :
ModalDialog ( pParent, ScResId( RID_SCDLG_ASCII ) ),
mpDatStream ( pInStream ),
mnStreamPos( pInStream ? pInStream->Tell() : 0 ),
@@ -110,6 +217,8 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
aFlFieldOpt ( this, ScResId( FL_FIELDOPT ) ),
aFtCharSet ( this, ScResId( FT_CHARSET ) ),
aLbCharSet ( this, ScResId( LB_CHARSET ) ),
+ aFtCustomLang( this, ScResId( FT_CUSTOMLANG ) ),
+ aLbCustomLang( this, ScResId( LB_CUSTOMLANG ) ),
aFtRow ( this, ScResId( FT_AT_ROW ) ),
aNfRow ( this, ScResId( NF_AT_ROW ) ),
@@ -125,9 +234,14 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
aCkbOther ( this, ScResId( CKB_OTHER ) ),
aEdOther ( this, ScResId( ED_OTHER ) ),
aCkbAsOnce ( this, ScResId( CB_ASONCE) ),
+ aFlOtherOpt ( this, ScResId( FL_OTHER_OPTIONS ) ),
+
aFtTextSep ( this, ScResId( FT_TEXTSEP ) ),
aCbTextSep ( this, ScResId( CB_TEXTSEP ) ),
+ aCkbQuotedAsText( this, ScResId(CB_QUOTED_AS_TEXT) ),
+ aCkbDetectNumber( this, ScResId(CB_DETECT_SPECIAL_NUMBER) ),
+
aFlWidth ( this, ScResId( FL_WIDTH ) ),
aFtType ( this, ScResId( FT_TYPE ) ),
aLbType ( this, ScResId( LB_TYPE1 ) ),
@@ -143,14 +257,15 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
aFldSepList ( ScResId( SCSTR_FIELDSEP ) ),
aTextSepList( ScResId( SCSTR_TEXTSEP ) ),
mcTextSep ( ScAsciiOptions::cDefaultTextSep ),
- maStrTextToColumns( ScResId( STR_TEXTTOCOLUMNS ) )
+ maStrTextToColumns( ScResId( STR_TEXTTOCOLUMNS ) ),
+ mbFileImport(true)
{
FreeResource();
+ mbFileImport = aDatName.Len() > 0;
String aName = GetText();
// aDatName is empty if invoked during paste from clipboard.
- BOOL bClipboard = (aDatName.Len() == 0);
- if (!bClipboard)
+ if (mbFileImport)
{
aName.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" - ["));
aName += aDatName;
@@ -158,20 +273,55 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
}
SetText( aName );
- switch(cSep)
+
+ OUString sFieldSeparators;
+ OUString sTextSeparators;
+ bool bMergeDelimiters = false;
+ bool bFixedWidth = false;
+ bool bQuotedFieldAsText = true;
+ bool bDetectSpecialNum = false;
+ sal_Int32 nFromRow = 1;
+ sal_Int32 nCharSet = -1;
+ sal_Int32 nLanguage = 0;
+ if (mbFileImport)
+ // load separators only when importing csv files.
+ load_Separators (sFieldSeparators, sTextSeparators, bMergeDelimiters,
+ bQuotedFieldAsText, bDetectSpecialNum, bFixedWidth, nFromRow, nCharSet, nLanguage);
+ maFieldSeparators = String(sFieldSeparators);
+
+ if( bMergeDelimiters )
+ aCkbAsOnce.Check();
+ if (bQuotedFieldAsText)
+ aCkbQuotedAsText.Check();
+ if (bDetectSpecialNum)
+ aCkbDetectNumber.Check();
+ if( bFixedWidth )
+ aRbFixed.Check();
+ if( nFromRow != 1 )
+ aNfRow.SetValue( nFromRow );
+
+ ByteString bString(maFieldSeparators,RTL_TEXTENCODING_MS_1252);
+ const sal_Char *aSep = bString.GetBuffer();
+ int len = maFieldSeparators.Len();
+ for (int i = 0; i < len; ++i)
{
- case '\t': aCkbTab.Check(); break;
- case ';': aCkbSemicolon.Check(); break;
- case ',': aCkbComma.Check(); break;
- case ' ': aCkbSpace.Check(); break;
- default:
- aCkbOther.Check();
- aEdOther.SetText( cSep );
+ switch( aSep[i] )
+ {
+ case '\t': aCkbTab.Check(); break;
+ case ';': aCkbSemicolon.Check(); break;
+ case ',': aCkbComma.Check(); break;
+ case ' ': aCkbSpace.Check(); break;
+ default:
+ aCkbOther.Check();
+ aEdOther.SetText( aEdOther.GetText() + OUString( aSep[i] ) );
+ }
}
+
+ // Get Separators from the dialog
maFieldSeparators = GetSeparators();
// Clipboard is always Unicode, else detect.
- BOOL bPreselectUnicode = bClipboard;
+ bool bPreselectUnicode = !mbFileImport;
// Sniff for Unicode / not
if( !bPreselectUnicode && mpDatStream )
{
@@ -207,6 +357,7 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
// *** Separator characters ***
lcl_FillCombo( aCbTextSep, aTextSepList, mcTextSep );
+ aCbTextSep.SetText( sTextSeparators );
Link aSeparatorHdl =LINK( this, ScImportAsciiDlg, SeparatorHdl );
aCbTextSep.SetSelectHdl( aSeparatorHdl );
@@ -215,6 +366,8 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
aCkbSemicolon.SetClickHdl( aSeparatorHdl );
aCkbComma.SetClickHdl( aSeparatorHdl );
aCkbAsOnce.SetClickHdl( aSeparatorHdl );
+ aCkbQuotedAsText.SetClickHdl( aSeparatorHdl );
+ aCkbDetectNumber.SetClickHdl( aSeparatorHdl );
aCkbSpace.SetClickHdl( aSeparatorHdl );
aCkbOther.SetClickHdl( aSeparatorHdl );
aEdOther.SetModifyHdl( aSeparatorHdl );
@@ -227,9 +380,18 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
aLbCharSet.InsertTextEncoding( RTL_TEXTENCODING_DONTKNOW, aCharSetUser );
aLbCharSet.SelectTextEncoding( bPreselectUnicode ?
RTL_TEXTENCODING_UNICODE : gsl_getSystemTextEncoding() );
+
+ if( nCharSet >= 0 )
+ aLbCharSet.SelectEntryPos( static_cast<USHORT>(nCharSet) );
+
SetSelectedCharSet();
aLbCharSet.SetSelectHdl( LINK( this, ScImportAsciiDlg, CharSetHdl ) );
+ aLbCustomLang.SetLanguageList(
+ LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN, false, false);
+ aLbCustomLang.InsertLanguage(LANGUAGE_SYSTEM);
+ aLbCustomLang.SelectLanguage(static_cast<LanguageType>(nLanguage), true);
+
// *** column type ListBox ***
xub_StrLen nCount = aColumnUser.GetTokenCount();
for (xub_StrLen i=0; i<nCount; i++)
@@ -336,6 +498,7 @@ void ScImportAsciiDlg::GetOptions( ScAsciiOptions& rOpt )
{
rOpt.SetCharSet( meCharSet );
rOpt.SetCharSetSystem( mbCharSetSystem );
+ rOpt.SetLanguage(aLbCustomLang.GetSelectLanguage());
rOpt.SetFixedLen( aRbFixed.IsChecked() );
rOpt.SetStartRow( (long)aNfRow.GetValue() );
maTableBox.FillColumnData( rOpt );
@@ -345,6 +508,9 @@ void ScImportAsciiDlg::GetOptions( ScAsciiOptions& rOpt )
rOpt.SetMergeSeps( aCkbAsOnce.IsChecked() );
rOpt.SetTextSep( lcl_CharFromCombo( aCbTextSep, aTextSepList ) );
}
+
+ rOpt.SetQuotedAsText(aCkbQuotedAsText.IsChecked());
+ rOpt.SetDetectSpecialNumber(aCkbDetectNumber.IsChecked());
}
void ScImportAsciiDlg::SetTextToColumnsMode()
@@ -352,8 +518,33 @@ void ScImportAsciiDlg::SetTextToColumnsMode()
SetText( maStrTextToColumns );
aFtCharSet.Disable();
aLbCharSet.Disable();
+ aFtCustomLang.Disable();
+ aLbCustomLang.SelectLanguage(LANGUAGE_SYSTEM);
+ aLbCustomLang.Disable();
aFtRow.Disable();
aNfRow.Disable();
+
+ // Quoted field as text option is not used for text-to-columns mode.
+ aCkbQuotedAsText.Check(false);
+ aCkbQuotedAsText.Disable();
+
+ // Always detect special numbers for text-to-columns mode.
+ aCkbDetectNumber.Check();
+ aCkbDetectNumber.Disable();
+}
+
+void ScImportAsciiDlg::SaveParameters()
+{
+ if (!mbFileImport)
+ // We save parameters only for file import.
+ return;
+
+ save_Separators( maFieldSeparators, aCbTextSep.GetText(), aCkbAsOnce.IsChecked(),
+ aCkbQuotedAsText.IsChecked(), aCkbDetectNumber.IsChecked(),
+ aRbFixed.IsChecked(),
+ static_cast<sal_Int32>(aNfRow.GetValue()),
+ static_cast<sal_Int32>(aLbCharSet.GetSelectEntryPos()),
+ static_cast<sal_Int32>(aLbCustomLang.GetSelectLanguage()) );
}
void ScImportAsciiDlg::SetSelectedCharSet()
diff --git a/sc/source/ui/dbgui/textimportoptions.cxx b/sc/source/ui/dbgui/textimportoptions.cxx
new file mode 100644
index 000000000000..be918d2a0fbd
--- /dev/null
+++ b/sc/source/ui/dbgui/textimportoptions.cxx
@@ -0,0 +1,121 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: langbox.hxx,v $
+ * $Revision: 1.4.242.1 $
+ *
+ * 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_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+//------------------------------------------------------------------------
+
+#include "textimportoptions.hxx"
+#include "textimportoptions.hrc"
+
+#include "scresid.hxx"
+#include "vcl/window.hxx"
+#include "vcl/msgbox.hxx"
+#include "vcl/svapp.hxx"
+
+ScTextImportOptionsDlg::ScTextImportOptionsDlg(Window* pParent) :
+ ModalDialog(pParent, ScResId(RID_SCDLG_TEXT_IMPORT_OPTIONS)),
+
+ maBtnOk(this, ScResId(BTN_OK)),
+ maBtnCancel(this, ScResId(BTN_CANCEL)),
+ maBtnHelp(this, ScResId(BTN_HELP)),
+ maFlChooseLang(this, ScResId(FL_CHOOSE_LANG)),
+ maRbAutomatic(this, ScResId(RB_AUTOMATIC)),
+ maRbCustom(this, ScResId(RB_CUSTOM)),
+ maLbCustomLang(this, ScResId(LB_CUSTOM_LANG)),
+ maFlOption(this, ScResId(FL_OPTION)),
+ maBtnConvertDate(this, ScResId(BTN_CONVERT_DATE))
+{
+ FreeResource();
+ init();
+}
+
+ScTextImportOptionsDlg::~ScTextImportOptionsDlg()
+{
+}
+
+short ScTextImportOptionsDlg::Execute()
+{
+ return ModalDialog::Execute();
+}
+
+LanguageType ScTextImportOptionsDlg::getLanguageType() const
+{
+ if (maRbAutomatic.IsChecked())
+ return LANGUAGE_SYSTEM;
+
+ return maLbCustomLang.GetSelectLanguage();
+}
+
+bool ScTextImportOptionsDlg::isDateConversionSet() const
+{
+ return maBtnConvertDate.IsChecked();
+}
+
+void ScTextImportOptionsDlg::init()
+{
+ Link aLink = LINK( this, ScTextImportOptionsDlg, OKHdl );
+ maBtnOk.SetClickHdl(aLink);
+ aLink = LINK( this, ScTextImportOptionsDlg, RadioHdl );
+ maRbAutomatic.SetClickHdl(aLink);
+ maRbCustom.SetClickHdl(aLink);
+
+ maRbAutomatic.Check(true);
+
+ maLbCustomLang.SetLanguageList(
+ LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN, false, false);
+
+ LanguageType eLang = Application::GetSettings().GetLanguage();
+ maLbCustomLang.SelectLanguage(eLang);
+ maLbCustomLang.Disable();
+}
+
+IMPL_LINK( ScTextImportOptionsDlg, OKHdl, OKButton*, EMPTYARG )
+{
+ EndDialog(RET_OK);
+ return 0;
+}
+
+IMPL_LINK( ScTextImportOptionsDlg, RadioHdl, RadioButton*, pBtn )
+{
+ if (pBtn == &maRbAutomatic)
+ {
+ maLbCustomLang.Disable();
+ }
+ else if (pBtn == &maRbCustom)
+ {
+ maLbCustomLang.Enable();
+ }
+ return 0;
+}
+
diff --git a/sc/source/ui/dbgui/textimportoptions.src b/sc/source/ui/dbgui/textimportoptions.src
new file mode 100644
index 000000000000..fff3c4b40749
--- /dev/null
+++ b/sc/source/ui/dbgui/textimportoptions.src
@@ -0,0 +1,112 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: retypepassdlg.src,v $
+ * $Revision: 1.1.2.3 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "textimportoptions.hrc"
+
+ModalDialog RID_SCDLG_TEXT_IMPORT_OPTIONS
+{
+ Text [ en-US ] = "Import Options" ;
+ Size = MAP_APPFONT ( 190 , 101 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ OutputSize = TRUE ;
+
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 135, 6 ) ;
+ Size = MAP_APPFONT ( 50, 14 ) ;
+ DefButton = TRUE ;
+ };
+
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 135, 23 ) ;
+ Size = MAP_APPFONT ( 50, 14 ) ;
+ };
+
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 135, 43 ) ;
+ Size = MAP_APPFONT ( 50, 14 ) ;
+ };
+
+ FixedLine FL_CHOOSE_LANG
+ {
+ Pos = MAP_APPFONT( 6, 3 ) ;
+ Size = MAP_APPFONT( 125, 14 ) ;
+
+ Text [ en-US ] = "Select the language to use for import" ;
+ };
+
+ RadioButton RB_AUTOMATIC
+ {
+ Pos = MAP_APPFONT( 12, 20 ) ;
+ Size = MAP_APPFONT( 50, 10 ) ;
+ TabStop = TRUE ;
+
+ Text [ en-US ] = "Automatic" ;
+ };
+
+ RadioButton RB_CUSTOM
+ {
+ Pos = MAP_APPFONT( 12, 34 ) ;
+ Size = MAP_APPFONT( 50, 10 ) ;
+ TabStop = TRUE ;
+
+ Text [ en-US ] = "Custom" ;
+ };
+
+ ListBox LB_CUSTOM_LANG
+ {
+ Pos = MAP_APPFONT( 20, 50 ) ;
+ Size = MAP_APPFONT( 100, 55 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ Sort = TRUE ;
+ };
+
+ FixedLine FL_OPTION
+ {
+ Pos = MAP_APPFONT( 6, 70 );
+ Size = MAP_APPFONT( 125, 14 );
+
+ Text [ en-US ] = "Options" ;
+ };
+
+ CheckBox BTN_CONVERT_DATE
+ {
+ Pos = MAP_APPFONT( 12, 86 );
+ Size = MAP_APPFONT( 125, 10 );
+ TabStop = TRUE ;
+
+ Text [ en-US ] = "Detect special numbers (such as dates)." ;
+ };
+};
+
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index 1633af000b51..9895f0f43610 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -56,6 +56,7 @@
#include "attrib.hxx"
#include "drwlayer.hxx"
#include "dpshttab.hxx"
+#include "hints.hxx"
// -----------------------------------------------------------------
@@ -592,7 +593,7 @@ BOOL ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam& rSortParam,
if (pDestData)
pNewData = pDestData; // Bereich vorhanden -> anpassen
else // Bereich ab Cursor/Markierung wird angelegt
- pNewData = rDocShell.GetDBData(aDestPos, SC_DB_MAKE, TRUE );
+ pNewData = rDocShell.GetDBData(aDestPos, SC_DB_MAKE, SC_DBSEL_FORCE_MARK );
if (pNewData)
{
pNewData->SetArea( nTab,
@@ -919,7 +920,7 @@ BOOL ScDBDocFunc::Query( SCTAB nTab, const ScQueryParam& rQueryParam,
pNewData = rDocShell.GetDBData(
ScRange( aLocalParam.nCol1, aLocalParam.nRow1, nDestTab,
aLocalParam.nCol2, aLocalParam.nRow2, nDestTab ),
- SC_DB_MAKE, TRUE );
+ SC_DB_MAKE, SC_DBSEL_FORCE_MARK );
if (pNewData)
{
@@ -1403,7 +1404,12 @@ BOOL ScDBDocFunc::DataPilotUpdate( ScDPObject* pOldObj, const ScDPObject* pNewOb
delete pUndoDPObj;
if (bDone)
+ {
+ // notify API objects
+ if (pDestObj)
+ pDoc->BroadcastUno( ScDataPilotModifiedHint( pDestObj->GetName() ) );
aModificator.SetDocumentModified();
+ }
if ( nErrId && !bApi )
rDocShell.ErrorMessage( nErrId );
diff --git a/sc/source/ui/docshell/dbdocimp.cxx b/sc/source/ui/docshell/dbdocimp.cxx
index 17b07099a491..a073e50d105c 100644
--- a/sc/source/ui/docshell/dbdocimp.cxx
+++ b/sc/source/ui/docshell/dbdocimp.cxx
@@ -69,7 +69,7 @@
using namespace com::sun::star;
#define SC_SERVICE_ROWSET "com.sun.star.sdb.RowSet"
-#define SC_SERVICE_INTHANDLER "com.sun.star.sdb.InteractionHandler"
+#define SC_SERVICE_INTHANDLER "com.sun.star.task.InteractionHandler"
//! move to a header file?
#define SC_DBPROP_DATASOURCENAME "DataSourceName"
@@ -86,7 +86,7 @@ void ScDBDocFunc::ShowInBeamer( const ScImportParam& rParam, SfxViewFrame* pFram
if ( !pFrame || !rParam.bImport )
return;
- uno::Reference<frame::XFrame> xFrame = pFrame->GetFrame()->GetFrameInterface();
+ uno::Reference<frame::XFrame> xFrame = pFrame->GetFrame().GetFrameInterface();
uno::Reference<frame::XDispatchProvider> xDP(xFrame, uno::UNO_QUERY);
uno::Reference<frame::XFrame> xBeamerFrame = xFrame->findFrame(
@@ -189,7 +189,7 @@ BOOL ScDBDocFunc::DoImportUno( const ScAddress& rPos,
// create database range
//! merge this with SID_SBA_IMPORT execute in docsh4.cxx
- ScDBData* pDBData = rDocShell.GetDBData( ScRange(rPos), SC_DB_IMPORT, FALSE );
+ ScDBData* pDBData = rDocShell.GetDBData( ScRange(rPos), SC_DB_IMPORT, SC_DBSEL_KEEP );
DBG_ASSERT(pDBData, "can't create DB data");
String sTarget = pDBData->GetName();
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index b991d9027854..26d534416500 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -57,7 +57,6 @@
#include <sfx2/fcontnr.hxx>
#include <sfx2/evntconf.hxx>
#include <sfx2/sfx.hrc>
-#include <sfx2/topfrm.hxx>
#include <sfx2/objface.hxx>
#include <svl/srchitem.hxx>
#include <unotools/fltrcfg.hxx>
@@ -127,6 +126,8 @@
#include <basic/sbstar.hxx>
#include <basic/basmgr.hxx>
using namespace com::sun::star;
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
#include <stdio.h>
#include <string>
@@ -859,6 +860,34 @@ BOOL __EXPORT ScDocShell::LoadFrom( SfxMedium& rMedium )
return bRet;
}
+static void lcl_parseHtmlFilterOption(const OUString& rOption, LanguageType& rLang, bool& rDateConvert)
+{
+ OUStringBuffer aBuf;
+ OUString aTokens[2];
+ sal_Int32 n = rOption.getLength();
+ const sal_Unicode* p = rOption.getStr();
+ sal_Int32 nTokenId = 0;
+ for (sal_Int32 i = 0; i < n; ++i)
+ {
+ const sal_Unicode c = p[i];
+ if (c == sal_Unicode(' '))
+ {
+ if (aBuf.getLength())
+ aTokens[nTokenId++] = aBuf.makeStringAndClear();
+ }
+ else
+ aBuf.append(c);
+
+ if (nTokenId >= 2)
+ break;
+ }
+
+ if (aBuf.getLength())
+ aTokens[nTokenId] = aBuf.makeStringAndClear();
+
+ rLang = static_cast<LanguageType>(aTokens[0].toInt32());
+ rDateConvert = static_cast<bool>(aTokens[1].toInt32());
+}
BOOL __EXPORT ScDocShell::ConvertFrom( SfxMedium& rMedium )
{
@@ -1232,12 +1261,24 @@ BOOL __EXPORT ScDocShell::ConvertFrom( SfxMedium& rMedium )
SvStream* pInStream = rMedium.GetInStream();
if (pInStream)
{
+ LanguageType eLang = LANGUAGE_SYSTEM;
+ bool bDateConvert = false;
+ SfxItemSet* pSet = rMedium.GetItemSet();
+ const SfxPoolItem* pItem;
+ if ( pSet && SFX_ITEM_SET ==
+ pSet->GetItemState( SID_FILE_FILTEROPTIONS, TRUE, &pItem ) )
+ {
+ String aFilterOption = (static_cast<const SfxStringItem*>(pItem))->GetValue();
+ lcl_parseHtmlFilterOption(aFilterOption, eLang, bDateConvert);
+ }
+
pInStream->Seek( 0 );
ScRange aRange;
// HTML macht eigenes ColWidth/RowHeight
CalcOutputFactor();
+ SvNumberFormatter aNumFormatter(aDocument.GetServiceManager(), eLang);
eError = ScFormatFilter::Get().ScImportHTML( *pInStream, rMedium.GetBaseURL(), &aDocument, aRange,
- GetOutputFactor(), !bWebQuery );
+ GetOutputFactor(), !bWebQuery, &aNumFormatter, bDateConvert );
if (eError != eERR_OK)
{
if (!GetError())
@@ -2156,7 +2197,7 @@ USHORT __EXPORT ScDocShell::PrepareClose( BOOL bUI, BOOL bForBrowsing )
{
if(SC_MOD()->GetCurRefDlgId()>0)
{
- SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this, TYPE(SfxTopViewFrame) );
+ SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this );
if( pFrame )
{
SfxViewShell* p = pFrame->GetViewShell();
@@ -2204,6 +2245,11 @@ String ScDocShell::GetOwnFilterName() // static
return String::CreateFromAscii(pFilterSc50);
}
+String ScDocShell::GetHtmlFilterName()
+{
+ return String::CreateFromAscii(pFilterHtml);
+}
+
String ScDocShell::GetWebQueryFilterName() // static
{
return String::CreateFromAscii(pFilterHtmlWebQ);
@@ -2303,22 +2349,19 @@ ScDocShell::ScDocShell( const ScDocShell& rShell )
//------------------------------------------------------------------
-ScDocShell::ScDocShell( SfxObjectCreateMode eMode, const bool _bScriptSupport )
- : SfxObjectShell( eMode ),
- __SCDOCSHELL_INIT
+ScDocShell::ScDocShell( const sal_uInt64 i_nSfxCreationFlags )
+ : SfxObjectShell( i_nSfxCreationFlags )
+ , __SCDOCSHELL_INIT
{
RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::ScDocShell" );
SetPool( &SC_MOD()->GetPool() );
- bIsInplace = (eMode == SFX_CREATE_MODE_EMBEDDED);
+ bIsInplace = (GetCreateMode() == SFX_CREATE_MODE_EMBEDDED);
// wird zurueckgesetzt, wenn nicht inplace
pDocFunc = new ScDocFunc(*this);
- if ( !_bScriptSupport )
- SetHasNoBasic();
-
// SetBaseModel needs exception handling
ScModelObj::CreateAndSet( this );
diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx
index 7ff714c2cbdd..4709a065792f 100644
--- a/sc/source/ui/docshell/docsh3.cxx
+++ b/sc/source/ui/docshell/docsh3.cxx
@@ -1088,6 +1088,16 @@ void ScDocShell::MergeDocument( ScDocument& rOtherDoc, bool bShared, bool bCheck
{
aSourceRange = pDel->GetOverAllRange().MakeRange();
GetDocFunc().DeleteCells( aSourceRange, NULL, DEL_DELROWS, TRUE, FALSE );
+
+ // #i101099# [Collaboration] Changes are not correctly shown
+ if ( bShared )
+ {
+ ScChangeAction* pAct = pThisTrack->GetLast();
+ if ( pAct && pAct->GetType() == eSourceType && pAct->IsDeletedIn() && !pSourceAction->IsDeletedIn() )
+ {
+ pAct->RemoveAllDeletedIn();
+ }
+ }
}
}
break;
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index 97403008915d..157b98497e83 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -53,7 +53,6 @@ using namespace ::com::sun::star;
#include <sfx2/printer.hxx>
#include <sfx2/request.hxx>
#include <svtools/sfxecode.hxx>
-#include <sfx2/topfrm.hxx>
#include <svx/ofaitem.hxx>
#include <sot/formats.hxx>
#include <svtools/printdlg.hxx>
@@ -265,7 +264,7 @@ void ScDocShell::Execute( SfxRequest& rReq )
GetUndoManager()->EnterListAction( aStrImport, aStrImport );
}
- ScDBData* pDBData = GetDBData( ScRange(aPos), SC_DB_IMPORT, FALSE );
+ ScDBData* pDBData = GetDBData( ScRange(aPos), SC_DB_IMPORT, SC_DBSEL_KEEP );
DBG_ASSERT(pDBData, "kann DB-Daten nicht anlegen");
sTarget = pDBData->GetName();
}
@@ -2561,7 +2560,7 @@ ScTabViewShell* ScDocShell::GetBestViewShell( BOOL bOnlyVisible )
if( !pViewSh )
{
// 1. ViewShell suchen
- SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this, TYPE(SfxTopViewFrame), bOnlyVisible );
+ SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this, bOnlyVisible );
if( pFrame )
{
SfxViewShell* p = pFrame->GetViewShell();
diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx
index 6fa6a5ac7863..1bbf9437bc1c 100644
--- a/sc/source/ui/docshell/docsh5.cxx
+++ b/sc/source/ui/docshell/docsh5.cxx
@@ -148,7 +148,7 @@ ScDBData* lcl_GetDBNearCursor( ScDBCollection* pColl, SCCOL nCol, SCROW nRow, SC
return pNoNameData; // "unbenannt" nur zurueck, wenn sonst nichts gefunden
}
-ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, BOOL bForceMark )
+ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGetDBSelection eSel )
{
SCCOL nCol = rMarked.aStart.Col();
SCROW nRow = rMarked.aStart.Row();
@@ -169,7 +169,9 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, BOOL
if (!pData)
pData = lcl_GetDBNearCursor( aDocument.GetDBCollection(), nCol, nRow, nTab );
- BOOL bSelected = ( bForceMark || rMarked.aStart != rMarked.aEnd );
+ BOOL bSelected = ( eSel == SC_DBSEL_FORCE_MARK ||
+ (rMarked.aStart != rMarked.aEnd && eSel != SC_DBSEL_ROW_DOWN) );
+ bool bOnlyDown = (!bSelected && eSel == SC_DBSEL_ROW_DOWN && rMarked.aStart.Row() == rMarked.aEnd.Row());
BOOL bUseThis = FALSE;
if (pData)
@@ -189,12 +191,21 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, BOOL
bUseThis = TRUE;
if ( bIsNoName && eMode == SC_DB_MAKE )
{
- // wenn nichts markiert, "unbenannt" auf zusammenhaengenden Bereich anpassen
+ // If nothing marked or only one row marked, adapt
+ // "unbenannt"/"unnamed" to contiguous area.
nStartCol = nCol;
nStartRow = nRow;
- nEndCol = nStartCol;
- nEndRow = nStartRow;
- aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, FALSE );
+ if (bOnlyDown)
+ {
+ nEndCol = rMarked.aEnd.Col();
+ nEndRow = rMarked.aEnd.Row();
+ }
+ else
+ {
+ nEndCol = nStartCol;
+ nEndRow = nStartRow;
+ }
+ aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, FALSE, bOnlyDown );
if ( nOldCol1 != nStartCol || nOldCol2 != nEndCol || nOldRow1 != nStartRow )
bUseThis = FALSE; // passt gar nicht
else if ( nOldRow2 != nEndRow )
@@ -242,9 +253,17 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, BOOL
{ // zusammenhaengender Bereich
nStartCol = nCol;
nStartRow = nRow;
- nEndCol = nStartCol;
- nEndRow = nStartRow;
- aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, FALSE );
+ if (bOnlyDown)
+ {
+ nEndCol = rMarked.aEnd.Col();
+ nEndRow = rMarked.aEnd.Row();
+ }
+ else
+ {
+ nEndCol = nStartCol;
+ nEndRow = nStartRow;
+ }
+ aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, FALSE, bOnlyDown );
}
BOOL bHasHeader = aDocument.HasColHeader( nStartCol,nStartRow, nEndCol,nEndRow, nTab );
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index 836d6cdf98e6..e7b04afa9c4f 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -238,6 +238,26 @@ void ScExternalRefCache::Table::getAllRows(vector<SCROW>& rRows) const
rRows.swap(aRows);
}
+::std::pair< SCROW, SCROW > ScExternalRefCache::Table::getRowRange() const
+{
+ ::std::pair< SCROW, SCROW > aRange( 0, 0 );
+ if( !maRows.empty() )
+ {
+ // iterate over entire container (hash map is not sorted by key)
+ RowsDataType::const_iterator itr = maRows.begin(), itrEnd = maRows.end();
+ aRange.first = itr->first;
+ aRange.second = itr->first + 1;
+ while( ++itr != itrEnd )
+ {
+ if( itr->first < aRange.first )
+ aRange.first = itr->first;
+ else if( itr->first >= aRange.second )
+ aRange.second = itr->first + 1;
+ }
+ }
+ return aRange;
+}
+
void ScExternalRefCache::Table::getAllCols(SCROW nRow, vector<SCCOL>& rCols) const
{
RowsDataType::const_iterator itrRow = maRows.find(nRow);
@@ -257,6 +277,33 @@ void ScExternalRefCache::Table::getAllCols(SCROW nRow, vector<SCCOL>& rCols) con
rCols.swap(aCols);
}
+::std::pair< SCCOL, SCCOL > ScExternalRefCache::Table::getColRange( SCROW nRow ) const
+{
+ ::std::pair< SCCOL, SCCOL > aRange( 0, 0 );
+
+ RowsDataType::const_iterator itrRow = maRows.find( nRow );
+ if (itrRow == maRows.end())
+ // this table doesn't have the specified row.
+ return aRange;
+
+ const RowDataType& rRowData = itrRow->second;
+ if( !rRowData.empty() )
+ {
+ // iterate over entire container (hash map is not sorted by key)
+ RowDataType::const_iterator itr = rRowData.begin(), itrEnd = rRowData.end();
+ aRange.first = itr->first;
+ aRange.second = itr->first + 1;
+ while( ++itr != itrEnd )
+ {
+ if( itr->first < aRange.first )
+ aRange.first = itr->first;
+ else if( itr->first >= aRange.second )
+ aRange.second = itr->first + 1;
+ }
+ }
+ return aRange;
+}
+
void ScExternalRefCache::Table::getAllNumberFormats(vector<sal_uInt32>& rNumFmts) const
{
RowsDataType::const_iterator itrRow = maRows.begin(), itrRowEnd = maRows.end();
@@ -1942,6 +1989,9 @@ SfxObjectShellRef ScExternalRefManager::loadSrcDocument(sal_uInt16 nFileId, Stri
if (aOptions.Len())
pSet->Put(SfxStringItem(SID_FILE_FILTEROPTIONS, aOptions));
+ // make medium hidden to prevent assertion from progress bar
+ pSet->Put( SfxBoolItem( SID_HIDDEN, TRUE ) );
+
auto_ptr<SfxMedium> pMedium(new SfxMedium(aFile, STREAM_STD_READ, false, pFilter, pSet));
if (pMedium->GetError() != ERRCODE_NONE)
return NULL;
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 8fc49696ba59..46b6b7af3a63 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -902,12 +902,11 @@ BOOL ScImportExport::Text2Doc( SvStream& rStrm )
//
-bool lcl_PutString( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab,
- const String& rStr, BYTE nColFormat,
- ::utl::TransliterationWrapper& rTransliteration,
- CalendarWrapper& rCalendar,
- ::utl::TransliterationWrapper* pSecondTransliteration,
- CalendarWrapper* pSecondCalendar )
+static bool lcl_PutString(
+ ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rStr, BYTE nColFormat,
+ SvNumberFormatter* pFormatter, bool bDetectNumFormat,
+ ::utl::TransliterationWrapper& rTransliteration, CalendarWrapper& rCalendar,
+ ::utl::TransliterationWrapper* pSecondTransliteration, CalendarWrapper* pSecondCalendar )
{
bool bMultiLine = false;
if ( nColFormat == SC_COL_SKIP || !rStr.Len() || !ValidCol(nCol) || !ValidRow(nRow) )
@@ -923,10 +922,10 @@ bool lcl_PutString( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab,
{
//! SetString mit Extra-Flag ???
- SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
- sal_uInt32 nEnglish = pFormatter->GetStandardIndex(LANGUAGE_ENGLISH_US);
+ SvNumberFormatter* pDocFormatter = pDoc->GetFormatTable();
+ sal_uInt32 nEnglish = pDocFormatter->GetStandardIndex(LANGUAGE_ENGLISH_US);
double fVal;
- if ( pFormatter->IsNumberFormat( rStr, nEnglish, fVal ) )
+ if ( pDocFormatter->IsNumberFormat( rStr, nEnglish, fVal ) )
{
// Zahlformat wird nicht auf englisch gesetzt
pDoc->SetValue( nCol, nRow, nTab, fVal );
@@ -1062,9 +1061,9 @@ bool lcl_PutString( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab,
}
}
- SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+ SvNumberFormatter* pDocFormatter = pDoc->GetFormatTable();
if ( nYear < 100 )
- nYear = pFormatter->ExpandTwoDigitYear( nYear );
+ nYear = pDocFormatter->ExpandTwoDigitYear( nYear );
CalendarWrapper* pCalendar = (bSecondCal ? pSecondCalendar : &rCalendar);
sal_Int16 nNumMonths = pCalendar->getNumberOfMonthsInYear();
@@ -1100,7 +1099,7 @@ bool lcl_PutString( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab,
pCalendar->setValue( i18n::CalendarFieldIndex::MILLISECOND, nMilli );
if ( pCalendar->isValid() )
{
- double fDiff = DateTime(*pFormatter->GetNullDate()) -
+ double fDiff = DateTime(*pDocFormatter->GetNullDate()) -
pCalendar->getEpochStart();
// #i14974# must use getLocalDateTime to get the same
// date values as set above
@@ -1112,10 +1111,10 @@ bool lcl_PutString( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab,
LanguageType eDocLang = eLatin; //! which language for date formats?
short nType = (nFound > 3 ? NUMBERFORMAT_DATETIME : NUMBERFORMAT_DATE);
- ULONG nFormat = pFormatter->GetStandardFormat( nType, eDocLang );
+ ULONG nFormat = pDocFormatter->GetStandardFormat( nType, eDocLang );
// maybe there is a special format including seconds or milliseconds
if (nFound > 5)
- nFormat = pFormatter->GetStandardFormat( fDays, nFormat, nType, eDocLang);
+ nFormat = pDocFormatter->GetStandardFormat( fDays, nFormat, nType, eDocLang);
pDoc->PutCell( nCol, nRow, nTab, new ScValueCell(fDays), nFormat, FALSE );
@@ -1127,7 +1126,7 @@ bool lcl_PutString( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab,
// Standard or date not determined -> SetString / EditCell
if( rStr.Search( _LF ) == STRING_NOTFOUND )
- pDoc->SetString( nCol, nRow, nTab, rStr );
+ pDoc->SetString( nCol, nRow, nTab, rStr, pFormatter, bDetectNumFormat );
else
{
bMultiLine = true;
@@ -1137,7 +1136,7 @@ bool lcl_PutString( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab,
}
-String lcl_GetFixed( const String& rLine, xub_StrLen nStart, xub_StrLen nNext )
+String lcl_GetFixed( const String& rLine, xub_StrLen nStart, xub_StrLen nNext, bool& rbIsQuoted )
{
xub_StrLen nLen = rLine.Len();
if (nNext > nLen)
@@ -1151,7 +1150,11 @@ String lcl_GetFixed( const String& rLine, xub_StrLen nStart, xub_StrLen nNext )
while ( nSpace > nStart && pStr[nSpace-1] == ' ' )
--nSpace;
- return rLine.Copy( nStart, nSpace-nStart );
+ rbIsQuoted = (pStr[nStart] == sal_Unicode('"') && pStr[nSpace-1] == sal_Unicode('"'));
+ if (rbIsQuoted)
+ return rLine.Copy(nStart+1, nSpace-nStart-2);
+ else
+ return rLine.Copy(nStart, nSpace-nStart);
}
BOOL ScImportExport::ExtText2Doc( SvStream& rStrm )
@@ -1184,9 +1187,9 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm )
const BYTE* pColFormat = pExtOptions->GetColFormat();
long nSkipLines = pExtOptions->GetStartRow();
- LanguageType eLatin, eCjk, eCtl;
- pDoc->GetLanguage( eLatin, eCjk, eCtl );
- LanguageType eDocLang = eLatin; //! which language for date formats?
+ LanguageType eDocLang = pExtOptions->GetLanguage();
+ SvNumberFormatter aNumFormatter(pDoc->GetServiceManager(), eDocLang);
+ bool bDetectNumFormat = pExtOptions->IsDetectSpecialNumber();
// For date recognition
::utl::TransliterationWrapper aTransliteration(
@@ -1228,6 +1231,8 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm )
// survives the toggle of bDetermineRange down at the end of the do{} loop.
bool bRangeIsDetermined = bDetermineRange;
+ bool bQuotedAsText = pExtOptions && pExtOptions->IsQuotedAsText();
+
ULONG nOriginalStreamPos = rStrm.Tell();
do
@@ -1249,7 +1254,8 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm )
// SC_COL_SKIP.
for ( i=0; i<nInfoCount && nCol <= MAXCOL+1; i++ )
{
- if ( pColFormat[i] != SC_COL_SKIP ) // sonst auch nCol nicht hochzaehlen
+ BYTE nFmt = pColFormat[i];
+ if (nFmt != SC_COL_SKIP) // sonst auch nCol nicht hochzaehlen
{
if (nCol > MAXCOL)
bOverflow = TRUE; // display warning on import
@@ -1257,11 +1263,15 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm )
{
xub_StrLen nStart = pColStart[i];
xub_StrLen nNext = ( i+1 < nInfoCount ) ? pColStart[i+1] : nLineLen;
- aCell = lcl_GetFixed( aLine, nStart, nNext );
- bMultiLine |= lcl_PutString( pDoc, nCol, nRow,
- nTab, aCell, pColFormat[i],
- aTransliteration, aCalendar,
- pEnglishTransliteration, pEnglishCalendar);
+ bool bIsQuoted = false;
+ aCell = lcl_GetFixed( aLine, nStart, nNext, bIsQuoted );
+ if (bIsQuoted && bQuotedAsText)
+ nFmt = SC_COL_TEXT;
+
+ bMultiLine |= lcl_PutString(
+ pDoc, nCol, nRow, nTab, aCell, nFmt,
+ &aNumFormatter, bDetectNumFormat, aTransliteration, aCalendar,
+ pEnglishTransliteration, pEnglishCalendar);
}
++nCol;
}
@@ -1278,7 +1288,8 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm )
// SC_COL_SKIP.
while (*p && nCol <= MAXCOL+1)
{
- p = ScImportExport::ScanNextFieldFromString( p, aCell, cStr, pSeps, bMerge );
+ bool bIsQuoted = false;
+ p = ScImportExport::ScanNextFieldFromString( p, aCell, cStr, pSeps, bMerge, bIsQuoted );
BYTE nFmt = SC_COL_STANDARD;
for ( i=nInfoStart; i<nInfoCount; i++ )
@@ -1295,10 +1306,15 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm )
if (nCol > MAXCOL)
bOverflow = TRUE; // display warning on import
else if (!bDetermineRange)
- bMultiLine |= lcl_PutString( pDoc, nCol, nRow,
- nTab, aCell, nFmt, aTransliteration,
- aCalendar, pEnglishTransliteration,
- pEnglishCalendar);
+ {
+ if (bIsQuoted && bQuotedAsText)
+ nFmt = SC_COL_TEXT;
+
+ bMultiLine |= lcl_PutString(
+ pDoc, nCol, nRow, nTab, aCell, nFmt,
+ &aNumFormatter, bDetectNumFormat, aTransliteration,
+ aCalendar, pEnglishTransliteration, pEnglishCalendar);
+ }
++nCol;
}
@@ -1372,11 +1388,13 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm )
// static
const sal_Unicode* ScImportExport::ScanNextFieldFromString( const sal_Unicode* p,
- String& rField, sal_Unicode cStr, const sal_Unicode* pSeps, BOOL bMergeSeps )
+ String& rField, sal_Unicode cStr, const sal_Unicode* pSeps, bool bMergeSeps, bool& rbIsQuoted )
{
+ rbIsQuoted = false;
rField.Erase();
if ( *p == cStr ) // String in Anfuehrungszeichen
{
+ rbIsQuoted = true;
const sal_Unicode* p1;
p1 = p = lcl_ScanString( p, rField, cStr, DQM_ESCAPE );
while ( *p && !ScGlobal::UnicodeStrChr( pSeps, *p ) )
@@ -2035,7 +2053,7 @@ class ScFormatFilterMissing : public ScFormatFilterPlugin {
virtual FltError ScImportDif( SvStream&, ScDocument*, const ScAddress&,
const CharSet, UINT32 ) RETURN_ERROR
virtual FltError ScImportRTF( SvStream&, const String&, ScDocument*, ScRange& ) RETURN_ERROR
- virtual FltError ScImportHTML( SvStream&, const String&, ScDocument*, ScRange&, double, BOOL ) RETURN_ERROR
+ virtual FltError ScImportHTML( SvStream&, const String&, ScDocument*, ScRange&, double, BOOL, SvNumberFormatter*, bool ) RETURN_ERROR
virtual ScEEAbsImport *CreateRTFImport( ScDocument*, const ScRange& ) { return NULL; }
virtual ScEEAbsImport *CreateHTMLImport( ScDocument*, const String&, const ScRange&, BOOL ) { return NULL; }
diff --git a/sc/source/ui/drawfunc/drawsh.cxx b/sc/source/ui/drawfunc/drawsh.cxx
index b44c396f4e0c..e2f70432d679 100644
--- a/sc/source/ui/drawfunc/drawsh.cxx
+++ b/sc/source/ui/drawfunc/drawsh.cxx
@@ -335,7 +335,7 @@ void ScDrawShell::ExecuteMacroAssign( SdrObject* pObj, Window* pWin )
com::sun::star::uno::Reference < com::sun::star::frame::XFrame > xFrame;
if (GetViewShell())
- xFrame = GetViewShell()->GetViewFrame()->GetFrame()->GetFrameInterface();
+ xFrame = GetViewShell()->GetViewFrame()->GetFrame().GetFrameInterface();
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
SfxAbstractDialog* pMacroDlg = pFact->CreateSfxDialog( pWin, *pItemSet, xFrame, SID_EVENTCONFIG );
diff --git a/sc/source/ui/drawfunc/fudraw.cxx b/sc/source/ui/drawfunc/fudraw.cxx
index 3a3fc833a515..bad23bf26ed1 100644
--- a/sc/source/ui/drawfunc/fudraw.cxx
+++ b/sc/source/ui/drawfunc/fudraw.cxx
@@ -310,7 +310,7 @@ BOOL __EXPORT FuDraw::KeyInput(const KeyEvent& rKEvt)
const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
if( !pView->IsTextEdit() && 1 == rMarkList.GetMarkCount() )
{
- BOOL bOle = pViewShell->GetViewFrame()->GetFrame()->IsInPlace();
+ BOOL bOle = pViewShell->GetViewFrame()->GetFrame().IsInPlace();
SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
if( pObj && pObj->ISA( SdrOle2Obj ) && !bOle )
{
diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx
index e0721fc47f50..f648a1484e8e 100644
--- a/sc/source/ui/drawfunc/fuins2.cxx
+++ b/sc/source/ui/drawfunc/fuins2.cxx
@@ -526,7 +526,8 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView*
ScRangeList aRanges;
aMultiMark.FillRangeListWithMarks( &aRanges, FALSE );
String aStr;
- aRanges.Format( aStr, SCR_ABS_3D, pViewSh->GetViewData()->GetDocument() );
+ ScDocument* pDocument = pViewSh->GetViewData()->GetDocument();
+ aRanges.Format( aStr, SCR_ABS_3D, pDocument, pDocument->GetAddressConvention() );
aRangeString = aStr;
// get "total" range for positioning
diff --git a/sc/source/ui/drawfunc/fusel.cxx b/sc/source/ui/drawfunc/fusel.cxx
index 213169b8b9fd..4a456522003c 100644
--- a/sc/source/ui/drawfunc/fusel.cxx
+++ b/sc/source/ui/drawfunc/fusel.cxx
@@ -390,7 +390,7 @@ BOOL __EXPORT FuSelection::MouseButtonUp(const MouseEvent& rMEvt)
BOOL bReturn = FuDraw::MouseButtonUp(rMEvt);
// BOOL bOle = pViewShell->GetViewData()->IsOle();
- BOOL bOle = pViewShell->GetViewFrame()->GetFrame()->IsInPlace();
+ BOOL bOle = pViewShell->GetViewFrame()->GetFrame().IsInPlace();
if (aDragTimer.IsActive() )
{
diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx
index d9add14952a4..2d9cdef1b54e 100644
--- a/sc/source/ui/formdlg/formula.cxx
+++ b/sc/source/ui/formdlg/formula.cxx
@@ -40,7 +40,6 @@
#include <svl/stritem.hxx>
#include <svtools/svtreebx.hxx>
#include <sfx2/viewfrm.hxx>
-#include <sfx2/topfrm.hxx>
#include <vcl/svapp.hxx>
#include <vcl/mnemonic.hxx>
#include <unotools/charclass.hxx>
@@ -308,7 +307,7 @@ ScInputHandler* ScFormulaDlg::GetNextInputHandler(ScDocShell* pDocShell,PtrTabVi
{
ScInputHandler* pHdl=NULL;
- SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell, TYPE(SfxTopViewFrame) );
+ SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
while( pFrame && pHdl==NULL)
{
SfxViewShell* p = pFrame->GetViewShell();
@@ -318,7 +317,7 @@ ScInputHandler* ScFormulaDlg::GetNextInputHandler(ScDocShell* pDocShell,PtrTabVi
pHdl=pViewSh->GetInputHandler();
if(ppViewSh!=NULL) *ppViewSh=pViewSh;
}
- pFrame = SfxViewFrame::GetNext(*pFrame,pDocShell, TYPE(SfxTopViewFrame) );
+ pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell );
}
diff --git a/sc/source/ui/inc/asciiopt.hxx b/sc/source/ui/inc/asciiopt.hxx
index aee63d682a26..a5c7a2b554b4 100644
--- a/sc/source/ui/inc/asciiopt.hxx
+++ b/sc/source/ui/inc/asciiopt.hxx
@@ -52,7 +52,7 @@
#include <tools/stream.hxx>
#include <svx/txencbox.hxx>
#include "csvtablebox.hxx"
-
+#include "i18npool/lang.h"
// ============================================================================
@@ -62,8 +62,11 @@ private:
BOOL bFixedLen;
String aFieldSeps;
BOOL bMergeFieldSeps;
+ bool bQuotedFieldAsText;
+ bool bDetectSpecialNumber;
sal_Unicode cTextSep;
CharSet eCharSet;
+ LanguageType eLang;
BOOL bCharSetSystem;
long nStartRow;
USHORT nInfoCount;
@@ -90,20 +93,26 @@ public:
BOOL GetCharSetSystem() const { return bCharSetSystem; }
const String& GetFieldSeps() const { return aFieldSeps; }
BOOL IsMergeSeps() const { return bMergeFieldSeps; }
+ bool IsQuotedAsText() const { return bQuotedFieldAsText; }
+ bool IsDetectSpecialNumber() const { return bDetectSpecialNumber; }
sal_Unicode GetTextSep() const { return cTextSep; }
BOOL IsFixedLen() const { return bFixedLen; }
USHORT GetInfoCount() const { return nInfoCount; }
const xub_StrLen* GetColStart() const { return pColStart; }
const BYTE* GetColFormat() const { return pColFormat; }
long GetStartRow() const { return nStartRow; }
+ LanguageType GetLanguage() const { return eLang; }
void SetCharSet( CharSet eNew ) { eCharSet = eNew; }
void SetCharSetSystem( BOOL bSet ) { bCharSetSystem = bSet; }
void SetFixedLen( BOOL bSet ) { bFixedLen = bSet; }
void SetFieldSeps( const String& rStr ) { aFieldSeps = rStr; }
void SetMergeSeps( BOOL bSet ) { bMergeFieldSeps = bSet; }
+ void SetQuotedAsText(bool bSet) { bQuotedFieldAsText = bSet; }
+ void SetDetectSpecialNumber(bool bSet) { bDetectSpecialNumber = bSet; }
void SetTextSep( sal_Unicode c ) { cTextSep = c; }
void SetStartRow( long nRow) { nStartRow= nRow; }
+ void SetLanguage(LanguageType e) { eLang = e; }
void SetColInfo( USHORT nCount, const xub_StrLen* pStart, const BYTE* pFormat );
void SetColumnInfo( const ScCsvExpDataVec& rDataVec );
diff --git a/sc/source/ui/inc/csvruler.hxx b/sc/source/ui/inc/csvruler.hxx
index 5ddeb1f1ceba..52be4b4ebd8c 100644
--- a/sc/source/ui/inc/csvruler.hxx
+++ b/sc/source/ui/inc/csvruler.hxx
@@ -68,6 +68,7 @@ private:
// ------------------------------------------------------------------------
public:
explicit ScCsvRuler( ScCsvControl& rParent );
+ ~ScCsvRuler();
// common ruler handling --------------------------------------------------
public:
diff --git a/sc/source/ui/inc/dbfunc.hxx b/sc/source/ui/inc/dbfunc.hxx
index 87df03b8ecd9..baadae0a64dc 100644
--- a/sc/source/ui/inc/dbfunc.hxx
+++ b/sc/source/ui/inc/dbfunc.hxx
@@ -53,7 +53,7 @@ private:
public:
ScDBFunc( Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell );
//UNUSED2008-05 ScDBFunc( Window* pParent, const ScDBFunc& rDBFunc, ScTabViewShell* pViewShell );
- ~ScDBFunc();
+ virtual ~ScDBFunc();
// nur UISort wiederholt bei Bedarf die Teilergebnisse
@@ -77,7 +77,7 @@ public:
void GotoDBArea( const String& rDBName );
// DB-Bereich vom Cursor
- ScDBData* GetDBData( BOOL bMarkArea = TRUE, ScGetDBMode eMode = SC_DB_MAKE, bool bShrinkToData = false );
+ ScDBData* GetDBData( BOOL bMarkArea = TRUE, ScGetDBMode eMode = SC_DB_MAKE, ScGetDBSelection eSel = SC_DBSEL_KEEP );
void NotifyCloseDbNameDlg( const ScDBCollection& rNewColl, const List& rDelAreaList );
@@ -86,8 +86,10 @@ public:
bool MakePivotTable( const ScDPSaveData& rData, const ScRange& rDest, BOOL bNewTable,
const ScDPObject& rSource, BOOL bApi = FALSE );
void DeletePivotTable();
- void RecalcPivotTable();
-
+ // Wang Xu Ming -- 2009-6-17
+ // DataPilot Migration
+ ULONG RecalcPivotTable();
+ // End Comments
BOOL HasSelectionForDateGroup( ScDPNumGroupInfo& rOldInfo, sal_Int32& rParts );
BOOL HasSelectionForNumGroup( ScDPNumGroupInfo& rOldInfo );
void GroupDataPilot();
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index da5e5e7ffbff..09d34c661995 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -31,10 +31,8 @@
#include <sfx2/objsh.hxx>
-//REMOVE #ifndef _SFX_INTERNO_HXX //autogen
-//REMOVE #include <sfx2/interno.hxx>
-//REMOVE #endif
#include <sfx2/docfac.hxx>
+#include <sfx2/sfxmodelfactory.hxx>
#include <sfx2/viewsh.hxx>
#include "scdllapi.h"
@@ -179,7 +177,7 @@ public:
SFX_DECL_OBJECTFACTORY();
ScDocShell( const ScDocShell& rDocShell );
- ScDocShell( SfxObjectCreateMode eMode = SFX_CREATE_MODE_EMBEDDED, const bool _bScriptSupport = true );
+ ScDocShell( const sal_uInt64 i_nSfxCreationFlags = SFXMODEL_EMBEDDED_OBJECT );
~ScDocShell();
using SotObject::GetInterface;
@@ -315,7 +313,7 @@ public:
BOOL IsOle();
void DBAreaDeleted( SCTAB nTab, SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 );
- ScDBData* GetDBData( const ScRange& rMarked, ScGetDBMode eMode, BOOL bForceMark );
+ ScDBData* GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGetDBSelection eSel );
ScDBData* GetOldAutoDBRange(); // has to be deleted by caller!
void CancelAutoDBRange(); // called when dialog is cancelled
@@ -399,6 +397,7 @@ public:
static ScDocShell* GetShellByNum( USHORT nDocNo );
static String GetOwnFilterName();
+ static String GetHtmlFilterName();
static String GetWebQueryFilterName();
static String GetAsciiFilterName();
static String GetLotusFilterName();
diff --git a/sc/source/ui/inc/fieldwnd.hxx b/sc/source/ui/inc/fieldwnd.hxx
index 45a573e72157..539dbe54e275 100644..100755
--- a/sc/source/ui/inc/fieldwnd.hxx
+++ b/sc/source/ui/inc/fieldwnd.hxx
@@ -34,7 +34,6 @@
#include <vcl/fixed.hxx>
#include <cppuhelper/weakref.hxx>
-#define MAX_LABELS 256
#define PAGE_SIZE 16 // count of visible fields for scrollbar
#define LINE_SIZE 8 // count of fields per column for scrollbar
#define MAX_FIELDS 8 // maximum count of fields for row/col/data area
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 0f8e479f6e54..149498a8314d 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -273,7 +273,7 @@ private:
void PasteSelection( const Point& rPosPixel );
- void SelectForContextMenu( const Point& rPosPixel );
+ void SelectForContextMenu( const Point& rPosPixel, SCsCOL nCellX, SCsROW nCellY );
void GetSelectionRects( ::std::vector< Rectangle >& rPixelRects );
diff --git a/sc/source/ui/inc/hdrcont.hxx b/sc/source/ui/inc/hdrcont.hxx
index 02a4df09afd2..ec4dd49705d1 100644
--- a/sc/source/ui/inc/hdrcont.hxx
+++ b/sc/source/ui/inc/hdrcont.hxx
@@ -77,7 +77,7 @@ private:
long GetScrPos( SCCOLROW nEntryNo );
SCCOLROW GetMousePos( const MouseEvent& rMEvt, BOOL& rBorder );
-
+ bool IsSelectionAllowed(SCCOLROW nPos) const;
void ShowDragHelp();
void DoPaint( SCCOLROW nStart, SCCOLROW nEnd );
diff --git a/sc/source/ui/inc/impex.hxx b/sc/source/ui/inc/impex.hxx
index fe4177df7cae..86a91216edcc 100644
--- a/sc/source/ui/inc/impex.hxx
+++ b/sc/source/ui/inc/impex.hxx
@@ -107,7 +107,7 @@ public:
static BOOL IsFormatSupported( ULONG nFormat );
static const sal_Unicode* ScanNextFieldFromString( const sal_Unicode* p,
- String& rField, sal_Unicode cStr, const sal_Unicode* pSeps, BOOL bMergeSeps );
+ String& rField, sal_Unicode cStr, const sal_Unicode* pSeps, bool bMergeSeps, bool& rbIsQuoted );
static void WriteUnicodeOrByteString( SvStream& rStrm, const String& rString, BOOL bZero = FALSE );
static void WriteUnicodeOrByteEndl( SvStream& rStrm );
static inline BOOL IsEndianSwap( const SvStream& rStrm );
diff --git a/sc/source/ui/inc/scuiasciiopt.hxx b/sc/source/ui/inc/scuiasciiopt.hxx
index a1f73458c3a0..3e1a7db38fb2 100644
--- a/sc/source/ui/inc/scuiasciiopt.hxx
+++ b/sc/source/ui/inc/scuiasciiopt.hxx
@@ -32,6 +32,8 @@
#include "asciiopt.hxx"
+#include "svx/langbox.hxx"
+
// ============================================================================
class ScImportAsciiDlg : public ModalDialog
@@ -46,6 +48,8 @@ class ScImportAsciiDlg : public ModalDialog
FixedLine aFlFieldOpt;
FixedText aFtCharSet;
SvxTextEncodingBox aLbCharSet;
+ FixedText aFtCustomLang;
+ SvxLanguageBox aLbCustomLang;
FixedText aFtRow;
NumericField aNfRow;
@@ -61,9 +65,15 @@ class ScImportAsciiDlg : public ModalDialog
CheckBox aCkbOther;
Edit aEdOther;
CheckBox aCkbAsOnce;
+
+ FixedLine aFlOtherOpt;
+
FixedText aFtTextSep;
ComboBox aCbTextSep;
+ CheckBox aCkbQuotedAsText;
+ CheckBox aCkbDetectNumber;
+
FixedLine aFlWidth;
FixedText aFtType;
ListBox aLbType;
@@ -84,6 +94,7 @@ class ScImportAsciiDlg : public ModalDialog
CharSet meCharSet; /// Selected char set.
bool mbCharSetSystem; /// Is System char set selected?
+ bool mbFileImport; /// Is this dialog involked for csv file import ?
public:
ScImportAsciiDlg(
@@ -93,6 +104,7 @@ public:
void GetOptions( ScAsciiOptions& rOpt );
void SetTextToColumnsMode();
+ void SaveParameters();
private:
/** Sets the selected char set data to meCharSet and mbCharSetSystem. */
diff --git a/sc/source/core/data/pivot.cxx b/sc/source/ui/inc/textimportoptions.hrc
index e63b228de703..93c554ef5c45 100644
--- a/sc/source/core/data/pivot.cxx
+++ b/sc/source/ui/inc/textimportoptions.hrc
@@ -2,10 +2,13 @@
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
- * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
+ * $RCSfile: retypepassdlg.src,v $
+ * $Revision: 1.1.2.3 $
+ *
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
@@ -25,10 +28,15 @@
*
************************************************************************/
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_sc.hxx"
-
-
+#include <sc.hrc>
-// -----------------------------------------------------------------------
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 3
+#define FL_CHOOSE_LANG 4
+#define RB_AUTOMATIC 5
+#define RB_CUSTOM 6
+#define LB_CUSTOM_LANG 7
+#define FL_OPTION 8
+#define BTN_CONVERT_DATE 9
diff --git a/sc/source/ui/inc/textimportoptions.hxx b/sc/source/ui/inc/textimportoptions.hxx
new file mode 100644
index 000000000000..bbb2bf6ebf09
--- /dev/null
+++ b/sc/source/ui/inc/textimportoptions.hxx
@@ -0,0 +1,76 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: langbox.hxx,v $
+ * $Revision: 1.4.242.1 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef SC_UI_IMPORTOPTIONS_HXX
+#define SC_UI_IMPORTOPTIONS_HXX
+
+#include "vcl/dialog.hxx"
+#include "vcl/button.hxx"
+#include "vcl/fixed.hxx"
+#include "i18npool/lang.h"
+#include "svx/langbox.hxx"
+
+class ScTextImportOptionsDlg : public ModalDialog
+{
+public:
+ ScTextImportOptionsDlg(Window* pParent);
+ virtual ~ScTextImportOptionsDlg();
+
+ virtual short Execute();
+
+ LanguageType getLanguageType() const;
+ bool isDateConversionSet() const;
+
+private:
+ void init();
+
+private:
+ OKButton maBtnOk;
+ CancelButton maBtnCancel;
+ HelpButton maBtnHelp;
+
+ FixedLine maFlChooseLang;
+
+ RadioButton maRbAutomatic;
+ RadioButton maRbCustom;
+
+ SvxLanguageBox maLbCustomLang;
+
+ FixedLine maFlOption;
+
+ CheckBox maBtnConvertDate;
+
+ DECL_LINK( OKHdl, OKButton* );
+
+ DECL_LINK( RadioHdl, RadioButton* );
+};
+
+
+#endif
diff --git a/sc/source/ui/inc/ui_pch.hxx b/sc/source/ui/inc/ui_pch.hxx
index ba0cd9dbd3ce..1ef2f02d405b 100644
--- a/sc/source/ui/inc/ui_pch.hxx
+++ b/sc/source/ui/inc/ui_pch.hxx
@@ -171,7 +171,6 @@
#include <svl/inethist.hxx>
#include <svl/inetdef.hxx>
#include <sfx2/sfxdefs.hxx>
-#include <svl/cancel.hxx>
#include <svtools/compat.hxx>
#include <svl/inetmsg.hxx>
#include <sfx2/app.hxx>
diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx
index 30e34def4620..32b3376da9a7 100644
--- a/sc/source/ui/miscdlgs/anyrefdg.cxx
+++ b/sc/source/ui/miscdlgs/anyrefdg.cxx
@@ -39,7 +39,6 @@
#include <vcl/mnemonic.hxx>
#include <tools/shl.hxx>
#include <svtools/taskbar.hxx>
-#include <sfx2/topfrm.hxx>
#include <sfx2/bindings.hxx>
#include <sfx2/dispatch.hxx>
@@ -103,7 +102,7 @@ void ScFormulaReferenceHelper::enableInput( BOOL bEnable )
while( pFrame )
{
// #71577# enable everything except InPlace, including bean frames
- if ( !pFrame->GetFrame()->IsInPlace() )
+ if ( !pFrame->GetFrame().IsInPlace() )
{
SfxViewShell* p = pFrame->GetViewShell();
ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,p);
@@ -602,7 +601,7 @@ void ScFormulaReferenceHelper::EnableSpreadsheets(BOOL bFlag, BOOL bChilds)
while( pFrame )
{
// #71577# enable everything except InPlace, including bean frames
- if ( !pFrame->GetFrame()->IsInPlace() )
+ if ( !pFrame->GetFrame().IsInPlace() )
{
SfxViewShell* p = pFrame->GetViewShell();
ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,p);
@@ -642,7 +641,7 @@ void lcl_InvalidateWindows()
while( pFrame )
{
// #71577# enable everything except InPlace, including bean frames
- if ( !pFrame->GetFrame()->IsInPlace() )
+ if ( !pFrame->GetFrame().IsInPlace() )
{
SfxViewShell* p = pFrame->GetViewShell();
ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,p);
diff --git a/sc/source/ui/miscdlgs/autofmt.cxx b/sc/source/ui/miscdlgs/autofmt.cxx
index 78e5ea066c7d..940856775c07 100644
--- a/sc/source/ui/miscdlgs/autofmt.cxx
+++ b/sc/source/ui/miscdlgs/autofmt.cxx
@@ -44,10 +44,10 @@
#include <editeng/shdditem.hxx>
#include <editeng/udlnitem.hxx>
#include <editeng/wghtitem.hxx>
-#include <sfx2/topfrm.hxx>
#include <vcl/svapp.hxx>
#include <svl/zforlist.hxx>
#include <vcl/msgbox.hxx>
+#include <sfx2/viewfrm.hxx>
#include <comphelper/processfactory.hxx>
#include "sc.hrc"
diff --git a/sc/source/ui/miscdlgs/scuiautofmt.cxx b/sc/source/ui/miscdlgs/scuiautofmt.cxx
index 79d7c502921f..b2f837db4cb4 100644
--- a/sc/source/ui/miscdlgs/scuiautofmt.cxx
+++ b/sc/source/ui/miscdlgs/scuiautofmt.cxx
@@ -369,7 +369,7 @@ IMPL_LINK( ScAutoFormatDlg, RenameHdl, void *, EMPTYARG )
aStrRename,
aStrLabel,
aFormatName,
- HID_SC_RENAME_AUTOFMT );
+ HID_SC_REN_AFMT_DLG );
if( pDlg->Execute() == RET_OK )
{
BOOL bFmtRenamed = FALSE;
diff --git a/sc/source/ui/miscdlgs/strindlg.cxx b/sc/source/ui/miscdlgs/strindlg.cxx
index aa6db3075b64..b8dc2e13538e 100644
--- a/sc/source/ui/miscdlgs/strindlg.cxx
+++ b/sc/source/ui/miscdlgs/strindlg.cxx
@@ -72,25 +72,21 @@ ScStringInputDlg::ScStringInputDlg( Window* pParent,
// HelpId for Edit different for different uses
- DBG_ASSERT( nHelpId == FID_TAB_APPEND || nHelpId == FID_TAB_RENAME ||
- nHelpId == HID_SC_ADD_AUTOFMT || nHelpId == HID_SC_RENAME_AUTOFMT ||
- nHelpId == SID_RENAME_OBJECT ||
- // #i68101#
- nHelpId == SID_TITLE_DESCRIPTION_OBJECT,
- "unknown ID" );
if ( nHelpId == FID_TAB_APPEND )
aEdInput.SetHelpId( HID_SC_APPEND_NAME );
else if ( nHelpId == FID_TAB_RENAME )
aEdInput.SetHelpId( HID_SC_RENAME_NAME );
else if ( nHelpId == HID_SC_ADD_AUTOFMT )
aEdInput.SetHelpId( HID_SC_AUTOFMT_NAME );
- else if ( nHelpId == HID_SC_RENAME_AUTOFMT )
+ else if ( nHelpId == HID_SC_REN_AFMT_DLG )
aEdInput.SetHelpId( HID_SC_REN_AFMT_NAME );
else if ( nHelpId == SID_RENAME_OBJECT )
aEdInput.SetHelpId( HID_SC_RENAME_OBJECT );
// #i68101#
else if ( nHelpId == SID_TITLE_DESCRIPTION_OBJECT )
aEdInput.SetHelpId( HID_SC_TITLE_DESCRIPTION_OBJECT );
+ else
+ DBG_ERRORFILE( "unknown ID" );
//-------------
FreeResource();
diff --git a/sc/source/ui/src/globstr.src b/sc/source/ui/src/globstr.src
index 6efb249ade84..96c56706f83c 100644
--- a/sc/source/ui/src/globstr.src
+++ b/sc/source/ui/src/globstr.src
@@ -1021,7 +1021,7 @@ Resource RID_GLOBSTR
};
String STR_QUERY_DELTAB
{
- Text [ en-US ] = "Are you sure you want to permanently delete the current sheet(s)?" ;
+ Text [ en-US ] = "Are you sure you want to delete the selected sheet(s)?" ;
};
String STR_QUERY_DELSCENARIO
{
@@ -1730,5 +1730,17 @@ Resource RID_GLOBSTR
{
Text [ en-US ] = "Page Styles";
};
+ String STR_ERR_DATAPILOTSOURCE
+ {
+ Text [ en-US ] = "DataPilot source data is invalid.";
+ };
+ String STR_PIVOT_FIRSTROWEMPTYERR
+ {
+ Text [ en-US ] = "The field name cannot be empty. Check the first row of data source to make sure there are no empty cells." ;
+ };
+ String STR_PIVOT_ONLYONEROWERR
+ {
+ Text [ en-US ] = "DataPilot table needs at least two rows of data to create or refresh." ;
+ };
};
diff --git a/sc/source/ui/src/miscdlgs.src b/sc/source/ui/src/miscdlgs.src
index 689938403658..e7d682e845e9 100644
--- a/sc/source/ui/src/miscdlgs.src
+++ b/sc/source/ui/src/miscdlgs.src
@@ -233,7 +233,7 @@ ModalDialog RID_SCDLG_DELCONT
{
Pos = MAP_APPFONT ( 12 , 86 ) ;
Size = MAP_APPFONT ( 83 , 10 ) ;
- Text [ en-US ] = "Not~es" ;
+ Text [ en-US ] = "~Comments" ;
TabStop = TRUE ;
};
CheckBox BTN_DELOBJECTS
@@ -326,14 +326,14 @@ ModalDialog RID_SCDLG_INSCONT
{
Pos = MAP_APPFONT ( 12 , 114 ) ;
Size = MAP_APPFONT ( 84 , 10 ) ;
- Text [ en-US ] = "O~bjects" ;
+ Text [ en-US ] = "~Objects" ;
TabStop = TRUE ;
};
CheckBox BTN_INSNOTES
{
Pos = MAP_APPFONT ( 12 , 86 ) ;
Size = MAP_APPFONT ( 84 , 10 ) ;
- Text [ en-US ] = "N~otes" ;
+ Text [ en-US ] = "~Comments" ;
TabStop = TRUE ;
};
FixedLine FL_FRAME
@@ -358,7 +358,7 @@ ModalDialog RID_SCDLG_INSCONT
{
Pos = MAP_APPFONT ( 111 , 44 ) ;
Size = MAP_APPFONT ( 83 , 10 ) ;
- Text [ en-US ] = "S~ubtract" ;
+ Text [ en-US ] = "~Subtract" ;
};
RadioButton BTN_OP_MUL
{
diff --git a/sc/source/ui/undo/makefile.mk b/sc/source/ui/undo/makefile.mk
index 168130c022ea..01edd92f8553 100644
--- a/sc/source/ui/undo/makefile.mk
+++ b/sc/source/ui/undo/makefile.mk
@@ -74,6 +74,8 @@ SLOFILES = \
$(SLO)$/undotab.obj
EXCEPTIONSFILES= \
+ $(SLO)$/undoblk3.obj \
+ $(SLO)$/undocell.obj \
$(SLO)$/undostyl.obj
# --- Tagets -------------------------------------------------------
diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx
index 2ed65d5db6f5..d550d54f1aea 100644
--- a/sc/source/ui/undo/undodat.cxx
+++ b/sc/source/ui/undo/undodat.cxx
@@ -50,6 +50,7 @@
#include "olinefun.hxx"
#include "dpobject.hxx"
#include "attrib.hxx"
+#include "hints.hxx"
#include "sc.hrc"
// -----------------------------------------------------------------------
@@ -1902,6 +1903,12 @@ void __EXPORT ScUndoDataPilot::Undo()
//! set current sheet
}
+ if (pNewDPObject)
+ {
+ // notify API objects
+ pDoc->BroadcastUno( ScDataPilotModifiedHint( pNewDPObject->GetName() ) );
+ }
+
EndUndo();
}
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 1a3dd3010734..67d651087082 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -5516,7 +5516,7 @@ uno::Sequence<beans::PropertyValue> SAL_CALL ScCellRangeObj::createSortDescripto
if ( pDocSh )
{
// DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
- ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, TRUE );
+ ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
if (pData)
{
pData->GetSortParam(aParam);
@@ -5547,7 +5547,7 @@ void SAL_CALL ScCellRangeObj::sort( const uno::Sequence<beans::PropertyValue>& a
{
USHORT i;
ScSortParam aParam;
- ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_MAKE, TRUE ); // ggf. Bereich anlegen
+ ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
if (pData)
{
// alten Einstellungen holen, falls nicht alles neu gesetzt wird
@@ -5576,7 +5576,7 @@ void SAL_CALL ScCellRangeObj::sort( const uno::Sequence<beans::PropertyValue>& a
aParam.nCol2 = aRange.aEnd.Col();
aParam.nRow2 = aRange.aEnd.Row();
- pDocSh->GetDBData( aRange, SC_DB_MAKE, TRUE ); // ggf. Bereich anlegen
+ pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
ScDBDocFunc aFunc(*pDocSh); // Bereich muss angelegt sein
aFunc.Sort( nTab, aParam, TRUE, TRUE, TRUE );
@@ -5594,7 +5594,7 @@ uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScCellRangeObj::createFil
if ( !bEmpty && pDocSh )
{
// DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
- ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, TRUE );
+ ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
if (pData)
{
ScQueryParam aParam;
@@ -5676,7 +5676,7 @@ void SAL_CALL ScCellRangeObj::filter( const uno::Reference<sheet::XSheetFilterDe
aParam.nCol2 = aRange.aEnd.Col();
aParam.nRow2 = aRange.aEnd.Row();
- pDocSh->GetDBData( aRange, SC_DB_MAKE, TRUE ); // ggf. Bereich anlegen
+ pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
//! keep source range in filter descriptor
//! if created by createFilterDescriptorByObject ???
@@ -5763,7 +5763,7 @@ uno::Reference<sheet::XSubTotalDescriptor> SAL_CALL ScCellRangeObj::createSubTot
if ( !bEmpty && pDocSh )
{
// DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
- ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, TRUE );
+ ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
if (pData)
{
ScSubTotalParam aParam;
@@ -5826,7 +5826,7 @@ void SAL_CALL ScCellRangeObj::applySubTotals(
aParam.nCol2 = aRange.aEnd.Col();
aParam.nRow2 = aRange.aEnd.Row();
- pDocSh->GetDBData( aRange, SC_DB_MAKE, TRUE ); // ggf. Bereich anlegen
+ pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
ScDBDocFunc aFunc(*pDocSh);
aFunc.DoSubTotals( nTab, aParam, NULL, TRUE, TRUE ); // Bereich muss angelegt sein
@@ -5841,7 +5841,7 @@ void SAL_CALL ScCellRangeObj::removeSubTotals() throw(uno::RuntimeException)
if (pDocSh)
{
ScSubTotalParam aParam;
- ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, TRUE );
+ ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
if (pData)
pData->GetSubTotalParam(aParam); // auch bei Remove die Feld-Eintraege behalten
@@ -5853,7 +5853,7 @@ void SAL_CALL ScCellRangeObj::removeSubTotals() throw(uno::RuntimeException)
aParam.nCol2 = aRange.aEnd.Col();
aParam.nRow2 = aRange.aEnd.Row();
- pDocSh->GetDBData( aRange, SC_DB_MAKE, TRUE ); // ggf. Bereich anlegen
+ pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
ScDBDocFunc aFunc(*pDocSh);
aFunc.DoSubTotals( nTab, aParam, NULL, TRUE, TRUE ); // Bereich muss angelegt sein
@@ -5869,7 +5869,7 @@ uno::Sequence<beans::PropertyValue> SAL_CALL ScCellRangeObj::createImportDescrip
if ( !bEmpty && pDocSh )
{
// DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
- ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, TRUE );
+ ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
if (pData)
pData->GetImportParam(aParam);
}
@@ -5898,7 +5898,7 @@ void SAL_CALL ScCellRangeObj::doImport( const uno::Sequence<beans::PropertyValue
//! TODO: could we get passed a valid result set by any means?
uno::Reference< sdbc::XResultSet > xResultSet;
- pDocSh->GetDBData( aRange, SC_DB_MAKE, TRUE ); // ggf. Bereich anlegen
+ pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
ScDBDocFunc aFunc(*pDocSh); // Bereich muss angelegt sein
aFunc.DoImport( nTab, aParam, xResultSet, NULL, TRUE, FALSE ); //! Api-Flag als Parameter
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index b8a751669e6f..8654de8a429e 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -118,61 +118,6 @@ template< typename T >
return aResult;
}
-::std::vector< ::rtl::OUString > lcl_getRangeRepresentationsFromDataSource(
- const uno::Reference< chart2::data::XDataSource > & xDataSource )
-{
- ::std::vector< ::rtl::OUString > aResult;
- if( xDataSource.is())
- {
- uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSequences(
- xDataSource->getDataSequences());
- const sal_Int32 nCount( aSequences.getLength());
- for( sal_Int32 nIdx=0; nIdx<nCount; ++nIdx )
- {
- if( aSequences[nIdx].is() )
- {
- // first: label
- uno::Reference< chart2::data::XDataSequence > xSeq( aSequences[nIdx]->getLabel());
- if( xSeq.is())
- aResult.push_back( xSeq->getSourceRangeRepresentation());
- // then: values
- xSeq.set( aSequences[nIdx]->getValues());
- if( xSeq.is())
- aResult.push_back( xSeq->getSourceRangeRepresentation());
- }
- }
- }
- return aResult;
-}
-
-uno::Reference< chart2::data::XLabeledDataSequence > lcl_getCategoriesFromDataSource(
- const uno::Reference< chart2::data::XDataSource > & xDataSource )
-{
- uno::Reference< chart2::data::XLabeledDataSequence > xResult;
- if( xDataSource.is())
- {
- uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSequences(
- xDataSource->getDataSequences());
- const sal_Int32 nCount( aSequences.getLength());
- for( sal_Int32 nIdx=0; nIdx<nCount; ++nIdx )
- {
- if( aSequences[nIdx].is() )
- {
- uno::Reference< beans::XPropertySet > xSeqProp( aSequences[nIdx]->getValues(), uno::UNO_QUERY );
- ::rtl::OUString aRole;
- if( xSeqProp.is() &&
- (xSeqProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Role"))) >>= aRole) &&
- aRole.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("categories")) )
- {
- xResult.set( aSequences[nIdx] );
- break;
- }
- }
- }
- }
- return xResult;
-}
-
struct lcl_appendTableNumber : public ::std::unary_function< SCTAB, void >
{
lcl_appendTableNumber( ::rtl::OUStringBuffer & rBuffer ) :
@@ -214,173 +159,290 @@ uno::Reference< sheet::XSpreadsheetDocument > lcl_GetSpreadSheetDocument( ScDocu
// ============================================================================
-class Chart2PositionMap
+namespace {
+
+struct DeleteInstance : public unary_function<FormulaToken*, void>
{
-public:
- Chart2PositionMap(SCCOL nColCount, SCROW nRowCount,
- bool bColAdd, bool bRowAdd, Table& rCols);
- ~Chart2PositionMap();
+ void operator() (FormulaToken* p) const
+ {
+ delete p;
+ }
+};
- SCCOL getColCount() const { return static_cast<SCCOL>(maColHeaders.size()); }
- SCROW getRowCount() const { return static_cast<SCROW>(maRowHeaders.size()); }
+}
- const FormulaToken* getColHeaderPosition(SCCOL nChartCol) const;
- const FormulaToken* getRowHeaderPosition(SCROW nChartRow) const;
+struct TokenTable
+{
+ SCROW mnRowCount;
+ SCCOL mnColCount;
+ vector<FormulaToken*> maTokens;
- vector<ScSharedTokenRef>* getColRanges(SCCOL nCol) const;
- vector<ScSharedTokenRef>* getRowRanges(SCROW nRow) const;
+ void init( SCCOL nColCount, SCROW nRowCount )
+ {
+ mnColCount = nColCount;
+ mnRowCount = nRowCount;
+ maTokens.reserve(mnColCount*mnRowCount);
+ }
+ void clear()
+ {
+ for_each(maTokens.begin(), maTokens.end(), DeleteInstance());
+ }
+ void push_back( FormulaToken* pToken )
+ {
+ maTokens.push_back( pToken );
+ DBG_ASSERT( maTokens.size()<= static_cast<sal_uInt32>( mnColCount*mnRowCount ), "too much tokens" );
+ }
-private:
sal_uInt32 getIndex(SCCOL nCol, SCROW nRow) const
{
- return static_cast<sal_uInt32>(nCol*getRowCount() + nRow);
+ DBG_ASSERT( nCol<mnColCount, "wrong column index" );
+ DBG_ASSERT( nRow<mnRowCount, "wrong row index" );
+ sal_uInt32 nRet = static_cast<sal_uInt32>(nCol*mnRowCount + nRow);
+ DBG_ASSERT( maTokens.size()>= static_cast<sal_uInt32>( mnColCount*mnRowCount ), "too few tokens" );
+ return nRet;
}
-private:
- vector<FormulaToken*> maRowHeaders;
- vector<FormulaToken*> maColHeaders;
- vector<FormulaToken*> maData;
+ vector<ScSharedTokenRef>* getColRanges(SCCOL nCol) const;
+ vector<ScSharedTokenRef>* getRowRanges(SCROW nRow) const;
+ vector<ScSharedTokenRef>* getAllRanges() const;
};
-Chart2PositionMap::Chart2PositionMap(SCCOL nColCount, SCROW nRowCount,
- bool bColAdd, bool bRowAdd, Table& rCols)
+vector<ScSharedTokenRef>* TokenTable::getColRanges(SCCOL nCol) const
{
- // bColAdd is true when the first column serves as a row header. Likewise,
- // when bRowAdd is true the first row serves as a column header.
+ if (nCol >= mnColCount)
+ return NULL;
+ if( mnRowCount<=0 )
+ return NULL;
- maColHeaders.reserve(nColCount);
- maRowHeaders.reserve(nRowCount);
- maData.reserve(nColCount*nRowCount);
+ auto_ptr< vector<ScSharedTokenRef> > pTokens(new vector<ScSharedTokenRef>);
+ sal_uInt32 nLast = getIndex(nCol, mnRowCount-1);
+ for (sal_uInt32 i = getIndex(nCol, 0); i <= nLast; ++i)
+ {
+ FormulaToken* p = maTokens[i];
+ if (!p)
+ continue;
- Table* pCol = static_cast<Table*>(rCols.First());
- FormulaToken* pPos = static_cast<FormulaToken*>(pCol->First());
+ ScSharedTokenRef pCopy(static_cast<ScToken*>(p->Clone()));
+ ScRefTokenHelper::join(*pTokens, pCopy);
+ }
+ return pTokens.release();
+}
- if (bRowAdd)
- pPos = static_cast<FormulaToken*>(pCol->Next());
+vector<ScSharedTokenRef>* TokenTable::getRowRanges(SCROW nRow) const
+{
+ if (nRow >= mnRowCount)
+ return NULL;
+ if( mnColCount<=0 )
+ return NULL;
- if (bColAdd)
+ auto_ptr< vector<ScSharedTokenRef> > pTokens(new vector<ScSharedTokenRef>);
+ sal_uInt32 nLast = getIndex(mnColCount-1, nRow);
+ for (sal_uInt32 i = getIndex(0, nRow); i <= nLast; i += mnRowCount)
{
- // 1st column as a row header.
- for (SCROW nRow = 0; nRow < nRowCount; ++nRow)
- {
- maRowHeaders.push_back(pPos);
- pPos = static_cast<FormulaToken*>(pCol->Next());
- }
- pCol = static_cast<Table*>(rCols.Next()); // move to the next column.
+ FormulaToken* p = maTokens[i];
+ if (!p)
+ continue;
+
+ ScSharedTokenRef p2(static_cast<ScToken*>(p->Clone()));
+ ScRefTokenHelper::join(*pTokens, p2);
}
- else
+ return pTokens.release();
+}
+
+vector<ScSharedTokenRef>* TokenTable::getAllRanges() const
+{
+ auto_ptr< vector<ScSharedTokenRef> > pTokens(new vector<ScSharedTokenRef>);
+ sal_uInt32 nStop = mnColCount*mnRowCount;
+ for (sal_uInt32 i = 0; i < nStop; i++)
{
- for (SCROW nRow = 0; nRow < nRowCount; ++nRow)
- {
- // Make a copy.
- maRowHeaders.push_back(pPos ? pPos->Clone() : NULL);
- pPos = static_cast<FormulaToken*>(pCol->Next());
- }
+ FormulaToken* p = maTokens[i];
+ if (!p)
+ continue;
+
+ ScSharedTokenRef p2(static_cast<ScToken*>(p->Clone()));
+ ScRefTokenHelper::join(*pTokens, p2);
}
+ return pTokens.release();
+}
+
+// ============================================================================
+
+class Chart2PositionMap
+{
+public:
+ Chart2PositionMap(SCCOL nColCount, SCROW nRowCount,
+ bool bFillRowHeader, bool bFillColumnHeader, Table& rCols,
+ ScDocument* pDoc );
+ ~Chart2PositionMap();
+
+ SCCOL getDataColCount() const { return mnDataColCount; }
+ SCROW getDataRowCount() const { return mnDataRowCount; }
+
+ vector<ScSharedTokenRef>* getLeftUpperCornerRanges() const;
+ vector<ScSharedTokenRef>* getAllColHeaderRanges() const;
+ vector<ScSharedTokenRef>* getAllRowHeaderRanges() const;
+
+ vector<ScSharedTokenRef>* getColHeaderRanges(SCCOL nChartCol) const;
+ vector<ScSharedTokenRef>* getRowHeaderRanges(SCROW nChartRow) const;
+
+ vector<ScSharedTokenRef>* getDataColRanges(SCCOL nCol) const;
+ vector<ScSharedTokenRef>* getDataRowRanges(SCROW nRow) const;
- // Data in columns and in column headers.
- for (SCCOL nCol = 0; nCol < nColCount; ++nCol)
+private:
+ SCCOL mnDataColCount;
+ SCROW mnDataRowCount;
+
+ TokenTable maLeftUpperCorner; //nHeaderColCount*nHeaderRowCount
+ TokenTable maColHeaders; //mnDataColCount*nHeaderRowCount
+ TokenTable maRowHeaders; //nHeaderColCount*mnDataRowCount
+ TokenTable maData;//mnDataColCount*mnDataRowCount
+};
+
+Chart2PositionMap::Chart2PositionMap(SCCOL nAllColCount, SCROW nAllRowCount,
+ bool bFillRowHeader, bool bFillColumnHeader, Table& rCols, ScDocument* pDoc)
+{
+ // if bFillRowHeader is true, at least the first column serves as a row header.
+ // If more than one column is pure text all the first pure text columns are used as header.
+ // Likewise, if bFillColumnHeader is true, at least the first row serves as a column header.
+ // If more than one row is pure text all the first pure text rows are used as header.
+
+ SCROW nHeaderRowCount = (bFillColumnHeader && nAllColCount && nAllRowCount) ? 1 : 0;
+ SCCOL nHeaderColCount = (bFillRowHeader && nAllColCount && nAllRowCount) ? 1 : 0;
+
+ if( nHeaderColCount || nHeaderRowCount )
{
- if (pCol)
+ const SCCOL nInitialHeaderColCount = nHeaderColCount;
+ //check whether there is more than one text column or row that should be added to the headers
+ SCROW nSmallestValueRowIndex = nAllRowCount;
+ bool bFoundValues = false;
+ bool bFoundAnything = false;
+ Table* pCol = static_cast<Table*>(rCols.First());
+ for (SCCOL nCol = 0; !bFoundValues && nCol < nAllColCount; ++nCol)
{
- pPos = static_cast<FormulaToken*>(pCol->First());
- if (bRowAdd)
- {
- // 1st row as a column header.
- maColHeaders.push_back(pPos);
- pPos = static_cast<FormulaToken*>(pCol->Next());
- }
- else
- // Duplicate the 1st cell as a column header.
- maColHeaders.push_back(pPos ? pPos->Clone() : NULL);
-
- for (SCROW nRow = 0; nRow < nRowCount; ++nRow)
+ if (pCol && nCol>=nHeaderColCount)
{
- maData.push_back(pPos);
- pPos = static_cast<FormulaToken*>(pCol->Next());
+ ScToken* pToken = static_cast<ScToken*>(pCol->First());
+ for (SCROW nRow = 0; !bFoundValues && nRow < nSmallestValueRowIndex; ++nRow)
+ {
+ if (pToken && nRow>=nHeaderRowCount)
+ {
+ ScRange aRange;
+ bool bExternal = false;
+ StackVar eType = pToken->GetType();
+ if( eType==svExternal || eType==svExternalSingleRef || eType==svExternalDoubleRef || eType==svExternalName )
+ bExternal = true;//lllll todo correct?
+ ScSharedTokenRef pSharedToken(static_cast<ScToken*>(pToken->Clone()));
+ ScRefTokenHelper::getRangeFromToken(aRange, pSharedToken, bExternal );
+ SCCOL nCol1=0, nCol2=0;
+ SCROW nRow1=0, nRow2=0;
+ SCTAB nTab1=0, nTab2=0;
+ aRange.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
+ if (pDoc && pDoc->HasValueData( nCol1, nRow1, nTab1 ))
+ {
+ bFoundValues = bFoundAnything = true;
+ nSmallestValueRowIndex = std::min( nSmallestValueRowIndex, nRow );
+ }
+ if( !bFoundAnything )
+ {
+ if (pDoc && pDoc->HasData( nCol1, nRow1, nTab1 ) )
+ bFoundAnything = true;
+ }
+ }
+ pToken = static_cast<ScToken*>(pCol->Next());
+ }
+ if(!bFoundValues && nHeaderColCount>0)
+ nHeaderColCount++;
}
+ pCol = static_cast<Table*>(rCols.Next());
}
- else
+ if( bFoundAnything )
{
- // the entire column is empty.
- maColHeaders.push_back(NULL);
- for (SCROW nRow = 0; nRow < nRowCount; ++nRow)
- maData.push_back(NULL);
+ if(nHeaderRowCount>0)
+ {
+ if( bFoundValues )
+ nHeaderRowCount = nSmallestValueRowIndex;
+ else if( nAllRowCount>1 )
+ nHeaderRowCount = nAllRowCount-1;
+ }
}
- pCol = static_cast<Table*>(rCols.Next());
+ else //if the cells are completely empty, just use single header rows and columns
+ nHeaderColCount = nInitialHeaderColCount;
}
-}
-namespace {
+ mnDataColCount = nAllColCount - nHeaderColCount;
+ mnDataRowCount = nAllRowCount - nHeaderRowCount;
-struct DeleteInstance : public unary_function<FormulaToken*, void>
-{
- void operator() (FormulaToken* p) const
+ maLeftUpperCorner.init(nHeaderColCount,nHeaderRowCount);
+ maColHeaders.init(mnDataColCount,nHeaderRowCount);
+ maRowHeaders.init(nHeaderColCount,mnDataRowCount);
+ maData.init(mnDataColCount,mnDataRowCount);
+
+ Table* pCol = static_cast<Table*>(rCols.First());
+ FormulaToken* pToken = static_cast<FormulaToken*>(pCol->First());
+ for (SCCOL nCol = 0; nCol < nAllColCount; ++nCol)
{
- delete p;
- }
-};
+ if (pCol)
+ {
+ pToken = static_cast<FormulaToken*>(pCol->First());
+ for (SCROW nRow = 0; nRow < nAllRowCount; ++nRow)
+ {
+ if( nCol < nHeaderColCount )
+ {
+ if( nRow < nHeaderRowCount )
+ maLeftUpperCorner.push_back(pToken);
+ else
+ maRowHeaders.push_back(pToken);
+ }
+ else if( nRow < nHeaderRowCount )
+ maColHeaders.push_back(pToken);
+ else
+ maData.push_back(pToken);
+ pToken = static_cast<FormulaToken*>(pCol->Next());
+ }
+ }
+ pCol = static_cast<Table*>(rCols.Next());
+ }
}
Chart2PositionMap::~Chart2PositionMap()
{
- for_each(maColHeaders.begin(), maColHeaders.end(), DeleteInstance());
- for_each(maRowHeaders.begin(), maRowHeaders.end(), DeleteInstance());
- for_each(maData.begin(), maData.end(), DeleteInstance());
+ maLeftUpperCorner.clear();
+ maColHeaders.clear();
+ maRowHeaders.clear();
+ maData.clear();
}
-const FormulaToken* Chart2PositionMap::getColHeaderPosition(SCCOL nCol) const
+vector<ScSharedTokenRef>* Chart2PositionMap::getLeftUpperCornerRanges() const
{
- if (nCol < getColCount())
- return maColHeaders[nCol];
- return NULL;
+ return maLeftUpperCorner.getAllRanges();
}
-const FormulaToken* Chart2PositionMap::getRowHeaderPosition(SCROW nRow) const
+vector<ScSharedTokenRef>* Chart2PositionMap::getAllColHeaderRanges() const
{
- if (nRow < getRowCount())
- return maRowHeaders[nRow];
- return NULL;
+ return maColHeaders.getAllRanges();
}
-
-vector<ScSharedTokenRef>* Chart2PositionMap::getColRanges(SCCOL nCol) const
+vector<ScSharedTokenRef>* Chart2PositionMap::getAllRowHeaderRanges() const
{
- if (nCol >= getColCount())
- return NULL;
-
- auto_ptr< vector<ScSharedTokenRef> > pTokens(new vector<ScSharedTokenRef>);
- sal_uInt32 nStop = getIndex(nCol, getRowCount());
- for (sal_uInt32 i = getIndex(nCol, 0); i < nStop; ++i)
- {
- FormulaToken* p = maData[i];
- if (!p)
- continue;
-
- ScSharedTokenRef pCopy(static_cast<ScToken*>(p->Clone()));
- ScRefTokenHelper::join(*pTokens, pCopy);
- }
- return pTokens.release();
+ return maRowHeaders.getAllRanges();
}
-
-vector<ScSharedTokenRef>* Chart2PositionMap::getRowRanges(SCROW nRow) const
+vector<ScSharedTokenRef>* Chart2PositionMap::getColHeaderRanges(SCCOL nCol) const
{
- SCROW nRowCount = getRowCount();
- if (nRow >= nRowCount)
- return NULL;
+ return maColHeaders.getColRanges( nCol);
+}
+vector<ScSharedTokenRef>* Chart2PositionMap::getRowHeaderRanges(SCROW nRow) const
+{
+ return maRowHeaders.getRowRanges( nRow);
+}
- auto_ptr< vector<ScSharedTokenRef> > pTokens(new vector<ScSharedTokenRef>);
- sal_uInt32 nStop = getIndex(getColCount(), nRow);
- for (sal_uInt32 i = getIndex(0, nRow); i < nStop; i += nRowCount)
- {
- FormulaToken* p = maData[i];
- if (!p)
- continue;
+vector<ScSharedTokenRef>* Chart2PositionMap::getDataColRanges(SCCOL nCol) const
+{
+ return maData.getColRanges( nCol);
+}
- ScSharedTokenRef p2(static_cast<ScToken*>(p->Clone()));
- ScRefTokenHelper::join(*pTokens, p2);
- }
- return pTokens.release();
+vector<ScSharedTokenRef>* Chart2PositionMap::getDataRowRanges(SCROW nRow) const
+{
+ return maData.getRowRanges( nRow);
}
// ----------------------------------------------------------------------------
@@ -730,55 +792,20 @@ void Chart2Positioner::createPositionMap()
pNewAddress.reset(NULL);
pNewRowTable.reset(NULL);
- bool bColAdd = mbRowHeaders;
- bool bRowAdd = mbColHeaders;
+ bool bFillRowHeader = mbRowHeaders;
+ bool bFillColumnHeader = mbColHeaders;
- SCSIZE nColCount = static_cast<SCSIZE>(pCols->Count());
- SCSIZE nRowCount = 0;
+ SCSIZE nAllColCount = static_cast<SCSIZE>(pCols->Count());
+ SCSIZE nAllRowCount = 0;
pCol = static_cast<Table*>(pCols->First());
if (pCol)
{
if (mbDummyUpperLeft)
pCol->Insert(0, NULL); // Dummy fuer Beschriftung
- nRowCount = static_cast<SCSIZE>(pCol->Count());
+ nAllRowCount = static_cast<SCSIZE>(pCol->Count());
}
- else
- nRowCount = 0;
- if (nColCount > 0 && bColAdd)
- nColCount -= 1;
- if (nRowCount > 0 && bRowAdd)
- nRowCount -= 1;
-
- if (nColCount == 0 || nRowCount == 0)
- {
- ScComplexRefData aData;
- ScRefTokenHelper::getDoubleRefDataFromToken(aData, mpRefTokens->front());
- if (pCols->Count() > 0)
- pCol = static_cast<Table*>(pCols->First());
- else
- {
- pCol = new Table;
- pCols->Insert(0, pCol);
- }
- nColCount = 1;
- if (pCol->Count() > 0)
- {
- FormulaToken* pPos = static_cast<FormulaToken*>(pCol->First());
- if (pPos)
- {
- delete pPos;
- pCol->Replace(pCol->GetCurKey(), NULL);
- }
- }
- else
- pCol->Insert(0, NULL);
-
- nRowCount = 1;
- bColAdd = false;
- bRowAdd = false;
- }
- else
+ if( nAllColCount!=0 && nAllRowCount!=0 )
{
if (bNoGlue)
{
@@ -796,8 +823,8 @@ void Chart2Positioner::createPositionMap()
}
mpPositionMap.reset(
new Chart2PositionMap(
- static_cast<SCCOL>(nColCount), static_cast<SCROW>(nRowCount),
- bColAdd, bRowAdd, *pCols));
+ static_cast<SCCOL>(nAllColCount), static_cast<SCROW>(nAllRowCount),
+ bFillRowHeader, bFillColumnHeader, *pCols, mpDoc));
// Destroy all column instances.
for (pCol = static_cast<Table*>(pCols->First()); pCol; pCol = static_cast<Table*>(pCols->Next()))
@@ -1021,639 +1048,44 @@ void ScChart2DataProvider::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint
return !aTokens.empty();
}
-namespace {
-
-class RemoveHeaderFromRanges : public unary_function<ScSharedTokenRef, void>
-{
-public:
- RemoveHeaderFromRanges(const ScSharedTokenRef& rHeaderCell, bool bOrientCol) :
- mpTokens(new vector<ScSharedTokenRef>),
- mpHeaderCell(rHeaderCell),
- mbOrientCol(bOrientCol)
- {
- }
-
- RemoveHeaderFromRanges(const RemoveHeaderFromRanges& r) :
- mpTokens(r.mpTokens),
- mpHeaderCell(r.mpHeaderCell),
- mbOrientCol(r.mbOrientCol)
- {
- }
-
- void operator() (const ScSharedTokenRef& pRange)
- {
- if (!isContained(pRange))
- {
- // header cell is not part of this range. Just add it to the
- // range list and move on.
- ScRefTokenHelper::join(*mpTokens, pRange);
- return;
- }
-
- // This range contains the header cell.
-
- ScComplexRefData aRange;
- ScRefTokenHelper::getDoubleRefDataFromToken(aRange, pRange);
- const ScSingleRefData& s = aRange.Ref1;
- const ScSingleRefData& e = aRange.Ref2;
- const ScSingleRefData& h = mpHeaderCell->GetSingleRef();
-
- if (equals(s, e))
- // This range *only* contains the header cell. Skip it.
- return;
-
- if (s.nTab != e.nTab)
- // 3D range has no business being here....
- return;
-
- if (mbOrientCol)
- {
- // column major
-
- if (s.nCol == e.nCol)
- {
- // single column range.
- splitSingleColRange(pRange, s, e);
- }
- else
- {
- if (s.nCol == h.nCol)
- {
- // header cell is in the first column.
-
- {
- ScSharedTokenRef pNew(static_cast<ScToken*>(pRange->Clone()));
- ScComplexRefData& r = pNew->GetDoubleRef();
- r.Ref2.InitAddress(s.nCol, e.nRow, s.nTab);
- splitSingleColRange(pNew, r.Ref1, r.Ref2);
- }
-
- {
- ScSharedTokenRef pNew(static_cast<ScToken*>(pRange->Clone()));
- ScComplexRefData& r = pNew->GetDoubleRef();
- r.Ref1.InitAddress(s.nCol + 1, s.nRow, s.nTab);
- ScRefTokenHelper::join(*mpTokens, pNew);
- }
- }
- else if (e.nCol == h.nCol)
- {
- // header cell is in the last column.
-
- {
- ScSharedTokenRef pNew(static_cast<ScToken*>(pRange->Clone()));
- ScComplexRefData& r = pNew->GetDoubleRef();
- r.Ref1.InitAddress(e.nCol, s.nRow, s.nTab);
- splitSingleColRange(pNew, r.Ref1, r.Ref2);
- }
-
- {
- ScSharedTokenRef pNew(static_cast<ScToken*>(pRange->Clone()));
- ScComplexRefData& r = pNew->GetDoubleRef();
- r.Ref2.InitAddress(e.nCol - 1, e.nRow, e.nTab);
- ScRefTokenHelper::join(*mpTokens, pNew);
- }
- }
- else
- {
- // header cell is somewhere between the first and last columns.
-
- {
- ScSharedTokenRef pNew(static_cast<ScToken*>(pRange->Clone()));
- ScComplexRefData& r = pNew->GetDoubleRef();
- r.Ref2.InitAddress(h.nCol - 1, e.nRow, h.nTab);
- ScRefTokenHelper::join(*mpTokens, pNew);
- }
-
- {
- ScSharedTokenRef pNew(static_cast<ScToken*>(pRange->Clone()));
- ScComplexRefData& r = pNew->GetDoubleRef();
- r.Ref1.InitAddress(h.nCol, s.nRow, s.nTab);
- r.Ref2.InitAddress(h.nCol, e.nRow, e.nTab);
- splitSingleColRange(pNew, r.Ref1, r.Ref2);
- }
-
- {
- ScSharedTokenRef pNew(static_cast<ScToken*>(pRange->Clone()));
- ScComplexRefData& r = pNew->GetDoubleRef();
- r.Ref1.InitAddress(h.nCol + 1, s.nRow, h.nTab);
- ScRefTokenHelper::join(*mpTokens, pNew);
- }
- }
- }
- }
- else
- {
- // row major
-
- if (s.nRow == e.nRow)
- {
- // Single row range.
- splitSingleRowRange(pRange, s, e);
- }
- else
- {
- if (s.nRow == h.nRow)
- {
- // header cell is in the first row.
-
- {
- ScSharedTokenRef pNew(static_cast<ScToken*>(pRange->Clone()));
- ScComplexRefData& r = pNew->GetDoubleRef();
- r.Ref2.InitAddress(e.nCol, s.nRow, s.nTab);
- splitSingleRowRange(pNew, r.Ref1, r.Ref2);
- }
-
- {
- ScSharedTokenRef pNew(static_cast<ScToken*>(pRange->Clone()));
- ScComplexRefData& r = pNew->GetDoubleRef();
- r.Ref1.InitAddress(s.nCol, s.nRow + 1, s.nTab);
- ScRefTokenHelper::join(*mpTokens, pNew);
- }
- }
- else if (e.nRow == h.nRow)
- {
- // header cell is in the last row.
-
- {
- ScSharedTokenRef pNew(static_cast<ScToken*>(pRange->Clone()));
- ScComplexRefData& r = pNew->GetDoubleRef();
- r.Ref1.InitAddress(s.nCol, e.nRow, s.nTab);
- splitSingleRowRange(pNew, r.Ref1, r.Ref2);
- }
-
- {
- ScSharedTokenRef pNew(static_cast<ScToken*>(pRange->Clone()));
- ScComplexRefData& r = pNew->GetDoubleRef();
- r.Ref2.InitAddress(e.nCol, e.nRow - 1, e.nTab);
- ScRefTokenHelper::join(*mpTokens, pNew);
- }
- }
- else
- {
- // header cell is somewhere between the 1st and last rows.
-
- {
- ScSharedTokenRef pNew(static_cast<ScToken*>(pRange->Clone()));
- ScComplexRefData& r = pNew->GetDoubleRef();
- r.Ref2.InitAddress(e.nCol, h.nRow - 1, h.nTab);
- ScRefTokenHelper::join(*mpTokens, pNew);
- }
-
- {
- ScSharedTokenRef pNew(static_cast<ScToken*>(pRange->Clone()));
- ScComplexRefData& r = pNew->GetDoubleRef();
- r.Ref1.InitAddress(s.nCol, h.nRow, s.nTab);
- r.Ref2.InitAddress(e.nCol, h.nRow, e.nTab);
- splitSingleRowRange(pNew, r.Ref1, r.Ref2);
- }
-
- {
- ScSharedTokenRef pNew(static_cast<ScToken*>(pRange->Clone()));
- ScComplexRefData& r = pNew->GetDoubleRef();
- r.Ref1.InitAddress(s.nCol, h.nRow + 1, h.nTab);
- ScRefTokenHelper::join(*mpTokens, pNew);
- }
- }
- }
- }
- }
-
- void getNewTokens(vector<ScSharedTokenRef>& rTokens)
- {
- mpTokens->swap(rTokens);
- }
-
-private:
-
- void splitSingleColRange(const ScSharedTokenRef& pRange, const ScSingleRefData& s, const ScSingleRefData& e)
- {
- const ScSingleRefData& h = mpHeaderCell->GetSingleRef();
-
- if (equals(s, h))
- {
- // header is at the top.
-
- ScSharedTokenRef pNew(static_cast<ScToken*>(pRange->Clone()));
- ScComplexRefData& r = pNew->GetDoubleRef();
- r.Ref1.nRow += 1;
- ScRefTokenHelper::join(*mpTokens, pNew);
- }
- else if (equals(e, h))
- {
- // header is at the bottom.
-
- ScSharedTokenRef pNew(static_cast<ScToken*>(pRange->Clone()));
- ScComplexRefData& r = pNew->GetDoubleRef();
- r.Ref2.nRow -= 1;
- ScRefTokenHelper::join(*mpTokens, pNew);
- }
- else
- {
- // header is somewhere in the middle.
-
- {
- ScSharedTokenRef pNew(static_cast<ScToken*>(pRange->Clone()));
- ScComplexRefData& r = pNew->GetDoubleRef();
- r.Ref2.InitAddress(h.nCol, h.nRow - 1, h.nTab);
- ScRefTokenHelper::join(*mpTokens, pNew);
- }
-
- {
- ScSharedTokenRef pNew(static_cast<ScToken*>(pRange->Clone()));
- ScComplexRefData& r = pNew->GetDoubleRef();
- r.Ref1.InitAddress(h.nCol, h.nRow + 1, h.nTab);
- ScRefTokenHelper::join(*mpTokens, pNew);
- }
- }
- }
-
- void splitSingleRowRange(const ScSharedTokenRef& pRange, const ScSingleRefData& s, const ScSingleRefData& e)
- {
- const ScSingleRefData& h = mpHeaderCell->GetSingleRef();
-
- if (equals(s, h))
- {
- // header is at the top.
-
- ScSharedTokenRef pNew(static_cast<ScToken*>(pRange->Clone()));
- ScComplexRefData& r = pNew->GetDoubleRef();
- r.Ref1.nCol += 1;
- ScRefTokenHelper::join(*mpTokens, pNew);
- }
- else if (equals(e, h))
- {
- // header is at the bottom.
-
- ScSharedTokenRef pNew(static_cast<ScToken*>(pRange->Clone()));
- ScComplexRefData& r = pNew->GetDoubleRef();
- r.Ref2.nCol -= 1;
- ScRefTokenHelper::join(*mpTokens, pNew);
- }
- else
- {
- // header is somewhere in the middle.
-
- {
- ScSharedTokenRef pNew(static_cast<ScToken*>(pRange->Clone()));
- ScComplexRefData& r = pNew->GetDoubleRef();
- r.Ref2.InitAddress(h.nCol - 1, h.nRow, h.nTab);
- ScRefTokenHelper::join(*mpTokens, pNew);
- }
-
- {
- ScSharedTokenRef pNew(static_cast<ScToken*>(pRange->Clone()));
- ScComplexRefData& r = pNew->GetDoubleRef();
- r.Ref1.InitAddress(h.nCol + 1, h.nRow, h.nTab);
- ScRefTokenHelper::join(*mpTokens, pNew);
- }
- }
- }
-
- /**
- * Compare two single ref data for equality, but only compare their
- * absolute cell addresses while ignoring flags and relative addresses.
- */
- bool equals(const ScSingleRefData& r1, const ScSingleRefData& r2) const
- {
- return (r1.nCol == r2.nCol) && (r1.nRow == r2.nRow) && (r1.nTab == r2.nTab);
- }
-
- bool isContained(const ScSharedTokenRef& pRange)
- {
- bool bExternal = ScRefTokenHelper::isExternalRef(mpHeaderCell);
- if (bExternal != ScRefTokenHelper::isExternalRef(pRange))
- // internal vs external.
- return false;
-
- if (bExternal)
- {
- if (pRange->GetIndex() != mpHeaderCell->GetIndex())
- // different external files.
- return false;
-
- if (pRange->GetString() != mpHeaderCell->GetString())
- // different table.
- return false;
- }
-
- ScComplexRefData aRange;
- ScRefTokenHelper::getDoubleRefDataFromToken(aRange, pRange);
- const ScSingleRefData& rCell = mpHeaderCell->GetSingleRef();
-
- bool bRowContained = (aRange.Ref1.nRow <= rCell.nRow) && (rCell.nRow <= aRange.Ref2.nRow);
- bool bColContained = (aRange.Ref1.nCol <= rCell.nCol) && (rCell.nCol <= aRange.Ref2.nCol);
- bool bTabContained = (aRange.Ref1.nTab <= rCell.nTab) && (rCell.nTab <= aRange.Ref2.nTab);
-
- return (bRowContained && bColContained && bTabContained);
- }
-
-private:
- shared_ptr< vector<ScSharedTokenRef> > mpTokens;
-
- /**
- * Stores header cell position. Must be a single ref token i.e. either
- * ScSingleRefToken or ScExternalSingleRefToken.
- */
- ScSharedTokenRef mpHeaderCell;
-
- bool mbOrientCol;
-};
-
-}
-
-static void lcl_removeHeaderFromRanges(vector<ScSharedTokenRef>& rTokens, const ScSharedTokenRef& rHeaderCell, bool bOrientCol)
-{
- RemoveHeaderFromRanges func(rHeaderCell, bOrientCol);
- func = for_each(rTokens.begin(), rTokens.end(), func);
- func.getNewTokens(rTokens);
-}
-
-uno::Reference< chart2::data::XDataSource> SAL_CALL
-ScChart2DataProvider::createDataSource(
- const uno::Sequence< beans::PropertyValue >& aArguments )
- throw( lang::IllegalArgumentException, uno::RuntimeException)
-{
- ScUnoGuard aGuard;
- if ( ! m_pDocument )
- throw uno::RuntimeException();
-
- uno::Reference< chart2::data::XDataSource> xResult;
- bool bLabel = true;
- bool bOrientCol = true;
- ::rtl::OUString aRangeRepresentation;
- uno::Sequence< sal_Int32 > aSequenceMapping;
- for(sal_Int32 i = 0; i < aArguments.getLength(); ++i)
- {
- rtl::OUString sName(aArguments[i].Name);
- if (aArguments[i].Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataRowSource")))
- {
- chart::ChartDataRowSource eSource = chart::ChartDataRowSource_COLUMNS;
- if( ! (aArguments[i].Value >>= eSource))
- {
- sal_Int32 nSource(0);
- if( aArguments[i].Value >>= nSource )
- eSource = (static_cast< chart::ChartDataRowSource >( nSource ));
- }
- bOrientCol = (eSource == chart::ChartDataRowSource_COLUMNS);
- }
- else if (aArguments[i].Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FirstCellAsLabel")))
- {
- bLabel = ::cppu::any2bool(aArguments[i].Value);
- }
- else if (aArguments[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("CellRangeRepresentation")))
- {
- aArguments[i].Value >>= aRangeRepresentation;
- }
- else if (aArguments[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("SequenceMapping")))
- {
- aArguments[i].Value >>= aSequenceMapping;
- }
- }
-
- vector<ScSharedTokenRef> aRefTokens;
- ScRefTokenHelper::compileRangeRepresentation(aRefTokens, aRangeRepresentation, m_pDocument, m_pDocument->GetGrammar());
- if (aRefTokens.empty())
- // Invalid range representation. Bail out.
- throw lang::IllegalArgumentException();
-
- if (bLabel)
- addUpperLeftCornerIfMissing(aRefTokens);
-
- bool bColHeaders = (bOrientCol ? bLabel : false );
- bool bRowHeaders = (bOrientCol ? false : bLabel );
-
- Chart2Positioner aChPositioner(m_pDocument, aRefTokens);
- aChPositioner.setHeaders(bColHeaders, bRowHeaders);
-
- const Chart2PositionMap* pChartMap = aChPositioner.getPositionMap();
- if (!pChartMap)
- // No chart position map instance. Bail out.
- return xResult;
-
- ScChart2DataSource* pDS = NULL;
- std::list < ScChart2LabeledDataSequence* > aSeqs;
-
- // Fill Categories
-
- ScChart2LabeledDataSequence* pHeader = NULL;
- if (bOrientCol ? aChPositioner.hasRowHeaders() : aChPositioner.hasColHeaders())
- {
- pHeader = new ScChart2LabeledDataSequence(m_pDocument);
- sal_Int32 nCount = static_cast< sal_Int32 >( bOrientCol ? pChartMap->getRowCount() : pChartMap->getColCount() );
- vector<ScSharedTokenRef> aRefTokens2;
- ScSharedTokenRef pLabelToken;
- for (sal_Int32 i = 0; i < nCount; ++i)
- {
- const FormulaToken* pPos = bOrientCol ?
- pChartMap->getRowHeaderPosition(static_cast<SCROW>(i)) :
- pChartMap->getColHeaderPosition(static_cast<SCCOL>(i));
- if (pPos)
- {
- ScSharedTokenRef p(static_cast<ScToken*>(pPos->Clone()));
- ScRefTokenHelper::join(aRefTokens2, p);
- if (!pLabelToken)
- {
- pLabelToken = p;
- StackVar eType = pLabelToken->GetType();
- if (eType == svSingleRef || eType == svExternalSingleRef)
- {
- ScSingleRefData& r = pLabelToken->GetSingleRef();
- if (bOrientCol)
- r.nRow -= 1;
- else
- r.nCol -= 1;
- }
- }
- }
- }
- if (pLabelToken)
- {
- if (bLabel)
- {
- auto_ptr< vector<ScSharedTokenRef> > pTokens(new vector<ScSharedTokenRef>);
- pTokens->push_back(pLabelToken);
- Reference < chart2::data::XDataSequence > xLabelSeq(new ScChart2DataSequence(m_pDocument, this, pTokens.release(), m_bIncludeHiddenCells));
- Reference< beans::XPropertySet > xLabelProps(xLabelSeq, uno::UNO_QUERY);
- if (xLabelProps.is())
- xLabelProps->setPropertyValue(
- OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ROLE)),
- uno::makeAny(OUString(RTL_CONSTASCII_USTRINGPARAM("label"))));
- pHeader->setLabel(xLabelSeq);
- }
- else
- ScRefTokenHelper::join(aRefTokens2, pLabelToken);
- }
- auto_ptr< vector<ScSharedTokenRef> > pTokens(new vector<ScSharedTokenRef>);
- pTokens->swap(aRefTokens2);
- uno::Reference< chart2::data::XDataSequence > xSeq( new ScChart2DataSequence( m_pDocument, this, pTokens.release(), m_bIncludeHiddenCells) );
- pHeader->setValues(xSeq);
- }
- if (pHeader)
- aSeqs.push_back(pHeader);
-
- // Fill Serieses with Labels
-
- sal_Int32 nCount = bOrientCol ? pChartMap->getColCount() : pChartMap->getRowCount();
- for (sal_Int32 i = 0; i < nCount; ++i)
- {
- ScChart2LabeledDataSequence* pLabeled = new ScChart2LabeledDataSequence(m_pDocument);
- uno::Reference < chart2::data::XDataSequence > xLabelSeq;
- auto_ptr< vector<ScSharedTokenRef> > pRanges(NULL);
- if (bOrientCol)
- pRanges.reset(pChartMap->getColRanges(static_cast<SCCOL>(i)));
- else
- pRanges.reset(pChartMap->getRowRanges(static_cast<SCROW>(i)));
-
- ScSharedTokenRef pHeaderCell;
- if (bOrientCol)
- {
- const FormulaToken* p = pChartMap->getColHeaderPosition(static_cast<SCCOL>(i));
- if (p)
- pHeaderCell.reset(static_cast<ScToken*>(p->Clone()));
- }
- else
- {
- const FormulaToken* p = pChartMap->getRowHeaderPosition(static_cast<SCROW>(i));
- if (p)
- pHeaderCell.reset(static_cast<ScToken*>(p->Clone()));
- }
-
- if (bLabel)
- {
- if (!pHeaderCell && pRanges.get() && !pRanges->empty())
- {
- const ScSharedTokenRef& p = pRanges->front();
- if (p && ScRefTokenHelper::isRef(p))
- {
- // Take the first cell in the range as the header position.
- ScSingleRefData aData = p->GetSingleRef();
- bool bExternal = ScRefTokenHelper::isExternalRef(p);
- if (bExternal)
- {
- sal_uInt16 nFileId = p->GetIndex();
- const String& rTabName = p->GetString();
- pHeaderCell.reset(new ScExternalSingleRefToken(nFileId, rTabName, aData));
- }
- else
- pHeaderCell.reset(new ScSingleRefToken(aData));
- }
- }
- if (pHeaderCell)
- {
- auto_ptr< vector<ScSharedTokenRef> > pTokens(new vector<ScSharedTokenRef>);
- pTokens->reserve(1);
- pTokens->push_back(pHeaderCell);
- xLabelSeq.set(new ScChart2DataSequence(m_pDocument, this, pTokens.release(), m_bIncludeHiddenCells));
- uno::Reference< beans::XPropertySet > xLabelProps(xLabelSeq, uno::UNO_QUERY);
- if (xLabelProps.is())
- xLabelProps->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ROLE)), uno::makeAny(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("label"))));
-
- // remove Header from Ranges
- lcl_removeHeaderFromRanges(*pRanges, pHeaderCell, bOrientCol);
- }
- }
- else
- {
- if (pHeaderCell)
- ScRefTokenHelper::join(*pRanges, pHeaderCell);
- }
-
- // FIXME: if there are no labels the column or row name should be taken
-
- uno::Reference < chart2::data::XDataSequence > xSeq(new ScChart2DataSequence(m_pDocument, this, pRanges.release(), m_bIncludeHiddenCells));
-
- pLabeled->setValues(xSeq);
- pLabeled->setLabel(xLabelSeq);
-
- aSeqs.push_back(pLabeled);
- }
-
- pDS = new ScChart2DataSource(m_pDocument);
- std::list < ScChart2LabeledDataSequence* >::iterator aItr(aSeqs.begin());
- std::list < ScChart2LabeledDataSequence* >::iterator aEndItr(aSeqs.end());
-
- //reorder labeled sequences according to aSequenceMapping
- std::vector< ScChart2LabeledDataSequence* > aSeqVector;
- while(aItr != aEndItr)
- {
- aSeqVector.push_back(*aItr);
- ++aItr;
- }
-
- std::map< sal_Int32, ScChart2LabeledDataSequence* > aSequenceMap;
- for( sal_Int32 nNewIndex = 0; nNewIndex < aSequenceMapping.getLength(); nNewIndex++ )
- {
- // note: assuming that the values in the sequence mapping are always non-negative
- std::vector< ScChart2LabeledDataSequence* >::size_type nOldIndex( static_cast< sal_uInt32 >( aSequenceMapping[nNewIndex] ));
- if( nOldIndex < aSeqVector.size() )
- {
- pDS->AddLabeledSequence( aSeqVector[nOldIndex] );
- aSeqVector[nOldIndex] = 0;
- }
-
- }
-
- std::vector< ScChart2LabeledDataSequence* >::iterator aVectorItr(aSeqVector.begin());
- std::vector< ScChart2LabeledDataSequence* >::iterator aVectorEndItr(aSeqVector.end());
- while(aVectorItr != aVectorEndItr)
- {
- if(*aVectorItr)
- pDS->AddLabeledSequence(*aVectorItr);
- ++aVectorItr;
- }
-
- xResult.set( pDS );
- return xResult;
-}
-
namespace
{
-bool lcl_HasCategories(
- const uno::Reference< chart2::data::XDataSource >& xDataSource,
- bool & rOutHasCategories )
+ScChart2LabeledDataSequence* lcl_createScChart2DataSequenceFromTokens( auto_ptr< vector<ScSharedTokenRef> > pValueTokens, auto_ptr< vector<ScSharedTokenRef> > pLabelTokens,
+ ScDocument* pDoc, const uno::Reference < chart2::data::XDataProvider >& xDP, bool bIncludeHiddenCells )
{
- bool bResult = false;
- uno::Reference< chart2::data::XLabeledDataSequence > xCategories(
- lcl_getCategoriesFromDataSource( xDataSource ));
- if( xCategories.is())
+ ScChart2LabeledDataSequence* pRet = 0;
+ bool bHasValues = pValueTokens.get() && !pValueTokens->empty();
+ bool bHasLabel = pLabelTokens.get() && !pLabelTokens->empty();
+ if( bHasValues || bHasLabel )
{
- uno::Reference< lang::XServiceInfo > xValues( xCategories->getValues(), uno::UNO_QUERY );
- if (xValues.is())
+ pRet = new ScChart2LabeledDataSequence(pDoc);
+ if(bHasValues)
{
- rOutHasCategories = xValues->getImplementationName().equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ScChart2DataSequence"));
- bResult = true;
+ uno::Reference < chart2::data::XDataSequence > xSeq(new ScChart2DataSequence(pDoc, xDP, pValueTokens.release(), bIncludeHiddenCells));
+ pRet->setValues(xSeq);
}
- }
- return bResult;
-}
-
-bool lcl_HasFirstCellAsLabel(
- const uno::Reference< chart2::data::XDataSource >& xDataSource,
- bool & rOutHasFirstCellAsLabel )
-{
- bool bResult = false;
- if( xDataSource.is())
- {
- uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSequences(
- xDataSource->getDataSequences());
- const sal_Int32 nCount( aSequences.getLength());
- if (nCount > 0 && aSequences[nCount - 1].is() )
+ if(bHasLabel)
{
- uno::Reference< lang::XServiceInfo > xLabel( aSequences[nCount - 1]->getLabel(), uno::UNO_QUERY ); // take the last sequence, because the first has no label if it is also created
- if (xLabel.is())
- {
- rOutHasFirstCellAsLabel = xLabel->getImplementationName().equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ScChart2DataSequence"));
- bResult = true;
- }
+ uno::Reference < chart2::data::XDataSequence > xLabelSeq(new ScChart2DataSequence(pDoc, xDP, pLabelTokens.release(), bIncludeHiddenCells));
+ pRet->setLabel(xLabelSeq);
}
}
- return bResult;
+ return pRet;
}
-} // anonymous namespace
-
-bool ScChart2DataProvider::addUpperLeftCornerIfMissing(vector<ScSharedTokenRef>& rRefTokens)
+//----------------------------------------------------
+/**
+ * Check the current list of reference tokens, and add the upper left
+ * corner of the minimum range that encloses all ranges if certain
+ * conditions are met.
+ *
+ * @param rRefTokens list of reference tokens
+ *
+ * @return true if the corner was added, false otherwise.
+ */
+bool lcl_addUpperLeftCornerIfMissing(vector<ScSharedTokenRef>& rRefTokens,
+ SCROW nCornerRowCount=1, SCCOL nCornerColumnCount=1)
{
using ::std::max;
using ::std::min;
@@ -1834,13 +1266,13 @@ bool ScChart2DataProvider::addUpperLeftCornerIfMissing(vector<ScSharedTokenRef>&
// The corner cell is contained.
return false;
- if (rData.nCol == nMinCol+1 && rData.nRow == nMinRow)
+ if (rData.nCol == nMinCol+nCornerColumnCount && rData.nRow == nMinRow)
bRight = true;
- if (rData.nCol == nMinCol && rData.nRow == nMinRow+1)
+ if (rData.nCol == nMinCol && rData.nRow == nMinRow+nCornerRowCount)
bBottom = true;
- if (rData.nCol == nMinCol+1 && rData.nRow == nMinRow+1)
+ if (rData.nCol == nMinCol+nCornerColumnCount && rData.nRow == nMinRow+nCornerRowCount)
bDiagonal = true;
}
break;
@@ -1855,16 +1287,16 @@ bool ScChart2DataProvider::addUpperLeftCornerIfMissing(vector<ScSharedTokenRef>&
// The corner cell is contained.
return false;
- if (r1.nCol <= nMinCol+1 && nMinCol+1 <= r2.nCol &&
+ if (r1.nCol <= nMinCol+nCornerColumnCount && nMinCol+nCornerColumnCount <= r2.nCol &&
r1.nRow <= nMinRow && nMinRow <= r2.nRow)
bRight = true;
if (r1.nCol <= nMinCol && nMinCol <= r2.nCol &&
- r1.nRow <= nMinRow+1 && nMinRow+1 <= r2.nRow)
+ r1.nRow <= nMinRow+nCornerRowCount && nMinRow+nCornerRowCount <= r2.nRow)
bBottom = true;
- if (r1.nCol <= nMinCol+1 && nMinCol+1 <= r2.nCol &&
- r1.nRow <= nMinRow+1 && nMinRow+1 <= r2.nRow)
+ if (r1.nCol <= nMinCol+nCornerColumnCount && nMinCol+nCornerColumnCount <= r2.nCol &&
+ r1.nRow <= nMinRow+nCornerRowCount && nMinRow+nCornerRowCount <= r2.nRow)
bDiagonal = true;
}
break;
@@ -1934,22 +1366,194 @@ bool ScChart2DataProvider::addUpperLeftCornerIfMissing(vector<ScSharedTokenRef>&
aData.nRow = nMinRow;
aData.nTab = nTab;
- if (bExternal)
+ if( nCornerRowCount==1 && nCornerColumnCount==1 )
{
- ScSharedTokenRef pCorner(
- new ScExternalSingleRefToken(nFileId, aExtTabName, aData));
- ScRefTokenHelper::join(rRefTokens, pCorner);
+ if (bExternal)
+ {
+ ScSharedTokenRef pCorner(
+ new ScExternalSingleRefToken(nFileId, aExtTabName, aData));
+ ScRefTokenHelper::join(rRefTokens, pCorner);
+ }
+ else
+ {
+ ScSharedTokenRef pCorner(new ScSingleRefToken(aData));
+ ScRefTokenHelper::join(rRefTokens, pCorner);
+ }
}
else
{
- ScSharedTokenRef pCorner(new ScSingleRefToken(aData));
- ScRefTokenHelper::join(rRefTokens, pCorner);
+ ScSingleRefData aDataEnd(aData);
+ aDataEnd.nCol += (nCornerColumnCount-1);
+ aDataEnd.nRow += (nCornerRowCount-1);
+ ScComplexRefData r;
+ r.Ref1=aData;
+ r.Ref2=aDataEnd;
+ if (bExternal)
+ {
+ ScSharedTokenRef pCorner(
+ new ScExternalDoubleRefToken(nFileId, aExtTabName, r));
+ ScRefTokenHelper::join(rRefTokens, pCorner);
+ }
+ else
+ {
+ ScSharedTokenRef pCorner(new ScDoubleRefToken(r));
+ ScRefTokenHelper::join(rRefTokens, pCorner);
+ }
}
return true;
}
-namespace {
+}
+
+uno::Reference< chart2::data::XDataSource> SAL_CALL
+ScChart2DataProvider::createDataSource(
+ const uno::Sequence< beans::PropertyValue >& aArguments )
+ throw( lang::IllegalArgumentException, uno::RuntimeException)
+{
+ ScUnoGuard aGuard;
+ if ( ! m_pDocument )
+ throw uno::RuntimeException();
+
+ uno::Reference< chart2::data::XDataSource> xResult;
+ bool bLabel = true;
+ bool bCategories = false;
+ bool bOrientCol = true;
+ ::rtl::OUString aRangeRepresentation;
+ uno::Sequence< sal_Int32 > aSequenceMapping;
+ for(sal_Int32 i = 0; i < aArguments.getLength(); ++i)
+ {
+ rtl::OUString sName(aArguments[i].Name);
+ if (aArguments[i].Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataRowSource")))
+ {
+ chart::ChartDataRowSource eSource = chart::ChartDataRowSource_COLUMNS;
+ if( ! (aArguments[i].Value >>= eSource))
+ {
+ sal_Int32 nSource(0);
+ if( aArguments[i].Value >>= nSource )
+ eSource = (static_cast< chart::ChartDataRowSource >( nSource ));
+ }
+ bOrientCol = (eSource == chart::ChartDataRowSource_COLUMNS);
+ }
+ else if (aArguments[i].Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FirstCellAsLabel")))
+ {
+ bLabel = ::cppu::any2bool(aArguments[i].Value);
+ }
+ else if (aArguments[i].Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HasCategories")))
+ {
+ bCategories = ::cppu::any2bool(aArguments[i].Value);
+ }
+ else if (aArguments[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("CellRangeRepresentation")))
+ {
+ aArguments[i].Value >>= aRangeRepresentation;
+ }
+ else if (aArguments[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("SequenceMapping")))
+ {
+ aArguments[i].Value >>= aSequenceMapping;
+ }
+ }
+
+ vector<ScSharedTokenRef> aRefTokens;
+ ScRefTokenHelper::compileRangeRepresentation(aRefTokens, aRangeRepresentation, m_pDocument, m_pDocument->GetGrammar());
+ if (aRefTokens.empty())
+ // Invalid range representation. Bail out.
+ throw lang::IllegalArgumentException();
+
+ if (bLabel)
+ lcl_addUpperLeftCornerIfMissing(aRefTokens); //#i90669#
+
+ bool bColHeaders = (bOrientCol ? bLabel : bCategories );
+ bool bRowHeaders = (bOrientCol ? bCategories : bLabel );
+
+ Chart2Positioner aChPositioner(m_pDocument, aRefTokens);
+ aChPositioner.setHeaders(bColHeaders, bRowHeaders);
+
+ const Chart2PositionMap* pChartMap = aChPositioner.getPositionMap();
+ if (!pChartMap)
+ // No chart position map instance. Bail out.
+ return xResult;
+
+ ScChart2DataSource* pDS = NULL;
+ std::list < ScChart2LabeledDataSequence* > aSeqs;
+
+ // Fill Categories
+ if( bCategories )
+ {
+ auto_ptr< vector<ScSharedTokenRef> > pValueTokens(NULL);
+ if (bOrientCol)
+ pValueTokens.reset(pChartMap->getAllRowHeaderRanges());
+ else
+ pValueTokens.reset(pChartMap->getAllColHeaderRanges());
+
+ auto_ptr< vector<ScSharedTokenRef> > pLabelTokens(NULL);
+ pLabelTokens.reset(pChartMap->getLeftUpperCornerRanges());
+
+ ScChart2LabeledDataSequence* pCategories = lcl_createScChart2DataSequenceFromTokens( pValueTokens, pLabelTokens, m_pDocument, this, m_bIncludeHiddenCells );//ownership of pointers is transfered!
+ if( pCategories )
+ aSeqs.push_back(pCategories);
+ }
+
+ // Fill Serieses (values and label)
+ sal_Int32 nCount = bOrientCol ? pChartMap->getDataColCount() : pChartMap->getDataRowCount();
+ for (sal_Int32 i = 0; i < nCount; ++i)
+ {
+ auto_ptr< vector<ScSharedTokenRef> > pValueTokens(NULL);
+ auto_ptr< vector<ScSharedTokenRef> > pLabelTokens(NULL);
+ if (bOrientCol)
+ {
+ pValueTokens.reset(pChartMap->getDataColRanges(static_cast<SCCOL>(i)));
+ pLabelTokens.reset(pChartMap->getColHeaderRanges(static_cast<SCCOL>(i)));
+ }
+ else
+ {
+ pValueTokens.reset(pChartMap->getDataRowRanges(static_cast<SCROW>(i)));
+ pLabelTokens.reset(pChartMap->getRowHeaderRanges(static_cast<SCROW>(i)));
+ }
+ ScChart2LabeledDataSequence* pChartSeries = lcl_createScChart2DataSequenceFromTokens( pValueTokens, pLabelTokens, m_pDocument, this, m_bIncludeHiddenCells ); //ownership of pointers is transfered!
+ if( pChartSeries )
+ aSeqs.push_back(pChartSeries);
+ }
+
+ pDS = new ScChart2DataSource(m_pDocument);
+ std::list < ScChart2LabeledDataSequence* >::iterator aItr(aSeqs.begin());
+ std::list < ScChart2LabeledDataSequence* >::iterator aEndItr(aSeqs.end());
+
+ //reorder labeled sequences according to aSequenceMapping
+ std::vector< ScChart2LabeledDataSequence* > aSeqVector;
+ while(aItr != aEndItr)
+ {
+ aSeqVector.push_back(*aItr);
+ ++aItr;
+ }
+
+ std::map< sal_Int32, ScChart2LabeledDataSequence* > aSequenceMap;
+ for( sal_Int32 nNewIndex = 0; nNewIndex < aSequenceMapping.getLength(); nNewIndex++ )
+ {
+ // note: assuming that the values in the sequence mapping are always non-negative
+ std::vector< ScChart2LabeledDataSequence* >::size_type nOldIndex( static_cast< sal_uInt32 >( aSequenceMapping[nNewIndex] ));
+ if( nOldIndex < aSeqVector.size() )
+ {
+ pDS->AddLabeledSequence( aSeqVector[nOldIndex] );
+ aSeqVector[nOldIndex] = 0;
+ }
+
+ }
+
+ std::vector< ScChart2LabeledDataSequence* >::iterator aVectorItr(aSeqVector.begin());
+ std::vector< ScChart2LabeledDataSequence* >::iterator aVectorEndItr(aSeqVector.end());
+ while(aVectorItr != aVectorEndItr)
+ {
+ if(*aVectorItr)
+ pDS->AddLabeledSequence(*aVectorItr);
+ ++aVectorItr;
+ }
+
+ xResult.set( pDS );
+ return xResult;
+}
+
+namespace
+{
/**
* Function object to create a list of table numbers from a token list.
@@ -1984,8 +1588,134 @@ private:
shared_ptr< list<SCTAB> > mpTabNumList;
};
+class RangeAnalyzer
+{
+public:
+ RangeAnalyzer();
+ void initRangeAnalyzer( const vector<ScSharedTokenRef>& rTokens );
+ void analyzeRange( sal_Int32& rnDataInRows, sal_Int32& rnDataInCols,
+ bool& rbRowSourceAmbiguous ) const;
+ bool inSameSingleRow( RangeAnalyzer& rOther );
+ bool inSameSingleColumn( RangeAnalyzer& rOther );
+ SCROW getRowCount() { return mnRowCount; }
+ SCCOL getColumnCount() { return mnColumnCount; }
+
+private:
+ bool mbEmpty;
+ bool mbAmbiguous;
+ SCROW mnRowCount;
+ SCCOL mnColumnCount;
+
+ SCCOL mnStartColumn;
+ SCROW mnStartRow;
+};
+
+RangeAnalyzer::RangeAnalyzer()
+ : mbEmpty(true)
+ , mbAmbiguous(false)
+ , mnRowCount(0)
+ , mnColumnCount(0)
+ , mnStartColumn(-1)
+ , mnStartRow(-1)
+{
}
+void RangeAnalyzer::initRangeAnalyzer( const vector<ScSharedTokenRef>& rTokens )
+{
+ mnRowCount=0;
+ mnColumnCount=0;
+ mnStartColumn = -1;
+ mnStartRow = -1;
+ mbAmbiguous=false;
+ if( rTokens.empty() )
+ {
+ mbEmpty=true;
+ return;
+ }
+ mbEmpty=false;
+
+ vector<ScSharedTokenRef>::const_iterator itr = rTokens.begin(), itrEnd = rTokens.end();
+ for (; itr != itrEnd ; ++itr)
+ {
+ ScSharedTokenRef aRefToken = *itr;
+ StackVar eVar = aRefToken->GetType();
+ if (eVar == svDoubleRef || eVar == svExternalDoubleRef)
+ {
+ const ScComplexRefData& r = aRefToken->GetDoubleRef();
+ if (r.Ref1.nTab == r.Ref2.nTab)
+ {
+ mnColumnCount = std::max<SCCOL>( mnColumnCount, static_cast<SCCOL>(abs(r.Ref2.nCol - r.Ref1.nCol)+1) );
+ mnRowCount = std::max<SCROW>( mnRowCount, static_cast<SCROW>(abs(r.Ref2.nRow - r.Ref1.nRow)+1) );
+ if( mnStartColumn == -1 )
+ {
+ mnStartColumn = r.Ref1.nCol;
+ mnStartRow = r.Ref1.nRow;
+ }
+ else
+ {
+ if( mnStartColumn != r.Ref1.nCol && mnStartRow != r.Ref1.nRow )
+ mbAmbiguous=true;
+ }
+ }
+ else
+ mbAmbiguous=true;
+ }
+ else if (eVar == svSingleRef || eVar == svExternalSingleRef)
+ {
+ const ScSingleRefData& r = aRefToken->GetSingleRef();
+ mnColumnCount = std::max<SCCOL>( mnColumnCount, 1);
+ mnRowCount = std::max<SCROW>( mnRowCount, 1);
+ if( mnStartColumn == -1 )
+ {
+ mnStartColumn = r.nCol;
+ mnStartRow = r.nRow;
+ }
+ else
+ {
+ if( mnStartColumn != r.nCol && mnStartRow != r.nRow )
+ mbAmbiguous=true;
+ }
+ }
+ else
+ mbAmbiguous=true;
+ }
+}
+
+void RangeAnalyzer::analyzeRange( sal_Int32& rnDataInRows,
+ sal_Int32& rnDataInCols,
+ bool& rbRowSourceAmbiguous ) const
+{
+ if(!mbEmpty && !mbAmbiguous)
+ {
+ if( mnRowCount==1 && mnColumnCount>1 )
+ ++rnDataInRows;
+ else if( mnColumnCount==1 && mnRowCount>1 )
+ ++rnDataInCols;
+ else if( mnRowCount>1 && mnColumnCount>1 )
+ rbRowSourceAmbiguous = true;
+ }
+ else if( !mbEmpty )
+ rbRowSourceAmbiguous = true;
+}
+
+bool RangeAnalyzer::inSameSingleRow( RangeAnalyzer& rOther )
+{
+ if( mnStartRow==rOther.mnStartRow &&
+ mnRowCount==1 && rOther.mnRowCount==1 )
+ return true;
+ return false;
+}
+
+bool RangeAnalyzer::inSameSingleColumn( RangeAnalyzer& rOther )
+{
+ if( mnStartColumn==rOther.mnStartColumn &&
+ mnColumnCount==1 && rOther.mnColumnCount==1 )
+ return true;
+ return false;
+}
+
+} //end anonymous namespace
+
uno::Sequence< beans::PropertyValue > SAL_CALL ScChart2DataProvider::detectArguments(
const uno::Reference< chart2::data::XDataSource >& xDataSource )
throw (uno::RuntimeException)
@@ -1993,28 +1723,137 @@ uno::Sequence< beans::PropertyValue > SAL_CALL ScChart2DataProvider::detectArgum
::std::vector< beans::PropertyValue > aResult;
bool bRowSourceDetected = false;
bool bFirstCellAsLabel = false;
- bool bHasCategories = true;
+ bool bHasCategories = false;
::rtl::OUString sRangeRep;
+ bool bHasCategoriesLabels = false;
+ vector<ScSharedTokenRef> aAllCategoriesValuesTokens;
+ vector<ScSharedTokenRef> aAllSeriesLabelTokens;
+
chart::ChartDataRowSource eRowSource = chart::ChartDataRowSource_COLUMNS;
- vector<ScSharedTokenRef> aTokens;
+ vector<ScSharedTokenRef> aAllTokens;
- // CellRangeRepresentation
+ // parse given data source and collect infos
{
ScUnoGuard aGuard;
DBG_ASSERT( m_pDocument, "No Document -> no detectArguments" );
- if(!m_pDocument)
+ if(!m_pDocument ||!xDataSource.is())
return lcl_VectorToSequence( aResult );
- detectRangesFromDataSource(aTokens, eRowSource, bRowSourceDetected, xDataSource);
+ sal_Int32 nDataInRows = 0;
+ sal_Int32 nDataInCols = 0;
+ bool bRowSourceAmbiguous = false;
+
+ Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences( xDataSource->getDataSequences());
+ const sal_Int32 nCount( aSequences.getLength());
+ RangeAnalyzer aPrevLabel,aPrevValues;
+ for( sal_Int32 nIdx=0; nIdx<nCount; ++nIdx )
+ {
+ Reference< chart2::data::XLabeledDataSequence > xLS(aSequences[nIdx]);
+ if( xLS.is() )
+ {
+ bool bThisIsCategories = false;
+ if(!bHasCategories)
+ {
+ Reference< beans::XPropertySet > xSeqProp( xLS->getValues(), uno::UNO_QUERY );
+ ::rtl::OUString aRole;
+ if( xSeqProp.is() && (xSeqProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Role"))) >>= aRole) &&
+ aRole.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("categories")) )
+ bThisIsCategories = bHasCategories = true;
+ }
+
+ RangeAnalyzer aLabel,aValues;
+ // label
+ Reference< chart2::data::XDataSequence > xLabel( xLS->getLabel());
+ if( xLabel.is())
+ {
+ bFirstCellAsLabel = true;
+ vector<ScSharedTokenRef> aTokens;
+ ScRefTokenHelper::compileRangeRepresentation( aTokens, xLabel->getSourceRangeRepresentation(), m_pDocument, m_pDocument->GetGrammar() );
+ aLabel.initRangeAnalyzer(aTokens);
+ vector<ScSharedTokenRef>::const_iterator itr = aTokens.begin(), itrEnd = aTokens.end();
+ for (; itr != itrEnd; ++itr)
+ {
+ ScRefTokenHelper::join(aAllTokens, *itr);
+ if(!bThisIsCategories)
+ ScRefTokenHelper::join(aAllSeriesLabelTokens, *itr);
+ }
+ if(bThisIsCategories)
+ bHasCategoriesLabels=true;
+ }
+ // values
+ Reference< chart2::data::XDataSequence > xValues( xLS->getValues());
+ if( xValues.is())
+ {
+ vector<ScSharedTokenRef> aTokens;
+ ScRefTokenHelper::compileRangeRepresentation( aTokens, xValues->getSourceRangeRepresentation(), m_pDocument, m_pDocument->GetGrammar() );
+ aValues.initRangeAnalyzer(aTokens);
+ vector<ScSharedTokenRef>::const_iterator itr = aTokens.begin(), itrEnd = aTokens.end();
+ for (; itr != itrEnd; ++itr)
+ {
+ ScRefTokenHelper::join(aAllTokens, *itr);
+ if(bThisIsCategories)
+ ScRefTokenHelper::join(aAllCategoriesValuesTokens, *itr);
+ }
+ }
+ //detect row source
+ if(!bThisIsCategories || nCount==1) //categories might span multiple rows *and* columns, so they should be used for detection only if nothing else is available
+ {
+ if (!bRowSourceAmbiguous)
+ {
+ aValues.analyzeRange(nDataInRows,nDataInCols,bRowSourceAmbiguous);
+ aLabel.analyzeRange(nDataInRows,nDataInCols,bRowSourceAmbiguous);
+ if (nDataInRows > 1 && nDataInCols > 1)
+ bRowSourceAmbiguous = true;
+ else if( !bRowSourceAmbiguous && !nDataInRows && !nDataInCols )
+ {
+ if( aValues.inSameSingleColumn( aLabel ) )
+ nDataInCols++;
+ else if( aValues.inSameSingleRow( aLabel ) )
+ nDataInRows++;
+ else
+ {
+ //#i86188# also detect a single column split into rows correctly
+ if( aValues.inSameSingleColumn( aPrevValues ) )
+ nDataInRows++;
+ else if( aValues.inSameSingleRow( aPrevValues ) )
+ nDataInCols++;
+ else if( aLabel.inSameSingleColumn( aPrevLabel ) )
+ nDataInRows++;
+ else if( aLabel.inSameSingleRow( aPrevLabel ) )
+ nDataInCols++;
+ }
+ }
+ }
+ }
+ aPrevValues=aValues;
+ aPrevLabel=aLabel;
+ }
+ }
+
+ if (!bRowSourceAmbiguous)
+ {
+ bRowSourceDetected = true;
+ eRowSource = ( nDataInRows > 0
+ ? chart::ChartDataRowSource_ROWS
+ : chart::ChartDataRowSource_COLUMNS );
+ }
+ else
+ {
+ // set DataRowSource to the better of the two ambiguities
+ eRowSource = ( nDataInRows > nDataInCols
+ ? chart::ChartDataRowSource_ROWS
+ : chart::ChartDataRowSource_COLUMNS );
+ }
+
}
// TableNumberList
{
list<SCTAB> aTableNumList;
InsertTabNumber func;
- func = for_each(aTokens.begin(), aTokens.end(), func);
+ func = for_each(aAllTokens.begin(), aAllTokens.end(), func);
func.getList(aTableNumList);
aResult.push_back(
beans::PropertyValue( ::rtl::OUString::createFromAscii("TableNumberList"), -1,
@@ -2033,29 +1872,38 @@ uno::Sequence< beans::PropertyValue > SAL_CALL ScChart2DataProvider::detectArgum
// HasCategories
if( bRowSourceDetected )
{
- if( lcl_HasCategories( xDataSource, bHasCategories ))
- {
- aResult.push_back(
- beans::PropertyValue( ::rtl::OUString::createFromAscii("HasCategories"), -1,
- uno::makeAny( bHasCategories ), beans::PropertyState_DIRECT_VALUE ));
- }
+ aResult.push_back(
+ beans::PropertyValue( ::rtl::OUString::createFromAscii("HasCategories"), -1,
+ uno::makeAny( bHasCategories ), beans::PropertyState_DIRECT_VALUE ));
}
// FirstCellAsLabel
if( bRowSourceDetected )
{
- lcl_HasFirstCellAsLabel( xDataSource, bFirstCellAsLabel );
aResult.push_back(
beans::PropertyValue( ::rtl::OUString::createFromAscii("FirstCellAsLabel"), -1,
uno::makeAny( bFirstCellAsLabel ), beans::PropertyState_DIRECT_VALUE ));
}
// Add the left upper corner to the range if it is missing.
- if (bRowSourceDetected && bFirstCellAsLabel && bHasCategories)
- addUpperLeftCornerIfMissing(aTokens);
+ if (bRowSourceDetected && bFirstCellAsLabel && bHasCategories && !bHasCategoriesLabels )
+ {
+ RangeAnalyzer aTop,aLeft;
+ if( eRowSource==chart::ChartDataRowSource_COLUMNS )
+ {
+ aTop.initRangeAnalyzer(aAllSeriesLabelTokens);
+ aLeft.initRangeAnalyzer(aAllCategoriesValuesTokens);
+ }
+ else
+ {
+ aTop.initRangeAnalyzer(aAllCategoriesValuesTokens);
+ aLeft.initRangeAnalyzer(aAllSeriesLabelTokens);
+ }
+ lcl_addUpperLeftCornerIfMissing(aAllTokens, aTop.getRowCount(), aLeft.getColumnCount());//e.g. #i91212#
+ }
// Get range string.
- lcl_convertTokensToString(sRangeRep, aTokens, m_pDocument);
+ lcl_convertTokensToString(sRangeRep, aAllTokens, m_pDocument);
// add cell range property
aResult.push_back(
@@ -2270,91 +2118,6 @@ rtl::OUString SAL_CALL ScChart2DataProvider::convertRangeFromXML( const rtl::OUS
return aRet;
}
-namespace {
-
-class CollectRefTokens : public ::std::unary_function<ScSharedTokenRef, void>
-{
-public:
- CollectRefTokens() :
- mpRefTokens(new vector<ScSharedTokenRef>()),
- mnDataInRows(0),
- mnDataInCols(0),
- mbRowSourceAmbiguous(false)
- {
- }
-
- CollectRefTokens(const CollectRefTokens& r) :
- mpRefTokens(r.mpRefTokens),
- mnDataInRows(r.mnDataInRows),
- mnDataInCols(r.mnDataInCols),
- mbRowSourceAmbiguous(r.mbRowSourceAmbiguous)
- {
- }
-
- void operator() (const ScSharedTokenRef& rRefToken)
- {
- if (!mbRowSourceAmbiguous)
- {
- StackVar eVar = rRefToken->GetType();
- if (eVar == svDoubleRef || eVar == svExternalDoubleRef)
- {
- const ScComplexRefData& r = rRefToken->GetDoubleRef();
- mbRowSourceAmbiguous = r.Ref1.nTab != r.Ref2.nTab;
- if (!mbRowSourceAmbiguous)
- {
- bool bColDiff = (r.Ref2.nCol - r.Ref1.nCol) != 0;
- bool bRowDiff = (r.Ref2.nRow - r.Ref1.nRow) != 0;
-
- if (bColDiff && !bRowDiff)
- ++mnDataInRows;
- else if (bRowDiff && !bColDiff)
- ++mnDataInCols;
- else if (bRowDiff && bColDiff)
- mbRowSourceAmbiguous = true;
-
- if (mnDataInRows > 0 && mnDataInCols > 0)
- mbRowSourceAmbiguous = true;
- }
- }
- }
-
- mpRefTokens->push_back(rRefToken);
- }
-
- void appendTokens(vector<ScSharedTokenRef>& rTokens)
- {
- vector<ScSharedTokenRef> aNewTokens = rTokens;
- vector<ScSharedTokenRef>::const_iterator itr = mpRefTokens->begin(), itrEnd = mpRefTokens->end();
- for (; itr != itrEnd; ++itr)
- ScRefTokenHelper::join(aNewTokens, *itr);
-
- rTokens.swap(aNewTokens);
- }
-
- bool isRowSourceAmbiguous() const
- {
- return mbRowSourceAmbiguous;
- }
-
- sal_uInt32 getDataInRows() const
- {
- return mnDataInRows;
- }
-
- sal_uInt32 getDataInCols() const
- {
- return mnDataInCols;
- }
-
-private:
- shared_ptr< vector<ScSharedTokenRef> > mpRefTokens;
- sal_uInt32 mnDataInRows;
- sal_uInt32 mnDataInCols;
- bool mbRowSourceAmbiguous;
-};
-
-}
-
// DataProvider XPropertySet -------------------------------------------------
uno::Reference< beans::XPropertySetInfo> SAL_CALL
@@ -2437,53 +2200,6 @@ void SAL_CALL ScChart2DataProvider::removeVetoableChangeListener(
OSL_ENSURE( false, "Not yet implemented" );
}
-void ScChart2DataProvider::detectRangesFromDataSource(vector<ScSharedTokenRef>& rRefTokens,
- chart::ChartDataRowSource& rRowSource,
- bool& rRowSourceDetected,
- const Reference<chart2::data::XDataSource>& xDataSource)
-{
- if (!m_pDocument)
- return;
-
- sal_Int32 nDataInRows = 0;
- sal_Int32 nDataInCols = 0;
- bool bRowSourceAmbiguous = false;
-
- vector<OUString> aRangeReps = lcl_getRangeRepresentationsFromDataSource(xDataSource);
- for (vector<OUString>::const_iterator itr = aRangeReps.begin(), itrEnd = aRangeReps.end();
- itr != itrEnd; ++itr)
- {
- const OUString& rRangeRep = *itr;
- vector<ScSharedTokenRef> aTokens;
- ScRefTokenHelper::compileRangeRepresentation(aTokens, rRangeRep, m_pDocument, m_pDocument->GetGrammar());
-
- CollectRefTokens func;
- func = for_each(aTokens.begin(), aTokens.end(), func);
- func.appendTokens(rRefTokens);
- bRowSourceAmbiguous = bRowSourceAmbiguous || func.isRowSourceAmbiguous();
- if (!bRowSourceAmbiguous)
- {
- nDataInRows += func.getDataInRows();
- nDataInCols += func.getDataInCols();
- }
- }
-
- if (!bRowSourceAmbiguous)
- {
- rRowSourceDetected = true;
- rRowSource = ( nDataInRows > 0
- ? chart::ChartDataRowSource_ROWS
- : chart::ChartDataRowSource_COLUMNS );
- }
- else
- {
- // set DataRowSource to the better of the two ambiguities
- rRowSource = ( nDataInRows > nDataInCols
- ? chart::ChartDataRowSource_ROWS
- : chart::ChartDataRowSource_COLUMNS );
- }
-}
-
// DataSource ================================================================
ScChart2DataSource::ScChart2DataSource( ScDocument* pDoc)
diff --git a/sc/source/ui/unoobj/chartuno.cxx b/sc/source/ui/unoobj/chartuno.cxx
index 5feabe72207d..201c411ea45c 100644
--- a/sc/source/ui/unoobj/chartuno.cxx
+++ b/sc/source/ui/unoobj/chartuno.cxx
@@ -480,20 +480,15 @@ void ScChartObj::GetData_Impl( ScRangeListRef& rRanges, bool& rColHeaders, bool&
{
bool bFound = false;
ScDocument* pDoc = (pDocShell? pDocShell->GetDocument(): 0);
- uno::Reference< embed::XEmbeddedObject > xIPObj;
+
if( pDoc )
- xIPObj.set( pDoc->FindOleObjectByName( aChartName ), uno::UNO_QUERY );
- if( xIPObj.is())
{
- //make sure that the chart is loaded
- svt::EmbeddedObjectRef::TryRunningState( xIPObj );
-
- uno::Reference< chart2::XChartDocument > xChartDoc( xIPObj->getComponent(), uno::UNO_QUERY );
- uno::Reference< chart2::data::XDataReceiver > xReceiver( xChartDoc, uno::UNO_QUERY );
- if( xReceiver.is() )
+ uno::Reference< chart2::XChartDocument > xChartDoc( pDoc->GetChartByName( aChartName ) );
+ if( xChartDoc.is() )
{
+ uno::Reference< chart2::data::XDataReceiver > xReceiver( xChartDoc, uno::UNO_QUERY );
uno::Reference< chart2::data::XDataProvider > xProvider = xChartDoc->getDataProvider();
- if( xProvider.is() )
+ if( xReceiver.is() && xProvider.is() )
{
uno::Sequence< beans::PropertyValue > aArgs( xProvider->detectArguments( xReceiver->getUsedData() ) );
diff --git a/sc/source/ui/unoobj/cursuno.cxx b/sc/source/ui/unoobj/cursuno.cxx
index 39ed859aa574..daf075964a3a 100644
--- a/sc/source/ui/unoobj/cursuno.cxx
+++ b/sc/source/ui/unoobj/cursuno.cxx
@@ -133,7 +133,7 @@ void SAL_CALL ScCellCursorObj::collapseToCurrentRegion() throw(uno::RuntimeExcep
SCTAB nTab = aOneRange.aStart.Tab();
pDocSh->GetDocument()->GetDataArea(
- nTab, nStartCol, nStartRow, nEndCol, nEndRow, TRUE );
+ nTab, nStartCol, nStartRow, nEndCol, nEndRow, TRUE, false );
ScRange aNew( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab );
SetNewRange( aNew );
@@ -331,7 +331,7 @@ void SAL_CALL ScCellCursorObj::gotoStart() throw(uno::RuntimeException)
SCTAB nTab = aOneRange.aStart.Tab();
pDocSh->GetDocument()->GetDataArea(
- nTab, nStartCol, nStartRow, nEndCol, nEndRow, FALSE );
+ nTab, nStartCol, nStartRow, nEndCol, nEndRow, FALSE, false );
ScRange aNew( nStartCol, nStartRow, nTab );
SetNewRange( aNew );
@@ -359,7 +359,7 @@ void SAL_CALL ScCellCursorObj::gotoEnd() throw(uno::RuntimeException)
SCTAB nTab = aOneRange.aStart.Tab();
pDocSh->GetDocument()->GetDataArea(
- nTab, nStartCol, nStartRow, nEndCol, nEndRow, FALSE );
+ nTab, nStartCol, nStartRow, nEndCol, nEndRow, FALSE, false );
ScRange aNew( nEndCol, nEndRow, nTab );
SetNewRange( aNew );
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
index a921d1e125f2..7e23d6b2f9f5 100644..100755
--- a/sc/source/ui/unoobj/dapiuno.cxx
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -43,15 +43,19 @@
#include "unoguard.hxx"
#include "dpobject.hxx"
#include "dpshttab.hxx"
+#include "dpsdbtab.hxx"
#include "dpsave.hxx"
#include "dbdocfun.hxx"
#include "unonames.hxx"
#include "dpgroup.hxx"
#include "dpdimsave.hxx"
+#include "hints.hxx"
+
#include <com/sun/star/sheet/XHierarchiesSupplier.hpp>
#include <com/sun/star/sheet/XLevelsSupplier.hpp>
#include <com/sun/star/sheet/XMembersSupplier.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/sheet/DataImportMode.hpp>
#include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
#include <com/sun/star/sheet/DataPilotOutputRangeType.hpp>
@@ -105,9 +109,12 @@ const SfxItemPropertyMapEntry* lcl_GetDataPilotDescriptorBaseMap()
{MAP_CHAR_LEN(SC_UNO_COLGRAND), 0, &getBooleanCppuType(), 0, 0 },
{MAP_CHAR_LEN(SC_UNO_DRILLDOWN), 0, &getBooleanCppuType(), 0, 0 },
{MAP_CHAR_LEN(SC_UNO_IGNEMPROWS), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_IMPORTDESC), 0, &getCppuType((uno::Sequence<beans::PropertyValue>*)0), 0, 0 },
{MAP_CHAR_LEN(SC_UNO_RPTEMPTY), 0, &getBooleanCppuType(), 0, 0 },
{MAP_CHAR_LEN(SC_UNO_ROWGRAND), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_SERVICEARG), 0, &getCppuType((uno::Sequence<beans::PropertyValue>*)0), 0, 0 },
{MAP_CHAR_LEN(SC_UNO_SHOWFILT), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_SOURCESERV), 0, &getCppuType((rtl::OUString*)0), 0, 0 },
{0,0,0,0,0,0}
};
return aDataPilotDescriptorBaseMap_Impl;
@@ -261,8 +268,7 @@ ScDPObject* lcl_GetDPObject( ScDocShell* pDocShell, SCTAB nTab, const String& rN
for (USHORT i=0; i<nCount; i++)
{
ScDPObject* pDPObj = (*pColl)[i];
- if ( pDPObj->IsSheetData() &&
- pDPObj->GetOutRange().aStart.Tab() == nTab &&
+ if ( pDPObj->GetOutRange().aStart.Tab() == nTab &&
pDPObj->GetName() == rName )
return pDPObj;
}
@@ -344,7 +350,7 @@ ScDataPilotTableObj* ScDataPilotTablesObj::GetObjectByIndex_Impl( sal_Int32 nInd
for (USHORT i=0; i<nCount; i++)
{
ScDPObject* pDPObj = (*pColl)[i];
- if ( pDPObj->IsSheetData() && pDPObj->GetOutRange().aStart.Tab() == nTab )
+ if ( pDPObj->GetOutRange().aStart.Tab() == nTab )
{
if ( nFound == nIndex )
{
@@ -496,7 +502,7 @@ sal_Int32 SAL_CALL ScDataPilotTablesObj::getCount() throw(RuntimeException)
for (USHORT i=0; i<nCount; i++)
{
ScDPObject* pDPObj = (*pColl)[i];
- if ( pDPObj->IsSheetData() && pDPObj->GetOutRange().aStart.Tab() == nTab )
+ if ( pDPObj->GetOutRange().aStart.Tab() == nTab )
++nFound;
}
return nFound;
@@ -560,7 +566,7 @@ Sequence<OUString> SAL_CALL ScDataPilotTablesObj::getElementNames()
for (i=0; i<nCount; i++)
{
ScDPObject* pDPObj = (*pColl)[i];
- if ( pDPObj->IsSheetData() && pDPObj->GetOutRange().aStart.Tab() == nTab )
+ if ( pDPObj->GetOutRange().aStart.Tab() == nTab )
++nFound;
}
@@ -570,7 +576,7 @@ Sequence<OUString> SAL_CALL ScDataPilotTablesObj::getElementNames()
for (i=0; i<nCount; i++)
{
ScDPObject* pDPObj = (*pColl)[i];
- if ( pDPObj->IsSheetData() && pDPObj->GetOutRange().aStart.Tab() == nTab )
+ if ( pDPObj->GetOutRange().aStart.Tab() == nTab )
pAry[nPos++] = pDPObj->GetName();
}
@@ -598,8 +604,7 @@ sal_Bool SAL_CALL ScDataPilotTablesObj::hasByName( const OUString& aName )
//! allow all data sources!!!
ScDPObject* pDPObj = (*pColl)[i];
- if ( pDPObj->IsSheetData() &&
- pDPObj->GetOutRange().aStart.Tab() == nTab &&
+ if ( pDPObj->GetOutRange().aStart.Tab() == nTab &&
pDPObj->GetName() == aNamStr )
return TRUE;
}
@@ -696,11 +701,12 @@ CellRangeAddress SAL_CALL ScDataPilotDescriptorBase::getSourceRange()
ScUnoGuard aGuard;
ScDPObject* pDPObject(GetDPObject());
- if (!pDPObject || !pDPObject->IsSheetData())
+ if (!pDPObject)
throw RuntimeException();
CellRangeAddress aRet;
- ScUnoConversion::FillApiRange( aRet, pDPObject->GetSheetDesc()->aSourceRange );
+ if (pDPObject->IsSheetData())
+ ScUnoConversion::FillApiRange( aRet, pDPObject->GetSheetDesc()->aSourceRange );
return aRet;
}
@@ -818,6 +824,99 @@ void SAL_CALL ScDataPilotDescriptorBase::setPropertyValue( const OUString& aProp
{
aNewData.SetDrillDown(::cppu::any2bool( aValue ));
}
+ else if ( aNameString.EqualsAscii( SC_UNO_IMPORTDESC ) )
+ {
+ uno::Sequence<beans::PropertyValue> aArgSeq;
+ if ( aValue >>= aArgSeq )
+ {
+ ScImportSourceDesc aImportDesc;
+
+ const ScImportSourceDesc* pOldDesc = pDPObject->GetImportSourceDesc();
+ if (pOldDesc)
+ aImportDesc = *pOldDesc;
+
+ ScImportParam aParam;
+ ScImportDescriptor::FillImportParam( aParam, aArgSeq );
+
+ USHORT nNewType = sheet::DataImportMode_NONE;
+ if ( aParam.bImport )
+ {
+ if ( aParam.bSql )
+ nNewType = sheet::DataImportMode_SQL;
+ else if ( aParam.nType == ScDbQuery )
+ nNewType = sheet::DataImportMode_QUERY;
+ else
+ nNewType = sheet::DataImportMode_TABLE;
+ }
+ aImportDesc.nType = nNewType;
+ aImportDesc.aDBName = aParam.aDBName;
+ aImportDesc.aObject = aParam.aStatement;
+ aImportDesc.bNative = aParam.bNative;
+
+ pDPObject->SetImportDesc( aImportDesc );
+ }
+ }
+ else if ( aNameString.EqualsAscii( SC_UNO_SOURCESERV ) )
+ {
+ rtl::OUString aStrVal;
+ if ( aValue >>= aStrVal )
+ {
+ String aEmpty;
+ ScDPServiceDesc aServiceDesc(aEmpty, aEmpty, aEmpty, aEmpty, aEmpty);
+
+ const ScDPServiceDesc* pOldDesc = pDPObject->GetDPServiceDesc();
+ if (pOldDesc)
+ aServiceDesc = *pOldDesc;
+
+ aServiceDesc.aServiceName = aStrVal;
+
+ pDPObject->SetServiceData( aServiceDesc );
+ }
+ }
+ else if ( aNameString.EqualsAscii( SC_UNO_SERVICEARG ) )
+ {
+ uno::Sequence<beans::PropertyValue> aArgSeq;
+ if ( aValue >>= aArgSeq )
+ {
+ String aEmpty;
+ ScDPServiceDesc aServiceDesc(aEmpty, aEmpty, aEmpty, aEmpty, aEmpty);
+
+ const ScDPServiceDesc* pOldDesc = pDPObject->GetDPServiceDesc();
+ if (pOldDesc)
+ aServiceDesc = *pOldDesc;
+
+ rtl::OUString aStrVal;
+ sal_Int32 nArgs = aArgSeq.getLength();
+ for (sal_Int32 nArgPos=0; nArgPos<nArgs; ++nArgPos)
+ {
+ const beans::PropertyValue& rProp = aArgSeq[nArgPos];
+ String aPropName(rProp.Name);
+
+ if (aPropName.EqualsAscii( SC_UNO_SOURCENAME ))
+ {
+ if ( rProp.Value >>= aStrVal )
+ aServiceDesc.aParSource = aStrVal;
+ }
+ else if (aPropName.EqualsAscii( SC_UNO_OBJECTNAME ))
+ {
+ if ( rProp.Value >>= aStrVal )
+ aServiceDesc.aParName = aStrVal;
+ }
+ else if (aPropName.EqualsAscii( SC_UNO_USERNAME ))
+ {
+ if ( rProp.Value >>= aStrVal )
+ aServiceDesc.aParUser = aStrVal;
+ }
+ else if (aPropName.EqualsAscii( SC_UNO_PASSWORD ))
+ {
+ if ( rProp.Value >>= aStrVal )
+ aServiceDesc.aParPass = aStrVal;
+ }
+ }
+
+ pDPObject->SetServiceData( aServiceDesc );
+ }
+ }
else
throw UnknownPropertyException();
@@ -868,6 +967,63 @@ Any SAL_CALL ScDataPilotDescriptorBase::getPropertyValue( const OUString& aPrope
{
aRet = ::cppu::bool2any( aNewData.GetDrillDown() );
}
+ else if ( aNameString.EqualsAscii( SC_UNO_IMPORTDESC ) )
+ {
+ const ScImportSourceDesc* pImportDesc = pDPObject->GetImportSourceDesc();
+ if ( pImportDesc )
+ {
+ // fill ScImportParam so ScImportDescriptor::FillProperties can be used
+ ScImportParam aParam;
+ aParam.bImport = ( pImportDesc->nType != sheet::DataImportMode_NONE );
+ aParam.aDBName = pImportDesc->aDBName;
+ aParam.aStatement = pImportDesc->aObject;
+ aParam.bNative = pImportDesc->bNative;
+ aParam.bSql = ( pImportDesc->nType == sheet::DataImportMode_SQL );
+ aParam.nType = static_cast<BYTE>(( pImportDesc->nType == sheet::DataImportMode_QUERY ) ? ScDbQuery : ScDbTable);
+
+ uno::Sequence<beans::PropertyValue> aSeq( ScImportDescriptor::GetPropertyCount() );
+ ScImportDescriptor::FillProperties( aSeq, aParam );
+ aRet <<= aSeq;
+ }
+ else
+ {
+ // empty sequence
+ uno::Sequence<beans::PropertyValue> aEmpty(0);
+ aRet <<= aEmpty;
+ }
+ }
+ else if ( aNameString.EqualsAscii( SC_UNO_SOURCESERV ) )
+ {
+ rtl::OUString aServiceName;
+ const ScDPServiceDesc* pServiceDesc = pDPObject->GetDPServiceDesc();
+ if (pServiceDesc)
+ aServiceName = pServiceDesc->aServiceName;
+ aRet <<= aServiceName; // empty string if no ServiceDesc set
+ }
+ else if ( aNameString.EqualsAscii( SC_UNO_SERVICEARG ) )
+ {
+ const ScDPServiceDesc* pServiceDesc = pDPObject->GetDPServiceDesc();
+ if (pServiceDesc)
+ {
+ uno::Sequence<beans::PropertyValue> aSeq( 4 );
+ beans::PropertyValue* pArray = aSeq.getArray();
+ pArray[0].Name = rtl::OUString::createFromAscii( SC_UNO_SOURCENAME );
+ pArray[0].Value <<= rtl::OUString( pServiceDesc->aParSource );
+ pArray[1].Name = rtl::OUString::createFromAscii( SC_UNO_OBJECTNAME );
+ pArray[1].Value <<= rtl::OUString( pServiceDesc->aParName );
+ pArray[2].Name = rtl::OUString::createFromAscii( SC_UNO_USERNAME );
+ pArray[2].Value <<= rtl::OUString( pServiceDesc->aParUser );
+ pArray[3].Name = rtl::OUString::createFromAscii( SC_UNO_PASSWORD );
+ pArray[3].Value <<= rtl::OUString( pServiceDesc->aParPass );
+ aRet <<= aSeq;
+ }
+ else
+ {
+ // empty sequence
+ uno::Sequence<beans::PropertyValue> aEmpty(0);
+ aRet <<= aEmpty;
+ }
+ }
else
throw UnknownPropertyException();
}
@@ -966,7 +1122,8 @@ ScDataPilotDescriptorBase* ScDataPilotDescriptorBase::getImplementation(
ScDataPilotTableObj::ScDataPilotTableObj(ScDocShell* pDocSh, SCTAB nT, const String& rN) :
ScDataPilotDescriptorBase( pDocSh ),
nTab( nT ),
- aName( rN )
+ aName( rN ),
+ aModifyListeners( 0 )
{
}
@@ -981,6 +1138,7 @@ Any SAL_CALL ScDataPilotTableObj::queryInterface( const uno::Type& rType )
// we also need to do the same for XDataPilotTable
SC_QUERYINTERFACE( XDataPilotTable )
SC_QUERYINTERFACE( XDataPilotTable2 )
+ SC_QUERYINTERFACE( XModifyBroadcaster )
return ScDataPilotDescriptorBase::queryInterface( rType );
}
@@ -1004,12 +1162,13 @@ Sequence< uno::Type > SAL_CALL ScDataPilotTableObj::getTypes() throw(RuntimeExce
sal_Int32 nParentLen = aParentTypes.getLength();
const uno::Type* pParentPtr = aParentTypes.getConstArray();
- aTypes.realloc( nParentLen + 1 );
+ aTypes.realloc( nParentLen + 2 );
uno::Type* pPtr = aTypes.getArray();
for (sal_Int32 i = 0; i < nParentLen; ++i)
pPtr[ i ] = pParentPtr[ i ]; // parent types first
pPtr[ nParentLen ] = getCppuType( (const Reference< XDataPilotTable2 >*)0 );
+ pPtr[ nParentLen+1 ] = getCppuType( (const Reference< XModifyBroadcaster >*)0 );
}
return aTypes;
}
@@ -1115,17 +1274,21 @@ CellRangeAddress SAL_CALL ScDataPilotTableObj::getOutputRange() throw(RuntimeExc
return aRet;
}
+ULONG RefreshDPObject( ScDPObject *pDPObj, ScDocument *pDoc, ScDocShell *pDocSh, BOOL bRecord, BOOL bApi );
+
void SAL_CALL ScDataPilotTableObj::refresh() throw(RuntimeException)
{
ScUnoGuard aGuard;
- ScDPObject* pDPObj = lcl_GetDPObject(GetDocShell(), nTab, aName);
- if (pDPObj)
- {
- ScDPObject* pNew = new ScDPObject(*pDPObj);
- ScDBDocFunc aFunc(*GetDocShell());
- aFunc.DataPilotUpdate( pDPObj, pNew, TRUE, TRUE );
- delete pNew; // DataPilotUpdate copies settings from "new" object
- }
+ if( ScDPObject* pDPObj = lcl_GetDPObject(GetDocShell(), nTab, aName) )
+ RefreshDPObject( pDPObj, NULL, GetDocShell(), TRUE, TRUE );
+ //if (pDPObj)
+ //{
+ // ScDPObject* pNew = new ScDPObject(*pDPObj);
+ // ScDBDocFunc aFunc(*GetDocShell());
+ // aFunc.DataPilotUpdate( pDPObj, pNew, TRUE, TRUE );
+ // delete pNew; // DataPilotUpdate copies settings from "new" object
+ //}
+
}
Sequence< Sequence<Any> > SAL_CALL ScDataPilotTableObj::getDrillDownData(const CellAddress& aAddr)
@@ -1183,6 +1346,70 @@ CellRangeAddress SAL_CALL ScDataPilotTableObj::getOutputRangeByType( sal_Int32 n
return aRet;
}
+void SAL_CALL ScDataPilotTableObj::addModifyListener( const uno::Reference<util::XModifyListener>& aListener )
+ throw (uno::RuntimeException)
+{
+ ScUnoGuard aGuard;
+
+ uno::Reference<util::XModifyListener> *pObj = new uno::Reference<util::XModifyListener>( aListener );
+ aModifyListeners.Insert( pObj, aModifyListeners.Count() );
+
+ if ( aModifyListeners.Count() == 1 )
+ {
+ acquire(); // don't lose this object (one ref for all listeners)
+ }
+}
+
+void SAL_CALL ScDataPilotTableObj::removeModifyListener( const uno::Reference<util::XModifyListener>& aListener )
+ throw (uno::RuntimeException)
+{
+ ScUnoGuard aGuard;
+
+ acquire(); // in case the listeners have the last ref - released below
+
+ USHORT nCount = aModifyListeners.Count();
+ for ( USHORT n=nCount; n--; )
+ {
+ uno::Reference<util::XModifyListener> *pObj = aModifyListeners[n];
+ if ( *pObj == aListener )
+ {
+ aModifyListeners.DeleteAndDestroy( n );
+
+ if ( aModifyListeners.Count() == 0 )
+ {
+ release(); // release the ref for the listeners
+ }
+
+ break;
+ }
+ }
+
+ release(); // might delete this object
+}
+
+void ScDataPilotTableObj::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ if ( rHint.ISA(ScDataPilotModifiedHint) &&
+ static_cast<const ScDataPilotModifiedHint&>(rHint).GetName() == aName )
+ {
+ Refreshed_Impl();
+ }
+
+ ScDataPilotDescriptorBase::Notify( rBC, rHint );
+}
+
+void ScDataPilotTableObj::Refreshed_Impl()
+{
+ lang::EventObject aEvent;
+ aEvent.Source.set((cppu::OWeakObject*)this);
+
+ // the EventObject holds a Ref to this object until after the listener calls
+
+ ScDocument* pDoc = GetDocShell()->GetDocument();
+ for ( USHORT n=0; n<aModifyListeners.Count(); n++ )
+ pDoc->AddUnoListenerCall( *aModifyListeners[n], aEvent );
+}
+
// ============================================================================
ScDataPilotDescriptor::ScDataPilotDescriptor(ScDocShell* pDocSh) :
diff --git a/sc/source/ui/unoobj/dispuno.cxx b/sc/source/ui/unoobj/dispuno.cxx
index cff547ce2652..6c82871d02da 100644
--- a/sc/source/ui/unoobj/dispuno.cxx
+++ b/sc/source/ui/unoobj/dispuno.cxx
@@ -65,9 +65,7 @@ uno::Reference<view::XSelectionSupplier> lcl_GetSelectionSupplier( SfxViewShell*
SfxViewFrame* pViewFrame = pViewShell->GetViewFrame();
if (pViewFrame)
{
- SfxFrame* pFrame = pViewFrame->GetFrame();
- if (pFrame)
- return uno::Reference<view::XSelectionSupplier>( pFrame->GetController(), uno::UNO_QUERY );
+ return uno::Reference<view::XSelectionSupplier>( pViewFrame->GetFrame().GetController(), uno::UNO_QUERY );
}
}
return uno::Reference<view::XSelectionSupplier>();
@@ -81,8 +79,7 @@ ScDispatchProviderInterceptor::ScDispatchProviderInterceptor(ScTabViewShell* pVi
{
if ( pViewShell )
{
- SfxFrame* pFrame = pViewShell->GetViewFrame()->GetFrame();
- m_xIntercepted.set(uno::Reference<frame::XDispatchProviderInterception>(pFrame->GetFrameInterface(), uno::UNO_QUERY));
+ m_xIntercepted.set(uno::Reference<frame::XDispatchProviderInterception>(pViewShell->GetViewFrame()->GetFrame().GetFrameInterface(), uno::UNO_QUERY));
if (m_xIntercepted.is())
{
comphelper::increment( m_refCount );
diff --git a/sc/source/ui/unoobj/filtuno.cxx b/sc/source/ui/unoobj/filtuno.cxx
index 837d34544b60..8591f2fc0801 100644
--- a/sc/source/ui/unoobj/filtuno.cxx
+++ b/sc/source/ui/unoobj/filtuno.cxx
@@ -48,7 +48,12 @@
#include "sc.hrc" //CHINA001
#include "scabstdlg.hxx" //CHINA001
+#include "i18npool/lang.h"
+
+#include <memory>
+
using namespace ::com::sun::star;
+using ::rtl::OUStringBuffer;
//------------------------------------------------------------------------
@@ -143,6 +148,10 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute() throw(uno::RuntimeException)
sal_Int16 nRet = ui::dialogs::ExecutableDialogResults::CANCEL;
String aFilterString( aFilterName );
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
if ( !bExport && aFilterString == ScDocShell::GetAsciiFilterName() )
{
// ascii import is special...
@@ -161,20 +170,40 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute() throw(uno::RuntimeException)
pInStream = utl::UcbStreamHelper::CreateStream( xInputStream );
//CHINA001 ScImportAsciiDlg* pDlg = new ScImportAsciiDlg( NULL, aPrivDatName, pInStream, cAsciiDel );
- ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
- DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
AbstractScImportAsciiDlg* pDlg = pFact->CreateScImportAsciiDlg( NULL, aPrivDatName, pInStream, RID_SCDLG_ASCII, cAsciiDel);
DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
if ( pDlg->Execute() == RET_OK )
{
ScAsciiOptions aOptions;
pDlg->GetOptions( aOptions );
+ pDlg->SaveParameters();
aFilterOptions = aOptions.WriteToString();
nRet = ui::dialogs::ExecutableDialogResults::OK;
}
delete pDlg;
delete pInStream;
}
+ else if ( aFilterString == ScDocShell::GetWebQueryFilterName() || aFilterString == ScDocShell::GetHtmlFilterName() )
+ {
+ if (!bExport)
+ {
+ // HTML import.
+ ::std::auto_ptr<AbstractScTextImportOptionsDlg> pDlg(
+ pFact->CreateScTextImportOptionsDlg(NULL, RID_SCDLG_TEXT_IMPORT_OPTIONS));
+
+ if (pDlg->Execute() == RET_OK)
+ {
+ LanguageType eLang = pDlg->GetLanguageType();
+ OUStringBuffer aBuf;
+
+ aBuf.append(String::CreateFromInt32(static_cast<sal_Int32>(eLang)));
+ aBuf.append(sal_Unicode(' '));
+ aBuf.append(pDlg->IsDateConversionSet() ? sal_Unicode('1') : sal_Unicode('0'));
+ aFilterOptions = aBuf.makeStringAndClear();
+ nRet = ui::dialogs::ExecutableDialogResults::OK;
+ }
+ }
+ }
else
{
sal_Bool bMultiByte = sal_True;
@@ -246,8 +275,6 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute() throw(uno::RuntimeException)
//CHINA001 &aOptions, &aTitle, bMultiByte, bDBEnc,
//CHINA001 !bExport );
//CHINA001
- ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
- DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
AbstractScImportOptionsDlg* pDlg = pFact->CreateScImportOptionsDlg( NULL, RID_SCDLG_IMPORTOPT,
bAscii, &aOptions, &aTitle, bMultiByte, bDBEnc,
diff --git a/sc/source/ui/unoobj/unodoc.cxx b/sc/source/ui/unoobj/unodoc.cxx
index 9673db411ea0..d3d755e8b495 100644
--- a/sc/source/ui/unoobj/unodoc.cxx
+++ b/sc/source/ui/unoobj/unodoc.cxx
@@ -60,9 +60,7 @@ uno::Reference< uno::XInterface > SAL_CALL ScDocument_createInstance(
{
::vos::OGuard aGuard( Application::GetSolarMutex() );
ScDLL::Init();
- const SfxObjectCreateMode eCreateMode = ( _nCreationFlags & SFXMODEL_EMBEDDED_OBJECT ) ? SFX_CREATE_MODE_EMBEDDED : SFX_CREATE_MODE_STANDARD;
- const bool bScriptSupport = ( _nCreationFlags & SFXMODEL_DISABLE_EMBEDDED_SCRIPTS ) == 0;
- SfxObjectShell* pShell = new ScDocShell( eCreateMode, bScriptSupport );
+ SfxObjectShell* pShell = new ScDocShell( _nCreationFlags );
return uno::Reference< uno::XInterface >( pShell->GetModel() );
}
diff --git a/sc/source/ui/vba/vbahelper.cxx b/sc/source/ui/vba/vbahelper.cxx
index ca3b7825b232..4bc57e150c8f 100644
--- a/sc/source/ui/vba/vbahelper.cxx
+++ b/sc/source/ui/vba/vbahelper.cxx
@@ -518,7 +518,7 @@ void PrintOutHelper( const uno::Any& From, const uno::Any& To, const uno::Any& C
{
if ( bPreview )
{
- if ( !pViewFrame->GetFrame()->IsInPlace() )
+ if ( !pViewFrame->GetFrame().IsInPlace() )
{
SC_MOD()->InputEnterHandler();
pViewFrame->GetDispatcher()->Execute( SID_VIEWSHELL1, SFX_CALLMODE_SYNCHRON );
diff --git a/sc/source/ui/vba/vbawindow.cxx b/sc/source/ui/vba/vbawindow.cxx
index 0416b99abcb3..f0aafe83908b 100644
--- a/sc/source/ui/vba/vbawindow.cxx
+++ b/sc/source/ui/vba/vbawindow.cxx
@@ -48,7 +48,7 @@
#include <sc.hrc>
#include <hash_map>
#include <sfx2/viewfrm.hxx>
-#include <sfx2/topfrm.hxx>
+#include <vcl/wrkwin.hxx>
#include "unonames.hxx"
using namespace ::com::sun::star;
@@ -400,17 +400,13 @@ ScVbaWindow::getWindowState() throw (uno::RuntimeException)
sal_Int32 nwindowState = xlNormal;
ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
SfxViewFrame* pViewFrame = pViewShell -> GetViewFrame();
- SfxTopViewFrame *pTop= PTR_CAST( SfxTopViewFrame, pViewFrame -> GetTopViewFrame() );
- if ( pTop )
+ WorkWindow* pWork = (WorkWindow*) pViewFrame->GetFrame().GetSystemWindow();
+ if ( pWork )
{
- WorkWindow* pWork = (WorkWindow*) pTop->GetTopFrame_Impl()->GetSystemWindow();
- if ( pWork )
- {
- if ( pWork -> IsMaximized())
- nwindowState = xlMaximized;
- else if (pWork -> IsMinimized())
- nwindowState = xlMinimized;
- }
+ if ( pWork -> IsMaximized())
+ nwindowState = xlMaximized;
+ else if (pWork -> IsMinimized())
+ nwindowState = xlMinimized;
}
return uno::makeAny( nwindowState );
}
@@ -422,21 +418,17 @@ ScVbaWindow::setWindowState( const uno::Any& _windowstate ) throw (uno::RuntimeE
_windowstate >>= nwindowState;
ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
SfxViewFrame* pViewFrame = pViewShell -> GetViewFrame();
- SfxTopViewFrame *pTop= PTR_CAST( SfxTopViewFrame, pViewFrame -> GetTopViewFrame() );
- if ( pTop )
+ WorkWindow* pWork = (WorkWindow*) pViewFrame->GetFrame().GetSystemWindow();
+ if ( pWork )
{
- WorkWindow* pWork = (WorkWindow*) pTop->GetTopFrame_Impl()->GetSystemWindow();
- if ( pWork )
- {
- if ( nwindowState == xlMaximized)
- pWork -> Maximize();
- else if (nwindowState == xlMinimized)
- pWork -> Minimize();
- else if (nwindowState == xlNormal)
- pWork -> Restore();
- else
- throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Invalid Parameter" ) ), uno::Reference< uno::XInterface >() );
- }
+ if ( nwindowState == xlMaximized)
+ pWork -> Maximize();
+ else if (nwindowState == xlMinimized)
+ pWork -> Minimize();
+ else if (nwindowState == xlNormal)
+ pWork -> Restore();
+ else
+ throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Invalid Parameter" ) ), uno::Reference< uno::XInterface >() );
}
}
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx
index 916e670ec5b1..a461c54f255e 100644
--- a/sc/source/ui/view/cellsh.cxx
+++ b/sc/source/ui/view/cellsh.cxx
@@ -42,6 +42,7 @@
#include <svx/hlnkitem.hxx>
#include <sfx2/app.hxx>
#include <sfx2/bindings.hxx>
+#include <sfx2/childwin.hxx>
#include <sfx2/objface.hxx>
#include <sfx2/request.hxx>
#include <sfx2/viewfrm.hxx>
@@ -518,7 +519,7 @@ void ScCellShell::GetState(SfxItemSet &rSet)
// removed: SID_BORDER_OBJECT (old Basic)
ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
-// BOOL bOle = pTabViewShell->GetViewFrame()->GetFrame()->IsInPlace();
+// BOOL bOle = pTabViewShell->GetViewFrame()->GetFrame().IsInPlace();
// BOOL bTabProt = GetViewData()->GetDocument()->IsTabProtected(GetViewData()->GetTabNo());
ScDocShell* pDocSh = GetViewData()->GetDocShell();
ScViewData* pData = GetViewData();
@@ -970,6 +971,29 @@ void ScCellShell::GetState(SfxItemSet &rSet)
}
break;
+ case SID_SPELL_DIALOG:
+ {
+ if ( pDoc && pData && pDoc->IsTabProtected( pData->GetTabNo() ) )
+ {
+ bool bVisible = false;
+ SfxViewFrame* pViewFrame = ( pTabViewShell ? pTabViewShell->GetViewFrame() : NULL );
+ if ( pViewFrame && pViewFrame->HasChildWindow( nWhich ) )
+ {
+ SfxChildWindow* pChild = pViewFrame->GetChildWindow( nWhich );
+ Window* pWin = ( pChild ? pChild->GetWindow() : NULL );
+ if ( pWin && pWin->IsVisible() )
+ {
+ bVisible = true;
+ }
+ }
+ if ( !bVisible )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ }
+ break;
+
} // switch ( nWitch )
nWhich = aIter.NextWhich();
} // while ( nWitch )
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index aec15fceef9e..95d86032ef56 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -1944,7 +1944,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
aSet.Put( SvxFontItem( aCurFont.GetFamily(), aCurFont.GetName(), aCurFont.GetStyleName(), aCurFont.GetPitch(), aCurFont.GetCharSet(), GetPool().GetWhich(SID_ATTR_CHAR_FONT) ) );
SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( pTabViewShell->GetDialogParent(), aSet,
- pTabViewShell->GetViewFrame()->GetFrame()->GetFrameInterface(), RID_SVXDLG_CHARMAP );
+ pTabViewShell->GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP );
if ( pDlg->Execute() == RET_OK )
{
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index 95ceffc5dc59..086160263739 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -161,7 +161,7 @@ BOOL lcl_GetSortParam( const ScViewData* pData, ScSortParam& rSortParam )
SCCOL nStartCol = aExternalRange.aStart.Col();
SCROW nEndRow = aExternalRange.aEnd.Row();
SCCOL nEndCol = aExternalRange.aEnd.Col();
- pDoc->GetDataArea( aExternalRange.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow, FALSE );
+ pDoc->GetDataArea( aExternalRange.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow, FALSE, false );
aExternalRange.aStart.SetRow( nStartRow );
aExternalRange.aStart.SetCol( nStartCol );
aExternalRange.aEnd.SetRow( nEndRow );
@@ -242,7 +242,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame();
BOOL bWasOpen = FALSE;
{
- uno::Reference<frame::XFrame> xFrame = pViewFrame->GetFrame()->GetFrameInterface();
+ uno::Reference<frame::XFrame> xFrame = pViewFrame->GetFrame().GetFrameInterface();
uno::Reference<frame::XFrame> xBeamerFrame = xFrame->findFrame(
rtl::OUString::createFromAscii("_beamer"),
frame::FrameSearchFlag::CHILDREN);
diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
index 2cc42635b9b0..ed391f154892 100644
--- a/sc/source/ui/view/cellsh3.cxx
+++ b/sc/source/ui/view/cellsh3.cxx
@@ -88,7 +88,7 @@ void ScCellShell::Execute( SfxRequest& rReq )
case SID_OPENDLG_FUNCTION:
// #53318# inplace macht die EditShell Aerger...
//! kann nicht immer umgeschaltet werden ????
- if (!pTabViewShell->GetViewFrame()->GetFrame()->IsInPlace())
+ if (!pTabViewShell->GetViewFrame()->GetFrame().IsInPlace())
pTabViewShell->SetDontSwitch(TRUE); // EditShell nicht abschalten
// kein break
@@ -244,7 +244,7 @@ void ScCellShell::Execute( SfxRequest& rReq )
{
if (nSlot == FID_INPUTLINE_BLOCK)
{
- pTabViewShell->EnterBlock( String(), pData );
+ pTabViewShell->EnterBlock( aString, pData );
}
else if ( aString.Len() > 0 && ( aString.GetChar(0) == '=' || aString.GetChar(0) == '+' || aString.GetChar(0) == '-' ) )
{
diff --git a/sc/source/ui/view/dbfunc.cxx b/sc/source/ui/view/dbfunc.cxx
index 02dfd77f7460..1e5a6b9da4ae 100644
--- a/sc/source/ui/view/dbfunc.cxx
+++ b/sc/source/ui/view/dbfunc.cxx
@@ -104,7 +104,7 @@ void ScDBFunc::GotoDBArea( const String& rDBName )
// aktuellen Datenbereich fuer Sortieren / Filtern suchen
-ScDBData* ScDBFunc::GetDBData( BOOL bMark, ScGetDBMode eMode, bool bShrinkToData )
+ScDBData* ScDBFunc::GetDBData( BOOL bMark, ScGetDBMode eMode, ScGetDBSelection eSel )
{
ScDocShell* pDocSh = GetViewData()->GetDocShell();
ScDBData* pData = NULL;
@@ -112,27 +112,72 @@ ScDBData* ScDBFunc::GetDBData( BOOL bMark, ScGetDBMode eMode, bool bShrinkToData
ScMarkType eMarkType = GetViewData()->GetSimpleArea(aRange);
if ( eMarkType == SC_MARK_SIMPLE || eMarkType == SC_MARK_SIMPLE_FILTERED )
{
- if (bShrinkToData)
+ bool bShrinkColumnsOnly = false;
+ if (eSel == SC_DBSEL_ROW_DOWN)
{
- // Shrink the range to only include data area.
- ScDocument* pDoc = pDocSh->GetDocument();
- SCCOL nCol1 = aRange.aStart.Col(), nCol2 = aRange.aEnd.Col();
- SCROW nRow1 = aRange.aStart.Row(), nRow2 = aRange.aEnd.Row();
- if (pDoc->ShrinkToDataArea(aRange.aStart.Tab(), nCol1, nRow1, nCol2, nRow2))
+ // Don't alter row range, additional rows may have been selected on
+ // purpose to append data, or to have a fake header row.
+ bShrinkColumnsOnly = true;
+ // Select further rows only if only one row or a portion thereof is
+ // selected.
+ if (aRange.aStart.Row() != aRange.aEnd.Row())
+ {
+ // If an area is selected shrink that to the actual used
+ // columns, don't draw filter buttons for empty columns.
+ eSel = SC_DBSEL_SHRINK_TO_USED_DATA;
+ }
+ else if (aRange.aStart.Col() == aRange.aEnd.Col())
{
- aRange.aStart.SetCol(nCol1);
- aRange.aEnd.SetCol(nCol2);
- aRange.aStart.SetRow(nRow1);
- aRange.aEnd.SetRow(nRow2);
+ // One cell only, if it is not marked obtain entire used data
+ // area.
+ const ScMarkData& rMarkData = GetViewData()->GetMarkData();
+ if (!(rMarkData.IsMarked() || rMarkData.IsMultiMarked()))
+ eSel = SC_DBSEL_KEEP;
}
}
- pData = pDocSh->GetDBData( aRange, eMode, FALSE );
+ switch (eSel)
+ {
+ case SC_DBSEL_SHRINK_TO_SHEET_DATA:
+ {
+ // Shrink the selection to sheet data area.
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCCOL nCol1 = aRange.aStart.Col(), nCol2 = aRange.aEnd.Col();
+ SCROW nRow1 = aRange.aStart.Row(), nRow2 = aRange.aEnd.Row();
+ if (pDoc->ShrinkToDataArea( aRange.aStart.Tab(), nCol1, nRow1, nCol2, nRow2))
+ {
+ aRange.aStart.SetCol(nCol1);
+ aRange.aEnd.SetCol(nCol2);
+ aRange.aStart.SetRow(nRow1);
+ aRange.aEnd.SetRow(nRow2);
+ }
+ }
+ break;
+ case SC_DBSEL_SHRINK_TO_USED_DATA:
+ case SC_DBSEL_ROW_DOWN:
+ {
+ // Shrink the selection to actual used area.
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCCOL nCol1 = aRange.aStart.Col(), nCol2 = aRange.aEnd.Col();
+ SCROW nRow1 = aRange.aStart.Row(), nRow2 = aRange.aEnd.Row();
+ if (pDoc->ShrinkToUsedDataArea( aRange.aStart.Tab(), nCol1, nRow1, nCol2, nRow2, bShrinkColumnsOnly))
+ {
+ aRange.aStart.SetCol(nCol1);
+ aRange.aEnd.SetCol(nCol2);
+ aRange.aStart.SetRow(nRow1);
+ aRange.aEnd.SetRow(nRow2);
+ }
+ }
+ break;
+ default:
+ ; // nothing
+ }
+ pData = pDocSh->GetDBData( aRange, eMode, eSel );
}
else if ( eMode != SC_DB_OLD )
pData = pDocSh->GetDBData(
ScRange( GetViewData()->GetCurX(), GetViewData()->GetCurY(),
GetViewData()->GetTabNo() ),
- eMode, FALSE );
+ eMode, SC_DBSEL_KEEP );
if ( pData && bMark )
{
@@ -290,7 +335,7 @@ void ScDBFunc::ToggleAutoFilter()
ScQueryParam aParam;
ScDocument* pDoc = GetViewData()->GetDocument();
- ScDBData* pDBData = GetDBData( FALSE );
+ ScDBData* pDBData = GetDBData( FALSE, SC_DB_MAKE, SC_DBSEL_ROW_DOWN );
pDBData->SetByRow( TRUE ); //! Undo, vorher abfragen ??
pDBData->GetQueryParam( aParam );
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index 2ef65f596c34..406fdab9c824 100644..100755
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -689,8 +689,41 @@ void ScDBFunc::DeletePivotTable()
else
ErrorMessage(STR_PIVOT_NOTFOUND);
}
+ULONG RefreshDPObject( ScDPObject *pDPObj, ScDocument *pDoc, ScDocShell *pDocSh, BOOL bRecord, BOOL bApi )
+{
+ if( !pDPObj )
+ return STR_PIVOT_NOTFOUND;
+
+ if( !pDoc )
+ return static_cast<ULONG>(-1);
+
+ if( !pDocSh && ( pDocSh = PTR_CAST( ScDocShell, pDoc->GetDocumentShell() ) ) == NULL )
+ return static_cast<ULONG>(-1);
+
+ if( ULONG nErrId = pDPObj->RefreshCache() )
+ return nErrId;
+ else if ( nErrId == 0 )
+ {
+ //Refresh all dpobjects
+ ScDPCollection* pDPCollection = pDoc->GetDPCollection();
+ USHORT nCount = pDPCollection->GetCount();
+ for (USHORT i=0; i<nCount; i++)
+ {
+ if ( (*pDPCollection)[i]->GetCacheId() == pDPObj->GetCacheId() )
+ {
+ ScDBDocFunc aFunc( * pDocSh );
+ if ( !aFunc.DataPilotUpdate( (*pDPCollection)[i], (*pDPCollection)[i], bRecord, bApi ) )
+ break;
+ }
+ }
-void ScDBFunc::RecalcPivotTable()
+ return nErrId;
+ }
+
+ return 0U;
+}
+
+ULONG ScDBFunc::RecalcPivotTable()
{
ScDocShell* pDocSh = GetViewData()->GetDocShell();
ScDocument* pDoc = GetViewData()->GetDocument();
@@ -702,12 +735,26 @@ void ScDBFunc::RecalcPivotTable()
GetViewData()->GetTabNo() );
if ( pDPObj )
{
- ScDBDocFunc aFunc( *pDocSh );
- aFunc.DataPilotUpdate( pDPObj, pDPObj, TRUE, FALSE );
- CursorPosChanged(); // shells may be switched
+ // Wang Xu Ming -- 2009-6-17
+ // DataPilot Migration
+ //ScDBDocFunc aFunc( *pDocSh );
+ //aFunc.DataPilotUpdate( pDPObj, pDPObj, TRUE, FALSE );
+ //CursorPosChanged(); // shells may be switched
+ ULONG nErrId = RefreshDPObject( pDPObj, pDoc, pDocSh, TRUE, FALSE );//pDPObj->RefreshCache();
+ if ( nErrId == 0 )
+ {
+ // There is no undo for the refresh of the cache table, but the undo history for cell changes
+ // remains valid and should be preserved, so the history isn't cleared here.
+ //GetViewData()->GetDocShell()->GetUndoManager()->Clear();
+ }
+ else if (nErrId <= USHRT_MAX)
+ ErrorMessage(static_cast<USHORT>(nErrId));
+ return nErrId;
+ // End Comments
}
else
ErrorMessage(STR_PIVOT_NOTFOUND);
+ return STR_PIVOT_NOTFOUND;
}
void ScDBFunc::GetSelectedMemberList( ScStrCollection& rEntries, long& rDimension )
diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx
index 837cee2698b3..311bcf8c24b2 100644
--- a/sc/source/ui/view/drawview.cxx
+++ b/sc/source/ui/view/drawview.cxx
@@ -529,7 +529,7 @@ void ScDrawView::MarkListHasChanged()
// Verben anpassen
SfxViewFrame* pViewFrame = pViewSh->GetViewFrame();
- BOOL bOle = pViewSh->GetViewFrame()->GetFrame()->IsInPlace();
+ BOOL bOle = pViewSh->GetViewFrame()->GetFrame().IsInPlace();
if ( pOle2Obj && !bOle )
{
uno::Reference < embed::XEmbeddedObject > xObj = pOle2Obj->GetObjRef();
@@ -570,16 +570,13 @@ void ScDrawView::MarkListHasChanged()
if (pViewFrame)
{
- SfxFrame* pFrame = pViewFrame->GetFrame();
- if (pFrame)
+ SfxFrame& rFrame = pViewFrame->GetFrame();
+ uno::Reference<frame::XController> xController = rFrame.GetController();
+ if (xController.is())
{
- uno::Reference<frame::XController> xController = pFrame->GetController();
- if (xController.is())
- {
- ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController );
- if (pImp)
- pImp->SelectionChanged();
- }
+ ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController );
+ if (pImp)
+ pImp->SelectionChanged();
}
}
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index cd55e4f72c34..b8eeb868809e 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -2407,24 +2407,20 @@ long ScGridWindow::PreNotify( NotifyEvent& rNEvt )
SfxViewFrame* pViewFrame = pViewData->GetViewShell()->GetViewFrame();
if (pViewFrame)
{
- SfxFrame* pFrame = pViewFrame->GetFrame();
- if (pFrame)
+ com::sun::star::uno::Reference<com::sun::star::frame::XController> xController = pViewFrame->GetFrame().GetController();
+ if (xController.is())
{
- com::sun::star::uno::Reference<com::sun::star::frame::XController> xController = pFrame->GetController();
- if (xController.is())
+ ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController );
+ if (pImp && pImp->IsMouseListening())
{
- ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController );
- if (pImp && pImp->IsMouseListening())
- {
- ::com::sun::star::awt::MouseEvent aEvent;
- lcl_InitMouseEvent( aEvent, *rNEvt.GetMouseEvent() );
- if ( rNEvt.GetWindow() )
- aEvent.Source = rNEvt.GetWindow()->GetComponentInterface();
- if ( nType == EVENT_MOUSEBUTTONDOWN)
- pImp->MousePressed( aEvent );
- else
- pImp->MouseReleased( aEvent );
- }
+ ::com::sun::star::awt::MouseEvent aEvent;
+ lcl_InitMouseEvent( aEvent, *rNEvt.GetMouseEvent() );
+ if ( rNEvt.GetWindow() )
+ aEvent.Source = rNEvt.GetWindow()->GetComponentInterface();
+ if ( nType == EVENT_MOUSEBUTTONDOWN)
+ pImp->MousePressed( aEvent );
+ else
+ pImp->MouseReleased( aEvent );
}
}
}
@@ -2689,9 +2685,32 @@ void __EXPORT ScGridWindow::Command( const CommandEvent& rCEvt )
if ( bMouse )
{
+ SCsCOL nCellX = -1;
+ SCsROW nCellY = -1;
+ pViewData->GetPosFromPixel(aPosPixel.X(), aPosPixel.Y(), eWhich, nCellX, nCellY);
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ const ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
+ bool bSelectAllowed = true;
+ if ( pProtect && pProtect->isProtected() )
+ {
+ // This sheet is protected. Check if a context menu is allowed on this cell.
+ bool bCellProtected = pDoc->HasAttrib(nCellX, nCellY, nTab, nCellX, nCellY, nTab, HASATTR_PROTECTED);
+ bool bSelProtected = pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
+ bool bSelUnprotected = pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
+
+ if (bCellProtected)
+ bSelectAllowed = bSelProtected;
+ else
+ bSelectAllowed = bSelUnprotected;
+ }
+ if (!bSelectAllowed)
+ // Selecting this cell is not allowed, neither is context menu.
+ return;
+
// #i18735# First select the item under the mouse pointer.
// This can change the selection, and the view state (edit mode, etc).
- SelectForContextMenu( aPosPixel );
+ SelectForContextMenu( aPosPixel, nCellX, nCellY );
}
BOOL bDone = FALSE;
@@ -2786,15 +2805,12 @@ void __EXPORT ScGridWindow::Command( const CommandEvent& rCEvt )
}
}
-void ScGridWindow::SelectForContextMenu( const Point& rPosPixel )
+void ScGridWindow::SelectForContextMenu( const Point& rPosPixel, SCsCOL nCellX, SCsROW nCellY )
{
// #i18735# if the click was outside of the current selection,
// the cursor is moved or an object at the click position selected.
// (see SwEditWin::SelectMenuPosition in Writer)
- SCsCOL nCellX;
- SCsROW nCellY;
- pViewData->GetPosFromPixel( rPosPixel.X(), rPosPixel.Y(), eWhich, nCellX, nCellY );
ScTabView* pView = pViewData->GetView();
ScDrawView* pDrawView = pView->GetScDrawView();
diff --git a/sc/source/ui/view/hdrcont.cxx b/sc/source/ui/view/hdrcont.cxx
index 511463db8a10..6c389d496b73 100644
--- a/sc/source/ui/view/hdrcont.cxx
+++ b/sc/source/ui/view/hdrcont.cxx
@@ -44,6 +44,7 @@
#include "scmod.hxx" // Optionen
#include "inputopt.hxx" // Optionen
#include "gridmerg.hxx"
+#include "document.hxx"
// -----------------------------------------------------------------------
@@ -120,7 +121,7 @@ void ScHeaderControl::SetWidth( long nNew )
}
}
-__EXPORT ScHeaderControl::~ScHeaderControl()
+ScHeaderControl::~ScHeaderControl()
{
}
@@ -262,7 +263,7 @@ void ScHeaderControl::DrawShadedRect( long nStart, long nEnd, const Color& rBase
// Paint
//
-void __EXPORT ScHeaderControl::Paint( const Rectangle& rRect )
+void ScHeaderControl::Paint( const Rectangle& rRect )
{
// fuer VCL ist es wichtig, wenig Aufrufe zu haben, darum werden die aeusseren
// Linien zusammengefasst
@@ -652,7 +653,46 @@ SCCOLROW ScHeaderControl::GetMousePos( const MouseEvent& rMEvt, BOOL& rBorder )
return nHitNo;
}
-void __EXPORT ScHeaderControl::MouseButtonDown( const MouseEvent& rMEvt )
+bool ScHeaderControl::IsSelectionAllowed(SCCOLROW nPos) const
+{
+ ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
+ if (!pViewSh)
+ return false;
+
+ ScViewData* pViewData = pViewSh->GetViewData();
+ USHORT nTab = pViewData->GetTabNo();
+ ScDocument* pDoc = pViewData->GetDocument();
+ const ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
+ bool bSelectAllowed = true;
+ if ( pProtect && pProtect->isProtected() )
+ {
+ // This sheet is protected. Check if a context menu is allowed on this cell.
+ bool bCellsProtected = false;
+ if (bVertical)
+ {
+ // row header
+ SCROW nRPos = static_cast<SCROW>(nPos);
+ bCellsProtected = pDoc->HasAttrib(0, nRPos, nTab, MAXCOL, nRPos, nTab, HASATTR_PROTECTED);
+ }
+ else
+ {
+ // column header
+ SCCOL nCPos = static_cast<SCCOL>(nPos);
+ bCellsProtected = pDoc->HasAttrib(nCPos, 0, nTab, nCPos, MAXROW, nTab, HASATTR_PROTECTED);
+ }
+
+ bool bSelProtected = pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
+ bool bSelUnprotected = pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
+
+ if (bCellsProtected)
+ bSelectAllowed = bSelProtected;
+ else
+ bSelectAllowed = bSelUnprotected;
+ }
+ return bSelectAllowed;
+}
+
+void ScHeaderControl::MouseButtonDown( const MouseEvent& rMEvt )
{
if (IsDisabled())
return;
@@ -662,6 +702,8 @@ void __EXPORT ScHeaderControl::MouseButtonDown( const MouseEvent& rMEvt )
BOOL bFound;
SCCOLROW nHitNo = GetMousePos( rMEvt, bFound );
+ if (!IsSelectionAllowed(nHitNo))
+ return;
if ( bFound && rMEvt.IsLeft() && ResizeAllowed() )
{
@@ -717,7 +759,7 @@ void __EXPORT ScHeaderControl::MouseButtonDown( const MouseEvent& rMEvt )
}
}
-void __EXPORT ScHeaderControl::MouseButtonUp( const MouseEvent& rMEvt )
+void ScHeaderControl::MouseButtonUp( const MouseEvent& rMEvt )
{
if ( IsDisabled() )
return;
@@ -770,7 +812,7 @@ void __EXPORT ScHeaderControl::MouseButtonUp( const MouseEvent& rMEvt )
}
}
-void __EXPORT ScHeaderControl::MouseMove( const MouseEvent& rMEvt )
+void ScHeaderControl::MouseMove( const MouseEvent& rMEvt )
{
if ( IsDisabled() )
{
@@ -820,7 +862,7 @@ void ScHeaderControl::Tracking( const TrackingEvent& rTEvt )
MouseMove( rTEvt.GetMouseEvent() );
}
-void __EXPORT ScHeaderControl::Command( const CommandEvent& rCEvt )
+void ScHeaderControl::Command( const CommandEvent& rCEvt )
{
USHORT nCmd = rCEvt.GetCommand();
if ( nCmd == COMMAND_CONTEXTMENU )
@@ -845,8 +887,11 @@ void __EXPORT ScHeaderControl::Command( const CommandEvent& rCEvt )
MouseEvent aMEvt( rCEvt.GetMousePosPixel() );
BOOL bBorder;
SCCOLROW nPos = GetMousePos( aMEvt, bBorder );
- USHORT nTab = pViewData->GetTabNo();
+ if (!IsSelectionAllowed(nPos))
+ // Selecting this cell is not allowed, neither is context menu.
+ return;
+ SCTAB nTab = pViewData->GetTabNo();
ScRange aNewRange;
if ( bVertical )
aNewRange = ScRange( 0, sal::static_int_cast<SCROW>(nPos), nTab,
@@ -935,7 +980,7 @@ void ScHeaderControl::ShowDragHelp()
}
}
-void __EXPORT ScHeaderControl::RequestHelp( const HelpEvent& rHEvt )
+void ScHeaderControl::RequestHelp( const HelpEvent& rHEvt )
{
// Wenn eigene QuickHelp angezeigt wird, nicht durch RequestHelp
// wieder wegnehmen lassen
diff --git a/sc/source/ui/view/makefile.mk b/sc/source/ui/view/makefile.mk
index e40d6da5c09d..feeacc865fba 100644
--- a/sc/source/ui/view/makefile.mk
+++ b/sc/source/ui/view/makefile.mk
@@ -156,6 +156,9 @@ EXCEPTIONSFILES= \
$(SLO)$/scextopt.obj \
$(SLO)$/tabvwshb.obj \
$(SLO)$/viewdata.obj \
+ $(SLO)$/viewfunc.obj \
+ $(SLO)$/viewfun2.obj \
+ $(SLO)$/viewfun3.obj \
$(SLO)$/viewfun5.obj \
$(SLO)$/viewfun7.obj \
$(SLO)$/reffact.obj
diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx
index f4b976b00e4d..38d5144274c5 100644
--- a/sc/source/ui/view/prevwsh.cxx
+++ b/sc/source/ui/view/prevwsh.cxx
@@ -44,7 +44,6 @@
#include <sfx2/dispatch.hxx>
#include <sfx2/objface.hxx>
#include <sfx2/request.hxx>
-#include <sfx2/topfrm.hxx>
#include <svtools/printdlg.hxx>
#include <svl/stritem.hxx>
#include <svl/whiter.hxx>
@@ -151,7 +150,7 @@ void ScPreviewShell::Construct( Window* pParent )
ScPreviewShell::ScPreviewShell( SfxViewFrame* pViewFrame,
SfxViewShell* pOldSh ) :
- SfxViewShell( pViewFrame, SFX_VIEW_MAXIMIZE_FIRST | SFX_VIEW_CAN_PRINT | SFX_VIEW_HAS_PRINTOPTIONS ),
+ SfxViewShell( pViewFrame, SFX_VIEW_CAN_PRINT | SFX_VIEW_HAS_PRINTOPTIONS ),
pDocShell( (ScDocShell*)pViewFrame->GetObjectShell() ),
nSourceDesignMode( SC_FORCEMODE_NONE ),
pAccessibilityBroadcaster( NULL )
diff --git a/sc/source/ui/view/spelldialog.cxx b/sc/source/ui/view/spelldialog.cxx
index 8ff816263b4f..a178b0a0ada6 100644
--- a/sc/source/ui/view/spelldialog.cxx
+++ b/sc/source/ui/view/spelldialog.cxx
@@ -200,7 +200,12 @@ void ScSpellDialogChildWindow::Init()
ScEditableTester aTester( mpDoc, rMarkData );
if( !aTester.IsEditable() )
{
- mpViewShell->ErrorMessage( aTester.GetMessageId() );
+ // #i85751# Don't show a ErrorMessage here, because the vcl
+ // parent of the InfoBox is not fully initialized yet.
+ // This leads to problems in the modality behaviour of the
+ // ScSpellDialogChildWindow.
+
+ //mpViewShell->ErrorMessage( aTester.GetMessageId() );
return;
}
}
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index b8656e1e25a0..4938defa437d 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -1169,7 +1169,7 @@ BOOL ScTabView::ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos )
const CommandWheelData* pData = rCEvt.GetWheelData();
if ( pData && pData->GetMode() == COMMAND_WHEEL_ZOOM )
{
- if ( !aViewData.GetViewShell()->GetViewFrame()->GetFrame()->IsInPlace() )
+ if ( !aViewData.GetViewShell()->GetViewFrame()->GetFrame().IsInPlace() )
{
// for ole inplace editing, the scale is defined by the visarea and client size
// and can't be changed directly
@@ -1626,7 +1626,7 @@ void ScTabView::UpdateHeaderWidth( const ScVSplitPos* pWhich, const SCROW* pPosY
return;
SCROW nEndPos = MAXROW;
- if ( !aViewData.GetViewShell()->GetViewFrame()->GetFrame()->IsInPlace() )
+ if ( !aViewData.GetViewShell()->GetViewFrame()->GetFrame().IsInPlace() )
{
// fuer OLE Inplace immer MAXROW
@@ -2455,16 +2455,13 @@ void ScTabView::SetNewVisArea()
SfxViewFrame* pViewFrame = aViewData.GetViewShell()->GetViewFrame();
if (pViewFrame)
{
- SfxFrame* pFrame = pViewFrame->GetFrame();
- if (pFrame)
+ SfxFrame& rFrame = pViewFrame->GetFrame();
+ com::sun::star::uno::Reference<com::sun::star::frame::XController> xController = rFrame.GetController();
+ if (xController.is())
{
- com::sun::star::uno::Reference<com::sun::star::frame::XController> xController = pFrame->GetController();
- if (xController.is())
- {
- ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController );
- if (pImp)
- pImp->VisAreaChanged();
- }
+ ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController );
+ if (pImp)
+ pImp->VisAreaChanged();
}
}
if (aViewData.GetViewShell()->HasAccessibilityObjects())
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index b61c3ade64f4..750e49ec2334 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -367,16 +367,12 @@ void ScTabView::SelectionChanged()
SfxViewFrame* pViewFrame = aViewData.GetViewShell()->GetViewFrame();
if (pViewFrame)
{
- SfxFrame* pFrame = pViewFrame->GetFrame();
- if (pFrame)
+ uno::Reference<frame::XController> xController = pViewFrame->GetFrame().GetController();
+ if (xController.is())
{
- uno::Reference<frame::XController> xController = pFrame->GetController();
- if (xController.is())
- {
- ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController );
- if (pImp)
- pImp->SelectionChanged();
- }
+ ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController );
+ if (pImp)
+ pImp->SelectionChanged();
}
}
@@ -1427,7 +1423,7 @@ void ScTabView::MarkDataArea( BOOL bIncludeCursor )
SCCOL nEndCol = nStartCol;
SCROW nEndRow = nStartRow;
- pDoc->GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, bIncludeCursor );
+ pDoc->GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, bIncludeCursor, false );
HideAllCursors();
DoneBlockMode();
diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx
index 460f31b07175..bc5c94c271e2 100644
--- a/sc/source/ui/view/tabview5.cxx
+++ b/sc/source/ui/view/tabview5.cxx
@@ -334,16 +334,12 @@ void ScTabView::TabChanged()
SfxViewFrame* pViewFrame = aViewData.GetViewShell()->GetViewFrame();
if (pViewFrame)
{
- SfxFrame* pFrame = pViewFrame->GetFrame();
- if (pFrame)
+ uno::Reference<frame::XController> xController = pViewFrame->GetFrame().GetController();
+ if (xController.is())
{
- uno::Reference<frame::XController> xController = pFrame->GetController();
- if (xController.is())
- {
- ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController );
- if (pImp)
- pImp->SheetChanged();
- }
+ ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController );
+ if (pImp)
+ pImp->SheetChanged();
}
}
}
diff --git a/sc/source/ui/view/tabvwsh2.cxx b/sc/source/ui/view/tabvwsh2.cxx
index ab0dae319105..ca47535ad2cf 100644
--- a/sc/source/ui/view/tabvwsh2.cxx
+++ b/sc/source/ui/view/tabvwsh2.cxx
@@ -451,7 +451,7 @@ void ScTabViewShell::GetDrawState(SfxItemSet &rSet)
case SID_DRAW_CHART:
{
- BOOL bOle = GetViewFrame()->GetFrame()->IsInPlace();
+ BOOL bOle = GetViewFrame()->GetFrame().IsInPlace();
if ( bOle || !SvtModuleOptions().IsChart() )
rSet.DisableItem( nWhich );
}
diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx
index 493760d7a6ba..c291d01d71c2 100644
--- a/sc/source/ui/view/tabvwsh3.cxx
+++ b/sc/source/ui/view/tabvwsh3.cxx
@@ -41,7 +41,6 @@
#include <sfx2/dispatch.hxx>
#include <sfx2/passwd.hxx>
#include <sfx2/request.hxx>
-#include <sfx2/topfrm.hxx>
#include <svl/ptitem.hxx>
#include <svl/stritem.hxx>
#include <tools/urlobj.hxx>
@@ -482,7 +481,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
{
if ( pDocSh->GetTitle() == aStrDocName )
{
- pViewFrame = SfxViewFrame::GetFirst( pDocSh, TYPE(SfxTopViewFrame) );
+ pViewFrame = SfxViewFrame::GetFirst( pDocSh );
bFound = ( NULL != pViewFrame );
}
@@ -490,8 +489,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
}
if ( bFound )
- if ( pViewFrame->ISA(SfxTopViewFrame) )
- pViewFrame->GetFrame()->Appear();
+ pViewFrame->GetFrame().Appear();
rReq.Ignore();//XXX wird von SFX erledigt
}
@@ -502,7 +500,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
case SID_PRINTPREVIEW:
{
- if ( !pThisFrame->GetFrame()->IsInPlace() ) // nicht bei OLE
+ if ( !pThisFrame->GetFrame().IsInPlace() ) // nicht bei OLE
{
// print preview is now always in the same frame as the tab view
// -> always switch this frame back to normal view
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index d7a0e2b080b0..ed09ec85ee8c 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -32,7 +32,6 @@
// INCLUDE ---------------------------------------------------------------
-#include <sfx2/topfrm.hxx>
#include "scitems.hxx"
#include <editeng/eeitem.hxx>
@@ -263,7 +262,7 @@ void __EXPORT ScTabViewShell::Deactivate(BOOL bMDI)
DeActivateOlk( GetViewData() );
ActivateView( FALSE, FALSE );
- if ( GetViewFrame()->GetFrame()->IsInPlace() ) // inplace
+ if ( GetViewFrame()->GetFrame().IsInPlace() ) // inplace
GetViewData()->GetDocShell()->UpdateOle(GetViewData(),TRUE);
if ( pHdl )
@@ -291,8 +290,7 @@ void ScTabViewShell::SetActive()
#if 0
SfxViewFrame* pFrame = GetViewFrame();
- if ( pFrame->ISA(SfxTopViewFrame) )
- pFrame->GetFrame()->Appear();
+ pFrame->GetFrame().Appear();
SFX_APP()->SetViewFrame( pFrame ); // immer erst Appear, dann SetViewFrame (#29290#)
#endif
@@ -390,7 +388,7 @@ void __EXPORT ScTabViewShell::AdjustPosSizePixel( const Point &rPos, const Size
void __EXPORT ScTabViewShell::InnerResizePixel( const Point &rOfs, const Size &rSize )
{
Size aNewSize( rSize );
- if ( GetViewFrame()->GetFrame()->IsInPlace() )
+ if ( GetViewFrame()->GetFrame().IsInPlace() )
{
SvBorder aBorder;
GetBorderSize( aBorder, rSize );
@@ -1335,13 +1333,10 @@ ScTabViewObj* lcl_GetViewObj( ScTabViewShell& rShell )
SfxViewFrame* pViewFrame = rShell.GetViewFrame();
if (pViewFrame)
{
- SfxFrame* pFrame = pViewFrame->GetFrame();
- if (pFrame)
- {
- uno::Reference<frame::XController> xController = pFrame->GetController();
- if (xController.is())
- pRet = ScTabViewObj::getImplementation( xController );
- }
+ SfxFrame& rFrame = pViewFrame->GetFrame();
+ uno::Reference<frame::XController> xController = rFrame.GetController();
+ if (xController.is())
+ pRet = ScTabViewObj::getImplementation( xController );
}
return pRet;
}
@@ -1382,8 +1377,7 @@ void ScTabViewShell::StartSimpleRefDialog(
// Then the view has to be activated first, the same way as in Execute for SID_CURRENTDOC.
// Can't use GrabFocus here, because it needs to take effect immediately.
- if ( pViewFrm->ISA(SfxTopViewFrame) )
- pViewFrm->GetFrame()->Appear();
+ pViewFrm->GetFrame().Appear();
}
USHORT nId = ScSimpleRefDlgWrapper::GetChildWindowId();
@@ -1525,7 +1519,7 @@ BOOL ScTabViewShell::TabKeyInput(const KeyEvent& rKEvt)
// container app and are executed during Window::KeyInput.
// -> don't pass keys to input handler that would be used there
// but should call slots instead.
- BOOL bParent = ( GetViewFrame()->GetFrame()->IsInPlace() && eFunc != KEYFUNC_DONTKNOW );
+ BOOL bParent = ( GetViewFrame()->GetFrame().IsInPlace() && eFunc != KEYFUNC_DONTKNOW );
if( !bUsed && !bDraw && nCode != KEY_RETURN && !bParent )
bUsed = pScMod->InputKeyEvent( rKEvt, TRUE ); // Eingabe
@@ -1645,8 +1639,6 @@ FASTBOOL __EXPORT ScTabViewShell::KeyInput( const KeyEvent &rKeyEvent )
//------------------------------------------------------------------
-// SfxViewShell( pViewFrame, SFX_VIEW_MAXIMIZE_FIRST | SFX_VIEW_DISABLE_ACCELS ),
-
#define __INIT_ScTabViewShell \
eCurOST(OST_NONE), \
nDrawSfxId(0), \
@@ -1736,7 +1728,7 @@ void ScTabViewShell::Construct( BYTE nForceDesignMode )
// show the right cells
GetViewData()->SetScreenPos( bNegativePage ? aVisArea.TopRight() : aVisArea.TopLeft() );
- if ( GetViewFrame()->GetFrame()->IsInPlace() ) // inplace
+ if ( GetViewFrame()->GetFrame().IsInPlace() ) // inplace
{
pDocSh->SetInplace( TRUE ); // schon so initialisiert
if (pDoc->IsEmbedded())
@@ -1876,7 +1868,7 @@ void ScTabViewShell::Construct( BYTE nForceDesignMode )
// #105575#; update only in the first creation of the ViewShell
pDocSh->SetUpdateEnabled(FALSE);
- if ( GetViewFrame()->GetFrame()->IsInPlace() )
+ if ( GetViewFrame()->GetFrame().IsInPlace() )
UpdateHeaderWidth(); // The implace activation requires headers to be calculated
SvBorder aBorder;
@@ -1898,7 +1890,7 @@ void ScTabViewShell::Construct( BYTE nForceDesignMode )
//UNUSED2008-05
//UNUSED2008-05 UpdatePageBreakData();
//UNUSED2008-05
-//UNUSED2008-05 /*uno::Reference<frame::XFrame> xFrame = pViewFrame->GetFrame()->GetFrameInterface();
+//UNUSED2008-05 /*uno::Reference<frame::XFrame> xFrame = pViewFrame->GetFrame().GetFrameInterface();
//UNUSED2008-05 if (xFrame.is())
//UNUSED2008-05 xFrame->setComponent( uno::Reference<awt::XWindow>(), new ScTabViewObj( this ) );*/
//UNUSED2008-05 // make Controller known to SFX
@@ -1914,7 +1906,7 @@ void ScTabViewShell::Construct( BYTE nForceDesignMode )
ScTabViewShell::ScTabViewShell( SfxViewFrame* pViewFrame,
SfxViewShell* pOldSh ) :
- SfxViewShell( pViewFrame, SFX_VIEW_MAXIMIZE_FIRST | SFX_VIEW_CAN_PRINT | SFX_VIEW_HAS_PRINTOPTIONS ),
+ SfxViewShell( pViewFrame, SFX_VIEW_CAN_PRINT | SFX_VIEW_HAS_PRINTOPTIONS ),
ScDBFunc( &pViewFrame->GetWindow(), (ScDocShell&)*pViewFrame->GetObjectShell(), this ),
__INIT_ScTabViewShell
{
@@ -1950,7 +1942,7 @@ ScTabViewShell::ScTabViewShell( SfxViewFrame* pViewFrame,
SetZoomType( rAppOpt.GetZoomType(), TRUE );
}
- /*uno::Reference<frame::XFrame> xFrame = pViewFrame->GetFrame()->GetFrameInterface();
+ /*uno::Reference<frame::XFrame> xFrame = pViewFrame->GetFrame().GetFrameInterface();
if (xFrame.is())
xFrame->setComponent( uno::Reference<awt::XWindow>(), new ScTabViewObj( this ) );*/
// make Controller known to SFX
diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx
index 5940b2a3b950..7734f3e24ff8 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -174,7 +174,7 @@ void __EXPORT ScTabViewShell::GetState( SfxItemSet& rSet )
USHORT nMyId = 0;
SfxViewFrame* pThisFrame = GetViewFrame();
- BOOL bOle = GetViewFrame()->GetFrame()->IsInPlace();
+ BOOL bOle = GetViewFrame()->GetFrame().IsInPlace();
SCTAB nTabCount = pDoc->GetTableCount();
SCTAB nTabSelCount = rMark.GetSelectCount();
diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx
index 5e69e5c9bf99..8f4a203ea14d 100644
--- a/sc/source/ui/view/tabvwshb.cxx
+++ b/sc/source/ui/view/tabvwshb.cxx
@@ -432,7 +432,7 @@ void ScTabViewShell::ExecDrawIns(SfxRequest& rReq)
void ScTabViewShell::GetDrawInsState(SfxItemSet &rSet)
{
- BOOL bOle = GetViewFrame()->GetFrame()->IsInPlace();
+ BOOL bOle = GetViewFrame()->GetFrame().IsInPlace();
BOOL bTabProt = GetViewData()->GetDocument()->IsTabProtected(GetViewData()->GetTabNo());
ScDocShell* pDocShell = ( GetViewData() ? GetViewData()->GetDocShell() : NULL );
bool bShared = ( pDocShell ? pDocShell->IsDocShared() : false );
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index 74a824a709d6..7d1cbb05761b 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -175,7 +175,7 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog(
SCITEM_QUERYDATA,
SCITEM_QUERYDATA );
- ScDBData* pDBData = GetDBData();
+ ScDBData* pDBData = GetDBData( TRUE, SC_DB_MAKE, SC_DBSEL_ROW_DOWN);
pDBData->GetQueryParam( aQueryParam );
ScQueryItem aItem( SCITEM_QUERYDATA, GetViewData(), &aQueryParam );
@@ -200,7 +200,7 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog(
SCITEM_QUERYDATA,
SCITEM_QUERYDATA );
- ScDBData* pDBData = GetDBData();
+ ScDBData* pDBData = GetDBData( TRUE, SC_DB_MAKE, SC_DBSEL_ROW_DOWN);
pDBData->GetQueryParam( aQueryParam );
aArgSet.Put( ScQueryItem( SCITEM_QUERYDATA,
diff --git a/sc/source/ui/view/tabvwshd.cxx b/sc/source/ui/view/tabvwshd.cxx
index 6074d03a67aa..4ef5186a25a0 100644
--- a/sc/source/ui/view/tabvwshd.cxx
+++ b/sc/source/ui/view/tabvwshd.cxx
@@ -40,7 +40,7 @@
#include <sfx2/childwin.hxx>
#include <sfx2/request.hxx>
-#include <sfx2/topfrm.hxx>
+#include <sfx2/viewfrm.hxx>
#include <vcl/svapp.hxx>
#include <vcl/wrkwin.hxx>
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 5afa6b0d0190..7c748f50dfc0 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -85,8 +85,10 @@
#include "inputwin.hxx"
#include "funcdesc.hxx"
#include "docuno.hxx"
+#include "charthelper.hxx"
#include "tabbgcolor.hxx"
+
// STATIC DATA ---------------------------------------------------------------
@@ -2822,6 +2824,10 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy )
nNewTab--;
SetTabNo( nNewTab, TRUE );
+
+ //#i29848# adjust references to data on the copied sheet
+ if( bCopy )
+ ScChartHelper::AdjustRangesOfChartsOnDestinationPage( pDoc, pDestDoc, nTab, nNewTab );
}
}
diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx
index 794ee488afed..9697cae3a57e 100644
--- a/sc/source/ui/view/viewfun5.cxx
+++ b/sc/source/ui/view/viewfun5.cxx
@@ -387,7 +387,7 @@ BOOL ScViewFunc::PasteDataFormat( ULONG nFormatId,
// Creation of database area "Import1" isn't here, but in the DocShell
// slot execute, so it can be added to the undo action
- ScDBData* pDBData = pDocSh->GetDBData( ScRange(nPosX,nPosY,nTab), SC_DB_OLD, FALSE );
+ ScDBData* pDBData = pDocSh->GetDBData( ScRange(nPosX,nPosY,nTab), SC_DB_OLD, SC_DBSEL_KEEP );
String sTarget;
if (pDBData)
sTarget = pDBData->GetName();
diff --git a/sc/source/ui/view/viewutil.cxx b/sc/source/ui/view/viewutil.cxx
index c348b843cfdc..f73346398ea1 100644
--- a/sc/source/ui/view/viewutil.cxx
+++ b/sc/source/ui/view/viewutil.cxx
@@ -370,7 +370,7 @@ BOOL ScViewUtil::ExecuteCharMap( const SvxFontItem& rOldFont,
SfxAllItemSet aSet( rFrame.GetObjectShell()->GetPool() );
aSet.Put( SfxBoolItem( FN_PARAM_1, FALSE ) );
aSet.Put( SvxFontItem( rOldFont.GetFamily(), rOldFont.GetFamilyName(), rOldFont.GetStyleName(), rOldFont.GetPitch(), rOldFont.GetCharSet(), aSet.GetPool()->GetWhich( SID_ATTR_CHAR_FONT ) ) );
- SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( &rFrame.GetWindow(), aSet, rFrame.GetFrame()->GetFrameInterface(), RID_SVXDLG_CHARMAP );
+ SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( &rFrame.GetWindow(), aSet, rFrame.GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP );
if ( pDlg->Execute() == RET_OK )
{
SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pItem, SfxStringItem, SID_CHARMAP, FALSE );
diff --git a/sc/util/hidother.src b/sc/util/hidother.src
index 48dfebdf5c2c..ffdb5c329399 100644
--- a/sc/util/hidother.src
+++ b/sc/util/hidother.src
@@ -81,6 +81,7 @@ hidspecial HID_SC_APPEND_NAME { HelpID = HID_SC_APPEND_NAME; };
hidspecial HID_SC_AUTOFMT_NAME { HelpID = HID_SC_AUTOFMT_NAME; };
hidspecial HID_SC_ADD_AUTOFMT { HelpID = HID_SC_ADD_AUTOFMT; };
hidspecial HID_SC_REN_AFMT_NAME { HelpID = HID_SC_REN_AFMT_NAME; };
+hidspecial HID_SC_REN_AFMT_DLG { HelpID = HID_SC_REN_AFMT_DLG; };
hidspecial HID_SC_RENAME_AUTOFMT { HelpID = HID_SC_RENAME_AUTOFMT; };
hidspecial HID_PASSWD_TABLE { HelpID = HID_PASSWD_TABLE; };
hidspecial HID_PASSWD_DOC { HelpID = HID_PASSWD_DOC; };
diff --git a/sc/util/makefile.mk b/sc/util/makefile.mk
index a056334254a9..aa6f0a6bcce2 100644
--- a/sc/util/makefile.mk
+++ b/sc/util/makefile.mk
@@ -139,7 +139,7 @@ LIB4FILES= \
SHL2TARGET= scd$(DLLPOSTFIX)
SHL2IMPLIB= scdimp
-SHL2VERSIONMAP= scd.map
+SHL2VERSIONMAP=$(SOLARENV)/src/component.map
SHL2DEF=$(MISC)$/$(SHL2TARGET).def
DEF2NAME= $(SHL2TARGET)
@@ -278,6 +278,7 @@ LIB8OBJFILES = \
$(SLO)$/dapidata.obj \
$(SLO)$/crdlg.obj \
$(SLO)$/scuiasciiopt.obj \
+ $(SLO)$/textimportoptions.obj \
$(SLO)$/scuiautofmt.obj \
$(SLO)$/dpgroupdlg.obj \
$(SLO)$/editfield.obj
@@ -288,7 +289,7 @@ TARGET_VBA=vbaobj
SHL9TARGET=$(TARGET_VBA)$(DLLPOSTFIX).uno
SHL9IMPLIB= i$(TARGET_VBA)
-SHL9VERSIONMAP=$(TARGET_VBA).map
+SHL9VERSIONMAP=$(SOLARENV)/src/component.map
SHL9DEF=$(MISC)$/$(SHL9TARGET).def
DEF9NAME=$(SHL9TARGET)
.IF "$(VBA_EXTENSION)"=="YES"
diff --git a/sc/util/sc.map b/sc/util/sc.map
deleted file mode 100644
index bfd1401a7685..000000000000
--- a/sc/util/sc.map
+++ /dev/null
@@ -1,8 +0,0 @@
-SC_1_0 {
- global:
- component_getImplementationEnvironment;
- component_writeInfo;
- component_getFactory;
- local:
- *;
-};
diff --git a/sc/util/scd.map b/sc/util/scd.map
deleted file mode 100644
index bfd1401a7685..000000000000
--- a/sc/util/scd.map
+++ /dev/null
@@ -1,8 +0,0 @@
-SC_1_0 {
- global:
- component_getImplementationEnvironment;
- component_writeInfo;
- component_getFactory;
- local:
- *;
-};
diff --git a/sc/util/scfilt.map b/sc/util/scfilt.map
index 589736f24eb1..642b8db15088 100644
--- a/sc/util/scfilt.map
+++ b/sc/util/scfilt.map
@@ -1,4 +1,4 @@
-SCFILT_1_0 {
+UDK_3_0_0 {
global:
ScFilterCreate;
local:
diff --git a/sc/util/scui.map b/sc/util/scui.map
index f40bd255fe1d..ad5e33836c7c 100644
--- a/sc/util/scui.map
+++ b/sc/util/scui.map
@@ -1,4 +1,4 @@
-SWUI_1_0 {
+UDK_3_0_0 {
global:
CreateDialogFactory;
local:
diff --git a/sc/util/vbaobj.map b/sc/util/vbaobj.map
deleted file mode 100644
index 737cddbfe3df..000000000000
--- a/sc/util/vbaobj.map
+++ /dev/null
@@ -1,9 +0,0 @@
-OOO_1.1 {
- global:
- component_getImplementationEnvironment;
- component_getFactory;
- component_writeInfo;
-
- local:
- *;
-};
diff --git a/scaddins/source/analysis/exports.map b/scaddins/source/analysis/exports.map
deleted file mode 100644
index 50dda088ac94..000000000000
--- a/scaddins/source/analysis/exports.map
+++ /dev/null
@@ -1,10 +0,0 @@
-SC_1_0 {
- global:
- component_getImplementationEnvironment;
- component_writeInfo;
- component_getFactory;
-
- local:
- *;
-};
-
diff --git a/scaddins/source/analysis/makefile.mk b/scaddins/source/analysis/makefile.mk
index c476b1b32d72..d837d644dc21 100644
--- a/scaddins/source/analysis/makefile.mk
+++ b/scaddins/source/analysis/makefile.mk
@@ -109,7 +109,7 @@ SHL1STDLIBS= \
SHL1DEPN=makefile.mk
-SHL1VERSIONMAP=exports.map
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
SHL1DEF=$(MISC)$/$(SHL1TARGET).def
DEF1NAME=$(SHL1TARGET)
diff --git a/scaddins/source/datefunc/exports.map b/scaddins/source/datefunc/exports.map
deleted file mode 100644
index 50dda088ac94..000000000000
--- a/scaddins/source/datefunc/exports.map
+++ /dev/null
@@ -1,10 +0,0 @@
-SC_1_0 {
- global:
- component_getImplementationEnvironment;
- component_writeInfo;
- component_getFactory;
-
- local:
- *;
-};
-
diff --git a/scaddins/source/datefunc/makefile.mk b/scaddins/source/datefunc/makefile.mk
index 5dd90bae6a4f..8a2805d76f7d 100644
--- a/scaddins/source/datefunc/makefile.mk
+++ b/scaddins/source/datefunc/makefile.mk
@@ -96,7 +96,7 @@ SHL1STDLIBS= \
SHL1DEPN=makefile.mk
-SHL1VERSIONMAP=exports.map
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
SHL1DEF=$(MISC)$/$(SHL1TARGET).def
DEF1NAME=$(SHL1TARGET)
diff --git a/sccomp/source/solver/exports.map b/sccomp/source/solver/exports.map
deleted file mode 100644
index fe0280ec6c21..000000000000
--- a/sccomp/source/solver/exports.map
+++ /dev/null
@@ -1,9 +0,0 @@
-SOLVER_1_0 {
- global:
- component_getImplementationEnvironment;
- component_getFactory;
- component_writeInfo;
-
- local:
- *;
-};
diff --git a/sccomp/source/solver/makefile.mk b/sccomp/source/solver/makefile.mk
index fc186ad61c1a..6b25f60c8762 100644
--- a/sccomp/source/solver/makefile.mk
+++ b/sccomp/source/solver/makefile.mk
@@ -60,7 +60,7 @@ SHL1STDLIBS= $(COMPHELPERLIB) \
SHL1DEPN= makefile.mk
SHL1DEF= $(MISC)$/$(SHL1TARGET).def
-SHL1VERSIONMAP= exports.map
+SHL1VERSIONMAP= $(SOLARENV)/src/component.map
DEF1NAME= $(SHL1TARGET)
# --- Resources --------------------------------