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 :
20 : #ifndef INCLUDED_SW_INC_IDOCUMENTMARKACCESS_HXX
21 : #define INCLUDED_SW_INC_IDOCUMENTMARKACCESS_HXX
22 :
23 : #include <sal/types.h>
24 : #include <IMark.hxx>
25 : #include <boost/shared_ptr.hpp>
26 :
27 : class SwPaM;
28 : struct SwPosition;
29 : class SwTxtNode;
30 :
31 : namespace sw { namespace mark {
32 : class SaveBookmark; // FIXME: Ugly: SaveBookmark is a core-internal class, and should not be used in the interface
33 : }}
34 :
35 : /** Provides access to the marks of a document.
36 : */
37 5052 : class IDocumentMarkAccess
38 : {
39 : public:
40 : enum MarkType
41 : {
42 : UNO_BOOKMARK,
43 : DDE_BOOKMARK,
44 : BOOKMARK,
45 : CROSSREF_HEADING_BOOKMARK,
46 : CROSSREF_NUMITEM_BOOKMARK,
47 : ANNOTATIONMARK,
48 : TEXT_FIELDMARK,
49 : CHECKBOX_FIELDMARK,
50 : NAVIGATOR_REMINDER
51 : };
52 :
53 : typedef ::boost::shared_ptr< ::sw::mark::IMark> pMark_t;
54 : typedef ::std::vector< pMark_t > container_t;
55 : typedef container_t::iterator iterator_t;
56 : typedef container_t::const_iterator const_iterator_t;
57 : typedef container_t::const_reverse_iterator const_reverse_iterator_t;
58 :
59 : /// To avoid recursive calls of deleteMark, the removal of dummy
60 : /// characters of fieldmarks has to be delayed; this is the baseclass
61 : /// that can be subclassed for that purpose.
62 0 : struct ILazyDeleter { virtual ~ILazyDeleter() { } };
63 :
64 : /** Generates a new mark in the document for a certain selection.
65 :
66 : @param rPaM
67 : [in] the selection being marked.
68 :
69 : @param rProposedName
70 : [in] the proposed name of the new mark.
71 :
72 : @param eMark
73 : [in] the type of the new mark.
74 :
75 : @returns
76 : a pointer to the new mark (name might have changed).
77 : */
78 : virtual ::sw::mark::IMark* makeMark(const SwPaM& rPaM,
79 : const OUString& rProposedName,
80 : MarkType eMark) =0;
81 :
82 : virtual sw::mark::IFieldmark* makeFieldBookmark( const SwPaM& rPaM,
83 : const OUString& rName,
84 : const OUString& rType) = 0;
85 : virtual sw::mark::IFieldmark* makeNoTextFieldBookmark( const SwPaM& rPaM,
86 : const OUString& rName,
87 : const OUString& rType) = 0;
88 :
89 : virtual sw::mark::IMark* makeAnnotationMark(
90 : const SwPaM& rPaM,
91 : const ::rtl::OUString& rName ) = 0;
92 :
93 : /** Returns a mark in the document for a paragraph.
94 : If there is none, a mark will be created.
95 :
96 : @param rTxtNode
97 : [in] the paragraph being marked (a selection over the paragraph is marked)
98 :
99 : @param eMark
100 : [in] the type of the new mark.
101 :
102 : @returns
103 : a pointer to the new mark (name might have changed).
104 : */
105 : virtual ::sw::mark::IMark* getMarkForTxtNode(const SwTxtNode& rTxtNode,
106 : MarkType eMark) =0;
107 :
108 : /** Moves an existing mark to a new selection and performs needed updates.
109 : @param io_pMark
110 : [in/out] the mark to be moved
111 :
112 : @param rPaM
113 : [in] new selection to be marked
114 : */
115 :
116 : virtual void repositionMark(::sw::mark::IMark* io_pMark,
117 : const SwPaM& rPaM) =0;
118 :
119 : /** Renames an existing Mark, if possible.
120 : @param io_pMark
121 : [in/out] the mark to be renamed
122 :
123 : @param rNewName
124 : [in] new name for the mark
125 :
126 : @returns false, if renaming failed (because the name is already in use)
127 : */
128 : virtual bool renameMark(::sw::mark::IMark* io_pMark,
129 : const OUString& rNewName) =0;
130 :
131 : /** Corrects marks (absolute)
132 : This method ignores the previous position of the mark in the paragraph
133 :
134 : @param rOldNode
135 : [in] the node from which nodes should be moved
136 :
137 : @param rNewPos
138 : [in] new position to which marks will be moved, if nOffset == 0
139 :
140 : @param nOffset
141 : [in] the offset by which the mark gets positioned of rNewPos
142 : */
143 : virtual void correctMarksAbsolute(const SwNodeIndex& rOldNode,
144 : const SwPosition& rNewPos,
145 : const sal_Int32 nOffset) =0;
146 :
147 : /** Corrects marks (relative)
148 : This method uses the previous position of the mark in the paragraph as offset
149 :
150 : @param rOldNode
151 : [in] the node from which nodes should be moved
152 :
153 : @param rNewPos
154 : [in] new position to which marks from the start of the paragraph will be
155 : moved, if nOffset == 0
156 :
157 : @param nOffset
158 : [in] the offset by which the mark gets positioned of rNewPos in addition to
159 : its old position in the paragraph
160 : */
161 : virtual void correctMarksRelative(const SwNodeIndex& rOldNode,
162 : const SwPosition& rNewPos,
163 : const sal_Int32 nOffset) =0;
164 :
165 : /** Deletes marks in a range
166 :
167 : Note: navigator reminders are excluded
168 :
169 : */
170 : virtual void deleteMarks(
171 : const SwNodeIndex& rStt,
172 : const SwNodeIndex& rEnd,
173 : ::std::vector< ::sw::mark::SaveBookmark>* pSaveBkmk, // Ugly: SaveBookmark is core-internal
174 : const SwIndex* pSttIdx,
175 : const SwIndex* pEndIdx) =0;
176 :
177 : /** Deletes a mark.
178 :
179 : @param ppMark
180 : [in] an iterator pointing to the Mark to be deleted.
181 : */
182 : virtual ::boost::shared_ptr<ILazyDeleter>
183 : deleteMark(const IDocumentMarkAccess::const_iterator_t ppMark) =0;
184 :
185 : /** Deletes a mark.
186 :
187 : @param ppMark
188 : [in] the name of the mark to be deleted.
189 : */
190 : virtual void deleteMark(const ::sw::mark::IMark* const pMark) =0;
191 :
192 : /** Clear (deletes) all marks.
193 : */
194 : virtual void clearAllMarks() =0;
195 :
196 : virtual void assureSortedMarkContainers() const = 0;
197 :
198 : /** returns a STL-like random access iterator to the begin of the sequence of marks.
199 : */
200 : virtual const_iterator_t getAllMarksBegin() const =0;
201 :
202 : /** returns a STL-like random access iterator to the end of the sequence of marks.
203 : */
204 : virtual const_iterator_t getAllMarksEnd() const =0;
205 :
206 : /** returns the number of marks.
207 :
208 : Note: annotation marks are excluded
209 : */
210 : virtual sal_Int32 getAllMarksCount() const =0;
211 :
212 : /** Finds a mark by name.
213 :
214 : @param rName
215 : [in] the name of the mark to find.
216 :
217 : @returns
218 : an iterator pointing to the mark, or pointing to getAllMarksEnd() if nothing was found.
219 : */
220 : virtual const_iterator_t findMark(const OUString& rMark) const =0;
221 :
222 : // interface IBookmarks (BOOKMARK, CROSSREF_NUMITEM_BOOKMARK, CROSSREF_HEADING_BOOKMARK )
223 :
224 : /** returns a STL-like random access iterator to the begin of the sequence the IBookmarks.
225 : */
226 : virtual const_iterator_t getBookmarksBegin() const =0;
227 :
228 : /** returns a STL-like random access iterator to the end of the sequence of IBookmarks.
229 : */
230 : virtual const_iterator_t getBookmarksEnd() const =0;
231 :
232 : /** returns the number of IBookmarks.
233 : */
234 : virtual sal_Int32 getBookmarksCount() const =0;
235 :
236 : /** Finds a bookmark by name.
237 :
238 : @param rName
239 : [in] the name of the bookmark to find.
240 :
241 : @returns
242 : an iterator pointing to the bookmark, or getBookmarksEnd() if nothing was found.
243 : */
244 : virtual const_iterator_t findBookmark(const OUString& rMark) const =0;
245 :
246 : // Fieldmarks
247 : virtual ::sw::mark::IFieldmark* getFieldmarkFor(const SwPosition& pos) const =0;
248 : virtual ::sw::mark::IFieldmark* getFieldmarkBefore(const SwPosition& pos) const =0;
249 : virtual ::sw::mark::IFieldmark* getFieldmarkAfter(const SwPosition& pos) const =0;
250 :
251 : virtual ::sw::mark::IFieldmark* getDropDownFor(const SwPosition& pos) const=0;
252 : virtual std::vector< ::sw::mark::IFieldmark* > getDropDownsFor(const SwPaM &rPaM) const=0;
253 :
254 : // Annotation Marks
255 : virtual const_iterator_t getAnnotationMarksBegin() const = 0;
256 : virtual const_iterator_t getAnnotationMarksEnd() const = 0;
257 : virtual sal_Int32 getAnnotationMarksCount() const = 0;
258 : virtual const_iterator_t findAnnotationMark( const ::rtl::OUString& rName ) const = 0;
259 : virtual sw::mark::IMark* getAnnotationMarkFor(const SwPosition& rPosition) const = 0;
260 :
261 : /** Returns the MarkType used to create the mark
262 : */
263 : static SW_DLLPUBLIC MarkType GetType(const ::sw::mark::IMark& rMark);
264 :
265 : static SW_DLLPUBLIC OUString GetCrossRefHeadingBookmarkNamePrefix();
266 : static SW_DLLPUBLIC bool IsLegalPaMForCrossRefHeadingBookmark( const SwPaM& rPaM );
267 : protected:
268 5045 : virtual ~IDocumentMarkAccess() {};
269 : };
270 :
271 : #endif // IDOCUMENTBOOKMARKACCESS_HXX_INCLUDED
272 :
273 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|