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 "scenariocontext.hxx"
21 :
22 : #include "scenariobuffer.hxx"
23 :
24 : namespace oox {
25 : namespace xls {
26 :
27 : using ::oox::core::ContextHandlerRef;
28 :
29 0 : ScenarioContext::ScenarioContext( WorksheetContextBase& rParent, SheetScenarios& rSheetScenarios ) :
30 : WorksheetContextBase( rParent ),
31 0 : mrScenario( rSheetScenarios.createScenario() )
32 : {
33 0 : }
34 :
35 0 : ContextHandlerRef ScenarioContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
36 : {
37 0 : switch( getCurrentElement() )
38 : {
39 : case XLS_TOKEN( scenario ):
40 0 : if( nElement == XLS_TOKEN( inputCells ) ) mrScenario.importInputCells( rAttribs );
41 0 : break;
42 : }
43 0 : return 0;
44 : }
45 :
46 0 : void ScenarioContext::onStartElement( const AttributeList& rAttribs )
47 : {
48 0 : if( isRootElement() )
49 0 : mrScenario.importScenario( rAttribs );
50 0 : }
51 :
52 0 : ContextHandlerRef ScenarioContext::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
53 : {
54 0 : switch( getCurrentElement() )
55 : {
56 : case BIFF12_ID_SCENARIO:
57 0 : if( nRecId == BIFF12_ID_INPUTCELLS ) mrScenario.importInputCells( rStrm );
58 0 : break;
59 : }
60 0 : return 0;
61 : }
62 :
63 0 : void ScenarioContext::onStartRecord( SequenceInputStream& rStrm )
64 : {
65 0 : if( isRootElement() )
66 0 : mrScenario.importScenario( rStrm );
67 0 : }
68 :
69 0 : ScenariosContext::ScenariosContext( WorksheetFragmentBase& rFragment ) :
70 : WorksheetContextBase( rFragment ),
71 0 : mrSheetScenarios( getScenarios().createSheetScenarios( getSheetIndex() ) )
72 : {
73 0 : }
74 :
75 0 : ContextHandlerRef ScenariosContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
76 : {
77 0 : switch( getCurrentElement() )
78 : {
79 : case XLS_TOKEN( scenarios ):
80 0 : if( nElement == XLS_TOKEN( scenario ) ) return new ScenarioContext( *this, mrSheetScenarios );
81 0 : break;
82 : }
83 0 : return 0;
84 : }
85 :
86 0 : void ScenariosContext::onStartElement( const AttributeList& rAttribs )
87 : {
88 0 : if( isRootElement() )
89 0 : mrSheetScenarios.importScenarios( rAttribs );
90 0 : }
91 :
92 0 : ContextHandlerRef ScenariosContext::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& )
93 : {
94 0 : switch( getCurrentElement() )
95 : {
96 : case BIFF12_ID_SCENARIOS:
97 0 : if( nRecId == BIFF12_ID_SCENARIO ) return new ScenarioContext( *this, mrSheetScenarios );
98 0 : break;
99 : }
100 0 : return 0;
101 : }
102 :
103 0 : void ScenariosContext::onStartRecord( SequenceInputStream& rStrm )
104 : {
105 0 : if( isRootElement() )
106 0 : mrSheetScenarios.importScenarios( rStrm );
107 0 : }
108 :
109 : } // namespace xls
110 18 : } // namespace oox
111 :
112 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|