Howto insert html styled text

Creating a macro - Writing a Script - Using the API

Howto insert html styled text

Postby djunges » Fri Aug 09, 2019 7:22 pm

Hi,

im searching for a way to insert html formatex text into a document.
at the moment im using unoidl.com.sun.star.text.XTextRange setString function but it ignore html and style tags, inserts the tags instead

best regards
djunges
djunges
 
Posts: 9
Joined: Tue Feb 19, 2008 4:54 pm

Re: Howto insert html styled text

Postby JeJe » Fri Aug 09, 2019 11:02 pm

Have you tried pasting with the dispatch helper?

Code: Select all   Expand viewCollapse view
   dim document   as object
   dim dispatcher as object
   document   = ThisComponent.CurrentController.Frame
   dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
   dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())

Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 613
Joined: Wed Mar 09, 2016 2:40 pm

Re: Howto insert html styled text

Postby djunges » Mon Aug 12, 2019 1:32 pm

Hi JeJe,

Thank you for you response.
This would be a possible solution, but I didn't want to use the Clipboard.
If pasting from the clipboard works then it should have a function that allows me to do the same but unfortunately I still can't find it.

I hope someone can help me

regards
djunges
djunges
 
Posts: 9
Joined: Tue Feb 19, 2008 4:54 pm

Re: Howto insert html styled text

Postby JeJe » Mon Aug 12, 2019 1:43 pm

You don't say the source of your html.

You can use gettransferable and settransferable to copy/paste content from an OO source
without using the clipboard

Example:

viewtopic.php?f=21&t=78814
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 613
Joined: Wed Mar 09, 2016 2:40 pm

Re: Howto insert html styled text

Postby djunges » Mon Aug 12, 2019 4:00 pm

thanks for you response,

The html source comes from database.
I have seen the settransferable, but i not found a way to create a XTransferable object and put the data into it. It seems to be used only to copy from one documento to another.

best regards
djunges
djunges
 
Posts: 9
Joined: Tue Feb 19, 2008 4:54 pm

Re: Howto insert html styled text

Postby JeJe » Mon Aug 12, 2019 10:28 pm

If no-one comes up with a better way you could save it to a file and then insert the file in the document.
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 613
Joined: Wed Mar 09, 2016 2:40 pm

Re: Howto insert html styled text

Postby djunges » Wed Aug 14, 2019 2:18 pm

Hi JeJe

Thanks for you help.
To avoid using the Clipboard a saved the html data into a tmp file and then insert it with ".uno:InsertDoc"

regards
djunges
djunges
 
Posts: 9
Joined: Tue Feb 19, 2008 4:54 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 3 guests