Bug 97734 - FORMATTING: Applying a new style breaks index entries, meta fields and user defined attributes
Summary: FORMATTING: Applying a new style breaks index entries, meta fields and user d...
Status: RESOLVED DUPLICATE of bug 94449
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
5.0.4.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2016-02-11 07:49 UTC by Xaver
Modified: 2016-05-09 13:03 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
create meta field and user-defined-attribute (2.87 KB, text/plain)
2016-02-12 10:29 UTC, Xaver
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Xaver 2016-02-11 07:49:17 UTC
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
Comment 1 Xaver 2016-02-11 19:53:42 UTC
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
Comment 2 Joel Madero 2016-02-12 06:33:06 UTC
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.
Comment 3 Xaver 2016-02-12 10:29:05 UTC
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.
Comment 4 Xaver 2016-02-12 10:32:50 UTC
(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.
Comment 5 Buovjaga 2016-02-16 08:47:29 UTC
(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)
Comment 6 Michael Stahl (CIB) 2016-05-09 13:03:30 UTC
with comment #4 it's a duplicate of bug 94449

*** This bug has been marked as a duplicate of bug 94449 ***