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
* )
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 (
102 maSubShells
[nId
] = ShellDescriptor(pShell
,pWindow
);
105 pWindow
->AddEventListener(LINK(this,TaskPaneShellManager
,WindowCallback
));
106 if (pWindow
->IsReallyVisible())
107 mpViewShellManager
->ActivateSubShell(mrViewShell
, nId
);
110 mpViewShellManager
->ActivateSubShell(mrViewShell
, nId
);
117 void TaskPaneShellManager::RemoveSubShell (const SfxShell
* pShell
)
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
);
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
);
154 IMPL_LINK(TaskPaneShellManager
, WindowCallback
, VclWindowEvent
*, pEvent
)
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
)
163 if (iShell
!= maSubShells
.end())
164 switch (pEvent
->GetId())
166 case VCLEVENT_WINDOW_SHOW
:
167 mpViewShellManager
->ActivateSubShell(mrViewShell
,iShell
->first
);
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);
184 } } // end of namespace ::sd::toolpanel