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 INCLUDED_SW_SOURCE_CORE_INC_UNOBOOKMARK_HXX
21 : #define INCLUDED_SW_SOURCE_CORE_INC_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 : class SwDoc;
38 :
39 : typedef ::cppu::ImplInheritanceHelper5
40 : < ::sfx2::MetadatableMixin
41 : , ::com::sun::star::lang::XUnoTunnel
42 : , ::com::sun::star::lang::XServiceInfo
43 : , ::com::sun::star::beans::XPropertySet
44 : , ::com::sun::star::container::XNamed
45 : , ::com::sun::star::text::XTextContent
46 : > SwXBookmark_Base;
47 :
48 : class SwXBookmark
49 : : public SwXBookmark_Base
50 : {
51 :
52 : private:
53 :
54 : class Impl;
55 : ::sw::UnoImplPtr<Impl> m_pImpl;
56 :
57 : protected:
58 :
59 : void attachToRangeEx(
60 : const ::com::sun::star::uno::Reference<
61 : ::com::sun::star::text::XTextRange > & xTextRange,
62 : IDocumentMarkAccess::MarkType eType)
63 : throw (::com::sun::star::lang::IllegalArgumentException,
64 : ::com::sun::star::uno::RuntimeException );
65 : virtual void attachToRange(
66 : const ::com::sun::star::uno::Reference<
67 : ::com::sun::star::text::XTextRange > & xTextRange)
68 : throw (::com::sun::star::lang::IllegalArgumentException,
69 : ::com::sun::star::uno::RuntimeException);
70 :
71 : const ::sw::mark::IMark* GetBookmark() const;
72 :
73 : void registerInMark( SwXBookmark& rXMark, ::sw::mark::IMark* const pMarkBase );
74 :
75 : virtual ~SwXBookmark();
76 :
77 : /// @param pDoc and pMark != 0, but not & because of ImplInheritanceHelper
78 : SwXBookmark(::sw::mark::IMark *const pMark, SwDoc *const pDoc);
79 :
80 : public:
81 :
82 : /// descriptor
83 : SwXBookmark();
84 :
85 : static ::com::sun::star::uno::Reference<
86 : ::com::sun::star::text::XTextContent>
87 : CreateXBookmark(SwDoc & rDoc, ::sw::mark::IMark & rBookmark);
88 :
89 : /// @return IMark for this, but only if it lives in pDoc
90 : static ::sw::mark::IMark const* GetBookmarkInDoc(SwDoc const*const pDoc,
91 : const ::com::sun::star::uno::Reference<
92 : ::com::sun::star::lang::XUnoTunnel> & xUT);
93 :
94 : // MetadatableMixin
95 : virtual ::sfx2::Metadatable* GetCoreObject() SAL_OVERRIDE;
96 : virtual ::com::sun::star::uno::Reference<
97 : ::com::sun::star::frame::XModel > GetModel() SAL_OVERRIDE;
98 :
99 : static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
100 :
101 : // XUnoTunnel
102 : virtual sal_Int64 SAL_CALL getSomething(
103 : const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier)
104 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
105 :
106 : // XServiceInfo
107 : virtual OUString SAL_CALL getImplementationName()
108 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
109 : virtual sal_Bool SAL_CALL supportsService(
110 : const OUString& rServiceName)
111 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
112 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL
113 : getSupportedServiceNames()
114 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
115 :
116 : // XComponent
117 : virtual void SAL_CALL dispose()
118 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
119 : virtual void SAL_CALL addEventListener(
120 : const ::com::sun::star::uno::Reference<
121 : ::com::sun::star::lang::XEventListener > & xListener)
122 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
123 : virtual void SAL_CALL removeEventListener(
124 : const ::com::sun::star::uno::Reference<
125 : ::com::sun::star::lang::XEventListener > & xListener)
126 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
127 :
128 : // XPropertySet
129 : virtual ::com::sun::star::uno::Reference<
130 : ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
131 : getPropertySetInfo()
132 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
133 : virtual void SAL_CALL setPropertyValue(
134 : const OUString& rPropertyName,
135 : const ::com::sun::star::uno::Any& rValue)
136 : throw (::com::sun::star::beans::UnknownPropertyException,
137 : ::com::sun::star::beans::PropertyVetoException,
138 : ::com::sun::star::lang::IllegalArgumentException,
139 : ::com::sun::star::lang::WrappedTargetException,
140 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
141 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
142 : const OUString& rPropertyName)
143 : throw (::com::sun::star::beans::UnknownPropertyException,
144 : ::com::sun::star::lang::WrappedTargetException,
145 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
146 : virtual void SAL_CALL addPropertyChangeListener(
147 : const OUString& rPropertyName,
148 : const ::com::sun::star::uno::Reference<
149 : ::com::sun::star::beans::XPropertyChangeListener >& xListener)
150 : throw (::com::sun::star::beans::UnknownPropertyException,
151 : ::com::sun::star::lang::WrappedTargetException,
152 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
153 : virtual void SAL_CALL removePropertyChangeListener(
154 : const OUString& rPropertyName,
155 : const ::com::sun::star::uno::Reference<
156 : ::com::sun::star::beans::XPropertyChangeListener >& xListener)
157 : throw (::com::sun::star::beans::UnknownPropertyException,
158 : ::com::sun::star::lang::WrappedTargetException,
159 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
160 : virtual void SAL_CALL addVetoableChangeListener(
161 : const OUString& rPropertyName,
162 : const ::com::sun::star::uno::Reference<
163 : ::com::sun::star::beans::XVetoableChangeListener >& xListener)
164 : throw (::com::sun::star::beans::UnknownPropertyException,
165 : ::com::sun::star::lang::WrappedTargetException,
166 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
167 : virtual void SAL_CALL removeVetoableChangeListener(
168 : const OUString& rPropertyName,
169 : const ::com::sun::star::uno::Reference<
170 : ::com::sun::star::beans::XVetoableChangeListener >& xListener)
171 : throw (::com::sun::star::beans::UnknownPropertyException,
172 : ::com::sun::star::lang::WrappedTargetException,
173 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
174 :
175 : // XNamed
176 : virtual OUString SAL_CALL getName()
177 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
178 : virtual void SAL_CALL setName(const OUString& rName)
179 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
180 :
181 : // XTextContent
182 : virtual void SAL_CALL attach(
183 : const ::com::sun::star::uno::Reference<
184 : ::com::sun::star::text::XTextRange > & xTextRange)
185 : throw (::com::sun::star::lang::IllegalArgumentException,
186 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
187 : virtual ::com::sun::star::uno::Reference<
188 : ::com::sun::star::text::XTextRange > SAL_CALL getAnchor()
189 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
190 :
191 : };
192 :
193 0 : class SwXFieldmarkParameters
194 : : public ::cppu::WeakImplHelper1< ::com::sun::star::container::XNameContainer>
195 : , private SwClient
196 : {
197 : public:
198 0 : SwXFieldmarkParameters(::sw::mark::IFieldmark* const pFieldmark)
199 0 : {
200 0 : pFieldmark->Add(this);
201 0 : }
202 :
203 : // XNameContainer
204 : virtual void SAL_CALL insertByName( const 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, std::exception) SAL_OVERRIDE;
205 : virtual void SAL_CALL removeByName( const OUString& Name ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
206 : // XNameReplace
207 : virtual void SAL_CALL replaceByName( const 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, std::exception) SAL_OVERRIDE;
208 : // XNameAccess
209 : virtual ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
210 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
211 : virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
212 : // XElementAccess
213 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
214 : virtual sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
215 : protected:
216 : //SwClient
217 : virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ) SAL_OVERRIDE;
218 : private:
219 : ::sw::mark::IFieldmark::parameter_map_t* getCoreParameters() throw (::com::sun::star::uno::RuntimeException);
220 : };
221 :
222 : typedef cppu::ImplInheritanceHelper1< SwXBookmark,
223 : ::com::sun::star::text::XFormField > SwXFieldmark_Base;
224 :
225 0 : class SwXFieldmark
226 : : public SwXFieldmark_Base
227 : {
228 :
229 : private:
230 : ::sw::mark::ICheckboxFieldmark* getCheckboxFieldmark();
231 : bool isReplacementObject;
232 : public:
233 :
234 : static ::com::sun::star::uno::Reference<
235 : ::com::sun::star::text::XTextContent>
236 : CreateXFieldmark( SwDoc & rDoc, ::sw::mark::IMark & rMark );
237 :
238 : SwXFieldmark(bool isReplacementObject,
239 : ::sw::mark::IMark* pBkm = 0, SwDoc* pDoc = 0);
240 :
241 : virtual void attachToRange(
242 : const ::com::sun::star::uno::Reference<
243 : ::com::sun::star::text::XTextRange > & xTextRange)
244 : throw (::com::sun::star::lang::IllegalArgumentException,
245 : ::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
246 : virtual OUString SAL_CALL getFieldType(void)
247 : throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
248 : virtual void SAL_CALL setFieldType(const OUString& description )
249 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
250 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > SAL_CALL getParameters( )
251 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
252 : virtual void SAL_CALL setPropertyValue(
253 : const OUString& rPropertyName,
254 : const ::com::sun::star::uno::Any& rValue)
255 : throw (::com::sun::star::beans::UnknownPropertyException,
256 : ::com::sun::star::beans::PropertyVetoException,
257 : ::com::sun::star::lang::IllegalArgumentException,
258 : ::com::sun::star::lang::WrappedTargetException,
259 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
260 :
261 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
262 : const OUString& rPropertyName)
263 : throw (::com::sun::star::beans::UnknownPropertyException,
264 : ::com::sun::star::lang::WrappedTargetException,
265 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
266 : };
267 :
268 : class SwXODFCheckboxField : public SwXFieldmark
269 : {
270 : public:
271 : SwXODFCheckboxField( ::sw::mark::IMark* pBkm = 0, SwDoc* pDoc = 0) : SwXFieldmark(true,
272 : pBkm, pDoc) {}
273 : };
274 : #endif // INCLUDED_SW_SOURCE_CORE_INC_UNOBOOKMARK_HXX
275 :
276 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|