Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _UNOPORT_HXX
29 : : #define _UNOPORT_HXX
30 : :
31 : : #include <unocrsr.hxx>
32 : : #include <unoevtlstnr.hxx>
33 : : #include <calbck.hxx>
34 : :
35 : : #include <com/sun/star/beans/XPropertySet.hpp>
36 : : #include <com/sun/star/text/XTextRange.hpp>
37 : : #include <com/sun/star/container/XEnumeration.hpp>
38 : : #include <com/sun/star/container/XContentEnumerationAccess.hpp>
39 : : #include <com/sun/star/container/XEnumerationAccess.hpp>
40 : : #include <com/sun/star/beans/XPropertyState.hpp>
41 : : #include <com/sun/star/beans/XMultiPropertySet.hpp>
42 : : #include <com/sun/star/beans/XTolerantMultiPropertySet.hpp>
43 : : #include <com/sun/star/text/XTextField.hpp>
44 : : #include <com/sun/star/text/XFootnote.hpp>
45 : : #include <com/sun/star/lang/XServiceInfo.hpp>
46 : : #include <com/sun/star/lang/XUnoTunnel.hpp>
47 : : #include <cppuhelper/implbase8.hxx>
48 : : #include <cppuhelper/implbase3.hxx>
49 : : #include <svl/itemprop.hxx>
50 : :
51 : : #include <memory>
52 : : #include <deque>
53 : :
54 : :
55 : : class SwFmtFld;
56 : : class SwFrmFmt;
57 : : class SwTxtRuby;
58 : :
59 : :
60 : : typedef ::std::deque<
61 : : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > >
62 : : TextRangeList_t;
63 : :
64 : : enum SwTextPortionType
65 : : {
66 : : PORTION_TEXT,
67 : : PORTION_FIELD,
68 : : PORTION_FRAME,
69 : : PORTION_FOOTNOTE,
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 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
120 : : ::std::auto_ptr< ::com::sun::star::uno::Any > m_pRubyText;
121 : : ::std::auto_ptr< ::com::sun::star::uno::Any > m_pRubyStyle;
122 : : ::std::auto_ptr< ::com::sun::star::uno::Any > m_pRubyAdjust;
123 : : ::std::auto_ptr< ::com::sun::star::uno::Any > m_pRubyIsAbove;
124 : : SAL_WNODEPRECATED_DECLARATIONS_POP
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 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);
187 : : 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);
188 : : 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);
189 : : virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
190 : : 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);
191 : :
192 : : //XPropertySet
193 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
194 : : 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);
195 : : 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);
196 : : 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);
197 : : 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);
198 : : 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);
199 : : 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);
200 : :
201 : : //XPropertyState
202 : : virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
203 : : 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);
204 : : virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
205 : : 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);
206 : :
207 : : //XTextContent
208 : : 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 );
209 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor( ) throw(::com::sun::star::uno::RuntimeException);
210 : :
211 : : //XComponent
212 : : virtual void SAL_CALL dispose() throw( ::com::sun::star::uno::RuntimeException );
213 : : virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException );
214 : : virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException );
215 : :
216 : : //XUnoTunnel
217 : : static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId();
218 : : virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
219 : :
220 : : //XServiceInfo
221 : : virtual rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
222 : : virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException );
223 : : virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
224 : :
225 : : //XContentEnumerationAccess
226 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createContentEnumeration(const rtl::OUString& aServiceName) throw( ::com::sun::star::uno::RuntimeException );
227 : : virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getAvailableServiceNames() throw( ::com::sun::star::uno::RuntimeException );
228 : :
229 : 92 : void SetRefMark( ::com::sun::star::uno::Reference<
230 : : ::com::sun::star::text::XTextContent > xMark)
231 : 92 : { m_xRefMark = xMark; }
232 : :
233 : 90 : void SetTOXMark( ::com::sun::star::uno::Reference<
234 : : ::com::sun::star::text::XTextContent > xMark)
235 : 90 : { m_xTOXMark = xMark; }
236 : :
237 : 3906 : void SetBookmark( ::com::sun::star::uno::Reference<
238 : : ::com::sun::star::text::XTextContent > xMark)
239 : 3906 : { m_xBookmark = xMark; }
240 : :
241 : 34 : void SetFootnote( ::com::sun::star::uno::Reference<
242 : : ::com::sun::star::text::XFootnote > xNote)
243 : 34 : { m_xFootnote = xNote; }
244 : :
245 : 147 : void SetTextField( ::com::sun::star::uno::Reference<
246 : : ::com::sun::star::text::XTextField> xField)
247 : 147 : { m_xTextField = xField; }
248 : :
249 : 290 : void SetMeta( ::com::sun::star::uno::Reference<
250 : : ::com::sun::star::text::XTextContent > xMeta)
251 : 290 : { m_xMeta = xMeta; }
252 : :
253 : : bool IsCollapsed() const { return m_bIsCollapsed; }
254 : 2575 : void SetCollapsed(bool bSet) { m_bIsCollapsed = bSet;}
255 : :
256 : 0 : SwTextPortionType GetTextPortionType() const { return m_ePortionType; }
257 : :
258 : 43597 : SwUnoCrsr* GetCursor() const
259 : 43597 : {return static_cast<SwUnoCrsr*>(const_cast<SwModify*>(GetRegisteredIn()));}
260 : : };
261 : :
262 : : class SwXTextPortionEnumeration
263 : : : public ::cppu::WeakImplHelper3
264 : : < ::com::sun::star::container::XEnumeration
265 : : , ::com::sun::star::lang::XServiceInfo
266 : : , ::com::sun::star::lang::XUnoTunnel
267 : : >
268 : : , public SwClient
269 : : {
270 : : TextRangeList_t m_Portions; // contains all portions, filled by ctor
271 : :
272 : 1139 : SwUnoCrsr* GetCursor() const
273 : 1139 : {return static_cast<SwUnoCrsr*>(const_cast<SwModify*>(GetRegisteredIn()));}
274 : :
275 : : protected:
276 : : virtual ~SwXTextPortionEnumeration();
277 : :
278 : : public:
279 : : SwXTextPortionEnumeration(SwPaM& rParaCrsr,
280 : : ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >
281 : : const & xParent,
282 : : const sal_Int32 nStart, const sal_Int32 nEnd );
283 : :
284 : : SwXTextPortionEnumeration(SwPaM& rParaCrsr,
285 : : TextRangeList_t const & rPortions );
286 : :
287 : :
288 : : static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId();
289 : :
290 : : //XUnoTunnel
291 : : virtual sal_Int64 SAL_CALL getSomething(
292 : : const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier )
293 : : throw(::com::sun::star::uno::RuntimeException);
294 : :
295 : : //XEnumeration
296 : : virtual sal_Bool SAL_CALL hasMoreElements()
297 : : throw( ::com::sun::star::uno::RuntimeException );
298 : : virtual ::com::sun::star::uno::Any SAL_CALL nextElement()
299 : : throw( ::com::sun::star::container::NoSuchElementException,
300 : : ::com::sun::star::lang::WrappedTargetException,
301 : : ::com::sun::star::uno::RuntimeException );
302 : :
303 : : //XServiceInfo
304 : : virtual rtl::OUString SAL_CALL getImplementationName()
305 : : throw( ::com::sun::star::uno::RuntimeException );
306 : : virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName)
307 : : throw( ::com::sun::star::uno::RuntimeException );
308 : : virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
309 : : getSupportedServiceNames()
310 : : throw( ::com::sun::star::uno::RuntimeException );
311 : : protected:
312 : : //SwClient
313 : : virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew);
314 : : };
315 : :
316 : : #endif
317 : :
318 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|