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 <osl/endian.h>
85 const char SYLK_LF[] =
"\x1b :";
111 : pDocSh( dynamic_cast<
ScDocShell* >(r.GetDocumentShell()) ), rDoc( r ),
112 nSizeLimit( 0 ), nMaxImportRow(!
utl::ConfigManager::IsFuzzing() ? rDoc.MaxRow() :
SCROWS32K),
113 cSep(
'\t' ), cStr(
'"' ),
114 bFormulas( false ), bIncludeFiltered( true ),
115 bAll( true ), bSingle( true ), bUndo( false ),
116 bOverflowRow( false ), bOverflowCol( false ), bOverflowCell( false ),
117 mbApi( true ), mbImportBroadcast(false), mbOverwriting( false ), mbIncludeBOM(false)
125 : pDocSh( dynamic_cast<
ScDocShell* >(r.GetDocumentShell()) ), rDoc( r ),
127 nSizeLimit( 0 ), nMaxImportRow(!
utl::ConfigManager::IsFuzzing() ? rDoc.MaxRow() :
SCROWS32K),
128 cSep(
'\t' ), cStr(
'"' ),
129 bFormulas( false ), bIncludeFiltered( true ),
130 bAll( false ), bSingle( true ), bUndo( pDocSh != nullptr ),
131 bOverflowRow( false ), bOverflowCol( false ), bOverflowCell( false ),
132 mbApi( true ), mbImportBroadcast(false), mbOverwriting( false ), mbIncludeBOM(false)
141 : pDocSh( dynamic_cast<
ScDocShell* >(r.GetDocumentShell()) ), rDoc( r ),
143 nSizeLimit( 0 ), nMaxImportRow(!
utl::ConfigManager::IsFuzzing() ? rDoc.MaxRow() :
SCROWS32K),
144 cSep(
'\t' ), cStr(
'"' ),
145 bFormulas( false ), bIncludeFiltered( true ),
146 bAll( false ), bSingle( false ), bUndo( pDocSh != nullptr ),
147 bOverflowRow( false ), bOverflowCol( false ), bOverflowCell( false ),
148 mbApi( true ), mbImportBroadcast(false), mbOverwriting( false ), mbIncludeBOM(false)
159 : pDocSh( dynamic_cast<
ScDocShell* >(r.GetDocumentShell()) ), rDoc( r ),
160 nSizeLimit( 0 ), nMaxImportRow(!
utl::ConfigManager::IsFuzzing() ? rDoc.MaxRow() :
SCROWS32K),
161 cSep(
'\t' ), cStr(
'"' ),
162 bFormulas( false ), bIncludeFiltered( true ),
163 bAll( false ), bSingle( true ), bUndo( pDocSh != nullptr ),
164 bOverflowRow( false ), bOverflowCol( false ), bOverflowCell( false ),
165 mbApi( true ), mbImportBroadcast(false), mbOverwriting( false ), mbIncludeBOM(false)
172 OUString aPos( rPos );
184 aPos =
pData->GetSymbol();
225 return nFormat == SotClipboardFormatId::STRING
226 || nFormat == SotClipboardFormatId::STRING_TSVC
227 || nFormat == SotClipboardFormatId::SYLK
228 || nFormat == SotClipboardFormatId::LINK
229 || nFormat == SotClipboardFormatId::HTML
230 || nFormat == SotClipboardFormatId::HTML_SIMPLE
231 || nFormat == SotClipboardFormatId::DIF;
243 VclMessageType::Info, VclButtonsType::Ok,
269 ScMarkData aDestMark(pRedoDoc->GetSheetLimits());
288 css::uno::Any & rValue )
292 if (fmtId == SotClipboardFormatId::STRING)
297 if (fmtId == SotClipboardFormatId::STRING)
300 rValue <<= OUString(static_cast<const sal_Unicode*>(aStrm.
GetData()),
306 rValue <<= css::uno::Sequence<sal_Int8>(
static_cast<sal_Int8 const*
>(aStrm.
GetData()),
319 case SotClipboardFormatId::STRING :
320 case SotClipboardFormatId::STRING_TSVC :
328 rtl_TextEncoding eEnc = osl_getThreadTextEncoding();
329 OString aTmp( rText.getStr(), rText.getLength(), eEnc );
330 SvMemoryStream aStrm(
const_cast<char *
>(aTmp.getStr()), aTmp.getLength() *
sizeof(
char), StreamMode::READ );
340 if ( nFmt != SotClipboardFormatId::STRING && nFmt != SotClipboardFormatId::STRING_TSVC )
342 SAL_WARN(
"sc.ui",
"ScImportExport::ExportString: Unicode not supported for other formats than SotClipboardFormatId::STRING[_TSV]");
343 rtl_TextEncoding eEnc = osl_getThreadTextEncoding();
346 rText = OStringToOUString( aTmp, eEnc );
369 OSL_ENSURE( eEnc != RTL_TEXTENCODING_UNICODE,
"ScImportExport::ExportByteString: Unicode not supported" );
370 if ( eEnc == RTL_TEXTENCODING_UNICODE )
371 eEnc = osl_getThreadTextEncoding();
385 rText =
static_cast<const char*
>(aStrm.
GetData());
395 if( nFmt == SotClipboardFormatId::STRING || nFmt == SotClipboardFormatId::STRING_TSVC )
400 if( nFmt == SotClipboardFormatId::SYLK )
405 if( nFmt == SotClipboardFormatId::DIF )
410 if( nFmt == SotClipboardFormatId::RTF || nFmt == SotClipboardFormatId::RICHTEXT )
415 if( nFmt == SotClipboardFormatId::LINK )
417 if ( nFmt == SotClipboardFormatId::HTML )
422 if ( nFmt == SotClipboardFormatId::HTML_SIMPLE )
426 if ( pHTML &&
HTML2Doc( *pHTML, rBaseURL ) )
435 if( nFmt == SotClipboardFormatId::STRING || nFmt == SotClipboardFormatId::STRING_TSVC )
440 if( nFmt == SotClipboardFormatId::SYLK )
445 if( nFmt == SotClipboardFormatId::DIF )
450 if( nFmt == SotClipboardFormatId::LINK && !
bAll )
462 OSL_ENSURE( !aDocName.isEmpty(),
"ClipBoard document has no name! :-/" );
463 if( !aDocName.isEmpty() )
492 if( nFmt == SotClipboardFormatId::HTML )
497 if( nFmt == SotClipboardFormatId::RTF || nFmt == SotClipboardFormatId::RICHTEXT )
509 if ( eEnc == RTL_TEXTENCODING_UNICODE )
511 if ( !lcl_IsEndianSwap(
rStrm ) )
557 sal_Int32 nWidth = 0;
558 while(nIdx < rStr.getLength() && nWidth < nMaxWidth)
560 sal_uInt32
nCode = rStr.iterateCodePoints(&nIdx);
568 if (nIdx < rStr.getLength())
570 sal_Int32 nTmpIdx = nIdx;
571 sal_uInt32
nCode = rStr.iterateCodePoints(&nTmpIdx);
627 return FIELDEND_QUOTE;
630 const bool bBlankSep = (
p[1] == cBlank && !rcDetectSep &&
p[2] &&
p[2] != cBlank);
631 while (
p[1] == cBlank)
634 return FIELDEND_QUOTE;
649 return FIELDEND_QUOTE;
656 rcDetectSep = cBlank;
657 return FIELDEND_QUOTE;
659 return DONTKNOW_QUOTE;
686 if ((nQuotes & 1) == 0)
692 SAL_WARN(
"sc",
"lcl_isEscapedOrFieldEndQuote: really want a FIELDSTART_QUOTE?");
693 return FIELDSTART_QUOTE;
709 rField += std::u16string_view( p1, p2 - p1 );
714 SAL_WARN(
"sc",
"lcl_appendLineData: data overflow");
722enum class DoubledQuoteMode
752 bool bClosingQuote = (
eMode == DoubledQuoteMode::KEEP_ALL);
754 if (
eMode != DoubledQuoteMode::KEEP_ALL)
768 if (
eMode == DoubledQuoteMode::KEEP_ALL)
781 if (
eMode == DoubledQuoteMode::ESCAPE)
786 bClosingQuote =
true;
798 case DoubledQuoteMode::KEEP_ALL :
801 case DoubledQuoteMode::ESCAPE :
806 if (
eMode == DoubledQuoteMode::ESCAPE )
815 rbOverflowCell =
true;
822 if (!aString.isEmpty())
833 if (eVersion >= SylkVersion::OOO32)
834 rString = rString.replaceAll(
";;",
";");
836 rString = rString.replaceAll(
"\"\"",
"\"");
838 rString = rString.replaceAll(SYLK_LF,
"\n");
842 OUString& rString, SylkVersion eVersion )
851 if (eVersion >= SylkVersion::OOO32)
871 else if (*(
p+1) ==
';')
878 rString += std::u16string_view(pStartQuote + 1, pEndQuote - pStartQuote - 1 );
884 OUString& rString, SylkVersion eVersion )
887 if (eVersion >= SylkVersion::OOO32)
900 rString += std::u16string_view( pStart,
p - pStart);
913 bool bQuoted =
false;
939 while (*
p && *
p !=
';')
941 rString += std::u16string_view( pStart,
p - pStart);
952 OUString strFrom(cEsc);
953 OUString strTo = strFrom + strFrom;
954 rString = rString.replaceAll(strFrom, strTo);
959 rString = OUStringChar(cQuote) + rString + OUStringChar(cQuote);
995 SCROW nRow = nStartRow;
1001 DoubledQuoteMode
mode = aLine.indexOf(
"\t") >= 0 ? DoubledQuoteMode::ESCAPE : DoubledQuoteMode::KEEP_ALL;
1004 SCCOL nCol = nStartCol;
1026 if (nCol>nEndCol) nEndCol = nCol;
1027 if (nRow>nEndRow) nEndRow = nRow;
1029 if( bData && nCol <= nEndCol && nRow <= nEndRow )
1070 SvNumberFormatter* pFormatter,
bool bDetectNumFormat,
bool bEvaluateFormulas,
bool bSkipEmptyCells,
1071 const ::utl::TransliterationWrapper& rTransliteration,
CalendarWrapper& rCalendar,
1072 const ::utl::TransliterationWrapper* pSecondTransliteration,
CalendarWrapper* pSecondCalendar )
1075 bool bMultiLine =
false;
1078 if ( rStr.isEmpty() )
1080 if ( !bSkipEmptyCells )
1082 if ( bUseDocImport )
1085 rDoc.
SetString( nCol, nRow, nTab, rStr );
1090 const bool bForceFormulaText = (!bEvaluateFormulas && rStr[0] ==
'=');
1091 if (nColFormat ==
SC_COL_TEXT || bForceFormulaText)
1093 if ( bUseDocImport )
1138 if ( bUseDocImport )
1141 rDoc.
SetValue( nCol, nRow, nTab, fVal );
1148 const sal_uInt16 nMaxNumberParts = 7;
1149 const sal_Int32 nLen = rStr.getLength();
1150 sal_Int32 nStart[nMaxNumberParts];
1151 sal_Int32 nEnd[nMaxNumberParts];
1154 sal_uInt16 nDP, nMP, nYP;
1155 switch ( nColFormat )
1157 case SC_COL_YMD: nDP = 2; nMP = 1; nYP = 0; bIso =
true;
break;
1158 case SC_COL_MDY: nDP = 1; nMP = 0; nYP = 2; bIso =
false;
break;
1160 default: nDP = 0; nMP = 1; nYP = 2; bIso =
false;
break;
1163 sal_uInt16 nFound = 0;
1164 bool bInNum =
false;
1165 for (sal_Int32
nPos = 0;
nPos < nLen && (bInNum || nFound < nMaxNumberParts); ++
nPos)
1167 bool bLetter =
false;
1168 if (rtl::isAsciiDigit(rStr[
nPos]) ||
1169 (((!bInNum && nFound==nMP) || (bInNum && nFound==nMP+1))
1175 nStart[nFound] =
nPos;
1178 nEnd[nFound-1] =
nPos;
1179 if (bIso && (bLetter || (2 <= nFound && nFound <= 6 && nPos > nStart[nFound-1] + 1)))
1195 if (nFound >= 5 &&
nPos == nEnd[nFound-1] + 1)
1203 if (nFound >= 5 &&
nPos == nEnd[nFound-1] + 1)
1206 else if (nFound == 0 &&
nPos > 0)
1209 else if (nFound < 1 || 2 < nFound ||
nPos != nEnd[nFound-1] + 1)
1215 if (nFound != 3 ||
nPos != nEnd[nFound-1] + 1)
1220 if (nFound < 4 || 5 < nFound ||
nPos != nEnd[nFound-1] + 1)
1226 if (nFound != 6 ||
nPos != nEnd[nFound-1] + 1)
1231 if (nFound >= 5 &&
nPos == nEnd[nFound-1] + 1)
1252 sal_uInt32 nFormat = 0;
1257 if (pDocFormatter->
GetType(nFormat) & SvNumFormatType::DATE)
1277 sal_Int32 nDateStart = nStart[0];
1278 sal_Int32 nDateLen = nEnd[0] + 1 - nDateStart;
1280 if ( nDateLen >= 5 && nDateLen <= 8 &&
1287 bool bLongYear = ( nDateLen >= 7 );
1288 bool bShortFirst = ( nDateLen == 5 || nDateLen == 7 );
1290 sal_uInt16 nFieldStart = nDateStart;
1293 sal_uInt16 nFieldEnd = nFieldStart + 1;
1294 if ( bLongYear &&
nPos == nYP )
1296 if ( bShortFirst &&
nPos == 0 )
1299 nStart[
nPos] = nFieldStart;
1300 nEnd[
nPos] = nFieldEnd;
1301 nFieldStart = nFieldEnd + 1;
1307 if (!bIso && nFound >= 3)
1310 bool bSecondCal =
false;
1311 sal_uInt16 nDay =
static_cast<sal_uInt16
>(
o3tl::toInt32(rStr.subView( nStart[nDP], nEnd[nDP]+1-nStart[nDP] )));
1312 sal_uInt16 nYear =
static_cast<sal_uInt16
>(
o3tl::toInt32(rStr.subView( nStart[nYP], nEnd[nYP]+1-nStart[nYP] )));
1313 OUString aMStr = rStr.copy( nStart[nMP], nEnd[nMP]+1-nStart[nMP] );
1314 sal_Int16 nMonth =
static_cast<sal_Int16
>(aMStr.toInt32());
1317 static constexpr OUStringLiteral aSepShortened =
u"SEP";
1318 uno::Sequence< i18n::CalendarItem2 > xMonths;
1319 sal_Int32
i, nMonthCount;
1322 nMonthCount = xMonths.getLength();
1323 for (
i=0;
i<nMonthCount && !nMonth;
i++)
1325 if ( rTransliteration.isEqual( aMStr, xMonths[
i].FullName ) ||
1326 rTransliteration.isEqual( aMStr, xMonths[
i].AbbrevName ) )
1327 nMonth = sal::static_int_cast<sal_Int16>(
i+1 );
1328 else if (
i == 8 && rTransliteration.isEqual(
"SEPT",
1329 xMonths[
i].AbbrevName ) &&
1330 rTransliteration.isEqual( aMStr, aSepShortened ) )
1333 nMonth = sal::static_int_cast<sal_Int16>(
i+1 );
1337 if ( !nMonth && pSecondCalendar && pSecondTransliteration )
1340 nMonthCount = xMonths.getLength();
1341 for (
i=0;
i<nMonthCount && !nMonth;
i++)
1343 if ( pSecondTransliteration->isEqual( aMStr, xMonths[
i].FullName ) ||
1344 pSecondTransliteration->isEqual( aMStr, xMonths[
i].AbbrevName ) )
1346 nMonth = sal::static_int_cast<sal_Int16>(
i+1 );
1349 else if (
i == 8 && pSecondTransliteration->isEqual(
1350 aMStr, aSepShortened ) )
1353 nMonth = sal::static_int_cast<sal_Int16>(
i+1 );
1364 CalendarWrapper* pCalendar = (bSecondCal ? pSecondCalendar : &rCalendar);
1366 if ( nDay && nMonth && nDay<=31 && nMonth<=nNumMonths )
1369 pCalendar->
setValue( i18n::CalendarFieldIndex::DAY_OF_MONTH, nDay );
1370 pCalendar->
setValue( i18n::CalendarFieldIndex::MONTH, nMonth );
1371 pCalendar->
setValue( i18n::CalendarFieldIndex::YEAR, nYear );
1372 sal_Int16 nHour, nMinute, nSecond;
1375 nHour = nMinute = nSecond = 0;
1377 nHour =
static_cast<sal_Int16
>(
o3tl::toInt32(rStr.subView( nStart[3], nEnd[3]+1-nStart[3])));
1379 nMinute =
static_cast<sal_Int16
>(
o3tl::toInt32(rStr.subView( nStart[4], nEnd[4]+1-nStart[4])));
1381 nSecond =
static_cast<sal_Int16
>(
o3tl::toInt32(rStr.subView( nStart[5], nEnd[5]+1-nStart[5])));
1387 OUString aT = OUStringChar(cDec) + rStr.subView( nStart[6], nEnd[6]+1-nStart[6]);
1388 rtl_math_ConversionStatus eStatus;
1389 double fV = rtl::math::stringToDouble( aT, cDec, 0, &eStatus );
1390 if (eStatus == rtl_math_ConversionStatus_Ok)
1391 fFrac = fV / 86400.0;
1394 if (nFound > 3 && 1 <= nHour && nHour <= 12 // nHour 0 and >=13 can
't be AM/PM
1395 && (nPos = nEnd[nFound-1] + 1) < nLen)
1397 // Dreaded AM/PM may be following.
1398 while (nPos < nLen && rStr[nPos] == ' ')
1402 sal_Int32 nStop = nPos;
1403 while (nStop < nLen && rStr[nStop] != ' ')
1405 OUString aAmPm = rStr.copy( nPos, nStop - nPos);
1406 // For AM only 12 needs to be treated, whereas for PM
1407 // it must not. Check both, locale and second/English
1410 (rTransliteration.isEqual( aAmPm, pFormatter->GetLocaleData()->getTimeAM()) ||
1411 (pSecondTransliteration && pSecondTransliteration->isEqual( aAmPm, "AM"))))
1415 else if (nHour < 12 &&
1416 (rTransliteration.isEqual( aAmPm, pFormatter->GetLocaleData()->getTimePM()) ||
1417 (pSecondTransliteration && pSecondTransliteration->isEqual( aAmPm, "PM"))))
1423 pCalendar->setValue( i18n::CalendarFieldIndex::HOUR, nHour );
1424 pCalendar->setValue( i18n::CalendarFieldIndex::MINUTE, nMinute );
1425 pCalendar->setValue( i18n::CalendarFieldIndex::SECOND, nSecond );
1426 pCalendar->setValue( i18n::CalendarFieldIndex::MILLISECOND, 0 );
1427 if ( pCalendar->isValid() )
1429 double fDiff = DateTime(pDocFormatter->GetNullDate()) -
1430 pCalendar->getEpochStart();
1431 // #i14974# must use getLocalDateTime to get the same
1432 // date values as set above
1433 double fDays = pCalendar->getLocalDateTime() + fFrac;
1436 LanguageType eLatin, eCjk, eCtl;
1437 rDoc.GetLanguage( eLatin, eCjk, eCtl );
1438 LanguageType eDocLang = eLatin; //! which language for date formats?
1440 SvNumFormatType nType = (nFound > 3 ? SvNumFormatType::DATETIME : SvNumFormatType::DATE);
1441 sal_uLong nFormat = pDocFormatter->GetStandardFormat( nType, eDocLang );
1442 // maybe there is a special format including seconds or milliseconds
1444 nFormat = pDocFormatter->GetStandardFormat( fDays, nFormat, nType, eDocLang);
1446 ScAddress aPos(nCol,nRow,nTab);
1447 if ( bUseDocImport )
1448 rDocImport.setNumericCell(aPos, fDays);
1450 rDoc.SetValue( aPos, fDays );
1451 rDoc.SetNumberFormat(aPos, nFormat);
1453 return bMultiLine; // success
1459 // Standard or date not determined -> SetString / EditCell
1460 if( rStr.indexOf( '\
n' ) == -1 )
1462 if (!bDetectNumFormat && nColFormat == SC_COL_STANDARD)
1464 // Import a strict ISO 8601 date(+time) string even without
1465 // "Detect special numbers" or "Date (YMD)".
1468 // Simple pre-check before calling more expensive parser.
1469 // ([+-])(Y)YYYY-MM-DD
1470 if (rStr.getLength() < 10)
1472 const sal_Int32 n1 = rStr.indexOf('-
', 1);
1475 const sal_Int32 n2 = rStr.indexOf('-
', n1 + 1);
1476 if (n2 < 7 || n1 + 3 < n2)
1479 css::util::DateTime aDateTime;
1480 if (!sax::Converter::parseDateTime( aDateTime, rStr))
1483 sal_uInt32 nFormat = 0;
1485 SvNumberFormatter* pDocFormatter = rDoc.GetFormatTable();
1486 if (pDocFormatter->IsNumberFormat( rStr, nFormat, fVal))
1488 if (pDocFormatter->GetType(nFormat) & SvNumFormatType::DATE)
1490 ScAddress aPos(nCol,nRow,nTab);
1492 rDocImport.setNumericCell(aPos, fVal);
1494 rDoc.SetValue(aPos, fVal);
1495 rDoc.SetNumberFormat(aPos, nFormat);
1497 return bMultiLine; // success
1504 ScSetStringParam aParam;
1505 aParam.mpNumFormatter = pFormatter;
1506 aParam.mbDetectNumberFormat = bDetectNumFormat;
1507 aParam.meSetTextNumFormat = ScSetStringParam::SpecialNumberOnly;
1508 aParam.mbHandleApostrophe = false;
1509 aParam.mbCheckLinkFormula = true;
1510 if ( bUseDocImport )
1511 rDocImport.setAutoInput(ScAddress(nCol, nRow, nTab), rStr, &aParam);
1513 rDoc.SetString( nCol, nRow, nTab, rStr, &aParam );
1518 ScFieldEditEngine& rEngine = rDoc.GetEditEngine();
1519 rEngine.SetTextCurrentDefaults(rStr);
1520 if ( bUseDocImport )
1521 rDocImport.setEditCell(ScAddress(nCol, nRow, nTab), rEngine.CreateTextObject());
1523 rDoc.SetEditText( ScAddress( nCol, nRow, nTab ), rEngine.CreateTextObject() );
1528static OUString lcl_GetFixed( const OUString& rLine, sal_Int32 nStart, sal_Int32 nNext,
1529 bool& rbIsQuoted, bool& rbOverflowCell )
1531 sal_Int32 nLen = rLine.getLength();
1534 if ( nNext <= nStart )
1537 const sal_Unicode* pStr = rLine.getStr();
1539 sal_Int32 nSpace = nNext;
1540 while ( nSpace > nStart && pStr[nSpace-1] == ' ' )
1543 rbIsQuoted = (pStr[nStart] == '"' && pStr[nSpace-1] == '"');
1546 bool bFits = (nSpace - nStart - 3 <= nArbitraryCellLengthLimit);
1548 return rLine.copy(nStart+1, std::max< sal_Int32 >(0, nSpace-nStart-2));
1551 SAL_WARN( "sc", "lcl_GetFixed: line doesn't fit into data
");
1552 rbOverflowCell = true;
1553 return rLine.copy(nStart+1, nArbitraryCellLengthLimit);
1558 bool bFits = (nSpace - nStart <= nArbitraryCellLengthLimit);
1560 return rLine.copy(nStart, nSpace-nStart);
1564 rbOverflowCell = true;
1565 return rLine.copy(nStart, nArbitraryCellLengthLimit);
1570bool ScImportExport::ExtText2Doc( SvStream& rStrm )
1573 return Text2Doc( rStrm );
1575 sal_uInt64 const nOldPos = rStrm.Tell();
1576 sal_uInt64 const nRemaining = rStrm.remainingSize();
1577 std::unique_ptr<ScProgress> xProgress( new ScProgress( pDocSh,
1578 ScResId( STR_LOAD_DOC ), nRemaining, true ));
1579 rStrm.StartReadingUnicodeText( rStrm.GetStreamCharSet() );
1580 // tdf#82254 - check whether to include a byte-order-mark in the output
1581 if (nOldPos != rStrm.Tell())
1582 mbIncludeBOM = true;
1584 SCCOL nStartCol = aRange.aStart.Col();
1585 SCCOL nEndCol = aRange.aEnd.Col();
1586 SCROW nStartRow = aRange.aStart.Row();
1587 const SCTAB nTab = aRange.aStart.Tab();
1589 bool bFixed = pExtOptions->IsFixedLen();
1590 OUString aSeps = pExtOptions->GetFieldSeps(); // Need non-const for ReadCsvLine(),
1591 const sal_Unicode* pSeps = aSeps.getStr(); // but it will be const anyway (asserted below).
1592 bool bMerge = pExtOptions->IsMergeSeps();
1593 bool bRemoveSpace = pExtOptions->IsRemoveSpace();
1594 sal_uInt16 nInfoCount = pExtOptions->GetInfoCount();
1595 const sal_Int32* pColStart = pExtOptions->GetColStart();
1596 const sal_uInt8* pColFormat = pExtOptions->GetColFormat();
1597 tools::Long nSkipLines = pExtOptions->GetStartRow();
1599 LanguageType eDocLang = pExtOptions->GetLanguage();
1600 SvNumberFormatter aNumFormatter( comphelper::getProcessComponentContext(), eDocLang);
1601 bool bDetectNumFormat = pExtOptions->IsDetectSpecialNumber();
1602 bool bEvaluateFormulas = pExtOptions->IsEvaluateFormulas();
1603 bool bSkipEmptyCells = pExtOptions->IsSkipEmptyCells();
1605 // For date recognition
1606 ::utl::TransliterationWrapper aTransliteration(
1607 comphelper::getProcessComponentContext(), TransliterationFlags::IGNORE_CASE );
1608 aTransliteration.loadModuleIfNeeded( eDocLang );
1609 CalendarWrapper aCalendar( comphelper::getProcessComponentContext() );
1610 aCalendar.loadDefaultCalendar(
1611 LanguageTag::convertToLocale( eDocLang ) );
1612 std::unique_ptr< ::utl::TransliterationWrapper > pEnglishTransliteration;
1613 std::unique_ptr< CalendarWrapper > pEnglishCalendar;
1614 if ( eDocLang != LANGUAGE_ENGLISH_US )
1616 pEnglishTransliteration.reset(new ::utl::TransliterationWrapper (
1617 comphelper::getProcessComponentContext(), TransliterationFlags::IGNORE_CASE ));
1618 aTransliteration.loadModuleIfNeeded( LANGUAGE_ENGLISH_US );
1619 pEnglishCalendar.reset(new CalendarWrapper ( comphelper::getProcessComponentContext() ));
1620 pEnglishCalendar->loadDefaultCalendar(
1621 LanguageTag::convertToLocale( LANGUAGE_ENGLISH_US ) );
1627 SCROW nRow = nStartRow;
1628 sal_Unicode cDetectSep = 0xffff; // No separator detection here.
1630 while(--nSkipLines>0)
1632 aLine = ReadCsvLine(rStrm, !bFixed, aSeps, cStr, cDetectSep); // content is ignored
1637 // Determine range for Undo.
1638 // We don't need
this during
import of a file
to a
new sheet or document...
1639 bool bDetermineRange = bUndo;
1640 bool bColumnsAreDetermined =
false;
1645 bool bRangeIsDetermined = bDetermineRange;
1647 bool bQuotedAsText = pExtOptions && pExtOptions->IsQuotedAsText();
1649 sal_uInt64 nOriginalStreamPos =
rStrm.
Tell();
1652 SCROW nLastUpdateRowHeight = -1;
1660 if (
rStrm.
eof() && aLine.isEmpty() )
1663 assert(pSeps == aSeps.getStr());
1665 if ( nRow > rDoc.
MaxRow() )
1667 bOverflowRow =
true;
1671 if (!bDetermineRange)
1672 EmbeddedNullTreatment( aLine);
1674 sal_Int32 nLineLen = aLine.getLength();
1675 SCCOL nCol = nStartCol;
1676 bool bMultiLine =
false;
1679 if (bDetermineRange)
1681 if (!bColumnsAreDetermined)
1687 for (
i=0;
i < nInfoCount && nCol <= rDoc.
MaxCol()+1; ++
i)
1692 if (nCol > rDoc.
MaxCol())
1693 bOverflowCol =
true;
1697 bColumnsAreDetermined =
true;
1702 sal_Int32 nStartIdx = 0;
1704 for (
i=0;
i < nInfoCount && nCol <= rDoc.
MaxCol()+1; ++
i)
1706 sal_Int32 nNextIdx = nStartIdx;
1707 if (
i + 1 < nInfoCount)
1708 CountVisualWidth( aLine, nNextIdx, pColStart[
i+1] - pColStart[
i] );
1710 nNextIdx = nLineLen;
1714 if (nCol > rDoc.
MaxCol())
1715 bOverflowCol =
true;
1718 bool bIsQuoted =
false;
1719 aCell =
lcl_GetFixed( aLine, nStartIdx, nNextIdx, bIsQuoted, bOverflowCell );
1720 if (bIsQuoted && bQuotedAsText)
1724 aDocImport, !mbOverwriting, nCol, nRow, nTab, aCell, nFmt,
1725 &aNumFormatter, bDetectNumFormat, bEvaluateFormulas, bSkipEmptyCells,
1726 aTransliteration, aCalendar,
1727 pEnglishTransliteration.get(), pEnglishCalendar.get());
1731 nStartIdx = nNextIdx;
1737 SCCOL nSourceCol = 0;
1738 sal_uInt16 nInfoStart = 0;
1744 while (*
p && nCol <= rDoc.
MaxCol()+1)
1746 bool bIsQuoted =
false;
1748 cStr, pSeps, bMerge, bIsQuoted, bOverflowCell, bRemoveSpace );
1751 for (
i=nInfoStart;
i<nInfoCount;
i++ )
1753 if ( pColStart[
i] == nSourceCol + 1 )
1755 nFmt = pColFormat[
i];
1762 if (nCol > rDoc.
MaxCol())
1763 bOverflowCol =
true;
1764 else if (!bDetermineRange)
1766 if (bIsQuoted && bQuotedAsText)
1770 aDocImport, !mbOverwriting, nCol, nRow, nTab, aCell, nFmt,
1771 &aNumFormatter, bDetectNumFormat, bEvaluateFormulas, bSkipEmptyCells,
1772 aTransliteration, aCalendar,
1773 pEnglishTransliteration.get(), pEnglishCalendar.get());
1784 if (!bDetermineRange)
1786 if (bMultiLine && !bRangeIsDetermined && pDocSh)
1788 nFirstUpdateRowHeight = std::min( nFirstUpdateRowHeight, nRow );
1789 nLastUpdateRowHeight = std::max( nLastUpdateRowHeight, nRow );
1791 xProgress->SetStateOnPercent(
rStrm.
Tell() - nOldPos );
1796 if (nRow > nStartRow)
1798 if (nEndCol > nStartCol)
1799 nEndCol = ::std::min(
static_cast<SCCOL>(nEndCol - 1), rDoc.
MaxCol());
1801 if (bDetermineRange)
1803 aRange.aEnd.SetCol( nEndCol );
1804 aRange.aEnd.SetRow( nRow );
1806 if ( !mbApi && nStartCol != nEndCol &&
1807 !rDoc.
IsBlockEmpty( nStartCol + 1, nStartRow, nEndCol, nRow, nTab ) )
1825 bDetermineRange = !bDetermineRange;
1826 }
while (!bDetermineRange);
1828 if ( !mbOverwriting )
1829 aDocImport.finalize();
1833 if( nFirstUpdateRowHeight < nLastUpdateRowHeight && pDocSh )
1834 pDocSh->AdjustRowHeight( nFirstUpdateRowHeight, nLastUpdateRowHeight, nTab);
1836 if (bRangeIsDetermined)
1839 if (mbImportBroadcast && !mbOverwriting)
1842 pDocSh->PostDataChanged();
1857 if (sal_Int32
pos = rStr.indexOf(cNull);
pos >= 0)
1859 rStr = rStr.replaceAll(std::u16string_view(&cNull, 1),
u"",
pos);
1865 bool& rbOverflowCell,
bool bRemoveSpace )
1876 while (*pb == cBlank)
1895 while ( ptrim_f > p1 && ( *(ptrim_f - 1) == cBlank ) )
1899 rbOverflowCell =
true;
1913 while ( ptrim_i < ptrim_f && *ptrim_i == cBlank )
1915 while ( ptrim_f > ptrim_i && ( *(ptrim_f - 1) == cBlank ) )
1919 rbOverflowCell =
true;
1939bool hasLineBreaksOrSeps(
const OUString& rStr,
sal_Unicode cSep )
1942 for (sal_Int32 i = 0, n = rStr.getLength(); i < n; ++i, ++p)
1984 std::vector< sc::ColumnBlockPosition > blockPos( nEndCol - nStartCol + 1 );
1985 for(
SCCOL i = nStartCol;
i <= nEndCol; ++
i )
1987 for (nRow = nStartRow; nRow <= nEndRow; nRow++)
1991 for (nCol = nStartCol; nCol <= nEndCol; nCol++)
2005 if( aCellStr.indexOf(
cSep ) != -1 )
2012 const Color* pColor;
2015 bool bMultiLineText = ( aCellStr.indexOf(
'\n' ) != -1 );
2016 if( bMultiLineText )
2019 aCellStr = aCellStr.replaceAll(
"\n",
" " );
2036 const Color* pColor;
2045 const Color* pColor;
2048 bool bMultiLineText = ( aCellStr.indexOf(
'\n' ) != -1 );
2049 if( bMultiLineText )
2052 aCellStr = aCellStr.replaceAll(
"\n",
" " );
2066 if( nCol < nEndCol )
2072 if (nStartRow != nEndRow || nStartCol != nEndCol)
2087 bool bMyDoc =
false;
2088 SylkVersion eVersion = SylkVersion::OTHER;
2100 ::std::vector< sal_uInt32 > aFormats;
2109 OStringBuffer aByteLine;
2110 SCCOL nCol = nStartCol;
2111 SCROW nRow = nStartRow;
2112 SCCOL nRefCol = nCol;
2113 SCROW nRefRow = nRow;
2122 bool bInvalidCol =
false;
2123 bool bInvalidRow =
false;
2131 bool bInvalidRefCol =
false;
2132 bool bInvalidRefRow =
false;
2141 bInvalidCol =
false;
2142 bool bFail = o3tl::checked_add<SCCOL>(
o3tl::toInt32(std::u16string_view(
p)), nStartCol - 1, nCol);
2143 if (bFail || nCol < 0 ||
rDoc.
MaxCol() < nCol)
2145 SAL_WARN(
"sc.ui",
"ScImportExport::Sylk2Doc - ;X invalid nCol=" << nCol);
2146 nCol = std::clamp<SCCOL>(nCol, 0,
rDoc.
MaxCol());
2153 bInvalidRow =
false;
2157 SAL_WARN(
"sc.ui",
"ScImportExport::Sylk2Doc - ;Y invalid nRow=" << nRow);
2165 bInvalidRefCol =
false;
2166 bool bFail = o3tl::checked_add<SCCOL>(
o3tl::toInt32(std::u16string_view(
p)), nStartCol - 1, nRefCol);
2167 if (bFail || nRefCol < 0 ||
rDoc.
MaxCol() < nRefCol)
2169 SAL_WARN(
"sc.ui",
"ScImportExport::Sylk2Doc - ;C invalid nRefCol=" << nRefCol);
2170 nRefCol = std::clamp<SCCOL>(nRefCol, 0,
rDoc.
MaxCol());
2177 bInvalidRefRow =
false;
2181 SAL_WARN(
"sc.ui",
"ScImportExport::Sylk2Doc - ;R invalid nRefRow=" << nRefRow);
2190 ( nCol < nStartCol || nCol > nEndCol
2191 || nRow < nStartRow || nRow > nEndRow
2193 || bInvalidCol || bInvalidRow ) )
2197 if( nRow > nEndRow )
2199 if( nCol > nEndCol )
2213 while( *q && *q !=
';' )
2215 if ( (*q !=
';' || *(q+1) !=
'I') && !bInvalidCol && !bInvalidRow )
2225 double fVal = rtl_math_uStringToDouble(
p,
2226 aLine.getStr() + aLine.getLength(),
2227 cDecSep, cGrpSep,
nullptr,
nullptr );
2238 if ( nRefCol < nCol )
2240 if ( nRefRow < nRow )
2244 if( nRefRow > nEndRow )
2246 if( nRefCol > nEndCol )
2250 if( !bMyDoc || !bData )
2255 if (bInvalidCol || bInvalidRow || (
ch ==
'M' && (bInvalidRefCol || bInvalidRefRow)))
2265 std::unique_ptr<ScTokenArray> xCode(aComp.
CompileString(aText));
2272 nRefRow, aMark, OUString(), xCode.get() );
2283 while( *
p && *
p !=
';' )
2289 else if( cTag ==
'F' )
2293 sal_Int32 nFormat = -1;
2302 bInvalidCol =
false;
2303 bool bFail = o3tl::checked_add<SCCOL>(
o3tl::toInt32(std::u16string_view(
p)), nStartCol - 1, nCol);
2304 if (bFail || nCol < 0 ||
rDoc.
MaxCol() < nCol)
2306 SAL_WARN(
"sc.ui",
"ScImportExport::Sylk2Doc - ;X invalid nCol=" << nCol);
2307 nCol = std::clamp<SCCOL>(nCol, 0,
rDoc.
MaxCol());
2314 bInvalidRow =
false;
2318 SAL_WARN(
"sc.ui",
"ScImportExport::Sylk2Doc - ;Y invalid nRow=" << nRow);
2331 while( *
p && *
p !=
';' )
2333 OUString aNumber(p0,
p - p0);
2334 nFormat = aNumber.toInt32();
2338 while( *
p && *
p !=
';' )
2345 if( nRow > nEndRow )
2347 if( nCol > nEndCol )
2350 if ( 0 <= nFormat &&
o3tl::make_unsigned(nFormat) < aFormats.size() && !bInvalidCol && !bInvalidRow )
2352 sal_uInt32 nKey = aFormats[nFormat];
2357 else if( cTag ==
'P' )
2359 if ( bData && *
p ==
';' && *(
p+1) ==
'P' )
2361 OUString aCode(
p+2 );
2364 sal_Int32 nCheckPos;
2374 aCode = aCode.replaceAll(
";;",
";");
2376 aCode = aCode.replaceAll(
"\x1b",
"");
2385 aFormats.push_back( nKey );
2388 else if (cTag ==
'I' && *
p ==
'D' && aLine.getLength() > 4)
2390 aLine = aLine.copy(4);
2391 if (aLine ==
"CALCOOO32")
2392 eVersion = SylkVersion::OOO32;
2393 else if (aLine ==
"SCALC3")
2394 eVersion = SylkVersion::SCALC3;
2395 bMyDoc = (eVersion <= SylkVersion::OWN);
2397 else if( cTag ==
'E' )
2428 for (nRow = nStartRow; nRow <= nEndRow; nRow++)
2430 for (nCol = nStartCol; nCol <= nEndCol; nCol++)
2435 SCROW r = nRow - nStartRow + 1;
2436 SCCOL c = nCol - nStartCol + 1;
2452 aValStr = ::rtl::math::doubleToUString( nVal,
2453 rtl_math_StringFormat_Automatic,
2454 rtl_math_DecimalPlaces_Max,
'.',
true );
2457 + OUString::number( c )
2459 + OUString::number( r )
2469 aCellStr = aCellStr.replaceAll(
"\n", SYLK_LF);
2472 + OUString::number( c )
2474 + OUString::number( r )
2497 aCellStr.startsWith(
"{") &&
2498 aCellStr.endsWith(
"}") )
2500 aCellStr = aCellStr.copy(1, aCellStr.getLength()-2);
2502 if ( aCellStr[0] ==
'=' )
2503 aCellStr = aCellStr.copy(1);
2515 + OUString::number( nR )
2517 + OUString::number( nC )
2526 + OUString::number( aPos.
Row() - nStartRow + 1 )
2528 + OUString::number( aPos.
Col() - nStartCol + 1 );
2536 if ( !aCellStr.isEmpty() )
2580 pImportDoc->InitUndo(
rDoc, nTab, nTab );
2587 pImportDoc->GetCellArea( nTab, nEndCol, nEndRow );
2600 pImportDoc->CopyToDocument(
aRange, nFlags,
false,
rDoc);
2612 pImp->Read(
rStrm, rBaseURL );
2613 aRange = pImp->GetRange();
2620 pImp->WriteToDocument();
2631 pImp->Read(
rStrm, rBaseURL );
2632 aRange = pImp->GetRange();
2650 bool bSpecialNumber =
pExtOptions->IsDetectSpecialNumber();
2651 pImp->WriteToDocument(
false, 1.0, &aNumFormatter, bSpecialNumber);
2655 pImp->WriteToDocument();
2662#ifndef DISABLE_DYNLOADING
2679#ifndef DISABLE_DYNLOADING
2680 OUString sFilterLib(
SVLIBRARY(
"scfilt"));
2681 static ::osl::Module aModule;
2682 bool bLoaded = aModule.is();
2684 bLoaded = aModule.loadRelative(&
thisModule, sFilterLib);
2686 bLoaded = aModule.load(sFilterLib);
2689 oslGenericFunction fn = aModule.getFunctionSymbol(
"ScFilterCreate" );
2691 return reinterpret_cast<FilterFn>(fn)();
2730 OUString& rFieldSeparators,
sal_Unicode cFieldQuote,
sal_Unicode& rcDetectSep, sal_uInt32 nMaxSourceLines )
2738 } eRetryState = (bEmbeddedLineBreak && rcDetectSep == 0 ? RetryState::ALLOW : RetryState::FORBID);
2740 sal_uInt64 nStreamPos = (eRetryState == RetryState::ALLOW ? rStream.
Tell() : 0);
2742Label_RetryWithNewSep:
2744 if (eRetryState == RetryState::RETRY)
2746 eRetryState = RetryState::RETRIED;
2747 rStream.
Seek( nStreamPos);
2753 if (bEmbeddedLineBreak)
2755 sal_Int32 nFirstLineLength =
aStr.getLength();
2756 sal_uInt64 nFirstLineStreamPos = rStream.
Tell();
2757 sal_uInt32 nLine = 0;
2759 const sal_Unicode* pSeps = rFieldSeparators.getStr();
2761 QuoteType eQuoteState = FIELDEND_QUOTE;
2762 bool bFieldStart =
true;
2764 sal_Int32 nLastOffset = 0;
2765 sal_Int32 nQuotes = 0;
2782 if (*
p == cFieldQuote)
2787 bFieldStart =
false;
2788 eQuoteState = FIELDSTART_QUOTE;
2789 nFirstLineLength =
aStr.getLength();
2790 nFirstLineStreamPos = rStream.
Tell();
2795 else if (eQuoteState != FIELDEND_QUOTE)
2799 if (eRetryState == RetryState::ALLOW && rcDetectSep)
2801 eRetryState = RetryState::RETRY;
2802 rFieldSeparators += OUStringChar(rcDetectSep);
2803 pSeps = rFieldSeparators.getStr();
2804 goto Label_RetryWithNewSep;
2809 if (eQuoteState != DONTKNOW_QUOTE)
2813 else if (eQuoteState == FIELDEND_QUOTE)
2826 if (*
p == cFieldQuote && bFieldStart)
2829 eQuoteState = FIELDSTART_QUOTE;
2830 bFieldStart =
false;
2831 nFirstLineLength =
aStr.getLength();
2832 nFirstLineStreamPos = rStream.
Tell();
2834 else if (eQuoteState == FIELDEND_QUOTE)
2851 if ((nQuotes & 1) == 0)
2856 else if (eQuoteState == DONTKNOW_QUOTE)
2861 else if (++nLine >= nMaxSourceLines && nMaxSourceLines > 0)
2867 nLastOffset =
aStr.getLength();
2871 aStr +=
"\n" + aNext;
2878 aStr =
aStr.copy( 0, nFirstLineLength);
2879 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...
bool ExportData(const OUString &rMimeType, css::uno::Any &rValue)
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
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(const OUString &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
static bool isIVSSelector(sal_uInt32 nCode)
static bool isCJKIVSCharacter(sal_uInt32 nCode)
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 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...