Kaydet (Commit) cc0b7db4 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

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
üst 405ed562
...@@ -106,7 +106,24 @@ TypeDetection::~TypeDetection() ...@@ -106,7 +106,24 @@ TypeDetection::~TypeDetection()
// <- SAFE // <- 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, ::rtl::OUString SAL_CALL TypeDetection::queryTypeByDescriptor(css::uno::Sequence< css::beans::PropertyValue >& lDescriptor,
sal_Bool bAllowDeep ) sal_Bool bAllowDeep )
...@@ -155,6 +172,9 @@ TypeDetection::~TypeDetection() ...@@ -155,6 +172,9 @@ TypeDetection::~TypeDetection()
aLock.clear(); aLock.clear();
// <- SAFE ---------------------------------- // <- SAFE ----------------------------------
// Properly prioritize all candidate types.
lFlatTypes.sort(SortByPriority());
::rtl::OUString sType ; ::rtl::OUString sType ;
::rtl::OUString sLastChance; ::rtl::OUString sLastChance;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment