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 #include <svl/listener.hxx>
39 
40 #include <unocrsr.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 {
78 };
79 
80 class SwXTextPortion : public cppu::WeakImplHelper
81 <
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
90 >,
91  public SvtListener
92 {
93 private:
94 
96  const css::uno::Reference< css::text::XText >
98  css::uno::Reference< css::text::XTextContent >
100  css::uno::Reference< css::text::XTextContent >
102  css::uno::Reference< css::text::XTextContent >
104  css::uno::Reference< css::text::XFootnote >
106  css::uno::Reference< css::text::XTextField >
108  css::uno::Reference< css::text::XTextContent >
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;
116 
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  virtual void Notify(const SfxHint& rHint) override;
149 
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 );
153 
154  // for Ruby
155  SwXTextPortion(const SwUnoCursor* pPortionCursor,
156  SwTextRuby const& rAttr,
157  css::uno::Reference< css::text::XText > const& xParent,
158  bool bIsEnd );
159 
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;
166 
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;
171 
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;
178 
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;
187 
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;
193 
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;
197 
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;
202 
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;
206 
207  void SetRefMark( css::uno::Reference< css::text::XTextContent > const & xMark)
208  { m_xRefMark = xMark; }
209 
210  void SetTOXMark( css::uno::Reference< css::text::XTextContent > const & xMark)
211  { m_xTOXMark = xMark; }
212 
213  void SetBookmark( css::uno::Reference< css::text::XTextContent > const & xMark)
214  { m_xBookmark = xMark; }
215 
216  void SetFootnote( css::uno::Reference< css::text::XFootnote > const & xNote)
217  { m_xFootnote = xNote; }
218 
219  void SetTextField( css::uno::Reference< css::text::XTextField> const & xField)
220  { m_xTextField = xField; }
221 
222  void SetMeta( css::uno::Reference< css::text::XTextContent > const & xMeta)
223  { m_xMeta = xMeta; }
224 
225  void SetCollapsed(bool bSet) { m_bIsCollapsed = bSet;}
226 
228 
230  { return *m_pUnoCursor; }
231 };
232 
234  : public ::cppu::WeakImplHelper
235  < css::container::XEnumeration
236  , css::lang::XServiceInfo
237  , css::lang::XUnoTunnel
238  >
239 {
240  TextRangeList_t m_Portions; // contains all portions, filled by ctor
242 
243 protected:
244  virtual ~SwXTextPortionEnumeration() override;
245 
246 public:
247  SwXTextPortionEnumeration(SwPaM& rParaCursor,
248  css::uno::Reference< css::text::XText > const & xParent,
249  const sal_Int32 nStart, const sal_Int32 nEnd );
250 
251  SwXTextPortionEnumeration(SwPaM& rParaCursor,
252  TextRangeList_t const & rPortions );
253 
254  static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
255 
256  //XUnoTunnel
257  virtual sal_Int64 SAL_CALL getSomething(
258  const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
259 
260  //XEnumeration
261  virtual sal_Bool SAL_CALL hasMoreElements() override;
262  virtual css::uno::Any SAL_CALL nextElement() override;
263 
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;
269 };
270 
272 {
273 private:
275 
277  void Validate();
278 
280 
281  virtual ~SwXRedlinePortion() override;
282 
283 public:
285  SwRangeRedline const& rRedline,
286  SwUnoCursor const* pPortionCursor,
287  css::uno::Reference< css::text::XText > const& xParent,
288  bool const bIsStart);
289 
291  static css::uno::Any GetPropertyValue(
292  OUString const& PropertyName, SwRangeRedline const& rRedline);
294  static css::uno::Sequence< css::beans::PropertyValue > CreateRedlineProperties(
295  SwRangeRedline const& rRedline, bool const bIsStart);
296 
297  virtual css::uno::Sequence< sal_Int8 > SAL_CALL
298  getImplementationId() override;
299 
300  // XPropertySet
301  virtual css::uno::Any SAL_CALL getPropertyValue(
302  const OUString& rPropertyName) override;
303 };
304 
305 #endif
306 
307 /* 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:114
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:115
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:111
virtual ~SwXTextPortionEnumeration() override
css::uno::Reference< css::text::XTextField > m_xTextField
Definition: unoport.hxx:107
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:99
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
Definition: unoport.cxx:134
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:110
const css::uno::Reference< css::text::XText > m_xParentText
Definition: unoport.hxx:97
void SetTOXMark(css::uno::Reference< css::text::XTextContent > const &xMark)
Definition: unoport.hxx:210
virtual void SAL_CALL setPropertyToDefault(const OUString &PropertyName) override
Definition: unoport.cxx:750
css::uno::Reference< css::text::XTextContent > m_xTOXMark
Definition: unoport.hxx:101
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unoport.cxx:188
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:103
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
Definition: unoport.cxx:151
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
SwRangeRedline const & m_rRedline
Definition: unoport.hxx:274
virtual void Notify(const SfxHint &rHint) override
Definition: unoport.cxx:823
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
Definition: unoport.cxx:139
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:216
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:213
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:219
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:225
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
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: unoport.cxx:204
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:241
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:109
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:229
virtual OUString SAL_CALL getString() override
Definition: unoport.cxx:163
css::uno::Reference< css::text::XFootnote > m_xFootnote
Definition: unoport.hxx:105
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:207
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unoport.cxx:807
virtual ~SwXTextPortion() override
Definition: unoport.cxx:127
void GetPropertyValue(css::uno::Any &rVal, const SfxItemPropertySimpleEntry &rEntry, SwUnoCursor *pUnoCursor, std::unique_ptr< SfxItemSet > &pSet)
Definition: unoport.cxx:214
void SetMeta(css::uno::Reference< css::text::XTextContent > const &xMeta)
Definition: unoport.hxx:222
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:112
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoport.cxx:812
TextRangeList_t m_Portions
Definition: unoport.hxx:240
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:95
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:227
virtual OUString SAL_CALL getImplementationName() override
Definition: unoport.cxx:802
virtual void SAL_CALL setString(const OUString &aString) override
Definition: unoport.cxx:180
std::unique_ptr< css::uno::Any > m_pRubyIsAbove
Definition: unoport.hxx:113