LibreOffice Module sw (master)  1
unotextrange.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 
20 #ifndef INCLUDED_SW_INC_UNOTEXTRANGE_HXX
21 #define INCLUDED_SW_INC_UNOTEXTRANGE_HXX
22 
23 #include <com/sun/star/lang/XUnoTunnel.hpp>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <com/sun/star/beans/XPropertySet.hpp>
26 #include <com/sun/star/beans/XPropertyState.hpp>
27 #include <com/sun/star/container/XIndexAccess.hpp>
28 #include <com/sun/star/container/XEnumerationAccess.hpp>
29 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
30 #include <com/sun/star/text/XTextRange.hpp>
31 #include <com/sun/star/text/XRedline.hpp>
32 
33 #include <cppuhelper/implbase.hxx>
34 
35 #include "pam.hxx"
36 #include "unobaseclass.hxx"
37 
38 class SwDoc;
39 class SwUnoCursor;
40 class SwFrameFormat;
41 
43  : public SwPaM
44 {
45 
46 private:
47  SwUnoInternalPaM(const SwUnoInternalPaM&) = delete;
48 
49 public:
50  SwUnoInternalPaM(SwDoc& rDoc);
51  virtual ~SwUnoInternalPaM() override;
52 
53  SwUnoInternalPaM& operator=(const SwPaM& rPaM);
54 };
55 
56 namespace sw {
57 
58  enum class TextRangeMode {
62  };
63 
64  void DeepCopyPaM(SwPaM const & rSource, SwPaM & rTarget);
65 
67  const css::uno::Reference<css::text::XTextRange> & xTextRange,
69 
70  css::uno::Reference< css::text::XText >
71  CreateParentXText(SwDoc & rDoc, const SwPosition& rPos);
72 
73  bool GetDefaultTextContentValue(css::uno::Any& rAny,
74  std::u16string_view rPropertyName, sal_uInt16 nWID = 0);
75 
76 } // namespace sw
77 
78 typedef ::cppu::WeakImplHelper
79 < css::lang::XUnoTunnel
80 , css::lang::XServiceInfo
81 , css::beans::XPropertySet
82 , css::beans::XPropertyState
83 , css::container::XEnumerationAccess
84 , css::container::XContentEnumerationAccess
85 , css::text::XTextRange
86 , css::text::XRedline
88 
90  : public SwXTextRange_Base
91 {
92 
93 private:
94 
95  friend class SwXText;
96 
97  class Impl;
99 
101  {
102  RANGE_IN_TEXT, // "ordinary" css::text::TextRange
103  RANGE_IN_CELL, // position created with a cell that has no uno object
104  RANGE_IS_TABLE, // anchor of a table
105  RANGE_IS_SECTION, // anchor of a section
106  };
107 
108  void SetPositions(SwPaM const& rPam);
109  //TODO: new exception type for protected content
111  void DeleteAndInsert(
112  const OUString& rText, const bool bForceExpandHints);
113  void Invalidate();
114 
115  virtual ~SwXTextRange() override;
116 
117 public:
118 
119  SwXTextRange(SwPaM const & rPam,
120  const css::uno::Reference< css::text::XText > & xParent,
121  const enum RangePosition eRange = RANGE_IN_TEXT);
122  // only for RANGE_IS_TABLE
123  SwXTextRange(SwTableFormat& rTableFormat);
124  // only for RANGE_IS_SECTION
125  SwXTextRange(SwSectionFormat& rSectionFormat);
126 
127  const SwDoc& GetDoc() const;
128  SwDoc& GetDoc();
129  bool GetPositions(SwPaM & rToFill,
131 
132  static css::uno::Reference< css::text::XTextRange > CreateXTextRange(
133  SwDoc & rDoc,
134  const SwPosition& rPos, const SwPosition *const pMark);
135 
136  static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
137 
138  // XUnoTunnel
139  virtual sal_Int64 SAL_CALL getSomething(
140  const css::uno::Sequence< sal_Int8 >& rIdentifier) override;
141 
142  // XServiceInfo
143  virtual OUString SAL_CALL getImplementationName() override;
144  virtual sal_Bool SAL_CALL supportsService(
145  const OUString& rServiceName) override;
146  virtual css::uno::Sequence< OUString > SAL_CALL
147  getSupportedServiceNames() override;
148 
149  // XPropertySet
150  virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
151  getPropertySetInfo() override;
152  virtual void SAL_CALL setPropertyValue(
153  const OUString& rPropertyName,
154  const css::uno::Any& rValue) override;
155  virtual css::uno::Any SAL_CALL getPropertyValue(
156  const OUString& rPropertyName) override;
157  virtual void SAL_CALL addPropertyChangeListener(
158  const OUString& rPropertyName,
159  const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override;
160  virtual void SAL_CALL removePropertyChangeListener(
161  const OUString& rPropertyName,
162  const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override;
163  virtual void SAL_CALL addVetoableChangeListener(
164  const OUString& rPropertyName,
165  const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override;
166  virtual void SAL_CALL removeVetoableChangeListener(
167  const OUString& rPropertyName,
168  const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override;
169 
170  // XPropertyState
171  virtual css::beans::PropertyState SAL_CALL
172  getPropertyState(const OUString& rPropertyName) override;
173  virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL
174  getPropertyStates(
175  const css::uno::Sequence< OUString >& rPropertyNames) override;
176  virtual void SAL_CALL setPropertyToDefault(
177  const OUString& rPropertyName) override;
178  virtual css::uno::Any SAL_CALL getPropertyDefault(
179  const OUString& rPropertyName) override;
180 
181  // XElementAccess
182  virtual css::uno::Type SAL_CALL getElementType() override;
183  virtual sal_Bool SAL_CALL hasElements() override;
184 
185  // XEnumerationAccess
186  virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
187  createEnumeration() override;
188 
189  // XContentEnumerationAccess
190  virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
191  createContentEnumeration(const OUString& rServiceName) override;
192  virtual css::uno::Sequence< OUString > SAL_CALL
193  getAvailableServiceNames() override;
194 
195  // XTextRange
196  virtual css::uno::Reference< css::text::XText >
197  SAL_CALL getText() override;
198  virtual css::uno::Reference<
199  css::text::XTextRange > SAL_CALL getStart() override;
200  virtual css::uno::Reference<
201  css::text::XTextRange > SAL_CALL getEnd() override;
202  virtual OUString SAL_CALL getString() override;
203  virtual void SAL_CALL setString(const OUString& rString) override;
204 
205  // XRedline
206  virtual void SAL_CALL makeRedline(
207  const OUString& rRedlineType,
208  const css::uno::Sequence< css::beans::PropertyValue >& RedlineProperties) override;
209 
210 };
211 
212 typedef ::cppu::WeakImplHelper
213 < css::lang::XUnoTunnel
214 , css::lang::XServiceInfo
215 , css::container::XIndexAccess
217 
219 {
220  virtual SwUnoCursor* GetCursor() =0;
221  static rtl::Reference<SwXTextRanges> Create(SwPaM* const pCursor);
222  static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
223 };
224 
225 #endif // INCLUDED_SW_INC_UNOTEXTRANGE_HXX
226 
227 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static rtl::Reference< SwXTextRanges > Create(SwPaM *const pCursor)
Definition: unoobj2.cxx:1620
Marks a position in the document model.
Definition: pam.hxx:35
Definition: doc.hxx:188
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
Dialog to specify the properties of date form field.
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
TextRangeMode
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
std::unique_ptr< T, UnoImplPtrDeleter< T > > UnoImplPtr
Smart pointer class ensuring that the pointed object is deleted with a locked SolarMutex.
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
bool GetDefaultTextContentValue(css::uno::Any &rAny, std::u16string_view rPropertyName, sal_uInt16 nWID=0)
Style of a layout element.
Definition: frmfmt.hxx:59
::cppu::WeakImplHelper< css::lang::XUnoTunnel, css::lang::XServiceInfo, css::container::XIndexAccess > SwXTextRanges_Base
unsigned char sal_Bool
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
bool setPropertyValue(uno::Sequence< beans::PropertyValue > &aProp, const OUString &aName, const uno::Any &aValue)
bool XTextRangeToSwPaM(SwUnoInternalPaM &rToFill, const uno::Reference< text::XTextRange > &xTextRange,::sw::TextRangeMode const eMode)
Definition: unoobj2.cxx:1107
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unoobj2.cxx:1623
void makeRedline(SwPaM const &rPaM, std::u16string_view rRedlineType, const uno::Sequence< beans::PropertyValue > &rRedlineProperties)
SwPaM & operator=(const SwPaM &)
@@ semantic: no copy assignment for super class Ring.
Definition: pam.cxx:460
::cppu::WeakImplHelper< css::lang::XUnoTunnel, css::lang::XServiceInfo, css::beans::XPropertySet, css::beans::XPropertyState, css::container::XEnumerationAccess, css::container::XContentEnumerationAccess, css::text::XTextRange, css::text::XRedline > SwXTextRange_Base
::sw::UnoImplPtr< Impl > m_pImpl
virtual SwUnoCursor * GetCursor()=0
OUString getString(const Any &_rAny)
void DeepCopyPaM(SwPaM const &rSource, SwPaM &rTarget)
Definition: unoobj2.cxx:78
uno::Reference< text::XText > CreateParentXText(SwDoc &rDoc, const SwPosition &rPos)
Definition: unoobj2.cxx:1235