1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/textrendering/textformatting/inc/EditorPlainTextUndo.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,95 @@
1.4 +/*
1.5 +* Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#ifndef EDITORPLAINTEXTUNDO_H_
1.23 +#define EDITORPLAINTEXTUNDO_H_
1.24 +
1.25 +#include "unified_editor.h"
1.26 +
1.27 +namespace UndoSystem
1.28 +{
1.29 +class CCommandManager;
1.30 +class MNotUndoableGatekeeper;
1.31 +}
1.32 +
1.33 +class CEditorPlainTextCommandFactory;
1.34 +
1.35 +/**
1.36 +MUnifiedEditor decorator that adds undo functionality to plain text editors.
1.37 +It passes commands transparently to the editor it is constructed upon, while
1.38 +storing the operations so that they can be undone and redone. Calling a
1.39 +non-const method of MUnifiedEditor wipes all 'Redo' operations.
1.40 +The undo and redo operations are only guaranteed to be accurate if the
1.41 +underlying editor satisfies certain conditions.
1.42 +
1.43 +@since App-frameworks6.1
1.44 +@internalComponent
1.45 +*/
1.46 +class CEditorPlainTextWithUndo : public CBase, public MUnifiedEditor,
1.47 + private MUnifiedEditor::MClipboardSupport
1.48 + {
1.49 +public:
1.50 + ~CEditorPlainTextWithUndo();
1.51 +
1.52 + /**
1.53 + * Creates a CEditorPlainTextWithUndo, using the aSharedUndoSystem.
1.54 + * This allows many objects to stay in synchronization when each is
1.55 + * accessed seperately.
1.56 + * The aEditor is not owned.
1.57 + * Undo functionality is accessed only via the aSharedUndoSystem
1.58 + * object.
1.59 + */
1.60 + IMPORT_C static CEditorPlainTextWithUndo* NewL(MUnifiedEditor& aEditor,
1.61 + UndoSystem::CCommandManager* aSharedUndoSystem);
1.62 +
1.63 + // From MUnifiedEditor
1.64 + void InsertTextL(TInt aPos, const TDesC& aText, const TDesC* aStyle,
1.65 + const TTmCharFormatLayer*, const RTmParFormatLayer*);
1.66 + void DeleteTextL(TInt aPos,TInt aLength);
1.67 + MTmOptionalInterface* Interface(TUint aId);
1.68 +
1.69 + // The following methods are forwarded to the base editor
1.70 + TInt DocumentLength() const;
1.71 + void GetText(TInt aPos, TPtrC& aText) const;
1.72 + void GetBaseFormatL(TTmCharFormat&, RTmParFormat&) const;
1.73 + void GetCharFormat(TInt aPos, TFormatLevel aLevel,
1.74 + TTmCharFormatLayer& aFormat,TInt& aRunLength) const;
1.75 + void GetParFormatL(TInt aPos, TFormatLevel aLevel,
1.76 + RTmParFormatLayer& aFormat, TInt& aRunLength) const;
1.77 + void SetBaseFormatL(const TTmCharFormat&, const RTmParFormat&);
1.78 + void SetCharFormatL(TInt aPos, TInt aLength, const TTmCharFormatLayer&);
1.79 + void SetParFormatL(TInt aPos, TInt aLength, const RTmParFormatLayer&);
1.80 + void DeleteCharFormatL(TInt aPos, TInt aLength);
1.81 + void DeleteParFormatL(TInt aPos, TInt aLength);
1.82 +
1.83 +private:
1.84 + CEditorPlainTextWithUndo();
1.85 + void ConstructL(MUnifiedEditor& aEditorBasedOn,
1.86 + UndoSystem::CCommandManager& aSharedUndoSystem);
1.87 +
1.88 + // from MUnifiedEditor::MClipboardSupport
1.89 + void CopyToStoreL(CStreamStore&, CStreamDictionary&, TInt, TInt) const;
1.90 + void PasteFromStoreL(const CStreamStore&, const CStreamDictionary&, TInt);
1.91 +
1.92 + CEditorPlainTextCommandFactory* iFactory;
1.93 + MUnifiedEditor* iBaseEditor;
1.94 + UndoSystem::CCommandManager* iCommandManager;
1.95 + };
1.96 +
1.97 +#endif // EDITORPLAINTEXTUNDO_H_
1.98 +