diff options
author | Oliver-Rainer Wittmann <orw@apache.org> | 2014-03-18 14:33:39 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-03-19 15:34:18 +0000 |
commit | 04187aaf09969341a7ae9ae7ff5a13925381a96b (patch) | |
tree | eb73ab0eb6c1b14cb8c0c621c32d85c266863b73 | |
parent | 35e190ba5bac01b47fbed1ea568dfb3456029d82 (diff) |
Resolves: #i124371# When changing the numbering or bullet styling...
of a set of paragraph which have more than one different List Style applied
create a new List Style and put the paragraphs into a new list.
(cherry picked from commit 0087ca89e3905009ed947c651f3dc70f3d61ea93)
Conflicts:
sw/inc/doc.hxx
sw/inc/docsh.hxx
sw/inc/editsh.hxx
sw/source/core/doc/docnum.cxx
sw/source/core/docnode/ndcopy.cxx
sw/source/core/edit/autofmt.cxx
sw/source/core/edit/ednumber.cxx
sw/source/core/uibase/app/docst.cxx
sw/source/core/uibase/docvw/edtwin.cxx
sw/source/core/uibase/inc/textsh.hxx
sw/source/core/uibase/shells/listsh.cxx
sw/source/core/uibase/shells/textsh1.cxx
sw/source/core/uibase/shells/txtnum.cxx
sw/source/core/uibase/uiview/formatclipboard.cxx
sw/source/core/uibase/uiview/view2.cxx
sw/source/core/uibase/wrtsh/wrtsh1.cxx
sw/source/core/undo/unnum.cxx
sw/source/core/unocore/unocrsrhelper.cxx
sw/source/filter/ww1/fltshell.cxx
sw/source/ui/misc/num.cxx
Change-Id: Iadb5b386cada296d90d96aa75574024baac7ae3e
-rw-r--r-- | sw/inc/doc.hxx | 27 | ||||
-rw-r--r-- | sw/inc/docsh.hxx | 6 | ||||
-rw-r--r-- | sw/inc/editsh.hxx | 31 | ||||
-rw-r--r-- | sw/source/core/doc/docnum.cxx | 120 | ||||
-rw-r--r-- | sw/source/core/docnode/ndcopy.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/edit/autofmt.cxx | 7 | ||||
-rw-r--r-- | sw/source/core/edit/ednumber.cxx | 96 | ||||
-rw-r--r-- | sw/source/core/uibase/app/docst.cxx | 17 | ||||
-rw-r--r-- | sw/source/core/uibase/docvw/edtwin.cxx | 25 | ||||
-rw-r--r-- | sw/source/core/uibase/inc/textsh.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/uibase/shells/listsh.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/uibase/shells/textsh1.cxx | 106 | ||||
-rw-r--r-- | sw/source/core/uibase/shells/txtattr.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/uibase/shells/txtnum.cxx | 263 | ||||
-rw-r--r-- | sw/source/core/uibase/uiview/view2.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/uibase/wrtsh/wrtsh1.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/undo/unnum.cxx | 11 | ||||
-rw-r--r-- | sw/source/core/unocore/unocrsrhelper.cxx | 13 | ||||
-rw-r--r-- | sw/source/filter/ww1/fltshell.cxx | 7 | ||||
-rw-r--r-- | sw/source/ui/misc/num.cxx | 2 |
20 files changed, 333 insertions, 417 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 034dbd57c962..324e4a1b4948 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1486,13 +1486,14 @@ public: /** Accept changes of outline styles for OUtlineRule. re-use unused 3rd parameter - Add optional parameter <bResetIndentAttrs> - default value sal_False. - If <bResetIndentAttrs> equals true, the indent attributes "before text" - and "first line indent" are additionally reset at the provided PaM, if - the list style makes use of the new list level attributes. - introduce parameters <bCreateNewList> and <sContinuedListId> - <bCreateNewList> indicates, if a new list is created by applying the - given list style. */ + Optional parameter <bResetIndentAttrs> - default value false: + If <bResetIndentAttrs> equals true, the indent attributes "before text" + and "first line indent" are additionally reset at the provided PaM, if + the list style makes use of the new list level attributes. + Parameters <bCreateNewList> and <sContinuedListId>: + <bCreateNewList> indicates, if a new list is created by applying the given list style. + If <bCreateNewList> equals false, <sContinuedListId> may contain the + list Id of a list, which has to be continued by applying the given list style */ void SetNumRule( const SwPaM&, const SwNumRule&, const bool bCreateNewList, @@ -1506,7 +1507,7 @@ public: void SetNumRuleStart( const SwPosition& rPos, sal_Bool bFlag = sal_True ); void SetNodeNumStart( const SwPosition& rPos, sal_uInt16 nStt ); - SwNumRule* GetCurrNumRule( const SwPosition& rPos ) const; + SwNumRule* GetNumRuleAtPos( const SwPosition& rPos ) const; const SwNumRuleTbl& GetNumRuleTbl() const { return *mpNumRuleTbl; } @@ -2023,7 +2024,7 @@ public: */ OUString GetPaMDescr(const SwPaM & rPaM) const; - bool IsFirstOfNumRule(SwPosition & rPos); + bool IsFirstOfNumRuleAtPos( const SwPosition & rPos ); // access methods for XForms model(s) @@ -2046,19 +2047,19 @@ public: void SetDefaultPageMode(bool bSquaredPageMode); sal_Bool IsSquaredPageMode() const; - void Setn32DummyCompatabilityOptions1( sal_uInt32 CompatabilityOptions1 ) + void Setn32DummyCompatabilityOptions1( const sal_uInt32 CompatabilityOptions1 ) { mn32DummyCompatabilityOptions1 = CompatabilityOptions1; } - sal_uInt32 Getn32DummyCompatabilityOptions1( ) + sal_uInt32 Getn32DummyCompatabilityOptions1() { return mn32DummyCompatabilityOptions1; } - void Setn32DummyCompatabilityOptions2( sal_uInt32 CompatabilityOptions2 ) + void Setn32DummyCompatabilityOptions2( const sal_uInt32 CompatabilityOptions2 ) { mn32DummyCompatabilityOptions2 = CompatabilityOptions2; } - sal_uInt32 Getn32DummyCompatabilityOptions2( ) + sal_uInt32 Getn32DummyCompatabilityOptions2() { return mn32DummyCompatabilityOptions2; } diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx index 5f3271c8ffcd..2da71e665cce 100644 --- a/sw/inc/docsh.hxx +++ b/sw/inc/docsh.hxx @@ -119,8 +119,10 @@ class SW_DLLPUBLIC SwDocShell: public SfxObjectShell, public SfxListener SAL_DLLPRIVATE sal_uInt16 Delete(const OUString &rName, sal_uInt16 nFamily); SAL_DLLPRIVATE sal_uInt16 Hide(const OUString &rName, sal_uInt16 nFamily, bool bHidden); - SAL_DLLPRIVATE sal_uInt16 ApplyStyles(const OUString &rName, sal_uInt16 nFamily, SwWrtShell* pShell = 0, - sal_uInt16 nMode = 0 ); + SAL_DLLPRIVATE sal_uInt16 ApplyStyles(const OUString &rName, + const sal_uInt16 nFamily, + SwWrtShell* pShell = 0, + sal_uInt16 nMode = 0); SAL_DLLPRIVATE sal_uInt16 DoWaterCan( const OUString &rName, sal_uInt16 nFamily); SAL_DLLPRIVATE sal_uInt16 UpdateStyle(const OUString &rName, sal_uInt16 nFamily, SwWrtShell* pShell = 0); SAL_DLLPRIVATE sal_uInt16 MakeByExample(const OUString &rName, diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx index f2d11c4eb23d..c03d5bf2444a 100644 --- a/sw/inc/editsh.hxx +++ b/sw/inc/editsh.hxx @@ -456,20 +456,20 @@ public: sal_Bool IsProtectedOutlinePara() const; - /// @return numbering rulse pf current enumeration list (else FALSE). - const SwNumRule* GetCurNumRule() const; - - /** If there is not already a numbering, set one, else change. - Works with old and new rules. Update only differences. - Add optional parameter @param <bResetIndentAttrs> (default value sal_False). - If @param <bResetIndentAttrs> equals true, the indent attributes "before text" - and "first line indent" are additionally reset at the current selection, - if the list style makes use of the new list level attributes. - introduce parameters @param <bCreateNewList> and @param <sContinuedListId> - @param <bCreateNewList> indicates, if a new list is created by applying the - given list style. - If @param <bCreateNewList> equals sal_False, @param <sContinuedListId> may contain the - list Id of a list, which has to be continued by applying the given list style. */ + const SwNumRule* GetNumRuleAtCurrCrsrPos() const; + + /** Returns the numbering rule found at the paragraphs of the current selection, + if all paragraphs of the current selection have the same or none numbering rule applied. */ + const SwNumRule* GetNumRuleAtCurrentSelection() const; + + /** Optional parameter <bResetIndentAttrs> (default value sal_False). + If <bResetIndentAttrs> equals true, the indent attributes "before text" + and "first line indent" are additionally reset at the current selection, + if the list style makes use of the new list level attributes. + Parameters <bCreateNewList> and <sContinuedListId> + <bCreateNewList> indicates, if a new list is created by applying the given list style. + If <bCreateNewList> equals false, <sContinuedListId> may contain the + list Id of a list, which has to be continued by applying the given list style */ void SetCurNumRule( const SwNumRule&, const bool bCreateNewList /*= false*/, const OUString& sContinuedListId = OUString(), @@ -496,8 +496,7 @@ public: void ChangeIndentOfAllListLevels( short nDiff ); // Adjust method name void SetIndent(short nIndent, const SwPosition & rPos); - bool IsFirstOfNumRule() const; - bool IsFirstOfNumRule(const SwPaM & rPaM) const; + bool IsFirstOfNumRuleAtCrsrPos() const; sal_Bool IsNoNum( sal_Bool bChkStart = sal_True ) const; diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index f66b8e6832c3..8a0f74141cbc 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -759,21 +759,23 @@ static void lcl_ChgNumRule( SwDoc& rDoc, const SwNumRule& rRule ) SwNumRule* pOld = rDoc.FindNumRulePtr( rRule.GetName() ); OSL_ENSURE( pOld, "we cannot proceed without the old NumRule" ); - sal_uInt16 nChgFmtLevel = 0, nMask = 1; - sal_uInt8 n; + sal_uInt16 nChgFmtLevel = 0; + sal_uInt16 nMask = 1; - for( n = 0; n < MAXLEVEL; ++n, nMask <<= 1 ) + for ( sal_uInt8 n = 0; n < MAXLEVEL; ++n, nMask <<= 1 ) { - const SwNumFmt& rOldFmt = pOld->Get( n ), - & rNewFmt = rRule.Get( n ); + const SwNumFmt& rOldFmt = pOld->Get( n ), &rNewFmt = rRule.Get( n ); - if( rOldFmt != rNewFmt ) + if ( rOldFmt != rNewFmt ) { nChgFmtLevel |= nMask; } - else if( SVX_NUM_NUMBER_NONE > rNewFmt.GetNumberingType() && 1 < rNewFmt.GetIncludeUpperLevels() && - 0 != (nChgFmtLevel & GetUpperLvlChg( n, rNewFmt.GetIncludeUpperLevels(),nMask )) ) + else if ( SVX_NUM_NUMBER_NONE > rNewFmt.GetNumberingType() + && 1 < rNewFmt.GetIncludeUpperLevels() + && 0 != ( nChgFmtLevel & GetUpperLvlChg( n, rNewFmt.GetIncludeUpperLevels(), nMask ) ) ) + { nChgFmtLevel |= nMask; + } } if( !nChgFmtLevel ) // Nothing has been changed? @@ -808,12 +810,12 @@ static void lcl_ChgNumRule( SwDoc& rDoc, const SwNumRule& rRule ) } } - for( n = 0; n < MAXLEVEL; ++n ) - if( nChgFmtLevel & ( 1 << n )) - pOld->Set( n, rRule.GetNumFmt( n )); + for ( sal_uInt8 n = 0; n < MAXLEVEL; ++n ) + if ( nChgFmtLevel & ( 1 << n ) ) + pOld->Set( n, rRule.GetNumFmt( n ) ); pOld->CheckCharFmts( &rDoc ); - pOld->SetInvalidRule(sal_True); + pOld->SetInvalidRule( sal_True ); pOld->SetContinusNum( rRule.IsContinusNum() ); rDoc.UpdateNumRule(); @@ -835,68 +837,67 @@ void SwDoc::SetNumRule( const SwPaM& rPam, GetIDocumentUndoRedo().AppendUndo(pUndo); } - SwNumRule * pNew = FindNumRulePtr( rRule.GetName() ); - bool bUpdateRule = false; - - if( !pNew ) + SwNumRule* pNewOrChangedNumRule = FindNumRulePtr( rRule.GetName() ); + bool bNewNumRuleCreated = false; + if ( pNewOrChangedNumRule == NULL ) { - pNew = (*mpNumRuleTbl)[ MakeNumRule( rRule.GetName(), &rRule ) ]; + // create new numbering rule based on given one + pNewOrChangedNumRule = ( *mpNumRuleTbl )[MakeNumRule( rRule.GetName(), &rRule )]; + bNewNumRuleCreated = true; } - else if (rRule != *pNew) - { - bUpdateRule = true; - } - - if (bUpdateRule) + else if ( rRule != *pNewOrChangedNumRule ) { - if( pUndo ) + // change existing numbering rule + if( pUndo != NULL ) { - pUndo->SaveOldNumRule( *pNew ); - ::lcl_ChgNumRule( *this, rRule ); - pUndo->SetLRSpaceEndPos(); + pUndo->SaveOldNumRule( *pNewOrChangedNumRule ); } - else + ::lcl_ChgNumRule( *this, rRule ); + if( pUndo != NULL ) { - ::lcl_ChgNumRule( *this, rRule ); + pUndo->SetLRSpaceEndPos(); } } if ( bSetItem ) { + OUString sListId; if ( bCreateNewList ) { - OUString sListId; - if ( !bUpdateRule ) + if ( bNewNumRuleCreated ) { // apply list id of list, which has been created for the new list style - sListId = pNew->GetDefaultListId(); + sListId = pNewOrChangedNumRule->GetDefaultListId(); } else { // create new list and apply its list id - SwList* pNewList = createList( OUString(), pNew->GetName() ); + const SwList* pNewList = createList( OUString(), pNewOrChangedNumRule->GetName() ); OSL_ENSURE( pNewList, "<SwDoc::SetNumRule(..)> - could not create new list. Serious defect -> please inform OD." ); sListId = pNewList->GetListId(); } - InsertPoolItem( rPam, SfxStringItem( RES_PARATR_LIST_ID, sListId ), 0 ); } else if ( !sContinuedListId.isEmpty() ) { // apply given list id - InsertPoolItem( rPam, SfxStringItem( RES_PARATR_LIST_ID, sContinuedListId ), 0 ); + sListId = sContinuedListId; + } + if (!sListId.isEmpty()) + { + InsertPoolItem( rPam, SfxStringItem( RES_PARATR_LIST_ID, sListId ), 0 ); } } - if ( ! rPam.HasMark()) + if ( !rPam.HasMark() ) { SwTxtNode * pTxtNd = rPam.GetPoint()->nNode.GetNode().GetTxtNode(); - // consider case that the PaM doesn't denote a text node - e.g. it denotes a graphic node - if ( pTxtNd ) + // robust code: consider case that the PaM doesn't denote a text node - e.g. it denotes a graphic node + if ( pTxtNd != NULL ) { SwNumRule * pRule = pTxtNd->GetNumRule(); - if (pRule && pRule->GetName() == pNew->GetName()) + if (pRule && pRule->GetName() == pNewOrChangedNumRule->GetName()) { bSetItem = false; if ( !pTxtNd->IsInList() ) @@ -912,7 +913,7 @@ void SwDoc::SetNumRule( const SwPaM& rPam, if ( pColl ) { SwNumRule* pCollRule = FindNumRulePtr(pColl->GetNumRule().GetValue()); - if ( pCollRule && pCollRule->GetName() == pNew->GetName() ) + if ( pCollRule && pCollRule->GetName() == pNewOrChangedNumRule->GetName() ) { pTxtNd->ResetAttr( RES_PARATR_NUMRULE ); bSetItem = false; @@ -924,11 +925,11 @@ void SwDoc::SetNumRule( const SwPaM& rPam, if ( bSetItem ) { - InsertPoolItem( rPam, SwNumRuleItem( pNew->GetName() ), 0 ); + InsertPoolItem( rPam, SwNumRuleItem( pNewOrChangedNumRule->GetName() ), 0 ); } - if ( bResetIndentAttrs && - pNew && pNew->Get( 0 ).GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ) + if ( bResetIndentAttrs + && pNewOrChangedNumRule->Get( 0 ).GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ) { ::lcl_ResetIndentAttrs(this, rPam, RES_LR_SPACE); } @@ -941,6 +942,7 @@ void SwDoc::SetNumRule( const SwPaM& rPam, SetModified(); } + void SwDoc::SetCounted(const SwPaM & rPam, bool bCounted) { if ( bCounted ) @@ -1156,7 +1158,6 @@ bool SwDoc::ReplaceNumRule( const SwPosition& rPos, pOldRule->GetTxtNodeList( aTxtNodeList ); if ( aTxtNodeList.size() > 0 ) { - SwRegHistory aRegH( pUndo ? pUndo->GetHistory() : 0 ); sal_uInt16 nChgFmtLevel = 0; for( sal_uInt8 n = 0; n < MAXLEVEL; ++n ) @@ -1171,7 +1172,6 @@ bool SwDoc::ReplaceNumRule( const SwPosition& rPos, const SwTxtNode* pGivenTxtNode = rPos.nNode.GetNode().GetTxtNode(); SwNumRuleItem aRule( rNewRule ); - for ( SwNumRule::tTxtNodeList::iterator aIter = aTxtNodeList.begin(); aIter != aTxtNodeList.end(); ++aIter ) { @@ -1218,11 +1218,10 @@ void SwDoc::MakeUniqueNumRules(const SwPaM & rPaM) ::std::map<SwNumRule *, ListStyleData> aMyNumRuleMap; - sal_uLong nStt = rPaM.Start()->nNode.GetIndex(); - sal_uLong nEnd = rPaM.End()->nNode.GetIndex(); - bool bFirst = true; + const sal_uLong nStt = rPaM.Start()->nNode.GetIndex(); + const sal_uLong nEnd = rPaM.End()->nNode.GetIndex(); for (sal_uLong n = nStt; n <= nEnd; n++) { SwTxtNode * pCNd = GetNodes()[n]->GetTxtNode(); @@ -1250,10 +1249,7 @@ void SwDoc::MakeUniqueNumRules(const SwPaM & rPaM) if ( aListStyleData.pReplaceNumRule == 0 ) { aListStyleData.pReplaceNumRule = new SwNumRule(*pRule); - - aListStyleData.pReplaceNumRule->SetName( - GetUniqueNumRuleName(), *this ); - + aListStyleData.pReplaceNumRule->SetName( GetUniqueNumRuleName(), *this ); aListStyleData.bCreateNewList = true; } @@ -1262,7 +1258,8 @@ void SwDoc::MakeUniqueNumRules(const SwPaM & rPaM) SwPaM aPam(*pCNd); - SetNumRule( aPam, *aListStyleData.pReplaceNumRule, + SetNumRule( aPam, + *aListStyleData.pReplaceNumRule, aListStyleData.bCreateNewList, aListStyleData.sListId ); if ( aListStyleData.bCreateNewList ) @@ -2097,12 +2094,12 @@ bool SwDoc::NumOrNoNum( const SwNodeIndex& rIdx, sal_Bool bDel ) return bResult; } -SwNumRule* SwDoc::GetCurrNumRule( const SwPosition& rPos ) const +SwNumRule* SwDoc::GetNumRuleAtPos( const SwPosition& rPos ) const { - SwNumRule* pRet = 0; + SwNumRule* pRet = NULL; SwTxtNode* pTNd = rPos.nNode.GetNode().GetTxtNode(); - if( pTNd ) + if ( pTNd != NULL ) { pRet = pTNd->GetNumRule(); } @@ -2312,17 +2309,14 @@ void SwDoc::MarkListLevel( SwList& rList, rList.MarkListLevel( nListLevel, bValue ); } -bool SwDoc::IsFirstOfNumRule(SwPosition & rPos) +bool SwDoc::IsFirstOfNumRuleAtPos( const SwPosition & rPos ) { bool bResult = false; - SwTxtNode * pTxtNode = rPos.nNode.GetNode().GetTxtNode(); - if (pTxtNode) + const SwTxtNode* pTxtNode = rPos.nNode.GetNode().GetTxtNode(); + if ( pTxtNode != NULL ) { - SwNumRule * pNumRule = pTxtNode->GetNumRule(); - - if (pNumRule) - bResult = pTxtNode->IsFirstOfNumRule(); + bResult = pTxtNode->IsFirstOfNumRule(); } return bResult; diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx index 4ec8d2ce63a0..01dc51279c33 100644 --- a/sw/source/core/docnode/ndcopy.cxx +++ b/sw/source/core/docnode/ndcopy.cxx @@ -1304,7 +1304,7 @@ bool SwDoc::CopyImpl( SwPaM& rPam, SwPosition& rPos, *pCpyRange->GetMark() = *pCopyPam->GetMark(); } - if ( pNumRuleToPropagate ) + if ( pNumRuleToPropagate != NULL ) { // #i86492# - use <SwDoc::SetNumRule(..)>, because it also handles the <ListId> pDoc->SetNumRule( *pCopyPam, *pNumRuleToPropagate, false, diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx index 0cc8f857904b..f6890c637e04 100644 --- a/sw/source/core/edit/autofmt.cxx +++ b/sw/source/core/edit/autofmt.cxx @@ -1561,7 +1561,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel ) bChgEnum = false; } - if( bChgEnum || bChgBullet ) + if ( bChgEnum || bChgBullet ) { m_aDelPam.DeleteMark(); m_aDelPam.GetPoint()->nNode = m_aNdIdx; @@ -1589,7 +1589,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel ) bChgEnum ? nTxtStt : 0 ); m_aDelPam.SetMark(); - if( bChgBullet ) + if ( bChgBullet ) nTxtStt += 2; while( nTxtStt < rStr.getLength() && IsSpace( rStr[ nTxtStt ] )) @@ -1623,7 +1623,8 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel ) nAutoCorrPos = 2; aSet.ClearItem(); } - SvxTabStopItem aTStops( RES_PARATR_TABSTOP ); aTStops.Insert( SvxTabStop( 0 )); + SvxTabStopItem aTStops( RES_PARATR_TABSTOP ); + aTStops.Insert( SvxTabStop( 0 ) ); aSet.Put( aTStops ); m_pDoc->SetFmtItemByAutoFmt( m_aDelPam, aSet ); } diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx index a534e616165e..409ac7c22b24 100644 --- a/sw/source/core/edit/ednumber.cxx +++ b/sw/source/core/edit/ednumber.cxx @@ -331,35 +331,18 @@ bool SwEditShell::NumUpDown( bool bDown ) return bRet; } -// -> #i23726# -bool SwEditShell::IsFirstOfNumRule() const +bool SwEditShell::IsFirstOfNumRuleAtCrsrPos() const { - bool bResult = false; - - SwPaM * pCrsr = GetCrsr(); - if (pCrsr->GetNext() == pCrsr) - { - bResult = IsFirstOfNumRule(*pCrsr); - } - - return bResult; + return GetDoc()->IsFirstOfNumRuleAtPos( *GetCrsr()->GetPoint() ); } -bool SwEditShell::IsFirstOfNumRule(const SwPaM & rPaM) const -{ - SwPosition aPos(*rPaM.GetPoint()); - return (GetDoc()->IsFirstOfNumRule(aPos)); -} -// <- #i23726# - // -> #i23725#, #i90078# -void SwEditShell::ChangeIndentOfAllListLevels( short nDiff ) +void SwEditShell::ChangeIndentOfAllListLevels( const short nDiff ) { StartAllAction(); - const SwNumRule *pCurNumRule = GetCurNumRule(); - //#120911# check if numbering rule really exists - if (pCurNumRule) + const SwNumRule *pCurNumRule = GetNumRuleAtCurrCrsrPos(); + if ( pCurNumRule != NULL ) { SwNumRule aRule(*pCurNumRule); const SwNumFmt& aRootNumFmt(aRule.Get(0)); @@ -380,34 +363,32 @@ void SwEditShell::SetIndent(short nIndent, const SwPosition & rPos) { StartAllAction(); - SwNumRule *pCurNumRule = GetDoc()->GetCurrNumRule(rPos); + SwNumRule *pCurNumRule = GetDoc()->GetNumRuleAtPos(rPos); if (pCurNumRule) { - SwPaM aPaM(rPos); - SwTxtNode * pTxtNode = aPaM.GetNode()->GetTxtNode(); - SwNumRule aRule(*pCurNumRule); - - if ( IsFirstOfNumRule() ) + if ( !IsMultiSelection() && IsFirstOfNumRuleAtCrsrPos() ) { aRule.SetIndentOfFirstListLevelAndChangeOthers( nIndent ); } - else if ( pTxtNode->GetActualListLevel() >= 0 ) + else { - aRule.SetIndent( nIndent, - static_cast<sal_uInt16>(pTxtNode->GetActualListLevel()) ); + const SwTxtNode* pTxtNode = rPos.nNode.GetNode().GetTxtNode(); + if ( pTxtNode != NULL + && pTxtNode->GetActualListLevel() >= 0 ) + { + aRule.SetIndent( nIndent, static_cast< sal_uInt16 >( pTxtNode->GetActualListLevel() ) ); + } } - // #i42921# - 3rd parameter = false in order to - // suppress setting of num rule at <aPaM>. - // do not apply any list + // change numbering rule - changed numbering rule is not applied at <aPaM> + SwPaM aPaM(rPos); GetDoc()->SetNumRule( aPaM, aRule, false, OUString(), false ); } EndAllAction(); } -// <- #i23725# bool SwEditShell::MoveParagraph( long nOffset ) { @@ -708,9 +689,48 @@ sal_uInt8 SwEditShell::GetNumLevel() const return nLevel; } -const SwNumRule* SwEditShell::GetCurNumRule() const +const SwNumRule* SwEditShell::GetNumRuleAtCurrCrsrPos() const { - return GetDoc()->GetCurrNumRule( *GetCrsr()->GetPoint() ); + return GetDoc()->GetNumRuleAtPos( *GetCrsr()->GetPoint() ); +} + +const SwNumRule* SwEditShell::GetNumRuleAtCurrentSelection() const +{ + const SwNumRule* pNumRuleAtCurrentSelection = NULL; + + const SwPaM* pCurrentCrsr = GetCrsr(); + bool bDifferentNumRuleFound = false; + const SwPaM* pCrsr = pCurrentCrsr; + do + { + const SwNodeIndex aEndNode = pCrsr->End()->nNode; + + for ( SwNodeIndex aNode = pCrsr->Start()->nNode; aNode <= aEndNode; aNode++ ) + { + const SwNumRule* pNumRule = GetDoc()->GetNumRuleAtPos( SwPosition( aNode ) ); + if ( pNumRule == NULL ) + { + continue; + } + else if ( pNumRule != pNumRuleAtCurrentSelection ) + { + if ( pNumRuleAtCurrentSelection == NULL ) + { + pNumRuleAtCurrentSelection = pNumRule; + } + else + { + pNumRuleAtCurrentSelection = NULL; + bDifferentNumRuleFound = true; + break; + } + } + } + + pCrsr = static_cast< const SwPaM* >(pCrsr->GetNext()); + } while ( !bDifferentNumRuleFound && pCrsr != pCurrentCrsr ); + + return pNumRuleAtCurrentSelection; } void SwEditShell::SetCurNumRule( const SwNumRule& rRule, @@ -732,7 +752,7 @@ void SwEditShell::SetCurNumRule( const SwNumRule& rRule, aRangeArr.SetPam( n, aPam ); GetDoc()->SetNumRule( aPam, rRule, bCreateNewList, sContinuedListId, - true , bResetIndentAttrs ); + true, bResetIndentAttrs ); GetDoc()->SetCounted( aPam, true ); } } diff --git a/sw/source/core/uibase/app/docst.cxx b/sw/source/core/uibase/app/docst.cxx index c2efe1ec4c35..5fe8d1a6641e 100644 --- a/sw/source/core/uibase/app/docst.cxx +++ b/sw/source/core/uibase/app/docst.cxx @@ -207,7 +207,7 @@ void SwDocShell::StateStyleSheet(SfxItemSet& rSet, SwWrtShell* pSh) break; case SID_STYLE_FAMILY5: { - const SwNumRule* pRule = pShell->GetCurNumRule(); + const SwNumRule* pRule = pShell->GetNumRuleAtCurrCrsrPos(); if( pRule ) aName = pRule->GetName(); @@ -227,7 +227,7 @@ void SwDocShell::StateStyleSheet(SfxItemSet& rSet, SwWrtShell* pSh) ? SFX_STYLE_FAMILY_FRAME != nActualFamily : ( SFX_STYLE_FAMILY_FRAME == nActualFamily || SFX_STYLE_FAMILY_PAGE == nActualFamily || - (SFX_STYLE_FAMILY_PSEUDO == nActualFamily && !pShell->GetCurNumRule())) ) + (SFX_STYLE_FAMILY_PSEUDO == nActualFamily && !pShell->GetNumRuleAtCurrCrsrPos())) ) { rSet.DisableItem( nWhich ); } @@ -237,7 +237,7 @@ void SwDocShell::StateStyleSheet(SfxItemSet& rSet, SwWrtShell* pSh) if( (pShell->IsFrmSelected() ? SFX_STYLE_FAMILY_FRAME != nActualFamily : SFX_STYLE_FAMILY_FRAME == nActualFamily) || - (SFX_STYLE_FAMILY_PSEUDO == nActualFamily && !pShell->GetCurNumRule()) ) + (SFX_STYLE_FAMILY_PSEUDO == nActualFamily && !pShell->GetNumRuleAtCurrCrsrPos()) ) { rSet.DisableItem( nWhich ); } @@ -840,10 +840,9 @@ sal_uInt16 SwDocShell::Hide(const OUString &rName, sal_uInt16 nFamily, bool bHid // apply template sal_uInt16 SwDocShell::ApplyStyles(const OUString &rName, sal_uInt16 nFamily, - SwWrtShell* pShell, sal_uInt16 nMode ) + SwWrtShell* pShell, const sal_uInt16 nMode ) { - SwDocStyleSheet* pStyle = - (SwDocStyleSheet*)mxBasePool->Find(rName, (SfxStyleFamily)nFamily); + SwDocStyleSheet* pStyle = (SwDocStyleSheet*) mxBasePool->Find( rName, (SfxStyleFamily) nFamily ); SAL_WARN_IF( !pStyle, "sw.ui", "Style not found" ); @@ -856,7 +855,7 @@ sal_uInt16 SwDocShell::ApplyStyles(const OUString &rName, sal_uInt16 nFamily, pSh->StartAllAction(); - switch(nFamily) + switch (nFamily) { case SFX_STYLE_FAMILY_CHAR: { @@ -1026,7 +1025,7 @@ sal_uInt16 SwDocShell::UpdateStyle(const OUString &rName, sal_uInt16 nFamily, Sw { const SwNumRule* pCurRule; if( pStyle->GetNumRule() && - 0 != ( pCurRule = pCurrWrtShell->GetCurNumRule() )) + 0 != ( pCurRule = pCurrWrtShell->GetNumRuleAtCurrCrsrPos() )) { SwNumRule aRule( *pCurRule ); // #i91400# @@ -1164,7 +1163,7 @@ sal_uInt16 SwDocShell::MakeByExample( const OUString &rName, sal_uInt16 nFamily, case SFX_STYLE_FAMILY_PSEUDO: { - const SwNumRule* pCurRule = pCurrWrtShell->GetCurNumRule(); + const SwNumRule* pCurRule = pCurrWrtShell->GetNumRuleAtCurrCrsrPos(); if (pCurRule) { diff --git a/sw/source/core/uibase/docvw/edtwin.cxx b/sw/source/core/uibase/docvw/edtwin.cxx index 40d61e86aa36..e1947e35e823 100644 --- a/sw/source/core/uibase/docvw/edtwin.cxx +++ b/sw/source/core/uibase/docvw/edtwin.cxx @@ -1860,8 +1860,8 @@ KEYINPUT_CHECKTABLE_INSDEL: //RETURN and empty paragraph in numbering -> end numbering else if( m_aInBuffer.isEmpty() && - rSh.GetCurNumRule() && - !rSh.GetCurNumRule()->IsOutlineRule() && + rSh.GetNumRuleAtCurrCrsrPos() && + !rSh.GetNumRuleAtCurrCrsrPos()->IsOutlineRule() && !rSh.HasSelection() && rSh.IsSttPara() && rSh.IsEndPara() ) eKeyState = KS_NumOff, eNextKeyState = KS_OutlineLvOff; @@ -1882,7 +1882,7 @@ KEYINPUT_CHECKTABLE_INSDEL: { if ( !rSh.HasReadonlySel() && !rSh.IsSttPara() - && rSh.GetCurNumRule() + && rSh.GetNumRuleAtCurrCrsrPos() && !rSh.CrsrInsideInputFld() ) { eKeyState = KS_NoNum; @@ -1907,7 +1907,7 @@ KEYINPUT_CHECKTABLE_INSDEL: const bool bOnlyBackspaceKey( KEY_BACKSPACE == rKeyCode.GetFullCode() ); if ( rSh.IsSttPara() && !rSh.HasSelection() - && ( rSh.GetCurNumRule() == NULL + && ( rSh.GetNumRuleAtCurrCrsrPos() == NULL || ( rSh.IsNoNum() && bOnlyBackspaceKey ) ) ) { bDone = rSh.TryRemoveIndent(); @@ -1961,7 +1961,7 @@ KEYINPUT_CHECKTABLE_INSDEL: && rSh.IsEndPara() && !rSh.HasSelection() ) { - const SwNumRule* pCurrNumRule( rSh.GetCurNumRule() ); + const SwNumRule* pCurrNumRule( rSh.GetNumRuleAtCurrCrsrPos() ); if ( pCurrNumRule != NULL && pCurrNumRule != rSh.GetOutlineNumRule() ) { @@ -2004,12 +2004,13 @@ KEYINPUT_CHECKTABLE_INSDEL: GetView().GetViewFrame()->GetDispatcher()->Execute( FN_GOTO_NEXT_INPUTFLD ); eKeyState = KS_End; } - else if( rSh.GetCurNumRule() + else if( rSh.GetNumRuleAtCurrCrsrPos() && rSh.IsSttOfPara() && !rSh.HasReadonlySel() ) { - if ( rSh.IsFirstOfNumRule() && - numfunc::ChangeIndentOnTabAtFirstPosOfFirstListItem() ) + if ( !rSh.IsMultiSelection() + && rSh.IsFirstOfNumRuleAtCrsrPos() + && numfunc::ChangeIndentOnTabAtFirstPosOfFirstListItem() ) eKeyState = KS_NumIndentInc; else eKeyState = KS_NumDown; @@ -2055,13 +2056,13 @@ KEYINPUT_CHECKTABLE_INSDEL: GetView().GetViewFrame()->GetDispatcher()->Execute( FN_GOTO_PREV_INPUTFLD ); eKeyState = KS_End; } - else if( rSh.GetCurNumRule() + else if( rSh.GetNumRuleAtCurrCrsrPos() && rSh.IsSttOfPara() && !rSh.HasReadonlySel() ) { - - if ( rSh.IsFirstOfNumRule() && - numfunc::ChangeIndentOnTabAtFirstPosOfFirstListItem() ) + if ( !rSh.IsMultiSelection() + && rSh.IsFirstOfNumRuleAtCrsrPos() + && numfunc::ChangeIndentOnTabAtFirstPosOfFirstListItem() ) eKeyState = KS_NumIndentDec; else eKeyState = KS_NumUp; diff --git a/sw/source/core/uibase/inc/textsh.hxx b/sw/source/core/uibase/inc/textsh.hxx index e9e00baeb535..98ea806d133e 100644 --- a/sw/source/core/uibase/inc/textsh.hxx +++ b/sw/source/core/uibase/inc/textsh.hxx @@ -33,10 +33,11 @@ class SwTextShell: public SwBaseShell RotateTransliteration m_aRotateCase; void InsertSymbol( SfxRequest& ); - void InsertHyperlink(const SvxHyperlinkItem& rHlnkItem); + void InsertHyperlink( const SvxHyperlinkItem& rHlnkItem ); bool InsertMediaDlg( SfxRequest& ); public: + SFX_DECL_INTERFACE(SW_TEXTSHELL) TYPEINFO(); diff --git a/sw/source/core/uibase/shells/listsh.cxx b/sw/source/core/uibase/shells/listsh.cxx index ae32351c3db8..22379a68dcd9 100644 --- a/sw/source/core/uibase/shells/listsh.cxx +++ b/sw/source/core/uibase/shells/listsh.cxx @@ -136,7 +136,7 @@ void SwListShell::Execute(SfxRequest &rReq) SwWrtShell& rSh = GetShell(); // #i35572# - const SwNumRule* pCurRule = rSh.GetCurNumRule(); + const SwNumRule* pCurRule = rSh.GetNumRuleAtCurrCrsrPos(); OSL_ENSURE( pCurRule, "SwListShell::Execute without NumRule" ); bool bOutline = pCurRule && pCurRule->IsOutlineRule(); diff --git a/sw/source/core/uibase/shells/textsh1.cxx b/sw/source/core/uibase/shells/textsh1.cxx index 7cc793bed17d..581c239a1f76 100644 --- a/sw/source/core/uibase/shells/textsh1.cxx +++ b/sw/source/core/uibase/shells/textsh1.cxx @@ -940,7 +940,7 @@ void SwTextShell::Execute(SfxRequest &rReq) ::SwToSfxPageDescAttr( aCoreSet ); // Properties of numbering - if( rWrtSh.GetDoc()->GetCurrNumRule( *pPaM->GetPoint() ) ) + if (rWrtSh.GetNumRuleAtCurrCrsrPos()) { SfxBoolItem aStart( FN_NUMBER_NEWSTART, rWrtSh.IsNumRuleStart( pPaM ) ); aCoreSet.Put(aStart); @@ -1089,49 +1089,49 @@ void SwTextShell::Execute(SfxRequest &rReq) } } break; + case FN_SELECT_PARA: { - if(!rWrtSh.IsSttOfPara()) - rWrtSh.SttPara(sal_False); + if ( !rWrtSh.IsSttOfPara() ) + rWrtSh.SttPara( sal_False ); else rWrtSh.EnterStdMode(); - rWrtSh.EndPara(sal_True); + rWrtSh.EndPara( sal_True ); } break; case SID_DEC_INDENT: case SID_INC_INDENT: - //According to the requirement, modified the behavior when user - //using the indent button on the toolbar. Now if we increase/decrease indent for a - //paragraph which has bullet style it will increase/decrease the bullet level. + //According to the requirement, modified the behavior when user + //using the indent button on the toolbar. Now if we increase/decrease indent for a + //paragraph which has bullet style it will increase/decrease the bullet level. + { + //If the current paragraph has bullet call the function to + //increase or decrease the bullet level. + //Why could I know wheter a paragraph has bullet or not by checking the below conditions? + //Please refer to the "case KEY_TAB:" section in SwEditWin::KeyInput(..) : + // if( rSh.GetCurNumRule() && rSh.IsSttOfPara() && + // !rSh.HasReadonlySel() ) + // eKeyState = KS_NumDown; + //Above code demonstrates that when the cursor is at the start of a paragraph which has bullet, + //press TAB will increase the bullet level. + //So I copied from that ^^ + if ( rWrtSh.GetNumRuleAtCurrCrsrPos() && !rWrtSh.HasReadonlySel() ) { - //If the current paragraph has bullet call the function to - //increase or decrease the bullet level. - //Why could I know wheter a paragraph has bullet or not by checking the below conditions? - //Please refer to the "case KEY_TAB:" section in SwEditWin::KeyInput(..) : - // if( rSh.GetCurNumRule() && rSh.IsSttOfPara() && - // !rSh.HasReadonlySel() ) - // eKeyState = KS_NumDown; - //Above code demonstrates that when the cursor is at the start of a paragraph which has bullet, - //press TAB will increase the bullet level. - //So I copied from that ^^ - if ( rWrtSh.GetCurNumRule() && !rWrtSh.HasReadonlySel() ) - { - rWrtSh.NumUpDown( SID_INC_INDENT == nSlot ); - } - else//execute the original processing functions - { - //below is copied of the old codes - rWrtSh.MoveLeftMargin( SID_INC_INDENT == nSlot, - rReq.GetModifier() != KEY_MOD1 ); - } + rWrtSh.NumUpDown( SID_INC_INDENT == nSlot ); } - rReq.Done(); - break; + else //execute the original processing functions + { + //below is copied of the old codes + rWrtSh.MoveLeftMargin( SID_INC_INDENT == nSlot, rReq.GetModifier() != KEY_MOD1 ); + } + } + rReq.Done(); + break; + case FN_DEC_INDENT_OFFSET: case FN_INC_INDENT_OFFSET: - rWrtSh.MoveLeftMargin( FN_INC_INDENT_OFFSET == nSlot, - rReq.GetModifier() == KEY_MOD1 ); + rWrtSh.MoveLeftMargin( FN_INC_INDENT_OFFSET == nSlot, rReq.GetModifier() == KEY_MOD1 ); rReq.Done(); break; @@ -1422,7 +1422,7 @@ void SwTextShell::GetState( SfxItemSet &rSet ) break; case FN_NUMBER_NEWSTART : - if(!rSh.GetCurNumRule()) + if(!rSh.GetNumRuleAtCurrCrsrPos()) rSet.DisableItem(nWhich); else rSet.Put(SfxBoolItem(FN_NUMBER_NEWSTART, @@ -1501,30 +1501,31 @@ void SwTextShell::GetState( SfxItemSet &rSet ) case SID_DEC_INDENT: case SID_INC_INDENT: + { + //if the paragrah has bullet we'll do the following things: + //1: if the bullet level is the first level, disable the decrease-indent button + //2: if the bullet level is the last level, disable the increase-indent button + if ( rSh.GetNumRuleAtCurrCrsrPos() && !rSh.HasReadonlySel() ) { - //if the paragrah has bullet we'll do the following things: - //1: if the bullet level is the first level, disable the decrease-indent button - //2: if the bullet level is the last level, disable the increase-indent button - if ( rSh.GetCurNumRule() && !rSh.HasReadonlySel() ) + const sal_uInt8 nLevel = rSh.GetNumLevel(); + if ( ( nLevel == ( MAXLEVEL - 1 ) && nWhich == SID_INC_INDENT ) + || ( nLevel == 0 && nWhich == SID_DEC_INDENT ) ) { - sal_uInt8 nLevel = rSh.GetNumLevel(); - if ( (nLevel == (MAXLEVEL-1) && nWhich == SID_INC_INDENT) || - (nLevel == 0 && nWhich == SID_DEC_INDENT) ) - { - rSet.DisableItem( nWhich ); - } + rSet.DisableItem( nWhich ); } - else//if the paragraph has no bullet, execute the original functions + } + else + { + sal_uInt16 nHtmlMode = ::GetHtmlMode( GetView().GetDocShell() ); + nHtmlMode &= HTMLMODE_ON | HTMLMODE_SOME_STYLES; + if ( ( nHtmlMode == HTMLMODE_ON ) + || !rSh.IsMoveLeftMargin( SID_INC_INDENT == nWhich, sal_True ) ) { - //below is copied of the old codes - sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell()); - nHtmlMode &= HTMLMODE_ON|HTMLMODE_SOME_STYLES; - if( (nHtmlMode == HTMLMODE_ON) || !rSh.IsMoveLeftMargin( - SID_INC_INDENT == nWhich, true )) - rSet.DisableItem( nWhich ); + rSet.DisableItem( nWhich ); } } - break; + } + break; case FN_DEC_INDENT_OFFSET: case FN_INC_INDENT_OFFSET: @@ -1729,16 +1730,19 @@ void SwTextShell::GetState( SfxItemSet &rSet ) rSet.DisableItem(nWhich); } break; + case FN_NUM_NUMBERING_ON: rSet.Put(SfxBoolItem(FN_NUM_NUMBERING_ON,rSh.SelectionHasNumber())); break; + case FN_NUM_BULLET_ON: rSet.Put(SfxBoolItem(FN_NUM_BULLET_ON,rSh.SelectionHasBullet())); break; + case FN_BUL_NUM_RULE_INDEX: case FN_NUM_NUM_RULE_INDEX: { - SwNumRule* pCurRule = (SwNumRule*)(GetShell().GetCurNumRule()); + SwNumRule* pCurRule = (SwNumRule*)(GetShell().GetNumRuleAtCurrCrsrPos()); sal_uInt16 nActNumLvl = (sal_uInt16)0xFFFF; rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,DEFAULT_NONE)); rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,DEFAULT_NONE)); diff --git a/sw/source/core/uibase/shells/txtattr.cxx b/sw/source/core/uibase/shells/txtattr.cxx index 47d7e9312acb..1b4350b31c08 100644 --- a/sw/source/core/uibase/shells/txtattr.cxx +++ b/sw/source/core/uibase/shells/txtattr.cxx @@ -355,7 +355,7 @@ SET_LINESPACE: aAdjust.SetWhich(SID_ATTR_PARA_ADJUST); GetView().GetViewFrame()->GetBindings().SetState( aAdjust ); // Toggle numbering alignment - const SwNumRule* pCurRule = GetShell().GetCurNumRule(); + const SwNumRule* pCurRule = GetShell().GetNumRuleAtCurrCrsrPos(); if( pCurRule ) { SvxNumRule aRule = pCurRule->MakeSvxNumRule(); diff --git a/sw/source/core/uibase/shells/txtnum.cxx b/sw/source/core/uibase/shells/txtnum.cxx index bffbfc2c3583..f5552272edeb 100644 --- a/sw/source/core/uibase/shells/txtnum.cxx +++ b/sw/source/core/uibase/shells/txtnum.cxx @@ -40,7 +40,6 @@ #include <svx/nbdtmgfact.hxx> #include <sfx2/viewfrm.hxx> #include <sfx2/bindings.hxx> -using namespace svx::sidebar; void SwTextShell::ExecEnterNum(SfxRequest &rReq) { @@ -105,25 +104,26 @@ void SwTextShell::ExecEnterNum(SfxRequest &rReq) GetShell().EndAllAction(); } break; + case FN_NUMBER_BULLETS: case SID_OUTLINE_BULLET: { - SfxItemSet aSet(GetPool(), - SID_HTML_MODE, SID_HTML_MODE, - SID_ATTR_NUMBERING_RULE, SID_PARAM_CUR_NUM_LEVEL, - 0 ); + SfxItemSet aSet( GetPool(), + SID_HTML_MODE, SID_HTML_MODE, + SID_ATTR_NUMBERING_RULE, SID_PARAM_CUR_NUM_LEVEL, + 0 ); SwDocShell* pDocSh = GetView().GetDocShell(); - bool bHtml = 0 != PTR_CAST(SwWebDocShell, pDocSh); - const SwNumRule* pCurRule = GetShell().GetCurNumRule(); - if( pCurRule ) + const bool bHtml = 0 != PTR_CAST( SwWebDocShell, pDocSh ); + const SwNumRule* pNumRuleAtCurrentSelection = GetShell().GetNumRuleAtCurrentSelection(); + if ( pNumRuleAtCurrentSelection != NULL ) { - SvxNumRule aRule = pCurRule->MakeSvxNumRule(); + SvxNumRule aRule = pNumRuleAtCurrentSelection->MakeSvxNumRule(); //convert type of linked bitmaps from SVX_NUM_BITMAP to (SVX_NUM_BITMAP|LINK_TOKEN) - for(sal_uInt16 i = 0; i < aRule.GetLevelCount(); i++) + for ( sal_uInt16 i = 0; i < aRule.GetLevelCount(); i++ ) { - SvxNumberFormat aFmt(aRule.GetLevel(i)); - if(SVX_NUM_BITMAP == aFmt.GetNumberingType()) + SvxNumberFormat aFmt( aRule.GetLevel( i ) ); + if ( SVX_NUM_BITMAP == aFmt.GetNumberingType() ) { const SvxBrushItem* pBrush = aFmt.GetBrush(); if(pBrush && !pBrush->GetGraphicLink().isEmpty()) @@ -140,8 +140,8 @@ void SwTextShell::ExecEnterNum(SfxRequest &rReq) sal_uInt16 nLevel = GetShell().GetNumLevel(); if( nLevel < MAXLEVEL ) { - nLevel = 1<<nLevel; - aSet.Put( SfxUInt16Item( SID_PARAM_CUR_NUM_LEVEL, nLevel )); + nLevel = 1 << nLevel; + aSet.Put( SfxUInt16Item( SID_PARAM_CUR_NUM_LEVEL, nLevel ) ); } } else @@ -152,9 +152,9 @@ void SwTextShell::ExecEnterNum(SfxRequest &rReq) SvxNumRule aSvxRule = aRule.MakeSvxNumRule(); const bool bRightToLeft = GetShell().IsInRightToLeftText( 0 ); - if( bHtml || bRightToLeft ) + if ( bHtml || bRightToLeft ) { - for( sal_uInt8 n = 0; n < MAXLEVEL; ++n ) + for ( sal_uInt8 n = 0; n < MAXLEVEL; ++n ) { SvxNumberFormat aFmt( aSvxRule.GetLevel( n ) ); if ( n && bHtml ) @@ -173,7 +173,7 @@ void SwTextShell::ExecEnterNum(SfxRequest &rReq) } aSvxRule.SetFeatureFlag(NUM_ENABLE_EMBEDDED_BMP, false); } - aSet.Put(SvxNumBulletItem(aSvxRule)); + aSet.Put( SvxNumBulletItem( aSvxRule ) ); } aSet.Put( SfxBoolItem( SID_PARAM_NUM_PRESET,false )); @@ -188,222 +188,115 @@ void SwTextShell::ExecEnterNum(SfxRequest &rReq) OSL_ENSURE(pDlg, "Dialogdiet fail!"); sal_uInt16 nRet = pDlg->Execute(); const SfxPoolItem* pItem; - if( RET_OK == nRet ) + if ( RET_OK == nRet ) { if( SFX_ITEM_SET == pDlg->GetOutputItemSet()->GetItemState( SID_ATTR_NUMBERING_RULE, false, &pItem )) { - rReq.AppendItem(*pItem); + rReq.AppendItem( *pItem ); rReq.Done(); - SvxNumRule* pSetRule = ((SvxNumBulletItem*)pItem)->GetNumRule(); + SvxNumRule* pSetRule = ( (SvxNumBulletItem*) pItem )->GetNumRule(); pSetRule->UnLinkGraphics(); - SwNumRule aSetRule( pCurRule - ? pCurRule->GetName() - : GetShell().GetUniqueNumRuleName(), - // #i89178# - numfunc::GetDefaultPositionAndSpaceMode() ); - aSetRule.SetSvxRule( *pSetRule, GetShell().GetDoc()); + SwNumRule aSetRule( pNumRuleAtCurrentSelection != NULL + ? pNumRuleAtCurrentSelection->GetName() + : GetShell().GetUniqueNumRuleName(), + numfunc::GetDefaultPositionAndSpaceMode() ); + aSetRule.SetSvxRule( *pSetRule, GetShell().GetDoc() ); aSetRule.SetAutoRule( sal_True ); // No start of new list, if an existing list style is edited. // Otherwise start a new list. - const bool bCreateList = (pCurRule == 0); + const bool bCreateList = ( pNumRuleAtCurrentSelection == NULL ); GetShell().SetCurNumRule( aSetRule, bCreateList ); } // If the Dialog was leaved with OK but nothing was chosen then the // numbering must be at least activated, if it is not already. - else if( !pCurRule && SFX_ITEM_SET == aSet.GetItemState( SID_ATTR_NUMBERING_RULE, false, &pItem )) + else if ( pNumRuleAtCurrentSelection == NULL + && SFX_ITEM_SET == aSet.GetItemState( SID_ATTR_NUMBERING_RULE, sal_False, &pItem ) ) { rReq.AppendItem( *pItem ); rReq.Done(); - SvxNumRule* pSetRule = ((SvxNumBulletItem*)pItem)->GetNumRule(); - SwNumRule aSetRule( GetShell().GetUniqueNumRuleName(), - // #i89178# - numfunc::GetDefaultPositionAndSpaceMode() ); - aSetRule.SetSvxRule(*pSetRule, GetShell().GetDoc()); + SvxNumRule* pSetRule = ( (SvxNumBulletItem*) pItem )->GetNumRule(); + SwNumRule aSetRule( + GetShell().GetUniqueNumRuleName(), + numfunc::GetDefaultPositionAndSpaceMode() ); + aSetRule.SetSvxRule( *pSetRule, GetShell().GetDoc() ); aSetRule.SetAutoRule( sal_True ); // start new list GetShell().SetCurNumRule( aSetRule, true ); } } - else if(RET_USER == nRet) + else if ( RET_USER == nRet ) GetShell().DelNumRules(); delete pDlg; } - break; + break; + default: OSL_FAIL("wrong dispatcher"); return; } } + void SwTextShell::ExecSetNumber(SfxRequest &rReq) { - SwNumRule aRule( GetShell().GetUniqueNumRuleName(), - // #i89178# - numfunc::GetDefaultPositionAndSpaceMode() ); - - SvxNumRule aSvxRule = aRule.MakeSvxNumRule(); - const bool bRightToLeft = GetShell().IsInRightToLeftText( 0 ); - - if( bRightToLeft ) - { - for( sal_uInt8 n = 0; n < MAXLEVEL; ++n ) - { - SvxNumberFormat aFmt( aSvxRule.GetLevel( n ) ); - /* if ( n && bHtml ) - { - // 1/2" for HTML - aFmt.SetLSpace(720); - aFmt.SetAbsLSpace(n * 720); - }*/ - // #i38904# Default alignment for - // numbering/bullet should be rtl in rtl paragraph: - if ( bRightToLeft ) - { - aFmt.SetNumAdjust( SVX_ADJUST_RIGHT ); - } - aSvxRule.SetLevel( n, aFmt, false ); - } - aSvxRule.SetFeatureFlag(NUM_ENABLE_EMBEDDED_BMP, false); - } - - const SwNumRule* pCurRule = GetShell().GetCurNumRule(); - sal_uInt16 nActNumLvl = (sal_uInt16)0xFFFF; - if( pCurRule ) - { - sal_uInt16 nLevel = GetShell().GetNumLevel(); - if( nLevel < MAXLEVEL ) - { - nActNumLvl = 1<<nLevel; - } - - aSvxRule = pCurRule->MakeSvxNumRule(); - - //convert type of linked bitmaps from SVX_NUM_BITMAP to (SVX_NUM_BITMAP|LINK_TOKEN) - for(sal_uInt16 i = 0; i < aSvxRule.GetLevelCount(); i++) - { - SvxNumberFormat aFmt(aSvxRule.GetLevel(i)); - if(SVX_NUM_BITMAP == aFmt.GetNumberingType()) - { - const SvxBrushItem* pBrush = aFmt.GetBrush(); - if( pBrush && !pBrush->GetGraphicLink().isEmpty() ) - aFmt.SetNumberingType(SvxExtNumType(SVX_NUM_BITMAP|LINK_TOKEN)); - aSvxRule.SetLevel(i, aFmt, aSvxRule.Get(i) != 0); - } - } - } - - switch(rReq.GetSlot()) + const sal_uInt16 nSlot = rReq.GetSlot(); + switch ( nSlot ) { case FN_SVX_SET_NUMBER: - { - SFX_REQUEST_ARG( rReq, pItem, SfxUInt16Item, FN_SVX_SET_NUMBER , false ); - if (pItem) - { - sal_uInt16 nIdx = pItem->GetValue(); - if (nIdx==DEFAULT_NONE) { - GetShell().DelNumRules(); - break; - } - --nIdx; - - NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(eNBOType::NUMBERING); - if ( pNumbering ) - { - SwNumRule aTmpRule( GetShell().GetUniqueNumRuleName(), - numfunc::GetDefaultPositionAndSpaceMode() ); - - SvxNumRule aTempRule = aTmpRule.MakeSvxNumRule(); - // set unit attribute to NB Manager - SfxItemSet aSet(GetPool(), - SID_ATTR_NUMBERING_RULE, SID_PARAM_CUR_NUM_LEVEL, - 0 ); - aSet.Put(SvxNumBulletItem(aTempRule)); - pNumbering->SetItems(&aSet); - pNumbering->ApplyNumRule(aTempRule,nIdx,nActNumLvl); - - sal_uInt16 nMask = 1; - for(sal_uInt16 i = 0; i < aSvxRule.GetLevelCount(); i++) - { - if(nActNumLvl & nMask) - { - SvxNumberFormat aFmt(aTempRule.GetLevel(i)); - aSvxRule.SetLevel(i, aFmt); - } - nMask <<= 1 ; - } - - aSvxRule.UnLinkGraphics(); - SwNumRule aSetRule( pCurRule - ? pCurRule->GetName() - : GetShell().GetUniqueNumRuleName(), - numfunc::GetDefaultPositionAndSpaceMode() ); - aSetRule.SetSvxRule( aSvxRule, GetShell().GetDoc()); - - aSetRule.SetAutoRule( sal_True ); - const bool bCreateList = (pCurRule == 0); - GetShell().SetCurNumRule( aSetRule, bCreateList ); - } - //End - } - break; - } case FN_SVX_SET_BULLET: { - SFX_REQUEST_ARG( rReq, pItem, SfxUInt16Item, FN_SVX_SET_BULLET , false ); - if (pItem) + SFX_REQUEST_ARG( rReq, pItem, SfxUInt16Item, nSlot, sal_False ); + if ( pItem != NULL ) { - sal_uInt16 nIdx = pItem->GetValue(); - if (nIdx==DEFAULT_NONE) { + const sal_uInt16 nChoosenItemIdx = pItem->GetValue(); + if ( nChoosenItemIdx == DEFAULT_NONE ) + { GetShell().DelNumRules(); - break; } - nIdx--; - - NBOTypeMgrBase* pBullets = NBOutlineTypeMgrFact::CreateInstance(eNBOType::MIXBULLETS); - if ( pBullets ) + else { - SwNumRule aTmpRule( GetShell().GetUniqueNumRuleName(), - numfunc::GetDefaultPositionAndSpaceMode() ); - - SvxNumRule aTempRule = aTmpRule.MakeSvxNumRule(); - // set unit attribute to NB Manager - SfxItemSet aSet(GetPool(), - SID_ATTR_NUMBERING_RULE, SID_PARAM_CUR_NUM_LEVEL, - 0 ); - aSet.Put(SvxNumBulletItem(aTempRule)); - pBullets->SetItems(&aSet); - - //SvxNumRule aTempRule( 0, 10, false ); - pBullets->ApplyNumRule(aTempRule,nIdx,nActNumLvl); - sal_uInt16 nMask = 1; - for(sal_uInt16 i = 0; i < aSvxRule.GetLevelCount(); i++) + svx::sidebar::NBOTypeMgrBase* pNBOTypeMgr = + nSlot == FN_SVX_SET_NUMBER + ? svx::sidebar::NBOutlineTypeMgrFact::CreateInstance( svx::sidebar::eNBOType::NUMBERING ) + : svx::sidebar::NBOutlineTypeMgrFact::CreateInstance( svx::sidebar::eNBOType::MIXBULLETS ); + if ( pNBOTypeMgr != NULL ) { - if(nActNumLvl & nMask) + const SwNumRule* pNumRuleAtCurrentSelection = GetShell().GetNumRuleAtCurrentSelection(); + sal_uInt16 nActNumLvl = (sal_uInt16) 0xFFFF; + if ( pNumRuleAtCurrentSelection != NULL ) { - SvxNumberFormat aFmt(aTempRule.GetLevel(i)); - aSvxRule.SetLevel(i, aFmt); + sal_uInt16 nLevel = GetShell().GetNumLevel(); + if ( nLevel < MAXLEVEL ) + { + nActNumLvl = 1 << nLevel; + } } - nMask <<= 1; + 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( sal_True ); + const bool bCreateNewList = ( pNumRuleAtCurrentSelection == NULL ); + GetShell().SetCurNumRule( aNewNumRule, bCreateNewList ); } - aSvxRule.UnLinkGraphics(); - - SwNumRule aSetRule( pCurRule - ? pCurRule->GetName() - : GetShell().GetUniqueNumRuleName(), - numfunc::GetDefaultPositionAndSpaceMode() ); - - aSetRule.SetSvxRule( aSvxRule, GetShell().GetDoc()); - - aSetRule.SetAutoRule( sal_True ); - const bool bCreateList = (pCurRule == 0); - GetShell().SetCurNumRule( aSetRule, bCreateList ); } - //End } - } break; + + default: + OSL_ENSURE(false, "wrong Dispatcher"); + return; } } diff --git a/sw/source/core/uibase/uiview/view2.cxx b/sw/source/core/uibase/uiview/view2.cxx index 0bc1e88d39e9..b7d865e4b6c8 100644 --- a/sw/source/core/uibase/uiview/view2.cxx +++ b/sw/source/core/uibase/uiview/view2.cxx @@ -1512,7 +1512,7 @@ void SwView::StateStatusLine(SfxItemSet &rSet) } } - const SwNumRule* pNumRule = rShell.GetCurNumRule(); + const SwNumRule* pNumRule = rShell.GetNumRuleAtCurrCrsrPos(); const bool bOutlineNum = pNumRule ? pNumRule->IsOutlineRule() : 0; if (pNumRule && !bOutlineNum ) // cursor in numbering @@ -1767,7 +1767,7 @@ void SwView::ExecuteStatusLine(SfxRequest &rReq) nId = FN_EDIT_REGION; else { - const SwNumRule* pNumRule = rSh.GetCurNumRule(); + const SwNumRule* pNumRule = rSh.GetNumRuleAtCurrCrsrPos(); if( pNumRule ) // cursor in numbering { if( pNumRule->IsAutoRule() ) diff --git a/sw/source/core/uibase/wrtsh/wrtsh1.cxx b/sw/source/core/uibase/wrtsh/wrtsh1.cxx index 417ddaeee73e..5d16ec867c3c 100644 --- a/sw/source/core/uibase/wrtsh/wrtsh1.cxx +++ b/sw/source/core/uibase/wrtsh/wrtsh1.cxx @@ -971,7 +971,7 @@ void SwWrtShell::SplitNode( sal_Bool bAutoFmt, sal_Bool bCheckTableStart ) void SwWrtShell::NumOrBulletOn(sal_Bool bNum) { // determine numbering rule found at current cursor position in the document. - const SwNumRule* pCurRule = GetCurNumRule(); + const SwNumRule* pCurRule = GetNumRuleAtCurrCrsrPos(); StartUndo(UNDO_NUMORNONUM); @@ -1282,7 +1282,7 @@ void SwWrtShell::NumOn() void SwWrtShell::NumOrBulletOff() { - const SwNumRule * pCurNumRule = GetCurNumRule(); + const SwNumRule * pCurNumRule = GetNumRuleAtCurrCrsrPos(); if (pCurNumRule) { @@ -1398,7 +1398,7 @@ SelectionType SwWrtShell::GetSelectionType() const nCnt |= (nsSelectionType::SEL_TBL | nsSelectionType::SEL_TBL_CELLS); // Do not pop up numbering toolbar, if the text node has a numbering of type SVX_NUM_NUMBER_NONE. - const SwNumRule* pNumRule = GetCurNumRule(); + const SwNumRule* pNumRule = GetNumRuleAtCurrCrsrPos(); if ( pNumRule ) { const SwTxtNode* pTxtNd = diff --git a/sw/source/core/undo/unnum.cxx b/sw/source/core/undo/unnum.cxx index 143b52f5659a..d3c9f3550c7c 100644 --- a/sw/source/core/undo/unnum.cxx +++ b/sw/source/core/undo/unnum.cxx @@ -107,15 +107,14 @@ void SwUndoInsNum::RedoImpl(::sw::UndoRedoContext & rContext) { SwDoc & rDoc = rContext.GetDoc(); - if( pOldNumRule ) + if ( pOldNumRule ) rDoc.ChgNumRuleFmts( aNumRule ); - else if( pHistory ) + else if ( pHistory ) { SwPaM & rPam( AddUndoRedoPaM(rContext) ); if( !sReplaceRule.isEmpty() ) { - rDoc.ReplaceNumRule(*rPam.GetPoint(), - sReplaceRule, aNumRule.GetName() ); + rDoc.ReplaceNumRule( *rPam.GetPoint(), sReplaceRule, aNumRule.GetName() ); } else { @@ -133,8 +132,8 @@ void SwUndoInsNum::SetLRSpaceEndPos() void SwUndoInsNum::RepeatImpl(::sw::RepeatContext & rContext) { - SwDoc & rDoc(rContext.GetDoc()); - if( nSttNode ) + SwDoc & rDoc( rContext.GetDoc() ); + if ( nSttNode ) { if( sReplaceRule.isEmpty() ) { diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index ea4f40ea0f53..71ccd9bb78b7 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -464,7 +464,7 @@ bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry getNumberingProperty(rPam, eNewState, pAny); else { - if( !rPam.GetDoc()->GetCurrNumRule( *rPam.GetPoint() ) ) + if( !rPam.GetDoc()->GetNumRuleAtPos( *rPam.GetPoint() ) ) eNewState = PropertyState_DEFAULT_VALUE; } break; @@ -841,7 +841,7 @@ void setNumberingProperty(const Any& rValue, SwPaM& rPam) pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); SwPamRanges aRangeArr( rPam ); SwPaM aPam( *rPam.GetPoint() ); - for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n ) + for ( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n ) { // no start of a new list pDoc->SetNumRule( aRangeArr.SetPam( n, aPam ), aRule, false ); @@ -857,9 +857,9 @@ void setNumberingProperty(const Any& rValue, SwPaM& rPam) } else if(!pSwNum->GetCreatedNumRuleName().isEmpty()) { - UnoActionContext aAction(pDoc); + UnoActionContext aAction( pDoc ); SwNumRule* pRule = pDoc->FindNumRulePtr( pSwNum->GetCreatedNumRuleName() ); - if(!pRule) + if ( !pRule ) throw RuntimeException(); // no start of a new list pDoc->SetNumRule( rPam, *pRule, false ); @@ -868,6 +868,7 @@ void setNumberingProperty(const Any& rValue, SwPaM& rPam) // outline numbering else { + // outline numbering UnoActionContext aAction(pDoc); SwNumRule* pRule = pDoc->GetOutlineNumRule(); if(!pRule) @@ -876,7 +877,7 @@ void setNumberingProperty(const Any& rValue, SwPaM& rPam) } } } - else if(rValue.getValueType() == ::getVoidCppuType()) + else if ( rValue.getValueType() == ::getVoidCppuType() ) { rPam.GetDoc()->DelNumRules(rPam); } @@ -884,7 +885,7 @@ void setNumberingProperty(const Any& rValue, SwPaM& rPam) void getNumberingProperty(SwPaM& rPam, PropertyState& eState, Any * pAny ) { - const SwNumRule* pNumRule = rPam.GetDoc()->GetCurrNumRule( *rPam.GetPoint() ); + const SwNumRule* pNumRule = rPam.GetDoc()->GetNumRuleAtPos( *rPam.GetPoint() ); if(pNumRule) { uno::Reference< XIndexReplace > xNum = new SwXNumberingRules(*pNumRule); diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx index 096f409f1ae6..59ac277848b6 100644 --- a/sw/source/filter/ww1/fltshell.cxx +++ b/sw/source/filter/ww1/fltshell.cxx @@ -522,8 +522,8 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, case RES_FLTR_NUMRULE: // insert Numrule { const OUString& rNumNm = ((SfxStringItem*)rEntry.pAttr)->GetValue(); - SwNumRule* pRul = pDoc->FindNumRulePtr( rNumNm ); - if( pRul ) + SwNumRule* pNumRule = pDoc->FindNumRulePtr( rNumNm ); + if( pNumRule ) { if( rEntry.MakeRegion(pDoc, aRegion, true)) { @@ -535,7 +535,7 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, { SwPaM aTmpPam( aTmpStart, aTmpEnd ); // no start of a new list - pDoc->SetNumRule( aTmpPam, *pRul, false ); + pDoc->SetNumRule( aTmpPam, *pNumRule, false ); aTmpStart = aTmpEnd; // here starts the next range ++aTmpStart; @@ -546,6 +546,7 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, } } break; + case RES_FLTR_NUMRULE_NUM: break; case RES_FLTR_BOOKMARK: diff --git a/sw/source/ui/misc/num.cxx b/sw/source/ui/misc/num.cxx index 376c600fdee9..c37c9b187003 100644 --- a/sw/source/ui/misc/num.cxx +++ b/sw/source/ui/misc/num.cxx @@ -921,7 +921,7 @@ SwSvxNumBulletTabDialog::SwSvxNumBulletTabDialog(Window* pParent, , rWrtSh(rSh) { GetUserButton()->SetClickHdl(LINK(this, SwSvxNumBulletTabDialog, RemoveNumberingHdl)); - GetUserButton()->Enable(rWrtSh.GetCurNumRule() != NULL); + GetUserButton()->Enable(rWrtSh.GetNumRuleAtCurrCrsrPos() != NULL); m_nSingleNumPageId = AddTabPage("singlenum", RID_SVXPAGE_PICK_SINGLE_NUM ); m_nBulletPageId = AddTabPage("bullets", RID_SVXPAGE_PICK_BULLET ); AddTabPage("outlinenum", RID_SVXPAGE_PICK_NUM ); |