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 OOX_XLS_QUERYTABLEBUFFER_HXX
25 #define OOX_XLS_QUERYTABLEBUFFER_HXX
26 
27 #include "oox/xls/stylesbuffer.hxx"
28 #include "oox/xls/worksheethelper.hxx"
29 
30 namespace oox {
31 namespace xls {
32 
33 // ============================================================================
34 
35 struct QueryTableModel : public AutoFormatModel
36 {
37     ::rtl::OUString     maDefName;          /// Defined name containing the target cell range.
38     sal_Int32           mnConnId;           /// Identifier of the external connection used to query the data.
39     sal_Int32           mnGrowShrinkType;   /// Behaviour when source data size changes.
40     bool                mbHeaders;          /// True = source data contains a header row.
41     bool                mbRowNumbers;       /// True = first column contains row numbers.
42     bool                mbDisableRefresh;   /// True = refreshing data disabled.
43     bool                mbBackground;       /// True = refresh asynchronously.
44     bool                mbFirstBackground;  /// True = first background refresh not yet finished.
45     bool                mbRefreshOnLoad;    /// True = refresh table after import.
46     bool                mbFillFormulas;     /// True = expand formulas next to range when source data grows.
47     bool                mbRemoveDataOnSave; /// True = remove querried data before saving.
48     bool                mbDisableEdit;      /// True = connection locked for editing.
49     bool                mbPreserveFormat;   /// True = use existing formatting for new rows.
50     bool                mbAdjustColWidth;   /// True = adjust column widths after refresh.
51     bool                mbIntermediate;     /// True = query table defined but not built yet.
52 
53     explicit            QueryTableModel();
54 };
55 
56 // ----------------------------------------------------------------------------
57 
58 class QueryTable : public WorksheetHelper
59 {
60 public:
61     explicit            QueryTable( const WorksheetHelper& rHelper );
62 
63     /** Imports query table settings from the queryTable element. */
64     void                importQueryTable( const AttributeList& rAttribs );
65     /** Imports query table settings from the QUERYTABLE record. */
66     void                importQueryTable( SequenceInputStream& rStrm );
67 
68     /** Imports query table settings from the QUERYTABLE record. */
69     void                importQueryTable( BiffInputStream& rStrm );
70     /** Imports query table settings from the QUERYTABLEREFRESH record. */
71     void                importQueryTableRefresh( BiffInputStream& rStrm );
72     /** Imports query table settings from the QUERYTABLESETTINGS record. */
73     void                importQueryTableSettings( BiffInputStream& rStrm );
74 
75     /** Inserts a web query into the sheet. */
76     void                finalizeImport();
77 
78 private:
79     QueryTableModel     maModel;
80 };
81 
82 // ============================================================================
83 
84 class QueryTableBuffer : public WorksheetHelper
85 {
86 public:
87     explicit            QueryTableBuffer( const WorksheetHelper& rHelper );
88 
89     /** Creates a new query table and stores it into the internal vector. */
90     QueryTable&         createQueryTable();
91 
92     /** Inserts all web queries into the sheet. */
93     void                finalizeImport();
94 
95 private:
96     typedef RefVector< QueryTable > QueryTableVector;
97     QueryTableVector    maQueryTables;
98 };
99 
100 // ============================================================================
101 
102 } // namespace xls
103 } // namespace oox
104 
105 #endif
106