Basic compiler undetected typo
[LibreOffice.git] / sw / inc / unotextrange.hxx
blob4d8ed2df2c06edec1cbe68081117637009ff5954
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/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>
33 #include <cppuhelper/implbase.hxx>
35 #include "pam.hxx"
36 #include "unobaseclass.hxx"
38 class SwDoc;
39 class SwUnoCursor;
40 class SwFrameFormat;
42 class SW_DLLPUBLIC SwUnoInternalPaM final
43 : public SwPaM
46 private:
47 SwUnoInternalPaM(const SwUnoInternalPaM&) = delete;
49 public:
50 SwUnoInternalPaM(SwDoc& rDoc);
51 virtual ~SwUnoInternalPaM() override;
53 SwUnoInternalPaM& operator=(const SwPaM& rPaM);
56 namespace sw {
58 enum class TextRangeMode {
59 RequireTextNode,
60 AllowNonTextNode,
61 AllowTableNode
64 void DeepCopyPaM(SwPaM const & rSource, SwPaM & rTarget);
66 SW_DLLPUBLIC bool XTextRangeToSwPaM(SwUnoInternalPaM& rToFill,
67 const css::uno::Reference<css::text::XTextRange> & xTextRange,
68 TextRangeMode eMode = TextRangeMode::RequireTextNode);
70 css::uno::Reference< css::text::XText >
71 CreateParentXText(SwDoc & rDoc, const SwPosition& rPos);
73 bool GetDefaultTextContentValue(css::uno::Any& rAny,
74 std::u16string_view rPropertyName, sal_uInt16 nWID = 0);
76 } // namespace sw
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
87 > SwXTextRange_Base;
89 class SW_DLLPUBLIC SwXTextRange final
90 : public SwXTextRange_Base
93 private:
95 friend class SwXText;
97 class Impl;
98 ::sw::UnoImplPtr<Impl> m_pImpl;
100 enum RangePosition
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
108 void SetPositions(SwPaM const& rPam);
109 //TODO: new exception type for protected content
110 /// @throws css::uno::RuntimeException
111 void DeleteAndInsert(
112 const OUString& rText, const bool bForceExpandHints);
113 void Invalidate();
115 virtual ~SwXTextRange() override;
117 public:
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);
127 const SwDoc& GetDoc() const;
128 SwDoc& GetDoc();
129 bool GetPositions(SwPaM & rToFill,
130 ::sw::TextRangeMode eMode = ::sw::TextRangeMode::RequireTextNode) const;
132 static css::uno::Reference< css::text::XTextRange > CreateXTextRange(
133 SwDoc & rDoc,
134 const SwPosition& rPos, const SwPosition *const pMark);
136 static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
138 // XUnoTunnel
139 virtual sal_Int64 SAL_CALL getSomething(
140 const css::uno::Sequence< sal_Int8 >& rIdentifier) override;
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;
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;
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;
181 // XElementAccess
182 virtual css::uno::Type SAL_CALL getElementType() override;
183 virtual sal_Bool SAL_CALL hasElements() override;
185 // XEnumerationAccess
186 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
187 createEnumeration() override;
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;
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;
205 // XRedline
206 virtual void SAL_CALL makeRedline(
207 const OUString& rRedlineType,
208 const css::uno::Sequence< css::beans::PropertyValue >& RedlineProperties) override;
212 typedef ::cppu::WeakImplHelper
213 < css::lang::XUnoTunnel
214 , css::lang::XServiceInfo
215 , css::container::XIndexAccess
216 > SwXTextRanges_Base;
218 struct SwXTextRanges : public SwXTextRanges_Base
220 virtual SwUnoCursor* GetCursor() =0;
221 static rtl::Reference<SwXTextRanges> Create(SwPaM* const pCursor);
222 static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
225 #endif // INCLUDED_SW_INC_UNOTEXTRANGE_HXX
227 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */