Hello,
I want to create an diagram in writer with several data from a database. I have looked on http://wiki.services.openoffice.org/wik ... readsheets, and now I'm trying to insert an diagram in writer. I have found some source-code on http://hermione.s41.xrea.com/pukiwiki/i ... r%2FCharts - does anybody know the several CLSID for changing the chart-type? Or is there som easier way to make a chart in writerv with dynamic data?
Kind regards
Thomas
[Solved] Insert a Chart in Writer
[Solved] Insert a Chart in Writer
Last edited by tbuecki on Wed Aug 15, 2012 3:52 pm, edited 1 time in total.
OpenOffice 3.4 on Windows 7
- Hagar Delest
- Moderator
- Posts: 33701
- Joined: Sun Oct 07, 2007 9:07 pm
- Location: France
Re: Insert a Chart in Writer
Old post, moved from Writer to Macro forum.
LibreOffice 25.2 on Linux Mint Debian Edition (LMDE 7 Gigi) and 25.2 portable on Windows 11.
- Charlie Young
- Volunteer
- Posts: 1559
- Joined: Fri May 14, 2010 1:07 am
Re: Insert a Chart in Writer
It is not a matter of changing the CLSID; the one specified is for all such embedded charts. The chart type is changed by changing the chart diagram type in the program. The TextEmbedded Object inserted by the program in Thomas' example is the stock bar chart one gets by using Insert > Object > Chart, which the program then modifies by changing the DataArray and such, and many, many, other properties can be changed as well.tbuecki wrote:Hello,
I want to create an diagram in writer with several data from a database. I have looked on http://wiki.services.openoffice.org/wik ... readsheets, and now I'm trying to insert an diagram in writer. I have found some source-code on http://hermione.s41.xrea.com/pukiwiki/i ... r%2FCharts - does anybody know the several CLSID for changing the chart-type? Or is there som easier way to make a chart in writerv with dynamic data?
Kind regards
Thomas
I happened to be working on a modification to my latest post in this thread when this message was posted. In that example, I was using XTableCharts.addNewByName(), and I was not happy with that for various reasons. A better approach for a chart using a ChartDataArray instead of CellRanges is to use an OLE2Shape in Calc, and the TextEmbeddedObject in Writer.
I have a rather lengthy example written in JavaScript for inserting a chart in writer, but I'll refrain from posting it just now. It uses the same chart stuff specified by a dialog as I do in the other thread, and may not be quite appropriate here without some modifications.
Apache OpenOffice 4.1.1
Windows XP
Windows XP
Re: Insert a Chart in Writer
Hello Charlie,
great, it works fine in a ods-Document. When I try to implement this in writer beginning with:
I got a "Unknown property", athoug a
shows "Model object <error> read-only, may be void "
I will try to implement this in writer, if I have a result, I post it. Have you an idea, whats wrong?
Kind regards
Thomas
great, it works fine in a ods-Document. When I try to implement this in writer beginning with:
Code: Select all
sub Test
Dim objDoc as Object
Dim objDiagramme, oEmbeded as Object
Dim objDiaFlaeche as New com.sun.star.awt.Rectangle
objDoc = ThisComponent
oEmbeded = objDoc.createInstance("com.sun.star.text.TextEmbeddedObject")
oEmbeded.setPropertyValue("CLSID","12DCAE26-281F-416F-a234-c3086127382e")
Xray oEmbeded.Model
exit subCode: Select all
Xray oEmbededI will try to implement this in writer, if I have a result, I post it. Have you an idea, whats wrong?
Kind regards
Thomas
OpenOffice 3.4 on Windows 7
- Charlie Young
- Volunteer
- Posts: 1559
- Joined: Fri May 14, 2010 1:07 am
Re: Insert a Chart in Writer
The Model, and also the EmbeddedObject properties (which is effectively the same thing), are not created until the object is inserted with Text.insertTextContent. The only thing I do to the object before so inserting it (other than assign the CLSID), is give it a size and a name, neither of which is strictly necessary, but generally you'll want control of these things.tbuecki wrote:Hello Charlie,
great, it works fine in a ods-Document. When I try to implement this in writer beginning with:
I got a "Unknown property", athoug aCode: Select all
sub Test Dim objDoc as Object Dim objDiagramme, oEmbeded as Object Dim objDiaFlaeche as New com.sun.star.awt.Rectangle objDoc = ThisComponent oEmbeded = objDoc.createInstance("com.sun.star.text.TextEmbeddedObject") oEmbeded.setPropertyValue("CLSID","12DCAE26-281F-416F-a234-c3086127382e") Xray oEmbeded.Model exit sub
shows "Model object <error> read-only, may be void "Code: Select all
Xray oEmbeded
I will try to implement this in writer, if I have a result, I post it. Have you an idea, whats wrong?
Kind regards
Thomas
Code: Select all
oText = ThisComponent.getText()
oEmbeded.setSize(....)
oEmbeded.setName(".........")
oText.insertTextContent(oText.getEnd(),oEmbeded,True)
Apache OpenOffice 4.1.1
Windows XP
Windows XP