Issue 25247 - font changed on import from word
Summary: font changed on import from word
Status: CLOSED FIXED
Alias: None
Product: Writer
Classification: Application
Component: open-import (show other issues)
Version: 680m22
Hardware: All All
: P3 Trivial (vote)
Target Milestone: ---
Assignee: michael.ruess
QA Contact: issues@sw
URL:
Keywords: ms_interoperability
Depends on:
Blocks:
 
Reported: 2004-02-09 12:16 UTC by sforbes
Modified: 2013-08-07 14:42 UTC (History)
4 users (show)

See Also:
Issue Type: PATCH
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
word file (78.00 KB, application/msword)
2004-02-09 12:17 UTC, sforbes
no flags Details
Handles case where the default CTL font is not set (764 bytes, patch)
2006-09-13 12:36 UTC, alan
no flags Details | Diff
test documents (8.49 KB, application/x-compressed)
2006-09-13 12:39 UTC, alan
no flags Details
New patch: checks for CTL font (908 bytes, patch)
2006-11-13 13:03 UTC, alan
no flags Details | Diff
Example Hebrew document where font table[3] isn't Hebrew (30.00 KB, application/msword)
2006-11-13 13:04 UTC, alan
no flags Details
Same patch, but with a null pointer check (920 bytes, patch)
2006-11-13 20:05 UTC, alan
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description sforbes 2004-02-09 12:16:34 UTC
oo 680m22 on windows 2003- when opening the attached word file, all the fonts
changed from miriam to times new roman, althugh I have miriam installed on my
computer.
Comment 1 sforbes 2004-02-09 12:17:16 UTC
Created attachment 12990 [details]
word file
Comment 2 sforbes 2004-02-16 16:26:03 UTC
another example can be seen in the file attached to issue #25561 :
attachment #13198 [details]
Comment 3 sforbes 2004-06-21 15:00:33 UTC
adding dina as cc
Comment 4 sforbes 2004-06-21 15:01:14 UTC
adding dina as cc
Comment 5 Dieter.Loeschky 2004-07-05 11:18:43 UTC
DL->MRU: Could you please handle this?
Comment 6 michael.ruess 2004-07-09 15:11:51 UTC
MRU->MM: The CTL font of the default paragraph style has been imported as "Times
New Roman" instead of "Miriam".
Comment 7 Unknown 2004-07-21 21:42:53 UTC
Please add keywords: ms_interoperability
Comment 8 alan 2004-08-12 11:07:11 UTC
ayaniger -> sforbes

I opened the attached file in MS Word 2002 on XP, copied the document to the
clipboard, pasted it into a new document, and saved it. When I opened the new
document in OOo 1.1.2, Miriam appeared as Miriam, and was not changed to Times
New Roman. Perhaps the problem exists only on certain versions of MS Word. On
which version of MS Word was the attached document "aliza.doc" created?

Alan
Comment 9 alan 2004-08-12 11:11:20 UTC
PS - the "attached file" that I referred to is the file "aliza.doc" that was
previously attached to this issue.
Comment 10 sforbes 2004-08-22 11:41:35 UTC
* the document was sent to me by email- it was probably created with office2k
* the bug is not about copy/paste from word, but about opening the document
directly in OOo.
Comment 11 andreas.martens 2004-12-03 10:55:15 UTC
Set to target OOoLater due to lack of resources.
Comment 12 martin_maher 2005-04-13 17:10:36 UTC
mmaher->flr: Yours I think
Comment 13 Mathias_Bauer 2006-08-30 15:30:39 UTC
assigning to hbrinkm
Comment 14 alan 2006-09-13 12:36:42 UTC
Created attachment 39115 [details]
Handles case where the default CTL font is not set
Comment 15 alan 2006-09-13 12:39:10 UTC
Created attachment 39117 [details]
test documents
Comment 16 alan 2006-09-13 12:42:06 UTC
The problem happens when in Word the CTL font is not changed from the default in
the base style. When Word sees this, it acts as if no CTL font at all was set in
the base style, and instead relies on the fourth font in the document's font
table (in this case Miriam) as a default CTL font for Hebrew. Word does not
write a 0x4a5e parameter for the base style in this case. (It *does* write one
if the font is changed to anything else.) Since the document contains no CTL
font setting for the base style, this misleads OOo. When OOo imports the
document, it does not see a font set for the base style, so it uses its own
default CTL font, which may or may not be Miriam.

The attached patch checks if the default CTL font was not set, and if so, sets
the default CTL font to be the fourth entry in the document's font table. 

I am also attaching documents used for testing this bug.
i25247_aliza_test.doc is a shortened form of the original document submitted by
the reporter,  sforbes.
i25247_aliza_test_david.doc has the CTL font in the base style changed to David.
If you hex dump this file, you'll notice that there is an extra x4a5E parameter.
i25247_aliza_test_poked.doc has the name “Miriam†in the font table modified by
a hex editor to be named “Niriamâ€. In this case, Word uses a fallback font, “Arialâ€.

Caolan McNamara provided an enormous amount of help with this. For more details,
see the discussion between Caolan and myself at :
http://sw.openoffice.org/servlets/BrowseList?list=dev&by=thread&from=1496917

Comment 17 alan 2006-09-13 12:43:51 UTC
There may also be a need to make a similar check for CJK fonts, and add to the code:
if (ftcStandardChpCJKStsh == 0)
	ftcStandardChpCJKStsh = 2;

However, I did not check this.
Comment 18 openoffice 2006-11-06 10:21:27 UTC
patch applied and approved
Comment 19 alan 2006-11-13 13:01:34 UTC
I found that for certain documents, font number 3 in the font table was a
Chinese font, SimSun. Because of this, the previous patch caused documents that
would have otherwise been imported properly to be displayed in a Chinese font.
To avoid this, I'm posting a new patch that adds a check to make sure that font
number 3 is in fact Hebrew. (Is there a simple way to generalize this for all
CTL languages?) Apparently, different versions of Word have different ways of
writing  CTL fonts in the font table.
Comment 20 alan 2006-11-13 13:03:12 UTC
Created attachment 40544 [details]
New patch: checks for CTL font
Comment 21 alan 2006-11-13 13:04:42 UTC
Created attachment 40545 [details]
Example Hebrew document where font table[3] isn't Hebrew
Comment 22 alan 2006-11-13 20:05:42 UTC
Created attachment 40556 [details]
Same patch, but with a null pointer check
Comment 23 openoffice 2006-11-21 08:50:08 UTC
fixed 
Comment 24 openoffice 2006-11-27 09:19:49 UTC
ready for QA
Comment 25 michael.ruess 2006-12-07 18:35:11 UTC
Verified fix in CWS docstatfix.
Comment 26 michael.ruess 2007-02-15 11:33:37 UTC
Checked fix in OO 2.2 rc build OOF680m7.