summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ucbhelper/inc/ucbhelper/fileidentifierconverter.hxx76
-rw-r--r--ucbhelper/source/client/fileidentifierconverter.cxx76
2 files changed, 36 insertions, 116 deletions
diff --git a/ucbhelper/inc/ucbhelper/fileidentifierconverter.hxx b/ucbhelper/inc/ucbhelper/fileidentifierconverter.hxx
index 1ea46c5352bf..b5f566d59f2e 100644
--- a/ucbhelper/inc/ucbhelper/fileidentifierconverter.hxx
+++ b/ucbhelper/inc/ucbhelper/fileidentifierconverter.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: fileidentifierconverter.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: sb $ $Date: 2000-11-13 11:35:36 $
+ * last change: $Author: sb $ $Date: 2000-12-15 08:25:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,8 +62,8 @@
#ifndef _UCBHELPER_FILEIDENTIFIERCONVERTER_HXX_
#define _UCBHELPER_FILEIDENTIFIERCONVERTER_HXX_
-#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
-#include <com/sun/star/uno/Reference.h>
+#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_
+#include <com/sun/star/uno/Reference.hxx>
#endif
namespace com { namespace sun { namespace star { namespace ucb {
@@ -71,71 +71,26 @@ namespace com { namespace sun { namespace star { namespace ucb {
} } } }
namespace rtl { class OUString; }
-//============================================================================
-/** Using a specific content provider manager, convert a normalized file path
- to a (file) URL.
-
- @param rManager
- A content provider manager. Must not be null.
-
- @param rHostName
- See the corresponding parameter of
- com::sun::star::ucb::XFileIdentiferConverter::getFileURLFromNormalizedPath().
-
- @param rNormalizedPath
- See the corresponding parameter of
- com::sun::star::ucb::XFileIdentiferConverter::getFileURLFromNormalizedPath().
-
- @returns
- a URL, if any of the content providers registered at the content provider
- manager returns a URL when calling
- com::sun::star::ucb::XFileIdentiferConverter::getFileURLFromNormalizedPath()
- on it. Otherwise, an empty string is returned.
-
- @see
- com::sun::star::ucb::XFileIdentiferConverter::getFileURLFromNormalizedPath().
- */
namespace ucb {
-rtl::OUString
-getFileURLFromNormalizedPath(
- com::sun::star::uno::Reference<
- com::sun::star::ucb::XContentProviderManager > const &
- rManager,
- rtl::OUString const & rHostName,
- rtl::OUString const & rNormalizedPath);
-
//============================================================================
-/** Using a specific content provider manager, convert a (file) URL to a
- normalized file path.
+/** Get a 'root' URL for the most 'local' file content provider.
+
+ @descr
+ The result can be used as the rBaseURL parameter of
+ ucb::getFileURLFromSystemPath().
@param rManager
A content provider manager. Must not be null.
- @param rHostName
- See the corresponding parameter of
- com::sun::star::ucb::XFileIdentiferConverter::getNormalizedPathFromFileURL().
-
- @param rURL
- See the corresponding parameter of
- com::sun::star::ucb::XFileIdentiferConverter::getNormalizedPathFromFileURL().
-
@returns
- a normalized path, if any of the content providers registered at the
- content provider manager returns a normalized path when calling
- com::sun::star::ucb::XFileIdentiferConverter::getNormalizedPathFromFileURL()
- on it. Otherwise, an empty string is returned.
-
- @see
- com::sun::star::ucb::XFileIdentiferConverter::getNormalizedPathFromFileURL().
+ either a 'root' URL for the most 'local' file content provider, or an
+ empty string, if no such URL can meaningfully be constructed.
*/
-rtl::OUString
-getNormalizedPathFromFileURL(
+rtl::OUString getLocalFileURL(
com::sun::star::uno::Reference<
com::sun::star::ucb::XContentProviderManager > const &
- rManager,
- rtl::OUString const & rHostName,
- rtl::OUString const & rURL);
+ rManager);
//============================================================================
/** Using a specific content provider manager, convert a file path in system
@@ -176,10 +131,6 @@ getFileURLFromSystemPath(
@param rManager
A content provider manager. Must not be null.
- @param rBaseURL
- See the corresponding parameter of
- com::sun::star::ucb::XFileIdentiferConverter::getSystemPathFromFileURL().
-
@param rURL
See the corresponding parameter of
com::sun::star::ucb::XFileIdentiferConverter::getSystemPathFromFileURL().
@@ -199,7 +150,6 @@ getSystemPathFromFileURL(
com::sun::star::uno::Reference<
com::sun::star::ucb::XContentProviderManager > const &
rManager,
- rtl::OUString const & rBaseURL,
rtl::OUString const & rURL);
}
diff --git a/ucbhelper/source/client/fileidentifierconverter.cxx b/ucbhelper/source/client/fileidentifierconverter.cxx
index fa3a86b56023..86f115a77268 100644
--- a/ucbhelper/source/client/fileidentifierconverter.cxx
+++ b/ucbhelper/source/client/fileidentifierconverter.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: fileidentifierconverter.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: sb $ $Date: 2000-11-13 11:36:12 $
+ * last change: $Author: sb $ $Date: 2000-12-15 08:27:28 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -91,71 +91,42 @@
using namespace com::sun;
using namespace com::sun::star;
-//============================================================================
-//
-// getFileURLFromNormalizedPath
-//
-//============================================================================
-
namespace ucb {
-rtl::OUString
-getFileURLFromNormalizedPath(
- uno::Reference< star::ucb::XContentProviderManager > const & rManager,
- rtl::OUString const & rHostName,
- rtl::OUString const & rNormalizedPath)
-{
- VOS_ASSERT(rManager.is());
-
- uno::Sequence< star::ucb::ContentProviderInfo >
- aProviders(rManager->queryContentProviders());
- for (sal_Int32 i = 0; i < aProviders.getLength(); ++i)
- {
- uno::Reference< star::ucb::XFileIdentifierConverter >
- xConverter(aProviders[i].ContentProvider, uno::UNO_QUERY);
- if (xConverter.is())
- {
- rtl::OUString
- aResult(xConverter->
- getFileURLFromNormalizedPath(rHostName,
- rNormalizedPath));
- if (aResult.getLength() != 0)
- return aResult;
- }
- }
- return rtl::OUString();
-}
-
//============================================================================
//
-// getNormalizedPathFromFileURL
+// getLocalFileURL
//
//============================================================================
rtl::OUString
-getNormalizedPathFromFileURL(
- uno::Reference< star::ucb::XContentProviderManager > const & rManager,
- rtl::OUString const & rHostName,
- rtl::OUString const & rURL)
+getLocalFileURL(
+ uno::Reference< star::ucb::XContentProviderManager > const & rManager)
{
VOS_ASSERT(rManager.is());
- uno::Sequence< star::ucb::ContentProviderInfo >
- aProviders(rManager->queryContentProviders());
- for (sal_Int32 i = 0; i < aProviders.getLength(); ++i)
+ static sal_Char const * const aBaseURLs[]
+ = { "file:///", "vnd.sun.star.wfs:///" };
+ sal_Int32 nMaxLocality = -1;
+ rtl::OUString aMaxBaseURL;
+ for (int i = 0; i < sizeof aBaseURLs / sizeof (sal_Char const *); ++i)
{
+ rtl::OUString aBaseURL(rtl::OUString::createFromAscii(aBaseURLs[i]));
uno::Reference< star::ucb::XFileIdentifierConverter >
- xConverter(aProviders[i].ContentProvider, uno::UNO_QUERY);
+ xConverter(rManager->queryContentProvider(aBaseURL),
+ uno::UNO_QUERY);
if (xConverter.is())
{
- rtl::OUString
- aResult(xConverter->getNormalizedPathFromFileURL(rHostName,
- rURL));
- if (aResult.getLength() != 0)
- return aResult;
+ sal_Int32 nLocality
+ = xConverter->getFileProviderLocality(aBaseURL);
+ if (nLocality > nMaxLocality)
+ {
+ nMaxLocality = nLocality;
+ aMaxBaseURL = aBaseURL;
+ }
}
}
- return rtl::OUString();
+ return aMaxBaseURL;
}
//============================================================================
@@ -189,15 +160,14 @@ getFileURLFromSystemPath(
rtl::OUString
getSystemPathFromFileURL(
uno::Reference< star::ucb::XContentProviderManager > const & rManager,
- rtl::OUString const & rBaseURL,
rtl::OUString const & rURL)
{
VOS_ASSERT(rManager.is());
uno::Reference< star::ucb::XFileIdentifierConverter >
- xConverter(rManager->queryContentProvider(rBaseURL), uno::UNO_QUERY);
+ xConverter(rManager->queryContentProvider(rURL), uno::UNO_QUERY);
if (xConverter.is())
- return xConverter->getSystemPathFromFileURL(rBaseURL, rURL);
+ return xConverter->getSystemPathFromFileURL(rURL);
else
return rtl::OUString();
}