1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include <svx/nbdtmg.hxx>
20 #include <svx/svxids.hrc>
21 #include <vcl/svapp.hxx>
22 #include <svl/itemset.hxx>
23 #include <sfx2/request.hxx>
24 #include <svl/stritem.hxx>
25 #include <editeng/unolingu.hxx>
26 #include <svtools/ctrltool.hxx>
27 #include <sfx2/objsh.hxx>
28 #include <editeng/flstitem.hxx>
29 #include <svl/itempool.hxx>
30 #include <vcl/outdev.hxx>
31 #include <svx/gallery.hxx>
32 #include <editeng/brushitem.hxx>
33 #include <svx/dialmgr.hxx>
34 #include <svx/dialogs.hrc>
35 #include <vcl/graph.hxx>
36 #include <vcl/settings.hxx>
38 #include <unotools/streamwrap.hxx>
39 #include <unotools/ucbstreamhelper.hxx>
40 #include <unotools/pathoptions.hxx>
41 #include <editeng/eeitem.hxx>
43 #include <com/sun/star/text/HoriOrientation.hpp>
44 #include <com/sun/star/text/VertOrientation.hpp>
45 #include <com/sun/star/text/RelOrientation.hpp>
46 #include <com/sun/star/style/NumberingType.hpp>
47 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
48 #include <com/sun/star/container/XIndexAccess.hpp>
49 #include <com/sun/star/text/DefaultNumberingProvider.hpp>
50 #include <com/sun/star/text/XNumberingFormatter.hpp>
51 #include <com/sun/star/beans/PropertyValue.hpp>
52 #include <comphelper/processfactory.hxx>
53 #include <com/sun/star/text/XNumberingTypeInfo.hpp>
56 using namespace com::sun::star
;
57 using namespace com::sun::star::uno
;
58 using namespace com::sun::star::beans
;
59 using namespace com::sun::star::lang
;
60 using namespace com::sun::star::text
;
61 using namespace com::sun::star::container
;
62 using namespace com::sun::star::style
;
64 namespace svx
{ namespace sidebar
{
65 #define MAX_VALUESET_GRAPHIC 30
67 vcl::Font
& lcl_GetDefaultBulletFont()
69 static bool bInit
= false;
70 static vcl::Font
aDefBulletFont( "StarSymbol", "", Size( 0, 14 ) );
73 aDefBulletFont
.SetCharSet( RTL_TEXTENCODING_SYMBOL
);
74 aDefBulletFont
.SetFamily( FAMILY_DONTKNOW
);
75 aDefBulletFont
.SetPitch( PITCH_DONTKNOW
);
76 aDefBulletFont
.SetWeight( WEIGHT_DONTKNOW
);
77 aDefBulletFont
.SetTransparent( true );
80 return aDefBulletFont
;
83 static const sal_Unicode aDefaultBulletTypes
[] =
95 NumSettings_ImplPtr
lcl_CreateNumberingSettingsPtr(const Sequence
<PropertyValue
>& rLevelProps
)
97 const PropertyValue
* pValues
= rLevelProps
.getConstArray();
98 NumSettings_ImplPtr pNew
= new NumSettings_Impl
;
99 for(sal_Int32 j
= 0; j
< rLevelProps
.getLength(); j
++)
101 if(pValues
[j
].Name
== "NumberingType")
102 pValues
[j
].Value
>>= pNew
->nNumberType
;
103 else if(pValues
[j
].Name
== "Prefix")
104 pValues
[j
].Value
>>= pNew
->sPrefix
;
105 else if(pValues
[j
].Name
== "Suffix")
106 pValues
[j
].Value
>>= pNew
->sSuffix
;
107 else if(pValues
[j
].Name
== "ParentNumbering")
108 pValues
[j
].Value
>>= pNew
->nParentNumbering
;
109 else if(pValues
[j
].Name
== "BulletChar")
110 pValues
[j
].Value
>>= pNew
->sBulletChar
;
111 else if(pValues
[j
].Name
== "BulletFontName")
112 pValues
[j
].Value
>>= pNew
->sBulletFont
;
114 const sal_Unicode cLocalPrefix
= pNew
->sPrefix
.getLength() ? pNew
->sPrefix
[0] : 0;
115 const sal_Unicode cLocalSuffix
= pNew
->sSuffix
.getLength() ? pNew
->sSuffix
[0] : 0;
117 if( cLocalPrefix
== ' ') pNew
->sPrefix
=aEmptyStr
;
118 if( cLocalSuffix
== ' ') pNew
->sSuffix
=aEmptyStr
;
122 sal_uInt16
NBOTypeMgrBase:: IsSingleLevel(sal_uInt16 nCurLevel
)
124 sal_uInt16 nLv
= (sal_uInt16
)0xFFFF;
125 sal_uInt16 nCount
= 0;
126 sal_uInt16 nMask
= 1;
127 for( sal_uInt16 i
= 0; i
< SVX_MAX_NUM
; i
++ )
129 if(nCurLevel
& nMask
)
140 return (sal_uInt16
)0xFFFF;
143 void NBOTypeMgrBase::StoreBulCharFmtName_impl() {
146 SfxAllItemSet
aSet(*pSet
);
147 SFX_ITEMSET_ARG(&aSet
,pBulletCharFmt
,SfxStringItem
,SID_BULLET_CHAR_FMT
,false);
149 if ( pBulletCharFmt
)
151 aNumCharFmtName
= pBulletCharFmt
->GetValue();
155 void NBOTypeMgrBase::ImplLoad(const OUString
& filename
)
158 SfxMapUnit eOldCoreUnit
=eCoreUnit
;
159 eCoreUnit
= SFX_MAPUNIT_100TH_MM
;
160 INetURLObject
aFile( SvtPathOptions().GetPalettePath() );
161 aFile
.Append( filename
);
162 std::unique_ptr
<SvStream
> xIStm(::utl::UcbStreamHelper::CreateStream( aFile
.GetMainURL( INetURLObject::NO_DECODE
), StreamMode::READ
));
164 sal_uInt32 nVersion
= 0;
165 sal_Int32 nNumIndex
= 0;
166 xIStm
->ReadUInt32( nVersion
);
167 if (nVersion
==DEFAULT_NUMBERING_CACHE_FORMAT_VERSION
) //first version
169 xIStm
->ReadInt32( nNumIndex
);
170 sal_uInt16 mLevel
= 0x1;
171 while (nNumIndex
>=0 && nNumIndex
<DEFAULT_NUM_VALUSET_COUNT
) {
172 SvxNumRule
aNum(*xIStm
);
173 //bullet color in font properties is not stored correctly. Need set tranparency bits manually
174 for(sal_uInt16 i
= 0; i
< aNum
.GetLevelCount(); i
++)
176 SvxNumberFormat
aFmt(aNum
.GetLevel(i
));
177 if (aFmt
.GetBulletFont()) {
178 vcl::Font
aFont(*aFmt
.GetBulletFont());
179 Color c
=aFont
.GetColor();
180 c
.SetTransparency(0xFF);
182 aFmt
.SetBulletFont(&aFont
);
183 aNum
.SetLevel(i
, aFmt
);
186 RelplaceNumRule(aNum
,nNumIndex
,mLevel
);
187 xIStm
->ReadInt32( nNumIndex
);
191 eCoreUnit
= eOldCoreUnit
;
194 void NBOTypeMgrBase::ImplStore(const OUString
& filename
)
196 if (bIsLoading
) return;
197 SfxMapUnit eOldCoreUnit
=eCoreUnit
;
198 eCoreUnit
= SFX_MAPUNIT_100TH_MM
;
199 INetURLObject
aFile( SvtPathOptions().GetPalettePath() );
200 aFile
.Append( filename
);
201 std::unique_ptr
<SvStream
> xOStm(::utl::UcbStreamHelper::CreateStream( aFile
.GetMainURL( INetURLObject::NO_DECODE
), StreamMode::WRITE
));
205 nVersion
= DEFAULT_NUMBERING_CACHE_FORMAT_VERSION
;
206 xOStm
->WriteUInt32( nVersion
);
207 for(sal_Int32 nItem
= 0; nItem
< DEFAULT_NUM_VALUSET_COUNT
; nItem
++ ) {
208 if (IsCustomized(nItem
)) {
209 SvxNumRule
aDefNumRule( SvxNumRuleFlags::BULLET_REL_SIZE
| SvxNumRuleFlags::CONTINUOUS
| SvxNumRuleFlags::BULLET_COLOR
|
210 SvxNumRuleFlags::CHAR_TEXT_DISTANCE
| SvxNumRuleFlags::SYMBOL_ALIGNMENT
,
212 SvxNumRuleType::NUMBERING
, SvxNumberFormat::LABEL_ALIGNMENT
);
213 sal_uInt16 mLevel
= 0x1;
214 xOStm
->WriteInt32( nItem
);
215 ApplyNumRule(aDefNumRule
,nItem
,mLevel
,false,true);
216 aDefNumRule
.Store(*xOStm
);
220 xOStm
->WriteInt32( nNumIndex
); //write end flag
222 eCoreUnit
= eOldCoreUnit
;
225 void NBOTypeMgrBase::StoreMapUnit_impl() {
228 const SfxPoolItem
* pItem
;
229 SfxItemState eState
= pSet
->GetItemState(SID_ATTR_NUMBERING_RULE
, false, &pItem
);
230 if(eState
== SfxItemState::SET
)
232 eCoreUnit
= pSet
->GetPool()->GetMetric(pSet
->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE
));
234 //sd use different sid for numbering rule
235 eState
= pSet
->GetItemState(EE_PARA_NUMBULLET
, false, &pItem
);
236 if(eState
== SfxItemState::SET
)
238 eCoreUnit
= pSet
->GetPool()->GetMetric(pSet
->GetPool()->GetWhich(EE_PARA_NUMBULLET
));
243 // Character Bullet Type lib
244 BulletsSettings_Impl
* BulletsTypeMgr::pActualBullets
[] ={0,0,0,0,0,0,0,0};
245 sal_Unicode
BulletsTypeMgr::aDynamicBulletTypes
[]={' ',' ',' ',' ',' ',' ',' ',' '};
246 sal_Unicode
BulletsTypeMgr::aDynamicRTLBulletTypes
[]={' ',' ',' ',' ',' ',' ',' ',' '};
248 BulletsTypeMgr::BulletsTypeMgr()
249 : NBOTypeMgrBase(eNBOType::BULLETS
)
254 BulletsTypeMgr::BulletsTypeMgr(const BulletsTypeMgr
& aTypeMgr
):
255 NBOTypeMgrBase(aTypeMgr
)
257 for (sal_uInt16 i
=0;i
<DEFAULT_BULLET_TYPES
;i
++)
259 pActualBullets
[i
]->bIsCustomized
= aTypeMgr
.pActualBullets
[i
]->bIsCustomized
;
260 pActualBullets
[i
]->cBulletChar
= aTypeMgr
.pActualBullets
[i
]->cBulletChar
;
261 pActualBullets
[i
]->aFont
= aTypeMgr
.pActualBullets
[i
]->aFont
;
262 pActualBullets
[i
]->sDescription
= aTypeMgr
. pActualBullets
[i
]->sDescription
;
263 pActualBullets
[i
]->eType
= aTypeMgr
. pActualBullets
[i
]->eType
;
267 class theBulletsTypeMgr
: public rtl::Static
<BulletsTypeMgr
, theBulletsTypeMgr
> {};
269 BulletsTypeMgr
& BulletsTypeMgr::GetInstance()
271 return theBulletsTypeMgr::get();
274 void BulletsTypeMgr::Init()
276 vcl::Font
& rActBulletFont
= lcl_GetDefaultBulletFont();
278 for (sal_uInt16 i
=0;i
<DEFAULT_BULLET_TYPES
;i
++)
280 pActualBullets
[i
] = new BulletsSettings_Impl(eNBType::BULLETS
);
281 pActualBullets
[i
]->cBulletChar
= aDefaultBulletTypes
[i
];
282 pActualBullets
[i
]->aFont
=rActBulletFont
;
283 pActualBullets
[i
]->sDescription
= SVX_RESSTR( RID_SVXSTR_BULLET_DESCRIPTION_0
+ i
);
286 sal_uInt16
BulletsTypeMgr::GetNBOIndexForNumRule(SvxNumRule
& aNum
,sal_uInt16 mLevel
,sal_uInt16 nFromIndex
)
288 if ( mLevel
== (sal_uInt16
)0xFFFF || mLevel
== 0)
289 return (sal_uInt16
)0xFFFF;
290 //if ( !lcl_IsNumFmtSet(pNR, mLevel) ) return (sal_uInt16)0xFFFF;
292 sal_uInt16 nActLv
= IsSingleLevel(mLevel
);
294 if ( nActLv
== (sal_uInt16
)0xFFFF )
295 return (sal_uInt16
)0xFFFF;
297 SvxNumberFormat
aFmt(aNum
.GetLevel(nActLv
));
298 sal_Unicode cChar
= aFmt
.GetBulletChar();
299 //const vcl::Font* pFont = aFmt.GetBulletFont();
300 //sal_uInt16 nLength = 0;
301 /*if( AllSettings::GetLayoutRTL() )
303 nLength = sizeof(aDynamicRTLBulletTypes)/sizeof(sal_Unicode);
304 for(sal_uInt16 i = 0; i < nLength; i++)
306 if ( cChar == aDynamicRTLBulletTypes[i] ||
307 (cChar == 9830 && 57356 == aDynamicRTLBulletTypes[i]) ||
308 (cChar == 9632 && 57354 == aDynamicRTLBulletTypes[i]) )
315 nLength = sizeof(aDynamicBulletTypes)/sizeof(sal_Unicode);
316 for(sal_uInt16 i = 0; i < nLength; i++)
318 if ( cChar == aDynamicBulletTypes[i] ||
319 (cChar == 9830 && 57356 == aDynamicBulletTypes[i]) ||
320 (cChar == 9632 && 57354 == aDynamicBulletTypes[i]) )
326 //nLength = sizeof(pActualBullets)/sizeof(BulletsSettings_Impl);
327 for(sal_uInt16 i
= nFromIndex
; i
< DEFAULT_BULLET_TYPES
; i
++)
329 if ( (cChar
== pActualBullets
[i
]->cBulletChar
||
330 (cChar
== 9830 && 57356 == pActualBullets
[i
]->cBulletChar
) ||
331 (cChar
== 9632 && 57354 == pActualBullets
[i
]->cBulletChar
)))
337 return (sal_uInt16
)0xFFFF;
340 bool BulletsTypeMgr::RelplaceNumRule(SvxNumRule
& aNum
, sal_uInt16 nIndex
, sal_uInt16 mLevel
)
342 if ( mLevel
== (sal_uInt16
)0xFFFF || mLevel
== 0)
345 if ( GetNBOIndexForNumRule(aNum
,mLevel
) != (sal_uInt16
)0xFFFF )
348 sal_uInt16 nActLv
= IsSingleLevel(mLevel
);
350 if ( nActLv
== (sal_uInt16
)0xFFFF )
353 SvxNumberFormat
aFmt(aNum
.GetLevel(nActLv
));
354 sal_Unicode cChar
= aFmt
.GetBulletChar();
355 const vcl::Font
* pFont
= aFmt
.GetBulletFont();
356 //sal_uInt16 nLength = 0;
357 /*if( AllSettings::GetLayoutRTL() )
359 nLength = sizeof(aDynamicRTLBulletTypes)/sizeof(sal_Unicode);
361 if ( nIndex >= nLength )
364 aDynamicRTLBulletTypes[nIndex] = cChar;
367 nLength = sizeof(aDynamicBulletTypes)/sizeof(sal_Unicode);
369 if ( nIndex >= nLength )
372 aDynamicBulletTypes[nIndex] = cChar;
374 //nLength = sizeof(pActualBullets)/sizeof(BulletsSettings_Impl);
375 if ( nIndex
>= DEFAULT_BULLET_TYPES
)
378 pActualBullets
[nIndex
]->cBulletChar
= cChar
;
380 pActualBullets
[nIndex
]->aFont
= *pFont
;
381 pActualBullets
[nIndex
]->bIsCustomized
= true;
383 OUString aStrFromRES
= SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_BULLET_DESCRIPTION
);
384 OUString aReplace
= "%LIST_NUM";
385 OUString sNUM
= OUString::number( nIndex
+ 1 );
386 aStrFromRES
= aStrFromRES
.replaceFirst(aReplace
,sNUM
);
387 pActualBullets
[nIndex
]->sDescription
= aStrFromRES
;
392 bool BulletsTypeMgr::ApplyNumRule(SvxNumRule
& aNum
, sal_uInt16 nIndex
, sal_uInt16 mLevel
, bool /*isDefault*/, bool isResetSize
)
394 //if ( mLevel == (sal_uInt16)0xFFFF )
398 //sal_uInt16 nLength = 0;
399 /*if( AllSettings::GetLayoutRTL() )
401 nLength = sizeof(aDynamicRTLBulletTypes)/sizeof(sal_Unicode);
403 if ( nIndex >= nLength )
406 cChar = aDynamicRTLBulletTypes[nIndex];
409 nLength = sizeof(aDynamicBulletTypes)/sizeof(sal_Unicode);
411 if ( nIndex >= nLength )
414 cChar = aDynamicBulletTypes[nIndex];
416 //nLength = sizeof(pActualBullets)/sizeof(BulletsSettings_Impl);
417 if ( nIndex
>= DEFAULT_BULLET_TYPES
)
419 cChar
= pActualBullets
[nIndex
]->cBulletChar
;
420 //vcl::Font& rActBulletFont = lcl_GetDefaultBulletFont();
421 vcl::Font rActBulletFont
= pActualBullets
[nIndex
]->aFont
;
423 sal_uInt16 nMask
= 1;
424 OUString sBulletCharFormatName
= GetBulCharFmtName();
425 for(sal_uInt16 i
= 0; i
< aNum
.GetLevelCount(); i
++)
429 SvxNumberFormat
aFmt(aNum
.GetLevel(i
));
430 aFmt
.SetNumberingType( SVX_NUM_CHAR_SPECIAL
);
431 aFmt
.SetBulletFont(&rActBulletFont
);
432 aFmt
.SetBulletChar(cChar
);
433 aFmt
.SetCharFormatName(sBulletCharFormatName
);
435 aFmt
.SetPrefix( aEmptyStr
);
436 aFmt
.SetSuffix( aEmptyStr
);
437 if (isResetSize
) aFmt
.SetBulletRelSize(45);
438 aNum
.SetLevel(i
, aFmt
);
446 OUString
BulletsTypeMgr::GetDescription(sal_uInt16 nIndex
, bool /*isDefault*/)
449 //sal_uInt16 nLength = 0;
450 //nLength = sizeof(pActualBullets)/sizeof(BulletsSettings_Impl);
452 if ( nIndex
>= DEFAULT_BULLET_TYPES
)
455 sRet
= pActualBullets
[nIndex
]->sDescription
;
460 bool BulletsTypeMgr::IsCustomized(sal_uInt16 nIndex
)
463 //sal_uInt16 nLength = 0;
464 //nLength = sizeof(pActualBullets)/sizeof(BulletsSettings_Impl);
466 if ( nIndex
>= DEFAULT_BULLET_TYPES
)
469 bRet
= pActualBullets
[nIndex
]->bIsCustomized
;
474 sal_Unicode
BulletsTypeMgr::GetBulChar(sal_uInt16 nIndex
)
477 //sal_uInt16 nLength = 0;
478 //nLength = sizeof(pActualBullets)/sizeof(BulletsSettings_Impl);
480 if ( nIndex
>= DEFAULT_BULLET_TYPES
)
483 cChar
= pActualBullets
[nIndex
]->cBulletChar
;
485 /*if( AllSettings::GetLayoutRTL() )
487 nLength = sizeof(aDynamicRTLBulletTypes)/sizeof(sal_Unicode);
489 if ( nIndex >= nLength )
492 cChar = aDynamicRTLBulletTypes[nIndex];
495 nLength = sizeof(aDynamicBulletTypes)/sizeof(sal_Unicode);
497 if ( nIndex >= nLength )
500 cChar = aDynamicBulletTypes[nIndex];
505 vcl::Font
BulletsTypeMgr::GetBulCharFont(sal_uInt16 nIndex
)
508 if ( nIndex
>= DEFAULT_BULLET_TYPES
)
509 aRet
= lcl_GetDefaultBulletFont();
511 aRet
= pActualBullets
[nIndex
]->aFont
;
515 // Graphic Bullet Type lib
516 GraphyicBulletsTypeMgr::GraphyicBulletsTypeMgr()
517 : NBOTypeMgrBase(eNBOType::BULLETS
)
522 GraphyicBulletsTypeMgr::GraphyicBulletsTypeMgr(const GraphyicBulletsTypeMgr
& aTypeMgr
):
523 NBOTypeMgrBase(aTypeMgr
)
525 for (size_t i
=0, n
= aTypeMgr
.aGrfDataLst
.size(); i
< n
; ++i
)
527 GrfBulDataRelation
* pEntry
= new GrfBulDataRelation(eNBType::GRAPHICBULLETS
);
528 GrfBulDataRelation
* pSrcEntry
= aTypeMgr
.aGrfDataLst
[i
];
531 pEntry
->bIsCustomized
= pSrcEntry
->bIsCustomized
;
532 pEntry
->nTabIndex
= pSrcEntry
->nTabIndex
;
533 pEntry
->nGallaryIndex
= pSrcEntry
->nGallaryIndex
;
534 pEntry
->sGrfName
= pSrcEntry
->sGrfName
;
535 pEntry
->sDescription
= pSrcEntry
->sDescription
;
536 aGrfDataLst
.push_back(pEntry
);
543 GraphyicBulletsTypeMgr::~GraphyicBulletsTypeMgr()
545 for (size_t i
= 0; i
< aGrfDataLst
.size(); ++i
)
546 delete aGrfDataLst
[i
];
549 class theGraphyicBulletsTypeMgr
: public rtl::Static
<GraphyicBulletsTypeMgr
, theGraphyicBulletsTypeMgr
> {};
551 GraphyicBulletsTypeMgr
& GraphyicBulletsTypeMgr::GetInstance()
553 return theGraphyicBulletsTypeMgr::get();
556 void GraphyicBulletsTypeMgr::Init()
558 std::vector
<OUString
> aGrfNames
;
559 GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS
, aGrfNames
);
560 for(sal_uInt16 i
= 0; i
< aGrfNames
.size(); i
++)
562 OUString sGrfNm
= aGrfNames
[i
];
563 INetURLObject
aObj(sGrfNm
);
564 if(aObj
.GetProtocol() == INetProtocol::File
)
565 sGrfNm
= aObj
.PathToFileName();
567 GrfBulDataRelation
* pEntry
= new GrfBulDataRelation(eNBType::GRAPHICBULLETS
);
568 pEntry
->nTabIndex
= i
+1;
569 pEntry
->nGallaryIndex
= i
;
570 pEntry
->sGrfName
= sGrfNm
;
572 if( i
< MAX_VALUESET_GRAPHIC
)
574 pEntry
->sDescription
= SVX_RESSTR( RID_SVXSTR_GRAPHICS_DESCRIPTIONS
+ i
);
577 pEntry
->sDescription
= sGrfNm
;
580 aGrfDataLst
.push_back(pEntry
);
583 sal_uInt16
GraphyicBulletsTypeMgr::GetNBOIndexForNumRule(SvxNumRule
& aNum
,sal_uInt16 mLevel
,sal_uInt16
/*nFromIndex*/)
585 if ( mLevel
== (sal_uInt16
)0xFFFF || mLevel
== 0)
586 return (sal_uInt16
)0xFFFF;
588 sal_uInt16 nActLv
= IsSingleLevel(mLevel
);
590 if ( nActLv
== (sal_uInt16
)0xFFFF )
591 return (sal_uInt16
)0xFFFF;
593 SvxNumberFormat
aFmt(aNum
.GetLevel(nActLv
));
594 const SvxBrushItem
* pBrsh
= aFmt
.GetBrush();
595 const Graphic
* pGrf
= 0;
597 pGrf
= pBrsh
->GetGraphic();
602 for (sal_uInt16 i
=0; i
< aGrfDataLst
.size(); ++i
)
604 GrfBulDataRelation
* pEntry
= aGrfDataLst
[i
];
607 bExist
= GalleryExplorer::GetGraphicObj(GALLERY_THEME_BULLETS
, pEntry
->nGallaryIndex
,&aGraphic
);
609 Bitmap aSum
=pGrf
->GetBitmap();
610 Bitmap aSum1
=aGraphic
.GetBitmap();
611 if (aSum
.IsEqual(aSum1
))
612 return pEntry
->nTabIndex
;
617 return (sal_uInt16
)0xFFFF;
620 bool GraphyicBulletsTypeMgr::RelplaceNumRule(SvxNumRule
& aNum
, sal_uInt16 nIndex
, sal_uInt16 mLevel
)
622 if ( mLevel
== (sal_uInt16
)0xFFFF || mLevel
> aNum
.GetLevelCount() || mLevel
== 0)
625 if ( GetNBOIndexForNumRule(aNum
,mLevel
) != (sal_uInt16
)0xFFFF )
628 if ( nIndex
>= aGrfDataLst
.size() )
631 sal_uInt16 nActLv
= IsSingleLevel(mLevel
);
632 if ( nActLv
== (sal_uInt16
)0xFFFF )
635 SvxNumberFormat
aFmt(aNum
.GetLevel(nActLv
));
636 const SvxBrushItem
* pBrsh
= aFmt
.GetBrush();
637 const Graphic
* pGrf
= 0;
639 pGrf
= pBrsh
->GetGraphic();
645 const OUString aGrfName
= pBrsh
->GetGraphicLink();
646 //String* pGrfName = (String*)(pBrsh->GetGraphicLink());
647 GrfBulDataRelation
* pEntry
= aGrfDataLst
[nIndex
];
648 if ( !aGrfName
.isEmpty() )
649 pEntry
->sGrfName
= aGrfName
;
650 //pEntry->sDescription = sEmpty;
651 pEntry
->nGallaryIndex
= (sal_uInt16
)0xFFFF;
652 pEntry
->bIsCustomized
= true;
653 OUString aStrFromRES
= SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_BULLET_DESCRIPTION
);
654 OUString sNUM
= OUString::number( nIndex
+ 1 );
655 aStrFromRES
= aStrFromRES
.replaceFirst("%LIST_NUM",sNUM
);
656 pEntry
->sDescription
= aStrFromRES
;
665 bool GraphyicBulletsTypeMgr::ApplyNumRule(SvxNumRule
& aNum
, sal_uInt16 nIndex
, sal_uInt16 mLevel
, bool /*isDefault*/, bool /*isResetSize*/)
667 //if ( mLevel == (sal_uInt16)0xFFFF )
670 if ( nIndex
>= aGrfDataLst
.size() )
674 GrfBulDataRelation
* pEntry
= aGrfDataLst
[nIndex
];
675 sGrfName
= pEntry
->sGrfName
;
677 sal_uInt16 nMask
= 1;
679 sal_uInt16 nSetNumberingType
= SVX_NUM_BITMAP
;
680 OUString sNumCharFmtName
= GetBulCharFmtName();
681 for(sal_uInt16 i
= 0; i
< aNum
.GetLevelCount(); i
++)
685 SvxNumberFormat
aFmt(aNum
.GetLevel(i
));
686 aFmt
.SetNumberingType(nSetNumberingType
);
687 aFmt
.SetPrefix( aEmptyStr
);
688 aFmt
.SetSuffix( aEmptyStr
);
689 aFmt
.SetCharFormatName( sNumCharFmtName
);
692 if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS
, pEntry
->nGallaryIndex
, &aGraphic
))
694 Size aSize
= SvxNumberFormat::GetGraphicSizeMM100(&aGraphic
);
695 sal_Int16 eOrient
= text::VertOrientation::LINE_CENTER
;
696 aSize
= OutputDevice::LogicToLogic(aSize
, MAP_100TH_MM
, (MapUnit
)GetMapUnit());
697 SvxBrushItem
aBrush(aGraphic
, GPOS_AREA
, SID_ATTR_BRUSH
);
698 aFmt
.SetGraphicBrush( &aBrush
, &aSize
, &eOrient
);
701 aFmt
.SetGraphic( sGrfName
);
703 aNum
.SetLevel(i
, aFmt
);
711 OUString
GraphyicBulletsTypeMgr::GetDescription(sal_uInt16 nIndex
, bool /*isDefault*/)
714 sal_uInt16 nLength
= 0;
715 nLength
= aGrfDataLst
.size();
717 if ( nIndex
>= nLength
)
721 GrfBulDataRelation
* pEntry
= aGrfDataLst
[nIndex
];
724 sRet
= pEntry
->sDescription
;
730 bool GraphyicBulletsTypeMgr::IsCustomized(sal_uInt16 nIndex
)
734 sal_uInt16 nLength
= 0;
735 nLength
= aGrfDataLst
.size() ;
737 if ( nIndex
>= nLength
)
741 GrfBulDataRelation
* pEntry
= aGrfDataLst
[nIndex
];
744 bRet
= pEntry
->bIsCustomized
;
750 OUString
GraphyicBulletsTypeMgr::GetGrfName(sal_uInt16 nIndex
)
753 if ( nIndex
< aGrfDataLst
.size() )
755 GrfBulDataRelation
* pEntry
= aGrfDataLst
[nIndex
];
758 sRet
= pEntry
->sGrfName
;
764 // Mix Bullets Type lib
765 MixBulletsSettings_Impl
* MixBulletsTypeMgr::pActualBullets
[] ={0,0,0,0,0,0,0,0};
766 MixBulletsSettings_Impl
* MixBulletsTypeMgr::pDefaultActualBullets
[] ={0,0,0,0,0,0,0,0};
768 MixBulletsTypeMgr::MixBulletsTypeMgr()
769 : NBOTypeMgrBase(eNBOType::MIXBULLETS
)
772 for(sal_Int32 nItem
= 0; nItem
< DEFAULT_BULLET_TYPES
; nItem
++ )
774 pDefaultActualBullets
[nItem
] = pActualBullets
[nItem
];
776 //Initial the first time to store the default value. Then do it again for customized value
778 ImplLoad(OUString("standard.sya"));
781 class theMixBulletsTypeMgr
: public rtl::Static
<MixBulletsTypeMgr
, theMixBulletsTypeMgr
> {};
783 MixBulletsTypeMgr
& MixBulletsTypeMgr::GetInstance()
785 return theMixBulletsTypeMgr::get();
788 MixBulletsTypeMgr::MixBulletsTypeMgr(const MixBulletsTypeMgr
& aTypeMgr
):
789 NBOTypeMgrBase(aTypeMgr
)
791 for (sal_uInt16 i
=0;i
<DEFAULT_BULLET_TYPES
;i
++)
793 if ( aTypeMgr
.pActualBullets
[i
]->eType
== eNBType::BULLETS
)
795 pActualBullets
[i
]->eType
= aTypeMgr
.pActualBullets
[i
]->eType
;
796 pActualBullets
[i
]->nIndex
= aTypeMgr
.pActualBullets
[i
]->nIndex
; //index in the tab page display
797 pActualBullets
[i
]->nIndexDefault
= aTypeMgr
.pActualBullets
[i
]->nIndexDefault
;
798 pActualBullets
[i
]->pBullets
= new BulletsSettings_Impl(eNBType::BULLETS
) ;
799 static_cast<BulletsSettings_Impl
*>(pActualBullets
[i
]->pBullets
)->cBulletChar
= static_cast<BulletsSettings_Impl
*>(aTypeMgr
.pActualBullets
[i
]->pBullets
)->cBulletChar
;
800 static_cast<BulletsSettings_Impl
*>(pActualBullets
[i
]->pBullets
)->aFont
= static_cast<BulletsSettings_Impl
*>(aTypeMgr
.pActualBullets
[i
]->pBullets
)->aFont
;
801 static_cast<BulletsSettings_Impl
*>(pActualBullets
[i
]->pBullets
)->sDescription
= static_cast<BulletsSettings_Impl
*>(aTypeMgr
.pActualBullets
[i
]->pBullets
)->sDescription
;
802 static_cast<BulletsSettings_Impl
*>(pActualBullets
[i
]->pBullets
)->bIsCustomized
= static_cast<BulletsSettings_Impl
*>(aTypeMgr
.pActualBullets
[i
]->pBullets
)->bIsCustomized
;
803 static_cast<BulletsSettings_Impl
*>(pActualBullets
[i
]->pBullets
)->eType
= static_cast<BulletsSettings_Impl
*>(aTypeMgr
.pActualBullets
[i
]->pBullets
)->eType
;
805 else if ( aTypeMgr
.pActualBullets
[i
]->eType
== eNBType::GRAPHICBULLETS
)
807 pActualBullets
[i
]->eType
= aTypeMgr
.pActualBullets
[i
]->eType
;
808 pActualBullets
[i
]->nIndex
= aTypeMgr
.pActualBullets
[i
]->nIndex
; //index in the tab page display
809 pActualBullets
[i
]->nIndexDefault
= aTypeMgr
.pActualBullets
[i
]->nIndexDefault
;
810 pActualBullets
[i
]->pBullets
= new GrfBulDataRelation(eNBType::GRAPHICBULLETS
) ;
811 static_cast<GrfBulDataRelation
*>(pActualBullets
[i
]->pBullets
)->sGrfName
= static_cast<GrfBulDataRelation
*>(aTypeMgr
.pActualBullets
[i
]->pBullets
)->sGrfName
;
812 static_cast<GrfBulDataRelation
*>(pActualBullets
[i
]->pBullets
)->sDescription
= static_cast<GrfBulDataRelation
*>(aTypeMgr
.pActualBullets
[i
]->pBullets
)->sDescription
;
813 static_cast<GrfBulDataRelation
*>(pActualBullets
[i
]->pBullets
)->bIsCustomized
= static_cast<GrfBulDataRelation
*>(aTypeMgr
.pActualBullets
[i
]->pBullets
)->bIsCustomized
;
814 static_cast<GrfBulDataRelation
*>(pActualBullets
[i
]->pBullets
)->eType
= static_cast<GrfBulDataRelation
*>(aTypeMgr
.pActualBullets
[i
]->pBullets
)->eType
;
815 if ( static_cast<GrfBulDataRelation
*>(aTypeMgr
.pActualBullets
[i
]->pBullets
)->bIsCustomized
&& static_cast<GrfBulDataRelation
*>(aTypeMgr
.pActualBullets
[i
]->pBullets
)->pGrfObj
!= NULL
)
817 static_cast<GrfBulDataRelation
*>(pActualBullets
[i
]->pBullets
)->pGrfObj
= static_cast<GrfBulDataRelation
*>(aTypeMgr
.pActualBullets
[i
]->pBullets
)->pGrfObj
;
821 ImplLoad(OUString("standard.sya"));
823 void MixBulletsTypeMgr::Init()
825 BulletsTypeMgr
&rBTMgr
= BulletsTypeMgr::GetInstance();
828 pActualBullets
[0] = new MixBulletsSettings_Impl(eNBType::BULLETS
);
829 pActualBullets
[0]->eType
= eNBType::BULLETS
;
830 pActualBullets
[0]->nIndex
= 0+1; //index in the tab page display,decrease 1 to the index within arr
831 pActualBullets
[0]->nIndexDefault
= 2; //index in the tab page display,decrease 1 to the index within arr
832 pActualBullets
[0]->pBullets
= new BulletsSettings_Impl(eNBType::BULLETS
) ;
833 static_cast<BulletsSettings_Impl
*>(pActualBullets
[0]->pBullets
)->cBulletChar
= BulletsTypeMgr::GetBulChar(pActualBullets
[0]->nIndexDefault
-1);
834 static_cast<BulletsSettings_Impl
*>(pActualBullets
[0]->pBullets
)->aFont
= BulletsTypeMgr::GetBulCharFont(pActualBullets
[0]->nIndexDefault
-1);
835 static_cast<BulletsSettings_Impl
*>(pActualBullets
[0]->pBullets
)->sDescription
= rBTMgr
.GetDescription(pActualBullets
[0]->nIndexDefault
-1);
836 static_cast<BulletsSettings_Impl
*>(pActualBullets
[0]->pBullets
)->bIsCustomized
= rBTMgr
.IsCustomized(pActualBullets
[0]->nIndexDefault
-1);
837 static_cast<BulletsSettings_Impl
*>(pActualBullets
[0]->pBullets
)->eType
= eNBType::BULLETS
;
840 pActualBullets
[1] = new MixBulletsSettings_Impl(eNBType::BULLETS
);
841 pActualBullets
[1]->eType
= eNBType::BULLETS
;
842 pActualBullets
[1]->nIndex
= 1+1; //index in the tab page display,decrease 1 to the index within arr
843 pActualBullets
[1]->nIndexDefault
= 3; //index in the tab page display,decrease 1 to the index within arr
844 pActualBullets
[1]->pBullets
= new BulletsSettings_Impl(eNBType::BULLETS
) ;
845 static_cast<BulletsSettings_Impl
*>(pActualBullets
[1]->pBullets
)->cBulletChar
= BulletsTypeMgr::GetBulChar(pActualBullets
[1]->nIndexDefault
-1);
846 static_cast<BulletsSettings_Impl
*>(pActualBullets
[1]->pBullets
)->aFont
= BulletsTypeMgr::GetBulCharFont(pActualBullets
[1]->nIndexDefault
-1);
847 static_cast<BulletsSettings_Impl
*>(pActualBullets
[1]->pBullets
)->sDescription
= rBTMgr
.GetDescription(pActualBullets
[1]->nIndexDefault
-1);
848 static_cast<BulletsSettings_Impl
*>(pActualBullets
[1]->pBullets
)->bIsCustomized
= rBTMgr
.IsCustomized(pActualBullets
[1]->nIndexDefault
-1);
849 static_cast<BulletsSettings_Impl
*>(pActualBullets
[1]->pBullets
)->eType
= eNBType::BULLETS
;
852 pActualBullets
[2] = new MixBulletsSettings_Impl(eNBType::BULLETS
);
853 pActualBullets
[2]->eType
= eNBType::BULLETS
;
854 pActualBullets
[2]->nIndex
= 2+1; //index in the tab page display,decrease 1 to the index within arr
855 pActualBullets
[2]->nIndexDefault
= 4; //index in the tab page display,decrease 1 to the index within arr
856 pActualBullets
[2]->pBullets
= new BulletsSettings_Impl(eNBType::BULLETS
) ;
857 static_cast<BulletsSettings_Impl
*>(pActualBullets
[2]->pBullets
)->cBulletChar
= BulletsTypeMgr::GetBulChar(pActualBullets
[2]->nIndexDefault
-1);
858 static_cast<BulletsSettings_Impl
*>(pActualBullets
[2]->pBullets
)->aFont
= BulletsTypeMgr::GetBulCharFont(pActualBullets
[2]->nIndexDefault
-1);
859 static_cast<BulletsSettings_Impl
*>(pActualBullets
[2]->pBullets
)->sDescription
= rBTMgr
.GetDescription(pActualBullets
[2]->nIndexDefault
-1);
860 static_cast<BulletsSettings_Impl
*>(pActualBullets
[2]->pBullets
)->bIsCustomized
= rBTMgr
.IsCustomized(pActualBullets
[2]->nIndexDefault
-1);
861 static_cast<BulletsSettings_Impl
*>(pActualBullets
[2]->pBullets
)->eType
= eNBType::BULLETS
;
864 pActualBullets
[3] = new MixBulletsSettings_Impl(eNBType::BULLETS
);
865 pActualBullets
[3]->eType
= eNBType::BULLETS
;
866 pActualBullets
[3]->nIndex
= 3+1; //index in the tab page display,decrease 1 to the index within arr
867 pActualBullets
[3]->nIndexDefault
= 5; //index in the tab page display,decrease 1 to the index within arr
868 pActualBullets
[3]->pBullets
= new BulletsSettings_Impl(eNBType::BULLETS
) ;
869 static_cast<BulletsSettings_Impl
*>(pActualBullets
[3]->pBullets
)->cBulletChar
= BulletsTypeMgr::GetBulChar(pActualBullets
[3]->nIndexDefault
-1);
870 static_cast<BulletsSettings_Impl
*>(pActualBullets
[3]->pBullets
)->aFont
= BulletsTypeMgr::GetBulCharFont(pActualBullets
[3]->nIndexDefault
-1);
871 static_cast<BulletsSettings_Impl
*>(pActualBullets
[3]->pBullets
)->sDescription
= rBTMgr
.GetDescription(pActualBullets
[3]->nIndexDefault
-1);
872 static_cast<BulletsSettings_Impl
*>(pActualBullets
[3]->pBullets
)->bIsCustomized
= rBTMgr
.IsCustomized(pActualBullets
[3]->nIndexDefault
-1);
873 static_cast<BulletsSettings_Impl
*>(pActualBullets
[3]->pBullets
)->eType
= eNBType::BULLETS
;
876 pActualBullets
[4] = new MixBulletsSettings_Impl(eNBType::BULLETS
);
877 pActualBullets
[4]->eType
= eNBType::BULLETS
;
878 pActualBullets
[4]->nIndex
= 4+1; //index in the tab page display,decrease 1 to the index within arr
879 pActualBullets
[4]->nIndexDefault
= 6; //index in the tab page display,decrease 1 to the index within arr
880 pActualBullets
[4]->pBullets
= new BulletsSettings_Impl(eNBType::BULLETS
) ;
881 static_cast<BulletsSettings_Impl
*>(pActualBullets
[4]->pBullets
)->cBulletChar
= BulletsTypeMgr::GetBulChar(pActualBullets
[4]->nIndexDefault
-1);
882 static_cast<BulletsSettings_Impl
*>(pActualBullets
[4]->pBullets
)->aFont
= BulletsTypeMgr::GetBulCharFont(pActualBullets
[4]->nIndexDefault
-1);
883 static_cast<BulletsSettings_Impl
*>(pActualBullets
[4]->pBullets
)->sDescription
= rBTMgr
.GetDescription(pActualBullets
[4]->nIndexDefault
-1);
884 static_cast<BulletsSettings_Impl
*>(pActualBullets
[4]->pBullets
)->bIsCustomized
= rBTMgr
.IsCustomized(pActualBullets
[4]->nIndexDefault
-1);
885 static_cast<BulletsSettings_Impl
*>(pActualBullets
[4]->pBullets
)->eType
= eNBType::BULLETS
;
888 pActualBullets
[5] = new MixBulletsSettings_Impl(eNBType::BULLETS
);
889 pActualBullets
[5]->eType
= eNBType::BULLETS
;
890 pActualBullets
[5]->nIndex
= 5+1; //index in the tab page display,decrease 1 to the index within arr
891 pActualBullets
[5]->nIndexDefault
= 8; //index in the tab page display,decrease 1 to the index within arr
892 pActualBullets
[5]->pBullets
= new BulletsSettings_Impl(eNBType::BULLETS
) ;
893 static_cast<BulletsSettings_Impl
*>(pActualBullets
[5]->pBullets
)->cBulletChar
= BulletsTypeMgr::GetBulChar(pActualBullets
[5]->nIndexDefault
-1);
894 static_cast<BulletsSettings_Impl
*>(pActualBullets
[5]->pBullets
)->aFont
= BulletsTypeMgr::GetBulCharFont(pActualBullets
[5]->nIndexDefault
-1);
895 static_cast<BulletsSettings_Impl
*>(pActualBullets
[5]->pBullets
)->sDescription
= rBTMgr
.GetDescription(pActualBullets
[5]->nIndexDefault
-1);
896 static_cast<BulletsSettings_Impl
*>(pActualBullets
[5]->pBullets
)->bIsCustomized
= rBTMgr
.IsCustomized(pActualBullets
[5]->nIndexDefault
-1);
897 static_cast<BulletsSettings_Impl
*>(pActualBullets
[5]->pBullets
)->eType
= eNBType::BULLETS
;
900 GraphyicBulletsTypeMgr
& rGrfTMgr
= GraphyicBulletsTypeMgr::GetInstance();
903 pActualBullets
[6] = new MixBulletsSettings_Impl(eNBType::GRAPHICBULLETS
);
904 pActualBullets
[6]->eType
= eNBType::GRAPHICBULLETS
;
905 pActualBullets
[6]->nIndex
= 6+1; //index in the tab page display,decrease 1 to the index within arr
906 pActualBullets
[6]->nIndexDefault
= 9; //index in the tab page display,decrease 1 to the index within arr
907 pActualBullets
[6]->pBullets
= new GrfBulDataRelation(eNBType::GRAPHICBULLETS
) ;
908 static_cast<GrfBulDataRelation
*>(pActualBullets
[6]->pBullets
)->sGrfName
= rGrfTMgr
.GetGrfName(pActualBullets
[6]->nIndexDefault
);
909 static_cast<GrfBulDataRelation
*>(pActualBullets
[6]->pBullets
)->sDescription
= rGrfTMgr
.GetDescription(pActualBullets
[6]->nIndexDefault
);
910 static_cast<GrfBulDataRelation
*>(pActualBullets
[6]->pBullets
)->bIsCustomized
= rGrfTMgr
.IsCustomized(pActualBullets
[6]->nIndexDefault
);
911 static_cast<GrfBulDataRelation
*>(pActualBullets
[6]->pBullets
)->eType
= eNBType::GRAPHICBULLETS
;
914 pActualBullets
[7] = new MixBulletsSettings_Impl(eNBType::GRAPHICBULLETS
);
915 pActualBullets
[7]->eType
= eNBType::GRAPHICBULLETS
;
916 pActualBullets
[7]->nIndex
= 7+1; //index in the tab page display,decrease 1 to the index within arr
917 pActualBullets
[7]->nIndexDefault
= 23; //index in the tab page display,decrease 1 to the index within arr
918 pActualBullets
[7]->pBullets
= new GrfBulDataRelation(eNBType::GRAPHICBULLETS
) ;
919 static_cast<GrfBulDataRelation
*>(pActualBullets
[7]->pBullets
)->sGrfName
= rGrfTMgr
.GetGrfName(pActualBullets
[7]->nIndexDefault
);
920 static_cast<GrfBulDataRelation
*>(pActualBullets
[7]->pBullets
)->sDescription
= rGrfTMgr
.GetDescription(pActualBullets
[7]->nIndexDefault
);
921 static_cast<GrfBulDataRelation
*>(pActualBullets
[7]->pBullets
)->bIsCustomized
= rGrfTMgr
.IsCustomized(pActualBullets
[7]->nIndexDefault
);
922 static_cast<GrfBulDataRelation
*>(pActualBullets
[7]->pBullets
)->eType
= eNBType::GRAPHICBULLETS
;
926 sal_uInt16
MixBulletsTypeMgr::GetNBOIndexForNumRule(SvxNumRule
& aNum
,sal_uInt16 mLevel
,sal_uInt16 nFromIndex
)
928 if ( mLevel
== (sal_uInt16
)0xFFFF || mLevel
== 0)
929 return (sal_uInt16
)0xFFFF;
930 //if ( !lcl_IsNumFmtSet(pNR, mLevel) ) return (sal_uInt16)0xFFFF;
932 sal_uInt16 nActLv
= IsSingleLevel(mLevel
);
934 if ( nActLv
== (sal_uInt16
)0xFFFF )
935 return (sal_uInt16
)0xFFFF;
937 SvxNumberFormat
aFmt(aNum
.GetLevel(nActLv
));
938 sal_Int16 eNumType
= aFmt
.GetNumberingType();
939 if( eNumType
== SVX_NUM_CHAR_SPECIAL
)
941 sal_Unicode cChar
= aFmt
.GetBulletChar();
942 // const vcl::Font* pFont = aFmt.GetBulletFont();
944 for(sal_uInt16 i
= nFromIndex
; i
< DEFAULT_BULLET_TYPES
; i
++)
946 if ( pActualBullets
[i
]->eType
== eNBType::BULLETS
)
948 if ( (cChar
== static_cast<BulletsSettings_Impl
*>(pActualBullets
[i
]->pBullets
)->cBulletChar
||
949 (cChar
== 9830 && 57356 == static_cast<BulletsSettings_Impl
*>(pActualBullets
[i
]->pBullets
)->cBulletChar
) ||
950 (cChar
== 9632 && 57354 == static_cast<BulletsSettings_Impl
*>(pActualBullets
[i
]->pBullets
)->cBulletChar
)))//&&
952 return pActualBullets
[i
]->nIndex
;
956 }else if ( (eNumType
&(~LINK_TOKEN
)) == SVX_NUM_BITMAP
)
958 const SvxBrushItem
* pBrsh
= aFmt
.GetBrush();
959 const Graphic
* pGrf
= 0;
961 pGrf
= pBrsh
->GetGraphic();
965 //const String* pGrfName = pBrsh->GetGraphicLink();
966 for(sal_uInt16 i
= nFromIndex
; i
< DEFAULT_BULLET_TYPES
; i
++)
968 if ( pActualBullets
[i
]->eType
== eNBType::GRAPHICBULLETS
)
970 GrfBulDataRelation
* pEntry
= static_cast<GrfBulDataRelation
*>(pActualBullets
[i
]->pBullets
);
971 //sal_Bool bExist = sal_False;
972 if ( pEntry
&& pActualBullets
[i
]->nIndexDefault
== (sal_uInt16
)0xFFFF && pEntry
->pGrfObj
)
974 if ( pEntry
->pGrfObj
->GetBitmap().IsEqual(pGrf
->GetBitmap()))
976 return pActualBullets
[i
]->nIndex
;
981 GalleryExplorer::GetGraphicObj(GALLERY_THEME_BULLETS
, pActualBullets
[i
]->nIndexDefault
,&aSrGrf
);
982 Bitmap aSum
=pGrf
->GetBitmap();
983 Bitmap aSum1
=aSrGrf
.GetBitmap();
984 if (aSum
.IsEqual(aSum1
))
985 return pActualBullets
[i
]->nIndex
;
992 return (sal_uInt16
)0xFFFF;
995 bool MixBulletsTypeMgr::RelplaceNumRule(SvxNumRule
& aNum
,sal_uInt16 nIndex
,sal_uInt16 mLevel
)
997 if ( mLevel
== (sal_uInt16
)0xFFFF || mLevel
== 0 || nIndex
>=DEFAULT_BULLET_TYPES
)
1000 //if ( GetNBOIndexForNumRule(aNum,mLevel) != (sal_uInt16)0xFFFF )
1001 // return sal_False;
1003 sal_uInt16 nActLv
= IsSingleLevel(mLevel
);
1005 if ( nActLv
== (sal_uInt16
)0xFFFF )
1008 SvxNumberFormat
aFmt(aNum
.GetLevel(nActLv
));
1009 sal_Int16 eNumType
= aFmt
.GetNumberingType();
1010 if( eNumType
== SVX_NUM_CHAR_SPECIAL
&& pActualBullets
[nIndex
]->eType
== eNBType::BULLETS
)
1012 sal_Unicode cChar
= aFmt
.GetBulletChar();
1013 const vcl::Font
* pFont
= aFmt
.GetBulletFont();
1014 BulletsSettings_Impl
* pEntry
= static_cast<BulletsSettings_Impl
*>(pActualBullets
[nIndex
]->pBullets
);
1015 pEntry
->cBulletChar
= cChar
;
1016 pEntry
->aFont
= pFont
?*pFont
:lcl_GetDefaultBulletFont();
1017 pEntry
->bIsCustomized
= true;
1018 OUString aStrFromRES
= SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_BULLET_DESCRIPTION
);
1019 OUString sNUM
= OUString::number( nIndex
+ 1 );
1020 aStrFromRES
= aStrFromRES
.replaceFirst("%LIST_NUM",sNUM
);
1021 pEntry
->sDescription
= aStrFromRES
;
1023 }else if ( (eNumType
&(~LINK_TOKEN
)) == SVX_NUM_BITMAP
&& pActualBullets
[nIndex
]->eType
== eNBType::GRAPHICBULLETS
)
1025 const SvxBrushItem
* pBrsh
= aFmt
.GetBrush();
1026 const Graphic
* pGrf
= 0;
1028 pGrf
= pBrsh
->GetGraphic();
1035 const OUString aGrfName
= pBrsh
->GetGraphicLink();
1036 GrfBulDataRelation
* pEntry
= static_cast<GrfBulDataRelation
*>(pActualBullets
[nIndex
]->pBullets
);
1037 if ( !aGrfName
.isEmpty() )
1038 pEntry
->sGrfName
= aGrfName
;
1039 GraphyicBulletsTypeMgr
& rGrfTMgr
= GraphyicBulletsTypeMgr::GetInstance();
1041 pActualBullets
[nIndex
]->nIndexDefault
= (sal_uInt16
)0xFFFF;
1042 sEmpty
= SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_BULLET_DESCRIPTION
);
1043 OUString sNUM
= OUString::number( nIndex
+ 1 );
1044 sEmpty
= sEmpty
.replaceFirst("%LIST_NUM",sNUM
);
1045 pEntry
->pGrfObj
= new Graphic(*pGrf
);
1046 pEntry
->aSize
= aFmt
.GetGraphicSize();
1047 pEntry
->aSize
= OutputDevice::LogicToLogic(pEntry
->aSize
,(MapUnit
)GetMapUnit(),MAP_100TH_MM
);
1048 sal_uInt16 nDIndex
= rGrfTMgr
.GetNBOIndexForNumRule(aNum
,mLevel
);
1049 if (nDIndex
!=(sal_uInt16
)0xFFFF)
1050 pEntry
->aSize
=Size(0,0);
1052 pEntry
->sDescription
= sEmpty
;
1053 pEntry
->bIsCustomized
= true;
1060 delete pActualBullets
[nIndex
]->pBullets
;
1061 pActualBullets
[nIndex
]->pBullets
= 0;
1062 if ( eNumType
== SVX_NUM_CHAR_SPECIAL
)
1064 sal_Unicode cChar
= aFmt
.GetBulletChar();
1065 const vcl::Font
* pFont
= aFmt
.GetBulletFont();
1066 pActualBullets
[nIndex
]->eType
= eNBType::BULLETS
;
1067 pActualBullets
[nIndex
]->nIndex
= nIndex
+1; //index in the tab page display,decrease 1 to the index within arr
1068 pActualBullets
[nIndex
]->pBullets
= new BulletsSettings_Impl(eNBType::BULLETS
) ;
1069 static_cast<BulletsSettings_Impl
*>(pActualBullets
[nIndex
]->pBullets
)->cBulletChar
= cChar
;
1070 static_cast<BulletsSettings_Impl
*>(pActualBullets
[nIndex
]->pBullets
)->aFont
= pFont
?*pFont
:lcl_GetDefaultBulletFont();
1071 static_cast<BulletsSettings_Impl
*>(pActualBullets
[nIndex
]->pBullets
)->bIsCustomized
= true;
1072 static_cast<BulletsSettings_Impl
*>(pActualBullets
[nIndex
]->pBullets
)->eType
= eNBType::BULLETS
;
1073 pActualBullets
[nIndex
]->nIndexDefault
= (sal_uInt16
)0xFFFF;
1074 OUString aStrFromRES
= SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_BULLET_DESCRIPTION
);
1075 OUString sNUM
= OUString::number( nIndex
+ 1 );
1076 aStrFromRES
= aStrFromRES
.replaceFirst("%LIST_NUM",sNUM
);
1077 static_cast<BulletsSettings_Impl
*>(pActualBullets
[nIndex
]->pBullets
)->sDescription
= aStrFromRES
;
1078 }else if ( (eNumType
&(~LINK_TOKEN
)) == SVX_NUM_BITMAP
)
1080 const SvxBrushItem
* pBrsh
= aFmt
.GetBrush();
1081 const Graphic
* pGrf
= 0;
1083 pGrf
= pBrsh
->GetGraphic();
1090 aGrfName
= pBrsh
->GetGraphicLink();
1092 pActualBullets
[nIndex
]->eType
= eNBType::GRAPHICBULLETS
;
1093 pActualBullets
[nIndex
]->nIndex
= nIndex
+1; //index in the tab page display,decrease 1 to the index within arr
1094 pActualBullets
[nIndex
]->pBullets
= new GrfBulDataRelation(eNBType::GRAPHICBULLETS
) ;
1095 if (!aGrfName
.isEmpty())
1096 static_cast<GrfBulDataRelation
*>(pActualBullets
[nIndex
]->pBullets
)->sGrfName
= aGrfName
;
1097 static_cast<GrfBulDataRelation
*>(pActualBullets
[nIndex
]->pBullets
)->bIsCustomized
= true;
1098 static_cast<GrfBulDataRelation
*>(pActualBullets
[nIndex
]->pBullets
)->eType
= eNBType::GRAPHICBULLETS
;
1099 GraphyicBulletsTypeMgr
& rGrfTMgr
= GraphyicBulletsTypeMgr::GetInstance();
1101 pActualBullets
[nIndex
]->nIndexDefault
= (sal_uInt16
)0xFFFF;
1102 OUString aStrFromRES
= SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_BULLET_DESCRIPTION
);
1103 OUString sNUM
= OUString::number( nIndex
+ 1 );
1104 aStrFromRES
= aStrFromRES
.replaceFirst("%LIST_NUM",sNUM
);
1105 static_cast<GrfBulDataRelation
*>(pActualBullets
[nIndex
]->pBullets
)->sDescription
= aStrFromRES
;
1106 static_cast<GrfBulDataRelation
*>(pActualBullets
[nIndex
]->pBullets
)->pGrfObj
= new Graphic(*pGrf
);
1107 static_cast<GrfBulDataRelation
*>(pActualBullets
[nIndex
]->pBullets
)->pGrfObj
= new Graphic(*pGrf
);
1108 Size aTmpSize
= aFmt
.GetGraphicSize();
1109 aTmpSize
= OutputDevice::LogicToLogic(aTmpSize
,(MapUnit
)GetMapUnit(),MAP_100TH_MM
);
1110 sal_uInt16 nDIndex
= rGrfTMgr
.GetNBOIndexForNumRule(aNum
,mLevel
);
1111 if (nDIndex
!=(sal_uInt16
)0xFFFF)
1113 static_cast<GrfBulDataRelation
*>(pActualBullets
[nIndex
]->pBullets
)->aSize
= aTmpSize
;
1118 SvxNumRule
aTmpRule1(aNum
);
1119 ApplyNumRule(aTmpRule1
,nIndex
,mLevel
,true);
1120 if (GetNBOIndexForNumRule(aTmpRule1
,mLevel
,nIndex
)==nIndex
+1) {
1121 if (pActualBullets
[nIndex
]->eType
== eNBType::BULLETS
) {
1122 BulletsSettings_Impl
* pEntry
= static_cast<BulletsSettings_Impl
*>(pActualBullets
[nIndex
]->pBullets
);
1123 pEntry
->bIsCustomized
= false;
1124 pEntry
->sDescription
= GetDescription(nIndex
,true);
1126 if (pActualBullets
[nIndex
]->eType
== eNBType::GRAPHICBULLETS
) {
1127 GrfBulDataRelation
* pEntry
= static_cast<GrfBulDataRelation
*>(pActualBullets
[nIndex
]->pBullets
);
1128 pEntry
->bIsCustomized
= false;
1129 pEntry
->sDescription
= GetDescription(nIndex
,true);
1132 ImplStore(OUString("standard.sya"));
1136 bool MixBulletsTypeMgr::ApplyNumRule(SvxNumRule
& aNum
, sal_uInt16 nIndex
, sal_uInt16 mLevel
, bool isDefault
, bool isResetSize
)
1138 //if ( mLevel == (sal_uInt16)0xFFFF || nIndex>=DEFAULT_BULLET_TYPES )
1139 if ( nIndex
>=DEFAULT_BULLET_TYPES
)
1141 MixBulletsSettings_Impl
* pCurrentBullets
= pActualBullets
[nIndex
];
1142 if (isDefault
) pCurrentBullets
=pDefaultActualBullets
[nIndex
];
1144 if ( pCurrentBullets
->eType
== eNBType::BULLETS
)
1147 cChar
= static_cast<BulletsSettings_Impl
*>(pCurrentBullets
->pBullets
)->cBulletChar
;
1149 //vcl::Font& rActBulletFont = lcl_GetDefaultBulletFont();
1150 vcl::Font rActBulletFont
= static_cast<BulletsSettings_Impl
*>(pCurrentBullets
->pBullets
)->aFont
;
1151 sal_uInt16 nMask
= 1;
1152 OUString sBulletCharFormatName
= GetBulCharFmtName();
1153 for(sal_uInt16 i
= 0; i
< aNum
.GetLevelCount(); i
++)
1157 SvxNumberFormat
aFmt(aNum
.GetLevel(i
));
1158 if (SVX_NUM_CHAR_SPECIAL
!=aFmt
.GetNumberingType()) isResetSize
=true;
1159 aFmt
.SetNumberingType( SVX_NUM_CHAR_SPECIAL
);
1160 aFmt
.SetBulletFont(&rActBulletFont
);
1161 aFmt
.SetBulletChar(cChar
);
1162 aFmt
.SetCharFormatName(sBulletCharFormatName
);
1164 aFmt
.SetPrefix( aEmptyStr
);
1165 aFmt
.SetSuffix( aEmptyStr
);
1166 if (isResetSize
) aFmt
.SetBulletRelSize(45);
1167 aNum
.SetLevel(i
, aFmt
);
1171 }else if ( pCurrentBullets
->eType
== eNBType::GRAPHICBULLETS
)
1174 GrfBulDataRelation
* pEntry
= static_cast<GrfBulDataRelation
*>(pCurrentBullets
->pBullets
);
1175 sGrfName
= pEntry
->sGrfName
;
1177 sal_uInt16 nMask
= 1;
1179 sal_uInt16 nSetNumberingType
= SVX_NUM_BITMAP
;
1180 OUString sNumCharFmtName
= GetBulCharFmtName();
1181 for(sal_uInt16 i
= 0; i
< aNum
.GetLevelCount(); i
++)
1185 SvxNumberFormat
aFmt(aNum
.GetLevel(i
));
1186 if (SVX_NUM_BITMAP
!=aFmt
.GetNumberingType()) isResetSize
=true;
1187 aFmt
.SetNumberingType(nSetNumberingType
);
1188 aFmt
.SetPrefix( aEmptyStr
);
1189 aFmt
.SetSuffix( aEmptyStr
);
1190 aFmt
.SetCharFormatName( sNumCharFmtName
);
1191 if ( pCurrentBullets
->nIndexDefault
== (sal_uInt16
)0xFFFF && pEntry
->pGrfObj
)
1193 Size aSize
= pEntry
->aSize
;
1194 sal_Int16 eOrient
= text::VertOrientation::LINE_CENTER
;
1195 if (!isResetSize
&& aFmt
.GetGraphicSize()!=Size(0,0)) aSize
=aFmt
.GetGraphicSize();
1197 if (aSize
.Width()==0 && aSize
.Height()==0) {
1198 aSize
= SvxNumberFormat::GetGraphicSizeMM100( pEntry
->pGrfObj
);
1200 aSize
= OutputDevice::LogicToLogic(aSize
, MAP_100TH_MM
, (MapUnit
)GetMapUnit());
1202 SvxBrushItem
aBrush(*(pEntry
->pGrfObj
), GPOS_AREA
, SID_ATTR_BRUSH
);
1203 aFmt
.SetGraphicBrush( &aBrush
, &aSize
, &eOrient
);
1207 if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS
, pCurrentBullets
->nIndexDefault
, &aGraphic
))
1209 Size aSize
= pEntry
->aSize
;
1210 sal_Int16 eOrient
= text::VertOrientation::LINE_CENTER
;
1211 if (!isResetSize
&& aFmt
.GetGraphicSize()!=Size(0,0)) aSize
=aFmt
.GetGraphicSize();
1213 if (aSize
.Width()==0 && aSize
.Height()==0) {
1214 aSize
= SvxNumberFormat::GetGraphicSizeMM100(&aGraphic
);
1216 aSize
= OutputDevice::LogicToLogic(aSize
, MAP_100TH_MM
, (MapUnit
)GetMapUnit());
1218 SvxBrushItem
aBrush(aGraphic
, GPOS_AREA
, SID_ATTR_BRUSH
);
1219 aFmt
.SetGraphicBrush( &aBrush
, &aSize
, &eOrient
);
1221 aFmt
.SetGraphic( sGrfName
);
1224 aNum
.SetLevel(i
, aFmt
);
1233 OUString
MixBulletsTypeMgr::GetDescription(sal_uInt16 nIndex
, bool isDefault
)
1236 //sal_uInt16 nLength = 0;
1237 //nLength = sizeof(pActualBullets)/sizeof(BulletsSettings_Impl);
1239 if ( nIndex
>= DEFAULT_BULLET_TYPES
)
1242 sRet
= pActualBullets
[nIndex
]->pBullets
->sDescription
;
1243 if (isDefault
) sRet
= pDefaultActualBullets
[nIndex
]->pBullets
->sDescription
;
1247 bool MixBulletsTypeMgr::IsCustomized(sal_uInt16 nIndex
)
1250 //sal_uInt16 nLength = 0;
1251 //nLength = sizeof(pActualBullets)/sizeof(BulletsSettings_Impl);
1253 if ( nIndex
>= DEFAULT_BULLET_TYPES
)
1256 bRet
= pActualBullets
[nIndex
]->pBullets
->bIsCustomized
;
1260 // Numbering Type lib
1261 NumberingTypeMgr::NumberingTypeMgr()
1262 : NBOTypeMgrBase(eNBOType::NUMBERING
)
1263 , pNumberSettingsArr (new NumberSettingsArr_Impl
)
1266 pDefaultNumberSettingsArr
= pNumberSettingsArr
;
1267 pNumberSettingsArr
= new NumberSettingsArr_Impl
;
1268 //Initial the first time to store the default value. Then do it again for customized value
1270 ImplLoad(OUString("standard.syb"));
1273 NumberingTypeMgr::NumberingTypeMgr(const NumberingTypeMgr
& rTypeMgr
)
1274 : NBOTypeMgrBase(rTypeMgr
)
1275 , pNumberSettingsArr (new NumberSettingsArr_Impl
)
1276 , pDefaultNumberSettingsArr(NULL
)
1278 ImplLoad(OUString("standard.syb"));
1281 NumberingTypeMgr::~NumberingTypeMgr()
1283 delete pNumberSettingsArr
;
1284 delete pDefaultNumberSettingsArr
;
1287 class theNumberingTypeMgr
: public rtl::Static
<NumberingTypeMgr
, theNumberingTypeMgr
> {};
1289 NumberingTypeMgr
& NumberingTypeMgr::GetInstance()
1291 return theNumberingTypeMgr::get();
1294 void NumberingTypeMgr::Init()
1296 Reference
< XComponentContext
> xContext
= ::comphelper::getProcessComponentContext();
1297 Reference
<XDefaultNumberingProvider
> xDefNum
= DefaultNumberingProvider::create( xContext
);
1299 Sequence
< Sequence
< PropertyValue
> > aNumberings
;
1300 Locale
aLocale(Application::GetSettings().GetLanguageTag().getLocale());
1303 aNumberings
= xDefNum
->getDefaultContinuousNumberingLevels( aLocale
);
1305 sal_Int32 nLength
= aNumberings
.getLength();
1307 const Sequence
<PropertyValue
>* pValuesArr
= aNumberings
.getConstArray();
1308 for(sal_Int32 i
= 0; i
< nLength
; i
++)
1310 NumSettings_ImplPtr pNew
= lcl_CreateNumberingSettingsPtr(pValuesArr
[i
]);
1311 NumberSettings_Impl
* pNumEntry
= new NumberSettings_Impl
;
1312 pNumEntry
->nIndex
= i
+ 1;
1313 pNumEntry
->nIndexDefault
= i
;
1314 pNumEntry
->pNumSetting
= pNew
;
1315 pNumEntry
->sDescription
= SVX_RESSTR( RID_SVXSTR_SINGLENUM_DESCRIPTIONS
+ i
);
1316 pNumberSettingsArr
->push_back(std::shared_ptr
<NumberSettings_Impl
>(pNumEntry
));
1324 sal_uInt16
NumberingTypeMgr::GetNBOIndexForNumRule(SvxNumRule
& aNum
,sal_uInt16 mLevel
,sal_uInt16 nFromIndex
)
1326 if ( mLevel
== (sal_uInt16
)0xFFFF || mLevel
> aNum
.GetLevelCount() || mLevel
== 0)
1327 return (sal_uInt16
)0xFFFF;
1329 sal_uInt16 nActLv
= IsSingleLevel(mLevel
);
1331 if ( nActLv
== (sal_uInt16
)0xFFFF )
1332 return (sal_uInt16
)0xFFFF;
1334 SvxNumberFormat
aFmt(aNum
.GetLevel(nActLv
));
1335 //sal_Unicode cPrefix = rtl::OUString(aFmt.GetPrefix())[0];
1336 //sal_Unicode cSuffix = rtl::OUString(aFmt.GetSuffix())[0];
1337 OUString sPrefix
= aFmt
.GetPrefix();
1338 OUString sLclSuffix
= aFmt
.GetSuffix();
1339 sal_Int16 eNumType
= aFmt
.GetNumberingType();
1341 sal_uInt16 nCount
= pNumberSettingsArr
->size();
1342 for(sal_uInt16 i
= nFromIndex
; i
< nCount
; ++i
)
1344 NumberSettings_ImplPtr _pSet
= (*pNumberSettingsArr
)[i
].get();
1345 sal_Int16 eNType
= _pSet
->pNumSetting
->nNumberType
;
1346 OUString sLocalPrefix
= _pSet
->pNumSetting
->sPrefix
;
1347 OUString sLocalSuffix
= _pSet
->pNumSetting
->sSuffix
;
1348 if (sPrefix
== sLocalPrefix
&&
1349 sLclSuffix
== sLocalSuffix
&&
1350 eNumType
== eNType
)
1357 return (sal_uInt16
)0xFFFF;
1360 bool NumberingTypeMgr::RelplaceNumRule(SvxNumRule
& aNum
, sal_uInt16 nIndex
, sal_uInt16 mLevel
)
1362 //if ( mLevel == (sal_uInt16)0xFFFF || mLevel == 0)
1363 // return sal_False;
1365 //if ( GetNBOIndexForNumRule(aNum,mLevel) != (sal_uInt16)0xFFFF )
1366 // return sal_False;
1368 sal_uInt16 nActLv
= IsSingleLevel(mLevel
);
1370 if ( nActLv
== (sal_uInt16
)0xFFFF )
1373 SvxNumberFormat
aFmt(aNum
.GetLevel(nActLv
));
1374 //sal_Unicode cPrefix = rtl::OUString(aFmt.GetPrefix())[0];
1375 //sal_Unicode cSuffix = rtl::OUString(aFmt.GetSuffix())[0];
1376 sal_Int16 eNumType
= aFmt
.GetNumberingType();
1378 sal_uInt16 nCount
= pNumberSettingsArr
->size();
1379 if ( nIndex
>= nCount
)
1382 NumberSettings_ImplPtr _pSet
= (*pNumberSettingsArr
)[nIndex
].get();
1384 _pSet
->pNumSetting
->sPrefix
= aFmt
.GetPrefix();
1385 _pSet
->pNumSetting
->sSuffix
= aFmt
.GetSuffix();
1386 _pSet
->pNumSetting
->nNumberType
= eNumType
;
1387 _pSet
->bIsCustomized
= true;
1389 SvxNumRule
aTmpRule1(aNum
);
1390 SvxNumRule
aTmpRule2(aNum
);
1391 ApplyNumRule(aTmpRule1
,nIndex
,mLevel
,true);
1392 ApplyNumRule(aTmpRule2
,nIndex
,mLevel
,false);
1393 if (aTmpRule1
==aTmpRule2
) _pSet
->bIsCustomized
=false;
1394 if (_pSet
->bIsCustomized
) {
1395 OUString aStrFromRES
= SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_NUMBERING_DESCRIPTION
);
1396 OUString sNUM
= OUString::number( nIndex
+ 1 );
1397 aStrFromRES
= aStrFromRES
.replaceFirst("%LIST_NUM",sNUM
);
1398 _pSet
->sDescription
= aStrFromRES
;
1400 _pSet
->sDescription
= GetDescription(nIndex
,true);
1402 ImplStore(OUString("standard.syb"));
1406 bool NumberingTypeMgr::ApplyNumRule(SvxNumRule
& aNum
, sal_uInt16 nIndex
, sal_uInt16 mLevel
, bool isDefault
, bool isResetSize
)
1408 //if ( mLevel == (sal_uInt16)0xFFFF )
1409 // return sal_False;
1411 //DBG_ASSERT(pNumSettingsArr->Count() > nIndex, "wrong index");
1412 if(pNumberSettingsArr
->size() <= nIndex
)
1414 NumberSettingsArr_Impl
* pCurrentNumberSettingsArr
=pNumberSettingsArr
;
1415 if (isDefault
) pCurrentNumberSettingsArr
=pDefaultNumberSettingsArr
;
1416 NumberSettings_ImplPtr _pSet
= (*pCurrentNumberSettingsArr
)[nIndex
].get();
1417 sal_Int16 eNewType
= _pSet
->pNumSetting
->nNumberType
;
1419 sal_uInt16 nMask
= 1;
1420 OUString sNumCharFmtName
= GetBulCharFmtName();
1421 for(sal_uInt16 i
= 0; i
< aNum
.GetLevelCount(); i
++)
1425 SvxNumberFormat
aFmt(aNum
.GetLevel(i
));
1426 if (eNewType
!=aFmt
.GetNumberingType()) isResetSize
=true;
1427 aFmt
.SetNumberingType(eNewType
);
1428 aFmt
.SetPrefix(_pSet
->pNumSetting
->sPrefix
);
1429 aFmt
.SetSuffix(_pSet
->pNumSetting
->sSuffix
);
1431 aFmt
.SetCharFormatName(sNumCharFmtName
);
1432 if (isResetSize
) aFmt
.SetBulletRelSize(100);
1433 aNum
.SetLevel(i
, aFmt
);
1441 OUString
NumberingTypeMgr::GetDescription(sal_uInt16 nIndex
, bool isDefault
)
1444 sal_uInt16 nLength
= 0;
1445 nLength
= pNumberSettingsArr
->size();
1447 if ( nIndex
>= nLength
)
1450 sRet
= (*pNumberSettingsArr
)[nIndex
]->sDescription
;
1451 if (isDefault
) sRet
= (*pDefaultNumberSettingsArr
)[nIndex
]->sDescription
;
1456 bool NumberingTypeMgr::IsCustomized(sal_uInt16 nIndex
)
1459 sal_uInt16 nLength
= 0;
1460 nLength
= pNumberSettingsArr
->size();
1462 if ( nIndex
>= nLength
)
1465 bRet
= (*pNumberSettingsArr
)[nIndex
]->bIsCustomized
;
1469 // Multi-level /Outline Type lib
1470 OutlineTypeMgr::OutlineTypeMgr()
1471 : NBOTypeMgrBase(eNBOType::OUTLINE
)
1474 for(sal_Int32 nItem
= 0; nItem
< DEFAULT_NUM_VALUSET_COUNT
; nItem
++ )
1476 pDefaultOutlineSettingsArrs
[nItem
] = pOutlineSettingsArrs
[nItem
];
1478 //Initial the first time to store the default value. Then do it again for customized value
1480 ImplLoad(OUString("standard.syc"));
1483 OutlineTypeMgr::OutlineTypeMgr(const OutlineTypeMgr
& aTypeMgr
)
1484 : NBOTypeMgrBase(aTypeMgr
)
1487 for(sal_Int32 nItem
= 0; nItem
< DEFAULT_NUM_VALUSET_COUNT
; nItem
++ )
1489 pDefaultOutlineSettingsArrs
[nItem
] = pOutlineSettingsArrs
[nItem
];
1491 //Initial the first time to store the default value. Then do it again for customized value
1493 ImplLoad(OUString("standard.syc"));
1496 class theOutlineTypeMgr
: public rtl::Static
<OutlineTypeMgr
, theOutlineTypeMgr
> {};
1498 OutlineTypeMgr
& OutlineTypeMgr::GetInstance()
1500 return theOutlineTypeMgr::get();
1503 void OutlineTypeMgr::Init()
1505 Reference
< XComponentContext
> xContext
= ::comphelper::getProcessComponentContext();
1506 Reference
<XDefaultNumberingProvider
> xDefNum
= DefaultNumberingProvider::create( xContext
);
1508 Sequence
<Reference
<XIndexAccess
> > aOutlineAccess
;
1509 Locale
aLocale(Application::GetSettings().GetLanguageTag().getLocale());
1512 aOutlineAccess
= xDefNum
->getDefaultOutlineNumberings( aLocale
);
1514 SvxNumRule
aDefNumRule( SvxNumRuleFlags::BULLET_REL_SIZE
| SvxNumRuleFlags::CONTINUOUS
| SvxNumRuleFlags::BULLET_COLOR
|
1515 SvxNumRuleFlags::CHAR_TEXT_DISTANCE
| SvxNumRuleFlags::SYMBOL_ALIGNMENT
,
1517 SvxNumRuleType::NUMBERING
, SvxNumberFormat::LABEL_ALIGNMENT
);
1519 for(sal_Int32 nItem
= 0;
1520 nItem
< aOutlineAccess
.getLength() && nItem
< DEFAULT_NUM_VALUSET_COUNT
;
1523 pOutlineSettingsArrs
[ nItem
] = new OutlineSettings_Impl
;
1524 OutlineSettings_Impl
* pItemArr
= pOutlineSettingsArrs
[ nItem
];
1525 pItemArr
->sDescription
= SVX_RESSTR( RID_SVXSTR_OUTLINENUM_DESCRIPTION_0
+ nItem
);
1526 pItemArr
->pNumSettingsArr
= new NumSettingsArr_Impl
;
1527 Reference
<XIndexAccess
> xLevel
= aOutlineAccess
.getConstArray()[nItem
];
1528 for(sal_Int32 nLevel
= 0; nLevel
< xLevel
->getCount() && nLevel
< 5; nLevel
++)
1530 Any aValueAny
= xLevel
->getByIndex(nLevel
);
1531 Sequence
<PropertyValue
> aLevelProps
;
1532 aValueAny
>>= aLevelProps
;
1533 NumSettings_ImplPtr pNew
= lcl_CreateNumberingSettingsPtr(aLevelProps
);
1534 SvxNumberFormat
aNumFmt( aDefNumRule
.GetLevel( nLevel
) );
1535 pNew
->eLabelFollowedBy
= aNumFmt
.GetLabelFollowedBy();
1536 pNew
->nTabValue
= aNumFmt
.GetListtabPos();
1537 pNew
->eNumAlign
= aNumFmt
.GetNumAdjust();
1538 pNew
->nNumAlignAt
= aNumFmt
.GetFirstLineIndent();
1539 pNew
->nNumIndentAt
= aNumFmt
.GetIndentAt();
1540 pItemArr
->pNumSettingsArr
->push_back(std::shared_ptr
<NumSettings_Impl
>(pNew
));
1549 sal_uInt16
OutlineTypeMgr::GetNBOIndexForNumRule(SvxNumRule
& aNum
,sal_uInt16
/*mLevel*/,sal_uInt16 nFromIndex
)
1551 sal_uInt16 nLength
= sizeof(pOutlineSettingsArrs
)/sizeof(OutlineSettings_Impl
*);
1552 for(sal_uInt16 iDex
= nFromIndex
; iDex
< nLength
; iDex
++)
1554 bool bNotMatch
= false;
1555 OutlineSettings_Impl
* pItemArr
= pOutlineSettingsArrs
[iDex
];
1556 sal_uInt16 nCount
= pItemArr
->pNumSettingsArr
->size();
1557 for (sal_uInt16 iLevel
=0;iLevel
< nCount
;iLevel
++)
1559 NumSettings_ImplPtr _pSet
= (*pItemArr
->pNumSettingsArr
)[iLevel
].get();
1560 sal_Int16 eNType
= _pSet
->nNumberType
;
1562 SvxNumberFormat
aFmt(aNum
.GetLevel(iLevel
));
1563 OUString sPrefix
= aFmt
.GetPrefix();
1564 OUString sLclSuffix
= aFmt
.GetSuffix();
1565 sal_Int16 eNumType
= aFmt
.GetNumberingType();
1566 if( eNumType
== SVX_NUM_CHAR_SPECIAL
)
1568 sal_Unicode cChar
= aFmt
.GetBulletChar();
1569 //const vcl::Font* pFont = aFmt.GetBulletFont();
1570 sal_Unicode ccChar
= _pSet
->sBulletChar
[0];
1571 // rtl::OUString sFont = _pSet->sBulletFont;
1572 if ( !((cChar
== ccChar
) && //pFont && sFont.compareTo(pFont->GetName()) &&
1573 _pSet
->eLabelFollowedBy
== aFmt
.GetLabelFollowedBy() &&
1574 _pSet
->nTabValue
== aFmt
.GetListtabPos() &&
1575 _pSet
->eNumAlign
== aFmt
.GetNumAdjust() &&
1576 _pSet
->nNumAlignAt
== aFmt
.GetFirstLineIndent() &&
1577 _pSet
->nNumIndentAt
== aFmt
.GetIndentAt()))
1582 }else if ((eNumType
&(~LINK_TOKEN
)) == SVX_NUM_BITMAP
) {
1583 const SvxBrushItem
* pBrsh1
= aFmt
.GetBrush();
1584 const SvxBrushItem
* pBrsh2
= _pSet
->pBrushItem
;
1585 bool bIsMatch
= false;
1586 if (pBrsh1
==pBrsh2
) bIsMatch
= true;
1587 if (pBrsh1
&& pBrsh2
) {
1588 const Graphic
* pGrf1
= pBrsh1
->GetGraphic();;
1589 const Graphic
* pGrf2
= pBrsh2
->GetGraphic();;
1590 if (pGrf1
==pGrf2
) bIsMatch
= true;
1591 if (pGrf1
&& pGrf2
) {
1592 if ( pGrf1
->GetBitmap().IsEqual(pGrf2
->GetBitmap()) &&
1593 _pSet
->aSize
==aFmt
.GetGraphicSize())
1603 if (!(sPrefix
== _pSet
->sPrefix
&&
1604 sLclSuffix
== _pSet
->sSuffix
&&
1605 eNumType
== eNType
&&
1606 _pSet
->eLabelFollowedBy
== aFmt
.GetLabelFollowedBy() &&
1607 _pSet
->nTabValue
== aFmt
.GetListtabPos() &&
1608 _pSet
->eNumAlign
== aFmt
.GetNumAdjust() &&
1609 _pSet
->nNumAlignAt
== aFmt
.GetFirstLineIndent() &&
1610 _pSet
->nNumIndentAt
== aFmt
.GetIndentAt()))
1622 return (sal_uInt16
)0xFFFF;
1625 bool OutlineTypeMgr::RelplaceNumRule(SvxNumRule
& aNum
, sal_uInt16 nIndex
, sal_uInt16 mLevel
)
1627 //if ( mLevel == 0 || mLevel == (sal_uInt16)0xFFFF )
1628 // return sal_False;
1630 sal_uInt16 nLength
= sizeof(pOutlineSettingsArrs
)/sizeof(OutlineSettings_Impl
*);
1631 if ( nIndex
>= nLength
)
1634 OutlineSettings_Impl
* pItemArr
= pOutlineSettingsArrs
[nIndex
];
1635 sal_uInt16 nCount
= pItemArr
->pNumSettingsArr
->size();
1636 for (sal_uInt16 iLevel
=0;iLevel
< nCount
;iLevel
++)
1638 SvxNumberFormat
aFmt(aNum
.GetLevel(iLevel
));
1639 //sal_Unicode cPrefix = rtl::OUString(aFmt.GetPrefix())[0];
1640 //sal_Unicode cSuffix = rtl::OUString(aFmt.GetSuffix())[0];
1641 sal_Int16 eNumType
= aFmt
.GetNumberingType();
1643 NumSettings_ImplPtr _pSet
= (*pItemArr
->pNumSettingsArr
)[iLevel
].get();
1645 _pSet
->eLabelFollowedBy
= aFmt
.GetLabelFollowedBy();
1646 _pSet
->nTabValue
= aFmt
.GetListtabPos();
1647 _pSet
->eNumAlign
= aFmt
.GetNumAdjust();
1648 _pSet
->nNumAlignAt
= aFmt
.GetFirstLineIndent();
1649 _pSet
->nNumIndentAt
= aFmt
.GetIndentAt();
1651 if( eNumType
== SVX_NUM_CHAR_SPECIAL
)
1653 sal_Unicode cChar
= aFmt
.GetBulletChar();
1654 OUString
sChar(cChar
);
1655 _pSet
->sBulletChar
= sChar
;//OUString(cChar);
1656 if ( aFmt
.GetBulletFont() )
1657 _pSet
->sBulletFont
= rtl::OUString(aFmt
.GetBulletFont()->GetName());
1658 _pSet
->nNumberType
= eNumType
;
1659 pItemArr
->bIsCustomized
= true;
1660 }else if ((eNumType
&(~LINK_TOKEN
)) == SVX_NUM_BITMAP
) {
1661 if (_pSet
->pBrushItem
) {
1662 delete (_pSet
->pBrushItem
);
1663 _pSet
->pBrushItem
=NULL
;
1665 if (aFmt
.GetBrush())
1666 _pSet
->pBrushItem
= new SvxBrushItem(*aFmt
.GetBrush());
1667 _pSet
->aSize
= aFmt
.GetGraphicSize();
1668 _pSet
->nNumberType
= eNumType
;
1671 _pSet
->sPrefix
= aFmt
.GetPrefix();
1672 _pSet
->sSuffix
= aFmt
.GetSuffix();
1673 _pSet
->nNumberType
= eNumType
;
1674 if ( aFmt
.GetBulletFont() )
1675 _pSet
->sBulletFont
= rtl::OUString(aFmt
.GetBulletFont()->GetName());
1676 pItemArr
->bIsCustomized
= true;
1679 SvxNumRule
aTmpRule1(aNum
);
1680 SvxNumRule
aTmpRule2(aNum
);
1681 ApplyNumRule(aTmpRule1
,nIndex
,mLevel
,true);
1682 ApplyNumRule(aTmpRule2
,nIndex
,mLevel
,false);
1683 if (aTmpRule1
==aTmpRule2
) pItemArr
->bIsCustomized
=false;
1684 if (pItemArr
->bIsCustomized
) {
1685 OUString aStrFromRES
= SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_MULTILEVEL_DESCRIPTION
);
1686 OUString sNUM
= OUString::number( nIndex
+ 1 );
1687 aStrFromRES
= aStrFromRES
.replaceFirst("%LIST_NUM",sNUM
);
1688 pItemArr
->sDescription
= aStrFromRES
;
1690 pItemArr
->sDescription
= GetDescription(nIndex
,true);
1692 ImplStore(OUString("standard.syc"));
1696 bool OutlineTypeMgr::ApplyNumRule(SvxNumRule
& aNum
, sal_uInt16 nIndex
, sal_uInt16
/*mLevel*/, bool isDefault
, bool isResetSize
)
1698 //if ( mLevel == (sal_uInt16)0xFFFF )
1699 // return sal_False;
1701 DBG_ASSERT(DEFAULT_NUM_VALUSET_COUNT
> nIndex
, "wrong index");
1702 if(DEFAULT_NUM_VALUSET_COUNT
<= nIndex
)
1705 const FontList
* pList
= 0;
1707 OutlineSettings_Impl
* pItemArr
= pOutlineSettingsArrs
[nIndex
];
1708 if (isDefault
) pItemArr
=pDefaultOutlineSettingsArrs
[nIndex
];
1710 //Font& rActBulletFont = lcl_GetDefaultBulletFont();
1711 NumSettingsArr_Impl
*pNumSettingsArr
=pItemArr
->pNumSettingsArr
;
1713 NumSettings_ImplPtr pLevelSettings
= 0;
1714 OUString sBulletCharFormatName
= GetBulCharFmtName();
1715 for(sal_uInt16 i
= 0; i
< aNum
.GetLevelCount(); i
++)
1717 if(pNumSettingsArr
->size() > i
)
1718 pLevelSettings
= (*pNumSettingsArr
)[i
].get();
1723 SvxNumberFormat
aFmt(aNum
.GetLevel(i
));
1724 //aFmt.SetBulletFont(&pLevelSettings->aFont);
1725 vcl::Font
& rActBulletFont
= lcl_GetDefaultBulletFont();
1726 if (pLevelSettings
->nNumberType
!=aFmt
.GetNumberingType()) isResetSize
=true;
1727 aFmt
.SetNumberingType( pLevelSettings
->nNumberType
);
1728 sal_uInt16 nUpperLevelOrChar
= (sal_uInt16
)pLevelSettings
->nParentNumbering
;
1729 if(aFmt
.GetNumberingType() == SVX_NUM_CHAR_SPECIAL
)
1731 if( pLevelSettings
->sBulletFont
.getLength() &&
1732 pLevelSettings
->sBulletFont
.compareTo(rActBulletFont
.GetName()))
1734 //search for the font
1737 SfxObjectShell
* pCurDocShell
= SfxObjectShell::Current();
1738 const SvxFontListItem
* pFontListItem
= static_cast<const SvxFontListItem
*>( pCurDocShell
->GetItem( SID_ATTR_CHAR_FONTLIST
) );
1739 pList
= pFontListItem
? pFontListItem
->GetFontList() : 0;
1741 if(pList
&& pList
->IsAvailable( pLevelSettings
->sBulletFont
) )
1743 vcl::FontInfo aInfo
= pList
->Get(pLevelSettings
->sBulletFont
,WEIGHT_NORMAL
, ITALIC_NONE
);
1744 vcl::Font
aFont(aInfo
);
1745 aFmt
.SetBulletFont(&aFont
);
1749 //if it cannot be found then create a new one
1750 vcl::Font
aCreateFont( pLevelSettings
->sBulletFont
, OUString(), Size( 0, 14 ) );
1751 aCreateFont
.SetCharSet( RTL_TEXTENCODING_DONTKNOW
);
1752 aCreateFont
.SetFamily( FAMILY_DONTKNOW
);
1753 aCreateFont
.SetPitch( PITCH_DONTKNOW
);
1754 aCreateFont
.SetWeight( WEIGHT_DONTKNOW
);
1755 aCreateFont
.SetTransparent( true );
1756 aFmt
.SetBulletFont( &aCreateFont
);
1759 aFmt
.SetBulletFont( &rActBulletFont
);
1761 sal_Unicode cChar
= 0;
1762 if( !pLevelSettings
->sBulletChar
.isEmpty() )
1763 cChar
= pLevelSettings
->sBulletChar
[0];
1764 if( AllSettings::GetLayoutRTL() )
1766 if( 0 == i
&& cChar
== BulletsTypeMgr::aDynamicBulletTypes
[5] )
1767 cChar
= BulletsTypeMgr::aDynamicRTLBulletTypes
[5];
1770 const SvxNumberFormat
& numberFmt
= aNum
.GetLevel(0);
1771 if( numberFmt
.GetBulletChar() == BulletsTypeMgr::aDynamicRTLBulletTypes
[5] )
1772 cChar
= BulletsTypeMgr::aDynamicRTLBulletTypes
[4];
1776 aFmt
.SetBulletChar(cChar
);
1777 aFmt
.SetCharFormatName( sBulletCharFormatName
);
1778 if (isResetSize
) aFmt
.SetBulletRelSize(45);
1779 }else if ((aFmt
.GetNumberingType()&(~LINK_TOKEN
)) == SVX_NUM_BITMAP
) {
1780 if (pLevelSettings
->pBrushItem
) {
1781 const Graphic
* pGrf
= pLevelSettings
->pBrushItem
->GetGraphic();;
1782 Size aSize
= pLevelSettings
->aSize
;
1783 sal_Int16 eOrient
= text::VertOrientation::LINE_CENTER
;
1784 if (!isResetSize
&& aFmt
.GetGraphicSize()!=Size(0,0)) aSize
=aFmt
.GetGraphicSize();
1786 if (aSize
.Width()==0 && aSize
.Height()==0 && pGrf
) {
1787 aSize
= SvxNumberFormat::GetGraphicSizeMM100( pGrf
);
1790 aSize
= OutputDevice::LogicToLogic(aSize
, MAP_100TH_MM
, (MapUnit
)GetMapUnit());
1791 aFmt
.SetGraphicBrush( pLevelSettings
->pBrushItem
, &aSize
, &eOrient
);
1795 aFmt
.SetIncludeUpperLevels(sal::static_int_cast
< sal_uInt8
>(0 != nUpperLevelOrChar
? aNum
.GetLevelCount() : 0));
1796 aFmt
.SetCharFormatName(sBulletCharFormatName
);
1797 if (isResetSize
) aFmt
.SetBulletRelSize(100);
1799 if(pNumSettingsArr
->size() > i
) {
1800 aFmt
.SetLabelFollowedBy(pLevelSettings
->eLabelFollowedBy
);
1801 aFmt
.SetListtabPos(pLevelSettings
->nTabValue
);
1802 aFmt
.SetNumAdjust(pLevelSettings
->eNumAlign
);
1803 aFmt
.SetFirstLineIndent(pLevelSettings
->nNumAlignAt
);
1804 aFmt
.SetIndentAt(pLevelSettings
->nNumIndentAt
);
1806 aFmt
.SetPrefix(pLevelSettings
->sPrefix
);
1807 aFmt
.SetSuffix(pLevelSettings
->sSuffix
);
1808 aNum
.SetLevel(i
, aFmt
);
1814 OUString
OutlineTypeMgr::GetDescription(sal_uInt16 nIndex
, bool isDefault
)
1817 sal_uInt16 nLength
= 0;
1818 nLength
= sizeof(pOutlineSettingsArrs
)/sizeof(OutlineSettings_Impl
*);
1820 if ( nIndex
>= nLength
)
1824 OutlineSettings_Impl
* pItemArr
= pOutlineSettingsArrs
[nIndex
];
1825 if (isDefault
) pItemArr
= pDefaultOutlineSettingsArrs
[nIndex
];
1828 sRet
= pItemArr
->sDescription
;
1834 bool OutlineTypeMgr::IsCustomized(sal_uInt16 nIndex
)
1838 sal_uInt16 nLength
= 0;
1839 nLength
= sizeof(pOutlineSettingsArrs
)/sizeof(OutlineSettings_Impl
*);
1841 if ( nIndex
>= nLength
)
1845 OutlineSettings_Impl
* pItemArr
= pOutlineSettingsArrs
[nIndex
];
1848 bRet
= pItemArr
->bIsCustomized
;
1858 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */