Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCSORT_HXX
21 : #define INCLUDED_SW_SOURCE_CORE_INC_DOCSORT_HXX
22 :
23 : #include <ndindex.hxx>
24 : #include <vector>
25 :
26 : class SwDoc;
27 : class SwTableBox;
28 : class SwUndoSort;
29 : class FlatFndBox;
30 : struct SwSortOptions;
31 : struct SwSortElement;
32 : class _FndBox;
33 : class _FndLine;
34 : class CollatorWrapper;
35 : class LocaleDataWrapper;
36 :
37 : namespace com {
38 : namespace sun {
39 : namespace star {
40 : namespace lang {
41 : struct Locale;
42 : }
43 : }
44 : }
45 : }
46 :
47 8 : class SwMovedBoxes : public std::vector<const SwTableBox*>
48 : {
49 : public:
50 : sal_uInt16 GetPos(const SwTableBox* pTableBox) const;
51 : };
52 :
53 : // Functions for moving boxes
54 : void MoveCol(SwDoc* pDoc, const FlatFndBox& rBox,
55 : sal_uInt16 nS, sal_uInt16 nT, SwMovedBoxes& rMovedList, SwUndoSort* pUD=0);
56 : void MoveRow(SwDoc* pDoc, const FlatFndBox& rBox,
57 : sal_uInt16 nS, sal_uInt16 nT, SwMovedBoxes& rMovedList, SwUndoSort* pUD=0);
58 : void MoveCell(SwDoc* pDoc, const SwTableBox* pSource,
59 : const SwTableBox* pTar, bool bMovedBefore, SwUndoSort* pUD=0);
60 :
61 : // Elements for sorting text and table content
62 52 : struct SwSortElement
63 : {
64 : static SwSortOptions* pOptions;
65 : static SwDoc* pDoc;
66 : static const FlatFndBox* pBox;
67 : static CollatorWrapper* pSortCollator;
68 : static ::com::sun::star::lang::Locale* pLocale;
69 : static OUString* pLastAlgorithm;
70 : static LocaleDataWrapper* pLclData;
71 :
72 : static void Init( SwDoc*, const SwSortOptions& rOpt, FlatFndBox* = 0 );
73 : static void Finit();
74 :
75 : virtual ~SwSortElement();
76 :
77 : virtual OUString GetKey(sal_uInt16 nKey ) const = 0;
78 : virtual double GetValue(sal_uInt16 nKey ) const;
79 :
80 : bool operator==(const SwSortElement& ) const;
81 : bool operator<(const SwSortElement& ) const;
82 :
83 : double StrToDouble(const OUString& rStr) const;
84 : private:
85 : int keycompare(const SwSortElement& rCmp, sal_uInt16 nKey) const;
86 : };
87 :
88 : // sort text
89 : struct SwSortTxtElement : public SwSortElement
90 : {
91 : sal_uLong nOrg;
92 : SwNodeIndex aPos;
93 :
94 : SwSortTxtElement( const SwNodeIndex& rPos );
95 : virtual ~SwSortTxtElement();
96 :
97 : virtual OUString GetKey( sal_uInt16 nKey ) const SAL_OVERRIDE;
98 : };
99 :
100 : // sort table
101 : struct SwSortBoxElement : public SwSortElement
102 : {
103 : sal_uInt16 nRow;
104 :
105 : SwSortBoxElement( sal_uInt16 nRC );
106 : virtual ~SwSortBoxElement();
107 :
108 : virtual OUString GetKey( sal_uInt16 nKey ) const SAL_OVERRIDE;
109 : virtual double GetValue( sal_uInt16 nKey ) const SAL_OVERRIDE;
110 : };
111 :
112 : // two-dimensional array of FndBoxes
113 : class FlatFndBox
114 : {
115 : public:
116 : FlatFndBox(SwDoc* pDocPtr, const _FndBox& rBox);
117 : ~FlatFndBox();
118 :
119 4 : bool IsSymmetric() const { return bSym; }
120 4 : sal_uInt16 GetRows() const { return nRows; }
121 72 : sal_uInt16 GetCols() const { return nCols; }
122 :
123 : const _FndBox* GetBox(sal_uInt16 nCol, sal_uInt16 nRow) const;
124 :
125 : inline bool HasItemSets() const;
126 : const SfxItemSet* GetItemSet(sal_uInt16 nCol, sal_uInt16 nRow) const;
127 :
128 : private:
129 : bool CheckLineSymmetry(const _FndBox& rBox);
130 : bool CheckBoxSymmetry(const _FndLine& rLn);
131 : sal_uInt16 GetColCount(const _FndBox& rBox);
132 : sal_uInt16 GetRowCount(const _FndBox& rBox);
133 : void FillFlat(const _FndBox&, bool bLastBox=false);
134 :
135 : SwDoc* pDoc;
136 : const _FndBox& rBoxRef;
137 : const _FndBox** pArr;
138 : SfxItemSet** ppItemSets;
139 :
140 : sal_uInt16 nRows;
141 : sal_uInt16 nCols;
142 : sal_uInt16 nRow;
143 : sal_uInt16 nCol;
144 :
145 : bool bSym;
146 : };
147 :
148 4 : inline bool FlatFndBox::HasItemSets() const { return 0 != ppItemSets; }
149 :
150 : #endif
151 :
152 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|