1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Pane.cxx,v $
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"
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
{
52 const Reference
<XResourceId
>& rxPaneId
,
55 : PaneInterfaceBase(MutexOwner::maMutex
),
58 mxWindow(VCLUnoHelper::GetInterface(pWindow
))
65 Pane::~Pane (void) throw()
72 void Pane::disposing (void)
81 ::Window
* Pane::GetWindow (void)
92 //----- XPane -----------------------------------------------------------------
94 Reference
<awt::XWindow
> SAL_CALL
Pane::getWindow (void)
95 throw (RuntimeException
)
105 Reference
<rendering::XCanvas
> SAL_CALL
Pane::getCanvas (void)
106 throw (RuntimeException
)
108 ::osl::MutexGuard
aGuard (maMutex
);
111 if ( ! mxCanvas
.is())
112 mxCanvas
= CreateCanvas();
120 //----- XPane2 ----------------------------------------------------------------
122 sal_Bool SAL_CALL
Pane::isVisible (void)
123 throw (RuntimeException
)
127 const ::Window
* pWindow
= GetWindow();
129 return pWindow
->IsVisible();
137 void SAL_CALL
Pane::setVisible (sal_Bool bIsVisible
)
138 throw (RuntimeException
)
142 ::Window
* pWindow
= GetWindow();
144 pWindow
->Show(bIsVisible
);
150 Reference
<accessibility::XAccessible
> SAL_CALL
Pane::getAccessible (void)
151 throw (RuntimeException
)
154 ::Window
* pWindow
= GetWindow();
156 return pWindow
->GetAccessible(FALSE
);
164 void SAL_CALL
Pane::setAccessible (
165 const Reference
<accessibility::XAccessible
>& rxAccessible
)
166 throw (RuntimeException
)
169 ::Window
* pWindow
= GetWindow();
171 pWindow
->SetAccessible(rxAccessible
);
177 //----- XResource -------------------------------------------------------------
179 Reference
<XResourceId
> SAL_CALL
Pane::getResourceId (void)
180 throw (RuntimeException
)
190 sal_Bool SAL_CALL
Pane::isAnchorOnly (void)
191 throw (RuntimeException
)
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
;
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);
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
);
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