/src/libreoffice/sw/source/uibase/inc/toxmgr.hxx
Line | Count | Source |
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_UIBASE_INC_TOXMGR_HXX |
21 | | #define INCLUDED_SW_SOURCE_UIBASE_INC_TOXMGR_HXX |
22 | | |
23 | | #include <swdllapi.h> |
24 | | #include <tox.hxx> |
25 | | #include <authfld.hxx> |
26 | | #include <memory> |
27 | | #include <optional> |
28 | | |
29 | | class SwWrtShell; |
30 | | |
31 | | // manager for directory functionality |
32 | | //one single method will be sufficient to insert AND update indexes |
33 | | class SW_DLLPUBLIC SwTOXDescription |
34 | | { |
35 | | TOXTypes m_eTOXType; |
36 | | UIName m_aStyleNames[MAXLEVEL]; |
37 | | UIName m_sSequenceName; |
38 | | UIName m_sMainEntryCharStyle; |
39 | | OUString m_sAutoMarkURL; |
40 | | std::optional<OUString> |
41 | | m_aTitle; |
42 | | std::optional<OUString> |
43 | | m_aTOUName; |
44 | | std::unique_ptr<SwForm> |
45 | | m_pForm; |
46 | | SwTOXElement m_nContent; |
47 | | SwTOIOptions m_nIndexOptions; |
48 | | SwTOOElements m_nOLEOptions; |
49 | | LanguageType m_eLanguage; |
50 | | OUString m_sSortAlgorithm; |
51 | | |
52 | | OUString m_sAuthBrackets; |
53 | | SwCaptionDisplay m_eCaptionDisplay; |
54 | | SwTOXSortKey m_eSortKey1; |
55 | | SwTOXSortKey m_eSortKey2; |
56 | | SwTOXSortKey m_eSortKey3; |
57 | | sal_uInt8 m_nLevel; |
58 | | bool m_bFromObjectNames : 1; |
59 | | bool m_bFromChapter : 1; |
60 | | bool m_bReadonly: 1; |
61 | | bool m_bLevelFromChapter : 1; |
62 | | bool m_bIsAuthSequence :1; |
63 | | bool m_bSortByDocument :1; |
64 | | |
65 | | //TODO: TemplateNames |
66 | | //const String* pTemplateName = 0, ??? |
67 | | |
68 | | SwTOXDescription(SwTOXDescription const &) = delete; |
69 | | SwTOXDescription & operator= (SwTOXDescription const &) = delete; |
70 | | |
71 | | public: |
72 | | // single argument ctors shall be explicit. |
73 | | explicit SwTOXDescription(TOXTypes eType) : |
74 | | m_eTOXType(eType), |
75 | | m_nContent(SwTOXElement::Mark | SwTOXElement::OutlineLevel), |
76 | | m_nIndexOptions(SwTOIOptions::SameEntry|SwTOIOptions::FF|SwTOIOptions::CaseSensitive), |
77 | | m_nOLEOptions(SwTOOElements::NONE), |
78 | | m_eLanguage(::GetAppLanguage()), |
79 | | m_eCaptionDisplay(SwCaptionDisplay::Complete), |
80 | | m_nLevel(MAXLEVEL), |
81 | | m_bFromObjectNames(false), |
82 | | m_bFromChapter(false), |
83 | | m_bReadonly(true), |
84 | | m_bLevelFromChapter(false), |
85 | | m_bIsAuthSequence(false), |
86 | | m_bSortByDocument(true) |
87 | 0 | {} |
88 | | |
89 | 0 | TOXTypes GetTOXType() const { return m_eTOXType;} |
90 | | |
91 | | const UIName& GetStyleNames(sal_uInt16 nLvl) const |
92 | 0 | {return m_aStyleNames[nLvl];} |
93 | | void SetStyleNames(const UIName& rSet, sal_uInt16 nLvl) |
94 | 0 | {m_aStyleNames[nLvl] = rSet; } |
95 | | |
96 | 0 | const OUString& GetAutoMarkURL() const { return m_sAutoMarkURL;} |
97 | 0 | void SetAutoMarkURL(const OUString& rSet) {m_sAutoMarkURL = rSet;} |
98 | | |
99 | 0 | void SetTitle(const OUString& rSet) { m_aTitle = rSet; } |
100 | 0 | std::optional<OUString> const & GetTitle() const {return m_aTitle; } |
101 | | |
102 | 0 | void SetTOUName(const OUString& rSet) { m_aTOUName = rSet; } |
103 | 0 | std::optional<OUString> const & GetTOUName() const { return m_aTOUName; } |
104 | | |
105 | 0 | void SetForm(const SwForm& rSet) { m_pForm.reset( new SwForm(rSet) );} |
106 | 0 | const SwForm* GetForm() const {return m_pForm.get();} |
107 | | |
108 | 0 | void SetContentOptions(SwTOXElement nSet) { m_nContent = nSet;} |
109 | 0 | SwTOXElement GetContentOptions() const { return m_nContent;} |
110 | | |
111 | 0 | void SetIndexOptions(SwTOIOptions nSet) { m_nIndexOptions = nSet;} |
112 | 0 | SwTOIOptions GetIndexOptions() const { return m_nIndexOptions;} |
113 | | |
114 | 0 | const UIName& GetMainEntryCharStyle() const {return m_sMainEntryCharStyle;} |
115 | 0 | void SetMainEntryCharStyle(const UIName& rSet) {m_sMainEntryCharStyle = rSet;} |
116 | | |
117 | 0 | void SetLevel(sal_uInt8 nSet) {m_nLevel = nSet;} |
118 | 0 | sal_uInt8 GetLevel()const {return m_nLevel; } |
119 | | |
120 | 0 | void SetCreateFromObjectNames(bool bSet) { m_bFromObjectNames = bSet;} |
121 | 0 | bool IsCreateFromObjectNames() const {return m_bFromObjectNames;} |
122 | | |
123 | 0 | const UIName& GetSequenceName() const {return m_sSequenceName;} |
124 | 0 | void SetSequenceName(const UIName& rSet) {m_sSequenceName = rSet;} |
125 | | |
126 | 0 | SwCaptionDisplay GetCaptionDisplay() const { return m_eCaptionDisplay;} |
127 | 0 | void SetCaptionDisplay(SwCaptionDisplay eSet) {m_eCaptionDisplay = eSet;} |
128 | | |
129 | 0 | void SetFromChapter(bool bSet) { m_bFromChapter = bSet;} |
130 | 0 | bool IsFromChapter() const {return m_bFromChapter;} |
131 | | |
132 | 0 | void SetReadonly(bool bSet){m_bReadonly = bSet;} |
133 | 0 | bool IsReadonly() const {return m_bReadonly;} |
134 | | |
135 | 0 | SwTOOElements GetOLEOptions() const {return m_nOLEOptions;} |
136 | 0 | void SetOLEOptions(SwTOOElements nOpt) {m_nOLEOptions = nOpt;} |
137 | | |
138 | 0 | bool IsLevelFromChapter() const {return m_bLevelFromChapter;} |
139 | 0 | void SetLevelFromChapter(bool bSet) {m_bLevelFromChapter = bSet;} |
140 | | |
141 | 0 | const OUString& GetAuthBrackets() const {return m_sAuthBrackets;} |
142 | 0 | void SetAuthBrackets(const OUString& rSet) {m_sAuthBrackets = rSet;} |
143 | | |
144 | 0 | bool IsAuthSequence() const {return m_bIsAuthSequence;} |
145 | 0 | void SetAuthSequence(bool bSet){m_bIsAuthSequence = bSet;} |
146 | | |
147 | 0 | bool IsSortByDocument()const {return m_bSortByDocument ;} |
148 | 0 | void SetSortByDocument(bool bSet) {m_bSortByDocument = bSet;} |
149 | | |
150 | | void SetSortKeys(SwTOXSortKey eKey1, |
151 | | SwTOXSortKey eKey2, |
152 | | SwTOXSortKey eKey3); |
153 | | |
154 | 0 | const SwTOXSortKey& GetSortKey1() const {return m_eSortKey1;} |
155 | 0 | const SwTOXSortKey& GetSortKey2() const {return m_eSortKey2;} |
156 | 0 | const SwTOXSortKey& GetSortKey3() const {return m_eSortKey3;} |
157 | | |
158 | 0 | LanguageType GetLanguage() const {return m_eLanguage;} |
159 | 0 | void SetLanguage(LanguageType nLang) {m_eLanguage = nLang;} |
160 | | |
161 | 0 | const OUString& GetSortAlgorithm()const {return m_sSortAlgorithm;} |
162 | 0 | void SetSortAlgorithm(const OUString& rSet) {m_sSortAlgorithm = rSet;} |
163 | | |
164 | | void ApplyTo(SwTOXBase& rTOXBase); |
165 | | |
166 | | }; |
167 | | |
168 | | class SwTOXMarkDescription |
169 | | { |
170 | | TOXTypes meTOXType; |
171 | | int mnLevel; |
172 | | bool mbMainEntry; |
173 | | |
174 | | std::optional<OUString> maPrimKey; |
175 | | std::optional<OUString> maSecKey; |
176 | | std::optional<OUString> maAltStr; |
177 | | std::optional<OUString> maTOUName; |
178 | | |
179 | | std::optional<OUString> maPhoneticReadingOfAltStr; |
180 | | std::optional<OUString> maPhoneticReadingOfPrimKey; |
181 | | std::optional<OUString> maPhoneticReadingOfSecKey; |
182 | | |
183 | | SwTOXMarkDescription(SwTOXMarkDescription const &) = delete; |
184 | | SwTOXMarkDescription & operator= (SwTOXMarkDescription const &) = delete; |
185 | | |
186 | | public: |
187 | | // single argument ctors shall be explicit. |
188 | | explicit SwTOXMarkDescription(TOXTypes eType) : |
189 | | meTOXType(eType), |
190 | | mnLevel(0), |
191 | | mbMainEntry(false) |
192 | 0 | { |
193 | 0 | } |
194 | | |
195 | 0 | TOXTypes GetTOXType()const {return meTOXType;} |
196 | | |
197 | 0 | void SetLevel(int nSet) {mnLevel = nSet;} |
198 | 0 | int GetLevel() const {return mnLevel;} |
199 | | |
200 | 0 | void SetMainEntry(bool bSet) {mbMainEntry = bSet;} |
201 | 0 | bool IsMainEntry() const {return mbMainEntry;} |
202 | | |
203 | 0 | void SetPrimKey(const OUString& rSet) { maPrimKey = rSet; } |
204 | 0 | std::optional<OUString> const & GetPrimKey() const { return maPrimKey; } |
205 | | |
206 | 0 | void SetSecKey(const OUString& rSet) { maSecKey = rSet; } |
207 | 0 | std::optional<OUString> const & GetSecKey() const { return maSecKey; } |
208 | | |
209 | 0 | void SetAltStr(const OUString& rSet) { maAltStr = rSet; } |
210 | 0 | std::optional<OUString> const & GetAltStr() const { return maAltStr; } |
211 | | |
212 | 0 | void SetTOUName(const OUString& rSet) { maTOUName = rSet; } |
213 | 0 | std::optional<OUString> const & GetTOUName() const { return maTOUName; } |
214 | | |
215 | 0 | void SetPhoneticReadingOfAltStr(const OUString& rSet) { maPhoneticReadingOfAltStr = rSet; } |
216 | 0 | std::optional<OUString> const & GetPhoneticReadingOfAltStr() const { return maPhoneticReadingOfAltStr; } |
217 | | |
218 | 0 | void SetPhoneticReadingOfPrimKey(const OUString& rSet) { maPhoneticReadingOfPrimKey = rSet; } |
219 | 0 | std::optional<OUString> const & GetPhoneticReadingOfPrimKey() const { return maPhoneticReadingOfPrimKey; } |
220 | | |
221 | 0 | void SetPhoneticReadingOfSecKey(const OUString& rSet) { maPhoneticReadingOfSecKey = rSet; } |
222 | 0 | std::optional<OUString> const & GetPhoneticReadingOfSecKey() const { return maPhoneticReadingOfSecKey; } |
223 | | }; |
224 | | |
225 | | /** |
226 | | * Built on top of SwWrtShell, provides functionality to insert, update or perform other actions on |
227 | | * various ToX types (table of contents, indexes and so on). |
228 | | */ |
229 | | class SW_DLLPUBLIC SwTOXMgr |
230 | | { |
231 | | SwWrtShell* m_pSh; |
232 | | SwTOXMark* m_pCurTOXMark; |
233 | | SwTOXMarks m_aCurMarks; |
234 | | |
235 | | SAL_DLLPRIVATE sal_uInt16 GetUserTypeID(const OUString& rStr); |
236 | | |
237 | | public: |
238 | | // single argument ctors shall be explicit. |
239 | | explicit SwTOXMgr(SwWrtShell* pShell); |
240 | | |
241 | | // methods for directory marks |
242 | | |
243 | | void InsertTOXMark(const SwTOXMarkDescription& rDesc); |
244 | | |
245 | | void UpdateTOXMark(const SwTOXMarkDescription& rDesc); |
246 | | |
247 | | void DeleteTOXMark(); |
248 | | void NextTOXMark(bool bSame=false); |
249 | | void PrevTOXMark(bool bSame=false); |
250 | | |
251 | | // get current TOXmarks |
252 | | sal_uInt16 GetTOXMarkCount() const; |
253 | | SwTOXMark* GetTOXMark(sal_uInt16 nId); |
254 | | SwTOXMark* GetCurTOXMark(); |
255 | | void SetCurTOXMark(sal_uInt16 nId); |
256 | | |
257 | | // methods for directories |
258 | | |
259 | | bool UpdateOrInsertTOX(const SwTOXDescription& rDesc, SwTOXBase** ppBase, const SfxItemSet* pSet); |
260 | | |
261 | | const SwTOXType* GetTOXType(TOXTypes eTyp) const; |
262 | 0 | SwWrtShell * GetShell() { return m_pSh; } |
263 | | }; |
264 | | |
265 | | // inlines |
266 | | inline sal_uInt16 SwTOXMgr::GetTOXMarkCount() const |
267 | 0 | { return m_aCurMarks.size(); } |
268 | | |
269 | | inline SwTOXMark* SwTOXMgr::GetCurTOXMark() |
270 | 0 | { return m_pCurTOXMark; } |
271 | | |
272 | | #endif |
273 | | |
274 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |