Hi Jun Ma,

please see my comments inline

MaJun wrote:
Hi all,

Currently i'm working on issue101666(its details please see
http://www.openoffice.org/issues/show_bug.cgi?id=101666 ). I found
the crash point is  that the pointer to SwFlyFrmFmt instance in undo
objects was invalid. It's because undo object recorded only a pointer
of such instance but not a copy and SwFlyFrmFmt instance was
destroyed after doing hide redline.

For example, undo object recorded a pointer to SwFlyFrmFmt instance. SwUndoFmtAttr::SwUndoFmtAttr( const SfxPoolItem& rItem, SwFmt&
rChgFmt, BOOL bSvDrwPt ) : SwUndo( UNDO_INSFMTATTR ), pFmt( &rChgFmt
), // Here, such pointer nNode( 0 ), nFmtWhich( rChgFmt.Which() ), bSaveDrawPt( bSvDrwPt ) { pOldSet = pFmt->GetAttrSet().Clone( FALSE
); pOldSet->Put( rItem ); Init(); }

But for Undo operate, it should do something but now nothing been
done. So from here, Office did not reach its expectation. void
SwUndoFmtAttr::Undo( SwUndoIter& rUndoIter) { if( !pOldSet || !pFmt
|| !IsFmtInDoc( &rUndoIter.GetDoc() )) return; // it should do
something below, but it didn't ...... }

It crashed when we do the last undo operation because it did not give
test for "pFrmFmt" and  unfortunately it was invalid. void
SwUndoInsLayFmt::Undo( SwUndoIter& rUndoIter ) { const SwFmtCntnt&
rCntnt = pFrmFmt->GetCntnt(); // no test for "pFrmFmt" pointer ......
 }


So my question is that should it be fixed in undo objects or do
something about the SwFlyFrmFmt instance in redline area? For the
former i mean we give a copy of SwFlyFrmFmt instance not only a
pointer to it and this seems simpler compared with the latter one.
And for the latter i do not familar with redline function but i think
it is a complex function. I also don't know if the latter method is
possible to fix this issue.

Your first suggestion - copy the <SwFlyFrmFmt> instance in the undo object <SwUndoInsLayFmt> - would not help directly. During Undo a certain <SwFlyFrmFmt> needs to be deleted and this one has to be identified.

Your second suggestion is - as you already stated - too complicated in my eyes.


Could anybody give me some hints or suggestions? I'd appreciated and
thanks very much in advance.


I took for first suggestion and changed it to the following:
- Do not keep a pointer of the inserted <SwFlyFrmFmt> instance in <SwUndoInsLayFmt>.
- Keep the name of the inserted <SwFlyFrmFmt> instance
- Keep the name of the parent <SwFlyFrmFmt> instance from the inserted <SwFlyFrmFmt> instance.
- Adjust the <SwUndoInsLayFmt::Undo> method
-- get the <SwFlyFrmFmt> instance from the <SwDoc> instance by search for it by name
-- remove the found <SwFlyFrmFmt> instance from the document
-- delete the found <SwFlyFrmFmt> instance
- Adjust the <SwUndoInsLayFmt::Redo> method
-- create a new <SwFlyFrmFmt> instance using its attribut set, name, and its parent <SwFlyFrmFmt> instance name
-- insert the newly create <SwFlyFrmFmt> instance into the document.

The difficulties of my proposal are:
- classes <SwUndoFlyBase> and <SwUndoDelLayFmt> needs to be adjusted, too.
- all this stuff needs to work for <SwDrawFrmFmt> instances (drawing objects) as well.

My approach needs some more analysis and investigation - probably something is missing or it does not work. If you want you can take over this task and continue your work on issue 101666.


Best regards, Oliver.



--
=======================================================================
Sun Microsystems GmbH    Oliver-Rainer Wittmann
Nagelsweg 55             Software Engineer - OpenOffice.org/StarOffice
20097 Hamburg
Germany                  Fax:   (+49 40) 23 646 955
http://www.sun.de        mailto:[email protected]
-----------------------------------------------------------------------
Sitz der Gesellschaft:
Sun Microsystems GmbH, Sonnenallee 1, D-85551 Kirchheim-Heimstetten
Amtsgericht Muenchen: HRB 161028
Geschaeftsfuehrer: Thomas Schroeder, Wolfgang Engels, Wolf Frenkel
Vorsitzender des Aufsichtsrates: Martin Haering

=======================================================================
Oliver-Rainer Wittmann (od) - OpenOffice.org Writer
OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

  • [sw-discussi... MaJun
    • Re: [sw... Oliver-Rainer Wittmann - Software Engineer - Sun Microsystems

Reply via email to