xref: /aoo42x/main/sw/source/core/inc/UndoInsert.hxx (revision 1d2dbeb0)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SW_UNDO_INSERT_HXX
25 #define SW_UNDO_INSERT_HXX
26 
27 #include <undobj.hxx>
28 
29 #include <tools/mempool.hxx>
30 
31 #include <swtypes.hxx>
32 #include <IDocumentContentOperations.hxx>
33 
34 
35 class Graphic;
36 class SwGrfNode;
37 class SwUndoDelete;
38 class SwUndoFmtAttr;
39 
40 
41 class SwUndoInsert: public SwUndo, private SwUndoSaveCntnt
42 {
43     SwPosition *pPos;                   // Inhalt fuers Redo
44     String *pTxt, *pUndoTxt;
45     SwRedlineData* pRedlData;
46     sal_uLong nNode;
47     xub_StrLen nCntnt, nLen;
48     sal_Bool bIsWordDelim : 1;
49     sal_Bool bIsAppend : 1;
50 
51     const IDocumentContentOperations::InsertFlags m_nInsertFlags;
52 
53     friend class SwDoc;     // eigentlich nur SwDoc::Insert( String )
54     sal_Bool CanGrouping( sal_Unicode cIns );
55     sal_Bool CanGrouping( const SwPosition& rPos );
56 
57     SwDoc * pDoc;
58 
59     void Init(const SwNodeIndex & rNode);
60     String * GetTxtFromDoc() const;
61 
62 public:
63     SwUndoInsert( const SwNodeIndex& rNode, xub_StrLen nCntnt, xub_StrLen nLen,
64                   const IDocumentContentOperations::InsertFlags nInsertFlags,
65                   sal_Bool bWDelim = sal_True );
66     SwUndoInsert( const SwNodeIndex& rNode );
67     virtual ~SwUndoInsert();
68 
69     virtual void UndoImpl( ::sw::UndoRedoContext & );
70     virtual void RedoImpl( ::sw::UndoRedoContext & );
71     virtual void RepeatImpl( ::sw::RepeatContext & );
72 
73     // #111827#
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 
88     DECL_FIXEDMEMPOOL_NEWDEL(SwUndoInsert)
89 };
90 
91 
92 //--------------------------------------------------------------------
93 
94 SwRewriter SW_DLLPRIVATE
95 MakeUndoReplaceRewriter(sal_uLong const ocurrences,
96     ::rtl::OUString const& sOld, ::rtl::OUString const& sNew);
97 
98 class SwUndoReplace
99     : public SwUndo
100 {
101 public:
102     SwUndoReplace(SwPaM const& rPam,
103             ::rtl::OUString const& rInsert, bool const bRegExp);
104 
105     virtual ~SwUndoReplace();
106 
107     virtual void UndoImpl( ::sw::UndoRedoContext & );
108     virtual void RedoImpl( ::sw::UndoRedoContext & );
109 
110     // #111827#
111     /**
112        Returns the rewriter of this undo object.
113 
114        If this undo object represents several replacements the
115        rewriter contains the following rules:
116 
117            $1 -> <number of replacements>
118            $2 -> occurrences of
119            $3 -> <replaced text>
120 
121        If this undo object represents one replacement the rewriter
122        contains these rules:
123 
124            $1 -> <replaced text>
125            $2 -> "->"                   (STR_YIELDS)
126            $3 -> <replacing text>
127 
128        @return the rewriter of this undo object
129     */
130     virtual SwRewriter GetRewriter() const;
131 
132     void SetEnd( const SwPaM& rPam );
133 
134 private:
135     class Impl;
136     ::std::auto_ptr<Impl> m_pImpl;
137 };
138 
139 
140 //--------------------------------------------------------------------
141 
142 class SwUndoReRead : public SwUndo
143 {
144     Graphic *pGrf;
145     String *pNm, *pFltr;
146     sal_uLong nPos;
147     sal_uInt16 nMirr;
148 
149     void SaveGraphicData( const SwGrfNode& );
150     void SetAndSave( ::sw::UndoRedoContext & );
151 
152 public:
153     SwUndoReRead( const SwPaM& rPam, const SwGrfNode& pGrfNd );
154 
155     virtual ~SwUndoReRead();
156 
157     virtual void UndoImpl( ::sw::UndoRedoContext & );
158     virtual void RedoImpl( ::sw::UndoRedoContext & );
159 };
160 
161 //--------------------------------------------------------------------
162 
163 class SwUndoInsertLabel : public SwUndo
164 {
165     union {
166         struct {
167             // fuer NoTxtFrms
168             SwUndoInsLayFmt* pUndoFly;
169             SwUndoFmtAttr* pUndoAttr;
170         } OBJECT;
171         struct {
172             // fuer Tabelle/TextRahmen
173             SwUndoDelete* pUndoInsNd;
174             sal_uLong nNode;
175         } NODE;
176     };
177 
178     String sText;
179     // --> PB 2005-01-06 #i39983# the separator is drawn with a character style
180     String sSeparator;
181     // <--
182     String sNumberSeparator;
183     String sCharacterStyle;
184     // OD 2004-04-15 #i26791# - re-store of drawing object position no longer needed
185     sal_uInt16 nFldId;
186     SwLabelType eType;
187     sal_uInt8 nLayerId;              // fuer Zeichen-Objekte
188     sal_Bool bBefore        :1;
189     sal_Bool bUndoKeep      :1;
190     sal_Bool bCpyBrd        :1;
191 
192 public:
193     SwUndoInsertLabel( const SwLabelType eTyp, const String &rText,
194     // --> PB 2005-01-06 #i39983# the separator is drawn with a character style
195                         const String& rSeparator,
196     // <--
197                         const String& rNumberSeparator, //#i61007# order of captions
198                         const sal_Bool bBefore, const sal_uInt16 nId,
199                         const String& rCharacterStyle,
200                         const sal_Bool bCpyBrd );
201     virtual ~SwUndoInsertLabel();
202 
203     virtual void UndoImpl( ::sw::UndoRedoContext & );
204     virtual void RedoImpl( ::sw::UndoRedoContext & );
205     virtual void RepeatImpl( ::sw::RepeatContext & );
206 
207     // #111827#
208     /**
209        Returns the rewriter of this undo object.
210 
211        The rewriter contains this rule:
212 
213            $1 -> '<text of inserted label>'
214 
215        <text of inserted label> is shortened to nUndoStringLength
216        characters.
217 
218        @return the rewriter of this undo object
219      */
220     virtual SwRewriter GetRewriter() const;
221 
SetNodePos(sal_uLong nNd)222     void SetNodePos( sal_uLong nNd )
223         { if( LTYPE_OBJECT != eType ) NODE.nNode = nNd; }
224 
SetUndoKeep()225     void SetUndoKeep()  { bUndoKeep = sal_True; }
226     void SetFlys( SwFrmFmt& rOldFly, SfxItemSet& rChgSet, SwFrmFmt& rNewFly );
227     void SetDrawObj( sal_uInt8 nLayerId );
228 };
229 
230 #endif // SW_UNDO_INSERT_HXX
231 
232