update credits
[LibreOffice.git] / sw / source / core / unocore / unosrch.cxx
bloba57b4d5075afc65d5e3aaa81c371fb2964965de9
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 .
21 #include "unosrch.hxx"
22 #include <doc.hxx>
23 #include <hints.hxx>
24 #include <unomap.hxx>
25 #include <unobaseclass.hxx>
26 #include <unomid.h>
28 #include <osl/mutex.hxx>
29 #include <vcl/svapp.hxx>
30 #include "editeng/unolingu.hxx"
31 #include <com/sun/star/util/SearchOptions.hpp>
32 #include <com/sun/star/util/SearchFlags.hpp>
33 #include <com/sun/star/i18n/TransliterationModules.hpp>
34 #include <com/sun/star/beans/PropertyAttribute.hpp>
35 #include <comphelper/servicehelper.hxx>
36 #include <cppuhelper/supportsservice.hxx>
38 using namespace ::com::sun::star;
40 class SwSearchProperties_Impl
42 beans::PropertyValue** pValueArr; //
43 sal_uInt32 nArrLen;
44 const PropertyEntryVector_t aPropertyEntries;
45 public:
46 SwSearchProperties_Impl();
47 ~SwSearchProperties_Impl();
49 void SetProperties(const uno::Sequence< beans::PropertyValue >& aSearchAttribs)
50 throw( beans::UnknownPropertyException, lang::IllegalArgumentException, uno::RuntimeException );
51 const uno::Sequence< beans::PropertyValue > GetProperties() const;
53 void FillItemSet(SfxItemSet& rSet, sal_Bool bIsValueSearch) const;
54 sal_Bool HasAttributes() const;
57 SwSearchProperties_Impl::SwSearchProperties_Impl() :
58 nArrLen(0),
59 aPropertyEntries( aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)->getPropertyMap().getPropertyEntries())
61 nArrLen = aPropertyEntries.size();
62 pValueArr = new beans::PropertyValue*[nArrLen];
63 for(sal_uInt32 i = 0; i < nArrLen; i++)
64 pValueArr[i] = 0;
67 SwSearchProperties_Impl::~SwSearchProperties_Impl()
69 for(sal_uInt32 i = 0; i < nArrLen; i++)
70 delete pValueArr[i];
71 delete[] pValueArr;
74 void SwSearchProperties_Impl::SetProperties(const uno::Sequence< beans::PropertyValue >& aSearchAttribs)
75 throw( beans::UnknownPropertyException, lang::IllegalArgumentException, uno::RuntimeException )
77 const beans::PropertyValue* pProps = aSearchAttribs.getConstArray();
78 sal_uInt32 i;
80 //delete all existing values
81 for( i = 0; i < nArrLen; i++)
83 delete pValueArr[i];
84 pValueArr[i] = 0;
87 sal_uInt32 nLen = aSearchAttribs.getLength();
88 for(i = 0; i < nLen; i++)
90 sal_uInt16 nIndex = 0;
91 PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
92 while(pProps[i].Name != aIt->sName)
94 ++aIt;
95 nIndex++;
96 if( aIt == aPropertyEntries.end() )
97 throw beans::UnknownPropertyException();
99 pValueArr[nIndex] = new beans::PropertyValue(pProps[i]);
103 const uno::Sequence< beans::PropertyValue > SwSearchProperties_Impl::GetProperties() const
105 sal_uInt32 nPropCount = 0;
106 sal_uInt32 i;
107 for( i = 0; i < nArrLen; i++)
108 if(pValueArr[i])
109 nPropCount++;
111 uno::Sequence< beans::PropertyValue > aRet(nPropCount);
112 beans::PropertyValue* pProps = aRet.getArray();
113 nPropCount = 0;
114 for(i = 0; i < nArrLen; i++)
116 if(pValueArr[i])
118 pProps[nPropCount++] = *(pValueArr[i]);
121 return aRet;
124 void SwSearchProperties_Impl::FillItemSet(SfxItemSet& rSet, sal_Bool bIsValueSearch) const
128 SfxPoolItem* pBoxItem = 0,
129 *pBreakItem = 0,
130 *pAutoKernItem = 0,
131 *pWLineItem = 0,
132 *pTabItem = 0,
133 *pSplitItem = 0,
134 *pRegItem = 0,
135 *pLineSpaceItem = 0,
136 *pLineNumItem = 0,
137 *pKeepItem = 0,
138 *pLRItem = 0,
139 *pULItem = 0,
140 *pBackItem = 0,
141 *pAdjItem = 0,
142 *pDescItem = 0,
143 *pInetItem = 0,
144 *pDropItem = 0,
145 *pWeightItem = 0,
146 *pULineItem = 0,
147 *pOLineItem = 0,
148 *pCharFmtItem = 0,
149 *pShadItem = 0,
150 *pPostItem = 0,
151 *pNHyphItem = 0,
152 *pLangItem = 0,
153 *pKernItem = 0,
154 *pFontSizeItem = 0,
155 *pFontItem = 0,
156 *pBlinkItem = 0,
157 *pEscItem = 0,
158 *pCrossedOutItem = 0,
159 *pContourItem = 0,
160 *pCharColorItem = 0,
161 *pCasemapItem = 0,
162 *pBrushItem = 0,
163 *pFontCJKItem = 0,
164 *pFontSizeCJKItem = 0,
165 *pCJKLangItem = 0,
166 *pCJKPostureItem = 0,
167 *pCJKWeightItem = 0,
168 *pFontCTLItem = 0,
169 *pFontSizeCTLItem = 0,
170 *pCTLLangItem = 0,
171 *pCTLPostureItem = 0,
172 *pCTLWeightItem = 0;
174 PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
175 for(sal_uInt32 i = 0; i < nArrLen; i++, ++aIt)
177 if(pValueArr[i])
179 SfxPoolItem* pTempItem = 0;
180 switch(aIt->nWID)
182 case RES_BOX:
183 if(!pBoxItem)
184 pBoxItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
185 pTempItem = pBoxItem;
186 break;
187 case RES_BREAK:
188 if(!pBreakItem)
189 pBreakItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
190 pTempItem = pBreakItem;
191 break;
192 case RES_CHRATR_AUTOKERN:
193 if(!pAutoKernItem)
194 pAutoKernItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
195 pTempItem = pAutoKernItem;
196 break;
197 case RES_CHRATR_BACKGROUND:
198 if(!pBrushItem)
199 pBrushItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
200 pTempItem = pBrushItem;
201 break;
202 case RES_CHRATR_CASEMAP:
203 if(!pCasemapItem)
204 pCasemapItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
205 pTempItem = pCasemapItem;
206 break;
207 case RES_CHRATR_COLOR:
208 if(!pCharColorItem)
209 pCharColorItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
210 pTempItem = pCharColorItem;
211 break;
212 case RES_CHRATR_CONTOUR:
213 if(!pContourItem)
214 pContourItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
215 pTempItem = pContourItem;
216 break;
217 case RES_CHRATR_CROSSEDOUT:
218 if(!pCrossedOutItem)
219 pCrossedOutItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
220 pTempItem = pCrossedOutItem;
221 break;
222 case RES_CHRATR_ESCAPEMENT:
223 if(!pEscItem)
224 pEscItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
225 pTempItem = pEscItem;
226 break;
227 case RES_CHRATR_BLINK:
228 if(!pBlinkItem)
229 pBlinkItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
230 pTempItem = pBlinkItem;
231 break;
232 case RES_CHRATR_FONT:
233 if(!pFontItem)
234 pFontItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
235 pTempItem = pFontItem;
236 break;
237 case RES_CHRATR_FONTSIZE:
238 if(!pFontSizeItem)
239 pFontSizeItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
240 pTempItem = pFontSizeItem;
241 break;
242 case RES_CHRATR_KERNING:
243 if(!pKernItem)
244 pKernItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
245 pTempItem = pKernItem;
246 break;
247 case RES_CHRATR_LANGUAGE:
248 if(!pLangItem)
249 pLangItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
250 pTempItem = pLangItem;
251 break;
252 case RES_CHRATR_NOHYPHEN:
253 if(!pNHyphItem)
254 pNHyphItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
255 pTempItem = pNHyphItem;
256 break;
257 case RES_CHRATR_POSTURE:
258 if(!pPostItem)
259 pPostItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
260 pTempItem = pPostItem;
261 break;
262 case RES_CHRATR_SHADOWED:
263 if(!pShadItem)
264 pShadItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
265 pTempItem = pShadItem;
266 break;
267 case RES_TXTATR_CHARFMT:
268 if(!pCharFmtItem)
269 pCharFmtItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
270 pTempItem = pCharFmtItem;
271 break;
272 case RES_CHRATR_UNDERLINE:
273 if(!pULineItem)
274 pULineItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
275 pTempItem = pULineItem;
276 break;
277 case RES_CHRATR_OVERLINE:
278 if(!pOLineItem)
279 pOLineItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
280 pTempItem = pOLineItem;
281 break;
282 case RES_CHRATR_WEIGHT:
283 if(!pWeightItem)
284 pWeightItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
285 pTempItem = pWeightItem;
286 break;
287 case RES_PARATR_DROP:
288 if(!pDropItem)
289 pDropItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
290 pTempItem = pDropItem;
291 break;
292 case RES_TXTATR_INETFMT:
293 if(!pInetItem)
294 pInetItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
295 pTempItem = pInetItem;
296 break;
297 case RES_PAGEDESC:
298 if(!pDescItem)
299 pDescItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
300 pTempItem = pDescItem;
301 break;
302 case RES_PARATR_ADJUST:
303 if(!pAdjItem)
304 pAdjItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
305 pTempItem = pAdjItem;
306 break;
307 case RES_BACKGROUND:
308 if(!pBackItem)
309 pBackItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
310 pTempItem = pBackItem;
311 break;
312 case RES_UL_SPACE:
313 if(!pULItem)
314 pULItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
315 pTempItem = pULItem;
316 break;
317 case RES_LR_SPACE:
318 if(!pLRItem)
319 pLRItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
320 pTempItem = pLRItem;
321 break;
322 case RES_KEEP:
323 if(!pKeepItem)
324 pKeepItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
325 pTempItem = pKeepItem;
326 break;
327 case RES_LINENUMBER:
328 if(!pLineNumItem)
329 pLineNumItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
330 pTempItem = pLineNumItem;
331 break;
332 case RES_PARATR_LINESPACING:
333 if(!pLineSpaceItem)
334 pLineSpaceItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
335 pTempItem = pLineSpaceItem;
336 break;
337 case RES_PARATR_REGISTER:
338 if(!pRegItem)
339 pRegItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
340 pTempItem = pRegItem;
341 break;
342 case RES_PARATR_SPLIT:
343 if(!pSplitItem)
344 pSplitItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
345 pTempItem = pSplitItem;
346 break;
347 case RES_PARATR_TABSTOP:
348 if(!pTabItem)
349 pTabItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
350 pTempItem = pTabItem;
351 break;
352 case RES_CHRATR_WORDLINEMODE:
353 if(!pWLineItem)
354 pWLineItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
355 pTempItem = pWLineItem;
356 break;
357 case RES_CHRATR_CJK_FONT:
358 if(!pFontCJKItem )
359 pFontCJKItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
360 pTempItem = pFontCJKItem;
361 break;
362 case RES_CHRATR_CJK_FONTSIZE:
363 if(!pFontSizeCJKItem )
364 pFontSizeCJKItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
365 pTempItem = pFontSizeCJKItem;
366 break;
367 case RES_CHRATR_CJK_LANGUAGE:
368 if(!pCJKLangItem )
369 pCJKLangItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
370 pTempItem = pCJKLangItem;
371 break;
372 case RES_CHRATR_CJK_POSTURE:
373 if(!pCJKPostureItem )
374 pCJKPostureItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
375 pTempItem = pCJKPostureItem;
376 break;
377 case RES_CHRATR_CJK_WEIGHT:
378 if(!pCJKWeightItem )
379 pCJKWeightItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
380 pTempItem = pCJKWeightItem;
381 break;
382 case RES_CHRATR_CTL_FONT:
383 if(!pFontCTLItem )
384 pFontCTLItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
385 pTempItem = pFontCTLItem;
386 break;
387 case RES_CHRATR_CTL_FONTSIZE:
388 if(!pFontSizeCTLItem )
389 pFontSizeCTLItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
390 pTempItem = pFontSizeCTLItem;
391 break;
392 case RES_CHRATR_CTL_LANGUAGE:
393 if(!pCTLLangItem )
394 pCTLLangItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
395 pTempItem = pCTLLangItem;
396 break;
397 case RES_CHRATR_CTL_POSTURE:
398 if(!pCTLPostureItem )
399 pCTLPostureItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
400 pTempItem = pCTLPostureItem;
401 break;
402 case RES_CHRATR_CTL_WEIGHT:
403 if(!pCTLWeightItem )
404 pCTLWeightItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
405 pTempItem = pCTLWeightItem;
406 break;
408 if(pTempItem)
410 if(bIsValueSearch)
412 pTempItem->PutValue(pValueArr[i]->Value, aIt->nMemberId);
413 rSet.Put(*pTempItem);
415 else
416 rSet.InvalidateItem( pTempItem->Which() );
420 delete pBoxItem;
421 delete pBreakItem;
422 delete pAutoKernItem ;
423 delete pWLineItem;
424 delete pTabItem;
425 delete pSplitItem;
426 delete pRegItem;
427 delete pLineSpaceItem ;
428 delete pLineNumItem ;
429 delete pKeepItem;
430 delete pLRItem ;
431 delete pULItem ;
432 delete pBackItem;
433 delete pAdjItem;
434 delete pDescItem;
435 delete pInetItem;
436 delete pDropItem;
437 delete pWeightItem;
438 delete pULineItem;
439 delete pOLineItem;
440 delete pCharFmtItem ;
441 delete pShadItem;
442 delete pPostItem;
443 delete pNHyphItem;
444 delete pLangItem;
445 delete pKernItem;
446 delete pFontSizeItem ;
447 delete pFontItem;
448 delete pBlinkItem;
449 delete pEscItem;
450 delete pCrossedOutItem;
451 delete pContourItem ;
452 delete pCharColorItem;
453 delete pCasemapItem ;
454 delete pBrushItem ;
457 sal_Bool SwSearchProperties_Impl::HasAttributes() const
459 for(sal_uInt32 i = 0; i < nArrLen; i++)
460 if(pValueArr[i])
461 return sal_True;
462 return sal_False;
465 SwXTextSearch::SwXTextSearch() :
466 pSearchProperties( new SwSearchProperties_Impl),
467 pReplaceProperties( new SwSearchProperties_Impl),
468 m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_SEARCH)),
469 bAll(sal_False),
470 bWord(sal_False),
471 bBack(sal_False),
472 bExpr(sal_False),
473 bCase(sal_False),
474 bStyles(sal_False),
475 bSimilarity(sal_False),
476 bLevRelax(sal_False),
477 nLevExchange(2),
478 nLevAdd(2),
479 nLevRemove(2),
480 bIsValueSearch(sal_True)
484 SwXTextSearch::~SwXTextSearch()
486 delete pSearchProperties;
487 delete pReplaceProperties;
490 namespace
492 class theSwXTextSearchUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextSearchUnoTunnelId > {};
495 const uno::Sequence< sal_Int8 > & SwXTextSearch::getUnoTunnelId()
497 return theSwXTextSearchUnoTunnelId::get().getSeq();
500 sal_Int64 SAL_CALL SwXTextSearch::getSomething( const uno::Sequence< sal_Int8 >& rId )
501 throw(uno::RuntimeException)
503 if( rId.getLength() == 16
504 && 0 == memcmp( getUnoTunnelId().getConstArray(),
505 rId.getConstArray(), 16 ) )
507 return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
509 return 0;
512 OUString SwXTextSearch::getSearchString(void) throw( uno::RuntimeException )
514 SolarMutexGuard aGuard;
515 return sSearchText;
518 void SwXTextSearch::setSearchString(const OUString& rString)
519 throw( uno::RuntimeException )
521 SolarMutexGuard aGuard;
522 sSearchText = String(rString);
525 OUString SwXTextSearch::getReplaceString(void) throw( uno::RuntimeException )
527 SolarMutexGuard aGuard;
528 return sReplaceText;
531 void SwXTextSearch::setReplaceString(const OUString& rReplaceString) throw( uno::RuntimeException )
533 SolarMutexGuard aGuard;
534 sReplaceText = String(rReplaceString);
537 uno::Reference< beans::XPropertySetInfo > SwXTextSearch::getPropertySetInfo(void) throw( uno::RuntimeException )
539 static uno::Reference< beans::XPropertySetInfo > aRef = m_pPropSet->getPropertySetInfo();
540 return aRef;
543 void SwXTextSearch::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
544 throw( beans::UnknownPropertyException, beans::PropertyVetoException,
545 lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException )
547 SolarMutexGuard aGuard;
548 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName(rPropertyName);
549 if(pEntry)
551 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
552 throw beans::PropertyVetoException ( OUString( "Property is read-only: " ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
553 sal_Bool bVal = sal_False;
554 if(aValue.getValueType() == ::getBooleanCppuType())
555 bVal = *(sal_Bool*)aValue.getValue();
556 switch(pEntry->nWID)
558 case WID_SEARCH_ALL : bAll = bVal; break;
559 case WID_WORDS: bWord = bVal; break;
560 case WID_BACKWARDS : bBack = bVal; break;
561 case WID_REGULAR_EXPRESSION : bExpr = bVal; break;
562 case WID_CASE_SENSITIVE : bCase = bVal; break;
563 //case WID_IN_SELECTION : bInSel = bVal; break;
564 case WID_STYLES : bStyles = bVal; break;
565 case WID_SIMILARITY : bSimilarity = bVal; break;
566 case WID_SIMILARITY_RELAX: bLevRelax = bVal; break;
567 case WID_SIMILARITY_EXCHANGE: aValue >>= nLevExchange; break;
568 case WID_SIMILARITY_ADD: aValue >>= nLevAdd; break;
569 case WID_SIMILARITY_REMOVE : aValue >>= nLevRemove;break;
572 else
573 throw beans::UnknownPropertyException(OUString( "Unknown property: " ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
576 uno::Any SwXTextSearch::getPropertyValue(const OUString& rPropertyName) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
578 SolarMutexGuard aGuard;
579 uno::Any aRet;
581 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName(rPropertyName);
582 sal_Bool bSet = sal_False;
583 if(pEntry)
585 sal_Int16 nSet = 0;
586 switch(pEntry->nWID)
588 case WID_SEARCH_ALL : bSet = bAll; goto SET_BOOL;
589 case WID_WORDS: bSet = bWord; goto SET_BOOL;
590 case WID_BACKWARDS : bSet = bBack; goto SET_BOOL;
591 case WID_REGULAR_EXPRESSION : bSet = bExpr; goto SET_BOOL;
592 case WID_CASE_SENSITIVE : bSet = bCase; goto SET_BOOL;
593 //case WID_IN_SELECTION : bSet = bInSel; goto SET_BOOL;
594 case WID_STYLES : bSet = bStyles; goto SET_BOOL;
595 case WID_SIMILARITY : bSet = bSimilarity; goto SET_BOOL;
596 case WID_SIMILARITY_RELAX: bSet = bLevRelax;
597 SET_BOOL:
598 aRet.setValue(&bSet, ::getBooleanCppuType());
599 break;
600 case WID_SIMILARITY_EXCHANGE: nSet = nLevExchange; goto SET_UINT16;
601 case WID_SIMILARITY_ADD: nSet = nLevAdd; goto SET_UINT16;
602 case WID_SIMILARITY_REMOVE : nSet = nLevRemove;
603 SET_UINT16:
604 aRet <<= nSet;
605 break;
608 else
609 throw beans::UnknownPropertyException(OUString( "Unknown property: " ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
610 return aRet;
613 void SwXTextSearch::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
615 OSL_FAIL("not implemented");
618 void SwXTextSearch::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw(beans::UnknownPropertyException, lang::WrappedTargetException,uno::RuntimeException )
620 OSL_FAIL("not implemented");
623 void SwXTextSearch::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw(beans::UnknownPropertyException, lang::WrappedTargetException,uno::RuntimeException )
625 OSL_FAIL("not implemented");
628 void SwXTextSearch::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw(beans::UnknownPropertyException, lang::WrappedTargetException,uno::RuntimeException )
630 OSL_FAIL("not implemented");
633 sal_Bool SwXTextSearch::getValueSearch(void) throw( uno::RuntimeException )
635 SolarMutexGuard aGuard;
636 return bIsValueSearch;
639 void SwXTextSearch::setValueSearch(sal_Bool ValueSearch_) throw( uno::RuntimeException )
641 SolarMutexGuard aGuard;
642 bIsValueSearch = ValueSearch_;
645 uno::Sequence< beans::PropertyValue > SwXTextSearch::getSearchAttributes(void) throw( uno::RuntimeException )
647 return pSearchProperties->GetProperties();
650 void SwXTextSearch::setSearchAttributes(const uno::Sequence< beans::PropertyValue >& rSearchAttribs)
651 throw( beans::UnknownPropertyException, lang::IllegalArgumentException, uno::RuntimeException )
653 pSearchProperties->SetProperties(rSearchAttribs);
656 uno::Sequence< beans::PropertyValue > SwXTextSearch::getReplaceAttributes(void)
657 throw( uno::RuntimeException )
659 return pReplaceProperties->GetProperties();
662 void SwXTextSearch::setReplaceAttributes(const uno::Sequence< beans::PropertyValue >& rReplaceAttribs)
663 throw( beans::UnknownPropertyException, lang::IllegalArgumentException, uno::RuntimeException )
665 pReplaceProperties->SetProperties(rReplaceAttribs);
668 void SwXTextSearch::FillSearchItemSet(SfxItemSet& rSet) const
670 pSearchProperties->FillItemSet(rSet, bIsValueSearch);
673 void SwXTextSearch::FillReplaceItemSet(SfxItemSet& rSet) const
675 pReplaceProperties->FillItemSet(rSet, bIsValueSearch);
678 sal_Bool SwXTextSearch::HasSearchAttributes() const
680 return pSearchProperties->HasAttributes();
683 sal_Bool SwXTextSearch::HasReplaceAttributes() const
685 return pReplaceProperties->HasAttributes();
688 OUString SwXTextSearch::getImplementationName(void) throw( uno::RuntimeException )
690 return OUString("SwXTextSearch");
693 sal_Bool SwXTextSearch::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
695 return cppu::supportsService(this, rServiceName);
698 uno::Sequence< OUString > SwXTextSearch::getSupportedServiceNames(void) throw( uno::RuntimeException )
700 uno::Sequence< OUString > aRet(2);
701 OUString* pArray = aRet.getArray();
702 pArray[0] = "com.sun.star.util.SearchDescriptor";
703 pArray[1] = "com.sun.star.util.ReplaceDescriptor";
704 return aRet;
707 void SwXTextSearch::FillSearchOptions( util::SearchOptions& rSearchOpt ) const
709 if( bSimilarity )
711 rSearchOpt.algorithmType = util::SearchAlgorithms_APPROXIMATE;
712 rSearchOpt.changedChars = nLevExchange;
713 rSearchOpt.deletedChars = nLevRemove;
714 rSearchOpt.insertedChars = nLevAdd;
715 if( bLevRelax )
716 rSearchOpt.searchFlag |= util::SearchFlags::LEV_RELAXED;
718 else if( bExpr )
719 rSearchOpt.algorithmType = util::SearchAlgorithms_REGEXP;
720 else
721 rSearchOpt.algorithmType = util::SearchAlgorithms_ABSOLUTE;
723 rSearchOpt.Locale = GetAppLanguageTag().getLocale();
724 rSearchOpt.searchString = sSearchText;
725 rSearchOpt.replaceString = sReplaceText;
727 if( !bCase )
728 rSearchOpt.transliterateFlags |= i18n::TransliterationModules_IGNORE_CASE;
729 if( bWord )
730 rSearchOpt.searchFlag |= util::SearchFlags::NORM_WORD_ONLY;
732 // bInSel: 1; // wie geht das?
733 // TODO: pSearch->bStyles!
734 // inSelection??
735 // aSrchParam.SetSrchInSelection(TypeConversion::toBOOL(aVal));
738 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */