25#include <com/sun/star/i18n/CalendarFieldIndex.hpp>
28#include <osl/module.hxx>
40#include <progress.hxx>
43#include <compiler.hxx>
52#include <tokenarray.hxx>
66#include <rtl/character.hxx>
67#include <rtl/math.hxx>
73#include <unicode/uchar.h>
75#include <osl/endian.h>
87 const char SYLK_LF[] =
"\x1b :";
101enum class SylkVersion
113 : pDocSh( dynamic_cast<
ScDocShell* >(r.GetDocumentShell()) ), rDoc( r ),
114 nSizeLimit( 0 ), nMaxImportRow(!
utl::ConfigManager::IsFuzzing() ? rDoc.MaxRow() :
SCROWS32K),
115 cSep(
'\t' ), cStr(
'"' ),
116 bFormulas( false ), bIncludeFiltered( true ),
117 bAll( true ), bSingle( true ), bUndo( false ),
118 bOverflowRow( false ), bOverflowCol( false ), bOverflowCell( false ),
119 mbApi( true ), mbImportBroadcast(false), mbOverwriting( false ), mbIncludeBOM(false)
127 : pDocSh( dynamic_cast<
ScDocShell* >(r.GetDocumentShell()) ), rDoc( r ),
129 nSizeLimit( 0 ), nMaxImportRow(!
utl::ConfigManager::IsFuzzing() ? rDoc.MaxRow() :
SCROWS32K),
130 cSep(
'\t' ), cStr(
'"' ),
131 bFormulas( false ), bIncludeFiltered( true ),
132 bAll( false ), bSingle( true ), bUndo( pDocSh != nullptr ),
133 bOverflowRow( false ), bOverflowCol( false ), bOverflowCell( false ),
134 mbApi( true ), mbImportBroadcast(false), mbOverwriting( false ), mbIncludeBOM(false)
143 : pDocSh( dynamic_cast<
ScDocShell* >(r.GetDocumentShell()) ), rDoc( r ),
145 nSizeLimit( 0 ), nMaxImportRow(!
utl::ConfigManager::IsFuzzing() ? rDoc.MaxRow() :
SCROWS32K),
146 cSep(
'\t' ), cStr(
'"' ),
147 bFormulas( false ), bIncludeFiltered( true ),
148 bAll( false ), bSingle( false ), bUndo( pDocSh != nullptr ),
149 bOverflowRow( false ), bOverflowCol( false ), bOverflowCell( false ),
150 mbApi( true ), mbImportBroadcast(false), mbOverwriting( false ), mbIncludeBOM(false)
161 : pDocSh( dynamic_cast<
ScDocShell* >(r.GetDocumentShell()) ), rDoc( r ),
162 nSizeLimit( 0 ), nMaxImportRow(!
utl::ConfigManager::IsFuzzing() ? rDoc.MaxRow() :
SCROWS32K),
163 cSep(
'\t' ), cStr(
'"' ),
164 bFormulas( false ), bIncludeFiltered( true ),
165 bAll( false ), bSingle( true ), bUndo( pDocSh != nullptr ),
166 bOverflowRow( false ), bOverflowCol( false ), bOverflowCell( false ),
167 mbApi( true ), mbImportBroadcast(false), mbOverwriting( false ), mbIncludeBOM(false)
174 OUString aPos( rPos );
186 aPos =
pData->GetSymbol();
227 return nFormat == SotClipboardFormatId::STRING
228 || nFormat == SotClipboardFormatId::STRING_TSVC
229 || nFormat == SotClipboardFormatId::SYLK
230 || nFormat == SotClipboardFormatId::LINK
231 || nFormat == SotClipboardFormatId::HTML
232 || nFormat == SotClipboardFormatId::HTML_SIMPLE
233 || nFormat == SotClipboardFormatId::DIF;
245 VclMessageType::Info, VclButtonsType::Ok,
271 ScMarkData aDestMark(pRedoDoc->GetSheetLimits());
290 css::uno::Any & rValue )
294 if (fmtId == SotClipboardFormatId::STRING)
299 if (fmtId == SotClipboardFormatId::STRING)
302 rValue <<= OUString(static_cast<const sal_Unicode*>(aStrm.
GetData()),
308 rValue <<= css::uno::Sequence<sal_Int8>(
static_cast<sal_Int8 const*
>(aStrm.
GetData()),
321 case SotClipboardFormatId::STRING :
322 case SotClipboardFormatId::STRING_TSVC :
330 rtl_TextEncoding eEnc = osl_getThreadTextEncoding();
331 OString aTmp( rText.getStr(), rText.getLength(), eEnc );
332 SvMemoryStream aStrm(
const_cast<char *
>(aTmp.getStr()), aTmp.getLength() *
sizeof(
char), StreamMode::READ );
342 if ( nFmt != SotClipboardFormatId::STRING && nFmt != SotClipboardFormatId::STRING_TSVC )
344 SAL_WARN(
"sc.ui",
"ScImportExport::ExportString: Unicode not supported for other formats than SotClipboardFormatId::STRING[_TSV]");
345 rtl_TextEncoding eEnc = osl_getThreadTextEncoding();
348 rText = OStringToOUString( aTmp, eEnc );
371 OSL_ENSURE( eEnc != RTL_TEXTENCODING_UNICODE,
"ScImportExport::ExportByteString: Unicode not supported" );
372 if ( eEnc == RTL_TEXTENCODING_UNICODE )
373 eEnc = osl_getThreadTextEncoding();
387 rText =
static_cast<const char*
>(aStrm.
GetData());
397 if( nFmt == SotClipboardFormatId::STRING || nFmt == SotClipboardFormatId::STRING_TSVC )
402 if( nFmt == SotClipboardFormatId::SYLK )
407 if( nFmt == SotClipboardFormatId::DIF )
412 if( nFmt == SotClipboardFormatId::RTF || nFmt == SotClipboardFormatId::RICHTEXT )
417 if( nFmt == SotClipboardFormatId::LINK )
419 if ( nFmt == SotClipboardFormatId::HTML )
424 if ( nFmt == SotClipboardFormatId::HTML_SIMPLE )
428 if ( pHTML &&
HTML2Doc( *pHTML, rBaseURL ) )
437 if( nFmt == SotClipboardFormatId::STRING || nFmt == SotClipboardFormatId::STRING_TSVC )
442 if( nFmt == SotClipboardFormatId::SYLK )
447 if( nFmt == SotClipboardFormatId::DIF )
452 if( nFmt == SotClipboardFormatId::LINK && !
bAll )
464 OSL_ENSURE( !aDocName.isEmpty(),
"ClipBoard document has no name! :-/" );
465 if( !aDocName.isEmpty() )
494 if( nFmt == SotClipboardFormatId::HTML )
499 if( nFmt == SotClipboardFormatId::RTF || nFmt == SotClipboardFormatId::RICHTEXT )
511 if ( eEnc == RTL_TEXTENCODING_UNICODE )
513 if ( !lcl_IsEndianSwap(
rStrm ) )
561 sal_Int32 nWidth = 0;
562 while(nIdx < rStr.getLength() && nWidth < nMaxWidth)
564 sal_uInt32 nCode = rStr.iterateCodePoints(&nIdx);
566 auto nEaWidth = u_getIntPropertyValue(nCode, UCHAR_EAST_ASIAN_WIDTH);
567 if (nEaWidth == U_EA_FULLWIDTH || nEaWidth == U_EA_WIDE)
569 else if (!u_getIntPropertyValue(nCode, UCHAR_DEFAULT_IGNORABLE_CODE_POINT))
573 if (nIdx < rStr.getLength())
575 sal_Int32 nTmpIdx = nIdx;
576 sal_uInt32 nCode = rStr.iterateCodePoints(&nTmpIdx);
578 if (u_getIntPropertyValue(nCode, UCHAR_DEFAULT_IGNORABLE_CODE_POINT))
632 return FIELDEND_QUOTE;
635 const bool bBlankSep = (
p[1] == cBlank && !rcDetectSep &&
p[2] &&
p[2] != cBlank);
636 while (
p[1] == cBlank)
639 return FIELDEND_QUOTE;
654 return FIELDEND_QUOTE;
661 rcDetectSep = cBlank;
662 return FIELDEND_QUOTE;
664 return DONTKNOW_QUOTE;
691 if ((nQuotes & 1) == 0)
697 SAL_WARN(
"sc",
"lcl_isEscapedOrFieldEndQuote: really want a FIELDSTART_QUOTE?");
698 return FIELDSTART_QUOTE;
714 rField += std::u16string_view( p1, p2 - p1 );
719 SAL_WARN(
"sc",
"lcl_appendLineData: data overflow");
727enum class DoubledQuoteMode
757 bool bClosingQuote = (
eMode == DoubledQuoteMode::KEEP_ALL);
759 if (
eMode != DoubledQuoteMode::KEEP_ALL)
773 if (
eMode == DoubledQuoteMode::KEEP_ALL)
786 if (
eMode == DoubledQuoteMode::ESCAPE)
791 bClosingQuote =
true;
803 case DoubledQuoteMode::KEEP_ALL :
806 case DoubledQuoteMode::ESCAPE :
811 if (
eMode == DoubledQuoteMode::ESCAPE )
820 rbOverflowCell =
true;
827 if (!aString.isEmpty())
838 if (eVersion >= SylkVersion::OOO32)
839 rString = rString.replaceAll(
";;",
";");
841 rString = rString.replaceAll(
"\"\"",
"\"");
843 rString = rString.replaceAll(SYLK_LF,
"\n");
847 OUString& rString, SylkVersion eVersion )
856 if (eVersion >= SylkVersion::OOO32)
876 else if (*(
p+1) ==
';')
883 rString += std::u16string_view(pStartQuote + 1, pEndQuote - pStartQuote - 1 );
889 OUString& rString, SylkVersion eVersion )
892 if (eVersion >= SylkVersion::OOO32)
905 rString += std::u16string_view( pStart,
p - pStart);
918 bool bQuoted =
false;
944 while (*
p && *
p !=
';')
946 rString += std::u16string_view( pStart,
p - pStart);
957 OUString strFrom(cEsc);
958 OUString strTo = strFrom + strFrom;
959 rString = rString.replaceAll(strFrom, strTo);
964 rString = OUStringChar(cQuote) + rString + OUStringChar(cQuote);
1000 SCROW nRow = nStartRow;
1006 DoubledQuoteMode
mode = aLine.indexOf(
"\t") >= 0 ? DoubledQuoteMode::ESCAPE : DoubledQuoteMode::KEEP_ALL;
1009 SCCOL nCol = nStartCol;
1031 if (nCol>nEndCol) nEndCol = nCol;
1032 if (nRow>nEndRow) nEndRow = nRow;
1034 if( bData && nCol <= nEndCol && nRow <= nEndRow )
1075 SvNumberFormatter* pFormatter,
bool bDetectNumFormat,
bool bDetectSciNumFormat,
bool bEvaluateFormulas,
bool bSkipEmptyCells,
1076 const ::utl::TransliterationWrapper& rTransliteration,
CalendarWrapper& rCalendar,
1077 const ::utl::TransliterationWrapper* pSecondTransliteration,
CalendarWrapper* pSecondCalendar )
1080 bool bMultiLine =
false;
1083 if ( rStr.isEmpty() )
1085 if ( !bSkipEmptyCells )
1087 if ( bUseDocImport )
1090 rDoc.
SetString( nCol, nRow, nTab, rStr );
1095 const bool bForceFormulaText = (!bEvaluateFormulas && rStr[0] ==
'=');
1096 if (nColFormat ==
SC_COL_TEXT || bForceFormulaText)
1098 if ( bUseDocImport )
1143 if ( bUseDocImport )
1146 rDoc.
SetValue( nCol, nRow, nTab, fVal );
1153 const sal_uInt16 nMaxNumberParts = 7;
1154 const sal_Int32 nLen = rStr.getLength();
1155 sal_Int32 nStart[nMaxNumberParts];
1156 sal_Int32 nEnd[nMaxNumberParts];
1159 sal_uInt16 nDP, nMP, nYP;
1160 switch ( nColFormat )
1162 case SC_COL_YMD: nDP = 2; nMP = 1; nYP = 0; bIso =
true;
break;
1163 case SC_COL_MDY: nDP = 1; nMP = 0; nYP = 2; bIso =
false;
break;
1165 default: nDP = 0; nMP = 1; nYP = 2; bIso =
false;
break;
1168 sal_uInt16 nFound = 0;
1169 bool bInNum =
false;
1170 for (sal_Int32
nPos = 0;
nPos < nLen && (bInNum || nFound < nMaxNumberParts); ++
nPos)
1172 bool bLetter =
false;
1173 if (rtl::isAsciiDigit(rStr[
nPos]) ||
1174 (((!bInNum && nFound==nMP) || (bInNum && nFound==nMP+1))
1180 nStart[nFound] =
nPos;
1183 nEnd[nFound-1] =
nPos;
1184 if (bIso && (bLetter || (2 <= nFound && nFound <= 6 && nPos > nStart[nFound-1] + 1)))
1200 if (nFound >= 5 &&
nPos == nEnd[nFound-1] + 1)
1208 if (nFound >= 5 &&
nPos == nEnd[nFound-1] + 1)
1211 else if (nFound == 0 &&
nPos > 0)
1214 else if (nFound < 1 || 2 < nFound ||
nPos != nEnd[nFound-1] + 1)
1220 if (nFound != 3 ||
nPos != nEnd[nFound-1] + 1)
1225 if (nFound < 4 || 5 < nFound ||
nPos != nEnd[nFound-1] + 1)
1231 if (nFound != 6 ||
nPos != nEnd[nFound-1] + 1)
1236 if (nFound >= 5 &&
nPos == nEnd[nFound-1] + 1)
1257 sal_uInt32 nFormat = 0;
1262 if (pDocFormatter->
GetType(nFormat) & SvNumFormatType::DATE)
1282 sal_Int32 nDateStart = nStart[0];
1283 sal_Int32 nDateLen = nEnd[0] + 1 - nDateStart;
1285 if ( nDateLen >= 5 && nDateLen <= 8 &&
1292 bool bLongYear = ( nDateLen >= 7 );
1293 bool bShortFirst = ( nDateLen == 5 || nDateLen == 7 );
1295 sal_uInt16 nFieldStart = nDateStart;
1298 sal_uInt16 nFieldEnd = nFieldStart + 1;
1299 if ( bLongYear &&
nPos == nYP )
1301 if ( bShortFirst &&
nPos == 0 )
1304 nStart[
nPos] = nFieldStart;
1305 nEnd[
nPos] = nFieldEnd;
1306 nFieldStart = nFieldEnd + 1;
1312 if (!bIso && nFound >= 3)
1315 bool bSecondCal =
false;
1316 sal_uInt16 nDay =
static_cast<sal_uInt16
>(
o3tl::toInt32(rStr.subView( nStart[nDP], nEnd[nDP]+1-nStart[nDP] )));
1317 sal_uInt16 nYear =
static_cast<sal_uInt16
>(
o3tl::toInt32(rStr.subView( nStart[nYP], nEnd[nYP]+1-nStart[nYP] )));
1318 OUString aMStr = rStr.copy( nStart[nMP], nEnd[nMP]+1-nStart[nMP] );
1319 sal_Int16 nMonth =
static_cast<sal_Int16
>(aMStr.toInt32());
1322 static constexpr OUStringLiteral aSepShortened =
u"SEP";
1323 uno::Sequence< i18n::CalendarItem2 > xMonths;
1324 sal_Int32
i, nMonthCount;
1327 nMonthCount = xMonths.getLength();
1328 for (
i=0;
i<nMonthCount && !nMonth;
i++)
1330 if ( rTransliteration.isEqual( aMStr, xMonths[
i].FullName ) ||
1331 rTransliteration.isEqual( aMStr, xMonths[
i].AbbrevName ) )
1332 nMonth = sal::static_int_cast<sal_Int16>(
i+1 );
1333 else if (
i == 8 && rTransliteration.isEqual(
"SEPT",
1334 xMonths[
i].AbbrevName ) &&
1335 rTransliteration.isEqual( aMStr, aSepShortened ) )
1338 nMonth = sal::static_int_cast<sal_Int16>(
i+1 );
1342 if ( !nMonth && pSecondCalendar && pSecondTransliteration )
1345 nMonthCount = xMonths.getLength();
1346 for (
i=0;
i<nMonthCount && !nMonth;
i++)
1348 if ( pSecondTransliteration->isEqual( aMStr, xMonths[
i].FullName ) ||
1349 pSecondTransliteration->isEqual( aMStr, xMonths[
i].AbbrevName ) )
1351 nMonth = sal::static_int_cast<sal_Int16>(
i+1 );
1354 else if (
i == 8 && pSecondTransliteration->isEqual(
1355 aMStr, aSepShortened ) )
1358 nMonth = sal::static_int_cast<sal_Int16>(
i+1 );
1369 CalendarWrapper* pCalendar = (bSecondCal ? pSecondCalendar : &rCalendar);
1371 if ( nDay && nMonth && nDay<=31 && nMonth<=nNumMonths )
1374 pCalendar->
setValue( i18n::CalendarFieldIndex::DAY_OF_MONTH, nDay );
1375 pCalendar->
setValue( i18n::CalendarFieldIndex::MONTH, nMonth );
1376 pCalendar->
setValue( i18n::CalendarFieldIndex::YEAR, nYear );
1377 sal_Int16 nHour, nMinute, nSecond;
1380 nHour = nMinute = nSecond = 0;
1382 nHour =
static_cast<sal_Int16
>(
o3tl::toInt32(rStr.subView( nStart[3], nEnd[3]+1-nStart[3])));
1384 nMinute =
static_cast<sal_Int16
>(
o3tl::toInt32(rStr.subView( nStart[4], nEnd[4]+1-nStart[4])));
1386 nSecond =
static_cast<sal_Int16
>(
o3tl::toInt32(rStr.subView( nStart[5], nEnd[5]+1-nStart[5])));
1392 OUString aT = OUStringChar(cDec) + rStr.subView( nStart[6], nEnd[6]+1-nStart[6]);
1393 rtl_math_ConversionStatus eStatus;
1394 double fV = rtl::math::stringToDouble( aT, cDec, 0, &eStatus );
1395 if (eStatus == rtl_math_ConversionStatus_Ok)
1396 fFrac = fV / 86400.0;
1399 if (nFound > 3 && 1 <= nHour && nHour <= 12 // nHour 0 and >=13 can
't be AM/PM
1400 && (nPos = nEnd[nFound-1] + 1) < nLen)
1402 // Dreaded AM/PM may be following.
1403 while (nPos < nLen && rStr[nPos] == ' ')
1407 sal_Int32 nStop = nPos;
1408 while (nStop < nLen && rStr[nStop] != ' ')
1410 OUString aAmPm = rStr.copy( nPos, nStop - nPos);
1411 // For AM only 12 needs to be treated, whereas for PM
1412 // it must not. Check both, locale and second/English
1415 (rTransliteration.isEqual( aAmPm, pFormatter->GetLocaleData()->getTimeAM()) ||
1416 (pSecondTransliteration && pSecondTransliteration->isEqual( aAmPm, "AM"))))
1420 else if (nHour < 12 &&
1421 (rTransliteration.isEqual( aAmPm, pFormatter->GetLocaleData()->getTimePM()) ||
1422 (pSecondTransliteration && pSecondTransliteration->isEqual( aAmPm, "PM"))))
1428 pCalendar->setValue( i18n::CalendarFieldIndex::HOUR, nHour );
1429 pCalendar->setValue( i18n::CalendarFieldIndex::MINUTE, nMinute );
1430 pCalendar->setValue( i18n::CalendarFieldIndex::SECOND, nSecond );
1431 pCalendar->setValue( i18n::CalendarFieldIndex::MILLISECOND, 0 );
1432 if ( pCalendar->isValid() )
1435 double fDiff = DateTime::Sub( DateTime(pDocFormatter->GetNullDate()),
1436 pCalendar->getEpochStart());
1437 // #i14974# must use getLocalDateTime to get the same
1438 // date values as set above
1439 double fDays = pCalendar->getLocalDateTime() + fFrac;
1442 LanguageType eLatin, eCjk, eCtl;
1443 rDoc.GetLanguage( eLatin, eCjk, eCtl );
1444 LanguageType eDocLang = eLatin; //! which language for date formats?
1446 SvNumFormatType nType = (nFound > 3 ? SvNumFormatType::DATETIME : SvNumFormatType::DATE);
1447 sal_uLong nFormat = pDocFormatter->GetStandardFormat( nType, eDocLang );
1448 // maybe there is a special format including seconds or milliseconds
1450 nFormat = pDocFormatter->GetStandardFormat( fDays, nFormat, nType, eDocLang);
1452 ScAddress aPos(nCol,nRow,nTab);
1453 if ( bUseDocImport )
1454 rDocImport.setNumericCell(aPos, fDays);
1456 rDoc.SetValue( aPos, fDays );
1457 rDoc.SetNumberFormat(aPos, nFormat);
1459 return bMultiLine; // success
1465 // Standard or date not determined -> SetString / EditCell
1466 if( rStr.indexOf( '\
n' ) == -1 )
1468 if (!bDetectNumFormat && nColFormat == SC_COL_STANDARD)
1470 // Import a strict ISO 8601 date(+time) string even without
1471 // "Detect special numbers" or "Date (YMD)".
1474 // Simple pre-check before calling more expensive parser.
1475 // ([+-])(Y)YYYY-MM-DD
1476 if (rStr.getLength() < 10)
1478 const sal_Int32 n1 = rStr.indexOf('-
', 1);
1481 const sal_Int32 n2 = rStr.indexOf('-
', n1 + 1);
1482 if (n2 < 7 || n1 + 3 < n2)
1485 css::util::DateTime aDateTime;
1486 if (!sax::Converter::parseDateTime( aDateTime, rStr))
1489 sal_uInt32 nFormat = 0;
1491 SvNumberFormatter* pDocFormatter = rDoc.GetFormatTable();
1492 if (pDocFormatter->IsNumberFormat( rStr, nFormat, fVal))
1494 if (pDocFormatter->GetType(nFormat) & SvNumFormatType::DATE)
1496 ScAddress aPos(nCol,nRow,nTab);
1498 rDocImport.setNumericCell(aPos, fVal);
1500 rDoc.SetValue(aPos, fVal);
1501 rDoc.SetNumberFormat(aPos, nFormat);
1503 return bMultiLine; // success
1510 ScSetStringParam aParam;
1511 aParam.mpNumFormatter = pFormatter;
1512 aParam.mbDetectNumberFormat = bDetectNumFormat;
1513 aParam.mbDetectScientificNumberFormat = bDetectSciNumFormat;
1514 aParam.meSetTextNumFormat = ScSetStringParam::SpecialNumberOnly;
1515 aParam.mbHandleApostrophe = false;
1516 aParam.mbCheckLinkFormula = true;
1517 if ( bUseDocImport )
1518 rDocImport.setAutoInput(ScAddress(nCol, nRow, nTab), rStr, &aParam);
1520 rDoc.SetString( nCol, nRow, nTab, rStr, &aParam );
1525 ScFieldEditEngine& rEngine = rDoc.GetEditEngine();
1526 rEngine.SetTextCurrentDefaults(rStr);
1527 if ( bUseDocImport )
1528 rDocImport.setEditCell(ScAddress(nCol, nRow, nTab), rEngine.CreateTextObject());
1530 rDoc.SetEditText( ScAddress( nCol, nRow, nTab ), rEngine.CreateTextObject() );
1535static OUString lcl_GetFixed( const OUString& rLine, sal_Int32 nStart, sal_Int32 nNext,
1536 bool& rbIsQuoted, bool& rbOverflowCell )
1538 sal_Int32 nLen = rLine.getLength();
1541 if ( nNext <= nStart )
1544 const sal_Unicode* pStr = rLine.getStr();
1546 sal_Int32 nSpace = nNext;
1547 while ( nSpace > nStart && pStr[nSpace-1] == ' ' )
1550 rbIsQuoted = (pStr[nStart] == '"' && pStr[nSpace-1] == '"');
1553 bool bFits = (nSpace - nStart - 3 <= nArbitraryCellLengthLimit);
1555 return rLine.copy(nStart+1, std::max< sal_Int32 >(0, nSpace-nStart-2));
1558 SAL_WARN( "sc", "lcl_GetFixed: line doesn't fit into data
");
1559 rbOverflowCell = true;
1560 return rLine.copy(nStart+1, nArbitraryCellLengthLimit);
1565 bool bFits = (nSpace - nStart <= nArbitraryCellLengthLimit);
1567 return rLine.copy(nStart, nSpace-nStart);
1571 rbOverflowCell = true;
1572 return rLine.copy(nStart, nArbitraryCellLengthLimit);
1577bool ScImportExport::ExtText2Doc( SvStream& rStrm )
1580 return Text2Doc( rStrm );
1582 sal_uInt64 const nOldPos = rStrm.Tell();
1583 sal_uInt64 const nRemaining = rStrm.remainingSize();
1584 std::unique_ptr<ScProgress> xProgress( new ScProgress( pDocSh,
1585 ScResId( STR_LOAD_DOC ), nRemaining, true ));
1586 rStrm.StartReadingUnicodeText( rStrm.GetStreamCharSet() );
1587 // tdf#82254 - check whether to include a byte-order-mark in the output
1588 if (nOldPos != rStrm.Tell())
1589 mbIncludeBOM = true;
1591 SCCOL nStartCol = aRange.aStart.Col();
1592 SCCOL nEndCol = aRange.aEnd.Col();
1593 SCROW nStartRow = aRange.aStart.Row();
1594 const SCTAB nTab = aRange.aStart.Tab();
1596 bool bFixed = pExtOptions->IsFixedLen();
1597 OUString aSeps = pExtOptions->GetFieldSeps(); // Need non-const for ReadCsvLine(),
1598 const sal_Unicode* pSeps = aSeps.getStr(); // but it will be const anyway (asserted below).
1599 bool bMerge = pExtOptions->IsMergeSeps();
1600 bool bRemoveSpace = pExtOptions->IsRemoveSpace();
1601 sal_uInt16 nInfoCount = pExtOptions->GetInfoCount();
1602 const sal_Int32* pColStart = pExtOptions->GetColStart();
1603 const sal_uInt8* pColFormat = pExtOptions->GetColFormat();
1604 tools::Long nSkipLines = pExtOptions->GetStartRow();
1606 LanguageType eDocLang = pExtOptions->GetLanguage();
1607 SvNumberFormatter aNumFormatter( comphelper::getProcessComponentContext(), eDocLang);
1608 bool bDetectNumFormat = pExtOptions->IsDetectSpecialNumber();
1609 bool bDetectSciNumFormat = pExtOptions->IsDetectScientificNumber();
1610 bool bEvaluateFormulas = pExtOptions->IsEvaluateFormulas();
1611 bool bSkipEmptyCells = pExtOptions->IsSkipEmptyCells();
1613 // For date recognition
1614 ::utl::TransliterationWrapper aTransliteration(
1615 comphelper::getProcessComponentContext(), TransliterationFlags::IGNORE_CASE );
1616 aTransliteration.loadModuleIfNeeded( eDocLang );
1617 CalendarWrapper aCalendar( comphelper::getProcessComponentContext() );
1618 aCalendar.loadDefaultCalendar(
1619 LanguageTag::convertToLocale( eDocLang ) );
1620 std::unique_ptr< ::utl::TransliterationWrapper > pEnglishTransliteration;
1621 std::unique_ptr< CalendarWrapper > pEnglishCalendar;
1622 if ( eDocLang != LANGUAGE_ENGLISH_US )
1624 pEnglishTransliteration.reset(new ::utl::TransliterationWrapper (
1625 comphelper::getProcessComponentContext(), TransliterationFlags::IGNORE_CASE ));
1626 aTransliteration.loadModuleIfNeeded( LANGUAGE_ENGLISH_US );
1627 pEnglishCalendar.reset(new CalendarWrapper ( comphelper::getProcessComponentContext() ));
1628 pEnglishCalendar->loadDefaultCalendar(
1629 LanguageTag::convertToLocale( LANGUAGE_ENGLISH_US ) );
1635 SCROW nRow = nStartRow;
1636 sal_Unicode cDetectSep = 0xffff; // No separator detection here.
1638 while(--nSkipLines>0)
1640 aLine = ReadCsvLine(rStrm, !bFixed, aSeps, cStr, cDetectSep); // content is ignored
1645 // Determine range for Undo.
1646 // We don't need
this during
import of a file
to a
new sheet or document...
1647 bool bDetermineRange = bUndo;
1648 bool bColumnsAreDetermined =
false;
1653 bool bRangeIsDetermined = bDetermineRange;
1655 bool bQuotedAsText = pExtOptions && pExtOptions->IsQuotedAsText();
1657 sal_uInt64 nOriginalStreamPos =
rStrm.
Tell();
1660 SCROW nLastUpdateRowHeight = -1;
1668 if (
rStrm.
eof() && aLine.isEmpty() )
1671 assert(pSeps == aSeps.getStr());
1673 if ( nRow > rDoc.
MaxRow() )
1675 bOverflowRow =
true;
1679 if (!bDetermineRange)
1680 EmbeddedNullTreatment( aLine);
1682 sal_Int32 nLineLen = aLine.getLength();
1683 SCCOL nCol = nStartCol;
1684 bool bMultiLine =
false;
1687 if (bDetermineRange)
1689 if (!bColumnsAreDetermined)
1695 for (
i=0;
i < nInfoCount && nCol <= rDoc.
MaxCol()+1; ++
i)
1700 if (nCol > rDoc.
MaxCol())
1701 bOverflowCol =
true;
1705 bColumnsAreDetermined =
true;
1710 sal_Int32 nStartIdx = 0;
1712 for (
i=0;
i < nInfoCount && nCol <= rDoc.
MaxCol()+1; ++
i)
1714 sal_Int32 nNextIdx = nStartIdx;
1715 if (
i + 1 < nInfoCount)
1716 CountVisualWidth( aLine, nNextIdx, pColStart[
i+1] - pColStart[
i] );
1718 nNextIdx = nLineLen;
1722 if (nCol > rDoc.
MaxCol())
1723 bOverflowCol =
true;
1726 bool bIsQuoted =
false;
1727 aCell =
lcl_GetFixed( aLine, nStartIdx, nNextIdx, bIsQuoted, bOverflowCell );
1728 if (bIsQuoted && bQuotedAsText)
1732 aDocImport, !mbOverwriting, nCol, nRow, nTab, aCell, nFmt,
1733 &aNumFormatter, bDetectNumFormat, bDetectSciNumFormat, bEvaluateFormulas, bSkipEmptyCells,
1734 aTransliteration, aCalendar,
1735 pEnglishTransliteration.get(), pEnglishCalendar.get());
1739 nStartIdx = nNextIdx;
1745 SCCOL nSourceCol = 0;
1746 sal_uInt16 nInfoStart = 0;
1752 while (*
p && nCol <= rDoc.
MaxCol()+1)
1754 bool bIsQuoted =
false;
1756 cStr, pSeps, bMerge, bIsQuoted, bOverflowCell, bRemoveSpace );
1759 for (
i=nInfoStart;
i<nInfoCount;
i++ )
1761 if ( pColStart[
i] == nSourceCol + 1 )
1763 nFmt = pColFormat[
i];
1770 if (nCol > rDoc.
MaxCol())
1771 bOverflowCol =
true;
1772 else if (!bDetermineRange)
1774 if (bIsQuoted && bQuotedAsText)
1778 aDocImport, !mbOverwriting, nCol, nRow, nTab, aCell, nFmt,
1779 &aNumFormatter, bDetectNumFormat, bDetectSciNumFormat, bEvaluateFormulas, bSkipEmptyCells,
1780 aTransliteration, aCalendar,
1781 pEnglishTransliteration.get(), pEnglishCalendar.get());
1792 if (!bDetermineRange)
1794 if (bMultiLine && !bRangeIsDetermined && pDocSh)
1796 nFirstUpdateRowHeight = std::min( nFirstUpdateRowHeight, nRow );
1797 nLastUpdateRowHeight = std::max( nLastUpdateRowHeight, nRow );
1799 xProgress->SetStateOnPercent(
rStrm.
Tell() - nOldPos );
1804 if (nRow > nStartRow)
1806 if (nEndCol > nStartCol)
1807 nEndCol = ::std::min(
static_cast<SCCOL>(nEndCol - 1), rDoc.
MaxCol());
1809 if (bDetermineRange)
1811 aRange.aEnd.SetCol( nEndCol );
1812 aRange.aEnd.SetRow( nRow );
1814 if ( !mbApi && nStartCol != nEndCol &&
1815 !rDoc.
IsBlockEmpty( nStartCol + 1, nStartRow, nEndCol, nRow, nTab ) )
1833 bDetermineRange = !bDetermineRange;
1834 }
while (!bDetermineRange);
1836 if ( !mbOverwriting )
1837 aDocImport.finalize();
1841 if( nFirstUpdateRowHeight < nLastUpdateRowHeight && pDocSh )
1842 pDocSh->AdjustRowHeight( nFirstUpdateRowHeight, nLastUpdateRowHeight, nTab);
1844 if (bRangeIsDetermined)
1847 if (mbImportBroadcast && !mbOverwriting)
1850 pDocSh->PostDataChanged();
1865 if (sal_Int32
pos = rStr.indexOf(cNull);
pos >= 0)
1867 rStr = rStr.replaceAll(std::u16string_view(&cNull, 1),
u"",
pos);
1873 bool& rbOverflowCell,
bool bRemoveSpace )
1884 while (*pb == cBlank)
1903 while ( ptrim_f > p1 && ( *(ptrim_f - 1) == cBlank ) )
1907 rbOverflowCell =
true;
1921 while ( ptrim_i < ptrim_f && *ptrim_i == cBlank )
1923 while ( ptrim_f > ptrim_i && ( *(ptrim_f - 1) == cBlank ) )
1927 rbOverflowCell =
true;
1947bool hasLineBreaksOrSeps(
const OUString& rStr,
sal_Unicode cSep )
1950 for (sal_Int32 i = 0, n = rStr.getLength(); i < n; ++i, ++p)
1992 std::vector< sc::ColumnBlockPosition > blockPos( nEndCol - nStartCol + 1 );
1993 for(
SCCOL i = nStartCol;
i <= nEndCol; ++
i )
1995 for (nRow = nStartRow; nRow <= nEndRow; nRow++)
1999 for (nCol = nStartCol; nCol <= nEndCol; nCol++)
2013 if( aCellStr.indexOf(
cSep ) != -1 )
2020 const Color* pColor;
2023 bool bMultiLineText = ( aCellStr.indexOf(
'\n' ) != -1 );
2024 if( bMultiLineText )
2027 aCellStr = aCellStr.replaceAll(
"\n",
" " );
2044 const Color* pColor;
2053 const Color* pColor;
2056 bool bMultiLineText = ( aCellStr.indexOf(
'\n' ) != -1 );
2057 if( bMultiLineText )
2060 aCellStr = aCellStr.replaceAll(
"\n",
" " );
2074 if( nCol < nEndCol )
2080 if (nStartRow != nEndRow || nStartCol != nEndCol)
2095 bool bMyDoc =
false;
2096 SylkVersion eVersion = SylkVersion::OTHER;
2108 ::std::vector< sal_uInt32 > aFormats;
2117 OStringBuffer aByteLine;
2118 SCCOL nCol = nStartCol;
2119 SCROW nRow = nStartRow;
2120 SCCOL nRefCol = nCol;
2121 SCROW nRefRow = nRow;
2130 bool bInvalidCol =
false;
2131 bool bInvalidRow =
false;
2139 bool bInvalidRefCol =
false;
2140 bool bInvalidRefRow =
false;
2149 bInvalidCol =
false;
2150 bool bFail = o3tl::checked_add<SCCOL>(
o3tl::toInt32(std::u16string_view(
p)), nStartCol - 1, nCol);
2151 if (bFail || nCol < 0 ||
rDoc.
MaxCol() < nCol)
2153 SAL_WARN(
"sc.ui",
"ScImportExport::Sylk2Doc - ;X invalid nCol=" << nCol);
2154 nCol = std::clamp<SCCOL>(nCol, 0,
rDoc.
MaxCol());
2161 bInvalidRow =
false;
2165 SAL_WARN(
"sc.ui",
"ScImportExport::Sylk2Doc - ;Y invalid nRow=" << nRow);
2173 bInvalidRefCol =
false;
2174 bool bFail = o3tl::checked_add<SCCOL>(
o3tl::toInt32(std::u16string_view(
p)), nStartCol - 1, nRefCol);
2175 if (bFail || nRefCol < 0 ||
rDoc.
MaxCol() < nRefCol)
2177 SAL_WARN(
"sc.ui",
"ScImportExport::Sylk2Doc - ;C invalid nRefCol=" << nRefCol);
2178 nRefCol = std::clamp<SCCOL>(nRefCol, 0,
rDoc.
MaxCol());
2185 bInvalidRefRow =
false;
2189 SAL_WARN(
"sc.ui",
"ScImportExport::Sylk2Doc - ;R invalid nRefRow=" << nRefRow);
2198 ( nCol < nStartCol || nCol > nEndCol
2199 || nRow < nStartRow || nRow > nEndRow
2201 || bInvalidCol || bInvalidRow ) )
2205 if( nRow > nEndRow )
2207 if( nCol > nEndCol )
2221 while( *q && *q !=
';' )
2223 if ( (*q !=
';' || *(q+1) !=
'I') && !bInvalidCol && !bInvalidRow )
2233 double fVal = rtl_math_uStringToDouble(
p,
2234 aLine.getStr() + aLine.getLength(),
2235 cDecSep, cGrpSep,
nullptr,
nullptr );
2246 if ( nRefCol < nCol )
2248 if ( nRefRow < nRow )
2252 if( nRefRow > nEndRow )
2254 if( nRefCol > nEndCol )
2258 if( !bMyDoc || !bData )
2263 if (bInvalidCol || bInvalidRow || (
ch ==
'M' && (bInvalidRefCol || bInvalidRefRow)))
2273 std::unique_ptr<ScTokenArray> xCode(aComp.
CompileString(aText));
2280 nRefRow, aMark, OUString(), xCode.get() );
2291 while( *
p && *
p !=
';' )
2297 else if( cTag ==
'F' )
2301 sal_Int32 nFormat = -1;
2310 bInvalidCol =
false;
2311 bool bFail = o3tl::checked_add<SCCOL>(
o3tl::toInt32(std::u16string_view(
p)), nStartCol - 1, nCol);
2312 if (bFail || nCol < 0 ||
rDoc.
MaxCol() < nCol)
2314 SAL_WARN(
"sc.ui",
"ScImportExport::Sylk2Doc - ;X invalid nCol=" << nCol);
2315 nCol = std::clamp<SCCOL>(nCol, 0,
rDoc.
MaxCol());
2322 bInvalidRow =
false;
2326 SAL_WARN(
"sc.ui",
"ScImportExport::Sylk2Doc - ;Y invalid nRow=" << nRow);
2339 while( *
p && *
p !=
';' )
2341 OUString aNumber(p0,
p - p0);
2342 nFormat = aNumber.toInt32();
2346 while( *
p && *
p !=
';' )
2353 if( nRow > nEndRow )
2355 if( nCol > nEndCol )
2358 if ( 0 <= nFormat &&
o3tl::make_unsigned(nFormat) < aFormats.size() && !bInvalidCol && !bInvalidRow )
2360 sal_uInt32 nKey = aFormats[nFormat];
2365 else if( cTag ==
'P' )
2367 if ( bData && *
p ==
';' && *(
p+1) ==
'P' )
2369 OUString aCode(
p+2 );
2372 sal_Int32 nCheckPos;
2382 aCode = aCode.replaceAll(
";;",
";");
2384 aCode = aCode.replaceAll(
"\x1b",
"");
2393 aFormats.push_back( nKey );
2396 else if (cTag ==
'I' && *
p ==
'D' && aLine.getLength() > 4)
2398 aLine = aLine.copy(4);
2399 if (aLine ==
"CALCOOO32")
2400 eVersion = SylkVersion::OOO32;
2401 else if (aLine ==
"SCALC3")
2402 eVersion = SylkVersion::SCALC3;
2403 bMyDoc = (eVersion <= SylkVersion::OWN);
2405 else if( cTag ==
'E' )
2436 for (nRow = nStartRow; nRow <= nEndRow; nRow++)
2438 for (nCol = nStartCol; nCol <= nEndCol; nCol++)
2443 SCROW r = nRow - nStartRow + 1;
2444 SCCOL c = nCol - nStartCol + 1;
2460 aValStr = ::rtl::math::doubleToUString( nVal,
2461 rtl_math_StringFormat_Automatic,
2462 rtl_math_DecimalPlaces_Max,
'.',
true );
2465 + OUString::number( c )
2467 + OUString::number( r )
2477 aCellStr = aCellStr.replaceAll(
"\n", SYLK_LF);
2480 + OUString::number( c )
2482 + OUString::number( r )
2505 aCellStr.startsWith(
"{") &&
2506 aCellStr.endsWith(
"}") )
2508 aCellStr = aCellStr.copy(1, aCellStr.getLength()-2);
2510 if ( aCellStr[0] ==
'=' )
2511 aCellStr = aCellStr.copy(1);
2523 + OUString::number( nR )
2525 + OUString::number( nC )
2534 + OUString::number( aPos.
Row() - nStartRow + 1 )
2536 + OUString::number( aPos.
Col() - nStartCol + 1 );
2544 if ( !aCellStr.isEmpty() )
2588 pImportDoc->InitUndo(
rDoc, nTab, nTab );
2595 pImportDoc->GetCellArea( nTab, nEndCol, nEndRow );
2608 pImportDoc->CopyToDocument(
aRange, nFlags,
false,
rDoc);
2620 pImp->Read(
rStrm, rBaseURL );
2621 aRange = pImp->GetRange();
2628 pImp->WriteToDocument();
2639 pImp->Read(
rStrm, rBaseURL );
2640 aRange = pImp->GetRange();
2658 bool bSpecialNumber =
pExtOptions->IsDetectSpecialNumber();
2659 bool bScientificNumber =
pExtOptions->IsDetectScientificNumber();
2660 pImp->WriteToDocument(
false, 1.0, &aNumFormatter, bSpecialNumber, bScientificNumber);
2664 pImp->WriteToDocument();
2671#ifndef DISABLE_DYNLOADING
2688#ifndef DISABLE_DYNLOADING
2689 OUString sFilterLib(
SVLIBRARY(
"scfilt"));
2690 static ::osl::Module aModule;
2691 bool bLoaded = aModule.is();
2693 bLoaded = aModule.loadRelative(&
thisModule, sFilterLib);
2695 bLoaded = aModule.load(sFilterLib);
2698 oslGenericFunction fn = aModule.getFunctionSymbol(
"ScFilterCreate" );
2700 return reinterpret_cast<FilterFn>(fn)();
2739 OUString& rFieldSeparators,
sal_Unicode cFieldQuote,
sal_Unicode& rcDetectSep, sal_uInt32 nMaxSourceLines )
2747 } eRetryState = (bEmbeddedLineBreak && rcDetectSep == 0 ? RetryState::ALLOW : RetryState::FORBID);
2749 sal_uInt64 nStreamPos = (eRetryState == RetryState::ALLOW ? rStream.
Tell() : 0);
2751Label_RetryWithNewSep:
2753 if (eRetryState == RetryState::RETRY)
2755 eRetryState = RetryState::RETRIED;
2756 rStream.
Seek( nStreamPos);
2762 if (bEmbeddedLineBreak)
2764 sal_Int32 nFirstLineLength =
aStr.getLength();
2765 sal_uInt64 nFirstLineStreamPos = rStream.
Tell();
2766 sal_uInt32 nLine = 0;
2768 const sal_Unicode* pSeps = rFieldSeparators.getStr();
2770 QuoteType eQuoteState = FIELDEND_QUOTE;
2771 bool bFieldStart =
true;
2773 sal_Int32 nLastOffset = 0;
2774 sal_Int32 nQuotes = 0;
2791 if (*
p == cFieldQuote)
2796 bFieldStart =
false;
2797 eQuoteState = FIELDSTART_QUOTE;
2798 nFirstLineLength =
aStr.getLength();
2799 nFirstLineStreamPos = rStream.
Tell();
2804 else if (eQuoteState != FIELDEND_QUOTE)
2808 if (eRetryState == RetryState::ALLOW && rcDetectSep)
2810 eRetryState = RetryState::RETRY;
2811 rFieldSeparators += OUStringChar(rcDetectSep);
2812 pSeps = rFieldSeparators.getStr();
2813 goto Label_RetryWithNewSep;
2818 if (eQuoteState != DONTKNOW_QUOTE)
2822 else if (eQuoteState == FIELDEND_QUOTE)
2835 if (*
p == cFieldQuote && bFieldStart)
2838 eQuoteState = FIELDSTART_QUOTE;
2839 bFieldStart =
false;
2840 nFirstLineLength =
aStr.getLength();
2841 nFirstLineStreamPos = rStream.
Tell();
2843 else if (eQuoteState == FIELDEND_QUOTE)
2860 if ((nQuotes & 1) == 0)
2865 else if (eQuoteState == DONTKNOW_QUOTE)
2870 else if (++nLine >= nMaxSourceLines && nMaxSourceLines > 0)
2876 nLastOffset =
aStr.getLength();
2880 aStr +=
"\n" + aNext;
2887 aStr =
aStr.copy( 0, nFirstLineLength);
2888 rStream.
Seek( nFirstLineStreamPos);
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
static OUString GetAppName()
css::uno::Sequence< css::i18n::CalendarItem2 > getMonths() const
void setValue(sal_Int16 nFieldIndex, sal_Int16 nValue)
sal_Int16 getNumberOfMonthsInYear() const
bool isLetterNumeric(const OUString &rStr, sal_Int32 nPos) const
std::unique_ptr< EditTextObject > CreateTextObject()
SC_DLLPUBLIC void Format(OStringBuffer &r, ScRefFlags nFlags, const ScDocument *pDocument=nullptr, const Details &rDetails=detailsOOOa1) const
SC_DLLPUBLIC ScRefFlags Parse(const OUString &, const ScDocument &, const Details &rDetails=detailsOOOa1, ExternalInfo *pExtInfo=nullptr, const css::uno::Sequence< css::sheet::ExternalLinkInfo > *pExternalLinks=nullptr, sal_Int32 *pSheetEndPos=nullptr, const OUString *pErrRef=nullptr)
static sal_Unicode GetWeightedFieldSep(const OUString &rFieldSeps, bool bDecodeNumbers)
From the import field separators obtain the one most likely to be used for export,...
sal_Unicode GetTextSep() const
const OUString & GetFieldSeps() const
std::unique_ptr< ScTokenArray > CompileString(const OUString &rFormula)
Tokenize formula expression string into an array of tokens.
static weld::Window * GetActiveDialogParent()
void SetDocumentModified()
ScDrawLayer * MakeDrawLayer()
void PostPaint(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, sal_uInt16 nExtFlags=0)
bool AdjustRowHeight(SCROW nStartRow, SCROW nEndRow, SCTAB nTab)
merge with docfunc
virtual SfxUndoManager * GetUndoManager() override
Accessor class to ScDocument.
void setEditCell(const ScAddress &rPos, std::unique_ptr< EditTextObject > pEditText)
void setStringCell(const ScAddress &rPos, const OUString &rStr)
void setNumericCell(const ScAddress &rPos, double fVal)
void setAutoInput(const ScAddress &rPos, const OUString &rStr, const ScSetStringParam *pStringParam=nullptr)
ScSheetLimits & GetSheetLimits() const
SC_DLLPUBLIC sal_uInt32 GetNumberFormat(SCCOL nCol, SCROW nRow, SCTAB nTab) const
SC_DLLPUBLIC ScFormulaCell * SetFormulaCell(const ScAddress &rPos, ScFormulaCell *pCell)
Set formula cell, and transfer its ownership to the document.
bool ValidRow(SCROW nRow) const
SC_DLLPUBLIC void InsertMatrixFormula(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, const ScMarkData &rMark, const OUString &rFormula, const ScTokenArray *p=nullptr, const formula::FormulaGrammar::Grammar=formula::FormulaGrammar::GRAM_DEFAULT)
ScClipParam & GetClipParam()
bool ShrinkToDataArea(SCTAB nTab, SCCOL &rStartCol, SCROW &rStartRow, SCCOL &rEndCol, SCROW &rEndRow) const
Shrink a range to only include data area.
SC_DLLPUBLIC SCCOL MaxCol() const
SC_DLLPUBLIC bool RowFiltered(SCROW nRow, SCTAB nTab, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
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 formula::FormulaGrammar::AddressConvention GetAddressConvention() const
SC_DLLPUBLIC SCROW MaxRow() const
SC_DLLPUBLIC void CheckLinkFormulaNeedingCheck(const ScTokenArray &rCode)
Check token array and set link check if ocDde/ocWebservice is contained.
SC_DLLPUBLIC ScFieldEditEngine & GetEditEngine()
SC_DLLPUBLIC double GetValue(const ScAddress &rPos) const
void BroadcastCells(const ScRange &rRange, SfxHintId nHint, bool bBroadcastSingleBroadcasters=true)
SC_DLLPUBLIC bool InitColumnBlockPosition(sc::ColumnBlockPosition &rBlockPos, SCTAB nTab, SCCOL nCol)
SC_DLLPUBLIC void ApplyPattern(SCCOL nCol, SCROW nRow, SCTAB nTab, const ScPatternAttr &rAttr)
SC_DLLPUBLIC void SetNumberFormat(const ScAddress &rPos, sal_uInt32 nNumberFormat)
SC_DLLPUBLIC bool SetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const ScSetStringParam *pParam=nullptr)
void CopyToDocument(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, InsertDeleteFlags nFlags, bool bMarked, ScDocument &rDestDoc, const ScMarkData *pMarks=nullptr, bool bColRowFlags=true)
SC_DLLPUBLIC void SetValue(SCCOL nCol, SCROW nRow, SCTAB nTab, const double &rVal)
SC_DLLPUBLIC void ApplyAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, const SfxPoolItem &rAttr)
SfxObjectShell * GetDocumentShell() const
bool ValidCol(SCCOL nCol) const
SC_DLLPUBLIC bool HasValueData(SCCOL nCol, SCROW nRow, SCTAB nTab) const
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
SC_DLLPUBLIC void DeleteAreaTab(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCTAB nTab, InsertDeleteFlags nDelFlag)
SC_DLLPUBLIC OUString GetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const ScInterpreterContext *pContext=nullptr) const
bool IsBlockEmpty(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab) const
bool IsUndoEnabled() const
void SetTextCurrentDefaults(const EditTextObject &rTextObject)
SetText and apply defaults already set.
TranslateId GetMessageId() const
static const sal_Unicode * UnicodeStrChr(const sal_Unicode *pStr, sal_Unicode c)
strchr() functionality on unicode, as long as we need it for FormulaToken etc.
static SC_DLLPUBLIC LanguageType eLnge
static sal_Unicode ToUpperAlpha(sal_Unicode c)
static SC_DLLPUBLIC const CharClass & getCharClass()
static const OUString & GetClipDocName()
static void EmbeddedNullTreatment(OUString &rStr)
static sal_Int32 CountVisualWidth(const OUString &rStr, sal_Int32 &nIdx, sal_Int32 nMaxWidth)
ScImportExport::CountVisualWidth Count the width of string visually ( in multiple of western characte...
void SetFilterOptions(const OUString &rFilterOptions)
bool Doc2HTML(SvStream &, const OUString &)
static void WriteUnicodeOrByteEndl(SvStream &rStrm)
ScExportTextOptions mExportTextOptions
bool ExportByteString(OString &, rtl_TextEncoding, SotClipboardFormatId)
static bool IsFormatSupported(SotClipboardFormatId nFormat)
bool ExportString(OUString &, SotClipboardFormatId)
static void WriteUnicodeOrByteString(SvStream &rStrm, std::u16string_view rString, bool bZero=false)
bool ExtText2Doc(SvStream &)
std::unique_ptr< ScAsciiOptions > pExtOptions
bool Text2Doc(SvStream &)
bool ExportStream(SvStream &, const OUString &rBaseURL, SotClipboardFormatId)
bool Doc2Text(SvStream &)
bool ImportString(const OUString &, SotClipboardFormatId)
bool RTF2Doc(SvStream &, const OUString &rBaseURL)
static const sal_Unicode * ScanNextFieldFromString(const sal_Unicode *p, OUString &rField, sal_Unicode cStr, const sal_Unicode *pSeps, bool bMergeSeps, bool &rbIsQuoted, bool &rbOverflowCell, bool bRemoveSpace)
bool Sylk2Doc(SvStream &)
ScImportExport(ScDocument &)
bool ImportStream(SvStream &, const OUString &rBaseURL, SotClipboardFormatId)
void EndPaste(bool bAutoRowHeight=true)
static void SetNoEndianSwap(SvStream &rStrm)
only if stream is only used in own (!) memory
void SetExtOptions(const ScAsciiOptions &rOpt)
OUString aNonConvertibleChars
bool HTML2Doc(SvStream &, const OUString &rBaseURL)
bool Doc2Sylk(SvStream &)
~ScImportExport() COVERITY_NOEXCEPT_FALSE
bool ExportData(std::u16string_view rMimeType, css::uno::Any &rValue)
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > pUndoDoc
ScImportStringStream(const OUString &rStr)
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
void SelectTable(SCTAB nTab, bool bNew)
void SetMarkArea(const ScRange &rRange)
SfxItemSet & GetItemSet()
SC_DLLPUBLIC ScRangeData * findByUpperName(const OUString &rName)
OUString Format(const ScDocument &rDocument, ScRefFlags nFlags=ScRefFlags::ZERO, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1, bool bFullAddressNotation=false) const
Returns string with formatted cell range from aStart to aEnd, according to provided address conventio...
ScRefFlags Parse(const OUString &, const ScDocument &, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1, ScAddress::ExternalInfo *pExtInfo=nullptr, const css::uno::Sequence< css::sheet::ExternalLinkInfo > *pExternalLinks=nullptr, const OUString *pErrRef=nullptr)
Warning box for "Replace cell contents?".
virtual short run() override
Opens dialog if IsDialogEnabled() returns true.
static bool SC_DLLPUBLIC isMultiline(std::u16string_view rStr)
void UpdateInputHandler(bool bForce=false, bool bStopEditing=true)
static ScTabViewShell * GetActiveViewShell()
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
OUString GetTitle(sal_uInt16 nMaxLen=0) const
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
static SotClipboardFormatId GetFormatIdFromMimeType(std::u16string_view rMimeType)
virtual sal_uInt64 TellEnd() override
void StartReadingUnicodeText(rtl_TextEncoding eReadBomCharSet)
void SetEndian(SvStreamEndian SvStreamEndian)
LineEnd GetLineDelimiter() const
std::size_t WriteBytes(const void *pData, std::size_t nSize)
SvStream & WriteUChar(unsigned char nChar)
bool ReadUniOrByteStringLine(OUString &rStr, rtl_TextEncoding eSrcCharSet, sal_Int32 nMaxCodepointsToRead=0xFFFE)
SvStream & WriteUInt16(sal_uInt16 nUInt16)
SvStream & WriteOString(std::string_view rStr)
bool ReadLine(OStringBuffer &rStr, sal_Int32 nMaxBytesToRead=0xFFFE)
SvStreamEndian GetEndian() const
sal_uInt64 Seek(sal_uInt64 nPos)
void SetStreamCharSet(rtl_TextEncoding eCharSet)
SvStream & WriteChar(char nChar)
rtl_TextEncoding GetStreamCharSet() const
const sal_uInt8 SC_COL_TEXT
const sal_uInt8 SC_COL_MDY
const sal_uInt8 SC_COL_YMD
const sal_uInt8 SC_COL_STANDARD
const sal_uInt8 SC_COL_DMY
const sal_uInt8 SC_COL_ENGLISH
const sal_uInt8 SC_COL_SKIP
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > ScDocumentUniquePtr
@ NOCAPTIONS
Sparklines in a cell.
static QuoteType lcl_isEscapedOrFieldEndQuote(sal_Int32 nQuotes, const sal_Unicode *p, const sal_Unicode *pSeps, sal_Unicode cStr, sal_Unicode &rcDetectSep)
Determine if *p is a quote that is escaped by being doubled or ends a quoted field.
static const sal_Unicode * lcl_ScanString(const sal_Unicode *p, OUString &rField, const sal_Unicode *pSeps, sal_Unicode cStr, DoubledQuoteMode eMode, bool &rbOverflowCell)
Scan for a quoted string.
static const sal_Unicode * lcl_UnicodeStrChr(const sal_Unicode *pStr, sal_Unicode c)
static void lcl_UnescapeSylk(OUString &rString, SylkVersion eVersion)
static bool lcl_appendLineData(OUString &rField, const sal_Unicode *p1, const sal_Unicode *p2)
Append characters of [p1,p2) to rField.
ScFormatFilterPlugin *(* FilterFn)()
static bool lcl_PutString(ScDocumentImport &rDocImport, bool bUseDocImport, SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rStr, sal_uInt8 nColFormat, SvNumberFormatter *pFormatter, bool bDetectNumFormat, bool bDetectSciNumFormat, bool bEvaluateFormulas, bool bSkipEmptyCells, const ::utl::TransliterationWrapper &rTransliteration, CalendarWrapper &rCalendar, const ::utl::TransliterationWrapper *pSecondTransliteration, CalendarWrapper *pSecondCalendar)
static OUString lcl_GetFixed(const OUString &rLine, sal_Int32 nStart, sal_Int32 nNext, bool &rbIsQuoted, bool &rbOverflowCell)
static void lcl_WriteSimpleString(SvStream &rStrm, std::u16string_view rString)
static bool lcl_isFieldEnd(sal_Unicode c, const sal_Unicode *pSeps)
static const sal_Unicode * lcl_ScanSylkString(const sal_Unicode *p, OUString &rString, SylkVersion eVersion)
static QuoteType lcl_isFieldEndQuote(const sal_Unicode *p, const sal_Unicode *pSeps, sal_Unicode &rcDetectSep)
Determine if *p is a quote that ends a quoted field.
constexpr sal_Int32 nArbitraryLineLengthLimit
static const sal_Unicode * lcl_ScanSylkFormula(const sal_Unicode *p, OUString &rString, SylkVersion eVersion)
constexpr sal_Int32 nArbitraryCellLengthLimit
OUString ReadCsvLine(SvStream &rStream, bool bEmbeddedLineBreak, OUString &rFieldSeparators, sal_Unicode cFieldQuote, sal_Unicode &rcDetectSep, sal_uInt32 nMaxSourceLines)
Read a CSV (comma separated values) data line using ReadUniOrByteStringLine().
static void lcl_WriteString(SvStream &rStrm, OUString &rString, sal_Unicode cQuote, sal_Unicode cEsc)
#define LANGUAGE_ENGLISH_US
LineEnd GetSystemLineEnd()
TOOLS_DLLPUBLIC OString convertLineEnd(const OString &rIn, LineEnd eLineEnd)
#define SAL_WARN(area, stream)
std::unique_ptr< sal_Int32[]> pData
double getLength(const B2DPolygon &rCandidate)
Reference< XComponentContext > getProcessComponentContext()
std::enable_if< std::is_signed< T >::value, bool >::type checked_add(T a, T b, T &result)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
CAUTION! The following defines must be in the same namespace as the respective type.
#define SFX_TITLE_FULLNAME
OUString ScResId(TranslateId aId)
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALUE_FORMAT(146)
TOOLS_DLLPUBLIC SvStream & endl(SvStream &rStr)
bool isMultiRange() const
sal_Unicode mcSeparatorConvertTo
NewlineConversion meNewlineConversion
This is very similar to ScCellValue, except that it references the original value instead of copying ...
ScFormulaCell * getFormula() const
Store parameters used in the ScDocument::SetString() method.
bool mbCheckLinkFormula
When true and the string results in a compiled formula, check the formula tokens for presence of func...