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 : namespace sw { class DocumentContentOperationsManager; }
34 :
35 : class SwUndoInsert: public SwUndo, private SwUndoSaveCntnt
36 : {
37 : /// start of Content in UndoNodes for Redo
38 : ::boost::scoped_ptr<SwNodeIndex> m_pUndoNodeIndex;
39 : OUString *pTxt, *pUndoTxt;
40 : SwRedlineData* pRedlData;
41 : sal_uLong nNode;
42 : sal_Int32 nCntnt, nLen;
43 : bool bIsWordDelim : 1;
44 : bool bIsAppend : 1;
45 : bool m_bWithRsid : 1;
46 :
47 : const IDocumentContentOperations::InsertFlags m_nInsertFlags;
48 :
49 : friend class ::sw::DocumentContentOperationsManager; // actually only DocumentContentOperationsManager::InsertString, because it uses CanGrouping
50 : bool CanGrouping( sal_Unicode cIns );
51 : bool CanGrouping( const SwPosition& rPos );
52 :
53 : SwDoc * pDoc;
54 :
55 : void Init(const SwNodeIndex & rNode);
56 : OUString * GetTxtFromDoc() const;
57 :
58 : public:
59 : SwUndoInsert( const SwNodeIndex& rNode, sal_Int32 nCntnt, sal_Int32 nLen,
60 : const IDocumentContentOperations::InsertFlags nInsertFlags,
61 : bool bWDelim = true );
62 : SwUndoInsert( const SwNodeIndex& rNode );
63 : virtual ~SwUndoInsert();
64 :
65 : virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
66 : virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
67 : virtual void RepeatImpl( ::sw::RepeatContext & ) SAL_OVERRIDE;
68 :
69 : /**
70 : Returns rewriter for this undo object.
71 :
72 : The returned rewriter has the following rule:
73 :
74 : $1 -> '<inserted text>'
75 :
76 : <inserted text> is shortened to a length of nUndoStringLength.
77 :
78 : @return rewriter for this undo object
79 : */
80 : virtual SwRewriter GetRewriter() const SAL_OVERRIDE;
81 :
82 18 : void SetWithRsid() { m_bWithRsid = true; }
83 :
84 40483 : DECL_FIXEDMEMPOOL_NEWDEL(SwUndoInsert)
85 : };
86 :
87 : SwRewriter
88 : MakeUndoReplaceRewriter(sal_uLong const ocurrences,
89 : OUString const& sOld, OUString const& sNew);
90 :
91 : class SwUndoReplace
92 : : public SwUndo
93 : {
94 : public:
95 : SwUndoReplace(SwPaM const& rPam,
96 : OUString const& rInsert, bool const bRegExp);
97 :
98 : virtual ~SwUndoReplace();
99 :
100 : virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
101 : virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
102 :
103 : /**
104 : Returns the rewriter of this undo object.
105 :
106 : If this undo object represents several replacements the
107 : rewriter contains the following rules:
108 :
109 : $1 -> <number of replacements>
110 : $2 -> occurrences of
111 : $3 -> <replaced text>
112 :
113 : If this undo object represents one replacement the rewriter
114 : contains these rules:
115 :
116 : $1 -> <replaced text>
117 : $2 -> "->" (STR_YIELDS)
118 : $3 -> <replacing text>
119 :
120 : @return the rewriter of this undo object
121 : */
122 : virtual SwRewriter GetRewriter() const SAL_OVERRIDE;
123 :
124 : void SetEnd( const SwPaM& rPam );
125 :
126 : private:
127 : class Impl;
128 : ::std::unique_ptr<Impl> m_pImpl;
129 : };
130 :
131 : class SwUndoReRead : public SwUndo
132 : {
133 : Graphic *pGrf;
134 : OUString *pNm;
135 : OUString *pFltr;
136 : sal_uLong nPos;
137 : sal_uInt16 nMirr;
138 :
139 : void SaveGraphicData( const SwGrfNode& );
140 : void SetAndSave( ::sw::UndoRedoContext & );
141 :
142 : public:
143 : SwUndoReRead( const SwPaM& rPam, const SwGrfNode& pGrfNd );
144 :
145 : virtual ~SwUndoReRead();
146 :
147 : virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
148 : virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
149 : };
150 :
151 : class SwUndoInsertLabel : public SwUndo
152 : {
153 : union {
154 : struct {
155 : // for NoTxtFrms
156 : SwUndoInsLayFmt* pUndoFly;
157 : SwUndoFmtAttr* pUndoAttr;
158 : } OBJECT;
159 : struct {
160 : // for tables or TxtFrms
161 : SwUndoDelete* pUndoInsNd;
162 : sal_uLong nNode;
163 : } NODE;
164 : };
165 :
166 : OUString sText;
167 : // #i39983# the separator is drawn with a character style
168 : OUString sSeparator;
169 : OUString sNumberSeparator;
170 : OUString sCharacterStyle;
171 : // #i26791# - re-store of drawing object position no longer needed
172 : sal_uInt16 nFldId;
173 : SwLabelType eType;
174 : sal_uInt8 nLayerId; // for character objects
175 : bool bBefore :1;
176 : bool bUndoKeep :1;
177 : bool bCpyBrd :1;
178 :
179 : public:
180 : SwUndoInsertLabel( const SwLabelType eTyp, const OUString &rText,
181 : // #i39983# the separator is drawn with a character style
182 : const OUString& rSeparator,
183 : const OUString& rNumberSeparator, //#i61007# order of captions
184 : const bool bBefore, const sal_uInt16 nId,
185 : const OUString& rCharacterStyle,
186 : const bool bCpyBrd );
187 : virtual ~SwUndoInsertLabel();
188 :
189 : virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
190 : virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
191 : virtual void RepeatImpl( ::sw::RepeatContext & ) SAL_OVERRIDE;
192 :
193 : /**
194 : Returns the rewriter of this undo object.
195 :
196 : The rewriter contains this rule:
197 :
198 : $1 -> '<text of inserted label>'
199 :
200 : <text of inserted label> is shortened to nUndoStringLength
201 : characters.
202 :
203 : @return the rewriter of this undo object
204 : */
205 : virtual SwRewriter GetRewriter() const SAL_OVERRIDE;
206 :
207 0 : void SetNodePos( sal_uLong nNd )
208 0 : { if( LTYPE_OBJECT != eType ) NODE.nNode = nNd; }
209 :
210 0 : void SetUndoKeep() { bUndoKeep = true; }
211 : void SetFlys( SwFrmFmt& rOldFly, SfxItemSet& rChgSet, SwFrmFmt& rNewFly );
212 : void SetDrawObj( sal_uInt8 nLayerId );
213 : };
214 :
215 : #endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOINSERT_HXX
216 :
217 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|