summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-05-24 21:14:40 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-05-25 02:04:17 -0400
commitcc0b7db44ea58f9395d0d89a0f2bdac32a272eb7 (patch)
treecf9b4b8cd3cadbd96354b3f64db5e118d608fbcd /filter
parent405ed562c9fa19d9fcf71e426739fcb022f9719e (diff)
Prioritize candidate types by extension first, then by document service.
This unfortunately breaks plain text format detection for writer, but I'll get to that next. Change-Id: I70382529596dbc3e3af4935d6e98ad6d58bb4d91
Diffstat (limited to 'filter')
-rw-r--r--filter/source/config/cache/typedetection.cxx20
1 files changed, 20 insertions, 0 deletions
diff --git a/filter/source/config/cache/typedetection.cxx b/filter/source/config/cache/typedetection.cxx
index 0b7a8874a97f..cac9b1456f72 100644
--- a/filter/source/config/cache/typedetection.cxx
+++ b/filter/source/config/cache/typedetection.cxx
@@ -106,7 +106,24 @@ TypeDetection::~TypeDetection()
// <- SAFE
}
+namespace {
+/**
+ * Types with matching extension come first, then types that are supported
+ * by the document service come next.
+ */
+struct SortByPriority : public std::binary_function<FlatDetectionInfo, FlatDetectionInfo, bool>
+{
+ bool operator() (const FlatDetectionInfo& r1, const FlatDetectionInfo& r2) const
+ {
+ if (r1.bMatchByExtension != r2.bMatchByExtension)
+ return r1.bMatchByExtension;
+
+ return r1.bPreselectedByDocumentService;
+ }
+};
+
+}
::rtl::OUString SAL_CALL TypeDetection::queryTypeByDescriptor(css::uno::Sequence< css::beans::PropertyValue >& lDescriptor,
sal_Bool bAllowDeep )
@@ -155,6 +172,9 @@ TypeDetection::~TypeDetection()
aLock.clear();
// <- SAFE ----------------------------------
+ // Properly prioritize all candidate types.
+ lFlatTypes.sort(SortByPriority());
+
::rtl::OUString sType ;
::rtl::OUString sLastChance;