swingkyd OOo Advocate

Joined: 15 Sep 2004 Posts: 479
|
Posted: Thu Mar 06, 2008 4:12 pm Post subject: StarBasic: Change all line widths in xy diagrams |
|
|
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. |
|