sc/source/filter/excel/xelink.cxx | 34 +++++++++++++++++----------------- sc/source/filter/excel/xilink.cxx | 26 +++++++++++++------------- sc/source/filter/inc/xllink.hxx | 32 +++++++++++++++++++++++++------- 3 files changed, 55 insertions(+), 37 deletions(-)
New commits: commit 6152bf9ee9b2e348dee854921a5a5db1cfc72995 Author: Tor Lillqvist <t...@collabora.com> Date: Tue Mar 28 19:15:55 2017 +0300 Turn XclSupbookType into scoped enum and add operator<< for SAL_INFO etc Part of preparatory work for handling xlExternalLinkPath/xlPathMissing. Change-Id: I29b77bb2680e4dbf293ab65bda5401afee132f11 diff --git a/sc/source/filter/excel/xelink.cxx b/sc/source/filter/excel/xelink.cxx index 46a7e779eba3..8b110575f7c0 100644 --- a/sc/source/filter/excel/xelink.cxx +++ b/sc/source/filter/excel/xelink.cxx @@ -1497,7 +1497,7 @@ void XclExpExternSheet::WriteBody( XclExpStream& rStrm ) XclExpSupbook::XclExpSupbook( const XclExpRoot& rRoot, sal_uInt16 nXclTabCount ) : XclExpExternSheetBase( rRoot, EXC_ID_SUPBOOK, 4 ), - meType( EXC_SBTYPE_SELF ), + meType( XclSupbookType::Self ), mnXclTabCount( nXclTabCount ), mnFileId( 0 ) { @@ -1505,7 +1505,7 @@ XclExpSupbook::XclExpSupbook( const XclExpRoot& rRoot, sal_uInt16 nXclTabCount ) XclExpSupbook::XclExpSupbook( const XclExpRoot& rRoot ) : XclExpExternSheetBase( rRoot, EXC_ID_SUPBOOK, 4 ), - meType( EXC_SBTYPE_ADDIN ), + meType( XclSupbookType::Addin ), mnXclTabCount( 1 ), mnFileId( 0 ) { @@ -1515,7 +1515,7 @@ XclExpSupbook::XclExpSupbook( const XclExpRoot& rRoot, const OUString& rUrl, Xcl XclExpExternSheetBase( rRoot, EXC_ID_SUPBOOK ), maUrl( rUrl ), maUrlEncoded( rUrl ), - meType( EXC_SBTYPE_EUROTOOL ), + meType( XclSupbookType::Eurotool ), mnXclTabCount( 0 ), mnFileId( 0 ) { @@ -1526,7 +1526,7 @@ XclExpSupbook::XclExpSupbook( const XclExpRoot& rRoot, const OUString& rUrl ) : XclExpExternSheetBase( rRoot, EXC_ID_SUPBOOK ), maUrl( rUrl ), maUrlEncoded( XclExpUrlHelper::EncodeUrl( rRoot, rUrl ) ), - meType( EXC_SBTYPE_EXTERN ), + meType( XclSupbookType::Extern ), mnXclTabCount( 0 ), mnFileId( 0 ) { @@ -1547,7 +1547,7 @@ XclExpSupbook::XclExpSupbook( const XclExpRoot& rRoot, const OUString& rApplic, maUrl( rApplic ), maDdeTopic( rTopic ), maUrlEncoded( XclExpUrlHelper::EncodeDde( rApplic, rTopic ) ), - meType( EXC_SBTYPE_SPECIAL ), + meType( XclSupbookType::Special ), mnXclTabCount( 0 ), mnFileId( 0 ) { @@ -1556,12 +1556,12 @@ XclExpSupbook::XclExpSupbook( const XclExpRoot& rRoot, const OUString& rApplic, bool XclExpSupbook::IsUrlLink( const OUString& rUrl ) const { - return (meType == EXC_SBTYPE_EXTERN || meType == EXC_SBTYPE_EUROTOOL) && (maUrl == rUrl); + return (meType == XclSupbookType::Extern || meType == XclSupbookType::Eurotool) && (maUrl == rUrl); } bool XclExpSupbook::IsDdeLink( const OUString& rApplic, const OUString& rTopic ) const { - return (meType == EXC_SBTYPE_SPECIAL) && (maUrl == rApplic) && (maDdeTopic == rTopic); + return (meType == XclSupbookType::Special) && (maUrl == rApplic) && (maDdeTopic == rTopic); } void XclExpSupbook::FillRefLogEntry( XclExpRefLogEntry& rRefLogEntry, @@ -1612,7 +1612,7 @@ sal_uInt16 XclExpSupbook::GetTabCount() const sal_uInt16 XclExpSupbook::InsertTabName( const OUString& rTabName, ScExternalRefCache::TableTypeRef const & xCacheTable ) { - OSL_ENSURE( meType == EXC_SBTYPE_EXTERN, "XclExpSupbook::InsertTabName - don't insert sheet names here" ); + SAL_WARN_IF( meType != XclSupbookType::Extern, "sc.filter", "Don't insert sheet names here" ); sal_uInt16 nSBTab = ulimit_cast< sal_uInt16 >( maXctList.GetSize() ); XclExpXctRef xXct( new XclExpXct( GetRoot(), rTabName, nSBTab, xCacheTable ) ); AddRecSize( xXct->GetTabName().GetSize() ); @@ -1731,12 +1731,12 @@ void XclExpSupbook::WriteBody( XclExpStream& rStrm ) { switch( meType ) { - case EXC_SBTYPE_SELF: + case XclSupbookType::Self: rStrm << mnXclTabCount << EXC_SUPB_SELF; break; - case EXC_SBTYPE_EXTERN: - case EXC_SBTYPE_SPECIAL: - case EXC_SBTYPE_EUROTOOL: + case XclSupbookType::Extern: + case XclSupbookType::Special: + case XclSupbookType::Eurotool: { sal_uInt16 nCount = ulimit_cast< sal_uInt16 >( maXctList.GetSize() ); rStrm << nCount << maUrlEncoded; @@ -1745,11 +1745,11 @@ void XclExpSupbook::WriteBody( XclExpStream& rStrm ) rStrm << maXctList.GetRecord( nPos )->GetTabName(); } break; - case EXC_SBTYPE_ADDIN: + case XclSupbookType::Addin: rStrm << mnXclTabCount << EXC_SUPB_ADDIN; break; default: - OSL_FAIL( "XclExpSupbook::WriteBody - unknown SUPBOOK type" ); + SAL_WARN( "sc.filter", "Unhandled SUPBOOK type " << meType); } } @@ -1978,7 +1978,7 @@ bool XclExpSupbookBuffer::InsertEuroTool( OUString aUrl( "\001\010EUROTOOL.XLA" ); if( !GetSupbookUrl( xSupbook, rnSupbook, aUrl ) ) { - xSupbook.reset( new XclExpSupbook( GetRoot(), aUrl, EXC_SBTYPE_EUROTOOL ) ); + xSupbook.reset( new XclExpSupbook( GetRoot(), aUrl, XclSupbookType::Eurotool ) ); rnSupbook = Append( xSupbook ); } rnExtName = xSupbook->InsertEuroTool( rName ); @@ -2080,7 +2080,7 @@ void XclExpSupbookBuffer::SaveXml( XclExpXmlStream& rStrm ) for (size_t nPos = 0, nSize = maSupbookList.GetSize(); nPos < nSize; ++nPos) { XclExpSupbookRef xRef( maSupbookList.GetRecord( nPos)); - if (xRef->GetType() != EXC_SBTYPE_EXTERN) + if (xRef->GetType() != XclSupbookType::Extern) continue; // handle only external reference (for now?) sal_uInt16 nId = xRef->GetFileId(); @@ -2120,7 +2120,7 @@ bool XclExpSupbookBuffer::HasExternalReferences() const { for (size_t nPos = 0, nSize = maSupbookList.GetSize(); nPos < nSize; ++nPos) { - if (maSupbookList.GetRecord( nPos)->GetType() == EXC_SBTYPE_EXTERN) + if (maSupbookList.GetRecord( nPos)->GetType() == XclSupbookType::Extern) return true; } return false; diff --git a/sc/source/filter/excel/xilink.cxx b/sc/source/filter/excel/xilink.cxx index 1784a5610be2..3763ef7413d8 100644 --- a/sc/source/filter/excel/xilink.cxx +++ b/sc/source/filter/excel/xilink.cxx @@ -349,12 +349,12 @@ XclImpExtName::XclImpExtName( XclImpSupbook& rSupbook, XclImpStream& rStrm, XclS maName = rStrm.ReadUniString( nLen ); if( ::get_flag( nFlags, EXC_EXTN_BUILTIN ) || !::get_flag( nFlags, EXC_EXTN_OLE_OR_DDE ) ) { - if( eSubType == EXC_SBTYPE_ADDIN ) + if( eSubType == XclSupbookType::Addin ) { meType = xlExtAddIn; maName = XclImpRoot::GetScAddInName( maName ); } - else if ( (eSubType == EXC_SBTYPE_EUROTOOL) && + else if ( (eSubType == XclSupbookType::Eurotool) && maName.equalsIgnoreAsciiCase( "EUROCONVERT" ) ) meType = xlExtEuroConvert; else @@ -619,7 +619,7 @@ void XclImpSupbookTab::LoadCachedValues( const ScExternalRefCache::TableTypeRef& XclImpSupbook::XclImpSupbook( XclImpStream& rStrm ) : XclImpRoot( rStrm.GetRoot() ), - meType( EXC_SBTYPE_UNKNOWN ), + meType( XclSupbookType::Unknown ), mnSBTab( EXC_TAB_DELETED ) { sal_uInt16 nSBTabCnt; @@ -629,8 +629,8 @@ XclImpSupbook::XclImpSupbook( XclImpStream& rStrm ) : { switch( rStrm.ReaduInt16() ) { - case EXC_SUPB_SELF: meType = EXC_SBTYPE_SELF; break; - case EXC_SUPB_ADDIN: meType = EXC_SBTYPE_ADDIN; break; + case EXC_SUPB_SELF: meType = XclSupbookType::Self; break; + case EXC_SUPB_ADDIN: meType = XclSupbookType::Addin; break; default: OSL_FAIL( "XclImpSupbook::XclImpSupbook - unknown special SUPBOOK type" ); } return; @@ -642,12 +642,12 @@ XclImpSupbook::XclImpSupbook( XclImpStream& rStrm ) : if( maXclUrl.equalsIgnoreAsciiCase( "\010EUROTOOL.XLA" ) ) { - meType = EXC_SBTYPE_EUROTOOL; + meType = XclSupbookType::Eurotool; maSupbTabList.push_back( o3tl::make_unique<XclImpSupbookTab>( maXclUrl ) ); } else if( nSBTabCnt ) { - meType = EXC_SBTYPE_EXTERN; + meType = XclSupbookType::Extern; //assuming all empty strings with just len header of 0 const size_t nMinRecordSize = sizeof(sal_Int16); @@ -667,7 +667,7 @@ XclImpSupbook::XclImpSupbook( XclImpStream& rStrm ) : } else { - meType = EXC_SBTYPE_SPECIAL; + meType = XclSupbookType::Special; // create dummy list entry maSupbTabList.push_back( o3tl::make_unique<XclImpSupbookTab>( maXclUrl ) ); } @@ -706,20 +706,20 @@ const XclImpExtName* XclImpSupbook::GetExternName( sal_uInt16 nXclIndex ) const SAL_WARN("sc", "XclImpSupbook::GetExternName - index must be >0"); return nullptr; } - if (meType == EXC_SBTYPE_SELF || nXclIndex > maExtNameList.size()) + if (meType == XclSupbookType::Self || nXclIndex > maExtNameList.size()) return nullptr; return maExtNameList[nXclIndex-1].get(); } bool XclImpSupbook::GetLinkData( OUString& rApplic, OUString& rTopic ) const { - return (meType == EXC_SBTYPE_SPECIAL) && XclImpUrlHelper::DecodeLink( rApplic, rTopic, maXclUrl ); + return (meType == XclSupbookType::Special) && XclImpUrlHelper::DecodeLink( rApplic, rTopic, maXclUrl ); } const OUString& XclImpSupbook::GetMacroName( sal_uInt16 nXclNameIdx ) const { OSL_ENSURE( nXclNameIdx > 0, "XclImpSupbook::GetMacroName - index must be >0" ); - const XclImpName* pName = (meType == EXC_SBTYPE_SELF) ? GetNameManager().GetName( nXclNameIdx ) : nullptr; + const XclImpName* pName = (meType == XclSupbookType::Self) ? GetNameManager().GetName( nXclNameIdx ) : nullptr; return (pName && pName->IsVBName()) ? pName->GetScName() : EMPTY_OUSTRING; } @@ -737,7 +737,7 @@ sal_uInt16 XclImpSupbook::GetTabCount() const void XclImpSupbook::LoadCachedValues() { - if (meType != EXC_SBTYPE_EXTERN || GetExtDocOptions().GetDocSettings().mnLinkCnt > 0 || !GetDocShell()) + if (meType != XclSupbookType::Extern || GetExtDocOptions().GetDocSettings().mnLinkCnt > 0 || !GetDocShell()) return; OUString aAbsUrl( ScGlobal::GetAbsDocName(maXclUrl, GetDocShell()) ); @@ -811,7 +811,7 @@ void XclImpLinkManagerImpl::ReadExternname( XclImpStream& rStrm, ExcelToSc* pFor bool XclImpLinkManagerImpl::IsSelfRef( sal_uInt16 nXtiIndex ) const { const XclImpSupbook* pSupbook = GetSupbook( nXtiIndex ); - return pSupbook && (pSupbook->GetType() == EXC_SBTYPE_SELF); + return pSupbook && (pSupbook->GetType() == XclSupbookType::Self); } bool XclImpLinkManagerImpl::GetScTabRange( diff --git a/sc/source/filter/inc/xllink.hxx b/sc/source/filter/inc/xllink.hxx index 08cbb27c18e5..224fdca0cc4c 100644 --- a/sc/source/filter/inc/xllink.hxx +++ b/sc/source/filter/inc/xllink.hxx @@ -20,6 +20,8 @@ #ifndef INCLUDED_SC_SOURCE_FILTER_INC_XLLINK_HXX #define INCLUDED_SC_SOURCE_FILTER_INC_XLLINK_HXX +#include <ostream> + #include <sal/types.h> // Constants and Enumerations ================================================= @@ -69,16 +71,32 @@ const sal_uInt16 EXC_SUPB_SELF = 0x0401; const sal_uInt16 EXC_SUPB_ADDIN = 0x3A01; /** This enumeration specifies the type of a SUPBOOK record. */ -enum XclSupbookType +enum class XclSupbookType { - EXC_SBTYPE_UNKNOWN, /// unknown SUPBOOK record type. - EXC_SBTYPE_SELF, /// SUPBOOK is used for internal references. - EXC_SBTYPE_EXTERN, /// SUPBOOK is used for external references. - EXC_SBTYPE_ADDIN, /// SUPBOOK contains add-in functions. - EXC_SBTYPE_SPECIAL, /// SUPBOOK is used for DDE or OLE links. - EXC_SBTYPE_EUROTOOL /// SUPBOOK is used for EUROCONVERT. + Unknown, /// unknown SUPBOOK record type. + Self, /// SUPBOOK is used for internal references. + Extern, /// SUPBOOK is used for external references. + Addin, /// SUPBOOK contains add-in functions. + Special, /// SUPBOOK is used for DDE or OLE links. + Eurotool /// SUPBOOK is used for EUROCONVERT. }; +template< typename charT, typename traits > +inline std::basic_ostream<charT, traits> & operator <<( + std::basic_ostream<charT, traits> & stream, const XclSupbookType& type ) +{ + switch (type) + { + case XclSupbookType::Unknown: return stream << "unknown"; + case XclSupbookType::Self: return stream << "self"; + case XclSupbookType::Extern: return stream << "extern"; + case XclSupbookType::Addin: return stream << "addin"; + case XclSupbookType::Special: return stream << "special"; + case XclSupbookType::Eurotool: return stream << "eurotool"; + default: return stream << static_cast<int>(type); + } +} + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits