xref: /aoo41x/main/sw/inc/unobookmark.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SW_UNOBOOKMARK_HXX
29 #define SW_UNOBOOKMARK_HXX
30 
31 #include <com/sun/star/lang/XUnoTunnel.hpp>
32 #include <com/sun/star/lang/XServiceInfo.hpp>
33 #include <com/sun/star/beans/XPropertySet.hpp>
34 #include <com/sun/star/container/XNamed.hpp>
35 #include <com/sun/star/text/XTextContent.hpp>
36 #include <com/sun/star/text/XFormField.hpp>
37 
38 #include <cppuhelper/implbase5.hxx>
39 
40 #include <sfx2/Metadatable.hxx>
41 
42 #include <unobaseclass.hxx>
43 #include <IDocumentMarkAccess.hxx>
44 
45 
46 class SwDoc;
47 
48 
49 typedef ::cppu::ImplInheritanceHelper5
50 <   ::sfx2::MetadatableMixin
51 ,   ::com::sun::star::lang::XUnoTunnel
52 ,   ::com::sun::star::lang::XServiceInfo
53 ,   ::com::sun::star::beans::XPropertySet
54 ,   ::com::sun::star::container::XNamed
55 ,   ::com::sun::star::text::XTextContent
56 > SwXBookmark_Base;
57 
58 class SwXBookmark
59     : public SwXBookmark_Base
60 {
61 
62 private:
63 
64     class Impl;
65     ::sw::UnoImplPtr<Impl> m_pImpl;
66 
67 protected:
68 
69     void attachToRangeEx(
70             const ::com::sun::star::uno::Reference<
71                 ::com::sun::star::text::XTextRange > & xTextRange,
72             IDocumentMarkAccess::MarkType eType)
73         throw (::com::sun::star::lang::IllegalArgumentException,
74                 ::com::sun::star::uno::RuntimeException );
75     virtual void attachToRange(
76             const ::com::sun::star::uno::Reference<
77                 ::com::sun::star::text::XTextRange > & xTextRange)
78         throw (::com::sun::star::lang::IllegalArgumentException,
79                 ::com::sun::star::uno::RuntimeException);
80 
81     const ::sw::mark::IMark* GetBookmark() const;
82 
83     virtual ~SwXBookmark();
84 
85     /// @param pDoc and pMark != 0, but not & because of ImplInheritanceHelper
86     SwXBookmark(::sw::mark::IMark *const pMark, SwDoc *const pDoc);
87 
88 public:
89 
90     /// descriptor
91     SwXBookmark();
92 
93     static ::com::sun::star::uno::Reference<
94             ::com::sun::star::text::XTextContent>
95         CreateXBookmark(SwDoc & rDoc, ::sw::mark::IMark & rBookmark);
96 
97     /// @return IMark for this, but only if it lives in pDoc
98     static ::sw::mark::IMark const* GetBookmarkInDoc(SwDoc const*const pDoc,
99             const ::com::sun::star::uno::Reference<
100                 ::com::sun::star::lang::XUnoTunnel> & xUT);
101 
102     // MetadatableMixin
103     virtual ::sfx2::Metadatable* GetCoreObject();
104     virtual ::com::sun::star::uno::Reference<
105         ::com::sun::star::frame::XModel > GetModel();
106 
107     static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
108 
109     // XUnoTunnel
110     virtual sal_Int64 SAL_CALL getSomething(
111             const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier)
112         throw (::com::sun::star::uno::RuntimeException);
113 
114     // XServiceInfo
115     virtual ::rtl::OUString SAL_CALL getImplementationName()
116         throw (::com::sun::star::uno::RuntimeException);
117     virtual sal_Bool SAL_CALL supportsService(
118             const ::rtl::OUString& rServiceName)
119         throw (::com::sun::star::uno::RuntimeException);
120     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
121         getSupportedServiceNames()
122         throw (::com::sun::star::uno::RuntimeException);
123 
124     // XComponent
125     virtual void SAL_CALL dispose()
126         throw (::com::sun::star::uno::RuntimeException);
127     virtual void SAL_CALL addEventListener(
128             const ::com::sun::star::uno::Reference<
129                 ::com::sun::star::lang::XEventListener > & xListener)
130         throw (::com::sun::star::uno::RuntimeException);
131     virtual void SAL_CALL removeEventListener(
132             const ::com::sun::star::uno::Reference<
133                 ::com::sun::star::lang::XEventListener > & xListener)
134         throw (::com::sun::star::uno::RuntimeException);
135 
136     // XPropertySet
137     virtual ::com::sun::star::uno::Reference<
138                 ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
139         getPropertySetInfo()
140         throw (::com::sun::star::uno::RuntimeException);
141     virtual void SAL_CALL setPropertyValue(
142             const ::rtl::OUString& rPropertyName,
143             const ::com::sun::star::uno::Any& rValue)
144         throw (::com::sun::star::beans::UnknownPropertyException,
145                 ::com::sun::star::beans::PropertyVetoException,
146                 ::com::sun::star::lang::IllegalArgumentException,
147                 ::com::sun::star::lang::WrappedTargetException,
148                 ::com::sun::star::uno::RuntimeException);
149     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
150             const ::rtl::OUString& rPropertyName)
151         throw (::com::sun::star::beans::UnknownPropertyException,
152                 ::com::sun::star::lang::WrappedTargetException,
153                 ::com::sun::star::uno::RuntimeException);
154     virtual void SAL_CALL addPropertyChangeListener(
155             const ::rtl::OUString& rPropertyName,
156             const ::com::sun::star::uno::Reference<
157                 ::com::sun::star::beans::XPropertyChangeListener >& xListener)
158         throw (::com::sun::star::beans::UnknownPropertyException,
159                 ::com::sun::star::lang::WrappedTargetException,
160                 ::com::sun::star::uno::RuntimeException);
161     virtual void SAL_CALL removePropertyChangeListener(
162             const ::rtl::OUString& rPropertyName,
163             const ::com::sun::star::uno::Reference<
164                 ::com::sun::star::beans::XPropertyChangeListener >& xListener)
165         throw (::com::sun::star::beans::UnknownPropertyException,
166                 ::com::sun::star::lang::WrappedTargetException,
167                 ::com::sun::star::uno::RuntimeException);
168     virtual void SAL_CALL addVetoableChangeListener(
169             const ::rtl::OUString& rPropertyName,
170             const ::com::sun::star::uno::Reference<
171                 ::com::sun::star::beans::XVetoableChangeListener >& xListener)
172         throw (::com::sun::star::beans::UnknownPropertyException,
173                 ::com::sun::star::lang::WrappedTargetException,
174                 ::com::sun::star::uno::RuntimeException);
175     virtual void SAL_CALL removeVetoableChangeListener(
176             const ::rtl::OUString& rPropertyName,
177             const ::com::sun::star::uno::Reference<
178                 ::com::sun::star::beans::XVetoableChangeListener >& xListener)
179         throw (::com::sun::star::beans::UnknownPropertyException,
180                 ::com::sun::star::lang::WrappedTargetException,
181                 ::com::sun::star::uno::RuntimeException);
182 
183     // XNamed
184     virtual ::rtl::OUString SAL_CALL getName()
185         throw (::com::sun::star::uno::RuntimeException);
186     virtual void SAL_CALL setName(const ::rtl::OUString& rName)
187         throw (::com::sun::star::uno::RuntimeException);
188 
189     // XTextContent
190     virtual void SAL_CALL attach(
191             const ::com::sun::star::uno::Reference<
192                 ::com::sun::star::text::XTextRange > & xTextRange)
193         throw (::com::sun::star::lang::IllegalArgumentException,
194                 ::com::sun::star::uno::RuntimeException);
195     virtual ::com::sun::star::uno::Reference<
196                 ::com::sun::star::text::XTextRange > SAL_CALL getAnchor()
197         throw (::com::sun::star::uno::RuntimeException);
198 
199 };
200 
201 class SwXFieldmarkParameters
202     : public ::cppu::WeakImplHelper1< ::com::sun::star::container::XNameContainer>
203     , private SwClient
204 {
205     public:
206         SwXFieldmarkParameters(::sw::mark::IFieldmark* const pFieldmark)
207         {
208             pFieldmark->Add(this);
209         }
210 
211         // XNameContainer
212         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);
213         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);
214         // XNameReplace
215         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);
216         // XNameAccess
217         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);
218         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames(  ) throw (::com::sun::star::uno::RuntimeException);
219         virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException);
220         // XElementAccess
221         virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  ) throw (::com::sun::star::uno::RuntimeException);
222         virtual ::sal_Bool SAL_CALL hasElements(  ) throw (::com::sun::star::uno::RuntimeException);
223     protected:
224         //SwClient
225     virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew );
226     private:
227         ::sw::mark::IFieldmark::parameter_map_t* getCoreParameters() throw (::com::sun::star::uno::RuntimeException);
228 };
229 
230 typedef cppu::ImplInheritanceHelper1< SwXBookmark,
231     ::com::sun::star::text::XFormField > SwXFieldmark_Base;
232 
233 class SwXFieldmark
234     : public SwXFieldmark_Base
235 {
236 
237 private:
238 
239     bool isReplacementObject;
240 
241 public:
242 
243     SwXFieldmark(bool isReplacementObject,
244             ::sw::mark::IMark* pBkm = 0, SwDoc* pDoc = 0);
245 
246     virtual void attachToRange(
247             const ::com::sun::star::uno::Reference<
248                 ::com::sun::star::text::XTextRange > & xTextRange)
249         throw (::com::sun::star::lang::IllegalArgumentException,
250                 ::com::sun::star::uno::RuntimeException);
251     virtual ::rtl::OUString SAL_CALL getFieldType(void)
252         throw( ::com::sun::star::uno::RuntimeException );
253     virtual void SAL_CALL setFieldType(const ::rtl::OUString& description )
254         throw (::com::sun::star::uno::RuntimeException);
255     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > SAL_CALL getParameters(  )
256         throw (::com::sun::star::uno::RuntimeException);
257 
258 };
259 
260 #endif // SW_UNOBOOKMARK_HXX
261 
262