LibreOffice Module sd (master) 1
PresenterSprite.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include "PresenterSprite.hxx"
21
22#include <com/sun/star/lang/XComponent.hpp>
23#include <com/sun/star/rendering/CompositeOperation.hpp>
24#include <com/sun/star/rendering/RenderState.hpp>
25#include <com/sun/star/rendering/ViewState.hpp>
26
27using namespace ::com::sun::star;
28using ::com::sun::star::uno::Reference;
29using ::com::sun::star::uno::UNO_QUERY;
30
31namespace sdext::presenter {
32
34 : maSize(0,0),
35 maLocation(0,0),
36 mbIsVisible(false)
37{
38}
39
41{
42 if (mxSprite.is())
43 {
44 mxSprite->hide();
45 Reference<lang::XComponent> xComponent (mxSprite, UNO_QUERY);
46 if (xComponent.is())
47 xComponent->dispose();
48 mxSprite = nullptr;
49 }
50}
51
53 const css::uno::Reference<css::rendering::XSpriteCanvas>& rxSpriteFactory)
54{
55 if (mxSpriteFactory != rxSpriteFactory)
56 {
58 mxSpriteFactory = rxSpriteFactory;
59 if (mbIsVisible)
61 }
62}
63
64css::uno::Reference<css::rendering::XCanvas> PresenterSprite::GetCanvas()
65{
67 if (mxSprite.is())
68 return mxSprite->getContentCanvas();
69 else
70 return nullptr;
71}
72
74{
75 mbIsVisible = true;
76 if (mxSprite.is())
77 mxSprite->show();
78 else
80}
81
83{
84 mbIsVisible = false;
85 if (mxSprite.is())
86 mxSprite->hide();
87}
88
89void PresenterSprite::Resize (const css::geometry::RealSize2D& rSize)
90{
91 maSize = rSize;
92 if (mxSprite.is())
94 if (mbIsVisible)
96}
97
98void PresenterSprite::MoveTo (const css::geometry::RealPoint2D& rLocation)
99{
100 maLocation = rLocation;
101 if (mxSprite.is())
102 mxSprite->move(
104 rendering::ViewState(
105 geometry::AffineMatrix2D(1,0,0, 0,1,0),
106 nullptr),
107 rendering::RenderState(
108 geometry::AffineMatrix2D(1,0,0, 0,1,0),
109 nullptr,
110 uno::Sequence<double>(4),
111 rendering::CompositeOperation::SOURCE)
112 );
113}
114
116{
117 if (mxSpriteFactory.is())
118 mxSpriteFactory->updateScreen(false);
119}
120
122{
123 if ( !(! mxSprite.is()
124 && mxSpriteFactory.is()
125 && maSize.Width>0
126 && maSize.Height>0))
127 return;
128
129 mxSprite = mxSpriteFactory->createCustomSprite(maSize);
130 if (!mxSprite.is())
131 return;
132
133 mxSprite->move(maLocation,
134 rendering::ViewState(
135 geometry::AffineMatrix2D(1,0,0, 0,1,0),
136 nullptr),
137 rendering::RenderState(
138 geometry::AffineMatrix2D(1,0,0, 0,1,0),
139 nullptr,
140 uno::Sequence<double>(4),
141 rendering::CompositeOperation::SOURCE)
142 );
143 mxSprite->setAlpha(1.0);
144 mxSprite->setPriority(0);
145 if (mbIsVisible)
146 mxSprite->show();
147}
148
150{
151 if (mxSprite.is())
152 {
153 mxSprite->hide();
154 Reference<lang::XComponent> xComponent (mxSprite, UNO_QUERY);
155 if (xComponent.is())
156 xComponent->dispose();
157 mxSprite = nullptr;
158 }
159}
160
161} //end of namespace sdext::presenter
162
163/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
geometry::RealSize2D maSize
awt::Point maLocation
css::uno::Reference< css::rendering::XCustomSprite > mxSprite
void Resize(const css::geometry::RealSize2D &rSize)
css::uno::Reference< css::rendering::XCanvas > GetCanvas()
void SetFactory(const css::uno::Reference< css::rendering::XSpriteCanvas > &rxSpriteFactory)
The given sprite canvas is used as factory to create the sprite that is wrapped by objects of this cl...
css::geometry::RealPoint2D maLocation
css::uno::Reference< css::rendering::XSpriteCanvas > mxSpriteFactory
css::geometry::RealSize2D maSize
void MoveTo(const css::geometry::RealPoint2D &rLocation)