1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef SC_XEROOT_HXX 25 #define SC_XEROOT_HXX 26 27 #include <com/sun/star/beans/NamedValue.hpp> 28 29 #include "xlroot.hxx" 30 31 // Forward declarations of objects in public use ============================== 32 33 class XclExpStream; 34 class XclExpRecordBase; 35 class XclExpString; 36 37 typedef ScfRef< XclExpRecordBase > XclExpRecordRef; 38 typedef ScfRef< XclExpString > XclExpStringRef; 39 40 // Global data ================================================================ 41 42 class XclExpTabInfo; 43 class XclExpAddressConverter; 44 class XclExpFormulaCompiler; 45 class XclExpProgressBar; 46 class XclExpSst; 47 class XclExpPalette; 48 class XclExpFontBuffer; 49 class XclExpNumFmtBuffer; 50 class XclExpXFBuffer; 51 class XclExpLinkManager; 52 class XclExpNameManager; 53 class XclExpObjectManager; 54 class XclExpFilterManager; 55 class XclExpPivotTableManager; 56 57 /** Stores global buffers and data needed for Excel export filter. */ 58 struct XclExpRootData : public XclRootData 59 { 60 typedef ScfRef< XclExpTabInfo > XclExpTabInfoRef; 61 typedef ScfRef< XclExpAddressConverter > XclExpAddrConvRef; 62 typedef ScfRef< XclExpFormulaCompiler > XclExpFmlaCompRef; 63 typedef ScfRef< XclExpProgressBar > XclExpProgressRef; 64 65 typedef ScfRef< XclExpSst > XclExpSstRef; 66 typedef ScfRef< XclExpPalette > XclExpPaletteRef; 67 typedef ScfRef< XclExpFontBuffer > XclExpFontBfrRef; 68 typedef ScfRef< XclExpNumFmtBuffer > XclExpNumFmtBfrRef; 69 typedef ScfRef< XclExpXFBuffer > XclExpXFBfrRef; 70 typedef ScfRef< XclExpNameManager > XclExpNameMgrRef; 71 typedef ScfRef< XclExpLinkManager > XclExpLinkMgrRef; 72 typedef ScfRef< XclExpObjectManager > XclExpObjectMgrRef; 73 typedef ScfRef< XclExpFilterManager > XclExpFilterMgrRef; 74 typedef ScfRef< XclExpPivotTableManager > XclExpPTableMgrRef; 75 76 XclExpTabInfoRef mxTabInfo; /// Calc->Excel sheet index conversion. 77 XclExpAddrConvRef mxAddrConv; /// The address converter. 78 XclExpFmlaCompRef mxFmlaComp; /// The formula compiler. 79 XclExpProgressRef mxProgress; /// The export progress bar. 80 81 XclExpSstRef mxSst; /// The shared string table. 82 XclExpPaletteRef mxPalette; /// The color buffer. 83 XclExpFontBfrRef mxFontBfr; /// All fonts in the file. 84 XclExpNumFmtBfrRef mxNumFmtBfr; /// All number formats in the file. 85 XclExpXFBfrRef mxXFBfr; /// All XF records in the file. 86 XclExpNameMgrRef mxNameMgr; /// Internal defined names. 87 XclExpLinkMgrRef mxGlobLinkMgr; /// Global link manager for defined names. 88 XclExpLinkMgrRef mxLocLinkMgr; /// Local link manager for a sheet. 89 XclExpObjectMgrRef mxObjMgr; /// All drawing objects. 90 XclExpFilterMgrRef mxFilterMgr; /// Manager for filtered areas in all sheets. 91 XclExpPTableMgrRef mxPTableMgr; /// All pivot tables and pivot caches. 92 93 bool mbRelUrl; /// true = Store URLs relative. 94 95 explicit XclExpRootData( XclBiff eBiff, SfxMedium& rMedium, 96 SotStorageRef xRootStrg, ScDocument& rDoc, rtl_TextEncoding eTextEnc ); 97 virtual ~XclExpRootData(); 98 }; 99 100 // ---------------------------------------------------------------------------- 101 102 /** Access to global data from other classes. */ 103 class XclExpRoot : public XclRoot 104 { 105 public: 106 explicit XclExpRoot( XclExpRootData& rExpRootData ); 107 108 /** Returns this root instance - for code readability in derived classes. */ GetRoot() const109 inline const XclExpRoot& GetRoot() const { return *this; } 110 /** Returns true, if URLs should be stored relative to the document location. */ IsRelUrl() const111 inline bool IsRelUrl() const { return mrExpData.mbRelUrl; } 112 113 /** Returns the buffer for Calc->Excel sheet index conversion. */ 114 XclExpTabInfo& GetTabInfo() const; 115 /** Returns the address converter. */ 116 XclExpAddressConverter& GetAddressConverter() const; 117 /** Returns the formula compiler to produce formula token arrays. */ 118 XclExpFormulaCompiler& GetFormulaCompiler() const; 119 /** Returns the export progress bar. */ 120 XclExpProgressBar& GetProgressBar() const; 121 122 /** Returns the shared string table. */ 123 XclExpSst& GetSst() const; 124 /** Returns the color buffer. */ 125 XclExpPalette& GetPalette() const; 126 /** Returns the font buffer. */ 127 XclExpFontBuffer& GetFontBuffer() const; 128 /** Returns the number format buffer. */ 129 XclExpNumFmtBuffer& GetNumFmtBuffer() const; 130 /** Returns the cell formatting attributes buffer. */ 131 XclExpXFBuffer& GetXFBuffer() const; 132 /** Returns the global link manager for defined names. */ 133 XclExpLinkManager& GetGlobalLinkManager() const; 134 /** Returns the local link manager for the current sheet. */ 135 XclExpLinkManager& GetLocalLinkManager() const; 136 /** Returns the buffer that contains internal defined names. */ 137 XclExpNameManager& GetNameManager() const; 138 /** Returns the drawing object manager. */ 139 XclExpObjectManager& GetObjectManager() const; 140 /** Returns the filter manager. */ 141 XclExpFilterManager& GetFilterManager() const; 142 /** Returns the pivot table manager. */ 143 XclExpPivotTableManager& GetPivotTableManager() const; 144 145 /** Is called when export filter starts to create the Excel document (all BIFF versions). */ 146 void InitializeConvert(); 147 /** Is called when export filter starts to create the workbook global data (>=BIFF5). */ 148 void InitializeGlobals(); 149 /** Is called when export filter starts to create data for a single sheet (all BIFF versions). */ 150 void InitializeTable( SCTAB nScTab ); 151 /** Is called before export filter starts to write the records to the stream. */ 152 void InitializeSave(); 153 /** Returns the reference to a record (or record list) representing a root object. 154 @param nRecId Identifier that specifies which record is returned. */ 155 XclExpRecordRef CreateRecord( sal_uInt16 nRecId ) const; 156 157 bool IsDocumentEncrypted() const; 158 159 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > GenerateEncryptionData( const ::rtl::OUString& aPass ) const; 160 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > GetEncryptionData() const; 161 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > GenerateDefaultEncryptionData() const; 162 163 private: 164 165 /** Returns the local or global link manager, depending on current context. */ 166 XclExpRootData::XclExpLinkMgrRef GetLocalLinkMgrRef() const; 167 168 private: 169 XclExpRootData& mrExpData; /// Reference to the global export data struct. 170 }; 171 172 // ============================================================================ 173 174 #endif 175 176