Re: need help to insert an image with a caption with the Libo java API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 2/13/2019 10:45 AM, Miklos Vajna via LibreOffice wrote:
Hi,

On Tue, Feb 12, 2019 at 09:27:15AM +0000, LORENZO Vincent <vincent.lorenzo@xxxxxx> wrote:
I would like to add a caption, to an inserted image in a text
document, but I don't find how to do that... Please do you have
pointer/documentation for me ?
I think captions are just a UI feature. The doc model just stores a text
frame around the image and the image is followed by the caption itself.

(I.e. later it's not possible to reliably detect if some content around
an image in a frame was created by hand or using the captions UI code.)

So you can do the same "manually" using the UNO API. When in doubt, see
what UNO API the ODT import uses to create the doc model based on the
input markup.

yep, insert a Frame, insert a Image in the frame and add a caption

sub InsertIllustrationReference
  oDoc = ThisComponent
  oText = oDoc.getText()
  oViewCursor = oDoc.getCurrentController().getViewCursor()
  
  oReference = oDoc.createInstance("com.sun.star.text.textfield.GetReference")
  With oReference
    .SourceName = "Illustration"
    .ReferenceFieldPart = com.sun.star.text.ReferenceFieldPart.ONLY_SEQUENCE_NUMBER
    .ReferenceFieldSource = com.sun.star.text.ReferenceFieldSource.SEQUENCE_FIELD
    .SequenceNumber = 0
  End With
  
  oText.insertTextContent(oViewCursor, oReference, False)
end sub

Regards,

Miklos

_______________________________________________
LibreOffice mailing list
LibreOffice@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/libreoffice
_______________________________________________
LibreOffice mailing list
LibreOffice@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/libreoffice

[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux