Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef SW_UNOBOOKMARK_HXX
21 : #define SW_UNOBOOKMARK_HXX
22 :
23 : #include <com/sun/star/lang/XUnoTunnel.hpp>
24 : #include <com/sun/star/lang/XServiceInfo.hpp>
25 : #include <com/sun/star/beans/XPropertySet.hpp>
26 : #include <com/sun/star/container/XNamed.hpp>
27 : #include <com/sun/star/text/XTextContent.hpp>
28 : #include <com/sun/star/text/XFormField.hpp>
29 :
30 : #include <cppuhelper/implbase5.hxx>
31 :
32 : #include <sfx2/Metadatable.hxx>
33 :
34 : #include <unobaseclass.hxx>
35 : #include <IDocumentMarkAccess.hxx>
36 :
37 :
38 : class SwDoc;
39 :
40 :
41 : typedef ::cppu::ImplInheritanceHelper5
42 : < ::sfx2::MetadatableMixin
43 : , ::com::sun::star::lang::XUnoTunnel
44 : , ::com::sun::star::lang::XServiceInfo
45 : , ::com::sun::star::beans::XPropertySet
46 : , ::com::sun::star::container::XNamed
47 : , ::com::sun::star::text::XTextContent
48 : > SwXBookmark_Base;
49 :
50 : class SwXBookmark
51 : : public SwXBookmark_Base
52 : {
53 :
54 : private:
55 :
56 : class Impl;
57 : ::sw::UnoImplPtr<Impl> m_pImpl;
58 :
59 : protected:
60 :
61 : void attachToRangeEx(
62 : const ::com::sun::star::uno::Reference<
63 : ::com::sun::star::text::XTextRange > & xTextRange,
64 : IDocumentMarkAccess::MarkType eType)
65 : throw (::com::sun::star::lang::IllegalArgumentException,
66 : ::com::sun::star::uno::RuntimeException );
67 : virtual void attachToRange(
68 : const ::com::sun::star::uno::Reference<
69 : ::com::sun::star::text::XTextRange > & xTextRange)
70 : throw (::com::sun::star::lang::IllegalArgumentException,
71 : ::com::sun::star::uno::RuntimeException);
72 :
73 : const ::sw::mark::IMark* GetBookmark() const;
74 :
75 : void registerInMark( SwXBookmark& rXMark, ::sw::mark::IMark* const pMarkBase );
76 :
77 : virtual ~SwXBookmark();
78 :
79 : /// @param pDoc and pMark != 0, but not & because of ImplInheritanceHelper
80 : SwXBookmark(::sw::mark::IMark *const pMark, SwDoc *const pDoc);
81 :
82 : public:
83 :
84 : /// descriptor
85 : SwXBookmark();
86 :
87 : static ::com::sun::star::uno::Reference<
88 : ::com::sun::star::text::XTextContent>
89 : CreateXBookmark(SwDoc & rDoc, ::sw::mark::IMark & rBookmark);
90 :
91 : /// @return IMark for this, but only if it lives in pDoc
92 : static ::sw::mark::IMark const* GetBookmarkInDoc(SwDoc const*const pDoc,
93 : const ::com::sun::star::uno::Reference<
94 : ::com::sun::star::lang::XUnoTunnel> & xUT);
95 :
96 : // MetadatableMixin
97 : virtual ::sfx2::Metadatable* GetCoreObject();
98 : virtual ::com::sun::star::uno::Reference<
99 : ::com::sun::star::frame::XModel > GetModel();
100 :
101 : static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
102 :
103 : // XUnoTunnel
104 : virtual sal_Int64 SAL_CALL getSomething(
105 : const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier)
106 : throw (::com::sun::star::uno::RuntimeException);
107 :
108 : // XServiceInfo
109 : virtual ::rtl::OUString SAL_CALL getImplementationName()
110 : throw (::com::sun::star::uno::RuntimeException);
111 : virtual sal_Bool SAL_CALL supportsService(
112 : const ::rtl::OUString& rServiceName)
113 : throw (::com::sun::star::uno::RuntimeException);
114 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
115 : getSupportedServiceNames()
116 : throw (::com::sun::star::uno::RuntimeException);
117 :
118 : // XComponent
119 : virtual void SAL_CALL dispose()
120 : throw (::com::sun::star::uno::RuntimeException);
121 : virtual void SAL_CALL addEventListener(
122 : const ::com::sun::star::uno::Reference<
123 : ::com::sun::star::lang::XEventListener > & xListener)
124 : throw (::com::sun::star::uno::RuntimeException);
125 : virtual void SAL_CALL removeEventListener(
126 : const ::com::sun::star::uno::Reference<
127 : ::com::sun::star::lang::XEventListener > & xListener)
128 : throw (::com::sun::star::uno::RuntimeException);
129 :
130 : // XPropertySet
131 : virtual ::com::sun::star::uno::Reference<
132 : ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
133 : getPropertySetInfo()
134 : throw (::com::sun::star::uno::RuntimeException);
135 : virtual void SAL_CALL setPropertyValue(
136 : const ::rtl::OUString& rPropertyName,
137 : const ::com::sun::star::uno::Any& rValue)
138 : throw (::com::sun::star::beans::UnknownPropertyException,
139 : ::com::sun::star::beans::PropertyVetoException,
140 : ::com::sun::star::lang::IllegalArgumentException,
141 : ::com::sun::star::lang::WrappedTargetException,
142 : ::com::sun::star::uno::RuntimeException);
143 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
144 : const ::rtl::OUString& rPropertyName)
145 : throw (::com::sun::star::beans::UnknownPropertyException,
146 : ::com::sun::star::lang::WrappedTargetException,
147 : ::com::sun::star::uno::RuntimeException);
148 : virtual void SAL_CALL addPropertyChangeListener(
149 : const ::rtl::OUString& rPropertyName,
150 : const ::com::sun::star::uno::Reference<
151 : ::com::sun::star::beans::XPropertyChangeListener >& xListener)
152 : throw (::com::sun::star::beans::UnknownPropertyException,
153 : ::com::sun::star::lang::WrappedTargetException,
154 : ::com::sun::star::uno::RuntimeException);
155 : virtual void SAL_CALL removePropertyChangeListener(
156 : const ::rtl::OUString& rPropertyName,
157 : const ::com::sun::star::uno::Reference<
158 : ::com::sun::star::beans::XPropertyChangeListener >& xListener)
159 : throw (::com::sun::star::beans::UnknownPropertyException,
160 : ::com::sun::star::lang::WrappedTargetException,
161 : ::com::sun::star::uno::RuntimeException);
162 : virtual void SAL_CALL addVetoableChangeListener(
163 : const ::rtl::OUString& rPropertyName,
164 : const ::com::sun::star::uno::Reference<
165 : ::com::sun::star::beans::XVetoableChangeListener >& xListener)
166 : throw (::com::sun::star::beans::UnknownPropertyException,
167 : ::com::sun::star::lang::WrappedTargetException,
168 : ::com::sun::star::uno::RuntimeException);
169 : virtual void SAL_CALL removeVetoableChangeListener(
170 : const ::rtl::OUString& rPropertyName,
171 : const ::com::sun::star::uno::Reference<
172 : ::com::sun::star::beans::XVetoableChangeListener >& xListener)
173 : throw (::com::sun::star::beans::UnknownPropertyException,
174 : ::com::sun::star::lang::WrappedTargetException,
175 : ::com::sun::star::uno::RuntimeException);
176 :
177 : // XNamed
178 : virtual ::rtl::OUString SAL_CALL getName()
179 : throw (::com::sun::star::uno::RuntimeException);
180 : virtual void SAL_CALL setName(const ::rtl::OUString& rName)
181 : throw (::com::sun::star::uno::RuntimeException);
182 :
183 : // XTextContent
184 : virtual void SAL_CALL attach(
185 : const ::com::sun::star::uno::Reference<
186 : ::com::sun::star::text::XTextRange > & xTextRange)
187 : throw (::com::sun::star::lang::IllegalArgumentException,
188 : ::com::sun::star::uno::RuntimeException);
189 : virtual ::com::sun::star::uno::Reference<
190 : ::com::sun::star::text::XTextRange > SAL_CALL getAnchor()
191 : throw (::com::sun::star::uno::RuntimeException);
192 :
193 : };
194 :
195 4 : class SwXFieldmarkParameters
196 : : public ::cppu::WeakImplHelper1< ::com::sun::star::container::XNameContainer>
197 : , private SwClient
198 : {
199 : public:
200 2 : SwXFieldmarkParameters(::sw::mark::IFieldmark* const pFieldmark)
201 2 : {
202 2 : pFieldmark->Add(this);
203 2 : }
204 :
205 : // XNameContainer
206 : virtual void SAL_CALL insertByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
207 : virtual void SAL_CALL removeByName( const ::rtl::OUString& Name ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
208 : // XNameReplace
209 : virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
210 : // XNameAccess
211 : virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
212 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (::com::sun::star::uno::RuntimeException);
213 : virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException);
214 : // XElementAccess
215 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException);
216 : virtual ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException);
217 : protected:
218 : //SwClient
219 : virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew );
220 : private:
221 : ::sw::mark::IFieldmark::parameter_map_t* getCoreParameters() throw (::com::sun::star::uno::RuntimeException);
222 : };
223 :
224 : typedef cppu::ImplInheritanceHelper1< SwXBookmark,
225 : ::com::sun::star::text::XFormField > SwXFieldmark_Base;
226 :
227 18 : class SwXFieldmark
228 : : public SwXFieldmark_Base
229 : {
230 :
231 : private:
232 : ::sw::mark::ICheckboxFieldmark* getCheckboxFieldmark();
233 : bool isReplacementObject;
234 : public:
235 :
236 : static ::com::sun::star::uno::Reference<
237 : ::com::sun::star::text::XTextContent>
238 : CreateXFieldmark( SwDoc & rDoc, ::sw::mark::IMark & rMark );
239 :
240 : SwXFieldmark(bool isReplacementObject,
241 : ::sw::mark::IMark* pBkm = 0, SwDoc* pDoc = 0);
242 :
243 : virtual void attachToRange(
244 : const ::com::sun::star::uno::Reference<
245 : ::com::sun::star::text::XTextRange > & xTextRange)
246 : throw (::com::sun::star::lang::IllegalArgumentException,
247 : ::com::sun::star::uno::RuntimeException);
248 : virtual ::rtl::OUString SAL_CALL getFieldType(void)
249 : throw( ::com::sun::star::uno::RuntimeException );
250 : virtual void SAL_CALL setFieldType(const ::rtl::OUString& description )
251 : throw (::com::sun::star::uno::RuntimeException);
252 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > SAL_CALL getParameters( )
253 : throw (::com::sun::star::uno::RuntimeException);
254 : virtual void SAL_CALL setPropertyValue(
255 : const ::rtl::OUString& rPropertyName,
256 : const ::com::sun::star::uno::Any& rValue)
257 : throw (::com::sun::star::beans::UnknownPropertyException,
258 : ::com::sun::star::beans::PropertyVetoException,
259 : ::com::sun::star::lang::IllegalArgumentException,
260 : ::com::sun::star::lang::WrappedTargetException,
261 : ::com::sun::star::uno::RuntimeException);
262 :
263 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
264 : const ::rtl::OUString& rPropertyName)
265 : throw (::com::sun::star::beans::UnknownPropertyException,
266 : ::com::sun::star::lang::WrappedTargetException,
267 : ::com::sun::star::uno::RuntimeException);
268 : };
269 :
270 0 : class SwXODFCheckboxField : public SwXFieldmark
271 : {
272 : public:
273 : SwXODFCheckboxField( ::sw::mark::IMark* pBkm = 0, SwDoc* pDoc = 0) : SwXFieldmark(true,
274 : pBkm, pDoc) {}
275 : };
276 : #endif // SW_UNOBOOKMARK_HXX
277 :
278 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|