Update ooo320-m1
[ooovba.git] / sd / source / ui / framework / factories / Pane.cxx
blobabfbfbc346237f736780b2a52bfe8c2ce80158b3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Pane.cxx,v $
11 * $Revision: 1.3 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #include "precompiled_sd.hxx"
34 #include "framework/Pane.hxx"
36 #include <rtl/uuid.h>
37 #include <vcl/svapp.hxx>
38 #include <vos/mutex.hxx>
39 #include <toolkit/helper/vclunohelper.hxx>
40 #include <vcl/window.hxx>
41 #include <cppcanvas/vclfactory.hxx>
43 using namespace ::com::sun::star;
44 using namespace ::com::sun::star::uno;
45 using namespace ::com::sun::star::drawing::framework;
47 using ::rtl::OUString;
49 namespace sd { namespace framework {
51 Pane::Pane (
52 const Reference<XResourceId>& rxPaneId,
53 ::Window* pWindow)
54 throw ()
55 : PaneInterfaceBase(MutexOwner::maMutex),
56 mxPaneId(rxPaneId),
57 mpWindow(pWindow),
58 mxWindow(VCLUnoHelper::GetInterface(pWindow))
65 Pane::~Pane (void) throw()
72 void Pane::disposing (void)
74 mxWindow = NULL;
75 mpWindow = NULL;
81 ::Window* Pane::GetWindow (void)
83 if (mxWindow.is())
84 return mpWindow;
85 else
86 return NULL;
92 //----- XPane -----------------------------------------------------------------
94 Reference<awt::XWindow> SAL_CALL Pane::getWindow (void)
95 throw (RuntimeException)
97 ThrowIfDisposed();
99 return mxWindow;
105 Reference<rendering::XCanvas> SAL_CALL Pane::getCanvas (void)
106 throw (RuntimeException)
108 ::osl::MutexGuard aGuard (maMutex);
109 ThrowIfDisposed();
111 if ( ! mxCanvas.is())
112 mxCanvas = CreateCanvas();
114 return mxCanvas;
120 //----- XPane2 ----------------------------------------------------------------
122 sal_Bool SAL_CALL Pane::isVisible (void)
123 throw (RuntimeException)
125 ThrowIfDisposed();
127 const ::Window* pWindow = GetWindow();
128 if (pWindow != NULL)
129 return pWindow->IsVisible();
130 else
131 return false;
137 void SAL_CALL Pane::setVisible (sal_Bool bIsVisible)
138 throw (RuntimeException)
140 ThrowIfDisposed();
142 ::Window* pWindow = GetWindow();
143 if (pWindow != NULL)
144 pWindow->Show(bIsVisible);
150 Reference<accessibility::XAccessible> SAL_CALL Pane::getAccessible (void)
151 throw (RuntimeException)
153 ThrowIfDisposed();
154 ::Window* pWindow = GetWindow();
155 if (pWindow != NULL)
156 return pWindow->GetAccessible(FALSE);
157 else
158 return NULL;
164 void SAL_CALL Pane::setAccessible (
165 const Reference<accessibility::XAccessible>& rxAccessible)
166 throw (RuntimeException)
168 ThrowIfDisposed();
169 ::Window* pWindow = GetWindow();
170 if (pWindow != NULL)
171 pWindow->SetAccessible(rxAccessible);
177 //----- XResource -------------------------------------------------------------
179 Reference<XResourceId> SAL_CALL Pane::getResourceId (void)
180 throw (RuntimeException)
182 ThrowIfDisposed();
184 return mxPaneId;
190 sal_Bool SAL_CALL Pane::isAnchorOnly (void)
191 throw (RuntimeException)
193 return true;
199 //----- XUnoTunnel ------------------------------------------------------------
201 const Sequence<sal_Int8>& Pane::getUnoTunnelId (void)
203 static Sequence<sal_Int8>* pSequence = NULL;
204 if (pSequence == NULL)
206 const ::vos::OGuard aSolarGuard (Application::GetSolarMutex());
207 if (pSequence == NULL)
209 static ::com::sun::star::uno::Sequence<sal_Int8> aSequence (16);
210 rtl_createUuid((sal_uInt8*)aSequence.getArray(), 0, sal_True);
211 pSequence = &aSequence;
214 return *pSequence;
220 sal_Int64 SAL_CALL Pane::getSomething (const Sequence<sal_Int8>& rId)
221 throw (RuntimeException)
223 sal_Int64 nResult = 0;
225 if (rId.getLength() == 16
226 && rtl_compareMemory(getUnoTunnelId().getConstArray(), rId.getConstArray(), 16) == 0)
228 nResult = reinterpret_cast<sal_Int64>(this);
231 return nResult;
237 //-----------------------------------------------------------------------------
239 Reference<rendering::XCanvas> Pane::CreateCanvas (void)
240 throw (RuntimeException)
242 Reference<rendering::XCanvas> xCanvas;
244 if (mpWindow != NULL)
246 ::cppcanvas::SpriteCanvasSharedPtr pCanvas (
247 ::cppcanvas::VCLFactory::getInstance().createSpriteCanvas(*mpWindow));
248 if (pCanvas.get() != NULL)
249 xCanvas = Reference<rendering::XCanvas>(pCanvas->getUNOSpriteCanvas(), UNO_QUERY);
252 return xCanvas;
258 void Pane::ThrowIfDisposed (void) const
259 throw (lang::DisposedException)
261 if (rBHelper.bDisposed || rBHelper.bInDispose)
263 throw lang::DisposedException (
264 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
265 "Pane object has already been disposed")),
266 const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
271 } } // end of namespace sd::framework