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