1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TaskPaneShellManager.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "TaskPaneShellManager.hxx"
36 #include "ViewShellManager.hxx"
37 #include <osl/diagnose.h>
38 #include <vcl/window.hxx>
42 namespace sd
{ namespace toolpanel
{
44 TaskPaneShellManager::TaskPaneShellManager (
45 const ::boost::shared_ptr
<ViewShellManager
>& rpViewShellManager
,
46 const ViewShell
& rViewShell
)
47 : mpViewShellManager(rpViewShellManager
),
48 mrViewShell(rViewShell
),
56 TaskPaneShellManager::~TaskPaneShellManager (void)
58 while ( ! maSubShells
.empty())
59 RemoveSubShell(maSubShells
.begin()->second
.mpShell
);
65 SfxShell
* TaskPaneShellManager::CreateShell( ShellId nId
, ::Window
* , FrameView
* )
67 SubShells::const_iterator
iShell (maSubShells
.find(nId
));
68 if (iShell
!= maSubShells
.end())
69 return iShell
->second
.mpShell
;
77 void TaskPaneShellManager::ReleaseShell (SfxShell
* )
85 void TaskPaneShellManager::AddSubShell (
92 maSubShells
[nId
] = ShellDescriptor(pShell
,pWindow
);
95 pWindow
->AddEventListener(LINK(this,TaskPaneShellManager
,WindowCallback
));
96 if (pWindow
->IsReallyVisible())
97 mpViewShellManager
->ActivateSubShell(mrViewShell
, nId
);
100 mpViewShellManager
->ActivateSubShell(mrViewShell
, nId
);
107 void TaskPaneShellManager::RemoveSubShell (const SfxShell
* pShell
)
111 SubShells::iterator iShell
;
112 for (iShell
=maSubShells
.begin(); iShell
!=maSubShells
.end(); ++iShell
)
113 if (iShell
->second
.mpShell
== pShell
)
115 if (iShell
->second
.mpWindow
!= NULL
)
116 iShell
->second
.mpWindow
->RemoveEventListener(
117 LINK(this,TaskPaneShellManager
,WindowCallback
));
118 mpViewShellManager
->DeactivateSubShell(mrViewShell
,iShell
->first
);
119 maSubShells
.erase(iShell
);
128 void TaskPaneShellManager::MoveToTop (SfxShell
* pShell
)
130 SubShells::const_iterator iShell
;
131 for (iShell
=maSubShells
.begin(); iShell
!=maSubShells
.end(); ++iShell
)
132 if (iShell
->second
.mpShell
== pShell
)
134 ViewShellManager::UpdateLock
aLocker (mpViewShellManager
);
135 mpViewShellManager
->MoveSubShellToTop(mrViewShell
,iShell
->first
);
136 mpViewShellManager
->MoveToTop(mrViewShell
);
144 IMPL_LINK(TaskPaneShellManager
, WindowCallback
, VclWindowEvent
*, pEvent
)
148 SubShells::const_iterator iShell
;
149 ::Window
* pWindow
= pEvent
->GetWindow();
150 for (iShell
=maSubShells
.begin(); iShell
!=maSubShells
.end(); ++iShell
)
151 if (iShell
->second
.mpWindow
== pWindow
)
153 if (iShell
!= maSubShells
.end())
154 switch (pEvent
->GetId())
156 case VCLEVENT_WINDOW_SHOW
:
157 mpViewShellManager
->ActivateSubShell(mrViewShell
,iShell
->first
);
160 case VCLEVENT_WINDOW_HIDE
:
161 // Do not activate the sub shell. This leads to
162 // problems with shapes currently being in text edit
163 // mode: Deactivating the shell leads to leaving the
164 // text editing mode.
165 // mpViewShellManager->DeactivateSubShell(mrViewShell,iShell->first);
174 } } // end of namespace ::sd::toolpanel