diff options
-rw-r--r-- | sc/source/core/tool/compiler.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/excel/xecontent.cxx | 12 | ||||
-rw-r--r-- | sc/source/filter/excel/xelink.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/inc/xecontent.hxx | 5 | ||||
-rw-r--r-- | sc/source/ui/unoobj/linkuno.cxx | 8 |
5 files changed, 18 insertions, 12 deletions
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index 510a2b842e38..98bad502e266 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -4184,8 +4184,7 @@ void ScCompiler::CreateStringFromExternal(OUStringBuffer& rBuffer, FormulaToken* { vector<OUString> aTabNames; pRefMgr->getAllCachedTableNames(nFileId, aTabNames); - if (aTabNames.empty()) - return; + assert(!aTabNames.empty()); // something is seriously wrong, but continue pConv->makeExternalRefStr( rBuffer, GetPos(), nFileId, *pFileName, aTabNames, t->GetString().getString(), diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx index f0e8a079e502..ca9f8dbc8683 100644 --- a/sc/source/filter/excel/xecontent.cxx +++ b/sc/source/filter/excel/xecontent.cxx @@ -353,7 +353,9 @@ XclExpHyperlink::XclExpHyperlink( const XclExpRoot& rRoot, const SvxURLField& rU { sal_uInt16 nLevel; bool bRel; - OUString aFileName( BuildFileName( nLevel, bRel, rUrl, rRoot ) ); + /* TODO: should we differentiate between BIFF and OOXML and write IURI + * encoded for OOXML? */ + OUString aFileName( BuildFileName( nLevel, bRel, rUrl, rRoot, false ) ); if( eProtocol == INET_PROT_SMB ) { @@ -444,9 +446,10 @@ XclExpHyperlink::~XclExpHyperlink() } OUString XclExpHyperlink::BuildFileName( - sal_uInt16& rnLevel, bool& rbRel, const OUString& rUrl, const XclExpRoot& rRoot ) + sal_uInt16& rnLevel, bool& rbRel, const OUString& rUrl, const XclExpRoot& rRoot, bool bEncoded ) { - OUString aDosName( INetURLObject( rUrl ).getFSysPath( INetURLObject::FSYS_DOS ) ); + INetURLObject aURLObject( rUrl ); + OUString aDosName( bEncoded ? aURLObject.GetURLPath() : aURLObject.getFSysPath( INetURLObject::FSYS_DOS ) ); rnLevel = 0; rbRel = rRoot.IsRelUrl(); @@ -455,7 +458,8 @@ OUString XclExpHyperlink::BuildFileName( // try to convert to relative file name OUString aTmpName( aDosName ); aDosName = INetURLObject::GetRelURL( rRoot.GetBasePath(), rUrl, - INetURLObject::WAS_ENCODED, INetURLObject::DECODE_WITH_CHARSET ); + INetURLObject::WAS_ENCODED, + (bEncoded ? INetURLObject::DECODE_TO_IURI : INetURLObject::DECODE_WITH_CHARSET)); if (aDosName.startsWith(INET_FILE_SCHEME)) { diff --git a/sc/source/filter/excel/xelink.cxx b/sc/source/filter/excel/xelink.cxx index 08b2afbf73dd..1f6143f31217 100644 --- a/sc/source/filter/excel/xelink.cxx +++ b/sc/source/filter/excel/xelink.cxx @@ -1659,7 +1659,7 @@ void XclExpSupbook::SaveXml( XclExpXmlStream& rStrm ) bool bRel = true; OUString sId = rStrm.addRelation( pExternalLink->getOutputStream(), "http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath", - XclExpHyperlink::BuildFileName( nLevel, bRel, maUrl, GetRoot()), + XclExpHyperlink::BuildFileName( nLevel, bRel, maUrl, GetRoot(), true), true ); pExternalLink->startElement( XML_externalLink, diff --git a/sc/source/filter/inc/xecontent.hxx b/sc/source/filter/inc/xecontent.hxx index 214229397860..f2e8ee939dcf 100644 --- a/sc/source/filter/inc/xecontent.hxx +++ b/sc/source/filter/inc/xecontent.hxx @@ -113,10 +113,11 @@ public: /** Builds file name from the passed file URL. Tries to convert to relative file name. @param rnLevel (out-param) The parent directory level. - @param rbRel (out-param) true = path is relative. */ + @param rbRel (out-param) true = path is relative. + @param bEncoded if true return an IURI encoded name, not a DOS name. */ static OUString BuildFileName( sal_uInt16& rnLevel, bool& rbRel, - const OUString& rUrl, const XclExpRoot& rRoot ); + const OUString& rUrl, const XclExpRoot& rRoot, bool bEncoded ); private: /** Writes the body of the HLINK record. */ diff --git a/sc/source/ui/unoobj/linkuno.cxx b/sc/source/ui/unoobj/linkuno.cxx index 86e7fc84581d..63b4b06a6552 100644 --- a/sc/source/ui/unoobj/linkuno.cxx +++ b/sc/source/ui/unoobj/linkuno.cxx @@ -1708,7 +1708,8 @@ Reference< sheet::XExternalDocLink > SAL_CALL ScExternalDocLinksObj::addDocLink( throw (RuntimeException, std::exception) { SolarMutexGuard aGuard; - sal_uInt16 nFileId = mpRefMgr->getExternalFileId(aDocName); + OUString aDocUrl( ScGlobal::GetAbsDocName( aDocName, mpDocShell)); + sal_uInt16 nFileId = mpRefMgr->getExternalFileId(aDocUrl); Reference< sheet::XExternalDocLink > aDocLink(new ScExternalDocLinkObj(mpDocShell, mpRefMgr, nFileId)); return aDocLink; } @@ -1717,10 +1718,11 @@ Any SAL_CALL ScExternalDocLinksObj::getByName(const OUString &aName) throw (container::NoSuchElementException, lang::WrappedTargetException, RuntimeException, std::exception) { SolarMutexGuard aGuard; - if (!mpRefMgr->hasExternalFile(aName)) + OUString aDocUrl( ScGlobal::GetAbsDocName( aName, mpDocShell)); + if (!mpRefMgr->hasExternalFile(aDocUrl)) throw container::NoSuchElementException(); - sal_uInt16 nFileId = mpRefMgr->getExternalFileId(aName); + sal_uInt16 nFileId = mpRefMgr->getExternalFileId(aDocUrl); Reference< sheet::XExternalDocLink > aDocLink(new ScExternalDocLinkObj(mpDocShell, mpRefMgr, nFileId)); Any aAny; |