From dfbbf2218e3ff4182b6776096311047ceb1d8e0d Mon Sep 17 00:00:00 2001 From: Jos Groot Lipman Date: Tue, 6 Sep 2011 10:29:00 +0000 Subject: [PATCH] Wincmd Packer progress svn path=/Slnkdwf/trunk/; revision=12512 --- SlnkDWFImpl/myEPlotSectionImpl.cpp | 6 ++---- SlnkDWFImpl/myWT_File.cpp | 10 +++++++++- SlnkDWFImpl/myeplotsectionimpl.h | 3 ++- SlnkDWFImpl/mywt_file.h | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/SlnkDWFImpl/myEPlotSectionImpl.cpp b/SlnkDWFImpl/myEPlotSectionImpl.cpp index 866c73a..d59c6e1 100644 --- a/SlnkDWFImpl/myEPlotSectionImpl.cpp +++ b/SlnkDWFImpl/myEPlotSectionImpl.cpp @@ -339,14 +339,12 @@ bool CEPlotSectionImpl::SaveAsAscii(const CString &srcpath, const CString &destp return true; } -bool CEPlotSectionImpl::SaveAsAscii(const CString &destpath) +bool CEPlotSectionImpl::SaveAsAscii(const CString &destpath, EPlot_Progress_Action progress_action /* = NULL */) { ATLASSERT(!m_pW2DInStream); // Don't open first! myWT_File my_input_file; my_input_file.set_eplotsection(this); - my_input_file.SaveAsAscii(destpath); - - return true; + return my_input_file.SaveAsAscii(destpath, progress_action); }; #endif \ No newline at end of file diff --git a/SlnkDWFImpl/myWT_File.cpp b/SlnkDWFImpl/myWT_File.cpp index 390e675..da5d5a4 100644 --- a/SlnkDWFImpl/myWT_File.cpp +++ b/SlnkDWFImpl/myWT_File.cpp @@ -95,7 +95,7 @@ WT_Result myWT_File::my_WSwrite (WT_File & file,int size,void const * buffer) return WT_Result::Success; }; -bool myWT_File::SaveAsAscii(const CString &destpath) +bool myWT_File::SaveAsAscii(const CString &destpath, EPlot_Progress_Action progress_action /*= NULL */) { try { @@ -111,6 +111,14 @@ bool myWT_File::SaveAsAscii(const CString &destpath) // Do the actual reading. while (result = process_next_object(), result==WT_Result::Success) { + if (progress_action) + { + int pos = file_pos(); + size_t sz = size(); + if (!progress_action(NULL /*progress_param*/, (sz==0)?0:double(pos)/sz)) + return false; + } + switch(current_object()->object_id()) { case WT_Object::DWF_Header_ID: diff --git a/SlnkDWFImpl/myeplotsectionimpl.h b/SlnkDWFImpl/myeplotsectionimpl.h index 99fd515..129dad4 100644 --- a/SlnkDWFImpl/myeplotsectionimpl.h +++ b/SlnkDWFImpl/myeplotsectionimpl.h @@ -4,6 +4,7 @@ #include "resource.h" // main symbols // CEPlotSection +typedef BOOL (* EPlot_Progress_Action) (void *param, double progress); class CEPlotSectionImpl { @@ -57,7 +58,7 @@ public: #ifndef DWFTK_READ_ONLY bool SaveAs(const CString &destpath); static bool SaveAsAscii(const CString &srcpath, const CString &destpath); - bool SaveAsAscii(const CString &destpath); + bool SaveAsAscii(const CString &destpath, EPlot_Progress_Action action = NULL); STDMETHOD(Write)( const void *pv, ULONG cb,ULONG *pcbWritten); #endif STDMETHOD(Close)(void); diff --git a/SlnkDWFImpl/mywt_file.h b/SlnkDWFImpl/mywt_file.h index 7e5a2f5..97ddc90 100644 --- a/SlnkDWFImpl/mywt_file.h +++ b/SlnkDWFImpl/mywt_file.h @@ -24,7 +24,7 @@ public: const unsigned int PaperColor() { return m_color; }; #ifndef DWFTK_READ_ONLY - bool SaveAsAscii(const CString &destpath); + bool SaveAsAscii(const CString &destpath, EPlot_Progress_Action action = NULL); #endif protected: