[Solved] Get and set texts in slides on impress

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
HCL
Posts: 22
Joined: Thu Jul 22, 2021 3:55 am

[Solved] Get and set texts in slides on impress

Post by HCL »

How to access texts in slide on impress?

And I just start to write code for impress.
Please introduce me good sites showing examples.

I couldn't find examples for impress.
https://wiki.openoffice.org/wiki/API/Samples/Java
Last edited by robleyd on Wed Jul 28, 2021 7:39 am, edited 2 times in total.
Reason: Add green tick
OpenOffice 3.1 on Windows 10
HCL
Posts: 22
Joined: Thu Jul 22, 2021 3:55 am

Re: Get and set texts in slides on impress

Post by HCL »

I reached to get a text from a shape in a slide on Impress.

Is it XDrawPagesSupplier on Impress correspoinding to XTextDocument on Writer or XSpreadsheetDocument on Calc...?

Code: Select all

			XMultiComponentFactory manager = context.getServiceManager();
			Object desktop_obj = manager.createInstanceWithContext(
					"com.sun.star.frame.Desktop", context);
			XDesktop desktop = UnoRuntime.queryInterface(XDesktop.class, desktop_obj);
			XComponent comp = desktop.getCurrentComponent();
			
			XDrawPagesSupplier page_sup = UnoRuntime.queryInterface(XDrawPagesSupplier.class, comp);
			XIndexAccess ia = UnoRuntime.queryInterface(XIndexAccess.class, page_sup.getDrawPages());
			
			XShapes shapes = UnoRuntime.queryInterface(XShapes.class, ia.getByIndex(0));
			
			XText xtext = UnoRuntime.queryInterface(XText.class, shapes.getByIndex(0));
			System.out.println(xtext.getString());
OpenOffice 3.1 on Windows 10
Post Reply