fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sd / source / ui / toolpanel / TaskPaneShellManager.cxx
blob2b249bed3e7f72e64e811619f79e01c0b7f082a0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
27 #include <algorithm>
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),
36 maSubShells()
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;
57 else
58 return NULL;
64 void TaskPaneShellManager::ReleaseShell (SfxShell* )
66 // Nothing to do.
69 void TaskPaneShellManager::AddSubShell (
70 ShellId nId,
71 SfxShell* pShell,
72 ::Window* pWindow)
74 if (pShell != NULL)
76 maSubShells[nId] = ShellDescriptor(pShell,pWindow);
77 if (pWindow != NULL)
79 pWindow->AddEventListener(LINK(this,TaskPaneShellManager,WindowCallback));
80 if (pWindow->IsReallyVisible())
81 mpViewShellManager->ActivateSubShell(mrViewShell, nId);
83 else
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)
108 if (pShell != NULL)
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);
119 break;
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);
136 break;
143 IMPL_LINK(TaskPaneShellManager, WindowCallback, VclWindowEvent*, pEvent)
145 if (pEvent != NULL)
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)
151 break;
152 if (iShell != maSubShells.end())
153 switch (pEvent->GetId())
155 case VCLEVENT_WINDOW_SHOW:
156 mpViewShellManager->ActivateSubShell(mrViewShell,iShell->first);
157 break;
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);
165 break;
169 return 0;
173 } } // end of namespace ::sd::toolpanel
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */