1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SW_INC_UNOTEXTRANGE_HXX
21 #define INCLUDED_SW_INC_UNOTEXTRANGE_HXX
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>
32 #include <cppuhelper/implbase.hxx>
35 #include "unobaseclass.hxx"
41 class SW_DLLPUBLIC SwUnoInternalPaM final
46 SwUnoInternalPaM(const SwUnoInternalPaM
&) = delete;
49 SwUnoInternalPaM(SwDoc
& rDoc
);
50 virtual ~SwUnoInternalPaM() override
;
52 SwUnoInternalPaM
& operator=(const SwPaM
& rPaM
);
57 enum class TextRangeMode
{
63 void DeepCopyPaM(SwPaM
const & rSource
, SwPaM
& rTarget
);
65 SW_DLLPUBLIC
bool XTextRangeToSwPaM(SwUnoInternalPaM
& rToFill
,
66 const css::uno::Reference
<css::text::XTextRange
> & xTextRange
,
67 TextRangeMode eMode
= TextRangeMode::RequireTextNode
);
69 css::uno::Reference
< css::text::XText
>
70 CreateParentXText(SwDoc
& rDoc
, const SwPosition
& rPos
);
72 bool GetDefaultTextContentValue(css::uno::Any
& rAny
,
73 std::u16string_view rPropertyName
, sal_uInt16 nWID
= 0);
77 typedef ::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
87 class SW_DLLPUBLIC SwXTextRange final
88 : public SwXTextRange_Base
96 ::sw::UnoImplPtr
<Impl
> m_pImpl
;
98 void SetPositions(SwPaM
const& rPam
);
99 //TODO: new exception type for protected content
100 /// @throws css::uno::RuntimeException
101 void DeleteAndInsert(
102 std::u16string_view aText
, ::sw::DeleteAndInsertMode eMode
);
105 virtual ~SwXTextRange() override
;
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
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
);
125 const SwDoc
& GetDoc() const;
127 bool GetPositions(SwPaM
& rToFill
,
128 ::sw::TextRangeMode eMode
= ::sw::TextRangeMode::RequireTextNode
) const;
130 static rtl::Reference
< SwXTextRange
> CreateXTextRange(
132 const SwPosition
& rPos
, const SwPosition
*const pMark
);
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
;
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
;
163 virtual css::beans::PropertyState SAL_CALL
164 getPropertyState(const OUString
& rPropertyName
) override
;
165 virtual css::uno::Sequence
< css::beans::PropertyState
> SAL_CALL
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
;
174 virtual css::uno::Type SAL_CALL
getElementType() override
;
175 virtual sal_Bool SAL_CALL
hasElements() override
;
177 // XEnumerationAccess
178 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
179 createEnumeration() override
;
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
;
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
;
198 virtual void SAL_CALL
makeRedline(
199 const OUString
& rRedlineType
,
200 const css::uno::Sequence
< css::beans::PropertyValue
>& RedlineProperties
) override
;
204 typedef ::cppu::WeakImplHelper
205 < css::lang::XServiceInfo
206 , css::container::XIndexAccess
207 > SwXTextRanges_Base
;
209 struct SwXTextRanges
: public SwXTextRanges_Base
211 virtual SwUnoCursor
* GetCursor() =0;
212 static rtl::Reference
<SwXTextRanges
> Create(SwPaM
* const pCursor
);
215 #endif // INCLUDED_SW_INC_UNOTEXTRANGE_HXX
217 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */