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