1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ndnum.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
39 #include <fldbas.hxx> // UpdateFlds der KapitelNummerierung
42 _SV_IMPL_SORTAR_ALG( SwOutlineNodes
, SwNodePtr
)
43 BOOL
SwOutlineNodes::Seek_Entry( const SwNodePtr rSrch
, USHORT
* pFndPos
) const
45 ULONG nIdx
= rSrch
->GetIndex();
47 USHORT nO
= Count(), nM
, nU
= 0;
50 //JP 17.03.98: aufgrund des Bug 48592 - wo unter anderem nach Undo/Redo
51 // Nodes aus dem falschen NodesArray im OutlineArray standen,
52 // jetzt mal einen Check eingebaut.
55 for( USHORT n
= 1; n
< nO
; ++n
)
56 if( &(*this)[ n
-1 ]->GetNodes() !=
57 &(*this)[ n
]->GetNodes() )
59 ASSERT( !this, "Node im falschen Outline-Array" );
67 nM
= nU
+ ( nO
- nU
) / 2;
68 if( (*this)[ nM
] == rSrch
)
74 else if( (*this)[ nM
]->GetIndex() < nIdx
)
91 void SwNodes::UpdateOutlineNode(SwNode
& rNd
)
93 SwTxtNode
* pTxtNd
= rNd
.GetTxtNode();
95 if (pTxtNd
&& pTxtNd
->IsOutlineStateChanged())
97 BOOL bFound
= pOutlineNds
->Seek_Entry(pTxtNd
);
99 if (pTxtNd
->IsOutline())
103 // --> OD 2005-11-02 #125329#
104 // assure that text is in the correct nodes array
105 if ( &(pTxtNd
->GetNodes()) == this )
107 pOutlineNds
->Insert(pTxtNd
);
112 "<SwNodes::UpdateOutlineNode(..)> - given text node isn't in the correct nodes array. This is a serious defect -> inform OD" );
120 pOutlineNds
->Remove(pTxtNd
);
123 pTxtNd
->UpdateOutlineState();
125 // die Gliederungs-Felder Updaten
126 GetDoc()->GetSysFldType( RES_CHAPTERFLD
)->UpdateFlds();
130 //void SwNodes::UpdateOutlineNode( const SwNode& rNd, BYTE nOldLevel, //#outline level,removed by zhaojianwei
133 // const SwNodePtr pSrch = (SwNodePtr)&rNd;
135 // BOOL bSeekIdx = pOutlineNds->Seek_Entry( pSrch, &nSttPos );
137 // //if( NO_NUMBERING == nOldLevel ) //#outline level,zhaojianwei
138 // if( 0 == nOldLevel ) //<-end, zhaojianwei
140 // // nicht vorhanden, also einfuegen
141 // //ASSERT( !bSeekIdx, "Der Node ist schon als OutlineNode vorhanden" );
143 // //JP 12.03.99: 63293 - Nodes vom RedlineBereich NIE aufnehmen
144 // ULONG nNd = rNd.GetIndex();
145 // if( nNd < GetEndOfRedlines().GetIndex() &&
146 // nNd > GetEndOfRedlines().StartOfSectionNode()->GetIndex() )
149 // // jetzt noch alle nachfolgende Outline-Nodes updaten
152 // // --> OD 2005-11-03 #125329#
153 // // assure that node <pSrch> is in the correct nodes array
154 // if ( &(pSrch->GetNodes()) == this )
156 // pOutlineNds->Insert( pSrch );
161 // "<SwNodes::UpdateOutlineNode(..)> - node <pSrch> isn't in correct nodes array. This is a serious defect -> inform OD" );
167 // //else if( NO_NUMBERING == nNewLevel ) //#outline level,removed by zhaojianwei
168 // else if( 0 == nNewLevel ) //<-end,added by zhaojianwei // Level entfernen
173 // // jetzt noch alle nachfolgende Outline-Nodes updaten
174 // pOutlineNds->Remove( nSttPos );
176 // else if( !bSeekIdx ) // Update und Index nicht gefunden ??
180 // SwTxtNode & rTxtNd = (SwTxtNode &) rNd;
181 // SwPaM aPam(rTxtNd); // #115901#
183 // //if (nNewLevel != NO_NUMBERING) //#outline level,zhaojianwei // #115901#
184 // if (nNewLevel != 0) //<-end,zhaojianwei // #115901#
186 // //rTxtNd.SetLevel(rTxtNd.GetTxtColl()->GetOutlineLevel()); //#outline level,zhaojianwei
187 // //rTxtNd.NumRuleChgd();
188 // if(rTxtNd.GetTxtColl()->IsAssignedToListLevelOfOutlineStyle())
190 // rTxtNd.SetLevel(rTxtNd.GetTxtColl()->GetAssignedOutlineStyleLevel());
191 // rTxtNd.NumRuleChgd();
192 // }//<-end,zhaojianwei
194 // //GetDoc()->SetNumRule(aPam, *GetDoc()->GetOutlineNumRule());
198 // GetDoc()->DelNumRules(aPam);
202 // // die Gliederungs-Felder Updaten
203 // GetDoc()->GetSysFldType( RES_CHAPTERFLD )->UpdateFlds();
204 // GetDoc()->ChkCondColls();
205 //}//<-end,zhaojianwei
207 void SwNodes::UpdtOutlineIdx( const SwNode
& rNd
)
209 if( !pOutlineNds
->Count() ) // keine OutlineNodes vorhanden ?
212 const SwNodePtr pSrch
= (SwNodePtr
)&rNd
;
214 pOutlineNds
->Seek_Entry( pSrch
, &nPos
);
215 if( nPos
== pOutlineNds
->Count() ) // keine zum Updaten vorhanden ?
221 if( !GetDoc()->IsInDtor() && IsDocNodes() )
222 UpdateOutlineNode( *(*pOutlineNds
)[ nPos
]);
225 const SwOutlineNodes
& SwNodes::GetOutLineNds() const