Lines 246-272
Link Here
|
246 |
// Check if the document couldn't be opened successfully and why. |
246 |
// Check if the document couldn't be opened successfully and why. |
247 |
if ( NULL == newDocument ) |
247 |
if ( NULL == newDocument ) |
248 |
{ |
248 |
{ |
249 |
// Poppler's glib wrapper passes the Poppler error code unless the |
|
|
250 |
// error is that the file is encrypted. We want to set our own |
251 |
// error code in this case. |
252 |
DocumentError errorCode = DocumentErrorNone; |
249 |
DocumentError errorCode = DocumentErrorNone; |
253 |
if ( POPPLER_ERROR == loadError->domain ) |
250 |
gchar *errorMessage = 0; |
254 |
{ |
251 |
|
255 |
errorCode = DocumentErrorEncrypted; |
252 |
// Obtain error code from Poppler. |
256 |
} |
253 |
switch ( loadError->code ) |
257 |
else |
254 |
{ |
258 |
{ |
255 |
case POPPLER_ERROR_OPEN_FILE: |
259 |
// OK, the glib's wrapper don't pass the error code directly |
256 |
case POPPLER_ERROR_INVALID: |
260 |
// from Poppler. Instead returns G_FILE_ERROR_FAILED and a |
257 |
errorCode = DocumentErrorOpenFile; |
261 |
// non translated string. |
258 |
break; |
262 |
// Maybe I'm wrong (very probable) but that's a wrong way. |
259 |
case POPPLER_ERROR_BAD_CATALOG: |
263 |
// So I'm reading the error code from the error string... |
260 |
errorCode = DocumentErrorBadCatalog; |
264 |
sscanf (loadError->message, "Failed to load document (error %d)", |
261 |
break; |
265 |
(gint *)&errorCode); |
262 |
case POPPLER_ERROR_DAMAGED: |
266 |
} |
263 |
errorCode = DocumentErrorDamaged; |
267 |
g_error_free (loadError); |
264 |
break; |
268 |
// Get our error message. |
265 |
case POPPLER_ERROR_ENCRYPTED: |
269 |
gchar *errorMessage = IDocument::getErrorMessage (errorCode); |
266 |
errorCode = DocumentErrorEncrypted; |
|
|
267 |
break; |
268 |
} |
269 |
errorMessage = IDocument::getErrorMessage (errorCode); |
270 |
g_set_error (error, |
270 |
g_set_error (error, |
271 |
EPDFVIEW_DOCUMENT_ERROR, errorCode, |
271 |
EPDFVIEW_DOCUMENT_ERROR, errorCode, |
272 |
_("Failed to load document '%s'.\n%s\n"), |
272 |
_("Failed to load document '%s'.\n%s\n"), |