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 "framework/TaskPanelResource.hxx" 25 26 #include <vcl/window.hxx> 27 #include <toolkit/helper/vclunohelper.hxx> 28 29 30 using namespace css; 31 using namespace cssu; 32 using namespace cssdf; 33 34 35 namespace sd { namespace framework { 36 37 namespace { 38 ::Window* GetWindowForResource ( 39 ViewShellBase& rViewShellBase, 40 const cssu::Reference<cssdf::XResourceId>& rxResourceId) 41 { 42 ::Window* pWindow = NULL; 43 if (rxResourceId.is() && rxResourceId->getAnchor().is()) 44 { 45 ::boost::shared_ptr<FrameworkHelper> pFrameworkHelper (FrameworkHelper::Instance(rViewShellBase)); 46 Reference<awt::XWindow> xWindow ( 47 pFrameworkHelper->GetPaneWindow(rxResourceId->getAnchor()->getAnchor())); 48 pWindow = VCLUnoHelper::GetWindow(xWindow); 49 } 50 return pWindow; 51 } 52 } 53 54 55 56 57 TaskPanelResource::TaskPanelResource ( 58 sidebar::SidebarViewShell& rSidebarViewShell, 59 sidebar::PanelId ePanelId, 60 const Reference<XResourceId>& rxResourceId) 61 : TaskPanelResourceInterfaceBase(m_aMutex), 62 mxResourceId(rxResourceId), 63 mpControl(rSidebarViewShell.CreatePanel( 64 GetWindowForResource(rSidebarViewShell.GetViewShellBase(), rxResourceId), 65 ePanelId)) 66 { 67 if (mpControl.get() != NULL) 68 { 69 mpControl->Show(); 70 mpControl->GetParent()->Show(); 71 mpControl->AddEventListener(LINK(this,TaskPanelResource,WindowEventHandler)); 72 } 73 } 74 75 76 77 78 TaskPanelResource::~TaskPanelResource (void) 79 { 80 mpControl.reset(); 81 } 82 83 84 85 86 void SAL_CALL TaskPanelResource::disposing () 87 { 88 mpControl.reset(); 89 } 90 91 92 93 94 Reference<XResourceId> SAL_CALL TaskPanelResource::getResourceId () 95 { 96 return mxResourceId; 97 } 98 99 100 101 102 sal_Bool SAL_CALL TaskPanelResource::isAnchorOnly (void) 103 { 104 return false; 105 } 106 107 108 109 110 ::Window* TaskPanelResource::GetControl (void) const 111 { 112 return mpControl.get(); 113 } 114 115 116 117 118 IMPL_LINK(TaskPanelResource,WindowEventHandler,VclWindowEvent*,pEvent) 119 { 120 if (pEvent!=NULL && pEvent->GetId()==SFX_HINT_DYING) 121 { 122 // Somebody else deleted the window. Release our reference so 123 // that we do not delete it again. 124 mpControl.release(); 125 return sal_True; 126 } 127 else 128 return sal_False; 129 } 130 131 } } // end of namespace sd::framework 132