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/PopplerCache.cc

    r277 r461  
    66//
    77// Copyright (C) 2009 Koji Otani <sho@bbr.jp>
    8 // Copyright (C) 2009 Albert Astals Cid <aacid@kde.org>
     8// Copyright (C) 2009, 2010 Albert Astals Cid <aacid@kde.org>
     9// Copyright (C) 2010 Carlos Garcia Campos <carlosgc@gnome.org>
    910//
    1011//========================================================================
    1112
    1213#include "PopplerCache.h"
     14
     15#include "XRef.h"
    1316
    1417PopplerCacheKey::~PopplerCacheKey()
     
    101104  return keys[index];
    102105}
     106
     107class ObjectKey : public PopplerCacheKey {
     108  public:
     109    ObjectKey(int numA, int genA) : num(numA), gen(genA)
     110    {
     111    }
     112
     113    bool operator==(const PopplerCacheKey &key) const
     114    {
     115      const ObjectKey *k = static_cast<const ObjectKey*>(&key);
     116      return k->num == num && k->gen == gen;
     117    }
     118
     119    int num, gen;
     120};
     121
     122class ObjectItem : public PopplerCacheItem {
     123  public:
     124    ObjectItem(Object *obj)
     125    {
     126      obj->copy(&item);
     127    }
     128
     129    ~ObjectItem()
     130    {
     131      item.free();
     132    }
     133
     134    Object item;
     135};
     136
     137PopplerObjectCache::PopplerObjectCache(int cacheSize, XRef *xrefA) {
     138  cache = new PopplerCache (cacheSize);
     139  xref = xrefA;
     140}
     141
     142PopplerObjectCache::~PopplerObjectCache() {
     143  delete cache;
     144}
     145
     146Object *PopplerObjectCache::put(const Ref &ref) {
     147  Object obj;
     148  xref->fetch(ref.num, ref.gen, &obj);
     149
     150  ObjectKey *key = new ObjectKey(ref.num, ref.gen);
     151  ObjectItem *item = new ObjectItem(&obj);
     152  cache->put(key, item);
     153  obj.free();
     154
     155  return &item->item;
     156}
     157
     158Object *PopplerObjectCache::lookup(const Ref &ref, Object *obj) {
     159  ObjectKey key(ref.num, ref.gen);
     160  ObjectItem *item = static_cast<ObjectItem *>(cache->lookup(key));
     161
     162  return item ? item->item.copy(obj) : obj->initNull();
     163}
Note: See TracChangeset for help on using the changeset viewer.