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