https://issues.apache.org/ooo/show_bug.cgi?id=119945
yuanlin <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #1 from yuanlin <[email protected]> --- 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 ); } ... } -- You are receiving this mail because: You are the assignee for the bug.
