xref: /AOO41X/main/sd/source/ui/inc/unosrch.hxx (revision 67e470dafe1997e73f56ff7ff4878983707e3e07)
1*c45d927aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*c45d927aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*c45d927aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*c45d927aSAndrew Rist  * distributed with this work for additional information
6*c45d927aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*c45d927aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*c45d927aSAndrew Rist  * "License"); you may not use this file except in compliance
9*c45d927aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*c45d927aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*c45d927aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*c45d927aSAndrew Rist  * software distributed under the License is distributed on an
15*c45d927aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c45d927aSAndrew Rist  * KIND, either express or implied.  See the License for the
17*c45d927aSAndrew Rist  * specific language governing permissions and limitations
18*c45d927aSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*c45d927aSAndrew Rist  *************************************************************/
21*c45d927aSAndrew Rist 
22*c45d927aSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include <com/sun/star/drawing/XShape.hpp>
25cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPage.hpp>
26cdf0e10cSrcweir #include <com/sun/star/text/XTextRange.hpp>
27cdf0e10cSrcweir #include <com/sun/star/drawing/XShapes.hpp>
28cdf0e10cSrcweir #include <com/sun/star/util/XReplaceable.hpp>
29cdf0e10cSrcweir #include <com/sun/star/util/XSearchable.hpp>
30cdf0e10cSrcweir #include <com/sun/star/util/XSearchDescriptor.hpp>
31cdf0e10cSrcweir #include <com/sun/star/util/XReplaceDescriptor.hpp>
32cdf0e10cSrcweir #include <com/sun/star/lang/XUnoTunnel.hpp>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include <comphelper/servicehelper.hxx>
35cdf0e10cSrcweir #include <editeng/editdata.hxx>
36cdf0e10cSrcweir #include <editeng/unoipset.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir class SdrObject;
39cdf0e10cSrcweir class SvxItemPropertySet;
40cdf0e10cSrcweir class SdUnoSearchReplaceDescriptor;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir /** this class implements a search or replace operation on a given page or a given sdrobj */
43cdf0e10cSrcweir class SdUnoSearchReplaceShape : public ::com::sun::star::util::XReplaceable
44cdf0e10cSrcweir {
45cdf0e10cSrcweir protected:
46cdf0e10cSrcweir 	::com::sun::star::drawing::XShape* mpShape;
47cdf0e10cSrcweir 	::com::sun::star::drawing::XDrawPage* mpPage;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir 	::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();
50cdf0e10cSrcweir 	sal_Bool Search( const ::rtl::OUString& rText, sal_Int32& nStartPos, sal_Int32& nEndPos, SdUnoSearchReplaceDescriptor* pDescr ) throw();
51cdf0e10cSrcweir 	ESelection GetSelection( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >  xTextRange ) throw();
52cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >  GetShape( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >  xTextRange ) throw();
53cdf0e10cSrcweir 	::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();
54cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >  GetCurrentShape() const throw();
55cdf0e10cSrcweir 
56cdf0e10cSrcweir public:
57cdf0e10cSrcweir     // danger, this c'tor is only usable if the given shape or page is derived
58cdf0e10cSrcweir     // from this class!!!
59cdf0e10cSrcweir     SdUnoSearchReplaceShape( ::com::sun::star::drawing::XDrawPage* xPage ) throw();
60cdf0e10cSrcweir     virtual ~SdUnoSearchReplaceShape() throw();
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 	// XReplaceable
63cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XReplaceDescriptor > SAL_CALL createReplaceDescriptor(  ) throw(::com::sun::star::uno::RuntimeException);
64cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL replaceAll( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor >& xDesc ) throw(::com::sun::star::uno::RuntimeException);
65cdf0e10cSrcweir 
66cdf0e10cSrcweir 	// XSearchable
67cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor > SAL_CALL createSearchDescriptor(  ) throw(::com::sun::star::uno::RuntimeException);
68cdf0e10cSrcweir     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);
69cdf0e10cSrcweir     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);
70cdf0e10cSrcweir     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);
71cdf0e10cSrcweir };
72cdf0e10cSrcweir 
73cdf0e10cSrcweir /* ================================================================= */
74cdf0e10cSrcweir 
75cdf0e10cSrcweir /** this class holds the parameters and status of a search or replace operation performed
76cdf0e10cSrcweir 	by class SdUnoSearchReplaceShape */
77cdf0e10cSrcweir 
78cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx>
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 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
81cdf0e10cSrcweir {
82cdf0e10cSrcweir protected:
83cdf0e10cSrcweir 	SvxItemPropertySet* mpPropSet;
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 	sal_Bool mbBackwards;
86cdf0e10cSrcweir 	sal_Bool mbCaseSensitive;
87cdf0e10cSrcweir 	sal_Bool mbWords;
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 	sal_Bool mbReplace;
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 	::rtl::OUString	maSearchStr;
92cdf0e10cSrcweir 	::rtl::OUString maReplaceStr;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir public:
95cdf0e10cSrcweir 	SdUnoSearchReplaceDescriptor( sal_Bool bReplace ) throw();
96cdf0e10cSrcweir 	virtual ~SdUnoSearchReplaceDescriptor() throw();
97cdf0e10cSrcweir 
IsBackwards() const98cdf0e10cSrcweir 	sal_Bool IsBackwards() const throw() { return mbBackwards; }
IsCaseSensitive() const99cdf0e10cSrcweir 	sal_Bool IsCaseSensitive() const throw() { return mbCaseSensitive; }
IsWords() const100cdf0e10cSrcweir 	sal_Bool IsWords() const throw() { return mbWords; }
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 	UNO3_GETIMPLEMENTATION_DECL( SdUnoSearchReplaceDescriptor )
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 	// XSearchDescriptor
105cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getSearchString(  ) throw(::com::sun::star::uno::RuntimeException);
106cdf0e10cSrcweir     virtual void SAL_CALL setSearchString( const ::rtl::OUString& aString ) throw(::com::sun::star::uno::RuntimeException);
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	// XReplaceDescriptor
109cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getReplaceString(  ) throw(::com::sun::star::uno::RuntimeException);
110cdf0e10cSrcweir     virtual void SAL_CALL setReplaceString( const ::rtl::OUString& aReplaceString ) throw(::com::sun::star::uno::RuntimeException);
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 	// XPropertySet
113cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
114cdf0e10cSrcweir     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);
115cdf0e10cSrcweir     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);
116cdf0e10cSrcweir     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);
117cdf0e10cSrcweir     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);
118cdf0e10cSrcweir     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);
119cdf0e10cSrcweir     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);
120cdf0e10cSrcweir };
121cdf0e10cSrcweir 
122cdf0e10cSrcweir /* ================================================================= */
123cdf0e10cSrcweir 
124cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
125cdf0e10cSrcweir 
126cdf0e10cSrcweir /** this class holds a sequence that is a result from a find all and
127cdf0e10cSrcweir 	lets people access it through the XIndexAccess Interface. */
128cdf0e10cSrcweir class SdUnoFindAllAccess : public ::cppu::WeakImplHelper1< ::com::sun::star::container::XIndexAccess > // public ::com::sun::star::container::XElementAccess
129cdf0e10cSrcweir {
130cdf0e10cSrcweir protected:
131cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >  > maSequence;
132cdf0e10cSrcweir 
133cdf0e10cSrcweir public:
134cdf0e10cSrcweir 	SdUnoFindAllAccess( ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >  >& rSequence ) throw();
135cdf0e10cSrcweir 	virtual ~SdUnoFindAllAccess() throw();
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 	// XIndexAccess
138cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException) ;
139cdf0e10cSrcweir     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);
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 	// XElementAccess
142cdf0e10cSrcweir     virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException);
143cdf0e10cSrcweir     virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
144cdf0e10cSrcweir };
145cdf0e10cSrcweir 
146