<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:x="urn:schemas-microsoft-com:office:excel" 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:"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;
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        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;
        color:black;}
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";
        color:black;}
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:11.0pt;
        font-family:"Calibri",sans-serif;
        color:windowtext;
        mso-fareast-language:EN-US;}
span.PrformatHTMLCar
        {mso-style-name:"Préformaté HTML Car";
        mso-style-priority:99;
        mso-style-link:"Préformaté HTML";
        font-family:Consolas;
        color:black;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.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:1391076957;
        mso-list-type:hybrid;
        mso-list-template-ids:1470790630 1911054456 67895321 67895323 67895311 67895321 67895323 67895311 67895321 67895323;}
@list l0:level1
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:53.25pt;
        text-indent:-35.25pt;}
@list l0:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level5
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level8
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
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 bgcolor="white" lang="FR" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" 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" style="text-indent:35.4pt"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">I thank you for your anwsers. I will continue with Bookmark which seem me quite easy to implement.
<o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:35.4pt"><span lang="EN-US" 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-indent:35.4pt"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">I found a way to avoid to search the text in the document:
<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas">            
</span><b><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas;color:#7F0055">short</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas">
</span><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">value</span><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas"> = ((Integer)
</span><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">text</span><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas">.length()).shortValue();</span><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas;color:windowtext"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas">            
</span><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas;color:#0000C0">cursor.setString(</span><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas">text);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:35.4pt"><span style="font-size:10.0pt;font-family:Consolas">      
</span><span style="font-size:10.0pt;font-family:Consolas;color:#0000C0">cursor</span><span style="font-size:10.0pt;font-family:Consolas">.gotoEnd(</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">);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:35.4pt"><span lang="EN-US" 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 lang="EN-US" style="font-size:10.0pt;font-family:Consolas">            
</span><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas;color:#0000C0">cursor</span><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas">.goLeft(</span><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas;color:#6A3E3E">value</span><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas">,
</span><b><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas;color:#7F0055">false</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas">);</span><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas;color:windowtext"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas">            
<i>InsertBookmark</i>(</span><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas;color:#0000C0">odtEditor</span><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas">.getXTextDocument(),
</span><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas;color:#0000C0">cursor</span><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas">,
</span><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"muBookmarkName"</span><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas">);</span><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas;color:windowtext"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:35.4pt"><span style="font-size:10.0pt;font-family:Consolas">      
</span><span style="font-size:10.0pt;font-family:Consolas;color:#0000C0">cursor</span><span style="font-size:10.0pt;font-family:Consolas">.gotoEnd(</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">);</span><span lang="EN-US" 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-indent:35.4pt"><span lang="EN-US" 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-indent:35.4pt"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">It seems work find.
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" 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 lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">/Vincent<o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:35.4pt"><span lang="EN-US" 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;color:windowtext">De :</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext"> LibreOffice [mailto:libreoffice-bounces@lists.freedesktop.org]
<b>De la part de</b> sos<br>
<b>Envoyé :</b> vendredi 11 janvier 2019 10:36<br>
<b>À :</b> libreoffice@lists.freedesktop.org<br>
<b>Objet :</b> Re: need advices and help about Bookmark API.<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p>Hallo,<br>
We did some test to use RDF (also Miklos his advice) to store some information about images in a Writerdoc, before we stored the information in the ImageObject , what was not a good idea.<br>
Greetz<br>
Fernand<o:p></o:p></p>
<p>below the code who works well<o:p></o:p></p>
<p style="margin-bottom:12.0pt">const BASE_TYPE = <a href="http://PMGopmaak.writer/Allgraphics">
"http://PMGopmaak.writer/Allgraphics"</a><br>
const TYPE_NAME = "GraphicURL"<br>
<br>
const FILE_NAME = "PMGopmaak.writer/Allgraphics.rdf"<br>
<br>
<br>
Sub StoreRDF<br>
  RemoveRDF()<br>
  <br>
  ' "graph" staat hier niet voor een graphic maar voor een ellement die data kan omschrijven en stockeren<br>
  ' een "litera" is een string die we stockeren en kunnen opvragen <br>
  doc = ThisComponent<br>
  repo = doc.getRDFRepository()<br>
  type_uri = GetTypeURI()<br>
  graph_name = doc.addMetadataFile(FILE_NAME, Array(type_uri))<br>
  named_graph = repo.getGraph(graph_name)<br>
  <br>
  value_uri = CreateURI(com.sun.star.rdf.URIs.RDF_VALUE)<br>
  <br>
 <br>
  <br>
  if doc.supportsService("com.sun.star.text.TextDocument") then<br>
    <br>
   oDocGraphics = doc.GraphicObjects<br>
 <br>
    vAlleFotos = oDocGraphics.getElementNames()<br>
            aantal = oDocGraphics.count<br>
             For iG = 0 to aantal - 1 <br>
            iFotNr = ig + 1<br>
             '   sFotMetNr = vAlleFotos(iG)<br>
                oGraphic1 = oDocGraphics.GetbyIndex(ig)<br>
  named_graph.addStatement(CreateURI(oGraphic1.Name &":", "URL"),value_uri,CreateLiteral(Ographic1.Title))<br>
  named_graph.addStatement(CreateURI(oGraphic1.Name &":", "ONDERSCHRIFT"),value_uri,CreateLiteral(Ographic1.Hyperlinkname))<br>
 <br>
  next IG <br>
<br>
  End If<br>
  <br>
  doc.setModified(True)<br>
End Sub<br>
<br>
Sub ReadRDF()<br>
zoek = "Image1:URL"<br>
  doc = ThisComponent<br>
  repo = doc.getRDFRepository()<br>
 <br>
  type_uri = GetTypeURI()<br>
<br>
  graph_names = doc.getMetadataGraphsWithType(type_uri)<br>
<br>
  If ubound(graph_names) = -1 then exit sub<br>
  <br>
  graph_name = graph_names(0)<br>
  <br>
  named_graph = repo.getGraph(graph_name)<br>
  value_uri = CreateURI(com.sun.star.rdf.URIs.RDF_VALUE)<br>
 <br>
 ' named_graph.clear<br>
  enume = named_graph.getStatements(Null, value_uri, Null)<br>
 ' xray named_graph.getStatements(null, value_uri, Null)<br>
  s = ""<br>
   Do while Enume.hasMoreElements <br>
    st = enume.nextElement()<br>
     name = st.Subject.StringValue<br>
       sts = st.Object.StringValue<br>
    s = s & name & ": " & sts & chr(10)<br>
    print name<br>
   ' if name = zoek  then<br>
   ' print sts<br>
  ' named_graph.removeStatements(st.Subject, value_uri,st.Object)<br>
   ' exit do<br>
  ' endif<br>
 loop<br>
<br>
  msgbox s<br>
End Sub<br>
<br>
<br>
Sub RemoveRDF<br>
  doc = ThisComponent<br>
  repo = doc.getRDFRepository()<br>
  <br>
  type_uri = GetTypeURI()<br>
  graph_names = doc.getMetadataGraphsWithType(type_uri)<br>
  if ubound(graph_names) = -1 then exit sub<br>
  graph_name = graph_names(0)<br>
  doc.removeMetadataFile(graph_name)<br>
  doc.setModified(True)<br>
End Sub<br>
<br>
<br>
Function GetTypeURI() As variant<br>
  GetTypeURI = CreateURI(BASE_TYPE & "/" & TYPE_NAME)<br>
End Function<br>
<br>
<br>
Function CreateURI(n, Optional l) As Variant<br>
  If IsMissing(l) Then<br>
    a = Array(n)<br>
  Else<br>
    a = Array(n, l)<br>
  End If<br>
  uri = CreateUnoServiceWithArguments("com.sun.star.rdf.URI", a)<br>
  CreateURI = uri<br>
End Function<br>
<br>
Function CreateLiteral(v) As Variant<br>
  a = Array(v)<br>
  literal = CreateUnoServiceWithArguments("com.sun.star.rdf.Literal", a)<br>
  CreateLiteral = literal<br>
End Function<br>
<br>
<br>
<br>
<o:p></o:p></p>
<p><o:p> </o:p></p>
<div>
<p class="MsoNormal">On 1/11/2019 9:27 AM, Miklos Vajna wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<pre>Hi Vincent,<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>On Thu, Jan 10, 2019 at 02:13:58PM +0000, LORENZO Vincent <a href="mailto:vincent.lorenzo@cea.fr"><vincent.lorenzo@cea.fr></a> wrote:<o:p></o:p></pre>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<pre>Question 1:<o:p></o:p></pre>
<pre>Currently we are studying the possibility to use the Bookmark field's name to store these datas. We want to use the Bookmark with start and end tag, to get something like that.<o:p></o:p></pre>
<pre><text:bookmark-start text:name="UML_element_qualified_name_and_others_useful_informations" /><o:p></o:p></pre>
<pre>              Some text<o:p></o:p></pre>
<pre>       <text:bookmark-end text:name=" UML_element_qualified_name_and_others_useful_informations " /><o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>In reality, I would prefer to be able to use a more structured datas, extending the Bookmark object (or using another solution ? ) to get that, something like that:<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>       <text:bookmark-start text:name="Bookmark1" umlElementQualifiedName="Package1::Class1" umlElementKind="Class" umlElementfeature="name" id="xxx"/><o:p></o:p></pre>
<pre>                           Some text<o:p></o:p></pre>
<pre>       <text:bookmark-end text:name="Bookmark1" /><o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>but I have no idea if it is possible and how to do that. Please, does someone have an idea to structure my datas ?<o:p></o:p></pre>
<pre>Of course, if you have a better solution than Bookmark, fell free to propose it.<o:p></o:p></pre>
</blockquote>
<pre><o:p> </o:p></pre>
<pre>Bookmark is just a string; one hack you can do is to give it a unique<o:p></o:p></pre>
<pre>name, which refers to a per-document custom metadata, where the value<o:p></o:p></pre>
<pre>disturbs the user less. But that's still just a string, so you need to<o:p></o:p></pre>
<pre>serialize/load to/from string if you want to store key-value pairs.<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>An alternative is to use RDF annotations, which allows more complex<o:p></o:p></pre>
<pre>structures:<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre><a href="https://wiki.openoffice.org/wiki/Documentation/DevGuide/OfficeDev/RDF_metadata">https://wiki.openoffice.org/wiki/Documentation/DevGuide/OfficeDev/RDF_metadata</a><o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>(Though you need to use archive.org or something like that to access it,<o:p></o:p></pre>
<pre>seems the Apache site is currently not available.)<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>One shortcoming of RDF is that it's ODF-only; while the per-doc custom<o:p></o:p></pre>
<pre>metadata + bookmarks works with most other formats as well.<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<pre>So, in this example, I write text, I look for it, then I create a XTextRange and at the end, I can create the Bookmark. I'm not very have happy with this solution. I would prefer a solution without the search step, but I don't know how to get a valid XTextRange (I admit I don't yet well understand  the behavior of the API).<o:p></o:p></pre>
<pre>Please, do you have some pointer or code example ?<o:p></o:p></pre>
</blockquote>
<pre><o:p> </o:p></pre>
<pre>Some kind of iteration or search is necessary: if you take the user's<o:p></o:p></pre>
<pre>current selection or you iterate to the nth paragraph or you search for<o:p></o:p></pre>
<pre>text is up to you. An XTextRange is just a selection (where start and<o:p></o:p></pre>
<pre>end may point to the same document model position).<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<pre>I thank you to read me until here.<o:p></o:p></pre>
</blockquote>
<pre><o:p> </o:p></pre>
<pre>Hope this helps. :-)<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>Regards,<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>Miklos<o:p></o:p></pre>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>LibreOffice mailing list<o:p></o:p></pre>
<pre><a href="mailto:LibreOffice@lists.freedesktop.org">LibreOffice@lists.freedesktop.org</a><o:p></o:p></pre>
<pre><a href="https://lists.freedesktop.org/mailman/listinfo/libreoffice">https://lists.freedesktop.org/mailman/listinfo/libreoffice</a><o:p></o:p></pre>
</blockquote>
</div>
</body>
</html>