Apache OpenOffice (AOO) Bugzilla – Issue 78849
Writer: undo of charts when modifying tables needs better implementation
Last modified: 2013-08-07 14:44:35 UTC
Since the switch to chart2 the Undo for chart objects does not work as good as with the old chart anymore. This becomes increasingly obvious with fixing issue 75159. Where undo operations may result in a chart that completely out of it's 'should be' state. The undo operations for chart in sw should keep a clone of the 'old' chart before the change happens in order to restore it later.
.
In CWS chart07 there is a new interface css::chart2::XUndoHelper. The chart's XModel is a chart2::XUndoSupplier, that offers a method getUndoManager(). The object returned is a chart2::XUndoManager which also implements XUndoHelper. There are two methods at this interface: 1. XModel getModelCloneForUndo( [in] XModel xModelBeforeChange ) Call this method to get a clone of the model that you can store in an Undo-Action 2. void applyModelContent( [inout] XModel xModelToChange, [in] XModel xModelToCopyFrom ) Call this in case you do an undo. the first parameter is the current XModel of the chart, the second parameter is the XModel you remembered in the undo-action. Note that the XModel you store still contains the XDataSequence objects the writer's data provider created. So, when you delete a table and do an undo afterward, I am not sure that the objects are still valid, because the data sequence objects may have references to the table that was destroyed at one point. The data sequences would have to be able to remember the ranges they use and reconnect to the table that was created in undo. (Maybe this is not necessary when the table itself was completely remembered in the undo action, I don't know the details here).
As discussed with BM: changing target to OOo 2.4
unochart.hxx/cxx specific changes done. Files changed: - sw/inc/unochart.hxx - sw/source/core/undo/untbl.cxx - sw/source/core/unocore/unochart.cxx TL->AMA: untbl.cxx has now two new functions - PrepareChartForUndo - RestoreChartFromUndo and a new member variable - m_xChartModelForUndo; that can be used to copy and restore the chart data. You will probably like to get rid of that new member when the implementation is complete and that reference is stored in an undo object. When adding the above functions where necessary please also have a break point in SwDoc::UpdateCharts in docchart.cxx. That function should only be called once per change/undo if possible. If it gets called more than once we should check how to optimize that.
Created attachment 49289 [details] short sample document
TL: cleaning up some older inconsistencies. Files changed: - unochart.hxx - unochart.cxx - unotbl.cxx
Set target OOo3.x
*** Issue 102990 has been marked as a duplicate of this issue. ***