Update ooo320-m1
[ooovba.git] / sd / source / ui / func / fusearch.cxx
blobd63f8790a2aa2a3fc1e625ac6548bf53e379a717
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fusearch.cxx,v $
10 * $Revision: 1.16 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
35 #include "fusearch.hxx"
37 #include <sfx2/viewfrm.hxx>
39 #include <svx/svxids.hrc>
40 #include <sfx2/srchitem.hxx>
41 #include <svx/srchdlg.hxx>
42 #include <sfx2/bindings.hxx>
43 #include "fupoor.hxx"
44 #include "fuspell.hxx" // wegen SidArraySpell[]
45 #ifndef SD_WINDOW_SHELL_HXX
46 #include "Window.hxx"
47 #endif
48 #include "drawdoc.hxx"
49 #include "app.hrc"
50 #include "app.hxx"
51 #include "View.hxx"
52 #include "Outliner.hxx"
53 #include "DrawViewShell.hxx"
54 #include "OutlineViewShell.hxx"
55 #include "ViewShellBase.hxx"
57 class SfxRequest;
59 namespace sd {
61 TYPEINIT1( FuSearch, FuPoor );
63 /*************************************************************************
65 |* Konstruktor
67 \************************************************************************/
69 FuSearch::FuSearch (
70 ViewShell* pViewSh,
71 ::sd::Window* pWin,
72 ::sd::View* pView,
73 SdDrawDocument* pDoc,
74 SfxRequest& rReq )
75 : FuPoor(pViewSh, pWin, pView, pDoc, rReq),
76 pSdOutliner(NULL),
77 bOwnOutliner(FALSE)
81 FunctionReference FuSearch::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
83 FunctionReference xFunc( new FuSearch( pViewSh, pWin, pView, pDoc, rReq ) );
84 xFunc->DoExecute(rReq);
85 return xFunc;
88 void FuSearch::DoExecute( SfxRequest& )
90 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArraySpell );
92 if ( mpViewShell->ISA(DrawViewShell) )
94 bOwnOutliner = TRUE;
95 pSdOutliner = new ::sd::Outliner( mpDoc, OUTLINERMODE_TEXTOBJECT );
97 else if ( mpViewShell->ISA(OutlineViewShell) )
99 bOwnOutliner = FALSE;
100 pSdOutliner = mpDoc->GetOutliner();
103 if (pSdOutliner)
104 pSdOutliner->PrepareSpelling();
107 /*************************************************************************
109 |* Destruktor
111 \************************************************************************/
113 FuSearch::~FuSearch()
115 if ( ! mpDocSh->IsInDestruction() && mpDocSh->GetViewShell()!=NULL)
116 mpDocSh->GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SidArraySpell );
118 if (pSdOutliner)
119 pSdOutliner->EndSpelling();
121 if (bOwnOutliner)
122 delete pSdOutliner;
126 /*************************************************************************
128 |* Suchen&Ersetzen
130 \************************************************************************/
132 void FuSearch::SearchAndReplace( const SvxSearchItem* pSearchItem )
134 ViewShellBase* pBase = PTR_CAST(ViewShellBase, SfxViewShell::Current());
135 ViewShell* pViewShell = NULL;
136 if (pBase != NULL)
137 pViewShell = pBase->GetMainViewShell().get();
139 if (pViewShell != NULL)
141 if ( pSdOutliner && pViewShell->ISA(DrawViewShell) && !bOwnOutliner )
143 pSdOutliner->EndSpelling();
145 bOwnOutliner = TRUE;
146 pSdOutliner = new ::sd::Outliner( mpDoc, OUTLINERMODE_TEXTOBJECT );
147 pSdOutliner->PrepareSpelling();
149 else if ( pSdOutliner && pViewShell->ISA(OutlineViewShell) && bOwnOutliner )
151 pSdOutliner->EndSpelling();
152 delete pSdOutliner;
154 bOwnOutliner = FALSE;
155 pSdOutliner = mpDoc->GetOutliner();
156 pSdOutliner->PrepareSpelling();
159 if (pSdOutliner)
161 BOOL bEndSpelling = pSdOutliner->StartSearchAndReplace(pSearchItem);
163 if (bEndSpelling)
165 pSdOutliner->EndSpelling();
166 pSdOutliner->PrepareSpelling();
174 } // end of namespace sd