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