1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "framework/Pane.hxx"
22 #include <vcl/svapp.hxx>
23 #include <osl/mutex.hxx>
24 #include <toolkit/helper/vclunohelper.hxx>
25 #include <vcl/window.hxx>
26 #include <cppcanvas/vclfactory.hxx>
27 #include <comphelper/servicehelper.hxx>
29 using namespace ::com::sun::star
;
30 using namespace ::com::sun::star::uno
;
31 using namespace ::com::sun::star::drawing::framework
;
33 namespace sd
{ namespace framework
{
36 const Reference
<XResourceId
>& rxPaneId
,
39 : PaneInterfaceBase(MutexOwner::maMutex
),
42 mxWindow(VCLUnoHelper::GetInterface(pWindow
))
50 void Pane::disposing()
56 vcl::Window
* Pane::GetWindow()
64 //----- XPane -----------------------------------------------------------------
66 Reference
<awt::XWindow
> SAL_CALL
Pane::getWindow()
67 throw (RuntimeException
, std::exception
)
74 Reference
<rendering::XCanvas
> SAL_CALL
Pane::getCanvas()
75 throw (RuntimeException
, std::exception
)
77 ::osl::MutexGuard
aGuard (maMutex
);
81 mxCanvas
= CreateCanvas();
86 //----- XPane2 ----------------------------------------------------------------
88 sal_Bool SAL_CALL
Pane::isVisible()
89 throw (RuntimeException
, std::exception
)
93 const vcl::Window
* pWindow
= GetWindow();
95 return pWindow
->IsVisible();
100 void SAL_CALL
Pane::setVisible (sal_Bool bIsVisible
)
101 throw (RuntimeException
, std::exception
)
105 vcl::Window
* pWindow
= GetWindow();
107 pWindow
->Show(bIsVisible
);
110 Reference
<css::accessibility::XAccessible
> SAL_CALL
Pane::getAccessible()
111 throw (RuntimeException
, std::exception
)
114 vcl::Window
* pWindow
= GetWindow();
116 return pWindow
->GetAccessible(false);
121 void SAL_CALL
Pane::setAccessible (
122 const Reference
<css::accessibility::XAccessible
>& rxAccessible
)
123 throw (RuntimeException
, std::exception
)
126 vcl::Window
* pWindow
= GetWindow();
128 pWindow
->SetAccessible(rxAccessible
);
131 //----- XResource -------------------------------------------------------------
133 Reference
<XResourceId
> SAL_CALL
Pane::getResourceId()
134 throw (RuntimeException
, std::exception
)
141 sal_Bool SAL_CALL
Pane::isAnchorOnly()
142 throw (RuntimeException
, std::exception
)
147 //----- XUnoTunnel ------------------------------------------------------------
151 class thePaneUnoTunnelId
: public rtl::Static
< UnoTunnelIdInit
, thePaneUnoTunnelId
> {};
154 const Sequence
<sal_Int8
>& Pane::getUnoTunnelId()
156 return thePaneUnoTunnelId::get().getSeq();
159 sal_Int64 SAL_CALL
Pane::getSomething (const Sequence
<sal_Int8
>& rId
)
160 throw (RuntimeException
, std::exception
)
162 sal_Int64 nResult
= 0;
164 if (rId
.getLength() == 16
165 && memcmp(getUnoTunnelId().getConstArray(), rId
.getConstArray(), 16) == 0)
167 nResult
= reinterpret_cast<sal_Int64
>(this);
173 Reference
<rendering::XCanvas
> Pane::CreateCanvas()
174 throw (RuntimeException
)
176 Reference
<rendering::XCanvas
> xCanvas
;
178 if (mpWindow
!= nullptr)
180 ::cppcanvas::SpriteCanvasSharedPtr
pCanvas (
181 cppcanvas::VCLFactory::createSpriteCanvas(*mpWindow
));
182 if (pCanvas
.get() != NULL
)
183 xCanvas
= Reference
<rendering::XCanvas
>(pCanvas
->getUNOSpriteCanvas(), UNO_QUERY
);
189 void Pane::ThrowIfDisposed() const
190 throw (lang::DisposedException
)
192 if (rBHelper
.bDisposed
|| rBHelper
.bInDispose
)
194 throw lang::DisposedException ("Pane object has already been disposed",
195 const_cast<uno::XWeak
*>(static_cast<const uno::XWeak
*>(this)));
199 } } // end of namespace sd::framework
201 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */