xref: /aoo41x/main/sw/inc/IDocumentMarkAccess.hxx (revision 12ad4c42)
11d2dbeb0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
31d2dbeb0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
41d2dbeb0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
51d2dbeb0SAndrew Rist  * distributed with this work for additional information
61d2dbeb0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
71d2dbeb0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
81d2dbeb0SAndrew Rist  * "License"); you may not use this file except in compliance
91d2dbeb0SAndrew Rist  * with the License.  You may obtain a copy of the License at
101d2dbeb0SAndrew Rist  *
111d2dbeb0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
121d2dbeb0SAndrew Rist  *
131d2dbeb0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
141d2dbeb0SAndrew Rist  * software distributed under the License is distributed on an
151d2dbeb0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
161d2dbeb0SAndrew Rist  * KIND, either express or implied.  See the License for the
171d2dbeb0SAndrew Rist  * specific language governing permissions and limitations
181d2dbeb0SAndrew Rist  * under the License.
191d2dbeb0SAndrew Rist  *
201d2dbeb0SAndrew Rist  *************************************************************/
211d2dbeb0SAndrew Rist 
221d2dbeb0SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef IDOCUMENTMARKACCESS_HXX_INCLUDED
25cdf0e10cSrcweir #define IDOCUMENTMARKACCESS_HXX_INCLUDED
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <sal/types.h>
28cdf0e10cSrcweir #include <IMark.hxx>
29cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir class SwPaM;
32cdf0e10cSrcweir class KeyCode;
33cdf0e10cSrcweir class String;
34cdf0e10cSrcweir struct SwPosition;
35cdf0e10cSrcweir class SwTxtNode;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir namespace sw { namespace mark {
38cdf0e10cSrcweir     class SaveBookmark; // FIXME: Ugly: SaveBookmark is a core-internal class, and should not be used in the interface
39cdf0e10cSrcweir }}
40cdf0e10cSrcweir 
41cdf0e10cSrcweir /** Provides access to the marks of a document.
42cdf0e10cSrcweir */
43cdf0e10cSrcweir class IDocumentMarkAccess
44cdf0e10cSrcweir {
45cdf0e10cSrcweir     public:
46cdf0e10cSrcweir         enum MarkType
47cdf0e10cSrcweir         {
48cdf0e10cSrcweir             UNO_BOOKMARK,
49cdf0e10cSrcweir             DDE_BOOKMARK,
50cdf0e10cSrcweir             BOOKMARK,
51cdf0e10cSrcweir             CROSSREF_HEADING_BOOKMARK,
52cdf0e10cSrcweir             CROSSREF_NUMITEM_BOOKMARK,
53dec99bbdSOliver-Rainer Wittmann             ANNOTATIONMARK,
54cdf0e10cSrcweir             TEXT_FIELDMARK,
55cdf0e10cSrcweir             CHECKBOX_FIELDMARK,
56cdf0e10cSrcweir             NAVIGATOR_REMINDER
57cdf0e10cSrcweir         };
58cdf0e10cSrcweir 
59cdf0e10cSrcweir         typedef ::boost::shared_ptr< ::sw::mark::IMark> pMark_t;
60cdf0e10cSrcweir         typedef ::std::vector< pMark_t > container_t;
61cdf0e10cSrcweir         typedef container_t::iterator iterator_t;
62cdf0e10cSrcweir         typedef container_t::const_iterator const_iterator_t;
63cdf0e10cSrcweir         typedef container_t::const_reverse_iterator const_reverse_iterator_t;
64cdf0e10cSrcweir 
65cdf0e10cSrcweir         /** Generates a new mark in the document for a certain selection.
66cdf0e10cSrcweir 
67cdf0e10cSrcweir            @param rPaM
68cdf0e10cSrcweir            [in] the selection being marked.
69cdf0e10cSrcweir 
70cdf0e10cSrcweir            @param rProposedName
71cdf0e10cSrcweir            [in] the proposed name of the new mark.
72cdf0e10cSrcweir 
73cdf0e10cSrcweir            @param eMark
74cdf0e10cSrcweir            [in] the type of the new mark.
75cdf0e10cSrcweir 
76cdf0e10cSrcweir            @returns
77cdf0e10cSrcweir            a pointer to the new mark (name might have changed).
78cdf0e10cSrcweir         */
79cdf0e10cSrcweir         virtual ::sw::mark::IMark* makeMark(const SwPaM& rPaM,
80cdf0e10cSrcweir             const ::rtl::OUString& rProposedName,
81cdf0e10cSrcweir             MarkType eMark) =0;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir         virtual sw::mark::IFieldmark* makeFieldBookmark( const SwPaM& rPaM,
84cdf0e10cSrcweir             const rtl::OUString& rName,
85cdf0e10cSrcweir             const rtl::OUString& rType) = 0;
86cdf0e10cSrcweir         virtual sw::mark::IFieldmark* makeNoTextFieldBookmark( const SwPaM& rPaM,
87cdf0e10cSrcweir             const rtl::OUString& rName,
88cdf0e10cSrcweir             const rtl::OUString& rType) = 0;
89cdf0e10cSrcweir 
90dec99bbdSOliver-Rainer Wittmann         virtual sw::mark::IMark* makeAnnotationMark(
91dec99bbdSOliver-Rainer Wittmann             const SwPaM& rPaM,
92dec99bbdSOliver-Rainer Wittmann             const ::rtl::OUString& rName ) = 0;
93dec99bbdSOliver-Rainer Wittmann 
94cdf0e10cSrcweir         /** Returns a mark in the document for a paragraph.
95cdf0e10cSrcweir             If there is none, a mark will be created.
96cdf0e10cSrcweir 
97cdf0e10cSrcweir            @param rTxtNode
98cdf0e10cSrcweir            [in] the paragraph being marked (a selection over the paragraph is marked)
99cdf0e10cSrcweir 
100cdf0e10cSrcweir            @param eMark
101cdf0e10cSrcweir            [in] the type of the new mark.
102cdf0e10cSrcweir 
103cdf0e10cSrcweir            @returns
104cdf0e10cSrcweir            a pointer to the new mark (name might have changed).
105cdf0e10cSrcweir         */
106cdf0e10cSrcweir         virtual ::sw::mark::IMark* getMarkForTxtNode(const SwTxtNode& rTxtNode,
107cdf0e10cSrcweir             MarkType eMark) =0;
108cdf0e10cSrcweir 
109cdf0e10cSrcweir         /** Moves an existing mark to a new selection and performs needed updates.
110cdf0e10cSrcweir             @param io_pMark
111cdf0e10cSrcweir             [in/out] the mark to be moved
112cdf0e10cSrcweir 
113cdf0e10cSrcweir             @param rPaM
114cdf0e10cSrcweir             [in] new selection to be marked
115cdf0e10cSrcweir         */
116cdf0e10cSrcweir 
117cdf0e10cSrcweir         virtual void repositionMark(::sw::mark::IMark* io_pMark,
118cdf0e10cSrcweir             const SwPaM& rPaM) =0;
119cdf0e10cSrcweir 
120cdf0e10cSrcweir         /** Renames an existing Mark, if possible.
121cdf0e10cSrcweir             @param io_pMark
122cdf0e10cSrcweir             [in/out] the mark to be renamed
123cdf0e10cSrcweir 
124cdf0e10cSrcweir             @param rNewName
125cdf0e10cSrcweir             [in] new name for the mark
126cdf0e10cSrcweir 
127cdf0e10cSrcweir             @returns false, if renaming failed (because the name is already in use)
128cdf0e10cSrcweir         */
129cdf0e10cSrcweir             virtual bool renameMark(::sw::mark::IMark* io_pMark,
130cdf0e10cSrcweir                 const ::rtl::OUString& rNewName) =0;
131cdf0e10cSrcweir 
132cdf0e10cSrcweir         /** Corrects marks (absolute)
133cdf0e10cSrcweir             This method ignores the previous position of the mark in the paragraph
134cdf0e10cSrcweir 
135cdf0e10cSrcweir             @param rOldNode
136cdf0e10cSrcweir             [in] the node from which nodes should be moved
137cdf0e10cSrcweir 
138cdf0e10cSrcweir             @param rNewPos
139cdf0e10cSrcweir             [in] new position to which marks will be moved, if nOffset == 0
140cdf0e10cSrcweir 
141cdf0e10cSrcweir             @param nOffset
142cdf0e10cSrcweir             [in] the offset by which the mark gets positioned of rNewPos
143cdf0e10cSrcweir         */
144cdf0e10cSrcweir         virtual void correctMarksAbsolute(const SwNodeIndex& rOldNode,
145cdf0e10cSrcweir             const SwPosition& rNewPos,
146cdf0e10cSrcweir             const xub_StrLen nOffset) =0;
147cdf0e10cSrcweir 
148cdf0e10cSrcweir         /** Corrects marks (relative)
149cdf0e10cSrcweir             This method uses the previous position of the mark in the paragraph as offset
150cdf0e10cSrcweir 
151cdf0e10cSrcweir             @param rOldNode
152cdf0e10cSrcweir             [in] the node from which nodes should be moved
153cdf0e10cSrcweir 
154cdf0e10cSrcweir             @param rNewPos
155cdf0e10cSrcweir             [in] new position to which marks from the start of the paragraph will be
156cdf0e10cSrcweir                  moved, if nOffset == 0
157cdf0e10cSrcweir 
158cdf0e10cSrcweir             @param nOffset
159cdf0e10cSrcweir             [in] the offset by which the mark gets positioned of rNewPos in addition to
160cdf0e10cSrcweir                  its old position in the paragraph
161cdf0e10cSrcweir         */
162cdf0e10cSrcweir         virtual void correctMarksRelative(const SwNodeIndex& rOldNode,
163cdf0e10cSrcweir             const SwPosition& rNewPos,
164cdf0e10cSrcweir             const xub_StrLen nOffset) =0;
165cdf0e10cSrcweir 
166cdf0e10cSrcweir         /** Deletes marks in a range
167dec99bbdSOliver-Rainer Wittmann 
168dec99bbdSOliver-Rainer Wittmann             Note: navigator reminders are excluded
169dec99bbdSOliver-Rainer Wittmann 
170cdf0e10cSrcweir         */
171cdf0e10cSrcweir         virtual void deleteMarks(
172cdf0e10cSrcweir             const SwNodeIndex& rStt,
173cdf0e10cSrcweir             const SwNodeIndex& rEnd,
174cdf0e10cSrcweir             ::std::vector< ::sw::mark::SaveBookmark>* pSaveBkmk, // Ugly: SaveBookmark is core-internal
175cdf0e10cSrcweir             const SwIndex* pSttIdx,
176cdf0e10cSrcweir             const SwIndex* pEndIdx) =0;
177cdf0e10cSrcweir 
178cdf0e10cSrcweir         /** Deletes a mark.
179cdf0e10cSrcweir 
180cdf0e10cSrcweir             @param ppMark
181cdf0e10cSrcweir             [in] an iterator pointing to the Mark to be deleted.
182cdf0e10cSrcweir         */
183cdf0e10cSrcweir         virtual void deleteMark(const IDocumentMarkAccess::const_iterator_t ppMark) =0;
184cdf0e10cSrcweir 
185cdf0e10cSrcweir         /** Deletes a mark.
186cdf0e10cSrcweir 
187cdf0e10cSrcweir             @param ppMark
188cdf0e10cSrcweir             [in] the name of the mark to be deleted.
189cdf0e10cSrcweir         */
190cdf0e10cSrcweir         virtual void deleteMark(const ::sw::mark::IMark* const pMark) =0;
191cdf0e10cSrcweir 
192cdf0e10cSrcweir         /** Clear (deletes) all marks.
193cdf0e10cSrcweir         */
194cdf0e10cSrcweir         virtual void clearAllMarks() =0;
195cdf0e10cSrcweir 
196*5b9fe260SOliver-Rainer Wittmann         virtual void assureSortedMarkContainers() const = 0;
197*5b9fe260SOliver-Rainer Wittmann 
198cdf0e10cSrcweir         /** returns a STL-like random access iterator to the begin of the sequence of marks.
199cdf0e10cSrcweir         */
200dec99bbdSOliver-Rainer Wittmann         virtual const_iterator_t getAllMarksBegin() const =0;
201cdf0e10cSrcweir 
202cdf0e10cSrcweir         /** returns a STL-like random access iterator to the end of the sequence of marks.
203cdf0e10cSrcweir         */
204dec99bbdSOliver-Rainer Wittmann         virtual const_iterator_t getAllMarksEnd() const =0;
205cdf0e10cSrcweir 
206cdf0e10cSrcweir         /** returns the number of marks.
207dec99bbdSOliver-Rainer Wittmann 
208dec99bbdSOliver-Rainer Wittmann             Note: annotation marks are excluded
209cdf0e10cSrcweir         */
210dec99bbdSOliver-Rainer Wittmann         virtual sal_Int32 getAllMarksCount() const =0;
211cdf0e10cSrcweir 
212cdf0e10cSrcweir         /** Finds a mark by name.
213cdf0e10cSrcweir 
214cdf0e10cSrcweir             @param rName
215cdf0e10cSrcweir             [in] the name of the mark to find.
216cdf0e10cSrcweir 
217cdf0e10cSrcweir             @returns
218dec99bbdSOliver-Rainer Wittmann             an iterator pointing to the mark, or pointing to getAllMarksEnd() if nothing was found.
219cdf0e10cSrcweir         */
220cdf0e10cSrcweir         virtual const_iterator_t findMark(const ::rtl::OUString& rMark) const =0;
221cdf0e10cSrcweir 
222cdf0e10cSrcweir 
223dec99bbdSOliver-Rainer Wittmann         // interface IBookmarks (BOOKMARK, CROSSREF_NUMITEM_BOOKMARK, CROSSREF_HEADING_BOOKMARK )
224cdf0e10cSrcweir 
225cdf0e10cSrcweir         /** returns a STL-like random access iterator to the begin of the sequence the IBookmarks.
226cdf0e10cSrcweir         */
227cdf0e10cSrcweir         virtual const_iterator_t getBookmarksBegin() const =0;
228cdf0e10cSrcweir 
229cdf0e10cSrcweir         /** returns a STL-like random access iterator to the end of the sequence of IBookmarks.
230cdf0e10cSrcweir         */
231cdf0e10cSrcweir         virtual const_iterator_t getBookmarksEnd() const =0;
232cdf0e10cSrcweir 
233cdf0e10cSrcweir         /** returns the number of IBookmarks.
234cdf0e10cSrcweir         */
235cdf0e10cSrcweir         virtual sal_Int32 getBookmarksCount() const =0;
236cdf0e10cSrcweir 
237cdf0e10cSrcweir         /** Finds a bookmark by name.
238cdf0e10cSrcweir 
239cdf0e10cSrcweir             @param rName
240cdf0e10cSrcweir             [in] the name of the bookmark to find.
241cdf0e10cSrcweir 
242cdf0e10cSrcweir             @returns
243cdf0e10cSrcweir             an iterator pointing to the bookmark, or getBookmarksEnd() if nothing was found.
244cdf0e10cSrcweir         */
245cdf0e10cSrcweir         virtual const_iterator_t findBookmark(const ::rtl::OUString& rMark) const =0;
246cdf0e10cSrcweir 
247cdf0e10cSrcweir 
248cdf0e10cSrcweir         // Fieldmarks
249cdf0e10cSrcweir         virtual ::sw::mark::IFieldmark* getFieldmarkFor(const SwPosition& pos) const =0;
250cdf0e10cSrcweir         virtual ::sw::mark::IFieldmark* getFieldmarkBefore(const SwPosition& pos) const =0;
251cdf0e10cSrcweir         virtual ::sw::mark::IFieldmark* getFieldmarkAfter(const SwPosition& pos) const =0;
252cdf0e10cSrcweir 
253dec99bbdSOliver-Rainer Wittmann         // Annotation Marks
254dec99bbdSOliver-Rainer Wittmann         virtual const_iterator_t getAnnotationMarksBegin() const = 0;
255dec99bbdSOliver-Rainer Wittmann         virtual const_iterator_t getAnnotationMarksEnd() const = 0;
256dec99bbdSOliver-Rainer Wittmann         virtual sal_Int32 getAnnotationMarksCount() const = 0;
257dec99bbdSOliver-Rainer Wittmann         virtual const_iterator_t findAnnotationMark( const ::rtl::OUString& rName ) const = 0;
258dec99bbdSOliver-Rainer Wittmann 
259cdf0e10cSrcweir         // Returns the MarkType used to create the mark
260332f371aSOliver-Rainer Wittmann         static SAL_DLLPUBLIC_EXPORT MarkType GetType(const ::sw::mark::IMark& rMark);
2613078b051SOliver-Rainer Wittmann 
2624409ef06SHerbert Dürr         static SAL_DLLPUBLIC_EXPORT const ::rtl::OUString& GetCrossRefHeadingBookmarkNamePrefix();
2634409ef06SHerbert Dürr         static SAL_DLLPUBLIC_EXPORT bool IsLegalPaMForCrossRefHeadingBookmark( const SwPaM& );
264cdf0e10cSrcweir     protected:
~IDocumentMarkAccess()265cdf0e10cSrcweir         virtual ~IDocumentMarkAccess() {};
266cdf0e10cSrcweir };
267cdf0e10cSrcweir 
268cdf0e10cSrcweir #endif // IDOCUMENTBOOKMARKACCESS_HXX_INCLUDED
269