1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 #include "precompiled_sd.hxx" 23 24 #include "SidebarViewShell.hxx" 25 26 #include "framework/TaskPanelResource.hxx" 27 28 #include <vcl/window.hxx> 29 #include <toolkit/helper/vclunohelper.hxx> 30 31 32 using namespace css; 33 using namespace cssu; 34 using namespace cssdf; 35 36 37 namespace sd { namespace framework { 38 39 namespace { 40 ::Window* GetWindowForResource ( 41 ViewShellBase& rViewShellBase, 42 const cssu::Reference<cssdf::XResourceId>& rxResourceId) 43 { 44 ::Window* pWindow = NULL; 45 if (rxResourceId.is() && rxResourceId->getAnchor().is()) 46 { 47 ::boost::shared_ptr<FrameworkHelper> pFrameworkHelper (FrameworkHelper::Instance(rViewShellBase)); 48 Reference<awt::XWindow> xWindow ( 49 pFrameworkHelper->GetPaneWindow(rxResourceId->getAnchor()->getAnchor())); 50 pWindow = VCLUnoHelper::GetWindow(xWindow); 51 } 52 return pWindow; 53 } 54 } 55 56 57 58 59 TaskPanelResource::TaskPanelResource ( 60 sidebar::SidebarViewShell& rSidebarViewShell, 61 sidebar::PanelId ePanelId, 62 const Reference<XResourceId>& rxResourceId) 63 : TaskPanelResourceInterfaceBase(m_aMutex), 64 mxResourceId(rxResourceId), 65 mpControl(rSidebarViewShell.CreatePanel( 66 GetWindowForResource(rSidebarViewShell.GetViewShellBase(), rxResourceId), 67 ePanelId)) 68 { 69 if (mpControl.get() != NULL) 70 { 71 mpControl->Show(); 72 mpControl->GetParent()->Show(); 73 mpControl->AddEventListener(LINK(this,TaskPanelResource,WindowEventHandler)); 74 } 75 } 76 77 78 79 80 TaskPanelResource::~TaskPanelResource (void) 81 { 82 mpControl.reset(); 83 } 84 85 86 87 88 void SAL_CALL TaskPanelResource::disposing () 89 { 90 mpControl.reset(); 91 } 92 93 94 95 96 Reference<XResourceId> SAL_CALL TaskPanelResource::getResourceId () 97 throw (css::uno::RuntimeException) 98 { 99 return mxResourceId; 100 } 101 102 103 104 105 sal_Bool SAL_CALL TaskPanelResource::isAnchorOnly (void) 106 throw (RuntimeException) 107 { 108 return false; 109 } 110 111 112 113 114 ::Window* TaskPanelResource::GetControl (void) const 115 { 116 return mpControl.get(); 117 } 118 119 120 121 122 IMPL_LINK(TaskPanelResource,WindowEventHandler,VclWindowEvent*,pEvent) 123 { 124 if (pEvent!=NULL && pEvent->GetId()==SFX_HINT_DYING) 125 { 126 // Somebody else deleted the window. Release our reference so 127 // that we do not delete it again. 128 mpControl.release(); 129 return sal_True; 130 } 131 else 132 return sal_False; 133 } 134 135 } } // end of namespace sd::framework 136