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