Bug 144191 - LILO starbase macro give name to chart proved by xraytool but manually the chart name is empty string
Summary: LILO starbase macro give name to chart proved by xraytool but manually the ch...
Status: UNCONFIRMED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Chart (show other bugs)
Version:
(earliest affected)
7.3.0.0 alpha0+
Hardware: All Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-30 15:53 UTC by elias estatistics
Modified: 2024-12-31 03:12 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
calc file with macro code - chart name is empty even it is declared (17.11 KB, application/vnd.oasis.opendocument.spreadsheet)
2021-08-30 15:53 UTC, elias estatistics
Details

Note You need to log in before you can comment on or make changes to this bug.
Description elias estatistics 2021-08-30 15:53:24 UTC
Created attachment 174646 [details]
calc file with macro code - chart name is empty even it is declared

LILO starbase macro give name to chart proved by xraytool but manually the chart name is empty string

To reproduce: 
- Run the macro code in the attachment .ods file. 
- Check Chart Name property - an empty string
- Try manually to name the chart with the name defined in macro code 
- The"OK" button is grayed out.
- Try to set any other name. You can. 


- LILO starbase macro code (included in a cell in the attachment)

  Sub LoadingLibraries
   BasicLibraries.LoadLibrary("XrayTool")
  End Sub


  Sub CreateCalcWithSimpleChart

  ' Definitions of variables
  Dim oSheet    'Sheet containing the chart
  Dim oRect     'How big is the chart
  Dim oCharts   'Charts in the sheet
  Dim oChart    'Created chart
  Dim oAddress  'Address of data to plot
  Dim sName$    'Chart name
  Dim oChartDoc 'Embedded chart object
  Dim oTitle    'Chart title object 
  Dim oDiagram  'Inserted diagram (data).
  Dim sDataRng  'Where is the data
  Dim oCalcDoc  

  ' it is needed to define Point and Size in order to
  ' change Position and Size of Chart Objects
  Dim Pos_Chart       As New com.sun.star.awt.Point
  Dim Pos_Title       As New com.sun.star.awt.Point
  Dim Pos_SubTitle    As New com.sun.star.awt.Point
  Dim Pos_xTitle      As New com.sun.star.awt.Point
  Dim Pos_yTitle      As New com.sun.star.awt.Point
  Dim Pos_Legend      As New com.sun.star.awt.Point

  Dim Size_Chart      As New com.sun.star.awt.Size
  Dim Size_Title      As New com.sun.star.awt.Size
  Dim Size_SubTitle   As New com.sun.star.awt.Size
  Dim Size_xTitle     As New com.sun.star.awt.Size
  Dim Size_yTitle     As New com.sun.star.awt.Size
  Dim Size_Legend     As New com.sun.star.awt.Size



  'Dont Forget to Define "Name of Sheet
  oSheets     = ThisComponent.getSheets()
  oSheet      = oSheets.getbyName( "Graph_stat" ) 

      
          Chart_XPos       = 0
          Chart_YPos       = 17000
          Chart_Width      = 16000
          Chart_Height     = 10000
   		Chart_New_XPos   =  Chart_New_XPos + Chart_Width + 900
  		
  		'Creation of objects into variables
  		oCalcDoc    = CreateCalcForChart()
  		sName       = "stat1"
  		sDataRng    = "D17:F28"
  		oAddress    = oSheet.getCellRangeByName(sDataRng).getRangeAddress()
  		oCharts     = oSheet.getCharts()
  		oRange      = oSheet.getCellRangeByName( sDataRng )
  		
  		
  		'The size of the whole chart 
  		If NOT oCharts.hasByName(sName) Then
  		oRect       = createObject("com.sun.star.awt.Rectangle")
  		oRect.X     = Chart_New_XPos
  		oRect.Y     = Chart_YPos
  		oRect.width = Chart_Width
  		oRect.Height= Chart_Height
  			
  		oCharts.addNewByName(sName, oRect, Array(oAddress), True, True)
  		End If		

  		
  		' Getting the Chart for manipulations
  		oChart       = oCharts.getByName(sName)  
  		oChart.setRanges(Array(oAddress))
  		oChartDoc    = oChart.getEmbeddedObject()
  		oDiagram     = oChartDoc.createInstance("com.sun.star.chart.ChartDiagram")
  		oChartDoc.setDiagram(oDiagram)  
  		oDiagram     = oChartDoc.getDiagram()

  		
  		'Inside the Chart, Setting Position and Size of the Diagram
  		oChartDoc.RefreshAddInAllowed = True
  		Pos_Chart.X                   = 300
  		Pos_Chart.Y                   = 1200
  		Size_Chart.width              = Chart_Width  - 800
  		Size_Chart.height             = Chart_Height - 1500
  		oDiagram.setPosition( Pos_Chart )
  		oDiagram.setSize(     Size_Chart )
  	
         
  end sub
Comment 1 elias estatistics 2021-08-30 16:16:08 UTC
Same as here maybe? id=125252
Comment 2 elias estatistics 2021-08-30 16:16:22 UTC Comment hidden (obsolete)
Comment 3 Regina Henschel 2024-12-30 14:49:10 UTC
The macro has at least this error: 
A service "com.sun.star.chart.ChartDiagram" does not exist.
Seen in line:
oDiagram = oChartDoc.createInstance("com.sun.star.chart.ChartDiagram")


Please provide an example with a valid macro and include the macro in the document itself instead of putting the code into a cell area.

You seem to have tried to adapt the example macros from Andrew Pitonyak: "OpenOffice.org Macros Explained"?

Does it works for you, if you use the example from Andrew Pitonyak unchanged?
Comment 4 elias estatistics 2024-12-30 15:46:47 UTC
i copy/paste the macro from the cell into edit macro menu with this system and macro run perfectly. I can provide a video if you would like. 

  
Version: 24.8.3.2 (X86_64) / LibreOffice Community
Build ID: 480(Build:2)
CPU threads: 24; OS: Linux 6.12; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Debian package version: 4:24.8.3-3
Calc: threaded

Be sure that before you run the code, you have selected with mouse an empty cell AND NOT the graph. 


I may ask sorry for not providing the test commands.
Exactly before END SUB

try `xray oChart.getName`
it prints "stat1"

however, WITHOUT double click, 
only select whole chart with single left click, then,
right click --> alt name OR name, both are empty in calc
even if macro has given a name to the chart.
Comment 5 elias estatistics 2024-12-30 15:49:46 UTC
However you dont need even the macro.

try
WITHOUT double click, 
only select whole chart with single left click, then,
right click --> NAME then write as name "stat1"
the button is grayed out cause the name is already given in the chart but calc 
do not show this name!
Comment 6 QA Administrators 2024-12-31 03:12:37 UTC Comment hidden (obsolete)