update dev300-m58
[ooovba.git] / sw / inc / IDocumentMarkAccess.hxx
blobe5a01122778e7969815a6680437f8c28cfcd7b87
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: IDocumentMarkAccess.hxx,v $
10 * $Revision: 1.4.42.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef IDOCUMENTMARKACCESS_HXX_INCLUDED
32 #define IDOCUMENTMARKACCESS_HXX_INCLUDED
34 #include <sal/types.h>
35 #include <IMark.hxx>
36 #include <boost/shared_ptr.hpp>
38 class SwPaM;
39 class KeyCode;
40 class String;
41 struct SwPosition;
42 class SwTxtNode;
44 namespace sw { namespace mark {
45 class SaveBookmark; // FIXME: Ugly: SaveBookmark is a core-internal class, and should not be used in the interface
48 /** Provides access to the marks of a document.
50 class IDocumentMarkAccess
52 public:
53 enum MarkType
55 UNO_BOOKMARK,
56 DDE_BOOKMARK,
57 BOOKMARK,
58 CROSSREF_HEADING_BOOKMARK,
59 CROSSREF_NUMITEM_BOOKMARK,
60 TEXT_FIELDMARK,
61 CHECKBOX_FIELDMARK,
62 NAVIGATOR_REMINDER
65 typedef ::boost::shared_ptr< ::sw::mark::IMark> pMark_t;
66 typedef ::std::vector< pMark_t > container_t;
67 typedef container_t::iterator iterator_t;
68 typedef container_t::const_iterator const_iterator_t;
69 typedef container_t::const_reverse_iterator const_reverse_iterator_t;
71 /** Generates a new mark in the document for a certain selection.
73 @param rPaM
74 [in] the selection being marked.
76 @param rProposedName
77 [in] the proposed name of the new mark.
79 @param eMark
80 [in] the type of the new mark.
82 @returns
83 a pointer to the new mark (name might have changed).
85 virtual ::sw::mark::IMark* makeMark(const SwPaM& rPaM,
86 const ::rtl::OUString& rProposedName,
87 MarkType eMark) =0;
89 virtual sw::mark::IMark* makeFieldBookmark( const SwPaM& rPaM,
90 const rtl::OUString& rName,
91 const rtl::OUString& rType) = 0;
92 virtual sw::mark::IMark* makeNoTextFieldBookmark( const SwPaM& rPaM,
93 const rtl::OUString& rName,
94 const rtl::OUString& rType) = 0;
96 /** Returns a mark in the document for a paragraph.
97 If there is none, a mark will be created.
99 @param rTxtNode
100 [in] the paragraph being marked (a selection over the paragraph is marked)
102 @param eMark
103 [in] the type of the new mark.
105 @returns
106 a pointer to the new mark (name might have changed).
108 virtual ::sw::mark::IMark* getMarkForTxtNode(const SwTxtNode& rTxtNode,
109 MarkType eMark) =0;
111 /** Moves an existing mark to a new selection and performs needed updates.
112 @param io_pMark
113 [in/out] the mark to be moved
115 @param rPaM
116 [in] new selection to be marked
119 virtual void repositionMark(::sw::mark::IMark* io_pMark,
120 const SwPaM& rPaM) =0;
122 /** Renames an existing Mark, if possible.
123 @param io_pMark
124 [in/out] the mark to be renamed
126 @param rNewName
127 [in] new name for the mark
129 @returns false, if renaming failed (because the name is already in use)
131 virtual bool renameMark(::sw::mark::IMark* io_pMark,
132 const ::rtl::OUString& rNewName) =0;
134 /** Corrects marks (absolute)
135 This method ignores the previous position of the mark in the paragraph
137 @param rOldNode
138 [in] the node from which nodes should be moved
140 @param rNewPos
141 [in] new position to which marks will be moved, if nOffset == 0
143 @param nOffset
144 [in] the offset by which the mark gets positioned of rNewPos
146 virtual void correctMarksAbsolute(const SwNodeIndex& rOldNode,
147 const SwPosition& rNewPos,
148 const xub_StrLen nOffset) =0;
150 /** Corrects marks (relative)
151 This method uses the previous position of the mark in the paragraph as offset
153 @param rOldNode
154 [in] the node from which nodes should be moved
156 @param rNewPos
157 [in] new position to which marks from the start of the paragraph will be
158 moved, if nOffset == 0
160 @param nOffset
161 [in] the offset by which the mark gets positioned of rNewPos in addition to
162 its old position in the paragraph
164 virtual void correctMarksRelative(const SwNodeIndex& rOldNode,
165 const SwPosition& rNewPos,
166 const xub_StrLen nOffset) =0;
168 /** Deletes marks in a range
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;
177 /** Deletes a mark.
179 @param ppMark
180 [in] an iterator pointing to the Mark to be deleted.
182 virtual void deleteMark(const IDocumentMarkAccess::const_iterator_t ppMark) =0;
184 /** Deletes a mark.
186 @param ppMark
187 [in] the name of the mark to be deleted.
189 virtual void deleteMark(const ::sw::mark::IMark* const pMark) =0;
191 /** Clear (deletes) all marks.
193 virtual void clearAllMarks() =0;
195 /** returns a STL-like random access iterator to the begin of the sequence of marks.
197 virtual const_iterator_t getMarksBegin() const =0;
199 /** returns a STL-like random access iterator to the end of the sequence of marks.
201 virtual const_iterator_t getMarksEnd() const =0;
203 /** returns the number of marks.
205 virtual sal_Int32 getMarksCount() const =0;
207 /** Finds a mark by name.
209 @param rName
210 [in] the name of the mark to find.
212 @returns
213 an iterator pointing to the mark, or pointing to getMarksEnd() if nothing was found.
215 virtual const_iterator_t findMark(const ::rtl::OUString& rMark) const =0;
218 // interface IBookmarks (BOOKMARK, CROSSREF_NUMITEM_BOOKMARK, CROSSREF_HEADING_BOOKMARK)
220 /** returns a STL-like random access iterator to the begin of the sequence the IBookmarks.
222 virtual const_iterator_t getBookmarksBegin() const =0;
224 /** returns a STL-like random access iterator to the end of the sequence of IBookmarks.
226 virtual const_iterator_t getBookmarksEnd() const =0;
228 /** returns the number of IBookmarks.
230 virtual sal_Int32 getBookmarksCount() const =0;
232 /** Finds a bookmark by name.
234 @param rName
235 [in] the name of the bookmark to find.
237 @returns
238 an iterator pointing to the bookmark, or getBookmarksEnd() if nothing was found.
240 virtual const_iterator_t findBookmark(const ::rtl::OUString& rMark) const =0;
243 // Fieldmarks
244 virtual ::sw::mark::IFieldmark* getFieldmarkFor(const SwPosition& pos) const =0;
245 virtual ::sw::mark::IFieldmark* getFieldmarkBefore(const SwPosition& pos) const =0;
246 virtual ::sw::mark::IFieldmark* getFieldmarkAfter(const SwPosition& pos) const =0;
248 // Returns the MarkType used to create the mark
249 static MarkType SAL_DLLPUBLIC_EXPORT GetType(const ::sw::mark::IMark& rMark);
250 protected:
251 virtual ~IDocumentMarkAccess() {};
254 #endif // IDOCUMENTBOOKMARKACCESS_HXX_INCLUDED