forked from tsdgeos/poppler_mirror
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCurlPDFDocBuilder.cc
46 lines (37 loc) · 1.52 KB
/
CurlPDFDocBuilder.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//========================================================================
//
// CurlPDFDocBuilder.cc
//
// This file is licensed under the GPLv2 or later
//
// Copyright 2010 Hib Eris <[email protected]>
// Copyright 2010, 2017, 2022 Albert Astals Cid <[email protected]>
// Copyright 2021 Oliver Sander <[email protected]>
//
//========================================================================
#include <config.h>
#include "CurlPDFDocBuilder.h"
#include "CachedFile.h"
#include "CurlCachedFile.h"
#include "ErrorCodes.h"
//------------------------------------------------------------------------
// CurlPDFDocBuilder
//------------------------------------------------------------------------
std::unique_ptr<PDFDoc> CurlPDFDocBuilder::buildPDFDoc(const GooString &uri, const std::optional<GooString> &ownerPassword, const std::optional<GooString> &userPassword, void *guiDataA)
{
CachedFile *cachedFile = new CachedFile(new CurlCachedFileLoader(uri.toStr()));
if (cachedFile->getLength() == ((unsigned int)-1)) {
cachedFile->decRefCnt();
return PDFDoc::ErrorPDFDoc(errOpenFile, std::unique_ptr<GooString>(uri.copy()));
}
BaseStream *str = new CachedFileStream(cachedFile, 0, false, cachedFile->getLength(), Object(objNull));
return std::make_unique<PDFDoc>(str, ownerPassword, userPassword, guiDataA);
}
bool CurlPDFDocBuilder::supports(const GooString &uri)
{
if (uri.cmpN("http://", 7) == 0 || uri.cmpN("https://", 8) == 0) {
return true;
} else {
return false;
}
}