[Solved] Redraw from LibreOffice Calc extension

Discussions about using 3rd party extension with OpenOffice.org
Post Reply
HCL
Posts: 22
Joined: Thu Jul 22, 2021 3:55 am

[Solved] Redraw from LibreOffice Calc extension

Post by HCL »

I'm developing an extension in Java for Libreoffice Calc.

How to perform redrawing?

It means refresh the view of spreadsheet between executing extension process.

If in VB, DoEvents.
Last edited by HCL on Mon Jul 26, 2021 5:32 am, edited 2 times in total.
OpenOffice 3.1 on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Redraw from Lireoffice Calc extention

Post by Villeroy »

The following Java code has been recorded with the MRI extension using OpenOffice 4.1. I do not fully understand the X,Y arguments to the draw function but it seems to redraw the ContainerWindow.
[Tutorial] Introduction into object inspection with MRI

Code: Select all

import com.sun.star.awt.XView;
import com.sun.star.awt.XWindow;
import com.sun.star.frame.XController;
import com.sun.star.frame.XFrame;
import com.sun.star.frame.XModel;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;

public static void snippet(XComponentContext xComponentContext, Object oInitialTarget)
{
	XModel xModel = UnoRuntime.queryInterface(
		XModel.class, oInitialTarget);
	XController xController = xModel.getCurrentController();
	
	XFrame xFrame = xController.getFrame();
	
	XWindow xWindow = xFrame.getContainerWindow();
	
	XView xView = UnoRuntime.queryInterface(
		XView.class, xWindow);
	
	xView.draw(0, 0);
	
}
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: Redraw from Lireoffice Calc extention

Post by JeJe »

The api documentation for "draw" is here:

https://www.openoffice.org/api/docs/com ... .html#draw
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: Redraw from Lireoffice Calc extention

Post by JeJe »

invalidate and invalidateRect are for repainting a particular window:

https://www.openoffice.org/api/docs/com ... wPeer.html
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
HCL
Posts: 22
Joined: Thu Jul 22, 2021 3:55 am

Re: Redraw from Lireoffice Calc extention

Post by HCL »

Thank you for your reply.

I could perform redrawing :D

But, when I perform redrawing by below code in for loop repeatedly,
redrawing is performed just first one time.

Code: Select all

	   XModel model = UnoRuntime.queryInterface(XModel.class, target);
	   XController xController = model.getCurrentController();
	   XFrame frame = xController.getFrame();
	   XWindow window = frame.getContainerWindow();
	   XView view = UnoRuntime.queryInterface(XView.class, window);
	   view.draw(0, 0);
OpenOffice 3.1 on Windows 10
Post Reply