Bug 105910 - Allow defaults to be used as parameters for RTF control words without explicit parameters
Summary: Allow defaults to be used as parameters for RTF control words without explici...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Ekansh Jha
URL:
Whiteboard: target:6.1.0
Keywords: difficultyBeginner, easyHack, filter:rtf, skillCpp, topicDebug
Depends on:
Blocks: RTF
  Show dependency treegraph
 
Reported: 2017-02-10 05:45 UTC by Mike Kaganski
Modified: 2018-01-28 20:09 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2017-02-10 05:45:59 UTC
As stated in "Conventions of an RTF Reader" of RTF Specification v.1.9.1:
> If a parameter is needed and not specified, then a default value is used.
> The default value used depends on the control word. If the control word
> does not specify a default, then RTF readers should assume a default of 0
> except for the toggle control words (like \b), which have a default of 1

Before 2a49c656e7d7643f8e47f1bae43f5540e80c1bf3, any control word that requires parameter behaved as if it had 0 as default.
Currently, RTFTokenizer::dispatchKeyword (writerfilter/source/rtftok/rtftokenizer.cxx) ignores control words that need parameters (CONTROL_VALUE) without parameter specified explicitly (except \dibitmap).
This may cause different RTF import problems. It is not a regression, because it didn't work properly in OOo.

The proposal is to extend RTFSymbol struct (writerfilter/source/rtftok/rtfcontrolwords.hxx) to include a default value (will be 0 for most), and specify actual defaults in aRTFControlWords (writerfilter/source/rtftok/rtfcontrolwords.cxx). Then use the default as parameter to RTFListener::dispatchValue in case when there's no explicit parameter (bParam==false) in RTFTokenizer::dispatchKeyword.

The task requires C++ knowledge on beginner level, and careful reading of RTF documentation: https://download.microsoft.com/download/2/f/5/2f599e18-07ee-4ec5-a1e7-f4e6a9423592/Word2007RTFSpec9.docx
Comment 1 Kunal Jain 2017-06-13 02:56:41 UTC
Hey, I'd like to work on this and this would be my first easyHack. It would be very helpful if I can talk to you once before I start working on it?
Comment 2 Mike Kaganski 2017-06-13 04:33:31 UTC
(In reply to Kunal Jain from comment #1)

Welcome to LibreOffice!

Please join #libreoffice-dev, and don't hesitate to ask if you have any questions. I'll try to provide any help necessary to get you going.
Comment 3 Commit Notification 2018-01-25 20:04:31 UTC
ekuiitr committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=061145e2172886f0bd8b33f16ede7c21dba6f3f6

tdf#105910 Allow defaults to be used as parameters for RTF control words.

It will be available in 6.1.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 4 Commit Notification 2018-01-28 20:09:51 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=21a15d5106bf081d3c896f9f1b01702b2c61d135

Unit test for tdf#105910, tdf#115276, tdf#115278

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