Files
libreoffice/sd/source/ui/func/fusearch.cxx

177 lines
4.8 KiB
C++
Raw Normal View History

2000-09-18 16:07:07 +00:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2000-09-18 16:07:07 +00:00
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2000-09-18 16:07:07 +00:00
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 16:07:07 +00:00
*
* This file is part of OpenOffice.org.
2000-09-18 16:07:07 +00:00
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
2000-09-18 16:07:07 +00:00
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
2000-09-18 16:07:07 +00:00
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
2000-09-18 16:07:07 +00:00
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sd.hxx"
2000-09-18 16:07:07 +00:00
#include "fusearch.hxx"
#include <sfx2/viewfrm.hxx>
2000-09-18 16:07:07 +00:00
#include <svx/svxids.hrc>
2009-12-10 23:06:35 +01:00
#include <svl/srchitem.hxx>
2000-09-18 16:07:07 +00:00
#include <svx/srchdlg.hxx>
#include <sfx2/bindings.hxx>
#include "fupoor.hxx"
#include "Window.hxx"
2000-09-18 16:07:07 +00:00
#include "drawdoc.hxx"
#include "app.hrc"
#include "app.hxx"
#include "View.hxx"
#include "Outliner.hxx"
#include "DrawViewShell.hxx"
#include "OutlineViewShell.hxx"
#include "ViewShellBase.hxx"
2000-09-18 16:07:07 +00:00
class SfxRequest;
namespace sd {
2000-09-18 16:07:07 +00:00
2010-05-05 17:39:48 +02:00
static USHORT SidArraySpell[] = {
SID_DRAWINGMODE,
SID_OUTLINEMODE,
SID_DIAMODE,
SID_NOTESMODE,
SID_HANDOUTMODE,
0 };
2000-09-18 16:07:07 +00:00
TYPEINIT1( FuSearch, FuPoor );
/*************************************************************************
|*
|* Konstruktor
|*
\************************************************************************/
FuSearch::FuSearch (
ViewShell* pViewSh,
::sd::Window* pWin,
::sd::View* pView,
SdDrawDocument* pDoc,
SfxRequest& rReq )
: FuPoor(pViewSh, pWin, pView, pDoc, rReq),
pSdOutliner(NULL),
bOwnOutliner(FALSE)
{
}
FunctionReference FuSearch::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
{
FunctionReference xFunc( new FuSearch( pViewSh, pWin, pView, pDoc, rReq ) );
xFunc->DoExecute(rReq);
return xFunc;
}
void FuSearch::DoExecute( SfxRequest& )
2000-09-18 16:07:07 +00:00
{
mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArraySpell );
2000-09-18 16:07:07 +00:00
if ( mpViewShell->ISA(DrawViewShell) )
2000-09-18 16:07:07 +00:00
{
bOwnOutliner = TRUE;
pSdOutliner = new ::sd::Outliner( mpDoc, OUTLINERMODE_TEXTOBJECT );
2000-09-18 16:07:07 +00:00
}
else if ( mpViewShell->ISA(OutlineViewShell) )
2000-09-18 16:07:07 +00:00
{
bOwnOutliner = FALSE;
pSdOutliner = mpDoc->GetOutliner();
2000-09-18 16:07:07 +00:00
}
if (pSdOutliner)
pSdOutliner->PrepareSpelling();
}
/*************************************************************************
|*
|* Destruktor
|*
\************************************************************************/
FuSearch::~FuSearch()
{
if ( ! mpDocSh->IsInDestruction() && mpDocSh->GetViewShell()!=NULL)
mpDocSh->GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SidArraySpell );
2000-09-18 16:07:07 +00:00
if (pSdOutliner)
pSdOutliner->EndSpelling();
if (bOwnOutliner)
delete pSdOutliner;
}
/*************************************************************************
|*
|* Suchen&Ersetzen
|*
\************************************************************************/
void FuSearch::SearchAndReplace( const SvxSearchItem* pSearchItem )
{
ViewShellBase* pBase = PTR_CAST(ViewShellBase, SfxViewShell::Current());
ViewShell* pViewShell = NULL;
if (pBase != NULL)
pViewShell = pBase->GetMainViewShell().get();
2000-09-18 16:07:07 +00:00
if (pViewShell != NULL)
2000-09-18 16:07:07 +00:00
{
if ( pSdOutliner && pViewShell->ISA(DrawViewShell) && !bOwnOutliner )
2000-09-18 16:07:07 +00:00
{
pSdOutliner->EndSpelling();
bOwnOutliner = TRUE;
pSdOutliner = new ::sd::Outliner( mpDoc, OUTLINERMODE_TEXTOBJECT );
2000-09-18 16:07:07 +00:00
pSdOutliner->PrepareSpelling();
}
else if ( pSdOutliner && pViewShell->ISA(OutlineViewShell) && bOwnOutliner )
2000-09-18 16:07:07 +00:00
{
pSdOutliner->EndSpelling();
delete pSdOutliner;
bOwnOutliner = FALSE;
pSdOutliner = mpDoc->GetOutliner();
2000-09-18 16:07:07 +00:00
pSdOutliner->PrepareSpelling();
}
if (pSdOutliner)
{
BOOL bEndSpelling = pSdOutliner->StartSearchAndReplace(pSearchItem);
if (bEndSpelling)
{
pSdOutliner->EndSpelling();
pSdOutliner->PrepareSpelling();
}
}
}
}
} // end of namespace sd