Issue 91483

Summary: Writer crashes when inserting ole if text is hidden
Product: Writer Reporter: jian.li
Component: codeAssignee: michael.ruess
Status: CLOSED FIXED QA Contact: issues@sw <issues>
Severity: Trivial    
Priority: P2 CC: andreas.martens, frank.meies, issues, liujiaxiang, orw, peter.junge
Version: OOo 3.0 BetaKeywords: crash
Target Milestone: ---   
Hardware: All   
OS: Windows XP   
Issue Type: PATCH Latest Confirmation in: ---
Developer Difficulty: ---
Issue Depends on:    
Issue Blocks: 72764    
Attachments:
Description Flags
patch file
none
patch 2 for this issue none

Description jian.li 2008-07-09 03:00:15 UTC
Here is the description for a crash bug.
1.New a writer document;
2."Format"-"Character", and select "Font Effects" tab page;
3.Check the checkbox "Hidden";
4."Insert"-"Object"-"OLE Object", and Click "OK" in the poped up dialog.
Writer crashes.
Comment 1 michael.ruess 2008-07-09 09:09:39 UTC
MRU->AMA: as described, when inserting an OLE into hidden text, OO crashes.
Comment 2 jian.li 2008-08-29 02:42:00 UTC
lijian->ama:
I am working on this issue. Assigned to me.
Comment 3 jian.li 2008-09-01 03:51:44 UTC
Hi all,
I have some findings on this issue:
An OLE object is a Flyfrm whose pLower is a SwNoTxtFrm.
If the SwFrm the OLE ahchors at is hidden, pLower of FlyFrm
will be deleted. Method SwWrtShell::CalcAndSetScale will 
calculate the rect area of the object and call the method
SwFEShell::FindFlyFrm to get the proper SwFlyFrm. If the SwFrm
anchored is hidden, pLower will be NULL. And function SwFEShell::GetAnyCurRect
will return an not exsited Rect which will cause crash.

I have just got a rough solution with the attached patch, but there are still
some other problems such as undo strings incorrect. But I don't know what 
it should be like when the anchored SwFrm is hidden when inserting an OLE 
object. It seems that OOo has a big defect on this.

Hope someone will have a look at the patch and give some suggestions.

Comments from Lijian.
Comment 4 jian.li 2008-09-01 03:55:28 UTC
Created attachment 56127 [details]
patch file
Comment 5 frank.meies 2008-09-01 16:26:06 UTC
First thing I notice is that there's an infinite loop in crsrsh.cxx (close to
the call of CalcLayout()). Looks like your patches do not address this. I
observed this in DEV300m29. 
Comment 6 frank.meies 2008-09-02 08:07:17 UTC
fme->lijian: Anyway: I think we should simply suppress the insertion if the
cursor is currently located in a hidden paragraph. Additionally we can check if
we can disable these functions in the UI in this case.
Comment 7 jian.li 2008-09-09 07:35:37 UTC
Created attachment 56340 [details]
patch 2 for this issue
Comment 8 jian.li 2008-09-09 07:46:14 UTC
lijian->fme && od:
Hi frank, I have disabled the insertion of crash-cause objects in the UI if 
the cursor is located in hidden paragraphs with the second patch. Please have 
a look and tell me if there is something incorrect.
I didn't disable text frame/images in this case because I think they will not 
cause crash anyway.
In fact, I think the perfect solution is to make the inserting of the OLE 
objects just like text frames/images even the cursor is in hidden paragraph.
But I think one solution is to avoid the calling of CalcAndSetScale( xObj ) 
and pClient->DoVerb( SVVERB_SHOW ) if the cursor is in hidden paragraph in 
function SwWrtShell::InsertObject in file wrtsh1.cxx. Maybe od could give help 
on this, right ?
Looking forward to your reply. Thank you!
Comment 9 frank.meies 2008-09-10 08:31:22 UTC
fme->lijian: Thank you for your patch. Please find my comments below:

[...] In fact, I think the perfect solution is to make the inserting of the OLE 
objects just like text frames/images even the cursor is in hidden paragraph.
But I think one solution is to avoid the calling of CalcAndSetScale( xObj ) 
and pClient->DoVerb( SVVERB_SHOW ) if the cursor is in hidden paragraph in 
function SwWrtShell::InsertObject in file wrtsh1.cxx. Maybe od could give help 
on this, right ? [...] 

Well, that's the crucial point. I also prefer the perfect solution. But as I
already on 2008-09-01, there's also an infinite loop in crsrsh.cxx in a current
version. So there's more obviously more left to consider than simply avoiding
the crash. Please switch your workspace to a more recent version and you'll see.
And that's the reason why I think we might be better of with the 'simple'
solution, since this issue actually only shows under some pretty rare circumstances.

Your patch works fine, I'll have a look if we should also disable some other
(possibly all) items in the text shell. Thank you for your good work.
Comment 10 jian.li 2008-09-16 02:34:16 UTC
lijian->fme:
so is there still anything I can do for this issue ?
Comment 11 frank.meies 2008-09-16 07:27:15 UTC
fme->lijian: No, thank you. I haven't yet decided if we should disable more
items in the text shell in case the cursor is currently in a hidden area. So
I'll take over. Thank you for your support.
Comment 12 frank.meies 2008-12-09 13:52:10 UTC
For now I'll take the patch as is. We should still check if we want to disable
more 'Insert' menu entries in case the cursor is located in hidden text. I set
up a follow-up task for this issue: 97069.
Comment 13 frank.meies 2008-12-09 13:54:37 UTC
Applied patch to textsh.cxx, cws sw31bf02.
Comment 14 frank.meies 2009-01-23 12:47:13 UTC
Ready for QA.
Comment 15 michael.ruess 2009-01-28 11:42:59 UTC
Verified fix in CWS sw31bf02.
Comment 16 amy2008 2009-03-27 07:42:40 UTC
In issue 97069, it's about "Disable Insert menu entries if cursor is positioned 
in hidden text". So, for reproducing this issue, I have entered some characters 
in Writer and  checked this issue following the steps. Indeed it has been 
verified in DEV310m7.

Closing
Li Meiying