Update ooo320-m1
[ooovba.git] / sd / source / ui / inc / unosrch.hxx
blob556509936e0f1e15eb9a36a96770354e20ae20a3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unosrch.hxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <com/sun/star/drawing/XShape.hpp>
32 #include <com/sun/star/drawing/XDrawPage.hpp>
33 #include <com/sun/star/text/XTextRange.hpp>
34 #include <com/sun/star/drawing/XShapes.hpp>
35 #include <com/sun/star/util/XReplaceable.hpp>
36 #include <com/sun/star/util/XSearchable.hpp>
37 #include <com/sun/star/util/XSearchDescriptor.hpp>
38 #include <com/sun/star/util/XReplaceDescriptor.hpp>
39 #include <com/sun/star/lang/XUnoTunnel.hpp>
41 #include <comphelper/servicehelper.hxx>
42 #include <svx/editdata.hxx>
43 #include <svx/unoipset.hxx>
45 class SdrObject;
46 class SvxItemPropertySet;
47 class SdUnoSearchReplaceDescriptor;
49 /** this class implements a search or replace operation on a given page or a given sdrobj */
50 class SdUnoSearchReplaceShape : public ::com::sun::star::util::XReplaceable
52 protected:
53 ::com::sun::star::drawing::XShape* mpShape;
54 ::com::sun::star::drawing::XDrawPage* mpPage;
56 ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > Search( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xText, SdUnoSearchReplaceDescriptor* pDescr ) throw();
57 sal_Bool Search( const ::rtl::OUString& rText, sal_Int32& nStartPos, sal_Int32& nEndPos, SdUnoSearchReplaceDescriptor* pDescr ) throw();
58 ESelection GetSelection( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xTextRange ) throw();
59 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > GetShape( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xTextRange ) throw();
60 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > GetNextShape( ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > xShapes, ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xCurrentShape ) throw();
61 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > GetCurrentShape() const throw();
63 public:
64 SdUnoSearchReplaceShape( ::com::sun::star::drawing::XDrawPage* xPage ) throw(); // danger, these c'tors are only usable if
65 SdUnoSearchReplaceShape( ::com::sun::star::drawing::XShape* xShape ) throw(); // the given shape or page is derived from
66 virtual ~SdUnoSearchReplaceShape() throw(); // this class!!!
68 // XReplaceable
69 virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XReplaceDescriptor > SAL_CALL createReplaceDescriptor( ) throw(::com::sun::star::uno::RuntimeException);
70 virtual sal_Int32 SAL_CALL replaceAll( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor >& xDesc ) throw(::com::sun::star::uno::RuntimeException);
72 // XSearchable
73 virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor > SAL_CALL createSearchDescriptor( ) throw(::com::sun::star::uno::RuntimeException);
74 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL findAll( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor >& xDesc ) throw(::com::sun::star::uno::RuntimeException);
75 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL findFirst( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor >& xDesc ) throw(::com::sun::star::uno::RuntimeException);
76 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL 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 ) throw(::com::sun::star::uno::RuntimeException);
79 /* ================================================================= */
81 /** this class holds the parameters and status of a search or replace operation performed
82 by class SdUnoSearchReplaceShape */
84 #include <cppuhelper/implbase2.hxx>
86 class SdUnoSearchReplaceDescriptor : public ::cppu::WeakImplHelper2< ::com::sun::star::lang::XUnoTunnel, ::com::sun::star::util::XReplaceDescriptor > // public ::com::sun::star::util::XSearchDescriptor, ::com::sun::star::beans::XPropertySet
88 protected:
89 SvxItemPropertySet* mpPropSet;
91 sal_Bool mbBackwards;
92 sal_Bool mbCaseSensitive;
93 sal_Bool mbWords;
95 sal_Bool mbReplace;
97 ::rtl::OUString maSearchStr;
98 ::rtl::OUString maReplaceStr;
100 public:
101 SdUnoSearchReplaceDescriptor( sal_Bool bReplace ) throw();
102 virtual ~SdUnoSearchReplaceDescriptor() throw();
104 sal_Bool IsBackwards() const throw() { return mbBackwards; }
105 sal_Bool IsCaseSensitive() const throw() { return mbCaseSensitive; }
106 sal_Bool IsWords() const throw() { return mbWords; }
108 UNO3_GETIMPLEMENTATION_DECL( SdUnoSearchReplaceDescriptor )
110 // XSearchDescriptor
111 virtual ::rtl::OUString SAL_CALL getSearchString( ) throw(::com::sun::star::uno::RuntimeException);
112 virtual void SAL_CALL setSearchString( const ::rtl::OUString& aString ) throw(::com::sun::star::uno::RuntimeException);
114 // XReplaceDescriptor
115 virtual ::rtl::OUString SAL_CALL getReplaceString( ) throw(::com::sun::star::uno::RuntimeException);
116 virtual void SAL_CALL setReplaceString( const ::rtl::OUString& aReplaceString ) throw(::com::sun::star::uno::RuntimeException);
118 // XPropertySet
119 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
120 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) 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);
121 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
122 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
123 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
124 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
125 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
128 /* ================================================================= */
130 #include <cppuhelper/implbase1.hxx>
132 /** this class holds a sequence that is a result from a find all and
133 lets people access it through the XIndexAccess Interface. */
134 class SdUnoFindAllAccess : public ::cppu::WeakImplHelper1< ::com::sun::star::container::XIndexAccess > // public ::com::sun::star::container::XElementAccess
136 protected:
137 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > maSequence;
139 public:
140 SdUnoFindAllAccess( ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >& rSequence ) throw();
141 virtual ~SdUnoFindAllAccess() throw();
143 // XIndexAccess
144 virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException) ;
145 virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
147 // XElementAccess
148 virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException);
149 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);