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
29using namespace com::sun::star;
30
32
33// SfxItemPropertyMapEntry only for GetPropertySetInfo
34
36{
37 static const SfxItemPropertyMapEntry aSearchPropertyMap_Impl[] =
38 {
50 { SC_UNO_SRCHTYPE, 0, cppu::UnoType<sal_Int16>::get(), 0, 0}, // enum TableSearch is gone
52 };
53 return aSearchPropertyMap_Impl;
54}
55
56constexpr OUStringLiteral SCSEARCHDESCRIPTOR_SERVICE = u"com.sun.star.util.SearchDescriptor";
57constexpr OUStringLiteral SCREPLACEDESCRIPTOR_SERVICE = u"com.sun.star.util.ReplaceDescriptor";
58
60 aPropSet(lcl_GetSearchPropertyMap()),
61 pSearchItem( new SvxSearchItem( SCITEM_SEARCHDATA ) )
62{
63 // Defaults:
64 pSearchItem->SetWordOnly(false);
65 pSearchItem->SetExact(false);
66 pSearchItem->SetMatchFullHalfWidthForms(false);
67 pSearchItem->SetUseAsianOptions(false); // or all asian bits would have to be handled
68 pSearchItem->SetBackward(false);
69 pSearchItem->SetSelection(false);
70 pSearchItem->SetRegExp(false);
71 pSearchItem->SetWildcard(false);
72 pSearchItem->SetPattern(false);
73 pSearchItem->SetLevenshtein(false);
74 pSearchItem->SetLEVRelaxed(false);
75 pSearchItem->SetLEVOther(2);
76 pSearchItem->SetLEVShorter(2);
77 pSearchItem->SetLEVLonger(2);
78 // Calc-Flags
79 pSearchItem->SetRowDirection(false);
80 pSearchItem->SetCellType(SvxSearchCellType::FORMULA);
81
82 // Selection-Flag will be set when this is called
83}
84
86{
87}
88
89// XSearchDescriptor
90
92{
93 SolarMutexGuard aGuard;
94 return pSearchItem->GetSearchString();
95}
96
97void SAL_CALL ScCellSearchObj::setSearchString( const OUString& aString )
98{
99 SolarMutexGuard aGuard;
100 pSearchItem->SetSearchString( aString );
101}
102
103// XReplaceDescriptor
104
106{
107 SolarMutexGuard aGuard;
108 return pSearchItem->GetReplaceString();
109}
110
111void SAL_CALL ScCellSearchObj::setReplaceString( const OUString& aReplaceString )
112{
113 SolarMutexGuard aGuard;
114 pSearchItem->SetReplaceString( aReplaceString );
115}
116
117// XPropertySet
118
119uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellSearchObj::getPropertySetInfo()
120{
121 SolarMutexGuard aGuard;
122 static uno::Reference<beans::XPropertySetInfo> aRef(
124 return aRef;
125}
126
128 const OUString& aPropertyName, const uno::Any& aValue )
129{
130 SolarMutexGuard aGuard;
131
132 if (aPropertyName == SC_UNO_SRCHBACK) pSearchItem->SetBackward( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
133 else if (aPropertyName == SC_UNO_SRCHBYROW) pSearchItem->SetRowDirection( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
134 else if (aPropertyName == SC_UNO_SRCHCASE) pSearchItem->SetExact( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
135 else if (aPropertyName == SC_UNO_SRCHREGEXP) pSearchItem->SetRegExp( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
136 else if (aPropertyName == SC_UNO_SRCHWILDCARD) pSearchItem->SetWildcard( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
137 else if (aPropertyName == SC_UNO_SRCHSIM) pSearchItem->SetLevenshtein( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
138 else if (aPropertyName == SC_UNO_SRCHSIMREL) pSearchItem->SetLEVRelaxed( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
139 else if (aPropertyName == SC_UNO_SRCHSTYLES) pSearchItem->SetPattern( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
140 else if (aPropertyName == SC_UNO_SRCHWORDS) pSearchItem->SetWordOnly( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
141 else if (aPropertyName == SC_UNO_SRCHSIMADD) pSearchItem->SetLEVLonger( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
142 else if (aPropertyName == SC_UNO_SRCHSIMEX) pSearchItem->SetLEVOther( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
143 else if (aPropertyName == SC_UNO_SRCHSIMREM) pSearchItem->SetLEVShorter( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
144 else if (aPropertyName == SC_UNO_SRCHTYPE) pSearchItem->SetCellType( static_cast<SvxSearchCellType>(ScUnoHelpFunctions::GetInt16FromAny( aValue )) );
145 else if (aPropertyName == SC_UNO_SRCHFILTERED) pSearchItem->SetSearchFiltered( ScUnoHelpFunctions::GetBoolFromAny(aValue) );
146 else if (aPropertyName == SC_UNO_SRCHFORMATTED) pSearchItem->SetSearchFormatted( ScUnoHelpFunctions::GetBoolFromAny(aValue) );
147}
148
149uno::Any SAL_CALL ScCellSearchObj::getPropertyValue( const OUString& aPropertyName )
150{
151 SolarMutexGuard aGuard;
152 uno::Any aRet;
153
154 if (aPropertyName == SC_UNO_SRCHBACK) aRet <<= pSearchItem->GetBackward();
155 else if (aPropertyName == SC_UNO_SRCHBYROW) aRet <<= pSearchItem->GetRowDirection();
156 else if (aPropertyName == SC_UNO_SRCHCASE) aRet <<= pSearchItem->GetExact();
157 else if (aPropertyName == SC_UNO_SRCHREGEXP) aRet <<= pSearchItem->GetRegExp();
158 else if (aPropertyName == SC_UNO_SRCHWILDCARD) aRet <<= pSearchItem->GetWildcard();
159 else if (aPropertyName == SC_UNO_SRCHSIM) aRet <<= pSearchItem->IsLevenshtein();
160 else if (aPropertyName == SC_UNO_SRCHSIMREL) aRet <<= pSearchItem->IsLEVRelaxed();
161 else if (aPropertyName == SC_UNO_SRCHSTYLES) aRet <<= pSearchItem->GetPattern();
162 else if (aPropertyName == SC_UNO_SRCHWORDS) aRet <<= pSearchItem->GetWordOnly();
163 else if (aPropertyName == SC_UNO_SRCHSIMADD) aRet <<= static_cast<sal_Int16>(pSearchItem->GetLEVLonger());
164 else if (aPropertyName == SC_UNO_SRCHSIMEX) aRet <<= static_cast<sal_Int16>(pSearchItem->GetLEVOther());
165 else if (aPropertyName == SC_UNO_SRCHSIMREM) aRet <<= static_cast<sal_Int16>(pSearchItem->GetLEVShorter());
166 else if (aPropertyName == SC_UNO_SRCHTYPE) aRet <<= static_cast<sal_Int16>(pSearchItem->GetCellType());
167 else if (aPropertyName == SC_UNO_SRCHFILTERED) aRet <<= pSearchItem->IsSearchFiltered();
168 else if (aPropertyName == SC_UNO_SRCHFORMATTED) aRet <<= pSearchItem->IsSearchFormatted();
169
170 return aRet;
171}
172
174
175// XServiceInfo
176
177OUString SAL_CALL ScCellSearchObj::getImplementationName()
178{
179 return "ScCellSearchObj";
180}
181
182sal_Bool SAL_CALL ScCellSearchObj::supportsService( const OUString& rServiceName )
183{
184 return cppu::supportsService(this, rServiceName);
185}
186
187uno::Sequence<OUString> SAL_CALL ScCellSearchObj::getSupportedServiceNames()
188{
190}
191
192/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ~ScCellSearchObj() override
Definition: srchuno.cxx:85
virtual OUString SAL_CALL getReplaceString() override
Definition: srchuno.cxx:105
std::unique_ptr< SvxSearchItem > pSearchItem
Definition: srchuno.hxx:38
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: srchuno.cxx:119
virtual void SAL_CALL setReplaceString(const OUString &aReplaceString) override
Definition: srchuno.cxx:111
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: srchuno.cxx:149
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: srchuno.cxx:127
SfxItemPropertySet aPropSet
Definition: srchuno.hxx:36
virtual void SAL_CALL setSearchString(const OUString &aString) override
Definition: srchuno.cxx:97
virtual OUString SAL_CALL getSearchString() override
Definition: srchuno.cxx:91
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: srchuno.cxx:182
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: srchuno.cxx:187
static sal_Int16 GetInt16FromAny(const css::uno::Any &aAny)
Definition: miscuno.cxx:145
static bool GetBoolFromAny(const css::uno::Any &aAny)
Definition: miscuno.cxx:139
const SfxItemPropertyMap & getPropertyMap() const
css::uno::Type const & get()
float u
#define SC_IMPL_DUMMY_PROPERTY_LISTENER(ClassName)
Definition: miscuno.hxx:72
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
#define SCITEM_SEARCHDATA
Definition: scitems.hxx:89
SvxSearchCellType
static o3tl::span< const SfxItemPropertyMapEntry > lcl_GetSearchPropertyMap()
SearchWords searches in whole cells - rename it ???
Definition: srchuno.cxx:35
constexpr OUStringLiteral SCREPLACEDESCRIPTOR_SERVICE
Definition: srchuno.cxx:57
constexpr OUStringLiteral SCSEARCHDESCRIPTOR_SERVICE
Definition: srchuno.cxx:56
unsigned char sal_Bool
constexpr OUStringLiteral SC_UNO_SRCHWORDS
Definition: unonames.hxx:394
constexpr OUStringLiteral SC_UNO_SRCHREGEXP
Definition: unonames.hxx:385
constexpr OUStringLiteral SC_UNO_SRCHSIMADD
Definition: unonames.hxx:388
constexpr OUStringLiteral SC_UNO_SRCHSIMEX
Definition: unonames.hxx:389
constexpr OUStringLiteral SC_UNO_SRCHBACK
Definition: unonames.hxx:382
constexpr OUStringLiteral SC_UNO_SRCHSIM
Definition: unonames.hxx:387
constexpr OUStringLiteral SC_UNO_SRCHCASE
Definition: unonames.hxx:384
constexpr OUStringLiteral SC_UNO_SRCHFORMATTED
Definition: unonames.hxx:396
constexpr OUStringLiteral SC_UNO_SRCHSIMREL
Definition: unonames.hxx:390
constexpr OUStringLiteral SC_UNO_SRCHBYROW
Definition: unonames.hxx:383
constexpr OUStringLiteral SC_UNO_SRCHTYPE
Definition: unonames.hxx:393
constexpr OUStringLiteral SC_UNO_SRCHFILTERED
Definition: unonames.hxx:395
constexpr OUStringLiteral SC_UNO_SRCHSTYLES
Definition: unonames.hxx:392
constexpr OUStringLiteral SC_UNO_SRCHSIMREM
Definition: unonames.hxx:391
constexpr OUStringLiteral SC_UNO_SRCHWILDCARD
Definition: unonames.hxx:386