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