xref: /aoo4110/main/sw/source/core/inc/UndoSort.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SW_UNDO_SORT_HXX
25 #define SW_UNDO_SORT_HXX
26 
27 #include <undobj.hxx>
28 
29 
30 struct SwSortOptions;
31 class SwTableNode;
32 class SwUndoAttrTbl;
33 
34 
35 /*--------------------------------------------------------------------
36     Undo for Sorting
37  --------------------------------------------------------------------*/
38 
39 struct SwSortUndoElement
40 {
41     union {
42         struct {
43             sal_uLong nKenn;
44             sal_uLong nSource, nTarget;
45         } TXT;
46         struct {
47             String *pSource, *pTarget;
48         } TBL;
49     } SORT_TXT_TBL;
50 
SwSortUndoElementSwSortUndoElement51     SwSortUndoElement( const String& aS, const String& aT )
52     {
53         SORT_TXT_TBL.TBL.pSource = new String( aS );
54         SORT_TXT_TBL.TBL.pTarget = new String( aT );
55     }
SwSortUndoElementSwSortUndoElement56     SwSortUndoElement( sal_uLong nS, sal_uLong nT )
57     {
58         SORT_TXT_TBL.TXT.nSource = nS;
59         SORT_TXT_TBL.TXT.nTarget = nT;
60         SORT_TXT_TBL.TXT.nKenn   = 0xffffffff;
61     }
62     ~SwSortUndoElement();
63 };
64 
65 SV_DECL_PTRARR_DEL(SwSortList, SwSortUndoElement*, 10,30)
66 SV_DECL_PTRARR(SwUndoSortList, SwNodeIndex*, 10,30)
67 
68 class SwUndoSort : public SwUndo, private SwUndRng
69 {
70     SwSortOptions*  pSortOpt;
71     SwSortList      aSortList;
72     SwUndoAttrTbl*  pUndoTblAttr;
73     SwRedlineData*  pRedlData;
74     sal_uLong           nTblNd;
75 
76 public:
77     SwUndoSort( const SwPaM&, const SwSortOptions& );
78     SwUndoSort( sal_uLong nStt, sal_uLong nEnd, const SwTableNode&,
79                 const SwSortOptions&, sal_Bool bSaveTable );
80 
81     virtual ~SwUndoSort();
82 
83     virtual void UndoImpl( ::sw::UndoRedoContext & );
84     virtual void RedoImpl( ::sw::UndoRedoContext & );
85     virtual void RepeatImpl( ::sw::RepeatContext & );
86 
87     void Insert( const String& rOrgPos, const String& rNewPos );
88     void Insert( sal_uLong nOrgPos, sal_uLong nNewPos );
89 
90 };
91 
92 #endif // SW_UNDO_SORT_HXX
93 
94