summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2014-08-21 22:01:19 +0300
committerMaxim Monastirsky <momonasmon@gmail.com>2014-08-22 00:02:06 +0300
commit9df3a83c304f3dd0e0233d234dc6036ab5eefb77 (patch)
treef5a4847ebdd189f799e8bac724a908a28919d85a
parentcebfcbd456ddfbd7291c85c6a6c329df165ccd3c (diff)
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
-rw-r--r--desktop/source/app/dispatchwatcher.cxx48
1 files changed, 14 insertions, 34 deletions
diff --git a/desktop/source/app/dispatchwatcher.cxx b/desktop/source/app/dispatchwatcher.cxx
index 318fe67f5345..f26d17c6bcbf 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( ':' );