1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
30 #include <unocrsr.hxx>
31 #include <unoevtlstnr.hxx>
34 #include <com/sun/star/beans/XPropertySet.hpp>
35 #include <com/sun/star/text/XTextRange.hpp>
36 #include <com/sun/star/container/XEnumeration.hpp>
37 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
38 #include <com/sun/star/container/XEnumerationAccess.hpp>
39 #include <com/sun/star/beans/XPropertyState.hpp>
40 #include <com/sun/star/beans/XMultiPropertySet.hpp>
41 #include <com/sun/star/beans/XTolerantMultiPropertySet.hpp>
42 #include <com/sun/star/text/XTextField.hpp>
43 #include <com/sun/star/text/XFootnote.hpp>
44 #include <com/sun/star/lang/XServiceInfo.hpp>
45 #include <com/sun/star/lang/XUnoTunnel.hpp>
46 #include <cppuhelper/implbase8.hxx>
47 #include <cppuhelper/implbase3.hxx>
48 #include <svl/itemprop.hxx>
60 ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
> >
64 /* -----------------29.05.98 14:42-------------------
66 * --------------------------------------------------*/
67 enum SwTextPortionType
73 // obsolete! PORTION_CONTROL_CHAR,
74 PORTION_REFMARK_START
,
76 PORTION_TOXMARK_START
,
78 PORTION_BOOKMARK_START
,
80 PORTION_REDLINE_START
,
84 PORTION_SOFT_PAGEBREAK
,
88 PORTION_FIELD_START_END
92 class SwXTextPortion
: public cppu::WeakImplHelper8
94 ::com::sun::star::beans::XTolerantMultiPropertySet
,
95 ::com::sun::star::beans::XMultiPropertySet
,
96 ::com::sun::star::beans::XPropertySet
,
97 ::com::sun::star::text::XTextRange
,
98 ::com::sun::star::beans::XPropertyState
,
99 ::com::sun::star::container::XContentEnumerationAccess
,
100 ::com::sun::star::lang::XUnoTunnel
,
101 ::com::sun::star::lang::XServiceInfo
107 SwEventListenerContainer m_ListenerContainer
;
108 const SfxItemPropertySet
* m_pPropSet
;
109 const ::com::sun::star::uno::Reference
< ::com::sun::star::text::XText
>
111 ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextContent
>
113 ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextContent
>
115 ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextContent
>
117 ::com::sun::star::uno::Reference
< ::com::sun::star::text::XFootnote
>
119 ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextField
>
121 ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextContent
>
123 ::std::auto_ptr
< ::com::sun::star::uno::Any
> m_pRubyText
;
124 ::std::auto_ptr
< ::com::sun::star::uno::Any
> m_pRubyStyle
;
125 ::std::auto_ptr
< ::com::sun::star::uno::Any
> m_pRubyAdjust
;
126 ::std::auto_ptr
< ::com::sun::star::uno::Any
> m_pRubyIsAbove
;
128 const SwDepend m_FrameDepend
;
129 SwFrmFmt
* m_pFrameFmt
;
130 const SwTextPortionType m_ePortionType
;
134 SwFmtFld
* GetFldFmt(bool bInit
= false);
138 //SfxItemPropertySet& GetPropSet() { return aPropSet; }
140 void SAL_CALL
SetPropertyValues_Impl(
141 const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& aPropertyNames
,
142 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& aValues
)
143 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
);
144 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> SAL_CALL
GetPropertyValues_Impl(
145 const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& aPropertyNames
)
146 throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
148 // ::com::sun::star::uno::Any GetPropertyValue( const SfxItemPropertyMap *pEntry,
149 // SwUnoCrsr *pUnoCrsr,
150 // SfxItemSet *pSet );
151 void GetPropertyValues( const ::rtl::OUString
*pPropertyNames
,
152 ::com::sun::star::uno::Any
*pValues
,
155 void GetPropertyValue( ::com::sun::star::uno::Any
&rVal
,
156 const SfxItemPropertySimpleEntry
& rEntry
, SwUnoCrsr
*pUnoCrsr
, SfxItemSet
*&pSet
);
158 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::GetDirectPropertyTolerantResult
> SAL_CALL
GetPropertyValuesTolerant_Impl(
159 const ::com::sun::star::uno::Sequence
< rtl::OUString
>& rPropertyNames
,
160 sal_Bool bDirectValuesOnly
) throw (::com::sun::star::uno::RuntimeException
);
162 virtual ~SwXTextPortion();
165 SwXTextPortion(const SwUnoCrsr
* pPortionCrsr
, ::com::sun::star::uno::Reference
< ::com::sun::star::text::XText
> const& rParent
, SwTextPortionType eType
);
166 SwXTextPortion(const SwUnoCrsr
* pPortionCrsr
, ::com::sun::star::uno::Reference
< ::com::sun::star::text::XText
> const& rParent
, SwFrmFmt
& rFmt
);
169 SwXTextPortion(const SwUnoCrsr
* pPortionCrsr
,
170 SwTxtRuby
const& rAttr
,
171 ::com::sun::star::uno::Reference
< ::com::sun::star::text::XText
>
176 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::text::XText
> SAL_CALL
getText() throw( ::com::sun::star::uno::RuntimeException
);
177 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
> SAL_CALL
getStart() throw( ::com::sun::star::uno::RuntimeException
);
178 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
> SAL_CALL
getEnd() throw( ::com::sun::star::uno::RuntimeException
);
179 virtual rtl::OUString SAL_CALL
getString() throw( ::com::sun::star::uno::RuntimeException
);
180 virtual void SAL_CALL
setString(const rtl::OUString
& aString
) throw( ::com::sun::star::uno::RuntimeException
);
182 //XTolerantMultiPropertySet
183 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
);
184 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
);
185 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
);
188 // virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
189 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
);
190 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
);
191 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
);
192 virtual void SAL_CALL
removePropertiesChangeListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertiesChangeListener
>& xListener
) throw(::com::sun::star::uno::RuntimeException
);
193 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
);
196 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
);
197 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
);
198 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
);
199 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
);
200 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
);
201 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
);
202 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
);
205 virtual ::com::sun::star::beans::PropertyState SAL_CALL
getPropertyState( const ::rtl::OUString
& PropertyName
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
);
206 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
);
207 virtual void SAL_CALL
setPropertyToDefault( const ::rtl::OUString
& PropertyName
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
);
208 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
);
211 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
);
212 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
> SAL_CALL
getAnchor( ) throw(::com::sun::star::uno::RuntimeException
);
215 virtual void SAL_CALL
dispose() throw( ::com::sun::star::uno::RuntimeException
);
216 virtual void SAL_CALL
addEventListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
> & aListener
) throw( ::com::sun::star::uno::RuntimeException
);
217 virtual void SAL_CALL
removeEventListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
> & aListener
) throw( ::com::sun::star::uno::RuntimeException
);
220 static const ::com::sun::star::uno::Sequence
< sal_Int8
> & getUnoTunnelId();
221 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
< sal_Int8
>& aIdentifier
) throw(::com::sun::star::uno::RuntimeException
);
224 virtual rtl::OUString SAL_CALL
getImplementationName() throw( ::com::sun::star::uno::RuntimeException
);
225 virtual sal_Bool SAL_CALL
supportsService(const rtl::OUString
& ServiceName
) throw( ::com::sun::star::uno::RuntimeException
);
226 virtual ::com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException
);
228 //XContentEnumerationAccess
229 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XEnumeration
> SAL_CALL
createContentEnumeration(const rtl::OUString
& aServiceName
) throw( ::com::sun::star::uno::RuntimeException
);
230 virtual ::com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
getAvailableServiceNames() throw( ::com::sun::star::uno::RuntimeException
);
233 virtual void Modify( SfxPoolItem
*pOld
, SfxPoolItem
*pNew
);
235 void SetRefMark( ::com::sun::star::uno::Reference
<
236 ::com::sun::star::text::XTextContent
> xMark
)
237 { m_xRefMark
= xMark
; }
239 void SetTOXMark( ::com::sun::star::uno::Reference
<
240 ::com::sun::star::text::XTextContent
> xMark
)
241 { m_xTOXMark
= xMark
; }
243 void SetBookmark( ::com::sun::star::uno::Reference
<
244 ::com::sun::star::text::XTextContent
> xMark
)
245 { m_xBookmark
= xMark
; }
247 void SetFootnote( ::com::sun::star::uno::Reference
<
248 ::com::sun::star::text::XFootnote
> xNote
)
249 { m_xFootnote
= xNote
; }
251 void SetTextField( ::com::sun::star::uno::Reference
<
252 ::com::sun::star::text::XTextField
> xField
)
253 { m_xTextField
= xField
; }
255 void SetMeta( ::com::sun::star::uno::Reference
<
256 ::com::sun::star::text::XTextContent
> xMeta
)
259 bool IsCollapsed() const { return m_bIsCollapsed
; }
260 void SetCollapsed(bool bSet
) { m_bIsCollapsed
= bSet
;}
262 SwTextPortionType
GetTextPortionType() const { return m_ePortionType
; }
264 SwUnoCrsr
* GetCursor() const
265 {return static_cast<SwUnoCrsr
*>(const_cast<SwModify
*>(GetRegisteredIn()));}
268 /* -----------------29.05.98 14:42-------------------
270 * --------------------------------------------------*/
271 class SwXTextPortionEnumeration
272 : public ::cppu::WeakImplHelper3
273 < ::com::sun::star::container::XEnumeration
274 , ::com::sun::star::lang::XServiceInfo
275 , ::com::sun::star::lang::XUnoTunnel
279 TextRangeList_t m_Portions
; // contains all portions, filled by ctor
281 SwUnoCrsr
* GetCursor() const
282 {return static_cast<SwUnoCrsr
*>(const_cast<SwModify
*>(GetRegisteredIn()));}
285 virtual ~SwXTextPortionEnumeration();
288 SwXTextPortionEnumeration(SwPaM
& rParaCrsr
,
289 ::com::sun::star::uno::Reference
< ::com::sun::star::text::XText
>
291 const sal_Int32 nStart
, const sal_Int32 nEnd
);
293 SwXTextPortionEnumeration(SwPaM
& rParaCrsr
,
294 TextRangeList_t
const & rPortions
);
297 static const ::com::sun::star::uno::Sequence
< sal_Int8
> & getUnoTunnelId();
300 virtual sal_Int64 SAL_CALL
getSomething(
301 const ::com::sun::star::uno::Sequence
< sal_Int8
>& aIdentifier
)
302 throw(::com::sun::star::uno::RuntimeException
);
305 virtual sal_Bool SAL_CALL
hasMoreElements()
306 throw( ::com::sun::star::uno::RuntimeException
);
307 virtual ::com::sun::star::uno::Any SAL_CALL
nextElement()
308 throw( ::com::sun::star::container::NoSuchElementException
,
309 ::com::sun::star::lang::WrappedTargetException
,
310 ::com::sun::star::uno::RuntimeException
);
313 virtual rtl::OUString SAL_CALL
getImplementationName()
314 throw( ::com::sun::star::uno::RuntimeException
);
315 virtual sal_Bool SAL_CALL
supportsService(const rtl::OUString
& ServiceName
)
316 throw( ::com::sun::star::uno::RuntimeException
);
317 virtual ::com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
318 getSupportedServiceNames()
319 throw( ::com::sun::star::uno::RuntimeException
);
322 virtual void Modify( SfxPoolItem
*pOld
, SfxPoolItem
*pNew
);