Update ooo320-m1
[ooovba.git] / oox / source / xls / condformatcontext.cxx
blob85a0f49a774625923d696c3a719b0efba2f48175
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: condformatcontext.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/condformatcontext.hxx"
33 using ::rtl::OUString;
34 using ::oox::core::ContextHandlerRef;
36 namespace oox {
37 namespace xls {
39 // ============================================================================
41 OoxCondFormatContext::OoxCondFormatContext( OoxWorksheetFragmentBase& rFragment ) :
42 OoxWorksheetContextBase( rFragment )
46 // oox.core.ContextHandler2Helper interface -----------------------------------
48 ContextHandlerRef OoxCondFormatContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
50 switch( getCurrentElement() )
52 case XLS_TOKEN( conditionalFormatting ):
53 return (nElement == XLS_TOKEN( cfRule )) ? this : 0;
54 case XLS_TOKEN( cfRule ):
55 return (nElement == XLS_TOKEN( formula )) ? this : 0;
57 return 0;
60 void OoxCondFormatContext::onStartElement( const AttributeList& rAttribs )
62 switch( getCurrentElement() )
64 case XLS_TOKEN( conditionalFormatting ):
65 mxCondFmt = getCondFormats().importConditionalFormatting( rAttribs );
66 break;
67 case XLS_TOKEN( cfRule ):
68 if( mxCondFmt.get() ) mxRule = mxCondFmt->importCfRule( rAttribs );
69 break;
73 void OoxCondFormatContext::onEndElement( const OUString& rChars )
75 switch( getCurrentElement() )
77 case XLS_TOKEN( formula ):
78 if( mxCondFmt.get() && mxRule.get() ) mxRule->appendFormula( rChars );
79 break;
83 ContextHandlerRef OoxCondFormatContext::onCreateRecordContext( sal_Int32 nRecId, RecordInputStream& )
85 switch( getCurrentElement() )
87 case OOBIN_ID_CONDFORMATTING:
88 return (nRecId == OOBIN_ID_CFRULE) ? this : 0;
90 return 0;
93 void OoxCondFormatContext::onStartRecord( RecordInputStream& rStrm )
95 switch( getCurrentElement() )
97 case OOBIN_ID_CONDFORMATTING:
98 mxCondFmt = getCondFormats().importCondFormatting( rStrm );
99 break;
100 case OOBIN_ID_CFRULE:
101 if( mxCondFmt.get() ) mxCondFmt->importCfRule( rStrm );
102 break;
106 // ============================================================================
108 } // namespace xls
109 } // namespace oox