Issue 114888 - simplify Undo by using an UndoSuppressor class
Summary: simplify Undo by using an UndoSuppressor class
Status: CLOSED FIXED
Alias: None
Product: Writer
Classification: Application
Component: code (show other issues)
Version: current
Hardware: All All
: P3 Trivial (vote)
Target Milestone: 3.4.0
Assignee: mst.ooo
QA Contact: issues@sw
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-01 14:02 UTC by bjoern.michaelsen
Modified: 2011-02-08 13:07 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
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
.