merge the formfield patch from ooo-build
[ooovba.git] / sw / source / core / inc / bookmrk.hxx
blobdffeafe594b60e57e33222e554756ca3ff0bb5e4
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 <sfx2/Metadatable.hxx>
37 #include <boost/scoped_ptr.hpp>
38 #include <boost/noncopyable.hpp>
40 struct SwPosition; // fwd Decl. wg. UI
41 class SwDoc;
43 namespace sw { namespace mark
45 class MarkBase
46 : virtual public IMark
47 , private ::boost::noncopyable
49 public:
50 //getters
51 virtual SwPosition& GetMarkPos() const
52 { return *m_pPos1; }
53 virtual const ::rtl::OUString& GetName() const
54 { return m_aName; }
55 virtual bool IsCoveringPosition(const SwPosition& rPos) const;
56 virtual SwPosition& GetOtherMarkPos() const
58 OSL_PRECOND(IsExpanded(), "<SwPosition::GetOtherMarkPos(..)> - I have no other Pos set." );
59 return *m_pPos2;
61 virtual SwPosition& GetMarkStart() const
63 if( !IsExpanded() ) return GetMarkPos( );
64 if ( GetMarkPos( ) < GetOtherMarkPos( ) )
65 return GetMarkPos();
66 else
67 return GetOtherMarkPos( );
69 virtual SwPosition& GetMarkEnd() const
71 if( !IsExpanded() ) return GetMarkPos();
72 if ( GetMarkPos( ) > GetOtherMarkPos( ) )
73 return GetMarkPos( );
74 else
75 return GetOtherMarkPos( );
77 virtual bool IsExpanded() const
78 { return m_pPos2; }
80 //setters
81 virtual void SetName(const ::rtl::OUString& rName)
82 { m_aName = rName; }
83 virtual void SetMarkPos(const SwPosition& rNewPos);
84 virtual void SetOtherMarkPos(const SwPosition& rNewPos);
85 virtual void ClearOtherMarkPos()
86 { m_pPos2.reset(); }
88 virtual rtl::OUString toString( ) const;
90 virtual void Swap()
92 if(m_pPos2)
93 m_pPos1.swap(m_pPos2);
96 virtual void InitDoc(SwDoc* const)
99 virtual ~MarkBase();
100 protected:
101 MarkBase(const SwPaM& rPaM,
102 const ::rtl::OUString& rName);
103 ::boost::scoped_ptr<SwPosition> m_pPos1;
104 ::boost::scoped_ptr<SwPosition> m_pPos2;
105 ::rtl::OUString m_aName;
106 static ::rtl::OUString GenerateNewName(const ::rtl::OUString& rPrefix);
109 class NavigatorReminder
110 : public MarkBase
111 , virtual public IMark
113 public:
114 NavigatorReminder(const SwPaM& rPaM);
115 private:
116 static const ::rtl::OUString our_sNamePrefix;
119 class UnoMark
120 : public MarkBase
122 public:
123 UnoMark(const SwPaM& rPaM);
124 private:
125 static const ::rtl::OUString our_sNamePrefix;
128 class DdeBookmark
129 : public MarkBase
131 public:
132 DdeBookmark(const SwPaM& rPaM);
134 //getters
135 const SwServerObject* GetRefObject() const
136 { return &m_aRefObj; }
137 SwServerObject* GetRefObject()
138 { return &m_aRefObj; }
140 bool IsServer() const
141 { return m_aRefObj.Is(); }
143 //setters
144 void SetRefObject( SwServerObject* pObj );
146 void DeregisterFromDoc(SwDoc* const pDoc);
147 virtual ~DdeBookmark();
148 private:
149 SwServerObjectRef m_aRefObj;
150 static const ::rtl::OUString our_sNamePrefix;
153 class Bookmark
154 : virtual public IBookmark
155 , public DdeBookmark
156 , public ::sfx2::Metadatable
158 public:
159 Bookmark(const SwPaM& rPaM,
160 const KeyCode& rCode,
161 const ::rtl::OUString& rName,
162 const ::rtl::OUString& rShortName);
163 virtual void InitDoc(SwDoc* const io_Doc);
165 virtual const ::rtl::OUString& GetShortName() const
166 { return m_sShortName; }
167 virtual const KeyCode& GetKeyCode() const
168 { return m_aCode; }
169 virtual void SetShortName(const ::rtl::OUString& rShortName)
170 { m_sShortName = rShortName; }
171 virtual void SetKeyCode(const KeyCode& rCode)
172 { m_aCode = rCode; }
174 // ::sfx2::Metadatable
175 virtual ::sfx2::IXmlIdRegistry& GetRegistry();
176 virtual bool IsInClipboard() const;
177 virtual bool IsInUndo() const;
178 virtual bool IsInContent() const;
179 virtual ::com::sun::star::uno::Reference<
180 ::com::sun::star::rdf::XMetadatable > MakeUnoObject();
182 private:
183 KeyCode m_aCode;
184 ::rtl::OUString m_sShortName;
187 class Fieldmark
188 : virtual public IFieldmark
189 , public MarkBase
191 public:
192 Fieldmark(const SwPaM& rPaM);
194 // getters
195 ::rtl::OUString GetFieldname() const
196 { return m_aFieldname; }
197 ::rtl::OUString GetFieldHelptext() const
198 { return m_aFieldHelptext; }
200 void addParam( rtl::OUString rParamName,
201 rtl::OUString rParamValue,
202 bool bReplaceExisting = true );
203 void addParam( const char* paramName, int value );
204 void addParams(std::vector<ParamPair_t>& params);
205 int getNumOfParams() const;
206 ParamPair_t getParam(int pos) const;
207 ParamPair_t getParam(const char *name, const char *defaultValue) const;
209 // setters
210 void SetFieldname(const ::rtl::OUString& aFieldname)
211 { m_aFieldname = aFieldname; }
212 void SetFieldHelptext(const ::rtl::OUString& aFieldHelptext)
213 { m_aFieldHelptext = aFieldHelptext; }
214 void invalidate( );
216 virtual rtl::OUString toString( ) const;
217 private:
218 //int fftype; // Type: 0 = Text, 1 = Check Box, 2 = List
219 //bool ffprot;
221 ::rtl::OUString m_aFieldname;
222 ::rtl::OUString m_aFieldHelptext;
223 static const ::rtl::OUString our_sNamePrefix;
224 std::vector<ParamPair_t> m_params;
227 class TextFieldmark
228 : public Fieldmark
230 public:
231 TextFieldmark(const SwPaM& rPaM);
232 virtual void InitDoc(SwDoc* const io_pDoc);
233 private:
234 //int fftypetxt; // Type of text field: 0 = Regular text, 1 = Number, 2 = Date, 3 = Current date, 4 = Current time, 5 = Calculation
235 //int ffmaxlen; // Number of characters for text field. Zero means unlimited.
238 class CheckboxFieldmark
239 : virtual public ICheckboxFieldmark
240 , public Fieldmark
242 public:
243 CheckboxFieldmark(const SwPaM& rPaM);
244 virtual void InitDoc(SwDoc* const io_pDoc);
245 bool IsChecked() const;
246 void SetChecked(bool checked);
247 private:
248 bool m_isChecked;
249 //bool ffsize; // 0 = Auto, 1=Exact (see ffhps)
250 //bool ffrecalc;
251 //int ffhps; // Check box size (half-point sizes).
255 #endif