Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef OOX_XLS_PIVOTCACHEFRAGMENT_HXX
21 : #define OOX_XLS_PIVOTCACHEFRAGMENT_HXX
22 :
23 : #include "excelhandlers.hxx"
24 :
25 : namespace oox {
26 : namespace xls {
27 :
28 : class PivotCache;
29 : class PivotCacheField;
30 :
31 : // ============================================================================
32 :
33 0 : class PivotCacheFieldContext : public WorkbookContextBase
34 : {
35 : public:
36 : explicit PivotCacheFieldContext(
37 : WorkbookFragmentBase& rFragment,
38 : PivotCacheField& rCacheField );
39 :
40 : protected:
41 : virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs );
42 : virtual void onStartElement( const AttributeList& rAttribs );
43 : virtual ::oox::core::ContextHandlerRef onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm );
44 : virtual void onStartRecord( SequenceInputStream& rStrm );
45 :
46 : private:
47 : PivotCacheField& mrCacheField;
48 : };
49 :
50 : // ============================================================================
51 :
52 0 : class PivotCacheDefinitionFragment : public WorkbookFragmentBase
53 : {
54 : public:
55 : explicit PivotCacheDefinitionFragment(
56 : const WorkbookHelper& rHelper,
57 : const ::rtl::OUString& rFragmentPath,
58 : PivotCache& rPivotCache );
59 :
60 : protected:
61 : virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs );
62 : virtual ::oox::core::ContextHandlerRef onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm );
63 : virtual const ::oox::core::RecordInfo* getRecordInfos() const;
64 : virtual void finalizeImport();
65 :
66 : private:
67 : PivotCache& mrPivotCache;
68 : };
69 :
70 : // ============================================================================
71 :
72 0 : class PivotCacheRecordsFragment : public WorksheetFragmentBase
73 : {
74 : public:
75 : explicit PivotCacheRecordsFragment(
76 : const WorksheetHelper& rHelper,
77 : const ::rtl::OUString& rFragmentPath,
78 : const PivotCache& rPivotCache );
79 :
80 : protected:
81 : virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs );
82 : virtual ::oox::core::ContextHandlerRef onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm );
83 : virtual const ::oox::core::RecordInfo* getRecordInfos() const;
84 :
85 : private:
86 : void startCacheRecord();
87 : void importPCRecord( SequenceInputStream& rStrm );
88 : void importPCRecordItem( sal_Int32 nRecId, SequenceInputStream& rStrm );
89 :
90 : private:
91 : const PivotCache& mrPivotCache;
92 : sal_Int32 mnColIdx; /// Relative column index in source data.
93 : sal_Int32 mnRowIdx; /// Relative row index in source data.
94 : bool mbInRecord;
95 : };
96 :
97 : // ============================================================================
98 : // ============================================================================
99 :
100 0 : class BiffPivotCacheFragment : public BiffWorkbookFragmentBase
101 : {
102 : public:
103 : explicit BiffPivotCacheFragment(
104 : const WorkbookHelper& rHelper,
105 : const ::rtl::OUString& rStrmName,
106 : PivotCache& rPivotCache );
107 :
108 : /** Imports the entire fragment, returns true, if EOF record has been reached. */
109 : virtual bool importFragment();
110 :
111 : private:
112 : PivotCache& mrPivotCache;
113 : };
114 :
115 : // ============================================================================
116 :
117 0 : class BiffPivotCacheRecordsContext : public BiffWorksheetContextBase
118 : {
119 : public:
120 : explicit BiffPivotCacheRecordsContext(
121 : const WorksheetHelper& rHelper,
122 : const PivotCache& rPivotCache );
123 :
124 : /** Reads the current record from stream and tries to insert a cell into
125 : the source data sheet. */
126 : virtual void importRecord( BiffInputStream& rStrm );
127 :
128 : private:
129 : void startNextRow();
130 :
131 : private:
132 : typedef ::std::vector< sal_Int32 > ColumnIndexVector;
133 :
134 : const PivotCache& mrPivotCache;
135 : ColumnIndexVector maUnsharedCols; /// Column indexes of all unshared cache fields.
136 : size_t mnColIdx; /// Current index into maUnsharedCols.
137 : sal_Int32 mnRowIdx; /// Current row in source data (0-based).
138 : bool mbHasShared; /// True = pivot cache contains fields with shared items.
139 : bool mbInRow; /// True = a data row has been started.
140 : };
141 :
142 : // ============================================================================
143 :
144 : } // namespace xls
145 : } // namespace oox
146 :
147 : #endif
148 :
149 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|