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