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_UIBASE_INC_TOXMGR_HXX
21 #define INCLUDED_SW_SOURCE_UIBASE_INC_TOXMGR_HXX
25 #include <authfld.hxx>
32 // manager for directory functionality
33 //one single method will be sufficient to insert AND update indexes
34 class SW_DLLPUBLIC SwTOXDescription
37 OUString m_aStyleNames
[MAXLEVEL
];
38 OUString m_sSequenceName
;
39 OUString m_sMainEntryCharStyle
;
40 OUString m_sAutoMarkURL
;
41 std::optional
<OUString
>
43 std::optional
<OUString
>
45 std::unique_ptr
<SwForm
>
47 SwTOXElement m_nContent
;
48 SwTOIOptions m_nIndexOptions
;
49 SwTOOElements m_nOLEOptions
;
50 LanguageType m_eLanguage
;
51 OUString m_sSortAlgorithm
;
53 OUString m_sAuthBrackets
;
54 SwCaptionDisplay m_eCaptionDisplay
;
55 SwTOXSortKey m_eSortKey1
;
56 SwTOXSortKey m_eSortKey2
;
57 SwTOXSortKey m_eSortKey3
;
59 bool m_bFromObjectNames
: 1;
60 bool m_bFromChapter
: 1;
62 bool m_bLevelFromChapter
: 1;
63 bool m_bIsAuthSequence
:1;
64 bool m_bSortByDocument
:1;
67 //const String* pTemplateName = 0, ???
69 SwTOXDescription(SwTOXDescription
const &) = delete;
70 SwTOXDescription
& operator= (SwTOXDescription
const &) = delete;
73 // single argument ctors shall be explicit.
74 explicit SwTOXDescription(TOXTypes eType
) :
76 m_nContent(SwTOXElement::Mark
| SwTOXElement::OutlineLevel
),
77 m_nIndexOptions(SwTOIOptions::SameEntry
|SwTOIOptions::FF
|SwTOIOptions::CaseSensitive
),
78 m_nOLEOptions(SwTOOElements::NONE
),
79 m_eLanguage(::GetAppLanguage()),
80 m_eCaptionDisplay(CAPTION_COMPLETE
),
82 m_bFromObjectNames(false),
83 m_bFromChapter(false),
85 m_bLevelFromChapter(false),
86 m_bIsAuthSequence(false),
87 m_bSortByDocument(true)
90 TOXTypes
GetTOXType() const { return m_eTOXType
;}
92 const OUString
& GetStyleNames(sal_uInt16 nLvl
) const
93 {return m_aStyleNames
[nLvl
];}
94 void SetStyleNames(const OUString
& rSet
, sal_uInt16 nLvl
)
95 {m_aStyleNames
[nLvl
] = rSet
; }
97 const OUString
& GetAutoMarkURL() const { return m_sAutoMarkURL
;}
98 void SetAutoMarkURL(const OUString
& rSet
) {m_sAutoMarkURL
= rSet
;}
100 void SetTitle(const OUString
& rSet
) { m_aTitle
= rSet
; }
101 std::optional
<OUString
> const & GetTitle() const {return m_aTitle
; }
103 void SetTOUName(const OUString
& rSet
) { m_aTOUName
= rSet
; }
104 std::optional
<OUString
> const & GetTOUName() const { return m_aTOUName
; }
106 void SetForm(const SwForm
& rSet
) { m_pForm
.reset( new SwForm(rSet
) );}
107 const SwForm
* GetForm() const {return m_pForm
.get();}
109 void SetContentOptions(SwTOXElement nSet
) { m_nContent
= nSet
;}
110 SwTOXElement
GetContentOptions() const { return m_nContent
;}
112 void SetIndexOptions(SwTOIOptions nSet
) { m_nIndexOptions
= nSet
;}
113 SwTOIOptions
GetIndexOptions() const { return m_nIndexOptions
;}
115 const OUString
& GetMainEntryCharStyle() const {return m_sMainEntryCharStyle
;}
116 void SetMainEntryCharStyle(const OUString
& rSet
) {m_sMainEntryCharStyle
= rSet
;}
118 void SetLevel(sal_uInt8 nSet
) {m_nLevel
= nSet
;}
119 sal_uInt8
GetLevel()const {return m_nLevel
; }
121 void SetCreateFromObjectNames(bool bSet
) { m_bFromObjectNames
= bSet
;}
122 bool IsCreateFromObjectNames() const {return m_bFromObjectNames
;}
124 const OUString
& GetSequenceName() const {return m_sSequenceName
;}
125 void SetSequenceName(const OUString
& rSet
) {m_sSequenceName
= rSet
;}
127 SwCaptionDisplay
GetCaptionDisplay() const { return m_eCaptionDisplay
;}
128 void SetCaptionDisplay(SwCaptionDisplay eSet
) {m_eCaptionDisplay
= eSet
;}
130 void SetFromChapter(bool bSet
) { m_bFromChapter
= bSet
;}
131 bool IsFromChapter() const {return m_bFromChapter
;}
133 void SetReadonly(bool bSet
){m_bReadonly
= bSet
;}
134 bool IsReadonly() const {return m_bReadonly
;}
136 SwTOOElements
GetOLEOptions() const {return m_nOLEOptions
;}
137 void SetOLEOptions(SwTOOElements nOpt
) {m_nOLEOptions
= nOpt
;}
139 bool IsLevelFromChapter() const {return m_bLevelFromChapter
;}
140 void SetLevelFromChapter(bool bSet
) {m_bLevelFromChapter
= bSet
;}
142 const OUString
& GetAuthBrackets() const {return m_sAuthBrackets
;}
143 void SetAuthBrackets(const OUString
& rSet
) {m_sAuthBrackets
= rSet
;}
145 bool IsAuthSequence() const {return m_bIsAuthSequence
;}
146 void SetAuthSequence(bool bSet
){m_bIsAuthSequence
= bSet
;}
148 bool IsSortByDocument()const {return m_bSortByDocument
;}
149 void SetSortByDocument(bool bSet
) {m_bSortByDocument
= bSet
;}
151 void SetSortKeys(SwTOXSortKey eKey1
,
155 const SwTOXSortKey
& GetSortKey1() const {return m_eSortKey1
;}
156 const SwTOXSortKey
& GetSortKey2() const {return m_eSortKey2
;}
157 const SwTOXSortKey
& GetSortKey3() const {return m_eSortKey3
;}
159 LanguageType
GetLanguage() const {return m_eLanguage
;}
160 void SetLanguage(LanguageType nLang
) {m_eLanguage
= nLang
;}
162 const OUString
& GetSortAlgorithm()const {return m_sSortAlgorithm
;}
163 void SetSortAlgorithm(const OUString
& rSet
) {m_sSortAlgorithm
= rSet
;}
165 void ApplyTo(SwTOXBase
& rTOXBase
);
169 class SwTOXMarkDescription
175 std::optional
<OUString
> maPrimKey
;
176 std::optional
<OUString
> maSecKey
;
177 std::optional
<OUString
> maAltStr
;
178 std::optional
<OUString
> maTOUName
;
180 std::optional
<OUString
> maPhoneticReadingOfAltStr
;
181 std::optional
<OUString
> maPhoneticReadingOfPrimKey
;
182 std::optional
<OUString
> maPhoneticReadingOfSecKey
;
184 SwTOXMarkDescription(SwTOXMarkDescription
const &) = delete;
185 SwTOXMarkDescription
& operator= (SwTOXMarkDescription
const &) = delete;
188 // single argument ctors shall be explicit.
189 explicit SwTOXMarkDescription(TOXTypes eType
) :
196 TOXTypes
GetTOXType()const {return meTOXType
;}
198 void SetLevel(int nSet
) {mnLevel
= nSet
;}
199 int GetLevel() const {return mnLevel
;}
201 void SetMainEntry(bool bSet
) {mbMainEntry
= bSet
;}
202 bool IsMainEntry() const {return mbMainEntry
;}
204 void SetPrimKey(const OUString
& rSet
) { maPrimKey
= rSet
; }
205 std::optional
<OUString
> const & GetPrimKey() const { return maPrimKey
; }
207 void SetSecKey(const OUString
& rSet
) { maSecKey
= rSet
; }
208 std::optional
<OUString
> const & GetSecKey() const { return maSecKey
; }
210 void SetAltStr(const OUString
& rSet
) { maAltStr
= rSet
; }
211 std::optional
<OUString
> const & GetAltStr() const { return maAltStr
; }
213 void SetTOUName(const OUString
& rSet
) { maTOUName
= rSet
; }
214 std::optional
<OUString
> const & GetTOUName() const { return maTOUName
; }
216 void SetPhoneticReadingOfAltStr(const OUString
& rSet
) { maPhoneticReadingOfAltStr
= rSet
; }
217 std::optional
<OUString
> const & GetPhoneticReadingOfAltStr() const { return maPhoneticReadingOfAltStr
; }
219 void SetPhoneticReadingOfPrimKey(const OUString
& rSet
) { maPhoneticReadingOfPrimKey
= rSet
; }
220 std::optional
<OUString
> const & GetPhoneticReadingOfPrimKey() const { return maPhoneticReadingOfPrimKey
; }
222 void SetPhoneticReadingOfSecKey(const OUString
& rSet
) { maPhoneticReadingOfSecKey
= rSet
; }
223 std::optional
<OUString
> const & GetPhoneticReadingOfSecKey() const { return maPhoneticReadingOfSecKey
; }
227 * Built on top of SwWrtShell, provides functionality to insert, update or perform other actions on
228 * various ToX types (table of contents, indexes and so on).
230 class SW_DLLPUBLIC SwTOXMgr
233 SwTOXMark
* m_pCurTOXMark
;
234 SwTOXMarks m_aCurMarks
;
236 SAL_DLLPRIVATE sal_uInt16
GetUserTypeID(const OUString
& rStr
);
239 // single argument ctors shall be explicit.
240 explicit SwTOXMgr(SwWrtShell
* pShell
);
242 // methods for directory marks
244 void InsertTOXMark(const SwTOXMarkDescription
& rDesc
);
246 void UpdateTOXMark(const SwTOXMarkDescription
& rDesc
);
248 void DeleteTOXMark();
249 void NextTOXMark(bool bSame
=false);
250 void PrevTOXMark(bool bSame
=false);
252 // get current TOXmarks
253 sal_uInt16
GetTOXMarkCount() const;
254 SwTOXMark
* GetTOXMark(sal_uInt16 nId
);
255 SwTOXMark
* GetCurTOXMark();
256 void SetCurTOXMark(sal_uInt16 nId
);
258 // methods for directories
260 bool UpdateOrInsertTOX(const SwTOXDescription
& rDesc
, SwTOXBase
** ppBase
, const SfxItemSet
* pSet
);
262 const SwTOXType
* GetTOXType(TOXTypes eTyp
) const;
263 SwWrtShell
* GetShell() { return m_pSh
; }
267 inline sal_uInt16
SwTOXMgr::GetTOXMarkCount() const
268 { return m_aCurMarks
.size(); }
270 inline SwTOXMark
* SwTOXMgr::GetCurTOXMark()
271 { return m_pCurTOXMark
; }
275 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */