Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "PresenterSpritePane.hxx"
30 : : #include "PresenterGeometryHelper.hxx"
31 : : #include <com/sun/star/lang/XMultiComponentFactory.hpp>
32 : : #include <com/sun/star/rendering/CompositeOperation.hpp>
33 : : #include <osl/mutex.hxx>
34 : :
35 : : using namespace ::com::sun::star;
36 : : using namespace ::com::sun::star::uno;
37 : : using namespace ::com::sun::star::drawing::framework;
38 : : using ::rtl::OUString;
39 : :
40 : : namespace sdext { namespace presenter {
41 : :
42 : : //===== PresenterSpritePane =========================================================
43 : :
44 : 0 : PresenterSpritePane::PresenterSpritePane (const Reference<XComponentContext>& rxContext,
45 : : const ::rtl::Reference<PresenterController>& rpPresenterController)
46 : : : PresenterPaneBase(rxContext, rpPresenterController),
47 : : mxParentWindow(),
48 : : mxParentCanvas(),
49 [ # # ][ # # ]: 0 : mpSprite(new PresenterSprite())
[ # # ]
50 : : {
51 : : Reference<lang::XMultiComponentFactory> xFactory (
52 [ # # ][ # # ]: 0 : mxComponentContext->getServiceManager(), UNO_QUERY_THROW);
[ # # ]
53 : : mxPresenterHelper = Reference<drawing::XPresenterHelper>(
54 [ # # ]: 0 : xFactory->createInstanceWithContext(
55 : : OUString("com.sun.star.comp.Draw.PresenterHelper"),
56 : 0 : mxComponentContext),
57 [ # # ][ # # ]: 0 : UNO_QUERY_THROW);
[ # # ]
58 : 0 : }
59 : :
60 [ # # ]: 0 : PresenterSpritePane::~PresenterSpritePane (void)
61 : : {
62 [ # # ]: 0 : }
63 : :
64 : 0 : void PresenterSpritePane::disposing (void)
65 : : {
66 [ # # ]: 0 : mpSprite->SetFactory(NULL);
67 : 0 : mxParentWindow = NULL;
68 : 0 : mxParentCanvas = NULL;
69 : 0 : PresenterPaneBase::disposing();
70 : 0 : }
71 : :
72 : : //----- XPane -----------------------------------------------------------------
73 : :
74 : 0 : Reference<awt::XWindow> SAL_CALL PresenterSpritePane::getWindow (void)
75 : : throw (RuntimeException)
76 : : {
77 : 0 : ThrowIfDisposed();
78 : 0 : return mxContentWindow;
79 : : }
80 : :
81 : 0 : Reference<rendering::XCanvas> SAL_CALL PresenterSpritePane::getCanvas (void)
82 : : throw (RuntimeException)
83 : : {
84 : 0 : ThrowIfDisposed();
85 : :
86 [ # # ]: 0 : if ( ! mxContentCanvas.is())
87 : 0 : UpdateCanvases();
88 : :
89 : 0 : return mxContentCanvas;
90 : : }
91 : :
92 : : //----- XWindowListener -------------------------------------------------------
93 : :
94 : 0 : void SAL_CALL PresenterSpritePane::windowResized (const awt::WindowEvent& rEvent)
95 : : throw (RuntimeException)
96 : : {
97 : : (void)rEvent;
98 : 0 : PresenterPaneBase::windowResized(rEvent);
99 : :
100 [ # # ]: 0 : mpSprite->Resize(geometry::RealSize2D(rEvent.Width, rEvent.Height));
101 : 0 : LayoutContextWindow();
102 : 0 : UpdateCanvases();
103 : 0 : }
104 : :
105 : 0 : void SAL_CALL PresenterSpritePane::windowMoved (const awt::WindowEvent& rEvent)
106 : : throw (RuntimeException)
107 : : {
108 : : (void)rEvent;
109 [ # # ]: 0 : PresenterPaneBase::windowMoved(rEvent);
110 : :
111 : : awt::Rectangle aBox (
112 [ # # ][ # # ]: 0 : mxPresenterHelper->getWindowExtentsRelative(mxBorderWindow, mxParentWindow));
113 [ # # ]: 0 : mpSprite->MoveTo(geometry::RealPoint2D(aBox.X, aBox.Y));
114 [ # # ]: 0 : mpSprite->Update();
115 : 0 : }
116 : :
117 : 0 : void SAL_CALL PresenterSpritePane::windowShown (const lang::EventObject& rEvent)
118 : : throw (RuntimeException)
119 : : {
120 : : (void)rEvent;
121 : 0 : PresenterPaneBase::windowShown(rEvent);
122 : :
123 : 0 : mpSprite->Show();
124 : 0 : ToTop();
125 : :
126 [ # # ]: 0 : if (mxContentWindow.is())
127 : : {
128 : 0 : LayoutContextWindow();
129 : 0 : mxContentWindow->setVisible(sal_True);
130 : : }
131 : 0 : }
132 : :
133 : 0 : void SAL_CALL PresenterSpritePane::windowHidden (const lang::EventObject& rEvent)
134 : : throw (RuntimeException)
135 : : {
136 : : (void)rEvent;
137 : 0 : PresenterPaneBase::windowHidden(rEvent);
138 : :
139 : 0 : mpSprite->Hide();
140 [ # # ]: 0 : if (mxContentWindow.is())
141 : 0 : mxContentWindow->setVisible(sal_False);
142 : 0 : }
143 : :
144 : : //----- XPaintListener --------------------------------------------------------
145 : :
146 : 0 : void SAL_CALL PresenterSpritePane::windowPaint (const awt::PaintEvent& rEvent)
147 : : throw (RuntimeException)
148 : : {
149 : : (void)rEvent;
150 : 0 : ThrowIfDisposed();
151 : :
152 : : /*
153 : : Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxParentCanvas, UNO_QUERY);
154 : : if (xSpriteCanvas.is())
155 : : xSpriteCanvas->updateScreen(sal_False);
156 : : */
157 : 0 : }
158 : :
159 : : //-----------------------------------------------------------------------------
160 : :
161 : 0 : ::boost::shared_ptr<PresenterSprite> PresenterSpritePane::GetSprite (void)
162 : : {
163 : 0 : return mpSprite;
164 : : }
165 : :
166 : 0 : void PresenterSpritePane::UpdateCanvases (void)
167 : : {
168 [ # # ]: 0 : Reference<XComponent> xContentCanvasComponent (mxContentCanvas, UNO_QUERY);
169 [ # # ]: 0 : if (xContentCanvasComponent.is())
170 : : {
171 [ # # ]: 0 : if (xContentCanvasComponent.is())
172 [ # # ][ # # ]: 0 : xContentCanvasComponent->dispose();
173 : : }
174 : :
175 : : // The border canvas is the content canvas of the sprite.
176 [ # # ][ # # ]: 0 : mxBorderCanvas = mpSprite->GetCanvas();
177 : :
178 : : // The content canvas is a wrapper of the border canvas.
179 [ # # ]: 0 : if (mxBorderCanvas.is())
180 [ # # ]: 0 : mxContentCanvas = mxPresenterHelper->createSharedCanvas(
181 : : mxParentCanvas,
182 : : mxParentWindow,
183 : : mxBorderCanvas,
184 : : mxBorderWindow,
185 [ # # ][ # # ]: 0 : mxContentWindow);
186 : :
187 [ # # ][ # # ]: 0 : const awt::Rectangle aWindowBox (mxBorderWindow->getPosSize());
188 [ # # ]: 0 : PaintBorder(awt::Rectangle(0,0,aWindowBox.Width,aWindowBox.Height));
189 : 0 : }
190 : :
191 : 0 : void PresenterSpritePane::CreateCanvases (
192 : : const css::uno::Reference<css::awt::XWindow>& rxParentWindow,
193 : : const css::uno::Reference<css::rendering::XSpriteCanvas>& rxParentCanvas)
194 : : {
195 : : OSL_ASSERT(!mxParentWindow.is() || mxParentWindow==rxParentWindow);
196 : : OSL_ASSERT(!mxParentCanvas.is() || mxParentCanvas==rxParentCanvas);
197 : 0 : mxParentWindow = rxParentWindow;
198 : 0 : mxParentCanvas = rxParentCanvas;
199 : :
200 : 0 : mpSprite->SetFactory(mxParentCanvas);
201 [ # # ]: 0 : if (mxBorderWindow.is())
202 : : {
203 [ # # ][ # # ]: 0 : const awt::Rectangle aBorderBox (mxBorderWindow->getPosSize());
204 [ # # ]: 0 : mpSprite->Resize(geometry::RealSize2D(aBorderBox.Width, aBorderBox.Height));
205 : : }
206 : :
207 : 0 : UpdateCanvases();
208 : 0 : }
209 : :
210 : : } } // end of namespace ::sd::presenter
211 : :
212 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|