OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

How to copy a calc chart to writer

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Tiksu
General User
General User


Joined: 31 Dec 2010
Posts: 48

PostPosted: Sun Apr 03, 2011 2:12 am    Post subject: How to copy a calc chart to writer Reply with quote

I'm new to the writer interface and i'd need to copy several charts from my calc sheet to a wrtiter document. if i have an object variable that references to a chart, how can i put the chart in a writer document.

Tiksu
Back to top
View user's profile Send private message
jrkrideau
Super User
Super User


Joined: 08 Aug 2005
Posts: 6732
Location: Kingston ON Canada

PostPosted: Sun Apr 03, 2011 3:54 am    Post subject: Re: How to copy a calc chart to writer Reply with quote

Tiksu wrote:
I'm new to the writer interface and i'd need to copy several charts from my calc sheet to a wrtiter document. if i have an object variable that references to a chart, how can i put the chart in a writer document.

Tiksu


Copy and paste. Or am I misunderstanding the question?
_________________
jrkrideau
Kingston ON Canada
Currently using Windows 7 & OOo 3.4.0 and Ubuntu 12.04 & LibreOffice 3.5.2.2
Back to top
View user's profile Send private message
Tiksu
General User
General User


Joined: 31 Dec 2010
Posts: 48

PostPosted: Sun Apr 03, 2011 4:49 am    Post subject: Re: How to copy a calc chart to writer Reply with quote

jrkrideau wrote:
Tiksu wrote:
I'm new to the writer interface and i'd need to copy several charts from my calc sheet to a wrtiter document. if i have an object variable that references to a chart, how can i put the chart in a writer document.

Tiksu


Copy and paste. Or am I misunderstanding the question?


Thank you for the posting.

In more detail, my problem can be seen in the following snippet that creates a chart oChart. Then, i would need to copy the chart to a writer document, which should be created if it is not existing.

From my point of view, the issue can be seen in two parts, how do i instruct my macro to create a writer document and how do i make my macro copy paste the chart to the created writer sheet?

Code:

Sub make_a_chart() 
   dim oDoc as object
   dim oCurrentSheet as object
   Dim oData as Object
   Dim oDataArray2(2, 2) as variant
   dim oSheetName as string
   dim oRegion(3, 3)
   oDoc = ThisComponent
   oCurrentSheet = oDoc.CurrentController.ActiveSheet
   oCharts = oCurrentSheet.Charts
   oSheetName = ThisComponent.getCurrentController.getActiveSheet.getName()


   oDataArray2(0,0) = 1:  oDataArray2(0,1) = 3: oDataArray2(0,2) = 4
   oDataArray2(1,0) = 2:  oDataArray2(1,1) = 5: oDataArray2(1,2) = 7
   oDataArray2(2,0) = 3:  oDataArray2(2,1) = 4: oDataArray2(2,2) = 5:
   
   Dim aRect as new com.sun.star.awt.Rectangle   
    with aRect
       .X = 5000 : .Y = 5000 : .Width = 15000 : .Height = 8000
    end with   
   
   oCharts.addNewByName(oSheetName, aRect, Array(), False, True)
   oChart = oCharts.getByName(oSheetName).EmbeddedObject
   oDiagram = oChart.createInstance("com.sun.star.chart.XYDiagram") 
   oChart.setDiagram( oDiagram ) 
   oChart.Diagram.DataRowSource = com.sun.star.chart.ChartDataRowSource.COLUMNS
   oData = oChart.Data
   oData.setData(oDataArray2)
End sub



Tiksu
Back to top
View user's profile Send private message
jrkrideau
Super User
Super User


Joined: 08 Aug 2005
Posts: 6732
Location: Kingston ON Canada

PostPosted: Sun Apr 03, 2011 5:59 am    Post subject: Reply with quote

Ah, beyond my skills. I think you really should move this question to the macros and apps forum.
_________________
jrkrideau
Kingston ON Canada
Currently using Windows 7 & OOo 3.4.0 and Ubuntu 12.04 & LibreOffice 3.5.2.2
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group