bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / func / fusearch.cxx
blobeb0003520830b1f165913f6f6517f87516731307
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 <svx/svxids.hrc>
25 #include <svl/srchitem.hxx>
26 #include <svx/srchdlg.hxx>
27 #include <sfx2/bindings.hxx>
28 #include "fupoor.hxx"
29 #include "Window.hxx"
30 #include "drawdoc.hxx"
31 #include "app.hrc"
32 #include "sdmod.hxx"
33 #include "View.hxx"
34 #include "Outliner.hxx"
35 #include "DrawViewShell.hxx"
36 #include "OutlineViewShell.hxx"
37 #include "ViewShellBase.hxx"
39 class SfxRequest;
41 namespace sd {
43 static sal_uInt16 SidArraySpell[] = {
44 SID_DRAWINGMODE,
45 SID_OUTLINEMODE,
46 SID_DIAMODE,
47 SID_NOTESMODE,
48 SID_HANDOUTMODE,
49 0 };
51 TYPEINIT1( FuSearch, FuPoor );
53 FuSearch::FuSearch (
54 ViewShell* pViewSh,
55 ::sd::Window* pWin,
56 ::sd::View* pView,
57 SdDrawDocument* pDoc,
58 SfxRequest& rReq )
59 : FuPoor(pViewSh, pWin, pView, pDoc, rReq),
60 pSdOutliner(NULL),
61 bOwnOutliner(false)
65 rtl::Reference<FuPoor> FuSearch::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
67 rtl::Reference<FuPoor> xFunc( new FuSearch( pViewSh, pWin, pView, pDoc, rReq ) );
68 xFunc->DoExecute(rReq);
69 return xFunc;
72 void FuSearch::DoExecute( SfxRequest& )
74 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArraySpell );
76 if ( mpViewShell->ISA(DrawViewShell) )
78 bOwnOutliner = true;
79 pSdOutliner = new ::sd::Outliner( mpDoc, OUTLINERMODE_TEXTOBJECT );
81 else if ( mpViewShell->ISA(OutlineViewShell) )
83 bOwnOutliner = false;
84 pSdOutliner = mpDoc->GetOutliner();
87 if (pSdOutliner)
88 pSdOutliner->PrepareSpelling();
91 FuSearch::~FuSearch()
93 if ( ! mpDocSh->IsInDestruction() && mpDocSh->GetViewShell()!=NULL)
94 mpDocSh->GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SidArraySpell );
96 if (pSdOutliner)
97 pSdOutliner->EndSpelling();
99 if (bOwnOutliner)
100 delete pSdOutliner;
103 void FuSearch::SearchAndReplace( const SvxSearchItem* pSearchItem )
105 ViewShellBase* pBase = PTR_CAST(ViewShellBase, SfxViewShell::Current());
106 ViewShell* pViewShell = NULL;
107 if (pBase != NULL)
108 pViewShell = pBase->GetMainViewShell().get();
110 if (pViewShell != NULL)
112 if ( pSdOutliner && pViewShell->ISA(DrawViewShell) && !bOwnOutliner )
114 pSdOutliner->EndSpelling();
116 bOwnOutliner = true;
117 pSdOutliner = new ::sd::Outliner( mpDoc, OUTLINERMODE_TEXTOBJECT );
118 pSdOutliner->PrepareSpelling();
120 else if ( pSdOutliner && pViewShell->ISA(OutlineViewShell) && bOwnOutliner )
122 pSdOutliner->EndSpelling();
123 delete pSdOutliner;
125 bOwnOutliner = false;
126 pSdOutliner = mpDoc->GetOutliner();
127 pSdOutliner->PrepareSpelling();
130 if (pSdOutliner)
132 bool bEndSpelling = pSdOutliner->StartSearchAndReplace(pSearchItem);
134 if (bEndSpelling)
136 pSdOutliner->EndSpelling();
137 pSdOutliner->PrepareSpelling();
143 } // end of namespace sd
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */