1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
29 using ::oox::core::ContextHandlerRef
;
31 ScenarioContext::ScenarioContext( WorksheetContextBase
& rParent
, SheetScenarios
& rSheetScenarios
) :
32 WorksheetContextBase( rParent
),
33 mrScenario( rSheetScenarios
.createScenario() )
37 ContextHandlerRef
ScenarioContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
39 switch( getCurrentElement() )
41 case XLS_TOKEN( scenario
):
42 if( nElement
== XLS_TOKEN( inputCells
) ) mrScenario
.importInputCells( rAttribs
);
48 void ScenarioContext::onStartElement( const AttributeList
& rAttribs
)
51 mrScenario
.importScenario( rAttribs
);
54 ContextHandlerRef
ScenarioContext::onCreateRecordContext( sal_Int32 nRecId
, SequenceInputStream
& rStrm
)
56 switch( getCurrentElement() )
58 case BIFF12_ID_SCENARIO
:
59 if( nRecId
== BIFF12_ID_INPUTCELLS
) mrScenario
.importInputCells( rStrm
);
65 void ScenarioContext::onStartRecord( SequenceInputStream
& rStrm
)
68 mrScenario
.importScenario( rStrm
);
71 ScenariosContext::ScenariosContext( WorksheetFragmentBase
& rFragment
) :
72 WorksheetContextBase( rFragment
),
73 mrSheetScenarios( getScenarios().createSheetScenarios( getSheetIndex() ) )
77 ContextHandlerRef
ScenariosContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& )
79 switch( getCurrentElement() )
81 case XLS_TOKEN( scenarios
):
82 if( nElement
== XLS_TOKEN( scenario
) ) return new ScenarioContext( *this, mrSheetScenarios
);
88 void ScenariosContext::onStartElement( const AttributeList
& rAttribs
)
91 mrSheetScenarios
.importScenarios( rAttribs
);
94 ContextHandlerRef
ScenariosContext::onCreateRecordContext( sal_Int32 nRecId
, SequenceInputStream
& )
96 switch( getCurrentElement() )
98 case BIFF12_ID_SCENARIOS
:
99 if( nRecId
== BIFF12_ID_SCENARIO
) return new ScenarioContext( *this, mrSheetScenarios
);
105 void ScenariosContext::onStartRecord( SequenceInputStream
& rStrm
)
107 if( isRootElement() )
108 mrSheetScenarios
.importScenarios( rStrm
);
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */