xref: /aoo41x/main/sw/source/core/inc/UndoSort.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SW_UNDO_SORT_HXX
29 #define SW_UNDO_SORT_HXX
30 
31 #include <undobj.hxx>
32 
33 
34 struct SwSortOptions;
35 class SwTableNode;
36 class SwUndoAttrTbl;
37 
38 
39 /*--------------------------------------------------------------------
40     Undo for Sorting
41  --------------------------------------------------------------------*/
42 
43 struct SwSortUndoElement
44 {
45     union {
46         struct {
47             sal_uLong nKenn;
48             sal_uLong nSource, nTarget;
49         } TXT;
50         struct {
51             String *pSource, *pTarget;
52         } TBL;
53     } SORT_TXT_TBL;
54 
55     SwSortUndoElement( const String& aS, const String& aT )
56     {
57         SORT_TXT_TBL.TBL.pSource = new String( aS );
58         SORT_TXT_TBL.TBL.pTarget = new String( aT );
59     }
60     SwSortUndoElement( sal_uLong nS, sal_uLong nT )
61     {
62         SORT_TXT_TBL.TXT.nSource = nS;
63         SORT_TXT_TBL.TXT.nTarget = nT;
64         SORT_TXT_TBL.TXT.nKenn   = 0xffffffff;
65     }
66     ~SwSortUndoElement();
67 };
68 
69 SV_DECL_PTRARR_DEL(SwSortList, SwSortUndoElement*, 10,30)
70 SV_DECL_PTRARR(SwUndoSortList, SwNodeIndex*, 10,30)
71 
72 class SwUndoSort : public SwUndo, private SwUndRng
73 {
74     SwSortOptions*  pSortOpt;
75     SwSortList      aSortList;
76     SwUndoAttrTbl*  pUndoTblAttr;
77     SwRedlineData*  pRedlData;
78     sal_uLong           nTblNd;
79 
80 public:
81     SwUndoSort( const SwPaM&, const SwSortOptions& );
82     SwUndoSort( sal_uLong nStt, sal_uLong nEnd, const SwTableNode&,
83                 const SwSortOptions&, sal_Bool bSaveTable );
84 
85     virtual ~SwUndoSort();
86 
87     virtual void UndoImpl( ::sw::UndoRedoContext & );
88     virtual void RedoImpl( ::sw::UndoRedoContext & );
89     virtual void RepeatImpl( ::sw::RepeatContext & );
90 
91     void Insert( const String& rOrgPos, const String& rNewPos );
92     void Insert( sal_uLong nOrgPos, sal_uLong nNewPos );
93 
94 };
95 
96 #endif // SW_UNDO_SORT_HXX
97 
98