<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><br>
</p>
<div class="moz-cite-prefix">On 2/13/2019 10:45 AM, Miklos Vajna via LibreOffice wrote:<br>
</div>
<blockquote type="cite" cite="mid:20190213094556.GB12660@collabora.com">
<pre class="moz-quote-pre" wrap="">Hi,
On Tue, Feb 12, 2019 at 09:27:15AM +0000, LORENZO Vincent <a class="moz-txt-link-rfc2396E" href="mailto:vincent.lorenzo@cea.fr"><vincent.lorenzo@cea.fr></a> wrote:
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">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 ?
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
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.</pre>
</blockquote>
<p>yep, insert a Frame, insert a Image in the frame and add a caption</p>
<pre class="code" style="line-height: 12.636px; border: 1px; padding: 0.5em; margin: 0px; color: rgb(0, 0, 0); background: rgb(255, 255, 255); line-break: strict; word-break: break-all; overflow-wrap: break-word; white-space: pre; overflow: visible; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"><code class="basic"><span class="code_identifier" style="color: darkblue;">sub</span> Insert<strong class="word0" style="font-weight: bold; background-color: transparent; color: black;">Illustration</strong>Reference
oDoc = ThisComponent
oText = oDoc.getText()
oViewCursor = oDoc.getCurrentController().getViewCursor()
oReference = oDoc.createInstance(<span class="code_string" style="color: rgb(255, 0, 0);">"com.sun.star.text.textfield.GetReference"</span>)
With oReference
.SourceName = <span class="code_string" style="color: rgb(255, 0, 0);">"<strong class="word0" style="font-weight: bold; background-color: transparent; color: black;">Illustration</strong>"</span>
.ReferenceFieldPart = <span class="code_identifier" style="color: darkblue;">com</span>.sun.star.text.ReferenceFieldPart.ONLY_SEQUENCE_NUMBER
.ReferenceFieldSource = <span class="code_identifier" style="color: darkblue;">com</span>.sun.star.text.ReferenceFieldSource.SEQUENCE_FIELD
.SequenceNumber = 0
<span class="code_identifier" style="color: darkblue;">End</span> With
oText.insertTextContent(oViewCursor, oReference, False)
<span class="code_identifier" style="color: darkblue;">end</span> <span class="code_identifier" style="color: darkblue;">sub</span></code></pre>
<blockquote type="cite" cite="mid:20190213094556.GB12660@collabora.com">
<pre class="moz-quote-pre" wrap="">
Regards,
Miklos
</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
LibreOffice mailing list
<a class="moz-txt-link-abbreviated" href="mailto:LibreOffice@lists.freedesktop.org">LibreOffice@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freedesktop.org/mailman/listinfo/libreoffice">https://lists.freedesktop.org/mailman/listinfo/libreoffice</a></pre>
</blockquote>
</body>
</html>