LibreOffice Module sd (master) 1
unosrch.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <memory>
23#include <com/sun/star/util/XReplaceable.hpp>
24#include <com/sun/star/util/XReplaceDescriptor.hpp>
25
28#include <editeng/editdata.hxx>
29
30namespace com::sun::star::drawing { class XDrawPage; }
31namespace com::sun::star::drawing { class XShape; }
32namespace com::sun::star::text { class XTextRange; }
33namespace com::sun::star::util { class XSearchDescriptor; }
34
37
39class SdUnoSearchReplaceShape : public css::util::XReplaceable
40{
41 css::drawing::XDrawPage* mpPage;
42
43protected:
44 css::uno::Reference< css::text::XTextRange > Search( const css::uno::Reference< css::text::XTextRange >& xText, SdUnoSearchReplaceDescriptor* pDescr );
45 bool Search( const OUString& rText, sal_Int32& nStartPos, sal_Int32& nEndPos, SdUnoSearchReplaceDescriptor* pDescr ) noexcept;
46 static ESelection GetSelection( const css::uno::Reference< css::text::XTextRange >& xTextRange ) noexcept;
47 static css::uno::Reference< css::drawing::XShape > GetShape( const css::uno::Reference< css::text::XTextRange >& xTextRange ) noexcept;
48 css::uno::Reference< css::drawing::XShape > GetNextShape( const css::uno::Reference< css::container::XIndexAccess >& xShapes, const css::uno::Reference< css::drawing::XShape >& xCurrentShape ) noexcept;
49 css::uno::Reference< css::drawing::XShape > GetCurrentShape() const noexcept;
50
51public:
52 // danger, this c'tor is only usable if the given shape or page is derived
53 // from this class!!!
54 SdUnoSearchReplaceShape( css::drawing::XDrawPage* xPage ) noexcept;
55 virtual ~SdUnoSearchReplaceShape() noexcept;
56
57 // XReplaceable
58 virtual css::uno::Reference< css::util::XReplaceDescriptor > SAL_CALL createReplaceDescriptor( ) override;
59 virtual sal_Int32 SAL_CALL replaceAll( const css::uno::Reference< css::util::XSearchDescriptor >& xDesc ) override;
60
61 // XSearchable
62 virtual css::uno::Reference< css::util::XSearchDescriptor > SAL_CALL createSearchDescriptor( ) override;
63 virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL findAll( const css::uno::Reference< css::util::XSearchDescriptor >& xDesc ) override;
64 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL findFirst( const css::uno::Reference< css::util::XSearchDescriptor >& xDesc ) override;
65 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL findNext( const css::uno::Reference< css::uno::XInterface >& xStartAt, const css::uno::Reference< css::util::XSearchDescriptor >& xDesc ) override;
66};
67
68/* ================================================================= */
69
73class SdUnoSearchReplaceDescriptor final : public ::cppu::WeakImplHelper< css::util::XReplaceDescriptor > // public css::util::XSearchDescriptor, css::beans::XPropertySet
74{
75 std::unique_ptr<SvxItemPropertySet> mpPropSet;
76
79 bool mbWords;
80
81 OUString maSearchStr;
82 OUString maReplaceStr;
83
84public:
87 virtual ~SdUnoSearchReplaceDescriptor() noexcept override;
88
89 bool IsCaseSensitive() const { return mbCaseSensitive; }
90 bool IsWords() const { return mbWords; }
91
92 // XSearchDescriptor
93 virtual OUString SAL_CALL getSearchString( ) override;
94 virtual void SAL_CALL setSearchString( const OUString& aString ) override;
95
96 // XReplaceDescriptor
97 virtual OUString SAL_CALL getReplaceString( ) override;
98 virtual void SAL_CALL setReplaceString( const OUString& aReplaceString ) override;
99
100 // XPropertySet
101 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
102 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
103 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
104 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
105 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
106 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
107 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
108};
109
110/* ================================================================= */
111
114class SdUnoFindAllAccess final : public ::cppu::WeakImplHelper< css::container::XIndexAccess > // public css::container::XElementAccess
115{
116 css::uno::Sequence< css::uno::Reference< css::uno::XInterface > > maSequence;
117
118public:
119 SdUnoFindAllAccess( css::uno::Sequence< css::uno::Reference< css::uno::XInterface > > const & rSequence ) noexcept;
120 virtual ~SdUnoFindAllAccess() noexcept override;
121
122 // XIndexAccess
123 virtual sal_Int32 SAL_CALL getCount() override ;
124 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
125
126 // XElementAccess
127 virtual css::uno::Type SAL_CALL getElementType() override;
128 virtual sal_Bool SAL_CALL hasElements() override;
129};
130
131/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _ADOIndex Index
this class holds a sequence that is a result from a find all and lets people access it through the XI...
Definition: unosrch.hxx:115
css::uno::Sequence< css::uno::Reference< css::uno::XInterface > > maSequence
Definition: unosrch.hxx:116
this class holds the parameters and status of a search or replace operation performed by class SdUnoS...
Definition: unosrch.hxx:74
std::unique_ptr< SvxItemPropertySet > mpPropSet
Definition: unosrch.hxx:75
this class implements a search or replace operation on a given page or a given sdrobj
Definition: unosrch.hxx:40
css::uno::Reference< css::drawing::XShape > GetNextShape(const css::uno::Reference< css::container::XIndexAccess > &xShapes, const css::uno::Reference< css::drawing::XShape > &xCurrentShape) noexcept
this method returns the shape that follows xCurrentShape in the shape collection xShapes.
Definition: unosrch.cxx:349
virtual css::uno::Reference< css::util::XSearchDescriptor > SAL_CALL createSearchDescriptor() override
Definition: unosrch.cxx:182
css::uno::Reference< css::drawing::XShape > GetCurrentShape() const noexcept
Definition: unosrch.cxx:288
static ESelection GetSelection(const css::uno::Reference< css::text::XTextRange > &xTextRange) noexcept
Definition: unosrch.cxx:594
virtual sal_Int32 SAL_CALL replaceAll(const css::uno::Reference< css::util::XSearchDescriptor > &xDesc) override
Definition: unosrch.cxx:107
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL findNext(const css::uno::Reference< css::uno::XInterface > &xStartAt, const css::uno::Reference< css::util::XSearchDescriptor > &xDesc) override
Definition: unosrch.cxx:299
css::drawing::XDrawPage * mpPage
Definition: unosrch.hxx:41
virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL findAll(const css::uno::Reference< css::util::XSearchDescriptor > &xDesc) override
Definition: unosrch.cxx:187
static css::uno::Reference< css::drawing::XShape > GetShape(const css::uno::Reference< css::text::XTextRange > &xTextRange) noexcept
Definition: unosrch.cxx:605
css::uno::Reference< css::text::XTextRange > Search(const css::uno::Reference< css::text::XTextRange > &xText, SdUnoSearchReplaceDescriptor *pDescr)
virtual css::uno::Reference< css::util::XReplaceDescriptor > SAL_CALL createReplaceDescriptor() override
Definition: unosrch.cxx:102
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL findFirst(const css::uno::Reference< css::util::XSearchDescriptor > &xDesc) override
Definition: unosrch.cxx:279
Type
VBAHELPER_DLLPUBLIC bool setPropertyValue(css::uno::Sequence< css::beans::PropertyValue > &aProp, const OUString &aName, const css::uno::Any &aValue)
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
unsigned char sal_Bool