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>
27 #include <osl/mutex.hxx>
29 using namespace ::com::sun::star
;
30 using namespace ::com::sun::star::uno
;
31 using namespace ::com::sun::star::drawing::framework
;
33 namespace sdext
{ namespace presenter
{
35 //===== PresenterPane =========================================================
37 PresenterPane::PresenterPane (
38 const Reference
<XComponentContext
>& rxContext
,
39 const ::rtl::Reference
<PresenterController
>& rpPresenterController
)
40 : PresenterPaneBase(rxContext
, rpPresenterController
),
43 Reference
<lang::XMultiComponentFactory
> xFactory (
44 mxComponentContext
->getServiceManager(), UNO_QUERY_THROW
);
45 mxPresenterHelper
= Reference
<drawing::XPresenterHelper
>(
46 xFactory
->createInstanceWithContext(
47 OUString("com.sun.star.comp.Draw.PresenterHelper"),
52 PresenterPane::~PresenterPane()
56 //----- XPane -----------------------------------------------------------------
58 Reference
<awt::XWindow
> SAL_CALL
PresenterPane::getWindow()
59 throw (RuntimeException
, std::exception
)
62 return mxContentWindow
;
65 Reference
<rendering::XCanvas
> SAL_CALL
PresenterPane::getCanvas()
66 throw (RuntimeException
, std::exception
)
69 return mxContentCanvas
;
72 //----- XWindowListener -------------------------------------------------------
74 void SAL_CALL
PresenterPane::windowResized (const awt::WindowEvent
& rEvent
)
75 throw (RuntimeException
, std::exception
)
78 PresenterPaneBase::windowResized(rEvent
);
80 Invalidate(maBoundingBox
);
82 LayoutContextWindow();
86 Invalidate(maBoundingBox
);
89 void SAL_CALL
PresenterPane::windowMoved (const awt::WindowEvent
& rEvent
)
90 throw (RuntimeException
, std::exception
)
93 PresenterPaneBase::windowMoved(rEvent
);
95 Invalidate(maBoundingBox
);
100 Invalidate(maBoundingBox
);
103 void SAL_CALL
PresenterPane::windowShown (const lang::EventObject
& rEvent
)
104 throw (RuntimeException
, std::exception
)
107 PresenterPaneBase::windowShown(rEvent
);
111 if (mxContentWindow
.is())
113 LayoutContextWindow();
114 mxContentWindow
->setVisible(sal_True
);
118 Invalidate(maBoundingBox
);
121 void SAL_CALL
PresenterPane::windowHidden (const lang::EventObject
& rEvent
)
122 throw (RuntimeException
, std::exception
)
125 PresenterPaneBase::windowHidden(rEvent
);
127 if (mxContentWindow
.is())
128 mxContentWindow
->setVisible(sal_False
);
131 //----- XPaintListener --------------------------------------------------------
133 void SAL_CALL
PresenterPane::windowPaint (const awt::PaintEvent
& rEvent
)
134 throw (RuntimeException
, std::exception
)
139 PaintBorder(rEvent
.UpdateRect
);
144 void PresenterPane::CreateCanvases (
145 const Reference
<awt::XWindow
>& rxParentWindow
,
146 const Reference
<rendering::XSpriteCanvas
>& rxParentCanvas
)
148 if ( ! mxPresenterHelper
.is())
150 if ( ! rxParentWindow
.is())
152 if ( ! rxParentCanvas
.is())
155 mxBorderCanvas
= mxPresenterHelper
->createSharedCanvas(
158 Reference
<rendering::XCanvas
>(rxParentCanvas
, UNO_QUERY
),
161 mxContentCanvas
= mxPresenterHelper
->createSharedCanvas(
164 Reference
<rendering::XCanvas
>(rxParentCanvas
, UNO_QUERY
),
168 PaintBorder(mxBorderWindow
->getPosSize());
171 void PresenterPane::Invalidate (const css::awt::Rectangle
& rRepaintBox
)
173 // Invalidate the parent window to be able to invalidate an area outside
174 // the current window area.
175 mpPresenterController
->GetPaintManager()->Invalidate(mxParentWindow
, rRepaintBox
);
178 void PresenterPane::UpdateBoundingBox()
180 if (mxBorderWindow
.is() && IsVisible())
181 maBoundingBox
= mxBorderWindow
->getPosSize();
183 maBoundingBox
= awt::Rectangle();
186 } } // end of namespace ::sd::presenter
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */