1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #include "oox/xls/condformatcontext.hxx" 29 30 namespace oox { 31 namespace xls { 32 33 // ============================================================================ 34 35 using ::oox::core::ContextHandlerRef; 36 using ::rtl::OUString; 37 38 // ============================================================================ 39 40 CondFormatContext::CondFormatContext( WorksheetFragmentBase& rFragment ) : 41 WorksheetContextBase( rFragment ) 42 { 43 } 44 45 ContextHandlerRef CondFormatContext::onCreateContext( sal_Int32 nElement, const AttributeList& ) 46 { 47 switch( getCurrentElement() ) 48 { 49 case XLS_TOKEN( conditionalFormatting ): 50 return (nElement == XLS_TOKEN( cfRule )) ? this : 0; 51 case XLS_TOKEN( cfRule ): 52 return (nElement == XLS_TOKEN( formula )) ? this : 0; 53 } 54 return 0; 55 } 56 57 void CondFormatContext::onStartElement( const AttributeList& rAttribs ) 58 { 59 switch( getCurrentElement() ) 60 { 61 case XLS_TOKEN( conditionalFormatting ): 62 mxCondFmt = getCondFormats().importConditionalFormatting( rAttribs ); 63 break; 64 case XLS_TOKEN( cfRule ): 65 if( mxCondFmt.get() ) mxRule = mxCondFmt->importCfRule( rAttribs ); 66 break; 67 } 68 } 69 70 void CondFormatContext::onCharacters( const OUString& rChars ) 71 { 72 if( isCurrentElement( XLS_TOKEN( formula ) ) && mxCondFmt.get() && mxRule.get() ) 73 mxRule->appendFormula( rChars ); 74 } 75 76 ContextHandlerRef CondFormatContext::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& ) 77 { 78 switch( getCurrentElement() ) 79 { 80 case BIFF12_ID_CONDFORMATTING: 81 return (nRecId == BIFF12_ID_CFRULE) ? this : 0; 82 } 83 return 0; 84 } 85 86 void CondFormatContext::onStartRecord( SequenceInputStream& rStrm ) 87 { 88 switch( getCurrentElement() ) 89 { 90 case BIFF12_ID_CONDFORMATTING: 91 mxCondFmt = getCondFormats().importCondFormatting( rStrm ); 92 break; 93 case BIFF12_ID_CFRULE: 94 if( mxCondFmt.get() ) mxCondFmt->importCfRule( rStrm ); 95 break; 96 } 97 } 98 99 // ============================================================================ 100 101 } // namespace xls 102 } // namespace oox 103