Difference between revisions of "Chart2/GetPositionOfAChart"
From Apache OpenOffice Wiki
< Chart2
m |
|||
Line 4: | Line 4: | ||
| Programming Language: || StarBasic | | Programming Language: || StarBasic | ||
|+ | |+ | ||
− | | Author: | | + | | Author: || Ingrid Halama, 2010 |
|} | |} | ||
− | < | + | <syntaxhighlight lang="oobas"> |
Sub Main | Sub Main | ||
Dim oTableChart as Object | Dim oTableChart as Object | ||
Line 48: | Line 48: | ||
wend | wend | ||
end function | end function | ||
− | </ | + | </syntaxhighlight> |
[[Category:API]] | [[Category:API]] | ||
[[Category:Samples]] | [[Category:Samples]] | ||
[[Category:StarBasic]] | [[Category:StarBasic]] | ||
[[Category:Chart]] | [[Category:Chart]] |
Latest revision as of 17:10, 30 January 2021
Description: | Get the position of a chart within a spreadsheet. | Programming Language: | StarBasic | Author: | Ingrid Halama, 2010 |
Sub Main Dim oTableChart as Object Dim oPosition as Object Dim Message as String oTableChart = ThisComponent.Sheets(0).getCharts().getByIndex(0) oPosition = getPositionOfChart( oTableChart ) Message = "Chart position: x=" & oPosition.X & " y=" & oPosition.Y MsgBox Message End Sub function getPositionOfChart( oTableChart as object ) dim oShape as object oShape = getShapeForChartName( oTableChart.Name, oTableChart.EmbeddedObject.Parent ) getPositionOfChart = oShape.Position end function function getShapeForChartName( sChartName as string, oSpreadSheetDocument ) as object 'iterate over all shapes in a calc document dim oSheet as object dim oShape as object SheetCount=oSpreadSheetDocument.Sheets.getCount SheetNo=0 while( SheetNo<SheetCount ) oSheet=ThisComponent.Sheets(SheetNo) oDrawPage=oSheet.DrawPage ShapeCount=oDrawPage.getCount ShapeNo=0 while(ShapeNo<ShapeCount) oShape = oDrawPage.getByIndex(ShapeNo) if( oShape.getShapeType() = "com.sun.star.drawing.OLE2Shape" ) then if( oShape.PersistName = sChartName ) then getShapeForChartName = oShape exit function endif endif ShapeNo=ShapeNo+1 wend SheetNo=SheetNo+1 wend end function