Update ooo320-m1
[ooovba.git] / sw / source / core / inc / docsort.hxx
blob8b3428fceb352112c6e80fa9ae618586f94dd21f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: docsort.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _SORT_HXX
31 #define _SORT_HXX
33 #include <svtools/svarray.hxx>
34 #include <ndindex.hxx>
37 class SwDoc;
38 class SwTableBox;
39 class SwUndoSort;
40 class FlatFndBox;
41 struct SwSortOptions;
42 struct SwSortElement;
43 class _FndBox;
44 class _FndLine;
45 class CollatorWrapper;
46 class LocaleDataWrapper;
49 namespace com { namespace sun { namespace star { namespace lang {
50 struct Locale;
51 }}}}
53 /*--------------------------------------------------------------------
54 Beschreibung: Liste aller sortierten Elemente
55 --------------------------------------------------------------------*/
56 typedef const _FndBox* _FndBoxPtr;
57 typedef SwSortElement* SwSortElementPtr;
58 typedef const SwTableBox* SwMovedBoxPtr;
60 SV_DECL_PTRARR_SORT(SwSortElements, SwSortElementPtr, 0, 1 )
61 SV_DECL_PTRARR(SwMovedBoxes, SwMovedBoxPtr, 10, 10 )
63 /*--------------------------------------------------------------------
64 Beschreibung: Funktionen zum Moven von Boxen
65 --------------------------------------------------------------------*/
67 void MoveCol(SwDoc* pDoc, const FlatFndBox& rBox,
68 USHORT nS, USHORT nT, SwMovedBoxes& rMovedList, SwUndoSort* pUD=0);
69 void MoveRow(SwDoc* pDoc, const FlatFndBox& rBox,
70 USHORT nS, USHORT nT, SwMovedBoxes& rMovedList, SwUndoSort* pUD=0);
71 void MoveCell(SwDoc* pDoc, const SwTableBox* pSource,
72 const SwTableBox* pTar, BOOL bMovedBefore, SwUndoSort* pUD=0);
74 /*-------------------------------------------------------------------
75 Beschreibung: Elemente zum Sortieren von Text und Tabellen-Inhalt
76 --------------------------------------------------------------------*/
78 struct SwSortElement
80 static SwSortOptions* pOptions;
81 static SwDoc* pDoc;
82 static const FlatFndBox* pBox;
83 static CollatorWrapper* pSortCollator;
84 static ::com::sun::star::lang::Locale* pLocale;
85 static String* pLastAlgorithm;
86 static LocaleDataWrapper* pLclData;
88 static void Init( SwDoc*, const SwSortOptions& rOpt, FlatFndBox* = 0 );
89 static void Finit();
91 virtual ~SwSortElement();
93 virtual String GetKey(USHORT nKey ) const = 0;
94 virtual double GetValue(USHORT nKey ) const;
96 BOOL operator==(const SwSortElement& );
97 BOOL operator<(const SwSortElement& );
99 double StrToDouble(const String& rStr) const;
102 /*--------------------------------------------------------------------
103 Beschreibung: Sortieren Text
104 --------------------------------------------------------------------*/
106 struct SwSortTxtElement : public SwSortElement
108 // fuer Text
109 ULONG nOrg;
110 SwNodeIndex aPos;
112 SwSortTxtElement( const SwNodeIndex& rPos );
113 virtual ~SwSortTxtElement();
115 virtual String GetKey( USHORT nKey ) const;
118 /*--------------------------------------------------------------------
119 Beschreibung: Sortieren Tabelle
120 --------------------------------------------------------------------*/
122 struct SwSortBoxElement : public SwSortElement
124 USHORT nRow;
126 SwSortBoxElement( USHORT nRC );
127 virtual ~SwSortBoxElement();
129 virtual String GetKey( USHORT nKey ) const;
130 virtual double GetValue( USHORT nKey ) const;
134 /*--------------------------------------------------------------------
135 Beschreibung: SymFndBoxes stellt ein zweidimensionales
136 Array von FndBoxes dar
137 --------------------------------------------------------------------*/
139 class FlatFndBox
141 public:
142 FlatFndBox(SwDoc* pDocPtr, const _FndBox& rBox);
143 ~FlatFndBox();
145 BOOL IsSymmetric() const { return bSym; }
146 USHORT GetRows() const { return nRows; }
147 USHORT GetCols() const { return nCols; }
149 const _FndBox* GetBox(USHORT nCol, USHORT nRow) const;
151 inline BOOL HasItemSets() const;
152 const SfxItemSet* GetItemSet(USHORT nCol, USHORT nRow) const;
154 private:
156 BOOL CheckLineSymmetry(const _FndBox& rBox);
157 BOOL CheckBoxSymmetry(const _FndLine& rLn);
158 USHORT GetColCount(const _FndBox& rBox);
159 USHORT GetRowCount(const _FndBox& rBox);
160 void FillFlat(const _FndBox&, BOOL bLastBox=FALSE);
162 SwDoc* pDoc;
163 const _FndBox& rBoxRef;
164 _FndBoxPtr* pArr;
165 SfxItemSet** ppItemSets;
167 USHORT nRows;
168 USHORT nCols;
170 USHORT nRow;
171 USHORT nCol;
173 BOOL bSym;
177 inline BOOL FlatFndBox::HasItemSets() const { return 0 != ppItemSets; }
179 #endif // _NDSORT_HXX