Revert "reduce symbol visibility in sw"
[LibreOffice.git] / sw / inc / unotextrange.hxx
blob1d2265ddfec13f4e7595338dbe8755c757ce5f6c
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/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>
34 #include "pam.hxx"
35 #include "unobaseclass.hxx"
37 class SwDoc;
38 class SwUnoCursor;
39 class SwFrameFormat;
40 class SwXText;
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< SwXText >
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::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
86 > SwXTextRange_Base;
88 class SW_DLLPUBLIC SwXTextRange final
89 : public SwXTextRange_Base
92 private:
94 friend class SwXText;
96 class Impl;
97 ::sw::UnoImplPtr<Impl> m_pImpl;
99 void SetPositions(SwPaM const& rPam);
100 //TODO: new exception type for protected content
101 /// @throws css::uno::RuntimeException
102 void DeleteAndInsert(
103 std::u16string_view aText, ::sw::DeleteAndInsertMode eMode);
104 void Invalidate();
106 virtual ~SwXTextRange() override;
108 public:
110 enum RangePosition
112 RANGE_IN_TEXT, // "ordinary" css::text::TextRange
113 RANGE_IN_CELL, // position created with a cell that has no uno object
114 RANGE_IS_TABLE, // anchor of a table
115 RANGE_IS_SECTION, // anchor of a section
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);
126 const SwDoc& GetDoc() const;
127 SwDoc& GetDoc();
128 bool GetPositions(SwPaM & rToFill,
129 ::sw::TextRangeMode eMode = ::sw::TextRangeMode::RequireTextNode) const;
131 static rtl::Reference< SwXTextRange > CreateXTextRange(
132 SwDoc & rDoc,
133 const SwPosition& rPos, const SwPosition *const pMark);
135 // XServiceInfo
136 virtual OUString SAL_CALL getImplementationName() override;
137 virtual sal_Bool SAL_CALL supportsService(
138 const OUString& rServiceName) override;
139 virtual css::uno::Sequence< OUString > SAL_CALL
140 getSupportedServiceNames() override;
142 // XPropertySet
143 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
144 getPropertySetInfo() override;
145 virtual void SAL_CALL setPropertyValue(
146 const OUString& rPropertyName,
147 const css::uno::Any& rValue) override;
148 virtual css::uno::Any SAL_CALL getPropertyValue(
149 const OUString& rPropertyName) override;
150 virtual void SAL_CALL addPropertyChangeListener(
151 const OUString& rPropertyName,
152 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override;
153 virtual void SAL_CALL removePropertyChangeListener(
154 const OUString& rPropertyName,
155 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) override;
156 virtual void SAL_CALL addVetoableChangeListener(
157 const OUString& rPropertyName,
158 const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override;
159 virtual void SAL_CALL removeVetoableChangeListener(
160 const OUString& rPropertyName,
161 const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) override;
163 // XPropertyState
164 virtual css::beans::PropertyState SAL_CALL
165 getPropertyState(const OUString& rPropertyName) override;
166 virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL
167 getPropertyStates(
168 const css::uno::Sequence< OUString >& rPropertyNames) override;
169 virtual void SAL_CALL setPropertyToDefault(
170 const OUString& rPropertyName) override;
171 virtual css::uno::Any SAL_CALL getPropertyDefault(
172 const OUString& rPropertyName) override;
174 // XElementAccess
175 virtual css::uno::Type SAL_CALL getElementType() override;
176 virtual sal_Bool SAL_CALL hasElements() override;
178 // XEnumerationAccess
179 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
180 createEnumeration() override;
182 // XContentEnumerationAccess
183 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
184 createContentEnumeration(const OUString& rServiceName) override;
185 virtual css::uno::Sequence< OUString > SAL_CALL
186 getAvailableServiceNames() override;
188 // XTextRange
189 virtual css::uno::Reference< css::text::XText >
190 SAL_CALL getText() override;
191 virtual css::uno::Reference<
192 css::text::XTextRange > SAL_CALL getStart() override;
193 virtual css::uno::Reference<
194 css::text::XTextRange > SAL_CALL getEnd() override;
195 virtual OUString SAL_CALL getString() override;
196 virtual void SAL_CALL setString(const OUString& rString) override;
198 // XRedline
199 virtual void SAL_CALL makeRedline(
200 const OUString& rRedlineType,
201 const css::uno::Sequence< css::beans::PropertyValue >& RedlineProperties) override;
205 typedef ::cppu::WeakImplHelper
206 < css::lang::XServiceInfo
207 , css::container::XIndexAccess
208 > SwXTextRanges_Base;
210 struct SwXTextRanges : public SwXTextRanges_Base
212 virtual SwUnoCursor* GetCursor() =0;
213 static rtl::Reference<SwXTextRanges> Create(SwPaM* const pCursor);
216 #endif // INCLUDED_SW_INC_UNOTEXTRANGE_HXX
218 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */