Bug 38071

Summary: [PATCH] crash on export of multi line form text fields to .doc
Product: LibreOffice Reporter: Caolán McNamara <caolan.mcnamara>
Component: WriterAssignee: Caolán McNamara <caolan.mcnamara>
Status: RESOLVED FIXED    
Severity: normal CC: cedric.bosdonnat.ooo, michael.stahl
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard: target:3.6.0 target:3.7.0
Crash report or crash signature: Regression By:
Attachments: propose fix
sample document

Description Caolán McNamara 2011-06-08 04:39:38 UTC
Created attachment 47713 [details]
propose fix

If the last line is empty, and consists of only the field-end char then...

we have...

if ( ch == CH_TXT_ATR_FIELDEND )
    SwPosition aPosition( rNode, SwIndex( const_cast< SwTxtNode* >( &rNode ), nAktPos - 1 ) );

...

so taking the sample .doc attached, load it, place cursor on second line of field and delete the single space in it, save it => crash

when looking at the CH_TXT_ATR_FIELDEND char we're at position 0 in that SwNode, getting nAktPos-1 to look at the content before the field-end is busted, because it assumes that the previous char is in the same SwNode, so we get an invalid -1 pos in the current node, not the last pos in the previous node.

Looking at MarkBase::IsCoveringPosition I see that we currently have...

return GetMarkStart() <= rPos && rPos < GetMarkEnd();

which suggests that the starting CH_TXT_ATR_FIELDBEGIN char is considered part of the coveredrange, but that the FIELDEND is not.

How about keeping it simple and consider both the field start and end chars as part of the range.
Comment 1 Caolán McNamara 2011-06-08 04:40:25 UTC
Created attachment 47714 [details]
sample document
Comment 2 Roman Eisele 2012-05-05 09:24:16 UTC
Talking about DOC export, this issue is (at least at the surface) a Writer issue, therefore changed the 'Component' field accordingly.
Comment 3 Not Assigned 2012-05-09 05:34:42 UTC
Caolan McNamara committed a patch related to this issue.
It has been pushed to "master":

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

Resolves: fdo#38071 improve multi-line form field text ranges
Comment 4 Not Assigned 2012-07-06 13:38:49 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "master":

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

fdo#38071: roll back change to MarkBase::IsCoveringPosition:
Comment 5 Not Assigned 2012-07-06 13:45:52 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-3-6":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=6497a45560fa34d7f1372412c0994632ec7ff75b&g=libreoffice-3-6

fdo#38071: roll back change to MarkBase::IsCoveringPosition:


It will be available in LibreOffice 3.6.