LibreOffice Module sc (master)  1
srchuno.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <scitems.hxx>
21 #include <svl/srchitem.hxx>
22 #include <vcl/svapp.hxx>
24 
25 #include <srchuno.hxx>
26 #include <miscuno.hxx>
27 #include <unonames.hxx>
28 
29 using namespace com::sun::star;
30 
32 
33 // SfxItemPropertyMapEntry only for GetPropertySetInfo
34 
36 {
37  static const SfxItemPropertyMapEntry aSearchPropertyMap_Impl[] =
38  {
39  {OUString(SC_UNO_SRCHBACK), 0, cppu::UnoType<bool>::get(), 0, 0},
40  {OUString(SC_UNO_SRCHBYROW), 0, cppu::UnoType<bool>::get(), 0, 0},
41  {OUString(SC_UNO_SRCHCASE), 0, cppu::UnoType<bool>::get(), 0, 0},
42  {OUString(SC_UNO_SRCHREGEXP), 0, cppu::UnoType<bool>::get(), 0, 0},
43  {OUString(SC_UNO_SRCHWILDCARD), 0, cppu::UnoType<bool>::get(), 0, 0},
44  {OUString(SC_UNO_SRCHSIM), 0, cppu::UnoType<bool>::get(), 0, 0},
45  {OUString(SC_UNO_SRCHSIMADD), 0, cppu::UnoType<sal_Int16>::get(), 0, 0},
46  {OUString(SC_UNO_SRCHSIMEX), 0, cppu::UnoType<sal_Int16>::get(), 0, 0},
47  {OUString(SC_UNO_SRCHSIMREL), 0, cppu::UnoType<bool>::get(), 0, 0},
48  {OUString(SC_UNO_SRCHSIMREM), 0, cppu::UnoType<sal_Int16>::get(), 0, 0},
49  {OUString(SC_UNO_SRCHSTYLES), 0, cppu::UnoType<bool>::get(), 0, 0},
50  {OUString(SC_UNO_SRCHTYPE), 0, cppu::UnoType<sal_Int16>::get(), 0, 0}, // enum TableSearch is gone
51  {OUString(SC_UNO_SRCHWORDS), 0, cppu::UnoType<bool>::get(), 0, 0},
52  { OUString(), 0, css::uno::Type(), 0, 0 }
53  };
54  return aSearchPropertyMap_Impl;
55 }
56 
57 #define SCSEARCHDESCRIPTOR_SERVICE "com.sun.star.util.SearchDescriptor"
58 #define SCREPLACEDESCRIPTOR_SERVICE "com.sun.star.util.ReplaceDescriptor"
59 
61  aPropSet(lcl_GetSearchPropertyMap()),
62  pSearchItem( new SvxSearchItem( SCITEM_SEARCHDATA ) )
63 {
64  // Defaults:
65  pSearchItem->SetWordOnly(false);
66  pSearchItem->SetExact(false);
67  pSearchItem->SetMatchFullHalfWidthForms(false);
68  pSearchItem->SetUseAsianOptions(false); // or all asian bits would have to be handled
69  pSearchItem->SetBackward(false);
70  pSearchItem->SetSelection(false);
71  pSearchItem->SetRegExp(false);
72  pSearchItem->SetWildcard(false);
73  pSearchItem->SetPattern(false);
74  pSearchItem->SetLevenshtein(false);
75  pSearchItem->SetLEVRelaxed(false);
76  pSearchItem->SetLEVOther(2);
77  pSearchItem->SetLEVShorter(2);
78  pSearchItem->SetLEVLonger(2);
79  // Calc-Flags
80  pSearchItem->SetRowDirection(false);
81  pSearchItem->SetCellType(SvxSearchCellType::FORMULA);
82 
83  // Selection-Flag will be set when this is called
84 }
85 
87 {
88 }
89 
90 // XSearchDescriptor
91 
93 {
94  SolarMutexGuard aGuard;
95  return pSearchItem->GetSearchString();
96 }
97 
98 void SAL_CALL ScCellSearchObj::setSearchString( const OUString& aString )
99 {
100  SolarMutexGuard aGuard;
101  pSearchItem->SetSearchString( aString );
102 }
103 
104 // XReplaceDescriptor
105 
107 {
108  SolarMutexGuard aGuard;
109  return pSearchItem->GetReplaceString();
110 }
111 
112 void SAL_CALL ScCellSearchObj::setReplaceString( const OUString& aReplaceString )
113 {
114  SolarMutexGuard aGuard;
115  pSearchItem->SetReplaceString( aReplaceString );
116 }
117 
118 // XPropertySet
119 
120 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellSearchObj::getPropertySetInfo()
121 {
122  SolarMutexGuard aGuard;
123  static uno::Reference<beans::XPropertySetInfo> aRef(
125  return aRef;
126 }
127 
129  const OUString& aPropertyName, const uno::Any& aValue )
130 {
131  SolarMutexGuard aGuard;
132 
133  if (aPropertyName == SC_UNO_SRCHBACK) pSearchItem->SetBackward( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
134  else if (aPropertyName == SC_UNO_SRCHBYROW) pSearchItem->SetRowDirection( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
135  else if (aPropertyName == SC_UNO_SRCHCASE) pSearchItem->SetExact( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
136  else if (aPropertyName == SC_UNO_SRCHREGEXP) pSearchItem->SetRegExp( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
137  else if (aPropertyName == SC_UNO_SRCHWILDCARD) pSearchItem->SetWildcard( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
138  else if (aPropertyName == SC_UNO_SRCHSIM) pSearchItem->SetLevenshtein( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
139  else if (aPropertyName == SC_UNO_SRCHSIMREL) pSearchItem->SetLEVRelaxed( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
140  else if (aPropertyName == SC_UNO_SRCHSTYLES) pSearchItem->SetPattern( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
141  else if (aPropertyName == SC_UNO_SRCHWORDS) pSearchItem->SetWordOnly( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
142  else if (aPropertyName == SC_UNO_SRCHSIMADD) pSearchItem->SetLEVLonger( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
143  else if (aPropertyName == SC_UNO_SRCHSIMEX) pSearchItem->SetLEVOther( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
144  else if (aPropertyName == SC_UNO_SRCHSIMREM) pSearchItem->SetLEVShorter( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
145  else if (aPropertyName == SC_UNO_SRCHTYPE) pSearchItem->SetCellType( static_cast<SvxSearchCellType>(ScUnoHelpFunctions::GetInt16FromAny( aValue )) );
146  else if (aPropertyName == SC_UNO_SRCHFILTERED) pSearchItem->SetSearchFiltered( ScUnoHelpFunctions::GetBoolFromAny(aValue) );
147  else if (aPropertyName == SC_UNO_SRCHFORMATTED) pSearchItem->SetSearchFormatted( ScUnoHelpFunctions::GetBoolFromAny(aValue) );
148 }
149 
150 uno::Any SAL_CALL ScCellSearchObj::getPropertyValue( const OUString& aPropertyName )
151 {
152  SolarMutexGuard aGuard;
153  uno::Any aRet;
154 
155  if (aPropertyName == SC_UNO_SRCHBACK) aRet <<= pSearchItem->GetBackward();
156  else if (aPropertyName == SC_UNO_SRCHBYROW) aRet <<= pSearchItem->GetRowDirection();
157  else if (aPropertyName == SC_UNO_SRCHCASE) aRet <<= pSearchItem->GetExact();
158  else if (aPropertyName == SC_UNO_SRCHREGEXP) aRet <<= pSearchItem->GetRegExp();
159  else if (aPropertyName == SC_UNO_SRCHWILDCARD) aRet <<= pSearchItem->GetWildcard();
160  else if (aPropertyName == SC_UNO_SRCHSIM) aRet <<= pSearchItem->IsLevenshtein();
161  else if (aPropertyName == SC_UNO_SRCHSIMREL) aRet <<= pSearchItem->IsLEVRelaxed();
162  else if (aPropertyName == SC_UNO_SRCHSTYLES) aRet <<= pSearchItem->GetPattern();
163  else if (aPropertyName == SC_UNO_SRCHWORDS) aRet <<= pSearchItem->GetWordOnly();
164  else if (aPropertyName == SC_UNO_SRCHSIMADD) aRet <<= static_cast<sal_Int16>(pSearchItem->GetLEVLonger());
165  else if (aPropertyName == SC_UNO_SRCHSIMEX) aRet <<= static_cast<sal_Int16>(pSearchItem->GetLEVOther());
166  else if (aPropertyName == SC_UNO_SRCHSIMREM) aRet <<= static_cast<sal_Int16>(pSearchItem->GetLEVShorter());
167  else if (aPropertyName == SC_UNO_SRCHTYPE) aRet <<= static_cast<sal_Int16>(pSearchItem->GetCellType());
168  else if (aPropertyName == SC_UNO_SRCHFILTERED) aRet <<= pSearchItem->IsSearchFiltered();
169  else if (aPropertyName == SC_UNO_SRCHFORMATTED) aRet <<= pSearchItem->IsSearchFormatted();
170 
171  return aRet;
172 }
173 
175 
176 // XServiceInfo
177 
178 OUString SAL_CALL ScCellSearchObj::getImplementationName()
179 {
180  return "ScCellSearchObj";
181 }
182 
183 sal_Bool SAL_CALL ScCellSearchObj::supportsService( const OUString& rServiceName )
184 {
185  return cppu::supportsService(this, rServiceName);
186 }
187 
188 uno::Sequence<OUString> SAL_CALL ScCellSearchObj::getSupportedServiceNames()
189 {
191 }
192 
193 // XUnoTunnel
194 
196 
197 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define SC_UNO_SRCHSTYLES
Definition: unonames.hxx:383
#define SCSEARCHDESCRIPTOR_SERVICE
Definition: srchuno.cxx:57
#define SC_UNO_SRCHSIMADD
Definition: unonames.hxx:379
#define SC_UNO_SRCHSIMREM
Definition: unonames.hxx:382
static const SfxItemPropertyMapEntry * lcl_GetSearchPropertyMap()
SearchWords searches in whole cells - rename it ???
Definition: srchuno.cxx:35
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: srchuno.cxx:150
std::unique_ptr< SvxSearchItem > pSearchItem
Definition: srchuno.hxx:41
virtual OUString SAL_CALL getSearchString() override
Definition: srchuno.cxx:92
#define SC_UNO_SRCHTYPE
Definition: unonames.hxx:384
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: srchuno.cxx:188
#define SC_UNO_SRCHCASE
Definition: unonames.hxx:375
#define SC_UNO_SRCHBYROW
Definition: unonames.hxx:374
#define SC_UNO_SRCHBACK
Definition: unonames.hxx:373
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: srchuno.cxx:120
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: srchuno.cxx:183
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
SfxItemPropertySet aPropSet
Definition: srchuno.hxx:39
virtual void SAL_CALL setReplaceString(const OUString &aReplaceString) override
Definition: srchuno.cxx:112
#define SC_UNO_SRCHSIMREL
Definition: unonames.hxx:381
#define SC_UNO_SRCHREGEXP
Definition: unonames.hxx:376
#define SC_UNO_SRCHWILDCARD
Definition: unonames.hxx:377
UNO3_GETIMPLEMENTATION_IMPL(ScCellSearchObj)
virtual void SAL_CALL setSearchString(const OUString &aString) override
Definition: srchuno.cxx:98
#define SC_UNO_SRCHSIMEX
Definition: unonames.hxx:380
#define SC_UNO_SRCHWORDS
Definition: unonames.hxx:385
#define SCITEM_SEARCHDATA
Definition: scitems.hxx:89
unsigned char sal_Bool
const SfxItemPropertyMap & getPropertyMap() const
virtual OUString SAL_CALL getReplaceString() override
Definition: srchuno.cxx:106
css::uno::Type const & get()
virtual ~ScCellSearchObj() override
Definition: srchuno.cxx:86
static sal_Int16 GetInt16FromAny(const css::uno::Any &aAny)
Definition: miscuno.cxx:144
#define SC_IMPL_DUMMY_PROPERTY_LISTENER(ClassName)
Definition: miscuno.hxx:73
#define SC_UNO_SRCHFORMATTED
Definition: unonames.hxx:387
#define SC_UNO_SRCHSIM
Definition: unonames.hxx:378
#define SC_UNO_SRCHFILTERED
Definition: unonames.hxx:386
static bool GetBoolFromAny(const css::uno::Any &aAny)
Definition: miscuno.cxx:138
#define SCREPLACEDESCRIPTOR_SERVICE
Definition: srchuno.cxx:58
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: srchuno.cxx:128