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 _DOCARY_HXX
20 : #define _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 SwRedline;
37 : class SwUnoCrsr;
38 : class SwOLENode;
39 : class SwTxtFmtColl;
40 : class SwGrfFmtColl;
41 :
42 : namespace com { namespace sun { namespace star { namespace i18n {
43 : struct ForbiddenCharacters; ///< comes from the I18N UNO interface
44 : }}}}
45 :
46 : #include <swtypes.hxx>
47 : #include <ndarr.hxx>
48 :
49 : /** provides some methods for generic operations on lists that contain
50 : SwFmt* subclasses. */
51 7310 : class SwFmtsBase
52 : {
53 : public:
54 : virtual size_t GetFmtCount() const = 0;
55 : virtual SwFmt* GetFmt(size_t idx) const = 0;
56 : virtual ~SwFmtsBase() = 0;
57 : };
58 :
59 898 : class SwGrfFmtColls : public std::vector<SwGrfFmtColl*>, public SwFmtsBase
60 : {
61 : public:
62 2 : virtual size_t GetFmtCount() const { return size(); }
63 4 : virtual SwFmt* GetFmt(size_t idx) const { return (SwFmt*)operator[](idx); }
64 : sal_uInt16 GetPos(const SwGrfFmtColl* pFmt) const;
65 : /// free's any remaining child objects
66 1790 : virtual ~SwGrfFmtColls() {}
67 : };
68 :
69 : /// stupid base class to work around MSVC dllexport mess
70 7427 : class SAL_DLLPUBLIC_TEMPLATE SwFrmFmts_Base : public std::vector<SwFrmFmt*> {};
71 :
72 : /// Specific frame formats (frames, DrawObjects).
73 3718 : class SW_DLLPUBLIC SwFrmFmts : public SwFrmFmts_Base, public SwFmtsBase
74 : {
75 : public:
76 11017 : virtual size_t GetFmtCount() const { return size(); }
77 8636 : virtual SwFmt* GetFmt(size_t idx) const { return (SwFmt*)operator[](idx); }
78 : sal_uInt16 GetPos(const SwFrmFmt* pFmt) const;
79 : bool Contains(const SwFrmFmt* pFmt) const;
80 : /// free's any remaining child objects
81 : virtual ~SwFrmFmts();
82 : };
83 :
84 898 : class SwCharFmts : public std::vector<SwCharFmt*>, public SwFmtsBase
85 : {
86 : public:
87 220317 : virtual size_t GetFmtCount() const { return size(); }
88 212264 : virtual SwFmt* GetFmt(size_t idx) const { return (SwFmt*)operator[](idx); }
89 : sal_uInt16 GetPos(const SwCharFmt* pFmt) const;
90 : bool Contains(const SwCharFmt* pFmt) const;
91 : /// free's any remaining child objects
92 : virtual ~SwCharFmts();
93 : };
94 :
95 898 : class SwTxtFmtColls : public std::vector<SwTxtFmtColl*>, public SwFmtsBase
96 : {
97 : public:
98 2228403 : virtual size_t GetFmtCount() const { return size(); }
99 2046486 : virtual SwFmt* GetFmt(size_t idx) const { return (SwFmt*)operator[](idx); }
100 : sal_uInt16 GetPos(const SwTxtFmtColl* pFmt) const;
101 1790 : virtual ~SwTxtFmtColls() {}
102 : };
103 :
104 : /// Array of Undo-history.
105 898 : class SW_DLLPUBLIC SwSectionFmts : public std::vector<SwSectionFmt*>, public SwFmtsBase
106 : {
107 : public:
108 0 : virtual size_t GetFmtCount() const { return size(); }
109 0 : virtual SwFmt* GetFmt(size_t idx) const { return (SwFmt*)operator[](idx); }
110 : sal_uInt16 GetPos(const SwSectionFmt* pFmt) const;
111 : bool Contains(const SwSectionFmt* pFmt) const;
112 : /// free's any remaining child objects
113 : virtual ~SwSectionFmts();
114 : };
115 :
116 898 : class SwFldTypes : public std::vector<SwFieldType*> {
117 : public:
118 : /// the destructor will free all objects still in the vector
119 : ~SwFldTypes();
120 : sal_uInt16 GetPos(const SwFieldType* pFieldType) const;
121 : void dumpAsXml(xmlTextWriterPtr w);
122 : };
123 :
124 898 : class SwTOXTypes : public std::vector<SwTOXType*> {
125 : public:
126 : /// the destructor will free all objects still in the vector
127 : ~SwTOXTypes();
128 : sal_uInt16 GetPos(const SwTOXType* pTOXType) const;
129 : };
130 :
131 952 : class SW_DLLPUBLIC SwNumRuleTbl : public std::vector<SwNumRule*> {
132 : public:
133 : /// the destructor will free all objects still in the vector
134 : ~SwNumRuleTbl();
135 : sal_uInt16 GetPos(const SwNumRule* pRule) const;
136 : };
137 :
138 : struct CompareSwRedlineTbl
139 : {
140 : bool operator()(SwRedline* const &lhs, SwRedline* const &rhs) const;
141 : };
142 898 : class _SwRedlineTbl
143 : : public o3tl::sorted_vector<SwRedline*, CompareSwRedlineTbl,
144 : o3tl::find_partialorder_ptrequals>
145 : {
146 : public:
147 : ~_SwRedlineTbl();
148 : };
149 :
150 1793 : class SwRedlineTbl : private _SwRedlineTbl
151 : {
152 : public:
153 0 : bool Contains(const SwRedline* p) const { return find(const_cast<SwRedline* const>(p)) != end(); }
154 : sal_uInt16 GetPos(const SwRedline* p) const;
155 :
156 : bool Insert( SwRedline* p, bool bIns = true );
157 : bool Insert( SwRedline* p, sal_uInt16& rInsPos, bool bIns = true );
158 : bool InsertWithValidRanges( SwRedline* p, sal_uInt16* pInsPos = 0 );
159 :
160 : void Remove( sal_uInt16 nPos );
161 : bool Remove( const SwRedline* p );
162 : void DeleteAndDestroy( sal_uInt16 nPos, sal_uInt16 nLen = 1 );
163 : void DeleteAndDestroyAll();
164 :
165 : /** Search next or previous Redline with the same Seq. No.
166 : Search can be restricted via Lookahaed.
167 : Using 0 or USHRT_MAX makes search the whole array. */
168 : sal_uInt16 FindNextOfSeqNo( sal_uInt16 nSttPos, sal_uInt16 nLookahead = 20 ) const;
169 : sal_uInt16 FindPrevOfSeqNo( sal_uInt16 nSttPos, sal_uInt16 nLookahead = 20 ) const;
170 : sal_uInt16 FindNextSeqNo( sal_uInt16 nSeqNo, sal_uInt16 nSttPos,
171 : sal_uInt16 nLookahead = 20 ) const;
172 : sal_uInt16 FindPrevSeqNo( sal_uInt16 nSeqNo, sal_uInt16 nSttPos,
173 : sal_uInt16 nLookahead = 20 ) const;
174 :
175 : using _SwRedlineTbl::size;
176 : using _SwRedlineTbl::operator[];
177 : using _SwRedlineTbl::empty;
178 : };
179 :
180 898 : class SwUnoCrsrTbl : public std::set<SwUnoCrsr*> {
181 : public:
182 : /// the destructor will free all objects still in the set
183 : ~SwUnoCrsrTbl();
184 : };
185 :
186 0 : class SwOLENodes : public std::vector<SwOLENode*> {};
187 :
188 :
189 : #endif //_DOCARY_HXX
190 :
191 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|