1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
30 #include "drawdoc.hxx"
34 #include "Outliner.hxx"
35 #include "DrawViewShell.hxx"
36 #include "OutlineViewShell.hxx"
37 #include "ViewShellBase.hxx"
43 static sal_uInt16 SidArraySpell
[] = {
51 TYPEINIT1( FuSearch
, FuPoor
);
59 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
),
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
);
72 void FuSearch::DoExecute( SfxRequest
& )
74 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SidArraySpell
);
76 if ( mpViewShell
->ISA(DrawViewShell
) )
79 pSdOutliner
= new ::sd::Outliner( mpDoc
, OUTLINERMODE_TEXTOBJECT
);
81 else if ( mpViewShell
->ISA(OutlineViewShell
) )
84 pSdOutliner
= mpDoc
->GetOutliner();
88 pSdOutliner
->PrepareSpelling();
93 if ( ! mpDocSh
->IsInDestruction() && mpDocSh
->GetViewShell()!=NULL
)
94 mpDocSh
->GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SidArraySpell
);
97 pSdOutliner
->EndSpelling();
103 void FuSearch::SearchAndReplace( const SvxSearchItem
* pSearchItem
)
105 ViewShellBase
* pBase
= PTR_CAST(ViewShellBase
, SfxViewShell::Current());
106 ViewShell
* pViewShell
= NULL
;
108 pViewShell
= pBase
->GetMainViewShell().get();
110 if (pViewShell
!= NULL
)
112 if ( pSdOutliner
&& pViewShell
->ISA(DrawViewShell
) && !bOwnOutliner
)
114 pSdOutliner
->EndSpelling();
117 pSdOutliner
= new ::sd::Outliner( mpDoc
, OUTLINERMODE_TEXTOBJECT
);
118 pSdOutliner
->PrepareSpelling();
120 else if ( pSdOutliner
&& pViewShell
->ISA(OutlineViewShell
) && bOwnOutliner
)
122 pSdOutliner
->EndSpelling();
125 bOwnOutliner
= false;
126 pSdOutliner
= mpDoc
->GetOutliner();
127 pSdOutliner
->PrepareSpelling();
132 bool bEndSpelling
= pSdOutliner
->StartSearchAndReplace(pSearchItem
);
136 pSdOutliner
->EndSpelling();
137 pSdOutliner
->PrepareSpelling();
143 } // end of namespace sd
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */