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
28PageTransition::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(key: "S");
50 if (obj.isName()) {
51 const char *s = obj.getName();
52
53 if (strcmp(s1: "R", s2: s) == 0) {
54 type = transitionReplace;
55 } else if (strcmp(s1: "Split", s2: s) == 0) {
56 type = transitionSplit;
57 } else if (strcmp(s1: "Blinds", s2: s) == 0) {
58 type = transitionBlinds;
59 } else if (strcmp(s1: "Box", s2: s) == 0) {
60 type = transitionBox;
61 } else if (strcmp(s1: "Wipe", s2: s) == 0) {
62 type = transitionWipe;
63 } else if (strcmp(s1: "Dissolve", s2: s) == 0) {
64 type = transitionDissolve;
65 } else if (strcmp(s1: "Glitter", s2: s) == 0) {
66 type = transitionGlitter;
67 } else if (strcmp(s1: "Fly", s2: s) == 0) {
68 type = transitionFly;
69 } else if (strcmp(s1: "Push", s2: s) == 0) {
70 type = transitionPush;
71 } else if (strcmp(s1: "Cover", s2: s) == 0) {
72 type = transitionCover;
73 } else if (strcmp(s1: "Uncover", s2: s) == 0) {
74 type = transitionUncover;
75 } else if (strcmp(s1: "Fade", s2: s) == 0) {
76 type = transitionFade;
77 }
78 }
79
80 // get duration
81 obj = dict->lookup(key: "D");
82 if (obj.isNum()) {
83 duration = obj.getNum();
84 }
85
86 // get alignment
87 obj = dict->lookup(key: "Dm");
88 if (obj.isName()) {
89 const char *dm = obj.getName();
90
91 if (strcmp(s1: "H", s2: dm) == 0) {
92 alignment = transitionHorizontal;
93 } else if (strcmp(s1: "V", s2: dm) == 0) {
94 alignment = transitionVertical;
95 }
96 }
97
98 // get direction
99 obj = dict->lookup(key: "M");
100 if (obj.isName()) {
101 const char *m = obj.getName();
102
103 if (strcmp(s1: "I", s2: m) == 0) {
104 direction = transitionInward;
105 } else if (strcmp(s1: "O", s2: m) == 0) {
106 direction = transitionOutward;
107 }
108 }
109
110 // get angle
111 obj = dict->lookup(key: "Di");
112 if (obj.isInt()) {
113 angle = obj.getInt();
114 }
115
116 obj = dict->lookup(key: "Di");
117 if (obj.isName()) {
118 if (strcmp(s1: "None", s2: obj.getName()) == 0) {
119 angle = 0;
120 }
121 }
122
123 // get scale
124 obj = dict->lookup(key: "SS");
125 if (obj.isNum()) {
126 scale = obj.getNum();
127 }
128
129 // get rectangular
130 rectangular = dict->lookup(key: "B").getBoolWithDefaultValue(defaultValue: false);
131}
132
133PageTransition::~PageTransition() { }
134

source code of poppler/poppler/PageTransition.cc