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 "PresenterPaneBase.hxx"
21 #include "PresenterController.hxx"
22 #include "PresenterPaintManager.hxx"
23 #include <com/sun/star/awt/PosSize.hpp>
24 #include <com/sun/star/awt/XWindow2.hpp>
27 using namespace css::uno
;
28 using namespace css::drawing::framework
;
30 namespace sdext
{ namespace presenter
{
32 //===== PresenterPaneBase =====================================================
34 PresenterPaneBase::PresenterPaneBase (
35 const Reference
<XComponentContext
>& rxContext
,
36 const ::rtl::Reference
<PresenterController
>& rpPresenterController
)
37 : PresenterPaneBaseInterfaceBase(m_aMutex
),
38 mpPresenterController(rpPresenterController
),
48 mxComponentContext(rxContext
)
50 if (mpPresenterController
.get() != nullptr)
51 mxPresenterHelper
= mpPresenterController
->GetPresenterHelper();
54 PresenterPaneBase::~PresenterPaneBase()
58 void PresenterPaneBase::disposing()
60 if (mxBorderWindow
.is())
62 mxBorderWindow
->removeWindowListener(this);
63 mxBorderWindow
->removePaintListener(this);
67 Reference
<XComponent
> xComponent (mxContentCanvas
, UNO_QUERY
);
68 mxContentCanvas
= nullptr;
70 xComponent
->dispose();
74 Reference
<XComponent
> xComponent
= mxContentWindow
;
75 mxContentWindow
= nullptr;
77 xComponent
->dispose();
81 Reference
<XComponent
> xComponent (mxBorderCanvas
, UNO_QUERY
);
82 mxBorderCanvas
= nullptr;
84 xComponent
->dispose();
88 Reference
<XComponent
> xComponent
= mxBorderWindow
;
89 mxBorderWindow
= nullptr;
91 xComponent
->dispose();
94 mxComponentContext
= nullptr;
97 void PresenterPaneBase::SetTitle (const OUString
& rsTitle
)
101 OSL_ASSERT(mpPresenterController
.get()!=nullptr);
102 OSL_ASSERT(mpPresenterController
->GetPaintManager() != nullptr);
104 mpPresenterController
->GetPaintManager()->Invalidate(mxBorderWindow
);
107 const OUString
& PresenterPaneBase::GetTitle() const
112 const Reference
<drawing::framework::XPaneBorderPainter
>&
113 PresenterPaneBase::GetPaneBorderPainter() const
115 return mxBorderPainter
;
118 //----- XInitialization -------------------------------------------------------
120 void SAL_CALL
PresenterPaneBase::initialize (const Sequence
<Any
>& rArguments
)
124 if ( ! mxComponentContext
.is())
126 throw RuntimeException(
127 "PresenterSpritePane: missing component context",
128 static_cast<XWeak
*>(this));
131 if (rArguments
.getLength() != 5 && rArguments
.getLength() != 6)
133 throw RuntimeException(
134 "PresenterSpritePane: invalid number of arguments",
135 static_cast<XWeak
*>(this));
140 // Get the resource id from the first argument.
141 if ( ! (rArguments
[0] >>= mxPaneId
))
143 throw lang::IllegalArgumentException(
144 "PresenterPane: invalid pane id",
145 static_cast<XWeak
*>(this),
149 if ( ! (rArguments
[1] >>= mxParentWindow
))
151 throw lang::IllegalArgumentException(
152 "PresenterPane: invalid parent window",
153 static_cast<XWeak
*>(this),
157 Reference
<rendering::XSpriteCanvas
> xParentCanvas
;
158 if ( ! (rArguments
[2] >>= xParentCanvas
))
160 throw lang::IllegalArgumentException(
161 "PresenterPane: invalid parent canvas",
162 static_cast<XWeak
*>(this),
166 if ( ! (rArguments
[3] >>= msTitle
))
168 throw lang::IllegalArgumentException(
169 "PresenterPane: invalid title",
170 static_cast<XWeak
*>(this),
174 if ( ! (rArguments
[4] >>= mxBorderPainter
))
176 throw lang::IllegalArgumentException(
177 "PresenterPane: invalid border painter",
178 static_cast<XWeak
*>(this),
182 bool bIsWindowVisibleOnCreation (true);
183 if (rArguments
.getLength()>5 && ! (rArguments
[5] >>= bIsWindowVisibleOnCreation
))
185 throw lang::IllegalArgumentException(
186 "PresenterPane: invalid window visibility flag",
187 static_cast<XWeak
*>(this),
191 CreateWindows(bIsWindowVisibleOnCreation
);
193 if (mxBorderWindow
.is())
195 mxBorderWindow
->addWindowListener(this);
196 mxBorderWindow
->addPaintListener(this);
199 CreateCanvases(xParentCanvas
);
201 // Raise new windows.
206 mxContentWindow
= nullptr;
207 mxComponentContext
= nullptr;
212 //----- XResourceId -----------------------------------------------------------
214 Reference
<XResourceId
> SAL_CALL
PresenterPaneBase::getResourceId()
220 sal_Bool SAL_CALL
PresenterPaneBase::isAnchorOnly()
225 //----- XWindowListener -------------------------------------------------------
227 void SAL_CALL
PresenterPaneBase::windowResized (const awt::WindowEvent
&)
232 void SAL_CALL
PresenterPaneBase::windowMoved (const awt::WindowEvent
&)
237 void SAL_CALL
PresenterPaneBase::windowShown (const lang::EventObject
&)
242 void SAL_CALL
PresenterPaneBase::windowHidden (const lang::EventObject
&)
247 //----- lang::XEventListener --------------------------------------------------
249 void SAL_CALL
PresenterPaneBase::disposing (const lang::EventObject
& rEvent
)
251 if (rEvent
.Source
== mxBorderWindow
)
253 mxBorderWindow
= nullptr;
258 void PresenterPaneBase::CreateWindows (
259 const bool bIsWindowVisibleOnCreation
)
261 if (!(mxPresenterHelper
.is() && mxParentWindow
.is()))
264 mxBorderWindow
= mxPresenterHelper
->createWindow(
267 bIsWindowVisibleOnCreation
,
270 mxContentWindow
= mxPresenterHelper
->createWindow(
273 bIsWindowVisibleOnCreation
,
278 const Reference
<awt::XWindow
>& PresenterPaneBase::GetBorderWindow() const
280 return mxBorderWindow
;
283 void PresenterPaneBase::ToTop()
285 if (mxPresenterHelper
.is())
286 mxPresenterHelper
->toTop(mxContentWindow
);
289 void PresenterPaneBase::PaintBorder (const awt::Rectangle
& rUpdateBox
)
291 OSL_ASSERT(mxPaneId
.is());
293 if (!(mxBorderPainter
.is() && mxBorderWindow
.is() && mxBorderCanvas
.is()))
296 awt::Rectangle
aBorderBox (mxBorderWindow
->getPosSize());
297 awt::Rectangle
aLocalBorderBox (0,0, aBorderBox
.Width
, aBorderBox
.Height
);
299 //TODO: paint border background?
301 mxBorderPainter
->paintBorder(
302 mxPaneId
->getResourceURL(),
309 void PresenterPaneBase::LayoutContextWindow()
311 OSL_ASSERT(mxPaneId
.is());
312 OSL_ASSERT(mxBorderWindow
.is());
313 OSL_ASSERT(mxContentWindow
.is());
314 if (!(mxBorderPainter
.is() && mxPaneId
.is() && mxBorderWindow
.is() && mxContentWindow
.is()))
317 const awt::Rectangle
aBorderBox (mxBorderWindow
->getPosSize());
318 const awt::Rectangle
aInnerBox (mxBorderPainter
->removeBorder(
319 mxPaneId
->getResourceURL(),
321 drawing::framework::BorderType_TOTAL_BORDER
));
322 mxContentWindow
->setPosSize(
323 aInnerBox
.X
- aBorderBox
.X
,
324 aInnerBox
.Y
- aBorderBox
.Y
,
327 awt::PosSize::POSSIZE
);
330 bool PresenterPaneBase::IsVisible() const
332 Reference
<awt::XWindow2
> xWindow2 (mxBorderPainter
, UNO_QUERY
);
334 return xWindow2
->isVisible();
339 void PresenterPaneBase::ThrowIfDisposed()
341 if (rBHelper
.bDisposed
|| rBHelper
.bInDispose
)
343 throw lang::DisposedException (
344 "PresenterPane object has already been disposed",
345 static_cast<uno::XWeak
*>(this));
349 } } // end of namespace ::sd::presenter
351 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */