xref: /aoo42x/main/sw/inc/unoport.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 #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 };
86 
87 
88 class SwXTextPortion : public cppu::WeakImplHelper8
89 <
90     ::com::sun::star::beans::XTolerantMultiPropertySet,
91     ::com::sun::star::beans::XMultiPropertySet,
92     ::com::sun::star::beans::XPropertySet,
93 	::com::sun::star::text::XTextRange,
94 	::com::sun::star::beans::XPropertyState,
95 	::com::sun::star::container::XContentEnumerationAccess,
96     ::com::sun::star::lang::XUnoTunnel,
97     ::com::sun::star::lang::XServiceInfo
98 >,
99 	public SwClient
100 {
101 private:
102 
103     SwEventListenerContainer    m_ListenerContainer;
104     const SfxItemPropertySet *  m_pPropSet;
105     const ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >
106         m_xParentText;
107     ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >
108         m_xRefMark;
109     ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >
110         m_xTOXMark;
111     ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >
112         m_xBookmark;
113     ::com::sun::star::uno::Reference< ::com::sun::star::text::XFootnote >
114         m_xFootnote;
115     ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextField >
116         m_xTextField;
117     ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >
118         m_xMeta;
119     ::std::auto_ptr< ::com::sun::star::uno::Any > m_pRubyText;
120     ::std::auto_ptr< ::com::sun::star::uno::Any > m_pRubyStyle;
121     ::std::auto_ptr< ::com::sun::star::uno::Any > m_pRubyAdjust;
122     ::std::auto_ptr< ::com::sun::star::uno::Any > m_pRubyIsAbove;
123 
124     const SwDepend              m_FrameDepend;
125     SwFrmFmt *                  m_pFrameFmt;
126     const SwTextPortionType     m_ePortionType;
127 
128     bool                        m_bIsCollapsed;
129 
130     SwFmtFld * GetFldFmt(bool bInit = false);
131 
132     void init(const SwUnoCrsr* pPortionCursor);
133 
134 protected:
135 
136     void SAL_CALL SetPropertyValues_Impl(
137         const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames,
138         const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues )
139             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);
140     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL GetPropertyValues_Impl(
141         const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames )
142             throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
143 
144     void        GetPropertyValues( const ::rtl::OUString *pPropertyNames,
145                                     ::com::sun::star::uno::Any *pValues,
146                                     sal_Int32 nLength );
147 
148     void GetPropertyValue( ::com::sun::star::uno::Any &rVal,
149                 const SfxItemPropertySimpleEntry& rEntry, SwUnoCrsr *pUnoCrsr, SfxItemSet *&pSet );
150 
151     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::GetDirectPropertyTolerantResult > SAL_CALL GetPropertyValuesTolerant_Impl(
152         const ::com::sun::star::uno::Sequence< rtl::OUString >& rPropertyNames,
153         sal_Bool bDirectValuesOnly ) throw (::com::sun::star::uno::RuntimeException);
154 
155     virtual ~SwXTextPortion();
156 
157 	//SwClient
158    virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew);
159 
160 public:
161 	SwXTextPortion(const SwUnoCrsr* pPortionCrsr, ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > const& rParent, SwTextPortionType	eType	);
162 	SwXTextPortion(const SwUnoCrsr* pPortionCrsr, ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > const& rParent, SwFrmFmt& rFmt );
163 
164     // for Ruby
165     SwXTextPortion(const SwUnoCrsr* pPortionCrsr,
166         SwTxtRuby const& rAttr,
167         ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >
168             const& xParent,
169         sal_Bool bIsEnd );
170 
171 	//XTextRange
172     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >  SAL_CALL getText() throw( ::com::sun::star::uno::RuntimeException );
173     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL  getStart() throw( ::com::sun::star::uno::RuntimeException );
174     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL   getEnd() throw( ::com::sun::star::uno::RuntimeException );
175     virtual rtl::OUString SAL_CALL  getString() throw( ::com::sun::star::uno::RuntimeException );
176 	virtual void SAL_CALL  setString(const rtl::OUString& aString) throw( ::com::sun::star::uno::RuntimeException );
177 
178     //XTolerantMultiPropertySet
179     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);
180     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);
181     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);
182 
183     //XMultiPropertySet
184 //    virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
185     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);
186     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);
187     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);
188     virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
189     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);
190 
191     //XPropertySet
192     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
193     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);
194     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);
195     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);
196     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);
197     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);
198     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);
199 
200 	//XPropertyState
201     virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
202     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);
203     virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
204     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);
205 
206 	//XTextContent
207 	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 );
208     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor(  ) throw(::com::sun::star::uno::RuntimeException);
209 
210 	//XComponent
211     virtual void SAL_CALL dispose() throw( ::com::sun::star::uno::RuntimeException );
212 	virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException );
213 	virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException );
214 
215     //XUnoTunnel
216 	static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId();
217 	virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
218 
219     //XServiceInfo
220     virtual rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
221     virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException );
222     virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
223 
224 	//XContentEnumerationAccess
225 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration >  SAL_CALL createContentEnumeration(const rtl::OUString& aServiceName) throw( ::com::sun::star::uno::RuntimeException );
226     virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getAvailableServiceNames() throw( ::com::sun::star::uno::RuntimeException );
227 
228     void SetRefMark( ::com::sun::star::uno::Reference<
229                         ::com::sun::star::text::XTextContent >  xMark)
230     { m_xRefMark = xMark; }
231 
232     void SetTOXMark( ::com::sun::star::uno::Reference<
233                         ::com::sun::star::text::XTextContent >  xMark)
234     { m_xTOXMark = xMark; }
235 
236     void SetBookmark( ::com::sun::star::uno::Reference<
237                         ::com::sun::star::text::XTextContent >  xMark)
238     { m_xBookmark = xMark; }
239 
240     void SetFootnote( ::com::sun::star::uno::Reference<
241                         ::com::sun::star::text::XFootnote > xNote)
242     { m_xFootnote = xNote; }
243 
244     void SetTextField( ::com::sun::star::uno::Reference<
245                         ::com::sun::star::text::XTextField> xField)
246     { m_xTextField = xField; }
247 
248     void SetMeta( ::com::sun::star::uno::Reference<
249                         ::com::sun::star::text::XTextContent >  xMeta)
250     { m_xMeta = xMeta; }
251 
252     bool IsCollapsed() const { return m_bIsCollapsed; }
253     void SetCollapsed(bool bSet)        { m_bIsCollapsed = bSet;}
254 
255     SwTextPortionType GetTextPortionType() const { return m_ePortionType; }
256 
257     SwUnoCrsr* GetCursor() const
258     {return static_cast<SwUnoCrsr*>(const_cast<SwModify*>(GetRegisteredIn()));}
259 };
260 
261 /* -----------------29.05.98 14:42-------------------
262  *
263  * --------------------------------------------------*/
264 class SwXTextPortionEnumeration
265     : public ::cppu::WeakImplHelper3
266         < ::com::sun::star::container::XEnumeration
267         , ::com::sun::star::lang::XServiceInfo
268         , ::com::sun::star::lang::XUnoTunnel
269         >
270    , public SwClient
271 {
272     TextRangeList_t m_Portions; // contains all portions, filled by ctor
273 
274     SwUnoCrsr*          GetCursor() const
275     {return static_cast<SwUnoCrsr*>(const_cast<SwModify*>(GetRegisteredIn()));}
276 
277 protected:
278     virtual ~SwXTextPortionEnumeration();
279 
280 public:
281     SwXTextPortionEnumeration(SwPaM& rParaCrsr,
282             ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >
283                 const & xParent,
284             const sal_Int32 nStart, const sal_Int32 nEnd );
285 
286     SwXTextPortionEnumeration(SwPaM& rParaCrsr,
287         TextRangeList_t const & rPortions );
288 
289 
290     static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId();
291 
292     //XUnoTunnel
293     virtual sal_Int64 SAL_CALL getSomething(
294             const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier )
295         throw(::com::sun::star::uno::RuntimeException);
296 
297     //XEnumeration
298     virtual sal_Bool SAL_CALL hasMoreElements()
299         throw( ::com::sun::star::uno::RuntimeException );
300     virtual ::com::sun::star::uno::Any SAL_CALL nextElement()
301         throw( ::com::sun::star::container::NoSuchElementException,
302                ::com::sun::star::lang::WrappedTargetException,
303                ::com::sun::star::uno::RuntimeException );
304 
305     //XServiceInfo
306     virtual rtl::OUString SAL_CALL getImplementationName()
307         throw( ::com::sun::star::uno::RuntimeException );
308     virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName)
309         throw( ::com::sun::star::uno::RuntimeException );
310     virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
311         getSupportedServiceNames()
312         throw( ::com::sun::star::uno::RuntimeException );
313 protected:
314     //SwClient
315     virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew);
316 };
317 
318 #endif
319