android: Update app-specific/MIME type icons
[LibreOffice.git] / sd / source / ui / func / fusearch.cxx
blob73a112bf44c6da9b88ee7cd2f02a10fb237412cc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <fusearch.hxx>
22 #include <sfx2/viewfrm.hxx>
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>
34 class SfxRequest;
36 namespace sd {
38 const 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 };
48 FuSearch::FuSearch (
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)
60 FuSearch* FuSearch::createPtr(ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq)
62 FuSearch* xFunc( new FuSearch( pViewSh, pWin, pView, pDoc, rReq ) );
63 xFunc->DoExecute(rReq);
64 return xFunc;
67 void FuSearch::DoExecute( SfxRequest& )
69 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArraySpell );
71 if ( dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr )
73 m_bOwnOutliner = true;
74 m_pSdOutliner = new SdOutliner( mpDoc, OutlinerMode::TextObject );
76 else if ( dynamic_cast< const OutlineViewShell *>( mpViewShell ) != nullptr )
78 m_bOwnOutliner = false;
79 m_pSdOutliner = mpDoc->GetOutliner();
82 if (m_pSdOutliner)
83 m_pSdOutliner->PrepareSpelling();
86 FuSearch::~FuSearch()
88 if ( ! mpDocSh->IsInDestruction() && mpDocSh->GetViewShell()!=nullptr)
89 mpDocSh->GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SidArraySpell );
91 if (m_pSdOutliner)
92 m_pSdOutliner->EndSpelling();
94 if (m_bOwnOutliner)
95 delete m_pSdOutliner;
98 void FuSearch::SearchAndReplace( const SvxSearchItem* pSearchItem )
100 ViewShellBase* pBase = dynamic_cast<ViewShellBase*>( SfxViewShell::Current() );
101 ViewShell* pViewShell = nullptr;
102 if (pBase != nullptr)
103 pViewShell = pBase->GetMainViewShell().get();
105 if (pViewShell == nullptr)
106 return;
108 if (m_pSdOutliner && dynamic_cast<const DrawViewShell*>(pViewShell) && !m_bOwnOutliner)
110 m_pSdOutliner->EndSpelling();
112 m_bOwnOutliner = true;
113 m_pSdOutliner = new SdOutliner(mpDoc, OutlinerMode::TextObject);
114 m_pSdOutliner->PrepareSpelling();
116 else if (m_pSdOutliner && dynamic_cast<const OutlineViewShell*>(pViewShell) && m_bOwnOutliner)
118 m_pSdOutliner->EndSpelling();
119 delete m_pSdOutliner;
121 m_bOwnOutliner = false;
122 m_pSdOutliner = mpDoc->GetOutliner();
123 m_pSdOutliner->PrepareSpelling();
126 if (m_pSdOutliner)
128 bool bEndSpelling = m_pSdOutliner->StartSearchAndReplace(pSearchItem);
130 if (bEndSpelling)
132 m_pSdOutliner->EndSpelling();
133 m_pSdOutliner->PrepareSpelling();
138 } // end of namespace sd
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */