summaryrefslogtreecommitdiff
path: root/sc/source/ui/docshell/impex.cxx
diff options
context:
space:
mode:
authorIngrid Halama <iha@openoffice.org>2010-04-09 10:24:13 +0200
committerIngrid Halama <iha@openoffice.org>2010-04-09 10:24:13 +0200
commitcba8a6f937aea45938401957dcca617172cb3d57 (patch)
treeada9ad0e9a7ef05a7c9db84110121602c13898f5 /sc/source/ui/docshell/impex.cxx
parent13d7655a877492f67814c1a269bcb52264f0e3e1 (diff)
parent6a30f2a3025a9db27d1230d9498570964cd74e3f (diff)
chart45: merge with DEV300_m76
Diffstat (limited to 'sc/source/ui/docshell/impex.cxx')
-rw-r--r--sc/source/ui/docshell/impex.cxx84
1 files changed, 51 insertions, 33 deletions
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 8fc49696ba59..46b6b7af3a63 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -902,12 +902,11 @@ BOOL ScImportExport::Text2Doc( SvStream& rStrm )
//
-bool lcl_PutString( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab,
- const String& rStr, BYTE nColFormat,
- ::utl::TransliterationWrapper& rTransliteration,
- CalendarWrapper& rCalendar,
- ::utl::TransliterationWrapper* pSecondTransliteration,
- CalendarWrapper* pSecondCalendar )
+static bool lcl_PutString(
+ ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rStr, BYTE nColFormat,
+ SvNumberFormatter* pFormatter, bool bDetectNumFormat,
+ ::utl::TransliterationWrapper& rTransliteration, CalendarWrapper& rCalendar,
+ ::utl::TransliterationWrapper* pSecondTransliteration, CalendarWrapper* pSecondCalendar )
{
bool bMultiLine = false;
if ( nColFormat == SC_COL_SKIP || !rStr.Len() || !ValidCol(nCol) || !ValidRow(nRow) )
@@ -923,10 +922,10 @@ bool lcl_PutString( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab,
{
//! SetString mit Extra-Flag ???
- SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
- sal_uInt32 nEnglish = pFormatter->GetStandardIndex(LANGUAGE_ENGLISH_US);
+ SvNumberFormatter* pDocFormatter = pDoc->GetFormatTable();
+ sal_uInt32 nEnglish = pDocFormatter->GetStandardIndex(LANGUAGE_ENGLISH_US);
double fVal;
- if ( pFormatter->IsNumberFormat( rStr, nEnglish, fVal ) )
+ if ( pDocFormatter->IsNumberFormat( rStr, nEnglish, fVal ) )
{
// Zahlformat wird nicht auf englisch gesetzt
pDoc->SetValue( nCol, nRow, nTab, fVal );
@@ -1062,9 +1061,9 @@ bool lcl_PutString( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab,
}
}
- SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+ SvNumberFormatter* pDocFormatter = pDoc->GetFormatTable();
if ( nYear < 100 )
- nYear = pFormatter->ExpandTwoDigitYear( nYear );
+ nYear = pDocFormatter->ExpandTwoDigitYear( nYear );
CalendarWrapper* pCalendar = (bSecondCal ? pSecondCalendar : &rCalendar);
sal_Int16 nNumMonths = pCalendar->getNumberOfMonthsInYear();
@@ -1100,7 +1099,7 @@ bool lcl_PutString( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab,
pCalendar->setValue( i18n::CalendarFieldIndex::MILLISECOND, nMilli );
if ( pCalendar->isValid() )
{
- double fDiff = DateTime(*pFormatter->GetNullDate()) -
+ double fDiff = DateTime(*pDocFormatter->GetNullDate()) -
pCalendar->getEpochStart();
// #i14974# must use getLocalDateTime to get the same
// date values as set above
@@ -1112,10 +1111,10 @@ bool lcl_PutString( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab,
LanguageType eDocLang = eLatin; //! which language for date formats?
short nType = (nFound > 3 ? NUMBERFORMAT_DATETIME : NUMBERFORMAT_DATE);
- ULONG nFormat = pFormatter->GetStandardFormat( nType, eDocLang );
+ ULONG nFormat = pDocFormatter->GetStandardFormat( nType, eDocLang );
// maybe there is a special format including seconds or milliseconds
if (nFound > 5)
- nFormat = pFormatter->GetStandardFormat( fDays, nFormat, nType, eDocLang);
+ nFormat = pDocFormatter->GetStandardFormat( fDays, nFormat, nType, eDocLang);
pDoc->PutCell( nCol, nRow, nTab, new ScValueCell(fDays), nFormat, FALSE );
@@ -1127,7 +1126,7 @@ bool lcl_PutString( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab,
// Standard or date not determined -> SetString / EditCell
if( rStr.Search( _LF ) == STRING_NOTFOUND )
- pDoc->SetString( nCol, nRow, nTab, rStr );
+ pDoc->SetString( nCol, nRow, nTab, rStr, pFormatter, bDetectNumFormat );
else
{
bMultiLine = true;
@@ -1137,7 +1136,7 @@ bool lcl_PutString( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab,
}
-String lcl_GetFixed( const String& rLine, xub_StrLen nStart, xub_StrLen nNext )
+String lcl_GetFixed( const String& rLine, xub_StrLen nStart, xub_StrLen nNext, bool& rbIsQuoted )
{
xub_StrLen nLen = rLine.Len();
if (nNext > nLen)
@@ -1151,7 +1150,11 @@ String lcl_GetFixed( const String& rLine, xub_StrLen nStart, xub_StrLen nNext )
while ( nSpace > nStart && pStr[nSpace-1] == ' ' )
--nSpace;
- return rLine.Copy( nStart, nSpace-nStart );
+ rbIsQuoted = (pStr[nStart] == sal_Unicode('"') && pStr[nSpace-1] == sal_Unicode('"'));
+ if (rbIsQuoted)
+ return rLine.Copy(nStart+1, nSpace-nStart-2);
+ else
+ return rLine.Copy(nStart, nSpace-nStart);
}
BOOL ScImportExport::ExtText2Doc( SvStream& rStrm )
@@ -1184,9 +1187,9 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm )
const BYTE* pColFormat = pExtOptions->GetColFormat();
long nSkipLines = pExtOptions->GetStartRow();
- LanguageType eLatin, eCjk, eCtl;
- pDoc->GetLanguage( eLatin, eCjk, eCtl );
- LanguageType eDocLang = eLatin; //! which language for date formats?
+ LanguageType eDocLang = pExtOptions->GetLanguage();
+ SvNumberFormatter aNumFormatter(pDoc->GetServiceManager(), eDocLang);
+ bool bDetectNumFormat = pExtOptions->IsDetectSpecialNumber();
// For date recognition
::utl::TransliterationWrapper aTransliteration(
@@ -1228,6 +1231,8 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm )
// survives the toggle of bDetermineRange down at the end of the do{} loop.
bool bRangeIsDetermined = bDetermineRange;
+ bool bQuotedAsText = pExtOptions && pExtOptions->IsQuotedAsText();
+
ULONG nOriginalStreamPos = rStrm.Tell();
do
@@ -1249,7 +1254,8 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm )
// SC_COL_SKIP.
for ( i=0; i<nInfoCount && nCol <= MAXCOL+1; i++ )
{
- if ( pColFormat[i] != SC_COL_SKIP ) // sonst auch nCol nicht hochzaehlen
+ BYTE nFmt = pColFormat[i];
+ if (nFmt != SC_COL_SKIP) // sonst auch nCol nicht hochzaehlen
{
if (nCol > MAXCOL)
bOverflow = TRUE; // display warning on import
@@ -1257,11 +1263,15 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm )
{
xub_StrLen nStart = pColStart[i];
xub_StrLen nNext = ( i+1 < nInfoCount ) ? pColStart[i+1] : nLineLen;
- aCell = lcl_GetFixed( aLine, nStart, nNext );
- bMultiLine |= lcl_PutString( pDoc, nCol, nRow,
- nTab, aCell, pColFormat[i],
- aTransliteration, aCalendar,
- pEnglishTransliteration, pEnglishCalendar);
+ bool bIsQuoted = false;
+ aCell = lcl_GetFixed( aLine, nStart, nNext, bIsQuoted );
+ if (bIsQuoted && bQuotedAsText)
+ nFmt = SC_COL_TEXT;
+
+ bMultiLine |= lcl_PutString(
+ pDoc, nCol, nRow, nTab, aCell, nFmt,
+ &aNumFormatter, bDetectNumFormat, aTransliteration, aCalendar,
+ pEnglishTransliteration, pEnglishCalendar);
}
++nCol;
}
@@ -1278,7 +1288,8 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm )
// SC_COL_SKIP.
while (*p && nCol <= MAXCOL+1)
{
- p = ScImportExport::ScanNextFieldFromString( p, aCell, cStr, pSeps, bMerge );
+ bool bIsQuoted = false;
+ p = ScImportExport::ScanNextFieldFromString( p, aCell, cStr, pSeps, bMerge, bIsQuoted );
BYTE nFmt = SC_COL_STANDARD;
for ( i=nInfoStart; i<nInfoCount; i++ )
@@ -1295,10 +1306,15 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm )
if (nCol > MAXCOL)
bOverflow = TRUE; // display warning on import
else if (!bDetermineRange)
- bMultiLine |= lcl_PutString( pDoc, nCol, nRow,
- nTab, aCell, nFmt, aTransliteration,
- aCalendar, pEnglishTransliteration,
- pEnglishCalendar);
+ {
+ if (bIsQuoted && bQuotedAsText)
+ nFmt = SC_COL_TEXT;
+
+ bMultiLine |= lcl_PutString(
+ pDoc, nCol, nRow, nTab, aCell, nFmt,
+ &aNumFormatter, bDetectNumFormat, aTransliteration,
+ aCalendar, pEnglishTransliteration, pEnglishCalendar);
+ }
++nCol;
}
@@ -1372,11 +1388,13 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm )
// static
const sal_Unicode* ScImportExport::ScanNextFieldFromString( const sal_Unicode* p,
- String& rField, sal_Unicode cStr, const sal_Unicode* pSeps, BOOL bMergeSeps )
+ String& rField, sal_Unicode cStr, const sal_Unicode* pSeps, bool bMergeSeps, bool& rbIsQuoted )
{
+ rbIsQuoted = false;
rField.Erase();
if ( *p == cStr ) // String in Anfuehrungszeichen
{
+ rbIsQuoted = true;
const sal_Unicode* p1;
p1 = p = lcl_ScanString( p, rField, cStr, DQM_ESCAPE );
while ( *p && !ScGlobal::UnicodeStrChr( pSeps, *p ) )
@@ -2035,7 +2053,7 @@ class ScFormatFilterMissing : public ScFormatFilterPlugin {
virtual FltError ScImportDif( SvStream&, ScDocument*, const ScAddress&,
const CharSet, UINT32 ) RETURN_ERROR
virtual FltError ScImportRTF( SvStream&, const String&, ScDocument*, ScRange& ) RETURN_ERROR
- virtual FltError ScImportHTML( SvStream&, const String&, ScDocument*, ScRange&, double, BOOL ) RETURN_ERROR
+ virtual FltError ScImportHTML( SvStream&, const String&, ScDocument*, ScRange&, double, BOOL, SvNumberFormatter*, bool ) RETURN_ERROR
virtual ScEEAbsImport *CreateRTFImport( ScDocument*, const ScRange& ) { return NULL; }
virtual ScEEAbsImport *CreateHTMLImport( ScDocument*, const String&, const ScRange&, BOOL ) { return NULL; }