summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-07-27 22:14:39 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-09-07 09:10:34 -0400
commita6639312005763d19e877bc61e6a844c09f5fb23 (patch)
treea955fe459e1eb82957100dd1c397ee3a31c32fdd /framework
parent948350d60c031904c7daffc7be95ef9c146e700c (diff)
First cut on integrating liborcus into libreoffice tree....
It introduces the 'FilterProvider' property in the media descriptor to optionally bypass the normal loading process and let the external filter provider to handle the loading. For now I'm overwriting the csv import filter just to see how this could work just as an experiment. Orcus still needs a lot of work, and it crashes very often at the moment. Change-Id: I11b34572c71073144804a7d0dd5176c8067d8deb
Diffstat (limited to 'framework')
-rw-r--r--framework/source/loadenv/loadenv.cxx50
1 files changed, 46 insertions, 4 deletions
diff --git a/framework/source/loadenv/loadenv.cxx b/framework/source/loadenv/loadenv.cxx
index 02a8c7a3f487..a4c042a28869 100644
--- a/framework/source/loadenv/loadenv.cxx
+++ b/framework/source/loadenv/loadenv.cxx
@@ -91,13 +91,13 @@
const char PROP_TYPES[] = "Types";
const char PROP_NAME[] = "Name";
-
-namespace framework{
+namespace framework {
// may there exist already a define .-(
#ifndef css
namespace css = ::com::sun::star;
#endif
+using namespace com::sun::star;
class LoadEnvListener : private ThreadHelpBase
@@ -716,6 +716,37 @@ LoadEnv::EContentType LoadEnv::classifyContent(const ::rtl::OUString&
return E_UNSUPPORTED_CONTENT;
}
+namespace {
+
+bool queryOrcusTypeAndFilter(const uno::Sequence<beans::PropertyValue>& rDescriptor, OUString& rType, OUString& rFilter)
+{
+ OUString aURL;
+ sal_Int32 nSize = rDescriptor.getLength();
+ for (sal_Int32 i = 0; i < nSize; ++i)
+ {
+ const beans::PropertyValue& rProp = rDescriptor[i];
+ if (rProp.Name == "URL")
+ {
+ rProp.Value >>= aURL;
+ break;
+ }
+ }
+
+ if (aURL.isEmpty() || aURL.copy(0,8).equalsIgnoreAsciiCase("private:"))
+ return false;
+
+ if (aURL.endsWith(".csv"))
+ {
+ // Use .csv as the first test file type.
+ rType = "generic_Text";
+ rFilter = "orcus-test-filter";
+ return true;
+ }
+
+ return false;
+}
+
+}
void LoadEnv::impl_detectTypeAndFilter()
throw(LoadEnvException, css::uno::RuntimeException)
@@ -736,7 +767,18 @@ void LoadEnv::impl_detectTypeAndFilter()
aReadLock.unlock();
// <- SAFE
- ::rtl::OUString sType;
+ rtl::OUString sType, sFilter;
+
+ if (queryOrcusTypeAndFilter(lDescriptor, sType, sFilter) && !sType.isEmpty() && !sFilter.isEmpty())
+ {
+ // Orcus type detected. Skip the normal type detection process.
+ m_lMediaDescriptor << lDescriptor;
+ m_lMediaDescriptor[comphelper::MediaDescriptor::PROP_TYPENAME()] <<= sType;
+ m_lMediaDescriptor[comphelper::MediaDescriptor::PROP_FILTERNAME()] <<= sFilter;
+ m_lMediaDescriptor[comphelper::MediaDescriptor::PROP_FILTERPROVIDER()] <<= OUString("orcus");
+ return;
+ }
+
css::uno::Reference< css::document::XTypeDetection > xDetect(xSMGR->createInstance(SERVICENAME_TYPEDETECTION), css::uno::UNO_QUERY);
if (xDetect.is())
sType = xDetect->queryTypeByDescriptor(lDescriptor, sal_True); /*TODO should deep detection be able for enable/disable it from outside? */
@@ -753,7 +795,7 @@ void LoadEnv::impl_detectTypeAndFilter()
m_lMediaDescriptor[::comphelper::MediaDescriptor::PROP_TYPENAME()] <<= sType;
// Is there an already detected (may be preselected) filter?
// see below ...
- ::rtl::OUString sFilter = m_lMediaDescriptor.getUnpackedValueOrDefault(::comphelper::MediaDescriptor::PROP_FILTERNAME(), ::rtl::OUString());
+ sFilter = m_lMediaDescriptor.getUnpackedValueOrDefault(::comphelper::MediaDescriptor::PROP_FILTERNAME(), ::rtl::OUString());
aWriteLock.unlock();
// <- SAFE