20 #include <svx/svxids.hrc>
32 #include <svx/strings.hrc>
44 #include <com/sun/star/text/VertOrientation.hpp>
45 #include <com/sun/star/style/NumberingType.hpp>
46 #include <com/sun/star/container/XIndexAccess.hpp>
47 #include <com/sun/star/text/DefaultNumberingProvider.hpp>
48 #include <com/sun/star/beans/PropertyValue.hpp>
69 tmp.SetCharSet( RTL_TEXTENCODING_SYMBOL );
70 tmp.SetFamily( FAMILY_DONTKNOW );
71 tmp.SetPitch( PITCH_DONTKNOW );
72 tmp.SetWeight( WEIGHT_DONTKNOW );
73 tmp.SetTransparent(
true );
76 return aDefBulletFont;
93 NumSettings_Impl* pNew =
new NumSettings_Impl;
94 for(
const PropertyValue& rValue : rLevelProps)
96 if(rValue.Name ==
"NumberingType")
99 if (rValue.Value >>= nTmp)
100 pNew->nNumberType =
static_cast<SvxNumType>(nTmp);
102 else if(rValue.Name ==
"Prefix")
103 rValue.Value >>= pNew->sPrefix;
104 else if(rValue.Name ==
"Suffix")
105 rValue.Value >>= pNew->sSuffix;
106 else if(rValue.Name ==
"ParentNumbering")
107 rValue.Value >>= pNew->nParentNumbering;
108 else if(rValue.Name ==
"BulletChar")
109 rValue.Value >>= pNew->sBulletChar;
110 else if(rValue.Name ==
"BulletFontName")
111 rValue.Value >>= pNew->sBulletFont;
113 const sal_Unicode cLocalPrefix = pNew->sPrefix.getLength() ? pNew->sPrefix[0] : 0;
114 const sal_Unicode cLocalSuffix = pNew->sSuffix.getLength() ? pNew->sSuffix[0] : 0;
115 if( cLocalPrefix ==
' ') pNew->sPrefix.clear();
116 if( cLocalSuffix ==
' ') pNew->sSuffix.clear();
122 sal_uInt16 NBOTypeMgrBase:: IsSingleLevel(sal_uInt16 nCurLevel)
124 sal_uInt16 nLv = sal_uInt16(0xFFFF);
126 sal_uInt16 nMask = 1;
129 if(nCurLevel & nMask)
140 return sal_uInt16(0xFFFF);
152 aBulletCharFmtName = pBulletCharFmt->
GetValue();
156 aNumCharFmtName = pNumCharFmt->
GetValue();
159 SfxItemState eState = pSet->GetItemState(SID_ATTR_NUMBERING_RULE,
false, &pItem);
160 if(eState == SfxItemState::SET)
162 eCoreUnit = pSet->GetPool()->GetMetric(pSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE));
166 if(eState == SfxItemState::SET)
168 eCoreUnit = pSet->GetPool()->GetMetric(pSet->GetPool()->GetWhich(
EE_PARA_NUMBULLET));
173 void NBOTypeMgrBase::ImplLoad(std::u16string_view filename)
176 MapUnit eOldCoreUnit=eCoreUnit;
177 eCoreUnit = MapUnit::Map100thMM;
183 sal_Int32 nNumIndex = 0;
184 xIStm->ReadUInt32( nVersion );
187 xIStm->ReadInt32( nNumIndex );
194 if (aFmt.GetBulletFont()) {
196 Color c=aFont.GetColor();
199 aFmt.SetBulletFont(&aFont);
203 RelplaceNumRule(aNum,nNumIndex,0x1);
204 xIStm->ReadInt32( nNumIndex );
208 eCoreUnit = eOldCoreUnit;
211 void NBOTypeMgrBase::ImplStore(std::u16string_view filename)
213 if (bIsLoading)
return;
214 MapUnit eOldCoreUnit=eCoreUnit;
215 eCoreUnit = MapUnit::Map100thMM;
223 xOStm->WriteUInt32( nVersion );
225 if (IsCustomized(nItem)) {
226 SvxNumRule aDefNumRule( SvxNumRuleFlags::BULLET_REL_SIZE | SvxNumRuleFlags::CONTINUOUS | SvxNumRuleFlags::BULLET_COLOR,
229 xOStm->WriteInt32( nItem );
230 ApplyNumRule(aDefNumRule,nItem,0x1,
false,
true);
231 aDefNumRule.
Store(*xOStm);
235 xOStm->WriteInt32( nNumIndex );
237 eCoreUnit = eOldCoreUnit;
241 BulletsSettings* BulletsTypeMgr::pActualBullets[] ={
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr};
242 sal_Unicode BulletsTypeMgr::aDynamicBulletTypes[]={
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' '};
243 sal_Unicode BulletsTypeMgr::aDynamicRTLBulletTypes[]={
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' '};
245 BulletsTypeMgr::BulletsTypeMgr()
253 return theBulletsTypeMgr;
256 void BulletsTypeMgr::Init()
264 pActualBullets[
i]->aFont = rActBulletFont;
265 OString
id = OString::Concat(RID_SVXSTR_BULLET_DESCRIPTION_0.mpId) + OString::number(
i);
266 pActualBullets[
i]->sDescription =
SvxResId(
TranslateId(RID_SVXSTR_BULLET_DESCRIPTION_0.mpContext,
id.getStr()) );
269 sal_uInt16 BulletsTypeMgr::GetNBOIndexForNumRule(
SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex)
271 if ( mLevel == sal_uInt16(0xFFFF) || mLevel == 0)
272 return sal_uInt16(0xFFFF);
275 sal_uInt16 nActLv = IsSingleLevel(mLevel);
277 if ( nActLv == sal_uInt16(0xFFFF) )
278 return sal_uInt16(0xFFFF);
285 (cChar == 9830 && 57356 == pActualBullets[
i]->
cBulletChar) ||
286 (cChar == 9632 && 57354 == pActualBullets[
i]->
cBulletChar) )
292 return sal_uInt16(0xFFFF);
295 void BulletsTypeMgr::RelplaceNumRule(
SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel)
297 if ( mLevel == sal_uInt16(0xFFFF) || mLevel == 0)
300 if ( GetNBOIndexForNumRule(aNum,mLevel) != sal_uInt16(0xFFFF) )
303 sal_uInt16 nActLv = IsSingleLevel(mLevel);
305 if ( nActLv == sal_uInt16(0xFFFF) )
310 std::optional<vcl::Font> pFont = aFmt.GetBulletFont();
314 pActualBullets[nIndex]->cBulletChar = cChar;
316 pActualBullets[nIndex]->aFont = *pFont;
317 pActualBullets[nIndex]->bIsCustomized =
true;
320 void BulletsTypeMgr::ApplyNumRule(
SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel,
bool ,
bool isResetSize)
324 sal_UCS4 cChar = pActualBullets[nIndex]->cBulletChar;
325 const vcl::Font& rActBulletFont = pActualBullets[nIndex]->aFont;
327 sal_uInt16 nMask = 1;
328 OUString sBulletCharFormatName = GetBulletCharFmtName();
335 aFmt.SetBulletFont(&rActBulletFont);
336 aFmt.SetBulletChar(cChar);
337 aFmt.SetCharFormatName(sBulletCharFormatName);
338 aFmt.SetListFormat(
"" );
339 if (isResetSize) aFmt.SetBulletRelSize(45);
346 OUString BulletsTypeMgr::GetDescription(sal_uInt16 nIndex,
bool )
353 sRet = pActualBullets[nIndex]->sDescription;
358 bool BulletsTypeMgr::IsCustomized(sal_uInt16 nIndex)
365 bRet = pActualBullets[nIndex]->bIsCustomized;
371 NumberingTypeMgr::NumberingTypeMgr()
374 maDefaultNumberSettingsArr = maNumberSettingsArr;
375 ImplLoad(
u"standard.syb");
378 NumberingTypeMgr::~NumberingTypeMgr()
384 RID_SVXSTR_SINGLENUM_DESCRIPTION_0,
385 RID_SVXSTR_SINGLENUM_DESCRIPTION_1,
386 RID_SVXSTR_SINGLENUM_DESCRIPTION_2,
387 RID_SVXSTR_SINGLENUM_DESCRIPTION_3,
388 RID_SVXSTR_SINGLENUM_DESCRIPTION_4,
389 RID_SVXSTR_SINGLENUM_DESCRIPTION_5,
390 RID_SVXSTR_SINGLENUM_DESCRIPTION_6,
391 RID_SVXSTR_SINGLENUM_DESCRIPTION_7
397 return theNumberingTypeMgr;
400 void NumberingTypeMgr::Init()
409 aNumberings = xDefNum->getDefaultContinuousNumberingLevels( aLocale );
411 sal_Int32
nLength = aNumberings.getLength();
414 for(sal_Int32
i = 0;
i < nLength;
i++)
417 std::shared_ptr<NumberSettings_Impl> pNumEntry = std::make_shared<NumberSettings_Impl>();
418 pNumEntry->pNumSetting = pNew;
420 pNumEntry->sDescription =
SvxResId(RID_SVXSTR_SINGLENUM_DESCRIPTIONS[i]);
421 maNumberSettingsArr.push_back(pNumEntry);
429 sal_uInt16 NumberingTypeMgr::GetNBOIndexForNumRule(
SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex)
431 if ( mLevel == sal_uInt16(0xFFFF) || mLevel > aNum.
GetLevelCount() || mLevel == 0)
432 return sal_uInt16(0xFFFF);
434 sal_uInt16 nActLv = IsSingleLevel(mLevel);
436 if ( nActLv == sal_uInt16(0xFFFF) )
437 return sal_uInt16(0xFFFF);
442 const OUString&
sPrefix = aFmt.GetPrefix();
443 const OUString& sLclSuffix = aFmt.GetSuffix();
444 sal_Int16 eNumType = aFmt.GetNumberingType();
446 sal_uInt16
nCount = maNumberSettingsArr.size();
447 for(sal_uInt16
i = nFromIndex;
i < nCount; ++
i)
453 if (sPrefix == sLocalPrefix &&
454 sLclSuffix == sLocalSuffix &&
462 return sal_uInt16(0xFFFF);
465 void NumberingTypeMgr::RelplaceNumRule(
SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel)
467 sal_uInt16 nActLv = IsSingleLevel(mLevel);
469 if ( nActLv == sal_uInt16(0xFFFF) )
475 sal_uInt16
nCount = maNumberSettingsArr.size();
476 if ( nIndex >= nCount )
488 ApplyNumRule(aTmpRule1,nIndex,mLevel,
true);
489 ApplyNumRule(aTmpRule2,nIndex,mLevel);
494 ImplStore(
u"standard.syb");
497 void NumberingTypeMgr::ApplyNumRule(
SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel,
bool isDefault,
bool isResetSize)
499 if(maNumberSettingsArr.size() <= nIndex)
502 if (isDefault) pCurrentNumberSettingsArr = &maDefaultNumberSettingsArr;
506 sal_uInt16 nMask = 1;
507 OUString sNumCharFmtName = GetNumCharFmtName();
513 if (eNewType!=aFmt.GetNumberingType()) isResetSize=
true;
516 aFmt.SetCharFormatName(sNumCharFmtName);
517 if (isResetSize) aFmt.SetBulletRelSize(100);
524 OUString NumberingTypeMgr::GetDescription(sal_uInt16 nIndex,
bool isDefault)
527 sal_uInt16
nLength = maNumberSettingsArr.size();
529 if ( nIndex >= nLength )
532 sRet = maNumberSettingsArr[nIndex]->sDescription;
533 if (isDefault) sRet = maDefaultNumberSettingsArr[nIndex]->sDescription;
538 bool NumberingTypeMgr::IsCustomized(sal_uInt16 nIndex)
541 sal_uInt16
nLength = maNumberSettingsArr.size();
543 if ( nIndex >= nLength )
546 bRet = maNumberSettingsArr[nIndex]->bIsCustomized;
551 OutlineTypeMgr::OutlineTypeMgr()
556 pDefaultOutlineSettingsArrs[nItem] = pOutlineSettingsArrs[nItem];
560 ImplLoad(
u"standard.syc");
566 return theOutlineTypeMgr;
569 void OutlineTypeMgr::Init()
578 aOutlineAccess = xDefNum->getDefaultOutlineNumberings( aLocale );
580 SvxNumRule aDefNumRule( SvxNumRuleFlags::BULLET_REL_SIZE | SvxNumRuleFlags::CONTINUOUS | SvxNumRuleFlags::BULLET_COLOR,
585 for(sal_Int32 nItem = 0; nItem < nSize; nItem++ )
589 OString
id = OString::Concat(RID_SVXSTR_OUTLINENUM_DESCRIPTION_0.mpId) + OString::number(nItem);
593 for(sal_Int32 nLevel = 0; nLevel < xLevel->getCount() && nLevel < 5; nLevel++)
595 Any aValueAny = xLevel->getByIndex(nLevel);
597 aValueAny >>= aLevelProps;
601 pNew->
nTabValue = aNumFmt.GetListtabPos();
602 pNew->
eNumAlign = aNumFmt.GetNumAdjust();
605 pItemArr->
pNumSettingsArr->push_back(std::shared_ptr<NumSettings_Impl>(pNew));
614 sal_uInt16 OutlineTypeMgr::GetNBOIndexForNumRule(
SvxNumRule& aNum,sal_uInt16 ,sal_uInt16 nFromIndex)
617 for(sal_uInt16 iDex = nFromIndex; iDex < nLength; iDex++)
619 bool bNotMatch =
false;
622 for (sal_uInt16 iLevel=0;iLevel < nCount;iLevel++)
628 const OUString&
sPrefix = aFmt.GetPrefix();
629 const OUString& sLclSuffix = aFmt.GetSuffix();
630 sal_Int16 eNumType = aFmt.GetNumberingType();
633 sal_UCS4 cChar = aFmt.GetBulletChar();
638 if ( !((cChar == ccChar) &&
640 _pSet->
nTabValue == aFmt.GetListtabPos() &&
641 _pSet->
eNumAlign == aFmt.GetNumAdjust() &&
653 bool bIsMatch =
false;
654 if (pBrsh1==pBrsh2) bIsMatch =
true;
655 if (pBrsh1 && pBrsh2) {
658 if (pGrf1==pGrf2) bIsMatch =
true;
659 if (pGrf1 && pGrf2) {
661 _pSet->
aSize == aFmt.GetGraphicSize())
672 if (!(sPrefix == _pSet->
sPrefix &&
673 sLclSuffix == _pSet->
sSuffix &&
674 eNumType == eNType &&
676 _pSet->
nTabValue == aFmt.GetListtabPos() &&
677 _pSet->
eNumAlign == aFmt.GetNumAdjust() &&
691 return sal_uInt16(0xFFFF);
694 void OutlineTypeMgr::RelplaceNumRule(
SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel)
697 if ( nIndex >= nLength )
702 for (sal_uInt16 iLevel=0;iLevel < nCount;iLevel++)
717 sal_UCS4 cChar = aFmt.GetBulletChar();
718 OUString sChar(&cChar, 1);
720 if ( aFmt.GetBulletFont() )
721 _pSet->
sBulletFont = aFmt.GetBulletFont()->GetFamilyName();
731 _pSet->
aSize = aFmt.GetGraphicSize();
735 _pSet->
sPrefix = aFmt.GetPrefix();
736 _pSet->
sSuffix = aFmt.GetSuffix();
738 if ( aFmt.GetBulletFont() )
739 _pSet->
sBulletFont = aFmt.GetBulletFont()->GetFamilyName();
745 ApplyNumRule(aTmpRule1,nIndex,mLevel,
true);
746 ApplyNumRule(aTmpRule2,nIndex,mLevel);
751 ImplStore(
u"standard.syc");
754 void OutlineTypeMgr::ApplyNumRule(
SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 ,
bool isDefault,
bool isResetSize)
763 if (isDefault) pItemArr=pDefaultOutlineSettingsArrs[nIndex];
770 if(pNumSettingsArr->size() >
i)
771 pLevelSettings = (*pNumSettingsArr)[
i].get();
778 if (pLevelSettings->
nNumberType !=aFmt.GetNumberingType()) isResetSize=
true;
779 aFmt.SetNumberingType( pLevelSettings->
nNumberType );
780 sal_uInt16 nUpperLevelOrChar =
static_cast<sal_uInt16
>(pLevelSettings->
nParentNumbering);
784 pLevelSettings->
sBulletFont != rActBulletFont.GetFamilyName() )
791 pList = pFontListItem ? pFontListItem->
GetFontList() :
nullptr;
797 aFmt.SetBulletFont(&aFont);
803 aCreateFont.
SetCharSet( RTL_TEXTENCODING_DONTKNOW );
808 aFmt.SetBulletFont( &aCreateFont );
811 aFmt.SetBulletFont( &rActBulletFont );
821 if( 0 ==
i && cChar == BulletsTypeMgr::aDynamicBulletTypes[5] )
822 cChar = BulletsTypeMgr::aDynamicRTLBulletTypes[5];
826 if( numberFmt.
GetBulletChar() == BulletsTypeMgr::aDynamicRTLBulletTypes[5] )
827 cChar = BulletsTypeMgr::aDynamicRTLBulletTypes[4];
832 aFmt.SetCharFormatName( GetBulletCharFmtName() );
833 if (isResetSize) aFmt.SetBulletRelSize(45);
838 sal_Int16 eOrient = text::VertOrientation::LINE_CENTER;
839 if (!isResetSize && aFmt.GetGraphicSize()!=
Size(0,0))
840 aSize = aFmt.GetGraphicSize();
841 else if (aSize.
IsEmpty() && pGrf)
844 aFmt.SetGraphicBrush( pLevelSettings->
pBrushItem, &aSize, &eOrient );
848 aFmt.SetIncludeUpperLevels(sal::static_int_cast< sal_uInt8 >(0 != nUpperLevelOrChar ? aNum.
GetLevelCount() : 1));
849 aFmt.SetCharFormatName(GetNumCharFmtName());
850 if (isResetSize) aFmt.SetBulletRelSize(100);
852 if(pNumSettingsArr->size() >
i) {
854 aFmt.SetListtabPos(pLevelSettings->
nTabValue);
855 aFmt.SetNumAdjust(pLevelSettings->
eNumAlign);
856 aFmt.SetFirstLineIndent(pLevelSettings->
nNumAlignAt);
859 aFmt.SetListFormat(pLevelSettings->
sPrefix, pLevelSettings->
sSuffix,
i);
864 OUString OutlineTypeMgr::GetDescription(sal_uInt16 nIndex,
bool isDefault)
873 if (isDefault) pItemArr = pDefaultOutlineSettingsArrs[nIndex];
882 bool OutlineTypeMgr::IsCustomized(sal_uInt16 nIndex)
void SetFamily(FontFamily)
SvxNumType GetNumberingType() const
bool IsAvailable(std::u16string_view rName) const
#define DEFAULT_BULLET_TYPES
void SetAlpha(sal_uInt8 nAlpha)
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
#define DEFAULT_NUM_VALUSET_COUNT
static const AllSettings & GetSettings()
const sal_Unicode cBulletChar
void SetWeight(FontWeight)
void SetCharSet(rtl_TextEncoding)
static SfxObjectShell * Current()
#define DEFAULT_NUMBERING_CACHE_FORMAT_VERSION
void Store(SvStream &rStream)
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
static vcl::Font & lcl_GetDefaultBulletFont()
OUString SvxResId(TranslateId aId)
FontMetric Get(const OUString &rName, const OUString &rStyleName) const
const Graphic * GetGraphic(OUString const &referer=OUString()) const
void SetPitch(FontPitch ePitch)
#define SAL_N_ELEMENTS(arr)
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
#define DBG_ASSERT(sCon, aError)
const OUString & GetValue() const
const SvxNumberFormat & GetLevel(sal_uInt16 nLevel) const
sal_uInt16 GetLevelCount() const
static bool GetLayoutRTL()
const TranslateId RID_SVXSTR_SINGLENUM_DESCRIPTIONS[]
BitmapEx GetBitmapEx(const GraphicConversionParameters &rParameters=GraphicConversionParameters()) const
constexpr T & temporary(T &&x)
const LanguageTag & getLocale()
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
virtual void GetDescription(OUString &rName) override
void SetTransparent(bool bTransparent)
bool Append(std::u16string_view rTheSegment, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
constexpr TypedWhichId< SvxNumBulletItem > EE_PARA_NUMBULLET(EE_PARA_START+5)
const FontList * GetFontList() const
void SetNumberingType(SvxNumType nSet)
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
void SetLevel(sal_uInt16 nLevel, const SvxNumberFormat &rFmt, bool bIsValid=true)