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 IDOCUMENTMARKACCESS_HXX_INCLUDED
21 #define IDOCUMENTMARKACCESS_HXX_INCLUDED
23 #include <sal/types.h>
25 #include <boost/shared_ptr.hpp>
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
47 CROSSREF_HEADING_BOOKMARK
,
48 CROSSREF_NUMITEM_BOOKMARK
,
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.
68 [in] the selection being marked.
71 [in] the proposed name of the new mark.
74 [in] the type of the new mark.
77 a pointer to the new mark (name might have changed).
79 virtual ::sw::mark::IMark
* makeMark(const SwPaM
& rPaM
,
80 const OUString
& rProposedName
,
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.
94 [in] the paragraph being marked (a selection over the paragraph is marked)
97 [in] the type of the new mark.
100 a pointer to the new mark (name might have changed).
102 virtual ::sw::mark::IMark
* getMarkForTxtNode(const SwTxtNode
& rTxtNode
,
105 /** Moves an existing mark to a new selection and performs needed updates.
107 [in/out] the mark to be moved
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.
118 [in/out] the mark to be renamed
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
132 [in] the node from which nodes should be moved
135 [in] new position to which marks will be moved, if nOffset == 0
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
148 [in] the node from which nodes should be moved
151 [in] new position to which marks from the start of the paragraph will be
152 moved, if nOffset == 0
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;
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;
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.
205 [in] the name of the mark to find.
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.
230 [in] the name of the bookmark to find.
233 an iterator pointing to the bookmark, or getBookmarksEnd() if nothing was found.
235 virtual const_iterator_t
findBookmark(const OUString
& rMark
) const =0;
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
);
247 virtual ~IDocumentMarkAccess() {};
250 #endif // IDOCUMENTBOOKMARKACCESS_HXX_INCLUDED
252 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */