[Libreoffice-commits] core.git: comphelper/source include/comphelper

Stephan Bergmann sbergman at redhat.com
Wed Oct 16 03:56:34 PDT 2013


 comphelper/source/misc/mediadescriptor.cxx |   63 ++++++-----------------------
 include/comphelper/mediadescriptor.hxx     |   12 -----
 2 files changed, 14 insertions(+), 61 deletions(-)

New commits:
commit 0522b84769922218cc1e1c9c7baa16e9fad77538
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 16 12:43:46 2013 +0200

    Straighten the removeFragment code again
    
    ...what apparently happened is:
    
    (1) First, 2c6363eb16f50a8cfd81bc8511554af4f9e06478 "Be less pathetic" replaced
        MediaDescriptor::impl_normalizeURL with removeFragment.
    
    (2) Then, b378e754ae892a044460cfbe33ccc2e51c01f5ca "CMIS: fix file saving issue"
        (plus follow-up b50d3727cf336bb536efe7bf067f484ddf864e9a "WaE: unused
        function 'removeFragment'") removed calling removeFragment at all (but re-
        introduced a now bogus "Parse URL! ..." comment that (1) had removed), which
    
    (3) 34f4d2574987b272681b5843e8f5edc374f55fde "CMIS file picker: it really does
        not like ID Mark" tried to revert again (but kept the bogus comment in), and
    
    (4) odd commit 319b160320a045b1a5b302dafbc2220ee1d4d3c3 "CMIS file picker: it
        really does not like ID Mark" (that looks like a merge conflict resolution
        gone wrong) erroneously re-introduced MediaDescriptor::impl_normalizeURL
        that (1) had removed, which caused a -Wunused-variable warning that
    
    (5) 706c5a54f662ea58e3b3a64f189eb5120191152a "-Werror,-Wunused-variable" tried
        to fix, but working under wrong assumptions.
    
    The solution is to go effectively back to the code as it was after (1).
    
    Change-Id: I62dfa9fa3adbea6b2cb10a509416fe3797c577b9

diff --git a/comphelper/source/misc/mediadescriptor.cxx b/comphelper/source/misc/mediadescriptor.cxx
index 095df58..fd2ff28 100644
--- a/comphelper/source/misc/mediadescriptor.cxx
+++ b/comphelper/source/misc/mediadescriptor.cxx
@@ -49,21 +49,22 @@ namespace comphelper{
 
 namespace {
 
-    OUString removeFragment(OUString const & uri) {
-        css::uno::Reference< css::uri::XUriReference > ref(
-                css::uri::UriReferenceFactory::create(
-                    comphelper::getProcessComponentContext())->
-                parse(uri));
-        if (ref.is()) {
-            ref->clearFragment();
-            return ref->getUriReference();
-        } else {
-            SAL_WARN("comphelper", "cannot parse <" << uri << ">");
-            return uri;
-        }
+OUString removeFragment(OUString const & uri) {
+    css::uno::Reference< css::uri::XUriReference > ref(
+        css::uri::UriReferenceFactory::create(
+            comphelper::getProcessComponentContext())->
+        parse(uri));
+    if (ref.is()) {
+        ref->clearFragment();
+        return ref->getUriReference();
+    } else {
+        SAL_WARN("comphelper", "cannot parse <" << uri << ">");
+        return uri;
     }
 }
 
+}
+
 const OUString& MediaDescriptor::PROP_ABORTED()
 {
     static const OUString sProp("Aborted");
@@ -483,9 +484,7 @@ sal_Bool MediaDescriptor::impl_addInputStream( sal_Bool bLockFile )
             throw css::uno::Exception("Found no URL.",
                     css::uno::Reference< css::uno::XInterface >());
 
-        // Parse URL! Only the main part has to be used further. E.g. a jumpmark can make trouble
-        OUString sNormalizedURL = impl_normalizeURL( sURL );
-        return impl_openStreamWithURL( removeFragment(sNormalizedURL), bLockFile );
+        return impl_openStreamWithURL( removeFragment(sURL), bLockFile );
     }
     catch(const css::uno::Exception& ex)
     {
@@ -724,40 +723,6 @@ sal_Bool MediaDescriptor::impl_openStreamWithURL( const OUString& sURL, sal_Bool
     return xInputStream.is();
 }
 
-OUString MediaDescriptor::impl_normalizeURL(const OUString& sURL)
-{
-    /* Remove Jumpmarks (fragments) of an URL only here.
-       They are not part of any URL and as a result may be
-       no ucb content can be created then.
-       On the other side arguments must exists ... because
-       they are part of an URL.
-
-       Do not use the URLTransformer service here. Because
-       it parses the URL in another way. It's main part isnt enough
-       and it's complete part contains the jumpmark (fragment) parameter ...
-    */
-
-    try
-    {
-        css::uno::Reference< css::uno::XComponentContext >    xContext    = ::comphelper::getProcessComponentContext();
-        css::uno::Reference< css::uri::XUriReferenceFactory > xUriFactory = css::uri::UriReferenceFactory::create(xContext);;
-        css::uno::Reference< css::uri::XUriReference >        xUriRef     = xUriFactory->parse(sURL);
-        if (xUriRef.is())
-        {
-            xUriRef->clearFragment();
-            return xUriRef->getUriReference();
-        }
-    }
-    catch(const css::uno::RuntimeException&)
-        { throw; }
-    catch(const css::uno::Exception&)
-        {}
-
-    // If an error ocurred ... return the original URL.
-    // It's a try .-)
-    return sURL;
-}
-
 } // namespace comphelper
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/mediadescriptor.hxx b/include/comphelper/mediadescriptor.hxx
index 5409f14..5f353e5 100644
--- a/include/comphelper/mediadescriptor.hxx
+++ b/include/comphelper/mediadescriptor.hxx
@@ -289,18 +289,6 @@ class COMPHELPER_DLLPUBLIC MediaDescriptor : public SequenceAsHashMap
                     be created as new item. FALSE otherwise.
          */
         COMPHELPER_DLLPRIVATE sal_Bool impl_addInputStream( sal_Bool bLockFile );
-
-        /** @short  some URL parts can make trouble for opening streams (e.g. jumpmarks.)
-                    An URL should be "normalized" before its used.
-
-            @param  sURL
-                    the original URL (e.g. including a jumpmark)
-
-            @return [string]
-                    the "normalized" URL (e.g. without jumpmark)
-         */
-        COMPHELPER_DLLPRIVATE OUString impl_normalizeURL(const OUString& sURL);
-
 };
 
 } // namespace comphelper


More information about the Libreoffice-commits mailing list