LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/unocore - unosrch.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 465 0.0 %
Date: 2012-12-27 Functions: 0 36 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10