LibreOffice Module sd (master) 1
Pane.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <framework/Pane.hxx>
21
22#include <osl/mutex.hxx>
24#include <vcl/window.hxx>
26#include <com/sun/star/rendering/XSpriteCanvas.hpp>
28
29using namespace ::com::sun::star;
30using namespace ::com::sun::star::uno;
32
33namespace sd::framework {
34
36 const Reference<XResourceId>& rxPaneId,
37 vcl::Window* pWindow)
38 noexcept
39 : PaneInterfaceBase(m_aMutex),
40 mxPaneId(rxPaneId),
41 mpWindow(pWindow),
42 mxWindow(VCLUnoHelper::GetInterface(pWindow))
43{
44}
45
47{
48}
49
51{
52 mxWindow = nullptr;
53 mpWindow = nullptr;
54}
55
57{
58 if (mxWindow.is())
59 return mpWindow;
60 else
61 return nullptr;
62}
63
64//----- XPane -----------------------------------------------------------------
65
66Reference<awt::XWindow> SAL_CALL Pane::getWindow()
67{
69
70 return mxWindow;
71}
72
73Reference<rendering::XCanvas> SAL_CALL Pane::getCanvas()
74{
75 ::osl::MutexGuard aGuard (m_aMutex);
77
78 if ( ! mxCanvas.is())
80
81 return mxCanvas;
82}
83
84//----- XPane2 ----------------------------------------------------------------
85
87{
89
90 const vcl::Window* pWindow = GetWindow();
91 if (pWindow != nullptr)
92 return pWindow->IsVisible();
93 else
94 return false;
95}
96
97void SAL_CALL Pane::setVisible (sal_Bool bIsVisible)
98{
100
101 vcl::Window* pWindow = GetWindow();
102 if (pWindow != nullptr)
103 pWindow->Show(bIsVisible);
104}
105
106Reference<css::accessibility::XAccessible> SAL_CALL Pane::getAccessible()
107{
109 vcl::Window* pWindow = GetWindow();
110 if (pWindow != nullptr)
111 return pWindow->GetAccessible(false);
112 else
113 return nullptr;
114}
115
116void SAL_CALL Pane::setAccessible (
117 const Reference<css::accessibility::XAccessible>& rxAccessible)
118{
120 vcl::Window* pWindow = GetWindow();
121 if (pWindow != nullptr)
122 pWindow->SetAccessible(rxAccessible);
123}
124
125//----- XResource -------------------------------------------------------------
126
127Reference<XResourceId> SAL_CALL Pane::getResourceId()
128{
130
131 return mxPaneId;
132}
133
135{
136 return true;
137}
138
139Reference<rendering::XCanvas> Pane::CreateCanvas()
140{
141 Reference<rendering::XCanvas> xCanvas;
142
143 if (mpWindow != nullptr)
144 {
147 if (pCanvas)
148 xCanvas.set(pCanvas->getUNOSpriteCanvas());
149 }
150
151 return xCanvas;
152}
153
155{
156 if (rBHelper.bDisposed || rBHelper.bInDispose)
157 {
158 throw lang::DisposedException ("Pane object has already been disposed",
159 const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
160 }
161}
162
163} // end of namespace sd::framework
164
165/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static css::uno::Reference< css::awt::XWindow > GetInterface(vcl::Window *pWindow)
static SpriteCanvasSharedPtr createSpriteCanvas(const vcl::Window &rVCLWindow)
mutable::osl::Mutex m_aMutex
VclPtr< vcl::Window > mpWindow
Definition: Pane.hxx:110
Pane(const css::uno::Reference< css::drawing::framework::XResourceId > &rxPaneId, vcl::Window *pWindow) noexcept
Create a new Pane object that wraps the given window.
Definition: Pane.cxx:35
virtual css::uno::Reference< css::drawing::framework::XResourceId > SAL_CALL getResourceId() override
Definition: Pane.cxx:127
css::uno::Reference< css::rendering::XCanvas > mxCanvas
Definition: Pane.hxx:112
virtual ~Pane() override
Definition: Pane.cxx:46
virtual void SAL_CALL setAccessible(const css::uno::Reference< css::accessibility::XAccessible > &rxAccessible) override
Definition: Pane.cxx:116
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessible() override
Definition: Pane.cxx:106
virtual void SAL_CALL disposing() override
Definition: Pane.cxx:50
virtual css::uno::Reference< css::awt::XWindow > SAL_CALL getWindow() override
For a UNO API based implementation of a view this may the most important method of this class because...
Definition: Pane.cxx:66
virtual css::uno::Reference< css::rendering::XCanvas > CreateCanvas()
Override this method, not getCanvas(), when you want to provide a different canvas.
Definition: Pane.cxx:139
virtual sal_Bool SAL_CALL isAnchorOnly() override
For the typical pane it makes no sense to be displayed without a view.
Definition: Pane.cxx:134
css::uno::Reference< css::awt::XWindow > mxWindow
Definition: Pane.hxx:111
virtual vcl::Window * GetWindow()
This method is typically used to obtain a Window pointer from an XPane object.
Definition: Pane.cxx:56
virtual void SAL_CALL setVisible(sal_Bool bIsVisible) override
Definition: Pane.cxx:97
virtual css::uno::Reference< css::rendering::XCanvas > SAL_CALL getCanvas() override
Definition: Pane.cxx:73
void ThrowIfDisposed() const
Throw DisposedException when the object has already been disposed or is currently being disposed.
Definition: Pane.cxx:154
virtual sal_Bool SAL_CALL isVisible() override
Definition: Pane.cxx:86
css::uno::Reference< css::drawing::framework::XResourceId > mxPaneId
Definition: Pane.hxx:109
void SetAccessible(const css::uno::Reference< css::accessibility::XAccessible > &)
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
css::uno::Reference< css::accessibility::XAccessible > GetAccessible(bool bCreate=true)
bool IsVisible() const
std::shared_ptr< ::cppcanvas::SpriteCanvas > SpriteCanvasSharedPtr
::cppu::WeakComponentImplHelper< css::drawing::framework::XPane, css::drawing::framework::XPane2 > PaneInterfaceBase
Definition: Pane.hxx:34
unsigned char sal_Bool
VclPtr< vcl::Window > mpWindow