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