Permalink
Browse files

Changing export handling. Just getting started...

  • Loading branch information...
1 parent 947bb67 commit 9722cdc4af6c9180ad04945191d818e11ee9f194 svnuser committed Oct 26, 2009
View
@@ -10,11 +10,20 @@
@interface AppController : NSObject {
-
+ IBOutlet NSView *exportAccessoryView;
+ IBOutlet NSButton *exportHeadersCheckbox;
+ IBOutlet NSPopUpButton *exportFormatSelector;
}
+@property (nonatomic, retain) IBOutlet NSView *exportAccessoryView;
+@property (nonatomic, retain) IBOutlet NSButton *exportHeadersCheckbox;
+@property (nonatomic, retain) IBOutlet NSPopUpButton *exportFormatSelector;
+
// clipboard
- (IBAction) newDocumentFromClipboard:(id)sender;
+// saving
+- (IBAction) exportDocument:(id)sender;
+
@end
View
@@ -15,6 +15,22 @@
@implementation AppController
+@synthesize exportAccessoryView;
+@synthesize exportHeadersCheckbox;
+@synthesize exportFormatSelector;
+
+
+- (void) dealloc
+{
+ self.exportAccessoryView = nil;
+ self.exportHeadersCheckbox = nil;
+ self.exportFormatSelector = nil;
+
+ [super dealloc];
+}
+#pragma mark -
+
+
# pragma mark Clipboard
- (IBAction) newDocumentFromClipboard:(id)sender
@@ -46,4 +62,28 @@ - (IBAction) newDocumentFromClipboard:(id)sender
#pragma mark -
+
+#pragma mark Saving
+- (IBAction) exportDocument:(id)sender
+{
+ // get active document
+// NSDocumentController *docController = [NSDocumentController sharedDocumentController];
+// MyDocument *myDocument = [docController currentDocument];
+
+ // configure the panel
+ NSSavePanel *exportPanel = [NSSavePanel savePanel];
+ [exportPanel setDelegate:self];
+ [exportPanel setAccessoryView:exportAccessoryView];
+
+ // TODO: Adjust the selected format
+
+ NSInteger result = [exportPanel runModal];
+
+ // got the OK -> handle export
+ if (result == NSFileHandlingPanelOKButton) {
+
+ }
+}
+
+
@end
View
@@ -362,20 +362,22 @@ - (NSString *) stringInFormat:(PPStringFormat *)format withColumns:(NSArray *)co
// get desired row indexes if not given
// TODO: Also return header rows if we want the headers!
+ NSArray *exportRows = nil;
if (nil == rowIndexes) {
if (NSNotFound == [rowController selectionIndex]) {
- NSRange fullRange = NSMakeRange(0, [rows count]);
- rowIndexes = [NSIndexSet indexSetWithIndexesInRange:fullRange];
+ exportRows = [rowController arrangedObjects];
}
else {
rowIndexes = [rowController selectionIndexes];
}
}
- NSArray *exportRows = [[rowController arrangedObjects] objectsAtIndexes:rowIndexes];
+ if (nil != rowIndexes) {
+ exportRows = [[rowController arrangedObjects] objectsAtIndexes:rowIndexes];
+ }
// get the string from the formatter
NSString *string = [format stringForRows:exportRows includeHeaderRows:headerFlag withColumnKeys:columnKeys];
- NSLog(@"--> %@ returning formatted string:\n%@", self, string);
+ NSLog(@"--> %@ stringInFormat: is returning string:\n%@", self, string);
return string;
}
#endif
View
@@ -45,7 +45,7 @@ - (id) init
{
self = [super init];
if (self) {
- rowValues = [[NSMutableDictionary alloc] init]; // done manually to prevent copying the new object (self.rowValues is a COPY property)
+ rowValues = [[NSMutableDictionary alloc] init]; // done manually to prevent copying the new object (self.rowValues is a copy property)
headerRowPosition = UINT_MAX;
}
Oops, something went wrong.

0 comments on commit 9722cdc

Please sign in to comment.