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

147 lines
4.3 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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
#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>
#include <drawdoc.hxx>
#include <app.hrc>
#include <sdmod.hxx>
#include <View.hxx>
#include <Outliner.hxx>
#include <DrawDocShell.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
static const sal_uInt16 SidArraySpell[] = {
2010-05-05 17:39:48 +02:00
SID_DRAWINGMODE,
Impress: Rework the way the display modes are presented. TODO: take into account remarks from Gerrit New combo to select display mode among: - Slide edition (Normal) - Outline - Notes - Slide sorter - Slide master - Notes master - Handout (master, as we are designing the template used to generate the handout) The combo is based on uno command .uno:DisplayMode Center pane tabs are hidden by default. A new uno dispatch command (.uno:ToggleTabBarVisibility) is available to show/hide this tab bar. Modified uno dispatch commands: No uno name has been modified. .uno:DiaMode : SID_DIAMODE renamed SID_SLIDER_SORTER_MODE .uno:OutlineMode SID_OUTLINEMODE renamed SID_OUTLINE_MODE .uno:NotesMode No change .uno:HandoutMode SID_HANDOUT_MODE renamed SID_HANDOUT_MASTER_MODE All internal code also considers the edit mode as master .uno:SlideMasterPage SID_SLIDE_MASTERPAGE renamed SID_SLIDE_MASTER_MODE If the input parameter SfxBoolItem Isactive is true or not provided, activates Slide Master mode. If parameter is false, activates the "Normal" (slide editing) mode. .uno:NotesMasterPage SID_NOTES_MASTERPAGE renamed SID_NOTES_MASTER_MODE If the input parameter SfxBoolItem Isactive is true or not provided, activates Notes Master mode. If parameter is false, activates the "Notes" mode. Modified behaviours: Now only one mode can be chosen. It is possible to navigate from a mode to any other mode. Previous behaviour: the following navigation Normal -> Slide Master -> Notes -> Normal was displaying slide master. It was required to activate Normal once more to get back to normal. Now the same commands will display the requested mode. Still to come (at least): - Fix reopen the last display mode. - Center pane tabs are now presenting all buttons for all modes (TODO). Change-Id: I11ab59d2f3caa9149260c5e55d44d598d0ce3390 Reviewed-on: https://gerrit.libreoffice.org/16723 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com>
2015-07-10 17:02:44 +02:00
SID_OUTLINE_MODE,
SID_SLIDE_SORTER_MODE,
SID_NOTES_MODE,
SID_HANDOUT_MASTER_MODE,
SID_SLIDE_MASTER_MODE,
SID_NOTES_MASTER_MODE,
2010-05-05 17:39:48 +02:00
0 };
FuSearch::FuSearch (
ViewShell* pViewSh,
::sd::Window* pWin,
::sd::View* pView,
SdDrawDocument* pDoc,
SfxRequest& rReq )
: FuPoor(pViewSh, pWin, pView, pDoc, rReq),
pSdOutliner(nullptr),
bOwnOutliner(false)
{
}
rtl::Reference<FuPoor> FuSearch::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
{
rtl::Reference<FuPoor> 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 ( dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr )
2000-09-18 16:07:07 +00:00
{
bOwnOutliner = true;
pSdOutliner = new SdOutliner( mpDoc, OutlinerMode::TextObject );
2000-09-18 16:07:07 +00:00
}
else if ( dynamic_cast< const OutlineViewShell *>( mpViewShell ) != nullptr )
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();
}
FuSearch::~FuSearch()
{
if ( ! mpDocSh->IsInDestruction() && mpDocSh->GetViewShell()!=nullptr)
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 )
{
ViewShellBase* pBase = dynamic_cast<ViewShellBase*>( SfxViewShell::Current() );
ViewShell* pViewShell = nullptr;
if (pBase != nullptr)
pViewShell = pBase->GetMainViewShell().get();
2000-09-18 16:07:07 +00:00
if (pViewShell != nullptr)
2000-09-18 16:07:07 +00:00
{
if ( pSdOutliner && dynamic_cast< const DrawViewShell *>( pViewShell ) != nullptr && !bOwnOutliner )
2000-09-18 16:07:07 +00:00
{
pSdOutliner->EndSpelling();
bOwnOutliner = true;
pSdOutliner = new SdOutliner( mpDoc, OutlinerMode::TextObject );
2000-09-18 16:07:07 +00:00
pSdOutliner->PrepareSpelling();
}
else if ( pSdOutliner && dynamic_cast< const OutlineViewShell *>( pViewShell ) != nullptr && 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);
2000-09-18 16:07:07 +00:00
if (bEndSpelling)
{
pSdOutliner->EndSpelling();
pSdOutliner->PrepareSpelling();
}
}
}
}
} // end of namespace sd
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */