Apache OpenOffice (AOO) Bugzilla – Full Text Issue Listing |
Summary: | [From Symphony]Application crashed if undo add caption to drawing object | ||||||
---|---|---|---|---|---|---|---|
Product: | Writer | Reporter: | Yan Ji <yanji.yj> | ||||
Component: | editing | Assignee: | Oliver-Rainer Wittmann <orw> | ||||
Status: | CLOSED FIXED | QA Contact: | |||||
Severity: | Critical | ||||||
Priority: | P3 | CC: | bjdujing, jingbaibetsy, liushenf, orw, yuanlin.ibm | ||||
Version: | 3.4.0 | ||||||
Target Milestone: | 4.0.0 | ||||||
Hardware: | PC | ||||||
OS: | All | ||||||
Issue Type: | DEFECT | Latest Confirmation in: | --- | ||||
Developer Difficulty: | --- | ||||||
Issue Depends on: | |||||||
Issue Blocks: | 120823 | ||||||
Attachments: |
|
Description
Yan Ji
2012-06-12 03:23:38 UTC
In SdrUndoRemoveObj, it stores and uses the OrdNum(order number) in SdrObjList to restore the corresponding objects. However, when insert a caption for a drawing object, a new SwFlyFrm will be created and the order of that drawing object in SdrObjList will be adjust to be right after the SwFlyFrm, which contains the caption. Below is an example in sw\source\core\layout\flylay.cxx void SwPageFrm::AppendFlyToPage( SwFlyFrm *pNew ) { .... const SwFlyFrm* pFly = pNew->GetAnchorFrm()->FindFlyFrm(); if ( pFly && pObj->GetOrdNum() < pFly->GetVirtDrawObj()->GetOrdNum() ) { sal_uInt32 nNewNum = pFly->GetVirtDrawObj()->GetOrdNumDirect(); if ( pObj->GetPage() ) pObj->GetPage()->SetObjectOrdNum( pObj->GetOrdNumDirect(), nNewNum); else pObj->SetOrdNum( nNewNum ); } ... } So when the SdrUndoRemoveObj use the stored OrdNum to restore the objects, strange things will happen such as crash. It can be verified by that if add caption for the last created drawing objects, AOO will not crash. But if add caption for other drawing objects, AOO will crash. The idea to fix this issue is that when adjust the order for the drawing object and new SwFlyFrm, do not change the original drawing objects's OrdNum, but change the SwFlyFrm's OrdNum which is added later than the drawing object. So when do Undo operation for caption and the drawing object, the OrdNum will be the same as that stored in SdrUndoRemoveObj. There are 3 places to adjust the order when insert a SwFlyFrm. Below is one fix example void SwPageFrm::AppendFlyToPage( SwFlyFrm *pNew ) { .... SwFlyFrm* pFly = (SwFlyFrm*)pNew->GetAnchorFrm()->FindFlyFrm(); if ( pFly && pObj->GetOrdNum() < pFly->GetVirtDrawObj()->GetOrdNum() ) { //#i119945# set pFly's OrdNum to _rNewObj's. So when pFly is removed by Undo, the original OrdNum will not be changed. sal_uInt32 nNewNum = pObj->GetOrdNumDirect(); if ( pObj->GetPage() ) pObj->GetPage()->SetObjectOrdNum( pFly->GetVirtDrawObj()->GetOrdNumDirect(), nNewNum ); else pFly->GetVirtDrawObj()->SetOrdNum( nNewNum ); } ... } Created attachment 78310 [details]
patch to fix the issue in i119945
taking over to review the patch Comment on attachment 78310 [details]
patch to fix the issue in i119945
The patch looks good. I have checked it on my Windows environment and will integrate the patch into the source code repository.
committed patch into trunk - changed files: /sw/source/core/layout/flylay.cxx, /sw/source/core/layout/frmtool.cxx revision 1352786 verified on the build AOO3.5 set Target Milestone to AOO 3.5.0 for PM purpose. |