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