[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/filters/kspread/csv
From: Fredrik Edemar <f_edemar () linux ! se>
Date: 2005-01-21 22:56:42
Message-ID: 20050121225642.7E08F1BA30 () office ! kde ! org
[Download RAW message or body]
CVS commit by fedemar:
Don't show the export/import dialog if batch mode is activated.
M +53 -15 csvexport.cc 1.31
M +4 -3 csvimport.cc 1.38
--- koffice/filters/kspread/csv/csvexport.cc #1.30:1.31
@@ -28,4 +28,5 @@
#include <kgenericfactory.h>
#include <koFilterChain.h>
+#include <koFilterManager.h>
#include <kspread_map.h>
@@ -130,17 +131,41 @@ KoFilter::ConversionStatus CSVExport::co
}
- CSVExportDialog expDialog( 0 );
- expDialog.fillTable( ksdoc->map() );
+ CSVExportDialog *expDialog = 0;
+ if (!m_chain->manager()->getBatchMode())
+ {
+ expDialog= new CSVExportDialog( 0 );
- if ( !expDialog.exec() )
+ if (!expDialog)
+ {
+ kdError(30501) << "Dialog has not been created! Aborting!" << endl;
+ return KoFilter::StupidError;
+ }
+ expDialog->fillTable( ksdoc->map() );
+
+ if ( !expDialog->exec() )
+ {
+ delete expDialog;
return KoFilter::UserCancelled;
+ }
+ }
- QTextCodec* codec = expDialog.getCodec();
+ QTextCodec* codec = 0;
+ QChar csvDelimiter;
+ if (expDialog)
+ {
+ codec = expDialog->getCodec();
if ( !codec )
+ {
+ delete expDialog;
return KoFilter::StupidError;
+ }
+ csvDelimiter = expDialog->getDelimiter();
+ }
+ else
+ {
+ codec = QTextCodec::codecForName("UTF-8");
+ csvDelimiter = ',';
+ }
- QChar csvDelimiter;
-
- csvDelimiter = expDialog.getDelimiter();
// Now get hold of the table to export
@@ -151,7 +176,11 @@ KoFilter::ConversionStatus CSVExport::co
bool first = true;
QString str;
- QChar textQuote = expDialog.getTextQuote();
+ QChar textQuote;
+ if (expDialog)
+ textQuote = expDialog->getTextQuote();
+ else
+ textQuote = '"';
- if ( expDialog.exportSelectionOnly() )
+ if ( expDialog && expDialog->exportSelectionOnly() )
{
kdDebug(30501) << "Export as selection mode" << endl;
@@ -159,5 +188,8 @@ KoFilter::ConversionStatus CSVExport::co
if ( !view ) // no view if embedded document
+ {
+ delete expDialog;
return KoFilter::StupidError;
+ }
KSpreadSheet const * const sheet = view->activeTable();
@@ -197,15 +229,19 @@ KoFilter::ConversionStatus CSVExport::co
KSpreadSheet const * const sheet = it.current();
- if ( !expDialog.exportTable( sheet->tableName() ) )
+ if (expDialog && !expDialog->exportTable( sheet->tableName() ) )
{
continue;
}
- if ( !first || expDialog.printAlwaysTableDelimiter() )
+ if ( !first || ( expDialog && expDialog->printAlwaysTableDelimiter() ) )
{
if ( !first)
str += m_eol;
- QString name( expDialog.getTableDelimiter() );
+ QString name;
+ if (expDialog)
+ name = expDialog->getTableDelimiter();
+ else
+ name = "********<SHEETNAME>********";
const QString tname( i18n("<SHEETNAME>") );
int pos = name.find( tname );
@@ -269,4 +305,5 @@ KoFilter::ConversionStatus CSVExport::co
kdError(30501) << "Unable to open output file!" << endl;
out.close();
+ delete expDialog;
return KoFilter::StupidError;
}
@@ -278,4 +315,5 @@ KoFilter::ConversionStatus CSVExport::co
out.close();
+ delete expDialog;
return KoFilter::OK;
}
--- koffice/filters/kspread/csv/csvimport.cc #1.37:1.38
@@ -30,4 +30,5 @@
#include <koFilterChain.h>
+#include <koFilterManager.h>
#include <kspread_doc.h>
#include <kspread_global.h>
@@ -101,6 +102,6 @@ KoFilter::ConversionStatus CSVFilter::co
in.close();
- CSVDialog *dialog = new CSVDialog(0L, inputFile, csv_delimiter);
- if (!dialog->exec())
+ CSVDialog *dialog = new CSVDialog(0L, inputFile, csv_delimiter );
+ if (!m_chain->manager()->getBatchMode() && !dialog->exec())
return KoFilter::UserCancelled;
inputFile.resize( 0 ); // Release memory (input file content)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic