LCOV - code coverage report
Current view: top level - sc/source/ui/unoobj - srchuno.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 116 0.0 %
Date: 2014-04-14 Functions: 0 24 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             : #include "scitems.hxx"
      21             : #include <svl/srchitem.hxx>
      22             : #include <vcl/svapp.hxx>
      23             : #include <osl/mutex.hxx>
      24             : #include <comphelper/servicehelper.hxx>
      25             : #include <cppuhelper/supportsservice.hxx>
      26             : 
      27             : #include "srchuno.hxx"
      28             : #include "docsh.hxx"
      29             : #include "undoblk.hxx"
      30             : #include "hints.hxx"
      31             : #include "markdata.hxx"
      32             : #include "miscuno.hxx"
      33             : #include "unonames.hxx"
      34             : 
      35             : using namespace com::sun::star;
      36             : 
      37             : //! SearchWords sucht in ganzen Zellen - umbenennen ???
      38             : 
      39             : //  SfxItemPropertyMapEntry nur fuer GetPropertySetInfo
      40             : 
      41           0 : static const SfxItemPropertyMapEntry* lcl_GetSearchPropertyMap()
      42             : {
      43             :     static const SfxItemPropertyMapEntry aSearchPropertyMap_Impl[] =
      44             :     {
      45           0 :         {OUString(SC_UNO_SRCHBACK),     0,      getBooleanCppuType(),       0, 0},
      46           0 :         {OUString(SC_UNO_SRCHBYROW),    0,      getBooleanCppuType(),       0, 0},
      47           0 :         {OUString(SC_UNO_SRCHCASE),     0,      getBooleanCppuType(),       0, 0},
      48           0 :         {OUString(SC_UNO_SRCHREGEXP),   0,      getBooleanCppuType(),       0, 0},
      49           0 :         {OUString(SC_UNO_SRCHSIM),      0,      getBooleanCppuType(),       0, 0},
      50           0 :         {OUString(SC_UNO_SRCHSIMADD),   0,      getCppuType((sal_Int16*)0), 0, 0},
      51           0 :         {OUString(SC_UNO_SRCHSIMEX),    0,      getCppuType((sal_Int16*)0), 0, 0},
      52           0 :         {OUString(SC_UNO_SRCHSIMREL),   0,      getBooleanCppuType(),       0, 0},
      53           0 :         {OUString(SC_UNO_SRCHSIMREM),   0,      getCppuType((sal_Int16*)0), 0, 0},
      54           0 :         {OUString(SC_UNO_SRCHSTYLES),   0,      getBooleanCppuType(),       0, 0},
      55           0 :         {OUString(SC_UNO_SRCHTYPE),     0,      getCppuType((sal_Int16*)0), 0, 0}, // enum TableSearch ist weg
      56           0 :         {OUString(SC_UNO_SRCHWORDS),    0,      getBooleanCppuType(),       0, 0},
      57             :         { OUString(), 0, css::uno::Type(), 0, 0 }
      58           0 :     };
      59           0 :     return aSearchPropertyMap_Impl;
      60             : }
      61             : 
      62             : #define SCSEARCHDESCRIPTOR_SERVICE      "com.sun.star.util.SearchDescriptor"
      63             : #define SCREPLACEDESCRIPTOR_SERVICE     "com.sun.star.util.ReplaceDescriptor"
      64             : 
      65           0 : ScCellSearchObj::ScCellSearchObj() :
      66           0 :     aPropSet(lcl_GetSearchPropertyMap())
      67             : {
      68           0 :     pSearchItem = new SvxSearchItem( SCITEM_SEARCHDATA );
      69             :     //  Defaults:
      70           0 :     pSearchItem->SetWordOnly(false);
      71           0 :     pSearchItem->SetExact(false);
      72           0 :     pSearchItem->SetMatchFullHalfWidthForms(false);
      73           0 :     pSearchItem->SetUseAsianOptions(false);     // or all asian bits would have to be handled
      74           0 :     pSearchItem->SetBackward(false);
      75           0 :     pSearchItem->SetSelection(false);
      76           0 :     pSearchItem->SetRegExp(false);
      77           0 :     pSearchItem->SetPattern(false);
      78           0 :     pSearchItem->SetLevenshtein(false);
      79           0 :     pSearchItem->SetLEVRelaxed(false);
      80           0 :     pSearchItem->SetLEVOther(2);
      81           0 :     pSearchItem->SetLEVShorter(2);
      82           0 :     pSearchItem->SetLEVLonger(2);
      83             :     //  Calc-Flags
      84           0 :     pSearchItem->SetRowDirection(false);
      85           0 :     pSearchItem->SetCellType(SVX_SEARCHIN_FORMULA);
      86             : 
      87             :     //  Selection-Flag wird beim Aufruf gesetzt
      88           0 : }
      89             : 
      90           0 : ScCellSearchObj::~ScCellSearchObj()
      91             : {
      92           0 :     delete pSearchItem;
      93           0 : }
      94             : 
      95             : // XSearchDescriptor
      96             : 
      97           0 : OUString SAL_CALL ScCellSearchObj::getSearchString() throw(uno::RuntimeException, std::exception)
      98             : {
      99           0 :     SolarMutexGuard aGuard;
     100           0 :     return pSearchItem->GetSearchString();
     101             : }
     102             : 
     103           0 : void SAL_CALL ScCellSearchObj::setSearchString( const OUString& aString )
     104             :                                                     throw(uno::RuntimeException, std::exception)
     105             : {
     106           0 :     SolarMutexGuard aGuard;
     107           0 :     pSearchItem->SetSearchString( aString );
     108           0 : }
     109             : 
     110             : // XReplaceDescriptor
     111             : 
     112           0 : OUString SAL_CALL ScCellSearchObj::getReplaceString() throw(uno::RuntimeException, std::exception)
     113             : {
     114           0 :     SolarMutexGuard aGuard;
     115           0 :     return pSearchItem->GetReplaceString();
     116             : }
     117             : 
     118           0 : void SAL_CALL ScCellSearchObj::setReplaceString( const OUString& aReplaceString )
     119             :                                                     throw(uno::RuntimeException, std::exception)
     120             : {
     121           0 :     SolarMutexGuard aGuard;
     122           0 :     pSearchItem->SetReplaceString( aReplaceString );
     123           0 : }
     124             : 
     125             : // XPropertySet
     126             : 
     127           0 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellSearchObj::getPropertySetInfo()
     128             :                                                         throw(uno::RuntimeException, std::exception)
     129             : {
     130           0 :     SolarMutexGuard aGuard;
     131             :     static uno::Reference<beans::XPropertySetInfo> aRef(
     132           0 :         new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
     133           0 :     return aRef;
     134             : }
     135             : 
     136           0 : void SAL_CALL ScCellSearchObj::setPropertyValue(
     137             :                         const OUString& aPropertyName, const uno::Any& aValue )
     138             :                 throw(beans::UnknownPropertyException, beans::PropertyVetoException,
     139             :                         lang::IllegalArgumentException, lang::WrappedTargetException,
     140             :                         uno::RuntimeException, std::exception)
     141             : {
     142           0 :     SolarMutexGuard aGuard;
     143           0 :     OUString aString(aPropertyName);
     144             : 
     145           0 :     if (aString.equalsAscii( SC_UNO_SRCHBACK ))        pSearchItem->SetBackward( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     146           0 :     else if (aString.equalsAscii( SC_UNO_SRCHBYROW ))  pSearchItem->SetRowDirection( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     147           0 :     else if (aString.equalsAscii( SC_UNO_SRCHCASE ))   pSearchItem->SetExact( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     148           0 :     else if (aString.equalsAscii( SC_UNO_SRCHREGEXP )) pSearchItem->SetRegExp( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     149           0 :     else if (aString.equalsAscii( SC_UNO_SRCHSIM ))    pSearchItem->SetLevenshtein( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     150           0 :     else if (aString.equalsAscii( SC_UNO_SRCHSIMREL )) pSearchItem->SetLEVRelaxed( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     151           0 :     else if (aString.equalsAscii( SC_UNO_SRCHSTYLES )) pSearchItem->SetPattern( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     152           0 :     else if (aString.equalsAscii( SC_UNO_SRCHWORDS ))  pSearchItem->SetWordOnly( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
     153           0 :     else if (aString.equalsAscii( SC_UNO_SRCHSIMADD )) pSearchItem->SetLEVLonger( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
     154           0 :     else if (aString.equalsAscii( SC_UNO_SRCHSIMEX ))  pSearchItem->SetLEVOther( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
     155           0 :     else if (aString.equalsAscii( SC_UNO_SRCHSIMREM )) pSearchItem->SetLEVShorter( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
     156           0 :     else if (aString.equalsAscii( SC_UNO_SRCHTYPE ))   pSearchItem->SetCellType( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
     157           0 :     else if (aString.equalsAscii( SC_UNO_SRCHFILTERED )) pSearchItem->SetSearchFiltered( ScUnoHelpFunctions::GetBoolFromAny(aValue) );
     158           0 : }
     159             : 
     160           0 : uno::Any SAL_CALL ScCellSearchObj::getPropertyValue( const OUString& aPropertyName )
     161             :                 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
     162             :                         uno::RuntimeException, std::exception)
     163             : {
     164           0 :     SolarMutexGuard aGuard;
     165           0 :     OUString aString(aPropertyName);
     166           0 :     uno::Any aRet;
     167             : 
     168           0 :     if (aString.equalsAscii( SC_UNO_SRCHBACK ))        ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->GetBackward() );
     169           0 :     else if (aString.equalsAscii( SC_UNO_SRCHBYROW ))  ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->GetRowDirection() );
     170           0 :     else if (aString.equalsAscii( SC_UNO_SRCHCASE ))   ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->GetExact() );
     171           0 :     else if (aString.equalsAscii( SC_UNO_SRCHREGEXP )) ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->GetRegExp() );
     172           0 :     else if (aString.equalsAscii( SC_UNO_SRCHSIM ))    ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->IsLevenshtein() );
     173           0 :     else if (aString.equalsAscii( SC_UNO_SRCHSIMREL )) ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->IsLEVRelaxed() );
     174           0 :     else if (aString.equalsAscii( SC_UNO_SRCHSTYLES )) ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->GetPattern() );
     175           0 :     else if (aString.equalsAscii( SC_UNO_SRCHWORDS ))  ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->GetWordOnly() );
     176           0 :     else if (aString.equalsAscii( SC_UNO_SRCHSIMADD )) aRet <<= (sal_Int16) pSearchItem->GetLEVLonger();
     177           0 :     else if (aString.equalsAscii( SC_UNO_SRCHSIMEX ))  aRet <<= (sal_Int16) pSearchItem->GetLEVOther();
     178           0 :     else if (aString.equalsAscii( SC_UNO_SRCHSIMREM )) aRet <<= (sal_Int16) pSearchItem->GetLEVShorter();
     179           0 :     else if (aString.equalsAscii( SC_UNO_SRCHTYPE ))   aRet <<= (sal_Int16) pSearchItem->GetCellType();
     180           0 :     else if (aString.equalsAscii( SC_UNO_SRCHFILTERED )) ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->IsSearchFiltered() );
     181             : 
     182           0 :     return aRet;
     183             : }
     184             : 
     185           0 : SC_IMPL_DUMMY_PROPERTY_LISTENER( ScCellSearchObj )
     186             : 
     187             : // XServiceInfo
     188             : 
     189           0 : OUString SAL_CALL ScCellSearchObj::getImplementationName() throw(uno::RuntimeException, std::exception)
     190             : {
     191           0 :     return OUString( "ScCellSearchObj" );
     192             : }
     193             : 
     194           0 : sal_Bool SAL_CALL ScCellSearchObj::supportsService( const OUString& rServiceName )
     195             :                                                     throw(uno::RuntimeException, std::exception)
     196             : {
     197           0 :     return cppu::supportsService(this, rServiceName);
     198             : }
     199             : 
     200           0 : uno::Sequence<OUString> SAL_CALL ScCellSearchObj::getSupportedServiceNames()
     201             :                                                     throw(uno::RuntimeException, std::exception)
     202             : {
     203           0 :     uno::Sequence<OUString> aRet(2);
     204           0 :     OUString* pArray = aRet.getArray();
     205           0 :     pArray[0] = OUString( SCSEARCHDESCRIPTOR_SERVICE );
     206           0 :     pArray[1] = OUString( SCREPLACEDESCRIPTOR_SERVICE );
     207           0 :     return aRet;
     208             : }
     209             : 
     210             : // XUnoTunnel
     211             : 
     212           0 : sal_Int64 SAL_CALL ScCellSearchObj::getSomething(
     213             :                 const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException, std::exception)
     214             : {
     215           0 :     if ( rId.getLength() == 16 &&
     216           0 :           0 == memcmp( getUnoTunnelId().getConstArray(),
     217           0 :                                     rId.getConstArray(), 16 ) )
     218             :     {
     219           0 :         return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
     220             :     }
     221           0 :     return 0;
     222             : }
     223             : 
     224             : namespace
     225             : {
     226             :     class theScCellSearchObjUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theScCellSearchObjUnoTunnelId> {};
     227             : }
     228             : 
     229           0 : const uno::Sequence<sal_Int8>& ScCellSearchObj::getUnoTunnelId()
     230             : {
     231           0 :     return theScCellSearchObjUnoTunnelId::get().getSeq();
     232             : }
     233             : 
     234           0 : ScCellSearchObj* ScCellSearchObj::getImplementation(
     235             :                                 const uno::Reference<util::XSearchDescriptor> xObj )
     236             : {
     237           0 :     ScCellSearchObj* pRet = NULL;
     238           0 :     uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
     239           0 :     if (xUT.is())
     240           0 :         pRet = reinterpret_cast<ScCellSearchObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
     241           0 :     return pRet;
     242           0 : }
     243             : 
     244             : 
     245             : 
     246             : 
     247             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10