diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-06-05 15:45:52 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-06-05 15:48:13 -0400 |
commit | 3da8f3680556e0163f660a0a159930337c8c32ff (patch) | |
tree | 0f88f0b57f265ce65ad80dfc4cfe125909f84ee7 /sfx2 | |
parent | 32c943e161117e4362ac9246baac2c0fb54e7c79 (diff) |
fdo#50694: Honor the preferred filter returned by type detection.
Because that filter is more reliable.
Change-Id: Ifbab294bf4f344301410cd671a9245bffa03fa11
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/bastyp/fltfnc.cxx | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/sfx2/source/bastyp/fltfnc.cxx b/sfx2/source/bastyp/fltfnc.cxx index fbb253e3b84b..72b35900575e 100644 --- a/sfx2/source/bastyp/fltfnc.cxx +++ b/sfx2/source/bastyp/fltfnc.cxx @@ -433,6 +433,7 @@ sal_uInt32 SfxFilterMatcher::GuessFilterControlDefaultUI( SfxMedium& rMedium, c ::rtl::OUString sURL( rMedium.GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ); ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > xInStream = rMedium.GetInputStream(); + rtl::OUString aFilterName; // stream exists => deep detection (with preselection ... if possible) if (xInStream.is()) @@ -454,6 +455,13 @@ sal_uInt32 SfxFilterMatcher::GuessFilterControlDefaultUI( SfxMedium& rMedium, c ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > lDescriptor = aDescriptor.getAsConstPropertyValueList(); sTypeName = xDetection->queryTypeByDescriptor(lDescriptor, sal_True); // lDescriptor is used as In/Out param ... dont use aDescriptor.getAsConstPropertyValueList() directly! + + for (sal_Int32 i = 0; i < lDescriptor.getLength(); ++i) + { + if (lDescriptor[i].Name == "FilterName") + // Type detection picked a preferred filter for this format. + aFilterName = lDescriptor[i].Value.get<rtl::OUString>(); + } } // no stream exists => try flat detection without preselection as fallback else @@ -461,16 +469,25 @@ sal_uInt32 SfxFilterMatcher::GuessFilterControlDefaultUI( SfxMedium& rMedium, c if (!sTypeName.isEmpty()) { - // detect filter by given type - // In case of this matcher is bound to a particular document type: - // If there is no acceptable type for this document at all, the type detection has possibly returned something else. - // The DocumentService property is only a preselection, and all preselections are considered as optional! - // This "wrong" type will be sorted out now because we match only allowed filters to the detected type - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > lQuery(1); - lQuery[0].Name = ::rtl::OUString("Name"); - lQuery[0].Value <<= sTypeName; - - const SfxFilter* pFilter = GetFilterForProps(lQuery, nMust, nDont); + const SfxFilter* pFilter = NULL; + if (!aFilterName.isEmpty()) + // Type detection returned a suitable filter for this. Use it. + pFilter = SfxFilter::GetFilterByName(aFilterName); + + if (!pFilter) + { + // detect filter by given type + // In case of this matcher is bound to a particular document type: + // If there is no acceptable type for this document at all, the type detection has possibly returned something else. + // The DocumentService property is only a preselection, and all preselections are considered as optional! + // This "wrong" type will be sorted out now because we match only allowed filters to the detected type + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > lQuery(1); + lQuery[0].Name = ::rtl::OUString("Name"); + lQuery[0].Value <<= sTypeName; + + pFilter = GetFilterForProps(lQuery, nMust, nDont); + } + if (pFilter) { *ppFilter = pFilter; |