1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sd.hxx" 30 31 32 #include "fusearch.hxx" 33 34 #include <sfx2/viewfrm.hxx> 35 36 #include <svx/svxids.hrc> 37 #include <svl/srchitem.hxx> 38 #include <svx/srchdlg.hxx> 39 #include <sfx2/bindings.hxx> 40 #include "fupoor.hxx" 41 #ifndef SD_WINDOW_SHELL_HXX 42 #include "Window.hxx" 43 #endif 44 #include "drawdoc.hxx" 45 #include "app.hrc" 46 #include "app.hxx" 47 #include "View.hxx" 48 #include "Outliner.hxx" 49 #include "DrawViewShell.hxx" 50 #include "OutlineViewShell.hxx" 51 #include "ViewShellBase.hxx" 52 53 class SfxRequest; 54 55 namespace sd { 56 57 static sal_uInt16 SidArraySpell[] = { 58 SID_DRAWINGMODE, 59 SID_OUTLINEMODE, 60 SID_DIAMODE, 61 SID_NOTESMODE, 62 SID_HANDOUTMODE, 63 0 }; 64 65 TYPEINIT1( FuSearch, FuPoor ); 66 67 /************************************************************************* 68 |* 69 |* Konstruktor 70 |* 71 \************************************************************************/ 72 73 FuSearch::FuSearch ( 74 ViewShell* pViewSh, 75 ::sd::Window* pWin, 76 ::sd::View* pView, 77 SdDrawDocument* pDoc, 78 SfxRequest& rReq ) 79 : FuPoor(pViewSh, pWin, pView, pDoc, rReq), 80 pSdOutliner(NULL), 81 bOwnOutliner(sal_False) 82 { 83 } 84 85 FunctionReference FuSearch::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq ) 86 { 87 FunctionReference xFunc( new FuSearch( pViewSh, pWin, pView, pDoc, rReq ) ); 88 xFunc->DoExecute(rReq); 89 return xFunc; 90 } 91 92 void FuSearch::DoExecute( SfxRequest& ) 93 { 94 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArraySpell ); 95 96 if ( mpViewShell->ISA(DrawViewShell) ) 97 { 98 bOwnOutliner = sal_True; 99 pSdOutliner = new ::sd::Outliner( mpDoc, OUTLINERMODE_TEXTOBJECT ); 100 } 101 else if ( mpViewShell->ISA(OutlineViewShell) ) 102 { 103 bOwnOutliner = sal_False; 104 pSdOutliner = mpDoc->GetOutliner(); 105 } 106 107 if (pSdOutliner) 108 pSdOutliner->PrepareSpelling(); 109 } 110 111 /************************************************************************* 112 |* 113 |* Destruktor 114 |* 115 \************************************************************************/ 116 117 FuSearch::~FuSearch() 118 { 119 if ( ! mpDocSh->IsInDestruction() && mpDocSh->GetViewShell()!=NULL) 120 mpDocSh->GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SidArraySpell ); 121 122 if (pSdOutliner) 123 pSdOutliner->EndSpelling(); 124 125 if (bOwnOutliner) 126 delete pSdOutliner; 127 } 128 129 130 /************************************************************************* 131 |* 132 |* Suchen&Ersetzen 133 |* 134 \************************************************************************/ 135 136 void FuSearch::SearchAndReplace( const SvxSearchItem* pSearchItem ) 137 { 138 ViewShellBase* pBase = PTR_CAST(ViewShellBase, SfxViewShell::Current()); 139 ViewShell* pViewShell = NULL; 140 if (pBase != NULL) 141 pViewShell = pBase->GetMainViewShell().get(); 142 143 if (pViewShell != NULL) 144 { 145 if ( pSdOutliner && pViewShell->ISA(DrawViewShell) && !bOwnOutliner ) 146 { 147 pSdOutliner->EndSpelling(); 148 149 bOwnOutliner = sal_True; 150 pSdOutliner = new ::sd::Outliner( mpDoc, OUTLINERMODE_TEXTOBJECT ); 151 pSdOutliner->PrepareSpelling(); 152 } 153 else if ( pSdOutliner && pViewShell->ISA(OutlineViewShell) && bOwnOutliner ) 154 { 155 pSdOutliner->EndSpelling(); 156 delete pSdOutliner; 157 158 bOwnOutliner = sal_False; 159 pSdOutliner = mpDoc->GetOutliner(); 160 pSdOutliner->PrepareSpelling(); 161 } 162 163 if (pSdOutliner) 164 { 165 sal_Bool bEndSpelling = pSdOutliner->StartSearchAndReplace(pSearchItem); 166 167 if (bEndSpelling) 168 { 169 pSdOutliner->EndSpelling(); 170 pSdOutliner->PrepareSpelling(); 171 } 172 } 173 } 174 } 175 176 177 178 } // end of namespace sd 179