1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26
27 #include <ctype.h>
28 #include <hintids.hxx>
29 #include <hints.hxx>
30 #include <svtools/filter.hxx>
31
32 #include <vcl/graph.hxx>
33 #include <svl/urihelper.hxx>
34 #include <editeng/boxitem.hxx>
35 #include <editeng/boxitem.hxx>
36 #include <editeng/wghtitem.hxx>
37 #include <editeng/cmapitem.hxx>
38 #include <editeng/cntritem.hxx>
39 #include <editeng/postitem.hxx>
40 #include <editeng/crsditem.hxx>
41 #include <svl/stritem.hxx>
42 #include <unotools/charclass.hxx>
43 #include <txtftn.hxx>
44 #include <fmtpdsc.hxx>
45 #include <fmtftn.hxx>
46 #include <fmtanchr.hxx>
47 #include <fmtrfmrk.hxx>
48 #include <fmtclds.hxx>
49 #include <fmtfld.hxx>
50 #include <fmtfsize.hxx>
51 #include <fmthdft.hxx>
52 #include <fmtcntnt.hxx>
53 #include <redline.hxx>
54 #include <pam.hxx>
55 #include <doc.hxx>
56 #include <ndtxt.hxx>
57 #include <frmatr.hxx>
58 #include <fldbas.hxx> // RES_SETEXPFLD
59 #include <charatr.hxx> // class SwFmtRefMark
60 #include <swtable.hxx> // class SwTableLines, ...
61 #include <tox.hxx>
62 #include <expfld.hxx> // SwExpField
63 #include <section.hxx> // class SwSection
64 #include <tblsel.hxx> // class SwSelBoxes
65 #include <pagedesc.hxx>
66 #include <docsh.hxx> // class SwDocSh
67 #include <fltshell.hxx>
68 #include <viewsh.hxx>
69 #include <shellres.hxx>
70
71
72 #define MAX_FIELDLEN 64000
73
74 using namespace com::sun::star;
75
GetCntntNode(SwDoc * pDoc,SwNodeIndex & rIdx,sal_Bool bNext)76 static SwCntntNode* GetCntntNode(SwDoc* pDoc, SwNodeIndex& rIdx, sal_Bool bNext)
77 {
78 SwCntntNode * pCNd = rIdx.GetNode().GetCntntNode();
79 if(!pCNd && 0 == (pCNd = bNext ? pDoc->GetNodes().GoNext(&rIdx)
80 : pDoc->GetNodes().GoPrevious(&rIdx)))
81 {
82 pCNd = bNext ? pDoc->GetNodes().GoPrevious(&rIdx)
83 : pDoc->GetNodes().GoNext(&rIdx);
84 ASSERT(pCNd, "kein ContentNode gefunden");
85 }
86 return pCNd;
87 }
88
89 // ------ Stack-Eintrag fuer die gesamten - Attribute vom Text -----------
SwFltStackEntry(const SwPosition & rStartPos,SfxPoolItem * pHt)90 SwFltStackEntry::SwFltStackEntry(const SwPosition& rStartPos, SfxPoolItem* pHt ) :
91 nMkNode(rStartPos.nNode, -1),
92 //Modify here for #119405, by easyfan, 2012-05-24
93 nPtNode(nMkNode),mnStartCP(-1),mnEndCP(-1),bIsParaEnd(false)
94 //End of modification, by easyfan
95 {
96 // Anfang vom Bereich merken
97 nMkCntnt = rStartPos.nContent.GetIndex();
98 pAttr = pHt; // speicher eine Kopie vom Attribut
99 bOld = sal_False; // used for marking Attributes *before* skipping field results
100 bLocked = sal_True; // locke das Attribut --> darf erst
101 bCopied = sal_False; // gesetzt werden, wenn es wieder geunlocked ist
102 bConsumedByField = sal_False;
103 }
104
SwFltStackEntry(const SwFltStackEntry & rEntry)105 SwFltStackEntry::SwFltStackEntry(const SwFltStackEntry& rEntry) :
106 nMkNode(rEntry.nMkNode),
107 nPtNode(rEntry.nPtNode)
108 {
109 pAttr = rEntry.pAttr->Clone();
110 nMkCntnt= rEntry.nMkCntnt;
111 bOld = rEntry.bOld;
112 bLocked = bCopied = sal_True; // when rEntry were NOT bLocked we would never have been called
113 bConsumedByField = rEntry.bConsumedByField;
114 //Modify here for #119405, by chengjh, 2012-08-16
115 mnStartCP= rEntry.mnStartCP;
116 mnEndCP = rEntry.mnEndCP;
117 bIsParaEnd = rEntry.bIsParaEnd;
118 //End
119 }
120
121
~SwFltStackEntry()122 SwFltStackEntry::~SwFltStackEntry()
123 {
124 // Attribut kam zwar als Pointer, wird aber hier geloescht
125 if (pAttr)
126 delete pAttr;
127 }
128
SetEndPos(const SwPosition & rEndPos)129 void SwFltStackEntry::SetEndPos(const SwPosition& rEndPos)
130 {
131 // Attribut freigeben und das Ende merken.
132 // Alles mit sal_uInt16's, weil sonst beim Einfuegen von neuem Text an der
133 // Cursor-Position auch der Bereich vom Attribut weiter
134 // verschoben wird.
135 // Das ist aber nicht das gewollte!
136 bLocked = sal_False; // freigeben und das ENDE merken
137 nPtNode = rEndPos.nNode.GetIndex()-1;
138 nPtCntnt = rEndPos.nContent.GetIndex();
139 }
140 //Modify here for #119405, by chengjh, 2012-08-16
141 //The only position of 0x0D will not be able to make regin in the old logic
142 //because it is beyond the length of para...need special consideration here.
IsAbleMakeRegion()143 bool SwFltStackEntry::IsAbleMakeRegion()
144 {
145 SwCntntNode *const pCntntNode( SwNodeIndex(nMkNode, +1).GetNode().GetCntntNode() );
146 if ( (nMkNode.GetIndex() == nPtNode.GetIndex())
147 && (nMkCntnt == nPtCntnt)
148 && ( (0 != nPtCntnt)
149 || ( pCntntNode
150 && ( 0 != pCntntNode->Len() ) ) )
151 && ( RES_TXTATR_FIELD != pAttr->Which()
152 && RES_TXTATR_ANNOTATION != pAttr->Which()
153 && RES_TXTATR_INPUTFIELD != pAttr->Which() )
154 && !( bIsParaEnd
155 && pCntntNode
156 && pCntntNode->IsTxtNode()
157 && 0 != pCntntNode->Len() ) )
158 {
159 return false;
160 }
161
162 return true;
163 }
164 //End
MakeRegion(SwDoc * pDoc,SwPaM & rRegion,sal_Bool bCheck)165 sal_Bool SwFltStackEntry::MakeRegion(SwDoc* pDoc, SwPaM& rRegion, sal_Bool bCheck )
166 {
167 // does this range actually contain something?
168 // empty range is allowed if at start of empty paragraph
169 // fields are special: never have range, so leave them
170 //Modify here for #119405, by chengjh, 2012-08-16
171 //Revised the code and move the code segment to defined function
172 if ( !IsAbleMakeRegion() )
173 {
174 return sal_False;
175 }
176 //End
177 // !!! Die Content-Indizies beziehen sich immer auf den Node !!!
178 rRegion.GetPoint()->nNode = nMkNode.GetIndex() + 1;
179 SwCntntNode* pCNd = GetCntntNode(pDoc, rRegion.GetPoint()->nNode, sal_True);
180 rRegion.GetPoint()->nContent.Assign(pCNd, nMkCntnt);
181 rRegion.SetMark();
182 if( nMkNode != nPtNode )
183 {
184 rRegion.GetPoint()->nNode = nPtNode.GetIndex() + 1;
185 pCNd = GetCntntNode(pDoc, rRegion.GetPoint()->nNode, sal_False);
186 }
187 rRegion.GetPoint()->nContent.Assign(pCNd, nPtCntnt);
188 #if OSL_DEBUG_LEVEL > 1
189 ASSERT( CheckNodesRange( rRegion.Start()->nNode,
190 rRegion.End()->nNode, sal_True ),
191 "Attribut oder AEhnliches ueber Bereichs-Grenzen" );
192 #endif
193 if( bCheck )
194 return CheckNodesRange( rRegion.Start()->nNode,
195 rRegion.End()->nNode, sal_True );
196 else
197 return sal_True;
198 }
199
SwFltControlStack(SwDoc * pDo,sal_uLong nFieldFl)200 SwFltControlStack::SwFltControlStack(SwDoc* pDo, sal_uLong nFieldFl)
201 : nFieldFlags(nFieldFl), bHasSdOD(true)
202 ,bSdODChecked(false), pDoc(pDo), bIsEndStack(false)
203 //End
204
205 {
206 }
207
208
~SwFltControlStack()209 SwFltControlStack::~SwFltControlStack()
210 {
211 ASSERT(!Count(), "noch Attribute auf dem Stack");
212 }
213
214 // MoveAttrs() ist fuer folgendes Problem:
215 // Wenn ueber den Stack ein Feld wie z.B. "Variable setzen" gesetzt wird,
216 // verschiebt sich der Text um ein \xff - Zeichen, und alle folgenden
217 // Attribute stimmen in ihrer Position nicht mehr.
218 // Dann muss MoveAttrs() nach dem Setzen des Attributes ins Doc gerufen werden,
219 // so dass alle Attribut-Positionen,
220 // die im selben Absatz weiter hinten stehen, um 1 Zeichen weiter
221 // nach rechts verschoben werden.
MoveAttrs(const SwPosition & rPos)222 void SwFltControlStack::MoveAttrs( const SwPosition& rPos )
223 {
224 sal_uInt16 nCnt = static_cast< sal_uInt16 >(Count());
225 SwFltStackEntry* pEntry;
226 sal_uLong nPosNd = rPos.nNode.GetIndex();
227 sal_uInt16 nPosCt = rPos.nContent.GetIndex() - 1;
228
229 for (sal_uInt16 i=0; i < nCnt; i++){
230 pEntry = (*this)[ i ];
231 if(( pEntry->nMkNode.GetIndex() + 1 == nPosNd )
232 &&( pEntry->nMkCntnt >= nPosCt )){
233 pEntry->nMkCntnt++;
234 ASSERT( pEntry->nMkCntnt
235 <= pDoc->GetNodes()[nPosNd]->GetCntntNode()->Len(),
236 "Attribut-Anfang hinter Zeilenende" );
237 }
238 if(( pEntry->nPtNode.GetIndex() + 1 == nPosNd )
239 &&( pEntry->nPtCntnt >= nPosCt )){
240 pEntry->nPtCntnt++;
241 ASSERT( pEntry->nPtCntnt
242 <= pDoc->GetNodes()[nPosNd]->GetCntntNode()->Len(),
243 "Attribut-Ende hinter Zeilenende" );
244 }
245 }
246 }
247
MarkAllAttrsOld()248 void SwFltControlStack::MarkAllAttrsOld()
249 {
250 sal_uInt16 nCnt = static_cast< sal_uInt16 >(Count());
251 for (sal_uInt16 i=0; i < nCnt; i++)
252 (*this)[ i ]->bOld = sal_True;
253 }
254
NewAttr(const SwPosition & rPos,const SfxPoolItem & rAttr)255 void SwFltControlStack::NewAttr(const SwPosition& rPos, const SfxPoolItem & rAttr )
256 {
257 SwFltStackEntry *pTmp = new SwFltStackEntry(rPos, rAttr.Clone() );
258 //Modify here for #119405, by easyfan, 2012-05-24
259 pTmp->SetStartCP(GetCurrAttrCP());
260 //End of modification, by easyfan
261 sal_uInt16 nWhich = pTmp->pAttr->Which();
262 SetAttr(rPos, nWhich);// Ende von evtl. gleichen Attributen auf dem Stack
263 // Setzen, damit sich die Attribute nicht auf
264 // dem Stack haeufen
265 maEntries.push_back(pTmp);
266 }
267
DeleteAndDestroy(Entries::size_type nCnt)268 void SwFltControlStack::DeleteAndDestroy(Entries::size_type nCnt)
269 {
270 ASSERT(nCnt < maEntries.size(), "Out of range!");
271 if (nCnt < maEntries.size())
272 {
273 myEIter aElement = maEntries.begin() + nCnt;
274 delete *aElement;
275 maEntries.erase(aElement);
276 }
277 //Modify for #119405 by chengjh, 2012-08-16
278 //Clear the para end position recorded in reader intermittently for the least impact on loading performance
279 //Because the attributes handled based on the unit of para
280 if ( Count() == 0 )
281 {
282 ClearParaEndPosition();
283 bHasSdOD = true;
284 bSdODChecked = false;
285 }
286 //End
287 }
288
289 // SwFltControlStack::StealAttr() loescht Attribute des angegebenen Typs vom Stack.
290 // Als nAttrId sind erlaubt: 0 fuer alle, oder ein spezieller Typ.
291 // Damit erscheinen sie nicht in der Doc-Struktur. Dabei werden nur die
292 // Attribute entfernt, die im selben Absatz wie pPos stehen.
293 // Wird fuer Grafik-Apos -> Grafiken benutzt.
StealAttr(const SwPosition * pPos,sal_uInt16 nAttrId)294 void SwFltControlStack::StealAttr(const SwPosition* pPos, sal_uInt16 nAttrId /* = 0 */)
295 {
296 sal_uInt16 nCnt = static_cast< sal_uInt16 >(Count());
297
298 SwFltStackEntry* pEntry;
299
300 while (nCnt)
301 {
302 nCnt --;
303 pEntry = (*this)[ nCnt ];
304 if (pEntry->nPtNode.GetIndex()+1 == pPos->nNode.GetIndex() &&
305 (!nAttrId || nAttrId == pEntry->pAttr->Which()))
306 DeleteAndDestroy(nCnt); // loesche aus dem Stack
307 }
308 }
309
310 // SwFltControlStack::KillUnlockedAttr() loescht alle Attribute vom Stack,
311 // welche punktuell auf pPos aufgespannt sind.
312 // Damit erscheinen sie nicht in der Doc-Struktur.
313 // Wird im WW Import benoetigt zum ignorieren der auf dem 0x0c Section-
314 // Break-Symbol gesetzten Attribute.
KillUnlockedAttrs(const SwPosition & pPos)315 void SwFltControlStack::KillUnlockedAttrs(const SwPosition& pPos)
316 {
317 SwNodeIndex aAktNode( pPos.nNode, -1 );
318 sal_uInt16 nAktIdx = pPos.nContent.GetIndex();
319
320 sal_uInt16 nCnt = static_cast< sal_uInt16 >(Count());
321 SwFltStackEntry* pEntry;
322 while( nCnt )
323 {
324 nCnt --;
325 pEntry = (*this)[ nCnt ];
326 if( !pEntry->bOld
327 && !pEntry->bLocked
328 && (pEntry->nMkNode == aAktNode)
329 && (pEntry->nMkCntnt == nAktIdx )
330 && (pEntry->nPtNode == aAktNode)
331 && (pEntry->nPtCntnt == nAktIdx ))
332 {
333 DeleteAndDestroy( nCnt ); // loesche aus dem Stack
334 }
335 }
336 }
337
338 // Alle gelockten Attribute freigeben (unlocken) und das Ende setzen,
339 // alle anderen im Document setzen und wieder aus dem Stack loeschen
340 // Returned, ob das gesuchte Attribut / die gesuchten Attribute
341 // ueberhaupt auf dem Stack standen
SetAttr(const SwPosition & rPos,sal_uInt16 nAttrId,sal_Bool bTstEnde,long nHand,sal_Bool consumedByField)342 void SwFltControlStack::SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId,
343 sal_Bool bTstEnde, long nHand, sal_Bool consumedByField )
344 {
345 ASSERT(!nAttrId ||
346 (POOLATTR_BEGIN <= nAttrId && POOLATTR_END > nAttrId) ||
347 (RES_FLTRATTR_BEGIN <= nAttrId && RES_FLTRATTR_END > nAttrId),
348 "Falsche Id fuers Attribut")
349
350 sal_uInt16 nCnt = static_cast< sal_uInt16 >(Count());
351
352 SwFltStackEntry* pEntry;
353
354 for (sal_uInt16 i=0; i < nCnt; i++)
355 {
356 pEntry = (*this)[ i ];
357 if (pEntry->bLocked)
358 {
359 // setze das Ende vom Attribut
360 bool bF = false;
361 if (!nAttrId ){
362 bF = true;
363 }else if( nAttrId == pEntry->pAttr->Which()){
364 if( nAttrId != RES_FLTR_BOOKMARK ){ // Handle abfragen
365 bF = true;
366 }else if( nHand == ((SwFltBookmark*)(pEntry->pAttr))->GetHandle() )
367 {
368 bF = true;
369 }
370 }
371 if (bF) {
372 pEntry->bConsumedByField = consumedByField;
373 pEntry->SetEndPos(rPos);
374 //Modify here for #119405, by easyfan, 2012-05-24
375 pEntry->SetEndCP(GetCurrAttrCP());
376 //End of modification, by easyfan
377 }
378 continue;
379 }
380
381 // ist die Endposition die Cursor-Position, dann noch nicht
382 // ins Dokument setzen, es muss noch Text folgen;
383 // ausser am Dokumentende. (Attribut-Expandierung !!)
384 // Beim Ende-Stack niemals ausser am DocEnde reinsetzen
385 if (bTstEnde)
386 {
387 if (bIsEndStack || pEntry->nPtNode.GetIndex()+1 ==
388 rPos.nNode.GetIndex())
389 continue;
390 }
391 SetAttrInDoc(rPos, pEntry);
392 DeleteAndDestroy(i); // loesche aus dem Stack
393 i--; nCnt--; // Danach rutschen alle folgenden nach unten
394 }
395 }
396
MakePoint(SwFltStackEntry * pEntry,SwDoc * pDoc,SwPaM & rRegion)397 static void MakePoint(SwFltStackEntry* pEntry, SwDoc* pDoc, SwPaM& rRegion)
398 {
399 // der Anker ist der Point vom Pam. Dieser wird beim Einfugen
400 // von Text usw. veraendert; darum wird er auf dem Stack
401 // gespeichert. Das Attribut muss nur noch im Format
402 // gesetzt werden.
403 rRegion.DeleteMark();
404 rRegion.GetPoint()->nNode = pEntry->nMkNode.GetIndex() + 1;
405 SwCntntNode* pCNd = GetCntntNode(pDoc, rRegion.GetPoint()->nNode, sal_True);
406 rRegion.GetPoint()->nContent.Assign(pCNd, pEntry->nMkCntnt);
407 }
408
409 // MakeBookRegionOrPoint() ist wie MakeRegionOrPoint, aber die besonderen
410 // Beschraenkungen von Bookmarks in Tabellen werden beachtet.
411 // ( Anfang und Ende muessen in selber Zelle sein )
MakeBookRegionOrPoint(SwFltStackEntry * pEntry,SwDoc * pDoc,SwPaM & rRegion,sal_Bool bCheck)412 static void MakeBookRegionOrPoint(SwFltStackEntry* pEntry, SwDoc* pDoc,
413 SwPaM& rRegion, sal_Bool bCheck )
414 {
415 if (pEntry->MakeRegion(pDoc, rRegion, bCheck )){
416 // sal_Bool b1 = rNds[rRegion.GetPoint()->nNode]->FindTableNode() != 0;
417 // const SwStartNode* p1 = rNds[rRegion.GetPoint()->nNode]->FindTableBoxStartNode();
418 // const SwStartNode* p2 = rNds[rRegion.GetMark()->nNode]->FindTableBoxStartNode();
419 if (rRegion.GetPoint()->nNode.GetNode().FindTableBoxStartNode()
420 != rRegion.GetMark()->nNode.GetNode().FindTableBoxStartNode())
421 {
422 rRegion.Exchange(); // Ungueltiger Bereich
423 rRegion.DeleteMark(); // -> beide auf Mark
424 }
425 }else{
426 MakePoint(pEntry, pDoc, rRegion);
427 }
428 }
429
430 #if OSL_DEBUG_LEVEL > 1
431 extern sal_Bool CheckNodesRange( const SwNodeIndex& rStt,
432 const SwNodeIndex& rEnd, sal_Bool bChkSection );
433 #endif
434
435 // IterateNumrulePiece() sucht von rTmpStart bis rEnd den ersten
436 // fuer Numrules gueltigen Bereich heraus.
437 //
438 // rNds sind die Doc-Nodes
439 // rEnd ist Bereichs-Ende,
440 // rTmpStart ist ReinRaus-Parameter: Anfang des zu untersuchenden Bereiches rein,
441 // Anfang des gueltigen Bereichs raus
442 // rTmpEnd ist raus-Parameter
443 // Return-Bool ist sal_True fuer gueltigen Bereich
IterateNumrulePiece(const SwNodeIndex & rEnd,SwNodeIndex & rTmpStart,SwNodeIndex & rTmpEnd)444 static sal_Bool IterateNumrulePiece( const SwNodeIndex& rEnd,
445 SwNodeIndex& rTmpStart, SwNodeIndex& rTmpEnd )
446 {
447 while( ( rTmpStart <= rEnd )
448 && !( rTmpStart.GetNode().IsTxtNode() ) ) // suche gueltigen Anfang
449 rTmpStart++;
450
451 rTmpEnd = rTmpStart;
452 while( ( rTmpEnd <= rEnd )
453 && ( rTmpEnd.GetNode().IsTxtNode() ) ) // suche gueltiges Ende + 1
454 rTmpEnd++;
455
456 rTmpEnd--; // gueltiges Ende
457
458 return rTmpStart <= rTmpEnd; // gueltig ?
459 }
460 //Modify for #119405 by chengjh, 2012-08-16
461 //***This function will check whether there is existing individual attribute positon for 0x0D***/
462 //The check will happen only once for a paragraph during loading
HasSdOD()463 bool SwFltControlStack::HasSdOD()
464 {
465 sal_uInt16 nCnt = static_cast< sal_uInt16 >(Count());
466
467 SwFltStackEntry* pEntry = 0;
468
469 bool bRet = false;
470
471 for (sal_uInt16 i=0; i < nCnt; i++)
472 {
473 pEntry = (*this)[ i ];
474 if ( pEntry && pEntry->mnStartCP == pEntry->mnEndCP )
475 {
476 if ( CheckSdOD(pEntry->mnStartCP,pEntry->mnEndCP) )
477 {
478 bRet = true;
479 break;
480 }
481 }
482 }
483
484 return bRet;
485 }
486 //End
SetAttrInDoc(const SwPosition & rTmpPos,SwFltStackEntry * pEntry)487 void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry* pEntry)
488 {
489 SwPaM aRegion( rTmpPos );
490
491 switch(pEntry->pAttr->Which())
492 {
493 case RES_FLTR_ANCHOR:
494 {
495 SwFrmFmt* pFmt = ((SwFltAnchor*)pEntry->pAttr)->GetFrmFmt();
496 if (pFmt != NULL)
497 {
498 MakePoint(pEntry, pDoc, aRegion);
499 SwFmtAnchor aAnchor(pFmt->GetAnchor());
500 aAnchor.SetAnchor(aRegion.GetPoint());
501 pFmt->SetFmtAttr(aAnchor);
502 // Damit die Frames bei Einfuegen in existierendes Doc
503 // erzeugt werden (erst nach Setzen des Ankers!):
504 if(pDoc->GetCurrentViewShell() //swmod 071108//swmod 071225
505 && (FLY_AT_PARA == pFmt->GetAnchor().GetAnchorId()))
506 {
507 pFmt->MakeFrms();
508 }
509 }
510 }
511 break;
512 case RES_FLTR_STYLESHEET:
513 break;
514
515 case RES_TXTATR_FIELD:
516 case RES_TXTATR_ANNOTATION:
517 case RES_TXTATR_INPUTFIELD:
518 break;
519
520 case RES_TXTATR_TOXMARK:
521 break;
522
523 case RES_FLTR_NUMRULE: // Numrule 'reinsetzen
524 {
525 const String& rNumNm = ((SfxStringItem*)pEntry->pAttr)->GetValue();
526 SwNumRule* pRul = pDoc->FindNumRulePtr( rNumNm );
527 if( pRul )
528 {
529 if( pEntry->MakeRegion(pDoc, aRegion, sal_True))
530 {
531 SwNodeIndex aTmpStart( aRegion.Start()->nNode );
532 SwNodeIndex aTmpEnd( aTmpStart );
533 SwNodeIndex& rRegEndNd = aRegion.End()->nNode;
534 while( IterateNumrulePiece( rRegEndNd,
535 aTmpStart, aTmpEnd ) )
536 {
537 SwPaM aTmpPam( aTmpStart, aTmpEnd );
538 // --> OD 2008-03-17 #refactorlists#
539 // no start of a new list
540 pDoc->SetNumRule( aTmpPam, *pRul, false );
541 // <--
542
543 aTmpStart = aTmpEnd; // Start fuer naechstes Teilstueck
544 aTmpStart++;
545 }
546 }
547 else
548 pDoc->DelNumRule( rNumNm );
549 }
550 }
551 break;
552 case RES_FLTR_NUMRULE_NUM:
553 break;
554 case RES_FLTR_BOOKMARK:
555 {
556 SwFltBookmark* pB = (SwFltBookmark*)pEntry->pAttr;
557 const String& rName = ((SwFltBookmark*)pEntry->pAttr)->GetName();
558
559 if (IsFlagSet(BOOK_TO_VAR_REF))
560 {
561 SwFieldType* pFT = pDoc->GetFldType(RES_SETEXPFLD, rName, false);
562 if (!pFT)
563 {
564 SwSetExpFieldType aS(pDoc, rName, nsSwGetSetExpType::GSE_STRING);
565 pFT = pDoc->InsertFldType(aS);
566 }
567 SwSetExpField aFld((SwSetExpFieldType*)pFT, pB->GetValSys());
568 aFld.SetSubType( nsSwExtendedSubType::SUB_INVISIBLE );
569 MakePoint(pEntry, pDoc, aRegion);
570 pDoc->InsertPoolItem(aRegion, SwFmtFld(aFld), 0);
571 MoveAttrs( *(aRegion.GetPoint()) );
572 }
573 if ( ( !IsFlagSet(HYPO) || IsFlagSet(BOOK_AND_REF) ) &&
574 !pEntry->bConsumedByField )
575 {
576 MakeBookRegionOrPoint(pEntry, pDoc, aRegion, sal_True);
577 // #120879# - create a cross reference heading bookmark if appropriate.
578 const IDocumentMarkAccess::MarkType eBookmarkType =
579 ( pB->IsTOCBookmark() &&
580 IDocumentMarkAccess::IsLegalPaMForCrossRefHeadingBookmark( aRegion ) )
581 ? IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK
582 : IDocumentMarkAccess::BOOKMARK;
583 pDoc->getIDocumentMarkAccess()->makeMark( aRegion, rName, eBookmarkType );
584 }
585 }
586 break;
587 case RES_FLTR_TOX:
588 {
589 MakePoint(pEntry, pDoc, aRegion);
590
591 SwPosition* pPoint = aRegion.GetPoint();
592
593 SwFltTOX* pTOXAttr = (SwFltTOX*)pEntry->pAttr;
594
595 // test if on this node there had been a pagebreak BEFORE the
596 // tox attribut was put on the stack
597 SfxItemSet aBkSet( pDoc->GetAttrPool(), RES_PAGEDESC, RES_BREAK );
598 SwCntntNode* pNd = 0;
599 if( !pTOXAttr->HadBreakItem() || !pTOXAttr->HadPageDescItem() )
600 {
601 pNd = pPoint->nNode.GetNode().GetCntntNode();
602 if( pNd )
603 {
604 const SfxItemSet* pSet = pNd->GetpSwAttrSet();
605 const SfxPoolItem* pItem;
606 if( pSet )
607 {
608 if( !pTOXAttr->HadBreakItem()
609 && SFX_ITEM_SET == pSet->GetItemState( RES_BREAK, sal_False, &pItem ) )
610 {
611 aBkSet.Put( *pItem );
612 pNd->ResetAttr( RES_BREAK );
613 }
614 if( !pTOXAttr->HadPageDescItem()
615 && SFX_ITEM_SET == pSet->GetItemState( RES_PAGEDESC, sal_False, &pItem ) )
616 {
617 aBkSet.Put( *pItem );
618 pNd->ResetAttr( RES_PAGEDESC );
619 }
620 }
621 }
622 }
623
624 delete pTOXAttr->GetBase();
625
626 // set (aboved saved and removed) the break item at the node following the TOX
627 if( aBkSet.Count() )
628 pNd->SetAttr( aBkSet );
629 }
630 break;
631 case RES_FLTR_SECTION:
632 MakePoint(pEntry, pDoc, aRegion); // bislang immer Point==Mark
633 pDoc->InsertSwSection(aRegion,
634 *(static_cast<SwFltSection*>(pEntry->pAttr))->GetSectionData(),
635 0, 0, false);
636 delete (((SwFltSection*)pEntry->pAttr)->GetSectionData());
637 break;
638 case RES_FLTR_REDLINE:
639 {
640 if (pEntry->MakeRegion(pDoc, aRegion, sal_True))
641 {
642 pDoc->SetRedlineMode((RedlineMode_t)( nsRedlineMode_t::REDLINE_ON
643 | nsRedlineMode_t::REDLINE_SHOW_INSERT
644 | nsRedlineMode_t::REDLINE_SHOW_DELETE ));
645 SwFltRedline& rFltRedline = *((SwFltRedline*)pEntry->pAttr);
646
647 if( USHRT_MAX != rFltRedline.nAutorNoPrev )
648 {
649 SwRedlineData aData(rFltRedline.eTypePrev,
650 rFltRedline.nAutorNoPrev,
651 rFltRedline.aStampPrev,
652 aEmptyStr,
653 0
654 );
655 pDoc->AppendRedline(new SwRedline(aData, aRegion), true);
656 }
657 SwRedlineData aData(rFltRedline.eType,
658 rFltRedline.nAutorNo,
659 rFltRedline.aStamp,
660 aEmptyStr,
661 0
662 );
663 pDoc->AppendRedline( new SwRedline(aData, aRegion), true );
664 pDoc->SetRedlineMode((RedlineMode_t)( nsRedlineMode_t::REDLINE_NONE
665 | nsRedlineMode_t::REDLINE_SHOW_INSERT
666 | nsRedlineMode_t::REDLINE_SHOW_DELETE ));
667 }
668 }
669 break;
670 default:
671 {
672 //Modify here for #119405, by chengjh, 2012-08-16
673 //Revised for more complex situations should be considered
674 if ( !bSdODChecked )
675 {
676 bHasSdOD = HasSdOD();
677 bSdODChecked = true;
678 }
679 sal_Int32 nStart = pEntry->GetStartCP();
680 sal_Int32 nEnd = pEntry->GetEndCP();
681 if (nStart != -1 && nEnd != -1 && nEnd >= nStart )
682 {
683 pEntry->SetIsParaEnd( IsParaEndInCPs(nStart,nEnd,bHasSdOD) );
684 }
685 //End
686 if (pEntry->MakeRegion(pDoc, aRegion, sal_False))
687 {
688 //Modify here for #119405, by easyfan, 2012-05-24
689 //Refined 2012-08-16
690 if (pEntry->IsParaEnd())
691 {
692 pDoc->InsertPoolItem(aRegion, *pEntry->pAttr, 0,true);
693 }else
694 {
695 pDoc->InsertPoolItem(aRegion, *pEntry->pAttr, 0);
696 }
697 //End
698 }
699 }
700 break;
701 }
702 }
703
GetFmtStackAttr(sal_uInt16 nWhich,sal_uInt16 * pPos)704 SfxPoolItem* SwFltControlStack::GetFmtStackAttr(sal_uInt16 nWhich, sal_uInt16 * pPos)
705 {
706 SwFltStackEntry* pEntry;
707 sal_uInt16 nSize = static_cast< sal_uInt16 >(Count());
708
709 while (nSize)
710 {
711 // ist es das gesuchte Attribut ? (gueltig sind nur gelockte,
712 // also akt. gesetzte Attribute!!)
713 if ((pEntry = (*this)[ --nSize ])->bLocked &&
714 pEntry->pAttr->Which() == nWhich)
715 {
716 if (pPos)
717 *pPos = nSize;
718 return (SfxPoolItem*)pEntry->pAttr; // Ok, dann Ende
719 }
720 }
721 return 0;
722 }
723
GetOpenStackAttr(const SwPosition & rPos,sal_uInt16 nWhich)724 const SfxPoolItem* SwFltControlStack::GetOpenStackAttr(const SwPosition& rPos, sal_uInt16 nWhich)
725 {
726 SwFltStackEntry* pEntry;
727 sal_uInt16 nSize = static_cast< sal_uInt16 >(Count());
728 SwNodeIndex aAktNode( rPos.nNode, -1 );
729 sal_uInt16 nAktIdx = rPos.nContent.GetIndex();
730
731 while (nSize)
732 {
733 pEntry = (*this)[ --nSize ];
734 if( pEntry->bLocked
735 && (pEntry->pAttr->Which() == nWhich)
736 && (pEntry->nMkNode == aAktNode)
737 && (pEntry->nMkCntnt == nAktIdx ))
738 {
739 return (SfxPoolItem*)pEntry->pAttr;
740 }
741 }
742 return 0;
743 }
744
GetFmtAttr(const SwPosition & rPos,sal_uInt16 nWhich)745 const SfxPoolItem* SwFltControlStack::GetFmtAttr(const SwPosition& rPos, sal_uInt16 nWhich)
746 {
747 SfxPoolItem* pHt = GetFmtStackAttr(nWhich);
748 if (pHt)
749 return (const SfxPoolItem*)pHt;
750
751 // im Stack ist das Attribut nicht vorhanden, also befrage das Dokument
752 // SwCntntNode * pNd = rPaM.GetCntntNode();
753 SwCntntNode * pNd = rPos.nNode.GetNode().GetCntntNode();
754
755 if (!pNd) // kein ContentNode, dann das dflt. Attribut
756 return &pDoc->GetAttrPool().GetDefaultItem(nWhich);
757 return &pNd->GetAttr(nWhich);
758 }
759
Delete(const SwPaM & rPam)760 void SwFltControlStack::Delete(const SwPaM &rPam)
761 {
762 const SwPosition *pStt = rPam.Start(), *pEnd = rPam.End();
763
764 if( !rPam.HasMark() || *pStt >= *pEnd )
765 return;
766
767 SwNodeIndex aStartNode(pStt->nNode, -1);
768 sal_uInt16 nStartIdx = pStt->nContent.GetIndex();
769 SwNodeIndex aEndNode(pEnd->nNode, -1);
770 sal_uInt16 nEndIdx = pEnd->nContent.GetIndex();
771
772 //We don't support deleting content that is over one node, or removing a node.
773 ASSERT(aEndNode == aStartNode, "nodes must be the same, or this method extended");
774 if (aEndNode != aStartNode)
775 return;
776
777 for (sal_uInt16 nSize = static_cast< sal_uInt16 >(Count()); nSize > 0;)
778 {
779 SwFltStackEntry* pEntry = (*this)[--nSize];
780
781 bool bEntryStartAfterSelStart =
782 (pEntry->nMkNode == aStartNode && pEntry->nMkCntnt >= nStartIdx);
783
784 bool bEntryStartBeforeSelEnd =
785 (pEntry->nMkNode == aEndNode && pEntry->nMkCntnt <= nEndIdx);
786
787 bool bEntryEndAfterSelStart = false;
788 bool bEntryEndBeforeSelEnd = false;
789 if (!pEntry->bLocked)
790 {
791 bEntryEndAfterSelStart =
792 (pEntry->nPtNode == aStartNode && pEntry->nPtCntnt >= nStartIdx);
793
794 bEntryEndBeforeSelEnd =
795 (pEntry->nPtNode == aEndNode && pEntry->nPtCntnt <= nEndIdx);
796 }
797
798 bool bTotallyContained = false;
799 if (
800 bEntryStartAfterSelStart && bEntryStartBeforeSelEnd &&
801 bEntryEndAfterSelStart && bEntryEndBeforeSelEnd
802 )
803 {
804 bTotallyContained = true;
805 }
806
807 if (bTotallyContained)
808 {
809 //after start, before end, delete
810 DeleteAndDestroy(nSize);
811 continue;
812 }
813
814 xub_StrLen nCntntDiff = nEndIdx - nStartIdx;
815
816 //to be adjusted
817 if (bEntryStartAfterSelStart)
818 {
819 if (bEntryStartBeforeSelEnd)
820 {
821 //move start to new start
822 pEntry->nMkNode = aStartNode;
823 pEntry->nMkCntnt = nStartIdx;
824 }
825 else
826 pEntry->nMkCntnt = pEntry->nMkCntnt - nCntntDiff;
827 }
828
829 if (bEntryEndAfterSelStart)
830 {
831 if (bEntryEndBeforeSelEnd)
832 {
833 pEntry->nPtNode = aStartNode;
834 pEntry->nPtCntnt = nStartIdx;
835 }
836 else
837 pEntry->nPtCntnt = pEntry->nPtCntnt - nCntntDiff;
838 }
839
840 //That's what locked is, end equal to start, and nPtCntnt is invalid
841 if (pEntry->bLocked)
842 pEntry->nPtNode = pEntry->nMkNode;
843 }
844 }
845
846 //------ hier stehen die Methoden von SwFltAnchor -----------
SwFltAnchor(SwFrmFmt * pFmt)847 SwFltAnchor::SwFltAnchor(SwFrmFmt* pFmt) :
848 SfxPoolItem(RES_FLTR_ANCHOR), pFrmFmt(pFmt)
849 {
850 pClient = new SwFltAnchorClient(this);
851 pFrmFmt->Add(pClient);
852 }
853
SwFltAnchor(const SwFltAnchor & rCpy)854 SwFltAnchor::SwFltAnchor(const SwFltAnchor& rCpy) :
855 SfxPoolItem(RES_FLTR_ANCHOR), pFrmFmt(rCpy.pFrmFmt)
856 {
857 pClient = new SwFltAnchorClient(this);
858 pFrmFmt->Add(pClient);
859 }
860
~SwFltAnchor()861 SwFltAnchor::~SwFltAnchor()
862 {
863 delete pClient;
864 }
865
SetFrmFmt(SwFrmFmt * _pFrmFmt)866 void SwFltAnchor::SetFrmFmt(SwFrmFmt * _pFrmFmt)
867 {
868 pFrmFmt = _pFrmFmt;
869 }
870
GetFrmFmt() const871 const SwFrmFmt * SwFltAnchor::GetFrmFmt() const
872 {
873 return pFrmFmt;
874 }
875
GetFrmFmt()876 SwFrmFmt * SwFltAnchor::GetFrmFmt()
877 {
878 return pFrmFmt;
879 }
880
operator ==(const SfxPoolItem & rItem) const881 int SwFltAnchor::operator==(const SfxPoolItem& rItem) const
882 {
883 return pFrmFmt == ((SwFltAnchor&)rItem).pFrmFmt;
884 }
885
Clone(SfxItemPool *) const886 SfxPoolItem* __EXPORT SwFltAnchor::Clone(SfxItemPool*) const
887 {
888 return new SwFltAnchor(*this);
889 }
890
891 // SwFltAnchorClient
892
SwFltAnchorClient(SwFltAnchor * pFltAnchor)893 SwFltAnchorClient::SwFltAnchorClient(SwFltAnchor * pFltAnchor)
894 : m_pFltAnchor(pFltAnchor)
895 {
896 }
897
Modify(const SfxPoolItem *,const SfxPoolItem * pNew)898 void SwFltAnchorClient::Modify(const SfxPoolItem *, const SfxPoolItem * pNew)
899 {
900 if (pNew->Which() == RES_FMT_CHG)
901 {
902 const SwFmtChg * pFmtChg = dynamic_cast<const SwFmtChg *> (pNew);
903
904 if (pFmtChg != NULL)
905 {
906 SwFrmFmt * pFrmFmt = dynamic_cast<SwFrmFmt *> (pFmtChg->pChangedFmt);
907
908 if (pFrmFmt != NULL)
909 m_pFltAnchor->SetFrmFmt(pFrmFmt);
910 }
911 }
912 }
913
914 //------ hier stehen die Methoden von SwFltRedline -----------
operator ==(const SfxPoolItem & rItem) const915 int SwFltRedline::operator==(const SfxPoolItem& rItem) const
916 {
917 return this == &rItem;
918 }
919
Clone(SfxItemPool *) const920 SfxPoolItem* SwFltRedline::Clone( SfxItemPool* ) const
921 {
922 return new SwFltRedline(*this);
923 }
924
925 //------ hier stehen die Methoden von SwFltBookmark -----------
SwFltBookmark(const String & rNa,const String & rVa,long nHand,const bool bIsTOCBookmark)926 SwFltBookmark::SwFltBookmark( const String& rNa, const String& rVa,
927 long nHand, const bool bIsTOCBookmark )
928 : SfxPoolItem( RES_FLTR_BOOKMARK )
929 , mnHandle( nHand )
930 , maName( rNa )
931 , maVal( rVa )
932 , mbIsTOCBookmark( bIsTOCBookmark )
933 {
934 // eSrc: CHARSET_DONTKNOW fuer keine UEbersetzung bei operator <<
935 // Upcase wird immer gemacht.
936 // bei XXXStack.NewAttr(...) wird nie eine UEbersetzung vorgenommen.
937 // ansonsten: uebergebener Src-Charset fuer aName
938 // im Filter eingestellter Src-Charset fuer aVal ( Text )
939
940 if ( IsTOCBookmark() )
941 {
942 maName = IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix();
943 maName += rNa;
944 }
945 }
946
SwFltBookmark(const SwFltBookmark & rCpy)947 SwFltBookmark::SwFltBookmark(const SwFltBookmark& rCpy)
948 : SfxPoolItem( RES_FLTR_BOOKMARK )
949 , mnHandle( rCpy.mnHandle )
950 , maName( rCpy.maName )
951 , maVal( rCpy.maVal )
952 , mbIsTOCBookmark( rCpy.mbIsTOCBookmark )
953 {
954 }
955
operator ==(const SfxPoolItem & rItem) const956 int SwFltBookmark::operator==(const SfxPoolItem& rItem) const
957 {
958 return ( maName == ((SwFltBookmark&)rItem).maName)
959 && (mnHandle == ((SwFltBookmark&)rItem).mnHandle);
960 }
961
Clone(SfxItemPool *) const962 SfxPoolItem* SwFltBookmark::Clone(SfxItemPool*) const
963 {
964 return new SwFltBookmark(*this);
965 }
966
967 //------ hier stehen die Methoden von SwFltTOX -----------
968
SwFltTOX(SwTOXBase * pBase,sal_uInt16 _nCols)969 SwFltTOX::SwFltTOX(SwTOXBase* pBase, sal_uInt16 _nCols)
970 : SfxPoolItem(RES_FLTR_TOX), pTOXBase(pBase), nCols( _nCols ),
971 bHadBreakItem( sal_False ), bHadPageDescItem( sal_False )
972 {
973 }
974
SwFltTOX(const SwFltTOX & rCpy)975 SwFltTOX::SwFltTOX(const SwFltTOX& rCpy)
976 : SfxPoolItem(RES_FLTR_TOX), pTOXBase(rCpy.pTOXBase), nCols( rCpy.nCols ),
977 bHadBreakItem( rCpy.bHadBreakItem ), bHadPageDescItem( rCpy.bHadPageDescItem )
978 {
979 }
980
operator ==(const SfxPoolItem & rItem) const981 int SwFltTOX::operator==(const SfxPoolItem& rItem) const
982 {
983 return pTOXBase == ((SwFltTOX&)rItem).pTOXBase;
984 }
985
Clone(SfxItemPool *) const986 SfxPoolItem* SwFltTOX::Clone(SfxItemPool*) const
987 {
988 return new SwFltTOX(*this);
989 }
990
991 //------ hier stehen die Methoden von SwFltSwSection -----------
992
SwFltSection(SwSectionData * const pSect)993 SwFltSection::SwFltSection(SwSectionData *const pSect)
994 : SfxPoolItem(RES_FLTR_SECTION)
995 , m_pSection(pSect)
996 {
997 }
998
SwFltSection(const SwFltSection & rCpy)999 SwFltSection::SwFltSection(const SwFltSection& rCpy)
1000 : SfxPoolItem(RES_FLTR_SECTION)
1001 , m_pSection(rCpy.m_pSection)
1002 {
1003 }
1004
operator ==(const SfxPoolItem & rItem) const1005 int SwFltSection::operator==(const SfxPoolItem& rItem) const
1006 {
1007 return m_pSection == ((SwFltSection&)rItem).m_pSection;
1008 }
1009
Clone(SfxItemPool *) const1010 SfxPoolItem* __EXPORT SwFltSection::Clone(SfxItemPool*) const
1011 {
1012 return new SwFltSection(*this);
1013 }
1014
1015 ///////////////////////////////////////////////////////////////////////
1016 //
1017 // hier beginnt der von mdt erzeugte code. dieser ist eine shell auf
1018 // der writer-seite nach moeglichkeit bald fuer alle filter. die ganze
1019 // schwierigkeit, texte & formatattribute einzufuegen, die positionen
1020 // zu verwalten, styles & kopf/fuszzeilen etc.
1021 //
1022
1023 //////////////////////////////////////////////////////////// SwFltShell
SwFltShell(SwDoc * pDoc,SwPaM & rPaM,const String & rBaseURL,sal_Bool bNew,sal_uLong nFieldFl)1024 SwFltShell::SwFltShell(SwDoc* pDoc, SwPaM& rPaM, const String& rBaseURL, sal_Bool bNew, sal_uLong nFieldFl) :
1025 pCurrentPageDesc(0),
1026 pSavedPos(0),
1027 eSubMode(None),
1028 nAktStyle(0),
1029 aStack(pDoc, nFieldFl),
1030 aEndStack(pDoc, nFieldFl),
1031 pPaM(new SwPaM(*(rPaM.GetPoint()))),
1032 sBaseURL(rBaseURL),
1033 nPageDescOffset(GetDoc().GetPageDescCnt()),
1034 eSrcCharSet(RTL_TEXTENCODING_MS_1252),
1035 bNewDoc(bNew),
1036 bStdPD(sal_False),
1037 bProtect(sal_False)
1038 {
1039 memset( pColls, 0, sizeof( pColls ) );
1040 pOutDoc = new SwFltOutDoc( *pDoc, pPaM, aStack, aEndStack );
1041 pOut = pOutDoc;
1042
1043 if( !bNewDoc ){ // in ein Dokument einfuegen ?
1044 // Da immer ganze Zeile eingelesen werden, muessen
1045 // evtl. Zeilen eingefuegt / aufgebrochen werden
1046 const SwPosition* pPos = pPaM->GetPoint();
1047 const SwTxtNode* pSttNd = pPos->nNode.GetNode().GetTxtNode();
1048 sal_uInt16 nCntPos = pPos->nContent.GetIndex();
1049 if( nCntPos && pSttNd->GetTxt().Len() )
1050 // EinfuegePos nicht in leerer Zeile
1051 pDoc->SplitNode( *pPos, false ); // neue Zeile erzeugen
1052 if( pSttNd->GetTxt().Len() ){ // EinfuegePos nicht am Ende der Zeile
1053 pDoc->SplitNode( *pPos, false ); // neue Zeile
1054 pPaM->Move( fnMoveBackward ); // gehe in leere Zeile
1055 }
1056
1057 // verhinder das Einlesen von Tabellen in Fussnoten / Tabellen
1058 sal_uLong nNd = pPos->nNode.GetIndex();
1059 sal_Bool bReadNoTbl = 0 != pSttNd->FindTableNode() ||
1060 ( nNd < pDoc->GetNodes().GetEndOfInserts().GetIndex() &&
1061 pDoc->GetNodes().GetEndOfInserts().StartOfSectionIndex() < nNd );
1062 if( bReadNoTbl )
1063 pOutDoc->SetReadNoTable();
1064 }
1065 pCurrentPageDesc = &((SwPageDesc&)const_cast<const SwDoc *>(pDoc)
1066 ->GetPageDesc( 0 )); // Standard
1067
1068 }
1069
~SwFltShell()1070 SwFltShell::~SwFltShell()
1071 {
1072 sal_uInt16 i;
1073
1074 if (eSubMode == Style)
1075 EndStyle();
1076 if( pOutDoc->IsInTable() ) // falls nicht ordentlich abgeschlossen
1077 EndTable();
1078 if( pOutDoc->IsInFly() )
1079 EndFly();
1080
1081 GetDoc().SetUpdateExpFldStat(true);
1082 GetDoc().SetInitDBFields(sal_True);
1083 aStack.SetAttr(*pPaM->GetPoint(), 0, sal_False);
1084 aStack.SetAttr(*pPaM->GetPoint(), 0, sal_False);
1085 aEndStack.SetAttr(*pPaM->GetPoint(), 0, sal_False);
1086 aEndStack.SetAttr(*pPaM->GetPoint(), 0, sal_False);
1087 if( bProtect ){ // Das ganze Doc soll geschuetzt sein
1088
1089 SwDoc& rDoc = GetDoc();
1090 // 1. SectionFmt und Section anlegen
1091 SwSectionFmt* pSFmt = rDoc.MakeSectionFmt( 0 );
1092 SwSectionData aSectionData( CONTENT_SECTION, String::CreateFromAscii(
1093 RTL_CONSTASCII_STRINGPARAM("PMW-Protect") ));
1094 aSectionData.SetProtectFlag( true );
1095 // 2. Start- und EndIdx suchen
1096 const SwNode* pEndNd = &rDoc.GetNodes().GetEndOfContent();
1097 SwNodeIndex aEndIdx( *pEndNd, -1L );
1098 const SwStartNode* pSttNd = pEndNd->StartOfSectionNode();
1099 SwNodeIndex aSttIdx( *pSttNd, 1L ); // +1 -> hinter StartNode
1100 // Section einfuegen
1101 // Section einfuegen
1102 rDoc.GetNodes().InsertTextSection(
1103 aSttIdx, *pSFmt, aSectionData, 0, &aEndIdx, false );
1104
1105 if( !IsFlagSet(SwFltControlStack::DONT_HARD_PROTECT) ){
1106 SwDocShell* pDocSh = rDoc.GetDocShell();
1107 if( pDocSh )
1108 pDocSh->SetReadOnlyUI( sal_True );
1109 }
1110 }
1111 // Pagedescriptoren am Dokument updaten (nur so werden auch die
1112 // linken Seiten usw. eingestellt).
1113
1114 GetDoc().ChgPageDesc( 0,
1115 const_cast<const SwDoc &>(GetDoc()).
1116 GetPageDesc( 0 )); // PageDesc "Standard"
1117 for (i=nPageDescOffset;i<GetDoc().GetPageDescCnt();i++)
1118 {
1119 const SwPageDesc& rPD = const_cast<const SwDoc &>(GetDoc()).
1120 GetPageDesc(i);
1121 GetDoc().ChgPageDesc(i, rPD);
1122 }
1123
1124 delete pPaM;
1125 for (i=0; i<sizeof(pColls)/sizeof(*pColls); i++)
1126 if( pColls[i] )
1127 delete pColls[i];
1128 delete pOutDoc;
1129 }
1130
operator <<(const String & rStr)1131 SwFltShell& SwFltShell::operator << ( const String& rStr )
1132 {
1133 ASSERT(eSubMode != Style, "char insert while in style-mode");
1134 GetDoc().InsertString( *pPaM, rStr );
1135 return *this;
1136 }
1137
ConvertUStr(String & rInOut)1138 void SwFltShell::ConvertUStr( String& rInOut )
1139 {
1140 GetAppCharClass().toUpper( rInOut );
1141 }
1142
1143 // QuoteString() wandelt CRs abhaengig von nFieldIniFlags in '\n' oder "\0x0d"
QuoteStr(const String & rIn)1144 String SwFltShell::QuoteStr( const String& rIn )
1145 {
1146 String sOut( rIn );
1147 sal_Bool bAllowCr = aStack.IsFlagSet( SwFltControlStack::ALLOW_FLD_CR );
1148
1149 for( xub_StrLen n = 0; n < sOut.Len(); ++n )
1150 {
1151 switch( sOut.GetChar( n ) )
1152 {
1153 case 0x0a:
1154 sOut.Erase( n, 1 ); // 0xd 0xa wird zu \n
1155 break;
1156
1157 case 0x0b:
1158 case 0x0c:
1159 case 0x0d:
1160 if( bAllowCr )
1161 sOut.SetChar( n, '\n' );
1162 break;
1163 }
1164 }
1165 return sOut;
1166 }
1167
operator <<(const sal_Unicode c)1168 SwFltShell& SwFltShell::operator << ( const sal_Unicode c )
1169 {
1170 ASSERT( eSubMode != Style, "char insert while in style-mode");
1171 GetDoc().InsertString( *pPaM, c );
1172 return *this;
1173 }
1174
AddError(const sal_Char * pErr)1175 SwFltShell& SwFltShell::AddError( const sal_Char* pErr )
1176 {
1177 String aName( String::CreateFromAscii(
1178 RTL_CONSTASCII_STRINGPARAM( "ErrorTag" )));
1179 SwFieldType* pFT = GetDoc().GetFldType( RES_SETEXPFLD, aName, false );
1180 if( pFT == 0)
1181 {
1182 SwSetExpFieldType aS(&GetDoc(), aName, nsSwGetSetExpType::GSE_STRING);
1183 pFT = GetDoc().InsertFldType(aS);
1184 }
1185 SwSetExpField aFld( (SwSetExpFieldType*)pFT,
1186 String::CreateFromAscii( pErr ));
1187 //, VVF_INVISIBLE
1188 GetDoc().InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
1189 return *this;
1190 }
1191
operator <<(Graphic & rGraphic)1192 SwFltShell& SwFltShell::operator << (Graphic& rGraphic)
1193 {
1194 // embedded Grafik !!
1195 GetDoc().Insert(*pPaM, aEmptyStr, aEmptyStr, &rGraphic, NULL, NULL, NULL);
1196 return *this;
1197 }
1198
NextParagraph()1199 void SwFltShell::NextParagraph()
1200 {
1201 GetDoc().AppendTxtNode(*pPaM->GetPoint());
1202 }
1203
NextPage()1204 void SwFltShell::NextPage()
1205 {
1206 NextParagraph();
1207 GetDoc().InsertPoolItem(*pPaM,
1208 SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK), 0);
1209 }
1210
AddGraphic(const String & rPicName)1211 SwFltShell& SwFltShell::AddGraphic( const String& rPicName )
1212 {
1213 // embedded:
1214 GraphicFilter* pFilter = GraphicFilter::GetGraphicFilter();
1215 Graphic aGraphic;
1216 // one of: GFF_NOT GFF_BMP GFF_GIF GFF_JPG GFF_PCD GFF_PCX GFF_PNG
1217 // GFF_TIF GFF_XBM GFF_DXF GFF_MET GFF_PCT GFF_SGF GFF_SVM GFF_WMF
1218 // GFF_SGV GFF_XXX
1219 INetURLObject aDir(
1220 URIHelper::SmartRel2Abs(
1221 INetURLObject(GetBaseURL()), rPicName,
1222 URIHelper::GetMaybeFileHdl()) );
1223 switch (pFilter->ImportGraphic(aGraphic, aDir))
1224 {
1225 case GRFILTER_OK:
1226 *this << aGraphic;
1227 break;
1228 case GRFILTER_OPENERROR:
1229 case GRFILTER_IOERROR:
1230 case GRFILTER_FORMATERROR:
1231 case GRFILTER_VERSIONERROR:
1232 case GRFILTER_FILTERERROR:
1233 case GRFILTER_ABORT:
1234 case GRFILTER_TOOBIG:
1235 default:
1236 AddError( "picture import error" );
1237 break;
1238 }
1239 return *this;
1240 }
1241
SetStyle(sal_uInt16 nStyle)1242 SwFltShell& SwFltShell::SetStyle( sal_uInt16 nStyle )
1243 {
1244 SwFltFormatCollection* p = pColls[ nStyle ];
1245
1246 if (p)
1247 {
1248 if( !pOutDoc->IsInTable() && nStyle != nAktStyle )
1249 {
1250 if( pColls[nAktStyle]->IsInFly() && pOutDoc->IsInFly() )
1251 pOutDoc->EndFly();
1252 if( p->IsInFly() )
1253 p->BeginStyleFly( pOutDoc );
1254 }
1255 GetDoc().SetTxtFmtColl(*pPaM, p->GetColl());
1256 nAktStyle = nStyle;
1257 }
1258 else
1259 {
1260 ASSERT( sal_False, "Ungueltiger SwFltStyleCode" );
1261 }
1262 return *this;
1263 }
1264
operator <<(SwFltBookmark & aBook)1265 SwFltShell& SwFltShell::operator << (SwFltBookmark& aBook)
1266 {
1267 ConvertUStr( aBook.maName );
1268 aBook.maVal = QuoteStr(aBook.maVal);
1269 aEndStack.NewAttr(*pPaM->GetPoint(), aBook);
1270 return *this;
1271 }
1272
SetBookEnd(long nHandle)1273 void SwFltShell::SetBookEnd(long nHandle)
1274 {
1275 aEndStack.SetAttr( *pPaM->GetPoint(), RES_FLTR_BOOKMARK, sal_True, nHandle );
1276 }
1277
EndItem(sal_uInt16 nAttrId)1278 SwFltShell& SwFltShell::EndItem( sal_uInt16 nAttrId )
1279 {
1280 switch( nAttrId )
1281 {
1282 case RES_FLTR_BOOKMARK:
1283 ASSERT( sal_False, "Falscher Aufruf fuer Bookmark-Ende" );
1284 break;
1285
1286 case RES_FLTR_TOX:
1287 aEndStack.SetAttr(*pPaM->GetPoint(), nAttrId);
1288 break;
1289
1290 default:
1291 aStack.SetAttr(*pPaM->GetPoint(), nAttrId);
1292 break;
1293 }
1294 return *this;
1295 }
1296
operator <<(const SwField & rField)1297 SwFltShell& SwFltShell::operator << (const SwField& rField)
1298 {
1299 GetDoc().InsertPoolItem(*pPaM, SwFmtFld(rField), 0);
1300 return *this;
1301 }
1302
operator <<(const SfxPoolItem & rItem)1303 /*virtual*/ SwFltOutBase& SwFltOutDoc::operator << (const SfxPoolItem& rItem)
1304 {
1305 rStack.NewAttr(*pPaM->GetPoint(), rItem);
1306 return *this;
1307 }
1308
operator <<(const SfxPoolItem & rItem)1309 /*virtual*/ SwFltOutBase& SwFltFormatCollection::operator <<
1310 (const SfxPoolItem& rItem)
1311 {
1312 pColl->SetFmtAttr(rItem);
1313 return *this;
1314 }
1315
GetAttr(sal_uInt16 nWhich)1316 const SfxPoolItem& SwFltOutDoc::GetAttr(sal_uInt16 nWhich)
1317 {
1318 return *rStack.GetFmtAttr(*pPaM->GetPoint(), nWhich);
1319 }
1320
GetAttr(sal_uInt16 nWhich)1321 const SfxPoolItem& SwFltFormatCollection::GetAttr(sal_uInt16 nWhich)
1322 {
1323 return GetColl()->GetFmtAttr(nWhich); // mit Parents
1324 }
1325
1326 // GetNodeOrStyAttr holt Attribute fuer Toggle- und Modify-Attribute:
1327 // Bei Formatdefinitionen aus dem altuellen Style mit Parents
1328 // sonst aus dem Node mit Parents
1329 // Im Stack wird nicht nachgesehen
1330
GetNodeOrStyAttr(sal_uInt16 nWhich)1331 const SfxPoolItem& SwFltOutDoc::GetNodeOrStyAttr(sal_uInt16 nWhich)
1332 {
1333 SwCntntNode * pNd = pPaM->GetPoint()->nNode.GetNode().GetCntntNode();
1334 if (pNd) // ContentNode: Attribut mit Parent
1335 return pNd->GetAttr(nWhich);
1336 else // kein ContentNode, dann das dflt. Attribut
1337 return GetDoc().GetAttrPool().GetDefaultItem(nWhich);
1338 }
1339
GetNodeOrStyAttr(sal_uInt16 nWhich)1340 const SfxPoolItem& SwFltFormatCollection::GetNodeOrStyAttr(sal_uInt16 nWhich)
1341 {
1342 return GetColl()->GetFmtAttr(nWhich); // mit Parents
1343 }
1344
GetNodeOrStyAttr(sal_uInt16 nWhich)1345 const SfxPoolItem& SwFltShell::GetNodeOrStyAttr(sal_uInt16 nWhich)
1346 {
1347 return pOut->GetNodeOrStyAttr( nWhich );
1348 }
1349
GetAttr(sal_uInt16 nWhich)1350 const SfxPoolItem& SwFltShell::GetAttr(sal_uInt16 nWhich)
1351 {
1352 return pOut->GetAttr( nWhich );
1353 }
1354
GetFlyFrmAttr(sal_uInt16 nWhich)1355 const SfxPoolItem& SwFltShell::GetFlyFrmAttr(sal_uInt16 nWhich)
1356 {
1357 return pOut->GetFlyFrmAttr( nWhich );
1358 }
1359
GetSysFldType(sal_uInt16 eWhich)1360 SwFieldType* SwFltShell::GetSysFldType(sal_uInt16 eWhich)
1361 {
1362 return GetDoc().GetSysFldType(eWhich);
1363 }
1364
GetWeightBold()1365 sal_Bool SwFltShell::GetWeightBold()
1366 {
1367 return ((SvxWeightItem&)GetNodeOrStyAttr(RES_CHRATR_WEIGHT)).GetWeight()
1368 != WEIGHT_NORMAL;
1369 }
1370
GetPostureItalic()1371 sal_Bool SwFltShell::GetPostureItalic()
1372 {
1373 return ((SvxPostureItem&)GetNodeOrStyAttr(RES_CHRATR_POSTURE)).GetPosture()
1374 != ITALIC_NONE;
1375 }
1376
GetCrossedOut()1377 sal_Bool SwFltShell::GetCrossedOut()
1378 {
1379 return ((SvxCrossedOutItem&)GetNodeOrStyAttr(RES_CHRATR_CROSSEDOUT))
1380 .GetStrikeout() != STRIKEOUT_NONE;
1381 }
1382
GetContour()1383 sal_Bool SwFltShell::GetContour()
1384 {
1385 return ((SvxContourItem&)GetNodeOrStyAttr(RES_CHRATR_CONTOUR)).GetValue();
1386 }
1387
GetCaseKapitaelchen()1388 sal_Bool SwFltShell::GetCaseKapitaelchen()
1389 {
1390 return ((SvxCaseMapItem&)GetNodeOrStyAttr(RES_CHRATR_CASEMAP))
1391 .GetCaseMap() == SVX_CASEMAP_KAPITAELCHEN;
1392 }
1393
GetCaseVersalien()1394 sal_Bool SwFltShell::GetCaseVersalien()
1395 {
1396 return ((SvxCaseMapItem&)GetNodeOrStyAttr(RES_CHRATR_CASEMAP))
1397 .GetCaseMap() == SVX_CASEMAP_VERSALIEN;
1398 }
1399
1400 //-------------------------------------------------------------------------
1401 // Tabellen
1402 //-------------------------------------------------------------------------
1403
~SwFltOutBase()1404 SwFltOutBase::~SwFltOutBase()
1405 {
1406 }
1407
SwFltOutBase(SwDoc & rDocu)1408 SwFltOutBase::SwFltOutBase(SwDoc& rDocu)
1409 : rDoc(rDocu), eFlyAnchor(FLY_AT_PARA), bFlyAbsPos(false)
1410 {
1411 }
1412
GetCellAttr(sal_uInt16 nWhich)1413 const SfxPoolItem& SwFltOutBase::GetCellAttr(sal_uInt16 nWhich)
1414 {
1415 ASSERT(sal_False, "GetCellAttr ausserhalb von normalem Text");
1416 return GetDoc().GetAttrPool().GetDefaultItem(nWhich);
1417 }
1418
BeginTable()1419 sal_Bool SwFltOutBase::BeginTable()
1420 {
1421 ASSERT(sal_False, "BeginTable ausserhalb von normalem Text");
1422 return sal_False;
1423 }
1424
NextTableCell()1425 void SwFltOutBase::NextTableCell()
1426 {
1427 ASSERT(sal_False, "NextTableCell ausserhalb von normalem Text");
1428 }
1429
NextTableRow()1430 void SwFltOutBase::NextTableRow()
1431 {
1432 ASSERT(sal_False, "NextTableRow ausserhalb von normalem Text");
1433 }
1434
SetTableWidth(SwTwips)1435 void SwFltOutBase::SetTableWidth(SwTwips /*nW*/)
1436 {
1437 ASSERT(sal_False, "SetTableWidth ausserhalb von normalem Text");
1438 }
1439
SetTableOrient(sal_Int16)1440 void SwFltOutBase::SetTableOrient(sal_Int16 /*eOri*/)
1441 {
1442 ASSERT(sal_False, "SetTableOrient ausserhalb von normalem Text");
1443 }
1444
SetCellWidth(SwTwips,sal_uInt16)1445 void SwFltOutBase::SetCellWidth(SwTwips /*nWidth*/, sal_uInt16 /*nCell*/)
1446 {
1447 ASSERT(sal_False, "SetCellWidth ausserhalb von normalem Text");
1448 }
1449
SetCellHeight(SwTwips)1450 void SwFltOutBase::SetCellHeight(SwTwips /*nH*/)
1451 {
1452 ASSERT(sal_False, "SetCellHeight ausserhalb von normalem Text");
1453 }
1454
SetCellBorder(const SvxBoxItem &,sal_uInt16)1455 void SwFltOutBase::SetCellBorder(const SvxBoxItem& /*rFmtBox*/, sal_uInt16 /*nCell*/)
1456 {
1457 ASSERT(sal_False, "SetCellBorder ausserhalb von normalem Text");
1458 }
1459
SetCellSpace(sal_uInt16)1460 void SwFltOutBase::SetCellSpace(sal_uInt16 /*nSp*/)
1461 {
1462 ASSERT(sal_False, "SetCellSpace ausserhalb von normalem Text");
1463 }
1464
DeleteCell(sal_uInt16)1465 void SwFltOutBase::DeleteCell(sal_uInt16 /*nCell*/)
1466 {
1467 ASSERT(sal_False, "DeleteCell ausserhalb von normalem Text");
1468 }
1469
EndTable()1470 void SwFltOutBase::EndTable()
1471 {
1472 ASSERT(sal_False, "EndTable ausserhalb von normalem Text");
1473 }
1474
IsInTable()1475 /*virtual*/ sal_Bool SwFltOutDoc::IsInTable()
1476 {
1477 return pTable != 0;
1478 };
1479
BeginTable()1480 sal_Bool SwFltOutDoc::BeginTable()
1481 {
1482 if(bReadNoTbl)
1483 return sal_False;
1484
1485 if (pTable){
1486 ASSERT(sal_False, "BeginTable in Table");
1487 return sal_False;
1488 }
1489 // Alle Attribute schliessen, da sonst Attribute
1490 // entstehen koennen, die in Flys reinragen
1491 rStack.SetAttr( *pPaM->GetPoint(), 0, sal_False );
1492 rEndStack.SetAttr( *pPaM->GetPoint(), 0, sal_False );
1493
1494 // create table:
1495 ASSERT(pTabSavedPos == NULL, "SwFltOutDoc");
1496 pTabSavedPos = new SwPosition(*pPaM->GetPoint());
1497 pTable = GetDoc().InsertTable(
1498 SwInsertTableOptions( tabopts::HEADLINE_NO_BORDER, 1 ),
1499 *pTabSavedPos, 1, 1, text::HoriOrientation::LEFT, 0, 0, sal_False, sal_False ); // TODO MULTIHEADER
1500 nTableWidth = 0;
1501 ((SwTable*)pTable)->LockModify(); // Nichts automatisch anpassen!
1502 // set pam in 1. table cell
1503 usTableX =
1504 usTableY = 0;
1505 SeekCell(usTableY, usTableX, sal_True);
1506 return sal_True;
1507 }
1508
GetBox(sal_uInt16 ny,sal_uInt16 nx)1509 SwTableBox* SwFltOutDoc::GetBox(sal_uInt16 ny, sal_uInt16 nx /*= USHRT_MAX */)
1510 {
1511 if(!pTable){
1512 ASSERT(pTable, "GetBox ohne Tabelle");
1513 return 0;
1514 }
1515 if( nx == USHRT_MAX ) // aktuelle Zelle
1516 nx = usTableX;
1517
1518 // get structs to table cells
1519 const SwTableLines* pTableLines = &pTable->GetTabLines();
1520 if(!pTableLines){
1521 ASSERT(sal_False, "SwFltOutDoc:GetBox:pTableLines");
1522 return 0;
1523 }
1524 if( ny >= pTableLines->Count() ){ // Notbremse
1525 ASSERT( sal_False, "SwFltOutDoc:GetBox:ny >= Count()");
1526 ny = pTableLines->Count() - 1;
1527 }
1528 SwTableLine* pTableLine = (*pTableLines)[ny];
1529 if(!pTableLine){
1530 ASSERT(sal_False, "SwFltOutDoc:GetBox:pTableLine");
1531 return 0;
1532 }
1533 SwTableBoxes* pTableBoxes = &pTableLine->GetTabBoxes();
1534 if(!pTableBoxes){
1535 ASSERT(sal_False, "SwFltOutDoc:GetBox:pTableBoxes");
1536 return 0;
1537 }
1538 if( nx >= pTableBoxes->Count() ){ // Notbremse
1539 ASSERT(sal_False, "SwFltOutDoc:GetBox:nx >= Count()");
1540 nx = pTableBoxes->Count() - 1;
1541 }
1542 SwTableBox* pTableBox = (*pTableBoxes)[nx];
1543
1544 ASSERT(pTableBox != 0, "SwFltOutDoc:GetBox:pTableBox");
1545 return pTableBox;
1546 }
1547
NextTableCell()1548 void SwFltOutDoc::NextTableCell()
1549 {
1550 if(!pTable){
1551 ASSERT(pTable, "NextTableCell ohne Tabelle");
1552 return;
1553 }
1554 const SwTableLines* pTableLines = &pTable->GetTabLines();
1555 SwTableLine* pTableLine = (*pTableLines)[usTableY];
1556 SwTableBoxes* pTableBoxes = &pTableLine->GetTabBoxes();
1557 SwTableBox* pTableBox = (*pTableBoxes)[usTableX];
1558 ASSERT(pTableBox != 0, "SwFltOutDoc:NextTableCell:pTableBox");
1559 if(!pTableBox)
1560 return;
1561 //#pragma message(__FILE__ "(?) : Sw's const problem")
1562 // insert cells:
1563 if (++usTableX >= pTableBoxes->Count())
1564 GetDoc().GetNodes().InsBoxen(
1565 GetDoc().IsIdxInTbl(pPaM->GetPoint()->nNode),
1566 pTableLine,
1567 (SwTableBoxFmt*)pTableBox->GetFrmFmt(),
1568 GetDoc().GetTxtCollFromPool(RES_POOLCOLL_STANDARD, false ),
1569 0,
1570 pTableBoxes->Count());
1571 SeekCell(usTableY, usTableX, sal_True);
1572 pTableBox = (*pTableBoxes)[usTableX];
1573 ASSERT(pTableBox != 0, "SwFltOutDoc:pTableBox");
1574 if(pTableBox)
1575 (*pTableBoxes)[usTableX]->ClaimFrmFmt();
1576 }
1577
NextTableRow()1578 void SwFltOutDoc::NextTableRow()
1579 {
1580 SwTableBox* pTableBox = GetBox(usTableY, 0);
1581 if (pTableBox)
1582 {
1583 // duplicate row:
1584 SwSelBoxes aSelBoxes;
1585 aSelBoxes.Insert( pTableBox );
1586 GetDoc().InsertRow(aSelBoxes);
1587 usTableX = 0;
1588 SeekCell(++usTableY, usTableX, sal_True);
1589 GetDoc().SetTxtFmtColl(*pPaM,
1590 GetDoc().GetTxtCollFromPool(RES_POOLCOLL_STANDARD, false ));
1591 }
1592 }
1593
SetTableWidth(SwTwips nSwWidth)1594 void SwFltOutDoc::SetTableWidth(SwTwips nSwWidth)
1595 {
1596 if(!pTable){
1597 ASSERT(pTable, "SetTableWidth ohne Tabelle");
1598 return;
1599 }
1600 ASSERT( nSwWidth > MINLAY, "Tabellenbreite <= MINLAY" );
1601 if( nSwWidth != nTableWidth ){
1602 if( nTableWidth ) // Nicht beim ersten Setzen
1603 SplitTable();
1604 pTable->GetFrmFmt()->SetFmtAttr( SwFmtFrmSize(ATT_VAR_SIZE, nSwWidth));
1605 nTableWidth = nSwWidth;
1606 }
1607 }
1608
SetTableOrient(sal_Int16 eOri)1609 void SwFltOutDoc::SetTableOrient(sal_Int16 eOri)
1610 {
1611 if(!pTable){
1612 ASSERT(pTable, "SetTableOrient ohne Tabelle");
1613 return;
1614 }
1615 pTable->GetFrmFmt()->SetFmtAttr( SwFmtHoriOrient( 0, eOri ));
1616 }
1617
SetCellWidth(SwTwips nWidth,sal_uInt16 nCell)1618 void SwFltOutDoc::SetCellWidth(SwTwips nWidth, sal_uInt16 nCell /* = USHRT_MAX */ )
1619 {
1620 if(!pTable){
1621 ASSERT(pTable, "SetCellWidth ohne Tabelle");
1622 return;
1623 }
1624 ASSERT( nWidth > MINLAY, "Tabellenzellenbreite <= MINLAY" );
1625 if (nWidth < MINLAY)
1626 nWidth = MINLAY;
1627
1628 SwTableBox* pTableBox = GetBox(usTableY, nCell);
1629 if(pTableBox && pTableBox->GetFrmFmt() ){
1630 SwFmtFrmSize aFmtFrmSize(ATT_FIX_SIZE);
1631 aFmtFrmSize.SetWidth(nWidth);
1632 pTableBox->GetFrmFmt()->SetFmtAttr(aFmtFrmSize);
1633 }
1634 }
1635
SetCellHeight(SwTwips nHeight)1636 void SwFltOutDoc::SetCellHeight(SwTwips nHeight)
1637 {
1638 if(!pTable){
1639 ASSERT(pTable, "SetCellHeight ohne Tabelle");
1640 return;
1641 }
1642
1643 const SwTableLines* pTableLines = &pTable->GetTabLines();
1644 SwTableLine* pTableLine = (*pTableLines)[usTableY];
1645 SwFmtFrmSize aFmtFrmSize(ATT_MIN_SIZE, 0, 0);
1646 if (nHeight < MINLAY)
1647 nHeight = MINLAY;
1648 aFmtFrmSize.SetHeight(nHeight);
1649 pTableLine->GetFrmFmt()->SetFmtAttr(aFmtFrmSize);
1650 }
1651
GetCellAttr(sal_uInt16 nWhich)1652 const SfxPoolItem& SwFltOutDoc::GetCellAttr(sal_uInt16 nWhich)
1653 {
1654 if (!pTable){
1655 ASSERT(pTable, "GetCellAttr ohne Table");
1656 return GetDoc().GetAttrPool().GetDefaultItem(nWhich);
1657 }
1658
1659 SwTableBox* pTableBox = GetBox(usTableY, usTableX);
1660 if(!pTableBox)
1661 return GetDoc().GetAttrPool().GetDefaultItem(nWhich);
1662 return pTableBox->GetFrmFmt()->GetFmtAttr( nWhich );
1663 }
1664
SetCellBorder(const SvxBoxItem & rFmtBox,sal_uInt16 nCell)1665 void SwFltOutDoc::SetCellBorder(const SvxBoxItem& rFmtBox,
1666 sal_uInt16 nCell /* = USHRT_MAX */ )
1667 {
1668 SwTableBox* pTableBox = GetBox(usTableY, nCell);
1669 if(pTableBox)
1670 pTableBox->GetFrmFmt()->SetFmtAttr(rFmtBox);
1671 }
1672
1673 // nicht aktiviert !!!
SetCellSpace(sal_uInt16 nDist)1674 void SwFltOutDoc::SetCellSpace(sal_uInt16 nDist)
1675 {
1676 if(!pTable){
1677 ASSERT(pTable, "SetCellSpace ohne Tabelle");
1678 return;
1679 }
1680 SwTableBox* pTableBox = GetBox(usTableY, usTableX);
1681 if(!pTableBox)
1682 return;
1683
1684 SvxBoxItem aFmtBox( *((SvxBoxItem*)
1685 &pTableBox->GetFrmFmt()->GetFmtAttr( RES_BOX )));
1686
1687 // versteh ich nich, sven: if (!nDist) nDist = 18; // ca. 0.03 cm
1688 if (nDist > 42) // max. 0.7 mm
1689 nDist = 42;
1690 else
1691 if (nDist < MIN_BORDER_DIST)
1692 nDist = MIN_BORDER_DIST;
1693 aFmtBox.SetDistance(nDist);
1694 pTableBox->GetFrmFmt()->SetFmtAttr(aFmtBox);
1695 }
1696
DeleteCell(sal_uInt16 nCell)1697 void SwFltOutDoc::DeleteCell(sal_uInt16 nCell /* = USHRT_MAX */)
1698 {
1699 SwTableBox* pTableBox = GetBox(usTableY, nCell);
1700 if(pTableBox){
1701 SwSelBoxes aSelBoxes;
1702 aSelBoxes.Insert( pTableBox );
1703 GetDoc().DeleteRowCol(aSelBoxes);
1704 usTableX--;
1705 }
1706 }
1707
SplitTable()1708 void SwFltOutDoc::SplitTable()
1709 {
1710 if(!pTable)
1711 {
1712 ASSERT(pTable, "SplitTable ohne Tabelle");
1713 return;
1714 }
1715 SwTableBox* pAktBox = GetBox(usTableY, usTableX);
1716 SwTableBox* pSplitBox = GetBox(usTableY - 1, 0);
1717 GetDoc().GetNodes().SplitTable(SwNodeIndex(*pSplitBox->GetSttNd()), false);
1718 pTable = &pAktBox->GetSttNd()->FindTableNode()->GetTable();
1719 usTableY = 0;
1720 }
1721
EndTable()1722 void SwFltOutDoc::EndTable()
1723 {
1724 if (!pTable){
1725 ASSERT(pTable, "EndTable ohne Table");
1726 return;
1727 }
1728 // Alle Attribute schliessen, da sonst Attribute
1729 // entstehen koennen, die in Flys reinragen
1730 rStack.SetAttr( *pPaM->GetPoint(), 0, sal_False );
1731 rEndStack.SetAttr( *pPaM->GetPoint(), 0, sal_False );
1732
1733 if (GetDoc().GetCurrentViewShell()){ //swmod 071108//swmod 071225
1734 SwTableNode* pTableNode = GetDoc().IsIdxInTbl(
1735 pPaM->GetPoint()->nNode);
1736 pTableNode->DelFrms();
1737 pTableNode->MakeFrms(&pPaM->GetPoint()->nNode);
1738 }
1739
1740 *pPaM->GetPoint() = *pTabSavedPos; // restore Cursor
1741 delete pTabSavedPos;
1742 pTabSavedPos = 0;
1743 ((SwTable*)pTable)->UnlockModify(); // Test, nuetzt nichts gegen Assert
1744 pTable = 0;
1745 nTableWidth = 0;
1746 }
1747
SeekCell(short nRow,short nCol,sal_Bool bPam)1748 sal_Bool SwFltOutDoc::SeekCell(short nRow, short nCol, sal_Bool bPam)
1749 {
1750 // get structs to table cells
1751 const SwTableLines* pTableLines = &pTable->GetTabLines();
1752 SwTableLine* pTableLine = (*pTableLines)[usTableY];
1753 SwTableBoxes* pTableBoxes = &pTableLine->GetTabBoxes();
1754 SwTableBox* pTableBox = (*pTableBoxes)[usTableX];
1755
1756 if ((sal_uInt16)nRow >= pTableLines->Count())
1757 {
1758 ASSERT((sal_uInt16)nRow >= pTableLines->Count(), "SwFltOutDoc");
1759 return sal_False;
1760 }
1761 pTableLine = (*pTableLines)[nRow];
1762 pTableBoxes = &pTableLine->GetTabBoxes();
1763 if (nCol >= pTableBoxes->Count())
1764 return sal_False;
1765 pTableBox = (*pTableBoxes)[nCol];
1766 if( !pTableBox->GetSttNd() )
1767 {
1768 ASSERT(pTableBox->GetSttNd(), "SwFltOutDoc");
1769 return sal_False;
1770 }
1771 if(bPam)
1772 {
1773 pPaM->GetPoint()->nNode = pTableBox->GetSttIdx() + 1;
1774 pPaM->GetPoint()->nContent.Assign(pPaM->GetCntntNode(), 0);
1775 //#pragma message(__FILE__ "(?) : Sw's const problem")
1776 #if OSL_DEBUG_LEVEL > 1
1777 const SwTxtFmtColl* p = GetDoc().GetDfltTxtFmtColl();
1778 p = GetDoc().GetTxtCollFromPool(RES_POOLCOLL_STANDARD, false );
1779 #endif
1780 GetDoc().SetTxtFmtColl(*pPaM,
1781 GetDoc().GetTxtCollFromPool(RES_POOLCOLL_STANDARD, false ));
1782 }
1783 return sal_True;
1784 }
1785
1786
1787 //-----------------------------------------------------------------------------
1788 // Flys in SwFltOutBase
1789 //-----------------------------------------------------------------------------
1790
NewFlyDefaults()1791 SfxItemSet* SwFltOutBase::NewFlyDefaults()
1792 {
1793 // Unbedingt noetige Standardwerte setzen ( falls diese Werte nicht
1794 // spaeter explizit gesetzt werden )
1795
1796 SfxItemSet* p = new SfxItemSet( GetDoc().GetAttrPool(),
1797 RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
1798 SwFmtFrmSize aSz( ATT_VAR_SIZE, MINFLY, MINFLY );
1799 // Default: Breite 100% ( = PMW:Auto )
1800 aSz.SetWidthPercent( 100 ); // Hoehe: Auto
1801 p->Put( aSz );
1802 p->Put( SwFmtHoriOrient( 0, text::HoriOrientation::NONE, text::RelOrientation::FRAME ));
1803 return p;
1804 }
1805
BeginFly(RndStdIds eAnchor,sal_Bool bAbsolutePos,const SfxItemSet * pMoreAttrs)1806 sal_Bool SwFltOutBase::BeginFly( RndStdIds eAnchor /*= FLY_AT_PARA*/,
1807 sal_Bool bAbsolutePos /*= sal_False*/,
1808 const SfxItemSet*
1809 #ifdef DBG_UTIL
1810 pMoreAttrs /*= 0*/
1811 #endif
1812 )
1813 {
1814 ASSERT(!pMoreAttrs, "SwFltOutBase:BeginFly mit pMoreAttrs" );
1815 eFlyAnchor = eAnchor;
1816 bFlyAbsPos = bAbsolutePos; // Bloedsinn eigentlich
1817 return sal_True;
1818 }
1819
SetFlyAnchor(RndStdIds eAnchor)1820 /*virtual*/ void SwFltOutBase::SetFlyAnchor( RndStdIds eAnchor )
1821 {
1822 if( !IsInFly() ){
1823 ASSERT( sal_False, "SetFlyAnchor() ohne Fly" );
1824 return;
1825 }
1826 if ( eAnchor == FLY_AS_CHAR ){
1827 ASSERT( sal_False, "SetFlyAnchor( FLY_AS_CHAR ) nicht implementiert" );
1828 return;
1829 }
1830 SwFmtAnchor& rAnchor = (SwFmtAnchor&)GetFlyFrmAttr( RES_ANCHOR );
1831 rAnchor.SetType( eAnchor );
1832 }
1833
EndFly()1834 void SwFltOutBase::EndFly()
1835 {
1836 if( bFlyAbsPos ){
1837 // hier muessen die absoluten Positionen am Fly noch in
1838 // die Writer-Koordinaten umgerechnet werden.
1839 }
1840 }
1841
1842 //-----------------------------------------------------------------------------
1843 // Flys in SwFltDoc
1844 //-----------------------------------------------------------------------------
1845
IsInFly()1846 /* virtual */ sal_Bool SwFltOutDoc::IsInFly()
1847 {
1848 return pFly != 0;
1849 };
1850
MakeFly(RndStdIds eAnchor,SfxItemSet * pSet)1851 SwFrmFmt* SwFltOutDoc::MakeFly( RndStdIds eAnchor, SfxItemSet* pSet )
1852 {
1853 pFly = (SwFlyFrmFmt*)GetDoc().MakeFlySection( eAnchor, pPaM->GetPoint(),
1854 pSet );
1855 return pFly;
1856 }
1857
BeginFly(RndStdIds eAnchor,sal_Bool bAbsolutePos,const SfxItemSet * pMoreAttrs)1858 sal_Bool SwFltOutDoc::BeginFly( RndStdIds eAnchor /*= FLY_AT_PARA*/,
1859 sal_Bool bAbsolutePos /*= sal_False*/,
1860 const SfxItemSet* pMoreAttrs /*= 0*/ )
1861
1862 {
1863 SwFltOutBase::BeginFly( eAnchor, bAbsolutePos, 0 );
1864 SfxItemSet* pSet = NewFlyDefaults();
1865
1866 // Alle Attribute schliessen, da sonst Attribute entstehen koennen,
1867 // die in Flys reinragen
1868 rStack.SetAttr( *pPaM->GetPoint(), 0, sal_False );
1869 rEndStack.SetAttr( *pPaM->GetPoint(), 0, sal_False );
1870
1871 // create Fly:
1872 ASSERT(pFlySavedPos == NULL, "BeginFly in Fly"); // rekursiv geht noch nicht
1873 pFlySavedPos = new SwPosition(*pPaM->GetPoint());
1874
1875
1876 SwFmtAnchor aAnchor( eAnchor, 1 );
1877
1878 // Wenn Fly-Attribute im Style waren, dann jetzt als Defaults reinsetzen
1879 if (pMoreAttrs)
1880 pSet->Put(*pMoreAttrs);
1881
1882 // dieses NICHT bei Seitengebundenem Fly mit Seiten-NUMMER !
1883 aAnchor.SetAnchor(pPaM->GetPoint()); // braucht erstaunlicherweise
1884 // den Stack nicht
1885 // aStack.NewAttr( *pPaM->GetPoint(), SwFltAnchor( pFly ) );
1886
1887 pSet->Put( aAnchor );
1888 SwFrmFmt* pF = MakeFly( eAnchor, pSet );
1889 delete pSet;
1890
1891 // set pam in Fly
1892 const SwFmtCntnt& rCntnt = pF->GetCntnt();
1893 ASSERT( rCntnt.GetCntntIdx(), "Kein Inhalt vorbereitet." );
1894 pPaM->GetPoint()->nNode = rCntnt.GetCntntIdx()->GetIndex() + 1;
1895 SwCntntNode *pNode = pPaM->GetCntntNode();
1896 pPaM->GetPoint()->nContent.Assign( pNode, 0 );
1897
1898 return sal_True;
1899 }
1900
SetFlyFrmAttr(const SfxPoolItem & rAttr)1901 /*virtual*/ void SwFltOutDoc::SetFlyFrmAttr(const SfxPoolItem& rAttr)
1902 {
1903 if (pFly){
1904 pFly->SetFmtAttr( rAttr );
1905 }else{
1906 ASSERT(pFly, "SetFlyAttr ohne Doc-Fly");
1907 return;
1908 }
1909 }
1910
GetFlyFrmAttr(sal_uInt16 nWhich)1911 /*virtual*/ const SfxPoolItem& SwFltOutDoc::GetFlyFrmAttr(sal_uInt16 nWhich)
1912 {
1913 if (pFly){
1914 return pFly->GetFmtAttr( nWhich );
1915 }else{
1916 ASSERT(pFly, "GetFlyAttr ohne Fly");
1917 return GetDoc().GetAttrPool().GetDefaultItem(nWhich);
1918 }
1919 }
1920
EndFly()1921 void SwFltOutDoc::EndFly()
1922 {
1923 if( pTable ){
1924 ASSERT( sal_False, "SwFltOutDoc::EndFly() in Table" );
1925 return;
1926 }
1927 // Alle Attribute schliessen, da sonst Attribute
1928 // entstehen koennen, die aus Flys rausragen
1929 rStack.SetAttr( *pPaM->GetPoint(), 0, sal_False );
1930 rEndStack.SetAttr( *pPaM->GetPoint(), 0, sal_False );
1931
1932 *pPaM->GetPoint() = *pFlySavedPos; // restore Cursor
1933 delete pFlySavedPos;
1934 pFlySavedPos = 0;
1935 SwFltOutBase::EndFly();
1936 pFly = 0;
1937 }
1938
1939 //-----------------------------------------------------------------------------
1940 // Flys in SwFltFormatCollection
1941 //-----------------------------------------------------------------------------
IsInFly()1942 /*virtual*/ sal_Bool SwFltFormatCollection::IsInFly()
1943 {
1944 return bHasFly;
1945 };
1946
SetFlyFrmAttr(const SfxPoolItem & rAttr)1947 /*virtual*/ void SwFltFormatCollection::SetFlyFrmAttr(const SfxPoolItem& rAttr)
1948 {
1949 if (!pFlyAttrs)
1950 pFlyAttrs = new SfxItemSet( GetDoc().GetAttrPool(),
1951 RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
1952 pFlyAttrs->Put( rAttr );
1953 }
1954
GetFlyFrmAttr(sal_uInt16 nWhich)1955 /*virtual*/ const SfxPoolItem& SwFltFormatCollection::GetFlyFrmAttr(sal_uInt16 nWhich)
1956 {
1957 // ASSERT( pFlyAttrs, "GetFlyFrmAttr ohne Coll-FlyAttrs" );
1958 if( pFlyAttrs )
1959 return pFlyAttrs->Get( nWhich, sal_False );
1960 else
1961 return GetDoc().GetAttrPool().GetDefaultItem(nWhich);
1962 }
1963
BeginFly(RndStdIds eAnchor,sal_Bool bAbsolutePos,const SfxItemSet * pMoreAttrs)1964 sal_Bool SwFltFormatCollection::BeginFly( RndStdIds eAnchor /*= FLY_AT_PARA*/,
1965 sal_Bool bAbsolutePos /*= sal_False*/,
1966 const SfxItemSet* pMoreAttrs /*= 0*/ )
1967
1968 {
1969 SwFltOutBase::BeginFly( eAnchor, bAbsolutePos, pMoreAttrs );
1970 bHasFly = sal_True;
1971 return sal_True;
1972 }
1973
EndFly()1974 void SwFltFormatCollection::EndFly() // Wird nie aufgerufen
1975 {
1976 }
1977
BeginStyleFly(SwFltOutDoc * pOutDoc)1978 sal_Bool SwFltFormatCollection::BeginStyleFly( SwFltOutDoc* pOutDoc )
1979 {
1980 ASSERT( pOutDoc, "BeginStyleFly ohne pOutDoc" );
1981 ASSERT( pOutDoc && !pOutDoc->IsInFly(), "BeginStyleFly in Fly" );
1982 if( pOutDoc && !pOutDoc->IsInFly() )
1983 return pOutDoc->BeginFly( eFlyAnchor, bFlyAbsPos, pFlyAttrs );
1984 else
1985 return sal_False;
1986 }
1987
1988 //-----------------------------------------------------------------------------
1989 // Flys in SwFltShell
1990 //-----------------------------------------------------------------------------
1991
BeginFly(RndStdIds eAnchor,sal_Bool bAbsolutePos)1992 sal_Bool SwFltShell::BeginFly( RndStdIds eAnchor /*= FLY_AT_PARA*/,
1993 sal_Bool bAbsolutePos /*= sal_False*/ )
1994
1995 {
1996 if (pOut->IsInFly()){
1997 ASSERT(sal_False, "BeginFly in Fly");
1998 return sal_False;
1999 }
2000 if (pOutDoc->IsInTable()){
2001 ASSERT(sal_False, "BeginFly in Table");
2002 return sal_False;
2003 }
2004 pOut->BeginFly( eAnchor, bAbsolutePos, pColls[nAktStyle]->GetpFlyAttrs() );
2005 eSubMode = Fly;
2006 return sal_True;
2007 }
2008
SetFlyXPos(short nXPos,sal_Int16 eHRel,sal_Int16 eHAlign)2009 void SwFltShell::SetFlyXPos( short nXPos, sal_Int16 eHRel /*= text::RelOrientation::FRAME*/,
2010 sal_Int16 eHAlign /*= text::HoriOrientation::NONE*/ )
2011 {
2012 SetFlyFrmAttr( SwFmtHoriOrient( nXPos, eHAlign, eHRel ) );
2013 }
2014
SetFlyYPos(short nYPos,sal_Int16 eVRel,sal_Int16 eVAlign)2015 void SwFltShell::SetFlyYPos( short nYPos, sal_Int16 eVRel /*= text::RelOrientation::FRAME*/,
2016 sal_Int16 eVAlign /*= text::VertOrientation::NONE*/ )
2017 {
2018 SetFlyFrmAttr( SwFmtVertOrient( nYPos, eVAlign, eVRel ) );
2019 }
2020
2021
EndFly()2022 void SwFltShell::EndFly()
2023 {
2024 if (!pOut->IsInFly()){
2025 ASSERT(sal_False, "EndFly ohne Fly");
2026 return;
2027 }
2028 if (pOutDoc->IsInTable()){ // Table verschraenkt mit Fly macht keinen Sinn
2029 ASSERT(sal_False, "EndFly in Table ( verschraenkt )");
2030 EndTable(); // -> Table beenden
2031 }
2032 pOut->EndFly();
2033 eSubMode = None;
2034 }
2035
2036 //-----------------------------------------------------------------------------
2037 // Fussnoten
2038 //-----------------------------------------------------------------------------
2039
BeginFootnote()2040 void SwFltShell::BeginFootnote()
2041 {
2042 if( pOut->IsInFly() ){ // Passiert z.B. bei Fussnote in Fly
2043 ASSERT(sal_False, "Fussnote in Fly nicht erlaubt");
2044 return;
2045 }
2046 if( pOutDoc->IsInTable() ){
2047 ASSERT(sal_False, "Fussnote in Table z.Zt. nicht erlaubt");
2048 return;
2049 }
2050
2051 // Alle Attribute schliessen, da sonst Attribute entstehen koennen,
2052 // die in Fussnoten reinragen
2053 aStack.SetAttr( *pPaM->GetPoint(), 0, sal_False );
2054 // aEndStack.SetAttr( *pPaM->GetPoint(), 0, sal_False );
2055 // EndStack erstmal nicht zwangs-Schliessen, damit Bookmarks ueber
2056 // Fussnoten im PMW uebernommen werden
2057
2058 SwFmtFtn aFtn;
2059 GetDoc().InsertPoolItem(*pPaM, aFtn, 0);
2060 ASSERT(pSavedPos == NULL, "SwFltShell");
2061 pSavedPos = new SwPosition(*pPaM->GetPoint());
2062 pPaM->Move(fnMoveBackward, fnGoCntnt);
2063 SwTxtNode* pTxt = pPaM->GetNode()->GetTxtNode();
2064 SwTxtAttr *const pFN = pTxt->GetTxtAttrForCharAt(
2065 pPaM->GetPoint()->nContent.GetIndex(), RES_TXTATR_FTN);
2066 if( !pFN ){ // Passiert z.B. bei Fussnote in Fly
2067 ASSERT(pFN, "Probleme beim Anlegen des Fussnoten-Textes");
2068 return;
2069 }
2070 const SwNodeIndex* pStartIndex = ((SwTxtFtn*)pFN)->GetStartNode();
2071 ASSERT(pStartIndex, "Probleme beim Anlegen des Fussnoten-Textes");
2072 pPaM->GetPoint()->nNode = pStartIndex->GetIndex() + 1;
2073 pPaM->GetPoint()->nContent.Assign(pPaM->GetCntntNode(), 0);
2074 eSubMode = Footnote;
2075 }
2076
EndFootnote()2077 void SwFltShell::EndFootnote()
2078 {
2079 if(!pSavedPos)
2080 return;
2081 // Alle Attribute schliessen, da sonst Attribute
2082 // entstehen koennen, die aus Fussnoten rausragen
2083 aStack.SetAttr( *pPaM->GetPoint(), 0, sal_False );
2084 // aEndStack.SetAttr( *pPaM->GetPoint(), 0, sal_False );
2085 // EndStack erstmal nicht zwangs-Schliessen, damit Bookmarks ueber
2086 // Fussnoten im PMW uebernommen werden
2087
2088 *pPaM->GetPoint() = *pSavedPos; // restore Cursor
2089 delete pSavedPos;
2090 pSavedPos = 0;
2091 }
2092
BeginHeader(SwPageDesc *)2093 void SwFltShell::BeginHeader(SwPageDesc* /*pPD*/)
2094 {
2095 SwFrmFmt* pFmt = &pCurrentPageDesc->GetMaster(
2096 ); //(bUseLeft) ? &pCurrentPageDesc->GetLeft() :
2097 SwFrmFmt* pHdFtFmt;
2098 pFmt->SetFmtAttr(SwFmtHeader(sal_True));
2099 pHdFtFmt = (SwFrmFmt*)pFmt->GetHeader().GetHeaderFmt();
2100 const SwNodeIndex* pStartIndex = pHdFtFmt->GetCntnt().GetCntntIdx();
2101 if (!pStartIndex)
2102 return;
2103 ASSERT(pSavedPos == NULL, "SwFltShell");
2104 pSavedPos = new SwPosition(*pPaM->GetPoint());
2105 pPaM->GetPoint()->nNode = pStartIndex->GetIndex() + 1;
2106 pPaM->GetPoint()->nContent.Assign(pPaM->GetCntntNode(), 0);
2107 eSubMode = Header;
2108 }
2109
BeginFooter(SwPageDesc *)2110 void SwFltShell::BeginFooter(SwPageDesc* /*pPD*/)
2111 {
2112 SwFrmFmt* pFmt = &pCurrentPageDesc->GetMaster(
2113 ); //(bUseLeft) ? &pCurrentPageDesc->GetLeft() :
2114 SwFrmFmt* pHdFtFmt;
2115 pFmt->SetFmtAttr(SwFmtFooter(sal_True));
2116 pHdFtFmt = (SwFrmFmt*)pFmt->GetFooter().GetFooterFmt();
2117 const SwNodeIndex* pStartIndex = pHdFtFmt->GetCntnt().GetCntntIdx();
2118 if (!pStartIndex)
2119 return;
2120 ASSERT(pSavedPos == NULL, "SwFltShell");
2121 pSavedPos = new SwPosition(*pPaM->GetPoint());
2122 pPaM->GetPoint()->nNode = pStartIndex->GetIndex() + 1;
2123 pPaM->GetPoint()->nContent.Assign(pPaM->GetCntntNode(), 0);
2124 eSubMode = Footer;
2125 }
2126
EndHeaderFooter()2127 void SwFltShell::EndHeaderFooter()
2128 {
2129 *pPaM->GetPoint() = *pSavedPos; // restore Cursor
2130 delete pSavedPos;
2131 pSavedPos = 0;
2132 }
2133
MakePageDesc(SwPageDesc * pFirstPageDesc)2134 SwPageDesc* SwFltShell::MakePageDesc(SwPageDesc* pFirstPageDesc)
2135 {
2136 if(bStdPD) // keine Neuen PageDescs
2137 return pCurrentPageDesc;
2138
2139 sal_Bool bFollow = (pFirstPageDesc != 0);
2140 SwPageDesc* pNewPD;
2141 sal_uInt16 nPos;
2142 if (bFollow && pFirstPageDesc->GetFollow() != pFirstPageDesc)
2143 return pFirstPageDesc; // Fehler: hat schon Follow
2144 // Erkennung doppelter Namen fehlt noch (Wahrscheinlichkeit
2145 // fuer dopp. Namen ist gering)
2146
2147 nPos = GetDoc().MakePageDesc( ViewShell::GetShellRes()->GetPageDescName(
2148 GetDoc().GetPageDescCnt(), sal_False, bFollow ),
2149 pFirstPageDesc, sal_False );
2150
2151 pNewPD = &((SwPageDesc&)const_cast<const SwDoc &>(GetDoc()).
2152 GetPageDesc(nPos));
2153 if (bFollow)
2154 { // Dieser ist der folgende von pPageDesc
2155 pFirstPageDesc->SetFollow(pNewPD);
2156 pNewPD->SetFollow(pNewPD);
2157 }
2158 else
2159 {
2160 GetDoc().InsertPoolItem( *pPaM, SwFmtPageDesc( pNewPD ), 0 );
2161 }
2162 pNewPD->WriteUseOn( // alle Seiten
2163 (UseOnPage)(nsUseOnPage::PD_ALL | nsUseOnPage::PD_HEADERSHARE | nsUseOnPage::PD_FOOTERSHARE));
2164 return pNewPD;
2165 }
2166
2167 ///////////////////////////////////////////////// SwFltFormatCollection
SwFltFormatCollection(SwDoc & _rDoc,RES_POOL_COLLFMT_TYPE nType)2168 SwFltFormatCollection::SwFltFormatCollection(
2169 SwDoc& _rDoc, RES_POOL_COLLFMT_TYPE nType ) :
2170 SwFltOutBase(_rDoc),
2171 pColl(_rDoc.GetTxtCollFromPool( static_cast< sal_uInt16 >(nType), false )),
2172 pFlyAttrs( 0 ),
2173 bHasFly( sal_False )
2174 {
2175 Reset(); // Default-Attrs loeschen und Auto-Flag
2176 }
2177
SwFltFormatCollection(SwDoc & _rDoc,const String & rName)2178 SwFltFormatCollection::SwFltFormatCollection(
2179 SwDoc& _rDoc, const String& rName ) :
2180 SwFltOutBase(_rDoc),
2181 pFlyAttrs( 0 ),
2182 bHasFly( sal_False )
2183 {
2184 pColl = _rDoc.MakeTxtFmtColl(rName, (SwTxtFmtColl*)_rDoc.GetDfltTxtFmtColl());
2185 Reset(); // Default-Attrs loeschen und Auto-Flag
2186 }
2187
NextStyle(sal_uInt16 nWhich,sal_uInt16 nNext)2188 void SwFltShell::NextStyle(sal_uInt16 nWhich, sal_uInt16 nNext)
2189 {
2190 ASSERT(pColls[nWhich], "Next style for noexistent style" );
2191 ASSERT(pColls[nNext], "Next style to noexistent style" );
2192 if( pColls[nWhich] && pColls[nNext] )
2193 pColls[nWhich]->GetColl()->SetNextTxtFmtColl(
2194 *pColls[nNext]->GetColl() );
2195 }
2196
2197 // UpdatePageDescs muss am Ende des Einlesevorganges aufgerufen werden, damit
2198 // der Writer den Inhalt der Pagedescs wirklich akzeptiert
UpdatePageDescs(SwDoc & rDoc,sal_uInt16 nInPageDescOffset)2199 void UpdatePageDescs(SwDoc &rDoc, sal_uInt16 nInPageDescOffset)
2200 {
2201 // Pagedescriptoren am Dokument updaten (nur so werden auch die
2202 // linken Seiten usw. eingestellt).
2203
2204 // PageDesc "Standard"
2205 rDoc.ChgPageDesc(0, const_cast<const SwDoc &>(rDoc).GetPageDesc(0));
2206
2207 // PageDescs "Konvert..."
2208 for (sal_uInt16 i = nInPageDescOffset; i < rDoc.GetPageDescCnt(); ++i)
2209 rDoc.ChgPageDesc(i, const_cast<const SwDoc &>(rDoc).GetPageDesc(i));
2210 }
2211
2212 /* vi:set tabstop=4 shiftwidth=4 expandtab: */
2213