1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCSORT_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_DOCSORT_HXX
23 #include <ndindex.hxx>
35 class CollatorWrapper
;
36 class LocaleDataWrapper
;
37 namespace com::sun::star::lang
{ struct Locale
; }
42 std::vector
<const SwTableBox
*> mBoxes
;
45 void push_back(const SwTableBox
* &rpTableBox
) {mBoxes
.push_back(rpTableBox
);}
47 sal_uInt16
GetPos(const SwTableBox
* pTableBox
) const;
50 // Functions for moving boxes
51 void MoveCol(SwDoc
* pDoc
, const FlatFndBox
& rBox
,
52 sal_uInt16 nS
, sal_uInt16 nT
, SwMovedBoxes
& rMovedList
, SwUndoSort
* pUD
);
53 void MoveRow(SwDoc
* pDoc
, const FlatFndBox
& rBox
,
54 sal_uInt16 nS
, sal_uInt16 nT
, SwMovedBoxes
& rMovedList
, SwUndoSort
* pUD
);
55 void MoveCell(SwDoc
* pDoc
, const SwTableBox
* pSource
,
56 const SwTableBox
* pTar
, bool bMovedBefore
, SwUndoSort
* pUD
=nullptr);
58 // Elements for sorting text and table content
61 static SwSortOptions
* pOptions
;
63 static const FlatFndBox
* pBox
;
64 static CollatorWrapper
* pSortCollator
;
65 static css::lang::Locale
* pLocale
;
66 static std::optional
<OUString
> xLastAlgorithm
;
67 static LocaleDataWrapper
* pLclData
;
69 static void Init( SwDoc
*, const SwSortOptions
& rOpt
, FlatFndBox
const * = nullptr );
72 SwSortElement() = default;
73 SwSortElement(SwSortElement
const &) = default;
74 SwSortElement(SwSortElement
&&) = default;
75 SwSortElement
& operator =(SwSortElement
const &) = default;
76 SwSortElement
& operator =(SwSortElement
&&) = default;
78 virtual ~SwSortElement();
80 virtual OUString
GetKey(sal_uInt16 nKey
) const = 0;
81 virtual double GetValue(sal_uInt16 nKey
) const;
83 bool operator<(const SwSortElement
& ) const;
85 static double StrToDouble(std::u16string_view rStr
);
87 int keycompare(const SwSortElement
& rCmp
, sal_uInt16 nKey
) const;
91 struct SwSortTextElement final
: public SwSortElement
96 SwSortTextElement( const SwNodeIndex
& rPos
);
98 virtual OUString
GetKey( sal_uInt16 nKey
) const override
;
102 struct SwSortBoxElement final
: public SwSortElement
106 SwSortBoxElement( sal_uInt16 nRC
);
108 virtual OUString
GetKey( sal_uInt16 nKey
) const override
;
109 virtual double GetValue( sal_uInt16 nKey
) const override
;
112 // two-dimensional array of FndBoxes
116 FlatFndBox(SwDoc
* pDocPtr
, const FndBox_
& rBox
);
119 bool IsSymmetric() const { return m_bSym
; }
120 sal_uInt16
GetRows() const { return m_nRows
; }
121 sal_uInt16
GetCols() const { return m_nCols
; }
123 const FndBox_
* GetBox(sal_uInt16 nCol
, sal_uInt16 nRow
) const;
125 inline bool HasItemSets() const;
126 const SfxItemSet
* GetItemSet(sal_uInt16 nCol
, sal_uInt16 nRow
) const;
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);
136 std::unique_ptr
<FndBox_
const *[]> m_pArr
;
137 /// using optional because SfxItemSet has no default constructor
138 std::vector
<std::optional
<SfxItemSet
>> m_vItemSets
;
148 inline bool FlatFndBox::HasItemSets() const { return !m_vItemSets
.empty(); }
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */