21#include <rtl/ustring.hxx>
23#include <document.hxx>
51#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
52#include <com/sun/star/frame/XModel.hpp>
54#include <oox/token/tokens.hxx>
55#include <oox/token/namespaces.hxx>
62 OUString aRet =
"__VBA__" + OUString::number(
static_cast<sal_uInt16
>(
n) );
123 nExcTab( rRoot.GetTabInfo().GetXclTab( nScTab ) ),
134 OSL_ENSURE( pRec,
"-ExcTable::Add(): pRec is NULL!" );
158 if( (nWriteProtHash > 0) || bRecommendReadOnly )
196 if( !rCodeName.isEmpty() )
260 for( nC = 0 ; nC < nScTabCount ; nC++ )
285 for( nC = 0 ; nC < nScTabCount ; nC++ )
294 for(
SCTAB nAdd = 0; nC < static_cast<SCTAB>(nCodenames) ; nC++, nAdd++ )
377 for( nC = 0 ; nC < nScTabCount ; nC++ )
387 for(
SCTAB nAdd = 0; nC < static_cast<SCTAB>(nCodenames) ; nC++, nAdd++ )
415 OSL_ENSURE( (
mnScTab >= 0) && (
mnScTab <=
MAXTAB),
"-ExcTable::Table(): mnScTab - no ordinary table!" );
426 std::vector<sc::NoteEntry> aNotes;
428 for (
const auto& rNote : aNotes)
430 if (rNote.maPos.Tab() !=
mnScTab)
438 bool bFitToPages = xPageSett->GetPageData().mbFitToPages;
516 for (
const auto& rProt : rProts)
557 OSL_ENSURE( (
mnScTab >= 0) && (
mnScTab <=
MAXTAB),
"-ExcTable::Table(): mnScTab - no ordinary table!" );
567 std::vector<sc::NoteEntry> aNotes;
569 for (
const auto& rNote : aNotes)
571 if (rNote.maPos.Tab() !=
mnScTab)
580 bool bFitToPages = xPageSett->GetPageData().mbFitToPages;
623 if( pHyperlinkList !=
nullptr && !pHyperlinkList->
IsEmpty() )
692 rStrm.PushStream( pWorksheet );
694 pWorksheet->startElement( XML_worksheet,
695 XML_xmlns,
rStrm.getNamespaceURL(OOX_NS(xls)),
696 FSNS(XML_xmlns, XML_r),
rStrm.getNamespaceURL(OOX_NS(officeRel)),
697 FSNS(XML_xmlns, XML_xdr),
"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing",
698 FSNS(XML_xmlns, XML_x14),
rStrm.getNamespaceURL(OOX_NS(xls14Lst)),
699 FSNS(XML_xmlns, XML_xr2),
rStrm.getNamespaceURL(OOX_NS(xr2)),
700 FSNS(XML_xmlns, XML_mc),
rStrm.getNamespaceURL(OOX_NS(mce)));
711 rStrm.GetCurrentStream()->endElement( XML_worksheet );
742 for( ; nScTab < nScTabCount; ++nScTab )
749 xTab->FillAsTableBinary(nCodeNameIdx);
751 xTab->FillAsTableXml();
756 for( ; nCodeNameIdx < nCodeNameCount; ++nScTab, ++nCodeNameIdx )
760 xTab->FillAsEmptyTable( nCodeNameIdx );
769 if (
GetDoc().GetChangeTrack() )
785 "ExcDocument::Write - different number of sheets and BOUNDSHEET records" );
810 uno::Reference<document::XDocumentPropertiesSupplier> xDPS( pDocShell->
GetModel(), uno::UNO_QUERY_THROW );
811 uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties();
815 bool bHasPasswordHash = nWriteProtHash && !sUserName.isEmpty();
817 OUString sAlgorithm, sSalt,
sHash;
819 for (
const auto& prop : aInfo)
821 if (prop.Name ==
"algorithm-name")
822 prop.Value >>= sAlgorithm;
823 else if (prop.Name ==
"salt")
824 prop.Value >>= sSalt;
825 else if (prop.Name ==
"iteration-count")
827 else if (prop.Name ==
"hash")
828 prop.Value >>=
sHash;
830 bool bHasPasswordInfo
831 = sAlgorithm !=
"PBKDF2" && !sSalt.isEmpty() && !
sHash.isEmpty() && !sUserName.isEmpty();
833 && !bHasPasswordHash && !bHasPasswordInfo);
834 rStrm.exportCustomFragments();
837 rWorkbook->startElement( XML_workbook,
838 XML_xmlns,
rStrm.getNamespaceURL(OOX_NS(xls)),
839 FSNS(XML_xmlns, XML_r),
rStrm.getNamespaceURL(OOX_NS(officeRel)) );
840 rWorkbook->singleElement( XML_fileVersion,
848 if (bHasPasswordHash)
849 rWorkbook->singleElement(XML_fileSharing,
850 XML_userName, sUserName,
851 XML_reservationPassword, OString::number(nWriteProtHash, 16));
852 else if (bHasPasswordInfo)
853 rWorkbook->singleElement(XML_fileSharing,
854 XML_userName, sUserName,
855 XML_algorithmName, sAlgorithm,
856 XML_hashValue,
sHash,
857 XML_saltValue, sSalt,
858 XML_spinCount, OString::number(
nCount));
898 xExtLst->SaveXml(
rStrm);
901 rWorkbook->endElement( XML_workbook );
void UpdateStreamPos(XclExpStream &rStrm)
ExcBoundsheetList maBoundsheetList
void Write(SvStream &rSvStrm)
virtual ~ExcDocument() override
std::unique_ptr< XclExpChangeTrack > m_xExpChangeTrack
void WriteXml(XclExpXmlStream &)
ExcDocument(const XclExpRoot &rRoot)
void FillAsEmptyTable(SCTAB nCodeNameIdx)
ExcTable(const XclExpRoot &rRoot)
virtual ~ExcTable() override
void FillAsHeaderBinary(ExcBoundsheetList &rBoundsheetList)
void Add(XclExpRecordBase *pRec)
void WriteXml(XclExpXmlStream &)
void Write(XclExpStream &)
XclExpNoteListRef mxNoteList
XclExpCellTableRef mxCellTable
void FillAsTableBinary(SCTAB nCodeNameIdx)
XclExpRecordList aRecList
void FillAsHeaderXml(ExcBoundsheetList &rBoundsheetList)
bool IsCalcAsShown() const
virtual css::uno::Sequence< sal_Int8 > getPasswordHash(ScPasswordHash eHash, ScPasswordHash eHash2=PASSHASH_UNSPECIFIED) const override
virtual bool isProtected() const override
bool isOptionEnabled(Option eOption) const
SC_DLLPUBLIC const ScTableProtection * GetTabProtection(SCTAB nTab) const
SC_DLLPUBLIC Color GetTabBgColor(SCTAB nTab) const
const ScCalcConfig & GetCalcConfig() const
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
SC_DLLPUBLIC void GetAllNoteEntries(std::vector< sc::NoteEntry > &rNotes) const
SC_DLLPUBLIC ScDocProtection * GetDocProtection() const
ScChangeTrack * GetChangeTrack() const
SC_DLLPUBLIC const ScDocOptions & GetDocOptions() const
const ScExtDocSettings & GetDocSettings() const
SCTAB GetCodeNameCount() const
sheet protection state container
bool isOptionEnabled(Option eOption) const
virtual css::uno::Sequence< sal_Int8 > getPasswordHash(ScPasswordHash eHash, ScPasswordHash eHash2=PASSHASH_UNSPECIFIED) const override
virtual bool isProtected() const override
const ::std::vector< ScEnhancedProtection > & getEnhancedProtection() const
bool IsLoadReadonly() const
sal_uInt32 GetModifyPasswordHash() const
bool IsSecurityOptOpenReadOnly() const
css::uno::Reference< css::frame::XModel3 > GetModel() const
const css::uno::Sequence< css::beans::PropertyValue > & GetModifyPasswordInfo() const
Record which contains a Boolean value.
This class contains the cell contents and more of an entire sheet.
This record contains the Windows country IDs for the UI and document language.
XclExpRecordRef CreateRecord(SCTAB nScTab)
Returns a record object containing all filter records for the specified sheet.
Provides export of bitmap data to an IMGDATA record.
End of User Interface Records.
Beginning of User Interface Records.
Provides export of the row/column label range list of a sheet.
Represents a NOTE record containing the relevant data of a cell note.
void StartSheet()
Initializes the object manager for a new sheet.
rtl::Reference< XclExpRecordBase > ProcessDrawing(const SdrPage *pSdrPage)
Processes a drawing page and returns the record block containing all related records (MSODRAWING,...
void EndDocument()
Finalizes the object manager after conversion of all sheets.
Contains all page (print) settings records for a single sheet.
void CreatePivotTables()
Creates all pivot tables and caches from the Calc DataPilot objects.
Base class for all Excel records.
A list of Excel record objects.
virtual void SaveXml(XclExpXmlStream &rStrm) override
void AppendNewRecord(RecType *pRec)
Appends a newly created record to the list.
void RemoveAllRecords()
Removes all records from the list.
virtual void Save(XclExpStream &rStrm) override
Writes the complete record list.
void AppendRecord(RecType *pRec)
Appends a record to the list.
RecType * GetRecord(size_t nPos) const
Returns reference to an existing record or empty reference on error.
Access to global data from other classes.
XclExpTablesManager & GetTablesManager()
XclExpPivotTableManager & GetPivotTableManager() const
Returns the pivot table manager.
void InitializeConvert()
Is called when export filter starts to create the Excel document (all BIFF versions).
void InitializeTable(SCTAB nScTab)
Is called when export filter starts to create data for a single sheet (all BIFF versions).
XclExpObjectManager & GetObjectManager() const
Returns the drawing object manager.
void InitializeGlobals()
Is called when export filter starts to create the workbook global data (>=BIFF5).
bool IsDocumentEncrypted() const
XclExpXmlPivotTableManager & GetXmlPivotTableManager()
XclExpTabInfo & GetTabInfo() const
Returns the buffer for Calc->Excel sheet index conversion.
XclExpRecordRef CreateRecord(sal_uInt16 nRecId) const
Returns the reference to a record (or record list) representing a root object.
void InitializeSave()
Is called before export filter starts to write the records to the stream.
const XclExpRoot & GetRoot() const
Returns this root instance - for code readability in derived classes.
XclExpFilterManager & GetFilterManager() const
Returns the filter manager.
Represents one EnhancedProtection feature in a FEAT record.
Represents a FEATHDR (SHEETPROTECTION) record that stores sheet protection options.
This class is used to export Excel record streams.
sal_uInt64 GetSvStreamPos() const
Returns the absolute position of the system stream.
Stores the correct Excel sheet index for each Calc sheet.
SCTAB GetScTabCount() const
Returns the number of Calc sheets.
sal_uInt16 GetXclTabCount() const
Returns the number of Excel sheets to be exported.
bool IsExportTab(SCTAB nScTab) const
Returns true, if the specified Calc sheet will be exported.
Contains all view settings records for a single sheet.
rtl::Reference< XclExpTables > GetTablesBySheet(SCTAB nTab)
std::vector< XclExpUserBView >::const_iterator const_iterator
Contains all web query records for this document.
Represents the WINDOW1 record containing global workbook view settings.
Write Access User Name - This record contains the user name, which is the name you type when you inst...
virtual void SaveXml(XclExpXmlStream &rStrm) override
XclExpXmlPivotCaches & GetCaches()
XclExpXmlPivotTables * GetTablesBySheet(SCTAB nTab)
virtual void SaveXml(XclExpXmlStream &rStrm) override
Save sheetPr element and its children for xlsx export.
SfxObjectShell * GetDocShell() const
Returns the object shell of the Calc document.
XclOutput GetOutput() const
Returns the current output format of the importer/exporter.
ScExtDocOptions & GetExtDocOptions() const
Returns the extended document options.
const OUString & GetUserName() const
Returns the current user name.
bool HasVbaStorage() const
Returns true, if the document contains a VBA storage.
XclBiff GetBiff() const
Returns the current BIFF version of the importer/exporter.
RootData & GetOldRoot() const
Returns old RootData struct.
void SetCurrScTab(SCTAB nScTab)
Sets the current Calc sheet index.
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
SdrPage * GetSdrPage(SCTAB nScTab) const
Returns the drawing layer page of the passed sheet, if present.
static OUString GetStreamName(const char *sStreamDir, const char *sStream, sal_Int32 nId)
Determines if sparklines needs to be exported and initiates the export.
static OUString lcl_GetVbaTabName(SCTAB n)
static void lcl_AddScenariosAndFilters(XclExpRecordList<> &aRecList, const XclExpRoot &rRoot, SCTAB nScTab)
static void lcl_AddWorkbookProtection(XclExpRecordList<> &aRecList, const ExcTable &self)
static void lcl_AddCalcPr(XclExpRecordList<> &aRecList, const ExcTable &self)
static void lcl_AddBookviews(XclExpRecordList<> &aRecList, const ExcTable &self)
constexpr sal_Int32 FSNS(sal_Int32 namespc, sal_Int32 element)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
const sal_uInt16 BIFF_ID_SCENPROTECT
const sal_uInt16 BIFF_ID_OBJECTPROTECT
const sal_uInt16 BIFF_ID_SAVERECALC
std::shared_ptr< FastSerializerHelper > FSHelperPtr
XclExpUserBViewList * pUserBViewList
Configuration options for formula interpreter.
formula::FormulaGrammar::AddressConvention meStringRefAddressSyntax
bool mbHasStringRefSyntax
OUString maGlobCodeName
Global codename (VBA module name).
rtl::Reference< XclExtLst > XclExtLstRef
XclExpValueRecord< sal_uInt16 > XclExpUInt16Record
A record containing an unsigned 16-bit value.
const sal_uInt16 EXC_ID_FONTLIST
const sal_uInt16 EXC_ID_XFLIST
For internal use only.
const sal_uInt16 EXC_ID_FORMATLIST
For internal use only.
const sal_uInt16 EXC_ID_FNGROUPCOUNT
const sal_uInt16 EXC_ID_CODEPAGE
const sal_uInt16 EXC_ID_WRITEPROT
const SCTAB SCTAB_GLOBAL
An invalid Calc sheet index, for common use.
const sal_uInt16 EXC_ID_USESELFS
const sal_uInt16 EXC_NOTAB
const sal_uInt16 EXC_ID_MMS
const sal_uInt16 EXC_ID_INTERFACEHDR
const sal_uInt16 EXC_ID_INTERFACEEND
XclBiff
An enumeration for all Excel file format types (BIFF types).
@ EXC_BIFF8
MS Excel 5.0, MS Excel 7.0 (95)
const sal_uInt16 EXC_ID_TOOLBAREND
const sal_uInt16 EXC_ID_XL9FILE
const sal_uInt16 EXC_ID_TOOLBARHDR
const sal_uInt16 EXC_ID_DSF
const sal_uInt16 EXC_ID_HLINK
const sal_uInt16 EXC_ID_SST
const sal_uInt16 EXC_ID_DVAL
Font escapement type modified?
const sal_uInt16 EXC_ID_MERGEDCELLS
const sal_uInt16 EXC_ID_EXTERNSHEET
const sal_uInt16 EXC_ID_NAME
const sal_uInt16 EXC_ID_PALETTE
const sal_uInt16 EXC_ID3_DIMENSIONS
const sal_uInt16 EXC_ID_GUTS
const sal_uInt16 EXC_ID2_DEFROWHEIGHT