Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_SD_SOURCE_UI_INC_UNOSRCH_HXX
21 : #define INCLUDED_SD_SOURCE_UI_INC_UNOSRCH_HXX
22 :
23 : #include <com/sun/star/drawing/XShape.hpp>
24 : #include <com/sun/star/drawing/XDrawPage.hpp>
25 : #include <com/sun/star/text/XTextRange.hpp>
26 : #include <com/sun/star/drawing/XShapes.hpp>
27 : #include <com/sun/star/util/XReplaceable.hpp>
28 : #include <com/sun/star/util/XSearchable.hpp>
29 : #include <com/sun/star/util/XSearchDescriptor.hpp>
30 : #include <com/sun/star/util/XReplaceDescriptor.hpp>
31 : #include <com/sun/star/lang/XUnoTunnel.hpp>
32 :
33 : #include <comphelper/servicehelper.hxx>
34 : #include <editeng/editdata.hxx>
35 : #include <editeng/unoipset.hxx>
36 :
37 : class SvxItemPropertySet;
38 : class SdUnoSearchReplaceDescriptor;
39 :
40 : /** this class implements a search or replace operation on a given page or a given sdrobj */
41 : class SdUnoSearchReplaceShape : public ::com::sun::star::util::XReplaceable
42 : {
43 : protected:
44 : ::com::sun::star::drawing::XShape* mpShape;
45 : ::com::sun::star::drawing::XDrawPage* mpPage;
46 :
47 : ::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();
48 : bool Search( const OUString& rText, sal_Int32& nStartPos, sal_Int32& nEndPos, SdUnoSearchReplaceDescriptor* pDescr ) throw();
49 : ESelection GetSelection( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xTextRange ) throw();
50 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > GetShape( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xTextRange ) throw();
51 : ::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();
52 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > GetCurrentShape() const throw();
53 :
54 : public:
55 : // danger, this c'tor is only usable if the given shape or page is derived
56 : // from this class!!!
57 : SdUnoSearchReplaceShape( ::com::sun::star::drawing::XDrawPage* xPage ) throw();
58 : virtual ~SdUnoSearchReplaceShape() throw();
59 :
60 : // XReplaceable
61 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XReplaceDescriptor > SAL_CALL createReplaceDescriptor( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
62 : virtual sal_Int32 SAL_CALL replaceAll( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor >& xDesc ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
63 :
64 : // XSearchable
65 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor > SAL_CALL createSearchDescriptor( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
66 : 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, std::exception) SAL_OVERRIDE;
67 : 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, std::exception) SAL_OVERRIDE;
68 : 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, std::exception) SAL_OVERRIDE;
69 : };
70 :
71 : /* ================================================================= */
72 :
73 : /** this class holds the parameters and status of a search or replace operation performed
74 : by class SdUnoSearchReplaceShape */
75 :
76 : #include <cppuhelper/implbase2.hxx>
77 :
78 : 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
79 : {
80 : protected:
81 : SvxItemPropertySet* mpPropSet;
82 :
83 : bool mbBackwards;
84 : bool mbCaseSensitive;
85 : bool mbWords;
86 :
87 : bool mbReplace;
88 :
89 : OUString maSearchStr;
90 : OUString maReplaceStr;
91 :
92 : public:
93 : SdUnoSearchReplaceDescriptor(bool bReplace) throw (css::uno::RuntimeException);
94 : virtual ~SdUnoSearchReplaceDescriptor() throw();
95 :
96 : bool IsBackwards() const throw() { return mbBackwards; }
97 0 : bool IsCaseSensitive() const throw() { return mbCaseSensitive; }
98 0 : bool IsWords() const throw() { return mbWords; }
99 :
100 : UNO3_GETIMPLEMENTATION_DECL( SdUnoSearchReplaceDescriptor )
101 :
102 : // XSearchDescriptor
103 : virtual OUString SAL_CALL getSearchString( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
104 : virtual void SAL_CALL setSearchString( const OUString& aString ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
105 :
106 : // XReplaceDescriptor
107 : virtual OUString SAL_CALL getReplaceString( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
108 : virtual void SAL_CALL setReplaceString( const OUString& aReplaceString ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
109 :
110 : // XPropertySet
111 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
112 : virtual void SAL_CALL setPropertyValue( const 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, std::exception) SAL_OVERRIDE;
113 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
114 : virtual void SAL_CALL addPropertyChangeListener( const 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, std::exception) SAL_OVERRIDE;
115 : virtual void SAL_CALL removePropertyChangeListener( const 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, std::exception) SAL_OVERRIDE;
116 : virtual void SAL_CALL addVetoableChangeListener( const 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, std::exception) SAL_OVERRIDE;
117 : virtual void SAL_CALL removeVetoableChangeListener( const 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, std::exception) SAL_OVERRIDE;
118 : };
119 :
120 : /* ================================================================= */
121 :
122 : #include <cppuhelper/implbase1.hxx>
123 :
124 : /** this class holds a sequence that is a result from a find all and
125 : lets people access it through the XIndexAccess Interface. */
126 : class SdUnoFindAllAccess : public ::cppu::WeakImplHelper1< ::com::sun::star::container::XIndexAccess > // public ::com::sun::star::container::XElementAccess
127 : {
128 : protected:
129 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > maSequence;
130 :
131 : public:
132 : SdUnoFindAllAccess( ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >& rSequence ) throw();
133 : virtual ~SdUnoFindAllAccess() throw();
134 :
135 : // XIndexAccess
136 : virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
137 : 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, std::exception) SAL_OVERRIDE;
138 :
139 : // XElementAccess
140 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
141 : virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
142 : };
143 :
144 : #endif // INCLUDED_SD_SOURCE_UI_INC_UNOSRCH_HXX
145 :
146 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|