LibreOffice Module sw (master)  1
unosrch.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <unosrch.hxx>
21 #include <doc.hxx>
22 #include <hints.hxx>
23 #include <unomap.hxx>
24 #include <unobaseclass.hxx>
25 #include <unomid.h>
26 #include <fchrfmt.hxx>
27 
28 #include <osl/diagnose.h>
30 #include <i18nutil/searchopt.hxx>
31 #include <o3tl/any.hxx>
32 #include <vcl/svapp.hxx>
33 #include <editeng/unolingu.hxx>
34 #include <com/sun/star/util/SearchAlgorithms2.hpp>
35 #include <com/sun/star/util/SearchFlags.hpp>
36 #include <com/sun/star/beans/PropertyAttribute.hpp>
39 #include <svl/itemprop.hxx>
40 #include <memory>
41 
42 using namespace ::com::sun::star;
43 
45 {
46  std::unique_ptr<std::unique_ptr<beans::PropertyValue>[]> pValueArr;
48 
51 
52 public:
54 
58  void SetProperties(const uno::Sequence< beans::PropertyValue >& aSearchAttribs);
59  const uno::Sequence< beans::PropertyValue > GetProperties() const;
60 
61  void FillItemSet(SfxItemSet& rSet, bool bIsValueSearch) const;
62  bool HasAttributes() const;
63 };
64 
66  aPropertyEntries( aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)->getPropertyMap().getPropertyEntries() )
67 {
68  size_t nArrLen = aPropertyEntries.size();
69  pValueArr.reset( new std::unique_ptr<beans::PropertyValue>[nArrLen] );
70 }
71 
72 void SwSearchProperties_Impl::SetProperties(const uno::Sequence< beans::PropertyValue >& aSearchAttribs)
73 {
74  //delete all existing values
75  for(size_t i = 0; i < aPropertyEntries.size(); ++i)
76  {
77  pValueArr[i].reset();
78  }
79 
80  for(const beans::PropertyValue& rSearchAttrib : aSearchAttribs)
81  {
82  const OUString& sName = rSearchAttrib.Name;
83  auto aIt = std::find_if(aPropertyEntries.begin(), aPropertyEntries.end(),
84  [&sName](const SfxItemPropertyNamedEntry& rProp) { return rProp.sName == sName; });
85  if( aIt == aPropertyEntries.end() )
86  throw beans::UnknownPropertyException();
87  auto nIndex = static_cast<sal_uInt32>(std::distance(aPropertyEntries.begin(), aIt));
88  pValueArr[nIndex].reset( new beans::PropertyValue(rSearchAttrib) );
89  }
90 }
91 
92 const uno::Sequence< beans::PropertyValue > SwSearchProperties_Impl::GetProperties() const
93 {
94  sal_uInt32 nPropCount = 0;
95  for( size_t i = 0; i < aPropertyEntries.size(); i++)
96  if(pValueArr[i])
97  nPropCount++;
98 
99  uno::Sequence< beans::PropertyValue > aRet(nPropCount);
100  beans::PropertyValue* pProps = aRet.getArray();
101  nPropCount = 0;
102  for(size_t i = 0; i < aPropertyEntries.size(); i++)
103  {
104  if(pValueArr[i])
105  {
106  pProps[nPropCount++] = *(pValueArr[i]);
107  }
108  }
109  return aRet;
110 }
111 
112 void SwSearchProperties_Impl::FillItemSet(SfxItemSet& rSet, bool bIsValueSearch) const
113 {
114 
115  std::unique_ptr<SfxPoolItem> pBoxItem,
116  pCharBoxItem,
117  pBreakItem,
118  pAutoKernItem ,
119  pWLineItem ,
120  pTabItem ,
121  pSplitItem ,
122  pRegItem ,
123  pLineSpaceItem ,
124  pLineNumItem ,
125  pKeepItem ,
126  pLRItem ,
127  pULItem ,
128  pBackItem ,
129  pAdjItem ,
130  pDescItem ,
131  pInetItem ,
132  pDropItem ,
133  pWeightItem ,
134  pULineItem ,
135  pOLineItem ,
136  pCharFormatItem ,
137  pShadItem ,
138  pPostItem ,
139  pNHyphItem ,
140  pLangItem ,
141  pKernItem ,
142  pFontSizeItem ,
143  pFontItem ,
144  pBlinkItem ,
145  pEscItem ,
146  pCrossedOutItem ,
147  pContourItem ,
148  pCharColorItem ,
149  pCasemapItem ,
150  pBrushItem ,
151  pFontCJKItem,
152  pFontSizeCJKItem,
153  pCJKLangItem,
154  pCJKPostureItem,
155  pCJKWeightItem,
156  pFontCTLItem,
157  pFontSizeCTLItem,
158  pCTLLangItem,
159  pCTLPostureItem,
160  pCTLWeightItem,
161  pShadowItem ;
162 
163  PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
164  for(size_t i = 0; i < aPropertyEntries.size(); i++, ++aIt)
165  {
166  if(pValueArr[i])
167  {
168  SfxPoolItem* pTempItem = nullptr;
169  switch(aIt->nWID)
170  {
171  case RES_BOX:
172  if(!pBoxItem)
173  pBoxItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
174  pTempItem = pBoxItem.get();
175  break;
176  case RES_CHRATR_BOX:
177  if(!pCharBoxItem)
178  pCharBoxItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
179  pTempItem = pCharBoxItem.get();
180  break;
181  case RES_BREAK:
182  if(!pBreakItem)
183  pBreakItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
184  pTempItem = pBreakItem.get();
185  break;
186  case RES_CHRATR_AUTOKERN:
187  if(!pAutoKernItem)
188  pAutoKernItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
189  pTempItem = pAutoKernItem.get();
190  break;
192  if(!pBrushItem)
193  pBrushItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
194  pTempItem = pBrushItem.get();
195  break;
196  case RES_CHRATR_CASEMAP:
197  if(!pCasemapItem)
198  pCasemapItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
199  pTempItem = pCasemapItem.get();
200  break;
201  case RES_CHRATR_COLOR:
202  if(!pCharColorItem)
203  pCharColorItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
204  pTempItem = pCharColorItem.get();
205  break;
206  case RES_CHRATR_CONTOUR:
207  if(!pContourItem)
208  pContourItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
209  pTempItem = pContourItem.get();
210  break;
212  if(!pCrossedOutItem)
213  pCrossedOutItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
214  pTempItem = pCrossedOutItem.get();
215  break;
217  if(!pEscItem)
218  pEscItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
219  pTempItem = pEscItem.get();
220  break;
221  case RES_CHRATR_BLINK:
222  if(!pBlinkItem)
223  pBlinkItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
224  pTempItem = pBlinkItem.get();
225  break;
226  case RES_CHRATR_FONT:
227  if(!pFontItem)
228  pFontItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
229  pTempItem = pFontItem.get();
230  break;
231  case RES_CHRATR_FONTSIZE:
232  if(!pFontSizeItem)
233  pFontSizeItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
234  pTempItem = pFontSizeItem.get();
235  break;
236  case RES_CHRATR_KERNING:
237  if(!pKernItem)
238  pKernItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
239  pTempItem = pKernItem.get();
240  break;
241  case RES_CHRATR_LANGUAGE:
242  if(!pLangItem)
243  pLangItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
244  pTempItem = pLangItem.get();
245  break;
246  case RES_CHRATR_NOHYPHEN:
247  if(!pNHyphItem)
248  pNHyphItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
249  pTempItem = pNHyphItem.get();
250  break;
251  case RES_CHRATR_POSTURE:
252  if(!pPostItem)
253  pPostItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
254  pTempItem = pPostItem.get();
255  break;
256  case RES_CHRATR_SHADOWED:
257  if(!pShadItem)
258  pShadItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
259  pTempItem = pShadItem.get();
260  break;
261  case RES_TXTATR_CHARFMT:
262  if(!pCharFormatItem)
263  pCharFormatItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
264  pTempItem = pCharFormatItem.get();
265  break;
267  if(!pULineItem)
268  pULineItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
269  pTempItem = pULineItem.get();
270  break;
271  case RES_CHRATR_OVERLINE:
272  if(!pOLineItem)
273  pOLineItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
274  pTempItem = pOLineItem.get();
275  break;
276  case RES_CHRATR_WEIGHT:
277  if(!pWeightItem)
278  pWeightItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
279  pTempItem = pWeightItem.get();
280  break;
281  case RES_PARATR_DROP:
282  if(!pDropItem)
283  pDropItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
284  pTempItem = pDropItem.get();
285  break;
286  case RES_TXTATR_INETFMT:
287  if(!pInetItem)
288  pInetItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
289  pTempItem = pInetItem.get();
290  break;
291  case RES_PAGEDESC:
292  if(!pDescItem)
293  pDescItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
294  pTempItem = pDescItem.get();
295  break;
296  case RES_PARATR_ADJUST:
297  if(!pAdjItem)
298  pAdjItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
299  pTempItem = pAdjItem.get();
300  break;
301  case RES_BACKGROUND:
302  if(!pBackItem)
303  pBackItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
304  pTempItem = pBackItem.get();
305  break;
306  case RES_UL_SPACE:
307  if(!pULItem)
308  pULItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
309  pTempItem = pULItem.get();
310  break;
311  case RES_LR_SPACE:
312  if(!pLRItem)
313  pLRItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
314  pTempItem = pLRItem.get();
315  break;
316  case RES_KEEP:
317  if(!pKeepItem)
318  pKeepItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
319  pTempItem = pKeepItem.get();
320  break;
321  case RES_LINENUMBER:
322  if(!pLineNumItem)
323  pLineNumItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
324  pTempItem = pLineNumItem.get();
325  break;
327  if(!pLineSpaceItem)
328  pLineSpaceItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
329  pTempItem = pLineSpaceItem.get();
330  break;
331  case RES_PARATR_REGISTER:
332  if(!pRegItem)
333  pRegItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
334  pTempItem = pRegItem.get();
335  break;
336  case RES_PARATR_SPLIT:
337  if(!pSplitItem)
338  pSplitItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
339  pTempItem = pSplitItem.get();
340  break;
341  case RES_PARATR_TABSTOP:
342  if(!pTabItem)
343  pTabItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
344  pTempItem = pTabItem.get();
345  break;
347  if(!pWLineItem)
348  pWLineItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
349  pTempItem = pWLineItem.get();
350  break;
351  case RES_CHRATR_CJK_FONT:
352  if(!pFontCJKItem )
353  pFontCJKItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
354  pTempItem = pFontCJKItem.get();
355  break;
357  if(!pFontSizeCJKItem )
358  pFontSizeCJKItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
359  pTempItem = pFontSizeCJKItem.get();
360  break;
362  if(!pCJKLangItem )
363  pCJKLangItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
364  pTempItem = pCJKLangItem.get();
365  break;
367  if(!pCJKPostureItem )
368  pCJKPostureItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
369  pTempItem = pCJKPostureItem.get();
370  break;
372  if(!pCJKWeightItem )
373  pCJKWeightItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
374  pTempItem = pCJKWeightItem.get();
375  break;
376  case RES_CHRATR_CTL_FONT:
377  if(!pFontCTLItem )
378  pFontCTLItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
379  pTempItem = pFontCTLItem.get();
380  break;
382  if(!pFontSizeCTLItem )
383  pFontSizeCTLItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
384  pTempItem = pFontSizeCTLItem.get();
385  break;
387  if(!pCTLLangItem )
388  pCTLLangItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
389  pTempItem = pCTLLangItem.get();
390  break;
392  if(!pCTLPostureItem )
393  pCTLPostureItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
394  pTempItem = pCTLPostureItem.get();
395  break;
397  if(!pCTLWeightItem )
398  pCTLWeightItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
399  pTempItem = pCTLWeightItem.get();
400  break;
401  case RES_CHRATR_SHADOW:
402  if(!pShadowItem )
403  pShadowItem.reset(rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone());
404  pTempItem = pShadowItem.get();
405  break;
406  }
407  if(pTempItem)
408  {
409  if(bIsValueSearch)
410  {
411  pTempItem->PutValue(pValueArr[i]->Value, aIt->nMemberId);
412  rSet.Put(*pTempItem);
413  }
414  else
415  rSet.InvalidateItem( pTempItem->Which() );
416  }
417  }
418  }
419 }
420 
422 {
423  for(size_t i = 0; i < aPropertyEntries.size(); i++)
424  if(pValueArr[i])
425  return true;
426  return false;
427 }
428 
430  m_pSearchProperties( new SwSearchProperties_Impl),
431  m_pReplaceProperties( new SwSearchProperties_Impl),
432  m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_SEARCH)),
433  m_bAll(false),
434  m_bWord(false),
435  m_bBack(false),
436  m_bExpr(false),
437  m_bCase(false),
438  m_bStyles(false),
439  m_bSimilarity(false),
440  m_bLevRelax(false),
441  m_nLevExchange(2),
442  m_nLevAdd(2),
443  m_nLevRemove(2),
444  m_bIsValueSearch(true)
445 {
446 }
447 
449 {
450  m_pSearchProperties.reset();
451  m_pReplaceProperties.reset();
452 }
453 
454 namespace
455 {
456  class theSwXTextSearchUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextSearchUnoTunnelId > {};
457 }
458 
459 const uno::Sequence< sal_Int8 > & SwXTextSearch::getUnoTunnelId()
460 {
461  return theSwXTextSearchUnoTunnelId::get().getSeq();
462 }
463 
464 sal_Int64 SAL_CALL SwXTextSearch::getSomething( const uno::Sequence< sal_Int8 >& rId )
465 {
466  if( rId.getLength() == 16
467  && 0 == memcmp( getUnoTunnelId().getConstArray(),
468  rId.getConstArray(), 16 ) )
469  {
470  return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
471  }
472  return 0;
473 }
474 
476 {
477  SolarMutexGuard aGuard;
478  return m_sSearchText;
479 }
480 
481 void SwXTextSearch::setSearchString(const OUString& rString)
482 {
483  SolarMutexGuard aGuard;
484  m_sSearchText = rString;
485 }
486 
488 {
489  SolarMutexGuard aGuard;
490  return m_sReplaceText;
491 }
492 
493 void SwXTextSearch::setReplaceString(const OUString& rReplaceString)
494 {
495  SolarMutexGuard aGuard;
496  m_sReplaceText = rReplaceString;
497 }
498 
499 uno::Reference< beans::XPropertySetInfo > SwXTextSearch::getPropertySetInfo()
500 {
501  static uno::Reference< beans::XPropertySetInfo > aRef = m_pPropSet->getPropertySetInfo();
502  return aRef;
503 }
504 
505 void SwXTextSearch::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
506 {
507  SolarMutexGuard aGuard;
508  const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName(rPropertyName);
509  if(!pEntry)
510  throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
511 
512  if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
513  throw beans::PropertyVetoException ("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
514  bool bVal = false;
515  if(auto b = o3tl::tryAccess<bool>(aValue))
516  bVal = *b;
517  switch(pEntry->nWID)
518  {
519  case WID_SEARCH_ALL : m_bAll = bVal; break;
520  case WID_WORDS: m_bWord = bVal; break;
521  case WID_BACKWARDS : m_bBack = bVal; break;
522  case WID_REGULAR_EXPRESSION : m_bExpr = bVal; break;
523  case WID_CASE_SENSITIVE : m_bCase = bVal; break;
524  //case WID_IN_SELECTION : bInSel = bVal; break;
525  case WID_STYLES : m_bStyles = bVal; break;
526  case WID_SIMILARITY : m_bSimilarity = bVal; break;
527  case WID_SIMILARITY_RELAX: m_bLevRelax = bVal; break;
528  case WID_SIMILARITY_EXCHANGE: aValue >>= m_nLevExchange; break;
529  case WID_SIMILARITY_ADD: aValue >>= m_nLevAdd; break;
530  case WID_SIMILARITY_REMOVE : aValue >>= m_nLevRemove;break;
531  };
532 
533 }
534 
535 uno::Any SwXTextSearch::getPropertyValue(const OUString& rPropertyName)
536 {
537  SolarMutexGuard aGuard;
538  uno::Any aRet;
539 
540  const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName(rPropertyName);
541  bool bSet = false;
542  if(!pEntry)
543  throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
544 
545  sal_Int16 nSet = 0;
546  switch(pEntry->nWID)
547  {
548  case WID_SEARCH_ALL : bSet = m_bAll; goto SET_BOOL;
549  case WID_WORDS: bSet = m_bWord; goto SET_BOOL;
550  case WID_BACKWARDS : bSet = m_bBack; goto SET_BOOL;
551  case WID_REGULAR_EXPRESSION : bSet = m_bExpr; goto SET_BOOL;
552  case WID_CASE_SENSITIVE : bSet = m_bCase; goto SET_BOOL;
553  //case WID_IN_SELECTION : bSet = bInSel; goto SET_BOOL;
554  case WID_STYLES : bSet = m_bStyles; goto SET_BOOL;
555  case WID_SIMILARITY : bSet = m_bSimilarity; goto SET_BOOL;
556  case WID_SIMILARITY_RELAX: bSet = m_bLevRelax;
557 SET_BOOL:
558  aRet <<= bSet;
559  break;
560  case WID_SIMILARITY_EXCHANGE: nSet = m_nLevExchange; goto SET_UINT16;
561  case WID_SIMILARITY_ADD: nSet = m_nLevAdd; goto SET_UINT16;
562  case WID_SIMILARITY_REMOVE : nSet = m_nLevRemove;
563 SET_UINT16:
564  aRet <<= nSet;
565  break;
566  };
567 
568  return aRet;
569 }
570 
571 void SwXTextSearch::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
572 {
573  OSL_FAIL("not implemented");
574 }
575 
576 void SwXTextSearch::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
577 {
578  OSL_FAIL("not implemented");
579 }
580 
581 void SwXTextSearch::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
582 {
583  OSL_FAIL("not implemented");
584 }
585 
586 void SwXTextSearch::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
587 {
588  OSL_FAIL("not implemented");
589 }
590 
592 {
593  SolarMutexGuard aGuard;
594  return m_bIsValueSearch;
595 }
596 
598 {
599  SolarMutexGuard aGuard;
600  m_bIsValueSearch = ValueSearch_;
601 }
602 
603 uno::Sequence< beans::PropertyValue > SwXTextSearch::getSearchAttributes()
604 {
605  return m_pSearchProperties->GetProperties();
606 }
607 
608 void SwXTextSearch::setSearchAttributes(const uno::Sequence< beans::PropertyValue >& rSearchAttribs)
609 {
610  m_pSearchProperties->SetProperties(rSearchAttribs);
611 }
612 
613 uno::Sequence< beans::PropertyValue > SwXTextSearch::getReplaceAttributes()
614 {
615  return m_pReplaceProperties->GetProperties();
616 }
617 
618 void SwXTextSearch::setReplaceAttributes(const uno::Sequence< beans::PropertyValue >& rReplaceAttribs)
619 {
620  m_pReplaceProperties->SetProperties(rReplaceAttribs);
621 }
622 
624 {
625  m_pSearchProperties->FillItemSet(rSet, m_bIsValueSearch);
626 }
627 
629 {
630  m_pReplaceProperties->FillItemSet(rSet, m_bIsValueSearch);
631 }
632 
634 {
635  return m_pSearchProperties->HasAttributes();
636 }
637 
639 {
640  return m_pReplaceProperties->HasAttributes();
641 }
642 
644 {
645  return "SwXTextSearch";
646 }
647 
648 sal_Bool SwXTextSearch::supportsService(const OUString& rServiceName)
649 {
650  return cppu::supportsService(this, rServiceName);
651 }
652 
653 uno::Sequence< OUString > SwXTextSearch::getSupportedServiceNames()
654 {
655  return { "com.sun.star.util.SearchDescriptor", "com.sun.star.util.ReplaceDescriptor" };
656 }
657 
659 {
660  if( m_bSimilarity )
661  {
662  rSearchOpt.algorithmType = util::SearchAlgorithms_APPROXIMATE;
663  rSearchOpt.AlgorithmType2 = util::SearchAlgorithms2::APPROXIMATE;
664  rSearchOpt.changedChars = m_nLevExchange;
665  rSearchOpt.deletedChars = m_nLevRemove;
666  rSearchOpt.insertedChars = m_nLevAdd;
667  if( m_bLevRelax )
668  rSearchOpt.searchFlag |= util::SearchFlags::LEV_RELAXED;
669  }
670  else if( m_bExpr )
671  {
672  rSearchOpt.algorithmType = util::SearchAlgorithms_REGEXP;
673  rSearchOpt.AlgorithmType2 = util::SearchAlgorithms2::REGEXP;
674  }
675  else
676  {
677  rSearchOpt.algorithmType = util::SearchAlgorithms_ABSOLUTE;
678  rSearchOpt.AlgorithmType2 = util::SearchAlgorithms2::ABSOLUTE;
679  }
680 
681  rSearchOpt.Locale = GetAppLanguageTag().getLocale();
682  rSearchOpt.searchString = m_sSearchText;
683  rSearchOpt.replaceString = m_sReplaceText;
684 
685  if( !m_bCase )
686  rSearchOpt.transliterateFlags |= TransliterationFlags::IGNORE_CASE;
687  if( m_bWord )
688  rSearchOpt.searchFlag |= util::SearchFlags::NORM_WORD_ONLY;
689 
690 // bInSel: 1; // How is that possible?
691 // TODO: pSearch->bStyles!
692 // inSelection??
693 // aSrchParam.SetSrchInSelection(TypeConversion::toBOOL(aVal));
694 }
695 
696 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
Definition: unosrch.cxx:464
#define RES_CHRATR_WEIGHT
Definition: hintids.hxx:83
#define RES_CHRATR_CJK_LANGUAGE
Definition: hintids.hxx:92
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unosrch.cxx:653
bool HasReplaceAttributes() const
Definition: unosrch.cxx:638
#define WID_STYLES
Definition: unomap.hxx:138
#define PROPERTY_MAP_TEXT_CURSOR
Definition: unomap.hxx:29
#define RES_CHRATR_FONTSIZE
Definition: hintids.hxx:76
#define RES_CHRATR_LANGUAGE
Definition: hintids.hxx:78
std::unique_ptr< std::unique_ptr< beans::PropertyValue >[]> pValueArr
Definition: unosrch.cxx:46
bool HasSearchAttributes() const
Definition: unosrch.cxx:633
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
#define RES_CHRATR_CJK_POSTURE
Definition: hintids.hxx:93
#define RES_CHRATR_WORDLINEMODE
Definition: hintids.hxx:84
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: unosrch.cxx:576
#define WID_SIMILARITY_RELAX
Definition: unomap.hxx:140
sal_Int16 m_nLevRemove
Definition: unosrch.hxx:63
virtual void SAL_CALL setSearchString(const OUString &aString) override
Definition: unosrch.cxx:481
void FillSearchOptions(i18nutil::SearchOptions2 &rSearchOpt) const
Definition: unosrch.cxx:658
OUString m_sSearchText
Definition: unosrch.hxx:46
virtual ~SwXTextSearch() override
Definition: unosrch.cxx:448
void InvalidateItem(sal_uInt16 nWhich)
#define RES_CHRATR_CJK_WEIGHT
Definition: hintids.hxx:94
#define RES_CHRATR_FONT
Definition: hintids.hxx:75
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getReplaceAttributes() override
Definition: unosrch.cxx:613
#define RES_PARATR_REGISTER
Definition: hintids.hxx:169
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unosrch.cxx:581
#define RES_CHRATR_BLINK
Definition: hintids.hxx:86
#define RES_CHRATR_CJK_FONT
Definition: hintids.hxx:90
#define RES_CHRATR_CJK_FONTSIZE
Definition: hintids.hxx:91
#define RES_TXTATR_CHARFMT
Definition: hintids.hxx:142
#define RES_PARATR_SPLIT
Definition: hintids.hxx:163
#define WID_CASE_SENSITIVE
Definition: unomap.hxx:136
css::uno::Reference< css::beans::XPropertySetInfo > const & getPropertySetInfo() const
std::unique_ptr< SwSearchProperties_Impl > m_pSearchProperties
Definition: unosrch.hxx:49
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
bool m_bWord
Definition: unosrch.hxx:54
Value
bool m_bExpr
Definition: unosrch.hxx:56
const PropertyEntryVector_t aPropertyEntries
Definition: unosrch.cxx:47
#define RES_CHRATR_CTL_FONTSIZE
Definition: hintids.hxx:96
OUString m_sReplaceText
Definition: unosrch.hxx:47
#define RES_PARATR_TABSTOP
Definition: hintids.hxx:166
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
virtual void SAL_CALL setValueSearch(sal_Bool ValueSearch_) override
Definition: unosrch.cxx:597
#define RES_UL_SPACE
Definition: hintids.hxx:197
const SfxItemPropertySet * m_pPropSet
Definition: unosrch.hxx:52
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: unosrch.cxx:505
#define RES_CHRATR_CASEMAP
Definition: hintids.hxx:69
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId)
#define WID_BACKWARDS
Definition: unomap.hxx:134
css::lang::Locale Locale
#define WID_SEARCH_ALL
Definition: unomap.hxx:144
#define RES_BACKGROUND
Definition: hintids.hxx:210
#define WID_SIMILARITY_REMOVE
Definition: unomap.hxx:143
#define RES_CHRATR_COLOR
Definition: hintids.hxx:71
#define WID_SIMILARITY_EXCHANGE
Definition: unomap.hxx:141
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unosrch.cxx:499
#define RES_CHRATR_NOHYPHEN
Definition: hintids.hxx:87
bool m_bCase
Definition: unosrch.hxx:57
#define WID_WORDS
Definition: unomap.hxx:133
#define RES_CHRATR_OVERLINE
Definition: hintids.hxx:106
std::unique_ptr< SwSearchProperties_Impl > m_pReplaceProperties
Definition: unosrch.hxx:50
virtual OUString SAL_CALL getReplaceString() override
Definition: unosrch.cxx:487
#define RES_CHRATR_BACKGROUND
Definition: hintids.hxx:89
#define RES_CHRATR_CTL_FONT
Definition: hintids.hxx:95
#define RES_CHRATR_BOX
Definition: hintids.hxx:108
TransliterationFlags transliterateFlags
OUString sName
int i
unsigned char sal_Bool
const SfxItemPropertyMap & getPropertyMap() const
#define RES_CHRATR_UNDERLINE
Definition: hintids.hxx:82
#define RES_CHRATR_ESCAPEMENT
Definition: hintids.hxx:74
#define RES_LINENUMBER
Definition: hintids.hxx:221
bool m_bBack
Definition: unosrch.hxx:55
virtual OUString SAL_CALL getImplementationName() override
Definition: unosrch.cxx:643
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
#define RES_TXTATR_INETFMT
Definition: hintids.hxx:141
SfxItemPool * GetPool() const
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unosrch.cxx:648
const SfxItemPropertySimpleEntry * getByName(const OUString &rName) const
#define RES_CHRATR_CONTOUR
Definition: hintids.hxx:72
css::util::SearchAlgorithms algorithmType
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getSearchAttributes() override
Definition: unosrch.cxx:603
#define RES_CHRATR_KERNING
Definition: hintids.hxx:77
std::vector< SfxItemPropertyNamedEntry > PropertyEntryVector_t
#define RES_LR_SPACE
Definition: hintids.hxx:196
bool HasAttributes() const
Definition: unosrch.cxx:421
const LanguageTag & GetAppLanguageTag()
Definition: init.cxx:778
SwSearchProperties_Impl & operator=(const SwSearchProperties_Impl &)=delete
sal_Int16 m_nLevAdd
Definition: unosrch.hxx:62
void FillReplaceItemSet(SfxItemSet &rSet) const
Definition: unosrch.cxx:628
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unosrch.cxx:571
sal_Int16 m_nLevExchange
Definition: unosrch.hxx:61
#define RES_CHRATR_SHADOW
Definition: hintids.hxx:109
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
#define WID_REGULAR_EXPRESSION
Definition: unomap.hxx:135
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: unosrch.cxx:535
const uno::Sequence< beans::PropertyValue > GetProperties() const
Definition: unosrch.cxx:92
#define PROPERTY_MAP_TEXT_SEARCH
Definition: unomap.hxx:39
#define RES_CHRATR_CTL_LANGUAGE
Definition: hintids.hxx:97
#define RES_CHRATR_POSTURE
Definition: hintids.hxx:79
#define RES_CHRATR_CTL_WEIGHT
Definition: hintids.hxx:99
#define RES_CHRATR_CTL_POSTURE
Definition: hintids.hxx:98
virtual OUString SAL_CALL getSearchString() override
Definition: unosrch.cxx:475
#define RES_KEEP
Definition: hintids.hxx:215
void SetProperties(const uno::Sequence< beans::PropertyValue > &aSearchAttribs)
Definition: unosrch.cxx:72
virtual sal_Bool SAL_CALL getValueSearch() override
Definition: unosrch.cxx:591
SwUnoPropertyMapProvider aSwMapProvider
Definition: unomap1.cxx:131
#define RES_PARATR_ADJUST
Definition: hintids.hxx:162
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unosrch.cxx:586
#define RES_CHRATR_SHADOWED
Definition: hintids.hxx:81
virtual void SAL_CALL setReplaceString(const OUString &aReplaceString) override
Definition: unosrch.cxx:493
#define RES_CHRATR_AUTOKERN
Definition: hintids.hxx:85
#define RES_BOX
Definition: hintids.hxx:211
virtual void SAL_CALL setReplaceAttributes(const css::uno::Sequence< css::beans::PropertyValue > &aSearchAttribs) override
Definition: unosrch.cxx:618
#define WID_SIMILARITY
Definition: unomap.hxx:139
#define RES_CHRATR_CROSSEDOUT
Definition: hintids.hxx:73
#define RES_PARATR_DROP
Definition: hintids.hxx:168
detail::Optional< bool >::type tryAccess< bool >(css::uno::Any const &any)
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unosrch.cxx:459
void FillItemSet(SfxItemSet &rSet, bool bIsValueSearch) const
Definition: unosrch.cxx:112
void FillSearchItemSet(SfxItemSet &rSet) const
Definition: unosrch.cxx:623
#define RES_PAGEDESC
Definition: hintids.hxx:198
bool m_bStyles
Definition: unosrch.hxx:58
#define RES_BREAK
Definition: hintids.hxx:199
bool m_bIsValueSearch
Definition: unosrch.hxx:65
#define WID_SIMILARITY_ADD
Definition: unomap.hxx:142
sal_uInt16 Which() const
bool m_bSimilarity
Definition: unosrch.hxx:59
#define RES_PARATR_LINESPACING
Definition: hintids.hxx:161
virtual void SAL_CALL setSearchAttributes(const css::uno::Sequence< css::beans::PropertyValue > &aSearchAttribs) override
Definition: unosrch.cxx:608
bool m_bLevRelax
Definition: unosrch.hxx:60