summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-10-29 02:31:22 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-10-30 16:28:55 +0100
commit93959db4d8846cfdfb87ab647c4d457fb09bb869 (patch)
tree856b744a621071f721e2baff4987584389dc178e
parent3757128f488bf47c51c2064daea90155601242b2 (diff)
use DocumentImport for csv import, related fdo#69006
Change-Id: Ib904510b6e897feb787497a4c8ff4204387cf6a4
-rw-r--r--sc/inc/documentimport.hxx4
-rw-r--r--sc/source/core/data/documentimport.cxx5
-rw-r--r--sc/source/ui/docshell/impex.cxx32
3 files changed, 29 insertions, 12 deletions
diff --git a/sc/inc/documentimport.hxx b/sc/inc/documentimport.hxx
index 06203019b042..25d4a03fdd1a 100644
--- a/sc/inc/documentimport.hxx
+++ b/sc/inc/documentimport.hxx
@@ -23,6 +23,7 @@ class ScColumn;
class ScAddress;
class ScTokenArray;
class ScFormulaCell;
+struct ScSetStringParam;
struct ScDocumentImportImpl;
/**
@@ -59,7 +60,8 @@ public:
void setOriginDate(sal_uInt16 nYear, sal_uInt16 nMonth, sal_uInt16 nDay);
- void setAutoInput(const ScAddress& rPos, const OUString& rStr);
+ void setAutoInput(const ScAddress& rPos, const OUString& rStr,
+ ScSetStringParam* pStringParam = NULL);
void setNumericCell(const ScAddress& rPos, double fVal);
void setStringCell(const ScAddress& rPos, const OUString& rStr);
void setEditCell(const ScAddress& rPos, EditTextObject* pEditText);
diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx
index 03f5842ec9c1..99e9b360f314 100644
--- a/sc/source/core/data/documentimport.cxx
+++ b/sc/source/core/data/documentimport.cxx
@@ -16,6 +16,7 @@
#include "globalnames.hxx"
#include "mtvelements.hxx"
#include "tokenarray.hxx"
+#include "stringutil.hxx"
#include "svl/sharedstringpool.hxx"
@@ -81,7 +82,7 @@ void ScDocumentImport::setOriginDate(sal_uInt16 nYear, sal_uInt16 nMonth, sal_uI
mpImpl->mrDoc.pDocOptions->SetDate(nDay, nMonth, nYear);
}
-void ScDocumentImport::setAutoInput(const ScAddress& rPos, const OUString& rStr)
+void ScDocumentImport::setAutoInput(const ScAddress& rPos, const OUString& rStr, ScSetStringParam* pStringParam)
{
ScTable* pTab = mpImpl->mrDoc.FetchTable(rPos.Tab());
if (!pTab)
@@ -95,7 +96,7 @@ void ScDocumentImport::setAutoInput(const ScAddress& rPos, const OUString& rStr)
ScCellValue aCell;
pTab->aCol[rPos.Col()].ParseString(
- aCell, rPos.Row(), rPos.Tab(), rStr, mpImpl->mrDoc.GetAddressConvention(), NULL);
+ aCell, rPos.Row(), rPos.Tab(), rStr, mpImpl->mrDoc.GetAddressConvention(), pStringParam);
sc::CellStoreType& rCells = pTab->aCol[rPos.Col()].maCells;
switch (aCell.meType)
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index fccafbe2200f..1399da28bd1c 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -49,6 +49,7 @@
#include "stringutil.hxx"
#include "cellvalue.hxx"
#include "tokenarray.hxx"
+#include "documentimport.hxx"
#include "globstr.hrc"
#include <vcl/svapp.hxx>
@@ -954,11 +955,12 @@ bool ScImportExport::Text2Doc( SvStream& rStrm )
static bool lcl_PutString(
- ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString& rStr, sal_uInt8 nColFormat,
+ ScDocumentImport& rDocImport, SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString& rStr, sal_uInt8 nColFormat,
SvNumberFormatter* pFormatter, bool bDetectNumFormat,
::utl::TransliterationWrapper& rTransliteration, CalendarWrapper& rCalendar,
::utl::TransliterationWrapper* pSecondTransliteration, CalendarWrapper* pSecondCalendar )
{
+ ScDocument* pDoc = &rDocImport.getDoc();
bool bMultiLine = false;
if ( nColFormat == SC_COL_SKIP || rStr.isEmpty() || !ValidCol(nCol) || !ValidRow(nRow) )
return bMultiLine;
@@ -977,8 +979,18 @@ static bool lcl_PutString(
pDoc->ApplyPattern(nCol, nRow, nTab, aNewAttrs);
}
- pDoc->SetTextCell(ScAddress(nCol,nRow,nTab), rStr);
- return bMultiLine;
+ if(ScStringUtil::isMultiline(rStr))
+ {
+ ScFieldEditEngine& rEngine = pDoc->GetEditEngine();
+ rEngine.SetText(rStr);
+ rDocImport.setEditCell(ScAddress(nCol, nRow, nTab), rEngine.CreateTextObject());
+ return true;
+ }
+ else
+ {
+ rDocImport.setStringCell(ScAddress(nCol, nRow, nTab), rStr);
+ return false;
+ }
}
if ( nColFormat == SC_COL_ENGLISH )
@@ -991,7 +1003,7 @@ static bool lcl_PutString(
if ( pDocFormatter->IsNumberFormat( rStr, nEnglish, fVal ) )
{
// Zahlformat wird nicht auf englisch gesetzt
- pDoc->SetValue( nCol, nRow, nTab, fVal );
+ rDocImport.setNumericCell( ScAddress( nCol, nRow, nTab ), fVal );
return bMultiLine;
}
// sonst weiter mit SetString
@@ -1180,7 +1192,7 @@ static bool lcl_PutString(
nFormat = pDocFormatter->GetStandardFormat( fDays, nFormat, nType, eDocLang);
ScAddress aPos(nCol,nRow,nTab);
- pDoc->SetValue(aPos, fDays);
+ rDocImport.setNumericCell(aPos, fDays);
pDoc->SetNumberFormat(aPos, nFormat);
return bMultiLine; // success
@@ -1197,14 +1209,14 @@ static bool lcl_PutString(
aParam.mbDetectNumberFormat = bDetectNumFormat;
aParam.meSetTextNumFormat = ScSetStringParam::SpecialNumberOnly;
aParam.mbHandleApostrophe = false;
- pDoc->SetString( nCol, nRow, nTab, rStr, &aParam );
+ rDocImport.setAutoInput(ScAddress(nCol, nRow, nTab), rStr, &aParam);
}
else
{
bMultiLine = true;
ScFieldEditEngine& rEngine = pDoc->GetEditEngine();
rEngine.SetText(rStr);
- pDoc->SetEditText(ScAddress(nCol,nRow,nTab), rEngine.CreateTextObject());
+ rDocImport.setEditCell(ScAddress(nCol, nRow, nTab), rEngine.CreateTextObject());
}
return bMultiLine;
}
@@ -1327,6 +1339,7 @@ bool ScImportExport::ExtText2Doc( SvStream& rStrm )
sal_uLong nOriginalStreamPos = rStrm.Tell();
+ ScDocumentImport aDocImport(*pDoc);
do
{
for( ;; )
@@ -1363,7 +1376,7 @@ bool ScImportExport::ExtText2Doc( SvStream& rStrm )
nFmt = SC_COL_TEXT;
bMultiLine |= lcl_PutString(
- pDoc, nCol, nRow, nTab, aCell, nFmt,
+ aDocImport, nCol, nRow, nTab, aCell, nFmt,
&aNumFormatter, bDetectNumFormat, aTransliteration, aCalendar,
pEnglishTransliteration.get(), pEnglishCalendar.get());
}
@@ -1406,7 +1419,7 @@ bool ScImportExport::ExtText2Doc( SvStream& rStrm )
nFmt = SC_COL_TEXT;
bMultiLine |= lcl_PutString(
- pDoc, nCol, nRow, nTab, aCell, nFmt,
+ aDocImport, nCol, nRow, nTab, aCell, nFmt,
&aNumFormatter, bDetectNumFormat, aTransliteration,
aCalendar, pEnglishTransliteration.get(), pEnglishCalendar.get());
}
@@ -1464,6 +1477,7 @@ bool ScImportExport::ExtText2Doc( SvStream& rStrm )
bDetermineRange = !bDetermineRange; // toggle
} while (!bDetermineRange);
+ aDocImport.finalize();
xProgress.reset(); // make room for AdjustRowHeight progress
if (bRangeIsDetermined)