Writer cut & paste

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
freddy
Posts: 3
Joined: Tue Dec 04, 2007 1:03 pm

Writer cut & paste

Post by freddy »

I'm trying to write a macro which in part needs to copy the entire text of a document, preserving its formatting, into a newly created empty text shape. I then want to set the width of the shape and retrieve it's height.
However, although I've succeeded in copying & pasting text using executedispatch & uno:Copy/Paste, I've so far been unable to place the copied text within the shape, as opposed to outside it or overwriting it. As far as I can tell, the problem appears to be, having selected the shape, in setting it into edit mode to accept an incoming paste - or maybe in placing the view cursor within it.
Has anyone got any working sample code or ideas on how to do this?
hol.sten
Volunteer
Posts: 495
Joined: Mon Oct 08, 2007 1:31 am
Location: Hamburg, Germany

Re: Writer cut & paste

Post by hol.sten »

freddy wrote:I've so far been unable to place the copied text within the shape,
Try this thread: http://www.oooforum.org/forum/viewtopic ... hape+basic
It contains information on how to add text in rectangle shape and refers to another useful thread covering an introduction to draw and basic shapes (http://www.oooforum.org/forum/viewtopic.phtml?t=5383).

Regards
hol.sten
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
freddy
Posts: 3
Joined: Tue Dec 04, 2007 1:03 pm

Re: Writer cut & paste

Post by freddy »

Thanks for that. I still haven't found how to 'paste' text into a shape though - which is needed in order to preserve formatting. I got around the problem by finding out how to retrieve the true size of a frame, which meant I could use a frame instead.
hol.sten
Volunteer
Posts: 495
Joined: Mon Oct 08, 2007 1:31 am
Location: Hamburg, Germany

Re: Writer cut & paste

Post by hol.sten »

freddy wrote:I got around the problem by finding out how to retrieve the true size of a frame, which meant I could use a frame instead.
Could you post some working code? It might help others with the same problem.
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
Post Reply