Kaydet (Commit) a16bf89a authored tarafından Matúš Kukan's avatar Matúš Kukan

sfx: Use constructor feature for SfxFrameLoader_Impl.

Change-Id: If0e20538b85057c52a953a7559f6e7cb75d2fe33
üst 44592540
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_SFX2_INC_FRMLOAD_HXX
#define INCLUDED_SFX2_INC_FRMLOAD_HXX
#include <sfx2/sfxuno.hxx>
#include <sfx2/objsh.hxx>
#include <com/sun/star/frame/XLoadEventListener.hpp>
#include <com/sun/star/frame/XSynchronousFrameLoader.hpp>
#include <com/sun/star/frame/XController2.hpp>
#include <com/sun/star/frame/XModel2.hpp>
#include <com/sun/star/document/XExtendedFilterDetection.hpp>
#include <com/sun/star/uno/Exception.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/task/XInteractionHandler.hpp>
#include <rtl/ustring.hxx>
#include <cppuhelper/implbase1.hxx>
#include <cppuhelper/implbase2.hxx>
#include <cppuhelper/implbase3.hxx>
#include <cppuhelper/factory.hxx>
#include <comphelper/namedvaluecollection.hxx>
class SfxFilter;
class SfxFilterMatcher;
class SAL_DLLPRIVATE SfxFrameLoader_Impl : public ::cppu::WeakImplHelper2< ::com::sun::star::frame::XSynchronousFrameLoader, ::com::sun::star::lang::XServiceInfo >
{
::com::sun::star::uno::Reference < ::com::sun::star::uno::XComponentContext > m_aContext;
public:
SfxFrameLoader_Impl( const ::com::sun::star::uno::Reference < ::com::sun::star::uno::XComponentContext >& _rxContext );
SFX_DECL_XSERVICEINFO
//----------------------------------------------------------------------------------
// XSynchronousFrameLoader
//----------------------------------------------------------------------------------
virtual sal_Bool SAL_CALL load( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rArgs, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxFrame ) throw( ::com::sun::star::uno::RuntimeException );
virtual void SAL_CALL cancel() throw( ::com::sun::star::uno::RuntimeException );
protected:
virtual ~SfxFrameLoader_Impl();
private:
const SfxFilter* impl_getFilterFromServiceName_nothrow(
const OUString& i_rServiceName
) const;
OUString impl_askForFilter_nothrow(
const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& i_rxHandler,
const OUString& i_rDocumentURL
) const;
const SfxFilter* impl_detectFilterForURL(
const OUString& _rURL,
const ::comphelper::NamedValueCollection& i_rDescriptor,
const SfxFilterMatcher& rMatcher
) const;
sal_Bool impl_createNewDocWithSlotParam(
const sal_uInt16 _nSlotID,
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rxFrame,
const bool i_bHidden
);
void impl_determineFilter(
::comphelper::NamedValueCollection& io_rDescriptor
) const;
bool impl_determineTemplateDocument(
::comphelper::NamedValueCollection& io_rDescriptor
) const;
sal_uInt16 impl_findSlotParam(
const OUString& i_rFactoryURL
) const;
SfxObjectShellRef impl_findObjectShell(
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel2 >& i_rxDocument
) const;
void impl_lockHiddenDocument(
SfxObjectShell& i_rDocument,
const ::comphelper::NamedValueCollection& i_rDescriptor
) const;
void impl_handleCaughtError_nothrow(
const ::com::sun::star::uno::Any& i_rCaughtError,
const ::comphelper::NamedValueCollection& i_rDescriptor
) const;
void impl_removeLoaderArguments(
::comphelper::NamedValueCollection& io_rDescriptor
);
sal_Int16 impl_determineEffectiveViewId_nothrow(
const SfxObjectShell& i_rDocument,
const ::comphelper::NamedValueCollection& i_rDescriptor
);
::comphelper::NamedValueCollection
impl_extractViewCreationArgs(
::comphelper::NamedValueCollection& io_rDescriptor
);
::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >
impl_createDocumentView(
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel2 >& i_rModel,
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame,
const ::comphelper::NamedValueCollection& i_rViewFactoryArgs,
const OUString& i_rViewName
);
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -28,8 +28,7 @@ ...@@ -28,8 +28,7 @@
#include <com/sun/star/frame/XDesktop.hpp> #include <com/sun/star/frame/XDesktop.hpp>
#include <com/sun/star/frame/XFramesSupplier.hpp> #include <com/sun/star/frame/XFramesSupplier.hpp>
#include <com/sun/star/frame/XLayoutManager.hpp> #include <com/sun/star/frame/XLayoutManager.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/frame/XSynchronousFrameLoader.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <com/sun/star/sdbc/DriverManager.hpp> #include <com/sun/star/sdbc/DriverManager.hpp>
#include <com/sun/star/system/SystemShellExecute.hpp> #include <com/sun/star/system/SystemShellExecute.hpp>
#include <com/sun/star/system/SystemShellExecuteFlags.hpp> #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
...@@ -82,7 +81,6 @@ ...@@ -82,7 +81,6 @@
#include <com/sun/star/frame/ModuleManager.hpp> #include <com/sun/star/frame/ModuleManager.hpp>
#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertySet.hpp>
#include "frmload.hxx"
#include <sfx2/app.hxx> #include <sfx2/app.hxx>
#include <sfx2/request.hxx> #include <sfx2/request.hxx>
#include <sfx2/dispatch.hxx> #include <sfx2/dispatch.hxx>
...@@ -1091,7 +1089,7 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) ...@@ -1091,7 +1089,7 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq )
// mechanism, and the type detection (which doesn't know about the Basic IDE). // mechanism, and the type detection (which doesn't know about the Basic IDE).
Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
Reference< XSynchronousFrameLoader > xLoader( Reference< XSynchronousFrameLoader > xLoader(
xContext->getServiceManager()->createInstanceWithContext(SfxFrameLoader_Impl::impl_getStaticImplementationName(), xContext), xContext->getServiceManager()->createInstanceWithContext("com.sun.star.comp.office.FrameLoader", xContext),
UNO_QUERY_THROW ); UNO_QUERY_THROW );
::comphelper::NamedValueCollection aLoadArgs; ::comphelper::NamedValueCollection aLoadArgs;
aLoadArgs.put( "Model", pBasicIDE->GetModel() ); aLoadArgs.put( "Model", pBasicIDE->GetModel() );
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include "backingcomp.hxx" #include "backingcomp.hxx"
#include "SfxDocumentMetaData.hxx" #include "SfxDocumentMetaData.hxx"
#include "fltoptint.hxx" #include "fltoptint.hxx"
#include "frmload.hxx"
#include "objshimp.hxx" #include "objshimp.hxx"
#include <sfx2/app.hxx> #include <sfx2/app.hxx>
#include <sfx2/brokenpackageint.hxx> #include <sfx2/brokenpackageint.hxx>
...@@ -1796,7 +1795,6 @@ SFX2_DLLPUBLIC void* SAL_CALL sfx_component_getFactory( ...@@ -1796,7 +1795,6 @@ SFX2_DLLPUBLIC void* SAL_CALL sfx_component_getFactory(
// Write no ";" at end of line and dont forget "else" ! (see macro) // Write no ";" at end of line and dont forget "else" ! (see macro)
//============================================================================= //=============================================================================
IF_NAME_CREATECOMPONENTFACTORY( BackingComp ) IF_NAME_CREATECOMPONENTFACTORY( BackingComp )
IF_NAME_CREATECOMPONENTFACTORY( SfxFrameLoader_Impl )
IF_NAME_CREATECOMPONENTFACTORY( ShutdownIcon ) IF_NAME_CREATECOMPONENTFACTORY( ShutdownIcon )
#ifdef TEST_HANDLERS #ifdef TEST_HANDLERS
IF_NAME_CREATECOMPONENTFACTORY( TestKeyHandler ) IF_NAME_CREATECOMPONENTFACTORY( TestKeyHandler )
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include <sal/macros.h> #include <sal/macros.h>
#include "frmload.hxx"
#include "objshimp.hxx" #include "objshimp.hxx"
#include <sfx2/app.hxx> #include <sfx2/app.hxx>
#include <sfx2/dispatch.hxx> #include <sfx2/dispatch.hxx>
...@@ -29,6 +28,7 @@ ...@@ -29,6 +28,7 @@
#include <sfx2/doctempl.hxx> #include <sfx2/doctempl.hxx>
#include <sfx2/fcontnr.hxx> #include <sfx2/fcontnr.hxx>
#include <sfx2/frame.hxx> #include <sfx2/frame.hxx>
#include <sfx2/objsh.hxx>
#include <sfx2/request.hxx> #include <sfx2/request.hxx>
#include <sfx2/sfx.hrc> #include <sfx2/sfx.hrc>
#include <sfx2/sfxsids.hrc> #include <sfx2/sfxsids.hrc>
...@@ -42,17 +42,22 @@ ...@@ -42,17 +42,22 @@
#include <com/sun/star/frame/XFrame.hpp> #include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/frame/XLoadable.hpp> #include <com/sun/star/frame/XLoadable.hpp>
#include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/task/XInteractionHandler.hpp>
#include <com/sun/star/task/XInteractionHandler2.hpp> #include <com/sun/star/task/XInteractionHandler2.hpp>
#include <com/sun/star/document/XViewDataSupplier.hpp> #include <com/sun/star/document/XViewDataSupplier.hpp>
#include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/frame/XSynchronousFrameLoader.hpp>
#include <com/sun/star/frame/XController2.hpp>
#include <com/sun/star/frame/XModel2.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <comphelper/interaction.hxx> #include <comphelper/interaction.hxx>
#include <comphelper/namedvaluecollection.hxx> #include <comphelper/namedvaluecollection.hxx>
#include <comphelper/sequenceashashmap.hxx>
#include <comphelper/processfactory.hxx>
#include <cppuhelper/exc_hlp.hxx> #include <cppuhelper/exc_hlp.hxx>
#include <cppuhelper/implbase2.hxx>
#include <cppuhelper/supportsservice.hxx> #include <cppuhelper/supportsservice.hxx>
#include <framework/interaction.hxx> #include <framework/interaction.hxx>
#include <rtl/ref.hxx>
#include <rtl/ustring.h> #include <rtl/ustring.h>
#include <sot/storinfo.hxx> #include <sot/storinfo.hxx>
#include <svtools/ehdl.hxx> #include <svtools/ehdl.hxx>
...@@ -87,7 +92,6 @@ using ::com::sun::star::uno::UNO_QUERY; ...@@ -87,7 +92,6 @@ using ::com::sun::star::uno::UNO_QUERY;
using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::uno::UNO_QUERY_THROW;
using ::com::sun::star::uno::UNO_SET_THROW; using ::com::sun::star::uno::UNO_SET_THROW;
using ::com::sun::star::uno::makeAny; using ::com::sun::star::uno::makeAny;
using ::com::sun::star::uno::XComponentContext;
using ::com::sun::star::util::XCloseable; using ::com::sun::star::util::XCloseable;
using ::com::sun::star::document::XViewDataSupplier; using ::com::sun::star::document::XViewDataSupplier;
using ::com::sun::star::container::XIndexAccess; using ::com::sun::star::container::XIndexAccess;
...@@ -95,7 +99,105 @@ using ::com::sun::star::frame::XController2; ...@@ -95,7 +99,105 @@ using ::com::sun::star::frame::XController2;
using ::com::sun::star::frame::XController; using ::com::sun::star::frame::XController;
using ::com::sun::star::frame::XModel2; using ::com::sun::star::frame::XModel2;
SfxFrameLoader_Impl::SfxFrameLoader_Impl( const Reference< XComponentContext >& _rxContext ) namespace {
class SfxFrameLoader_Impl : public ::cppu::WeakImplHelper2< css::frame::XSynchronousFrameLoader, css::lang::XServiceInfo >
{
css::uno::Reference < css::uno::XComponentContext > m_aContext;
public:
SfxFrameLoader_Impl( const css::uno::Reference < css::uno::XComponentContext >& _rxContext );
virtual OUString SAL_CALL getImplementationName()
throw (css::uno::RuntimeException);
virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
throw (css::uno::RuntimeException);
virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
throw (css::uno::RuntimeException);
//----------------------------------------------------------------------------------
// XSynchronousFrameLoader
//----------------------------------------------------------------------------------
virtual sal_Bool SAL_CALL load( const css::uno::Sequence< css::beans::PropertyValue >& _rArgs, const css::uno::Reference< css::frame::XFrame >& _rxFrame ) throw( css::uno::RuntimeException );
virtual void SAL_CALL cancel() throw( css::uno::RuntimeException );
protected:
virtual ~SfxFrameLoader_Impl();
private:
const SfxFilter* impl_getFilterFromServiceName_nothrow(
const OUString& i_rServiceName
) const;
OUString impl_askForFilter_nothrow(
const css::uno::Reference< css::task::XInteractionHandler >& i_rxHandler,
const OUString& i_rDocumentURL
) const;
const SfxFilter* impl_detectFilterForURL(
const OUString& _rURL,
const ::comphelper::NamedValueCollection& i_rDescriptor,
const SfxFilterMatcher& rMatcher
) const;
sal_Bool impl_createNewDocWithSlotParam(
const sal_uInt16 _nSlotID,
const css::uno::Reference< css::frame::XFrame >& i_rxFrame,
const bool i_bHidden
);
void impl_determineFilter(
::comphelper::NamedValueCollection& io_rDescriptor
) const;
bool impl_determineTemplateDocument(
::comphelper::NamedValueCollection& io_rDescriptor
) const;
sal_uInt16 impl_findSlotParam(
const OUString& i_rFactoryURL
) const;
SfxObjectShellRef impl_findObjectShell(
const css::uno::Reference< css::frame::XModel2 >& i_rxDocument
) const;
void impl_lockHiddenDocument(
SfxObjectShell& i_rDocument,
const ::comphelper::NamedValueCollection& i_rDescriptor
) const;
void impl_handleCaughtError_nothrow(
const css::uno::Any& i_rCaughtError,
const ::comphelper::NamedValueCollection& i_rDescriptor
) const;
void impl_removeLoaderArguments(
::comphelper::NamedValueCollection& io_rDescriptor
);
sal_Int16 impl_determineEffectiveViewId_nothrow(
const SfxObjectShell& i_rDocument,
const ::comphelper::NamedValueCollection& i_rDescriptor
);
::comphelper::NamedValueCollection
impl_extractViewCreationArgs(
::comphelper::NamedValueCollection& io_rDescriptor
);
css::uno::Reference< css::frame::XController2 >
impl_createDocumentView(
const css::uno::Reference< css::frame::XModel2 >& i_rModel,
const css::uno::Reference< css::frame::XFrame >& i_rFrame,
const ::comphelper::NamedValueCollection& i_rViewFactoryArgs,
const OUString& i_rViewName
);
};
SfxFrameLoader_Impl::SfxFrameLoader_Impl( const Reference< css::uno::XComponentContext >& _rxContext )
:m_aContext( _rxContext ) :m_aContext( _rxContext )
{ {
} }
...@@ -648,12 +750,10 @@ void SfxFrameLoader_Impl::cancel() throw( RuntimeException ) ...@@ -648,12 +750,10 @@ void SfxFrameLoader_Impl::cancel() throw( RuntimeException )
{ {
} }
SFX_IMPL_SINGLEFACTORY( SfxFrameLoader_Impl )
/* XServiceInfo */ /* XServiceInfo */
OUString SAL_CALL SfxFrameLoader_Impl::getImplementationName() throw( RuntimeException ) OUString SAL_CALL SfxFrameLoader_Impl::getImplementationName() throw( RuntimeException )
{ {
return impl_getStaticImplementationName(); return OUString("com.sun.star.comp.office.FrameLoader");
} }
\ \
/* XServiceInfo */ /* XServiceInfo */
...@@ -664,12 +764,6 @@ sal_Bool SAL_CALL SfxFrameLoader_Impl::supportsService( const OUString& sService ...@@ -664,12 +764,6 @@ sal_Bool SAL_CALL SfxFrameLoader_Impl::supportsService( const OUString& sService
/* XServiceInfo */ /* XServiceInfo */
Sequence< OUString > SAL_CALL SfxFrameLoader_Impl::getSupportedServiceNames() throw( RuntimeException ) Sequence< OUString > SAL_CALL SfxFrameLoader_Impl::getSupportedServiceNames() throw( RuntimeException )
{
return impl_getStaticSupportedServiceNames();
}
/* Helper for XServiceInfo */
Sequence< OUString > SfxFrameLoader_Impl::impl_getStaticSupportedServiceNames()
{ {
Sequence< OUString > seqServiceNames( 2 ); Sequence< OUString > seqServiceNames( 2 );
seqServiceNames.getArray() [0] = "com.sun.star.frame.SynchronousFrameLoader"; seqServiceNames.getArray() [0] = "com.sun.star.frame.SynchronousFrameLoader";
...@@ -677,16 +771,16 @@ Sequence< OUString > SfxFrameLoader_Impl::impl_getStaticSupportedServiceNames() ...@@ -677,16 +771,16 @@ Sequence< OUString > SfxFrameLoader_Impl::impl_getStaticSupportedServiceNames()
return seqServiceNames ; return seqServiceNames ;
} }
/* Helper for XServiceInfo */
OUString SfxFrameLoader_Impl::impl_getStaticImplementationName()
{
return OUString( "com.sun.star.comp.office.FrameLoader" );
} }
/* Helper for registry */ extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
Reference< css::uno::XInterface > SAL_CALL SfxFrameLoader_Impl::impl_createInstance( const Reference< XMultiServiceFactory >& xServiceManager ) throw( Exception ) com_sun_star_comp_office_FrameLoader_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{ {
return Reference< css::uno::XInterface >( *new SfxFrameLoader_Impl( comphelper::getComponentContext(xServiceManager) ) ); rtl::Reference<SfxFrameLoader_Impl> x(new SfxFrameLoader_Impl(context));
x->acquire();
return static_cast<cppu::OWeakObject *>(x.get());
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -40,7 +40,8 @@ ...@@ -40,7 +40,8 @@
<service name="com.sun.star.comp.embed.PackageStructureCreator"/> <service name="com.sun.star.comp.embed.PackageStructureCreator"/>
<service name="com.sun.star.embed.PackageStructureCreator"/> <service name="com.sun.star.embed.PackageStructureCreator"/>
</implementation> </implementation>
<implementation name="com.sun.star.comp.office.FrameLoader"> <implementation name="com.sun.star.comp.office.FrameLoader"
constructor="com_sun_star_comp_office_FrameLoader_get_implementation">
<service name="com.sun.star.frame.SynchronousFrameLoader"/> <service name="com.sun.star.frame.SynchronousFrameLoader"/>
<service name="com.sun.star.frame.OfficeFrameLoader"/> <service name="com.sun.star.frame.OfficeFrameLoader"/>
</implementation> </implementation>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment