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 : #include "excelhandlers.hxx"
21 :
22 : #include "oox/core/filterbase.hxx"
23 : #include "biffinputstream.hxx"
24 :
25 : namespace oox {
26 : namespace xls {
27 :
28 : // ============================================================================
29 :
30 : using ::oox::core::FilterBase;
31 : using ::oox::core::FragmentHandler2;
32 :
33 : // ============================================================================
34 : // ============================================================================
35 :
36 53 : WorkbookFragmentBase::WorkbookFragmentBase(
37 : const WorkbookHelper& rHelper, const OUString& rFragmentPath ) :
38 53 : FragmentHandler2( rHelper.getOoxFilter(), rFragmentPath ),
39 53 : WorkbookHelper( rHelper )
40 : {
41 53 : }
42 :
43 : // ============================================================================
44 :
45 48 : WorksheetFragmentBase::WorksheetFragmentBase(
46 : const WorksheetHelper& rHelper, const OUString& rFragmentPath ) :
47 48 : FragmentHandler2( rHelper.getOoxFilter(), rFragmentPath ),
48 48 : WorksheetHelper( rHelper )
49 : {
50 48 : }
51 :
52 : // ============================================================================
53 : // ============================================================================
54 :
55 0 : BiffContextHandler::~BiffContextHandler()
56 : {
57 0 : }
58 :
59 : // ----------------------------------------------------------------------------
60 :
61 0 : BiffWorksheetContextBase::BiffWorksheetContextBase( const WorksheetHelper& rHelper ) :
62 0 : WorksheetHelper( rHelper )
63 : {
64 0 : }
65 :
66 : // ============================================================================
67 :
68 : namespace {
69 :
70 : const sal_uInt16 BIFF_BOF_GLOBALS = 0x0005; /// BIFF5-BIFF8 workbook globals.
71 : const sal_uInt16 BIFF_BOF_MODULE = 0x0006; /// BIFF5-BIFF8 Visual Basic module.
72 : const sal_uInt16 BIFF_BOF_SHEET = 0x0010; /// BIFF2-BIFF8 worksheet/dialog sheet.
73 : const sal_uInt16 BIFF_BOF_CHART = 0x0020; /// BIFF2-BIFF8 chart sheet.
74 : const sal_uInt16 BIFF_BOF_MACRO = 0x0040; /// BIFF4-BIFF8 macro sheet.
75 : const sal_uInt16 BIFF_BOF_WORKSPACE = 0x0100; /// BIFF3-BIFF8 workspace.
76 :
77 : } // namespace
78 :
79 : // ----------------------------------------------------------------------------
80 :
81 0 : BiffFragmentHandler::BiffFragmentHandler( const FilterBase& rFilter, const OUString& rStrmName )
82 : {
83 : // do not automatically close the root stream (indicated by empty stream name)
84 0 : bool bRootStrm = rStrmName.isEmpty();
85 0 : mxXInStrm.reset( new BinaryXInputStream( rFilter.openInputStream( rStrmName ), !bRootStrm ) );
86 0 : mxBiffStrm.reset( new BiffInputStream( *mxXInStrm ) );
87 0 : }
88 :
89 0 : BiffFragmentHandler::~BiffFragmentHandler()
90 : {
91 0 : }
92 :
93 0 : bool BiffFragmentHandler::skipFragment()
94 : {
95 0 : while( mxBiffStrm->startNextRecord() && (mxBiffStrm->getRecId() != BIFF_ID_EOF) )
96 0 : if( BiffHelper::isBofRecord( *mxBiffStrm ) )
97 0 : skipFragment();
98 0 : return !mxBiffStrm->isEof() && (mxBiffStrm->getRecId() == BIFF_ID_EOF);
99 : }
100 :
101 : // ============================================================================
102 :
103 0 : BiffWorkbookFragmentBase::BiffWorkbookFragmentBase( const WorkbookHelper& rHelper, const OUString& rStrmName, bool bCloneDecoder ) :
104 0 : BiffFragmentHandler( rHelper.getBaseFilter(), rStrmName ),
105 0 : WorkbookHelper( rHelper )
106 : {
107 0 : if( bCloneDecoder )
108 0 : getCodecHelper().cloneDecoder( getInputStream() );
109 0 : }
110 :
111 : // ----------------------------------------------------------------------------
112 :
113 : } // namespace xls
114 15 : } // namespace oox
115 :
116 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|