xref: /aoo42x/main/sw/inc/unotextrange.hxx (revision 1d2dbeb0)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SW_UNOTEXTRANGE_HXX
25 #define SW_UNOTEXTRANGE_HXX
26 
27 #include <com/sun/star/lang/XUnoTunnel.hpp>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/beans/XPropertySet.hpp>
30 #include <com/sun/star/beans/XPropertyState.hpp>
31 #include <com/sun/star/container/XIndexAccess.hpp>
32 #include <com/sun/star/container/XEnumerationAccess.hpp>
33 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
34 #include <com/sun/star/text/XTextRange.hpp>
35 #include <com/sun/star/text/XRedline.hpp>
36 
37 #include <cppuhelper/implbase3.hxx>
38 #include <cppuhelper/implbase8.hxx>
39 
40 #include <pam.hxx>
41 #include <unobaseclass.hxx>
42 
43 
44 class SwDoc;
45 struct SwPosition;
46 class SwPaM;
47 class SwUnoCrsr;
48 class SwFrmFmt;
49 
50 /* -----------------29.04.98 07:35-------------------
51  *
52  * --------------------------------------------------*/
53 class SwUnoInternalPaM
54     : public SwPaM
55 {
56 
57 private:
58     SwUnoInternalPaM(const SwUnoInternalPaM&);
59 
60 public:
61     SwUnoInternalPaM(SwDoc& rDoc);
62     virtual ~SwUnoInternalPaM();
63 
64     SwUnoInternalPaM& operator=(const SwPaM& rPaM);
65 };
66 
67 
68 namespace sw {
69 
70     void DeepCopyPaM(SwPaM const & rSource, SwPaM & rTarget);
71 
72     bool XTextRangeToSwPaM(SwUnoInternalPaM& rToFill,
73             const ::com::sun::star::uno::Reference<
74                 ::com::sun::star::text::XTextRange > & xTextRange);
75 
76     ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >
77         CreateParentXText(SwDoc & rDoc, const SwPosition& rPos);
78 
79     bool GetDefaultTextContentValue(::com::sun::star::uno::Any& rAny,
80         const ::rtl::OUString& rPropertyName, sal_uInt16 nWID = 0);
81 
82 } // namespace sw
83 
84 
85 typedef ::cppu::WeakImplHelper8
86 <   ::com::sun::star::lang::XUnoTunnel
87 ,   ::com::sun::star::lang::XServiceInfo
88 ,   ::com::sun::star::beans::XPropertySet
89 ,   ::com::sun::star::beans::XPropertyState
90 ,   ::com::sun::star::container::XEnumerationAccess
91 ,   ::com::sun::star::container::XContentEnumerationAccess
92 ,   ::com::sun::star::text::XTextRange
93 ,   ::com::sun::star::text::XRedline
94 > SwXTextRange_Base;
95 
96 class SW_DLLPUBLIC SwXTextRange
97     : public SwXTextRange_Base
98 {
99 
100 private:
101 
102     friend class SwXText;
103 
104     class Impl;
105     ::sw::UnoImplPtr<Impl> m_pImpl;
106 
107     enum RangePosition
108     {
109         RANGE_IN_TEXT,  // "ordinary" ::com::sun::star::text::TextRange
110         RANGE_IN_CELL,  // position created with a cell that has no uno object
111         RANGE_IS_TABLE, // anchor of a table
112     };
113 
114     void    SetPositions(SwPaM const& rPam);
115     //TODO: new exception type for protected content
116     void    DeleteAndInsert(
117                 const ::rtl::OUString& rText, const bool bForceExpandHints)
118         throw (::com::sun::star::uno::RuntimeException);
119     void    Invalidate();
120 
121     virtual ~SwXTextRange();
122 
123 public:
124 
125     SwXTextRange(SwPaM& rPam,
126             const ::com::sun::star::uno::Reference<
127                 ::com::sun::star::text::XText > & xParent,
128             const enum RangePosition eRange = RANGE_IN_TEXT);
129     // only for RANGE_IS_TABLE
130     SwXTextRange(SwFrmFmt& rTblFmt);
131 
132     const SwDoc* GetDoc() const;
133           SwDoc* GetDoc();
134     bool GetPositions(SwPaM & rToFill) const;
135 
136     static ::com::sun::star::uno::Reference<
137                 ::com::sun::star::text::XTextRange > CreateXTextRange(
138             SwDoc & rDoc,
139             const SwPosition& rPos, const SwPosition *const pMark);
140 
141     static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
142 
143     // XUnoTunnel
144     virtual sal_Int64 SAL_CALL getSomething(
145             const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier)
146         throw (::com::sun::star::uno::RuntimeException);
147 
148     // XServiceInfo
149     virtual ::rtl::OUString SAL_CALL getImplementationName()
150         throw (::com::sun::star::uno::RuntimeException);
151     virtual sal_Bool SAL_CALL supportsService(
152             const ::rtl::OUString& rServiceName)
153         throw (::com::sun::star::uno::RuntimeException);
154     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
155         getSupportedServiceNames()
156         throw (::com::sun::star::uno::RuntimeException);
157 
158     // XPropertySet
159     virtual ::com::sun::star::uno::Reference<
160                 ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
161         getPropertySetInfo()
162         throw (::com::sun::star::uno::RuntimeException);
163     virtual void SAL_CALL setPropertyValue(
164             const ::rtl::OUString& rPropertyName,
165             const ::com::sun::star::uno::Any& rValue)
166         throw (::com::sun::star::beans::UnknownPropertyException,
167                 ::com::sun::star::beans::PropertyVetoException,
168                 ::com::sun::star::lang::IllegalArgumentException,
169                 ::com::sun::star::lang::WrappedTargetException,
170                 ::com::sun::star::uno::RuntimeException);
171     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
172             const ::rtl::OUString& rPropertyName)
173         throw (::com::sun::star::beans::UnknownPropertyException,
174                 ::com::sun::star::lang::WrappedTargetException,
175                 ::com::sun::star::uno::RuntimeException);
176     virtual void SAL_CALL addPropertyChangeListener(
177             const ::rtl::OUString& rPropertyName,
178             const ::com::sun::star::uno::Reference<
179                 ::com::sun::star::beans::XPropertyChangeListener >& xListener)
180         throw (::com::sun::star::beans::UnknownPropertyException,
181                 ::com::sun::star::lang::WrappedTargetException,
182                 ::com::sun::star::uno::RuntimeException);
183     virtual void SAL_CALL removePropertyChangeListener(
184             const ::rtl::OUString& rPropertyName,
185             const ::com::sun::star::uno::Reference<
186                 ::com::sun::star::beans::XPropertyChangeListener >& xListener)
187         throw (::com::sun::star::beans::UnknownPropertyException,
188                 ::com::sun::star::lang::WrappedTargetException,
189                 ::com::sun::star::uno::RuntimeException);
190     virtual void SAL_CALL addVetoableChangeListener(
191             const ::rtl::OUString& rPropertyName,
192             const ::com::sun::star::uno::Reference<
193                 ::com::sun::star::beans::XVetoableChangeListener >& xListener)
194         throw (::com::sun::star::beans::UnknownPropertyException,
195                 ::com::sun::star::lang::WrappedTargetException,
196                 ::com::sun::star::uno::RuntimeException);
197     virtual void SAL_CALL removeVetoableChangeListener(
198             const ::rtl::OUString& rPropertyName,
199             const ::com::sun::star::uno::Reference<
200                 ::com::sun::star::beans::XVetoableChangeListener >& xListener)
201         throw (::com::sun::star::beans::UnknownPropertyException,
202                 ::com::sun::star::lang::WrappedTargetException,
203                 ::com::sun::star::uno::RuntimeException);
204 
205     // XPropertyState
206     virtual ::com::sun::star::beans::PropertyState SAL_CALL
207         getPropertyState(const ::rtl::OUString& rPropertyName)
208         throw (::com::sun::star::beans::UnknownPropertyException,
209                 ::com::sun::star::uno::RuntimeException);
210     virtual ::com::sun::star::uno::Sequence<
211             ::com::sun::star::beans::PropertyState > SAL_CALL
212         getPropertyStates(
213             const ::com::sun::star::uno::Sequence<
214                 ::rtl::OUString >& rPropertyNames)
215         throw (::com::sun::star::beans::UnknownPropertyException,
216                 ::com::sun::star::uno::RuntimeException);
217     virtual void SAL_CALL setPropertyToDefault(
218             const ::rtl::OUString& rPropertyName)
219         throw (::com::sun::star::beans::UnknownPropertyException,
220                 ::com::sun::star::uno::RuntimeException);
221     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault(
222             const ::rtl::OUString& rPropertyName)
223         throw (::com::sun::star::beans::UnknownPropertyException,
224                 ::com::sun::star::lang::WrappedTargetException,
225                 ::com::sun::star::uno::RuntimeException);
226 
227     // XElementAccess
228     virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
229         throw (::com::sun::star::uno::RuntimeException);
230     virtual sal_Bool SAL_CALL hasElements()
231         throw (::com::sun::star::uno::RuntimeException);
232 
233     // XEnumerationAccess
234     virtual ::com::sun::star::uno::Reference<
235             ::com::sun::star::container::XEnumeration >  SAL_CALL
236         createEnumeration()
237         throw (::com::sun::star::uno::RuntimeException);
238 
239     // XContentEnumerationAccess
240     virtual ::com::sun::star::uno::Reference<
241                 ::com::sun::star::container::XEnumeration > SAL_CALL
242         createContentEnumeration(const ::rtl::OUString& rServiceName)
243         throw (::com::sun::star::uno::RuntimeException);
244     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
245         getAvailableServiceNames()
246         throw (::com::sun::star::uno::RuntimeException);
247 
248     // XTextRange
249     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >
250         SAL_CALL getText()
251         throw (::com::sun::star::uno::RuntimeException);
252     virtual ::com::sun::star::uno::Reference<
253                 ::com::sun::star::text::XTextRange > SAL_CALL getStart()
254         throw (::com::sun::star::uno::RuntimeException);
255     virtual ::com::sun::star::uno::Reference<
256                 ::com::sun::star::text::XTextRange > SAL_CALL getEnd()
257         throw (::com::sun::star::uno::RuntimeException);
258     virtual ::rtl::OUString SAL_CALL getString()
259         throw (::com::sun::star::uno::RuntimeException);
260     virtual void SAL_CALL setString(const ::rtl::OUString& rString)
261         throw (::com::sun::star::uno::RuntimeException);
262 
263     // XRedline
264     virtual void SAL_CALL makeRedline(
265             const ::rtl::OUString& rRedlineType,
266             const ::com::sun::star::uno::Sequence<
267                 ::com::sun::star::beans::PropertyValue >& RedlineProperties)
268         throw (::com::sun::star::lang::IllegalArgumentException,
269                 ::com::sun::star::uno::RuntimeException);
270 
271 };
272 
273 /* -----------------15.05.98 08:29-------------------
274  *
275  * --------------------------------------------------*/
276 
277 typedef ::cppu::WeakImplHelper3
278 <   ::com::sun::star::lang::XUnoTunnel
279 ,   ::com::sun::star::lang::XServiceInfo
280 ,   ::com::sun::star::container::XIndexAccess
281 > SwXTextRanges_Base;
282 
283 class SwXTextRanges
284     : public SwXTextRanges_Base
285 {
286 
287 private:
288 
289     class Impl;
290     ::sw::UnoImplPtr<Impl> m_pImpl;
291 
292     virtual ~SwXTextRanges();
293 
294 public:
295 
296     SwXTextRanges(SwPaM *const pCrsr);
297 
298     const SwUnoCrsr* GetCursor() const;
299 
300     static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
301 
302     // XUnoTunnel
303     virtual sal_Int64 SAL_CALL getSomething(
304             const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier)
305         throw (::com::sun::star::uno::RuntimeException);
306 
307     // XServiceInfo
308     virtual ::rtl::OUString SAL_CALL getImplementationName()
309         throw (::com::sun::star::uno::RuntimeException);
310     virtual sal_Bool SAL_CALL supportsService(
311             const ::rtl::OUString& rServiceName)
312         throw (::com::sun::star::uno::RuntimeException);
313     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
314         getSupportedServiceNames()
315         throw (::com::sun::star::uno::RuntimeException);
316 
317     // XElementAccess
318     virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
319         throw (::com::sun::star::uno::RuntimeException);
320     virtual sal_Bool SAL_CALL hasElements()
321         throw (::com::sun::star::uno::RuntimeException);
322 
323     // XIndexAccess
324     virtual sal_Int32 SAL_CALL getCount()
325         throw (::com::sun::star::uno::RuntimeException);
326     virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex)
327         throw (::com::sun::star::lang::IndexOutOfBoundsException,
328                 ::com::sun::star::lang::WrappedTargetException,
329                 ::com::sun::star::uno::RuntimeException);
330 
331 };
332 
333 #endif // SW_UNOTEXTRANGE_HXX
334 
335