1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _TOXMGR_HXX 25 #define _TOXMGR_HXX 26 27 #include "swdllapi.h" 28 #include "tox.hxx" 29 #include <authfld.hxx> 30 31 class SwWrtShell; 32 class SwForm; 33 34 /*-------------------------------------------------------------------- 35 Beschreibung: Manager fuer Verzeichnisfunktionalitaet 36 --------------------------------------------------------------------*/ 37 //one single method will be sufficient to insert AND upate indexes 38 39 class SW_DLLPUBLIC SwTOXDescription 40 { 41 TOXTypes eTOXType; 42 String aStyleNames[MAXLEVEL]; 43 String sSequenceName; 44 String sMainEntryCharStyle; 45 String sAutoMarkURL; 46 String* pTitle; 47 String* pTOUName; 48 SwForm* pForm; 49 sal_uInt16 nContent; 50 sal_uInt16 nIndexOptions; 51 sal_uInt16 nOLEOptions; 52 LanguageType eLanguage; 53 String sSortAlgorithm; 54 55 String sAuthBrackets; 56 SwCaptionDisplay eCaptionDisplay; 57 SwTOXSortKey eSortKey1; 58 SwTOXSortKey eSortKey2; 59 SwTOXSortKey eSortKey3; 60 sal_uInt8 nLevel; 61 sal_Bool bFromObjectNames : 1; 62 sal_Bool bFromChapter : 1; 63 sal_Bool bReadonly: 1; 64 sal_Bool bLevelFromChapter : 1; 65 sal_Bool bIsAuthSequence :1; 66 sal_Bool bSortByDocument :1; 67 68 //TODO: TemplateNames 69 //const String* pTemplateName = 0, ??? 70 71 // forbidden and not implemented. 72 SwTOXDescription(); 73 SwTOXDescription(SwTOXDescription&); 74 SwTOXDescription & operator= (SwTOXDescription&); 75 76 public: 77 // single argument ctors shall be explicit. 78 explicit SwTOXDescription(TOXTypes eType) : 79 eTOXType(eType), 80 pTitle(0), 81 pTOUName(0), 82 pForm(0), 83 nContent(nsSwTOXElement::TOX_MARK | nsSwTOXElement::TOX_OUTLINELEVEL), 84 nIndexOptions(nsSwTOIOptions::TOI_SAME_ENTRY|nsSwTOIOptions::TOI_FF|nsSwTOIOptions::TOI_CASE_SENSITIVE), 85 nOLEOptions(0), 86 eLanguage((LanguageType)::GetAppLanguage()), 87 eCaptionDisplay(CAPTION_COMPLETE), 88 nLevel(MAXLEVEL), 89 bFromObjectNames(sal_False), 90 bFromChapter(sal_False), 91 bReadonly(sal_True), 92 bLevelFromChapter(sal_False), 93 bIsAuthSequence(sal_False), 94 bSortByDocument(sal_True) 95 {} 96 ~SwTOXDescription() 97 { 98 delete pTitle; 99 delete pForm; 100 delete pTOUName; 101 } 102 103 void SetTOXType(TOXTypes eSet) { eTOXType = eSet;} 104 TOXTypes GetTOXType() const { return eTOXType;} 105 106 const String& GetStyleNames(sal_uInt16 nLvl) const 107 {return aStyleNames[nLvl];} 108 void SetStyleNames(const String& rSet, sal_uInt16 nLvl) 109 {aStyleNames[nLvl] = rSet; } 110 111 const String& GetAutoMarkURL() const { return sAutoMarkURL;} 112 void SetAutoMarkURL(const String& rSet) {sAutoMarkURL = rSet;} 113 114 void SetTitle(const String& pSet) {delete pTitle; pTitle = new String(pSet);} 115 const String* GetTitle() const {return pTitle; } 116 117 void SetTOUName(const String& pSet) {delete pTOUName; pTOUName = new String(pSet);} 118 const String* GetTOUName() const {return pTOUName; } 119 120 void SetForm(const SwForm& rSet) {delete pForm; pForm = new SwForm(rSet);} 121 const SwForm* GetForm() const {return pForm;} 122 123 void SetContentOptions(sal_uInt16 nSet) { nContent = nSet;} 124 sal_uInt16 GetContentOptions() const { return nContent;} 125 126 void SetIndexOptions(sal_uInt16 nSet) { nIndexOptions = nSet;} 127 sal_uInt16 GetIndexOptions() const { return nIndexOptions;} 128 129 const String& GetMainEntryCharStyle() const {return sMainEntryCharStyle;} 130 void SetMainEntryCharStyle(const String& rSet) {sMainEntryCharStyle = rSet;} 131 132 void SetLevel(sal_uInt8 nSet) {nLevel = nSet;} 133 sal_uInt8 GetLevel()const {return nLevel; } 134 135 void SetCreateFromObjectNames(sal_Bool bSet) { bFromObjectNames = bSet;} 136 sal_Bool IsCreateFromObjectNames() const {return bFromObjectNames;} 137 138 const String& GetSequenceName() const {return sSequenceName;} 139 void SetSequenceName(const String& rSet) {sSequenceName = rSet;} 140 141 SwCaptionDisplay GetCaptionDisplay() const { return eCaptionDisplay;} 142 void SetCaptionDisplay(SwCaptionDisplay eSet) {eCaptionDisplay = eSet;} 143 144 void SetFromChapter(sal_Bool bSet) { bFromChapter = bSet;} 145 sal_Bool IsFromChapter() const {return bFromChapter;} 146 147 void SetReadonly(sal_Bool bSet){bReadonly = bSet;} 148 sal_Bool IsReadonly() const {return bReadonly;} 149 150 sal_uInt16 GetOLEOptions() const {return nOLEOptions;} 151 void SetOLEOptions(sal_uInt16 nOpt) {nOLEOptions = nOpt;} 152 153 sal_Bool IsLevelFromChapter() const {return bLevelFromChapter;} 154 void SetLevelFromChapter(sal_Bool bSet) {bLevelFromChapter = bSet;} 155 156 String GetAuthBrackets() const {return sAuthBrackets;} 157 void SetAuthBrackets(const String& rSet) {sAuthBrackets = rSet;} 158 159 sal_Bool IsAuthSequence() const {return bIsAuthSequence;} 160 void SetAuthSequence(sal_Bool bSet){bIsAuthSequence = bSet;} 161 162 sal_Bool IsSortByDocument()const {return bSortByDocument ;} 163 void SetSortByDocument(sal_Bool bSet) {bSortByDocument = bSet;} 164 165 void SetSortKeys(SwTOXSortKey eKey1, 166 SwTOXSortKey eKey2, 167 SwTOXSortKey eKey3); 168 169 SwTOXSortKey GetSortKey1() const {return eSortKey1;} 170 SwTOXSortKey GetSortKey2() const {return eSortKey2;} 171 SwTOXSortKey GetSortKey3() const {return eSortKey3;} 172 173 LanguageType GetLanguage() const {return eLanguage;} 174 void SetLanguage(LanguageType nLang) {eLanguage = nLang;} 175 176 const String& GetSortAlgorithm()const {return sSortAlgorithm;} 177 void SetSortAlgorithm(const String& rSet) {sSortAlgorithm = rSet;} 178 179 void ApplyTo(SwTOXBase& rTOXBase); 180 181 }; 182 // -------------------------------------------------------------------------------- 183 class SwTOXMarkDescription 184 { 185 TOXTypes eTOXType; 186 int nLevel; 187 sal_Bool bMainEntry; 188 189 String* pPrimKey; 190 String* pSecKey; 191 String* pAltStr; 192 String* pTOUName; 193 194 String* pPhoneticReadingOfAltStr; 195 String* pPhoneticReadingOfPrimKey; 196 String* pPhoneticReadingOfSecKey; 197 198 // forbidden and not implemented. 199 SwTOXMarkDescription(); 200 SwTOXMarkDescription(SwTOXMarkDescription&); 201 SwTOXMarkDescription & operator= (SwTOXMarkDescription&); 202 203 public: 204 // single argument ctors shall be explicit. 205 explicit SwTOXMarkDescription(TOXTypes eType) : 206 eTOXType(eType), 207 nLevel(0), 208 bMainEntry(sal_False), 209 pPrimKey(0), 210 pSecKey(0), 211 pAltStr(0), 212 pTOUName(0), 213 pPhoneticReadingOfAltStr(0), 214 pPhoneticReadingOfPrimKey(0), 215 pPhoneticReadingOfSecKey(0) 216 { 217 } 218 ~SwTOXMarkDescription() 219 { 220 delete pPrimKey; 221 delete pSecKey; 222 delete pAltStr; 223 delete pTOUName; 224 delete pPhoneticReadingOfAltStr; 225 delete pPhoneticReadingOfPrimKey; 226 delete pPhoneticReadingOfSecKey; 227 } 228 229 TOXTypes GetTOXType()const {return eTOXType;} 230 231 void SetLevel(int nSet) {nLevel = nSet;} 232 int GetLevel() const {return nLevel;} 233 234 void SetMainEntry(sal_Bool bSet) {bMainEntry = bSet;} 235 sal_Bool IsMainEntry() const {return bMainEntry;} 236 237 void SetPrimKey(const String& rSet) 238 {delete pPrimKey; pPrimKey = new String(rSet);} 239 const String* GetPrimKey() const {return pPrimKey;} 240 241 void SetSecKey(const String& rSet) 242 {delete pSecKey; pSecKey = new String(rSet);} 243 const String* GetSecKey() const { return pSecKey; } 244 245 void SetAltStr(const String& rSet) 246 {delete pAltStr; pAltStr = new String(rSet);} 247 const String* GetAltStr() const { return pAltStr; } 248 249 void SetTOUName(const String& rSet) 250 {delete pTOUName; pTOUName = new String(rSet);} 251 const String* GetTOUName() const {return pTOUName;} 252 253 254 void SetPhoneticReadingOfAltStr(const String& rSet) 255 {delete pPhoneticReadingOfAltStr; pPhoneticReadingOfAltStr = new String(rSet);} 256 const String* GetPhoneticReadingOfAltStr() const { return pPhoneticReadingOfAltStr; } 257 258 void SetPhoneticReadingOfPrimKey(const String& rSet) 259 {delete pPhoneticReadingOfPrimKey; pPhoneticReadingOfPrimKey = new String(rSet);} 260 const String* GetPhoneticReadingOfPrimKey() const { return pPhoneticReadingOfPrimKey; } 261 262 void SetPhoneticReadingOfSecKey(const String& rSet) 263 {delete pPhoneticReadingOfSecKey; pPhoneticReadingOfSecKey = new String(rSet);} 264 const String* GetPhoneticReadingOfSecKey() const { return pPhoneticReadingOfSecKey; } 265 }; 266 267 class SW_DLLPUBLIC SwTOXMgr 268 { 269 SwWrtShell* pSh; 270 SwTOXMark* pCurTOXMark; 271 SwTOXMarks aCurMarks; 272 273 SW_DLLPRIVATE sal_uInt16 GetUserTypeID(const String& rStr); 274 275 public: 276 // single argument ctors shall be explicit. 277 explicit SwTOXMgr(SwWrtShell* pShell); 278 279 // 280 // Methoden fuer Verzeichnismarkierungen 281 // 282 void InsertTOXMark(const SwTOXMarkDescription& rDesc); 283 284 void UpdateTOXMark(const SwTOXMarkDescription& rDesc); 285 286 287 void DeleteTOXMark(); 288 void NextTOXMark(sal_Bool bSame=sal_False); 289 void PrevTOXMark(sal_Bool bSame=sal_False); 290 291 // Aktuelle TOXmarks holen 292 sal_uInt16 GetTOXMarks(); 293 sal_uInt16 GetTOXMarkCount(); 294 SwTOXMark* GetTOXMark(sal_uInt16 nId); 295 SwTOXMark* GetCurTOXMark(); 296 void SetCurTOXMark(sal_uInt16 nId); 297 298 // 299 // Methoden fuer Verzeichnisse 300 // 301 sal_Bool UpdateOrInsertTOX(const SwTOXDescription& rDesc, SwTOXBase** ppBase = 0, const SfxItemSet* pSet = 0); 302 303 const SwTOXType* GetTOXType(TOXTypes eTyp, sal_uInt16 nId) const; 304 const SwTOXBase* GetCurTOX(); 305 306 }; 307 308 309 /*-------------------------------------------------------------------- 310 Beschreibung: Inlines 311 --------------------------------------------------------------------*/ 312 313 inline sal_uInt16 SwTOXMgr::GetTOXMarkCount() 314 { return aCurMarks.Count(); } 315 316 317 inline SwTOXMark* SwTOXMgr::GetCurTOXMark() 318 { return pCurTOXMark; } 319 320 #endif 321