xref: /aoo42x/main/sw/inc/unoport.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 #ifndef _UNOPORT_HXX
24 #define _UNOPORT_HXX
25 
26 #include <unocrsr.hxx>
27 #include <unoevtlstnr.hxx>
28 #include <calbck.hxx>
29 
30 #include <com/sun/star/beans/XPropertySet.hpp>
31 #include <com/sun/star/text/XTextRange.hpp>
32 #include <com/sun/star/container/XEnumeration.hpp>
33 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
34 #include <com/sun/star/container/XEnumerationAccess.hpp>
35 #include <com/sun/star/beans/XPropertyState.hpp>
36 #include <com/sun/star/beans/XMultiPropertySet.hpp>
37 #include <com/sun/star/beans/XTolerantMultiPropertySet.hpp>
38 #include <com/sun/star/text/XTextField.hpp>
39 #include <com/sun/star/text/XFootnote.hpp>
40 #include <com/sun/star/lang/XServiceInfo.hpp>
41 #include <com/sun/star/lang/XUnoTunnel.hpp>
42 #include <cppuhelper/implbase8.hxx>
43 #include <cppuhelper/implbase3.hxx>
44 #include <svl/itemprop.hxx>
45 
46 #include <memory>
47 #include <deque>
48 
49 
50 class SwFmtFld;
51 class SwFrmFmt;
52 class SwTxtRuby;
53 
54 
55 typedef ::std::deque<
56     ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > >
57     TextRangeList_t;
58 
59 
60 /* -----------------29.05.98 14:42-------------------
61  *
62  * --------------------------------------------------*/
63 enum SwTextPortionType
64 {
65 	PORTION_TEXT,
66 	PORTION_FIELD,
67 	PORTION_FRAME,
68 	PORTION_FOOTNOTE,
69 // obsolete!	PORTION_CONTROL_CHAR,
70 	PORTION_REFMARK_START,
71 	PORTION_REFMARK_END,
72 	PORTION_TOXMARK_START,
73 	PORTION_TOXMARK_END,
74 	PORTION_BOOKMARK_START,
75 	PORTION_BOOKMARK_END,
76 	PORTION_REDLINE_START,
77 	PORTION_REDLINE_END,
78 	PORTION_RUBY_START,
79 	PORTION_RUBY_END,
80     PORTION_SOFT_PAGEBREAK,
81     PORTION_META,
82 	PORTION_FIELD_START,
83 	PORTION_FIELD_END,
84 	PORTION_FIELD_START_END,
85     PORTION_ANNOTATION,
86     PORTION_ANNOTATION_END
87 };
88 
89 
90 class SwXTextPortion : public cppu::WeakImplHelper8
91 <
92     ::com::sun::star::beans::XTolerantMultiPropertySet,
93     ::com::sun::star::beans::XMultiPropertySet,
94     ::com::sun::star::beans::XPropertySet,
95 	::com::sun::star::text::XTextRange,
96 	::com::sun::star::beans::XPropertyState,
97 	::com::sun::star::container::XContentEnumerationAccess,
98     ::com::sun::star::lang::XUnoTunnel,
99     ::com::sun::star::lang::XServiceInfo
100 >,
101 	public SwClient
102 {
103 private:
104 
105     SwEventListenerContainer    m_ListenerContainer;
106     const SfxItemPropertySet *  m_pPropSet;
107     const ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >
108         m_xParentText;
109     ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >
110         m_xRefMark;
111     ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >
112         m_xTOXMark;
113     ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >
114         m_xBookmark;
115     ::com::sun::star::uno::Reference< ::com::sun::star::text::XFootnote >
116         m_xFootnote;
117     ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextField >
118         m_xTextField;
119     ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >
120         m_xMeta;
121     ::std::auto_ptr< ::com::sun::star::uno::Any > m_pRubyText;
122     ::std::auto_ptr< ::com::sun::star::uno::Any > m_pRubyStyle;
123     ::std::auto_ptr< ::com::sun::star::uno::Any > m_pRubyAdjust;
124     ::std::auto_ptr< ::com::sun::star::uno::Any > m_pRubyIsAbove;
125 
126     const SwDepend              m_FrameDepend;
127     SwFrmFmt *                  m_pFrameFmt;
128     const SwTextPortionType     m_ePortionType;
129 
130     bool                        m_bIsCollapsed;
131 
132     SwFmtFld * GetFldFmt(bool bInit = false);
133 
134     void init(const SwUnoCrsr* pPortionCursor);
135 
136 protected:
137 
138     void SAL_CALL SetPropertyValues_Impl(
139         const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames,
140         const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues )
141             throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
142     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL GetPropertyValues_Impl(
143         const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames )
144             throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
145 
146     void        GetPropertyValues( const ::rtl::OUString *pPropertyNames,
147                                     ::com::sun::star::uno::Any *pValues,
148                                     sal_Int32 nLength );
149 
150     void GetPropertyValue( ::com::sun::star::uno::Any &rVal,
151                 const SfxItemPropertySimpleEntry& rEntry, SwUnoCrsr *pUnoCrsr, SfxItemSet *&pSet );
152 
153     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::GetDirectPropertyTolerantResult > SAL_CALL GetPropertyValuesTolerant_Impl(
154         const ::com::sun::star::uno::Sequence< rtl::OUString >& rPropertyNames,
155         sal_Bool bDirectValuesOnly ) throw (::com::sun::star::uno::RuntimeException);
156 
157     virtual ~SwXTextPortion();
158 
159 	//SwClient
160    virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew);
161 
162 public:
163 	SwXTextPortion(const SwUnoCrsr* pPortionCrsr, ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > const& rParent, SwTextPortionType	eType	);
164 	SwXTextPortion(const SwUnoCrsr* pPortionCrsr, ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > const& rParent, SwFrmFmt& rFmt );
165 
166     // for Ruby
167     SwXTextPortion(const SwUnoCrsr* pPortionCrsr,
168         SwTxtRuby const& rAttr,
169         ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >
170             const& xParent,
171         sal_Bool bIsEnd );
172 
173 	//XTextRange
174     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >  SAL_CALL getText() throw( ::com::sun::star::uno::RuntimeException );
175     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL  getStart() throw( ::com::sun::star::uno::RuntimeException );
176     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL   getEnd() throw( ::com::sun::star::uno::RuntimeException );
177     virtual rtl::OUString SAL_CALL  getString() throw( ::com::sun::star::uno::RuntimeException );
178 	virtual void SAL_CALL  setString(const rtl::OUString& aString) throw( ::com::sun::star::uno::RuntimeException );
179 
180     //XTolerantMultiPropertySet
181     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::SetPropertyTolerantFailed > SAL_CALL setPropertyValuesTolerant( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
182     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::GetPropertyTolerantResult > SAL_CALL getPropertyValuesTolerant( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::uno::RuntimeException);
183     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::GetDirectPropertyTolerantResult > SAL_CALL getDirectPropertyValuesTolerant( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::uno::RuntimeException);
184 
185     //XMultiPropertySet
186 //    virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
187     virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
188     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw(::com::sun::star::uno::RuntimeException);
189     virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
190     virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
191     virtual void SAL_CALL firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
192 
193     //XPropertySet
194     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
195     virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
196     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
197     virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
198     virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
199     virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
200     virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
201 
202 	//XPropertyState
203     virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
204     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
205     virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
206     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
207 
208 	//XTextContent
209 	virtual void SAL_CALL attach(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
210     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor(  ) throw(::com::sun::star::uno::RuntimeException);
211 
212 	//XComponent
213     virtual void SAL_CALL dispose() throw( ::com::sun::star::uno::RuntimeException );
214 	virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException );
215 	virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException );
216 
217     //XUnoTunnel
218 	static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId();
219 	virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
220 
221     //XServiceInfo
222     virtual rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
223     virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException );
224     virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
225 
226 	//XContentEnumerationAccess
227 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration >  SAL_CALL createContentEnumeration(const rtl::OUString& aServiceName) throw( ::com::sun::star::uno::RuntimeException );
228     virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getAvailableServiceNames() throw( ::com::sun::star::uno::RuntimeException );
229 
SetRefMark(::com::sun::star::uno::Reference<::com::sun::star::text::XTextContent> xMark)230     void SetRefMark( ::com::sun::star::uno::Reference<
231                         ::com::sun::star::text::XTextContent >  xMark)
232     { m_xRefMark = xMark; }
233 
SetTOXMark(::com::sun::star::uno::Reference<::com::sun::star::text::XTextContent> xMark)234     void SetTOXMark( ::com::sun::star::uno::Reference<
235                         ::com::sun::star::text::XTextContent >  xMark)
236     { m_xTOXMark = xMark; }
237 
SetBookmark(::com::sun::star::uno::Reference<::com::sun::star::text::XTextContent> xMark)238     void SetBookmark( ::com::sun::star::uno::Reference<
239                         ::com::sun::star::text::XTextContent >  xMark)
240     { m_xBookmark = xMark; }
241 
SetFootnote(::com::sun::star::uno::Reference<::com::sun::star::text::XFootnote> xNote)242     void SetFootnote( ::com::sun::star::uno::Reference<
243                         ::com::sun::star::text::XFootnote > xNote)
244     { m_xFootnote = xNote; }
245 
SetTextField(::com::sun::star::uno::Reference<::com::sun::star::text::XTextField> xField)246     void SetTextField( ::com::sun::star::uno::Reference<
247                         ::com::sun::star::text::XTextField> xField)
248     { m_xTextField = xField; }
249 
SetMeta(::com::sun::star::uno::Reference<::com::sun::star::text::XTextContent> xMeta)250     void SetMeta( ::com::sun::star::uno::Reference<
251                         ::com::sun::star::text::XTextContent >  xMeta)
252     { m_xMeta = xMeta; }
253 
IsCollapsed() const254     bool IsCollapsed() const { return m_bIsCollapsed; }
SetCollapsed(bool bSet)255     void SetCollapsed(bool bSet)        { m_bIsCollapsed = bSet;}
256 
GetTextPortionType() const257     SwTextPortionType GetTextPortionType() const { return m_ePortionType; }
258 
GetCursor() const259     SwUnoCrsr* GetCursor() const
260     {return static_cast<SwUnoCrsr*>(const_cast<SwModify*>(GetRegisteredIn()));}
261 };
262 
263 /* -----------------29.05.98 14:42-------------------
264  *
265  * --------------------------------------------------*/
266 class SwXTextPortionEnumeration
267     : public ::cppu::WeakImplHelper3
268         < ::com::sun::star::container::XEnumeration
269         , ::com::sun::star::lang::XServiceInfo
270         , ::com::sun::star::lang::XUnoTunnel
271         >
272    , public SwClient
273 {
274     TextRangeList_t m_Portions; // contains all portions, filled by ctor
275 
GetCursor() const276     SwUnoCrsr*          GetCursor() const
277     {return static_cast<SwUnoCrsr*>(const_cast<SwModify*>(GetRegisteredIn()));}
278 
279 protected:
280     virtual ~SwXTextPortionEnumeration();
281 
282 public:
283     SwXTextPortionEnumeration(SwPaM& rParaCrsr,
284             ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >
285                 const & xParent,
286             const sal_Int32 nStart, const sal_Int32 nEnd );
287 
288     SwXTextPortionEnumeration(SwPaM& rParaCrsr,
289         TextRangeList_t const & rPortions );
290 
291 
292     static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId();
293 
294     //XUnoTunnel
295     virtual sal_Int64 SAL_CALL getSomething(
296             const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier )
297         throw(::com::sun::star::uno::RuntimeException);
298 
299     //XEnumeration
300     virtual sal_Bool SAL_CALL hasMoreElements()
301         throw( ::com::sun::star::uno::RuntimeException );
302     virtual ::com::sun::star::uno::Any SAL_CALL nextElement()
303         throw( ::com::sun::star::container::NoSuchElementException,
304                ::com::sun::star::lang::WrappedTargetException,
305                ::com::sun::star::uno::RuntimeException );
306 
307     //XServiceInfo
308     virtual rtl::OUString SAL_CALL getImplementationName()
309         throw( ::com::sun::star::uno::RuntimeException );
310     virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName)
311         throw( ::com::sun::star::uno::RuntimeException );
312     virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
313         getSupportedServiceNames()
314         throw( ::com::sun::star::uno::RuntimeException );
315 protected:
316     //SwClient
317     virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew);
318 };
319 
320 #endif
321