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 <svl/smplhint.hxx>
28cdf0e10cSrcweir #include <hintids.hxx>
29cdf0e10cSrcweir #include <sfx2/linkmgr.hxx>
30cdf0e10cSrcweir #include <svl/itemiter.hxx>
31cdf0e10cSrcweir #include <tools/resid.hxx>
32cdf0e10cSrcweir #include <fmtcntnt.hxx>
33cdf0e10cSrcweir #include <fmtanchr.hxx>
34cdf0e10cSrcweir #include <txtftn.hxx>
35cdf0e10cSrcweir #include <fmtclds.hxx>
36cdf0e10cSrcweir #include <doc.hxx>
37cdf0e10cSrcweir #include <IDocumentUndoRedo.hxx>
38cdf0e10cSrcweir #include <rootfrm.hxx>
39cdf0e10cSrcweir #include <pam.hxx>
40cdf0e10cSrcweir #include <ndtxt.hxx>
41cdf0e10cSrcweir #include <section.hxx>
42cdf0e10cSrcweir #include <UndoSection.hxx>
43cdf0e10cSrcweir #include <UndoDelete.hxx>
44cdf0e10cSrcweir #include <swundo.hxx>
45cdf0e10cSrcweir #include <calc.hxx>
46cdf0e10cSrcweir #include <swtable.hxx>
47cdf0e10cSrcweir #include <swserv.hxx>
48cdf0e10cSrcweir #include <frmfmt.hxx>
49cdf0e10cSrcweir #include <frmtool.hxx>
50cdf0e10cSrcweir #include <ftnidx.hxx>
51cdf0e10cSrcweir #include <docary.hxx>
52cdf0e10cSrcweir #include <redline.hxx>
53cdf0e10cSrcweir #include <sectfrm.hxx>
54cdf0e10cSrcweir #include <pagefrm.hxx>
55cdf0e10cSrcweir #include <cntfrm.hxx>
56cdf0e10cSrcweir #include <node2lay.hxx>
57cdf0e10cSrcweir #include <doctxm.hxx>
58cdf0e10cSrcweir #include <fmtftntx.hxx>
59cdf0e10cSrcweir #include <comcore.hrc>
60cdf0e10cSrcweir // --> OD 2005-12-01 #i27138#
61cdf0e10cSrcweir #include <viewsh.hxx>
62cdf0e10cSrcweir #include <txtfrm.hxx>
63cdf0e10cSrcweir // <--
64cdf0e10cSrcweir
65cdf0e10cSrcweir
66cdf0e10cSrcweir // OD 04.11.2003 #i21457# - new implementation of local method <lcl_IsInSameTblBox(..)>.
67cdf0e10cSrcweir // Method now determines the previous/next on its own. Thus, it can be controlled,
68cdf0e10cSrcweir // for which previous/next is checked, if it's visible.
lcl_IsInSameTblBox(SwNodes & _rNds,const SwNode & _rNd,const bool _bPrev)69cdf0e10cSrcweir bool lcl_IsInSameTblBox( SwNodes& _rNds,
70cdf0e10cSrcweir const SwNode& _rNd,
71cdf0e10cSrcweir const bool _bPrev )
72cdf0e10cSrcweir {
73cdf0e10cSrcweir const SwTableNode* pTblNd = _rNd.FindTableNode();
74cdf0e10cSrcweir if ( !pTblNd )
75cdf0e10cSrcweir {
76cdf0e10cSrcweir return true;
77cdf0e10cSrcweir }
78cdf0e10cSrcweir
79cdf0e10cSrcweir // determine index to be checked. Its assumed that a previous/next exist.
80cdf0e10cSrcweir SwNodeIndex aChkIdx( _rNd );
81cdf0e10cSrcweir {
82cdf0e10cSrcweir // determine index of previous/next - skip hidden ones, which are
83cdf0e10cSrcweir // inside the table.
84cdf0e10cSrcweir // If found one is before/after table, this one isn't in the same
85cdf0e10cSrcweir // table box as <_rNd>.
86cdf0e10cSrcweir bool bFound = false;
87cdf0e10cSrcweir do
88cdf0e10cSrcweir {
89cdf0e10cSrcweir if ( _bPrev
90cdf0e10cSrcweir ? !_rNds.GoPrevSection( &aChkIdx, sal_False, sal_False )
91cdf0e10cSrcweir : !_rNds.GoNextSection( &aChkIdx, sal_False, sal_False ) )
92cdf0e10cSrcweir {
93cdf0e10cSrcweir ASSERT( false, "<lcl_IsInSameTblBox(..)> - no previous/next!" );
94cdf0e10cSrcweir return false;
95cdf0e10cSrcweir }
96cdf0e10cSrcweir else
97cdf0e10cSrcweir {
98cdf0e10cSrcweir if ( aChkIdx < pTblNd->GetIndex() ||
99cdf0e10cSrcweir aChkIdx > pTblNd->EndOfSectionNode()->GetIndex() )
100cdf0e10cSrcweir {
101cdf0e10cSrcweir return false;
102cdf0e10cSrcweir }
103cdf0e10cSrcweir else
104cdf0e10cSrcweir {
105cdf0e10cSrcweir // check, if found one isn't inside a hidden section, which
106cdf0e10cSrcweir // is also inside the table.
107cdf0e10cSrcweir SwSectionNode* pSectNd = aChkIdx.GetNode().FindSectionNode();
108cdf0e10cSrcweir if ( !pSectNd ||
109cdf0e10cSrcweir pSectNd->GetIndex() < pTblNd->GetIndex() ||
110cdf0e10cSrcweir !pSectNd->GetSection().IsHiddenFlag() )
111cdf0e10cSrcweir {
112cdf0e10cSrcweir bFound = true;
113cdf0e10cSrcweir }
114cdf0e10cSrcweir }
115cdf0e10cSrcweir }
116cdf0e10cSrcweir } while ( !bFound );
117cdf0e10cSrcweir }
118cdf0e10cSrcweir
119cdf0e10cSrcweir // dann suche den StartNode der Box
120cdf0e10cSrcweir const SwTableSortBoxes& rSortBoxes = pTblNd->GetTable().GetTabSortBoxes();
121cdf0e10cSrcweir sal_uLong nIdx = _rNd.GetIndex();
122cdf0e10cSrcweir for( sal_uInt16 n = 0; n < rSortBoxes.Count(); ++n )
123cdf0e10cSrcweir {
124cdf0e10cSrcweir const SwStartNode* pNd = rSortBoxes[ n ]->GetSttNd();
125cdf0e10cSrcweir if ( pNd->GetIndex() < nIdx && nIdx < pNd->EndOfSectionIndex() )
126cdf0e10cSrcweir {
127cdf0e10cSrcweir // dann muss der andere Index in derselben Section liegen
128cdf0e10cSrcweir nIdx = aChkIdx.GetIndex();
129cdf0e10cSrcweir return pNd->GetIndex() < nIdx && nIdx < pNd->EndOfSectionIndex();
130cdf0e10cSrcweir }
131cdf0e10cSrcweir }
132cdf0e10cSrcweir
133cdf0e10cSrcweir return true;
134cdf0e10cSrcweir }
135cdf0e10cSrcweir
lcl_CheckEmptyLayFrm(SwNodes & rNds,SwSectionData & rSectionData,const SwNode & rStt,const SwNode & rEnd)136cdf0e10cSrcweir void lcl_CheckEmptyLayFrm( SwNodes& rNds, SwSectionData& rSectionData,
137cdf0e10cSrcweir const SwNode& rStt, const SwNode& rEnd )
138cdf0e10cSrcweir {
139cdf0e10cSrcweir SwNodeIndex aIdx( rStt );
140cdf0e10cSrcweir if( !rNds.GoPrevSection( &aIdx, sal_True, sal_False ) ||
141cdf0e10cSrcweir !CheckNodesRange( rStt, aIdx, sal_True ) ||
142cdf0e10cSrcweir // OD 04.11.2003 #i21457#
143cdf0e10cSrcweir !lcl_IsInSameTblBox( rNds, rStt, true ))
144cdf0e10cSrcweir {
145cdf0e10cSrcweir aIdx = rEnd;
146cdf0e10cSrcweir if( !rNds.GoNextSection( &aIdx, sal_True, sal_False ) ||
147cdf0e10cSrcweir !CheckNodesRange( rEnd, aIdx, sal_True ) ||
148cdf0e10cSrcweir // OD 04.11.2003 #i21457#
149cdf0e10cSrcweir !lcl_IsInSameTblBox( rNds, rEnd, false ))
150cdf0e10cSrcweir {
151cdf0e10cSrcweir rSectionData.SetHidden( false );
152cdf0e10cSrcweir }
153cdf0e10cSrcweir }
154cdf0e10cSrcweir }
155cdf0e10cSrcweir
156cdf0e10cSrcweir SwSection *
InsertSwSection(SwPaM const & rRange,SwSectionData & rNewData,SwTOXBase const * const pTOXBase,SfxItemSet const * const pAttr,bool const bUpdate)157cdf0e10cSrcweir SwDoc::InsertSwSection(SwPaM const& rRange, SwSectionData & rNewData,
158cdf0e10cSrcweir SwTOXBase const*const pTOXBase,
159cdf0e10cSrcweir SfxItemSet const*const pAttr, bool const bUpdate)
160cdf0e10cSrcweir {
161cdf0e10cSrcweir const SwNode* pPrvNd = 0;
162cdf0e10cSrcweir sal_uInt16 nRegionRet = 0;
163cdf0e10cSrcweir if( rRange.HasMark() &&
164cdf0e10cSrcweir 0 == ( nRegionRet = IsInsRegionAvailable( rRange, &pPrvNd ) ))
165cdf0e10cSrcweir {
166*870262e3SDon Lewis ASSERT( sal_False, "Selection over different sections" );
167cdf0e10cSrcweir return 0;
168cdf0e10cSrcweir }
169cdf0e10cSrcweir
170cdf0e10cSrcweir // Teste ob das gesamte Dokument versteckt werden soll,
171cdf0e10cSrcweir // koennen wir zur Zeit nicht !!!!
172cdf0e10cSrcweir if (rNewData.IsHidden() && rRange.HasMark())
173cdf0e10cSrcweir {
174cdf0e10cSrcweir const SwPosition *pStt = rRange.Start(), *pEnd = rRange.End();
175cdf0e10cSrcweir if( !pStt->nContent.GetIndex() &&
176cdf0e10cSrcweir pEnd->nNode.GetNode().GetCntntNode()->Len() ==
177cdf0e10cSrcweir pEnd->nContent.GetIndex() )
178cdf0e10cSrcweir {
179cdf0e10cSrcweir ::lcl_CheckEmptyLayFrm( GetNodes(),
180cdf0e10cSrcweir rNewData,
181cdf0e10cSrcweir pStt->nNode.GetNode(),
182cdf0e10cSrcweir pEnd->nNode.GetNode() );
183cdf0e10cSrcweir }
184cdf0e10cSrcweir }
185cdf0e10cSrcweir
186cdf0e10cSrcweir SwUndoInsSection* pUndoInsSect = 0;
187cdf0e10cSrcweir bool const bUndo(GetIDocumentUndoRedo().DoesUndo());
188cdf0e10cSrcweir if (bUndo)
189cdf0e10cSrcweir {
190cdf0e10cSrcweir pUndoInsSect = new SwUndoInsSection(rRange, rNewData, pAttr, pTOXBase);
191cdf0e10cSrcweir GetIDocumentUndoRedo().AppendUndo( pUndoInsSect );
192cdf0e10cSrcweir GetIDocumentUndoRedo().DoUndo(false);
193cdf0e10cSrcweir }
194cdf0e10cSrcweir
195cdf0e10cSrcweir SwSectionFmt* const pFmt = MakeSectionFmt( 0 );
196cdf0e10cSrcweir if ( pAttr )
197cdf0e10cSrcweir {
198cdf0e10cSrcweir pFmt->SetFmtAttr( *pAttr );
199cdf0e10cSrcweir }
200cdf0e10cSrcweir
201cdf0e10cSrcweir SwSectionNode* pNewSectNode = 0;
202cdf0e10cSrcweir
203cdf0e10cSrcweir RedlineMode_t eOld = GetRedlineMode();
204cdf0e10cSrcweir SetRedlineMode_intern( (RedlineMode_t)((eOld & ~nsRedlineMode_t::REDLINE_SHOW_MASK) | nsRedlineMode_t::REDLINE_IGNORE));
205cdf0e10cSrcweir
206cdf0e10cSrcweir if( rRange.HasMark() )
207cdf0e10cSrcweir {
208cdf0e10cSrcweir SwPosition *pSttPos = (SwPosition*)rRange.Start(),
209cdf0e10cSrcweir *pEndPos = (SwPosition*)rRange.End();
210cdf0e10cSrcweir if( pPrvNd && 3 == nRegionRet )
211cdf0e10cSrcweir {
212cdf0e10cSrcweir ASSERT( pPrvNd, "der SectionNode fehlt" );
213cdf0e10cSrcweir SwNodeIndex aStt( pSttPos->nNode ), aEnd( pEndPos->nNode, +1 );
214cdf0e10cSrcweir while( pPrvNd != aStt.GetNode().StartOfSectionNode() )
215cdf0e10cSrcweir aStt--;
216cdf0e10cSrcweir while( pPrvNd != aEnd.GetNode().StartOfSectionNode() )
217cdf0e10cSrcweir aEnd++;
218cdf0e10cSrcweir
219cdf0e10cSrcweir --aEnd; // im InsertSection ist Ende inclusive
220cdf0e10cSrcweir pNewSectNode = GetNodes().InsertTextSection(
221cdf0e10cSrcweir aStt, *pFmt, rNewData, pTOXBase, & aEnd);
222cdf0e10cSrcweir }
223cdf0e10cSrcweir else
224cdf0e10cSrcweir {
225cdf0e10cSrcweir if( pUndoInsSect )
226cdf0e10cSrcweir {
227cdf0e10cSrcweir if( !( pPrvNd && 1 == nRegionRet ) &&
228cdf0e10cSrcweir pSttPos->nContent.GetIndex() )
229cdf0e10cSrcweir {
230cdf0e10cSrcweir SwTxtNode* const pTNd =
231cdf0e10cSrcweir pSttPos->nNode.GetNode().GetTxtNode();
232cdf0e10cSrcweir if (pTNd)
233cdf0e10cSrcweir {
234cdf0e10cSrcweir pUndoInsSect->SaveSplitNode( pTNd, sal_True );
235cdf0e10cSrcweir }
236cdf0e10cSrcweir }
237cdf0e10cSrcweir
238cdf0e10cSrcweir if ( !( pPrvNd && 2 == nRegionRet ) )
239cdf0e10cSrcweir {
240cdf0e10cSrcweir SwTxtNode *const pTNd =
241cdf0e10cSrcweir pEndPos->nNode.GetNode().GetTxtNode();
242cdf0e10cSrcweir if (pTNd &&
243cdf0e10cSrcweir (pTNd->GetTxt().Len() != pEndPos->nContent.GetIndex()))
244cdf0e10cSrcweir {
245cdf0e10cSrcweir pUndoInsSect->SaveSplitNode( pTNd, sal_False );
246cdf0e10cSrcweir }
247cdf0e10cSrcweir }
248cdf0e10cSrcweir }
249cdf0e10cSrcweir
250cdf0e10cSrcweir const SwCntntNode* pCNd;
251cdf0e10cSrcweir if( pPrvNd && 1 == nRegionRet )
252cdf0e10cSrcweir {
253cdf0e10cSrcweir pSttPos->nNode.Assign( *pPrvNd );
254cdf0e10cSrcweir pSttPos->nContent.Assign( pSttPos->nNode.GetNode().GetCntntNode(), 0 );
255cdf0e10cSrcweir }
256cdf0e10cSrcweir else if( pSttPos->nContent.GetIndex() )
257cdf0e10cSrcweir {
258cdf0e10cSrcweir SplitNode( *pSttPos, false );
259cdf0e10cSrcweir }
260cdf0e10cSrcweir
261cdf0e10cSrcweir if( pPrvNd && 2 == nRegionRet )
262cdf0e10cSrcweir {
263cdf0e10cSrcweir pEndPos->nNode.Assign( *pPrvNd );
264cdf0e10cSrcweir pEndPos->nContent.Assign( pEndPos->nNode.GetNode().GetCntntNode(), 0 );
265cdf0e10cSrcweir }
266cdf0e10cSrcweir else
267cdf0e10cSrcweir {
268cdf0e10cSrcweir pCNd = pEndPos->nNode.GetNode().GetCntntNode();
269cdf0e10cSrcweir if( pCNd && pCNd->Len() != pEndPos->nContent.GetIndex() )
270cdf0e10cSrcweir {
271cdf0e10cSrcweir xub_StrLen nCntnt = pSttPos->nContent.GetIndex();
272cdf0e10cSrcweir SplitNode( *pEndPos, false );
273cdf0e10cSrcweir
274cdf0e10cSrcweir SwTxtNode* pTNd;
275cdf0e10cSrcweir if( pEndPos->nNode.GetIndex() == pSttPos->nNode.GetIndex() )
276cdf0e10cSrcweir {
277cdf0e10cSrcweir pSttPos->nNode--;
278cdf0e10cSrcweir pEndPos->nNode--;
279cdf0e10cSrcweir pTNd = pSttPos->nNode.GetNode().GetTxtNode();
280cdf0e10cSrcweir pSttPos->nContent.Assign( pTNd, nCntnt );
281cdf0e10cSrcweir }
282cdf0e10cSrcweir else
283cdf0e10cSrcweir {
284cdf0e10cSrcweir // wieder ans Ende vom vorherigen setzen
285cdf0e10cSrcweir pEndPos->nNode--;
286cdf0e10cSrcweir pTNd = pEndPos->nNode.GetNode().GetTxtNode();
287cdf0e10cSrcweir }
288cdf0e10cSrcweir if( pTNd ) nCntnt = pTNd->GetTxt().Len(); else nCntnt = 0;
289cdf0e10cSrcweir pEndPos->nContent.Assign( pTNd, nCntnt );
290cdf0e10cSrcweir }
291cdf0e10cSrcweir }
292cdf0e10cSrcweir pNewSectNode = GetNodes().InsertTextSection(
293cdf0e10cSrcweir pSttPos->nNode, *pFmt, rNewData, pTOXBase, &pEndPos->nNode);
294cdf0e10cSrcweir }
295cdf0e10cSrcweir }
296cdf0e10cSrcweir else
297cdf0e10cSrcweir {
298cdf0e10cSrcweir const SwPosition* pPos = rRange.GetPoint();
299cdf0e10cSrcweir const SwCntntNode* pCNd = pPos->nNode.GetNode().GetCntntNode();
300cdf0e10cSrcweir if( !pPos->nContent.GetIndex() )
301cdf0e10cSrcweir {
302cdf0e10cSrcweir pNewSectNode = GetNodes().InsertTextSection(
303cdf0e10cSrcweir pPos->nNode, *pFmt, rNewData, pTOXBase, 0, true);
304cdf0e10cSrcweir }
305cdf0e10cSrcweir else if( pPos->nContent.GetIndex() == pCNd->Len() )
306cdf0e10cSrcweir {
307cdf0e10cSrcweir pNewSectNode = GetNodes().InsertTextSection(
308cdf0e10cSrcweir pPos->nNode, *pFmt, rNewData, pTOXBase, 0, false);
309cdf0e10cSrcweir }
310cdf0e10cSrcweir else
311cdf0e10cSrcweir {
312cdf0e10cSrcweir if( pUndoInsSect && pCNd->IsTxtNode() )
313cdf0e10cSrcweir {
314cdf0e10cSrcweir pUndoInsSect->SaveSplitNode( (SwTxtNode*)pCNd, sal_True );
315cdf0e10cSrcweir }
316cdf0e10cSrcweir SplitNode( *pPos, false );
317cdf0e10cSrcweir pNewSectNode = GetNodes().InsertTextSection(
318cdf0e10cSrcweir pPos->nNode, *pFmt, rNewData, pTOXBase, 0, true);
319cdf0e10cSrcweir }
320cdf0e10cSrcweir }
321cdf0e10cSrcweir
322cdf0e10cSrcweir //FEATURE::CONDCOLL
323cdf0e10cSrcweir pNewSectNode->CheckSectionCondColl();
324cdf0e10cSrcweir //FEATURE::CONDCOLL
325cdf0e10cSrcweir
326cdf0e10cSrcweir SetRedlineMode_intern( eOld );
327cdf0e10cSrcweir
328cdf0e10cSrcweir if( IsRedlineOn() || (!IsIgnoreRedline() && pRedlineTbl->Count() ))
329cdf0e10cSrcweir {
330cdf0e10cSrcweir SwPaM aPam( *pNewSectNode->EndOfSectionNode(), *pNewSectNode, 1 );
331cdf0e10cSrcweir if( IsRedlineOn() )
332cdf0e10cSrcweir {
333cdf0e10cSrcweir AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
334cdf0e10cSrcweir }
335cdf0e10cSrcweir else
336cdf0e10cSrcweir {
337cdf0e10cSrcweir SplitRedline( aPam );
338cdf0e10cSrcweir }
339cdf0e10cSrcweir }
340cdf0e10cSrcweir
341cdf0e10cSrcweir // ist eine Condition gesetzt
342cdf0e10cSrcweir if (rNewData.IsHidden() && rNewData.GetCondition().Len())
343cdf0e10cSrcweir {
344cdf0e10cSrcweir // dann berechne bis zu dieser Position
345cdf0e10cSrcweir SwCalc aCalc( *this );
346cdf0e10cSrcweir if( ! IsInReading() )
347cdf0e10cSrcweir {
348cdf0e10cSrcweir FldsToCalc( aCalc, pNewSectNode->GetIndex(), USHRT_MAX );
349cdf0e10cSrcweir }
350cdf0e10cSrcweir SwSection& rNewSect = pNewSectNode->GetSection();
351cdf0e10cSrcweir rNewSect.SetCondHidden( aCalc.Calculate( rNewSect.GetCondition() ).GetBool() );
352cdf0e10cSrcweir }
353cdf0e10cSrcweir
354cdf0e10cSrcweir sal_Bool bUpdateFtn = sal_False;
355cdf0e10cSrcweir if( GetFtnIdxs().Count() && pAttr )
356cdf0e10cSrcweir {
357cdf0e10cSrcweir sal_uInt16 nVal = ((SwFmtFtnAtTxtEnd&)pAttr->Get(
358cdf0e10cSrcweir RES_FTN_AT_TXTEND )).GetValue();
359cdf0e10cSrcweir if( ( FTNEND_ATTXTEND_OWNNUMSEQ == nVal ||
360cdf0e10cSrcweir FTNEND_ATTXTEND_OWNNUMANDFMT == nVal ) ||
361cdf0e10cSrcweir ( FTNEND_ATTXTEND_OWNNUMSEQ == ( nVal = ((SwFmtEndAtTxtEnd&)
362cdf0e10cSrcweir pAttr->Get( RES_END_AT_TXTEND )).GetValue() ) ||
363cdf0e10cSrcweir FTNEND_ATTXTEND_OWNNUMANDFMT == nVal ))
364cdf0e10cSrcweir {
365cdf0e10cSrcweir bUpdateFtn = sal_True;
366cdf0e10cSrcweir }
367cdf0e10cSrcweir }
368cdf0e10cSrcweir
369cdf0e10cSrcweir if( pUndoInsSect )
370cdf0e10cSrcweir {
371cdf0e10cSrcweir pUndoInsSect->SetSectNdPos( pNewSectNode->GetIndex() );
372cdf0e10cSrcweir pUndoInsSect->SetUpdtFtnFlag( bUpdateFtn );
373cdf0e10cSrcweir GetIDocumentUndoRedo().DoUndo(bUndo);
374cdf0e10cSrcweir }
375cdf0e10cSrcweir
376cdf0e10cSrcweir if (rNewData.IsLinkType())
377cdf0e10cSrcweir {
378cdf0e10cSrcweir pNewSectNode->GetSection().CreateLink( bUpdate ? CREATE_UPDATE : CREATE_CONNECT );
379cdf0e10cSrcweir }
380cdf0e10cSrcweir
381cdf0e10cSrcweir if( bUpdateFtn )
382cdf0e10cSrcweir {
383cdf0e10cSrcweir GetFtnIdxs().UpdateFtn( SwNodeIndex( *pNewSectNode ));
384cdf0e10cSrcweir }
385cdf0e10cSrcweir
386cdf0e10cSrcweir SetModified();
387cdf0e10cSrcweir return &pNewSectNode->GetSection();
388cdf0e10cSrcweir }
389cdf0e10cSrcweir
IsInsRegionAvailable(const SwPaM & rRange,const SwNode ** ppSttNd) const390cdf0e10cSrcweir sal_uInt16 SwDoc::IsInsRegionAvailable( const SwPaM& rRange,
391cdf0e10cSrcweir const SwNode** ppSttNd ) const
392cdf0e10cSrcweir {
393cdf0e10cSrcweir sal_uInt16 nRet = 1;
394cdf0e10cSrcweir if( rRange.HasMark() )
395cdf0e10cSrcweir {
396cdf0e10cSrcweir // teste ob es sich um eine gueltige Selektion handelt
397cdf0e10cSrcweir const SwPosition* pStt = rRange.Start(),
398cdf0e10cSrcweir * pEnd = rRange.End();
399cdf0e10cSrcweir
400cdf0e10cSrcweir const SwCntntNode* pCNd = pEnd->nNode.GetNode().GetCntntNode();
401cdf0e10cSrcweir const SwNode* pNd = &pStt->nNode.GetNode();
402cdf0e10cSrcweir const SwSectionNode* pSectNd = pNd->FindSectionNode();
403cdf0e10cSrcweir const SwSectionNode* pEndSectNd = pCNd ? pCNd->FindSectionNode() : 0;
404cdf0e10cSrcweir if( pSectNd && pEndSectNd && pSectNd != pEndSectNd )
405cdf0e10cSrcweir {
406cdf0e10cSrcweir // versuche eine umschliessende Section zu erzeugen
407cdf0e10cSrcweir // Aber, nur wenn der Start am Sectionanfang und das Ende am
408cdf0e10cSrcweir // Section Ende liegt!
409cdf0e10cSrcweir nRet = 0;
410cdf0e10cSrcweir if( !pStt->nContent.GetIndex() && pSectNd->GetIndex()
411cdf0e10cSrcweir == pStt->nNode.GetIndex() - 1 && pEnd->nContent.GetIndex() ==
412cdf0e10cSrcweir pCNd->Len() )
413cdf0e10cSrcweir {
414cdf0e10cSrcweir SwNodeIndex aIdx( pStt->nNode, -1 );
415cdf0e10cSrcweir sal_uLong nCmp = pEnd->nNode.GetIndex();
416cdf0e10cSrcweir const SwStartNode* pPrvNd;
417cdf0e10cSrcweir const SwEndNode* pNxtNd;
418cdf0e10cSrcweir while( 0 != ( pPrvNd = (pNd = &aIdx.GetNode())->GetSectionNode() ) &&
419cdf0e10cSrcweir !( aIdx.GetIndex() < nCmp &&
420cdf0e10cSrcweir nCmp < pPrvNd->EndOfSectionIndex() ) )
421cdf0e10cSrcweir {
422cdf0e10cSrcweir aIdx--;
423cdf0e10cSrcweir }
424cdf0e10cSrcweir if( !pPrvNd )
425cdf0e10cSrcweir pPrvNd = pNd->IsStartNode() ? (SwStartNode*)pNd
426cdf0e10cSrcweir : pNd->StartOfSectionNode();
427cdf0e10cSrcweir
428cdf0e10cSrcweir aIdx = pEnd->nNode.GetIndex() + 1;
429cdf0e10cSrcweir nCmp = pStt->nNode.GetIndex();
430cdf0e10cSrcweir while( 0 != ( pNxtNd = (pNd = &aIdx.GetNode())->GetEndNode() ) &&
431cdf0e10cSrcweir pNxtNd->StartOfSectionNode()->IsSectionNode() &&
432cdf0e10cSrcweir !( pNxtNd->StartOfSectionIndex() < nCmp &&
433cdf0e10cSrcweir nCmp < aIdx.GetIndex() ) )
434cdf0e10cSrcweir {
435cdf0e10cSrcweir aIdx++;
436cdf0e10cSrcweir }
437cdf0e10cSrcweir if( !pNxtNd )
438cdf0e10cSrcweir pNxtNd = pNd->EndOfSectionNode();
439cdf0e10cSrcweir
440cdf0e10cSrcweir if( pPrvNd && pNxtNd && pPrvNd == pNxtNd->StartOfSectionNode() )
441cdf0e10cSrcweir {
442cdf0e10cSrcweir nRet = 3;
443cdf0e10cSrcweir
444cdf0e10cSrcweir if( ppSttNd )
445cdf0e10cSrcweir *ppSttNd = pPrvNd;
446cdf0e10cSrcweir }
447cdf0e10cSrcweir }
448cdf0e10cSrcweir }
449cdf0e10cSrcweir else if( !pSectNd && pEndSectNd )
450cdf0e10cSrcweir {
451015b7d31SHerbert Dürr // try to create a section enclosing it if the end is at the section end
452cdf0e10cSrcweir nRet = 0;
453cdf0e10cSrcweir if( pEnd->nContent.GetIndex() == pCNd->Len() )
454cdf0e10cSrcweir {
455cdf0e10cSrcweir SwNodeIndex aIdx( pEnd->nNode, 1 );
456cdf0e10cSrcweir if( aIdx.GetNode().IsEndNode() &&
457cdf0e10cSrcweir 0 != aIdx.GetNode().FindSectionNode() )
458cdf0e10cSrcweir {
459cdf0e10cSrcweir do {
460cdf0e10cSrcweir aIdx++;
461cdf0e10cSrcweir } while( aIdx.GetNode().IsEndNode() &&
462cdf0e10cSrcweir 0 != aIdx.GetNode().FindSectionNode() );
463cdf0e10cSrcweir // if( !aIdx.GetNode().IsEndNode() )
464cdf0e10cSrcweir {
465cdf0e10cSrcweir nRet = 2;
466cdf0e10cSrcweir if( ppSttNd )
467cdf0e10cSrcweir {
468cdf0e10cSrcweir aIdx--;
469cdf0e10cSrcweir *ppSttNd = &aIdx.GetNode();
470cdf0e10cSrcweir }
471cdf0e10cSrcweir }
472cdf0e10cSrcweir }
473cdf0e10cSrcweir }
474cdf0e10cSrcweir }
475cdf0e10cSrcweir else if( pSectNd && !pEndSectNd )
476cdf0e10cSrcweir {
477015b7d31SHerbert Dürr // try to create a section enclosing it if the start is at the section start
478cdf0e10cSrcweir nRet = 0;
479cdf0e10cSrcweir if( !pStt->nContent.GetIndex() )
480cdf0e10cSrcweir {
481cdf0e10cSrcweir SwNodeIndex aIdx( pStt->nNode, -1 );
482cdf0e10cSrcweir if( aIdx.GetNode().IsSectionNode() )
483cdf0e10cSrcweir {
484cdf0e10cSrcweir do {
485cdf0e10cSrcweir aIdx--;
486cdf0e10cSrcweir } while( aIdx.GetNode().IsSectionNode() );
487cdf0e10cSrcweir if( !aIdx.GetNode().IsSectionNode() )
488cdf0e10cSrcweir {
489cdf0e10cSrcweir nRet = 1;
490cdf0e10cSrcweir if( ppSttNd )
491cdf0e10cSrcweir {
492cdf0e10cSrcweir aIdx++;
493cdf0e10cSrcweir *ppSttNd = &aIdx.GetNode();
494cdf0e10cSrcweir }
495cdf0e10cSrcweir }
496cdf0e10cSrcweir }
497cdf0e10cSrcweir }
498cdf0e10cSrcweir }
499cdf0e10cSrcweir }
500cdf0e10cSrcweir return nRet;
501cdf0e10cSrcweir }
502cdf0e10cSrcweir
GetCurrSection(const SwPosition & rPos) const503cdf0e10cSrcweir SwSection* SwDoc::GetCurrSection( const SwPosition& rPos ) const
504cdf0e10cSrcweir {
505cdf0e10cSrcweir const SwSectionNode* pSectNd = rPos.nNode.GetNode().FindSectionNode();
506cdf0e10cSrcweir if( pSectNd )
507cdf0e10cSrcweir return (SwSection*)&pSectNd->GetSection();
508cdf0e10cSrcweir return 0;
509cdf0e10cSrcweir }
510cdf0e10cSrcweir
MakeSectionFmt(SwSectionFmt * pDerivedFrom)511cdf0e10cSrcweir SwSectionFmt* SwDoc::MakeSectionFmt( SwSectionFmt *pDerivedFrom )
512cdf0e10cSrcweir {
513cdf0e10cSrcweir if( !pDerivedFrom )
514cdf0e10cSrcweir pDerivedFrom = (SwSectionFmt*)pDfltFrmFmt;
515cdf0e10cSrcweir SwSectionFmt* pNew = new SwSectionFmt( pDerivedFrom, this );
516cdf0e10cSrcweir pSectionFmtTbl->Insert( pNew, pSectionFmtTbl->Count() );
517cdf0e10cSrcweir return pNew;
518cdf0e10cSrcweir }
519cdf0e10cSrcweir
DelSectionFmt(SwSectionFmt * pFmt,sal_Bool bDelNodes)520cdf0e10cSrcweir void SwDoc::DelSectionFmt( SwSectionFmt *pFmt, sal_Bool bDelNodes )
521cdf0e10cSrcweir {
522cdf0e10cSrcweir sal_uInt16 nPos = pSectionFmtTbl->GetPos( pFmt );
523cdf0e10cSrcweir
524cdf0e10cSrcweir GetIDocumentUndoRedo().StartUndo(UNDO_DELSECTION, NULL);
525cdf0e10cSrcweir
526cdf0e10cSrcweir if( USHRT_MAX != nPos )
527cdf0e10cSrcweir {
528cdf0e10cSrcweir const SwNodeIndex* pIdx = pFmt->GetCntnt( sal_False ).GetCntntIdx();
529cdf0e10cSrcweir const SfxPoolItem* pFtnEndAtTxtEnd;
530cdf0e10cSrcweir if( SFX_ITEM_SET != pFmt->GetItemState(
531cdf0e10cSrcweir RES_FTN_AT_TXTEND, sal_True, &pFtnEndAtTxtEnd ) ||
532cdf0e10cSrcweir SFX_ITEM_SET != pFmt->GetItemState(
533cdf0e10cSrcweir RES_END_AT_TXTEND, sal_True, &pFtnEndAtTxtEnd ))
534cdf0e10cSrcweir pFtnEndAtTxtEnd = 0;
535cdf0e10cSrcweir
536cdf0e10cSrcweir const SwSectionNode* pSectNd;
537cdf0e10cSrcweir
538cdf0e10cSrcweir if( GetIDocumentUndoRedo().DoesUndo() )
539cdf0e10cSrcweir {
540cdf0e10cSrcweir if( bDelNodes && pIdx && &GetNodes() == &pIdx->GetNodes() &&
541cdf0e10cSrcweir 0 != (pSectNd = pIdx->GetNode().GetSectionNode() ))
542cdf0e10cSrcweir {
543cdf0e10cSrcweir SwNodeIndex aUpdIdx( *pIdx );
544cdf0e10cSrcweir SwPaM aPaM( *pSectNd->EndOfSectionNode(), *pSectNd );
545cdf0e10cSrcweir GetIDocumentUndoRedo().AppendUndo( new SwUndoDelete( aPaM ));
546cdf0e10cSrcweir if( pFtnEndAtTxtEnd )
547cdf0e10cSrcweir GetFtnIdxs().UpdateFtn( aUpdIdx );
548cdf0e10cSrcweir SetModified();
549cdf0e10cSrcweir //#126178# start/end undo have to be pairs!
550cdf0e10cSrcweir GetIDocumentUndoRedo().EndUndo(UNDO_DELSECTION, NULL);
551cdf0e10cSrcweir return ;
552cdf0e10cSrcweir }
553cdf0e10cSrcweir GetIDocumentUndoRedo().AppendUndo( MakeUndoDelSection( *pFmt ) );
554cdf0e10cSrcweir }
555cdf0e10cSrcweir else if( bDelNodes && pIdx && &GetNodes() == &pIdx->GetNodes() &&
556cdf0e10cSrcweir 0 != (pSectNd = pIdx->GetNode().GetSectionNode() ))
557cdf0e10cSrcweir {
558cdf0e10cSrcweir SwNodeIndex aUpdIdx( *pIdx );
559cdf0e10cSrcweir DeleteSection( (SwNode*)pSectNd );
560cdf0e10cSrcweir if( pFtnEndAtTxtEnd )
561cdf0e10cSrcweir GetFtnIdxs().UpdateFtn( aUpdIdx );
562cdf0e10cSrcweir SetModified();
563cdf0e10cSrcweir //#126178# start/end undo have to be pairs!
564cdf0e10cSrcweir GetIDocumentUndoRedo().EndUndo(UNDO_DELSECTION, NULL);
565cdf0e10cSrcweir return ;
566cdf0e10cSrcweir }
567cdf0e10cSrcweir
568cdf0e10cSrcweir {
569cdf0e10cSrcweir SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT, pFmt );
570cdf0e10cSrcweir pFmt->ModifyNotification( &aMsgHint, &aMsgHint );
571cdf0e10cSrcweir }
572cdf0e10cSrcweir
573cdf0e10cSrcweir // A ClearRedo could result in a rekursive call of this function and delete some section
574cdf0e10cSrcweir // formats => the position iside the SectionFmtTbl could have changed
575cdf0e10cSrcweir nPos = pSectionFmtTbl->GetPos( pFmt );
576cdf0e10cSrcweir
577cdf0e10cSrcweir // ACHTUNG: erst aus dem Array entfernen und dann loeschen.
578cdf0e10cSrcweir // Der Section-DTOR versucht selbst noch sein Format
579cdf0e10cSrcweir // zu loeschen!
580cdf0e10cSrcweir pSectionFmtTbl->Remove( nPos );
581cdf0e10cSrcweir //FEATURE::CONDCOLL
582cdf0e10cSrcweir sal_uLong nCnt = 0, nSttNd = 0;
583cdf0e10cSrcweir if( pIdx && &GetNodes() == &pIdx->GetNodes() &&
584cdf0e10cSrcweir 0 != (pSectNd = pIdx->GetNode().GetSectionNode() ))
585cdf0e10cSrcweir {
586cdf0e10cSrcweir nSttNd = pSectNd->GetIndex();
587cdf0e10cSrcweir nCnt = pSectNd->EndOfSectionIndex() - nSttNd - 1;
588cdf0e10cSrcweir }
589cdf0e10cSrcweir //FEATURE::CONDCOLL
590cdf0e10cSrcweir
591cdf0e10cSrcweir delete pFmt;
592cdf0e10cSrcweir
593cdf0e10cSrcweir if( nSttNd && pFtnEndAtTxtEnd )
594cdf0e10cSrcweir {
595cdf0e10cSrcweir SwNodeIndex aUpdIdx( GetNodes(), nSttNd );
596cdf0e10cSrcweir GetFtnIdxs().UpdateFtn( aUpdIdx );
597cdf0e10cSrcweir }
598cdf0e10cSrcweir
599cdf0e10cSrcweir //FEATURE::CONDCOLL
600cdf0e10cSrcweir SwCntntNode* pCNd;
601cdf0e10cSrcweir for( ; nCnt--; ++nSttNd )
602cdf0e10cSrcweir if( 0 != (pCNd = GetNodes()[ nSttNd ]->GetCntntNode() ) &&
603cdf0e10cSrcweir RES_CONDTXTFMTCOLL == pCNd->GetFmtColl()->Which() )
604cdf0e10cSrcweir pCNd->ChkCondColl();
605cdf0e10cSrcweir //FEATURE::CONDCOLL
606cdf0e10cSrcweir }
607cdf0e10cSrcweir
608cdf0e10cSrcweir GetIDocumentUndoRedo().EndUndo(UNDO_DELSECTION, NULL);
609cdf0e10cSrcweir
610cdf0e10cSrcweir SetModified();
611cdf0e10cSrcweir }
612cdf0e10cSrcweir
UpdateSection(sal_uInt16 const nPos,SwSectionData & rNewData,SfxItemSet const * const pAttr,bool const bPreventLinkUpdate)613cdf0e10cSrcweir void SwDoc::UpdateSection(sal_uInt16 const nPos, SwSectionData & rNewData,
614cdf0e10cSrcweir SfxItemSet const*const pAttr, bool const bPreventLinkUpdate)
615cdf0e10cSrcweir {
616cdf0e10cSrcweir SwSectionFmt* pFmt = (*pSectionFmtTbl)[ nPos ];
617cdf0e10cSrcweir SwSection* pSection = pFmt->GetSection();
618cdf0e10cSrcweir /// OD 04.10.2002 #102894#
619cdf0e10cSrcweir /// remember hidden condition flag of SwSection before changes
620cdf0e10cSrcweir bool bOldCondHidden = pSection->IsCondHidden() ? true : false;
621cdf0e10cSrcweir
622cdf0e10cSrcweir if (pSection->DataEquals(rNewData))
623cdf0e10cSrcweir {
624cdf0e10cSrcweir // die Attribute ueberpruefen
625cdf0e10cSrcweir sal_Bool bOnlyAttrChg = sal_False;
626cdf0e10cSrcweir if( pAttr && pAttr->Count() )
627cdf0e10cSrcweir {
628cdf0e10cSrcweir SfxItemIter aIter( *pAttr );
629cdf0e10cSrcweir sal_uInt16 nWhich = aIter.GetCurItem()->Which();
630cdf0e10cSrcweir while( sal_True )
631cdf0e10cSrcweir {
632cdf0e10cSrcweir if( pFmt->GetFmtAttr( nWhich ) != *aIter.GetCurItem() )
633cdf0e10cSrcweir {
634cdf0e10cSrcweir bOnlyAttrChg = sal_True;
635cdf0e10cSrcweir break;
636cdf0e10cSrcweir }
637cdf0e10cSrcweir
638cdf0e10cSrcweir if( aIter.IsAtEnd() )
639cdf0e10cSrcweir break;
640cdf0e10cSrcweir nWhich = aIter.NextItem()->Which();
641cdf0e10cSrcweir }
642cdf0e10cSrcweir }
643cdf0e10cSrcweir
644cdf0e10cSrcweir if( bOnlyAttrChg )
645cdf0e10cSrcweir {
646cdf0e10cSrcweir if (GetIDocumentUndoRedo().DoesUndo())
647cdf0e10cSrcweir {
648cdf0e10cSrcweir GetIDocumentUndoRedo().AppendUndo(
649cdf0e10cSrcweir MakeUndoUpdateSection( *pFmt, true ) );
650cdf0e10cSrcweir }
651cdf0e10cSrcweir // #i32968# Inserting columns in the section causes MakeFrmFmt
652cdf0e10cSrcweir // to put two objects of type SwUndoFrmFmt on the undo stack.
653cdf0e10cSrcweir // We don't want them.
654cdf0e10cSrcweir ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
655cdf0e10cSrcweir pFmt->SetFmtAttr( *pAttr );
656cdf0e10cSrcweir SetModified();
657cdf0e10cSrcweir }
658cdf0e10cSrcweir return;
659cdf0e10cSrcweir }
660cdf0e10cSrcweir
661cdf0e10cSrcweir // Teste ob eine gesamte Content-Section (Dokument/TabellenBox/Fly)
662cdf0e10cSrcweir // versteckt werden soll, koennen wir zur Zeit nicht !!!!
663cdf0e10cSrcweir const SwNodeIndex* pIdx = 0;
664cdf0e10cSrcweir {
665cdf0e10cSrcweir if (rNewData.IsHidden())
666cdf0e10cSrcweir {
667cdf0e10cSrcweir pIdx = pFmt->GetCntnt().GetCntntIdx();
668cdf0e10cSrcweir if (pIdx)
669cdf0e10cSrcweir {
670cdf0e10cSrcweir const SwSectionNode* pSectNd =
671cdf0e10cSrcweir pIdx->GetNode().GetSectionNode();
672cdf0e10cSrcweir if (pSectNd)
673cdf0e10cSrcweir {
674cdf0e10cSrcweir ::lcl_CheckEmptyLayFrm( GetNodes(), rNewData,
675cdf0e10cSrcweir *pSectNd, *pSectNd->EndOfSectionNode() );
676cdf0e10cSrcweir }
677cdf0e10cSrcweir }
678cdf0e10cSrcweir }
679cdf0e10cSrcweir }
680cdf0e10cSrcweir
681cdf0e10cSrcweir if (GetIDocumentUndoRedo().DoesUndo())
682cdf0e10cSrcweir {
683cdf0e10cSrcweir GetIDocumentUndoRedo().AppendUndo(MakeUndoUpdateSection(*pFmt, false));
684cdf0e10cSrcweir }
685cdf0e10cSrcweir // #i32968# Inserting columns in the section causes MakeFrmFmt to put two
686cdf0e10cSrcweir // objects of type SwUndoFrmFmt on the undo stack. We don't want them.
687cdf0e10cSrcweir ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
688cdf0e10cSrcweir
689cdf0e10cSrcweir // #56167# Der LinkFileName koennte auch nur aus Separatoren bestehen
690cdf0e10cSrcweir String sCompareString = sfx2::cTokenSeperator;
691cdf0e10cSrcweir sCompareString += sfx2::cTokenSeperator;
692cdf0e10cSrcweir const bool bUpdate =
693cdf0e10cSrcweir (!pSection->IsLinkType() && rNewData.IsLinkType())
694cdf0e10cSrcweir || ( rNewData.GetLinkFileName().Len()
695cdf0e10cSrcweir && (rNewData.GetLinkFileName() != sCompareString)
696cdf0e10cSrcweir && (rNewData.GetLinkFileName() != pSection->GetLinkFileName()));
697cdf0e10cSrcweir
698cdf0e10cSrcweir String sSectName( rNewData.GetSectionName() );
699cdf0e10cSrcweir if (sSectName != pSection->GetSectionName())
700cdf0e10cSrcweir GetUniqueSectionName( &sSectName );
701cdf0e10cSrcweir else
702cdf0e10cSrcweir sSectName.Erase();
703cdf0e10cSrcweir
704cdf0e10cSrcweir /// OD 04.10.2002 #102894# - NOTE
705cdf0e10cSrcweir /// In SwSection::operator=(..) class member bCondHiddenFlag is always set to sal_True.
706cdf0e10cSrcweir /// IMHO this have to be changed, but I can't estimate the consequences:
707cdf0e10cSrcweir /// Either it is set to sal_True using corresponding method <SwSection.SetCondHidden(..)>,
708cdf0e10cSrcweir /// or it is set to the value of SwSection which is assigned to it.
709cdf0e10cSrcweir /// Discussion with AMA results that the adjustment to the assignment operator
710cdf0e10cSrcweir /// could be very risky -> see notes in bug #102894#.
711cdf0e10cSrcweir pSection->SetSectionData(rNewData);
712cdf0e10cSrcweir
713cdf0e10cSrcweir if( pAttr )
714cdf0e10cSrcweir pSection->GetFmt()->SetFmtAttr( *pAttr );
715cdf0e10cSrcweir
716cdf0e10cSrcweir if( sSectName.Len() )
717cdf0e10cSrcweir {
718cdf0e10cSrcweir pSection->SetSectionName( sSectName );
719cdf0e10cSrcweir }
720cdf0e10cSrcweir
721cdf0e10cSrcweir // ist eine Condition gesetzt
722cdf0e10cSrcweir if( pSection->IsHidden() && pSection->GetCondition().Len() )
723cdf0e10cSrcweir {
724cdf0e10cSrcweir // dann berechne bis zu dieser Position
725cdf0e10cSrcweir SwCalc aCalc( *this );
726cdf0e10cSrcweir if( !pIdx )
727cdf0e10cSrcweir pIdx = pFmt->GetCntnt().GetCntntIdx();
728cdf0e10cSrcweir FldsToCalc( aCalc, pIdx->GetIndex(), USHRT_MAX );
729cdf0e10cSrcweir /// OD 04.10.2002 #102894#
730cdf0e10cSrcweir /// Because on using SwSection::operator=() to set up <pSection>
731cdf0e10cSrcweir /// with <rNewData> and the above given note, the hidden condition flag
732cdf0e10cSrcweir /// has to be set to sal_False, if hidden condition flag of <pFmt->GetSection()>
733cdf0e10cSrcweir /// (SwSection before the changes) is sal_False (already saved in <bOldCondHidden>)
734cdf0e10cSrcweir /// and new calculated condition is sal_True.
735cdf0e10cSrcweir /// This is necessary, because otherwise the <SetCondHidden> would have
736cdf0e10cSrcweir /// no effect.
737cdf0e10cSrcweir bool bCalculatedCondHidden =
738cdf0e10cSrcweir aCalc.Calculate( pSection->GetCondition() ).GetBool() ? true : false;
739cdf0e10cSrcweir if ( bCalculatedCondHidden && !bOldCondHidden )
740cdf0e10cSrcweir {
741cdf0e10cSrcweir pSection->SetCondHidden( false );
742cdf0e10cSrcweir }
743cdf0e10cSrcweir pSection->SetCondHidden( bCalculatedCondHidden );
744cdf0e10cSrcweir }
745cdf0e10cSrcweir
746cdf0e10cSrcweir if( bUpdate )
747cdf0e10cSrcweir pSection->CreateLink( bPreventLinkUpdate ? CREATE_CONNECT : CREATE_UPDATE );
748cdf0e10cSrcweir else if( !pSection->IsLinkType() && pSection->IsConnected() )
749cdf0e10cSrcweir {
750cdf0e10cSrcweir pSection->Disconnect();
751cdf0e10cSrcweir GetLinkManager().Remove( &pSection->GetBaseLink() );
752cdf0e10cSrcweir }
753cdf0e10cSrcweir
754cdf0e10cSrcweir SetModified();
755cdf0e10cSrcweir }
756cdf0e10cSrcweir
757cdf0e10cSrcweir /* -----------------19.02.99 09:31-------------------
758cdf0e10cSrcweir * LockFrms wurde im InsertSection genutzt, um zu verhindern, dass
759cdf0e10cSrcweir * SectionFrms durch das DelFrms zerstoert werden. Dies ist durch
760cdf0e10cSrcweir * den Destroy-Listen-Mechanismus ueberfluessig geworden.
761cdf0e10cSrcweir * Falls diese Methode doch noch einmal reanimiert wird, bietet es
762cdf0e10cSrcweir * sich vielleicht an, beim Entlocken die SectionFrms auf Inhalt zu
763cdf0e10cSrcweir * pruefen und dann ggf. zur Zerstoerung anzumelden.
764cdf0e10cSrcweir * --------------------------------------------------*/
765cdf0e10cSrcweir
766cdf0e10cSrcweir // und dann waren da noch die Fussnoten:
lcl_DeleteFtn(SwSectionNode * pNd,sal_uLong nStt,sal_uLong nEnd)767cdf0e10cSrcweir void lcl_DeleteFtn( SwSectionNode *pNd, sal_uLong nStt, sal_uLong nEnd )
768cdf0e10cSrcweir {
769cdf0e10cSrcweir SwFtnIdxs& rFtnArr = pNd->GetDoc()->GetFtnIdxs();
770cdf0e10cSrcweir if( rFtnArr.Count() )
771cdf0e10cSrcweir {
772cdf0e10cSrcweir sal_uInt16 nPos;
773cdf0e10cSrcweir rFtnArr.SeekEntry( SwNodeIndex( *pNd ), &nPos );
774cdf0e10cSrcweir SwTxtFtn* pSrch;
775cdf0e10cSrcweir
776cdf0e10cSrcweir // loesche erstmal alle, die dahinter stehen
777cdf0e10cSrcweir while( nPos < rFtnArr.Count() &&
778cdf0e10cSrcweir _SwTxtFtn_GetIndex( (pSrch = rFtnArr[ nPos ]) ) <= nEnd )
779cdf0e10cSrcweir {
780cdf0e10cSrcweir // Werden die Nodes nicht geloescht mussen sie bei den Seiten
781cdf0e10cSrcweir // abmeldet (Frms loeschen) werden, denn sonst bleiben sie
782cdf0e10cSrcweir // stehen (Undo loescht sie nicht!)
783cdf0e10cSrcweir pSrch->DelFrms(0);
784cdf0e10cSrcweir ++nPos;
785cdf0e10cSrcweir }
786cdf0e10cSrcweir
787cdf0e10cSrcweir while( nPos-- &&
788cdf0e10cSrcweir _SwTxtFtn_GetIndex( (pSrch = rFtnArr[ nPos ]) ) >= nStt )
789cdf0e10cSrcweir {
790cdf0e10cSrcweir // Werden die Nodes nicht geloescht mussen sie bei den Seiten
791cdf0e10cSrcweir // abmeldet (Frms loeschen) werden, denn sonst bleiben sie
792cdf0e10cSrcweir // stehen (Undo loescht sie nicht!)
793cdf0e10cSrcweir pSrch->DelFrms(0);
794cdf0e10cSrcweir }
795cdf0e10cSrcweir }
796cdf0e10cSrcweir }
797cdf0e10cSrcweir
lcl_IsTOXSection(SwSectionData const & rSectionData)798cdf0e10cSrcweir static inline bool lcl_IsTOXSection(SwSectionData const& rSectionData)
799cdf0e10cSrcweir {
800cdf0e10cSrcweir return (TOX_CONTENT_SECTION == rSectionData.GetType())
801cdf0e10cSrcweir || (TOX_HEADER_SECTION == rSectionData.GetType());
802cdf0e10cSrcweir }
803cdf0e10cSrcweir
InsertTextSection(SwNodeIndex const & rNdIdx,SwSectionFmt & rSectionFmt,SwSectionData const & rSectionData,SwTOXBase const * const pTOXBase,SwNodeIndex const * const pEnde,bool const bInsAtStart,bool const bCreateFrms)804cdf0e10cSrcweir SwSectionNode* SwNodes::InsertTextSection(SwNodeIndex const& rNdIdx,
805cdf0e10cSrcweir SwSectionFmt& rSectionFmt,
806cdf0e10cSrcweir SwSectionData const& rSectionData,
807cdf0e10cSrcweir SwTOXBase const*const pTOXBase,
808cdf0e10cSrcweir SwNodeIndex const*const pEnde,
809cdf0e10cSrcweir bool const bInsAtStart, bool const bCreateFrms)
810cdf0e10cSrcweir {
811cdf0e10cSrcweir SwNodeIndex aInsPos( rNdIdx );
812cdf0e10cSrcweir if( !pEnde ) // kein Bereich also neue Section davor/hinter anlegen
813cdf0e10cSrcweir {
814cdf0e10cSrcweir // #i26762#
815cdf0e10cSrcweir ASSERT(!pEnde || rNdIdx <= *pEnde,
816cdf0e10cSrcweir "Section start and end in wrong order!");
817cdf0e10cSrcweir
818cdf0e10cSrcweir if( bInsAtStart )
819cdf0e10cSrcweir {
820cdf0e10cSrcweir if (!lcl_IsTOXSection(rSectionData))
821cdf0e10cSrcweir {
822cdf0e10cSrcweir do {
823cdf0e10cSrcweir aInsPos--;
824cdf0e10cSrcweir } while( aInsPos.GetNode().IsSectionNode() );
825cdf0e10cSrcweir aInsPos++;
826cdf0e10cSrcweir }
827cdf0e10cSrcweir }
828cdf0e10cSrcweir else
829cdf0e10cSrcweir {
830cdf0e10cSrcweir SwNode* pNd;
831cdf0e10cSrcweir aInsPos++;
832cdf0e10cSrcweir if (!lcl_IsTOXSection(rSectionData))
833cdf0e10cSrcweir {
834cdf0e10cSrcweir while( aInsPos.GetIndex() < Count() - 1 &&
835cdf0e10cSrcweir ( pNd = &aInsPos.GetNode())->IsEndNode() &&
836cdf0e10cSrcweir pNd->StartOfSectionNode()->IsSectionNode())
837cdf0e10cSrcweir {
838cdf0e10cSrcweir aInsPos++;
839cdf0e10cSrcweir }
840cdf0e10cSrcweir }
841cdf0e10cSrcweir }
842cdf0e10cSrcweir }
843cdf0e10cSrcweir
844cdf0e10cSrcweir SwSectionNode *const pSectNd =
845cdf0e10cSrcweir new SwSectionNode(aInsPos, rSectionFmt, pTOXBase);
846cdf0e10cSrcweir if( pEnde )
847cdf0e10cSrcweir {
848cdf0e10cSrcweir // Sonderfall fuer die Reader/Writer
849cdf0e10cSrcweir if( &pEnde->GetNode() != &GetEndOfContent() )
850cdf0e10cSrcweir aInsPos = pEnde->GetIndex()+1;
851cdf0e10cSrcweir // #i58710: We created a RTF document with a section break inside a table cell
852cdf0e10cSrcweir // We are not able to handle a section start inside a table and the section end outside.
853cdf0e10cSrcweir const SwNode* pLastNode = pSectNd->StartOfSectionNode()->EndOfSectionNode();
854cdf0e10cSrcweir if( aInsPos > pLastNode->GetIndex() )
855cdf0e10cSrcweir aInsPos = pLastNode->GetIndex();
856cdf0e10cSrcweir // Another way round: if the section starts outside a table but the end is inside...
857cdf0e10cSrcweir // aInsPos is at the moment the Position where my EndNode will be inserted
858cdf0e10cSrcweir const SwStartNode* pStartNode = aInsPos.GetNode().StartOfSectionNode();
859cdf0e10cSrcweir // This StartNode should be in front of me, but if not, I wanna survive
860cdf0e10cSrcweir sal_uLong nMyIndex = pSectNd->GetIndex();
861cdf0e10cSrcweir if( pStartNode->GetIndex() > nMyIndex ) // Suspicious!
862cdf0e10cSrcweir {
863cdf0e10cSrcweir const SwNode* pTemp;
864cdf0e10cSrcweir do
865cdf0e10cSrcweir {
866cdf0e10cSrcweir pTemp = pStartNode; // pTemp is a suspicious one
867cdf0e10cSrcweir pStartNode = pStartNode->StartOfSectionNode();
868cdf0e10cSrcweir }
869cdf0e10cSrcweir while( pStartNode->GetIndex() > nMyIndex );
870cdf0e10cSrcweir pTemp = pTemp->EndOfSectionNode();
871cdf0e10cSrcweir // If it starts behind me but ends behind my end...
872cdf0e10cSrcweir if( pTemp->GetIndex() >= aInsPos.GetIndex() )
873cdf0e10cSrcweir aInsPos = pTemp->GetIndex()+1; // ...I have to correct my end position
874cdf0e10cSrcweir }
875cdf0e10cSrcweir
876cdf0e10cSrcweir }
877cdf0e10cSrcweir else
878cdf0e10cSrcweir {
879cdf0e10cSrcweir SwTxtNode* pCpyTNd = rNdIdx.GetNode().GetTxtNode();
880cdf0e10cSrcweir if( pCpyTNd )
881cdf0e10cSrcweir {
882cdf0e10cSrcweir SwTxtNode* pTNd = new SwTxtNode( aInsPos, pCpyTNd->GetTxtColl() );
883cdf0e10cSrcweir if( pCpyTNd->HasSwAttrSet() )
884cdf0e10cSrcweir {
885cdf0e10cSrcweir // Task 70955 - move PageDesc/Break to the first Node of the
886cdf0e10cSrcweir // section
887cdf0e10cSrcweir const SfxItemSet& rSet = *pCpyTNd->GetpSwAttrSet();
888cdf0e10cSrcweir if( SFX_ITEM_SET == rSet.GetItemState( RES_BREAK ) ||
889cdf0e10cSrcweir SFX_ITEM_SET == rSet.GetItemState( RES_PAGEDESC ))
890cdf0e10cSrcweir {
891cdf0e10cSrcweir SfxItemSet aSet( rSet );
892cdf0e10cSrcweir if( bInsAtStart )
893cdf0e10cSrcweir pCpyTNd->ResetAttr( RES_PAGEDESC, RES_BREAK );
894cdf0e10cSrcweir else
895cdf0e10cSrcweir {
896cdf0e10cSrcweir aSet.ClearItem( RES_PAGEDESC );
897cdf0e10cSrcweir aSet.ClearItem( RES_BREAK );
898cdf0e10cSrcweir }
899cdf0e10cSrcweir pTNd->SetAttr( aSet );
900cdf0e10cSrcweir }
901cdf0e10cSrcweir else
902cdf0e10cSrcweir pTNd->SetAttr( rSet );
903cdf0e10cSrcweir }
904cdf0e10cSrcweir // den Frame anlegen nicht vergessen !!
905cdf0e10cSrcweir pCpyTNd->MakeFrms( *pTNd );
906cdf0e10cSrcweir }
907cdf0e10cSrcweir else
908cdf0e10cSrcweir new SwTxtNode( aInsPos, (SwTxtFmtColl*)GetDoc()->GetDfltTxtFmtColl() );
909cdf0e10cSrcweir }
910cdf0e10cSrcweir new SwEndNode( aInsPos, *pSectNd );
911cdf0e10cSrcweir
912cdf0e10cSrcweir pSectNd->GetSection().SetSectionData(rSectionData);
913cdf0e10cSrcweir SwSectionFmt* pSectFmt = pSectNd->GetSection().GetFmt();
914cdf0e10cSrcweir
915cdf0e10cSrcweir // Hier bietet sich als Optimierung an, vorhandene Frames nicht zu
916cdf0e10cSrcweir // zerstoeren und wieder neu anzulegen, sondern nur umzuhaengen.
917cdf0e10cSrcweir sal_Bool bInsFrm = bCreateFrms && !pSectNd->GetSection().IsHidden() &&
918cdf0e10cSrcweir GetDoc()->GetCurrentViewShell(); //swmod 071108//swmod 071225
919cdf0e10cSrcweir SwNode2Layout *pNode2Layout = NULL;
920cdf0e10cSrcweir if( bInsFrm )
921cdf0e10cSrcweir {
922cdf0e10cSrcweir SwNodeIndex aTmp( *pSectNd );
923cdf0e10cSrcweir if( !pSectNd->GetNodes().FindPrvNxtFrmNode( aTmp, pSectNd->EndOfSectionNode() ) )
924cdf0e10cSrcweir // dann sammel mal alle Uppers ein
925cdf0e10cSrcweir pNode2Layout = new SwNode2Layout( *pSectNd );
926cdf0e10cSrcweir }
927cdf0e10cSrcweir
928cdf0e10cSrcweir // jetzt noch bei allen im Bereich den richtigen StartNode setzen
929cdf0e10cSrcweir sal_uLong nEnde = pSectNd->EndOfSectionIndex();
930cdf0e10cSrcweir sal_uLong nStart = pSectNd->GetIndex()+1;
931cdf0e10cSrcweir sal_uLong nSkipIdx = ULONG_MAX;
932cdf0e10cSrcweir for( sal_uLong n = nStart; n < nEnde; ++n )
933cdf0e10cSrcweir {
934cdf0e10cSrcweir SwNode* pNd = (*this)[n];
935cdf0e10cSrcweir
936cdf0e10cSrcweir //JP 30.04.99: Bug 65644 - alle in der NodeSection liegenden
937cdf0e10cSrcweir // Sections unter die neue haengen
938cdf0e10cSrcweir if( ULONG_MAX == nSkipIdx )
939cdf0e10cSrcweir pNd->pStartOfSection = pSectNd;
940cdf0e10cSrcweir else if( n >= nSkipIdx )
941cdf0e10cSrcweir nSkipIdx = ULONG_MAX;
942cdf0e10cSrcweir
943cdf0e10cSrcweir if( pNd->IsStartNode() )
944cdf0e10cSrcweir {
945cdf0e10cSrcweir // die Verschachtelung der Formate herstellen!
946cdf0e10cSrcweir if( pNd->IsSectionNode() )
947cdf0e10cSrcweir {
948cdf0e10cSrcweir ((SwSectionNode*)pNd)->GetSection().GetFmt()->
949cdf0e10cSrcweir SetDerivedFrom( pSectFmt );
950cdf0e10cSrcweir ((SwSectionNode*)pNd)->DelFrms();
951cdf0e10cSrcweir n = pNd->EndOfSectionIndex();
952cdf0e10cSrcweir }
953cdf0e10cSrcweir else
954cdf0e10cSrcweir {
955cdf0e10cSrcweir if( pNd->IsTableNode() )
956cdf0e10cSrcweir ((SwTableNode*)pNd)->DelFrms();
957cdf0e10cSrcweir
958cdf0e10cSrcweir if( ULONG_MAX == nSkipIdx )
959cdf0e10cSrcweir nSkipIdx = pNd->EndOfSectionIndex();
960cdf0e10cSrcweir }
961cdf0e10cSrcweir }
962cdf0e10cSrcweir else if( pNd->IsCntntNode() )
963cdf0e10cSrcweir ((SwCntntNode*)pNd)->DelFrms();
964cdf0e10cSrcweir }
965cdf0e10cSrcweir
966cdf0e10cSrcweir lcl_DeleteFtn( pSectNd, nStart, nEnde );
967cdf0e10cSrcweir
968cdf0e10cSrcweir if( bInsFrm )
969cdf0e10cSrcweir {
970cdf0e10cSrcweir if( pNode2Layout )
971cdf0e10cSrcweir {
972cdf0e10cSrcweir sal_uLong nIdx = pSectNd->GetIndex();
973cdf0e10cSrcweir pNode2Layout->RestoreUpperFrms( pSectNd->GetNodes(), nIdx, nIdx + 1 );
974cdf0e10cSrcweir delete pNode2Layout;
975cdf0e10cSrcweir }
976cdf0e10cSrcweir else
977cdf0e10cSrcweir pSectNd->MakeFrms( &aInsPos );
978cdf0e10cSrcweir }
979cdf0e10cSrcweir
980cdf0e10cSrcweir return pSectNd;
981cdf0e10cSrcweir }
982cdf0e10cSrcweir
FindSectionNode()983cdf0e10cSrcweir SwSectionNode* SwNode::FindSectionNode()
984cdf0e10cSrcweir {
985cdf0e10cSrcweir if( IsSectionNode() )
986cdf0e10cSrcweir return GetSectionNode();
987cdf0e10cSrcweir SwStartNode* pTmp = pStartOfSection;
988cdf0e10cSrcweir while( !pTmp->IsSectionNode() && pTmp->GetIndex() )
989cdf0e10cSrcweir #if defined( ALPHA ) && defined( UNX )
990cdf0e10cSrcweir pTmp = ((SwNode*)pTmp)->pStartOfSection;
991cdf0e10cSrcweir #else
992cdf0e10cSrcweir pTmp = pTmp->pStartOfSection;
993cdf0e10cSrcweir #endif
994cdf0e10cSrcweir return pTmp->GetSectionNode();
995cdf0e10cSrcweir }
996cdf0e10cSrcweir
997cdf0e10cSrcweir
998cdf0e10cSrcweir //---------
999cdf0e10cSrcweir // SwSectionNode
1000cdf0e10cSrcweir //---------
1001cdf0e10cSrcweir
1002cdf0e10cSrcweir // ugly hack to make m_pSection const
1003cdf0e10cSrcweir static SwSectionFmt &
lcl_initParent(SwSectionNode & rThis,SwSectionFmt & rFmt)1004cdf0e10cSrcweir lcl_initParent(SwSectionNode & rThis, SwSectionFmt & rFmt)
1005cdf0e10cSrcweir {
1006cdf0e10cSrcweir SwSectionNode *const pParent =
1007cdf0e10cSrcweir rThis.StartOfSectionNode()->FindSectionNode();
1008cdf0e10cSrcweir if( pParent )
1009cdf0e10cSrcweir {
1010cdf0e10cSrcweir // das Format beim richtigen Parent anmelden.
1011cdf0e10cSrcweir rFmt.SetDerivedFrom( pParent->GetSection().GetFmt() );
1012cdf0e10cSrcweir }
1013cdf0e10cSrcweir return rFmt;
1014cdf0e10cSrcweir }
1015cdf0e10cSrcweir
SwSectionNode(SwNodeIndex const & rIdx,SwSectionFmt & rFmt,SwTOXBase const * const pTOXBase)1016cdf0e10cSrcweir SwSectionNode::SwSectionNode(SwNodeIndex const& rIdx,
1017cdf0e10cSrcweir SwSectionFmt & rFmt, SwTOXBase const*const pTOXBase)
1018cdf0e10cSrcweir : SwStartNode( rIdx, ND_SECTIONNODE )
1019cdf0e10cSrcweir , m_pSection( (pTOXBase)
1020cdf0e10cSrcweir ? new SwTOXBaseSection(*pTOXBase, lcl_initParent(*this, rFmt))
1021cdf0e10cSrcweir : new SwSection( CONTENT_SECTION, rFmt.GetName(),
1022cdf0e10cSrcweir lcl_initParent(*this, rFmt) ) )
1023cdf0e10cSrcweir {
1024cdf0e10cSrcweir // jetzt noch die Verbindung von Format zum Node setzen
1025cdf0e10cSrcweir // Modify unterdruecken, interresiert keinen
1026cdf0e10cSrcweir rFmt.LockModify();
1027cdf0e10cSrcweir rFmt.SetFmtAttr( SwFmtCntnt( this ) );
1028cdf0e10cSrcweir rFmt.UnlockModify();
1029cdf0e10cSrcweir }
1030cdf0e10cSrcweir
1031cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1032cdf0e10cSrcweir //Hier werden ueberfluessige SectionFrms entfernt
SwClearDummies(SwFrm * pFrm)1033cdf0e10cSrcweir SwFrm* SwClearDummies( SwFrm* pFrm )
1034cdf0e10cSrcweir {
1035cdf0e10cSrcweir SwFrm* pTmp = pFrm;
1036cdf0e10cSrcweir while( pTmp )
1037cdf0e10cSrcweir {
1038cdf0e10cSrcweir ASSERT( !pTmp->GetUpper(), "SwClearDummies: No Upper allowed!" );
1039cdf0e10cSrcweir if( pTmp->IsSctFrm() )
1040cdf0e10cSrcweir {
1041cdf0e10cSrcweir SwSectionFrm* pSectFrm = (SwSectionFrm*)pFrm;
1042cdf0e10cSrcweir pTmp = pTmp->GetNext();
1043cdf0e10cSrcweir if( !pSectFrm->GetLower() )
1044cdf0e10cSrcweir {
1045cdf0e10cSrcweir if( pSectFrm->GetPrev() )
1046cdf0e10cSrcweir pSectFrm->GetPrev()->pNext = pTmp;
1047cdf0e10cSrcweir else
1048cdf0e10cSrcweir pFrm = pTmp;
1049cdf0e10cSrcweir if( pTmp )
1050cdf0e10cSrcweir pTmp->pPrev = pSectFrm->GetPrev();
1051cdf0e10cSrcweir delete pSectFrm;
1052cdf0e10cSrcweir }
1053cdf0e10cSrcweir }
1054cdf0e10cSrcweir else
1055cdf0e10cSrcweir pTmp = pTmp->GetNext();
1056cdf0e10cSrcweir }
1057cdf0e10cSrcweir return pFrm;
1058cdf0e10cSrcweir }
1059cdf0e10cSrcweir #endif
1060cdf0e10cSrcweir
~SwSectionNode()1061cdf0e10cSrcweir SwSectionNode::~SwSectionNode()
1062cdf0e10cSrcweir {
1063cdf0e10cSrcweir // mba: test if iteration works as clients will be removed in callback
1064713b4dcdSMichael Stahl // --> OD #i117863#
1065713b4dcdSMichael Stahl // use hint which allows to specify, if the content shall be saved or not
1066713b4dcdSMichael Stahl m_pSection->GetFmt()->CallSwClientNotify( SwSectionFrmMoveAndDeleteHint( sal_True ) );
1067713b4dcdSMichael Stahl // <--
1068cdf0e10cSrcweir SwSectionFmt* pFmt = m_pSection->GetFmt();
1069cdf0e10cSrcweir if( pFmt )
1070cdf0e10cSrcweir {
1071cdf0e10cSrcweir // das Attribut entfernen, weil die Section ihr Format loescht
1072cdf0e10cSrcweir // und falls das Cntnt-Attribut vorhanden ist, die Section aufhebt.
1073cdf0e10cSrcweir pFmt->LockModify();
1074cdf0e10cSrcweir pFmt->ResetFmtAttr( RES_CNTNT );
1075cdf0e10cSrcweir pFmt->UnlockModify();
1076cdf0e10cSrcweir }
1077cdf0e10cSrcweir }
1078cdf0e10cSrcweir
1079cdf0e10cSrcweir
MakeFrm(SwFrm * pSib)1080cdf0e10cSrcweir SwFrm *SwSectionNode::MakeFrm( SwFrm *pSib )
1081cdf0e10cSrcweir {
1082cdf0e10cSrcweir m_pSection->m_Data.SetHiddenFlag(false);
1083cdf0e10cSrcweir return new SwSectionFrm( *m_pSection, pSib );
1084cdf0e10cSrcweir }
1085cdf0e10cSrcweir
1086cdf0e10cSrcweir //Methode erzeugt fuer den vorhergehenden Node alle Ansichten vom
1087cdf0e10cSrcweir //Dokument. Die erzeugten Contentframes werden in das entsprechende
1088cdf0e10cSrcweir //Layout gehaengt.
MakeFrms(const SwNodeIndex & rIdx)1089cdf0e10cSrcweir void SwSectionNode::MakeFrms(const SwNodeIndex & rIdx )
1090cdf0e10cSrcweir {
1091cdf0e10cSrcweir // also nehme meinen nachfolgenden oder vorhergehenden ContentFrame:
1092cdf0e10cSrcweir SwNodes& rNds = GetNodes();
1093cdf0e10cSrcweir if( rNds.IsDocNodes() && rNds.GetDoc()->GetCurrentViewShell() ) //swmod 071108//swmod 071225
1094cdf0e10cSrcweir {
1095cdf0e10cSrcweir if( GetSection().IsHidden() || IsCntntHidden() )
1096cdf0e10cSrcweir {
1097cdf0e10cSrcweir SwNodeIndex aIdx( *EndOfSectionNode() );
1098cdf0e10cSrcweir SwCntntNode* pCNd = rNds.GoNextSection( &aIdx, sal_True, sal_False );
1099cdf0e10cSrcweir if( !pCNd )
1100cdf0e10cSrcweir {
1101cdf0e10cSrcweir aIdx = *this;
1102cdf0e10cSrcweir if( 0 == ( pCNd = rNds.GoPrevSection( &aIdx, sal_True, sal_False )) )
1103cdf0e10cSrcweir return ;
1104cdf0e10cSrcweir }
1105cdf0e10cSrcweir pCNd = aIdx.GetNode().GetCntntNode();
1106cdf0e10cSrcweir pCNd->MakeFrms( (SwCntntNode&)rIdx.GetNode() );
1107cdf0e10cSrcweir }
1108cdf0e10cSrcweir else
1109cdf0e10cSrcweir {
1110cdf0e10cSrcweir SwNode2Layout aNode2Layout( *this, rIdx.GetIndex() );
1111cdf0e10cSrcweir SwFrm *pFrm, *pNew;
1112cdf0e10cSrcweir while( 0 != (pFrm = aNode2Layout.NextFrm()) )
1113cdf0e10cSrcweir {
1114cdf0e10cSrcweir ASSERT( pFrm->IsSctFrm(), "Depend von Section keine Section." );
1115cdf0e10cSrcweir pNew = rIdx.GetNode().GetCntntNode()->MakeFrm( pFrm );
1116cdf0e10cSrcweir
1117cdf0e10cSrcweir SwSectionNode* pS = rIdx.GetNode().FindSectionNode();
1118cdf0e10cSrcweir // --> OD 2008-06-23 #156927#
1119cdf0e10cSrcweir // Assure that node is not inside a table, which is inside the
1120cdf0e10cSrcweir // found section.
1121cdf0e10cSrcweir if ( pS )
1122cdf0e10cSrcweir {
1123cdf0e10cSrcweir SwTableNode* pTableNode = rIdx.GetNode().FindTableNode();
1124cdf0e10cSrcweir if ( pTableNode &&
1125cdf0e10cSrcweir pTableNode->GetIndex() > pS->GetIndex() )
1126cdf0e10cSrcweir {
1127cdf0e10cSrcweir pS = 0;
1128cdf0e10cSrcweir }
1129cdf0e10cSrcweir }
1130cdf0e10cSrcweir // <--
1131cdf0e10cSrcweir // if the node is in a section, the sectionframe now
1132cdf0e10cSrcweir // has to be created..
1133cdf0e10cSrcweir // OD 14.11.2002 #104684# - boolean to control <Init()> of a new
1134cdf0e10cSrcweir // section frame.
1135cdf0e10cSrcweir bool bInitNewSect = false;
1136cdf0e10cSrcweir if( pS )
1137cdf0e10cSrcweir {
1138cdf0e10cSrcweir SwSectionFrm *pSct = new SwSectionFrm( pS->GetSection(), pFrm );
1139cdf0e10cSrcweir // OD 14.11.2002 #104684# - prepare <Init()> of new section frame.
1140cdf0e10cSrcweir bInitNewSect = true;
1141cdf0e10cSrcweir SwLayoutFrm* pUp = pSct;
1142cdf0e10cSrcweir while( pUp->Lower() ) // for columned sections
1143cdf0e10cSrcweir {
1144cdf0e10cSrcweir ASSERT( pUp->Lower()->IsLayoutFrm(),"Who's in there?" );
1145cdf0e10cSrcweir pUp = (SwLayoutFrm*)pUp->Lower();
1146cdf0e10cSrcweir }
1147cdf0e10cSrcweir pNew->Paste( pUp, NULL );
1148cdf0e10cSrcweir // --> OD 2005-12-01 #i27138#
1149cdf0e10cSrcweir // notify accessibility paragraphs objects about changed
1150cdf0e10cSrcweir // CONTENT_FLOWS_FROM/_TO relation.
1151cdf0e10cSrcweir // Relation CONTENT_FLOWS_FROM for next paragraph will change
1152cdf0e10cSrcweir // and relation CONTENT_FLOWS_TO for previous paragraph will change.
1153cdf0e10cSrcweir if ( pNew->IsTxtFrm() )
1154cdf0e10cSrcweir {
1155cdf0e10cSrcweir ViewShell* pViewShell( pNew->getRootFrm()->GetCurrShell() );
1156cdf0e10cSrcweir if ( pViewShell && pViewShell->GetLayout() &&
1157cdf0e10cSrcweir pViewShell->GetLayout()->IsAnyShellAccessible() )
1158cdf0e10cSrcweir {
1159cdf0e10cSrcweir pViewShell->InvalidateAccessibleParaFlowRelation(
1160cdf0e10cSrcweir dynamic_cast<SwTxtFrm*>(pNew->FindNextCnt( true )),
1161cdf0e10cSrcweir dynamic_cast<SwTxtFrm*>(pNew->FindPrevCnt( true )) );
1162cdf0e10cSrcweir }
1163cdf0e10cSrcweir }
1164cdf0e10cSrcweir // <--
1165cdf0e10cSrcweir pNew = pSct;
1166cdf0e10cSrcweir }
1167cdf0e10cSrcweir
1168cdf0e10cSrcweir // wird ein Node vorher oder nachher mit Frames versehen
1169cdf0e10cSrcweir if ( rIdx < GetIndex() )
1170cdf0e10cSrcweir // der neue liegt vor mir
1171cdf0e10cSrcweir pNew->Paste( pFrm->GetUpper(), pFrm );
1172cdf0e10cSrcweir else
1173cdf0e10cSrcweir // der neue liegt hinter mir
1174cdf0e10cSrcweir pNew->Paste( pFrm->GetUpper(), pFrm->GetNext() );
1175cdf0e10cSrcweir // --> OD 2005-12-01 #i27138#
1176cdf0e10cSrcweir // notify accessibility paragraphs objects about changed
1177cdf0e10cSrcweir // CONTENT_FLOWS_FROM/_TO relation.
1178cdf0e10cSrcweir // Relation CONTENT_FLOWS_FROM for next paragraph will change
1179cdf0e10cSrcweir // and relation CONTENT_FLOWS_TO for previous paragraph will change.
1180cdf0e10cSrcweir if ( pNew->IsTxtFrm() )
1181cdf0e10cSrcweir {
1182cdf0e10cSrcweir ViewShell* pViewShell( pNew->getRootFrm()->GetCurrShell() );
1183cdf0e10cSrcweir if ( pViewShell && pViewShell->GetLayout() &&
1184cdf0e10cSrcweir pViewShell->GetLayout()->IsAnyShellAccessible() )
1185cdf0e10cSrcweir {
1186cdf0e10cSrcweir pViewShell->InvalidateAccessibleParaFlowRelation(
1187cdf0e10cSrcweir dynamic_cast<SwTxtFrm*>(pNew->FindNextCnt( true )),
1188cdf0e10cSrcweir dynamic_cast<SwTxtFrm*>(pNew->FindPrevCnt( true )) );
1189cdf0e10cSrcweir }
1190cdf0e10cSrcweir }
1191cdf0e10cSrcweir // <--
1192cdf0e10cSrcweir if ( bInitNewSect )
1193cdf0e10cSrcweir static_cast<SwSectionFrm*>(pNew)->Init();
1194cdf0e10cSrcweir }
1195cdf0e10cSrcweir }
1196cdf0e10cSrcweir }
1197cdf0e10cSrcweir }
1198cdf0e10cSrcweir
1199cdf0e10cSrcweir //Fuer jedes vorkommen im Layout einen SectionFrm anlegen und vor den
1200cdf0e10cSrcweir //entsprechenden CntntFrm pasten.
1201cdf0e10cSrcweir
MakeFrms(SwNodeIndex * pIdxBehind,SwNodeIndex * pEndIdx)1202cdf0e10cSrcweir void SwSectionNode::MakeFrms( SwNodeIndex* pIdxBehind, SwNodeIndex* pEndIdx )
1203cdf0e10cSrcweir {
1204cdf0e10cSrcweir ASSERT( pIdxBehind, "kein Index" );
1205cdf0e10cSrcweir SwNodes& rNds = GetNodes();
1206cdf0e10cSrcweir SwDoc* pDoc = rNds.GetDoc();
1207cdf0e10cSrcweir
1208cdf0e10cSrcweir *pIdxBehind = *this;
1209cdf0e10cSrcweir
1210cdf0e10cSrcweir m_pSection->m_Data.SetHiddenFlag(true);
1211cdf0e10cSrcweir
1212cdf0e10cSrcweir if( rNds.IsDocNodes() )
1213cdf0e10cSrcweir {
1214cdf0e10cSrcweir SwNodeIndex *pEnd = pEndIdx ? pEndIdx :
1215cdf0e10cSrcweir new SwNodeIndex( *EndOfSectionNode(), 1 );
1216cdf0e10cSrcweir ::MakeFrms( pDoc, *pIdxBehind, *pEnd );
1217cdf0e10cSrcweir if( !pEndIdx )
1218cdf0e10cSrcweir delete pEnd;
1219cdf0e10cSrcweir }
1220cdf0e10cSrcweir
1221cdf0e10cSrcweir }
1222cdf0e10cSrcweir
DelFrms()1223cdf0e10cSrcweir void SwSectionNode::DelFrms()
1224cdf0e10cSrcweir {
1225cdf0e10cSrcweir sal_uLong nStt = GetIndex()+1, nEnd = EndOfSectionIndex();
1226cdf0e10cSrcweir if( nStt >= nEnd )
1227cdf0e10cSrcweir {
1228cdf0e10cSrcweir // unser Flag muessen wir noch aktualisieren
1229cdf0e10cSrcweir // pSection->bHiddenFlag = sal_True;
1230cdf0e10cSrcweir return ;
1231cdf0e10cSrcweir }
1232cdf0e10cSrcweir
1233cdf0e10cSrcweir SwNodes& rNds = GetNodes();
1234cdf0e10cSrcweir m_pSection->GetFmt()->DelFrms();
1235cdf0e10cSrcweir
1236cdf0e10cSrcweir // unser Flag muessen wir noch aktualisieren
1237cdf0e10cSrcweir m_pSection->m_Data.SetHiddenFlag(true);
1238cdf0e10cSrcweir
1239cdf0e10cSrcweir // Bug 30582: falls der Bereich in Fly oder TabellenBox ist, dann
1240cdf0e10cSrcweir // kann er nur "gehiddet" werden, wenn weiterer Content
1241cdf0e10cSrcweir // vorhanden ist, der "Frames" haelt. Sonst hat der
1242cdf0e10cSrcweir // Fly/TblBox-Frame keinen Lower !!!
1243cdf0e10cSrcweir {
1244cdf0e10cSrcweir SwNodeIndex aIdx( *this );
1245cdf0e10cSrcweir if( !rNds.GoPrevSection( &aIdx, sal_True, sal_False ) ||
1246cdf0e10cSrcweir !CheckNodesRange( *this, aIdx, sal_True ) ||
1247cdf0e10cSrcweir // OD 04.11.2003 #i21457#
1248cdf0e10cSrcweir !lcl_IsInSameTblBox( rNds, *this, true ))
1249cdf0e10cSrcweir {
1250cdf0e10cSrcweir aIdx = *EndOfSectionNode();
1251cdf0e10cSrcweir if( !rNds.GoNextSection( &aIdx, sal_True, sal_False ) ||
1252cdf0e10cSrcweir !CheckNodesRange( *EndOfSectionNode(), aIdx, sal_True ) ||
1253cdf0e10cSrcweir // OD 04.11.2003 #i21457#
1254cdf0e10cSrcweir !lcl_IsInSameTblBox( rNds, *EndOfSectionNode(), false ))
1255cdf0e10cSrcweir {
1256cdf0e10cSrcweir m_pSection->m_Data.SetHiddenFlag(false);
1257cdf0e10cSrcweir }
1258cdf0e10cSrcweir }
1259cdf0e10cSrcweir }
1260cdf0e10cSrcweir }
1261cdf0e10cSrcweir
MakeCopy(SwDoc * pDoc,const SwNodeIndex & rIdx) const1262cdf0e10cSrcweir SwSectionNode* SwSectionNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const
1263cdf0e10cSrcweir {
1264cdf0e10cSrcweir // in welchen Array steht ich denn: Nodes, UndoNodes ??
1265cdf0e10cSrcweir const SwNodes& rNds = GetNodes();
1266cdf0e10cSrcweir
1267cdf0e10cSrcweir // das SectionFrmFmt kopieren
1268cdf0e10cSrcweir SwSectionFmt* pSectFmt = pDoc->MakeSectionFmt( 0 );
1269cdf0e10cSrcweir pSectFmt->CopyAttrs( *GetSection().GetFmt() );
1270cdf0e10cSrcweir
1271cdf0e10cSrcweir ::std::auto_ptr<SwTOXBase> pTOXBase;
1272cdf0e10cSrcweir if (TOX_CONTENT_SECTION == GetSection().GetType())
1273cdf0e10cSrcweir {
1274cdf0e10cSrcweir ASSERT( GetSection().ISA( SwTOXBaseSection ), "no TOXBaseSection!" );
1275cdf0e10cSrcweir SwTOXBaseSection const& rTBS(
1276cdf0e10cSrcweir dynamic_cast<SwTOXBaseSection const&>(GetSection()));
1277cdf0e10cSrcweir pTOXBase.reset( new SwTOXBase(rTBS, pDoc) );
1278cdf0e10cSrcweir }
1279cdf0e10cSrcweir
1280cdf0e10cSrcweir SwSectionNode *const pSectNd =
1281cdf0e10cSrcweir new SwSectionNode(rIdx, *pSectFmt, pTOXBase.get());
1282cdf0e10cSrcweir SwEndNode* pEndNd = new SwEndNode( rIdx, *pSectNd );
1283cdf0e10cSrcweir SwNodeIndex aInsPos( *pEndNd );
1284cdf0e10cSrcweir
1285cdf0e10cSrcweir // Werte uebertragen
1286cdf0e10cSrcweir SwSection *const pNewSect = pSectNd->m_pSection.get();
1287cdf0e10cSrcweir
1288cdf0e10cSrcweir if (TOX_CONTENT_SECTION != GetSection().GetType())
1289cdf0e10cSrcweir {
1290cdf0e10cSrcweir // beim Move den Namen beibehalten
1291cdf0e10cSrcweir if( rNds.GetDoc() == pDoc && pDoc->IsCopyIsMove() )
1292cdf0e10cSrcweir {
1293cdf0e10cSrcweir pNewSect->SetSectionName( GetSection().GetSectionName() );
1294cdf0e10cSrcweir }
1295cdf0e10cSrcweir else
1296cdf0e10cSrcweir {
1297cdf0e10cSrcweir pNewSect->SetSectionName(
1298cdf0e10cSrcweir pDoc->GetUniqueSectionName( &GetSection().GetSectionName() ));
1299cdf0e10cSrcweir }
1300cdf0e10cSrcweir }
1301cdf0e10cSrcweir
1302cdf0e10cSrcweir
1303cdf0e10cSrcweir pNewSect->SetType( GetSection().GetType() );
1304cdf0e10cSrcweir pNewSect->SetCondition( GetSection().GetCondition() );
1305cdf0e10cSrcweir pNewSect->SetLinkFileName( GetSection().GetLinkFileName() );
1306cdf0e10cSrcweir if( !pNewSect->IsHiddenFlag() && GetSection().IsHidden() )
1307cdf0e10cSrcweir pNewSect->SetHidden( sal_True );
1308cdf0e10cSrcweir if( !pNewSect->IsProtectFlag() && GetSection().IsProtect() )
1309cdf0e10cSrcweir pNewSect->SetProtect( sal_True );
1310cdf0e10cSrcweir // --> FME 2004-06-22 #114856# edit in readonly sections
1311cdf0e10cSrcweir if( !pNewSect->IsEditInReadonlyFlag() && GetSection().IsEditInReadonly() )
1312cdf0e10cSrcweir pNewSect->SetEditInReadonly( sal_True );
1313cdf0e10cSrcweir // <--
1314cdf0e10cSrcweir
1315cdf0e10cSrcweir SwNodeRange aRg( *this, +1, *EndOfSectionNode() ); // (wo stehe in denn nun ??)
1316cdf0e10cSrcweir rNds._Copy( aRg, aInsPos, sal_False );
1317cdf0e10cSrcweir
1318cdf0e10cSrcweir // loesche alle Frames vom kopierten Bereich, diese werden beim
1319cdf0e10cSrcweir // erzeugen des SectionFrames angelegt !
1320cdf0e10cSrcweir pSectNd->DelFrms();
1321cdf0e10cSrcweir
1322cdf0e10cSrcweir // dann kopiere auch noch die Links/Server
1323cdf0e10cSrcweir if( pNewSect->IsLinkType() ) // den Link eintragen
1324cdf0e10cSrcweir pNewSect->CreateLink( pDoc->GetCurrentViewShell() ? CREATE_CONNECT //swmod 071108//swmod 071225
1325cdf0e10cSrcweir : CREATE_NONE );
1326cdf0e10cSrcweir
1327cdf0e10cSrcweir // falls als Server aus dem Undo kopiert wird, wieder eintragen
1328cdf0e10cSrcweir if (m_pSection->IsServer()
1329cdf0e10cSrcweir && pDoc->GetIDocumentUndoRedo().IsUndoNodes(rNds))
1330cdf0e10cSrcweir {
1331cdf0e10cSrcweir pNewSect->SetRefObject( m_pSection->GetObject() );
1332cdf0e10cSrcweir pDoc->GetLinkManager().InsertServer( pNewSect->GetObject() );
1333cdf0e10cSrcweir }
1334cdf0e10cSrcweir
1335cdf0e10cSrcweir // METADATA: copy xml:id; must be done after insertion of node
1336cdf0e10cSrcweir pSectFmt->RegisterAsCopyOf(*GetSection().GetFmt());
1337cdf0e10cSrcweir
1338cdf0e10cSrcweir return pSectNd;
1339cdf0e10cSrcweir }
1340cdf0e10cSrcweir
IsCntntHidden() const1341cdf0e10cSrcweir sal_Bool SwSectionNode::IsCntntHidden() const
1342cdf0e10cSrcweir {
1343cdf0e10cSrcweir ASSERT( !m_pSection->IsHidden(),
1344cdf0e10cSrcweir "That's simple: Hidden Section => Hidden Content" );
1345cdf0e10cSrcweir SwNodeIndex aTmp( *this, 1 );
1346cdf0e10cSrcweir sal_uLong nEnd = EndOfSectionIndex();
1347cdf0e10cSrcweir while( aTmp < nEnd )
1348cdf0e10cSrcweir {
1349cdf0e10cSrcweir if( aTmp.GetNode().IsSectionNode() )
1350cdf0e10cSrcweir {
1351cdf0e10cSrcweir const SwSection& rSect = ((SwSectionNode&)aTmp.GetNode()).GetSection();
1352cdf0e10cSrcweir if( rSect.IsHiddenFlag() )
1353cdf0e10cSrcweir // dann diese Section ueberspringen
1354cdf0e10cSrcweir aTmp = *aTmp.GetNode().EndOfSectionNode();
1355cdf0e10cSrcweir }
1356cdf0e10cSrcweir else
1357cdf0e10cSrcweir {
1358cdf0e10cSrcweir if( aTmp.GetNode().IsCntntNode() || aTmp.GetNode().IsTableNode() )
1359cdf0e10cSrcweir return sal_False; // Nicht versteckter Inhalt wurde gefunden
1360cdf0e10cSrcweir ASSERT( aTmp.GetNode().IsEndNode(), "EndNode expected" );
1361cdf0e10cSrcweir }
1362cdf0e10cSrcweir aTmp++;
1363cdf0e10cSrcweir }
1364cdf0e10cSrcweir return sal_True; // Alles versteckt
1365cdf0e10cSrcweir }
1366cdf0e10cSrcweir
1367cdf0e10cSrcweir
NodesArrChgd()1368cdf0e10cSrcweir void SwSectionNode::NodesArrChgd()
1369cdf0e10cSrcweir {
1370cdf0e10cSrcweir SwSectionFmt *const pFmt = m_pSection->GetFmt();
1371cdf0e10cSrcweir if( pFmt )
1372cdf0e10cSrcweir {
1373cdf0e10cSrcweir SwNodes& rNds = GetNodes();
1374cdf0e10cSrcweir SwDoc* pDoc = pFmt->GetDoc();
1375cdf0e10cSrcweir
1376cdf0e10cSrcweir if( !rNds.IsDocNodes() )
1377cdf0e10cSrcweir {
1378cdf0e10cSrcweir SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT, pFmt );
1379cdf0e10cSrcweir pFmt->ModifyNotification( &aMsgHint, &aMsgHint );
1380cdf0e10cSrcweir }
1381cdf0e10cSrcweir
1382cdf0e10cSrcweir pFmt->LockModify();
1383cdf0e10cSrcweir pFmt->SetFmtAttr( SwFmtCntnt( this ));
1384cdf0e10cSrcweir pFmt->UnlockModify();
1385cdf0e10cSrcweir
1386cdf0e10cSrcweir SwSectionNode* pSectNd = StartOfSectionNode()->FindSectionNode();
1387cdf0e10cSrcweir // set the correct parent from the new section
1388cdf0e10cSrcweir pFmt->SetDerivedFrom( pSectNd ? pSectNd->GetSection().GetFmt()
1389cdf0e10cSrcweir : pDoc->GetDfltFrmFmt() );
1390cdf0e10cSrcweir
1391cdf0e10cSrcweir // jetzt noch bei allen im Bereich den richtigen StartNode setzen
1392cdf0e10cSrcweir sal_uLong nStart = GetIndex()+1, nEnde = EndOfSectionIndex();
1393cdf0e10cSrcweir for( sal_uLong n = nStart; n < nEnde; ++n )
1394cdf0e10cSrcweir // die Verschachtelung der Formate herstellen!
1395cdf0e10cSrcweir if( 0 != ( pSectNd = rNds[ n ]->GetSectionNode() ) )
1396cdf0e10cSrcweir {
1397cdf0e10cSrcweir pSectNd->GetSection().GetFmt()->SetDerivedFrom( pFmt );
1398cdf0e10cSrcweir n = pSectNd->EndOfSectionIndex();
1399cdf0e10cSrcweir }
1400cdf0e10cSrcweir
1401cdf0e10cSrcweir // verschieben vom Nodes- ins UndoNodes-Array?
1402cdf0e10cSrcweir if( rNds.IsDocNodes() )
1403cdf0e10cSrcweir {
1404cdf0e10cSrcweir ASSERT( pDoc == GetDoc(),
1405cdf0e10cSrcweir "verschieben in unterschiedliche Documente?" );
1406cdf0e10cSrcweir if( m_pSection->IsLinkType() ) // den Link austragen
1407cdf0e10cSrcweir m_pSection->CreateLink( pDoc->GetCurrentViewShell() ? CREATE_CONNECT //swmod 071108
1408cdf0e10cSrcweir : CREATE_NONE );//swmod 071225
1409cdf0e10cSrcweir if (m_pSection->IsServer())
1410cdf0e10cSrcweir {
1411cdf0e10cSrcweir pDoc->GetLinkManager().InsertServer( m_pSection->GetObject() );
1412cdf0e10cSrcweir }
1413cdf0e10cSrcweir }
1414cdf0e10cSrcweir else
1415cdf0e10cSrcweir {
1416cdf0e10cSrcweir if (CONTENT_SECTION != m_pSection->GetType())
1417cdf0e10cSrcweir {
1418cdf0e10cSrcweir pDoc->GetLinkManager().Remove( &m_pSection->GetBaseLink() );
1419cdf0e10cSrcweir }
1420cdf0e10cSrcweir
1421cdf0e10cSrcweir if (m_pSection->IsServer())
1422cdf0e10cSrcweir {
1423cdf0e10cSrcweir pDoc->GetLinkManager().RemoveServer( m_pSection->GetObject() );
1424cdf0e10cSrcweir }
1425cdf0e10cSrcweir }
1426cdf0e10cSrcweir }
1427cdf0e10cSrcweir }
1428cdf0e10cSrcweir
1429cdf0e10cSrcweir
GetUniqueSectionName(const String * pChkStr) const1430cdf0e10cSrcweir String SwDoc::GetUniqueSectionName( const String* pChkStr ) const
1431cdf0e10cSrcweir {
1432cdf0e10cSrcweir ResId aId( STR_REGION_DEFNAME, *pSwResMgr );
1433cdf0e10cSrcweir String aName( aId );
1434cdf0e10cSrcweir xub_StrLen nNmLen = aName.Len();
1435cdf0e10cSrcweir
1436cdf0e10cSrcweir sal_uInt16 nNum = 0;
1437cdf0e10cSrcweir sal_uInt16 nTmp, nFlagSize = ( pSectionFmtTbl->Count() / 8 ) +2;
1438cdf0e10cSrcweir sal_uInt8* pSetFlags = new sal_uInt8[ nFlagSize ];
1439cdf0e10cSrcweir memset( pSetFlags, 0, nFlagSize );
1440cdf0e10cSrcweir
1441cdf0e10cSrcweir const SwSectionNode* pSectNd;
1442cdf0e10cSrcweir sal_uInt16 n;
1443cdf0e10cSrcweir
1444cdf0e10cSrcweir for( n = 0; n < pSectionFmtTbl->Count(); ++n )
1445cdf0e10cSrcweir if( 0 != ( pSectNd = (*pSectionFmtTbl)[ n ]->GetSectionNode( sal_False ) ))
1446cdf0e10cSrcweir {
1447cdf0e10cSrcweir const String& rNm = pSectNd->GetSection().GetSectionName();
1448cdf0e10cSrcweir if( rNm.Match( aName ) == nNmLen )
1449cdf0e10cSrcweir {
1450cdf0e10cSrcweir // Nummer bestimmen und das Flag setzen
1451cdf0e10cSrcweir nNum = static_cast<sal_uInt16>(rNm.Copy( nNmLen ).ToInt32());
1452cdf0e10cSrcweir if( nNum-- && nNum < pSectionFmtTbl->Count() )
1453cdf0e10cSrcweir pSetFlags[ nNum / 8 ] |= (0x01 << ( nNum & 0x07 ));
1454cdf0e10cSrcweir }
1455cdf0e10cSrcweir if( pChkStr && pChkStr->Equals( rNm ) )
1456cdf0e10cSrcweir pChkStr = 0;
1457cdf0e10cSrcweir }
1458cdf0e10cSrcweir
1459cdf0e10cSrcweir if( !pChkStr )
1460cdf0e10cSrcweir {
1461cdf0e10cSrcweir // alle Nummern entsprechend geflag, also bestimme die richtige Nummer
1462cdf0e10cSrcweir nNum = pSectionFmtTbl->Count();
1463cdf0e10cSrcweir for( n = 0; n < nFlagSize; ++n )
1464cdf0e10cSrcweir if( 0xff != ( nTmp = pSetFlags[ n ] ))
1465cdf0e10cSrcweir {
1466cdf0e10cSrcweir // also die Nummer bestimmen
1467cdf0e10cSrcweir nNum = n * 8;
1468cdf0e10cSrcweir while( nTmp & 1 )
1469cdf0e10cSrcweir ++nNum, nTmp >>= 1;
1470cdf0e10cSrcweir break;
1471cdf0e10cSrcweir }
1472cdf0e10cSrcweir
1473cdf0e10cSrcweir }
1474cdf0e10cSrcweir delete [] pSetFlags;
1475cdf0e10cSrcweir if( pChkStr )
1476cdf0e10cSrcweir return *pChkStr;
1477cdf0e10cSrcweir return aName += String::CreateFromInt32( ++nNum );
1478cdf0e10cSrcweir }
1479cdf0e10cSrcweir
1480cdf0e10cSrcweir
1481