///
" + error + "", WebSecurityContext.Trusted, null ); } private void LoadHtml( string fileName ) { Core.WebBrowser.Visible = true; Core.WebBrowser.ShowHtml( "Please wait while the file is being converted…", WebSecurityContext.Trusted, null ); _killedConverter = false; _converterProcess = ExcelDocPlugin.CreateConverterProcess( fileName, false ); _converterProcess.EnableRaisingEvents = true; _converterProcess.Exited += _converterProcess_OnExited; try { if(!_converterProcess.Start()) throw new Exception(); } catch { _converterProcess = null; Core.UIManager.QueueUIJob( new ShowErrorDelegate( ShowError ), "Failed to convert Excel file to HTML. Cannot start the convertion process: converter is not found."); return; } _converterOutputReader = new StreamReader( _converterProcess.StandardOutput.BaseStream, Encoding.UTF8 ); _converterOutputWriter = new StringWriter(); new Thread( ProcessConverterOutput ).Start(); } private void ProcessConverterOutput() { try { string str; while ((str = _converterOutputReader.ReadLine()) != null) { _converterOutputWriter.WriteLine( str ); } } finally { _converterOutputWriter.Close(); } } private void _converterProcess_OnExited( object sender, EventArgs e ) { if ( _killedConverter || null == _converterProcess) return; if ( _converterProcess.ExitCode == 0 ) { Core.WebBrowser.ShowHtml( _converterOutputWriter.ToString(), WebSecurityContext.Restricted, _wordsToHighlight ); _wordsToHighlight = null; } else { string error = Utils.StreamReaderReadToEnd( _converterProcess.StandardError ); Core.UIManager.QueueUIJob( new ShowErrorDelegate( ShowError ), "Failed to convert Excel file to HTML. " + error ); } Core.FileResourceManager.CleanupSourceFile( _resource, _sourceFileName ); } private delegate void ShowErrorDelegate( string error ); public void HighlightWords( WordPtr[] words ) { words = DocumentSection.RestrictResults( words, DocumentSection.BodySection ); Core.WebBrowser.HighlightWords( words, 0 ); _wordsToHighlight = words; } public void EndDisplayResource( IResource resource ) { if ( _converterProcess != null && !_converterProcess.HasExited ) { // In the case the process was already killed - nothing to do try { _converterProcess.Kill(); } catch( InvalidOperationException ){} _killedConverter = true; } } public void DisposePane() { Controls.Remove( Core.WebBrowser ); Core.WebBrowser.Visible = true; Dispose(); } public string GetSelectedText( ref TextFormat format ) { format = TextFormat.Html; return Core.WebBrowser.SelectedHtml; } public string GetSelectedPlainText() { return Core.WebBrowser.SelectedText; } public bool CanExecuteCommand( string command ) { return Core.WebBrowser.CanExecuteCommand( command ); } public void ExecuteCommand( string command ) { Core.WebBrowser.ExecuteCommand( command ); } public void DisplayResource( IResource resource, WordPtr[] wordsToHighlight ) { _wordsToHighlight = DocumentSection.RestrictResults( wordsToHighlight, DocumentSection.BodySection ); DisplayResource( resource ); } } }