Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_SW_SOURCE_CORE_INC_UNDOINSERT_HXX
21 : #define INCLUDED_SW_SOURCE_CORE_INC_UNDOINSERT_HXX
22 :
23 : #include <undobj.hxx>
24 : #include <rtl/ustring.hxx>
25 : #include <tools/mempool.hxx>
26 : #include <swtypes.hxx>
27 : #include <IDocumentContentOperations.hxx>
28 :
29 : class Graphic;
30 : class SwGrfNode;
31 : class SwUndoDelete;
32 : class SwUndoFmtAttr;
33 :
34 : class SwUndoInsert: public SwUndo, private SwUndoSaveCntnt
35 : {
36 : /// start of Content in UndoNodes for Redo
37 : ::boost::scoped_ptr<SwNodeIndex> m_pUndoNodeIndex;
38 : OUString *pTxt, *pUndoTxt;
39 : SwRedlineData* pRedlData;
40 : sal_uLong nNode;
41 : sal_Int32 nCntnt, nLen;
42 : bool bIsWordDelim : 1;
43 : sal_Bool bIsAppend : 1;
44 : sal_Bool m_bWithRsid : 1;
45 :
46 : const IDocumentContentOperations::InsertFlags m_nInsertFlags;
47 :
48 : friend class SwDoc; // actually only SwDoc::Insert( String )
49 : sal_Bool CanGrouping( sal_Unicode cIns );
50 : sal_Bool CanGrouping( const SwPosition& rPos );
51 :
52 : SwDoc * pDoc;
53 :
54 : void Init(const SwNodeIndex & rNode);
55 : OUString * GetTxtFromDoc() const;
56 :
57 : public:
58 : SwUndoInsert( const SwNodeIndex& rNode, sal_Int32 nCntnt, sal_Int32 nLen,
59 : const IDocumentContentOperations::InsertFlags nInsertFlags,
60 : sal_Bool bWDelim = sal_True );
61 : SwUndoInsert( const SwNodeIndex& rNode );
62 : virtual ~SwUndoInsert();
63 :
64 : virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
65 : virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
66 : virtual void RepeatImpl( ::sw::RepeatContext & ) SAL_OVERRIDE;
67 :
68 : /**
69 : Returns rewriter for this undo object.
70 :
71 : The returned rewriter has the following rule:
72 :
73 : $1 -> '<inserted text>'
74 :
75 : <inserted text> is shortened to a length of nUndoStringLength.
76 :
77 : @return rewriter for this undo object
78 : */
79 : virtual SwRewriter GetRewriter() const SAL_OVERRIDE;
80 :
81 0 : void SetWithRsid() { m_bWithRsid = true; }
82 :
83 0 : DECL_FIXEDMEMPOOL_NEWDEL(SwUndoInsert)
84 : };
85 :
86 : SwRewriter
87 : MakeUndoReplaceRewriter(sal_uLong const ocurrences,
88 : OUString const& sOld, OUString const& sNew);
89 :
90 : class SwUndoReplace
91 : : public SwUndo
92 : {
93 : public:
94 : SwUndoReplace(SwPaM const& rPam,
95 : OUString const& rInsert, bool const bRegExp);
96 :
97 : virtual ~SwUndoReplace();
98 :
99 : virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
100 : virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
101 :
102 : /**
103 : Returns the rewriter of this undo object.
104 :
105 : If this undo object represents several replacements the
106 : rewriter contains the following rules:
107 :
108 : $1 -> <number of replacements>
109 : $2 -> occurrences of
110 : $3 -> <replaced text>
111 :
112 : If this undo object represents one replacement the rewriter
113 : contains these rules:
114 :
115 : $1 -> <replaced text>
116 : $2 -> "->" (STR_YIELDS)
117 : $3 -> <replacing text>
118 :
119 : @return the rewriter of this undo object
120 : */
121 : virtual SwRewriter GetRewriter() const SAL_OVERRIDE;
122 :
123 : void SetEnd( const SwPaM& rPam );
124 :
125 : private:
126 : class Impl;
127 : ::std::auto_ptr<Impl> m_pImpl;
128 : };
129 :
130 : class SwUndoReRead : public SwUndo
131 : {
132 : Graphic *pGrf;
133 : OUString *pNm;
134 : OUString *pFltr;
135 : sal_uLong nPos;
136 : sal_uInt16 nMirr;
137 :
138 : void SaveGraphicData( const SwGrfNode& );
139 : void SetAndSave( ::sw::UndoRedoContext & );
140 :
141 : public:
142 : SwUndoReRead( const SwPaM& rPam, const SwGrfNode& pGrfNd );
143 :
144 : virtual ~SwUndoReRead();
145 :
146 : virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
147 : virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
148 : };
149 :
150 : class SwUndoInsertLabel : public SwUndo
151 : {
152 : union {
153 : struct {
154 : // for NoTxtFrms
155 : SwUndoInsLayFmt* pUndoFly;
156 : SwUndoFmtAttr* pUndoAttr;
157 : } OBJECT;
158 : struct {
159 : // for tables or TxtFrms
160 : SwUndoDelete* pUndoInsNd;
161 : sal_uLong nNode;
162 : } NODE;
163 : };
164 :
165 : OUString sText;
166 : // #i39983# the separator is drawn with a character style
167 : OUString sSeparator;
168 : OUString sNumberSeparator;
169 : OUString sCharacterStyle;
170 : // #i26791# - re-store of drawing object position no longer needed
171 : sal_uInt16 nFldId;
172 : SwLabelType eType;
173 : sal_uInt8 nLayerId; // for character objects
174 : sal_Bool bBefore :1;
175 : sal_Bool bUndoKeep :1;
176 : sal_Bool bCpyBrd :1;
177 :
178 : public:
179 : SwUndoInsertLabel( const SwLabelType eTyp, const OUString &rText,
180 : // #i39983# the separator is drawn with a character style
181 : const OUString& rSeparator,
182 : const OUString& rNumberSeparator, //#i61007# order of captions
183 : const sal_Bool bBefore, const sal_uInt16 nId,
184 : const OUString& rCharacterStyle,
185 : const sal_Bool bCpyBrd );
186 : virtual ~SwUndoInsertLabel();
187 :
188 : virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
189 : virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
190 : virtual void RepeatImpl( ::sw::RepeatContext & ) SAL_OVERRIDE;
191 :
192 : /**
193 : Returns the rewriter of this undo object.
194 :
195 : The rewriter contains this rule:
196 :
197 : $1 -> '<text of inserted label>'
198 :
199 : <text of inserted label> is shortened to nUndoStringLength
200 : characters.
201 :
202 : @return the rewriter of this undo object
203 : */
204 : virtual SwRewriter GetRewriter() const SAL_OVERRIDE;
205 :
206 0 : void SetNodePos( sal_uLong nNd )
207 0 : { if( LTYPE_OBJECT != eType ) NODE.nNode = nNd; }
208 :
209 0 : void SetUndoKeep() { bUndoKeep = sal_True; }
210 : void SetFlys( SwFrmFmt& rOldFly, SfxItemSet& rChgSet, SwFrmFmt& rNewFly );
211 : void SetDrawObj( sal_uInt8 nLayerId );
212 : };
213 :
214 : #endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOINSERT_HXX
215 :
216 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|