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 16 : class SwMovedBoxes
48 : {
49 : private:
50 : std::vector<const SwTableBox*> mBoxes;
51 :
52 : public:
53 96 : void push_back(const SwTableBox* &rpTableBox) {mBoxes.push_back(rpTableBox);}
54 :
55 : sal_uInt16 GetPos(const SwTableBox* pTableBox) const;
56 : };
57 :
58 : // Functions for moving boxes
59 : void MoveCol(SwDoc* pDoc, const FlatFndBox& rBox,
60 : sal_uInt16 nS, sal_uInt16 nT, SwMovedBoxes& rMovedList, SwUndoSort* pUD=0);
61 : void MoveRow(SwDoc* pDoc, const FlatFndBox& rBox,
62 : sal_uInt16 nS, sal_uInt16 nT, SwMovedBoxes& rMovedList, SwUndoSort* pUD=0);
63 : void MoveCell(SwDoc* pDoc, const SwTableBox* pSource,
64 : const SwTableBox* pTar, bool bMovedBefore, SwUndoSort* pUD=0);
65 :
66 : // Elements for sorting text and table content
67 104 : struct SwSortElement
68 : {
69 : static SwSortOptions* pOptions;
70 : static SwDoc* pDoc;
71 : static const FlatFndBox* pBox;
72 : static CollatorWrapper* pSortCollator;
73 : static ::com::sun::star::lang::Locale* pLocale;
74 : static OUString* pLastAlgorithm;
75 : static LocaleDataWrapper* pLclData;
76 :
77 : static void Init( SwDoc*, const SwSortOptions& rOpt, FlatFndBox* = 0 );
78 : static void Finit();
79 :
80 : virtual ~SwSortElement();
81 :
82 : virtual OUString GetKey(sal_uInt16 nKey ) const = 0;
83 : virtual double GetValue(sal_uInt16 nKey ) const;
84 :
85 : bool operator==(const SwSortElement& ) const;
86 : bool operator<(const SwSortElement& ) const;
87 :
88 : double StrToDouble(const OUString& rStr) const;
89 : private:
90 : int keycompare(const SwSortElement& rCmp, sal_uInt16 nKey) const;
91 : };
92 :
93 : // sort text
94 : struct SwSortTxtElement : public SwSortElement
95 : {
96 : sal_uLong nOrg;
97 : SwNodeIndex aPos;
98 :
99 : SwSortTxtElement( const SwNodeIndex& rPos );
100 : virtual ~SwSortTxtElement();
101 :
102 : virtual OUString GetKey( sal_uInt16 nKey ) const SAL_OVERRIDE;
103 : };
104 :
105 : // sort table
106 : struct SwSortBoxElement : public SwSortElement
107 : {
108 : sal_uInt16 nRow;
109 :
110 : SwSortBoxElement( sal_uInt16 nRC );
111 : virtual ~SwSortBoxElement();
112 :
113 : virtual OUString GetKey( sal_uInt16 nKey ) const SAL_OVERRIDE;
114 : virtual double GetValue( sal_uInt16 nKey ) const SAL_OVERRIDE;
115 : };
116 :
117 : // two-dimensional array of FndBoxes
118 : class FlatFndBox
119 : {
120 : public:
121 : FlatFndBox(SwDoc* pDocPtr, const _FndBox& rBox);
122 : ~FlatFndBox();
123 :
124 8 : bool IsSymmetric() const { return bSym; }
125 8 : sal_uInt16 GetRows() const { return nRows; }
126 144 : sal_uInt16 GetCols() const { return nCols; }
127 :
128 : const _FndBox* GetBox(sal_uInt16 nCol, sal_uInt16 nRow) const;
129 :
130 : inline bool HasItemSets() const;
131 : const SfxItemSet* GetItemSet(sal_uInt16 nCol, sal_uInt16 nRow) const;
132 :
133 : private:
134 : bool CheckLineSymmetry(const _FndBox& rBox);
135 : bool CheckBoxSymmetry(const _FndLine& rLn);
136 : sal_uInt16 GetColCount(const _FndBox& rBox);
137 : sal_uInt16 GetRowCount(const _FndBox& rBox);
138 : void FillFlat(const _FndBox&, bool bLastBox=false);
139 :
140 : SwDoc* pDoc;
141 : const _FndBox& rBoxRef;
142 : const _FndBox** pArr;
143 : SfxItemSet** ppItemSets;
144 :
145 : sal_uInt16 nRows;
146 : sal_uInt16 nCols;
147 : sal_uInt16 nRow;
148 : sal_uInt16 nCol;
149 :
150 : bool bSym;
151 : };
152 :
153 8 : inline bool FlatFndBox::HasItemSets() const { return 0 != ppItemSets; }
154 :
155 : #endif
156 :
157 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|