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 "PresenterPane.hxx"
21 #include "PresenterController.hxx"
22 #include "PresenterPaintManager.hxx"
23 #include <com/sun/star/awt/XWindowPeer.hpp>
24 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
25 #include <com/sun/star/drawing/CanvasFeature.hpp>
26 #include <com/sun/star/rendering/CompositeOperation.hpp>
28 using namespace ::com::sun::star
;
29 using namespace ::com::sun::star::uno
;
30 using namespace ::com::sun::star::drawing::framework
;
32 namespace sdext
{ namespace presenter
{
34 //===== PresenterPane =========================================================
36 PresenterPane::PresenterPane (
37 const Reference
<XComponentContext
>& rxContext
,
38 const ::rtl::Reference
<PresenterController
>& rpPresenterController
)
39 : PresenterPaneBase(rxContext
, rpPresenterController
),
42 Reference
<lang::XMultiComponentFactory
> xFactory (
43 mxComponentContext
->getServiceManager(), UNO_QUERY_THROW
);
44 mxPresenterHelper
.set(
45 xFactory
->createInstanceWithContext(
46 "com.sun.star.comp.Draw.PresenterHelper",
51 PresenterPane::~PresenterPane()
55 //----- XPane -----------------------------------------------------------------
57 Reference
<awt::XWindow
> SAL_CALL
PresenterPane::getWindow()
60 return mxContentWindow
;
63 Reference
<rendering::XCanvas
> SAL_CALL
PresenterPane::getCanvas()
66 return mxContentCanvas
;
69 //----- XWindowListener -------------------------------------------------------
71 void SAL_CALL
PresenterPane::windowResized (const awt::WindowEvent
& rEvent
)
73 PresenterPaneBase::windowResized(rEvent
);
75 Invalidate(maBoundingBox
);
77 LayoutContextWindow();
81 Invalidate(maBoundingBox
);
84 void SAL_CALL
PresenterPane::windowMoved (const awt::WindowEvent
& rEvent
)
86 PresenterPaneBase::windowMoved(rEvent
);
88 Invalidate(maBoundingBox
);
93 Invalidate(maBoundingBox
);
96 void SAL_CALL
PresenterPane::windowShown (const lang::EventObject
& rEvent
)
98 PresenterPaneBase::windowShown(rEvent
);
102 if (mxContentWindow
.is())
104 LayoutContextWindow();
105 mxContentWindow
->setVisible(true);
109 Invalidate(maBoundingBox
);
112 void SAL_CALL
PresenterPane::windowHidden (const lang::EventObject
& rEvent
)
114 PresenterPaneBase::windowHidden(rEvent
);
116 if (mxContentWindow
.is())
117 mxContentWindow
->setVisible(false);
120 //----- XPaintListener --------------------------------------------------------
122 void SAL_CALL
PresenterPane::windowPaint (const awt::PaintEvent
& rEvent
)
126 PaintBorder(rEvent
.UpdateRect
);
130 void PresenterPane::CreateCanvases (
131 const Reference
<rendering::XSpriteCanvas
>& rxParentCanvas
)
133 if ( ! mxPresenterHelper
.is())
135 if ( ! mxParentWindow
.is())
137 if ( ! rxParentCanvas
.is())
140 mxBorderCanvas
= mxPresenterHelper
->createSharedCanvas(
143 Reference
<rendering::XCanvas
>(rxParentCanvas
, UNO_QUERY
),
146 mxContentCanvas
= mxPresenterHelper
->createSharedCanvas(
149 Reference
<rendering::XCanvas
>(rxParentCanvas
, UNO_QUERY
),
153 PaintBorder(mxBorderWindow
->getPosSize());
156 void PresenterPane::Invalidate (const css::awt::Rectangle
& rRepaintBox
)
158 // Invalidate the parent window to be able to invalidate an area outside
159 // the current window area.
160 mpPresenterController
->GetPaintManager()->Invalidate(mxParentWindow
, rRepaintBox
);
163 void PresenterPane::UpdateBoundingBox()
165 if (mxBorderWindow
.is() && IsVisible())
166 maBoundingBox
= mxBorderWindow
->getPosSize();
168 maBoundingBox
= awt::Rectangle();
171 } } // end of namespace ::sd::presenter
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */