tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / unoobj / srchuno.cxx
blob9312fdcd3c55bfd9ab4ac022133742629492b37a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <scitems.hxx>
21 #include <svl/srchitem.hxx>
22 #include <vcl/svapp.hxx>
23 #include <cppuhelper/supportsservice.hxx>
25 #include <srchuno.hxx>
26 #include <miscuno.hxx>
27 #include <unonames.hxx>
29 using namespace com::sun::star;
31 //! SearchWords searches in whole cells - rename it ???
33 // SfxItemPropertyMapEntry only for GetPropertySetInfo
35 static std::span<const SfxItemPropertyMapEntry> lcl_GetSearchPropertyMap()
37 static const SfxItemPropertyMapEntry aSearchPropertyMap_Impl[] =
39 { SC_UNO_SRCHBACK, 0, cppu::UnoType<bool>::get(), 0, 0},
40 { SC_UNO_SRCHBYROW, 0, cppu::UnoType<bool>::get(), 0, 0},
41 { SC_UNO_SRCHCASE, 0, cppu::UnoType<bool>::get(), 0, 0},
42 { SC_UNO_SRCHREGEXP, 0, cppu::UnoType<bool>::get(), 0, 0},
43 { SC_UNO_SRCHWILDCARD, 0, cppu::UnoType<bool>::get(), 0, 0},
44 { SC_UNO_SRCHSIM, 0, cppu::UnoType<bool>::get(), 0, 0},
45 { SC_UNO_SRCHSIMADD, 0, cppu::UnoType<sal_Int16>::get(), 0, 0},
46 { SC_UNO_SRCHSIMEX, 0, cppu::UnoType<sal_Int16>::get(), 0, 0},
47 { SC_UNO_SRCHSIMREL, 0, cppu::UnoType<bool>::get(), 0, 0},
48 { SC_UNO_SRCHSIMREM, 0, cppu::UnoType<sal_Int16>::get(), 0, 0},
49 { SC_UNO_SRCHSTYLES, 0, cppu::UnoType<bool>::get(), 0, 0},
50 { SC_UNO_SRCHTYPE, 0, cppu::UnoType<sal_Int16>::get(), 0, 0}, // enum TableSearch is gone
51 { SC_UNO_SRCHWORDS, 0, cppu::UnoType<bool>::get(), 0, 0},
52 { SC_UNO_SRCHWCESCCHAR, 0, cppu::UnoType<sal_Int32>::get(), 0, 0 },
54 return aSearchPropertyMap_Impl;
57 constexpr OUString SCSEARCHDESCRIPTOR_SERVICE = u"com.sun.star.util.SearchDescriptor"_ustr;
58 constexpr OUString SCREPLACEDESCRIPTOR_SERVICE = u"com.sun.star.util.ReplaceDescriptor"_ustr;
60 ScCellSearchObj::ScCellSearchObj() :
61 aPropSet(lcl_GetSearchPropertyMap()),
62 pSearchItem( new SvxSearchItem( SCITEM_SEARCHDATA ) )
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);
83 // Selection-Flag will be set when this is called
86 ScCellSearchObj::~ScCellSearchObj()
90 // XSearchDescriptor
92 OUString SAL_CALL ScCellSearchObj::getSearchString()
94 SolarMutexGuard aGuard;
95 return pSearchItem->GetSearchString();
98 void SAL_CALL ScCellSearchObj::setSearchString( const OUString& aString )
100 SolarMutexGuard aGuard;
101 pSearchItem->SetSearchString( aString );
104 // XReplaceDescriptor
106 OUString SAL_CALL ScCellSearchObj::getReplaceString()
108 SolarMutexGuard aGuard;
109 return pSearchItem->GetReplaceString();
112 void SAL_CALL ScCellSearchObj::setReplaceString( const OUString& aReplaceString )
114 SolarMutexGuard aGuard;
115 pSearchItem->SetReplaceString( aReplaceString );
118 // XPropertySet
120 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellSearchObj::getPropertySetInfo()
122 SolarMutexGuard aGuard;
123 static uno::Reference<beans::XPropertySetInfo> aRef(
124 new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
125 return aRef;
128 void SAL_CALL ScCellSearchObj::setPropertyValue(
129 const OUString& aPropertyName, const uno::Any& aValue )
131 SolarMutexGuard aGuard;
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 else if (aPropertyName == SC_UNO_SRCHWCESCCHAR) pSearchItem->SetWildcardEscapeCharacter( ScUnoHelpFunctions::GetInt32FromAny(aValue) );
151 uno::Any SAL_CALL ScCellSearchObj::getPropertyValue( const OUString& aPropertyName )
153 SolarMutexGuard aGuard;
154 uno::Any aRet;
156 if (aPropertyName == SC_UNO_SRCHBACK) aRet <<= pSearchItem->GetBackward();
157 else if (aPropertyName == SC_UNO_SRCHBYROW) aRet <<= pSearchItem->GetRowDirection();
158 else if (aPropertyName == SC_UNO_SRCHCASE) aRet <<= pSearchItem->GetExact();
159 else if (aPropertyName == SC_UNO_SRCHREGEXP) aRet <<= pSearchItem->GetRegExp();
160 else if (aPropertyName == SC_UNO_SRCHWILDCARD) aRet <<= pSearchItem->GetWildcard();
161 else if (aPropertyName == SC_UNO_SRCHSIM) aRet <<= pSearchItem->IsLevenshtein();
162 else if (aPropertyName == SC_UNO_SRCHSIMREL) aRet <<= pSearchItem->IsLEVRelaxed();
163 else if (aPropertyName == SC_UNO_SRCHSTYLES) aRet <<= pSearchItem->GetPattern();
164 else if (aPropertyName == SC_UNO_SRCHWORDS) aRet <<= pSearchItem->GetWordOnly();
165 else if (aPropertyName == SC_UNO_SRCHSIMADD) aRet <<= static_cast<sal_Int16>(pSearchItem->GetLEVLonger());
166 else if (aPropertyName == SC_UNO_SRCHSIMEX) aRet <<= static_cast<sal_Int16>(pSearchItem->GetLEVOther());
167 else if (aPropertyName == SC_UNO_SRCHSIMREM) aRet <<= static_cast<sal_Int16>(pSearchItem->GetLEVShorter());
168 else if (aPropertyName == SC_UNO_SRCHTYPE) aRet <<= static_cast<sal_Int16>(pSearchItem->GetCellType());
169 else if (aPropertyName == SC_UNO_SRCHFILTERED) aRet <<= pSearchItem->IsSearchFiltered();
170 else if (aPropertyName == SC_UNO_SRCHFORMATTED) aRet <<= pSearchItem->IsSearchFormatted();
171 else if (aPropertyName == SC_UNO_SRCHWCESCCHAR) aRet <<= pSearchItem->GetWildcardEscapeCharacter();
173 return aRet;
176 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScCellSearchObj )
178 // XServiceInfo
180 OUString SAL_CALL ScCellSearchObj::getImplementationName()
182 return u"ScCellSearchObj"_ustr;
185 sal_Bool SAL_CALL ScCellSearchObj::supportsService( const OUString& rServiceName )
187 return cppu::supportsService(this, rServiceName);
190 uno::Sequence<OUString> SAL_CALL ScCellSearchObj::getSupportedServiceNames()
192 return {SCSEARCHDESCRIPTOR_SERVICE, SCREPLACEDESCRIPTOR_SERVICE};
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */