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