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 : #include <com/sun/star/drawing/XShape.hpp>
21 : #include <com/sun/star/drawing/XDrawPage.hpp>
22 : #include <com/sun/star/text/XTextRange.hpp>
23 : #include <com/sun/star/drawing/XShapes.hpp>
24 : #include <com/sun/star/util/XReplaceable.hpp>
25 : #include <com/sun/star/util/XSearchable.hpp>
26 : #include <com/sun/star/util/XSearchDescriptor.hpp>
27 : #include <com/sun/star/util/XReplaceDescriptor.hpp>
28 : #include <com/sun/star/lang/XUnoTunnel.hpp>
29 :
30 : #include <comphelper/servicehelper.hxx>
31 : #include <editeng/editdata.hxx>
32 : #include <editeng/unoipset.hxx>
33 :
34 : class SvxItemPropertySet;
35 : class SdUnoSearchReplaceDescriptor;
36 :
37 : /** this class implements a search or replace operation on a given page or a given sdrobj */
38 : class SdUnoSearchReplaceShape : public ::com::sun::star::util::XReplaceable
39 : {
40 : protected:
41 : ::com::sun::star::drawing::XShape* mpShape;
42 : ::com::sun::star::drawing::XDrawPage* mpPage;
43 :
44 : ::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();
45 : sal_Bool Search( const OUString& rText, sal_Int32& nStartPos, sal_Int32& nEndPos, SdUnoSearchReplaceDescriptor* pDescr ) throw();
46 : ESelection GetSelection( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xTextRange ) throw();
47 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > GetShape( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xTextRange ) throw();
48 : ::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();
49 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > GetCurrentShape() const throw();
50 :
51 : public:
52 : // danger, this c'tor is only usable if the given shape or page is derived
53 : // from this class!!!
54 : SdUnoSearchReplaceShape( ::com::sun::star::drawing::XDrawPage* xPage ) throw();
55 : virtual ~SdUnoSearchReplaceShape() throw();
56 :
57 : // XReplaceable
58 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XReplaceDescriptor > SAL_CALL createReplaceDescriptor( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
59 : 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;
60 :
61 : // XSearchable
62 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor > SAL_CALL createSearchDescriptor( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
63 : 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;
64 : 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;
65 : 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;
66 : };
67 :
68 : /* ================================================================= */
69 :
70 : /** this class holds the parameters and status of a search or replace operation performed
71 : by class SdUnoSearchReplaceShape */
72 :
73 : #include <cppuhelper/implbase2.hxx>
74 :
75 : 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
76 : {
77 : protected:
78 : SvxItemPropertySet* mpPropSet;
79 :
80 : sal_Bool mbBackwards;
81 : sal_Bool mbCaseSensitive;
82 : sal_Bool mbWords;
83 :
84 : sal_Bool mbReplace;
85 :
86 : OUString maSearchStr;
87 : OUString maReplaceStr;
88 :
89 : public:
90 : SdUnoSearchReplaceDescriptor( sal_Bool bReplace ) throw();
91 : virtual ~SdUnoSearchReplaceDescriptor() throw();
92 :
93 : sal_Bool IsBackwards() const throw() { return mbBackwards; }
94 0 : sal_Bool IsCaseSensitive() const throw() { return mbCaseSensitive; }
95 0 : sal_Bool IsWords() const throw() { return mbWords; }
96 :
97 : UNO3_GETIMPLEMENTATION_DECL( SdUnoSearchReplaceDescriptor )
98 :
99 : // XSearchDescriptor
100 : virtual OUString SAL_CALL getSearchString( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
101 : virtual void SAL_CALL setSearchString( const OUString& aString ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
102 :
103 : // XReplaceDescriptor
104 : virtual OUString SAL_CALL getReplaceString( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
105 : virtual void SAL_CALL setReplaceString( const OUString& aReplaceString ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
106 :
107 : // XPropertySet
108 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
109 : 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;
110 : 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;
111 : 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;
112 : 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;
113 : 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;
114 : 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;
115 : };
116 :
117 : /* ================================================================= */
118 :
119 : #include <cppuhelper/implbase1.hxx>
120 :
121 : /** this class holds a sequence that is a result from a find all and
122 : lets people access it through the XIndexAccess Interface. */
123 : class SdUnoFindAllAccess : public ::cppu::WeakImplHelper1< ::com::sun::star::container::XIndexAccess > // public ::com::sun::star::container::XElementAccess
124 : {
125 : protected:
126 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > maSequence;
127 :
128 : public:
129 : SdUnoFindAllAccess( ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >& rSequence ) throw();
130 : virtual ~SdUnoFindAllAccess() throw();
131 :
132 : // XIndexAccess
133 : virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
134 : 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;
135 :
136 : // XElementAccess
137 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
138 : virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
139 : };
140 :
141 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|