2010-10-12 15:51:52 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-21 14:30:25 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2017-10-23 22:32:55 +02:00
|
|
|
#include <fusearch.hxx>
|
2004-01-20 10:12:08 +00:00
|
|
|
|
2004-10-04 17:33:34 +00:00
|
|
|
#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>
|
2017-10-23 22:32:55 +02:00
|
|
|
#include <fupoor.hxx>
|
|
|
|
#include <Window.hxx>
|
|
|
|
#include <drawdoc.hxx>
|
|
|
|
#include <app.hrc>
|
|
|
|
#include <sdmod.hxx>
|
|
|
|
#include <View.hxx>
|
|
|
|
#include <Outliner.hxx>
|
2018-08-10 07:48:42 +02:00
|
|
|
#include <DrawDocShell.hxx>
|
2017-10-23 22:32:55 +02:00
|
|
|
#include <DrawViewShell.hxx>
|
|
|
|
#include <OutlineViewShell.hxx>
|
|
|
|
#include <ViewShellBase.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
class SfxRequest;
|
|
|
|
|
2004-01-20 10:12:08 +00:00
|
|
|
namespace sd {
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2016-12-11 15:15:49 +09:00
|
|
|
static const sal_uInt16 SidArraySpell[] = {
|
2010-05-05 17:39:48 +02:00
|
|
|
SID_DRAWINGMODE,
|
2015-07-10 17:02:44 +02:00
|
|
|
SID_OUTLINE_MODE,
|
|
|
|
SID_SLIDE_SORTER_MODE,
|
|
|
|
SID_NOTES_MODE,
|
|
|
|
SID_HANDOUT_MASTER_MODE,
|
2016-07-12 09:58:41 +01:00
|
|
|
SID_SLIDE_MASTER_MODE,
|
|
|
|
SID_NOTES_MASTER_MODE,
|
2010-05-05 17:39:48 +02:00
|
|
|
0 };
|
|
|
|
|
2004-01-20 10:12:08 +00:00
|
|
|
FuSearch::FuSearch (
|
|
|
|
ViewShell* pViewSh,
|
|
|
|
::sd::Window* pWin,
|
|
|
|
::sd::View* pView,
|
|
|
|
SdDrawDocument* pDoc,
|
|
|
|
SfxRequest& rReq )
|
|
|
|
: FuPoor(pViewSh, pWin, pView, pDoc, rReq),
|
2015-11-10 10:23:02 +01:00
|
|
|
pSdOutliner(nullptr),
|
2014-04-24 10:52:02 +02:00
|
|
|
bOwnOutliner(false)
|
2005-12-14 16:03:03 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-10-25 15:42:11 +02:00
|
|
|
rtl::Reference<FuPoor> FuSearch::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
|
2005-12-14 16:03:03 +00:00
|
|
|
{
|
2013-10-25 15:42:11 +02:00
|
|
|
rtl::Reference<FuPoor> xFunc( new FuSearch( pViewSh, pWin, pView, pDoc, rReq ) );
|
2005-12-14 16:03:03 +00:00
|
|
|
xFunc->DoExecute(rReq);
|
|
|
|
return xFunc;
|
|
|
|
}
|
|
|
|
|
2006-12-12 16:22:51 +00:00
|
|
|
void FuSearch::DoExecute( SfxRequest& )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2006-12-12 16:22:51 +00:00
|
|
|
mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArraySpell );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2015-09-30 16:10:07 +02:00
|
|
|
if ( dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-04-24 10:52:02 +02:00
|
|
|
bOwnOutliner = true;
|
2016-10-14 10:10:44 +02:00
|
|
|
pSdOutliner = new SdOutliner( mpDoc, OutlinerMode::TextObject );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2015-09-30 16:10:07 +02:00
|
|
|
else if ( dynamic_cast< const OutlineViewShell *>( mpViewShell ) != nullptr )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-04-24 10:52:02 +02:00
|
|
|
bOwnOutliner = false;
|
2006-12-12 16:22:51 +00:00
|
|
|
pSdOutliner = mpDoc->GetOutliner();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pSdOutliner)
|
|
|
|
pSdOutliner->PrepareSpelling();
|
|
|
|
}
|
|
|
|
|
|
|
|
FuSearch::~FuSearch()
|
|
|
|
{
|
2015-11-10 10:23:02 +01:00
|
|
|
if ( ! mpDocSh->IsInDestruction() && mpDocSh->GetViewShell()!=nullptr)
|
2006-12-12 16:22:51 +00:00
|
|
|
mpDocSh->GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SidArraySpell );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (pSdOutliner)
|
|
|
|
pSdOutliner->EndSpelling();
|
|
|
|
|
|
|
|
if (bOwnOutliner)
|
|
|
|
delete pSdOutliner;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FuSearch::SearchAndReplace( const SvxSearchItem* pSearchItem )
|
|
|
|
{
|
2015-09-30 16:10:07 +02:00
|
|
|
ViewShellBase* pBase = dynamic_cast<ViewShellBase*>( SfxViewShell::Current() );
|
2015-11-10 10:23:02 +01:00
|
|
|
ViewShell* pViewShell = nullptr;
|
|
|
|
if (pBase != nullptr)
|
2007-04-03 15:01:14 +00:00
|
|
|
pViewShell = pBase->GetMainViewShell().get();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2015-11-10 10:23:02 +01:00
|
|
|
if (pViewShell != nullptr)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2015-09-30 16:10:07 +02:00
|
|
|
if ( pSdOutliner && dynamic_cast< const DrawViewShell *>( pViewShell ) != nullptr && !bOwnOutliner )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
pSdOutliner->EndSpelling();
|
|
|
|
|
2014-04-24 10:52:02 +02:00
|
|
|
bOwnOutliner = true;
|
2016-10-14 10:10:44 +02:00
|
|
|
pSdOutliner = new SdOutliner( mpDoc, OutlinerMode::TextObject );
|
2000-09-18 16:07:07 +00:00
|
|
|
pSdOutliner->PrepareSpelling();
|
|
|
|
}
|
2015-09-30 16:10:07 +02:00
|
|
|
else if ( pSdOutliner && dynamic_cast< const OutlineViewShell *>( pViewShell ) != nullptr && bOwnOutliner )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
pSdOutliner->EndSpelling();
|
|
|
|
delete pSdOutliner;
|
|
|
|
|
2014-04-24 10:52:02 +02:00
|
|
|
bOwnOutliner = false;
|
2006-12-12 16:22:51 +00:00
|
|
|
pSdOutliner = mpDoc->GetOutliner();
|
2000-09-18 16:07:07 +00:00
|
|
|
pSdOutliner->PrepareSpelling();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pSdOutliner)
|
|
|
|
{
|
2014-04-24 10:52:02 +02:00
|
|
|
bool bEndSpelling = pSdOutliner->StartSearchAndReplace(pSearchItem);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (bEndSpelling)
|
|
|
|
{
|
|
|
|
pSdOutliner->EndSpelling();
|
|
|
|
pSdOutliner->PrepareSpelling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-20 10:12:08 +00:00
|
|
|
} // end of namespace sd
|
2010-10-12 15:51:52 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|