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

Generated by: LCOV version 1.10