25#include <oox/token/namespaces.hxx>
26#include <oox/token/tokens.hxx>
36using ::oox::core::ContextHandlerRef;
42const sal_uInt32 BIFF12_CELL_SHOWPHONETIC = 0x01000000;
44const sal_uInt8 BIFF12_DATATABLE_ROW = 0x01;
45const sal_uInt8 BIFF12_DATATABLE_2D = 0x02;
46const sal_uInt8 BIFF12_DATATABLE_REF1DEL = 0x04;
47const sal_uInt8 BIFF12_DATATABLE_REF2DEL = 0x08;
49const sal_uInt16 BIFF12_ROW_THICKTOP = 0x0001;
50const sal_uInt16 BIFF12_ROW_THICKBOTTOM = 0x0002;
51const sal_uInt16 BIFF12_ROW_COLLAPSED = 0x0800;
52const sal_uInt16 BIFF12_ROW_HIDDEN = 0x1000;
53const sal_uInt16 BIFF12_ROW_CUSTOMHEIGHT = 0x2000;
54const sal_uInt16 BIFF12_ROW_CUSTOMFORMAT = 0x4000;
55const sal_uInt8 BIFF12_ROW_SHOWPHONETIC = 0x01;
61 mrAddressConv( rFragment.getAddressConverter() ),
62 mrSheetData( rFragment.getSheetData() ),
63 mnSheet( rFragment.getSheetIndex() ),
64 mbHasFormula( false ),
65 mbValidRange( false ),
69 SAL_INFO(
"sc.filter",
"start safe sheet data context - unlock" );
75 SAL_INFO(
"sc.filter",
"end safe sheet data context - relock" );
80 switch( getCurrentElement() )
82 case XLS_TOKEN( sheetData ):
83 if( nElement == XLS_TOKEN( row ) ) {
importRow( rAttribs );
return this; }
86 case XLS_TOKEN( row ):
88 if( nElement == XLS_TOKEN( c ) &&
importCell( rAttribs ) )
111 switch( getCurrentElement() )
127 if( getCurrentElement() != XLS_TOKEN( c ) )
194 if (!bValue &&
maCellValue.equalsIgnoreAsciiCase(
u"true"))
227 switch( getCurrentElement() )
270 sal_Int32 nRow = rAttribs.
getInteger( XML_r, -1 );
298 OUString aColSpansText = rAttribs.
getString( XML_spans, OUString() );
303 size_t nSepPos = aColSpanToken.find(
':' );
304 if( (0 < nSepPos) && (nSepPos + 1 < aColSpanToken.size()) )
307 const sal_Int32 nCol1 =
o3tl::toInt32(aColSpanToken.substr( 0, nSepPos )) - 1;
311 const sal_Int32 nCol2 =
o3tl::toInt32(aColSpanToken.substr( nSepPos + 1 )) - 1;
324 std::string_view
p = rAttribs.
getView(XML_r);
380 sal_Int32 nSpanCount;
381 sal_uInt16 nHeight, nFlags1;
385 nHeight =
rStrm.readuInt16();
386 nFlags1 =
rStrm.readuInt16();
387 nFlags2 =
rStrm.readuChar();
388 nSpanCount =
rStrm.readInt32();
396 aModel.
mnLevel = extractValue< sal_Int32 >( nFlags1, 8, 3 );
406 for( sal_Int32 nSpanIdx = 0; (nSpanIdx < nSpanCount) && !
rStrm.isEof(); ++nSpanIdx )
408 sal_Int32 nFirstCol, nLastCol;
409 nFirstCol =
rStrm.readInt32();
411 nLastCol =
rStrm.readInt32();
428 sal_uInt32 nXfId =
rStrm.readuInt32();
458 bool bValue =
rStrm.readuInt8() != 0;
468 OSL_ENSURE( eCellType !=
CELLTYPE_FORMULA,
"SheetDataContext::importCellBlank - no formula cells supported" );
478 double fValue =
rStrm.readDouble();
501 OSL_ENSURE( eCellType !=
CELLTYPE_FORMULA,
"SheetDataContext::importCellRk - no formula cells supported" );
511 OSL_ENSURE( eCellType !=
CELLTYPE_FORMULA,
"SheetDataContext::importCellRString - no formula cells supported" );
516 xString->importString(
rStrm,
true, *
this );
517 xString->finalizeImport( *
this );
524 OSL_ENSURE( eCellType !=
CELLTYPE_FORMULA,
"SheetDataContext::importCellSi - no formula cells supported" );
539 xString->importString(
rStrm,
false, *
this );
540 xString->finalizeImport( *
this );
565 rStrm >> aRef1 >> aRef2;
566 nFlags =
rStrm.readuChar();
std::optional< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
std::string_view getView(sal_Int32 nAttrToken) const
std::optional< OUString > getString(sal_Int32 nAttrToken) const
std::optional< bool > getBool(sal_Int32 nAttrToken) const
std::optional< sal_Int32 > getToken(sal_Int32 nAttrToken) const
std::optional< double > getDouble(sal_Int32 nAttrToken) const
XmlFilterBase & getFilter() const
bool isMSODocument() const
bool convertToCellAddress(ScAddress &orAddress, const OUString &rString, sal_Int16 nSheet, bool bTrackOverflow)
Tries to convert the passed string to a single cell address.
bool checkCellAddress(const ScAddress &rAddress, bool bTrackOverflow)
Checks the passed cell address if it fits into the spreadsheet limits.
bool checkRow(sal_Int32 nRow, bool bTrackOverflow)
Checks if the passed row index is valid.
bool checkCol(sal_Int32 nCol, bool bTrackOverflow)
Checks if the passed column index is valid.
bool convertToCellRange(ScRange &orRange, std::u16string_view aString, sal_Int16 nSheet, bool bAllowOverflow, bool bTrackOverflow)
Tries to convert the passed string to a cell range address.
static double calcDoubleFromRk(sal_Int32 nRkValue)
Converts the passed packed number to a double.
void setErrorCell(const CellModel &rModel, const OUString &rErrorCode)
Inserts an error cell from the passed error code into the sheet.
void setBlankCell(const CellModel &rModel)
Inserts a blank cell (with formatting) into the sheet.
void createTableOperation(const ScRange &rRange, const DataTableModel &rModel)
Sets a multiple table operation to the passed range.
void setDateCell(const CellModel &rModel, const OUString &rDateString)
Inserts an ISO 8601 date cell into the sheet.
void setCellFormat(const CellModel &rModel)
Processes the cell formatting data of the passed cell.
void setValueCell(const CellModel &rModel, double fValue)
Inserts a value cell into the sheet.
void createSharedFormula(const ScAddress &rRange, const ApiTokenSequence &rTokens)
void setFormulaCell(const CellModel &rModel, const ApiTokenSequence &rTokens)
Inserts a formula cell into the sheet.
void setBooleanCell(const CellModel &rModel, bool bValue)
Inserts a boolean cell into the sheet and adjusts number format.
void setStringCell(const CellModel &rModel, const OUString &rText)
Inserts a simple string cell into the sheet.
void createArrayFormula(const ScRange &rRange, const ApiTokenSequence &rTokens)
Inserts the passed token array as array formula.
void importCellString(SequenceInputStream &rStrm, CellType eCellType)
Imports a string cell from a CELL_STRING, MULTCELL_STRING, or FORMULA_STRING record.
CellFormulaModel maFmlaData
Position, contents, formatting of current imported cell.
SheetDataContext(WorksheetFragmentBase &rFragment)
void importCellBool(SequenceInputStream &rStrm, CellType eCellType)
Imports a boolean cell from a CELL_BOOL, MULTCELL_BOOL, or FORMULA_BOOL record.
void importSharedFmla(SequenceInputStream &rStrm)
Imports a shared formula from a SHAREDFORMULA record.
void importCellRString(SequenceInputStream &rStrm, CellType eCellType)
Imports a rich-string cell from a CELL_RSTRING or MULTCELL_RSTRING record.
bool readFormulaRef(SequenceInputStream &rStrm)
Reads the formula range used by shared formulas, arrays, and data tables.
RichStringRef mxInlineStr
Cell value string (OOXML only).
SheetDataBuffer & mrSheetData
The formula parser, different one for each SheetDataContext.
bool mbValidRange
True = current cell has formula data (OOXML only).
virtual void onCharacters(const OUString &rChars) override
void importCellDouble(SequenceInputStream &rStrm, CellType eCellType)
Imports a numeric cell from a CELL_DOUBLE, MULTCELL_DOUBLE, or FORMULA_DOUBLE record.
virtual ::oox::core::ContextHandlerRef onCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm) override
sal_Int32 mnRow
True = maFmlaData.maFormulaRef is valid (OOXML only).
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
void importCellBlank(SequenceInputStream &rStrm, CellType eCellType)
Imports an empty cell from a CELL_BLANK or MULTCELL_BLANK record.
virtual ~SheetDataContext() override
BinAddress maCurrPos
Settings for table operations.
void importCellRk(SequenceInputStream &rStrm, CellType eCellType)
Imports an encoded numeric cell from a CELL_RK or MULTCELL_RK record.
void importDataTable(SequenceInputStream &rStrm)
Imports table operation from a DATATABLE record.
sal_Int16 mnSheet
Settings for a cell formula.
DataTableModel maTableData
void importArray(SequenceInputStream &rStrm)
Imports an array formula from an ARRAY record.
void importCellError(SequenceInputStream &rStrm, CellType eCellType)
Imports an error code cell from a CELL_ERROR, MULTCELL_ERROR, or FORMULA_ERROR record.
bool importCell(const AttributeList &rAttribs)
Imports cell settings from a c element.
CellType
Different types of cell records.
virtual void onEndElement() override
void importRow(const AttributeList &rAttribs)
Imports row settings from a row element.
void importCellSi(SequenceInputStream &rStrm, CellType eCellType)
Imports a string cell from a CELL_SI or MULTCELL_SI record.
CellModel maCellData
The sheet data buffer for cell content and formatting.
std::unique_ptr< FormulaParser > mxFormulaParser
The address converter.
bool readCellHeader(SequenceInputStream &rStrm, CellType eCellType)
Reads a cell address and the following XF identifier.
bool mbHasFormula
Current cell position (BIFF12 only).
AddressConverter & mrAddressConv
void importFormula(const AttributeList &rAttribs)
Imports cell settings from an f element.
sal_Int32 mnCol
row index (0-based)
OUString maFormulaStr
Inline rich string (OOXML only).
ApiTokenSequence readCellFormula(SequenceInputStream &rStrm)
Reads a cell formula for the current cell.
FormulaParser * createFormulaParser() const
Returns an unshared import formula parser (import filter only!).
Context handler derived from the WorksheetHelper helper class.
Fragment handler derived from the WorksheetHelper helper class.
void setCellFormula(const ScAddress &rTokenAddress, const OUString &)
void extendUsedArea(const ScAddress &rAddress)
Extends the used area of this sheet by the passed cell position.
void createSharedFormulaMapEntry(const ScAddress &rAddress, sal_Int32 nSharedId, const OUString &rTokens)
void setCellArrayFormula(const ScRange &rRangeAddress, const ScAddress &rTokenAddress, const OUString &rTokenStr)
void setRowModel(const RowModel &rModel)
Sets row settings for a specific range of rows.
void setCellFormulaValue(const ScAddress &rAddress, const OUString &rValueStr, sal_Int32 nCellType)
#define SAL_INFO(area, stream)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
const sal_Int32 BIFF12_ID_MULTCELL_SI
const sal_Int32 BIFF12_ID_DATATABLE
const sal_Int32 BIFF12_ID_CELL_RK
css::uno::Sequence< ApiToken > ApiTokenSequence
const sal_Int32 BIFF12_ID_CELL_BOOL
const sal_Int32 BIFF12_ID_SHAREDFMLA
const sal_Int32 BIFF12_ID_MULTCELL_BOOL
const sal_Int32 BIFF12_ID_MULTCELL_RSTRING
@ Array
Simple cell formula, or reference to a shared formula name.
@ SharedFormula
Array (matrix) formula.
const sal_Int32 BIFF12_ID_CELL_RSTRING
const sal_Int32 BIFF12_ID_FORMULA_STRING
const sal_Int32 BIFF12_ID_CELL_BLANK
const sal_Int32 BIFF12_ID_CELL_SI
const sal_Int32 BIFF12_ID_MULTCELL_RK
const sal_Int32 BIFF12_ID_ROW
const sal_Int32 BIFF12_ID_FORMULA_DOUBLE
const sal_Int32 BIFF12_ID_CELL_STRING
const sal_Int32 BIFF12_ID_MULTCELL_BLANK
const sal_Int32 BIFF12_ID_CELL_DOUBLE
const sal_Int32 BIFF12_ID_MULTCELL_ERROR
const sal_Int32 BIFF12_ID_MULTCELL_DOUBLE
const sal_Int32 BIFF12_ID_FORMULA_BOOL
const sal_Int32 BIFF12_ID_FORMULA_ERROR
const sal_Int32 BIFF12_ID_ARRAY
const sal_Int32 BIFF12_ID_MULTCELL_STRING
const sal_Int32 BIFF12_ID_CELL_ERROR
const sal_Int32 BIFF12_ID_SHEETDATA
std::shared_ptr< RichString > RichStringRef
bool getFlag(Type nBitField, Type nMask)
A 2D cell address struct for binary filters.
A 2D cell range address struct for binary filters.
bool mbShowPhonetic
XF (cell formatting) identifier.
sal_Int32 mnXfId
Data type of the cell value.
sal_Int32 mnCellType
The address of the current cell.
bool mbRef2Deleted
True = first reference cell deleted.
bool mb2dTable
Second reference cell for table operations.
OUString maRef2
First reference cell for table operations.
bool mbRowTable
True = 2-dimensional data table.
bool mbRef1Deleted
True = row oriented data table.
Stores settings and formatting data about a sheet row.
double mfHeight
1-based (!) index of the described row.
bool mbCustomHeight
Row outline level.
sal_Int32 mnLevel
Row default formatting (see mbIsFormatted).
bool mbCollapsed
True = row is hidden.
bool mbThickBottom
True = row has extra space above text.
sal_Int32 mnXfId
Row height in points.
bool mbShowPhonetic
True = cells in row have explicit formatting.
bool mbCustomFormat
True = row has custom height.
bool mbThickTop
True = row outline is collapsed.
bool mbHidden
True = cells in row show phonetic settings.