xref: /trunk/main/sd/source/ui/inc/unosrch.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #include <com/sun/star/drawing/XShape.hpp>
29*cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPage.hpp>
30*cdf0e10cSrcweir #include <com/sun/star/text/XTextRange.hpp>
31*cdf0e10cSrcweir #include <com/sun/star/drawing/XShapes.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/util/XReplaceable.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/util/XSearchable.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/util/XSearchDescriptor.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/util/XReplaceDescriptor.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/lang/XUnoTunnel.hpp>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #include <comphelper/servicehelper.hxx>
39*cdf0e10cSrcweir #include <editeng/editdata.hxx>
40*cdf0e10cSrcweir #include <editeng/unoipset.hxx>
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir class SdrObject;
43*cdf0e10cSrcweir class SvxItemPropertySet;
44*cdf0e10cSrcweir class SdUnoSearchReplaceDescriptor;
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir /** this class implements a search or replace operation on a given page or a given sdrobj */
47*cdf0e10cSrcweir class SdUnoSearchReplaceShape : public ::com::sun::star::util::XReplaceable
48*cdf0e10cSrcweir {
49*cdf0e10cSrcweir protected:
50*cdf0e10cSrcweir     ::com::sun::star::drawing::XShape* mpShape;
51*cdf0e10cSrcweir     ::com::sun::star::drawing::XDrawPage* mpPage;
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir     ::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();
54*cdf0e10cSrcweir     sal_Bool Search( const ::rtl::OUString& rText, sal_Int32& nStartPos, sal_Int32& nEndPos, SdUnoSearchReplaceDescriptor* pDescr ) throw();
55*cdf0e10cSrcweir     ESelection GetSelection( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >  xTextRange ) throw();
56*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >  GetShape( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >  xTextRange ) throw();
57*cdf0e10cSrcweir     ::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();
58*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >  GetCurrentShape() const throw();
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir public:
61*cdf0e10cSrcweir     // danger, this c'tor is only usable if the given shape or page is derived
62*cdf0e10cSrcweir     // from this class!!!
63*cdf0e10cSrcweir     SdUnoSearchReplaceShape( ::com::sun::star::drawing::XDrawPage* xPage ) throw();
64*cdf0e10cSrcweir     virtual ~SdUnoSearchReplaceShape() throw();
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir     // XReplaceable
67*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XReplaceDescriptor > SAL_CALL createReplaceDescriptor(  ) throw(::com::sun::star::uno::RuntimeException);
68*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL replaceAll( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor >& xDesc ) throw(::com::sun::star::uno::RuntimeException);
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir     // XSearchable
71*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor > SAL_CALL createSearchDescriptor(  ) throw(::com::sun::star::uno::RuntimeException);
72*cdf0e10cSrcweir     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);
73*cdf0e10cSrcweir     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);
74*cdf0e10cSrcweir     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);
75*cdf0e10cSrcweir };
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir /* ================================================================= */
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir /** this class holds the parameters and status of a search or replace operation performed
80*cdf0e10cSrcweir     by class SdUnoSearchReplaceShape */
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx>
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir 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
85*cdf0e10cSrcweir {
86*cdf0e10cSrcweir protected:
87*cdf0e10cSrcweir     SvxItemPropertySet* mpPropSet;
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir     sal_Bool mbBackwards;
90*cdf0e10cSrcweir     sal_Bool mbCaseSensitive;
91*cdf0e10cSrcweir     sal_Bool mbWords;
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir     sal_Bool mbReplace;
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir     ::rtl::OUString maSearchStr;
96*cdf0e10cSrcweir     ::rtl::OUString maReplaceStr;
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir public:
99*cdf0e10cSrcweir     SdUnoSearchReplaceDescriptor( sal_Bool bReplace ) throw();
100*cdf0e10cSrcweir     virtual ~SdUnoSearchReplaceDescriptor() throw();
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir     sal_Bool IsBackwards() const throw() { return mbBackwards; }
103*cdf0e10cSrcweir     sal_Bool IsCaseSensitive() const throw() { return mbCaseSensitive; }
104*cdf0e10cSrcweir     sal_Bool IsWords() const throw() { return mbWords; }
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir     UNO3_GETIMPLEMENTATION_DECL( SdUnoSearchReplaceDescriptor )
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir     // XSearchDescriptor
109*cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getSearchString(  ) throw(::com::sun::star::uno::RuntimeException);
110*cdf0e10cSrcweir     virtual void SAL_CALL setSearchString( const ::rtl::OUString& aString ) throw(::com::sun::star::uno::RuntimeException);
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir     // XReplaceDescriptor
113*cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getReplaceString(  ) throw(::com::sun::star::uno::RuntimeException);
114*cdf0e10cSrcweir     virtual void SAL_CALL setReplaceString( const ::rtl::OUString& aReplaceString ) throw(::com::sun::star::uno::RuntimeException);
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir     // XPropertySet
117*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
118*cdf0e10cSrcweir     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);
119*cdf0e10cSrcweir     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);
120*cdf0e10cSrcweir     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);
121*cdf0e10cSrcweir     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);
122*cdf0e10cSrcweir     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);
123*cdf0e10cSrcweir     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);
124*cdf0e10cSrcweir };
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir /* ================================================================= */
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir /** this class holds a sequence that is a result from a find all and
131*cdf0e10cSrcweir     lets people access it through the XIndexAccess Interface. */
132*cdf0e10cSrcweir class SdUnoFindAllAccess : public ::cppu::WeakImplHelper1< ::com::sun::star::container::XIndexAccess > // public ::com::sun::star::container::XElementAccess
133*cdf0e10cSrcweir {
134*cdf0e10cSrcweir protected:
135*cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >  > maSequence;
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir public:
138*cdf0e10cSrcweir     SdUnoFindAllAccess( ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >  >& rSequence ) throw();
139*cdf0e10cSrcweir     virtual ~SdUnoFindAllAccess() throw();
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir     // XIndexAccess
142*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException) ;
143*cdf0e10cSrcweir     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);
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir     // XElementAccess
146*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException);
147*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
148*cdf0e10cSrcweir };
149*cdf0e10cSrcweir 
150