Line data Source code
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/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>
32 :
33 : #include <cppuhelper/implbase.hxx>
34 :
35 : #include <pam.hxx>
36 : #include <unobaseclass.hxx>
37 :
38 : class SwDoc;
39 : class SwUnoCrsr;
40 : class SwFrameFormat;
41 :
42 : class SW_DLLPUBLIC SwUnoInternalPaM
43 : : public SwPaM
44 : {
45 :
46 : private:
47 : SwUnoInternalPaM(const SwUnoInternalPaM&) SAL_DELETED_FUNCTION;
48 :
49 : public:
50 : SwUnoInternalPaM(SwDoc& rDoc);
51 : virtual ~SwUnoInternalPaM();
52 :
53 : SwUnoInternalPaM& operator=(const SwPaM& rPaM);
54 : };
55 :
56 : namespace sw {
57 :
58 : void DeepCopyPaM(SwPaM const & rSource, SwPaM & rTarget);
59 :
60 : SW_DLLPUBLIC bool XTextRangeToSwPaM(SwUnoInternalPaM& rToFill,
61 : const ::com::sun::star::uno::Reference<
62 : ::com::sun::star::text::XTextRange > & xTextRange);
63 :
64 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >
65 : CreateParentXText(SwDoc & rDoc, const SwPosition& rPos);
66 :
67 : bool GetDefaultTextContentValue(::com::sun::star::uno::Any& rAny,
68 : const OUString& rPropertyName, sal_uInt16 nWID = 0);
69 :
70 : } // namespace sw
71 :
72 : typedef ::cppu::WeakImplHelper
73 : < ::com::sun::star::lang::XUnoTunnel
74 : , ::com::sun::star::lang::XServiceInfo
75 : , ::com::sun::star::beans::XPropertySet
76 : , ::com::sun::star::beans::XPropertyState
77 : , ::com::sun::star::container::XEnumerationAccess
78 : , ::com::sun::star::container::XContentEnumerationAccess
79 : , ::com::sun::star::text::XTextRange
80 : , ::com::sun::star::text::XRedline
81 : > SwXTextRange_Base;
82 :
83 : class SW_DLLPUBLIC SwXTextRange
84 : : public SwXTextRange_Base
85 : {
86 :
87 : private:
88 :
89 : friend class SwXText;
90 :
91 : class Impl;
92 : ::sw::UnoImplPtr<Impl> m_pImpl;
93 :
94 : enum RangePosition
95 : {
96 : RANGE_IN_TEXT, // "ordinary" ::com::sun::star::text::TextRange
97 : RANGE_IN_CELL, // position created with a cell that has no uno object
98 : RANGE_IS_TABLE, // anchor of a table
99 : };
100 :
101 : void SetPositions(SwPaM const& rPam);
102 : //TODO: new exception type for protected content
103 : void DeleteAndInsert(
104 : const OUString& rText, const bool bForceExpandHints)
105 : throw (::com::sun::star::uno::RuntimeException);
106 : void Invalidate();
107 :
108 : virtual ~SwXTextRange();
109 :
110 : public:
111 :
112 : SwXTextRange(SwPaM& rPam,
113 : const ::com::sun::star::uno::Reference<
114 : ::com::sun::star::text::XText > & xParent,
115 : const enum RangePosition eRange = RANGE_IN_TEXT);
116 : // only for RANGE_IS_TABLE
117 : SwXTextRange(SwFrameFormat& rTableFormat);
118 :
119 : const SwDoc* GetDoc() const;
120 : SwDoc* GetDoc();
121 : bool GetPositions(SwPaM & rToFill) const;
122 :
123 : static ::com::sun::star::uno::Reference<
124 : ::com::sun::star::text::XTextRange > CreateXTextRange(
125 : SwDoc & rDoc,
126 : const SwPosition& rPos, const SwPosition *const pMark);
127 :
128 : static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
129 :
130 : // XUnoTunnel
131 : virtual sal_Int64 SAL_CALL getSomething(
132 : const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier)
133 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
134 :
135 : // XServiceInfo
136 : virtual OUString SAL_CALL getImplementationName()
137 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
138 : virtual sal_Bool SAL_CALL supportsService(
139 : const OUString& rServiceName)
140 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
141 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL
142 : getSupportedServiceNames()
143 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
144 :
145 : // XPropertySet
146 : virtual ::com::sun::star::uno::Reference<
147 : ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
148 : getPropertySetInfo()
149 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
150 : virtual void SAL_CALL setPropertyValue(
151 : const OUString& rPropertyName,
152 : const ::com::sun::star::uno::Any& rValue)
153 : throw (::com::sun::star::beans::UnknownPropertyException,
154 : ::com::sun::star::beans::PropertyVetoException,
155 : ::com::sun::star::lang::IllegalArgumentException,
156 : ::com::sun::star::lang::WrappedTargetException,
157 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
158 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
159 : const OUString& rPropertyName)
160 : throw (::com::sun::star::beans::UnknownPropertyException,
161 : ::com::sun::star::lang::WrappedTargetException,
162 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
163 : virtual void SAL_CALL addPropertyChangeListener(
164 : const OUString& rPropertyName,
165 : const ::com::sun::star::uno::Reference<
166 : ::com::sun::star::beans::XPropertyChangeListener >& xListener)
167 : throw (::com::sun::star::beans::UnknownPropertyException,
168 : ::com::sun::star::lang::WrappedTargetException,
169 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
170 : virtual void SAL_CALL removePropertyChangeListener(
171 : const OUString& rPropertyName,
172 : const ::com::sun::star::uno::Reference<
173 : ::com::sun::star::beans::XPropertyChangeListener >& xListener)
174 : throw (::com::sun::star::beans::UnknownPropertyException,
175 : ::com::sun::star::lang::WrappedTargetException,
176 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
177 : virtual void SAL_CALL addVetoableChangeListener(
178 : const OUString& rPropertyName,
179 : const ::com::sun::star::uno::Reference<
180 : ::com::sun::star::beans::XVetoableChangeListener >& xListener)
181 : throw (::com::sun::star::beans::UnknownPropertyException,
182 : ::com::sun::star::lang::WrappedTargetException,
183 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
184 : virtual void SAL_CALL removeVetoableChangeListener(
185 : const OUString& rPropertyName,
186 : const ::com::sun::star::uno::Reference<
187 : ::com::sun::star::beans::XVetoableChangeListener >& xListener)
188 : throw (::com::sun::star::beans::UnknownPropertyException,
189 : ::com::sun::star::lang::WrappedTargetException,
190 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
191 :
192 : // XPropertyState
193 : virtual ::com::sun::star::beans::PropertyState SAL_CALL
194 : getPropertyState(const OUString& rPropertyName)
195 : throw (::com::sun::star::beans::UnknownPropertyException,
196 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
197 : virtual ::com::sun::star::uno::Sequence<
198 : ::com::sun::star::beans::PropertyState > SAL_CALL
199 : getPropertyStates(
200 : const ::com::sun::star::uno::Sequence<
201 : OUString >& rPropertyNames)
202 : throw (::com::sun::star::beans::UnknownPropertyException,
203 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
204 : virtual void SAL_CALL setPropertyToDefault(
205 : const OUString& rPropertyName)
206 : throw (::com::sun::star::beans::UnknownPropertyException,
207 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
208 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault(
209 : const OUString& rPropertyName)
210 : throw (::com::sun::star::beans::UnknownPropertyException,
211 : ::com::sun::star::lang::WrappedTargetException,
212 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
213 :
214 : // XElementAccess
215 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
216 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
217 : virtual sal_Bool SAL_CALL hasElements()
218 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
219 :
220 : // XEnumerationAccess
221 : virtual ::com::sun::star::uno::Reference<
222 : ::com::sun::star::container::XEnumeration > SAL_CALL
223 : createEnumeration()
224 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
225 :
226 : // XContentEnumerationAccess
227 : virtual ::com::sun::star::uno::Reference<
228 : ::com::sun::star::container::XEnumeration > SAL_CALL
229 : createContentEnumeration(const OUString& rServiceName)
230 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
231 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL
232 : getAvailableServiceNames()
233 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
234 :
235 : // XTextRange
236 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >
237 : SAL_CALL getText()
238 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
239 : virtual ::com::sun::star::uno::Reference<
240 : ::com::sun::star::text::XTextRange > SAL_CALL getStart()
241 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
242 : virtual ::com::sun::star::uno::Reference<
243 : ::com::sun::star::text::XTextRange > SAL_CALL getEnd()
244 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
245 : virtual OUString SAL_CALL getString()
246 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
247 : virtual void SAL_CALL setString(const OUString& rString)
248 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
249 :
250 : // XRedline
251 : virtual void SAL_CALL makeRedline(
252 : const OUString& rRedlineType,
253 : const ::com::sun::star::uno::Sequence<
254 : ::com::sun::star::beans::PropertyValue >& RedlineProperties)
255 : throw (::com::sun::star::lang::IllegalArgumentException,
256 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
257 :
258 : };
259 :
260 : typedef ::cppu::WeakImplHelper
261 : < ::com::sun::star::lang::XUnoTunnel
262 : , ::com::sun::star::lang::XServiceInfo
263 : , ::com::sun::star::container::XIndexAccess
264 : > SwXTextRanges_Base;
265 :
266 2 : struct SwXTextRanges : public SwXTextRanges_Base
267 : {
268 : virtual SwUnoCrsr* GetCursor() =0;
269 : static SwXTextRanges* Create(SwPaM* const pCrsr);
270 : static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
271 : };
272 :
273 : #endif // INCLUDED_SW_INC_UNOTEXTRANGE_HXX
274 :
275 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|