update dev300-m58
[ooovba.git] / sw / source / core / inc / bookmrk.hxx
blobbd62abe8ed43cd5943748e736386b9cb3d78705f
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: $
10 * $Revision: $
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 _BOOKMRK_HXX
32 #define _BOOKMRK_HXX
34 #include <IMark.hxx>
35 #include <boost/scoped_ptr.hpp>
36 #include <boost/noncopyable.hpp>
38 struct SwPosition; // fwd Decl. wg. UI
39 class SwDoc;
41 namespace sw { namespace mark
43 class MarkBase
44 : virtual public IMark
45 , private ::boost::noncopyable
47 public:
48 //getters
49 virtual SwPosition& GetMarkPos() const
50 { return *m_pPos1; }
51 virtual const ::rtl::OUString& GetName() const
52 { return m_aName; }
53 virtual bool IsCoveringPosition(const SwPosition& rPos) const;
54 virtual SwPosition& GetOtherMarkPos() const
56 OSL_PRECOND(IsExpanded(), "<SwPosition::GetOtherMarkPos(..)> - I have no other Pos set." );
57 return *m_pPos2;
59 virtual SwPosition& GetMarkStart() const
61 if( !IsExpanded() ) return GetMarkPos( );
62 if ( GetMarkPos( ) < GetOtherMarkPos( ) )
63 return GetMarkPos();
64 else
65 return GetOtherMarkPos( );
67 virtual SwPosition& GetMarkEnd() const
69 if( !IsExpanded() ) return GetMarkPos();
70 if ( GetMarkPos( ) > GetOtherMarkPos( ) )
71 return GetMarkPos( );
72 else
73 return GetOtherMarkPos( );
75 virtual bool IsExpanded() const
76 { return m_pPos2; }
78 //setters
79 virtual void SetName(const ::rtl::OUString& rName)
80 { m_aName = rName; }
81 virtual void SetMarkPos(const SwPosition& rNewPos);
82 virtual void SetOtherMarkPos(const SwPosition& rNewPos);
83 virtual void ClearOtherMarkPos()
84 { m_pPos2.reset(); }
86 virtual rtl::OUString toString( ) const;
88 virtual void Swap()
90 if(m_pPos2)
91 m_pPos1.swap(m_pPos2);
94 virtual void InitDoc(SwDoc* const)
97 virtual ~MarkBase();
98 protected:
99 MarkBase(const SwPaM& rPaM,
100 const ::rtl::OUString& rName);
101 ::boost::scoped_ptr<SwPosition> m_pPos1;
102 ::boost::scoped_ptr<SwPosition> m_pPos2;
103 ::rtl::OUString m_aName;
104 static ::rtl::OUString GenerateNewName(const ::rtl::OUString& rPrefix);
107 class NavigatorReminder
108 : public MarkBase
109 , virtual public IMark
111 public:
112 NavigatorReminder(const SwPaM& rPaM);
113 private:
114 static const ::rtl::OUString our_sNamePrefix;
117 class UnoMark
118 : public MarkBase
120 public:
121 UnoMark(const SwPaM& rPaM);
122 private:
123 static const ::rtl::OUString our_sNamePrefix;
126 class DdeBookmark
127 : public MarkBase
129 public:
130 DdeBookmark(const SwPaM& rPaM);
132 //getters
133 const SwServerObject* GetRefObject() const
134 { return &m_aRefObj; }
135 SwServerObject* GetRefObject()
136 { return &m_aRefObj; }
138 bool IsServer() const
139 { return m_aRefObj.Is(); }
141 //setters
142 void SetRefObject( SwServerObject* pObj );
144 void DeregisterFromDoc(SwDoc* const pDoc);
145 virtual ~DdeBookmark();
146 private:
147 SwServerObjectRef m_aRefObj;
148 static const ::rtl::OUString our_sNamePrefix;
151 class Bookmark
152 : virtual public IBookmark
153 , public DdeBookmark
155 public:
156 Bookmark(const SwPaM& rPaM,
157 const KeyCode& rCode,
158 const ::rtl::OUString& rName,
159 const ::rtl::OUString& rShortName);
160 virtual void InitDoc(SwDoc* const io_Doc);
162 virtual const ::rtl::OUString& GetShortName() const
163 { return m_sShortName; }
164 virtual const KeyCode& GetKeyCode() const
165 { return m_aCode; }
166 virtual void SetShortName(const ::rtl::OUString& rShortName)
167 { m_sShortName = rShortName; }
168 virtual void SetKeyCode(const KeyCode& rCode)
169 { m_aCode = rCode; }
170 private:
171 KeyCode m_aCode;
172 ::rtl::OUString m_sShortName;
175 class Fieldmark
176 : virtual public IFieldmark
177 , public MarkBase
179 public:
180 Fieldmark(const SwPaM& rPaM);
182 // getters
183 ::rtl::OUString GetFieldname() const
184 { return m_aFieldname; }
185 ::rtl::OUString GetFieldHelptext() const
186 { return m_aFieldHelptext; }
188 void addParam( rtl::OUString rParamName,
189 rtl::OUString rParamValue,
190 bool bReplaceExisting = true );
191 void addParam( const char* paramName, int value );
192 void addParams(std::vector<ParamPair_t>& params);
193 int getNumOfParams() const;
194 ParamPair_t getParam(int pos) const;
195 ParamPair_t getParam(const char *name, const char *defaultValue) const;
197 // setters
198 void SetFieldname(const ::rtl::OUString& aFieldname)
199 { m_aFieldname = aFieldname; }
200 void SetFieldHelptext(const ::rtl::OUString& aFieldHelptext)
201 { m_aFieldHelptext = aFieldHelptext; }
202 void invalidate( );
204 virtual rtl::OUString toString( ) const;
205 private:
206 //int fftype; // Type: 0 = Text, 1 = Check Box, 2 = List
207 //bool ffprot;
209 ::rtl::OUString m_aFieldname;
210 ::rtl::OUString m_aFieldHelptext;
211 static const ::rtl::OUString our_sNamePrefix;
212 std::vector<ParamPair_t> m_params;
215 class TextFieldmark
216 : public Fieldmark
218 public:
219 TextFieldmark(const SwPaM& rPaM);
220 virtual void InitDoc(SwDoc* const io_pDoc);
221 private:
222 //int fftypetxt; // Type of text field: 0 = Regular text, 1 = Number, 2 = Date, 3 = Current date, 4 = Current time, 5 = Calculation
223 //int ffmaxlen; // Number of characters for text field. Zero means unlimited.
226 class CheckboxFieldmark
227 : virtual public ICheckboxFieldmark
228 , public Fieldmark
230 public:
231 CheckboxFieldmark(const SwPaM& rPaM);
232 virtual void InitDoc(SwDoc* const io_pDoc);
233 bool IsChecked() const;
234 void SetChecked(bool checked);
235 private:
236 bool m_isChecked;
237 //bool ffsize; // 0 = Auto, 1=Exact (see ffhps)
238 //bool ffrecalc;
239 //int ffhps; // Check box size (half-point sizes).
243 #endif