xref: /trunk/main/svx/inc/svx/nbdtmg.hxx (revision c05f2616a465dea96e35a8861f2e4c1436673fea)
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 #ifndef _NBDTMG_HXX
23 #define _NBDTMG_HXX
24 #include "svx/svxdllapi.h"
25 
26 #ifndef _SVX_NUMITEM_HXX
27 #include <editeng/numitem.hxx>
28 #endif
29 #define _SVSTDARR_USHORTS
30 #include <svl/svstdarr.hxx>
31 #include <svl/svarray.hxx>
32 #ifndef _LIST_HXX
33 #include <tools/list.hxx>
34 #endif
35 #ifndef _SV_FONT_HXX
36 #include <vcl/font.hxx>
37 #endif
38 
39 namespace svx { namespace sidebar {
40 
41 #define DEFAULT_BULLET_TYPES                            8
42 #define DEFAULT_NONE                                    10
43 #define DEFAULT_NUM_TYPE_MEMBER                         5
44 #define DEFAULT_NUM_VALUESET_COUNT                      8
45 #define DEFAULT_NUMBERING_CACHE_FORMAT_VERSION          0x10
46 
47 typedef sal_uInt16 NBOType;
48 namespace eNBOType
49 {
50     const NBOType BULLETS = 0x01;
51     const NBOType GRAPHICBULLETS = 0x02;
52     const NBOType NUMBERING = 0x03;
53     const NBOType OUTLINE = 0x04;
54     const NBOType MIXBULLETS = 0x05;
55 }
56 
57 typedef sal_uInt16 NBType;
58 namespace eNBType
59 {
60     const NBOType BULLETS = 0x01;
61     const NBOType GRAPHICBULLETS = 0x02;
62 }
63 
64 class SVX_DLLPUBLIC NumSettings_Impl
65 {
66     public:
67         short       nNumberType;
68         short       nParentNumbering;
69         SvxNumberFormat::SvxNumLabelFollowedBy eLabelFollowedBy;
70         long        nTabValue;
71         SvxAdjust   eNumAlign;
72         long            nNumAlignAt;
73         long            nNumIndentAt;
74         rtl::OUString   sPrefix;
75         rtl::OUString   sSuffix;
76         rtl::OUString   sBulletChar;
77         rtl::OUString   sBulletFont;
78         SvxBrushItem    *pBrushItem;
79         Size            aSize;
80 
81     public:
NumSettings_Impl()82         NumSettings_Impl() :
83           nNumberType(0),
84           nParentNumbering(0),
85           pBrushItem(0),
86           aSize(0,0)
87             {}
~NumSettings_Impl()88         ~NumSettings_Impl(){}
89 };
90 /*
91 typedef NumSettings_Impl* NumSettings_ImplPtr;
92 SV_DECL_PTRARR_DEL(NumSettingsArr_Impl,NumSettings_ImplPtr,8,4)
93 SV_IMPL_PTRARR( NumSettingsArr_Impl, NumSettings_ImplPtr )*/
94 
95 class NumSettingsArr_Impl;
96 
97 class SVX_DLLPUBLIC BulletsSettings
98 {
99     public:
100         sal_Bool        bIsCustomized;
101         rtl::OUString   sDescription;
102         NBType      eType;
103     public:
BulletsSettings(NBType eTy)104         BulletsSettings(NBType eTy) :
105             bIsCustomized(sal_False),
106             eType(eTy)
107             {}
~BulletsSettings()108         virtual ~BulletsSettings(){}
109 };
110 
111 class SVX_DLLPUBLIC BulletsSettings_Impl:public BulletsSettings
112 {
113     public:
114         sal_Unicode cBulletChar;
115         //rtl::OUString sBulletFont;
116         Font            aFont;
117 
118     public:
BulletsSettings_Impl(NBType eTy)119         BulletsSettings_Impl(NBType eTy) :
120             BulletsSettings(eTy)
121             {}
~BulletsSettings_Impl()122         virtual ~BulletsSettings_Impl(){}
123 };
124 
125 class SVX_DLLPUBLIC GrfBulDataRelation: public BulletsSettings
126 {
127     public:
128         String  sGrfName;
129         sal_uInt16  nTabIndex;
130         sal_uInt16  nGallaryIndex;
131         const Graphic*  pGrfObj;
132         Size aSize;
GrfBulDataRelation(NBType eTy)133     GrfBulDataRelation(NBType eTy):
134         BulletsSettings(eTy),
135         nTabIndex((sal_uInt16)0xFFFF),
136         nGallaryIndex((sal_uInt16)0xFFFF),
137         pGrfObj(0),
138         aSize(0,0)
139     {}
~GrfBulDataRelation()140     virtual ~GrfBulDataRelation(){}
141 };
142 
143 class SVX_DLLPUBLIC MixBulletsSettings_Impl
144 {
145     public:
146         NBType          eType;
147         sal_uInt16          nIndex; //index in the tab page display
148         sal_uInt16          nIndexDefault;
149         BulletsSettings*    pBullets;
150     public:
MixBulletsSettings_Impl(NBType eTy)151         MixBulletsSettings_Impl(NBType eTy) :
152             eType(eTy),
153             nIndex((sal_uInt16)0xFFFF),
154             nIndexDefault((sal_uInt16)0xFFFF),
155             pBullets(0)
156             {}
~MixBulletsSettings_Impl()157         ~MixBulletsSettings_Impl(){}
158 };
159 
160 class SVX_DLLPUBLIC NumberSettings_Impl
161 {
162     public:
163         sal_Bool        bIsCustomized;
164         rtl::OUString   sDescription;
165         sal_uInt16      nIndex; //index in the tab page display
166         sal_uInt16      nIndexDefault;
167         NumSettings_Impl    *pNumSetting;
168     public:
NumberSettings_Impl()169         NumberSettings_Impl() :
170             bIsCustomized(sal_False),
171             nIndex((sal_uInt16)0xFFFF),
172             nIndexDefault((sal_uInt16)0xFFFF),
173             pNumSetting(NULL)
174             {}
~NumberSettings_Impl()175         ~NumberSettings_Impl(){}
176 };
177 
178 class NumberSettingsArr_Impl;
179 
180 class SVX_DLLPUBLIC OutlineSettings_Impl
181 {
182     public:
183         sal_Bool        bIsCustomized;
184         rtl::OUString   sDescription;
185         NumSettingsArr_Impl *pNumSettingsArr;
186     public:
OutlineSettings_Impl()187         OutlineSettings_Impl() :
188             bIsCustomized(sal_False),
189             pNumSettingsArr(NULL)
190             {}
~OutlineSettings_Impl()191         ~OutlineSettings_Impl(){
192         }
193 };
194 
195 class SVX_DLLPUBLIC NBOTypeMgrBase
196 {
197     public:
198         NBOType         eType;
199     private:
200         const SfxItemSet*   pSet;
201         SfxMapUnit      eCoreUnit;
202         // store the attributes passed from pSet
203         String          aNumCharFmtName;
204         void            StoreBulCharFmtName_impl();
205         void            StoreMapUnit_impl();
206 
207     public:
NBOTypeMgrBase(const NBOType aType)208         NBOTypeMgrBase(const NBOType aType):eType(aType),pSet(0),eCoreUnit(SFX_MAPUNIT_TWIP),aNumCharFmtName(String()){}
NBOTypeMgrBase(const NBOType aType,const SfxItemSet * pArg)209         NBOTypeMgrBase(const NBOType aType,const SfxItemSet* pArg):eType(aType),pSet(pArg),eCoreUnit(SFX_MAPUNIT_TWIP),aNumCharFmtName(String()){}
NBOTypeMgrBase(const NBOTypeMgrBase & aTypeMgr)210         NBOTypeMgrBase(const NBOTypeMgrBase& aTypeMgr){eType = aTypeMgr.eType;pSet = aTypeMgr.pSet;eCoreUnit = aTypeMgr.eCoreUnit;aNumCharFmtName = aTypeMgr.aNumCharFmtName; }
~NBOTypeMgrBase()211         virtual ~NBOTypeMgrBase() {}
212         virtual void Init()=0;
213         virtual sal_uInt16 GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex=0)=0;
214         virtual sal_Bool RelplaceNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel=(sal_uInt16)0xFFFF)=0;
215         virtual sal_Bool ApplyNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel=(sal_uInt16)0xFFFF, sal_Bool isDefault=false,sal_Bool isResetSize=false)=0;
216         virtual String GetDescription(sal_uInt16 nIndex,sal_Bool isDefault=false)=0;
217         virtual sal_Bool IsCustomized(sal_uInt16 nIndex)=0;
218         sal_uInt16 IsSingleLevel(sal_uInt16 nCurLevel);
GetItems()219         const SfxItemSet* GetItems() { return pSet;}
220         // store the attributes passed from pSet
SetItems(const SfxItemSet * pArg)221         void SetItems(const SfxItemSet* pArg) { pSet = pArg;StoreBulCharFmtName_impl();StoreMapUnit_impl();}
222     protected:
223         String GetBulCharFmtName();
224         SfxMapUnit GetMapUnit();
225     protected:
226         sal_Bool    bIsLoading;
227         void    ImplLoad(String filename);
228         void    ImplStore(String filename);
229 
230 };
231 
232 class SVX_DLLPUBLIC BulletsTypeMgr: public NBOTypeMgrBase
233 {
234     friend class OutlineTypeMgr;
235     friend class NumberingTypeMgr;
236     public:
237         static sal_Unicode aDynamicBulletTypes[DEFAULT_BULLET_TYPES];
238         static sal_Unicode aDynamicRTLBulletTypes[DEFAULT_BULLET_TYPES];
239         static BulletsSettings_Impl* pActualBullets[DEFAULT_BULLET_TYPES];
240         static BulletsTypeMgr* _instance;
241     public:
242         BulletsTypeMgr(const NBOType aType);
243         BulletsTypeMgr(const NBOType aType,const SfxItemSet* pArg);
244         BulletsTypeMgr(const BulletsTypeMgr& aTypeMgr);
~BulletsTypeMgr()245         virtual ~BulletsTypeMgr() {}
246         virtual void Init();
247         virtual sal_uInt16 GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex=0);
248         virtual sal_Bool RelplaceNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel=(sal_uInt16)0xFFFF);
249         virtual sal_Bool ApplyNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel=(sal_uInt16)0xFFFF,sal_Bool isDefault=false,sal_Bool isResetSize=false);
250         virtual String GetDescription(sal_uInt16 nIndex,sal_Bool isDefault=false);
251         virtual sal_Bool IsCustomized(sal_uInt16 nIndex);
252         sal_Unicode GetBulChar(sal_uInt16 nIndex);
253         Font GetBulCharFont(sal_uInt16 nIndex);
GetInstance()254         static BulletsTypeMgr* GetInstance()
255         {
256              if ( _instance == 0 )
257                     {
258                         _instance = new BulletsTypeMgr(eNBOType::BULLETS);
259                     }
260 
261                     return _instance;
262         }
263 
264 };
265 
266 class SVX_DLLPUBLIC GraphicBulletsTypeMgr: public NBOTypeMgrBase
267 {
268     friend class OutlineTypeMgr;
269     friend class NumberingTypeMgr;
270     public:
271         List    aGrfDataLst;
272         static GraphicBulletsTypeMgr* _instance;
273     public:
274         GraphicBulletsTypeMgr(const NBOType aType);
275         GraphicBulletsTypeMgr(const NBOType aType,const SfxItemSet* pArg);
276         GraphicBulletsTypeMgr(const GraphicBulletsTypeMgr& aTypeMgr);
~GraphicBulletsTypeMgr()277         virtual ~GraphicBulletsTypeMgr() {}
278         virtual void Init();
279         virtual sal_uInt16 GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex=0);
280         virtual sal_Bool RelplaceNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel=(sal_uInt16)0xFFFF);
281         virtual sal_Bool ApplyNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel=(sal_uInt16)0xFFFF,sal_Bool isDefault=false,sal_Bool isResetSize=false);
282         virtual String GetDescription(sal_uInt16 nIndex,sal_Bool isDefault=false);
283         virtual sal_Bool IsCustomized(sal_uInt16 nIndex);
284         String GetGrfName(sal_uInt16 nIndex);
GetInstance()285         static GraphicBulletsTypeMgr* GetInstance()
286         {
287              if ( _instance == 0 )
288                     {
289                         _instance = new GraphicBulletsTypeMgr(eNBOType::BULLETS);
290                     }
291 
292                     return _instance;
293         }
294 
295 };
296 
297 class SVX_DLLPUBLIC MixBulletsTypeMgr: public NBOTypeMgrBase
298 {
299     friend class OutlineTypeMgr;
300     friend class NumberingTypeMgr;
301     public:
302         static MixBulletsSettings_Impl* pActualBullets[DEFAULT_BULLET_TYPES];
303         static MixBulletsSettings_Impl* pDefaultActualBullets[DEFAULT_BULLET_TYPES];
304         static MixBulletsTypeMgr* _instance;
305     public:
306         MixBulletsTypeMgr(const NBOType aType);
307         MixBulletsTypeMgr(const NBOType aType,const SfxItemSet* pArg);
308         MixBulletsTypeMgr(const MixBulletsTypeMgr& aTypeMgr);
~MixBulletsTypeMgr()309         virtual ~MixBulletsTypeMgr() {}
310         virtual void Init();
311         virtual sal_uInt16 GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex=0);
312         virtual sal_Bool RelplaceNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel=(sal_uInt16)0xFFFF);
313         virtual sal_Bool ApplyNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel=(sal_uInt16)0xFFFF,sal_Bool isDefault=false,sal_Bool isResetSize=false);
314         virtual String GetDescription(sal_uInt16 nIndex,sal_Bool isDefault=false);
315         virtual sal_Bool IsCustomized(sal_uInt16 nIndex);
GetInstance()316         static MixBulletsTypeMgr* GetInstance()
317         {
318              if ( _instance == 0 )
319                     {
320                         _instance = new MixBulletsTypeMgr(eNBOType::MIXBULLETS);
321                     }
322 
323                     return _instance;
324         }
325 
326 };
327 
328 class SVX_DLLPUBLIC NumberingTypeMgr: public NBOTypeMgrBase
329 {
330     public:
331         //NumSettingsArr_Impl*      pNumSettingsArr;
332         NumberSettingsArr_Impl*     pNumberSettingsArr;
333         NumberSettingsArr_Impl*     pDefaultNumberSettingsArr;
334         static NumberingTypeMgr*    _instance;
335     public:
336         NumberingTypeMgr(const NBOType aType);
337         NumberingTypeMgr(const NBOType aType,const SfxItemSet* pArg);
338         NumberingTypeMgr(const NumberingTypeMgr& aTypeMgr);
~NumberingTypeMgr()339         virtual ~NumberingTypeMgr() {}
340         virtual void Init();
341         virtual sal_uInt16 GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex=0);
342         virtual sal_Bool RelplaceNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel=(sal_uInt16)0xFFFF);
343         virtual sal_Bool ApplyNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel=(sal_uInt16)0xFFFF,sal_Bool isDefault=false,sal_Bool isResetSize=false);
344         virtual String GetDescription(sal_uInt16 nIndex,sal_Bool isDefault=false);
345         virtual sal_Bool IsCustomized(sal_uInt16 nIndex);
346         sal_uInt16 GetNumCount() const;
347         NumberSettings_Impl* GetNumSettingByIndex(sal_uInt16 nIndex) const;
GetInstance()348         static NumberingTypeMgr* GetInstance()
349         {
350              if ( _instance == 0 )
351                     {
352                         _instance = new NumberingTypeMgr(eNBOType::NUMBERING);
353                     }
354 
355                     return _instance;
356         }
357 };
358 
359 class SVX_DLLPUBLIC OutlineTypeMgr: public NBOTypeMgrBase
360 {
361     public:
362         //NumSettingsArr_Impl*      pNumSettingsArrs[DEFAULT_NUM_VALUESET_COUNT];
363         OutlineSettings_Impl*       pOutlineSettingsArrs[DEFAULT_NUM_VALUESET_COUNT];
364         OutlineSettings_Impl*       pDefaultOutlineSettingsArrs[DEFAULT_NUM_VALUESET_COUNT];
365         static OutlineTypeMgr*  _instance;
366     public:
367         OutlineTypeMgr(const NBOType aType);
368         OutlineTypeMgr(const NBOType aType,const SfxItemSet* pArg);
369         OutlineTypeMgr(const OutlineTypeMgr& aTypeMgr);
~OutlineTypeMgr()370         virtual ~OutlineTypeMgr() {}
371         virtual void Init();
372         virtual sal_uInt16 GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex=0);
373         virtual sal_Bool RelplaceNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel=(sal_uInt16)0xFFFF);
374         virtual sal_Bool ApplyNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel=(sal_uInt16)0xFFFF,sal_Bool isDefault=false,sal_Bool isResetSize=false);
375         virtual String GetDescription(sal_uInt16 nIndex,sal_Bool isDefault=false);
376         virtual sal_Bool IsCustomized(sal_uInt16 nIndex);
GetInstance()377         static OutlineTypeMgr* GetInstance()
378         {
379              if ( _instance == 0 )
380                     {
381                         _instance = new OutlineTypeMgr(eNBOType::OUTLINE);
382                     }
383 
384                     return _instance;
385         }
386 };
387 }}
388 #endif
389 
390 /* vim: set noet sw=4 ts=4: */
391