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