Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _TOXMGR_HXX
30 : : #define _TOXMGR_HXX
31 : :
32 : : #include "swdllapi.h"
33 : : #include "tox.hxx"
34 : : #include <authfld.hxx>
35 : :
36 : : class SwWrtShell;
37 : : class SwForm;
38 : :
39 : : /*--------------------------------------------------------------------
40 : : Description: manager for directory functionality
41 : : --------------------------------------------------------------------*/
42 : : //one single method will be sufficient to insert AND upate indexes
43 : : class SW_DLLPUBLIC SwTOXDescription
44 : : {
45 : : TOXTypes eTOXType;
46 : : String aStyleNames[MAXLEVEL];
47 : : String sSequenceName;
48 : : String sMainEntryCharStyle;
49 : : String sAutoMarkURL;
50 : : String* pTitle;
51 : : String* pTOUName;
52 : : SwForm* pForm;
53 : : sal_uInt16 nContent;
54 : : sal_uInt16 nIndexOptions;
55 : : sal_uInt16 nOLEOptions;
56 : : LanguageType eLanguage;
57 : : String sSortAlgorithm;
58 : :
59 : : String sAuthBrackets;
60 : : SwCaptionDisplay eCaptionDisplay;
61 : : SwTOXSortKey eSortKey1;
62 : : SwTOXSortKey eSortKey2;
63 : : SwTOXSortKey eSortKey3;
64 : : sal_uInt8 nLevel;
65 : : sal_Bool bFromObjectNames : 1;
66 : : sal_Bool bFromChapter : 1;
67 : : sal_Bool bReadonly: 1;
68 : : sal_Bool bLevelFromChapter : 1;
69 : : sal_Bool bIsAuthSequence :1;
70 : : sal_Bool bSortByDocument :1;
71 : :
72 : : //TODO: TemplateNames
73 : : //const String* pTemplateName = 0, ???
74 : :
75 : : // forbidden and not implemented.
76 : : SwTOXDescription();
77 : : SwTOXDescription(SwTOXDescription&);
78 : : SwTOXDescription & operator= (SwTOXDescription&);
79 : :
80 : : public:
81 : : // single argument ctors shall be explicit.
82 : 0 : explicit SwTOXDescription(TOXTypes eType) :
83 : : eTOXType(eType),
84 : : pTitle(0),
85 : : pTOUName(0),
86 : : pForm(0),
87 : : nContent(nsSwTOXElement::TOX_MARK | nsSwTOXElement::TOX_OUTLINELEVEL),
88 : : nIndexOptions(nsSwTOIOptions::TOI_SAME_ENTRY|nsSwTOIOptions::TOI_FF|nsSwTOIOptions::TOI_CASE_SENSITIVE),
89 : : nOLEOptions(0),
90 : 0 : eLanguage((LanguageType)::GetAppLanguage()),
91 : : eCaptionDisplay(CAPTION_COMPLETE),
92 : : nLevel(MAXLEVEL),
93 : : bFromObjectNames(sal_False),
94 : : bFromChapter(sal_False),
95 : : bReadonly(sal_True),
96 : : bLevelFromChapter(sal_False),
97 : : bIsAuthSequence(sal_False),
98 : 0 : bSortByDocument(sal_True)
99 : 0 : {}
100 : 0 : ~SwTOXDescription()
101 : 0 : {
102 : 0 : delete pTitle;
103 : 0 : delete pForm;
104 : 0 : delete pTOUName;
105 : 0 : }
106 : :
107 : : void SetTOXType(TOXTypes eSet) { eTOXType = eSet;}
108 : 0 : TOXTypes GetTOXType() const { return eTOXType;}
109 : :
110 : 0 : const String& GetStyleNames(sal_uInt16 nLvl) const
111 : 0 : {return aStyleNames[nLvl];}
112 : 0 : void SetStyleNames(const String& rSet, sal_uInt16 nLvl)
113 : 0 : {aStyleNames[nLvl] = rSet; }
114 : :
115 : 0 : const String& GetAutoMarkURL() const { return sAutoMarkURL;}
116 : 0 : void SetAutoMarkURL(const String& rSet) {sAutoMarkURL = rSet;}
117 : :
118 : 0 : void SetTitle(const String& pSet) {delete pTitle; pTitle = new String(pSet);}
119 : 0 : const String* GetTitle() const {return pTitle; }
120 : :
121 : 0 : void SetTOUName(const String& pSet) {delete pTOUName; pTOUName = new String(pSet);}
122 : 0 : const String* GetTOUName() const {return pTOUName; }
123 : :
124 : 0 : void SetForm(const SwForm& rSet) {delete pForm; pForm = new SwForm(rSet);}
125 : 0 : const SwForm* GetForm() const {return pForm;}
126 : :
127 : 0 : void SetContentOptions(sal_uInt16 nSet) { nContent = nSet;}
128 : 0 : sal_uInt16 GetContentOptions() const { return nContent;}
129 : :
130 : 0 : void SetIndexOptions(sal_uInt16 nSet) { nIndexOptions = nSet;}
131 : 0 : sal_uInt16 GetIndexOptions() const { return nIndexOptions;}
132 : :
133 : 0 : const String& GetMainEntryCharStyle() const {return sMainEntryCharStyle;}
134 : 0 : void SetMainEntryCharStyle(const String& rSet) {sMainEntryCharStyle = rSet;}
135 : :
136 : 0 : void SetLevel(sal_uInt8 nSet) {nLevel = nSet;}
137 : 0 : sal_uInt8 GetLevel()const {return nLevel; }
138 : :
139 : 0 : void SetCreateFromObjectNames(sal_Bool bSet) { bFromObjectNames = bSet;}
140 : 0 : sal_Bool IsCreateFromObjectNames() const {return bFromObjectNames;}
141 : :
142 : 0 : const String& GetSequenceName() const {return sSequenceName;}
143 : 0 : void SetSequenceName(const String& rSet) {sSequenceName = rSet;}
144 : :
145 : 0 : SwCaptionDisplay GetCaptionDisplay() const { return eCaptionDisplay;}
146 : 0 : void SetCaptionDisplay(SwCaptionDisplay eSet) {eCaptionDisplay = eSet;}
147 : :
148 : 0 : void SetFromChapter(sal_Bool bSet) { bFromChapter = bSet;}
149 : 0 : sal_Bool IsFromChapter() const {return bFromChapter;}
150 : :
151 : 0 : void SetReadonly(sal_Bool bSet){bReadonly = bSet;}
152 : 0 : sal_Bool IsReadonly() const {return bReadonly;}
153 : :
154 : 0 : sal_uInt16 GetOLEOptions() const {return nOLEOptions;}
155 : 0 : void SetOLEOptions(sal_uInt16 nOpt) {nOLEOptions = nOpt;}
156 : :
157 : 0 : sal_Bool IsLevelFromChapter() const {return bLevelFromChapter;}
158 : 0 : void SetLevelFromChapter(sal_Bool bSet) {bLevelFromChapter = bSet;}
159 : :
160 : 0 : String GetAuthBrackets() const {return sAuthBrackets;}
161 : 0 : void SetAuthBrackets(const String& rSet) {sAuthBrackets = rSet;}
162 : :
163 : 0 : sal_Bool IsAuthSequence() const {return bIsAuthSequence;}
164 : 0 : void SetAuthSequence(sal_Bool bSet){bIsAuthSequence = bSet;}
165 : :
166 : 0 : sal_Bool IsSortByDocument()const {return bSortByDocument ;}
167 : 0 : void SetSortByDocument(sal_Bool bSet) {bSortByDocument = bSet;}
168 : :
169 : : void SetSortKeys(SwTOXSortKey eKey1,
170 : : SwTOXSortKey eKey2,
171 : : SwTOXSortKey eKey3);
172 : :
173 : 0 : SwTOXSortKey GetSortKey1() const {return eSortKey1;}
174 : 0 : SwTOXSortKey GetSortKey2() const {return eSortKey2;}
175 : 0 : SwTOXSortKey GetSortKey3() const {return eSortKey3;}
176 : :
177 : 0 : LanguageType GetLanguage() const {return eLanguage;}
178 : 0 : void SetLanguage(LanguageType nLang) {eLanguage = nLang;}
179 : :
180 : 0 : const String& GetSortAlgorithm()const {return sSortAlgorithm;}
181 : 0 : void SetSortAlgorithm(const String& rSet) {sSortAlgorithm = rSet;}
182 : :
183 : : void ApplyTo(SwTOXBase& rTOXBase);
184 : :
185 : : };
186 : :
187 : : class SwTOXMarkDescription
188 : : {
189 : : TOXTypes eTOXType;
190 : : int nLevel;
191 : : sal_Bool bMainEntry;
192 : :
193 : : String* pPrimKey;
194 : : String* pSecKey;
195 : : String* pAltStr;
196 : : String* pTOUName;
197 : :
198 : : String* pPhoneticReadingOfAltStr;
199 : : String* pPhoneticReadingOfPrimKey;
200 : : String* pPhoneticReadingOfSecKey;
201 : :
202 : : // forbidden and not implemented.
203 : : SwTOXMarkDescription();
204 : : SwTOXMarkDescription(SwTOXMarkDescription&);
205 : : SwTOXMarkDescription & operator= (SwTOXMarkDescription&);
206 : :
207 : : public:
208 : : // single argument ctors shall be explicit.
209 : 0 : explicit SwTOXMarkDescription(TOXTypes eType) :
210 : : eTOXType(eType),
211 : : nLevel(0),
212 : : bMainEntry(sal_False),
213 : : pPrimKey(0),
214 : : pSecKey(0),
215 : : pAltStr(0),
216 : : pTOUName(0),
217 : : pPhoneticReadingOfAltStr(0),
218 : : pPhoneticReadingOfPrimKey(0),
219 : 0 : pPhoneticReadingOfSecKey(0)
220 : : {
221 : 0 : }
222 : 0 : ~SwTOXMarkDescription()
223 : : {
224 : 0 : delete pPrimKey;
225 : 0 : delete pSecKey;
226 : 0 : delete pAltStr;
227 : 0 : delete pTOUName;
228 : 0 : delete pPhoneticReadingOfAltStr;
229 : 0 : delete pPhoneticReadingOfPrimKey;
230 : 0 : delete pPhoneticReadingOfSecKey;
231 : 0 : }
232 : :
233 : 0 : TOXTypes GetTOXType()const {return eTOXType;}
234 : :
235 : 0 : void SetLevel(int nSet) {nLevel = nSet;}
236 : 0 : int GetLevel() const {return nLevel;}
237 : :
238 : 0 : void SetMainEntry(sal_Bool bSet) {bMainEntry = bSet;}
239 : 0 : sal_Bool IsMainEntry() const {return bMainEntry;}
240 : :
241 : 0 : void SetPrimKey(const String& rSet)
242 : 0 : {delete pPrimKey; pPrimKey = new String(rSet);}
243 : 0 : const String* GetPrimKey() const {return pPrimKey;}
244 : :
245 : 0 : void SetSecKey(const String& rSet)
246 : 0 : {delete pSecKey; pSecKey = new String(rSet);}
247 : 0 : const String* GetSecKey() const { return pSecKey; }
248 : :
249 : 0 : void SetAltStr(const String& rSet)
250 : 0 : {delete pAltStr; pAltStr = new String(rSet);}
251 : 0 : const String* GetAltStr() const { return pAltStr; }
252 : :
253 : 0 : void SetTOUName(const String& rSet)
254 : 0 : {delete pTOUName; pTOUName = new String(rSet);}
255 : 0 : const String* GetTOUName() const {return pTOUName;}
256 : :
257 : :
258 : 0 : void SetPhoneticReadingOfAltStr(const String& rSet)
259 : 0 : {delete pPhoneticReadingOfAltStr; pPhoneticReadingOfAltStr = new String(rSet);}
260 : 0 : const String* GetPhoneticReadingOfAltStr() const { return pPhoneticReadingOfAltStr; }
261 : :
262 : 0 : void SetPhoneticReadingOfPrimKey(const String& rSet)
263 : 0 : {delete pPhoneticReadingOfPrimKey; pPhoneticReadingOfPrimKey = new String(rSet);}
264 : 0 : const String* GetPhoneticReadingOfPrimKey() const { return pPhoneticReadingOfPrimKey; }
265 : :
266 : 0 : void SetPhoneticReadingOfSecKey(const String& rSet)
267 : 0 : {delete pPhoneticReadingOfSecKey; pPhoneticReadingOfSecKey = new String(rSet);}
268 : 0 : const String* GetPhoneticReadingOfSecKey() const { return pPhoneticReadingOfSecKey; }
269 : : };
270 : :
271 : 0 : class SW_DLLPUBLIC SwTOXMgr
272 : : {
273 : : SwWrtShell* pSh;
274 : : SwTOXMark* pCurTOXMark;
275 : : SwTOXMarks aCurMarks;
276 : :
277 : : SW_DLLPRIVATE sal_uInt16 GetUserTypeID(const String& rStr);
278 : :
279 : : public:
280 : : // single argument ctors shall be explicit.
281 : : explicit SwTOXMgr(SwWrtShell* pShell);
282 : :
283 : : //
284 : : // methods for directory marks
285 : : //
286 : : void InsertTOXMark(const SwTOXMarkDescription& rDesc);
287 : :
288 : : void UpdateTOXMark(const SwTOXMarkDescription& rDesc);
289 : :
290 : :
291 : : void DeleteTOXMark();
292 : : void NextTOXMark(sal_Bool bSame=sal_False);
293 : : void PrevTOXMark(sal_Bool bSame=sal_False);
294 : :
295 : : // get current TOXmarks
296 : : sal_uInt16 GetTOXMarks();
297 : : sal_uInt16 GetTOXMarkCount();
298 : : SwTOXMark* GetTOXMark(sal_uInt16 nId);
299 : : SwTOXMark* GetCurTOXMark();
300 : : void SetCurTOXMark(sal_uInt16 nId);
301 : :
302 : : //
303 : : // methods for directories
304 : : //
305 : : sal_Bool UpdateOrInsertTOX(const SwTOXDescription& rDesc, SwTOXBase** ppBase = 0, const SfxItemSet* pSet = 0);
306 : :
307 : : const SwTOXType* GetTOXType(TOXTypes eTyp, sal_uInt16 nId) const;
308 : : const SwTOXBase* GetCurTOX();
309 : :
310 : : };
311 : :
312 : : /*--------------------------------------------------------------------
313 : : Description: inlines
314 : : --------------------------------------------------------------------*/
315 : 0 : inline sal_uInt16 SwTOXMgr::GetTOXMarkCount()
316 : 0 : { return aCurMarks.size(); }
317 : :
318 : 0 : inline SwTOXMark* SwTOXMgr::GetCurTOXMark()
319 : 0 : { return pCurTOXMark; }
320 : :
321 : : #endif
322 : :
323 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|