Download it now!
Bug 39001 - Inserts a blank page at the end of all RTF documents
Summary: Inserts a blank page at the end of all RTF documents
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
3.3.3 release
Hardware: Other Linux (All)
: medium normal
Assignee: Miklos Vajna
URL:
Whiteboard: target:4.2.0 target:4.1.1
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-06 04:56 UTC by Ron
Modified: 2013-07-08 09:03 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Example where the extra blank page is visible (1017 bytes, application/rtf)
2011-07-06 04:56 UTC, Ron
Details
The last "\sect" is removed, then no extra blank page is visible (1013 bytes, application/rtf)
2011-07-06 04:57 UTC, Ron
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ron 2011-07-06 04:56:46 UTC
Created attachment 48812 [details]
Example where the extra blank page is visible

See attached example.rtf
It contains of 3 pages, but there will 4 in libreoffice (the last one being blank).

In for example MS Office there will be 3 displayed.

I have modifed the example, see example_modified.rtf, and removed the last \sect and then only 3 pages are displayed.

but the problem here is libreoffice and not the documents as far as I can tell, I have the same problem with all rtf documents
Comment 1 Ron 2011-07-06 04:57:22 UTC
Created attachment 48813 [details]
The last "\sect" is removed, then no extra blank page is visible
Comment 2 Jean-Baptiste Faure 2011-12-18 04:26:30 UTC
If I open example.rtf with LO 3.5.0 beta-1 I get indeed 4 pages.
But, if I create a text document with 2 pages in ODF format and then save this doc as RTF file, I get 2 pages as expected when I reopen the RTF file.
I do not have MS-Office to test a document produced by MS-Word in RTF format.

@Ron: please provide a description step by step how you produced this RTF file.

Side notes:
1/ Abiword 2.5.8 see only one page; it does not detect or handle the page break
2/ In my RTF file I do not see any \sect nor \sbkpage

Best regards. JBF
Comment 3 Björn Michaelsen 2011-12-23 12:21:14 UTC
[This is an automated message.]
This bug was filed before the changes to Bugzilla on 2011-10-16. Thus it
started right out as NEW without ever being explicitly confirmed. The bug is
changed to state NEEDINFO for this reason. To move this bug from NEEDINFO back
to NEW please check if the bug still persists with the 3.5.0 beta1 or beta2 prereleases.
Details on how to test the 3.5.0 beta1 can be found at:
http://wiki.documentfoundation.org/QA/BugHunting_Session_3.5.0.-1

more detail on this bulk operation: http://nabble.documentfoundation.org/RFC-Operation-Spamzilla-tp3607474p3607474.html
Comment 4 Benjamin Riefenstahl 2012-01-02 01:40:50 UTC
In our case we create the RTF with Apache FOP, see <https://issues.apache.org/bugzilla/show_bug.cgi?id=51484>.   We can work-around the issue there, but according to my understanding of the spec that I found at <http://www.biblioscape.com/rtf15_spec.htm#Heading27>, this seems to be a problem in LibreOffice.
Comment 5 Florian Reisinger 2012-08-14 13:57:45 UTC
Dear bug submitter!

Due to the fact, that there are a lot of NEEDINFO bugs with no answer within the last six months, we close all of these bugs.

To keep this message short, more infos are available @ https://wiki.documentfoundation.org/QA/NeedinfoClosure#Statement

Thanks for understanding and hopefully updating your bug, so that everything is prepared for developers to fix your problem.

Yours!

Florian
Comment 6 Florian Reisinger 2012-08-14 13:59:04 UTC
Dear bug submitter!

Due to the fact, that there are a lot of NEEDINFO bugs with no answer within the last six months, we close all of these bugs.

To keep this message short, more infos are available @ https://wiki.documentfoundation.org/QA/NeedinfoClosure#Statement

Thanks for understanding and hopefully updating your bug, so that everything is prepared for developers to fix your problem.

Yours!

Florian
Comment 7 Florian Reisinger 2012-08-14 14:03:37 UTC
Dear bug submitter!

Due to the fact, that there are a lot of NEEDINFO bugs with no answer within the last six months, we close all of these bugs.

To keep this message short, more infos are available @ https://wiki.documentfoundation.org/QA/NeedinfoClosure#Statement

Thanks for understanding and hopefully updating your bug, so that everything is prepared for developers to fix your problem.

Yours!

Florian
Comment 8 Florian Reisinger 2012-08-14 14:05:53 UTC
Dear bug submitter!

Due to the fact, that there are a lot of NEEDINFO bugs with no answer within the last six months, we close all of these bugs.

To keep this message short, more infos are available @ https://wiki.documentfoundation.org/QA/NeedinfoClosure#Statement

Thanks for understanding and hopefully updating your bug, so that everything is prepared for developers to fix your problem.

Yours!

Florian
Comment 9 sasha.libreoffice 2012-09-26 12:33:36 UTC
reproduced in 3.6.1 on Fedora 64 bit. First attachment in Writer has 4 page. In msWord 2003 for comparison number of pages is 3.
Comment 10 Julien Nabet 2013-06-23 10:24:28 UTC
on pc Debian x86-64 with master sources updated today, I reproduced this.

Miklós: is it invalid there's a final sect in the rtf file or should import rtf part in LO be fixed?
Comment 11 Julien Nabet 2013-06-23 11:26:53 UTC
If the file isn't invalid, here's a proposed patch:
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 7c4f545..ce3aeb5 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -506,7 +506,13 @@ void RTFDocumentImpl::sectBreak(bool bFinal = false)
     bool bNeedSect = m_bNeedSect;
     // If there is no paragraph in this section, then insert a dummy one, as required by Writer
     if (m_bNeedPar)
+    {
+        // sometimes the rtf file has \sect at the end (see fdo#39001)
+        // in this case, there shouldn't be a new page
+        if (bFinal)
+            return;
         dispatchSymbol(RTF_PAR);
+    }
     // It's allowed to not have a non-table paragraph at the end of an RTF doc, add it now if required.
     if (m_bNeedFinalPar && bFinal)
     {
Comment 12 Julien Nabet 2013-07-01 19:52:41 UTC
The patch was wrong, sorry guys. Hopefully Miklos pinpointed this.
Comment 13 Commit Notification 2013-07-05 10:15:29 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=4108f285207ed4a60c8876a8206bc5f2d7f05620

fdo#39001 RTF import: fix fake empty page at the end of the doc



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 14 Miklos Vajna 2013-07-05 10:31:06 UTC
-4-1 review: https://gerrit.libreoffice.org/4737
Comment 15 Commit Notification 2013-07-08 09:03:42 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "libreoffice-4-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=5430b9e0f4082025ff9bf7621d18292db0361121&h=libreoffice-4-1

fdo#39001 RTF import: fix fake empty page at the end of the doc


It will be available in LibreOffice 4.1.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.