1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: bookmrk.hxx,v $
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 ************************************************************************/
33 #include "hintids.hxx" //die Ids der Attribute, vor macitem damit die
34 //die Attribut richtig angezogen werden.
35 #include <svtools/macitem.hxx>
37 #ifndef _KEYCOD_HXX //autogen
38 #include <vcl/keycod.hxx>
40 #ifndef _TOOLS_REF_HXX
41 #include <tools/ref.hxx>
43 #include <IDocumentBookmarkAccess.hxx>
47 #ifndef SW_DECL_SWSERVEROBJECT_DEFINED
48 #define SW_DECL_SWSERVEROBJECT_DEFINED
49 SV_DECL_REF( SwServerObject
)
53 struct SwPosition
; // fwd Decl. wg. UI
55 class SwBookmark
: public SwModify
58 SwPosition
*pPos1
, *pPos2
; // wird im CTOR gesetzt, im DTOR geloescht
59 // pPos1 is always != 0, pPos2 may be 0
60 SwServerObjectRef refObj
; // falls DataServer -> Pointer gesetzt
66 IDocumentBookmarkAccess::BookmarkType eMarkType
;
68 SwBookmark( const SwPosition
& aPos
,
70 const String
& rName
, const String
& rShortName
);
75 SwBookmark( const SwPosition
& aPos
);
76 // --> OD 2007-09-26 #i81002#
77 SwBookmark( const SwPaM
& aPaM
,
79 const String
& rName
, const String
& rShortName
);
82 // Beim Loeschen von Text werden Bookmarks mitgeloescht!
83 virtual ~SwBookmark();
85 const SwPosition
& GetPos() const { return *pPos1
; }
86 const SwPosition
* GetOtherPos() const { return pPos2
; }
88 // --> OD 2007-10-10 #i81002#
89 // made virtual and thus no longer inline
90 virtual const SwPosition
& GetBookmarkPos() const;
91 virtual const SwPosition
* GetOtherBookmarkPos() const;
95 const String
& GetName() const { return aName
; }
97 const String
& GetShortName() const { return aShortName
; }
99 const KeyCode
& GetKeyCode() const { return aCode
; }
101 // Vergleiche auf Basis der Dokumentposition
102 BOOL
operator < (const SwBookmark
&) const;
103 BOOL
operator ==(const SwBookmark
&) const;
104 // falls man wirklich auf gleiche Position abfragen will.
105 BOOL
IsEqualPos( const SwBookmark
&rBM
) const;
107 BOOL
IsFormFieldMark() const { return IDocumentBookmarkAccess::FORM_FIELDMARK_TEXT
== eMarkType
|| IDocumentBookmarkAccess::FORM_FIELDMARK_NO_TEXT
== eMarkType
; }
108 BOOL
IsTabbedFormFieldMark() const;
110 BOOL
IsBookMark() const { return IDocumentBookmarkAccess::BOOKMARK
== eMarkType
|| IDocumentBookmarkAccess::FORM_FIELDMARK_TEXT
== eMarkType
|| IDocumentBookmarkAccess::FORM_FIELDMARK_NO_TEXT
== eMarkType
; }
111 // // --> OD 2007-10-17 #TESTING#
112 // BOOL IsBookMark() const
114 // return IDocumentBookmarkAccess::BOOKMARK == eMarkType ||
118 BOOL
IsMark() const { return IDocumentBookmarkAccess::MARK
== eMarkType
; }
119 BOOL
IsUNOMark() const { return IDocumentBookmarkAccess::UNO_BOOKMARK
== eMarkType
; }
120 // --> OD 2007-10-11 #i81002# - bookmark type for cross-references
121 BOOL
IsCrossRefMark() const { return IDocumentBookmarkAccess::CROSSREF_BOOKMARK
== eMarkType
; }
123 void SetType( IDocumentBookmarkAccess::BookmarkType eNewType
) { eMarkType
= eNewType
; }
124 IDocumentBookmarkAccess::BookmarkType
GetType() const { return eMarkType
; }
126 // Daten Server-Methoden
127 void SetRefObject( SwServerObject
* pObj
);
128 const SwServerObject
* GetObject() const { return &refObj
; }
129 SwServerObject
* GetObject() { return &refObj
; }
130 BOOL
IsServer() const { return refObj
.Is(); }
132 // --> OD 2007-10-10 #i81002#
133 // made virtual and thus no longer inline
134 // to access start and end of a bookmark.
135 // start and end may be the same
136 virtual const SwPosition
* BookmarkStart() const;
137 virtual const SwPosition
* BookmarkEnd() const;
140 // --> OD 2007-09-26 #i81002#
141 virtual void SetBookmarkPos( const SwPosition
* pNewPos1
);
142 virtual void SetOtherBookmarkPos( const SwPosition
* pNewPos2
);
147 // es wird (vorerst) nicht kopiert und nicht zugewiesen
148 SwBookmark(const SwBookmark
&);
149 SwBookmark
&operator=(const SwBookmark
&);
152 class SwMark
: public SwBookmark
155 SwMark( const SwPosition
& aPos
,
156 const KeyCode
& rCode
,
157 const String
& rName
, const String
& rShortName
);
160 class SW_DLLPUBLIC SwFieldBookmark
: public SwBookmark
163 typedef std::pair
< ::rtl::OUString
, ::rtl::OUString
> ParamPair_t
;
165 ::rtl::OUString m_type
;
166 std::vector
<ParamPair_t
> m_params
;
169 SwFieldBookmark(const SwPosition
& aPos
,
170 const KeyCode
& rCode
,
171 const String
& rName
, const String
& rShortName
,
172 IDocumentBookmarkAccess::BookmarkType eMark
);
174 virtual ~SwFieldBookmark();
176 void setTypeName(const ::rtl::OUString
&typeName
);
178 SwPosition
getSelectionStart();
179 SwPosition
getSelectionEnd();
181 // field specific stuff
182 bool isTabbed() const;
185 bool isType(const char *type
) const;
186 rtl::OUString
getTypeName();
187 void addParam(::rtl::OUString paramName
, ::rtl::OUString paramValue
, bool replaceExisting
=true);
188 void addParam(const char* paramName
, int value
);
189 int getNumOfParams();
190 ParamPair_t
getParam(int pos
);
191 ParamPair_t
getParam(const char *name
, const char *defaultValue
=NULL
);
192 void addParams(std::vector
<ParamPair_t
> ¶ms
);
195 class SwUNOMark
: public SwBookmark
198 // --> OD 2007-09-26 #i81002#
199 SwUNOMark( const SwPaM
& aPaM
,
200 const KeyCode
& rCode
,
201 const String
& rName
, const String
& rShortName
);