From 3ff30b06a09894ed0e7214d8fefbc4ce07a4276a Mon Sep 17 00:00:00 2001 From: Wilfried Huss Date: Sat, 6 Aug 2005 11:20:54 +0000 Subject: [PATCH] Port of Revision 443451 Refractor the text export into the kviewshell. This has the additional benefit that text export is now also available for DjVu files. svn path=/trunk/KDE/kdegraphics/kdvi/; revision=443454 --- kdvi_multipage.cpp | 3 -- kdvi_multipage.h | 1 - kdvi_multipage_texthandling.cpp | 50 +-------------------------------- kdvi_part.rc | 11 ++++---- 4 files changed, 6 insertions(+), 59 deletions(-) diff --git a/kdvi_multipage.cpp b/kdvi_multipage.cpp index 6cf89fd44..5b37fc7f7 100644 --- a/kdvi_multipage.cpp +++ b/kdvi_multipage.cpp @@ -74,7 +74,6 @@ KDVIMultiPage::KDVIMultiPage(QWidget *parentWidget, const char *widgetName, QObj new KAction(i18n("Enable All Warnings && Messages"), 0, this, SLOT(doEnableWarnings()), actionCollection(), "enable_msgs"); exportPSAction = new KAction(i18n("PostScript..."), 0, &DVIRenderer, SLOT(exportPS()), actionCollection(), "export_postscript"); exportPDFAction = new KAction(i18n("PDF..."), 0, &DVIRenderer, SLOT(exportPDF()), actionCollection(), "export_pdf"); - exportTextAction = new KAction(i18n("Text..."), 0, this, SLOT(doExportText()), actionCollection(), "export_text"); KStdAction::tipOfDay(this, SLOT(showTip()), actionCollection(), "help_tipofday"); @@ -95,7 +94,6 @@ KDVIMultiPage::~KDVIMultiPage() delete embedPSAction; delete exportPSAction; delete exportPDFAction; - delete exportTextAction; writeSettings(); Prefs::writeConfig(); @@ -410,7 +408,6 @@ void KDVIMultiPage::enableActions(bool b) docInfoAction->setEnabled(b); exportPSAction->setEnabled(b); exportPDFAction->setEnabled(b); - exportTextAction->setEnabled(b); setEmbedPostScriptAction(); } diff --git a/kdvi_multipage.h b/kdvi_multipage.h index 6a47af013..599e1e129 100644 --- a/kdvi_multipage.h +++ b/kdvi_multipage.h @@ -88,7 +88,6 @@ private: KAction *docInfoAction; KAction *embedPSAction; KAction *exportPDFAction; - KAction *exportTextAction; KAction *exportPSAction; }; diff --git a/kdvi_multipage_texthandling.cpp b/kdvi_multipage_texthandling.cpp index 2ba1c98a7..7f114cbfa 100644 --- a/kdvi_multipage_texthandling.cpp +++ b/kdvi_multipage_texthandling.cpp @@ -66,53 +66,5 @@ void KDVIMultiPage::doExportText(void) "warning_export_to_text_may_not_work") == KMessageBox::Cancel) return; - // Generate a suggestion for a reasonable file name - QString suggestedName = DVIRenderer.dviFile->filename; - suggestedName = suggestedName.left(suggestedName.find(".")) + ".txt"; - - QString fileName = KFileDialog::getSaveFileName(suggestedName, i18n("*.txt|Plain Text (Latin 1) (*.txt)"), scrollView(), i18n("Export File As")); - if (fileName.isEmpty()) - return; - QFileInfo finfo(fileName); - if (finfo.exists()) { - int r = KMessageBox::warningContinueCancel (scrollView(), i18n("The file %1\nexists. Do you want to overwrite that file?").arg(fileName), - i18n("Overwrite File"), i18n("Overwrite")); - if (r == KMessageBox::Cancel) - return; - } - - QFile textFile(fileName); - textFile.open( QIODevice::WriteOnly ); - QTextStream stream( &textFile ); - - Q3ProgressDialog progress( i18n("Exporting to text..."), i18n("Abort"), DVIRenderer.totalPages(), scrollView(), "export_text_progress", TRUE ); - progress.setMinimumDuration(300); - - RenderedDocumentPagePixmap dummyPage; - dummyPage.resize(1,1); - - for(int page=1; page <= DVIRenderer.totalPages(); page++) { - progress.setProgress( page ); - // Funny. The manual to QT tells us that we need to call - // qApp->processEvents() regularly to keep the application from - // freezing. However, the application crashes immediately if we - // uncomment the following line and works just fine as it is. Wild - // guess: Could that be related to the fact that we are linking - // agains qt-mt? - - // qApp->processEvents(); - - if ( progress.wasCanceled() ) - break; - - dummyPage.setPageNumber(page); - DVIRenderer.drawPage(100.0, &dummyPage); // We gracefully ingore any errors (bad dvi-file, etc.) which may occur during draw_page() - - for(int i=0; i - + &File - - Export As - - - + + Export As + +