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>
66 OUString aRet =
"__VBA__" + OUString::number(
static_cast<sal_uInt16
>(
n) );
127 nExcTab( rRoot.GetTabInfo().GetXclTab( nScTab ) ),
138 OSL_ENSURE( pRec,
"-ExcTable::Add(): pRec is NULL!" );
162 if( (nWriteProtHash > 0) || bRecommendReadOnly )
200 if( !rCodeName.isEmpty() )
264 for( nC = 0 ; nC < nScTabCount ; nC++ )
289 for( nC = 0 ; nC < nScTabCount ; nC++ )
298 for(
SCTAB nAdd = 0; nC < static_cast<SCTAB>(nCodenames) ; nC++, nAdd++ )
381 for( nC = 0 ; nC < nScTabCount ; nC++ )
391 for(
SCTAB nAdd = 0; nC < static_cast<SCTAB>(nCodenames) ; nC++, nAdd++ )
419 OSL_ENSURE( (
mnScTab >= 0) && (
mnScTab <=
MAXTAB),
"-ExcTable::Table(): mnScTab - no ordinary table!" );
430 std::vector<sc::NoteEntry> aNotes;
432 for (
const auto& rNote : aNotes)
434 if (rNote.maPos.Tab() !=
mnScTab)
442 bool bFitToPages = xPageSett->GetPageData().mbFitToPages;
520 for (
const auto& rProt : rProts)
561 OSL_ENSURE( (
mnScTab >= 0) && (
mnScTab <=
MAXTAB),
"-ExcTable::Table(): mnScTab - no ordinary table!" );
571 std::vector<sc::NoteEntry> aNotes;
573 for (
const auto& rNote : aNotes)
575 if (rNote.maPos.Tab() !=
mnScTab)
584 bool bFitToPages = xPageSett->GetPageData().mbFitToPages;
627 if( pHyperlinkList !=
nullptr && !pHyperlinkList->
IsEmpty() )
696 rStrm.PushStream( pWorksheet );
698 pWorksheet->startElement( XML_worksheet,
699 XML_xmlns,
rStrm.getNamespaceURL(OOX_NS(xls)),
700 FSNS(XML_xmlns, XML_r),
rStrm.getNamespaceURL(OOX_NS(officeRel)),
701 FSNS(XML_xmlns, XML_xdr),
"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing",
702 FSNS(XML_xmlns, XML_x14),
rStrm.getNamespaceURL(OOX_NS(xls14Lst)),
703 FSNS(XML_xmlns, XML_xr2),
rStrm.getNamespaceURL(OOX_NS(xr2)),
704 FSNS(XML_xmlns, XML_mc),
rStrm.getNamespaceURL(OOX_NS(mce)));
715 rStrm.GetCurrentStream()->endElement( XML_worksheet );
746 for( ; nScTab < nScTabCount; ++nScTab )
753 xTab->FillAsTableBinary(nCodeNameIdx);
755 xTab->FillAsTableXml();
760 for( ; nCodeNameIdx < nCodeNameCount; ++nScTab, ++nCodeNameIdx )
764 xTab->FillAsEmptyTable( nCodeNameIdx );
773 if (
GetDoc().GetChangeTrack() )
789 "ExcDocument::Write - different number of sheets and BOUNDSHEET records" );
814 uno::Reference<document::XDocumentPropertiesSupplier> xDPS( pDocShell->
GetModel(), uno::UNO_QUERY_THROW );
815 uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties();
819 bool bHasPasswordHash = nWriteProtHash && !sUserName.isEmpty();
821 OUString sAlgorithm, sSalt,
sHash;
823 for (
const auto& prop : aInfo)
825 if (prop.Name ==
"algorithm-name")
826 prop.Value >>= sAlgorithm;
827 else if (prop.Name ==
"salt")
828 prop.Value >>= sSalt;
829 else if (prop.Name ==
"iteration-count")
831 else if (prop.Name ==
"hash")
832 prop.Value >>=
sHash;
834 bool bHasPasswordInfo
835 = sAlgorithm !=
"PBKDF2" && !sSalt.isEmpty() && !
sHash.isEmpty() && !sUserName.isEmpty();
837 && !bHasPasswordHash && !bHasPasswordInfo);
838 rStrm.exportCustomFragments();
841 rWorkbook->startElement( XML_workbook,
842 XML_xmlns,
rStrm.getNamespaceURL(OOX_NS(xls)),
843 FSNS(XML_xmlns, XML_r),
rStrm.getNamespaceURL(OOX_NS(officeRel)) );
844 rWorkbook->singleElement( XML_fileVersion,
852 if (bHasPasswordHash)
853 rWorkbook->singleElement(XML_fileSharing,
854 XML_userName, sUserName,
855 XML_reservationPassword, OString::number(nWriteProtHash, 16));
856 else if (bHasPasswordInfo)
857 rWorkbook->singleElement(XML_fileSharing,
858 XML_userName, sUserName,
859 XML_algorithmName, sAlgorithm,
860 XML_hashValue,
sHash,
861 XML_saltValue, sSalt,
862 XML_spinCount, OString::number(
nCount));
871 SdrPage* pPage = pDrawLayer->GetPage(0);
877 OUString sThemeRelationshipPath =
"theme/theme1.xml";
878 OUString sThemeDocumentPath =
"xl/" + sThemeRelationshipPath;
881 aThemeExport.
write(sThemeDocumentPath, *pTheme);
883 rStrm.addRelation(
rStrm.GetCurrentStream()->getOutputStream(),
885 sThemeRelationshipPath);
924 xExtLst->SaveXml(
rStrm);
927 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 ScDrawLayer * GetDrawLayer()
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
std::shared_ptr< model::Theme > const & GetTheme() const
SdrPageProperties & getSdrPageProperties()
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)
void write(OUString const &rPath, model::Theme const &rTheme)
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
OUString getRelationship(Relationship eRelationship)
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