diff options
author | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-08-04 00:05:26 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-08-04 00:05:26 -0400 |
commit | 0a99c699719dc5d72c0e5c0ecb2b56c5c9b4c4d3 (patch) | |
tree | bd8996d2f65e5108957d2e678dc395caf8cd24d7 /sc | |
parent | 24d8e4eaf4543c5b39b9e816d8514525b098827d (diff) |
Combined two html option loops.
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/filter/html/htmlpars.cxx | 69 |
1 files changed, 33 insertions, 36 deletions
diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx index 18bf94ad5143..33fc92bebea1 100644 --- a/sc/source/filter/html/htmlpars.cxx +++ b/sc/source/filter/html/htmlpars.cxx @@ -2225,57 +2225,54 @@ void ScHTMLTable::DataOn( const ImportInfo& rInfo ) // read needed options from the <td> tag ScHTMLSize aSpanSize( 1, 1 ); ::std::auto_ptr< String > pValStr, pNumStr; - for( ScHTMLOptionIterator aIter( rInfo ); aIter.is(); ++aIter ) + const HTMLOptions& rOptions = static_cast<HTMLParser*>(rInfo.pParser)->GetOptions(); + HTMLOptions::const_iterator itr = rOptions.begin(), itrEnd = rOptions.end(); + sal_uInt32 nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND; + for (; itr != itrEnd; ++itr) { - switch( aIter->GetToken() ) + switch (itr->GetToken()) { case HTML_O_COLSPAN: - aSpanSize.mnCols = static_cast< SCCOL >( getLimitedValue< sal_Int32 >( aIter->GetString().ToInt32(), 1, 256 ) ); + aSpanSize.mnCols = static_cast<SCCOL>( getLimitedValue<sal_Int32>( itr->GetString().ToInt32(), 1, 256 ) ); break; case HTML_O_ROWSPAN: - aSpanSize.mnRows = static_cast< SCROW >( getLimitedValue< sal_Int32 >( aIter->GetString().ToInt32(), 1, 256 ) ); + aSpanSize.mnRows = static_cast<SCROW>( getLimitedValue<sal_Int32>( itr->GetString().ToInt32(), 1, 256 ) ); break; case HTML_O_SDVAL: - pValStr.reset( new String( aIter->GetString() ) ); + pValStr.reset( new String( itr->GetString() ) ); break; case HTML_O_SDNUM: - pNumStr.reset( new String( aIter->GetString() ) ); + pNumStr.reset( new String( itr->GetString() ) ); + break; + case HTML_O_CLASS: + { + // Pick up the number format associated with this class (if + // any). + rtl::OUString aElem(RTL_CONSTASCII_USTRINGPARAM("td")); + rtl::OUString aClass = itr->GetString(); + rtl::OUString aProp(RTL_CONSTASCII_USTRINGPARAM("mso-number-format")); + const ScHTMLStyles& rStyles = mpParser->GetStyles(); + const rtl::OUString& rVal = rStyles.getPropertyValue(aElem, aClass, aProp); + rtl::OUString aNumFmt = decodeNumberFormat(rVal); + + nNumberFormat = GetFormatTable()->GetEntryKey(aNumFmt); + if (nNumberFormat == NUMBERFORMAT_ENTRY_NOT_FOUND) + { + xub_StrLen nErrPos = 0; + short nDummy; + bool bValidFmt = GetFormatTable()->PutEntry(aNumFmt, nErrPos, nDummy, nNumberFormat); + if (!bValidFmt) + nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND; + } + } break; } } ImplDataOn( aSpanSize ); - const HTMLOptions& rOptions = static_cast<HTMLParser*>(rInfo.pParser)->GetOptions(); - HTMLOptions::const_iterator itr = rOptions.begin(), itrEnd = rOptions.end(); - for (; itr != itrEnd; ++itr) - { - if (itr->GetToken() == HTML_O_CLASS) - { - // This <td> has class property. Pick up the number format - // associated with this class (if any). - rtl::OUString aElem(RTL_CONSTASCII_USTRINGPARAM("td")); - rtl::OUString aClass = itr->GetString(); - rtl::OUString aProp(RTL_CONSTASCII_USTRINGPARAM("mso-number-format")); - const ScHTMLStyles& rStyles = mpParser->GetStyles(); - const rtl::OUString& rVal = rStyles.getPropertyValue(aElem, aClass, aProp); - rtl::OUString aNumFmt = decodeNumberFormat(rVal); - - sal_uInt32 nNumberFormat = GetFormatTable()->GetEntryKey(aNumFmt); - bool bValidFmt = false; - if ( nNumberFormat == NUMBERFORMAT_ENTRY_NOT_FOUND ) - { - xub_StrLen nErrPos = 0; - short nDummy; - bValidFmt = GetFormatTable()->PutEntry(aNumFmt, nErrPos, nDummy, nNumberFormat); - } - else - bValidFmt = true; - - if (bValidFmt) - mxDataItemSet->Put( SfxUInt32Item(ATTR_VALUE_FORMAT, nNumberFormat) ); - } - } + if (nNumberFormat != NUMBERFORMAT_ENTRY_NOT_FOUND) + mxDataItemSet->Put( SfxUInt32Item(ATTR_VALUE_FORMAT, nNumberFormat) ); ProcessFormatOptions( *mxDataItemSet, rInfo ); CreateNewEntry( rInfo ); |