15b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
35b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
45b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file
55b190011SAndrew Rist * distributed with this work for additional information
65b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file
75b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the
85b190011SAndrew Rist * "License"); you may not use this file except in compliance
95b190011SAndrew Rist * with the License. You may obtain a copy of the License at
105b190011SAndrew Rist *
115b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
125b190011SAndrew Rist *
135b190011SAndrew Rist * Unless required by applicable law or agreed to in writing,
145b190011SAndrew Rist * software distributed under the License is distributed on an
155b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165b190011SAndrew Rist * KIND, either express or implied. See the License for the
175b190011SAndrew Rist * specific language governing permissions and limitations
185b190011SAndrew Rist * under the License.
195b190011SAndrew Rist *
205b190011SAndrew Rist *************************************************************/
215b190011SAndrew Rist
225b190011SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir #include <vcl/svapp.hxx>
27cdf0e10cSrcweir #include <vos/mutex.hxx>
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include <svx/unoshape.hxx>
30cdf0e10cSrcweir #include <svx/svdpool.hxx>
31cdf0e10cSrcweir #include <svx/unoprov.hxx>
32cdf0e10cSrcweir #include <editeng/unotext.hxx>
33cdf0e10cSrcweir
34cdf0e10cSrcweir #include <comphelper/extract.hxx>
35cdf0e10cSrcweir #include <rtl/uuid.h>
36cdf0e10cSrcweir #include <rtl/memory.h>
37cdf0e10cSrcweir
38cdf0e10cSrcweir #include "unohelp.hxx"
39cdf0e10cSrcweir #include "unoprnms.hxx"
40cdf0e10cSrcweir #include "unosrch.hxx"
41cdf0e10cSrcweir
42cdf0e10cSrcweir using namespace ::vos;
43cdf0e10cSrcweir using namespace ::rtl;
44cdf0e10cSrcweir using namespace ::com::sun::star;
45cdf0e10cSrcweir
46cdf0e10cSrcweir #define WID_SEARCH_BACKWARDS 0
47cdf0e10cSrcweir #define WID_SEARCH_CASE 1
48cdf0e10cSrcweir #define WID_SEARCH_WORDS 2
49cdf0e10cSrcweir
ImplGetSearchPropertyMap()50cdf0e10cSrcweir const SfxItemPropertyMapEntry* ImplGetSearchPropertyMap()
51cdf0e10cSrcweir {
52cdf0e10cSrcweir static const SfxItemPropertyMapEntry aSearchPropertyMap_Impl[] =
53cdf0e10cSrcweir {
54cdf0e10cSrcweir { MAP_CHAR_LEN(UNO_NAME_SEARCH_BACKWARDS), WID_SEARCH_BACKWARDS, &::getBooleanCppuType(), 0, 0 },
55cdf0e10cSrcweir { MAP_CHAR_LEN(UNO_NAME_SEARCH_CASE), WID_SEARCH_CASE, &::getBooleanCppuType(), 0, 0 },
56cdf0e10cSrcweir { MAP_CHAR_LEN(UNO_NAME_SEARCH_WORDS), WID_SEARCH_WORDS, &::getBooleanCppuType(), 0, 0 },
57cdf0e10cSrcweir { 0,0,0,0,0,0}
58cdf0e10cSrcweir };
59cdf0e10cSrcweir
60cdf0e10cSrcweir return aSearchPropertyMap_Impl;
61cdf0e10cSrcweir }
62cdf0e10cSrcweir
63cdf0e10cSrcweir class SearchContext_impl
64cdf0e10cSrcweir {
65cdf0e10cSrcweir uno::Reference< drawing::XShapes > mxShapes;
66cdf0e10cSrcweir sal_Int32 mnIndex;
67cdf0e10cSrcweir SearchContext_impl* mpParent;
68cdf0e10cSrcweir
69cdf0e10cSrcweir public:
SearchContext_impl(uno::Reference<drawing::XShapes> xShapes,SearchContext_impl * pParent=NULL)70cdf0e10cSrcweir SearchContext_impl( uno::Reference< drawing::XShapes > xShapes, SearchContext_impl* pParent = NULL )
71cdf0e10cSrcweir : mxShapes( xShapes ), mnIndex( -1 ), mpParent( pParent ) {}
72cdf0e10cSrcweir
73cdf0e10cSrcweir
firstShape()74cdf0e10cSrcweir uno::Reference< drawing::XShape > firstShape()
75cdf0e10cSrcweir {
76cdf0e10cSrcweir mnIndex = -1;
77cdf0e10cSrcweir return nextShape();
78cdf0e10cSrcweir }
79cdf0e10cSrcweir
nextShape()80cdf0e10cSrcweir uno::Reference< drawing::XShape > nextShape()
81cdf0e10cSrcweir {
82cdf0e10cSrcweir uno::Reference< drawing::XShape > xShape;
83cdf0e10cSrcweir mnIndex++;
84cdf0e10cSrcweir if( mxShapes.is() && mxShapes->getCount() > mnIndex )
85cdf0e10cSrcweir {
86cdf0e10cSrcweir mxShapes->getByIndex( mnIndex ) >>= xShape;
87cdf0e10cSrcweir }
88cdf0e10cSrcweir return xShape;
89cdf0e10cSrcweir }
90cdf0e10cSrcweir
getParent() const91cdf0e10cSrcweir SearchContext_impl* getParent() const { return mpParent; }
92cdf0e10cSrcweir };
93cdf0e10cSrcweir
94cdf0e10cSrcweir /* ================================================================= */
95cdf0e10cSrcweir /** this class implements a search or replace operation on a given
96cdf0e10cSrcweir page or a given sdrobj
97cdf0e10cSrcweir */
98cdf0e10cSrcweir
SdUnoSearchReplaceShape(drawing::XDrawPage * pPage)99cdf0e10cSrcweir SdUnoSearchReplaceShape::SdUnoSearchReplaceShape( drawing::XDrawPage* pPage ) throw()
100cdf0e10cSrcweir {
101cdf0e10cSrcweir mpPage = pPage;
102cdf0e10cSrcweir }
103cdf0e10cSrcweir
~SdUnoSearchReplaceShape()104cdf0e10cSrcweir SdUnoSearchReplaceShape::~SdUnoSearchReplaceShape() throw()
105cdf0e10cSrcweir {
106cdf0e10cSrcweir }
107cdf0e10cSrcweir
108cdf0e10cSrcweir // util::XReplaceable
createReplaceDescriptor()109cdf0e10cSrcweir uno::Reference< util::XReplaceDescriptor > SAL_CALL SdUnoSearchReplaceShape::createReplaceDescriptor()
110cdf0e10cSrcweir throw( uno::RuntimeException )
111cdf0e10cSrcweir {
112cdf0e10cSrcweir return new SdUnoSearchReplaceDescriptor(sal_True);
113cdf0e10cSrcweir }
114cdf0e10cSrcweir
replaceAll(const uno::Reference<util::XSearchDescriptor> & xDesc)115cdf0e10cSrcweir sal_Int32 SAL_CALL SdUnoSearchReplaceShape::replaceAll( const uno::Reference< util::XSearchDescriptor >& xDesc )
116cdf0e10cSrcweir throw( uno::RuntimeException )
117cdf0e10cSrcweir {
118cdf0e10cSrcweir SdUnoSearchReplaceDescriptor* pDescr = SdUnoSearchReplaceDescriptor::getImplementation( xDesc );
119cdf0e10cSrcweir if( pDescr == NULL )
120cdf0e10cSrcweir return 0;
121cdf0e10cSrcweir
122cdf0e10cSrcweir sal_Int32 nFound = 0;
123cdf0e10cSrcweir
124cdf0e10cSrcweir uno::Reference< drawing::XShapes > xShapes;
125cdf0e10cSrcweir uno::Reference< drawing::XShape > xShape;
126cdf0e10cSrcweir
127cdf0e10cSrcweir SearchContext_impl* pContext = NULL;
128cdf0e10cSrcweir if(mpPage)
129cdf0e10cSrcweir {
130cdf0e10cSrcweir uno::Reference< drawing::XDrawPage > xPage( mpPage );
131cdf0e10cSrcweir
132cdf0e10cSrcweir xPage->queryInterface( ITYPE( drawing::XShapes ) ) >>= xShapes;
133cdf0e10cSrcweir
134cdf0e10cSrcweir if( xShapes.is() && (xShapes->getCount() > 0) )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir pContext = new SearchContext_impl( xShapes );
137cdf0e10cSrcweir xShape = pContext->firstShape();
138cdf0e10cSrcweir }
139cdf0e10cSrcweir else
140cdf0e10cSrcweir {
141cdf0e10cSrcweir xShapes = NULL;
142cdf0e10cSrcweir }
143cdf0e10cSrcweir }
144cdf0e10cSrcweir else
145cdf0e10cSrcweir {
146cdf0e10cSrcweir xShape = mpShape;
147cdf0e10cSrcweir }
148cdf0e10cSrcweir
149cdf0e10cSrcweir while( xShape.is() )
150cdf0e10cSrcweir {
151cdf0e10cSrcweir // replace in xShape
152cdf0e10cSrcweir uno::Reference< text::XText > xText(xShape, uno::UNO_QUERY);
153cdf0e10cSrcweir uno::Reference< text::XTextRange > xRange(xText, uno::UNO_QUERY);
154cdf0e10cSrcweir uno::Reference< text::XTextRange > xFound;
155cdf0e10cSrcweir
156cdf0e10cSrcweir while( xRange.is() )
157cdf0e10cSrcweir {
158cdf0e10cSrcweir xFound = Search( xRange, pDescr );
159cdf0e10cSrcweir if( !xFound.is() )
160cdf0e10cSrcweir break;
161cdf0e10cSrcweir
162cdf0e10cSrcweir xFound->setString( pDescr->getReplaceString() );
163cdf0e10cSrcweir xRange = xFound->getEnd();
164cdf0e10cSrcweir nFound++;
165cdf0e10cSrcweir }
166cdf0e10cSrcweir // done with xShape -> get next shape
167cdf0e10cSrcweir
168cdf0e10cSrcweir // test if its a group
169cdf0e10cSrcweir uno::Reference< drawing::XShapes > xGroupShape( xShape, uno::UNO_QUERY );
170cdf0e10cSrcweir if( xGroupShape.is() && ( xGroupShape->getCount() > 0 ) )
171cdf0e10cSrcweir {
172cdf0e10cSrcweir pContext = new SearchContext_impl( xGroupShape, pContext );
173cdf0e10cSrcweir xShape = pContext->firstShape();
174cdf0e10cSrcweir }
175cdf0e10cSrcweir else
176cdf0e10cSrcweir {
177cdf0e10cSrcweir if( pContext )
178cdf0e10cSrcweir xShape = pContext->nextShape();
179cdf0e10cSrcweir else
180cdf0e10cSrcweir xShape = NULL;
181cdf0e10cSrcweir }
182cdf0e10cSrcweir
183cdf0e10cSrcweir // test parent contexts for next shape if none
184cdf0e10cSrcweir // is found in the current context
185cdf0e10cSrcweir while( pContext && !xShape.is() )
186cdf0e10cSrcweir {
187cdf0e10cSrcweir if( pContext->getParent() )
188cdf0e10cSrcweir {
189cdf0e10cSrcweir SearchContext_impl* pOldContext = pContext;
190cdf0e10cSrcweir pContext = pContext->getParent();
191cdf0e10cSrcweir delete pOldContext;
192cdf0e10cSrcweir xShape = pContext->nextShape();
193cdf0e10cSrcweir }
194cdf0e10cSrcweir else
195cdf0e10cSrcweir {
196cdf0e10cSrcweir delete pContext;
197cdf0e10cSrcweir pContext = NULL;
198cdf0e10cSrcweir xShape = NULL;
199cdf0e10cSrcweir }
200cdf0e10cSrcweir }
201cdf0e10cSrcweir }
202cdf0e10cSrcweir
203cdf0e10cSrcweir return nFound;
204cdf0e10cSrcweir }
205cdf0e10cSrcweir
206cdf0e10cSrcweir // XSearchable
createSearchDescriptor()207cdf0e10cSrcweir uno::Reference< ::com::sun::star::util::XSearchDescriptor > SAL_CALL SdUnoSearchReplaceShape::createSearchDescriptor( )
208cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
209cdf0e10cSrcweir {
210cdf0e10cSrcweir return new SdUnoSearchReplaceDescriptor(sal_False);
211cdf0e10cSrcweir }
212cdf0e10cSrcweir
findAll(const::com::sun::star::uno::Reference<::com::sun::star::util::XSearchDescriptor> & xDesc)213cdf0e10cSrcweir uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL SdUnoSearchReplaceShape::findAll( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor >& xDesc )
214cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
215cdf0e10cSrcweir {
216cdf0e10cSrcweir SdUnoSearchReplaceDescriptor* pDescr = SdUnoSearchReplaceDescriptor::getImplementation( xDesc );
217cdf0e10cSrcweir if( pDescr == NULL )
218cdf0e10cSrcweir return uno::Reference< container::XIndexAccess > ();
219cdf0e10cSrcweir
220cdf0e10cSrcweir
221cdf0e10cSrcweir sal_Int32 nSequence = 32;
222cdf0e10cSrcweir sal_Int32 nFound = 0;
223cdf0e10cSrcweir
224cdf0e10cSrcweir uno::Sequence < uno::Reference< uno::XInterface > > aSeq( nSequence );
225cdf0e10cSrcweir
226cdf0e10cSrcweir uno::Reference< uno::XInterface > * pArray = aSeq.getArray();
227cdf0e10cSrcweir
228cdf0e10cSrcweir uno::Reference< drawing::XShapes > xShapes;
229cdf0e10cSrcweir uno::Reference< drawing::XShape > xShape;
230cdf0e10cSrcweir
231cdf0e10cSrcweir SearchContext_impl* pContext = NULL;
232cdf0e10cSrcweir if(mpPage)
233cdf0e10cSrcweir {
234cdf0e10cSrcweir uno::Reference< drawing::XDrawPage > xPage( mpPage );
235cdf0e10cSrcweir xPage->queryInterface( ITYPE( drawing::XShapes ) ) >>= xShapes;
236cdf0e10cSrcweir
237cdf0e10cSrcweir if( xShapes.is() && xShapes->getCount() > 0 )
238cdf0e10cSrcweir {
239cdf0e10cSrcweir pContext = new SearchContext_impl( xShapes );
240cdf0e10cSrcweir xShape = pContext->firstShape();
241cdf0e10cSrcweir }
242cdf0e10cSrcweir else
243cdf0e10cSrcweir {
244cdf0e10cSrcweir xShapes = NULL;
245cdf0e10cSrcweir }
246cdf0e10cSrcweir }
247cdf0e10cSrcweir else
248cdf0e10cSrcweir {
249cdf0e10cSrcweir xShape = mpShape;
250cdf0e10cSrcweir }
251cdf0e10cSrcweir while( xShape.is() )
252cdf0e10cSrcweir {
253cdf0e10cSrcweir // find in xShape
254cdf0e10cSrcweir uno::Reference< text::XText > xText(xShape, uno::UNO_QUERY);
255cdf0e10cSrcweir uno::Reference< text::XTextRange > xRange(xText, uno::UNO_QUERY);
256cdf0e10cSrcweir uno::Reference< text::XTextRange > xFound;
257cdf0e10cSrcweir
258cdf0e10cSrcweir while( xRange.is() )
259cdf0e10cSrcweir {
260cdf0e10cSrcweir xFound = Search( xRange, pDescr );
261cdf0e10cSrcweir if( !xFound.is() )
262cdf0e10cSrcweir break;
263cdf0e10cSrcweir
264cdf0e10cSrcweir if( nFound >= nSequence )
265cdf0e10cSrcweir {
266cdf0e10cSrcweir nSequence += 32;
267cdf0e10cSrcweir aSeq.realloc( nSequence );
268cdf0e10cSrcweir pArray = aSeq.getArray();
269cdf0e10cSrcweir }
270cdf0e10cSrcweir
271cdf0e10cSrcweir pArray[nFound++] = xFound;
272cdf0e10cSrcweir
273cdf0e10cSrcweir xRange = xFound->getEnd();
274cdf0e10cSrcweir }
275cdf0e10cSrcweir // done with shape -> get next shape
276cdf0e10cSrcweir
277cdf0e10cSrcweir // test if its a group
278cdf0e10cSrcweir uno::Reference< drawing::XShapes > xGroupShape;
279cdf0e10cSrcweir uno::Any aAny( xShape->queryInterface( ITYPE( drawing::XShapes )));
280cdf0e10cSrcweir
281cdf0e10cSrcweir if( (aAny >>= xGroupShape ) && xGroupShape->getCount() > 0 )
282cdf0e10cSrcweir {
283cdf0e10cSrcweir pContext = new SearchContext_impl( xGroupShape, pContext );
284cdf0e10cSrcweir xShape = pContext->firstShape();
285cdf0e10cSrcweir }
286cdf0e10cSrcweir else
287cdf0e10cSrcweir {
288cdf0e10cSrcweir if( pContext )
289cdf0e10cSrcweir xShape = pContext->nextShape();
290cdf0e10cSrcweir else
291cdf0e10cSrcweir xShape = NULL;
292cdf0e10cSrcweir }
293cdf0e10cSrcweir
294cdf0e10cSrcweir // test parent contexts for next shape if none
295cdf0e10cSrcweir // is found in the current context
296cdf0e10cSrcweir while( pContext && !xShape.is() )
297cdf0e10cSrcweir {
298cdf0e10cSrcweir if( pContext->getParent() )
299cdf0e10cSrcweir {
300cdf0e10cSrcweir SearchContext_impl* pOldContext = pContext;
301cdf0e10cSrcweir pContext = pContext->getParent();
302cdf0e10cSrcweir delete pOldContext;
303cdf0e10cSrcweir xShape = pContext->nextShape();
304cdf0e10cSrcweir }
305cdf0e10cSrcweir else
306cdf0e10cSrcweir {
307cdf0e10cSrcweir delete pContext;
308cdf0e10cSrcweir pContext = NULL;
309cdf0e10cSrcweir xShape = NULL;
310cdf0e10cSrcweir }
311cdf0e10cSrcweir }
312cdf0e10cSrcweir }
313cdf0e10cSrcweir
314cdf0e10cSrcweir if( nFound != nSequence )
315cdf0e10cSrcweir aSeq.realloc( nFound );
316cdf0e10cSrcweir
317cdf0e10cSrcweir return (container::XIndexAccess*)new SdUnoFindAllAccess( aSeq );
318cdf0e10cSrcweir }
319cdf0e10cSrcweir
findFirst(const::com::sun::star::uno::Reference<::com::sun::star::util::XSearchDescriptor> & xDesc)320cdf0e10cSrcweir uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SdUnoSearchReplaceShape::findFirst( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor >& xDesc )
321cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
322cdf0e10cSrcweir {
323cdf0e10cSrcweir uno::Reference< text::XTextRange > xRange( GetCurrentShape(), uno::UNO_QUERY );
324cdf0e10cSrcweir if( xRange.is() )
325cdf0e10cSrcweir return findNext( xRange, xDesc );
326cdf0e10cSrcweir
327cdf0e10cSrcweir return uno::Reference< uno::XInterface > ();
328cdf0e10cSrcweir }
329cdf0e10cSrcweir
GetCurrentShape() const330cdf0e10cSrcweir uno::Reference< drawing::XShape > SdUnoSearchReplaceShape::GetCurrentShape() const throw()
331cdf0e10cSrcweir {
332cdf0e10cSrcweir uno::Reference< drawing::XShape > xShape;
333cdf0e10cSrcweir
334cdf0e10cSrcweir if( mpPage )
335cdf0e10cSrcweir {
336cdf0e10cSrcweir uno::Reference< drawing::XDrawPage > xPage( mpPage );
337cdf0e10cSrcweir uno::Reference< container::XIndexAccess > xShapes( xPage, uno::UNO_QUERY );
338cdf0e10cSrcweir if( xShapes.is() )
339cdf0e10cSrcweir {
340cdf0e10cSrcweir if(xShapes->getCount() > 0)
341cdf0e10cSrcweir {
342cdf0e10cSrcweir xShapes->getByIndex(0) >>= xShape;
343cdf0e10cSrcweir }
344cdf0e10cSrcweir }
345cdf0e10cSrcweir }
346cdf0e10cSrcweir else if( mpShape )
347cdf0e10cSrcweir {
348cdf0e10cSrcweir xShape = mpShape;
349cdf0e10cSrcweir }
350cdf0e10cSrcweir
351cdf0e10cSrcweir return xShape;
352cdf0e10cSrcweir
353cdf0e10cSrcweir }
354cdf0e10cSrcweir
findNext(const::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> & xStartAt,const::com::sun::star::uno::Reference<::com::sun::star::util::XSearchDescriptor> & xDesc)355cdf0e10cSrcweir uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SdUnoSearchReplaceShape::findNext( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xStartAt, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor >& xDesc )
356cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
357cdf0e10cSrcweir {
358cdf0e10cSrcweir SdUnoSearchReplaceDescriptor* pDescr = SdUnoSearchReplaceDescriptor::getImplementation( xDesc );
359cdf0e10cSrcweir
360cdf0e10cSrcweir uno::Reference< uno::XInterface > xFound;
361cdf0e10cSrcweir
362cdf0e10cSrcweir uno::Reference< text::XTextRange > xRange( xStartAt, uno::UNO_QUERY );
363cdf0e10cSrcweir if(pDescr && xRange.is() )
364cdf0e10cSrcweir {
365cdf0e10cSrcweir
366cdf0e10cSrcweir uno::Reference< text::XTextRange > xCurrentRange( xStartAt, uno::UNO_QUERY );
367cdf0e10cSrcweir
368cdf0e10cSrcweir uno::Reference< drawing::XShape > xCurrentShape( GetShape( xCurrentRange ) );
369cdf0e10cSrcweir
370cdf0e10cSrcweir while(!xFound.is() && xRange.is())
371cdf0e10cSrcweir {
372cdf0e10cSrcweir xFound = Search( xRange, pDescr );
373cdf0e10cSrcweir if(!xFound.is())
374cdf0e10cSrcweir {
375cdf0e10cSrcweir // we need a new starting range now
376cdf0e10cSrcweir xRange = NULL;
377cdf0e10cSrcweir
378cdf0e10cSrcweir if(mpPage)
379cdf0e10cSrcweir {
380cdf0e10cSrcweir uno::Reference< drawing::XDrawPage > xPage( mpPage );
381cdf0e10cSrcweir
382cdf0e10cSrcweir // we do a page wide search, so skip to the next shape here
383cdf0e10cSrcweir uno::Reference< container::XIndexAccess > xShapes( xPage, uno::UNO_QUERY );
384cdf0e10cSrcweir
385cdf0e10cSrcweir // get next shape on our page
386cdf0e10cSrcweir if( xShapes.is() )
387cdf0e10cSrcweir {
388cdf0e10cSrcweir uno::Reference< drawing::XShape > xFound2( GetNextShape( xShapes, xCurrentShape ) );
389cdf0e10cSrcweir if( xFound2.is() && (xFound2.get() != xCurrentShape.get()) )
390cdf0e10cSrcweir xCurrentShape = xFound2;
391cdf0e10cSrcweir else
392cdf0e10cSrcweir xCurrentShape = NULL;
393cdf0e10cSrcweir
394cdf0e10cSrcweir xCurrentShape->queryInterface( ITYPE( text::XTextRange ) ) >>= xRange;
395cdf0e10cSrcweir if(!(xCurrentShape.is() && (xRange.is())))
396cdf0e10cSrcweir xRange = NULL;
397cdf0e10cSrcweir }
398cdf0e10cSrcweir }
399cdf0e10cSrcweir else
400cdf0e10cSrcweir {
401cdf0e10cSrcweir // we search only in this shape, so end search if we have
402cdf0e10cSrcweir // not found anything
403cdf0e10cSrcweir }
404cdf0e10cSrcweir }
405cdf0e10cSrcweir }
406cdf0e10cSrcweir }
407cdf0e10cSrcweir return xFound;
408cdf0e10cSrcweir }
409cdf0e10cSrcweir
410cdf0e10cSrcweir /** this method returns the shape that follows xCurrentShape in the shape collection xShapes.
411cdf0e10cSrcweir It steps recursive into groupshapes and returns the xCurrentShape if it is the last
412cdf0e10cSrcweir shape in this collection */
GetNextShape(uno::Reference<container::XIndexAccess> xShapes,uno::Reference<drawing::XShape> xCurrentShape)413cdf0e10cSrcweir uno::Reference< drawing::XShape > SdUnoSearchReplaceShape::GetNextShape( uno::Reference< container::XIndexAccess > xShapes, uno::Reference< drawing::XShape > xCurrentShape ) throw()
414cdf0e10cSrcweir {
415cdf0e10cSrcweir uno::Reference< drawing::XShape > xFound;
416cdf0e10cSrcweir uno::Any aAny;
417cdf0e10cSrcweir
418cdf0e10cSrcweir if(xShapes.is() && xCurrentShape.is())
419cdf0e10cSrcweir {
420cdf0e10cSrcweir const sal_Int32 nCount = xShapes->getCount();
421cdf0e10cSrcweir for( sal_Int32 i = 0; i < nCount; i++ )
422cdf0e10cSrcweir {
423cdf0e10cSrcweir uno::Reference< drawing::XShape > xSearchShape;
424cdf0e10cSrcweir xShapes->getByIndex(i) >>= xSearchShape;
425cdf0e10cSrcweir
426cdf0e10cSrcweir if( xSearchShape.is() )
427cdf0e10cSrcweir {
428cdf0e10cSrcweir uno::Reference< container::XIndexAccess > xGroup( xSearchShape, uno::UNO_QUERY );
429cdf0e10cSrcweir
430cdf0e10cSrcweir if( xCurrentShape.get() == xSearchShape.get() )
431cdf0e10cSrcweir {
432cdf0e10cSrcweir if( xGroup.is() && xGroup->getCount() > 0 )
433cdf0e10cSrcweir {
434cdf0e10cSrcweir xGroup->getByIndex( 0 ) >>= xFound;
435cdf0e10cSrcweir }
436cdf0e10cSrcweir else
437cdf0e10cSrcweir {
438cdf0e10cSrcweir i++;
439cdf0e10cSrcweir if( i < nCount )
440cdf0e10cSrcweir xShapes->getByIndex( i ) >>= xFound;
441cdf0e10cSrcweir else
442cdf0e10cSrcweir xFound = xCurrentShape;
443cdf0e10cSrcweir }
444cdf0e10cSrcweir
445cdf0e10cSrcweir break;
446cdf0e10cSrcweir }
447cdf0e10cSrcweir else if( xGroup.is() )
448cdf0e10cSrcweir {
449cdf0e10cSrcweir xFound = GetNextShape( xGroup, xCurrentShape );
450cdf0e10cSrcweir if( xFound.is() )
451cdf0e10cSrcweir {
452cdf0e10cSrcweir if( xFound.get() == xCurrentShape.get() )
453cdf0e10cSrcweir {
454cdf0e10cSrcweir // the current shape was found at the end of the group
455cdf0e10cSrcweir i++;
456cdf0e10cSrcweir if( i < nCount )
457cdf0e10cSrcweir {
458cdf0e10cSrcweir xShapes->getByIndex(i) >>= xFound;
459cdf0e10cSrcweir }
460cdf0e10cSrcweir }
461cdf0e10cSrcweir break;
462cdf0e10cSrcweir }
463cdf0e10cSrcweir }
464cdf0e10cSrcweir }
465cdf0e10cSrcweir }
466cdf0e10cSrcweir }
467cdf0e10cSrcweir
468cdf0e10cSrcweir return xFound;
469cdf0e10cSrcweir }
470cdf0e10cSrcweir
Search(uno::Reference<text::XTextRange> xText,SdUnoSearchReplaceDescriptor * pDescr)471cdf0e10cSrcweir uno::Reference< text::XTextRange > SdUnoSearchReplaceShape::Search( uno::Reference< text::XTextRange > xText, SdUnoSearchReplaceDescriptor* pDescr ) throw()
472cdf0e10cSrcweir {
473cdf0e10cSrcweir if(!xText.is())
474cdf0e10cSrcweir return uno::Reference< text::XTextRange > ();
475cdf0e10cSrcweir
476cdf0e10cSrcweir uno::Reference< text::XText > xParent( xText->getText() );
477cdf0e10cSrcweir
478cdf0e10cSrcweir if( !xParent.is() )
479cdf0e10cSrcweir {
480cdf0e10cSrcweir uno::Any aAny( xText->queryInterface( ITYPE( text::XText )) );
481cdf0e10cSrcweir aAny >>= xParent;
482cdf0e10cSrcweir }
483cdf0e10cSrcweir
484cdf0e10cSrcweir const OUString aText( xParent->getString() );
485cdf0e10cSrcweir
486cdf0e10cSrcweir const sal_Int32 nTextLen = aText.getLength();
487cdf0e10cSrcweir
488cdf0e10cSrcweir sal_Int32* pConvertPos = new sal_Int32[nTextLen+2];
489cdf0e10cSrcweir sal_Int32* pConvertPara = new sal_Int32[nTextLen+2];
490cdf0e10cSrcweir
491cdf0e10cSrcweir int ndbg = 0;
492*24c56ab9SHerbert Dürr const sal_Unicode* pText = aText.getStr();
493cdf0e10cSrcweir
494cdf0e10cSrcweir sal_Int32* pPos = pConvertPos;
495cdf0e10cSrcweir sal_Int32* pPara = pConvertPara;
496cdf0e10cSrcweir
497cdf0e10cSrcweir sal_Int32 nLastPos = 0, nLastPara = 0;
498cdf0e10cSrcweir
499cdf0e10cSrcweir uno::Reference< container::XEnumerationAccess > xEnumAccess( xParent, uno::UNO_QUERY );
500cdf0e10cSrcweir
501cdf0e10cSrcweir // first we fill the arrys with the position and paragraph for every character
502cdf0e10cSrcweir // inside the text
503cdf0e10cSrcweir if( xEnumAccess.is() )
504cdf0e10cSrcweir {
505cdf0e10cSrcweir uno::Reference< container::XEnumeration > xParaEnum( xEnumAccess->createEnumeration() );
506cdf0e10cSrcweir
507cdf0e10cSrcweir while(xParaEnum->hasMoreElements())
508cdf0e10cSrcweir {
509cdf0e10cSrcweir uno::Reference< text::XTextContent > xParagraph( xParaEnum->nextElement(), uno::UNO_QUERY );
510cdf0e10cSrcweir if( xParagraph.is() )
511cdf0e10cSrcweir xEnumAccess.query( xParagraph );
512cdf0e10cSrcweir else
513cdf0e10cSrcweir xEnumAccess.clear();
514cdf0e10cSrcweir
515cdf0e10cSrcweir if( xEnumAccess.is() )
516cdf0e10cSrcweir {
517cdf0e10cSrcweir uno::Reference< container::XEnumeration > xPortionEnum( xEnumAccess->createEnumeration() );
518cdf0e10cSrcweir if( xPortionEnum.is() )
519cdf0e10cSrcweir {
520cdf0e10cSrcweir while(xPortionEnum->hasMoreElements())
521cdf0e10cSrcweir {
522cdf0e10cSrcweir uno::Reference< text::XTextRange > xPortion( xPortionEnum->nextElement(), uno::UNO_QUERY );
523cdf0e10cSrcweir if( xPortion.is() )
524cdf0e10cSrcweir {
525cdf0e10cSrcweir const OUString aPortion( xPortion->getString() );
526cdf0e10cSrcweir const sal_Int32 nLen = aPortion.getLength();
527cdf0e10cSrcweir
528cdf0e10cSrcweir ESelection aStartSel( GetSelection( xPortion->getStart() ) );
529cdf0e10cSrcweir ESelection aEndSel( GetSelection( xPortion->getEnd() ) );
530cdf0e10cSrcweir
531cdf0e10cSrcweir // special case for empty portions with content or length one portions with content (fields)
532cdf0e10cSrcweir if( (aStartSel.nStartPos == aEndSel.nStartPos) || ( (aStartSel.nStartPos == (aEndSel.nStartPos - 1)) && (nLen > 1) ) )
533cdf0e10cSrcweir {
534cdf0e10cSrcweir for( sal_Int32 i = 0; i < nLen; i++ )
535cdf0e10cSrcweir {
536cdf0e10cSrcweir if( ndbg < (nTextLen+2) )
537cdf0e10cSrcweir {
538cdf0e10cSrcweir *pPos++ = aStartSel.nStartPos;
539cdf0e10cSrcweir *pPara++ = aStartSel.nStartPara;
540cdf0e10cSrcweir
541cdf0e10cSrcweir ndbg += 1;
542cdf0e10cSrcweir pText++;
543cdf0e10cSrcweir }
544cdf0e10cSrcweir else
545cdf0e10cSrcweir {
546cdf0e10cSrcweir DBG_ERROR( "array overflow while searching" );
547cdf0e10cSrcweir }
548cdf0e10cSrcweir }
549cdf0e10cSrcweir
550cdf0e10cSrcweir nLastPos = aStartSel.nStartPos;
551cdf0e10cSrcweir }
552cdf0e10cSrcweir // normal case
553cdf0e10cSrcweir else
554cdf0e10cSrcweir {
555cdf0e10cSrcweir for( sal_Int32 i = 0; i < nLen; i++ )
556cdf0e10cSrcweir {
557cdf0e10cSrcweir if( ndbg < (nTextLen+2) )
558cdf0e10cSrcweir {
559cdf0e10cSrcweir *pPos++ = aStartSel.nStartPos++;
560cdf0e10cSrcweir *pPara++ = aStartSel.nStartPara;
561cdf0e10cSrcweir
562cdf0e10cSrcweir ndbg += 1;
563cdf0e10cSrcweir pText++;
564cdf0e10cSrcweir }
565cdf0e10cSrcweir else
566cdf0e10cSrcweir {
567cdf0e10cSrcweir DBG_ERROR( "array overflow while searching" );
568cdf0e10cSrcweir }
569cdf0e10cSrcweir }
570cdf0e10cSrcweir
571cdf0e10cSrcweir nLastPos = aStartSel.nStartPos - 1;
572cdf0e10cSrcweir DBG_ASSERT( aEndSel.nStartPos == aStartSel.nStartPos, "Search is not working" );
573cdf0e10cSrcweir }
574cdf0e10cSrcweir nLastPara = aStartSel.nStartPara;
575cdf0e10cSrcweir }
576cdf0e10cSrcweir }
577cdf0e10cSrcweir }
578cdf0e10cSrcweir }
579cdf0e10cSrcweir
580cdf0e10cSrcweir if( ndbg < (nTextLen+2) )
581cdf0e10cSrcweir {
582cdf0e10cSrcweir *pPos++ = nLastPos + 1;
583cdf0e10cSrcweir *pPara++ = nLastPara;
584cdf0e10cSrcweir
585cdf0e10cSrcweir ndbg += 1;
586cdf0e10cSrcweir pText++;
587cdf0e10cSrcweir }
588cdf0e10cSrcweir else
589cdf0e10cSrcweir {
590cdf0e10cSrcweir DBG_ERROR( "array overflow while searching" );
591cdf0e10cSrcweir }
592cdf0e10cSrcweir }
593cdf0e10cSrcweir }
594cdf0e10cSrcweir
595cdf0e10cSrcweir uno::Reference< text::XText > xFound;
596cdf0e10cSrcweir ESelection aSel;
597cdf0e10cSrcweir
598cdf0e10cSrcweir uno::Reference< text::XTextRange > xRangeRef( xText, uno::UNO_QUERY );
599cdf0e10cSrcweir if( xRangeRef.is() )
600cdf0e10cSrcweir aSel = GetSelection( xRangeRef );
601cdf0e10cSrcweir
602cdf0e10cSrcweir sal_Int32 nStartPos;
603cdf0e10cSrcweir sal_Int32 nEndPos = 0;
604cdf0e10cSrcweir for( nStartPos = 0; nStartPos < nTextLen; nStartPos++ )
605cdf0e10cSrcweir {
606cdf0e10cSrcweir if( pConvertPara[nStartPos] == aSel.nStartPara && pConvertPos[nStartPos] == aSel.nStartPos )
607cdf0e10cSrcweir break;
608cdf0e10cSrcweir }
609cdf0e10cSrcweir
610cdf0e10cSrcweir if( Search( aText, nStartPos, nEndPos, pDescr ) )
611cdf0e10cSrcweir {
612cdf0e10cSrcweir if( nStartPos <= nTextLen && nEndPos <= nTextLen )
613cdf0e10cSrcweir {
614cdf0e10cSrcweir ESelection aSelection( (sal_uInt16)pConvertPara[nStartPos], (sal_uInt16)pConvertPos[nStartPos],
615cdf0e10cSrcweir (sal_uInt16)pConvertPara[nEndPos], (sal_uInt16)pConvertPos[nEndPos] );
616cdf0e10cSrcweir SvxUnoTextRange *pRange;
617cdf0e10cSrcweir
618cdf0e10cSrcweir SvxUnoTextBase* pParent = SvxUnoTextBase::getImplementation( xParent );
619cdf0e10cSrcweir
620cdf0e10cSrcweir if(pParent)
621cdf0e10cSrcweir {
622cdf0e10cSrcweir pRange = new SvxUnoTextRange( *pParent );
623cdf0e10cSrcweir xFound = (text::XText*)pRange;
624cdf0e10cSrcweir pRange->SetSelection(aSelection);
625cdf0e10cSrcweir
626cdf0e10cSrcweir // pDescr->SetStartPos( nEndPos );
627cdf0e10cSrcweir }
628cdf0e10cSrcweir }
629cdf0e10cSrcweir else
630cdf0e10cSrcweir {
631cdf0e10cSrcweir DBG_ERROR("Array overflow while searching!");
632cdf0e10cSrcweir }
633cdf0e10cSrcweir }
634cdf0e10cSrcweir
635cdf0e10cSrcweir delete[] pConvertPos;
636cdf0e10cSrcweir delete[] pConvertPara;
637cdf0e10cSrcweir
638cdf0e10cSrcweir return uno::Reference< text::XTextRange > ( xFound, uno::UNO_QUERY );
639cdf0e10cSrcweir }
640cdf0e10cSrcweir
Search(const OUString & rText,sal_Int32 & nStartPos,sal_Int32 & nEndPos,SdUnoSearchReplaceDescriptor * pDescr)641cdf0e10cSrcweir sal_Bool SdUnoSearchReplaceShape::Search( const OUString& rText, sal_Int32& nStartPos, sal_Int32& nEndPos, SdUnoSearchReplaceDescriptor* pDescr ) throw()
642cdf0e10cSrcweir {
643cdf0e10cSrcweir OUString aSearchStr( pDescr->getSearchString() );
644cdf0e10cSrcweir OUString aText( rText );
645cdf0e10cSrcweir
646cdf0e10cSrcweir if( !pDescr->IsCaseSensitive() )
647cdf0e10cSrcweir {
648cdf0e10cSrcweir aText.toAsciiLowerCase();
649cdf0e10cSrcweir aSearchStr.toAsciiLowerCase();
650cdf0e10cSrcweir }
651cdf0e10cSrcweir
652cdf0e10cSrcweir sal_Int32 nFound = aText.indexOf( aSearchStr, nStartPos );
653cdf0e10cSrcweir if( nFound != -1 )
654cdf0e10cSrcweir {
655cdf0e10cSrcweir nStartPos = nFound;
656cdf0e10cSrcweir nEndPos = nFound + aSearchStr.getLength();
657cdf0e10cSrcweir
658cdf0e10cSrcweir if(pDescr->IsWords())
659cdf0e10cSrcweir {
660cdf0e10cSrcweir if( (nStartPos > 0 && aText.getStr()[nStartPos-1] > ' ') ||
661cdf0e10cSrcweir (nEndPos < aText.getLength() && aText.getStr()[nEndPos] > ' ') )
662cdf0e10cSrcweir {
663cdf0e10cSrcweir nStartPos++;
664cdf0e10cSrcweir return Search( aText, nStartPos, nEndPos, pDescr );
665cdf0e10cSrcweir }
666cdf0e10cSrcweir }
667cdf0e10cSrcweir
668cdf0e10cSrcweir return sal_True;
669cdf0e10cSrcweir }
670cdf0e10cSrcweir else
671cdf0e10cSrcweir return sal_False;
672cdf0e10cSrcweir }
673cdf0e10cSrcweir
GetSelection(uno::Reference<text::XTextRange> xTextRange)674cdf0e10cSrcweir ESelection SdUnoSearchReplaceShape::GetSelection( uno::Reference< text::XTextRange > xTextRange ) throw()
675cdf0e10cSrcweir {
676cdf0e10cSrcweir ESelection aSel;
677cdf0e10cSrcweir SvxUnoTextRangeBase* pRange = SvxUnoTextRangeBase::getImplementation( xTextRange );
678cdf0e10cSrcweir
679cdf0e10cSrcweir if(pRange)
680cdf0e10cSrcweir aSel = pRange->GetSelection();
681cdf0e10cSrcweir
682cdf0e10cSrcweir return aSel;
683cdf0e10cSrcweir }
684cdf0e10cSrcweir
GetShape(uno::Reference<text::XTextRange> xTextRange)685cdf0e10cSrcweir uno::Reference< drawing::XShape > SdUnoSearchReplaceShape::GetShape( uno::Reference< text::XTextRange > xTextRange ) throw()
686cdf0e10cSrcweir {
687cdf0e10cSrcweir uno::Reference< drawing::XShape > xShape;
688cdf0e10cSrcweir
689cdf0e10cSrcweir if(xTextRange.is())
690cdf0e10cSrcweir {
691cdf0e10cSrcweir uno::Reference< text::XText > xText( xTextRange->getText() );
692cdf0e10cSrcweir
693cdf0e10cSrcweir if(xText.is())
694cdf0e10cSrcweir {
695cdf0e10cSrcweir do
696cdf0e10cSrcweir {
697cdf0e10cSrcweir xText->queryInterface( ITYPE( drawing::XShape )) >>= xShape;
698cdf0e10cSrcweir if(!xShape.is())
699cdf0e10cSrcweir {
700cdf0e10cSrcweir uno::Reference< text::XText > xParent( xText->getText() );
701cdf0e10cSrcweir if(!xParent.is() || xText.get() == xParent.get())
702cdf0e10cSrcweir return xShape;
703cdf0e10cSrcweir
704cdf0e10cSrcweir xText = xParent;
705cdf0e10cSrcweir }
706cdf0e10cSrcweir } while( !xShape.is() );
707cdf0e10cSrcweir }
708cdf0e10cSrcweir }
709cdf0e10cSrcweir
710cdf0e10cSrcweir return xShape;
711cdf0e10cSrcweir }
712cdf0e10cSrcweir
713cdf0e10cSrcweir /* ================================================================= */
714cdf0e10cSrcweir /** this class holds the parameters and status of a search or replace
715cdf0e10cSrcweir operation performed by class SdUnoSearchReplaceShape
716cdf0e10cSrcweir */
717cdf0e10cSrcweir
718cdf0e10cSrcweir UNO3_GETIMPLEMENTATION_IMPL( SdUnoSearchReplaceDescriptor );
719cdf0e10cSrcweir
SdUnoSearchReplaceDescriptor(sal_Bool bReplace)720cdf0e10cSrcweir SdUnoSearchReplaceDescriptor::SdUnoSearchReplaceDescriptor( sal_Bool bReplace ) throw()
721cdf0e10cSrcweir {
722cdf0e10cSrcweir mpPropSet = new SvxItemPropertySet(ImplGetSearchPropertyMap(), SdrObject::GetGlobalDrawObjectItemPool());
723cdf0e10cSrcweir
724cdf0e10cSrcweir mbBackwards = sal_False;
725cdf0e10cSrcweir mbCaseSensitive = sal_False;
726cdf0e10cSrcweir mbWords = sal_False;
727cdf0e10cSrcweir
728cdf0e10cSrcweir mbReplace = bReplace;
729cdf0e10cSrcweir }
730cdf0e10cSrcweir
~SdUnoSearchReplaceDescriptor()731cdf0e10cSrcweir SdUnoSearchReplaceDescriptor::~SdUnoSearchReplaceDescriptor() throw()
732cdf0e10cSrcweir {
733cdf0e10cSrcweir delete mpPropSet;
734cdf0e10cSrcweir }
735cdf0e10cSrcweir
736cdf0e10cSrcweir // XSearchDescriptor
getSearchString()737cdf0e10cSrcweir OUString SAL_CALL SdUnoSearchReplaceDescriptor::getSearchString()
738cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
739cdf0e10cSrcweir {
740cdf0e10cSrcweir return maSearchStr;
741cdf0e10cSrcweir }
742cdf0e10cSrcweir
setSearchString(const OUString & aString)743cdf0e10cSrcweir void SAL_CALL SdUnoSearchReplaceDescriptor::setSearchString( const OUString& aString )
744cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
745cdf0e10cSrcweir {
746cdf0e10cSrcweir maSearchStr = aString;
747cdf0e10cSrcweir }
748cdf0e10cSrcweir
749cdf0e10cSrcweir // XReplaceDescriptor
getReplaceString()750cdf0e10cSrcweir OUString SAL_CALL SdUnoSearchReplaceDescriptor::getReplaceString()
751cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
752cdf0e10cSrcweir {
753cdf0e10cSrcweir return maReplaceStr;
754cdf0e10cSrcweir }
755cdf0e10cSrcweir
setReplaceString(const::rtl::OUString & aReplaceString)756cdf0e10cSrcweir void SAL_CALL SdUnoSearchReplaceDescriptor::setReplaceString( const ::rtl::OUString& aReplaceString )
757cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
758cdf0e10cSrcweir {
759cdf0e10cSrcweir maReplaceStr = aReplaceString;
760cdf0e10cSrcweir }
761cdf0e10cSrcweir
762cdf0e10cSrcweir // XPropertySet
getPropertySetInfo()763cdf0e10cSrcweir uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL SdUnoSearchReplaceDescriptor::getPropertySetInfo()
764cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
765cdf0e10cSrcweir {
766cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() );
767cdf0e10cSrcweir return mpPropSet->getPropertySetInfo();
768cdf0e10cSrcweir }
769cdf0e10cSrcweir
setPropertyValue(const::rtl::OUString & aPropertyName,const::com::sun::star::uno::Any & aValue)770cdf0e10cSrcweir void SAL_CALL SdUnoSearchReplaceDescriptor::setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
771cdf0e10cSrcweir throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
772cdf0e10cSrcweir {
773cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() );
774cdf0e10cSrcweir
775cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(aPropertyName);
776cdf0e10cSrcweir
777cdf0e10cSrcweir sal_Bool bOk = sal_False;
778cdf0e10cSrcweir
779cdf0e10cSrcweir switch( pEntry ? pEntry->nWID : -1 )
780cdf0e10cSrcweir {
781cdf0e10cSrcweir case WID_SEARCH_BACKWARDS:
782cdf0e10cSrcweir bOk = (aValue >>= mbBackwards);
783cdf0e10cSrcweir break;
784cdf0e10cSrcweir case WID_SEARCH_CASE:
785cdf0e10cSrcweir bOk = (aValue >>= mbCaseSensitive);
786cdf0e10cSrcweir break;
787cdf0e10cSrcweir case WID_SEARCH_WORDS:
788cdf0e10cSrcweir bOk = (aValue >>= mbWords);
789cdf0e10cSrcweir break;
790cdf0e10cSrcweir default:
791cdf0e10cSrcweir throw beans::UnknownPropertyException();
792cdf0e10cSrcweir }
793cdf0e10cSrcweir
794cdf0e10cSrcweir if( !bOk )
795cdf0e10cSrcweir throw lang::IllegalArgumentException();
796cdf0e10cSrcweir }
797cdf0e10cSrcweir
getPropertyValue(const::rtl::OUString & PropertyName)798cdf0e10cSrcweir uno::Any SAL_CALL SdUnoSearchReplaceDescriptor::getPropertyValue( const ::rtl::OUString& PropertyName )
799cdf0e10cSrcweir throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
800cdf0e10cSrcweir {
801cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() );
802cdf0e10cSrcweir
803cdf0e10cSrcweir uno::Any aAny;
804cdf0e10cSrcweir
805cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(PropertyName);
806cdf0e10cSrcweir
807cdf0e10cSrcweir switch( pEntry ? pEntry->nWID : -1 )
808cdf0e10cSrcweir {
809cdf0e10cSrcweir case WID_SEARCH_BACKWARDS:
810cdf0e10cSrcweir aAny <<= (sal_Bool)mbBackwards;
811cdf0e10cSrcweir break;
812cdf0e10cSrcweir case WID_SEARCH_CASE:
813cdf0e10cSrcweir aAny <<= (sal_Bool)mbCaseSensitive;
814cdf0e10cSrcweir break;
815cdf0e10cSrcweir case WID_SEARCH_WORDS:
816cdf0e10cSrcweir aAny <<= (sal_Bool)mbWords;
817cdf0e10cSrcweir break;
818cdf0e10cSrcweir default:
819cdf0e10cSrcweir throw beans::UnknownPropertyException();
820cdf0e10cSrcweir }
821cdf0e10cSrcweir
822cdf0e10cSrcweir return aAny;
823cdf0e10cSrcweir }
824cdf0e10cSrcweir
addPropertyChangeListener(const::rtl::OUString &,const::com::sun::star::uno::Reference<::com::sun::star::beans::XPropertyChangeListener> &)825cdf0e10cSrcweir void SAL_CALL SdUnoSearchReplaceDescriptor::addPropertyChangeListener( const ::rtl::OUString& , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) {}
removePropertyChangeListener(const::rtl::OUString &,const::com::sun::star::uno::Reference<::com::sun::star::beans::XPropertyChangeListener> &)826cdf0e10cSrcweir void SAL_CALL SdUnoSearchReplaceDescriptor::removePropertyChangeListener( const ::rtl::OUString& , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) {}
addVetoableChangeListener(const::rtl::OUString &,const::com::sun::star::uno::Reference<::com::sun::star::beans::XVetoableChangeListener> &)827cdf0e10cSrcweir void SAL_CALL SdUnoSearchReplaceDescriptor::addVetoableChangeListener( const ::rtl::OUString& , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) {}
removeVetoableChangeListener(const::rtl::OUString &,const::com::sun::star::uno::Reference<::com::sun::star::beans::XVetoableChangeListener> &)828cdf0e10cSrcweir void SAL_CALL SdUnoSearchReplaceDescriptor::removeVetoableChangeListener( const ::rtl::OUString& , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) {}
829cdf0e10cSrcweir
830cdf0e10cSrcweir
831cdf0e10cSrcweir /* ================================================================= */
832cdf0e10cSrcweir
SdUnoFindAllAccess(uno::Sequence<uno::Reference<uno::XInterface>> & rSequence)833cdf0e10cSrcweir SdUnoFindAllAccess::SdUnoFindAllAccess( uno::Sequence< uno::Reference< uno::XInterface > >& rSequence ) throw()
834cdf0e10cSrcweir :maSequence( rSequence )
835cdf0e10cSrcweir {
836cdf0e10cSrcweir }
837cdf0e10cSrcweir
~SdUnoFindAllAccess()838cdf0e10cSrcweir SdUnoFindAllAccess::~SdUnoFindAllAccess() throw()
839cdf0e10cSrcweir {
840cdf0e10cSrcweir }
841cdf0e10cSrcweir
842cdf0e10cSrcweir // XElementAccess
getElementType()843cdf0e10cSrcweir uno::Type SAL_CALL SdUnoFindAllAccess::getElementType()
844cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
845cdf0e10cSrcweir {
846cdf0e10cSrcweir return ITYPE( text::XTextRange );
847cdf0e10cSrcweir }
848cdf0e10cSrcweir
hasElements()849cdf0e10cSrcweir sal_Bool SAL_CALL SdUnoFindAllAccess::hasElements()
850cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
851cdf0e10cSrcweir {
852cdf0e10cSrcweir return maSequence.getLength() > 0;
853cdf0e10cSrcweir }
854cdf0e10cSrcweir
855cdf0e10cSrcweir // XIndexAccess
getCount()856cdf0e10cSrcweir sal_Int32 SAL_CALL SdUnoFindAllAccess::getCount()
857cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
858cdf0e10cSrcweir {
859cdf0e10cSrcweir return maSequence.getLength();
860cdf0e10cSrcweir }
861cdf0e10cSrcweir
getByIndex(sal_Int32 Index)862cdf0e10cSrcweir uno::Any SAL_CALL SdUnoFindAllAccess::getByIndex( sal_Int32 Index )
863cdf0e10cSrcweir throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
864cdf0e10cSrcweir {
865cdf0e10cSrcweir uno::Any aAny;
866cdf0e10cSrcweir
867cdf0e10cSrcweir if( Index < 0 || Index >= getCount() )
868cdf0e10cSrcweir throw lang::IndexOutOfBoundsException();
869cdf0e10cSrcweir
870cdf0e10cSrcweir const uno::Reference< uno::XInterface > *pRefs = maSequence.getConstArray();
871cdf0e10cSrcweir if(pRefs)
872cdf0e10cSrcweir aAny <<= pRefs[ Index ];
873cdf0e10cSrcweir return aAny;
874cdf0e10cSrcweir }
875cdf0e10cSrcweir
876