Revision: 3972
http://skim-app.svn.sourceforge.net/skim-app/?rev=3972&view=rev
Author: hofman
Date: 2008-06-05 05:34:09 -0700 (Thu, 05 Jun 2008)
Log Message:
-----------
Separate files for formatter
Modified Paths:
--------------
trunk/SKLineInspector.h
trunk/SKLineInspector.m
trunk/Skim.xcodeproj/project.pbxproj
Added Paths:
-----------
trunk/SKNumberArrayFormatter.h
trunk/SKNumberArrayFormatter.m
Modified: trunk/SKLineInspector.h
===================================================================
--- trunk/SKLineInspector.h 2008-06-05 09:51:48 UTC (rev 3971)
+++ trunk/SKLineInspector.h 2008-06-05 12:34:09 UTC (rev 3972)
@@ -92,9 +92,3 @@
- (void)changeEndLineStyle:(id)sender;
@end
-
-
[EMAIL PROTECTED] SKNumberArrayFormatter : NSFormatter {
- NSNumberFormatter *numberFormatter;
-}
[EMAIL PROTECTED]
Modified: trunk/SKLineInspector.m
===================================================================
--- trunk/SKLineInspector.m 2008-06-05 09:51:48 UTC (rev 3971)
+++ trunk/SKLineInspector.m 2008-06-05 12:34:09 UTC (rev 3972)
@@ -40,6 +40,7 @@
#import "SKLineWell.h"
#import "PDFAnnotation_SKExtensions.h"
#import "NSSegmentedControl_SKExtensions.h"
+#import "SKNumberArrayFormatter.h"
NSString *SKLineInspectorLineWidthDidChangeNotification =
@"SKLineInspectorLineWidthDidChangeNotification";
NSString *SKLineInspectorLineStyleDidChangeNotification =
@"SKLineInspectorLineStyleDidChangeNotification";
@@ -516,88 +517,3 @@
}
@end
-
-#pragma mark -
-
[EMAIL PROTECTED] SKNumberArrayFormatter
-
-- (void)commonInit {
- numberFormatter = [[NSNumberFormatter alloc] init];
- [numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
- [numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle];
- [numberFormatter setFormat:@"0;0;-0"];
- [numberFormatter setMinimum:[NSNumber numberWithFloat:0.0]];
-}
-
- - (id)init {
- if (self = [super init])
- [self commonInit];
- return self;
- }
-
- - (id)initWithCoder:(NSCoder *)aCoder {
- if (self = [super initWithCoder:aCoder])
- [self commonInit];
- return self;
-}
-
-- (void)dealloc {
- [numberFormatter release];
- [super dealloc];
-}
-
-- (NSString *)stringForObjectValue:(id)obj {
- if ([obj isKindOfClass:[NSNumber class]])
- obj = [NSArray arrayWithObjects:obj, nil];
-
- NSEnumerator *numberEnum = [obj objectEnumerator];
- NSNumber *number;
- NSMutableString *string = [NSMutableString string];
-
- while (number = [numberEnum nextObject]) {
- NSString *s = [numberFormatter stringForObjectValue:number];
- if ([s length]) {
- if ([string length])
- [string appendString:@" "];
- [string appendString:s];
- }
- }
- return string;
-}
-
-- (NSAttributedString *)attributedStringForObjectValue:(id)obj
withDefaultAttributes:(NSDictionary *)attrs {
- if ([obj isKindOfClass:[NSNumber class]])
- obj = [NSArray arrayWithObjects:obj, nil];
-
- NSEnumerator *numberEnum = [obj objectEnumerator];
- NSNumber *number;
- NSMutableAttributedString *string = [[[NSMutableAttributedString alloc]
init] autorelease];
-
- while (number = [numberEnum nextObject]) {
- NSAttributedString *s = [numberFormatter
attributedStringForObjectValue:number withDefaultAttributes:attrs];
- if ([s length]) {
- if ([string length])
- [string appendAttributedString:[[[NSAttributedString alloc]
initWithString:@" " attributes:attrs] autorelease]];
- [string appendAttributedString:s];
- }
- }
- return string;
-}
-
-- (BOOL)getObjectValue:(id *)obj forString:(NSString *)string
errorDescription:(NSString **)error {
- NSEnumerator *stringEnum = [[string componentsSeparatedByString:@" "]
objectEnumerator];
- NSString *s;
- NSNumber *number;
- NSMutableArray *array = [NSMutableArray array];
- BOOL success = YES;
-
- while (success && (s = [stringEnum nextObject])) {
- if ([s length] && (success = [numberFormatter getObjectValue:&number
forString:s errorDescription:error]))
- [array addObject:number];
- }
- if (success)
- *obj = array;
- return success;
-}
-
[EMAIL PROTECTED]
Added: trunk/SKNumberArrayFormatter.h
===================================================================
--- trunk/SKNumberArrayFormatter.h (rev 0)
+++ trunk/SKNumberArrayFormatter.h 2008-06-05 12:34:09 UTC (rev 3972)
@@ -0,0 +1,45 @@
+//
+// SKNumberArrayFormatter.h
+// Skim
+//
+// Created by Christiaan Hofman on 6/5/08.
+/*
+ This software is Copyright (c) 2008
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Cocoa/Cocoa.h>
+
+
[EMAIL PROTECTED] SKNumberArrayFormatter : NSFormatter {
+ NSNumberFormatter *numberFormatter;
+}
[EMAIL PROTECTED]
Added: trunk/SKNumberArrayFormatter.m
===================================================================
--- trunk/SKNumberArrayFormatter.m (rev 0)
+++ trunk/SKNumberArrayFormatter.m 2008-06-05 12:34:09 UTC (rev 3972)
@@ -0,0 +1,123 @@
+//
+// SKNumberArrayFormatter.m
+// Skim
+//
+// Created by Christiaan Hofman on 6/5/08.
+/*
+ This software is Copyright (c) 2008
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "SKNumberArrayFormatter.h"
+
+
[EMAIL PROTECTED] SKNumberArrayFormatter
+
+- (void)commonInit {
+ numberFormatter = [[NSNumberFormatter alloc] init];
+ [numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
+ [numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle];
+ [numberFormatter setFormat:@"0;0;-0"];
+ [numberFormatter setMinimum:[NSNumber numberWithFloat:0.0]];
+}
+
+ - (id)init {
+ if (self = [super init])
+ [self commonInit];
+ return self;
+ }
+
+ - (id)initWithCoder:(NSCoder *)aCoder {
+ if (self = [super initWithCoder:aCoder])
+ [self commonInit];
+ return self;
+}
+
+- (void)dealloc {
+ [numberFormatter release];
+ [super dealloc];
+}
+
+- (NSString *)stringForObjectValue:(id)obj {
+ if ([obj isKindOfClass:[NSNumber class]])
+ obj = [NSArray arrayWithObjects:obj, nil];
+
+ NSEnumerator *numberEnum = [obj objectEnumerator];
+ NSNumber *number;
+ NSMutableString *string = [NSMutableString string];
+
+ while (number = [numberEnum nextObject]) {
+ NSString *s = [numberFormatter stringForObjectValue:number];
+ if ([s length]) {
+ if ([string length])
+ [string appendString:@" "];
+ [string appendString:s];
+ }
+ }
+ return string;
+}
+
+- (NSAttributedString *)attributedStringForObjectValue:(id)obj
withDefaultAttributes:(NSDictionary *)attrs {
+ if ([obj isKindOfClass:[NSNumber class]])
+ obj = [NSArray arrayWithObjects:obj, nil];
+
+ NSEnumerator *numberEnum = [obj objectEnumerator];
+ NSNumber *number;
+ NSMutableAttributedString *string = [[[NSMutableAttributedString alloc]
init] autorelease];
+
+ while (number = [numberEnum nextObject]) {
+ NSAttributedString *s = [numberFormatter
attributedStringForObjectValue:number withDefaultAttributes:attrs];
+ if ([s length]) {
+ if ([string length])
+ [string appendAttributedString:[[[NSAttributedString alloc]
initWithString:@" " attributes:attrs] autorelease]];
+ [string appendAttributedString:s];
+ }
+ }
+ return string;
+}
+
+- (BOOL)getObjectValue:(id *)obj forString:(NSString *)string
errorDescription:(NSString **)error {
+ NSEnumerator *stringEnum = [[string componentsSeparatedByString:@" "]
objectEnumerator];
+ NSString *s;
+ NSNumber *number;
+ NSMutableArray *array = [NSMutableArray array];
+ BOOL success = YES;
+
+ while (success && (s = [stringEnum nextObject])) {
+ if ([s length] && (success = [numberFormatter getObjectValue:&number
forString:s errorDescription:error]))
+ [array addObject:number];
+ }
+ if (success)
+ *obj = array;
+ return success;
+}
+
[EMAIL PROTECTED]
Modified: trunk/Skim.xcodeproj/project.pbxproj
===================================================================
--- trunk/Skim.xcodeproj/project.pbxproj 2008-06-05 09:51:48 UTC (rev
3971)
+++ trunk/Skim.xcodeproj/project.pbxproj 2008-06-05 12:34:09 UTC (rev
3972)
@@ -96,6 +96,7 @@
CE4643D80DF6B63500CFD8D2 /* SKTextCommand.m in Sources */ =
{isa = PBXBuildFile; fileRef = CE4643D70DF6B63500CFD8D2 /* SKTextCommand.m */;
};
CE4643DB0DF6B66000CFD8D2 /* SKIndexCommand.m in Sources */ =
{isa = PBXBuildFile; fileRef = CE4643DA0DF6B66000CFD8D2 /* SKIndexCommand.m */;
};
CE4643DE0DF6B77800CFD8D2 /* SKBoundsCommand.m in Sources */ =
{isa = PBXBuildFile; fileRef = CE4643DD0DF6B77800CFD8D2 /* SKBoundsCommand.m
*/; };
+ CE4645910DF8140200CFD8D2 /* SKNumberArrayFormatter.m in Sources
*/ = {isa = PBXBuildFile; fileRef = CE4645900DF8140200CFD8D2 /*
SKNumberArrayFormatter.m */; };
CE48BAD80C089EA300A166C6 /* SKTemplateParser.m in Sources */ =
{isa = PBXBuildFile; fileRef = CE48BAD60C089EA300A166C6 /* SKTemplateParser.m
*/; };
CE4972510BDE898F00D7F1D2 /* SKMainWindow.m in Sources */ = {isa
= PBXBuildFile; fileRef = CE49724F0BDE898F00D7F1D2 /* SKMainWindow.m */; };
CE49726D0BDE8A7400D7F1D2 /* PDFSelection_SKExtensions.m in
Sources */ = {isa = PBXBuildFile; fileRef = CE49726B0BDE8A7400D7F1D2 /*
PDFSelection_SKExtensions.m */; };
@@ -508,6 +509,8 @@
CE4643DA0DF6B66000CFD8D2 /* SKIndexCommand.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= SKIndexCommand.m; sourceTree = "<group>"; };
CE4643DC0DF6B77800CFD8D2 /* SKBoundsCommand.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
SKBoundsCommand.h; sourceTree = "<group>"; };
CE4643DD0DF6B77800CFD8D2 /* SKBoundsCommand.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= SKBoundsCommand.m; sourceTree = "<group>"; };
+ CE46458F0DF8140200CFD8D2 /* SKNumberArrayFormatter.h */ = {isa
= PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path
= SKNumberArrayFormatter.h; sourceTree = "<group>"; };
+ CE4645900DF8140200CFD8D2 /* SKNumberArrayFormatter.m */ = {isa
= PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc;
path = SKNumberArrayFormatter.m; sourceTree = "<group>"; };
CE485B650BC4420900FA7109 /* Dutch */ = {isa = PBXFileReference;
lastKnownFileType = folder; name = Dutch; path = "Dutch.lproj/Skim Help";
sourceTree = "<group>"; };
CE485B780BC4426800FA7109 /* Dutch */ = {isa = PBXFileReference;
lastKnownFileType = wrapper.nib; name = Dutch; path =
Dutch.lproj/InfoWindow.nib; sourceTree = "<group>"; };
CE485B7B0BC4427100FA7109 /* Dutch */ = {isa = PBXFileReference;
lastKnownFileType = wrapper.nib; name = Dutch; path = Dutch.lproj/MainMenu.nib;
sourceTree = "<group>"; };
@@ -1331,6 +1334,8 @@
CE5BD6720C7ADF1500EBDCF7 /*
SKTypeSelectHelper.m */,
CEE54F8E0DA3FE9A0037169F /*
SKUnarchiveFromDataArrayTransformer.h */,
CEE54F8F0DA3FE9A0037169F /*
SKUnarchiveFromDataArrayTransformer.m */,
+ CE46458F0DF8140200CFD8D2 /*
SKNumberArrayFormatter.h */,
+ CE4645900DF8140200CFD8D2 /*
SKNumberArrayFormatter.m */,
);
name = Miscellaneous;
sourceTree = "<group>";
@@ -2055,6 +2060,7 @@
CE4643D80DF6B63500CFD8D2 /* SKTextCommand.m in
Sources */,
CE4643DB0DF6B66000CFD8D2 /* SKIndexCommand.m in
Sources */,
CE4643DE0DF6B77800CFD8D2 /* SKBoundsCommand.m
in Sources */,
+ CE4645910DF8140200CFD8D2 /*
SKNumberArrayFormatter.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit