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 #ifndef INCLUDED_SD_SOURCE_UI_INC_UNOSRCH_HXX
21 #define INCLUDED_SD_SOURCE_UI_INC_UNOSRCH_HXX
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>
33 #include <comphelper/servicehelper.hxx>
34 #include <editeng/editdata.hxx>
35 #include <editeng/unoipset.hxx>
37 class SvxItemPropertySet
;
38 class SdUnoSearchReplaceDescriptor
;
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
44 ::com::sun::star::drawing::XShape
* mpShape
;
45 ::com::sun::star::drawing::XDrawPage
* mpPage
;
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 static ESelection
GetSelection( ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
> xTextRange
) throw();
50 static ::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();
55 // danger, this c'tor is only usable if the given shape or page is derived
57 SdUnoSearchReplaceShape( ::com::sun::star::drawing::XDrawPage
* xPage
) throw();
58 virtual ~SdUnoSearchReplaceShape() throw();
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
;
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
;
71 /* ================================================================= */
73 /** this class holds the parameters and status of a search or replace operation performed
74 by class SdUnoSearchReplaceShape */
76 #include <cppuhelper/implbase2.hxx>
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
81 SvxItemPropertySet
* mpPropSet
;
90 OUString maReplaceStr
;
93 SdUnoSearchReplaceDescriptor(bool bReplace
) throw (css::uno::RuntimeException
);
94 virtual ~SdUnoSearchReplaceDescriptor() throw();
96 bool IsBackwards() const throw() { return mbBackwards
; }
97 bool IsCaseSensitive() const throw() { return mbCaseSensitive
; }
98 bool IsWords() const throw() { return mbWords
; }
100 UNO3_GETIMPLEMENTATION_DECL( SdUnoSearchReplaceDescriptor
)
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
;
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
;
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
;
120 /* ================================================================= */
122 #include <cppuhelper/implbase1.hxx>
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
129 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> > maSequence
;
132 SdUnoFindAllAccess( ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> >& rSequence
) throw();
133 virtual ~SdUnoFindAllAccess() throw();
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
;
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
;
144 #endif // INCLUDED_SD_SOURCE_UI_INC_UNOSRCH_HXX
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */