Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef INCLUDED_SW_SOURCE_FILTER_INC_FLTSHELL_HXX
20 : #define INCLUDED_SW_SOURCE_FILTER_INC_FLTSHELL_HXX
21 :
22 : #include <com/sun/star/text/HoriOrientation.hpp>
23 : #include <com/sun/star/text/VertOrientation.hpp>
24 : #include <com/sun/star/text/RelOrientation.hpp>
25 : #include <hintids.hxx>
26 : #include <vcl/keycod.hxx>
27 : #include <tools/datetime.hxx>
28 : #include <editeng/formatbreakitem.hxx>
29 : #include <poolfmt.hxx>
30 : #include <fmtornt.hxx>
31 : #include <ndindex.hxx>
32 : #include <pam.hxx>
33 : #include <IDocumentRedlineAccess.hxx>
34 :
35 : #include <boost/noncopyable.hpp>
36 : #include <boost/ptr_container/ptr_deque.hpp>
37 :
38 : class SwTOXBase;
39 : class SwFltShell;
40 : class SwField;
41 : class SwFieldType;
42 : class Graphic;
43 : class SwTableBox;
44 : class SwDoc;
45 : class SwPaM;
46 :
47 : inline void SwFltClearFlag(sal_uLong& rFieldFlags, int no)
48 : { rFieldFlags &= ~(1L << no); }
49 :
50 0 : inline void SwFltSetFlag(sal_uLong& rFieldFlags, int no)
51 0 : { rFieldFlags |= 1L << no; }
52 :
53 0 : inline bool SwFltGetFlag(sal_uLong nFieldFlags, int no)
54 0 : { return (nFieldFlags & (1L << no)) != 0; }
55 :
56 : //Subvert the Node/Content system to get positions which don't update as
57 : //content is appended to them
58 0 : struct SW_DLLPUBLIC SwFltPosition
59 : {
60 : public:
61 : SwNodeIndex m_nNode;
62 : sal_Int32 m_nCntnt;
63 : public:
64 0 : SwFltPosition(const SwFltPosition &rOther)
65 : : m_nNode(rOther.m_nNode)
66 0 : , m_nCntnt(rOther.m_nCntnt)
67 : {
68 0 : }
69 0 : SwFltPosition &operator=(const SwFltPosition &rOther)
70 : {
71 0 : m_nNode = rOther.m_nNode;
72 0 : m_nCntnt = rOther.m_nCntnt;
73 0 : return *this;
74 : }
75 0 : bool operator==(const SwFltPosition &rOther) const
76 : {
77 0 : return (m_nCntnt == rOther.m_nCntnt &&
78 0 : m_nNode == rOther.m_nNode);
79 : }
80 0 : void SetPos(SwNodeIndex &rNode, sal_uInt16 nIdx)
81 : {
82 0 : m_nNode = rNode;
83 0 : m_nCntnt = nIdx;
84 0 : }
85 : //operators with SwPosition, where the node is hacked to the previous one,
86 : //and the offset to content is de-dynamic-ified
87 0 : SwFltPosition(const SwPosition &rPos)
88 : : m_nNode(rPos.nNode, -1)
89 0 : , m_nCntnt(rPos.nContent.GetIndex())
90 : {
91 0 : }
92 0 : void SetPos(const SwPosition &rPos)
93 : {
94 0 : m_nNode = rPos.nNode.GetIndex()-1;
95 0 : m_nCntnt = rPos.nContent.GetIndex();
96 0 : }
97 : };
98 :
99 : // Stack-Eintrag fuer die Attribute Es werden immer Pointer auf neue Attribute uebergeben.
100 : class SwFltStackEntry : private ::boost::noncopyable
101 : {
102 : public:
103 : SwFltPosition m_aMkPos;
104 : SwFltPosition m_aPtPos;
105 :
106 : SfxPoolItem * pAttr;// Format Attribute
107 :
108 : sal_Bool bOld; // to mark Attributes *before* skipping field results
109 : sal_Bool bOpen; //Entry open, awaiting being closed
110 : sal_Bool bConsumedByField;
111 :
112 : sal_Int32 mnStartCP;
113 : sal_Int32 mnEndCP;
114 : bool bIsParaEnd;
115 :
116 : SW_DLLPUBLIC SwFltStackEntry(const SwPosition & rStartPos, SfxPoolItem* pHt );
117 : SW_DLLPUBLIC ~SwFltStackEntry();
118 :
119 : void SetStartPos(const SwPosition & rStartPos);
120 : SW_DLLPUBLIC void SetEndPos( const SwPosition & rEndPos);
121 : SW_DLLPUBLIC bool MakeRegion(SwDoc* pDoc, SwPaM& rRegion, bool bCheck) const;
122 : SW_DLLPUBLIC static bool MakeRegion(SwDoc* pDoc, SwPaM& rRegion,
123 : bool bCheck, const SwFltPosition &rMkPos, const SwFltPosition &rPtPos, bool bIsParaEnd=false,
124 : sal_uInt16 nWhich=0);
125 :
126 0 : void SetStartCP(sal_Int32 nCP) {mnStartCP = nCP;}
127 0 : void SetEndCP(sal_Int32 nCP) {mnEndCP = nCP;}
128 0 : sal_Int32 GetStartCP() const {return mnStartCP;}
129 0 : sal_Int32 GetEndCP() const {return mnEndCP;}
130 : bool IsAbleMakeRegion();
131 0 : bool IsParaEnd(){ return bIsParaEnd;}
132 0 : void SetIsParaEnd(bool bArg){ bIsParaEnd = bArg;}
133 : };
134 :
135 : class SW_DLLPUBLIC SwFltControlStack : private ::boost::noncopyable
136 : {
137 : typedef boost::ptr_deque<SwFltStackEntry> Entries;
138 : typedef Entries::iterator myEIter;
139 : Entries maEntries;
140 : friend class SwFltShell;
141 :
142 : sal_uLong nFieldFlags;
143 : KeyCode aEmptyKeyCode; // fuer Bookmarks
144 :
145 : private:
146 : bool bHasSdOD;
147 : bool bSdODChecked;
148 :
149 : protected:
150 : SwDoc* pDoc;
151 : bool bIsEndStack;
152 :
153 : void MoveAttrs( const SwPosition& rPos );
154 : virtual void SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry& rEntry);
155 0 : virtual sal_Int32 GetCurrAttrCP() const {return -1;}
156 : virtual bool IsParaEndInCPs(sal_Int32 nStart,sal_Int32 nEnd,bool bSdOD=true) const;
157 :
158 : //Clear the para end position recorded in reader intermittently for the least impact on loading performance
159 0 : virtual void ClearParaEndPosition(){};
160 : virtual bool CheckSdOD(sal_Int32 nStart,sal_Int32 nEnd);
161 : bool HasSdOD();
162 :
163 : public:
164 : enum Flags
165 : {
166 : HYPO,
167 : TAGS_DO_ID,
168 : TAGS_VISIBLE,
169 : BOOK_TO_VAR_REF,
170 : BOOK_AND_REF,
171 : TAGS_IN_TEXT,
172 : ALLOW_FLD_CR,
173 : NO_FLD_CR,
174 : DONT_HARD_PROTECT
175 : };
176 :
177 : SwFltControlStack(SwDoc* pDo, sal_uLong nFieldFl);
178 : virtual ~SwFltControlStack();
179 :
180 0 : bool IsFlagSet(Flags no) const { return ::SwFltGetFlag(nFieldFlags, no);}
181 :
182 : void NewAttr(const SwPosition& rPos, const SfxPoolItem & rAttr );
183 :
184 : virtual SwFltStackEntry* SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId=0, sal_Bool bTstEnde=sal_True, long nHand = LONG_MAX, sal_Bool consumedByField=sal_False);
185 :
186 : void StealAttr(const SwNodeIndex& rNode, sal_uInt16 nAttrId = 0);
187 : void MarkAllAttrsOld();
188 : void KillUnlockedAttrs(const SwPosition& pPos);
189 : SfxPoolItem* GetFmtStackAttr(sal_uInt16 nWhich, sal_uInt16 * pPos = 0);
190 : const SfxPoolItem* GetOpenStackAttr(const SwPosition& rPos, sal_uInt16 nWhich);
191 : const SfxPoolItem* GetFmtAttr(const SwPosition& rPos, sal_uInt16 nWhich);
192 : void Delete(const SwPaM &rPam);
193 :
194 0 : bool empty() const { return maEntries.empty(); }
195 0 : Entries::size_type size() const { return maEntries.size(); }
196 0 : SwFltStackEntry& operator[](Entries::size_type nIndex)
197 0 : { return maEntries[nIndex]; }
198 : void DeleteAndDestroy(Entries::size_type nCnt);
199 : };
200 :
201 : class SwFltAnchorClient;
202 :
203 : class SW_DLLPUBLIC SwFltAnchor : public SfxPoolItem
204 : {
205 : SwFrmFmt* pFrmFmt;
206 : SwFltAnchorClient * pClient;
207 :
208 : public:
209 : SwFltAnchor(SwFrmFmt* pFlyFmt);
210 : SwFltAnchor(const SwFltAnchor&);
211 : virtual ~SwFltAnchor();
212 :
213 : // "pure virtual Methoden" vom SfxPoolItem
214 : virtual bool operator==(const SfxPoolItem&) const SAL_OVERRIDE;
215 : virtual SfxPoolItem* Clone(SfxItemPool* = 0) const SAL_OVERRIDE;
216 : void SetFrmFmt(SwFrmFmt * _pFrmFmt);
217 : const SwFrmFmt* GetFrmFmt() const;
218 : SwFrmFmt* GetFrmFmt();
219 : };
220 :
221 0 : class SwFltAnchorClient : public SwClient
222 : {
223 : SwFltAnchor * m_pFltAnchor;
224 :
225 : public:
226 : SwFltAnchorClient(SwFltAnchor * pFltAnchor);
227 :
228 : virtual void Modify (const SfxPoolItem *pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
229 : };
230 :
231 0 : class SW_DLLPUBLIC SwFltRedline : public SfxPoolItem
232 : {
233 : public:
234 : DateTime aStamp;
235 : DateTime aStampPrev;
236 : RedlineType_t eType;
237 : RedlineType_t eTypePrev;
238 : sal_uInt16 nAutorNo;
239 : sal_uInt16 nAutorNoPrev;
240 :
241 0 : SwFltRedline(RedlineType_t eType_,
242 : sal_uInt16 nAutorNo_,
243 : const DateTime& rStamp_,
244 : RedlineType_t eTypePrev_ = nsRedlineType_t::REDLINE_INSERT,
245 : sal_uInt16 nAutorNoPrev_ = USHRT_MAX,
246 : const DateTime* pStampPrev_ = 0)
247 : : SfxPoolItem(RES_FLTR_REDLINE), aStamp(rStamp_),
248 : aStampPrev( DateTime::EMPTY ),
249 : eType(eType_),
250 0 : eTypePrev(eTypePrev_), nAutorNo(nAutorNo_), nAutorNoPrev(nAutorNoPrev_)
251 : {
252 0 : if( pStampPrev_ )
253 0 : aStampPrev = *pStampPrev_;
254 0 : }
255 :
256 0 : SwFltRedline(const SwFltRedline& rCpy):
257 : SfxPoolItem(RES_FLTR_REDLINE),
258 : aStamp( rCpy.aStamp ),
259 : aStampPrev( rCpy.aStampPrev ),
260 : eType( rCpy.eType ),
261 : eTypePrev( rCpy.eTypePrev ),
262 : nAutorNo( rCpy.nAutorNo ),
263 0 : nAutorNoPrev( rCpy.nAutorNoPrev )
264 0 : {}
265 : // "pure virtual Methoden" vom SfxPoolItem
266 : virtual bool operator==(const SfxPoolItem& rItem) const SAL_OVERRIDE;
267 : virtual SfxPoolItem* Clone(SfxItemPool* = 0) const SAL_OVERRIDE;
268 : };
269 :
270 0 : class SW_DLLPUBLIC SwFltBookmark : public SfxPoolItem
271 : {
272 : private:
273 : friend class SwFltShell; // darf aName und aVal uebersetzen
274 :
275 : long mnHandle;
276 : OUString maName;
277 : OUString maVal;
278 : bool mbIsTOCBookmark;
279 :
280 : public:
281 : SwFltBookmark( const OUString& rNa,
282 : const OUString& rVa,
283 : long nHand,
284 : const bool bIsTOCBookmark = false );
285 : SwFltBookmark( const SwFltBookmark& );
286 :
287 : // "pure virtual Methoden" vom SfxPoolItem
288 : virtual bool operator==(const SfxPoolItem&) const SAL_OVERRIDE;
289 : virtual SfxPoolItem* Clone(SfxItemPool* = 0) const SAL_OVERRIDE;
290 :
291 0 : long GetHandle() const { return mnHandle; }
292 0 : const OUString& GetName() const { return maName; }
293 0 : const OUString& GetValSys() const { return maVal; }
294 0 : bool IsTOCBookmark() const
295 : {
296 0 : return mbIsTOCBookmark;
297 : }
298 : };
299 :
300 0 : class SW_DLLPUBLIC SwFltTOX : public SfxPoolItem
301 : {
302 : SwTOXBase* pTOXBase;
303 : sal_uInt16 nCols;
304 : sal_Bool bHadBreakItem; // there was a break item BEFORE insertion of the TOX
305 : sal_Bool bHadPageDescItem;
306 : public:
307 : SwFltTOX(SwTOXBase* pBase, sal_uInt16 _nCols = 0);
308 : SwFltTOX(const SwFltTOX&);
309 : // "pure virtual Methoden" vom SfxPoolItem
310 : virtual bool operator==(const SfxPoolItem&) const SAL_OVERRIDE;
311 : virtual SfxPoolItem* Clone(SfxItemPool* = 0) const SAL_OVERRIDE;
312 0 : SwTOXBase* GetBase() { return pTOXBase; }
313 : sal_uInt16 GetCols() const { return nCols; }
314 0 : void SetHadBreakItem( sal_Bool bVal ) { bHadBreakItem = bVal; }
315 0 : void SetHadPageDescItem( sal_Bool bVal ) { bHadPageDescItem = bVal; }
316 0 : sal_Bool HadBreakItem() const { return bHadBreakItem; }
317 0 : sal_Bool HadPageDescItem() const { return bHadPageDescItem; }
318 : };
319 :
320 0 : class SwFltSection : public SfxPoolItem
321 : {
322 : SwSectionData * m_pSection;
323 :
324 : public:
325 : SwFltSection( SwSectionData *const pSect );
326 : SwFltSection( const SwFltSection& );
327 : // "pure virtual Methoden" vom SfxPoolItem
328 : virtual bool operator==(const SfxPoolItem&) const SAL_OVERRIDE;
329 : virtual SfxPoolItem* Clone(SfxItemPool* = 0) const SAL_OVERRIDE;
330 0 : SwSectionData * GetSectionData() { return m_pSection; }
331 : };
332 : // Der WWEndStack verhaelt sich wie der WWControlStck, nur dass die Attribute
333 : // auf ihm bis ans Ende des Dokuments gehortet werden, falls auf sie noch
334 : // zugegriffen werden muss (z.B. Book/RefMarks, Index u.s.w.)
335 0 : class SwFltEndStack : public SwFltControlStack
336 : {
337 : public:
338 0 : SwFltEndStack(SwDoc* pDo, sal_uLong nFieldFl)
339 0 : :SwFltControlStack(pDo, nFieldFl)
340 : {
341 0 : bIsEndStack = true;
342 0 : }
343 : };
344 :
345 : // hier beginnen die fuer ww1-filter neu erstellten klassen. diese
346 : // sollen eine simple oberflaeche fuer die komplexen strukturen des
347 : // writers speziell fuer filter sein. soll etwas in den writer gegeben
348 : // werden, soll ein << reichen. hierfuer sind neue typen erzeugt
349 : // worden. ausserdem soll moeglich sein das objekt nach vielen
350 : // zustaenden der momentanen formatierung zu fragen, sodasz diese der
351 : // filter nicht selbst verwalten musz.
352 :
353 : // den anfang macht eine vorlagen-oberklasse, die einfachen umgang mit
354 : // formatvorlagen ermoeglicht:
355 :
356 : class SwFltOutBase
357 : {
358 : SwDoc& rDoc;
359 : protected:
360 : RndStdIds eFlyAnchor;
361 : sal_Bool bFlyAbsPos;
362 :
363 0 : SwDoc& GetDoc() { return rDoc; }
364 : SfxItemSet* NewFlyDefaults();
365 : SwFltOutBase(SwDoc& rDocu);
366 : virtual ~SwFltOutBase();
367 : public:
368 : virtual SwFltOutBase& operator << (const SfxPoolItem& rItem) = 0;
369 :
370 : virtual const SfxPoolItem& GetAttr(sal_uInt16 nWhich) = 0;
371 : virtual const SfxPoolItem& GetNodeOrStyAttr(sal_uInt16 nWhich) = 0;
372 :
373 : virtual const SfxPoolItem& GetCellAttr(sal_uInt16 nWhich);
374 : virtual bool BeginTable();
375 : virtual void NextTableCell();
376 : virtual void NextTableRow();
377 : virtual void SetTableWidth(SwTwips nW);
378 : virtual void SetTableOrient(sal_Int16 eOri);
379 : virtual void SetCellWidth(SwTwips nWidth, sal_uInt16 nCell);
380 : virtual void SetCellHeight(SwTwips nH);
381 : virtual void SetCellBorder(const SvxBoxItem& rFmtBox, sal_uInt16 nCell);
382 : virtual void SetCellSpace(sal_uInt16 nSp);
383 : virtual void DeleteCell(sal_uInt16 nCell);
384 : virtual void EndTable();
385 :
386 : virtual bool IsInFly() = 0;
387 : virtual void SetFlyFrmAttr(const SfxPoolItem& rAttr) = 0;
388 : virtual const SfxPoolItem& GetFlyFrmAttr(sal_uInt16 nWhich) = 0;
389 : virtual bool BeginFly( RndStdIds eAnchor, sal_Bool bAbsolutePos,
390 : const SfxItemSet* pMoreAttrs = 0 );
391 : virtual void SetFlyAnchor( RndStdIds eAnchor );
392 : virtual void EndFly();
393 : };
394 :
395 0 : class SwFltOutDoc : public SwFltOutBase
396 : {
397 : SwFltControlStack& rStack;
398 : SwFltEndStack& rEndStack;
399 : SwPaM* pPaM;
400 : SwFrmFmt* pFly;
401 : // table items:
402 : const SwTable* pTable;
403 : SwPosition* pTabSavedPos; // set when in table
404 : SwPosition* pFlySavedPos; // set when in fly
405 : SwTwips nTableWidth;
406 : sal_uInt16 usTableX;
407 : sal_uInt16 usTableY;
408 : sal_Bool bReadNoTbl; // Keine Tabellen
409 :
410 : SwTableBox* GetBox(sal_uInt16 ny, sal_uInt16 nx = USHRT_MAX);
411 : sal_Bool SeekCell( short nRow, short nCol, sal_Bool bPam );
412 : void SplitTable();
413 : public:
414 0 : SwFltOutDoc(SwDoc& rDocu, SwPaM* pP, SwFltControlStack& rStk,
415 : SwFltEndStack& rEStk)
416 : : SwFltOutBase(rDocu)
417 : , rStack(rStk)
418 : , rEndStack(rEStk)
419 : , pPaM(pP)
420 : , pFly(0)
421 : , pTable(0)
422 : , pTabSavedPos(0)
423 : , pFlySavedPos(0)
424 : , nTableWidth(0)
425 : , usTableX(0)
426 : , usTableY(0)
427 0 : , bReadNoTbl(sal_False)
428 : {
429 0 : }
430 :
431 0 : void SetReadNoTable() { bReadNoTbl = sal_True; }
432 : sal_Bool IsTableWidthSet() const { return 0 != nTableWidth; }
433 :
434 : virtual SwFltOutBase& operator << (const SfxPoolItem& rItem) SAL_OVERRIDE;
435 :
436 : virtual const SfxPoolItem& GetAttr(sal_uInt16 nWhich) SAL_OVERRIDE;
437 : virtual const SfxPoolItem& GetNodeOrStyAttr(sal_uInt16 nWhich) SAL_OVERRIDE;
438 :
439 : sal_Bool IsInTable();
440 : virtual const SfxPoolItem& GetCellAttr(sal_uInt16 nWhich) SAL_OVERRIDE;
441 : virtual bool BeginTable() SAL_OVERRIDE;
442 : virtual void NextTableCell() SAL_OVERRIDE;
443 : virtual void NextTableRow() SAL_OVERRIDE;
444 : virtual void SetTableWidth(SwTwips nW) SAL_OVERRIDE;
445 : virtual void SetTableOrient(sal_Int16 eOri) SAL_OVERRIDE;
446 : virtual void SetCellWidth(SwTwips nWidth, sal_uInt16 nCell) SAL_OVERRIDE;
447 : virtual void SetCellHeight(SwTwips nH) SAL_OVERRIDE;
448 : virtual void SetCellBorder(const SvxBoxItem& rFmtBox, sal_uInt16 nCell) SAL_OVERRIDE;
449 : virtual void SetCellSpace(sal_uInt16 nSp) SAL_OVERRIDE;
450 : virtual void DeleteCell(sal_uInt16 nCell) SAL_OVERRIDE;
451 : virtual void EndTable() SAL_OVERRIDE;
452 :
453 : SwFrmFmt* MakeFly( RndStdIds eAnchor, SfxItemSet* pSet );
454 : virtual bool IsInFly() SAL_OVERRIDE;
455 : virtual void SetFlyFrmAttr(const SfxPoolItem& rAttr) SAL_OVERRIDE;
456 : virtual const SfxPoolItem& GetFlyFrmAttr(sal_uInt16 nWhich) SAL_OVERRIDE;
457 : virtual bool BeginFly( RndStdIds eAnchor, sal_Bool bAbsolutePos,
458 : const SfxItemSet* pMoreAttrs = 0 ) SAL_OVERRIDE;
459 : virtual void EndFly() SAL_OVERRIDE;
460 : };
461 :
462 : class SwFltFormatCollection : public SwFltOutBase
463 : {
464 : SwTxtFmtColl* pColl;
465 : SfxItemSet* pFlyAttrs; // Simulation der Flys in Styles
466 : bool bHasFly;
467 : public:
468 : SwFltFormatCollection(SwDoc&, RES_POOL_COLLFMT_TYPE nType);
469 : SwFltFormatCollection(SwDoc&, const OUString& rName );
470 0 : virtual ~SwFltFormatCollection() { if( pFlyAttrs ) delete pFlyAttrs; }
471 :
472 0 : void Reset()
473 : {
474 : // #i73790# - method renamed
475 0 : pColl->ResetAllFmtAttr();
476 0 : pColl->SetAuto(false); // nach Empfehlung JP
477 0 : }
478 0 : void Derived(SwTxtFmtColl* pBase)
479 0 : { pColl->SetDerivedFrom(pBase); }
480 :
481 : // SwTxtFmtColl* Search(String, CharSet eSrc);
482 0 : SwTxtFmtColl* GetColl() { return pColl; }
483 : void SetHasFly() { bHasFly = true; }
484 0 : SfxItemSet* GetpFlyAttrs() { return pFlyAttrs; }
485 :
486 : virtual SwFltOutBase& operator << (const SfxPoolItem& rItem) SAL_OVERRIDE;
487 : virtual const SfxPoolItem& GetAttr(sal_uInt16 nWhich) SAL_OVERRIDE;
488 : virtual const SfxPoolItem& GetNodeOrStyAttr(sal_uInt16 nWhich) SAL_OVERRIDE;
489 :
490 : virtual bool IsInFly() SAL_OVERRIDE;
491 : virtual void SetFlyFrmAttr(const SfxPoolItem& rAttr) SAL_OVERRIDE;
492 : virtual const SfxPoolItem& GetFlyFrmAttr(sal_uInt16 nWhich) SAL_OVERRIDE;
493 : virtual bool BeginFly( RndStdIds eAnchor, sal_Bool bAbsolutePos,
494 : const SfxItemSet* pMoreAttrs = 0 ) SAL_OVERRIDE;
495 : bool BeginStyleFly( SwFltOutDoc* pOutDoc );
496 : virtual void EndFly() SAL_OVERRIDE;
497 : };
498 :
499 : // dies nun ist die zauberhafteklasse: intention: alle eins nach dem
500 : // andern hinein'pipe'n. wird eine besondere struktur eingelesen, wird
501 : // eine klammer geoeffnet (BeginXxx) und nach beendigung geschlossen
502 : // (EndXxx), wobei Xxx zB fuer Fusznoten, Kopf/Fuszzeilen oder
503 : // Tabellen steht. Styles funktionieren auch so, haben aber den
504 : // unterschied, keine buchstaben zu akzeptieren.
505 : // beginnt ein neuer absatz oder aehnliches, wird NextXxx genutzt.
506 : // hier ist moeglich, Tab, Zeilenumbruch, Absatzende, Seitenumbruch
507 : // und Sektionsende einzufuegen.
508 :
509 : class SwFltShell
510 : {
511 : SwFltOutDoc* pOutDoc;
512 : SwFltFormatCollection* pColls[256];
513 : SwFltOutBase* pOut;
514 :
515 : // SwFltFormatCollection* pFormat; // set when in style-mode
516 : SwPageDesc* pCurrentPageDesc;
517 : SwPosition* pSavedPos; // set, when in footnote or header/footer -mode
518 : #ifdef None
519 : #undef None
520 : #endif
521 : enum SubModes {
522 : None,
523 : Header,
524 : Footer,
525 : Footnote,
526 : Table,
527 : Fly,
528 : Style,
529 : Max
530 : } eSubMode;
531 :
532 : // Fly items:
533 : sal_uInt16 nAktStyle; // zur Indizierung pStyleFlyTable
534 :
535 : SwFltControlStack aStack;
536 : SwFltEndStack aEndStack;
537 : SwPaM* pPaM;
538 :
539 : OUString sBaseURL;
540 : sal_uInt16 nPageDescOffset; // fuers update der pagedescs
541 : rtl_TextEncoding eSrcCharSet; // charset der quelle
542 : friend class SwFltControlStack;
543 : sal_Bool bNewDoc;
544 : sal_Bool bStdPD;
545 : sal_Bool bProtect;
546 :
547 : public:
548 : SwFltShell(SwDoc* , SwPaM& , const OUString& rBaseURL, sal_Bool bNew, sal_uLong = 0);
549 : ~SwFltShell();
550 :
551 0 : SwDoc& GetDoc() { return *aStack.pDoc; }
552 :
553 : rtl_TextEncoding SetCharSet(rtl_TextEncoding eNew) { rtl_TextEncoding eOld = eSrcCharSet;
554 : eSrcCharSet = eNew;
555 : return eOld;
556 : }
557 0 : void SetUseStdPageDesc() { bStdPD = sal_True; }
558 0 : void SetProtect() { bProtect = sal_True; }
559 : SwPageDesc* MakePageDesc(SwPageDesc* pFirstPageDesc = NULL);
560 0 : SwPageDesc& GetPageDesc() { return *pCurrentPageDesc; }
561 0 : void NextTab() { (*this) << sal_uInt8(0x09); }
562 0 : void NextLine() { (*this) << sal_uInt8(0x0a); }
563 : void NextParagraph();
564 : void NextPage();
565 0 : void NextSection() { pCurrentPageDesc = MakePageDesc(); }
566 :
567 : SwFltShell& AddGraphic( const OUString& rPicName );
568 : SwFltShell& AddError( const sal_Char* pErr );
569 : SwFltShell& EndItem( sal_uInt16 nId );
570 : SwFltShell& SetStyle( sal_uInt16 nStyle );
571 :
572 : SwFltShell& operator << ( Graphic& );
573 : SwFltShell& operator << ( SwFltBookmark& aBook );
574 : void SetBookEnd(long nHandle);
575 : SwFltShell& operator << ( const OUString& ); // Vorsicht: CHARSET_ANSI
576 : SwFltShell& operator << ( const sal_Unicode );
577 : SwFltShell& operator << ( const SwField& );
578 0 : SwFltShell& operator << ( const SfxPoolItem& rItem )
579 0 : { *pOut << rItem; return *this; }
580 :
581 : // SwFltShell& operator >> (SfxPoolItem&);
582 : // methode zum beenden einer sub-sektion, zB Fusznote etc
583 : void End() { eSubMode = None; }
584 : // methoden zur verwaltung von Header/Footer
585 : void BeginHeader(SwPageDesc* =NULL);
586 : void BeginFooter(SwPageDesc* =NULL);
587 : void EndHeaderFooter();
588 : // methoden zur verwaltung von FootNotes
589 : void BeginFootnote();
590 : void EndFootnote();
591 : // methoden zur verwaltung von Tabellen
592 0 : sal_Bool IsInTable() {
593 0 : return ( pOut == pOutDoc ) ? pOutDoc->IsInTable() : 0; }
594 0 : const SfxPoolItem& GetCellAttr(sal_uInt16 nWhich) {
595 0 : return pOut->GetCellAttr(nWhich); }
596 0 : bool BeginTable() {
597 0 : bool b = pOut->BeginTable();
598 0 : if(b) eSubMode = Table;
599 0 : return b; }
600 0 : void NextTableCell() {
601 0 : pOut->NextTableCell(); }
602 0 : void NextTableRow() {
603 0 : pOut->NextTableRow(); }
604 0 : void SetTableWidth(SwTwips nW) {
605 0 : pOut->SetTableWidth(nW); }
606 : sal_Bool IsTableWidthSet() {
607 : return pOutDoc->IsTableWidthSet(); }
608 0 : void SetTableOrient(sal_Int16 eOri) {
609 0 : pOut->SetTableOrient(eOri); }
610 0 : void SetCellWidth(SwTwips nWidth, sal_uInt16 nCell = USHRT_MAX ) {
611 0 : pOut->SetCellWidth(nWidth, nCell); }
612 0 : void SetCellHeight(SwTwips nH) {
613 0 : pOut->SetCellHeight(nH); }
614 0 : void SetCellBorder(const SvxBoxItem& rFmtBox, sal_uInt16 nCell = USHRT_MAX ){
615 0 : pOut->SetCellBorder(rFmtBox, nCell); }
616 0 : void SetCellSpace(sal_uInt16 nSp) {
617 0 : pOut->SetCellSpace(nSp); }
618 0 : void DeleteCell(sal_uInt16 nCell = USHRT_MAX) {
619 0 : pOut->DeleteCell(nCell); }
620 0 : void EndTable() {
621 0 : pOut->EndTable(); }
622 : // methoden zur verwaltung von Flys
623 0 : bool IsInFly() { return pOut->IsInFly(); }
624 : bool BeginFly( RndStdIds eAnchor = FLY_AT_PARA, sal_Bool bAbsolutePos = sal_False );
625 0 : void SetFlyAnchor( RndStdIds eAnchor )
626 0 : { pOut->SetFlyAnchor( eAnchor ); }
627 : void SetFlyXPos( short nXPos, sal_Int16 eHRel = com::sun::star::text::RelOrientation::FRAME,
628 : sal_Int16 eHAlign = com::sun::star::text::HoriOrientation::NONE );
629 : void SetFlyYPos( short nYPos, sal_Int16 eVRel = com::sun::star::text::RelOrientation::FRAME,
630 : sal_Int16 eVAlign = com::sun::star::text::VertOrientation::NONE );
631 0 : void SetFlyFrmAttr(const SfxPoolItem& rAttr){
632 0 : pOut->SetFlyFrmAttr( rAttr ); }
633 : void EndFly();
634 : // methoden zur verwaltung von styles:
635 0 : void BeginStyle(sal_uInt16 nUserCode, RES_POOL_COLLFMT_TYPE aType)
636 : {
637 : OSL_ENSURE(nUserCode<sizeof(pColls)/sizeof(*pColls), "code out of bounds");
638 : OSL_ENSURE(pColls[nUserCode] == NULL, "user codes dublicate");
639 0 : if (eSubMode == Style)
640 0 : EndStyle();
641 0 : pOut = pColls[nUserCode] = new SwFltFormatCollection(GetDoc(), aType);
642 0 : nAktStyle = nUserCode;
643 0 : eSubMode = Style;
644 0 : }
645 0 : void BeginStyle( sal_uInt16 nUserCode, const OUString& rName )
646 : {
647 : OSL_ENSURE(nUserCode<sizeof(pColls)/sizeof(*pColls), "code out of bounds");
648 : OSL_ENSURE(pColls[nUserCode] == NULL, "user codes dublicate");
649 0 : if (eSubMode == Style)
650 0 : EndStyle();
651 0 : pOut = pColls[nUserCode] = new SwFltFormatCollection(GetDoc(), rName );
652 0 : nAktStyle = nUserCode;
653 0 : eSubMode = Style;
654 0 : }
655 0 : sal_Bool IsStyleImported(sal_uInt16 nUserCode)
656 0 : { return pColls[nUserCode] != 0; }
657 0 : void BaseStyle(sal_uInt16 nBased)
658 : {
659 : OSL_ENSURE(eSubMode == Style, "wrong state for style");
660 : OSL_ENSURE(pColls[nBased], "Style based on noexistent style" );
661 0 : if( eSubMode == Style && pColls[nBased]->GetColl() )
662 0 : ((SwFltFormatCollection*)pOut)->Derived(pColls[nBased]->GetColl());
663 0 : }
664 : void NextStyle(sal_uInt16 nWhich, sal_uInt16 nNext);
665 :
666 0 : void EndStyle()
667 : {
668 : // OSL_ENSURE(eSubMode == Style, "wrong state for style");
669 0 : nAktStyle = 0;
670 0 : pOut = pOutDoc;
671 0 : eSubMode = None;
672 0 : }
673 :
674 0 : bool IsFlagSet(SwFltControlStack::Flags no) const
675 0 : { return aStack.IsFlagSet(no); }
676 : OUString ConvertUStr(const OUString& rInOut);
677 : OUString QuoteStr( const OUString& rIn );
678 :
679 : // folgende status kann die shell verwalten:
680 : const SfxPoolItem& GetNodeOrStyAttr(sal_uInt16 nWhich);
681 : const SfxPoolItem& GetAttr(sal_uInt16 nWhich);
682 : const SfxPoolItem& GetFlyFrmAttr(sal_uInt16 nWhich);
683 : SwFieldType* GetSysFldType(sal_uInt16 eWhich);
684 : bool GetWeightBold();
685 : bool GetPostureItalic();
686 : bool GetCrossedOut();
687 : bool GetContour();
688 : bool GetCaseKapitaelchen();
689 : bool GetCaseVersalien();
690 :
691 0 : const OUString& GetBaseURL() const { return sBaseURL; }
692 : };
693 :
694 : SW_DLLPUBLIC void UpdatePageDescs(SwDoc &rDoc, sal_uInt16 nInPageDescOffset);
695 :
696 : #endif
697 :
698 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|