Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / sc / source / filter / oox / tablefragment.cxx
blob12a45ec362ce2cd21064cac85af49d0eb3de290b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "tablefragment.hxx"
22 #include "autofilterbuffer.hxx"
23 #include "autofiltercontext.hxx"
24 #include "tablecolumnsbuffer.hxx"
25 #include "tablecolumnscontext.hxx"
26 #include "tablebuffer.hxx"
27 #include <oox/token/namespaces.hxx>
28 #include <oox/token/tokens.hxx>
30 namespace oox {
31 namespace xls {
33 using namespace ::oox::core;
35 TableFragment::TableFragment( const WorksheetHelper& rHelper, const OUString& rFragmentPath ) :
36 WorksheetFragmentBase( rHelper, rFragmentPath ),
37 mrTable( getTables().createTable() )
41 ContextHandlerRef TableFragment::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
43 switch( getCurrentElement() )
45 case XML_ROOT_CONTEXT:
46 if( nElement == XLS_TOKEN( table ) )
48 mrTable.importTable( rAttribs, getSheetIndex() );
49 return this;
51 break;
52 case XLS_TOKEN( table ):
53 switch (nElement)
55 case XLS_TOKEN( autoFilter ):
56 return new AutoFilterContext( *this, mrTable.createAutoFilter() );
57 case XLS_TOKEN( tableColumns ):
58 return new TableColumnsContext( *this, mrTable.createTableColumns() );
60 break;
62 return nullptr;
65 ContextHandlerRef TableFragment::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
67 switch( getCurrentElement() )
69 case XML_ROOT_CONTEXT:
70 if( nRecId == BIFF12_ID_TABLE )
72 mrTable.importTable( rStrm, getSheetIndex() );
73 return this;
75 break;
76 case BIFF12_ID_TABLE:
77 if( nRecId == BIFF12_ID_AUTOFILTER )
78 return new AutoFilterContext( *this, mrTable.createAutoFilter() );
79 break;
81 return nullptr;
84 const RecordInfo* TableFragment::getRecordInfos() const
86 static const RecordInfo spRecInfos[] =
88 { BIFF12_ID_AUTOFILTER, BIFF12_ID_AUTOFILTER + 1 },
89 { BIFF12_ID_CUSTOMFILTERS, BIFF12_ID_CUSTOMFILTERS + 1 },
90 { BIFF12_ID_DISCRETEFILTERS, BIFF12_ID_DISCRETEFILTERS + 1 },
91 { BIFF12_ID_FILTERCOLUMN, BIFF12_ID_FILTERCOLUMN + 1 },
92 { BIFF12_ID_TABLE, BIFF12_ID_TABLE + 1 },
93 { -1, -1 }
95 return spRecInfos;
98 } // namespace xls
99 } // namespace oox
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */