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/lang/XMultiComponentFactory.hpp>
25 using namespace ::com::sun::star
;
26 using namespace ::com::sun::star::uno
;
28 namespace sdext::presenter
{
30 //===== PresenterPane =========================================================
32 PresenterPane::PresenterPane (
33 const Reference
<XComponentContext
>& rxContext
,
34 const ::rtl::Reference
<PresenterController
>& rpPresenterController
)
35 : PresenterPaneBase(rxContext
, rpPresenterController
)
37 Reference
<lang::XMultiComponentFactory
> xFactory (
38 mxComponentContext
->getServiceManager(), UNO_SET_THROW
);
39 mxPresenterHelper
.set(
40 xFactory
->createInstanceWithContext(
41 u
"com.sun.star.comp.Draw.PresenterHelper"_ustr
,
46 PresenterPane::~PresenterPane()
50 //----- XPane -----------------------------------------------------------------
52 Reference
<awt::XWindow
> SAL_CALL
PresenterPane::getWindow()
55 return mxContentWindow
;
58 Reference
<rendering::XCanvas
> SAL_CALL
PresenterPane::getCanvas()
61 return mxContentCanvas
;
64 //----- XWindowListener -------------------------------------------------------
66 void SAL_CALL
PresenterPane::windowResized (const awt::WindowEvent
& rEvent
)
68 PresenterPaneBase::windowResized(rEvent
);
70 Invalidate(maBoundingBox
);
72 LayoutContextWindow();
76 Invalidate(maBoundingBox
);
79 void SAL_CALL
PresenterPane::windowMoved (const awt::WindowEvent
& rEvent
)
81 PresenterPaneBase::windowMoved(rEvent
);
83 Invalidate(maBoundingBox
);
88 Invalidate(maBoundingBox
);
91 void SAL_CALL
PresenterPane::windowShown (const lang::EventObject
& rEvent
)
93 PresenterPaneBase::windowShown(rEvent
);
97 if (mxContentWindow
.is())
99 LayoutContextWindow();
100 mxContentWindow
->setVisible(true);
104 Invalidate(maBoundingBox
);
107 void SAL_CALL
PresenterPane::windowHidden (const lang::EventObject
& rEvent
)
109 PresenterPaneBase::windowHidden(rEvent
);
111 if (mxContentWindow
.is())
112 mxContentWindow
->setVisible(false);
115 //----- XPaintListener --------------------------------------------------------
117 void SAL_CALL
PresenterPane::windowPaint (const awt::PaintEvent
& rEvent
)
121 PaintBorder(rEvent
.UpdateRect
);
125 void PresenterPane::CreateCanvases (
126 const Reference
<rendering::XSpriteCanvas
>& rxParentCanvas
)
128 if ( ! mxPresenterHelper
.is())
130 if ( ! mxParentWindow
.is())
132 if ( ! rxParentCanvas
.is())
135 mxBorderCanvas
= mxPresenterHelper
->createSharedCanvas(
141 mxContentCanvas
= mxPresenterHelper
->createSharedCanvas(
148 PaintBorder(mxBorderWindow
->getPosSize());
151 void PresenterPane::Invalidate (const css::awt::Rectangle
& rRepaintBox
)
153 // Invalidate the parent window to be able to invalidate an area outside
154 // the current window area.
155 mpPresenterController
->GetPaintManager()->Invalidate(mxParentWindow
, rRepaintBox
);
158 void PresenterPane::UpdateBoundingBox()
160 if (mxBorderWindow
.is() && IsVisible())
161 maBoundingBox
= mxBorderWindow
->getPosSize();
163 maBoundingBox
= awt::Rectangle();
166 } // end of namespace ::sdext::presenter
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */