Control redraw of diagrams in writer via macro

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
target3000
Posts: 2
Joined: Fri Mar 05, 2010 7:01 pm

Control redraw of diagrams in writer via macro

Post by target3000 »

HI everybody,
its my first post here - but i have already a lot of reader-experience and learned a lot here

maybe someone can help me with my current question:
I'm generating series of a report written with ooo-writer that contain embedded objecs (diagrams). The sourcedata for the diagrams is a table, which was pasted from a ooo-calc sheet as DDE-link.
With a maco I change the data in calc and store the henc changed writer-doc as PDF. Works fine, but has one problem: How can the "redrawing" of the diagrams be controlled. The main loop containing
- datachange in the calc componente
- a refresh call on all Links in the writer component
- a component.storeToUrl()
is simply faster than the redrawing of all diagrams!
Behavior is unpredictable. Some graphs are updated, some not. The stored files are incorrect. Sometimes graphs aren't updated at all, until i click them and than double-click or change some legend-texts or change the objects size a little.

How is this repaint called from basic? Is there a way (some raised event maybe) to determine if the repaint is already finished?
I have "xrayed" a lot and also tried to find it in the api

Currently, to work around this all, I'm doing: (which is not really g.p.)

Code: Select all

let wdoc be a valid writer component:
        Dim EO,currEO,i
	'get the collection of embedded objects inside the writer-component
	EO=wdoc.EmbeddedObjects
	if EO.hasElements() then
	while i<EO.count
	 	currEO=EO.getByIndex(i)
 		Dim aSize: aSize=currEO.ExtendedControlOverEmbeddedObject.getVisualAreaSize(1)  
		Dim oSize As New com.sun.star.awt.Size
		oSize.Width = 1000
		oSize.Height = 1000
		'change the size in order to force redraw on embedded object
		currEO.ExtendedControlOverEmbeddedObject.setVisualAreaSize(1,oSize)  
		currEO.ExtendedControlOverEmbeddedObject.setVisualAreaSize(1,aSize)  
 	    i=i+1
	wend
	endif
    'wait some time and hope the the redraw for all eo's will be REALLY done
	wait 2000
	'TODO : thats just awfull - a correct method for the repaint would be needet, or at 
	'least wait until some raised signal is cought....
debian etch ooo 3.0
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Control redraw of diagrams in writer via macro

Post by hanya »

Does this work for you?

Code: Select all

Sub UpdateChart
  oDoc = ThisComponent
  oDrawPage = oDoc.getDrawPage()
  oShape = oDrawPage.getByIndex(0)
  oChart = oShape.getEmbeddedObject()
  
  ' send modified event to the chart
  ev = CreateUnoStruct("com.sun.star.lang.EventObject")
  ev.Source = oChart
  oChart.modified(ev)
End Sub
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
target3000
Posts: 2
Joined: Fri Mar 05, 2010 7:01 pm

Re: Control redraw of diagrams in writer via macro

Post by target3000 »

thanks, but no.
same problem.

im doing now:

Code: Select all

Sub triggerRedraw1(wdoc)
  Dim oDrawPage,oShape,oChart,ev 
  oDrawPage = wDoc.getDrawPage()
  Dim i:i=0

  while (i<oDrawPage.getCount) 
  oShape = oDrawPage.getByIndex(i)
  'xray oShape
  if not (isNull(oShape) ) and (instr(oShape.Dbg_Methods,"getEmbeddedObject")) then
  oChart = oShape.getEmbeddedObject()
  ' send modified event to the chart
  if not (isNull(oChart)) then
  ev = CreateUnoStruct("com.sun.star.lang.EventObject")
  ev.Source = oChart
  oChart.modified(ev)
  endif
  endif
  i=i+1
  wend
 ';-)
  wait msec
End Sub
debian etch ooo 3.0
Post Reply