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