xref: /aoo4110/main/svx/inc/svx/nbdtmg.hxx (revision b1cdbd2c)
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_VALUSET_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 
233 class SVX_DLLPUBLIC BulletsTypeMgr: public NBOTypeMgrBase
234 {
235 	friend class OutlineTypeMgr;
236 	friend class NumberingTypeMgr;
237 	public:
238 		static sal_Unicode aDynamicBulletTypes[DEFAULT_BULLET_TYPES];
239 		static sal_Unicode aDynamicRTLBulletTypes[DEFAULT_BULLET_TYPES];
240 		static BulletsSettings_Impl* pActualBullets[DEFAULT_BULLET_TYPES];
241 		static BulletsTypeMgr* _instance;
242 	public:
243 		BulletsTypeMgr(const NBOType aType);
244 		BulletsTypeMgr(const NBOType aType,const SfxItemSet* pArg);
245 		BulletsTypeMgr(const BulletsTypeMgr& aTypeMgr);
~BulletsTypeMgr()246 		virtual ~BulletsTypeMgr() {}
247 		virtual void Init();
248 		virtual sal_uInt16 GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex=0);
249 		virtual sal_Bool RelplaceNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel=(sal_uInt16)0xFFFF);
250 		virtual sal_Bool ApplyNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel=(sal_uInt16)0xFFFF,sal_Bool isDefault=false,sal_Bool isResetSize=false);
251 		virtual String GetDescription(sal_uInt16 nIndex,sal_Bool isDefault=false);
252 		virtual sal_Bool IsCustomized(sal_uInt16 nIndex);
253 		sal_Unicode GetBulChar(sal_uInt16 nIndex);
254 		Font GetBulCharFont(sal_uInt16 nIndex);
GetInstance()255 		static BulletsTypeMgr* GetInstance()
256 		{
257 			 if ( _instance == 0 )
258 	                {
259 	                    _instance = new BulletsTypeMgr(eNBOType::BULLETS);
260 	                }
261 
262 	                return _instance;
263 		}
264 
265 };
266 
267 class SVX_DLLPUBLIC GraphyicBulletsTypeMgr: public NBOTypeMgrBase
268 {
269 	friend class OutlineTypeMgr;
270 	friend class NumberingTypeMgr;
271 	public:
272 		List	aGrfDataLst;
273 		static GraphyicBulletsTypeMgr* _instance;
274 	public:
275 		GraphyicBulletsTypeMgr(const NBOType aType);
276 		GraphyicBulletsTypeMgr(const NBOType aType,const SfxItemSet* pArg);
277 		GraphyicBulletsTypeMgr(const GraphyicBulletsTypeMgr& aTypeMgr);
~GraphyicBulletsTypeMgr()278 		virtual ~GraphyicBulletsTypeMgr() {}
279 		virtual void Init();
280 		virtual sal_uInt16 GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex=0);
281 		virtual sal_Bool RelplaceNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel=(sal_uInt16)0xFFFF);
282 		virtual sal_Bool ApplyNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel=(sal_uInt16)0xFFFF,sal_Bool isDefault=false,sal_Bool isResetSize=false);
283 		virtual String GetDescription(sal_uInt16 nIndex,sal_Bool isDefault=false);
284 		virtual sal_Bool IsCustomized(sal_uInt16 nIndex);
285 		String GetGrfName(sal_uInt16 nIndex);
GetInstance()286 		static GraphyicBulletsTypeMgr* GetInstance()
287 		{
288 			 if ( _instance == 0 )
289 	                {
290 	                    _instance = new GraphyicBulletsTypeMgr(eNBOType::BULLETS);
291 	                }
292 
293 	                return _instance;
294 		}
295 
296 };
297 
298 class SVX_DLLPUBLIC MixBulletsTypeMgr: public NBOTypeMgrBase
299 {
300 	friend class OutlineTypeMgr;
301 	friend class NumberingTypeMgr;
302 	public:
303 		static MixBulletsSettings_Impl* pActualBullets[DEFAULT_BULLET_TYPES];
304 		static MixBulletsSettings_Impl* pDefaultActualBullets[DEFAULT_BULLET_TYPES];
305 		static MixBulletsTypeMgr* _instance;
306 	public:
307 		MixBulletsTypeMgr(const NBOType aType);
308 		MixBulletsTypeMgr(const NBOType aType,const SfxItemSet* pArg);
309 		MixBulletsTypeMgr(const MixBulletsTypeMgr& aTypeMgr);
~MixBulletsTypeMgr()310 		virtual ~MixBulletsTypeMgr() {}
311 		virtual void Init();
312 		virtual sal_uInt16 GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex=0);
313 		virtual sal_Bool RelplaceNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel=(sal_uInt16)0xFFFF);
314 		virtual sal_Bool ApplyNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel=(sal_uInt16)0xFFFF,sal_Bool isDefault=false,sal_Bool isResetSize=false);
315 		virtual String GetDescription(sal_uInt16 nIndex,sal_Bool isDefault=false);
316 		virtual sal_Bool IsCustomized(sal_uInt16 nIndex);
GetInstance()317 		static MixBulletsTypeMgr* GetInstance()
318 		{
319 			 if ( _instance == 0 )
320 	                {
321 	                    _instance = new MixBulletsTypeMgr(eNBOType::MIXBULLETS);
322 	                }
323 
324 	                return _instance;
325 		}
326 
327 };
328 
329 class SVX_DLLPUBLIC NumberingTypeMgr: public NBOTypeMgrBase
330 {
331 	public:
332 		//NumSettingsArr_Impl*		pNumSettingsArr;
333 		NumberSettingsArr_Impl*		pNumberSettingsArr;
334 		NumberSettingsArr_Impl*		pDefaultNumberSettingsArr;
335 		static NumberingTypeMgr* 	_instance;
336 	public:
337 		NumberingTypeMgr(const NBOType aType);
338 		NumberingTypeMgr(const NBOType aType,const SfxItemSet* pArg);
339 		NumberingTypeMgr(const NumberingTypeMgr& aTypeMgr);
~NumberingTypeMgr()340 		virtual ~NumberingTypeMgr() {}
341 		virtual void Init();
342 		virtual sal_uInt16 GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex=0);
343 		virtual sal_Bool RelplaceNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel=(sal_uInt16)0xFFFF);
344 		virtual sal_Bool ApplyNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel=(sal_uInt16)0xFFFF,sal_Bool isDefault=false,sal_Bool isResetSize=false);
345 		virtual String GetDescription(sal_uInt16 nIndex,sal_Bool isDefault=false);
346 		virtual sal_Bool IsCustomized(sal_uInt16 nIndex);
347 		sal_uInt16 GetNumCount() const;
348 		NumberSettings_Impl* GetNumSettingByIndex(sal_uInt16 nIndex) const;
GetInstance()349 		static NumberingTypeMgr* GetInstance()
350 		{
351 			 if ( _instance == 0 )
352 	                {
353 	                    _instance = new NumberingTypeMgr(eNBOType::NUMBERING);
354 	                }
355 
356 	                return _instance;
357 		}
358 };
359 
360 class SVX_DLLPUBLIC OutlineTypeMgr: public NBOTypeMgrBase
361 {
362 	public:
363 		//NumSettingsArr_Impl*		pNumSettingsArrs[DEFAULT_NUM_VALUSET_COUNT];
364 		OutlineSettings_Impl*		pOutlineSettingsArrs[DEFAULT_NUM_VALUSET_COUNT];
365 		OutlineSettings_Impl*		pDefaultOutlineSettingsArrs[DEFAULT_NUM_VALUSET_COUNT];
366 		static OutlineTypeMgr* 	_instance;
367 	public:
368 		OutlineTypeMgr(const NBOType aType);
369 		OutlineTypeMgr(const NBOType aType,const SfxItemSet* pArg);
370 		OutlineTypeMgr(const OutlineTypeMgr& aTypeMgr);
~OutlineTypeMgr()371 		virtual ~OutlineTypeMgr() {}
372 		virtual void Init();
373 		virtual sal_uInt16 GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex=0);
374 		virtual sal_Bool RelplaceNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel=(sal_uInt16)0xFFFF);
375 		virtual sal_Bool ApplyNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel=(sal_uInt16)0xFFFF,sal_Bool isDefault=false,sal_Bool isResetSize=false);
376 		virtual String GetDescription(sal_uInt16 nIndex,sal_Bool isDefault=false);
377 		virtual sal_Bool IsCustomized(sal_uInt16 nIndex);
GetInstance()378 		static OutlineTypeMgr* GetInstance()
379 		{
380 			 if ( _instance == 0 )
381 	                {
382 	                    _instance = new OutlineTypeMgr(eNBOType::OUTLINE);
383 	                }
384 
385 	                return _instance;
386 		}
387 };
388 }}
389 #endif
390 
391