source: trunk/poppler/mypoppler/poppler/PDFDocFactory.cc @ 461

Last change on this file since 461 was 461, checked in by Silvan Scherrer, 11 years ago

poppler update to 0.14.2

File size: 1.8 KB
Line 
1//========================================================================
2//
3// PDFDocFactory.cc
4//
5// This file is licensed under the GPLv2 or later
6//
7// Copyright 2010 Hib Eris <hib@hiberis.nl>
8// Copyright 2010 Albert Astals Cid <aacid@kde.org>
9//
10//========================================================================
11
12#include <config.h>
13
14#include "PDFDocFactory.h"
15
16#include "goo/GooList.h"
17#include "goo/GooString.h"
18#include "PDFDoc.h"
19#include "LocalPDFDocBuilder.h"
20#include "StdinPDFDocBuilder.h"
21#if ENABLE_LIBCURL
22#include "CurlPDFDocBuilder.h"
23#endif
24#include "ErrorCodes.h"
25
26//------------------------------------------------------------------------
27// PDFDocFactory
28//------------------------------------------------------------------------
29
30PDFDocFactory::PDFDocFactory(GooList *pdfDocBuilders)
31{
32  if (pdfDocBuilders) {
33    builders = pdfDocBuilders;
34  } else {
35    builders = new GooList();
36  }
37#if ENABLE_LIBCURL
38  builders->insert(0, new CurlPDFDocBuilder());
39#endif
40  builders->insert(0, new StdinPDFDocBuilder());
41  builders->insert(0, new LocalPDFDocBuilder());
42}
43
44PDFDocFactory::~PDFDocFactory()
45{
46  if (builders) {
47    deleteGooList(builders, PDFDocBuilder);
48  }
49}
50
51PDFDoc *
52PDFDocFactory::createPDFDoc(const GooString &uri, GooString *ownerPassword,
53                                    GooString *userPassword, void *guiDataA)
54{
55  for (int i = builders->getLength() - 1; i >= 0 ; i--) {
56    PDFDocBuilder *builder = (PDFDocBuilder *) builders->get(i);
57    if (builder->supports(uri)) {
58      return builder->buildPDFDoc(uri, ownerPassword, userPassword, guiDataA);
59    }
60  }
61
62  error(-1, "Cannot handle URI '%s'.", uri.getCString());
63  GooString *fileName = uri.copy();
64  return PDFDoc::ErrorPDFDoc(errOpenFile, fileName);
65}
66
67void PDFDocFactory::registerPDFDocBuilder(PDFDocBuilder *pdfDocBuilder)
68{
69  builders->append(pdfDocBuilder);
70}
71
72
Note: See TracBrowser for help on using the repository browser.