Ignore:
Timestamp:
Oct 19, 2008, 4:08:46 PM (13 years ago)
Author:
Eugene Romanenko
Message:

PDF plugin: Poppler library updated to version 0.10.0

File:
1 edited

Legend:

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

    r254 r257  
    44//
    55// Copyright 1996-2003 Glyph & Cog, LLC
     6//
     7//========================================================================
     8
     9//========================================================================
     10//
     11// Modified under the Poppler project - http://poppler.freedesktop.org
     12//
     13// All changes made under the Poppler project to this file are licensed
     14// under GPL version 2 or later
     15//
     16// Copyright (C) 2006, 2008 Pino Toscano <pino@kde.org>
     17// Copyright (C) 2007 Carlos Garcia Campos <carlosgc@gnome.org>
     18// Copyright (C) 2008 Hugo Mercier <hmercier31@gmail.com>
     19// Copyright (C) 2008 Albert Astals Cid <aacid@kde.org>
     20//
     21// To see a description of the changes please see the Changelog file that
     22// came with your tarball or type make ChangeLog if you are building from git
    623//
    724//========================================================================
     
    2441#include "Sound.h"
    2542#include "Movie.h"
     43#include "FileSpec.h"
    2644
    2745//------------------------------------------------------------------------
     
    94112    action = new LinkSound(obj);
    95113
     114  // JavaScript action
     115  } else if (obj2.isName("JavaScript")) {
     116    obj->dictLookup("JS", &obj3);
     117    action = new LinkJavaScript(&obj3);
     118    obj3.free();
     119
    96120  // unknown action
    97121  } else if (obj2.isName()) {
     
    112136  }
    113137  return action;
    114 }
    115 
    116 GooString *LinkAction::getFileSpecName(Object *fileSpecObj) {
    117   GooString *name;
    118   Object obj1;
    119 
    120   name = NULL;
    121 
    122   // string
    123   if (fileSpecObj->isString()) {
    124     name = fileSpecObj->getString()->copy();
    125 
    126   // dictionary
    127   } else if (fileSpecObj->isDict()) {
    128 #ifdef WIN32
    129     if (!fileSpecObj->dictLookup("DOS", &obj1)->isString()) {
    130 #else
    131     if (!fileSpecObj->dictLookup("Unix", &obj1)->isString()) {
    132 #endif
    133       obj1.free();
    134       fileSpecObj->dictLookup("F", &obj1);
    135     }
    136     if (obj1.isString()) {
    137       name = obj1.getString()->copy();
    138     } else {
    139       error(-1, "Illegal file spec in link");
    140     }
    141     obj1.free();
    142 
    143   // error
    144   } else {
    145     error(-1, "Illegal file spec in link");
    146   }
    147 
    148   // system-dependent path manipulation
    149   if (name) {
    150 #ifdef WIN32
    151     int i, j;
    152 
    153     // "//...."             --> "\...."
    154     // "/x/...."            --> "x:\...."
    155     // "/server/share/...." --> "\\server\share\...."
    156     // convert escaped slashes to slashes and unescaped slashes to backslashes
    157     i = 0;
    158     if (name->getChar(0) == '/') {
    159       if (name->getLength() >= 2 && name->getChar(1) == '/') {
    160         name->del(0);
    161         i = 0;
    162       } else if (name->getLength() >= 2 &&
    163                  ((name->getChar(1) >= 'a' && name->getChar(1) <= 'z') ||
    164                   (name->getChar(1) >= 'A' && name->getChar(1) <= 'Z')) &&
    165                  (name->getLength() == 2 || name->getChar(2) == '/')) {
    166         name->setChar(0, name->getChar(1));
    167         name->setChar(1, ':');
    168         i = 2;
    169       } else {
    170         for (j = 2; j < name->getLength(); ++j) {
    171           if (name->getChar(j-1) != '\\' &&
    172               name->getChar(j) == '/') {
    173             break;
    174           }
    175         }
    176         if (j < name->getLength()) {
    177           name->setChar(0, '\\');
    178           name->insert(0, '\\');
    179           i = 2;
    180         }
    181       }
    182     }
    183     for (; i < name->getLength(); ++i) {
    184       if (name->getChar(i) == '/') {
    185         name->setChar(i, '\\');
    186       } else if (name->getChar(i) == '\\' &&
    187                  i+1 < name->getLength() &&
    188                  name->getChar(i+1) == '/') {
    189         name->del(i);
    190       }
    191     }
    192 #else
    193     // no manipulation needed for Unix
    194 #endif
    195   }
    196 
    197   return name;
    198138}
    199139
     
    483423
    484424  // get file name
    485   fileName = getFileSpecName(fileSpecObj);
     425  Object obj1;
     426  getFileSpecNameForPlatform (fileSpecObj, &obj1);
     427  fileName = obj1.getString()->copy();
     428  obj1.free();
    486429
    487430  // named destination
     
    520463
    521464LinkLaunch::LinkLaunch(Object *actionObj) {
    522   Object obj1, obj2;
     465  Object obj1, obj2, obj3;
    523466
    524467  fileName = NULL;
     
    527470  if (actionObj->isDict()) {
    528471    if (!actionObj->dictLookup("F", &obj1)->isNull()) {
    529       fileName = getFileSpecName(&obj1);
     472      getFileSpecNameForPlatform (&obj1, &obj3);
     473      fileName = obj3.getString()->copy();
     474      obj3.free();
    530475    } else {
    531476      obj1.free();
     
    533478      if (actionObj->dictLookup("Win", &obj1)->isDict()) {
    534479        obj1.dictLookup("F", &obj2);
    535         fileName = getFileSpecName(&obj2);
     480        getFileSpecNameForPlatform (&obj2, &obj3);
     481        fileName = obj3.getString()->copy();
     482        obj3.free();
    536483        obj2.free();
    537484        if (obj1.dictLookup("P", &obj2)->isString()) {
     
    547494      if (actionObj->dictLookup("Unix", &obj1)->isDict()) {
    548495        obj1.dictLookup("F", &obj2);
    549         fileName = getFileSpecName(&obj2);
     496        getFileSpecNameForPlatform (&obj2, &obj3);
     497        fileName = obj3.getString()->copy();
     498        obj3.free();
    550499        obj2.free();
    551500        if (obj1.dictLookup("P", &obj2)->isString()) {
     
    780729
    781730//------------------------------------------------------------------------
     731// LinkJavaScript
     732//------------------------------------------------------------------------
     733
     734LinkJavaScript::LinkJavaScript(Object *jsObj) {
     735  js = NULL;
     736
     737  if (jsObj->isString()) {
     738    js = new GooString(jsObj->getString());
     739  }
     740  else if (jsObj->isStream()) {
     741    Stream *stream = jsObj->getStream();
     742    js = new GooString();
     743    stream->reset();
     744    int i;
     745    while ((i = stream->getChar()) != EOF) {
     746      js->append((char)i);
     747    }
     748  }
     749}
     750
     751LinkJavaScript::~LinkJavaScript() {
     752  if (js) {
     753    delete js;
     754  }
     755}
     756
     757//------------------------------------------------------------------------
    782758// LinkUnknown
    783759//------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.