diff options
Diffstat (limited to 'Libraries external/VFR Pdf Reader/Sources')
40 files changed, 0 insertions, 7342 deletions
diff --git a/Libraries external/VFR Pdf Reader/Sources/CGPDFDocument.h b/Libraries external/VFR Pdf Reader/Sources/CGPDFDocument.h deleted file mode 100755 index 8c6ad80cb..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/CGPDFDocument.h +++ /dev/null @@ -1,39 +0,0 @@ -// -// CGPDFDocument.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <Foundation/Foundation.h> -#import <QuartzCore/QuartzCore.h> - -// -// Custom CGPDFDocument[...] functions -// - -CGPDFDocumentRef CGPDFDocumentCreateUsingUrl(CFURLRef theURL, NSString *password); - -CGPDFDocumentRef CGPDFDocumentCreateUsingData(CGDataProviderRef dataProvider, NSString *password); - -BOOL CGPDFDocumentUrlNeedsPassword(CFURLRef theURL, NSString *password); - -BOOL CGPDFDocumentDataNeedsPassword(CGDataProviderRef dataProvider, NSString *password); diff --git a/Libraries external/VFR Pdf Reader/Sources/CGPDFDocument.m b/Libraries external/VFR Pdf Reader/Sources/CGPDFDocument.m deleted file mode 100755 index 20c6b63fa..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/CGPDFDocument.m +++ /dev/null @@ -1,242 +0,0 @@ -// -// CGPDFDocument.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "CGPDFDocument.h" - -// -// CGPDFDocumentRef CGPDFDocumentCreateUsingUrl(CFURLRef, NSString *) function -// - -CGPDFDocumentRef CGPDFDocumentCreateUsingUrl(CFURLRef theURL, NSString *password) -{ - CGPDFDocumentRef thePDFDocRef = NULL; // CGPDFDocument - - if (theURL != NULL) // Check for non-NULL CFURLRef - { - thePDFDocRef = CGPDFDocumentCreateWithURL(theURL); - - if (thePDFDocRef != NULL) // Check for non-NULL CGPDFDocumentRef - { - if (CGPDFDocumentIsEncrypted(thePDFDocRef) == TRUE) // Encrypted - { - // Try a blank password first, per Apple's Quartz PDF example - - if (CGPDFDocumentUnlockWithPassword(thePDFDocRef, "") == FALSE) - { - // Nope, now let's try the provided password to unlock the PDF - - if ((password != nil) && (password.length > 0)) // Not blank? - { - char text[128]; // char array buffer for the string conversion - - [password getCString:text maxLength:126 encoding:NSUTF8StringEncoding]; - - if (CGPDFDocumentUnlockWithPassword(thePDFDocRef, text) == FALSE) // Log failure - { - #ifdef DEBUG - NSLog(@"CGPDFDocumentCreateUsingUrl: Unable to unlock [%@] with [%@]", theURL, password); - #endif - } - } - } - - if (CGPDFDocumentIsUnlocked(thePDFDocRef) == FALSE) // Cleanup unlock failure - { - CGPDFDocumentRelease(thePDFDocRef), thePDFDocRef = NULL; - } - } - } - } - else // Log an error diagnostic - { - #ifdef DEBUG - NSLog(@"CGPDFDocumentCreateUsingUrl: theURL == NULL"); - #endif - } - - return thePDFDocRef; -} - -// -// CGPDFDocumentRef CGPDFDocumentCreateUsingData(CGDataProviderRef, NSString *) function -// - -CGPDFDocumentRef CGPDFDocumentCreateUsingData(CGDataProviderRef dataProvider, NSString *password) -{ - CGPDFDocumentRef thePDFDocRef = NULL; // CGPDFDocument - - if (dataProvider != NULL) // Check for non-NULL CGDataProviderRef - { - thePDFDocRef = CGPDFDocumentCreateWithProvider(dataProvider); - - if (thePDFDocRef != NULL) // Check for non-NULL CGPDFDocumentRef - { - if (CGPDFDocumentIsEncrypted(thePDFDocRef) == TRUE) // Encrypted - { - // Try a blank password first, per Apple's Quartz PDF example - - if (CGPDFDocumentUnlockWithPassword(thePDFDocRef, "") == FALSE) - { - // Nope, now let's try the provided password to unlock the PDF - - if ((password != nil) && (password.length > 0)) // Not blank? - { - char text[128]; // char array buffer for the string conversion - - [password getCString:text maxLength:126 encoding:NSUTF8StringEncoding]; - - if (CGPDFDocumentUnlockWithPassword(thePDFDocRef, text) == FALSE) // Log failure - { - #ifdef DEBUG - NSLog(@"CGPDFDocumentCreateUsingData: Unable to unlock data with '%@'", password); - #endif - } - } - } - - if (CGPDFDocumentIsUnlocked(thePDFDocRef) == FALSE) // Cleanup unlock failure - { - CGPDFDocumentRelease(thePDFDocRef), thePDFDocRef = NULL; - } - } - } - } - else // Log an error diagnostic - { - #ifdef DEBUG - NSLog(@"CGPDFDocumentCreateUsingData: theURL == NULL"); - #endif - } - - return thePDFDocRef; -} - -// -// BOOL CGPDFDocumentUrlNeedsPassword(CFURLRef, NSString *) function -// - -BOOL CGPDFDocumentUrlNeedsPassword(CFURLRef theURL, NSString *password) -{ - BOOL needPassword = NO; // Default flag - - if (theURL != NULL) // Check for non-NULL CFURLRef - { - CGPDFDocumentRef thePDFDocRef = CGPDFDocumentCreateWithURL(theURL); - - if (thePDFDocRef != NULL) // Check for non-NULL CGPDFDocumentRef - { - if (CGPDFDocumentIsEncrypted(thePDFDocRef) == TRUE) // Encrypted - { - // Try a blank password first, per Apple's Quartz PDF example - - if (CGPDFDocumentUnlockWithPassword(thePDFDocRef, "") == FALSE) - { - // Nope, now let's try the provided password to unlock the PDF - - if ((password != nil) && (password.length > 0)) // Not blank? - { - char text[128]; // char array buffer for the string conversion - - [password getCString:text maxLength:126 encoding:NSUTF8StringEncoding]; - - if (CGPDFDocumentUnlockWithPassword(thePDFDocRef, text) == FALSE) - { - needPassword = YES; - } - } - else - { - needPassword = YES; - } - } - } - - CGPDFDocumentRelease(thePDFDocRef); // Cleanup CGPDFDocumentRef - } - } - else // Log an error diagnostic - { - #ifdef DEBUG - NSLog(@"CGPDFDocumentUrlNeedsPassword: theURL == NULL"); - #endif - } - - return needPassword; -} - -// -// BOOL CGPDFDocumentUrlNeedsPassword(CGDataProviderRef, NSString *) function -// - -BOOL CGPDFDocumentDataNeedsPassword(CGDataProviderRef dataProvider, NSString *password) -{ - BOOL needPassword = NO; // Default flag - - if (dataProvider != NULL) // Check for non-NULL CGDataProviderRef - { - CGPDFDocumentRef thePDFDocRef = CGPDFDocumentCreateWithProvider(dataProvider); - - if (thePDFDocRef != NULL) // Check for non-NULL CGPDFDocumentRef - { - if (CGPDFDocumentIsEncrypted(thePDFDocRef) == TRUE) // Encrypted - { - // Try a blank password first, per Apple's Quartz PDF example - - if (CGPDFDocumentUnlockWithPassword(thePDFDocRef, "") == FALSE) - { - // Nope, now let's try the provided password to unlock the PDF - - if ((password != nil) && (password.length > 0)) // Not blank? - { - char text[128]; // char array buffer for the string conversion - - [password getCString:text maxLength:126 encoding:NSUTF8StringEncoding]; - - if (CGPDFDocumentUnlockWithPassword(thePDFDocRef, text) == FALSE) - { - needPassword = YES; - } - } - else - { - needPassword = YES; - } - } - } - - CGPDFDocumentRelease(thePDFDocRef); // Cleanup CGPDFDocumentRef - } - } - else // Log an error diagnostic - { - #ifdef DEBUG - NSLog(@"CGPDFDocumentUrlNeedsPassword: theURL == NULL"); - #endif - } - - return needPassword; -} - -// EOF diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderConstants.h b/Libraries external/VFR Pdf Reader/Sources/ReaderConstants.h deleted file mode 100755 index 3d1b06da0..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderConstants.h +++ /dev/null @@ -1,39 +0,0 @@ -// -// ReaderConstants.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#if !__has_feature(objc_arc) - #error ARC (-fobjc-arc) is required to build this code. -#endif - -#import <Foundation/Foundation.h> - -#define READER_FLAT_UI TRUE -#define READER_SHOW_SHADOWS TRUE -#define READER_ENABLE_THUMBS TRUE -#define READER_DISABLE_RETINA FALSE -#define READER_ENABLE_PREVIEW TRUE -#define READER_DISABLE_IDLE FALSE -#define READER_STANDALONE TRUE -#define READER_BOOKMARKS TRUE diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderConstants.m b/Libraries external/VFR Pdf Reader/Sources/ReaderConstants.m deleted file mode 100755 index cb11f9886..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderConstants.m +++ /dev/null @@ -1,28 +0,0 @@ -// -// ReaderConstants.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderConstants.h" - -static NSString *const kReaderCopyrightNotice = @"Reader v2.x.y • Copyright © 2011-2015 Julius Oklamcak. All rights reserved."; diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderContentPage.h b/Libraries external/VFR Pdf Reader/Sources/ReaderContentPage.h deleted file mode 100755 index 92f540801..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderContentPage.h +++ /dev/null @@ -1,50 +0,0 @@ -// -// ReaderContentPage.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <UIKit/UIKit.h> - -@interface ReaderContentPage : UIView - -- (instancetype)initWithURL:(NSURL *)fileURL page:(NSInteger)page password:(NSString *)phrase; - -- (id)processSingleTap:(UITapGestureRecognizer *)recognizer; - -@end - -#pragma mark - - -// -// ReaderDocumentLink class interface -// - -@interface ReaderDocumentLink : NSObject <NSObject> - -@property (nonatomic, assign, readonly) CGRect rect; - -@property (nonatomic, assign, readonly) CGPDFDictionaryRef dictionary; - -+ (instancetype)newWithRect:(CGRect)linkRect dictionary:(CGPDFDictionaryRef)linkDictionary; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderContentPage.m b/Libraries external/VFR Pdf Reader/Sources/ReaderContentPage.m deleted file mode 100755 index e6902c191..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderContentPage.m +++ /dev/null @@ -1,593 +0,0 @@ -// -// ReaderContentPage.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderConstants.h" -#import "ReaderContentPage.h" -#import "ReaderContentTile.h" -#import "CGPDFDocument.h" - -@implementation ReaderContentPage -{ - NSMutableArray *_links; - - CGPDFDocumentRef _PDFDocRef; - - CGPDFPageRef _PDFPageRef; - - NSInteger _pageAngle; - - CGFloat _pageWidth; - CGFloat _pageHeight; - - CGFloat _pageOffsetX; - CGFloat _pageOffsetY; -} - -#pragma mark - ReaderContentPage class methods - -+ (Class)layerClass -{ - return [ReaderContentTile class]; -} - -#pragma mark - ReaderContentPage PDF link methods - -- (void)highlightPageLinks -{ - if (_links.count > 0) // Add highlight views over all links - { - UIColor *hilite = [UIColor colorWithRed:0.0f green:0.0f blue:1.0f alpha:0.15f]; - - for (ReaderDocumentLink *link in _links) // Enumerate the links array - { - UIView *highlight = [[UIView alloc] initWithFrame:link.rect]; - - highlight.autoresizesSubviews = NO; - highlight.userInteractionEnabled = NO; - highlight.contentMode = UIViewContentModeRedraw; - highlight.autoresizingMask = UIViewAutoresizingNone; - highlight.backgroundColor = hilite; // Color - - [self addSubview:highlight]; - } - } -} - -- (ReaderDocumentLink *)linkFromAnnotation:(CGPDFDictionaryRef)annotationDictionary -{ - ReaderDocumentLink *documentLink = nil; // Document link object - - CGPDFArrayRef annotationRectArray = NULL; // Annotation co-ordinates array - - if (CGPDFDictionaryGetArray(annotationDictionary, "Rect", &annotationRectArray)) - { - CGPDFReal ll_x = 0.0f; CGPDFReal ll_y = 0.0f; // PDFRect lower-left X and Y - CGPDFReal ur_x = 0.0f; CGPDFReal ur_y = 0.0f; // PDFRect upper-right X and Y - - CGPDFArrayGetNumber(annotationRectArray, 0, &ll_x); // Lower-left X co-ordinate - CGPDFArrayGetNumber(annotationRectArray, 1, &ll_y); // Lower-left Y co-ordinate - - CGPDFArrayGetNumber(annotationRectArray, 2, &ur_x); // Upper-right X co-ordinate - CGPDFArrayGetNumber(annotationRectArray, 3, &ur_y); // Upper-right Y co-ordinate - - if (ll_x > ur_x) { CGPDFReal t = ll_x; ll_x = ur_x; ur_x = t; } // Normalize Xs - if (ll_y > ur_y) { CGPDFReal t = ll_y; ll_y = ur_y; ur_y = t; } // Normalize Ys - - ll_x -= _pageOffsetX; ll_y -= _pageOffsetY; // Offset lower-left co-ordinate - ur_x -= _pageOffsetX; ur_y -= _pageOffsetY; // Offset upper-right co-ordinate - - switch (_pageAngle) // Page rotation angle (in degrees) - { - case 90: // 90 degree page rotation - { - CGPDFReal swap; - swap = ll_y; ll_y = ll_x; ll_x = swap; - swap = ur_y; ur_y = ur_x; ur_x = swap; - break; - } - - case 270: // 270 degree page rotation - { - CGPDFReal swap; - swap = ll_y; ll_y = ll_x; ll_x = swap; - swap = ur_y; ur_y = ur_x; ur_x = swap; - ll_x = ((0.0f - ll_x) + _pageWidth); - ur_x = ((0.0f - ur_x) + _pageWidth); - break; - } - - case 0: // 0 degree page rotation - { - ll_y = ((0.0f - ll_y) + _pageHeight); - ur_y = ((0.0f - ur_y) + _pageHeight); - break; - } - } - - NSInteger vr_x = ll_x; NSInteger vr_w = (ur_x - ll_x); // Integer X and width - NSInteger vr_y = ll_y; NSInteger vr_h = (ur_y - ll_y); // Integer Y and height - - CGRect viewRect = CGRectMake(vr_x, vr_y, vr_w, vr_h); // View CGRect from PDFRect - - documentLink = [ReaderDocumentLink newWithRect:viewRect dictionary:annotationDictionary]; - } - - return documentLink; -} - -- (void)buildAnnotationLinksList -{ - _links = [NSMutableArray new]; // Links list array - - CGPDFArrayRef pageAnnotations = NULL; // Page annotations array - - CGPDFDictionaryRef pageDictionary = CGPDFPageGetDictionary(_PDFPageRef); - - if (CGPDFDictionaryGetArray(pageDictionary, "Annots", &pageAnnotations) == true) - { - NSInteger count = CGPDFArrayGetCount(pageAnnotations); // Number of annotations - - for (NSInteger index = 0; index < count; index++) // Iterate through all annotations - { - CGPDFDictionaryRef annotationDictionary = NULL; // PDF annotation dictionary - - if (CGPDFArrayGetDictionary(pageAnnotations, index, &annotationDictionary) == true) - { - const char *annotationSubtype = NULL; // PDF annotation subtype string - - if (CGPDFDictionaryGetName(annotationDictionary, "Subtype", &annotationSubtype) == true) - { - if (strcmp(annotationSubtype, "Link") == 0) // Found annotation subtype of 'Link' - { - ReaderDocumentLink *documentLink = [self linkFromAnnotation:annotationDictionary]; - - if (documentLink != nil) [_links insertObject:documentLink atIndex:0]; // Add link - } - } - } - } - - //[self highlightPageLinks]; // Link support debugging - } -} - -- (CGPDFArrayRef)destinationWithName:(const char *)destinationName inDestsTree:(CGPDFDictionaryRef)node -{ - CGPDFArrayRef destinationArray = NULL; - - CGPDFArrayRef limitsArray = NULL; // Limits array - - if (CGPDFDictionaryGetArray(node, "Limits", &limitsArray) == true) - { - CGPDFStringRef lowerLimit = NULL; CGPDFStringRef upperLimit = NULL; - - if (CGPDFArrayGetString(limitsArray, 0, &lowerLimit) == true) // Lower limit - { - if (CGPDFArrayGetString(limitsArray, 1, &upperLimit) == true) // Upper limit - { - const char *ll = (const char *)CGPDFStringGetBytePtr(lowerLimit); // Lower string - const char *ul = (const char *)CGPDFStringGetBytePtr(upperLimit); // Upper string - - if ((strcmp(destinationName, ll) < 0) || (strcmp(destinationName, ul) > 0)) - { - return NULL; // Destination name is outside this node's limits - } - } - } - } - - CGPDFArrayRef namesArray = NULL; // Names array - - if (CGPDFDictionaryGetArray(node, "Names", &namesArray) == true) - { - NSInteger namesCount = CGPDFArrayGetCount(namesArray); - - for (NSInteger index = 0; index < namesCount; index += 2) - { - CGPDFStringRef destName; // Destination name string - - if (CGPDFArrayGetString(namesArray, index, &destName) == true) - { - const char *dn = (const char *)CGPDFStringGetBytePtr(destName); - - if (strcmp(dn, destinationName) == 0) // Found the destination name - { - if (CGPDFArrayGetArray(namesArray, (index + 1), &destinationArray) == false) - { - CGPDFDictionaryRef destinationDictionary = NULL; // Destination dictionary - - if (CGPDFArrayGetDictionary(namesArray, (index + 1), &destinationDictionary) == true) - { - CGPDFDictionaryGetArray(destinationDictionary, "D", &destinationArray); - } - } - - return destinationArray; // Return the destination array - } - } - } - } - - CGPDFArrayRef kidsArray = NULL; // Kids array - - if (CGPDFDictionaryGetArray(node, "Kids", &kidsArray) == true) - { - NSInteger kidsCount = CGPDFArrayGetCount(kidsArray); - - for (NSInteger index = 0; index < kidsCount; index++) - { - CGPDFDictionaryRef kidNode = NULL; // Kid node dictionary - - if (CGPDFArrayGetDictionary(kidsArray, index, &kidNode) == true) // Recurse into node - { - destinationArray = [self destinationWithName:destinationName inDestsTree:kidNode]; - - if (destinationArray != NULL) return destinationArray; // Return destination array - } - } - } - - return NULL; -} - -- (id)annotationLinkTarget:(CGPDFDictionaryRef)annotationDictionary -{ - id linkTarget = nil; // Link target object - - CGPDFStringRef destName = NULL; const char *destString = NULL; - - CGPDFDictionaryRef actionDictionary = NULL; CGPDFArrayRef destArray = NULL; - - if (CGPDFDictionaryGetDictionary(annotationDictionary, "A", &actionDictionary) == true) - { - const char *actionType = NULL; // Annotation action type string - - if (CGPDFDictionaryGetName(actionDictionary, "S", &actionType) == true) - { - if (strcmp(actionType, "GoTo") == 0) // GoTo action type - { - if (CGPDFDictionaryGetArray(actionDictionary, "D", &destArray) == false) - { - CGPDFDictionaryGetString(actionDictionary, "D", &destName); - } - } - else // Handle other link action type possibility - { - if (strcmp(actionType, "URI") == 0) // URI action type - { - CGPDFStringRef uriString = NULL; // Action's URI string - - if (CGPDFDictionaryGetString(actionDictionary, "URI", &uriString) == true) - { - const char *uri = (const char *)CGPDFStringGetBytePtr(uriString); // Destination URI string - - NSString *target = [NSString stringWithCString:uri encoding:NSUTF8StringEncoding]; // NSString - UTF8 - - linkTarget = [NSURL URLWithString:[target stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; - - if (linkTarget == nil) NSLog(@"%s Bad URI '%@'", __FUNCTION__, target); - } - } - } - } - } - else // Handle other link target possibilities - { - if (CGPDFDictionaryGetArray(annotationDictionary, "Dest", &destArray) == false) - { - if (CGPDFDictionaryGetString(annotationDictionary, "Dest", &destName) == false) - { - CGPDFDictionaryGetName(annotationDictionary, "Dest", &destString); - } - } - } - - if (destName != NULL) // Handle a destination name - { - CGPDFDictionaryRef catalogDictionary = CGPDFDocumentGetCatalog(_PDFDocRef); - - CGPDFDictionaryRef namesDictionary = NULL; // Destination names in the document - - if (CGPDFDictionaryGetDictionary(catalogDictionary, "Names", &namesDictionary) == true) - { - CGPDFDictionaryRef destsDictionary = NULL; // Document destinations dictionary - - if (CGPDFDictionaryGetDictionary(namesDictionary, "Dests", &destsDictionary) == true) - { - const char *destinationName = (const char *)CGPDFStringGetBytePtr(destName); // Name - - destArray = [self destinationWithName:destinationName inDestsTree:destsDictionary]; - } - } - } - - if (destString != NULL) // Handle a destination string - { - CGPDFDictionaryRef catalogDictionary = CGPDFDocumentGetCatalog(_PDFDocRef); - - CGPDFDictionaryRef destsDictionary = NULL; // Document destinations dictionary - - if (CGPDFDictionaryGetDictionary(catalogDictionary, "Dests", &destsDictionary) == true) - { - CGPDFDictionaryRef targetDictionary = NULL; // Destination target dictionary - - if (CGPDFDictionaryGetDictionary(destsDictionary, destString, &targetDictionary) == true) - { - CGPDFDictionaryGetArray(targetDictionary, "D", &destArray); - } - } - } - - if (destArray != NULL) // Handle a destination array - { - NSInteger targetPageNumber = 0; // The target page number - - CGPDFDictionaryRef pageDictionaryFromDestArray = NULL; // Target reference - - if (CGPDFArrayGetDictionary(destArray, 0, &pageDictionaryFromDestArray) == true) - { - NSInteger pageCount = CGPDFDocumentGetNumberOfPages(_PDFDocRef); // Pages - - for (NSInteger pageNumber = 1; pageNumber <= pageCount; pageNumber++) - { - CGPDFPageRef pageRef = CGPDFDocumentGetPage(_PDFDocRef, pageNumber); - - CGPDFDictionaryRef pageDictionaryFromPage = CGPDFPageGetDictionary(pageRef); - - if (pageDictionaryFromPage == pageDictionaryFromDestArray) // Found it - { - targetPageNumber = pageNumber; break; - } - } - } - else // Try page number from array possibility - { - CGPDFInteger pageNumber = 0; // Page number in array - - if (CGPDFArrayGetInteger(destArray, 0, &pageNumber) == true) - { - targetPageNumber = (pageNumber + 1); // 1-based - } - } - - if (targetPageNumber > 0) // We have a target page number - { - linkTarget = [NSNumber numberWithInteger:targetPageNumber]; - } - } - - return linkTarget; -} - -- (id)processSingleTap:(UITapGestureRecognizer *)recognizer -{ - id result = nil; // Tap result object - - if (recognizer.state == UIGestureRecognizerStateRecognized) - { - if (_links.count > 0) // Process the single tap - { - CGPoint point = [recognizer locationInView:self]; - - for (ReaderDocumentLink *link in _links) // Enumerate links - { - if (CGRectContainsPoint(link.rect, point) == true) // Found it - { - result = [self annotationLinkTarget:link.dictionary]; break; - } - } - } - } - - return result; -} - -#pragma mark - ReaderContentPage instance methods - -- (instancetype)initWithFrame:(CGRect)frame -{ - if ((self = [super initWithFrame:frame])) - { - self.autoresizesSubviews = NO; - self.userInteractionEnabled = NO; - self.contentMode = UIViewContentModeRedraw; - self.autoresizingMask = UIViewAutoresizingNone; - self.backgroundColor = [UIColor clearColor]; - } - - return self; -} - -- (instancetype)initWithURL:(NSURL *)fileURL page:(NSInteger)page password:(NSString *)phrase -{ - CGRect viewRect = CGRectZero; // View rect - - if (fileURL != nil) // Check for non-nil file URL - { - _PDFDocRef = CGPDFDocumentCreateUsingUrl((__bridge CFURLRef)fileURL, phrase); - - if (_PDFDocRef != NULL) // Check for non-NULL CGPDFDocumentRef - { - if (page < 1) page = 1; // Check the lower page bounds - - NSInteger pages = CGPDFDocumentGetNumberOfPages(_PDFDocRef); - - if (page > pages) page = pages; // Check the upper page bounds - - _PDFPageRef = CGPDFDocumentGetPage(_PDFDocRef, page); // Get page - - if (_PDFPageRef != NULL) // Check for non-NULL CGPDFPageRef - { - CGPDFPageRetain(_PDFPageRef); // Retain the PDF page - - CGRect cropBoxRect = CGPDFPageGetBoxRect(_PDFPageRef, kCGPDFCropBox); - CGRect mediaBoxRect = CGPDFPageGetBoxRect(_PDFPageRef, kCGPDFMediaBox); - CGRect effectiveRect = CGRectIntersection(cropBoxRect, mediaBoxRect); - - _pageAngle = CGPDFPageGetRotationAngle(_PDFPageRef); // Angle - - switch (_pageAngle) // Page rotation angle (in degrees) - { - default: // Default case - case 0: case 180: // 0 and 180 degrees - { - _pageWidth = effectiveRect.size.width; - _pageHeight = effectiveRect.size.height; - _pageOffsetX = effectiveRect.origin.x; - _pageOffsetY = effectiveRect.origin.y; - break; - } - - case 90: case 270: // 90 and 270 degrees - { - _pageWidth = effectiveRect.size.height; - _pageHeight = effectiveRect.size.width; - _pageOffsetX = effectiveRect.origin.y; - _pageOffsetY = effectiveRect.origin.x; - break; - } - } - - NSInteger page_w = _pageWidth; // Integer width - NSInteger page_h = _pageHeight; // Integer height - - if (page_w % 2) page_w--; if (page_h % 2) page_h--; // Even - - viewRect.size = CGSizeMake(page_w, page_h); // View size - } - else // Error out with a diagnostic - { - CGPDFDocumentRelease(_PDFDocRef), _PDFDocRef = NULL; - - NSAssert(NO, @"CGPDFPageRef == NULL"); - } - } - else // Error out with a diagnostic - { - NSAssert(NO, @"CGPDFDocumentRef == NULL"); - } - } - else // Error out with a diagnostic - { - NSAssert(NO, @"fileURL == nil"); - } - - ReaderContentPage *view = [self initWithFrame:viewRect]; - - if (view != nil) [self buildAnnotationLinksList]; - - return view; -} - -- (void)removeFromSuperview -{ - self.layer.delegate = nil; - - //self.layer.contents = nil; - - [super removeFromSuperview]; -} - -- (void)dealloc -{ - CGPDFPageRelease(_PDFPageRef), _PDFPageRef = NULL; - - CGPDFDocumentRelease(_PDFDocRef), _PDFDocRef = NULL; -} - -#if (READER_DISABLE_RETINA == TRUE) // Option - -- (void)didMoveToWindow -{ - self.contentScaleFactor = 1.0f; // Override scale factor -} - -#endif // end of READER_DISABLE_RETINA Option - -#pragma mark - CATiledLayer delegate methods - -- (void)drawLayer:(CATiledLayer *)layer inContext:(CGContextRef)context -{ - ReaderContentPage *readerContentPage = self; // Retain self - - CGContextSetRGBFillColor(context, 1.0f, 1.0f, 1.0f, 1.0f); // White - - CGContextFillRect(context, CGContextGetClipBoundingBox(context)); // Fill - - //NSLog(@"%s %@", __FUNCTION__, NSStringFromCGRect(CGContextGetClipBoundingBox(context))); - - CGContextTranslateCTM(context, 0.0f, self.bounds.size.height); CGContextScaleCTM(context, 1.0f, -1.0f); - - CGContextConcatCTM(context, CGPDFPageGetDrawingTransform(_PDFPageRef, kCGPDFCropBox, self.bounds, 0, true)); - - //CGContextSetRenderingIntent(context, kCGRenderingIntentDefault); CGContextSetInterpolationQuality(context, kCGInterpolationDefault); - - CGContextDrawPDFPage(context, _PDFPageRef); // Render the PDF page into the context - - if (readerContentPage != nil) readerContentPage = nil; // Release self -} - -@end - -#pragma mark - - -// -// ReaderDocumentLink class implementation -// - -@implementation ReaderDocumentLink -{ - CGPDFDictionaryRef _dictionary; - - CGRect _rect; -} - -#pragma mark - Properties - -@synthesize rect = _rect; -@synthesize dictionary = _dictionary; - -#pragma mark - ReaderDocumentLink class methods - -+ (instancetype)newWithRect:(CGRect)linkRect dictionary:(CGPDFDictionaryRef)linkDictionary -{ - return [[ReaderDocumentLink alloc] initWithRect:linkRect dictionary:linkDictionary]; -} - -#pragma mark - ReaderDocumentLink instance methods - -- (instancetype)initWithRect:(CGRect)linkRect dictionary:(CGPDFDictionaryRef)linkDictionary -{ - if ((self = [super init])) - { - _dictionary = linkDictionary; - - _rect = linkRect; - } - - return self; -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderContentTile.h b/Libraries external/VFR Pdf Reader/Sources/ReaderContentTile.h deleted file mode 100755 index 6c8ba808d..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderContentTile.h +++ /dev/null @@ -1,31 +0,0 @@ -// -// ReaderContentTile.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <UIKit/UIKit.h> -#import <QuartzCore/QuartzCore.h> - -@interface ReaderContentTile : CATiledLayer - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderContentTile.m b/Libraries external/VFR Pdf Reader/Sources/ReaderContentTile.m deleted file mode 100755 index b80132357..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderContentTile.m +++ /dev/null @@ -1,71 +0,0 @@ -// -// ReaderContentTile.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderContentTile.h" - -@implementation ReaderContentTile - -#pragma mark - Constants - -#define LEVELS_OF_DETAIL 16 - -#pragma mark - ReaderContentTile class methods - -+ (CFTimeInterval)fadeDuration -{ - return 0.001; // iOS bug (flickering tiles) workaround -} - -#pragma mark - ReaderContentTile instance methods - -- (instancetype)init -{ - if ((self = [super init])) // Initialize superclass - { - self.levelsOfDetail = LEVELS_OF_DETAIL; // Zoom levels - - self.levelsOfDetailBias = (LEVELS_OF_DETAIL - 1); // Bias - - UIScreen *mainScreen = [UIScreen mainScreen]; // Main screen - - CGFloat screenScale = [mainScreen scale]; // Main screen scale - - CGRect screenBounds = [mainScreen bounds]; // Main screen bounds - - CGFloat w_pixels = (screenBounds.size.width * screenScale); - - CGFloat h_pixels = (screenBounds.size.height * screenScale); - - CGFloat max = ((w_pixels < h_pixels) ? h_pixels : w_pixels); - - CGFloat sizeOfTiles = ((max < 512.0f) ? 512.0f : 1024.0f); - - self.tileSize = CGSizeMake(sizeOfTiles, sizeOfTiles); - } - - return self; -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderContentView.h b/Libraries external/VFR Pdf Reader/Sources/ReaderContentView.h deleted file mode 100755 index 1738309c4..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderContentView.h +++ /dev/null @@ -1,66 +0,0 @@ -// -// ReaderContentView.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <UIKit/UIKit.h> - -#import "ReaderThumbView.h" - -@class ReaderContentView; -@class ReaderContentPage; -@class ReaderContentThumb; - -@protocol ReaderContentViewDelegate <NSObject> - -@required // Delegate protocols - -- (void)contentView:(ReaderContentView *)contentView touchesBegan:(NSSet *)touches; - -@end - -@interface ReaderContentView : UIScrollView - -@property (nonatomic, weak, readwrite) id <ReaderContentViewDelegate> message; - -- (instancetype)initWithFrame:(CGRect)frame fileURL:(NSURL *)fileURL page:(NSUInteger)page password:(NSString *)phrase; - -- (void)showPageThumb:(NSURL *)fileURL page:(NSInteger)page password:(NSString *)phrase guid:(NSString *)guid; - -- (id)processSingleTap:(UITapGestureRecognizer *)recognizer; - -- (void)zoomIncrement:(UITapGestureRecognizer *)recognizer; -- (void)zoomDecrement:(UITapGestureRecognizer *)recognizer; -- (void)zoomResetAnimated:(BOOL)animated; - -@end - -#pragma mark - - -// -// ReaderContentThumb class interface -// - -@interface ReaderContentThumb : ReaderThumbView - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderContentView.m b/Libraries external/VFR Pdf Reader/Sources/ReaderContentView.m deleted file mode 100755 index f6ab8421d..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderContentView.m +++ /dev/null @@ -1,402 +0,0 @@ -// -// ReaderContentView.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderConstants.h" -#import "ReaderContentView.h" -#import "ReaderContentPage.h" -#import "ReaderThumbCache.h" - -#import <QuartzCore/QuartzCore.h> - -@interface ReaderContentView () <UIScrollViewDelegate> - -@end - -@implementation ReaderContentView -{ - UIView *theContainerView; - - UIUserInterfaceIdiom userInterfaceIdiom; - - ReaderContentPage *theContentPage; - - ReaderContentThumb *theThumbView; - - CGFloat realMaximumZoom; - CGFloat tempMaximumZoom; - - BOOL zoomBounced; -} - -#pragma mark - Constants - -#define ZOOM_FACTOR 2.0f -#define ZOOM_MAXIMUM 16.0f - -#define PAGE_THUMB_LARGE 240 -#define PAGE_THUMB_SMALL 144 - -static void *ReaderContentViewContext = &ReaderContentViewContext; - -static CGFloat g_BugFixWidthInset = 0.0f; - -#pragma mark - Properties - -@synthesize message; - -#pragma mark - ReaderContentView functions - -static inline CGFloat zoomScaleThatFits(CGSize target, CGSize source) -{ - CGFloat w_scale = (target.width / (source.width + g_BugFixWidthInset)); - - CGFloat h_scale = (target.height / source.height); - - return ((w_scale < h_scale) ? w_scale : h_scale); -} - -#pragma mark - ReaderContentView class methods - -+ (void)initialize -{ - if (self == [ReaderContentView self]) // Do once - iOS 8.0 UIScrollView bug workaround - { - if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) // Not iPads - { - NSString *iosVersion = [UIDevice currentDevice].systemVersion; // iOS version as a string - - if ([@"8.0" compare:iosVersion options:NSNumericSearch] != NSOrderedDescending) // 8.0 and up - { - if ([@"8.2" compare:iosVersion options:NSNumericSearch] == NSOrderedDescending) // Below 8.2 - { - g_BugFixWidthInset = 2.0f * [[UIScreen mainScreen] scale]; // Reduce width of content view - } - } - } - } -} - -#pragma mark - ReaderContentView instance methods - -- (void)updateMinimumMaximumZoom -{ - CGFloat zoomScale = zoomScaleThatFits(self.bounds.size, theContentPage.bounds.size); - - self.minimumZoomScale = zoomScale; self.maximumZoomScale = (zoomScale * ZOOM_MAXIMUM); - - realMaximumZoom = self.maximumZoomScale; tempMaximumZoom = (realMaximumZoom * ZOOM_FACTOR); -} - -- (void)centerScrollViewContent -{ - CGFloat iw = 0.0f; CGFloat ih = 0.0f; // Content width and height insets - - CGSize boundsSize = self.bounds.size; CGSize contentSize = self.contentSize; // Sizes - - if (contentSize.width < boundsSize.width) iw = ((boundsSize.width - contentSize.width) * 0.5f); - - if (contentSize.height < boundsSize.height) ih = ((boundsSize.height - contentSize.height) * 0.5f); - - UIEdgeInsets insets = UIEdgeInsetsMake(ih, iw, ih, iw); // Create (possibly updated) content insets - - if (UIEdgeInsetsEqualToEdgeInsets(self.contentInset, insets) == false) self.contentInset = insets; -} - -- (instancetype)initWithFrame:(CGRect)frame fileURL:(NSURL *)fileURL page:(NSUInteger)page password:(NSString *)phrase -{ - if ((self = [super initWithFrame:frame])) - { - self.scrollsToTop = NO; - self.delaysContentTouches = NO; - self.showsVerticalScrollIndicator = NO; - self.showsHorizontalScrollIndicator = NO; - self.contentMode = UIViewContentModeRedraw; - self.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight); - self.backgroundColor = [UIColor clearColor]; - self.autoresizesSubviews = NO; - self.clipsToBounds = NO; - self.delegate = self; - - userInterfaceIdiom = [UIDevice currentDevice].userInterfaceIdiom; // User interface idiom - - theContentPage = [[ReaderContentPage alloc] initWithURL:fileURL page:page password:phrase]; - - if (theContentPage != nil) // Must have a valid and initialized content page - { - theContainerView = [[UIView alloc] initWithFrame:theContentPage.bounds]; - - theContainerView.autoresizesSubviews = NO; - theContainerView.userInteractionEnabled = NO; - theContainerView.contentMode = UIViewContentModeRedraw; - theContainerView.autoresizingMask = UIViewAutoresizingNone; - theContainerView.backgroundColor = [UIColor whiteColor]; - -#if (READER_SHOW_SHADOWS == TRUE) // Option - - theContainerView.layer.shadowOffset = CGSizeMake(0.0f, 0.0f); - theContainerView.layer.shadowRadius = 4.0f; theContainerView.layer.shadowOpacity = 1.0f; - theContainerView.layer.shadowPath = [UIBezierPath bezierPathWithRect:theContainerView.bounds].CGPath; - -#endif // end of READER_SHOW_SHADOWS Option - - self.contentSize = theContentPage.bounds.size; [self centerScrollViewContent]; - -#if (READER_ENABLE_PREVIEW == TRUE) // Option - - theThumbView = [[ReaderContentThumb alloc] initWithFrame:theContentPage.bounds]; // Page thumb view - - [theContainerView addSubview:theThumbView]; // Add the page thumb view to the container view - -#endif // end of READER_ENABLE_PREVIEW Option - - [theContainerView addSubview:theContentPage]; // Add the content page to the container view - - [self addSubview:theContainerView]; // Add the container view to the scroll view - - [self updateMinimumMaximumZoom]; // Update the minimum and maximum zoom scales - - self.zoomScale = self.minimumZoomScale; // Set the zoom scale to fit page content - - [self addObserver:self forKeyPath:@"frame" options:0 context:ReaderContentViewContext]; - } - - self.tag = page; // Tag the view with the page number - } - - return self; -} - -- (void)dealloc -{ - [self removeObserver:self forKeyPath:@"frame" context:ReaderContentViewContext]; -} - -- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context -{ - if (context == ReaderContentViewContext) // Our context - { - if ((object == self) && [keyPath isEqualToString:@"frame"]) - { - [self centerScrollViewContent]; // Center content - - CGFloat oldMinimumZoomScale = self.minimumZoomScale; - - [self updateMinimumMaximumZoom]; // Update zoom scale limits - - if (self.zoomScale == oldMinimumZoomScale) // Old minimum - { - self.zoomScale = self.minimumZoomScale; - } - else // Check against minimum zoom scale - { - if (self.zoomScale < self.minimumZoomScale) - { - self.zoomScale = self.minimumZoomScale; - } - else // Check against maximum zoom scale - { - if (self.zoomScale > self.maximumZoomScale) - { - self.zoomScale = self.maximumZoomScale; - } - } - } - } - } -} - -- (void)showPageThumb:(NSURL *)fileURL page:(NSInteger)page password:(NSString *)phrase guid:(NSString *)guid -{ -#if (READER_ENABLE_PREVIEW == TRUE) // Option - - CGSize size = ((userInterfaceIdiom == UIUserInterfaceIdiomPad) ? CGSizeMake(PAGE_THUMB_LARGE, PAGE_THUMB_LARGE) : CGSizeMake(PAGE_THUMB_SMALL, PAGE_THUMB_SMALL)); - - ReaderThumbRequest *request = [ReaderThumbRequest newForView:theThumbView fileURL:fileURL password:phrase guid:guid page:page size:size]; - - UIImage *image = [[ReaderThumbCache sharedInstance] thumbRequest:request priority:YES]; // Request the page thumb - - if ([image isKindOfClass:[UIImage class]]) [theThumbView showImage:image]; // Show image from cache - -#endif // end of READER_ENABLE_PREVIEW Option -} - -- (id)processSingleTap:(UITapGestureRecognizer *)recognizer -{ - return [theContentPage processSingleTap:recognizer]; -} - -- (CGRect)zoomRectForScale:(CGFloat)scale withCenter:(CGPoint)center -{ - CGRect zoomRect; // Centered zoom rect - - zoomRect.size.width = (self.bounds.size.width / scale); - zoomRect.size.height = (self.bounds.size.height / scale); - - zoomRect.origin.x = (center.x - (zoomRect.size.width * 0.5f)); - zoomRect.origin.y = (center.y - (zoomRect.size.height * 0.5f)); - - return zoomRect; -} - -- (void)zoomIncrement:(UITapGestureRecognizer *)recognizer -{ - CGFloat zoomScale = self.zoomScale; // Current zoom - - CGPoint point = [recognizer locationInView:theContentPage]; - - if (zoomScale < self.maximumZoomScale) // Zoom in - { - zoomScale *= ZOOM_FACTOR; // Zoom in by zoom factor amount - - if (zoomScale > self.maximumZoomScale) zoomScale = self.maximumZoomScale; - - CGRect zoomRect = [self zoomRectForScale:zoomScale withCenter:point]; - - [self zoomToRect:zoomRect animated:YES]; - } - else // Handle fully zoomed in - { - if (zoomBounced == NO) // Zoom bounce - { - self.maximumZoomScale = tempMaximumZoom; - - [self setZoomScale:tempMaximumZoom animated:YES]; - } - else // Zoom all the way out - { - zoomScale = self.minimumZoomScale; - - [self setZoomScale:zoomScale animated:YES]; - } - } -} - -- (void)zoomDecrement:(UITapGestureRecognizer *)recognizer -{ - CGFloat zoomScale = self.zoomScale; // Current zoom - - CGPoint point = [recognizer locationInView:theContentPage]; - - if (zoomScale > self.minimumZoomScale) // Zoom out - { - zoomScale /= ZOOM_FACTOR; // Zoom out by zoom factor amount - - if (zoomScale < self.minimumZoomScale) zoomScale = self.minimumZoomScale; - - CGRect zoomRect = [self zoomRectForScale:zoomScale withCenter:point]; - - [self zoomToRect:zoomRect animated:YES]; - } - else // Handle fully zoomed out - { - zoomScale = self.maximumZoomScale; // Full zoom in - - CGRect zoomRect = [self zoomRectForScale:zoomScale withCenter:point]; - - [self zoomToRect:zoomRect animated:YES]; - } -} - -- (void)zoomResetAnimated:(BOOL)animated -{ - if (self.zoomScale > self.minimumZoomScale) // Reset zoom - { - if (animated) [self setZoomScale:self.minimumZoomScale animated:YES]; else self.zoomScale = self.minimumZoomScale; zoomBounced = NO; - } -} - -#pragma mark - UIScrollViewDelegate methods - -- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView -{ - return theContainerView; -} - -- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale -{ - if (self.zoomScale > realMaximumZoom) // Bounce back to real maximum zoom scale - { - [self setZoomScale:realMaximumZoom animated:YES]; self.maximumZoomScale = realMaximumZoom; zoomBounced = YES; - } - else // Normal scroll view did end zooming - { - if (self.zoomScale < realMaximumZoom) zoomBounced = NO; - } -} - -- (void)scrollViewDidZoom:(UIScrollView *)scrollView -{ - [self centerScrollViewContent]; // Center content -} - -#pragma mark - UIResponder instance methods - -- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event -{ - [super touchesBegan:touches withEvent:event]; // Message superclass - - [message contentView:self touchesBegan:touches]; // Message delegate -} - -- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event -{ - [super touchesCancelled:touches withEvent:event]; // Message superclass -} - -- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event -{ - [super touchesEnded:touches withEvent:event]; // Message superclass -} - -- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event -{ - [super touchesMoved:touches withEvent:event]; // Message superclass -} - -@end - -#pragma mark - - -// -// ReaderContentThumb class implementation -// - -@implementation ReaderContentThumb - -#pragma mark - ReaderContentThumb instance methods - -- (instancetype)initWithFrame:(CGRect)frame -{ - if ((self = [super initWithFrame:frame])) // Superclass init - { - imageView.contentMode = UIViewContentModeScaleAspectFill; - - imageView.clipsToBounds = YES; // Needed for aspect fill - } - - return self; -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderDocument.h b/Libraries external/VFR Pdf Reader/Sources/ReaderDocument.h deleted file mode 100755 index a144e745b..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderDocument.h +++ /dev/null @@ -1,55 +0,0 @@ -// -// ReaderDocument.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <Foundation/Foundation.h> - -@interface ReaderDocument : NSObject <NSObject, NSCoding> - -@property (nonatomic, strong, readonly) NSString *guid; -@property (nonatomic, strong, readonly) NSDate *fileDate; -@property (nonatomic, strong, readwrite) NSDate *lastOpen; -@property (nonatomic, strong, readonly) NSNumber *fileSize; -@property (nonatomic, strong, readonly) NSNumber *pageCount; -@property (nonatomic, strong, readwrite) NSNumber *pageNumber; -@property (nonatomic, strong, readonly) NSMutableIndexSet *bookmarks; -@property (nonatomic, strong, readonly) NSString *password; -@property (nonatomic, strong, readonly) NSString *fileName; -@property (nonatomic, strong, readonly) NSURL *fileURL; - -@property (nonatomic, readonly) BOOL canEmail; -@property (nonatomic, readonly) BOOL canExport; -@property (nonatomic, readonly) BOOL canPrint; - -+ (ReaderDocument *)withDocumentFilePath:(NSString *)filePath password:(NSString *)phrase; - -+ (ReaderDocument *)unarchiveFromFileName:(NSString *)filePath password:(NSString *)phrase; - -- (instancetype)initWithFilePath:(NSString *)filePath password:(NSString *)phrase; - -- (BOOL)archiveDocumentProperties; - -- (void)updateDocumentProperties; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderDocument.m b/Libraries external/VFR Pdf Reader/Sources/ReaderDocument.m deleted file mode 100755 index ea54b04d0..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderDocument.m +++ /dev/null @@ -1,354 +0,0 @@ -// -// ReaderDocument.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderDocument.h" -#import "CGPDFDocument.h" -#import <fcntl.h> - -@interface ReaderDocument () - -@property (nonatomic, strong, readwrite) NSString *password; -@property (nonatomic, strong, readwrite) NSString *filePath; - -@end - -@implementation ReaderDocument -{ - NSString *_guid; - - NSDate *_fileDate; - - NSDate *_lastOpen; - - NSNumber *_fileSize; - - NSNumber *_pageCount; - - NSNumber *_pageNumber; - - NSMutableIndexSet *_bookmarks; - - NSString *_password; - - NSString *_fileName; - - NSString *_filePath; - - NSURL *_fileURL; -} - -#pragma mark - Properties - -@synthesize guid = _guid; -@synthesize fileDate = _fileDate; -@synthesize lastOpen = _lastOpen; -@synthesize fileSize = _fileSize; -@synthesize pageCount = _pageCount; -@synthesize pageNumber = _pageNumber; -@synthesize bookmarks = _bookmarks; -@synthesize password = _password; -@synthesize filePath = _filePath; -@dynamic fileName, fileURL; -@dynamic canEmail, canExport, canPrint; - -#pragma mark - ReaderDocument class methods - -+ (NSString *)GUID -{ - CFUUIDRef theUUID = CFUUIDCreate(NULL); - - CFStringRef theString = CFUUIDCreateString(NULL, theUUID); - - NSString *unique = [NSString stringWithString:(__bridge id)theString]; - - CFRelease(theString); CFRelease(theUUID); // Cleanup CF objects - - return unique; -} - -+ (NSString *)documentsPath -{ - NSFileManager *fileManager = [NSFileManager defaultManager]; // Singleton - - NSURL *pathURL = [fileManager URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL]; - - return [pathURL path]; // Path to the application's "~/Documents" directory -} - -+ (NSString *)applicationSupportPath -{ - NSFileManager *fileManager = [NSFileManager defaultManager]; // Singleton - - NSURL *pathURL = [fileManager URLForDirectory:NSApplicationSupportDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL]; - - return [pathURL path]; // Path to the application's "~/Library/Application Support" directory -} - -+ (NSString *)archiveFilePath:(NSString *)fileName -{ - NSFileManager *fileManager = [NSFileManager defaultManager]; // Singleton - - NSString *applicationSupportPath = [ReaderDocument applicationSupportPath]; // See above - - NSString *archivePath = [applicationSupportPath stringByAppendingPathComponent:@"Reader Metadata"]; - - [fileManager createDirectoryAtPath:archivePath withIntermediateDirectories:NO attributes:nil error:NULL]; - - NSString *archiveName = [[fileName stringByDeletingPathExtension] stringByAppendingPathExtension:@"plist"]; - - return [archivePath stringByAppendingPathComponent:archiveName]; // "{archivePath}/'fileName'.plist" -} - -+ (ReaderDocument *)unarchiveFromFileName:(NSString *)filePath password:(NSString *)phrase -{ - ReaderDocument *document = nil; // ReaderDocument object - - NSString *fileName = [filePath lastPathComponent]; // File name only - - NSString *archiveFilePath = [ReaderDocument archiveFilePath:fileName]; - - @try // Unarchive an archived ReaderDocument object from its property list - { - document = [NSKeyedUnarchiver unarchiveObjectWithFile:archiveFilePath]; - - if (document != nil) // Set the document's file path and password properties - { - document.filePath = [filePath copy]; document.password = [phrase copy]; - } - } - @catch (NSException *exception) // Exception handling (just in case O_o) - { - #ifdef DEBUG - NSLog(@"%s Caught %@: %@", __FUNCTION__, [exception name], [exception reason]); - #endif - } - - return document; -} - -+ (ReaderDocument *)withDocumentFilePath:(NSString *)filePath password:(NSString *)phrase -{ - ReaderDocument *document = nil; // ReaderDocument object - - document = [ReaderDocument unarchiveFromFileName:filePath password:phrase]; - - if (document == nil) // Unarchive failed so create a new ReaderDocument object - { - document = [[ReaderDocument alloc] initWithFilePath:filePath password:phrase]; - } - - return document; -} - -+ (BOOL)isPDF:(NSString *)filePath -{ - BOOL state = NO; - - if (filePath != nil) // Must have a file path - { - const char *path = [filePath fileSystemRepresentation]; - - int fd = open(path, O_RDONLY); // Open the file - - if (fd > 0) // We have a valid file descriptor - { - const char sig[1024]; // File signature buffer - - ssize_t len = read(fd, (void *)&sig, sizeof(sig)); - - state = (strnstr(sig, "%PDF", len) != NULL); - - close(fd); // Close the file - } - } - - return state; -} - -#pragma mark - ReaderDocument instance methods - -- (instancetype)initWithFilePath:(NSString *)filePath password:(NSString *)phrase -{ - if ((self = [super init])) // Initialize superclass first - { - if ([ReaderDocument isPDF:filePath] == YES) // Valid PDF - { - _guid = [ReaderDocument GUID]; // Create document's GUID - - _password = [phrase copy]; // Keep copy of document password - - _filePath = [filePath copy]; // Keep copy of document file path - - _pageNumber = [NSNumber numberWithInteger:1]; // Start on page one - - _bookmarks = [NSMutableIndexSet new]; // Bookmarked pages index set - - CFURLRef docURLRef = (__bridge CFURLRef)[self fileURL]; // CFURLRef from NSURL - - CGPDFDocumentRef thePDFDocRef = CGPDFDocumentCreateUsingUrl(docURLRef, _password); - - if (thePDFDocRef != NULL) // Get the total number of pages in the document - { - NSInteger pageCount = CGPDFDocumentGetNumberOfPages(thePDFDocRef); - - _pageCount = [NSNumber numberWithInteger:pageCount]; - - CGPDFDocumentRelease(thePDFDocRef); // Cleanup - } - else // Cupertino, we have a problem with the document - { - NSAssert(NO, @"CGPDFDocumentRef == NULL"); - } - - _lastOpen = [NSDate dateWithTimeIntervalSinceReferenceDate:0.0]; - - NSFileManager *fileManager = [NSFileManager defaultManager]; // Singleton - - NSDictionary *fileAttributes = [fileManager attributesOfItemAtPath:_filePath error:NULL]; - - _fileDate = [fileAttributes objectForKey:NSFileModificationDate]; // File date - - _fileSize = [fileAttributes objectForKey:NSFileSize]; // File size (bytes) - - [self archiveDocumentProperties]; // Archive ReaderDocument object - } - else // Not a valid PDF file - { - self = nil; - } - } - - return self; -} - -- (NSString *)fileName -{ - if (_fileName == nil) _fileName = [_filePath lastPathComponent]; - - return _fileName; -} - -- (NSURL *)fileURL -{ - if (_fileURL == nil) _fileURL = [[NSURL alloc] initFileURLWithPath:_filePath isDirectory:NO]; - - return _fileURL; -} - -- (BOOL)canEmail -{ - return YES; -} - -- (BOOL)canExport -{ - return NO; -} - -- (BOOL)canPrint -{ - return YES; -} - -- (BOOL)archiveDocumentProperties -{ - NSString *archiveFilePath = [ReaderDocument archiveFilePath:[self fileName]]; - - return [NSKeyedArchiver archiveRootObject:self toFile:archiveFilePath]; -} - -- (void)updateDocumentProperties -{ - CFURLRef docURLRef = (__bridge CFURLRef)[self fileURL]; // CFURLRef from NSURL - - CGPDFDocumentRef thePDFDocRef = CGPDFDocumentCreateUsingUrl(docURLRef, _password); - - if (thePDFDocRef != NULL) // Get the total number of pages in the document - { - NSInteger pageCount = CGPDFDocumentGetNumberOfPages(thePDFDocRef); - - _pageCount = [NSNumber numberWithInteger:pageCount]; - - CGPDFDocumentRelease(thePDFDocRef); // Cleanup - } - - NSFileManager *fileManager = [NSFileManager defaultManager]; // Singleton - - NSDictionary *fileAttributes = [fileManager attributesOfItemAtPath:_filePath error:NULL]; - - _fileDate = [fileAttributes objectForKey:NSFileModificationDate]; // File date - - _fileSize = [fileAttributes objectForKey:NSFileSize]; // File size (bytes) -} - -#pragma mark - NSCoding protocol methods - -- (void)encodeWithCoder:(NSCoder *)encoder -{ - [encoder encodeObject:_guid forKey:@"FileGUID"]; - - [encoder encodeObject:_fileDate forKey:@"FileDate"]; - - [encoder encodeObject:_pageCount forKey:@"PageCount"]; - - [encoder encodeObject:_pageNumber forKey:@"PageNumber"]; - - [encoder encodeObject:_bookmarks forKey:@"Bookmarks"]; - - [encoder encodeObject:_fileSize forKey:@"FileSize"]; - - [encoder encodeObject:_lastOpen forKey:@"LastOpen"]; -} - -- (instancetype)initWithCoder:(NSCoder *)decoder -{ - if ((self = [super init])) // Superclass init - { - _guid = [decoder decodeObjectForKey:@"FileGUID"]; - - _fileDate = [decoder decodeObjectForKey:@"FileDate"]; - - _pageCount = [decoder decodeObjectForKey:@"PageCount"]; - - _pageNumber = [decoder decodeObjectForKey:@"PageNumber"]; - - _bookmarks = [decoder decodeObjectForKey:@"Bookmarks"]; - - _fileSize = [decoder decodeObjectForKey:@"FileSize"]; - - _lastOpen = [decoder decodeObjectForKey:@"LastOpen"]; - - if (_guid == nil) _guid = [ReaderDocument GUID]; - - if (_bookmarks != nil) - _bookmarks = [_bookmarks mutableCopy]; - else - _bookmarks = [NSMutableIndexSet new]; - } - - return self; -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderDocumentOutline.h b/Libraries external/VFR Pdf Reader/Sources/ReaderDocumentOutline.h deleted file mode 100755 index 7fecc3918..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderDocumentOutline.h +++ /dev/null @@ -1,45 +0,0 @@ -// -// ReaderDocumentOutline.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2012-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <Foundation/Foundation.h> - -@interface ReaderDocumentOutline : NSObject <NSObject> - -+ (NSArray *)outlineFromFileURL:(NSURL *)fileURL password:(NSString *)phrase; - -+ (void)logDocumentOutlineArray:(NSArray *)array; - -@end - -@interface DocumentOutlineEntry : NSObject <NSObject> - -+ (instancetype)newWithTitle:(NSString *)title target:(id)target level:(NSInteger)level; - -@property (nonatomic, assign, readonly) NSInteger level; -@property (nonatomic, strong, readwrite) NSMutableArray *children; -@property (nonatomic, strong, readonly) NSString *title; -@property (nonatomic, strong, readonly) id target; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderDocumentOutline.m b/Libraries external/VFR Pdf Reader/Sources/ReaderDocumentOutline.m deleted file mode 100755 index 2c94ff155..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderDocumentOutline.m +++ /dev/null @@ -1,467 +0,0 @@ -// -// ReaderDocumentOutline.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2012-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderDocumentOutline.h" -#import "CGPDFDocument.h" - -@implementation ReaderDocumentOutline - -#pragma mark - Build option flags - -#define HIERARCHICAL_OUTLINE TRUE - -#pragma mark - ReaderDocumentOutline functions - -void logDictionaryEntry(const char *key, CGPDFObjectRef object, void *info) -{ - //CGPDFDictionaryApplyFunction(dictionary, logDictionaryEntry, NULL); - - NSString *kind = nil; // CGPDFObject type - - CGPDFObjectType type = CGPDFObjectGetType(object); - - switch (type) // CGPDFObjectTypes - { - case kCGPDFObjectTypeNull: - kind = @"CGPDFObjectTypeNull"; - NSLog(@"%s %@", key, kind); - break; - - case kCGPDFObjectTypeBoolean: - kind = @"CGPDFObjectTypeBoolean"; - NSLog(@"%s %@", key, kind); - break; - - case kCGPDFObjectTypeInteger: - kind = @"CGPDFObjectTypeInteger"; - NSLog(@"%s %@", key, kind); - break; - - case kCGPDFObjectTypeReal: - kind = @"CGPDFObjectTypeReal"; - NSLog(@"%s %@", key, kind); - break; - - case kCGPDFObjectTypeName: - { - kind = @"CGPDFObjectTypeName"; const char *pdfName = NULL; - - if (CGPDFObjectGetValue(object, kCGPDFObjectTypeName, &pdfName)) - { - if (pdfName != NULL) NSLog(@"%s %@ %s", key, kind, pdfName); - } - break; - } - - case kCGPDFObjectTypeString: - { - kind = @"CGPDFObjectTypeString"; CGPDFStringRef pdfString = NULL; - - if (CGPDFObjectGetValue(object, kCGPDFObjectTypeString, &pdfString)) - { - const unsigned char *string = CGPDFStringGetBytePtr(pdfString); - - if (string != NULL) NSLog(@"%s %@ %s", key, kind, string); - } - break; - } - - case kCGPDFObjectTypeArray: - kind = @"CGPDFObjectTypeArray"; - NSLog(@"%s %@", key, kind); - break; - - case kCGPDFObjectTypeDictionary: - kind = @"CGPDFObjectTypeDictionary"; - NSLog(@"%s %@", key, kind); - break; - - case kCGPDFObjectTypeStream: - kind = @"CGPDFObjectTypeStream"; - NSLog(@"%s %@", key, kind); - break; - } -} - -#pragma mark - ReaderDocumentOutline class methods - -+ (void)logDocumentOutlineArray:(NSArray *)array -{ - for (DocumentOutlineEntry *item in array) // Enumerate array entries - { - NSInteger indent = (item.level * 2); // Indent amount for NSLog output - - NSLog(@"%@%@", [@"" stringByPaddingToLength:indent withString:@" " startingAtIndex:0], item); - - [self logDocumentOutlineArray:item.children]; // Log any child entries - } -} - -+ (CGPDFArrayRef)destinationWithName:(const char *)destinationName inDestsTree:(CGPDFDictionaryRef)node -{ - CGPDFArrayRef destinationArray = NULL; - - CGPDFArrayRef limitsArray = NULL; // Limits array - - if (CGPDFDictionaryGetArray(node, "Limits", &limitsArray) == true) - { - CGPDFStringRef lowerLimit = NULL; CGPDFStringRef upperLimit = NULL; - - if (CGPDFArrayGetString(limitsArray, 0, &lowerLimit) == true) // Lower limit - { - if (CGPDFArrayGetString(limitsArray, 1, &upperLimit) == true) // Upper limit - { - const char *ll = (const char *)CGPDFStringGetBytePtr(lowerLimit); // Lower string - const char *ul = (const char *)CGPDFStringGetBytePtr(upperLimit); // Upper string - - if ((strcmp(destinationName, ll) < 0) || (strcmp(destinationName, ul) > 0)) - { - return NULL; // Destination name is outside this node's limits - } - } - } - } - - CGPDFArrayRef namesArray = NULL; // Names array - - if (CGPDFDictionaryGetArray(node, "Names", &namesArray) == true) - { - NSInteger namesCount = CGPDFArrayGetCount(namesArray); - - for (NSInteger index = 0; index < namesCount; index += 2) - { - CGPDFStringRef destName; // Destination name string - - if (CGPDFArrayGetString(namesArray, index, &destName) == true) - { - const char *dn = (const char *)CGPDFStringGetBytePtr(destName); - - if (strcmp(dn, destinationName) == 0) // Found the destination name - { - if (CGPDFArrayGetArray(namesArray, (index + 1), &destinationArray) == false) - { - CGPDFDictionaryRef destinationDictionary = NULL; // Destination dictionary - - if (CGPDFArrayGetDictionary(namesArray, (index + 1), &destinationDictionary) == true) - { - CGPDFDictionaryGetArray(destinationDictionary, "D", &destinationArray); - } - } - - return destinationArray; // Return the destination array - } - } - } - } - - CGPDFArrayRef kidsArray = NULL; // Kids array - - if (CGPDFDictionaryGetArray(node, "Kids", &kidsArray) == true) - { - NSInteger kidsCount = CGPDFArrayGetCount(kidsArray); - - for (NSInteger index = 0; index < kidsCount; index++) - { - CGPDFDictionaryRef kidNode = NULL; // Kid node dictionary - - if (CGPDFArrayGetDictionary(kidsArray, index, &kidNode) == true) // Recurse into node - { - destinationArray = [self destinationWithName:destinationName inDestsTree:kidNode]; - - if (destinationArray != NULL) return destinationArray; // Return destination array - } - } - } - - return NULL; -} - -+ (id)outlineEntryTarget:(CGPDFDictionaryRef)outlineDictionary document:(CGPDFDocumentRef)document -{ - id entryTarget = nil; // Entry target object - - CGPDFStringRef destName = NULL; const char *destString = NULL; - - CGPDFDictionaryRef actionDictionary = NULL; CGPDFArrayRef destArray = NULL; - - if (CGPDFDictionaryGetDictionary(outlineDictionary, "A", &actionDictionary) == true) - { - const char *actionType = NULL; // Outline entry action type string - - if (CGPDFDictionaryGetName(actionDictionary, "S", &actionType) == true) - { - if (strcmp(actionType, "GoTo") == 0) // GoTo action type - { - if (CGPDFDictionaryGetArray(actionDictionary, "D", &destArray) == false) - { - CGPDFDictionaryGetString(actionDictionary, "D", &destName); - } - } - else // Handle other entry action type possibility - { - if (strcmp(actionType, "URI") == 0) // URI action type - { - CGPDFStringRef uriString = NULL; // Action's URI string - - if (CGPDFDictionaryGetString(actionDictionary, "URI", &uriString) == true) - { - const char *uri = (const char *)CGPDFStringGetBytePtr(uriString); // Destination URI string - - entryTarget = [NSURL URLWithString:[NSString stringWithCString:uri encoding:NSASCIIStringEncoding]]; - } - } - } - } - } - else // Handle other entry target possibilities - { - if (CGPDFDictionaryGetArray(outlineDictionary, "Dest", &destArray) == false) - { - if (CGPDFDictionaryGetString(outlineDictionary, "Dest", &destName) == false) - { - CGPDFDictionaryGetName(outlineDictionary, "Dest", &destString); - } - } - } - - if (destName != NULL) // Handle a destination name - { - CGPDFDictionaryRef catalogDictionary = CGPDFDocumentGetCatalog(document); - - CGPDFDictionaryRef namesDictionary = NULL; // Destination names in the document - - if (CGPDFDictionaryGetDictionary(catalogDictionary, "Names", &namesDictionary) == true) - { - CGPDFDictionaryRef destsDictionary = NULL; // Document destinations dictionary - - if (CGPDFDictionaryGetDictionary(namesDictionary, "Dests", &destsDictionary) == true) - { - const char *destinationName = (const char *)CGPDFStringGetBytePtr(destName); // Name - - destArray = [self destinationWithName:destinationName inDestsTree:destsDictionary]; - } - } - } - - if (destString != NULL) // Handle a destination string - { - CGPDFDictionaryRef catalogDictionary = CGPDFDocumentGetCatalog(document); - - CGPDFDictionaryRef destsDictionary = NULL; // Document destinations dictionary - - if (CGPDFDictionaryGetDictionary(catalogDictionary, "Dests", &destsDictionary) == true) - { - CGPDFDictionaryRef targetDictionary = NULL; // Destination target dictionary - - if (CGPDFDictionaryGetDictionary(destsDictionary, destString, &targetDictionary) == true) - { - CGPDFDictionaryGetArray(targetDictionary, "D", &destArray); - } - } - } - - if (destArray != NULL) // Handle a destination array - { - NSInteger targetPageNumber = 0; // The target page number - - CGPDFDictionaryRef pageDictionaryFromDestArray = NULL; // Target reference - - if (CGPDFArrayGetDictionary(destArray, 0, &pageDictionaryFromDestArray) == true) - { - NSInteger pageCount = CGPDFDocumentGetNumberOfPages(document); // Pages - - for (NSInteger pageNumber = 1; pageNumber <= pageCount; pageNumber++) - { - CGPDFPageRef pageRef = CGPDFDocumentGetPage(document, pageNumber); - - CGPDFDictionaryRef pageDictionaryFromPage = CGPDFPageGetDictionary(pageRef); - - if (pageDictionaryFromPage == pageDictionaryFromDestArray) // Found it - { - targetPageNumber = pageNumber; break; - } - } - } - else // Try page number from array possibility - { - CGPDFInteger pageNumber = 0; // Page number in array - - if (CGPDFArrayGetInteger(destArray, 0, &pageNumber) == true) - { - targetPageNumber = (pageNumber + 1); // 1-based - } - } - - if (targetPageNumber > 0) // We have a target page number - { - entryTarget = [NSNumber numberWithInteger:targetPageNumber]; - } - } - - return entryTarget; -} - -+ (void)outlineItems:(CGPDFDictionaryRef)outlineDictionary document:(CGPDFDocumentRef)document array:(NSMutableArray *)array level:(NSInteger)level -{ - do // Loop through current level outline entries - { - DocumentOutlineEntry *outlineEntry = nil; // An entry - - CGPDFStringRef string = NULL; // Outline entry title string - - if (CGPDFDictionaryGetString(outlineDictionary, "Title", &string) == true) - { - CFStringRef title = NULL; // Actual outline title (CFObject) string - - if ((title = CGPDFStringCopyTextString(string)) != NULL) // Copy of CFObject string - { - NSString *titleString = (__bridge NSString *)title; // CFString to NSString toll-free bridge cast - - id entryTarget = [self outlineEntryTarget:outlineDictionary document:document]; // Get target object - - NSString *trimmed = [titleString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; - - outlineEntry = [DocumentOutlineEntry newWithTitle:trimmed target:entryTarget level:level]; // New entry - - [array addObject:outlineEntry]; CFRelease(title); // Add new entry and cleanup - } - } - - if (outlineEntry != nil) // Must have a current outline entry - { - CGPDFDictionaryRef childItem = NULL; // First child outline item - - if (CGPDFDictionaryGetDictionary(outlineDictionary, "First", &childItem) == true) - { -#if (HIERARCHICAL_OUTLINE == TRUE) // Option - NSMutableArray *childArray = [NSMutableArray array]; outlineEntry.children = childArray; - - [self outlineItems:childItem document:document array:childArray level:(level + 1)]; -#else // Flat - [self outlineItems:childItem document:document array:array level:(level + 1)]; - -#endif // end of HIERARCHICAL_OUTLINE Option - } - } - - } while (CGPDFDictionaryGetDictionary(outlineDictionary, "Next", &outlineDictionary) == true); -} - -+ (NSArray *)outlineFromFileURL:(NSURL *)fileURL password:(NSString *)phrase -{ - NSMutableArray *outlineArray = nil; // Mutable outline array - - if ((fileURL != nil) && [fileURL isFileURL]) // Check for valid file URL - { - CGPDFDocumentRef document = CGPDFDocumentCreateUsingUrl((__bridge CFURLRef)fileURL, phrase); - - if (document != NULL) // Check for non-NULL CGPDFDocumentRef - { - CGPDFDictionaryRef outlines = NULL; // Document's outlines - - CGPDFDictionaryRef catalog = CGPDFDocumentGetCatalog(document); - - if (CGPDFDictionaryGetDictionary(catalog, "Outlines", &outlines) == true) - { - CGPDFDictionaryRef firstItem = NULL; // First outline item entry - - if (CGPDFDictionaryGetDictionary(outlines, "First", &firstItem) == true) - { - outlineArray = [NSMutableArray array]; // Top level outline entries array - - [self outlineItems:firstItem document:document array:outlineArray level:0]; - } - } - - CGPDFDocumentRelease(document); // Cleanup - } - } - - //[self logDocumentOutlineArray:outlineArray]; // Log it - - return [outlineArray copy]; // NSArray -} - -@end - -#pragma mark - - -// -// DocumentOutlineEntry class implementation -// - -@interface DocumentOutlineEntry () - -@property (nonatomic, assign, readwrite) NSInteger level; -@property (nonatomic, strong, readwrite) NSString *title; -@property (nonatomic, strong, readwrite) id target; - -@end - -@implementation DocumentOutlineEntry -{ - NSInteger _level; - - NSMutableArray *_children; - - NSString *_title; - - id _target; -} - -#pragma mark - Properties - -@synthesize level = _level; -@synthesize children = _children; -@synthesize target = _target; -@synthesize title = _title; - -#pragma mark - DocumentOutlineEntry class methods - -+ (instancetype)newWithTitle:(NSString *)title target:(id)target level:(NSInteger)level -{ - return [[DocumentOutlineEntry alloc] initWithTitle:title target:target level:level]; -} - -#pragma mark - DocumentOutlineEntry instance methods - -- (instancetype)initWithTitle:(NSString *)title target:(id)target level:(NSInteger)level -{ - if ((self = [super init])) - { - self.title = title; self.target = target; self.level = level; - } - - return self; -} - -- (NSString *)description -{ - NSString *format = @"%@ Title = '%@', Target = '%@', Level = (%i)"; - - return [[NSString alloc] initWithFormat:format, [super description], _title, _target, _level]; -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderMainPagebar.h b/Libraries external/VFR Pdf Reader/Sources/ReaderMainPagebar.h deleted file mode 100755 index 0c8a1357a..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderMainPagebar.h +++ /dev/null @@ -1,88 +0,0 @@ -// -// ReaderMainPagebar.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <UIKit/UIKit.h> - -#import "ReaderThumbView.h" - -@class ReaderMainPagebar; -@class ReaderTrackControl; -@class ReaderPagebarThumb; -@class ReaderDocument; - -@protocol ReaderMainPagebarDelegate <NSObject> - -@required // Delegate protocols - -- (void)pagebar:(ReaderMainPagebar *)pagebar gotoPage:(NSInteger)page; - -@end - -@interface ReaderMainPagebar : UIView - -@property (nonatomic, weak, readwrite) id <ReaderMainPagebarDelegate> delegate; - -- (instancetype)initWithFrame:(CGRect)frame document:(ReaderDocument *)object; - -- (void)updatePagebar; - -- (void)hidePagebar; -- (void)showPagebar; - -@end - -#pragma mark - - -// -// ReaderTrackControl class interface -// - -@interface ReaderTrackControl : UIControl - -@property (nonatomic, assign, readonly) CGFloat value; - -@end - -#pragma mark - - -// -// ReaderPagebarThumb class interface -// - -@interface ReaderPagebarThumb : ReaderThumbView - -- (instancetype)initWithFrame:(CGRect)frame small:(BOOL)small; - -@end - -#pragma mark - - -// -// ReaderPagebarShadow class interface -// - -@interface ReaderPagebarShadow : UIView - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderMainPagebar.m b/Libraries external/VFR Pdf Reader/Sources/ReaderMainPagebar.m deleted file mode 100755 index 5a5934553..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderMainPagebar.m +++ /dev/null @@ -1,642 +0,0 @@ -// -// ReaderMainPagebar.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderConstants.h" -#import "ReaderMainPagebar.h" -#import "ReaderThumbCache.h" -#import "ReaderDocument.h" - -#import <QuartzCore/QuartzCore.h> - -@implementation ReaderMainPagebar -{ - ReaderDocument *document; - - ReaderTrackControl *trackControl; - - NSMutableDictionary *miniThumbViews; - - ReaderPagebarThumb *pageThumbView; - - UILabel *pageNumberLabel; - - UIView *pageNumberView; - - NSTimer *enableTimer; - NSTimer *trackTimer; -} - -#pragma mark - Constants - -#define THUMB_SMALL_GAP 2 -#define THUMB_SMALL_WIDTH 22 -#define THUMB_SMALL_HEIGHT 28 - -#define THUMB_LARGE_WIDTH 32 -#define THUMB_LARGE_HEIGHT 42 - -#define PAGE_NUMBER_WIDTH 96.0f -#define PAGE_NUMBER_HEIGHT 30.0f - -#define PAGE_NUMBER_SPACE_SMALL 16.0f -#define PAGE_NUMBER_SPACE_LARGE 32.0f - -#define SHADOW_HEIGHT 4.0f - -#pragma mark - Properties - -@synthesize delegate; - -#pragma mark - ReaderMainPagebar class methods - -+ (Class)layerClass -{ -#if (READER_FLAT_UI == FALSE) // Option - return [CAGradientLayer class]; -#else - return [CALayer class]; -#endif // end of READER_FLAT_UI Option -} - -#pragma mark - ReaderMainPagebar instance methods - -- (instancetype)initWithFrame:(CGRect)frame -{ - return [self initWithFrame:frame document:nil]; -} - -- (void)updatePageThumbView:(NSInteger)page -{ - NSInteger pages = [document.pageCount integerValue]; - - if (pages > 1) // Only update frame if more than one page - { - CGFloat controlWidth = trackControl.bounds.size.width; - - CGFloat useableWidth = (controlWidth - THUMB_LARGE_WIDTH); - - CGFloat stride = (useableWidth / (pages - 1)); // Page stride - - NSInteger X = (stride * (page - 1)); CGFloat pageThumbX = X; - - CGRect pageThumbRect = pageThumbView.frame; // Current frame - - if (pageThumbX != pageThumbRect.origin.x) // Only if different - { - pageThumbRect.origin.x = pageThumbX; // The new X position - - pageThumbView.frame = pageThumbRect; // Update the frame - } - } - - if (page != pageThumbView.tag) // Only if page number changed - { - pageThumbView.tag = page; [pageThumbView reuse]; // Reuse the thumb view - - CGSize size = CGSizeMake(THUMB_LARGE_WIDTH, THUMB_LARGE_HEIGHT); // Maximum thumb size - - NSURL *fileURL = document.fileURL; NSString *guid = document.guid; NSString *phrase = document.password; - - ReaderThumbRequest *request = [ReaderThumbRequest newForView:pageThumbView fileURL:fileURL password:phrase guid:guid page:page size:size]; - - UIImage *image = [[ReaderThumbCache sharedInstance] thumbRequest:request priority:YES]; // Request the thumb - - UIImage *thumb = ([image isKindOfClass:[UIImage class]] ? image : nil); [pageThumbView showImage:thumb]; - } -} - -- (void)updatePageNumberText:(NSInteger)page -{ - if (page != pageNumberLabel.tag) // Only if page number changed - { - NSInteger pages = [document.pageCount integerValue]; // Total pages - - NSString *format = NSLocalizedString(@"%i of %i", @"format"); // Format - - NSString *number = [[NSString alloc] initWithFormat:format, (int)page, (int)pages]; - - pageNumberLabel.text = number; // Update the page number label text - - pageNumberLabel.tag = page; // Update the last page number tag - } -} - -- (instancetype)initWithFrame:(CGRect)frame document:(ReaderDocument *)object -{ - assert(object != nil); // Must have a valid ReaderDocument - - if ((self = [super initWithFrame:frame])) - { - self.autoresizesSubviews = YES; - self.userInteractionEnabled = YES; - self.contentMode = UIViewContentModeRedraw; - self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin; - - if ([self.layer isKindOfClass:[CAGradientLayer class]]) - { - self.backgroundColor = [UIColor clearColor]; - - CAGradientLayer *layer = (CAGradientLayer *)self.layer; - UIColor *liteColor = [UIColor colorWithWhite:0.82f alpha:0.8f]; - UIColor *darkColor = [UIColor colorWithWhite:0.32f alpha:0.8f]; - layer.colors = [NSArray arrayWithObjects:(id)liteColor.CGColor, (id)darkColor.CGColor, nil]; - - CGRect shadowRect = self.bounds; shadowRect.size.height = SHADOW_HEIGHT; shadowRect.origin.y -= shadowRect.size.height; - - ReaderPagebarShadow *shadowView = [[ReaderPagebarShadow alloc] initWithFrame:shadowRect]; - - [self addSubview:shadowView]; // Add shadow to toolbar - } - else // Follow The Fuglyosity of Flat Fad - { - self.backgroundColor = [UIColor colorWithWhite:0.94f alpha:0.94f]; - - CGRect lineRect = self.bounds; lineRect.size.height = 1.0f; lineRect.origin.y -= lineRect.size.height; - - UIView *lineView = [[UIView alloc] initWithFrame:lineRect]; - lineView.autoresizesSubviews = NO; - lineView.userInteractionEnabled = NO; - lineView.contentMode = UIViewContentModeRedraw; - lineView.autoresizingMask = UIViewAutoresizingFlexibleWidth; - lineView.backgroundColor = [UIColor colorWithWhite:0.64f alpha:0.94f]; - [self addSubview:lineView]; - } - - CGFloat space = (([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) ? PAGE_NUMBER_SPACE_LARGE : PAGE_NUMBER_SPACE_SMALL); - CGFloat numberY = (0.0f - (PAGE_NUMBER_HEIGHT + space)); CGFloat numberX = ((self.bounds.size.width - PAGE_NUMBER_WIDTH) * 0.5f); - CGRect numberRect = CGRectMake(numberX, numberY, PAGE_NUMBER_WIDTH, PAGE_NUMBER_HEIGHT); - - pageNumberView = [[UIView alloc] initWithFrame:numberRect]; // Page numbers view - - pageNumberView.autoresizesSubviews = NO; - pageNumberView.userInteractionEnabled = NO; - pageNumberView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; - pageNumberView.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.4f]; - - pageNumberView.layer.shadowOffset = CGSizeMake(0.0f, 0.0f); - pageNumberView.layer.shadowColor = [UIColor colorWithWhite:0.0f alpha:0.6f].CGColor; - pageNumberView.layer.shadowPath = [UIBezierPath bezierPathWithRect:pageNumberView.bounds].CGPath; - pageNumberView.layer.shadowRadius = 2.0f; pageNumberView.layer.shadowOpacity = 1.0f; - - CGRect textRect = CGRectInset(pageNumberView.bounds, 4.0f, 2.0f); // Inset the text a bit - - pageNumberLabel = [[UILabel alloc] initWithFrame:textRect]; // Page numbers label - - pageNumberLabel.autoresizesSubviews = NO; - pageNumberLabel.autoresizingMask = UIViewAutoresizingNone; - pageNumberLabel.textAlignment = NSTextAlignmentCenter; - pageNumberLabel.backgroundColor = [UIColor clearColor]; - pageNumberLabel.textColor = [UIColor whiteColor]; - pageNumberLabel.font = [UIFont systemFontOfSize:16.0f]; - pageNumberLabel.shadowOffset = CGSizeMake(0.0f, 1.0f); - pageNumberLabel.shadowColor = [UIColor blackColor]; - pageNumberLabel.adjustsFontSizeToFitWidth = YES; - pageNumberLabel.minimumScaleFactor = 0.75f; - - [pageNumberView addSubview:pageNumberLabel]; // Add label view - - [self addSubview:pageNumberView]; // Add page numbers display view - - trackControl = [[ReaderTrackControl alloc] initWithFrame:self.bounds]; // Track control view - - [trackControl addTarget:self action:@selector(trackViewTouchDown:) forControlEvents:UIControlEventTouchDown]; - [trackControl addTarget:self action:@selector(trackViewValueChanged:) forControlEvents:UIControlEventValueChanged]; - [trackControl addTarget:self action:@selector(trackViewTouchUp:) forControlEvents:UIControlEventTouchUpOutside]; - [trackControl addTarget:self action:@selector(trackViewTouchUp:) forControlEvents:UIControlEventTouchUpInside]; - - [self addSubview:trackControl]; // Add the track control and thumbs view - - document = object; // Retain the document object for our use - - [self updatePageNumberText:[document.pageNumber integerValue]]; - - miniThumbViews = [NSMutableDictionary new]; // Small thumbs - } - - return self; -} - -- (void)removeFromSuperview -{ - [trackTimer invalidate]; [enableTimer invalidate]; - - [super removeFromSuperview]; -} - -- (void)layoutSubviews -{ - CGRect controlRect = CGRectInset(self.bounds, 4.0f, 0.0f); - - CGFloat thumbWidth = (THUMB_SMALL_WIDTH + THUMB_SMALL_GAP); - - NSInteger thumbs = (controlRect.size.width / thumbWidth); - - NSInteger pages = [document.pageCount integerValue]; // Pages - - if (thumbs > pages) thumbs = pages; // No more than total pages - - CGFloat controlWidth = ((thumbs * thumbWidth) - THUMB_SMALL_GAP); - - controlRect.size.width = controlWidth; // Update control width - - CGFloat widthDelta = (self.bounds.size.width - controlWidth); - - NSInteger X = (widthDelta * 0.5f); controlRect.origin.x = X; - - trackControl.frame = controlRect; // Update track control frame - - if (pageThumbView == nil) // Create the page thumb view when needed - { - CGFloat heightDelta = (controlRect.size.height - THUMB_LARGE_HEIGHT); - - NSInteger thumbY = (heightDelta * 0.5f); NSInteger thumbX = 0; // Thumb X, Y - - CGRect thumbRect = CGRectMake(thumbX, thumbY, THUMB_LARGE_WIDTH, THUMB_LARGE_HEIGHT); - - pageThumbView = [[ReaderPagebarThumb alloc] initWithFrame:thumbRect]; // Create the thumb view - - pageThumbView.layer.zPosition = 1.0f; // Z position so that it sits on top of the small thumbs - - [trackControl addSubview:pageThumbView]; // Add as the first subview of the track control - } - - [self updatePageThumbView:[document.pageNumber integerValue]]; // Update page thumb view - - NSInteger strideThumbs = (thumbs - 1); if (strideThumbs < 1) strideThumbs = 1; - - CGFloat stride = ((CGFloat)pages / (CGFloat)strideThumbs); // Page stride - - CGFloat heightDelta = (controlRect.size.height - THUMB_SMALL_HEIGHT); - - NSInteger thumbY = (heightDelta * 0.5f); NSInteger thumbX = 0; // Initial X, Y - - CGRect thumbRect = CGRectMake(thumbX, thumbY, THUMB_SMALL_WIDTH, THUMB_SMALL_HEIGHT); - - NSMutableDictionary *thumbsToHide = [miniThumbViews mutableCopy]; - - for (NSInteger thumb = 0; thumb < thumbs; thumb++) // Iterate through needed thumbs - { - NSInteger page = ((stride * thumb) + 1); if (page > pages) page = pages; // Page - - NSNumber *key = [NSNumber numberWithInteger:page]; // Page number key for thumb view - - ReaderPagebarThumb *smallThumbView = [miniThumbViews objectForKey:key]; // Thumb view - - if (smallThumbView == nil) // We need to create a new small thumb view for the page number - { - CGSize size = CGSizeMake(THUMB_SMALL_WIDTH, THUMB_SMALL_HEIGHT); // Maximum thumb size - - NSURL *fileURL = document.fileURL; NSString *guid = document.guid; NSString *phrase = document.password; - - smallThumbView = [[ReaderPagebarThumb alloc] initWithFrame:thumbRect small:YES]; // Create a small thumb view - - ReaderThumbRequest *thumbRequest = [ReaderThumbRequest newForView:smallThumbView fileURL:fileURL password:phrase guid:guid page:page size:size]; - - UIImage *image = [[ReaderThumbCache sharedInstance] thumbRequest:thumbRequest priority:NO]; // Request the thumb - - if ([image isKindOfClass:[UIImage class]]) [smallThumbView showImage:image]; // Use thumb image from cache - - [trackControl addSubview:smallThumbView]; [miniThumbViews setObject:smallThumbView forKey:key]; - } - else // Resue existing small thumb view for the page number - { - smallThumbView.hidden = NO; [thumbsToHide removeObjectForKey:key]; - - if (CGRectEqualToRect(smallThumbView.frame, thumbRect) == false) - { - smallThumbView.frame = thumbRect; // Update thumb frame - } - } - - thumbRect.origin.x += thumbWidth; // Next thumb X position - } - - [thumbsToHide enumerateKeysAndObjectsUsingBlock: // Hide unused thumbs - ^(id key, id object, BOOL *stop) - { - ReaderPagebarThumb *thumb = object; thumb.hidden = YES; - } - ]; -} - -- (void)updatePagebarViews -{ - NSInteger page = [document.pageNumber integerValue]; // # - - [self updatePageNumberText:page]; // Update page number text - - [self updatePageThumbView:page]; // Update page thumb view -} - -- (void)updatePagebar -{ - if (self.hidden == NO) // Only if visible - { - [self updatePagebarViews]; // Update views - } -} - -- (void)hidePagebar -{ - if (self.hidden == NO) // Only if visible - { - [UIView animateWithDuration:0.25 delay:0.0 - options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction - animations:^(void) - { - self.alpha = 0.0f; - } - completion:^(BOOL finished) - { - self.hidden = YES; - } - ]; - } -} - -- (void)showPagebar -{ - if (self.hidden == YES) // Only if hidden - { - [self updatePagebarViews]; // Update views first - - [UIView animateWithDuration:0.25 delay:0.0 - options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction - animations:^(void) - { - self.hidden = NO; - self.alpha = 1.0f; - } - completion:NULL - ]; - } -} - -#pragma mark - ReaderTrackControl action methods - -- (void)trackTimerFired:(NSTimer *)timer -{ - [trackTimer invalidate]; trackTimer = nil; // Cleanup timer - - if (trackControl.tag != [document.pageNumber integerValue]) // Only if different - { - [delegate pagebar:self gotoPage:trackControl.tag]; // Go to document page - } -} - -- (void)enableTimerFired:(NSTimer *)timer -{ - [enableTimer invalidate]; enableTimer = nil; // Cleanup timer - - trackControl.userInteractionEnabled = YES; // Enable track control interaction -} - -- (void)restartTrackTimer -{ - if (trackTimer != nil) { [trackTimer invalidate]; trackTimer = nil; } // Invalidate and release previous timer - - trackTimer = [NSTimer scheduledTimerWithTimeInterval:0.25 target:self selector:@selector(trackTimerFired:) userInfo:nil repeats:NO]; -} - -- (void)startEnableTimer -{ - if (enableTimer != nil) { [enableTimer invalidate]; enableTimer = nil; } // Invalidate and release previous timer - - enableTimer = [NSTimer scheduledTimerWithTimeInterval:0.25 target:self selector:@selector(enableTimerFired:) userInfo:nil repeats:NO]; -} - -- (NSInteger)trackViewPageNumber:(ReaderTrackControl *)trackView -{ - CGFloat controlWidth = trackView.bounds.size.width; // View width - - CGFloat stride = (controlWidth / [document.pageCount integerValue]); - - NSInteger page = (trackView.value / stride); // Integer page number - - return (page + 1); // + 1 -} - -- (void)trackViewTouchDown:(ReaderTrackControl *)trackView -{ - NSInteger page = [self trackViewPageNumber:trackView]; // Page - - if (page != [document.pageNumber integerValue]) // Only if different - { - [self updatePageNumberText:page]; // Update page number text - - [self updatePageThumbView:page]; // Update page thumb view - - [self restartTrackTimer]; // Start the track timer - } - - trackView.tag = page; // Start page tracking -} - -- (void)trackViewValueChanged:(ReaderTrackControl *)trackView -{ - NSInteger page = [self trackViewPageNumber:trackView]; // Page - - if (page != trackView.tag) // Only if the page number has changed - { - [self updatePageNumberText:page]; // Update page number text - - [self updatePageThumbView:page]; // Update page thumb view - - trackView.tag = page; // Update the page tracking tag - - [self restartTrackTimer]; // Restart the track timer - } -} - -- (void)trackViewTouchUp:(ReaderTrackControl *)trackView -{ - [trackTimer invalidate]; trackTimer = nil; // Cleanup - - if (trackView.tag != [document.pageNumber integerValue]) // Only if different - { - trackView.userInteractionEnabled = NO; // Disable track control interaction - - [delegate pagebar:self gotoPage:trackView.tag]; // Go to document page - - [self startEnableTimer]; // Start track control enable timer - } - - trackView.tag = 0; // Reset page tracking -} - -@end - -#pragma mark - - -// -// ReaderTrackControl class implementation -// - -@implementation ReaderTrackControl -{ - CGFloat _value; -} - -#pragma mark - Properties - -@synthesize value = _value; - -#pragma mark - ReaderTrackControl instance methods - -- (instancetype)initWithFrame:(CGRect)frame -{ - if ((self = [super initWithFrame:frame])) - { - self.autoresizesSubviews = NO; - self.userInteractionEnabled = YES; - self.contentMode = UIViewContentModeRedraw; - self.autoresizingMask = UIViewAutoresizingNone; - self.backgroundColor = [UIColor clearColor]; - self.exclusiveTouch = YES; - } - - return self; -} - -- (CGFloat)limitValue:(CGFloat)valueX -{ - CGFloat minX = self.bounds.origin.x; // 0.0f; - CGFloat maxX = (self.bounds.size.width - 1.0f); - - if (valueX < minX) valueX = minX; // Minimum X - if (valueX > maxX) valueX = maxX; // Maximum X - - return valueX; -} - -#pragma mark - UIControl subclass methods - -- (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event -{ - CGPoint point = [touch locationInView:self]; // Touch point - - _value = [self limitValue:point.x]; // Limit control value - - return YES; -} - -- (BOOL)continueTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event -{ - if (self.touchInside == YES) // Only if inside the control - { - CGPoint point = [touch locationInView:touch.view]; // Touch point - - CGFloat x = [self limitValue:point.x]; // Potential new control value - - if (x != _value) // Only if the new value has changed since the last time - { - _value = x; [self sendActionsForControlEvents:UIControlEventValueChanged]; - } - } - - return YES; -} - -- (void)endTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event -{ - CGPoint point = [touch locationInView:self]; // Touch point - - _value = [self limitValue:point.x]; // Limit control value -} - -@end - -#pragma mark - - -// -// ReaderPagebarThumb class implementation -// - -@implementation ReaderPagebarThumb - -#pragma mark - ReaderPagebarThumb instance methods - -- (instancetype)initWithFrame:(CGRect)frame -{ - return [self initWithFrame:frame small:NO]; -} - -- (instancetype)initWithFrame:(CGRect)frame small:(BOOL)small -{ - if ((self = [super initWithFrame:frame])) // Superclass init - { - CGFloat value = (small ? 0.6f : 0.7f); // Size based alpha value - - UIColor *background = [UIColor colorWithWhite:0.8f alpha:value]; - - self.backgroundColor = background; imageView.backgroundColor = background; - - imageView.layer.borderColor = [UIColor colorWithWhite:0.4f alpha:0.6f].CGColor; - - imageView.layer.borderWidth = 1.0f; // Give the thumb image view a border - } - - return self; -} - -@end - -#pragma mark - - -// -// ReaderPagebarShadow class implementation -// - -@implementation ReaderPagebarShadow - -#pragma mark - ReaderPagebarShadow class methods - -+ (Class)layerClass -{ - return [CAGradientLayer class]; -} - -#pragma mark - ReaderPagebarShadow instance methods - -- (instancetype)initWithFrame:(CGRect)frame -{ - if ((self = [super initWithFrame:frame])) - { - self.autoresizesSubviews = NO; - self.userInteractionEnabled = NO; - self.contentMode = UIViewContentModeRedraw; - self.autoresizingMask = UIViewAutoresizingFlexibleWidth; - self.backgroundColor = [UIColor clearColor]; - - CAGradientLayer *layer = (CAGradientLayer *)self.layer; - UIColor *blackColor = [UIColor colorWithWhite:0.42f alpha:1.0f]; - UIColor *clearColor = [UIColor colorWithWhite:0.42f alpha:0.0f]; - layer.colors = [NSArray arrayWithObjects:(id)clearColor.CGColor, (id)blackColor.CGColor, nil]; - } - - return self; -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderMainToolbar.h b/Libraries external/VFR Pdf Reader/Sources/ReaderMainToolbar.h deleted file mode 100755 index caf543877..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderMainToolbar.h +++ /dev/null @@ -1,57 +0,0 @@ -// -// ReaderMainToolbar.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <UIKit/UIKit.h> - -#import "UIXToolbarView.h" - -@class ReaderMainToolbar; -@class ReaderDocument; - -@protocol ReaderMainToolbarDelegate <NSObject> - -@required // Delegate protocols - -- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar doneButton:(UIButton *)button; -- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar thumbsButton:(UIButton *)button; -- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar exportButton:(UIButton *)button; -- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar printButton:(UIButton *)button; -- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar emailButton:(UIButton *)button; -- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar markButton:(UIButton *)button; - -@end - -@interface ReaderMainToolbar : UIXToolbarView - -@property (nonatomic, weak, readwrite) id <ReaderMainToolbarDelegate> delegate; - -- (instancetype)initWithFrame:(CGRect)frame document:(ReaderDocument *)document; - -- (void)setBookmarkState:(BOOL)state; - -- (void)hideToolbar; -- (void)showToolbar; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderMainToolbar.m b/Libraries external/VFR Pdf Reader/Sources/ReaderMainToolbar.m deleted file mode 100755 index d97c92eaa..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderMainToolbar.m +++ /dev/null @@ -1,360 +0,0 @@ -// -// ReaderMainToolbar.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderConstants.h" -#import "ReaderMainToolbar.h" -#import "ReaderDocument.h" - -#import <MessageUI/MessageUI.h> - -@implementation ReaderMainToolbar -{ - UIButton *markButton; - - UIImage *markImageN; - UIImage *markImageY; -} - -#pragma mark - Constants - -#define BUTTON_X 8.0f -#define BUTTON_Y 8.0f - -#define BUTTON_SPACE 8.0f -#define BUTTON_HEIGHT 30.0f - -#define BUTTON_FONT_SIZE 15.0f -#define TEXT_BUTTON_PADDING 24.0f - -#define ICON_BUTTON_WIDTH 40.0f - -#define TITLE_FONT_SIZE 19.0f -#define TITLE_HEIGHT 28.0f - -#define COLOR_BAR [UIColor colorWithRed:(248.0f/255.0f) green:(248.0f/255.0f) blue:(248.0f/255.0f) alpha:1.0] -#define COLOR_ARANCIO [UIColor colorWithRed:241.0/255.0 green:90.0/255.0 blue:34.0/255.0 alpha:1.0] - - -#pragma mark - Properties - -@synthesize delegate; - -#pragma mark - ReaderMainToolbar instance methods - -- (instancetype)initWithFrame:(CGRect)frame -{ - return [self initWithFrame:frame document:nil]; -} - -- (instancetype)initWithFrame:(CGRect)frame document:(ReaderDocument *)document -{ - assert(document != nil); // Must have a valid ReaderDocument - - if ((self = [super initWithFrame:frame])) - { - CGFloat viewWidth = self.bounds.size.width; // Toolbar view width - -#if (READER_FLAT_UI == TRUE) // Option - UIImage *buttonH = nil; UIImage *buttonN = nil; -#else - UIImage *buttonH = [[UIImage imageNamed:@"Reader-Button-H"] stretchableImageWithLeftCapWidth:5 topCapHeight:0]; - UIImage *buttonN = [[UIImage imageNamed:@"Reader-Button-N"] stretchableImageWithLeftCapWidth:5 topCapHeight:0]; -#endif // end of READER_FLAT_UI Option - - BOOL largeDevice = ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad); - - const CGFloat buttonSpacing = BUTTON_SPACE; const CGFloat iconButtonWidth = ICON_BUTTON_WIDTH; - - CGFloat titleX = BUTTON_X; CGFloat titleWidth = (viewWidth - (titleX + titleX)); - - CGFloat leftButtonX = BUTTON_X; // Left-side button start X position - -#if (READER_STANDALONE == FALSE) // Option - - UIFont *doneButtonFont = [UIFont systemFontOfSize:BUTTON_FONT_SIZE]; - NSString *doneButtonText = NSLocalizedString(@"Done", @"button"); - CGSize doneButtonSize = [doneButtonText sizeWithFont:doneButtonFont]; - CGFloat doneButtonWidth = (doneButtonSize.width + TEXT_BUTTON_PADDING); - - UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom]; - doneButton.frame = CGRectMake(leftButtonX, BUTTON_Y, doneButtonWidth, BUTTON_HEIGHT); - [doneButton setTitleColor:[UIColor colorWithWhite:0.0f alpha:1.0f] forState:UIControlStateNormal]; - [doneButton setTitleColor:[UIColor colorWithWhite:1.0f alpha:1.0f] forState:UIControlStateHighlighted]; - [doneButton setTitle:doneButtonText forState:UIControlStateNormal]; doneButton.titleLabel.font = doneButtonFont; - [doneButton addTarget:self action:@selector(doneButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; - [doneButton setBackgroundImage:buttonH forState:UIControlStateHighlighted]; - [doneButton setBackgroundImage:buttonN forState:UIControlStateNormal]; - doneButton.autoresizingMask = UIViewAutoresizingNone; - //doneButton.backgroundColor = [UIColor grayColor]; - doneButton.exclusiveTouch = YES; - - [self addSubview:doneButton]; leftButtonX += (doneButtonWidth + buttonSpacing); - - titleX += (doneButtonWidth + buttonSpacing); titleWidth -= (doneButtonWidth + buttonSpacing); - -#endif // end of READER_STANDALONE Option - -#if (READER_ENABLE_THUMBS == TRUE) // Option - - UIButton *thumbsButton = [UIButton buttonWithType:UIButtonTypeCustom]; - thumbsButton.frame = CGRectMake(leftButtonX, BUTTON_Y, iconButtonWidth, BUTTON_HEIGHT); - [thumbsButton setImage:[UIImage imageNamed:@"Reader-Thumbs"] forState:UIControlStateNormal]; - [thumbsButton addTarget:self action:@selector(thumbsButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; - [thumbsButton setBackgroundImage:buttonH forState:UIControlStateHighlighted]; - [thumbsButton setBackgroundImage:buttonN forState:UIControlStateNormal]; - thumbsButton.autoresizingMask = UIViewAutoresizingNone; - //thumbsButton.backgroundColor = [UIColor grayColor]; - thumbsButton.exclusiveTouch = YES; - - [self addSubview:thumbsButton]; //leftButtonX += (iconButtonWidth + buttonSpacing); - - titleX += (iconButtonWidth + buttonSpacing); titleWidth -= (iconButtonWidth + buttonSpacing); - -#endif // end of READER_ENABLE_THUMBS Option - - CGFloat rightButtonX = viewWidth; // Right-side buttons start X position - -#if (READER_BOOKMARKS == TRUE) // Option - - rightButtonX -= (iconButtonWidth + buttonSpacing); // Position - - UIButton *flagButton = [UIButton buttonWithType:UIButtonTypeCustom]; - flagButton.frame = CGRectMake(rightButtonX, BUTTON_Y, iconButtonWidth, BUTTON_HEIGHT); - //[flagButton setImage:[UIImage imageNamed:@"Reader-Mark-N"] forState:UIControlStateNormal]; - [flagButton addTarget:self action:@selector(markButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; - [flagButton setBackgroundImage:buttonH forState:UIControlStateHighlighted]; - [flagButton setBackgroundImage:buttonN forState:UIControlStateNormal]; - flagButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin; - //flagButton.backgroundColor = [UIColor grayColor]; - flagButton.exclusiveTouch = YES; - - [self addSubview:flagButton]; titleWidth -= (iconButtonWidth + buttonSpacing); - - markButton = flagButton; markButton.enabled = NO; markButton.tag = NSIntegerMin; - - markImageN = [UIImage imageNamed:@"Reader-Mark-N"]; // N image - markImageY = [UIImage imageNamed:@"Reader-Mark-Y"]; // Y image - -#endif // end of READER_BOOKMARKS Option - - if (document.canEmail == YES) // Document email enabled - { - if ([MFMailComposeViewController canSendMail] == YES) // Can email - { - unsigned long long fileSize = [document.fileSize unsignedLongLongValue]; - - if (fileSize < 15728640ull) // Check attachment size limit (15MB) - { - rightButtonX -= (iconButtonWidth + buttonSpacing); // Next position - - UIButton *emailButton = [UIButton buttonWithType:UIButtonTypeCustom]; - emailButton.frame = CGRectMake(rightButtonX, BUTTON_Y, iconButtonWidth, BUTTON_HEIGHT); - [emailButton setImage:[UIImage imageNamed:@"Reader-Email"] forState:UIControlStateNormal]; - [emailButton addTarget:self action:@selector(emailButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; - [emailButton setBackgroundImage:buttonH forState:UIControlStateHighlighted]; - [emailButton setBackgroundImage:buttonN forState:UIControlStateNormal]; - emailButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin; - //emailButton.backgroundColor = [UIColor grayColor]; - emailButton.exclusiveTouch = YES; - - [self addSubview:emailButton]; titleWidth -= (iconButtonWidth + buttonSpacing); - } - } - } - - if ((document.canPrint == YES) && (document.password == nil)) // Document print enabled - { - Class printInteractionController = NSClassFromString(@"UIPrintInteractionController"); - - if ((printInteractionController != nil) && [printInteractionController isPrintingAvailable]) - { - rightButtonX -= (iconButtonWidth + buttonSpacing); // Next position - - UIButton *printButton = [UIButton buttonWithType:UIButtonTypeCustom]; - printButton.frame = CGRectMake(rightButtonX, BUTTON_Y, iconButtonWidth, BUTTON_HEIGHT); - [printButton setImage:[UIImage imageNamed:@"Reader-Print"] forState:UIControlStateNormal]; - [printButton addTarget:self action:@selector(printButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; - [printButton setBackgroundImage:buttonH forState:UIControlStateHighlighted]; - [printButton setBackgroundImage:buttonN forState:UIControlStateNormal]; - printButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin; - //printButton.backgroundColor = [UIColor grayColor]; - printButton.exclusiveTouch = YES; - - [self addSubview:printButton]; titleWidth -= (iconButtonWidth + buttonSpacing); - } - } - - if (document.canExport == YES) // Document export enabled - { - rightButtonX -= (iconButtonWidth + buttonSpacing); // Next position - - UIButton *exportButton = [UIButton buttonWithType:UIButtonTypeCustom]; - exportButton.frame = CGRectMake(rightButtonX, BUTTON_Y, iconButtonWidth, BUTTON_HEIGHT); - [exportButton setImage:[UIImage imageNamed:@"Reader-Export"] forState:UIControlStateNormal]; - [exportButton addTarget:self action:@selector(exportButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; - [exportButton setBackgroundImage:buttonH forState:UIControlStateHighlighted]; - [exportButton setBackgroundImage:buttonN forState:UIControlStateNormal]; - exportButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin; - //exportButton.backgroundColor = [UIColor grayColor]; - exportButton.exclusiveTouch = YES; - - [self addSubview:exportButton]; titleWidth -= (iconButtonWidth + buttonSpacing); - } - - if (largeDevice == YES) // Show document filename in toolbar - { - CGRect titleRect = CGRectMake(titleX, BUTTON_Y, titleWidth, TITLE_HEIGHT); - - UILabel *titleLabel = [[UILabel alloc] initWithFrame:titleRect]; - - titleLabel.textAlignment = NSTextAlignmentCenter; - titleLabel.font = [UIFont systemFontOfSize:TITLE_FONT_SIZE]; - titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth; - titleLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters; - titleLabel.textColor = [UIColor colorWithWhite:0.0f alpha:1.0f]; - titleLabel.backgroundColor = [UIColor clearColor]; - titleLabel.adjustsFontSizeToFitWidth = YES; - titleLabel.minimumScaleFactor = 0.75f; - titleLabel.text = [document.fileName stringByDeletingPathExtension]; -#if (READER_FLAT_UI == FALSE) // Option - titleLabel.shadowColor = [UIColor colorWithWhite:0.75f alpha:1.0f]; - titleLabel.shadowOffset = CGSizeMake(0.0f, 1.0f); -#endif // end of READER_FLAT_UI Option - - [self addSubview:titleLabel]; - } - } - - return self; -} - -- (void)setBookmarkState:(BOOL)state -{ -#if (READER_BOOKMARKS == TRUE) // Option - - if (state != markButton.tag) // Only if different state - { - if (self.hidden == NO) // Only if toolbar is visible - { - UIImage *image = (state ? markImageY : markImageN); - - [markButton setImage:image forState:UIControlStateNormal]; - } - - markButton.tag = state; // Update bookmarked state tag - } - - if (markButton.enabled == NO) markButton.enabled = YES; - -#endif // end of READER_BOOKMARKS Option -} - -- (void)updateBookmarkImage -{ -#if (READER_BOOKMARKS == TRUE) // Option - - if (markButton.tag != NSIntegerMin) // Valid tag - { - BOOL state = markButton.tag; // Bookmarked state - - UIImage *image = (state ? markImageY : markImageN); - - [markButton setImage:image forState:UIControlStateNormal]; - } - - if (markButton.enabled == NO) markButton.enabled = YES; - -#endif // end of READER_BOOKMARKS Option -} - -- (void)hideToolbar -{ - if (self.hidden == NO) - { - [UIView animateWithDuration:0.25 delay:0.0 - options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction - animations:^(void) - { - self.alpha = 0.0f; - } - completion:^(BOOL finished) - { - self.hidden = YES; - } - ]; - } -} - -- (void)showToolbar -{ - if (self.hidden == YES) - { - [self updateBookmarkImage]; // First - - [UIView animateWithDuration:0.25 delay:0.0 - options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction - animations:^(void) - { - self.hidden = NO; - self.alpha = 1.0f; - } - completion:NULL - ]; - } -} - -#pragma mark - UIButton action methods - -- (void)doneButtonTapped:(UIButton *)button -{ - [delegate tappedInToolbar:self doneButton:button]; -} - -- (void)thumbsButtonTapped:(UIButton *)button -{ - [delegate tappedInToolbar:self thumbsButton:button]; -} - -- (void)exportButtonTapped:(UIButton *)button -{ - [delegate tappedInToolbar:self exportButton:button]; -} - -- (void)printButtonTapped:(UIButton *)button -{ - [delegate tappedInToolbar:self printButton:button]; -} - -- (void)emailButtonTapped:(UIButton *)button -{ - [delegate tappedInToolbar:self emailButton:button]; -} - -- (void)markButtonTapped:(UIButton *)button -{ - [delegate tappedInToolbar:self markButton:button]; -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbCache.h b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbCache.h deleted file mode 100755 index 948022d66..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbCache.h +++ /dev/null @@ -1,54 +0,0 @@ -// -// ReaderThumbCache.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <UIKit/UIKit.h> - -#import "ReaderThumbRequest.h" - -@interface ReaderThumbCache : NSObject <NSObject> - -+ (ReaderThumbCache *)sharedInstance; - -+ (void)touchThumbCacheWithGUID:(NSString *)guid; - -+ (void)createThumbCacheWithGUID:(NSString *)guid; - -+ (void)removeThumbCacheWithGUID:(NSString *)guid; - -+ (void)purgeThumbCachesOlderThan:(NSTimeInterval)age; - -+ (NSString *)thumbCachePathForGUID:(NSString *)guid; - -- (id)thumbRequest:(ReaderThumbRequest *)request priority:(BOOL)priority; - -- (void)setObject:(UIImage *)image forKey:(NSString *)key; - -- (void)removeObjectForKey:(NSString *)key; - -- (void)removeNullForKey:(NSString *)key; - -- (void)removeAllObjects; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbCache.m b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbCache.m deleted file mode 100755 index 5f0220460..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbCache.m +++ /dev/null @@ -1,228 +0,0 @@ -// -// ReaderThumbCache.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderThumbCache.h" -#import "ReaderThumbQueue.h" -#import "ReaderThumbFetch.h" -#import "ReaderThumbView.h" - -@implementation ReaderThumbCache -{ - NSCache *thumbCache; -} - -#pragma mark - Constants - -#define CACHE_SIZE 2097152 - -#pragma mark - ReaderThumbCache class methods - -+ (ReaderThumbCache *)sharedInstance -{ - static dispatch_once_t predicate = 0; - - static ReaderThumbCache *object = nil; // Object - - dispatch_once(&predicate, ^{ object = [self new]; }); - - return object; // ReaderThumbCache singleton -} - -+ (NSString *)appCachesPath -{ - static dispatch_once_t predicate = 0; - - static NSString *theCachesPath = nil; // Application caches path string - - dispatch_once(&predicate, // Save a copy of the application caches path the first time it is needed - ^{ - NSArray *cachesPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); - - theCachesPath = [[cachesPaths objectAtIndex:0] copy]; // Keep a copy for later abusage - }); - - return theCachesPath; -} - -+ (NSString *)thumbCachePathForGUID:(NSString *)guid -{ - NSString *cachesPath = [ReaderThumbCache appCachesPath]; // Caches path - - return [cachesPath stringByAppendingPathComponent:guid]; // Append GUID -} - -+ (void)createThumbCacheWithGUID:(NSString *)guid -{ - NSFileManager *fileManager = [NSFileManager new]; // File manager instance - - NSString *cachePath = [ReaderThumbCache thumbCachePathForGUID:guid]; // Thumb cache path - - [fileManager createDirectoryAtPath:cachePath withIntermediateDirectories:NO attributes:nil error:NULL]; -} - -+ (void)removeThumbCacheWithGUID:(NSString *)guid -{ - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), - ^{ - NSFileManager *fileManager = [NSFileManager new]; // File manager instance - - NSString *cachePath = [ReaderThumbCache thumbCachePathForGUID:guid]; // Thumb cache path - - [fileManager removeItemAtPath:cachePath error:NULL]; // Remove thumb cache directory - }); -} - -+ (void)touchThumbCacheWithGUID:(NSString *)guid -{ - NSFileManager *fileManager = [NSFileManager new]; // File manager instance - - NSString *cachePath = [ReaderThumbCache thumbCachePathForGUID:guid]; // Thumb cache path - - NSDictionary *attributes = [NSDictionary dictionaryWithObject:[NSDate date] forKey:NSFileModificationDate]; - - [fileManager setAttributes:attributes ofItemAtPath:cachePath error:NULL]; // New modification date -} - -+ (void)purgeThumbCachesOlderThan:(NSTimeInterval)age -{ - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), - ^{ - NSDate *now = [NSDate date]; // Right about now time - - NSString *cachesPath = [ReaderThumbCache appCachesPath]; // Caches path - - NSFileManager *fileManager = [NSFileManager new]; // File manager instance - - NSArray *cachesList = [fileManager contentsOfDirectoryAtPath:cachesPath error:NULL]; - - if (cachesList != nil) // Process caches directory contents - { - for (NSString *cacheName in cachesList) // Enumerate directory contents - { - if (cacheName.length == 36) // This is a very hacky cache ident kludge - { - NSString *cachePath = [cachesPath stringByAppendingPathComponent:cacheName]; - - NSDictionary *attributes = [fileManager attributesOfItemAtPath:cachePath error:NULL]; - - NSDate *cacheDate = [attributes objectForKey:NSFileModificationDate]; // Cache date - - NSTimeInterval seconds = [now timeIntervalSinceDate:cacheDate]; // Cache age - - if (seconds > age) // Older than so remove the thumb cache - { - [fileManager removeItemAtPath:cachePath error:NULL]; - - #ifdef DEBUG - NSLog(@"%s purged %@", __FUNCTION__, cacheName); - #endif - } - } - } - } - }); -} - -#pragma mark - ReaderThumbCache instance methods - -- (instancetype)init -{ - if ((self = [super init])) // Initialize - { - thumbCache = [NSCache new]; // Cache - - [thumbCache setName:@"ReaderThumbCache"]; - - [thumbCache setTotalCostLimit:CACHE_SIZE]; - } - - return self; -} - -- (id)thumbRequest:(ReaderThumbRequest *)request priority:(BOOL)priority -{ - @synchronized(thumbCache) // Mutex lock - { - id object = [thumbCache objectForKey:request.cacheKey]; - - if (object == nil) // Thumb object does not yet exist in the cache - { - object = [NSNull null]; // Return an NSNull thumb placeholder object - - [thumbCache setObject:object forKey:request.cacheKey cost:2]; // Cache the placeholder object - - ReaderThumbFetch *thumbFetch = [[ReaderThumbFetch alloc] initWithRequest:request]; // Create a thumb fetch operation - - [thumbFetch setQueuePriority:(priority ? NSOperationQueuePriorityNormal : NSOperationQueuePriorityLow)]; // Queue priority - - request.thumbView.operation = thumbFetch; [thumbFetch setThreadPriority:(priority ? 0.55 : 0.35)]; // Thread priority - - [[ReaderThumbQueue sharedInstance] addLoadOperation:thumbFetch]; // Queue the operation - } - - return object; // NSNull or UIImage - } -} - -- (void)setObject:(UIImage *)image forKey:(NSString *)key -{ - @synchronized(thumbCache) // Mutex lock - { - NSUInteger bytes = (image.size.width * image.size.height * 4.0f); - - [thumbCache setObject:image forKey:key cost:bytes]; // Cache image - } -} - -- (void)removeObjectForKey:(NSString *)key -{ - @synchronized(thumbCache) // Mutex lock - { - [thumbCache removeObjectForKey:key]; - } -} - -- (void)removeNullForKey:(NSString *)key -{ - @synchronized(thumbCache) // Mutex lock - { - id object = [thumbCache objectForKey:key]; - - if ([object isMemberOfClass:[NSNull class]]) - { - [thumbCache removeObjectForKey:key]; - } - } -} - -- (void)removeAllObjects -{ - @synchronized(thumbCache) // Mutex lock - { - [thumbCache removeAllObjects]; - } -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbFetch.h b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbFetch.h deleted file mode 100755 index 39f077070..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbFetch.h +++ /dev/null @@ -1,36 +0,0 @@ -// -// ReaderThumbFetch.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <Foundation/Foundation.h> - -#import "ReaderThumbQueue.h" - -@class ReaderThumbRequest; - -@interface ReaderThumbFetch : ReaderThumbOperation - -- (instancetype)initWithRequest:(ReaderThumbRequest *)options; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbFetch.m b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbFetch.m deleted file mode 100755 index 83593aca6..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbFetch.m +++ /dev/null @@ -1,128 +0,0 @@ -// -// ReaderThumbFetch.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderThumbFetch.h" -#import "ReaderThumbRender.h" -#import "ReaderThumbCache.h" -#import "ReaderThumbView.h" - -#import <ImageIO/ImageIO.h> - -@implementation ReaderThumbFetch -{ - ReaderThumbRequest *request; -} - -#pragma mark - ReaderThumbFetch instance methods - -- (instancetype)initWithRequest:(ReaderThumbRequest *)options -{ - if ((self = [super initWithGUID:options.guid])) - { - request = options; - } - - return self; -} - -- (void)cancel -{ - [super cancel]; // Cancel the operation - - request.thumbView.operation = nil; // Break retain loop - - request.thumbView = nil; // Release target thumb view on cancel - - [[ReaderThumbCache sharedInstance] removeNullForKey:request.cacheKey]; -} - -- (NSURL *)thumbFileURL -{ - NSString *cachePath = [ReaderThumbCache thumbCachePathForGUID:request.guid]; // Thumb cache path - - NSString *fileName = [[NSString alloc] initWithFormat:@"%@.png", request.thumbName]; // Thumb file name - - return [NSURL fileURLWithPath:[cachePath stringByAppendingPathComponent:fileName]]; // File URL -} - -- (void)main -{ - CGImageRef imageRef = NULL; NSURL *thumbURL = [self thumbFileURL]; - - CGImageSourceRef loadRef = CGImageSourceCreateWithURL((__bridge CFURLRef)thumbURL, NULL); - - if (loadRef != NULL) // Load the existing thumb image - { - imageRef = CGImageSourceCreateImageAtIndex(loadRef, 0, NULL); // Load it - - CFRelease(loadRef); // Release CGImageSource reference - } - else // Existing thumb image not found - so create and queue up a thumb render operation on the work queue - { - ReaderThumbRender *thumbRender = [[ReaderThumbRender alloc] initWithRequest:request]; // Create a thumb render operation - - [thumbRender setQueuePriority:self.queuePriority]; [thumbRender setThreadPriority:(self.threadPriority - 0.1)]; // Priority - - if (self.isCancelled == NO) // We're not cancelled - so update things and add the render operation to the work queue - { - request.thumbView.operation = thumbRender; // Update the thumb view operation property to the new operation - - [[ReaderThumbQueue sharedInstance] addWorkOperation:thumbRender]; return; // Queue the operation - } - } - - if (imageRef != NULL) // Create a UIImage from a CGImage and show it - { - UIImage *image = [UIImage imageWithCGImage:imageRef scale:request.scale orientation:UIImageOrientationUp]; - - CGImageRelease(imageRef); // Release the CGImage reference from the above thumb load code - - UIGraphicsBeginImageContextWithOptions(image.size, YES, request.scale); // Graphics context - - [image drawAtPoint:CGPointZero]; // Decode and draw the image on this background thread - - UIImage *decoded = UIGraphicsGetImageFromCurrentImageContext(); // Newly decoded image - - UIGraphicsEndImageContext(); // Cleanup after the bitmap-based graphics drawing context - - [[ReaderThumbCache sharedInstance] setObject:decoded forKey:request.cacheKey]; // Cache it - - if (self.isCancelled == NO) // Show the image in the target thumb view on the main thread - { - ReaderThumbView *thumbView = request.thumbView; // Target thumb view for image show - - NSUInteger targetTag = request.targetTag; // Target reference tag for image show - - dispatch_async(dispatch_get_main_queue(), // Queue image show on main thread - ^{ - if (thumbView.targetTag == targetTag) [thumbView showImage:decoded]; - }); - } - } - - request.thumbView.operation = nil; // Break retain loop -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbQueue.h b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbQueue.h deleted file mode 100755 index 9532813b4..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbQueue.h +++ /dev/null @@ -1,54 +0,0 @@ -// -// ReaderThumbQueue.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <Foundation/Foundation.h> - -@interface ReaderThumbQueue : NSObject <NSObject> - -+ (ReaderThumbQueue *)sharedInstance; - -- (void)addLoadOperation:(NSOperation *)operation; - -- (void)addWorkOperation:(NSOperation *)operation; - -- (void)cancelOperationsWithGUID:(NSString *)guid; - -- (void)cancelAllOperations; - -@end - -#pragma mark - - -// -// ReaderThumbOperation class interface -// - -@interface ReaderThumbOperation : NSOperation - -@property (nonatomic, strong, readonly) NSString *guid; - -- (instancetype)initWithGUID:(NSString *)guid; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbQueue.m b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbQueue.m deleted file mode 100755 index dc256ab30..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbQueue.m +++ /dev/null @@ -1,141 +0,0 @@ -// -// ReaderThumbQueue.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderThumbQueue.h" - -@implementation ReaderThumbQueue -{ - NSOperationQueue *loadQueue; - - NSOperationQueue *workQueue; -} - -#pragma mark - ReaderThumbQueue class methods - -+ (ReaderThumbQueue *)sharedInstance -{ - static dispatch_once_t predicate = 0; - - static ReaderThumbQueue *object = nil; // Object - - dispatch_once(&predicate, ^{ object = [self new]; }); - - return object; // ReaderThumbQueue singleton -} - -#pragma mark - ReaderThumbQueue instance methods - -- (instancetype)init -{ - if ((self = [super init])) // Initialize - { - loadQueue = [NSOperationQueue new]; - - [loadQueue setName:@"ReaderThumbLoadQueue"]; - - [loadQueue setMaxConcurrentOperationCount:1]; - - workQueue = [NSOperationQueue new]; - - [workQueue setName:@"ReaderThumbWorkQueue"]; - - [workQueue setMaxConcurrentOperationCount:1]; - } - - return self; -} - -- (void)addLoadOperation:(NSOperation *)operation -{ - if ([operation isKindOfClass:[ReaderThumbOperation class]]) - { - [loadQueue addOperation:operation]; // Add to load queue - } -} - -- (void)addWorkOperation:(NSOperation *)operation -{ - if ([operation isKindOfClass:[ReaderThumbOperation class]]) - { - [workQueue addOperation:operation]; // Add to work queue - } -} - -- (void)cancelOperationsWithGUID:(NSString *)guid -{ - [loadQueue setSuspended:YES]; [workQueue setSuspended:YES]; - - for (ReaderThumbOperation *operation in loadQueue.operations) - { - if ([operation isKindOfClass:[ReaderThumbOperation class]]) - { - if ([operation.guid isEqualToString:guid]) [operation cancel]; - } - } - - for (ReaderThumbOperation *operation in workQueue.operations) - { - if ([operation isKindOfClass:[ReaderThumbOperation class]]) - { - if ([operation.guid isEqualToString:guid]) [operation cancel]; - } - } - - [workQueue setSuspended:NO]; [loadQueue setSuspended:NO]; -} - -- (void)cancelAllOperations -{ - [loadQueue cancelAllOperations]; [workQueue cancelAllOperations]; -} - -@end - -#pragma mark - - -// -// ReaderThumbOperation class implementation -// - -@implementation ReaderThumbOperation -{ - NSString *_guid; -} - -@synthesize guid = _guid; - -#pragma mark - ReaderThumbOperation instance methods - -- (instancetype)initWithGUID:(NSString *)guid -{ - if ((self = [super init])) - { - _guid = guid; - } - - return self; -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbRender.h b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbRender.h deleted file mode 100755 index 953b93ce9..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbRender.h +++ /dev/null @@ -1,36 +0,0 @@ -// -// ReaderThumbRender.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <Foundation/Foundation.h> - -#import "ReaderThumbQueue.h" - -@class ReaderThumbRequest; - -@interface ReaderThumbRender : ReaderThumbOperation - -- (instancetype)initWithRequest:(ReaderThumbRequest *)options; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbRender.m b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbRender.m deleted file mode 100755 index fa01461b5..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbRender.m +++ /dev/null @@ -1,204 +0,0 @@ -// -// ReaderThumbRender.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderThumbRender.h" -#import "ReaderThumbCache.h" -#import "ReaderThumbView.h" -#import "CGPDFDocument.h" - -#import <ImageIO/ImageIO.h> - -@implementation ReaderThumbRender -{ - ReaderThumbRequest *request; -} - -#pragma mark - ReaderThumbRender instance methods - -- (instancetype)initWithRequest:(ReaderThumbRequest *)options -{ - if ((self = [super initWithGUID:options.guid])) - { - request = options; - } - - return self; -} - -- (void)cancel -{ - [super cancel]; // Cancel the operation - - request.thumbView.operation = nil; // Break retain loop - - request.thumbView = nil; // Release target thumb view on cancel - - [[ReaderThumbCache sharedInstance] removeNullForKey:request.cacheKey]; -} - -- (NSURL *)thumbFileURL -{ - NSFileManager *fileManager = [NSFileManager new]; // File manager instance - - NSString *cachePath = [ReaderThumbCache thumbCachePathForGUID:request.guid]; // Thumb cache path - - [fileManager createDirectoryAtPath:cachePath withIntermediateDirectories:NO attributes:nil error:NULL]; - - NSString *fileName = [[NSString alloc] initWithFormat:@"%@.png", request.thumbName]; // Thumb file name - - return [NSURL fileURLWithPath:[cachePath stringByAppendingPathComponent:fileName]]; // File URL -} - -- (void)main -{ - NSInteger page = request.thumbPage; NSString *password = request.password; - - CGImageRef imageRef = NULL; CFURLRef fileURL = (__bridge CFURLRef)request.fileURL; - - CGPDFDocumentRef thePDFDocRef = CGPDFDocumentCreateUsingUrl(fileURL, password); - - if (thePDFDocRef != NULL) // Check for non-NULL CGPDFDocumentRef - { - CGPDFPageRef thePDFPageRef = CGPDFDocumentGetPage(thePDFDocRef, page); - - if (thePDFPageRef != NULL) // Check for non-NULL CGPDFPageRef - { - CGFloat thumb_w = request.thumbSize.width; // Maximum thumb width - CGFloat thumb_h = request.thumbSize.height; // Maximum thumb height - - CGRect cropBoxRect = CGPDFPageGetBoxRect(thePDFPageRef, kCGPDFCropBox); - CGRect mediaBoxRect = CGPDFPageGetBoxRect(thePDFPageRef, kCGPDFMediaBox); - CGRect effectiveRect = CGRectIntersection(cropBoxRect, mediaBoxRect); - - NSInteger pageRotate = CGPDFPageGetRotationAngle(thePDFPageRef); // Angle - - CGFloat page_w = 0.0f; CGFloat page_h = 0.0f; // Rotated page size - - switch (pageRotate) // Page rotation (in degrees) - { - default: // Default case - case 0: case 180: // 0 and 180 degrees - { - page_w = effectiveRect.size.width; - page_h = effectiveRect.size.height; - break; - } - - case 90: case 270: // 90 and 270 degrees - { - page_h = effectiveRect.size.width; - page_w = effectiveRect.size.height; - break; - } - } - - CGFloat scale_w = (thumb_w / page_w); // Width scale - CGFloat scale_h = (thumb_h / page_h); // Height scale - - CGFloat scale = 0.0f; // Page to target thumb size scale - - if (page_h > page_w) - scale = ((thumb_h > thumb_w) ? scale_w : scale_h); // Portrait - else - scale = ((thumb_h < thumb_w) ? scale_h : scale_w); // Landscape - - NSInteger target_w = (page_w * scale); // Integer target thumb width - NSInteger target_h = (page_h * scale); // Integer target thumb height - - if (target_w % 2) target_w--; if (target_h % 2) target_h--; // Even - - target_w *= request.scale; target_h *= request.scale; // Screen scale - - CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB(); // RGB color space - - CGBitmapInfo bmi = (kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst); - - CGContextRef context = CGBitmapContextCreate(NULL, target_w, target_h, 8, 0, rgb, bmi); - - if (context != NULL) // Must have a valid custom CGBitmap context to draw into - { - CGRect thumbRect = CGRectMake(0.0f, 0.0f, target_w, target_h); // Target thumb rect - - CGContextSetRGBFillColor(context, 1.0f, 1.0f, 1.0f, 1.0f); CGContextFillRect(context, thumbRect); // White fill - - CGContextConcatCTM(context, CGPDFPageGetDrawingTransform(thePDFPageRef, kCGPDFCropBox, thumbRect, 0, true)); // Fit rect - - //CGContextSetRenderingIntent(context, kCGRenderingIntentDefault); CGContextSetInterpolationQuality(context, kCGInterpolationDefault); - - CGContextDrawPDFPage(context, thePDFPageRef); // Render the PDF page into the custom CGBitmap context - - imageRef = CGBitmapContextCreateImage(context); // Create CGImage from custom CGBitmap context - - CGContextRelease(context); // Release custom CGBitmap context reference - } - - CGColorSpaceRelease(rgb); // Release device RGB color space reference - } - - CGPDFDocumentRelease(thePDFDocRef); // Release CGPDFDocumentRef reference - } - - if (imageRef != NULL) // Create UIImage from CGImage and show it, then save thumb as PNG - { - UIImage *image = [UIImage imageWithCGImage:imageRef scale:request.scale orientation:UIImageOrientationUp]; - - [[ReaderThumbCache sharedInstance] setObject:image forKey:request.cacheKey]; // Update cache - - if (self.isCancelled == NO) // Show the image in the target thumb view on the main thread - { - ReaderThumbView *thumbView = request.thumbView; // Target thumb view for image show - - NSUInteger targetTag = request.targetTag; // Target reference tag for image show - - dispatch_async(dispatch_get_main_queue(), // Queue image show on main thread - ^{ - if (thumbView.targetTag == targetTag) [thumbView showImage:image]; - }); - } - - CFURLRef thumbURL = (__bridge CFURLRef)[self thumbFileURL]; // Thumb cache path with PNG file name URL - - CGImageDestinationRef thumbRef = CGImageDestinationCreateWithURL(thumbURL, (CFStringRef)@"public.png", 1, NULL); - - if (thumbRef != NULL) // Write the thumb image file out to the thumb cache directory - { - CGImageDestinationAddImage(thumbRef, imageRef, NULL); // Add the image - - CGImageDestinationFinalize(thumbRef); // Finalize the image file - - CFRelease(thumbRef); // Release CGImageDestination reference - } - - CGImageRelease(imageRef); // Release CGImage reference - } - else // No image - so remove the placeholder object from the cache - { - [[ReaderThumbCache sharedInstance] removeNullForKey:request.cacheKey]; - } - - request.thumbView.operation = nil; // Break retain loop -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbRequest.h b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbRequest.h deleted file mode 100755 index f4846d03f..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbRequest.h +++ /dev/null @@ -1,45 +0,0 @@ -// -// ReaderThumbRequest.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <UIKit/UIKit.h> - -@class ReaderThumbView; - -@interface ReaderThumbRequest : NSObject <NSObject> - -@property (nonatomic, strong, readonly) NSURL *fileURL; -@property (nonatomic, strong, readonly) NSString *guid; -@property (nonatomic, strong, readonly) NSString *password; -@property (nonatomic, strong, readonly) NSString *cacheKey; -@property (nonatomic, strong, readonly) NSString *thumbName; -@property (nonatomic, strong, readwrite) ReaderThumbView *thumbView; -@property (nonatomic, assign, readonly) NSUInteger targetTag; -@property (nonatomic, assign, readonly) NSInteger thumbPage; -@property (nonatomic, assign, readonly) CGSize thumbSize; -@property (nonatomic, assign, readonly) CGFloat scale; - -+ (instancetype)newForView:(ReaderThumbView *)view fileURL:(NSURL *)url password:(NSString *)phrase guid:(NSString *)guid page:(NSInteger)page size:(CGSize)size; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbRequest.m b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbRequest.m deleted file mode 100755 index 93ed9ad2f..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbRequest.m +++ /dev/null @@ -1,96 +0,0 @@ -// -// ReaderThumbRequest.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderThumbRequest.h" -#import "ReaderThumbView.h" - -@implementation ReaderThumbRequest -{ - NSURL *_fileURL; - - NSString *_guid; - - NSString *_password; - - NSString *_cacheKey; - - NSString *_thumbName; - - ReaderThumbView *_thumbView; - - NSUInteger _targetTag; - - NSInteger _thumbPage; - - CGSize _thumbSize; - - CGFloat _scale; -} - -#pragma mark - Properties - -@synthesize guid = _guid; -@synthesize fileURL = _fileURL; -@synthesize password = _password; -@synthesize thumbView = _thumbView; -@synthesize thumbPage = _thumbPage; -@synthesize thumbSize = _thumbSize; -@synthesize thumbName = _thumbName; -@synthesize targetTag = _targetTag; -@synthesize cacheKey = _cacheKey; -@synthesize scale = _scale; - -#pragma mark - ReaderThumbRequest class methods - -+ (instancetype)newForView:(ReaderThumbView *)view fileURL:(NSURL *)url password:(NSString *)phrase guid:(NSString *)guid page:(NSInteger)page size:(CGSize)size -{ - return [[ReaderThumbRequest alloc] initForView:view fileURL:url password:phrase guid:guid page:page size:size]; -} - -#pragma mark - ReaderThumbRequest instance methods - -- (instancetype)initForView:(ReaderThumbView *)view fileURL:(NSURL *)url password:(NSString *)phrase guid:(NSString *)guid page:(NSInteger)page size:(CGSize)size -{ - if ((self = [super init])) // Initialize object - { - NSInteger w = size.width; NSInteger h = size.height; - - _thumbView = view; _thumbPage = page; _thumbSize = size; - - _fileURL = [url copy]; _password = [phrase copy]; _guid = [guid copy]; - - _thumbName = [[NSString alloc] initWithFormat:@"%07i-%04ix%04i", (int)page, (int)w, (int)h]; - - _cacheKey = [[NSString alloc] initWithFormat:@"%@+%@", _thumbName, _guid]; - - _targetTag = [_cacheKey hash]; _thumbView.targetTag = _targetTag; - - _scale = [[UIScreen mainScreen] scale]; // Thumb screen scale - } - - return self; -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbView.h b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbView.h deleted file mode 100755 index 42356819a..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbView.h +++ /dev/null @@ -1,45 +0,0 @@ -// -// ReaderThumbView.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <UIKit/UIKit.h> - -@interface ReaderThumbView : UIView -{ -@protected // Instance variables - - UIImageView *imageView; -} - -@property (atomic, strong, readwrite) NSOperation *operation; - -@property (nonatomic, assign, readwrite) NSUInteger targetTag; - -- (void)showImage:(UIImage *)image; - -- (void)showTouched:(BOOL)touched; - -- (void)reuse; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbView.m b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbView.m deleted file mode 100755 index 10c5c91cf..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbView.m +++ /dev/null @@ -1,93 +0,0 @@ -// -// ReaderThumbView.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderThumbView.h" - -@implementation ReaderThumbView -{ - NSOperation *_operation; - - NSUInteger _targetTag; -} - -#pragma mark - Properties - -@synthesize operation = _operation; -@synthesize targetTag = _targetTag; - -#pragma mark - ReaderThumbView instance methods - -- (instancetype)initWithFrame:(CGRect)frame -{ - if ((self = [super initWithFrame:frame])) - { - self.autoresizesSubviews = NO; - self.userInteractionEnabled = NO; - self.contentMode = UIViewContentModeRedraw; - self.autoresizingMask = UIViewAutoresizingNone; - self.backgroundColor = [UIColor clearColor]; - - imageView = [[UIImageView alloc] initWithFrame:self.bounds]; - - imageView.autoresizesSubviews = NO; - imageView.userInteractionEnabled = NO; - imageView.autoresizingMask = UIViewAutoresizingNone; - imageView.contentMode = UIViewContentModeScaleAspectFit; - - [self addSubview:imageView]; - } - - return self; -} - -- (void)showImage:(UIImage *)image -{ - imageView.image = image; // Show image -} - -- (void)showTouched:(BOOL)touched -{ - // Implemented by ReaderThumbView subclass -} - -- (void)removeFromSuperview -{ - _targetTag = 0; // Clear target tag - - [self.operation cancel]; // Cancel operation - - [super removeFromSuperview]; // Remove view -} - -- (void)reuse -{ - _targetTag = 0; // Clear target tag - - [self.operation cancel]; // Cancel operation - - imageView.image = nil; // Release image -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbsView.h b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbsView.h deleted file mode 100755 index 6268770b2..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbsView.h +++ /dev/null @@ -1,68 +0,0 @@ -// -// ReaderThumbsView.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <UIKit/UIKit.h> - -#import "ReaderThumbView.h" - -@class ReaderThumbsView; - -@protocol ReaderThumbsViewDelegate <NSObject, UIScrollViewDelegate> - -@required // Delegate protocols - -- (NSUInteger)numberOfThumbsInThumbsView:(ReaderThumbsView *)thumbsView; - -- (id)thumbsView:(ReaderThumbsView *)thumbsView thumbCellWithFrame:(CGRect)frame; - -- (void)thumbsView:(ReaderThumbsView *)thumbsView updateThumbCell:(id)thumbCell forIndex:(NSInteger)index; - -- (void)thumbsView:(ReaderThumbsView *)thumbsView didSelectThumbWithIndex:(NSInteger)index; - -@optional // Delegate protocols - -- (void)thumbsView:(ReaderThumbsView *)thumbsView refreshThumbCell:(id)thumbCell forIndex:(NSInteger)index; - -- (void)thumbsView:(ReaderThumbsView *)thumbsView didPressThumbWithIndex:(NSInteger)index; - -@end - -@interface ReaderThumbsView : UIScrollView - -@property (nonatomic, weak, readwrite) id <ReaderThumbsViewDelegate> delegate; - -- (void)setThumbSize:(CGSize)thumbSize; - -- (void)reloadThumbsCenterOnIndex:(NSInteger)index; - -- (void)reloadThumbsContentOffset:(CGPoint)newContentOffset; - -- (void)refreshThumbWithIndex:(NSInteger)index; - -- (void)refreshVisibleThumbs; - -- (CGPoint)insetContentOffset; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbsView.m b/Libraries external/VFR Pdf Reader/Sources/ReaderThumbsView.m deleted file mode 100755 index f2a59d5fb..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderThumbsView.m +++ /dev/null @@ -1,545 +0,0 @@ -// -// ReaderThumbsView.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderThumbsView.h" - -@interface ReaderThumbsView () <UIScrollViewDelegate, UIGestureRecognizerDelegate> - -@end - -@implementation ReaderThumbsView -{ - CGPoint lastContentOffset; - - ReaderThumbView *touchedCell; - - NSMutableArray *thumbCellsQueue; - - NSMutableArray *thumbCellsVisible; - - NSInteger _thumbsX, _thumbsY, _thumbX; - - CGSize _thumbSize, _lastViewSize; - - NSUInteger _thumbCount; - - BOOL canUpdate; -} - -#pragma mark - Properties - -@synthesize delegate; - -#pragma mark - ReaderThumbsView instance methods - -- (instancetype)initWithFrame:(CGRect)frame -{ - if ((self = [super initWithFrame:frame])) - { - self.scrollsToTop = NO; - self.autoresizesSubviews = NO; - self.delaysContentTouches = NO; - self.alwaysBounceVertical = YES; - self.contentMode = UIViewContentModeRedraw; - self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; - self.backgroundColor = [UIColor clearColor]; - - [super setDelegate:self]; // Set the superclass UIScrollView delegate - - thumbCellsQueue = [NSMutableArray new]; thumbCellsVisible = [NSMutableArray new]; // Cell management arrays - - UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)]; - //tapGesture.numberOfTouchesRequired = 1; tapGesture.numberOfTapsRequired = 1; tapGesture.delegate = self; - [self addGestureRecognizer:tapGesture]; - - UILongPressGestureRecognizer *pressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handlePressGesture:)]; - pressGesture.minimumPressDuration = 0.8; //pressGesture.numberOfTouchesRequired = 1; pressGesture.delegate = self; - [self addGestureRecognizer:pressGesture]; - - lastContentOffset = CGPointMake(CGFLOAT_MIN, CGFLOAT_MIN); - } - - return self; -} - -- (void)requeueThumbCell:(ReaderThumbView *)tvCell -{ - [thumbCellsQueue addObject:tvCell]; - - [thumbCellsVisible removeObject:tvCell]; - - tvCell.tag = NSIntegerMin; tvCell.hidden = YES; - - [tvCell reuse]; // Reuse the cell -} - -- (void)requeueAllThumbCells -{ - if (thumbCellsVisible.count > 0) - { - NSArray *visible = [thumbCellsVisible copy]; - - for (ReaderThumbView *tvCell in visible) - { - [self requeueThumbCell:tvCell]; - } - } -} - -- (ReaderThumbView *)dequeueThumbCellWithFrame:(CGRect)frame -{ - ReaderThumbView *theCell = nil; - - if (thumbCellsQueue.count > 0) // Reuse existing cell - { - theCell = [thumbCellsQueue objectAtIndex:0]; - - [thumbCellsQueue removeObjectAtIndex:0]; // Dequeue it - - theCell.frame = frame; // Position the reused cell - } - else // Allocate a brand new thumb cell subclass for our use - { - theCell = [delegate thumbsView:self thumbCellWithFrame:frame]; - - //assert([theCell isKindOfClass:[ReaderThumbView class]]); - - theCell.tag = NSIntegerMin; theCell.hidden = YES; - - [self insertSubview:theCell atIndex:0]; // Add - } - - [thumbCellsVisible addObject:theCell]; - - return theCell; -} - -- (NSMutableIndexSet *)visibleIndexSetForContentOffset -{ - CGFloat minY = self.contentOffset.y; // Content offset - CGFloat maxY = (minY + self.bounds.size.height - 1.0f); - - NSInteger startRow = (minY / _thumbSize.height); // Start row - NSInteger finalRow = (maxY / _thumbSize.height); // Final row - - NSInteger startIndex = (startRow * _thumbsX); // Start index - NSInteger finalIndex = (finalRow * _thumbsX); // Final index - - finalIndex += (_thumbsX - 1); // Last index value in last row - - NSInteger maximumIndex = (_thumbCount - 1); // Maximum index value - - if (finalIndex > maximumIndex) finalIndex = maximumIndex; // Limit it - - NSRange indexRange = NSMakeRange(startIndex, (finalIndex - startIndex + 1)); - - return [NSMutableIndexSet indexSetWithIndexesInRange:indexRange]; -} - -- (ReaderThumbView *)thumbCellContainingPoint:(CGPoint)point -{ - ReaderThumbView *theCell = nil; - - for (ReaderThumbView *tvCell in thumbCellsVisible) - { - if (CGRectContainsPoint(tvCell.frame, point) == true) - { - theCell = tvCell; break; // Found it - } - } - - return theCell; -} - -- (CGRect)thumbCellFrameForIndex:(NSInteger)index -{ - CGRect thumbRect; thumbRect.size = _thumbSize; - - NSInteger thumbY = ((index / _thumbsX) * _thumbSize.height); // X, Y - - NSInteger thumbX = (((index % _thumbsX) * _thumbSize.width) + _thumbX); - - thumbRect.origin.x = thumbX; thumbRect.origin.y = thumbY; - - return thumbRect; -} - -- (void)updateContentSize:(NSUInteger)thumbCount -{ - canUpdate = NO; // Disable updates - - if (thumbCount > 0) // Have some thumbs - { - CGFloat bw = self.bounds.size.width; - - _thumbsX = (bw / _thumbSize.width); - - if (_thumbsX < 1) _thumbsX = 1; - - _thumbsY = (thumbCount / _thumbsX); - - if ((_thumbsX * _thumbsY) < thumbCount) _thumbsY++; - - CGFloat tw = (_thumbsX * _thumbSize.width); - CGFloat th = (_thumbsY * _thumbSize.height); - - if (tw < bw) - _thumbX = ((bw - tw) * 0.5f); - else - _thumbX = 0; // Reset - - if (tw < bw) tw = bw; // Limit - - [self setContentSize:CGSizeMake(tw, th)]; - } - else // Zero (0) thumbs - { - [self setContentSize:CGSizeZero]; - } - - canUpdate = YES; // Enable updates -} - -- (void)layoutSubviews -{ - if (CGSizeEqualToSize(_lastViewSize, CGSizeZero) == true) - { - _lastViewSize = self.bounds.size; // Initial view size - } - else - if (CGSizeEqualToSize(_lastViewSize, self.bounds.size) == false) - { - _lastViewSize = self.bounds.size; // Track the view size - - [self updateContentSize:_thumbCount]; // Update the content size - - NSMutableArray *requeueCells = [NSMutableArray array]; // Requeue cell list - - NSMutableIndexSet *visibleIndexSet = [self visibleIndexSetForContentOffset]; - - for (ReaderThumbView *tvCell in thumbCellsVisible) // Enumerate visible cells - { - NSInteger index = tvCell.tag; // Get the cell's index value - - if ([visibleIndexSet containsIndex:index] == YES) // Visible cell - { - tvCell.frame = [self thumbCellFrameForIndex:index]; // Frame - - [visibleIndexSet removeIndex:index]; // Remove from set - } - else // Add it to the list of cells to requeue - { - [requeueCells addObject:tvCell]; - } - } - - for (ReaderThumbView *tvCell in requeueCells) // Enumerate requeue cells - { - [self requeueThumbCell:tvCell]; // Requeue the thumb cell - } - - [visibleIndexSet enumerateIndexesUsingBlock: // Enumerate visible indexes - ^(NSUInteger index, BOOL *stop) - { - CGRect thumbRect = [self thumbCellFrameForIndex:index]; // Frame - - ReaderThumbView *tvCell = [self dequeueThumbCellWithFrame:thumbRect]; - - [delegate thumbsView:self updateThumbCell:tvCell forIndex:index]; - - tvCell.tag = index; tvCell.hidden = NO; // Tag and show it - } - ]; - } -} - -- (void)setThumbSize:(CGSize)thumbSize -{ - if (CGSizeEqualToSize(_thumbSize, CGSizeZero) == true) - { - if (CGSizeEqualToSize(thumbSize, CGSizeZero) == false) - { - _thumbSize = thumbSize; // Set the maximum thumb size - } - } -} - -- (void)reloadThumbsCenterOnIndex:(NSInteger)index -{ - assert(delegate != nil); // Check delegate - - assert(CGSizeEqualToSize(_thumbSize, CGSizeZero) == false); - - if (self.decelerating == YES) // Stop scroll view movement - { - [self setContentOffset:self.contentOffset animated:NO]; - } - - CGPoint newContentOffset = CGPointZero; // At top - - lastContentOffset = CGPointMake(CGFLOAT_MIN, CGFLOAT_MIN); - - [self requeueAllThumbCells]; // Start off fresh - - _thumbCount = 0; // Reset the thumb count to zero - - NSUInteger thumbCount = [delegate numberOfThumbsInThumbsView:self]; - - [self updateContentSize:thumbCount]; _thumbCount = thumbCount; - - if (thumbCount > 0) // Have some thumbs - { - NSInteger boundsHeight = self.bounds.size.height; - - NSInteger maxY = (self.contentSize.height - boundsHeight); - - NSInteger minY = 0; maxY--; if (maxY < minY) maxY = minY; // Limits - - if (index < 0) index = 0; else if (index > thumbCount) index = (thumbCount - 1); - - NSInteger thumbY = ((index / _thumbsX) * _thumbSize.height); // Thumb Y - - NSInteger offsetY = (thumbY - (boundsHeight / 2) + (_thumbSize.height / 2)); - - if (offsetY < minY) offsetY = minY; else if (offsetY > maxY) offsetY = maxY; - - newContentOffset.y = offsetY; // Calculated content offset Y position - } - - newContentOffset.y -= self.contentInset.top; // Content inset adjust - - if (CGPointEqualToPoint(self.contentOffset, newContentOffset) == false) - [self setContentOffset:newContentOffset animated:NO]; - else - [self scrollViewDidScroll:self]; - - [self flashScrollIndicators]; -} - -- (void)reloadThumbsContentOffset:(CGPoint)newContentOffset -{ - assert(delegate != nil); // Check delegate - - assert(CGSizeEqualToSize(_thumbSize, CGSizeZero) == false); - - if (self.decelerating == YES) // Stop scroll view movement - { - [self setContentOffset:self.contentOffset animated:NO]; - } - - lastContentOffset = CGPointMake(CGFLOAT_MIN, CGFLOAT_MIN); - - [self requeueAllThumbCells]; // Start off fresh - - _thumbCount = 0; // Reset the thumb count to zero - - NSUInteger thumbCount = [delegate numberOfThumbsInThumbsView:self]; - - [self updateContentSize:thumbCount]; _thumbCount = thumbCount; - - if (thumbCount > 0) // Have some thumbs - { - NSInteger boundsHeight = self.bounds.size.height; - - NSInteger maxY = (self.contentSize.height - boundsHeight); - - NSInteger minY = 0; maxY--; if (maxY < minY) maxY = minY; // Limits - - NSInteger offsetY = newContentOffset.y; // Requested content offset Y - - if (offsetY < minY) offsetY = minY; else if (offsetY > maxY) offsetY = maxY; - - newContentOffset.y = offsetY; newContentOffset.x = 0.0f; // Validated - } - else // Zero (0) thumbs - { - newContentOffset = CGPointZero; - } - - newContentOffset.y -= self.contentInset.top; // Content inset adjust - - if (CGPointEqualToPoint(self.contentOffset, newContentOffset) == false) - [self setContentOffset:newContentOffset animated:NO]; - else - [self scrollViewDidScroll:self]; - - [self flashScrollIndicators]; -} - -- (void)refreshThumbWithIndex:(NSInteger)index -{ - for (ReaderThumbView *tvCell in thumbCellsVisible) // Enumerate visible cells - { - if (tvCell.tag == index) // Found a visible thumb cell with the index value - { - if ([delegate respondsToSelector:@selector(thumbsView:refreshThumbCell:forIndex:)]) - { - [delegate thumbsView:self refreshThumbCell:tvCell forIndex:index]; // Refresh - } - - break; - } - } -} - -- (void)refreshVisibleThumbs -{ - for (ReaderThumbView *tvCell in thumbCellsVisible) // Enumerate visible cells - { - if ([delegate respondsToSelector:@selector(thumbsView:refreshThumbCell:forIndex:)]) - { - [delegate thumbsView:self refreshThumbCell:tvCell forIndex:tvCell.tag]; // Refresh - } - } -} - -- (CGPoint)insetContentOffset -{ - CGPoint insetContentOffset = self.contentOffset; // Offset - - insetContentOffset.y += self.contentInset.top; // Inset adjust - - return insetContentOffset; // Adjusted content offset -} - -#pragma mark - UIGestureRecognizer action methods - -- (void)handleTapGesture:(UITapGestureRecognizer *)recognizer -{ - if (recognizer.state == UIGestureRecognizerStateRecognized) // Handle the tap - { - CGPoint point = [recognizer locationInView:recognizer.view]; // Tap location - - ReaderThumbView *tvCell = [self thumbCellContainingPoint:point]; // Look for cell - - if (tvCell != nil) [delegate thumbsView:self didSelectThumbWithIndex:tvCell.tag]; - } -} - -- (void)handlePressGesture:(UILongPressGestureRecognizer *)recognizer -{ - if (recognizer.state == UIGestureRecognizerStateBegan) // Handle the press - { - if ([delegate respondsToSelector:@selector(thumbsView:didPressThumbWithIndex:)]) - { - CGPoint point = [recognizer locationInView:recognizer.view]; // Press location - - ReaderThumbView *tvCell = [self thumbCellContainingPoint:point]; // Look for cell - - if (tvCell != nil) [delegate thumbsView:self didPressThumbWithIndex:tvCell.tag]; - } - } -} - -#pragma mark - UIScrollViewDelegate methods - -- (void)scrollViewDidScroll:(UIScrollView *)scrollView -{ - if ((canUpdate == YES) && (_thumbCount > 0)) // Check flag and thumb count - { - if (CGPointEqualToPoint(scrollView.contentOffset, lastContentOffset) == false) - { - lastContentOffset = scrollView.contentOffset; // Work around a 'feature' - - CGRect visibleBounds = self.bounds; // Visible bounds in the scroll view - - NSMutableArray *requeueCells = [NSMutableArray array]; // Requeue cell list - - NSMutableIndexSet *visibleCellSet = [NSMutableIndexSet indexSet]; // Visible set - - for (ReaderThumbView *tvCell in thumbCellsVisible) // Enumerate visible cells - { - if (CGRectIntersectsRect(tvCell.frame, visibleBounds) == true) - [visibleCellSet addIndex:tvCell.tag]; - else - [requeueCells addObject:tvCell]; - } - - for (ReaderThumbView *tvCell in requeueCells) // Enumerate requeue cells - { - [self requeueThumbCell:tvCell]; // Requeue the thumb cell - } - - NSMutableIndexSet *visibleIndexSet = [self visibleIndexSetForContentOffset]; - - [visibleIndexSet enumerateIndexesUsingBlock: // Enumerate visible indexes - ^(NSUInteger index, BOOL *stop) - { - if ([visibleCellSet containsIndex:index] == NO) // Index not visible - { - CGRect thumbRect = [self thumbCellFrameForIndex:index]; // Frame - - ReaderThumbView *tvCell = [self dequeueThumbCellWithFrame:thumbRect]; - - [delegate thumbsView:self updateThumbCell:tvCell forIndex:index]; - - tvCell.tag = index; tvCell.hidden = NO; // Tag and show it - } - } - ]; - } - } -} - -#pragma mark - UIResponder instance methods - -- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event -{ - [super touchesBegan:touches withEvent:event]; // Message superclass - - if (touchedCell != nil) { [touchedCell showTouched:NO]; touchedCell = nil; } - - if (touches.count == 1) // Show selection on single touch - { - UITouch *touch = [touches anyObject]; // Get touch from set - - CGPoint point = [touch locationInView:touch.view]; // Touch location - - ReaderThumbView *tvCell = [self thumbCellContainingPoint:point]; // Look for cell - - if (tvCell != nil) { touchedCell = tvCell; [touchedCell showTouched:YES]; } - } -} - -- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event -{ - [super touchesCancelled:touches withEvent:event]; // Message superclass - - if (touchedCell != nil) { [touchedCell showTouched:NO]; touchedCell = nil; } -} - -- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event -{ - [super touchesEnded:touches withEvent:event]; // Message superclass - - if (touchedCell != nil) { [touchedCell showTouched:NO]; touchedCell = nil; } -} - -- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event -{ - [super touchesMoved:touches withEvent:event]; // Message superclass -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderViewController.h b/Libraries external/VFR Pdf Reader/Sources/ReaderViewController.h deleted file mode 100755 index 3a54f5375..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderViewController.h +++ /dev/null @@ -1,48 +0,0 @@ -// -// ReaderViewController.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <UIKit/UIKit.h> - -#import "ReaderDocument.h" - -@class ReaderViewController; - -@protocol ReaderViewControllerDelegate <NSObject> - -@optional // Delegate protocols - -- (void)dismissReaderViewController:(ReaderViewController *)viewController; - -@end - -@interface ReaderViewController : UIViewController - -@property (nonatomic, weak, readwrite) id <ReaderViewControllerDelegate> delegate; - -- (instancetype)initWithReaderDocument:(ReaderDocument *)object; - -- (void)updateContentViews; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ReaderViewController.m b/Libraries external/VFR Pdf Reader/Sources/ReaderViewController.m deleted file mode 100755 index b33a64553..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ReaderViewController.m +++ /dev/null @@ -1,914 +0,0 @@ -// -// ReaderViewController.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-07-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderConstants.h" -#import "ReaderViewController.h" -#import "ThumbsViewController.h" -#import "ReaderMainToolbar.h" -#import "ReaderMainPagebar.h" -#import "ReaderContentView.h" -#import "ReaderThumbCache.h" -#import "ReaderThumbQueue.h" - -#import <MessageUI/MessageUI.h> - -@interface ReaderViewController () <UIScrollViewDelegate, UIGestureRecognizerDelegate, MFMailComposeViewControllerDelegate, UIDocumentInteractionControllerDelegate, - ReaderMainToolbarDelegate, ReaderMainPagebarDelegate, ReaderContentViewDelegate, ThumbsViewControllerDelegate> -@end - -@implementation ReaderViewController -{ - ReaderDocument *document; - - UIScrollView *theScrollView; - - ReaderMainToolbar *mainToolbar; - - ReaderMainPagebar *mainPagebar; - - NSMutableDictionary *contentViews; - - UIUserInterfaceIdiom userInterfaceIdiom; - - NSInteger currentPage, minimumPage, maximumPage; - - UIDocumentInteractionController *documentInteraction; - - UIPrintInteractionController *printInteraction; - - CGFloat scrollViewOutset; - - CGSize lastAppearSize; - - NSDate *lastHideTime; - - BOOL ignoreDidScroll; -} - -#pragma mark - Constants - -#define STATUS_HEIGHT 20.0f - -#define TOOLBAR_HEIGHT 44.0f -#define PAGEBAR_HEIGHT 48.0f - -#define SCROLLVIEW_OUTSET_SMALL 4.0f -#define SCROLLVIEW_OUTSET_LARGE 8.0f - -#define TAP_AREA_SIZE 48.0f - -#pragma mark - Properties - -@synthesize delegate; - -#pragma mark - ReaderViewController methods - -- (void)updateContentSize:(UIScrollView *)scrollView -{ - CGFloat contentHeight = scrollView.bounds.size.height; // Height - - CGFloat contentWidth = (scrollView.bounds.size.width * maximumPage); - - scrollView.contentSize = CGSizeMake(contentWidth, contentHeight); -} - -- (void)updateContentViews:(UIScrollView *)scrollView -{ - [self updateContentSize:scrollView]; // Update content size first - - [contentViews enumerateKeysAndObjectsUsingBlock: // Enumerate content views - ^(NSNumber *key, ReaderContentView *contentView, BOOL *stop) - { - NSInteger page = [key integerValue]; // Page number value - - CGRect viewRect = CGRectZero; viewRect.size = scrollView.bounds.size; - - viewRect.origin.x = (viewRect.size.width * (page - 1)); // Update X - - contentView.frame = CGRectInset(viewRect, scrollViewOutset, 0.0f); - } - ]; - - NSInteger page = currentPage; // Update scroll view offset to current page - - CGPoint contentOffset = CGPointMake((scrollView.bounds.size.width * (page - 1)), 0.0f); - - if (CGPointEqualToPoint(scrollView.contentOffset, contentOffset) == false) // Update - { - scrollView.contentOffset = contentOffset; // Update content offset - } - - [mainToolbar setBookmarkState:[document.bookmarks containsIndex:page]]; - - [mainPagebar updatePagebar]; // Update page bar -} - -- (void)addContentView:(UIScrollView *)scrollView page:(NSInteger)page -{ - CGRect viewRect = CGRectZero; viewRect.size = scrollView.bounds.size; - - viewRect.origin.x = (viewRect.size.width * (page - 1)); viewRect = CGRectInset(viewRect, scrollViewOutset, 0.0f); - - NSURL *fileURL = document.fileURL; NSString *phrase = document.password; NSString *guid = document.guid; // Document properties - - ReaderContentView *contentView = [[ReaderContentView alloc] initWithFrame:viewRect fileURL:fileURL page:page password:phrase]; // ReaderContentView - - contentView.message = self; [contentViews setObject:contentView forKey:[NSNumber numberWithInteger:page]]; [scrollView addSubview:contentView]; - - [contentView showPageThumb:fileURL page:page password:phrase guid:guid]; // Request page preview thumb -} - -- (void)layoutContentViews:(UIScrollView *)scrollView -{ - CGFloat viewWidth = scrollView.bounds.size.width; // View width - - CGFloat contentOffsetX = scrollView.contentOffset.x; // Content offset X - - NSInteger pageB = ((contentOffsetX + viewWidth - 1.0f) / viewWidth); // Pages - - NSInteger pageA = (contentOffsetX / viewWidth); pageB += 2; // Add extra pages - - if (pageA < minimumPage) pageA = minimumPage; if (pageB > maximumPage) pageB = maximumPage; - - NSRange pageRange = NSMakeRange(pageA, (pageB - pageA + 1)); // Make page range (A to B) - - NSMutableIndexSet *pageSet = [NSMutableIndexSet indexSetWithIndexesInRange:pageRange]; - - for (NSNumber *key in [contentViews allKeys]) // Enumerate content views - { - NSInteger page = [key integerValue]; // Page number value - - if ([pageSet containsIndex:page] == NO) // Remove content view - { - ReaderContentView *contentView = [contentViews objectForKey:key]; - - [contentView removeFromSuperview]; [contentViews removeObjectForKey:key]; - } - else // Visible content view - so remove it from page set - { - [pageSet removeIndex:page]; - } - } - - NSInteger pages = pageSet.count; - - if (pages > 0) // We have pages to add - { - NSEnumerationOptions options = 0; // Default - - if (pages == 2) // Handle case of only two content views - { - if ((maximumPage > 2) && ([pageSet lastIndex] == maximumPage)) options = NSEnumerationReverse; - } - else if (pages == 3) // Handle three content views - show the middle one first - { - NSMutableIndexSet *workSet = [pageSet mutableCopy]; options = NSEnumerationReverse; - - [workSet removeIndex:[pageSet firstIndex]]; [workSet removeIndex:[pageSet lastIndex]]; - - NSInteger page = [workSet firstIndex]; [pageSet removeIndex:page]; - - [self addContentView:scrollView page:page]; - } - - [pageSet enumerateIndexesWithOptions:options usingBlock: // Enumerate page set - ^(NSUInteger page, BOOL *stop) - { - [self addContentView:scrollView page:page]; - } - ]; - } -} - -- (void)handleScrollViewDidEnd:(UIScrollView *)scrollView -{ - CGFloat viewWidth = scrollView.bounds.size.width; // Scroll view width - - CGFloat contentOffsetX = scrollView.contentOffset.x; // Content offset X - - NSInteger page = (contentOffsetX / viewWidth); page++; // Page number - - if (page != currentPage) // Only if on different page - { - currentPage = page; document.pageNumber = [NSNumber numberWithInteger:page]; - - [contentViews enumerateKeysAndObjectsUsingBlock: // Enumerate content views - ^(NSNumber *key, ReaderContentView *contentView, BOOL *stop) - { - if ([key integerValue] != page) [contentView zoomResetAnimated:NO]; - } - ]; - - [mainToolbar setBookmarkState:[document.bookmarks containsIndex:page]]; - - [mainPagebar updatePagebar]; // Update page bar - } -} - -- (void)showDocumentPage:(NSInteger)page -{ - if (page != currentPage) // Only if on different page - { - if ((page < minimumPage) || (page > maximumPage)) return; - - currentPage = page; document.pageNumber = [NSNumber numberWithInteger:page]; - - CGPoint contentOffset = CGPointMake((theScrollView.bounds.size.width * (page - 1)), 0.0f); - - if (CGPointEqualToPoint(theScrollView.contentOffset, contentOffset) == true) - [self layoutContentViews:theScrollView]; - else - [theScrollView setContentOffset:contentOffset]; - - [contentViews enumerateKeysAndObjectsUsingBlock: // Enumerate content views - ^(NSNumber *key, ReaderContentView *contentView, BOOL *stop) - { - if ([key integerValue] != page) [contentView zoomResetAnimated:NO]; - } - ]; - - [mainToolbar setBookmarkState:[document.bookmarks containsIndex:page]]; - - [mainPagebar updatePagebar]; // Update page bar - } -} - -- (void)showDocument -{ - [self updateContentSize:theScrollView]; // Update content size first - - [self showDocumentPage:[document.pageNumber integerValue]]; // Show page - - document.lastOpen = [NSDate date]; // Update document last opened date -} - -- (void)closeDocument -{ - if (printInteraction != nil) [printInteraction dismissAnimated:NO]; - - [document archiveDocumentProperties]; // Save any ReaderDocument changes - - [[ReaderThumbQueue sharedInstance] cancelOperationsWithGUID:document.guid]; - - [[ReaderThumbCache sharedInstance] removeAllObjects]; // Empty the thumb cache - - if ([delegate respondsToSelector:@selector(dismissReaderViewController:)] == YES) - { - [delegate dismissReaderViewController:self]; // Dismiss the ReaderViewController - } - else // We have a "Delegate must respond to -dismissReaderViewController:" error - { - NSAssert(NO, @"Delegate must respond to -dismissReaderViewController:"); - } -} - -#pragma mark - UIViewController methods - -- (instancetype)initWithReaderDocument:(ReaderDocument *)object -{ - if ((self = [super initWithNibName:nil bundle:nil])) // Initialize superclass - { - if ((object != nil) && ([object isKindOfClass:[ReaderDocument class]])) // Valid object - { - userInterfaceIdiom = [UIDevice currentDevice].userInterfaceIdiom; // User interface idiom - - NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; // Default notification center - - [notificationCenter addObserver:self selector:@selector(applicationWillResign:) name:UIApplicationWillTerminateNotification object:nil]; - - [notificationCenter addObserver:self selector:@selector(applicationWillResign:) name:UIApplicationWillResignActiveNotification object:nil]; - - scrollViewOutset = ((userInterfaceIdiom == UIUserInterfaceIdiomPad) ? SCROLLVIEW_OUTSET_LARGE : SCROLLVIEW_OUTSET_SMALL); - - [object updateDocumentProperties]; document = object; // Retain the supplied ReaderDocument object for our use - - [ReaderThumbCache touchThumbCacheWithGUID:object.guid]; // Touch the document thumb cache directory - } - else // Invalid ReaderDocument object - { - self = nil; - } - } - - return self; -} - -- (void)dealloc -{ - [[NSNotificationCenter defaultCenter] removeObserver:self]; -} - -- (void)viewDidLoad -{ - [super viewDidLoad]; - - assert(document != nil); // Must have a valid ReaderDocument - - self.view.backgroundColor = [UIColor grayColor]; // Neutral gray - - UIView *fakeStatusBar = nil; CGRect viewRect = self.view.bounds; // View bounds - - if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) // iOS 7+ - { - if ([self prefersStatusBarHidden] == NO) // Visible status bar - { - CGRect statusBarRect = viewRect; statusBarRect.size.height = STATUS_HEIGHT; - fakeStatusBar = [[UIView alloc] initWithFrame:statusBarRect]; // UIView - fakeStatusBar.autoresizingMask = UIViewAutoresizingFlexibleWidth; - fakeStatusBar.backgroundColor = [UIColor blackColor]; - fakeStatusBar.contentMode = UIViewContentModeRedraw; - fakeStatusBar.userInteractionEnabled = NO; - - viewRect.origin.y += STATUS_HEIGHT; viewRect.size.height -= STATUS_HEIGHT; - } - } - - CGRect scrollViewRect = CGRectInset(viewRect, -scrollViewOutset, 0.0f); - theScrollView = [[UIScrollView alloc] initWithFrame:scrollViewRect]; // All - theScrollView.autoresizesSubviews = NO; theScrollView.contentMode = UIViewContentModeRedraw; - theScrollView.showsHorizontalScrollIndicator = NO; theScrollView.showsVerticalScrollIndicator = NO; - theScrollView.scrollsToTop = NO; theScrollView.delaysContentTouches = NO; theScrollView.pagingEnabled = YES; - theScrollView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight); - theScrollView.backgroundColor = [UIColor clearColor]; theScrollView.delegate = self; - [self.view addSubview:theScrollView]; - - CGRect toolbarRect = viewRect; toolbarRect.size.height = TOOLBAR_HEIGHT; - mainToolbar = [[ReaderMainToolbar alloc] initWithFrame:toolbarRect document:document]; // ReaderMainToolbar - mainToolbar.delegate = self; // ReaderMainToolbarDelegate - //TWS [self.view addSubview:mainToolbar]; - - CGRect pagebarRect = self.view.bounds; pagebarRect.size.height = PAGEBAR_HEIGHT; - pagebarRect.origin.y = (self.view.bounds.size.height - pagebarRect.size.height); - mainPagebar = [[ReaderMainPagebar alloc] initWithFrame:pagebarRect document:document]; // ReaderMainPagebar - mainPagebar.delegate = self; // ReaderMainPagebarDelegate - [self.view addSubview:mainPagebar]; - - if (fakeStatusBar != nil) [self.view addSubview:fakeStatusBar]; // Add status bar background view - - UITapGestureRecognizer *singleTapOne = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)]; - singleTapOne.numberOfTouchesRequired = 1; singleTapOne.numberOfTapsRequired = 1; singleTapOne.delegate = self; - [self.view addGestureRecognizer:singleTapOne]; - - UITapGestureRecognizer *doubleTapOne = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)]; - doubleTapOne.numberOfTouchesRequired = 1; doubleTapOne.numberOfTapsRequired = 2; doubleTapOne.delegate = self; - [self.view addGestureRecognizer:doubleTapOne]; - - UITapGestureRecognizer *doubleTapTwo = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)]; - doubleTapTwo.numberOfTouchesRequired = 2; doubleTapTwo.numberOfTapsRequired = 2; doubleTapTwo.delegate = self; - [self.view addGestureRecognizer:doubleTapTwo]; - - [singleTapOne requireGestureRecognizerToFail:doubleTapOne]; // Single tap requires double tap to fail - - contentViews = [NSMutableDictionary new]; lastHideTime = [NSDate date]; - - minimumPage = 1; maximumPage = [document.pageCount integerValue]; -} - -- (void)viewWillAppear:(BOOL)animated -{ - [super viewWillAppear:animated]; - - if (CGSizeEqualToSize(lastAppearSize, CGSizeZero) == false) - { - if (CGSizeEqualToSize(lastAppearSize, self.view.bounds.size) == false) - { - [self updateContentViews:theScrollView]; // Update content views - } - - lastAppearSize = CGSizeZero; // Reset view size tracking - } - - //TWS (IOS7) - self.tabBarController.tabBar.hidden = YES; -} - -- (void)viewDidAppear:(BOOL)animated -{ - [super viewDidAppear:animated]; - - if (CGSizeEqualToSize(theScrollView.contentSize, CGSizeZero) == true) - { - [self performSelector:@selector(showDocument) withObject:nil afterDelay:0.0]; - } - -#if (READER_DISABLE_IDLE == TRUE) // Option - - [UIApplication sharedApplication].idleTimerDisabled = YES; - -#endif // end of READER_DISABLE_IDLE Option -} - -- (void)viewWillDisappear:(BOOL)animated -{ - [super viewWillDisappear:animated]; - - lastAppearSize = self.view.bounds.size; // Track view size - -#if (READER_DISABLE_IDLE == TRUE) // Option - - [UIApplication sharedApplication].idleTimerDisabled = NO; - -#endif // end of READER_DISABLE_IDLE Option -} - -- (void)viewDidDisappear:(BOOL)animated -{ - [super viewDidDisappear:animated]; -} - -- (void)viewDidUnload -{ -#ifdef DEBUG - NSLog(@"%s", __FUNCTION__); -#endif - - mainToolbar = nil; mainPagebar = nil; - - theScrollView = nil; contentViews = nil; lastHideTime = nil; - - documentInteraction = nil; printInteraction = nil; - - lastAppearSize = CGSizeZero; currentPage = 0; - - [super viewDidUnload]; -} - -- (BOOL)prefersStatusBarHidden -{ - return YES; -} - -- (UIStatusBarStyle)preferredStatusBarStyle -{ - return UIStatusBarStyleLightContent; -} - -- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation -{ - return YES; -} - -- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration -{ - if (userInterfaceIdiom == UIUserInterfaceIdiomPad) if (printInteraction != nil) [printInteraction dismissAnimated:NO]; - - ignoreDidScroll = YES; -} - -- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration -{ - if (CGSizeEqualToSize(theScrollView.contentSize, CGSizeZero) == false) - { - [self updateContentViews:theScrollView]; lastAppearSize = CGSizeZero; - } -} - -- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation -{ - ignoreDidScroll = NO; -} - -- (void)updateContentViews -{ - if (currentPage > 0) { - [self updateContentViews:theScrollView]; - } -} - -- (void)didReceiveMemoryWarning -{ -#ifdef DEBUG - NSLog(@"%s", __FUNCTION__); -#endif - - [super didReceiveMemoryWarning]; -} - -#pragma mark - UIScrollViewDelegate methods - -- (void)scrollViewDidScroll:(UIScrollView *)scrollView -{ - if (ignoreDidScroll == NO) [self layoutContentViews:scrollView]; -} - -- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView -{ - [self handleScrollViewDidEnd:scrollView]; -} - -- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView -{ - [self handleScrollViewDidEnd:scrollView]; -} - -#pragma mark - UIGestureRecognizerDelegate methods - -- (BOOL)gestureRecognizer:(UIGestureRecognizer *)recognizer shouldReceiveTouch:(UITouch *)touch -{ - if ([touch.view isKindOfClass:[UIScrollView class]]) return YES; - - return NO; -} - -#pragma mark - UIGestureRecognizer action methods - -- (void)decrementPageNumber -{ - if ((maximumPage > minimumPage) && (currentPage != minimumPage)) - { - CGPoint contentOffset = theScrollView.contentOffset; // Offset - - contentOffset.x -= theScrollView.bounds.size.width; // View X-- - - [theScrollView setContentOffset:contentOffset animated:YES]; - } -} - -- (void)incrementPageNumber -{ - if ((maximumPage > minimumPage) && (currentPage != maximumPage)) - { - CGPoint contentOffset = theScrollView.contentOffset; // Offset - - contentOffset.x += theScrollView.bounds.size.width; // View X++ - - [theScrollView setContentOffset:contentOffset animated:YES]; - } -} - -- (void)handleSingleTap:(UITapGestureRecognizer *)recognizer -{ - if (recognizer.state == UIGestureRecognizerStateRecognized) - { - CGRect viewRect = recognizer.view.bounds; // View bounds - - CGPoint point = [recognizer locationInView:recognizer.view]; // Point - - CGRect areaRect = CGRectInset(viewRect, TAP_AREA_SIZE, 0.0f); // Area rect - - if (CGRectContainsPoint(areaRect, point) == true) // Single tap is inside area - { - NSNumber *key = [NSNumber numberWithInteger:currentPage]; // Page number key - - ReaderContentView *targetView = [contentViews objectForKey:key]; // View - - id target = [targetView processSingleTap:recognizer]; // Target object - - if (target != nil) // Handle the returned target object - { - if ([target isKindOfClass:[NSURL class]]) // Open a URL - { - NSURL *url = (NSURL *)target; // Cast to a NSURL object - - if (url.scheme == nil) // Handle a missing URL scheme - { - NSString *www = url.absoluteString; // Get URL string - - if ([www hasPrefix:@"www"] == YES) // Check for 'www' prefix - { - NSString *http = [[NSString alloc] initWithFormat:@"http://%@", www]; - - url = [NSURL URLWithString:http]; // Proper http-based URL - } - } - - if ([[UIApplication sharedApplication] openURL:url] == NO) - { - #ifdef DEBUG - NSLog(@"%s '%@'", __FUNCTION__, url); // Bad or unknown URL - #endif - } - } - else // Not a URL, so check for another possible object type - { - if ([target isKindOfClass:[NSNumber class]]) // Goto page - { - NSInteger number = [target integerValue]; // Number - - [self showDocumentPage:number]; // Show the page - } - } - } - else // Nothing active tapped in the target content view - { - if ([lastHideTime timeIntervalSinceNow] < -0.75) // Delay since hide - { - if ((mainToolbar.alpha < 1.0f) || (mainPagebar.alpha < 1.0f)) // Hidden - { - [mainToolbar showToolbar]; [mainPagebar showPagebar]; // Show - } - } - } - - return; - } - - CGRect nextPageRect = viewRect; - nextPageRect.size.width = TAP_AREA_SIZE; - nextPageRect.origin.x = (viewRect.size.width - TAP_AREA_SIZE); - - if (CGRectContainsPoint(nextPageRect, point) == true) // page++ - { - [self incrementPageNumber]; return; - } - - CGRect prevPageRect = viewRect; - prevPageRect.size.width = TAP_AREA_SIZE; - - if (CGRectContainsPoint(prevPageRect, point) == true) // page-- - { - [self decrementPageNumber]; return; - } - } -} - -- (void)handleDoubleTap:(UITapGestureRecognizer *)recognizer -{ - if (recognizer.state == UIGestureRecognizerStateRecognized) - { - CGRect viewRect = recognizer.view.bounds; // View bounds - - CGPoint point = [recognizer locationInView:recognizer.view]; // Point - - CGRect zoomArea = CGRectInset(viewRect, TAP_AREA_SIZE, TAP_AREA_SIZE); // Area - - if (CGRectContainsPoint(zoomArea, point) == true) // Double tap is inside zoom area - { - NSNumber *key = [NSNumber numberWithInteger:currentPage]; // Page number key - - ReaderContentView *targetView = [contentViews objectForKey:key]; // View - - switch (recognizer.numberOfTouchesRequired) // Touches count - { - case 1: // One finger double tap: zoom++ - { - [targetView zoomIncrement:recognizer]; break; - } - - case 2: // Two finger double tap: zoom-- - { - [targetView zoomDecrement:recognizer]; break; - } - } - - return; - } - - CGRect nextPageRect = viewRect; - nextPageRect.size.width = TAP_AREA_SIZE; - nextPageRect.origin.x = (viewRect.size.width - TAP_AREA_SIZE); - - if (CGRectContainsPoint(nextPageRect, point) == true) // page++ - { - [self incrementPageNumber]; return; - } - - CGRect prevPageRect = viewRect; - prevPageRect.size.width = TAP_AREA_SIZE; - - if (CGRectContainsPoint(prevPageRect, point) == true) // page-- - { - [self decrementPageNumber]; return; - } - } -} - -#pragma mark - ReaderContentViewDelegate methods - -- (void)contentView:(ReaderContentView *)contentView touchesBegan:(NSSet *)touches -{ - if ((mainToolbar.alpha > 0.0f) || (mainPagebar.alpha > 0.0f)) - { - if (touches.count == 1) // Single touches only - { - UITouch *touch = [touches anyObject]; // Touch info - - CGPoint point = [touch locationInView:self.view]; // Touch location - - CGRect areaRect = CGRectInset(self.view.bounds, TAP_AREA_SIZE, TAP_AREA_SIZE); - - if (CGRectContainsPoint(areaRect, point) == false) return; - } - - [mainToolbar hideToolbar]; [mainPagebar hidePagebar]; // Hide - - lastHideTime = [NSDate date]; // Set last hide time - } -} - -#pragma mark - ReaderMainToolbarDelegate methods - -- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar doneButton:(UIButton *)button -{ -#if (READER_STANDALONE == FALSE) // Option - - [self closeDocument]; // Close ReaderViewController - -#endif // end of READER_STANDALONE Option -} - -- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar thumbsButton:(UIButton *)button -{ -#if (READER_ENABLE_THUMBS == TRUE) // Option - - [[UIApplication sharedApplication] setStatusBarHidden:YES]; - - if (printInteraction != nil) [printInteraction dismissAnimated:NO]; - - ThumbsViewController *thumbsViewController = [[ThumbsViewController alloc] initWithReaderDocument:document]; - - thumbsViewController.title = self.title; thumbsViewController.delegate = self; // ThumbsViewControllerDelegate - - thumbsViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; - thumbsViewController.modalPresentationStyle = UIModalPresentationFullScreen; - - [self presentViewController:thumbsViewController animated:NO completion:NULL]; - -#endif // end of READER_ENABLE_THUMBS Option -} - -- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar exportButton:(UIButton *)button -{ - if (printInteraction != nil) [printInteraction dismissAnimated:YES]; - - NSURL *fileURL = document.fileURL; // Document file URL - - documentInteraction = [UIDocumentInteractionController interactionControllerWithURL:fileURL]; - - documentInteraction.delegate = self; // UIDocumentInteractionControllerDelegate - - [documentInteraction presentOpenInMenuFromRect:button.bounds inView:button animated:YES]; -} - -- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar printButton:(UIButton *)button -{ - if ([UIPrintInteractionController isPrintingAvailable] == YES) - { - NSURL *fileURL = document.fileURL; // Document file URL - - if ([UIPrintInteractionController canPrintURL:fileURL] == YES) - { - printInteraction = [UIPrintInteractionController sharedPrintController]; - - UIPrintInfo *printInfo = [UIPrintInfo printInfo]; - printInfo.duplex = UIPrintInfoDuplexLongEdge; - printInfo.outputType = UIPrintInfoOutputGeneral; - printInfo.jobName = document.fileName; - - printInteraction.printInfo = printInfo; - printInteraction.printingItem = fileURL; - printInteraction.showsPageRange = YES; - - if (userInterfaceIdiom == UIUserInterfaceIdiomPad) // Large device printing - { - [printInteraction presentFromRect:button.bounds inView:button animated:YES completionHandler: - ^(UIPrintInteractionController *pic, BOOL completed, NSError *error) - { - #ifdef DEBUG - if ((completed == NO) && (error != nil)) NSLog(@"%s %@", __FUNCTION__, error); - #endif - } - ]; - } - else // Handle printing on small device - { - [printInteraction presentAnimated:YES completionHandler: - ^(UIPrintInteractionController *pic, BOOL completed, NSError *error) - { - #ifdef DEBUG - if ((completed == NO) && (error != nil)) NSLog(@"%s %@", __FUNCTION__, error); - #endif - } - ]; - } - } - } -} - -- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar emailButton:(UIButton *)button -{ - if ([MFMailComposeViewController canSendMail] == NO) return; - - if (printInteraction != nil) [printInteraction dismissAnimated:YES]; - - unsigned long long fileSize = [document.fileSize unsignedLongLongValue]; - - if (fileSize < 15728640ull) // Check attachment size limit (15MB) - { - NSURL *fileURL = document.fileURL; NSString *fileName = document.fileName; - - NSData *attachment = [NSData dataWithContentsOfURL:fileURL options:(NSDataReadingMapped|NSDataReadingUncached) error:nil]; - - if (attachment != nil) // Ensure that we have valid document file attachment data available - { - MFMailComposeViewController *mailComposer = [MFMailComposeViewController new]; - - [mailComposer addAttachmentData:attachment mimeType:@"application/pdf" fileName:fileName]; - - [mailComposer setSubject:fileName]; // Use the document file name for the subject - - mailComposer.modalTransitionStyle = UIModalTransitionStyleCoverVertical; - mailComposer.modalPresentationStyle = UIModalPresentationFormSheet; - - mailComposer.mailComposeDelegate = self; // MFMailComposeViewControllerDelegate - - [self presentViewController:mailComposer animated:YES completion:NULL]; - } - } -} - -- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar markButton:(UIButton *)button -{ -#if (READER_BOOKMARKS == TRUE) // Option - - if (printInteraction != nil) [printInteraction dismissAnimated:YES]; - - if ([document.bookmarks containsIndex:currentPage]) // Remove bookmark - { - [document.bookmarks removeIndex:currentPage]; [mainToolbar setBookmarkState:NO]; - } - else // Add the bookmarked page number to the bookmark index set - { - [document.bookmarks addIndex:currentPage]; [mainToolbar setBookmarkState:YES]; - } - -#endif // end of READER_BOOKMARKS Option -} - -#pragma mark - MFMailComposeViewControllerDelegate methods - -- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error -{ -#ifdef DEBUG - if ((result == MFMailComposeResultFailed) && (error != NULL)) NSLog(@"%@", error); -#endif - - [self dismissViewControllerAnimated:YES completion:NULL]; -} - -#pragma mark - UIDocumentInteractionControllerDelegate methods - -- (void)documentInteractionControllerDidDismissOpenInMenu:(UIDocumentInteractionController *)controller -{ - documentInteraction = nil; -} - -#pragma mark - ThumbsViewControllerDelegate methods - -- (void)thumbsViewController:(ThumbsViewController *)viewController gotoPage:(NSInteger)page -{ -#if (READER_ENABLE_THUMBS == TRUE) // Option - - [self showDocumentPage:page]; - -#endif // end of READER_ENABLE_THUMBS Option -} - -- (void)dismissThumbsViewController:(ThumbsViewController *)viewController -{ -#if (READER_ENABLE_THUMBS == TRUE) // Option - - [self dismissViewControllerAnimated:NO completion:NULL]; - -#endif // end of READER_ENABLE_THUMBS Option -} - -#pragma mark - ReaderMainPagebarDelegate methods - -- (void)pagebar:(ReaderMainPagebar *)pagebar gotoPage:(NSInteger)page -{ - [self showDocumentPage:page]; -} - -#pragma mark - UIApplication notification methods - -- (void)applicationWillResign:(NSNotification *)notification -{ - [document archiveDocumentProperties]; // Save any ReaderDocument changes - - if (userInterfaceIdiom == UIUserInterfaceIdiomPad) if (printInteraction != nil) [printInteraction dismissAnimated:NO]; -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ThumbsMainToolbar.h b/Libraries external/VFR Pdf Reader/Sources/ThumbsMainToolbar.h deleted file mode 100755 index 8b3a5283a..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ThumbsMainToolbar.h +++ /dev/null @@ -1,47 +0,0 @@ -// -// ThumbsMainToolbar.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <UIKit/UIKit.h> - -#import "UIXToolbarView.h" - -@class ThumbsMainToolbar; - -@protocol ThumbsMainToolbarDelegate <NSObject> - -@required // Delegate protocols - -- (void)tappedInToolbar:(ThumbsMainToolbar *)toolbar doneButton:(UIButton *)button; -- (void)tappedInToolbar:(ThumbsMainToolbar *)toolbar showControl:(UISegmentedControl *)control; - -@end - -@interface ThumbsMainToolbar : UIXToolbarView - -@property (nonatomic, weak, readwrite) id <ThumbsMainToolbarDelegate> delegate; - -- (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ThumbsMainToolbar.m b/Libraries external/VFR Pdf Reader/Sources/ThumbsMainToolbar.m deleted file mode 100755 index e7b742fa0..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ThumbsMainToolbar.m +++ /dev/null @@ -1,176 +0,0 @@ -// -// ThumbsMainToolbar.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderConstants.h" -#import "ThumbsMainToolbar.h" - -@implementation ThumbsMainToolbar - -#pragma mark - Constants - -#define BUTTON_X 8.0f -#define BUTTON_Y 8.0f - -#define BUTTON_SPACE 8.0f -#define BUTTON_HEIGHT 30.0f - -#define BUTTON_FONT_SIZE 15.0f -#define TEXT_BUTTON_PADDING 24.0f - -#define SHOW_CONTROL_WIDTH 78.0f -#define ICON_BUTTON_WIDTH 40.0f - -#define TITLE_FONT_SIZE 19.0f -#define TITLE_HEIGHT 28.0f - -#define COLOR_BAR [UIColor colorWithRed:(248.0f/255.0f) green:(248.0f/255.0f) blue:(248.0f/255.0f) alpha:1.0] -#define COLOR_ARANCIO [UIColor colorWithRed:241.0/255.0 green:90.0/255.0 blue:34.0/255.0 alpha:1.0] - - -#pragma mark - Properties - -@synthesize delegate; - -#pragma mark - ThumbsMainToolbar instance methods - -- (instancetype)initWithFrame:(CGRect)frame -{ - return [self initWithFrame:frame title:nil]; -} - -- (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title -{ - if ((self = [super initWithFrame:frame])) - { - CGFloat viewWidth = self.bounds.size.width; // Toolbar view width - -#if (READER_FLAT_UI == TRUE) // Option - UIImage *buttonH = nil; UIImage *buttonN = nil; -#else - UIImage *buttonH = [[UIImage imageNamed:@"Reader-Button-H"] stretchableImageWithLeftCapWidth:5 topCapHeight:0]; - UIImage *buttonN = [[UIImage imageNamed:@"Reader-Button-N"] stretchableImageWithLeftCapWidth:5 topCapHeight:0]; -#endif // end of READER_FLAT_UI Option - - BOOL largeDevice = ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad); - - const CGFloat buttonSpacing = BUTTON_SPACE; //const CGFloat iconButtonWidth = ICON_BUTTON_WIDTH; - - CGFloat titleX = BUTTON_X; CGFloat titleWidth = (viewWidth - (titleX + titleX)); - - CGFloat leftButtonX = BUTTON_X; // Left-side button start X position - - UIFont *doneButtonFont = [UIFont systemFontOfSize:BUTTON_FONT_SIZE]; - NSString *doneButtonText = NSLocalizedString(@"Done", @"button"); - //CGSize doneButtonSize = [doneButtonText sizeWithFont:doneButtonFont]; - CGSize doneButtonSize = [doneButtonText sizeWithAttributes:@{NSFontAttributeName: doneButtonFont}]; - CGFloat doneButtonWidth = (doneButtonSize.width + TEXT_BUTTON_PADDING); - - UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom]; - doneButton.frame = CGRectMake(leftButtonX, BUTTON_Y, doneButtonWidth, BUTTON_HEIGHT); - [doneButton setTitleColor:COLOR_ARANCIO forState:UIControlStateNormal]; - [doneButton setTitleColor:[UIColor colorWithWhite:1.0f alpha:1.0f] forState:UIControlStateHighlighted]; - [doneButton setTitle:doneButtonText forState:UIControlStateNormal]; doneButton.titleLabel.font = doneButtonFont; - [doneButton addTarget:self action:@selector(doneButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; - [doneButton setBackgroundImage:buttonH forState:UIControlStateHighlighted]; - [doneButton setBackgroundImage:buttonN forState:UIControlStateNormal]; - doneButton.autoresizingMask = UIViewAutoresizingNone; - //doneButton.backgroundColor = [UIColor grayColor]; - doneButton.exclusiveTouch = YES; - - [self addSubview:doneButton]; //leftButtonX += (doneButtonWidth + buttonSpacing); - - titleX += (doneButtonWidth + buttonSpacing); titleWidth -= (doneButtonWidth + buttonSpacing); - -#if (READER_BOOKMARKS == TRUE) // Option - - CGFloat showControlX = (viewWidth - (SHOW_CONTROL_WIDTH + buttonSpacing)); - - UIImage *thumbsImage = [UIImage imageNamed:@"Reader-Thumbs"]; - UIImage *bookmarkImage = [UIImage imageNamed:@"Reader-Mark-Y"]; - NSArray *buttonItems = [NSArray arrayWithObjects:thumbsImage, bookmarkImage, nil]; - - BOOL useTint = [self respondsToSelector:@selector(tintColor)]; // iOS 7 and up - - UISegmentedControl *showControl = [[UISegmentedControl alloc] initWithItems:buttonItems]; - showControl.frame = CGRectMake(showControlX, BUTTON_Y, SHOW_CONTROL_WIDTH, BUTTON_HEIGHT); - - showControl.tintColor = (useTint ? [UIColor blackColor] : [UIColor colorWithWhite:0.8f alpha:1.0f]); - showControl.tintColor = COLOR_ARANCIO; - - showControl.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin; - //showControl.segmentedControlStyle = UISegmentedControlStyleBar; - showControl.selectedSegmentIndex = 0; // Default segment index - showControl.exclusiveTouch = YES; - - [showControl addTarget:self action:@selector(showControlTapped:) forControlEvents:UIControlEventValueChanged]; - - [self addSubview:showControl]; - - titleWidth -= (SHOW_CONTROL_WIDTH + buttonSpacing); - -#endif // end of READER_BOOKMARKS Option - - if (largeDevice == YES) // Show document filename in toolbar - { - CGRect titleRect = CGRectMake(titleX, BUTTON_Y, titleWidth, TITLE_HEIGHT); - - UILabel *titleLabel = [[UILabel alloc] initWithFrame:titleRect]; - - titleLabel.textAlignment = NSTextAlignmentCenter; - titleLabel.font = [UIFont systemFontOfSize:TITLE_FONT_SIZE]; - titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth; - titleLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters; - titleLabel.textColor = [UIColor colorWithWhite:0.0f alpha:1.0f]; - titleLabel.backgroundColor = [UIColor clearColor]; - titleLabel.adjustsFontSizeToFitWidth = YES; - titleLabel.minimumScaleFactor = 0.75f; - titleLabel.text = title; -#if (READER_FLAT_UI == FALSE) // Option - titleLabel.shadowColor = [UIColor colorWithWhite:0.65f alpha:1.0f]; - titleLabel.shadowOffset = CGSizeMake(0.0f, 1.0f); -#endif // end of READER_FLAT_UI Option - - [self addSubview:titleLabel]; - } - } - - return self; -} - -#pragma mark - UISegmentedControl action methods - -- (void)showControlTapped:(UISegmentedControl *)control -{ - [delegate tappedInToolbar:self showControl:control]; -} - -#pragma mark - UIButton action methods - -- (void)doneButtonTapped:(UIButton *)button -{ - [delegate tappedInToolbar:self doneButton:button]; -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ThumbsViewController.h b/Libraries external/VFR Pdf Reader/Sources/ThumbsViewController.h deleted file mode 100755 index db36a870d..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ThumbsViewController.h +++ /dev/null @@ -1,66 +0,0 @@ -// -// ThumbsViewController.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <UIKit/UIKit.h> - -#import "ThumbsMainToolbar.h" -#import "ReaderThumbsView.h" - -@class ReaderDocument; -@class ThumbsViewController; - -@protocol ThumbsViewControllerDelegate <NSObject> - -@required // Delegate protocols - -- (void)thumbsViewController:(ThumbsViewController *)viewController gotoPage:(NSInteger)page; - -- (void)dismissThumbsViewController:(ThumbsViewController *)viewController; - -@end - -@interface ThumbsViewController : UIViewController - -@property (nonatomic, weak, readwrite) id <ThumbsViewControllerDelegate> delegate; - -- (instancetype)initWithReaderDocument:(ReaderDocument *)object; - -@end - -#pragma mark - - -// -// ThumbsPageThumb class interface -// - -@interface ThumbsPageThumb : ReaderThumbView - -- (CGSize)maximumContentSize; - -- (void)showText:(NSString *)text; - -- (void)showBookmark:(BOOL)show; - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/ThumbsViewController.m b/Libraries external/VFR Pdf Reader/Sources/ThumbsViewController.m deleted file mode 100755 index 28a6010fe..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/ThumbsViewController.m +++ /dev/null @@ -1,518 +0,0 @@ -// -// ThumbsViewController.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderConstants.h" -#import "ThumbsViewController.h" -#import "ReaderThumbRequest.h" -#import "ReaderThumbCache.h" -#import "ReaderDocument.h" - -#import <QuartzCore/QuartzCore.h> - -@interface ThumbsViewController () <ThumbsMainToolbarDelegate, ReaderThumbsViewDelegate> - -@end - -@implementation ThumbsViewController -{ - ReaderDocument *document; - - ThumbsMainToolbar *mainToolbar; - - ReaderThumbsView *theThumbsView; - - NSMutableArray *bookmarked; - - CGPoint thumbsOffset; - CGPoint markedOffset; - - BOOL updateBookmarked; - BOOL showBookmarked; -} - -#pragma mark - Constants - -#define STATUS_HEIGHT 20.0f - -#define TOOLBAR_HEIGHT 44.0f - -#define PAGE_THUMB_SMALL 160 -#define PAGE_THUMB_LARGE 256 - -#pragma mark - Properties - -@synthesize delegate; - -#pragma mark - UIViewController methods - -- (instancetype)initWithReaderDocument:(ReaderDocument *)object -{ - if ((self = [super initWithNibName:nil bundle:nil])) // Initialize superclass - { - if ((object != nil) && ([object isKindOfClass:[ReaderDocument class]])) // Valid object - { - updateBookmarked = YES; bookmarked = [NSMutableArray new]; // Bookmarked pages - - document = object; // Retain the ReaderDocument object for our use - } - else // Invalid ReaderDocument object - { - self = nil; - } - } - - return self; -} - -- (void)viewDidLoad -{ - [super viewDidLoad]; - - assert(delegate != nil); assert(document != nil); - - self.view.backgroundColor = [UIColor grayColor]; // Neutral gray - - CGRect scrollViewRect = self.view.bounds; UIView *fakeStatusBar = nil; - - if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) // iOS 7+ - { - if ([self prefersStatusBarHidden] == NO) // Visible status bar - { - CGRect statusBarRect = self.view.bounds; // Status bar frame - statusBarRect.size.height = STATUS_HEIGHT; // Default status height - fakeStatusBar = [[UIView alloc] initWithFrame:statusBarRect]; // UIView - fakeStatusBar.autoresizingMask = UIViewAutoresizingFlexibleWidth; - fakeStatusBar.backgroundColor = [UIColor blackColor]; - fakeStatusBar.contentMode = UIViewContentModeRedraw; - fakeStatusBar.userInteractionEnabled = NO; - - scrollViewRect.origin.y += STATUS_HEIGHT; scrollViewRect.size.height -= STATUS_HEIGHT; - } - } - - NSString *toolbarTitle = [document.fileName stringByDeletingPathExtension]; - - CGRect toolbarRect = scrollViewRect; // Toolbar frame - toolbarRect.size.height = TOOLBAR_HEIGHT; // Default toolbar height - mainToolbar = [[ThumbsMainToolbar alloc] initWithFrame:toolbarRect title:toolbarTitle]; // ThumbsMainToolbar - mainToolbar.delegate = self; // ThumbsMainToolbarDelegate - [self.view addSubview:mainToolbar]; - - if (fakeStatusBar != nil) [self.view addSubview:fakeStatusBar]; // Add status bar background view - - UIEdgeInsets scrollViewInsets = UIEdgeInsetsZero; // Scroll view toolbar insets - - if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) // iPad - { - scrollViewRect.origin.y += TOOLBAR_HEIGHT; scrollViewRect.size.height -= TOOLBAR_HEIGHT; - } - else // Set UIScrollView insets for non-UIUserInterfaceIdiomPad case - { - scrollViewInsets.top = TOOLBAR_HEIGHT; - } - - theThumbsView = [[ReaderThumbsView alloc] initWithFrame:scrollViewRect]; // ReaderThumbsView - theThumbsView.contentInset = scrollViewInsets; theThumbsView.scrollIndicatorInsets = scrollViewInsets; - theThumbsView.delegate = self; // ReaderThumbsViewDelegate - [self.view insertSubview:theThumbsView belowSubview:mainToolbar]; - - if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) - { - CGRect viewRect = self.view.bounds; CGSize viewSize = viewRect.size; // View size - - CGFloat min = ((viewSize.width < viewSize.height) ? viewSize.width : viewSize.height); - - CGFloat thumbSize = ((min > 320.0f) ? floorf(min / 3.0f) : PAGE_THUMB_SMALL); - - [theThumbsView setThumbSize:CGSizeMake(thumbSize, thumbSize)]; - } - else // Set thumb size for large (iPad) devices - { - [theThumbsView setThumbSize:CGSizeMake(PAGE_THUMB_LARGE, PAGE_THUMB_LARGE)]; - } -} - -- (void)viewWillAppear:(BOOL)animated -{ - [super viewWillAppear:animated]; - - [theThumbsView reloadThumbsCenterOnIndex:([document.pageNumber integerValue] - 1)]; // Page -} - -- (void)viewDidAppear:(BOOL)animated -{ - [super viewDidAppear:animated]; -} - -- (void)viewWillDisappear:(BOOL)animated -{ - [super viewWillDisappear:animated]; -} - -- (void)viewDidDisappear:(BOOL)animated -{ - [super viewDidDisappear:animated]; -} - -- (void)viewDidUnload -{ -#ifdef DEBUG - NSLog(@"%s", __FUNCTION__); -#endif - - mainToolbar = nil; theThumbsView = nil; - - [super viewDidUnload]; -} - -- (BOOL)prefersStatusBarHidden -{ - return YES; -} - -- (UIStatusBarStyle)preferredStatusBarStyle -{ - return UIStatusBarStyleLightContent; -} - -- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation -{ - return YES; -} - -/* -- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration -{ -} - -- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration -{ -} - -- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation -{ - //if (fromInterfaceOrientation == self.interfaceOrientation) return; -} -*/ - -- (void)didReceiveMemoryWarning -{ -#ifdef DEBUG - NSLog(@"%s", __FUNCTION__); -#endif - - [super didReceiveMemoryWarning]; -} - -#pragma mark - ThumbsMainToolbarDelegate methods - -- (void)tappedInToolbar:(ThumbsMainToolbar *)toolbar showControl:(UISegmentedControl *)control -{ - switch (control.selectedSegmentIndex) - { - case 0: // Show all page thumbs - { - showBookmarked = NO; // Show all thumbs - - markedOffset = [theThumbsView insetContentOffset]; - - [theThumbsView reloadThumbsContentOffset:thumbsOffset]; - - break; // We're done - } - - case 1: // Show bookmarked thumbs - { - showBookmarked = YES; // Only bookmarked - - thumbsOffset = [theThumbsView insetContentOffset]; - - if (updateBookmarked == YES) // Update bookmarked list - { - [bookmarked removeAllObjects]; // Empty the list first - - [document.bookmarks enumerateIndexesUsingBlock: // Enumerate - ^(NSUInteger page, BOOL *stop) - { - [bookmarked addObject:[NSNumber numberWithInteger:page]]; - } - ]; - - markedOffset = CGPointZero; updateBookmarked = NO; // Reset - } - - [theThumbsView reloadThumbsContentOffset:markedOffset]; - - break; // We're done - } - } -} - -- (void)tappedInToolbar:(ThumbsMainToolbar *)toolbar doneButton:(UIButton *)button -{ - [[UIApplication sharedApplication] setStatusBarHidden:NO]; - - [delegate dismissThumbsViewController:self]; // Dismiss thumbs display -} - -#pragma mark - UIThumbsViewDelegate methods - -- (NSUInteger)numberOfThumbsInThumbsView:(ReaderThumbsView *)thumbsView -{ - return (showBookmarked ? bookmarked.count : [document.pageCount integerValue]); -} - -- (id)thumbsView:(ReaderThumbsView *)thumbsView thumbCellWithFrame:(CGRect)frame -{ - return [[ThumbsPageThumb alloc] initWithFrame:frame]; -} - -- (void)thumbsView:(ReaderThumbsView *)thumbsView updateThumbCell:(ThumbsPageThumb *)thumbCell forIndex:(NSInteger)index -{ - CGSize size = [thumbCell maximumContentSize]; // Get the cell's maximum content size - - NSInteger page = (showBookmarked ? [[bookmarked objectAtIndex:index] integerValue] : (index + 1)); - - [thumbCell showText:[[NSString alloc] initWithFormat:@"%i", (int)page]]; // Page number place holder - - [thumbCell showBookmark:[document.bookmarks containsIndex:page]]; // Show bookmarked status - - NSURL *fileURL = document.fileURL; NSString *guid = document.guid; NSString *phrase = document.password; // Document info - - ReaderThumbRequest *thumbRequest = [ReaderThumbRequest newForView:thumbCell fileURL:fileURL password:phrase guid:guid page:page size:size]; - - UIImage *image = [[ReaderThumbCache sharedInstance] thumbRequest:thumbRequest priority:YES]; // Request the thumbnail - - if ([image isKindOfClass:[UIImage class]]) [thumbCell showImage:image]; // Show image from cache -} - -- (void)thumbsView:(ReaderThumbsView *)thumbsView refreshThumbCell:(ThumbsPageThumb *)thumbCell forIndex:(NSInteger)index -{ - NSInteger page = (showBookmarked ? [[bookmarked objectAtIndex:index] integerValue] : (index + 1)); - - [thumbCell showBookmark:[document.bookmarks containsIndex:page]]; // Show bookmarked status -} - -- (void)thumbsView:(ReaderThumbsView *)thumbsView didSelectThumbWithIndex:(NSInteger)index -{ - [[UIApplication sharedApplication] setStatusBarHidden:NO]; - - NSInteger page = (showBookmarked ? [[bookmarked objectAtIndex:index] integerValue] : (index + 1)); - - [delegate thumbsViewController:self gotoPage:page]; // Show the selected page - - [delegate dismissThumbsViewController:self]; // Dismiss thumbs display -} - -- (void)thumbsView:(ReaderThumbsView *)thumbsView didPressThumbWithIndex:(NSInteger)index -{ - NSInteger page = (showBookmarked ? [[bookmarked objectAtIndex:index] integerValue] : (index + 1)); - - if ([document.bookmarks containsIndex:page]) [document.bookmarks removeIndex:page]; else [document.bookmarks addIndex:page]; - - updateBookmarked = YES; [thumbsView refreshThumbWithIndex:index]; // Refresh page thumb -} - -@end - -#pragma mark - - -// -// ThumbsPageThumb class implementation -// - -@implementation ThumbsPageThumb -{ - UIView *backView; - - UIView *tintView; - - UILabel *textLabel; - - UIImageView *bookMark; - - CGSize maximumSize; - - CGRect defaultRect; -} - -#pragma mark - Constants - -#define CONTENT_INSET 8.0f - -#pragma mark - ThumbsPageThumb instance methods - -- (CGRect)markRectInImageView -{ - CGRect iconRect = bookMark.frame; iconRect.origin.y = (-2.0f); - - iconRect.origin.x = (imageView.bounds.size.width - bookMark.image.size.width - 8.0f); - - return iconRect; // Frame position rect inside of image view -} - -- (instancetype)initWithFrame:(CGRect)frame -{ - if ((self = [super initWithFrame:frame])) - { - imageView.contentMode = UIViewContentModeCenter; - - defaultRect = CGRectInset(self.bounds, CONTENT_INSET, CONTENT_INSET); - - maximumSize = defaultRect.size; // Maximum thumb content size - - CGFloat newWidth = ((defaultRect.size.width / 4.0f) * 3.0f); - - CGFloat offsetX = ((defaultRect.size.width - newWidth) * 0.5f); - - defaultRect.size.width = newWidth; defaultRect.origin.x += offsetX; - - imageView.frame = defaultRect; // Update the image view frame - - CGFloat fontSize = (([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) ? 19.0f : 16.0f); - - textLabel = [[UILabel alloc] initWithFrame:defaultRect]; - - textLabel.autoresizesSubviews = NO; - textLabel.userInteractionEnabled = NO; - textLabel.contentMode = UIViewContentModeRedraw; - textLabel.autoresizingMask = UIViewAutoresizingNone; - textLabel.textAlignment = NSTextAlignmentCenter; - textLabel.font = [UIFont systemFontOfSize:fontSize]; - textLabel.textColor = [UIColor colorWithWhite:0.24f alpha:1.0f]; - textLabel.backgroundColor = [UIColor whiteColor]; - - [self insertSubview:textLabel belowSubview:imageView]; - - backView = [[UIView alloc] initWithFrame:defaultRect]; - - backView.autoresizesSubviews = NO; - backView.userInteractionEnabled = NO; - backView.contentMode = UIViewContentModeRedraw; - backView.autoresizingMask = UIViewAutoresizingNone; - backView.backgroundColor = [UIColor whiteColor]; - -#if (READER_SHOW_SHADOWS == TRUE) // Option - - backView.layer.shadowOffset = CGSizeMake(0.0f, 1.0f); - backView.layer.shadowRadius = 3.0f; backView.layer.shadowOpacity = 1.0f; - backView.layer.shadowPath = [UIBezierPath bezierPathWithRect:backView.bounds].CGPath; - -#endif // end of READER_SHOW_SHADOWS Option - - [self insertSubview:backView belowSubview:textLabel]; - - tintView = [[UIView alloc] initWithFrame:imageView.bounds]; - - tintView.hidden = YES; - tintView.autoresizesSubviews = NO; - tintView.userInteractionEnabled = NO; - tintView.contentMode = UIViewContentModeRedraw; - tintView.autoresizingMask = UIViewAutoresizingNone; - tintView.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.25f]; - - [imageView addSubview:tintView]; - - UIImage *image = [UIImage imageNamed:@"Reader-Mark-Y"]; - - bookMark = [[UIImageView alloc] initWithImage:image]; - - bookMark.hidden = YES; - bookMark.autoresizesSubviews = NO; - bookMark.userInteractionEnabled = NO; - bookMark.contentMode = UIViewContentModeCenter; - bookMark.autoresizingMask = UIViewAutoresizingNone; - bookMark.frame = [self markRectInImageView]; - - [imageView addSubview:bookMark]; - } - - return self; -} - -- (CGSize)maximumContentSize -{ - return maximumSize; -} - -- (void)showImage:(UIImage *)image -{ - NSInteger x = (self.bounds.size.width * 0.5f); - NSInteger y = (self.bounds.size.height * 0.5f); - - CGPoint location = CGPointMake(x, y); // Center point - - CGRect viewRect = CGRectZero; viewRect.size = image.size; - - textLabel.bounds = viewRect; textLabel.center = location; // Position - - imageView.bounds = viewRect; imageView.center = location; imageView.image = image; - - bookMark.frame = [self markRectInImageView]; // Position bookmark image - - tintView.frame = imageView.bounds; backView.bounds = viewRect; backView.center = location; - -#if (READER_SHOW_SHADOWS == TRUE) // Option - - backView.layer.shadowPath = [UIBezierPath bezierPathWithRect:backView.bounds].CGPath; - -#endif // end of READER_SHOW_SHADOWS Option -} - -- (void)reuse -{ - [super reuse]; // Reuse thumb view - - textLabel.text = nil; textLabel.frame = defaultRect; - - imageView.image = nil; imageView.frame = defaultRect; - - bookMark.hidden = YES; bookMark.frame = [self markRectInImageView]; - - tintView.hidden = YES; tintView.frame = imageView.bounds; backView.frame = defaultRect; - -#if (READER_SHOW_SHADOWS == TRUE) // Option - - backView.layer.shadowPath = [UIBezierPath bezierPathWithRect:backView.bounds].CGPath; - -#endif // end of READER_SHOW_SHADOWS Option -} - -- (void)showBookmark:(BOOL)show -{ - bookMark.hidden = (show ? NO : YES); -} - -- (void)showTouched:(BOOL)touched -{ - tintView.hidden = (touched ? NO : YES); -} - -- (void)showText:(NSString *)text -{ - textLabel.text = text; -} - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/UIXToolbarView.h b/Libraries external/VFR Pdf Reader/Sources/UIXToolbarView.h deleted file mode 100755 index 5ca89bf4f..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/UIXToolbarView.h +++ /dev/null @@ -1,40 +0,0 @@ -// -// UIXToolbarView.h -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import <UIKit/UIKit.h> - -@interface UIXToolbarView : UIView - -@end - -#pragma mark - - -// -// UIXToolbarShadow class interface -// - -@interface UIXToolbarShadow : UIView - -@end diff --git a/Libraries external/VFR Pdf Reader/Sources/UIXToolbarView.m b/Libraries external/VFR Pdf Reader/Sources/UIXToolbarView.m deleted file mode 100755 index 44829db37..000000000 --- a/Libraries external/VFR Pdf Reader/Sources/UIXToolbarView.m +++ /dev/null @@ -1,131 +0,0 @@ -// -// UIXToolbarView.m -// Reader v2.8.6 -// -// Created by Julius Oklamcak on 2011-09-01. -// Copyright © 2011-2015 Julius Oklamcak. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to -// do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#import "ReaderConstants.h" -#import "UIXToolbarView.h" - -#import <QuartzCore/QuartzCore.h> - -@implementation UIXToolbarView - -#pragma mark - Constants - -#define SHADOW_HEIGHT 4.0f - -#pragma mark - UIXToolbarView class methods - -+ (Class)layerClass -{ -#if (READER_FLAT_UI == FALSE) // Option - return [CAGradientLayer class]; -#else - return [CALayer class]; -#endif // end of READER_FLAT_UI Option -} - -#pragma mark - UIXToolbarView instance methods - -- (instancetype)initWithFrame:(CGRect)frame -{ - if ((self = [super initWithFrame:frame])) - { - self.autoresizesSubviews = YES; - self.userInteractionEnabled = YES; - self.contentMode = UIViewContentModeRedraw; - self.autoresizingMask = UIViewAutoresizingFlexibleWidth; - - if ([self.layer isKindOfClass:[CAGradientLayer class]]) - { - self.backgroundColor = [UIColor clearColor]; - - CAGradientLayer *layer = (CAGradientLayer *)self.layer; - UIColor *liteColor = [UIColor colorWithWhite:0.92f alpha:0.8f]; - UIColor *darkColor = [UIColor colorWithWhite:0.32f alpha:0.8f]; - layer.colors = [NSArray arrayWithObjects:(id)liteColor.CGColor, (id)darkColor.CGColor, nil]; - - CGRect shadowRect = self.bounds; shadowRect.origin.y += shadowRect.size.height; shadowRect.size.height = SHADOW_HEIGHT; - - UIXToolbarShadow *shadowView = [[UIXToolbarShadow alloc] initWithFrame:shadowRect]; - - [self addSubview:shadowView]; // Add shadow to toolbar - } - else // Follow The Fuglyosity of Flat Fad - { - self.backgroundColor = [UIColor colorWithWhite:0.94f alpha:0.94f]; - - CGRect lineRect = self.bounds; lineRect.origin.y += lineRect.size.height; lineRect.size.height = 1.0f; - - UIView *lineView = [[UIView alloc] initWithFrame:lineRect]; - lineView.autoresizesSubviews = NO; - lineView.userInteractionEnabled = NO; - lineView.contentMode = UIViewContentModeRedraw; - lineView.autoresizingMask = UIViewAutoresizingFlexibleWidth; - lineView.backgroundColor = [UIColor colorWithWhite:0.64f alpha:0.94f]; - [self addSubview:lineView]; - } - } - - return self; -} - -@end - -#pragma mark - - -// -// UIXToolbarShadow class implementation -// - -@implementation UIXToolbarShadow - -#pragma mark - UIXToolbarShadow class methods - -+ (Class)layerClass -{ - return [CAGradientLayer class]; -} - -#pragma mark - UIXToolbarShadow instance methods - -- (instancetype)initWithFrame:(CGRect)frame -{ - if ((self = [super initWithFrame:frame])) - { - self.autoresizesSubviews = NO; - self.userInteractionEnabled = NO; - self.contentMode = UIViewContentModeRedraw; - self.autoresizingMask = UIViewAutoresizingFlexibleWidth; - self.backgroundColor = [UIColor clearColor]; - - CAGradientLayer *layer = (CAGradientLayer *)self.layer; - UIColor *blackColor = [UIColor colorWithWhite:0.24f alpha:1.0f]; - UIColor *clearColor = [UIColor colorWithWhite:0.24f alpha:0.0f]; - layer.colors = [NSArray arrayWithObjects:(id)blackColor.CGColor, (id)clearColor.CGColor, nil]; - } - - return self; -} - -@end |