24#include <com/sun/star/i18n/ScriptType.hpp>
31#include <document.hxx>
44#include <tokenarray.hxx>
47#include <oox/token/tokens.hxx>
52namespace ApiScriptType = ::com::sun::star::i18n::ScriptType;
61 "XclExpStringRec::XclExpStringRec - empty result not allowed in BIFF8+" );
73 sal_uInt16 nRecId, sal_uInt32 nRecSize,
const ScAddress& rScPos ) :
78 maBaseXclPos.
Set(
static_cast< sal_uInt16
>( rScPos.
Col() ),
static_cast< sal_uInt16
>( rScPos.
Row() ) );
83 sal_uInt16 nRecId, sal_uInt32 nRecSize,
const ScRange& rScRange ) :
89 static_cast< sal_uInt16
>( rScRange.
aStart.
Col() ),
90 static_cast< sal_uInt16
>( rScRange.
aStart.
Row() ),
91 static_cast< sal_uInt16
>( rScRange.
aEnd.
Col() ),
92 static_cast< sal_uInt16
>( rScRange.
aEnd.
Row() ) );
103 sal_uInt16 nXclCol =
static_cast< sal_uInt16
>( rScPos.
Col() );
104 sal_uInt32 nXclRow =
static_cast< sal_uInt32
>( rScPos.
Row() );
152 OSL_ENSURE(
maRecMap.find( rScPos ) ==
maRecMap.end(),
"XclExpArrayBuffer::CreateArray - array exists already" );
162 if (rScTokArr.
GetLen() != 1)
173 XclExpArrayMap::const_iterator it =
maRecMap.find(aAbsPos);
221 sal_uInt16 nLen = rArray.
GetLen();
222 for (sal_uInt16
i = 0;
i < nLen; ++
i)
225 switch (
p->GetType())
276 TokensType::iterator aIt =
maRecMap.find(pShrdScTokArr);
287 OSL_ENSURE( aIt->second,
"XclExpShrfmlaBuffer::CreateOrExtendShrfmla - missing record" );
289 xRec->ExtendRange( rScPos );
300 mnLastAppXclCol( static_cast< sal_uInt16 >( rScPos.
Col() ) ),
301 mnColInpXclCol( static_cast< sal_uInt16 >( rRefs.maColFirstScPos.
Col() ) ),
302 mnColInpXclRow( static_cast< sal_uInt16 >( rRefs.maColFirstScPos.
Row() ) ),
303 mnRowInpXclCol( static_cast< sal_uInt16 >( rRefs.maRowFirstScPos.
Col() ) ),
304 mnRowInpXclRow( static_cast< sal_uInt16 >( rRefs.maRowFirstScPos.
Row() ) ),
312 sal_uInt16 nXclCol =
static_cast< sal_uInt16
>( rScPos.
Col() );
313 sal_uInt16 nXclRow =
static_cast< sal_uInt16
>( rScPos.
Row() );
365 OSL_ENSURE(
IsAppendable( nXclCol, nXclRow ),
"XclExpTableop::TryExtend - wrong cell address" );
470 if( xTempRec->
TryExtend( rScPos, aRefs ) )
542 sal_uInt16 nRecId, std::size_t nContSize,
const XclAddress& rXclPos ) :
571 sal_uInt16 nRecId, std::size_t nContSize,
const XclAddress& rXclPos, sal_uInt32 nXFId ) :
574 mnContSize( nContSize )
579 sal_uInt16 nRecId, std::size_t nContSize,
const XclAddress& rXclPos,
580 const ScPatternAttr* pPattern, sal_Int16 nScript, sal_uInt32 nForcedXFId ) :
582 maXFId( nForcedXFId ),
583 mnContSize( nContSize )
624 const ScPatternAttr* pPattern, sal_uInt32 nForcedXFId,
double fValue ) :
633 return OString::number(
rStrm.GetRoot().GetXFBuffer()
634 .GetXmlCellIndex( nXFIndex ) );
640 sal_uInt16 nXFIndex =
rStrm.GetRoot().GetXFBuffer().GetXFIndex( nXFId );
647 rWorksheet->startElement( XML_c,
653 rWorksheet->startElement(XML_v);
655 rWorksheet->endElement( XML_v );
656 rWorksheet->endElement( XML_c );
666 const ScPatternAttr* pPattern, sal_uInt32 nForcedXFId,
bool bValue ) :
676 rWorksheet->startElement( XML_c,
682 rWorksheet->startElement( XML_v );
683 rWorksheet->write(
mbValue ?
"1" :
"0" );
684 rWorksheet->endElement( XML_v );
685 rWorksheet->endElement( XML_c );
695 const ScPatternAttr* pPattern, sal_uInt32 nForcedXFId,
const OUString& rStr ) :
701 Init( rRoot, pPattern, xText );
720 Init( rRoot, pPattern, xText );
731 OSL_ENSURE( xText && xText->Len(),
"XclExpLabelCell::XclExpLabelCell - empty string passed" );
739 if( rFormats.size() == 1 )
740 nXclFont =
mxText->RemoveLeadingFont();
742 nXclFont =
mxText->GetLeadingFont();
747 OSL_ENSURE( nXclFont !=
EXC_FONT_NOTFOUND,
"XclExpLabelCell::Init - leading font not found" );
748 bool bForceLineBreak =
mxText->IsWrapped();
766 OSL_ENSURE(
mxText->GetFormatsCount() <=
EXC_LABEL_MAXLEN,
"XclExpLabelCell::WriteContents - too many formats" );
785 rWorksheet->startElement( XML_c,
791 rWorksheet->startElement( XML_v );
792 rWorksheet->write(
static_cast<sal_Int32
>(
mnSstIndex) );
793 rWorksheet->endElement( XML_v );
794 rWorksheet->endElement( XML_c );
799 switch(
rStrm.GetRoot().GetBiff() )
805 rStrm << static_cast< sal_uInt8 >(
mxText->GetFormatsCount() );
834 sal_uInt32 nScNumFmt = pPattern ?
846 (nFormatType != SvNumFormatType::LOGICAL) &&
847 (nFormatType != SvNumFormatType::TEXT) )
848 nAltScNumFmt = nScNumFmt;
851 else if( (nFormatType == SvNumFormatType::LOGICAL) &&
852 (rFormatter.
GetType( nScNumFmt ) == SvNumFormatType::LOGICAL) )
856 sal_Int16 nScript = ApiScriptType::LATIN;
857 bool bForceLineBreak =
false;
858 if( nFormatType == SvNumFormatType::TEXT )
885 OSL_ENSURE( nMatWidth && nMatHeight,
"XclExpFormulaCell::XclExpFormulaCell - empty matrix" );
888 rMatEnd.
IncCol(
static_cast< SCCOL >( nMatWidth - 1 ) );
889 rMatEnd.
IncRow(
static_cast< SCROW >( nMatHeight - 1 ) );
901 OSL_ENSURE(
mxAddRec,
"XclExpFormulaCell::XclExpFormulaCell - no matrix found" );
923 OSL_ENSURE(
mxTokArr,
"XclExpFormulaCell::Save - missing token array" );
940 const char*
sType =
nullptr;
944 rWorksheet->startElement( XML_c,
951 bool bWriteFormula =
true;
952 bool bTagStarted =
false;
961 bWriteFormula =
false;
969 OSL_ENSURE( nMatWidth && nMatHeight,
"XclExpFormulaCell::XclExpFormulaCell - empty matrix" );
972 rMatEnd.
IncCol(
static_cast< SCCOL >( nMatWidth - 1 ) );
973 rMatEnd.
IncRow(
static_cast< SCROW >( nMatHeight - 1 ) );
975 rStrm.GetRoot().GetAddressConverter().ValidateRange( aMatScRange,
true );
977 OStringBuffer sFmlaCellRange;
978 if (
rStrm.GetRoot().GetDoc().ValidRange(aMatScRange))
982 rStrm.GetRoot().GetStringBuf(), aMatScRange.
aStart )
983 + OString::Concat(
":"));
985 rStrm.GetRoot().GetStringBuf(), aMatScRange.
aEnd ));
991 rWorksheet->startElement( XML_f,
994 XML_t,
mxAddRec ?
"array" :
nullptr,
995 XML_ref, !sFmlaCellRange.isEmpty()? sFmlaCellRange.getStr() :
nullptr
1016 rWorksheet->startElement( XML_f,
1023 rWorksheet->endElement( XML_f );
1026 if( strcmp(
sType,
"inlineStr" ) == 0 )
1028 rWorksheet->startElement(XML_is);
1029 rWorksheet->startElement(XML_t);
1030 rWorksheet->writeEscaped( sValue );
1031 rWorksheet->endElement( XML_t );
1032 rWorksheet->endElement( XML_is );
1036 rWorksheet->startElement(XML_v);
1037 rWorksheet->writeEscaped( sValue );
1038 rWorksheet->endElement( XML_v );
1040 rWorksheet->endElement( XML_c );
1046 if( nScErrCode != FormulaError::NONE )
1051 << sal_uInt16( 0xFFFF );
1058 case SvNumFormatType::NUMBER:
1065 case SvNumFormatType::TEXT:
1068 if( !aResult.isEmpty() || (
rStrm.GetRoot().GetBiff() <=
EXC_BIFF5) )
1075 rStrm <<
sal_uInt8( 0 ) << sal_uInt32( 0 ) << sal_uInt16( 0xFFFF );
1079 case SvNumFormatType::LOGICAL:
1083 << nXclValue <<
sal_uInt8( 0 ) << sal_uInt16( 0 )
1084 << sal_uInt16( 0xFFFF );
1103 sal_uInt16 nRecId, sal_uInt16 nMulRecId, std::size_t nContSize,
const XclAddress& rXclPos ) :
1105 mnMulRecId( nMulRecId ),
1106 mnContSize( nContSize )
1128 rXFId.ConvertXFIndex( rRoot );
1135 XclExpMultiXFIdDeq::const_iterator aEnd =
maXFIds.end();
1136 XclExpMultiXFIdDeq::const_iterator aRangeBeg =
maXFIds.begin();
1137 XclExpMultiXFIdDeq::const_iterator aRangeEnd = aRangeBeg;
1139 sal_uInt16 nEndXclCol = nBegXclCol;
1141 while( aRangeEnd != aEnd )
1144 aRangeBeg = aRangeEnd;
1145 nBegXclCol = nEndXclCol;
1146 while( (aRangeBeg != aEnd) && (aRangeBeg->mnXFIndex ==
EXC_XF_NOTFOUND) )
1148 nBegXclCol = nBegXclCol + aRangeBeg->mnCount;
1152 aRangeEnd = aRangeBeg;
1153 nEndXclCol = nBegXclCol;
1154 while( (aRangeEnd != aEnd) && (aRangeEnd->mnXFIndex !=
EXC_XF_NOTFOUND) )
1156 nEndXclCol = nEndXclCol + aRangeEnd->mnCount;
1161 if( aRangeBeg != aRangeEnd )
1163 sal_uInt16
nCount = nEndXclCol - nBegXclCol;
1164 bool bIsMulti =
nCount > 1;
1166 if( bIsMulti ) nTotalSize += 2;
1169 rStrm << static_cast<sal_uInt16> (
GetXclRow()) << nBegXclCol;
1171 sal_uInt16 nRelCol = nBegXclCol -
GetXclCol();
1172 for( XclExpMultiXFIdDeq::const_iterator aIt = aRangeBeg; aIt != aRangeEnd; ++aIt )
1174 for( sal_uInt16 nIdx = 0; nIdx < aIt->mnCount; ++nIdx )
1176 rStrm << aIt->mnXFIndex;
1182 rStrm << static_cast< sal_uInt16 >( nEndXclCol - 1 );
1190 XclExpMultiXFIdDeq::const_iterator aEnd =
maXFIds.end();
1191 XclExpMultiXFIdDeq::const_iterator aRangeBeg =
maXFIds.begin();
1192 XclExpMultiXFIdDeq::const_iterator aRangeEnd = aRangeBeg;
1194 sal_uInt16 nEndXclCol = nBegXclCol;
1196 while( aRangeEnd != aEnd )
1199 aRangeBeg = aRangeEnd;
1200 nBegXclCol = nEndXclCol;
1201 while( (aRangeBeg != aEnd) && (aRangeBeg->mnXFIndex ==
EXC_XF_NOTFOUND) )
1203 nBegXclCol = nBegXclCol + aRangeBeg->mnCount;
1207 aRangeEnd = aRangeBeg;
1208 nEndXclCol = nBegXclCol;
1209 while( (aRangeEnd != aEnd) && (aRangeEnd->mnXFIndex !=
EXC_XF_NOTFOUND) )
1211 nEndXclCol = nEndXclCol + aRangeEnd->mnCount;
1216 if( aRangeBeg != aRangeEnd )
1218 sal_uInt16 nRelColIdx = nBegXclCol -
GetXclCol();
1219 sal_Int32 nRelCol = 0;
1220 for( XclExpMultiXFIdDeq::const_iterator aIt = aRangeBeg; aIt != aRangeEnd; ++aIt )
1222 for( sal_uInt16 nIdx = 0; nIdx < aIt->mnCount; ++nIdx )
1239 return std::accumulate(
maXFIds.begin(),
maXFIds.end(), sal_uInt16(0),
1252 const ScPatternAttr* pPattern, sal_uInt16 nScript, sal_uInt32 nForcedXFId, sal_uInt16 nCount )
1271 OSL_ENSURE(
GetLastXclCol() < rXFIndexes.size(),
"XclExpMultiCellBase::GetXFIndexes - vector too small" );
1272 ScfUInt16Vec::iterator aDestIt = rXFIndexes.begin() +
GetXclCol();
1273 for(
const auto& rXFId :
maXFIds )
1275 ::std::fill( aDestIt, aDestIt + rXFId.mnCount, rXFId.mnXFIndex );
1276 aDestIt += rXFId.mnCount;
1284 OSL_ENSURE( nLastXclCol < rXFIndexes.size(),
"XclExpMultiCellBase::RemoveUnusedXFIndexes - XF index vector too small" );
1289 size_t nEnd = std::min<size_t>(nLastXclCol + 1, nStartAllNotFound);
1313 sal_uInt16 nMaxNonDefCol =
col;
1314 for(
const auto& rXFId :
maXFIds )
1316 col += rXFId.mnCount;
1318 nMaxNonDefCol =
col;
1320 return nMaxNonDefCol;
1326 OSL_ENSURE( rXFId.
mnCount > 0,
"XclExpBlankCell::XclExpBlankCell - invalid count" );
1335 OSL_ENSURE( rXclPos.
mnCol <= nLastXclCol,
"XclExpBlankCell::XclExpBlankCell - invalid column range" );
1363 rWorksheet->singleElement( XML_c,
1370 const ScPatternAttr* pPattern, sal_uInt32 nForcedXFId, sal_Int32 nRkValue ) :
1374 AppendXFId( rRoot, pPattern, ApiScriptType::LATIN, nForcedXFId );
1392 rWorksheet->startElement( XML_c,
1398 rWorksheet->startElement( XML_v );
1400 rWorksheet->endElement( XML_v );
1401 rWorksheet->endElement( XML_c );
1406 OSL_ENSURE( nRelCol <
maRkValues.size(),
"XclExpRkCell::WriteContents - overflow error" );
1413 mpScOLArray( nullptr ),
1416 mbCurrCollapse( false )
1419 mpScOLArray = &(bRows ? pOutlineTable->GetRowArray() : pOutlineTable->GetColArray());
1433 size_t nNewOpenScLevel = 0;
1437 nNewLevel =
static_cast< sal_uInt8 >( nNewOpenScLevel + 1 );
1444 for(
size_t nScLevel = 0; nScLevel <= nNewOpenScLevel; ++nScLevel )
1452 maLevelInfos[ nScLevel ].mnScEndPos = pEntry->GetEnd();
1453 maLevelInfos[ nScLevel ].mbHidden = pEntry->IsHidden();
1463 for( sal_uInt16 nScLevel = nNewOpenScLevel + 1; !
mbCurrCollapse && (nScLevel <= nOldOpenScLevel); ++nScLevel )
1508 mnFirstUsedXclRow( 0 ),
1509 mnFirstFreeXclRow( 0 ),
1510 mnFirstUsedXclCol( 0 ),
1511 mnFirstFreeXclCol( 0 )
1525 sal_uInt16 nFirstUsedXclCol, sal_uInt32 nFirstUsedXclRow,
1526 sal_uInt16 nFirstFreeXclCol, sal_uInt32 nFirstFreeXclRow )
1547 rStrm.GetCurrentStream()->singleElement( XML_dimension,
1563 rStrm << sal_uInt16( 0 );
1568double lclGetCChCorrection(
const XclExpRoot& rRoot)
1592 double defaultColumnWidth = 256.0 *
GetValue();
1595 return std::abs(defaultColumnWidth - nXclColWidth) < 256.0 * 1.0 / 16.0;
1600 double fCCh = nXclColWidth / 256.0;
1603 const double fCorrection = lclGetCChCorrection(
GetRoot());
1604 const double fCorrectedCCh = fCCh - fCorrection;
1606 double fCChRound = std::round(fCorrectedCCh);
1612 if (fCChRound < 0.0 || fCChRound > 255.0 || std::abs(fCChRound - fCorrectedCCh) > 1.0 / 512)
1614 fCCh = fCChRound + fCorrection;
1625 static_cast<sal_uInt16
>(std::round(fCorrectedCCh)));
1633 mbCustomWidth( false ),
1637 mnOutlineLevel( 0 ),
1638 mnFirstXclCol( static_cast< sal_uInt16 >( nScCol ) ),
1639 mnLastXclCol( static_cast< sal_uInt16 >( nScCol ) )
1649 sal_uInt16 nScWidth = rDoc.
GetColWidth( nScCol, nScTab,
false );
1657 rOutlineBfr.
Update( nScCol );
1695 if( nLastXclCol ==
static_cast< sal_uInt16
>(
rStrm.GetRoot().GetMaxPos().Col() ) )
1718 const double nTruncatedExcelColumnWidth = std::trunc( nExcelColumnWidth * 100.0 + 0.5 ) / 100.0;
1719 rStrm.GetCurrentStream()->singleElement( XML_col,
1729 XML_width, OString::number(nTruncatedExcelColumnWidth) );
1734 maDefcolwidth( rRoot ),
1735 maOutlineBfr( rRoot ),
1736 mnHighestOutlineLevel( 0 )
1743 for( sal_uInt16 nScCol = 0, nLastScCol =
GetMaxPos().
Col(); nScCol <= nLastScCol; ++nScCol )
1777 std::unordered_map< sal_uInt16, sal_uInt16 > aWidthMap;
1778 sal_uInt16 nMaxColCount = 0;
1779 sal_uInt16 nMaxUsedWidth = 0;
1786 rXFIndexes.resize( rXFIndexes.size() + nColCount, xRec->
GetXFIndex() );
1790 sal_uInt16& rnMapCount = aWidthMap[ nWidth ];
1791 rnMapCount = rnMapCount + nColCount;
1792 if( rnMapCount > nMaxColCount )
1794 nMaxColCount = rnMapCount;
1795 nMaxUsedWidth = nWidth;
1824 rWorksheet->startElement(XML_cols);
1826 rWorksheet->endElement( XML_cols );
1869 mnXclRow( nXclRow ),
1873 mnOutlineLevel( 0 ),
1875 mnCurrentRow( nXclRow ),
1876 mbAlwaysEmpty( bAlwaysEmpty ),
1891 rOutlineBfr.
Update( nScRow );
1904 size_t searchStart = std::numeric_limits<size_t>::max())
1906 for(
size_t i = std::min(rIndexes.size(), searchStart);
i >= 1; --
i )
1908 if( rIndexes[
i - 1 ] !=
value )
1916 OSL_ENSURE( !
mbAlwaysEmpty,
"XclExpRow::AppendCell - row is marked to be always empty" );
1929 OSL_ENSURE( rColXFIndexes.size() == nColCount,
"XclExpRow::Finalize - wrong column XF index count" );
1933 assert( aXFIndexes.size() == nColCount );
1963 if( nFirstFreeXclCol < nNextUsedXclCol )
1965 aXFId.
mnCount = nNextUsedXclCol - nFirstFreeXclCol;
1970 for(
size_t i = nFirstFreeXclCol;
i < nNextUsedXclCol; ++
i )
1982 size_t nStartSearchAllDefault = aXFIndexes.size();
1986 assert(pLastBlank->
GetLastXclCol() == aXFIndexes.size() - 1);
1993 const size_t nHalfIndexes = aXFIndexes.size() / 2;
1994 if( nStartAllDefault > nHalfIndexes )
1997 nRowXFIndex = aXFIndexes.back();
1999 if( nStartLastSame > nHalfIndexes )
2001 std::unordered_map< sal_uInt16, size_t > aIndexMap;
2002 size_t nMaxXFCount = 0;
2003 for(
const auto& rXFIndex : aXFIndexes )
2007 size_t& rnCount = aIndexMap[ rXFIndex ];
2009 if( rnCount > nMaxXFCount )
2011 nRowXFIndex = rXFIndex;
2012 nMaxXFCount = rnCount;
2013 if (nMaxXFCount > nHalfIndexes)
2029 if( !bUseColDefXFs )
2032 size_t nXFCountWithRowDefXF = 0;
2033 size_t nXFCountWithoutRowDefXF = 0;
2034 ScfUInt16Vec::const_iterator aColIt = rColXFIndexes.begin();
2035 for(
const auto& rXFIndex : aXFIndexes )
2037 sal_uInt16 nXFIndex = rXFIndex;
2040 if( nXFIndex != nRowXFIndex )
2041 ++nXFCountWithRowDefXF;
2042 if( nXFIndex != *aColIt )
2043 ++nXFCountWithoutRowDefXF;
2049 bUseColDefXFs = nXFCountWithoutRowDefXF <= nXFCountWithRowDefXF;
2054 size_t maxStartAllNotFound;
2057 size_t maxStartAllDefault = std::max( nStartAllDefault, nStartColAllDefault );
2060 for(
size_t i = 0;
i < maxStartAllDefault; ++
i )
2062 if( aXFIndexes[
i ] == rColXFIndexes[
i ] )
2066 for(
size_t i = maxStartAllDefault;
i < aXFIndexes.size(); ++
i )
2068 maxStartAllNotFound = maxStartAllDefault;
2076 for(
auto& rXFIndex : aXFIndexes )
2077 if( rXFIndex == nRowXFIndex )
2079 maxStartAllNotFound = aXFIndexes.size();
2095 for(
size_t i = 0;
i < nStartAllNotFound; ++
i )
2115 return !
::get_flag(
mnFlags,
static_cast< sal_uInt16
>( ~nFlagsAlwaysMarkedAsDefault ) ) &&
2145 OSL_ENSURE( xCell,
"XclExpRow::InsertCell - missing cell" );
2150 if( bIsMergedBase && xCell->IsMultiLineText() )
2155 if( xPrevCell && xPrevCell->
TryMerge( *xCell ) )
2163 if( xNextCell && xCell->TryMerge( *xNextCell ) )
2187 rWorksheet->startElement( XML_row,
2191 XML_customFormat, ToPsz( haveFormat ),
2192 XML_ht, OString::number(
static_cast<double>(
mnHeight) / 20.0),
2203 rWorksheet->endElement( XML_row );
2209 maOutlineBfr( rRoot ),
2210 maDimensions( rRoot ),
2211 mnHighestOutlineLevel( 0 )
2217 OSL_ENSURE( xCell,
"XclExpRowBuffer::AppendCell - missing cell" );
2223 if( nFirstFreeScRow > 0 )
2233 size_t mnStartColAllDefault;
2234 std::vector< XclExpRow * > maRows;
2236 RowFinalizeTask(
const std::shared_ptr<comphelper::ThreadTaskTag> & pTag,
2238 size_t nStartColAllDefault,
2241 mbProgress( bProgress ),
2242 mrColXFIndexes( rColXFIndexes ),
2243 mnStartColAllDefault( nStartColAllDefault )
2246 void push_back(
XclExpRow *pRow ) { maRows.push_back( pRow ); }
2247 virtual void doWork()
override
2251 p->Finalize( mrColXFIndexes, aXFIndexes, mnStartColAllDefault, mbProgress );
2259 size_t nStartColAllDefault )
2268 const size_t nRows =
maRowMap.size();
2271 const size_t nThreads = 1;
2277 rEntry.second->Finalize( rColXFIndexes, aXFIndexes, nStartColAllDefault,
true );
2283 std::vector<std::unique_ptr<RowFinalizeTask>> aTasks(nThreads);
2284 for (
size_t i = 0;
i < nThreads;
i++ )
2285 aTasks[
i ].reset(
new RowFinalizeTask( pTag, rColXFIndexes, nStartColAllDefault,
i == 0 ) );
2288 for (
const auto& rEntry :
maRowMap )
2290 aTasks[ nIdx % nThreads ]->push_back( rEntry.second.get() );
2294 for (
size_t i = 1;
i < nThreads;
i++ )
2295 rPool.
pushTask( std::move(aTasks[
i ]) );
2298 aTasks[0]->doWork();
2305 std::map< XclExpDefaultRowData, size_t > aDefRowMap;
2308 size_t nMaxDefCount = 0;
2312 std::vector< XclExpRow* > aRepeated;
2313 for (
const auto& rEntry :
maRowMap)
2315 const RowRef& rRow = rEntry.second;
2316 if ( rRow->IsDefaultable() )
2319 size_t& rnDefCount = aDefRowMap[ aDefData ];
2321 if( rnDefCount > nMaxDefCount )
2323 nMaxDefCount = rnDefCount;
2324 aMaxDefData = aDefData;
2334 sal_uInt32 nRpt = rRow->GetXclRow() - pPrev->
GetXclRow();
2336 aRepeated.push_back( pPrev );
2339 size_t& rnDefCount = aDefRowMap[ aDefData ];
2341 if( rnDefCount > nMaxDefCount )
2343 nMaxDefCount = rnDefCount;
2344 aMaxDefData = aDefData;
2351 rDefRowData = aMaxDefData;
2354 for (
auto& rpRow : aRepeated)
2356 if ( rpRow->GetXclRowRpt() > 1
2357 && rpRow->GetHeight() == rDefRowData.
mnHeight
2358 && rpRow->IsHidden() == rDefRowData.
IsHidden() )
2360 rpRow->SetXclRowRpt( 1 );
2367 sal_uInt16 nFirstFreeXclCol = 0;
2369 sal_uInt32 nFirstFreeXclRow = 0;
2371 for (
const auto& rEntry :
maRowMap)
2373 const RowRef& rRow = rEntry.second;
2375 rRow->DisableIfDefault( aMaxDefData );
2378 if( !rRow->IsEmpty() )
2380 nFirstUsedXclCol = ::std::min( nFirstUsedXclCol, rRow->GetFirstUsedXclCol() );
2381 nFirstFreeXclCol = ::std::max( nFirstFreeXclCol, rRow->GetFirstFreeXclCol() );
2385 if( rRow->IsEnabled() )
2387 sal_uInt32 nXclRow = rRow->GetXclRow();
2388 nFirstUsedXclRow = ::std::min< sal_uInt32 >( nFirstUsedXclRow, nXclRow );
2389 nFirstFreeXclRow = ::std::max< sal_uInt32 >( nFirstFreeXclRow, nXclRow + 1 );
2394 nFirstUsedXclCol = ::std::min( nFirstUsedXclCol, nFirstFreeXclCol );
2395 nFirstUsedXclRow = ::std::min( nFirstUsedXclRow, nFirstFreeXclRow );
2399 nFirstUsedXclCol, nFirstUsedXclRow, nFirstFreeXclCol, nFirstFreeXclRow );
2410 RowMap::iterator itrBlkStart =
maRowMap.begin(), itrBlkEnd =
maRowMap.begin();
2411 sal_uInt16 nStartXclRow = (nSize == 0) ? 0 : itr->second->GetXclRow();
2413 for (; itr != itrEnd; ++itr)
2416 itrBlkEnd = std::find_if_not(itrBlkEnd, itrEnd,
2417 [&nStartXclRow](
const RowMap::value_type& rRow) {
return rRow.second->GetXclRow() - nStartXclRow <
EXC_ROW_ROWBLOCKSIZE; });
2420 std::for_each(itrBlkStart, itrBlkEnd, [&
rStrm](
const RowMap::value_type& rRow) { rRow.second->Save(
rStrm ); });
2423 std::for_each(itrBlkStart, itrBlkEnd, [&
rStrm](
const RowMap::value_type& rRow) { rRow.second->WriteCellList(
rStrm ); });
2425 itrBlkStart = (itrBlkEnd == itrEnd) ? itrBlkEnd : itrBlkEnd++;
2432 if (std::none_of(
maRowMap.begin(),
maRowMap.end(), [](
const RowMap::value_type& rRow) { return rRow.second->IsEnabled(); }))
2434 rStrm.GetCurrentStream()->singleElement(XML_sheetData);
2439 rWorksheet->startElement(XML_sheetData);
2440 for (
const auto& rEntry :
maRowMap)
2441 rEntry.second->SaveXml(
rStrm);
2442 rWorksheet->endElement( XML_sheetData );
2449 RowMap::iterator itr;
2455 if(
last->first == nXclRow )
2456 return *
last->second;
2457 if( nXclRow >
last->first )
2460 itr =
maRowMap.lower_bound( nXclRow );
2462 const bool bFound = itr !=
maRowMap.end();
2465 const bool bFoundHigher = bFound && itr->first != nXclRow;
2466 if( bFound && !bFoundHigher )
2467 return *itr->second;
2474 pPrevEntry = itr->second;
2478 nFrom = itr->first + 1;
2484 bool bHidden =
false;
2485 SCROW lastSameHiddenRow = -1;
2486 sal_uInt16 nHeight = 0;
2487 SCROW lastSameHeightRow = -1;
2489 while( nFrom <= nXclRow )
2493 if(
static_cast<SCROW>(nFrom) > lastSameHiddenRow )
2494 bHidden = rDoc.
RowHidden(nFrom, nScTab,
nullptr, &lastSameHiddenRow);
2498 if(
static_cast<SCROW>(nFrom) > lastSameHeightRow )
2499 nHeight = rDoc.
GetRowHeight(nFrom, nScTab,
nullptr, &lastSameHeightRow,
false);
2500 if ( !pPrevEntry || ( nFrom == nXclRow ) ||
2503 ( bRowAlwaysEmpty && !pPrevEntry->IsEmpty() ) ||
2504 ( bHidden != pPrevEntry->IsHidden() ) ||
2505 ( nHeight != pPrevEntry->GetHeight() ) )
2518 return *itr->second;
2525 maColInfoBfr( rRoot ),
2527 maArrayBfr( rRoot ),
2528 maShrfmlaBfr( rRoot ),
2529 maTableopBfr( rRoot ),
2547 SCCOL nLastUsedScCol;
2548 SCROW nLastUsedScRow;
2549 rDoc.
GetTableArea( nScTab, nLastUsedScCol, nLastUsedScRow );
2551 if(nLastUsedScCol > nMaxScCol)
2552 nLastUsedScCol = nMaxScCol;
2555 nLastUsedScRow += 1000;
2557 if(nLastUsedScRow > nMaxScRow)
2558 nLastUsedScRow = nMaxScRow;
2560 ScRange aUsedRange( 0, 0, nScTab, nLastUsedScCol, nLastUsedScRow, nScTab );
2562 nLastUsedScRow = aUsedRange.
aEnd.
Row();
2568 SCROW nFirstUngroupedScRow = 0;
2573 rRowArray.
GetRange( nScStartPos, nScEndPos );
2575 nFirstUngroupedScRow =
static_cast< SCROW >( nScEndPos + 2 );
2584 if( (31871 <= nLastUsedScRow) && (nLastUsedScRow <= 32127) && (nFirstUnflaggedScRow < nLastUsedScRow) && (nFirstUngroupedScRow <= nLastUsedScRow) )
2585 nMaxScRow = nLastUsedScRow;
2589 SCCOL nLastIterScCol = nMaxScCol;
2590 SCROW nLastIterScRow = ulimit_cast< SCROW >( nLastUsedScRow, nMaxScRow );
2601 ScAddress aScPos( nScCol, nScRow, nScTab );
2603 XclAddress aXclPos(
static_cast< sal_uInt16
>( nScCol ),
static_cast< sal_uInt32
>( nScRow ) );
2604 sal_uInt16 nLastXclCol =
static_cast< sal_uInt16
>( nLastScCol );
2613 bool bIsMergedBase =
false;
2619 bIsMergedBase = rMergeItem.
IsMerged();
2627 OUString aAddNoteText;
2638 if (!aUrl.isEmpty())
2647 if( pPattern && ((fValue == 0.0) || (fValue == 1.0)) )
2650 if( rFormatter.
GetType( nScNumFmt ) == SvNumFormatType::LOGICAL )
2652 GetRoot(), aXclPos, pPattern, nMergeBaseXFId, fValue != 0.0 );
2659 GetRoot(), aXclPos, pPattern, nMergeBaseXFId, nRkValue );
2664 GetRoot(), aXclPos, pPattern, nMergeBaseXFId, fValue );
2695 if (!aUrl.isEmpty())
2704 GetRoot(), aXclPos, pPattern, nMergeBaseXFId,
2710 OSL_FAIL(
"XclExpCellTable::XclExpCellTable - unknown cell type" );
2715 GetRoot(), aXclPos, nLastXclCol, pPattern, nMergeBaseXFId );
2720 assert(xCell &&
"can only reach here with xCell set");
2725 if ( !aAddNoteText.isEmpty() )
2740 sal_uInt32 nXFId = xCell->GetFirstXFId();
2742 OSL_ENSURE( (aScRange.
aStart.
Col() == aScRange.
aEnd.
Col()) || (nScCol == nLastScCol),
2743 "XclExpCellTable::XclExpCellTable - invalid repeated blank merged cell" );
2758 mxDval->InsertCellRange( aScRange, nScHandle );
2806 default: OSL_FAIL(
"XclExpCellTable::CreateRecord - unknown record id" );
2824 rWorksheet->startElement( XML_sheetFormatPr,
2830 XML_defaultRowHeight, OString::number(
static_cast<double> (rDefData.
mnHeight) / 20.0),
2831 XML_zeroHeight, ToPsz( rDefData.
IsHidden() ),
2834 rWorksheet->endElement( XML_sheetFormatPr );
constexpr auto convertTwipToMm100(N n)
void IncCol(SCCOL nDelta=1)
void IncRow(SCROW nDelta=1)
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
SC_DLLPUBLIC SCROW GetLastFlaggedRow(SCTAB nTab) const
SC_DLLPUBLIC const ScPatternAttr * GetMostUsedPattern(SCCOL nCol, SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const
SC_DLLPUBLIC bool RowHidden(SCROW nRow, SCTAB nTab, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
SC_DLLPUBLIC CRFlags GetRowFlags(SCROW nRow, SCTAB nTab) const
SC_DLLPUBLIC bool GetTableArea(SCTAB nTab, SCCOL &rEndCol, SCROW &rEndRow, bool bCalcHiddens=false) const
SC_DLLPUBLIC ScOutlineTable * GetOutlineTable(SCTAB nTab, bool bCreate=false)
SC_DLLPUBLIC bool ColHidden(SCCOL nCol, SCTAB nTab, SCCOL *pFirstCol=nullptr, SCCOL *pLastCol=nullptr) const
static SC_DLLPUBLIC OUString addToken(std::u16string_view rTokenList, std::u16string_view rToken, sal_Unicode cSep, sal_Int32 nSepCount=1, bool bForceSep=false)
Adds the string rToken to rTokenList, using a list separator character.
SCCOL GetColMerge() const
SCROW GetRowMerge() const
bool IsOverlapped() const
void GetRange(SCCOLROW &rStart, SCCOLROW &rEnd) const
bool FindTouchedLevel(SCCOLROW nBlockStart, SCCOLROW nBlockEnd, size_t &rFindLevel) const
const ScOutlineEntry * GetEntryByPos(size_t nLevel, SCCOLROW nPos) const
const ScOutlineArray & GetColArray() const
const ScOutlineArray & GetRowArray() const
SfxItemSet & GetItemSet()
const ScRefCellValue & GetCell() const
SCCOL GetStartCol() const
const ScPatternAttr * GetPattern() const
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
bool ValidateRange(ScRange &rScRange, bool bWarn)
Checks and eventually crops the cell range to valid dimensions.
Caches all ARRAY records.
XclExpArrayRef FindArray(const ScTokenArray &rScTokArr, const ScAddress &rBasePos) const
Tries to find an ARRAY record that corresponds to an ocMatRef token.
XclExpArrayBuffer(const XclExpRoot &rRoot)
XclExpArrayRef CreateArray(const ScTokenArray &rScTokArr, const ScRange &rScRange)
Inserts a new ARRAY record into the buffer and returns it.
Represents an ARRAY record that contains the token array of a matrix formula.
virtual bool IsVolatile() const override
Returns true, if the array formula contains volatile functions.
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the record (without record header).
virtual XclTokenArrayRef CreateCellTokenArray(const XclExpRoot &rRoot) const override
Creates and returns the token array for a corresponding FORMULA cell record.
XclTokenArrayRef mxTokArr
XclExpArray(const XclTokenArrayRef &xTokArr, const ScRange &rScRange)
Represents a BLANK or MULBLANK record that describes empty but formatted cells.
virtual void RemoveUnusedBlankCells(const ScfUInt16Vec &rXFIndexes, size_t nStartAllNotFound) override
Tries to remove unused Excel XF index(es).
virtual void WriteXmlContents(XclExpXmlStream &rStrm, const XclAddress &rAddress, sal_uInt32 nXFId, sal_uInt16 nRelCol) override
virtual void GetBlankXFIndexes(ScfUInt16Vec &rXFIndexes) const override
Inserts the Excel XF index(es) into the passed vector.
sal_uInt16 GetStartColAllDefaultCell() const
Return starting column at which all indexes until the end are EXC_XF_DEFAULTCELL .
XclExpBlankCell(const XclAddress &rXclPos, const XclExpMultiXFId &rXFId)
virtual void WriteContents(XclExpStream &rStrm, sal_uInt16 nRelCol) override
Writes the remaining contents of the specified cell (without XF index).
virtual bool TryMerge(const XclExpCellBase &rCell) override
Tries to merge the contents of the passed cell to own data.
Represents a BOOLERR record that describes a cell with a Boolean value.
virtual void WriteContents(XclExpStream &rStrm) override
Derived classes write the contents of the specified cell (without XF index).
virtual void SaveXml(XclExpXmlStream &rStrm) override
XclExpBooleanCell(const XclExpRoot &rRoot, const XclAddress &rXclPos, const ScPatternAttr *pPattern, sal_uInt32 nForcedXFId, bool bValue)
The base class of all cell records.
virtual void ConvertXFIndexes(const XclExpRoot &rRoot)=0
Derived classes convert the XF identifier(s) into the Excel XF index(es).
sal_uInt16 GetXclCol() const
Returns the (first) Excel column index of the cell(s).
virtual bool IsEmpty() const =0
Derived classes return true, if this record does not contain at least one valid cell.
virtual void RemoveUnusedBlankCells(const ScfUInt16Vec &rXFIndexes, size_t nStartAllNotFound)
Derived classes for blank cells remove unused Excel XF index(es).
virtual sal_uInt16 GetLastXclCol() const =0
Derived classes return the column index of the last contained cell.
const XclAddress & GetXclPos() const
Returns the (first) address of the cell(s).
void SetXclCol(sal_uInt16 nXclCol)
Sets this record to a new column position.
virtual sal_uInt32 GetFirstXFId() const =0
Derived classes return the XF identifier of the first contained cell.
virtual void GetBlankXFIndexes(ScfUInt16Vec &rXFIndexes) const
Derived classes for blank cells insert the Excel XF index(es) into the passed vector.
virtual bool TryMerge(const XclExpCellBase &rCell)
Derived classes try to merge the contents of the passed cell to own data.
virtual bool IsMultiLineText() const
Derived classes return whether the cell contains multi-line text.
XclExpCellBase(sal_uInt16 nRecId, std::size_t nContSize, const XclAddress &rXclPos)
sal_uInt32 GetXclRow() const
Returns the Excel row index of the cell.
XclExpRowBuffer maRowBfr
Buffer for column formatting.
XclExpTableopBuffer maTableopBfr
Buffer for SHRFMLA records.
virtual void Save(XclExpStream &rStrm) override
Saves the entire cell table.
XclExpNoteListRef mxNoteList
GUTS record for outline areas.
XclExpShrfmlaBuffer maShrfmlaBfr
Buffer for ARRAY records.
virtual void SaveXml(XclExpXmlStream &rStrm) override
XclExpHyperlinkRef mxHyperlinkList
MERGEDCELLS record for merged cell ranges.
XclExpMergedcellsRef mxMergedcells
List of NOTE records.
XclExpDefrowhRef mxDefrowheight
Buffer for TABLEOP records.
void Finalize(bool bXLS)
Converts all XF identifiers into the Excel XF indexes and calculates default formats.
XclExtLstRef mxExtLst
Data validation with DVAL and DV records.
XclExpColinfoBuffer maColInfoBfr
XclExpCellTable(const XclExpRoot &rRoot)
XclExpRecordRef CreateRecord(sal_uInt16 nRecId) const
Returns the reference to an internal record specified by the passed record id.
XclExpDvalRef mxDval
List of HLINK records.
XclExpRecordRef mxGuts
DEFROWHEIGHT record for default row format.
XclExpArrayBuffer maArrayBfr
Rows and cell records.
The outline buffer for column outlines.
void Update(SCCOL nScCol)
Updates the current state by processing the settings of the passed Calc column.
sal_uInt8 mnHighestOutlineLevel
Buffer for column outline groups.
double GetDefColWidth() const
sal_uInt8 GetHighestOutlineLevel() const
XclExpDefcolwidth maDefcolwidth
List of COLINFO records.
void Initialize(SCROW nLastScRow)
Initializes the buffer: finds settings and formatting of all columns.
XclExpColinfoList maColInfos
XclExpColinfoBuffer(const XclExpRoot &rRoot)
void Finalize(ScfUInt16Vec &rXFIndexes, bool bXLS)
Converts the XF identifiers into the Excel XF indexes and merges equal columns.
XclExpColOutlineBuffer maOutlineBfr
The DEFCOLWIDTH record.
virtual void Save(XclExpStream &rStrm) override
Writes all COLINFO records of this buffer.
virtual void SaveXml(XclExpXmlStream &rStrm) override
Contains the column settings for a range of columns.
bool TryMerge(const XclExpColinfo &rColInfo)
Tries to merge this record with the passed record.
XclExpColinfo(const XclExpRoot &rRoot, SCCOL nScCol, SCROW nLastScRow, XclExpColOutlineBuffer &rOutlineBfr)
Constructs the record with the settings in the Calc document.
void ConvertXFIndexes()
Converts the XF identifier into the Excel XF index.
sal_uInt16 mnScWidth
Excel width of the column.
sal_uInt16 mnLastXclCol
Index to first column.
virtual void WriteBody(XclExpStream &rStrm) override
Writes the contents of this COLINFO record.
sal_uInt8 mnOutlineLevel
Additional column flags.
sal_uInt16 GetColCount() const
Returns the number of columns represented by this record.
bool mbCustomWidth
The XF identifier for column default format.
sal_uInt16 mnFlags
Calc width of the column.
sal_uInt16 GetXFIndex() const
Returns the final Excel XF index of the column(s).
sal_uInt16 mnWidth
True = Column width is different from default width.
virtual void SaveXml(XclExpXmlStream &rStrm) override
sal_uInt16 GetColWidth() const
Returns the Excel width of the column(s).
sal_uInt16 mnFirstXclCol
Outline Level of column (for OOXML)
bool IsDefault(const XclExpDefcolwidth &rDefColWidth)
Returns true, if the column has default format and width.
Represents the DEFCOLWIDTH record containing the default column width of a sheet.
void SetDefWidth(sal_uInt16 nXclColWidth, bool bXLS)
Sets the passed column width (in 1/256 character width) as default width.
XclExpDefcolwidth(const XclExpRoot &rRoot)
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
bool IsDefWidth(sal_uInt16 nXclColWidth) const
Returns true, if the own default width exactly matches the passed width.
Represents a DEFROWHEIGHT record containing default format for unused rows.
void SetDefaultData(const XclExpDefaultRowData &rDefData)
Sets the passed default data as current record contents.
XclExpDefaultRowData maDefData
virtual void WriteBody(XclExpStream &rStrm) override
Writes the contents of the record.
virtual void SaveXml(XclExpXmlStream &rStrm) override
void SetDimensions(sal_uInt16 nFirstUsedXclCol, sal_uInt32 nFirstUsedXclRow, sal_uInt16 nFirstFreeXclCol, sal_uInt32 nFirstFreeXclRow)
Sets the used area to the record.
virtual void WriteBody(XclExpStream &rStrm) override
Writes the contents of the DIMENSIONS record.
sal_uInt16 mnFirstFreeXclCol
First used column.
const XclExpRoot & mrRoot
XclExpDimensions(const XclExpRoot &rRoot)
sal_uInt32 mnFirstFreeXclRow
First used row.
sal_uInt32 mnFirstUsedXclRow
sal_uInt16 mnFirstUsedXclCol
First unused row after used area.
This class contains the DV record list following the DVAL record.
const XclFontData & GetAppFontData() const
Returns the application font data of this file, needed e.g.
Represents a GUTS record containing the level count of row and column outlines.
XclExpGuts(const XclExpRoot &rRoot)
sal_uInt16 mnRowLevels
Width of column outline area (pixels).
sal_uInt16 mnRowWidth
Number of visible row outline levels.
sal_uInt16 mnColWidth
Number of visible column outline levels.
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the record (without record header).
Helper to create HLINK records during creation of formatted cell strings.
bool HasLinkRecord() const
Returns true, if a single HLINK record has been created.
bool HasMultipleUrls() const
Returns true, if multiple URLs have been processed.
XclExpHyperlinkRef GetLinkRecord() const
Returns the created single HLINk record, or an empty reference.
const OUString & GetUrlList() const
Returns a string containing all processed URLs.
Provides export of hyperlink data.
Represents a text cell record.
bool mbLineBreak
Index into Shared String Table (only used for BIFF8).
virtual bool IsMultiLineText() const override
Returns true if the cell contains multi-line text.
XclExpLabelCell(const XclExpRoot &rRoot, const XclAddress &rXclPos, const ScPatternAttr *pPattern, sal_uInt32 nForcedXFId, const OUString &rStr)
Constructs the record from an unformatted Calc string cell.
sal_uInt32 mnSstIndex
The cell text.
void Init(const XclExpRoot &rRoot, const ScPatternAttr *pPattern, XclExpStringRef const &xText)
Initializes the record contents.
virtual void SaveXml(XclExpXmlStream &rStrm) override
virtual void WriteContents(XclExpStream &rStrm) override
Derived classes write the contents of the specified cell (without XF index).
Represents a MERGEDCELLS record containing all merged cell ranges in a sheet.
Base class for all cell records supporting multiple contents.
virtual bool IsEmpty() const override
Returns true, if this record does not contain at least one valid cell.
void GetXFIndexes(ScfUInt16Vec &rXFIndexes) const
Inserts the Excel XF index(es) into the passed vector.
XclExpMultiXFIdDeq maXFIds
Data size of contents for one cell.
virtual sal_uInt32 GetFirstXFId() const override
Return the XF identifier of the first contained cell.
virtual void ConvertXFIndexes(const XclExpRoot &rRoot) override
Convert all XF identifiers into the Excel XF indexes.
virtual void WriteXmlContents(XclExpXmlStream &rStrm, const XclAddress &rAddress, sal_uInt32 nXFId, sal_uInt16 nRelCol)=0
sal_uInt16 GetStartColAllDefaultCell() const
Return starting column at which all indexes until the end are EXC_XF_DEFAULTCELL .
bool TryMergeXFIds(const XclExpMultiCellBase &rCell)
Tries to merge the XF ID list of the passed cell with the own list.
virtual void WriteContents(XclExpStream &rStrm, sal_uInt16 nRelCol)=0
Derived classes write the remaining contents of the specified cell (without XF index).
XclExpMultiCellBase(sal_uInt16 nRecId, sal_uInt16 nMulRecId, std::size_t nContSize, const XclAddress &rXclPos)
sal_uInt16 GetCellCount() const
Returns the number of cells this record represents.
std::size_t mnContSize
Record ID for multiple record variant.
void AppendXFId(const XclExpMultiXFId &rXFId)
Appends the passed XF identifier nCount times to the list of XF identifiers.
virtual void Save(XclExpStream &rStrm) override
Writes the record, calls WriteContents() for each contained cell.
virtual void SaveXml(XclExpXmlStream &rStrm) override
virtual sal_uInt16 GetLastXclCol() const override
Returns the column index of the last cell this record describes.
void RemoveUnusedXFIndexes(const ScfUInt16Vec &rXFIndexes, size_t nStartAllNotFound)
Removes unused Excel XF index(es).
Represents a NOTE record containing the relevant data of a cell note.
Stores all number formats used in the document.
sal_uInt32 GetStandardFormat() const
Returns the core index of the current standard number format.
Represents a NUMBER record that describes a cell with a double value.
virtual void SaveXml(XclExpXmlStream &rStrm) override
XclExpNumberCell(const XclExpRoot &rRoot, const XclAddress &rXclPos, const ScPatternAttr *pPattern, sal_uInt32 nForcedXFId, double fValue)
virtual void WriteContents(XclExpStream &rStrm) override
Derived classes write the contents of the specified cell (without XF index).
XclExpOutlineBuffer(const XclExpRoot &rRoot, bool bRows)
Constructs the outline buffer.
sal_uInt8 mnCurrLevel
Info for current row and all levels.
const ScOutlineArray * mpScOLArray
bool mbCurrCollapse
Highest level of an open group for current position.
sal_uInt8 GetLevel() const
Returns the highest level of an open group at the last processed position.
void UpdateColRow(SCCOLROW nScPos)
Updates the current state by processing the settings at the passed Calc position.
std::vector< XclExpLevelInfo > maLevelInfos
Pointer to Calc outline array.
bool IsCollapsed() const
Returns true, if a collapsed group ends at the last processed position.
The main progress bar for the export filter.
void ActivateFinalRowsSegment()
Activates the progress segment to finalize ROW records.
void Progress()
Increases the currently activated (sub) progress bar by 1 step.
void ActivateCreateRowsSegment()
Activates the progress segment to create ROW records.
void IncRowRecordCount()
Increases the number of existing ROW records by 1.
Base record for additional range formula records (i.e.
XclExpRangeFmlaBase(sal_uInt16 nRecId, sal_uInt32 nRecSize, const ScAddress &rScPos)
Constructs the record with a single cell.
XclAddress maBaseXclPos
Range described by this record.
void Extend(const ScAddress &rScPos)
Extends the cell range to include the passed cell address.
bool IsBasePos(sal_uInt16 nXclCol, sal_uInt32 nXclRow) const
Returns true, if the passed cell position is equal to own base position.
void WriteRangeAddress(XclExpStream &rStrm) const
Writes the range address covered by this record.
RecType * GetLastRecord() const
Returns reference to the last existing record or empty reference, if list is empty.
RecType * GetFirstRecord() const
Returns reference to the first existing record or empty reference, if list is empty.
virtual void SaveXml(XclExpXmlStream &rStrm) override
void AppendNewRecord(RecType *pRec)
Appends a newly created record to the list.
void RemoveRecord(size_t nPos)
Removes the record at the specified position from the list.
void InvalidateRecord(size_t nPos)
Optimization for repeated removal.
void InsertRecord(RecType *pRec, size_t nPos)
Inserts a record at the specified position into the list.
virtual void Save(XclExpStream &rStrm) override
Writes the complete record list.
void AppendRecord(RecType *pRec)
Appends a record to the list.
void RemoveInvalidatedRecords()
RecType * GetRecord(size_t nPos) const
Returns reference to an existing record or empty reference on error.
Base class for single records with any content.
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
sal_uInt16 GetRecId() const
Returns the current record ID.
void SetRecHeader(sal_uInt16 nRecId, std::size_t nRecSize)
Sets record ID and size with one call.
void AddRecSize(std::size_t nRecSize)
Adds a size value to the record size prediction.
void SetRecSize(std::size_t nRecSize)
Sets a new record size prediction.
void SetRecId(sal_uInt16 nRecId)
Sets a new record ID.
std::size_t GetRecSize() const
Returns the current record size prediction.
Represents an RK or MULRK record that describes cells with a compressed double values.
virtual void WriteContents(XclExpStream &rStrm, sal_uInt16 nRelCol) override
Writes the remaining contents of the specified cell (without XF index).
XclExpRkCell(const XclExpRoot &rRoot, const XclAddress &rXclPos, const ScPatternAttr *pPattern, sal_uInt32 nForcedXFId, sal_Int32 nRkValue)
virtual bool TryMerge(const XclExpCellBase &rCell) override
Tries to merge the contents of the passed cell to own data.
virtual void WriteXmlContents(XclExpXmlStream &rStrm, const XclAddress &rAddress, sal_uInt32 nXFId, sal_uInt16 nRelCol) override
Access to global data from other classes.
XclExpFontBuffer & GetFontBuffer() const
Returns the font buffer.
XclExpFormulaCompiler & GetFormulaCompiler() const
Returns the formula compiler to produce formula token arrays.
XclExpAddressConverter & GetAddressConverter() const
Returns the address converter.
XclExpNumFmtBuffer & GetNumFmtBuffer() const
Returns the number format buffer.
XclExpSst & GetSst() const
Returns the shared string table.
XclExpXFBuffer & GetXFBuffer() const
Returns the cell formatting attributes buffer.
XclExpProgressBar & GetProgressBar() const
Returns the export progress bar.
const XclExpRoot & GetRoot() const
Returns this root instance - for code readability in derived classes.
Collects all rows which contain all cells of a sheet.
XclExpRow & GetOrCreateRow(sal_uInt32 nXclRow, bool bRowAlwaysEmpty)
Returns access to the specified ROW record.
virtual void SaveXml(XclExpXmlStream &rStrm) override
sal_uInt8 mnHighestOutlineLevel
DIMENSIONS record for used area.
virtual void Save(XclExpStream &rStrm) override
Writes the DIMENSIONS record, all ROW records and all cell records.
void CreateRows(SCROW nFirstFreeScRow)
Forces insertion of all ROW records before the passed row.
XclExpRowOutlineBuffer maOutlineBfr
sal_uInt8 GetHighestOutlineLevel() const
void AppendCell(XclExpCellRef const &xCell, bool bIsMergedBase)
Appends the passed cell object to the row that the cell specifies.
std::shared_ptr< XclExpRow > RowRef
XclExpDimensions maDimensions
Buffer for row outline groups.
XclExpRowBuffer(const XclExpRoot &rRoot)
void Finalize(XclExpDefaultRowData &rDefRowData, const ScfUInt16Vec &rColXFIndexes, size_t nStartColAllDefault)
Converts all XF identifiers into the Excel XF indexes and calculates default formats.
The outline buffer for row outlines.
void Update(SCROW nScRow)
Updates the current state by processing the settings of the passed Calc row.
Represents a ROW record and additionally contains all cells records of a row.
sal_uInt16 mnFlags
Row height in twips.
bool IsDefaultable() const
Returns true, if this row may be omitted by using the DEFROWHEIGHT record.
virtual void SaveXml(XclExpXmlStream &rStrm) override
bool mbEnabled
true = Do not add blank cells in Finalize().
sal_uInt32 mnXclRowRpt
Outline Level of row (for OOXML)
XclExpRecordList< XclExpCellBase > maCellList
sal_uInt8 mnOutlineLevel
Default row formatting.
void AppendCell(XclExpCellRef const &xCell, bool bIsMergedBase)
Appends the passed cell object to this row.
sal_uInt32 GetXclRow() const
Returns the excel row index of this ROW record.
sal_uInt16 GetFirstUsedXclCol() const
Returns the column index of the first used cell in this row.
sal_uInt32 GetXclRowRpt() const
bool IsHidden() const
Returns true, if this row is hidden.
void Finalize(const ScfUInt16Vec &rColXFIndexes, ScfUInt16Vec &aXFIndexes, size_t nStartColAllDefault, bool bUpdateProgress)
Converts all XF identifiers into the Excel XF indexes.
sal_uInt16 mnXFIndex
Flags for the ROW record.
bool IsEmpty() const
Returns true, if this row does not contain at least one valid cell.
void DisableIfDefault(const XclExpDefaultRowData &rDefRowData)
Disables this row, if it is defaultable and has the passed default format.
virtual void Save(XclExpStream &rStrm) override
Writes the ROW record if the row is not disabled (see DisableIfDefault() function).
void InsertCell(XclExpCellRef xCell, size_t nPos, bool bIsMergedBase)
Inserts a cell at the specified list position, tries to merge with neighbors.
void WriteCellList(XclExpStream &rStrm)
Writes all cell records of this row.
sal_uInt16 GetFirstFreeXclCol() const
Returns the column index of the first unused cell following all used cells in this row.
sal_uInt16 mnHeight
Excel row index of this row.
XclExpRow(const XclExpRoot &rRoot, sal_uInt32 nXclRow, XclExpRowOutlineBuffer &rOutlineBfr, bool bAlwaysEmpty, bool bHidden, sal_uInt16 nHeight)
Constructs the ROW record and converts the Calc row settings.
void SetXclRowRpt(sal_uInt32 nRpt)
sal_uInt32 mnXclRow
List of cell records for this row.
virtual void WriteBody(XclExpStream &rStrm) override
Writes the contents of the ROW record.
bool IsUnsynced() const
Returns true, if this row contains a manually set height.
Caches all SHRFMLA records and provides functions to update their ranges.
XclExpShrfmlaRef CreateOrExtendShrfmla(const ScFormulaCell &rScCell, const ScAddress &rScPos)
Tries to create a new or to update an existing SHRFMLA record.
bool IsValidTokenArray(const ScTokenArray &rArray) const
Check for presence of token that's not allowed in Excel's shared formula.
XclExpShrfmlaBuffer(const XclExpRoot &rRoot)
BadTokenArraysType maBadTokens
Map containing the SHRFMLA records.
Represents a SHRFMLA record that contains the token array of a shared formula.
XclExpShrfmla(const XclTokenArrayRef &xTokArr, const ScAddress &rScPos)
Creates a SHRFMLA record that consists of the passed cell address only.
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the record (without record header).
virtual XclTokenArrayRef CreateCellTokenArray(const XclExpRoot &rRoot) const override
Creates and returns the token array for a corresponding FORMULA cell record.
XclTokenArrayRef mxTokArr
virtual bool IsVolatile() const override
Returns true, if the shared formula contains volatile functions.
sal_uInt8 mnUsedCount
The token array of a shared formula.
void ExtendRange(const ScAddress &rScPos)
Extends the cell range to include the passed cell address.
Base class for all cell records not supporting multiple contents.
virtual sal_uInt32 GetFirstXFId() const override
Return the XF identifier of the cell.
virtual void WriteContents(XclExpStream &rStrm)=0
Derived classes write the contents of the specified cell (without XF index).
virtual void WriteBody(XclExpStream &rStrm) override
Writes cell address, XF index, and calls WriteContents() for each cell.
void SetXFId(sal_uInt32 nXFId)
XclExpSingleCellBase(sal_uInt16 nRecId, std::size_t nContSize, const XclAddress &rXclPos, sal_uInt32 nXFId)
virtual sal_uInt16 GetLastXclCol() const override
Returns the last column, which is equal to the first column for single cells.
virtual void ConvertXFIndexes(const XclExpRoot &rRoot) override
Converts the XF identifier into the Excel XF index.
std::size_t mnContSize
The XF identifier of the cell formatting.
std::size_t GetContSize() const
void SetContSize(std::size_t nContSize)
sal_uInt32 GetXFId() const
virtual void Save(XclExpStream &rStrm) override
Writes cell address, XF index, and calls WriteContents() for each cell.
virtual bool IsEmpty() const override
Returns true, if this record does not contain at least one valid cell.
sal_uInt32 Insert(const XclExpStringRef &xString)
Inserts a new string into the table.
This class is used to export Excel record streams.
This class provides methods to create an XclExpString.
static sal_Int16 GetLeadingScriptType(const XclExpRoot &rRoot, const OUString &rString)
Returns the script type first text portion different to WEAK, or the system default script type,...
static XclExpStringRef CreateCellString(const XclExpRoot &rRoot, const OUString &rString, const ScPatternAttr *pCellAttr, XclStrFlags nFlags=XclStrFlags::NONE, sal_uInt16 nMaxLen=EXC_STR_MAXLEN)
Creates a new formatted string from a Calc string cell.
Represents a STRING record that contains the result of a string formula.
XclExpStringRec(const XclExpRoot &rRoot, const OUString &rResult)
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the record (without record header).
Contains all created TABLEOP records and supports creating or updating them.
XclExpTableopRef CreateOrExtendTableop(const ScTokenArray &rScTokArr, const ScAddress &rScPos)
Tries to update an existing or to create a new TABLEOP record.
void Finalize()
Finalizes all contained TABLEOP records.
XclExpTableopRef TryCreate(const ScAddress &rScPos, const XclMultipleOpRefs &rRefs)
Tries to create a new TABLEOP record, if rRefs contains valid references.
XclExpRecordList< XclExpTableop > maTableopList
XclExpTableopBuffer(const XclExpRoot &rRoot)
Represents a TABLEOP record for a multiple operations range.
sal_uInt16 mnRowInpXclCol
Row index of column input cell.
sal_uInt32 mnRowInpXclRow
Column index of row input cell.
bool TryExtend(const ScAddress &rScPos, const XclMultipleOpRefs &rRefs)
Returns true, if the cell range has been extended to the passed position.
bool mbValid
Type of the multiple operation (Calc constant).
virtual void WriteBody(XclExpStream &rStrm) override
Writes the contents of the TABLEOP record.
sal_uInt16 mnColInpXclCol
Column index of last appended cell.
virtual bool IsVolatile() const override
Returns true, if the multiple operations range is volatile.
XclExpTableop(const ScAddress &rScPos, const XclMultipleOpRefs &rRefs, sal_uInt8 nScMode)
sal_uInt32 mnColInpXclRow
Column index of column input cell.
virtual void Save(XclExpStream &rStrm) override
Writes the record if it is valid.
void Finalize()
Finalizes the record.
sal_uInt16 mnLastAppXclCol
bool IsAppendable(sal_uInt16 nXclCol, sal_uInt16 nXclRow) const
Returns true, if the passed cell position can be appended to this record.
virtual XclTokenArrayRef CreateCellTokenArray(const XclExpRoot &rRoot) const override
Creates and returns the token array for a corresponding FORMULA cell record.
sal_uInt8 mnScMode
Row index of row input cell.
A record with a single value of type Type.
const Type & GetValue() const
Returns the value of the record.
void SetValue(const Type &rValue)
Sets a new record value.
sal_uInt32 InsertWithNumFmt(const ScPatternAttr *pPattern, sal_Int16 nScript, sal_uInt32 nForceScNumFmt, bool bForceLineBreak)
Finds or creates a cell XF record for the passed item set, with custom number format.
sal_uInt32 InsertWithFont(const ScPatternAttr *pPattern, sal_Int16 nScript, sal_uInt16 nForceXclFont, bool bForceLineBreak)
Finds or creates a cell XF record for the passed item set.
static sal_uInt32 GetDefCellXFId()
Returns the XF identifier representing the default cell XF.
sal_uInt32 Insert(const ScPatternAttr *pPattern, sal_Int16 nScript)
Finds or creates a cell XF record for the passed item set.
const XclExpXF * GetXFById(sal_uInt32 nXFId) const
Returns an XF record by its unique identifier.
Represents an XF record which contains all formatting data of a cell or cell style.
const XclExpCellAlign & GetAlignmentData() const
Returns the alignment settings of this XF.
tools::Long GetCharWidth() const
Returns the width of the '0' character (default font) for the current printer (twips).
SvNumberFormatter & GetFormatter() const
Returns the number formatter of the Calc document.
const ScAddress & GetMaxPos() const
Returns the highest possible cell address valid in Calc and Excel (using current BIFF version).
sal_Int16 GetDefApiScript() const
Returns the default script type, e.g.
SCTAB GetCurrScTab() const
Returns the current Calc sheet index.
XclBiff GetBiff() const
Returns the current BIFF version of the importer/exporter.
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
static bool GetMultipleOpRefs(const ScDocument &rDoc, XclMultipleOpRefs &rRefs, const ScTokenArray &rScTokArr, const ScAddress &rScPos)
Parses the passed formula and tries to extract references of a multiple operation.
static OString ToOString(const Color &rColor)
static void GetFormulaTypeAndValue(ScFormulaCell &rCell, const char *&sType, OUString &rValue)
static OUString ToOUString(const char *s)
static ThreadPool & getSharedOptimalPool()
void waitUntilDone(const std::shared_ptr< ThreadTaskTag > &, bool bJoin=true)
static std::shared_ptr< ThreadTaskTag > createThreadTaskTag()
void pushTask(std::unique_ptr< ThreadTask > pTask)
static std::size_t getPreferredConcurrency()
size_type count(const Value &v) const
std::pair< const_iterator, bool > insert(Value &&x)
const OUString & getString() const
RttiCompleteObjectLocator col
constexpr OUStringLiteral last
std::shared_ptr< FastSerializerHelper > FSHelperPtr
constexpr TypedWhichId< ScMergeFlagAttr > ATTR_MERGE_FLAG(145)
constexpr TypedWhichId< SfxStringItem > ATTR_HYPERLINK(155)
constexpr TypedWhichId< ScMergeAttr > ATTR_MERGE(144)
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALUE_FORMAT(146)
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALIDDATA(153)
Complex reference (a range) into the sheet.
This is very similar to ScCellValue, except that it references the original value instead of copying ...
ScFormulaCell * getFormula() const
const EditTextObject * getEditText() const
const svl::SharedString * getSharedString() const
Single reference (one address) into the sheet.
ScAddress toAbs(const ScSheetLimits &rLimits, const ScAddress &rPos) const
A 2D cell address struct with Excel column and row indexes.
void Set(sal_uInt16 nCol, sal_uInt32 nRow)
bool mbLineBreak
Indentation.
Contains all possible default row settings.
XclExpDefaultRowData()
Default height for unspecified rows.
sal_uInt16 mnHeight
Default flags for unspecified rows.
bool IsHidden() const
Returns true, if rows are hidden by default.
bool IsUnsynced() const
Returns true, if the rows have a manually set height by default.
sal_uInt16 mnXFIndex
Temporary XF identifier.
void ConvertXFIndex(const XclExpRoot &rRoot)
Converts the XF identifier in mnXFId to an Excel XF index and stores it in mnXFIndex.
sal_uInt16 mnHeight
String with styles (bold, italic).
Contains all cell references that can be extracted from a multiple operations formula.
ScAddress maRowFirstScPos
ScAddress maColFirstScPos
Position of the (first) formula cell.
void Set(sal_uInt16 nCol1, sal_uInt32 nRow1, sal_uInt16 nCol2, sal_uInt32 nRow2)
void Write(XclExpStream &rStrm, bool bCol16Bit=true) const
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
std::shared_ptr< XclExpString > XclExpStringRef
static bool operator<(const XclExpDefaultRowData &rLeft, const XclExpDefaultRowData &rRight)
static size_t findFirstAllSameUntilEnd(const ScfUInt16Vec &rIndexes, sal_uInt16 value, size_t searchStart=std::numeric_limits< size_t >::max())
static OString lcl_GetStyleId(const XclExpXmlStream &rStrm, sal_uInt32 nXFIndex)
const sal_uInt8 EXC_ERR_NA
XclBiff
An enumeration for all Excel file format types (BIFF types).
@ EXC_BIFF8
MS Excel 5.0, MS Excel 7.0 (95)
const sal_uInt16 EXC_ID_HLINK
const sal_uInt16 EXC_ID_EXTLST
const sal_uInt16 EXC_ID_DVAL
Font escapement type modified?
const sal_uInt16 EXC_ID_MERGEDCELLS
const sal_uInt16 EXC_ID_NOTE
const sal_uInt16 EXC_STR_MAXLEN
::std::vector< XclFormatRun > XclFormatRunVec
A vector with all formatting runs for a rich-string.
const sal_uInt16 EXC_FONT_NOTFOUND
Application font index.
const sal_uInt16 EXC_XF_NOTFOUND
Excel index to default cell XF.
const sal_uInt32 EXC_XFID_NOTFOUND
Special index for "not found" state.
const sal_uInt16 EXC_XF_DEFAULTCELL
Excel index to default style XF.
const sal_uInt16 EXC_ROW_HIDDEN
const sal_uInt16 EXC_ROW_USEDEFXF
const sal_uInt16 EXC_ID3_LABEL
const sal_uInt16 EXC_ARRAY_RECALC_ALWAYS
const sal_uInt16 EXC_ROW_DEFAULTFLAGS
const sal_uInt16 EXC_ID3_DIMENSIONS
const sal_uInt16 EXC_ID3_NUMBER
const sal_uInt16 EXC_ID3_STRING
const sal_uInt16 EXC_TABLEOP_RECALC_ALWAYS
const sal_uInt16 EXC_ID3_ROW
const sal_uInt16 EXC_FORMULA_DEFAULTFLAGS
const sal_uInt16 EXC_TABLEOP_ROW
const sal_uInt8 EXC_FORMULA_RES_STRING
const sal_uInt16 EXC_ARRAY_DEFAULTFLAGS
const sal_uInt16 EXC_ID_COLINFO
const sal_uInt8 EXC_BOOLERR_BOOL
const sal_uInt16 EXC_ID_GUTS
const sal_uInt16 EXC_ROW_UNSYNCED
const sal_uInt16 EXC_DEFCOLWIDTH_DEF
const sal_uInt16 EXC_ROW_ROWBLOCKSIZE
const sal_uInt8 EXC_OUTLINE_MAX
const sal_uInt8 EXC_FORMULA_RES_EMPTY
Result is error code.
const sal_uInt16 EXC_ID2_DEFROWHEIGHT
const sal_uInt16 EXC_ROW_COLLAPSED
const sal_uInt16 EXC_ID3_DEFROWHEIGHT
const sal_uInt16 EXC_ID_SHRFMLA
const sal_uInt16 EXC_ID3_ARRAY
const sal_uInt16 EXC_ID2_FORMULA
const sal_uInt16 EXC_ID_RK
const sal_uInt16 EXC_ID3_BOOLERR
const sal_uInt16 EXC_ID_LABELSST
const sal_uInt16 EXC_ID2_DIMENSIONS
const sal_uInt16 EXC_DEFROW_UNSYNCED
const sal_uInt16 EXC_ID_DEFCOLWIDTH
const sal_uInt16 EXC_ID_MULBLANK
const sal_uInt16 EXC_TABLEOP_DEFAULTFLAGS
const sal_uInt16 EXC_ID3_BLANK
const sal_uInt8 EXC_LABEL_MAXLEN
const sal_uInt16 EXC_TABLEOP_BOTH
const sal_uInt16 EXC_ID3_TABLEOP
const sal_uInt16 EXC_ID_RSTRING
const sal_uInt8 EXC_FORMULA_RES_ERROR
Result is Boolean value.
const sal_uInt16 EXC_FORMULA_RECALC_ALWAYS
const sal_uInt16 EXC_COLINFO_COLLAPSED
const sal_uInt16 EXC_ID_MULRK
const sal_uInt16 EXC_DEFROW_DEFAULTHEIGHT
const sal_uInt8 EXC_FORMULA_RES_BOOL
Result is a string.
const sal_uInt16 EXC_DEFROW_DEFAULTFLAGS
const sal_uInt16 EXC_DEFROW_HIDDEN
const sal_uInt16 EXC_FORMULA_SHARED
const sal_uInt16 EXC_COLINFO_HIDDEN
#define SV_COUNTRY_LANGUAGE_OFFSET
constexpr sal_uInt32 NUMBERFORMAT_ENTRY_NOT_FOUND