diff options
author | Tor Lillqvist <tml@collabora.com> | 2017-03-28 17:01:22 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2017-03-28 18:44:44 +0300 |
commit | b566f0d68804e97f9c73d1cc2beed568a4b74105 (patch) | |
tree | 8730f70da9eb8040e6f60978f0faca504a5aeaed | |
parent | b3545786dafcf2293168fea894b4a61ae64b52f3 (diff) |
First steps to round-trip xlExternalLinkPath/xlPathMissing things
Links to broken or missing external workbooks in .xlsx have the
relationship type
http://schemas.microsoft.com/office/2006/relationships/xlExternalLinkPath/xlPathMissing
. Ideally we should round-trip those (save identically back to .xlsx).
Currently we don't save them at all, and Excel doesn't like formulas
that refer to such external (but not mentioned in externalLinks)
workbooks.
Just a start, does not actually produce anything useful yet.
Change-Id: Ic5a481c91864134f1caf66c56a4aef685d3018a7
-rw-r--r-- | sc/source/filter/inc/externallinkbuffer.hxx | 22 | ||||
-rw-r--r-- | sc/source/filter/oox/externallinkbuffer.cxx | 11 |
2 files changed, 30 insertions, 3 deletions
diff --git a/sc/source/filter/inc/externallinkbuffer.hxx b/sc/source/filter/inc/externallinkbuffer.hxx index 7114daa4eddf..8d52c4216604 100644 --- a/sc/source/filter/inc/externallinkbuffer.hxx +++ b/sc/source/filter/inc/externallinkbuffer.hxx @@ -20,6 +20,8 @@ #ifndef INCLUDED_SC_SOURCE_FILTER_INC_EXTERNALLINKBUFFER_HXX #define INCLUDED_SC_SOURCE_FILTER_INC_EXTERNALLINKBUFFER_HXX +#include <ostream> + #include <com/sun/star/sheet/ExternalLinkInfo.hpp> #include <oox/helper/containerhelper.hxx> #include "defnamesbuffer.hxx" @@ -160,12 +162,32 @@ enum class ExternalLinkType Self, /// Link refers to the current workbook. Same, /// Link refers to the current sheet. External, /// Link refers to an external spreadsheet document. + // let's ignore xlStartup and xlAlternateStartup for now + PathMissing, /// Just for round-tripping Library, /// Link refers to an external add-in. DDE, /// DDE link. OLE, /// OLE link. Unknown /// Unknown or unsupported link type. }; +template< typename charT, typename traits > +inline std::basic_ostream<charT, traits> & operator <<( + std::basic_ostream<charT, traits> & stream, const ExternalLinkType& type ) +{ + switch (type) + { + case ExternalLinkType::Self: return stream << "self"; + case ExternalLinkType::Same: return stream << "same"; + case ExternalLinkType::External: return stream << "external"; + case ExternalLinkType::PathMissing: return stream << "pathmissing"; + case ExternalLinkType::Library: return stream << "library"; + case ExternalLinkType::DDE: return stream << "dde"; + case ExternalLinkType::OLE: return stream << "ole"; + case ExternalLinkType::Unknown: return stream << "unknown"; + default: return stream << static_cast<int>(type); + } +} + class ExternalLink : public WorkbookHelper { public: diff --git a/sc/source/filter/oox/externallinkbuffer.cxx b/sc/source/filter/oox/externallinkbuffer.cxx index 73e65081a418..eb6d5fad6356 100644 --- a/sc/source/filter/oox/externallinkbuffer.cxx +++ b/sc/source/filter/oox/externallinkbuffer.cxx @@ -360,8 +360,9 @@ void ExternalLink::importExternalBook( const Relations& rRelations, SequenceInpu void ExternalLink::importExtSheetNames( SequenceInputStream& rStrm ) { // load external sheet names and create the sheet caches in the Calc document - OSL_ENSURE( (meLinkType == ExternalLinkType::External) || (meLinkType == ExternalLinkType::Library), - "ExternalLink::importExtSheetNames - invalid link type" ); + SAL_WARN_IF( (meLinkType != ExternalLinkType::External) && (meLinkType != ExternalLinkType::Library), + "sc.filter", + "Invalid link type: " << meLinkType ); if( meLinkType == ExternalLinkType::External ) // ignore sheets of external libraries for( sal_Int32 nSheet = 0, nCount = rStrm.readInt32(); !rStrm.isEof() && (nSheet < nCount); ++nSheet ) insertExternalSheet( BiffHelper::readString( rStrm ) ); @@ -487,12 +488,16 @@ void ExternalLink::setExternalTargetUrl( const OUString& rTargetUrl, const OUStr if( !maTargetUrl.isEmpty() ) meLinkType = ExternalLinkType::External; } + else if( rTargetType == CREATE_MSOFFICE_RELATION_TYPE( "xlExternalLinkPath/xlPathMissing" ) ) + { + meLinkType = ExternalLinkType::PathMissing; + } else if( rTargetType == CREATE_MSOFFICE_RELATION_TYPE( "xlExternalLinkPath/xlLibrary" ) ) { meLinkType = ExternalLinkType::Library; meFuncLibType = FunctionProvider::getFuncLibTypeFromLibraryName( rTargetUrl ); } - OSL_ENSURE( meLinkType != ExternalLinkType::Unknown, "ExternalLink::setExternalTargetUrl - empty target URL or unknown target type" ); + SAL_WARN_IF( meLinkType == ExternalLinkType::Unknown, "sc.filter", "Empty target URL or unknown target type, URL='" << rTargetUrl << "', type='" << rTargetType << "'" ); // create the external document link API object that will contain the sheet caches if( meLinkType == ExternalLinkType::External ) try |