2010-10-14 01:30:41 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2006-08-14 09:14:15 -05:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 04:41:27 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2006-08-14 09:14:15 -05:00
|
|
|
*
|
2010-02-12 08:01:35 -06:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2006-08-14 09:14:15 -05:00
|
|
|
*
|
2008-04-10 04:41:27 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2006-08-14 09:14:15 -05:00
|
|
|
*
|
2008-04-10 04:41:27 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2006-08-14 09:14:15 -05:00
|
|
|
*
|
2008-04-10 04:41:27 -05:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2006-08-14 09:14:15 -05:00
|
|
|
*
|
2008-04-10 04:41:27 -05:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2006-08-14 09:14:15 -05:00
|
|
|
*
|
2008-04-10 04:41:27 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2006-08-14 09:14:15 -05:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-10-11 02:45:25 -05:00
|
|
|
|
2007-09-27 01:54:26 -05:00
|
|
|
#ifndef IDOCUMENTUNDOREDO_HXX_INCLUDED
|
|
|
|
#define IDOCUMENTUNDOREDO_HXX_INCLUDED
|
2006-08-14 09:14:15 -05:00
|
|
|
|
2007-09-27 01:54:26 -05:00
|
|
|
#include <sal/types.h>
|
2010-12-15 02:14:02 -06:00
|
|
|
|
2007-09-27 01:54:26 -05:00
|
|
|
#include <swundo.hxx>
|
2006-08-14 09:14:15 -05:00
|
|
|
|
|
|
|
|
2007-09-27 01:54:26 -05:00
|
|
|
class SwRewriter;
|
|
|
|
class SwNodes;
|
|
|
|
class SwUndo;
|
2007-05-25 06:59:33 -05:00
|
|
|
|
2010-12-15 02:14:11 -06:00
|
|
|
namespace sw {
|
|
|
|
class RepeatContext;
|
|
|
|
}
|
|
|
|
|
2007-05-25 06:59:33 -05:00
|
|
|
|
2007-09-27 01:54:26 -05:00
|
|
|
|
|
|
|
/** IDocumentUndoRedo
|
|
|
|
*/
|
|
|
|
class IDocumentUndoRedo
|
|
|
|
{
|
|
|
|
public:
|
2006-08-14 09:14:15 -05:00
|
|
|
|
2010-11-25 07:31:10 -06:00
|
|
|
/** Enable/Disable Undo.
|
2006-08-14 09:14:15 -05:00
|
|
|
*/
|
2010-11-25 07:31:10 -06:00
|
|
|
virtual void DoUndo(bool const bDoUndo) = 0;
|
2006-08-14 09:14:15 -05:00
|
|
|
|
2010-11-25 07:31:10 -06:00
|
|
|
/** Is Undo enabled?
|
2006-08-14 09:14:15 -05:00
|
|
|
*/
|
|
|
|
virtual bool DoesUndo() const = 0;
|
|
|
|
|
2010-11-25 07:31:10 -06:00
|
|
|
/** Enable/Disable Group Undo.
|
|
|
|
This determines whether successive Insert/Delete/Overwrite
|
|
|
|
actions are combined.
|
2006-08-14 09:14:15 -05:00
|
|
|
*/
|
2010-11-25 07:31:10 -06:00
|
|
|
virtual void DoGroupUndo(bool const bDoUndo) = 0;
|
2006-08-14 09:14:15 -05:00
|
|
|
|
2010-11-25 07:31:10 -06:00
|
|
|
/** Is Group Undo enabled?
|
2006-08-14 09:14:15 -05:00
|
|
|
*/
|
|
|
|
virtual bool DoesGroupUndo() const = 0;
|
|
|
|
|
2010-11-25 07:31:11 -06:00
|
|
|
/** Enable/Disable Undo for Drawing objects.
|
|
|
|
*/
|
|
|
|
virtual void DoDrawUndo(bool const bDoUndo) = 0;
|
|
|
|
|
|
|
|
/** Is Undo for Drawing objects enabled?
|
|
|
|
for Draw-Undo: writer wants to handle actions on Flys on its own.
|
|
|
|
*/
|
|
|
|
virtual bool DoesDrawUndo() const = 0;
|
|
|
|
|
2010-11-25 07:31:10 -06:00
|
|
|
/** Set the position at which the document is in the "unmodified" state
|
|
|
|
to the current position in the Undo stack.
|
|
|
|
*/
|
|
|
|
virtual void SetUndoNoModifiedPosition() = 0;
|
|
|
|
|
|
|
|
/** Prevent updates to the "unmodified" state position
|
|
|
|
via SetUndoNoResetModified().
|
|
|
|
*/
|
|
|
|
virtual void LockUndoNoModifiedPosition() = 0;
|
|
|
|
|
|
|
|
/** Allow updates to the "unmodified" state position
|
|
|
|
via SetUndoNoResetModified().
|
2006-08-14 09:14:15 -05:00
|
|
|
*/
|
2010-11-25 07:31:10 -06:00
|
|
|
virtual void UnLockUndoNoModifiedPosition() = 0;
|
|
|
|
|
|
|
|
/** Disable (re)setting the document modified flag on Undo/Redo.
|
|
|
|
*/
|
|
|
|
virtual void SetUndoNoResetModified() = 0;
|
|
|
|
|
|
|
|
/** Is setting the document modified flag on Undo/Redo disabled?
|
|
|
|
*/
|
|
|
|
virtual bool IsUndoNoResetModified() const = 0;
|
|
|
|
|
2010-11-25 07:31:10 -06:00
|
|
|
/** Execute Undo.
|
|
|
|
|
|
|
|
@return true if executing the last Undo action was successful.
|
2006-08-14 09:14:15 -05:00
|
|
|
*/
|
2010-12-15 02:14:11 -06:00
|
|
|
virtual sal_Bool Undo() = 0;
|
2006-08-14 09:14:15 -05:00
|
|
|
|
|
|
|
/** Opens undo block.
|
|
|
|
|
2010-11-25 07:31:10 -06:00
|
|
|
@remark StartUndo() and EndUndo() do nothing if !DoesUndo().
|
|
|
|
|
2011-01-20 12:19:11 -06:00
|
|
|
@param nUndoId undo ID for the list action
|
2006-08-14 09:14:15 -05:00
|
|
|
@param pRewriter rewriter for comments @see SwUndo::GetComment
|
|
|
|
|
|
|
|
If the given nUndoId is equal to zero an undo object with ID
|
|
|
|
UNDO_START will be generated.
|
|
|
|
|
|
|
|
@return the undo ID of the created object
|
|
|
|
*/
|
2010-11-25 07:31:10 -06:00
|
|
|
virtual SwUndoId StartUndo(SwUndoId const eUndoId,
|
|
|
|
SwRewriter const*const pRewriter) = 0;
|
2006-08-14 09:14:15 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Closes undo block.
|
|
|
|
|
2010-11-25 07:31:10 -06:00
|
|
|
@remark StartUndo() and EndUndo() do nothing if !DoesUndo().
|
2006-08-14 09:14:15 -05:00
|
|
|
|
2011-01-20 12:19:11 -06:00
|
|
|
@param nUndoId undo ID for the list action
|
2006-08-14 09:14:15 -05:00
|
|
|
@param pRewriter rewriter for comments @see SwUndo::GetComment
|
|
|
|
|
2011-01-20 12:19:11 -06:00
|
|
|
If the given nUndoId is not UNDO_EMPTY or UNDO_END, the comment of
|
|
|
|
the resulting list action will be set via the nUndoId, applying the
|
|
|
|
given pRewriter (if not 0). Otherwise the comment of the resulting
|
|
|
|
list action is unchanged if it has an UndoId that is not UNDO_START
|
|
|
|
set by StartUndo, and in case the UndoId is UNDO_START the comment
|
|
|
|
of the list action defaults to the comment of the last action
|
|
|
|
contained in the list action.
|
2006-08-14 09:14:15 -05:00
|
|
|
*/
|
2010-11-25 07:31:10 -06:00
|
|
|
virtual SwUndoId EndUndo(SwUndoId const eUndoId,
|
|
|
|
SwRewriter const*const pRewriter) = 0;
|
2006-08-14 09:14:15 -05:00
|
|
|
|
2010-11-15 05:59:57 -06:00
|
|
|
/**
|
2010-11-25 07:31:10 -06:00
|
|
|
Delete all Undo actions.
|
|
|
|
Of course Undo will be disabled during deletion.
|
2006-08-14 09:14:15 -05:00
|
|
|
*/
|
|
|
|
virtual void DelAllUndoObj() = 0;
|
|
|
|
|
2010-12-15 02:14:02 -06:00
|
|
|
/** Get Id and comment of last Undo action.
|
2010-11-25 07:31:10 -06:00
|
|
|
@param o_pStr if not 0, receives comment of last Undo action.
|
2010-12-15 02:14:08 -06:00
|
|
|
@param o_pId if not 0, receives Id of last Undo action.
|
|
|
|
@return true if there is a Undo action, false if none
|
2006-08-14 09:14:15 -05:00
|
|
|
*/
|
2010-12-15 02:14:08 -06:00
|
|
|
virtual bool GetLastUndoInfo(::rtl::OUString *const o_pStr,
|
|
|
|
SwUndoId *const o_pId) const = 0;
|
2010-12-15 02:14:02 -06:00
|
|
|
|
|
|
|
/** Get comments of Undo actions.
|
|
|
|
@return comments of all top-level Undo actions.
|
2006-08-14 09:14:15 -05:00
|
|
|
*/
|
2010-12-15 02:14:02 -06:00
|
|
|
virtual SwUndoComments_t GetUndoComments() const = 0;
|
2006-08-14 09:14:15 -05:00
|
|
|
|
2010-11-25 07:31:10 -06:00
|
|
|
/** Execute Redo.
|
2006-08-14 09:14:15 -05:00
|
|
|
|
2010-11-25 07:31:10 -06:00
|
|
|
@return true if executing the first Redo action was successful.
|
2006-08-14 09:14:15 -05:00
|
|
|
*/
|
2010-12-15 02:14:11 -06:00
|
|
|
virtual sal_Bool Redo() = 0;
|
2006-08-14 09:14:15 -05:00
|
|
|
|
2010-12-15 02:14:07 -06:00
|
|
|
/** Get comment of first Redo action.
|
2010-11-25 07:31:10 -06:00
|
|
|
@param o_pStr if not 0, receives comment of first Redo action.
|
2010-12-15 02:14:07 -06:00
|
|
|
@return true if there is a Redo action, false if none
|
2006-08-14 09:14:15 -05:00
|
|
|
*/
|
2010-12-15 02:14:07 -06:00
|
|
|
virtual bool GetFirstRedoInfo(::rtl::OUString *const o_pStr) const = 0;
|
2006-08-14 09:14:15 -05:00
|
|
|
|
2010-12-15 02:14:02 -06:00
|
|
|
/** Get comments of Redo actions.
|
|
|
|
@return comments of all top-level Redo actions.
|
|
|
|
*/
|
|
|
|
virtual SwUndoComments_t GetRedoComments() const = 0;
|
2006-08-14 09:14:15 -05:00
|
|
|
|
2010-11-25 07:31:10 -06:00
|
|
|
/** Repeat the last Undo action.
|
|
|
|
@return true if repeating the last Undo Redo action was attempted.
|
2006-08-14 09:14:15 -05:00
|
|
|
*/
|
2010-12-15 02:14:11 -06:00
|
|
|
virtual bool Repeat(::sw::RepeatContext & rContext,
|
|
|
|
sal_uInt16 const nRepeatCnt) = 0;
|
2010-11-25 07:31:10 -06:00
|
|
|
|
2010-11-25 07:31:10 -06:00
|
|
|
/** Get Id and comment of last Undo action, if it is Repeat capable.
|
|
|
|
@param o_pStr if not 0, receives comment of last Undo action
|
|
|
|
if it is Repeat capable.
|
2010-11-25 07:31:10 -06:00
|
|
|
@return Id of last Undo action if it is Repeat capable,
|
|
|
|
or UNDO_EMPTY if there is none or it is not Repeat capable.
|
2006-08-14 09:14:15 -05:00
|
|
|
*/
|
2010-12-15 02:14:02 -06:00
|
|
|
virtual SwUndoId GetRepeatInfo(::rtl::OUString *const o_pStr) const = 0;
|
2006-08-14 09:14:15 -05:00
|
|
|
|
2010-11-25 07:31:10 -06:00
|
|
|
/** Add new Undo action.
|
|
|
|
Takes over ownership of pUndo.
|
|
|
|
@remark calls ClearRedo(), except for UNDO_START/UNDO_END.
|
2010-12-15 02:14:06 -06:00
|
|
|
@remark does nothing if !DoesUndo().
|
2010-11-25 07:31:10 -06:00
|
|
|
*/
|
|
|
|
virtual void AppendUndo(SwUndo *const pUndo) = 0;
|
2006-08-14 09:14:15 -05:00
|
|
|
|
2010-11-25 07:31:10 -06:00
|
|
|
/** Delete all Redo actions.
|
2006-08-14 09:14:15 -05:00
|
|
|
*/
|
|
|
|
virtual void ClearRedo() = 0;
|
|
|
|
|
2010-11-25 07:31:10 -06:00
|
|
|
/* Is the given nodes array the Undo nodes array?
|
|
|
|
*/
|
|
|
|
virtual bool IsUndoNodes(SwNodes const& rNodes) const = 0;
|
2006-08-14 09:14:15 -05:00
|
|
|
|
2007-09-27 01:54:26 -05:00
|
|
|
protected:
|
2010-11-25 07:31:10 -06:00
|
|
|
virtual ~IDocumentUndoRedo() {};
|
2007-09-27 01:54:26 -05:00
|
|
|
};
|
2006-08-14 09:14:15 -05:00
|
|
|
|
|
|
|
|
2010-11-25 07:31:09 -06:00
|
|
|
namespace sw {
|
2006-08-14 09:14:15 -05:00
|
|
|
|
2010-11-25 07:31:09 -06:00
|
|
|
class UndoGuard
|
|
|
|
{
|
|
|
|
public:
|
2006-08-14 09:14:15 -05:00
|
|
|
|
2010-11-25 07:31:09 -06:00
|
|
|
UndoGuard(IDocumentUndoRedo & rUndoRedo)
|
|
|
|
: m_rUndoRedo(rUndoRedo)
|
|
|
|
, m_bUndoWasEnabled(rUndoRedo.DoesUndo())
|
|
|
|
{
|
|
|
|
m_rUndoRedo.DoUndo(false);
|
|
|
|
}
|
|
|
|
~UndoGuard()
|
|
|
|
{
|
|
|
|
m_rUndoRedo.DoUndo(m_bUndoWasEnabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool UndoWasEnabled() const
|
|
|
|
{
|
|
|
|
return m_bUndoWasEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
IDocumentUndoRedo & m_rUndoRedo;
|
|
|
|
bool const m_bUndoWasEnabled;
|
|
|
|
};
|
2006-08-14 09:14:15 -05:00
|
|
|
|
2010-11-25 07:31:09 -06:00
|
|
|
class GroupUndoGuard
|
|
|
|
{
|
|
|
|
public:
|
2007-05-25 06:59:33 -05:00
|
|
|
|
2010-11-25 07:31:09 -06:00
|
|
|
GroupUndoGuard(IDocumentUndoRedo & rUndoRedo)
|
|
|
|
: m_rUndoRedo(rUndoRedo)
|
|
|
|
, m_bGroupUndoWasEnabled(rUndoRedo.DoesGroupUndo())
|
|
|
|
{
|
|
|
|
m_rUndoRedo.DoGroupUndo(false);
|
|
|
|
}
|
|
|
|
~GroupUndoGuard()
|
|
|
|
{
|
|
|
|
m_rUndoRedo.DoGroupUndo(m_bGroupUndoWasEnabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
IDocumentUndoRedo & m_rUndoRedo;
|
|
|
|
bool const m_bGroupUndoWasEnabled;
|
|
|
|
};
|
2007-05-25 06:59:33 -05:00
|
|
|
|
2010-11-25 07:31:11 -06:00
|
|
|
class DrawUndoGuard
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
DrawUndoGuard(IDocumentUndoRedo & rUndoRedo)
|
|
|
|
: m_rUndoRedo(rUndoRedo)
|
|
|
|
, m_bDrawUndoWasEnabled(rUndoRedo.DoesDrawUndo())
|
|
|
|
{
|
|
|
|
m_rUndoRedo.DoDrawUndo(false);
|
|
|
|
}
|
|
|
|
~DrawUndoGuard()
|
|
|
|
{
|
|
|
|
m_rUndoRedo.DoDrawUndo(m_bDrawUndoWasEnabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
IDocumentUndoRedo & m_rUndoRedo;
|
|
|
|
bool const m_bDrawUndoWasEnabled;
|
2007-09-27 01:54:26 -05:00
|
|
|
};
|
|
|
|
|
2010-11-25 07:31:11 -06:00
|
|
|
|
2010-11-25 07:31:09 -06:00
|
|
|
} // namespace sw
|
|
|
|
|
2007-09-27 01:54:26 -05:00
|
|
|
#endif
|
2006-08-14 09:14:15 -05:00
|
|
|
|
2010-10-14 01:30:41 -05:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|