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