blob: 83bf0e71d99f6c38050abdf75f6f87aa381e3ec6 [file] [log] [blame]
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
#include "oox/xls/condformatcontext.hxx"
namespace oox {
namespace xls {
// ============================================================================
using ::oox::core::ContextHandlerRef;
using ::rtl::OUString;
// ============================================================================
CondFormatContext::CondFormatContext( WorksheetFragmentBase& rFragment ) :
WorksheetContextBase( rFragment )
{
}
ContextHandlerRef CondFormatContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
{
switch( getCurrentElement() )
{
case XLS_TOKEN( conditionalFormatting ):
return (nElement == XLS_TOKEN( cfRule )) ? this : 0;
case XLS_TOKEN( cfRule ):
return (nElement == XLS_TOKEN( formula )) ? this : 0;
}
return 0;
}
void CondFormatContext::onStartElement( const AttributeList& rAttribs )
{
switch( getCurrentElement() )
{
case XLS_TOKEN( conditionalFormatting ):
mxCondFmt = getCondFormats().importConditionalFormatting( rAttribs );
break;
case XLS_TOKEN( cfRule ):
if( mxCondFmt.get() ) mxRule = mxCondFmt->importCfRule( rAttribs );
break;
}
}
void CondFormatContext::onCharacters( const OUString& rChars )
{
if( isCurrentElement( XLS_TOKEN( formula ) ) && mxCondFmt.get() && mxRule.get() )
mxRule->appendFormula( rChars );
}
ContextHandlerRef CondFormatContext::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& )
{
switch( getCurrentElement() )
{
case BIFF12_ID_CONDFORMATTING:
return (nRecId == BIFF12_ID_CFRULE) ? this : 0;
}
return 0;
}
void CondFormatContext::onStartRecord( SequenceInputStream& rStrm )
{
switch( getCurrentElement() )
{
case BIFF12_ID_CONDFORMATTING:
mxCondFmt = getCondFormats().importCondFormatting( rStrm );
break;
case BIFF12_ID_CFRULE:
if( mxCondFmt.get() ) mxCondFmt->importCfRule( rStrm );
break;
}
}
// ============================================================================
} // namespace xls
} // namespace oox