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_INC_DOCARY_HXX
20 : #define INCLUDED_SW_INC_DOCARY_HXX
21 :
22 : #include <com/sun/star/i18n/ForbiddenCharacters.hpp>
23 : #include <vector>
24 : #include <set>
25 : #include <algorithm>
26 : #include <o3tl/sorted_vector.hxx>
27 :
28 : class SwFieldType;
29 : class SwFmt;
30 : class SwFrmFmt;
31 : class SwCharFmt;
32 : class SwTOXType;
33 : class SwUndo;
34 : class SwSectionFmt;
35 : class SwNumRule;
36 : class SwRangeRedline;
37 : class SwExtraRedline;
38 : class SwUnoCrsr;
39 : class SwOLENode;
40 : class SwTxtFmtColl;
41 : class SwGrfFmtColl;
42 : class SwTable;
43 : class SwTableLine;
44 : class SwTableBox;
45 :
46 : namespace com { namespace sun { namespace star { namespace i18n {
47 : struct ForbiddenCharacters; ///< comes from the I18N UNO interface
48 : }}}}
49 :
50 : #include <swtypes.hxx>
51 : #include <ndarr.hxx>
52 :
53 : /** provides some methods for generic operations on lists that contain
54 : SwFmt* subclasses. */
55 0 : class SwFmtsBase
56 : {
57 : public:
58 : virtual size_t GetFmtCount() const = 0;
59 : virtual SwFmt* GetFmt(size_t idx) const = 0;
60 : virtual ~SwFmtsBase() = 0;
61 : };
62 :
63 0 : class SwGrfFmtColls : public std::vector<SwGrfFmtColl*>, public SwFmtsBase
64 : {
65 : public:
66 0 : virtual size_t GetFmtCount() const SAL_OVERRIDE { return size(); }
67 0 : virtual SwFmt* GetFmt(size_t idx) const SAL_OVERRIDE { return (SwFmt*)operator[](idx); }
68 : sal_uInt16 GetPos(const SwGrfFmtColl* pFmt) const;
69 : /// free's any remaining child objects
70 0 : virtual ~SwGrfFmtColls() {}
71 : };
72 :
73 : /// stupid base class to work around MSVC dllexport mess
74 0 : class SAL_DLLPUBLIC_TEMPLATE SwFrmFmts_Base : public std::vector<SwFrmFmt*> {};
75 :
76 : /// Specific frame formats (frames, DrawObjects).
77 0 : class SW_DLLPUBLIC SwFrmFmts : public SwFrmFmts_Base, public SwFmtsBase
78 : {
79 : public:
80 0 : virtual size_t GetFmtCount() const SAL_OVERRIDE { return size(); }
81 0 : virtual SwFmt* GetFmt(size_t idx) const SAL_OVERRIDE { return (SwFmt*)operator[](idx); }
82 : sal_uInt16 GetPos(const SwFrmFmt* pFmt) const;
83 : bool Contains(const SwFrmFmt* pFmt) const;
84 : void dumpAsXml(xmlTextWriterPtr w);
85 : /// free's any remaining child objects
86 : virtual ~SwFrmFmts();
87 : };
88 :
89 0 : class SwCharFmts : public std::vector<SwCharFmt*>, public SwFmtsBase
90 : {
91 : public:
92 0 : virtual size_t GetFmtCount() const SAL_OVERRIDE { return size(); }
93 0 : virtual SwFmt* GetFmt(size_t idx) const SAL_OVERRIDE { return (SwFmt*)operator[](idx); }
94 : sal_uInt16 GetPos(const SwCharFmt* pFmt) const;
95 : bool Contains(const SwCharFmt* pFmt) const;
96 : void dumpAsXml(xmlTextWriterPtr w);
97 : /// free's any remaining child objects
98 : virtual ~SwCharFmts();
99 : };
100 :
101 0 : class SwTxtFmtColls : public std::vector<SwTxtFmtColl*>, public SwFmtsBase
102 : {
103 : public:
104 0 : virtual size_t GetFmtCount() const SAL_OVERRIDE { return size(); }
105 0 : virtual SwFmt* GetFmt(size_t idx) const SAL_OVERRIDE { return (SwFmt*)operator[](idx); }
106 : sal_uInt16 GetPos(const SwTxtFmtColl* pFmt) const;
107 : void dumpAsXml(xmlTextWriterPtr w);
108 0 : virtual ~SwTxtFmtColls() {}
109 : };
110 :
111 : /// Array of Undo-history.
112 0 : class SW_DLLPUBLIC SwSectionFmts : public std::vector<SwSectionFmt*>, public SwFmtsBase
113 : {
114 : public:
115 0 : virtual size_t GetFmtCount() const SAL_OVERRIDE { return size(); }
116 0 : virtual SwFmt* GetFmt(size_t idx) const SAL_OVERRIDE { return (SwFmt*)operator[](idx); }
117 : sal_uInt16 GetPos(const SwSectionFmt* pFmt) const;
118 : bool Contains(const SwSectionFmt* pFmt) const;
119 : /// free's any remaining child objects
120 : virtual ~SwSectionFmts();
121 : };
122 :
123 0 : class SwFldTypes : public std::vector<SwFieldType*> {
124 : public:
125 : /// the destructor will free all objects still in the vector
126 : ~SwFldTypes();
127 : sal_uInt16 GetPos(const SwFieldType* pFieldType) const;
128 : void dumpAsXml(xmlTextWriterPtr w);
129 : };
130 :
131 0 : class SwTOXTypes : public std::vector<SwTOXType*> {
132 : public:
133 : /// the destructor will free all objects still in the vector
134 : ~SwTOXTypes();
135 : sal_uInt16 GetPos(const SwTOXType* pTOXType) const;
136 : };
137 :
138 0 : class SW_DLLPUBLIC SwNumRuleTbl : public std::vector<SwNumRule*> {
139 : public:
140 : /// the destructor will free all objects still in the vector
141 : ~SwNumRuleTbl();
142 : sal_uInt16 GetPos(const SwNumRule* pRule) const;
143 : void dumpAsXml(xmlTextWriterPtr w);
144 : };
145 :
146 : struct CompareSwRedlineTbl
147 : {
148 : bool operator()(SwRangeRedline* const &lhs, SwRangeRedline* const &rhs) const;
149 : };
150 0 : class _SwRedlineTbl
151 : : public o3tl::sorted_vector<SwRangeRedline*, CompareSwRedlineTbl,
152 : o3tl::find_partialorder_ptrequals>
153 : {
154 : public:
155 : ~_SwRedlineTbl();
156 : };
157 :
158 0 : class SwRedlineTbl : private _SwRedlineTbl
159 : {
160 : public:
161 0 : bool Contains(const SwRangeRedline* p) const { return find(const_cast<SwRangeRedline* const>(p)) != end(); }
162 : sal_uInt16 GetPos(const SwRangeRedline* p) const;
163 :
164 : bool Insert( SwRangeRedline* p, bool bIns = true );
165 : bool Insert( SwRangeRedline* p, sal_uInt16& rInsPos, bool bIns = true );
166 : bool InsertWithValidRanges( SwRangeRedline* p, sal_uInt16* pInsPos = 0 );
167 :
168 : void Remove( sal_uInt16 nPos );
169 : bool Remove( const SwRangeRedline* p );
170 : void DeleteAndDestroy( sal_uInt16 nPos, sal_uInt16 nLen = 1 );
171 : void DeleteAndDestroyAll();
172 :
173 : void dumpAsXml(xmlTextWriterPtr w);
174 :
175 : /** Search next or previous Redline with the same Seq. No.
176 : Search can be restricted via Lookahaed.
177 : Using 0 or USHRT_MAX makes search the whole array. */
178 : sal_uInt16 FindNextOfSeqNo( sal_uInt16 nSttPos, sal_uInt16 nLookahead = 20 ) const;
179 : sal_uInt16 FindPrevOfSeqNo( sal_uInt16 nSttPos, sal_uInt16 nLookahead = 20 ) const;
180 : sal_uInt16 FindNextSeqNo( sal_uInt16 nSeqNo, sal_uInt16 nSttPos,
181 : sal_uInt16 nLookahead = 20 ) const;
182 : sal_uInt16 FindPrevSeqNo( sal_uInt16 nSeqNo, sal_uInt16 nSttPos,
183 : sal_uInt16 nLookahead = 20 ) const;
184 :
185 : using _SwRedlineTbl::size;
186 : using _SwRedlineTbl::operator[];
187 : using _SwRedlineTbl::empty;
188 : };
189 :
190 : /// Table that holds 'extra' redlines, such as 'table row insert\delete', 'paragraph moves' etc...
191 0 : class SwExtraRedlineTbl
192 : {
193 : private:
194 : std::vector<SwExtraRedline*> m_aExtraRedlines;
195 :
196 : public:
197 : ~SwExtraRedlineTbl();
198 : sal_uInt16 GetPos(const SwExtraRedline* p) const;
199 :
200 : bool Insert( SwExtraRedline* p );
201 :
202 : void Remove( sal_uInt16 nPos );
203 : void DeleteAndDestroy( sal_uInt16 nPos, sal_uInt16 nLen = 1 );
204 : void DeleteAndDestroyAll();
205 :
206 : void dumpAsXml(xmlTextWriterPtr w);
207 :
208 0 : sal_uInt16 GetSize() const { return m_aExtraRedlines.size(); }
209 0 : SwExtraRedline* GetRedline( sal_uInt16 uIndex ) const { return m_aExtraRedlines.operator[]( uIndex ); }
210 : bool IsEmpty() const { return m_aExtraRedlines.empty(); }
211 :
212 : bool DeleteAllTableRedlines( SwDoc* pDoc, const SwTable& rTable, bool bSaveInUndo, sal_uInt16 nRedlineTypeToDelete );
213 : bool DeleteTableRowRedline ( SwDoc* pDoc, const SwTableLine& rTableLine, bool bSaveInUndo, sal_uInt16 nRedlineTypeToDelete );
214 : bool DeleteTableCellRedline( SwDoc* pDoc, const SwTableBox& rTableBox, bool bSaveInUndo, sal_uInt16 nRedlineTypeToDelete );
215 : };
216 :
217 0 : class SwUnoCrsrTbl : public std::set<SwUnoCrsr*> {
218 : public:
219 : /// the destructor will free all objects still in the set
220 : ~SwUnoCrsrTbl();
221 : };
222 :
223 0 : class SwOLENodes : public std::vector<SwOLENode*> {};
224 :
225 : #endif // INCLUDED_SW_INC_DOCARY_HXX
226 :
227 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|