diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2013-12-30 10:23:00 +0100 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2013-12-31 13:25:47 +0100 |
commit | 6d564bac023ef13955ad0269c91370396cf33d3e (patch) | |
tree | f31debe4f6fecb5f7557d427083602343448be9d /svx | |
parent | svx: Use constructor feature for sidebar::PanelFactory. (diff) | |
download | core-6d564bac023ef13955ad0269c91370396cf33d3e.tar.gz core-6d564bac023ef13955ad0269c91370396cf33d3e.zip |
svx: Use constructor feature for SvXMLGraphicImportExportHelper.
Change-Id: Icc281ece80b81cdd95b6660c6a82077d283f5a62
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/unodraw/unoctabl.cxx | 17 | ||||
-rw-r--r-- | svx/source/xml/xmlgrhlp.cxx | 108 | ||||
-rw-r--r-- | svx/util/svx.component | 8 | ||||
-rw-r--r-- | svx/util/svxcore.component | 10 |
4 files changed, 78 insertions, 65 deletions
diff --git a/svx/source/unodraw/unoctabl.cxx b/svx/source/unodraw/unoctabl.cxx index 085b36f87060..1c4d5cdefc03 100644 --- a/svx/source/unodraw/unoctabl.cxx +++ b/svx/source/unodraw/unoctabl.cxx @@ -27,7 +27,6 @@ #include <svx/xtable.hxx> #include "svx/unoshcol.hxx" #include "recoveryui.hxx" -#include "svx/xmlgrhlp.hxx" #include "tbunocontroller.hxx" #include "tbunosearchcontrollers.hxx" @@ -348,22 +347,6 @@ SAL_DLLPUBLIC_EXPORT void * SAL_CALL svx_component_getFactory ( drawinglayer::primitive2d::XPrimitiveFactory2DProvider_createInstance, drawinglayer::primitive2d::PrimitiveFactory2D::getSupportedServiceNames_Static() ); } - else if( ::svx::SvXMLGraphicImportHelper_getImplementationName().equalsAscii( pImplName ) ) - { - xFactory = ::cppu::createSingleFactory( - reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ), - ::svx::SvXMLGraphicImportHelper_getImplementationName(), - ::svx::SvXMLGraphicImportHelper_createInstance, - ::svx::SvXMLGraphicImportHelper_getSupportedServiceNames() ); - } - else if( ::svx::SvXMLGraphicExportHelper_getImplementationName().equalsAscii( pImplName ) ) - { - xFactory = ::cppu::createSingleFactory( - reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ), - ::svx::SvXMLGraphicExportHelper_getImplementationName(), - ::svx::SvXMLGraphicExportHelper_createInstance, - ::svx::SvXMLGraphicExportHelper_getSupportedServiceNames() ); - } if( xFactory.is()) { diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx index 0509b7c8309e..913ca6cf1d21 100644 --- a/svx/source/xml/xmlgrhlp.cxx +++ b/svx/source/xml/xmlgrhlp.cxx @@ -54,6 +54,8 @@ using ::com::sun::star::lang::XMultiServiceFactory; #define XML_GRAPHICSTORAGE_NAME "Pictures" #define XML_GRAPHICOBJECT_URL_BASE "vnd.sun.star.GraphicObject:" +namespace { + const MetaCommentAction* ImplCheckForEPS( GDIMetaFile& rMtf ) { const MetaCommentAction* pComment = NULL; @@ -346,6 +348,8 @@ const GraphicObject& SvXMLGraphicOutputStream::GetGraphicObject() return maGrfObj; } +} + SvXMLGraphicHelper::SvXMLGraphicHelper( SvXMLGraphicHelperMode eCreateMode ) : ::cppu::WeakComponentImplHelper2< ::com::sun::star::document::XGraphicObjectResolver, ::com::sun::star::document::XBinaryStreamResolver >( maMutex ) @@ -885,8 +889,7 @@ OUString SAL_CALL SvXMLGraphicHelper::resolveOutputStream( const Reference< XOut } // for instantiation via service manager -namespace svx -{ +namespace { namespace impl { @@ -1014,8 +1017,8 @@ OUString SAL_CALL SvXMLGraphicImportExportHelper::getImplementationName() throw (uno::RuntimeException) { if( m_eGraphicHelperMode == GRAPHICHELPER_MODE_READ ) - return SvXMLGraphicImportHelper_getImplementationName(); - return SvXMLGraphicExportHelper_getImplementationName(); + return OUString("com.sun.star.comp.Svx.GraphicImportHelper"); + return OUString("com.sun.star.comp.Svx.GraphicExportHelper"); } ::sal_Bool SAL_CALL SvXMLGraphicImportExportHelper::supportsService( const OUString& ServiceName ) @@ -1027,25 +1030,6 @@ OUString SAL_CALL SvXMLGraphicImportExportHelper::getImplementationName() Sequence< OUString > SAL_CALL SvXMLGraphicImportExportHelper::getSupportedServiceNames() throw (uno::RuntimeException) { - if( m_eGraphicHelperMode == GRAPHICHELPER_MODE_READ ) - return SvXMLGraphicImportHelper_getSupportedServiceNames(); - return SvXMLGraphicExportHelper_getSupportedServiceNames(); -} - -// import -Reference< XInterface > SAL_CALL SvXMLGraphicImportHelper_createInstance(const Reference< XMultiServiceFactory > & /* rSMgr */ ) - throw( Exception ) -{ - return static_cast< XWeak* >( new SvXMLGraphicImportExportHelper( GRAPHICHELPER_MODE_READ )); -} -OUString SAL_CALL SvXMLGraphicImportHelper_getImplementationName() - throw() -{ - return OUString( "com.sun.star.comp.Svx.GraphicImportHelper" ); -} -Sequence< OUString > SAL_CALL SvXMLGraphicImportHelper_getSupportedServiceNames() - throw() -{ // XGraphicObjectResolver and XBinaryStreamResolver are not part of any service Sequence< OUString > aSupportedServiceNames( 2 ); aSupportedServiceNames[0] = "com.sun.star.document.GraphicObjectResolver"; @@ -1053,27 +1037,71 @@ Sequence< OUString > SAL_CALL SvXMLGraphicImportHelper_getSupportedServiceNames( return aSupportedServiceNames; } -// export -Reference< XInterface > SAL_CALL SvXMLGraphicExportHelper_createInstance(const Reference< XMultiServiceFactory > & /* rSMgr */ ) - throw( Exception ) -{ - return static_cast< XWeak* >( new SvXMLGraphicImportExportHelper( GRAPHICHELPER_MODE_WRITE )); } -OUString SAL_CALL SvXMLGraphicExportHelper_getImplementationName() - throw() + +/** Create this with createInstanceWithArguments. service name + "com.sun.star.comp.Svx.GraphicImportHelper", one argument which is the + XStorage. Without arguments no helper class is created. With an empty + argument the helper class is created and initialized like in the CTOR to + SvXMLGraphicHelper that only gets the create mode. + + You should call dispose after you no longer need this component. + + uses eCreateMode == GRAPHICHELPER_MODE_READ, bDirect == sal_True in + SvXMLGraphicHelper + */ +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL +com_sun_star_comp_Svx_GraphicImportHelper_implementation_getFactory( + SAL_UNUSED_PARAMETER css::uno::XComponentContext *, + uno_Sequence * arguments) { - return OUString( "com.sun.star.comp.Svx.GraphicExportHelper" ); + assert(arguments != 0); + css::uno::Reference<css::uno::XInterface> x( + static_cast<cppu::OWeakObject *>(new SvXMLGraphicImportExportHelper( + GRAPHICHELPER_MODE_READ))); + x->acquire(); + css::uno::Reference< css::lang::XInitialization > xx(x, css::uno::UNO_QUERY); + if (xx.is()) + { + css::uno::Sequence<css::uno::Any> aArgs( + reinterpret_cast<css::uno::Any *>(arguments->elements), + arguments->nElements); + xx->initialize(aArgs); + } + return x.get(); } -Sequence< OUString > SAL_CALL SvXMLGraphicExportHelper_getSupportedServiceNames() - throw() + +/** Create this with createInstanceWithArguments. service name + "com.sun.star.comp.Svx.GraphicExportHelper", one argument which is the + XStorage. Without arguments no helper class is created. With an empty + argument the helper class is created and initialized like in the CTOR to + SvXMLGraphicHelper that only gets the create mode + + To write the Pictures stream, you have to call dispose at this component. + Make sure you call dipose before you commit the parent storage. + + uses eCreateMode == GRAPHICHELPER_MODE_WRITE, bDirect == sal_True in + SvXMLGraphicHelper + */ +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL +com_sun_star_comp_Svx_GraphicExportHelper_implementation_getFactory( + SAL_UNUSED_PARAMETER css::uno::XComponentContext *, + uno_Sequence * arguments) { - // XGraphicObjectResolver and XBinaryStreamResolver are not part of any service - Sequence< OUString > aSupportedServiceNames( 2 ); - aSupportedServiceNames[0] = "com.sun.star.document.GraphicObjectResolver"; - aSupportedServiceNames[1] = "com.sun.star.document.BinaryStreamResolver"; - return aSupportedServiceNames; + assert(arguments != 0); + css::uno::Reference<css::uno::XInterface> x( + static_cast<cppu::OWeakObject *>(new SvXMLGraphicImportExportHelper( + GRAPHICHELPER_MODE_WRITE ))); + x->acquire(); + css::uno::Reference< css::lang::XInitialization > xx(x, css::uno::UNO_QUERY); + if (xx.is()) + { + css::uno::Sequence<css::uno::Any> aArgs( + reinterpret_cast<css::uno::Any *>(arguments->elements), + arguments->nElements); + xx->initialize(aArgs); + } + return x.get(); } -} // namespace svx - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/util/svx.component b/svx/util/svx.component index f087dcb833df..b8f043c8631c 100644 --- a/svx/util/svx.component +++ b/svx/util/svx.component @@ -22,14 +22,6 @@ <implementation name="com.sun.star.comp.Draw.GraphicExporter"> <service name="com.sun.star.drawing.GraphicExportFilter"/> </implementation> - <implementation name="com.sun.star.comp.Svx.GraphicExportHelper"> - <service name="com.sun.star.document.BinaryStreamResolver"/> - <service name="com.sun.star.document.GraphicObjectResolver"/> - </implementation> - <implementation name="com.sun.star.comp.Svx.GraphicImportHelper"> - <service name="com.sun.star.document.BinaryStreamResolver"/> - <service name="com.sun.star.document.GraphicObjectResolver"/> - </implementation> <implementation name="com.sun.star.comp.gallery.GalleryThemeProvider"> <service name="com.sun.star.gallery.GalleryThemeProvider"/> </implementation> diff --git a/svx/util/svxcore.component b/svx/util/svxcore.component index 3a9d43c229f9..8d4e1498fef0 100644 --- a/svx/util/svxcore.component +++ b/svx/util/svxcore.component @@ -36,4 +36,14 @@ <implementation name="com.sun.star.comp.svx.FontworkCharacterSpacingController"> <service name="com.sun.star.frame.ToolbarController"/> </implementation> + <implementation name="com.sun.star.comp.Svx.GraphicExportHelper" + constructor="com_sun_star_comp_Svx_GraphicExportHelper_implementation_getFactory"> + <service name="com.sun.star.document.BinaryStreamResolver"/> + <service name="com.sun.star.document.GraphicObjectResolver"/> + </implementation> + <implementation name="com.sun.star.comp.Svx.GraphicImportHelper" + constructor="com_sun_star_comp_Svx_GraphicImportHelper_implementation_getFactory"> + <service name="com.sun.star.document.BinaryStreamResolver"/> + <service name="com.sun.star.document.GraphicObjectResolver"/> + </implementation> </component> |