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 : :
30 : : #include "unosrch.hxx"
31 : : #include <doc.hxx>
32 : : #include <hints.hxx>
33 : : #include <unomap.hxx>
34 : : #include <unobaseclass.hxx>
35 : : #include <unomid.h>
36 : :
37 : : #include <osl/mutex.hxx>
38 : : #include <vcl/svapp.hxx>
39 : : #include "editeng/unolingu.hxx"
40 : : #include <com/sun/star/util/SearchOptions.hpp>
41 : : #include <com/sun/star/util/SearchFlags.hpp>
42 : : #include <com/sun/star/i18n/TransliterationModules.hpp>
43 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
44 : : #include <comphelper/servicehelper.hxx>
45 : :
46 : : using namespace ::com::sun::star;
47 : : using ::rtl::OUString;
48 : :
49 : : class SwSearchProperties_Impl
50 : : {
51 : : beans::PropertyValue** pValueArr; //
52 : : sal_uInt32 nArrLen;
53 : : const PropertyEntryVector_t aPropertyEntries;
54 : : public:
55 : : SwSearchProperties_Impl();
56 : : ~SwSearchProperties_Impl();
57 : :
58 : : void SetProperties(const uno::Sequence< beans::PropertyValue >& aSearchAttribs)
59 : : throw( beans::UnknownPropertyException, lang::IllegalArgumentException, uno::RuntimeException );
60 : : const uno::Sequence< beans::PropertyValue > GetProperties() const;
61 : :
62 : : void FillItemSet(SfxItemSet& rSet, sal_Bool bIsValueSearch) const;
63 : : sal_Bool HasAttributes() const;
64 : : };
65 : :
66 : 20 : SwSearchProperties_Impl::SwSearchProperties_Impl() :
67 : : nArrLen(0),
68 : 20 : aPropertyEntries( aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)->getPropertyMap().getPropertyEntries())
69 : : {
70 : 20 : nArrLen = aPropertyEntries.size();
71 [ + - ]: 20 : pValueArr = new beans::PropertyValue*[nArrLen];
72 [ + + ]: 3060 : for(sal_uInt32 i = 0; i < nArrLen; i++)
73 : 3040 : pValueArr[i] = 0;
74 : 20 : }
75 : :
76 : 20 : SwSearchProperties_Impl::~SwSearchProperties_Impl()
77 : : {
78 [ + + ]: 3060 : for(sal_uInt32 i = 0; i < nArrLen; i++)
79 [ - + ]: 3040 : delete pValueArr[i];
80 [ + - ]: 20 : delete[] pValueArr;
81 : 20 : }
82 : :
83 : 0 : void SwSearchProperties_Impl::SetProperties(const uno::Sequence< beans::PropertyValue >& aSearchAttribs)
84 : : throw( beans::UnknownPropertyException, lang::IllegalArgumentException, uno::RuntimeException )
85 : : {
86 : 0 : const beans::PropertyValue* pProps = aSearchAttribs.getConstArray();
87 : : sal_uInt32 i;
88 : :
89 : : //delete all existing values
90 [ # # ]: 0 : for( i = 0; i < nArrLen; i++)
91 : : {
92 [ # # ]: 0 : delete pValueArr[i];
93 : 0 : pValueArr[i] = 0;
94 : : }
95 : :
96 : 0 : sal_uInt32 nLen = aSearchAttribs.getLength();
97 [ # # ]: 0 : for(i = 0; i < nLen; i++)
98 : : {
99 : 0 : sal_uInt16 nIndex = 0;
100 : 0 : PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
101 [ # # ]: 0 : while(pProps[i].Name != aIt->sName)
102 : : {
103 : 0 : ++aIt;
104 : 0 : nIndex++;
105 [ # # ][ # # ]: 0 : if( aIt == aPropertyEntries.end() )
106 [ # # ]: 0 : throw beans::UnknownPropertyException();
107 : : }
108 [ # # ]: 0 : pValueArr[nIndex] = new beans::PropertyValue(pProps[i]);
109 : : }
110 : 0 : }
111 : :
112 : 0 : const uno::Sequence< beans::PropertyValue > SwSearchProperties_Impl::GetProperties() const
113 : : {
114 : 0 : sal_uInt32 nPropCount = 0;
115 : : sal_uInt32 i;
116 [ # # ]: 0 : for( i = 0; i < nArrLen; i++)
117 [ # # ]: 0 : if(pValueArr[i])
118 : 0 : nPropCount++;
119 : :
120 : 0 : uno::Sequence< beans::PropertyValue > aRet(nPropCount);
121 [ # # ]: 0 : beans::PropertyValue* pProps = aRet.getArray();
122 : 0 : nPropCount = 0;
123 [ # # ]: 0 : for(i = 0; i < nArrLen; i++)
124 : : {
125 [ # # ]: 0 : if(pValueArr[i])
126 : : {
127 : 0 : pProps[nPropCount++] = *(pValueArr[i]);
128 : : }
129 : : }
130 : 0 : return aRet;
131 : : }
132 : :
133 : 0 : void SwSearchProperties_Impl::FillItemSet(SfxItemSet& rSet, sal_Bool bIsValueSearch) const
134 : : {
135 : : //
136 : :
137 : 0 : SfxPoolItem* pBoxItem = 0,
138 : 0 : *pBreakItem = 0,
139 : 0 : *pAutoKernItem = 0,
140 : 0 : *pWLineItem = 0,
141 : 0 : *pTabItem = 0,
142 : 0 : *pSplitItem = 0,
143 : 0 : *pRegItem = 0,
144 : 0 : *pLineSpaceItem = 0,
145 : 0 : *pLineNumItem = 0,
146 : 0 : *pKeepItem = 0,
147 : 0 : *pLRItem = 0,
148 : 0 : *pULItem = 0,
149 : 0 : *pBackItem = 0,
150 : 0 : *pAdjItem = 0,
151 : 0 : *pDescItem = 0,
152 : 0 : *pInetItem = 0,
153 : 0 : *pDropItem = 0,
154 : 0 : *pWeightItem = 0,
155 : 0 : *pULineItem = 0,
156 : 0 : *pOLineItem = 0,
157 : 0 : *pCharFmtItem = 0,
158 : 0 : *pShadItem = 0,
159 : 0 : *pPostItem = 0,
160 : 0 : *pNHyphItem = 0,
161 : 0 : *pLangItem = 0,
162 : 0 : *pKernItem = 0,
163 : 0 : *pFontSizeItem = 0,
164 : 0 : *pFontItem = 0,
165 : 0 : *pBlinkItem = 0,
166 : 0 : *pEscItem = 0,
167 : 0 : *pCrossedOutItem = 0,
168 : 0 : *pContourItem = 0,
169 : 0 : *pCharColorItem = 0,
170 : 0 : *pCasemapItem = 0,
171 : 0 : *pBrushItem = 0,
172 : 0 : *pFontCJKItem = 0,
173 : 0 : *pFontSizeCJKItem = 0,
174 : 0 : *pCJKLangItem = 0,
175 : 0 : *pCJKPostureItem = 0,
176 : 0 : *pCJKWeightItem = 0,
177 : 0 : *pFontCTLItem = 0,
178 : 0 : *pFontSizeCTLItem = 0,
179 : 0 : *pCTLLangItem = 0,
180 : 0 : *pCTLPostureItem = 0,
181 : 0 : *pCTLWeightItem = 0;
182 : :
183 : 0 : PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
184 [ # # ]: 0 : for(sal_uInt32 i = 0; i < nArrLen; i++, ++aIt)
185 : : {
186 [ # # ]: 0 : if(pValueArr[i])
187 : : {
188 : 0 : SfxPoolItem* pTempItem = 0;
189 [ # # # # : 0 : switch(aIt->nWID)
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # ]
190 : : {
191 : : case RES_BOX:
192 [ # # ]: 0 : if(!pBoxItem)
193 [ # # ][ # # ]: 0 : pBoxItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
194 : 0 : pTempItem = pBoxItem;
195 : 0 : break;
196 : : case RES_BREAK:
197 [ # # ]: 0 : if(!pBreakItem)
198 [ # # ][ # # ]: 0 : pBreakItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
199 : 0 : pTempItem = pBreakItem;
200 : 0 : break;
201 : : case RES_CHRATR_AUTOKERN:
202 [ # # ]: 0 : if(!pAutoKernItem)
203 [ # # ][ # # ]: 0 : pAutoKernItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
204 : 0 : pTempItem = pAutoKernItem;
205 : 0 : break;
206 : : case RES_CHRATR_BACKGROUND:
207 [ # # ]: 0 : if(!pBrushItem)
208 [ # # ][ # # ]: 0 : pBrushItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
209 : 0 : pTempItem = pBrushItem;
210 : 0 : break;
211 : : case RES_CHRATR_CASEMAP:
212 [ # # ]: 0 : if(!pCasemapItem)
213 [ # # ][ # # ]: 0 : pCasemapItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
214 : 0 : pTempItem = pCasemapItem;
215 : 0 : break;
216 : : case RES_CHRATR_COLOR:
217 [ # # ]: 0 : if(!pCharColorItem)
218 [ # # ][ # # ]: 0 : pCharColorItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
219 : 0 : pTempItem = pCharColorItem;
220 : 0 : break;
221 : : case RES_CHRATR_CONTOUR:
222 [ # # ]: 0 : if(!pContourItem)
223 [ # # ][ # # ]: 0 : pContourItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
224 : 0 : pTempItem = pContourItem;
225 : 0 : break;
226 : : case RES_CHRATR_CROSSEDOUT:
227 [ # # ]: 0 : if(!pCrossedOutItem)
228 [ # # ][ # # ]: 0 : pCrossedOutItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
229 : 0 : pTempItem = pCrossedOutItem;
230 : 0 : break;
231 : : case RES_CHRATR_ESCAPEMENT:
232 [ # # ]: 0 : if(!pEscItem)
233 [ # # ][ # # ]: 0 : pEscItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
234 : 0 : pTempItem = pEscItem;
235 : 0 : break;
236 : : case RES_CHRATR_BLINK:
237 [ # # ]: 0 : if(!pBlinkItem)
238 [ # # ][ # # ]: 0 : pBlinkItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
239 : 0 : pTempItem = pBlinkItem;
240 : 0 : break;
241 : : case RES_CHRATR_FONT:
242 [ # # ]: 0 : if(!pFontItem)
243 [ # # ][ # # ]: 0 : pFontItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
244 : 0 : pTempItem = pFontItem;
245 : 0 : break;
246 : : case RES_CHRATR_FONTSIZE:
247 [ # # ]: 0 : if(!pFontSizeItem)
248 [ # # ][ # # ]: 0 : pFontSizeItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
249 : 0 : pTempItem = pFontSizeItem;
250 : 0 : break;
251 : : case RES_CHRATR_KERNING:
252 [ # # ]: 0 : if(!pKernItem)
253 [ # # ][ # # ]: 0 : pKernItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
254 : 0 : pTempItem = pKernItem;
255 : 0 : break;
256 : : case RES_CHRATR_LANGUAGE:
257 [ # # ]: 0 : if(!pLangItem)
258 [ # # ][ # # ]: 0 : pLangItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
259 : 0 : pTempItem = pLangItem;
260 : 0 : break;
261 : : case RES_CHRATR_NOHYPHEN:
262 [ # # ]: 0 : if(!pNHyphItem)
263 [ # # ][ # # ]: 0 : pNHyphItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
264 : 0 : pTempItem = pNHyphItem;
265 : 0 : break;
266 : : case RES_CHRATR_POSTURE:
267 [ # # ]: 0 : if(!pPostItem)
268 [ # # ][ # # ]: 0 : pPostItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
269 : 0 : pTempItem = pPostItem;
270 : 0 : break;
271 : : case RES_CHRATR_SHADOWED:
272 [ # # ]: 0 : if(!pShadItem)
273 [ # # ][ # # ]: 0 : pShadItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
274 : 0 : pTempItem = pShadItem;
275 : 0 : break;
276 : : case RES_TXTATR_CHARFMT:
277 [ # # ]: 0 : if(!pCharFmtItem)
278 [ # # ][ # # ]: 0 : pCharFmtItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
279 : 0 : pTempItem = pCharFmtItem;
280 : 0 : break;
281 : : case RES_CHRATR_UNDERLINE:
282 [ # # ]: 0 : if(!pULineItem)
283 [ # # ][ # # ]: 0 : pULineItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
284 : 0 : pTempItem = pULineItem;
285 : 0 : break;
286 : : case RES_CHRATR_OVERLINE:
287 [ # # ]: 0 : if(!pOLineItem)
288 [ # # ][ # # ]: 0 : pOLineItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
289 : 0 : pTempItem = pOLineItem;
290 : 0 : break;
291 : : case RES_CHRATR_WEIGHT:
292 [ # # ]: 0 : if(!pWeightItem)
293 [ # # ][ # # ]: 0 : pWeightItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
294 : 0 : pTempItem = pWeightItem;
295 : 0 : break;
296 : : case RES_PARATR_DROP:
297 [ # # ]: 0 : if(!pDropItem)
298 [ # # ][ # # ]: 0 : pDropItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
299 : 0 : pTempItem = pDropItem;
300 : 0 : break;
301 : : case RES_TXTATR_INETFMT:
302 [ # # ]: 0 : if(!pInetItem)
303 [ # # ][ # # ]: 0 : pInetItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
304 : 0 : pTempItem = pInetItem;
305 : 0 : break;
306 : : case RES_PAGEDESC:
307 [ # # ]: 0 : if(!pDescItem)
308 [ # # ][ # # ]: 0 : pDescItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
309 : 0 : pTempItem = pDescItem;
310 : 0 : break;
311 : : case RES_PARATR_ADJUST:
312 [ # # ]: 0 : if(!pAdjItem)
313 [ # # ][ # # ]: 0 : pAdjItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
314 : 0 : pTempItem = pAdjItem;
315 : 0 : break;
316 : : case RES_BACKGROUND:
317 [ # # ]: 0 : if(!pBackItem)
318 [ # # ][ # # ]: 0 : pBackItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
319 : 0 : pTempItem = pBackItem;
320 : 0 : break;
321 : : case RES_UL_SPACE:
322 [ # # ]: 0 : if(!pULItem)
323 [ # # ][ # # ]: 0 : pULItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
324 : 0 : pTempItem = pULItem;
325 : 0 : break;
326 : : case RES_LR_SPACE:
327 [ # # ]: 0 : if(!pLRItem)
328 [ # # ][ # # ]: 0 : pLRItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
329 : 0 : pTempItem = pLRItem;
330 : 0 : break;
331 : : case RES_KEEP:
332 [ # # ]: 0 : if(!pKeepItem)
333 [ # # ][ # # ]: 0 : pKeepItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
334 : 0 : pTempItem = pKeepItem;
335 : 0 : break;
336 : : case RES_LINENUMBER:
337 [ # # ]: 0 : if(!pLineNumItem)
338 [ # # ][ # # ]: 0 : pLineNumItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
339 : 0 : pTempItem = pLineNumItem;
340 : 0 : break;
341 : : case RES_PARATR_LINESPACING:
342 [ # # ]: 0 : if(!pLineSpaceItem)
343 [ # # ][ # # ]: 0 : pLineSpaceItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
344 : 0 : pTempItem = pLineSpaceItem;
345 : 0 : break;
346 : : case RES_PARATR_REGISTER:
347 [ # # ]: 0 : if(!pRegItem)
348 [ # # ][ # # ]: 0 : pRegItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
349 : 0 : pTempItem = pRegItem;
350 : 0 : break;
351 : : case RES_PARATR_SPLIT:
352 [ # # ]: 0 : if(!pSplitItem)
353 [ # # ][ # # ]: 0 : pSplitItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
354 : 0 : pTempItem = pSplitItem;
355 : 0 : break;
356 : : case RES_PARATR_TABSTOP:
357 [ # # ]: 0 : if(!pTabItem)
358 [ # # ][ # # ]: 0 : pTabItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
359 : 0 : pTempItem = pTabItem;
360 : 0 : break;
361 : : case RES_CHRATR_WORDLINEMODE:
362 [ # # ]: 0 : if(!pWLineItem)
363 [ # # ][ # # ]: 0 : pWLineItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
364 : 0 : pTempItem = pWLineItem;
365 : 0 : break;
366 : : case RES_CHRATR_CJK_FONT:
367 [ # # ]: 0 : if(!pFontCJKItem )
368 [ # # ][ # # ]: 0 : pFontCJKItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
369 : 0 : pTempItem = pFontCJKItem;
370 : 0 : break;
371 : : case RES_CHRATR_CJK_FONTSIZE:
372 [ # # ]: 0 : if(!pFontSizeCJKItem )
373 [ # # ][ # # ]: 0 : pFontSizeCJKItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
374 : 0 : pTempItem = pFontSizeCJKItem;
375 : 0 : break;
376 : : case RES_CHRATR_CJK_LANGUAGE:
377 [ # # ]: 0 : if(!pCJKLangItem )
378 [ # # ][ # # ]: 0 : pCJKLangItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
379 : 0 : pTempItem = pCJKLangItem;
380 : 0 : break;
381 : : case RES_CHRATR_CJK_POSTURE:
382 [ # # ]: 0 : if(!pCJKPostureItem )
383 [ # # ][ # # ]: 0 : pCJKPostureItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
384 : 0 : pTempItem = pCJKPostureItem;
385 : 0 : break;
386 : : case RES_CHRATR_CJK_WEIGHT:
387 [ # # ]: 0 : if(!pCJKWeightItem )
388 [ # # ][ # # ]: 0 : pCJKWeightItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
389 : 0 : pTempItem = pCJKWeightItem;
390 : 0 : break;
391 : : case RES_CHRATR_CTL_FONT:
392 [ # # ]: 0 : if(!pFontCTLItem )
393 [ # # ][ # # ]: 0 : pFontCTLItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
394 : 0 : pTempItem = pFontCTLItem;
395 : 0 : break;
396 : : case RES_CHRATR_CTL_FONTSIZE:
397 [ # # ]: 0 : if(!pFontSizeCTLItem )
398 [ # # ][ # # ]: 0 : pFontSizeCTLItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
399 : 0 : pTempItem = pFontSizeCTLItem;
400 : 0 : break;
401 : : case RES_CHRATR_CTL_LANGUAGE:
402 [ # # ]: 0 : if(!pCTLLangItem )
403 [ # # ][ # # ]: 0 : pCTLLangItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
404 : 0 : pTempItem = pCTLLangItem;
405 : 0 : break;
406 : : case RES_CHRATR_CTL_POSTURE:
407 [ # # ]: 0 : if(!pCTLPostureItem )
408 [ # # ][ # # ]: 0 : pCTLPostureItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
409 : 0 : pTempItem = pCTLPostureItem;
410 : 0 : break;
411 : : case RES_CHRATR_CTL_WEIGHT:
412 [ # # ]: 0 : if(!pCTLWeightItem )
413 [ # # ][ # # ]: 0 : pCTLWeightItem = rSet.GetPool()->GetDefaultItem(aIt->nWID).Clone();
414 : 0 : pTempItem = pCTLWeightItem;
415 : 0 : break;
416 : : }
417 [ # # ]: 0 : if(pTempItem)
418 : : {
419 [ # # ]: 0 : if(bIsValueSearch)
420 : : {
421 [ # # ]: 0 : pTempItem->PutValue(pValueArr[i]->Value, aIt->nMemberId);
422 [ # # ]: 0 : rSet.Put(*pTempItem);
423 : : }
424 : : else
425 [ # # ]: 0 : rSet.InvalidateItem( pTempItem->Which() );
426 : : }
427 : : }
428 : : }
429 [ # # ][ # # ]: 0 : delete pBoxItem;
430 [ # # ][ # # ]: 0 : delete pBreakItem;
431 [ # # ][ # # ]: 0 : delete pAutoKernItem ;
432 [ # # ][ # # ]: 0 : delete pWLineItem;
433 [ # # ][ # # ]: 0 : delete pTabItem;
434 [ # # ][ # # ]: 0 : delete pSplitItem;
435 [ # # ][ # # ]: 0 : delete pRegItem;
436 [ # # ][ # # ]: 0 : delete pLineSpaceItem ;
437 [ # # ][ # # ]: 0 : delete pLineNumItem ;
438 [ # # ][ # # ]: 0 : delete pKeepItem;
439 [ # # ][ # # ]: 0 : delete pLRItem ;
440 [ # # ][ # # ]: 0 : delete pULItem ;
441 [ # # ][ # # ]: 0 : delete pBackItem;
442 [ # # ][ # # ]: 0 : delete pAdjItem;
443 [ # # ][ # # ]: 0 : delete pDescItem;
444 [ # # ][ # # ]: 0 : delete pInetItem;
445 [ # # ][ # # ]: 0 : delete pDropItem;
446 [ # # ][ # # ]: 0 : delete pWeightItem;
447 [ # # ][ # # ]: 0 : delete pULineItem;
448 [ # # ][ # # ]: 0 : delete pOLineItem;
449 [ # # ][ # # ]: 0 : delete pCharFmtItem ;
450 [ # # ][ # # ]: 0 : delete pShadItem;
451 [ # # ][ # # ]: 0 : delete pPostItem;
452 [ # # ][ # # ]: 0 : delete pNHyphItem;
453 [ # # ][ # # ]: 0 : delete pLangItem;
454 [ # # ][ # # ]: 0 : delete pKernItem;
455 [ # # ][ # # ]: 0 : delete pFontSizeItem ;
456 [ # # ][ # # ]: 0 : delete pFontItem;
457 [ # # ][ # # ]: 0 : delete pBlinkItem;
458 [ # # ][ # # ]: 0 : delete pEscItem;
459 [ # # ][ # # ]: 0 : delete pCrossedOutItem;
460 [ # # ][ # # ]: 0 : delete pContourItem ;
461 [ # # ][ # # ]: 0 : delete pCharColorItem;
462 [ # # ][ # # ]: 0 : delete pCasemapItem ;
463 [ # # ][ # # ]: 0 : delete pBrushItem ;
464 : 0 : }
465 : :
466 : 22 : sal_Bool SwSearchProperties_Impl::HasAttributes() const
467 : : {
468 [ + + ]: 3366 : for(sal_uInt32 i = 0; i < nArrLen; i++)
469 [ - + ]: 3344 : if(pValueArr[i])
470 : 0 : return sal_True;
471 : 22 : return sal_False;
472 : : }
473 : :
474 : 10 : SwXTextSearch::SwXTextSearch() :
475 [ + - ]: 10 : pSearchProperties( new SwSearchProperties_Impl),
476 [ + - ]: 10 : pReplaceProperties( new SwSearchProperties_Impl),
477 [ + - ]: 10 : m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_SEARCH)),
478 : : bAll(sal_False),
479 : : bWord(sal_False),
480 : : bBack(sal_False),
481 : : bExpr(sal_False),
482 : : bCase(sal_False),
483 : : bStyles(sal_False),
484 : : bSimilarity(sal_False),
485 : : bLevRelax(sal_False),
486 : : nLevExchange(2),
487 : : nLevAdd(2),
488 : : nLevRemove(2),
489 [ + - ][ + - ]: 20 : bIsValueSearch(sal_True)
[ + - ][ + - ]
490 : : {
491 : 10 : }
492 : :
493 [ + - ][ + - ]: 10 : SwXTextSearch::~SwXTextSearch()
494 : : {
495 [ + - ]: 10 : delete pSearchProperties;
496 [ + - ]: 10 : delete pReplaceProperties;
497 [ - + ]: 20 : }
498 : :
499 : : namespace
500 : : {
501 : : class theSwXTextSearchUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextSearchUnoTunnelId > {};
502 : : }
503 : :
504 : 64 : const uno::Sequence< sal_Int8 > & SwXTextSearch::getUnoTunnelId()
505 : : {
506 : 64 : return theSwXTextSearchUnoTunnelId::get().getSeq();
507 : : }
508 : :
509 : 32 : sal_Int64 SAL_CALL SwXTextSearch::getSomething( const uno::Sequence< sal_Int8 >& rId )
510 : : throw(uno::RuntimeException)
511 : : {
512 [ + - + - ]: 64 : if( rId.getLength() == 16
[ + - ]
513 : 32 : && 0 == memcmp( getUnoTunnelId().getConstArray(),
514 : 32 : rId.getConstArray(), 16 ) )
515 : : {
516 : 32 : return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
517 : : }
518 : 32 : return 0;
519 : : }
520 : :
521 : 6 : OUString SwXTextSearch::getSearchString(void) throw( uno::RuntimeException )
522 : : {
523 [ + - ]: 6 : SolarMutexGuard aGuard;
524 [ + - ][ + - ]: 6 : return sSearchText;
525 : : }
526 : :
527 : 14 : void SwXTextSearch::setSearchString(const OUString& rString)
528 : : throw( uno::RuntimeException )
529 : : {
530 [ + - ]: 14 : SolarMutexGuard aGuard;
531 [ + - ][ + - ]: 14 : sSearchText = String(rString);
[ + - ][ + - ]
532 : 14 : }
533 : :
534 : 0 : OUString SwXTextSearch::getReplaceString(void) throw( uno::RuntimeException )
535 : : {
536 [ # # ]: 0 : SolarMutexGuard aGuard;
537 [ # # ][ # # ]: 0 : return sReplaceText;
538 : : }
539 : :
540 : 4 : void SwXTextSearch::setReplaceString(const OUString& rReplaceString) throw( uno::RuntimeException )
541 : : {
542 [ + - ]: 4 : SolarMutexGuard aGuard;
543 [ + - ][ + - ]: 4 : sReplaceText = String(rReplaceString);
[ + - ][ + - ]
544 : 4 : }
545 : :
546 : 42 : uno::Reference< beans::XPropertySetInfo > SwXTextSearch::getPropertySetInfo(void) throw( uno::RuntimeException )
547 : : {
548 [ + + ][ + - ]: 42 : static uno::Reference< beans::XPropertySetInfo > aRef = m_pPropSet->getPropertySetInfo();
[ + - ][ # # ]
549 : 42 : return aRef;
550 : : }
551 : :
552 : 64 : void SwXTextSearch::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
553 : : throw( beans::UnknownPropertyException, beans::PropertyVetoException,
554 : : lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException )
555 : : {
556 [ + - ]: 64 : SolarMutexGuard aGuard;
557 [ + - ]: 64 : const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName(rPropertyName);
558 [ + - ]: 64 : if(pEntry)
559 : : {
560 [ - + ]: 64 : if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
561 [ # # ][ # # ]: 0 : throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
[ # # ]
562 : 64 : sal_Bool bVal = sal_False;
563 [ + - ][ + + ]: 64 : if(aValue.getValueType() == ::getBooleanCppuType())
564 : 46 : bVal = *(sal_Bool*)aValue.getValue();
565 [ + + + + : 64 : switch(pEntry->nWID)
+ + + + +
+ + - ]
566 : : {
567 : 4 : case WID_SEARCH_ALL : bAll = bVal; break;
568 : 6 : case WID_WORDS: bWord = bVal; break;
569 : 6 : case WID_BACKWARDS : bBack = bVal; break;
570 : 6 : case WID_REGULAR_EXPRESSION : bExpr = bVal; break;
571 : 6 : case WID_CASE_SENSITIVE : bCase = bVal; break;
572 : : //case WID_IN_SELECTION : bInSel = bVal; break;
573 : 6 : case WID_STYLES : bStyles = bVal; break;
574 : 6 : case WID_SIMILARITY : bSimilarity = bVal; break;
575 : 6 : case WID_SIMILARITY_RELAX: bLevRelax = bVal; break;
576 : 6 : case WID_SIMILARITY_EXCHANGE: aValue >>= nLevExchange; break;
577 : 6 : case WID_SIMILARITY_ADD: aValue >>= nLevAdd; break;
578 : 6 : case WID_SIMILARITY_REMOVE : aValue >>= nLevRemove;break;
579 : : };
580 : : }
581 : : else
582 [ + - ][ # # ]: 64 : throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
[ # # ][ # # ]
583 : 64 : }
584 : :
585 : 150 : uno::Any SwXTextSearch::getPropertyValue(const OUString& rPropertyName) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
586 : : {
587 [ + - ]: 150 : SolarMutexGuard aGuard;
588 : 150 : uno::Any aRet;
589 : :
590 [ + - ]: 150 : const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName(rPropertyName);
591 : 150 : sal_Bool bSet = sal_False;
592 [ + - ]: 150 : if(pEntry)
593 : : {
594 : 150 : sal_Int16 nSet = 0;
595 [ + + + + : 150 : switch(pEntry->nWID)
+ + + + +
+ + - ]
596 : : {
597 : 10 : case WID_SEARCH_ALL : bSet = bAll; goto SET_BOOL;
598 : 14 : case WID_WORDS: bSet = bWord; goto SET_BOOL;
599 : 14 : case WID_BACKWARDS : bSet = bBack; goto SET_BOOL;
600 : 14 : case WID_REGULAR_EXPRESSION : bSet = bExpr; goto SET_BOOL;
601 : 14 : case WID_CASE_SENSITIVE : bSet = bCase; goto SET_BOOL;
602 : : //case WID_IN_SELECTION : bSet = bInSel; goto SET_BOOL;
603 : 14 : case WID_STYLES : bSet = bStyles; goto SET_BOOL;
604 : 14 : case WID_SIMILARITY : bSet = bSimilarity; goto SET_BOOL;
605 : 14 : case WID_SIMILARITY_RELAX: bSet = bLevRelax;
606 : : SET_BOOL:
607 [ + - ]: 108 : aRet.setValue(&bSet, ::getBooleanCppuType());
608 : 108 : break;
609 : 14 : case WID_SIMILARITY_EXCHANGE: nSet = nLevExchange; goto SET_UINT16;
610 : 14 : case WID_SIMILARITY_ADD: nSet = nLevAdd; goto SET_UINT16;
611 : 14 : case WID_SIMILARITY_REMOVE : nSet = nLevRemove;
612 : : SET_UINT16:
613 [ + - ]: 42 : aRet <<= nSet;
614 : 42 : break;
615 : : };
616 : : }
617 : : else
618 [ # # ][ # # ]: 150 : throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
[ # # ]
619 [ + - ]: 300 : return aRet;
620 : : }
621 : :
622 : 0 : void SwXTextSearch::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
623 : : {
624 : : OSL_FAIL("not implemented");
625 : 0 : }
626 : :
627 : 0 : void SwXTextSearch::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw(beans::UnknownPropertyException, lang::WrappedTargetException,uno::RuntimeException )
628 : : {
629 : : OSL_FAIL("not implemented");
630 : 0 : }
631 : :
632 : 0 : void SwXTextSearch::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw(beans::UnknownPropertyException, lang::WrappedTargetException,uno::RuntimeException )
633 : : {
634 : : OSL_FAIL("not implemented");
635 : 0 : }
636 : :
637 : 0 : void SwXTextSearch::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw(beans::UnknownPropertyException, lang::WrappedTargetException,uno::RuntimeException )
638 : : {
639 : : OSL_FAIL("not implemented");
640 : 0 : }
641 : :
642 : 0 : sal_Bool SwXTextSearch::getValueSearch(void) throw( uno::RuntimeException )
643 : : {
644 [ # # ]: 0 : SolarMutexGuard aGuard;
645 [ # # ]: 0 : return bIsValueSearch;
646 : : }
647 : :
648 : 0 : void SwXTextSearch::setValueSearch(sal_Bool ValueSearch_) throw( uno::RuntimeException )
649 : : {
650 [ # # ]: 0 : SolarMutexGuard aGuard;
651 [ # # ]: 0 : bIsValueSearch = ValueSearch_;
652 : 0 : }
653 : :
654 : 0 : uno::Sequence< beans::PropertyValue > SwXTextSearch::getSearchAttributes(void) throw( uno::RuntimeException )
655 : : {
656 : 0 : return pSearchProperties->GetProperties();
657 : : }
658 : :
659 : 0 : void SwXTextSearch::setSearchAttributes(const uno::Sequence< beans::PropertyValue >& rSearchAttribs)
660 : : throw( beans::UnknownPropertyException, lang::IllegalArgumentException, uno::RuntimeException )
661 : : {
662 : 0 : pSearchProperties->SetProperties(rSearchAttribs);
663 : 0 : }
664 : :
665 : 0 : uno::Sequence< beans::PropertyValue > SwXTextSearch::getReplaceAttributes(void)
666 : : throw( uno::RuntimeException )
667 : : {
668 : 0 : return pReplaceProperties->GetProperties();
669 : : }
670 : :
671 : 0 : void SwXTextSearch::setReplaceAttributes(const uno::Sequence< beans::PropertyValue >& rReplaceAttribs)
672 : : throw( beans::UnknownPropertyException, lang::IllegalArgumentException, uno::RuntimeException )
673 : : {
674 : 0 : pReplaceProperties->SetProperties(rReplaceAttribs);
675 : 0 : }
676 : :
677 : 0 : void SwXTextSearch::FillSearchItemSet(SfxItemSet& rSet) const
678 : : {
679 : 0 : pSearchProperties->FillItemSet(rSet, bIsValueSearch);
680 : 0 : }
681 : :
682 : 0 : void SwXTextSearch::FillReplaceItemSet(SfxItemSet& rSet) const
683 : : {
684 : 0 : pReplaceProperties->FillItemSet(rSet, bIsValueSearch);
685 : 0 : }
686 : :
687 : 18 : sal_Bool SwXTextSearch::HasSearchAttributes() const
688 : : {
689 : 18 : return pSearchProperties->HasAttributes();
690 : : }
691 : :
692 : 4 : sal_Bool SwXTextSearch::HasReplaceAttributes() const
693 : : {
694 : 4 : return pReplaceProperties->HasAttributes();
695 : : }
696 : :
697 : 0 : OUString SwXTextSearch::getImplementationName(void) throw( uno::RuntimeException )
698 : : {
699 : 0 : return C2U("SwXTextSearch");
700 : : }
701 : :
702 : 2 : sal_Bool SwXTextSearch::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
703 : : {
704 [ + - ][ + - ]: 4 : return C2U("com.sun.star.util.SearchDescriptor") == rServiceName ||
[ # # ]
705 [ # # ][ # # ]: 4 : C2U("com.sun.star.util.ReplaceDescriptor") == rServiceName;
[ - + ][ # # ]
[ - + ]
706 : : }
707 : :
708 : 0 : uno::Sequence< OUString > SwXTextSearch::getSupportedServiceNames(void) throw( uno::RuntimeException )
709 : : {
710 : 0 : uno::Sequence< OUString > aRet(2);
711 [ # # ]: 0 : OUString* pArray = aRet.getArray();
712 [ # # ]: 0 : pArray[0] = C2U("com.sun.star.util.SearchDescriptor");
713 [ # # ]: 0 : pArray[1] = C2U("com.sun.star.util.ReplaceDescriptor");
714 : 0 : return aRet;
715 : : }
716 : :
717 : 16 : void SwXTextSearch::FillSearchOptions( util::SearchOptions& rSearchOpt ) const
718 : : {
719 [ - + ]: 16 : if( bSimilarity )
720 : : {
721 : 0 : rSearchOpt.algorithmType = util::SearchAlgorithms_APPROXIMATE;
722 : 0 : rSearchOpt.changedChars = nLevExchange;
723 : 0 : rSearchOpt.deletedChars = nLevRemove;
724 : 0 : rSearchOpt.insertedChars = nLevAdd;
725 [ # # ]: 0 : if( bLevRelax )
726 : 0 : rSearchOpt.searchFlag |= util::SearchFlags::LEV_RELAXED;
727 : : }
728 [ - + ]: 16 : else if( bExpr )
729 : 0 : rSearchOpt.algorithmType = util::SearchAlgorithms_REGEXP;
730 : : else
731 : 16 : rSearchOpt.algorithmType = util::SearchAlgorithms_ABSOLUTE;
732 : :
733 : 16 : rSearchOpt.Locale = SvxCreateLocale( GetAppLanguage() );
734 : 16 : rSearchOpt.searchString = sSearchText;
735 : 16 : rSearchOpt.replaceString = sReplaceText;
736 : :
737 [ + - ]: 16 : if( !bCase )
738 : 16 : rSearchOpt.transliterateFlags |= i18n::TransliterationModules_IGNORE_CASE;
739 [ - + ]: 16 : if( bWord )
740 : 0 : rSearchOpt.searchFlag |= util::SearchFlags::NORM_WORD_ONLY;
741 : :
742 : : // bInSel: 1; // wie geht das?
743 : : // TODO: pSearch->bStyles!
744 : : // inSelection??
745 : : // aSrchParam.SetSrchInSelection(TypeConversion::toBOOL(aVal));
746 : 16 : }
747 : :
748 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|