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 #pragma once
21
22 #include <vector>
23
24 #include <sfx2/tabdlg.hxx>
25 #include <svtools/collatorres.hxx>
26 #include <svx/langbox.hxx>
27 #include <unotools/collatorwrapper.hxx>
28 #include <vcl/idle.hxx>
29
30 #include "sortkeydlg.hxx"
31
32 #include <address.hxx>
33 #include <sheetlimits.hxx>
34 #include <sortparam.hxx>
35
36 // +1 because one field is reserved for the "- undefined -" entry
SC_MAXFIELDS(const ScSheetLimits & rLimits)37 inline SCCOL SC_MAXFIELDS(const ScSheetLimits& rLimits) { return rLimits.GetMaxColCount() + 1; }
38
39 class ScSortItem;
40 class ScViewData;
41
42 // Sort Criteria
43
44 class ScTabPageSortFields : public SfxTabPage
45 {
46 public:
47 ScTabPageSortFields(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet);
48 static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rArgSet);
49 virtual ~ScTabPageSortFields() override;
50
51 virtual bool FillItemSet ( SfxItemSet* rArgSet ) override;
52 virtual void Reset ( const SfxItemSet* rArgSet ) override;
53
54 protected:
55 virtual void ActivatePage ( const SfxItemSet& rSet ) override;
56 virtual DeactivateRC DeactivatePage ( SfxItemSet* pSet ) override;
57
58 private:
59 Idle m_aIdle;
60
61 OUString aStrUndefined;
62 OUString aStrColumn;
63 OUString aStrRow;
64 OUString aStrRowLabel;
65 OUString aStrColLabel;
66
67 TypedWhichId<ScSortItem> nWhichSort;
68 ScViewData* pViewData;
69 ScSortParam aSortData;
70 std::vector<SCCOLROW> nFieldArr;
71 sal_uInt16 nFieldCount;
72 sal_uInt16 nSortKeyCount;
73
74 std::unique_ptr<weld::Container> m_xTop;
75 std::unique_ptr<weld::CheckButton> m_xBtnHeader;
76 std::unique_ptr<weld::RadioButton> m_xBtnTopDown;
77 std::unique_ptr<weld::RadioButton> m_xBtnLeftRight;
78 std::unique_ptr<weld::ScrolledWindow> m_xScrolledWindow;
79 std::unique_ptr<weld::Container> m_xBox;
80 ScSortKeyWindow m_aSortWin;
81
82 void AddSortKey( sal_uInt16 nItem );
83
84 private:
85 void Init ();
86 void FillFieldLists ( sal_uInt16 nStartField );
87 sal_uInt16 GetFieldSelPos ( SCCOLROW nField );
88 void SetLastSortKey( sal_uInt16 nItem );
89
90 // Handler ------------------------
91 DECL_LINK(SelectHdl, weld::ComboBox&, void);
92 DECL_LINK(ScrollToEndHdl, Timer*, void);
93 DECL_LINK(SortDirHdl, weld::Toggleable&, void);
94
95 };
96
97 // Sort Options
98
99 class ScDocument;
100
101 class ScTabPageSortOptions : public SfxTabPage
102 {
103 public:
104 ScTabPageSortOptions(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet);
105 static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* pArgSet);
106
107 virtual bool FillItemSet ( SfxItemSet* rArgSet ) override;
108 virtual void Reset ( const SfxItemSet* rArgSet ) override;
109
110 protected:
111 virtual void ActivatePage ( const SfxItemSet& rSet ) override;
112 virtual DeactivateRC DeactivatePage ( SfxItemSet* pSet ) override;
113
114 private:
115 OUString aStrUndefined;
116 OUString aStrCommentsRowLabel;
117 OUString aStrCommentsColLabel;
118 OUString aStrImgRowLabel;
119 OUString aStrImgColLabel;
120
121 TypedWhichId<ScSortItem> nWhichSort;
122 ScSortParam aSortData;
123 ScViewData* pViewData;
124 ScDocument* pDoc;
125 ScAddress theOutPos;
126
127 std::unique_ptr<CollatorResource> m_xColRes;
128 std::optional<CollatorWrapper> m_oColWrap;
129
130 std::unique_ptr<weld::CheckButton> m_xBtnCase;
131 std::unique_ptr<weld::CheckButton> m_xBtnFormats;
132 std::unique_ptr<weld::CheckButton> m_xBtnNaturalSort;
133 std::unique_ptr<weld::CheckButton> m_xBtnCopyResult;
134 std::unique_ptr<weld::ComboBox> m_xLbOutPos;
135 std::unique_ptr<weld::Entry> m_xEdOutPos;
136 std::unique_ptr<weld::CheckButton> m_xBtnSortUser;
137 std::unique_ptr<weld::ComboBox> m_xLbSortUser;
138 std::unique_ptr<SvxLanguageBox> m_xLbLanguage;
139 std::unique_ptr<weld::Label> m_xFtAlgorithm;
140 std::unique_ptr<weld::ComboBox> m_xLbAlgorithm;
141 std::unique_ptr<weld::CheckButton> m_xBtnIncComments;
142 std::unique_ptr<weld::CheckButton> m_xBtnIncImages;
143
144 private:
145 void Init ();
146 void FillUserSortListBox ();
147
148 // Handler ------------------------
149 DECL_LINK( EnableHdl, weld::Toggleable&, void );
150 DECL_LINK( SelOutPosHdl, weld::ComboBox&, void );
151 void EdOutPosModHdl();
152 void FillAlgor();
153 DECL_LINK( FillAlgorHdl, weld::ComboBox&, void );
154 };
155
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
157