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