Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

progress indicator for exporting

git-svn-id: https://ichm.googlecode.com/svn/trunk@58 e1f60c0e-2a54-0410-99cd-d3f60e83567d
  • Loading branch information...
commit a4496570242d9533733887089525feb2adf1553e 1 parent b0d6633
iamawalrus authored
View
7 CHMDocument.h
@@ -32,6 +32,10 @@ struct chmFile;
IBOutlet NSPanel *addBookmarkPanel;
IBOutlet NSMenu *sidebarViewMenu;
+ IBOutlet NSWindow *exportProgressSheet;
+ IBOutlet NSProgressIndicator *exportProgressIndicator;
+ IBOutlet NSTextField *exportNoticeLabel;
+
struct chmFile *chmFileHandle;
NSString *filePath;
@@ -91,6 +95,9 @@ struct chmFile;
// dump to pdf
- (IBAction)exportToPDF:(id)sender;
+- (IBAction)showExportProgressSheet:(id)sender;
+- (IBAction)endExportProgressSheet:(id)sender;
+- (void)exportedProgressRate:(double)rate PageCount:(int)count;
// search
- (IBAction)setSearchInFile:(id)sender;
View
30 CHMDocument.m
@@ -951,6 +951,13 @@ - (IBAction)printDocument:(id)sender
}
+- (void)updateHistoryButton
+{
+ [historyItemView setEnabled:[curWebView canGoBack] forSegment:0];
+ [historyItemView setEnabled:[curWebView canGoForward] forSegment:1];
+}
+
+#pragma mark export to pdf
- (IBAction)exportToPDF:(id)sender
{
NSSavePanel *sp;
@@ -962,7 +969,7 @@ - (IBAction)exportToPDF:(id)sender
[sp setRequiredFileType:@"pdf"];
/* display the NSSavePanel */
- runResult = [sp runModal];
+ runResult = [sp runModalForDirectory:nil file:[[filePath lastPathComponent] stringByDeletingPathExtension] ];
/* if successful, save file under designated name */
if (runResult == NSOKButton) {
@@ -970,13 +977,28 @@ - (IBAction)exportToPDF:(id)sender
CHMExporter *exporter = [[CHMExporter alloc] initWithCHMDocument:self toFileName:filename WithPageList:[tocSource pageList]];
[exporter export];
[exporter release];
+ [self showExportProgressSheet:self];
}
}
-- (void)updateHistoryButton
+- (IBAction)showExportProgressSheet:(id)sender
{
- [historyItemView setEnabled:[curWebView canGoBack] forSegment:0];
- [historyItemView setEnabled:[curWebView canGoForward] forSegment:1];
+ [NSApp beginSheet:exportProgressSheet modalForWindow:documentWindow modalDelegate:nil didEndSelector:NULL contextInfo:NULL];
+ [exportProgressIndicator setIndeterminate:FALSE];
+}
+
+- (IBAction)endExportProgressSheet:(id)sender
+{
+ [NSApp endSheet:exportProgressSheet];
+ [exportProgressSheet orderOut:sender];
+}
+
+- (void)exportedProgressRate:(double)rate PageCount:(int)count
+{
+ NSString *title = NSLocalizedString(@"Export to PDF", @"Export to PDF");
+ NSString *label = [NSString stringWithFormat:@"%@ : %d %@", title, count, NSLocalizedString(@"pages", @"pages")];
+ [exportNoticeLabel setStringValue:label];
+ [exportProgressIndicator setDoubleValue:rate];
}
# pragma mark TabVew
View
1  CHMExporter.h
@@ -13,6 +13,7 @@
@interface CHMExporter : NSObject {
CHMDocument *document;
NSUInteger curPageId;
+ int pageCount;
WebView *webView;
CGRect pageRecct;
CGContextRef ctx;
View
13 CHMExporter.m
@@ -17,6 +17,7 @@ - (id)initWithCHMDocument:(CHMDocument*)doc toFileName:(NSString*)filename WithP
[document retain];
pageList = list;
+ pageCount = 0;
curPageId = 0;
webView = [[WebView alloc] init];
[webView setPolicyDelegate:document];
@@ -48,13 +49,20 @@ - (id)initWithCHMDocument:(CHMDocument*)doc toFileName:(NSString*)filename WithP
- (void)export
{
if (curPageId == [pageList count])
- return [self release];
+ {
+ [self release];
+ [document endExportProgressSheet:nil];
+ return;
+ }
LinkItem *page = [pageList objectAtIndex:curPageId];
NSURL *url = [document composeURL:[page path]];
NSURLRequest *req = [NSURLRequest requestWithURL:url];
- [[webView mainFrame] loadRequest:req];
+ [[webView mainFrame] loadRequest:req];
+
+ double rate = 100.0 * curPageId / [pageList count];
+ [document exportedProgressRate:rate PageCount:pageCount];
}
- (void)dealloc
@@ -84,6 +92,7 @@ - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
CGContextBeginPage(ctx, &pageRecct);
CGContextDrawPDFPage(ctx, page);
CGContextEndPage(ctx);
+ ++pageCount;
}
CGPDFDocumentRelease(pdfDoc);
View
186 English.lproj/CHMDocument.xib
@@ -2,21 +2,14 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02">
<data>
<int key="IBDocument.SystemTarget">1050</int>
- <string key="IBDocument.SystemVersion">9E17</string>
- <string key="IBDocument.InterfaceBuilderVersion">670</string>
- <string key="IBDocument.AppKitVersion">949.33</string>
+ <string key="IBDocument.SystemVersion">9F33</string>
+ <string key="IBDocument.InterfaceBuilderVersion">672</string>
+ <string key="IBDocument.AppKitVersion">949.34</string>
<string key="IBDocument.HIToolboxVersion">352.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="100163"/>
- <integer value="6"/>
- <integer value="100115"/>
- <integer value="100131"/>
- <integer value="100064"/>
- <integer value="100099"/>
- <integer value="100175"/>
- <integer value="100094"/>
- <integer value="100123"/>
+ <integer value="5"/>
+ <integer value="100190"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -157,7 +150,7 @@
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">controlBackgroundColor</string>
- <object class="NSColor" key="NSColor">
+ <object class="NSColor" key="NSColor" id="517689868">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC42NjY2NjY2OQA</bytes>
</object>
@@ -318,7 +311,7 @@
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSCustomView" id="307481529">
- <reference key="NSNextResponder"/>
+ <nil key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -365,11 +358,10 @@
</object>
</object>
<string key="NSFrameSize">{109, 40}</string>
- <reference key="NSSuperview"/>
<string key="NSClassName">NSView</string>
</object>
<object class="NSCustomView" id="37771630">
- <reference key="NSNextResponder"/>
+ <nil key="NSNextResponder"/>
<int key="NSvFlags">268</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -445,11 +437,10 @@
</object>
</object>
<string key="NSFrameSize">{266, 42}</string>
- <reference key="NSSuperview"/>
<string key="NSClassName">NSView</string>
</object>
<object class="NSCustomView" id="815097467">
- <reference key="NSNextResponder"/>
+ <nil key="NSNextResponder"/>
<int key="NSvFlags">268</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -492,7 +483,6 @@
</object>
</object>
<string key="NSFrameSize">{97, 40}</string>
- <reference key="NSSuperview"/>
<string key="NSClassName">NSView</string>
</object>
<object class="NSMenu" id="590169457">
@@ -516,7 +506,7 @@
</object>
</object>
<object class="NSCustomView" id="752860054">
- <reference key="NSNextResponder"/>
+ <nil key="NSNextResponder"/>
<int key="NSvFlags">268</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -546,11 +536,10 @@
</object>
</object>
<string key="NSFrameSize">{98, 43}</string>
- <reference key="NSSuperview"/>
<string key="NSClassName">NSView</string>
</object>
<object class="NSCustomView" id="117214111">
- <reference key="NSNextResponder"/>
+ <nil key="NSNextResponder"/>
<int key="NSvFlags">268</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -580,7 +569,6 @@
</object>
</object>
<string key="NSFrameSize">{97, 43}</string>
- <reference key="NSSuperview"/>
<string key="NSClassName">NSView</string>
</object>
<object class="NSMenu" id="241538245">
@@ -638,6 +626,56 @@
<object class="NSUserDefaultsController" id="956390096">
<bool key="NSSharedInstance">YES</bool>
</object>
+ <object class="NSWindowTemplate" id="354758231">
+ <int key="NSWindowStyleMask">7</int>
+ <int key="NSWindowBacking">2</int>
+ <string key="NSWindowRect">{{196, 429}, {362, 81}}</string>
+ <int key="NSWTFlags">1677721600</int>
+ <string key="NSWindowTitle"/>
+ <string key="NSWindowClass">NSWindow</string>
+ <nil key="NSViewClass"/>
+ <object class="NSView" key="NSWindowView" id="278247573">
+ <reference key="NSNextResponder"/>
+ <int key="NSvFlags">256</int>
+ <object class="NSMutableArray" key="NSSubviews">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSProgressIndicator" id="672947785">
+ <reference key="NSNextResponder" ref="278247573"/>
+ <int key="NSvFlags">1292</int>
+ <object class="NSPSMatrix" key="NSDrawMatrix"/>
+ <string key="NSFrame">{{18, 16}, {326, 20}}</string>
+ <reference key="NSSuperview" ref="278247573"/>
+ <int key="NSpiFlags">16392</int>
+ <double key="NSMaxValue">1.000000e+02</double>
+ </object>
+ <object class="NSTextField" id="613732017">
+ <reference key="NSNextResponder" ref="278247573"/>
+ <int key="NSvFlags">268</int>
+ <string key="NSFrame">{{17, 44}, {328, 17}}</string>
+ <reference key="NSSuperview" ref="278247573"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="288698546">
+ <int key="NSCellFlags">68288064</int>
+ <int key="NSCellFlags2">272630784</int>
+ <string key="NSContents">Label</string>
+ <reference key="NSSupport" ref="389328562"/>
+ <reference key="NSControlView" ref="613732017"/>
+ <object class="NSColor" key="NSBackgroundColor">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">controlColor</string>
+ <reference key="NSColor" ref="517689868"/>
+ </object>
+ <reference key="NSTextColor" ref="369001385"/>
+ </object>
+ </object>
+ </object>
+ <string key="NSFrameSize">{362, 81}</string>
+ <reference key="NSSuperview"/>
+ </object>
+ <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
+ <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
+ </object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
@@ -902,6 +940,30 @@
</object>
<int key="connectionID">100188</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">exportProgressIndicator</string>
+ <reference key="source" ref="512844837"/>
+ <reference key="destination" ref="672947785"/>
+ </object>
+ <int key="connectionID">100194</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">exportNoticeLabel</string>
+ <reference key="source" ref="512844837"/>
+ <reference key="destination" ref="613732017"/>
+ </object>
+ <int key="connectionID">100195</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">exportProgressSheet</string>
+ <reference key="source" ref="512844837"/>
+ <reference key="destination" ref="354758231"/>
+ </object>
+ <int key="connectionID">100196</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -1252,6 +1314,44 @@
<reference key="object" ref="956390096"/>
<reference key="parent" ref="0"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100189</int>
+ <reference key="object" ref="354758231"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="278247573"/>
+ </object>
+ <reference key="parent" ref="0"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100190</int>
+ <reference key="object" ref="278247573"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="613732017"/>
+ <reference ref="672947785"/>
+ </object>
+ <reference key="parent" ref="354758231"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100191</int>
+ <reference key="object" ref="672947785"/>
+ <reference key="parent" ref="278247573"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100192</int>
+ <reference key="object" ref="613732017"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="288698546"/>
+ </object>
+ <reference key="parent" ref="278247573"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100193</int>
+ <reference key="object" ref="288698546"/>
+ <reference key="parent" ref="613732017"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -1307,6 +1407,14 @@
<string>100175.IBPluginDependency</string>
<string>100176.IBPluginDependency</string>
<string>100177.IBPluginDependency</string>
+ <string>100189.IBEditorWindowLastContentRect</string>
+ <string>100189.IBPluginDependency</string>
+ <string>100189.IBWindowTemplateEditedContentRect</string>
+ <string>100189.NSWindowTemplate.visibleAtLaunch</string>
+ <string>100190.IBPluginDependency</string>
+ <string>100191.IBPluginDependency</string>
+ <string>100192.IBPluginDependency</string>
+ <string>100193.IBPluginDependency</string>
<string>5.IBEditorWindowLastContentRect</string>
<string>5.IBPluginDependency</string>
<string>5.IBWindowTemplateEditedContentRect</string>
@@ -1370,9 +1478,17 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{-6, 374}, {819, 559}}</string>
+ <string>{{491, 755}, {362, 81}}</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>{{491, 755}, {362, 81}}</string>
+ <integer value="0"/>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{-6, 374}, {819, 559}}</string>
+ <string>{{150, 347}, {819, 559}}</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>{{150, 347}, {819, 559}}</string>
<reference ref="9"/>
<integer value="0"/>
<string>{{201, 387}, {507, 413}}</string>
@@ -1403,7 +1519,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">100188</int>
+ <int key="maxID">100196</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -1423,13 +1539,18 @@
<string>changeTopic:</string>
<string>closeTab:</string>
<string>doneFind:</string>
+ <string>endExportProgressSheet:</string>
+ <string>exportToPDF:</string>
<string>findInFile:</string>
<string>findNext:</string>
<string>findPrev:</string>
+ <string>focusOnSearch:</string>
<string>goBack:</string>
<string>goForward:</string>
<string>goHistory:</string>
<string>goHome:</string>
+ <string>gotoNextPage:</string>
+ <string>gotoPrevPage:</string>
<string>hideSidebar:</string>
<string>locateTOC:</string>
<string>openInNewTab:</string>
@@ -1440,6 +1561,7 @@
<string>setSearchInFile:</string>
<string>setSearchInIndex:</string>
<string>showAddBookmark:</string>
+ <string>showExportProgressSheet:</string>
<string>showFindPanel:</string>
<string>toggleSidebar:</string>
<string>zoom:</string>
@@ -1467,6 +1589,11 @@
<string>id</string>
<string>id</string>
<string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
<string>NSMenuItem</string>
<string>id</string>
<string>id</string>
@@ -1478,6 +1605,7 @@
<string>id</string>
<string>id</string>
<string>id</string>
+ <string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
@@ -1487,6 +1615,9 @@
<string>addBookmarkPanel</string>
<string>docTabView</string>
<string>documentWindow</string>
+ <string>exportNoticeLabel</string>
+ <string>exportProgressIndicator</string>
+ <string>exportProgressSheet</string>
<string>historyItemView</string>
<string>homeItemView</string>
<string>searchItemView</string>
@@ -1503,6 +1634,9 @@
<string>NSPanel</string>
<string>NSTabView</string>
<string>NSWindow</string>
+ <string>NSTextField</string>
+ <string>NSProgressIndicator</string>
+ <string>NSWindow</string>
<string>NSSegmentedControl</string>
<string>NSButton</string>
<string>NSSearchField</string>
Please sign in to comment.
Something went wrong with that request. Please try again.