Update ooo320-m1
[ooovba.git] / oox / source / xls / scenariocontext.cxx
blob3943bd5b257fc3948d5c1fa687856dc91dca2256
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tablefragment.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "oox/xls/scenariocontext.hxx"
32 #include "oox/xls/scenariobuffer.hxx"
34 using ::oox::core::ContextHandlerRef;
36 namespace oox {
37 namespace xls {
39 // ============================================================================
41 OoxScenarioContext::OoxScenarioContext( OoxWorksheetContextBase& rParent, SheetScenarios& rSheetScenarios ) :
42 OoxWorksheetContextBase( rParent ),
43 mrScenario( rSheetScenarios.createScenario() )
47 ContextHandlerRef OoxScenarioContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
49 switch( getCurrentElement() )
51 case XLS_TOKEN( scenario ):
52 if( nElement == XLS_TOKEN( inputCells ) ) mrScenario.importInputCells( rAttribs );
53 break;
55 return 0;
58 void OoxScenarioContext::onStartElement( const AttributeList& rAttribs )
60 if( isRootElement() )
61 mrScenario.importScenario( rAttribs );
64 ContextHandlerRef OoxScenarioContext::onCreateRecordContext( sal_Int32 nRecId, RecordInputStream& rStrm )
66 switch( getCurrentElement() )
68 case OOBIN_ID_SCENARIO:
69 if( nRecId == OOBIN_ID_INPUTCELLS ) mrScenario.importInputCells( rStrm );
70 break;
72 return 0;
75 void OoxScenarioContext::onStartRecord( RecordInputStream& rStrm )
77 if( isRootElement() )
78 mrScenario.importScenario( rStrm );
81 // ============================================================================
83 OoxScenariosContext::OoxScenariosContext( OoxWorksheetFragmentBase& rFragment ) :
84 OoxWorksheetContextBase( rFragment ),
85 mrSheetScenarios( getScenarios().createSheetScenarios( getSheetIndex() ) )
89 ContextHandlerRef OoxScenariosContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
91 switch( getCurrentElement() )
93 case XLS_TOKEN( scenarios ):
94 if( nElement == XLS_TOKEN( scenario ) ) return new OoxScenarioContext( *this, mrSheetScenarios );
95 break;
97 return 0;
100 void OoxScenariosContext::onStartElement( const AttributeList& rAttribs )
102 if( isRootElement() )
103 mrSheetScenarios.importScenarios( rAttribs );
106 ContextHandlerRef OoxScenariosContext::onCreateRecordContext( sal_Int32 nRecId, RecordInputStream& )
108 switch( getCurrentElement() )
110 case OOBIN_ID_SCENARIOS:
111 if( nRecId == OOBIN_ID_SCENARIO ) return new OoxScenarioContext( *this, mrSheetScenarios );
112 break;
114 return 0;
117 void OoxScenariosContext::onStartRecord( RecordInputStream& rStrm )
119 if( isRootElement() )
120 mrSheetScenarios.importScenarios( rStrm );
123 // ============================================================================
125 } // namespace xls
126 } // namespace oox