Kaydet (Commit) d8b1b4b0 authored tarafından Maxim Monastirsky's avatar Maxim Monastirsky

tdf#88290 Adapt the numbering popup to more than 8 items

The items count of NumberingTypeMgr is limited by 8, but
some languages have more items, so remove that limitation.

Also fix the behavior of the 10th item. The old sidebar
popup had a "None" item, whose id was 10 (defined by
DEFAULT_NONE from include/svx/nbdtmg.hxx), and that causes
now the 10th item to behave as on/off toggle. Since we
don't have a "None" item anymore, get rid of that behavior
completely.

Change-Id: I5546ca637f9951cc093a7bbf8fda11dc35341d4e
(cherry picked from commit 71b35212)
üst 8ca4e26a
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
namespace svx { namespace sidebar { namespace svx { namespace sidebar {
#define DEFAULT_BULLET_TYPES 8 #define DEFAULT_BULLET_TYPES 8
#define DEFAULT_NONE 10
#define DEFAULT_NUM_VALUSET_COUNT 8 #define DEFAULT_NUM_VALUSET_COUNT 8
#define DEFAULT_NUMBERING_CACHE_FORMAT_VERSION 0x10 #define DEFAULT_NUMBERING_CACHE_FORMAT_VERSION 0x10
......
...@@ -182,17 +182,12 @@ void FuOutlineBullet::SetCurrentBulletsNumbering(SfxRequest& rReq) ...@@ -182,17 +182,12 @@ void FuOutlineBullet::SetCurrentBulletsNumbering(SfxRequest& rReq)
sal_uInt16 nIdx = pItem->GetValue(); sal_uInt16 nIdx = pItem->GetValue();
bool bToggle = false; bool bToggle = false;
bool bSwitchOff = false;
if( nIdx == (sal_uInt16)0xFFFF ) if( nIdx == (sal_uInt16)0xFFFF )
{ {
// If the nIdx is (sal_uInt16)0xFFFF, means set bullet status to on/off // If the nIdx is (sal_uInt16)0xFFFF, means set bullet status to on/off
nIdx = 1; nIdx = 1;
bToggle = true; bToggle = true;
} }
else if (nIdx == DEFAULT_NONE)
{
bSwitchOff = true;
}
nIdx--; nIdx--;
sal_uInt32 nNumItemId = SID_ATTR_NUMBERING_RULE; sal_uInt32 nNumItemId = SID_ATTR_NUMBERING_RULE;
...@@ -266,18 +261,11 @@ void FuOutlineBullet::SetCurrentBulletsNumbering(SfxRequest& rReq) ...@@ -266,18 +261,11 @@ void FuOutlineBullet::SetCurrentBulletsNumbering(SfxRequest& rReq)
if ( pOLV ) if ( pOLV )
{ {
if ( bSwitchOff ) pOLV->ToggleBulletsNumbering( bToggle, nSId == FN_SVX_SET_BULLET, bInMasterView ? 0 : pNumRule );
{
pOLV->SwitchOffBulletsNumbering( true );
}
else
{
pOLV->ToggleBulletsNumbering( bToggle, nSId == FN_SVX_SET_BULLET, bInMasterView ? 0 : pNumRule );
}
} }
else else
{ {
mpView->ChangeMarkedObjectsBulletsNumbering( bToggle, nSId == FN_SVX_SET_BULLET, bInMasterView ? 0 : pNumRule, bSwitchOff ); mpView->ChangeMarkedObjectsBulletsNumbering( bToggle, nSId == FN_SVX_SET_BULLET, bInMasterView ? 0 : pNumRule, false );
} }
if ( bInMasterView ) if ( bInMasterView )
{ {
......
...@@ -576,9 +576,6 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet ) ...@@ -576,9 +576,6 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
boost::scoped_ptr<SvxNumRule> pNumRule; boost::scoped_ptr<SvxNumRule> pNumRule;
const SfxPoolItem* pTmpItem=NULL; const SfxPoolItem* pTmpItem=NULL;
sal_uInt16 nNumItemId = SID_ATTR_NUMBERING_RULE; sal_uInt16 nNumItemId = SID_ATTR_NUMBERING_RULE;
rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,DEFAULT_NONE));
rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,DEFAULT_NONE));
sal_uInt16 nActNumLvl = mpDrawView->GetSelectionLevel(); sal_uInt16 nActNumLvl = mpDrawView->GetSelectionLevel();
pTmpItem=GetNumBulletItem(aNewAttr, nNumItemId); pTmpItem=GetNumBulletItem(aNewAttr, nNumItemId);
......
...@@ -1302,7 +1302,7 @@ void NumberingTypeMgr::Init() ...@@ -1302,7 +1302,7 @@ void NumberingTypeMgr::Init()
{ {
aNumberings = xDefNum->getDefaultContinuousNumberingLevels( aLocale ); aNumberings = xDefNum->getDefaultContinuousNumberingLevels( aLocale );
sal_Int32 nLength = aNumberings.getLength() > DEFAULT_NUM_VALUSET_COUNT ? DEFAULT_NUM_VALUSET_COUNT :aNumberings.getLength(); sal_Int32 nLength = aNumberings.getLength();
const Sequence<PropertyValue>* pValuesArr = aNumberings.getConstArray(); const Sequence<PropertyValue>* pValuesArr = aNumberings.getConstArray();
for(sal_Int32 i = 0; i < nLength; i++) for(sal_Int32 i = 0; i < nLength; i++)
......
...@@ -1794,8 +1794,6 @@ void SwTextShell::GetState( SfxItemSet &rSet ) ...@@ -1794,8 +1794,6 @@ void SwTextShell::GetState( SfxItemSet &rSet )
{ {
SwNumRule* pCurRule = const_cast<SwNumRule*>(GetShell().GetNumRuleAtCurrCrsrPos()); SwNumRule* pCurRule = const_cast<SwNumRule*>(GetShell().GetNumRuleAtCurrCrsrPos());
sal_uInt16 nActNumLvl = USHRT_MAX; sal_uInt16 nActNumLvl = USHRT_MAX;
rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,DEFAULT_NONE));
rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,DEFAULT_NONE));
if( pCurRule ) if( pCurRule )
{ {
nActNumLvl = GetShell().GetNumLevel(); nActNumLvl = GetShell().GetNumLevel();
......
...@@ -251,45 +251,38 @@ void SwTextShell::ExecSetNumber(SfxRequest &rReq) ...@@ -251,45 +251,38 @@ void SwTextShell::ExecSetNumber(SfxRequest &rReq)
if ( pItem != NULL ) if ( pItem != NULL )
{ {
const sal_uInt16 nChoosenItemIdx = pItem->GetValue(); const sal_uInt16 nChoosenItemIdx = pItem->GetValue();
if ( nChoosenItemIdx == DEFAULT_NONE ) svx::sidebar::NBOTypeMgrBase* pNBOTypeMgr =
nSlot == FN_SVX_SET_NUMBER
? svx::sidebar::NBOutlineTypeMgrFact::CreateInstance( svx::sidebar::eNBOType::NUMBERING )
: svx::sidebar::NBOutlineTypeMgrFact::CreateInstance( svx::sidebar::eNBOType::BULLETS );
if ( pNBOTypeMgr != NULL )
{ {
GetShell().DelNumRules(); const SwNumRule* pNumRuleAtCurrentSelection = GetShell().GetNumRuleAtCurrentSelection();
} sal_uInt16 nActNumLvl = USHRT_MAX;
else if ( pNumRuleAtCurrentSelection != NULL )
{
svx::sidebar::NBOTypeMgrBase* pNBOTypeMgr =
nSlot == FN_SVX_SET_NUMBER
? svx::sidebar::NBOutlineTypeMgrFact::CreateInstance( svx::sidebar::eNBOType::NUMBERING )
: svx::sidebar::NBOutlineTypeMgrFact::CreateInstance( svx::sidebar::eNBOType::BULLETS );
if ( pNBOTypeMgr != NULL )
{ {
const SwNumRule* pNumRuleAtCurrentSelection = GetShell().GetNumRuleAtCurrentSelection(); const sal_uInt16 nLevel = GetShell().GetNumLevel();
sal_uInt16 nActNumLvl = USHRT_MAX; if ( nLevel < MAXLEVEL )
if ( pNumRuleAtCurrentSelection != NULL )
{ {
const sal_uInt16 nLevel = GetShell().GetNumLevel(); nActNumLvl = 1 << nLevel;
if ( nLevel < MAXLEVEL )
{
nActNumLvl = 1 << nLevel;
}
} }
SwNumRule aNewNumRule(
pNumRuleAtCurrentSelection != NULL ? pNumRuleAtCurrentSelection->GetName() : GetShell().GetUniqueNumRuleName(),
numfunc::GetDefaultPositionAndSpaceMode() );
SvxNumRule aNewSvxNumRule = pNumRuleAtCurrentSelection != NULL
? pNumRuleAtCurrentSelection->MakeSvxNumRule()
: aNewNumRule.MakeSvxNumRule();
// set unit attribute to NB Manager
SfxItemSet aSet( GetPool(), SID_ATTR_NUMBERING_RULE, SID_PARAM_CUR_NUM_LEVEL, 0 );
aSet.Put( SvxNumBulletItem( aNewSvxNumRule ) );
pNBOTypeMgr->SetItems( &aSet );
pNBOTypeMgr->ApplyNumRule( aNewSvxNumRule, nChoosenItemIdx - 1, nActNumLvl );
aNewNumRule.SetSvxRule( aNewSvxNumRule, GetShell().GetDoc() );
aNewNumRule.SetAutoRule( true );
const bool bCreateNewList = ( pNumRuleAtCurrentSelection == NULL );
GetShell().SetCurNumRule( aNewNumRule, bCreateNewList );
} }
SwNumRule aNewNumRule(
pNumRuleAtCurrentSelection != NULL ? pNumRuleAtCurrentSelection->GetName() : GetShell().GetUniqueNumRuleName(),
numfunc::GetDefaultPositionAndSpaceMode() );
SvxNumRule aNewSvxNumRule = pNumRuleAtCurrentSelection != NULL
? pNumRuleAtCurrentSelection->MakeSvxNumRule()
: aNewNumRule.MakeSvxNumRule();
// set unit attribute to NB Manager
SfxItemSet aSet( GetPool(), SID_ATTR_NUMBERING_RULE, SID_PARAM_CUR_NUM_LEVEL, 0 );
aSet.Put( SvxNumBulletItem( aNewSvxNumRule ) );
pNBOTypeMgr->SetItems( &aSet );
pNBOTypeMgr->ApplyNumRule( aNewSvxNumRule, nChoosenItemIdx - 1, nActNumLvl );
aNewNumRule.SetSvxRule( aNewSvxNumRule, GetShell().GetDoc() );
aNewNumRule.SetAutoRule( true );
const bool bCreateNewList = ( pNumRuleAtCurrentSelection == NULL );
GetShell().SetCurNumRule( aNewNumRule, bCreateNewList );
} }
} }
} }
......
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