Bug 476959

Summary: [fix available] Table of Contents level not correctly exported and imported to/from .doc
Product: Red Hat Enterprise Linux 5 Reporter: Toralf <bugzilla>
Component: openoffice.orgAssignee: Caolan McNamara <caolanm>
Status: CLOSED ERRATA QA Contact: desktop-bugs <desktop-bugs>
Severity: medium Docs Contact:
Priority: low    
Version: 5.2CC: llim
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-09-02 09:09:08 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Example doc file
none
Another example
none
patch for this problem none

Description Toralf 2008-12-18 10:10:29 UTC
Description of problem:
A table of contents read from a .doc file will always have the value for "Evaluate up to level" set to 9, regardless of what is stored in the file 

Version-Release number of selected component (if applicable):
2.3.0-6.5.4.el5_2

How reproducible:
Every time

Steps to Reproduce:
1. Create a new text document.
2. Select "Heading 1" from the paragraph style menu, then enter a short line of text.
3. Select Insert->Indexes and Tables...->Indexes and Tables...
4. Under "Create index/table", change the value for "Evaluate up to level" from 10 (the default) to 3. Then select OK (you now get an empty table of contents.)
5. Select File->Save, display the File Type list, select "Microsoft Word 97/2000/XP."
6. Enter a file name, then press Save.
7. Exit openoffice.org
8. Restart, then open the file you just saved.
9. Right-click on the table of context field, then select "Edit index/table".
  
Actual results:
Value of "Evaluate up to level" under "Create index/table" is 9.

Expected results:
Value of "Evaluate up to level" under "Create index/table" is 3.

Additional info:
This also happens when creating a file with MS Word, setting a similar option for index level.

When opening the above mentioned file in MS Word, the level setting is actually correct (i.e. the value is 3.)

Comment 1 Caolan McNamara 2008-12-18 18:19:41 UTC
Looks like something came unstuck quite a while ago around this area.

Comment 2 Caolan McNamara 2008-12-22 12:00:19 UTC
Ok, got a patch for the problems I see here on .doc export and .doc import. Just to be sure though I've tackled all the reported problems you mention "this also happens when creating a file with MS Word, setting a similar option for index level", can you attach such a sample document to avoid disappointment.

Comment 3 Toralf 2009-01-05 07:16:42 UTC
Created attachment 328175 [details]
Example doc file

OK. Here is a file at last.

But actually, I'm a bit confused now, as I see the value 10 in OOo in this case, where I get 9 with some other files. The expected setting is 3, however.

Comment 4 Toralf 2009-01-05 07:18:25 UTC
Created attachment 328176 [details]
Another example

Here is another file, where I see 9 in the levels field.

Comment 5 Toralf 2009-01-05 07:19:26 UTC
Both attached files are created using MS Word, but the last one has also been saved with OOo.

Comment 6 Caolan McNamara 2009-01-05 10:55:32 UTC
in #4 "TOCTST.DOC" the msword field code is TOC \o "1-9" \t "Heading 9,9,Heading 8,8,Heading 7,7,Heading 6,6,Heading 5,5,Heading 4,4,Heading 3,3,Heading 2,2,Heading 1,1" \h

i.e. make a toc from the outline levels 1 to 9 and from styles Heading 1 to Heading 9 assigning Heading 1 to 1, Heading 2 to 2 etc. The use of both \o and \t is a bit redundant and was likely exported from writer, the above patch would cleans up that sort of thing on initial export.

Anyway, given the .doc as it is, on loading this into word or writer then 1 to 9 is the correct setting, so that works fine in word and writer.

In #3 "TOCTST3.DOC" the code is TOC \o i.e. "make it from all outline styles" writer has 10 such styles, and word has 9 which is why there is the difference. Because word has only 9 styles we should always import that bare "use all outline styles" as evaluate up to level 9 rather than leaving it at our writer default of 10. So I've updated the patch to handle that clip to 9 levels on import rather than 10.

In either case though the msword field refers to *9* outline levels, not three. Though the msword UI itself might give the impression in the toc dialog that there are three levels, there really are nine. 

So I'm confident that the major problem is in the export, with only a little problem in the import and that the new patch "does the right thing"

Comment 7 Caolan McNamara 2009-01-05 10:55:59 UTC
Created attachment 328181 [details]
patch for this problem

Comment 8 Caolan McNamara 2009-03-12 11:15:14 UTC
committed to >= 2.3.0-6.11

Comment 12 errata-xmlrpc 2009-09-02 09:09:08 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2009-1248.html