summaryrefslogtreecommitdiff
path: root/sw/inc/IDocumentBookmarkAccess.hxx
blob: 539fb594852bbb3820309f050d03c30f03e68e83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: IDocumentBookmarkAccess.hxx,v $
 * $Revision: 1.6 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#ifndef IDOCUMENTBOOKMARKACCESS_HXX_INCLUDED
#define IDOCUMENTBOOKMARKACCESS_HXX_INCLUDED

#include <sal/types.h>

class SwBookmark;
class SwFieldBookmark;
class SwBookmarks;
class SwPaM;
class KeyCode;
class String;
struct SwPosition;
class SwTxtNode;

/** Provides access to the bookmarks of a document.
*/
class IDocumentBookmarkAccess
{
public:
    enum BookmarkType
    {
        BOOKMARK,
        MARK,
        DDE_BOOKMARK,
        UNO_BOOKMARK,
        // --> OD 2007-10-11 #i81002# - bookmark type for cross-references
        CROSSREF_BOOKMARK,
        // <--
 //     FIELDMARK, // for future use...
         FORM_FIELDMARK_TEXT,
         FORM_FIELDMARK_NO_TEXT
    };

    // --> OD 2007-11-16 #i83479#
    enum CrossReferenceBookmarkSubType
    {
        HEADING,
        NUMITEM
    };
    // <--

public:
    /** Returns all bookmarks set at the document.

       @returns
       the bookmarks set at the document.
    */
    virtual const SwBookmarks& getBookmarks() const = 0;

    /** Generates a new bookmark in the document.

       @param rPaM
       [in] the location of the new bookmark.

       @param rKC
       [in] ???

       @param rName
       [in] the name of the new bookmark.

       @param rShortName
       [in] the short name of the new bookmark.

       @param eMark
       [in] the type of the new bookmark.

       @returns
       a pointer to the new bookmark.
    */
    virtual SwBookmark* makeBookmark( /*[in]*/const SwPaM& rPaM, /*[in]*/const KeyCode& rKC,
                                      /*[in]*/const String& rName, /*[in]*/const String& rShortName,
                                      /*[in]*/BookmarkType eMark ) = 0;

    /** Deletes a bookmark.

       @param nPos
       [in] the position of the bookmark to be deleted.
    */
    virtual void deleteBookmark( /*[in]*/sal_uInt16 nPos ) = 0;

    /** Deletes a bookmark.

       @param rName
       [in] the name of the bookmark to be deleted.
    */
    virtual void deleteBookmark( /*[in]*/const String& rName ) = 0;

    /** Checks, if the given name fits to the cross-reference bookmark
        name schema

        OD 2007-10-24 #i81002#

        @author OD

        @param rName
        [in] the name to be checked.

        @returns
        boolean indicating , if the name fits or not
    */
    virtual bool isCrossRefBookmarkName( /*[in]*/const String& rName ) = 0;

    /** Find a bookmark.

       @param rName
       [in] the name of the bookmark to be found.

       @returns
       the position of the bookmark in the bookmark container.
    */
    virtual sal_uInt16 findBookmark(  /*[in]*/const String& rName ) = 0;

    /** Generates a unique bookmark name. The name has to be passed to the
        function, a number will be added to the name if the name is already
        used.

       @param rName
       [in/out] the name of the bookmark.
    */
    virtual void makeUniqueBookmarkName( /*[in/out]*/String& rName ) = 0;

    /** Get the number of ::com::sun::star::text::Bookmarks.

       @param bBkmrk
       [in] if set, only "real" bookmarks are considered.

       @returns
       the number of bookmarks.
    */
    virtual sal_uInt16 getBookmarkCount( /*[in]*/bool bBkmrk) const = 0;

    /** Get a bookmark.

       @param nPos
       [in] the position of the bookmark in the bookmark container.

       @param bBkmrk
       [in] if set, only "real" bookmarks are considered.

       @returns
       the bookmark.
    */
    virtual SwBookmark& getBookmark(  /*[in]*/sal_uInt16 nPos, /*[in]*/bool bBkmrk) = 0;

    /** Get cross-reference bookmark name for certain text node

        OD 2007-11-16 #i83479#

        @author OD

        @param rTxtNode
        [in] reference to text node, whose cross-reference bookmark name has to be returned.

        @param nCrossRefType
        [in] sub type of cross-reference bookmark, whose name has to be returned.

        @returns
        name of cross-reference bookmark of given cross-reference sub type,
        if such a cross-reference bookmark exists at given textnode.
        otherwise, empty string
    */
    virtual String getCrossRefBookmarkName(
            /*[in]*/const SwTxtNode& rTxtNode,
            /*[in]*/const CrossReferenceBookmarkSubType nCrossRefType ) const = 0;

    /** Generates new cross-reference bookmark for given text node of given sub type

        OD 2007-11-16 #i83479#

        @author OD

        @param rTxtNode
        [in] reference to text node, at which the cross-reference bookmark has to be generated.

        @param nCrossRefType
        [in] sub type of cross-reference bookmark.

        @returns
        name of generated cross-reference bookmark.
        If empty, cross-reference bookmark is not generated.
    */
    virtual String makeCrossRefBookmark(
                /*[in]*/const SwTxtNode& rTxtNode,
                /*[in]*/const CrossReferenceBookmarkSubType nCrossRefType ) = 0;

    virtual SwBookmark* getFieldBookmarkFor(const SwPosition &pos) const = 0;
    virtual SwFieldBookmark* getFormFieldBookmarkFor(const SwPosition &pos) const = 0;
    virtual SwBookmark* getNextFieldBookmarkFor(const SwPosition &pos) const = 0;
    virtual SwBookmark* getPrevFieldBookmarkFor(const SwPosition &pos) const = 0;

protected:
    virtual ~IDocumentBookmarkAccess() {};
};

namespace bookmarkfunc
{
    /** return the prefix used for cross-reference bookmark for headings

        OD 2007-11-16 #i83479#

        @author OD
    */
    const String getHeadingCrossRefBookmarkNamePrefix();

    /** return the prefix used for cross-reference bookmark for numbered items

        OD 2007-11-16 #i83479#

        @author OD
    */
    const String getNumItemCrossRefBookmarkNamePrefix();

    /** Checks, if the given name fits to the heading cross-reference bookmark
        name schema

        OD 2007-11-09 #i81002#

        @author OD

        @param rName
        [in] the name to be checked.

        @returns
        boolean indicating , if the name fits or not
    */
    bool isHeadingCrossRefBookmarkName( /*[in]*/const String& rName );

    /** Checks, if the given name fits to the numbered item cross-reference
        bookmark name schema

        OD 2007-11-09 #i81002#

        @author OD

        @param rName
        [in] the name to be checked.

        @returns
        boolean indicating , if the name fits or not
    */
    bool isNumItemCrossRefBookmarkName( /*[in]*/const String& rName );

    /** generate new name for a cross-reference bookmark of given sub type

        OD 2007-11-16 #i83479#

        @author OD
    */
    String generateNewCrossRefBookmarkName(
            /*[in]*/const IDocumentBookmarkAccess::CrossReferenceBookmarkSubType nSubType );
}
#endif // IDOCUMENTBOOKMARKACCESS_HXX_INCLUDED