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 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20
21 #ifdef USE_GCC_PRAGMAS
22 #pragma implementation
23 #endif
24
25 #include "PageTransition.h"
26
27 //------------------------------------------------------------------------
28 // PageTransition
29 //------------------------------------------------------------------------
30
PageTransition(Object * trans)31 PageTransition::PageTransition (Object *trans) {
32 Object obj;
33 Dict *dict;
34
35 type = transitionReplace;
36 duration = 1;
37 alignment = transitionHorizontal;
38 direction = transitionInward;
39 angle = 0;
40 scale = 1.0;
41 rectangular = gFalse;
42 ok = gTrue;
43
44 if (!trans || !trans->isDict ()) {
45 ok = gFalse;
46 return;
47 }
48
49 dict = trans->getDict();
50
51 // get type
52 if (dict->lookup("S", &obj)->isName()) {
53 const char *s = obj.getName();
54
55 if (strcmp("R", s) == 0)
56 type = transitionReplace;
57 else if (strcmp("Split", s) == 0)
58 type = transitionSplit;
59 else if (strcmp("Blinds", s) == 0)
60 type = transitionBlinds;
61 else if (strcmp("Box", s) == 0)
62 type = transitionBox;
63 else if (strcmp("Wipe", s) == 0)
64 type = transitionWipe;
65 else if (strcmp("Dissolve", s) == 0)
66 type = transitionDissolve;
67 else if (strcmp("Glitter", s) == 0)
68 type = transitionGlitter;
69 else if (strcmp("Fly", s) == 0)
70 type = transitionFly;
71 else if (strcmp("Push", s) == 0)
72 type = transitionPush;
73 else if (strcmp("Cover", s) == 0)
74 type = transitionCover;
75 else if (strcmp("Uncover", s) == 0)
76 type = transitionUncover;
77 else if (strcmp("Fade", s) == 0)
78 type = transitionFade;
79 }
80 obj.free();
81
82 // get duration
83 if (dict->lookup("D", &obj)->isInt()) {
84 duration = obj.getInt();
85 }
86 obj.free();
87
88 // get alignment
89 if (dict->lookup("Dm", &obj)->isName()) {
90 const char *dm = obj.getName();
91
92 if (strcmp("H", dm) == 0)
93 alignment = transitionHorizontal;
94 else if (strcmp("V", dm) == 0)
95 alignment = transitionVertical;
96 }
97 obj.free();
98
99 // get direction
100 if (dict->lookup("M", &obj)->isName()) {
101 const char *m = obj.getName();
102
103 if (strcmp("I", m) == 0)
104 direction = transitionInward;
105 else if (strcmp("O", m) == 0)
106 direction = transitionOutward;
107 }
108 obj.free();
109
110 // get angle
111 if (dict->lookup("Di", &obj)->isInt()) {
112 angle = obj.getInt();
113 }
114 obj.free();
115
116 if (dict->lookup("Di", &obj)->isName()) {
117 if (strcmp("None", obj.getName()) == 0)
118 angle = 0;
119 }
120 obj.free();
121
122 // get scale
123 if (dict->lookup("SS", &obj)->isNum()) {
124 scale = obj.getNum();
125 }
126 obj.free();
127
128 // get rectangular
129 if (dict->lookup("B", &obj)->isBool()) {
130 rectangular = obj.getBool();
131 }
132 obj.free();
133 }
134
~PageTransition()135 PageTransition::~PageTransition()
136 {
137 }
138
139