Bug 33478 - [FILESAVE] bad rtf when save with ru_RU locale
Summary: [FILESAVE] bad rtf when save with ru_RU locale
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
(earliest affected)
3.3.0 release
Hardware: x86 (IA32) Linux (All)
: medium normal
Assignee: Miklos Vajna
Depends on:
Reported: 2011-01-25 08:30 UTC by Alex B
Modified: 2012-03-17 16:14 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:

rtf saved with ru_RU locale (1.62 KB, application/rtf)
2011-01-25 08:30 UTC, Alex B
Test document containing a style named "x{y" (8.52 KB, application/vnd.oasis.opendocument.text)
2011-01-25 16:53 UTC, Miklos Vajna
Patch fixing the style name escape part of the issue (1020 bytes, patch)
2011-01-25 17:33 UTC, Miklos Vajna
Test doc reproducing the second part (8.51 KB, application/vnd.oasis.opendocument.text)
2011-01-25 19:24 UTC, Miklos Vajna

Note You need to log in before you can comment on or make changes to this bug.
Description Alex B 2011-01-25 08:30:51 UTC
Created attachment 42470 [details]
rtf saved with ru_RU locale

1) Start Writer with ru_RU locale

2) Type something like 'Тест'

3) Save as rtf

4) Try to open rtf file, you will get 'General Error. General input/output error.'

If save file with en_US or C locale it opens without error but non-ascii characters changed. E.g. 'Òåñò' instead expected 'Тест'.

Rtf files created by OO 3.2 opens just fine.
Comment 1 Noel Power 2011-01-25 11:09:38 UTC
Miklos for you I think
Comment 2 Miklos Vajna 2011-01-25 16:53:19 UTC
Created attachment 42498 [details]
Test document containing a style named "x{y"

The general error part is caused by an unescaped { in the stylesheet group. I'm attaching a simple English document reproducing the issue in a locale-independent way.
Comment 3 Miklos Vajna 2011-01-25 17:33:59 UTC
Created attachment 42499 [details]
Patch fixing the style name escape part of the issue
Comment 4 Miklos Vajna 2011-01-25 19:24:02 UTC
Created attachment 42501 [details]
Test doc reproducing the second part

The problem seems to be that with an empty locale only 5 fonts are printed in the font table, the 6th one is added to it during the export, so \f6 is used, but it'll point to nowhere. Now the interesting fact is that wwFontHelper::InitFontTable() already preloads fonts for RTF, but in case locale is empty, the 6th one will be missing there - which is strange, since later the font is referred by RtfAttributeOutput::CharFont(), which is called for each RES_CHRATR_FONT (but ideally InitFontTable() already printed those).

So what I can imagine is that the SfxItemPool gets modified and a new RES_CHRATR_FONT gets added somewhere but from a quick look I don't see where that would happen.

To sum up - no idea what's going on - yet. :)
Comment 5 Miklos Vajna 2011-01-25 19:49:51 UTC
OK after some poking in gdb, it turns out that SwWW8AttrIter::OutAttr() is the strange caller (at the very end of the function). The question: is there any easy way to search for those fonts in the document model before starting the export? (Provided that we have access to rDoc.GetAttrPool()).
Comment 6 Miklos Vajna 2011-01-26 06:09:56 UTC
After dicussing with caolan on IRC, this is fixed in master with commit a37fae128b4badc8f9f2201e28dca3e08948ddec in writer.git.
Comment 7 Jean-Baptiste Faure 2012-03-17 16:14:25 UTC
Fixed a typo in the summary FILESAFE -> FILESAVE
RTF written by LO 3.4 and 3.5 does not show the bug. Closing