Update git submodules
[LibreOffice.git] / sc / source / filter / oox / scenariocontext.cxx
blob2e192d4a3d67f3e5e8d72c4397aac6ca596f9efa
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 <scenariocontext.hxx>
21 #include <biffhelper.hxx>
23 #include <scenariobuffer.hxx>
24 #include <oox/token/namespaces.hxx>
26 namespace oox::xls {
28 using ::oox::core::ContextHandlerRef;
30 ScenarioContext::ScenarioContext( WorksheetContextBase& rParent, SheetScenarios& rSheetScenarios ) :
31 WorksheetContextBase( rParent ),
32 mrScenario( rSheetScenarios.createScenario() )
36 ContextHandlerRef ScenarioContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
38 switch( getCurrentElement() )
40 case XLS_TOKEN( scenario ):
41 if( nElement == XLS_TOKEN( inputCells ) ) mrScenario.importInputCells( rAttribs );
42 break;
44 return nullptr;
47 void ScenarioContext::onStartElement( const AttributeList& rAttribs )
49 if( isRootElement() )
50 mrScenario.importScenario( rAttribs );
53 ContextHandlerRef ScenarioContext::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
55 switch( getCurrentElement() )
57 case BIFF12_ID_SCENARIO:
58 if( nRecId == BIFF12_ID_INPUTCELLS ) mrScenario.importInputCells( rStrm );
59 break;
61 return nullptr;
64 void ScenarioContext::onStartRecord( SequenceInputStream& rStrm )
66 if( isRootElement() )
67 mrScenario.importScenario( rStrm );
70 ScenariosContext::ScenariosContext( WorksheetFragmentBase& rFragment ) :
71 WorksheetContextBase( rFragment ),
72 mrSheetScenarios( getScenarios().createSheetScenarios( getSheetIndex() ) )
76 ContextHandlerRef ScenariosContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
78 switch( getCurrentElement() )
80 case XLS_TOKEN( scenarios ):
81 if( nElement == XLS_TOKEN( scenario ) ) return new ScenarioContext( *this, mrSheetScenarios );
82 break;
84 return nullptr;
87 void ScenariosContext::onStartElement( const AttributeList& rAttribs )
89 if( isRootElement() )
90 mrSheetScenarios.importScenarios( rAttribs );
93 ContextHandlerRef ScenariosContext::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& )
95 switch( getCurrentElement() )
97 case BIFF12_ID_SCENARIOS:
98 if( nRecId == BIFF12_ID_SCENARIO ) return new ScenarioContext( *this, mrSheetScenarios );
99 break;
101 return nullptr;
104 void ScenariosContext::onStartRecord( SequenceInputStream& rStrm )
106 if( isRootElement() )
107 mrSheetScenarios.importScenarios( rStrm );
110 } // namespace oox::xls
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */