24 #include <com/sun/star/i18n/ScriptType.hpp>
31 #include <document.hxx>
44 #include <tokenarray.hxx>
47 #include <oox/token/tokens.hxx>
50 using namespace ::
oox;
52 namespace 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() );
139 rStrm << nFlags << sal_uInt32( 0 ) << *
mxTokArr;
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)
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 ) :
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();
761 OSL_ENSURE( mxText->Len() <=
EXC_LABEL_MAXLEN,
"XclExpLabelCell::XclExpLabelCell - string too long" );
764 if( mxText->IsRich() )
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 );
803 if( mxText->IsRich() )
805 rStrm << static_cast< sal_uInt8 >( mxText->GetFormatsCount() );
806 mxText->WriteFormats( rStrm );
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 ) );
977 OStringBuffer sFmlaCellRange;
983 sFmlaCellRange.append(
":");
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:
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 );
1097 rStrm << nFlags << sal_uInt32( 0 ) << *
mxTokArr;
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),
1240 [](
const sal_uInt16& rSum,
const XclExpMultiXFId& rXFId) {
return rSum + rXFId.mnCount; });
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 for(
const auto& rXFId :
maXFIds )
1316 col += rXFId.mnCount;
1324 OSL_ENSURE( rXFId.
mnCount > 0,
"XclExpBlankCell::XclExpBlankCell - invalid count" );
1333 OSL_ENSURE( rXclPos.
mnCol <= nLastXclCol,
"XclExpBlankCell::XclExpBlankCell - invalid column range" );
1361 rWorksheet->singleElement( XML_c,
1368 const ScPatternAttr* pPattern, sal_uInt32 nForcedXFId, sal_Int32 nRkValue ) :
1372 AppendXFId( rRoot, pPattern, ApiScriptType::LATIN, nForcedXFId );
1390 rWorksheet->startElement( XML_c,
1396 rWorksheet->startElement( XML_v );
1398 rWorksheet->endElement( XML_v );
1399 rWorksheet->endElement( XML_c );
1404 OSL_ENSURE( nRelCol <
maRkValues.size(),
"XclExpRkCell::WriteContents - overflow error" );
1411 mpScOLArray( nullptr ),
1414 mbCurrCollapse(
false )
1417 mpScOLArray = &(bRows ? pOutlineTable->GetRowArray() : pOutlineTable->GetColArray());
1431 size_t nNewOpenScLevel = 0;
1435 nNewLevel = static_cast< sal_uInt8 >( nNewOpenScLevel + 1 );
1442 for(
size_t nScLevel = 0; nScLevel <= nNewOpenScLevel; ++nScLevel )
1450 maLevelInfos[ nScLevel ].mnScEndPos = pEntry->GetEnd();
1451 maLevelInfos[ nScLevel ].mbHidden = pEntry->IsHidden();
1461 for( sal_uInt16 nScLevel = nNewOpenScLevel + 1; !
mbCurrCollapse && (nScLevel <= nOldOpenScLevel); ++nScLevel )
1506 mnFirstUsedXclRow( 0 ),
1507 mnFirstFreeXclRow( 0 ),
1508 mnFirstUsedXclCol( 0 ),
1509 mnFirstFreeXclCol( 0 )
1523 sal_uInt16 nFirstUsedXclCol, sal_uInt32 nFirstUsedXclRow,
1524 sal_uInt16 nFirstFreeXclCol, sal_uInt32 nFirstFreeXclRow )
1558 rStrm << static_cast< sal_uInt16 >(
mnFirstUsedXclRow ) << static_cast< sal_uInt16 >( mnFirstFreeXclRow );
1561 rStrm << sal_uInt16( 0 );
1566 double lclGetCChCorrection(
const XclExpRoot& rRoot)
1590 double defaultColumnWidth = 256.0 *
GetValue();
1593 return std::abs(defaultColumnWidth - nXclColWidth) < 256.0 * 1.0 / 16.0;
1598 double fCCh = nXclColWidth / 256.0;
1601 const double fCorrection = lclGetCChCorrection(
GetRoot());
1602 const double fCorrectedCCh = fCCh - fCorrection;
1604 double fCChRound = std::round(fCorrectedCCh);
1610 if (fCChRound < 0.0 || fCChRound > 255.0 || std::abs(fCChRound - fCorrectedCCh) > 1.0 / 512)
1612 fCCh = fCChRound + fCorrection;
1623 static_cast<sal_uInt16>(std::round(fCorrectedCCh)));
1624 aUInt16Rec.
Save(rStrm);
1631 mbCustomWidth(
false ),
1635 mnOutlineLevel( 0 ),
1636 mnFirstXclCol( static_cast< sal_uInt16 >( nScCol ) ),
1637 mnLastXclCol( static_cast< sal_uInt16 >( nScCol ) )
1647 sal_uInt16 nScWidth = rDoc.
GetColWidth( nScCol, nScTab,
false );
1655 rOutlineBfr.
Update( nScCol );
1716 const double nTruncatedExcelColumnWidth = std::trunc( nExcelColumnWidth * 100.0 + 0.5 ) / 100.0;
1727 XML_width, OString::number(nTruncatedExcelColumnWidth) );
1732 maDefcolwidth( rRoot ),
1733 maOutlineBfr( rRoot ),
1734 mnHighestOutlineLevel( 0 )
1741 for( sal_uInt16 nScCol = 0, nLastScCol =
GetMaxPos().
Col(); nScCol <= nLastScCol; ++nScCol )
1775 std::unordered_map< sal_uInt16, sal_uInt16 > aWidthMap;
1776 sal_uInt16 nMaxColCount = 0;
1777 sal_uInt16 nMaxUsedWidth = 0;
1784 rXFIndexes.resize( rXFIndexes.size() + nColCount, xRec->
GetXFIndex() );
1788 sal_uInt16& rnMapCount = aWidthMap[ nWidth ];
1789 rnMapCount = rnMapCount + nColCount;
1790 if( rnMapCount > nMaxColCount )
1792 nMaxColCount = rnMapCount;
1793 nMaxUsedWidth = nWidth;
1822 rWorksheet->startElement(XML_cols);
1824 rWorksheet->endElement( XML_cols );
1867 mnXclRow( nXclRow ),
1871 mnOutlineLevel( 0 ),
1873 mnCurrentRow( nXclRow ),
1874 mbAlwaysEmpty( bAlwaysEmpty ),
1889 rOutlineBfr.
Update( nScRow );
1902 size_t searchStart = std::numeric_limits<size_t>::max())
1904 for(
size_t i = std::min(rIndexes.size(), searchStart);
i >= 1; --
i )
1906 if( rIndexes[
i - 1 ] != value )
1914 OSL_ENSURE( !
mbAlwaysEmpty,
"XclExpRow::AppendCell - row is marked to be always empty" );
1927 OSL_ENSURE( rColXFIndexes.size() == nColCount,
"XclExpRow::Finalize - wrong column XF index count" );
1931 assert( aXFIndexes.size() == nColCount );
1961 if( nFirstFreeXclCol < nNextUsedXclCol )
1963 aXFId.
mnCount = nNextUsedXclCol - nFirstFreeXclCol;
1968 for(
size_t i = nFirstFreeXclCol;
i < nNextUsedXclCol; ++
i )
1980 size_t nStartSearchAllDefault = aXFIndexes.size();
1984 assert(pLastBlank->
GetLastXclCol() == aXFIndexes.size() - 1);
1991 const size_t nHalfIndexes = aXFIndexes.size() / 2;
1992 if( nStartAllDefault > nHalfIndexes )
1995 nRowXFIndex = aXFIndexes.back();
1997 if( nStartLastSame > nHalfIndexes )
1999 std::unordered_map< sal_uInt16, size_t > aIndexMap;
2000 size_t nMaxXFCount = 0;
2001 for(
const auto& rXFIndex : aXFIndexes )
2005 size_t& rnCount = aIndexMap[ rXFIndex ];
2007 if( rnCount > nMaxXFCount )
2009 nRowXFIndex = rXFIndex;
2010 nMaxXFCount = rnCount;
2011 if (nMaxXFCount > nHalfIndexes)
2027 if( !bUseColDefXFs )
2030 size_t nXFCountWithRowDefXF = 0;
2031 size_t nXFCountWithoutRowDefXF = 0;
2032 ScfUInt16Vec::const_iterator aColIt = rColXFIndexes.begin();
2033 for(
const auto& rXFIndex : aXFIndexes )
2035 sal_uInt16 nXFIndex = rXFIndex;
2038 if( nXFIndex != nRowXFIndex )
2039 ++nXFCountWithRowDefXF;
2040 if( nXFIndex != *aColIt )
2041 ++nXFCountWithoutRowDefXF;
2047 bUseColDefXFs = nXFCountWithoutRowDefXF <= nXFCountWithRowDefXF;
2052 size_t maxStartAllNotFound;
2055 size_t maxStartAllDefault = std::max( nStartAllDefault, nStartColAllDefault );
2058 for(
size_t i = 0;
i < maxStartAllDefault; ++
i )
2060 if( aXFIndexes[
i ] == rColXFIndexes[
i ] )
2064 for(
size_t i = maxStartAllDefault;
i < aXFIndexes.size(); ++
i )
2066 maxStartAllNotFound = maxStartAllDefault;
2074 for(
auto& rXFIndex : aXFIndexes )
2075 if( rXFIndex == nRowXFIndex )
2077 maxStartAllNotFound = aXFIndexes.size();
2093 for(
size_t i = 0;
i < nStartAllNotFound; ++
i )
2113 return !
::get_flag(
mnFlags, static_cast< sal_uInt16 >( ~nFlagsAlwaysMarkedAsDefault ) ) &&
2143 OSL_ENSURE( xCell,
"XclExpRow::InsertCell - missing cell" );
2148 if( bIsMergedBase && xCell->IsMultiLineText() )
2153 if( xPrevCell && xPrevCell->
TryMerge( *xCell ) )
2161 if( xNextCell && xCell->TryMerge( *xNextCell ) )
2185 rWorksheet->startElement( XML_row,
2189 XML_customFormat, ToPsz( haveFormat ),
2190 XML_ht, OString::number(static_cast<double>(
mnHeight) / 20.0),
2201 rWorksheet->endElement( XML_row );
2207 maOutlineBfr( rRoot ),
2208 maDimensions( rRoot ),
2209 mnHighestOutlineLevel( 0 )
2215 OSL_ENSURE( xCell,
"XclExpRowBuffer::AppendCell - missing cell" );
2221 if( nFirstFreeScRow > 0 )
2231 size_t mnStartColAllDefault;
2232 std::vector< XclExpRow * > maRows;
2234 RowFinalizeTask(
const std::shared_ptr<comphelper::ThreadTaskTag> & pTag,
2236 size_t nStartColAllDefault,
2239 mbProgress( bProgress ),
2240 mrColXFIndexes( rColXFIndexes ),
2241 mnStartColAllDefault( nStartColAllDefault )
2244 void push_back(
XclExpRow *pRow ) { maRows.push_back( pRow ); }
2245 virtual void doWork()
override
2249 p->Finalize( mrColXFIndexes, aXFIndexes, mnStartColAllDefault, mbProgress );
2257 size_t nStartColAllDefault )
2266 const size_t nRows =
maRowMap.size();
2269 const size_t nThreads = 1;
2275 rEntry.second->Finalize( rColXFIndexes, aXFIndexes, nStartColAllDefault,
true );
2281 std::vector<std::unique_ptr<RowFinalizeTask>> aTasks(nThreads);
2282 for (
size_t i = 0;
i < nThreads;
i++ )
2283 aTasks[
i ].reset(
new RowFinalizeTask( pTag, rColXFIndexes, nStartColAllDefault,
i == 0 ) );
2286 for (
const auto& rEntry :
maRowMap )
2288 aTasks[ nIdx % nThreads ]->push_back( rEntry.second.get() );
2292 for (
size_t i = 1;
i < nThreads;
i++ )
2293 rPool.
pushTask( std::move(aTasks[
i ]) );
2296 aTasks[0]->doWork();
2303 std::map< XclExpDefaultRowData, size_t > aDefRowMap;
2306 size_t nMaxDefCount = 0;
2310 std::vector< XclExpRow* > aRepeated;
2311 for (
const auto& rEntry :
maRowMap)
2313 const RowRef& rRow = rEntry.second;
2314 if ( rRow->IsDefaultable() )
2317 size_t& rnDefCount = aDefRowMap[ aDefData ];
2319 if( rnDefCount > nMaxDefCount )
2321 nMaxDefCount = rnDefCount;
2322 aMaxDefData = aDefData;
2332 sal_uInt32 nRpt = rRow->GetXclRow() - pPrev->
GetXclRow();
2334 aRepeated.push_back( pPrev );
2337 size_t& rnDefCount = aDefRowMap[ aDefData ];
2339 if( rnDefCount > nMaxDefCount )
2341 nMaxDefCount = rnDefCount;
2342 aMaxDefData = aDefData;
2349 rDefRowData = aMaxDefData;
2352 for (
auto& rpRow : aRepeated)
2354 if ( rpRow->GetXclRowRpt() > 1
2355 && rpRow->GetHeight() == rDefRowData.
mnHeight
2356 && rpRow->IsHidden() == rDefRowData.
IsHidden() )
2358 rpRow->SetXclRowRpt( 1 );
2365 sal_uInt16 nFirstFreeXclCol = 0;
2367 sal_uInt32 nFirstFreeXclRow = 0;
2369 for (
const auto& rEntry : maRowMap)
2371 const RowRef& rRow = rEntry.second;
2373 rRow->DisableIfDefault( aMaxDefData );
2376 if( !rRow->IsEmpty() )
2378 nFirstUsedXclCol = ::std::min( nFirstUsedXclCol, rRow->GetFirstUsedXclCol() );
2379 nFirstFreeXclCol = ::std::max( nFirstFreeXclCol, rRow->GetFirstFreeXclCol() );
2383 if( rRow->IsEnabled() )
2385 sal_uInt32 nXclRow = rRow->GetXclRow();
2386 nFirstUsedXclRow = ::std::min< sal_uInt32 >( nFirstUsedXclRow, nXclRow );
2387 nFirstFreeXclRow = ::std::max< sal_uInt32 >( nFirstFreeXclRow, nXclRow + 1 );
2392 nFirstUsedXclCol = ::std::min( nFirstUsedXclCol, nFirstFreeXclCol );
2393 nFirstUsedXclRow = ::std::min( nFirstUsedXclRow, nFirstFreeXclRow );
2397 nFirstUsedXclCol, nFirstUsedXclRow, nFirstFreeXclCol, nFirstFreeXclRow );
2408 RowMap::iterator itrBlkStart =
maRowMap.begin(), itrBlkEnd =
maRowMap.begin();
2409 sal_uInt16 nStartXclRow = (nSize == 0) ? 0 : itr->second->GetXclRow();
2411 for (; itr != itrEnd; ++itr)
2414 itrBlkEnd = std::find_if_not(itrBlkEnd, itrEnd,
2415 [&nStartXclRow](
const RowMap::value_type& rRow) {
return rRow.second->GetXclRow() - nStartXclRow <
EXC_ROW_ROWBLOCKSIZE; });
2418 std::for_each(itrBlkStart, itrBlkEnd, [&rStrm](
const RowMap::value_type& rRow) { rRow.second->Save( rStrm ); });
2421 std::for_each(itrBlkStart, itrBlkEnd, [&rStrm](
const RowMap::value_type& rRow) { rRow.second->WriteCellList( rStrm ); });
2423 itrBlkStart = (itrBlkEnd == itrEnd) ? itrBlkEnd : itrBlkEnd++;
2430 if (std::none_of(
maRowMap.begin(),
maRowMap.end(), [](
const RowMap::value_type& rRow) {
return rRow.second->IsEnabled(); }))
2437 rWorksheet->startElement(XML_sheetData);
2438 for (
const auto& rEntry :
maRowMap)
2439 rEntry.second->SaveXml(rStrm);
2440 rWorksheet->endElement( XML_sheetData );
2447 RowMap::iterator itr;
2453 if( last->first == nXclRow )
2454 return *last->second;
2455 if( nXclRow > last->first )
2458 itr =
maRowMap.lower_bound( nXclRow );
2460 const bool bFound = itr !=
maRowMap.end();
2463 const bool bFoundHigher = bFound && itr->first != nXclRow;
2464 if( bFound && !bFoundHigher )
2465 return *itr->second;
2472 pPrevEntry = itr->second;
2476 nFrom = itr->first + 1;
2482 bool bHidden =
false;
2483 SCROW lastSameHiddenRow = -1;
2484 sal_uInt16 nHeight = 0;
2485 SCROW lastSameHeightRow = -1;
2487 while( nFrom <= nXclRow )
2491 if( static_cast<SCROW>(nFrom) > lastSameHiddenRow )
2492 bHidden = rDoc.
RowHidden(nFrom, nScTab,
nullptr, &lastSameHiddenRow);
2496 if( static_cast<SCROW>(nFrom) > lastSameHeightRow )
2497 nHeight = rDoc.
GetRowHeight(nFrom, nScTab,
nullptr, &lastSameHeightRow,
false);
2498 if ( !pPrevEntry || ( nFrom == nXclRow ) ||
2501 ( bRowAlwaysEmpty && !pPrevEntry->IsEmpty() ) ||
2502 ( bHidden != pPrevEntry->IsHidden() ) ||
2503 ( nHeight != pPrevEntry->GetHeight() ) )
2516 return *itr->second;
2523 maColInfoBfr( rRoot ),
2525 maArrayBfr( rRoot ),
2526 maShrfmlaBfr( rRoot ),
2527 maTableopBfr( rRoot ),
2545 SCCOL nLastUsedScCol;
2546 SCROW nLastUsedScRow;
2547 rDoc.
GetTableArea( nScTab, nLastUsedScCol, nLastUsedScRow );
2549 if(nLastUsedScCol > nMaxScCol)
2550 nLastUsedScCol = nMaxScCol;
2553 nLastUsedScRow += 1000;
2555 if(nLastUsedScRow > nMaxScRow)
2556 nLastUsedScRow = nMaxScRow;
2558 ScRange aUsedRange( 0, 0, nScTab, nLastUsedScCol, nLastUsedScRow, nScTab );
2560 nLastUsedScRow = aUsedRange.
aEnd.
Row();
2566 SCROW nFirstUngroupedScRow = 0;
2571 rRowArray.
GetRange( nScStartPos, nScEndPos );
2573 nFirstUngroupedScRow =
static_cast< SCROW >( nScEndPos + 2 );
2582 if( (31871 <= nLastUsedScRow) && (nLastUsedScRow <= 32127) && (nFirstUnflaggedScRow < nLastUsedScRow) && (nFirstUngroupedScRow <= nLastUsedScRow) )
2583 nMaxScRow = nLastUsedScRow;
2587 SCCOL nLastIterScCol = nMaxScCol;
2594 for(
bool bIt = aIt.GetNext(); bIt; bIt = aIt.GetNext() )
2596 SCCOL nScCol = aIt.GetStartCol();
2597 SCROW nScRow = aIt.GetRow();
2598 SCCOL nLastScCol = aIt.GetEndCol();
2599 ScAddress aScPos( nScCol, nScRow, nScTab );
2601 XclAddress aXclPos( static_cast< sal_uInt16 >( nScCol ), static_cast< sal_uInt32 >( nScRow ) );
2602 sal_uInt16 nLastXclCol =
static_cast< sal_uInt16
>( nLastScCol );
2611 bool bIsMergedBase =
false;
2617 bIsMergedBase = rMergeItem.
IsMerged();
2625 OUString aAddNoteText;
2631 double fValue = rScCell.
mfValue;
2636 if (!aUrl.isEmpty())
2645 if( pPattern && ((fValue == 0.0) || (fValue == 1.0)) )
2648 if( rFormatter.
GetType( nScNumFmt ) == SvNumFormatType::LOGICAL )
2650 GetRoot(), aXclPos, pPattern, nMergeBaseXFId, fValue != 0.0 );
2657 GetRoot(), aXclPos, pPattern, nMergeBaseXFId, nRkValue );
2662 GetRoot(), aXclPos, pPattern, nMergeBaseXFId, fValue );
2693 if (!aUrl.isEmpty())
2702 GetRoot(), aXclPos, pPattern, nMergeBaseXFId,
2708 OSL_FAIL(
"XclExpCellTable::XclExpCellTable - unknown cell type" );
2713 GetRoot(), aXclPos, nLastXclCol, pPattern, nMergeBaseXFId );
2718 assert(xCell &&
"can only reach here with xCell set");
2723 if ( !aAddNoteText.isEmpty() )
2738 sal_uInt32 nXFId = xCell->GetFirstXFId();
2740 OSL_ENSURE( (aScRange.
aStart.
Col() == aScRange.
aEnd.
Col()) || (nScCol == nLastScCol),
2741 "XclExpCellTable::XclExpCellTable - invalid repeated blank merged cell" );
2756 mxDval->InsertCellRange( aScRange, nScHandle );
2804 default: OSL_FAIL(
"XclExpCellTable::CreateRecord - unknown record id" );
2822 rWorksheet->startElement( XML_sheetFormatPr,
2828 XML_defaultRowHeight, OString::number(static_cast<double> (rDefData.
mnHeight) / 20.0),
2829 XML_zeroHeight, ToPsz( rDefData.
IsHidden() ),
2832 rWorksheet->endElement( XML_sheetFormatPr );
void SetValue(const Type &rValue)
Sets a new record value.
SC_DLLPUBLIC const ScPatternAttr * GetMostUsedPattern(SCCOL nCol, SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const
sal_uInt16 GetFirstUsedXclCol() const
Returns the column index of the first used cell in this row.
virtual sal_uInt32 GetFirstXFId() const override
Return the XF identifier of the cell.
virtual void Save(XclExpStream &rStrm) override
Writes the complete record list.
SCCOL GetColMerge() const
const sal_uInt16 EXC_TABLEOP_BOTH
XclExpCellBase(sal_uInt16 nRecId, std::size_t nContSize, const XclAddress &rXclPos)
void Finalize()
Finalizes all contained TABLEOP records.
XclExpBlankCell(const XclAddress &rXclPos, const XclExpMultiXFId &rXFId)
static void GetFormulaTypeAndValue(ScFormulaCell &rCell, const char *&sType, OUString &rValue)
const sal_uInt16 EXC_ID2_DIMENSIONS
XclExpColinfoBuffer maColInfoBfr
const sal_uInt16 EXC_STR_MAXLEN
static OString ToOString(const Color &rColor)
virtual void SaveXml(XclExpXmlStream &rStrm) override
sal_uInt32 mnColInpXclRow
Column index of column input cell.
OUString getString() const
bool mbCustomWidth
The XF identifier for column default format.
XclBiff
An enumeration for all Excel file format types (BIFF types).
virtual bool IsEmpty() const override
Returns true, if this record does not contain at least one valid cell.
XclExpShrfmla(const XclTokenArrayRef &xTokArr, const ScAddress &rScPos)
Creates a SHRFMLA record that consists of the passed cell address only.
XclExpStringRec(const XclExpRoot &rRoot, const OUString &rResult)
ScAddress maRowFirstScPos
const sal_uInt8 EXC_ERR_NA
virtual void WriteContents(XclExpStream &rStrm, sal_uInt16 nRelCol) override
Writes the remaining contents of the specified cell (without XF index).
XclExpNumberCell(const XclExpRoot &rRoot, const XclAddress &rXclPos, const ScPatternAttr *pPattern, sal_uInt32 nForcedXFId, double fValue)
The main progress bar for the export filter.
sal_uInt16 mnColWidth
Number of visible column outline levels.
const sal_uInt16 EXC_XF_DEFAULTCELL
Excel index to default style XF.
const XclExpRoot & GetRoot() const
Returns the filter root data.
void ActivateCreateRowsSegment()
Activates the progress segment to create ROW records.
void AppendCell(XclExpCellRef const &xCell, bool bIsMergedBase)
Appends the passed cell object to this row.
static sal_Int32 getPreferredConcurrency()
bool IsEmpty() const
Returns true, if this row does not contain at least one valid cell.
virtual bool IsEmpty() const =0
Derived classes return true, if this record does not contain at least one valid cell.
bool IsAppendable(sal_uInt16 nXclCol, sal_uInt16 nXclRow) const
Returns true, if the passed cell position can be appended to this record.
sal_uInt32 GetStandardFormat() const
Returns the core index of the current standard number format.
This class is used to export Excel record streams.
OStringBuffer & GetStringBuf() const
Clean and return the OStringBuffer.
virtual void SaveXml(XclExpXmlStream &rStrm) override
sal_uInt16 GetXclCol() const
Returns the (first) Excel column index of the cell(s).
virtual bool IsMultiLineText() const
Derived classes return whether the cell contains multi-line text.
XclExpArrayBuffer maArrayBfr
Rows and cell records.
virtual void SaveXml(XclExpXmlStream &rStrm) override
const sal_uInt16 EXC_ID3_STRING
Single reference (one address) into the sheet.
void Init(const XclExpRoot &rRoot, const ScPatternAttr *pPattern, XclExpStringRef const &xText)
Initializes the record contents.
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.
XclExpDimensions maDimensions
Buffer for row outline groups.
const sal_uInt16 EXC_ID_NOTE
size_type count(const Value &v) const
The outline buffer for row outlines.
void Write(XclExpStream &rStrm, bool bCol16Bit=true) const
const sal_uInt16 EXC_FORMULA_SHARED
virtual void Save(XclExpStream &rStrm) override
Writes cell address, XF index, and calls WriteContents() for each cell.
virtual bool IsMultiLineText() const override
Returns true if the cell contains multi-line text.
XclExpBooleanCell(const XclExpRoot &rRoot, const XclAddress &rXclPos, const ScPatternAttr *pPattern, sal_uInt32 nForcedXFId, bool bValue)
void AppendRecord(RecType *pRec)
Appends a record to the list.
const Type & GetValue() const
Returns the value of the record.
static OUString ToOUString(const char *s)
Base class for all cell records not supporting multiple contents.
ScAddress toAbs(const ScSheetLimits &rLimits, const ScAddress &rPos) const
virtual void WriteXmlContents(XclExpXmlStream &rStrm, const XclAddress &rAddress, sal_uInt32 nXFId, sal_uInt16 nRelCol)=0
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.
virtual sal_uInt16 GetLastXclCol() const override
Returns the column index of the last cell this record describes.
const sal_uInt16 EXC_ID2_FORMULA
const XclAddress & GetXclPos() const
Returns the (first) address of the cell(s).
void Progress()
Increases the currently activated (sub) progress bar by 1 step.
constexpr OUStringLiteral last
sal_uInt32 mnXclRow
List of cell records for this row.
bool ValidRange(const ScRange &rRange) const
Represents an RK or MULRK record that describes cells with a compressed double values.
virtual void WriteBody(XclExpStream &rStrm) override
Writes the contents of the record.
const sal_uInt16 EXC_ROW_USEDEFXF
void Finalize(ScfUInt16Vec &rXFIndexes, bool bXLS)
Converts the XF identifiers into the Excel XF indexes and merges equal columns.
bool IsOverlapped() const
sal_uInt16 mnRowWidth
Number of visible row outline levels.
const sal_uInt16 EXC_DEFROW_UNSYNCED
Provides export of hyperlink data.
double GetDefColWidth() const
sal_uInt32 mnFirstFreeXclRow
First used row.
const sal_uInt8 EXC_FORMULA_RES_EMPTY
Result is error code.
Represents the DEFCOLWIDTH record containing the default column width of a sheet. ...
XclExpFormulaCompiler & GetFormulaCompiler() const
Returns the formula compiler to produce formula token arrays.
void SetRecSize(std::size_t nRecSize)
Sets a new record size prediction.
Represents a NOTE record containing the relevant data of a cell note.
void Update(SCROW nScRow)
Updates the current state by processing the settings of the passed Calc row.
virtual void WriteBody(XclExpStream &rStrm) override
Writes cell address, XF index, and calls WriteContents() for each cell.
sal_uInt16 mnHeight
Font color.
const sal_uInt16 EXC_ID3_BOOLERR
XclExpProgressBar & GetProgressBar() const
Returns the export progress bar.
void SetDefWidth(sal_uInt16 nXclColWidth, bool bXLS)
Sets the passed column width (in 1/256 character width) as default width.
const sal_uInt16 EXC_XF_NOTFOUND
Excel index to default cell XF.
virtual void SaveXml(XclExpXmlStream &rStrm) override
XclExpDimensions(const XclExpRoot &rRoot)
Contains the column settings for a range of columns.
const sal_uInt16 EXC_ID2_DEFROWHEIGHT
Represents a BOOLERR record that describes a cell with a Boolean value.
XclExpRecordRef CreateRecord(sal_uInt16 nRecId) const
Returns the reference to an internal record specified by the passed record id.
bool mbEnabled
true = Do not add blank cells in Finalize().
std::size_t GetRecSize() const
Returns the current record size prediction.
XclExpRowOutlineBuffer maOutlineBfr
This is very similar to ScCellValue, except that it references the original value instead of copying ...
sal_uInt8 mnHighestOutlineLevel
Buffer for column outline groups.
void Finalize()
Finalizes the record.
virtual void WriteBody(XclExpStream &rStrm) override
Writes the contents of this COLINFO record.
sal_uInt16 mnFlags
Row height in twips.
void ConvertXFIndexes()
Converts the XF identifier into the Excel XF index.
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
void ActivateFinalRowsSegment()
Activates the progress segment to finalize ROW records.
SvNumberFormatter & GetFormatter() const
Returns the number formatter of the Calc document.
void RemoveInvalidatedRecords()
const sal_uInt16 EXC_DEFROW_DEFAULTHEIGHT
const XclExpXF * GetXFById(sal_uInt32 nXFId) const
Returns an XF record by its unique identifier.
Represents a BLANK or MULBLANK record that describes empty but formatted cells.
virtual void WriteBody(XclExpStream &rStrm) override
Writes the contents of the DIMENSIONS record.
const ScOutlineEntry * GetEntryByPos(size_t nLevel, SCCOLROW nPos) const
sal_uInt16 GetColCount() const
Returns the number of columns represented by this record.
const sal_uInt16 EXC_FORMULA_DEFAULTFLAGS
std::size_t mnContSize
Record ID for multiple record variant.
sal_uInt8 mnOutlineLevel
Default row formatting.
void waitUntilDone(const std::shared_ptr< ThreadTaskTag > &, bool bJoin=true)
sal_uInt32 GetXclRow() const
Returns the Excel row index of the cell.
virtual void WriteContents(XclExpStream &rStrm)=0
Derived classes write the contents of the specified cell (without XF index).
virtual XclTokenArrayRef CreateCellTokenArray(const XclExpRoot &rRoot) const override
Creates and returns the token array for a corresponding FORMULA cell record.
bool TryExtend(const ScAddress &rScPos, const XclMultipleOpRefs &rRefs)
Returns true, if the cell range has been extended to the passed position.
const ScOutlineArray * mpScOLArray
void Finalize(XclExpDefaultRowData &rDefRowData, const ScfUInt16Vec &rColXFIndexes, size_t nStartColAllDefault)
Converts all XF identifiers into the Excel XF indexes and calculates default formats.
XclExpDefrowhRef mxDefrowheight
Buffer for TABLEOP records.
void SetDimensions(sal_uInt16 nFirstUsedXclCol, sal_uInt32 nFirstUsedXclRow, sal_uInt16 nFirstFreeXclCol, sal_uInt32 nFirstFreeXclRow)
Sets the used area to the record.
constexpr TypedWhichId< ScMergeAttr > ATTR_MERGE(144)
const XclExpRoot & mrRoot
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
sal_uInt8 mnOutlineLevel
Additional column flags.
const sal_uInt16 EXC_ID3_DIMENSIONS
sal_uInt16 GetRecId() const
Returns the current record ID.
sal_uInt16 mnLastXclCol
Index to first column.
constexpr auto convertTwipToMm100(N n)
sal_uInt16 mnFirstUsedXclCol
First unused row after used area.
XclExpArrayBuffer(const XclExpRoot &rRoot)
sal_uInt8 mnUsedCount
The token array of a shared formula.
const sal_uInt8 EXC_OUTLINE_MAX
XclExpRecordList< XclExpTableop > maTableopList
Represents an ARRAY record that contains the token array of a matrix formula.
const OUString & GetUrlList() const
Returns a string containing all processed URLs.
void WriteRangeAddress(XclExpStream &rStrm) const
Writes the range address covered by this record.
XclExpMultiCellBase(sal_uInt16 nRecId, sal_uInt16 nMulRecId, std::size_t nContSize, const XclAddress &rXclPos)
virtual bool IsVolatile() const override
Returns true, if the array formula contains volatile functions.
sal_uInt32 mnSstIndex
The cell text.
Access to global data from other classes.
RecType * GetLastRecord() const
Returns reference to the last existing record or empty reference, if list is empty.
const EditTextObject * mpEditText
const sal_uInt16 EXC_FONT_NOTFOUND
Application font index.
bool TryMergeXFIds(const XclExpMultiCellBase &rCell)
Tries to merge the XF ID list of the passed cell with the own list.
sal_uInt16 mnHeight
Default flags for unspecified rows.
static OString lcl_GetStyleId(const XclExpXmlStream &rStrm, sal_uInt32 nXFIndex)
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
SC_DLLPUBLIC SCROW GetLastFlaggedRow(SCTAB nTab) const
sal_Int32 GetXmlCellIndex(sal_uInt32 nXFId) const
virtual bool TryMerge(const XclExpCellBase &rCell) override
Tries to merge the contents of the passed cell to own data.
Helper to create HLINK records during creation of formatted cell strings.
XclExpTableopRef TryCreate(const ScAddress &rScPos, const XclMultipleOpRefs &rRefs)
Tries to create a new TABLEOP record, if rRefs contains valid references.
void DisableIfDefault(const XclExpDefaultRowData &rDefRowData)
Disables this row, if it is defaultable and has the passed default format.
const sal_uInt16 EXC_ID_MERGEDCELLS
XclExpSingleCellBase(sal_uInt16 nRecId, std::size_t nContSize, const XclAddress &rXclPos, sal_uInt32 nXFId)
sal_uInt16 GetCellCount() const
Returns the number of cells this record represents.
sal_uInt16 GetStartColAllDefaultCell() const
Return starting column at which all indexes until the end are EXC_XF_DEFAULTCELL .
constexpr sal_uInt32 NUMBERFORMAT_ENTRY_NOT_FOUND
std::shared_ptr< XclExpRow > RowRef
Represents a SHRFMLA record that contains the token array of a shared formula.
const sal_uInt8 EXC_FORMULA_RES_STRING
std::vector< XclExpLevelInfo > maLevelInfos
Pointer to Calc outline array.
void RemoveUnusedXFIndexes(const ScfUInt16Vec &rXFIndexes, size_t nStartAllNotFound)
Removes unused Excel XF index(es).
virtual void ConvertXFIndexes(const XclExpRoot &rRoot) override
Convert all XF identifiers into the Excel XF indexes.
void WriteCellList(XclExpStream &rStrm)
Writes all cell records of this row.
sal_uInt16 mnWidth
True = Column width is different from default width.
virtual sal_uInt16 GetLastXclCol() const =0
Derived classes return the column index of the last contained cell.
XclExpColOutlineBuffer maOutlineBfr
The DEFCOLWIDTH record.
void Set(sal_uInt16 nCol1, sal_uInt32 nRow1, sal_uInt16 nCol2, sal_uInt32 nRow2)
static bool operator<(const XclExpDefaultRowData &rLeft, const XclExpDefaultRowData &rRight)
sal_uInt16 GetColWidth() const
Returns the Excel width of the column(s).
const sal_uInt16 EXC_ROW_ROWBLOCKSIZE
XclExtLstRef mxExtLst
Data validation with DVAL and DV records.
ScFormulaCell * mpFormula
XclExpShrfmlaBuffer maShrfmlaBfr
Buffer for ARRAY records.
Represents a DEFROWHEIGHT record containing default format for unused rows.
void ConvertXFIndex(const XclExpRoot &rRoot)
Converts the XF identifier in mnXFId to an Excel XF index and stores it in mnXFIndex.
const sal_uInt8 EXC_BOOLERR_BOOL
::std::vector< XclFormatRun > XclFormatRunVec
A vector with all formatting runs for a rich-string.
virtual void SaveXml(XclExpXmlStream &rStrm) override
sal_uInt8 mnScMode
Row index of row input cell.
Stores all number formats used in the document.
const sal_uInt16 EXC_ID3_DEFROWHEIGHT
The outline buffer for column outlines.
XclExpHyperlinkRef mxHyperlinkList
MERGEDCELLS record for merged cell ranges.
sax_fastparser::FSHelperPtr & GetCurrentStream()
virtual XclTokenArrayRef CreateCellTokenArray(const XclExpRoot &rRoot) const override
Creates and returns the token array for a corresponding FORMULA cell record.
virtual void ConvertXFIndexes(const XclExpRoot &rRoot) override
Converts the XF identifier into the Excel XF index.
bool IsCollapsed() const
Returns true, if a collapsed group ends at the last processed position.
bool IsBasePos(sal_uInt16 nXclCol, sal_uInt32 nXclRow) const
Returns true, if the passed cell position is equal to own base position.
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the record (without record header).
void ExtendRange(const ScAddress &rScPos)
Extends the cell range to include the passed cell address.
void GetXFIndexes(ScfUInt16Vec &rXFIndexes) const
Inserts the Excel XF index(es) into the passed vector.
void GetRange(SCCOLROW &rStart, SCCOLROW &rEnd) const
static size_t findFirstAllSameUntilEnd(const ScfUInt16Vec &rIndexes, sal_uInt16 value, size_t searchStart=std::numeric_limits< size_t >::max())
virtual void GetBlankXFIndexes(ScfUInt16Vec &rXFIndexes) const
Derived classes for blank cells insert the Excel XF index(es) into the passed vector.
const sal_uInt16 EXC_ID3_BLANK
void SetDefaultData(const XclExpDefaultRowData &rDefData)
Sets the passed default data as current record contents.
sal_uInt32 mnRowInpXclRow
Column index of row input cell.
bool mbLineBreak
Index into Shared String Table (only used for BIFF8).
bool IsDefaultable() const
Returns true, if this row may be omitted by using the DEFROWHEIGHT record.
virtual void WriteXmlContents(XclExpXmlStream &rStrm, const XclAddress &rAddress, sal_uInt32 nXFId, sal_uInt16 nRelCol) override
const sal_uInt16 EXC_ID_DVAL
Font escapement type modified?
static ThreadPool & getSharedOptimalPool()
XclTokenArrayRef mxTokArr
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALIDDATA(153)
const sal_uInt16 EXC_ID3_NUMBER
bool IsDefault(const XclExpDefcolwidth &rDefColWidth)
Returns true, if the column has default format and width.
XclExpArray(const XclTokenArrayRef &xTokArr, const ScRange &rScRange)
sal_uInt16 mnColInpXclCol
Column index of last appended cell.
sal_uInt16 mnHeight
Excel row index of this row.
bool TryMerge(const XclExpColinfo &rColInfo)
Tries to merge this record with the passed record.
virtual void WriteContents(XclExpStream &rStrm, sal_uInt16 nRelCol) override
Writes the remaining contents of the specified cell (without XF index).
sal_uInt32 GetXFId() const
SC_DLLPUBLIC bool ColHidden(SCCOL nCol, SCTAB nTab, SCCOL *pFirstCol=nullptr, SCCOL *pLastCol=nullptr) const
sal_uInt16 mnFirstFreeXclCol
First used column.
MS Excel 5.0, MS Excel 7.0 (95)
A record with a single value of type Type.
const sal_uInt16 EXC_DEFCOLWIDTH_DEF
Base class for all cell records supporting multiple contents.
const ScAddress & GetMaxPos() const
Returns the highest possible cell address valid in Calc and Excel (using current BIFF version)...
XclExpAddressConverter & GetAddressConverter() const
Returns the address converter.
void IncRowRecordCount()
Increases the number of existing ROW records by 1.
virtual void WriteContents(XclExpStream &rStrm) override
Derived classes write the contents of the specified cell (without XF index).
sal_uInt16 GetFirstFreeXclCol() const
Returns the column index of the first unused cell following all used cells in this row...
XclExpTableopBuffer(const XclExpRoot &rRoot)
void pushTask(std::unique_ptr< ThreadTask > pTask)
XclExpMultiXFIdDeq maXFIds
Data size of contents for one cell.
bool IsUnsynced() const
Returns true, if the rows have a manually set height by default.
const sal_uInt16 EXC_ID_LABELSST
This class contains the DV record list following the DVAL record.
void IncCol(SCCOL nDelta=1)
Caches all ARRAY records.
bool mbCurrCollapse
Highest level of an open group for current position.
XclExpGuts(const XclExpRoot &rRoot)
const ScOutlineArray & GetRowArray() const
const svl::SharedString * mpString
const sal_uInt16 EXC_ROW_DEFAULTFLAGS
sal_uInt16 mnFlags
Calc width of the column.
const ScOutlineArray & GetColArray() const
const sal_uInt16 EXC_ID_COLINFO
void UpdateColRow(SCCOLROW nScPos)
Updates the current state by processing the settings at the passed Calc position. ...
virtual void SaveXml(XclExpXmlStream &rStrm) override
void RemoveRecord(size_t nPos)
Removes the record at the specified position from the list.
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the record (without record header).
const XclFontData & GetAppFontData() const
Returns the application font data of this file, needed e.g.
Represents an XF record which contains all formatting data of a cell or cell style.
XclExpNumFmtBuffer & GetNumFmtBuffer() const
Returns the number format buffer.
const sal_uInt16 EXC_ID_DEFCOLWIDTH
XclExpTableopRef CreateOrExtendTableop(const ScTokenArray &rScTokArr, const ScAddress &rScPos)
Tries to update an existing or to create a new TABLEOP record.
sal_uInt16 mnXFIndex
Flags for the ROW record.
XclExpArrayRef FindArray(const ScTokenArray &rScTokArr, const ScAddress &rBasePos) const
Tries to find an ARRAY record that corresponds to an ocMatRef token.
virtual void WriteBody(XclExpStream &rStrm) override
Writes the contents of the ROW record.
void Initialize(SCROW nLastScRow)
Initializes the buffer: finds settings and formatting of all columns.
XclExpHyperlinkRef GetLinkRecord() const
Returns the created single HLINk record, or an empty reference.
Represents a STRING record that contains the result of a string formula.
void CreateRows(SCROW nFirstFreeScRow)
Forces insertion of all ROW records before the passed row.
void InsertRecord(RecType *pRec, size_t nPos)
Inserts a record at the specified position into the list.
void IncRow(SCROW nDelta=1)
XclExpCellTable(const XclExpRoot &rRoot)
SfxItemSet & GetItemSet()
bool HasMultipleUrls() const
Returns true, if multiple URLs have been processed.
void EndRecord()
Checks and corrects real record length.
XclExpNoteListRef mxNoteList
GUTS record for outline areas.
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALUE_FORMAT(146)
The base class of all cell records.
const sal_uInt16 EXC_ARRAY_RECALC_ALWAYS
bool mbLineBreak
Indentation.
bool IsDefWidth(sal_uInt16 nXclColWidth) const
Returns true, if the own default width exactly matches the passed width.
const sal_uInt16 EXC_ROW_COLLAPSED
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...
virtual XclTokenArrayRef CreateCellTokenArray(const XclExpRoot &rRoot) const override
Creates and returns the token array for a corresponding FORMULA cell record.
Represents a TABLEOP record for a multiple operations range.
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
void Finalize(bool bXLS)
Converts all XF identifiers into the Excel XF indexes and calculates default formats.
sal_uInt32 GetXclRow() const
Returns the excel row index of this ROW record.
virtual void SaveXml(XclExpXmlStream &rStrm) override
sal_uInt16 mnRowInpXclCol
Row index of column input cell.
const sal_uInt16 EXC_ROW_HIDDEN
#define SV_COUNTRY_LANGUAGE_OFFSET
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the record (without record header).
RecType * GetFirstRecord() const
Returns reference to the first existing record or empty reference, if list is empty.
sal_uInt32 mnXclRowRpt
Outline Level of row (for OOXML)
A 2D cell address struct with Excel column and row indexes.
XclExpDefaultRowData()
Default height for unspecified rows.
XclExpRow & GetOrCreateRow(sal_uInt32 nXclRow, bool bRowAlwaysEmpty)
Returns access to the specified ROW record.
Contains all possible default row settings.
bool HasLinkRecord() const
Returns true, if a single HLINK record has been created.
std::shared_ptr< FastSerializerHelper > FSHelperPtr
const sal_uInt16 EXC_DEFROW_HIDDEN
void AppendXFId(const XclExpMultiXFId &rXFId)
Appends the passed XF identifier nCount times to the list of XF identifiers.
void AppendNewRecord(RecType *pRec)
Appends a newly created record to the list.
sal_uInt16 GetXFIndex() const
Returns the final Excel XF index of the column(s).
void InvalidateRecord(size_t nPos)
Optimization for repeated removal.
XclExpColinfoBuffer(const XclExpRoot &rRoot)
bool ValidateRange(ScRange &rScRange, bool bWarn)
Checks and eventually crops the cell range to valid dimensions.
virtual bool IsEmpty() const override
Returns true, if this record does not contain at least one valid cell.
void Set(sal_uInt16 nCol, sal_uInt32 nRow)
const sal_uInt16 EXC_ID_MULRK
sal_Int16 GetDefApiScript() const
Returns the default script type, e.g.
sal_uInt8 GetHighestOutlineLevel() const
const XclExpRoot & GetRoot() const
Returns this root instance - for code readability in derived classes.
XclExpSst & GetSst() const
Returns the shared string table.
virtual bool TryMerge(const XclExpCellBase &rCell)
Derived classes try to merge the contents of the passed cell to own data.
SCTAB GetCurrScTab() const
Returns the current Calc sheet index.
sal_uInt8 mnCurrLevel
Info for current row and all levels.
virtual sal_uInt32 GetFirstXFId() const override
Return the XF identifier of the first contained cell.
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.
const sal_uInt32 EXC_XFID_NOTFOUND
Special index for "not found" state.
const sal_uInt16 EXC_FORMULA_RECALC_ALWAYS
XclExpTableop(const ScAddress &rScPos, const XclMultipleOpRefs &rRefs, sal_uInt8 nScMode)
Base record for additional range formula records (i.e.
const sal_uInt16 EXC_ID_GUTS
const sal_uInt16 EXC_TABLEOP_RECALC_ALWAYS
RecType * GetRecord(size_t nPos) const
Returns reference to an existing record or empty reference on error.
static sal_uInt32 GetDefCellXFId()
Returns the XF identifier representing the default cell XF.
bool IsValidTokenArray(const ScTokenArray &rArray) const
Check for presence of token that's not allowed in Excel's shared formula.
XclExpRowBuffer(const XclExpRoot &rRoot)
XclExpDefcolwidth maDefcolwidth
List of COLINFO records.
virtual bool IsVolatile() const override
Returns true, if the shared formula contains volatile functions.
constexpr TypedWhichId< ScMergeFlagAttr > ATTR_MERGE_FLAG(145)
virtual void GetBlankXFIndexes(ScfUInt16Vec &rXFIndexes) const override
Inserts the Excel XF index(es) into the passed vector.
const sal_uInt16 EXC_TABLEOP_ROW
std::size_t mnContSize
The XF identifier of the cell formatting.
virtual void RemoveUnusedBlankCells(const ScfUInt16Vec &rXFIndexes, size_t nStartAllNotFound) override
Tries to remove unused Excel XF index(es).
void SetContSize(std::size_t nContSize)
XclExpDefcolwidth(const XclExpRoot &rRoot)
virtual bool TryMerge(const XclExpCellBase &rCell) override
Tries to merge the contents of the passed cell to own data.
const XclExpCellAlign & GetAlignmentData() const
Returns the alignment settings of this XF.
Represents a GUTS record containing the level count of row and column outlines.
void SetRecHeader(sal_uInt16 nRecId, std::size_t nRecSize)
Sets record ID and size with one call.
XclExpOutlineBuffer(const XclExpRoot &rRoot, bool bRows)
Constructs the outline buffer.
XclAddress maBaseXclPos
Range described by this record.
Represents a ROW record and additionally contains all cells records of a row.
const sal_uInt16 EXC_ID_RSTRING
virtual void SaveXml(XclExpXmlStream &rStrm) override
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.
Contains all cell references that can be extracted from a multiple operations formula.
const sal_uInt8 EXC_FORMULA_RES_BOOL
Result is a string.
XclTokenArrayRef mxTokArr
XclExpColinfo(const XclExpRoot &rRoot, SCCOL nScCol, SCROW nLastScRow, XclExpColOutlineBuffer &rOutlineBfr)
Constructs the record with the settings in the Calc document.
XclExpShrfmlaBuffer(const XclExpRoot &rRoot)
virtual void Save(XclExpStream &rStrm) override
Writes all COLINFO records of this buffer.
void Extend(const ScAddress &rScPos)
Extends the cell range to include the passed cell address.
void AppendCell(XclExpCellRef const &xCell, bool bIsMergedBase)
Appends the passed cell object to the row that the cell specifies.
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
SC_DLLPUBLIC bool GetTableArea(SCTAB nTab, SCCOL &rEndCol, SCROW &rEndRow, bool bCalcHiddens=false) const
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.
void Finalize(const ScfUInt16Vec &rColXFIndexes, ScfUInt16Vec &aXFIndexes, size_t nStartColAllDefault, bool bUpdateProgress)
Converts all XF identifiers into the Excel XF indexes.
XclExpArrayRef CreateArray(const ScTokenArray &rScTokArr, const ScRange &rScRange)
Inserts a new ARRAY record into the buffer and returns it.
sal_uInt32 GetXclRowRpt() const
XclExpShrfmlaRef CreateOrExtendShrfmla(const ScFormulaCell &rScCell, const ScAddress &rScPos)
Tries to create a new or to update an existing SHRFMLA record.
const sal_uInt16 EXC_ID_MULBLANK
virtual void SaveXml(XclExpXmlStream &rStrm) override
XclExpRangeFmlaBase(sal_uInt16 nRecId, sal_uInt32 nRecSize, const ScAddress &rScPos)
Constructs the record with a single cell.
XclExpDefaultRowData maDefData
std::size_t GetContSize() const
virtual void SaveXml(XclExpXmlStream &rStrm) override
Caches all SHRFMLA records and provides functions to update their ranges.
Represents a NUMBER record that describes a cell with a double value.
void Update(SCCOL nScCol)
Updates the current state by processing the settings of the passed Calc column.
virtual void Save(XclExpStream &rStrm) override
Saves the entire cell table.
Represents a MERGEDCELLS record containing all merged cell ranges in a sheet.
virtual sal_uInt32 GetFirstXFId() const =0
Derived classes return the XF identifier of the first contained cell.
virtual void WriteContents(XclExpStream &rStrm, sal_uInt16 nRelCol)=0
Derived classes write the remaining contents of the specified cell (without XF index).
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the record (without record header).
void InsertCell(XclExpCellRef xCell, size_t nPos, bool bIsMergedBase)
Inserts a cell at the specified list position, tries to merge with neighbors.
SC_DLLPUBLIC ScOutlineTable * GetOutlineTable(SCTAB nTab, bool bCreate=false)
sal_uInt32 Insert(const ScPatternAttr *pPattern, sal_Int16 nScript)
Finds or creates a cell XF record for the passed item set.
const sal_uInt16 EXC_ID_RK
static std::shared_ptr< ThreadTaskTag > createThreadTaskTag()
const sal_uInt16 EXC_COLINFO_HIDDEN
Contains all created TABLEOP records and supports creating or updating them.
sal_uInt16 mnXFIndex
Temporary XF identifier.
XclBiff GetBiff() const
Returns the current BIFF version of the importer/exporter.
const sal_uInt16 EXC_TABLEOP_DEFAULTFLAGS
void SetXclCol(sal_uInt16 nXclCol)
Sets this record to a new column position.
const sal_uInt16 EXC_ID_HLINK
const sal_uInt8 EXC_LABEL_MAXLEN
virtual void SaveXml(XclExpXmlStream &rStrm) override
XclExpRecordList< XclExpCellBase > maCellList
const sal_uInt16 EXC_ID3_TABLEOP
const sal_uInt16 EXC_ID3_ARRAY
sal_uInt32 Insert(const XclExpStringRef &xString)
Inserts a new string into the table.
constexpr TypedWhichId< SfxStringItem > ATTR_HYPERLINK(155)
virtual bool IsVolatile() const override
Returns true, if the multiple operations range is volatile.
SC_DLLPUBLIC bool RowHidden(SCROW nRow, SCTAB nTab, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
Complex reference (a range) into the sheet.
This class provides methods to create an XclExpString.
void StartRecord(sal_uInt16 nRecId, std::size_t nRecSize)
Starts a new record: writes header data, stores calculated record size.
virtual void WriteXmlContents(XclExpXmlStream &rStrm, const XclAddress &rAddress, sal_uInt32 nXFId, sal_uInt16 nRelCol) override
bool mbValid
Type of the multiple operation (Calc constant).
sal_uInt16 mnRowLevels
Width of column outline area (pixels).
bool IsHidden() const
Returns true, if rows are hidden by default.
void SetXFId(sal_uInt32 nXFId)
const sal_uInt8 EXC_FORMULA_RES_ERROR
Result is Boolean value.
const sal_uInt16 EXC_ID3_ROW
const sal_uInt16 EXC_ROW_UNSYNCED
virtual void WriteContents(XclExpStream &rStrm) override
Derived classes write the contents of the specified cell (without XF index).
sal_uInt8 mnHighestOutlineLevel
DIMENSIONS record for used area.
bool FindTouchedLevel(SCCOLROW nBlockStart, SCCOLROW nBlockEnd, size_t &rFindLevel) const
virtual void RemoveUnusedBlankCells(const ScfUInt16Vec &rXFIndexes, size_t nStartAllNotFound)
Derived classes for blank cells remove unused Excel XF index(es).
SCROW GetRowMerge() const
const sal_uInt16 EXC_ID_SHRFMLA
XclExpRowBuffer maRowBfr
Buffer for column formatting.
const sal_uInt16 EXC_ARRAY_DEFAULTFLAGS
std::shared_ptr< XclExpString > XclExpStringRef
XclExpColinfoList maColInfos
const sal_uInt16 EXC_COLINFO_COLLAPSED
const XclExpRoot & GetRoot() const
Returns the filter root data.
bool IsHidden() const
Returns true, if this row is hidden.
XclExpRecordRef mxGuts
DEFROWHEIGHT record for default row format.
std::pair< const_iterator, bool > insert(Value &&x)
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
virtual void Save(XclExpStream &rStrm) override
Writes the record, calls WriteContents() for each contained cell.
virtual void WriteBody(XclExpStream &rStrm) override
Writes the contents of the TABLEOP record.
BadTokenArraysType maBadTokens
Map containing the SHRFMLA records.
sal_uInt16 mnScWidth
Excel width of the column.
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
sal_uInt16 mnLastAppXclCol
sal_uInt8 GetLevel() const
Returns the highest level of an open group at the last processed position.
XclExpXFBuffer & GetXFBuffer() const
Returns the cell formatting attributes buffer.
void SetRecId(sal_uInt16 nRecId)
Sets a new record ID.
virtual void ConvertXFIndexes(const XclExpRoot &rRoot)=0
Derived classes convert the XF identifier(s) into the Excel XF index(es).
tools::Long GetCharWidth() const
Returns the width of the '0' character (default font) for the current printer (twips).
XclExpFontBuffer & GetFontBuffer() const
Returns the font buffer.
virtual void WriteContents(XclExpStream &rStrm) override
Derived classes write the contents of the specified cell (without XF index).
XclExpTableopBuffer maTableopBfr
Buffer for SHRFMLA records.
sc::CompileFormulaContext & GetCompileFormulaContext() const
Represents a text cell record.
sal_uInt16 mnFirstXclCol
Outline Level of column (for OOXML)
sal_uInt8 GetHighestOutlineLevel() const
void SetXclRowRpt(sal_uInt32 nRpt)
virtual void Save(XclExpStream &rStrm) override
Writes the DIMENSIONS record, all ROW records and all cell records.
virtual sal_uInt16 GetLastXclCol() const override
Returns the last column, which is equal to the first column for single cells.
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.
bool IsUnsynced() const
Returns true, if this row contains a manually set height.
const sal_uInt16 EXC_ID_EXTLST
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.
sal_uInt32 mnFirstUsedXclRow
XclExpRkCell(const XclExpRoot &rRoot, const XclAddress &rXclPos, const ScPatternAttr *pPattern, sal_uInt32 nForcedXFId, sal_Int32 nRkValue)
virtual void Save(XclExpStream &rStrm) override
Writes the record if it is valid.
Base class for single records with any content.
XclExpMergedcellsRef mxMergedcells
List of NOTE records.
SC_DLLPUBLIC CRFlags GetRowFlags(SCROW nRow, SCTAB nTab) const
ScAddress maColFirstScPos
Position of the (first) formula cell.
virtual void Save(XclExpStream &rStrm) override
Writes the ROW record if the row is not disabled (see DisableIfDefault() function).
const sal_uInt16 EXC_ID3_LABEL
bool m_bDetectedRangeSegmentation false
const sal_uInt16 EXC_DEFROW_DEFAULTFLAGS
sal_uInt16 GetXFIndex(sal_uInt32 nXFId) const
Returns the Excel XF index of the XF record with passed XF ID.
void AddRecSize(std::size_t nRecSize)
Adds a size value to the record size prediction.
XclExpDvalRef mxDval
List of HLINK records.