Summary: | CSV external data import field types doesn't affect cell format | ||
---|---|---|---|
Product: | [Applications] calligrasheets | Reporter: | Tais P. Hansen <tais.hansen> |
Component: | general | Assignee: | Calligra Sheets (KSpread) Bugs <calligra-sheets-bugs-null> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version First Reported In: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: | Examples csv-file |
Description
Tais P. Hansen
2007-04-19 11:05:36 UTC
Created attachment 20321 [details]
Examples csv-file
SVN commit 695194 by nikolaus: Commands CSV Data Insertion. Initial implementation. Moved the logic into its own command and fix the issue, that the column data types were ignored. BUGS: 95552, 144415 M +1 -0 CMakeLists.txt A commands/CSVDataCommand.cpp [License: LGPL (v2+)] A commands/CSVDataCommand.h [License: LGPL (v2+)] M +27 -18 dialogs/CSVDialog.cpp --- trunk/koffice/kspread/CMakeLists.txt #695193:695194 @@ -41,6 +41,7 @@ commands/AutoFormatCommand.cpp commands/CommentCommand.cpp commands/ConditionCommand.cpp + commands/CSVDataCommand.cpp commands/DataManipulators.cpp commands/DefinePrintRangeCommand.cpp commands/DeleteCommand.cpp --- trunk/koffice/kspread/dialogs/CSVDialog.cpp #695193:695194 @@ -41,7 +41,7 @@ #include "Sheet.h" #include "View.h" -#include "commands/DataManipulators.h" +#include "commands/CSVDataCommand.h" using namespace KSpread; @@ -162,24 +162,33 @@ else m_targetRect.setBottom( m_targetRect.top() + numRows - 1 ); - Value val( Value::Array ); - for (int row = 0; row < numRows; ++row) - for (int col = 0; col < numCols; ++col) - val.setElement (col, row, Value(text(row, col))); + QList<KoCsvImportDialog::DataType> dataTypes; + Value value(Value::Array); + for (int row = 0; row < numRows; ++row) + { + for (int col = 0; col < numCols; ++col) + { + value.setElement(col, row, Value(text(row, col))); + if (row == 0) + dataTypes.insert(col, dataType(col)); + } + } - DataManipulator *manipulator = new DataManipulator; - if ( m_mode == Clipboard ) - manipulator->setText( i18n( "Inserting From Clipboard" ) ); - else if ( m_mode == File ) - manipulator->setText( i18n( "Inserting Text File" ) ); - else - manipulator->setText( i18n( "Text to Columns" ) ); - manipulator->setSheet (sheet); - manipulator->setParsing (true); - manipulator->setFormat (Format::Generic); - manipulator->setValue (val); - manipulator->add (m_targetRect); - manipulator->execute (); + CSVDataCommand* command = new CSVDataCommand(); + if (m_mode == Clipboard) + command->setText(i18n("Inserting From Clipboard")); + else if (m_mode == File) + command->setText(i18n("Inserting Text File")); + else + command->setText(i18n("Text to Columns")); + command->setSheet(sheet); + command->setValue(value); + command->setColumnDataTypes(dataTypes); + command->setDecimalSymbol(decimalSymbol()); + command->setThousandsSeparator(thousandsSeparator()); + command->add(m_targetRect); + if (!command->execute()) + delete command; m_pView->slotUpdateView( sheet ); KoCsvImportDialog::accept(); |