1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
30 #include <comphelper/servicehelper.hxx>
31 #include <editeng/editdata.hxx>
32 #include <editeng/unoipset.hxx>
34 class SvxItemPropertySet
;
35 class SdUnoSearchReplaceDescriptor
;
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
41 ::com::sun::star::drawing::XShape
* mpShape
;
42 ::com::sun::star::drawing::XDrawPage
* mpPage
;
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();
52 // danger, this c'tor is only usable if the given shape or page is derived
54 SdUnoSearchReplaceShape( ::com::sun::star::drawing::XDrawPage
* xPage
) throw();
55 virtual ~SdUnoSearchReplaceShape() throw();
58 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::util::XReplaceDescriptor
> SAL_CALL
createReplaceDescriptor( ) throw(::com::sun::star::uno::RuntimeException
);
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
);
62 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::util::XSearchDescriptor
> SAL_CALL
createSearchDescriptor( ) throw(::com::sun::star::uno::RuntimeException
);
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
);
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
);
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
);
68 /* ================================================================= */
70 /** this class holds the parameters and status of a search or replace operation performed
71 by class SdUnoSearchReplaceShape */
73 #include <cppuhelper/implbase2.hxx>
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
78 SvxItemPropertySet
* mpPropSet
;
81 sal_Bool mbCaseSensitive
;
87 OUString maReplaceStr
;
90 SdUnoSearchReplaceDescriptor( sal_Bool bReplace
) throw();
91 virtual ~SdUnoSearchReplaceDescriptor() throw();
93 sal_Bool
IsBackwards() const throw() { return mbBackwards
; }
94 sal_Bool
IsCaseSensitive() const throw() { return mbCaseSensitive
; }
95 sal_Bool
IsWords() const throw() { return mbWords
; }
97 UNO3_GETIMPLEMENTATION_DECL( SdUnoSearchReplaceDescriptor
)
100 virtual OUString SAL_CALL
getSearchString( ) throw(::com::sun::star::uno::RuntimeException
);
101 virtual void SAL_CALL
setSearchString( const OUString
& aString
) throw(::com::sun::star::uno::RuntimeException
);
103 // XReplaceDescriptor
104 virtual OUString SAL_CALL
getReplaceString( ) throw(::com::sun::star::uno::RuntimeException
);
105 virtual void SAL_CALL
setReplaceString( const OUString
& aReplaceString
) throw(::com::sun::star::uno::RuntimeException
);
108 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
);
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
);
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
);
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
);
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
);
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
);
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
);
117 /* ================================================================= */
119 #include <cppuhelper/implbase1.hxx>
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
126 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> > maSequence
;
129 SdUnoFindAllAccess( ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> >& rSequence
) throw();
130 virtual ~SdUnoFindAllAccess() throw();
133 virtual sal_Int32 SAL_CALL
getCount() throw(::com::sun::star::uno::RuntimeException
) ;
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
);
137 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType() throw(::com::sun::star::uno::RuntimeException
);
138 virtual sal_Bool SAL_CALL
hasElements() throw(::com::sun::star::uno::RuntimeException
);
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */