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_UNDOCORE_HXX
30 : : #define SW_UNDOCORE_HXX
31 : :
32 : : #include <undobj.hxx>
33 : : #include <calbck.hxx>
34 : :
35 : : class SfxItemSet;
36 : : class SwFmtColl;
37 : : class SwFmtAnchor;
38 : : class SdrMarkList;
39 : : class SwUndoDelete;
40 : : class SwRedlineSaveData;
41 : : class SwFmt;
42 : :
43 : : namespace sw {
44 : : class UndoManager;
45 : : class IShellCursorSupplier;
46 : : }
47 : :
48 : 46 : class SwRedlineSaveDatas : public std::vector<SwRedlineSaveData*> {
49 : : public:
50 [ + - ]: 46 : ~SwRedlineSaveDatas() { DeleteAndDestroyAll(); }
51 : :
52 : : void DeleteAndDestroyAll();
53 : : };
54 : :
55 : : namespace sw {
56 [ - + ]: 52 : class SW_DLLPRIVATE UndoRedoContext
57 : : : public SfxUndoContext
58 : : {
59 : : public:
60 : 52 : UndoRedoContext(SwDoc & rDoc, IShellCursorSupplier & rCursorSupplier)
61 : : : m_rDoc(rDoc)
62 : : , m_rCursorSupplier(rCursorSupplier)
63 : : , m_pSelFmt(0)
64 : 52 : , m_pMarkList(0)
65 : 52 : { }
66 : :
67 : 28 : SwDoc & GetDoc() const { return m_rDoc; }
68 : :
69 : 10 : IShellCursorSupplier & GetCursorSupplier() { return m_rCursorSupplier; }
70 : :
71 : 0 : void SetSelections(SwFrmFmt *const pSelFmt, SdrMarkList *const pMarkList)
72 : : {
73 : 0 : m_pSelFmt = pSelFmt;
74 : 0 : m_pMarkList = pMarkList;
75 : 0 : }
76 : 44 : void GetSelections(SwFrmFmt *& o_rpSelFmt, SdrMarkList *& o_rpMarkList)
77 : : {
78 : 44 : o_rpSelFmt = m_pSelFmt;
79 : 44 : o_rpMarkList = m_pMarkList;
80 : 44 : }
81 : :
82 : : private:
83 : : SwDoc & m_rDoc;
84 : : IShellCursorSupplier & m_rCursorSupplier;
85 : : SwFrmFmt * m_pSelFmt;
86 : : SdrMarkList * m_pMarkList;
87 : : };
88 : :
89 [ # # ]: 0 : class SW_DLLPRIVATE RepeatContext
90 : : : public SfxRepeatTarget
91 : : {
92 : : public:
93 : 0 : RepeatContext(SwDoc & rDoc, SwPaM & rPaM)
94 : : : m_rDoc(rDoc)
95 : : , m_pCurrentPaM(& rPaM)
96 : 0 : , m_bDeleteRepeated(false)
97 : 0 : { }
98 : :
99 : 0 : SwDoc & GetDoc() const { return m_rDoc; }
100 : :
101 : 0 : SwPaM & GetRepeatPaM()
102 : : {
103 : 0 : return *m_pCurrentPaM;
104 : : }
105 : :
106 : : private:
107 : : friend class ::sw::UndoManager;
108 : : friend class ::SwUndoDelete;
109 : :
110 : : SwDoc & m_rDoc;
111 : : SwPaM * m_pCurrentPaM;
112 : : bool m_bDeleteRepeated; /// has a delete action been repeated?
113 : : };
114 : :
115 : : } // namespace sw
116 : :
117 : : class SwUndoFmtColl : public SwUndo, private SwUndRng
118 : : {
119 : : String aFmtName;
120 : : SwHistory* pHistory;
121 : : SwFmtColl* pFmtColl;
122 : : // for correct <ReDo(..)> and <Repeat(..)>
123 : : // boolean, which indicates that the attributes are reseted at the nodes
124 : : // before the format has been applied.
125 : : const bool mbReset;
126 : : // boolean, which indicates that the list attributes had been reseted at
127 : : // the nodes before the format has been applied.
128 : : const bool mbResetListAttrs;
129 : :
130 : : void DoSetFmtColl(SwDoc & rDoc, SwPaM & rPaM);
131 : :
132 : : public:
133 : : SwUndoFmtColl( const SwPaM&, SwFmtColl*,
134 : : const bool bReset,
135 : : const bool bResetListAttrs );
136 : : virtual ~SwUndoFmtColl();
137 : :
138 : : virtual void UndoImpl( ::sw::UndoRedoContext & );
139 : : virtual void RedoImpl( ::sw::UndoRedoContext & );
140 : : virtual void RepeatImpl( ::sw::RepeatContext & );
141 : :
142 : : /**
143 : : Returns the rewriter for this undo object.
144 : :
145 : : The rewriter contains one rule:
146 : :
147 : : $1 -> <name of format collection>
148 : :
149 : : <name of format collection> is the name of the format
150 : : collection that is applied by the action recorded by this undo
151 : : object.
152 : :
153 : : @return the rewriter for this undo object
154 : : */
155 : : virtual SwRewriter GetRewriter() const;
156 : :
157 : 8 : SwHistory* GetHistory() { return pHistory; }
158 : :
159 : : };
160 : :
161 : : class SwUndoSetFlyFmt : public SwUndo, public SwClient
162 : : {
163 : : SwFrmFmt* pFrmFmt; // saved FlyFormat
164 : : SwFrmFmt* pOldFmt;
165 : : SwFrmFmt* pNewFmt;
166 : : SfxItemSet* pItemSet; // the re-/ set attributes
167 : : sal_uLong nOldNode, nNewNode;
168 : : xub_StrLen nOldCntnt, nNewCntnt;
169 : : sal_uInt16 nOldAnchorTyp, nNewAnchorTyp;
170 : : sal_Bool bAnchorChgd;
171 : :
172 : : void PutAttr( sal_uInt16 nWhich, const SfxPoolItem* pItem );
173 : : void Modify( const SfxPoolItem*, const SfxPoolItem* );
174 : : void GetAnchor( SwFmtAnchor& rAnhor, sal_uLong nNode, xub_StrLen nCntnt );
175 : :
176 : : public:
177 : : SwUndoSetFlyFmt( SwFrmFmt& rFlyFmt, SwFrmFmt& rNewFrmFmt );
178 : : virtual ~SwUndoSetFlyFmt();
179 : :
180 : : virtual void UndoImpl( ::sw::UndoRedoContext & );
181 : : virtual void RedoImpl( ::sw::UndoRedoContext & );
182 : :
183 : : virtual SwRewriter GetRewriter() const;
184 : : void DeRegisterFromFormat( SwFmt& );
185 : : };
186 : :
187 [ # # ]: 0 : class SwUndoOutlineLeftRight : public SwUndo, private SwUndRng
188 : : {
189 : : short nOffset;
190 : :
191 : : public:
192 : : SwUndoOutlineLeftRight( const SwPaM& rPam, short nOffset );
193 : :
194 : : virtual void UndoImpl( ::sw::UndoRedoContext & );
195 : : virtual void RedoImpl( ::sw::UndoRedoContext & );
196 : : virtual void RepeatImpl( ::sw::RepeatContext & );
197 : : };
198 : :
199 : : const int nUndoStringLength = 20;
200 : :
201 : : /**
202 : : Shortens a string to a maximum length.
203 : :
204 : : @param rStr the string to be shortened
205 : : @param nLength the maximum length for rStr
206 : : @param rFillStr string to replace cut out characters with
207 : :
208 : : If rStr has less than nLength characters it will be returned unaltered.
209 : :
210 : : If rStr has more than nLength characters the following algorithm
211 : : generates the shortened string:
212 : :
213 : : frontLength = (nLength - length(rFillStr)) / 2
214 : : rearLength = nLength - length(rFillStr) - frontLength
215 : : shortenedString = concat(<first frontLength characters of rStr,
216 : : rFillStr,
217 : : <last rearLength characters of rStr>)
218 : :
219 : : Preconditions:
220 : : - nLength - length(rFillStr) >= 2
221 : :
222 : : @return the shortened string
223 : : */
224 : : String
225 : : ShortenString(const String & rStr, xub_StrLen nLength, const String & rFillStr);
226 : : /**
227 : : Denotes special characters in a string.
228 : :
229 : : The rStr is split into parts containing special characters and
230 : : parts not containing special characters. In a part containing
231 : : special characters all characters are equal. These parts are
232 : : maximal.
233 : :
234 : : @param rStr the string to denote in
235 : :
236 : : The resulting string is generated by concatenating the found
237 : : parts. The parts without special characters are surrounded by
238 : : "'". The parts containing special characters are denoted as "n x",
239 : : where n is the length of the part and x is the representation of
240 : : the special character (i. e. "tab(s)").
241 : :
242 : : @return the denoted string
243 : : */
244 : : String DenoteSpecialCharacters(const String & rStr);
245 : :
246 : : #endif // SW_UNDOCORE_HXX
247 : :
248 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|