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 "PresenterSprite.hxx"
30 : :
31 : : #include <com/sun/star/lang/XComponent.hpp>
32 : : #include <com/sun/star/rendering/CompositeOperation.hpp>
33 : : #include <com/sun/star/rendering/RenderState.hpp>
34 : : #include <com/sun/star/rendering/ViewState.hpp>
35 : :
36 : : using namespace ::com::sun::star;
37 : : using ::com::sun::star::uno::Reference;
38 : : using ::com::sun::star::uno::UNO_QUERY;
39 : :
40 : : namespace sdext { namespace presenter {
41 : :
42 : 0 : PresenterSprite::PresenterSprite (void)
43 : : : mxSpriteFactory(),
44 : : mxSprite(),
45 : : maSize(0,0),
46 : : maLocation(0,0),
47 : : mbIsVisible(false),
48 : : mnPriority(0),
49 : 0 : mnAlpha(1.0)
50 : : {
51 : 0 : }
52 : :
53 : 0 : PresenterSprite::~PresenterSprite (void)
54 : : {
55 [ # # ]: 0 : if (mxSprite.is())
56 : : {
57 [ # # ][ # # ]: 0 : mxSprite->hide();
58 [ # # ]: 0 : Reference<lang::XComponent> xComponent (mxSprite, UNO_QUERY);
59 [ # # ]: 0 : if (xComponent.is())
60 [ # # ][ # # ]: 0 : xComponent->dispose();
61 [ # # ]: 0 : mxSprite = NULL;
62 : : }
63 [ # # ]: 0 : }
64 : :
65 : 0 : void PresenterSprite::SetFactory (
66 : : const ::css::uno::Reference<css::rendering::XSpriteCanvas>& rxSpriteFactory)
67 : : {
68 [ # # ]: 0 : if (mxSpriteFactory != rxSpriteFactory)
69 : : {
70 : 0 : DisposeSprite();
71 : 0 : mxSpriteFactory = rxSpriteFactory;
72 [ # # ]: 0 : if (mbIsVisible)
73 : 0 : ProvideSprite();
74 : : }
75 : 0 : }
76 : :
77 : 0 : ::css::uno::Reference<css::rendering::XCanvas> PresenterSprite::GetCanvas (void)
78 : : {
79 : 0 : ProvideSprite();
80 [ # # ]: 0 : if (mxSprite.is())
81 : 0 : return mxSprite->getContentCanvas();
82 : : else
83 : 0 : return NULL;
84 : : }
85 : :
86 : 0 : void PresenterSprite::Show (void)
87 : : {
88 : 0 : mbIsVisible = true;
89 [ # # ]: 0 : if (mxSprite.is())
90 : 0 : mxSprite->show();
91 : : else
92 : 0 : ProvideSprite();
93 : 0 : }
94 : :
95 : 0 : void PresenterSprite::Hide (void)
96 : : {
97 : 0 : mbIsVisible = false;
98 [ # # ]: 0 : if (mxSprite.is())
99 : 0 : mxSprite->hide();
100 : 0 : }
101 : :
102 : 0 : void PresenterSprite::Resize (const css::geometry::RealSize2D& rSize)
103 : : {
104 : 0 : maSize = rSize;
105 [ # # ]: 0 : if (mxSprite.is())
106 : 0 : DisposeSprite();
107 [ # # ]: 0 : if (mbIsVisible)
108 : 0 : ProvideSprite();
109 : 0 : }
110 : :
111 : 0 : void PresenterSprite::MoveTo (const css::geometry::RealPoint2D& rLocation)
112 : : {
113 : 0 : maLocation = rLocation;
114 [ # # ]: 0 : if (mxSprite.is())
115 : 0 : mxSprite->move(
116 : : maLocation,
117 : : rendering::ViewState(
118 : : geometry::AffineMatrix2D(1,0,0, 0,1,0),
119 : : NULL),
120 : : rendering::RenderState(
121 : : geometry::AffineMatrix2D(1,0,0, 0,1,0),
122 : : NULL,
123 : : uno::Sequence<double>(4),
124 : : rendering::CompositeOperation::SOURCE)
125 [ # # ][ # # ]: 0 : );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
126 : 0 : }
127 : :
128 : 0 : void PresenterSprite::Update (void)
129 : : {
130 [ # # ]: 0 : if (mxSpriteFactory.is())
131 : 0 : mxSpriteFactory->updateScreen(sal_False);
132 : 0 : }
133 : :
134 : 0 : void PresenterSprite::ProvideSprite (void)
135 : : {
136 [ # # # # ]: 0 : if ( ! mxSprite.is()
[ # # ][ # # ]
[ # # ]
137 : 0 : && mxSpriteFactory.is()
138 : : && maSize.Width>0
139 : : && maSize.Height>0)
140 : : {
141 [ # # ]: 0 : mxSprite = mxSpriteFactory->createCustomSprite(maSize);
142 [ # # ]: 0 : if (mxSprite.is())
143 : : {
144 : 0 : mxSprite->move(maLocation,
145 : : rendering::ViewState(
146 : : geometry::AffineMatrix2D(1,0,0, 0,1,0),
147 : : NULL),
148 : : rendering::RenderState(
149 : : geometry::AffineMatrix2D(1,0,0, 0,1,0),
150 : : NULL,
151 : : uno::Sequence<double>(4),
152 : : rendering::CompositeOperation::SOURCE)
153 [ # # ][ # # ]: 0 : );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
154 : 0 : mxSprite->setAlpha(mnAlpha);
155 : 0 : mxSprite->setPriority(mnPriority);
156 [ # # ]: 0 : if (mbIsVisible)
157 : 0 : mxSprite->show();
158 : : }
159 : : }
160 : 0 : }
161 : :
162 : 0 : void PresenterSprite::DisposeSprite (void)
163 : : {
164 [ # # ]: 0 : if (mxSprite.is())
165 : : {
166 [ # # ][ # # ]: 0 : mxSprite->hide();
167 [ # # ]: 0 : Reference<lang::XComponent> xComponent (mxSprite, UNO_QUERY);
168 [ # # ]: 0 : if (xComponent.is())
169 [ # # ][ # # ]: 0 : xComponent->dispose();
170 [ # # ]: 0 : mxSprite = NULL;
171 : : }
172 : 0 : }
173 : :
174 : : } } //end of namespace sdext::presenter
175 : :
176 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|