source: trunk/poppler/mypoppler/splash/SplashFontFile.cc @ 2

Last change on this file since 2 was 2, checked in by Eugene Romanenko, 15 years ago

First import

File size: 1.8 KB
Line 
1//========================================================================
2//
3// SplashFontFile.cc
4//
5//========================================================================
6
7#include <config.h>
8
9#ifdef USE_GCC_PRAGMAS
10#pragma implementation
11#endif
12
13#include <stdio.h>
14#include <unistd.h>
15#include "goo/gmem.h"
16#include "goo/GooString.h"
17#include "SplashFontFile.h"
18#include "SplashFontFileID.h"
19
20#ifdef VMS
21#if (__VMS_VER < 70000000)
22extern "C" int unlink(char *filename);
23#endif
24#endif
25
26//------------------------------------------------------------------------
27// SplashFontFile
28//------------------------------------------------------------------------
29
30SplashFontFile::SplashFontFile(SplashFontFileID *idA, SplashFontSrc *srcA) {
31  id = idA;
32  src = srcA;
33  src->ref();
34  refCnt = 0;
35}
36
37SplashFontFile::~SplashFontFile() {
38  src->unref();
39  delete id;
40}
41
42void SplashFontFile::incRefCnt() {
43  ++refCnt;
44}
45
46void SplashFontFile::decRefCnt() {
47  if (!--refCnt) {
48    delete this;
49  }
50}
51
52//
53
54SplashFontSrc::SplashFontSrc() {
55  isFile = gFalse;
56  deleteSrc = gFalse;
57  fileName = NULL;
58  buf = NULL;
59  refcnt = 1;
60}
61
62SplashFontSrc::~SplashFontSrc() {
63  if (deleteSrc) {
64    if (isFile) {
65      if (fileName)
66        unlink(fileName->getCString());
67    } else {
68      if (buf)
69        gfree(buf);
70    }
71  }
72
73  if (isFile && fileName)
74    delete fileName;
75}
76
77void SplashFontSrc::ref() {
78  refcnt++;
79}
80
81void SplashFontSrc::unref() {
82  if (! --refcnt)
83    delete this;
84}
85
86void SplashFontSrc::setFile(GooString *file, GBool del)
87{
88  isFile = gTrue;
89  fileName = file->copy();
90  deleteSrc = del;
91}
92
93void SplashFontSrc::setFile(const char *file, GBool del)
94{
95  isFile = gTrue;
96  fileName = new GooString(file);
97  deleteSrc = del;
98}
99
100void SplashFontSrc::setBuf(char *bufA, int bufLenA, GBool del)
101{
102  isFile = gFalse;
103  buf = bufA;
104  bufLen = bufLenA;
105  deleteSrc = del;
106}
107
Note: See TracBrowser for help on using the repository browser.