[Libreoffice-commits] core.git: 4 commits - sc/source

Eike Rathke erack at redhat.com
Fri Jan 9 07:11:11 PST 2015


 sc/source/core/data/global2.cxx      |    2 +-
 sc/source/core/tool/compiler.cxx     |    3 +--
 sc/source/filter/excel/xecontent.cxx |   12 ++++++++----
 sc/source/filter/excel/xelink.cxx    |    2 +-
 sc/source/filter/inc/xecontent.hxx   |    5 +++--
 sc/source/ui/unoobj/linkuno.cxx      |    8 +++++---
 6 files changed, 19 insertions(+), 13 deletions(-)

New commits:
commit 97a8b3ed5e5bd42e213d3230fa764b0f5d10f0f2
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Jan 9 13:53:27 2015 +0100

    Resolves: fdo#85617 always store fully encoded external document name
    
    Also OOXML calls these API functions, this is the central place to handle it.

diff --git a/sc/source/ui/unoobj/linkuno.cxx b/sc/source/ui/unoobj/linkuno.cxx
index ce36197..bec0c4d 100644
--- a/sc/source/ui/unoobj/linkuno.cxx
+++ b/sc/source/ui/unoobj/linkuno.cxx
@@ -1709,7 +1709,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;
 }
@@ -1718,10 +1719,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;
commit b6339617b1cc3136f9e527acd0746d712cd21643
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Jan 9 13:44:32 2015 +0100

    do not drop entire external reference, fdo#85617 related
    
    If there are no matching tab names for a FileId, preserve at least the known
    reference parts. In case of 2D references the sheet name is in the token if
    for example read from .xlsx, only for 3D references the second sheet name
    would be needed. The underlying makeExternalRefStr() and its subroutines
    handle the missing tabname elements gracefully.
    
    Still this situation is worth an assertion.

diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index f6c868d..9ae1474 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -4160,8 +4160,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(),
commit 7eb5e135422f1a5830a44d129300bc3fafb4627d
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Jan 8 23:01:44 2015 +0100

    write externalLink Relationship Target IURI encoded, fdo#85617 related
    
    Change-Id: I3df065af8e4ef44734f468fd455c3b7c93d7fbc6

diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index 521d1a9..47de380 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 7cbf9a5..5ac4d84 100644
--- a/sc/source/filter/excel/xelink.cxx
+++ b/sc/source/filter/excel/xelink.cxx
@@ -1655,7 +1655,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 2142293..f2e8ee9 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. */
commit 19feb49bd1b232425b7be19b55b950cbbc1bff67
Author: Eike Rathke <erack at redhat.com>
Date:   Wed Jan 7 22:26:40 2015 +0100

    Revert "NO_DECODE breaks non-ascii urls, fdo#85617"
    
    This reverts commit 808b0bf831d4a4fdb60c01865d0a7dd36cf9d521.
    
    This is not the right fix, it cures a symptom but probably will break
    other cases. See also my comment on https://gerrit.libreoffice.org/13670
    
    Change-Id: I5bb661ba2bcbd387a69aacf08cb13b503315c5b1

diff --git a/sc/source/core/data/global2.cxx b/sc/source/core/data/global2.cxx
index 5fd14cc..93da6d3 100644
--- a/sc/source/core/data/global2.cxx
+++ b/sc/source/core/data/global2.cxx
@@ -327,7 +327,7 @@ OUString ScGlobal::GetAbsDocName( const OUString& rFileName,
         if ( pMedium )
         {
             bool bWasAbs = true;
-            aAbsName = pMedium->GetURLObject().smartRel2Abs( rFileName, bWasAbs ).GetMainURL(INetURLObject::DECODE_TO_IURI);
+            aAbsName = pMedium->GetURLObject().smartRel2Abs( rFileName, bWasAbs ).GetMainURL(INetURLObject::NO_DECODE);
         }
         else
         {   // This can't happen, but ...


More information about the Libreoffice-commits mailing list