1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #include "oox/xls/condformatcontext.hxx" 25 26 namespace oox { 27 namespace xls { 28 29 // ============================================================================ 30 31 using ::oox::core::ContextHandlerRef; 32 using ::rtl::OUString; 33 34 // ============================================================================ 35 CondFormatContext(WorksheetFragmentBase & rFragment)36CondFormatContext::CondFormatContext( WorksheetFragmentBase& rFragment ) : 37 WorksheetContextBase( rFragment ) 38 { 39 } 40 onCreateContext(sal_Int32 nElement,const AttributeList &)41ContextHandlerRef CondFormatContext::onCreateContext( sal_Int32 nElement, const AttributeList& ) 42 { 43 switch( getCurrentElement() ) 44 { 45 case XLS_TOKEN( conditionalFormatting ): 46 return (nElement == XLS_TOKEN( cfRule )) ? this : 0; 47 case XLS_TOKEN( cfRule ): 48 return (nElement == XLS_TOKEN( formula )) ? this : 0; 49 } 50 return 0; 51 } 52 onStartElement(const AttributeList & rAttribs)53void CondFormatContext::onStartElement( const AttributeList& rAttribs ) 54 { 55 switch( getCurrentElement() ) 56 { 57 case XLS_TOKEN( conditionalFormatting ): 58 mxCondFmt = getCondFormats().importConditionalFormatting( rAttribs ); 59 break; 60 case XLS_TOKEN( cfRule ): 61 if( mxCondFmt.get() ) mxRule = mxCondFmt->importCfRule( rAttribs ); 62 break; 63 } 64 } 65 onCharacters(const OUString & rChars)66void CondFormatContext::onCharacters( const OUString& rChars ) 67 { 68 if( isCurrentElement( XLS_TOKEN( formula ) ) && mxCondFmt.get() && mxRule.get() ) 69 mxRule->appendFormula( rChars ); 70 } 71 onCreateRecordContext(sal_Int32 nRecId,SequenceInputStream &)72ContextHandlerRef CondFormatContext::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& ) 73 { 74 switch( getCurrentElement() ) 75 { 76 case BIFF12_ID_CONDFORMATTING: 77 return (nRecId == BIFF12_ID_CFRULE) ? this : 0; 78 } 79 return 0; 80 } 81 onStartRecord(SequenceInputStream & rStrm)82void CondFormatContext::onStartRecord( SequenceInputStream& rStrm ) 83 { 84 switch( getCurrentElement() ) 85 { 86 case BIFF12_ID_CONDFORMATTING: 87 mxCondFmt = getCondFormats().importCondFormatting( rStrm ); 88 break; 89 case BIFF12_ID_CFRULE: 90 if( mxCondFmt.get() ) mxCondFmt->importCfRule( rStrm ); 91 break; 92 } 93 } 94 95 // ============================================================================ 96 97 } // namespace xls 98 } // namespace oox 99