To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=63893
                  Issue #:|63893
                  Summary:|Chart Data is reset after Sheet Deletion
                Component:|Chart
                  Version:|1.0.0
                 Platform:|All
                      URL:|
               OS/Version:|All
                   Status:|UNCONFIRMED
        Status whiteboard:|
                 Keywords:|
               Resolution:|
               Issue type:|DEFECT
                 Priority:|P3
             Subcomponent:|code
              Assigned to:|kla
              Reported by:|chrisk1





------- Additional comments from [EMAIL PROTECTED] Sat Apr  1 13:01:10 -0800 
2006 -------
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

---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to