Difference between revisions of "Chart2/ChangeTitleFormattingForAllChartsInACalc"
From Apache OpenOffice Wiki
< Chart2
Line 11: | Line 11: | ||
changeAllChartsInCalc() | changeAllChartsInCalc() | ||
End Sub | End Sub | ||
− | + | ||
sub changeAllChartsInCalc() | sub changeAllChartsInCalc() | ||
'iterate over all charts in a calc document | 'iterate over all charts in a calc document | ||
Line 32: | Line 32: | ||
wend | wend | ||
end sub | end sub | ||
− | + | ||
sub changeOneChart( oChartModel as object ) | sub changeOneChart( oChartModel as object ) | ||
'prevent change notifications to optimize performance | 'prevent change notifications to optimize performance |
Revision as of 12:20, 25 February 2008
Description: | Iterate over all charts in a spreadsheet document, insert a title and do some formatting at the title. | Programming Language: | StarBasic | Author: | Ingrid Halama, 2008 |
[starbasic]
Sub Main changeAllChartsInCalc() End Sub sub changeAllChartsInCalc() 'iterate over all charts in a calc document dim oSheet as object dim oCharts as object SheetCount=ThisComponent.Sheets.getCount SheetNo=0 while( SheetNo<SheetCount ) oSheet=ThisComponent.Sheets(SheetNo) oCharts=oSheet.Charts ChartCount=oCharts.getCount ChartNo=0 while(ChartNo<ChartCount) dim oChartModel as object oChartModel = oCharts(ChartNo).EmbeddedObject changeOneChart( oChartModel ) ChartNo=ChartNo+1 wend SheetNo=SheetNo+1 wend end sub sub changeOneChart( oChartModel as object ) 'prevent change notifications to optimize performance oChartModel.lockControllers ' insert a main title and set some properties oChartModel.HasMainTitle = True oChartModel.Title.String = "Example Title" 'modify font and size oChartModel.Title.CharFontName = "Times New Roman" oChartModel.Title.CharHeight = 14 'modify color 'light gray 20% for the text for example oChartModel.Title.CharColor = 13421772 'some blue color 'chart12' for the backround oChartModel.Title.FillStyle = com.sun.star.drawing.FillStyle.SOLID oChartModel.Title.FillColor = 34001 'add thin black lines around oChartModel.Title.LineStyle = com.sun.star.drawing.LineStyle.SOLID oChartModel.Title.LineColor = 0 'allow change notifications again thus the chart view gets updated when necessary oChartModel.unlockControllers end sub