From ab361b2efb10e1cf71c11b31bf948eca6126e4de Mon Sep 17 00:00:00 2001 From: Matthew Wilber Date: Sun, 3 Aug 2003 13:04:07 +0000 Subject: [PATCH] Changed identify string to include index of identified page and count of pages so that even when this translator is used with programs that don't support multiple pages, the user can see how many pages the TIFF has and what page is currently active. Also, fixed issue when ioExtension is supplied, but does not contain "/documentIndex" which caused B_NO_TRANSLATOR to be returned. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4217 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../libtifftranslator/TIFFTranslator.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/add-ons/translators/libtifftranslator/TIFFTranslator.cpp b/src/add-ons/translators/libtifftranslator/TIFFTranslator.cpp index 8f8b38cb40..96981b8afd 100644 --- a/src/add-ons/translators/libtifftranslator/TIFFTranslator.cpp +++ b/src/add-ons/translators/libtifftranslator/TIFFTranslator.cpp @@ -442,9 +442,15 @@ identify_tiff_header(BPositionIO *inSource, BMessage *ioExtension, ioExtension->AddInt32(DOCUMENT_COUNT, document_count); // Check if a document index has been specified - ioExtension->FindInt32(DOCUMENT_INDEX, &document_index); - if (document_index < 1 || document_index > document_count) + status_t fnd = ioExtension->FindInt32(DOCUMENT_INDEX, &document_index); + if (fnd == B_OK && (document_index < 1 || document_index > document_count)) + // If a document index has been supplied, and it is an invalid value, + // return failure return B_NO_TRANSLATOR; + else if (fnd != B_OK) + // If FindInt32 failed, make certain the document index + // is the default value + document_index = 1; } // identify the document the user specified or the first document @@ -458,7 +464,8 @@ identify_tiff_header(BPositionIO *inSource, BMessage *ioExtension, outInfo->quality = TIFF_IN_QUALITY; outInfo->capability = TIFF_IN_CAPABILITY; strcpy(outInfo->MIME, "image/tiff"); - strcpy(outInfo->name, "TIFF image"); + sprintf(outInfo->name, "TIFF image (page %d of %d)", + static_cast(document_index), static_cast(document_count)); } if (!poutTIFF)