23#include <osl/diagnose.h>
27#include <oox/token/namespaces.hxx>
28#include <oox/token/tokens.hxx>
53const sal_uInt16 BIFF_COLINFO_HIDDEN = 0x0001;
54const sal_uInt16 BIFF_COLINFO_SHOWPHONETIC = 0x0008;
55const sal_uInt16 BIFF_COLINFO_COLLAPSED = 0x1000;
57const sal_uInt16 BIFF_DEFROW_CUSTOMHEIGHT = 0x0001;
58const sal_uInt16 BIFF_DEFROW_HIDDEN = 0x0002;
59const sal_uInt16 BIFF_DEFROW_THICKTOP = 0x0004;
60const sal_uInt16 BIFF_DEFROW_THICKBOTTOM = 0x0008;
62const sal_uInt32 BIFF_DATAVAL_STRINGLIST = 0x00000080;
63const sal_uInt32 BIFF_DATAVAL_ALLOWBLANK = 0x00000100;
64const sal_uInt32 BIFF_DATAVAL_NODROPDOWN = 0x00000200;
65const sal_uInt32 BIFF_DATAVAL_SHOWINPUT = 0x00040000;
66const sal_uInt32 BIFF_DATAVAL_SHOWERROR = 0x00080000;
68const sal_Int32 BIFF12_OLEOBJECT_ICON = 4;
69const sal_Int32 BIFF12_OLEOBJECT_ALWAYS = 1;
70const sal_uInt16 BIFF12_OLEOBJECT_LINKED = 0x0001;
71const sal_uInt16 BIFF12_OLEOBJECT_AUTOLOAD = 0x0002;
86 rTarget.getFormulaParser().convertStringToStringList(
mxValModel->maTokens1,
',',
true);
122 nFlags =
rStrm.readuInt32();
126 aModel.
setBiffType(extractValue< sal_uInt8 >(nFlags, 0, 4));
135 rTarget.getAddressConverter().convertToCellRangeList(aModel.
maRanges, aRanges,
rTarget.getSheetIndex(),
true);
143 if ((aModel.
mnType == XML_list) &&
getFlag(nFlags, BIFF_DATAVAL_STRINGLIST))
157 switch( getCurrentElementWithMce() )
159 case XLS_TOKEN( dataValidations ):
160 if( nElement == XLS_TOKEN( dataValidation ) )
166 case XLS_TOKEN( dataValidation ):
169 case MCE_TOKEN( AlternateContent ):
170 case XLS_TOKEN( formula1 ):
171 case XLS_TOKEN( formula2 ):
175 case MCE_TOKEN( AlternateContent ):
178 case MCE_TOKEN( Choice ):
179 case MCE_TOKEN( Fallback ):
183 case MCE_TOKEN( Choice ):
186 case X12AC_TOKEN( list ):
190 case MCE_TOKEN( Fallback ):
193 case XLS_TOKEN( formula1 ):
197 case XLS_TOKEN( formula2 ):
209OUString NormalizeOoxList(std::u16string_view aList)
211 OUStringBuffer aResult(
"\"");
212 bool bInsideQuotes =
false;
213 const size_t nLen = aList.size();
214 for (
size_t i = 0;
i < nLen; ++
i)
221 bInsideQuotes = !bInsideQuotes;
226 aResult.append(
"\",\"");
235 return aResult.append(
'"').makeStringAndClear();
241 switch( getCurrentElement() )
243 case XLS_TOKEN( formula1 ):
246 case XLS_TOKEN( formula2 ):
249 case X12AC_TOKEN( list ):
257 if( getCurrentElementWithMce() == XLS_TOKEN( dataValidation ) )
277 switch( getCurrentElement() )
279 case XLS14_TOKEN( dataValidations ):
280 if ( nElement == XLS14_TOKEN( dataValidation ) )
286 case XLS14_TOKEN( dataValidation ):
289 case XLS14_TOKEN( formula1 ):
290 case XLS14_TOKEN( formula2 ):
293 case XM_TOKEN( sqref ):
297 case XLS14_TOKEN( formula1 ):
298 case XLS14_TOKEN( formula2 ):
311 switch( getCurrentElement() )
316 case XLS14_TOKEN( formula1 ):
319 case XLS14_TOKEN( formula2 ):
324 case XM_TOKEN( sqref ):
332 if( isCurrentElement( XLS14_TOKEN( dataValidation ) ) )
342 RelationsRef xTableRels = getRelations().getRelationsFromTypeFromOfficeDoc(
u"table" );
343 for(
const auto& rEntry : *xTableRels )
347 OUString aCommentsFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc(
u"comments" );
348 if( !aCommentsFragmentPath.isEmpty() )
354 switch( getCurrentElement() )
366 case XLS_TOKEN( worksheet ):
367 case XM_TOKEN( macrosheet ):
368 case XLS_TOKEN( dialogsheet ):
378 case XLS_TOKEN( sheetViews ):
379 case XLS_TOKEN( cols ):
380 case XLS_TOKEN( mergeCells ):
381 case XLS_TOKEN( hyperlinks ):
382 case XLS_TOKEN( rowBreaks ):
383 case XLS_TOKEN( colBreaks ):
384 case XLS_TOKEN( oleObjects ):
385 case XLS_TOKEN( controls ):
return this;
391 case XLS_TOKEN( protectedRanges ):
405 case XLS_TOKEN( sheetPr ):
414 case XLS_TOKEN( sheetViews ):
420 case XLS_TOKEN( sheetView ):
428 case XLS_TOKEN( cols ):
429 if( nElement == XLS_TOKEN(
col ) )
importCol( rAttribs );
431 case XLS_TOKEN( mergeCells ):
434 case XLS_TOKEN( hyperlinks ):
437 case XLS_TOKEN( rowBreaks ):
438 if( nElement == XLS_TOKEN( brk ) )
importBrk( rAttribs,
true );
440 case XLS_TOKEN( colBreaks ):
441 if( nElement == XLS_TOKEN( brk ) )
importBrk( rAttribs,
false );
444 case XLS_TOKEN( protectedRanges ):
451 case XLS_TOKEN( headerFooter ):
454 case XLS_TOKEN( firstHeader ):
455 case XLS_TOKEN( firstFooter ):
456 case XLS_TOKEN( oddHeader ):
457 case XLS_TOKEN( oddFooter ):
458 case XLS_TOKEN( evenHeader ):
459 case XLS_TOKEN( evenFooter ):
return this;
465 case XLS_TOKEN( controls ):
466 case XLS_TOKEN( oleObjects ):
467 if( isMCEStateEmpty() || getMCEState() == MCE_STATE::Started )
469 if ( getCurrentElement() == XLS_TOKEN( oleObjects ) )
474 else if ( !isMCEStateEmpty() && getMCEState() == MCE_STATE::FoundChoice )
478 setMCEState( MCE_STATE::Started );
487 switch( getCurrentElement() )
489 case XLS_TOKEN( firstHeader ):
490 case XLS_TOKEN( firstFooter ):
491 case XLS_TOKEN( oddHeader ):
492 case XLS_TOKEN( oddFooter ):
493 case XLS_TOKEN( evenHeader ):
494 case XLS_TOKEN( evenFooter ):
502 switch( getCurrentElement() )
579 static const RecordInfo spRecInfos[] =
619 RelationsRef xQueryRels = getRelations().getRelationsFromTypeFromOfficeDoc(
u"queryTable" );
620 for(
const auto& rEntry : *xQueryRels )
624 RelationsRef xPivotRels = getRelations().getRelationsFromTypeFromOfficeDoc(
u"pivotTable" );
625 for(
const auto& rEntry : *xPivotRels )
668 double fDefaultRowHeight = rAttribs.
getDouble(XML_defaultRowHeight, 0.0);
669 if (getFilter().isMSODocument())
671 fDefaultRowHeight -= fmod(fDefaultRowHeight, 0.75);
675 rAttribs.
getBool( XML_customHeight,
false ),
676 rAttribs.
getBool( XML_zeroHeight,
false ),
677 rAttribs.
getBool( XML_thickTop,
false ),
678 rAttribs.
getBool( XML_thickBottom,
false ) );
708 aModel.
maTarget = getRelations().getExternalTargetFromRelId( rAttribs.
getString( R_TOKEN(
id ), OUString() ) );
741 "WorksheetFragment::importOleObject - OLE object must be either linked or embedded" );
748 aInfo.
mbShowAsIcon = rAttribs.
getToken( XML_dvAspect, XML_DVASPECT_CONTENT ) == XML_DVASPECT_ICON;
749 aInfo.
mbAutoUpdate = rAttribs.
getToken( XML_oleUpdate, XML_OLEUPDATE_ONCALL ) == XML_OLEUPDATE_ALWAYS;
779 sal_Int32 nDefaultWidth;
780 sal_uInt16 nBaseWidth, nDefaultHeight, nFlags;
781 nDefaultWidth =
rStrm.readInt32();
782 nBaseWidth =
rStrm.readuInt16();
783 nDefaultHeight =
rStrm.readuInt16();
784 nFlags =
rStrm.readuInt16();
792 nDefaultHeight / 20.0,
793 getFlag( nFlags, BIFF_DEFROW_CUSTOMHEIGHT ),
794 getFlag( nFlags, BIFF_DEFROW_HIDDEN ),
795 getFlag( nFlags, BIFF_DEFROW_THICKTOP ),
796 getFlag( nFlags, BIFF_DEFROW_THICKBOTTOM ) );
807 nWidth =
rStrm.readInt32();
809 nFlags =
rStrm.readuInt16();
815 aModel.
mfWidth =
static_cast< double >( nWidth ) / 256.0;
817 aModel.
mnLevel = extractValue< sal_Int32 >( nFlags, 8, 3 );
854 nManual =
rStrm.readInt32();
872 sal_Int32 nAspect, nUpdateMode, nShapeId;
874 nAspect =
rStrm.readInt32();
875 nUpdateMode =
rStrm.readInt32();
876 nShapeId =
rStrm.readInt32();
877 nFlags =
rStrm.readuInt16();
886 aInfo.
mbAutoUpdate = nUpdateMode == BIFF12_OLEOBJECT_ALWAYS;
902 OUString aFragmentPath = getFragmentPathFromRelId( rRelId );
903 if( !aFragmentPath.isEmpty() )
ScAddress GetTopLeftCorner() const
bool hasAttribute(sal_Int32 nAttrToken) const
std::optional< OUString > getXString(sal_Int32 nAttrToken) const
std::optional< sal_Int32 > getInteger(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
bool importBinaryData(StreamDataSequence &orDataSeq, const OUString &rStreamName)
void registerOleObject(const OleObjectInfo &rOleObject)
void registerControl(const ControlInfo &rControl)
static bool convertToCellRangeUnchecked(ScRange &orRange, std::u16string_view aString, sal_Int16 nSheet)
Converts the passed string to a cell range address, without checking any sheet limits.
static OUString readString(SequenceInputStream &rStrm, bool b32BitLen=true)
Reads a BIFF12 string with leading 16-bit or 32-bit length field.
A 2D cell range address list for binary filters.
bool isFormula1Set() const
std::unique_ptr< ValidationModel > mxValModel
void importDataValidation(const AttributeList &rAttribs)
Imports the dataValidation element containing data validation settings.
void SetFormula1(const OUString &rChars)
bool isFormula2Set() const
void SetFormula2(const OUString &rChars)
void SetValidation(WorksheetHelper &rTarget)
void SetSqref(const OUString &rChars)
virtual void onCharacters(const OUString &rChars) override
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
virtual void onEndElement() override
DataValidationsContext(WorksheetFragmentBase &rFragment)
virtual ::oox::core::ContextHandlerRef onCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm) override
virtual void onEndElement() override
ExtDataValidationsContext(WorksheetContextBase &rFragment)
virtual void onCharacters(const OUString &rChars) override
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
Used for the actual ExtLst containing the new extended definition.
void importPrintOptions(const AttributeList &rAttribs)
Imports printing options from a printOptions element.
void importPageSetup(const ::oox::core::Relations &rRelations, const AttributeList &rAttribs)
Imports pageSetup element for worksheets.
void importPicture(const ::oox::core::Relations &rRelations, const AttributeList &rAttribs)
Imports the picture element.
void importHeaderFooterCharacters(std::u16string_view rChars, sal_Int32 nElement)
Imports header/footer characters from a headerFooter element.
void importPageMargins(const AttributeList &rAttribs)
Imports pageMarings element containing page margins.
void importHeaderFooter(const AttributeList &rAttribs)
Imports header and footer settings from a headerFooter element.
void setFitToPagesMode(bool bFitToPages)
Sets whether percentual scaling or fit to width/height scaling is used.
void setMergedRange(const ScRange &rRange)
Merges the cells in the passed cell range.
This class implements importing the sheetData element.
void importPane(const AttributeList &rAttribs)
Imports the pane element containing sheet pane settings.
void importSelection(const AttributeList &rAttribs)
Imports the selection element containing selection settings for a pane.
void importSheetView(const AttributeList &rAttribs)
Imports the sheetView element containing sheet view settings.
bool importOoxFragment(const rtl::Reference< oox::core::FragmentHandler > &rxHandler)
Imports a fragment using the passed fragment handler, which contains the full path to the fragment st...
AddressConverter & getAddressConverter() const
Returns the converter for string to cell address/range conversion.
::oox::core::FilterBase & getBaseFilter() const
Returns the base filter object (base class of all filters).
FormulaParser & getFormulaParser() const
Returns a shared import formula parser (import filter only!).
Context handler derived from the WorksheetHelper helper class.
Fragment handler derived from the WorksheetHelper helper class.
virtual const ::oox::core::RecordInfo * getRecordInfos() const override
virtual void onCharacters(const OUString &rChars) override
void importCol(const AttributeList &rAttribs)
Imports column settings from a col element.
void importOleObject(const AttributeList &rAttribs)
Imports additional data for an OLE object.
virtual void finalizeImport() override
virtual ::oox::core::ContextHandlerRef onCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm) override
void importLegacyDrawing(const AttributeList &rAttribs)
Imports the relation identifier for the legacy VML drawing part.
void importDimension(const AttributeList &rAttribs)
Imports the dimension element containing the used area of the sheet.
void importSheetFormatPr(const AttributeList &rAttribs)
Imports sheet format properties from a sheetFormatPr element.
virtual void initializeImport() override
void importDrawing(const AttributeList &rAttribs)
Imports the relation identifier for the DrawingML part.
WorksheetFragment(const WorksheetHelper &rHelper, const OUString &rFragmentPath)
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
void importBrk(const AttributeList &rAttribs, bool bRowBreak)
Imports individual break that is either within row or column break context.
void importHyperlink(const AttributeList &rAttribs)
Imports the hyperlink element containing a hyperlink for a cell range.
void importMergeCell(const AttributeList &rAttribs)
Imports a merged cell range from a mergeCell element.
void importPageSetUpPr(const AttributeList &rAttribs)
Imports page settings from a pageSetUpPr element.
void importEmbeddedOleData(StreamDataSequence &orEmbeddedData, const OUString &rRelId)
Imports the binary data of an embedded OLE object from the fragment with the passed ID.
void importControl(const AttributeList &rAttribs)
Imports additional data for an OCX form control.
PageSettings & getPageSettings() const
Returns the page/print settings for this sheet.
VmlDrawing & getVmlDrawing() const
Returns the VML drawing page for this sheet (OOXML/BIFF12 only).
void extendUsedArea(const ScAddress &rAddress)
Extends the used area of this sheet by the passed cell position.
WorksheetType getSheetType() const
Returns the type of this sheet.
void setPageBreak(const PageBreakModel &rModel, bool bRowBreak)
Sets a column or row page break described in the passed struct.
WorksheetSettings & getWorksheetSettings() const
Returns the worksheet settings object.
void setDrawingPath(const OUString &rDrawingPath)
Sets the path to the DrawingML fragment of this sheet.
SheetDataBuffer & getSheetData() const
Returns the buffer for cell contents and cell formatting.
void setDefaultColumnWidth(double fWidth)
Sets default width for all columns.
SCTAB getSheetIndex() const
Returns the index of the current sheet.
void setColumnModel(const ColumnModel &rModel)
Sets column settings for a specific range of columns.
void setBaseColumnWidth(sal_Int32 nWidth)
Sets base width for all columns (without padding pixels).
void finalizeWorksheetImport()
Final conversion after importing the worksheet.
AutoFilterBuffer & getAutoFilters() const
Returns the auto filters for the sheet.
SheetViewSettings & getSheetViewSettings() const
Returns the view settings for this sheet.
void initializeWorksheetImport()
Initial conversion before importing the worksheet.
void setVmlDrawingPath(const OUString &rVmlDrawingPath)
Sets the path to the legacy VML drawing fragment of this sheet.
void setHyperlink(const HyperlinkModel &rModel)
Inserts the hyperlink URL into the spreadsheet.
void setDefaultRowSettings(double fHeight, bool bCustomHeight, bool bHidden, bool bThickTop, bool bThickBottom)
Sets default height and hidden state for all unused rows in the sheet.
void importSheetProtection(const AttributeList &rAttribs)
Imports protection settings from the sheetProtection element.
void importProtectedRange(const AttributeList &rAttribs)
Imports enhanced protection settings from the protectedRange element.
void importOutlinePr(const AttributeList &rAttribs)
Imports outline settings from the outlinePr element.
void importPhoneticPr(const AttributeList &rAttribs)
Imports phonetic settings from the phoneticPr element.
void importSheetPr(const AttributeList &rAttribs)
Imports sheet settings from the sheetPr element.
void importTabColor(const AttributeList &rAttribs)
Imports the sheet tab color from the tabColor element.
RttiCompleteObjectLocator col
const sal_Int32 XML_ROOT_CONTEXT
std::shared_ptr< Relations > RelationsRef
const sal_Int32 BIFF12_ID_WORKSHEET
const sal_Int32 BIFF12_ID_FILTERCOLUMN
const sal_Int32 BIFF12_ID_PAGEMARGINS
const sal_Int32 BIFF12_ID_DIMENSION
const sal_Int32 BIFF12_ID_PAGESETUP
const sal_Int32 BIFF12_ID_CFRULE
const sal_Int32 BIFF12_ID_SELECTION
const sal_Int32 BIFF12_ID_OLEOBJECTS
const sal_Int32 BIFF12_ID_SHEETVIEWS
const sal_Int32 BIFF12_ID_SHEETFORMATPR
const sal_Int32 BIFF12_ID_HYPERLINK
const sal_Int32 BIFF12_ID_TABLEPARTS
const sal_Int32 BIFF12_ID_CUSTOMSHEETVIEW
const sal_Int32 BIFF12_ID_PICTURE
const sal_Int32 BIFF12_ID_SCENARIO
const sal_Int32 BIFF12_ID_DATAVALIDATIONS
const sal_Int32 BIFF12_ID_PANE
const sal_Int32 BIFF12_ID_PRINTOPTIONS
@ Validation
Condition of a conditional format rule.
const sal_Int32 BIFF12_ID_COL
const sal_Int32 BIFF12_ID_CONDFORMATTING
const sal_Int32 BIFF12_ID_COLS
const sal_Int32 BIFF12_ID_SHEETVIEW
const sal_Int32 BIFF12_ID_CONTROL
const sal_Int32 BIFF12_ID_LEGACYDRAWING
const sal_Int32 BIFF12_ID_ICONSET
const sal_Int32 BIFF12_ID_SHEETPROTECTION
const sal_Int32 BIFF12_ID_MERGECELLS
const sal_Int32 BIFF12_ID_CUSTOMFILTERS
const sal_Int32 BIFF12_ID_OLEOBJECT
const sal_Int32 BIFF12_ID_DATAVALIDATION
const sal_Int32 BIFF12_ID_DISCRETEFILTERS
const sal_Int32 BIFF12_ID_ROW
const sal_Int32 BIFF12_ID_CUSTOMSHEETVIEWS
const sal_Int32 BIFF12_ID_SHEETPR
const sal_Int32 BIFF12_ID_DRAWING
const sal_Int32 BIFF12_ID_SCENARIOS
const sal_Int32 BIFF12_ID_DATABAR
const sal_Int32 BIFF12_ID_ROWBREAKS
const sal_Int32 BIFF12_ID_MERGECELL
const sal_Int32 BIFF12_ID_PHONETICPR
const sal_Int32 BIFF12_ID_COLBREAKS
const sal_Int32 BIFF12_ID_CONTROLS
@ Empty
Dialog sheet (BIFF5+).
const sal_Int32 BIFF12_ID_AUTOFILTER
const sal_Int32 BIFF12_ID_HEADERFOOTER
const sal_Int32 BIFF12_ID_BRK
const sal_Int32 BIFF12_ID_SHEETDATA
const sal_Int32 BIFF12_ID_COLORSCALE
css::uno::Sequence< sal_Int8 > StreamDataSequence
bool getFlag(Type nBitField, Type nMask)
StreamDataSequence maEmbeddedData
void setShapeId(sal_Int32 nShapeId)
void setShapeId(sal_Int32 nShapeId)
A 2D cell range address struct for binary filters.
void read(SequenceInputStream &rStrm)
Stores settings and formatting data about a range of sheet columns.
sal_Int32 mnLevel
Column default formatting.
bool mbShowPhonetic
Column outline level.
bool mbHidden
True = cells in column show phonetic settings.
sal_Int32 mnXfId
Column width in number of characters.
double mfWidth
1-based (!) range of the described columns.
bool mbCollapsed
True = column is hidden.
Stores data about a hyperlink range.
OUString maTooltip
The cell area containing the hyperlink.
Stores formatting data about a page break.
sal_Int32 mnMax
Start of limited break.
sal_Int32 mnMin
0-based (!) index of column/row.
bool mbManual
End of limited break.
Stores data about ranges with data validation settings.
ApiTokenSequence maTokens2
ApiTokenSequence maTokens1
void setBiffType(sal_uInt8 nType)
Sets the passed BIFF validation type.
void setBiffOperator(sal_uInt8 nOperator)
Sets the passed BIFF operator.
void setBiffErrorStyle(sal_uInt8 nErrorStyle)
Sets the passed BIFF error style.