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