1//========================================================================
2//
3// LocalPDFDocBuilder.cc
4//
5// This file is licensed under the GPLv2 or later
6//
7// Copyright 2010 Hib Eris <hib@hiberis.nl>
8// Copyright 2010, 2022 Albert Astals Cid <aacid@kde.org>
9// Copyright 2021 Oliver Sander <oliver.sander@tu-dresden.de>
10//
11//========================================================================
12
13#include <config.h>
14
15#include "LocalPDFDocBuilder.h"
16
17//------------------------------------------------------------------------
18// LocalPDFDocBuilder
19//------------------------------------------------------------------------
20
21std::unique_ptr<PDFDoc> LocalPDFDocBuilder::buildPDFDoc(const GooString &uri, const std::optional<GooString> &ownerPassword, const std::optional<GooString> &userPassword, void *guiDataA)
22{
23 if (uri.cmpN(sA: "file://", n: 7) == 0) {
24 std::unique_ptr<GooString> fileName(uri.copy());
25 fileName->del(i: 0, n: 7);
26 return std::make_unique<PDFDoc>(args: std::move(fileName), args: ownerPassword, args: userPassword, args&: guiDataA);
27 } else {
28 return std::make_unique<PDFDoc>(args: std::unique_ptr<GooString>(uri.copy()), args: ownerPassword, args: userPassword, args&: guiDataA);
29 }
30}
31
32bool LocalPDFDocBuilder::supports(const GooString &uri)
33{
34 if (uri.cmpN(sA: "file://", n: 7) == 0) {
35 return true;
36 } else if (!strstr(haystack: uri.c_str(), needle: "://")) {
37 return true;
38 } else {
39 return false;
40 }
41}
42

source code of poppler/poppler/LocalPDFDocBuilder.cc