summaryrefslogtreecommitdiff
path: root/poppler/PageTransition.cc
blob: 07a2c65a5f07f3877898b8fdc44e8b50b220579e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/* PageTransition.cc
 * Copyright (C) 2005, Net Integration Technologies, Inc.
 * Copyright (C) 2010, 2017, Albert Astals Cid <aacid@kde.org>
 * Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com>
 * Copyright (C) 2015, Arseniy Lartsev <arseniy@alumni.chalmers.se>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
 */

#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif

#include "PageTransition.h"

//------------------------------------------------------------------------
// PageTransition
//------------------------------------------------------------------------

PageTransition::PageTransition (Object *trans) {
  Object obj;
  Dict *dict;

  type = transitionReplace;
  duration = 1;
  alignment = transitionHorizontal;
  direction = transitionInward;
  angle = 0;
  scale = 1.0;
  rectangular = gFalse;
  ok = gTrue;

  if (!trans || !trans->isDict ()) {
    ok = gFalse;
    return;
  }

  dict = trans->getDict();

  // get type
  obj = dict->lookup("S");
  if (obj.isName()) {
    const char *s = obj.getName();
    
    if (strcmp("R", s) == 0)
      type = transitionReplace;
    else if (strcmp("Split", s) == 0)
      type = transitionSplit;
    else if (strcmp("Blinds", s) == 0)
      type = transitionBlinds;
    else if (strcmp("Box", s) == 0)
      type = transitionBox;
    else if (strcmp("Wipe", s) == 0)
      type = transitionWipe;
    else if (strcmp("Dissolve", s) == 0)
      type = transitionDissolve;
    else if (strcmp("Glitter", s) == 0)
      type = transitionGlitter;
    else if (strcmp("Fly", s) == 0)
      type = transitionFly;
    else if (strcmp("Push", s) == 0)
      type = transitionPush;
    else if (strcmp("Cover", s) == 0)
      type = transitionCover;
    else if (strcmp("Uncover", s) == 0)
      type = transitionUncover;
    else if (strcmp("Fade", s) == 0)
      type = transitionFade;
  }

  // get duration
  obj = dict->lookup("D");
  if (obj.isNum()) {
    duration = obj.getNum();
  }

  // get alignment
  obj = dict->lookup("Dm");
  if (obj.isName()) {
    const char *dm = obj.getName();
    
    if (strcmp("H", dm) == 0)
      alignment = transitionHorizontal;
    else if (strcmp("V", dm) == 0)
      alignment = transitionVertical;
  }

  // get direction
  obj = dict->lookup("M");
  if (obj.isName()) {
    const char *m = obj.getName();
    
    if (strcmp("I", m) == 0)
      direction = transitionInward;
    else if (strcmp("O", m) == 0)
      direction = transitionOutward;
  }

  // get angle
  obj = dict->lookup("Di");
  if (obj.isInt()) {
    angle = obj.getInt();
  }

  obj = dict->lookup("Di");
  if (obj.isName()) {
    if (strcmp("None", obj.getName()) == 0)
      angle = 0;
  }

  // get scale
  obj = dict->lookup("SS");
  if (obj.isNum()) {
    scale = obj.getNum();
  }

  // get rectangular
  obj = dict->lookup("B");
  if (obj.isBool()) {
    rectangular = obj.getBool();
  }
}

PageTransition::~PageTransition()
{
}