<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
code
        {mso-style-priority:99;
        font-family:"Courier New";}
pre
        {mso-style-priority:99;
        mso-style-link:"Préformaté HTML Car";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
span.EmailStyle19
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
span.EmailStyle20
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
span.PrformatHTMLCar
        {mso-style-name:"Préformaté HTML Car";
        mso-style-priority:99;
        mso-style-link:"Préformaté HTML";
        font-family:"Courier New";}
span.pln
        {mso-style-name:pln;}
span.typ
        {mso-style-name:typ;}
span.pun
        {mso-style-name:pun;}
span.str
        {mso-style-name:str;}
span.com
        {mso-style-name:com;}
span.kwd
        {mso-style-name:kwd;}
span.lit
        {mso-style-name:lit;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:590044977;
        mso-list-type:hybrid;
        mso-list-template-ids:1342070280 1013979864 67895299 67895301 67895297 67895299 67895301 67895297 67895299 67895301;}
@list l0:level1
        {mso-level-start-at:0;
        mso-level-number-format:bullet;
        mso-level-text:-;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:53.25pt;
        text-indent:-18.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-font-family:Calibri;}
@list l0:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:89.25pt;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level3
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:125.25pt;
        text-indent:-18.0pt;
        font-family:Wingdings;}
@list l0:level4
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:161.25pt;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l0:level5
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:197.25pt;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level6
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:233.25pt;
        text-indent:-18.0pt;
        font-family:Wingdings;}
@list l0:level7
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:269.25pt;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l0:level8
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:305.25pt;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level9
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:341.25pt;
        text-indent:-18.0pt;
        font-family:Wingdings;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="FR" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Hello everybody,
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">              Here my java code to get numbered caption under the inserted image (with some dependencies on my API, sorry for that)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Hoping it will help someone in the future. I still thank you for the help.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">FYI, this code will be available in few days (or week) on this git repository :
</span><code><span style="font-size:10.0pt"><a href="https://git.eclipse.org/c/papyrus/org.eclipse.papyrus-model2doc.git/">https://git.eclipse.org/c/papyrus/org.eclipse.papyrus-model2doc.git/</a><o:p></o:p></span></code></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">     
</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F0055">public</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black">
</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F0055">static</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black">
</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F0055">void</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black"> addImageLink(String
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">imageFilePath</span><span style="font-size:10.0pt;font-family:Consolas;color:black">, String
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">caption</span><span style="font-size:10.0pt;font-family:Consolas;color:black">, XTextCursor
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">xTextCursor</span><span style="font-size:10.0pt;font-family:Consolas;color:black">, ODTEditor
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">odtEditor</span><span style="font-size:10.0pt;font-family:Consolas;color:black">) {</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">           
</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F0055">try</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black"> {</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                   XMultiServiceFactory
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">xMultiServiceFactory</span><span style="font-size:10.0pt;font-family:Consolas;color:black"> =
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">odtEditor</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.getXMultiServiceFactory();</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                   Object
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">tmp</span><span style="font-size:10.0pt;font-family:Consolas;color:black"> =
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">xMultiServiceFactory</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.createInstance(</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"com.sun.star.text.TextFrame"</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">//$NON-NLS-1$</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                   XTextFrame
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">textFrame</span><span style="font-size:10.0pt;font-family:Consolas;color:black"> = UnoRuntime.<i>queryInterface</i>(XTextFrame.</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F0055">class</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">tmp</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                   XPropertySet
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">framePropertySet</span><span style="font-size:10.0pt;font-family:Consolas;color:black"> =
<i>createXPropertySet</i>(</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">textFrame</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                  
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">framePropertySet</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.setPropertyValue(</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"SizeType"</span><span style="font-size:10.0pt;font-family:Consolas;color:black">,
 SizeType.</span><b><i><span style="font-size:10.0pt;font-family:Consolas;color:#0000C0">VARIABLE</span></i></b><span style="font-size:10.0pt;font-family:Consolas;color:black">);
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">//$NON-NLS-1$</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                  
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">framePropertySet</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.setPropertyValue(</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"AnchorType"</span><span style="font-size:10.0pt;font-family:Consolas;color:black">,
 TextContentAnchorType.</span><b><i><span style="font-size:10.0pt;font-family:Consolas;color:#0000C0">AS_CHARACTER</span></i></b><span style="font-size:10.0pt;font-family:Consolas;color:black">);
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">//$NON-NLS-1$</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                  
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">framePropertySet</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.setPropertyValue(</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"ZOrder"</span><span style="font-size:10.0pt;font-family:Consolas;color:black">,
 1);</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">// not really sure //$NON-NLS-1$</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                  
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">framePropertySet</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.setPropertyValue(</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"TextWrap"</span><span style="font-size:10.0pt;font-family:Consolas;color:black">,
 WrapTextMode.</span><b><i><span style="font-size:10.0pt;font-family:Consolas;color:#0000C0">THROUGH</span></i></b><span style="font-size:10.0pt;font-family:Consolas;color:black">);
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">//$NON-NLS-1$</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                  
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">// Creating the service GraphicObject</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                   Object
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">graphicObject</span><span style="font-size:10.0pt;font-family:Consolas;color:black"> =
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">xMultiServiceFactory</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.createInstance(</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"com.sun.star.text.TextGraphicObject"</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">//$NON-NLS-1$</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                  
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">// Creating TextContent for GraphicObject</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                   XTextContent
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">graphicContent</span><span style="font-size:10.0pt;font-family:Consolas;color:black"> = UnoRuntime.<i>queryInterface</i>(XTextContent.</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F0055">class</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">graphicObject</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                  
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">// Creating bitmap container service</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                   XNameContainer
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">bitmapContainer</span><span style="font-size:10.0pt;font-family:Consolas;color:black"> = UnoRuntime.<i>queryInterface</i>(XNameContainer.</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F0055">class</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">xMultiServiceFactory</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.createInstance(</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"com.sun.star.drawing.BitmapTable"</span><span style="font-size:10.0pt;font-family:Consolas;color:black">));
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">//$NON-NLS-1$</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                  
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">// Inserting image to the container</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                  
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">bitmapContainer</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.insertByName(</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">imageFilePath</span><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">imageFilePath</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                   PropertySetUtil.<i>setProperty</i>(</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">graphicContent</span><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"AnchorType"</span><span style="font-size:10.0pt;font-family:Consolas;color:black">, TextContentAnchorType.</span><b><i><span style="font-size:10.0pt;font-family:Consolas;color:#0000C0">AT_CHARACTER</span></i></b><span style="font-size:10.0pt;font-family:Consolas;color:black">);
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">//$NON-NLS-1$</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                   PropertySetUtil.<i>setProperty</i>(</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">graphicContent</span><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"GraphicURL"</span><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">bitmapContainer</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.getByName(</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">imageFilePath</span><span style="font-size:10.0pt;font-family:Consolas;color:black">));
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">//$NON-NLS-1$</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                  
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">graphicContent</span><span style="font-size:10.0pt;font-family:Consolas;color:black"> = ImageUtil.<i>resizeImage</i>(</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">graphicContent</span><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">imageFilePath</span><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">odtEditor</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.getXTextDocument(),
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">odtEditor</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.getXMultiComponentFactory(),
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">odtEditor</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.getXComponentContext());</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                   XPropertySet
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">graphicPropSet</span><span style="font-size:10.0pt;font-family:Consolas;color:black"> =
<i>createXPropertySet</i>(</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">graphicContent</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                   Object
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">heightValue</span><span style="font-size:10.0pt;font-family:Consolas;color:black"> =
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">graphicPropSet</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.getPropertyValue(</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"Height"</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">//$NON-NLS-1$</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                   Object
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">widthValue</span><span style="font-size:10.0pt;font-family:Consolas;color:black"> =
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">graphicPropSet</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.getPropertyValue(</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"Width"</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">//$NON-NLS-1$</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                   XPropertySet
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">textFrameSet</span><span style="font-size:10.0pt;font-family:Consolas;color:black"> =
<i>createXPropertySet</i>(</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">textFrame</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                  
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">textFrameSet</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.setPropertyValue(</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"Height"</span><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">heightValue</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">//
</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F9FBF">TODO</span></b><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F"> don't work, and should be on the next level... //$NON-NLS-1$</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                  
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">textFrameSet</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.setPropertyValue(</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"Width"</span><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">widthValue</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">//$NON-NLS-1$</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">               
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">xTextCursor</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.getText().insertTextContent(</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">xTextCursor</span><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">textFrame</span><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F0055">false</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black">);</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                   XTextCursor
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">localCursor</span><span style="font-size:10.0pt;font-family:Consolas;color:black"> =
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">textFrame</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.getText().createTextCursor();</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                   XParagraphCursor
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">paragraphCursor</span><span style="font-size:10.0pt;font-family:Consolas;color:black"> = UnoRuntime.<i>queryInterface</i>(XParagraphCursor.</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F0055">class</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">localCursor</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                   XPropertySet
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">paraSet</span><span style="font-size:10.0pt;font-family:Consolas;color:black"> =
<i>createXPropertySet</i>(</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">paragraphCursor</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                  
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">paraSet</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.setPropertyValue(</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"ParaStyleName"</span><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"Figure"</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">               
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">localCursor</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.getText().insertTextContent(</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">localCursor</span><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">graphicContent</span><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F0055">false</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black">);</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                  
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">localCursor</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.gotoEnd(</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F0055">true</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black">);</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                  
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">// managing the caption, we need a text field master</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                   XTextFieldsSupplier
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">supplier</span><span style="font-size:10.0pt;font-family:Consolas;color:black"> = UnoRuntime.<i>queryInterface</i>(XTextFieldsSupplier.</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F0055">class</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">odtEditor</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.getXTextDocument());</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                   XNameAccess
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">masters</span><span style="font-size:10.0pt;font-family:Consolas;color:black"> =
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">supplier</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.getTextFieldMasters();</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                   Object
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">masterSetExpressionForFigure</span><span style="font-size:10.0pt;font-family:Consolas;color:black"> =
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">masters</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.getByName(</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"com.sun.star.text.fieldmaster.SetExpression.Figure"</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">//$NON-NLS-1$</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                  
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">// create a dependent SetExpression</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                   Object
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">textFieldSetExpression</span><span style="font-size:10.0pt;font-family:Consolas;color:black"> =
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">xMultiServiceFactory</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.createInstance(</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"com.sun.star.text.textfield.SetExpression"</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">//$NON-NLS-1$</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                   XPropertySet
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">textFieldSetExpressionPropertySet</span><span style="font-size:10.0pt;font-family:Consolas;color:black"> = UnoRuntime.<i>queryInterface</i>(XPropertySet.</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F0055">class</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">textFieldSetExpression</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">            
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">textFieldSetExpressionPropertySet</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.setPropertyValue(</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"NumberingType"</span><span style="font-size:10.0pt;font-family:Consolas;color:black">,
 com.sun.star.style.NumberingType.</span><b><i><span style="font-size:10.0pt;font-family:Consolas;color:#0000C0">ARABIC</span></i></b><span style="font-size:10.0pt;font-family:Consolas;color:black">);
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">//$NON-NLS-1$</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">            
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">textFieldSetExpressionPropertySet</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.setPropertyValue(</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"NumberFormat"</span><span style="font-size:10.0pt;font-family:Consolas;color:black">,
 NumberFormat.</span><b><i><span style="font-size:10.0pt;font-family:Consolas;color:#0000C0">NUMBER</span></i></b><span style="font-size:10.0pt;font-family:Consolas;color:black">);
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">//$NON-NLS-1$</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">            
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">textFieldSetExpressionPropertySet</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.setPropertyValue(</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"Content"</span><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"Figure + 1"</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">//$NON-NLS-1$ //$NON-NLS-2$</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                   XDependentTextField
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">xDependeantTextFIeld</span><span style="font-size:10.0pt;font-family:Consolas;color:black"> = UnoRuntime.<i>queryInterface</i>(XDependentTextField.</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F0055">class</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">textFieldSetExpression</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                  
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">// attach the dependent SetExpression to its master</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">            
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">xDependeantTextFIeld</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.attachTextFieldMaster(UnoRuntime.<i>queryInterface</i>(XPropertySet.</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F0055">class</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">masterSetExpressionForFigure</span><span style="font-size:10.0pt;font-family:Consolas;color:black">));</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                  
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">localCursor</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.getText().insertString(</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">localCursor</span><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"Figure "</span><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F0055">false</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black">);
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">//$NON-NLS-1$</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                  
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">// insert the SetExpression</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">               
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">localCursor</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.getText().insertTextContent(</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">localCursor</span><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">xDependeantTextFIeld</span><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F0055">true</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black">);</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                  
</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F0055">if</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black"> (</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">caption</span><span style="font-size:10.0pt;font-family:Consolas;color:black">
 != </span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F0055">null</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black"> && !</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">caption</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.isEmpty())
 {</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                        
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">localCursor</span><span style="font-size:10.0pt;font-family:Consolas;color:black">.getText().insertString(</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">localCursor</span><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">": "</span><span style="font-size:10.0pt;font-family:Consolas;color:black"> +
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">caption</span><span style="font-size:10.0pt;font-family:Consolas;color:black">,
</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F0055">false</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black">);
</span><span style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F">//$NON-NLS-1$</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                   }</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                  
<i>endParagraph</i>(</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">xTextCursor</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">             }
</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F0055">catch</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black"> (Exception
</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">e</span><span style="font-size:10.0pt;font-family:Consolas;color:black">) {</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">                   Activator.</span><i><span style="font-size:10.0pt;font-family:Consolas;color:#0000C0">log</span></i><span style="font-size:10.0pt;font-family:Consolas;color:black">.error(</span><span style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">e</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">             }</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">      }</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Best regards,
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">--<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Vincent Lorenzo<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">De :</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> LibreOffice <libreoffice-bounces@lists.freedesktop.org>
<b>De la part de</b> LORENZO Vincent<br>
<b>Envoyé :</b> lundi 16 septembre 2019 11:10<br>
<b>À :</b> Andrew Pitonyak <andrew@pitonyak.org><br>
<b>Cc :</b> libreoffice@lists.freedesktop.org; Miklos Vajna <vmiklos@collabora.com>; sos <sos@pmg.be>; Kaganski Mike <mikekaganski@hotmail.com><br>
<b>Objet :</b> [PROVENANCE INTERNET] RE: need help to insert an image with a caption with the Libo java API <text:sequence-ref instead of <text:sequence<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Hi Andrew,
<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">    Thank you very much, I succeded to make a caption and a table of figures last Friday !
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">I will post the final solution on this thread when I will have finished to clean my code.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Best Regards,
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">--<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Vincent Lorenzo<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">De :</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Andrew Pitonyak <<a href="mailto:andrew@pitonyak.org">andrew@pitonyak.org</a>>
<br>
<b>Envoyé :</b> vendredi 6 septembre 2019 18:06<br>
<b>À :</b> LORENZO Vincent <<a href="mailto:vincent.lorenzo@cea.fr">vincent.lorenzo@cea.fr</a>><br>
<b>Cc :</b> Kaganski Mike <<a href="mailto:mikekaganski@hotmail.com">mikekaganski@hotmail.com</a>>; Miklos Vajna <<a href="mailto:vmiklos@collabora.com">vmiklos@collabora.com</a>>; sos <<a href="mailto:sos@pmg.be">sos@pmg.be</a>>;
<a href="mailto:libreoffice@lists.freedesktop.org">libreoffice@lists.freedesktop.org</a><br>
<b>Objet :</b> RE: need help to insert an image with a caption with the Libo java API <text:sequence-ref instead of <text:sequence<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I am going from memory here, so I might be a bit off. <br>
<br>
When you create a variable such as "Figure", it is of a specific type because they know how you want to use it. If I insert a caption manually, something like the following happens. <br>
<br>
I enter the text "Figure " at the start of a paragraph and then I insert a field; one of those Figure fields (The type is SetExpression). I then set the value to be "Figure + 1". It turns out that we have a single MASTER for ALL of the Figure fields that you
 see. They are ALL a dependent, child, or what ever they call it, of this one master text field. In OOME.odt (on my web site), I have examples in Basic to create and manipulate these, but it is missing some details I think. <br>
<br>
I thought that you wanted to know how to insert a reference to a specific SetExpression field, which is the part that says something like "Figure 1. ...". I was wrong. So, I assume that you want to insert one of those SetExpression fields (A caption field). <br>
<br>
Lets consider what happens when I insert a caption using the UI. Note that I don't really know what it does, but, I am guessing and going from memory. So, some of my details may be wrong. <br>
<br>
I paste a graphic into my document. By default, I think that it anchors itself to a paragraph and it can float a bit, but that is not very important for our purposes. This is my best guess as to what happens when you right click and say create caption. <br>
<br>
1. A frame is created that uses the same anchor as the graphic. <br>
2. The graphic is anchored as a character to the text object in the frame as a character.<br>
3. The text "Figure " is inserted followed by a SetExpression type field with the expression "Figure + 1" followed by the rest of your text. <br>
<br>
So, I think that by default there is a single paragraph in that text frame. I could not tell you how things are sized because I have never looked into it, but, that is how I think it is done. What ever they do, if you resize the frame, the image resizes with
 it. In other words, i think that they probably set some specific properties on the image and on the frame for that magic to occur. <br>
<br>
Let me look again at what you say you want to do..<br>
<br>
You insert an image and you know how to do that. Good. <br>
<br>
I think you then say that you do not know how to create a caption for that image, but you use the term "Table Of Figure" so I think of creating a list of references to figures, which would really reference those SetExpression fields (I think that text field
 type is called a GetExpression). So I think you want to know how to insert a SetExpression field. <br>
<br>
Also not that you are referencing the text field, which is associated to a graphic (or what ever) based on proximity (it is close). <br>
<br>
The first question you must ask.... Does your Master text field already exist? You can create your own if you want, so, you could four different types of figures with their own Master field. <br>
<br>
OOME (OpenOffice Macros Explained) demonstrates how to create a Master Field if you need to. You are probably using one that already exists, however. The example below creates one named "Listing". <br>
<br>
A <i>Listing</i> sequence field is associated to the com.sun.star.text.FieldMaster.SetExpression.Listing master field, which must exist before the sequence field can be used. Listing 396 Demonstrates how to create a master field if it does not exist, and how
 to get the master field if it does. <br>
<b><i>Listing 396.</i></b><i> Creating a master field.</i><br>
<span style="font-size:9.0pt;font-family:"Courier New";color:green">oMasters</span><span style="font-size:9.0pt;font-family:"Courier New"">
<span style="color:navy">=</span> <span style="color:green">oDoc</span><span style="color:navy">.</span><span style="color:green">getTextFieldMasters</span></span><br>
<span style="font-size:9.0pt;font-family:"Courier New";color:navy">If</span><span style="font-size:9.0pt;font-family:"Courier New"">
<span style="color:navy">NOT</span> <span style="color:green">oMasters</span><span style="color:navy">.</span><span style="color:green">hasByName</span><span style="color:navy">(</span><span style="color:red">"com.sun.star.text.FieldMaster.SetExpression.Listing"</span><span style="color:navy">)</span>
<span style="color:navy">Then</span></span><br>
<span style="font-size:9.0pt;font-family:"Courier New";color:green">  oMasterField</span><span style="font-size:9.0pt;font-family:"Courier New"">
<span style="color:navy">=</span> <span style="color:green">oDoc</span><span style="color:navy">.</span><span style="color:green">createInstance</span><span style="color:navy">(</span><span style="color:red">"com.sun.star.text.FieldMaster.SetExpression"</span><span style="color:navy">)</span></span><br>
<span style="font-size:9.0pt;font-family:"Courier New";color:green">  oMasterField</span><span style="font-size:9.0pt;font-family:"Courier New";color:navy">.Name</span><span style="font-size:9.0pt;font-family:"Courier New"">
<span style="color:navy">=</span> <span style="color:red">"Listing"</span></span><br>
<span style="font-size:9.0pt;font-family:"Courier New";color:green">  oMasterField</span><span style="font-size:9.0pt;font-family:"Courier New";color:navy">.</span><span style="font-size:9.0pt;font-family:"Courier New";color:green">SubType</span><span style="font-size:9.0pt;font-family:"Courier New"">
<span style="color:navy">=</span> <span style="color:green">com</span><span style="color:navy">.</span><span style="color:green">sun</span><span style="color:navy">.</span><span style="color:green">star</span><span style="color:navy">.text.</span><span style="color:green">SetVariableType</span><span style="color:navy">.</span><span style="color:green">SEQUENCE</span></span><br>
<span style="font-size:9.0pt;font-family:"Courier New";color:navy">Else</span><br>
<span style="font-size:9.0pt;font-family:"Courier New";color:green">  oMasterField</span><span style="font-size:9.0pt;font-family:"Courier New"">
<span style="color:navy">=</span> <span style="color:green">oMasters</span><span style="color:navy">.</span><span style="color:green">getByName</span><span style="color:navy">(</span><span style="color:red">"com.sun.star.text.FieldMaster.SetExpression.Listing"</span><span style="color:navy">)</span></span><br>
<span style="font-size:9.0pt;font-family:"Courier New";color:navy">End</span><span style="font-size:9.0pt;font-family:"Courier New"">
<span style="color:navy">If</span></span><br>
The master field sub-type determines the field type (see Table 154).<br>
<b><i>Table 154.</i></b><i> Constants for com.sun.star.text.SetVariableType.</i><o:p></o:p></p>
<table class="MsoNormalTable" border="0" cellspacing="4" cellpadding="0" width="100%" style="width:100.0%;border:undefined">
<thead>
<tr>
<td width="13%" valign="top" style="width:13.0%;background:navy;padding:.75pt .75pt .75pt .75pt">
<p class="MsoNormal"><b><i><span style="font-size:11.0pt;font-family:"Arial",sans-serif;color:white;background:navy">Value</span></i></b><o:p></o:p></p>
</td>
<td width="54%" valign="top" style="width:54.0%;background:navy;padding:.75pt .75pt .75pt .75pt">
<p class="MsoNormal"><b><i><span style="font-size:11.0pt;font-family:"Arial",sans-serif;color:white;background:navy">Constant</span></i></b><o:p></o:p></p>
</td>
<td width="33%" valign="top" style="width:33.0%;background:navy;padding:.75pt .75pt .75pt .75pt">
<p class="MsoNormal"><b><i><span style="font-size:11.0pt;font-family:"Arial",sans-serif;color:white;background:navy">Description</span></i></b><o:p></o:p></p>
</td>
</tr>
</thead>
<tbody>
<tr>
<td width="13%" valign="top" style="width:13.0%;padding:.75pt .75pt .75pt .75pt">
<p class="MsoNormal"><span style="font-size:10.0pt">0</span><o:p></o:p></p>
</td>
<td width="54%" valign="top" style="width:54.0%;padding:.75pt .75pt .75pt .75pt">
<p class="MsoNormal"><span style="font-size:10.0pt">com.sun.star.text.SetVariableType.VAR
</span><o:p></o:p></p>
</td>
<td width="33%" valign="top" style="width:33.0%;padding:.75pt .75pt .75pt .75pt">
<p class="MsoNormal"><span style="font-size:10.0pt">Simple variable. </span><o:p></o:p></p>
</td>
</tr>
<tr>
<td width="13%" valign="top" style="width:13.0%;background:#E6E6E6;padding:.75pt .75pt .75pt .75pt">
<p class="MsoNormal"><span style="font-size:10.0pt">1</span><o:p></o:p></p>
</td>
<td width="54%" valign="top" style="width:54.0%;background:#E6E6E6;padding:.75pt .75pt .75pt .75pt">
<p class="MsoNormal"><span style="font-size:10.0pt">com.sun.star.text.SetVariableType.SEQUENCE
</span><o:p></o:p></p>
</td>
<td width="33%" valign="top" style="width:33.0%;background:#E6E6E6;padding:.75pt .75pt .75pt .75pt">
<p class="MsoNormal"><span style="font-size:10.0pt">Number sequence field. </span>
<o:p></o:p></p>
</td>
</tr>
<tr>
<td width="13%" valign="top" style="width:13.0%;padding:.75pt .75pt .75pt .75pt">
<p class="MsoNormal"><span style="font-size:10.0pt">2</span><o:p></o:p></p>
</td>
<td width="54%" valign="top" style="width:54.0%;padding:.75pt .75pt .75pt .75pt">
<p class="MsoNormal"><span style="font-size:10.0pt">com.sun.star.text.SetVariableType.FORMULA
</span><o:p></o:p></p>
</td>
<td width="33%" valign="top" style="width:33.0%;padding:.75pt .75pt .75pt .75pt">
<p class="MsoNormal"><span style="font-size:10.0pt">Formula field. </span><o:p></o:p></p>
</td>
</tr>
<tr>
<td width="13%" valign="top" style="width:13.0%;background:#E6E6E6;padding:.75pt .75pt .75pt .75pt">
<p class="MsoNormal"><span style="font-size:10.0pt">3</span><o:p></o:p></p>
</td>
<td width="54%" valign="top" style="width:54.0%;background:#E6E6E6;padding:.75pt .75pt .75pt .75pt">
<p class="MsoNormal"><span style="font-size:10.0pt">com.sun.star.text.SetVariableType.STRING
</span><o:p></o:p></p>
</td>
<td width="33%" valign="top" style="width:33.0%;background:#E6E6E6;padding:.75pt .75pt .75pt .75pt">
<p class="MsoNormal"><span style="font-size:10.0pt">String field. </span><o:p></o:p></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><br>
This is the next section:<br>
<br>
The sequence field is created by the document, then the numbering type is set to arabic. The number format is set, the master field is associated to the field (the master field is a sequence field), and then the field content is set to increment the value (Listing
 + 1). Note that when the field is inserted, the field may not be immediately updated. Either wait for the field to update, or force an update using
<b>Tools > Update > Fields</b>.<br>
<b><i>Listing 397.</i></b><i> Creating a set expression sequence field.</i><br>
<span style="font-size:9.0pt;font-family:"Courier New";color:green">oField</span><span style="font-size:9.0pt;font-family:"Courier New"">
<span style="color:navy">=</span> <span style="color:green">oDoc</span><span style="color:navy">.</span><span style="color:green">createInstance</span><span style="color:navy">(</span><span style="color:red">"com.sun.star.text.TextField.SetExpression"</span><span style="color:navy">)</span></span><br>
<span style="font-size:9.0pt;font-family:"Courier New";color:green">oField</span><span style="font-size:9.0pt;font-family:"Courier New";color:navy">.</span><span style="font-size:9.0pt;font-family:"Courier New";color:green">NumberingType</span><span style="font-size:9.0pt;font-family:"Courier New"">
<span style="color:navy">=</span> <span style="color:green">com</span><span style="color:navy">.</span><span style="color:green">sun</span><span style="color:navy">.</span><span style="color:green">star</span><span style="color:navy">.</span><span style="color:green">style</span><span style="color:navy">.</span><span style="color:green">NumberingType</span><span style="color:navy">.</span><span style="color:green">ARABIC</span></span><br>
<span style="font-size:9.0pt;font-family:"Courier New";color:green">oField</span><span style="font-size:9.0pt;font-family:"Courier New";color:navy">.</span><span style="font-size:9.0pt;font-family:"Courier New";color:green">NumberFormat</span><span style="font-size:9.0pt;font-family:"Courier New"">
<span style="color:navy">=</span> <span style="color:green">FindCreateNumberFormatStyle</span><span style="color:navy">(</span><span style="color:red">"###0"</span><span style="color:navy">,</span>
<span style="color:green">oDoc</span><span style="color:navy">)</span></span><br>
<span style="font-size:9.0pt;font-family:"Courier New";color:green">oField</span><span style="font-size:9.0pt;font-family:"Courier New";color:navy">.</span><span style="font-size:9.0pt;font-family:"Courier New";color:green">attachTextFieldMaster</span><span style="font-size:9.0pt;font-family:"Courier New";color:navy">(</span><span style="font-size:9.0pt;font-family:"Courier New";color:green">oMasterField</span><span style="font-size:9.0pt;font-family:"Courier New";color:navy">)</span><br>
<span style="font-size:9.0pt;font-family:"Courier New";color:green">oField</span><span style="font-size:9.0pt;font-family:"Courier New";color:navy">.</span><span style="font-size:9.0pt;font-family:"Courier New";color:green">Content</span><span style="font-size:9.0pt;font-family:"Courier New"">
<span style="color:navy">=</span> <span style="color:navy">name</span> <span style="color:navy">
&</span> <span style="color:red">" + 1"</span></span><br>
Constants used to set the numbering type are set as shown in the Table 150.<br>
<br>
Things to note.<br>
<br>
1. The document creates field that you want to insert. <br>
2. The SetExpression field itself is directly attached to the associated Master field (attachTextFieldMaster). <br>
3. I actually create my own numbering style, I don't know what the default is or what happens if you do not set the style.  I just don't remember. <br>
4. This little snippet does not actually show you inserting the field. You do this by inserting text content with a text cursor. <br>
5. You will not see anything displayed, at least not correctly, until after you update fields from the menu. In the example I posted, i used a dispatch to do this for you. <br>
<br>
There is a full example that replaces text references for figures with actual fields such as this. I had a document with a bunch of manually entered values and I wanted to use fields. It was created before I knew how to do that using the UI. <br>
<br>
So, I hope this helps some. <br>
<br>
I am overdue for pushing a new copy of OOME4.odt; I made some changes in other areas, I just need to push it. <br>
<br>
<br>
<br>
On Friday, September 06, 2019 09:51 EDT, LORENZO Vincent <<a href="mailto:vincent.lorenzo@cea.fr">vincent.lorenzo@cea.fr</a>> wrote:<br>
 <o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"> <o:p></o:p></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Hi Andrew,
</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">   Thank you for your answer. In fact I want to create a numbered caption (something like « Figure 1 : my nice caption ») under an
 inserted image and I want to create a table of figure with these captions to list all images.
</span><o:p></o:p></p>
<p class="MsoListParagraph" style="margin-left:53.25pt;text-indent:-18.0pt;mso-list:l0 level1 lfo2">
<![if !supportLists]><span style="font-family:"Calibri",sans-serif"><span style="mso-list:Ignore">-<span style="font:7.0pt "Times New Roman"">        
</span></span></span><![endif]><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">The image is well inserted</span><o:p></o:p></p>
<p class="MsoListParagraph" style="margin-left:53.25pt;text-indent:-18.0pt;mso-list:l0 level1 lfo2">
<![if !supportLists]><span style="font-family:"Calibri",sans-serif"><span style="mso-list:Ignore">-<span style="font:7.0pt "Times New Roman"">        
</span></span></span><![endif]><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">The Table Of Figure is created and works fine when I add manually an image with a caption in the generated document.
</span><o:p></o:p></p>
<p class="MsoListParagraph" style="margin-left:53.25pt;text-indent:-18.0pt;mso-list:l0 level1 lfo2">
<![if !supportLists]><span style="font-family:"Calibri",sans-serif"><span style="mso-list:Ignore">-<span style="font:7.0pt "Times New Roman"">        
</span></span></span><![endif]><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">This table of Figure doesn’t work for the image inserted programmatically, probably, because I don’t know how to create properly
 a numbered caption. </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">I’m a bit confused about the SetExpression, DependentField, field master, … I will continue to investigate about that, but if you have
 some references for me, please don’t hesitate. </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Regards,
</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">/Vincent Lorenzo</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">De :</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Andrew Pitonyak <<a href="mailto:andrew@pitonyak.org">andrew@pitonyak.org</a>><br>
<b>Envoyé :</b> jeudi 5 septembre 2019 22:57<br>
<b>À :</b> LORENZO Vincent <<a href="mailto:vincent.lorenzo@cea.fr">vincent.lorenzo@cea.fr</a>><br>
<b>Cc :</b> Kaganski Mike <<a href="mailto:mikekaganski@hotmail.com">mikekaganski@hotmail.com</a>>; Miklos Vajna <<a href="mailto:vmiklos@collabora.com">vmiklos@collabora.com</a>>; sos <<a href="mailto:sos@pmg.be">sos@pmg.be</a>>;
<a href="mailto:libreoffice@lists.freedesktop.org">libreoffice@lists.freedesktop.org</a><br>
<b>Objet :</b> RE: need help to insert an image with a caption with the Libo java API <text:sequence-ref instead of <text:sequence</span><o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">Are you looking to insert the caption, or the reference to the caption? I think you want to insert a reference to a dependent field for a text field master. Does this sound correct? <br>
<br>
The text field master, which is of type: <br>
<br>
com.sun.star.text.fieldmaster.SetExpression.Figure<br>
<br>
But you want to reference a Dependent field. If my guess is correct, this is how I insert a reference to the first Figure using Basic. Note that there is almost no error checking, so, this could go very wrong. <br>
<br>
Sub Main<br>
  Dim oField<br>
  Dim oNewField<br>
  Dim oText<br>
  Dim oCurs<br>
  Dim oReferencedField<br>
  Dim oEnum<br>
  Dim oDispatcher      ' Dispatcher object.<br>
  Dim oFrame<br>
<br>
 ' Setup to perform a dispatch.<br>
  oFrame = ThisComponent.CurrentController.Frame<br>
  oDispatcher = createUnoService("com.sun.star.frame.DispatchHelper")<br>
<br>
  oText = ThisComponent.getText()<br>
  oCurs = ThisComponent.CurrentController.getViewCursor()<br>
<br>
    oEnum = ThisComponent.getTextFields().createEnumeration()<br>
    If Not IsNull(oEnum) Then<br>
    Do While oEnum.hasMoreElements()<br>
<br>
<br>
      oField = oEnum.nextElement()<br>
      'Inspect oField<br>
      If oField.supportsService("com.sun.star.text.TextField.SetExpression") Then<br>
        If oField.VariableName = "Figure" Then<br>
          Print "Found one"<br>
          Exit Do<br>
        End If<br>
      End If<br>
    Loop<br>
  End If<br>
<br>
  ' No error checking, I just assume that I found one. DANGER DANGER DANGER<br>
<br>
<br>
  oNewField = ThisComponent.createInstance("com.sun.star.text.textfield.GetReference")<br>
  oNewField.ReferenceFieldPart = com.sun.star.text.ReferenceFieldPart.CATEGORY_AND_NUMBER<br>
  oNewField.ReferenceFieldSource = com.sun.star.text.ReferenceFieldSource.SEQUENCE_FIELD<br>
  oNewField.SequenceNumber = oField.SequenceValue<br>
  oNewField.SourceName = "Figure"<br>
  oText.insertTextContent(oCurs, oNewField, True)<br>
  <br>
  ' This next part will NOT work until after all of the fields have updated.<br>
  ' So, force an update.<br>
  oDispatcher.executeDispatch(oFrame, ".uno:UpdateFields", "", 0, Array())<br>
End Sub<br>
<br>
<br>
On Thursday, September 05, 2019 10:59 EDT, LORENZO Vincent <<a href="mailto:vincent.lorenzo@cea.fr">vincent.lorenzo@cea.fr</a>> wrote:<br>
 <o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">Hello everybody,<br>
Since my last question, I switched task. Now I come back to my LibreOffice task to resolve my caption problem.<br>
I'm still blocked on this problem. I get a different result compared to my last email, but the reference for the caption is still not found.<br>
I replace Illustration by Figure, but the problem keeps the same.<br>
<br>
I obtain a text:sequence-ref instead of a text:sequence. Does someone know why or which is the API to use to generate a text:sequence...<br>
<br>
My result for the numbering of the caption:<br>
<text:sequence-ref text:reference-format="value" text:ref-name="refFigure0">Erreur : source de la référence non trouvée</text:sequence-ref> (the french text said "reference not found")<br>
<br>
I would like to get :<br>
<text:sequence text:ref-name="refFigure0" text:name="Figure" text:formula="ooow:Figure+1" style:num-format="1">1</text:sequence><br>
<br>
My java code for that :<br>
<br>
Object oReference = xMultiServiceFactory.createInstance("com.sun.star.text.textfield.GetReference");<br>
XPropertySet oReferencePropertySet = UnoRuntime.queryInterface(XPropertySet.class, oReference);<br>
oReferencePropertySet.setPropertyValue("SourceName", "Figure");// I get <text:sequence-ref<br>
oReferencePropertySet.setPropertyValue("ReferenceFieldPart", ReferenceFieldPart.ONLY_SEQUENCE_NUMBER);<br>
oReferencePropertySet.setPropertyValue("ReferenceFieldSource", ReferenceFieldSource.SEQUENCE_FIELD);<br>
oReferencePropertySet.setPropertyValue("SequenceNumber", 0);// (short) 2);//not requireed ?<br>
XTextContent xRef = UnoRuntime.queryInterface(XTextContent.class, oReference);<br>
localCursor.getText().insertTextContent(localCursor, xRef, false);<br>
<br>
Regards,<br>
--<br>
Vincent Lorenzo<br>
<br>
<br>
-----Message d'origine-----<br>
De : LibreOffice <<a href="mailto:libreoffice-bounces@lists.freedesktop.org">libreoffice-bounces@lists.freedesktop.org</a>> De la part de LORENZO Vincent<br>
Envoyé : vendredi 15 février 2019 14:37<br>
À : Kaganski Mike <<a href="mailto:mikekaganski@hotmail.com">mikekaganski@hotmail.com</a>>; Miklos Vajna <<a href="mailto:vmiklos@collabora.com">vmiklos@collabora.com</a>>; sos <<a href="mailto:sos@pmg.be">sos@pmg.be</a>><br>
Cc : <a href="mailto:libreoffice@lists.freedesktop.org">libreoffice@lists.freedesktop.org</a><br>
Objet : [PROVENANCE INTERNET] RE: need help to insert an image with a caption with the Libo java API<br>
<br>
Hello everybody,<br>
I thank you for your answers. Yes I want to add an image with a caption programmatically and I want a caption like this "Illustration 1 : My caption"<br>
To my mind, it would be better/cleaner if I was able to generate the same thing than I do the UI. Thanks to you, I succeed to build the expected structure for the image and to set a text below it, but I still have some problems, mainly with the GetReference.<br>
<br>
The GetReference generates :<br>
<text:reference-ref text:reference-format="text" text:ref-name="refIllustration0">Erreur : source de la référence non trouvée</text:reference-ref> (sorry my Libo is in French, it is written "Sorry : source of the reference not found").<br>
<br>
And I would like to get a text:sequence instead of a text:reference, to get this result:<br>
<text:sequence text:ref-name="refIllustration0" text:name="Illustration" text:formula="ooow:Illustration+1" style:num-format="1">1</text:sequence><br>
<br>
Please, do you know how I can build a text:sequence ?<br>
<br>
Please found in attachment the java code I wrote [1], the expect xml structure [2] and the current xml structure [3].<br>
I know I have some difference between [2] and [3] with the width/height properties and inside the draw frame, but it is not the subject of this thread.<br>
<br>
[1] insertImage.java<br>
[2] expectedResult.xml<br>
[3] currentResult.xml<br>
<br>
In addition, I have more generic question, do you know if it exists a documentation, indicating mapping, between the xml elements and how to get/create them from java ? For example, in xml svg:width is called Height in the java API, and my Textframe becomes
 <draw:text-box...<<br>
<br>
Best regards,<br>
--<br>
Vincent Lorenzo<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
-----Message d'origine-----<br>
De : Kaganski Mike [<a href="mailto:mikekaganski@hotmail.com">mailto:mikekaganski@hotmail.com</a>]<br>
Envoyé : mercredi 13 février 2019 11:42<br>
À : Miklos Vajna <<a href="mailto:vmiklos@collabora.com">vmiklos@collabora.com</a>>; LORENZO Vincent <<a href="mailto:vincent.lorenzo@cea.fr">vincent.lorenzo@cea.fr</a>><br>
Cc : <a href="mailto:libreoffice@lists.freedesktop.org">libreoffice@lists.freedesktop.org</a><br>
Objet : Re: need help to insert an image with a caption with the Libo java API<br>
<br>
On 13.02.2019 12:45, Miklos Vajna via LibreOffice wrote:<br>
> Hi,<br>
><br>
> On Tue, Feb 12, 2019 at 09:27:15AM +0000, LORENZO Vincent <<a href="mailto:vincent.lorenzo@cea.fr">vincent.lorenzo@cea.fr</a>> wrote:<br>
>> I would like to add a caption, to an inserted image in a text<br>
>> document, but I don't find how to do that... Please do you have<br>
>> pointer/documentation for me ?<br>
><br>
> I think captions are just a UI feature. The doc model just stores a<br>
> text frame around the image and the image is followed by the caption itself.<br>
><br>
> (I.e. later it's not possible to reliably detect if some content<br>
> around an image in a frame was created by hand or using the captions<br>
> UI code.)<br>
><br>
> So you can do the same "manually" using the UNO API. When in doubt,<br>
> see what UNO API the ODT import uses to create the doc model based on<br>
> the input markup.<br>
<br>
And actually, if an image is not intended to be floating, but (as seen in majority of cases) is a part of normal text flow, then the frame could be not needed at all - simply add an image anchored as character, then add a paragraph with required style and numbering
 range field, then continue with other paragraphs. This makes the document structure clearer. Just an advise based on own experience.<br>
<br>
--<br>
Best regards,<br>
Mike Kaganski<br>
_______________________________________________<br>
LibreOffice mailing list<br>
<a href="mailto:LibreOffice@lists.freedesktop.org">LibreOffice@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/libreoffice">https://lists.freedesktop.org/mailman/listinfo/libreoffice</a><o:p></o:p></p>
</blockquote>
<p class="MsoNormal"><br>
<br>
<br>
 <o:p></o:p></p>
<p class="MsoNormal"><br>
<br>
<br>
 <o:p></o:p></p>
</div>
</body>
</html>