summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-03-07 01:35:09 -0500
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-03-07 01:44:47 -0500
commite4003b67062e575f9b77772488f9b9691fa9fc38 (patch)
tree347499e7f3fa76578160ad5a8a7b610c22b732e0
parentcdcd7b0898626b6b5f475f31bb19b55c4fd0c23b (diff)
Make check passes. Remove deep-only detection for real.
Now the type detection process is a lot more simpler. Change-Id: I5a3a68afef8276a7f07be75c0b2db8151512b3fb
-rw-r--r--filter/source/config/cache/typedetection.cxx164
-rw-r--r--filter/source/config/cache/typedetection.hxx27
2 files changed, 0 insertions, 191 deletions
diff --git a/filter/source/config/cache/typedetection.cxx b/filter/source/config/cache/typedetection.cxx
index aba091d6498c..367797ecbe2e 100644
--- a/filter/source/config/cache/typedetection.cxx
+++ b/filter/source/config/cache/typedetection.cxx
@@ -426,24 +426,6 @@ void printFlatDetectionList(const char* caption, const FlatDetection& types)
if (lFlatTypes.size()>0)
sType = impl_detectTypeFlatAndDeep(stlDescriptor, lFlatTypes, bAllowDeep, lUsedDetectors, sLastChance);
-#if 0 // In theory we should no longer need to do deep-only detection, but let's see if it works fine in real life...
-
- //*******************************************
- // if no flat detected (nor preselected!) type could be
- // verified and no error occurred during creation of
- // the might needed input stream, start detection
- // which uses all registered deep detection services.
- if (
- (sType.isEmpty()) &&
- (bAllowDeep )
- )
- {
- // Let's the detection service know we are in a deep detection phase.
- stlDescriptor[comphelper::MediaDescriptor::PROP_DEEPDETECTION()] <<= sal_True;
- sType = impl_detectTypeDeepOnly(stlDescriptor, lUsedDetectors);
- }
-#endif
-
//*******************************************
// flat detection failed
// pure deep detection failed
@@ -969,152 +951,6 @@ void TypeDetection::impl_getPreselection(
// <- SAFE ----------------------------------
}
-//TO-DO: add a priority entry to filter config, e.g. defaulting to 50 and
-//flag externally that some filters are lower e.g. 25 and are catch-alls
-//to be tried last. Split up writer/calc/etc. filter detection to standalone
-//those problematic formats
-namespace
-{
- bool sort_catchalls_to_end(const rtl::OUString& rA, const rtl::OUString& rB)
- {
- if (rA == rB)
- return false;
- if ( rA == "com.sun.star.text.FormatDetector" )
- return false;
- if ( rB == "com.sun.star.text.FormatDetector" )
- return true;
- return rA < rB;
- }
-}
-
-::rtl::OUString TypeDetection::impl_detectTypeDeepOnly( ::comphelper::MediaDescriptor& rDescriptor ,
- const OUStringList& lOutsideUsedDetectors)
-{
- // We must know if a detect service was already used:
- // i) in a combined flat/deep detection scenario outside or
- // ii) in this method for a deep detection only.
- // Reason: Such deep detection services work differently in these two modes!
- OUStringList lInsideUsedDetectors;
- OUStringList::const_iterator pIt;
-
- // a)
- // The list of "already used detect services" correspond to the list
- // of preselected or flat detected types. But these detect services was called
- // to check these types explicitly and return black/white ... yes/no only.
- // Now they are called to return any possible result. But we should preferr
- // these already used detect services against all other ones!
- for ( pIt = lOutsideUsedDetectors.begin();
- pIt != lOutsideUsedDetectors.end() ;
- ++pIt )
- {
- const ::rtl::OUString& sDetectService = *pIt;
- ::rtl::OUString sDeepType = impl_askDetectService(sDetectService, rDescriptor);
- if (!sDeepType.isEmpty())
- return sDeepType;
- lInsideUsedDetectors.push_back(sDetectService);
- }
-
- // SAFE -> ----------------------------------
- ::osl::ResettableMutexGuard aLock(m_aLock);
- OUStringList lDetectors = m_rCache->getItemNames(FilterCache::E_DETECTSERVICE);
- std::sort(lDetectors.begin(), lDetectors.end(), sort_catchalls_to_end);
- aLock.clear();
- // <- SAFE ----------------------------------
-
- // b)
- // Sometimes it would be nice to ask a special set of detect services before
- // any other detect service is asked. E.g. by using a preselection of a DocumentService.
- // That's needed to prevent us from asking the "wrong application module" and
- // opening the files into the "wrong application".
- ::rtl::OUString sPreselDocumentService = rDescriptor.getUnpackedValueOrDefault(
- ::comphelper::MediaDescriptor::PROP_DOCUMENTSERVICE(),
- ::rtl::OUString());
- if (!sPreselDocumentService.isEmpty())
- {
- for ( pIt = lDetectors.begin();
- pIt != lDetectors.end() ;
- ++pIt )
- {
- const ::rtl::OUString& sDetectService = *pIt;
-
- OUStringList::const_iterator pAlreadyUsed = ::std::find(lInsideUsedDetectors.begin(), lInsideUsedDetectors.end(), sDetectService);
- if (pAlreadyUsed != lInsideUsedDetectors.end())
- continue;
-
- // SAFE -> --------------------------------------------------------
- aLock.reset();
-
- CacheItem lIProps;
- lIProps[PROPNAME_DETECTSERVICE] <<= sDetectService;
- OUStringList lTypes = m_rCache->getMatchingItemsByProps(FilterCache::E_TYPE, lIProps);
-
- aLock.clear();
- // <- SAFE --------------------------------------------------------
-
- sal_Bool bMatchDetectorToDocumentService = sal_False;
- OUStringList::const_iterator pIt2;
- for ( pIt2 = lTypes.begin();
- pIt2 != lTypes.end() ;
- ++pIt2 )
- {
- const ::rtl::OUString& sType = *pIt2;
-
- try
- {
- // SAFE -> ----------------------------------------------------
- aLock.reset();
-
- CacheItem aType = m_rCache->getItem(FilterCache::E_TYPE, sType);
- ::rtl::OUString sFilter;
- aType[PROPNAME_PREFERREDFILTER] >>= sFilter;
- CacheItem aFilter = m_rCache->getItem(FilterCache::E_FILTER, sFilter);
- ::rtl::OUString sCheckDocumentService;
- aFilter[PROPNAME_DOCUMENTSERVICE] >>= sCheckDocumentService;
-
- aLock.clear();
- // <- SAFE
-
- if (sCheckDocumentService.equals(sPreselDocumentService))
- {
- bMatchDetectorToDocumentService = sal_True;
- break;
- }
- }
- catch(const css::uno::Exception&)
- { continue; }
- }
-
- if (bMatchDetectorToDocumentService)
- {
- ::rtl::OUString sDeepType = impl_askDetectService(sDetectService, rDescriptor);
- if (!sDeepType.isEmpty())
- return sDeepType;
- lInsideUsedDetectors.push_back(sDetectService);
- }
- }
- }
-
- // c)
- // Last chance. No "used detectors", no "preselected detectors" ... ask any existing detect services
- // for this till know unknown format.
- for ( pIt = lDetectors.begin();
- pIt != lDetectors.end() ;
- ++pIt )
- {
- const ::rtl::OUString& sDetectService = *pIt;
-
- OUStringList::const_iterator pAlreadyUsed = ::std::find(lInsideUsedDetectors.begin(), lInsideUsedDetectors.end(), sDetectService);
- if (pAlreadyUsed != lInsideUsedDetectors.end())
- continue;
-
- ::rtl::OUString sDeepType = impl_askDetectService(sDetectService, rDescriptor);
- if (!sDeepType.isEmpty())
- return sDeepType;
- }
-
- return ::rtl::OUString();
-}
-
void TypeDetection::impl_seekStreamToZero(comphelper::MediaDescriptor& rDescriptor)
{
// try to seek to 0 ...
diff --git a/filter/source/config/cache/typedetection.hxx b/filter/source/config/cache/typedetection.hxx
index ec41aff39c82..3650842c35dc 100644
--- a/filter/source/config/cache/typedetection.hxx
+++ b/filter/source/config/cache/typedetection.hxx
@@ -153,33 +153,6 @@ private:
//---------------------------------------
- /** @short make a deep type detection only
-
- @descr It steps over all well known deep detection services
- and check her results. The first positive result will be
- used for return. Its more a "try and error" algorithm then
- a real type detection and will be used if a flat detection
- cant work realy ... e.g. if the extension of an URL is
- missing or wrong.
-
- @param rDescriptor
- provides any easy-to-use stl interface to the MediaDescriptor.
- Note : Its content will be adapted to returned result of this method.
- Means: The type/filter entries of it will be actualized or removed from it.
-
- @param rUsedDetectors
- It contains a list of names of all deep detection services,
- which was already used inside the method "impl_detectTypeFlatAndDeep()"!
- Such detectors must be ignored here!
-
- @return The internal name of a detected type.
- An empty value if detection failed.
- */
- ::rtl::OUString impl_detectTypeDeepOnly( ::comphelper::MediaDescriptor& rDescriptor ,
- const OUStringList& rUsedDetectors);
-
- //---------------------------------------
-
/** @short seek a might existing stream to position 0.
@descr This is an optinal action to be more robust