nss: upgrade to release 3.73
[LibreOffice.git] / sw / source / core / inc / unoport.hxx
blob69c407d5b13519bd08d4d975b563efbdad8d3fe0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_SOURCE_CORE_INC_UNOPORT_HXX
20 #define INCLUDED_SW_SOURCE_CORE_INC_UNOPORT_HXX
22 #include <memory>
23 #include <deque>
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/beans/XPropertyState.hpp>
30 #include <com/sun/star/beans/XMultiPropertySet.hpp>
31 #include <com/sun/star/beans/XTolerantMultiPropertySet.hpp>
32 #include <com/sun/star/lang/XServiceInfo.hpp>
33 #include <com/sun/star/lang/XUnoTunnel.hpp>
35 #include <cppuhelper/implbase.hxx>
37 #include <svl/itemprop.hxx>
38 #include <svl/listener.hxx>
40 #include <unocrsr.hxx>
42 namespace com::sun::star::beans { struct PropertyValue; }
43 namespace com::sun::star::text { class XTextField; }
44 namespace com::sun::star::text { class XFootnote; }
46 class SwFrameFormat;
47 class SwRangeRedline;
48 class SwTextRuby;
50 typedef std::deque<
51 css::uno::Reference< css::text::XTextRange > >
52 TextRangeList_t;
54 enum SwTextPortionType
56 PORTION_TEXT,
57 PORTION_FIELD,
58 PORTION_FRAME,
59 PORTION_FOOTNOTE,
60 PORTION_REFMARK_START,
61 PORTION_REFMARK_END,
62 PORTION_TOXMARK_START,
63 PORTION_TOXMARK_END,
64 PORTION_BOOKMARK_START,
65 PORTION_BOOKMARK_END,
66 PORTION_REDLINE_START,
67 PORTION_REDLINE_END,
68 PORTION_RUBY_START,
69 PORTION_RUBY_END,
70 PORTION_SOFT_PAGEBREAK,
71 PORTION_META,
72 PORTION_FIELD_START,
73 PORTION_FIELD_SEP,
74 PORTION_FIELD_END,
75 PORTION_FIELD_START_END,
76 PORTION_ANNOTATION,
77 PORTION_ANNOTATION_END
80 class SwXTextPortion : public cppu::WeakImplHelper
82 css::beans::XTolerantMultiPropertySet,
83 css::beans::XMultiPropertySet,
84 css::beans::XPropertySet,
85 css::text::XTextRange,
86 css::beans::XPropertyState,
87 css::container::XContentEnumerationAccess,
88 css::lang::XUnoTunnel,
89 css::lang::XServiceInfo
91 public SvtListener
93 private:
95 const SfxItemPropertySet * m_pPropSet;
96 const css::uno::Reference< css::text::XText >
97 m_xParentText;
98 css::uno::Reference< css::text::XTextContent >
99 m_xRefMark;
100 css::uno::Reference< css::text::XTextContent >
101 m_xTOXMark;
102 css::uno::Reference< css::text::XTextContent >
103 m_xBookmark;
104 css::uno::Reference< css::text::XFootnote >
105 m_xFootnote;
106 css::uno::Reference< css::text::XTextField >
107 m_xTextField;
108 css::uno::Reference< css::text::XTextContent >
109 m_xMeta;
110 std::unique_ptr< css::uno::Any > m_pRubyText;
111 std::unique_ptr< css::uno::Any > m_pRubyStyle;
112 std::unique_ptr< css::uno::Any > m_pRubyAdjust;
113 std::unique_ptr< css::uno::Any > m_pRubyIsAbove;
114 std::unique_ptr< css::uno::Any > m_pRubyPosition;
115 sw::UnoCursorPointer m_pUnoCursor;
117 SwFrameFormat* m_pFrameFormat;
118 const SwTextPortionType m_ePortionType;
120 bool m_bIsCollapsed;
122 void init(const SwUnoCursor* pPortionCursor);
124 protected:
125 /// @throws css::beans::UnknownPropertyException
126 /// @throws css::beans::PropertyVetoException
127 /// @throws css::lang::IllegalArgumentException
128 /// @throws css::lang::WrappedTargetException
129 /// @throws css::uno::RuntimeException
130 void SetPropertyValues_Impl(
131 const css::uno::Sequence< OUString >& aPropertyNames,
132 const css::uno::Sequence< css::uno::Any >& aValues );
133 /// @throws css::beans::UnknownPropertyException
134 /// @throws css::lang::WrappedTargetException
135 /// @throws css::uno::RuntimeException
136 css::uno::Sequence< css::uno::Any > GetPropertyValues_Impl(
137 const css::uno::Sequence< OUString >& aPropertyNames );
139 void GetPropertyValue( css::uno::Any &rVal,
140 const SfxItemPropertySimpleEntry& rEntry, SwUnoCursor *pUnoCursor, std::unique_ptr<SfxItemSet> &pSet );
142 /// @throws css::uno::RuntimeException
143 css::uno::Sequence<css::beans::GetDirectPropertyTolerantResult> GetPropertyValuesTolerant_Impl(
144 const css::uno::Sequence< OUString >& rPropertyNames, bool bDirectValuesOnly );
146 virtual ~SwXTextPortion() override;
148 virtual void Notify(const SfxHint& rHint) override;
150 public:
151 SwXTextPortion(const SwUnoCursor* pPortionCursor, css::uno::Reference< css::text::XText > const& rParent, SwTextPortionType eType );
152 SwXTextPortion(const SwUnoCursor* pPortionCursor, css::uno::Reference< css::text::XText > const& rParent, SwFrameFormat& rFormat );
154 // for Ruby
155 SwXTextPortion(const SwUnoCursor* pPortionCursor,
156 SwTextRuby const& rAttr,
157 css::uno::Reference< css::text::XText > const& xParent,
158 bool bIsEnd );
160 //XTextRange
161 virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override;
162 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override;
163 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override;
164 virtual OUString SAL_CALL getString() override;
165 virtual void SAL_CALL setString(const OUString& aString) override;
167 //XTolerantMultiPropertySet
168 virtual css::uno::Sequence< css::beans::SetPropertyTolerantFailed > SAL_CALL setPropertyValuesTolerant( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues ) override;
169 virtual css::uno::Sequence< css::beans::GetPropertyTolerantResult > SAL_CALL getPropertyValuesTolerant( const css::uno::Sequence< OUString >& aPropertyNames ) override;
170 virtual css::uno::Sequence< css::beans::GetDirectPropertyTolerantResult > SAL_CALL getDirectPropertyValuesTolerant( const css::uno::Sequence< OUString >& aPropertyNames ) override;
172 //XMultiPropertySet
173 virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues ) override;
174 virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) override;
175 virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
176 virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
177 virtual void SAL_CALL firePropertiesChangeEvent( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
179 //XPropertySet
180 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
181 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
182 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
183 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
184 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
185 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
186 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
188 //XPropertyState
189 virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override;
190 virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override;
191 virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override;
192 virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
194 //XUnoTunnel
195 static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
196 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
198 //XServiceInfo
199 virtual OUString SAL_CALL getImplementationName() override;
200 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
201 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
203 //XContentEnumerationAccess
204 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createContentEnumeration(const OUString& aServiceName) override;
205 virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override;
207 void SetRefMark( css::uno::Reference< css::text::XTextContent > const & xMark)
208 { m_xRefMark = xMark; }
210 void SetTOXMark( css::uno::Reference< css::text::XTextContent > const & xMark)
211 { m_xTOXMark = xMark; }
213 void SetBookmark( css::uno::Reference< css::text::XTextContent > const & xMark)
214 { m_xBookmark = xMark; }
216 void SetFootnote( css::uno::Reference< css::text::XFootnote > const & xNote)
217 { m_xFootnote = xNote; }
219 void SetTextField( css::uno::Reference< css::text::XTextField> const & xField)
220 { m_xTextField = xField; }
222 void SetMeta( css::uno::Reference< css::text::XTextContent > const & xMeta)
223 { m_xMeta = xMeta; }
225 void SetCollapsed(bool bSet) { m_bIsCollapsed = bSet;}
227 SwTextPortionType GetTextPortionType() const { return m_ePortionType; }
229 SwUnoCursor& GetCursor() const
230 { return *m_pUnoCursor; }
233 class SwXTextPortionEnumeration
234 : public ::cppu::WeakImplHelper
235 < css::container::XEnumeration
236 , css::lang::XServiceInfo
237 , css::lang::XUnoTunnel
240 TextRangeList_t m_Portions; // contains all portions, filled by ctor
241 sw::UnoCursorPointer m_pUnoCursor;
243 protected:
244 virtual ~SwXTextPortionEnumeration() override;
246 public:
247 SwXTextPortionEnumeration(SwPaM& rParaCursor,
248 css::uno::Reference< css::text::XText > const & xParent,
249 const sal_Int32 nStart, const sal_Int32 nEnd );
251 SwXTextPortionEnumeration(SwPaM& rParaCursor,
252 TextRangeList_t const & rPortions );
254 static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
256 //XUnoTunnel
257 virtual sal_Int64 SAL_CALL getSomething(
258 const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
260 //XEnumeration
261 virtual sal_Bool SAL_CALL hasMoreElements() override;
262 virtual css::uno::Any SAL_CALL nextElement() override;
264 //XServiceInfo
265 virtual OUString SAL_CALL getImplementationName() override;
266 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
267 virtual css::uno::Sequence< OUString > SAL_CALL
268 getSupportedServiceNames() override;
271 class SwXRedlinePortion : public SwXTextPortion
273 private:
274 SwRangeRedline const& m_rRedline;
276 bool Validate();
278 using SwXTextPortion::GetPropertyValue;
280 virtual ~SwXRedlinePortion() override;
282 public:
283 SwXRedlinePortion(
284 SwRangeRedline const& rRedline,
285 SwUnoCursor const* pPortionCursor,
286 css::uno::Reference< css::text::XText > const& xParent,
287 bool const bIsStart);
289 /// @throws std::exception
290 static css::uno::Any GetPropertyValue(
291 OUString const& PropertyName, SwRangeRedline const& rRedline);
292 /// @throws std::exception
293 static css::uno::Sequence< css::beans::PropertyValue > CreateRedlineProperties(
294 SwRangeRedline const& rRedline, bool const bIsStart);
296 virtual css::uno::Sequence< sal_Int8 > SAL_CALL
297 getImplementationId() override;
299 // XPropertySet
300 virtual css::uno::Any SAL_CALL getPropertyValue(
301 const OUString& rPropertyName) override;
304 #endif
306 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */