Hi Vincent,

On Thu, Jan 10, 2019 at 02:13:58PM +0000, LORENZO Vincent 
<vincent.lore...@cea.fr> wrote:
> Question 1:
> 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.
> <text:bookmark-start 
> text:name="UML_element_qualified_name_and_others_useful_informations" />
>               Some text
>        <text:bookmark-end text:name=" 
> UML_element_qualified_name_and_others_useful_informations " />
> 
> 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:
> 
>        <text:bookmark-start text:name="Bookmark1" 
> umlElementQualifiedName="Package1::Class1" umlElementKind="Class" 
> umlElementfeature="name" id="xxx"/>
>                            Some text
>        <text:bookmark-end text:name="Bookmark1" />
> 
> but I have no idea if it is possible and how to do that. Please, does someone 
> have an idea to structure my datas ?
> Of course, if you have a better solution than Bookmark, fell free to propose 
> it.

Bookmark is just a string; one hack you can do is to give it a unique
name, which refers to a per-document custom metadata, where the value
disturbs the user less. But that's still just a string, so you need to
serialize/load to/from string if you want to store key-value pairs.

An alternative is to use RDF annotations, which allows more complex
structures:

https://wiki.openoffice.org/wiki/Documentation/DevGuide/OfficeDev/RDF_metadata

(Though you need to use archive.org or something like that to access it,
seems the Apache site is currently not available.)

One shortcoming of RDF is that it's ODF-only; while the per-doc custom
metadata + bookmarks works with most other formats as well.

> 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).
> Please, do you have some pointer or code example ?

Some kind of iteration or search is necessary: if you take the user's
current selection or you iterate to the nth paragraph or you search for
text is up to you. An XTextRange is just a selection (where start and
end may point to the same document model position).

> I thank you to read me until here.

Hope this helps. :-)

Regards,

Miklos

Attachment: signature.asc
Description: Digital signature

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

Reply via email to