beta-0.89.2
[luatex.git] / source / libs / poppler / poppler-src / poppler / PageTransition.cc
blobd5a84f89a7b3f6531c13d882820b243a8e83e01f
1 /* PageTransition.cc
2 * Copyright (C) 2005, Net Integration Technologies, Inc.
3 * Copyright (C) 2010, Albert Astals Cid <aacid@kde.org>
4 * Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com>
5 * Copyright (C) 2015, Arseniy Lartsev <arseniy@alumni.chalmers.se>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
22 #ifdef USE_GCC_PRAGMAS
23 #pragma implementation
24 #endif
26 #include "PageTransition.h"
28 //------------------------------------------------------------------------
29 // PageTransition
30 //------------------------------------------------------------------------
32 PageTransition::PageTransition (Object *trans) {
33 Object obj;
34 Dict *dict;
36 type = transitionReplace;
37 duration = 1;
38 alignment = transitionHorizontal;
39 direction = transitionInward;
40 angle = 0;
41 scale = 1.0;
42 rectangular = gFalse;
43 ok = gTrue;
45 if (!trans || !trans->isDict ()) {
46 ok = gFalse;
47 return;
50 dict = trans->getDict();
52 // get type
53 if (dict->lookup("S", &obj)->isName()) {
54 const char *s = obj.getName();
56 if (strcmp("R", s) == 0)
57 type = transitionReplace;
58 else if (strcmp("Split", s) == 0)
59 type = transitionSplit;
60 else if (strcmp("Blinds", s) == 0)
61 type = transitionBlinds;
62 else if (strcmp("Box", s) == 0)
63 type = transitionBox;
64 else if (strcmp("Wipe", s) == 0)
65 type = transitionWipe;
66 else if (strcmp("Dissolve", s) == 0)
67 type = transitionDissolve;
68 else if (strcmp("Glitter", s) == 0)
69 type = transitionGlitter;
70 else if (strcmp("Fly", s) == 0)
71 type = transitionFly;
72 else if (strcmp("Push", s) == 0)
73 type = transitionPush;
74 else if (strcmp("Cover", s) == 0)
75 type = transitionCover;
76 else if (strcmp("Uncover", s) == 0)
77 type = transitionUncover;
78 else if (strcmp("Fade", s) == 0)
79 type = transitionFade;
81 obj.free();
83 // get duration
84 if (dict->lookup("D", &obj)->isNum()) {
85 duration = obj.getNum();
87 obj.free();
89 // get alignment
90 if (dict->lookup("Dm", &obj)->isName()) {
91 const char *dm = obj.getName();
93 if (strcmp("H", dm) == 0)
94 alignment = transitionHorizontal;
95 else if (strcmp("V", dm) == 0)
96 alignment = transitionVertical;
98 obj.free();
100 // get direction
101 if (dict->lookup("M", &obj)->isName()) {
102 const char *m = obj.getName();
104 if (strcmp("I", m) == 0)
105 direction = transitionInward;
106 else if (strcmp("O", m) == 0)
107 direction = transitionOutward;
109 obj.free();
111 // get angle
112 if (dict->lookup("Di", &obj)->isInt()) {
113 angle = obj.getInt();
115 obj.free();
117 if (dict->lookup("Di", &obj)->isName()) {
118 if (strcmp("None", obj.getName()) == 0)
119 angle = 0;
121 obj.free();
123 // get scale
124 if (dict->lookup("SS", &obj)->isNum()) {
125 scale = obj.getNum();
127 obj.free();
129 // get rectangular
130 if (dict->lookup("B", &obj)->isBool()) {
131 rectangular = obj.getBool();
133 obj.free();
136 PageTransition::~PageTransition()