xref: /aoo41x/main/sc/source/filter/inc/xecontent.hxx (revision 38d50f7b)
1*38d50f7bSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*38d50f7bSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*38d50f7bSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*38d50f7bSAndrew Rist  * distributed with this work for additional information
6*38d50f7bSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*38d50f7bSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*38d50f7bSAndrew Rist  * "License"); you may not use this file except in compliance
9*38d50f7bSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*38d50f7bSAndrew Rist  *
11*38d50f7bSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*38d50f7bSAndrew Rist  *
13*38d50f7bSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*38d50f7bSAndrew Rist  * software distributed under the License is distributed on an
15*38d50f7bSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*38d50f7bSAndrew Rist  * KIND, either express or implied.  See the License for the
17*38d50f7bSAndrew Rist  * specific language governing permissions and limitations
18*38d50f7bSAndrew Rist  * under the License.
19*38d50f7bSAndrew Rist  *
20*38d50f7bSAndrew Rist  *************************************************************/
21*38d50f7bSAndrew Rist 
22*38d50f7bSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SC_XECONTENT_HXX
25cdf0e10cSrcweir #define SC_XECONTENT_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "rangelst.hxx"
28cdf0e10cSrcweir #include "xlcontent.hxx"
29cdf0e10cSrcweir #include "xladdress.hxx"
30cdf0e10cSrcweir #include "xerecord.hxx"
31cdf0e10cSrcweir #include "xeroot.hxx"
32cdf0e10cSrcweir #include "xestring.hxx"
33cdf0e10cSrcweir #include "xeformula.hxx"
34cdf0e10cSrcweir 
35cdf0e10cSrcweir /* ============================================================================
36cdf0e10cSrcweir Classes to export the big Excel document contents (related to several cells or
37cdf0e10cSrcweir globals for the sheet or document).
38cdf0e10cSrcweir - Shared string table
39cdf0e10cSrcweir - Merged cells
40cdf0e10cSrcweir - Hyperlinks
41cdf0e10cSrcweir - Label ranges
42cdf0e10cSrcweir - Conditional formatting
43cdf0e10cSrcweir - Data validation
44cdf0e10cSrcweir - Web Queries
45cdf0e10cSrcweir ============================================================================ */
46cdf0e10cSrcweir 
47cdf0e10cSrcweir // Shared string table ========================================================
48cdf0e10cSrcweir 
49cdf0e10cSrcweir class XclExpSstImpl;
50cdf0e10cSrcweir 
51cdf0e10cSrcweir /** Provides export of the SST (shared string table) record.
52cdf0e10cSrcweir     @descr  Contains all strings in the document and writes the SST. */
53cdf0e10cSrcweir class XclExpSst : public XclExpRecordBase
54cdf0e10cSrcweir {
55cdf0e10cSrcweir public:
56cdf0e10cSrcweir     explicit            XclExpSst();
57cdf0e10cSrcweir     virtual             ~XclExpSst();
58cdf0e10cSrcweir 
59cdf0e10cSrcweir     /** Inserts a new string into the table.
60cdf0e10cSrcweir         @return  The index of the string in the SST, used in other records. */
61cdf0e10cSrcweir     sal_uInt32          Insert( XclExpStringRef xString );
62cdf0e10cSrcweir 
63cdf0e10cSrcweir     /** Writes the complete SST and EXTSST records. */
64cdf0e10cSrcweir     virtual void        Save( XclExpStream& rStrm );
65cdf0e10cSrcweir     virtual void        SaveXml( XclExpXmlStream& rStrm );
66cdf0e10cSrcweir 
67cdf0e10cSrcweir private:
68cdf0e10cSrcweir     typedef ::std::auto_ptr< XclExpSstImpl > XclExpSstImplPtr;
69cdf0e10cSrcweir     XclExpSstImplPtr    mxImpl;
70cdf0e10cSrcweir };
71cdf0e10cSrcweir 
72cdf0e10cSrcweir // Merged cells ===============================================================
73cdf0e10cSrcweir 
74cdf0e10cSrcweir /** Represents a MERGEDCELLS record containing all merged cell ranges in a sheet. */
75cdf0e10cSrcweir class XclExpMergedcells : public XclExpRecordBase, protected XclExpRoot
76cdf0e10cSrcweir {
77cdf0e10cSrcweir public:
78cdf0e10cSrcweir     explicit            XclExpMergedcells( const XclExpRoot& rRoot );
79cdf0e10cSrcweir 
80cdf0e10cSrcweir     /** Appends a new range to the list of merged cell ranges. */
81cdf0e10cSrcweir     void                AppendRange( const ScRange& rRange, sal_uInt32 nBaseXFId );
82cdf0e10cSrcweir     /** Returns the XF identifier of the top-left cell in a merged range. */
83cdf0e10cSrcweir     sal_uInt32          GetBaseXFId( const ScAddress& rPos ) const;
84cdf0e10cSrcweir 
85cdf0e10cSrcweir     /** Writes the record, if it contains at least one merged cell range. */
86cdf0e10cSrcweir     virtual void        Save( XclExpStream& rStrm );
87cdf0e10cSrcweir     virtual void        SaveXml( XclExpXmlStream& rStrm );
88cdf0e10cSrcweir 
89cdf0e10cSrcweir private:
90cdf0e10cSrcweir     ScRangeList         maMergedRanges;     /// All merged cell ranges of the sheet.
91cdf0e10cSrcweir     ScfUInt32Vec        maBaseXFIds;        /// The XF identifiers of the top-left cells.
92cdf0e10cSrcweir };
93cdf0e10cSrcweir 
94cdf0e10cSrcweir // Hyperlinks =================================================================
95cdf0e10cSrcweir 
96cdf0e10cSrcweir class SvxURLField;
97cdf0e10cSrcweir class INetURLObject;
98cdf0e10cSrcweir 
99cdf0e10cSrcweir /** Provides export of hyperlink data. */
100cdf0e10cSrcweir class XclExpHyperlink : public XclExpRecord
101cdf0e10cSrcweir {
102cdf0e10cSrcweir public:
103cdf0e10cSrcweir     /** Constructs the HLINK record from an URL text field. */
104cdf0e10cSrcweir     explicit            XclExpHyperlink( const XclExpRoot& rRoot,
105cdf0e10cSrcweir                             const SvxURLField& rUrlField, const ScAddress& rScPos );
106cdf0e10cSrcweir     virtual             ~XclExpHyperlink();
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     /** Returns the cell representation text or 0, if not available. */
GetRepr() const109cdf0e10cSrcweir     inline const String* GetRepr() const { return mxRepr.get(); }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     virtual void        SaveXml( XclExpXmlStream& rStrm );
112cdf0e10cSrcweir private:
113cdf0e10cSrcweir     /** Builds file name from the passed file URL. Tries to convert to relative file name.
114cdf0e10cSrcweir         @param rnLevel  (out-param) The parent directory level.
115cdf0e10cSrcweir         @param rbRel  (out-param) true = path is relative. */
116cdf0e10cSrcweir     String              BuildFileName(
117cdf0e10cSrcweir                             sal_uInt16& rnLevel, bool& rbRel,
118cdf0e10cSrcweir                             const String& rUrl, const XclExpRoot& rRoot ) const;
119cdf0e10cSrcweir 
120cdf0e10cSrcweir     /** Writes the body of the HLINK record. */
121cdf0e10cSrcweir     virtual void        WriteBody( XclExpStream& rStrm );
122cdf0e10cSrcweir 
123cdf0e10cSrcweir private:
124cdf0e10cSrcweir     typedef ::std::auto_ptr< String >   StringPtr;
125cdf0e10cSrcweir     typedef ::std::auto_ptr< SvStream > SvStreamPtr;
126cdf0e10cSrcweir 
127cdf0e10cSrcweir     ScAddress           maScPos;            /// Position of the hyperlink.
128cdf0e10cSrcweir     StringPtr           mxRepr;             /// Cell representation text.
129cdf0e10cSrcweir     SvStreamPtr         mxVarData;          /// Buffer stream with variable data.
130cdf0e10cSrcweir     sal_uInt32          mnFlags;            /// Option flags.
131cdf0e10cSrcweir     XclExpStringRef     mxTextMark;         /// Location within mxRepr
132cdf0e10cSrcweir     ::rtl::OUString     msTarget;           /// Target URL
133cdf0e10cSrcweir };
134cdf0e10cSrcweir 
135cdf0e10cSrcweir typedef XclExpRecordList< XclExpHyperlink > XclExpHyperlinkList;
136cdf0e10cSrcweir 
137cdf0e10cSrcweir // Label ranges ===============================================================
138cdf0e10cSrcweir 
139cdf0e10cSrcweir /** Provides export of the row/column label range list of a sheet. */
140cdf0e10cSrcweir class XclExpLabelranges : public XclExpRecordBase, protected XclExpRoot
141cdf0e10cSrcweir {
142cdf0e10cSrcweir public:
143cdf0e10cSrcweir     /** Fills the cell range lists with all ranges of the current sheet. */
144cdf0e10cSrcweir     explicit            XclExpLabelranges( const XclExpRoot& rRoot );
145cdf0e10cSrcweir 
146cdf0e10cSrcweir     /** Writes the LABELRANGES record if it contains at least one range. */
147cdf0e10cSrcweir     virtual void        Save( XclExpStream& rStrm );
148cdf0e10cSrcweir 
149cdf0e10cSrcweir private:
150cdf0e10cSrcweir     /** Fills the specified range list with all label headers of the current sheet.
151cdf0e10cSrcweir         @param rRanges  The cell range list to fill.
152cdf0e10cSrcweir         @param xLabelRangesRef  The core range list with all ranges.
153cdf0e10cSrcweir         @param nScTab  The current Calc sheet index. */
154cdf0e10cSrcweir     void                FillRangeList( ScRangeList& rScRanges,
155cdf0e10cSrcweir                             ScRangePairListRef xLabelRangesRef, SCTAB nScTab );
156cdf0e10cSrcweir 
157cdf0e10cSrcweir private:
158cdf0e10cSrcweir     ScRangeList         maRowRanges;    /// Cell range list for row labels.
159cdf0e10cSrcweir     ScRangeList         maColRanges;    /// Cell range list for column labels.
160cdf0e10cSrcweir };
161cdf0e10cSrcweir 
162cdf0e10cSrcweir // Conditional formatting =====================================================
163cdf0e10cSrcweir 
164cdf0e10cSrcweir class ScCondFormatEntry;
165cdf0e10cSrcweir class XclExpCFImpl;
166cdf0e10cSrcweir 
167cdf0e10cSrcweir /** Represents a CF record that contains one condition of a conditional format. */
168cdf0e10cSrcweir class XclExpCF : public XclExpRecord, protected XclExpRoot
169cdf0e10cSrcweir {
170cdf0e10cSrcweir public:
171cdf0e10cSrcweir     explicit            XclExpCF( const XclExpRoot& rRoot, const ScCondFormatEntry& rFormatEntry );
172cdf0e10cSrcweir     virtual             ~XclExpCF();
173cdf0e10cSrcweir 
174cdf0e10cSrcweir private:
175cdf0e10cSrcweir     /** Writes the body of the CF record. */
176cdf0e10cSrcweir     virtual void        WriteBody( XclExpStream& rStrm );
177cdf0e10cSrcweir 
178cdf0e10cSrcweir private:
179cdf0e10cSrcweir     typedef ::std::auto_ptr< XclExpCFImpl > XclExpCFImplPtr;
180cdf0e10cSrcweir     XclExpCFImplPtr     mxImpl;
181cdf0e10cSrcweir };
182cdf0e10cSrcweir 
183cdf0e10cSrcweir // ----------------------------------------------------------------------------
184cdf0e10cSrcweir 
185cdf0e10cSrcweir class ScConditionalFormat;
186cdf0e10cSrcweir 
187cdf0e10cSrcweir /** Represents a CONDFMT record that contains all conditions of a conditional format.
188cdf0e10cSrcweir     @descr  Contains the conditions which are stored in CF records. */
189cdf0e10cSrcweir class XclExpCondfmt : public XclExpRecord, protected XclExpRoot
190cdf0e10cSrcweir {
191cdf0e10cSrcweir public:
192cdf0e10cSrcweir     explicit            XclExpCondfmt( const XclExpRoot& rRoot, const ScConditionalFormat& rCondFormat );
193cdf0e10cSrcweir     virtual             ~XclExpCondfmt();
194cdf0e10cSrcweir 
195cdf0e10cSrcweir     /** Returns true, if this conditional format contains at least one cell range and CF record. */
196cdf0e10cSrcweir     bool                IsValid() const;
197cdf0e10cSrcweir 
198cdf0e10cSrcweir     /** Writes the CONDFMT record with following CF records, if there is valid data. */
199cdf0e10cSrcweir     virtual void        Save( XclExpStream& rStrm );
200cdf0e10cSrcweir     virtual void        SaveXml( XclExpXmlStream& rStrm );
201cdf0e10cSrcweir 
202cdf0e10cSrcweir private:
203cdf0e10cSrcweir     /** Writes the body of the CONDFMT record. */
204cdf0e10cSrcweir     virtual void        WriteBody( XclExpStream& rStrm );
205cdf0e10cSrcweir 
206cdf0e10cSrcweir private:
207cdf0e10cSrcweir     typedef XclExpRecordList< XclExpCF > XclExpCFList;
208cdf0e10cSrcweir 
209cdf0e10cSrcweir     XclExpCFList        maCFList;       /// List of CF records.
210cdf0e10cSrcweir     XclRangeList        maXclRanges;    /// Cell ranges for this conditional format.
211cdf0e10cSrcweir     String              msSeqRef;       /// OOXML Sequence of References
212cdf0e10cSrcweir };
213cdf0e10cSrcweir 
214cdf0e10cSrcweir // ----------------------------------------------------------------------------
215cdf0e10cSrcweir 
216cdf0e10cSrcweir /** Contains all conditional formats of a specific sheet. */
217cdf0e10cSrcweir class XclExpCondFormatBuffer : public XclExpRecordBase, protected XclExpRoot
218cdf0e10cSrcweir {
219cdf0e10cSrcweir public:
220cdf0e10cSrcweir     /** Constructs CONDFMT and CF records containing the conditional formats of the current sheet. */
221cdf0e10cSrcweir     explicit            XclExpCondFormatBuffer( const XclExpRoot& rRoot );
222cdf0e10cSrcweir 
223cdf0e10cSrcweir     /** Writes all contained CONDFMT records with their CF records. */
224cdf0e10cSrcweir     virtual void        Save( XclExpStream& rStrm );
225cdf0e10cSrcweir     virtual void        SaveXml( XclExpXmlStream& rStrm );
226cdf0e10cSrcweir 
227cdf0e10cSrcweir private:
228cdf0e10cSrcweir     typedef XclExpRecordList< XclExpCondfmt > XclExpCondfmtList;
229cdf0e10cSrcweir     XclExpCondfmtList   maCondfmtList;  /// List of CONDFMT records.
230cdf0e10cSrcweir };
231cdf0e10cSrcweir 
232cdf0e10cSrcweir // Data Validation ============================================================
233cdf0e10cSrcweir 
234cdf0e10cSrcweir class ScValidationData;
235cdf0e10cSrcweir 
236cdf0e10cSrcweir /** Provides export of the data of a DV record.
237cdf0e10cSrcweir     @descr  This record contains the settings for a data validation. In detail
238cdf0e10cSrcweir     this is a pointer to the core validation data and a cell range list with all
239cdf0e10cSrcweir     affected cells. The handle index is used to optimize list search algorithm. */
240cdf0e10cSrcweir class XclExpDV : public XclExpRecord, protected XclExpRoot
241cdf0e10cSrcweir {
242cdf0e10cSrcweir public:
243cdf0e10cSrcweir     explicit            XclExpDV( const XclExpRoot& rRoot, sal_uLong nScHandle );
244cdf0e10cSrcweir     virtual             ~XclExpDV();
245cdf0e10cSrcweir 
246cdf0e10cSrcweir     /** Returns the core handle of the validation data. */
GetScHandle() const247cdf0e10cSrcweir     inline sal_uLong        GetScHandle() const { return mnScHandle; }
248cdf0e10cSrcweir 
249cdf0e10cSrcweir     /** Inserts a new cell range into the cell range list. */
250cdf0e10cSrcweir     void                InsertCellRange( const ScRange& rPos );
251cdf0e10cSrcweir     /** Converts the Calc range list to the Excel range list.
252cdf0e10cSrcweir         @return  false = Resulting range list empty - do not write this record. */
253cdf0e10cSrcweir     bool                Finalize();
254cdf0e10cSrcweir 
255cdf0e10cSrcweir     virtual void        SaveXml( XclExpXmlStream& rStrm );
256cdf0e10cSrcweir 
257cdf0e10cSrcweir private:
258cdf0e10cSrcweir     /** Writes the body of the DV record. */
259cdf0e10cSrcweir     virtual void        WriteBody( XclExpStream& rStrm );
260cdf0e10cSrcweir 
261cdf0e10cSrcweir private:
262cdf0e10cSrcweir     ScRangeList         maScRanges;     /// Calc range list with all affected cells.
263cdf0e10cSrcweir     XclRangeList        maXclRanges;    /// Excel range list with all affected cells.
264cdf0e10cSrcweir     XclExpString        maPromptTitle;  /// The prompt title.
265cdf0e10cSrcweir     XclExpString        maPromptText;   /// The prompt text.
266cdf0e10cSrcweir     XclExpString        maErrorTitle;   /// The error title.
267cdf0e10cSrcweir     XclExpString        maErrorText;    /// The error text.
268cdf0e10cSrcweir     XclExpStringRef     mxString1;      /// String for first condition formula.
269cdf0e10cSrcweir     XclTokenArrayRef    mxTokArr1;      /// Formula for first condition.
270cdf0e10cSrcweir     ::rtl::OUString     msFormula1;     /// OOXML Formula for first condition.
271cdf0e10cSrcweir     XclTokenArrayRef    mxTokArr2;      /// Formula for second condition.
272cdf0e10cSrcweir     ::rtl::OUString     msFormula2;     /// OOXML Formula for second condition.
273cdf0e10cSrcweir     sal_uInt32          mnFlags;        /// Miscellaneous flags.
274cdf0e10cSrcweir     sal_uLong               mnScHandle;     /// The core handle for quick list search.
275cdf0e10cSrcweir };
276cdf0e10cSrcweir 
277cdf0e10cSrcweir // ----------------------------------------------------------------------------
278cdf0e10cSrcweir 
279cdf0e10cSrcweir /** This class contains the DV record list following the DVAL record. */
280cdf0e10cSrcweir class XclExpDval : public XclExpRecord, protected XclExpRoot
281cdf0e10cSrcweir {
282cdf0e10cSrcweir public:
283cdf0e10cSrcweir     explicit            XclExpDval( const XclExpRoot& rRoot );
284cdf0e10cSrcweir     virtual             ~XclExpDval();
285cdf0e10cSrcweir 
286cdf0e10cSrcweir     /** Inserts the cell range into the range list of the DV record with the specified handle. */
287cdf0e10cSrcweir     void                InsertCellRange( const ScRange& rRange, sal_uLong nScHandle );
288cdf0e10cSrcweir 
289cdf0e10cSrcweir     /** Writes the DVAL record and the DV record list. */
290cdf0e10cSrcweir     virtual void        Save( XclExpStream& rStrm );
291cdf0e10cSrcweir     virtual void        SaveXml( XclExpXmlStream& rStrm );
292cdf0e10cSrcweir 
293cdf0e10cSrcweir private:
294cdf0e10cSrcweir     /** Searches for or creates a XclExpDV record object with the specified handle. */
295cdf0e10cSrcweir     XclExpDV&           SearchOrCreateDv( sal_uLong nScHandle );
296cdf0e10cSrcweir 
297cdf0e10cSrcweir     /** Writes the body of the DVAL record. */
298cdf0e10cSrcweir     virtual void        WriteBody( XclExpStream& rStrm );
299cdf0e10cSrcweir 
300cdf0e10cSrcweir private:
301cdf0e10cSrcweir     typedef XclExpRecordList< XclExpDV >    XclExpDVList;
302cdf0e10cSrcweir     typedef XclExpDVList::RecordRefType     XclExpDVRef;
303cdf0e10cSrcweir 
304cdf0e10cSrcweir     XclExpDVList        maDVList;       /// List of DV records
305cdf0e10cSrcweir     XclExpDVRef         mxLastFoundDV;  /// For search optimization.
306cdf0e10cSrcweir };
307cdf0e10cSrcweir 
308cdf0e10cSrcweir // Web Queries ================================================================
309cdf0e10cSrcweir 
310cdf0e10cSrcweir /** Contains all records for a web query (linked tables in an HTML document).
311cdf0e10cSrcweir     @descr  mode 1 (entire document): mpQryTables==0, mbEntireDoc==true;
312cdf0e10cSrcweir     mode 2 (all tables): mpQryTables==0, mbEntireDoc==false;
313cdf0e10cSrcweir     mode 3 (custom range list): mpQryTables!=0, mbEntireDoc==false. */
314cdf0e10cSrcweir class XclExpWebQuery : public XclExpRecordBase
315cdf0e10cSrcweir {
316cdf0e10cSrcweir public:
317cdf0e10cSrcweir     /** Constructs a web query record container with settings from Calc. */
318cdf0e10cSrcweir     explicit            XclExpWebQuery(
319cdf0e10cSrcweir                             const String& rRangeName,
320cdf0e10cSrcweir                             const String& rUrl,
321cdf0e10cSrcweir                             const String& rSource,
322cdf0e10cSrcweir                             sal_Int32 nRefrSecs );
323cdf0e10cSrcweir     virtual             ~XclExpWebQuery();
324cdf0e10cSrcweir 
325cdf0e10cSrcweir     /** Writes all needed records for this web query. */
326cdf0e10cSrcweir     virtual void        Save( XclExpStream& rStrm );
327cdf0e10cSrcweir 
328cdf0e10cSrcweir private:
329cdf0e10cSrcweir     XclExpString        maDestRange;    /// Destination range.
330cdf0e10cSrcweir     XclExpString        maUrl;          /// Source document URL.
331cdf0e10cSrcweir     XclExpStringRef     mxQryTables;    /// List of source range names.
332cdf0e10cSrcweir     sal_Int16           mnRefresh;      /// Refresh time in minutes.
333cdf0e10cSrcweir     bool                mbEntireDoc;    /// true = entire document.
334cdf0e10cSrcweir };
335cdf0e10cSrcweir 
336cdf0e10cSrcweir // ----------------------------------------------------------------------------
337cdf0e10cSrcweir 
338cdf0e10cSrcweir /** Contains all web query records for this document. */
339cdf0e10cSrcweir class XclExpWebQueryBuffer : public XclExpRecordList< XclExpWebQuery >
340cdf0e10cSrcweir {
341cdf0e10cSrcweir public:
342cdf0e10cSrcweir     explicit            XclExpWebQueryBuffer( const XclExpRoot& rRoot );
343cdf0e10cSrcweir };
344cdf0e10cSrcweir 
345cdf0e10cSrcweir // ============================================================================
346cdf0e10cSrcweir 
347cdf0e10cSrcweir #endif
348cdf0e10cSrcweir 
349