LibreOffice Module sw (master)  1
unoport.hxx
Go to the documentation of this file.
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/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>
34 
35 #include <cppuhelper/implbase.hxx>
36 
37 #include <svl/itemprop.hxx>
38 
39 #include <unocrsr.hxx>
40 #include <calbck.hxx>
41 
42 namespace com::sun::star::beans { struct PropertyValue; }
43 namespace com::sun::star::text { class XTextField; }
44 namespace com::sun::star::text { class XFootnote; }
45 
46 class SwFrameFormat;
47 class SwRangeRedline;
48 class SwTextRuby;
49 
50 typedef std::deque<
51  css::uno::Reference< css::text::XTextRange > >
53 
55 {
77 };
78 
79 class SwXTextPortion : public cppu::WeakImplHelper
80 <
81  css::beans::XTolerantMultiPropertySet,
82  css::beans::XMultiPropertySet,
83  css::beans::XPropertySet,
84  css::text::XTextRange,
85  css::beans::XPropertyState,
86  css::container::XContentEnumerationAccess,
87  css::lang::XUnoTunnel,
88  css::lang::XServiceInfo
89 >,
90  public SwClient
91 {
92 private:
93 
95  const css::uno::Reference< css::text::XText >
97  css::uno::Reference< css::text::XTextContent >
99  css::uno::Reference< css::text::XTextContent >
101  css::uno::Reference< css::text::XTextContent >
103  css::uno::Reference< css::text::XFootnote >
105  css::uno::Reference< css::text::XTextField >
107  css::uno::Reference< css::text::XTextContent >
109  std::unique_ptr< css::uno::Any > m_pRubyText;
110  std::unique_ptr< css::uno::Any > m_pRubyStyle;
111  std::unique_ptr< css::uno::Any > m_pRubyAdjust;
112  std::unique_ptr< css::uno::Any > m_pRubyIsAbove;
113  std::unique_ptr< css::uno::Any > m_pRubyPosition;
115 
119 
121 
122  void init(const SwUnoCursor* pPortionCursor);
123 
124 protected:
131  const css::uno::Sequence< OUString >& aPropertyNames,
132  const css::uno::Sequence< css::uno::Any >& aValues );
136  css::uno::Sequence< css::uno::Any > GetPropertyValues_Impl(
137  const css::uno::Sequence< OUString >& aPropertyNames );
138 
139  void GetPropertyValue( css::uno::Any &rVal,
140  const SfxItemPropertySimpleEntry& rEntry, SwUnoCursor *pUnoCursor, std::unique_ptr<SfxItemSet> &pSet );
141 
143  css::uno::Sequence<css::beans::GetDirectPropertyTolerantResult> GetPropertyValuesTolerant_Impl(
144  const css::uno::Sequence< OUString >& rPropertyNames, bool bDirectValuesOnly );
145 
146  virtual ~SwXTextPortion() override;
147 
148  //SwClient
149  virtual void SwClientNotify(const SwModify&, const SfxHint& rHint) override;
150 
151 public:
152  SwXTextPortion(const SwUnoCursor* pPortionCursor, css::uno::Reference< css::text::XText > const& rParent, SwTextPortionType eType );
153  SwXTextPortion(const SwUnoCursor* pPortionCursor, css::uno::Reference< css::text::XText > const& rParent, SwFrameFormat& rFormat );
154 
155  // for Ruby
156  SwXTextPortion(const SwUnoCursor* pPortionCursor,
157  SwTextRuby const& rAttr,
158  css::uno::Reference< css::text::XText > const& xParent,
159  bool bIsEnd );
160 
161  //XTextRange
162  virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override;
163  virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override;
164  virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override;
165  virtual OUString SAL_CALL getString() override;
166  virtual void SAL_CALL setString(const OUString& aString) override;
167 
168  //XTolerantMultiPropertySet
169  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;
170  virtual css::uno::Sequence< css::beans::GetPropertyTolerantResult > SAL_CALL getPropertyValuesTolerant( const css::uno::Sequence< OUString >& aPropertyNames ) override;
171  virtual css::uno::Sequence< css::beans::GetDirectPropertyTolerantResult > SAL_CALL getDirectPropertyValuesTolerant( const css::uno::Sequence< OUString >& aPropertyNames ) override;
172 
173  //XMultiPropertySet
174  virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues ) override;
175  virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) override;
176  virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
177  virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
178  virtual void SAL_CALL firePropertiesChangeEvent( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
179 
180  //XPropertySet
181  virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
182  virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
183  virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
184  virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
185  virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
186  virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
187  virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
188 
189  //XPropertyState
190  virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override;
191  virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override;
192  virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override;
193  virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
194 
195  //XUnoTunnel
196  static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
197  virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
198 
199  //XServiceInfo
200  virtual OUString SAL_CALL getImplementationName() override;
201  virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
202  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
203 
204  //XContentEnumerationAccess
205  virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createContentEnumeration(const OUString& aServiceName) override;
206  virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override;
207 
208  void SetRefMark( css::uno::Reference< css::text::XTextContent > const & xMark)
209  { m_xRefMark = xMark; }
210 
211  void SetTOXMark( css::uno::Reference< css::text::XTextContent > const & xMark)
212  { m_xTOXMark = xMark; }
213 
214  void SetBookmark( css::uno::Reference< css::text::XTextContent > const & xMark)
215  { m_xBookmark = xMark; }
216 
217  void SetFootnote( css::uno::Reference< css::text::XFootnote > const & xNote)
218  { m_xFootnote = xNote; }
219 
220  void SetTextField( css::uno::Reference< css::text::XTextField> const & xField)
221  { m_xTextField = xField; }
222 
223  void SetMeta( css::uno::Reference< css::text::XTextContent > const & xMeta)
224  { m_xMeta = xMeta; }
225 
226  void SetCollapsed(bool bSet) { m_bIsCollapsed = bSet;}
227 
229 
231  { return *m_pUnoCursor; }
232 };
233 
235  : public ::cppu::WeakImplHelper
236  < css::container::XEnumeration
237  , css::lang::XServiceInfo
238  , css::lang::XUnoTunnel
239  >
240 {
241  TextRangeList_t m_Portions; // contains all portions, filled by ctor
243 
244 protected:
245  virtual ~SwXTextPortionEnumeration() override;
246 
247 public:
248  SwXTextPortionEnumeration(SwPaM& rParaCursor,
249  css::uno::Reference< css::text::XText > const & xParent,
250  const sal_Int32 nStart, const sal_Int32 nEnd );
251 
252  SwXTextPortionEnumeration(SwPaM& rParaCursor,
253  TextRangeList_t const & rPortions );
254 
255  static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
256 
257  //XUnoTunnel
258  virtual sal_Int64 SAL_CALL getSomething(
259  const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
260 
261  //XEnumeration
262  virtual sal_Bool SAL_CALL hasMoreElements() override;
263  virtual css::uno::Any SAL_CALL nextElement() override;
264 
265  //XServiceInfo
266  virtual OUString SAL_CALL getImplementationName() override;
267  virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
268  virtual css::uno::Sequence< OUString > SAL_CALL
269  getSupportedServiceNames() override;
270 };
271 
273 {
274 private:
276 
278  void Validate();
279 
281 
282  virtual ~SwXRedlinePortion() override;
283 
284 public:
286  SwRangeRedline const& rRedline,
287  SwUnoCursor const* pPortionCursor,
288  css::uno::Reference< css::text::XText > const& xParent,
289  bool const bIsStart);
290 
292  static css::uno::Any GetPropertyValue(
293  OUString const& PropertyName, SwRangeRedline const& rRedline);
295  static css::uno::Sequence< css::beans::PropertyValue > CreateRedlineProperties(
296  SwRangeRedline const& rRedline, bool const bIsStart);
297 
298  virtual css::uno::Sequence< sal_Int8 > SAL_CALL
299  getImplementationId() override;
300 
301  // XPropertySet
302  virtual css::uno::Any SAL_CALL getPropertyValue(
303  const OUString& rPropertyName) override;
304 };
305 
306 #endif
307 
308 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::deque< css::uno::Reference< css::text::XTextRange > > TextRangeList_t
Definition: unometa.hxx:42
std::unique_ptr< css::uno::Any > m_pRubyPosition
Definition: unoport.hxx:113
virtual css::uno::Any SAL_CALL nextElement() override
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override
Definition: unoport.cxx:797
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &PropertyName) override
Definition: unoport.cxx:708
sw::UnoCursorPointer m_pUnoCursor
Definition: unoport.hxx:114
bool m_bIsCollapsed
Definition: unoport.hxx:120
virtual sal_Bool SAL_CALL hasMoreElements() override
virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString &aPropertyName) override
Definition: unoport.cxx:759
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
Definition: unoport.cxx:483
std::unique_ptr< css::uno::Any > m_pRubyStyle
Definition: unoport.hxx:110
virtual ~SwXTextPortionEnumeration() override
css::uno::Reference< css::text::XTextField > m_xTextField
Definition: unoport.hxx:106
std::deque< css::uno::Reference< css::text::XTextRange > > TextRangeList_t
Definition: unoport.hxx:48
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unoredline.cxx:203
SwXTextPortion(const SwUnoCursor *pPortionCursor, css::uno::Reference< css::text::XText > const &rParent, SwTextPortionType eType)
virtual void SAL_CALL removePropertiesChangeListener(const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoport.cxx:677
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Sequence< css::uno::Any > &aValues) override
Definition: unoport.cxx:434
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: unoredline.cxx:247
const SwTextPortionType m_ePortionType
Definition: unoport.hxx:118
css::uno::Reference< css::text::XTextContent > m_xRefMark
Definition: unoport.hxx:98
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
Definition: unoport.cxx:137
SwXRedlinePortion(SwRangeRedline const &rRedline, SwUnoCursor const *pPortionCursor, css::uno::Reference< css::text::XText > const &xParent, bool const bIsStart)
Definition: unoredline.cxx:167
SwFrameFormat * m_pFrameFormat
Definition: unoport.hxx:117
std::unique_ptr< css::uno::Any > m_pRubyText
Definition: unoport.hxx:109
const css::uno::Reference< css::text::XText > m_xParentText
Definition: unoport.hxx:96
void SetTOXMark(css::uno::Reference< css::text::XTextContent > const &xMark)
Definition: unoport.hxx:211
virtual void SAL_CALL setPropertyToDefault(const OUString &PropertyName) override
Definition: unoport.cxx:750
css::uno::Reference< css::text::XTextContent > m_xTOXMark
Definition: unoport.hxx:100
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unoport.cxx:191
css::uno::Sequence< css::beans::GetDirectPropertyTolerantResult > GetPropertyValuesTolerant_Impl(const css::uno::Sequence< OUString > &rPropertyNames, bool bDirectValuesOnly)
Definition: unoport.cxx:573
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
Definition: unoport.cxx:788
css::uno::Reference< css::text::XTextContent > m_xBookmark
Definition: unoport.hxx:102
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
Definition: unoport.cxx:154
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
SwRangeRedline const & m_rRedline
Definition: unoport.hxx:275
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: unoport.cxx:823
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
Definition: unoport.cxx:142
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
void SetFootnote(css::uno::Reference< css::text::XFootnote > const &xNote)
Definition: unoport.hxx:217
Style of a layout element.
Definition: frmfmt.hxx:57
virtual OUString SAL_CALL getImplementationName() override
css::uno::Sequence< css::uno::Any > GetPropertyValues_Impl(const css::uno::Sequence< OUString > &aPropertyNames)
Definition: unoport.cxx:375
void SetPropertyValues_Impl(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Sequence< css::uno::Any > &aValues)
Definition: unoport.cxx:408
void SetBookmark(css::uno::Reference< css::text::XTextContent > const &xMark)
Definition: unoport.hxx:214
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
virtual css::uno::Sequence< css::beans::GetPropertyTolerantResult > SAL_CALL getPropertyValuesTolerant(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: unoport.cxx:551
unsigned char sal_Bool
void SetTextField(css::uno::Reference< css::text::XTextField > const &xField)
Definition: unoport.hxx:220
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: unoport.cxx:693
void SetCollapsed(bool bSet)
Definition: unoport.hxx:226
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unoport.cxx:783
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: unoport.cxx:400
void init(const SwUnoCursor *pPortionCursor)
Definition: unoport.cxx:55
static css::uno::Any GetPropertyValue(OUString const &PropertyName, SwRangeRedline const &rRedline)
Definition: unoredline.cxx:252
sw::WriterMultiListener m_aDepends
Definition: unoport.hxx:116
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: unoport.cxx:207
static css::uno::Sequence< css::beans::PropertyValue > CreateRedlineProperties(SwRangeRedline const &rRedline, bool const bIsStart)
Definition: unoredline.cxx:290
virtual ~SwXRedlinePortion() override
Definition: unoredline.cxx:177
SwXTextPortionEnumeration(SwPaM &rParaCursor, css::uno::Reference< css::text::XText > const &xParent, const sal_Int32 nStart, const sal_Int32 nEnd)
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: unoport.cxx:455
sw::UnoCursorPointer m_pUnoCursor
Definition: unoport.hxx:242
virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(const css::uno::Sequence< OUString > &aPropertyName) override
Definition: unoport.cxx:727
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createContentEnumeration(const OUString &aServiceName) override
Definition: unoport.cxx:770
SwTextPortionType
Definition: unoport.hxx:54
css::uno::Reference< css::text::XTextContent > m_xMeta
Definition: unoport.hxx:108
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unoport.cxx:703
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
SwUnoCursor & GetCursor() const
Definition: unoport.hxx:230
virtual OUString SAL_CALL getString() override
Definition: unoport.cxx:166
css::uno::Reference< css::text::XFootnote > m_xFootnote
Definition: unoport.hxx:104
virtual css::uno::Sequence< css::beans::GetDirectPropertyTolerantResult > SAL_CALL getDirectPropertyValuesTolerant(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: unoport.cxx:566
virtual void SAL_CALL firePropertiesChangeEvent(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoport.cxx:681
void SetRefMark(css::uno::Reference< css::text::XTextContent > const &xMark)
Definition: unoport.hxx:208
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unoport.cxx:807
virtual ~SwXTextPortion() override
Definition: unoport.cxx:130
void GetPropertyValue(css::uno::Any &rVal, const SfxItemPropertySimpleEntry &rEntry, SwUnoCursor *pUnoCursor, std::unique_ptr< SfxItemSet > &pSet)
Definition: unoport.cxx:217
void SetMeta(css::uno::Reference< css::text::XTextContent > const &xMeta)
Definition: unoport.hxx:223
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unoport.cxx:698
std::unique_ptr< css::uno::Any > m_pRubyAdjust
Definition: unoport.hxx:111
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoport.cxx:812
TextRangeList_t m_Portions
Definition: unoport.hxx:241
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoport.cxx:686
const SfxItemPropertySet * m_pPropSet
Definition: unoport.hxx:94
virtual void SAL_CALL addPropertiesChangeListener(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoport.cxx:672
SwTextPortionType GetTextPortionType() const
Definition: unoport.hxx:228
virtual OUString SAL_CALL getImplementationName() override
Definition: unoport.cxx:802
virtual void SAL_CALL setString(const OUString &aString) override
Definition: unoport.cxx:183
std::unique_ptr< css::uno::Any > m_pRubyIsAbove
Definition: unoport.hxx:112