bump product version to 4.1.6.2
[LibreOffice.git] / sd / source / ui / unoidl / unosrch.cxx
blobaa736a6142ece2ea5761d597c5a22a71bba7abd7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <vcl/svapp.hxx>
21 #include <osl/mutex.hxx>
23 #include <svx/unoshape.hxx>
24 #include <svx/svdpool.hxx>
25 #include <svx/unoprov.hxx>
26 #include <editeng/unotext.hxx>
28 #include <comphelper/extract.hxx>
30 #include "unohelp.hxx"
31 #include "unoprnms.hxx"
32 #include "unosrch.hxx"
34 using namespace ::rtl;
35 using namespace ::com::sun::star;
37 #define WID_SEARCH_BACKWARDS 0
38 #define WID_SEARCH_CASE 1
39 #define WID_SEARCH_WORDS 2
41 const SfxItemPropertyMapEntry* ImplGetSearchPropertyMap()
43 static const SfxItemPropertyMapEntry aSearchPropertyMap_Impl[] =
45 { MAP_CHAR_LEN(UNO_NAME_SEARCH_BACKWARDS), WID_SEARCH_BACKWARDS, &::getBooleanCppuType(), 0, 0 },
46 { MAP_CHAR_LEN(UNO_NAME_SEARCH_CASE), WID_SEARCH_CASE, &::getBooleanCppuType(), 0, 0 },
47 { MAP_CHAR_LEN(UNO_NAME_SEARCH_WORDS), WID_SEARCH_WORDS, &::getBooleanCppuType(), 0, 0 },
48 { 0,0,0,0,0,0}
51 return aSearchPropertyMap_Impl;
54 class SearchContext_impl
56 uno::Reference< drawing::XShapes > mxShapes;
57 sal_Int32 mnIndex;
58 SearchContext_impl* mpParent;
60 public:
61 SearchContext_impl( uno::Reference< drawing::XShapes > xShapes, SearchContext_impl* pParent = NULL )
62 : mxShapes( xShapes ), mnIndex( -1 ), mpParent( pParent ) {}
65 uno::Reference< drawing::XShape > firstShape()
67 mnIndex = -1;
68 return nextShape();
71 uno::Reference< drawing::XShape > nextShape()
73 uno::Reference< drawing::XShape > xShape;
74 mnIndex++;
75 if( mxShapes.is() && mxShapes->getCount() > mnIndex )
77 mxShapes->getByIndex( mnIndex ) >>= xShape;
79 return xShape;
82 SearchContext_impl* getParent() const { return mpParent; }
85 /* ================================================================= */
86 /** this class implements a search or replace operation on a given
87 page or a given sdrobj
90 SdUnoSearchReplaceShape::SdUnoSearchReplaceShape( drawing::XDrawPage* pPage ) throw()
92 mpPage = pPage;
95 SdUnoSearchReplaceShape::~SdUnoSearchReplaceShape() throw()
99 // util::XReplaceable
100 uno::Reference< util::XReplaceDescriptor > SAL_CALL SdUnoSearchReplaceShape::createReplaceDescriptor()
101 throw( uno::RuntimeException )
103 return new SdUnoSearchReplaceDescriptor(sal_True);
106 sal_Int32 SAL_CALL SdUnoSearchReplaceShape::replaceAll( const uno::Reference< util::XSearchDescriptor >& xDesc )
107 throw( uno::RuntimeException )
109 SdUnoSearchReplaceDescriptor* pDescr = SdUnoSearchReplaceDescriptor::getImplementation( xDesc );
110 if( pDescr == NULL )
111 return 0;
113 sal_Int32 nFound = 0;
115 uno::Reference< drawing::XShapes > xShapes;
116 uno::Reference< drawing::XShape > xShape;
118 SearchContext_impl* pContext = NULL;
119 if(mpPage)
121 uno::Reference< drawing::XDrawPage > xPage( mpPage );
123 xShapes.set( xPage, uno::UNO_QUERY );
125 if( xShapes.is() && (xShapes->getCount() > 0) )
127 pContext = new SearchContext_impl( xShapes );
128 xShape = pContext->firstShape();
130 else
132 xShapes = NULL;
135 else
137 xShape = mpShape;
140 while( xShape.is() )
142 // replace in xShape
143 uno::Reference< text::XText > xText(xShape, uno::UNO_QUERY);
144 uno::Reference< text::XTextRange > xRange(xText, uno::UNO_QUERY);
145 uno::Reference< text::XTextRange > xFound;
147 while( xRange.is() )
149 xFound = Search( xRange, pDescr );
150 if( !xFound.is() )
151 break;
153 xFound->setString( pDescr->getReplaceString() );
154 xRange = xFound->getEnd();
155 nFound++;
157 // done with xShape -> get next shape
159 // test if its a group
160 uno::Reference< drawing::XShapes > xGroupShape( xShape, uno::UNO_QUERY );
161 if( xGroupShape.is() && ( xGroupShape->getCount() > 0 ) )
163 pContext = new SearchContext_impl( xGroupShape, pContext );
164 xShape = pContext->firstShape();
166 else
168 if( pContext )
169 xShape = pContext->nextShape();
170 else
171 xShape = NULL;
174 // test parent contexts for next shape if none
175 // is found in the current context
176 while( pContext && !xShape.is() )
178 if( pContext->getParent() )
180 SearchContext_impl* pOldContext = pContext;
181 pContext = pContext->getParent();
182 delete pOldContext;
183 xShape = pContext->nextShape();
185 else
187 delete pContext;
188 pContext = NULL;
189 xShape = NULL;
194 return nFound;
197 // XSearchable
198 uno::Reference< ::com::sun::star::util::XSearchDescriptor > SAL_CALL SdUnoSearchReplaceShape::createSearchDescriptor( )
199 throw(::com::sun::star::uno::RuntimeException)
201 return new SdUnoSearchReplaceDescriptor(sal_False);
204 uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL SdUnoSearchReplaceShape::findAll( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor >& xDesc )
205 throw(::com::sun::star::uno::RuntimeException)
207 SdUnoSearchReplaceDescriptor* pDescr = SdUnoSearchReplaceDescriptor::getImplementation( xDesc );
208 if( pDescr == NULL )
209 return uno::Reference< container::XIndexAccess > ();
212 sal_Int32 nSequence = 32;
213 sal_Int32 nFound = 0;
215 uno::Sequence < uno::Reference< uno::XInterface > > aSeq( nSequence );
217 uno::Reference< uno::XInterface > * pArray = aSeq.getArray();
219 uno::Reference< drawing::XShapes > xShapes;
220 uno::Reference< drawing::XShape > xShape;
222 SearchContext_impl* pContext = NULL;
223 if(mpPage)
225 uno::Reference< drawing::XDrawPage > xPage( mpPage );
226 xShapes.set( xPage, uno::UNO_QUERY );
228 if( xShapes.is() && xShapes->getCount() > 0 )
230 pContext = new SearchContext_impl( xShapes );
231 xShape = pContext->firstShape();
233 else
235 xShapes = NULL;
238 else
240 xShape = mpShape;
242 while( xShape.is() )
244 // find in xShape
245 uno::Reference< text::XText > xText(xShape, uno::UNO_QUERY);
246 uno::Reference< text::XTextRange > xRange(xText, uno::UNO_QUERY);
247 uno::Reference< text::XTextRange > xFound;
249 while( xRange.is() )
251 xFound = Search( xRange, pDescr );
252 if( !xFound.is() )
253 break;
255 if( nFound >= nSequence )
257 nSequence += 32;
258 aSeq.realloc( nSequence );
259 pArray = aSeq.getArray();
262 pArray[nFound++] = xFound;
264 xRange = xFound->getEnd();
266 // done with shape -> get next shape
268 // test if its a group
269 uno::Reference< drawing::XShapes > xGroupShape;
270 xGroupShape.set( xShape, uno::UNO_QUERY );
272 if( xGroupShape.is() && xGroupShape->getCount() > 0 )
274 pContext = new SearchContext_impl( xGroupShape, pContext );
275 xShape = pContext->firstShape();
277 else
279 if( pContext )
280 xShape = pContext->nextShape();
281 else
282 xShape = NULL;
285 // test parent contexts for next shape if none
286 // is found in the current context
287 while( pContext && !xShape.is() )
289 if( pContext->getParent() )
291 SearchContext_impl* pOldContext = pContext;
292 pContext = pContext->getParent();
293 delete pOldContext;
294 xShape = pContext->nextShape();
296 else
298 delete pContext;
299 pContext = NULL;
300 xShape = NULL;
305 if( nFound != nSequence )
306 aSeq.realloc( nFound );
308 return (container::XIndexAccess*)new SdUnoFindAllAccess( aSeq );
311 uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SdUnoSearchReplaceShape::findFirst( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor >& xDesc )
312 throw(::com::sun::star::uno::RuntimeException)
314 uno::Reference< text::XTextRange > xRange( GetCurrentShape(), uno::UNO_QUERY );
315 if( xRange.is() )
316 return findNext( xRange, xDesc );
318 return uno::Reference< uno::XInterface > ();
321 uno::Reference< drawing::XShape > SdUnoSearchReplaceShape::GetCurrentShape() const throw()
323 uno::Reference< drawing::XShape > xShape;
325 if( mpPage )
327 uno::Reference< drawing::XDrawPage > xPage( mpPage );
328 uno::Reference< container::XIndexAccess > xShapes( xPage, uno::UNO_QUERY );
329 if( xShapes.is() )
331 if(xShapes->getCount() > 0)
333 xShapes->getByIndex(0) >>= xShape;
337 else if( mpShape )
339 xShape = mpShape;
342 return xShape;
346 uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SdUnoSearchReplaceShape::findNext( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xStartAt, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor >& xDesc )
347 throw(::com::sun::star::uno::RuntimeException)
349 SdUnoSearchReplaceDescriptor* pDescr = SdUnoSearchReplaceDescriptor::getImplementation( xDesc );
351 uno::Reference< uno::XInterface > xFound;
353 uno::Reference< text::XTextRange > xRange( xStartAt, uno::UNO_QUERY );
354 if(pDescr && xRange.is() )
357 uno::Reference< text::XTextRange > xCurrentRange( xStartAt, uno::UNO_QUERY );
359 uno::Reference< drawing::XShape > xCurrentShape( GetShape( xCurrentRange ) );
361 while(!xFound.is() && xRange.is())
363 xFound = Search( xRange, pDescr );
364 if(!xFound.is())
366 // we need a new starting range now
367 xRange = NULL;
369 if(mpPage)
371 uno::Reference< drawing::XDrawPage > xPage( mpPage );
373 // we do a page wide search, so skip to the next shape here
374 uno::Reference< container::XIndexAccess > xShapes( xPage, uno::UNO_QUERY );
376 // get next shape on our page
377 if( xShapes.is() )
379 uno::Reference< drawing::XShape > xFound2( GetNextShape( xShapes, xCurrentShape ) );
380 if( xFound2.is() && (xFound2.get() != xCurrentShape.get()) )
381 xCurrentShape = xFound2;
382 else
383 xCurrentShape = NULL;
385 xRange.set( xCurrentShape, uno::UNO_QUERY );
386 if(!(xCurrentShape.is() && (xRange.is())))
387 xRange = NULL;
390 else
392 // we search only in this shape, so end search if we have
393 // not found anything
398 return xFound;
401 /** this method returns the shape that follows xCurrentShape in the shape collection xShapes.
402 It steps recursive into groupshapes and returns the xCurrentShape if it is the last
403 shape in this collection */
404 uno::Reference< drawing::XShape > SdUnoSearchReplaceShape::GetNextShape( uno::Reference< container::XIndexAccess > xShapes, uno::Reference< drawing::XShape > xCurrentShape ) throw()
406 uno::Reference< drawing::XShape > xFound;
407 uno::Any aAny;
409 if(xShapes.is() && xCurrentShape.is())
411 const sal_Int32 nCount = xShapes->getCount();
412 for( sal_Int32 i = 0; i < nCount; i++ )
414 uno::Reference< drawing::XShape > xSearchShape;
415 xShapes->getByIndex(i) >>= xSearchShape;
417 if( xSearchShape.is() )
419 uno::Reference< container::XIndexAccess > xGroup( xSearchShape, uno::UNO_QUERY );
421 if( xCurrentShape.get() == xSearchShape.get() )
423 if( xGroup.is() && xGroup->getCount() > 0 )
425 xGroup->getByIndex( 0 ) >>= xFound;
427 else
429 i++;
430 if( i < nCount )
431 xShapes->getByIndex( i ) >>= xFound;
432 else
433 xFound = xCurrentShape;
436 break;
438 else if( xGroup.is() )
440 xFound = GetNextShape( xGroup, xCurrentShape );
441 if( xFound.is() )
443 if( xFound.get() == xCurrentShape.get() )
445 // the current shape was found at the end of the group
446 i++;
447 if( i < nCount )
449 xShapes->getByIndex(i) >>= xFound;
452 break;
459 return xFound;
462 uno::Reference< text::XTextRange > SdUnoSearchReplaceShape::Search( uno::Reference< text::XTextRange > xText, SdUnoSearchReplaceDescriptor* pDescr ) throw()
464 if(!xText.is())
465 return uno::Reference< text::XTextRange > ();
467 uno::Reference< text::XText > xParent( xText->getText() );
469 if( !xParent.is() )
471 xParent.set( xText, uno::UNO_QUERY );
474 const OUString aText( xParent->getString() );
476 const sal_Int32 nTextLen = aText.getLength();
478 sal_Int32* pConvertPos = new sal_Int32[nTextLen+2];
479 sal_Int32* pConvertPara = new sal_Int32[nTextLen+2];
481 int ndbg = 0;
482 const sal_Unicode* pText = aText.getStr();
484 sal_Int32* pPos = pConvertPos;
485 sal_Int32* pPara = pConvertPara;
487 sal_Int32 nLastPos = 0, nLastPara = 0;
489 uno::Reference< container::XEnumerationAccess > xEnumAccess( xParent, uno::UNO_QUERY );
491 // first we fill the arrys with the position and paragraph for every character
492 // inside the text
493 if( xEnumAccess.is() )
495 uno::Reference< container::XEnumeration > xParaEnum( xEnumAccess->createEnumeration() );
497 while(xParaEnum->hasMoreElements())
499 uno::Reference< text::XTextContent > xParagraph( xParaEnum->nextElement(), uno::UNO_QUERY );
500 if( xParagraph.is() )
501 xEnumAccess.query( xParagraph );
502 else
503 xEnumAccess.clear();
505 if( xEnumAccess.is() )
507 uno::Reference< container::XEnumeration > xPortionEnum( xEnumAccess->createEnumeration() );
508 if( xPortionEnum.is() )
510 while(xPortionEnum->hasMoreElements())
512 uno::Reference< text::XTextRange > xPortion( xPortionEnum->nextElement(), uno::UNO_QUERY );
513 if( xPortion.is() )
515 const OUString aPortion( xPortion->getString() );
516 const sal_Int32 nLen = aPortion.getLength();
518 ESelection aStartSel( GetSelection( xPortion->getStart() ) );
519 ESelection aEndSel( GetSelection( xPortion->getEnd() ) );
521 // special case for empty portions with content or length one portions with content (fields)
522 if( (aStartSel.nStartPos == aEndSel.nStartPos) || ( (aStartSel.nStartPos == (aEndSel.nStartPos - 1)) && (nLen > 1) ) )
524 for( sal_Int32 i = 0; i < nLen; i++ )
526 if( ndbg < (nTextLen+2) )
528 *pPos++ = aStartSel.nStartPos;
529 *pPara++ = aStartSel.nStartPara;
531 ndbg += 1;
532 pText++;
534 else
536 OSL_FAIL( "array overflow while searching" );
540 nLastPos = aStartSel.nStartPos;
542 // normal case
543 else
545 for( sal_Int32 i = 0; i < nLen; i++ )
547 if( ndbg < (nTextLen+2) )
549 *pPos++ = aStartSel.nStartPos++;
550 *pPara++ = aStartSel.nStartPara;
552 ndbg += 1;
553 pText++;
555 else
557 OSL_FAIL( "array overflow while searching" );
561 nLastPos = aStartSel.nStartPos - 1;
562 DBG_ASSERT( aEndSel.nStartPos == aStartSel.nStartPos, "Search is not working" );
564 nLastPara = aStartSel.nStartPara;
570 if( ndbg < (nTextLen+2) )
572 *pPos++ = nLastPos + 1;
573 *pPara++ = nLastPara;
575 ndbg += 1;
576 pText++;
578 else
580 OSL_FAIL( "array overflow while searching" );
585 uno::Reference< text::XText > xFound;
586 ESelection aSel;
588 uno::Reference< text::XTextRange > xRangeRef( xText, uno::UNO_QUERY );
589 if( xRangeRef.is() )
590 aSel = GetSelection( xRangeRef );
592 sal_Int32 nStartPos;
593 sal_Int32 nEndPos = 0;
594 for( nStartPos = 0; nStartPos < nTextLen; nStartPos++ )
596 if( pConvertPara[nStartPos] == aSel.nStartPara && pConvertPos[nStartPos] == aSel.nStartPos )
597 break;
600 if( Search( aText, nStartPos, nEndPos, pDescr ) )
602 if( nStartPos <= nTextLen && nEndPos <= nTextLen )
604 ESelection aSelection( pConvertPara[nStartPos], (sal_uInt16)pConvertPos[nStartPos],
605 pConvertPara[nEndPos], (sal_uInt16)pConvertPos[nEndPos] );
606 SvxUnoTextRange *pRange;
608 SvxUnoTextBase* pParent = SvxUnoTextBase::getImplementation( xParent );
610 if(pParent)
612 pRange = new SvxUnoTextRange( *pParent );
613 xFound = (text::XText*)pRange;
614 pRange->SetSelection(aSelection);
618 else
620 OSL_FAIL("Array overflow while searching!");
624 delete[] pConvertPos;
625 delete[] pConvertPara;
627 return uno::Reference< text::XTextRange > ( xFound, uno::UNO_QUERY );
630 sal_Bool SdUnoSearchReplaceShape::Search( const OUString& rText, sal_Int32& nStartPos, sal_Int32& nEndPos, SdUnoSearchReplaceDescriptor* pDescr ) throw()
632 OUString aSearchStr( pDescr->getSearchString() );
633 OUString aText( rText );
635 if( !pDescr->IsCaseSensitive() )
637 aText = aText.toAsciiLowerCase();
638 aSearchStr = aSearchStr.toAsciiLowerCase();
641 sal_Int32 nFound = aText.indexOf( aSearchStr, nStartPos );
642 if( nFound != -1 )
644 nStartPos = nFound;
645 nEndPos = nFound + aSearchStr.getLength();
647 if(pDescr->IsWords())
649 if( (nStartPos > 0 && aText.getStr()[nStartPos-1] > ' ') ||
650 (nEndPos < aText.getLength() && aText.getStr()[nEndPos] > ' ') )
652 nStartPos++;
653 return Search( aText, nStartPos, nEndPos, pDescr );
657 return sal_True;
659 else
660 return sal_False;
663 ESelection SdUnoSearchReplaceShape::GetSelection( uno::Reference< text::XTextRange > xTextRange ) throw()
665 ESelection aSel;
666 SvxUnoTextRangeBase* pRange = SvxUnoTextRangeBase::getImplementation( xTextRange );
668 if(pRange)
669 aSel = pRange->GetSelection();
671 return aSel;
674 uno::Reference< drawing::XShape > SdUnoSearchReplaceShape::GetShape( uno::Reference< text::XTextRange > xTextRange ) throw()
676 uno::Reference< drawing::XShape > xShape;
678 if(xTextRange.is())
680 uno::Reference< text::XText > xText( xTextRange->getText() );
682 if(xText.is())
686 xShape.set( xText, uno::UNO_QUERY );
687 if(!xShape.is())
689 uno::Reference< text::XText > xParent( xText->getText() );
690 if(!xParent.is() || xText.get() == xParent.get())
691 return xShape;
693 xText = xParent;
695 } while( !xShape.is() );
699 return xShape;
702 /* ================================================================= */
703 /** this class holds the parameters and status of a search or replace
704 operation performed by class SdUnoSearchReplaceShape
707 UNO3_GETIMPLEMENTATION_IMPL( SdUnoSearchReplaceDescriptor );
709 SdUnoSearchReplaceDescriptor::SdUnoSearchReplaceDescriptor( sal_Bool bReplace ) throw()
711 mpPropSet = new SvxItemPropertySet(ImplGetSearchPropertyMap(), SdrObject::GetGlobalDrawObjectItemPool());
713 mbBackwards = sal_False;
714 mbCaseSensitive = sal_False;
715 mbWords = sal_False;
717 mbReplace = bReplace;
720 SdUnoSearchReplaceDescriptor::~SdUnoSearchReplaceDescriptor() throw()
722 delete mpPropSet;
725 // XSearchDescriptor
726 OUString SAL_CALL SdUnoSearchReplaceDescriptor::getSearchString()
727 throw(::com::sun::star::uno::RuntimeException)
729 return maSearchStr;
732 void SAL_CALL SdUnoSearchReplaceDescriptor::setSearchString( const OUString& aString )
733 throw(::com::sun::star::uno::RuntimeException)
735 maSearchStr = aString;
738 // XReplaceDescriptor
739 OUString SAL_CALL SdUnoSearchReplaceDescriptor::getReplaceString()
740 throw(::com::sun::star::uno::RuntimeException)
742 return maReplaceStr;
745 void SAL_CALL SdUnoSearchReplaceDescriptor::setReplaceString( const OUString& aReplaceString )
746 throw(::com::sun::star::uno::RuntimeException)
748 maReplaceStr = aReplaceString;
751 // XPropertySet
752 uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL SdUnoSearchReplaceDescriptor::getPropertySetInfo()
753 throw(::com::sun::star::uno::RuntimeException)
755 SolarMutexGuard aGuard;
756 return mpPropSet->getPropertySetInfo();
759 void SAL_CALL SdUnoSearchReplaceDescriptor::setPropertyValue( const OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
760 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
762 SolarMutexGuard aGuard;
764 const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(aPropertyName);
766 sal_Bool bOk = sal_False;
768 switch( pEntry ? pEntry->nWID : -1 )
770 case WID_SEARCH_BACKWARDS:
771 bOk = (aValue >>= mbBackwards);
772 break;
773 case WID_SEARCH_CASE:
774 bOk = (aValue >>= mbCaseSensitive);
775 break;
776 case WID_SEARCH_WORDS:
777 bOk = (aValue >>= mbWords);
778 break;
779 default:
780 throw beans::UnknownPropertyException();
783 if( !bOk )
784 throw lang::IllegalArgumentException();
787 uno::Any SAL_CALL SdUnoSearchReplaceDescriptor::getPropertyValue( const OUString& PropertyName )
788 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
790 SolarMutexGuard aGuard;
792 uno::Any aAny;
794 const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(PropertyName);
796 switch( pEntry ? pEntry->nWID : -1 )
798 case WID_SEARCH_BACKWARDS:
799 aAny <<= (sal_Bool)mbBackwards;
800 break;
801 case WID_SEARCH_CASE:
802 aAny <<= (sal_Bool)mbCaseSensitive;
803 break;
804 case WID_SEARCH_WORDS:
805 aAny <<= (sal_Bool)mbWords;
806 break;
807 default:
808 throw beans::UnknownPropertyException();
811 return aAny;
814 void SAL_CALL SdUnoSearchReplaceDescriptor::addPropertyChangeListener( const OUString& , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) {}
815 void SAL_CALL SdUnoSearchReplaceDescriptor::removePropertyChangeListener( const OUString& , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) {}
816 void SAL_CALL SdUnoSearchReplaceDescriptor::addVetoableChangeListener( const OUString& , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) {}
817 void SAL_CALL SdUnoSearchReplaceDescriptor::removeVetoableChangeListener( const OUString& , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) {}
820 /* ================================================================= */
822 SdUnoFindAllAccess::SdUnoFindAllAccess( uno::Sequence< uno::Reference< uno::XInterface > >& rSequence ) throw()
823 :maSequence( rSequence )
827 SdUnoFindAllAccess::~SdUnoFindAllAccess() throw()
831 // XElementAccess
832 uno::Type SAL_CALL SdUnoFindAllAccess::getElementType()
833 throw(::com::sun::star::uno::RuntimeException)
835 return ITYPE( text::XTextRange );
838 sal_Bool SAL_CALL SdUnoFindAllAccess::hasElements()
839 throw(::com::sun::star::uno::RuntimeException)
841 return maSequence.getLength() > 0;
844 // XIndexAccess
845 sal_Int32 SAL_CALL SdUnoFindAllAccess::getCount()
846 throw(::com::sun::star::uno::RuntimeException)
848 return maSequence.getLength();
851 uno::Any SAL_CALL SdUnoFindAllAccess::getByIndex( sal_Int32 Index )
852 throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
854 uno::Any aAny;
856 if( Index < 0 || Index >= getCount() )
857 throw lang::IndexOutOfBoundsException();
859 const uno::Reference< uno::XInterface > *pRefs = maSequence.getConstArray();
860 if(pRefs)
861 aAny <<= pRefs[ Index ];
862 return aAny;
865 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */