Ignore:
Timestamp:
Aug 27, 2010, 11:00:52 AM (11 years ago)
Author:
Silvan Scherrer
Message:

poppler update to 0.14.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/poppler/mypoppler/poppler/Link.cc

    r277 r461  
    1515//
    1616// Copyright (C) 2006, 2008 Pino Toscano <pino@kde.org>
    17 // Copyright (C) 2007 Carlos Garcia Campos <carlosgc@gnome.org>
     17// Copyright (C) 2007,2010 Carlos Garcia Campos <carlosgc@gnome.org>
    1818// Copyright (C) 2008 Hugo Mercier <hmercier31@gmail.com>
    1919// Copyright (C) 2008, 2009 Albert Astals Cid <aacid@kde.org>
     
    3636#include "goo/gmem.h"
    3737#include "goo/GooString.h"
     38#include "goo/GooList.h"
    3839#include "Error.h"
    3940#include "Object.h"
     
    4243#include "Link.h"
    4344#include "Sound.h"
    44 #include "Movie.h"
    4545#include "FileSpec.h"
     46#include "Rendition.h"
    4647
    4748//------------------------------------------------------------------------
     
    119120    action = new LinkJavaScript(&obj3);
    120121    obj3.free();
     122
     123  // Set-OCG-State action
     124  } else if (obj2.isName("SetOCGState")) {
     125    action = new LinkOCGState(obj);
    121126
    122127  // unknown action
     
    686691//------------------------------------------------------------------------
    687692
    688 LinkRendition::LinkRendition(Object *Obj) {
     693LinkRendition::LinkRendition(Object *obj) {
    689694  operation = -1;
    690   movie = NULL;
    691   screenRef.num = -1;
    692 
    693   if (Obj->isDict())
    694   {
     695  media = NULL;
     696  js = NULL;
     697
     698  if (obj->isDict()) {
    695699    Object tmp;
    696700
    697     if (Obj->dictLookup("OP", &tmp)->isNull()) {
    698       error(-1, "Rendition action : no /OP field defined");
    699       tmp.free();
    700     } else {
    701    
     701    if (!obj->dictLookup("JS", &tmp)->isNull()) {
     702      if (tmp.isString()) {
     703        js = new GooString(tmp.getString());
     704      } else if (tmp.isStream()) {
     705        Stream *stream = tmp.getStream();
     706        js = new GooString();
     707        stream->reset();
     708        int i;
     709        while ((i = stream->getChar()) != EOF) {
     710          js->append((char)i);
     711        }
     712      } else {
     713        error(-1, "Invalid Rendition Action: JS not string or stream");
     714      }
     715    }
     716    tmp.free();
     717
     718    if (obj->dictLookup("OP", &tmp)->isInt()) {
    702719      operation = tmp.getInt();
    703       tmp.free();
    704 
    705       // screen annotation reference
    706       Obj->dictLookupNF("AN", &tmp);
    707       if (tmp.isRef()) {
    708         screenRef = tmp.getRef();
     720      if (!js && (operation < 0 || operation > 4)) {
     721        error (-1, "Invalid Rendition Action: unrecognized operation valued: %d", operation);
     722      } else {
     723        Object obj1;
     724
     725        // retrieve rendition object
     726        if (obj->dictLookup("R", &renditionObj)->isDict()) {
     727          media = new MediaRendition(&renditionObj);
     728        } else if (operation == 0 || operation == 4) {
     729          error (-1, "Invalid Rendition Action: no R field with op = %d", operation);
     730          renditionObj.free();
     731        }
     732
     733        if (!obj->dictLookupNF("AN", &screenRef)->isRef() && operation >= 0 && operation <= 4) {
     734          error (-1, "Invalid Rendition Action: no AN field with op = %d", operation);
     735          screenRef.free();
     736        }
    709737      }
    710       tmp.free();
    711 
    712       // retrieve rendition object
    713       Obj->dictLookup("R", &renditionObj);
    714       if (renditionObj.isDict()) {
    715 
    716         movie = new Movie();
    717         movie->parseMediaRendition(&renditionObj);
    718        
    719         if (screenRef.num == -1) {
    720           error(-1, "Action Rendition : Rendition without Screen Annotation !");
    721         }
    722       }     
    723 
    724     }
    725   }
    726 
     738    } else if (!js) {
     739      error(-1, "Invalid Rendition action: no OP or JS field defined");
     740    }
     741    tmp.free();
     742  }
    727743}
    728744
    729745LinkRendition::~LinkRendition() {
    730746  renditionObj.free();
    731 
    732   if (movie)
    733     delete movie;
     747  screenRef.free();
     748
     749  if (js)
     750    delete js;
     751  if (media)
     752    delete media;
    734753}
    735754
     
    760779    delete js;
    761780  }
     781}
     782
     783//------------------------------------------------------------------------
     784// LinkOCGState
     785//------------------------------------------------------------------------
     786LinkOCGState::LinkOCGState(Object *obj) {
     787  Object obj1;
     788
     789  stateList = new GooList();
     790  preserveRB = gTrue;
     791
     792  if (obj->dictLookup("State", &obj1)->isArray()) {
     793    StateList *stList = NULL;
     794
     795    for (int i = 0; i < obj1.arrayGetLength(); ++i) {
     796      Object obj2;
     797
     798      obj1.arrayGetNF(i, &obj2);
     799      if (obj2.isName()) {
     800        if (stList)
     801          stateList->append(stList);
     802
     803        char *name = obj2.getName();
     804        stList = new StateList();
     805        stList->list = new GooList();
     806        if (!strcmp (name, "ON")) {
     807          stList->st = On;
     808        } else if (!strcmp (name, "OFF")) {
     809          stList->st = Off;
     810        } else if (!strcmp (name, "Toggle")) {
     811          stList->st = Toggle;
     812        } else {
     813          error (-1, "Invalid name '%s' in OCG Action state array", name);
     814          delete stList;
     815          stList = NULL;
     816        }
     817      } else if (obj2.isRef()) {
     818        if (stList) {
     819          Ref ocgRef = obj2.getRef();
     820          Ref *item = new Ref();
     821          item->num = ocgRef.num;
     822          item->gen = ocgRef.gen;
     823          stList->list->append(item);
     824        } else {
     825          error (-1, "Invalid OCG Action State array, expected name instead of ref");
     826        }
     827      } else {
     828        error (-1, "Invalid item in OCG Action State array");
     829      }
     830      obj2.free();
     831    }
     832    // Add the last group
     833    if (stList)
     834      stateList->append(stList);
     835  } else {
     836    error (-1, "Invalid OCGState action");
     837    delete stateList;
     838    stateList = NULL;
     839  }
     840  obj1.free();
     841
     842  if (obj->dictLookup("PreserveRB", &obj1)->isBool()) {
     843    preserveRB = obj1.getBool();
     844  }
     845  obj1.free();
     846}
     847
     848LinkOCGState::~LinkOCGState() {
     849  if (stateList)
     850    deleteGooList(stateList, StateList);
     851}
     852
     853LinkOCGState::StateList::~StateList() {
     854  if (list)
     855    deleteGooList(list, Ref);
    762856}
    763857
Note: See TracChangeset for help on using the changeset viewer.