[poppler] poppler/poppler: Makefile.am, 1.16, 1.17 PageTransition.cc, NONE, 1.1 PageTransition.h, NONE, 1.1 Private.h, NONE, 1.1

Albert Astals Cid aacid at freedesktop.org
Fri Dec 30 14:31:34 PST 2005


Update of /cvs/poppler/poppler/poppler
In directory gabe:/tmp/cvs-serv25153/poppler

Modified Files:
	Makefile.am 
Added Files:
	PageTransition.cc PageTransition.h Private.h 
Log Message:
Puting PageTransition implementation into poppler "core", both Qt and Qt4 frontends use it.


Index: Makefile.am
===================================================================
RCS file: /cvs/poppler/poppler/poppler/Makefile.am,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- Makefile.am	9 Dec 2005 19:40:40 -0000	1.16
+++ Makefile.am	30 Dec 2005 22:31:32 -0000	1.17
@@ -185,6 +185,7 @@
 	Outline.cc		\
 	OutputDev.cc 		\
 	Page.cc 		\
+	PageTransition.cc 	\
 	Parser.cc 		\
 	PDFDoc.cc 		\
 	PDFDocEncoding.cc	\

--- NEW FILE: PageTransition.cc ---
/* PageTransition.cc
 * Copyright (C) 2005, Net Integration Technologies, Inc.
 *
 * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#include <iostream>

#include "Object.h"
#include "PageTransition.h"
#include "Private.h"

namespace Poppler {

class PageTransitionData
{
  public:
    PageTransition::Type type;
    int duration;
    PageTransition::Alignment alignment;
    PageTransition::Direction direction;
    int angle;
    double scale;
    bool rectangular;
};

PageTransition::PageTransition(const PageTransitionParams &params)
{
  data = new PageTransitionData();
  data->type = Replace;
  data->duration = 1;
  data->alignment = Horizontal;
  data->direction = Inward;
  data->angle = 0;
  data->scale = 1.0;
  data->rectangular = false;

  // Paranoid safety checks
  if (params.dictObj == 0) {
    std::cerr << "ERROR in the poppler library: the method PageTransition_x::PageTransition_x(Object *params.dictObj) was called with params.dictObj==0\n";
    return;
  }
  if (params.dictObj->isDict() == false) {
    std::cerr << "ERROR in the poppler library: the method PageTransition_x::PageTransition_x(Object *params.dictObj) was called where params.dictObj->isDict()==false\n";
    return;
  }

  // Obtain a pointer to the dictionary and start parsing.
  Dict *transDict = params.dictObj->getDict();
  Object obj;

  if (transDict->lookup("S", &obj)->isName()) {
    const char *s = obj.getName();
    if (strcmp("R", s) == 0)
      data->type = Replace;
    else if (strcmp("Split", s) == 0)
      data->type = Split;
    else if (strcmp("Blinds", s) == 0)
      data->type = Blinds;
    else if (strcmp("Box", s) == 0)
      data->type = Box;
    else if (strcmp("Wipe", s) == 0)
      data->type = Wipe;
    else if (strcmp("Dissolve", s) == 0)
      data->type = Dissolve;
    else if (strcmp("Glitter", s) == 0)
      data->type = Glitter;
    else if (strcmp("Fly", s) == 0)
      data->type = Fly;
    else if (strcmp("Push", s) == 0)
      data->type = Push;
    else if (strcmp("Cover", s) == 0)
      data->type = Cover;
    else if (strcmp("Uncover", s) == 0)
      data->type = Push;
    else if (strcmp("Fade", s) == 0)
      data->type = Cover;
  }
  obj.free();
  
  if (transDict->lookup("D", &obj)->isInt()) {
    data->duration = obj.getInt();
  }
  obj.free();

  if (transDict->lookup("Dm", &obj)->isName()) {
    const char *dm = obj.getName();
    if ( strcmp( "H", dm ) == 0 )
      data->alignment = Horizontal;
    else if ( strcmp( "V", dm ) == 0 )
      data->alignment = Vertical;
  }
  obj.free();
  
  if (transDict->lookup("M", &obj)->isName()) {
    const char *m = obj.getName();
    if ( strcmp( "I", m ) == 0 )
      data->direction = Inward;
    else if ( strcmp( "O", m ) == 0 )
      data->direction = Outward;
  }
  obj.free();
  
  if (transDict->lookup("Di", &obj)->isInt()) {
    data->angle = obj.getInt();
  }
  obj.free();
  
  if (transDict->lookup("Di", &obj)->isName()) {
    if ( strcmp( "None", obj.getName() ) == 0 )
      data->angle = 0;
  }
  obj.free();
  
  if (transDict->lookup("SS", &obj)->isReal()) {
    data->scale = obj.getReal();
  }
  obj.free();
  
  if (transDict->lookup("B", &obj)->isBool()) {
    data->rectangular = obj.getBool();
  }
  obj.free();
}

PageTransition::PageTransition(const PageTransition &pt)
{
  data = new PageTransitionData();
  data->type = pt.data->type;
  data->duration = pt.data->duration;
  data->alignment = pt.data->alignment;
  data->direction = pt.data->direction;
  data->angle = pt.data->angle;
  data->scale = pt.data->scale;
  data->rectangular = pt.data->rectangular;
}

PageTransition::~PageTransition()
{
}

PageTransition::Type PageTransition::type() const
{
  return data->type;
}

int PageTransition::duration() const
{
  return data->duration;
}

PageTransition::Alignment PageTransition::alignment() const
{
  return data->alignment;
}

PageTransition::Direction PageTransition::direction() const
{
  return data->direction;
}

int PageTransition::angle() const
{
  return data->angle;
}

double PageTransition::scale() const
{
  return data->scale;
}
bool PageTransition::isRectangular() const
{
  return data->rectangular;
}

}

--- NEW FILE: PageTransition.h ---
/* PageTransition.h
 * Copyright (C) 2005, Net Integration Technologies, Inc.
 * Copyright (C) 2005, Brad Hards <bradh at frogmouth.net>
 *
 * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef __PAGETRANSITION_X_H__
#define __PAGETRANSITION_X_H__

class PageTransitionParams;

namespace Poppler {

class PageTransitionData;

class PageTransition {
 public:
  enum Type {
    Replace,
    Split,
    Blinds,
    Box,
    Wipe,
    Dissolve,
    Glitter,
    Fly,
    Push,
    Cover,
    Uncover,
    Fade
  };
  
  enum Alignment {
    Horizontal,
    Vertical
  };
  
  enum Direction {
    Inward,
    Outward
  };
  
  /** \brief Construct a new PageTransition object from a page dictionary.

  In case or error, this method will print an error message to stderr,
  and construct a default object.

  @param dictObj pointer to an object whose dictionary will be read
  and parsed. The pointer dictObj must point to a valid object, whose
  dictionaries are accessed by the constructor. The dictObj is only
  accessed by this constructor, and may be deleted after the
  constructor returns.
  */
  PageTransition(const PageTransitionParams &params);
  
  PageTransition(const PageTransition &pt);
  
  /**
     Destructor
  */
  ~PageTransition();
  
  /**
     \brief Get type of the transition.
  */
  Type type() const;
  
  /**
     \brief Get duration of the transition in seconds.
  */
  int duration() const;
  
  /**
     \brief Get dimension in which the transition effect occurs.
  */
  Alignment alignment() const;
  
  /**
     \brief Get direction of motion of the transition effect.
  */
  Direction direction() const;
  
  /**
     \brief Get direction in which the transition effect moves.
  */
  int angle() const;
  
  /**
     \brief Get starting or ending scale.
  */
  double scale() const;
  
  /**
     \brief Returns true if the area to be flown is rectangular and
     opaque.
  */
  bool isRectangular() const;
  
 private:
  PageTransitionData *data;
};

}

#endif

--- NEW FILE: Private.h ---
/* Private.h
 * Copyright (C) 2005, Albert Astals Cid <aacid at kde.org>
 *
 * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef __PRIVATE_H__
#define __PRIVATE_H__

class Object;

class PageTransitionParams
{
  public:
    Object *dictObj;
};

#endif



More information about the poppler mailing list