xref: /AOO41X/main/sw/source/ui/inc/toxmgr.hxx (revision 1d2dbeb0b7301723c6d13094e87a8714ef81a328)
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.
SwTOXDescription(TOXTypes eType)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         {}
~SwTOXDescription()96     ~SwTOXDescription()
97         {
98             delete pTitle;
99             delete pForm;
100             delete pTOUName;
101         }
102 
SetTOXType(TOXTypes eSet)103     void            SetTOXType(TOXTypes eSet) { eTOXType = eSet;}
GetTOXType() const104     TOXTypes        GetTOXType() const { return eTOXType;}
105 
GetStyleNames(sal_uInt16 nLvl) const106     const String&   GetStyleNames(sal_uInt16 nLvl) const
107                                 {return aStyleNames[nLvl];}
SetStyleNames(const String & rSet,sal_uInt16 nLvl)108     void            SetStyleNames(const String& rSet, sal_uInt16 nLvl)
109                                 {aStyleNames[nLvl] = rSet; }
110 
GetAutoMarkURL() const111     const String&   GetAutoMarkURL() const { return sAutoMarkURL;}
SetAutoMarkURL(const String & rSet)112     void            SetAutoMarkURL(const String& rSet) {sAutoMarkURL = rSet;}
113 
SetTitle(const String & pSet)114     void            SetTitle(const String& pSet) {delete pTitle; pTitle = new String(pSet);}
GetTitle() const115     const String*   GetTitle() const {return pTitle; }
116 
SetTOUName(const String & pSet)117     void            SetTOUName(const String& pSet) {delete pTOUName; pTOUName = new String(pSet);}
GetTOUName() const118     const String*   GetTOUName() const {return pTOUName; }
119 
SetForm(const SwForm & rSet)120     void            SetForm(const SwForm& rSet) {delete pForm; pForm = new SwForm(rSet);}
GetForm() const121     const SwForm*   GetForm() const {return pForm;}
122 
SetContentOptions(sal_uInt16 nSet)123     void            SetContentOptions(sal_uInt16 nSet) { nContent = nSet;}
GetContentOptions() const124     sal_uInt16          GetContentOptions() const { return nContent;}
125 
SetIndexOptions(sal_uInt16 nSet)126     void            SetIndexOptions(sal_uInt16 nSet) { nIndexOptions = nSet;}
GetIndexOptions() const127     sal_uInt16          GetIndexOptions() const { return nIndexOptions;}
128 
GetMainEntryCharStyle() const129     const String&   GetMainEntryCharStyle() const {return sMainEntryCharStyle;}
SetMainEntryCharStyle(const String & rSet)130     void            SetMainEntryCharStyle(const String& rSet)  {sMainEntryCharStyle = rSet;}
131 
SetLevel(sal_uInt8 nSet)132     void            SetLevel(sal_uInt8 nSet) {nLevel = nSet;}
GetLevel() const133     sal_uInt8           GetLevel()const  {return nLevel; }
134 
SetCreateFromObjectNames(sal_Bool bSet)135     void            SetCreateFromObjectNames(sal_Bool bSet) { bFromObjectNames = bSet;}
IsCreateFromObjectNames() const136     sal_Bool            IsCreateFromObjectNames() const {return bFromObjectNames;}
137 
GetSequenceName() const138     const String&   GetSequenceName() const {return sSequenceName;}
SetSequenceName(const String & rSet)139     void            SetSequenceName(const String& rSet) {sSequenceName = rSet;}
140 
GetCaptionDisplay() const141     SwCaptionDisplay    GetCaptionDisplay() const { return eCaptionDisplay;}
SetCaptionDisplay(SwCaptionDisplay eSet)142     void                SetCaptionDisplay(SwCaptionDisplay eSet) {eCaptionDisplay = eSet;}
143 
SetFromChapter(sal_Bool bSet)144     void            SetFromChapter(sal_Bool bSet) { bFromChapter = bSet;}
IsFromChapter() const145     sal_Bool            IsFromChapter() const {return bFromChapter;}
146 
SetReadonly(sal_Bool bSet)147     void            SetReadonly(sal_Bool bSet){bReadonly = bSet;}
IsReadonly() const148     sal_Bool            IsReadonly() const {return bReadonly;}
149 
GetOLEOptions() const150     sal_uInt16          GetOLEOptions() const {return nOLEOptions;}
SetOLEOptions(sal_uInt16 nOpt)151     void            SetOLEOptions(sal_uInt16 nOpt) {nOLEOptions = nOpt;}
152 
IsLevelFromChapter() const153     sal_Bool            IsLevelFromChapter() const {return bLevelFromChapter;}
SetLevelFromChapter(sal_Bool bSet)154     void            SetLevelFromChapter(sal_Bool bSet) {bLevelFromChapter = bSet;}
155 
GetAuthBrackets() const156     String          GetAuthBrackets() const {return sAuthBrackets;}
SetAuthBrackets(const String & rSet)157     void            SetAuthBrackets(const String& rSet) {sAuthBrackets = rSet;}
158 
IsAuthSequence() const159     sal_Bool            IsAuthSequence() const {return bIsAuthSequence;}
SetAuthSequence(sal_Bool bSet)160     void            SetAuthSequence(sal_Bool bSet){bIsAuthSequence = bSet;}
161 
IsSortByDocument() const162     sal_Bool            IsSortByDocument()const {return bSortByDocument ;}
SetSortByDocument(sal_Bool bSet)163     void            SetSortByDocument(sal_Bool bSet) {bSortByDocument = bSet;}
164 
165     void SetSortKeys(SwTOXSortKey eKey1,
166                         SwTOXSortKey eKey2,
167                             SwTOXSortKey eKey3);
168 
GetSortKey1() const169     SwTOXSortKey GetSortKey1() const {return eSortKey1;}
GetSortKey2() const170     SwTOXSortKey GetSortKey2() const {return eSortKey2;}
GetSortKey3() const171     SwTOXSortKey GetSortKey3() const {return eSortKey3;}
172 
GetLanguage() const173     LanguageType    GetLanguage() const {return eLanguage;}
SetLanguage(LanguageType nLang)174     void            SetLanguage(LanguageType nLang)  {eLanguage = nLang;}
175 
GetSortAlgorithm() const176     const String&   GetSortAlgorithm()const {return sSortAlgorithm;}
SetSortAlgorithm(const String & rSet)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.
SwTOXMarkDescription(TOXTypes eType)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         }
~SwTOXMarkDescription()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 
GetTOXType() const229     TOXTypes        GetTOXType()const {return eTOXType;}
230 
SetLevel(int nSet)231     void            SetLevel(int nSet) {nLevel = nSet;}
GetLevel() const232     int             GetLevel() const {return nLevel;}
233 
SetMainEntry(sal_Bool bSet)234     void            SetMainEntry(sal_Bool bSet) {bMainEntry = bSet;}
IsMainEntry() const235     sal_Bool            IsMainEntry() const {return bMainEntry;}
236 
SetPrimKey(const String & rSet)237     void            SetPrimKey(const String& rSet)
238                                 {delete pPrimKey; pPrimKey = new String(rSet);}
GetPrimKey() const239     const String*   GetPrimKey() const {return pPrimKey;}
240 
SetSecKey(const String & rSet)241     void            SetSecKey(const String& rSet)
242                                 {delete pSecKey;  pSecKey  = new String(rSet);}
GetSecKey() const243     const String*   GetSecKey() const { return pSecKey; }
244 
SetAltStr(const String & rSet)245     void            SetAltStr(const String& rSet)
246                                 {delete pAltStr;  pAltStr  = new String(rSet);}
GetAltStr() const247     const String*   GetAltStr() const { return pAltStr; }
248 
SetTOUName(const String & rSet)249     void            SetTOUName(const String& rSet)
250                                 {delete pTOUName; pTOUName = new String(rSet);}
GetTOUName() const251     const String*   GetTOUName() const {return pTOUName;}
252 
253 
SetPhoneticReadingOfAltStr(const String & rSet)254     void            SetPhoneticReadingOfAltStr(const String& rSet)
255                                 {delete pPhoneticReadingOfAltStr;  pPhoneticReadingOfAltStr  = new String(rSet);}
GetPhoneticReadingOfAltStr() const256     const String*   GetPhoneticReadingOfAltStr() const {    return pPhoneticReadingOfAltStr; }
257 
SetPhoneticReadingOfPrimKey(const String & rSet)258     void            SetPhoneticReadingOfPrimKey(const String& rSet)
259                                 {delete pPhoneticReadingOfPrimKey;  pPhoneticReadingOfPrimKey  = new String(rSet);}
GetPhoneticReadingOfPrimKey() const260     const String*   GetPhoneticReadingOfPrimKey() const {   return pPhoneticReadingOfPrimKey; }
261 
SetPhoneticReadingOfSecKey(const String & rSet)262     void            SetPhoneticReadingOfSecKey(const String& rSet)
263                                 {delete pPhoneticReadingOfSecKey;  pPhoneticReadingOfSecKey  = new String(rSet);}
GetPhoneticReadingOfSecKey() const264     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 
GetTOXMarkCount()313 inline sal_uInt16 SwTOXMgr::GetTOXMarkCount()
314     {   return aCurMarks.Count();   }
315 
316 
GetCurTOXMark()317 inline SwTOXMark* SwTOXMgr::GetCurTOXMark()
318     {   return pCurTOXMark; }
319 
320 #endif
321