Issue 63893 - Chart Data is reset after Sheet Deletion
Summary: Chart Data is reset after Sheet Deletion
Status: CLOSED NOT_AN_OOO_ISSUE
Alias: None
Product: General
Classification: Code
Component: chart (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: All All
: P3 Trivial (vote)
Target Milestone: ---
Assignee: kla
QA Contact: issues@graphics
URL:
Keywords: oooqa
Depends on:
Blocks:
 
Reported: 2006-04-01 21:01 UTC by chrisk1
Modified: 2013-02-24 21:19 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description chrisk1 2006-04-01 21:01:10 UTC
If I run the following code in OOo 2.0 Calc a chart is created but after the
Delete Sheet macro is run the chart no longer has data displayed. It also occurs
if the ThisComponent.Sheets.removeByName("Sheet1") line is just added to the
RunPC macro. It seems the data range of the chart is changed to Cell A1. Thank you
                  Chris

Sub RunPC
Dim DataArray(4,0)
dim DataLabelsArray(4)

DataArray(0,0)=5000
DataArray(1,0)=4000
DataArray(2,0)=3000
DataArray(3,0)=2000
DataArray(4,0)=1000

DataLabelsArray(0) = "First"
DataLabelsArray(1) = "Second"
DataLabelsArray(2) = "Third"
DataLabelsArray(3) = "Fourth"
DataLabelsArray(4) = "Fifth"

PieChart(DataArray(), DataLabelsArray(), "Chart1", "Sheet1", 0)
DeleteSheet("Sheet2")
End Sub 

Sub PieChart(ChartDataArray(), LabelsArray(), CName as String, _
     CSheet as String, Optional YPos as Integer)
' DataArray is an array of data values
' DataArrayLabels is the set of labels for each value
' CName is Chart Name and its Title
' CSheet is the Sheet to use for the chart
' YPos is the Y Position of the diagram
' (or Y value of the rectangle shape)
' http://docs.sun.com/app/docs/doc/819-0439
' http://www.oooforum.org/forum/viewtopic.phtml?t=4996, =6297,
'   =11920, =33640, =29391, =31620, =5328
' http://api.openoffice.org/docs/common/ref/com/sun/star/chart/
'   ChartDataCaption.html
' Dims
 Dim Length as Integer
 Dim oSheet, oCharts, oChart
 Dim oRect as new com.sun.star.awt.Rectangle
' Sets
 oSheet = ThisComponent.getSheets().getByName(CSheet)
 oCharts = ThisComponent.getSheets().getByName(CSheet).Charts
 If IsMissing(ChartNum) Then ChartNum=0
 With oRect
     .X = 0  : .Y = YPos  : .Width = 15000 : .Height = 10000
 End With
' Remove the CName chart if it exists
 If oSheet.getCharts().hasByName(CName) Then _
    oSheet.getCharts().removeByName(CName)
' Make the Data Array N x 0 for use by oChart.createInstance
 Length = UBound(ChartDataArray) - LBound(ChartDataArray)
 Dim DataArray(Length,0)
 For I = 0 to Length
 DataArray(I,0)=ChartDataArray(I)
 Next I
' Make Chart
 oCharts.addNewByName(CName,oRect,Array(),TRUE, TRUE)
 oChart = oCharts.getByName(CName).embeddedObject
 oChart.diagram = oChart.createInstance _
     ("com.sun.star.chart.PieDiagram")
 oChart.lockControllers()
' Data
 oChart.Data.setData(DataArray())
 oChart.Data.setRowDescriptions(LabelsArray())
' Title
 oChart.HasMainTitle=True
 oChart.Title.string = CName
' Labels
 oChart.DataSourceLabelsInFirstColumn = false
 oChart.DataSourceLabelsInFirstRow=true
' Legend
 oSheet.getCharts.getByName(CName).getEmbeddedObject. _
     hasLegend = False
' Percentages
'     Last DrawPage is oSheet.getDrawPage().getCount()-1
 oSheet.drawpage.getByIndex(oSheet.getDrawPage().getCount()-1). _
     model.diagram.setPropertyValue("DataCaption",6)
     'PERCENT = 2 and TEXT = 4
 oChart.unlockControllers()
End Sub

Sub DeleteSheet(SName as string)
 If ThisComponent.Sheets.hasByName(SName) Then _
     ThisComponent.Sheets.removeByName(SName)
End Sub
Comment 1 chrisk1 2006-04-01 21:06:41 UTC
Please delete Issue 63893. A mistake on my part.
Comment 2 lars 2006-04-02 12:38:42 UTC
I cannot delete it but set it as duplicate

*** This issue has been marked as a duplicate of 63892 ***
Comment 3 lars 2006-04-02 12:39:36 UTC
closing duplicate
Comment 4 Rainer Bielefeld 2007-01-08 07:45:49 UTC
Invalid
Comment 5 Rainer Bielefeld 2007-01-08 07:46:22 UTC
Invalid, not DUP
Comment 6 Rainer Bielefeld 2007-01-08 07:46:34 UTC
.