1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fusearch.cxx,v $
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>
44 #include "fuspell.hxx" // wegen SidArraySpell[]
45 #ifndef SD_WINDOW_SHELL_HXX
48 #include "drawdoc.hxx"
52 #include "Outliner.hxx"
53 #include "DrawViewShell.hxx"
54 #include "OutlineViewShell.hxx"
55 #include "ViewShellBase.hxx"
61 TYPEINIT1( FuSearch
, FuPoor
);
63 /*************************************************************************
67 \************************************************************************/
75 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
),
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
);
88 void FuSearch::DoExecute( SfxRequest
& )
90 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SidArraySpell
);
92 if ( mpViewShell
->ISA(DrawViewShell
) )
95 pSdOutliner
= new ::sd::Outliner( mpDoc
, OUTLINERMODE_TEXTOBJECT
);
97 else if ( mpViewShell
->ISA(OutlineViewShell
) )
100 pSdOutliner
= mpDoc
->GetOutliner();
104 pSdOutliner
->PrepareSpelling();
107 /*************************************************************************
111 \************************************************************************/
113 FuSearch::~FuSearch()
115 if ( ! mpDocSh
->IsInDestruction() && mpDocSh
->GetViewShell()!=NULL
)
116 mpDocSh
->GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SidArraySpell
);
119 pSdOutliner
->EndSpelling();
126 /*************************************************************************
130 \************************************************************************/
132 void FuSearch::SearchAndReplace( const SvxSearchItem
* pSearchItem
)
134 ViewShellBase
* pBase
= PTR_CAST(ViewShellBase
, SfxViewShell::Current());
135 ViewShell
* pViewShell
= NULL
;
137 pViewShell
= pBase
->GetMainViewShell().get();
139 if (pViewShell
!= NULL
)
141 if ( pSdOutliner
&& pViewShell
->ISA(DrawViewShell
) && !bOwnOutliner
)
143 pSdOutliner
->EndSpelling();
146 pSdOutliner
= new ::sd::Outliner( mpDoc
, OUTLINERMODE_TEXTOBJECT
);
147 pSdOutliner
->PrepareSpelling();
149 else if ( pSdOutliner
&& pViewShell
->ISA(OutlineViewShell
) && bOwnOutliner
)
151 pSdOutliner
->EndSpelling();
154 bOwnOutliner
= FALSE
;
155 pSdOutliner
= mpDoc
->GetOutliner();
156 pSdOutliner
->PrepareSpelling();
161 BOOL bEndSpelling
= pSdOutliner
->StartSearchAndReplace(pSearchItem
);
165 pSdOutliner
->EndSpelling();
166 pSdOutliner
->PrepareSpelling();
174 } // end of namespace sd