Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef SW_UNDO_INSERT_HXX
30 : : #define SW_UNDO_INSERT_HXX
31 : :
32 : : #include <undobj.hxx>
33 : : #include <tools/mempool.hxx>
34 : : #include <swtypes.hxx>
35 : : #include <IDocumentContentOperations.hxx>
36 : :
37 : : class Graphic;
38 : : class SwGrfNode;
39 : : class SwUndoDelete;
40 : : class SwUndoFmtAttr;
41 : :
42 : : class SwUndoInsert: public SwUndo, private SwUndoSaveCntnt
43 : : {
44 : : SwPosition *pPos; // Inhalt fuers Redo
45 : : String *pTxt, *pUndoTxt;
46 : : SwRedlineData* pRedlData;
47 : : sal_uLong nNode;
48 : : xub_StrLen nCntnt, nLen;
49 : : sal_Bool bIsWordDelim : 1;
50 : : sal_Bool bIsAppend : 1;
51 : :
52 : : const IDocumentContentOperations::InsertFlags m_nInsertFlags;
53 : :
54 : : friend class SwDoc; // eigentlich nur SwDoc::Insert( String )
55 : : sal_Bool CanGrouping( sal_Unicode cIns );
56 : : sal_Bool CanGrouping( const SwPosition& rPos );
57 : :
58 : : SwDoc * pDoc;
59 : :
60 : : void Init(const SwNodeIndex & rNode);
61 : : String * GetTxtFromDoc() const;
62 : :
63 : : public:
64 : : SwUndoInsert( const SwNodeIndex& rNode, xub_StrLen nCntnt, xub_StrLen nLen,
65 : : const IDocumentContentOperations::InsertFlags nInsertFlags,
66 : : sal_Bool bWDelim = sal_True );
67 : : SwUndoInsert( const SwNodeIndex& rNode );
68 : : virtual ~SwUndoInsert();
69 : :
70 : : virtual void UndoImpl( ::sw::UndoRedoContext & );
71 : : virtual void RedoImpl( ::sw::UndoRedoContext & );
72 : : virtual void RepeatImpl( ::sw::RepeatContext & );
73 : :
74 : : /**
75 : : Returns rewriter for this undo object.
76 : :
77 : : The returned rewriter has the following rule:
78 : :
79 : : $1 -> '<inserted text>'
80 : :
81 : : <inserted text> is shortened to a length of nUndoStringLength.
82 : :
83 : : @return rewriter for this undo object
84 : : */
85 : : virtual SwRewriter GetRewriter() const;
86 : :
87 [ + - ][ + - ]: 14414 : DECL_FIXEDMEMPOOL_NEWDEL(SwUndoInsert)
88 : : };
89 : :
90 : : SwRewriter SW_DLLPRIVATE
91 : : MakeUndoReplaceRewriter(sal_uLong const ocurrences,
92 : : ::rtl::OUString const& sOld, ::rtl::OUString const& sNew);
93 : :
94 : : class SwUndoReplace
95 : : : public SwUndo
96 : : {
97 : : public:
98 : : SwUndoReplace(SwPaM const& rPam,
99 : : ::rtl::OUString const& rInsert, bool const bRegExp);
100 : :
101 : : virtual ~SwUndoReplace();
102 : :
103 : : virtual void UndoImpl( ::sw::UndoRedoContext & );
104 : : virtual void RedoImpl( ::sw::UndoRedoContext & );
105 : :
106 : : /**
107 : : Returns the rewriter of this undo object.
108 : :
109 : : If this undo object represents several replacements the
110 : : rewriter contains the following rules:
111 : :
112 : : $1 -> <number of replacements>
113 : : $2 -> occurrences of
114 : : $3 -> <replaced text>
115 : :
116 : : If this undo object represents one replacement the rewriter
117 : : contains these rules:
118 : :
119 : : $1 -> <replaced text>
120 : : $2 -> "->" (STR_YIELDS)
121 : : $3 -> <replacing text>
122 : :
123 : : @return the rewriter of this undo object
124 : : */
125 : : virtual SwRewriter GetRewriter() const;
126 : :
127 : : void SetEnd( const SwPaM& rPam );
128 : :
129 : : private:
130 : : class Impl;
131 : : ::std::auto_ptr<Impl> m_pImpl;
132 : : };
133 : :
134 : : class SwUndoReRead : public SwUndo
135 : : {
136 : : Graphic *pGrf;
137 : : String *pNm, *pFltr;
138 : : sal_uLong nPos;
139 : : sal_uInt16 nMirr;
140 : :
141 : : void SaveGraphicData( const SwGrfNode& );
142 : : void SetAndSave( ::sw::UndoRedoContext & );
143 : :
144 : : public:
145 : : SwUndoReRead( const SwPaM& rPam, const SwGrfNode& pGrfNd );
146 : :
147 : : virtual ~SwUndoReRead();
148 : :
149 : : virtual void UndoImpl( ::sw::UndoRedoContext & );
150 : : virtual void RedoImpl( ::sw::UndoRedoContext & );
151 : : };
152 : :
153 : : class SwUndoInsertLabel : public SwUndo
154 : : {
155 : : union {
156 : : struct {
157 : : // for NoTxtFrms
158 : : SwUndoInsLayFmt* pUndoFly;
159 : : SwUndoFmtAttr* pUndoAttr;
160 : : } OBJECT;
161 : : struct {
162 : : // for tables or TxtFrms
163 : : SwUndoDelete* pUndoInsNd;
164 : : sal_uLong nNode;
165 : : } NODE;
166 : : };
167 : :
168 : : String sText;
169 : : // #i39983# the separator is drawn with a character style
170 : : String sSeparator;
171 : : String sNumberSeparator;
172 : : String sCharacterStyle;
173 : : // #i26791# - re-store of drawing object position no longer needed
174 : : sal_uInt16 nFldId;
175 : : SwLabelType eType;
176 : : sal_uInt8 nLayerId; // for character objects
177 : : sal_Bool bBefore :1;
178 : : sal_Bool bUndoKeep :1;
179 : : sal_Bool bCpyBrd :1;
180 : :
181 : : public:
182 : : SwUndoInsertLabel( const SwLabelType eTyp, const String &rText,
183 : : // #i39983# the separator is drawn with a character style
184 : : const String& rSeparator,
185 : : const String& rNumberSeparator, //#i61007# order of captions
186 : : const sal_Bool bBefore, const sal_uInt16 nId,
187 : : const String& rCharacterStyle,
188 : : const sal_Bool bCpyBrd );
189 : : virtual ~SwUndoInsertLabel();
190 : :
191 : : virtual void UndoImpl( ::sw::UndoRedoContext & );
192 : : virtual void RedoImpl( ::sw::UndoRedoContext & );
193 : : virtual void RepeatImpl( ::sw::RepeatContext & );
194 : :
195 : : /**
196 : : Returns the rewriter of this undo object.
197 : :
198 : : The rewriter contains this rule:
199 : :
200 : : $1 -> '<text of inserted label>'
201 : :
202 : : <text of inserted label> is shortened to nUndoStringLength
203 : : characters.
204 : :
205 : : @return the rewriter of this undo object
206 : : */
207 : : virtual SwRewriter GetRewriter() const;
208 : :
209 : 0 : void SetNodePos( sal_uLong nNd )
210 [ # # ]: 0 : { if( LTYPE_OBJECT != eType ) NODE.nNode = nNd; }
211 : :
212 : 0 : void SetUndoKeep() { bUndoKeep = sal_True; }
213 : : void SetFlys( SwFrmFmt& rOldFly, SfxItemSet& rChgSet, SwFrmFmt& rNewFly );
214 : : void SetDrawObj( sal_uInt8 nLayerId );
215 : : };
216 : :
217 : : #endif // SW_UNDO_INSERT_HXX
218 : :
219 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|