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