[Libreoffice-commits] .: tools/inc tools/source

Fridrich Strba fridrich at kemper.freedesktop.org
Fri Nov 26 05:51:08 PST 2010


 tools/inc/tools/urlobj.hxx   |    3 +++
 tools/source/fsys/urlobj.cxx |   38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)

New commits:
commit da0fd5c999fc6f8b5e2d4ecccbf66e1034a03ed9
Author: Florian Reuter <freuter at novell.com>
Date:   Fri Nov 26 14:40:03 2010 +0100

    tools-urlobj-smb-scheme-patch.diff: migrated
    
    process relative SMB paths (in hyperlinks) correctly

diff --git a/tools/inc/tools/urlobj.hxx b/tools/inc/tools/urlobj.hxx
index a4f2a07..f446f25 100644
--- a/tools/inc/tools/urlobj.hxx
+++ b/tools/inc/tools/urlobj.hxx
@@ -1533,6 +1533,9 @@ private:
 
     TOOLS_DLLPRIVATE static bool scanIPv6reference(
         sal_Unicode const *& rBegin, sal_Unicode const * pEnd);
+
+private:
+    void changeScheme(INetProtocol eTargetScheme);
 };
 
 // static
diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index c87c0b2..ec6d7a2 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -1444,10 +1444,48 @@ bool INetURLObject::setAbsURIRef(rtl::OUString const & rTheAbsURIRef,
 
     m_aAbsURIRef = aSynAbsURIRef;
 
+    // At this point references of type "\\server\paths" have
+    // been converted to file:://server/path".
+#ifdef LINUX
+    if (m_eScheme==INET_PROT_FILE && !m_aHost.isEmpty()) {
+        // Change "file:://server/path" URIs to "smb:://server/path" on
+        // Linux
+        // Leave "file::path" URIs unchanged.
+        changeScheme(INET_PROT_SMB);
+    }
+#endif
+
+#ifdef WIN
+    if (m_eScheme==INET_PROT_SMB) {
+        // Change "smb://server/path" URIs to "file://server/path"
+        // URIs on Windows, since Windows doesn't understand the
+        // SMB scheme.
+        changeScheme(INET_PROT_FILE);
+    }
+#endif
+
     return true;
 }
 
 //============================================================================
+void INetURLObject::changeScheme(INetProtocol eTargetScheme) {
+    ::rtl::OUString aTmpStr=m_aAbsURIRef.makeStringAndClear();
+    int oldSchemeLen=strlen(getSchemeInfo().m_pScheme);
+    m_eScheme=eTargetScheme;
+    int newSchemeLen=strlen(getSchemeInfo().m_pScheme);
+    m_aAbsURIRef.appendAscii(getSchemeInfo().m_pScheme);
+    m_aAbsURIRef.append(aTmpStr.getStr()+oldSchemeLen);
+    int delta=newSchemeLen-oldSchemeLen;
+    m_aUser+=delta;
+    m_aAuth+=delta;
+    m_aHost+=delta;
+    m_aPort+=delta;
+    m_aPath+=delta;
+    m_aQuery+=delta;
+    m_aFragment+=delta;
+}
+
+//============================================================================
 bool INetURLObject::convertRelToAbs(rtl::OUString const & rTheRelURIRef,
                                     bool bOctets,
                                     INetURLObject & rTheAbsURIRef,


More information about the Libreoffice-commits mailing list