Issue 114888

Summary: simplify Undo by using an UndoSuppressor class
Product: Writer Reporter: bjoern.michaelsen
Component: codeAssignee: mst.ooo
Status: CLOSED FIXED QA Contact: issues@sw <issues>
Severity: Trivial    
Priority: P3 CC: issues
Version: current   
Target Milestone: 3.4.0   
Hardware: All   
OS: All   
Issue Type: DEFECT Latest Confirmation in: ---
Developer Difficulty: ---

Description bjoern.michaelsen 2010-10-01 14:02:28 UTC
There is the idea:

namespace sw { namespace undo {

class UndoSuppresor
{
    public:
        UndoSuppresor(IDocumentUndoRedo* io_pUndoRedo)
            : m_pUndoRedo(io_pUndoRedo)
            , m_bOldState(io_pUndoRedo->DoesUndo())
        {
            m_pUndoRedo->DoUndo(false);
        };
        ~UndoSuppresor()
            { m_pUndoRedo->DoUndo(m_bOldState); };
    private:
        IDocumentUndoRedo* const m_pUndoRedo;
        const bool m_bOldState;
}

instead of writing:

BOOL bUndo = pDoc->DoesUndo();
pDoc->DoUndo(false);
... something ...
pDoc->DoUndo(bUndo);

one would write:
{
    UndoSuppresor(p_Doc);
    ... something ...
}
Comment 1 bjoern.michaelsen 2010-11-01 12:28:30 UTC
reassigning to mst, he would steal the issue from me if I wouldnt anyway ...
Comment 2 mst.ooo 2010-12-17 16:53:13 UTC
fixed in CWS undoapi.

there is a UndoGuard, GroupUndoGuard and DrawUndoGuard.

Comment 3 mst.ooo 2010-12-17 16:55:29 UTC
.
Comment 4 mst.ooo 2011-02-08 13:07:56 UTC
.