libs-gui/Source/NSPDFImageRep.m

89 lines
2 KiB
Mathematica
Raw Normal View History

2019-11-18 10:23:30 +00:00
/* Implementation of class NSPDFImageRep
Copyright (C) 2019 Free Software Foundation, Inc.
By: Gregory Casamento <greg.casamento@gmail.com>
2019-11-18 10:23:30 +00:00
Date: Fri Nov 15 04:24:27 EST 2019
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02111 USA.
*/
#include <AppKit/NSPDFImageRep.h>
#include <Foundation/NSString.h>
#include <Foundation/NSData.h>
2019-11-18 10:23:30 +00:00
@implementation NSPDFImageRep
+ (BOOL) canInitWithData: (NSData *)imageData
{
NSData *header = [imageData subdataWithRange: NSMakeRange(0,4)];
NSString *str = [[NSString alloc] initWithData: header encoding: NSUTF8StringEncoding];
AUTORELEASE(str);
return [str isEqualToString: @"%PDF"] &&
[super canInitWithData: imageData];
}
2019-11-18 10:23:30 +00:00
+ (instancetype) imageRepWithData: (NSData *)imageData
{
2019-11-21 06:17:14 +00:00
return AUTORELEASE([[self alloc] initWithData: imageData]);
2019-11-18 10:23:30 +00:00
}
- (instancetype) initWithData: (NSData *)imageData
{
2019-11-22 07:16:05 +00:00
self = [super init];
if(self != nil)
{
#if HAVE_IMAGEMAGICK
#endif
2019-11-22 07:16:05 +00:00
}
return self;
2019-11-18 10:23:30 +00:00
}
- (NSRect) bounds
{
2019-11-22 07:16:05 +00:00
return _bounds;
2019-11-18 10:23:30 +00:00
}
- (void) setBounds: (NSRect)bounds
{
2019-11-22 07:16:05 +00:00
_bounds = bounds;
2019-11-18 10:23:30 +00:00
}
- (NSInteger) currentPage
{
2019-11-22 07:16:05 +00:00
return _currentPage;
2019-11-18 10:23:30 +00:00
}
- (void) setCurrentPage: (NSInteger)currentPage
{
2019-11-22 07:16:05 +00:00
_currentPage = currentPage;
2019-11-18 10:23:30 +00:00
}
- (NSInteger) pageCount
{
2019-11-22 07:16:05 +00:00
return _pageCount;
2019-11-18 10:23:30 +00:00
}
- (NSData *) PDFRepresentation
{
2019-11-22 07:16:05 +00:00
return _pdfRepresentation;
2019-11-18 10:23:30 +00:00
}
@end