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 {
61  };
62 
63  void DeepCopyPaM(SwPaM const & rSource, SwPaM & rTarget);
64 
66  const css::uno::Reference<css::text::XTextRange> & xTextRange,
68 
69  css::uno::Reference< css::text::XText >
70  CreateParentXText(SwDoc & rDoc, const SwPosition& rPos);
71 
72  bool GetDefaultTextContentValue(css::uno::Any& rAny,
73  std::u16string_view rPropertyName, sal_uInt16 nWID = 0);
74 
75 } // namespace sw
76 
77 typedef ::cppu::WeakImplHelper
78 < css::lang::XUnoTunnel
79 , css::lang::XServiceInfo
80 , css::beans::XPropertySet
81 , css::beans::XPropertyState
82 , css::container::XEnumerationAccess
83 , css::container::XContentEnumerationAccess
84 , css::text::XTextRange
85 , css::text::XRedline
87 
89  : public SwXTextRange_Base
90 {
91 
92 private:
93 
94  friend class SwXText;
95 
96  class Impl;
98 
100  {
101  RANGE_IN_TEXT, // "ordinary" css::text::TextRange
102  RANGE_IN_CELL, // position created with a cell that has no uno object
103  RANGE_IS_TABLE, // anchor of a table
104  RANGE_IS_SECTION, // anchor of a section
105  };
106 
107  void SetPositions(SwPaM const& rPam);
108  //TODO: new exception type for protected content
110  void DeleteAndInsert(
111  const OUString& rText, const bool bForceExpandHints);
112  void Invalidate();
113 
114  virtual ~SwXTextRange() override;
115 
116 public:
117 
118  SwXTextRange(SwPaM const & rPam,
119  const css::uno::Reference< css::text::XText > & xParent,
120  const enum RangePosition eRange = RANGE_IN_TEXT);
121  // only for RANGE_IS_TABLE
122  SwXTextRange(SwTableFormat& rTableFormat);
123  // only for RANGE_IS_SECTION
124  SwXTextRange(SwSectionFormat& rSectionFormat);
125 
126  const SwDoc& GetDoc() const;
127  SwDoc& GetDoc();
128  bool GetPositions(SwPaM & rToFill,
130 
131  static css::uno::Reference< css::text::XTextRange > CreateXTextRange(
132  SwDoc & rDoc,
133  const SwPosition& rPos, const SwPosition *const pMark);
134 
135  static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
136 
137  // XUnoTunnel
138  virtual sal_Int64 SAL_CALL getSomething(
139  const css::uno::Sequence< sal_Int8 >& rIdentifier) override;
140 
141  // XServiceInfo
142  virtual OUString SAL_CALL getImplementationName() override;
143  virtual sal_Bool SAL_CALL supportsService(
144  const OUString& rServiceName) override;
145  virtual css::uno::Sequence< OUString > SAL_CALL
146  getSupportedServiceNames() override;
147 
148  // XPropertySet
149  virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
150  getPropertySetInfo() override;
151  virtual void SAL_CALL setPropertyValue(
152  const OUString& rPropertyName,
153  const css::uno::Any& rValue) override;
154  virtual css::uno::Any SAL_CALL getPropertyValue(
155  const OUString& rPropertyName) override;
156  virtual void SAL_CALL addPropertyChangeListener(
157  const OUString& rPropertyName,
158  const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override;
159  virtual void SAL_CALL removePropertyChangeListener(
160  const OUString& rPropertyName,
161  const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override;
162  virtual void SAL_CALL addVetoableChangeListener(
163  const OUString& rPropertyName,
164  const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override;
165  virtual void SAL_CALL removeVetoableChangeListener(
166  const OUString& rPropertyName,
167  const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override;
168 
169  // XPropertyState
170  virtual css::beans::PropertyState SAL_CALL
171  getPropertyState(const OUString& rPropertyName) override;
172  virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL
173  getPropertyStates(
174  const css::uno::Sequence< OUString >& rPropertyNames) override;
175  virtual void SAL_CALL setPropertyToDefault(
176  const OUString& rPropertyName) override;
177  virtual css::uno::Any SAL_CALL getPropertyDefault(
178  const OUString& rPropertyName) override;
179 
180  // XElementAccess
181  virtual css::uno::Type SAL_CALL getElementType() override;
182  virtual sal_Bool SAL_CALL hasElements() override;
183 
184  // XEnumerationAccess
185  virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
186  createEnumeration() override;
187 
188  // XContentEnumerationAccess
189  virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
190  createContentEnumeration(const OUString& rServiceName) override;
191  virtual css::uno::Sequence< OUString > SAL_CALL
192  getAvailableServiceNames() override;
193 
194  // XTextRange
195  virtual css::uno::Reference< css::text::XText >
196  SAL_CALL getText() override;
197  virtual css::uno::Reference<
198  css::text::XTextRange > SAL_CALL getStart() override;
199  virtual css::uno::Reference<
200  css::text::XTextRange > SAL_CALL getEnd() override;
201  virtual OUString SAL_CALL getString() override;
202  virtual void SAL_CALL setString(const OUString& rString) override;
203 
204  // XRedline
205  virtual void SAL_CALL makeRedline(
206  const OUString& rRedlineType,
207  const css::uno::Sequence< css::beans::PropertyValue >& RedlineProperties) override;
208 
209 };
210 
211 typedef ::cppu::WeakImplHelper
212 < css::lang::XUnoTunnel
213 , css::lang::XServiceInfo
214 , css::container::XIndexAccess
216 
218 {
219  virtual SwUnoCursor* GetCursor() =0;
220  static SwXTextRanges* Create(SwPaM* const pCursor);
221  static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
222 };
223 
224 #endif // INCLUDED_SW_INC_UNOTEXTRANGE_HXX
225 
226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Marks a position in the document model.
Definition: pam.hxx:35
static SwXTextRanges * Create(SwPaM *const pCursor)
Definition: unoobj2.cxx:1609
Definition: doc.hxx:186
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:58
::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:1100
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unoobj2.cxx:1617
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:1224