summaryrefslogtreecommitdiff
path: root/poppler/LocalPDFDocBuilder.cc
blob: bd78041d6957c3b83a9139455d7ae50037b7b1a8 (plain)
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
//========================================================================
//
// LocalPDFDocBuilder.cc
//
// This file is licensed under the GPLv2 or later
//
// Copyright 2010 Hib Eris <hib@hiberis.nl>
// Copyright 2010, 2022 Albert Astals Cid <aacid@kde.org>
// Copyright 2021 Oliver Sander <oliver.sander@tu-dresden.de>
//
//========================================================================

#include <config.h>

#include "LocalPDFDocBuilder.h"

//------------------------------------------------------------------------
// LocalPDFDocBuilder
//------------------------------------------------------------------------

std::unique_ptr<PDFDoc> LocalPDFDocBuilder::buildPDFDoc(const GooString &uri, GooString *ownerPassword, GooString *userPassword, void *guiDataA)
{
    if (uri.cmpN("file://", 7) == 0) {
        std::unique_ptr<GooString> fileName(uri.copy());
        fileName->del(0, 7);
        return std::make_unique<PDFDoc>(std::move(fileName), ownerPassword, userPassword, guiDataA);
    } else {
        return std::make_unique<PDFDoc>(std::unique_ptr<GooString>(uri.copy()), ownerPassword, userPassword, guiDataA);
    }
}

bool LocalPDFDocBuilder::supports(const GooString &uri)
{
    if (uri.cmpN("file://", 7) == 0) {
        return true;
    } else if (!strstr(uri.c_str(), "://")) {
        return true;
    } else {
        return false;
    }
}