xref: /trunk/main/editeng/source/uno/unotext2.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_editeng.hxx"
30 #include <vcl/svapp.hxx>
31 #include <vos/mutex.hxx>
32 
33 #define _SVSTDARR_sal_uIt16S
34 #include <svl/svstdarr.hxx>
35 
36 #include <rtl/uuid.h>
37 #include <rtl/memory.h>
38 
39 #include <editeng/eeitem.hxx>
40 #include <editeng/flditem.hxx>
41 #include <editeng/unofield.hxx>
42 #include <editeng/unotext.hxx>
43 #include <comphelper/serviceinfohelper.hxx>
44 
45 using namespace ::rtl;
46 using namespace ::vos;
47 using namespace ::cppu;
48 using namespace ::com::sun::star;
49 
50 #define QUERYINT( xint ) \
51 	if( rType == ::getCppuType((const uno::Reference< xint >*)0) ) \
52         return uno::makeAny(uno::Reference< xint >(this))
53 
54 // ====================================================================
55 // SvxUnoTextContentEnumeration
56 // ====================================================================
57 
58 SvxUnoTextContentEnumeration::SvxUnoTextContentEnumeration( const SvxUnoTextBase& _rText ) throw()
59 : mrText( _rText )
60 {
61 	mxParentText = const_cast<SvxUnoTextBase*>(&_rText);
62 	if( mrText.GetEditSource() )
63 		mpEditSource = mrText.GetEditSource()->Clone();
64 	else
65 		mpEditSource = NULL;
66 	mnNextParagraph = 0;
67 }
68 
69 SvxUnoTextContentEnumeration::~SvxUnoTextContentEnumeration() throw()
70 {
71 	delete mpEditSource;
72 }
73 
74 // container::XEnumeration
75 sal_Bool SAL_CALL SvxUnoTextContentEnumeration::hasMoreElements(void)
76 	throw( uno::RuntimeException )
77 {
78 	OGuard aGuard( Application::GetSolarMutex() );
79 	if( mpEditSource && mpEditSource->GetTextForwarder() )
80         return mnNextParagraph < mpEditSource->GetTextForwarder()->GetParagraphCount();
81 	else
82 		return sal_False;
83 }
84 
85 uno::Any SvxUnoTextContentEnumeration::nextElement(void) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
86 {
87 	OGuard aGuard( Application::GetSolarMutex() );
88 
89 	if(!hasMoreElements())
90 		throw container::NoSuchElementException();
91 
92 	SvxUnoTextContent* pContent = 0;
93 
94 	const SvxUnoTextRangeBaseList& rRanges( mpEditSource->getRanges() );
95 	SvxUnoTextRangeBaseList::const_iterator aIter;
96 	for( aIter = rRanges.begin(); (aIter != rRanges.end()) && (pContent == 0); aIter++ )
97 	{
98 		SvxUnoTextContent* pIterContent = dynamic_cast< SvxUnoTextContent* >( (*aIter ) );
99 		if( pIterContent && (pIterContent->mnParagraph == mnNextParagraph) )
100 			pContent = pIterContent;
101 	}
102 
103 	if( pContent == 0 )
104 	 pContent = new SvxUnoTextContent( mrText, mnNextParagraph );
105 
106 	mnNextParagraph++;
107 
108 	uno::Reference< text::XTextContent > xRef( pContent );
109 	return uno::makeAny( xRef );
110 }
111 
112 // ====================================================================
113 // class SvxUnoTextContent
114 // ====================================================================
115 uno::Reference< text::XText > xDummyText;
116 uno::Sequence< uno::Type > SvxUnoTextContent::maTypeSequence;
117 
118 static SvxUnoText* getDummyText() throw()
119 {
120 	if(!xDummyText.is())
121 		xDummyText = new SvxUnoText();
122 
123 	return SvxUnoText::getImplementation( xDummyText );
124 }
125 
126 SvxUnoTextContent::SvxUnoTextContent() throw()
127 :	SvxUnoTextRangeBase(*getDummyText())
128 ,	mnParagraph(0)
129 ,	mrParentText(*getDummyText())
130 ,	maDisposeListeners(maDisposeContainerMutex)
131 ,	mbDisposing( false )
132 {
133 }
134 
135 SvxUnoTextContent::SvxUnoTextContent( const SvxUnoTextBase& rText, sal_uInt16 nPara ) throw()
136 :	SvxUnoTextRangeBase(rText)
137 ,	mnParagraph(nPara)
138 ,	mrParentText(rText)
139 ,	maDisposeListeners(maDisposeContainerMutex)
140 ,	mbDisposing( false )
141 {
142 	mxParentText = const_cast<SvxUnoTextBase*>(&rText);
143 	if( GetEditSource() && GetEditSource()->GetTextForwarder() )
144 		SetSelection( ESelection( mnParagraph,0, mnParagraph, GetEditSource()->GetTextForwarder()->GetTextLen( mnParagraph ) ) );
145 }
146 
147 SvxUnoTextContent::SvxUnoTextContent( const SvxUnoTextContent& rContent ) throw()
148 :	SvxUnoTextRangeBase(rContent)
149 ,	text::XTextContent()
150 ,	container::XEnumerationAccess()
151 ,	lang::XTypeProvider()
152 ,	cppu::OWeakAggObject()
153 ,	mrParentText(rContent.mrParentText)
154 ,	maDisposeListeners(maDisposeContainerMutex)
155 ,	mbDisposing( false )
156 {
157 	mxParentText = rContent.mxParentText;
158 	mnParagraph  = rContent.mnParagraph;
159 	SetSelection( rContent.GetSelection() );
160 }
161 
162 SvxUnoTextContent::~SvxUnoTextContent() throw()
163 {
164 }
165 
166 // uno::XInterface
167 uno::Any SAL_CALL SvxUnoTextContent::queryAggregation( const uno::Type & rType ) throw( uno::RuntimeException )
168 {
169 	QUERYINT( text::XTextRange );
170 	else QUERYINT( beans::XMultiPropertyStates );
171 	else QUERYINT( beans::XPropertySet );
172 	else QUERYINT( beans::XMultiPropertySet );
173 	else QUERYINT( beans::XPropertyState );
174 	else QUERYINT( text::XTextContent );
175 	else QUERYINT( text::XTextRangeCompare );
176 	else QUERYINT( lang::XComponent );
177 	else QUERYINT( container::XEnumerationAccess );
178 	else QUERYINT( container::XElementAccess );
179 	else QUERYINT( lang::XServiceInfo );
180 	else QUERYINT( lang::XTypeProvider );
181 	else QUERYINT( lang::XUnoTunnel );
182 	else
183 		return OWeakAggObject::queryAggregation( rType );
184 }
185 
186 uno::Any SAL_CALL SvxUnoTextContent::queryInterface( const uno::Type & rType ) throw( uno::RuntimeException )
187 {
188 	return OWeakAggObject::queryInterface(rType);
189 }
190 
191 void SAL_CALL SvxUnoTextContent::acquire() throw( )
192 {
193 	OWeakAggObject::acquire();
194 }
195 
196 void SAL_CALL SvxUnoTextContent::release() throw( )
197 {
198 	OWeakAggObject::release();
199 }
200 
201 // XTypeProvider
202 
203 uno::Sequence< uno::Type > SAL_CALL SvxUnoTextContent::getTypes()
204 	throw (uno::RuntimeException)
205 {
206 	if( maTypeSequence.getLength() == 0 )
207 	{
208 		maTypeSequence.realloc( 11 ); // !DANGER! keep this updated
209 		uno::Type* pTypes = maTypeSequence.getArray();
210 
211 		*pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRange >*)0);
212 		*pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertySet >*)0);
213 		*pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertySet >*)0);
214 		*pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertyStates >*)0);
215 		*pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertyState >*)0);
216 		*pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeCompare >*)0);
217 		*pTypes++ = ::getCppuType(( const uno::Reference< text::XTextContent >*)0);
218 		*pTypes++ = ::getCppuType(( const uno::Reference< container::XEnumerationAccess >*)0);
219 		*pTypes++ = ::getCppuType(( const uno::Reference< lang::XServiceInfo >*)0);
220 		*pTypes++ = ::getCppuType(( const uno::Reference< lang::XTypeProvider >*)0);
221 		*pTypes++ = ::getCppuType(( const uno::Reference< lang::XUnoTunnel >*)0);
222 	}
223 	return maTypeSequence;
224 }
225 
226 uno::Sequence< sal_Int8 > SAL_CALL SvxUnoTextContent::getImplementationId()
227 	throw (uno::RuntimeException)
228 {
229 	static uno::Sequence< sal_Int8 > aId;
230 	if( aId.getLength() == 0 )
231 	{
232 		aId.realloc( 16 );
233 		rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
234 	}
235 	return aId;
236 }
237 
238 // text::XTextRange
239 
240 uno::Reference< text::XText > SAL_CALL SvxUnoTextContent::getText()
241 	throw(uno::RuntimeException)
242 {
243 	return mxParentText;
244 }
245 
246 // text::XTextContent
247 void SAL_CALL SvxUnoTextContent::attach( const uno::Reference< text::XTextRange >& )
248 	throw(lang::IllegalArgumentException, uno::RuntimeException)
249 {
250 }
251 
252 uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextContent::getAnchor() throw( uno::RuntimeException )
253 {
254 	return uno::Reference< text::XTextRange >::query( mxParentText );
255 }
256 
257 // XComponent
258 
259 void SAL_CALL SvxUnoTextContent::dispose()
260 	throw(uno::RuntimeException)
261 {
262 	OGuard aGuard( Application::GetSolarMutex() );
263 
264 	if( mbDisposing )
265 		return;	// catched a recursion
266 
267 	mbDisposing = true;
268 
269 	lang::EventObject aEvt;
270 	aEvt.Source = *(OWeakAggObject*) this;
271 	maDisposeListeners.disposeAndClear(aEvt);
272 
273 	if( mxParentText.is() )
274 		mxParentText->removeTextContent( this );
275 }
276 
277 void SAL_CALL SvxUnoTextContent::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
278 	throw(uno::RuntimeException)
279 {
280 	maDisposeListeners.addInterface(xListener);
281 }
282 
283 void SAL_CALL SvxUnoTextContent::removeEventListener( const uno::Reference< lang::XEventListener >& aListener )
284 	throw(uno::RuntimeException)
285 {
286    maDisposeListeners.removeInterface(aListener);
287 }
288 
289 // XEnumerationAccess
290 
291 uno::Reference< container::XEnumeration > SAL_CALL SvxUnoTextContent::createEnumeration(  )
292 	throw(uno::RuntimeException)
293 {
294 	OGuard aGuard( Application::GetSolarMutex() );
295 
296 	return new SvxUnoTextRangeEnumeration( mrParentText, mnParagraph );
297 }
298 
299 // XElementAccess ( container::XEnumerationAccess )
300 
301 uno::Type SAL_CALL SvxUnoTextContent::getElementType()
302 	throw(uno::RuntimeException)
303 {
304 	return ::getCppuType((const uno::Reference< text::XTextRange >*)0);
305 }
306 
307 sal_Bool SAL_CALL SvxUnoTextContent::hasElements()
308 	throw(uno::RuntimeException)
309 {
310 	OGuard aGuard( Application::GetSolarMutex() );
311 
312 	SvxTextForwarder* pForwarder = GetEditSource() ? GetEditSource()->GetTextForwarder() : NULL;
313 	if( pForwarder )
314 	{
315 		SvUShorts aPortions;
316 		pForwarder->GetPortions( mnParagraph, aPortions );
317 		return aPortions.Count() > 0;
318 	}
319 	else
320 	{
321 		return 0;
322 	}
323 }
324 
325 // XPropertySet
326 
327 void SAL_CALL SvxUnoTextContent::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
328 	throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
329 {
330 	_setPropertyValue( aPropertyName, aValue, mnParagraph );
331 }
332 
333 uno::Any SAL_CALL SvxUnoTextContent::getPropertyValue( const OUString& PropertyName )
334 	throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
335 {
336 	return _getPropertyValue( PropertyName, mnParagraph );
337 }
338 
339 // XMultiPropertySet
340 void SAL_CALL SvxUnoTextContent::setPropertyValues( const uno::Sequence< ::rtl::OUString >& aPropertyNames, const uno::Sequence< uno::Any >& aValues ) throw (beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
341 {
342 	_setPropertyValues( aPropertyNames, aValues, mnParagraph );
343 }
344 
345 uno::Sequence< uno::Any > SAL_CALL SvxUnoTextContent::getPropertyValues( const uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (uno::RuntimeException)
346 {
347 	return _getPropertyValues( aPropertyNames, mnParagraph );
348 }
349 
350 /*// XTolerantMultiPropertySet
351 uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SvxUnoTextContent::setPropertyValuesTolerant( const uno::Sequence< ::rtl::OUString >& aPropertyNames, const uno::Sequence< uno::Any >& aValues ) throw (lang::IllegalArgumentException, uno::RuntimeException)
352 {
353     return _setPropertyValuesTolerant(aPropertyNames, aValues, mnParagraph);
354 }
355 
356 uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL SvxUnoTextContent::getPropertyValuesTolerant( const uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (uno::RuntimeException)
357 {
358     return _getPropertyValuesTolerant(aPropertyNames, mnParagraph);
359 }
360 
361 uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SvxUnoTextContent::getDirectPropertyValuesTolerant( const uno::Sequence< ::rtl::OUString >& aPropertyNames )
362     throw (uno::RuntimeException)
363 {
364     return _getDirectPropertyValuesTolerant(aPropertyNames, mnParagraph);
365 }*/
366 
367 // beans::XPropertyState
368 beans::PropertyState SAL_CALL SvxUnoTextContent::getPropertyState( const OUString& PropertyName )
369 	throw(beans::UnknownPropertyException, uno::RuntimeException)
370 {
371 	return _getPropertyState( PropertyName, mnParagraph );
372 }
373 
374 uno::Sequence< beans::PropertyState > SAL_CALL SvxUnoTextContent::getPropertyStates( const uno::Sequence< OUString >& aPropertyName )
375 	throw(beans::UnknownPropertyException, uno::RuntimeException)
376 {
377 	return _getPropertyStates( aPropertyName, mnParagraph );
378 }
379 
380 void SAL_CALL SvxUnoTextContent::setPropertyToDefault( const OUString& PropertyName )
381 	throw(beans::UnknownPropertyException, uno::RuntimeException)
382 {
383 	_setPropertyToDefault( PropertyName, mnParagraph );
384 }
385 
386 // lang::XServiceInfo
387 
388 OUString SAL_CALL SvxUnoTextContent::getImplementationName()
389 	throw(uno::RuntimeException)
390 {
391 	return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoTextContent") );
392 }
393 
394 uno::Sequence< OUString > SAL_CALL SvxUnoTextContent::getSupportedServiceNames()
395 	throw(uno::RuntimeException)
396 {
397 	uno::Sequence< OUString > aSeq( SvxUnoTextRangeBase::getSupportedServiceNames() );
398 	comphelper::ServiceInfoHelper::addToSequence( aSeq, 5, "com.sun.star.style.ParagraphProperties",
399 												  "com.sun.star.style.ParagraphPropertiesComplex",
400 												  "com.sun.star.style.ParagraphPropertiesAsian",
401 												  "com.sun.star.text.TextContent",
402 												  "com.sun.star.text.Paragraph");
403 	return aSeq;
404 }
405 
406 // ====================================================================
407 //  class SvxUnoTextRangeEnumeration
408 // ====================================================================
409 
410 SvxUnoTextRangeEnumeration::SvxUnoTextRangeEnumeration( const SvxUnoTextBase& rText, sal_uInt16 nPara ) throw()
411 :	mxParentText(  const_cast<SvxUnoTextBase*>(&rText) ),
412 	mrParentText( rText ),
413 	mnParagraph( nPara ),
414 	mnNextPortion( 0 )
415 {
416 	mpEditSource = rText.GetEditSource() ? rText.GetEditSource()->Clone() : NULL;
417 
418 	if( mpEditSource && mpEditSource->GetTextForwarder() )
419 	{
420 		mpPortions = new SvUShorts;
421 		mpEditSource->GetTextForwarder()->GetPortions( nPara, *mpPortions );
422 	}
423 	else
424 	{
425 		mpPortions = NULL;
426 	}
427 }
428 
429 SvxUnoTextRangeEnumeration::~SvxUnoTextRangeEnumeration() throw()
430 {
431 	delete mpEditSource;
432 	delete mpPortions;
433 }
434 
435 // container::XEnumeration
436 
437 sal_Bool SAL_CALL SvxUnoTextRangeEnumeration::hasMoreElements()
438 	throw(uno::RuntimeException)
439 {
440 	OGuard aGuard( Application::GetSolarMutex() );
441 
442 	return mpPortions && mnNextPortion < mpPortions->Count();
443 }
444 
445 uno::Any SAL_CALL SvxUnoTextRangeEnumeration::nextElement()
446 	throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
447 {
448 	OGuard aGuard( Application::GetSolarMutex() );
449 
450 	if( mpPortions == NULL || mnNextPortion >= mpPortions->Count() )
451 		throw container::NoSuchElementException();
452 
453 	sal_uInt16 nStartPos = 0;
454 	if (mnNextPortion > 0)
455 		nStartPos = mpPortions->GetObject(mnNextPortion-1);
456 	sal_uInt16 nEndPos = mpPortions->GetObject(mnNextPortion);
457 	ESelection aSel( mnParagraph, nStartPos, mnParagraph, nEndPos );
458 
459 	uno::Reference< text::XTextRange > xRange;
460 
461 	const SvxUnoTextRangeBaseList& rRanges( mpEditSource->getRanges() );
462 
463 	SvxUnoTextRange* pRange = 0;
464 
465 	SvxUnoTextRangeBaseList::const_iterator aIter;
466 	for( aIter = rRanges.begin(); (aIter != rRanges.end()) && (pRange == 0); aIter++ )
467 	{
468 		SvxUnoTextRange* pIterRange = dynamic_cast< SvxUnoTextRange* >( (*aIter ) );
469 		if( pIterRange && pIterRange->mbPortion && (aSel.IsEqual( pIterRange->maSelection ) ) )
470 			pRange = pIterRange;
471 	}
472 
473 	if( pRange == 0 )
474 	{
475 		pRange = new SvxUnoTextRange( mrParentText, sal_True );
476 		pRange->SetSelection(aSel);
477 	}
478 
479 	xRange = pRange;
480 
481 	mnNextPortion++;
482 
483 	return uno::makeAny( xRange );
484 }
485 
486 // ====================================================================
487 // class SvxUnoTextCursor
488 // ====================================================================
489 
490 uno::Sequence< uno::Type > SvxUnoTextCursor::maTypeSequence;
491 
492 uno::Reference< uno::XInterface > SvxUnoTextCursor_NewInstance()
493 {
494 	SvxUnoText aText;
495 	uno::Reference< text::XText > xText( (text::XText*)new SvxUnoTextCursor( aText ) );
496 	uno::Reference< uno::XInterface > xInt( xText, uno::UNO_QUERY );
497 	return xInt;
498 }
499 
500 SvxUnoTextCursor::SvxUnoTextCursor( const SvxUnoTextBase& rText ) throw()
501 :	SvxUnoTextRangeBase(rText),
502 	mxParentText( const_cast<SvxUnoTextBase*>(&rText) )
503 {
504 }
505 
506 SvxUnoTextCursor::SvxUnoTextCursor( const SvxUnoTextCursor& rCursor ) throw()
507 :	SvxUnoTextRangeBase(rCursor)
508 ,	text::XTextCursor()
509 ,	lang::XTypeProvider()
510 ,	cppu::OWeakAggObject()
511 ,	mxParentText(rCursor.mxParentText)
512 {
513 }
514 
515 SvxUnoTextCursor::~SvxUnoTextCursor() throw()
516 {
517 }
518 
519 // automatisch auskommentiert - [getIdlClass(es) or queryInterface] - Bitte XTypeProvider benutzen!
520 //sal_Bool SvxUnoTextCursor::queryInterface( uno::Uik aUIK, Reference< uno::XInterface > & xRef)
521 uno::Any SAL_CALL SvxUnoTextCursor::queryAggregation( const uno::Type & rType )
522 	throw(uno::RuntimeException)
523 {
524 	if( rType == ::getCppuType((const uno::Reference< text::XTextRange >*)0) )
525         return uno::makeAny(uno::Reference< text::XTextRange >((text::XText*)(this)));
526 	else QUERYINT( text::XTextCursor );
527 	else QUERYINT( beans::XMultiPropertyStates );
528 	else QUERYINT( beans::XPropertySet );
529 	else QUERYINT( beans::XMultiPropertySet );
530 	else QUERYINT( beans::XPropertyState );
531 	else QUERYINT( text::XTextRangeCompare );
532 	else QUERYINT( lang::XServiceInfo );
533 	else QUERYINT( lang::XTypeProvider );
534 	else QUERYINT( lang::XUnoTunnel );
535 	else
536 		return OWeakAggObject::queryAggregation( rType );
537 }
538 
539 uno::Any SAL_CALL SvxUnoTextCursor::queryInterface( const uno::Type & rType )
540 	throw(uno::RuntimeException)
541 {
542 	return OWeakAggObject::queryInterface(rType);
543 }
544 
545 void SAL_CALL SvxUnoTextCursor::acquire() throw ( )
546 {
547 	OWeakAggObject::acquire();
548 }
549 
550 void SAL_CALL SvxUnoTextCursor::release() throw ( )
551 {
552 	OWeakAggObject::release();
553 }
554 
555 // XTypeProvider
556 uno::Sequence< uno::Type > SAL_CALL SvxUnoTextCursor::getTypes()
557 	throw(uno::RuntimeException)
558 {
559 	if( maTypeSequence.getLength() == 0 )
560 	{
561 		maTypeSequence.realloc( 10 ); // !DANGER! keep this updated
562 		uno::Type* pTypes = maTypeSequence.getArray();
563 
564 		*pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRange >*)0);
565 		*pTypes++ = ::getCppuType(( const uno::Reference< text::XTextCursor >*)0);
566 		*pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertySet >*)0);
567 		*pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertySet >*)0);
568 		*pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertyStates >*)0);
569 		*pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertyState >*)0);
570 		*pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeCompare >*)0);
571 		*pTypes++ = ::getCppuType(( const uno::Reference< lang::XServiceInfo >*)0);
572 		*pTypes++ = ::getCppuType(( const uno::Reference< lang::XTypeProvider >*)0);
573 		*pTypes++ = ::getCppuType(( const uno::Reference< lang::XUnoTunnel >*)0);
574 	}
575 	return maTypeSequence;
576 }
577 
578 uno::Sequence< sal_Int8 > SAL_CALL SvxUnoTextCursor::getImplementationId()
579 	throw (uno::RuntimeException)
580 {
581 	static uno::Sequence< sal_Int8 > aId;
582 	if( aId.getLength() == 0 )
583 	{
584 		aId.realloc( 16 );
585 		rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
586 	}
587 	return aId;
588 }
589 
590 // text::XTextCursor
591 void SAL_CALL SvxUnoTextCursor::collapseToStart()
592 	throw(uno::RuntimeException)
593 {
594 	OGuard aGuard( Application::GetSolarMutex() );
595 	CollapseToStart();
596 }
597 
598 void SAL_CALL SvxUnoTextCursor::collapseToEnd()
599 	throw(uno::RuntimeException)
600 {
601 	OGuard aGuard( Application::GetSolarMutex() );
602 	CollapseToEnd();
603 }
604 
605 sal_Bool SAL_CALL SvxUnoTextCursor::isCollapsed()
606 	throw(uno::RuntimeException)
607 {
608 	OGuard aGuard( Application::GetSolarMutex() );
609 	return IsCollapsed();
610 }
611 
612 sal_Bool SAL_CALL SvxUnoTextCursor::goLeft( sal_Int16 nCount, sal_Bool bExpand )
613 	throw(uno::RuntimeException)
614 {
615 	OGuard aGuard( Application::GetSolarMutex() );
616 	return GoLeft( nCount, bExpand );
617 }
618 
619 sal_Bool SAL_CALL SvxUnoTextCursor::goRight( sal_Int16 nCount, sal_Bool bExpand )
620 	throw(uno::RuntimeException)
621 {
622 	OGuard aGuard( Application::GetSolarMutex() );
623 	return GoRight( nCount, bExpand );
624 }
625 
626 void SAL_CALL SvxUnoTextCursor::gotoStart( sal_Bool bExpand )
627 	throw(uno::RuntimeException)
628 {
629 	OGuard aGuard( Application::GetSolarMutex() );
630 	GotoStart( bExpand );
631 }
632 
633 void SAL_CALL SvxUnoTextCursor::gotoEnd( sal_Bool bExpand )
634 	throw(uno::RuntimeException)
635 {
636 	OGuard aGuard( Application::GetSolarMutex() );
637 	GotoEnd( bExpand );
638 }
639 
640 void SAL_CALL SvxUnoTextCursor::gotoRange( const uno::Reference< text::XTextRange >& xRange, sal_Bool bExpand )
641 	throw(uno::RuntimeException)
642 {
643 	if( !xRange.is() )
644 		return;
645 
646 	SvxUnoTextRangeBase* pRange = SvxUnoTextRangeBase::getImplementation( xRange );
647 
648 	if( pRange )
649 	{
650 		ESelection aNewSel = pRange->GetSelection();
651 
652 		if( bExpand )
653 		{
654 			const ESelection& rOldSel = GetSelection();
655 			aNewSel.nStartPara = rOldSel.nStartPara;
656 			aNewSel.nStartPos  = rOldSel.nStartPos;
657 		}
658 
659 		SetSelection( aNewSel );
660 	}
661 }
662 
663 // text::XTextRange (rest in SvxTextRange)
664 uno::Reference< text::XText > SAL_CALL SvxUnoTextCursor::getText(void) throw( uno::RuntimeException )
665 {
666 	return mxParentText;
667 }
668 
669 uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextCursor::getStart()
670 	throw(uno::RuntimeException)
671 {
672 	return SvxUnoTextRangeBase::getStart();
673 }
674 
675 uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextCursor::getEnd()
676 	throw(uno::RuntimeException)
677 {
678 	return SvxUnoTextRangeBase::getEnd();
679 }
680 
681 OUString SAL_CALL SvxUnoTextCursor::getString() throw( uno::RuntimeException )
682 {
683 	return SvxUnoTextRangeBase::getString();
684 }
685 
686 void SAL_CALL SvxUnoTextCursor::setString( const OUString& aString ) throw(uno::RuntimeException)
687 {
688 	SvxUnoTextRangeBase::setString(aString);
689 }
690 // lang::XServiceInfo
691 OUString SAL_CALL SvxUnoTextCursor::getImplementationName() throw(uno::RuntimeException)
692 {
693 	return OUString(RTL_CONSTASCII_USTRINGPARAM("SvxUnoTextCursor"));
694 }
695 
696 sal_Bool SAL_CALL SvxUnoTextCursor::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException)
697 {
698 	return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
699 }
700 
701 uno::Sequence< OUString > SAL_CALL SvxUnoTextCursor::getSupportedServiceNames() throw(uno::RuntimeException)
702 {
703 	uno::Sequence< OUString > aSeq( SvxUnoTextRangeBase::getSupportedServiceNames() );
704 	comphelper::ServiceInfoHelper::addToSequence( aSeq, 4,"com.sun.star.style.ParagraphProperties",
705 												  "com.sun.star.style.ParagraphPropertiesComplex",
706 												  "com.sun.star.style.ParagraphPropertiesAsian",
707 												 "com.sun.star.text.TextCursor");
708 	return aSeq;
709 }
710 
711 
712