diff options
author | Daniel Rentz [dr] <daniel.rentz@oracle.com> | 2011-03-23 14:41:21 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2012-12-04 07:17:05 +0000 |
commit | 6641d76c8b2a66e14bdb827de9b658d42a595094 (patch) | |
tree | 8ea356da23b6d4642b60afdd58970c9abbac20b7 | |
parent | 4d6827a99493f5c18adde21d12f00c3ef85efb7d (diff) |
dr80: #i117511# remove some assertions in xlsx/xlsb import filters
Conflicts:
sc/source/filter/oox/numberformatsbuffer.cxx
sc/source/filter/oox/stylesbuffer.cxx
-rw-r--r-- | sc/source/filter/oox/externallinkbuffer.cxx | 13 | ||||
-rw-r--r-- | sc/source/filter/oox/numberformatsbuffer.cxx | 9 | ||||
-rw-r--r-- | sc/source/filter/oox/stylesbuffer.cxx | 32 |
3 files changed, 37 insertions, 17 deletions
diff --git a/sc/source/filter/oox/externallinkbuffer.cxx b/sc/source/filter/oox/externallinkbuffer.cxx index cb0e608d66ae..ce1851771306 100644 --- a/sc/source/filter/oox/externallinkbuffer.cxx +++ b/sc/source/filter/oox/externallinkbuffer.cxx @@ -454,10 +454,19 @@ ExternalLinkInfo ExternalLink::getLinkInfo() const ExternalLinkInfo aLinkInfo; switch( meLinkType ) { + case LINKTYPE_SELF: + case LINKTYPE_SAME: + case LINKTYPE_INTERNAL: + aLinkInfo.Type = ::com::sun::star::sheet::ExternalLinkType::SELF; + break; case LINKTYPE_EXTERNAL: aLinkInfo.Type = ::com::sun::star::sheet::ExternalLinkType::DOCUMENT; aLinkInfo.Data <<= maTargetUrl; break; + case LINKTYPE_LIBRARY: + // parser will return library function names in OPCODE_BAD string tokens + aLinkInfo.Type = ::com::sun::star::sheet::ExternalLinkType::SPECIAL; + break; case LINKTYPE_DDE: { aLinkInfo.Type = ::com::sun::star::sheet::ExternalLinkType::DDE; @@ -717,8 +726,8 @@ void ExternalLinkBuffer::importExternalSheets( SequenceInputStream& rStrm ) Sequence< ExternalLinkInfo > ExternalLinkBuffer::getLinkInfos() const { ::std::vector< ExternalLinkInfo > aLinkInfos; - // should not be used for BIFF12 documents - OSL_ENSURE( (getFilterType() == FILTER_OOXML) && !mbUseRefSheets, "ExternalLinkBuffer::getLinkInfos - unexpected file format" ); + // XML formula parser also used in BIFF12 documents, e.g. replacement formulas in unsupported conditional formattings + OSL_ENSURE( getFilterType() == FILTER_OOXML, "ExternalLinkBuffer::getLinkInfos - unexpected file format" ); // add entry for implicit index 0 (self reference to this document) aLinkInfos.push_back( mxSelfRef->getLinkInfo() ); for( ExternalLinkVec::const_iterator aIt = maExtLinks.begin(), aEnd = maExtLinks.end(); aIt != aEnd; ++aIt ) diff --git a/sc/source/filter/oox/numberformatsbuffer.cxx b/sc/source/filter/oox/numberformatsbuffer.cxx index e9a242de4f5a..e4a406121c1a 100644 --- a/sc/source/filter/oox/numberformatsbuffer.cxx +++ b/sc/source/filter/oox/numberformatsbuffer.cxx @@ -1857,14 +1857,17 @@ sal_Int32 lclCreateFormat( const Reference< XNumberFormats >& rxNumFmts, catch( Exception& ) { // BIFF2-BIFF4 stores standard format explicitly in stream - static const OUString saGeneral = "general"; - if( rFmtCode.equalsIgnoreAsciiCase( saGeneral ) ) + if( rFmtCode.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "general" ) ) ) { nIndex = lclCreatePredefinedFormat( rxNumFmts, 0, rToLocale ); } else { - OSL_FAIL( OStringBuffer( "lclCreateFormat - cannot create number format '" ). + // do not assert fractional number formats with fixed denominator + OSL_ENSURE( rFmtCode.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "#\\ ?/" ) ) || + rFmtCode.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "#\\ ?\?/" ) ) || + rFmtCode.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "#\\ ?\?\?/" ) ), + OStringBuffer( "lclCreateFormat - cannot create number format '" ). append( OUStringToOString( rFmtCode, osl_getThreadTextEncoding() ) ). append( '\'' ).getStr() ); } diff --git a/sc/source/filter/oox/stylesbuffer.cxx b/sc/source/filter/oox/stylesbuffer.cxx index fbb63b076399..70c19e992323 100644 --- a/sc/source/filter/oox/stylesbuffer.cxx +++ b/sc/source/filter/oox/stylesbuffer.cxx @@ -2577,9 +2577,9 @@ const sal_Char* const sppcStyleNames[] = "Followed Hyperlink", "Note", // new in OOX "Warning Text", - "", - "", - "", + 0, + 0, + 0, "Title", "Heading 1", "Heading 2", @@ -2627,7 +2627,7 @@ OUString lclGetBuiltinStyleName( sal_Int32 nBuiltinId, const OUString& rName, sa OSL_ENSURE( (0 <= nBuiltinId) && (nBuiltinId < snStyleNamesCount), "lclGetBuiltinStyleName - unknown built-in style" ); OUStringBuffer aStyleName; aStyleName.appendAscii( spcStyleNamePrefix ); - if( (0 <= nBuiltinId) && (nBuiltinId < snStyleNamesCount) && (sppcStyleNames[ nBuiltinId ][ 0 ] != 0) ) + if( (0 <= nBuiltinId) && (nBuiltinId < snStyleNamesCount) && (sppcStyleNames[ nBuiltinId ] != 0) ) aStyleName.appendAscii( sppcStyleNames[ nBuiltinId ] ); else if( !rName.isEmpty() ) aStyleName.append( rName ); @@ -2638,6 +2638,11 @@ OUString lclGetBuiltinStyleName( sal_Int32 nBuiltinId, const OUString& rName, sa return aStyleName.makeStringAndClear(); } +OUString lclCreateStyleName( const CellStyleModel& rModel ) +{ + return rModel.mbBuiltin ? lclGetBuiltinStyleName( rModel.mnBuiltinId, rModel.maName, rModel.mnLevel ) : rModel.maName; +} + } // namespace // ---------------------------------------------------------------------------- @@ -2805,10 +2810,11 @@ void CellStyleBuffer::finalizeImport() if (rModel.isDefaultStyle()) continue; - OUString aStyleName = lclGetBuiltinStyleName( rModel.mnBuiltinId, rModel.maName, rModel.mnLevel ); - OSL_ENSURE( bReserveAll || (aCellStyles.count( aStyleName ) == 0), - "CellStyleBuffer::finalizeImport - multiple styles with equal built-in identifier" ); - if( aCellStyles.count( aStyleName ) > 0 ) + OUString aStyleName = lclCreateStyleName( rModel ); + /* If a builtin style entry already exists, and we do not reserve all + existing styles, we just stick with the last definition and ignore + the preceding ones. */ + if( bReserveAll && (aCellStyles.count( aStyleName ) > 0) ) aConflictNameStyles.push_back( *aIt ); else aCellStyles[ aStyleName ] = *aIt; @@ -2819,13 +2825,14 @@ void CellStyleBuffer::finalizeImport() for( CellStyleVector::iterator aIt = maUserStyles.begin(), aEnd = maUserStyles.end(); aIt != aEnd; ++aIt ) { const CellStyleModel& rModel = (*aIt)->getModel(); + OUString aStyleName = lclCreateStyleName( rModel ); // #i1624# #i1768# ignore unnamed user styles - if( !rModel.maName.isEmpty() ) + if( !aStyleName.isEmpty() ) { - if( aCellStyles.count( rModel.maName ) > 0 ) + if( aCellStyles.count( aStyleName ) > 0 ) aConflictNameStyles.push_back( *aIt ); else - aCellStyles[ rModel.maName ] = *aIt; + aCellStyles[ aStyleName ] = *aIt; } } @@ -2833,11 +2840,12 @@ void CellStyleBuffer::finalizeImport() for( CellStyleVector::iterator aIt = aConflictNameStyles.begin(), aEnd = aConflictNameStyles.end(); aIt != aEnd; ++aIt ) { const CellStyleModel& rModel = (*aIt)->getModel(); + OUString aStyleName = lclCreateStyleName( rModel ); OUString aUnusedName; sal_Int32 nIndex = 0; do { - aUnusedName = OUStringBuffer( rModel.maName ).append( sal_Unicode( ' ' ) ).append( ++nIndex ).makeStringAndClear(); + aUnusedName = OUStringBuffer( aStyleName ).append( sal_Unicode( ' ' ) ).append( ++nIndex ).makeStringAndClear(); } while( aCellStyles.count( aUnusedName ) > 0 ); aCellStyles[ aUnusedName ] = *aIt; |