desktop/source/app/dispatchwatcher.cxx | 50 +++++++++------------------------ 1 file changed, 15 insertions(+), 35 deletions(-)
New commits: commit 9df3a83c304f3dd0e0233d234dc6036ab5eefb77 Author: Maxim Monastirsky <momonas...@gmail.com> Date: Thu Aug 21 22:01:19 2014 +0300 Base the convert-to detection on the actual service There is no need to run a type detection on the input file (for a second time!), just to get the document service. This also simplifies the conversion of some generic formats like HTML and RTF, using Calc export filters. Previously setting both input and output filters was required. Now it's enough to set the input filter, or simply use --calc. Change-Id: I825e0fe3e7368d6649acb434b13de53a4523064a diff --git a/desktop/source/app/dispatchwatcher.cxx b/desktop/source/app/dispatchwatcher.cxx index 318fe67..f26d17c 100644 --- a/desktop/source/app/dispatchwatcher.cxx +++ b/desktop/source/app/dispatchwatcher.cxx @@ -151,41 +151,14 @@ catch ( const Exception& ) return 0; } - -static OUString impl_GetFilterFromExt( const OUString& aUrl, SfxFilterFlags nFlags, - const OUString& aAppl ) +OUString impl_GuessFilter( const OUString& rUrlOut, const OUString& rDocService ) { - OUString aFilter; - SfxMedium* pMedium = new SfxMedium( aUrl, - STREAM_STD_READ ); - - const SfxFilter *pSfxFilter = NULL; - if( nFlags == SFX_FILTER_EXPORT ) - { - pSfxFilter = impl_getExportFilterFromUrl( aUrl, aAppl ); - } - else - { - SfxGetpApp()->GetFilterMatcher().GuessFilter( *pMedium, &pSfxFilter, nFlags ); - } - - if( pSfxFilter ) - { - if (nFlags == SFX_FILTER_EXPORT) - aFilter = pSfxFilter->GetFilterName(); - else - aFilter = pSfxFilter->GetServiceName(); - } + OUString aOutFilter; + const SfxFilter* pOutFilter = impl_getExportFilterFromUrl( rUrlOut, rDocService ); + if (pOutFilter) + aOutFilter = pOutFilter->GetFilterName(); - delete pMedium; - return aFilter; -} -static OUString impl_GuessFilter( const OUString& aUrlIn, const OUString& aUrlOut ) -{ - /* aAppl can also be set to Factory like scalc, swriter... */ - OUString aAppl; - aAppl = impl_GetFilterFromExt( aUrlIn, SFX_FILTER_IMPORT, aAppl ); - return impl_GetFilterFromExt( aUrlOut, SFX_FILTER_EXPORT, aAppl ); + return aOutFilter; } } @@ -545,7 +518,14 @@ bool DispatchWatcher::executeDispatchRequests( const DispatchList& aDispatchRequ if ( bGuess ) { - aFilter = impl_GuessFilter( aName, aOutFile ); + OUString aDocService; + Reference< XModel > xModel( xDoc, UNO_QUERY ); + if ( xModel.is() ) + { + utl::MediaDescriptor aMediaDesc( xModel->getArgs() ); + aDocService = aMediaDesc.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_DOCUMENTSERVICE(), OUString() ); + } + aFilter = impl_GuessFilter( aOutFile, aDocService ); } sal_Int32 nFilterOptionsIndex = aFilter.indexOf( ':' ); commit cebfcbd456ddfbd7291c85c6a6c329df165ccd3c Author: Maxim Monastirsky <momonas...@gmail.com> Date: Thu Aug 21 22:47:52 2014 +0300 Better to use an instance with a doc service specified ...to avoid detection of filter from other services, and to additionally check for filters other than the preferred by the type (see SfxFilterMatcher::GetFilterForProps). Change-Id: I64609b32f6aac7553b4b6b96db88acfcad0ce000 diff --git a/desktop/source/app/dispatchwatcher.cxx b/desktop/source/app/dispatchwatcher.cxx index eba914d..318fe67 100644 --- a/desktop/source/app/dispatchwatcher.cxx +++ b/desktop/source/app/dispatchwatcher.cxx @@ -135,7 +135,7 @@ const SfxFilter* impl_getExportFilterFromUrl( const rtl::OUString& rUrl, const r UNO_QUERY_THROW ); const rtl::OUString aTypeName( xTypeDetector->queryTypeByURL( rUrl ) ); - const SfxFilter* pFilter( SfxGetpApp()->GetFilterMatcher().GetFilter4EA( aTypeName, SFX_FILTER_EXPORT ) ); + const SfxFilter* pFilter( SfxFilterMatcher( rFactory ).GetFilter4EA( aTypeName, SFX_FILTER_EXPORT ) ); if ( !pFilter ) pFilter = impl_lookupExportFilterForUrl( rUrl, rFactory ); if ( !pFilter ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits