LibreOffice Module sd (master) 1
fusearch.cxx
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#include <fusearch.hxx>
21
22#include <sfx2/viewfrm.hxx>
23
24#include <sfx2/bindings.hxx>
25#include <fupoor.hxx>
26#include <drawdoc.hxx>
27#include <app.hrc>
28#include <Outliner.hxx>
29#include <DrawDocShell.hxx>
30#include <DrawViewShell.hxx>
31#include <OutlineViewShell.hxx>
32#include <ViewShellBase.hxx>
33
34class SfxRequest;
35
36namespace sd {
37
38const sal_uInt16 SidArraySpell[] = {
39 SID_DRAWINGMODE,
40 SID_OUTLINE_MODE,
41 SID_SLIDE_SORTER_MODE,
42 SID_NOTES_MODE,
43 SID_HANDOUT_MASTER_MODE,
44 SID_SLIDE_MASTER_MODE,
45 SID_NOTES_MASTER_MODE,
46 0 };
47
49 ViewShell* pViewSh,
50 ::sd::Window* pWin,
51 ::sd::View* pView,
52 SdDrawDocument* pDoc,
53 SfxRequest& rReq )
54 : FuPoor(pViewSh, pWin, pView, pDoc, rReq),
55 m_pSdOutliner(nullptr),
56 m_bOwnOutliner(false)
57{
58}
59
61{
62 FuSearch* xFunc( new FuSearch( pViewSh, pWin, pView, pDoc, rReq ) );
63 xFunc->DoExecute(rReq);
64 return xFunc;
65}
66
68{
70
71 if ( dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr )
72 {
73 m_bOwnOutliner = true;
74 m_pSdOutliner = new SdOutliner( mpDoc, OutlinerMode::TextObject );
75 }
76 else if ( dynamic_cast< const OutlineViewShell *>( mpViewShell ) != nullptr )
77 {
78 m_bOwnOutliner = false;
80 }
81
82 if (m_pSdOutliner)
84}
85
87{
88 if ( ! mpDocSh->IsInDestruction() && mpDocSh->GetViewShell()!=nullptr)
90
91 if (m_pSdOutliner)
93
95 delete m_pSdOutliner;
96}
97
98void FuSearch::SearchAndReplace( const SvxSearchItem* pSearchItem )
99{
100 ViewShellBase* pBase = dynamic_cast<ViewShellBase*>( SfxViewShell::Current() );
101 ViewShell* pViewShell = nullptr;
102 if (pBase != nullptr)
103 pViewShell = pBase->GetMainViewShell().get();
104
105 if (pViewShell == nullptr)
106 return;
107
108 if (m_pSdOutliner && dynamic_cast<const DrawViewShell*>(pViewShell) && !m_bOwnOutliner)
109 {
111
112 m_bOwnOutliner = true;
113 m_pSdOutliner = new SdOutliner(mpDoc, OutlinerMode::TextObject);
115 }
116 else if (m_pSdOutliner && dynamic_cast<const OutlineViewShell*>(pViewShell) && m_bOwnOutliner)
117 {
119 delete m_pSdOutliner;
120
121 m_bOwnOutliner = false;
124 }
125
126 if (m_pSdOutliner)
127 {
128 bool bEndSpelling = m_pSdOutliner->StartSearchAndReplace(pSearchItem);
129
130 if (bEndSpelling)
131 {
134 }
135 }
136}
137
138} // end of namespace sd
139
140/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPRIVATE SdOutliner * GetOutliner(bool bCreateOutliner=true)
Definition: drawdoc.cxx:912
The main purpose of this class is searching and replacing as well as spelling of impress documents.
Definition: Outliner.hxx:123
bool StartSearchAndReplace(const SvxSearchItem *pSearchItem)
Initiate a find and/or replace on the next relevant text object.
Definition: Outliner.cxx:420
void PrepareSpelling()
Despite the name this method is called prior to spell checking and searching and replacing.
Definition: Outliner.cxx:241
void EndSpelling()
Release all resources that have been created during the find&replace or spell check.
Definition: Outliner.cxx:281
void Invalidate(sal_uInt16 nId)
SfxBindings & GetBindings()
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
sd::ViewShell * GetViewShell()
bool IsInDestruction() const
Base class of the stacked shells that provide graphical views to Draw and Impress documents and editi...
Base class for all functions.
Definition: fupoor.hxx:48
SdDrawDocument * mpDoc
Definition: fupoor.hxx:148
ViewShell * mpViewShell
Definition: fupoor.hxx:145
DrawDocShell * mpDocSh
Definition: fupoor.hxx:147
bool m_bOwnOutliner
Definition: fusearch.hxx:43
virtual void DoExecute(SfxRequest &rReq) override
Definition: fusearch.cxx:67
virtual ~FuSearch() override
Definition: fusearch.cxx:86
static FuSearch * createPtr(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
Definition: fusearch.cxx:60
SdOutliner * m_pSdOutliner
Definition: fusearch.hxx:42
void SearchAndReplace(const SvxSearchItem *pSearchItem)
Definition: fusearch.cxx:98
FuSearch(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
Definition: fusearch.cxx:48
Show a textual overview of the text contents of all slides.
SfxViewShell descendant that the stacked Draw/Impress shells are based on.
std::shared_ptr< ViewShell > GetMainViewShell() const
Return the main view shell stacked on the called ViewShellBase object.
Base class of the stacked shell hierarchy.
Definition: ViewShell.hxx:92
SD_DLLPUBLIC SfxViewFrame * GetViewFrame() const
Definition: viewshel.cxx:118
An SdWindow contains the actual working area of ViewShell.
Definition: Window.hxx:45
const sal_uInt16 SidArraySpell[]
Definition: fusearch.cxx:38