xref: /trunk/main/sw/source/core/unocore/unosrch.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sw.hxx"
30 
31 #include "unosrch.hxx"
32 #include <doc.hxx>
33 #include <hints.hxx>
34 #include <unomap.hxx>
35 #include <unobaseclass.hxx>
36 #include <unomid.h>
37 
38 #include <vos/mutex.hxx>
39 #include <vcl/svapp.hxx>
40 #include "editeng/unolingu.hxx"
41 #include <com/sun/star/util/SearchOptions.hpp>
42 #include <com/sun/star/util/SearchFlags.hpp>
43 #include <com/sun/star/i18n/TransliterationModules.hpp>
44 #include <com/sun/star/beans/PropertyAttribute.hpp>
45 
46 using namespace ::com::sun::star;
47 using ::rtl::OUString;
48 
49 /******************************************************************************
50  *
51  ******************************************************************************/
52 
53 /* -----------------23.06.99 12:19-------------------
54 
55  --------------------------------------------------*/
56 class SwSearchProperties_Impl
57 {
58     beans::PropertyValue**          pValueArr; //
59     sal_uInt32                      nArrLen;
60     const PropertyEntryVector_t     aPropertyEntries;
61 public:
62     SwSearchProperties_Impl();
63     ~SwSearchProperties_Impl();
64 
65     void    SetProperties(const uno::Sequence< beans::PropertyValue >& aSearchAttribs)
66         throw( beans::UnknownPropertyException, lang::IllegalArgumentException, uno::RuntimeException );
67     const uno::Sequence< beans::PropertyValue > GetProperties() const;
68 
69     void    FillItemSet(SfxItemSet& rSet, sal_Bool bIsValueSearch) const;
70     sal_Bool    HasAttributes() const;
71 };
72 /* -----------------23.06.99 13:08-------------------
73 
74  --------------------------------------------------*/
75 SwSearchProperties_Impl::SwSearchProperties_Impl() :
76     nArrLen(0),
77     aPropertyEntries( aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)->getPropertyMap()->getPropertyEntries())
78 {
79     nArrLen = aPropertyEntries.size();
80     pValueArr = new beans::PropertyValue*[nArrLen];
81     for(sal_uInt32 i = 0; i < nArrLen; i++)
82         pValueArr[i] = 0;
83 }
84 /* -----------------23.06.99 13:08-------------------
85 
86  --------------------------------------------------*/
87 SwSearchProperties_Impl::~SwSearchProperties_Impl()
88 {
89     for(sal_uInt32 i = 0; i < nArrLen; i++)
90         delete pValueArr[i];
91     delete[] pValueArr;
92 }
93 /* -----------------23.06.99 13:09-------------------
94 
95  --------------------------------------------------*/
96 void    SwSearchProperties_Impl::SetProperties(const uno::Sequence< beans::PropertyValue >& aSearchAttribs)
97                 throw( beans::UnknownPropertyException, lang::IllegalArgumentException, uno::RuntimeException )
98 {
99     const beans::PropertyValue* pProps = aSearchAttribs.getConstArray();
100     sal_uInt32 i;
101 
102     //delete all existing values
103     for( i = 0; i < nArrLen; i++)
104     {
105         delete pValueArr[i];
106         pValueArr[i] = 0;
107     }
108 
109     sal_uInt32 nLen = aSearchAttribs.getLength();
110     for(i = 0; i < nLen; i++)
111     {
112         sal_uInt16 nIndex = 0;
113         PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
114         while(pProps[i].Name != aIt->sName)
115         {
116             ++aIt;
117             nIndex++;
118             if( aIt == aPropertyEntries.end() )
119                 throw beans::UnknownPropertyException();
120         }
121         pValueArr[nIndex] = new beans::PropertyValue(pProps[i]);
122     }
123 }
124 /* -----------------23.06.99 13:08-------------------
125 
126  --------------------------------------------------*/
127 const uno::Sequence< beans::PropertyValue > SwSearchProperties_Impl::GetProperties() const
128 {
129     sal_uInt32 nPropCount = 0;
130     sal_uInt32 i;
131     for( i = 0; i < nArrLen; i++)
132         if(pValueArr[i])
133             nPropCount++;
134 
135     uno::Sequence< beans::PropertyValue > aRet(nPropCount);
136     beans::PropertyValue* pProps = aRet.getArray();
137     nPropCount = 0;
138     for(i = 0; i < nArrLen; i++)
139     {
140         if(pValueArr[i])
141         {
142             pProps[nPropCount++] = *(pValueArr[i]);
143         }
144     }
145     return aRet;
146 }
147 /* -----------------23.06.99 13:06-------------------
148 
149  --------------------------------------------------*/
150 void SwSearchProperties_Impl::FillItemSet(SfxItemSet& rSet, sal_Bool bIsValueSearch) const
151 {
152     //
153 
154     SfxPoolItem* pBoxItem = 0,
155     *pBreakItem = 0,
156     *pAutoKernItem  = 0,
157     *pWLineItem   = 0,
158     *pTabItem  = 0,
159     *pSplitItem  = 0,
160     *pRegItem  = 0,
161     *pLineSpaceItem  = 0,
162     *pLineNumItem  = 0,
163     *pKeepItem  = 0,
164     *pLRItem  = 0,
165     *pULItem  = 0,
166     *pBackItem  = 0,
167     *pAdjItem  = 0,
168     *pDescItem  = 0,
169     *pInetItem  = 0,
170     *pDropItem  = 0,
171     *pWeightItem  = 0,
172     *pULineItem  = 0,
173     *pOLineItem  = 0,
174     *pCharFmtItem  = 0,
175     *pShadItem  = 0,
176     *pPostItem  = 0,
177     *pNHyphItem  = 0,
178     *pLangItem  = 0,
179     *pKernItem  = 0,
180     *pFontSizeItem  = 0,
181     *pFontItem  = 0,
182     *pBlinkItem  = 0,
183     *pEscItem  = 0,
184     *pCrossedOutItem  = 0,
185     *pContourItem  = 0,
186     *pCharColorItem  = 0,
187     *pCasemapItem  = 0,
188     *pBrushItem  = 0,
189     *pFontCJKItem = 0,
190     *pFontSizeCJKItem = 0,
191     *pCJKLangItem = 0,
192     *pCJKPostureItem = 0,
193     *pCJKWeightItem = 0,
194     *pFontCTLItem = 0,
195     *pFontSizeCTLItem = 0,
196     *pCTLLangItem = 0,
197     *pCTLPostureItem = 0,
198     *pCTLWeightItem = 0;
199 
200     PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
201     for(sal_uInt32 i = 0; i < nArrLen; i++, ++aIt)
202     {
203         if(pValueArr[i])
204         {
205             SfxPoolItem* pTempItem = 0;
206             switch(aIt->nWID)
207             {
208                 case  RES_BOX:
209                     if(!pBoxItem)
210                         pBoxItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
211                     pTempItem = pBoxItem;
212                 break;
213                 case  RES_BREAK:
214                     if(!pBreakItem)
215                         pBreakItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
216                     pTempItem = pBreakItem;
217                 break;
218                 case  RES_CHRATR_AUTOKERN:
219                     if(!pAutoKernItem)
220                         pAutoKernItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
221                     pTempItem = pAutoKernItem;
222                     break;
223                 case  RES_CHRATR_BACKGROUND:
224                     if(!pBrushItem)
225                         pBrushItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
226                     pTempItem = pBrushItem;
227                 break;
228                 case  RES_CHRATR_CASEMAP:
229                     if(!pCasemapItem)
230                         pCasemapItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
231                     pTempItem = pCasemapItem;
232                 break;
233                 case  RES_CHRATR_COLOR:
234                     if(!pCharColorItem)
235                         pCharColorItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
236                     pTempItem = pCharColorItem;
237                 break;
238                 case  RES_CHRATR_CONTOUR:
239                     if(!pContourItem)
240                         pContourItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
241                     pTempItem = pContourItem;
242                 break;
243                 case  RES_CHRATR_CROSSEDOUT:
244                     if(!pCrossedOutItem)
245                         pCrossedOutItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
246                     pTempItem = pCrossedOutItem;
247                 break;
248                 case  RES_CHRATR_ESCAPEMENT:
249                     if(!pEscItem)
250                         pEscItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
251                     pTempItem = pEscItem;
252                 break;
253                 case  RES_CHRATR_BLINK:
254                     if(!pBlinkItem)
255                         pBlinkItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
256                     pTempItem = pBlinkItem;
257                 break;
258                 case  RES_CHRATR_FONT:
259                     if(!pFontItem)
260                         pFontItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
261                     pTempItem = pFontItem;
262                 break;
263                 case  RES_CHRATR_FONTSIZE:
264                     if(!pFontSizeItem)
265                         pFontSizeItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
266                     pTempItem = pFontSizeItem;
267                 break;
268                 case  RES_CHRATR_KERNING:
269                     if(!pKernItem)
270                         pKernItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
271                     pTempItem = pKernItem;
272                 break;
273                 case  RES_CHRATR_LANGUAGE:
274                     if(!pLangItem)
275                         pLangItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
276                     pTempItem = pLangItem;
277                 break;
278                 case  RES_CHRATR_NOHYPHEN:
279                     if(!pNHyphItem)
280                         pNHyphItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
281                     pTempItem = pNHyphItem;
282                 break;
283                 case  RES_CHRATR_POSTURE:
284                     if(!pPostItem)
285                         pPostItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
286                     pTempItem = pPostItem;
287                 break;
288                 case  RES_CHRATR_SHADOWED:
289                     if(!pShadItem)
290                         pShadItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
291                     pTempItem = pShadItem;
292                 break;
293                 case  RES_TXTATR_CHARFMT:
294                     if(!pCharFmtItem)
295                         pCharFmtItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
296                     pTempItem = pCharFmtItem;
297                 break;
298                 case  RES_CHRATR_UNDERLINE:
299                     if(!pULineItem)
300                         pULineItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
301                     pTempItem = pULineItem;
302                 break;
303                 case  RES_CHRATR_OVERLINE:
304                     if(!pOLineItem)
305                         pOLineItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
306                     pTempItem = pOLineItem;
307                 break;
308                 case  RES_CHRATR_WEIGHT:
309                     if(!pWeightItem)
310                         pWeightItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
311                     pTempItem = pWeightItem;
312                 break;
313                 case  RES_PARATR_DROP:
314                     if(!pDropItem)
315                         pDropItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
316                     pTempItem = pDropItem;
317                 break;
318                 case  RES_TXTATR_INETFMT:
319                     if(!pInetItem)
320                         pInetItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
321                     pTempItem = pInetItem;
322                 break;
323                 case  RES_PAGEDESC:
324                     if(!pDescItem)
325                         pDescItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
326                     pTempItem = pDescItem;
327                 break;
328                 case  RES_PARATR_ADJUST:
329                     if(!pAdjItem)
330                         pAdjItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
331                     pTempItem = pAdjItem;
332                 break;
333                 case  RES_BACKGROUND:
334                     if(!pBackItem)
335                         pBackItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
336                     pTempItem = pBackItem;
337                 break;
338                 case  RES_UL_SPACE:
339                     if(!pULItem)
340                         pULItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
341                     pTempItem = pULItem;
342                 break;
343                 case  RES_LR_SPACE:
344                     if(!pLRItem)
345                         pLRItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
346                     pTempItem = pLRItem;
347                 break;
348                 case  RES_KEEP:
349                     if(!pKeepItem)
350                         pKeepItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
351                     pTempItem = pKeepItem;
352                 break;
353                 case  RES_LINENUMBER:
354                     if(!pLineNumItem)
355                         pLineNumItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
356                     pTempItem = pLineNumItem;
357                 break;
358                 case  RES_PARATR_LINESPACING:
359                     if(!pLineSpaceItem)
360                         pLineSpaceItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
361                     pTempItem = pLineSpaceItem;
362                 break;
363                 case  RES_PARATR_REGISTER:
364                     if(!pRegItem)
365                         pRegItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
366                     pTempItem = pRegItem;
367                 break;
368                 case  RES_PARATR_SPLIT:
369                     if(!pSplitItem)
370                         pSplitItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
371                     pTempItem = pSplitItem;
372                 break;
373                 case  RES_PARATR_TABSTOP:
374                     if(!pTabItem)
375                         pTabItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
376                     pTempItem = pTabItem;
377                 break;
378                 case  RES_CHRATR_WORDLINEMODE:
379                     if(!pWLineItem)
380                         pWLineItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
381                     pTempItem = pWLineItem;
382                 break;
383                 case RES_CHRATR_CJK_FONT:
384                     if(!pFontCJKItem )
385                         pFontCJKItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
386                     pTempItem = pFontCJKItem;
387                 break;
388                 case RES_CHRATR_CJK_FONTSIZE:
389                     if(!pFontSizeCJKItem )
390                         pFontSizeCJKItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
391                     pTempItem = pFontSizeCJKItem;
392                 break;
393                 case RES_CHRATR_CJK_LANGUAGE:
394                     if(!pCJKLangItem )
395                         pCJKLangItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
396                     pTempItem = pCJKLangItem;
397                 break;
398                 case RES_CHRATR_CJK_POSTURE:
399                     if(!pCJKPostureItem )
400                         pCJKPostureItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
401                     pTempItem = pCJKPostureItem;
402                 break;
403                 case RES_CHRATR_CJK_WEIGHT:
404                     if(!pCJKWeightItem )
405                         pCJKWeightItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
406                     pTempItem = pCJKWeightItem;
407                 break;
408                 case RES_CHRATR_CTL_FONT:
409                     if(!pFontCTLItem )
410                         pFontCTLItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
411                     pTempItem = pFontCTLItem;
412                 break;
413                 case RES_CHRATR_CTL_FONTSIZE:
414                     if(!pFontSizeCTLItem )
415                         pFontSizeCTLItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
416                     pTempItem = pFontSizeCTLItem;
417                 break;
418                 case RES_CHRATR_CTL_LANGUAGE:
419                     if(!pCTLLangItem )
420                         pCTLLangItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
421                     pTempItem = pCTLLangItem;
422                 break;
423                 case RES_CHRATR_CTL_POSTURE:
424                     if(!pCTLPostureItem )
425                         pCTLPostureItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
426                     pTempItem = pCTLPostureItem;
427                 break;
428                 case RES_CHRATR_CTL_WEIGHT:
429                     if(!pCTLWeightItem )
430                         pCTLWeightItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
431                     pTempItem = pCTLWeightItem;
432                 break;
433             }
434             if(pTempItem)
435             {
436                 if(bIsValueSearch)
437                 {
438                     pTempItem->PutValue(pValueArr[i]->Value, aIt->nMemberId);
439                     rSet.Put(*pTempItem);
440                 }
441                 else
442                     rSet.InvalidateItem( pTempItem->Which() );
443             }
444         }
445     }
446     delete pBoxItem;
447     delete pBreakItem;
448     delete pBreakItem ;
449     delete pAutoKernItem ;
450     delete pWLineItem;
451     delete pTabItem;
452     delete pSplitItem;
453     delete pRegItem;
454     delete pLineSpaceItem ;
455     delete pLineNumItem  ;
456     delete pKeepItem;
457     delete pLRItem  ;
458     delete pULItem  ;
459     delete pBackItem;
460     delete pAdjItem;
461     delete pDescItem;
462     delete pInetItem;
463     delete pDropItem;
464     delete pWeightItem;
465     delete pULineItem;
466     delete pOLineItem;
467     delete pCharFmtItem  ;
468     delete pShadItem;
469     delete pPostItem;
470     delete pNHyphItem;
471     delete pLangItem;
472     delete pKernItem;
473     delete pFontSizeItem ;
474     delete pFontItem;
475     delete pBlinkItem;
476     delete pEscItem;
477     delete pCrossedOutItem;
478     delete pContourItem  ;
479     delete pCharColorItem;
480     delete pCasemapItem  ;
481     delete pBrushItem  ;
482 }
483 /* -----------------23.06.99 14:18-------------------
484 
485  --------------------------------------------------*/
486 sal_Bool    SwSearchProperties_Impl::HasAttributes() const
487 {
488     for(sal_uInt32 i = 0; i < nArrLen; i++)
489         if(pValueArr[i])
490             return sal_True;
491     return sal_False;
492 }
493 
494 /*-- 14.12.98 13:07:10    ---------------------------------------------------
495 
496   -----------------------------------------------------------------------*/
497 SwXTextSearch::SwXTextSearch() :
498     pSearchProperties( new SwSearchProperties_Impl),
499     pReplaceProperties( new SwSearchProperties_Impl),
500     m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_SEARCH)),
501     bAll(sal_False),
502     bWord(sal_False),
503     bBack(sal_False),
504     bExpr(sal_False),
505     bCase(sal_False),
506     bStyles(sal_False),
507     bSimilarity(sal_False),
508     bLevRelax(sal_False),
509     nLevExchange(2),
510     nLevAdd(2),
511     nLevRemove(2),
512     bIsValueSearch(sal_True)
513 {
514 }
515 /*-- 14.12.98 13:07:12    ---------------------------------------------------
516 
517   -----------------------------------------------------------------------*/
518 SwXTextSearch::~SwXTextSearch()
519 {
520     delete pSearchProperties;
521     delete pReplaceProperties;
522 }
523 /* -----------------------------10.03.00 18:02--------------------------------
524 
525  ---------------------------------------------------------------------------*/
526 const uno::Sequence< sal_Int8 > & SwXTextSearch::getUnoTunnelId()
527 {
528     static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
529     return aSeq;
530 }
531 /* -----------------------------10.03.00 18:04--------------------------------
532 
533  ---------------------------------------------------------------------------*/
534 sal_Int64 SAL_CALL SwXTextSearch::getSomething( const uno::Sequence< sal_Int8 >& rId )
535     throw(uno::RuntimeException)
536 {
537     if( rId.getLength() == 16
538         && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
539                                         rId.getConstArray(), 16 ) )
540     {
541         return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
542     }
543     return 0;
544 }
545 /*-- 14.12.98 13:07:12---------------------------------------------------
546 
547   -----------------------------------------------------------------------*/
548 OUString SwXTextSearch::getSearchString(void) throw( uno::RuntimeException )
549 {
550     vos::OGuard aGuard(Application::GetSolarMutex());
551     return sSearchText;
552 }
553 /*-- 14.12.98 13:07:12---------------------------------------------------
554 
555   -----------------------------------------------------------------------*/
556 void SwXTextSearch::setSearchString(const OUString& rString)
557                                         throw( uno::RuntimeException )
558 {
559     vos::OGuard aGuard(Application::GetSolarMutex());
560     sSearchText = String(rString);
561 }
562 /*-- 14.12.98 13:07:12---------------------------------------------------
563 
564   -----------------------------------------------------------------------*/
565 OUString SwXTextSearch::getReplaceString(void) throw( uno::RuntimeException )
566 {
567     vos::OGuard aGuard(Application::GetSolarMutex());
568     return sReplaceText;
569 }
570 /*-- 14.12.98 13:07:12---------------------------------------------------
571 
572   -----------------------------------------------------------------------*/
573 void SwXTextSearch::setReplaceString(const OUString& rReplaceString) throw( uno::RuntimeException )
574 {
575     vos::OGuard aGuard(Application::GetSolarMutex());
576     sReplaceText = String(rReplaceString);
577 }
578 /*-- 14.12.98 13:07:13---------------------------------------------------
579 
580   -----------------------------------------------------------------------*/
581 uno::Reference< beans::XPropertySetInfo >  SwXTextSearch::getPropertySetInfo(void) throw( uno::RuntimeException )
582 {
583     static uno::Reference< beans::XPropertySetInfo >  aRef = m_pPropSet->getPropertySetInfo();
584     return aRef;
585 }
586 /*-- 14.12.98 13:07:13---------------------------------------------------
587 
588   -----------------------------------------------------------------------*/
589 void SwXTextSearch::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
590     throw( beans::UnknownPropertyException, beans::PropertyVetoException,
591         lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException )
592 {
593     vos::OGuard aGuard(Application::GetSolarMutex());
594     const SfxItemPropertySimpleEntry*  pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName);
595     if(pEntry)
596     {
597         if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
598             throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
599         sal_Bool bVal = sal_False;
600         if(aValue.getValueType() == ::getBooleanCppuType())
601             bVal = *(sal_Bool*)aValue.getValue();
602         switch(pEntry->nWID)
603         {
604             case WID_SEARCH_ALL :           bAll        = bVal; break;
605             case WID_WORDS:                 bWord       = bVal; break;
606             case WID_BACKWARDS :            bBack       = bVal; break;
607             case WID_REGULAR_EXPRESSION :   bExpr       = bVal; break;
608             case WID_CASE_SENSITIVE  :      bCase       = bVal; break;
609             //case WID_IN_SELECTION  :      bInSel      = bVal; break;
610             case WID_STYLES          :      bStyles     = bVal; break;
611             case WID_SIMILARITY      :      bSimilarity = bVal; break;
612             case WID_SIMILARITY_RELAX:      bLevRelax   = bVal; break;
613             case WID_SIMILARITY_EXCHANGE:   aValue >>= nLevExchange; break;
614             case WID_SIMILARITY_ADD:        aValue >>= nLevAdd; break;
615             case WID_SIMILARITY_REMOVE :    aValue >>= nLevRemove;break;
616         };
617     }
618     else
619         throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
620 }
621 /*-- 14.12.98 13:07:13---------------------------------------------------
622 
623   -----------------------------------------------------------------------*/
624 uno::Any SwXTextSearch::getPropertyValue(const OUString& rPropertyName) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
625 {
626     vos::OGuard aGuard(Application::GetSolarMutex());
627     uno::Any aRet;
628 
629     const SfxItemPropertySimpleEntry*  pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName);
630     sal_Bool bSet = sal_False;
631     sal_Int16 nSet = 0;
632     if(pEntry)
633     {
634         switch(pEntry->nWID)
635         {
636             case WID_SEARCH_ALL :           bSet = bAll; goto SET_BOOL;
637             case WID_WORDS:                 bSet = bWord; goto SET_BOOL;
638             case WID_BACKWARDS :            bSet = bBack; goto SET_BOOL;
639             case WID_REGULAR_EXPRESSION :   bSet = bExpr; goto SET_BOOL;
640             case WID_CASE_SENSITIVE  :      bSet = bCase; goto SET_BOOL;
641             //case WID_IN_SELECTION  :      bSet = bInSel; goto SET_BOOL;
642             case WID_STYLES          :      bSet = bStyles; goto SET_BOOL;
643             case WID_SIMILARITY      :      bSet = bSimilarity; goto SET_BOOL;
644             case WID_SIMILARITY_RELAX:      bSet = bLevRelax;
645 SET_BOOL:
646             aRet.setValue(&bSet, ::getBooleanCppuType());
647             break;
648             case WID_SIMILARITY_EXCHANGE:   nSet = nLevExchange; goto SET_UINT16;
649             case WID_SIMILARITY_ADD:        nSet = nLevAdd; goto SET_UINT16;
650             case WID_SIMILARITY_REMOVE :    nSet = nLevRemove;
651 SET_UINT16:
652             aRet <<= nSet;
653             break;
654         };
655     }
656     else
657         throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
658     return aRet;
659 }
660 /*-- 14.12.98 13:07:13---------------------------------------------------
661 
662   -----------------------------------------------------------------------*/
663 void SwXTextSearch::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
664 {
665     DBG_WARNING("not implemented");
666 }
667 /*-- 14.12.98 13:07:13---------------------------------------------------
668 
669   -----------------------------------------------------------------------*/
670 void SwXTextSearch::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw(beans::UnknownPropertyException, lang::WrappedTargetException,uno::RuntimeException )
671 {
672     DBG_WARNING("not implemented");
673 }
674 /*-- 14.12.98 13:07:14---------------------------------------------------
675 
676   -----------------------------------------------------------------------*/
677 void SwXTextSearch::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw(beans::UnknownPropertyException, lang::WrappedTargetException,uno::RuntimeException )
678 {
679     DBG_WARNING("not implemented");
680 }
681 /*-- 14.12.98 13:07:14---------------------------------------------------
682 
683   -----------------------------------------------------------------------*/
684 void SwXTextSearch::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw(beans::UnknownPropertyException, lang::WrappedTargetException,uno::RuntimeException )
685 {
686     DBG_WARNING("not implemented");
687 }
688 /*-- 14.12.98 13:07:14---------------------------------------------------
689 
690   -----------------------------------------------------------------------*/
691 sal_Bool SwXTextSearch::getValueSearch(void) throw( uno::RuntimeException )
692 {
693     vos::OGuard aGuard(Application::GetSolarMutex());
694     return bIsValueSearch;
695 }
696 /*-- 14.12.98 13:07:15---------------------------------------------------
697 
698   -----------------------------------------------------------------------*/
699 void SwXTextSearch::setValueSearch(sal_Bool ValueSearch_) throw( uno::RuntimeException )
700 {
701     vos::OGuard aGuard(Application::GetSolarMutex());
702     bIsValueSearch = ValueSearch_;
703 }
704 /*-- 14.12.98 13:07:15---------------------------------------------------
705 
706   -----------------------------------------------------------------------*/
707 uno::Sequence< beans::PropertyValue > SwXTextSearch::getSearchAttributes(void) throw( uno::RuntimeException )
708 {
709     return  pSearchProperties->GetProperties();
710 }
711 /*-- 14.12.98 13:07:16---------------------------------------------------
712 
713   -----------------------------------------------------------------------*/
714 void SwXTextSearch::setSearchAttributes(const uno::Sequence< beans::PropertyValue >& rSearchAttribs)
715     throw( beans::UnknownPropertyException, lang::IllegalArgumentException, uno::RuntimeException )
716 {
717     pSearchProperties->SetProperties(rSearchAttribs);
718 }
719 /*-- 14.12.98 13:07:16---------------------------------------------------
720 
721   -----------------------------------------------------------------------*/
722 uno::Sequence< beans::PropertyValue > SwXTextSearch::getReplaceAttributes(void)
723     throw( uno::RuntimeException )
724 {
725     return pReplaceProperties->GetProperties();
726 }
727 /*-- 14.12.98 13:07:17---------------------------------------------------
728 
729   -----------------------------------------------------------------------*/
730 void SwXTextSearch::setReplaceAttributes(const uno::Sequence< beans::PropertyValue >& rReplaceAttribs)
731     throw( beans::UnknownPropertyException, lang::IllegalArgumentException, uno::RuntimeException )
732 {
733     pReplaceProperties->SetProperties(rReplaceAttribs);
734 }
735 /* -----------------23.06.99 14:13-------------------
736 
737  --------------------------------------------------*/
738 void    SwXTextSearch::FillSearchItemSet(SfxItemSet& rSet) const
739 {
740     pSearchProperties->FillItemSet(rSet, bIsValueSearch);
741 }
742 /* -----------------23.06.99 14:14-------------------
743 
744  --------------------------------------------------*/
745 void    SwXTextSearch::FillReplaceItemSet(SfxItemSet& rSet) const
746 {
747     pReplaceProperties->FillItemSet(rSet, bIsValueSearch);
748 }
749 /* -----------------23.06.99 14:17-------------------
750 
751  --------------------------------------------------*/
752 sal_Bool    SwXTextSearch::HasSearchAttributes() const
753 {
754     return pSearchProperties->HasAttributes();
755 }
756 /* -----------------23.06.99 14:17-------------------
757 
758  --------------------------------------------------*/
759 sal_Bool    SwXTextSearch::HasReplaceAttributes() const
760 {
761     return pReplaceProperties->HasAttributes();
762 }
763 /* -----------------------------19.04.00 14:43--------------------------------
764 
765  ---------------------------------------------------------------------------*/
766 OUString SwXTextSearch::getImplementationName(void) throw( uno::RuntimeException )
767 {
768     return C2U("SwXTextSearch");
769 }
770 /* -----------------------------19.04.00 14:43--------------------------------
771 
772  ---------------------------------------------------------------------------*/
773 sal_Bool SwXTextSearch::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
774 {
775     return C2U("com.sun.star.util.SearchDescriptor") == rServiceName ||
776             C2U("com.sun.star.util.ReplaceDescriptor") == rServiceName;
777 }
778 /* -----------------------------19.04.00 14:43--------------------------------
779 
780  ---------------------------------------------------------------------------*/
781 uno::Sequence< OUString > SwXTextSearch::getSupportedServiceNames(void) throw( uno::RuntimeException )
782 {
783     uno::Sequence< OUString > aRet(2);
784     OUString* pArray = aRet.getArray();
785     pArray[0] = C2U("com.sun.star.util.SearchDescriptor");
786     pArray[1] = C2U("com.sun.star.util.ReplaceDescriptor");
787     return aRet;
788 }
789 
790 void SwXTextSearch::FillSearchOptions( util::SearchOptions& rSearchOpt ) const
791 {
792     if( bSimilarity )
793     {
794         rSearchOpt.algorithmType = util::SearchAlgorithms_APPROXIMATE;
795         rSearchOpt.changedChars = nLevExchange;
796         rSearchOpt.deletedChars = nLevRemove;
797         rSearchOpt.insertedChars = nLevAdd;
798         if( bLevRelax )
799             rSearchOpt.searchFlag |= util::SearchFlags::LEV_RELAXED;
800     }
801     else if( bExpr )
802         rSearchOpt.algorithmType = util::SearchAlgorithms_REGEXP;
803     else
804         rSearchOpt.algorithmType = util::SearchAlgorithms_ABSOLUTE;
805 
806     rSearchOpt.Locale = SvxCreateLocale( GetAppLanguage() );
807     rSearchOpt.searchString = sSearchText;
808     rSearchOpt.replaceString = sReplaceText;
809 
810     if( !bCase )
811         rSearchOpt.transliterateFlags |= i18n::TransliterationModules_IGNORE_CASE;
812     if( bWord )
813         rSearchOpt.searchFlag |= util::SearchFlags::NORM_WORD_ONLY;
814 
815 //  bInSel: 1;  // wie geht das?
816 //  TODO: pSearch->bStyles!
817 //      inSelection??
818 //      aSrchParam.SetSrchInSelection(TypeConversion::toBOOL(aVal));
819 }
820 
821 
822 
823