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 "PresenterSpritePane.hxx"
21 #include "PresenterGeometryHelper.hxx"
22 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
23 #include <com/sun/star/rendering/CompositeOperation.hpp>
25 using namespace ::com::sun::star
;
26 using namespace ::com::sun::star::uno
;
27 using namespace ::com::sun::star::drawing::framework
;
29 namespace sdext
{ namespace presenter
{
31 //===== PresenterSpritePane =========================================================
33 PresenterSpritePane::PresenterSpritePane (const Reference
<XComponentContext
>& rxContext
,
34 const ::rtl::Reference
<PresenterController
>& rpPresenterController
)
35 : PresenterPaneBase(rxContext
, rpPresenterController
),
37 mpSprite(new PresenterSprite())
39 Reference
<lang::XMultiComponentFactory
> xFactory (
40 mxComponentContext
->getServiceManager(), UNO_QUERY_THROW
);
41 mxPresenterHelper
.set(
42 xFactory
->createInstanceWithContext(
43 "com.sun.star.comp.Draw.PresenterHelper",
48 PresenterSpritePane::~PresenterSpritePane()
52 void PresenterSpritePane::disposing()
54 mpSprite
->SetFactory(nullptr);
55 mxParentCanvas
= nullptr;
56 PresenterPaneBase::disposing();
59 //----- XPane -----------------------------------------------------------------
61 Reference
<awt::XWindow
> SAL_CALL
PresenterSpritePane::getWindow()
64 return mxContentWindow
;
67 Reference
<rendering::XCanvas
> SAL_CALL
PresenterSpritePane::getCanvas()
71 if ( ! mxContentCanvas
.is())
74 return mxContentCanvas
;
77 //----- XWindowListener -------------------------------------------------------
79 void SAL_CALL
PresenterSpritePane::windowResized (const awt::WindowEvent
& rEvent
)
81 PresenterPaneBase::windowResized(rEvent
);
83 mpSprite
->Resize(geometry::RealSize2D(rEvent
.Width
, rEvent
.Height
));
84 LayoutContextWindow();
88 void SAL_CALL
PresenterSpritePane::windowMoved (const awt::WindowEvent
& rEvent
)
90 PresenterPaneBase::windowMoved(rEvent
);
93 mxPresenterHelper
->getWindowExtentsRelative(mxBorderWindow
, mxParentWindow
));
94 mpSprite
->MoveTo(geometry::RealPoint2D(aBox
.X
, aBox
.Y
));
98 void SAL_CALL
PresenterSpritePane::windowShown (const lang::EventObject
& rEvent
)
100 PresenterPaneBase::windowShown(rEvent
);
105 if (mxContentWindow
.is())
107 LayoutContextWindow();
108 mxContentWindow
->setVisible(true);
112 void SAL_CALL
PresenterSpritePane::windowHidden (const lang::EventObject
& rEvent
)
114 PresenterPaneBase::windowHidden(rEvent
);
117 if (mxContentWindow
.is())
118 mxContentWindow
->setVisible(false);
121 //----- XPaintListener --------------------------------------------------------
123 void SAL_CALL
PresenterSpritePane::windowPaint (const awt::PaintEvent
&)
128 Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxParentCanvas, UNO_QUERY);
129 if (xSpriteCanvas.is())
130 xSpriteCanvas->updateScreen(sal_False);
135 const std::shared_ptr
<PresenterSprite
>& PresenterSpritePane::GetSprite()
140 void PresenterSpritePane::UpdateCanvases()
142 Reference
<XComponent
> xContentCanvasComponent (mxContentCanvas
, UNO_QUERY
);
143 if (xContentCanvasComponent
.is())
145 if (xContentCanvasComponent
.is())
146 xContentCanvasComponent
->dispose();
149 // The border canvas is the content canvas of the sprite.
150 mxBorderCanvas
= mpSprite
->GetCanvas();
152 // The content canvas is a wrapper of the border canvas.
153 if (mxBorderCanvas
.is())
154 mxContentCanvas
= mxPresenterHelper
->createSharedCanvas(
161 const awt::Rectangle
aWindowBox (mxBorderWindow
->getPosSize());
162 PaintBorder(awt::Rectangle(0,0,aWindowBox
.Width
,aWindowBox
.Height
));
165 void PresenterSpritePane::CreateCanvases (
166 const css::uno::Reference
<css::rendering::XSpriteCanvas
>& rxParentCanvas
)
168 OSL_ASSERT(!mxParentCanvas
.is() || mxParentCanvas
==rxParentCanvas
);
169 mxParentCanvas
= rxParentCanvas
;
171 mpSprite
->SetFactory(mxParentCanvas
);
172 if (mxBorderWindow
.is())
174 const awt::Rectangle
aBorderBox (mxBorderWindow
->getPosSize());
175 mpSprite
->Resize(geometry::RealSize2D(aBorderBox
.Width
, aBorderBox
.Height
));
181 } } // end of namespace ::sd::presenter
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */