When a new style is applied to a paragraph, it will delete index entries, meta-fields and user-defined-attributes. As I was looking for a workaround for cross-references on linked files (which are also broken), I came across this behaviour: To reproduce the bug: 1) Insert an index entry inside LO. 2) Insert a meta-field (python): ctx = uno.getComponentContext() desktop = ctx.ServiceManager.createInstanceWithContext( "com.sun.star.frame.Desktop", ctx) doc = desktop.getCurrentComponent() vc = doc.CurrentController.ViewCursor field = doc.createInstance('com.sun.star.text.InContentMetadata') # or: field = doc.createInstance('com.sun.star.text.textfield.MetadataField') doc.Text.insertTextContent(vc, field, True) 3) insert a user-defined-attribute: from com.sun.star.xml import AttributeData attrib = AttributeData() attrib.Type = 'CDATA' attrib.Value = 'something' txt_user_attr = vc.TextUserDefinedAttributes txt_user_attr.insertByName('some_attrib', attrib) vc.TextUserDefinedAttributes = txt_user_attr After that, the content.xml inside the .odt file looks like this: <text:p text:style-name="P1"> <text:user-index-mark-start text:id="IMark152381916" text:index-name="User-Defined" text:outline-level="1"/> this goes to the index <text:user-index-mark-end text:id="IMark152381916"/> </text:p> <text:p text:style-name="P1"> <text:meta xml:id="id1002081541">surrounded by meta-field</text:meta> </text:p> <text:p text:style-name="P1"> <text:span text:style-name="T1">attributed text</text:span> </text:p> And the style "T1" shows: <style:style style:name="T1" style:family="text"> <style:text-properties some_attribute="something"/> </style:style> After applying the standard style, content.xml is changed to: <text:p text:style-name="Standard">this goes to the index</text:p> <text:p text:style-name="Standard">surrounded by meta-field</text:p> <text:p text:style-name="Standard">attributed text</text:p> The style entry is still present, but it's not in use anymore. As the user-defined-attribute is done by a style setting, I can understand, why it gets broken. But in this way it can't reliable be used by a developer, as one can't foresee, if the user is going to change a style. This bug might be related to bug #87036 https://bugs.documentfoundation.org/show_bug.cgi?id=87036
A reference field set by the user also gets deleted. ( Insert/Cross-Reference/References/Set Reference ) In my opinion that's a serious bug. Guess one writes a scientific work and after finishing and doing some layout, all his index entries and user references are gone. Tried on win7 LO 5.0.4.2 64bit and Fedora 22 xfce 4.12 with LO 5.0.2.2 64bit
Please attach a sample file that gets us at least through step 2. Marking as NEEDINFO -> once you attach a useful/simple test file please set to UNCONFIRMED> Thanks.
Created attachment 122569 [details] create meta field and user-defined-attribute create_fields(): Creates a metafield and a user-defined-attribute. show_content_xml(): Shows content.xml of .odt file in a webbrowser Save script to LO script folder and start methods as a makro.
(In reply to Joel Madero from comment #2) > Please attach a sample file that gets us at least through step 2. Marking as > NEEDINFO -> once you attach a useful/simple test file please set to > UNCONFIRMED> Thanks. There might be two different issues. Sorry for setting more than one issue into this bug report. I thought they were related. Issue 1: Create a index entry and a reference field ( Insert/Cross-Reference/References/Set Reference ) Set a new style. Index entry and reference field will be gone. Issue 2: I attached a python file as I can't include it in an .odt. Set it into the script folder. Start a new document and save it. Start create_fields() from the script. Save the document. Have a look at content.xml (You can use show_content_xml() from the script) Set a new style to all. Save the document. Look at content.xml As I examined it further, I found this behaviour: A paragraph containing nothing else than a text nested by a meta field or user-defined-attribute will be break the field and the attribute, when you set a new style to it. When the paragraph contains something else, field and attribute will be kept.
(In reply to Xaver from comment #4) > (In reply to Joel Madero from comment #2) > > Please attach a sample file that gets us at least through step 2. Marking as > > NEEDINFO -> once you attach a useful/simple test file please set to > > UNCONFIRMED> Thanks. > > There might be two different issues. Sorry for setting more than one issue > into this bug report. I thought they were related. > > Issue 1: > > Create a index entry and a reference field ( > Insert/Cross-Reference/References/Set Reference ) > Set a new style. > Index entry and reference field will be gone. Reproduced. Win 7 Pro 64-bit Version: 5.2.0.0.alpha0+ Build ID: a6f876d45bd4e41a7143594a6cb11b6893a0f620 CPU Threads: 4; OS Version: Windows 6.1; UI Render: default; TinderBox: Win-x86@39, Branch:master, Time: 2016-02-11_00:07:38 Locale: fi-FI (fi_FI)
with comment #4 it's a duplicate of bug 94449 *** This bug has been marked as a duplicate of bug 94449 ***