xref: /aoo42x/main/svx/source/sidebar/nbdtmg.cxx (revision 49b39f76)
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 #include "precompiled_svx.hxx"
25 #ifndef _NBDTMG_HXX
26 #include <svx/nbdtmg.hxx>
27 #endif
28 #ifndef _SVX_SVXIDS_HRC
29 #include <svx/svxids.hrc>
30 #endif
31 #ifndef _SV_SVAPP_HXX
32 #include <vcl/svapp.hxx>
33 #endif
34 #ifndef _SFXITEMSET_HXX
35 #include <svl/itemset.hxx>
36 #endif
37 #ifndef _SFXREQUEST_HXX
38 #include <sfx2/request.hxx>
39 #endif
40 #ifndef _SFXSTRITEM_HXX
41 #include <svl/stritem.hxx>
42 #endif
43 #ifndef _UNO_LINGU_HXX
44 #include <editeng/unolingu.hxx>
45 #endif
46 #ifndef _CTRLTOOL_HXX
47 #include <svtools/ctrltool.hxx>
48 #endif
49 #ifndef _SFX_OBJSH_HXX
50 #include <sfx2/objsh.hxx>
51 #endif
52 #ifndef _SVX_FLSTITEM_HXX
53 #include <editeng/flstitem.hxx>
54 #endif
55 #ifndef _SFXITEMPOOL_HXX
56 #include <svl/itempool.hxx>
57 #endif
58 #ifndef _SV_OUTDEV_HXX
59 #include <vcl/outdev.hxx>
60 #endif
61 #ifndef _GALLERY_HXX_
62 #include <svx/gallery.hxx>
63 #endif
64 #ifndef _SVX_BRSHITEM_HXX
65 #include <editeng/brshitem.hxx>
66 #endif
67 #include <svx/dialmgr.hxx>
68 #ifndef _SVX_DIALOGS_HRC
69 #include <svx/dialogs.hrc>
70 #endif
71 #ifndef _SV_GRAPH_HXX
72 #include <vcl/graph.hxx>
73 #endif
74 
75 #include <unotools/streamwrap.hxx>
76 #include <unotools/ucbstreamhelper.hxx>
77 #include <unotools/pathoptions.hxx>
78 #include <editeng/eeitem.hxx>
79 
80 #include <com/sun/star/text/HoriOrientation.hpp>
81 #include <com/sun/star/text/VertOrientation.hpp>
82 #include <com/sun/star/text/RelOrientation.hpp>
83 #include <com/sun/star/style/NumberingType.hpp>
84 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
85 #include <com/sun/star/container/XIndexAccess.hpp>
86 #include <com/sun/star/text/XDefaultNumberingProvider.hpp>
87 #include <com/sun/star/text/XNumberingFormatter.hpp>
88 #include <com/sun/star/beans/PropertyValue.hpp>
89 #include <comphelper/processfactory.hxx>
90 #include <com/sun/star/text/XNumberingTypeInfo.hpp>
91 
92 using namespace com::sun::star;
93 using namespace com::sun::star::uno;
94 using namespace com::sun::star::beans;
95 using namespace com::sun::star::lang;
96 using namespace com::sun::star::text;
97 using namespace com::sun::star::container;
98 using namespace com::sun::star::style;
99 using rtl::OUString;
100 
101 namespace svx { namespace sidebar {
102 #define NUM_TYPE_MEMBER			4
103 #define NUM_VALUSET_COUNT		16
104 #define MAX_VALUESET_GRAPHIC	30
105 
106 typedef NumSettings_Impl* NumSettings_ImplPtr;
107 SV_DECL_PTRARR_DEL(NumSettingsArr_Impl,NumSettings_ImplPtr,8,4)
108 SV_IMPL_PTRARR( NumSettingsArr_Impl, NumSettings_ImplPtr )
109 
110 typedef NumberSettings_Impl* NumberSettings_ImplPtr;
111 SV_DECL_PTRARR_DEL(NumberSettingsArr_Impl,NumberSettings_ImplPtr,8,4)
SV_IMPL_PTRARR(NumberSettingsArr_Impl,NumberSettings_ImplPtr)112 SV_IMPL_PTRARR( NumberSettingsArr_Impl, NumberSettings_ImplPtr )
113 
114 Font& lcl_GetDefaultBulletFont()
115 {
116 	static sal_Bool bInit = 0;
117 	static Font aDefBulletFont( UniString::CreateFromAscii(
118 								RTL_CONSTASCII_STRINGPARAM( "StarSymbol" ) ),
119 								String(), Size( 0, 14 ) );
120 	if(!bInit)
121 	{
122 		aDefBulletFont.SetCharSet( RTL_TEXTENCODING_SYMBOL );
123 		aDefBulletFont.SetFamily( FAMILY_DONTKNOW );
124 		aDefBulletFont.SetPitch( PITCH_DONTKNOW );
125 		aDefBulletFont.SetWeight( WEIGHT_DONTKNOW );
126 		aDefBulletFont.SetTransparent( sal_True );
127 		bInit = sal_True;
128 	}
129 	return aDefBulletFont;
130 }
131 
132 static const sal_Unicode aDefaultBulletTypes[] =
133 {
134 	0x2022,
135 	0x25cf,
136 	0xe00c,
137 	0xe00a,
138 	0x2794,
139 	0x27a2,
140 	0x2717,
141 	0x2714
142 };
143 
144 static const sal_Unicode aDefaultRTLBulletTypes[] =
145 {
146 	0x2022,
147 	0x25cf,
148 	0xe00c,
149 	0xe00a,
150 	0x25c4,
151 	0x272b,
152 	0x2717,
153 	0x2714
154 };
155 
156 static const sal_Char sNumberingType[] = "NumberingType";
157 static const sal_Char sValue[] = "Value";
158 static const sal_Char sParentNumbering[] = "ParentNumbering";
159 static const sal_Char sPrefix[] = "Prefix";
160 static const sal_Char sSuffix[] = "Suffix";
161 static const sal_Char sBulletChar[] = "BulletChar";
162 static const sal_Char sBulletFontName[] = "BulletFontName";
163 
lcl_CreateNumberingSettingsPtr(const Sequence<PropertyValue> & rLevelProps)164 NumSettings_ImplPtr lcl_CreateNumberingSettingsPtr(const Sequence<PropertyValue>& rLevelProps)
165 {
166 	const PropertyValue* pValues = rLevelProps.getConstArray();
167 	NumSettings_ImplPtr pNew = new NumSettings_Impl;
168 	for(sal_Int32 j = 0; j < rLevelProps.getLength(); j++)
169 	{
170 		if(pValues[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sNumberingType)))
171 			pValues[j].Value >>= pNew->nNumberType;
172 		else if(pValues[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sPrefix)))
173 			pValues[j].Value >>= pNew->sPrefix;
174 		else if(pValues[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sSuffix)))
175 			pValues[j].Value >>= pNew->sSuffix;
176 		else if(pValues[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sParentNumbering)))
177 			pValues[j].Value >>= pNew->nParentNumbering;
178 		else if(pValues[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sBulletChar)))
179 			pValues[j].Value >>= pNew->sBulletChar;
180 		else if(pValues[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sBulletFontName)))
181 			pValues[j].Value >>= pNew->sBulletFont;
182 	}
183 	const sal_Unicode cLocalPrefix = pNew->sPrefix.getLength() ? pNew->sPrefix.getStr()[0] : 0;
184 	const sal_Unicode cLocalSuffix = pNew->sSuffix.getLength() ? pNew->sSuffix.getStr()[0] : 0;
185 	String aEmptyStr;
186 	if( cLocalPrefix == ' ') pNew->sPrefix=aEmptyStr;
187 	if( cLocalSuffix == ' ') pNew->sSuffix=aEmptyStr;
188 	return pNew;
189 }
190 
IsSingleLevel(sal_uInt16 nCurLevel)191 sal_uInt16 NBOTypeMgrBase:: IsSingleLevel(sal_uInt16 nCurLevel)
192 {
193 	sal_uInt16 nLv = (sal_uInt16)0xFFFF;
194 	sal_uInt16 nCount = 0;
195 	sal_uInt16 nMask = 1;
196 	for( sal_uInt16 i = 0; i < SVX_MAX_NUM; i++ )
197 	{
198 		if(nCurLevel & nMask)
199 		{
200 			nCount++;
201 			nLv=i;
202 		}
203 		nMask <<= 1 ;
204 	}
205 
206 	if ( nCount == 1)
207 		return nLv;
208 	else
209 		return (sal_uInt16)0xFFFF;
210 }
211 
StoreBulCharFmtName_impl()212 void NBOTypeMgrBase::StoreBulCharFmtName_impl() {
213 		if ( pSet )
214 		{
215 			SfxAllItemSet aSet(*pSet);
216 			SFX_ITEMSET_ARG(&aSet,pBulletCharFmt,SfxStringItem,SID_BULLET_CHAR_FMT,sal_False);
217 
218 			if ( pBulletCharFmt )
219 			{
220 				aNumCharFmtName = String(pBulletCharFmt->GetValue());
221 			}
222 		}
223 }
GetBulCharFmtName()224 String NBOTypeMgrBase::GetBulCharFmtName()
225 {
226 	return aNumCharFmtName;
227 }
ImplLoad(String filename)228 void NBOTypeMgrBase::ImplLoad(String filename)
229 {
230 	bIsLoading = true;
231 	SfxMapUnit		eOldCoreUnit=eCoreUnit;
232 	eCoreUnit = SFX_MAPUNIT_100TH_MM;
233 	INetURLObject aFile( SvtPathOptions().GetPalettePath() );
234 	aFile.Append( filename);
235 	SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( aFile.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
236 	if( pIStm ) {
237 		sal_uInt32	nVersion;
238 		sal_Int32	nNumIndex;
239 		*pIStm >> nVersion;
240 		if (nVersion==DEFAULT_NUMBERING_CACHE_FORMAT_VERSION) // first version
241 		{
242 			*pIStm >> nNumIndex;
243 			sal_uInt16 mLevel = 0x1;
244 			while (nNumIndex>=0 && nNumIndex<DEFAULT_NUM_VALUSET_COUNT) {
245 				SvxNumRule aNum(*pIStm);
246 				// bullet color in font properties is not stored correctly. Need set transparency bits manually
247 				for(sal_uInt16 i = 0; i < aNum.GetLevelCount(); i++)
248 				{
249 					SvxNumberFormat aFmt(aNum.GetLevel(i));
250 					if (aFmt.GetBulletFont()) {
251 						Font aFont(*aFmt.GetBulletFont());
252 						Color c=aFont.GetColor();
253 						c.SetTransparency(0xFF);
254 						aFont.SetColor(c);
255 						aFmt.SetBulletFont(&aFont);
256 						aNum.SetLevel(i, aFmt);
257 					}
258 				}
259 				RelplaceNumRule(aNum,nNumIndex,mLevel);
260 				*pIStm >> nNumIndex;
261 			}
262 			delete pIStm;
263 		}
264 	}
265 	eCoreUnit = eOldCoreUnit;
266 	bIsLoading = false;
267 }
ImplStore(String filename)268 void NBOTypeMgrBase::ImplStore(String filename)
269 {
270 	if (bIsLoading) return;
271 	SfxMapUnit		eOldCoreUnit=eCoreUnit;
272 	eCoreUnit = SFX_MAPUNIT_100TH_MM;
273 	INetURLObject aFile( SvtPathOptions().GetPalettePath() );
274 	aFile.Append( filename);
275 	SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( aFile.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE );
276 	if( pOStm ) {
277 		sal_uInt32	nVersion;
278 		sal_Int32	nNumIndex;
279 		nVersion = DEFAULT_NUMBERING_CACHE_FORMAT_VERSION;
280 		*pOStm << nVersion;
281 		for(sal_Int32 nItem = 0; nItem < DEFAULT_NUM_VALUSET_COUNT; nItem++ ) {
282 			if (IsCustomized(nItem)) {
283 				SvxNumRule aDefNumRule( NUM_BULLET_REL_SIZE|NUM_CONTINUOUS|NUM_BULLET_COLOR|NUM_CHAR_TEXT_DISTANCE|NUM_SYMBOL_ALIGNMENT,10, sal_False ,
284 					SVX_RULETYPE_NUMBERING,SvxNumberFormat::LABEL_ALIGNMENT);
285 				sal_uInt16 mLevel = 0x1;
286 				*pOStm << nItem;
287 				ApplyNumRule(aDefNumRule,nItem,mLevel,false,true);
288 				aDefNumRule.Store(*pOStm);
289 			}
290 		}
291 		nNumIndex = -1;
292 		*pOStm << nNumIndex; // write end flag
293 		delete pOStm;
294 	}
295 	eCoreUnit = eOldCoreUnit;
296 }
297 
StoreMapUnit_impl()298 void NBOTypeMgrBase::StoreMapUnit_impl() {
299 	if ( pSet )
300 	{
301 		const SfxPoolItem* pItem;
302 		SfxItemState eState = pSet->GetItemState(SID_ATTR_NUMBERING_RULE, sal_False, &pItem);
303 		if(eState == SFX_ITEM_SET)
304 		{
305 			eCoreUnit = pSet->GetPool()->GetMetric(pSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE));
306 		} else {
307 			// sd use different sid for numbering rule
308 			eState = pSet->GetItemState(EE_PARA_NUMBULLET, sal_False, &pItem);
309 			if(eState == SFX_ITEM_SET)
310 			{
311 				eCoreUnit = pSet->GetPool()->GetMetric(pSet->GetPool()->GetWhich(EE_PARA_NUMBULLET));
312 			}
313 		}
314 	}
315 }
GetMapUnit()316 SfxMapUnit NBOTypeMgrBase::GetMapUnit()
317 {
318 	return eCoreUnit;
319 }
320 /***************************************************************************************************
321 **********************Character Bullet Type lib**********************************************************
322 ****************************************************************************************************/
323 BulletsTypeMgr* BulletsTypeMgr::_instance = 0;
324 BulletsSettings_Impl* BulletsTypeMgr::pActualBullets[] ={0,0,0,0,0,0,0,0};
325 sal_Unicode BulletsTypeMgr::aDynamicBulletTypes[]={' ',' ',' ',' ',' ',' ',' ',' '};
326 sal_Unicode BulletsTypeMgr::aDynamicRTLBulletTypes[]={' ',' ',' ',' ',' ',' ',' ',' '};
327 
BulletsTypeMgr(const NBOType aType)328 BulletsTypeMgr::BulletsTypeMgr(const NBOType aType):
329 	NBOTypeMgrBase(aType)
330 {
331 	Init();
332 }
333 
BulletsTypeMgr(const NBOType aType,const SfxItemSet * pArg)334 BulletsTypeMgr::BulletsTypeMgr(const NBOType aType,const SfxItemSet* pArg):
335 	NBOTypeMgrBase(aType,pArg)
336 {
337 	Init();
338 }
339 
BulletsTypeMgr(const BulletsTypeMgr & aTypeMgr)340 BulletsTypeMgr::BulletsTypeMgr(const BulletsTypeMgr& aTypeMgr):
341 	NBOTypeMgrBase(aTypeMgr)
342 {
343 	for (sal_uInt16 i=0;i<DEFAULT_BULLET_TYPES;i++)
344 	{
345 		pActualBullets[i]->bIsCustomized = aTypeMgr.pActualBullets[i]->bIsCustomized;
346 		pActualBullets[i]->cBulletChar = aTypeMgr.pActualBullets[i]->cBulletChar;
347 		pActualBullets[i]->aFont = aTypeMgr.pActualBullets[i]->aFont;
348 		pActualBullets[i]->sDescription = aTypeMgr. pActualBullets[i]->sDescription;
349 		pActualBullets[i]->eType = aTypeMgr. pActualBullets[i]->eType;
350 	}
351 }
Init()352 void BulletsTypeMgr::Init()
353 {
354 	Font& rActBulletFont = lcl_GetDefaultBulletFont();
355 	String sName = rActBulletFont.GetName();
356 	if( Application::GetSettings().GetLayoutRTL() )
357 	{
358 		for (sal_uInt16 i=0;i<DEFAULT_BULLET_TYPES;i++)
359 		{
360 			pActualBullets[i] = new BulletsSettings_Impl(eNBType::BULLETS);
361 			pActualBullets[i]->cBulletChar = aDefaultRTLBulletTypes[i];
362 			pActualBullets[i]->aFont = rActBulletFont;
363 			if (i==4 || i==5)
364 				pActualBullets[i]->sDescription = SVX_RESSTR( RID_SVXSTR_BULLET_RTL_DESCRIPTION_4 - 4 + i );
365 			else
366 				pActualBullets[i]->sDescription = SVX_RESSTR( RID_SVXSTR_BULLET_DESCRIPTION_0 + i );
367 		}
368 	}else
369 	{
370 		for (sal_uInt16 i=0;i<DEFAULT_BULLET_TYPES;i++)
371 		{
372 			pActualBullets[i] = new BulletsSettings_Impl(eNBType::BULLETS);
373 			pActualBullets[i]->cBulletChar = aDefaultBulletTypes[i];
374 			pActualBullets[i]->aFont =rActBulletFont;
375 			pActualBullets[i]->sDescription = SVX_RESSTR( RID_SVXSTR_BULLET_DESCRIPTION_0 + i );
376 		}
377 	}
378 }
GetNBOIndexForNumRule(SvxNumRule & aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex)379 sal_uInt16 BulletsTypeMgr::GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex)
380 {
381 	if ( mLevel == (sal_uInt16)0xFFFF || mLevel == 0)
382 		return (sal_uInt16)0xFFFF;
383 	//if ( !lcl_IsNumFmtSet(pNR, mLevel) ) return (sal_uInt16)0xFFFF;
384 
385 	sal_uInt16 nActLv = IsSingleLevel(mLevel);
386 
387 	if ( nActLv == (sal_uInt16)0xFFFF )
388 		return (sal_uInt16)0xFFFF;
389 
390 	SvxNumberFormat aFmt(aNum.GetLevel(nActLv));
391 	sal_Unicode cChar = aFmt.GetBulletChar();
392 	//sal_uInt16 nLength = 0;
393 	/*if( Application::GetSettings().GetLayoutRTL() )
394 	{
395 		nLength = sizeof(aDynamicRTLBulletTypes)/sizeof(sal_Unicode);
396 		for(sal_uInt16 i = 0; i < nLength; i++)
397 		{
398 			if ( cChar == aDynamicRTLBulletTypes[i] ||
399 				(cChar == 9830 && 57356 == aDynamicRTLBulletTypes[i]) ||
400 				(cChar == 9632 && 57354 == aDynamicRTLBulletTypes[i]) )
401 			{
402 				return i+1;
403 			}
404 		}
405 	} else
406 	{
407 		nLength = sizeof(aDynamicBulletTypes)/sizeof(sal_Unicode);
408 		for(sal_uInt16 i = 0; i < nLength; i++)
409 		{
410 			if ( cChar == aDynamicBulletTypes[i] ||
411 				(cChar == 9830 && 57356 == aDynamicBulletTypes[i]) ||
412 				(cChar == 9632 && 57354 == aDynamicBulletTypes[i]) )
413 			{
414 				return i+1;
415 			}
416 		}
417 	}*/
418 	//nLength = sizeof(pActualBullets)/sizeof(BulletsSettings_Impl);
419 	for(sal_uInt16 i = nFromIndex; i < DEFAULT_BULLET_TYPES; i++)
420 	{
421 		if ( (cChar == pActualBullets[i]->cBulletChar||
422 			(cChar == 9830 && 57356 == pActualBullets[i]->cBulletChar) ||
423 			(cChar == 9632 && 57354 == pActualBullets[i]->cBulletChar)))// && pFont && (pFont->GetName().CompareTo(pActualBullets[i]->aFont.GetName())==COMPARE_EQUAL))
424 		{
425 			return i+1;
426 		}
427 	}
428 
429 	return (sal_uInt16)0xFFFF;
430 }
431 
RelplaceNumRule(SvxNumRule & aNum,sal_uInt16 nIndex,sal_uInt16 mLevel)432 sal_Bool BulletsTypeMgr::RelplaceNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel)
433 {
434 	if ( mLevel == (sal_uInt16)0xFFFF || mLevel == 0)
435 		return sal_False;
436 
437 	if ( GetNBOIndexForNumRule(aNum,mLevel) != (sal_uInt16)0xFFFF )
438 		return sal_False;
439 
440 	sal_uInt16 nActLv = IsSingleLevel(mLevel);
441 
442 	if ( nActLv == (sal_uInt16)0xFFFF )
443 		return sal_False;
444 
445 	SvxNumberFormat aFmt(aNum.GetLevel(nActLv));
446 	sal_Unicode cChar = aFmt.GetBulletChar();
447 	const Font* pFont = aFmt.GetBulletFont();
448 	//sal_uInt16 nLength = 0;
449 	/*if( Application::GetSettings().GetLayoutRTL() )
450 	{
451 		nLength = sizeof(aDynamicRTLBulletTypes)/sizeof(sal_Unicode);
452 
453 		if ( nIndex >= nLength )
454 			return sal_False;
455 
456 		aDynamicRTLBulletTypes[nIndex] = cChar;
457 	} else
458 	{
459 		nLength = sizeof(aDynamicBulletTypes)/sizeof(sal_Unicode);
460 
461 		if ( nIndex >= nLength )
462 			return sal_False;
463 
464 		aDynamicBulletTypes[nIndex] = cChar;
465 	}*/
466 	//nLength = sizeof(pActualBullets)/sizeof(BulletsSettings_Impl);
467 	if ( nIndex >= DEFAULT_BULLET_TYPES )
468 		return sal_False;
469 
470 	pActualBullets[nIndex]->cBulletChar = cChar;
471 	if ( pFont )
472 		pActualBullets[nIndex]->aFont = *pFont;
473 	pActualBullets[nIndex]->bIsCustomized = sal_True;
474 
475 	String aStrFromRES = String(SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_BULLET_DESCRIPTION));
476 	String aReplace = String::CreateFromAscii("%LIST_NUM");
477 	String sNUM = String::CreateFromInt32( nIndex + 1 );
478 	aStrFromRES.SearchAndReplace(aReplace,sNUM);
479 	pActualBullets[nIndex]->sDescription = aStrFromRES;
480 
481 	return sal_True;
482 }
483 
ApplyNumRule(SvxNumRule & aNum,sal_uInt16 nIndex,sal_uInt16 mLevel,sal_Bool,sal_Bool isResetSize)484 sal_Bool BulletsTypeMgr::ApplyNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel,sal_Bool /* isDefault */,sal_Bool isResetSize)
485 {
486 	//if ( mLevel == (sal_uInt16)0xFFFF )
487 	//	return sal_False;
488 
489 	sal_Unicode cChar;
490 	//sal_uInt16 nLength = 0;
491 	/*if( Application::GetSettings().GetLayoutRTL() )
492 	{
493 		nLength = sizeof(aDynamicRTLBulletTypes)/sizeof(sal_Unicode);
494 
495 		if ( nIndex >= nLength )
496 			return sal_False;
497 
498 		cChar = aDynamicRTLBulletTypes[nIndex];
499 	}else
500 	{
501 		nLength = sizeof(aDynamicBulletTypes)/sizeof(sal_Unicode);
502 
503 		if ( nIndex >= nLength )
504 			return sal_False;
505 
506 		cChar = aDynamicBulletTypes[nIndex];
507 	}*/
508 	//nLength = sizeof(pActualBullets)/sizeof(BulletsSettings_Impl);
509 	if ( nIndex >= DEFAULT_BULLET_TYPES )
510 		return sal_False;
511 	cChar = pActualBullets[nIndex]->cBulletChar;
512 	//Font& rActBulletFont = lcl_GetDefaultBulletFont();
513 	Font rActBulletFont = pActualBullets[nIndex]->aFont;
514 
515 	sal_uInt16 nMask = 1;
516 	String sBulletCharFmtName = GetBulCharFmtName();
517 	for(sal_uInt16 i = 0; i < aNum.GetLevelCount(); i++)
518 	{
519 		if(mLevel & nMask)
520 		{
521 			SvxNumberFormat aFmt(aNum.GetLevel(i));
522 			aFmt.SetNumberingType( SVX_NUM_CHAR_SPECIAL );
523 			aFmt.SetBulletFont(&rActBulletFont);
524 			aFmt.SetBulletChar(cChar );
525 			aFmt.SetCharFmtName(sBulletCharFmtName);
526 			if (isResetSize) aFmt.SetBulletRelSize(45);
527 			aNum.SetLevel(i, aFmt);
528 		}
529 		nMask <<= 1;
530 	}
531 
532 	return sal_True;
533 }
534 
GetDescription(sal_uInt16 nIndex,sal_Bool)535 String BulletsTypeMgr::GetDescription(sal_uInt16 nIndex,sal_Bool /* isDefault */)
536 {
537 	String sRet;
538 	//sal_uInt16 nLength = 0;
539 	//nLength = sizeof(pActualBullets)/sizeof(BulletsSettings_Impl);
540 
541 	if ( nIndex >= DEFAULT_BULLET_TYPES )
542 		return sRet;
543 	else
544 		sRet = pActualBullets[nIndex]->sDescription;
545 
546 	return sRet;
547 }
IsCustomized(sal_uInt16 nIndex)548 sal_Bool BulletsTypeMgr::IsCustomized(sal_uInt16 nIndex)
549 {
550 	sal_Bool bRet = sal_False;
551 	//sal_uInt16 nLength = 0;
552 	//nLength = sizeof(pActualBullets)/sizeof(BulletsSettings_Impl);
553 
554 	if ( nIndex >= DEFAULT_BULLET_TYPES )
555 		bRet = sal_False;
556 	else
557 		bRet = pActualBullets[nIndex]->bIsCustomized;
558 
559 	return bRet;
560 }
561 
GetBulChar(sal_uInt16 nIndex)562 sal_Unicode BulletsTypeMgr::GetBulChar(sal_uInt16 nIndex)
563 {
564 	sal_Unicode cChar;
565 	//sal_uInt16 nLength = 0;
566 	//nLength = sizeof(pActualBullets)/sizeof(BulletsSettings_Impl);
567 
568 	if ( nIndex >= DEFAULT_BULLET_TYPES )
569 		cChar = ' ';
570 	else
571 		cChar = pActualBullets[nIndex]->cBulletChar;
572 
573 	/*if( Application::GetSettings().GetLayoutRTL() )
574 	{
575 		nLength = sizeof(aDynamicRTLBulletTypes)/sizeof(sal_Unicode);
576 
577 		if ( nIndex >= nLength )
578 			cChar = ' ';
579 		else
580 			cChar = aDynamicRTLBulletTypes[nIndex];
581 	}else
582 	{
583 		nLength = sizeof(aDynamicBulletTypes)/sizeof(sal_Unicode);
584 
585 		if ( nIndex >= nLength )
586 			cChar = ' ';
587 		else
588 			cChar = aDynamicBulletTypes[nIndex];
589 	}*/
590 
591 	return cChar;
592 }
GetBulCharFont(sal_uInt16 nIndex)593 Font BulletsTypeMgr::GetBulCharFont(sal_uInt16 nIndex)
594 {
595 	Font aRet;
596 	if ( nIndex >= DEFAULT_BULLET_TYPES )
597 		aRet = lcl_GetDefaultBulletFont();
598 	else
599 		aRet = pActualBullets[nIndex]->aFont;
600 
601 	return aRet;
602 }
603 /***************************************************************************************************
604 **********************Graphic Bullet Type lib***********************************************************
605 ****************************************************************************************************/
606 GraphicBulletsTypeMgr* GraphicBulletsTypeMgr::_instance = 0;
GraphicBulletsTypeMgr(const NBOType aType)607 GraphicBulletsTypeMgr::GraphicBulletsTypeMgr(const NBOType aType):
608 	NBOTypeMgrBase(aType)
609 {
610 	Init();
611 }
612 
GraphicBulletsTypeMgr(const NBOType aType,const SfxItemSet * pArg)613 GraphicBulletsTypeMgr::GraphicBulletsTypeMgr(const NBOType aType,const SfxItemSet* pArg):
614 	NBOTypeMgrBase(aType,pArg)
615 {
616 	Init();
617 }
GraphicBulletsTypeMgr(const GraphicBulletsTypeMgr & aTypeMgr)618 GraphicBulletsTypeMgr::GraphicBulletsTypeMgr(const GraphicBulletsTypeMgr& aTypeMgr):
619 	NBOTypeMgrBase(aTypeMgr)
620 {
621 	for (sal_uInt16 i=0;i< aTypeMgr.aGrfDataLst.Count();i++)
622 	{
623 		GrfBulDataRelation* pEntry = new GrfBulDataRelation(eNBType::GRAPHICBULLETS);
624 		GrfBulDataRelation* pSrcEntry = (GrfBulDataRelation*)(aTypeMgr.aGrfDataLst.GetObject(i));
625 		if ( pEntry && pSrcEntry)
626 		{
627 			pEntry->bIsCustomized = pSrcEntry->bIsCustomized;
628 			pEntry->nTabIndex = pSrcEntry->nTabIndex;
629 			pEntry->nGallaryIndex = pSrcEntry->nGallaryIndex;
630 			pEntry->sGrfName = pSrcEntry->sGrfName;
631 			pEntry->sDescription = pSrcEntry->sDescription;
632 			aGrfDataLst.Insert( pEntry, LIST_APPEND );
633 		}
634 		else
635 			delete pEntry;
636 	}
637 }
Init()638 void GraphicBulletsTypeMgr::Init()
639 {
640 	List aGrfNames;
641 	GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS, aGrfNames);
642 	for(sal_uInt16 i = 0; i < aGrfNames.Count(); i++)
643 	{
644 		String* pGrfNm = (String*) aGrfNames.GetObject(i);
645 			INetURLObject aObj(*pGrfNm);
646 			if(aObj.GetProtocol() == INET_PROT_FILE)
647 					*pGrfNm = aObj.PathToFileName();
648 
649 		GrfBulDataRelation* pEntry = new GrfBulDataRelation(eNBType::GRAPHICBULLETS);
650 		pEntry->nTabIndex = i+1;
651 		pEntry->nGallaryIndex = i;
652 		pEntry->sGrfName = *pGrfNm;
653 
654 		if( i < MAX_VALUESET_GRAPHIC )
655 		{
656 			pEntry->sDescription = SVX_RESSTR( RID_SVXSTR_GRAPHICS_DESCRIPTIONS + i );
657 		}else
658 		{
659 			pEntry->sDescription = *pGrfNm;
660 		}
661 
662 		aGrfDataLst.Insert( pEntry, LIST_APPEND );
663 	}
664 }
GetNBOIndexForNumRule(SvxNumRule & aNum,sal_uInt16 mLevel,sal_uInt16)665 sal_uInt16 GraphicBulletsTypeMgr::GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 /* nFromIndex */)
666 {
667 	if ( mLevel == (sal_uInt16)0xFFFF || mLevel == 0)
668 		return (sal_uInt16)0xFFFF;
669 
670 	sal_uInt16 nActLv = IsSingleLevel(mLevel);
671 
672 	if ( nActLv == (sal_uInt16)0xFFFF )
673 		return (sal_uInt16)0xFFFF;
674 
675 	SvxNumberFormat aFmt(aNum.GetLevel(nActLv));
676 	const SvxBrushItem* pBrsh = aFmt.GetBrush();
677 	const Graphic* pGrf = 0;
678 	if ( pBrsh )
679 		pGrf = pBrsh->GetGraphic();
680 
681 	if ( pGrf )
682 	{
683 		Graphic aGraphic;
684 		for(sal_uInt16 i=0;i<aGrfDataLst.Count();i++)
685 		{
686 			GrfBulDataRelation* pEntry = (GrfBulDataRelation*) aGrfDataLst.GetObject(i);
687 			sal_Bool bExist = sal_False;
688 			if ( pEntry) // && pEntry->sGrfName.CompareTo(*pGrfName)==COMPARE_EQUAL )
689 				bExist = GalleryExplorer::GetGraphicObj(GALLERY_THEME_BULLETS, pEntry->nGallaryIndex,&aGraphic);
690 			if (bExist) {
691 				Bitmap aSum=pGrf->GetBitmap();
692 				Bitmap aSum1=aGraphic.GetBitmap();
693 				if (aSum.IsEqual(aSum1))
694 				return pEntry->nTabIndex;
695 			}
696 		}
697 	}
698 
699 	return (sal_uInt16)0xFFFF;
700 }
701 
RelplaceNumRule(SvxNumRule & aNum,sal_uInt16 nIndex,sal_uInt16 mLevel)702 sal_Bool GraphicBulletsTypeMgr::RelplaceNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel)
703 {
704 	if ( mLevel == (sal_uInt16)0xFFFF || mLevel > aNum.GetLevelCount() || mLevel == 0)
705 		return sal_False;
706 
707 	if ( GetNBOIndexForNumRule(aNum,mLevel) != (sal_uInt16)0xFFFF )
708 		return sal_False;
709 
710 	if ( nIndex >= aGrfDataLst.Count() )
711 		return sal_False;
712 
713 	sal_uInt16 nActLv = IsSingleLevel(mLevel);
714 	if ( nActLv == (sal_uInt16)0xFFFF )
715 		return sal_False;
716 
717 	SvxNumberFormat aFmt(aNum.GetLevel(nActLv));
718 	const SvxBrushItem* pBrsh = aFmt.GetBrush();
719 	const Graphic* pGrf = 0;
720 	if ( pBrsh )
721 		pGrf = pBrsh->GetGraphic();
722 	else
723 		return sal_False;
724 
725 	String sEmpty;
726 	if ( pGrf )
727 	{
728 		const String* pGrfName = pBrsh->GetGraphicLink();
729 		//String* pGrfName = (String*)(pBrsh->GetGraphicLink());
730 		GrfBulDataRelation* pEntry = (GrfBulDataRelation*) aGrfDataLst.GetObject(nIndex);
731 		if ( pGrfName )
732 			pEntry->sGrfName = *pGrfName;
733 		//pEntry->sDescription = sEmpty;
734 		pEntry->nGallaryIndex = (sal_uInt16)0xFFFF;
735 		pEntry->bIsCustomized = sal_True;
736 		String aStrFromRES = String(SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_BULLET_DESCRIPTION));
737 		String aReplace = String::CreateFromAscii("%LIST_NUM");
738 		String sNUM = String::CreateFromInt32( nIndex + 1 );
739 		aStrFromRES.SearchAndReplace(aReplace,sNUM);
740 		pEntry->sDescription = aStrFromRES;
741 	}else
742 	{
743 		return sal_False;
744 	}
745 
746 	return sal_True;
747 }
748 
ApplyNumRule(SvxNumRule & aNum,sal_uInt16 nIndex,sal_uInt16 mLevel,sal_Bool,sal_Bool)749 sal_Bool GraphicBulletsTypeMgr::ApplyNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel,sal_Bool /* isDefault */,sal_Bool /* isResetSize */)
750 {
751 	//if ( mLevel == (sal_uInt16)0xFFFF )
752 	//	return sal_False;
753 
754 	if ( nIndex >= aGrfDataLst.Count() )
755 		return sal_False;
756 
757 	String sGrfName;
758 	GrfBulDataRelation* pEntry = (GrfBulDataRelation*) aGrfDataLst.GetObject(nIndex);
759 	sGrfName= pEntry->sGrfName;
760 
761 	sal_uInt16 nMask = 1;
762 	String aEmptyStr;
763 	sal_uInt16 nSetNumberingType = SVX_NUM_BITMAP;
764 	String sNumCharFmtName = GetBulCharFmtName();
765 	for(sal_uInt16 i = 0; i < aNum.GetLevelCount(); i++)
766 	{
767 		if(mLevel & nMask)
768 		{
769 			SvxNumberFormat aFmt(aNum.GetLevel(i));
770 			aFmt.SetNumberingType(nSetNumberingType);
771 			aFmt.SetPrefix( aEmptyStr );
772 			aFmt.SetSuffix( aEmptyStr );
773 			aFmt.SetCharFmtName( sNumCharFmtName );
774 
775 			Graphic aGraphic;
776 			if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, pEntry->nGallaryIndex, &aGraphic))
777 			{
778 				Size aSize = SvxNumberFormat::GetGraphicSizeMM100(&aGraphic);
779 				sal_Int16 eOrient = text::VertOrientation::LINE_CENTER;
780 				aSize = OutputDevice::LogicToLogic(aSize, MAP_100TH_MM, (MapUnit)GetMapUnit());
781 				SvxBrushItem aBrush(aGraphic, GPOS_AREA, SID_ATTR_BRUSH );
782 				aFmt.SetGraphicBrush( &aBrush, &aSize, &eOrient );
783 			}
784 			else // if(pGrfName)
785 				aFmt.SetGraphic( sGrfName );
786 
787 			aNum.SetLevel(i, aFmt);
788 		}
789 		nMask <<= 1 ;
790 	}
791 
792 	return sal_True;
793 }
GetDescription(sal_uInt16 nIndex,sal_Bool)794 String GraphicBulletsTypeMgr::GetDescription(sal_uInt16 nIndex,sal_Bool /* isDefault */)
795 {
796 	String sRet;
797 	sal_uInt16 nLength = 0;
798 	nLength = aGrfDataLst.Count() ;
799 
800 	if ( nIndex >= nLength )
801 		return sRet;
802 	else
803 	{
804 		GrfBulDataRelation* pEntry = (GrfBulDataRelation*) aGrfDataLst.GetObject(nIndex);
805 		if ( pEntry )
806 		{
807 			sRet = pEntry->sDescription;
808 		};
809 	}
810 	return sRet;
811 }
IsCustomized(sal_uInt16 nIndex)812 sal_Bool GraphicBulletsTypeMgr::IsCustomized(sal_uInt16 nIndex)
813 {
814 	sal_Bool bRet = sal_False;
815 
816 	sal_uInt16 nLength = 0;
817 	nLength = aGrfDataLst.Count() ;
818 
819 	if ( nIndex >= nLength )
820 		return bRet;
821 	else
822 	{
823 		GrfBulDataRelation* pEntry = (GrfBulDataRelation*) aGrfDataLst.GetObject(nIndex);
824 		if ( pEntry )
825 		{
826 			bRet = pEntry->bIsCustomized;
827 		};
828 	}
829 
830 	return bRet;
831 }
GetGrfName(sal_uInt16 nIndex)832 String GraphicBulletsTypeMgr::GetGrfName(sal_uInt16 nIndex)
833 {
834 	String sRet;
835 	if ( nIndex < aGrfDataLst.Count() )
836 	{
837 		GrfBulDataRelation* pEntry = (GrfBulDataRelation*) aGrfDataLst.GetObject(nIndex);
838 		if ( pEntry )
839 		{
840 			sRet = pEntry->sGrfName;
841 		}
842 	}
843 
844 	return sRet;
845 }
846 /***************************************************************************************************
847 **********************Mix Bullets Type lib**************************************************************
848 ****************************************************************************************************/
849 MixBulletsTypeMgr* MixBulletsTypeMgr::_instance = 0;
850 MixBulletsSettings_Impl* MixBulletsTypeMgr::pActualBullets[] ={0,0,0,0,0,0,0,0};
851 MixBulletsSettings_Impl* MixBulletsTypeMgr::pDefaultActualBullets[] ={0,0,0,0,0,0,0,0};
852 
MixBulletsTypeMgr(const NBOType aType)853 MixBulletsTypeMgr::MixBulletsTypeMgr(const NBOType aType):
854 	NBOTypeMgrBase(aType)
855 {
856 	Init();
857 	for(sal_Int32 nItem = 0; nItem < DEFAULT_BULLET_TYPES; nItem++ )
858 	{
859 		pDefaultActualBullets[nItem] = pActualBullets[nItem];
860 	}
861 	// Initialize the first time to store the default value. Then do it again for customized value
862 	Init();
863 	ImplLoad(String::CreateFromAscii("standard.sya"));
864 }
865 
MixBulletsTypeMgr(const NBOType aType,const SfxItemSet * pArg)866 MixBulletsTypeMgr::MixBulletsTypeMgr(const NBOType aType,const SfxItemSet* pArg):
867 	NBOTypeMgrBase(aType,pArg)
868 {
869 	Init();
870 	for(sal_Int32 nItem = 0; nItem < DEFAULT_BULLET_TYPES; nItem++ )
871 	{
872 		pDefaultActualBullets[nItem] = pActualBullets[nItem];
873 	}
874 	// Initialize the first time to store the default value. Then do it again for customized value
875 	Init();
876 	ImplLoad(String::CreateFromAscii("standard.sya"));
877 }
878 
MixBulletsTypeMgr(const MixBulletsTypeMgr & aTypeMgr)879 MixBulletsTypeMgr::MixBulletsTypeMgr(const MixBulletsTypeMgr& aTypeMgr):
880 	NBOTypeMgrBase(aTypeMgr)
881 {
882 	for (sal_uInt16 i=0;i<DEFAULT_BULLET_TYPES;i++)
883 	{
884 		if ( aTypeMgr.pActualBullets[i]->eType == eNBType::BULLETS )
885 		{
886 			pActualBullets[i]->eType = aTypeMgr.pActualBullets[i]->eType;
887 			pActualBullets[i]->nIndex = aTypeMgr.pActualBullets[i]->nIndex; // Index in the tab page display
888 			pActualBullets[i]->nIndexDefault = aTypeMgr.pActualBullets[i]->nIndexDefault;
889 			pActualBullets[i]->pBullets = new BulletsSettings_Impl(eNBType::BULLETS) ;
890 			((BulletsSettings_Impl*)(pActualBullets[i]->pBullets))->cBulletChar = ((BulletsSettings_Impl*)(aTypeMgr.pActualBullets[i]->pBullets))->cBulletChar;
891 			((BulletsSettings_Impl*)(pActualBullets[i]->pBullets))->aFont = ((BulletsSettings_Impl*)(aTypeMgr.pActualBullets[i]->pBullets))->aFont;
892 			((BulletsSettings_Impl*)(pActualBullets[i]->pBullets))->sDescription = ((BulletsSettings_Impl*)(aTypeMgr.pActualBullets[i]->pBullets))->sDescription;
893 			((BulletsSettings_Impl*)(pActualBullets[i]->pBullets))->bIsCustomized = ((BulletsSettings_Impl*)(aTypeMgr.pActualBullets[i]->pBullets))->bIsCustomized;
894 			((BulletsSettings_Impl*)(pActualBullets[i]->pBullets))->eType = ((BulletsSettings_Impl*)(aTypeMgr.pActualBullets[i]->pBullets))->eType;
895 		}else if ( aTypeMgr.pActualBullets[i]->eType == eNBType::GRAPHICBULLETS )
896 		{
897 			pActualBullets[i]->eType = aTypeMgr.pActualBullets[i]->eType;
898 			pActualBullets[i]->nIndex = aTypeMgr.pActualBullets[i]->nIndex; // Index in the tab page display
899 			pActualBullets[i]->nIndexDefault = aTypeMgr.pActualBullets[i]->nIndexDefault;
900 			pActualBullets[i]->pBullets = new GrfBulDataRelation(eNBType::GRAPHICBULLETS) ;
901 			((GrfBulDataRelation*)(pActualBullets[i]->pBullets))->sGrfName = ((GrfBulDataRelation*)(aTypeMgr.pActualBullets[i]->pBullets))->sGrfName;
902 			((GrfBulDataRelation*)(pActualBullets[i]->pBullets))->sDescription = ((GrfBulDataRelation*)(aTypeMgr.pActualBullets[i]->pBullets))->sDescription;
903 			((GrfBulDataRelation*)(pActualBullets[i]->pBullets))->bIsCustomized = ((GrfBulDataRelation*)(aTypeMgr.pActualBullets[i]->pBullets))->bIsCustomized;
904 			((GrfBulDataRelation*)(pActualBullets[i]->pBullets))->eType = ((GrfBulDataRelation*)(aTypeMgr.pActualBullets[i]->pBullets))->eType;
905 			if ( ((GrfBulDataRelation*)(aTypeMgr.pActualBullets[i]->pBullets))->bIsCustomized && ((GrfBulDataRelation*)(aTypeMgr.pActualBullets[i]->pBullets))->pGrfObj != NULL)
906 			{
907 				((GrfBulDataRelation*)(pActualBullets[i]->pBullets))->pGrfObj = ((GrfBulDataRelation*)(aTypeMgr.pActualBullets[i]->pBullets))->pGrfObj;
908 			}
909 		}
910 	}
911 	ImplLoad(String::CreateFromAscii("standard.sya"));
912 }
Init()913 void MixBulletsTypeMgr::Init()
914 {
915 	BulletsTypeMgr* pBTMgr = BulletsTypeMgr::GetInstance();
916 	if ( pBTMgr )
917 	{
918 		// Index 1
919 		pActualBullets[0] = new MixBulletsSettings_Impl(eNBType::BULLETS);
920 		pActualBullets[0]->eType = eNBType::BULLETS;
921 		pActualBullets[0]->nIndex = 0+1; // Index in the tab page display,decrease 1 to the index within arr
922 		pActualBullets[0]->nIndexDefault = 2; // Index in the tab page display,decrease 1 to the index within arr
923 		pActualBullets[0]->pBullets = new BulletsSettings_Impl(eNBType::BULLETS) ;
924 		((BulletsSettings_Impl*)(pActualBullets[0]->pBullets))->cBulletChar = pBTMgr->GetBulChar(pActualBullets[0]->nIndexDefault-1);
925 		((BulletsSettings_Impl*)(pActualBullets[0]->pBullets))->aFont = pBTMgr->GetBulCharFont(pActualBullets[0]->nIndexDefault-1);
926 		((BulletsSettings_Impl*)(pActualBullets[0]->pBullets))->sDescription = pBTMgr->GetDescription(pActualBullets[0]->nIndexDefault-1);
927 		((BulletsSettings_Impl*)(pActualBullets[0]->pBullets))->bIsCustomized = pBTMgr->IsCustomized(pActualBullets[0]->nIndexDefault-1);
928 		((BulletsSettings_Impl*)(pActualBullets[0]->pBullets))->eType = eNBType::BULLETS;
929 
930 		// Index 2
931 		pActualBullets[1] = new MixBulletsSettings_Impl(eNBType::BULLETS);
932 		pActualBullets[1]->eType = eNBType::BULLETS;
933 		pActualBullets[1]->nIndex = 1+1; // Index in the tab page display,decrease 1 to the index within arr
934 		pActualBullets[1]->nIndexDefault = 3; // Index in the tab page display,decrease 1 to the index within arr
935 		pActualBullets[1]->pBullets = new BulletsSettings_Impl(eNBType::BULLETS) ;
936 		((BulletsSettings_Impl*)(pActualBullets[1]->pBullets))->cBulletChar = pBTMgr->GetBulChar(pActualBullets[1]->nIndexDefault-1);
937 		((BulletsSettings_Impl*)(pActualBullets[1]->pBullets))->aFont = pBTMgr->GetBulCharFont(pActualBullets[1]->nIndexDefault-1);
938 		((BulletsSettings_Impl*)(pActualBullets[1]->pBullets))->sDescription = pBTMgr->GetDescription(pActualBullets[1]->nIndexDefault-1);
939 		((BulletsSettings_Impl*)(pActualBullets[1]->pBullets))->bIsCustomized = pBTMgr->IsCustomized(pActualBullets[1]->nIndexDefault-1);
940 		((BulletsSettings_Impl*)(pActualBullets[1]->pBullets))->eType = eNBType::BULLETS;
941 
942 		// Index 3
943 		pActualBullets[2] = new MixBulletsSettings_Impl(eNBType::BULLETS);
944 		pActualBullets[2]->eType = eNBType::BULLETS;
945 		pActualBullets[2]->nIndex = 2+1; // Index in the tab page display,decrease 1 to the index within arr
946 		pActualBullets[2]->nIndexDefault = 4; // Index in the tab page display,decrease 1 to the index within arr
947 		pActualBullets[2]->pBullets = new BulletsSettings_Impl(eNBType::BULLETS) ;
948 		((BulletsSettings_Impl*)(pActualBullets[2]->pBullets))->cBulletChar = pBTMgr->GetBulChar(pActualBullets[2]->nIndexDefault-1);
949 		((BulletsSettings_Impl*)(pActualBullets[2]->pBullets))->aFont = pBTMgr->GetBulCharFont(pActualBullets[2]->nIndexDefault-1);
950 		((BulletsSettings_Impl*)(pActualBullets[2]->pBullets))->sDescription = pBTMgr->GetDescription(pActualBullets[2]->nIndexDefault-1);
951 		((BulletsSettings_Impl*)(pActualBullets[2]->pBullets))->bIsCustomized = pBTMgr->IsCustomized(pActualBullets[2]->nIndexDefault-1);
952 		((BulletsSettings_Impl*)(pActualBullets[2]->pBullets))->eType = eNBType::BULLETS;
953 
954 		// Index 4
955 		pActualBullets[3] = new MixBulletsSettings_Impl(eNBType::BULLETS);
956 		pActualBullets[3]->eType = eNBType::BULLETS;
957 		pActualBullets[3]->nIndex = 3+1; // Index in the tab page display,decrease 1 to the index within arr
958 		pActualBullets[3]->nIndexDefault = 5; // Index in the tab page display,decrease 1 to the index within arr
959 		pActualBullets[3]->pBullets = new BulletsSettings_Impl(eNBType::BULLETS) ;
960 		((BulletsSettings_Impl*)(pActualBullets[3]->pBullets))->cBulletChar = pBTMgr->GetBulChar(pActualBullets[3]->nIndexDefault-1);
961 		((BulletsSettings_Impl*)(pActualBullets[3]->pBullets))->aFont = pBTMgr->GetBulCharFont(pActualBullets[3]->nIndexDefault-1);
962 		((BulletsSettings_Impl*)(pActualBullets[3]->pBullets))->sDescription = pBTMgr->GetDescription(pActualBullets[3]->nIndexDefault-1);
963 		((BulletsSettings_Impl*)(pActualBullets[3]->pBullets))->bIsCustomized = pBTMgr->IsCustomized(pActualBullets[3]->nIndexDefault-1);
964 		((BulletsSettings_Impl*)(pActualBullets[3]->pBullets))->eType = eNBType::BULLETS;
965 
966 		// Index 5
967 		pActualBullets[4] = new MixBulletsSettings_Impl(eNBType::BULLETS);
968 		pActualBullets[4]->eType = eNBType::BULLETS;
969 		pActualBullets[4]->nIndex = 4+1; // Index in the tab page display,decrease 1 to the index within arr
970 		pActualBullets[4]->nIndexDefault = 6; // Index in the tab page display,decrease 1 to the index within arr
971 		pActualBullets[4]->pBullets = new BulletsSettings_Impl(eNBType::BULLETS) ;
972 		((BulletsSettings_Impl*)(pActualBullets[4]->pBullets))->cBulletChar = pBTMgr->GetBulChar(pActualBullets[4]->nIndexDefault-1);
973 		((BulletsSettings_Impl*)(pActualBullets[4]->pBullets))->aFont = pBTMgr->GetBulCharFont(pActualBullets[4]->nIndexDefault-1);
974 		((BulletsSettings_Impl*)(pActualBullets[4]->pBullets))->sDescription = pBTMgr->GetDescription(pActualBullets[4]->nIndexDefault-1);
975 		((BulletsSettings_Impl*)(pActualBullets[4]->pBullets))->bIsCustomized = pBTMgr->IsCustomized(pActualBullets[4]->nIndexDefault-1);
976 		((BulletsSettings_Impl*)(pActualBullets[4]->pBullets))->eType = eNBType::BULLETS;
977 
978 		// Index 6
979 		pActualBullets[5] = new MixBulletsSettings_Impl(eNBType::BULLETS);
980 		pActualBullets[5]->eType = eNBType::BULLETS;
981 		pActualBullets[5]->nIndex = 5+1; // Index in the tab page display,decrease 1 to the index within arr
982 		pActualBullets[5]->nIndexDefault = 8; // Index in the tab page display,decrease 1 to the index within arr
983 		pActualBullets[5]->pBullets = new BulletsSettings_Impl(eNBType::BULLETS) ;
984 		((BulletsSettings_Impl*)(pActualBullets[5]->pBullets))->cBulletChar = pBTMgr->GetBulChar(pActualBullets[5]->nIndexDefault-1);
985 		((BulletsSettings_Impl*)(pActualBullets[5]->pBullets))->aFont = pBTMgr->GetBulCharFont(pActualBullets[5]->nIndexDefault-1);
986 		((BulletsSettings_Impl*)(pActualBullets[5]->pBullets))->sDescription = pBTMgr->GetDescription(pActualBullets[5]->nIndexDefault-1);
987 		((BulletsSettings_Impl*)(pActualBullets[5]->pBullets))->bIsCustomized = pBTMgr->IsCustomized(pActualBullets[5]->nIndexDefault-1);
988 		((BulletsSettings_Impl*)(pActualBullets[5]->pBullets))->eType = eNBType::BULLETS;
989 	}
990 
991 	GraphicBulletsTypeMgr* mGrfTMgr = GraphicBulletsTypeMgr::GetInstance();
992 	if ( mGrfTMgr )
993 	{
994 		// Index 7
995 		pActualBullets[6] = new MixBulletsSettings_Impl(eNBType::GRAPHICBULLETS);
996 		pActualBullets[6]->eType = eNBType::GRAPHICBULLETS;
997 		pActualBullets[6]->nIndex = 6+1; // Index in the tab page display,decrease 1 to the index within arr
998 		pActualBullets[6]->nIndexDefault = 9; // Index in the tab page display,decrease 1 to the index within arr
999 		pActualBullets[6]->pBullets = new GrfBulDataRelation(eNBType::GRAPHICBULLETS) ;
1000 		((GrfBulDataRelation*)(pActualBullets[6]->pBullets))->sGrfName = mGrfTMgr->GetGrfName(pActualBullets[6]->nIndexDefault);
1001 		((GrfBulDataRelation*)(pActualBullets[6]->pBullets))->sDescription = mGrfTMgr->GetDescription(pActualBullets[6]->nIndexDefault);
1002 		((GrfBulDataRelation*)(pActualBullets[6]->pBullets))->bIsCustomized = mGrfTMgr->IsCustomized(pActualBullets[6]->nIndexDefault);
1003 		((GrfBulDataRelation*)(pActualBullets[6]->pBullets))->eType = eNBType::GRAPHICBULLETS;
1004 
1005 		// Index 8
1006 		pActualBullets[7] = new MixBulletsSettings_Impl(eNBType::GRAPHICBULLETS);
1007 		pActualBullets[7]->eType = eNBType::GRAPHICBULLETS;
1008 		pActualBullets[7]->nIndex = 7+1; // Index in the tab page display,decrease 1 to the index within arr
1009 		pActualBullets[7]->nIndexDefault = 23; // Index in the tab page display,decrease 1 to the index within arr
1010 		pActualBullets[7]->pBullets = new GrfBulDataRelation(eNBType::GRAPHICBULLETS) ;
1011 		((GrfBulDataRelation*)(pActualBullets[7]->pBullets))->sGrfName = mGrfTMgr->GetGrfName(pActualBullets[7]->nIndexDefault);
1012 		((GrfBulDataRelation*)(pActualBullets[7]->pBullets))->sDescription = mGrfTMgr->GetDescription(pActualBullets[7]->nIndexDefault);
1013 		((GrfBulDataRelation*)(pActualBullets[7]->pBullets))->bIsCustomized = mGrfTMgr->IsCustomized(pActualBullets[7]->nIndexDefault);
1014 		((GrfBulDataRelation*)(pActualBullets[7]->pBullets))->eType = eNBType::GRAPHICBULLETS;
1015 	}
1016 
1017 }
GetNBOIndexForNumRule(SvxNumRule & aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex)1018 sal_uInt16 MixBulletsTypeMgr::GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex)
1019 {
1020 	if ( mLevel == (sal_uInt16)0xFFFF || mLevel == 0)
1021 		return (sal_uInt16)0xFFFF;
1022 	//if ( !lcl_IsNumFmtSet(pNR, mLevel) ) return (sal_uInt16)0xFFFF;
1023 
1024 	sal_uInt16 nActLv = IsSingleLevel(mLevel);
1025 
1026 	if ( nActLv == (sal_uInt16)0xFFFF )
1027 		return (sal_uInt16)0xFFFF;
1028 
1029 	SvxNumberFormat aFmt(aNum.GetLevel(nActLv));
1030 	sal_Int16 eNumType = aFmt.GetNumberingType();
1031 	if( eNumType == SVX_NUM_CHAR_SPECIAL)
1032 	{
1033 		sal_Unicode cChar = aFmt.GetBulletChar();
1034 		const Font* pFont = aFmt.GetBulletFont();
1035 		String sName = pFont?pFont->GetName():String();
1036 
1037 		for(sal_uInt16 i = nFromIndex; i < DEFAULT_BULLET_TYPES; i++)
1038 		{
1039 			if ( pActualBullets[i]->eType == eNBType::BULLETS )
1040 			{
1041 				String ssName = ((BulletsSettings_Impl*)(pActualBullets[i]->pBullets))->aFont.GetName();
1042 				if ( (cChar == ((BulletsSettings_Impl*)(pActualBullets[i]->pBullets))->cBulletChar||
1043 					(cChar == 9830 && 57356 == ((BulletsSettings_Impl*)(pActualBullets[i]->pBullets))->cBulletChar) ||
1044 					(cChar == 9632 && 57354 == ((BulletsSettings_Impl*)(pActualBullets[i]->pBullets))->cBulletChar)))//&&
1045 					//(pFont && pFont->GetName().CompareTo(((BulletsSettings_Impl*)(pActualBullets[i]->pBullets))->aFont.GetName())==COMPARE_EQUAL) )
1046 				{
1047 					return pActualBullets[i]->nIndex;
1048 				}
1049 			}
1050 		}
1051 	}else if ( (eNumType&(~LINK_TOKEN)) == SVX_NUM_BITMAP )
1052 	{
1053 		const SvxBrushItem* pBrsh = aFmt.GetBrush();
1054 		const Graphic* pGrf = 0;
1055 		if ( pBrsh )
1056 			pGrf = pBrsh->GetGraphic();
1057 
1058 		if ( pGrf )
1059 		{
1060 			for(sal_uInt16 i = nFromIndex; i < DEFAULT_BULLET_TYPES; i++)
1061 			{
1062 				if ( pActualBullets[i]->eType == eNBType::GRAPHICBULLETS )
1063 				{
1064 					GrfBulDataRelation* pEntry = (GrfBulDataRelation*) (pActualBullets[i]->pBullets);
1065 					//sal_Bool bExist = sal_False;
1066 					if ( pEntry && pActualBullets[i]->nIndexDefault == (sal_uInt16)0xFFFF && pEntry->pGrfObj)
1067 					{
1068 						if ( pEntry->pGrfObj->GetBitmap().IsEqual(pGrf->GetBitmap()))
1069 						{
1070 							return pActualBullets[i]->nIndex;
1071 						}
1072 					}else { //if ( pEntry && pGrfName && pEntry->sGrfName.CompareTo(*pGrfName)==COMPARE_EQUAL )
1073 						//bExist = GalleryExplorer::GetGraphicObj(GALLERY_THEME_BULLETS, pActualBullets[i]->nIndexDefault-1,pSrGrf);
1074 						Graphic aSrGrf;
1075 						if (pEntry)
1076 							GalleryExplorer::GetGraphicObj(GALLERY_THEME_BULLETS, pActualBullets[i]->nIndexDefault,&aSrGrf);
1077 						Bitmap aSum=pGrf->GetBitmap();
1078 						Bitmap aSum1=aSrGrf.GetBitmap();
1079 						if (aSum.IsEqual(aSum1))
1080 							return pActualBullets[i]->nIndex;
1081 					}
1082 				}
1083 			}
1084 		}
1085 	}
1086 
1087 	return (sal_uInt16)0xFFFF;
1088 }
1089 
RelplaceNumRule(SvxNumRule & aNum,sal_uInt16 nIndex,sal_uInt16 mLevel)1090 sal_Bool MixBulletsTypeMgr::RelplaceNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel)
1091 {
1092 	if ( mLevel == (sal_uInt16)0xFFFF || mLevel == 0 || nIndex>=DEFAULT_BULLET_TYPES)
1093 		return sal_False;
1094 
1095 	//if ( GetNBOIndexForNumRule(aNum,mLevel) != (sal_uInt16)0xFFFF )
1096 	//	return sal_False;
1097 
1098 	sal_uInt16 nActLv = IsSingleLevel(mLevel);
1099 
1100 	if ( nActLv == (sal_uInt16)0xFFFF )
1101 		return sal_False;
1102 
1103 	SvxNumberFormat aFmt(aNum.GetLevel(nActLv));
1104 	sal_Int16 eNumType = aFmt.GetNumberingType();
1105 	if( eNumType == SVX_NUM_CHAR_SPECIAL && pActualBullets[nIndex]->eType == eNBType::BULLETS )
1106 	{
1107 		sal_Unicode cChar = aFmt.GetBulletChar();
1108 		const Font* pFont = aFmt.GetBulletFont();
1109 		BulletsSettings_Impl* pEntry = (BulletsSettings_Impl*) (pActualBullets[nIndex]->pBullets);
1110 		pEntry->cBulletChar = cChar;
1111 		pEntry->aFont = pFont?*pFont:lcl_GetDefaultBulletFont();
1112 		pEntry->bIsCustomized = sal_True;
1113 		String aStrFromRES = String(SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_BULLET_DESCRIPTION));
1114 		String aReplace = String::CreateFromAscii("%LIST_NUM");
1115 		String sNUM = String::CreateFromInt32( nIndex + 1 );
1116 		aStrFromRES.SearchAndReplace(aReplace,sNUM);
1117 		pEntry->sDescription = aStrFromRES;
1118 
1119 	}else if ( (eNumType&(~LINK_TOKEN)) == SVX_NUM_BITMAP && pActualBullets[nIndex]->eType == eNBType::GRAPHICBULLETS )
1120 	{
1121 		const SvxBrushItem* pBrsh = aFmt.GetBrush();
1122 		const Graphic* pGrf = 0;
1123 		if ( pBrsh )
1124 			pGrf = pBrsh->GetGraphic();
1125 		else
1126 			return sal_False;
1127 
1128 		String sEmpty;
1129 		if ( pGrf )
1130 		{
1131 			const String* pGrfName = pBrsh->GetGraphicLink();
1132 			//String* pGrfName = (String*)(pBrsh->GetGraphicLink());
1133 			GrfBulDataRelation* pEntry = (GrfBulDataRelation*) (pActualBullets[nIndex]->pBullets);
1134 			if ( pGrfName )
1135 				pEntry->sGrfName = *pGrfName;
1136 			GraphicBulletsTypeMgr* mGrfTMgr = GraphicBulletsTypeMgr::GetInstance();
1137 			if ( mGrfTMgr )
1138 			{
1139 				//sal_uInt16 nDIndex = mGrfTMgr->GetNBOIndexForNumRule(aNum,mLevel);
1140 				//if ( nDIndex != (sal_uInt16)0xFFFF)
1141 				//{
1142 				//	pActualBullets[nIndex]->nIndexDefault = nDIndex -1;
1143 				//	sEmpty = mGrfTMgr->GetDescription( nDIndex -1);
1144 				//}else
1145 				{
1146 					pActualBullets[nIndex]->nIndexDefault = (sal_uInt16)0xFFFF;
1147 					sEmpty = String(SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_BULLET_DESCRIPTION));
1148 					String aReplace = String::CreateFromAscii("%LIST_NUM");
1149 					String sNUM = String::CreateFromInt32( nIndex + 1 );
1150 					sEmpty.SearchAndReplace(aReplace,sNUM);
1151 					//pEntry->pGrfObj = pGrf;
1152 					pEntry->pGrfObj = new Graphic(*pGrf);
1153 					pEntry->aSize = aFmt.GetGraphicSize();
1154 					pEntry->aSize = OutputDevice::LogicToLogic(pEntry->aSize,(MapUnit)GetMapUnit(),MAP_100TH_MM);
1155 					sal_uInt16 nDIndex = mGrfTMgr->GetNBOIndexForNumRule(aNum,mLevel);
1156 					if (nDIndex!=(sal_uInt16)0xFFFF) pEntry->aSize=Size(0,0);
1157 				}
1158 			}
1159 			pEntry->sDescription = sEmpty;
1160 			pEntry->bIsCustomized = sal_True;
1161 		}else
1162 		{
1163 			return sal_False;
1164 		}
1165 	}else
1166 	{
1167 		delete pActualBullets[nIndex]->pBullets;
1168 		pActualBullets[nIndex]->pBullets = 0;
1169 		if ( eNumType == SVX_NUM_CHAR_SPECIAL )
1170 		{
1171 			sal_Unicode cChar = aFmt.GetBulletChar();
1172 			const Font* pFont = aFmt.GetBulletFont();
1173 			pActualBullets[nIndex]->eType = eNBType::BULLETS;
1174 			pActualBullets[nIndex]->nIndex = nIndex+1; // Index in the tab page display, decrease 1 to the index within arr
1175 			pActualBullets[nIndex]->pBullets = new BulletsSettings_Impl(eNBType::BULLETS) ;
1176 			((BulletsSettings_Impl*)(pActualBullets[nIndex]->pBullets))->cBulletChar = cChar;
1177 			((BulletsSettings_Impl*)(pActualBullets[nIndex]->pBullets))->aFont = pFont?*pFont:lcl_GetDefaultBulletFont();
1178 			((BulletsSettings_Impl*)(pActualBullets[nIndex]->pBullets))->bIsCustomized = sal_True;
1179 			((BulletsSettings_Impl*)(pActualBullets[nIndex]->pBullets))->eType = eNBType::BULLETS;
1180 			BulletsTypeMgr* pBTMgr = BulletsTypeMgr::GetInstance();
1181 			if ( pBTMgr )
1182 			{
1183 				//sal_uInt16 nDIndex = pBTMgr->GetNBOIndexForNumRule(aNum,mLevel);
1184 				//if ( nDIndex != (sal_uInt16)0xFFFF)
1185 				//{
1186 				//	pActualBullets[nIndex]->nIndexDefault = nDIndex -1;
1187 				//	((BulletsSettings_Impl*)(pActualBullets[nIndex]->pBullets))->sDescription = pBTMgr->GetDescription(nDIndex - 1);
1188 				//}else
1189 				{
1190 					pActualBullets[nIndex]->nIndexDefault = (sal_uInt16)0xFFFF;
1191 					String aStrFromRES = String(SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_BULLET_DESCRIPTION));
1192 					String aReplace = String::CreateFromAscii("%LIST_NUM");
1193 					String sNUM = String::CreateFromInt32( nIndex + 1 );
1194 					aStrFromRES.SearchAndReplace(aReplace,sNUM);
1195 					((BulletsSettings_Impl*)(pActualBullets[nIndex]->pBullets))->sDescription = aStrFromRES;
1196 				}
1197 			}
1198 		}else if ( (eNumType&(~LINK_TOKEN)) == SVX_NUM_BITMAP )
1199 		{
1200 			const SvxBrushItem* pBrsh = aFmt.GetBrush();
1201 			const Graphic* pGrf = 0;
1202 			if ( pBrsh )
1203 				pGrf = pBrsh->GetGraphic();
1204 			else
1205 				return sal_False;
1206 
1207 			String sEmpty;
1208 			const String* pGrfName = 0;
1209 			if ( pGrf )
1210 			{
1211 				pGrfName = pBrsh->GetGraphicLink();
1212 
1213 				pActualBullets[nIndex]->eType = eNBType::GRAPHICBULLETS;
1214 				pActualBullets[nIndex]->nIndex = nIndex+1; // Index in the tab page display, decrease 1 to the index within arr
1215 				pActualBullets[nIndex]->pBullets = new GrfBulDataRelation(eNBType::GRAPHICBULLETS) ;
1216 				if (pGrfName)
1217 					((GrfBulDataRelation*)(pActualBullets[nIndex]->pBullets))->sGrfName = *pGrfName;
1218 				((GrfBulDataRelation*)(pActualBullets[nIndex]->pBullets))->bIsCustomized = sal_True;
1219 				((GrfBulDataRelation*)(pActualBullets[nIndex]->pBullets))->eType = eNBType::GRAPHICBULLETS;
1220 				GraphicBulletsTypeMgr* mGrfTMgr = GraphicBulletsTypeMgr::GetInstance();
1221 				if ( mGrfTMgr )
1222 				{
1223 					//sal_uInt16 nDIndex = mGrfTMgr->GetNBOIndexForNumRule(aNum,mLevel);
1224 					//if ( nDIndex != (sal_uInt16)0xFFFF)
1225 					//{
1226 					//	pActualBullets[nIndex]->nIndexDefault = nDIndex - 1;
1227 					//	((GrfBulDataRelation*)(pActualBullets[nIndex]->pBullets))->sDescription = mGrfTMgr->GetDescription(nDIndex - 1);
1228 					//}else
1229 					{
1230 						pActualBullets[nIndex]->nIndexDefault = (sal_uInt16)0xFFFF;
1231 						String aStrFromRES = String(SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_BULLET_DESCRIPTION));
1232 						String aReplace = String::CreateFromAscii("%LIST_NUM");
1233 						String sNUM = String::CreateFromInt32( nIndex + 1 );
1234 						aStrFromRES.SearchAndReplace(aReplace,sNUM);
1235 						((GrfBulDataRelation*)(pActualBullets[nIndex]->pBullets))->sDescription = aStrFromRES;
1236 						//((GrfBulDataRelation*)(pActualBullets[nIndex]->pBullets))->pGrfObj = pGrf;
1237 						((GrfBulDataRelation*)(pActualBullets[nIndex]->pBullets))->pGrfObj = new Graphic(*pGrf);
1238 						((GrfBulDataRelation*)(pActualBullets[nIndex]->pBullets))->pGrfObj = new Graphic(*pGrf);
1239 						Size aTmpSize = aFmt.GetGraphicSize();
1240 						aTmpSize = OutputDevice::LogicToLogic(aTmpSize,(MapUnit)GetMapUnit(),MAP_100TH_MM);
1241 						sal_uInt16 nDIndex = mGrfTMgr->GetNBOIndexForNumRule(aNum,mLevel);
1242 						if (nDIndex!=(sal_uInt16)0xFFFF) aTmpSize=Size(0,0);
1243 						((GrfBulDataRelation*)(pActualBullets[nIndex]->pBullets))->aSize = aTmpSize;
1244 
1245 				}
1246 				}
1247 			}
1248 		}
1249 	}
1250 	SvxNumRule aTmpRule1(aNum);
1251 	ApplyNumRule(aTmpRule1,nIndex,mLevel,true);
1252 	if (GetNBOIndexForNumRule(aTmpRule1,mLevel,nIndex)==nIndex+1) {
1253 		if (pActualBullets[nIndex]->eType == eNBType::BULLETS) {
1254 			BulletsSettings_Impl* pEntry = (BulletsSettings_Impl*) (pActualBullets[nIndex]->pBullets);
1255 			pEntry->bIsCustomized = false;
1256 			pEntry->sDescription = GetDescription(nIndex,true);
1257 		}
1258 		if (pActualBullets[nIndex]->eType == eNBType::GRAPHICBULLETS) {
1259 			GrfBulDataRelation* pEntry = (GrfBulDataRelation*) (pActualBullets[nIndex]->pBullets);
1260 			pEntry->bIsCustomized = false;
1261 			pEntry->sDescription = GetDescription(nIndex,true);
1262 		}
1263 	}
1264 	ImplStore(String::CreateFromAscii("standard.sya"));
1265 	return sal_True;
1266 }
1267 
ApplyNumRule(SvxNumRule & aNum,sal_uInt16 nIndex,sal_uInt16 mLevel,sal_Bool isDefault,sal_Bool isResetSize)1268 sal_Bool MixBulletsTypeMgr::ApplyNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel,sal_Bool isDefault,sal_Bool isResetSize)
1269 {
1270 	//if ( mLevel == (sal_uInt16)0xFFFF || nIndex>=DEFAULT_BULLET_TYPES )
1271 	if ( nIndex>=DEFAULT_BULLET_TYPES )
1272 		return sal_False;
1273 	MixBulletsSettings_Impl* pCurrentBullets = pActualBullets[nIndex];
1274 	if (isDefault) pCurrentBullets=pDefaultActualBullets[nIndex];
1275 
1276 	if ( pCurrentBullets->eType == eNBType::BULLETS )
1277 	{
1278 		sal_Unicode cChar;
1279 		cChar = ((BulletsSettings_Impl*)(pCurrentBullets->pBullets))->cBulletChar;
1280 
1281 		//Font& rActBulletFont = lcl_GetDefaultBulletFont();
1282 		Font rActBulletFont = ((BulletsSettings_Impl*)(pCurrentBullets->pBullets))->aFont;
1283 		sal_uInt16 nMask = 1;
1284 		String sBulletCharFmtName = GetBulCharFmtName();
1285 		for(sal_uInt16 i = 0; i < aNum.GetLevelCount(); i++)
1286 		{
1287 			if(mLevel & nMask)
1288 			{
1289 				SvxNumberFormat aFmt(aNum.GetLevel(i));
1290 				if (SVX_NUM_CHAR_SPECIAL !=aFmt.GetNumberingType()) isResetSize=true;
1291 				aFmt.SetNumberingType( SVX_NUM_CHAR_SPECIAL );
1292 				aFmt.SetBulletFont(&rActBulletFont);
1293 				aFmt.SetBulletChar(cChar );
1294 				aFmt.SetCharFmtName(sBulletCharFmtName);
1295 				String aEmptyStr;
1296 				aFmt.SetPrefix( aEmptyStr );
1297 				aFmt.SetSuffix( aEmptyStr );
1298 				if (isResetSize) aFmt.SetBulletRelSize(45);
1299 				aNum.SetLevel(i, aFmt);
1300 			}
1301 			nMask <<= 1;
1302 		}
1303 	}else if ( pCurrentBullets->eType == eNBType::GRAPHICBULLETS )
1304 	{
1305 		String sGrfName;
1306 		GrfBulDataRelation* pEntry = (GrfBulDataRelation*) (pCurrentBullets->pBullets);
1307 		sGrfName= pEntry->sGrfName;
1308 
1309 		sal_uInt16 nMask = 1;
1310 		String aEmptyStr;
1311 		sal_uInt16 nSetNumberingType = SVX_NUM_BITMAP;
1312 		String sNumCharFmtName = GetBulCharFmtName();
1313 		for(sal_uInt16 i = 0; i < aNum.GetLevelCount(); i++)
1314 		{
1315 			if(mLevel & nMask)
1316 			{
1317 				SvxNumberFormat aFmt(aNum.GetLevel(i));
1318 				if (SVX_NUM_BITMAP !=aFmt.GetNumberingType()) isResetSize=true;
1319 				aFmt.SetNumberingType(nSetNumberingType);
1320 				aFmt.SetPrefix( aEmptyStr );
1321 				aFmt.SetSuffix( aEmptyStr );
1322 				aFmt.SetCharFmtName( sNumCharFmtName );
1323 				if ( pCurrentBullets->nIndexDefault == (sal_uInt16)0xFFFF && pEntry->pGrfObj )
1324 				{
1325 					Size aSize = pEntry->aSize;
1326 					sal_Int16 eOrient = text::VertOrientation::LINE_CENTER;
1327 					if (!isResetSize && aFmt.GetGraphicSize()!=Size(0,0)) aSize=aFmt.GetGraphicSize();
1328 					else {
1329 						if (aSize.Width()==0 && aSize.Height()==0) {
1330 							aSize = SvxNumberFormat::GetGraphicSizeMM100( pEntry->pGrfObj );
1331 						}
1332 						aSize = OutputDevice::LogicToLogic(aSize, MAP_100TH_MM, (MapUnit)GetMapUnit());
1333 					}
1334 					SvxBrushItem aBrush(*(pEntry->pGrfObj), GPOS_AREA, SID_ATTR_BRUSH );
1335 					aFmt.SetGraphicBrush( &aBrush, &aSize, &eOrient );
1336 				}else
1337 				{
1338 					Graphic aGraphic;
1339 					if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, pCurrentBullets->nIndexDefault, &aGraphic))
1340 					{
1341 								Size aSize = pEntry->aSize;
1342 								sal_Int16 eOrient = text::VertOrientation::LINE_CENTER;
1343 								if (!isResetSize && aFmt.GetGraphicSize()!=Size(0,0)) aSize=aFmt.GetGraphicSize();
1344 								else {
1345 									if (aSize.Width()==0 && aSize.Height()==0) {
1346 										aSize = SvxNumberFormat::GetGraphicSizeMM100(&aGraphic);
1347 									}
1348 									aSize = OutputDevice::LogicToLogic(aSize, MAP_100TH_MM, (MapUnit)GetMapUnit());
1349 								}
1350 								SvxBrushItem aBrush(aGraphic, GPOS_AREA, SID_ATTR_BRUSH );
1351 								aFmt.SetGraphicBrush( &aBrush, &aSize, &eOrient );
1352 					}else
1353 						aFmt.SetGraphic( sGrfName );
1354 				}
1355 
1356 				aNum.SetLevel(i, aFmt);
1357 			}
1358 			nMask <<= 1 ;
1359 		}
1360 	}
1361 
1362 	return sal_True;
1363 }
1364 
GetDescription(sal_uInt16 nIndex,sal_Bool isDefault)1365 String MixBulletsTypeMgr::GetDescription(sal_uInt16 nIndex,sal_Bool isDefault)
1366 {
1367 	String sRet;
1368 	//sal_uInt16 nLength = 0;
1369 	//nLength = sizeof(pActualBullets)/sizeof(BulletsSettings_Impl);
1370 
1371 	if ( nIndex >= DEFAULT_BULLET_TYPES )
1372 		return sRet;
1373 	else
1374 		sRet = pActualBullets[nIndex]->pBullets->sDescription;
1375 	if (isDefault) sRet = pDefaultActualBullets[nIndex]->pBullets->sDescription;
1376 	return sRet;
1377 }
IsCustomized(sal_uInt16 nIndex)1378 sal_Bool MixBulletsTypeMgr::IsCustomized(sal_uInt16 nIndex)
1379 {
1380 	sal_Bool bRet = sal_False;
1381 	//sal_uInt16 nLength = 0;
1382 	//nLength = sizeof(pActualBullets)/sizeof(BulletsSettings_Impl);
1383 
1384 	if ( nIndex >= DEFAULT_BULLET_TYPES )
1385 		bRet = sal_False;
1386 	else
1387 		bRet = pActualBullets[nIndex]->pBullets->bIsCustomized;
1388 
1389 	return bRet;
1390 }
1391 /***************************************************************************************************
1392 **********************Numbering Type lib**************************************************************
1393 ****************************************************************************************************/
1394 NumberingTypeMgr* NumberingTypeMgr::_instance = 0;
1395 
NumberingTypeMgr(const NBOType aType)1396 NumberingTypeMgr::NumberingTypeMgr(const NBOType aType):
1397 	NBOTypeMgrBase(aType),
1398 	//pNumSettingsArr( new NumSettingsArr_Impl ),
1399 	pNumberSettingsArr (new NumberSettingsArr_Impl)
1400 {
1401 	Init();
1402 	pDefaultNumberSettingsArr = pNumberSettingsArr;
1403 	pNumberSettingsArr = new NumberSettingsArr_Impl;
1404 	// Initialize the first time to store the default value. Then do it again for customized value
1405 	Init();
1406 	ImplLoad(String::CreateFromAscii("standard.syb"));
1407 }
1408 
NumberingTypeMgr(const NBOType aType,const SfxItemSet * pArg)1409 NumberingTypeMgr::NumberingTypeMgr(const NBOType aType,const SfxItemSet* pArg):
1410 	NBOTypeMgrBase(aType,pArg),
1411 	//pNumSettingsArr( new NumSettingsArr_Impl ),
1412 	pNumberSettingsArr (new NumberSettingsArr_Impl)
1413 {
1414 	Init();
1415 	pDefaultNumberSettingsArr = pNumberSettingsArr;
1416 	pNumberSettingsArr = new NumberSettingsArr_Impl;
1417 	// Initialize the first time to store the default value. Then do it again for customized value
1418 	Init();
1419 	ImplLoad(String::CreateFromAscii("standard.syb"));
1420 }
1421 
NumberingTypeMgr(const NumberingTypeMgr & aTypeMgr)1422 NumberingTypeMgr::NumberingTypeMgr(const NumberingTypeMgr& aTypeMgr):
1423 	NBOTypeMgrBase(aTypeMgr),
1424 	//pNumSettingsArr( new NumSettingsArr_Impl ),
1425 	pNumberSettingsArr (new NumberSettingsArr_Impl)
1426 {
1427 	/*
1428 	for(sal_uInt16 i=0;i<aTypeMgr.GetNumCount();i++)
1429 	{
1430 		NumberSettings_Impl* _pSet = aTypeMgr.GetNumSettingByIndex(i);
1431 		if ( _pSet )
1432 		{
1433 			pNumberSettingsArr->GetObject(i)->nIndex = _pSet->nIndex;
1434 			pNumberSettingsArr->GetObject(i)->nIndexDefault = _pSet->nIndexDefault;
1435 			pNumberSettingsArr->GetObject(i)->sDescription = _pSet->sDescription;
1436 			pNumberSettingsArr->GetObject(i)->bIsCustomized = _pSet->bIsCustomized;
1437 			if ( _pSet->pNumSetting )
1438 			{
1439 				pNumberSettingsArr->GetObject(i)->pNumSetting->nNumberType = _pSet->pNumSetting->nNumberType;
1440 				pNumberSettingsArr->GetObject(i)->pNumSetting->nParentNumbering = _pSet->pNumSetting->nParentNumbering;
1441 				pNumberSettingsArr->GetObject(i)->pNumSetting->sPrefix = _pSet->pNumSetting->sPrefix;
1442 				pNumberSettingsArr->GetObject(i)->pNumSetting->sSuffix = _pSet->pNumSetting->sSuffix;
1443 				pNumberSettingsArr->GetObject(i)->pNumSetting->sBulletChar = _pSet->pNumSetting->sBulletChar;
1444 				pNumberSettingsArr->GetObject(i)->pNumSetting->sBulletFont = _pSet->pNumSetting->sBulletFont;
1445 
1446 				pNumberSettingsArr->GetObject(i)->pNumSetting->eLabelFollowedBy = _pSet->pNumSetting->eLabelFollowedBy;
1447 				pNumberSettingsArr->GetObject(i)->pNumSetting->nTabValue = _pSet->pNumSetting->nTabValue;
1448 				pNumberSettingsArr->GetObject(i)->pNumSetting->eNumAlign = _pSet->pNumSetting->eNumAlign;
1449 				pNumberSettingsArr->GetObject(i)->pNumSetting->nNumAlignAt = _pSet->pNumSetting->nNumAlignAt;
1450 				pNumberSettingsArr->GetObject(i)->pNumSetting->nNumIndentAt = _pSet->pNumSetting->nNumIndentAt;
1451 			}
1452 		}
1453 	}
1454 	*/
1455 	ImplLoad(String::CreateFromAscii("standard.syb"));
1456 }
1457 
Init()1458 void NumberingTypeMgr::Init()
1459 {
1460 	Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
1461 	Reference < XInterface > xI = xMSF->createInstance(
1462 		::rtl::OUString::createFromAscii( "com.sun.star.text.DefaultNumberingProvider" ) );
1463 	Reference<XDefaultNumberingProvider> xDefNum(xI, UNO_QUERY);
1464 
1465 	if(xDefNum.is())
1466 	{
1467 		Sequence< Sequence< PropertyValue > > aNumberings;
1468 			LanguageType eLang = Application::GetSettings().GetLanguage();
1469 		Locale aLocale = SvxCreateLocale(eLang);
1470 		try
1471 		{
1472 			aNumberings = xDefNum->getDefaultContinuousNumberingLevels( aLocale );
1473 
1474 				sal_Int32 nLength = aNumberings.getLength() > DEFAULT_NUM_VALUSET_COUNT ? DEFAULT_NUM_VALUSET_COUNT :aNumberings.getLength();
1475 
1476 			const Sequence<PropertyValue>* pValuesArr = aNumberings.getConstArray();
1477 			for(sal_Int32 i = 0; i < nLength; i++)
1478 			{
1479 				NumSettings_ImplPtr pNew = lcl_CreateNumberingSettingsPtr(pValuesArr[i]);
1480 				NumberSettings_Impl* pNumEntry = new NumberSettings_Impl;
1481 				pNumEntry->nIndex = i + 1;
1482 				pNumEntry->nIndexDefault = i;
1483 				pNumEntry->pNumSetting = pNew;
1484 				//SetItemText( i + 1, SVX_RESSTR( RID_SVXSTR_SINGLENUM_DESCRIPTIONS + i ));
1485 //				{
1486 //					String sText;
1487 //					//const OUString sValue(C2U("Value"));
1488 //					Reference<XNumberingFormatter> xFormatter(xDefNum, UNO_QUERY);
1489 //					if(xFormatter.is() && aNumberings.getLength() > i)
1490 //					{
1491 
1492 //						for (sal_uInt16 j=0;j<3;j++)
1493 //						{
1494 //							Sequence<PropertyValue> aLevel = aNumberings.getConstArray()[i];
1495 //							try
1496 //							{
1497 //								aLevel.realloc(aLevel.getLength() + 1);
1498 //								PropertyValue& rValue = aLevel.getArray()[aLevel.getLength() - 1];
1499 //								rValue.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value"));
1500 //								rValue.Value <<= (sal_Int32)(j + 1);
1501 
1502 //								if (j!=0)
1503 //									sText += String::CreateFromAscii(" ");
1504 
1505 //								sText+=String(xFormatter->makeNumberingString( aLevel, aLocale ));
1506 //							}
1507 //							catch(Exception&)
1508 //							{
1509 //								DBG_ERROR("Exception in DefaultNumberingProvider::makeNumberingString");
1510 //							}
1511 //						}
1512 //					}
1513 //					String aStrFromRES(SVX_RESSTR( RID_SVXSTR_SINGLENUM_DESCRIPTIONS));
1514 //					String aReplace = String::CreateFromAscii("%NUMBERINGSAMPLE");
1515 //					aStrFromRES.SearchAndReplace(aReplace,sText);
1516 //					pNumEntry->sDescription = aStrFromRES;
1517 //				}
1518 		// End modification
1519 
1520 				pNumEntry->sDescription = SVX_RESSTR( RID_SVXSTR_SINGLENUM_DESCRIPTIONS + i );
1521 				pNumberSettingsArr->Insert(pNumEntry, pNumberSettingsArr->Count());
1522 			}
1523 		}
1524 		catch(Exception&)
1525 		{
1526 		}
1527 	}
1528 }
1529 
GetNBOIndexForNumRule(SvxNumRule & aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex)1530 sal_uInt16 NumberingTypeMgr::GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex)
1531 {
1532 	if ( mLevel == (sal_uInt16)0xFFFF || mLevel > aNum.GetLevelCount() || mLevel == 0)
1533 		return (sal_uInt16)0xFFFF;
1534 
1535 	sal_uInt16 nActLv = IsSingleLevel(mLevel);
1536 
1537 	if ( nActLv == (sal_uInt16)0xFFFF )
1538 		return (sal_uInt16)0xFFFF;
1539 
1540 	SvxNumberFormat aFmt(aNum.GetLevel(nActLv));
1541 	String sPreFix = aFmt.GetPrefix();
1542 	String sSuffix = aFmt.GetSuffix();
1543 	String sEmpty;
1544 		sal_Int16 eNumType = aFmt.GetNumberingType();
1545 
1546 	sal_uInt16 nCount = pNumberSettingsArr->Count();
1547 	for(sal_uInt16 i = nFromIndex; i < nCount; i++)
1548 	{
1549 		NumberSettings_ImplPtr _pSet = pNumberSettingsArr->GetObject(i);
1550 		sal_Int16 eNType = _pSet->pNumSetting->nNumberType;
1551 		String sLocalPreFix = _pSet->pNumSetting->sPrefix.getStr();
1552 		String sLocalSuffix = _pSet->pNumSetting->sSuffix.getStr();
1553 		if (sPreFix.CompareTo(sLocalPreFix)==COMPARE_EQUAL &&
1554 			sSuffix.CompareTo(sLocalSuffix)==COMPARE_EQUAL &&
1555 			eNumType == eNType )
1556 		{
1557 			return i+1;
1558 		}
1559 	}
1560 
1561 
1562 	return (sal_uInt16)0xFFFF;
1563 }
1564 
RelplaceNumRule(SvxNumRule & aNum,sal_uInt16 nIndex,sal_uInt16 mLevel)1565 sal_Bool NumberingTypeMgr::RelplaceNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel)
1566 {
1567 	//if ( mLevel == (sal_uInt16)0xFFFF || mLevel == 0)
1568 	//	return sal_False;
1569 
1570 	//if ( GetNBOIndexForNumRule(aNum,mLevel) != (sal_uInt16)0xFFFF )
1571 	//	return sal_False;
1572 
1573 	sal_uInt16 nActLv = IsSingleLevel(mLevel);
1574 
1575 	if ( nActLv == (sal_uInt16)0xFFFF )
1576 		return sal_False;
1577 
1578 	SvxNumberFormat aFmt(aNum.GetLevel(nActLv));
1579 	//sal_Unicode cPrefix = rtl::OUString(aFmt.GetPrefix()).getStr()[0];
1580 	//sal_Unicode cSuffix = rtl::OUString(aFmt.GetSuffix()).getStr()[0];
1581 	sal_Int16 eNumType = aFmt.GetNumberingType();
1582 
1583 	sal_uInt16 nCount = pNumberSettingsArr->Count();
1584 	if ( nIndex >= nCount )
1585 		return sal_False;
1586 
1587 	NumberSettings_ImplPtr _pSet = pNumberSettingsArr->GetObject(nIndex);
1588 
1589 	_pSet->pNumSetting->sPrefix = aFmt.GetPrefix();
1590 	_pSet->pNumSetting->sSuffix = aFmt.GetSuffix();
1591 	 _pSet->pNumSetting->nNumberType = eNumType;
1592 	_pSet->bIsCustomized = sal_True;
1593 
1594 	SvxNumRule aTmpRule1(aNum);
1595 	SvxNumRule aTmpRule2(aNum);
1596 	ApplyNumRule(aTmpRule1,nIndex,mLevel,true);
1597 	ApplyNumRule(aTmpRule2,nIndex,mLevel,false);
1598 	if (aTmpRule1==aTmpRule2) _pSet->bIsCustomized=false;
1599 	if (_pSet->bIsCustomized) {
1600 		String aStrFromRES = String(SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_NUMBERING_DESCRIPTION));
1601 		String aReplace = String::CreateFromAscii("%LIST_NUM");
1602 		String sNUM = String::CreateFromInt32( nIndex + 1 );
1603 		aStrFromRES.SearchAndReplace(aReplace,sNUM);
1604 		_pSet->sDescription = aStrFromRES;
1605 	} else {
1606 		_pSet->sDescription = GetDescription(nIndex,true);
1607 	}
1608 	ImplStore(String::CreateFromAscii("standard.syb"));
1609 	return sal_True;
1610 }
1611 
ApplyNumRule(SvxNumRule & aNum,sal_uInt16 nIndex,sal_uInt16 mLevel,sal_Bool isDefault,sal_Bool isResetSize)1612 sal_Bool NumberingTypeMgr::ApplyNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel,sal_Bool isDefault,sal_Bool isResetSize)
1613 {
1614 	//if ( mLevel == (sal_uInt16)0xFFFF )
1615 	//	return sal_False;
1616 
1617 	//DBG_ASSERT(pNumSettingsArr->Count() > nIndex, "wrong index");
1618 	if(pNumberSettingsArr->Count() <= nIndex)
1619 		return sal_False;
1620 	NumberSettingsArr_Impl*		pCurrentNumberSettingsArr=pNumberSettingsArr;
1621 	if (isDefault) pCurrentNumberSettingsArr=pDefaultNumberSettingsArr;
1622 	NumberSettings_ImplPtr _pSet = pCurrentNumberSettingsArr->GetObject(nIndex);
1623 	sal_Int16 eNewType = _pSet->pNumSetting->nNumberType;
1624 
1625 	sal_uInt16 nMask = 1;
1626 	String sNumCharFmtName = GetBulCharFmtName();
1627 	for(sal_uInt16 i = 0; i < aNum.GetLevelCount(); i++)
1628 	{
1629 		if(mLevel & nMask)
1630 		{
1631 			SvxNumberFormat aFmt(aNum.GetLevel(i));
1632 			if (eNewType!=aFmt.GetNumberingType()) isResetSize=true;
1633 			aFmt.SetNumberingType(eNewType);
1634 			aFmt.SetPrefix(_pSet->pNumSetting->sPrefix);
1635 			aFmt.SetSuffix(_pSet->pNumSetting->sSuffix);
1636 
1637 			aFmt.SetCharFmtName(sNumCharFmtName);
1638 			if (isResetSize) aFmt.SetBulletRelSize(100);
1639 			aNum.SetLevel(i, aFmt);
1640 		}
1641 		nMask <<= 1 ;
1642 	}
1643 
1644 	return sal_True;
1645 }
GetDescription(sal_uInt16 nIndex,sal_Bool isDefault)1646 String NumberingTypeMgr::GetDescription(sal_uInt16 nIndex,sal_Bool isDefault)
1647 {
1648 	String sRet;
1649 	sal_uInt16 nLength = 0;
1650 	nLength = pNumberSettingsArr->Count();
1651 
1652 	if ( nIndex >= nLength )
1653 		return sRet;
1654 	else
1655 		sRet = pNumberSettingsArr->GetObject(nIndex)->sDescription;
1656 	if (isDefault) sRet = pDefaultNumberSettingsArr->GetObject(nIndex)->sDescription;
1657 
1658 	return sRet;
1659 }
IsCustomized(sal_uInt16 nIndex)1660 sal_Bool NumberingTypeMgr::IsCustomized(sal_uInt16 nIndex)
1661 {
1662 	sal_Bool bRet = sal_False;
1663 	sal_uInt16 nLength = 0;
1664 	nLength = pNumberSettingsArr->Count();
1665 
1666 	if ( nIndex >= nLength )
1667 		bRet = sal_False;
1668 	else
1669 		bRet = pNumberSettingsArr->GetObject(nIndex)->bIsCustomized;
1670 
1671 	return bRet;
1672 }
GetNumCount() const1673 sal_uInt16 NumberingTypeMgr::GetNumCount() const
1674 {
1675 	sal_uInt16 nRet = 0;
1676 	if ( pNumberSettingsArr )
1677 		nRet = pNumberSettingsArr->Count();
1678 
1679 	return nRet;
1680 }
GetNumSettingByIndex(sal_uInt16 nIndex) const1681 NumberSettings_Impl* NumberingTypeMgr::GetNumSettingByIndex(sal_uInt16 nIndex) const
1682 {
1683 	NumberSettings_Impl* pRet = 0;
1684 	if ( pNumberSettingsArr && nIndex< pNumberSettingsArr->Count() )
1685 	{
1686 		pRet = pNumberSettingsArr->GetObject(nIndex);
1687 	}
1688 
1689 	return pRet;
1690 }
1691 /***************************************************************************************************
1692 **********************Multi-level /Outline Type lib*******************************************************
1693 ****************************************************************************************************/
1694 OutlineTypeMgr* OutlineTypeMgr::_instance = 0;
1695 
OutlineTypeMgr(const NBOType aType)1696 OutlineTypeMgr::OutlineTypeMgr(const NBOType aType):
1697 	NBOTypeMgrBase(aType)//,
1698 	//pNumSettingsArrs( new NumSettingsArr_Impl[DEFAULT_NUM_VALUSET_COUNT] )
1699 {
1700 	Init();
1701 	for(sal_Int32 nItem = 0; nItem < DEFAULT_NUM_VALUSET_COUNT; nItem++ )
1702 	{
1703 		pDefaultOutlineSettingsArrs[nItem] = pOutlineSettingsArrs[nItem];
1704 	}
1705 	// Initialize the first time to store the default value. Then do it again for customized value
1706 	Init();
1707 	ImplLoad(String::CreateFromAscii("standard.syc"));
1708 }
1709 
OutlineTypeMgr(const NBOType aType,const SfxItemSet * pArg)1710 OutlineTypeMgr::OutlineTypeMgr(const NBOType aType,const SfxItemSet* pArg):
1711 	NBOTypeMgrBase(aType,pArg)//,
1712 	//pNumSettingsArrs( new NumSettingsArr_Impl[DEFAULT_NUM_VALUSET_COUNT])
1713 {
1714 	Init();
1715 	for(sal_Int32 nItem = 0; nItem < DEFAULT_NUM_VALUSET_COUNT; nItem++ )
1716 	{
1717 		pDefaultOutlineSettingsArrs[nItem] = pOutlineSettingsArrs[nItem];
1718 	}
1719 	// Initialize the first time to store the default value. Then do it again for customized value
1720 	Init();
1721 	ImplLoad(String::CreateFromAscii("standard.syc"));
1722 }
1723 
OutlineTypeMgr(const OutlineTypeMgr & aTypeMgr)1724 OutlineTypeMgr::OutlineTypeMgr(const OutlineTypeMgr& aTypeMgr):
1725 	NBOTypeMgrBase(aTypeMgr)//,
1726 	//pNumSettingsArrs( new NumSettingsArr_Impl[DEFAULT_NUM_VALUSET_COUNT])
1727 {
1728 	Init();
1729 	for(sal_Int32 nItem = 0; nItem < DEFAULT_NUM_VALUSET_COUNT; nItem++ )
1730 	{
1731 		pDefaultOutlineSettingsArrs[nItem] = pOutlineSettingsArrs[nItem];
1732 	}
1733 	// Initialize the first time to store the default value. Then do it again for customized value
1734 	Init();
1735 	ImplLoad(String::CreateFromAscii("standard.syc"));
1736 }
1737 
Init()1738 void OutlineTypeMgr::Init()
1739 {
1740 	Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
1741 	Reference < XInterface > xI = xMSF->createInstance(
1742 		::rtl::OUString::createFromAscii( "com.sun.star.text.DefaultNumberingProvider" ) );
1743 	Reference<XDefaultNumberingProvider> xDefNum(xI, UNO_QUERY);
1744 
1745 	if(xDefNum.is())
1746 	{
1747 		Sequence<Reference<XIndexAccess> > aOutlineAccess;
1748 			LanguageType eLang = Application::GetSettings().GetLanguage();
1749 		Locale aLocale = SvxCreateLocale(eLang);
1750 		try
1751 		{
1752 			aOutlineAccess = xDefNum->getDefaultOutlineNumberings( aLocale );
1753 
1754 			SvxNumRule aDefNumRule( NUM_BULLET_REL_SIZE|NUM_CONTINUOUS|NUM_BULLET_COLOR|NUM_CHAR_TEXT_DISTANCE|NUM_SYMBOL_ALIGNMENT,10, sal_False ,
1755 				SVX_RULETYPE_NUMBERING,SvxNumberFormat::LABEL_ALIGNMENT);
1756 
1757 			for(sal_Int32 nItem = 0;
1758 				nItem < aOutlineAccess.getLength() && nItem < DEFAULT_NUM_VALUSET_COUNT;
1759 				nItem++ )
1760 			{
1761 				pOutlineSettingsArrs[ nItem ] = new OutlineSettings_Impl;
1762 				OutlineSettings_Impl* pItemArr = pOutlineSettingsArrs[ nItem ];
1763 				pItemArr->sDescription = SVX_RESSTR( RID_SVXSTR_OUTLINENUM_DESCRIPTION_0 + nItem );
1764 				pItemArr->pNumSettingsArr = new NumSettingsArr_Impl;
1765 				Reference<XIndexAccess> xLevel = aOutlineAccess.getConstArray()[nItem];
1766 				for(sal_Int32 nLevel = 0; nLevel < xLevel->getCount() && nLevel < 5; nLevel++)
1767 				{
1768 					Any aValueAny = xLevel->getByIndex(nLevel);
1769 					Sequence<PropertyValue> aLevelProps;
1770 					aValueAny >>= aLevelProps;
1771 					NumSettings_ImplPtr pNew = lcl_CreateNumberingSettingsPtr(aLevelProps);
1772 					SvxNumberFormat aNumFmt( aDefNumRule.GetLevel( nLevel) );
1773 					pNew->eLabelFollowedBy = aNumFmt.GetLabelFollowedBy();
1774 					pNew->nTabValue = aNumFmt.GetListtabPos();
1775 					pNew->eNumAlign = aNumFmt.GetNumAdjust();
1776 					pNew->nNumAlignAt = aNumFmt.GetFirstLineIndent();
1777 					pNew->nNumIndentAt = aNumFmt.GetIndentAt();
1778 					pItemArr->pNumSettingsArr->Insert( pNew, pItemArr->pNumSettingsArr->Count() );
1779 				}
1780 			}
1781 		}
1782 		catch(Exception&)
1783 		{
1784 		}
1785 	}
1786 }
1787 
GetNBOIndexForNumRule(SvxNumRule & aNum,sal_uInt16,sal_uInt16 nFromIndex)1788 sal_uInt16 OutlineTypeMgr::GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 /* mLevel */,sal_uInt16 nFromIndex)
1789 {
1790 	sal_uInt16 nLength = sizeof(pOutlineSettingsArrs)/sizeof(OutlineSettings_Impl*);
1791 	for(sal_uInt16 iDex = nFromIndex; iDex < nLength; iDex++)
1792 	{
1793 		sal_Bool bNotMatch = sal_False;
1794 		OutlineSettings_Impl* pItemArr = pOutlineSettingsArrs[iDex];
1795 		sal_uInt16 nCount = pItemArr->pNumSettingsArr->Count();
1796 		for (sal_uInt16 iLevel=0;iLevel < nCount;iLevel++)
1797 		{
1798 			NumSettings_ImplPtr _pSet = pItemArr->pNumSettingsArr->GetObject(iLevel);
1799 			sal_Int16 eNType = _pSet->nNumberType;
1800 
1801 				SvxNumberFormat aFmt(aNum.GetLevel(iLevel));
1802 			String sPreFix = aFmt.GetPrefix();
1803 			String sSuffix = aFmt.GetSuffix();
1804 			String sEmpty;
1805 				sal_Int16 eNumType = aFmt.GetNumberingType();
1806 				if( eNumType == SVX_NUM_CHAR_SPECIAL)
1807 			{
1808 				sal_Unicode cChar = aFmt.GetBulletChar();
1809 				sal_Unicode ccChar = _pSet->sBulletChar.getStr()[0];
1810 				rtl::OUString sFont = _pSet->sBulletFont;
1811 				if ( !((cChar == ccChar) && //pFont && sFont.compareTo(pFont->GetName()) &&
1812 					_pSet->eLabelFollowedBy == aFmt.GetLabelFollowedBy() &&
1813 					_pSet->nTabValue == aFmt.GetListtabPos() &&
1814 					_pSet->eNumAlign == aFmt.GetNumAdjust() &&
1815 					_pSet->nNumAlignAt == aFmt.GetFirstLineIndent() &&
1816 					_pSet->nNumIndentAt == aFmt.GetIndentAt()))
1817 				{
1818 					bNotMatch = sal_True;
1819 					break;
1820 				}
1821 				}else if ((eNumType&(~LINK_TOKEN)) == SVX_NUM_BITMAP ) {
1822 						const SvxBrushItem* pBrsh1 = aFmt.GetBrush();
1823 						const SvxBrushItem* pBrsh2 = _pSet->pBrushItem;
1824 						sal_Bool bIsMatch = false;
1825 						if (pBrsh1==pBrsh2) bIsMatch = true;
1826 						if (pBrsh1 && pBrsh2) {
1827 							const Graphic* pGrf1 = pBrsh1->GetGraphic();;
1828 							const Graphic* pGrf2 = pBrsh2->GetGraphic();;
1829 							if (pGrf1==pGrf2) bIsMatch = true;
1830 							if (pGrf1 && pGrf2) {
1831 								if ( pGrf1->GetBitmap().IsEqual(pGrf2->GetBitmap()) &&
1832 									 _pSet->aSize==aFmt.GetGraphicSize())
1833 									bIsMatch = true;
1834 							}
1835 						}
1836 						if (!bIsMatch) {
1837 							bNotMatch = sal_True;
1838 							break;
1839 						}
1840 				} else
1841 			{
1842 				if (!((sPreFix.CompareTo(_pSet->sPrefix.getStr())==COMPARE_EQUAL) &&
1843 					( sSuffix.CompareTo(_pSet->sSuffix.getStr())==COMPARE_EQUAL ) &&
1844 					eNumType == eNType &&
1845 					_pSet->eLabelFollowedBy == aFmt.GetLabelFollowedBy() &&
1846 					_pSet->nTabValue == aFmt.GetListtabPos() &&
1847 					_pSet->eNumAlign == aFmt.GetNumAdjust() &&
1848 					_pSet->nNumAlignAt == aFmt.GetFirstLineIndent() &&
1849 					_pSet->nNumIndentAt == aFmt.GetIndentAt()))
1850 				{
1851 					bNotMatch = sal_True;
1852 					break;
1853 				}
1854 			}
1855 		}
1856 		if ( !bNotMatch )
1857 			return iDex+1;
1858 	}
1859 
1860 
1861 	return (sal_uInt16)0xFFFF;
1862 }
1863 
RelplaceNumRule(SvxNumRule & aNum,sal_uInt16 nIndex,sal_uInt16 mLevel)1864 sal_Bool OutlineTypeMgr::RelplaceNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel)
1865 {
1866 	//if ( mLevel == 0 || mLevel == (sal_uInt16)0xFFFF )
1867 	//	return sal_False;
1868 
1869 	sal_uInt16 nLength = sizeof(pOutlineSettingsArrs)/sizeof(OutlineSettings_Impl*);
1870 	if ( nIndex >= nLength )
1871 		return sal_False;
1872 
1873 	OutlineSettings_Impl* pItemArr = pOutlineSettingsArrs[nIndex];
1874 	sal_uInt16 nCount = pItemArr->pNumSettingsArr->Count();
1875 	for (sal_uInt16 iLevel=0;iLevel < nCount;iLevel++)
1876 	{
1877 		SvxNumberFormat aFmt(aNum.GetLevel(iLevel));
1878 		sal_Int16 eNumType = aFmt.GetNumberingType();
1879 
1880 		NumSettings_ImplPtr _pSet = pItemArr->pNumSettingsArr->GetObject(iLevel);
1881 
1882 		_pSet->eLabelFollowedBy = aFmt.GetLabelFollowedBy();
1883 		_pSet->nTabValue = aFmt.GetListtabPos();
1884 		_pSet->eNumAlign = aFmt.GetNumAdjust();
1885 		_pSet->nNumAlignAt = aFmt.GetFirstLineIndent();
1886 		_pSet->nNumIndentAt = aFmt.GetIndentAt();
1887 
1888 		if( eNumType == SVX_NUM_CHAR_SPECIAL)
1889 		{
1890 			sal_Unicode cChar = aFmt.GetBulletChar();
1891 			OUString sChar(cChar);
1892 			_pSet->sBulletChar = sChar;//OUString(cChar);
1893 			if ( aFmt.GetBulletFont() )
1894 				_pSet->sBulletFont = rtl::OUString(aFmt.GetBulletFont()->GetName());
1895 			_pSet->nNumberType = eNumType;
1896 			pItemArr->bIsCustomized = sal_True;
1897 		}else if ((eNumType&(~LINK_TOKEN)) == SVX_NUM_BITMAP ) {
1898 			if (_pSet->pBrushItem) {
1899 				delete (_pSet->pBrushItem);
1900 				_pSet->pBrushItem=NULL;
1901 			}
1902 			if (aFmt.GetBrush())
1903 				_pSet->pBrushItem = new SvxBrushItem(*aFmt.GetBrush());
1904 			_pSet->aSize = aFmt.GetGraphicSize();
1905 			_pSet->nNumberType = eNumType;
1906 		} else
1907 		{
1908 			_pSet->sPrefix = aFmt.GetPrefix();
1909 			_pSet->sSuffix = aFmt.GetSuffix();
1910 			_pSet->nNumberType = eNumType;
1911 			if ( aFmt.GetBulletFont() )
1912 				_pSet->sBulletFont = rtl::OUString(aFmt.GetBulletFont()->GetName());
1913 			pItemArr->bIsCustomized = sal_True;
1914 		}
1915 	}
1916 	SvxNumRule aTmpRule1(aNum);
1917 	SvxNumRule aTmpRule2(aNum);
1918 	ApplyNumRule(aTmpRule1,nIndex,mLevel,true);
1919 	ApplyNumRule(aTmpRule2,nIndex,mLevel,false);
1920 	if (aTmpRule1==aTmpRule2) pItemArr->bIsCustomized=false;
1921 	if (pItemArr->bIsCustomized) {
1922 		String aStrFromRES = String(SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_MULTILEVEL_DESCRIPTION));
1923 		String aReplace = String::CreateFromAscii("%LIST_NUM");
1924 		String sNUM = String::CreateFromInt32( nIndex + 1 );
1925 		aStrFromRES.SearchAndReplace(aReplace,sNUM);
1926 		pItemArr->sDescription = aStrFromRES;
1927 	} else {
1928 		pItemArr->sDescription = GetDescription(nIndex,true);
1929 	}
1930 	ImplStore(String::CreateFromAscii("standard.syc"));
1931 	return sal_True;
1932 }
1933 
ApplyNumRule(SvxNumRule & aNum,sal_uInt16 nIndex,sal_uInt16,sal_Bool isDefault,sal_Bool isResetSize)1934 sal_Bool OutlineTypeMgr::ApplyNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 /* mLevel */,sal_Bool isDefault,sal_Bool isResetSize)
1935 {
1936 	//if ( mLevel == (sal_uInt16)0xFFFF )
1937 	//	return sal_False;
1938 
1939 	DBG_ASSERT(DEFAULT_NUM_VALUSET_COUNT > nIndex, "wrong index");
1940 	if(DEFAULT_NUM_VALUSET_COUNT <= nIndex)
1941 		return sal_False;
1942 
1943 	const FontList* pList = 0;
1944 
1945 	OutlineSettings_Impl* pItemArr = pOutlineSettingsArrs[nIndex];
1946 	if (isDefault) pItemArr=pDefaultOutlineSettingsArrs[nIndex];
1947 
1948 	//Font& rActBulletFont = lcl_GetDefaultBulletFont();
1949 	NumSettingsArr_Impl *pNumSettingsArr=pItemArr->pNumSettingsArr;
1950 
1951 	NumSettings_ImplPtr pLevelSettings = 0;
1952 	String sBulletCharFmtName = GetBulCharFmtName();
1953 	for(sal_uInt16 i = 0; i < aNum.GetLevelCount(); i++)
1954 	{
1955 		if(pNumSettingsArr->Count() > i)
1956 			pLevelSettings = pNumSettingsArr->GetObject(i);
1957 
1958 		if(!pLevelSettings)
1959 			break;
1960 
1961 		SvxNumberFormat aFmt(aNum.GetLevel(i));
1962 		//aFmt.SetBulletFont(&pLevelSettings->aFont);
1963 		Font& rActBulletFont = lcl_GetDefaultBulletFont();
1964 		if (pLevelSettings->nNumberType !=aFmt.GetNumberingType()) isResetSize=true;
1965 		aFmt.SetNumberingType( pLevelSettings->nNumberType );
1966 		sal_uInt16 nUpperLevelOrChar = (sal_uInt16)pLevelSettings->nParentNumbering;
1967 		if(aFmt.GetNumberingType() == SVX_NUM_CHAR_SPECIAL)
1968 		{
1969 			if( pLevelSettings->sBulletFont.getLength() &&
1970 				pLevelSettings->sBulletFont.compareTo(rActBulletFont.GetName()))
1971 			{
1972 				// search for the font
1973 				if(!pList)
1974 				{
1975 					SfxObjectShell* pCurDocShell = SfxObjectShell::Current();
1976 					const SvxFontListItem* pFontListItem = (const SvxFontListItem* )pCurDocShell->GetItem( SID_ATTR_CHAR_FONTLIST );
1977 					pList = pFontListItem ? pFontListItem->GetFontList() : 0;
1978 				}
1979 				if(pList && pList->IsAvailable( pLevelSettings->sBulletFont ) )
1980 				{
1981 			FontInfo aInfo = pList->Get(pLevelSettings->sBulletFont,WEIGHT_NORMAL, ITALIC_NONE);
1982 			Font aFont(aInfo);
1983 			aFmt.SetBulletFont(&aFont);
1984 			}
1985 				else
1986 				{
1987 					// if it cannot be found then create a new one
1988 					Font aCreateFont( pLevelSettings->sBulletFont,String(), Size( 0, 14 ) );
1989 					aCreateFont.SetCharSet( RTL_TEXTENCODING_DONTKNOW );
1990 					aCreateFont.SetFamily( FAMILY_DONTKNOW );
1991 					aCreateFont.SetPitch( PITCH_DONTKNOW );
1992 					aCreateFont.SetWeight( WEIGHT_DONTKNOW );
1993 					aCreateFont.SetTransparent( sal_True );
1994 					aFmt.SetBulletFont( &aCreateFont );
1995 				}
1996 			}else
1997 			aFmt.SetBulletFont( &rActBulletFont );
1998 
1999 			sal_Unicode cChar = 0;
2000 			if( pLevelSettings->sBulletChar.getLength() )
2001 				cChar = pLevelSettings->sBulletChar.getStr()[0];
2002 			if( Application::GetSettings().GetLayoutRTL() )
2003 			{
2004 					if( 0 == i && cChar == BulletsTypeMgr::aDynamicBulletTypes[5] )
2005 					cChar = BulletsTypeMgr::aDynamicRTLBulletTypes[5];
2006 				else if( 1 == i )
2007 				{
2008 					const SvxNumberFormat& numberFmt = aNum.GetLevel(0);
2009 					if( numberFmt.GetBulletChar() == BulletsTypeMgr::aDynamicRTLBulletTypes[5] )
2010 						cChar = BulletsTypeMgr::aDynamicRTLBulletTypes[4];
2011 				}
2012 			}
2013 
2014 			aFmt.SetBulletChar(cChar);
2015 			aFmt.SetCharFmtName( sBulletCharFmtName );
2016 			if (isResetSize) aFmt.SetBulletRelSize(45);
2017 		}else if ((aFmt.GetNumberingType()&(~LINK_TOKEN)) == SVX_NUM_BITMAP ) {
2018 			if (pLevelSettings->pBrushItem) {
2019 					const Graphic* pGrf = pLevelSettings->pBrushItem->GetGraphic();;
2020 					Size aSize = pLevelSettings->aSize;
2021 					sal_Int16 eOrient = text::VertOrientation::LINE_CENTER;
2022 					if (!isResetSize && aFmt.GetGraphicSize()!=Size(0,0)) aSize=aFmt.GetGraphicSize();
2023 					else {
2024 						if (aSize.Width()==0 && aSize.Height()==0 && pGrf) {
2025 							aSize = SvxNumberFormat::GetGraphicSizeMM100( pGrf );
2026 						}
2027 					}
2028 					aSize = OutputDevice::LogicToLogic(aSize, MAP_100TH_MM, (MapUnit)GetMapUnit());
2029 					aFmt.SetGraphicBrush( pLevelSettings->pBrushItem, &aSize, &eOrient );
2030 			}
2031 		} else
2032 		{
2033 			aFmt.SetIncludeUpperLevels(sal::static_int_cast< sal_uInt8 >(0 != nUpperLevelOrChar ? aNum.GetLevelCount() : 0));
2034 			aFmt.SetCharFmtName(sBulletCharFmtName);
2035 			if (isResetSize) aFmt.SetBulletRelSize(100);
2036 		}
2037 		if(pNumSettingsArr->Count() > i) {
2038 			aFmt.SetLabelFollowedBy(pLevelSettings->eLabelFollowedBy);
2039 			aFmt.SetListtabPos(pLevelSettings->nTabValue);
2040 			aFmt.SetNumAdjust(pLevelSettings->eNumAlign);
2041 			aFmt.SetFirstLineIndent(pLevelSettings->nNumAlignAt);
2042 			aFmt.SetIndentAt(pLevelSettings->nNumIndentAt);
2043 		}
2044 		aFmt.SetPrefix(pLevelSettings->sPrefix);
2045 		aFmt.SetSuffix(pLevelSettings->sSuffix);
2046 		aNum.SetLevel(i, aFmt);
2047 	}
2048 
2049 	return sal_True;
2050 }
GetDescription(sal_uInt16 nIndex,sal_Bool isDefault)2051 String OutlineTypeMgr::GetDescription(sal_uInt16 nIndex,sal_Bool isDefault)
2052 {
2053 	String sRet;
2054 	sal_uInt16 nLength = 0;
2055 	nLength = sizeof(pOutlineSettingsArrs)/sizeof(OutlineSettings_Impl*);
2056 
2057 	if ( nIndex >= nLength )
2058 		return sRet;
2059 	else
2060 	{
2061 		OutlineSettings_Impl* pItemArr = pOutlineSettingsArrs[nIndex];
2062 		if (isDefault) pItemArr = pDefaultOutlineSettingsArrs[nIndex];
2063 		if ( pItemArr )
2064 		{
2065 			sRet = pItemArr->sDescription;
2066 		};
2067 	}
2068 	return sRet;
2069 }
IsCustomized(sal_uInt16 nIndex)2070 sal_Bool OutlineTypeMgr::IsCustomized(sal_uInt16 nIndex)
2071 {
2072 	sal_Bool bRet = sal_False;
2073 
2074 	sal_uInt16 nLength = 0;
2075 	nLength = sizeof(pOutlineSettingsArrs)/sizeof(OutlineSettings_Impl*);
2076 
2077 	if ( nIndex >= nLength )
2078 		return bRet;
2079 	else
2080 	{
2081 		OutlineSettings_Impl* pItemArr = pOutlineSettingsArrs[nIndex];
2082 		if ( pItemArr )
2083 		{
2084 			bRet = pItemArr->bIsCustomized;
2085 		};
2086 	}
2087 
2088 	return bRet;
2089 }
2090 
2091 
2092 }}
2093 
2094 /* vim: set noet sw=4 ts=4: */
2095