xref: /aoo42x/main/sw/inc/unobookmark.hxx (revision dec99bbd)
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     void registerInMark( ::sw::mark::IMark *const pBkmk );
85 
86 public:
87 
88     /// descriptor
89     SwXBookmark();
90 
91     static ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >
92         CreateXBookmark(SwDoc & rDoc, ::sw::mark::IMark & rBookmark);
93 
94     /// @return IMark for this, but only if it lives in pDoc
95     static ::sw::mark::IMark const* GetBookmarkInDoc(SwDoc const*const pDoc,
96             const ::com::sun::star::uno::Reference<
97                 ::com::sun::star::lang::XUnoTunnel> & xUT);
98 
99     // MetadatableMixin
100     virtual ::sfx2::Metadatable* GetCoreObject();
101     virtual ::com::sun::star::uno::Reference<
102         ::com::sun::star::frame::XModel > GetModel();
103 
104     static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
105 
106     // XUnoTunnel
107     virtual sal_Int64 SAL_CALL getSomething(
108             const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier)
109         throw (::com::sun::star::uno::RuntimeException);
110 
111     // XServiceInfo
112     virtual ::rtl::OUString SAL_CALL getImplementationName()
113         throw (::com::sun::star::uno::RuntimeException);
114     virtual sal_Bool SAL_CALL supportsService(
115             const ::rtl::OUString& rServiceName)
116         throw (::com::sun::star::uno::RuntimeException);
117     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
118         getSupportedServiceNames()
119         throw (::com::sun::star::uno::RuntimeException);
120 
121     // XComponent
122     virtual void SAL_CALL dispose()
123         throw (::com::sun::star::uno::RuntimeException);
124     virtual void SAL_CALL addEventListener(
125             const ::com::sun::star::uno::Reference<
126                 ::com::sun::star::lang::XEventListener > & xListener)
127         throw (::com::sun::star::uno::RuntimeException);
128     virtual void SAL_CALL removeEventListener(
129             const ::com::sun::star::uno::Reference<
130                 ::com::sun::star::lang::XEventListener > & xListener)
131         throw (::com::sun::star::uno::RuntimeException);
132 
133     // XPropertySet
134     virtual ::com::sun::star::uno::Reference<
135                 ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
136         getPropertySetInfo()
137         throw (::com::sun::star::uno::RuntimeException);
138     virtual void SAL_CALL setPropertyValue(
139             const ::rtl::OUString& rPropertyName,
140             const ::com::sun::star::uno::Any& rValue)
141         throw (::com::sun::star::beans::UnknownPropertyException,
142                 ::com::sun::star::beans::PropertyVetoException,
143                 ::com::sun::star::lang::IllegalArgumentException,
144                 ::com::sun::star::lang::WrappedTargetException,
145                 ::com::sun::star::uno::RuntimeException);
146     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
147             const ::rtl::OUString& rPropertyName)
148         throw (::com::sun::star::beans::UnknownPropertyException,
149                 ::com::sun::star::lang::WrappedTargetException,
150                 ::com::sun::star::uno::RuntimeException);
151     virtual void SAL_CALL addPropertyChangeListener(
152             const ::rtl::OUString& rPropertyName,
153             const ::com::sun::star::uno::Reference<
154                 ::com::sun::star::beans::XPropertyChangeListener >& xListener)
155         throw (::com::sun::star::beans::UnknownPropertyException,
156                 ::com::sun::star::lang::WrappedTargetException,
157                 ::com::sun::star::uno::RuntimeException);
158     virtual void SAL_CALL removePropertyChangeListener(
159             const ::rtl::OUString& rPropertyName,
160             const ::com::sun::star::uno::Reference<
161                 ::com::sun::star::beans::XPropertyChangeListener >& xListener)
162         throw (::com::sun::star::beans::UnknownPropertyException,
163                 ::com::sun::star::lang::WrappedTargetException,
164                 ::com::sun::star::uno::RuntimeException);
165     virtual void SAL_CALL addVetoableChangeListener(
166             const ::rtl::OUString& rPropertyName,
167             const ::com::sun::star::uno::Reference<
168                 ::com::sun::star::beans::XVetoableChangeListener >& xListener)
169         throw (::com::sun::star::beans::UnknownPropertyException,
170                 ::com::sun::star::lang::WrappedTargetException,
171                 ::com::sun::star::uno::RuntimeException);
172     virtual void SAL_CALL removeVetoableChangeListener(
173             const ::rtl::OUString& rPropertyName,
174             const ::com::sun::star::uno::Reference<
175                 ::com::sun::star::beans::XVetoableChangeListener >& xListener)
176         throw (::com::sun::star::beans::UnknownPropertyException,
177                 ::com::sun::star::lang::WrappedTargetException,
178                 ::com::sun::star::uno::RuntimeException);
179 
180     // XNamed
181     virtual ::rtl::OUString SAL_CALL getName()
182         throw (::com::sun::star::uno::RuntimeException);
183     virtual void SAL_CALL setName(const ::rtl::OUString& rName)
184         throw (::com::sun::star::uno::RuntimeException);
185 
186     // XTextContent
187     virtual void SAL_CALL attach(
188             const ::com::sun::star::uno::Reference<
189                 ::com::sun::star::text::XTextRange > & xTextRange)
190         throw (::com::sun::star::lang::IllegalArgumentException,
191                 ::com::sun::star::uno::RuntimeException);
192     virtual ::com::sun::star::uno::Reference<
193                 ::com::sun::star::text::XTextRange > SAL_CALL getAnchor()
194         throw (::com::sun::star::uno::RuntimeException);
195 
196 };
197 
198 class SwXFieldmarkParameters
199     : public ::cppu::WeakImplHelper1< ::com::sun::star::container::XNameContainer>
200     , private SwClient
201 {
202     public:
SwXFieldmarkParameters(::sw::mark::IFieldmark * const pFieldmark)203         SwXFieldmarkParameters(::sw::mark::IFieldmark* const pFieldmark)
204         {
205             pFieldmark->Add(this);
206         }
207 
208         // XNameContainer
209         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);
210         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);
211         // XNameReplace
212         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);
213         // XNameAccess
214         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);
215         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames(  ) throw (::com::sun::star::uno::RuntimeException);
216         virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException);
217         // XElementAccess
218         virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  ) throw (::com::sun::star::uno::RuntimeException);
219         virtual ::sal_Bool SAL_CALL hasElements(  ) throw (::com::sun::star::uno::RuntimeException);
220     protected:
221         //SwClient
222     virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew );
223     private:
224         ::sw::mark::IFieldmark::parameter_map_t* getCoreParameters() throw (::com::sun::star::uno::RuntimeException);
225 };
226 
227 typedef cppu::ImplInheritanceHelper1< SwXBookmark,
228     ::com::sun::star::text::XFormField > SwXFieldmark_Base;
229 
230 class SwXFieldmark
231     : public SwXFieldmark_Base
232 {
233 
234 private:
235 
236     bool isReplacementObject;
237 
238     SwXFieldmark(
239         bool _isReplacementObject,
240         ::sw::mark::IMark *const pMark,
241         SwDoc *const pDoc );
242 
243 public:
244 
245     // <SwXFieldmark> instance not attached to the document - property descriptor available
246     SwXFieldmark( bool isReplacementObject );
247 
248     // (as the parent class) newly created <SwXFieldmark> instances for an existing <IMark> instance needs to be registered in the Mark
249     static ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >
250         CreateXFieldmark(
251             SwDoc & rDoc,
252             ::sw::mark::IMark & rBookmark );
253 
254     virtual void attachToRange(
255             const ::com::sun::star::uno::Reference<
256                 ::com::sun::star::text::XTextRange > & xTextRange)
257         throw (::com::sun::star::lang::IllegalArgumentException,
258                 ::com::sun::star::uno::RuntimeException);
259     virtual ::rtl::OUString SAL_CALL getFieldType(void)
260         throw( ::com::sun::star::uno::RuntimeException );
261     virtual void SAL_CALL setFieldType(const ::rtl::OUString& description )
262         throw (::com::sun::star::uno::RuntimeException);
263     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > SAL_CALL getParameters(  )
264         throw (::com::sun::star::uno::RuntimeException);
265 
266 };
267 
268 #endif // SW_UNOBOOKMARK_HXX
269 
270