summaryrefslogtreecommitdiff
path: root/sw/source/core
diff options
context:
space:
mode:
authorHenning Brinkmann <hbrinkm@openoffice.org>2003-09-05 14:13:51 +0000
committerHenning Brinkmann <hbrinkm@openoffice.org>2003-09-05 14:13:51 +0000
commit87ac4bad390c58629ae9b78a392d86b5a9a70b94 (patch)
tree4a42b4b382a8b425e07bf49ef1233230fab9b18b /sw/source/core
parent76974f040cf6f76ddb372deab5175e045aa5c622 (diff)
#111955#
Diffstat (limited to 'sw/source/core')
-rw-r--r--sw/source/core/doc/doc.cxx24
-rw-r--r--sw/source/core/doc/docnum.cxx323
-rw-r--r--sw/source/core/doc/number.cxx18
-rw-r--r--sw/source/core/docnode/ndnum.cxx51
-rw-r--r--sw/source/core/txtnode/ndtxt.cxx18
5 files changed, 383 insertions, 51 deletions
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index c1100cabd152..94c55f67569b 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: doc.cxx,v $
*
- * $Revision: 1.17 $
+ * $Revision: 1.18 $
*
- * last change: $Author: obo $ $Date: 2003-09-01 12:36:24 $
+ * last change: $Author: hbrinkm $ $Date: 2003-09-05 15:11:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -1236,5 +1236,25 @@ void SwDoc::AppendUndoForInsertFromDB( const SwPaM& rPam, BOOL bIsTable )
}
}
+// #111955#
+void SwDoc::SetOldNumbering(sal_Bool _bOldNumbering)
+{
+ if (bOldNumbering != _bOldNumbering)
+ {
+ bOldNumbering = _bOldNumbering;
+ SwNumRuleTbl& rNmTbl = GetNumRuleTbl();
+ for( USHORT n = 0; n < rNmTbl.Count(); ++n )
+ rNmTbl[n]->SetInvalidRule(TRUE);
+ UpdateNumRule();
+
+ if (bOldNumbering)
+ GetNodes().UpdateOutlineNodes();
+ else
+ {
+ if (pOutlineRule)
+ UpdateNumRule(*pOutlineRule, 0, TRUE);
+ }
+ }
+}
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index 00aa246c9881..1f6c95dcc246 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: docnum.cxx,v $
*
- * $Revision: 1.15 $
+ * $Revision: 1.16 $
*
- * last change: $Author: obo $ $Date: 2003-09-04 11:46:01 $
+ * last change: $Author: hbrinkm $ $Date: 2003-09-05 15:11:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -804,20 +804,44 @@ void SwDoc::SetOutlineLSpace( BYTE nLevel, short nFirstLnOfst, USHORT nLSpace )
void SwNumRuleInfo::MakeList( SwDoc& rDoc )
{
- SwModify* pMod;
- const SfxPoolItem* pItem;
- USHORT i, nMaxItems = rDoc.GetAttrPool().GetItemCount( RES_PARATR_NUMRULE);
- for( i = 0; i < nMaxItems; ++i )
- if( 0 != (pItem = rDoc.GetAttrPool().GetItem( RES_PARATR_NUMRULE, i ) ) &&
- 0 != ( pMod = (SwModify*)((SwNumRuleItem*)pItem)->GetDefinedIn()) &&
- ((SwNumRuleItem*)pItem)->GetValue().Len() &&
- ((SwNumRuleItem*)pItem)->GetValue() == rName )
+ // -> #111955#
+ if (bOutline)
+ {
+ const SwOutlineNodes & rOutlineNodes = rDoc.GetNodes().GetOutLineNds();
+
+ for (int i = 0; i < rOutlineNodes.Count(); i++)
+ {
+ SwTxtNode & aNode = *((SwTxtNode *) rOutlineNodes[i]);
+
+ if (aNode.IsOutlineNum())
+ AddNode(aNode);
+ }
+ }
+ // <- #111955#
+ else
+ {
+ SwModify* pMod;
+ const SfxPoolItem* pItem;
+ USHORT i, nMaxItems = rDoc.GetAttrPool().GetItemCount
+ ( RES_PARATR_NUMRULE);
+ for( i = 0; i < nMaxItems; ++i )
{
- if( pMod->IsA( TYPE( SwFmt )) )
- pMod->GetInfo( *this );
- else if( ((SwTxtNode*)pMod)->GetNodes().IsDocNodes() )
- AddNode( *(SwTxtNode*)pMod );
+ pItem = rDoc.GetAttrPool().GetItem( RES_PARATR_NUMRULE, i );
+ if( 0 != pItem)
+ {
+ pMod = (SwModify*)((SwNumRuleItem*)pItem)->GetDefinedIn();
+ if (0 != pMod &&
+ ((SwNumRuleItem*)pItem)->GetValue().Len() &&
+ ((SwNumRuleItem*)pItem)->GetValue() == rName )
+ {
+ if( pMod->IsA( TYPE( SwFmt )) )
+ pMod->GetInfo( *this );
+ else if( ((SwTxtNode*)pMod)->GetNodes().IsDocNodes() )
+ AddNode( *(SwTxtNode*)pMod );
+ }
+ }
}
+ }
}
@@ -2187,11 +2211,271 @@ void SwDoc::UpdateNumRule()
for( USHORT n = 0; n < rNmTbl.Count(); ++n )
if( rNmTbl[ n ]->IsInvalidRule() )
UpdateNumRule( rNmTbl[ n ]->GetName(), ULONG_MAX );
+
+
}
-void SwDoc::UpdateNumRule( const String& rName, ULONG nUpdPos )
+// -> #111955#
+/**
+ Reset numbering to start values.
+
+ @param rNum the numbering to reset
+ @param rNumRule the numbering rule to take the start values
+ from
+ @param nStartLevel the level to start
+ @param bInitializedLevels array to mark reset levels in
+
+ All values in rNum that have a level >= nStartLevel are set to
+ their start level. The start level is looked up in rNumRule. For
+ all levels >= nStartLevel the accroding entry in bInitializedLevels
+ is set to true.
+*/
+void lcl_NodeNumReset(SwNodeNum & rNum, const SwNumRule & rNumRule,
+ int nStartLevel, bool * bInitializedLevels)
{
- SwNumRuleInfo aUpd( rName );
+ for (int i = nStartLevel; i < MAXLEVEL; i++)
+ {
+ rNum.GetLevelVal()[i] = rNumRule.Get(i).GetStart();
+ bInitializedLevels[i] = true;
+ }
+}
+
+/**
+ Update numbering for all nodes that have a certain numbering rule.
+
+ @param rName name of the numbering rule to search for
+ @param nUpdatePos document position to start at
+ */
+void SwDoc::UpdateNumRule( const String& rName, ULONG nUpdatePos )
+{
+ SwNumRule * pRule = FindNumRulePtr(rName);
+ ASSERT(pRule, "numrule not found");
+ if (pRule == NULL)
+ return;
+
+ UpdateNumRule(*pRule, nUpdatePos);
+}
+
+/**
+ Update numbering for all nodes that have a certain numbering rule.
+
+ @param rRule numbering rule to search for
+ @param nUpdatePos document position to start at
+ @param bOutline TRUE: update outline numbering
+ FALSE: update normal numbering
+ */
+void SwDoc::UpdateNumRule( const SwNumRule & rRule, ULONG nUpdatePos,
+ BOOL bOutline)
+{
+ /* If old numbering is activated use the old algorithm. */
+ if (IsOldNumbering())
+ {
+ UpdateNumRuleOld(rRule, nUpdatePos);
+
+ return;
+ }
+
+ /* Get all paragraphs with the given numbering rule from the
+ document. */
+ SwNumRuleInfo aNumRuleInfo(rRule.GetName());
+ aNumRuleInfo.MakeList(*this, bOutline);
+
+ /* If there are no matching paragraphs we are done. */
+ if (aNumRuleInfo.GetList().Count() == 0)
+ return;
+
+ /* ULONG_MAX -> process all paragraphs found */
+ if (nUpdatePos == ULONG_MAX)
+ nUpdatePos = 0;
+ else /* nUpdatePos is still the position in the document. Convert
+ to position in the list of found paragraphs. */
+ aNumRuleInfo.GetList().SearchKey(nUpdatePos, &nUpdatePos);
+
+ /* Temporal numbering holding the values to be changed in the
+ current node*/
+ SwNodeNum aNum(0);
+ /* Array for initialized levels.
+ bInitializedLevels[i] == true -> level i is initialized.
+ */
+ bool bInitializedLevels[MAXLEVEL];
+ /* flag for initialized continuous numbering. */
+ bool bInitialized = false;
+ /* counter for continuous numbering */
+ int nCount = 0;
+
+ /* If all paragraphs found are to be processed initialize all
+ levels with their start values.*/
+ if (nUpdatePos == 0)
+ {
+ for (int i = 0; i < MAXLEVEL; i++)
+ bInitializedLevels[i] = false;
+
+ lcl_NodeNumReset(aNum, rRule, 0, bInitializedLevels);
+
+ nCount = rRule.Get(0).GetStart();
+ bInitialized = true;
+ }
+ else /* If we start at a certain paragraph fill aNum/nCount with
+ values from that paragraph. Mark all levels as initalized,
+ including continuous numbering. */
+ {
+ for (int i = 0; i < MAXLEVEL; i++)
+ bInitializedLevels[i] = true;
+
+ aNum = aNumRuleInfo.GetList().GetObject(nUpdatePos)->
+ GetNum(bOutline);
+
+ nCount = aNum.GetLevelVal()[aNum.GetRealLevel()];
+ bInitialized = true;
+ }
+
+ /* The old level is the level of the first node to process. */
+ SwNodeNum * pNum = aNumRuleInfo.GetList().GetObject(nUpdatePos)->
+ GetNum();
+ BYTE nOldLevel = pNum ? pNum->GetLevel() : 0;
+
+ /* Iterate over all nodes to process. */
+ while(nUpdatePos < aNumRuleInfo.GetList().Count())
+ {
+ /* Get the current node. */
+ SwTxtNode * pTxtNode = aNumRuleInfo.GetList().GetObject(nUpdatePos);
+
+ /* If the current node has a conditional paragraph style,
+ ensure the current node gets the resulting style. */
+ if( RES_CONDTXTFMTCOLL == pTxtNode->GetFmtColl()->Which() )
+ pTxtNode->ChkCondColl();
+
+ ASSERT(0 != pTxtNode->GetNum(bOutline), "No numrule!");
+
+ if (! pTxtNode->GetNum(bOutline))
+ continue;
+
+ /* Get old numbering of the current node. */
+ const SwNodeNum * pOldNum = pTxtNode->GetNum(bOutline);
+
+ BYTE nLevel = pOldNum->GetRealLevel();
+
+ /* If numbering restarts at the current node ...*/
+ if (pOldNum->IsStart())
+ {
+ /* Fill aNum with start values of current level and
+ subsequent levels. */
+ lcl_NodeNumReset(aNum, rRule, nLevel, bInitializedLevels);
+
+ /* Fill nCount with start values for continuous numbering. */
+ nCount = rRule.Get(0).GetStart();
+ bInitialized = true;
+ }
+ /* If numbering restarts with a specific value ...*/
+ else if (pOldNum->HasSetValue())
+ {
+ /* Fill aNum with start values of current level and
+ subsequent levels. This also marks the current level as
+ initialized. Set specific value for current level. */
+ lcl_NodeNumReset(aNum, rRule, nLevel, bInitializedLevels);
+ aNum.GetLevelVal()[nLevel] = pOldNum->GetSetValue();
+
+ /* Fill nCount with the specific start value. */
+ nCount = pOldNum->GetSetValue();
+ bInitialized = true;
+ }
+ /* If the current node is the first in a row of nodes of its
+ level initialize the subsequent levels. */
+ else if (nOldLevel != nLevel)
+ {
+ lcl_NodeNumReset(aNum, rRule, nLevel + 1, bInitializedLevels);
+ }
+ nOldLevel = nLevel;
+
+ int i;
+
+ /* All previous levels are initialized. */
+ for (i = nLevel - 1; i >= 0; i--)
+ bInitializedLevels[i] = false;
+
+ /* If the level of the current node is initialized do not
+ increase the value for this level. Mark this level as
+ uninitialized. */
+ if (bInitializedLevels[nLevel])
+ bInitializedLevels[nLevel] = false;
+ else /* If the level of the current node was not initialized
+ increase the value for this level. */
+ aNum.GetLevelVal()[nLevel]++;
+
+ /* If the continuous numbering was initialized. mark it as
+ uninitialized and do not increase the value for the
+ continuous numbering. */
+ if (bInitialized)
+ bInitialized = false;
+ else /* If the continuous numbering was not initialized,
+ increase its value. */
+ nCount++;
+
+ /* If the current numbering is continuous set the value for
+ the current level to the value of the continous
+ numbering. Mark the current numbering as
+ continous. Otherwise mark the current numbering as
+ non-continuous. */
+ if (rRule.IsContinusNum())
+ {
+ aNum.GetLevelVal()[nLevel] = nCount;
+ aNum.SetContinuousNum();
+ }
+ else
+ {
+ aNum.SetContinuousNum(FALSE);
+ }
+
+ /* bChanged = true -> the current node's numbering has to be altered. */
+ bool bChanged = false;
+
+ /* the numbering to replace the current numbering */
+ SwNodeNum aTmpNum = *pOldNum;
+
+ if (aNum.IsContinuousNum() != aTmpNum.IsContinuousNum())
+ {
+ /* Continuous numbering has been activated or deactivated
+ -> change the numbering of the current node. */
+ aTmpNum.SetContinuousNum(aNum.IsContinuousNum());
+ aTmpNum.GetLevelVal()[nLevel] = nCount;
+ bChanged = true;
+ }
+
+ if (! bChanged)
+ {
+ /* For each level synchronize the local numbering (aNum)
+ with the numbering to be set in the current node
+ (aTmpNum). If there are differences propagate the value
+ fom aNum to aTmpNum. In this case the numbering of the
+ current node. */
+ for (i = 0; i < MAXLEVEL; i++)
+ {
+ if (aTmpNum.GetLevelVal()[i] != aNum.GetLevelVal()[i])
+ {
+ aTmpNum.GetLevelVal()[i] = aNum.GetLevelVal()[i];
+ bChanged = true;
+ }
+ }
+ }
+
+ /* If the current node's numbering is to be changed change the
+ according normal or outline numbering. */
+ if (bChanged)
+ {
+ if (bOutline)
+ pTxtNode->UpdateOutlineNum(aTmpNum);
+ else
+ pTxtNode->UpdateNum(aTmpNum);
+ }
+
+ nUpdatePos++;
+ }
+}
+
+// pre-SRC680-numbering
+void SwDoc::UpdateNumRuleOld( const SwNumRule & rRule, ULONG nUpdPos )
+{
+ SwNumRuleInfo aUpd( rRule.GetName() );
aUpd.MakeList( *this );
if( ULONG_MAX == nUpdPos )
@@ -2199,7 +2483,8 @@ void SwDoc::UpdateNumRule( const String& rName, ULONG nUpdPos )
else
aUpd.GetList().SearchKey( nUpdPos, &nUpdPos );
- SwNumRule* pRule = FindNumRulePtr( rName );
+ const SwNumRule* pRule = &rRule;
+
if( nUpdPos < aUpd.GetList().Count() )
{
USHORT nInitLevels = USHRT_MAX; // Bitfeld fuer die Levels!
@@ -2443,6 +2728,4 @@ void SwDoc::UpdateNumRule( const String& rName, ULONG nUpdPos )
if( pRule )
pRule->SetInvalidRule( FALSE );
}
-
-
-
+// <- #111955#
diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx
index a16ef7e76eb4..5dcbbc9d685c 100644
--- a/sw/source/core/doc/number.cxx
+++ b/sw/source/core/doc/number.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: number.cxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: vg $ $Date: 2003-06-10 13:17:29 $
+ * last change: $Author: hbrinkm $ $Date: 2003-09-05 15:11:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -406,12 +406,14 @@ const SwFmtVertOrient* SwNumFmt::GetGraphicOrientation() const
BOOL SwNodeNum::operator==( const SwNodeNum& rNum ) const
{
- return nMyLevel == rNum.nMyLevel &&
- nSetValue == rNum.nSetValue &&
- bStartNum == rNum.bStartNum &&
- ( nMyLevel >= MAXLEVEL ||
- 0 == memcmp( nLevelVal, rNum.nLevelVal,
- sizeof( USHORT ) * (nMyLevel+1) ));
+ return
+ nMyLevel == rNum.nMyLevel &&
+ nSetValue == rNum.nSetValue &&
+ bStartNum == rNum.bStartNum &&
+ bContNum == rNum.bContNum && // #111955#
+ ( nMyLevel >= MAXLEVEL ||
+ 0 == memcmp( nLevelVal, rNum.nLevelVal,
+ sizeof( USHORT ) * (nMyLevel+1) ));
}
SwNumRule::SwNumRule( const String& rNm, SwNumRuleType eType, BOOL bAutoFlg )
diff --git a/sw/source/core/docnode/ndnum.cxx b/sw/source/core/docnode/ndnum.cxx
index 8631e101d2c2..58fbf740d506 100644
--- a/sw/source/core/docnode/ndnum.cxx
+++ b/sw/source/core/docnode/ndnum.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ndnum.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: vg $ $Date: 2003-04-17 13:56:42 $
+ * last change: $Author: hbrinkm $ $Date: 2003-09-05 15:11:31 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -316,7 +316,7 @@ BOOL lcl_UpdateOutline( const SwNodePtr& rpNd, void* pPara )
void SwNodes::UpdateOutlineNode( const SwNode& rNd, BYTE nOldLevel,
- BYTE nNewLevel )
+ BYTE nNewLevel )
{
const SwNodePtr pSrch = (SwNodePtr)&rNd;
USHORT nSttPos;
@@ -351,27 +351,40 @@ void SwNodes::UpdateOutlineNode( const SwNode& rNd, BYTE nOldLevel,
else if( !bSeekIdx ) // Update und Index nicht gefunden ??
return ;
- _OutlinePara aPara( *this, nSttPos, nOldLevel, nNewLevel );
- pOutlineNds->ForEach( nSttPos, pOutlineNds->Count(),
- lcl_UpdateOutline, &aPara );
-
-//FEATURE::CONDCOLL
+ if (GetDoc()->IsOldNumbering())
{
- SwCntntNode* pCNd;
- ULONG nSttNd = rNd.GetIndex();
- if( NO_NUMBERING != nNewLevel )
- ++nSttPos;
+ _OutlinePara aPara( *this, nSttPos, nOldLevel, nNewLevel );
+ pOutlineNds->ForEach( nSttPos, pOutlineNds->Count(),
+ lcl_UpdateOutline, &aPara );
+
+ //FEATURE::CONDCOLL
+ {
+ SwCntntNode* pCNd;
+ ULONG nSttNd = rNd.GetIndex();
+ if( NO_NUMBERING != nNewLevel )
+ ++nSttPos;
- ULONG nChkCount = ( nSttPos < pOutlineNds->Count()
+ ULONG nChkCount = ( nSttPos < pOutlineNds->Count()
? (*pOutlineNds)[ nSttPos ]->GetIndex()
: GetEndOfContent().GetIndex() )
- - nSttNd;
- for( ; nChkCount--; ++nSttNd )
- if( 0 != (pCNd = (*this)[ nSttNd ]->GetCntntNode() ) &&
- RES_CONDTXTFMTCOLL == pCNd->GetFmtColl()->Which() )
- pCNd->ChkCondColl();
+ - nSttNd;
+ for( ; nChkCount--; ++nSttNd )
+ if( 0 != (pCNd = (*this)[ nSttNd ]->GetCntntNode() ) &&
+ RES_CONDTXTFMTCOLL == pCNd->GetFmtColl()->Which() )
+ pCNd->ChkCondColl();
+ }
+ //FEATURE::CONDCOLL
+
+ }
+ else // #111955#
+ {
+ SwTxtNode & rTxtNd = (SwTxtNode &) rNd;
+ SwNodeNum aNum = rTxtNd.GetOutlineNum();
+ aNum.SetLevel(rTxtNd.GetTxtColl()->GetOutlineLevel());
+ rTxtNd.UpdateOutlineNum(aNum);
+
+ GetDoc()->UpdateNumRule(*GetDoc()->GetOutlineNumRule(), 0, TRUE);
}
-//FEATURE::CONDCOLL
// die Gliederungs-Felder Updaten
GetDoc()->GetSysFldType( RES_CHAPTERFLD )->UpdateFlds();
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 0327dfadc4a4..59d37888c43e 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ndtxt.cxx,v $
*
- * $Revision: 1.17 $
+ * $Revision: 1.18 $
*
- * last change: $Author: vg $ $Date: 2003-05-26 08:14:13 $
+ * last change: $Author: hbrinkm $ $Date: 2003-09-05 15:11:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -2256,6 +2256,9 @@ void SwTxtNode::GCAttr()
const SwNodeNum* SwTxtNode::UpdateNum( const SwNodeNum& rNum )
{
+ // #111955#
+ const SwNodeNum * pOldNum = pNdNum;
+
if( NO_NUMBERING == rNum.GetLevel() ) // kein Nummerierung mehr ?
{
if( !pNdNum )
@@ -2269,6 +2272,11 @@ const SwNodeNum* SwTxtNode::UpdateNum( const SwNodeNum& rNum )
else if( !( *pNdNum == rNum ))
*pNdNum = rNum;
}
+
+ // #111955#
+ if ((0 == pOldNum || 0 == pNdNum) && pOldNum != pNdNum)
+ GetDoc()->UpdateNumRule(*GetDoc()->GetOutlineNumRule(), 0, TRUE);
+
NumRuleChgd();
return pNdNum;
}
@@ -2326,6 +2334,12 @@ const SwNodeNum* SwTxtNode::UpdateOutlineNum( const SwNodeNum& rNum )
return pNdOutl;
}
+// #111955#
+BOOL SwTxtNode::IsOutlineNum() const
+{
+ return pNdOutl != NULL && pNdNum == NULL;
+}
+
SwTxtNode* SwTxtNode::_MakeNewTxtNode( const SwNodeIndex& rPos, BOOL bNext,
BOOL bChgFollow )
{