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/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>
36 #include "unobaseclass.hxx"
42 class SW_DLLPUBLIC SwUnoInternalPaM final
47 SwUnoInternalPaM(const SwUnoInternalPaM
&) = delete;
50 SwUnoInternalPaM(SwDoc
& rDoc
);
51 virtual ~SwUnoInternalPaM() override
;
53 SwUnoInternalPaM
& operator=(const SwPaM
& rPaM
);
58 void DeepCopyPaM(SwPaM
const & rSource
, SwPaM
& rTarget
);
60 SW_DLLPUBLIC
bool XTextRangeToSwPaM(SwUnoInternalPaM
& rToFill
,
61 const css::uno::Reference
< css::text::XTextRange
> & xTextRange
);
63 css::uno::Reference
< css::text::XText
>
64 CreateParentXText(SwDoc
& rDoc
, const SwPosition
& rPos
);
66 bool GetDefaultTextContentValue(css::uno::Any
& rAny
,
67 const OUString
& rPropertyName
, sal_uInt16 nWID
= 0);
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
82 class SW_DLLPUBLIC SwXTextRange final
83 : public SwXTextRange_Base
91 ::sw::UnoImplPtr
<Impl
> m_pImpl
;
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
100 void SetPositions(SwPaM
const& rPam
);
101 //TODO: new exception type for protected content
102 /// @throws css::uno::RuntimeException
103 void DeleteAndInsert(
104 const OUString
& rText
, const bool bForceExpandHints
);
107 virtual ~SwXTextRange() override
;
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
);
117 const SwDoc
& GetDoc() const;
119 bool GetPositions(SwPaM
& rToFill
) const;
121 static css::uno::Reference
< css::text::XTextRange
> CreateXTextRange(
123 const SwPosition
& rPos
, const SwPosition
*const pMark
);
125 static const css::uno::Sequence
< sal_Int8
>& getUnoTunnelId();
128 virtual sal_Int64 SAL_CALL
getSomething(
129 const css::uno::Sequence
< sal_Int8
>& rIdentifier
) override
;
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
;
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
;
160 virtual css::beans::PropertyState SAL_CALL
161 getPropertyState(const OUString
& rPropertyName
) override
;
162 virtual css::uno::Sequence
< css::beans::PropertyState
> SAL_CALL
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
;
171 virtual css::uno::Type SAL_CALL
getElementType() override
;
172 virtual sal_Bool SAL_CALL
hasElements() override
;
174 // XEnumerationAccess
175 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
176 createEnumeration() override
;
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
;
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
;
195 virtual void SAL_CALL
makeRedline(
196 const OUString
& rRedlineType
,
197 const css::uno::Sequence
< css::beans::PropertyValue
>& RedlineProperties
) override
;
201 typedef ::cppu::WeakImplHelper
202 < css::lang::XUnoTunnel
203 , css::lang::XServiceInfo
204 , css::container::XIndexAccess
205 > SwXTextRanges_Base
;
207 struct SwXTextRanges
: public SwXTextRanges_Base
209 virtual SwUnoCursor
* GetCursor() =0;
210 static SwXTextRanges
* Create(SwPaM
* const pCursor
);
211 static const css::uno::Sequence
< sal_Int8
>& getUnoTunnelId();
214 #endif // INCLUDED_SW_INC_UNOTEXTRANGE_HXX
216 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */