merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / toolpanel / TaskPaneShellManager.cxx
blobadb534c6e702ef554dc65e1887ec5e936bb6c4d0
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.
82 // hack for annotation panel, better fix?
83 void TaskPaneShellManager_AddSubShell ( TaskPaneShellManager* pManager, sal_Int32 nId, SfxShell* pShell, ::Window* pWindow )
85 if( pManager != NULL )
86 pManager->AddSubShell( (ShellId)nId, pShell, pWindow );
89 void TaskPaneShellManager_RemoveSubShell ( TaskPaneShellManager* pManager, const SfxShell* pShell)
91 if( pManager != NULL )
92 pManager->RemoveSubShell( pShell );
95 void TaskPaneShellManager::AddSubShell (
96 ShellId nId,
97 SfxShell* pShell,
98 ::Window* pWindow)
100 if (pShell != NULL)
102 maSubShells[nId] = ShellDescriptor(pShell,pWindow);
103 if (pWindow != NULL)
105 pWindow->AddEventListener(LINK(this,TaskPaneShellManager,WindowCallback));
106 if (pWindow->IsReallyVisible())
107 mpViewShellManager->ActivateSubShell(mrViewShell, nId);
109 else
110 mpViewShellManager->ActivateSubShell(mrViewShell, nId);
117 void TaskPaneShellManager::RemoveSubShell (const SfxShell* pShell)
119 if (pShell != NULL)
121 SubShells::iterator iShell;
122 for (iShell=maSubShells.begin(); iShell!=maSubShells.end(); ++iShell)
123 if (iShell->second.mpShell == pShell)
125 if (iShell->second.mpWindow != NULL)
126 iShell->second.mpWindow->RemoveEventListener(
127 LINK(this,TaskPaneShellManager,WindowCallback));
128 mpViewShellManager->DeactivateSubShell(mrViewShell,iShell->first);
129 maSubShells.erase(iShell);
130 break;
138 void TaskPaneShellManager::MoveToTop (SfxShell* pShell)
140 SubShells::const_iterator iShell;
141 for (iShell=maSubShells.begin(); iShell!=maSubShells.end(); ++iShell)
142 if (iShell->second.mpShell == pShell)
144 ViewShellManager::UpdateLock aLocker (mpViewShellManager);
145 mpViewShellManager->MoveSubShellToTop(mrViewShell,iShell->first);
146 mpViewShellManager->MoveToTop(mrViewShell);
147 break;
154 IMPL_LINK(TaskPaneShellManager, WindowCallback, VclWindowEvent*, pEvent)
156 if (pEvent != NULL)
158 SubShells::const_iterator iShell;
159 ::Window* pWindow = pEvent->GetWindow();
160 for (iShell=maSubShells.begin(); iShell!=maSubShells.end(); ++iShell)
161 if (iShell->second.mpWindow == pWindow)
162 break;
163 if (iShell != maSubShells.end())
164 switch (pEvent->GetId())
166 case VCLEVENT_WINDOW_SHOW:
167 mpViewShellManager->ActivateSubShell(mrViewShell,iShell->first);
168 break;
170 case VCLEVENT_WINDOW_HIDE:
171 // Do not activate the sub shell. This leads to
172 // problems with shapes currently being in text edit
173 // mode: Deactivating the shell leads to leaving the
174 // text editing mode.
175 // mpViewShellManager->DeactivateSubShell(mrViewShell,iShell->first);
176 break;
180 return 0;
184 } } // end of namespace ::sd::toolpanel