summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorCao Cuong Ngo <cao.cuong.ngo@gmail.com>2013-09-21 23:36:06 +0200
committerCédric Bosdonnat <cedric.bosdonnat@free.fr>2013-10-15 14:50:31 +0200
commit319b160320a045b1a5b302dafbc2220ee1d4d3c3 (patch)
tree66cd1313c1374939872533df3ddbcc333595a67b /comphelper
parent8a8d1e5b4961ada276a660b8b842f2f012a8ae85 (diff)
CMIS file picker: it really does not like ID Mark
The file picker can't go back folder if we use ID mark in the URL. Conflicts: ucb/source/ucp/cmis/cmis_content.cxx Change-Id: I6985feec71dc23848ee022e0bab9e8515a21ffd2
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/misc/mediadescriptor.cxx35
1 files changed, 35 insertions, 0 deletions
diff --git a/comphelper/source/misc/mediadescriptor.cxx b/comphelper/source/misc/mediadescriptor.cxx
index 21361f565dae..b5cd5b669a33 100644
--- a/comphelper/source/misc/mediadescriptor.cxx
+++ b/comphelper/source/misc/mediadescriptor.cxx
@@ -484,6 +484,7 @@ sal_Bool MediaDescriptor::impl_addInputStream( sal_Bool bLockFile )
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(sURL), bLockFile );
}
catch(const css::uno::Exception& ex)
@@ -723,6 +724,40 @@ 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: */