This patch is a try to make outline numbering more flexible. I just want to know the feedback of community.
To make outline numbering more flexible, a LabelText property is added to SvxNumberFormat and some elements to ui. So if the LabelText is not empty, governs the format of numbering. The place holder for level numbers are %0 upto %9. So the %0 will be replaced by level 1 number. The level separator is not a hardcoded "." But this patch lacks some parts, such as save and load from files. Thanks Elahi
From 827d72a0806801001fb4096b5299e9f5b664b319 Mon Sep 17 00:00:00 2001 From: Mohammad Elahi <elahimoham...@gmail.com> Date: Tue, 30 Aug 2011 02:22:37 +0430 Subject: [PATCH 1/3] Add LabelText property to SvxNumberFormat A LabelText propery was added to SvxNumberFormat to support customized formating of outline numbering. --- editeng/inc/editeng/numitem.hxx | 3 +++ editeng/source/items/numitem.cxx | 2 ++ 2 files changed, 5 insertions(+), 0 deletions(-) diff --git a/editeng/inc/editeng/numitem.hxx b/editeng/inc/editeng/numitem.hxx index 1084ea1..8b9c9ab 100644 --- a/editeng/inc/editeng/numitem.hxx +++ b/editeng/inc/editeng/numitem.hxx @@ -119,6 +119,7 @@ public: private: String sPrefix; String sSuffix; + String sLabelText; SvxAdjust eNumAdjust; @@ -186,6 +187,8 @@ public: const String& GetPrefix() const { return sPrefix;} void SetSuffix(const String& rSet) { sSuffix = rSet;} const String& GetSuffix() const { return sSuffix;} + void SetLabelText(const String& rSet) { sLabelText = rSet;} + const String& GetLabelText() const { return sLabelText;} void SetCharFmtName(const String& rSet){ sCharStyleName = rSet; } virtual const String& GetCharFmtName()const; diff --git a/editeng/source/items/numitem.cxx b/editeng/source/items/numitem.cxx index eb15ca5..fcb24e6 100644 --- a/editeng/source/items/numitem.cxx +++ b/editeng/source/items/numitem.cxx @@ -289,6 +289,7 @@ SvxNumberFormat& SvxNumberFormat::operator=( const SvxNumberFormat& rFormat ) eVertOrient = rFormat.eVertOrient ; sPrefix = rFormat.sPrefix ; sSuffix = rFormat.sSuffix ; + sLabelText = rFormat.sLabelText ; aGraphicSize = rFormat.aGraphicSize ; nBulletColor = rFormat.nBulletColor ; nBulletRelSize = rFormat.nBulletRelSize; @@ -325,6 +326,7 @@ sal_Bool SvxNumberFormat::operator==( const SvxNumberFormat& rFormat) const eVertOrient != rFormat.eVertOrient || sPrefix != rFormat.sPrefix || sSuffix != rFormat.sSuffix || + sLabelText != rFormat.sLabelText || aGraphicSize != rFormat.aGraphicSize || nBulletColor != rFormat.nBulletColor || nBulletRelSize != rFormat.nBulletRelSize || -- 1.7.4.1
From 041067f41cdd659984d2b6fa123afed93c89881d Mon Sep 17 00:00:00 2001 From: Mohammad Elahi <elahimoham...@gmail.com> Date: Tue, 30 Aug 2011 02:26:05 +0430 Subject: [PATCH 2/3] Add elements to ui to add support for LabelText An edit box was added to outline and numpages dialogs to add a more flexible outline numbering. --- cui/source/inc/numpages.hxx | 2 ++ cui/source/tabpages/numpages.cxx | 15 +++++++++++++++ cui/source/tabpages/numpages.hrc | 3 ++- cui/source/tabpages/numpages.src | 17 +++++++++++++++++ sw/source/ui/inc/outline.hxx | 3 +++ sw/source/ui/misc/outline.cxx | 27 +++++++++++++++++++++++++++ sw/source/ui/misc/outline.hrc | 3 +++ sw/source/ui/misc/outline.src | 17 +++++++++++++++++ 8 files changed, 86 insertions(+), 1 deletions(-) diff --git a/cui/source/inc/numpages.hxx b/cui/source/inc/numpages.hxx index bd61da2..fa57d40 100644 --- a/cui/source/inc/numpages.hxx +++ b/cui/source/inc/numpages.hxx @@ -256,6 +256,8 @@ class SvxNumOptionsTabPage : public SfxTabPage Edit aPrefixED; FixedText aSuffixFT; Edit aSuffixED; + FixedText aLabelTextFT; + Edit aLabelTextED; FixedText aCharFmtFT; ListBox aCharFmtLB; FixedText aBulColorFT; diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx index 4a47004..adf60d6 100644 --- a/cui/source/tabpages/numpages.cxx +++ b/cui/source/tabpages/numpages.cxx @@ -1055,6 +1055,8 @@ SvxNumOptionsTabPage::SvxNumOptionsTabPage(Window* pParent, aPrefixED( this, CUI_RES(ED_PREFIX )), aSuffixFT( this, CUI_RES(FT_SUFFIX )), aSuffixED( this, CUI_RES(ED_SUFFIX )), + aLabelTextFT( this, CUI_RES(FT_LABEL_TEXT )), + aLabelTextED( this, CUI_RES(ED_LABEL_TEXT )), aCharFmtFT( this, CUI_RES(FT_CHARFMT )), aCharFmtLB( this, CUI_RES(LB_CHARFMT )), aBulColorFT( this, CUI_RES(FT_BUL_COLOR)), @@ -1109,6 +1111,7 @@ SvxNumOptionsTabPage::SvxNumOptionsTabPage(Window* pParent, aStartED.SetModifyHdl(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl)); aPrefixED.SetModifyHdl(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl)); aSuffixED.SetModifyHdl(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl)); + aLabelTextED.SetModifyHdl(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl)); aAllLevelNF.SetModifyHdl(LINK(this,SvxNumOptionsTabPage, AllLevelHdl_Impl)); aOrientLB.SetSelectHdl(LINK(this, SvxNumOptionsTabPage, OrientHdl_Impl)); aSameLevelCB.SetClickHdl(LINK(this, SvxNumOptionsTabPage, SameLevelHdl_Impl)); @@ -1455,6 +1458,7 @@ void SvxNumOptionsTabPage::InitControls() sal_Bool bSameStart = sal_True; sal_Bool bSamePrefix = sal_True; sal_Bool bSameSuffix = sal_True; + sal_Bool bSameLabelText = sal_True; sal_Bool bAllLevel = sal_True; sal_Bool bSameCharFmt = sal_True; sal_Bool bSameVOrient = sal_True; @@ -1607,6 +1611,11 @@ void SvxNumOptionsTabPage::InitControls() else aSuffixED.SetText(aEmptyStr); + if(bSameLabelText) + aLabelTextED.SetText(aNumFmtArr[nLvl]->GetLabelText()); + else + aLabelTextED.SetText(aEmptyStr); + if(bSameCharFmt) { if(sFirstCharFmt.Len()) @@ -1652,6 +1661,8 @@ void SvxNumOptionsTabPage::SwitchNumberType( sal_uInt8 nType, sal_Bool ) aPrefixED.Show(bNumeric); aSuffixFT.Show(bNumeric); aSuffixED.Show(bNumeric); + aLabelTextFT.Show(bNumeric); + aLabelTextED.Show(bNumeric); sal_Bool bCharFmt = pActNum->IsFeatureSupported(NUM_CHAR_STYLE); aCharFmtFT.Show(!bBitmap && bCharFmt); @@ -1814,6 +1825,7 @@ IMPL_LINK( SvxNumOptionsTabPage, NumberTypeSelectHdl_Impl, ListBox *, pBox ) { aNumFmt.SetPrefix( aPrefixED.GetText() ); aNumFmt.SetSuffix( aSuffixED.GetText() ); + aNumFmt.SetLabelText( aLabelTextED.GetText() ); SwitchNumberType(SHOW_NUMBERING); pActNum->SetLevel(i, aNumFmt); CheckForStartValue_Impl(nNumberingType); @@ -2250,6 +2262,7 @@ IMPL_LINK( SvxNumOptionsTabPage, EditModifyHdl_Impl, Edit *, pEdit ) sal_Bool bPrefix = pEdit == &aPrefixED; sal_Bool bSuffix = pEdit == &aSuffixED; sal_Bool bStart = pEdit == &aStartED; + sal_Bool bLabelText = pEdit == &aLabelTextED; sal_uInt16 nMask = 1; for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) { @@ -2262,6 +2275,8 @@ IMPL_LINK( SvxNumOptionsTabPage, EditModifyHdl_Impl, Edit *, pEdit ) aNumFmt.SetSuffix( aSuffixED.GetText() ); else if(bStart) aNumFmt.SetStart( (sal_uInt16)aStartED.GetValue() ); + else if(bLabelText) + aNumFmt.SetLabelText( aLabelTextED.GetText() ); else //align { sal_uInt16 nPos = aAlignLB.GetSelectEntryPos(); diff --git a/cui/source/tabpages/numpages.hrc b/cui/source/tabpages/numpages.hrc index 02fb936..e45c4e1 100644 --- a/cui/source/tabpages/numpages.hrc +++ b/cui/source/tabpages/numpages.hrc @@ -129,4 +129,5 @@ #define MF_ALIGNED_AT 257 #define FT_INDENT_AT 258 #define MF_INDENT_AT 259 - +#define FT_LABEL_TEXT 260 +#define ED_LABEL_TEXT 261 diff --git a/cui/source/tabpages/numpages.src b/cui/source/tabpages/numpages.src index 97b6686..dbc6764 100644 --- a/cui/source/tabpages/numpages.src +++ b/cui/source/tabpages/numpages.src @@ -353,6 +353,23 @@ TabPage RID_SVXPAGE_NUM_OPTIONS First = 0 ; Last = 65535 ; }; + FixedText FT_LABEL_TEXT + { + Pos = MAP_APPFONT ( 50 , 123 ) ; + Size = MAP_APPFONT ( 50 , 8 ) ; + Text [ en-US ] = "Label Text" ; + Left = TRUE ; + }; + Edit ED_LABEL_TEXT + { + HelpID = "cui:Edit:RID_SVXPAGE_NUM_OPTIONS:ED_LABEL_TEXT"; + Border = TRUE ; + Pos = MAP_APPFONT ( 103 , 121 ) ; + Size = MAP_APPFONT ( 67 , 12 ) ; + TabStop = TRUE ; + Left = TRUE ; + MaxTextLength = 50 ; + }; FixedText FT_ALIGN { Pos = MAP_APPFONT ( 50 , 135 ) ; diff --git a/sw/source/ui/inc/outline.hxx b/sw/source/ui/inc/outline.hxx index 22bc4f1..fd765f1 100644 --- a/sw/source/ui/inc/outline.hxx +++ b/sw/source/ui/inc/outline.hxx @@ -109,6 +109,8 @@ class SwOutlineSettingsTabPage : public SfxTabPage Edit aSuffixED; FixedText aStartLbl; NumericField aStartEdit; + FixedText aLabelTextFT; + Edit aLabelTextED; NumberingPreview aPreviewWIN; String aNoFmtName; @@ -125,6 +127,7 @@ class SwOutlineSettingsTabPage : public SfxTabPage DECL_LINK( NumberSelect, SwNumberingTypeListBox * ); DECL_LINK( DelimModify, Edit * ); DECL_LINK( StartModified, NumericField * ); + DECL_LINK( LabelTextModify, Edit * ); DECL_LINK( CharFmtHdl, ListBox * ); void Update(); diff --git a/sw/source/ui/misc/outline.cxx b/sw/source/ui/misc/outline.cxx index d4e734e..a78c786 100644 --- a/sw/source/ui/misc/outline.cxx +++ b/sw/source/ui/misc/outline.cxx @@ -456,6 +456,8 @@ SwOutlineSettingsTabPage::SwOutlineSettingsTabPage(Window* pParent, const SfxIte aSuffixED(this, SW_RES(ED_SUFFIX)), aStartLbl(this, SW_RES(FT_START)), aStartEdit(this, SW_RES(ED_START)), + aLabelTextFT(this, SW_RES(FT_LABEL_TEXT)), + aLabelTextED(this, SW_RES(ED_LABEL_TEXT)), aPreviewWIN( this, SW_RES(WIN_PREVIEW )), aNoFmtName(SW_RES(ST_NO_COLL)), @@ -475,6 +477,7 @@ SwOutlineSettingsTabPage::SwOutlineSettingsTabPage(Window* pParent, const SfxIte aPrefixED.SetModifyHdl(LINK(this, SwOutlineSettingsTabPage, DelimModify)); aSuffixED.SetModifyHdl(LINK(this, SwOutlineSettingsTabPage, DelimModify)); aStartEdit.SetModifyHdl(LINK(this, SwOutlineSettingsTabPage, StartModified)); + aLabelTextED.SetModifyHdl(LINK(this, SwOutlineSettingsTabPage, LabelTextModify)); aCharFmtLB.SetSelectHdl(LINK(this, SwOutlineSettingsTabPage, CharFmtHdl)); } @@ -487,6 +490,7 @@ void SwOutlineSettingsTabPage::Update() { sal_Bool bSamePrefix = sal_True; sal_Bool bSameSuffix = sal_True; + sal_Bool bSameLabelText = sal_True; sal_Bool bSameType = sal_True; sal_Bool bSameComplete = sal_True; sal_Bool bSameStart = sal_True; @@ -507,6 +511,7 @@ void SwOutlineSettingsTabPage::Update() bSameStart &= aNumFmtArr[i]->GetStart() == aNumFmtArr[0]->GetStart(); bSamePrefix &= aNumFmtArr[i]->GetPrefix() == aNumFmtArr[0]->GetPrefix(); bSameSuffix &= aNumFmtArr[i]->GetSuffix() == aNumFmtArr[0]->GetSuffix(); + bSameLabelText &= aNumFmtArr[i]->GetLabelText() == aNumFmtArr[0]->GetLabelText(); bSameComplete &= aNumFmtArr[i]->GetIncludeUpperLevels() == aNumFmtArr[0]->GetIncludeUpperLevels(); const SwCharFmt* pFmt = aNumFmtArr[i]->GetCharFmt(); bSameCharFmt &= (!pFirstFmt && !pFmt) @@ -531,6 +536,11 @@ void SwOutlineSettingsTabPage::Update() else aSuffixED.SetText(aEmptyStr); + if(bSameLabelText) + aLabelTextED.SetText(aNumFmtArr[0]->GetLabelText()); + else + aLabelTextED.SetText(aEmptyStr); + if(bSameCharFmt) { if(pFirstFmt) @@ -566,6 +576,7 @@ void SwOutlineSettingsTabPage::Update() aNumberBox.SelectNumberingType( rFmt.GetNumberingType() ); aPrefixED.SetText(rFmt.GetPrefix()); aSuffixED.SetText(rFmt.GetSuffix()); + aLabelTextED.SetText(rFmt.GetLabelText()); const SwCharFmt* pFmt = rFmt.GetCharFmt(); if(pFmt) aCharFmtLB.SelectEntry(pFmt->GetName()); @@ -734,6 +745,22 @@ IMPL_LINK( SwOutlineSettingsTabPage, StartModified, NumericField *, pFld ) return 0; } +IMPL_LINK( SwOutlineSettingsTabPage, LabelTextModify, Edit *, EMPTYARG ) +{ + sal_uInt16 nMask = 1; + for(sal_uInt16 i = 0; i < MAXLEVEL; i++) + { + if(nActLevel & nMask) + { + SwNumFmt aNumFmt(pNumRule->Get(i)); + aNumFmt.SetLabelText( aLabelTextED.GetText() ); + pNumRule->Set(i, aNumFmt); + } + nMask <<= 1; + } + SetModified(); + return 0; +} IMPL_LINK( SwOutlineSettingsTabPage, CharFmtHdl, ListBox *, EMPTYARG ) { String sEntry = aCharFmtLB.GetSelectEntry(); diff --git a/sw/source/ui/misc/outline.hrc b/sw/source/ui/misc/outline.hrc index 2f8a4a4..eb333db 100644 --- a/sw/source/ui/misc/outline.hrc +++ b/sw/source/ui/misc/outline.hrc @@ -96,3 +96,6 @@ #define ST_FORM 140 #define FT_CHARFMT 141 #define LB_CHARFMT 141 + +#define FT_LABEL_TEXT 142 +#define ED_LABEL_TEXT 143 diff --git a/sw/source/ui/misc/outline.src b/sw/source/ui/misc/outline.src index f84fd67..9f1de09 100644 --- a/sw/source/ui/misc/outline.src +++ b/sw/source/ui/misc/outline.src @@ -362,6 +362,23 @@ TabPage TP_OUTLINE_NUM Last = 99 ; SpinSize = 1 ; }; + FixedText FT_LABEL_TEXT + { + Pos = MAP_APPFONT ( 56 , 149 ) ; + Size = MAP_APPFONT ( 46 , 8 ) ; + Text [ en-US ] = "~Label text" ; + Left = TRUE ; + }; + Edit ED_LABEL_TEXT + { + HelpID = "sw:Edit:TP_OUTLINE_NUM:ED_LABEL_TEXT"; + Border = TRUE ; + Pos = MAP_APPFONT ( 104 , 147 ) ; + Size = MAP_APPFONT ( 66 , 12 ) ; + TabStop = TRUE ; + Group = TRUE ; + Left = TRUE ; + }; FixedLine FL_NUMBER { Pos = MAP_APPFONT ( 44 , 3 ) ; -- 1.7.4.1
From 2c3aa419af6b39b81a3b931663fa5c64e161f0ce Mon Sep 17 00:00:00 2001 From: Mohammad Elahi <elahimoham...@gmail.com> Date: Tue, 30 Aug 2011 02:27:53 +0430 Subject: [PATCH 3/3] Add number formating based on LabelText Numbering is based of LabelText propery of number formating. If the LabelText property is empty the traditional prefix and suffix and ... are used to format the number; but if LabelText is not empty, number formating is based on it. It parses %0 to level 1 number, %1 to level 2 and so on. So a custom format for outline number is possible. --- editeng/source/items/numitem.cxx | 68 +++++++++++++++++++++++-------------- sw/source/core/doc/number.cxx | 12 ++++++- 2 files changed, 53 insertions(+), 27 deletions(-) diff --git a/editeng/source/items/numitem.cxx b/editeng/source/items/numitem.cxx index fcb24e6..788c8b8 100644 --- a/editeng/source/items/numitem.cxx +++ b/editeng/source/items/numitem.cxx @@ -788,41 +788,57 @@ String SvxNumRule::MakeNumString( const SvxNodeNum& rNum, sal_Bool bInclStrings const SvxNumberFormat& rMyNFmt = GetLevel( rNum.GetLevel() ); if( SVX_NUM_NUMBER_NONE != rMyNFmt.GetNumberingType() ) { - sal_uInt8 i = rNum.GetLevel(); - - if( !IsContinuousNumbering() && - 1 < rMyNFmt.GetIncludeUpperLevels() ) // only on own level? + if( rMyNFmt.GetLabelText().Len() == 0 ) { - sal_uInt8 n = rMyNFmt.GetIncludeUpperLevels(); - if( 1 < n ) + sal_uInt8 i = rNum.GetLevel(); + + if( !IsContinuousNumbering() && + 1 < rMyNFmt.GetIncludeUpperLevels() ) // only on own level? { - if( i+1 >= n ) - i -= n - 1; + sal_uInt8 n = rMyNFmt.GetIncludeUpperLevels(); + if( 1 < n ) + { + if( i+1 >= n ) + i -= n - 1; + else + i = 0; + } + } + + for( ; i <= rNum.GetLevel(); ++i ) + { + const SvxNumberFormat& rNFmt = GetLevel( i ); + if( SVX_NUM_NUMBER_NONE == rNFmt.GetNumberingType() ) + { + continue; + } + + sal_Bool bDot = sal_True; + if( rNum.GetLevelVal()[ i ] ) + { + if(SVX_NUM_BITMAP != rNFmt.GetNumberingType()) + aStr += rNFmt.GetNumStr( rNum.GetLevelVal()[ i ], aLocale ); + else + bDot = sal_False; + } else - i = 0; + aStr += sal_Unicode('0'); // all 0-levels are a 0 + if( i != rNum.GetLevel() && bDot) + aStr += sal_Unicode('.'); } } - - for( ; i <= rNum.GetLevel(); ++i ) + else { - const SvxNumberFormat& rNFmt = GetLevel( i ); - if( SVX_NUM_NUMBER_NONE == rNFmt.GetNumberingType() ) + aStr = rMyNFmt.GetLabelText(); + sal_Char pEscape[] = "%0"; + for(int i=0;i<=rNum.GetLevel();i++) { - continue; + pEscape[1]=i+'0'; + aStr.SearchAndReplaceAll(String::CreateFromAscii(pEscape), GetLevel(i).GetNumStr( rNum.GetLevelVal()[ i ], aLocale )); } - sal_Bool bDot = sal_True; - if( rNum.GetLevelVal()[ i ] ) - { - if(SVX_NUM_BITMAP != rNFmt.GetNumberingType()) - aStr += rNFmt.GetNumStr( rNum.GetLevelVal()[ i ], aLocale ); - else - bDot = sal_False; - } - else - aStr += sal_Unicode('0'); // all 0-levels are a 0 - if( i != rNum.GetLevel() && bDot) - aStr += sal_Unicode('.'); + // LabelText is a replacement for prefix and suffix so no bInclStrings + bInclStrings = sal_False; } } diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx index 112ffd5..c5e9359 100644 --- a/sw/source/core/doc/number.cxx +++ b/sw/source/core/doc/number.cxx @@ -689,7 +689,7 @@ String SwNumRule::MakeNumString( const SwNumberTree::tNumberVector & rNumVector, if (nLevel < MAXLEVEL) { const SwNumFmt& rMyNFmt = Get( static_cast<sal_uInt16>(nLevel) ); - + if( rMyNFmt.GetLabelText().Len() == 0 ) { sal_uInt8 i = static_cast<sal_uInt8>(nLevel); @@ -750,6 +750,16 @@ String SwNumRule::MakeNumString( const SwNumberTree::tNumberVector & rNumVector, } } } + else if( SVX_NUM_NUMBER_NONE != rMyNFmt.GetNumberingType() ) + { + aStr = rMyNFmt.GetLabelText(); + sal_Char pEscape[] = "%0"; + for(int i=0;i<=nLevel;i++) + { + pEscape[1]=i+'0'; + aStr.SearchAndReplaceAll(String::CreateFromAscii(pEscape), Get(i).GetNumStr( rNumVector[ i ])); + } + } } return aStr; -- 1.7.4.1
_______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice