2004-05-07 09:53:44 -05:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-09 00:57:37 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-05-07 09:53:44 -05:00
|
|
|
*
|
2005-09-09 00:57:37 -05:00
|
|
|
* $RCSfile: FormShellManager.cxx,v $
|
2004-05-07 09:53:44 -05:00
|
|
|
*
|
2008-04-03 09:01:51 -05:00
|
|
|
* $Revision: 1.11 $
|
2004-05-07 09:53:44 -05:00
|
|
|
*
|
2008-04-03 09:01:51 -05:00
|
|
|
* last change: $Author: kz $ $Date: 2008-04-03 15:01:51 $
|
2004-05-07 09:53:44 -05:00
|
|
|
*
|
2005-09-09 00:57:37 -05:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2004-05-07 09:53:44 -05:00
|
|
|
*
|
|
|
|
*
|
2005-09-09 00:57:37 -05:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2004-05-07 09:53:44 -05:00
|
|
|
*
|
2005-09-09 00:57:37 -05:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2004-05-07 09:53:44 -05:00
|
|
|
*
|
2005-09-09 00:57:37 -05:00
|
|
|
* This library 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 for more details.
|
2004-05-07 09:53:44 -05:00
|
|
|
*
|
2005-09-09 00:57:37 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2004-05-07 09:53:44 -05:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 13:29:50 -05:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sd.hxx"
|
|
|
|
|
2004-05-07 09:53:44 -05:00
|
|
|
#include "FormShellManager.hxx"
|
|
|
|
|
2007-04-03 10:25:40 -05:00
|
|
|
#include "EventMultiplexer.hxx"
|
2004-05-07 09:53:44 -05:00
|
|
|
#include "ViewShell.hxx"
|
|
|
|
#include "ViewShellBase.hxx"
|
2006-03-21 10:36:21 -06:00
|
|
|
#include "ViewShellManager.hxx"
|
2004-07-13 08:50:00 -05:00
|
|
|
#include "Window.hxx"
|
2004-05-07 09:53:44 -05:00
|
|
|
#include <svx/fmshell.hxx>
|
|
|
|
|
|
|
|
namespace sd {
|
|
|
|
|
2006-03-21 10:36:21 -06:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
/** This factory is responsible for creating and deleting the FmFormShell.
|
|
|
|
*/
|
|
|
|
class FormShellManagerFactory
|
|
|
|
: public ::sd::ShellFactory<SfxShell>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FormShellManagerFactory (ViewShell& rViewShell, FormShellManager& rManager);
|
|
|
|
virtual FmFormShell* CreateShell (ShellId nId, ::Window* pParentWindow, FrameView* pFrameView);
|
|
|
|
virtual void ReleaseShell (SfxShell* pShell);
|
|
|
|
|
|
|
|
private:
|
|
|
|
::sd::ViewShell& mrViewShell;
|
|
|
|
FormShellManager& mrFormShellManager;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end of anonymous namespace
|
|
|
|
|
2004-05-07 09:53:44 -05:00
|
|
|
|
2004-07-13 08:50:00 -05:00
|
|
|
FormShellManager::FormShellManager (ViewShellBase& rBase)
|
2004-06-03 01:45:07 -05:00
|
|
|
: mrBase(rBase),
|
2006-03-21 10:36:21 -06:00
|
|
|
mpFormShell(NULL),
|
|
|
|
mbFormShellAboveViewShell(false),
|
2008-04-03 09:01:51 -05:00
|
|
|
mpSubShellFactory(),
|
|
|
|
mbIsMainViewChangePending(false),
|
|
|
|
mpMainViewShellWindow(NULL)
|
2004-05-07 09:53:44 -05:00
|
|
|
{
|
2007-04-03 10:25:40 -05:00
|
|
|
// Register at the EventMultiplexer to be informed about changes in the
|
2004-11-26 08:03:16 -06:00
|
|
|
// center pane.
|
2007-04-03 10:25:40 -05:00
|
|
|
Link aLink (LINK(this, FormShellManager, ConfigurationUpdateHandler));
|
2008-04-03 09:01:51 -05:00
|
|
|
mrBase.GetEventMultiplexer()->AddEventListener(
|
2007-04-03 10:25:40 -05:00
|
|
|
aLink,
|
|
|
|
sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED
|
2008-04-03 09:01:51 -05:00
|
|
|
| sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED
|
|
|
|
| sd::tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED);
|
2004-11-26 08:03:16 -06:00
|
|
|
|
|
|
|
RegisterAtCenterPane();
|
|
|
|
}
|
2004-05-07 09:53:44 -05:00
|
|
|
|
2004-07-13 08:50:00 -05:00
|
|
|
|
2004-05-07 09:53:44 -05:00
|
|
|
|
2004-11-26 08:03:16 -06:00
|
|
|
|
|
|
|
FormShellManager::~FormShellManager (void)
|
|
|
|
{
|
2006-03-21 10:36:21 -06:00
|
|
|
SetFormShell(NULL);
|
2004-11-26 08:03:16 -06:00
|
|
|
UnregisterAtCenterPane();
|
|
|
|
|
2007-04-03 10:25:40 -05:00
|
|
|
// Unregister from the EventMultiplexer.
|
|
|
|
Link aLink (LINK(this, FormShellManager, ConfigurationUpdateHandler));
|
2008-04-03 09:01:51 -05:00
|
|
|
mrBase.GetEventMultiplexer()->RemoveEventListener(aLink);
|
2006-03-21 10:36:21 -06:00
|
|
|
|
|
|
|
if (mpSubShellFactory.get() != NULL)
|
|
|
|
{
|
2007-04-03 10:25:40 -05:00
|
|
|
ViewShell* pShell = mrBase.GetMainViewShell().get();
|
2006-03-21 10:36:21 -06:00
|
|
|
if (pShell != NULL)
|
2008-04-03 09:01:51 -05:00
|
|
|
mrBase.GetViewShellManager()->RemoveSubShellFactory(pShell,mpSubShellFactory);
|
2006-03-21 10:36:21 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FormShellManager::SetFormShell (FmFormShell* pFormShell)
|
|
|
|
{
|
|
|
|
if (mpFormShell != pFormShell)
|
|
|
|
{
|
|
|
|
// Disconnect from the old form shell.
|
|
|
|
if (mpFormShell != NULL)
|
|
|
|
{
|
|
|
|
mpFormShell->SetControlActivationHandler(Link());
|
|
|
|
EndListening(*mpFormShell);
|
|
|
|
mpFormShell->SetView(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
mpFormShell = pFormShell;
|
|
|
|
|
|
|
|
// Connect to the new form shell.
|
|
|
|
if (mpFormShell != NULL)
|
|
|
|
{
|
|
|
|
mpFormShell->SetControlActivationHandler(
|
|
|
|
LINK(
|
|
|
|
this,
|
|
|
|
FormShellManager,
|
|
|
|
FormControlActivated));
|
|
|
|
StartListening(*mpFormShell);
|
|
|
|
|
2007-04-03 10:25:40 -05:00
|
|
|
ViewShell* pMainViewShell = mrBase.GetMainViewShell().get();
|
2006-03-21 10:36:21 -06:00
|
|
|
if (pMainViewShell != NULL)
|
|
|
|
{
|
|
|
|
// Prevent setting the view twice at the FmFormShell.
|
|
|
|
FmFormView* pFormView = static_cast<FmFormView*>(pMainViewShell->GetView());
|
|
|
|
if (mpFormShell->GetFormView() != pFormView)
|
|
|
|
mpFormShell->SetView(pFormView);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tell the ViewShellManager where on the stack to place the form shell.
|
2008-04-03 09:01:51 -05:00
|
|
|
mrBase.GetViewShellManager()->SetFormShell(
|
2007-04-03 10:25:40 -05:00
|
|
|
mrBase.GetMainViewShell().get(),
|
2006-03-21 10:36:21 -06:00
|
|
|
mpFormShell,
|
|
|
|
mbFormShellAboveViewShell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FmFormShell* FormShellManager::GetFormShell (void)
|
|
|
|
{
|
|
|
|
return mpFormShell;
|
2004-05-07 09:53:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-11-26 08:03:16 -06:00
|
|
|
void FormShellManager::RegisterAtCenterPane (void)
|
2004-05-07 09:53:44 -05:00
|
|
|
{
|
2004-11-26 08:03:16 -06:00
|
|
|
do
|
2004-05-07 09:53:44 -05:00
|
|
|
{
|
2007-04-03 10:25:40 -05:00
|
|
|
ViewShell* pShell = mrBase.GetMainViewShell().get();
|
2004-11-26 08:03:16 -06:00
|
|
|
if (pShell == NULL)
|
|
|
|
break;
|
|
|
|
|
2006-03-21 10:36:21 -06:00
|
|
|
// No form shell for the slide sorter. Besides that it is not
|
|
|
|
// necessary, using both together results in crashes.
|
|
|
|
if (pShell->GetShellType() == ViewShell::ST_SLIDE_SORTER)
|
|
|
|
break;
|
|
|
|
|
2008-04-03 09:01:51 -05:00
|
|
|
mpMainViewShellWindow = pShell->GetActiveWindow();
|
|
|
|
if (mpMainViewShellWindow == NULL)
|
2004-11-26 08:03:16 -06:00
|
|
|
break;
|
2004-07-13 08:50:00 -05:00
|
|
|
|
2004-11-26 08:03:16 -06:00
|
|
|
// Register at the window to get informed when to move the form
|
|
|
|
// shell to the bottom of the shell stack.
|
2008-04-03 09:01:51 -05:00
|
|
|
mpMainViewShellWindow->AddEventListener(
|
2004-05-07 09:53:44 -05:00
|
|
|
LINK(
|
|
|
|
this,
|
|
|
|
FormShellManager,
|
2004-11-26 08:03:16 -06:00
|
|
|
WindowEventHandler));
|
2004-05-07 09:53:44 -05:00
|
|
|
|
2006-03-21 10:36:21 -06:00
|
|
|
// Create a shell factory and with it activate the form shell.
|
|
|
|
OSL_ASSERT(mpSubShellFactory.get()==NULL);
|
|
|
|
mpSubShellFactory.reset(new FormShellManagerFactory(*pShell, *this));
|
2008-04-03 09:01:51 -05:00
|
|
|
mrBase.GetViewShellManager()->AddSubShellFactory(pShell,mpSubShellFactory);
|
|
|
|
mrBase.GetViewShellManager()->ActivateSubShell(*pShell, RID_FORMLAYER_TOOLBOX);
|
2004-11-26 08:03:16 -06:00
|
|
|
}
|
|
|
|
while (false);
|
2004-07-13 08:50:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-11-26 08:03:16 -06:00
|
|
|
void FormShellManager::UnregisterAtCenterPane (void)
|
2004-07-13 08:50:00 -05:00
|
|
|
{
|
2004-11-26 08:03:16 -06:00
|
|
|
do
|
|
|
|
{
|
2008-04-03 09:01:51 -05:00
|
|
|
if (mpMainViewShellWindow != NULL)
|
|
|
|
{
|
|
|
|
// Unregister from the window.
|
|
|
|
mpMainViewShellWindow->RemoveEventListener(
|
|
|
|
LINK(
|
|
|
|
this,
|
|
|
|
FormShellManager,
|
|
|
|
WindowEventHandler));
|
|
|
|
mpMainViewShellWindow = NULL;
|
|
|
|
}
|
2004-11-26 08:03:16 -06:00
|
|
|
|
|
|
|
// Unregister form at the form shell.
|
2006-03-21 10:36:21 -06:00
|
|
|
SetFormShell(NULL);
|
|
|
|
|
|
|
|
// Deactivate the form shell and destroy the shell factory.
|
2008-04-03 09:01:51 -05:00
|
|
|
ViewShell* pShell = mrBase.GetMainViewShell().get();
|
|
|
|
if (pShell != NULL)
|
|
|
|
{
|
|
|
|
mrBase.GetViewShellManager()->DeactivateSubShell(*pShell, RID_FORMLAYER_TOOLBOX);
|
|
|
|
mrBase.GetViewShellManager()->RemoveSubShellFactory(pShell, mpSubShellFactory);
|
|
|
|
}
|
|
|
|
|
2006-03-21 10:36:21 -06:00
|
|
|
mpSubShellFactory.reset();
|
2004-11-26 08:03:16 -06:00
|
|
|
}
|
|
|
|
while (false);
|
2004-07-13 08:50:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-05-07 09:53:44 -05:00
|
|
|
IMPL_LINK(FormShellManager, FormControlActivated, FmFormShell*, EMPTYARG)
|
|
|
|
{
|
|
|
|
// The form shell has been actived. To give it priority in reacting to
|
|
|
|
// slot calls the form shell is moved to the top of the object bar shell
|
|
|
|
// stack.
|
2007-04-03 10:25:40 -05:00
|
|
|
ViewShell* pShell = mrBase.GetMainViewShell().get();
|
2006-03-21 10:36:21 -06:00
|
|
|
if (pShell!=NULL && !mbFormShellAboveViewShell)
|
2004-05-07 09:53:44 -05:00
|
|
|
{
|
2006-03-21 10:36:21 -06:00
|
|
|
mbFormShellAboveViewShell = true;
|
|
|
|
|
|
|
|
ViewShellManager::UpdateLock aLock (mrBase.GetViewShellManager());
|
2008-04-03 09:01:51 -05:00
|
|
|
mrBase.GetViewShellManager()->SetFormShell(pShell,mpFormShell,mbFormShellAboveViewShell);
|
2004-05-07 09:53:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-04-03 10:25:40 -05:00
|
|
|
IMPL_LINK(FormShellManager, ConfigurationUpdateHandler, sd::tools::EventMultiplexerEvent*, pEvent)
|
2004-07-13 08:50:00 -05:00
|
|
|
{
|
2007-04-03 10:25:40 -05:00
|
|
|
switch (pEvent->meEventId)
|
2004-07-13 08:50:00 -05:00
|
|
|
{
|
2007-04-03 10:25:40 -05:00
|
|
|
case sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED:
|
|
|
|
UnregisterAtCenterPane();
|
|
|
|
break;
|
2004-07-13 08:50:00 -05:00
|
|
|
|
2007-04-03 10:25:40 -05:00
|
|
|
case sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED:
|
2008-04-03 09:01:51 -05:00
|
|
|
mbIsMainViewChangePending = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case sd::tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED:
|
|
|
|
if (mbIsMainViewChangePending)
|
|
|
|
{
|
|
|
|
mbIsMainViewChangePending = false;
|
|
|
|
RegisterAtCenterPane();
|
|
|
|
}
|
2007-04-03 10:25:40 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2004-07-13 08:50:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-05-07 09:53:44 -05:00
|
|
|
IMPL_LINK(FormShellManager, WindowEventHandler, VclWindowEvent*, pEvent)
|
|
|
|
{
|
|
|
|
if (pEvent != NULL)
|
|
|
|
{
|
|
|
|
switch (pEvent->GetId())
|
|
|
|
{
|
|
|
|
case VCLEVENT_WINDOW_GETFOCUS:
|
|
|
|
{
|
|
|
|
// The window of the center pane got the focus. Therefore
|
|
|
|
// the form shell is moved to the bottom of the object bar
|
|
|
|
// stack.
|
2007-04-03 10:25:40 -05:00
|
|
|
ViewShell* pShell = mrBase.GetMainViewShell().get();
|
2006-03-21 10:36:21 -06:00
|
|
|
if (pShell!=NULL && mbFormShellAboveViewShell)
|
2004-05-07 09:53:44 -05:00
|
|
|
{
|
2006-03-21 10:36:21 -06:00
|
|
|
mbFormShellAboveViewShell = false;
|
|
|
|
ViewShellManager::UpdateLock aLock (mrBase.GetViewShellManager());
|
2008-04-03 09:01:51 -05:00
|
|
|
mrBase.GetViewShellManager()->SetFormShell(
|
2006-03-21 10:36:21 -06:00
|
|
|
pShell,
|
|
|
|
mpFormShell,
|
|
|
|
mbFormShellAboveViewShell);
|
2004-05-07 09:53:44 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VCLEVENT_WINDOW_LOSEFOCUS:
|
|
|
|
// We follow the sloppy focus policy. Losing the focus is
|
2006-03-21 10:36:21 -06:00
|
|
|
// ignored. We wait for the focus to be placed either in
|
|
|
|
// the window or the form shell. The later, however, is
|
2004-05-07 09:53:44 -05:00
|
|
|
// notified over the FormControlActivated handler, not this
|
|
|
|
// one.
|
|
|
|
break;
|
2008-04-03 09:01:51 -05:00
|
|
|
|
|
|
|
case VCLEVENT_OBJECT_DYING:
|
|
|
|
mpMainViewShellWindow = NULL;
|
|
|
|
break;
|
2004-05-07 09:53:44 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-21 10:36:21 -06:00
|
|
|
|
|
|
|
|
|
|
|
void FormShellManager::SFX_NOTIFY(
|
2006-12-12 12:04:47 -06:00
|
|
|
SfxBroadcaster&,
|
2006-03-21 10:36:21 -06:00
|
|
|
const TypeId& rBCType,
|
|
|
|
const SfxHint& rHint,
|
|
|
|
const TypeId& rHintType)
|
|
|
|
{
|
|
|
|
const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
|
|
|
|
if (pSimpleHint!=NULL && pSimpleHint->GetId()==SFX_HINT_DYING)
|
|
|
|
{
|
|
|
|
// If all goes well this listener is called after the
|
|
|
|
// FormShellManager was notified about the dying form shell by the
|
|
|
|
// FormShellManagerFactory.
|
|
|
|
OSL_ASSERT(mpFormShell==NULL);
|
|
|
|
if (mpFormShell != NULL)
|
|
|
|
{
|
|
|
|
mpFormShell = NULL;
|
2008-04-03 09:01:51 -05:00
|
|
|
mrBase.GetViewShellManager()->SetFormShell(
|
2007-04-03 10:25:40 -05:00
|
|
|
mrBase.GetMainViewShell().get(),
|
2006-03-21 10:36:21 -06:00
|
|
|
NULL,
|
|
|
|
false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===== FormShellManagerFactory ===============================================
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
FormShellManagerFactory::FormShellManagerFactory (
|
|
|
|
::sd::ViewShell& rViewShell,
|
|
|
|
FormShellManager& rManager)
|
|
|
|
: mrViewShell(rViewShell),
|
|
|
|
mrFormShellManager(rManager)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FmFormShell* FormShellManagerFactory::CreateShell (
|
|
|
|
::sd::ShellId nId,
|
2006-12-12 12:04:47 -06:00
|
|
|
::Window*,
|
|
|
|
::sd::FrameView*)
|
2006-03-21 10:36:21 -06:00
|
|
|
{
|
|
|
|
FmFormShell* pShell = NULL;
|
|
|
|
|
|
|
|
::sd::View* pView = mrViewShell.GetView();
|
|
|
|
if (nId == RID_FORMLAYER_TOOLBOX)
|
|
|
|
{
|
|
|
|
pShell = new FmFormShell(&mrViewShell.GetViewShellBase(), pView);
|
|
|
|
mrFormShellManager.SetFormShell(pShell);
|
|
|
|
}
|
|
|
|
|
|
|
|
return pShell;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FormShellManagerFactory::ReleaseShell (SfxShell* pShell)
|
|
|
|
{
|
|
|
|
if (pShell != NULL)
|
|
|
|
{
|
|
|
|
mrFormShellManager.SetFormShell(NULL);
|
|
|
|
delete pShell;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // end of anonymous namespace
|
|
|
|
|
2004-05-07 09:53:44 -05:00
|
|
|
} // end of namespace sd
|