22#include <osl/diagnose.h>
25#include <document.hxx>
43 const rtl_TextEncoding eVon )
50 bool bSyntErrWarn =
false;
51 bool bOverflowWarn =
false;
53 OUStringBuffer& rData = aDifParser.
m_aData;
65 const bool bData = !rData.isEmpty();
71 if( aDifParser.
nVector != 0 || aDifParser.
nVal != 1 )
74 pDoc->
RenameTab(nBaseTab, rData.toString());
91 if( aDifParser.
nVector != 0 || aDifParser.
nVal != 0 )
108 OSL_FAIL(
"ScImportDif - missing enum" );
126 while( eCurrent !=
D_EOD )
131 ScAddress aPos(nColCnt, nRowCnt, nBaseTab);
132 const OUString
aData = rData.makeStringAndClear();
157 else if(
aData ==
"TRUE" ||
aData ==
"FALSE" )
169 OUString aTmp =
"#IND:" +
aData +
"?";
174 bOverflowWarn =
true;
184 if (!
aData.isEmpty())
191 bOverflowWarn =
true;
200 OSL_FAIL(
"ScImportDif - missing enum" );
204 aAttrCache.
Apply( *pDoc, nBaseTab );
214 else if( bOverflowWarn )
225 , pNumFormatter(rDoc.GetFormatTable())
230 OSL_FAIL(
"CharSet passed overrides and modifies StreamCharSet" );
238 enum STATE { S_VectorVal, S_Data, S_END, S_START, S_UNKNOWN, S_ERROR_L2 };
240 static const std::u16string_view ppKeys[] =
258 static const TOPIC pTopics[] =
295 const std::u16string_view* pRef;
299 pRef = &ppKeys[ nCnt ];
305 eRet = pTopics[ nCnt ];
311 pRef = &ppKeys[ nCnt ];
329 if( pCur && *pCur ==
',' )
340 OSL_ENSURE( aLine.getLength() >= 2,
341 "+GetNextTopic(): <String> is too short!" );
342 if( aLine.getLength() > 2 )
343 m_aData.append(aLine.subView(1, aLine.getLength() - 2));
349 OSL_FAIL(
"DifParser::GetNextTopic - unexpected state" );
361 OSL_FAIL(
"DifParser::GetNextTopic - missing enum" );
375 rString = rString.makeStringAndClear().replaceAll(
"\"\"",
"\"");
383 OSL_ENSURE(
pNumFormatter,
"-DifParser::GetNumberDataset(): No Formatter, more fun!" );
384 OUString aTestVal( pPossibleNumericData );
385 sal_uInt32 nFormat = 0;
418 bool bValidStructure =
false;
420 OSL_ENSURE(
aLookAheadLine.isEmpty(),
"*DifParser::LookAhead(): LookAhead called twice in a row" );
425 switch( *pCurrentBuffer )
430 if(
Is1_0( pCurrentBuffer ) )
432 bValidStructure =
true;
437 if( *pCurrentBuffer ==
',' )
446 bValidStructure =
true;
450 return bValidStructure;
461 pCurrentBuffer = aLine.getStr();
463 switch( *pCurrentBuffer )
468 if(
Is1_0( pCurrentBuffer ) )
471 if(
IsBOT( aLine.getStr() ) )
473 else if(
IsEOD( aLine.getStr() ) )
479 if( *pCurrentBuffer ==
',' )
487 m_aData = OUString::Concat(
"#ERR: ") + pCurrentBuffer +
" (" + aTmpLine +
")";
497 if(
Is1_0( aLine.getStr() ) )
500 sal_Int32 nLineLength = aLine.getLength();
503 if( nLineLength >= 1 && *pLine ==
'"' )
511 if( nLineLength >= 2 && pLine[nLineLength - 1] ==
'"' )
513 m_aData = aLine.subView( 1, nLineLength - 2 );
522 bool bContinue =
true;
529 nLineLength = aLine.getLength();
530 if( nLineLength >= 1 )
532 pLine = aLine.getStr();
538 else if( pLine[nLineLength - 1] ==
'"' )
540 m_aData.append(aLine.subView(0, nLineLength -1));
565 while (*pStart ==
' ' || *pStart ==
'\t')
571 rRet =
static_cast<sal_uInt32
>( cCurrent -
'0' );
578 while(
IsNumber( cCurrent ) && rRet < ( 0xFFFFFFFF / 10 ) )
581 rRet +=
static_cast<sal_uInt32
>( cCurrent -
'0' );
597 OSL_ENSURE( pDoc->
ValidRow(nRow),
"*DifColumn::SetNumFormat(): Row too big!" );
603 OSL_ENSURE( nRow > 0,
604 "*DifColumn::SetNumFormat(): more cannot be zero!" );
606 "*DifColumn::SetNumFormat(): start from scratch?" );
636 OSL_ENSURE( rEntry.nNumFormat > 0,
637 "+DifColumn::Apply(): Number format must not be 0!" );
657 OSL_ENSURE( pDoc->
ValidCol(nCol),
"-DifAttrCache::SetNumFormat(): Col too big!" );
662 maColMap[ nCol ]->SetNumFormat( pDoc, nRow, nNumFormat );
670 maColMap[ nCol ]->Apply( rDoc, nCol, nTab );
std::map< SCCOL, std::unique_ptr< DifColumn > > maColMap
void SetNumFormat(const ScDocument *pDoc, const SCCOL nCol, const SCROW nRow, const sal_uInt32 nNumFormat)
void Apply(ScDocument &, SCTAB nTab)
std::vector< ENTRY > maEntries
void NewEntry(const SCROW nPos, const sal_uInt32 nNumFormat)
void SetNumFormat(const ScDocument *pDoc, SCROW nRow, const sal_uInt32 nNumFormat)
void Apply(ScDocument &rDoc, const SCCOL nCol, const SCTAB nTab)
DATASET GetNumberDataset(const sal_Unicode *pPossibleNumericData)
static bool IsBOT(const sal_Unicode *pRef)
static bool Is1_0(const sal_Unicode *pRef)
DifParser(SvStream &, const ScDocument &, rtl_TextEncoding)
static bool IsNumber(const sal_Unicode cChar)
static bool IsEOD(const sal_Unicode *pRef)
bool ReadNextLine(OUString &rStr)
static const sal_Unicode * ScanIntVal(const sal_Unicode *pStart, sal_uInt32 &rRet)
static bool IsV(const sal_Unicode *pRef)
SvNumberFormatter * pNumFormatter
SC_DLLPUBLIC ScColumnsRange GetWritableColumnsRange(SCTAB nTab, SCCOL nColBegin, SCCOL nColEnd)
bool ValidRow(SCROW nRow) const
SC_DLLPUBLIC SCCOL MaxCol() const
SC_DLLPUBLIC bool RenameTab(SCTAB nTab, const OUString &rName, bool bExternalDocument=false)
SC_DLLPUBLIC void SetTextCell(const ScAddress &rPos, const OUString &rStr)
Call this if you are not sure whether to put this as an edit text or a simple text.
SC_DLLPUBLIC ScDocumentPool * GetPool()
SC_DLLPUBLIC void EnsureTable(SCTAB nTab)
SC_DLLPUBLIC void ApplyPatternAreaTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, const ScPatternAttr &rAttr)
SC_DLLPUBLIC bool SetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const ScSetStringParam *pParam=nullptr)
SC_DLLPUBLIC void SetValue(SCCOL nCol, SCROW nRow, SCTAB nTab, const double &rVal)
SfxObjectShell * GetDocumentShell() const
bool ValidCol(SCCOL nCol) const
SfxItemSet & GetItemSet()
A simplified progress bar based on the stream position of an existing stream.
void Progress()
Sets the progress bar to the current stream position.
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void StartReadingUnicodeText(rtl_TextEncoding eReadBomCharSet)
bool ReadUniOrByteStringLine(OUString &rStr, rtl_TextEncoding eSrcCharSet, sal_Int32 nMaxCodepointsToRead=0xFFFE)
sal_uInt64 Seek(sal_uInt64 nPos)
void SetStreamCharSet(rtl_TextEncoding eCharSet)
rtl_TextEncoding GetStreamCharSet() const
static void lcl_DeEscapeQuotesDif(OUStringBuffer &rString)
const std::u16string_view pKeyTABLE
const std::u16string_view pKeyVECTORS
const std::u16string_view pKeyTUPLES
const std::u16string_view pKeyDATA
const std::u16string_view pKeyEOD
const std::u16string_view pKeyBOT
constexpr OUStringLiteral aData
#define SCERR_IMPORT_FORMAT
#define SCWARN_IMPORT_RANGE_OVERFLOW
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALUE_FORMAT(146)
Store parameters used in the ScDocument::SetString() method.
void setTextInput()
Call this whenever you need to unconditionally set input as text, no matter what the input is.