https://bugs.documentfoundation.org/show_bug.cgi?id=116960

            Bug ID: 116960
           Summary: Fieldmarks can't be enumerated via getTextFields /
                    getBookmarks
           Product: LibreOffice
           Version: 6.0.3.2 release
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: sdk
          Assignee: libreoffice-bugs@lists.freedesktop.org
          Reporter: ttsten...@gmail.com

Description:
Most citation processors (Endnote, Zotero, Mendeley) insert fields into Word
documents to store citation data. Libreoffice repesents these as Fieldmarks
(com.sun.star.text.Fieldmark) and can create them just fine using UNO but not
enumerate them.

Steps to Reproduce:
(see also https://stackoverflow.com/q/49728663/73299,
https://ask.libreoffice.org/en/question/30175/how-access-fieldmarks-with-api/)

1. start libreoffice (libreoffice --writer
--accept="socket,host=localhost,port=2002;urp;")
2. Create a text with a fieldmark:

import uno
from pythonscript import ScriptContext

resolver =
uno.getComponentContext().ServiceManager.createInstance('com.sun.star.bridge.UnoUrlResolver')
# start libreoffice as
# libreoffice --writer --accept="socket,host=localhost,port=2002;urp;"`
client =
resolver.resolve('uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext')

XSCRIPTCONTEXT = ScriptContext(client, None, None)
doc = XSCRIPTCONTEXT.getDocument()

def cursor():
    return doc.getCurrentController().getSelection().getByIndex(0)

t = doc.getText()
# insert text before field
t.insertString(cursor(), 'Fieldmark-Start|', False)

# create the field
field = doc.createInstance('com.sun.star.text.Fieldmark')

fieldcursor = cursor()
# add the String 'Field contents' to the document
fieldcursor.setString('Field contents')

# actually insert the field in the document (linked to the string)
field.attach(fieldcursor)
field.setFieldType('Testfieldtype')
field.setName('Fieldname')

# insert text after the field
t.insertString(cursor(), '|Fieldmark-End', False)

3. try to enumerate all text fields to get the inserted Fieldmark:

XSCRIPTCONTEXT.getDocument().getTextFields()

Actual Results:  
The returned enumeration has no elements

Expected Results:
An enumeration with one element: the just inserted Fieldmark


Reproducible: Always


User Profile Reset: No



Additional Info:


User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:59.0) Gecko/20100101
Firefox/59.0

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
Libreoffice-bugs@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to