xref: /AOO41X/main/sw/source/core/inc/UndoOverwrite.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SW_UNDO_OVERWRITE_HXX
29 #define SW_UNDO_OVERWRITE_HXX
30 
31 #include <undobj.hxx>
32 
33 #include <com/sun/star/uno/Sequence.h>
34 
35 
36 class SwRedlineSaveDatas;
37 class SwTxtNode;
38 
39 namespace utl {
40     class TransliterationWrapper;
41 }
42 
43 
44 class SwUndoOverwrite: public SwUndo, private SwUndoSaveCntnt
45 {
46     String aDelStr, aInsStr;
47     SwRedlineSaveDatas* pRedlSaveData;
48     sal_uLong nSttNode;
49     xub_StrLen nSttCntnt;
50     sal_Bool bInsChar : 1;  // no Overwrite, but Insert
51     sal_Bool bGroup : 1;    // TRUE: is already grouped; evaluated in CanGrouping()
52 
53 public:
54     SwUndoOverwrite( SwDoc*, SwPosition&, sal_Unicode cIns );
55 
56     virtual ~SwUndoOverwrite();
57 
58     virtual void UndoImpl( ::sw::UndoRedoContext & );
59     virtual void RedoImpl( ::sw::UndoRedoContext & );
60     virtual void RepeatImpl( ::sw::RepeatContext & );
61 
62     // #111827#
63     /**
64        Returns the rewriter of this undo object.
65 
66        The rewriter contains the following rule:
67 
68            $1 -> '<overwritten text>'
69 
70        <overwritten text> is shortened to nUndoStringLength characters.
71 
72        @return the rewriter of this undo object
73      */
74     virtual SwRewriter GetRewriter() const;
75 
76     sal_Bool CanGrouping( SwDoc*, SwPosition&, sal_Unicode cIns );
77 };
78 
79 //--------------------------------------------------------------------
80 
81 struct _UndoTransliterate_Data;
82 class SwUndoTransliterate : public SwUndo, public SwUndRng
83 {
84     std::vector< _UndoTransliterate_Data * >    aChanges;
85     sal_uInt32 nType;
86 
87     void DoTransliterate(SwDoc & rDoc, SwPaM & rPam);
88 
89 public:
90     SwUndoTransliterate( const SwPaM& rPam,
91                             const utl::TransliterationWrapper& rTrans );
92 
93     virtual ~SwUndoTransliterate();
94 
95     virtual void UndoImpl( ::sw::UndoRedoContext & );
96     virtual void RedoImpl( ::sw::UndoRedoContext & );
97     virtual void RepeatImpl( ::sw::RepeatContext & );
98 
99     void AddChanges( SwTxtNode& rTNd, xub_StrLen nStart, xub_StrLen nLen,
100                      ::com::sun::star::uno::Sequence <sal_Int32>& rOffsets );
101     sal_Bool HasData() const { return aChanges.size() > 0; }
102 };
103 
104 #endif // SW_UNDO_OVERWRITE_HXX
105 
106