Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef INCLUDED_SW_SOURCE_CORE_INC_UNOPORT_HXX
20 : #define INCLUDED_SW_SOURCE_CORE_INC_UNOPORT_HXX
21 :
22 : #include <memory>
23 : #include <deque>
24 :
25 : #include <com/sun/star/beans/XPropertySet.hpp>
26 : #include <com/sun/star/text/XTextRange.hpp>
27 : #include <com/sun/star/container/XEnumeration.hpp>
28 : #include <com/sun/star/container/XContentEnumerationAccess.hpp>
29 : #include <com/sun/star/container/XEnumerationAccess.hpp>
30 : #include <com/sun/star/beans/XPropertyState.hpp>
31 : #include <com/sun/star/beans/XMultiPropertySet.hpp>
32 : #include <com/sun/star/beans/XTolerantMultiPropertySet.hpp>
33 : #include <com/sun/star/text/XTextField.hpp>
34 : #include <com/sun/star/text/XFootnote.hpp>
35 : #include <com/sun/star/lang/XServiceInfo.hpp>
36 : #include <com/sun/star/lang/XUnoTunnel.hpp>
37 :
38 : #include <cppuhelper/implbase.hxx>
39 :
40 : #include <svl/itemprop.hxx>
41 :
42 : #include <unocrsr.hxx>
43 : #include <calbck.hxx>
44 : #include <unobaseclass.hxx>
45 :
46 : class SwFormatField;
47 : class SwFrameFormat;
48 : class SwRangeRedline;
49 : class SwTextRuby;
50 :
51 : typedef ::std::deque<
52 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > >
53 : TextRangeList_t;
54 :
55 : enum SwTextPortionType
56 : {
57 : PORTION_TEXT,
58 : PORTION_FIELD,
59 : PORTION_FRAME,
60 : PORTION_FOOTNOTE,
61 : PORTION_REFMARK_START,
62 : PORTION_REFMARK_END,
63 : PORTION_TOXMARK_START,
64 : PORTION_TOXMARK_END,
65 : PORTION_BOOKMARK_START,
66 : PORTION_BOOKMARK_END,
67 : PORTION_REDLINE_START,
68 : PORTION_REDLINE_END,
69 : PORTION_RUBY_START,
70 : PORTION_RUBY_END,
71 : PORTION_SOFT_PAGEBREAK,
72 : PORTION_META,
73 : PORTION_FIELD_START,
74 : PORTION_FIELD_END,
75 : PORTION_FIELD_START_END,
76 : PORTION_ANNOTATION,
77 : PORTION_ANNOTATION_END
78 : };
79 :
80 : class SwXTextPortion : public cppu::WeakImplHelper
81 : <
82 : ::com::sun::star::beans::XTolerantMultiPropertySet,
83 : ::com::sun::star::beans::XMultiPropertySet,
84 : ::com::sun::star::beans::XPropertySet,
85 : ::com::sun::star::text::XTextRange,
86 : ::com::sun::star::beans::XPropertyState,
87 : ::com::sun::star::container::XContentEnumerationAccess,
88 : ::com::sun::star::lang::XUnoTunnel,
89 : ::com::sun::star::lang::XServiceInfo
90 : >,
91 : public SwClient
92 : {
93 : private:
94 :
95 : class Impl;
96 : ::sw::UnoImplPtr<Impl> m_pImpl;
97 :
98 : const SfxItemPropertySet * m_pPropSet;
99 : const ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >
100 : m_xParentText;
101 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >
102 : m_xRefMark;
103 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >
104 : m_xTOXMark;
105 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >
106 : m_xBookmark;
107 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XFootnote >
108 : m_xFootnote;
109 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextField >
110 : m_xTextField;
111 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >
112 : m_xMeta;
113 : ::std::unique_ptr< ::com::sun::star::uno::Any > m_pRubyText;
114 : ::std::unique_ptr< ::com::sun::star::uno::Any > m_pRubyStyle;
115 : ::std::unique_ptr< ::com::sun::star::uno::Any > m_pRubyAdjust;
116 : ::std::unique_ptr< ::com::sun::star::uno::Any > m_pRubyIsAbove;
117 : sw::UnoCursorPointer m_pUnoCursor;
118 :
119 : const SwDepend m_FrameDepend;
120 : SwFrameFormat * m_pFrameFormat;
121 : const SwTextPortionType m_ePortionType;
122 :
123 : bool m_bIsCollapsed;
124 :
125 : SwFormatField * GetFieldFormat(bool bInit = false);
126 :
127 : void init(const SwUnoCrsr* pPortionCursor);
128 :
129 : protected:
130 :
131 : void SAL_CALL SetPropertyValues_Impl(
132 : const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames,
133 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues )
134 : 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);
135 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL GetPropertyValues_Impl(
136 : const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames )
137 : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
138 :
139 : void GetPropertyValues( const OUString *pPropertyNames,
140 : ::com::sun::star::uno::Any *pValues,
141 : sal_Int32 nLength );
142 :
143 : void GetPropertyValue( ::com::sun::star::uno::Any &rVal,
144 : const SfxItemPropertySimpleEntry& rEntry, SwUnoCrsr *pUnoCrsr, SfxItemSet *&pSet );
145 :
146 : css::uno::Sequence<css::beans::GetDirectPropertyTolerantResult> SAL_CALL GetPropertyValuesTolerant_Impl(
147 : const css::uno::Sequence< OUString >& rPropertyNames, bool bDirectValuesOnly )
148 : throw (css::uno::RuntimeException, std::exception);
149 :
150 : virtual ~SwXTextPortion();
151 :
152 : //SwClient
153 : virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
154 :
155 : public:
156 : SwXTextPortion(const SwUnoCrsr* pPortionCrsr, ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > const& rParent, SwTextPortionType eType );
157 : SwXTextPortion(const SwUnoCrsr* pPortionCrsr, ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > const& rParent, SwFrameFormat& rFormat );
158 :
159 : // for Ruby
160 : SwXTextPortion(const SwUnoCrsr* pPortionCrsr,
161 : SwTextRuby const& rAttr,
162 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >
163 : const& xParent,
164 : bool bIsEnd );
165 :
166 : //XTextRange
167 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL getText() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
168 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getStart() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
169 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getEnd() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
170 : virtual OUString SAL_CALL getString() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
171 : virtual void SAL_CALL setString(const OUString& aString) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
172 :
173 : //XTolerantMultiPropertySet
174 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::SetPropertyTolerantFailed > SAL_CALL setPropertyValuesTolerant( const ::com::sun::star::uno::Sequence< 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, std::exception) SAL_OVERRIDE;
175 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::GetPropertyTolerantResult > SAL_CALL getPropertyValuesTolerant( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
176 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::GetDirectPropertyTolerantResult > SAL_CALL getDirectPropertyValuesTolerant( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
177 :
178 : //XMultiPropertySet
179 : virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< 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, std::exception) SAL_OVERRIDE;
180 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
181 : virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
182 : virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
183 : virtual void SAL_CALL firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
184 :
185 : //XPropertySet
186 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
187 : virtual void SAL_CALL setPropertyValue( const 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, std::exception) SAL_OVERRIDE;
188 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
189 : virtual void SAL_CALL addPropertyChangeListener( const 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, std::exception) SAL_OVERRIDE;
190 : virtual void SAL_CALL removePropertyChangeListener( const 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, std::exception) SAL_OVERRIDE;
191 : virtual void SAL_CALL addVetoableChangeListener( const 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, std::exception) SAL_OVERRIDE;
192 : virtual void SAL_CALL removeVetoableChangeListener( const 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, std::exception) SAL_OVERRIDE;
193 :
194 : //XPropertyState
195 : virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
196 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< OUString >& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
197 : virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
198 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
199 :
200 : //XUnoTunnel
201 : static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId();
202 : virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
203 :
204 : //XServiceInfo
205 : virtual OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
206 : virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
207 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
208 :
209 : //XContentEnumerationAccess
210 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createContentEnumeration(const OUString& aServiceName) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
211 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
212 :
213 46 : void SetRefMark( ::com::sun::star::uno::Reference<
214 : ::com::sun::star::text::XTextContent > xMark)
215 46 : { m_xRefMark = xMark; }
216 :
217 47 : void SetTOXMark( ::com::sun::star::uno::Reference<
218 : ::com::sun::star::text::XTextContent > xMark)
219 47 : { m_xTOXMark = xMark; }
220 :
221 2367 : void SetBookmark( ::com::sun::star::uno::Reference<
222 : ::com::sun::star::text::XTextContent > xMark)
223 2367 : { m_xBookmark = xMark; }
224 :
225 22 : void SetFootnote( ::com::sun::star::uno::Reference<
226 : ::com::sun::star::text::XFootnote > xNote)
227 22 : { m_xFootnote = xNote; }
228 :
229 384 : void SetTextField( ::com::sun::star::uno::Reference<
230 : ::com::sun::star::text::XTextField> xField)
231 384 : { m_xTextField = xField; }
232 :
233 145 : void SetMeta( ::com::sun::star::uno::Reference<
234 : ::com::sun::star::text::XTextContent > xMeta)
235 145 : { m_xMeta = xMeta; }
236 :
237 : bool IsCollapsed() const { return m_bIsCollapsed; }
238 1901 : void SetCollapsed(bool bSet) { m_bIsCollapsed = bSet;}
239 :
240 95 : SwTextPortionType GetTextPortionType() const { return m_ePortionType; }
241 :
242 21369 : SwUnoCrsr* GetCursor() const
243 21369 : { return &(*m_pUnoCursor); }
244 : };
245 :
246 : class SwXTextPortionEnumeration
247 : : public ::cppu::WeakImplHelper
248 : < ::com::sun::star::container::XEnumeration
249 : , ::com::sun::star::lang::XServiceInfo
250 : , ::com::sun::star::lang::XUnoTunnel
251 : >
252 : {
253 : TextRangeList_t m_Portions; // contains all portions, filled by ctor
254 : sw::UnoCursorPointer m_pUnoCrsr;
255 :
256 1949 : SwUnoCrsr* GetCursor() const
257 1949 : {return &(*m_pUnoCrsr);}
258 :
259 : protected:
260 : virtual ~SwXTextPortionEnumeration();
261 :
262 : public:
263 : SwXTextPortionEnumeration(SwPaM& rParaCrsr,
264 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >
265 : const & xParent,
266 : const sal_Int32 nStart, const sal_Int32 nEnd );
267 :
268 : SwXTextPortionEnumeration(SwPaM& rParaCrsr,
269 : TextRangeList_t const & rPortions );
270 :
271 : static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId();
272 :
273 : //XUnoTunnel
274 : virtual sal_Int64 SAL_CALL getSomething(
275 : const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier )
276 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
277 :
278 : //XEnumeration
279 : virtual sal_Bool SAL_CALL hasMoreElements()
280 : throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
281 : virtual ::com::sun::star::uno::Any SAL_CALL nextElement()
282 : throw( ::com::sun::star::container::NoSuchElementException,
283 : ::com::sun::star::lang::WrappedTargetException,
284 : ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
285 :
286 : //XServiceInfo
287 : virtual OUString SAL_CALL getImplementationName()
288 : throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
289 : virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName)
290 : throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
291 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL
292 : getSupportedServiceNames()
293 : throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
294 : };
295 :
296 : class SwXRedlinePortion : public SwXTextPortion
297 : {
298 : private:
299 : SwRangeRedline const& m_rRedline;
300 :
301 : void Validate() throw (::com::sun::star::uno::RuntimeException);
302 :
303 : using SwXTextPortion::GetPropertyValue;
304 :
305 : virtual ~SwXRedlinePortion();
306 :
307 : public:
308 : SwXRedlinePortion(
309 : SwRangeRedline const& rRedline,
310 : SwUnoCrsr const* pPortionCrsr,
311 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >
312 : const& xParent,
313 : bool const bIsStart);
314 :
315 : static ::com::sun::star::uno::Any GetPropertyValue(
316 : OUString const& PropertyName, SwRangeRedline const& rRedline) throw();
317 : static ::com::sun::star::uno::Sequence<
318 : ::com::sun::star::beans::PropertyValue > CreateRedlineProperties(
319 : SwRangeRedline const& rRedline, bool const bIsStart) throw();
320 :
321 : virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
322 : getImplementationId() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
323 :
324 : // XPropertySet
325 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
326 : const OUString& rPropertyName)
327 : throw (::com::sun::star::beans::UnknownPropertyException,
328 : ::com::sun::star::lang::WrappedTargetException,
329 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
330 : };
331 :
332 : #endif
333 :
334 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|