1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 INCLUDED_SW_INC_IDOCUMENTMARKACCESS_HXX
21 #define INCLUDED_SW_INC_IDOCUMENTMARKACCESS_HXX
23 #include <sal/types.h>
25 #include <boost/shared_ptr.hpp>
31 namespace sw
{ namespace mark
{
32 class SaveBookmark
; // FIXME: Ugly: SaveBookmark is a core-internal class, and should not be used in the interface
35 /** Provides access to the marks of a document.
37 class IDocumentMarkAccess
45 CROSSREF_HEADING_BOOKMARK
,
46 CROSSREF_NUMITEM_BOOKMARK
,
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
;
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 struct ILazyDeleter
{ virtual ~ILazyDeleter() { } };
64 /** Generates a new mark in the document for a certain selection.
67 [in] the selection being marked.
70 [in] the proposed name of the new mark.
73 [in] the type of the new mark.
76 a pointer to the new mark (name might have changed).
78 virtual ::sw::mark::IMark
* makeMark(const SwPaM
& rPaM
,
79 const OUString
& rProposedName
,
80 MarkType eMark
, bool = false) = 0;
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;
89 virtual sw::mark::IMark
* makeAnnotationMark(
91 const OUString
& rName
) = 0;
93 /** Returns a mark in the document for a paragraph.
94 If there is none, a mark will be created.
97 [in] the paragraph being marked (a selection over the paragraph is marked)
100 [in] the type of the new mark.
103 a pointer to the new mark (name might have changed).
105 virtual ::sw::mark::IMark
* getMarkForTextNode(const SwTextNode
& rTextNode
,
108 /** Moves an existing mark to a new selection and performs needed updates.
110 [in/out] the mark to be moved
113 [in] new selection to be marked
116 virtual void repositionMark(::sw::mark::IMark
* io_pMark
,
117 const SwPaM
& rPaM
) =0;
119 /** Renames an existing Mark, if possible.
121 [in/out] the mark to be renamed
124 [in] new name for the mark
126 @returns false, if renaming failed (because the name is already in use)
128 virtual bool renameMark(::sw::mark::IMark
* io_pMark
,
129 const OUString
& rNewName
) =0;
131 /** Corrects marks (absolute)
132 This method ignores the previous position of the mark in the paragraph
135 [in] the node from which nodes should be moved
138 [in] new position to which marks will be moved, if nOffset == 0
141 [in] the offset by which the mark gets positioned of rNewPos
143 virtual void correctMarksAbsolute(const SwNodeIndex
& rOldNode
,
144 const SwPosition
& rNewPos
,
145 const sal_Int32 nOffset
) =0;
147 /** Corrects marks (relative)
148 This method uses the previous position of the mark in the paragraph as offset
151 [in] the node from which nodes should be moved
154 [in] new position to which marks from the start of the paragraph will be
155 moved, if nOffset == 0
158 [in] the offset by which the mark gets positioned of rNewPos in addition to
159 its old position in the paragraph
161 virtual void correctMarksRelative(const SwNodeIndex
& rOldNode
,
162 const SwPosition
& rNewPos
,
163 const sal_Int32 nOffset
) =0;
165 /** Deletes marks in a range
167 Note: navigator reminders are excluded
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;
180 [in] an iterator pointing to the Mark to be deleted.
182 virtual ::boost::shared_ptr
<ILazyDeleter
>
183 deleteMark(const IDocumentMarkAccess::const_iterator_t
& ppMark
) =0;
188 [in] the name of the mark to be deleted.
190 virtual void deleteMark(const ::sw::mark::IMark
* const pMark
) =0;
192 /** Clear (deletes) all marks.
194 virtual void clearAllMarks() =0;
196 virtual void assureSortedMarkContainers() const = 0;
198 /** returns a STL-like random access iterator to the begin of the sequence of marks.
200 virtual const_iterator_t
getAllMarksBegin() const =0;
202 /** returns a STL-like random access iterator to the end of the sequence of marks.
204 virtual const_iterator_t
getAllMarksEnd() const =0;
206 /** returns the number of marks.
208 Note: annotation marks are excluded
210 virtual sal_Int32
getAllMarksCount() const =0;
212 /** Finds a mark by name.
215 [in] the name of the mark to find.
218 an iterator pointing to the mark, or pointing to getAllMarksEnd() if nothing was found.
220 virtual const_iterator_t
findMark(const OUString
& rMark
) const =0;
222 // interface IBookmarks (BOOKMARK, CROSSREF_NUMITEM_BOOKMARK, CROSSREF_HEADING_BOOKMARK )
224 /** returns a STL-like random access iterator to the begin of the sequence the IBookmarks.
226 virtual const_iterator_t
getBookmarksBegin() const =0;
228 /** returns a STL-like random access iterator to the end of the sequence of IBookmarks.
230 virtual const_iterator_t
getBookmarksEnd() const =0;
232 /** returns the number of IBookmarks.
234 virtual sal_Int32
getBookmarksCount() const =0;
236 /** Finds a bookmark by name.
239 [in] the name of the bookmark to find.
242 an iterator pointing to the bookmark, or getBookmarksEnd() if nothing was found.
244 virtual const_iterator_t
findBookmark(const OUString
& rMark
) const =0;
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;
251 virtual ::sw::mark::IFieldmark
* getDropDownFor(const SwPosition
& pos
) const=0;
252 virtual std::vector
< ::sw::mark::IFieldmark
* > getDropDownsFor(const SwPaM
&rPaM
) const=0;
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 OUString
& rName
) const = 0;
259 virtual sw::mark::IMark
* getAnnotationMarkFor(const SwPosition
& rPosition
) const = 0;
261 /** Returns the MarkType used to create the mark
263 static SW_DLLPUBLIC MarkType
GetType(const ::sw::mark::IMark
& rMark
);
265 static SW_DLLPUBLIC OUString
GetCrossRefHeadingBookmarkNamePrefix();
266 static SW_DLLPUBLIC
bool IsLegalPaMForCrossRefHeadingBookmark( const SwPaM
& rPaM
);
268 virtual ~IDocumentMarkAccess() {};
271 #endif // IDOCUMENTBOOKMARKACCESS_HXX_INCLUDED
273 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */