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 const sal_uInt16 SidArraySpell
[] = {
46 SID_SLIDE_SORTER_MODE
,
48 SID_HANDOUT_MASTER_MODE
,
49 SID_SLIDE_MASTER_MODE
,
50 SID_NOTES_MASTER_MODE
,
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 ( dynamic_cast< const DrawViewShell
*>( mpViewShell
) != nullptr )
79 pSdOutliner
= new SdOutliner( mpDoc
, OutlinerMode::TextObject
);
81 else if ( dynamic_cast< const OutlineViewShell
*>( mpViewShell
) != nullptr )
84 pSdOutliner
= mpDoc
->GetOutliner();
88 pSdOutliner
->PrepareSpelling();
93 if ( ! mpDocSh
->IsInDestruction() && mpDocSh
->GetViewShell()!=nullptr)
94 mpDocSh
->GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SidArraySpell
);
97 pSdOutliner
->EndSpelling();
103 void FuSearch::SearchAndReplace( const SvxSearchItem
* pSearchItem
)
105 ViewShellBase
* pBase
= dynamic_cast<ViewShellBase
*>( SfxViewShell::Current() );
106 ViewShell
* pViewShell
= nullptr;
107 if (pBase
!= nullptr)
108 pViewShell
= pBase
->GetMainViewShell().get();
110 if (pViewShell
!= nullptr)
112 if ( pSdOutliner
&& dynamic_cast< const DrawViewShell
*>( pViewShell
) != nullptr && !bOwnOutliner
)
114 pSdOutliner
->EndSpelling();
117 pSdOutliner
= new SdOutliner( mpDoc
, OutlinerMode::TextObject
);
118 pSdOutliner
->PrepareSpelling();
120 else if ( pSdOutliner
&& dynamic_cast< const OutlineViewShell
*>( pViewShell
) != nullptr && 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: */