1 //*********************************************************************************
3 //---------------------------------------------------------------------------------
5 //---------------------------------------------------------------------------------
6 // Hugo Mercier <hmercier31[at]gmail.com> (c) 2008
7 // Pino Toscano <pino@kde.org> (c) 2008
8 // Carlos Garcia Campos <carlosgc@gnome.org> (c) 2010
9 // Albert Astals Cid <aacid@kde.org> (c) 2010
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
16 // This program 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 General Public License for more details.
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 //*********************************************************************************
30 MovieActivationParameters::MovieActivationParameters() {
32 floatingWindow
= gFalse
;
37 showControls
= gFalse
;
38 synchronousPlay
= gFalse
;
39 repeatMode
= repeatModeOnce
;
46 MovieActivationParameters::~MovieActivationParameters() {
49 void MovieActivationParameters::parseMovieActivation(Object
* aDict
) {
52 if (!aDict
->dictLookup("Start", &obj1
)->isNull()) {
54 // If it is representable as an integer (subject to the implementation limit for
55 // integers, as described in Appendix C), it should be specified as such.
57 start
.units
= obj1
.getInt();
58 } else if (obj1
.isString()) {
59 // If it is not representable as an integer, it should be specified as an 8-byte
60 // string representing a 64-bit twos-complement integer, most significant
64 } else if (obj1
.isArray()) {
65 Array
* a
= obj1
.getArray();
70 start
.units
= tmp
.getInt();
79 start
.units_per_second
= tmp
.getInt();
86 if (!aDict
->dictLookup("Duration", &obj1
)->isNull()) {
88 duration
.units
= obj1
.getInt();
89 } else if (obj1
.isString()) {
91 } else if (obj1
.isArray()) {
92 Array
* a
= obj1
.getArray();
97 duration
.units
= tmp
.getInt();
106 duration
.units_per_second
= tmp
.getInt();
113 if (aDict
->dictLookup("Rate", &obj1
)->isNum()) {
114 rate
= obj1
.getNum();
118 if (aDict
->dictLookup("Volume", &obj1
)->isNum()) {
119 // convert volume to [0 100]
120 volume
= int((obj1
.getNum() + 1.0) * 50);
124 if (aDict
->dictLookup("ShowControls", &obj1
)->isBool()) {
125 showControls
= obj1
.getBool();
129 if (aDict
->dictLookup("Synchronous", &obj1
)->isBool()) {
130 synchronousPlay
= obj1
.getBool();
134 if (aDict
->dictLookup("Mode", &obj1
)->isName()) {
135 char* name
= obj1
.getName();
136 if (!strcmp(name
, "Once")) {
137 repeatMode
= repeatModeOnce
;
138 } else if (!strcmp(name
, "Open")) {
139 repeatMode
= repeatModeOpen
;
140 } else if (!strcmp(name
, "Repeat")) {
141 repeatMode
= repeatModeRepeat
;
142 } else if (!strcmp(name
,"Palindrome")) {
143 repeatMode
= repeatModePalindrome
;
148 if (aDict
->dictLookup("FWScale", &obj1
)->isArray()) {
149 // the presence of that entry implies that the movie is to be played
150 // in a floating window
151 floatingWindow
= gTrue
;
153 Array
* scale
= obj1
.getArray();
154 if (scale
->getLength() >= 2) {
156 if (scale
->get(0, &tmp
)->isInt()) {
160 if (scale
->get(1, &tmp
)->isInt()) {
161 zdenum
= tmp
.getInt();
168 if (aDict
->dictLookup("FWPosition", &obj1
)->isArray()) {
169 Array
* pos
= obj1
.getArray();
170 if (pos
->getLength() >= 2) {
172 if (pos
->get(0, &tmp
)->isNum()) {
173 xPosition
= tmp
.getNum();
176 if (pos
->get(1, &tmp
)->isNum()) {
177 yPosition
= tmp
.getNum();
185 void Movie::parseMovie (Object
*movieDict
) {
193 if (getFileSpecNameForPlatform(movieDict
->dictLookup("F", &obj1
), &obj2
)) {
194 fileName
= obj2
.getString()->copy();
197 error (errSyntaxError
, -1, "Invalid Movie");
204 if (movieDict
->dictLookup("Aspect", &obj1
)->isArray()) {
205 Array
* aspect
= obj1
.getArray();
206 if (aspect
->getLength() >= 2) {
208 if( aspect
->get(0, &tmp
)->isNum() ) {
209 width
= (int)floor( aspect
->get(0, &tmp
)->getNum() + 0.5 );
212 if( aspect
->get(1, &tmp
)->isNum() ) {
213 height
= (int)floor( aspect
->get(1, &tmp
)->getNum() + 0.5 );
220 if (movieDict
->dictLookup("Rotate", &obj1
)->isInt()) {
222 rotationAngle
= (((obj1
.getInt() + 360) % 360) % 90) * 90;
229 if (!movieDict
->dictLookupNF("Poster", &poster
)->isNull()) {
230 if (poster
.isRef() || poster
.isStream()) {
232 } else if (poster
.isBool()) {
233 showPoster
= poster
.getBool();
247 Movie::Movie(Object
*movieDict
) {
250 if (movieDict
->isDict())
251 parseMovie(movieDict
);
256 Movie::Movie(Object
*movieDict
, Object
*aDict
) {
259 if (movieDict
->isDict()) {
260 parseMovie(movieDict
);
262 MA
.parseMovieActivation(aDict
);
268 void Movie::getFloatingWindowSize(int *widthA
, int *heightA
)
270 *widthA
= int(width
* double(MA
.znum
) / MA
.zdenum
);
271 *heightA
= int(height
* double(MA
.znum
) / MA
.zdenum
);
274 Movie
* Movie::copy() {
276 // call default copy constructor
277 Movie
* new_movie
= new Movie(*this);
280 new_movie
->fileName
= fileName
->copy();
282 poster
.copy(&new_movie
->poster
);