update dev300-m58
[ooovba.git] / sw / source / core / unocore / unosrch.cxx
blob8ee8e3e1412bd2883c8a63c237124950898c23bf
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.19.210.1 $
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_sw.hxx"
33 #include "unosrch.hxx"
36 #include <doc.hxx>
37 #include <hints.hxx>
38 #include <unomap.hxx>
39 #include <unoobj.hxx>
40 #include <vos/mutex.hxx>
41 #include <vcl/svapp.hxx>
42 #include "svx/unolingu.hxx"
43 #include <com/sun/star/util/SearchOptions.hpp>
44 #include <com/sun/star/util/SearchFlags.hpp>
45 #include <com/sun/star/i18n/TransliterationModules.hpp>
46 #include <com/sun/star/beans/PropertyAttribute.hpp>
48 using namespace ::com::sun::star;
49 using ::rtl::OUString;
51 /******************************************************************************
53 ******************************************************************************/
55 /* -----------------23.06.99 12:19-------------------
57 --------------------------------------------------*/
58 class SwSearchProperties_Impl
60 beans::PropertyValue** pValueArr; //
61 sal_uInt32 nArrLen;
62 const PropertyEntryVector_t aPropertyEntries;
63 public:
64 SwSearchProperties_Impl();
65 ~SwSearchProperties_Impl();
67 void SetProperties(const uno::Sequence< beans::PropertyValue >& aSearchAttribs)
68 throw( beans::UnknownPropertyException, lang::IllegalArgumentException, uno::RuntimeException );
69 const uno::Sequence< beans::PropertyValue > GetProperties() const;
71 void FillItemSet(SfxItemSet& rSet, sal_Bool bIsValueSearch) const;
72 sal_Bool HasAttributes() const;
74 /* -----------------23.06.99 13:08-------------------
76 --------------------------------------------------*/
77 SwSearchProperties_Impl::SwSearchProperties_Impl() :
78 nArrLen(0),
79 aPropertyEntries( aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)->getPropertyMap()->getPropertyEntries())
81 nArrLen = aPropertyEntries.size();
82 pValueArr = new beans::PropertyValue*[nArrLen];
83 for(sal_uInt32 i = 0; i < nArrLen; i++)
84 pValueArr[i] = 0;
86 /* -----------------23.06.99 13:08-------------------
88 --------------------------------------------------*/
89 SwSearchProperties_Impl::~SwSearchProperties_Impl()
91 for(sal_uInt32 i = 0; i < nArrLen; i++)
92 delete pValueArr[i];
93 delete[] pValueArr;
95 /* -----------------23.06.99 13:09-------------------
97 --------------------------------------------------*/
98 void SwSearchProperties_Impl::SetProperties(const uno::Sequence< beans::PropertyValue >& aSearchAttribs)
99 throw( beans::UnknownPropertyException, lang::IllegalArgumentException, uno::RuntimeException )
101 const beans::PropertyValue* pProps = aSearchAttribs.getConstArray();
102 sal_uInt32 i;
104 //delete all existing values
105 for( i = 0; i < nArrLen; i++)
107 delete pValueArr[i];
108 pValueArr[i] = 0;
111 sal_uInt32 nLen = aSearchAttribs.getLength();
112 for(i = 0; i < nLen; i++)
114 sal_uInt16 nIndex = 0;
115 PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
116 while(pProps[i].Name != aIt->sName)
118 ++aIt;
119 nIndex++;
120 if( aIt == aPropertyEntries.end() )
121 throw beans::UnknownPropertyException();
123 pValueArr[nIndex] = new beans::PropertyValue(pProps[i]);
126 /* -----------------23.06.99 13:08-------------------
128 --------------------------------------------------*/
129 const uno::Sequence< beans::PropertyValue > SwSearchProperties_Impl::GetProperties() const
131 sal_uInt32 nPropCount = 0;
132 sal_uInt32 i;
133 for( i = 0; i < nArrLen; i++)
134 if(pValueArr[i])
135 nPropCount++;
137 uno::Sequence< beans::PropertyValue > aRet(nPropCount);
138 beans::PropertyValue* pProps = aRet.getArray();
139 nPropCount = 0;
140 for(i = 0; i < nArrLen; i++)
142 if(pValueArr[i])
144 pProps[nPropCount++] = *(pValueArr[i]);
147 return aRet;
149 /* -----------------23.06.99 13:06-------------------
151 --------------------------------------------------*/
152 void SwSearchProperties_Impl::FillItemSet(SfxItemSet& rSet, sal_Bool bIsValueSearch) const
156 SfxPoolItem* pBoxItem = 0,
157 *pBreakItem = 0,
158 *pAutoKernItem = 0,
159 *pWLineItem = 0,
160 *pTabItem = 0,
161 *pSplitItem = 0,
162 *pRegItem = 0,
163 *pLineSpaceItem = 0,
164 *pLineNumItem = 0,
165 *pKeepItem = 0,
166 *pLRItem = 0,
167 *pULItem = 0,
168 *pBackItem = 0,
169 *pAdjItem = 0,
170 *pDescItem = 0,
171 *pInetItem = 0,
172 *pDropItem = 0,
173 *pWeightItem = 0,
174 *pULineItem = 0,
175 *pOLineItem = 0,
176 *pCharFmtItem = 0,
177 *pShadItem = 0,
178 *pPostItem = 0,
179 *pNHyphItem = 0,
180 *pLangItem = 0,
181 *pKernItem = 0,
182 *pFontSizeItem = 0,
183 *pFontItem = 0,
184 *pBlinkItem = 0,
185 *pEscItem = 0,
186 *pCrossedOutItem = 0,
187 *pContourItem = 0,
188 *pCharColorItem = 0,
189 *pCasemapItem = 0,
190 *pBrushItem = 0;
192 PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
193 for(sal_uInt32 i = 0; i < nArrLen; i++, ++aIt)
195 if(pValueArr[i])
197 SfxPoolItem* pTempItem = 0;
198 switch(aIt->nWID)
200 case RES_BOX:
201 if(!pBoxItem)
202 pBoxItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
203 pTempItem = pBoxItem;
204 break;
205 case RES_BREAK:
206 if(!pBreakItem)
207 pBreakItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
208 pTempItem = pBreakItem;
209 break;
210 case RES_CHRATR_AUTOKERN:
211 if(!pAutoKernItem)
212 pAutoKernItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
213 pTempItem = pAutoKernItem;
214 break;
215 case RES_CHRATR_BACKGROUND:
216 if(!pBrushItem)
217 pBrushItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
218 pTempItem = pBrushItem;
219 break;
220 case RES_CHRATR_CASEMAP:
221 if(!pCasemapItem)
222 pCasemapItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
223 pTempItem = pCasemapItem;
224 break;
225 case RES_CHRATR_COLOR:
226 if(!pCharColorItem)
227 pCharColorItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
228 pTempItem = pCharColorItem;
229 break;
230 case RES_CHRATR_CONTOUR:
231 if(!pContourItem)
232 pContourItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
233 pTempItem = pContourItem;
234 break;
235 case RES_CHRATR_CROSSEDOUT:
236 if(!pCrossedOutItem)
237 pCrossedOutItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
238 pTempItem = pCrossedOutItem;
239 break;
240 case RES_CHRATR_ESCAPEMENT:
241 if(!pEscItem)
242 pEscItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
243 pTempItem = pEscItem;
244 break;
245 case RES_CHRATR_BLINK:
246 if(!pBlinkItem)
247 pBlinkItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
248 pTempItem = pBlinkItem;
249 break;
250 case RES_CHRATR_FONT:
251 if(!pFontItem)
252 pFontItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
253 pTempItem = pFontItem;
254 break;
255 case RES_CHRATR_FONTSIZE:
256 if(!pFontSizeItem)
257 pFontSizeItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
258 pTempItem = pFontSizeItem;
259 break;
260 case RES_CHRATR_KERNING:
261 if(!pKernItem)
262 pKernItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
263 pTempItem = pKernItem;
264 break;
265 case RES_CHRATR_LANGUAGE:
266 if(!pLangItem)
267 pLangItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
268 pTempItem = pLangItem;
269 break;
270 case RES_CHRATR_NOHYPHEN:
271 if(!pNHyphItem)
272 pNHyphItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
273 pTempItem = pNHyphItem;
274 break;
275 case RES_CHRATR_POSTURE:
276 if(!pPostItem)
277 pPostItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
278 pTempItem = pPostItem;
279 break;
280 case RES_CHRATR_SHADOWED:
281 if(!pShadItem)
282 pShadItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
283 pTempItem = pShadItem;
284 break;
285 case RES_TXTATR_CHARFMT:
286 if(!pCharFmtItem)
287 pCharFmtItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
288 pTempItem = pCharFmtItem;
289 break;
290 case RES_CHRATR_UNDERLINE:
291 if(!pULineItem)
292 pULineItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
293 pTempItem = pULineItem;
294 break;
295 case RES_CHRATR_OVERLINE:
296 if(!pOLineItem)
297 pOLineItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
298 pTempItem = pOLineItem;
299 break;
300 case RES_CHRATR_WEIGHT:
301 if(!pWeightItem)
302 pWeightItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
303 pTempItem = pWeightItem;
304 break;
305 case RES_PARATR_DROP:
306 if(!pDropItem)
307 pDropItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
308 pTempItem = pDropItem;
309 break;
310 case RES_TXTATR_INETFMT:
311 if(!pInetItem)
312 pInetItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
313 pTempItem = pInetItem;
314 break;
315 case RES_PAGEDESC:
316 if(!pDescItem)
317 pDescItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
318 pTempItem = pDescItem;
319 break;
320 case RES_PARATR_ADJUST:
321 if(!pAdjItem)
322 pAdjItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
323 pTempItem = pAdjItem;
324 break;
325 case RES_BACKGROUND:
326 if(!pBackItem)
327 pBackItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
328 pTempItem = pBackItem;
329 break;
330 case RES_UL_SPACE:
331 if(!pULItem)
332 pULItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
333 pTempItem = pULItem;
334 break;
335 case RES_LR_SPACE:
336 if(!pLRItem)
337 pLRItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
338 pTempItem = pLRItem;
339 break;
340 case RES_KEEP:
341 if(!pKeepItem)
342 pKeepItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
343 pTempItem = pKeepItem;
344 break;
345 case RES_LINENUMBER:
346 if(!pLineNumItem)
347 pLineNumItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
348 pTempItem = pLineNumItem;
349 break;
350 case RES_PARATR_LINESPACING:
351 if(!pLineSpaceItem)
352 pLineSpaceItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
353 pTempItem = pLineSpaceItem;
354 break;
355 case RES_PARATR_REGISTER:
356 if(!pRegItem)
357 pRegItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
358 pTempItem = pRegItem;
359 break;
360 case RES_PARATR_SPLIT:
361 if(!pSplitItem)
362 pSplitItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
363 pTempItem = pSplitItem;
364 break;
365 case RES_PARATR_TABSTOP:
366 if(!pTabItem)
367 pTabItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
368 pTempItem = pTabItem;
369 break;
370 case RES_CHRATR_WORDLINEMODE:
371 if(!pWLineItem)
372 pWLineItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
373 pTempItem = pWLineItem;
374 break;
376 if(pTempItem)
378 if(bIsValueSearch)
380 pTempItem->PutValue(pValueArr[i]->Value, aIt->nMemberId);
381 rSet.Put(*pTempItem);
383 else
384 rSet.InvalidateItem( pTempItem->Which() );
388 delete pBoxItem;
389 delete pBreakItem;
390 delete pBreakItem ;
391 delete pAutoKernItem ;
392 delete pWLineItem;
393 delete pTabItem;
394 delete pSplitItem;
395 delete pRegItem;
396 delete pLineSpaceItem ;
397 delete pLineNumItem ;
398 delete pKeepItem;
399 delete pLRItem ;
400 delete pULItem ;
401 delete pBackItem;
402 delete pAdjItem;
403 delete pDescItem;
404 delete pInetItem;
405 delete pDropItem;
406 delete pWeightItem;
407 delete pULineItem;
408 delete pOLineItem;
409 delete pCharFmtItem ;
410 delete pShadItem;
411 delete pPostItem;
412 delete pNHyphItem;
413 delete pLangItem;
414 delete pKernItem;
415 delete pFontSizeItem ;
416 delete pFontItem;
417 delete pBlinkItem;
418 delete pEscItem;
419 delete pCrossedOutItem;
420 delete pContourItem ;
421 delete pCharColorItem;
422 delete pCasemapItem ;
423 delete pBrushItem ;
425 /* -----------------23.06.99 14:18-------------------
427 --------------------------------------------------*/
428 sal_Bool SwSearchProperties_Impl::HasAttributes() const
430 for(sal_uInt32 i = 0; i < nArrLen; i++)
431 if(pValueArr[i])
432 return sal_True;
433 return sal_False;
436 /*-- 14.12.98 13:07:10 ---------------------------------------------------
438 -----------------------------------------------------------------------*/
439 SwXTextSearch::SwXTextSearch() :
440 pSearchProperties( new SwSearchProperties_Impl),
441 pReplaceProperties( new SwSearchProperties_Impl),
442 m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_SEARCH)),
443 bAll(sal_False),
444 bWord(sal_False),
445 bBack(sal_False),
446 bExpr(sal_False),
447 bCase(sal_False),
448 bStyles(sal_False),
449 bSimilarity(sal_False),
450 bLevRelax(sal_False),
451 nLevExchange(2),
452 nLevAdd(2),
453 nLevRemove(2),
454 bIsValueSearch(sal_True)
457 /*-- 14.12.98 13:07:12 ---------------------------------------------------
459 -----------------------------------------------------------------------*/
460 SwXTextSearch::~SwXTextSearch()
462 delete pSearchProperties;
463 delete pReplaceProperties;
465 /* -----------------------------10.03.00 18:02--------------------------------
467 ---------------------------------------------------------------------------*/
468 const uno::Sequence< sal_Int8 > & SwXTextSearch::getUnoTunnelId()
470 static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
471 return aSeq;
473 /* -----------------------------10.03.00 18:04--------------------------------
475 ---------------------------------------------------------------------------*/
476 sal_Int64 SAL_CALL SwXTextSearch::getSomething( const uno::Sequence< sal_Int8 >& rId )
477 throw(uno::RuntimeException)
479 if( rId.getLength() == 16
480 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
481 rId.getConstArray(), 16 ) )
483 return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
485 return 0;
487 /*-- 14.12.98 13:07:12---------------------------------------------------
489 -----------------------------------------------------------------------*/
490 OUString SwXTextSearch::getSearchString(void) throw( uno::RuntimeException )
492 vos::OGuard aGuard(Application::GetSolarMutex());
493 return sSearchText;
495 /*-- 14.12.98 13:07:12---------------------------------------------------
497 -----------------------------------------------------------------------*/
498 void SwXTextSearch::setSearchString(const OUString& rString)
499 throw( uno::RuntimeException )
501 vos::OGuard aGuard(Application::GetSolarMutex());
502 sSearchText = String(rString);
504 /*-- 14.12.98 13:07:12---------------------------------------------------
506 -----------------------------------------------------------------------*/
507 OUString SwXTextSearch::getReplaceString(void) throw( uno::RuntimeException )
509 vos::OGuard aGuard(Application::GetSolarMutex());
510 return sReplaceText;
512 /*-- 14.12.98 13:07:12---------------------------------------------------
514 -----------------------------------------------------------------------*/
515 void SwXTextSearch::setReplaceString(const OUString& rReplaceString) throw( uno::RuntimeException )
517 vos::OGuard aGuard(Application::GetSolarMutex());
518 sReplaceText = String(rReplaceString);
520 /*-- 14.12.98 13:07:13---------------------------------------------------
522 -----------------------------------------------------------------------*/
523 uno::Reference< beans::XPropertySetInfo > SwXTextSearch::getPropertySetInfo(void) throw( uno::RuntimeException )
525 static uno::Reference< beans::XPropertySetInfo > aRef = m_pPropSet->getPropertySetInfo();
526 return aRef;
528 /*-- 14.12.98 13:07:13---------------------------------------------------
530 -----------------------------------------------------------------------*/
531 void SwXTextSearch::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
532 throw( beans::UnknownPropertyException, beans::PropertyVetoException,
533 lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException )
535 vos::OGuard aGuard(Application::GetSolarMutex());
536 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName);
537 if(pEntry)
539 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
540 throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
541 sal_Bool bVal = FALSE;
542 if(aValue.getValueType() == ::getBooleanCppuType())
543 bVal = *(sal_Bool*)aValue.getValue();
544 switch(pEntry->nWID)
546 case WID_SEARCH_ALL : bAll = bVal; break;
547 case WID_WORDS: bWord = bVal; break;
548 case WID_BACKWARDS : bBack = bVal; break;
549 case WID_REGULAR_EXPRESSION : bExpr = bVal; break;
550 case WID_CASE_SENSITIVE : bCase = bVal; break;
551 //case WID_IN_SELECTION : bInSel = bVal; break;
552 case WID_STYLES : bStyles = bVal; break;
553 case WID_SIMILARITY : bSimilarity = bVal; break;
554 case WID_SIMILARITY_RELAX: bLevRelax = bVal; break;
555 case WID_SIMILARITY_EXCHANGE: aValue >>= nLevExchange; break;
556 case WID_SIMILARITY_ADD: aValue >>= nLevAdd; break;
557 case WID_SIMILARITY_REMOVE : aValue >>= nLevRemove;break;
560 else
561 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
563 /*-- 14.12.98 13:07:13---------------------------------------------------
565 -----------------------------------------------------------------------*/
566 uno::Any SwXTextSearch::getPropertyValue(const OUString& rPropertyName) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
568 vos::OGuard aGuard(Application::GetSolarMutex());
569 uno::Any aRet;
571 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName);
572 sal_Bool bSet = sal_False;
573 sal_Int16 nSet = 0;
574 if(pEntry)
576 switch(pEntry->nWID)
578 case WID_SEARCH_ALL : bSet = bAll; goto SET_BOOL;
579 case WID_WORDS: bSet = bWord; goto SET_BOOL;
580 case WID_BACKWARDS : bSet = bBack; goto SET_BOOL;
581 case WID_REGULAR_EXPRESSION : bSet = bExpr; goto SET_BOOL;
582 case WID_CASE_SENSITIVE : bSet = bCase; goto SET_BOOL;
583 //case WID_IN_SELECTION : bSet = bInSel; goto SET_BOOL;
584 case WID_STYLES : bSet = bStyles; goto SET_BOOL;
585 case WID_SIMILARITY : bSet = bSimilarity; goto SET_BOOL;
586 case WID_SIMILARITY_RELAX: bSet = bLevRelax;
587 SET_BOOL:
588 aRet.setValue(&bSet, ::getBooleanCppuType());
589 break;
590 case WID_SIMILARITY_EXCHANGE: nSet = nLevExchange; goto SET_UINT16;
591 case WID_SIMILARITY_ADD: nSet = nLevAdd; goto SET_UINT16;
592 case WID_SIMILARITY_REMOVE : nSet = nLevRemove;
593 SET_UINT16:
594 aRet <<= nSet;
595 break;
598 else
599 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
600 return aRet;
602 /*-- 14.12.98 13:07:13---------------------------------------------------
604 -----------------------------------------------------------------------*/
605 void SwXTextSearch::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
607 DBG_WARNING("not implemented");
609 /*-- 14.12.98 13:07:13---------------------------------------------------
611 -----------------------------------------------------------------------*/
612 void SwXTextSearch::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw(beans::UnknownPropertyException, lang::WrappedTargetException,uno::RuntimeException )
614 DBG_WARNING("not implemented");
616 /*-- 14.12.98 13:07:14---------------------------------------------------
618 -----------------------------------------------------------------------*/
619 void SwXTextSearch::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw(beans::UnknownPropertyException, lang::WrappedTargetException,uno::RuntimeException )
621 DBG_WARNING("not implemented");
623 /*-- 14.12.98 13:07:14---------------------------------------------------
625 -----------------------------------------------------------------------*/
626 void SwXTextSearch::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw(beans::UnknownPropertyException, lang::WrappedTargetException,uno::RuntimeException )
628 DBG_WARNING("not implemented");
630 /*-- 14.12.98 13:07:14---------------------------------------------------
632 -----------------------------------------------------------------------*/
633 sal_Bool SwXTextSearch::getValueSearch(void) throw( uno::RuntimeException )
635 vos::OGuard aGuard(Application::GetSolarMutex());
636 return bIsValueSearch;
638 /*-- 14.12.98 13:07:15---------------------------------------------------
640 -----------------------------------------------------------------------*/
641 void SwXTextSearch::setValueSearch(sal_Bool ValueSearch_) throw( uno::RuntimeException )
643 vos::OGuard aGuard(Application::GetSolarMutex());
644 bIsValueSearch = ValueSearch_;
646 /*-- 14.12.98 13:07:15---------------------------------------------------
648 -----------------------------------------------------------------------*/
649 uno::Sequence< beans::PropertyValue > SwXTextSearch::getSearchAttributes(void) throw( uno::RuntimeException )
651 return pSearchProperties->GetProperties();
653 /*-- 14.12.98 13:07:16---------------------------------------------------
655 -----------------------------------------------------------------------*/
656 void SwXTextSearch::setSearchAttributes(const uno::Sequence< beans::PropertyValue >& rSearchAttribs)
657 throw( beans::UnknownPropertyException, lang::IllegalArgumentException, uno::RuntimeException )
659 pSearchProperties->SetProperties(rSearchAttribs);
661 /*-- 14.12.98 13:07:16---------------------------------------------------
663 -----------------------------------------------------------------------*/
664 uno::Sequence< beans::PropertyValue > SwXTextSearch::getReplaceAttributes(void)
665 throw( uno::RuntimeException )
667 return pReplaceProperties->GetProperties();
669 /*-- 14.12.98 13:07:17---------------------------------------------------
671 -----------------------------------------------------------------------*/
672 void SwXTextSearch::setReplaceAttributes(const uno::Sequence< beans::PropertyValue >& rReplaceAttribs)
673 throw( beans::UnknownPropertyException, lang::IllegalArgumentException, uno::RuntimeException )
675 pReplaceProperties->SetProperties(rReplaceAttribs);
677 /* -----------------23.06.99 14:13-------------------
679 --------------------------------------------------*/
680 void SwXTextSearch::FillSearchItemSet(SfxItemSet& rSet) const
682 pSearchProperties->FillItemSet(rSet, bIsValueSearch);
684 /* -----------------23.06.99 14:14-------------------
686 --------------------------------------------------*/
687 void SwXTextSearch::FillReplaceItemSet(SfxItemSet& rSet) const
689 pReplaceProperties->FillItemSet(rSet, bIsValueSearch);
691 /* -----------------23.06.99 14:17-------------------
693 --------------------------------------------------*/
694 sal_Bool SwXTextSearch::HasSearchAttributes() const
696 return pSearchProperties->HasAttributes();
698 /* -----------------23.06.99 14:17-------------------
700 --------------------------------------------------*/
701 sal_Bool SwXTextSearch::HasReplaceAttributes() const
703 return pReplaceProperties->HasAttributes();
705 /* -----------------------------19.04.00 14:43--------------------------------
707 ---------------------------------------------------------------------------*/
708 OUString SwXTextSearch::getImplementationName(void) throw( uno::RuntimeException )
710 return C2U("SwXTextSearch");
712 /* -----------------------------19.04.00 14:43--------------------------------
714 ---------------------------------------------------------------------------*/
715 BOOL SwXTextSearch::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
717 return C2U("com.sun.star.util.SearchDescriptor") == rServiceName ||
718 C2U("com.sun.star.util.ReplaceDescriptor") == rServiceName;
720 /* -----------------------------19.04.00 14:43--------------------------------
722 ---------------------------------------------------------------------------*/
723 uno::Sequence< OUString > SwXTextSearch::getSupportedServiceNames(void) throw( uno::RuntimeException )
725 uno::Sequence< OUString > aRet(2);
726 OUString* pArray = aRet.getArray();
727 pArray[0] = C2U("com.sun.star.util.SearchDescriptor");
728 pArray[1] = C2U("com.sun.star.util.ReplaceDescriptor");
729 return aRet;
732 void SwXTextSearch::FillSearchOptions( util::SearchOptions& rSearchOpt ) const
734 if( bSimilarity )
736 rSearchOpt.algorithmType = util::SearchAlgorithms_APPROXIMATE;
737 rSearchOpt.changedChars = nLevExchange;
738 rSearchOpt.deletedChars = nLevRemove;
739 rSearchOpt.insertedChars = nLevAdd;
740 if( bLevRelax )
741 rSearchOpt.searchFlag |= util::SearchFlags::LEV_RELAXED;
743 else if( bExpr )
744 rSearchOpt.algorithmType = util::SearchAlgorithms_REGEXP;
745 else
746 rSearchOpt.algorithmType = util::SearchAlgorithms_ABSOLUTE;
748 rSearchOpt.Locale = SvxCreateLocale( GetAppLanguage() );
749 rSearchOpt.searchString = sSearchText;
750 rSearchOpt.replaceString = sReplaceText;
752 if( !bCase )
753 rSearchOpt.transliterateFlags |= i18n::TransliterationModules_IGNORE_CASE;
754 if( bWord )
755 rSearchOpt.searchFlag |= util::SearchFlags::NORM_WORD_ONLY;
757 // bInSel: 1; // wie geht das?
758 // TODO: pSearch->bStyles!
759 // inSelection??
760 // aSrchParam.SetSrchInSelection(TypeConversion::toBOOL(aVal));