Update ooo320-m1
[ooovba.git] / sd / source / ui / unoidl / unosrch.cxx
blob0d5d501ba313b49b7b07ce281fac3ddb02367236
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unosrch.cxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
33 #include <vcl/svapp.hxx>
34 #include <vos/mutex.hxx>
36 #ifndef SVX_UNOSHAPE_HXX
37 #include <svx/unoshape.hxx>
38 #endif
39 #include <svx/unoprov.hxx>
40 #include <svx/unotext.hxx>
42 #include <comphelper/extract.hxx>
43 #include <rtl/uuid.h>
44 #include <rtl/memory.h>
46 #include "unohelp.hxx"
47 #include "unoprnms.hxx"
48 #include "unosrch.hxx"
50 using namespace ::vos;
51 using namespace ::rtl;
52 using namespace ::com::sun::star;
54 #define WID_SEARCH_BACKWARDS 0
55 #define WID_SEARCH_CASE 1
56 #define WID_SEARCH_WORDS 2
58 const SfxItemPropertyMapEntry* ImplGetSearchPropertyMap()
60 static const SfxItemPropertyMapEntry aSearchPropertyMap_Impl[] =
62 { MAP_CHAR_LEN(UNO_NAME_SEARCH_BACKWARDS), WID_SEARCH_BACKWARDS, &::getBooleanCppuType(), 0, 0 },
63 { MAP_CHAR_LEN(UNO_NAME_SEARCH_CASE), WID_SEARCH_CASE, &::getBooleanCppuType(), 0, 0 },
64 { MAP_CHAR_LEN(UNO_NAME_SEARCH_WORDS), WID_SEARCH_WORDS, &::getBooleanCppuType(), 0, 0 },
65 { 0,0,0,0,0,0}
68 return aSearchPropertyMap_Impl;
71 class SearchContext_impl
73 uno::Reference< drawing::XShapes > mxShapes;
74 sal_Int32 mnIndex;
75 SearchContext_impl* mpParent;
77 public:
78 SearchContext_impl( uno::Reference< drawing::XShapes > xShapes, SearchContext_impl* pParent = NULL )
79 : mxShapes( xShapes ), mnIndex( -1 ), mpParent( pParent ) {}
82 uno::Reference< drawing::XShape > firstShape()
84 mnIndex = -1;
85 return nextShape();
88 uno::Reference< drawing::XShape > nextShape()
90 uno::Reference< drawing::XShape > xShape;
91 mnIndex++;
92 if( mxShapes.is() && mxShapes->getCount() > mnIndex )
94 mxShapes->getByIndex( mnIndex ) >>= xShape;
96 return xShape;
99 SearchContext_impl* getParent() const { return mpParent; }
102 /* ================================================================= */
103 /** this class implements a search or replace operation on a given
104 page or a given sdrobj
107 SdUnoSearchReplaceShape::SdUnoSearchReplaceShape( drawing::XDrawPage* pPage ) throw()
109 mpPage = pPage;
112 SdUnoSearchReplaceShape::SdUnoSearchReplaceShape( drawing::XShape* pShape ) throw()
114 mpShape = pShape;
117 SdUnoSearchReplaceShape::~SdUnoSearchReplaceShape() throw()
121 // util::XReplaceable
122 uno::Reference< util::XReplaceDescriptor > SAL_CALL SdUnoSearchReplaceShape::createReplaceDescriptor()
123 throw( uno::RuntimeException )
125 return new SdUnoSearchReplaceDescriptor(sal_True);
128 sal_Int32 SAL_CALL SdUnoSearchReplaceShape::replaceAll( const uno::Reference< util::XSearchDescriptor >& xDesc )
129 throw( uno::RuntimeException )
131 SdUnoSearchReplaceDescriptor* pDescr = SdUnoSearchReplaceDescriptor::getImplementation( xDesc );
132 if( pDescr == NULL )
133 return 0;
135 sal_Int32 nFound = 0;
137 uno::Reference< drawing::XShapes > xShapes;
138 uno::Reference< drawing::XShape > xShape;
140 SearchContext_impl* pContext = NULL;
141 if(mpPage)
143 uno::Reference< drawing::XDrawPage > xPage( mpPage );
145 xPage->queryInterface( ITYPE( drawing::XShapes ) ) >>= xShapes;
147 if( xShapes.is() && (xShapes->getCount() > 0) )
149 pContext = new SearchContext_impl( xShapes );
150 xShape = pContext->firstShape();
152 else
154 xShapes = NULL;
157 else
159 xShape = mpShape;
162 while( xShape.is() )
164 // replace in xShape
165 uno::Reference< text::XText > xText(xShape, uno::UNO_QUERY);
166 uno::Reference< text::XTextRange > xRange(xText, uno::UNO_QUERY);
167 uno::Reference< text::XTextRange > xFound;
169 while( xRange.is() )
171 xFound = Search( xRange, pDescr );
172 if( !xFound.is() )
173 break;
175 xFound->setString( pDescr->getReplaceString() );
176 xRange = xFound->getEnd();
177 nFound++;
179 // done with xShape -> get next shape
181 // test if its a group
182 uno::Reference< drawing::XShapes > xGroupShape( xShape, uno::UNO_QUERY );
183 if( xGroupShape.is() && ( xGroupShape->getCount() > 0 ) )
185 pContext = new SearchContext_impl( xGroupShape, pContext );
186 xShape = pContext->firstShape();
188 else
190 if( pContext )
191 xShape = pContext->nextShape();
192 else
193 xShape = NULL;
196 // test parent contexts for next shape if none
197 // is found in the current context
198 while( pContext && !xShape.is() )
200 if( pContext->getParent() )
202 SearchContext_impl* pOldContext = pContext;
203 pContext = pContext->getParent();
204 delete pOldContext;
205 xShape = pContext->nextShape();
207 else
209 delete pContext;
210 pContext = NULL;
211 xShape = NULL;
216 return nFound;
219 // XSearchable
220 uno::Reference< ::com::sun::star::util::XSearchDescriptor > SAL_CALL SdUnoSearchReplaceShape::createSearchDescriptor( )
221 throw(::com::sun::star::uno::RuntimeException)
223 return new SdUnoSearchReplaceDescriptor(sal_False);
226 uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL SdUnoSearchReplaceShape::findAll( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor >& xDesc )
227 throw(::com::sun::star::uno::RuntimeException)
229 SdUnoSearchReplaceDescriptor* pDescr = SdUnoSearchReplaceDescriptor::getImplementation( xDesc );
230 if( pDescr == NULL )
231 return uno::Reference< container::XIndexAccess > ();
234 sal_Int32 nSequence = 32;
235 sal_Int32 nFound = 0;
237 uno::Sequence < uno::Reference< uno::XInterface > > aSeq( nSequence );
239 uno::Reference< uno::XInterface > * pArray = aSeq.getArray();
241 uno::Reference< drawing::XShapes > xShapes;
242 uno::Reference< drawing::XShape > xShape;
244 SearchContext_impl* pContext = NULL;
245 if(mpPage)
247 uno::Reference< drawing::XDrawPage > xPage( mpPage );
248 xPage->queryInterface( ITYPE( drawing::XShapes ) ) >>= xShapes;
250 if( xShapes.is() && xShapes->getCount() > 0 )
252 pContext = new SearchContext_impl( xShapes );
253 xShape = pContext->firstShape();
255 else
257 xShapes = NULL;
260 else
262 xShape = mpShape;
264 while( xShape.is() )
266 // find in xShape
267 uno::Reference< text::XText > xText(xShape, uno::UNO_QUERY);
268 uno::Reference< text::XTextRange > xRange(xText, uno::UNO_QUERY);
269 uno::Reference< text::XTextRange > xFound;
271 while( xRange.is() )
273 xFound = Search( xRange, pDescr );
274 if( !xFound.is() )
275 break;
277 if( nFound >= nSequence )
279 nSequence += 32;
280 aSeq.realloc( nSequence );
281 pArray = aSeq.getArray();
284 pArray[nFound++] = xFound;
286 xRange = xFound->getEnd();
288 // done with shape -> get next shape
290 // test if its a group
291 uno::Reference< drawing::XShapes > xGroupShape;
292 uno::Any aAny( xShape->queryInterface( ITYPE( drawing::XShapes )));
294 if( (aAny >>= xGroupShape ) && xGroupShape->getCount() > 0 )
296 pContext = new SearchContext_impl( xGroupShape, pContext );
297 xShape = pContext->firstShape();
299 else
301 if( pContext )
302 xShape = pContext->nextShape();
303 else
304 xShape = NULL;
307 // test parent contexts for next shape if none
308 // is found in the current context
309 while( pContext && !xShape.is() )
311 if( pContext->getParent() )
313 SearchContext_impl* pOldContext = pContext;
314 pContext = pContext->getParent();
315 delete pOldContext;
316 xShape = pContext->nextShape();
318 else
320 delete pContext;
321 pContext = NULL;
322 xShape = NULL;
327 if( nFound != nSequence )
328 aSeq.realloc( nFound );
330 return (container::XIndexAccess*)new SdUnoFindAllAccess( aSeq );
333 uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SdUnoSearchReplaceShape::findFirst( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor >& xDesc )
334 throw(::com::sun::star::uno::RuntimeException)
336 uno::Reference< text::XTextRange > xRange( GetCurrentShape(), uno::UNO_QUERY );
337 if( xRange.is() )
338 return findNext( xRange, xDesc );
340 return uno::Reference< uno::XInterface > ();
343 uno::Reference< drawing::XShape > SdUnoSearchReplaceShape::GetCurrentShape() const throw()
345 uno::Reference< drawing::XShape > xShape;
347 if( mpPage )
349 uno::Reference< drawing::XDrawPage > xPage( mpPage );
350 uno::Reference< container::XIndexAccess > xShapes( xPage, uno::UNO_QUERY );
351 if( xShapes.is() )
353 if(xShapes->getCount() > 0)
355 xShapes->getByIndex(0) >>= xShape;
359 else if( mpShape )
361 xShape = mpShape;
364 return xShape;
368 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 )
369 throw(::com::sun::star::uno::RuntimeException)
371 SdUnoSearchReplaceDescriptor* pDescr = SdUnoSearchReplaceDescriptor::getImplementation( xDesc );
373 uno::Reference< uno::XInterface > xFound;
375 uno::Reference< text::XTextRange > xRange( xStartAt, uno::UNO_QUERY );
376 if(pDescr && xRange.is() )
379 uno::Reference< text::XTextRange > xCurrentRange( xStartAt, uno::UNO_QUERY );
381 uno::Reference< drawing::XShape > xCurrentShape( GetShape( xCurrentRange ) );
383 while(!xFound.is() && xRange.is())
385 xFound = Search( xRange, pDescr );
386 if(!xFound.is())
388 // we need a new starting range now
389 xRange = NULL;
391 if(mpPage)
393 uno::Reference< drawing::XDrawPage > xPage( mpPage );
395 // we do a page wide search, so skip to the next shape here
396 uno::Reference< container::XIndexAccess > xShapes( xPage, uno::UNO_QUERY );
398 // get next shape on our page
399 if( xShapes.is() )
401 uno::Reference< drawing::XShape > xFound2( GetNextShape( xShapes, xCurrentShape ) );
402 if( xFound2.is() && (xFound2.get() != xCurrentShape.get()) )
403 xCurrentShape = xFound2;
404 else
405 xCurrentShape = NULL;
407 xCurrentShape->queryInterface( ITYPE( text::XTextRange ) ) >>= xRange;
408 if(!(xCurrentShape.is() && (xRange.is())))
409 xRange = NULL;
412 else
414 // we search only in this shape, so end search if we have
415 // not found anything
420 return xFound;
423 /** this method returns the shape that follows xCurrentShape in the shape collection xShapes.
424 It steps recursive into groupshapes and returns the xCurrentShape if it is the last
425 shape in this collection */
426 uno::Reference< drawing::XShape > SdUnoSearchReplaceShape::GetNextShape( uno::Reference< container::XIndexAccess > xShapes, uno::Reference< drawing::XShape > xCurrentShape ) throw()
428 uno::Reference< drawing::XShape > xFound;
429 uno::Any aAny;
431 if(xShapes.is() && xCurrentShape.is())
433 const sal_Int32 nCount = xShapes->getCount();
434 for( sal_Int32 i = 0; i < nCount; i++ )
436 uno::Reference< drawing::XShape > xSearchShape;
437 xShapes->getByIndex(i) >>= xSearchShape;
439 if( xSearchShape.is() )
441 uno::Reference< container::XIndexAccess > xGroup( xSearchShape, uno::UNO_QUERY );
443 if( xCurrentShape.get() == xSearchShape.get() )
445 if( xGroup.is() && xGroup->getCount() > 0 )
447 xGroup->getByIndex( 0 ) >>= xFound;
449 else
451 i++;
452 if( i < nCount )
453 xShapes->getByIndex( i ) >>= xFound;
454 else
455 xFound = xCurrentShape;
458 break;
460 else if( xGroup.is() )
462 xFound = GetNextShape( xGroup, xCurrentShape );
463 if( xFound.is() )
465 if( xFound.get() == xCurrentShape.get() )
467 // the current shape was found at the end of the group
468 i++;
469 if( i < nCount )
471 xShapes->getByIndex(i) >>= xFound;
474 break;
481 return xFound;
484 uno::Reference< text::XTextRange > SdUnoSearchReplaceShape::Search( uno::Reference< text::XTextRange > xText, SdUnoSearchReplaceDescriptor* pDescr ) throw()
486 if(!xText.is())
487 return uno::Reference< text::XTextRange > ();
489 uno::Reference< text::XText > xParent( xText->getText() );
491 if( !xParent.is() )
493 uno::Any aAny( xText->queryInterface( ITYPE( text::XText )) );
494 aAny >>= xParent;
497 const OUString aText( xParent->getString() );
499 const sal_Int32 nTextLen = aText.getLength();
501 sal_Int32* pConvertPos = new sal_Int32[nTextLen+2];
502 sal_Int32* pConvertPara = new sal_Int32[nTextLen+2];
504 int ndbg = 0;
505 const sal_Unicode* pText = aText;
507 sal_Int32* pPos = pConvertPos;
508 sal_Int32* pPara = pConvertPara;
510 sal_Int32 nLastPos = 0, nLastPara = 0;
512 uno::Reference< container::XEnumerationAccess > xEnumAccess( xParent, uno::UNO_QUERY );
514 // first we fill the arrys with the position and paragraph for every character
515 // inside the text
516 if( xEnumAccess.is() )
518 uno::Reference< container::XEnumeration > xParaEnum( xEnumAccess->createEnumeration() );
520 while(xParaEnum->hasMoreElements())
522 uno::Reference< text::XTextContent > xParagraph( xParaEnum->nextElement(), uno::UNO_QUERY );
523 if( xParagraph.is() )
524 xEnumAccess.query( xParagraph );
525 else
526 xEnumAccess.clear();
528 if( xEnumAccess.is() )
530 uno::Reference< container::XEnumeration > xPortionEnum( xEnumAccess->createEnumeration() );
531 if( xPortionEnum.is() )
533 while(xPortionEnum->hasMoreElements())
535 uno::Reference< text::XTextRange > xPortion( xPortionEnum->nextElement(), uno::UNO_QUERY );
536 if( xPortion.is() )
538 const OUString aPortion( xPortion->getString() );
539 const sal_Int32 nLen = aPortion.getLength();
541 ESelection aStartSel( GetSelection( xPortion->getStart() ) );
542 ESelection aEndSel( GetSelection( xPortion->getEnd() ) );
544 // special case for empty portions with content or length one portions with content (fields)
545 if( (aStartSel.nStartPos == aEndSel.nStartPos) || ( (aStartSel.nStartPos == (aEndSel.nStartPos - 1)) && (nLen > 1) ) )
547 for( sal_Int32 i = 0; i < nLen; i++ )
549 if( ndbg < (nTextLen+2) )
551 *pPos++ = aStartSel.nStartPos;
552 *pPara++ = aStartSel.nStartPara;
554 ndbg += 1;
555 pText++;
557 else
559 DBG_ERROR( "array overflow while searching" );
563 nLastPos = aStartSel.nStartPos;
565 // normal case
566 else
568 for( sal_Int32 i = 0; i < nLen; i++ )
570 if( ndbg < (nTextLen+2) )
572 *pPos++ = aStartSel.nStartPos++;
573 *pPara++ = aStartSel.nStartPara;
575 ndbg += 1;
576 pText++;
578 else
580 DBG_ERROR( "array overflow while searching" );
584 nLastPos = aStartSel.nStartPos - 1;
585 DBG_ASSERT( aEndSel.nStartPos == aStartSel.nStartPos, "Search is not working" );
587 nLastPara = aStartSel.nStartPara;
593 if( ndbg < (nTextLen+2) )
595 *pPos++ = nLastPos + 1;
596 *pPara++ = nLastPara;
598 ndbg += 1;
599 pText++;
601 else
603 DBG_ERROR( "array overflow while searching" );
608 uno::Reference< text::XText > xFound;
609 ESelection aSel;
611 uno::Reference< text::XTextRange > xRangeRef( xText, uno::UNO_QUERY );
612 if( xRangeRef.is() )
613 aSel = GetSelection( xRangeRef );
615 sal_Int32 nStartPos;
616 sal_Int32 nEndPos = 0;
617 for( nStartPos = 0; nStartPos < nTextLen; nStartPos++ )
619 if( pConvertPara[nStartPos] == aSel.nStartPara && pConvertPos[nStartPos] == aSel.nStartPos )
620 break;
623 if( Search( aText, nStartPos, nEndPos, pDescr ) )
625 if( nStartPos <= nTextLen && nEndPos <= nTextLen )
627 ESelection aSelection( (USHORT)pConvertPara[nStartPos], (USHORT)pConvertPos[nStartPos],
628 (USHORT)pConvertPara[nEndPos], (USHORT)pConvertPos[nEndPos] );
629 SvxUnoTextRange *pRange;
631 SvxUnoTextBase* pParent = SvxUnoTextBase::getImplementation( xParent );
633 if(pParent)
635 pRange = new SvxUnoTextRange( *pParent );
636 xFound = (text::XText*)pRange;
637 pRange->SetSelection(aSelection);
639 // pDescr->SetStartPos( nEndPos );
642 else
644 DBG_ERROR("Array overflow while searching!");
648 delete[] pConvertPos;
649 delete[] pConvertPara;
651 return uno::Reference< text::XTextRange > ( xFound, uno::UNO_QUERY );
654 sal_Bool SdUnoSearchReplaceShape::Search( const OUString& rText, sal_Int32& nStartPos, sal_Int32& nEndPos, SdUnoSearchReplaceDescriptor* pDescr ) throw()
656 OUString aSearchStr( pDescr->getSearchString() );
657 OUString aText( rText );
659 if( !pDescr->IsCaseSensitive() )
661 aText.toAsciiLowerCase();
662 aSearchStr.toAsciiLowerCase();
665 sal_Int32 nFound = aText.indexOf( aSearchStr, nStartPos );
666 if( nFound != -1 )
668 nStartPos = nFound;
669 nEndPos = nFound + aSearchStr.getLength();
671 if(pDescr->IsWords())
673 if( (nStartPos > 0 && aText.getStr()[nStartPos-1] > ' ') ||
674 (nEndPos < aText.getLength() && aText.getStr()[nEndPos] > ' ') )
676 nStartPos++;
677 return Search( aText, nStartPos, nEndPos, pDescr );
681 return sal_True;
683 else
684 return sal_False;
687 ESelection SdUnoSearchReplaceShape::GetSelection( uno::Reference< text::XTextRange > xTextRange ) throw()
689 ESelection aSel;
690 SvxUnoTextRangeBase* pRange = SvxUnoTextRangeBase::getImplementation( xTextRange );
692 if(pRange)
693 aSel = pRange->GetSelection();
695 return aSel;
698 uno::Reference< drawing::XShape > SdUnoSearchReplaceShape::GetShape( uno::Reference< text::XTextRange > xTextRange ) throw()
700 uno::Reference< drawing::XShape > xShape;
702 if(xTextRange.is())
704 uno::Reference< text::XText > xText( xTextRange->getText() );
706 if(xText.is())
710 xText->queryInterface( ITYPE( drawing::XShape )) >>= xShape;
711 if(!xShape.is())
713 uno::Reference< text::XText > xParent( xText->getText() );
714 if(!xParent.is() || xText.get() == xParent.get())
715 return xShape;
717 xText = xParent;
719 } while( !xShape.is() );
723 return xShape;
726 /* ================================================================= */
727 /** this class holds the parameters and status of a search or replace
728 operation performed by class SdUnoSearchReplaceShape
731 UNO3_GETIMPLEMENTATION_IMPL( SdUnoSearchReplaceDescriptor );
733 SdUnoSearchReplaceDescriptor::SdUnoSearchReplaceDescriptor( sal_Bool bReplace ) throw()
735 mpPropSet = new SvxItemPropertySet(ImplGetSearchPropertyMap());
737 mbBackwards = sal_False;
738 mbCaseSensitive = sal_False;
739 mbWords = sal_False;
741 mbReplace = bReplace;
744 SdUnoSearchReplaceDescriptor::~SdUnoSearchReplaceDescriptor() throw()
746 delete mpPropSet;
749 // XSearchDescriptor
750 OUString SAL_CALL SdUnoSearchReplaceDescriptor::getSearchString()
751 throw(::com::sun::star::uno::RuntimeException)
753 return maSearchStr;
756 void SAL_CALL SdUnoSearchReplaceDescriptor::setSearchString( const OUString& aString )
757 throw(::com::sun::star::uno::RuntimeException)
759 maSearchStr = aString;
762 // XReplaceDescriptor
763 OUString SAL_CALL SdUnoSearchReplaceDescriptor::getReplaceString()
764 throw(::com::sun::star::uno::RuntimeException)
766 return maReplaceStr;
769 void SAL_CALL SdUnoSearchReplaceDescriptor::setReplaceString( const ::rtl::OUString& aReplaceString )
770 throw(::com::sun::star::uno::RuntimeException)
772 maReplaceStr = aReplaceString;
775 // XPropertySet
776 uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL SdUnoSearchReplaceDescriptor::getPropertySetInfo()
777 throw(::com::sun::star::uno::RuntimeException)
779 OGuard aGuard( Application::GetSolarMutex() );
780 return mpPropSet->getPropertySetInfo();
783 void SAL_CALL SdUnoSearchReplaceDescriptor::setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
784 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)
786 OGuard aGuard( Application::GetSolarMutex() );
788 const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(aPropertyName);
790 sal_Bool bOk = sal_False;
792 switch( pEntry ? pEntry->nWID : -1 )
794 case WID_SEARCH_BACKWARDS:
795 bOk = (aValue >>= mbBackwards);
796 break;
797 case WID_SEARCH_CASE:
798 bOk = (aValue >>= mbCaseSensitive);
799 break;
800 case WID_SEARCH_WORDS:
801 bOk = (aValue >>= mbWords);
802 break;
803 default:
804 throw beans::UnknownPropertyException();
807 if( !bOk )
808 throw lang::IllegalArgumentException();
811 uno::Any SAL_CALL SdUnoSearchReplaceDescriptor::getPropertyValue( const ::rtl::OUString& PropertyName )
812 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
814 OGuard aGuard( Application::GetSolarMutex() );
816 uno::Any aAny;
818 const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(PropertyName);
820 switch( pEntry ? pEntry->nWID : -1 )
822 case WID_SEARCH_BACKWARDS:
823 aAny <<= (sal_Bool)mbBackwards;
824 break;
825 case WID_SEARCH_CASE:
826 aAny <<= (sal_Bool)mbCaseSensitive;
827 break;
828 case WID_SEARCH_WORDS:
829 aAny <<= (sal_Bool)mbWords;
830 break;
831 default:
832 throw beans::UnknownPropertyException();
835 return aAny;
838 void SAL_CALL SdUnoSearchReplaceDescriptor::addPropertyChangeListener( const ::rtl::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) {}
839 void SAL_CALL SdUnoSearchReplaceDescriptor::removePropertyChangeListener( const ::rtl::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) {}
840 void SAL_CALL SdUnoSearchReplaceDescriptor::addVetoableChangeListener( const ::rtl::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) {}
841 void SAL_CALL SdUnoSearchReplaceDescriptor::removeVetoableChangeListener( const ::rtl::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) {}
844 /* ================================================================= */
846 SdUnoFindAllAccess::SdUnoFindAllAccess( uno::Sequence< uno::Reference< uno::XInterface > >& rSequence ) throw()
847 :maSequence( rSequence )
851 SdUnoFindAllAccess::~SdUnoFindAllAccess() throw()
855 // XElementAccess
856 uno::Type SAL_CALL SdUnoFindAllAccess::getElementType()
857 throw(::com::sun::star::uno::RuntimeException)
859 return ITYPE( text::XTextRange );
862 sal_Bool SAL_CALL SdUnoFindAllAccess::hasElements()
863 throw(::com::sun::star::uno::RuntimeException)
865 return maSequence.getLength() > 0;
868 // XIndexAccess
869 sal_Int32 SAL_CALL SdUnoFindAllAccess::getCount()
870 throw(::com::sun::star::uno::RuntimeException)
872 return maSequence.getLength();
875 uno::Any SAL_CALL SdUnoFindAllAccess::getByIndex( sal_Int32 Index )
876 throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
878 uno::Any aAny;
880 if( Index < 0 || Index >= getCount() )
881 throw lang::IndexOutOfBoundsException();
883 const uno::Reference< uno::XInterface > *pRefs = maSequence.getConstArray();
884 if(pRefs)
885 aAny <<= pRefs[ Index ];
886 return aAny;