[Solved] Draw: "Insert File" into document
[Solved] Draw: "Insert File" into document
I've created macros that adjust text, lines and images in draw files to handle various requirements.
Each file need a cover page depending on the content, located in a draw file with a number of pages.
I need code to import one of the cover pages from that file into each macro adjusted file.
The macro should do what you get with Insert->File... select page(s).
Wouldn't mind if the code is expressed as ooRexx or similar.
Can't seem to find code how to switch to a specific page either.
Each file need a cover page depending on the content, located in a draw file with a number of pages.
I need code to import one of the cover pages from that file into each macro adjusted file.
The macro should do what you get with Insert->File... select page(s).
Wouldn't mind if the code is expressed as ooRexx or similar.
Can't seem to find code how to switch to a specific page either.
Last edited by MrProgrammer on Wed Apr 24, 2024 7:46 pm, edited 1 time in total.
Reason: Tagged ✓ [Solved] -- MrProgrammer, forum moderator
Reason: Tagged ✓ [Solved] -- MrProgrammer, forum moderator
Apache OpenOffice 4.1.13 on ArcaOS 5.0.7
Re: Draw: "Insert File" into file
So the link says:
"Currently it is not possible to insert slides from a drawing or presentation into a drawing document through API. To accomplish this, use the Insert – File command from the menu."
Is it possible to call the menu command (Dispatch...)?
"Currently it is not possible to insert slides from a drawing or presentation into a drawing document through API. To accomplish this, use the Insert – File command from the menu."
Is it possible to call the menu command (Dispatch...)?
Apache OpenOffice 4.1.13 on ArcaOS 5.0.7
Re: Draw: "Insert File" into file
I've decided to write code to do it, but how can one select to display a certain page?
Apache OpenOffice 4.1.13 on ArcaOS 5.0.7
Re: Draw: "Insert File" into file
self~XDispatchHelper~executeDispatch( self~xDoc~XModel~getCurrentController~getFrame~XDispatchProvider, ".uno:Intersect", "", 0, .UNO~noProps )
I use this code to call "Intersect".
I use this code to call "Intersect".
Apache OpenOffice 4.1.13 on ArcaOS 5.0.7
Re: Draw: "Insert File" into file
You cannot interact with UNO commands
Co-admin french forum branch
Re: Draw: "Insert File" into file
I probably can't understand the subject "Insert File ...", but:
1. The CurrentController of a Draw document can select a DrawPage (all its shapes as a "temporary group").
2. Draw doesn't support the macro recorder.
3. AOO is under very slow (if any) development. Better shift to LibreOffice with such tasks.
4. The attached demo was created with LibO 24.2.0.3. It was also tested successfully with LibO 6.4.5. it failed when tried with AOO 4.1.7.
5. The alternative approach didn't run for me.
(To support tests V 24.2 is already available as a PortableApps package.)
See demo:
1. The CurrentController of a Draw document can select a DrawPage (all its shapes as a "temporary group").
2. Draw doesn't support the macro recorder.
3. AOO is under very slow (if any) development. Better shift to LibreOffice with such tasks.
4. The attached demo was created with LibO 24.2.0.3. It was also tested successfully with LibO 6.4.5. it failed when tried with AOO 4.1.7.
5. The alternative approach didn't run for me.
(To support tests V 24.2 is already available as a PortableApps package.)
See demo:
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
---
Lupp from München
Re: Draw: "Insert File" into file
I'll use your approach to copy content, but my pages are completely separated, located in another draw file.
In my case it contain 3 pages, each depending on what the current draw file contain.
The page to insert is static, but describe the content in the current draw file.
Case 1: current draw file contain com.sun.star.drawing.LineShape or com.sun.star.drawing.PolyLineShape
Insert first page from the separate file.
Case 2: current draw file contain com.sun.star.drawing.GraphicObjectShape
Insert second page from the separate file.
Case 3: current draw file contain com.sun.star.drawing.ClosedBezierShape or com.sun.star.drawing.PolyPolygonShape
Insert third page from the separate file.
In my case it contain 3 pages, each depending on what the current draw file contain.
The page to insert is static, but describe the content in the current draw file.
Case 1: current draw file contain com.sun.star.drawing.LineShape or com.sun.star.drawing.PolyLineShape
Insert first page from the separate file.
Case 2: current draw file contain com.sun.star.drawing.GraphicObjectShape
Insert second page from the separate file.
Case 3: current draw file contain com.sun.star.drawing.ClosedBezierShape or com.sun.star.drawing.PolyPolygonShape
Insert third page from the separate file.
Last edited by jep on Thu Feb 08, 2024 5:41 pm, edited 1 time in total.
Apache OpenOffice 4.1.13 on ArcaOS 5.0.7
Re: Draw: "Insert File" into file
I use
self~XDispatchHelper~executeDispatch( self~xDoc~XModel~getCurrentController~getFrame~XDispatchProvider, ".uno:Intersect", "", 0, .UNO~noProps )
to create quite advanced intersecting draw objects with ooRexx paired with BSF4ooRexx to run everything from outside OpenOffice as it is now, and it work great.
I do look for a replacement to ".uno:InsertFile"
A stable API is preferable, and AOO itself has the ability... so it should be possible to call it somehow... but if it refuse, I'll resort to mouse clicks and menu commands then.
Apache OpenOffice 4.1.13 on ArcaOS 5.0.7
Re: Draw: "Insert File" into file
I never work with Draw documents unambiguously belonging one of your "cases".
Or are you talking of a currently selected shape?
Or... In what way, precisely, would you distinguish the cases?
Anyway: Simply select your case with a helper function, and set the DrawPage index you actually need to the respective value.
Mainly: I don't know a way to copy/paste a DrawPage object itself. You will need to either create a temporary group making a single shape of the content of the page needing to be copied and pasted, or to copy/paste all the shapes of that page one by one as I demonstrated.
Or are you talking of a currently selected shape?
Or... In what way, precisely, would you distinguish the cases?
Anyway: Simply select your case with a helper function, and set the DrawPage index you actually need to the respective value.
Mainly: I don't know a way to copy/paste a DrawPage object itself. You will need to either create a temporary group making a single shape of the content of the page needing to be copied and pasted, or to copy/paste all the shapes of that page one by one as I demonstrated.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
---
Lupp from München
Re: Draw: "Insert File" into file
XTransferableSupplier seems not to be implemented for Draw docs, see https://bugs.documentfoundation.org/sho ... ?id=1517135. The alternative approach didn't run for me.
Re: Draw: "Insert File" into file
controller.model.getTransferData
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: Draw: "Insert File" into file
¡¿aha?!
Since the number of downloads of my first attachment shows some interest, i attacfh also an enhanced example containig a working solution based on the group/ungroup idea:
Since the number of downloads of my first attachment shows some interest, i attacfh also an enhanced example containig a working solution based on the group/ungroup idea:
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
---
Lupp from München