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