update ooo310-m15
[ooovba.git] / sw / inc / bookmrk.hxx
blob89499c286933f2ad74d25bb2b2bb60df7a8eba97
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: bookmrk.hxx,v $
10 * $Revision: 1.11 $
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 ************************************************************************/
30 #ifndef _BOOKMRK_HXX
31 #define _BOOKMRK_HXX
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>
39 #endif
40 #ifndef _TOOLS_REF_HXX
41 #include <tools/ref.hxx>
42 #endif
43 #include <IDocumentBookmarkAccess.hxx>
44 #include <calbck.hxx>
45 #include <pam.hxx>
47 #ifndef SW_DECL_SWSERVEROBJECT_DEFINED
48 #define SW_DECL_SWSERVEROBJECT_DEFINED
49 SV_DECL_REF( SwServerObject )
50 #endif
53 struct SwPosition; // fwd Decl. wg. UI
55 class SwBookmark : public SwModify
57 friend class SwDoc;
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
62 protected:
63 String aName;
64 String aShortName;
65 KeyCode aCode;
66 IDocumentBookmarkAccess::BookmarkType eMarkType;
68 SwBookmark( const SwPosition& aPos,
69 const KeyCode& rCode,
70 const String& rName, const String& rShortName);
72 public:
73 TYPEINFO();
75 SwBookmark( const SwPosition& aPos );
76 // --> OD 2007-09-26 #i81002#
77 SwBookmark( const SwPaM& aPaM,
78 const KeyCode& rCode,
79 const String& rName, const String& rShortName);
80 // <--
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;
92 // <--
94 // nicht undofaehig
95 const String& GetName() const { return aName; }
96 // nicht undofaehig
97 const String& GetShortName() const { return aShortName; }
98 // nicht undofaehig
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
113 // {
114 // return IDocumentBookmarkAccess::BOOKMARK == eMarkType ||
115 // IsCrossRefMark();
116 // }
117 // // <--
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; }
122 // <--
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;
138 // <--
140 // --> OD 2007-09-26 #i81002#
141 virtual void SetBookmarkPos( const SwPosition* pNewPos1 );
142 virtual void SetOtherBookmarkPos( const SwPosition* pNewPos2 );
143 // <--
145 private:
146 // fuer METWARE:
147 // es wird (vorerst) nicht kopiert und nicht zugewiesen
148 SwBookmark(const SwBookmark &);
149 SwBookmark &operator=(const SwBookmark &);
152 class SwMark: public SwBookmark
154 public:
155 SwMark( const SwPosition& aPos,
156 const KeyCode& rCode,
157 const String& rName, const String& rShortName);
160 class SW_DLLPUBLIC SwFieldBookmark : public SwBookmark
162 public:
163 typedef std::pair< ::rtl::OUString, ::rtl::OUString > ParamPair_t;
164 private:
165 ::rtl::OUString m_type;
166 std::vector<ParamPair_t> m_params;
168 public:
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);
177 void invalidate();
178 SwPosition getSelectionStart();
179 SwPosition getSelectionEnd();
181 // field specific stuff
182 bool isTabbed() const;
184 // generic methods
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> &params);
195 class SwUNOMark: public SwBookmark
197 public:
198 // --> OD 2007-09-26 #i81002#
199 SwUNOMark( const SwPaM& aPaM,
200 const KeyCode& rCode,
201 const String& rName, const String& rShortName);
202 // <--
206 #endif