Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _BOOKMRK_HXX
30 : : #define _BOOKMRK_HXX
31 : :
32 : : #include <cppuhelper/weakref.hxx>
33 : : #include <sfx2/Metadatable.hxx>
34 : : #include <boost/scoped_ptr.hpp>
35 : : #include <boost/noncopyable.hpp>
36 : : #include <map>
37 : : #include <rtl/ustring.hxx>
38 : : #include <IMark.hxx>
39 : :
40 : : namespace com {
41 : : namespace sun {
42 : : namespace star {
43 : : namespace text {
44 : : class XTextContent;
45 : : }
46 : : }
47 : : }
48 : : }
49 : :
50 : : struct SwPosition; // fwd Decl. wg. UI
51 : : class SwDoc;
52 : :
53 : : namespace sw {
54 : : namespace mark {
55 : : class MarkBase
56 : : : virtual public IMark
57 : : {
58 : : public:
59 : 7688991 : virtual SwPosition& GetMarkPos() const
60 : 7688991 : { return *m_pPos1; }
61 : 4737555 : virtual const ::rtl::OUString& GetName() const
62 : 4737555 : { return m_aName; }
63 : 12326516 : virtual SwPosition& GetOtherMarkPos() const
64 : : {
65 : : OSL_PRECOND(IsExpanded(), "<SwPosition::GetOtherMarkPos(..)> - I have no other Pos set." );
66 : 12326516 : return *m_pPos2;
67 : : }
68 : 627646 : virtual SwPosition& GetMarkStart() const
69 : : {
70 [ + + ]: 627646 : if( !IsExpanded() ) return GetMarkPos( );
71 [ + + ]: 543307 : if ( GetMarkPos( ) < GetOtherMarkPos( ) )
72 : 541244 : return GetMarkPos();
73 : : else
74 : 627646 : return GetOtherMarkPos( );
75 : : }
76 : 5337993 : virtual SwPosition& GetMarkEnd() const
77 : : {
78 [ + + ]: 5337993 : if( !IsExpanded() ) return GetMarkPos();
79 [ + + ]: 5318935 : if ( GetMarkPos( ) >= GetOtherMarkPos( ) )
80 : 15 : return GetMarkPos( );
81 : : else
82 : 5337993 : return GetOtherMarkPos( );
83 : : }
84 : :
85 : : virtual bool IsCoveringPosition(const SwPosition& rPos) const;
86 : 6849665 : virtual bool IsExpanded() const
87 : 6849665 : { return m_pPos2; }
88 : :
89 : 4049 : virtual void SetName(const ::rtl::OUString& rName)
90 : 4049 : { m_aName = rName; }
91 : : virtual void SetMarkPos(const SwPosition& rNewPos);
92 : : virtual void SetOtherMarkPos(const SwPosition& rNewPos);
93 : 0 : virtual void ClearOtherMarkPos()
94 : 0 : { m_pPos2.reset(); }
95 : :
96 : : virtual rtl::OUString ToString( ) const;
97 : :
98 : 2033 : virtual void Swap()
99 : : {
100 [ + - ]: 2033 : if(m_pPos2)
101 : 2033 : m_pPos1.swap(m_pPos2);
102 : 2033 : }
103 : :
104 : 20318 : virtual void InitDoc(SwDoc* const)
105 : : {
106 : 20318 : }
107 : :
108 : : virtual ~MarkBase();
109 : :
110 : : const ::com::sun::star::uno::WeakReference<
111 : 13584 : ::com::sun::star::text::XTextContent> & GetXBookmark() const
112 : 13584 : { return m_wXBookmark; }
113 : 14409 : void SetXBookmark(::com::sun::star::uno::Reference<
114 : : ::com::sun::star::text::XTextContent> const& xBkmk)
115 : 14409 : { m_wXBookmark = xBkmk; }
116 : :
117 : : protected:
118 : : // SwClient
119 : : virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew );
120 : :
121 : : MarkBase(const SwPaM& rPaM, const ::rtl::OUString& rName);
122 : : ::boost::scoped_ptr<SwPosition> m_pPos1;
123 : : ::boost::scoped_ptr<SwPosition> m_pPos2;
124 : : ::rtl::OUString m_aName;
125 : : static ::rtl::OUString GenerateNewName(const ::rtl::OUString& rPrefix);
126 : :
127 : : ::com::sun::star::uno::WeakReference<
128 : : ::com::sun::star::text::XTextContent> m_wXBookmark;
129 : : };
130 : :
131 [ # # ][ # # ]: 0 : class NavigatorReminder
[ # # ][ # # ]
[ # # ]
[ # # # # ]
132 : : : public MarkBase
133 : : {
134 : : public:
135 : : NavigatorReminder(const SwPaM& rPaM);
136 : : };
137 : :
138 [ + - ][ + - ]: 40636 : class UnoMark
[ + - ][ + - ]
[ - + ]
[ # # # # ]
139 : : : public MarkBase
140 : : {
141 : : public:
142 : : UnoMark(const SwPaM& rPaM);
143 : : };
144 : :
145 : : class DdeBookmark
146 : : : public MarkBase
147 : : {
148 : : public:
149 : : DdeBookmark(const SwPaM& rPaM);
150 : :
151 : : const SwServerObject* GetRefObject() const
152 : : { return &m_aRefObj; }
153 : 0 : SwServerObject* GetRefObject()
154 : 0 : { return &m_aRefObj; }
155 : :
156 : 0 : bool IsServer() const
157 : 0 : { return m_aRefObj.Is(); }
158 : :
159 : : void SetRefObject( SwServerObject* pObj );
160 : :
161 : : void DeregisterFromDoc(SwDoc* const pDoc);
162 : : virtual ~DdeBookmark();
163 : :
164 : : private:
165 : : SwServerObjectRef m_aRefObj;
166 : : };
167 : :
168 [ + - ][ + - ]: 8018 : class Bookmark
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ - + ]
[ # # # #
# # ][ + - ]
[ + - ][ - + ]
[ # # ][ - + ]
[ # # ][ - + ]
[ - + ][ # #
# # # # ]
169 : : : virtual public IBookmark
170 : : , public DdeBookmark
171 : : , public ::sfx2::Metadatable
172 : : {
173 : : public:
174 : : Bookmark(const SwPaM& rPaM,
175 : : const KeyCode& rCode,
176 : : const ::rtl::OUString& rName,
177 : : const ::rtl::OUString& rShortName);
178 : : virtual void InitDoc(SwDoc* const io_Doc);
179 : :
180 : 2532 : virtual const ::rtl::OUString& GetShortName() const
181 : 2532 : { return m_sShortName; }
182 : 2532 : virtual const KeyCode& GetKeyCode() const
183 : 2532 : { return m_aCode; }
184 : 0 : virtual void SetShortName(const ::rtl::OUString& rShortName)
185 : 0 : { m_sShortName = rShortName; }
186 : 0 : virtual void SetKeyCode(const KeyCode& rCode)
187 : 0 : { m_aCode = rCode; }
188 : :
189 : : // ::sfx2::Metadatable
190 : : virtual ::sfx2::IXmlIdRegistry& GetRegistry();
191 : : virtual bool IsInClipboard() const;
192 : : virtual bool IsInUndo() const;
193 : : virtual bool IsInContent() const;
194 : : virtual ::com::sun::star::uno::Reference<
195 : : ::com::sun::star::rdf::XMetadatable > MakeUnoObject();
196 : :
197 : : private:
198 : : KeyCode m_aCode;
199 : : ::rtl::OUString m_sShortName;
200 : : };
201 : :
202 [ # # ][ # # ]: 18 : class Fieldmark
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # #
# # # # ]
[ + - ][ - + ]
[ # # ][ - + ]
[ # # ][ - + ]
[ - + ][ # #
# # # # ]
203 : : : virtual public IFieldmark
204 : : , public MarkBase
205 : : {
206 : : public:
207 : : Fieldmark(const SwPaM& rPaM);
208 : :
209 : 252 : virtual ::rtl::OUString GetFieldname() const
210 : 252 : { return m_aFieldname; }
211 : 0 : virtual ::rtl::OUString GetFieldHelptext() const
212 : 0 : { return m_aFieldHelptext; }
213 : :
214 : 6 : virtual IFieldmark::parameter_map_t* GetParameters()
215 : 6 : { return &m_vParams; }
216 : :
217 : 6 : virtual const IFieldmark::parameter_map_t* GetParameters() const
218 : 6 : { return &m_vParams; }
219 : :
220 : 21 : virtual void SetFieldname(const ::rtl::OUString& aFieldname)
221 : 21 : { m_aFieldname = aFieldname; }
222 : 0 : virtual void SetFieldHelptext(const ::rtl::OUString& aFieldHelptext)
223 : 0 : { m_aFieldHelptext = aFieldHelptext; }
224 : :
225 : : virtual void Invalidate();
226 : : virtual rtl::OUString ToString() const;
227 : :
228 : : private:
229 : : ::rtl::OUString m_aFieldname;
230 : : ::rtl::OUString m_aFieldHelptext;
231 : : IFieldmark::parameter_map_t m_vParams;
232 : : };
233 : :
234 [ + - ][ + - ]: 30 : class TextFieldmark
[ + - ][ + - ]
[ + - ][ + - ]
[ - + ][ # #
# # # # ]
235 : : : public Fieldmark
236 : : {
237 : : public:
238 : : TextFieldmark(const SwPaM& rPaM);
239 : : virtual void InitDoc(SwDoc* const io_pDoc);
240 : : void ReleaseDoc(SwDoc* const pDoc);
241 : : };
242 : :
243 [ + - ][ + - ]: 6 : class CheckboxFieldmark
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ - + ][ # #
# # # # #
# ]
244 : : : virtual public ICheckboxFieldmark
245 : : , public Fieldmark
246 : : {
247 : : public:
248 : : CheckboxFieldmark(const SwPaM& rPaM);
249 : : virtual void InitDoc(SwDoc* const io_pDoc);
250 : : bool IsChecked() const;
251 : : void SetChecked(bool checked);
252 : :
253 : : virtual rtl::OUString toString( ) const;
254 : : };
255 : : }
256 : : }
257 : : #endif
258 : :
259 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|