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

StarBasic: Change all line widths in xy diagrams

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets
View previous topic :: View next topic  
Author Message
swingkyd
OOo Advocate
OOo Advocate


Joined: 15 Sep 2004
Posts: 479

PostPosted: Thu Mar 06, 2008 4:12 pm    Post subject: StarBasic: Change all line widths in xy diagrams Reply with quote

The following code is a starting point for changing the line widths of all lines in an x-y diagram in OO.org using StarBasic:
Code:
Sub IncreaseXYChartLineWidths
  Dim oDoc As Object
  Dim oCharts As Object
  Dim oChart As Object
  Dim oDiagram As Object
  Dim oLineW As New com.sun.star.beans.PropertyValue
  Dim oDataRowProps As Object
  Dim oData As Variant
  Dim nCols As Long
  Dim nRows As Long
  Dim nIdx As Long
  Const nNewWidth = 60      ' new width in 1/100ths of a mm
  oDoc = StarDesktop.CurrentComponent
  oCharts = oDoc.currentController.ActiveSheet.Charts
  For i = 0 to (oCharts.Count - 1)
    oChart = oCharts.getByIndex(i).EmbeddedObject
    oData = oChart.Data.Data
    nRows = uBound(oData,1)
    nCols = Ubound(oData(0),1)
    if nRows < nCols then
      nIdx = nRows
    else
      nIdx = nCols
    end if
    oDiagram = oChart.Diagram
    for j = 1 to (nIdx)
       oDataRowProps = oDiagram.getDataRowProperties(j)
       oDataRowProps.LineWidth = nNewWidth
    next
  next
end sub

This code can be run from the macro "run" dialog...
it's not very smart and may not work for you (should be an xy diagram)....but I thought I would share it anyway if anyone wants to improve it...feel free!
It needs improvement on the following:

  • User enters width in any units
  • Catch calling from wrong document
  • Catch calling on non-xy diagrams
  • Assumes the series are ALWAYS less than the rows...


The assumption about the series is a serious flaw...it was a "hack" to "get the job done"... if anyone can figure out how to determine a better way of getting the number of series...feel free to modify and post here. I may post a question in the StarBasic programming program.
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 Code Snippets 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