bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / func / fusearch.cxx
blob817d357fa25b59dc22a4e2d3262f4c421f785fcc
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 static 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 pSdOutliner(nullptr),
56 bOwnOutliner(false)
60 rtl::Reference<FuPoor> FuSearch::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
62 rtl::Reference<FuPoor> 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 bOwnOutliner = true;
74 pSdOutliner = new SdOutliner( mpDoc, OutlinerMode::TextObject );
76 else if ( dynamic_cast< const OutlineViewShell *>( mpViewShell ) != nullptr )
78 bOwnOutliner = false;
79 pSdOutliner = mpDoc->GetOutliner();
82 if (pSdOutliner)
83 pSdOutliner->PrepareSpelling();
86 FuSearch::~FuSearch()
88 if ( ! mpDocSh->IsInDestruction() && mpDocSh->GetViewShell()!=nullptr)
89 mpDocSh->GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SidArraySpell );
91 if (pSdOutliner)
92 pSdOutliner->EndSpelling();
94 if (bOwnOutliner)
95 delete 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 ( pSdOutliner && dynamic_cast< const DrawViewShell *>( pViewShell ) != nullptr && !bOwnOutliner )
110 pSdOutliner->EndSpelling();
112 bOwnOutliner = true;
113 pSdOutliner = new SdOutliner( mpDoc, OutlinerMode::TextObject );
114 pSdOutliner->PrepareSpelling();
116 else if ( pSdOutliner && dynamic_cast< const OutlineViewShell *>( pViewShell ) != nullptr && bOwnOutliner )
118 pSdOutliner->EndSpelling();
119 delete pSdOutliner;
121 bOwnOutliner = false;
122 pSdOutliner = mpDoc->GetOutliner();
123 pSdOutliner->PrepareSpelling();
126 if (pSdOutliner)
128 bool bEndSpelling = pSdOutliner->StartSearchAndReplace(pSearchItem);
130 if (bEndSpelling)
132 pSdOutliner->EndSpelling();
133 pSdOutliner->PrepareSpelling();
138 } // end of namespace sd
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */