xref: /aoo41x/main/sw/source/core/inc/docsort.hxx (revision 1d2dbeb0)
1*1d2dbeb0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
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 #ifndef _SORT_HXX
24cdf0e10cSrcweir #define _SORT_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <svl/svarray.hxx>
27cdf0e10cSrcweir #include <ndindex.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir 
30cdf0e10cSrcweir class SwDoc;
31cdf0e10cSrcweir class SwTableBox;
32cdf0e10cSrcweir class SwUndoSort;
33cdf0e10cSrcweir class FlatFndBox;
34cdf0e10cSrcweir struct SwSortOptions;
35cdf0e10cSrcweir struct SwSortElement;
36cdf0e10cSrcweir class _FndBox;
37cdf0e10cSrcweir class _FndLine;
38cdf0e10cSrcweir class CollatorWrapper;
39cdf0e10cSrcweir class LocaleDataWrapper;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir 
42cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace lang {
43cdf0e10cSrcweir 	struct Locale;
44cdf0e10cSrcweir }}}}
45cdf0e10cSrcweir 
46cdf0e10cSrcweir /*--------------------------------------------------------------------
47cdf0e10cSrcweir 	Beschreibung: Liste aller sortierten Elemente
48cdf0e10cSrcweir  --------------------------------------------------------------------*/
49cdf0e10cSrcweir typedef const _FndBox* 		_FndBoxPtr;
50cdf0e10cSrcweir typedef SwSortElement* 		SwSortElementPtr;
51cdf0e10cSrcweir typedef const SwTableBox* 	SwMovedBoxPtr;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir SV_DECL_PTRARR_SORT(SwSortElements, SwSortElementPtr, 0, 1 )
54cdf0e10cSrcweir SV_DECL_PTRARR(SwMovedBoxes, 		SwMovedBoxPtr, 10, 10 )
55cdf0e10cSrcweir 
56cdf0e10cSrcweir /*--------------------------------------------------------------------
57cdf0e10cSrcweir 	Beschreibung: Funktionen zum Moven von Boxen
58cdf0e10cSrcweir  --------------------------------------------------------------------*/
59cdf0e10cSrcweir 
60cdf0e10cSrcweir void MoveCol(SwDoc* pDoc, const FlatFndBox& rBox,
61cdf0e10cSrcweir 			 sal_uInt16 nS, sal_uInt16 nT, SwMovedBoxes& rMovedList, SwUndoSort* pUD=0);
62cdf0e10cSrcweir void MoveRow(SwDoc* pDoc, const FlatFndBox& rBox,
63cdf0e10cSrcweir 			 sal_uInt16 nS, sal_uInt16 nT, SwMovedBoxes& rMovedList, SwUndoSort* pUD=0);
64cdf0e10cSrcweir void MoveCell(SwDoc* pDoc, const SwTableBox* pSource,
65cdf0e10cSrcweir 			  const SwTableBox* pTar, sal_Bool bMovedBefore, SwUndoSort* pUD=0);
66cdf0e10cSrcweir 
67cdf0e10cSrcweir /*-------------------------------------------------------------------
68cdf0e10cSrcweir 	Beschreibung: Elemente zum Sortieren von Text und Tabellen-Inhalt
69cdf0e10cSrcweir  --------------------------------------------------------------------*/
70cdf0e10cSrcweir 
71cdf0e10cSrcweir struct SwSortElement
72cdf0e10cSrcweir {
73cdf0e10cSrcweir 	static SwSortOptions*		pOptions;
74cdf0e10cSrcweir 	static SwDoc*				pDoc;
75cdf0e10cSrcweir 	static const FlatFndBox*	pBox;
76cdf0e10cSrcweir 	static CollatorWrapper*		pSortCollator;
77cdf0e10cSrcweir 	static ::com::sun::star::lang::Locale* pLocale;
78cdf0e10cSrcweir 	static String*				pLastAlgorithm;
79cdf0e10cSrcweir 	static LocaleDataWrapper* 	pLclData;
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 	static void Init( SwDoc*, const SwSortOptions& rOpt, FlatFndBox* = 0 );
82cdf0e10cSrcweir 	static void Finit();
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 	virtual ~SwSortElement();
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 	virtual	String GetKey(sal_uInt16 nKey ) const = 0;
87cdf0e10cSrcweir 	virtual	double GetValue(sal_uInt16 nKey ) const;
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 	sal_Bool operator==(const SwSortElement& );
90cdf0e10cSrcweir 	sal_Bool operator<(const SwSortElement& );
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 	double StrToDouble(const String& rStr) const;
93cdf0e10cSrcweir };
94cdf0e10cSrcweir 
95cdf0e10cSrcweir /*--------------------------------------------------------------------
96cdf0e10cSrcweir 	Beschreibung: Sortieren Text
97cdf0e10cSrcweir  --------------------------------------------------------------------*/
98cdf0e10cSrcweir 
99cdf0e10cSrcweir struct SwSortTxtElement : public SwSortElement
100cdf0e10cSrcweir {
101cdf0e10cSrcweir 	// fuer Text
102cdf0e10cSrcweir 	sal_uLong 			nOrg;
103cdf0e10cSrcweir 	SwNodeIndex		aPos;
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 	SwSortTxtElement( const SwNodeIndex& rPos );
106cdf0e10cSrcweir 	virtual ~SwSortTxtElement();
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	virtual String GetKey( sal_uInt16 nKey ) const;
109cdf0e10cSrcweir };
110cdf0e10cSrcweir 
111cdf0e10cSrcweir /*--------------------------------------------------------------------
112cdf0e10cSrcweir 	Beschreibung: Sortieren Tabelle
113cdf0e10cSrcweir  --------------------------------------------------------------------*/
114cdf0e10cSrcweir 
115cdf0e10cSrcweir struct SwSortBoxElement : public SwSortElement
116cdf0e10cSrcweir {
117cdf0e10cSrcweir 	sal_uInt16 						nRow;
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 	SwSortBoxElement( sal_uInt16 nRC );
120cdf0e10cSrcweir 	virtual ~SwSortBoxElement();
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 	virtual String GetKey( sal_uInt16 nKey ) const;
123cdf0e10cSrcweir 	virtual	double GetValue( sal_uInt16 nKey ) const;
124cdf0e10cSrcweir };
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 
127cdf0e10cSrcweir /*--------------------------------------------------------------------
128cdf0e10cSrcweir 	Beschreibung: SymFndBoxes stellt ein zweidimensionales
129cdf0e10cSrcweir 				  Array von FndBoxes dar
130cdf0e10cSrcweir  --------------------------------------------------------------------*/
131cdf0e10cSrcweir 
132cdf0e10cSrcweir class FlatFndBox
133cdf0e10cSrcweir {
134cdf0e10cSrcweir public:
135cdf0e10cSrcweir 	FlatFndBox(SwDoc* pDocPtr, const _FndBox& rBox);
136cdf0e10cSrcweir 	~FlatFndBox();
137cdf0e10cSrcweir 
IsSymmetric() const138cdf0e10cSrcweir 	sal_Bool 				IsSymmetric() const { return bSym; 	}
GetRows() const139cdf0e10cSrcweir 	sal_uInt16				GetRows()	  const { return nRows;	}
GetCols() const140cdf0e10cSrcweir 	sal_uInt16				GetCols()	  const { return nCols;	}
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 	const _FndBox* 		GetBox(sal_uInt16 nCol, sal_uInt16 nRow) const;
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 	inline sal_Bool			HasItemSets() const;
145cdf0e10cSrcweir 	const SfxItemSet* 	GetItemSet(sal_uInt16 nCol, sal_uInt16 nRow) const;
146cdf0e10cSrcweir 
147cdf0e10cSrcweir private:
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 	sal_Bool 				CheckLineSymmetry(const _FndBox& rBox);
150cdf0e10cSrcweir 	sal_Bool 				CheckBoxSymmetry(const _FndLine& rLn);
151cdf0e10cSrcweir 	sal_uInt16 				GetColCount(const _FndBox& rBox);
152cdf0e10cSrcweir 	sal_uInt16 				GetRowCount(const _FndBox& rBox);
153cdf0e10cSrcweir 	void 		   		FillFlat(const _FndBox&, sal_Bool bLastBox=sal_False);
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 	SwDoc*				pDoc;
156cdf0e10cSrcweir 	const _FndBox&		rBoxRef;
157cdf0e10cSrcweir 	_FndBoxPtr* 		pArr;
158cdf0e10cSrcweir 	SfxItemSet** 		ppItemSets;
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 	sal_uInt16 	 			nRows;
161cdf0e10cSrcweir 	sal_uInt16   	   		nCols;
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	sal_uInt16 				nRow;
164cdf0e10cSrcweir 	sal_uInt16 				nCol;
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 	sal_Bool				bSym;
167cdf0e10cSrcweir };
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 
HasItemSets() const170cdf0e10cSrcweir inline sal_Bool FlatFndBox::HasItemSets() const	{ return 0 != ppItemSets; }
171cdf0e10cSrcweir 
172cdf0e10cSrcweir #endif // _NDSORT_HXX
173