<html>
    <head>
      <base href="https://bugs.documentfoundation.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_UNCONFIRMED "
   title="UNCONFIRMED - Fieldmarks can't be enumerated via getTextFields / getBookmarks"
   href="https://bugs.documentfoundation.org/show_bug.cgi?id=116960">116960</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Fieldmarks can't be enumerated via getTextFields / getBookmarks
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>LibreOffice
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>6.0.3.2 release
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>UNCONFIRMED
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>sdk
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>libreoffice-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>ttstenner@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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 <a href="https://stackoverflow.com/q/49728663/73299">https://stackoverflow.com/q/49728663/73299</a>,
<a href="https://ask.libreoffice.org/en/question/30175/how-access-fieldmarks-with-api/">https://ask.libreoffice.org/en/question/30175/how-access-fieldmarks-with-api/</a>)

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</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>