update dev300-m58
[ooovba.git] / sd / source / ui / toolpanel / TaskPaneShellManager.cxx
blobb668403c9183904a24763919ef14ab85b237486c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TaskPaneShellManager.cxx,v $
10 * $Revision: 1.11 $
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>
40 #include <algorithm>
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),
49 maSubShells()
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;
70 else
71 return NULL;
77 void TaskPaneShellManager::ReleaseShell (SfxShell* )
79 // Nothing to do.
85 void TaskPaneShellManager::AddSubShell (
86 ShellId nId,
87 SfxShell* pShell,
88 ::Window* pWindow)
90 if (pShell != NULL)
92 maSubShells[nId] = ShellDescriptor(pShell,pWindow);
93 if (pWindow != NULL)
95 pWindow->AddEventListener(LINK(this,TaskPaneShellManager,WindowCallback));
96 if (pWindow->IsReallyVisible())
97 mpViewShellManager->ActivateSubShell(mrViewShell, nId);
99 else
100 mpViewShellManager->ActivateSubShell(mrViewShell, nId);
107 void TaskPaneShellManager::RemoveSubShell (const SfxShell* pShell)
109 if (pShell != NULL)
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);
120 break;
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);
137 break;
144 IMPL_LINK(TaskPaneShellManager, WindowCallback, VclWindowEvent*, pEvent)
146 if (pEvent != NULL)
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)
152 break;
153 if (iShell != maSubShells.end())
154 switch (pEvent->GetId())
156 case VCLEVENT_WINDOW_SHOW:
157 mpViewShellManager->ActivateSubShell(mrViewShell,iShell->first);
158 break;
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);
166 break;
170 return 0;
174 } } // end of namespace ::sd::toolpanel