xref: /aoo42x/main/sw/source/core/inc/UndoAttribute.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_ATTRIBUTE_HXX
25cdf0e10cSrcweir #define SW_UNDO_ATTRIBUTE_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <undobj.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <memory>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #ifndef _SVSTDARR_HXX
32cdf0e10cSrcweir #define _SVSTDARR_USHORTS
33cdf0e10cSrcweir #define _SVSTDARR_ULONGS
34cdf0e10cSrcweir #define _SVSTDARR_BOOLS
35cdf0e10cSrcweir #define _SVSTDARR_BYTES
36cdf0e10cSrcweir #define _SVSTDARR_USHORTSSORT
37cdf0e10cSrcweir #include <svl/svstdarr.hxx>
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir #include <svl/itemset.hxx>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include <swtypes.hxx>
42cdf0e10cSrcweir #include <calbck.hxx>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir 
45cdf0e10cSrcweir class SvxTabStopItem;
46cdf0e10cSrcweir class SwFmt;
47cdf0e10cSrcweir class SwFtnInfo;
48cdf0e10cSrcweir class SwEndNoteInfo;
49cdf0e10cSrcweir 
50cdf0e10cSrcweir 
51cdf0e10cSrcweir class SwUndoAttr : public SwUndo, private SwUndRng
52cdf0e10cSrcweir {
53cdf0e10cSrcweir     SfxItemSet m_AttrSet;                           // attributes for Redo
54cdf0e10cSrcweir     const ::std::auto_ptr<SwHistory> m_pHistory;    // History for Undo
55cdf0e10cSrcweir     ::std::auto_ptr<SwRedlineData> m_pRedlineData;  // Redlining
56cdf0e10cSrcweir     ::std::auto_ptr<SwRedlineSaveDatas> m_pRedlineSaveData;
57cdf0e10cSrcweir     sal_uLong m_nNodeIndex;                             // Offset: for Redlining
58cdf0e10cSrcweir     const SetAttrMode m_nInsertFlags;               // insert flags
59cdf0e10cSrcweir 
60cdf0e10cSrcweir     void RemoveIdx( SwDoc& rDoc );
61cdf0e10cSrcweir 
62cdf0e10cSrcweir public:
63cdf0e10cSrcweir     SwUndoAttr( const SwPaM&, const SfxItemSet &, const SetAttrMode nFlags );
64cdf0e10cSrcweir     SwUndoAttr( const SwPaM&, const SfxPoolItem&, const SetAttrMode nFlags );
65cdf0e10cSrcweir 
66cdf0e10cSrcweir     virtual ~SwUndoAttr();
67cdf0e10cSrcweir 
68cdf0e10cSrcweir     virtual void UndoImpl( ::sw::UndoRedoContext & );
69cdf0e10cSrcweir     virtual void RedoImpl( ::sw::UndoRedoContext & );
70cdf0e10cSrcweir     virtual void RepeatImpl( ::sw::RepeatContext & );
71cdf0e10cSrcweir 
72cdf0e10cSrcweir     void SaveRedlineData( const SwPaM& rPam, sal_Bool bInsCntnt );
73cdf0e10cSrcweir 
GetHistory()74cdf0e10cSrcweir     SwHistory& GetHistory() { return *m_pHistory; }
75cdf0e10cSrcweir 
76cdf0e10cSrcweir };
77cdf0e10cSrcweir 
78cdf0e10cSrcweir class SwUndoResetAttr : public SwUndo, private SwUndRng
79cdf0e10cSrcweir {
80cdf0e10cSrcweir     const ::std::auto_ptr<SwHistory> m_pHistory;
81cdf0e10cSrcweir     SvUShortsSort m_Ids;
82cdf0e10cSrcweir     const sal_uInt16 m_nFormatId;             // Format-Id for Redo
83cdf0e10cSrcweir 
84cdf0e10cSrcweir public:
85cdf0e10cSrcweir     SwUndoResetAttr( const SwPaM&, sal_uInt16 nFmtId );
86cdf0e10cSrcweir     SwUndoResetAttr( const SwPosition&, sal_uInt16 nFmtId );
87cdf0e10cSrcweir 
88cdf0e10cSrcweir     virtual ~SwUndoResetAttr();
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     virtual void UndoImpl( ::sw::UndoRedoContext & );
91cdf0e10cSrcweir     virtual void RedoImpl( ::sw::UndoRedoContext & );
92cdf0e10cSrcweir     virtual void RepeatImpl( ::sw::RepeatContext & );
93cdf0e10cSrcweir 
94cdf0e10cSrcweir     void SetAttrs( const SvUShortsSort& rArr );
95cdf0e10cSrcweir 
GetHistory()96cdf0e10cSrcweir     SwHistory& GetHistory() { return *m_pHistory; }
97cdf0e10cSrcweir 
98cdf0e10cSrcweir };
99cdf0e10cSrcweir 
100cdf0e10cSrcweir class SwUndoFmtAttr : public SwUndo
101cdf0e10cSrcweir {
102cdf0e10cSrcweir     friend class SwUndoDefaultAttr;
103cdf0e10cSrcweir     SwFmt * m_pFmt;
104cdf0e10cSrcweir     ::std::auto_ptr<SfxItemSet> m_pOldSet;    // old attributes
105cdf0e10cSrcweir     sal_uLong m_nNodeIndex;
106cdf0e10cSrcweir     const sal_uInt16 m_nFmtWhich;
107cdf0e10cSrcweir     const bool m_bSaveDrawPt;
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     bool IsFmtInDoc( SwDoc* );   //is the attribute format still in the Doc?
110cdf0e10cSrcweir     void SaveFlyAnchor( bool bSaveDrawPt = false );
111cdf0e10cSrcweir     // --> OD 2004-10-26 #i35443# - Add return value, type <bool>.
112cdf0e10cSrcweir     // Return value indicates, if anchor attribute is restored.
113cdf0e10cSrcweir     // Notes: - If anchor attribute is restored, all other existing attributes
114cdf0e10cSrcweir     //          are also restored.
115cdf0e10cSrcweir     //        - Anchor attribute isn't restored successfully, if it contains
116cdf0e10cSrcweir     //          an invalid anchor position and all other existing attributes
117cdf0e10cSrcweir     //          aren't restored.
118cdf0e10cSrcweir     //          This situation occurs for undo of styles.
119cdf0e10cSrcweir     bool RestoreFlyAnchor(::sw::UndoRedoContext & rContext);
120cdf0e10cSrcweir     // <--
121cdf0e10cSrcweir     // --> OD 2008-02-27 #refactorlists# - removed <rAffectedItemSet>
122cdf0e10cSrcweir     void Init();
123cdf0e10cSrcweir     // <--
124cdf0e10cSrcweir 
125cdf0e10cSrcweir public:
126cdf0e10cSrcweir     // register at the Format and save old attributes
127cdf0e10cSrcweir     // --> OD 2008-02-27 #refactorlists# - removed <rNewSet>
128cdf0e10cSrcweir     SwUndoFmtAttr( const SfxItemSet& rOldSet,
129cdf0e10cSrcweir                    SwFmt& rFmt,
130cdf0e10cSrcweir                    bool bSaveDrawPt = true );
131cdf0e10cSrcweir     // <--
132cdf0e10cSrcweir     SwUndoFmtAttr( const SfxPoolItem& rItem,
133cdf0e10cSrcweir                    SwFmt& rFmt,
134cdf0e10cSrcweir                    bool bSaveDrawPt = true );
135cdf0e10cSrcweir 
136cdf0e10cSrcweir     virtual ~SwUndoFmtAttr();
137cdf0e10cSrcweir 
138cdf0e10cSrcweir     virtual void UndoImpl( ::sw::UndoRedoContext & );
139cdf0e10cSrcweir     virtual void RedoImpl( ::sw::UndoRedoContext & );
140cdf0e10cSrcweir     virtual void RepeatImpl( ::sw::RepeatContext & );
141cdf0e10cSrcweir 
142cdf0e10cSrcweir     virtual SwRewriter GetRewriter() const;
143cdf0e10cSrcweir 
144cdf0e10cSrcweir     void PutAttr( const SfxPoolItem& rItem );
145cdf0e10cSrcweir     SwFmt* GetFmt( SwDoc& rDoc );   // checks if it is still in the Doc!
146cdf0e10cSrcweir };
147cdf0e10cSrcweir 
148cdf0e10cSrcweir // --> OD 2008-02-12 #newlistlevelattrs#
149cdf0e10cSrcweir class SwUndoFmtResetAttr : public SwUndo
150cdf0e10cSrcweir {
151cdf0e10cSrcweir     public:
152cdf0e10cSrcweir         SwUndoFmtResetAttr( SwFmt& rChangedFormat,
153cdf0e10cSrcweir                             const sal_uInt16 nWhichId );
154cdf0e10cSrcweir         ~SwUndoFmtResetAttr();
155cdf0e10cSrcweir 
156cdf0e10cSrcweir         virtual void UndoImpl( ::sw::UndoRedoContext & );
157cdf0e10cSrcweir         virtual void RedoImpl( ::sw::UndoRedoContext & );
158cdf0e10cSrcweir 
159cdf0e10cSrcweir     private:
160cdf0e10cSrcweir         // format at which a certain attribute is reset.
161cdf0e10cSrcweir         SwFmt * const m_pChangedFormat;
162cdf0e10cSrcweir         // which ID of the reset attribute
163cdf0e10cSrcweir         const sal_uInt16 m_nWhichId;
164cdf0e10cSrcweir         // old attribute which has been reset - needed for undo.
165cdf0e10cSrcweir         ::std::auto_ptr<SfxPoolItem> m_pOldItem;
166cdf0e10cSrcweir };
167cdf0e10cSrcweir // <--
168cdf0e10cSrcweir 
169cdf0e10cSrcweir class SwUndoDontExpandFmt : public SwUndo
170cdf0e10cSrcweir {
171cdf0e10cSrcweir     const sal_uLong m_nNodeIndex;
172cdf0e10cSrcweir     const xub_StrLen m_nContentIndex;
173cdf0e10cSrcweir 
174cdf0e10cSrcweir public:
175cdf0e10cSrcweir     SwUndoDontExpandFmt( const SwPosition& rPos );
176cdf0e10cSrcweir 
177cdf0e10cSrcweir     virtual void UndoImpl( ::sw::UndoRedoContext & );
178cdf0e10cSrcweir     virtual void RedoImpl( ::sw::UndoRedoContext & );
179cdf0e10cSrcweir     virtual void RepeatImpl( ::sw::RepeatContext & );
180cdf0e10cSrcweir };
181cdf0e10cSrcweir 
182cdf0e10cSrcweir // helper class to receive changed attribute sets
183cdf0e10cSrcweir class SwUndoFmtAttrHelper : public SwClient
184cdf0e10cSrcweir {
185cdf0e10cSrcweir     ::std::auto_ptr<SwUndoFmtAttr> m_pUndo;
186cdf0e10cSrcweir     const bool m_bSaveDrawPt;
187cdf0e10cSrcweir 
188cdf0e10cSrcweir public:
189cdf0e10cSrcweir     SwUndoFmtAttrHelper( SwFmt& rFmt, bool bSaveDrawPt = true );
190cdf0e10cSrcweir 
191cdf0e10cSrcweir     virtual void Modify( const SfxPoolItem*, const SfxPoolItem* );
192cdf0e10cSrcweir 
GetUndo() const193cdf0e10cSrcweir     SwUndoFmtAttr* GetUndo() const  { return m_pUndo.get(); }
194cdf0e10cSrcweir     // release the undo object (so it is not deleted here), and return it
ReleaseUndo()195cdf0e10cSrcweir     SwUndoFmtAttr* ReleaseUndo()    { return m_pUndo.release(); }
196cdf0e10cSrcweir };
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 
199cdf0e10cSrcweir class SwUndoMoveLeftMargin : public SwUndo, private SwUndRng
200cdf0e10cSrcweir {
201cdf0e10cSrcweir     const ::std::auto_ptr<SwHistory> m_pHistory;
202cdf0e10cSrcweir     const bool m_bModulus;
203cdf0e10cSrcweir 
204cdf0e10cSrcweir public:
205cdf0e10cSrcweir     SwUndoMoveLeftMargin( const SwPaM&, sal_Bool bRight, sal_Bool bModulus );
206cdf0e10cSrcweir 
207cdf0e10cSrcweir     virtual ~SwUndoMoveLeftMargin();
208cdf0e10cSrcweir 
209cdf0e10cSrcweir     virtual void UndoImpl( ::sw::UndoRedoContext & );
210cdf0e10cSrcweir     virtual void RedoImpl( ::sw::UndoRedoContext & );
211cdf0e10cSrcweir     virtual void RepeatImpl( ::sw::RepeatContext & );
212cdf0e10cSrcweir 
GetHistory()213cdf0e10cSrcweir     SwHistory& GetHistory() { return *m_pHistory; }
214cdf0e10cSrcweir 
215cdf0e10cSrcweir };
216cdf0e10cSrcweir 
217cdf0e10cSrcweir 
218cdf0e10cSrcweir //--------------------------------------------------------------------
219cdf0e10cSrcweir 
220cdf0e10cSrcweir class SwUndoDefaultAttr : public SwUndo
221cdf0e10cSrcweir {
222cdf0e10cSrcweir     ::std::auto_ptr<SfxItemSet> m_pOldSet;        // the old attributes
223cdf0e10cSrcweir     ::std::auto_ptr<SvxTabStopItem> m_pTabStop;
224cdf0e10cSrcweir 
225cdf0e10cSrcweir public:
226cdf0e10cSrcweir     // registers at the format and saves old attributes
227cdf0e10cSrcweir     SwUndoDefaultAttr( const SfxItemSet& rOldSet );
228cdf0e10cSrcweir 
229cdf0e10cSrcweir     virtual ~SwUndoDefaultAttr();
230cdf0e10cSrcweir 
231cdf0e10cSrcweir     virtual void UndoImpl( ::sw::UndoRedoContext & );
232cdf0e10cSrcweir     virtual void RedoImpl( ::sw::UndoRedoContext & );
233cdf0e10cSrcweir };
234cdf0e10cSrcweir 
235cdf0e10cSrcweir 
236cdf0e10cSrcweir //--------------------------------------------------------------------
237cdf0e10cSrcweir 
238cdf0e10cSrcweir class SwUndoChangeFootNote : public SwUndo, private SwUndRng
239cdf0e10cSrcweir {
240cdf0e10cSrcweir     const ::std::auto_ptr<SwHistory> m_pHistory;
241cdf0e10cSrcweir     const String m_Text;
242cdf0e10cSrcweir     const sal_uInt16 m_nNumber;
243cdf0e10cSrcweir     const bool m_bEndNote;
244cdf0e10cSrcweir 
245cdf0e10cSrcweir public:
246cdf0e10cSrcweir     SwUndoChangeFootNote( const SwPaM& rRange, const String& rTxt,
247cdf0e10cSrcweir                           sal_uInt16 nNum, bool bIsEndNote );
248cdf0e10cSrcweir     virtual ~SwUndoChangeFootNote();
249cdf0e10cSrcweir 
250cdf0e10cSrcweir     virtual void UndoImpl( ::sw::UndoRedoContext & );
251cdf0e10cSrcweir     virtual void RedoImpl( ::sw::UndoRedoContext & );
252cdf0e10cSrcweir     virtual void RepeatImpl( ::sw::RepeatContext & );
253cdf0e10cSrcweir 
GetHistory()254cdf0e10cSrcweir     SwHistory& GetHistory() { return *m_pHistory; }
255cdf0e10cSrcweir };
256cdf0e10cSrcweir 
257cdf0e10cSrcweir class SwUndoFootNoteInfo : public SwUndo
258cdf0e10cSrcweir {
259cdf0e10cSrcweir     ::std::auto_ptr<SwFtnInfo> m_pFootNoteInfo;
260cdf0e10cSrcweir 
261cdf0e10cSrcweir public:
262cdf0e10cSrcweir     SwUndoFootNoteInfo( const SwFtnInfo &rInfo );
263cdf0e10cSrcweir 
264cdf0e10cSrcweir     virtual ~SwUndoFootNoteInfo();
265cdf0e10cSrcweir 
266cdf0e10cSrcweir     virtual void UndoImpl( ::sw::UndoRedoContext & );
267cdf0e10cSrcweir     virtual void RedoImpl( ::sw::UndoRedoContext & );
268cdf0e10cSrcweir };
269cdf0e10cSrcweir 
270cdf0e10cSrcweir class SwUndoEndNoteInfo : public SwUndo
271cdf0e10cSrcweir {
272cdf0e10cSrcweir     ::std::auto_ptr<SwEndNoteInfo> m_pEndNoteInfo;
273cdf0e10cSrcweir 
274cdf0e10cSrcweir public:
275cdf0e10cSrcweir     SwUndoEndNoteInfo( const SwEndNoteInfo &rInfo );
276cdf0e10cSrcweir 
277cdf0e10cSrcweir     virtual ~SwUndoEndNoteInfo();
278cdf0e10cSrcweir 
279cdf0e10cSrcweir     virtual void UndoImpl( ::sw::UndoRedoContext & );
280cdf0e10cSrcweir     virtual void RedoImpl( ::sw::UndoRedoContext & );
281cdf0e10cSrcweir };
282cdf0e10cSrcweir 
283cdf0e10cSrcweir #endif // SW_UNDO_ATTRIBUTE_HXX
284cdf0e10cSrcweir 
285