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