Bug Hunting Session
Bug 58076 - RTF FILEOPEN import result 2 pages (1 page in LO 3.4)
Summary: RTF FILEOPEN import result 2 pages (1 page in LO 3.4)
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.0.0.0.beta2
Hardware: All All
: high normal
Assignee: Miklos Vajna
URL:
Whiteboard: target:4.1.0 target:4.0.0.1
Keywords: filter:rtf, regression
Depends on:
Blocks:
 
Reported: 2012-12-10 11:15 UTC by VX
Modified: 2015-12-17 12:08 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
LO 4.0.0.0b1 fails to open this RTF, wrong formating in erlier LO versions (670.21 KB, application/rtf)
2012-12-10 11:15 UTC, VX
Details
RTF Filter bug_Regression_LO Writer 4.0.0beta2_screenshots (107.58 KB, application/zip)
2012-12-22 13:03 UTC, VX
Details
LO Writter 3.6.4 look for comparison porpuses (53.02 KB, image/png)
2012-12-22 15:43 UTC, VX
Details
Bug is partially fixed in the current daily build (31.37 KB, image/png)
2012-12-28 20:05 UTC, VX
Details

Note You need to log in before you can comment on or make changes to this bug.
Description VX 2012-12-10 11:15:22 UTC
Created attachment 71263 [details]
LO 4.0.0.0b1 fails to open this RTF, wrong formating in erlier LO versions

I've installed LibreOffice 4.0.0.0beta 1 version on Windows 7 64bit (Polish) to check some RTF files that were opened with with a lot of formating issues in erlier LibreOffice versions (LO 3.4.x, LO 3.5.x and LO 3.6.x).

To my surprise new LO Writer 4.0.0.0beta1 doesn't open such RTF files at all!
 
I've added an example RTF file as an attachment to verify this. Unfortunatelly, I'm not the one who created this file. I suppose it was created with a Russian version of MS Office. 

It was used as a template in the company with various LO versions. Erlier versions of LO (before 4.0.0.0 beta 1) can always open this file, but everytime there were some formating issues with it, so I marked this bug as a regression.
Comment 1 s-joyemusequna 2012-12-11 08:05:09 UTC
Confirmed with Windows XP and Vista64. "General Error. General input/output error."
Comment 2 Michael Meeks 2012-12-13 14:56:23 UTC
Stack trace shows simple null-ptr de-reference:

Program received signal SIGSEGV, Segmentation fault.
0xad40424c in SdrObject::ApplyNotPersistAttr (this=0x0, rAttr=...) at /data/opt/libreoffice/master/svx/source/svdraw/svdobj.cxx:2024
2024	    Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
(gdb) bt
#0  0xad40424c in SdrObject::ApplyNotPersistAttr (this=0x0, rAttr=...) at /data/opt/libreoffice/master/svx/source/svdraw/svdobj.cxx:2024
#1  0xad4d7ae0 in SvxShape::ObtainSettingsFromPropertySet (this=0xae0b3d8, rPropSet=...)
    at /data/opt/libreoffice/master/svx/source/unodraw/unoshape.cxx:674
#2  0xad4dd0df in SvxShape::Create (this=0xae0b3d8, pNewObj=0xae0ab68) at /data/opt/libreoffice/master/svx/source/unodraw/unoshape.cxx:450
#3  0xad4dd1de in SvxShapeText::Create (this=0xae0b3d8, pNewObj=0xae0ab68, pNewPage=0x9227f58)
    at /data/opt/libreoffice/master/svx/source/unodraw/unoshape.cxx:4022
#4  0xad4c0d1e in SvxCustomShape::Create (this=0xae0b3d8, pNewObj=0xae0ab68, pNewPage=0x9227f58)
    at /data/opt/libreoffice/master/svx/source/unodraw/unoshap2.cxx:1733
#5  0xad4b2ecb in SvxDrawPage::add (this=0x9227f58, xShape=
    uno::Reference to {<com::sun::star::drawing::XShapeDescriptor> = {<com::sun::star::uno::XInterface> = {_vptr.XInterface = 0xaea46480}, <No data fields>}, <No data fields>}) at /data/opt/libreoffice/master/svx/source/unodraw/unopage.cxx:243
#6  0xae353a29 in SwXDrawPage::add (this=0x9027188, xShape=
    uno::Reference to {<com::sun::star::drawing::XShapeDescriptor> = {<com::sun::star::uno::XInterface> = {_vptr.XInterface = 0xaea46480}, <No data fields>}, <No data fields>}) at /data/opt/libreoffice/master/sw/source/core/unocore/unodraw.cxx:603
#7  0xa43977bc in writerfilter::rtftok::RTFSdrImport::resolve (this=0x9027280, rShape=...)
    at /data/opt/libreoffice/master/writerfilter/source/rtftok/rtfsdrimport.cxx:308
#8  0xa4387e89 in writerfilter::rtftok::RTFDocumentImpl::popState (this=0x902b908)
    at /data/opt/libreoffice/master/writerfilter/source/rtftok/rtfdocumentimpl.cxx:3616
#9  0xa4399b72 in writerfilter::rtftok::RTFTokenizer::resolveParse (this=0x91f2be0)
    at /data/opt/libreoffice/master/writerfilter/source/rtftok/rtftokenizer.cxx:125
#10 0xa4372823 in writerfilter::rtftok::RTFDocumentImpl::resolve (this=0x902b908, rMapper=...)
    at /data/opt/libreoffice/master/writerfilter/source/rtftok/rtfdocumentimpl.cxx:604
#11 0xa4417270 in RtfFilter::filter (this=0x902f468, aDescriptor=uno::Sequence of length 13 = {...})
    at /data/opt/libreoffice/master/writerfilter/source/filter/RtfFilter.cxx:115
#12 0xb6f85d47 in SfxObjectShell::ImportFrom (this=0x918c190, rMedium=..., bInsert=false)
    at /data/opt/libreoffice/master/sfx2/source/doc/objstor.cxx:2221
#13 0xb6f84cb9 in SfxObjectShell::DoLoad (this=0x918c190, pMed=0x91ce678) at /data/opt/libreoffice/master/sfx2/source/doc/objstor.cxx:714
#14 0xb6fa8b94 in SfxBaseModel::load (this=0x91cee08, seqArguments=uno::Sequence of length 14 = {...})
Comment 3 Michael Meeks 2012-12-14 10:40:16 UTC
In fact this is a duplicate - and not RTF specific :-) I added some more debugging information in #58267

*** This bug has been marked as a duplicate of bug 58267 ***
Comment 4 VX 2012-12-14 19:07:32 UTC
(In reply to comment #3)
> In fact this is a duplicate - and not RTF specific :-) I added some more
> debugging information in #58267
> 
> *** This bug has been marked as a duplicate of bug 58267 ***

Michael, perhaps you are right about the duplicate. 
However, the attached RTF file can help to solve some nasty formatting issues in LO RTF filter. This file looks as it should in MS Word (various versions tested) but none of LibreOffice Writter version can display it correctly.

I can see some improvements comparing how it looked in LO 3.4.x and 3.6.x, but despite the regression in LO 4.0.0.0 b1 there ARE some bugs in LO 3.x.x which you can see when opening this file.

Maybe Miklos could take a deeper look at it? 

I'm reopening this bug for further investigation. Let's hope LO 4.0 can handle it correctly. Thanks for your replies.
Comment 5 Miklos Vajna 2012-12-15 08:23:18 UTC
OK, after reverting 76350361f386b78e1bc9edb75af89e7ff3afe356, I see that on master this is imported as two pages, while on LO 3.4 / Word, this is imported as a single page, so reopening makes sense, just the title was misleading.
Comment 6 VX 2012-12-22 08:52:39 UTC
LO 4.0.0.0 Beta 2 - in this version I can open the file so there is some progress with it, but it looks much worse than in LO 3.6.x. I'll add some screenshots later.
Comment 7 VX 2012-12-22 13:03:48 UTC
Created attachment 71971 [details]
RTF Filter bug_Regression_LO Writer 4.0.0beta2_screenshots

As you can see at the screenshot, the title of this bug report could be misleading. Indeed, there is 2 pages in LO Writer 4.0.0.0 beta2 instead of one in MS Office or LibreOffice 3.x.x versions. However, the issue is much worse: just look at the screenshots attached and compare by yourself. 
This file is unusable in LO Writer 4.0.0.0 beta 2, the formatting is destroyed completely.
Comment 8 VX 2012-12-22 15:43:24 UTC
Created attachment 71977 [details]
LO Writter 3.6.4 look for comparison porpuses
Comment 9 VX 2012-12-22 15:44:43 UTC
(In reply to comment #7)
> Created attachment 71971 [details]
> RTF Filter bug_Regression_LO Writer 4.0.0beta2_screenshots
> 
> As you can see at the screenshot, the title of this bug report could be
> misleading. Indeed, there is 2 pages in LO Writer 4.0.0.0 beta2 instead of
> one in MS Office or LibreOffice 3.x.x versions. However, the issue is much
> worse: just look at the screenshots attached and compare by yourself. 
> This file is unusable in LO Writer 4.0.0.0 beta 2, the formatting is
> destroyed completely.

I've just created a screenshot to show how the file look like in LO Writer 3.6.4 Polish (I was using an English GUI at the moment). As you can see it's much better than in 4.0.0.0 beta 2: there are still 2 pages instead of one, but at least the file is usable after removing a few empty lines. As far as I can remember it was looking even better with one of the previous version (3.5.x maybe), but I can't install it at the moment.
Comment 10 Miklos Vajna 2012-12-23 13:41:46 UTC
Hmm, with latest master (bb121c864cc3c101ef733a4088c7ba3e36eced14), it seems I have to revert 7fec8dfcaca4efc92516f9af51a3157f1a11ccd7 and 76350361f386b78e1bc9edb75af89e7ff3afe356, or the input file will crash the importer. Seems to be related to bug 56267 and bug 56980. David, any ideas?

In the meantime, I'll revert them locally, so I can provide a fix for the original problem, which seems to be about incorrect margins.
Comment 11 Not Assigned 2012-12-23 14:48:56 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=07c80d23fadcc2334fe7c6f9ce7b5dafeb88d623

fdo#58076 fix import of RTF page margins vs partial section props



The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 12 Not Assigned 2012-12-23 15:40:04 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "libreoffice-4-0":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=99894610482eb8f631083c327ca2f0310391eb23&h=libreoffice-4-0

fdo#58076 fix import of RTF page margins vs partial section props


It will be available in LibreOffice 4.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 13 Miklos Vajna 2012-12-23 15:51:02 UTC
Fixed in master and -4-0, marking as resolved.
Comment 14 VX 2012-12-23 19:53:11 UTC
Miklos, thank you very much for fixing this issue. I'm going to test the fix and give some feedback as soon as it's available in the Daily Builds.

Wishing you all the happiness of the season and peace and prosperity in the new year. Merry Christmas!
Comment 15 Miklos Vajna 2012-12-23 21:30:14 UTC
Hi,

Sure, feedback is welcome. I suggest to either test it with the stripped down test document http://cgit.freedesktop.org/libreoffice/core/plain/sw/qa/extras/rtfimport/data/fdo58076.rtf, or wait till the shape part is fixed as well (see comment 10).

And same best wishes to you. :-)

Miklos
Comment 16 David Tardon 2012-12-24 15:27:24 UTC
(In reply to comment #10)
> Hmm, with latest master (bb121c864cc3c101ef733a4088c7ba3e36eced14), it seems
> I have to revert 7fec8dfcaca4efc92516f9af51a3157f1a11ccd7 and
> 76350361f386b78e1bc9edb75af89e7ff3afe356, or the input file will crash the
> importer. Seems to be related to bug 56267 and bug 56980. David, any ideas?

Yes, I missed one possible problem with that fix. Commit 31b93b8600a3e219d33173aa68d9ab570e477e50 should take care of that.

Merry Christmas!
Comment 17 Miklos Vajna 2012-12-25 20:14:34 UTC
David,

Thanks for the quick fix -- confirmed, now the bugdoc opens without crashes on master.

Best,

Miklos
Comment 18 VX 2012-12-28 20:05:26 UTC
Created attachment 72227 [details]
Bug is partially fixed in the current daily build

Guys, thank you very much for your fixes. I'm attaching a new screenshot that shows how the file looks with LO daily build from today. The file was opened with LO Version 4.0.0.0.beta2+ (Build ID: 1d7287f8d7984eae98a577f60a8bc0a740fc5e9) on Windows 7 64bit Polish UI. 

As you can see the document has one page, so the bug is partially solved.
 
Unfortunately, the current look is far from perfect and its readability is worse than in LO 3.6.4 (compare the 4 screenshots attached - the screenshot from MS Word 2007 shows expected look of the document).

I have this bug report reopened. Feel free to adjust the title to be more descriptive for the Developers as the problem with inaccurate pages is solved but the content of the RTF file is hardly readable.
Comment 19 Jorendc 2013-01-10 16:04:59 UTC
Comment on attachment 71971 [details]
RTF Filter bug_Regression_LO Writer 4.0.0beta2_screenshots

Fix MIME Type
Comment 20 Jorendc 2013-01-10 16:07:49 UTC
Comment on attachment 71971 [details]
RTF Filter bug_Regression_LO Writer 4.0.0beta2_screenshots

rewind MIME Type
Comment 21 Jorendc 2013-01-10 16:09:09 UTC
Comment on attachment 71971 [details]
RTF Filter bug_Regression_LO Writer 4.0.0beta2_screenshots

Correct MIME Type this time (sorry about that)
Comment 22 Jorendc 2013-01-10 16:11:34 UTC
(In reply to comment #18)

> 
> I have this bug report reopened. Feel free to adjust the title to be more
> descriptive for the Developers as the problem with inaccurate pages is
> solved but the content of the RTF file is hardly readable.

Can reproduce that behavior with latest master 4.1 (build today); 
Status to NEW again
Comment 23 VX 2013-01-31 14:37:47 UTC
I can confirm this bug for LO 4.0 RC 2 as well.
Comment 24 Miklos Vajna 2013-02-05 17:01:01 UTC
Yes, I see -- the position of the graphical element isn't imported, so it's zero, this way hiding some text. I'll fix this in a bit.
Comment 25 Not Assigned 2013-02-05 17:39:39 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=878c6f7cb4b7495de90581e8513d46053b8a38e9

fdo#58076 import RTF_SHPLEFT/TOP of ESCHER_ShpInst_PictureFrame



The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 26 Miklos Vajna 2013-02-05 20:03:48 UTC
4-0 review: https://gerrit.libreoffice.org/2005

And VX, if you have any further issues, you're welcome to open a separate bugreport for new problems you find. But please don't reopen this bug, unless there is a problem with the page count or the graphic position.

Using the same bug number for independent issues just creates a mess, sadly.

See: https://wiki.documentfoundation.org/BugReport_Details#How_to_reopen_Bugs

Thanks,

Miklos
Comment 27 Not Assigned 2013-02-05 21:49:07 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "libreoffice-4-0":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=f5b7e504324f3284ccb118c0006c716685746710&h=libreoffice-4-0

fdo#58076 import RTF_SHPLEFT/TOP of ESCHER_ShpInst_PictureFrame


It will be available in LibreOffice 4.0.1.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 28 Robinson Tryon (qubit) 2015-12-17 12:08:59 UTC
Migrating Whiteboard tags to Keywords: (filter:rtf)
Replace rtf_filter -> filter:rtf.
[NinjaEdit]