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 <sfx2/bindings.hxx>
26 #include <drawdoc.hxx>
28 #include <Outliner.hxx>
29 #include <DrawDocShell.hxx>
30 #include <DrawViewShell.hxx>
31 #include <OutlineViewShell.hxx>
32 #include <ViewShellBase.hxx>
38 static const sal_uInt16 SidArraySpell
[] = {
41 SID_SLIDE_SORTER_MODE
,
43 SID_HANDOUT_MASTER_MODE
,
44 SID_SLIDE_MASTER_MODE
,
45 SID_NOTES_MASTER_MODE
,
54 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
),
60 rtl::Reference
<FuPoor
> FuSearch::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
62 rtl::Reference
<FuPoor
> xFunc( new FuSearch( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
63 xFunc
->DoExecute(rReq
);
67 void FuSearch::DoExecute( SfxRequest
& )
69 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SidArraySpell
);
71 if ( dynamic_cast< const DrawViewShell
*>( mpViewShell
) != nullptr )
74 pSdOutliner
= new SdOutliner( mpDoc
, OutlinerMode::TextObject
);
76 else if ( dynamic_cast< const OutlineViewShell
*>( mpViewShell
) != nullptr )
79 pSdOutliner
= mpDoc
->GetOutliner();
83 pSdOutliner
->PrepareSpelling();
88 if ( ! mpDocSh
->IsInDestruction() && mpDocSh
->GetViewShell()!=nullptr)
89 mpDocSh
->GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SidArraySpell
);
92 pSdOutliner
->EndSpelling();
98 void FuSearch::SearchAndReplace( const SvxSearchItem
* pSearchItem
)
100 ViewShellBase
* pBase
= dynamic_cast<ViewShellBase
*>( SfxViewShell::Current() );
101 ViewShell
* pViewShell
= nullptr;
102 if (pBase
!= nullptr)
103 pViewShell
= pBase
->GetMainViewShell().get();
105 if (pViewShell
== nullptr)
108 if ( pSdOutliner
&& dynamic_cast< const DrawViewShell
*>( pViewShell
) != nullptr && !bOwnOutliner
)
110 pSdOutliner
->EndSpelling();
113 pSdOutliner
= new SdOutliner( mpDoc
, OutlinerMode::TextObject
);
114 pSdOutliner
->PrepareSpelling();
116 else if ( pSdOutliner
&& dynamic_cast< const OutlineViewShell
*>( pViewShell
) != nullptr && bOwnOutliner
)
118 pSdOutliner
->EndSpelling();
121 bOwnOutliner
= false;
122 pSdOutliner
= mpDoc
->GetOutliner();
123 pSdOutliner
->PrepareSpelling();
128 bool bEndSpelling
= pSdOutliner
->StartSearchAndReplace(pSearchItem
);
132 pSdOutliner
->EndSpelling();
133 pSdOutliner
->PrepareSpelling();
138 } // end of namespace sd
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */