Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "scitems.hxx"
30 : : #include <svl/srchitem.hxx>
31 : : #include <vcl/svapp.hxx>
32 : : #include <osl/mutex.hxx>
33 : : #include <comphelper/servicehelper.hxx>
34 : :
35 : : #include "srchuno.hxx"
36 : : #include "docsh.hxx"
37 : : #include "undoblk.hxx"
38 : : #include "hints.hxx"
39 : : #include "markdata.hxx"
40 : : #include "miscuno.hxx"
41 : : #include "unonames.hxx"
42 : :
43 : : using namespace com::sun::star;
44 : :
45 : : //------------------------------------------------------------------------
46 : :
47 : : //! SearchWords sucht in ganzen Zellen - umbenennen ???
48 : :
49 : : // SfxItemPropertyMapEntry nur fuer GetPropertySetInfo
50 : :
51 : 32 : const SfxItemPropertyMapEntry* lcl_GetSearchPropertyMap()
52 : : {
53 : : static SfxItemPropertyMapEntry aSearchPropertyMap_Impl[] =
54 : : {
55 [ + - ]: 5 : {MAP_CHAR_LEN(SC_UNO_SRCHBACK), 0, &getBooleanCppuType(), 0, 0},
56 [ + - ]: 5 : {MAP_CHAR_LEN(SC_UNO_SRCHBYROW), 0, &getBooleanCppuType(), 0, 0},
57 [ + - ]: 5 : {MAP_CHAR_LEN(SC_UNO_SRCHCASE), 0, &getBooleanCppuType(), 0, 0},
58 [ + - ]: 5 : {MAP_CHAR_LEN(SC_UNO_SRCHREGEXP), 0, &getBooleanCppuType(), 0, 0},
59 [ + - ]: 5 : {MAP_CHAR_LEN(SC_UNO_SRCHSIM), 0, &getBooleanCppuType(), 0, 0},
60 [ + - ]: 5 : {MAP_CHAR_LEN(SC_UNO_SRCHSIMADD), 0, &getCppuType((sal_Int16*)0), 0, 0},
61 [ + - ]: 5 : {MAP_CHAR_LEN(SC_UNO_SRCHSIMEX), 0, &getCppuType((sal_Int16*)0), 0, 0},
62 [ + - ]: 5 : {MAP_CHAR_LEN(SC_UNO_SRCHSIMREL), 0, &getBooleanCppuType(), 0, 0},
63 [ + - ]: 5 : {MAP_CHAR_LEN(SC_UNO_SRCHSIMREM), 0, &getCppuType((sal_Int16*)0), 0, 0},
64 [ + - ]: 5 : {MAP_CHAR_LEN(SC_UNO_SRCHSTYLES), 0, &getBooleanCppuType(), 0, 0},
65 [ + - ]: 5 : {MAP_CHAR_LEN(SC_UNO_SRCHTYPE), 0, &getCppuType((sal_Int16*)0), 0, 0}, // enum TableSearch ist weg
66 [ + - ]: 5 : {MAP_CHAR_LEN(SC_UNO_SRCHWORDS), 0, &getBooleanCppuType(), 0, 0},
67 : : {0,0,0,0,0,0}
68 [ + + ][ + - ]: 37 : };
[ # # ]
69 : 32 : return aSearchPropertyMap_Impl;
70 : : }
71 : :
72 : : //------------------------------------------------------------------------
73 : :
74 : : #define SCSEARCHDESCRIPTOR_SERVICE "com.sun.star.util.SearchDescriptor"
75 : : #define SCREPLACEDESCRIPTOR_SERVICE "com.sun.star.util.ReplaceDescriptor"
76 : :
77 : : //------------------------------------------------------------------------
78 : :
79 : 32 : ScCellSearchObj::ScCellSearchObj() :
80 [ + - ][ + - ]: 32 : aPropSet(lcl_GetSearchPropertyMap())
81 : : {
82 [ + - ][ + - ]: 32 : pSearchItem = new SvxSearchItem( SCITEM_SEARCHDATA );
83 : : // Defaults:
84 [ + - ]: 32 : pSearchItem->SetWordOnly(false);
85 [ + - ]: 32 : pSearchItem->SetExact(false);
86 [ + - ]: 32 : pSearchItem->SetMatchFullHalfWidthForms(false);
87 : 32 : pSearchItem->SetUseAsianOptions(false); // or all asian bits would have to be handled
88 : 32 : pSearchItem->SetBackward(false);
89 [ + - ]: 32 : pSearchItem->SetSelection(false);
90 [ + - ]: 32 : pSearchItem->SetRegExp(false);
91 : 32 : pSearchItem->SetPattern(false);
92 [ + - ]: 32 : pSearchItem->SetLevenshtein(false);
93 [ + - ]: 32 : pSearchItem->SetLEVRelaxed(false);
94 : 32 : pSearchItem->SetLEVOther(2);
95 : 32 : pSearchItem->SetLEVShorter(2);
96 : 32 : pSearchItem->SetLEVLonger(2);
97 : : // Calc-Flags
98 : 32 : pSearchItem->SetRowDirection(false);
99 : 32 : pSearchItem->SetCellType(SVX_SEARCHIN_FORMULA);
100 : :
101 : : // Selection-Flag wird beim Aufruf gesetzt
102 : 32 : }
103 : :
104 [ + - ]: 32 : ScCellSearchObj::~ScCellSearchObj()
105 : : {
106 [ + - ][ + - ]: 32 : delete pSearchItem;
107 [ - + ]: 64 : }
108 : :
109 : : // XSearchDescriptor
110 : :
111 : 3 : rtl::OUString SAL_CALL ScCellSearchObj::getSearchString() throw(uno::RuntimeException)
112 : : {
113 [ + - ]: 3 : SolarMutexGuard aGuard;
114 [ + - ][ + - ]: 3 : return pSearchItem->GetSearchString();
[ + - ][ + - ]
115 : : }
116 : :
117 : 47 : void SAL_CALL ScCellSearchObj::setSearchString( const rtl::OUString& aString )
118 : : throw(uno::RuntimeException)
119 : : {
120 [ + - ]: 47 : SolarMutexGuard aGuard;
121 [ + - ][ + - ]: 47 : pSearchItem->SetSearchString( aString );
[ + - ][ + - ]
122 : 47 : }
123 : :
124 : : // XReplaceDescriptor
125 : :
126 : 3 : rtl::OUString SAL_CALL ScCellSearchObj::getReplaceString() throw(uno::RuntimeException)
127 : : {
128 [ + - ]: 3 : SolarMutexGuard aGuard;
129 [ + - ][ + - ]: 3 : return pSearchItem->GetReplaceString();
[ + - ][ + - ]
130 : : }
131 : :
132 : 15 : void SAL_CALL ScCellSearchObj::setReplaceString( const rtl::OUString& aReplaceString )
133 : : throw(uno::RuntimeException)
134 : : {
135 [ + - ]: 15 : SolarMutexGuard aGuard;
136 [ + - ][ + - ]: 15 : pSearchItem->SetReplaceString( aReplaceString );
[ + - ][ + - ]
137 : 15 : }
138 : :
139 : : // XPropertySet
140 : :
141 : 21 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellSearchObj::getPropertySetInfo()
142 : : throw(uno::RuntimeException)
143 : : {
144 [ + - ]: 21 : SolarMutexGuard aGuard;
145 : : static uno::Reference<beans::XPropertySetInfo> aRef(
146 [ + + ][ + - ]: 21 : new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
[ + - ][ + - ]
[ + - ][ # # ]
147 [ + - ]: 21 : return aRef;
148 : : }
149 : :
150 : 34 : void SAL_CALL ScCellSearchObj::setPropertyValue(
151 : : const rtl::OUString& aPropertyName, const uno::Any& aValue )
152 : : throw(beans::UnknownPropertyException, beans::PropertyVetoException,
153 : : lang::IllegalArgumentException, lang::WrappedTargetException,
154 : : uno::RuntimeException)
155 : : {
156 [ + - ]: 34 : SolarMutexGuard aGuard;
157 [ + - ]: 34 : String aString(aPropertyName);
158 : :
159 [ + - ][ + + ]: 34 : if (aString.EqualsAscii( SC_UNO_SRCHBACK )) pSearchItem->SetBackward( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
[ + - ]
160 [ + - ][ + + ]: 31 : else if (aString.EqualsAscii( SC_UNO_SRCHBYROW )) pSearchItem->SetRowDirection( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
[ + - ]
161 [ + - ][ + + ]: 29 : else if (aString.EqualsAscii( SC_UNO_SRCHCASE )) pSearchItem->SetExact( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
[ + - ][ + - ]
162 [ + - ][ + + ]: 26 : else if (aString.EqualsAscii( SC_UNO_SRCHREGEXP )) pSearchItem->SetRegExp( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
[ + - ][ + - ]
163 [ + - ][ + + ]: 23 : else if (aString.EqualsAscii( SC_UNO_SRCHSIM )) pSearchItem->SetLevenshtein( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
[ + - ][ + - ]
164 [ + - ][ + + ]: 20 : else if (aString.EqualsAscii( SC_UNO_SRCHSIMREL )) pSearchItem->SetLEVRelaxed( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
[ + - ][ + - ]
165 [ + - ][ + + ]: 17 : else if (aString.EqualsAscii( SC_UNO_SRCHSTYLES )) pSearchItem->SetPattern( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
[ + - ]
166 [ + - ][ + + ]: 14 : else if (aString.EqualsAscii( SC_UNO_SRCHWORDS )) pSearchItem->SetWordOnly( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
[ + - ][ + - ]
167 [ + - ][ + + ]: 11 : else if (aString.EqualsAscii( SC_UNO_SRCHSIMADD )) pSearchItem->SetLEVLonger( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
[ + - ]
168 [ + - ][ + + ]: 8 : else if (aString.EqualsAscii( SC_UNO_SRCHSIMEX )) pSearchItem->SetLEVOther( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
[ + - ]
169 [ + - ][ + + ]: 5 : else if (aString.EqualsAscii( SC_UNO_SRCHSIMREM )) pSearchItem->SetLEVShorter( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
[ + - ]
170 [ + - ][ + - ]: 2 : else if (aString.EqualsAscii( SC_UNO_SRCHTYPE )) pSearchItem->SetCellType( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
[ + - ]
171 [ # # ][ # # ]: 34 : else if (aString.EqualsAscii( SC_UNO_SRCHFILTERED )) pSearchItem->SetSearchFiltered( ScUnoHelpFunctions::GetBoolFromAny(aValue) );
[ # # ][ + - ]
[ + - ]
172 : 34 : }
173 : :
174 : 80 : uno::Any SAL_CALL ScCellSearchObj::getPropertyValue( const rtl::OUString& aPropertyName )
175 : : throw(beans::UnknownPropertyException, lang::WrappedTargetException,
176 : : uno::RuntimeException)
177 : : {
178 [ + - ]: 80 : SolarMutexGuard aGuard;
179 [ + - ]: 80 : String aString(aPropertyName);
180 : 80 : uno::Any aRet;
181 : :
182 [ + + ][ + - ]: 80 : if (aString.EqualsAscii( SC_UNO_SRCHBACK )) ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->GetBackward() );
[ + - ]
183 [ + - ][ + + ]: 73 : else if (aString.EqualsAscii( SC_UNO_SRCHBYROW )) ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->GetRowDirection() );
[ + - ]
184 [ + - ][ + + ]: 68 : else if (aString.EqualsAscii( SC_UNO_SRCHCASE )) ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->GetExact() );
[ + - ]
185 [ + - ][ + + ]: 61 : else if (aString.EqualsAscii( SC_UNO_SRCHREGEXP )) ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->GetRegExp() );
[ + - ]
186 [ + - ][ + + ]: 54 : else if (aString.EqualsAscii( SC_UNO_SRCHSIM )) ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->IsLevenshtein() );
[ + - ]
187 [ + - ][ + + ]: 47 : else if (aString.EqualsAscii( SC_UNO_SRCHSIMREL )) ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->IsLEVRelaxed() );
[ + - ]
188 [ + - ][ + + ]: 40 : else if (aString.EqualsAscii( SC_UNO_SRCHSTYLES )) ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->GetPattern() );
[ + - ]
189 [ + - ][ + + ]: 33 : else if (aString.EqualsAscii( SC_UNO_SRCHWORDS )) ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->GetWordOnly() );
[ + - ]
190 [ + - ][ + + ]: 26 : else if (aString.EqualsAscii( SC_UNO_SRCHSIMADD )) aRet <<= (sal_Int16) pSearchItem->GetLEVLonger();
[ + - ]
191 [ + - ][ + + ]: 19 : else if (aString.EqualsAscii( SC_UNO_SRCHSIMEX )) aRet <<= (sal_Int16) pSearchItem->GetLEVOther();
[ + - ]
192 [ + - ][ + + ]: 12 : else if (aString.EqualsAscii( SC_UNO_SRCHSIMREM )) aRet <<= (sal_Int16) pSearchItem->GetLEVShorter();
[ + - ]
193 [ + - ][ + - ]: 5 : else if (aString.EqualsAscii( SC_UNO_SRCHTYPE )) aRet <<= (sal_Int16) pSearchItem->GetCellType();
[ + - ]
194 [ # # ][ # # ]: 0 : else if (aString.EqualsAscii( SC_UNO_SRCHFILTERED )) ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->IsSearchFiltered() );
[ # # ]
195 : :
196 [ + - ][ + - ]: 80 : return aRet;
197 : : }
198 : :
199 : 0 : SC_IMPL_DUMMY_PROPERTY_LISTENER( ScCellSearchObj )
200 : :
201 : : // XServiceInfo
202 : :
203 : 0 : rtl::OUString SAL_CALL ScCellSearchObj::getImplementationName() throw(uno::RuntimeException)
204 : : {
205 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ScCellSearchObj" ));
206 : : }
207 : :
208 : 1 : sal_Bool SAL_CALL ScCellSearchObj::supportsService( const rtl::OUString& rServiceName )
209 : : throw(uno::RuntimeException)
210 : : {
211 [ + - ]: 1 : String aServiceStr(rServiceName);
212 [ + - ]: 1 : return aServiceStr.EqualsAscii( SCSEARCHDESCRIPTOR_SERVICE ) ||
213 [ - + ][ # # ]: 1 : aServiceStr.EqualsAscii( SCREPLACEDESCRIPTOR_SERVICE );
[ # # ][ + - ]
214 : : }
215 : :
216 : 0 : uno::Sequence<rtl::OUString> SAL_CALL ScCellSearchObj::getSupportedServiceNames()
217 : : throw(uno::RuntimeException)
218 : : {
219 : 0 : uno::Sequence<rtl::OUString> aRet(2);
220 [ # # ]: 0 : rtl::OUString* pArray = aRet.getArray();
221 [ # # ]: 0 : pArray[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SCSEARCHDESCRIPTOR_SERVICE ));
222 [ # # ]: 0 : pArray[1] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SCREPLACEDESCRIPTOR_SERVICE ));
223 : 0 : return aRet;
224 : : }
225 : :
226 : : // XUnoTunnel
227 : :
228 : 64 : sal_Int64 SAL_CALL ScCellSearchObj::getSomething(
229 : : const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
230 : : {
231 [ + - + - ]: 128 : if ( rId.getLength() == 16 &&
[ + - ]
232 : 64 : 0 == memcmp( getUnoTunnelId().getConstArray(),
233 : 64 : rId.getConstArray(), 16 ) )
234 : : {
235 : 64 : return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
236 : : }
237 : 64 : return 0;
238 : : }
239 : :
240 : : namespace
241 : : {
242 : : class theScCellSearchObjUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theScCellSearchObjUnoTunnelId> {};
243 : : }
244 : :
245 : 128 : const uno::Sequence<sal_Int8>& ScCellSearchObj::getUnoTunnelId()
246 : : {
247 : 128 : return theScCellSearchObjUnoTunnelId::get().getSeq();
248 : : }
249 : :
250 : 64 : ScCellSearchObj* ScCellSearchObj::getImplementation(
251 : : const uno::Reference<util::XSearchDescriptor> xObj )
252 : : {
253 : 64 : ScCellSearchObj* pRet = NULL;
254 [ + - ]: 64 : uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
255 [ + - ]: 64 : if (xUT.is())
256 [ + - ][ + - ]: 64 : pRet = reinterpret_cast<ScCellSearchObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
[ + - ]
257 : 64 : return pRet;
258 : : }
259 : :
260 : :
261 : : //------------------------------------------------------------------------
262 : :
263 : :
264 : :
265 : :
266 : :
267 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|