1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "TaskPaneShellManager.hxx"
23 #include "ViewShellManager.hxx"
24 #include <tools/diagnose_ex.h>
25 #include <vcl/window.hxx>
29 namespace sd
{ namespace toolpanel
{
31 TaskPaneShellManager::TaskPaneShellManager (
32 const ::boost::shared_ptr
<ViewShellManager
>& rpViewShellManager
,
33 const ViewShell
& rViewShell
)
34 : mpViewShellManager(rpViewShellManager
),
35 mrViewShell(rViewShell
),
43 TaskPaneShellManager::~TaskPaneShellManager (void)
45 while ( ! maSubShells
.empty())
46 RemoveSubShell(maSubShells
.begin()->second
.mpShell
);
52 SfxShell
* TaskPaneShellManager::CreateShell( ShellId nId
, ::Window
* , FrameView
* )
54 SubShells::const_iterator
iShell (maSubShells
.find(nId
));
55 if (iShell
!= maSubShells
.end())
56 return iShell
->second
.mpShell
;
64 void TaskPaneShellManager::ReleaseShell (SfxShell
* )
69 void TaskPaneShellManager::AddSubShell (
76 maSubShells
[nId
] = ShellDescriptor(pShell
,pWindow
);
79 pWindow
->AddEventListener(LINK(this,TaskPaneShellManager
,WindowCallback
));
80 if (pWindow
->IsReallyVisible())
81 mpViewShellManager
->ActivateSubShell(mrViewShell
, nId
);
84 mpViewShellManager
->ActivateSubShell(mrViewShell
, nId
);
91 void TaskPaneShellManager::RemoveSubShell (const ShellId i_nShellId
)
93 SubShells::iterator pos
= maSubShells
.find( i_nShellId
);
94 ENSURE_OR_RETURN_VOID( pos
!= maSubShells
.end(), "no shell for this ID" );
95 if ( pos
->second
.mpWindow
!= NULL
)
97 pos
->second
.mpWindow
->RemoveEventListener( LINK( this, TaskPaneShellManager
, WindowCallback
) );
99 mpViewShellManager
->DeactivateSubShell( mrViewShell
, pos
->first
);
100 maSubShells
.erase( pos
);
106 void TaskPaneShellManager::RemoveSubShell (const SfxShell
* pShell
)
110 SubShells::iterator iShell
;
111 for (iShell
=maSubShells
.begin(); iShell
!=maSubShells
.end(); ++iShell
)
112 if (iShell
->second
.mpShell
== pShell
)
114 if (iShell
->second
.mpWindow
!= NULL
)
115 iShell
->second
.mpWindow
->RemoveEventListener(
116 LINK(this,TaskPaneShellManager
,WindowCallback
));
117 mpViewShellManager
->DeactivateSubShell(mrViewShell
,iShell
->first
);
118 maSubShells
.erase(iShell
);
127 void TaskPaneShellManager::MoveToTop (SfxShell
* pShell
)
129 SubShells::const_iterator iShell
;
130 for (iShell
=maSubShells
.begin(); iShell
!=maSubShells
.end(); ++iShell
)
131 if (iShell
->second
.mpShell
== pShell
)
133 ViewShellManager::UpdateLock
aLocker (mpViewShellManager
);
134 mpViewShellManager
->MoveSubShellToTop(mrViewShell
,iShell
->first
);
135 mpViewShellManager
->MoveToTop(mrViewShell
);
143 IMPL_LINK(TaskPaneShellManager
, WindowCallback
, VclWindowEvent
*, pEvent
)
147 SubShells::const_iterator iShell
;
148 ::Window
* pWindow
= pEvent
->GetWindow();
149 for (iShell
=maSubShells
.begin(); iShell
!=maSubShells
.end(); ++iShell
)
150 if (iShell
->second
.mpWindow
== pWindow
)
152 if (iShell
!= maSubShells
.end())
153 switch (pEvent
->GetId())
155 case VCLEVENT_WINDOW_SHOW
:
156 mpViewShellManager
->ActivateSubShell(mrViewShell
,iShell
->first
);
159 case VCLEVENT_WINDOW_HIDE
:
160 // Do not activate the sub shell. This leads to
161 // problems with shapes currently being in text edit
162 // mode: Deactivating the shell leads to leaving the
163 // text editing mode.
164 // mpViewShellManager->DeactivateSubShell(mrViewShell,iShell->first);
173 } } // end of namespace ::sd::toolpanel
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */