Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef OOX_XLS_EXCELHANDLERS_HXX
30 : : #define OOX_XLS_EXCELHANDLERS_HXX
31 : :
32 : : #include "oox/core/fragmenthandler2.hxx"
33 : : #include "worksheethelper.hxx"
34 : :
35 : : namespace oox {
36 : : namespace xls {
37 : :
38 : : // ============================================================================
39 : : // ============================================================================
40 : :
41 : : /** Context handler derived from the WorkbookHelper helper class.
42 : :
43 : : Used to import contexts in global workbook fragments.
44 : : */
45 [ + - ][ - + ]: 783 : class WorkbookContextBase : public ::oox::core::ContextHandler2, public WorkbookHelper
46 : : {
47 : : public:
48 : : template< typename ParentType >
49 : 783 : inline explicit WorkbookContextBase( ParentType& rParent ) :
50 : 783 : ::oox::core::ContextHandler2( rParent ), WorkbookHelper( rParent ) {}
51 : : };
52 : :
53 : : // ============================================================================
54 : :
55 : : /** Context handler derived from the WorksheetHelper helper class.
56 : :
57 : : Used to import contexts in sheet fragments.
58 : : */
59 [ + - ][ - + ]: 69 : class WorksheetContextBase : public ::oox::core::ContextHandler2, public WorksheetHelper
60 : : {
61 : : public:
62 : : template< typename ParentType >
63 : 69 : inline explicit WorksheetContextBase( ParentType& rParent ) :
64 [ + - ][ + - ]: 69 : ::oox::core::ContextHandler2( rParent ), WorksheetHelper( rParent ) {}
65 : : };
66 : :
67 : : // ============================================================================
68 : :
69 : : /** Fragment handler derived from the WorkbookHelper helper class.
70 : :
71 : : Used to import global workbook fragments.
72 : : */
73 [ + - ][ - + ]: 66 : class WorkbookFragmentBase : public ::oox::core::FragmentHandler2, public WorkbookHelper
74 : : {
75 : : public:
76 : : explicit WorkbookFragmentBase(
77 : : const WorkbookHelper& rHelper,
78 : : const ::rtl::OUString& rFragmentPath );
79 : : };
80 : :
81 : : // ============================================================================
82 : :
83 : : /** Fragment handler derived from the WorksheetHelper helper class.
84 : :
85 : : Used to import sheet fragments.
86 : : */
87 [ + - ][ - + ]: 69 : class WorksheetFragmentBase : public ::oox::core::FragmentHandler2, public WorksheetHelper
88 : : {
89 : : public:
90 : : explicit WorksheetFragmentBase(
91 : : const WorksheetHelper& rHelper,
92 : : const ::rtl::OUString& rFragmentPath );
93 : : };
94 : :
95 : : // ============================================================================
96 : : // ============================================================================
97 : :
98 : : /** Base class for all BIFF context handlers.
99 : :
100 : : Derived handlers have to implement the importRecord() function that has to
101 : : import the record the passed BIFF input stream currently points to.
102 : : */
103 : 0 : class BiffContextHandler
104 : : {
105 : : public:
106 : : virtual ~BiffContextHandler();
107 : :
108 : : /** Derived classes have to implement importing the current record. */
109 : : virtual void importRecord( BiffInputStream& rStrm ) = 0;
110 : : };
111 : :
112 : : // ----------------------------------------------------------------------------
113 : :
114 : : /** Context handler derived from the WorksheetHelper helper class.
115 : :
116 : : Used to import contexts in sheet fragments.
117 : : */
118 [ # # ][ # # ]: 0 : class BiffWorksheetContextBase : public BiffContextHandler, public WorksheetHelper
119 : : {
120 : : protected:
121 : : explicit BiffWorksheetContextBase( const WorksheetHelper& rHelper );
122 : : };
123 : :
124 : : // ============================================================================
125 : :
126 : : /** An enumeration for all types of fragments in a BIFF workbook stream. */
127 : : enum BiffFragmentType
128 : : {
129 : : BIFF_FRAGMENT_GLOBALS, /// Workbook globals fragment.
130 : : BIFF_FRAGMENT_WORKSHEET, /// Worksheet fragment.
131 : : BIFF_FRAGMENT_CHARTSHEET, /// Chart sheet fragment.
132 : : BIFF_FRAGMENT_MACROSHEET, /// Macro sheet fragment.
133 : : BIFF_FRAGMENT_MODULESHEET, /// BIFF5 VB module fragment.
134 : : BIFF_FRAGMENT_EMPTYSHEET, /// Sheet fragment of unsupported type.
135 : : BIFF_FRAGMENT_WORKSPACE, /// BIFF4 workspace/workbook globals.
136 : : BIFF_FRAGMENT_UNKNOWN /// Unknown fragment/error.
137 : : };
138 : :
139 : : // ----------------------------------------------------------------------------
140 : :
141 : : class BiffFragmentHandler
142 : : {
143 : : public:
144 : : /** Opens the stream with the passed full name. */
145 : : explicit BiffFragmentHandler(
146 : : const ::oox::core::FilterBase& rFilter,
147 : : const ::rtl::OUString& rStrmName );
148 : :
149 : : virtual ~BiffFragmentHandler();
150 : :
151 : : /** Imports the fragment, returns true, if EOF record has been reached. */
152 : : virtual bool importFragment() = 0;
153 : :
154 : : protected:
155 : : /** Returns the BIFF input stream of this fragment. */
156 : 0 : inline BiffInputStream& getInputStream() { return *mxBiffStrm; }
157 : :
158 : : /** Skips the current fragment up to its trailing EOF record.
159 : :
160 : : Skips all records until next EOF record. When this function returns,
161 : : stream points to the EOF record, and the next call of startNextRecord()
162 : : at the stream will start the record following the EOF record.
163 : :
164 : : Embedded fragments enclosed in BOF/EOF records (e.g. embedded chart
165 : : objects) are skipped correctly.
166 : :
167 : : @return True = stream points to the EOF record of the current fragment.
168 : : */
169 : : bool skipFragment();
170 : :
171 : : private:
172 : : typedef ::boost::shared_ptr< BinaryXInputStream > XInputStreamRef;
173 : : typedef ::boost::shared_ptr< BiffInputStream > BiffInputStreamRef;
174 : :
175 : : XInputStreamRef mxXInStrm;
176 : : BiffInputStreamRef mxBiffStrm;
177 : : };
178 : :
179 : : // ----------------------------------------------------------------------------
180 : :
181 : : /** Fragment handler derived from the WorkbookHelper helper class.
182 : :
183 : : Used to import global workbook fragments.
184 : : */
185 [ # # ][ # # ]: 0 : class BiffWorkbookFragmentBase : public BiffFragmentHandler, public WorkbookHelper
186 : : {
187 : : protected:
188 : : explicit BiffWorkbookFragmentBase(
189 : : const WorkbookHelper& rHelper,
190 : : const ::rtl::OUString& rStrmName,
191 : : bool bCloneDecoder = false );
192 : : };
193 : :
194 : : // ----------------------------------------------------------------------------
195 : :
196 : : } // namespace xls
197 : : } // namespace oox
198 : :
199 : : #endif
200 : :
201 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|