xref: /trunk/main/sw/inc/unotextrange.hxx (revision 9d37da743abb7db0a497688391f6e55a19f27c44)
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     void    Invalidate();
119 
120     virtual ~SwXTextRange();
121 
122 public:
123 
124     SwXTextRange(SwPaM& rPam,
125             const ::com::sun::star::uno::Reference<
126                 ::com::sun::star::text::XText > & xParent,
127             const enum RangePosition eRange = RANGE_IN_TEXT);
128     // only for RANGE_IS_TABLE
129     SwXTextRange(SwFrmFmt& rTblFmt);
130 
131     const SwDoc* GetDoc() const;
132           SwDoc* GetDoc();
133     bool GetPositions(SwPaM & rToFill) const;
134 
135     static ::com::sun::star::uno::Reference<
136                 ::com::sun::star::text::XTextRange > CreateXTextRange(
137             SwDoc & rDoc,
138             const SwPosition& rPos, const SwPosition *const pMark);
139 
140     static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
141 
142     // XUnoTunnel
143     virtual sal_Int64 SAL_CALL getSomething(
144             const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier);
145 
146     // XServiceInfo
147     virtual ::rtl::OUString SAL_CALL getImplementationName();
148     virtual sal_Bool SAL_CALL supportsService(
149             const ::rtl::OUString& rServiceName);
150     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
151         getSupportedServiceNames();
152 
153     // XPropertySet
154     virtual ::com::sun::star::uno::Reference<
155                 ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
156         getPropertySetInfo();
157     virtual void SAL_CALL setPropertyValue(
158             const ::rtl::OUString& rPropertyName,
159             const ::com::sun::star::uno::Any& rValue);
160     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
161             const ::rtl::OUString& rPropertyName);
162     virtual void SAL_CALL addPropertyChangeListener(
163             const ::rtl::OUString& rPropertyName,
164             const ::com::sun::star::uno::Reference<
165                 ::com::sun::star::beans::XPropertyChangeListener >& xListener);
166     virtual void SAL_CALL removePropertyChangeListener(
167             const ::rtl::OUString& rPropertyName,
168             const ::com::sun::star::uno::Reference<
169                 ::com::sun::star::beans::XPropertyChangeListener >& xListener);
170     virtual void SAL_CALL addVetoableChangeListener(
171             const ::rtl::OUString& rPropertyName,
172             const ::com::sun::star::uno::Reference<
173                 ::com::sun::star::beans::XVetoableChangeListener >& xListener);
174     virtual void SAL_CALL removeVetoableChangeListener(
175             const ::rtl::OUString& rPropertyName,
176             const ::com::sun::star::uno::Reference<
177                 ::com::sun::star::beans::XVetoableChangeListener >& xListener);
178 
179     // XPropertyState
180     virtual ::com::sun::star::beans::PropertyState SAL_CALL
181         getPropertyState(const ::rtl::OUString& rPropertyName);
182     virtual ::com::sun::star::uno::Sequence<
183             ::com::sun::star::beans::PropertyState > SAL_CALL
184         getPropertyStates(
185             const ::com::sun::star::uno::Sequence<
186                 ::rtl::OUString >& rPropertyNames);
187     virtual void SAL_CALL setPropertyToDefault(
188             const ::rtl::OUString& rPropertyName);
189     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault(
190             const ::rtl::OUString& rPropertyName);
191 
192     // XElementAccess
193     virtual ::com::sun::star::uno::Type SAL_CALL getElementType();
194     virtual sal_Bool SAL_CALL hasElements();
195 
196     // XEnumerationAccess
197     virtual ::com::sun::star::uno::Reference<
198             ::com::sun::star::container::XEnumeration >  SAL_CALL
199         createEnumeration();
200 
201     // XContentEnumerationAccess
202     virtual ::com::sun::star::uno::Reference<
203                 ::com::sun::star::container::XEnumeration > SAL_CALL
204         createContentEnumeration(const ::rtl::OUString& rServiceName);
205     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
206         getAvailableServiceNames();
207 
208     // XTextRange
209     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >
210         SAL_CALL getText();
211     virtual ::com::sun::star::uno::Reference<
212                 ::com::sun::star::text::XTextRange > SAL_CALL getStart();
213     virtual ::com::sun::star::uno::Reference<
214                 ::com::sun::star::text::XTextRange > SAL_CALL getEnd();
215     virtual ::rtl::OUString SAL_CALL getString();
216     virtual void SAL_CALL setString(const ::rtl::OUString& rString);
217 
218     // XRedline
219     virtual void SAL_CALL makeRedline(
220             const ::rtl::OUString& rRedlineType,
221             const ::com::sun::star::uno::Sequence<
222                 ::com::sun::star::beans::PropertyValue >& RedlineProperties);
223 
224 };
225 
226 /* -----------------15.05.98 08:29-------------------
227  *
228  * --------------------------------------------------*/
229 
230 typedef ::cppu::WeakImplHelper3
231 <   ::com::sun::star::lang::XUnoTunnel
232 ,   ::com::sun::star::lang::XServiceInfo
233 ,   ::com::sun::star::container::XIndexAccess
234 > SwXTextRanges_Base;
235 
236 class SwXTextRanges
237     : public SwXTextRanges_Base
238 {
239 
240 private:
241 
242     class Impl;
243     ::sw::UnoImplPtr<Impl> m_pImpl;
244 
245     virtual ~SwXTextRanges();
246 
247 public:
248 
249     SwXTextRanges(SwPaM *const pCrsr);
250 
251     const SwUnoCrsr* GetCursor() const;
252 
253     static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
254 
255     // XUnoTunnel
256     virtual sal_Int64 SAL_CALL getSomething(
257             const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier);
258 
259     // XServiceInfo
260     virtual ::rtl::OUString SAL_CALL getImplementationName();
261     virtual sal_Bool SAL_CALL supportsService(
262             const ::rtl::OUString& rServiceName);
263     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
264         getSupportedServiceNames();
265 
266     // XElementAccess
267     virtual ::com::sun::star::uno::Type SAL_CALL getElementType();
268     virtual sal_Bool SAL_CALL hasElements();
269 
270     // XIndexAccess
271     virtual sal_Int32 SAL_CALL getCount();
272     virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex);
273 
274 };
275 
276 #endif // SW_UNOTEXTRANGE_HXX
277