Bug 116960 - Fieldmarks can't be enumerated via getTextFields / getBookmarks
Summary: Fieldmarks can't be enumerated via getTextFields / getBookmarks
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: sdk (show other bugs)
Version:
(earliest affected)
6.0.3.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL: https://stackoverflow.com/a/49735882/...
Whiteboard:
Keywords:
Depends on:
Blocks: Fields
  Show dependency treegraph
 
Reported: 2018-04-12 07:25 UTC by Tristan Stenner
Modified: 2023-04-05 03:23 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tristan Stenner 2018-04-12 07:25:01 UTC
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
Comment 1 Buovjaga 2018-04-22 14:30:34 UTC
(In reply to Tristan Stenner from comment #0)
> XSCRIPTCONTEXT.getDocument().getTextFields()

I guess I could repro the bad result:
pyuno object (com.sun.star.container.XEnumerationAccess)0x7fa538061728{implementationName=SwXTextFieldTypes, supportedServices={com.sun.star.text.TextFields}, supportedInterfaces={com.sun.star.container.XEnumerationAccess,com.sun.star.lang.XServiceInfo,com.sun.star.util.XRefreshable,com.sun.star.lang.XTypeProvider,com.sun.star.uno.XWeak}}

Arch Linux 64-bit
Version: 6.1.0.0.alpha0+
Build ID: de07f40030bbd604bc42d58f0e954cca284a2646
CPU threads: 8; OS: Linux 4.16; UI render: default; VCL: kde4; 
Locale: fi-FI (fi_FI.UTF-8); Calc: group
Built on April 21st 2018
Comment 2 QA Administrators 2021-04-04 04:00:12 UTC Comment hidden (obsolete)
Comment 3 QA Administrators 2023-04-05 03:23:52 UTC
Dear Tristan Stenner,

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/

If the bug is present, please leave a comment that includes the information from Help - About LibreOffice.
 
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice.

Please DO NOT

Update the version field
Reply via email (please reply directly on the bug tracker)
Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not 
appropriate in this case)


If you want to do more to help you can test to see if your issue is a REGRESSION. To do so:
1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug
3. Leave a comment with your results.
4a. If the bug was present with 3.3 - set version to 'inherited from OOo';
4b. If the bug was not present in 3.3 - add 'regression' to keyword


Feel free to come ask questions or to say hello in our QA chat: https://web.libera.chat/?settings=#libreoffice-qa

Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team

MassPing-UntouchedBug