xref: /aoo41x/main/sw/source/core/docnode/node.cxx (revision 4d7c9de0)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10efeef26fSAndrew Rist  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19efeef26fSAndrew Rist  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <hintids.hxx>
28cdf0e10cSrcweir #include <editeng/frmdiritem.hxx>
29cdf0e10cSrcweir #include <editeng/protitem.hxx>
30cdf0e10cSrcweir #include <com/sun/star/i18n/CharacterIteratorMode.hdl>
31cdf0e10cSrcweir #include <fmtcntnt.hxx>
32cdf0e10cSrcweir #include <fmtanchr.hxx>
33cdf0e10cSrcweir #include <frmfmt.hxx>
34cdf0e10cSrcweir #include <txtftn.hxx>
35cdf0e10cSrcweir #include <ftnfrm.hxx>
36cdf0e10cSrcweir #include <doc.hxx>
37cdf0e10cSrcweir #include <docary.hxx>
38cdf0e10cSrcweir #include <node.hxx>
39cdf0e10cSrcweir #include <ndindex.hxx>
40cdf0e10cSrcweir #include <numrule.hxx>
41cdf0e10cSrcweir #include <swtable.hxx>
42cdf0e10cSrcweir #include <ndtxt.hxx>
43cdf0e10cSrcweir #include <pam.hxx>
44cdf0e10cSrcweir #include <swcache.hxx>
45cdf0e10cSrcweir #include <section.hxx>
46cdf0e10cSrcweir #include <cntfrm.hxx>
47cdf0e10cSrcweir #include <flyfrm.hxx>
48cdf0e10cSrcweir #include <txtfrm.hxx>
49cdf0e10cSrcweir #include <tabfrm.hxx>  // SwTabFrm
50cdf0e10cSrcweir #include <viewsh.hxx>
51cdf0e10cSrcweir #include <paratr.hxx>
52cdf0e10cSrcweir #include <ftnidx.hxx>
53cdf0e10cSrcweir #include <fmtftn.hxx>
54cdf0e10cSrcweir #include <fmthdft.hxx>
55cdf0e10cSrcweir #include <frmatr.hxx>
56cdf0e10cSrcweir #include <fmtautofmt.hxx>
57cdf0e10cSrcweir #include <frmtool.hxx>
58cdf0e10cSrcweir #include <pagefrm.hxx>
59cdf0e10cSrcweir #include <node2lay.hxx>
60cdf0e10cSrcweir #include <pagedesc.hxx>
61cdf0e10cSrcweir #include <fmtpdsc.hxx>
62cdf0e10cSrcweir #include <breakit.hxx>
63cdf0e10cSrcweir #include <crsskip.hxx>
64cdf0e10cSrcweir #include <SwStyleNameMapper.hxx>
65cdf0e10cSrcweir #include <scriptinfo.hxx>
66cdf0e10cSrcweir #include <rootfrm.hxx>
67cdf0e10cSrcweir #include <istyleaccess.hxx>
68cdf0e10cSrcweir #include <IDocumentListItems.hxx>
69cdf0e10cSrcweir #include <switerator.hxx>
70cdf0e10cSrcweir #include "ndole.hxx"
71cdf0e10cSrcweir 
72cdf0e10cSrcweir using namespace ::com::sun::star::i18n;
73cdf0e10cSrcweir 
74cdf0e10cSrcweir TYPEINIT2( SwCntntNode, SwModify, SwIndexReg )
75cdf0e10cSrcweir 
76cdf0e10cSrcweir /*
77cdf0e10cSrcweir  * Some local helper functions for the attribute set handle of a content node.
78cdf0e10cSrcweir  * Since the attribute set of a content node may not be modified directly,
79cdf0e10cSrcweir  * we always have to create a new SwAttrSet, do the modifications, and get
80cdf0e10cSrcweir  * a new handle from the style access
81cdf0e10cSrcweir  */
82cdf0e10cSrcweir 
83cdf0e10cSrcweir namespace AttrSetHandleHelper
84cdf0e10cSrcweir {
85cdf0e10cSrcweir 
GetNewAutoStyle(boost::shared_ptr<const SfxItemSet> & mrpAttrSet,const SwCntntNode & rNode,SwAttrSet & rNewAttrSet)86cdf0e10cSrcweir void GetNewAutoStyle( boost::shared_ptr<const SfxItemSet>& mrpAttrSet,
87cdf0e10cSrcweir                       const SwCntntNode& rNode,
88cdf0e10cSrcweir                       SwAttrSet& rNewAttrSet )
89cdf0e10cSrcweir {
90cdf0e10cSrcweir     const SwAttrSet* pAttrSet = static_cast<const SwAttrSet*>(mrpAttrSet.get());
91cdf0e10cSrcweir 	if( rNode.GetModifyAtAttr() )
92cdf0e10cSrcweir         const_cast<SwAttrSet*>(pAttrSet)->SetModifyAtAttr( 0 );
93cdf0e10cSrcweir     IStyleAccess& rSA = pAttrSet->GetPool()->GetDoc()->GetIStyleAccess();
94cdf0e10cSrcweir     mrpAttrSet = rSA.getAutomaticStyle( rNewAttrSet, rNode.IsTxtNode() ?
95cdf0e10cSrcweir                                                      IStyleAccess::AUTO_STYLE_PARA :
96cdf0e10cSrcweir                                                      IStyleAccess::AUTO_STYLE_NOTXT );
97cdf0e10cSrcweir     const bool bSetModifyAtAttr = ((SwAttrSet*)mrpAttrSet.get())->SetModifyAtAttr( &rNode );
98cdf0e10cSrcweir     rNode.SetModifyAtAttr( bSetModifyAtAttr );
99cdf0e10cSrcweir }
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 
SetParent(boost::shared_ptr<const SfxItemSet> & mrpAttrSet,const SwCntntNode & rNode,const SwFmt * pParentFmt,const SwFmt * pConditionalFmt)102cdf0e10cSrcweir void SetParent( boost::shared_ptr<const SfxItemSet>& mrpAttrSet,
103cdf0e10cSrcweir                 const SwCntntNode& rNode,
104cdf0e10cSrcweir                 const SwFmt* pParentFmt,
105cdf0e10cSrcweir                 const SwFmt* pConditionalFmt )
106cdf0e10cSrcweir {
107cdf0e10cSrcweir     const SwAttrSet* pAttrSet = static_cast<const SwAttrSet*>(mrpAttrSet.get());
108cdf0e10cSrcweir     ASSERT( pAttrSet, "no SwAttrSet" )
109cdf0e10cSrcweir     ASSERT( pParentFmt || !pConditionalFmt, "ConditionalFmt without ParentFmt?" )
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     const SwAttrSet* pParentSet = pParentFmt ? &pParentFmt->GetAttrSet() : 0;
112cdf0e10cSrcweir 
113cdf0e10cSrcweir     if ( pParentSet != pAttrSet->GetParent() )
114cdf0e10cSrcweir     {
115cdf0e10cSrcweir         SwAttrSet aNewSet( *pAttrSet );
116cdf0e10cSrcweir         aNewSet.SetParent( pParentSet );
117cdf0e10cSrcweir         aNewSet.ClearItem( RES_FRMATR_STYLE_NAME );
118cdf0e10cSrcweir         aNewSet.ClearItem( RES_FRMATR_CONDITIONAL_STYLE_NAME );
119cdf0e10cSrcweir         String sVal;
120cdf0e10cSrcweir 
121cdf0e10cSrcweir         if ( pParentFmt )
122cdf0e10cSrcweir         {
123cdf0e10cSrcweir             SwStyleNameMapper::FillProgName( pParentFmt->GetName(), sVal, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True );
124cdf0e10cSrcweir             const SfxStringItem aAnyFmtColl( RES_FRMATR_STYLE_NAME, sVal );
125cdf0e10cSrcweir             aNewSet.Put( aAnyFmtColl );
126cdf0e10cSrcweir 
127cdf0e10cSrcweir             if ( pConditionalFmt != pParentFmt )
128cdf0e10cSrcweir                 SwStyleNameMapper::FillProgName( pConditionalFmt->GetName(), sVal, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True );
129cdf0e10cSrcweir 
130cdf0e10cSrcweir             const SfxStringItem aFmtColl( RES_FRMATR_CONDITIONAL_STYLE_NAME, sVal );
131cdf0e10cSrcweir             aNewSet.Put( aFmtColl );
132cdf0e10cSrcweir         }
133cdf0e10cSrcweir 
134cdf0e10cSrcweir         GetNewAutoStyle( mrpAttrSet, rNode, aNewSet );
135cdf0e10cSrcweir     }
136cdf0e10cSrcweir }
137cdf0e10cSrcweir 
Put(boost::shared_ptr<const SfxItemSet> & mrpAttrSet,const SwCntntNode & rNode,const SfxPoolItem & rAttr)138cdf0e10cSrcweir const SfxPoolItem* Put( boost::shared_ptr<const SfxItemSet>& mrpAttrSet,
139cdf0e10cSrcweir                         const SwCntntNode& rNode,
140cdf0e10cSrcweir                         const SfxPoolItem& rAttr )
141cdf0e10cSrcweir {
142cdf0e10cSrcweir     SwAttrSet aNewSet( (SwAttrSet&)*mrpAttrSet );
143cdf0e10cSrcweir     const SfxPoolItem* pRet = aNewSet.Put( rAttr );
144cdf0e10cSrcweir     if ( pRet )
145cdf0e10cSrcweir         GetNewAutoStyle( mrpAttrSet, rNode, aNewSet );
146cdf0e10cSrcweir     return pRet;
147cdf0e10cSrcweir }
148cdf0e10cSrcweir 
Put(boost::shared_ptr<const SfxItemSet> & mrpAttrSet,const SwCntntNode & rNode,const SfxItemSet & rSet)149cdf0e10cSrcweir int Put( boost::shared_ptr<const SfxItemSet>& mrpAttrSet, const SwCntntNode& rNode,
150cdf0e10cSrcweir          const SfxItemSet& rSet )
151cdf0e10cSrcweir {
152cdf0e10cSrcweir     SwAttrSet aNewSet( (SwAttrSet&)*mrpAttrSet );
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     // --> FME 2007-4-12 #i76273# Robust: Save the style name items:
155cdf0e10cSrcweir     SfxItemSet* pStyleNames = 0;
156cdf0e10cSrcweir     if ( SFX_ITEM_SET == rSet.GetItemState( RES_FRMATR_STYLE_NAME, sal_False ) )
157cdf0e10cSrcweir     {
158cdf0e10cSrcweir         pStyleNames = new SfxItemSet( *aNewSet.GetPool(), RES_FRMATR_STYLE_NAME, RES_FRMATR_CONDITIONAL_STYLE_NAME );
159cdf0e10cSrcweir         pStyleNames->Put( aNewSet );
160cdf0e10cSrcweir     }
161cdf0e10cSrcweir     // <--
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     const int nRet = aNewSet.Put( rSet );
164cdf0e10cSrcweir 
165cdf0e10cSrcweir     // --> FME 2007-4-12 #i76273# Robust: Save the style name items:
166cdf0e10cSrcweir     if ( pStyleNames )
167cdf0e10cSrcweir     {
168cdf0e10cSrcweir         aNewSet.Put( *pStyleNames );
169cdf0e10cSrcweir         delete pStyleNames;
170cdf0e10cSrcweir     }
171cdf0e10cSrcweir     // <--
172cdf0e10cSrcweir 
173cdf0e10cSrcweir     if ( nRet )
174cdf0e10cSrcweir         GetNewAutoStyle( mrpAttrSet, rNode, aNewSet );
175cdf0e10cSrcweir 
176cdf0e10cSrcweir     return nRet;
177cdf0e10cSrcweir }
178cdf0e10cSrcweir 
Put_BC(boost::shared_ptr<const SfxItemSet> & mrpAttrSet,const SwCntntNode & rNode,const SfxPoolItem & rAttr,SwAttrSet * pOld,SwAttrSet * pNew)179cdf0e10cSrcweir int Put_BC( boost::shared_ptr<const SfxItemSet>& mrpAttrSet,
180cdf0e10cSrcweir             const SwCntntNode& rNode, const SfxPoolItem& rAttr,
181cdf0e10cSrcweir             SwAttrSet* pOld, SwAttrSet* pNew )
182cdf0e10cSrcweir {
183cdf0e10cSrcweir     SwAttrSet aNewSet( (SwAttrSet&)*mrpAttrSet );
184cdf0e10cSrcweir 
185cdf0e10cSrcweir     // for a correct broadcast, we need to do a SetModifyAtAttr with the items
186cdf0e10cSrcweir     // from aNewSet. The 'regular' SetModifyAtAttr is done in GetNewAutoStyle
187cdf0e10cSrcweir     if( rNode.GetModifyAtAttr() )
188cdf0e10cSrcweir         aNewSet.SetModifyAtAttr( &rNode );
189cdf0e10cSrcweir 
190cdf0e10cSrcweir     const int nRet = aNewSet.Put_BC( rAttr, pOld, pNew );
191cdf0e10cSrcweir 
192cdf0e10cSrcweir     if ( nRet )
193cdf0e10cSrcweir         GetNewAutoStyle( mrpAttrSet, rNode, aNewSet );
194cdf0e10cSrcweir 
195cdf0e10cSrcweir     return nRet;
196cdf0e10cSrcweir }
197cdf0e10cSrcweir 
Put_BC(boost::shared_ptr<const SfxItemSet> & mrpAttrSet,const SwCntntNode & rNode,const SfxItemSet & rSet,SwAttrSet * pOld,SwAttrSet * pNew)198cdf0e10cSrcweir int Put_BC( boost::shared_ptr<const SfxItemSet>& mrpAttrSet,
199cdf0e10cSrcweir             const SwCntntNode& rNode, const SfxItemSet& rSet,
200cdf0e10cSrcweir             SwAttrSet* pOld, SwAttrSet* pNew )
201cdf0e10cSrcweir {
202cdf0e10cSrcweir     SwAttrSet aNewSet( (SwAttrSet&)*mrpAttrSet );
203cdf0e10cSrcweir 
204cdf0e10cSrcweir     // --> FME 2007-4-12 #i76273# Robust: Save the style name items:
205cdf0e10cSrcweir     SfxItemSet* pStyleNames = 0;
206cdf0e10cSrcweir     if ( SFX_ITEM_SET == rSet.GetItemState( RES_FRMATR_STYLE_NAME, sal_False ) )
207cdf0e10cSrcweir     {
208cdf0e10cSrcweir         pStyleNames = new SfxItemSet( *aNewSet.GetPool(), RES_FRMATR_STYLE_NAME, RES_FRMATR_CONDITIONAL_STYLE_NAME );
209cdf0e10cSrcweir         pStyleNames->Put( aNewSet );
210cdf0e10cSrcweir     }
211cdf0e10cSrcweir     // <--
212cdf0e10cSrcweir 
213cdf0e10cSrcweir     // for a correct broadcast, we need to do a SetModifyAtAttr with the items
214cdf0e10cSrcweir     // from aNewSet. The 'regular' SetModifyAtAttr is done in GetNewAutoStyle
215cdf0e10cSrcweir 	if( rNode.GetModifyAtAttr() )
216cdf0e10cSrcweir         aNewSet.SetModifyAtAttr( &rNode );
217cdf0e10cSrcweir 
218cdf0e10cSrcweir     const int nRet = aNewSet.Put_BC( rSet, pOld, pNew );
219cdf0e10cSrcweir 
220cdf0e10cSrcweir     // --> FME 2007-4-12 #i76273# Robust: Save the style name items:
221cdf0e10cSrcweir     if ( pStyleNames )
222cdf0e10cSrcweir     {
223cdf0e10cSrcweir         aNewSet.Put( *pStyleNames );
224cdf0e10cSrcweir         delete pStyleNames;
225cdf0e10cSrcweir     }
226cdf0e10cSrcweir     // <--
227cdf0e10cSrcweir 
228cdf0e10cSrcweir     if ( nRet )
229cdf0e10cSrcweir         GetNewAutoStyle( mrpAttrSet, rNode, aNewSet );
230cdf0e10cSrcweir 
231cdf0e10cSrcweir     return nRet;
232cdf0e10cSrcweir }
233cdf0e10cSrcweir 
ClearItem_BC(boost::shared_ptr<const SfxItemSet> & mrpAttrSet,const SwCntntNode & rNode,sal_uInt16 nWhich,SwAttrSet * pOld,SwAttrSet * pNew)234cdf0e10cSrcweir sal_uInt16 ClearItem_BC( boost::shared_ptr<const SfxItemSet>& mrpAttrSet,
235cdf0e10cSrcweir                      const SwCntntNode& rNode, sal_uInt16 nWhich,
236cdf0e10cSrcweir                      SwAttrSet* pOld, SwAttrSet* pNew )
237cdf0e10cSrcweir {
238cdf0e10cSrcweir     SwAttrSet aNewSet( (SwAttrSet&)*mrpAttrSet );
239cdf0e10cSrcweir 	if( rNode.GetModifyAtAttr() )
240cdf0e10cSrcweir         aNewSet.SetModifyAtAttr( &rNode );
241cdf0e10cSrcweir     const sal_uInt16 nRet = aNewSet.ClearItem_BC( nWhich, pOld, pNew );
242cdf0e10cSrcweir     if ( nRet )
243cdf0e10cSrcweir         GetNewAutoStyle( mrpAttrSet, rNode, aNewSet );
244cdf0e10cSrcweir     return nRet;
245cdf0e10cSrcweir }
246cdf0e10cSrcweir 
ClearItem_BC(boost::shared_ptr<const SfxItemSet> & mrpAttrSet,const SwCntntNode & rNode,sal_uInt16 nWhich1,sal_uInt16 nWhich2,SwAttrSet * pOld,SwAttrSet * pNew)247cdf0e10cSrcweir sal_uInt16 ClearItem_BC( boost::shared_ptr<const SfxItemSet>& mrpAttrSet,
248cdf0e10cSrcweir                      const SwCntntNode& rNode,
249cdf0e10cSrcweir                      sal_uInt16 nWhich1, sal_uInt16 nWhich2,
250cdf0e10cSrcweir                      SwAttrSet* pOld, SwAttrSet* pNew )
251cdf0e10cSrcweir {
252cdf0e10cSrcweir     SwAttrSet aNewSet( (SwAttrSet&)*mrpAttrSet );
253cdf0e10cSrcweir 	if( rNode.GetModifyAtAttr() )
254cdf0e10cSrcweir         aNewSet.SetModifyAtAttr( &rNode );
255cdf0e10cSrcweir     const sal_uInt16 nRet = aNewSet.ClearItem_BC( nWhich1, nWhich2, pOld, pNew );
256cdf0e10cSrcweir     if ( nRet )
257cdf0e10cSrcweir         GetNewAutoStyle( mrpAttrSet, rNode, aNewSet );
258cdf0e10cSrcweir     return nRet;
259cdf0e10cSrcweir }
260cdf0e10cSrcweir 
261cdf0e10cSrcweir }
262cdf0e10cSrcweir 
263cdf0e10cSrcweir /*******************************************************************
264cdf0e10cSrcweir |*
265cdf0e10cSrcweir |*	SwNode::GetSectionLevel
266cdf0e10cSrcweir |*
267cdf0e10cSrcweir |*	Beschreibung
268cdf0e10cSrcweir |*		Die Funktion liefert den Sectionlevel an der durch
269cdf0e10cSrcweir |*		aIndex bezeichneten Position.
270cdf0e10cSrcweir |*
271cdf0e10cSrcweir |*		Die Logik ist wie folgt:   ( S -> Start, E -> End, C -> CntntNode)
272cdf0e10cSrcweir |*			Level 	0		E
273cdf0e10cSrcweir |*					1 	S  E
274cdf0e10cSrcweir |*					2  	 SC
275cdf0e10cSrcweir |*
276cdf0e10cSrcweir |*		alle EndNodes der GrundSection haben den Level 0
277cdf0e10cSrcweir |*		alle StartNodes der GrundSection haben den Level 1
278cdf0e10cSrcweir |*
279cdf0e10cSrcweir |*	Ersterstellung
280cdf0e10cSrcweir |*		VER0100 vb 901214
281cdf0e10cSrcweir |*
282cdf0e10cSrcweir |*	Aenderung:	JP	11.08.93
283cdf0e10cSrcweir |*		keine Rekursion mehr !!
284cdf0e10cSrcweir |*
285cdf0e10cSrcweir *******************************************************************/
286cdf0e10cSrcweir 
287cdf0e10cSrcweir 
GetSectionLevel() const288cdf0e10cSrcweir sal_uInt16 SwNode::GetSectionLevel() const
289cdf0e10cSrcweir {
290cdf0e10cSrcweir 	// EndNode einer Grund-Section ?? diese sind immer 0 !!
291cdf0e10cSrcweir 	if( IsEndNode() && 0 == pStartOfSection->StartOfSectionIndex() )
292cdf0e10cSrcweir 		return 0;
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 	sal_uInt16 nLevel;
295cdf0e10cSrcweir 	const SwNode* pNode = IsStartNode() ? this : pStartOfSection;
296cdf0e10cSrcweir 	for( nLevel = 1; 0 != pNode->StartOfSectionIndex(); ++nLevel )
297cdf0e10cSrcweir 		pNode = pNode->pStartOfSection;
298cdf0e10cSrcweir 	return IsEndNode() ? nLevel-1 : nLevel;
299cdf0e10cSrcweir }
300cdf0e10cSrcweir 
301cdf0e10cSrcweir /*******************************************************************
302cdf0e10cSrcweir |*
303cdf0e10cSrcweir |*	SwNode::SwNode
304cdf0e10cSrcweir |*
305cdf0e10cSrcweir |*	Beschreibung
306cdf0e10cSrcweir |*		Konstruktor; dieser fuegt einen Node in das Array rNodes
307cdf0e10cSrcweir |*		an der Position rWhere ein. Dieser bekommt als
308cdf0e10cSrcweir |*		theEndOfSection den EndOfSection-Index des Nodes
309cdf0e10cSrcweir |*		unmittelbar vor ihm. Falls er sich an der Position 0
310cdf0e10cSrcweir |*		innerhalb des variablen Arrays befindet, wird
311cdf0e10cSrcweir |*		theEndOfSection 0 (der neue selbst).
312cdf0e10cSrcweir |*
313cdf0e10cSrcweir |*	Parameter
314cdf0e10cSrcweir |*		IN
315cdf0e10cSrcweir |*		rNodes bezeichnet das variable Array, in das der Node
316cdf0e10cSrcweir |*		eingefuegt werden soll
317cdf0e10cSrcweir |*		IN
318cdf0e10cSrcweir |*		rWhere bezeichnet die Position innerhalb dieses Arrays,
319cdf0e10cSrcweir |*		an der der Node eingefuegt werden soll
320cdf0e10cSrcweir |*
321cdf0e10cSrcweir |*	Ersterstellung
322cdf0e10cSrcweir |*		VER0100 vb 901214
323cdf0e10cSrcweir |*
324cdf0e10cSrcweir |*	Stand
325cdf0e10cSrcweir |*		VER0100 vb 901214
326cdf0e10cSrcweir |*
327cdf0e10cSrcweir *******************************************************************/
328cdf0e10cSrcweir 
329cdf0e10cSrcweir #ifdef DBG_UTIL
330cdf0e10cSrcweir long SwNode::nSerial = 0;
331cdf0e10cSrcweir #endif
332cdf0e10cSrcweir 
SwNode(const SwNodeIndex & rWhere,const sal_uInt8 nNdType)333cdf0e10cSrcweir SwNode::SwNode( const SwNodeIndex &rWhere, const sal_uInt8 nNdType )
334cdf0e10cSrcweir 	: nNodeType( nNdType ), pStartOfSection( 0 )
335cdf0e10cSrcweir {
336cdf0e10cSrcweir     bSetNumLSpace = bIgnoreDontExpand = sal_False;
337cdf0e10cSrcweir 	nAFmtNumLvl = 0;
338cdf0e10cSrcweir 
339cdf0e10cSrcweir 	SwNodes& rNodes = (SwNodes&)rWhere.GetNodes();
340cdf0e10cSrcweir 	SwNode* pInsNd = this; 		// der MAC kann this nicht einfuegen !!
341cdf0e10cSrcweir 	if( rWhere.GetIndex() )
342cdf0e10cSrcweir 	{
343cdf0e10cSrcweir 		SwNode* pNd = rNodes[ rWhere.GetIndex() -1 ];
344cdf0e10cSrcweir         rNodes.InsertNode( pInsNd, rWhere );
345cdf0e10cSrcweir 		if( 0 == ( pStartOfSection = pNd->GetStartNode()) )
346cdf0e10cSrcweir 		{
347cdf0e10cSrcweir 			pStartOfSection = pNd->pStartOfSection;
348cdf0e10cSrcweir 			if( pNd->GetEndNode() )		// EndNode ? Section ueberspringen!
349cdf0e10cSrcweir 			{
350cdf0e10cSrcweir 				pNd = pStartOfSection;
351cdf0e10cSrcweir 				pStartOfSection = pNd->pStartOfSection;
352cdf0e10cSrcweir 			}
353cdf0e10cSrcweir 		}
354cdf0e10cSrcweir 	}
355cdf0e10cSrcweir 	else
356cdf0e10cSrcweir 	{
357cdf0e10cSrcweir         rNodes.InsertNode( pInsNd, rWhere );
358cdf0e10cSrcweir 		pStartOfSection = (SwStartNode*)this;
359cdf0e10cSrcweir 	}
360cdf0e10cSrcweir 
361cdf0e10cSrcweir #ifdef DBG_UTIL
362cdf0e10cSrcweir     nMySerial = nSerial;
363cdf0e10cSrcweir     nSerial++;
364cdf0e10cSrcweir #endif
365cdf0e10cSrcweir }
366cdf0e10cSrcweir 
SwNode(SwNodes & rNodes,sal_uLong nPos,const sal_uInt8 nNdType)367cdf0e10cSrcweir SwNode::SwNode( SwNodes& rNodes, sal_uLong nPos, const sal_uInt8 nNdType )
368cdf0e10cSrcweir 	: nNodeType( nNdType ), pStartOfSection( 0 )
369cdf0e10cSrcweir {
370cdf0e10cSrcweir     bSetNumLSpace = bIgnoreDontExpand = sal_False;
371cdf0e10cSrcweir 	nAFmtNumLvl = 0;
372cdf0e10cSrcweir 
373cdf0e10cSrcweir 	SwNode* pInsNd = this; 		// der MAC kann this nicht einfuegen !!
374cdf0e10cSrcweir 	if( nPos )
375cdf0e10cSrcweir 	{
376cdf0e10cSrcweir 		SwNode* pNd = rNodes[ nPos - 1 ];
377cdf0e10cSrcweir         rNodes.InsertNode( pInsNd, nPos );
378cdf0e10cSrcweir 		if( 0 == ( pStartOfSection = pNd->GetStartNode()) )
379cdf0e10cSrcweir 		{
380cdf0e10cSrcweir 			pStartOfSection = pNd->pStartOfSection;
381cdf0e10cSrcweir 			if( pNd->GetEndNode() )		// EndNode ? Section ueberspringen!
382cdf0e10cSrcweir 			{
383cdf0e10cSrcweir 				pNd = pStartOfSection;
384cdf0e10cSrcweir 				pStartOfSection = pNd->pStartOfSection;
385cdf0e10cSrcweir 			}
386cdf0e10cSrcweir 		}
387cdf0e10cSrcweir 	}
388cdf0e10cSrcweir 	else
389cdf0e10cSrcweir 	{
390cdf0e10cSrcweir         rNodes.InsertNode( pInsNd, nPos );
391cdf0e10cSrcweir 		pStartOfSection = (SwStartNode*)this;
392cdf0e10cSrcweir 	}
393cdf0e10cSrcweir 
394cdf0e10cSrcweir #ifdef DBG_UTIL
395cdf0e10cSrcweir     nMySerial = nSerial;
396cdf0e10cSrcweir     nSerial++;
397cdf0e10cSrcweir #endif
398cdf0e10cSrcweir }
399cdf0e10cSrcweir 
~SwNode()400cdf0e10cSrcweir SwNode::~SwNode()
401cdf0e10cSrcweir {
402cdf0e10cSrcweir }
403cdf0e10cSrcweir 
404cdf0e10cSrcweir // suche den TabellenNode, in dem dieser steht. Wenn in keiner
405cdf0e10cSrcweir // Tabelle wird 0 returnt.
406cdf0e10cSrcweir 
407cdf0e10cSrcweir 
FindTableNode()408cdf0e10cSrcweir SwTableNode* SwNode::FindTableNode()
409cdf0e10cSrcweir {
410cdf0e10cSrcweir 	if( IsTableNode() )
411cdf0e10cSrcweir 		return GetTableNode();
412cdf0e10cSrcweir 	SwStartNode* pTmp = pStartOfSection;
413cdf0e10cSrcweir 	while( !pTmp->IsTableNode() && pTmp->GetIndex() )
414cdf0e10cSrcweir #if defined( ALPHA ) && defined( UNX )
415cdf0e10cSrcweir 		pTmp = ((SwNode*)pTmp)->pStartOfSection;
416cdf0e10cSrcweir #else
417cdf0e10cSrcweir 		pTmp = pTmp->pStartOfSection;
418cdf0e10cSrcweir #endif
419cdf0e10cSrcweir 	return pTmp->GetTableNode();
420cdf0e10cSrcweir }
421cdf0e10cSrcweir 
422cdf0e10cSrcweir 
423cdf0e10cSrcweir // liegt der Node im Sichtbarenbereich der Shell ?
IsInVisibleArea(ViewShell * pSh) const424cdf0e10cSrcweir sal_Bool SwNode::IsInVisibleArea( ViewShell* pSh ) const
425cdf0e10cSrcweir {
426cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
427cdf0e10cSrcweir 	const SwCntntNode* pNd;
428cdf0e10cSrcweir 
429cdf0e10cSrcweir 	if( ND_STARTNODE & nNodeType )
430cdf0e10cSrcweir 	{
431cdf0e10cSrcweir 		SwNodeIndex aIdx( *this );
432cdf0e10cSrcweir 		pNd = GetNodes().GoNext( &aIdx );
433cdf0e10cSrcweir 	}
434cdf0e10cSrcweir 	else if( ND_ENDNODE & nNodeType )
435cdf0e10cSrcweir 	{
436cdf0e10cSrcweir 		SwNodeIndex aIdx( *EndOfSectionNode() );
437cdf0e10cSrcweir 		pNd = GetNodes().GoPrevious( &aIdx );
438cdf0e10cSrcweir 	}
439cdf0e10cSrcweir 	else
440cdf0e10cSrcweir 		pNd = GetCntntNode();
441cdf0e10cSrcweir 
442cdf0e10cSrcweir 	if( !pSh )
443cdf0e10cSrcweir 		// dann die Shell vom Doc besorgen:
444cdf0e10cSrcweir 		GetDoc()->GetEditShell( &pSh );
445cdf0e10cSrcweir 
446cdf0e10cSrcweir     if( pSh )
447cdf0e10cSrcweir     {
448cdf0e10cSrcweir 	    const SwFrm* pFrm;
449cdf0e10cSrcweir 	    if( pNd && 0 != ( pFrm = pNd->getLayoutFrm( pSh->GetLayout(), 0, 0, sal_False ) ) )
450cdf0e10cSrcweir 	    {
451cdf0e10cSrcweir 
452cdf0e10cSrcweir 			if ( pFrm->IsInTab() )
453cdf0e10cSrcweir 				pFrm = pFrm->FindTabFrm();
454cdf0e10cSrcweir 
455cdf0e10cSrcweir 			if( !pFrm->IsValid() )
456cdf0e10cSrcweir 				do
457cdf0e10cSrcweir 				{	pFrm = pFrm->FindPrev();
458cdf0e10cSrcweir 				} while ( pFrm && !pFrm->IsValid() );
459cdf0e10cSrcweir 
460cdf0e10cSrcweir 			if( !pFrm || pSh->VisArea().IsOver( pFrm->Frm() ) )
461cdf0e10cSrcweir 				bRet = sal_True;
462cdf0e10cSrcweir 		}
463cdf0e10cSrcweir 	}
464cdf0e10cSrcweir 
465cdf0e10cSrcweir 	return bRet;
466cdf0e10cSrcweir }
467cdf0e10cSrcweir 
IsInProtectSect() const468cdf0e10cSrcweir sal_Bool SwNode::IsInProtectSect() const
469cdf0e10cSrcweir {
470cdf0e10cSrcweir 	const SwNode* pNd = ND_SECTIONNODE == nNodeType ? pStartOfSection : this;
471cdf0e10cSrcweir 	const SwSectionNode* pSectNd = pNd->FindSectionNode();
472cdf0e10cSrcweir 	return pSectNd && pSectNd->GetSection().IsProtectFlag();
473cdf0e10cSrcweir }
474cdf0e10cSrcweir 
475cdf0e10cSrcweir 	// befindet sich der Node in irgendetwas geschuetzten ?
476cdf0e10cSrcweir 	// (Bereich/Rahmen/Tabellenzellen/... incl. des Ankers bei
477cdf0e10cSrcweir 	//	Rahmen/Fussnoten/..)
IsProtect() const478cdf0e10cSrcweir sal_Bool SwNode::IsProtect() const
479cdf0e10cSrcweir {
480cdf0e10cSrcweir 	const SwNode* pNd = ND_SECTIONNODE == nNodeType ? pStartOfSection : this;
481cdf0e10cSrcweir 	const SwStartNode* pSttNd = pNd->FindSectionNode();
482cdf0e10cSrcweir 	if( pSttNd && ((SwSectionNode*)pSttNd)->GetSection().IsProtectFlag() )
483cdf0e10cSrcweir 		return sal_True;
484cdf0e10cSrcweir 
485cdf0e10cSrcweir 	if( 0 != ( pSttNd = FindTableBoxStartNode() ) )
486cdf0e10cSrcweir 	{
487cdf0e10cSrcweir 		SwCntntFrm* pCFrm;
488cdf0e10cSrcweir 		if( IsCntntNode() && 0 != (pCFrm = ((SwCntntNode*)this)->getLayoutFrm( GetDoc()->GetCurrentLayout() ) ))
489cdf0e10cSrcweir 			return pCFrm->IsProtected();
490cdf0e10cSrcweir 
491cdf0e10cSrcweir 		const SwTableBox* pBox = pSttNd->FindTableNode()->GetTable().
492cdf0e10cSrcweir 										GetTblBox( pSttNd->GetIndex() );
493cdf0e10cSrcweir         //Robust #149568
494cdf0e10cSrcweir 		if( pBox && pBox->GetFrmFmt()->GetProtect().IsCntntProtected() )
495cdf0e10cSrcweir 			return sal_True;
496cdf0e10cSrcweir 	}
497cdf0e10cSrcweir 
498cdf0e10cSrcweir 	SwFrmFmt* pFlyFmt = GetFlyFmt();
499cdf0e10cSrcweir 	if( pFlyFmt )
500cdf0e10cSrcweir 	{
501cdf0e10cSrcweir 		if( pFlyFmt->GetProtect().IsCntntProtected() )
502cdf0e10cSrcweir 			return sal_True;
503cdf0e10cSrcweir 		const SwFmtAnchor& rAnchor = pFlyFmt->GetAnchor();
504cdf0e10cSrcweir 		return rAnchor.GetCntntAnchor()
505cdf0e10cSrcweir 				? rAnchor.GetCntntAnchor()->nNode.GetNode().IsProtect()
506cdf0e10cSrcweir 				: sal_False;
507cdf0e10cSrcweir 	}
508cdf0e10cSrcweir 
509cdf0e10cSrcweir 	if( 0 != ( pSttNd = FindFootnoteStartNode() ) )
510cdf0e10cSrcweir 	{
511cdf0e10cSrcweir 		const SwTxtFtn* pTFtn = GetDoc()->GetFtnIdxs().SeekEntry(
512cdf0e10cSrcweir 								SwNodeIndex( *pSttNd ) );
513cdf0e10cSrcweir 		if( pTFtn )
514cdf0e10cSrcweir 			return pTFtn->GetTxtNode().IsProtect();
515cdf0e10cSrcweir 	}
516cdf0e10cSrcweir 
517cdf0e10cSrcweir 	return sal_False;
518cdf0e10cSrcweir }
519cdf0e10cSrcweir 
520cdf0e10cSrcweir 	// suche den PageDesc, mit dem dieser Node formatiert ist. Wenn das
521cdf0e10cSrcweir 	// Layout vorhanden ist wird ueber das gesucht, ansonsten gibt es nur
522cdf0e10cSrcweir 	// die harte Tour ueber die Nodes nach vorne suchen!!
FindPageDesc(sal_Bool bCalcLay,sal_uInt32 * pPgDescNdIdx) const523cdf0e10cSrcweir const SwPageDesc* SwNode::FindPageDesc( sal_Bool bCalcLay,
524cdf0e10cSrcweir                                         sal_uInt32* pPgDescNdIdx ) const
525cdf0e10cSrcweir {
526cdf0e10cSrcweir     // OD 18.03.2003 #106329#
527cdf0e10cSrcweir     if ( !GetNodes().IsDocNodes() )
528cdf0e10cSrcweir     {
529cdf0e10cSrcweir         return 0;
530cdf0e10cSrcweir     }
531cdf0e10cSrcweir 
532cdf0e10cSrcweir     const SwPageDesc* pPgDesc = 0;
533cdf0e10cSrcweir 
534cdf0e10cSrcweir     const SwCntntNode* pNode;
535cdf0e10cSrcweir     if( ND_STARTNODE & nNodeType )
536cdf0e10cSrcweir     {
537cdf0e10cSrcweir         SwNodeIndex aIdx( *this );
538cdf0e10cSrcweir         pNode = GetNodes().GoNext( &aIdx );
539cdf0e10cSrcweir     }
540cdf0e10cSrcweir     else if( ND_ENDNODE & nNodeType )
541cdf0e10cSrcweir     {
542cdf0e10cSrcweir         SwNodeIndex aIdx( *EndOfSectionNode() );
543cdf0e10cSrcweir         pNode = GetNodes().GoPrevious( &aIdx );
544cdf0e10cSrcweir     }
545cdf0e10cSrcweir     else
546cdf0e10cSrcweir     {
547cdf0e10cSrcweir         pNode = GetCntntNode();
548cdf0e10cSrcweir         if( pNode )
549cdf0e10cSrcweir             pPgDesc = ((SwFmtPageDesc&)pNode->GetAttr( RES_PAGEDESC )).GetPageDesc();
550cdf0e10cSrcweir     }
551cdf0e10cSrcweir 
552cdf0e10cSrcweir     // geht es uebers Layout?
553cdf0e10cSrcweir     if( !pPgDesc )
554cdf0e10cSrcweir     {
555cdf0e10cSrcweir         const SwFrm* pFrm;
556cdf0e10cSrcweir         const SwPageFrm* pPage;
557cdf0e10cSrcweir         if( pNode && 0 != ( pFrm = pNode->getLayoutFrm( pNode->GetDoc()->GetCurrentLayout(), 0, 0, bCalcLay ) ) &&
558cdf0e10cSrcweir             0 != ( pPage = pFrm->FindPageFrm() ) )
559cdf0e10cSrcweir         {
560cdf0e10cSrcweir             pPgDesc = pPage->GetPageDesc();
561cdf0e10cSrcweir             // OD 18.03.2003 #106329#
562cdf0e10cSrcweir             if ( pPgDescNdIdx )
563cdf0e10cSrcweir             {
564cdf0e10cSrcweir                 *pPgDescNdIdx = pNode->GetIndex();
565cdf0e10cSrcweir             }
566cdf0e10cSrcweir         }
567cdf0e10cSrcweir     }
568cdf0e10cSrcweir 
569cdf0e10cSrcweir     if( !pPgDesc )
570cdf0e10cSrcweir     {
571cdf0e10cSrcweir         // dann also uebers Nodes-Array
572cdf0e10cSrcweir         const SwDoc* pDoc = GetDoc();
573cdf0e10cSrcweir         const SwNode* pNd = this;
574cdf0e10cSrcweir         const SwStartNode* pSttNd;
575cdf0e10cSrcweir         if( pNd->GetIndex() < GetNodes().GetEndOfExtras().GetIndex() &&
576cdf0e10cSrcweir             0 != ( pSttNd = pNd->FindFlyStartNode() ) )
577cdf0e10cSrcweir         {
578cdf0e10cSrcweir             // dann erstmal den richtigen Anker finden
579cdf0e10cSrcweir             const SwFrmFmt* pFmt = 0;
580cdf0e10cSrcweir             const SwSpzFrmFmts& rFmts = *pDoc->GetSpzFrmFmts();
581cdf0e10cSrcweir             sal_uInt16 n;
582cdf0e10cSrcweir 
583cdf0e10cSrcweir             for( n = 0; n < rFmts.Count(); ++n )
584cdf0e10cSrcweir             {
585cdf0e10cSrcweir                 SwFrmFmt* pFrmFmt = rFmts[ n ];
586cdf0e10cSrcweir                 const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt();
587cdf0e10cSrcweir                 if( rCntnt.GetCntntIdx() &&
588cdf0e10cSrcweir                     &rCntnt.GetCntntIdx()->GetNode() == (SwNode*)pSttNd )
589cdf0e10cSrcweir                 {
590cdf0e10cSrcweir                     pFmt = pFrmFmt;
591cdf0e10cSrcweir                     break;
592cdf0e10cSrcweir                 }
593cdf0e10cSrcweir             }
594cdf0e10cSrcweir 
595cdf0e10cSrcweir             if( pFmt )
596cdf0e10cSrcweir             {
597cdf0e10cSrcweir                 const SwFmtAnchor* pAnchor = &pFmt->GetAnchor();
598cdf0e10cSrcweir                 if ((FLY_AT_PAGE != pAnchor->GetAnchorId()) &&
599cdf0e10cSrcweir                     pAnchor->GetCntntAnchor() )
600cdf0e10cSrcweir                 {
601cdf0e10cSrcweir                     pNd = &pAnchor->GetCntntAnchor()->nNode.GetNode();
602cdf0e10cSrcweir                     const SwNode* pFlyNd = pNd->FindFlyStartNode();
603cdf0e10cSrcweir                     while( pFlyNd )
604cdf0e10cSrcweir                     {
605cdf0e10cSrcweir                         // dann ueber den Anker nach oben "hangeln"
606cdf0e10cSrcweir                         for( n = 0; n < rFmts.Count(); ++n )
607cdf0e10cSrcweir                         {
608cdf0e10cSrcweir                             const SwFrmFmt* pFrmFmt = rFmts[ n ];
609cdf0e10cSrcweir                             const SwNodeIndex* pIdx = pFrmFmt->GetCntnt().
610cdf0e10cSrcweir                                                         GetCntntIdx();
611cdf0e10cSrcweir                             if( pIdx && pFlyNd == &pIdx->GetNode() )
612cdf0e10cSrcweir                             {
613cdf0e10cSrcweir                                 if( pFmt == pFrmFmt )
614cdf0e10cSrcweir                                 {
615cdf0e10cSrcweir                                     pNd = pFlyNd;
616cdf0e10cSrcweir                                     pFlyNd = 0;
617cdf0e10cSrcweir                                     break;
618cdf0e10cSrcweir                                 }
619cdf0e10cSrcweir                                 pAnchor = &pFrmFmt->GetAnchor();
620cdf0e10cSrcweir                                 if ((FLY_AT_PAGE == pAnchor->GetAnchorId()) ||
621cdf0e10cSrcweir                                     !pAnchor->GetCntntAnchor() )
622cdf0e10cSrcweir                                 {
623cdf0e10cSrcweir                                     pFlyNd = 0;
624cdf0e10cSrcweir                                     break;
625cdf0e10cSrcweir                                 }
626cdf0e10cSrcweir 
627cdf0e10cSrcweir                                 pFlyNd = pAnchor->GetCntntAnchor()->nNode.
628cdf0e10cSrcweir                                         GetNode().FindFlyStartNode();
629cdf0e10cSrcweir                                 break;
630cdf0e10cSrcweir                             }
631cdf0e10cSrcweir                         }
632cdf0e10cSrcweir                         if( n >= rFmts.Count() )
633cdf0e10cSrcweir                         {
63446d2a04eSHerbert Dürr                             ASSERT( !this, "Fly-Section but no format found" );
63546d2a04eSHerbert Dürr                             return NULL;
636cdf0e10cSrcweir                         }
637cdf0e10cSrcweir                     }
638cdf0e10cSrcweir                 }
639cdf0e10cSrcweir             }
640cdf0e10cSrcweir             // in pNd sollte jetzt der richtige Anker Node stehen oder
641cdf0e10cSrcweir             // immer noch der this
642cdf0e10cSrcweir         }
643cdf0e10cSrcweir 
644cdf0e10cSrcweir         if( pNd->GetIndex() < GetNodes().GetEndOfExtras().GetIndex() )
645cdf0e10cSrcweir         {
646cdf0e10cSrcweir             if( pNd->GetIndex() > GetNodes().GetEndOfAutotext().GetIndex() )
647cdf0e10cSrcweir             {
648cdf0e10cSrcweir                 pPgDesc = &pDoc->GetPageDesc( 0 );
649cdf0e10cSrcweir                 pNd = 0;
650cdf0e10cSrcweir             }
651cdf0e10cSrcweir             else
652cdf0e10cSrcweir             {
653cdf0e10cSrcweir                 // suche den Body Textnode
654cdf0e10cSrcweir                 if( 0 != ( pSttNd = pNd->FindHeaderStartNode() ) ||
655cdf0e10cSrcweir                     0 != ( pSttNd = pNd->FindFooterStartNode() ))
656cdf0e10cSrcweir                 {
657cdf0e10cSrcweir                     // dann in den PageDescs diesen StartNode suchen
658cdf0e10cSrcweir                     sal_uInt16 nId;
659cdf0e10cSrcweir                     UseOnPage eAskUse;
660cdf0e10cSrcweir                     if( SwHeaderStartNode == pSttNd->GetStartNodeType())
661cdf0e10cSrcweir                     {
662cdf0e10cSrcweir                         nId = RES_HEADER;
663cdf0e10cSrcweir                         eAskUse = nsUseOnPage::PD_HEADERSHARE;
664cdf0e10cSrcweir                     }
665cdf0e10cSrcweir                     else
666cdf0e10cSrcweir                     {
667cdf0e10cSrcweir                         nId = RES_FOOTER;
668cdf0e10cSrcweir                         eAskUse = nsUseOnPage::PD_FOOTERSHARE;
669cdf0e10cSrcweir                     }
670cdf0e10cSrcweir 
671cdf0e10cSrcweir                     for( sal_uInt16 n = pDoc->GetPageDescCnt(); n && !pPgDesc; )
672cdf0e10cSrcweir                     {
673cdf0e10cSrcweir                         const SwPageDesc& rPgDsc = pDoc->GetPageDesc( --n );
674cdf0e10cSrcweir                         const SwFrmFmt* pFmt = &rPgDsc.GetMaster();
675cdf0e10cSrcweir                         int nStt = 0, nLast = 1;
676cdf0e10cSrcweir                         if( !( eAskUse & rPgDsc.ReadUseOn() )) ++nLast;
677cdf0e10cSrcweir 
678cdf0e10cSrcweir                         for( ; nStt < nLast; ++nStt, pFmt = &rPgDsc.GetLeft() )
679cdf0e10cSrcweir                         {
680cdf0e10cSrcweir                             const SwFmtHeader& rHdFt = (SwFmtHeader&)
681cdf0e10cSrcweir                                                     pFmt->GetFmtAttr( nId );
682cdf0e10cSrcweir                             if( rHdFt.GetHeaderFmt() )
683cdf0e10cSrcweir                             {
684cdf0e10cSrcweir                                 const SwFmtCntnt& rCntnt =
685cdf0e10cSrcweir                                     rHdFt.GetHeaderFmt()->GetCntnt();
686cdf0e10cSrcweir                                 if( rCntnt.GetCntntIdx() &&
687cdf0e10cSrcweir                                     &rCntnt.GetCntntIdx()->GetNode() ==
688cdf0e10cSrcweir                                     (SwNode*)pSttNd )
689cdf0e10cSrcweir                                 {
690cdf0e10cSrcweir                                     pPgDesc = &rPgDsc;
691cdf0e10cSrcweir                                     break;
692cdf0e10cSrcweir                                 }
693cdf0e10cSrcweir                             }
694cdf0e10cSrcweir                         }
695cdf0e10cSrcweir                     }
696cdf0e10cSrcweir 
697cdf0e10cSrcweir                     if( !pPgDesc )
698cdf0e10cSrcweir                         pPgDesc = &pDoc->GetPageDesc( 0 );
699cdf0e10cSrcweir                     pNd = 0;
700cdf0e10cSrcweir                 }
701cdf0e10cSrcweir                 else if( 0 != ( pSttNd = pNd->FindFootnoteStartNode() ))
702cdf0e10cSrcweir                 {
703cdf0e10cSrcweir                     // der Anker kann nur im Bodytext sein
704cdf0e10cSrcweir                     const SwTxtFtn* pTxtFtn;
705cdf0e10cSrcweir                     const SwFtnIdxs& rFtnArr = pDoc->GetFtnIdxs();
706cdf0e10cSrcweir                     for( sal_uInt16 n = 0; n < rFtnArr.Count(); ++n )
707cdf0e10cSrcweir                         if( 0 != ( pTxtFtn = rFtnArr[ n ])->GetStartNode() &&
708cdf0e10cSrcweir                             (SwNode*)pSttNd ==
709cdf0e10cSrcweir                             &pTxtFtn->GetStartNode()->GetNode() )
710cdf0e10cSrcweir                         {
711cdf0e10cSrcweir                             pNd = &pTxtFtn->GetTxtNode();
712cdf0e10cSrcweir                             break;
713cdf0e10cSrcweir                         }
714cdf0e10cSrcweir                 }
715cdf0e10cSrcweir                 else
716cdf0e10cSrcweir                 {
717cdf0e10cSrcweir                     // kann jetzt nur noch ein Seitengebundener Fly sein
718cdf0e10cSrcweir                     // oder irgendetwas neueres.
719cdf0e10cSrcweir                     // Hier koennen wir nur noch den Standard returnen
720cdf0e10cSrcweir                     ASSERT( pNd->FindFlyStartNode(),
721cdf0e10cSrcweir                             "wo befindet sich dieser Node?" );
722cdf0e10cSrcweir 
723cdf0e10cSrcweir                     pPgDesc = &pDoc->GetPageDesc( 0 );
724cdf0e10cSrcweir                     pNd = 0;
725cdf0e10cSrcweir                 }
726cdf0e10cSrcweir             }
727cdf0e10cSrcweir         }
728cdf0e10cSrcweir 
729cdf0e10cSrcweir         if( pNd )
730cdf0e10cSrcweir         {
731cdf0e10cSrcweir             SwFindNearestNode aInfo( *pNd );
732cdf0e10cSrcweir             // dann ueber alle Nodes aller PageDesc
733cdf0e10cSrcweir             const SfxPoolItem* pItem;
734cdf0e10cSrcweir             sal_uInt32 i, nMaxItems = pDoc->GetAttrPool().GetItemCount2( RES_PAGEDESC );
735cdf0e10cSrcweir             for( i = 0; i < nMaxItems; ++i )
736cdf0e10cSrcweir                 if( 0 != (pItem = pDoc->GetAttrPool().GetItem2( RES_PAGEDESC, i ) ) &&
737cdf0e10cSrcweir                     ((SwFmtPageDesc*)pItem)->GetDefinedIn() )
738cdf0e10cSrcweir                 {
739cdf0e10cSrcweir                     const SwModify* pMod = ((SwFmtPageDesc*)pItem)->GetDefinedIn();
740cdf0e10cSrcweir                     if( pMod->ISA( SwCntntNode ) )
741cdf0e10cSrcweir                         aInfo.CheckNode( *(SwCntntNode*)pMod );
742cdf0e10cSrcweir                     else if( pMod->ISA( SwFmt ))
743cdf0e10cSrcweir                         ((SwFmt*)pMod)->GetInfo( aInfo );
744cdf0e10cSrcweir                 }
745cdf0e10cSrcweir 
746cdf0e10cSrcweir             if( 0 != ( pNd = aInfo.GetFoundNode() ))
747cdf0e10cSrcweir             {
748cdf0e10cSrcweir                 if( pNd->IsCntntNode() )
749cdf0e10cSrcweir                     pPgDesc = ((SwFmtPageDesc&)pNd->GetCntntNode()->
750cdf0e10cSrcweir                                 GetAttr( RES_PAGEDESC )).GetPageDesc();
751cdf0e10cSrcweir                 else if( pNd->IsTableNode() )
752cdf0e10cSrcweir                     pPgDesc = pNd->GetTableNode()->GetTable().
753cdf0e10cSrcweir                             GetFrmFmt()->GetPageDesc().GetPageDesc();
754cdf0e10cSrcweir                 else if( pNd->IsSectionNode() )
755cdf0e10cSrcweir                     pPgDesc = pNd->GetSectionNode()->GetSection().
756cdf0e10cSrcweir                             GetFmt()->GetPageDesc().GetPageDesc();
757cdf0e10cSrcweir                 // OD 18.03.2003 #106329#
758cdf0e10cSrcweir                 if ( pPgDescNdIdx )
759cdf0e10cSrcweir                 {
760cdf0e10cSrcweir                     *pPgDescNdIdx = pNd->GetIndex();
761cdf0e10cSrcweir                 }
762cdf0e10cSrcweir             }
763cdf0e10cSrcweir             if( !pPgDesc )
764cdf0e10cSrcweir                 pPgDesc = &pDoc->GetPageDesc( 0 );
765cdf0e10cSrcweir         }
766cdf0e10cSrcweir     }
767cdf0e10cSrcweir 	return pPgDesc;
768cdf0e10cSrcweir }
769cdf0e10cSrcweir 
770cdf0e10cSrcweir 
771cdf0e10cSrcweir 	// falls der Node in einem Fly steht, dann wird das entsprechende Format
772cdf0e10cSrcweir 	// returnt
GetFlyFmt() const773cdf0e10cSrcweir SwFrmFmt* SwNode::GetFlyFmt() const
774cdf0e10cSrcweir {
775cdf0e10cSrcweir 	SwFrmFmt* pRet = 0;
776cdf0e10cSrcweir 	const SwNode* pSttNd = FindFlyStartNode();
777cdf0e10cSrcweir 	if( pSttNd )
778cdf0e10cSrcweir 	{
779cdf0e10cSrcweir 		if( IsCntntNode() )
780cdf0e10cSrcweir 		{
781cdf0e10cSrcweir 			SwCntntFrm* pFrm = SwIterator<SwCntntFrm,SwCntntNode>::FirstElement( *(SwCntntNode*)this );
782cdf0e10cSrcweir 			if( pFrm )
783cdf0e10cSrcweir 				pRet = pFrm->FindFlyFrm()->GetFmt();
784cdf0e10cSrcweir 		}
785cdf0e10cSrcweir 		if( !pRet )
786cdf0e10cSrcweir 		{
787cdf0e10cSrcweir 			// dann gibts noch harten steinigen Weg uebers Dokument:
788cdf0e10cSrcweir 			const SwSpzFrmFmts& rFrmFmtTbl = *GetDoc()->GetSpzFrmFmts();
789cdf0e10cSrcweir 			for( sal_uInt16 n = 0; n < rFrmFmtTbl.Count(); ++n )
790cdf0e10cSrcweir 			{
791cdf0e10cSrcweir 				SwFrmFmt* pFmt = rFrmFmtTbl[n];
792cdf0e10cSrcweir 				const SwFmtCntnt& rCntnt = pFmt->GetCntnt();
793cdf0e10cSrcweir 				if( rCntnt.GetCntntIdx() &&
794cdf0e10cSrcweir 					&rCntnt.GetCntntIdx()->GetNode() == pSttNd )
795cdf0e10cSrcweir 				{
796cdf0e10cSrcweir 					pRet = pFmt;
797cdf0e10cSrcweir 					break;
798cdf0e10cSrcweir 				}
799cdf0e10cSrcweir 			}
800cdf0e10cSrcweir 		}
801cdf0e10cSrcweir 	}
802cdf0e10cSrcweir 	return pRet;
803cdf0e10cSrcweir }
804cdf0e10cSrcweir 
GetTblBox() const805cdf0e10cSrcweir SwTableBox* SwNode::GetTblBox() const
806cdf0e10cSrcweir {
807cdf0e10cSrcweir 	SwTableBox* pBox = 0;
808cdf0e10cSrcweir 	const SwNode* pSttNd = FindTableBoxStartNode();
809cdf0e10cSrcweir 	if( pSttNd )
810cdf0e10cSrcweir 		pBox = (SwTableBox*)pSttNd->FindTableNode()->GetTable().GetTblBox(
811cdf0e10cSrcweir 													pSttNd->GetIndex() );
812cdf0e10cSrcweir 	return pBox;
813cdf0e10cSrcweir }
814cdf0e10cSrcweir 
FindSttNodeByType(SwStartNodeType eTyp)815cdf0e10cSrcweir SwStartNode* SwNode::FindSttNodeByType( SwStartNodeType eTyp )
816cdf0e10cSrcweir {
817cdf0e10cSrcweir 	SwStartNode* pTmp = IsStartNode() ? (SwStartNode*)this : pStartOfSection;
818cdf0e10cSrcweir 
819cdf0e10cSrcweir 	while( eTyp != pTmp->GetStartNodeType() && pTmp->GetIndex() )
820cdf0e10cSrcweir #if defined( ALPHA ) && defined( UNX )
821cdf0e10cSrcweir 		pTmp = ((SwNode*)pTmp)->pStartOfSection;
822cdf0e10cSrcweir #else
823cdf0e10cSrcweir 		pTmp = pTmp->pStartOfSection;
824cdf0e10cSrcweir #endif
825cdf0e10cSrcweir 	return eTyp == pTmp->GetStartNodeType() ? pTmp : 0;
826cdf0e10cSrcweir }
827cdf0e10cSrcweir 
FindOutlineNodeOfLevel(sal_uInt8 nLvl) const828cdf0e10cSrcweir const SwTxtNode* SwNode::FindOutlineNodeOfLevel( sal_uInt8 nLvl ) const
829cdf0e10cSrcweir {
830cdf0e10cSrcweir 	const SwTxtNode* pRet = 0;
831cdf0e10cSrcweir 	const SwOutlineNodes& rONds = GetNodes().GetOutLineNds();
832cdf0e10cSrcweir 	if( MAXLEVEL > nLvl && rONds.Count() )
833cdf0e10cSrcweir 	{
834cdf0e10cSrcweir 		sal_uInt16 nPos;
835cdf0e10cSrcweir 		SwNode* pNd = (SwNode*)this;
836cdf0e10cSrcweir 		sal_Bool bCheckFirst = sal_False;
837cdf0e10cSrcweir 		if( !rONds.Seek_Entry( pNd, &nPos ))
838cdf0e10cSrcweir 		{
839cdf0e10cSrcweir 			if( nPos )
840cdf0e10cSrcweir 				nPos = nPos-1;
841cdf0e10cSrcweir 			else
842cdf0e10cSrcweir 				bCheckFirst = sal_True;
843cdf0e10cSrcweir 		}
844cdf0e10cSrcweir 
845cdf0e10cSrcweir 		if( bCheckFirst )
846cdf0e10cSrcweir 		{
847cdf0e10cSrcweir 			// der 1.GliederungsNode liegt hinter dem Fragenden. Dann
848cdf0e10cSrcweir 			// teste mal, ob dieser auf der gleichen Seite steht. Wenn
849cdf0e10cSrcweir 			// nicht, ist das ein ungueltiger. Bug 61865
850cdf0e10cSrcweir 			pRet = rONds[0]->GetTxtNode();
851cdf0e10cSrcweir 
852cdf0e10cSrcweir 			const SwCntntNode* pCNd = GetCntntNode();
853cdf0e10cSrcweir 
854cdf0e10cSrcweir 			Point aPt( 0, 0 );
855cdf0e10cSrcweir 			const SwFrm* pFrm = pRet->getLayoutFrm( pRet->GetDoc()->GetCurrentLayout(), &aPt, 0, sal_False ),
856cdf0e10cSrcweir 					   * pMyFrm = pCNd ? pCNd->getLayoutFrm( pCNd->GetDoc()->GetCurrentLayout(), &aPt, 0, sal_False ) : 0;
857cdf0e10cSrcweir 			const SwPageFrm* pPgFrm = pFrm ? pFrm->FindPageFrm() : 0;
858cdf0e10cSrcweir 			if( pPgFrm && pMyFrm &&
859cdf0e10cSrcweir 				pPgFrm->Frm().Top() > pMyFrm->Frm().Top() )
860cdf0e10cSrcweir 			{
861cdf0e10cSrcweir 				// der Fragende liegt vor der Seite, also ist er ungueltig
862cdf0e10cSrcweir 				pRet = 0;
863cdf0e10cSrcweir 			}
864cdf0e10cSrcweir 		}
865cdf0e10cSrcweir 		else
866cdf0e10cSrcweir 		{
867cdf0e10cSrcweir 			// oder ans Feld und von dort holen !!
868cdf0e10cSrcweir             while( nPos &&
869cdf0e10cSrcweir                    nLvl < ( pRet = rONds[nPos]->GetTxtNode() )
870cdf0e10cSrcweir 					//->GetTxtColl()->GetOutlineLevel() )//#outline level,zhaojianwei
871cdf0e10cSrcweir                     ->GetAttrOutlineLevel() - 1 )  //<-end,zhaojianwei
872cdf0e10cSrcweir 				--nPos;
873cdf0e10cSrcweir 
874cdf0e10cSrcweir 			if( !nPos )		// bei 0 gesondert holen !!
875cdf0e10cSrcweir 				pRet = rONds[0]->GetTxtNode();
876cdf0e10cSrcweir 		}
877cdf0e10cSrcweir 	}
878cdf0e10cSrcweir 	return pRet;
879cdf0e10cSrcweir }
880cdf0e10cSrcweir 
IsValidNextPrevNd(const SwNode & rNd)881cdf0e10cSrcweir inline sal_Bool IsValidNextPrevNd( const SwNode& rNd )
882cdf0e10cSrcweir {
883cdf0e10cSrcweir 	return ND_TABLENODE == rNd.GetNodeType() ||
884cdf0e10cSrcweir            ( ND_CONTENTNODE & rNd.GetNodeType() ) ||
885cdf0e10cSrcweir 			( ND_ENDNODE == rNd.GetNodeType() && rNd.StartOfSectionNode() &&
886cdf0e10cSrcweir             ND_TABLENODE == rNd.StartOfSectionNode()->GetNodeType() );
887cdf0e10cSrcweir }
888cdf0e10cSrcweir 
HasPrevNextLayNode() const889cdf0e10cSrcweir sal_uInt8 SwNode::HasPrevNextLayNode() const
890cdf0e10cSrcweir {
891cdf0e10cSrcweir     // assumption: <this> node is a node inside the document nodes array section.
892cdf0e10cSrcweir 
893cdf0e10cSrcweir 	sal_uInt8 nRet = 0;
894cdf0e10cSrcweir 	if( IsValidNextPrevNd( *this ))
895cdf0e10cSrcweir 	{
896cdf0e10cSrcweir 		SwNodeIndex aIdx( *this, -1 );
897cdf0e10cSrcweir         // --> OD 2007-06-04 #i77805#
898cdf0e10cSrcweir         // skip section start and end nodes
899cdf0e10cSrcweir         while ( aIdx.GetNode().IsSectionNode() ||
900cdf0e10cSrcweir                 ( aIdx.GetNode().IsEndNode() &&
901cdf0e10cSrcweir                   aIdx.GetNode().StartOfSectionNode()->IsSectionNode() ) )
902cdf0e10cSrcweir         {
903cdf0e10cSrcweir             --aIdx;
904cdf0e10cSrcweir         }
905cdf0e10cSrcweir         // <--
906cdf0e10cSrcweir 		if( IsValidNextPrevNd( aIdx.GetNode() ))
907cdf0e10cSrcweir 			nRet |= ND_HAS_PREV_LAYNODE;
908cdf0e10cSrcweir         // --> OD 2007-06-04 #i77805#
909cdf0e10cSrcweir         // skip section start and end nodes
910cdf0e10cSrcweir //        aIdx += 2;
911cdf0e10cSrcweir         aIdx = SwNodeIndex( *this, +1 );
912cdf0e10cSrcweir         while ( aIdx.GetNode().IsSectionNode() ||
913cdf0e10cSrcweir                 ( aIdx.GetNode().IsEndNode() &&
914cdf0e10cSrcweir                   aIdx.GetNode().StartOfSectionNode()->IsSectionNode() ) )
915cdf0e10cSrcweir         {
916cdf0e10cSrcweir             ++aIdx;
917cdf0e10cSrcweir         }
918cdf0e10cSrcweir         // <--
919cdf0e10cSrcweir         if( IsValidNextPrevNd( aIdx.GetNode() ))
920cdf0e10cSrcweir 			nRet |= ND_HAS_NEXT_LAYNODE;
921cdf0e10cSrcweir 	}
922cdf0e10cSrcweir 	return nRet;
923cdf0e10cSrcweir }
924cdf0e10cSrcweir 
925cdf0e10cSrcweir /*******************************************************************
926cdf0e10cSrcweir |*
927cdf0e10cSrcweir |*	SwNode::StartOfSection
928cdf0e10cSrcweir |*
929cdf0e10cSrcweir |*	Beschreibung
930cdf0e10cSrcweir |*		Die Funktion liefert die StartOfSection des Nodes.
931cdf0e10cSrcweir |*
932cdf0e10cSrcweir |*	Parameter
933cdf0e10cSrcweir |*		IN
934cdf0e10cSrcweir |*		rNodes bezeichnet das variable Array, in dem sich der Node
935cdf0e10cSrcweir |*		befindet
936cdf0e10cSrcweir |*	Ersterstellung
937cdf0e10cSrcweir |*		VER0100 vb 901214
938cdf0e10cSrcweir |*
939cdf0e10cSrcweir |*	Stand
940cdf0e10cSrcweir |*		VER0100 vb 901214
941cdf0e10cSrcweir |*
942cdf0e10cSrcweir *******************************************************************/
943cdf0e10cSrcweir 
944cdf0e10cSrcweir 
SwStartNode(const SwNodeIndex & rWhere,const sal_uInt8 nNdType,SwStartNodeType eSttNd)945cdf0e10cSrcweir SwStartNode::SwStartNode( const SwNodeIndex &rWhere, const sal_uInt8 nNdType,
946cdf0e10cSrcweir 							SwStartNodeType eSttNd )
947cdf0e10cSrcweir 	: SwNode( rWhere, nNdType ), eSttNdTyp( eSttNd )
948cdf0e10cSrcweir {
949cdf0e10cSrcweir 	// erstmal temporaer, bis der EndNode eingefuegt wird.
950cdf0e10cSrcweir 	pEndOfSection = (SwEndNode*)this;
951cdf0e10cSrcweir }
952cdf0e10cSrcweir 
SwStartNode(SwNodes & rNodes,sal_uLong nPos)953cdf0e10cSrcweir SwStartNode::SwStartNode( SwNodes& rNodes, sal_uLong nPos )
954cdf0e10cSrcweir 	: SwNode( rNodes, nPos, ND_STARTNODE ), eSttNdTyp( SwNormalStartNode )
955cdf0e10cSrcweir {
956cdf0e10cSrcweir 	// erstmal temporaer, bis der EndNode eingefuegt wird.
957cdf0e10cSrcweir 	pEndOfSection = (SwEndNode*)this;
958cdf0e10cSrcweir }
959cdf0e10cSrcweir 
960cdf0e10cSrcweir 
CheckSectionCondColl() const961cdf0e10cSrcweir void SwStartNode::CheckSectionCondColl() const
962cdf0e10cSrcweir {
963cdf0e10cSrcweir //FEATURE::CONDCOLL
964cdf0e10cSrcweir 	SwNodeIndex aIdx( *this );
965cdf0e10cSrcweir 	sal_uLong nEndIdx = EndOfSectionIndex();
966cdf0e10cSrcweir 	const SwNodes& rNds = GetNodes();
967cdf0e10cSrcweir 	SwCntntNode* pCNd;
968cdf0e10cSrcweir 	while( 0 != ( pCNd = rNds.GoNext( &aIdx )) && pCNd->GetIndex() < nEndIdx )
969cdf0e10cSrcweir 		pCNd->ChkCondColl();
970cdf0e10cSrcweir //FEATURE::CONDCOLL
971cdf0e10cSrcweir }
972cdf0e10cSrcweir 
973cdf0e10cSrcweir /*******************************************************************
974cdf0e10cSrcweir |*
975cdf0e10cSrcweir |*	SwEndNode::SwEndNode
976cdf0e10cSrcweir |*
977cdf0e10cSrcweir |*	Beschreibung
978cdf0e10cSrcweir |*		Konstruktor; dieser fuegt einen Node in das Array rNodes
979cdf0e10cSrcweir |*		an der Position aWhere ein. Der
980cdf0e10cSrcweir |*		theStartOfSection-Pointer wird entsprechend gesetzt,
981cdf0e10cSrcweir |*		und der EndOfSection-Pointer des zugehoerigen
982cdf0e10cSrcweir |*		Startnodes -- durch rStartOfSection bezeichnet --
983cdf0e10cSrcweir |*		wird auf diesen Node gesetzt.
984cdf0e10cSrcweir |*
985cdf0e10cSrcweir |*	Parameter
986cdf0e10cSrcweir |*		IN
987cdf0e10cSrcweir |*		rNodes bezeichnet das variable Array, in das der Node
988cdf0e10cSrcweir |*		eingefuegt werden soll
989cdf0e10cSrcweir |*		IN
990cdf0e10cSrcweir |*		aWhere bezeichnet die Position innerhalb dieses Arrays,
991cdf0e10cSrcweir |*		an der der Node eingefuegt werden soll
992cdf0e10cSrcweir |*		!!!!!!!!!!!!
993cdf0e10cSrcweir |*		Es wird eine Kopie uebergeben!
994cdf0e10cSrcweir |*
995cdf0e10cSrcweir |*	Ersterstellung
996cdf0e10cSrcweir |*		VER0100 vb 901214
997cdf0e10cSrcweir |*
998cdf0e10cSrcweir |*	Stand
999cdf0e10cSrcweir |*		VER0100 vb 901214
1000cdf0e10cSrcweir |*
1001cdf0e10cSrcweir *******************************************************************/
1002cdf0e10cSrcweir 
1003cdf0e10cSrcweir 
SwEndNode(const SwNodeIndex & rWhere,SwStartNode & rSttNd)1004cdf0e10cSrcweir SwEndNode::SwEndNode( const SwNodeIndex &rWhere, SwStartNode& rSttNd )
1005cdf0e10cSrcweir 	: SwNode( rWhere, ND_ENDNODE )
1006cdf0e10cSrcweir {
1007cdf0e10cSrcweir 	pStartOfSection = &rSttNd;
1008cdf0e10cSrcweir 	pStartOfSection->pEndOfSection = this;
1009cdf0e10cSrcweir }
1010cdf0e10cSrcweir 
SwEndNode(SwNodes & rNds,sal_uLong nPos,SwStartNode & rSttNd)1011cdf0e10cSrcweir SwEndNode::SwEndNode( SwNodes& rNds, sal_uLong nPos, SwStartNode& rSttNd )
1012cdf0e10cSrcweir 	: SwNode( rNds, nPos, ND_ENDNODE )
1013cdf0e10cSrcweir {
1014cdf0e10cSrcweir 	pStartOfSection = &rSttNd;
1015cdf0e10cSrcweir 	pStartOfSection->pEndOfSection = this;
1016cdf0e10cSrcweir }
1017cdf0e10cSrcweir 
1018cdf0e10cSrcweir 
1019cdf0e10cSrcweir 
1020cdf0e10cSrcweir // --------------------
1021cdf0e10cSrcweir // SwCntntNode
1022cdf0e10cSrcweir // --------------------
1023cdf0e10cSrcweir 
1024cdf0e10cSrcweir 
SwCntntNode(const SwNodeIndex & rWhere,const sal_uInt8 nNdType,SwFmtColl * pColl)1025cdf0e10cSrcweir SwCntntNode::SwCntntNode( const SwNodeIndex &rWhere, const sal_uInt8 nNdType,
1026cdf0e10cSrcweir 							SwFmtColl *pColl )
1027cdf0e10cSrcweir 	: SwModify( pColl ),	 // CrsrsShell, FrameFmt,
1028cdf0e10cSrcweir     SwNode( rWhere, nNdType ),
1029cdf0e10cSrcweir     pCondColl( 0 ),
1030cdf0e10cSrcweir     mbSetModifyAtAttr( false )
1031cdf0e10cSrcweir #ifdef OLD_INDEX
1032cdf0e10cSrcweir 	,SwIndexReg(2)
1033cdf0e10cSrcweir #endif
1034cdf0e10cSrcweir {
1035cdf0e10cSrcweir }
1036cdf0e10cSrcweir 
1037cdf0e10cSrcweir 
~SwCntntNode()1038cdf0e10cSrcweir SwCntntNode::~SwCntntNode()
1039cdf0e10cSrcweir {
1040cdf0e10cSrcweir 	// Die Basisklasse SwClient vom SwFrm nimmt sich aus
1041cdf0e10cSrcweir 	// der Abhaengikeitsliste raus!
1042cdf0e10cSrcweir 	// Daher muessen alle Frames in der Abhaengigkeitsliste geloescht werden.
1043cdf0e10cSrcweir 	if( GetDepends() )
1044ca62e2c2SSteve Yin 		DelFrms(sal_True, sal_False);
1045cdf0e10cSrcweir 
1046cdf0e10cSrcweir     if( pCondColl )
1047cdf0e10cSrcweir 		delete pCondColl;
1048cdf0e10cSrcweir 
1049cdf0e10cSrcweir     if ( mpAttrSet.get() && mbSetModifyAtAttr )
1050cdf0e10cSrcweir         ((SwAttrSet*)mpAttrSet.get())->SetModifyAtAttr( 0 );
1051cdf0e10cSrcweir }
1052cdf0e10cSrcweir 
Modify(const SfxPoolItem * pOldValue,const SfxPoolItem * pNewValue)1053cdf0e10cSrcweir void SwCntntNode::Modify( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue )
1054cdf0e10cSrcweir {
1055cdf0e10cSrcweir 	sal_uInt16 nWhich = pOldValue ? pOldValue->Which() :
1056cdf0e10cSrcweir 					pNewValue ? pNewValue->Which() : 0 ;
1057cdf0e10cSrcweir 
1058cdf0e10cSrcweir 	switch( nWhich )
1059cdf0e10cSrcweir 	{
1060cdf0e10cSrcweir 	case RES_OBJECTDYING :
1061cdf0e10cSrcweir 		{
1062cdf0e10cSrcweir 			SwFmt * pFmt = (SwFmt *) ((SwPtrMsgPoolItem *)pNewValue)->pObject;
1063cdf0e10cSrcweir 
1064cdf0e10cSrcweir 			// nicht umhaengen wenn dieses das oberste Format ist !!
1065cdf0e10cSrcweir 			if( GetRegisteredIn() == pFmt )
1066cdf0e10cSrcweir 			{
1067cdf0e10cSrcweir 				if( pFmt->GetRegisteredIn() )
1068cdf0e10cSrcweir 				{
1069cdf0e10cSrcweir 					// wenn Parent, dann im neuen Parent wieder anmelden
1070cdf0e10cSrcweir 					((SwModify*)pFmt->GetRegisteredIn())->Add( this );
1071cdf0e10cSrcweir                     if ( GetpSwAttrSet() )
1072cdf0e10cSrcweir                         AttrSetHandleHelper::SetParent( mpAttrSet, *this, GetFmtColl(), GetFmtColl() );
1073cdf0e10cSrcweir 				}
1074cdf0e10cSrcweir 				else
1075cdf0e10cSrcweir 				{
1076cdf0e10cSrcweir 					// sonst auf jeden Fall beim sterbenden abmelden
1077cdf0e10cSrcweir 					((SwModify*)GetRegisteredIn())->Remove( this );
1078cdf0e10cSrcweir                     if ( GetpSwAttrSet() )
1079cdf0e10cSrcweir                         AttrSetHandleHelper::SetParent( mpAttrSet, *this, 0, 0 );
1080cdf0e10cSrcweir 				}
1081cdf0e10cSrcweir 			}
1082cdf0e10cSrcweir 		}
1083cdf0e10cSrcweir 		break;
1084cdf0e10cSrcweir 
1085cdf0e10cSrcweir 
1086cdf0e10cSrcweir 	case RES_FMT_CHG:
1087cdf0e10cSrcweir 		// falls mein Format Parent umgesetzt wird, dann melde ich
1088cdf0e10cSrcweir 		// meinen Attrset beim Neuen an.
1089cdf0e10cSrcweir 
1090cdf0e10cSrcweir 		// sein eigenes Modify ueberspringen !!
1091cdf0e10cSrcweir         if( GetpSwAttrSet() &&
1092cdf0e10cSrcweir 			((SwFmtChg*)pNewValue)->pChangedFmt == GetRegisteredIn() )
1093cdf0e10cSrcweir 		{
1094cdf0e10cSrcweir 			// den Set an den neuen Parent haengen
1095cdf0e10cSrcweir             AttrSetHandleHelper::SetParent( mpAttrSet, *this, GetFmtColl(), GetFmtColl() );
1096cdf0e10cSrcweir 		}
1097cdf0e10cSrcweir 		break;
1098cdf0e10cSrcweir //FEATURE::CONDCOLL
1099cdf0e10cSrcweir 	case RES_CONDCOLL_CONDCHG:
1100cdf0e10cSrcweir 		if( ((SwCondCollCondChg*)pNewValue)->pChangedFmt == GetRegisteredIn() &&
1101cdf0e10cSrcweir 			&GetNodes() == &GetDoc()->GetNodes() )
1102cdf0e10cSrcweir 		{
1103cdf0e10cSrcweir 			ChkCondColl();
1104cdf0e10cSrcweir 		}
1105cdf0e10cSrcweir 		return ;	// nicht an die Basisklasse / Frames weitergeben
1106cdf0e10cSrcweir //FEATURE::CONDCOLL
1107cdf0e10cSrcweir 
1108cdf0e10cSrcweir 	case RES_ATTRSET_CHG:
1109cdf0e10cSrcweir 		if( GetNodes().IsDocNodes() && IsTxtNode() )
1110cdf0e10cSrcweir 		{
1111cdf0e10cSrcweir             if( SFX_ITEM_SET == ((SwAttrSetChg*)pOldValue)->GetChgSet()->GetItemState(
1112cdf0e10cSrcweir                 RES_CHRATR_HIDDEN, sal_False ) )
1113cdf0e10cSrcweir             {
1114cdf0e10cSrcweir                 ((SwTxtNode*)this)->SetCalcHiddenCharFlags();
1115cdf0e10cSrcweir             }
1116cdf0e10cSrcweir 		}
1117cdf0e10cSrcweir 		break;
1118cdf0e10cSrcweir 
1119cdf0e10cSrcweir     case RES_UPDATE_ATTR:
1120cdf0e10cSrcweir 		if( GetNodes().IsDocNodes() && IsTxtNode() )
1121cdf0e10cSrcweir         {
1122cdf0e10cSrcweir             const sal_uInt16 nTmp = ((SwUpdateAttr*)pNewValue)->nWhichAttr;
1123cdf0e10cSrcweir             if ( RES_ATTRSET_CHG == nTmp )
1124cdf0e10cSrcweir             {
1125cdf0e10cSrcweir                 // anybody wants to do some optimization here?
1126cdf0e10cSrcweir                 ((SwTxtNode*)this)->SetCalcHiddenCharFlags();
1127cdf0e10cSrcweir             }
1128cdf0e10cSrcweir         }
1129cdf0e10cSrcweir         break;
1130cdf0e10cSrcweir 	}
1131cdf0e10cSrcweir 
1132cdf0e10cSrcweir 	NotifyClients( pOldValue, pNewValue );
1133cdf0e10cSrcweir }
1134cdf0e10cSrcweir 
InvalidateNumRule()1135cdf0e10cSrcweir sal_Bool SwCntntNode::InvalidateNumRule()
1136cdf0e10cSrcweir {
1137cdf0e10cSrcweir 	SwNumRule* pRule = 0;
1138cdf0e10cSrcweir 	const SfxPoolItem* pItem;
1139cdf0e10cSrcweir 	if( GetNodes().IsDocNodes() &&
1140cdf0e10cSrcweir 		0 != ( pItem = GetNoCondAttr( RES_PARATR_NUMRULE, sal_True )) &&
1141cdf0e10cSrcweir 		((SwNumRuleItem*)pItem)->GetValue().Len() &&
1142cdf0e10cSrcweir 		0 != (pRule = GetDoc()->FindNumRulePtr(
1143cdf0e10cSrcweir 								((SwNumRuleItem*)pItem)->GetValue() ) ) )
1144cdf0e10cSrcweir 	{
1145cdf0e10cSrcweir 		pRule->SetInvalidRule( sal_True );
1146cdf0e10cSrcweir 	}
1147cdf0e10cSrcweir 	return 0 != pRule;
1148cdf0e10cSrcweir }
1149cdf0e10cSrcweir 
getLayoutFrm(const SwRootFrm * _pRoot,const Point * pPoint,const SwPosition * pPos,const sal_Bool bCalcFrm) const1150cdf0e10cSrcweir SwCntntFrm *SwCntntNode::getLayoutFrm( const SwRootFrm* _pRoot,
1151cdf0e10cSrcweir     const Point* pPoint, const SwPosition *pPos, const sal_Bool bCalcFrm ) const
1152cdf0e10cSrcweir {
1153cdf0e10cSrcweir 	return (SwCntntFrm*) ::GetFrmOfModify( _pRoot, *(SwModify*)this, FRM_CNTNT,
1154cdf0e10cSrcweir 											pPoint, pPos, bCalcFrm );
1155cdf0e10cSrcweir }
1156cdf0e10cSrcweir 
FindLayoutRect(const sal_Bool bPrtArea,const Point * pPoint,const sal_Bool bCalcFrm) const1157cdf0e10cSrcweir SwRect SwCntntNode::FindLayoutRect( const sal_Bool bPrtArea, const Point* pPoint,
1158cdf0e10cSrcweir 									const sal_Bool bCalcFrm ) const
1159cdf0e10cSrcweir {
1160cdf0e10cSrcweir 	SwRect aRet;
1161cdf0e10cSrcweir 	SwCntntFrm* pFrm = (SwCntntFrm*)::GetFrmOfModify( 0, *(SwModify*)this,
1162cdf0e10cSrcweir 											FRM_CNTNT, pPoint, 0, bCalcFrm );
1163cdf0e10cSrcweir 	if( pFrm )
1164cdf0e10cSrcweir 		aRet = bPrtArea ? pFrm->Prt() : pFrm->Frm();
1165cdf0e10cSrcweir 	return aRet;
1166cdf0e10cSrcweir }
1167cdf0e10cSrcweir 
FindPageFrmRect(const sal_Bool bPrtArea,const Point * pPoint,const sal_Bool bCalcFrm) const1168cdf0e10cSrcweir SwRect SwCntntNode::FindPageFrmRect( const sal_Bool bPrtArea, const Point* pPoint,
1169cdf0e10cSrcweir 									const sal_Bool bCalcFrm ) const
1170cdf0e10cSrcweir {
1171cdf0e10cSrcweir 	SwRect aRet;
1172cdf0e10cSrcweir 	SwFrm* pFrm = ::GetFrmOfModify( 0, *(SwModify*)this,
1173cdf0e10cSrcweir 											FRM_CNTNT, pPoint, 0, bCalcFrm );
1174cdf0e10cSrcweir 	if( pFrm && 0 != ( pFrm = pFrm->FindPageFrm() ))
1175cdf0e10cSrcweir 		aRet = bPrtArea ? pFrm->Prt() : pFrm->Frm();
1176cdf0e10cSrcweir 	return aRet;
1177cdf0e10cSrcweir }
1178cdf0e10cSrcweir 
Len() const1179cdf0e10cSrcweir xub_StrLen SwCntntNode::Len() const { return 0; }
1180cdf0e10cSrcweir 
1181cdf0e10cSrcweir 
1182cdf0e10cSrcweir 
ChgFmtColl(SwFmtColl * pNewColl)1183cdf0e10cSrcweir SwFmtColl *SwCntntNode::ChgFmtColl( SwFmtColl *pNewColl )
1184cdf0e10cSrcweir {
1185cdf0e10cSrcweir 	ASSERT( pNewColl, "Collectionpointer ist 0." );
1186cdf0e10cSrcweir 	SwFmtColl *pOldColl = GetFmtColl();
1187cdf0e10cSrcweir 
1188cdf0e10cSrcweir 	if( pNewColl != pOldColl )
1189cdf0e10cSrcweir 	{
1190cdf0e10cSrcweir 		pNewColl->Add( this );
1191cdf0e10cSrcweir 
1192cdf0e10cSrcweir 		// setze den Parent von unseren Auto-Attributen auf die neue
1193cdf0e10cSrcweir 		// Collection:
1194cdf0e10cSrcweir         if( GetpSwAttrSet() )
1195cdf0e10cSrcweir             AttrSetHandleHelper::SetParent( mpAttrSet, *this, pNewColl, pNewColl );
1196cdf0e10cSrcweir 
1197cdf0e10cSrcweir //FEATURE::CONDCOLL
1198cdf0e10cSrcweir 		// HACK: hier muss die entsprechend der neuen Vorlage die Bedingungen
1199cdf0e10cSrcweir 		//		neu ueberprueft werden!
1200cdf0e10cSrcweir 		if( sal_True /*pNewColl */ )
1201cdf0e10cSrcweir 		{
1202cdf0e10cSrcweir 			SetCondFmtColl( 0 );
1203cdf0e10cSrcweir 		}
1204cdf0e10cSrcweir //FEATURE::CONDCOLL
1205cdf0e10cSrcweir 
1206cdf0e10cSrcweir 		if( !IsModifyLocked() )
1207cdf0e10cSrcweir 		{
1208cdf0e10cSrcweir 			SwFmtChg aTmp1( pOldColl );
1209cdf0e10cSrcweir 			SwFmtChg aTmp2( pNewColl );
1210cdf0e10cSrcweir             SwCntntNode::Modify( &aTmp1, &aTmp2 );
1211cdf0e10cSrcweir 		}
1212cdf0e10cSrcweir 	}
1213cdf0e10cSrcweir 	if ( IsInCache() )
1214cdf0e10cSrcweir 	{
1215cdf0e10cSrcweir 		SwFrm::GetCache().Delete( this );
1216cdf0e10cSrcweir 		SetInCache( sal_False );
1217cdf0e10cSrcweir 	}
1218cdf0e10cSrcweir 	return pOldColl;
1219cdf0e10cSrcweir }
1220cdf0e10cSrcweir 
1221cdf0e10cSrcweir 
GoNext(SwIndex * pIdx,sal_uInt16 nMode) const1222cdf0e10cSrcweir sal_Bool SwCntntNode::GoNext(SwIndex * pIdx, sal_uInt16 nMode ) const
1223cdf0e10cSrcweir {
1224cdf0e10cSrcweir 	sal_Bool bRet = sal_True;
1225cdf0e10cSrcweir 	if( pIdx->GetIndex() < Len() )
1226cdf0e10cSrcweir 	{
1227cdf0e10cSrcweir 		if( !IsTxtNode() )
1228cdf0e10cSrcweir 			(*pIdx)++;
1229cdf0e10cSrcweir 		else
1230cdf0e10cSrcweir 		{
1231cdf0e10cSrcweir 			const SwTxtNode& rTNd = *GetTxtNode();
1232cdf0e10cSrcweir 			xub_StrLen nPos = pIdx->GetIndex();
1233cdf0e10cSrcweir 			if( pBreakIt->GetBreakIter().is() )
1234cdf0e10cSrcweir 			{
1235cdf0e10cSrcweir 				sal_Int32 nDone = 0;
1236cdf0e10cSrcweir 				sal_uInt16 nItrMode = ( CRSR_SKIP_CELLS & nMode ) ?
1237cdf0e10cSrcweir                                         CharacterIteratorMode::SKIPCELL :
1238cdf0e10cSrcweir                                         CharacterIteratorMode::SKIPCONTROLCHARACTER;
1239cdf0e10cSrcweir                 nPos = (xub_StrLen)pBreakIt->GetBreakIter()->nextCharacters( rTNd.GetTxt(), nPos,
1240cdf0e10cSrcweir                                    pBreakIt->GetLocale( rTNd.GetLang( nPos ) ),
1241cdf0e10cSrcweir                                    nItrMode, 1, nDone );
1242cdf0e10cSrcweir 
1243cdf0e10cSrcweir                 // Check if nPos is inside hidden text range:
1244cdf0e10cSrcweir                 if ( CRSR_SKIP_HIDDEN & nMode )
1245cdf0e10cSrcweir                 {
1246cdf0e10cSrcweir                     xub_StrLen nHiddenStart;
1247cdf0e10cSrcweir                     xub_StrLen nHiddenEnd;
1248cdf0e10cSrcweir                     SwScriptInfo::GetBoundsOfHiddenRange( rTNd, nPos, nHiddenStart, nHiddenEnd );
1249cdf0e10cSrcweir                     if ( nHiddenStart != STRING_LEN && nHiddenStart != nPos )
1250cdf0e10cSrcweir                          nPos = nHiddenEnd;
1251cdf0e10cSrcweir                 }
1252cdf0e10cSrcweir 
1253cdf0e10cSrcweir 				if( 1 == nDone )
1254cdf0e10cSrcweir 					*pIdx = nPos;
1255cdf0e10cSrcweir 				else
1256cdf0e10cSrcweir 					bRet = sal_False;
1257cdf0e10cSrcweir 			}
1258cdf0e10cSrcweir 			else if( nPos < rTNd.GetTxt().Len() )
1259cdf0e10cSrcweir 				(*pIdx)++;
1260cdf0e10cSrcweir 			else
1261cdf0e10cSrcweir 				bRet = sal_False;
1262cdf0e10cSrcweir 		}
1263cdf0e10cSrcweir 	}
1264cdf0e10cSrcweir 	else
1265cdf0e10cSrcweir 		bRet = sal_False;
1266cdf0e10cSrcweir 	return bRet;
1267cdf0e10cSrcweir }
1268cdf0e10cSrcweir 
1269cdf0e10cSrcweir 
GoPrevious(SwIndex * pIdx,sal_uInt16 nMode) const1270cdf0e10cSrcweir sal_Bool SwCntntNode::GoPrevious(SwIndex * pIdx, sal_uInt16 nMode ) const
1271cdf0e10cSrcweir {
1272cdf0e10cSrcweir 	sal_Bool bRet = sal_True;
1273cdf0e10cSrcweir 	if( pIdx->GetIndex() > 0 )
1274cdf0e10cSrcweir 	{
1275cdf0e10cSrcweir 		if( !IsTxtNode() )
1276cdf0e10cSrcweir 			(*pIdx)--;
1277cdf0e10cSrcweir 		else
1278cdf0e10cSrcweir 		{
1279cdf0e10cSrcweir 			const SwTxtNode& rTNd = *GetTxtNode();
1280cdf0e10cSrcweir 			xub_StrLen nPos = pIdx->GetIndex();
1281cdf0e10cSrcweir 			if( pBreakIt->GetBreakIter().is() )
1282cdf0e10cSrcweir 			{
1283cdf0e10cSrcweir 				sal_Int32 nDone = 0;
1284cdf0e10cSrcweir 				sal_uInt16 nItrMode = ( CRSR_SKIP_CELLS & nMode ) ?
1285cdf0e10cSrcweir                                         CharacterIteratorMode::SKIPCELL :
1286cdf0e10cSrcweir                                         CharacterIteratorMode::SKIPCONTROLCHARACTER;
1287cdf0e10cSrcweir                 nPos = (xub_StrLen)pBreakIt->GetBreakIter()->previousCharacters( rTNd.GetTxt(), nPos,
1288cdf0e10cSrcweir                                    pBreakIt->GetLocale( rTNd.GetLang( nPos ) ),
1289cdf0e10cSrcweir                                    nItrMode, 1, nDone );
1290cdf0e10cSrcweir 
1291cdf0e10cSrcweir                 // Check if nPos is inside hidden text range:
1292cdf0e10cSrcweir                 if ( CRSR_SKIP_HIDDEN & nMode )
1293cdf0e10cSrcweir                 {
1294cdf0e10cSrcweir                     xub_StrLen nHiddenStart;
1295cdf0e10cSrcweir                     xub_StrLen nHiddenEnd;
1296cdf0e10cSrcweir                     SwScriptInfo::GetBoundsOfHiddenRange( rTNd, nPos, nHiddenStart, nHiddenEnd );
1297cdf0e10cSrcweir                     if ( nHiddenStart != STRING_LEN  )
1298cdf0e10cSrcweir                          nPos = nHiddenStart;
1299cdf0e10cSrcweir                 }
1300cdf0e10cSrcweir 
1301cdf0e10cSrcweir 				if( 1 == nDone )
1302cdf0e10cSrcweir 					*pIdx = nPos;
1303cdf0e10cSrcweir 				else
1304cdf0e10cSrcweir 					bRet = sal_False;
1305cdf0e10cSrcweir 			}
1306cdf0e10cSrcweir 			else if( nPos )
1307cdf0e10cSrcweir 				(*pIdx)--;
1308cdf0e10cSrcweir 			else
1309cdf0e10cSrcweir 				bRet = sal_False;
1310cdf0e10cSrcweir 		}
1311cdf0e10cSrcweir 	}
1312cdf0e10cSrcweir 	else
1313cdf0e10cSrcweir 		bRet = sal_False;
1314cdf0e10cSrcweir 	return bRet;
1315cdf0e10cSrcweir }
1316cdf0e10cSrcweir 
1317cdf0e10cSrcweir 
1318cdf0e10cSrcweir /*
1319cdf0e10cSrcweir  * Methode erzeugt fuer den vorhergehenden Node alle Ansichten vom
1320cdf0e10cSrcweir  * Dokument. Die erzeugten Contentframes werden in das entsprechende
1321cdf0e10cSrcweir  * Layout gehaengt.
1322cdf0e10cSrcweir  */
1323cdf0e10cSrcweir 
1324cdf0e10cSrcweir 
MakeFrms(SwCntntNode & rNode)1325cdf0e10cSrcweir void SwCntntNode::MakeFrms( SwCntntNode& rNode )
1326cdf0e10cSrcweir {
1327cdf0e10cSrcweir 	ASSERT( &rNode != this,
1328cdf0e10cSrcweir 			"Kein Contentnode oder Copy-Node und neuer Node identisch." );
1329cdf0e10cSrcweir 
1330cdf0e10cSrcweir 	if( !GetDepends() || &rNode == this )	// gibt es ueberhaupt Frames ??
1331cdf0e10cSrcweir 		return;
1332cdf0e10cSrcweir 
1333cdf0e10cSrcweir 	SwFrm *pFrm, *pNew;
1334cdf0e10cSrcweir 	SwLayoutFrm *pUpper;
1335cdf0e10cSrcweir 	// Frames anlegen fuer Nodes, die vor oder hinter der Tabelle stehen ??
1336cdf0e10cSrcweir 	ASSERT( FindTableNode() == rNode.FindTableNode(), "Table confusion" )
1337cdf0e10cSrcweir 
1338cdf0e10cSrcweir 	SwNode2Layout aNode2Layout( *this, rNode.GetIndex() );
1339cdf0e10cSrcweir 
1340cdf0e10cSrcweir 	while( 0 != (pUpper = aNode2Layout.UpperFrm( pFrm, rNode )) )
1341cdf0e10cSrcweir 	{
1342cdf0e10cSrcweir 		pNew = rNode.MakeFrm( pUpper );
1343cdf0e10cSrcweir 		pNew->Paste( pUpper, pFrm );
1344cdf0e10cSrcweir         // --> OD 2005-12-01 #i27138#
1345cdf0e10cSrcweir         // notify accessibility paragraphs objects about changed
1346cdf0e10cSrcweir         // CONTENT_FLOWS_FROM/_TO relation.
1347cdf0e10cSrcweir         // Relation CONTENT_FLOWS_FROM for next paragraph will change
1348cdf0e10cSrcweir         // and relation CONTENT_FLOWS_TO for previous paragraph will change.
1349cdf0e10cSrcweir         if ( pNew->IsTxtFrm() )
1350cdf0e10cSrcweir         {
1351cdf0e10cSrcweir             ViewShell* pViewShell( pNew->getRootFrm()->GetCurrShell() );
1352cdf0e10cSrcweir             if ( pViewShell && pViewShell->GetLayout() &&
1353cdf0e10cSrcweir                  pViewShell->GetLayout()->IsAnyShellAccessible() )
1354cdf0e10cSrcweir             {
1355cdf0e10cSrcweir                 pViewShell->InvalidateAccessibleParaFlowRelation(
1356cdf0e10cSrcweir                             dynamic_cast<SwTxtFrm*>(pNew->FindNextCnt( true )),
1357cdf0e10cSrcweir                             dynamic_cast<SwTxtFrm*>(pNew->FindPrevCnt( true )) );
1358cdf0e10cSrcweir             }
1359cdf0e10cSrcweir         }
1360cdf0e10cSrcweir         // <--
1361cdf0e10cSrcweir     }
1362cdf0e10cSrcweir }
1363cdf0e10cSrcweir 
1364cdf0e10cSrcweir /*
1365cdf0e10cSrcweir  * Methode loescht fuer den Node alle Ansichten vom
1366cdf0e10cSrcweir  * Dokument. Die Contentframes werden aus dem entsprechenden
1367cdf0e10cSrcweir  * Layout ausgehaengt.
1368cdf0e10cSrcweir  */
1369cdf0e10cSrcweir 
1370cdf0e10cSrcweir 
1371ca62e2c2SSteve Yin //Solution:Add a input param to identify if the acc table should be disposed.
1372ca62e2c2SSteve Yin //add a flag(bNeedDel) to indicate whether to del corresponding frm even in doc loading process,
1373ca62e2c2SSteve Yin //void SwCntntNode::DelFrms()
DelFrms(sal_Bool,sal_Bool bIsDisposeAccTable)1374*76b751b2SPavel Janík void SwCntntNode::DelFrms( sal_Bool /* bNeedDel */, sal_Bool bIsDisposeAccTable )
1375cdf0e10cSrcweir {
1376cdf0e10cSrcweir 	if( !GetDepends() )
1377cdf0e10cSrcweir 		return;
1378cdf0e10cSrcweir 
1379ca62e2c2SSteve Yin 	SwClientIter aIter( *this );
1380ca62e2c2SSteve Yin 	SwCntntFrm *pFrm;
1381ca62e2c2SSteve Yin 
1382ca62e2c2SSteve Yin 	for( pFrm = (SwCntntFrm*)aIter.First( TYPE(SwCntntFrm)); pFrm;
1383ca62e2c2SSteve Yin 		 pFrm = (SwCntntFrm*)aIter.Next() )
1384ca62e2c2SSteve Yin 	{
1385ca62e2c2SSteve Yin         // --> OD 2005-12-01 #i27138#
1386ca62e2c2SSteve Yin         // notify accessibility paragraphs objects about changed
1387ca62e2c2SSteve Yin         // CONTENT_FLOWS_FROM/_TO relation.
1388ca62e2c2SSteve Yin         // Relation CONTENT_FLOWS_FROM for current next paragraph will change
1389ca62e2c2SSteve Yin         // and relation CONTENT_FLOWS_TO for current previous paragraph will change.
1390ca62e2c2SSteve Yin         if ( pFrm->IsTxtFrm() )
1391ca62e2c2SSteve Yin         {
1392ca62e2c2SSteve Yin             ViewShell* pViewShell( pFrm->getRootFrm()->GetCurrShell() );
1393ca62e2c2SSteve Yin             if ( pViewShell && pViewShell->GetLayout() &&
1394ca62e2c2SSteve Yin                  pViewShell->GetLayout()->IsAnyShellAccessible() )
1395ca62e2c2SSteve Yin             {
1396ca62e2c2SSteve Yin                 pViewShell->InvalidateAccessibleParaFlowRelation(
1397ca62e2c2SSteve Yin                             dynamic_cast<SwTxtFrm*>(pFrm->FindNextCnt( true )),
1398ca62e2c2SSteve Yin                             dynamic_cast<SwTxtFrm*>(pFrm->FindPrevCnt( true )) );
1399ca62e2c2SSteve Yin             }
1400ca62e2c2SSteve Yin         }
1401ca62e2c2SSteve Yin         // <--
1402ca62e2c2SSteve Yin         if( pFrm->HasFollow() )
1403ca62e2c2SSteve Yin             pFrm->GetFollow()->_SetIsFollow( pFrm->IsFollow() );
1404ca62e2c2SSteve Yin         if( pFrm->IsFollow() )
1405ca62e2c2SSteve Yin         {
1406ca62e2c2SSteve Yin             SwCntntFrm* pMaster = (SwTxtFrm*)pFrm->FindMaster();
1407ca62e2c2SSteve Yin             pMaster->SetFollow( pFrm->GetFollow() );
1408ca62e2c2SSteve Yin             pFrm->_SetIsFollow( sal_False );
1409ca62e2c2SSteve Yin         }
1410ca62e2c2SSteve Yin 		pFrm->SetFollow( 0 );//Damit er nicht auf dumme Gedanken kommt.
1411ca62e2c2SSteve Yin 								//Andernfalls kann es sein, dass ein Follow
1412ca62e2c2SSteve Yin 								//vor seinem Master zerstoert wird, der Master
1413ca62e2c2SSteve Yin 								//greift dann ueber den ungueltigen
1414ca62e2c2SSteve Yin 								//Follow-Pointer auf fremdes Memory zu.
1415ca62e2c2SSteve Yin 								//Die Kette darf hier zerknauscht werden, weil
1416ca62e2c2SSteve Yin 								//sowieso alle zerstoert werden.
1417ca62e2c2SSteve Yin 		if( pFrm->GetUpper() && pFrm->IsInFtn() && !pFrm->GetIndNext() &&
1418ca62e2c2SSteve Yin 			!pFrm->GetIndPrev() )
1419ca62e2c2SSteve Yin 		{
1420ca62e2c2SSteve Yin 			SwFtnFrm *pFtn = pFrm->FindFtnFrm();
1421ca62e2c2SSteve Yin 			ASSERT( pFtn, "You promised a FtnFrm?" );
1422ca62e2c2SSteve Yin 			SwCntntFrm* pCFrm;
1423ca62e2c2SSteve Yin 			if( !pFtn->GetFollow() && !pFtn->GetMaster() &&
1424ca62e2c2SSteve Yin 				0 != ( pCFrm = pFtn->GetRefFromAttr()) && pCFrm->IsFollow() )
1425ca62e2c2SSteve Yin 			{
1426ca62e2c2SSteve Yin 				ASSERT( pCFrm->IsTxtFrm(), "NoTxtFrm has Footnote?" );
1427ca62e2c2SSteve Yin 				((SwTxtFrm*)pCFrm->FindMaster())->Prepare( PREP_FTN_GONE );
1428ca62e2c2SSteve Yin 			}
1429ca62e2c2SSteve Yin 		}
1430ca62e2c2SSteve Yin 		//Solution:Set acc table dispose state
1431ca62e2c2SSteve Yin 		pFrm->SetAccTableDispose( bIsDisposeAccTable );
1432ca62e2c2SSteve Yin 		//End Added
1433ca62e2c2SSteve Yin 		pFrm->Cut();
1434ca62e2c2SSteve Yin 		//Solution:Set acc table dispose state to default value
1435ca62e2c2SSteve Yin 		pFrm->SetAccTableDispose( sal_True );
1436ca62e2c2SSteve Yin 		delete pFrm;
1437ca62e2c2SSteve Yin 	}
1438cdf0e10cSrcweir 	if( IsTxtNode() )
1439cdf0e10cSrcweir 	{
1440cdf0e10cSrcweir         ((SwTxtNode*)this)->SetWrong( NULL );
1441cdf0e10cSrcweir         ((SwTxtNode*)this)->SetWrongDirty( true );
1442cdf0e10cSrcweir 
1443cdf0e10cSrcweir         ((SwTxtNode*)this)->SetGrammarCheck( NULL );
1444cdf0e10cSrcweir         ((SwTxtNode*)this)->SetGrammarCheckDirty( true );
1445cdf0e10cSrcweir         // SMARTTAGS
1446cdf0e10cSrcweir         ((SwTxtNode*)this)->SetSmartTags( NULL );
1447cdf0e10cSrcweir         ((SwTxtNode*)this)->SetSmartTagDirty( true );
1448cdf0e10cSrcweir 
1449cdf0e10cSrcweir         ((SwTxtNode*)this)->SetWordCountDirty( true );
1450cdf0e10cSrcweir         ((SwTxtNode*)this)->SetAutoCompleteWordDirty( true );
1451cdf0e10cSrcweir 	}
1452cdf0e10cSrcweir }
1453cdf0e10cSrcweir 
1454cdf0e10cSrcweir 
JoinNext()1455cdf0e10cSrcweir SwCntntNode *SwCntntNode::JoinNext()
1456cdf0e10cSrcweir {
1457cdf0e10cSrcweir 	return this;
1458cdf0e10cSrcweir }
1459cdf0e10cSrcweir 
1460cdf0e10cSrcweir 
JoinPrev()1461cdf0e10cSrcweir SwCntntNode *SwCntntNode::JoinPrev()
1462cdf0e10cSrcweir {
1463cdf0e10cSrcweir 	return this;
1464cdf0e10cSrcweir }
1465cdf0e10cSrcweir 
1466cdf0e10cSrcweir 
1467cdf0e10cSrcweir 
1468cdf0e10cSrcweir 	// erfrage vom Modify Informationen
GetInfo(SfxPoolItem & rInfo) const1469cdf0e10cSrcweir sal_Bool SwCntntNode::GetInfo( SfxPoolItem& rInfo ) const
1470cdf0e10cSrcweir {
1471cdf0e10cSrcweir 	switch( rInfo.Which() )
1472cdf0e10cSrcweir 	{
1473cdf0e10cSrcweir 	case RES_AUTOFMT_DOCNODE:
1474cdf0e10cSrcweir 		if( &GetNodes() == ((SwAutoFmtGetDocNode&)rInfo).pNodes )
1475cdf0e10cSrcweir 		{
1476cdf0e10cSrcweir 			((SwAutoFmtGetDocNode&)rInfo).pCntntNode = this;
1477cdf0e10cSrcweir 			return sal_False;
1478cdf0e10cSrcweir 		}
1479cdf0e10cSrcweir 		break;
1480cdf0e10cSrcweir     // --> OD 2008-02-19 #refactorlists#
1481cdf0e10cSrcweir //    case RES_GETNUMNODES:
1482cdf0e10cSrcweir //        // #111955# only numbered nodes in rInfo
1483cdf0e10cSrcweir //        if( IsTxtNode())
1484cdf0e10cSrcweir //        {
1485cdf0e10cSrcweir //            SwTxtNode * pTxtNode = (SwTxtNode*)this;
1486cdf0e10cSrcweir //            pItem = (SwNumRuleItem*)GetNoCondAttr(RES_PARATR_NUMRULE, sal_True );
1487cdf0e10cSrcweir 
1488cdf0e10cSrcweir //            if (0 != pItem  &&
1489cdf0e10cSrcweir //                pItem->GetValue().Len() &&
1490cdf0e10cSrcweir //                pItem->GetValue() == ((SwNumRuleInfo&)rInfo).GetName() &&
1491cdf0e10cSrcweir //                GetNodes().IsDocNodes())
1492cdf0e10cSrcweir //            {
1493cdf0e10cSrcweir //                ((SwNumRuleInfo&)rInfo).AddNode( *pTxtNode );
1494cdf0e10cSrcweir //            }
1495cdf0e10cSrcweir //        }
1496cdf0e10cSrcweir 
1497cdf0e10cSrcweir //        return sal_True;
1498cdf0e10cSrcweir     // <--
1499cdf0e10cSrcweir 
1500cdf0e10cSrcweir 	case RES_FINDNEARESTNODE:
1501cdf0e10cSrcweir         if( ((SwFmtPageDesc&)GetAttr( RES_PAGEDESC )).GetPageDesc() )
1502cdf0e10cSrcweir 			((SwFindNearestNode&)rInfo).CheckNode( *this );
1503cdf0e10cSrcweir 		return sal_True;
1504cdf0e10cSrcweir 
1505cdf0e10cSrcweir 	case RES_CONTENT_VISIBLE:
1506cdf0e10cSrcweir 		{
1507cdf0e10cSrcweir 			((SwPtrMsgPoolItem&)rInfo).pObject =
1508cdf0e10cSrcweir 				SwIterator<SwFrm,SwCntntNode>::FirstElement(*this);
1509cdf0e10cSrcweir 		}
1510cdf0e10cSrcweir 		return sal_False;
1511cdf0e10cSrcweir 	}
1512cdf0e10cSrcweir 
1513cdf0e10cSrcweir 	return SwModify::GetInfo( rInfo );
1514cdf0e10cSrcweir }
1515cdf0e10cSrcweir 
1516cdf0e10cSrcweir 
1517cdf0e10cSrcweir 	// setze ein Attribut
SetAttr(const SfxPoolItem & rAttr)1518cdf0e10cSrcweir sal_Bool SwCntntNode::SetAttr(const SfxPoolItem& rAttr )
1519cdf0e10cSrcweir {
1520cdf0e10cSrcweir     if( !GetpSwAttrSet() )            // lasse von den entsprechenden Nodes die
1521cdf0e10cSrcweir 		NewAttrSet( GetDoc()->GetAttrPool() );		// AttrSets anlegen
1522cdf0e10cSrcweir 
1523cdf0e10cSrcweir     ASSERT( GetpSwAttrSet(), "warum wurde kein AttrSet angelegt?" );
1524cdf0e10cSrcweir 
1525cdf0e10cSrcweir     if ( IsInCache() )
1526cdf0e10cSrcweir 	{
1527cdf0e10cSrcweir 		SwFrm::GetCache().Delete( this );
1528cdf0e10cSrcweir 		SetInCache( sal_False );
1529cdf0e10cSrcweir 	}
1530cdf0e10cSrcweir 
1531cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
1532cdf0e10cSrcweir 	// wenn Modify gelockt ist, werden keine Modifies verschickt
1533cdf0e10cSrcweir 	if( IsModifyLocked() ||
1534cdf0e10cSrcweir 		( !GetDepends() &&  RES_PARATR_NUMRULE != rAttr.Which() ))
1535cdf0e10cSrcweir 	{
1536cdf0e10cSrcweir         bRet = 0 != AttrSetHandleHelper::Put( mpAttrSet, *this, rAttr );
1537cdf0e10cSrcweir 	}
1538cdf0e10cSrcweir 	else
1539cdf0e10cSrcweir 	{
1540cdf0e10cSrcweir         SwAttrSet aOld( *GetpSwAttrSet()->GetPool(), GetpSwAttrSet()->GetRanges() ),
1541cdf0e10cSrcweir                   aNew( *GetpSwAttrSet()->GetPool(), GetpSwAttrSet()->GetRanges() );
1542cdf0e10cSrcweir         if( 0 != ( bRet = 0 != AttrSetHandleHelper::Put_BC( mpAttrSet, *this, rAttr, &aOld, &aNew ) ))
1543cdf0e10cSrcweir 		{
1544cdf0e10cSrcweir             SwAttrSetChg aChgOld( *GetpSwAttrSet(), aOld );
1545cdf0e10cSrcweir             SwAttrSetChg aChgNew( *GetpSwAttrSet(), aNew );
1546cdf0e10cSrcweir 			ModifyNotification( &aChgOld, &aChgNew );		// alle veraenderten werden verschickt
1547cdf0e10cSrcweir 		}
1548cdf0e10cSrcweir 	}
1549cdf0e10cSrcweir 	return bRet;
1550cdf0e10cSrcweir }
1551cdf0e10cSrcweir #include <svl/itemiter.hxx>
1552cdf0e10cSrcweir 
SetAttr(const SfxItemSet & rSet)1553cdf0e10cSrcweir sal_Bool SwCntntNode::SetAttr( const SfxItemSet& rSet )
1554cdf0e10cSrcweir {
1555cdf0e10cSrcweir     if ( IsInCache() )
1556cdf0e10cSrcweir 	{
1557cdf0e10cSrcweir 		SwFrm::GetCache().Delete( this );
1558cdf0e10cSrcweir 		SetInCache( sal_False );
1559cdf0e10cSrcweir 	}
1560cdf0e10cSrcweir 
1561cdf0e10cSrcweir     const SfxPoolItem* pFnd = 0;
1562cdf0e10cSrcweir     if( SFX_ITEM_SET == rSet.GetItemState( RES_AUTO_STYLE, sal_False, &pFnd ) )
1563cdf0e10cSrcweir     {
1564cdf0e10cSrcweir         ASSERT( rSet.Count() == 1, "SetAutoStyle mixed with other attributes?!" );
1565cdf0e10cSrcweir         const SwFmtAutoFmt* pTmp = static_cast<const SwFmtAutoFmt*>(pFnd);
1566cdf0e10cSrcweir 
1567cdf0e10cSrcweir         // If there already is an attribute set (usually containing a numbering
1568cdf0e10cSrcweir         // item), we have to merge the attribute of the new set into the old set:
1569cdf0e10cSrcweir         bool bSetParent = true;
1570cdf0e10cSrcweir         if ( GetpSwAttrSet() )
1571cdf0e10cSrcweir         {
1572cdf0e10cSrcweir             bSetParent = false;
1573cdf0e10cSrcweir             AttrSetHandleHelper::Put( mpAttrSet, *this, *pTmp->GetStyleHandle() );
1574cdf0e10cSrcweir         }
1575cdf0e10cSrcweir         else
1576cdf0e10cSrcweir         {
1577cdf0e10cSrcweir             mpAttrSet = pTmp->GetStyleHandle();
1578cdf0e10cSrcweir         }
1579cdf0e10cSrcweir 
1580cdf0e10cSrcweir         if ( bSetParent )
1581cdf0e10cSrcweir         {
1582cdf0e10cSrcweir             // If the content node has a conditional style, we have to set the
1583cdf0e10cSrcweir             // string item containing the correct conditional style name (the
1584cdf0e10cSrcweir             // style name property has already been set during the import!)
1585cdf0e10cSrcweir             // In case we do not have a conditional style, we make use of the
1586cdf0e10cSrcweir             // fact that nobody else uses the attribute set behind the handle.
1587cdf0e10cSrcweir             // FME 2007-07-10 #i78124# If autostyle does not have a parent,
1588cdf0e10cSrcweir             // the string is empty.
1589cdf0e10cSrcweir             const SfxPoolItem* pNameItem = 0;
1590cdf0e10cSrcweir             if ( 0 != GetCondFmtColl() ||
1591cdf0e10cSrcweir                  SFX_ITEM_SET != mpAttrSet->GetItemState( RES_FRMATR_STYLE_NAME, sal_False, &pNameItem ) ||
1592cdf0e10cSrcweir                  0 == static_cast<const SfxStringItem*>(pNameItem)->GetValue().Len() )
1593cdf0e10cSrcweir                 AttrSetHandleHelper::SetParent( mpAttrSet, *this, &GetAnyFmtColl(), GetFmtColl() );
1594cdf0e10cSrcweir             else
1595cdf0e10cSrcweir                 const_cast<SfxItemSet*>(mpAttrSet.get())->SetParent( &GetFmtColl()->GetAttrSet() );
1596cdf0e10cSrcweir         }
1597cdf0e10cSrcweir 
1598cdf0e10cSrcweir         return sal_True;
1599cdf0e10cSrcweir     }
1600cdf0e10cSrcweir 
1601cdf0e10cSrcweir     if( !GetpSwAttrSet() )            // lasse von den entsprechenden Nodes die
1602cdf0e10cSrcweir 		NewAttrSet( GetDoc()->GetAttrPool() );		// AttrSets anlegen
1603cdf0e10cSrcweir 
1604cdf0e10cSrcweir     sal_Bool bRet = sal_False;
1605cdf0e10cSrcweir 	// wenn Modify gelockt ist, werden keine Modifies verschickt
1606cdf0e10cSrcweir     if ( IsModifyLocked() ||
1607cdf0e10cSrcweir          ( !GetDepends() &&
1608cdf0e10cSrcweir            SFX_ITEM_SET != rSet.GetItemState( RES_PARATR_NUMRULE, sal_False ) ) )
1609cdf0e10cSrcweir 	{
1610cdf0e10cSrcweir 		// einige Sonderbehandlungen fuer Attribute
1611cdf0e10cSrcweir         bRet = 0 != AttrSetHandleHelper::Put( mpAttrSet, *this, rSet );
1612cdf0e10cSrcweir 	}
1613cdf0e10cSrcweir 	else
1614cdf0e10cSrcweir 	{
1615cdf0e10cSrcweir         SwAttrSet aOld( *GetpSwAttrSet()->GetPool(), GetpSwAttrSet()->GetRanges() ),
1616cdf0e10cSrcweir                   aNew( *GetpSwAttrSet()->GetPool(), GetpSwAttrSet()->GetRanges() );
1617cdf0e10cSrcweir         if( 0 != (bRet = 0 != AttrSetHandleHelper::Put_BC( mpAttrSet, *this, rSet, &aOld, &aNew )) )
1618cdf0e10cSrcweir 		{
1619cdf0e10cSrcweir 			// einige Sonderbehandlungen fuer Attribute
1620cdf0e10cSrcweir             SwAttrSetChg aChgOld( *GetpSwAttrSet(), aOld );
1621cdf0e10cSrcweir             SwAttrSetChg aChgNew( *GetpSwAttrSet(), aNew );
1622cdf0e10cSrcweir 			ModifyNotification( &aChgOld, &aChgNew );		// alle veraenderten werden verschickt
1623cdf0e10cSrcweir 		}
1624cdf0e10cSrcweir 	}
1625cdf0e10cSrcweir 	return bRet;
1626cdf0e10cSrcweir }
1627cdf0e10cSrcweir 
1628cdf0e10cSrcweir // Nimmt den Hint mit nWhich aus dem Delta-Array
1629cdf0e10cSrcweir 
1630cdf0e10cSrcweir 
ResetAttr(sal_uInt16 nWhich1,sal_uInt16 nWhich2)1631cdf0e10cSrcweir sal_Bool SwCntntNode::ResetAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 )
1632cdf0e10cSrcweir {
1633cdf0e10cSrcweir     if( !GetpSwAttrSet() )
1634cdf0e10cSrcweir 		return sal_False;
1635cdf0e10cSrcweir 
1636cdf0e10cSrcweir     if ( IsInCache() )
1637cdf0e10cSrcweir 	{
1638cdf0e10cSrcweir 		SwFrm::GetCache().Delete( this );
1639cdf0e10cSrcweir 		SetInCache( sal_False );
1640cdf0e10cSrcweir 	}
1641cdf0e10cSrcweir 
1642cdf0e10cSrcweir 	// wenn Modify gelockt ist, werden keine Modifies verschickt
1643cdf0e10cSrcweir 	if( IsModifyLocked() )
1644cdf0e10cSrcweir 	{
1645cdf0e10cSrcweir         sal_uInt16 nDel = 0;
1646cdf0e10cSrcweir         if ( !nWhich2 || nWhich2 < nWhich1 )
1647cdf0e10cSrcweir         {
1648cdf0e10cSrcweir             std::vector<sal_uInt16> aClearWhichIds;
1649cdf0e10cSrcweir             aClearWhichIds.push_back( nWhich1 );
1650cdf0e10cSrcweir             nDel = ClearItemsFromAttrSet( aClearWhichIds );
1651cdf0e10cSrcweir         }
1652cdf0e10cSrcweir         else
1653cdf0e10cSrcweir             nDel = AttrSetHandleHelper::ClearItem_BC( mpAttrSet, *this, nWhich1, nWhich2, 0, 0 );
1654cdf0e10cSrcweir 
1655cdf0e10cSrcweir         if( !GetpSwAttrSet()->Count() )   // leer, dann loeschen
1656cdf0e10cSrcweir             mpAttrSet.reset();//DELETEZ( mpAttrSet );
1657cdf0e10cSrcweir 		return 0 != nDel;
1658cdf0e10cSrcweir 	}
1659cdf0e10cSrcweir 
1660cdf0e10cSrcweir 	// sollte kein gueltiger Bereich definiert sein ?
1661cdf0e10cSrcweir 	if( !nWhich2 || nWhich2 < nWhich1 )
1662cdf0e10cSrcweir 		nWhich2 = nWhich1;		// dann setze auf 1. Id, nur dieses Item
1663cdf0e10cSrcweir 
1664cdf0e10cSrcweir     SwAttrSet aOld( *GetpSwAttrSet()->GetPool(), GetpSwAttrSet()->GetRanges() ),
1665cdf0e10cSrcweir               aNew( *GetpSwAttrSet()->GetPool(), GetpSwAttrSet()->GetRanges() );
1666cdf0e10cSrcweir     sal_Bool bRet = 0 != AttrSetHandleHelper::ClearItem_BC( mpAttrSet, *this, nWhich1, nWhich2, &aOld, &aNew );
1667cdf0e10cSrcweir 
1668cdf0e10cSrcweir 	if( bRet )
1669cdf0e10cSrcweir 	{
1670cdf0e10cSrcweir         SwAttrSetChg aChgOld( *GetpSwAttrSet(), aOld );
1671cdf0e10cSrcweir         SwAttrSetChg aChgNew( *GetpSwAttrSet(), aNew );
1672cdf0e10cSrcweir 		ModifyNotification( &aChgOld, &aChgNew );		// alle veraenderten werden verschickt
1673cdf0e10cSrcweir 
1674cdf0e10cSrcweir         if( !GetpSwAttrSet()->Count() )   // leer, dann loeschen
1675cdf0e10cSrcweir             mpAttrSet.reset();//DELETEZ( mpAttrSet );
1676cdf0e10cSrcweir 	}
1677cdf0e10cSrcweir 	return bRet;
1678cdf0e10cSrcweir }
ResetAttr(const SvUShorts & rWhichArr)1679cdf0e10cSrcweir sal_Bool SwCntntNode::ResetAttr( const SvUShorts& rWhichArr )
1680cdf0e10cSrcweir {
1681cdf0e10cSrcweir     if( !GetpSwAttrSet() )
1682cdf0e10cSrcweir 		return sal_False;
1683cdf0e10cSrcweir 
1684cdf0e10cSrcweir     if ( IsInCache() )
1685cdf0e10cSrcweir 	{
1686cdf0e10cSrcweir 		SwFrm::GetCache().Delete( this );
1687cdf0e10cSrcweir 		SetInCache( sal_False );
1688cdf0e10cSrcweir 	}
1689cdf0e10cSrcweir 
1690cdf0e10cSrcweir 	// wenn Modify gelockt ist, werden keine Modifies verschickt
1691cdf0e10cSrcweir 	sal_uInt16 nDel = 0;
1692cdf0e10cSrcweir 	if( IsModifyLocked() )
1693cdf0e10cSrcweir 	{
1694cdf0e10cSrcweir         std::vector<sal_uInt16> aClearWhichIds;
1695cdf0e10cSrcweir 		for( sal_uInt16 n = 0, nEnd = rWhichArr.Count(); n < nEnd; ++n )
1696cdf0e10cSrcweir             aClearWhichIds.push_back( rWhichArr[ n ] );
1697cdf0e10cSrcweir 
1698cdf0e10cSrcweir         nDel = ClearItemsFromAttrSet( aClearWhichIds );
1699cdf0e10cSrcweir     }
1700cdf0e10cSrcweir 	else
1701cdf0e10cSrcweir 	{
1702cdf0e10cSrcweir         SwAttrSet aOld( *GetpSwAttrSet()->GetPool(), GetpSwAttrSet()->GetRanges() ),
1703cdf0e10cSrcweir                   aNew( *GetpSwAttrSet()->GetPool(), GetpSwAttrSet()->GetRanges() );
1704cdf0e10cSrcweir 
1705cdf0e10cSrcweir 		for( sal_uInt16 n = 0, nEnd = rWhichArr.Count(); n < nEnd; ++n )
1706cdf0e10cSrcweir             if( AttrSetHandleHelper::ClearItem_BC( mpAttrSet, *this, rWhichArr[ n ], &aOld, &aNew ))
1707cdf0e10cSrcweir 				++nDel;
1708cdf0e10cSrcweir 
1709cdf0e10cSrcweir 		if( nDel )
1710cdf0e10cSrcweir 		{
1711cdf0e10cSrcweir             SwAttrSetChg aChgOld( *GetpSwAttrSet(), aOld );
1712cdf0e10cSrcweir             SwAttrSetChg aChgNew( *GetpSwAttrSet(), aNew );
1713cdf0e10cSrcweir 			ModifyNotification( &aChgOld, &aChgNew );		// alle veraenderten werden verschickt
1714cdf0e10cSrcweir 		}
1715cdf0e10cSrcweir 	}
1716cdf0e10cSrcweir     if( !GetpSwAttrSet()->Count() )   // leer, dann loeschen
1717cdf0e10cSrcweir         mpAttrSet.reset();//DELETEZ( mpAttrSet );
1718cdf0e10cSrcweir 	return 0 != nDel ;
1719cdf0e10cSrcweir }
1720cdf0e10cSrcweir 
1721cdf0e10cSrcweir 
ResetAllAttr()1722cdf0e10cSrcweir sal_uInt16 SwCntntNode::ResetAllAttr()
1723cdf0e10cSrcweir {
1724cdf0e10cSrcweir     if( !GetpSwAttrSet() )
1725cdf0e10cSrcweir 		return 0;
1726cdf0e10cSrcweir 
1727cdf0e10cSrcweir     if ( IsInCache() )
1728cdf0e10cSrcweir 	{
1729cdf0e10cSrcweir 		SwFrm::GetCache().Delete( this );
1730cdf0e10cSrcweir 		SetInCache( sal_False );
1731cdf0e10cSrcweir 	}
1732cdf0e10cSrcweir 
1733cdf0e10cSrcweir 	// wenn Modify gelockt ist, werden keine Modifies verschickt
1734cdf0e10cSrcweir 	if( IsModifyLocked() )
1735cdf0e10cSrcweir 	{
1736cdf0e10cSrcweir         std::vector<sal_uInt16> aClearWhichIds;
1737cdf0e10cSrcweir         aClearWhichIds.push_back(0);
1738cdf0e10cSrcweir         sal_uInt16 nDel = ClearItemsFromAttrSet( aClearWhichIds );
1739cdf0e10cSrcweir         if( !GetpSwAttrSet()->Count() )   // leer, dann loeschen
1740cdf0e10cSrcweir             mpAttrSet.reset();            // DELETEZ( mpAttrSet );
1741cdf0e10cSrcweir 		return nDel;
1742cdf0e10cSrcweir 	}
1743cdf0e10cSrcweir 
1744cdf0e10cSrcweir     SwAttrSet aOld( *GetpSwAttrSet()->GetPool(), GetpSwAttrSet()->GetRanges() ),
1745cdf0e10cSrcweir               aNew( *GetpSwAttrSet()->GetPool(), GetpSwAttrSet()->GetRanges() );
1746cdf0e10cSrcweir     sal_Bool bRet = 0 != AttrSetHandleHelper::ClearItem_BC( mpAttrSet, *this, 0, &aOld, &aNew );
1747cdf0e10cSrcweir 
1748cdf0e10cSrcweir 	if( bRet )
1749cdf0e10cSrcweir 	{
1750cdf0e10cSrcweir         SwAttrSetChg aChgOld( *GetpSwAttrSet(), aOld );
1751cdf0e10cSrcweir         SwAttrSetChg aChgNew( *GetpSwAttrSet(), aNew );
1752cdf0e10cSrcweir 		ModifyNotification( &aChgOld, &aChgNew );		// alle veraenderten werden verschickt
1753cdf0e10cSrcweir 
1754cdf0e10cSrcweir         if( !GetpSwAttrSet()->Count() )   // leer, dann loeschen
1755cdf0e10cSrcweir             mpAttrSet.reset();//DELETEZ( mpAttrSet );
1756cdf0e10cSrcweir 	}
1757cdf0e10cSrcweir 	return aNew.Count();
1758cdf0e10cSrcweir }
1759cdf0e10cSrcweir 
1760cdf0e10cSrcweir 
GetAttr(SfxItemSet & rSet,sal_Bool bInParent) const1761cdf0e10cSrcweir sal_Bool SwCntntNode::GetAttr( SfxItemSet& rSet, sal_Bool bInParent ) const
1762cdf0e10cSrcweir {
1763cdf0e10cSrcweir 	if( rSet.Count() )
1764cdf0e10cSrcweir 		rSet.ClearItem();
1765cdf0e10cSrcweir 
1766cdf0e10cSrcweir 	const SwAttrSet& rAttrSet = GetSwAttrSet();
1767cdf0e10cSrcweir 	if( bInParent )
1768cdf0e10cSrcweir 		return rSet.Set( rAttrSet, sal_True ) ? sal_True : sal_False;
1769cdf0e10cSrcweir 
1770cdf0e10cSrcweir 	rSet.Put( rAttrSet );
1771cdf0e10cSrcweir 	return rSet.Count() ? sal_True : sal_False;
1772cdf0e10cSrcweir }
1773cdf0e10cSrcweir 
ClearItemsFromAttrSet(const std::vector<sal_uInt16> & rWhichIds)1774cdf0e10cSrcweir sal_uInt16 SwCntntNode::ClearItemsFromAttrSet( const std::vector<sal_uInt16>& rWhichIds )
1775cdf0e10cSrcweir {
1776cdf0e10cSrcweir     sal_uInt16 nRet = 0;
1777cdf0e10cSrcweir     if ( 0 == rWhichIds.size() )
1778cdf0e10cSrcweir         return nRet;
1779cdf0e10cSrcweir 
1780cdf0e10cSrcweir     ASSERT( GetpSwAttrSet(), "no item set" )
1781cdf0e10cSrcweir     SwAttrSet aNewAttrSet( *GetpSwAttrSet() );
1782cdf0e10cSrcweir     for ( std::vector<sal_uInt16>::const_iterator aIter = rWhichIds.begin();
1783cdf0e10cSrcweir           aIter != rWhichIds.end();
1784cdf0e10cSrcweir           ++aIter )
1785cdf0e10cSrcweir     {
1786cdf0e10cSrcweir         nRet = nRet + aNewAttrSet.ClearItem( *aIter );
1787cdf0e10cSrcweir     }
1788cdf0e10cSrcweir     if ( nRet )
1789cdf0e10cSrcweir         AttrSetHandleHelper::GetNewAutoStyle( mpAttrSet, *this, aNewAttrSet );
1790cdf0e10cSrcweir 
1791cdf0e10cSrcweir     return nRet;
1792cdf0e10cSrcweir }
1793cdf0e10cSrcweir 
GetNoCondAttr(sal_uInt16 nWhich,sal_Bool bInParents) const1794cdf0e10cSrcweir const SfxPoolItem* SwCntntNode::GetNoCondAttr( sal_uInt16 nWhich,
1795cdf0e10cSrcweir 												sal_Bool bInParents ) const
1796cdf0e10cSrcweir {
1797cdf0e10cSrcweir 	const SfxPoolItem* pFnd = 0;
1798cdf0e10cSrcweir 	if( pCondColl && pCondColl->GetRegisteredIn() )
1799cdf0e10cSrcweir 	{
1800cdf0e10cSrcweir         if( !GetpSwAttrSet() || ( SFX_ITEM_SET != GetpSwAttrSet()->GetItemState(
1801cdf0e10cSrcweir 					nWhich, sal_False, &pFnd ) && bInParents ))
1802cdf0e10cSrcweir 			((SwFmt*)GetRegisteredIn())->GetItemState( nWhich, bInParents, &pFnd );
1803cdf0e10cSrcweir 	}
1804cdf0e10cSrcweir     // --> OD 2005-10-25 #126347# - undo change of issue #i51029#
1805cdf0e10cSrcweir     // Note: <GetSwAttrSet()> returns <mpAttrSet>, if set, otherwise it returns
1806cdf0e10cSrcweir     //       the attribute set of the paragraph style, which is valid for the
1807cdf0e10cSrcweir     //       content node - see file <node.hxx>
1808cdf0e10cSrcweir     else
1809cdf0e10cSrcweir     // <--
1810cdf0e10cSrcweir     {
1811cdf0e10cSrcweir 		GetSwAttrSet().GetItemState( nWhich, bInParents, &pFnd );
1812cdf0e10cSrcweir     }
1813cdf0e10cSrcweir 	return pFnd;
1814cdf0e10cSrcweir }
1815cdf0e10cSrcweir 
1816cdf0e10cSrcweir 	// koennen 2 Nodes zusammengefasst werden ?
1817cdf0e10cSrcweir 	// in pIdx kann die 2. Position returnt werden.
CanJoinNext(SwNodeIndex * pIdx) const1818cdf0e10cSrcweir int SwCntntNode::CanJoinNext( SwNodeIndex* pIdx ) const
1819cdf0e10cSrcweir {
1820cdf0e10cSrcweir 	const SwNodes& rNds = GetNodes();
1821cdf0e10cSrcweir 	sal_uInt8 nNdType = GetNodeType();
1822cdf0e10cSrcweir 	SwNodeIndex aIdx( *this, 1 );
1823cdf0e10cSrcweir 
1824cdf0e10cSrcweir 	const SwNode* pNd = this;
1825cdf0e10cSrcweir 	while( aIdx < rNds.Count()-1 &&
1826cdf0e10cSrcweir 		(( pNd = &aIdx.GetNode())->IsSectionNode() ||
1827cdf0e10cSrcweir             ( pNd->IsEndNode() && pNd->StartOfSectionNode()->IsSectionNode() )))
1828cdf0e10cSrcweir 		aIdx++;
1829cdf0e10cSrcweir 
1830cdf0e10cSrcweir 	if( pNd->GetNodeType() != nNdType || rNds.Count()-1 == aIdx.GetIndex() )
1831cdf0e10cSrcweir 		return sal_False;
1832cdf0e10cSrcweir     if( IsTxtNode() )
1833cdf0e10cSrcweir     {   // Do not merge strings if the result exceeds the allowed string length
1834cdf0e10cSrcweir         const SwTxtNode* pTxtNd = static_cast<const SwTxtNode*>(this);
1835cdf0e10cSrcweir         sal_uInt64 nSum = pTxtNd->GetTxt().Len();
1836cdf0e10cSrcweir         pTxtNd = static_cast<const SwTxtNode*>(pNd);
1837cdf0e10cSrcweir         nSum += pTxtNd->GetTxt().Len();
1838cdf0e10cSrcweir         if( nSum > STRING_LEN )
1839cdf0e10cSrcweir             return sal_False;
1840cdf0e10cSrcweir     }
1841cdf0e10cSrcweir 	if( pIdx )
1842cdf0e10cSrcweir 		*pIdx = aIdx;
1843cdf0e10cSrcweir 	return sal_True;
1844cdf0e10cSrcweir }
1845cdf0e10cSrcweir 
1846cdf0e10cSrcweir 
1847cdf0e10cSrcweir 	// koennen 2 Nodes zusammengefasst werden ?
1848cdf0e10cSrcweir 	// in pIdx kann die 2. Position returnt werden.
CanJoinPrev(SwNodeIndex * pIdx) const1849cdf0e10cSrcweir int SwCntntNode::CanJoinPrev( SwNodeIndex* pIdx ) const
1850cdf0e10cSrcweir {
1851cdf0e10cSrcweir     sal_uInt8 nNdType = GetNodeType();
1852cdf0e10cSrcweir 	SwNodeIndex aIdx( *this, -1 );
1853cdf0e10cSrcweir 
1854cdf0e10cSrcweir 	const SwNode* pNd = this;
1855cdf0e10cSrcweir 	while( aIdx.GetIndex() &&
1856cdf0e10cSrcweir 		(( pNd = &aIdx.GetNode())->IsSectionNode() ||
1857cdf0e10cSrcweir             ( pNd->IsEndNode() && pNd->StartOfSectionNode()->IsSectionNode() )))
1858cdf0e10cSrcweir 		aIdx--;
1859cdf0e10cSrcweir 
1860cdf0e10cSrcweir 	if( pNd->GetNodeType() != nNdType || 0 == aIdx.GetIndex() )
1861cdf0e10cSrcweir 		return sal_False;
1862cdf0e10cSrcweir 	if( pIdx )
1863cdf0e10cSrcweir 		*pIdx = aIdx;
1864cdf0e10cSrcweir 	return sal_True;
1865cdf0e10cSrcweir }
1866cdf0e10cSrcweir 
1867cdf0e10cSrcweir 
1868cdf0e10cSrcweir //FEATURE::CONDCOLL
1869cdf0e10cSrcweir 
1870cdf0e10cSrcweir 
SetCondFmtColl(SwFmtColl * pColl)1871cdf0e10cSrcweir void SwCntntNode::SetCondFmtColl( SwFmtColl* pColl )
1872cdf0e10cSrcweir {
1873cdf0e10cSrcweir 	if( (!pColl && pCondColl) || ( pColl && !pCondColl ) ||
1874cdf0e10cSrcweir 		( pColl && pColl != pCondColl->GetRegisteredIn() ) )
1875cdf0e10cSrcweir 	{
1876cdf0e10cSrcweir 		SwFmtColl* pOldColl = GetCondFmtColl();
1877cdf0e10cSrcweir 		delete pCondColl;
1878cdf0e10cSrcweir 		if( pColl )
1879cdf0e10cSrcweir 			pCondColl = new SwDepend( this, pColl );
1880cdf0e10cSrcweir 		else
1881cdf0e10cSrcweir 			pCondColl = 0;
1882cdf0e10cSrcweir 
1883cdf0e10cSrcweir         if( GetpSwAttrSet() )
1884cdf0e10cSrcweir 		{
1885cdf0e10cSrcweir             AttrSetHandleHelper::SetParent( mpAttrSet, *this, &GetAnyFmtColl(), GetFmtColl() );
1886cdf0e10cSrcweir 		}
1887cdf0e10cSrcweir 
1888cdf0e10cSrcweir 		if( !IsModifyLocked() )
1889cdf0e10cSrcweir 		{
1890cdf0e10cSrcweir 			SwFmtChg aTmp1( pOldColl ? pOldColl : GetFmtColl() );
1891cdf0e10cSrcweir 			SwFmtChg aTmp2( pColl ? pColl : GetFmtColl() );
1892cdf0e10cSrcweir 			NotifyClients( &aTmp1, &aTmp2 );
1893cdf0e10cSrcweir 		}
1894cdf0e10cSrcweir 		if( IsInCache() )
1895cdf0e10cSrcweir 		{
1896cdf0e10cSrcweir 			SwFrm::GetCache().Delete( this );
1897cdf0e10cSrcweir 			SetInCache( sal_False );
1898cdf0e10cSrcweir 		}
1899cdf0e10cSrcweir 	}
1900cdf0e10cSrcweir }
1901cdf0e10cSrcweir 
1902cdf0e10cSrcweir 
IsAnyCondition(SwCollCondition & rTmp) const1903cdf0e10cSrcweir sal_Bool SwCntntNode::IsAnyCondition( SwCollCondition& rTmp ) const
1904cdf0e10cSrcweir {
1905cdf0e10cSrcweir 	const SwNodes& rNds = GetNodes();
1906cdf0e10cSrcweir 	{
1907cdf0e10cSrcweir 		int nCond = 0;
1908cdf0e10cSrcweir         const SwStartNode* pSttNd = StartOfSectionNode();
1909cdf0e10cSrcweir 		while( pSttNd )
1910cdf0e10cSrcweir 		{
1911cdf0e10cSrcweir 			switch( pSttNd->GetNodeType() )
1912cdf0e10cSrcweir 			{
1913cdf0e10cSrcweir 			case ND_TABLENODE:		nCond = PARA_IN_TABLEBODY; break;
1914cdf0e10cSrcweir 			case ND_SECTIONNODE: 	nCond = PARA_IN_SECTION; break;
1915cdf0e10cSrcweir 
1916cdf0e10cSrcweir 			default:
1917cdf0e10cSrcweir 				switch( pSttNd->GetStartNodeType() )
1918cdf0e10cSrcweir 				{
1919cdf0e10cSrcweir 				case SwTableBoxStartNode:
1920cdf0e10cSrcweir 					{
1921cdf0e10cSrcweir 						nCond = PARA_IN_TABLEBODY;
1922cdf0e10cSrcweir 						const SwTableNode* pTblNd = pSttNd->FindTableNode();
1923cdf0e10cSrcweir 						const SwTableBox* pBox;
1924cdf0e10cSrcweir 						if( pTblNd && 0 != ( pBox = pTblNd->GetTable().
1925cdf0e10cSrcweir 							GetTblBox( pSttNd->GetIndex() ) ) && pBox &&
1926cdf0e10cSrcweir 							pBox->IsInHeadline( &pTblNd->GetTable() ) )
1927cdf0e10cSrcweir 							nCond = PARA_IN_TABLEHEAD;
1928cdf0e10cSrcweir 					}
1929cdf0e10cSrcweir 					break;
1930cdf0e10cSrcweir 				case SwFlyStartNode:		nCond = PARA_IN_FRAME; break;
1931cdf0e10cSrcweir 				case SwFootnoteStartNode:
1932cdf0e10cSrcweir 					{
1933cdf0e10cSrcweir 						nCond = PARA_IN_FOOTENOTE;
1934cdf0e10cSrcweir 						const SwFtnIdxs& rFtnArr = rNds.GetDoc()->GetFtnIdxs();
1935cdf0e10cSrcweir 						const SwTxtFtn* pTxtFtn;
1936cdf0e10cSrcweir 						const SwNode* pSrchNd = pSttNd;
1937cdf0e10cSrcweir 
1938cdf0e10cSrcweir 						for( sal_uInt16 n = 0; n < rFtnArr.Count(); ++n )
1939cdf0e10cSrcweir 							if( 0 != ( pTxtFtn = rFtnArr[ n ])->GetStartNode() &&
1940cdf0e10cSrcweir 								pSrchNd == &pTxtFtn->GetStartNode()->GetNode() )
1941cdf0e10cSrcweir 							{
1942cdf0e10cSrcweir 								if( pTxtFtn->GetFtn().IsEndNote() )
1943cdf0e10cSrcweir 									nCond = PARA_IN_ENDNOTE;
1944cdf0e10cSrcweir 								break;
1945cdf0e10cSrcweir 							}
1946cdf0e10cSrcweir 					}
1947cdf0e10cSrcweir 					break;
1948cdf0e10cSrcweir 				case SwHeaderStartNode:     nCond = PARA_IN_HEADER; break;
1949cdf0e10cSrcweir 				case SwFooterStartNode:     nCond = PARA_IN_FOOTER; break;
1950cdf0e10cSrcweir 				case SwNormalStartNode:     break;
1951cdf0e10cSrcweir 				}
1952cdf0e10cSrcweir 			}
1953cdf0e10cSrcweir 
1954cdf0e10cSrcweir 			if( nCond )
1955cdf0e10cSrcweir 			{
1956cdf0e10cSrcweir 				rTmp.SetCondition( (Master_CollConditions)nCond, 0 );
1957cdf0e10cSrcweir 				return sal_True;
1958cdf0e10cSrcweir 			}
1959cdf0e10cSrcweir 			pSttNd = pSttNd->GetIndex()
1960cdf0e10cSrcweir                         ? pSttNd->StartOfSectionNode()
1961cdf0e10cSrcweir 						: 0;
1962cdf0e10cSrcweir 		}
1963cdf0e10cSrcweir 	}
1964cdf0e10cSrcweir 
1965cdf0e10cSrcweir 	{
1966cdf0e10cSrcweir 		sal_uInt16 nPos;
1967cdf0e10cSrcweir 		const SwOutlineNodes& rOutlNds = rNds.GetOutLineNds();
1968cdf0e10cSrcweir 		if( rOutlNds.Count() )
1969cdf0e10cSrcweir 		{
1970cdf0e10cSrcweir 			if( !rOutlNds.Seek_Entry( (SwCntntNode*)this, &nPos ) && nPos )
1971cdf0e10cSrcweir 				--nPos;
1972cdf0e10cSrcweir 			if( nPos < rOutlNds.Count() &&
1973cdf0e10cSrcweir 				rOutlNds[ nPos ]->GetIndex() < GetIndex() )
1974cdf0e10cSrcweir 			{
1975cdf0e10cSrcweir 				SwTxtNode* pOutlNd = rOutlNds[ nPos ]->GetTxtNode();
1976cdf0e10cSrcweir 
1977cdf0e10cSrcweir 				if( pOutlNd->IsOutline())
1978cdf0e10cSrcweir 				{
1979cdf0e10cSrcweir                     rTmp.SetCondition( PARA_IN_OUTLINE, pOutlNd->GetAttrOutlineLevel() - 1 );
1980cdf0e10cSrcweir 					return sal_True;
1981cdf0e10cSrcweir 				}
1982cdf0e10cSrcweir 			}
1983cdf0e10cSrcweir 		}
1984cdf0e10cSrcweir 	}
1985cdf0e10cSrcweir 
1986cdf0e10cSrcweir 	return sal_False;
1987cdf0e10cSrcweir }
1988cdf0e10cSrcweir 
1989cdf0e10cSrcweir 
ChkCondColl()1990cdf0e10cSrcweir void SwCntntNode::ChkCondColl()
1991cdf0e10cSrcweir {
1992cdf0e10cSrcweir 	// zur Sicherheit abfragen
1993cdf0e10cSrcweir 	if( RES_CONDTXTFMTCOLL == GetFmtColl()->Which() )
1994cdf0e10cSrcweir 	{
1995cdf0e10cSrcweir 		SwCollCondition aTmp( 0, 0, 0 );
1996cdf0e10cSrcweir 		const SwCollCondition* pCColl;
1997cdf0e10cSrcweir 
1998cdf0e10cSrcweir         bool bDone = false;
1999cdf0e10cSrcweir 
2000cdf0e10cSrcweir 		if( IsAnyCondition( aTmp ))
2001cdf0e10cSrcweir         {
2002cdf0e10cSrcweir             pCColl = static_cast<SwConditionTxtFmtColl*>(GetFmtColl())
2003cdf0e10cSrcweir                 ->HasCondition( aTmp );
2004cdf0e10cSrcweir 
2005cdf0e10cSrcweir             if (pCColl)
2006cdf0e10cSrcweir             {
2007cdf0e10cSrcweir                 SetCondFmtColl( pCColl->GetTxtFmtColl() );
2008cdf0e10cSrcweir                 bDone = true;
2009cdf0e10cSrcweir             }
2010cdf0e10cSrcweir         }
2011cdf0e10cSrcweir 
2012cdf0e10cSrcweir 		if (!bDone)
2013cdf0e10cSrcweir 		{
2014cdf0e10cSrcweir             if( IsTxtNode() && ((SwTxtNode*)this)->GetNumRule())
2015cdf0e10cSrcweir 			{
2016cdf0e10cSrcweir 				// steht in einer Numerierung
2017cdf0e10cSrcweir 				// welcher Level?
2018cdf0e10cSrcweir 				aTmp.SetCondition( PARA_IN_LIST,
2019cdf0e10cSrcweir                                 ((SwTxtNode*)this)->GetActualListLevel() );
2020cdf0e10cSrcweir 				pCColl = ((SwConditionTxtFmtColl*)GetFmtColl())->
2021cdf0e10cSrcweir 								HasCondition( aTmp );
2022cdf0e10cSrcweir 			}
2023cdf0e10cSrcweir 			else
2024cdf0e10cSrcweir 				pCColl = 0;
2025cdf0e10cSrcweir 
2026cdf0e10cSrcweir 			if( pCColl )
2027cdf0e10cSrcweir 				SetCondFmtColl( pCColl->GetTxtFmtColl() );
2028cdf0e10cSrcweir 			else if( pCondColl )
2029cdf0e10cSrcweir 				SetCondFmtColl( 0 );
2030cdf0e10cSrcweir 		}
2031cdf0e10cSrcweir 	}
2032cdf0e10cSrcweir }
2033cdf0e10cSrcweir 
2034cdf0e10cSrcweir // --> OD 2005-02-21 #i42921#
GetTextDirection(const SwPosition & rPos,const Point * pPt) const2035cdf0e10cSrcweir short SwCntntNode::GetTextDirection( const SwPosition& rPos,
2036cdf0e10cSrcweir                                      const Point* pPt ) const
2037cdf0e10cSrcweir {
2038cdf0e10cSrcweir     short nRet = -1;
2039cdf0e10cSrcweir 
2040cdf0e10cSrcweir     Point aPt;
2041cdf0e10cSrcweir     if( pPt )
2042cdf0e10cSrcweir         aPt = *pPt;
2043cdf0e10cSrcweir 
2044cdf0e10cSrcweir     // --> OD 2007-01-10 #i72024#
2045cdf0e10cSrcweir     // No format of the frame, because this can cause recursive layout actions
2046cdf0e10cSrcweir     SwFrm* pFrm = getLayoutFrm( GetDoc()->GetCurrentLayout(), &aPt, &rPos, sal_False );
2047cdf0e10cSrcweir     // <--
2048cdf0e10cSrcweir 
2049cdf0e10cSrcweir     if ( pFrm )
2050cdf0e10cSrcweir     {
2051cdf0e10cSrcweir         if ( pFrm->IsVertical() )
2052cdf0e10cSrcweir         {
2053cdf0e10cSrcweir             if ( pFrm->IsRightToLeft() )
2054cdf0e10cSrcweir                 nRet = FRMDIR_VERT_TOP_LEFT;
2055cdf0e10cSrcweir             else
2056cdf0e10cSrcweir                 nRet = FRMDIR_VERT_TOP_RIGHT;
2057cdf0e10cSrcweir         }
2058cdf0e10cSrcweir         else
2059cdf0e10cSrcweir         {
2060cdf0e10cSrcweir             if ( pFrm->IsRightToLeft() )
2061cdf0e10cSrcweir                 nRet = FRMDIR_HORI_RIGHT_TOP;
2062cdf0e10cSrcweir             else
2063cdf0e10cSrcweir                 nRet = FRMDIR_HORI_LEFT_TOP;
2064cdf0e10cSrcweir         }
2065cdf0e10cSrcweir     }
2066cdf0e10cSrcweir 
2067cdf0e10cSrcweir 
2068cdf0e10cSrcweir     return nRet;
2069cdf0e10cSrcweir }
2070cdf0e10cSrcweir // <--
2071cdf0e10cSrcweir 
CreateOLENodesArray(const SwFmtColl & rColl,bool bOnlyWithInvalidSize)2072cdf0e10cSrcweir SwOLENodes* SwCntntNode::CreateOLENodesArray( const SwFmtColl& rColl, bool bOnlyWithInvalidSize )
2073cdf0e10cSrcweir {
2074cdf0e10cSrcweir     SwOLENodes *pNodes = 0;
2075cdf0e10cSrcweir     SwIterator<SwCntntNode,SwFmtColl> aIter( rColl );
2076cdf0e10cSrcweir     for( SwCntntNode* pNd = aIter.First(); pNd; pNd = aIter.Next() )
2077cdf0e10cSrcweir     {
2078cdf0e10cSrcweir         SwOLENode *pONd = pNd->GetOLENode();
2079cdf0e10cSrcweir         if ( pONd && (!bOnlyWithInvalidSize || pONd->IsOLESizeInvalid()) )
2080cdf0e10cSrcweir         {
2081cdf0e10cSrcweir             if ( !pNodes  )
2082cdf0e10cSrcweir                 pNodes = new SwOLENodes;
2083cdf0e10cSrcweir             pNodes->Insert( pONd, pNodes->Count() );
2084cdf0e10cSrcweir         }
2085cdf0e10cSrcweir     }
2086cdf0e10cSrcweir 
2087cdf0e10cSrcweir     return pNodes;
2088cdf0e10cSrcweir }
2089cdf0e10cSrcweir 
2090cdf0e10cSrcweir //FEATURE::CONDCOLL
2091cdf0e10cSrcweir // Metoden aus Node.hxx - erst hier ist der TxtNode bekannt !!
2092cdf0e10cSrcweir // os: nur fuer ICC, da der zum optimieren zu dumm ist
2093cdf0e10cSrcweir #ifdef ICC
GetTxtNode()2094cdf0e10cSrcweir SwTxtNode   *SwNode::GetTxtNode()
2095cdf0e10cSrcweir {
2096cdf0e10cSrcweir 	 return ND_TEXTNODE == nNodeType ? (SwTxtNode*)this : 0;
2097cdf0e10cSrcweir }
GetTxtNode() const2098cdf0e10cSrcweir const SwTxtNode   *SwNode::GetTxtNode() const
2099cdf0e10cSrcweir {
2100cdf0e10cSrcweir 	 return ND_TEXTNODE == nNodeType ? (const SwTxtNode*)this : 0;
2101cdf0e10cSrcweir }
2102cdf0e10cSrcweir #endif
2103cdf0e10cSrcweir 
2104cdf0e10cSrcweir /*
2105cdf0e10cSrcweir  * Document Interface Access
2106cdf0e10cSrcweir  */
getIDocumentSettingAccess() const2107cdf0e10cSrcweir const IDocumentSettingAccess* SwNode::getIDocumentSettingAccess() const { return GetDoc(); }
getIDocumentDeviceAccess() const2108cdf0e10cSrcweir const IDocumentDeviceAccess* SwNode::getIDocumentDeviceAccess() const { return GetDoc(); }
getIDocumentMarkAccess() const2109cdf0e10cSrcweir const IDocumentMarkAccess* SwNode::getIDocumentMarkAccess() const { return GetDoc()->getIDocumentMarkAccess(); }
getIDocumentRedlineAccess() const2110cdf0e10cSrcweir const IDocumentRedlineAccess* SwNode::getIDocumentRedlineAccess() const { return GetDoc(); }
getIDocumentStylePoolAccess() const2111cdf0e10cSrcweir const IDocumentStylePoolAccess* SwNode::getIDocumentStylePoolAccess() const { return GetDoc(); }
getIDocumentLineNumberAccess() const2112cdf0e10cSrcweir const IDocumentLineNumberAccess* SwNode::getIDocumentLineNumberAccess() const { return GetDoc(); }
getIDocumentDrawModelAccess() const2113cdf0e10cSrcweir const IDocumentDrawModelAccess* SwNode::getIDocumentDrawModelAccess() const { return GetDoc(); }
getIDocumentLayoutAccess() const2114cdf0e10cSrcweir const IDocumentLayoutAccess* SwNode::getIDocumentLayoutAccess() const { return GetDoc(); }
getIDocumentLayoutAccess()2115cdf0e10cSrcweir IDocumentLayoutAccess* SwNode::getIDocumentLayoutAccess() { return GetDoc(); }
getIDocumentLinksAdministration() const2116cdf0e10cSrcweir const IDocumentLinksAdministration* SwNode::getIDocumentLinksAdministration() const { return GetDoc(); }
getIDocumentLinksAdministration()2117cdf0e10cSrcweir IDocumentLinksAdministration* SwNode::getIDocumentLinksAdministration() { return GetDoc(); }
getIDocumentFieldsAccess() const2118cdf0e10cSrcweir const IDocumentFieldsAccess* SwNode::getIDocumentFieldsAccess() const { return GetDoc(); }
getIDocumentFieldsAccess()2119cdf0e10cSrcweir IDocumentFieldsAccess* SwNode::getIDocumentFieldsAccess() { return GetDoc(); }
getIDocumentContentOperations()2120cdf0e10cSrcweir IDocumentContentOperations* SwNode::getIDocumentContentOperations() { return GetDoc(); }
getIDocumentStyleAccess()2121cdf0e10cSrcweir IStyleAccess& SwNode::getIDocumentStyleAccess() { return GetDoc()->GetIStyleAccess(); }
2122cdf0e10cSrcweir // --> OD 2007-10-31 #i83479#
getIDocumentListItems()2123cdf0e10cSrcweir IDocumentListItems& SwNode::getIDocumentListItems()
2124cdf0e10cSrcweir {
2125cdf0e10cSrcweir     return *GetDoc();
2126cdf0e10cSrcweir }
2127cdf0e10cSrcweir // <--
2128cdf0e10cSrcweir 
IsInRedlines() const2129cdf0e10cSrcweir sal_Bool SwNode::IsInRedlines() const
2130cdf0e10cSrcweir {
2131cdf0e10cSrcweir     const SwDoc * pDoc = GetDoc();
2132cdf0e10cSrcweir     sal_Bool bResult = sal_False;
2133cdf0e10cSrcweir 
2134cdf0e10cSrcweir     if (pDoc != NULL)
2135cdf0e10cSrcweir         bResult = pDoc->IsInRedlines(*this);
2136cdf0e10cSrcweir 
2137cdf0e10cSrcweir     return bResult;
2138cdf0e10cSrcweir }
2139