merge the formfield patch from ooo-build
[ooovba.git] / binfilter / inc / bf_sw / ndarr.hxx
blobdc2db2c8296d9e616037fec6f4676d107df38da7
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ndarr.hxx,v $
10 * $Revision: 1.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _NDARR_HXX
32 #define _NDARR_HXX
34 #ifndef _SVARRAY_HXX //autogen
35 #include <bf_svtools/svarray.hxx>
36 #endif
38 #ifndef _BPARR_HXX
39 #include <bparr.hxx>
40 #endif
41 #ifndef _NDTYP_HXX
42 #include <ndtyp.hxx>
43 #endif
45 class Graphic;
46 class UniString;
48 namespace binfilter {
49 class SvInPlaceObject;
50 class BfGraphicObject;
52 class SwAttrSet;
53 class SwCntntFrm;
54 class SwCntntNode;
55 class SwDoc;
56 class SwGrfFmtColl;
57 class SwGrfNode;
58 class SwHistory;
59 class SwNode;
60 class SwNodeIndex;
61 class SwNodeRange;
62 class SwOLENode;
63 class SwOutlineNodes;
64 class SwPaM;
65 class SwSection;
66 class SwSectionFmt;
67 class SwSectionNode;
68 class SwStartNode;
69 class SwTableBoxFmt;
70 class SwTableFmt;
71 class SwTableLine;
72 class SwTableLineFmt;
73 class SwTableNode;
74 class SwTblToTxtSaves;
75 class SwTxtFmtColl;
76 class SwTxtNode;
77 struct SwPosition;
80 // --------------------
81 // class SwNodes
82 // --------------------
84 typedef SwNode * SwNodePtr;
85 typedef BOOL (*FnForEach_SwNodes)( const SwNodePtr&, void* pArgs );
87 SV_DECL_PTRARR_SORT( SwOutlineNodes, SwNodePtr, 0, 10 )
89 class SwNodes: private BigPtrArray
91 friend class SwDoc;
92 friend class SwNode;
93 friend class SwNodeIndex;
95 SwNodePtr operator[]( USHORT n ) const;
96 SwNodePtr operator[]( int n ) const;
98 SwNodeIndex* pRoot; // Liste aller Indizies auf Nodes
100 void Insert( const SwNodePtr pNode, const SwNodeIndex& rPos );
101 void Insert( const SwNodePtr pNode, ULONG nPos);
102 // void Remove( const SwNodeIndex& rPos, USHORT nLen = 1 );
103 // void Remove( ULONG nPos, USHORT nLen = 1 );
104 // BOOL Move( const SwIndex & rOldPos, const SwIndex & rNewPos );
107 SwDoc* pMyDoc; // in diesem Doc ist das Nodes-Array
109 SwNode *pEndOfPostIts, *pEndOfInserts, // das sind die festen Bereiche
110 *pEndOfAutotext, *pEndOfRedlines,
111 *pEndOfContent;
113 SwOutlineNodes* pOutlineNds; // Array aller GliederiungsNodes
115 BOOL bInNodesDel : 1; // falls rekursiv aufgerufen wird
116 // Num/Outline nicht aktualisierem
117 BOOL bInDelUpdOutl : 1; // Flags fuers aktualisieren von Outl.
118 BOOL bInDelUpdNum : 1; // Flags fuers aktualisieren von Outl.
120 // fuer dier Verwaltung der Indizies
121 void RegisterIndex( SwNodeIndex& rIdx );
122 void DeRegisterIndex( SwNodeIndex& rIdx );
123 void RemoveNode( ULONG nDelPos, ULONG nLen, FASTBOOL bDel );
125 // Aktionen auf die Nodes
126 void SectionUpDown( const SwNodeIndex & aStart, const SwNodeIndex & aEnd );
127 void DelNodes( const SwNodeIndex& rStart, ULONG nCnt = 1 );
129 void UpdtOutlineIdx( const SwNode& ); // Update ab Node alle OutlineNodes
131 void _CopyNodes( const SwNodeRange&, const SwNodeIndex&,
132 BOOL bNewFrms = TRUE, BOOL bTblInsDummyNode = FALSE ) const;
133 void _DelDummyNodes( const SwNodeRange& rRg );
135 protected:
136 SwNodes( SwDoc* pDoc );
138 public:
139 ~SwNodes();
141 SwNodePtr operator[]( ULONG n ) const
142 { return (SwNodePtr)BigPtrArray::operator[] ( n ); }
144 //JP 29.09.97: impl. steht im ndindex.hxx - sollte moeglichst bald auf die
145 // neue Schnittstelle angepasst werden
146 inline SwNodePtr operator[]( const SwNodeIndex& rIdx ) const;
148 ULONG Count() const { return BigPtrArray::Count(); }
149 void ForEach( FnForEach_SwNodes fnForEach, void* pArgs = 0 )
151 BigPtrArray::ForEach( 0, BigPtrArray::Count(),
152 (FnForEach) fnForEach, pArgs );
154 void ForEach( ULONG nStt, ULONG nEnd, FnForEach_SwNodes fnForEach, void* pArgs = 0 )
156 BigPtrArray::ForEach( nStt, nEnd, (FnForEach) fnForEach, pArgs );
158 void ForEach( const SwNodeIndex& rStart, const SwNodeIndex& rEnd,
159 FnForEach_SwNodes fnForEach, void* pArgs = 0 );
161 // eine noch leere Section
162 SwNode& GetEndOfPostIts() const { return *pEndOfPostIts; }
163 // Section fuer alle Fussnoten
164 SwNode& GetEndOfInserts() const { return *pEndOfInserts; }
165 // Section fuer alle Flys/Header/Footers
166 SwNode& GetEndOfAutotext() const { return *pEndOfAutotext; }
167 // Section fuer alle Redlines
168 SwNode& GetEndOfRedlines() const { return *pEndOfRedlines; }
169 // das ist der letzte EndNode einer SonderSection. Hier nach kommt nur
170 // noch die normale ContentSection (also der BodyText)
171 SwNode& GetEndOfExtras() const { return *pEndOfRedlines; }
172 // die normale ContentSection (also der BodyText)
173 SwNode& GetEndOfContent() const { return *pEndOfContent; }
175 // ist das NodesArray das normale vom Doc? (nicht das UndoNds, .. )
176 // Implementierung steht im doc.hxx (weil man dazu Doc kennen muss) !
177 inline BOOL IsDocNodes() const;
179 void Delete(const SwNodeIndex &rPos, ULONG nNodes = 1);
181 void _Copy( const SwNodeRange& rRg, const SwNodeIndex& rInsPos,
182 BOOL bNewFrms = TRUE ) const
183 { _CopyNodes( rRg, rInsPos, bNewFrms ); }
185 void SectionDown( SwNodeRange *pRange, SwStartNodeType = SwNormalStartNode );
187 BOOL CheckNodesRange( const SwNodeIndex& rStt, const SwNodeIndex& rEnd ) const;
189 void GoStartOfSection(SwNodeIndex *) const;
190 void GoEndOfSection(SwNodeIndex *) const;
192 SwCntntNode* GoNext(SwNodeIndex *) const;
193 SwCntntNode* GoPrevious(SwNodeIndex *) const;
195 //Gehe zum naechsten/vorherigen Cntnt/Tabellennode, fuer den
196 //es LayoutFrames gibt, dabei Kopf-/Fusszeilen/Rahmen etc. nicht verlassen
197 SwNode* GoNextWithFrm(SwNodeIndex *) const;
199 // zum naechsten Content-Node, der nicht geschuetzt oder versteckt ist
200 // (beides auf FALSE ==> GoNext/GoPrevious!!!)
201 SwCntntNode* GoNextSection( SwNodeIndex *, int bSkipHidden = TRUE,
202 int bSkipProtect = TRUE ) const;
203 SwCntntNode* GoPrevSection( SwNodeIndex *, int bSkipHidden = TRUE,
204 int bSkipProtect = TRUE ) const;
206 // erzeuge ein leere Section von Start und EndNode. Darf nur gerufen
207 // werden, wenn eine neue Section mit Inhalt erzeugt werden soll.
208 // Zum Beispiel bei den Filtern/Undo/...
209 SwStartNode* MakeEmptySection( const SwNodeIndex& rIdx,
210 SwStartNodeType = SwNormalStartNode );
213 // die Impl. von "Make...Node" stehen in den angegebenen .ccx-Files
214 SwTxtNode *MakeTxtNode( const SwNodeIndex & rWhere,
215 SwTxtFmtColl *pColl,
216 SwAttrSet* pAutoAttr = 0 ); // in ndtxt.cxx
217 SwStartNode* MakeTextSection( const SwNodeIndex & rWhere,
218 SwStartNodeType eSttNdTyp,
219 SwTxtFmtColl *pColl,
220 SwAttrSet* pAutoAttr = 0 );
222 SwGrfNode *MakeGrfNode( const SwNodeIndex & rWhere,
223 const UniString& rGrfName,
224 const UniString& rFltName,
225 const Graphic* pGraphic,
226 SwGrfFmtColl *pColl,
227 SwAttrSet* pAutoAttr = 0,
228 BOOL bDelayed = FALSE ); // in ndgrf.cxx
230 SwGrfNode *MakeGrfNode( const SwNodeIndex & rWhere,
231 const BfGraphicObject& rGrfObj,
232 SwGrfFmtColl *pColl,
233 SwAttrSet* pAutoAttr = 0 ); // in ndgrf.cxx
235 SwOLENode *MakeOLENode( const SwNodeIndex & rWhere,
236 SvInPlaceObject *pObj,
237 SwGrfFmtColl *pColl,
238 SwAttrSet* pAutoAttr = 0 ); // in ndole.cxx
239 SwOLENode *MakeOLENode( const SwNodeIndex & rWhere,
240 UniString &rName,
241 SwGrfFmtColl *pColl,
242 SwAttrSet* pAutoAttr = 0 ); // in ndole.cxx
244 // Array aller GliederiungsNodes;
245 const SwOutlineNodes& GetOutLineNds() const { return *pOutlineNds; }
246 // ab einem bestimmten TextNode alle Updaten
247 void UpdateOutlineNode( const SwNode&, BYTE nOldLevel, BYTE nNewLevel );
248 // alle Nodes Updaten - Rule/Format-Aenderung
249 void UpdateOutlineNodes();
251 // fuege die Nodes fuer die Tabelle ein
252 // wenn Lines angegeben, erzeuge die Matrix aus Lines & Boxen
253 // ansonsten nur die Anzahl von Boxen.
254 /* #109161#
256 New parameter pAttrSet: If pAttrSet is non-null and contains an
257 adjust item it is propagated to the table cells. If there is an
258 adjust in pCntntTxtColl or pHeadlineTxtColl this adjust item
259 overrides the item in pAttrSet.
262 SwTableNode* InsertTable( const SwNodeIndex& rNdIdx,
263 USHORT nBoxes, SwTxtFmtColl* pCntntTxtColl,
264 USHORT nLines=0, SwTxtFmtColl* pHeadlineTxtColl=0,
265 const SwAttrSet * pAttrSet = 0);
267 // fuege in der Line, vor der InsPos eine neue Box ein. Das Format
268 // wird von der nachfolgenden (vorhergenden;wenn an Ende) genommen
269 // in der Line muss schon eine Box vorhanden sein !
270 BOOL InsBoxen( SwTableNode*, SwTableLine*, SwTableBoxFmt*,
271 // Formate fuer den TextNode der Box
272 SwTxtFmtColl*, SwAttrSet* pAutoAttr,
273 USHORT nInsPos, USHORT nCnt = 1 );
274 // Splittet eine Tabelle in der Grund-Zeile, in der der Index steht.
275 // Alle GrundZeilen dahinter wandern in eine neue Tabelle/-Node.
276 // Ist das Flag bCalcNewSize auf TRUE, wird fuer beide neuen Tabellen
277 // die neue SSize aus dem Max der Boxen errechnet; vorrausgesetzt,
278 // die SSize ist "absolut" gesetzt (LONG_MAX)
279 // (Wird zur Zeit nur fuer den RTF-Parser benoetigt)
280 // fuegt 2 Tabellen, die hintereinander stehen, wieder zusammen
282 // fuege eine neue SwSection ein
283 SwSectionNode* InsertSection( const SwNodeIndex& rNdIdx,
284 SwSectionFmt& rSectionFmt,
285 const SwSection&,
286 const SwNodeIndex* pEnde,
287 BOOL bInsAtStart = TRUE,
288 BOOL bCreateFrms = TRUE );
290 // in welchem Doc steht das Nodes-Array ?
291 SwDoc* GetDoc() { return pMyDoc; }
292 const SwDoc* GetDoc() const { return pMyDoc; }
294 // suche den vorhergehenden [/nachfolgenden ] ContentNode oder
295 // TabellenNode mit Frames. Wird kein Ende angeben, dann wird mit
296 // dem FrameIndex begonnen; ansonsten, wird mit dem vor rFrmIdx und
297 // dem hintern pEnd die Suche gestartet. Sollte kein gueltiger Node
298 // gefunden werden, wird 0 returnt. rFrmIdx zeigt auf dem Node mit
299 // Frames
300 SwNode* FindPrvNxtFrmNode( SwNodeIndex& rFrmIdx,
301 const SwNode* pEnd = 0 ) const;
302 private:
303 // privater Constructor, weil nie kopiert werden darf !!
304 SwNodes( const SwNodes & rNodes );
309 } //namespace binfilter
310 #endif