1 /* PageTransition.cc
2 * Copyright (C) 2005, Net Integration Technologies, Inc.
3 * Copyright (C) 2010, 2017, 2020, 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>
6 *
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.
11 *
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.
16 *
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.
20 */
21
22 #include "PageTransition.h"
23
24 //------------------------------------------------------------------------
25 // PageTransition
26 //------------------------------------------------------------------------
27
PageTransition(Object * trans)28 PageTransition::PageTransition(Object *trans)
29 {
30 Object obj;
31 Dict *dict;
32
33 type = transitionReplace;
34 duration = 1;
35 alignment = transitionHorizontal;
36 direction = transitionInward;
37 angle = 0;
38 scale = 1.0;
39 ok = true;
40
41 if (!trans || !trans->isDict()) {
42 ok = false;
43 return;
44 }
45
46 dict = trans->getDict();
47
48 // get type
49 obj = dict->lookup("S");
50 if (obj.isName()) {
51 const char *s = obj.getName();
52
53 if (strcmp("R", s) == 0)
54 type = transitionReplace;
55 else if (strcmp("Split", s) == 0)
56 type = transitionSplit;
57 else if (strcmp("Blinds", s) == 0)
58 type = transitionBlinds;
59 else if (strcmp("Box", s) == 0)
60 type = transitionBox;
61 else if (strcmp("Wipe", s) == 0)
62 type = transitionWipe;
63 else if (strcmp("Dissolve", s) == 0)
64 type = transitionDissolve;
65 else if (strcmp("Glitter", s) == 0)
66 type = transitionGlitter;
67 else if (strcmp("Fly", s) == 0)
68 type = transitionFly;
69 else if (strcmp("Push", s) == 0)
70 type = transitionPush;
71 else if (strcmp("Cover", s) == 0)
72 type = transitionCover;
73 else if (strcmp("Uncover", s) == 0)
74 type = transitionUncover;
75 else if (strcmp("Fade", s) == 0)
76 type = transitionFade;
77 }
78
79 // get duration
80 obj = dict->lookup("D");
81 if (obj.isNum()) {
82 duration = obj.getNum();
83 }
84
85 // get alignment
86 obj = dict->lookup("Dm");
87 if (obj.isName()) {
88 const char *dm = obj.getName();
89
90 if (strcmp("H", dm) == 0)
91 alignment = transitionHorizontal;
92 else if (strcmp("V", dm) == 0)
93 alignment = transitionVertical;
94 }
95
96 // get direction
97 obj = dict->lookup("M");
98 if (obj.isName()) {
99 const char *m = obj.getName();
100
101 if (strcmp("I", m) == 0)
102 direction = transitionInward;
103 else if (strcmp("O", m) == 0)
104 direction = transitionOutward;
105 }
106
107 // get angle
108 obj = dict->lookup("Di");
109 if (obj.isInt()) {
110 angle = obj.getInt();
111 }
112
113 obj = dict->lookup("Di");
114 if (obj.isName()) {
115 if (strcmp("None", obj.getName()) == 0)
116 angle = 0;
117 }
118
119 // get scale
120 obj = dict->lookup("SS");
121 if (obj.isNum()) {
122 scale = obj.getNum();
123 }
124
125 // get rectangular
126 rectangular = dict->lookup("B").getBoolWithDefaultValue(false);
127 }
128
~PageTransition()129 PageTransition::~PageTransition() { }
130