update dev300-m58
[ooovba.git] / sd / source / ui / framework / factories / Pane.cxx
blob1b0388710727f2ad4efa6d5800860faa527b72ad
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 //----- XResource -------------------------------------------------------------
122 Reference<XResourceId> SAL_CALL Pane::getResourceId (void)
123 throw (RuntimeException)
125 ThrowIfDisposed();
127 return mxPaneId;
133 sal_Bool SAL_CALL Pane::isAnchorOnly (void)
134 throw (RuntimeException)
136 return true;
142 //----- XUnoTunnel ------------------------------------------------------------
144 const Sequence<sal_Int8>& Pane::getUnoTunnelId (void)
146 static Sequence<sal_Int8>* pSequence = NULL;
147 if (pSequence == NULL)
149 const ::vos::OGuard aSolarGuard (Application::GetSolarMutex());
150 if (pSequence == NULL)
152 static ::com::sun::star::uno::Sequence<sal_Int8> aSequence (16);
153 rtl_createUuid((sal_uInt8*)aSequence.getArray(), 0, sal_True);
154 pSequence = &aSequence;
157 return *pSequence;
163 sal_Int64 SAL_CALL Pane::getSomething (const Sequence<sal_Int8>& rId)
164 throw (RuntimeException)
166 sal_Int64 nResult = 0;
168 if (rId.getLength() == 16
169 && rtl_compareMemory(getUnoTunnelId().getConstArray(), rId.getConstArray(), 16) == 0)
171 nResult = reinterpret_cast<sal_Int64>(this);
174 return nResult;
180 //-----------------------------------------------------------------------------
182 Reference<rendering::XCanvas> Pane::CreateCanvas (void)
183 throw (RuntimeException)
185 Reference<rendering::XCanvas> xCanvas;
187 if (mpWindow != NULL)
189 ::cppcanvas::SpriteCanvasSharedPtr pCanvas (
190 ::cppcanvas::VCLFactory::getInstance().createSpriteCanvas(*mpWindow));
191 if (pCanvas.get() != NULL)
192 xCanvas = Reference<rendering::XCanvas>(pCanvas->getUNOSpriteCanvas(), UNO_QUERY);
195 return xCanvas;
201 void Pane::ThrowIfDisposed (void) const
202 throw (lang::DisposedException)
204 if (rBHelper.bDisposed || rBHelper.bInDispose)
206 throw lang::DisposedException (
207 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
208 "Pane object has already been disposed")),
209 const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
214 } } // end of namespace sd::framework