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