23 #include <osl/diagnose.h>
27 #include <oox/token/namespaces.hxx>
28 #include <oox/token/tokens.hxx>
53 const sal_uInt16 BIFF_COLINFO_HIDDEN = 0x0001;
54 const sal_uInt16 BIFF_COLINFO_SHOWPHONETIC = 0x0008;
55 const sal_uInt16 BIFF_COLINFO_COLLAPSED = 0x1000;
57 const sal_uInt16 BIFF_DEFROW_CUSTOMHEIGHT = 0x0001;
58 const sal_uInt16 BIFF_DEFROW_HIDDEN = 0x0002;
59 const sal_uInt16 BIFF_DEFROW_THICKTOP = 0x0004;
60 const sal_uInt16 BIFF_DEFROW_THICKBOTTOM = 0x0008;
62 const sal_uInt32 BIFF_DATAVAL_STRINGLIST = 0x00000080;
63 const sal_uInt32 BIFF_DATAVAL_ALLOWBLANK = 0x00000100;
64 const sal_uInt32 BIFF_DATAVAL_NODROPDOWN = 0x00000200;
65 const sal_uInt32 BIFF_DATAVAL_SHOWINPUT = 0x00040000;
66 const sal_uInt32 BIFF_DATAVAL_SHOWERROR = 0x00080000;
68 const sal_Int32 BIFF12_OLEOBJECT_ICON = 4;
69 const sal_Int32 BIFF12_OLEOBJECT_ALWAYS = 1;
70 const sal_uInt16 BIFF12_OLEOBJECT_LINKED = 0x0001;
71 const sal_uInt16 BIFF12_OLEOBJECT_AUTOLOAD = 0x0002;
126 aModel.
setBiffType(extractValue< sal_uInt8 >(nFlags, 0, 4));
143 if ((aModel.
mnType == XML_list) &&
getFlag(nFlags, BIFF_DATAVAL_STRINGLIST))
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 ):
209 OUString NormalizeOoxList(
const OUString& aList)
211 OUStringBuffer aResult(
"\"");
212 bool bInsideQuotes =
false;
213 const sal_Int32 nLen = aList.getLength();
214 for (sal_Int32 i = 0;
i < nLen; ++
i)
221 bInsideQuotes = !bInsideQuotes;
226 aResult.append(
"\",\"");
235 return aResult.append(
'"').makeStringAndClear();
243 case XLS_TOKEN( formula1 ):
246 case XLS_TOKEN( formula2 ):
249 case X12AC_TOKEN(
list ):
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 ):
316 case XLS14_TOKEN( formula1 ):
319 case XLS14_TOKEN( formula2 ):
324 case XM_TOKEN( sqref ):
342 RelationsRef xTableRels = getRelations().getRelationsFromTypeFromOfficeDoc(
u"table" );
343 for(
const auto& rEntry : *xTableRels )
347 OUString aCommentsFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc(
u"comments" );
348 if( !aCommentsFragmentPath.isEmpty() )
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 ):
491 case XLS_TOKEN( firstHeader ):
492 case XLS_TOKEN( firstFooter ):
493 case XLS_TOKEN( oddHeader ):
494 case XLS_TOKEN( oddFooter ):
495 case XLS_TOKEN( evenHeader ):
496 case XLS_TOKEN( evenFooter ):
581 static const RecordInfo spRecInfos[] =
621 RelationsRef xQueryRels = getRelations().getRelationsFromTypeFromOfficeDoc(
u"queryTable" );
622 for(
const auto& rEntry : *xQueryRels )
626 RelationsRef xPivotRels = getRelations().getRelationsFromTypeFromOfficeDoc(
u"pivotTable" );
627 for(
const auto& rEntry : *xPivotRels )
671 rAttribs.
getDouble( XML_defaultRowHeight, 0.0 ),
672 rAttribs.
getBool( XML_customHeight,
false ),
673 rAttribs.
getBool( XML_zeroHeight,
false ),
674 rAttribs.
getBool( XML_thickTop,
false ),
675 rAttribs.
getBool( XML_thickBottom,
false ) );
705 aModel.
maTarget = getRelations().getExternalTargetFromRelId( rAttribs.
getString( R_TOKEN(
id ), OUString() ) );
738 "WorksheetFragment::importOleObject - OLE object must be either linked or embedded" );
745 aInfo.
mbShowAsIcon = rAttribs.
getToken( XML_dvAspect, XML_DVASPECT_CONTENT ) == XML_DVASPECT_ICON;
746 aInfo.
mbAutoUpdate = rAttribs.
getToken( XML_oleUpdate, XML_OLEUPDATE_ONCALL ) == XML_OLEUPDATE_ALWAYS;
763 aBinRange.
read( rStrm );
776 sal_Int32 nDefaultWidth;
777 sal_uInt16 nBaseWidth, nDefaultHeight, nFlags;
789 nDefaultHeight / 20.0,
790 getFlag( nFlags, BIFF_DEFROW_CUSTOMHEIGHT ),
791 getFlag( nFlags, BIFF_DEFROW_HIDDEN ),
792 getFlag( nFlags, BIFF_DEFROW_THICKTOP ),
793 getFlag( nFlags, BIFF_DEFROW_THICKBOTTOM ) );
812 aModel.
mfWidth =
static_cast< double >( nWidth ) / 256.0;
814 aModel.
mnLevel = extractValue< sal_Int32 >( nFlags, 8, 3 );
869 sal_Int32 nAspect, nUpdateMode, nShapeId;
883 aInfo.
mbAutoUpdate = nUpdateMode == BIFF12_OLEOBJECT_ALWAYS;
899 OUString aFragmentPath = getFragmentPathFromRelId( rRelId );
900 if( !aFragmentPath.isEmpty() )
const sal_Int32 BIFF12_ID_SHEETPR
std::shared_ptr< Relations > RelationsRef
const sal_Int32 BIFF12_ID_CONTROL
virtual void initializeImport() override
SheetDataBuffer & getSheetData() const
Returns the buffer for cell contents and cell formatting.
OptValue< bool > getBool(sal_Int32 nAttrToken) const
::std::vector< MCE_STATE > aMceState
Condition of a conditional format rule.
A 2D cell range address list for binary filters.
OptValue< OUString > getXString(sal_Int32 nAttrToken) const
ExtDataValidationsContext(WorksheetContextBase &rFragment)
void importDataValidation(const AttributeList &rAttribs)
Imports the dataValidation element containing data validation settings.
OptValue< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
bool isCurrentElement(sal_Int32 nElement) const
const sal_Int32 BIFF12_ID_PRINTOPTIONS
void importLegacyDrawing(const AttributeList &rAttribs)
Imports the relation identifier for the legacy VML drawing part.
A 2D cell range address struct for binary filters.
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
void SetSqref(const OUString &rChars)
sal_Int32 mnMax
Start of limited break.
const sal_Int32 BIFF12_ID_CUSTOMSHEETVIEWS
const sal_Int32 BIFF12_ID_PAGESETUP
OptValue< double > getDouble(sal_Int32 nAttrToken) const
void importHeaderFooter(const AttributeList &rAttribs)
Imports header and footer settings from a headerFooter element.
DataValidationsContext(WorksheetFragmentBase &rFragment)
OptValue< OUString > getString(sal_Int32 nAttrToken) const
void registerOleObject(const OleObjectInfo &rOleObject)
void SetFormula2(const OUString &rChars)
WorksheetSettings & getWorksheetSettings() const
Returns the worksheet settings object.
virtual void onCharacters(const OUString &rChars) override
static bool convertToCellRangeUnchecked(ScRange &orRange, const OUString &rString, sal_Int16 nSheet)
Converts the passed string to a cell range address, without checking any sheet limits.
const sal_Int32 BIFF12_ID_PAGEMARGINS
SheetViewSettings & getSheetViewSettings() const
Returns the view settings for this sheet.
void importOutlinePr(const AttributeList &rAttribs)
Imports outline settings from the outlinePr element.
const sal_Int32 BIFF12_ID_PICTURE
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...
const sal_Int32 BIFF12_ID_HEADERFOOTER
void SetFormula1(const OUString &rChars)
const sal_Int32 BIFF12_ID_CONTROLS
void setHyperlink(const HyperlinkModel &rModel)
Inserts the hyperlink URL into the spreadsheet.
sal_Int32 getCurrentElementWithMce() const
void importProtectedRange(const AttributeList &rAttribs)
Imports enhanced protection settings from the protectedRange element.
const sal_Int32 BIFF12_ID_PANE
void importPicture(const ::oox::core::Relations &rRelations, const AttributeList &rAttribs)
Imports the picture element.
void importCol(const AttributeList &rAttribs)
Imports column settings from a col element.
void setBiffType(sal_uInt8 nType)
Sets the passed BIFF validation type.
bool importBinaryData(StreamDataSequence &orDataSeq, const OUString &rStreamName)
virtual void finalizeImport() override
const sal_Int32 BIFF12_ID_CFRULE
Stores formatting data about a page break.
OUString maTooltip
The cell area containing the hyperlink.
Used for the actual ExtLst containing the new extended definition.
const sal_Int32 BIFF12_ID_COLORSCALE
bool hasAttribute(sal_Int32 nAttrToken) const
void setVmlDrawingPath(const OUString &rVmlDrawingPath)
Sets the path to the legacy VML drawing fragment of this sheet.
const sal_Int32 BIFF12_ID_LEGACYDRAWING
::oox::core::FilterBase & getBaseFilter() const
Returns the base filter object (base class of all filters).
const sal_Int32 BIFF12_ID_DISCRETEFILTERS
void importHyperlink(const AttributeList &rAttribs)
Imports the hyperlink element containing a hyperlink for a cell range.
const sal_Int32 BIFF12_ID_SHEETPROTECTION
WorksheetFragment(const WorksheetHelper &rHelper, const OUString &rFragmentPath)
const sal_Int32 BIFF12_ID_OLEOBJECTS
virtual ::oox::core::ContextHandlerRef onCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm) override
void importPrintOptions(const AttributeList &rAttribs)
Imports printing options from a printOptions element.
const sal_Int32 BIFF12_ID_BRK
bool isFormula2Set() const
sal_Int32 mnLevel
Column default formatting.
void importBrk(const AttributeList &rAttribs, bool bRowBreak)
Imports individual break that is either within row or column break context.
virtual void onCharacters(const OUString &rChars) override
void setMergedRange(const ScRange &rRange)
Merges the cells in the passed cell range.
bool getFlag(Type nBitField, Type nMask)
const sal_Int32 BIFF12_ID_AUTOFILTER
ScAddress GetTopLeftCorner() const
void setBiffOperator(sal_uInt8 nOperator)
Sets the passed BIFF operator.
double mfWidth
1-based (!) range of the described columns.
sal_Int32 mnXfId
Column width in number of characters.
const sal_Int32 BIFF12_ID_COL
bool isFormula1Set() const
void importEmbeddedOleData(StreamDataSequence &orEmbeddedData, const OUString &rRelId)
Imports the binary data of an embedded OLE object from the fragment with the passed ID...
void importSheetFormatPr(const AttributeList &rAttribs)
Imports sheet format properties from a sheetFormatPr element.
const sal_Int32 BIFF12_ID_SHEETVIEW
css::uno::Sequence< sal_Int8 > StreamDataSequence
virtual ::oox::core::ContextHandlerRef onCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm) override
const sal_Int32 BIFF12_ID_DATAVALIDATIONS
void importPageSetUpPr(const AttributeList &rAttribs)
Imports page settings from a pageSetUpPr element.
void setDrawingPath(const OUString &rDrawingPath)
Sets the path to the DrawingML fragment of this sheet.
bool mbHidden
True = cells in column show phonetic settings.
This class implements importing the sheetData element.
bool mbCollapsed
True = column is hidden.
const sal_Int32 BIFF12_ID_CUSTOMSHEETVIEW
ApiTokenSequence maTokens2
const sal_Int32 BIFF12_ID_DRAWING
Stores settings and formatting data about a range of sheet columns.
void importSheetPr(const AttributeList &rAttribs)
Imports sheet settings from the sheetPr element.
WorksheetType getSheetType() const
Returns the type of this sheet.
const sal_Int32 BIFF12_ID_DIMENSION
static OUString readString(SequenceInputStream &rStrm, bool b32BitLen=true)
Reads a BIFF12 string with leading 16-bit or 32-bit length field.
void importHeaderFooterCharacters(std::u16string_view rChars, sal_Int32 nElement)
Imports header/footer characters from a headerFooter element.
const sal_Int32 BIFF12_ID_DATAVALIDATION
void importSelection(const AttributeList &rAttribs)
Imports the selection element containing selection settings for a pane.
const sal_Int32 BIFF12_ID_SHEETDATA
void setPageBreak(const PageBreakModel &rModel, bool bRowBreak)
Sets a column or row page break described in the passed struct.
sal_Int32 getCurrentElement() const
const sal_Int32 BIFF12_ID_MERGECELL
std::unique_ptr< ValidationModel > mxValModel
void convertToCellRangeList(ScRangeList &orRanges, const OUString &rString, sal_Int16 nSheet, bool bTrackOverflow)
Tries to convert the passed string to a cell range list.
const sal_Int32 BIFF12_ID_CUSTOMFILTERS
const sal_Int32 BIFF12_ID_SELECTION
void setBaseColumnWidth(sal_Int32 nWidth)
Sets base width for all columns (without padding pixels).
const sal_Int32 BIFF12_ID_FILTERCOLUMN
const sal_Int32 BIFF12_ID_SHEETVIEWS
StreamDataSequence maEmbeddedData
void importMergeCell(const AttributeList &rAttribs)
Imports a merged cell range from a mergeCell element.
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 initializeWorksheetImport()
Initial conversion before importing the worksheet.
const sal_Int32 BIFF12_ID_ROWBREAKS
void setShapeId(sal_Int32 nShapeId)
const sal_Int32 BIFF12_ID_COLS
void setColumnModel(const ColumnModel &rModel)
Sets column settings for a specific range of columns.
void setValidation(const ValidationModel &rModel)
Inserts the data validation settings into the spreadsheet.
const sal_Int32 BIFF12_ID_PHONETICPR
Fragment handler derived from the WorksheetHelper helper class.
Stores data about ranges with data validation settings.
const sal_Int32 BIFF12_ID_DATABAR
virtual void onEndElement() override
void extendUsedArea(const ScAddress &rAddress)
Extends the used area of this sheet by the passed cell position.
const sal_Int32 BIFF12_ID_OLEOBJECT
void importPhoneticPr(const AttributeList &rAttribs)
Imports phonetic settings from the phoneticPr element.
virtual void onEndElement() override
sal_Int32 mnMin
0-based (!) index of column/row.
void importPageSetup(const ::oox::core::Relations &rRelations, const AttributeList &rAttribs)
Imports pageSetup element for worksheets.
Context handler derived from the WorksheetHelper helper class.
virtual void onCharacters(const OUString &rChars) override
const sal_Int32 BIFF12_ID_SCENARIO
const sal_Int32 BIFF12_ID_COLBREAKS
SCTAB getSheetIndex() const
Returns the index of the current sheet.
void read(SequenceInputStream &rStrm)
bool mbShowPhonetic
Column outline level.
void importSheetView(const AttributeList &rAttribs)
Imports the sheetView element containing sheet view settings.
void importPageMargins(const AttributeList &rAttribs)
Imports pageMarings element containing page margins.
void importControl(const AttributeList &rAttribs)
Imports additional data for an OCX form control.
const sal_Int32 BIFF12_ID_SHEETFORMATPR
const sal_Int32 BIFF12_ID_ROW
void importOleObject(const AttributeList &rAttribs)
Imports additional data for an OLE object.
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
FormulaParser & getFormulaParser() const
Returns a shared import formula parser (import filter only!).
const sal_Int32 XML_ROOT_CONTEXT
const sal_Int32 BIFF12_ID_MERGECELLS
void registerControl(const ControlInfo &rControl)
void(* f)(TrueTypeTable *)
void setFitToPagesMode(bool bFitToPages)
Sets whether percentual scaling or fit to width/height scaling is used.
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
VmlDrawing & getVmlDrawing() const
Returns the VML drawing page for this sheet (OOXML/BIFF12 only).
void importTabColor(const AttributeList &rAttribs)
Imports the sheet tab color from the tabColor element.
void importDimension(const AttributeList &rAttribs)
Imports the dimension element containing the used area of the sheet.
void SetValidation(WorksheetHelper &rTarget)
Stores data about a hyperlink range.
const sal_Int32 BIFF12_ID_CONDFORMATTING
const sal_Int32 BIFF12_ID_ICONSET
void importDrawing(const AttributeList &rAttribs)
Imports the relation identifier for the DrawingML part.
void importPane(const AttributeList &rAttribs)
Imports the pane element containing sheet pane settings.
AutoFilterBuffer & getAutoFilters() const
Returns the auto filters for the sheet.
virtual const ::oox::core::RecordInfo * getRecordInfos() const override
void setShapeId(sal_Int32 nShapeId)
void finalizeWorksheetImport()
Final conversion after importing the worksheet.
void importSheetProtection(const AttributeList &rAttribs)
Imports protection settings from the sheetProtection element.
const sal_Int32 BIFF12_ID_HYPERLINK
const sal_Int32 BIFF12_ID_TABLEPARTS
OptValue< sal_Int32 > getToken(sal_Int32 nAttrToken) const
PageSettings & getPageSettings() const
Returns the page/print settings for this sheet.
const sal_Int32 BIFF12_ID_SCENARIOS
bool mbManual
End of limited break.
AddressConverter & getAddressConverter() const
Returns the converter for string to cell address/range conversion.
const sal_Int32 BIFF12_ID_WORKSHEET
ApiTokenSequence maTokens1
void setDefaultColumnWidth(double fWidth)
Sets default width for all columns.
void setBiffErrorStyle(sal_uInt8 nErrorStyle)
Sets the passed BIFF error style.