|
|
|
|
@ -58,6 +58,20 @@ bool PopplerGlibDocument::equals(XojPdfDocumentInterface* doc) |
|
|
|
|
return document == ((PopplerGlibDocument*)doc)->document; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
string pathToUri(path filename, GError** error) |
|
|
|
|
{ |
|
|
|
|
char * uri = g_filename_to_uri(filename.c_str(), NULL, error); |
|
|
|
|
|
|
|
|
|
if (uri == NULL) |
|
|
|
|
{ |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
string uriString = uri; |
|
|
|
|
g_free(uri); |
|
|
|
|
return uriString; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool PopplerGlibDocument::save(path filename, GError** error) |
|
|
|
|
{ |
|
|
|
|
XOJ_CHECK_TYPE(PopplerGlibDocument); |
|
|
|
|
@ -67,15 +81,11 @@ bool PopplerGlibDocument::save(path filename, GError** error) |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
string uri = "file://"; |
|
|
|
|
uri += filename.string(); |
|
|
|
|
|
|
|
|
|
#if WIN32 |
|
|
|
|
StringUtils::replace_all_chars(uri, { |
|
|
|
|
replace_pair('\\', "/"), |
|
|
|
|
}); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
string uri = pathToUri(filename, error); |
|
|
|
|
if (*error != NULL) |
|
|
|
|
{ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return poppler_document_save(document, uri.c_str(), error); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -83,17 +93,13 @@ bool PopplerGlibDocument::load(path filename, string password, GError** error) |
|
|
|
|
{ |
|
|
|
|
XOJ_CHECK_TYPE(PopplerGlibDocument); |
|
|
|
|
|
|
|
|
|
string uri = "file://"; |
|
|
|
|
uri += filename.string(); |
|
|
|
|
|
|
|
|
|
#if WIN32 |
|
|
|
|
StringUtils::replace_all_chars(uri, { |
|
|
|
|
replace_pair('\\', "/"), |
|
|
|
|
}); |
|
|
|
|
#endif |
|
|
|
|
string uri = pathToUri(filename, error); |
|
|
|
|
if (*error != NULL) |
|
|
|
|
{ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this->document = poppler_document_new_from_file(uri.c_str(), password.c_str(), error); |
|
|
|
|
|
|
|
|
|
return this->document != NULL; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|