1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _TOXMGR_HXX 29 #define _TOXMGR_HXX 30 31 #include "swdllapi.h" 32 #include "tox.hxx" 33 #include <authfld.hxx> 34 35 class SwWrtShell; 36 class SwForm; 37 38 /*-------------------------------------------------------------------- 39 Beschreibung: Manager fuer Verzeichnisfunktionalitaet 40 --------------------------------------------------------------------*/ 41 //one single method will be sufficient to insert AND upate indexes 42 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 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 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 bSortByDocument(sal_True) 99 {} 100 ~SwTOXDescription() 101 { 102 delete pTitle; 103 delete pForm; 104 delete pTOUName; 105 } 106 107 void SetTOXType(TOXTypes eSet) { eTOXType = eSet;} 108 TOXTypes GetTOXType() const { return eTOXType;} 109 110 const String& GetStyleNames(sal_uInt16 nLvl) const 111 {return aStyleNames[nLvl];} 112 void SetStyleNames(const String& rSet, sal_uInt16 nLvl) 113 {aStyleNames[nLvl] = rSet; } 114 115 const String& GetAutoMarkURL() const { return sAutoMarkURL;} 116 void SetAutoMarkURL(const String& rSet) {sAutoMarkURL = rSet;} 117 118 void SetTitle(const String& pSet) {delete pTitle; pTitle = new String(pSet);} 119 const String* GetTitle() const {return pTitle; } 120 121 void SetTOUName(const String& pSet) {delete pTOUName; pTOUName = new String(pSet);} 122 const String* GetTOUName() const {return pTOUName; } 123 124 void SetForm(const SwForm& rSet) {delete pForm; pForm = new SwForm(rSet);} 125 const SwForm* GetForm() const {return pForm;} 126 127 void SetContentOptions(sal_uInt16 nSet) { nContent = nSet;} 128 sal_uInt16 GetContentOptions() const { return nContent;} 129 130 void SetIndexOptions(sal_uInt16 nSet) { nIndexOptions = nSet;} 131 sal_uInt16 GetIndexOptions() const { return nIndexOptions;} 132 133 const String& GetMainEntryCharStyle() const {return sMainEntryCharStyle;} 134 void SetMainEntryCharStyle(const String& rSet) {sMainEntryCharStyle = rSet;} 135 136 void SetLevel(sal_uInt8 nSet) {nLevel = nSet;} 137 sal_uInt8 GetLevel()const {return nLevel; } 138 139 void SetCreateFromObjectNames(sal_Bool bSet) { bFromObjectNames = bSet;} 140 sal_Bool IsCreateFromObjectNames() const {return bFromObjectNames;} 141 142 const String& GetSequenceName() const {return sSequenceName;} 143 void SetSequenceName(const String& rSet) {sSequenceName = rSet;} 144 145 SwCaptionDisplay GetCaptionDisplay() const { return eCaptionDisplay;} 146 void SetCaptionDisplay(SwCaptionDisplay eSet) {eCaptionDisplay = eSet;} 147 148 void SetFromChapter(sal_Bool bSet) { bFromChapter = bSet;} 149 sal_Bool IsFromChapter() const {return bFromChapter;} 150 151 void SetReadonly(sal_Bool bSet){bReadonly = bSet;} 152 sal_Bool IsReadonly() const {return bReadonly;} 153 154 sal_uInt16 GetOLEOptions() const {return nOLEOptions;} 155 void SetOLEOptions(sal_uInt16 nOpt) {nOLEOptions = nOpt;} 156 157 sal_Bool IsLevelFromChapter() const {return bLevelFromChapter;} 158 void SetLevelFromChapter(sal_Bool bSet) {bLevelFromChapter = bSet;} 159 160 String GetAuthBrackets() const {return sAuthBrackets;} 161 void SetAuthBrackets(const String& rSet) {sAuthBrackets = rSet;} 162 163 sal_Bool IsAuthSequence() const {return bIsAuthSequence;} 164 void SetAuthSequence(sal_Bool bSet){bIsAuthSequence = bSet;} 165 166 sal_Bool IsSortByDocument()const {return bSortByDocument ;} 167 void SetSortByDocument(sal_Bool bSet) {bSortByDocument = bSet;} 168 169 void SetSortKeys(SwTOXSortKey eKey1, 170 SwTOXSortKey eKey2, 171 SwTOXSortKey eKey3); 172 173 SwTOXSortKey GetSortKey1() const {return eSortKey1;} 174 SwTOXSortKey GetSortKey2() const {return eSortKey2;} 175 SwTOXSortKey GetSortKey3() const {return eSortKey3;} 176 177 LanguageType GetLanguage() const {return eLanguage;} 178 void SetLanguage(LanguageType nLang) {eLanguage = nLang;} 179 180 const String& GetSortAlgorithm()const {return sSortAlgorithm;} 181 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 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 pPhoneticReadingOfSecKey(0) 220 { 221 } 222 ~SwTOXMarkDescription() 223 { 224 delete pPrimKey; 225 delete pSecKey; 226 delete pAltStr; 227 delete pTOUName; 228 delete pPhoneticReadingOfAltStr; 229 delete pPhoneticReadingOfPrimKey; 230 delete pPhoneticReadingOfSecKey; 231 } 232 233 TOXTypes GetTOXType()const {return eTOXType;} 234 235 void SetLevel(int nSet) {nLevel = nSet;} 236 int GetLevel() const {return nLevel;} 237 238 void SetMainEntry(sal_Bool bSet) {bMainEntry = bSet;} 239 sal_Bool IsMainEntry() const {return bMainEntry;} 240 241 void SetPrimKey(const String& rSet) 242 {delete pPrimKey; pPrimKey = new String(rSet);} 243 const String* GetPrimKey() const {return pPrimKey;} 244 245 void SetSecKey(const String& rSet) 246 {delete pSecKey; pSecKey = new String(rSet);} 247 const String* GetSecKey() const { return pSecKey; } 248 249 void SetAltStr(const String& rSet) 250 {delete pAltStr; pAltStr = new String(rSet);} 251 const String* GetAltStr() const { return pAltStr; } 252 253 void SetTOUName(const String& rSet) 254 {delete pTOUName; pTOUName = new String(rSet);} 255 const String* GetTOUName() const {return pTOUName;} 256 257 258 void SetPhoneticReadingOfAltStr(const String& rSet) 259 {delete pPhoneticReadingOfAltStr; pPhoneticReadingOfAltStr = new String(rSet);} 260 const String* GetPhoneticReadingOfAltStr() const { return pPhoneticReadingOfAltStr; } 261 262 void SetPhoneticReadingOfPrimKey(const String& rSet) 263 {delete pPhoneticReadingOfPrimKey; pPhoneticReadingOfPrimKey = new String(rSet);} 264 const String* GetPhoneticReadingOfPrimKey() const { return pPhoneticReadingOfPrimKey; } 265 266 void SetPhoneticReadingOfSecKey(const String& rSet) 267 {delete pPhoneticReadingOfSecKey; pPhoneticReadingOfSecKey = new String(rSet);} 268 const String* GetPhoneticReadingOfSecKey() const { return pPhoneticReadingOfSecKey; } 269 }; 270 271 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 // Methoden fuer Verzeichnismarkierungen 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 // Aktuelle TOXmarks holen 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 // Methoden fuer Verzeichnisse 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 /*-------------------------------------------------------------------- 314 Beschreibung: Inlines 315 --------------------------------------------------------------------*/ 316 317 inline sal_uInt16 SwTOXMgr::GetTOXMarkCount() 318 { return aCurMarks.Count(); } 319 320 321 inline SwTOXMark* SwTOXMgr::GetCurTOXMark() 322 { return pCurTOXMark; } 323 324 #endif 325