Page 1 of 1

Howto insert html styled text

PostPosted: Fri Aug 09, 2019 7:22 pm
by djunges
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

Re: Howto insert html styled text

PostPosted: Fri Aug 09, 2019 11:02 pm
by JeJe
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())


Re: Howto insert html styled text

PostPosted: Mon Aug 12, 2019 1:32 pm
by djunges
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

Re: Howto insert html styled text

PostPosted: Mon Aug 12, 2019 1:43 pm
by JeJe
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

Re: Howto insert html styled text

PostPosted: Mon Aug 12, 2019 4:00 pm
by djunges
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

Re: Howto insert html styled text

PostPosted: Mon Aug 12, 2019 10:28 pm
by JeJe
If no-one comes up with a better way you could save it to a file and then insert the file in the document.

Re: Howto insert html styled text

PostPosted: Wed Aug 14, 2019 2:18 pm
by djunges
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