Kaydet (Commit) 69c29c9f authored tarafından Noel Grandin's avatar Noel Grandin

convert eNBOType constants to scoped enum

and remove unused constants, which means we can remove the
GraphicBulletsTypeMgr and MixBulletsTypeMgr classes

Change-Id: I395691b48987543355379708e2c60d0de438d72c
üst 594c2b98
......@@ -30,15 +30,10 @@ namespace svx { namespace sidebar {
#define DEFAULT_NUM_VALUSET_COUNT 8
#define DEFAULT_NUMBERING_CACHE_FORMAT_VERSION 0x10
typedef sal_uInt16 NBOType;
namespace eNBOType
enum class NBOType
{
const NBOType BULLETS = 0x01;
const NBOType GRAPHICBULLETS = 0x02;
const NBOType NUMBERING = 0x03;
const NBOType OUTLINE = 0x04;
const NBOType MIXBULLETS = 0x05;
}
Bullets = 1, Numbering, Outline
};
enum class NBType
{
......@@ -240,48 +235,6 @@ class SVX_DLLPUBLIC BulletsTypeMgr: public NBOTypeMgrBase
static BulletsTypeMgr& GetInstance();
};
class SVX_DLLPUBLIC GraphicBulletsTypeMgr: public NBOTypeMgrBase
{
friend class OutlineTypeMgr;
friend class NumberingTypeMgr;
private:
GraphicBulletsTypeMgr(const GraphicBulletsTypeMgr&) = delete;
public:
typedef std::vector<GrfBulDataRelation*> ListType;
ListType aGrfDataLst;
public:
GraphicBulletsTypeMgr();
virtual ~GraphicBulletsTypeMgr() override;
virtual void Init() override;
virtual sal_uInt16 GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex=0) override;
virtual void RelplaceNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel) override;
virtual void ApplyNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel, bool isDefault=false,bool isResetSize=false) override;
virtual OUString GetDescription(sal_uInt16 nIndex,bool isDefault=false) override;
virtual bool IsCustomized(sal_uInt16 nIndex) override;
OUString GetGrfName(sal_uInt16 nIndex);
static GraphicBulletsTypeMgr& GetInstance();
};
class SVX_DLLPUBLIC MixBulletsTypeMgr: public NBOTypeMgrBase
{
friend class OutlineTypeMgr;
friend class NumberingTypeMgr;
private:
MixBulletsTypeMgr(const MixBulletsTypeMgr&) = delete;
public:
static MixBulletsSettings_Impl* pActualBullets[DEFAULT_BULLET_TYPES];
static MixBulletsSettings_Impl* pDefaultActualBullets[DEFAULT_BULLET_TYPES];
public:
MixBulletsTypeMgr();
virtual ~MixBulletsTypeMgr() override {}
virtual void Init() override;
virtual sal_uInt16 GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex=0) override;
virtual void RelplaceNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel) override;
virtual void ApplyNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel, bool isDefault=false,bool isResetSize=false) override;
virtual OUString GetDescription(sal_uInt16 nIndex,bool isDefault=false) override;
virtual bool IsCustomized(sal_uInt16 nIndex) override;
static MixBulletsTypeMgr& GetInstance();
};
class SVX_DLLPUBLIC NumberingTypeMgr: public NBOTypeMgrBase
{
......
......@@ -199,7 +199,7 @@ void FuOutlineBullet::SetCurrentBulletsNumbering(SfxRequest& rReq)
// get numbering rule corresponding to <nIdx> and apply the needed number formats to <pNumRule>
NBOTypeMgrBase* pNumRuleMgr =
NBOutlineTypeMgrFact::CreateInstance(
nSId == FN_SVX_SET_BULLET ? eNBOType::BULLETS : eNBOType::NUMBERING );
nSId == FN_SVX_SET_BULLET ? NBOType::Bullets : NBOType::Numbering );
if ( pNumRuleMgr )
{
sal_uInt16 nActNumLvl = (sal_uInt16)0xFFFF;
......
......@@ -618,7 +618,7 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,(sal_uInt16)0xFFFF));
if ( bBullets )
{
NBOTypeMgrBase* pBullets = NBOutlineTypeMgrFact::CreateInstance(eNBOType::BULLETS);
NBOTypeMgrBase* pBullets = NBOutlineTypeMgrFact::CreateInstance(NBOType::Bullets);
if ( pBullets )
{
sal_uInt16 nBulIndex = pBullets->GetNBOIndexForNumRule(*pNumRule,nActNumLvl);
......@@ -626,7 +626,7 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
}
}else
{
NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(eNBOType::NUMBERING);
NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(NBOType::Numbering);
if ( pNumbering )
{
sal_uInt16 nBulIndex = pNumbering->GetNBOIndexForNumRule(*pNumRule,nActNumLvl);
......
......@@ -62,7 +62,6 @@ using namespace com::sun::star::container;
using namespace com::sun::star::style;
namespace svx { namespace sidebar {
#define MAX_VALUESET_GRAPHIC 30
vcl::Font& lcl_GetDefaultBulletFont()
{
......@@ -493,681 +492,7 @@ vcl::Font BulletsTypeMgr::GetBulCharFont(sal_uInt16 nIndex)
return aRet;
}
// Graphic Bullet Type lib
GraphicBulletsTypeMgr::GraphicBulletsTypeMgr()
: NBOTypeMgrBase()
{
Init();
}
GraphicBulletsTypeMgr::~GraphicBulletsTypeMgr()
{
for (const GrfBulDataRelation* p : aGrfDataLst)
delete p;
}
class theGraphicBulletsTypeMgr : public rtl::Static<GraphicBulletsTypeMgr, theGraphicBulletsTypeMgr> {};
GraphicBulletsTypeMgr& GraphicBulletsTypeMgr::GetInstance()
{
return theGraphicBulletsTypeMgr::get();
}
void GraphicBulletsTypeMgr::Init()
{
std::vector<OUString> aGrfNames;
GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS, aGrfNames);
for(size_t i = 0; i < aGrfNames.size(); i++)
{
OUString sGrfNm = aGrfNames[i];
INetURLObject aObj(sGrfNm);
if(aObj.GetProtocol() == INetProtocol::File)
sGrfNm = aObj.PathToFileName();
GrfBulDataRelation* pEntry = new GrfBulDataRelation(NBType::GraphicBullets);
pEntry->nTabIndex = i+1;
pEntry->nGallaryIndex = i;
pEntry->sGrfName = sGrfNm;
if( i < MAX_VALUESET_GRAPHIC )
{
pEntry->sDescription = SVX_RESSTR( RID_SVXSTR_GRAPHICS_DESCRIPTIONS + i );
}else
{
pEntry->sDescription = sGrfNm;
}
aGrfDataLst.push_back(pEntry);
}
}
sal_uInt16 GraphicBulletsTypeMgr::GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 /*nFromIndex*/)
{
if ( mLevel == (sal_uInt16)0xFFFF || mLevel == 0)
return (sal_uInt16)0xFFFF;
sal_uInt16 nActLv = IsSingleLevel(mLevel);
if ( nActLv == (sal_uInt16)0xFFFF )
return (sal_uInt16)0xFFFF;
SvxNumberFormat aFmt(aNum.GetLevel(nActLv));
const SvxBrushItem* pBrsh = aFmt.GetBrush();
const Graphic* pGrf = nullptr;
if ( pBrsh )
pGrf = pBrsh->GetGraphic();
if ( pGrf )
{
Graphic aGraphic;
for (const GrfBulDataRelation* pEntry : aGrfDataLst)
{
bool bExist = false;
if ( pEntry)
bExist = GalleryExplorer::GetGraphicObj(GALLERY_THEME_BULLETS, pEntry->nGallaryIndex,&aGraphic);
if (bExist) {
Bitmap aSum=pGrf->GetBitmap();
Bitmap aSum1=aGraphic.GetBitmap();
if (aSum.IsEqual(aSum1))
return pEntry->nTabIndex;
}
}
}
return (sal_uInt16)0xFFFF;
}
void GraphicBulletsTypeMgr::RelplaceNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel)
{
if ( mLevel == (sal_uInt16)0xFFFF || mLevel > aNum.GetLevelCount() || mLevel == 0)
return;
if ( GetNBOIndexForNumRule(aNum,mLevel) != (sal_uInt16)0xFFFF )
return;
if ( nIndex >= aGrfDataLst.size() )
return;
sal_uInt16 nActLv = IsSingleLevel(mLevel);
if ( nActLv == (sal_uInt16)0xFFFF )
return;
SvxNumberFormat aFmt(aNum.GetLevel(nActLv));
const SvxBrushItem* pBrsh = aFmt.GetBrush();
const Graphic* pGrf = nullptr;
if ( pBrsh )
pGrf = pBrsh->GetGraphic();
else
return;
if ( pGrf )
{
const OUString aGrfName = pBrsh->GetGraphicLink();
//String* pGrfName = (String*)(pBrsh->GetGraphicLink());
GrfBulDataRelation* pEntry = aGrfDataLst[nIndex];
if ( !aGrfName.isEmpty() )
pEntry->sGrfName = aGrfName;
//pEntry->sDescription.clear();
pEntry->nGallaryIndex = (sal_uInt16)0xFFFF;
pEntry->bIsCustomized = true;
OUString aStrFromRES = SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_BULLET_DESCRIPTION);
OUString sNUM = OUString::number( nIndex + 1 );
aStrFromRES = aStrFromRES.replaceFirst("%LIST_NUM",sNUM);
pEntry->sDescription = aStrFromRES;
}
}
void GraphicBulletsTypeMgr::ApplyNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel, bool /*isDefault*/, bool /*isResetSize*/)
{
//if ( mLevel == (sal_uInt16)0xFFFF )
// return sal_False;
if ( nIndex >= aGrfDataLst.size() )
return;
OUString sGrfName;
GrfBulDataRelation* pEntry = aGrfDataLst[nIndex];
sGrfName= pEntry->sGrfName;
sal_uInt16 nMask = 1;
sal_uInt16 nSetNumberingType = SVX_NUM_BITMAP;
OUString sNumCharFmtName = GetBulCharFmtName();
for(sal_uInt16 i = 0; i < aNum.GetLevelCount(); i++)
{
if(mLevel & nMask)
{
SvxNumberFormat aFmt(aNum.GetLevel(i));
aFmt.SetNumberingType(nSetNumberingType);
aFmt.SetPrefix( "" );
aFmt.SetSuffix( "" );
aFmt.SetCharFormatName( sNumCharFmtName );
Graphic aGraphic;
if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, pEntry->nGallaryIndex, &aGraphic))
{
Size aSize = SvxNumberFormat::GetGraphicSizeMM100(&aGraphic);
sal_Int16 eOrient = text::VertOrientation::LINE_CENTER;
aSize = OutputDevice::LogicToLogic(aSize, MAP_100TH_MM, (MapUnit)GetMapUnit());
SvxBrushItem aBrush(aGraphic, GPOS_AREA, SID_ATTR_BRUSH );
aFmt.SetGraphicBrush( &aBrush, &aSize, &eOrient );
}
else// if(pGrfName)
aFmt.SetGraphic( sGrfName );
aNum.SetLevel(i, aFmt);
}
nMask <<= 1 ;
}
}
OUString GraphicBulletsTypeMgr::GetDescription(sal_uInt16 nIndex, bool /*isDefault*/)
{
OUString sRet;
sal_uInt16 nLength = 0;
nLength = aGrfDataLst.size();
if ( nIndex >= nLength )
return sRet;
else
{
GrfBulDataRelation* pEntry = aGrfDataLst[nIndex];
if ( pEntry )
{
sRet = pEntry->sDescription;
}
}
return sRet;
}
bool GraphicBulletsTypeMgr::IsCustomized(sal_uInt16 nIndex)
{
bool bRet = false;
sal_uInt16 nLength = 0;
nLength = aGrfDataLst.size() ;
if ( nIndex >= nLength )
return bRet;
else
{
GrfBulDataRelation* pEntry = aGrfDataLst[nIndex];
if ( pEntry )
{
bRet = pEntry->bIsCustomized;
}
}
return bRet;
}
OUString GraphicBulletsTypeMgr::GetGrfName(sal_uInt16 nIndex)
{
OUString sRet;
if ( nIndex < aGrfDataLst.size() )
{
GrfBulDataRelation* pEntry = aGrfDataLst[nIndex];
if ( pEntry )
{
sRet = pEntry->sGrfName;
}
}
return sRet;
}
// Mix Bullets Type lib
MixBulletsSettings_Impl* MixBulletsTypeMgr::pActualBullets[] ={nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr};
MixBulletsSettings_Impl* MixBulletsTypeMgr::pDefaultActualBullets[] ={nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr};
MixBulletsTypeMgr::MixBulletsTypeMgr()
: NBOTypeMgrBase()
{
Init();
for(sal_Int32 nItem = 0; nItem < DEFAULT_BULLET_TYPES; nItem++ )
{
pDefaultActualBullets[nItem] = pActualBullets[nItem];
}
//Initial the first time to store the default value. Then do it again for customized value
Init();
ImplLoad("standard.sya");
}
class theMixBulletsTypeMgr : public rtl::Static<MixBulletsTypeMgr, theMixBulletsTypeMgr> {};
MixBulletsTypeMgr& MixBulletsTypeMgr::GetInstance()
{
return theMixBulletsTypeMgr::get();
}
void MixBulletsTypeMgr::Init()
{
BulletsTypeMgr &rBTMgr = BulletsTypeMgr::GetInstance();
{
//Index 1
pActualBullets[0] = new MixBulletsSettings_Impl(NBType::Bullets);
pActualBullets[0]->eType = NBType::Bullets;
pActualBullets[0]->nIndex = 0+1; //index in the tab page display,decrease 1 to the index within arr
pActualBullets[0]->nIndexDefault = 2; //index in the tab page display,decrease 1 to the index within arr
pActualBullets[0]->pBullets = new BulletsSettings_Impl(NBType::Bullets) ;
static_cast<BulletsSettings_Impl*>(pActualBullets[0]->pBullets)->cBulletChar = BulletsTypeMgr::GetBulChar(pActualBullets[0]->nIndexDefault-1);
static_cast<BulletsSettings_Impl*>(pActualBullets[0]->pBullets)->aFont = BulletsTypeMgr::GetBulCharFont(pActualBullets[0]->nIndexDefault-1);
static_cast<BulletsSettings_Impl*>(pActualBullets[0]->pBullets)->sDescription = rBTMgr.GetDescription(pActualBullets[0]->nIndexDefault-1);
static_cast<BulletsSettings_Impl*>(pActualBullets[0]->pBullets)->bIsCustomized = rBTMgr.IsCustomized(pActualBullets[0]->nIndexDefault-1);
static_cast<BulletsSettings_Impl*>(pActualBullets[0]->pBullets)->eType = NBType::Bullets;
//Index 2
pActualBullets[1] = new MixBulletsSettings_Impl(NBType::Bullets);
pActualBullets[1]->eType = NBType::Bullets;
pActualBullets[1]->nIndex = 1+1; //index in the tab page display,decrease 1 to the index within arr
pActualBullets[1]->nIndexDefault = 3; //index in the tab page display,decrease 1 to the index within arr
pActualBullets[1]->pBullets = new BulletsSettings_Impl(NBType::Bullets) ;
static_cast<BulletsSettings_Impl*>(pActualBullets[1]->pBullets)->cBulletChar = BulletsTypeMgr::GetBulChar(pActualBullets[1]->nIndexDefault-1);
static_cast<BulletsSettings_Impl*>(pActualBullets[1]->pBullets)->aFont = BulletsTypeMgr::GetBulCharFont(pActualBullets[1]->nIndexDefault-1);
static_cast<BulletsSettings_Impl*>(pActualBullets[1]->pBullets)->sDescription = rBTMgr.GetDescription(pActualBullets[1]->nIndexDefault-1);
static_cast<BulletsSettings_Impl*>(pActualBullets[1]->pBullets)->bIsCustomized = rBTMgr.IsCustomized(pActualBullets[1]->nIndexDefault-1);
static_cast<BulletsSettings_Impl*>(pActualBullets[1]->pBullets)->eType = NBType::Bullets;
//Index 3
pActualBullets[2] = new MixBulletsSettings_Impl(NBType::Bullets);
pActualBullets[2]->eType = NBType::Bullets;
pActualBullets[2]->nIndex = 2+1; //index in the tab page display,decrease 1 to the index within arr
pActualBullets[2]->nIndexDefault = 4; //index in the tab page display,decrease 1 to the index within arr
pActualBullets[2]->pBullets = new BulletsSettings_Impl(NBType::Bullets) ;
static_cast<BulletsSettings_Impl*>(pActualBullets[2]->pBullets)->cBulletChar = BulletsTypeMgr::GetBulChar(pActualBullets[2]->nIndexDefault-1);
static_cast<BulletsSettings_Impl*>(pActualBullets[2]->pBullets)->aFont = BulletsTypeMgr::GetBulCharFont(pActualBullets[2]->nIndexDefault-1);
static_cast<BulletsSettings_Impl*>(pActualBullets[2]->pBullets)->sDescription = rBTMgr.GetDescription(pActualBullets[2]->nIndexDefault-1);
static_cast<BulletsSettings_Impl*>(pActualBullets[2]->pBullets)->bIsCustomized = rBTMgr.IsCustomized(pActualBullets[2]->nIndexDefault-1);
static_cast<BulletsSettings_Impl*>(pActualBullets[2]->pBullets)->eType = NBType::Bullets;
//Index 4
pActualBullets[3] = new MixBulletsSettings_Impl(NBType::Bullets);
pActualBullets[3]->eType = NBType::Bullets;
pActualBullets[3]->nIndex = 3+1; //index in the tab page display,decrease 1 to the index within arr
pActualBullets[3]->nIndexDefault = 5; //index in the tab page display,decrease 1 to the index within arr
pActualBullets[3]->pBullets = new BulletsSettings_Impl(NBType::Bullets) ;
static_cast<BulletsSettings_Impl*>(pActualBullets[3]->pBullets)->cBulletChar = BulletsTypeMgr::GetBulChar(pActualBullets[3]->nIndexDefault-1);
static_cast<BulletsSettings_Impl*>(pActualBullets[3]->pBullets)->aFont = BulletsTypeMgr::GetBulCharFont(pActualBullets[3]->nIndexDefault-1);
static_cast<BulletsSettings_Impl*>(pActualBullets[3]->pBullets)->sDescription = rBTMgr.GetDescription(pActualBullets[3]->nIndexDefault-1);
static_cast<BulletsSettings_Impl*>(pActualBullets[3]->pBullets)->bIsCustomized = rBTMgr.IsCustomized(pActualBullets[3]->nIndexDefault-1);
static_cast<BulletsSettings_Impl*>(pActualBullets[3]->pBullets)->eType = NBType::Bullets;
//Index 5
pActualBullets[4] = new MixBulletsSettings_Impl(NBType::Bullets);
pActualBullets[4]->eType = NBType::Bullets;
pActualBullets[4]->nIndex = 4+1; //index in the tab page display,decrease 1 to the index within arr
pActualBullets[4]->nIndexDefault = 6; //index in the tab page display,decrease 1 to the index within arr
pActualBullets[4]->pBullets = new BulletsSettings_Impl(NBType::Bullets) ;
static_cast<BulletsSettings_Impl*>(pActualBullets[4]->pBullets)->cBulletChar = BulletsTypeMgr::GetBulChar(pActualBullets[4]->nIndexDefault-1);
static_cast<BulletsSettings_Impl*>(pActualBullets[4]->pBullets)->aFont = BulletsTypeMgr::GetBulCharFont(pActualBullets[4]->nIndexDefault-1);
static_cast<BulletsSettings_Impl*>(pActualBullets[4]->pBullets)->sDescription = rBTMgr.GetDescription(pActualBullets[4]->nIndexDefault-1);
static_cast<BulletsSettings_Impl*>(pActualBullets[4]->pBullets)->bIsCustomized = rBTMgr.IsCustomized(pActualBullets[4]->nIndexDefault-1);
static_cast<BulletsSettings_Impl*>(pActualBullets[4]->pBullets)->eType = NBType::Bullets;
//Index 6
pActualBullets[5] = new MixBulletsSettings_Impl(NBType::Bullets);
pActualBullets[5]->eType = NBType::Bullets;
pActualBullets[5]->nIndex = 5+1; //index in the tab page display,decrease 1 to the index within arr
pActualBullets[5]->nIndexDefault = 8; //index in the tab page display,decrease 1 to the index within arr
pActualBullets[5]->pBullets = new BulletsSettings_Impl(NBType::Bullets) ;
static_cast<BulletsSettings_Impl*>(pActualBullets[5]->pBullets)->cBulletChar = BulletsTypeMgr::GetBulChar(pActualBullets[5]->nIndexDefault-1);
static_cast<BulletsSettings_Impl*>(pActualBullets[5]->pBullets)->aFont = BulletsTypeMgr::GetBulCharFont(pActualBullets[5]->nIndexDefault-1);
static_cast<BulletsSettings_Impl*>(pActualBullets[5]->pBullets)->sDescription = rBTMgr.GetDescription(pActualBullets[5]->nIndexDefault-1);
static_cast<BulletsSettings_Impl*>(pActualBullets[5]->pBullets)->bIsCustomized = rBTMgr.IsCustomized(pActualBullets[5]->nIndexDefault-1);
static_cast<BulletsSettings_Impl*>(pActualBullets[5]->pBullets)->eType = NBType::Bullets;
}
GraphicBulletsTypeMgr& rGrfTMgr = GraphicBulletsTypeMgr::GetInstance();
{
//Index 7
pActualBullets[6] = new MixBulletsSettings_Impl(NBType::GraphicBullets);
pActualBullets[6]->eType = NBType::GraphicBullets;
pActualBullets[6]->nIndex = 6+1; //index in the tab page display,decrease 1 to the index within arr
pActualBullets[6]->nIndexDefault = 9; //index in the tab page display,decrease 1 to the index within arr
pActualBullets[6]->pBullets = new GrfBulDataRelation(NBType::GraphicBullets) ;
static_cast<GrfBulDataRelation*>(pActualBullets[6]->pBullets)->sGrfName = rGrfTMgr.GetGrfName(pActualBullets[6]->nIndexDefault);
static_cast<GrfBulDataRelation*>(pActualBullets[6]->pBullets)->sDescription = rGrfTMgr.GetDescription(pActualBullets[6]->nIndexDefault);
static_cast<GrfBulDataRelation*>(pActualBullets[6]->pBullets)->bIsCustomized = rGrfTMgr.IsCustomized(pActualBullets[6]->nIndexDefault);
static_cast<GrfBulDataRelation*>(pActualBullets[6]->pBullets)->eType = NBType::GraphicBullets;
//Index 8
pActualBullets[7] = new MixBulletsSettings_Impl(NBType::GraphicBullets);
pActualBullets[7]->eType = NBType::GraphicBullets;
pActualBullets[7]->nIndex = 7+1; //index in the tab page display,decrease 1 to the index within arr
pActualBullets[7]->nIndexDefault = 23; //index in the tab page display,decrease 1 to the index within arr
pActualBullets[7]->pBullets = new GrfBulDataRelation(NBType::GraphicBullets) ;
static_cast<GrfBulDataRelation*>(pActualBullets[7]->pBullets)->sGrfName = rGrfTMgr.GetGrfName(pActualBullets[7]->nIndexDefault);
static_cast<GrfBulDataRelation*>(pActualBullets[7]->pBullets)->sDescription = rGrfTMgr.GetDescription(pActualBullets[7]->nIndexDefault);
static_cast<GrfBulDataRelation*>(pActualBullets[7]->pBullets)->bIsCustomized = rGrfTMgr.IsCustomized(pActualBullets[7]->nIndexDefault);
static_cast<GrfBulDataRelation*>(pActualBullets[7]->pBullets)->eType = NBType::GraphicBullets;
}
}
sal_uInt16 MixBulletsTypeMgr::GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLevel,sal_uInt16 nFromIndex)
{
if ( mLevel == (sal_uInt16)0xFFFF || mLevel == 0)
return (sal_uInt16)0xFFFF;
//if ( !lcl_IsNumFmtSet(pNR, mLevel) ) return (sal_uInt16)0xFFFF;
sal_uInt16 nActLv = IsSingleLevel(mLevel);
if ( nActLv == (sal_uInt16)0xFFFF )
return (sal_uInt16)0xFFFF;
SvxNumberFormat aFmt(aNum.GetLevel(nActLv));
sal_Int16 eNumType = aFmt.GetNumberingType();
if( eNumType == SVX_NUM_CHAR_SPECIAL)
{
sal_Unicode cChar = aFmt.GetBulletChar();
// const vcl::Font* pFont = aFmt.GetBulletFont();
for(sal_uInt16 i = nFromIndex; i < DEFAULT_BULLET_TYPES; i++)
{
if ( pActualBullets[i]->eType == NBType::Bullets )
{
if ( (cChar == static_cast<BulletsSettings_Impl*>(pActualBullets[i]->pBullets)->cBulletChar||
(cChar == 9830 && 57356 == static_cast<BulletsSettings_Impl*>(pActualBullets[i]->pBullets)->cBulletChar) ||
(cChar == 9632 && 57354 == static_cast<BulletsSettings_Impl*>(pActualBullets[i]->pBullets)->cBulletChar)))//&&
{
return pActualBullets[i]->nIndex;
}
}
}
}else if ( (eNumType&(~LINK_TOKEN)) == SVX_NUM_BITMAP )
{
const SvxBrushItem* pBrsh = aFmt.GetBrush();
const Graphic* pGrf = nullptr;
if ( pBrsh )
pGrf = pBrsh->GetGraphic();
if ( pGrf )
{
//const String* pGrfName = pBrsh->GetGraphicLink();
for(sal_uInt16 i = nFromIndex; i < DEFAULT_BULLET_TYPES; i++)
{
if ( pActualBullets[i]->eType == NBType::GraphicBullets )
{
GrfBulDataRelation* pEntry = static_cast<GrfBulDataRelation*>(pActualBullets[i]->pBullets);
//sal_Bool bExist = sal_False;
if ( pEntry && pActualBullets[i]->nIndexDefault == (sal_uInt16)0xFFFF && pEntry->pGrfObj)
{
if ( pEntry->pGrfObj->GetBitmap().IsEqual(pGrf->GetBitmap()))
{
return pActualBullets[i]->nIndex;
}
}else {
Graphic aSrGrf;
if (pEntry)
GalleryExplorer::GetGraphicObj(GALLERY_THEME_BULLETS, pActualBullets[i]->nIndexDefault,&aSrGrf);
Bitmap aSum=pGrf->GetBitmap();
Bitmap aSum1=aSrGrf.GetBitmap();
if (aSum.IsEqual(aSum1))
return pActualBullets[i]->nIndex;
}
}
}
}
}
return (sal_uInt16)0xFFFF;
}
void MixBulletsTypeMgr::RelplaceNumRule(SvxNumRule& aNum,sal_uInt16 nIndex,sal_uInt16 mLevel)
{
if ( mLevel == (sal_uInt16)0xFFFF || mLevel == 0 || nIndex>=DEFAULT_BULLET_TYPES)
return;
//if ( GetNBOIndexForNumRule(aNum,mLevel) != (sal_uInt16)0xFFFF )
// return sal_False;
sal_uInt16 nActLv = IsSingleLevel(mLevel);
if ( nActLv == (sal_uInt16)0xFFFF )
return;
SvxNumberFormat aFmt(aNum.GetLevel(nActLv));
sal_Int16 eNumType = aFmt.GetNumberingType();
if( eNumType == SVX_NUM_CHAR_SPECIAL && pActualBullets[nIndex]->eType == NBType::Bullets )
{
sal_Unicode cChar = aFmt.GetBulletChar();
const vcl::Font* pFont = aFmt.GetBulletFont();
BulletsSettings_Impl* pEntry = static_cast<BulletsSettings_Impl*>(pActualBullets[nIndex]->pBullets);
pEntry->cBulletChar = cChar;
pEntry->aFont = pFont?*pFont:lcl_GetDefaultBulletFont();
pEntry->bIsCustomized = true;
OUString aStrFromRES = SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_BULLET_DESCRIPTION);
OUString sNUM = OUString::number( nIndex + 1 );
aStrFromRES = aStrFromRES.replaceFirst("%LIST_NUM",sNUM);
pEntry->sDescription = aStrFromRES;
}else if ( (eNumType&(~LINK_TOKEN)) == SVX_NUM_BITMAP && pActualBullets[nIndex]->eType == NBType::GraphicBullets )
{
const SvxBrushItem* pBrsh = aFmt.GetBrush();
const Graphic* pGrf = nullptr;
if ( pBrsh )
pGrf = pBrsh->GetGraphic();
else
return;
OUString sEmpty;
if ( pGrf )
{
const OUString aGrfName = pBrsh->GetGraphicLink();
GrfBulDataRelation* pEntry = static_cast<GrfBulDataRelation*>(pActualBullets[nIndex]->pBullets);
if ( !aGrfName.isEmpty() )
pEntry->sGrfName = aGrfName;
GraphicBulletsTypeMgr& rGrfTMgr = GraphicBulletsTypeMgr::GetInstance();
{
pActualBullets[nIndex]->nIndexDefault = (sal_uInt16)0xFFFF;
sEmpty = SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_BULLET_DESCRIPTION);
OUString sNUM = OUString::number( nIndex + 1 );
sEmpty = sEmpty.replaceFirst("%LIST_NUM",sNUM);
pEntry->pGrfObj = new Graphic(*pGrf);
pEntry->aSize = aFmt.GetGraphicSize();
pEntry->aSize = OutputDevice::LogicToLogic(pEntry->aSize,(MapUnit)GetMapUnit(),MAP_100TH_MM);
sal_uInt16 nDIndex = rGrfTMgr.GetNBOIndexForNumRule(aNum,mLevel);
if (nDIndex!=(sal_uInt16)0xFFFF)
pEntry->aSize=Size(0,0);
}
pEntry->sDescription = sEmpty;
pEntry->bIsCustomized = true;
}else
{
return;
}
}else
{
delete pActualBullets[nIndex]->pBullets;
pActualBullets[nIndex]->pBullets = nullptr;
if ( eNumType == SVX_NUM_CHAR_SPECIAL )
{
sal_Unicode cChar = aFmt.GetBulletChar();
const vcl::Font* pFont = aFmt.GetBulletFont();
pActualBullets[nIndex]->eType = NBType::Bullets;
pActualBullets[nIndex]->nIndex = nIndex+1; //index in the tab page display,decrease 1 to the index within arr
pActualBullets[nIndex]->pBullets = new BulletsSettings_Impl(NBType::Bullets) ;
static_cast<BulletsSettings_Impl*>(pActualBullets[nIndex]->pBullets)->cBulletChar = cChar;
static_cast<BulletsSettings_Impl*>(pActualBullets[nIndex]->pBullets)->aFont = pFont?*pFont:lcl_GetDefaultBulletFont();
static_cast<BulletsSettings_Impl*>(pActualBullets[nIndex]->pBullets)->bIsCustomized = true;
static_cast<BulletsSettings_Impl*>(pActualBullets[nIndex]->pBullets)->eType = NBType::Bullets;
pActualBullets[nIndex]->nIndexDefault = (sal_uInt16)0xFFFF;
OUString aStrFromRES = SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_BULLET_DESCRIPTION);
OUString sNUM = OUString::number( nIndex + 1 );
aStrFromRES = aStrFromRES.replaceFirst("%LIST_NUM",sNUM);
static_cast<BulletsSettings_Impl*>(pActualBullets[nIndex]->pBullets)->sDescription = aStrFromRES;
}else if ( (eNumType&(~LINK_TOKEN)) == SVX_NUM_BITMAP )
{
const SvxBrushItem* pBrsh = aFmt.GetBrush();
const Graphic* pGrf = nullptr;
if ( pBrsh )
pGrf = pBrsh->GetGraphic();
else
return;
OUString aGrfName;
if ( pGrf )
{
aGrfName = pBrsh->GetGraphicLink();
pActualBullets[nIndex]->eType = NBType::GraphicBullets;
pActualBullets[nIndex]->nIndex = nIndex+1; //index in the tab page display,decrease 1 to the index within arr
pActualBullets[nIndex]->pBullets = new GrfBulDataRelation(NBType::GraphicBullets) ;
if (!aGrfName.isEmpty())
static_cast<GrfBulDataRelation*>(pActualBullets[nIndex]->pBullets)->sGrfName = aGrfName;
static_cast<GrfBulDataRelation*>(pActualBullets[nIndex]->pBullets)->bIsCustomized = true;
static_cast<GrfBulDataRelation*>(pActualBullets[nIndex]->pBullets)->eType = NBType::GraphicBullets;
GraphicBulletsTypeMgr& rGrfTMgr = GraphicBulletsTypeMgr::GetInstance();
{
pActualBullets[nIndex]->nIndexDefault = (sal_uInt16)0xFFFF;
OUString aStrFromRES = SVX_RESSTR( RID_SVXSTR_NUMBULLET_CUSTOM_BULLET_DESCRIPTION);
OUString sNUM = OUString::number( nIndex + 1 );
aStrFromRES = aStrFromRES.replaceFirst("%LIST_NUM",sNUM);
static_cast<GrfBulDataRelation*>(pActualBullets[nIndex]->pBullets)->sDescription = aStrFromRES;
static_cast<GrfBulDataRelation*>(pActualBullets[nIndex]->pBullets)->pGrfObj = new Graphic(*pGrf);
static_cast<GrfBulDataRelation*>(pActualBullets[nIndex]->pBullets)->pGrfObj = new Graphic(*pGrf);
Size aTmpSize = aFmt.GetGraphicSize();
aTmpSize = OutputDevice::LogicToLogic(aTmpSize,(MapUnit)GetMapUnit(),MAP_100TH_MM);
sal_uInt16 nDIndex = rGrfTMgr.GetNBOIndexForNumRule(aNum,mLevel);
if (nDIndex!=(sal_uInt16)0xFFFF)
aTmpSize=Size(0,0);
static_cast<GrfBulDataRelation*>(pActualBullets[nIndex]->pBullets)->aSize = aTmpSize;
}
}
}
}
SvxNumRule aTmpRule1(aNum);
ApplyNumRule(aTmpRule1,nIndex,mLevel,true);
if (GetNBOIndexForNumRule(aTmpRule1,mLevel,nIndex)==nIndex+1) {
if (pActualBullets[nIndex]->eType == NBType::Bullets) {
BulletsSettings_Impl* pEntry = static_cast<BulletsSettings_Impl*>(pActualBullets[nIndex]->pBullets);
pEntry->bIsCustomized = false;
pEntry->sDescription = GetDescription(nIndex,true);
}
if (pActualBullets[nIndex]->eType == NBType::GraphicBullets) {
GrfBulDataRelation* pEntry = static_cast<GrfBulDataRelation*>(pActualBullets[nIndex]->pBullets);
pEntry->bIsCustomized = false;
pEntry->sDescription = GetDescription(nIndex,true);
}
}
ImplStore("standard.sya");
}
void MixBulletsTypeMgr::ApplyNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt16 mLevel, bool isDefault, bool isResetSize)
{
//if ( mLevel == (sal_uInt16)0xFFFF || nIndex>=DEFAULT_BULLET_TYPES )
if ( nIndex>=DEFAULT_BULLET_TYPES )
return;
MixBulletsSettings_Impl* pCurrentBullets = pActualBullets[nIndex];
if (isDefault) pCurrentBullets=pDefaultActualBullets[nIndex];
if ( pCurrentBullets->eType == NBType::Bullets )
{
sal_Unicode cChar;
cChar = static_cast<BulletsSettings_Impl*>(pCurrentBullets->pBullets)->cBulletChar;
//vcl::Font& rActBulletFont = lcl_GetDefaultBulletFont();
vcl::Font rActBulletFont = static_cast<BulletsSettings_Impl*>(pCurrentBullets->pBullets)->aFont;
sal_uInt16 nMask = 1;
OUString sBulletCharFormatName = GetBulCharFmtName();
for(sal_uInt16 i = 0; i < aNum.GetLevelCount(); i++)
{
if(mLevel & nMask)
{
SvxNumberFormat aFmt(aNum.GetLevel(i));
if (SVX_NUM_CHAR_SPECIAL !=aFmt.GetNumberingType()) isResetSize=true;
aFmt.SetNumberingType( SVX_NUM_CHAR_SPECIAL );
aFmt.SetBulletFont(&rActBulletFont);
aFmt.SetBulletChar(cChar );
aFmt.SetCharFormatName(sBulletCharFormatName);
aFmt.SetPrefix( "" );
aFmt.SetSuffix( "" );
if (isResetSize) aFmt.SetBulletRelSize(45);
aNum.SetLevel(i, aFmt);
}
nMask <<= 1;
}
}else if ( pCurrentBullets->eType == NBType::GraphicBullets )
{
OUString sGrfName;
GrfBulDataRelation* pEntry = static_cast<GrfBulDataRelation*>(pCurrentBullets->pBullets);
sGrfName= pEntry->sGrfName;
sal_uInt16 nMask = 1;
sal_uInt16 nSetNumberingType = SVX_NUM_BITMAP;
OUString sNumCharFmtName = GetBulCharFmtName();
for(sal_uInt16 i = 0; i < aNum.GetLevelCount(); i++)
{
if(mLevel & nMask)
{
SvxNumberFormat aFmt(aNum.GetLevel(i));
if (SVX_NUM_BITMAP !=aFmt.GetNumberingType()) isResetSize=true;
aFmt.SetNumberingType(nSetNumberingType);
aFmt.SetPrefix( "" );
aFmt.SetSuffix( "" );
aFmt.SetCharFormatName( sNumCharFmtName );
if ( pCurrentBullets->nIndexDefault == (sal_uInt16)0xFFFF && pEntry->pGrfObj )
{
Size aSize = pEntry->aSize;
sal_Int16 eOrient = text::VertOrientation::LINE_CENTER;
if (!isResetSize && aFmt.GetGraphicSize()!=Size(0,0)) aSize=aFmt.GetGraphicSize();
else {
if (aSize.Width()==0 && aSize.Height()==0) {
aSize = SvxNumberFormat::GetGraphicSizeMM100( pEntry->pGrfObj );
}
aSize = OutputDevice::LogicToLogic(aSize, MAP_100TH_MM, (MapUnit)GetMapUnit());
}
SvxBrushItem aBrush(*(pEntry->pGrfObj), GPOS_AREA, SID_ATTR_BRUSH );
aFmt.SetGraphicBrush( &aBrush, &aSize, &eOrient );
}else
{
Graphic aGraphic;
if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, pCurrentBullets->nIndexDefault, &aGraphic))
{
Size aSize = pEntry->aSize;
sal_Int16 eOrient = text::VertOrientation::LINE_CENTER;
if (!isResetSize && aFmt.GetGraphicSize()!=Size(0,0)) aSize=aFmt.GetGraphicSize();
else {
if (aSize.Width()==0 && aSize.Height()==0) {
aSize = SvxNumberFormat::GetGraphicSizeMM100(&aGraphic);
}
aSize = OutputDevice::LogicToLogic(aSize, MAP_100TH_MM, (MapUnit)GetMapUnit());
}
SvxBrushItem aBrush(aGraphic, GPOS_AREA, SID_ATTR_BRUSH );
aFmt.SetGraphicBrush( &aBrush, &aSize, &eOrient );
}else
aFmt.SetGraphic( sGrfName );
}
aNum.SetLevel(i, aFmt);
}
nMask <<= 1 ;
}
}
}
OUString MixBulletsTypeMgr::GetDescription(sal_uInt16 nIndex, bool isDefault)
{
OUString sRet;
//sal_uInt16 nLength = 0;
//nLength = sizeof(pActualBullets)/sizeof(BulletsSettings_Impl);
if ( nIndex >= DEFAULT_BULLET_TYPES )
return sRet;
else
sRet = pActualBullets[nIndex]->pBullets->sDescription;
if (isDefault) sRet = pDefaultActualBullets[nIndex]->pBullets->sDescription;
return sRet;
}
bool MixBulletsTypeMgr::IsCustomized(sal_uInt16 nIndex)
{
bool bRet = false;
//sal_uInt16 nLength = 0;
//nLength = sizeof(pActualBullets)/sizeof(BulletsSettings_Impl);
if ( nIndex >= DEFAULT_BULLET_TYPES )
bRet = false;
else
bRet = pActualBullets[nIndex]->pBullets->bIsCustomized;
return bRet;
}
// Numbering Type lib
NumberingTypeMgr::NumberingTypeMgr()
: NBOTypeMgrBase()
......
......@@ -23,24 +23,15 @@ namespace svx { namespace sidebar { namespace NBOutlineTypeMgrFact {
NBOTypeMgrBase* CreateInstance(const NBOType aType)
{
//NBOTypeMgrBase* pRet= 0;
if ( aType == eNBOType::BULLETS )
if ( aType == NBOType::Bullets )
{
return &BulletsTypeMgr::GetInstance();
}
else if ( aType == eNBOType::GRAPHICBULLETS )
{
return &GraphicBulletsTypeMgr::GetInstance();
}
else if ( aType == eNBOType::MIXBULLETS )
{
return &MixBulletsTypeMgr::GetInstance();
}
else if ( aType == eNBOType::NUMBERING )
else if ( aType == NBOType::Numbering )
{
return &NumberingTypeMgr::GetInstance();
}
else if ( aType == eNBOType::OUTLINE )
else if ( aType == NBOType::Outline )
{
return &OutlineTypeMgr::GetInstance();
}
......
......@@ -1844,7 +1844,7 @@ void SwTextShell::GetState( SfxItemSet &rSet )
{
rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX, USHRT_MAX));
rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX, USHRT_MAX));
NBOTypeMgrBase* pBullets = NBOutlineTypeMgrFact::CreateInstance(eNBOType::BULLETS);
NBOTypeMgrBase* pBullets = NBOutlineTypeMgrFact::CreateInstance(NBOType::Bullets);
if ( pBullets )
{
const sal_uInt16 nBulIndex = pBullets->GetNBOIndexForNumRule(aSvxRule,nActNumLvl);
......@@ -1854,7 +1854,7 @@ void SwTextShell::GetState( SfxItemSet &rSet )
{
rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX, USHRT_MAX));
rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX, USHRT_MAX));
NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(eNBOType::NUMBERING);
NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(NBOType::Numbering);
if ( pNumbering )
{
const sal_uInt16 nBulIndex = pNumbering->GetNBOIndexForNumRule(aSvxRule,nActNumLvl);
......@@ -1865,7 +1865,7 @@ void SwTextShell::GetState( SfxItemSet &rSet )
if ( nWhich == FN_OUTLINE_RULE_INDEX )
{
rSet.Put(SfxUInt16Item(FN_OUTLINE_RULE_INDEX, USHRT_MAX));
NBOTypeMgrBase* pOutline = NBOutlineTypeMgrFact::CreateInstance(eNBOType::OUTLINE);
NBOTypeMgrBase* pOutline = NBOutlineTypeMgrFact::CreateInstance(NBOType::Outline);
if ( pOutline )
{
const sal_uInt16 nIndex = pOutline->GetNBOIndexForNumRule(aSvxRule,nActNumLvl);
......
......@@ -252,11 +252,11 @@ void SwTextShell::ExecSetNumber(SfxRequest &rReq)
if ( pItem != nullptr )
{
const sal_uInt16 nChoosenItemIdx = pItem->GetValue();
sal_uInt16 nNBOType = svx::sidebar::eNBOType::BULLETS;
svx::sidebar::NBOType nNBOType = svx::sidebar::NBOType::Bullets;
if ( nSlot == FN_SVX_SET_NUMBER )
nNBOType = svx::sidebar::eNBOType::NUMBERING;
nNBOType = svx::sidebar::NBOType::Numbering;
else if ( nSlot == FN_SVX_SET_OUTLINE )
nNBOType = svx::sidebar::eNBOType::OUTLINE;
nNBOType = svx::sidebar::NBOType::Outline;
svx::sidebar::NBOTypeMgrBase* pNBOTypeMgr = svx::sidebar::NBOutlineTypeMgrFact::CreateInstance( nNBOType );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment