bump product version to 4.1.6.2
[LibreOffice.git] / sw / inc / IDocumentMarkAccess.hxx
bloba01915479cc0833096a732d7e3ca6d6e350dab1c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef IDOCUMENTMARKACCESS_HXX_INCLUDED
21 #define IDOCUMENTMARKACCESS_HXX_INCLUDED
23 #include <sal/types.h>
24 #include <IMark.hxx>
25 #include <boost/shared_ptr.hpp>
27 class SwPaM;
28 class KeyCode;
29 class String;
30 struct SwPosition;
31 class SwTxtNode;
33 namespace sw { namespace mark {
34 class SaveBookmark; // FIXME: Ugly: SaveBookmark is a core-internal class, and should not be used in the interface
37 /** Provides access to the marks of a document.
39 class IDocumentMarkAccess
41 public:
42 enum MarkType
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
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;
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 struct ILazyDeleter { virtual ~ILazyDeleter() { } };
65 /** Generates a new mark in the document for a certain selection.
67 @param rPaM
68 [in] the selection being marked.
70 @param rProposedName
71 [in] the proposed name of the new mark.
73 @param eMark
74 [in] the type of the new mark.
76 @returns
77 a pointer to the new mark (name might have changed).
79 virtual ::sw::mark::IMark* makeMark(const SwPaM& rPaM,
80 const OUString& rProposedName,
81 MarkType eMark) =0;
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;
90 /** Returns a mark in the document for a paragraph.
91 If there is none, a mark will be created.
93 @param rTxtNode
94 [in] the paragraph being marked (a selection over the paragraph is marked)
96 @param eMark
97 [in] the type of the new mark.
99 @returns
100 a pointer to the new mark (name might have changed).
102 virtual ::sw::mark::IMark* getMarkForTxtNode(const SwTxtNode& rTxtNode,
103 MarkType eMark) =0;
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
109 @param rPaM
110 [in] new selection to be marked
113 virtual void repositionMark(::sw::mark::IMark* io_pMark,
114 const SwPaM& rPaM) =0;
116 /** Renames an existing Mark, if possible.
117 @param io_pMark
118 [in/out] the mark to be renamed
120 @param rNewName
121 [in] new name for the mark
123 @returns false, if renaming failed (because the name is already in use)
125 virtual bool renameMark(::sw::mark::IMark* io_pMark,
126 const OUString& rNewName) =0;
128 /** Corrects marks (absolute)
129 This method ignores the previous position of the mark in the paragraph
131 @param rOldNode
132 [in] the node from which nodes should be moved
134 @param rNewPos
135 [in] new position to which marks will be moved, if nOffset == 0
137 @param nOffset
138 [in] the offset by which the mark gets positioned of rNewPos
140 virtual void correctMarksAbsolute(const SwNodeIndex& rOldNode,
141 const SwPosition& rNewPos,
142 const xub_StrLen nOffset) =0;
144 /** Corrects marks (relative)
145 This method uses the previous position of the mark in the paragraph as offset
147 @param rOldNode
148 [in] the node from which nodes should be moved
150 @param rNewPos
151 [in] new position to which marks from the start of the paragraph will be
152 moved, if nOffset == 0
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
158 virtual void correctMarksRelative(const SwNodeIndex& rOldNode,
159 const SwPosition& rNewPos,
160 const xub_StrLen nOffset) =0;
162 /** Deletes marks in a range
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;
171 /** Deletes a mark.
173 @param ppMark
174 [in] an iterator pointing to the Mark to be deleted.
176 virtual ::boost::shared_ptr<ILazyDeleter>
177 deleteMark(const IDocumentMarkAccess::const_iterator_t ppMark) =0;
179 /** Deletes a mark.
181 @param ppMark
182 [in] the name of the mark to be deleted.
184 virtual void deleteMark(const ::sw::mark::IMark* const pMark) =0;
186 /** Clear (deletes) all marks.
188 virtual void clearAllMarks() =0;
190 /** returns a STL-like random access iterator to the begin of the sequence of marks.
192 virtual const_iterator_t getMarksBegin() const =0;
194 /** returns a STL-like random access iterator to the end of the sequence of marks.
196 virtual const_iterator_t getMarksEnd() const =0;
198 /** returns the number of marks.
200 virtual sal_Int32 getMarksCount() const =0;
202 /** Finds a mark by name.
204 @param rName
205 [in] the name of the mark to find.
207 @returns
208 an iterator pointing to the mark, or pointing to getMarksEnd() if nothing was found.
210 virtual const_iterator_t findMark(const OUString& rMark) const =0;
213 // interface IBookmarks (BOOKMARK, CROSSREF_NUMITEM_BOOKMARK, CROSSREF_HEADING_BOOKMARK)
215 /** returns a STL-like random access iterator to the begin of the sequence the IBookmarks.
217 virtual const_iterator_t getBookmarksBegin() const =0;
219 /** returns a STL-like random access iterator to the end of the sequence of IBookmarks.
221 virtual const_iterator_t getBookmarksEnd() const =0;
223 /** returns the number of IBookmarks.
225 virtual sal_Int32 getBookmarksCount() const =0;
227 /** Finds a bookmark by name.
229 @param rName
230 [in] the name of the bookmark to find.
232 @returns
233 an iterator pointing to the bookmark, or getBookmarksEnd() if nothing was found.
235 virtual const_iterator_t findBookmark(const OUString& rMark) const =0;
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;
243 /** Returns the MarkType used to create the mark
245 static MarkType SAL_DLLPUBLIC_EXPORT GetType(const ::sw::mark::IMark& rMark);
246 protected:
247 virtual ~IDocumentMarkAccess() {};
250 #endif // IDOCUMENTBOOKMARKACCESS_HXX_INCLUDED
252 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */