diff options
author | Noel Grandin <noel@peralex.com> | 2013-03-19 15:46:25 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2013-03-20 07:32:52 +0200 |
commit | c09c64ede6a395ad4cc5a263e88d5e180b890127 (patch) | |
tree | 2ddcf5b0e6a7ad8e53579237b2fa5d52b5cf16a7 /sd | |
parent | 23a16f5d3856d6eb61d599af9e47add4c456bfb2 (diff) |
fdo#46808, convert drawing::GraphicExportFilter to new style
Change-Id: Icd456209406ee8f4dc4ea1f966058f71dce08d58
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/filter/grf/sdgrffilter.cxx | 179 | ||||
-rw-r--r-- | sd/source/filter/html/htmlex.cxx | 15 | ||||
-rw-r--r-- | sd/source/ui/remotecontrol/ImagePreparer.cxx | 16 |
3 files changed, 92 insertions, 118 deletions
diff --git a/sd/source/filter/grf/sdgrffilter.cxx b/sd/source/filter/grf/sdgrffilter.cxx index 8a4ac2f07197..e8df14893f61 100644 --- a/sd/source/filter/grf/sdgrffilter.cxx +++ b/sd/source/filter/grf/sdgrffilter.cxx @@ -21,6 +21,7 @@ #ifdef _MSC_VER #pragma warning (disable:4190) #endif +#include <com/sun/star/drawing/GraphicExportFilter.hpp> #include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <com/sun/star/graphic/GraphicType.hpp> @@ -255,112 +256,100 @@ sal_Bool SdGRFFilter::Export() sal_Bool bRet = sal_False; - uno::Reference< lang::XMultiServiceFactory > - xSMgr( ::comphelper::getProcessServiceFactory() ); - uno::Reference< uno::XInterface > xComponent - ( xSMgr->createInstance( "com.sun.star.drawing.GraphicExportFilter" ), - uno::UNO_QUERY ); - if ( xComponent.is() ) - { - uno::Reference< document::XExporter > xExporter - ( xComponent, uno::UNO_QUERY ); - uno::Reference< document::XFilter > xFilter - ( xComponent, uno::UNO_QUERY ); - if ( xExporter.is() && xFilter.is() ) - { - SdPage* pPage = NULL; - sd::DrawViewShell* pDrawViewShell = static_cast< ::sd::DrawViewShell* > - ( ( ( mrDocShell.GetViewShell() && mrDocShell.GetViewShell()->ISA(::sd::DrawViewShell ) ) ? mrDocShell.GetViewShell() : NULL ) ); + uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); + uno::Reference< drawing::XGraphicExportFilter > xExporter = drawing::GraphicExportFilter::create( xContext ); - PageKind ePageKind = PK_STANDARD; - if( pDrawViewShell ) - { - ePageKind = pDrawViewShell->GetPageKind(); - if( PK_HANDOUT == ePageKind ) - pPage = mrDocument.GetSdPage( 0, PK_HANDOUT ); - else - pPage = pDrawViewShell->GetActualPage(); - } - else - pPage = mrDocument.GetSdPage( 0, PK_STANDARD ); + SdPage* pPage = NULL; + sd::DrawViewShell* pDrawViewShell = static_cast< ::sd::DrawViewShell* > + ( ( ( mrDocShell.GetViewShell() && mrDocShell.GetViewShell()->ISA(::sd::DrawViewShell ) ) ? mrDocShell.GetViewShell() : NULL ) ); + + PageKind ePageKind = PK_STANDARD; + if( pDrawViewShell ) + { + ePageKind = pDrawViewShell->GetPageKind(); + if( PK_HANDOUT == ePageKind ) + pPage = mrDocument.GetSdPage( 0, PK_HANDOUT ); + else + pPage = pDrawViewShell->GetActualPage(); + } + else + pPage = mrDocument.GetSdPage( 0, PK_STANDARD ); - if ( pPage ) + if ( pPage ) + { + // taking the 'correct' page number, seems that there might exist a better method to archive this + pPage = mrDocument.GetSdPage( pPage->GetPageNum() ? ( pPage->GetPageNum() - 1 ) >> 1 : 0, ePageKind ); + if ( pPage ) + { + uno::Reference< lang::XComponent > xSource( pPage->getUnoPage(), uno::UNO_QUERY ); + SfxItemSet* pSet = mrMedium.GetItemSet(); + if ( pSet && xSource.is() ) { - // taking the 'correct' page number, seems that there might exist a better method to archive this - pPage = mrDocument.GetSdPage( pPage->GetPageNum() ? ( pPage->GetPageNum() - 1 ) >> 1 : 0, ePageKind ); - if ( pPage ) + const String aTypeName( mrMedium.GetFilter()->GetTypeName() ); + GraphicFilter &rGraphicFilter = GraphicFilter::GetGraphicFilter(); + const sal_uInt16 nFilter = rGraphicFilter.GetExportFormatNumberForTypeName( aTypeName ); + if ( nFilter != GRFILTER_FORMAT_NOTFOUND ) { - uno::Reference< lang::XComponent > xSource( pPage->getUnoPage(), uno::UNO_QUERY ); - SfxItemSet* pSet = mrMedium.GetItemSet(); - if ( pSet && xSource.is() ) - { - const String aTypeName( mrMedium.GetFilter()->GetTypeName() ); - GraphicFilter &rGraphicFilter = GraphicFilter::GetGraphicFilter(); - const sal_uInt16 nFilter = rGraphicFilter.GetExportFormatNumberForTypeName( aTypeName ); - if ( nFilter != GRFILTER_FORMAT_NOTFOUND ) - { - uno::Reference< task::XInteractionHandler > mXInteractionHandler; + uno::Reference< task::XInteractionHandler > mXInteractionHandler; - beans::PropertyValues aArgs; - TransformItems( SID_SAVEASDOC, *pSet, aArgs ); + beans::PropertyValues aArgs; + TransformItems( SID_SAVEASDOC, *pSet, aArgs ); - rtl::OUString sInteractionHandler( "InteractionHandler" ); - rtl::OUString sFilterName( "FilterName" ); - rtl::OUString sShortName( rGraphicFilter.GetExportFormatShortName( nFilter ) ); + rtl::OUString sInteractionHandler( "InteractionHandler" ); + rtl::OUString sFilterName( "FilterName" ); + rtl::OUString sShortName( rGraphicFilter.GetExportFormatShortName( nFilter ) ); - sal_Bool bFilterNameFound = sal_False; - sal_Int32 i, nCount; - for ( i = 0, nCount = aArgs.getLength(); i < nCount; i++ ) - { - rtl::OUString& rStr = aArgs[ i ].Name; - if ( rStr == sFilterName ) - { - bFilterNameFound = sal_True; - aArgs[ i ].Name = sFilterName; - aArgs[ i ].Value <<= sShortName; - } - else if ( rStr == sInteractionHandler ) - { - uno::Reference< task::XInteractionHandler > xHdl; - if ( aArgs[ i ].Value >>= xHdl ) - { - mXInteractionHandler = new SdGRFFilter_ImplInteractionHdl( xHdl ); - aArgs[ i ].Value <<= mXInteractionHandler; - } - } - } - if ( !bFilterNameFound ) - { - aArgs.realloc( ++nCount ); - aArgs[ i ].Name = sFilterName; - aArgs[ i ].Value <<= sShortName; - } - - // take selection if needed - if( ( SFX_ITEM_SET == pSet->GetItemState( SID_SELECTION ) ) - && static_cast< const SfxBoolItem& >( pSet->Get( SID_SELECTION ) ).GetValue() - && pDrawViewShell ) + sal_Bool bFilterNameFound = sal_False; + sal_Int32 i, nCount; + for ( i = 0, nCount = aArgs.getLength(); i < nCount; i++ ) + { + rtl::OUString& rStr = aArgs[ i ].Name; + if ( rStr == sFilterName ) + { + bFilterNameFound = sal_True; + aArgs[ i ].Name = sFilterName; + aArgs[ i ].Value <<= sShortName; + } + else if ( rStr == sInteractionHandler ) + { + uno::Reference< task::XInteractionHandler > xHdl; + if ( aArgs[ i ].Value >>= xHdl ) { - uno::Reference< view::XSelectionSupplier > xSelectionSupplier( - pDrawViewShell->GetViewShellBase().GetController(), uno::UNO_QUERY ); - if ( xSelectionSupplier.is() ) - { - uno::Any aSelection( xSelectionSupplier->getSelection() ); - uno::Reference< lang::XComponent > xSelection; - if ( aSelection >>= xSelection ) - xSource = xSelection; - } + mXInteractionHandler = new SdGRFFilter_ImplInteractionHdl( xHdl ); + aArgs[ i ].Value <<= mXInteractionHandler; } - xExporter->setSourceDocument( xSource ); - bRet = xFilter->filter( aArgs ); - if ( !bRet && mXInteractionHandler.is() ) - SdGRFFilter::HandleGraphicFilterError( - static_cast< SdGRFFilter_ImplInteractionHdl* >( mXInteractionHandler.get() )->GetErrorCode(), - rGraphicFilter.GetLastError().nStreamError ); } - } + } + if ( !bFilterNameFound ) + { + aArgs.realloc( ++nCount ); + aArgs[ i ].Name = sFilterName; + aArgs[ i ].Value <<= sShortName; + } + + // take selection if needed + if( ( SFX_ITEM_SET == pSet->GetItemState( SID_SELECTION ) ) + && static_cast< const SfxBoolItem& >( pSet->Get( SID_SELECTION ) ).GetValue() + && pDrawViewShell ) + { + uno::Reference< view::XSelectionSupplier > xSelectionSupplier( + pDrawViewShell->GetViewShellBase().GetController(), uno::UNO_QUERY ); + if ( xSelectionSupplier.is() ) + { + uno::Any aSelection( xSelectionSupplier->getSelection() ); + uno::Reference< lang::XComponent > xSelection; + if ( aSelection >>= xSelection ) + xSource = xSelection; + } + } + xExporter->setSourceDocument( xSource ); + bRet = xExporter->filter( aArgs ); + if ( !bRet && mXInteractionHandler.is() ) + SdGRFFilter::HandleGraphicFilterError( + static_cast< SdGRFFilter_ImplInteractionHdl* >( mXInteractionHandler.get() )->GetErrorCode(), + rGraphicFilter.GetLastError().nStreamError ); } - } + } } } return bRet; diff --git a/sd/source/filter/html/htmlex.cxx b/sd/source/filter/html/htmlex.cxx index 92690d0ccb57..c05ed5d2d79c 100644 --- a/sd/source/filter/html/htmlex.cxx +++ b/sd/source/filter/html/htmlex.cxx @@ -20,8 +20,8 @@ #include "htmlex.hxx" #include <com/sun/star/document/XExporter.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/document/XFilter.hpp> +#include <com/sun/star/drawing/GraphicExportFilter.hpp> #include <com/sun/star/ucb/SimpleFileAccess.hpp> #include <rtl/uri.hxx> @@ -966,16 +966,9 @@ bool HtmlExport::CreateImagesForPresPages( bool bThumbnail) { try { - Reference < XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() ); - if( !xMSF.is() ) - return false; - - Reference< XExporter > xGraphicExporter( xMSF->createInstance( "com.sun.star.drawing.GraphicExportFilter" ), UNO_QUERY ); - Reference< XFilter > xFilter( xGraphicExporter, UNO_QUERY ); + Reference < XComponentContext > xContext = ::comphelper::getProcessComponentContext(); - DBG_ASSERT( xFilter.is(), "no com.sun.star.drawing.GraphicExportFilter?" ); - if( !xFilter.is() ) - return false; + Reference< drawing::XGraphicExportFilter > xGraphicExporter = drawing::GraphicExportFilter::create( xContext ); Sequence< PropertyValue > aFilterData(((meFormat==FORMAT_JPG)&&(mnCompression != -1))? 3 : 2); aFilterData[0].Name = "PixelWidth"; @@ -1018,7 +1011,7 @@ bool HtmlExport::CreateImagesForPresPages( bool bThumbnail) Reference< XComponent > xPage( pPage->getUnoPage(), UNO_QUERY ); xGraphicExporter->setSourceDocument( xPage ); - xFilter->filter( aDescriptor ); + xGraphicExporter->filter( aDescriptor ); if (mpProgress) mpProgress->SetState(++mnPagesWritten); diff --git a/sd/source/ui/remotecontrol/ImagePreparer.cxx b/sd/source/ui/remotecontrol/ImagePreparer.cxx index 2c6ca5bce558..e9f9c22d9099 100644 --- a/sd/source/ui/remotecontrol/ImagePreparer.cxx +++ b/sd/source/ui/remotecontrol/ImagePreparer.cxx @@ -34,6 +34,7 @@ #include <com/sun/star/document/XFilter.hpp> #include <com/sun/star/document/XImporter.hpp> #include <com/sun/star/document/XExporter.hpp> +#include <com/sun/star/drawing/GraphicExportFilter.hpp> #include <com/sun/star/lang/XServiceName.hpp> #include <com/sun/star/presentation/XPresentationPage.hpp> #include <com/sun/star/text/XTextRange.hpp> @@ -113,17 +114,8 @@ uno::Sequence<sal_Int8> ImagePreparer::preparePreview( OUString aFileURL; FileBase::createTempFile( 0, 0, &aFileURL ); - uno::Reference< lang::XMultiServiceFactory > xServiceManager( - ::comphelper::getProcessServiceFactory(), - uno::UNO_QUERY_THROW ); - - uno::Reference< document::XFilter > xFilter( - xServiceManager->createInstance( - "com.sun.star.drawing.GraphicExportFilter" ) , - uno::UNO_QUERY_THROW ); - - uno::Reference< document::XExporter > xExporter( xFilter, - uno::UNO_QUERY_THROW ); + uno::Reference< drawing::XGraphicExportFilter > xFilter = + drawing::GraphicExportFilter::create( ::comphelper::getProcessComponentContext() ); if ( !xController->isRunning() ) return uno::Sequence<sal_Int8>(); @@ -132,7 +124,7 @@ uno::Sequence<sal_Int8> ImagePreparer::preparePreview( xController->getSlideByIndex( aSlideNumber ), uno::UNO_QUERY_THROW ); - xExporter->setSourceDocument( xSourceDoc ); + xFilter->setSourceDocument( xSourceDoc ); uno::Sequence< beans::PropertyValue > aFilterData(3); |