os/textandloc/textrendering/textformatting/inc/EditorPlainTextUndo.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
#ifndef EDITORPLAINTEXTUNDO_H_
sl@0
    20
#define EDITORPLAINTEXTUNDO_H_
sl@0
    21
sl@0
    22
#include "unified_editor.h"
sl@0
    23
sl@0
    24
namespace UndoSystem
sl@0
    25
{
sl@0
    26
class CCommandManager;
sl@0
    27
class MNotUndoableGatekeeper;
sl@0
    28
}
sl@0
    29
sl@0
    30
class CEditorPlainTextCommandFactory;
sl@0
    31
sl@0
    32
/**
sl@0
    33
MUnifiedEditor decorator that adds undo functionality to plain text editors.
sl@0
    34
It passes commands transparently to the editor it is constructed upon, while
sl@0
    35
storing the operations so that they can be undone and redone. Calling a
sl@0
    36
non-const method of MUnifiedEditor wipes all 'Redo' operations.
sl@0
    37
The undo and redo operations are only guaranteed to be accurate if the
sl@0
    38
underlying editor satisfies certain conditions.
sl@0
    39
sl@0
    40
@since App-frameworks6.1
sl@0
    41
@internalComponent
sl@0
    42
*/
sl@0
    43
class CEditorPlainTextWithUndo : public CBase, public MUnifiedEditor,
sl@0
    44
	private MUnifiedEditor::MClipboardSupport
sl@0
    45
	{
sl@0
    46
public:
sl@0
    47
	~CEditorPlainTextWithUndo();
sl@0
    48
sl@0
    49
	/**
sl@0
    50
	 * Creates a CEditorPlainTextWithUndo, using the aSharedUndoSystem.
sl@0
    51
	 * This allows many objects to stay in synchronization when each is
sl@0
    52
	 * accessed seperately.
sl@0
    53
	 * The aEditor is not owned.
sl@0
    54
	 * Undo functionality is accessed only via the aSharedUndoSystem
sl@0
    55
	 * object.
sl@0
    56
	 */
sl@0
    57
	IMPORT_C static CEditorPlainTextWithUndo* NewL(MUnifiedEditor& aEditor,
sl@0
    58
		UndoSystem::CCommandManager* aSharedUndoSystem);
sl@0
    59
sl@0
    60
	// From MUnifiedEditor
sl@0
    61
	void InsertTextL(TInt aPos, const TDesC& aText, const TDesC* aStyle,
sl@0
    62
		const TTmCharFormatLayer*, const RTmParFormatLayer*);
sl@0
    63
	void DeleteTextL(TInt aPos,TInt aLength);
sl@0
    64
	MTmOptionalInterface* Interface(TUint aId);
sl@0
    65
sl@0
    66
	// The following methods are forwarded to the base editor
sl@0
    67
	TInt DocumentLength() const;
sl@0
    68
	void GetText(TInt aPos, TPtrC& aText) const;
sl@0
    69
	void GetBaseFormatL(TTmCharFormat&, RTmParFormat&) const;
sl@0
    70
	void GetCharFormat(TInt aPos, TFormatLevel aLevel,
sl@0
    71
		TTmCharFormatLayer& aFormat,TInt& aRunLength) const;
sl@0
    72
	void GetParFormatL(TInt aPos, TFormatLevel aLevel,
sl@0
    73
		RTmParFormatLayer& aFormat, TInt& aRunLength) const;
sl@0
    74
	void SetBaseFormatL(const TTmCharFormat&, const RTmParFormat&);
sl@0
    75
	void SetCharFormatL(TInt aPos, TInt aLength, const TTmCharFormatLayer&);
sl@0
    76
	void SetParFormatL(TInt aPos, TInt aLength, const RTmParFormatLayer&);
sl@0
    77
	void DeleteCharFormatL(TInt aPos, TInt aLength);
sl@0
    78
	void DeleteParFormatL(TInt aPos, TInt aLength);
sl@0
    79
sl@0
    80
private:
sl@0
    81
	CEditorPlainTextWithUndo();
sl@0
    82
	void ConstructL(MUnifiedEditor& aEditorBasedOn,
sl@0
    83
		UndoSystem::CCommandManager& aSharedUndoSystem);
sl@0
    84
sl@0
    85
	// from MUnifiedEditor::MClipboardSupport
sl@0
    86
	void CopyToStoreL(CStreamStore&, CStreamDictionary&, TInt, TInt) const;
sl@0
    87
	void PasteFromStoreL(const CStreamStore&, const CStreamDictionary&, TInt);
sl@0
    88
sl@0
    89
	CEditorPlainTextCommandFactory*	iFactory;
sl@0
    90
	MUnifiedEditor*						iBaseEditor;
sl@0
    91
	UndoSystem::CCommandManager*	iCommandManager;
sl@0
    92
	};
sl@0
    93
sl@0
    94
#endif	// EDITORPLAINTEXTUNDO_H_
sl@0
    95