no need for sd::ModuleController to load these factories via UNO

Change-Id: I2ac1d29ff9cbd5c8676dc1957a62ea02454d052e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146122
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2023-01-25 10:09:55 +02:00
parent fec0b1e444
commit bfb8706466
10 changed files with 113 additions and 212 deletions

View file

@ -20,7 +20,7 @@
#include <memory>
#include <sal/config.h>
#include "BasicPaneFactory.hxx"
#include <framework/factories/BasicPaneFactory.hxx>
#include "ChildWindowPane.hxx"
#include "FrameWindowPane.hxx"
@ -84,67 +84,23 @@ public:
//===== PaneFactory ===========================================================
BasicPaneFactory::BasicPaneFactory (
const Reference<XComponentContext>& rxContext)
const Reference<XComponentContext>& rxContext,
const rtl::Reference<::sd::DrawController>& rxController)
: mxComponentContext(rxContext),
mpViewShellBase(nullptr),
mpPaneContainer(new PaneContainer)
{
}
BasicPaneFactory::~BasicPaneFactory()
{
}
void BasicPaneFactory::disposing(std::unique_lock<std::mutex>&)
{
Reference<XConfigurationController> xCC (mxConfigurationControllerWeak);
if (xCC.is())
{
xCC->removeResourceFactoryForReference(this);
xCC->removeConfigurationChangeListener(this);
mxConfigurationControllerWeak.clear();
}
for (const auto& rDescriptor : *mpPaneContainer)
{
if (rDescriptor.mbIsReleased)
{
Reference<XComponent> xComponent (rDescriptor.mxPane, UNO_QUERY);
if (xComponent.is())
{
xComponent->removeEventListener(this);
xComponent->dispose();
}
}
}
}
void SAL_CALL BasicPaneFactory::initialize (const Sequence<Any>& aArguments)
{
if (!aArguments.hasElements())
return;
try
{
// Get the XController from the first argument.
Reference<frame::XController> xController (aArguments[0], UNO_QUERY_THROW);
// Tunnel through the controller to obtain access to the ViewShellBase.
try
{
if (auto pController = dynamic_cast<DrawController*>(xController.get()))
mpViewShellBase = pController->GetViewShellBase();
}
catch(RuntimeException&)
{}
mpViewShellBase = rxController->GetViewShellBase();
Reference<XControllerManager> xCM (xController, UNO_QUERY_THROW);
Reference<XConfigurationController> xCC (xCM->getConfigurationController());
Reference<XConfigurationController> xCC (rxController->getConfigurationController());
mxConfigurationControllerWeak = xCC;
// Add pane factories for the two left panes (one for Impress and one for
// Draw) and the center pane.
if (xController.is() && xCC.is())
if (rxController.is() && xCC.is())
{
PaneDescriptor aDescriptor;
aDescriptor.msPaneURL = FrameworkHelper::msCenterPaneURL;
@ -190,6 +146,34 @@ void SAL_CALL BasicPaneFactory::initialize (const Sequence<Any>& aArguments)
}
}
BasicPaneFactory::~BasicPaneFactory()
{
}
void BasicPaneFactory::disposing(std::unique_lock<std::mutex>&)
{
Reference<XConfigurationController> xCC (mxConfigurationControllerWeak);
if (xCC.is())
{
xCC->removeResourceFactoryForReference(this);
xCC->removeConfigurationChangeListener(this);
mxConfigurationControllerWeak.clear();
}
for (const auto& rDescriptor : *mpPaneContainer)
{
if (rDescriptor.mbIsReleased)
{
Reference<XComponent> xComponent (rDescriptor.mxPane, UNO_QUERY);
if (xComponent.is())
{
xComponent->removeEventListener(this);
xComponent->dispose();
}
}
}
}
//===== XPaneFactory ==========================================================
Reference<XResource> SAL_CALL BasicPaneFactory::createResource (
@ -420,12 +404,4 @@ void BasicPaneFactory::ThrowIfDisposed() const
} // end of namespace sd::framework
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
com_sun_star_comp_Draw_framework_BasicPaneFactory_get_implementation(css::uno::XComponentContext* context,
css::uno::Sequence<css::uno::Any> const &)
{
return cppu::acquire(new sd::framework::BasicPaneFactory(context));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -17,10 +17,11 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "BasicToolBarFactory.hxx"
#include <framework/factories/BasicToolBarFactory.hxx>
#include <ViewTabBar.hxx>
#include <framework/FrameworkHelper.hxx>
#include <DrawController.hxx>
#include <unotools/mediadescriptor.hxx>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
@ -37,42 +38,11 @@ namespace sd::framework {
//===== BasicToolBarFactory ===================================================
BasicToolBarFactory::BasicToolBarFactory ()
BasicToolBarFactory::BasicToolBarFactory(const rtl::Reference<::sd::DrawController>& rxController)
{
}
BasicToolBarFactory::~BasicToolBarFactory()
{
}
void BasicToolBarFactory::disposing(std::unique_lock<std::mutex>&)
{
Shutdown();
}
void BasicToolBarFactory::Shutdown()
{
Reference<lang::XComponent> xComponent (mxConfigurationController, UNO_QUERY);
if (xComponent.is())
xComponent->removeEventListener(static_cast<lang::XEventListener*>(this));
if (mxConfigurationController.is())
{
mxConfigurationController->removeResourceFactoryForReference(this);
mxConfigurationController = nullptr;
}
}
//----- XInitialization -------------------------------------------------------
void SAL_CALL BasicToolBarFactory::initialize (const Sequence<Any>& aArguments)
{
if (!aArguments.hasElements())
return;
try
{
// Get the XController from the first argument.
mxController.set(aArguments[0], UNO_QUERY_THROW);
mxController = rxController;
utl::MediaDescriptor aDescriptor (mxController->getModel()->getArgs());
if ( ! aDescriptor.getUnpackedValueOrDefault(
@ -80,8 +50,7 @@ void SAL_CALL BasicToolBarFactory::initialize (const Sequence<Any>& aArguments)
false))
{
// Register the factory for its supported tool bars.
Reference<XControllerManager> xControllerManager(mxController, UNO_QUERY_THROW);
mxConfigurationController = xControllerManager->getConfigurationController();
mxConfigurationController = mxController->getConfigurationController();
if (mxConfigurationController.is())
{
mxConfigurationController->addResourceFactory(
@ -106,6 +75,28 @@ void SAL_CALL BasicToolBarFactory::initialize (const Sequence<Any>& aArguments)
}
}
BasicToolBarFactory::~BasicToolBarFactory()
{
}
void BasicToolBarFactory::disposing(std::unique_lock<std::mutex>&)
{
Shutdown();
}
void BasicToolBarFactory::Shutdown()
{
Reference<lang::XComponent> xComponent (mxConfigurationController, UNO_QUERY);
if (xComponent.is())
xComponent->removeEventListener(static_cast<lang::XEventListener*>(this));
if (mxConfigurationController.is())
{
mxConfigurationController->removeResourceFactoryForReference(this);
mxConfigurationController = nullptr;
}
}
//----- lang::XEventListener --------------------------------------------------
void SAL_CALL BasicToolBarFactory::disposing (
@ -150,12 +141,4 @@ void BasicToolBarFactory::ThrowIfDisposed() const
} // end of namespace sd::framework
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
com_sun_star_comp_Draw_framework_BasicToolBarFactory_get_implementation(css::uno::XComponentContext*,
css::uno::Sequence<css::uno::Any> const &)
{
return cppu::acquire(new sd::framework::BasicToolBarFactory);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -17,7 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "BasicViewFactory.hxx"
#include <framework/factories/BasicViewFactory.hxx>
#include <framework/ViewShellWrapper.hxx>
#include <framework/FrameworkHelper.hxx>
@ -82,7 +82,7 @@ public:
//===== ViewFactory ===========================================================
BasicViewFactory::BasicViewFactory ()
BasicViewFactory::BasicViewFactory (const rtl::Reference<::sd::DrawController>& rxController)
: mpViewShellContainer(new ViewShellContainer()),
mpBase(nullptr),
mpFrameView(nullptr),
@ -90,6 +90,30 @@ BasicViewFactory::BasicViewFactory ()
mpViewCache(std::make_shared<ViewCache>()),
mxLocalPane(new Pane(Reference<XResourceId>(), mpWindow.get()))
{
try
{
// Tunnel through the controller to obtain a ViewShellBase.
mpBase = rxController->GetViewShellBase();
// Register the factory for its supported views.
mxConfigurationController = rxController->getConfigurationController();
if ( ! mxConfigurationController.is())
throw RuntimeException();
mxConfigurationController->addResourceFactory(FrameworkHelper::msImpressViewURL, this);
mxConfigurationController->addResourceFactory(FrameworkHelper::msDrawViewURL, this);
mxConfigurationController->addResourceFactory(FrameworkHelper::msOutlineViewURL, this);
mxConfigurationController->addResourceFactory(FrameworkHelper::msNotesViewURL, this);
mxConfigurationController->addResourceFactory(FrameworkHelper::msHandoutViewURL, this);
mxConfigurationController->addResourceFactory(FrameworkHelper::msPresentationViewURL, this);
mxConfigurationController->addResourceFactory(FrameworkHelper::msSlideSorterURL, this);
}
catch (RuntimeException&)
{
mpBase = nullptr;
if (mxConfigurationController.is())
mxConfigurationController->removeResourceFactoryForReference(this);
throw;
}
}
BasicViewFactory::~BasicViewFactory()
@ -226,43 +250,6 @@ void SAL_CALL BasicViewFactory::releaseResource (const Reference<XResource>& rxV
mpViewShellContainer->erase(iViewShell);
}
void SAL_CALL BasicViewFactory::initialize (const Sequence<Any>& aArguments)
{
if (!aArguments.hasElements())
return;
try
{
// Get the XController from the first argument.
Reference<frame::XController> xController (aArguments[0], UNO_QUERY_THROW);
// Tunnel through the controller to obtain a ViewShellBase.
::sd::DrawController* pController = dynamic_cast<sd::DrawController*>(xController.get());
if (pController != nullptr)
mpBase = pController->GetViewShellBase();
// Register the factory for its supported views.
Reference<XControllerManager> xCM (xController,UNO_QUERY_THROW);
mxConfigurationController = xCM->getConfigurationController();
if ( ! mxConfigurationController.is())
throw RuntimeException();
mxConfigurationController->addResourceFactory(FrameworkHelper::msImpressViewURL, this);
mxConfigurationController->addResourceFactory(FrameworkHelper::msDrawViewURL, this);
mxConfigurationController->addResourceFactory(FrameworkHelper::msOutlineViewURL, this);
mxConfigurationController->addResourceFactory(FrameworkHelper::msNotesViewURL, this);
mxConfigurationController->addResourceFactory(FrameworkHelper::msHandoutViewURL, this);
mxConfigurationController->addResourceFactory(FrameworkHelper::msPresentationViewURL, this);
mxConfigurationController->addResourceFactory(FrameworkHelper::msSlideSorterURL, this);
}
catch (RuntimeException&)
{
mpBase = nullptr;
if (mxConfigurationController.is())
mxConfigurationController->removeResourceFactoryForReference(this);
throw;
}
}
std::shared_ptr<BasicViewFactory::ViewDescriptor> BasicViewFactory::CreateView (
const Reference<XResourceId>& rxViewId,
SfxViewFrame& rFrame,
@ -505,12 +492,4 @@ void BasicViewFactory::ActivateCenterView (
} // end of namespace sd::framework
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
com_sun_star_comp_Draw_framework_BasicViewFactory_get_implementation(css::uno::XComponentContext*,
css::uno::Sequence<css::uno::Any> const &)
{
return cppu::acquire(new sd::framework::BasicViewFactory);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -19,6 +19,9 @@
#include <framework/ModuleController.hxx>
#include <framework/PresentationFactory.hxx>
#include <framework/factories/BasicPaneFactory.hxx>
#include <framework/factories/BasicViewFactory.hxx>
#include <framework/factories/BasicToolBarFactory.hxx>
#include <DrawController.hxx>
#include <com/sun/star/frame/XController.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
@ -63,15 +66,6 @@ ModuleController::ModuleController(const rtl::Reference<::sd::DrawController>& r
ProcessFactory(
"com.sun.star.drawing.framework.BasicToolBarFactory",
{ "private:resource/toolbar/ViewTabBar" });
ProcessFactory(
"com.sun.star.comp.Draw.framework.TaskPanelFactory",
{ "private:resource/toolpanel/AllMasterPages",
"private:resource/toolpanel/RecentMasterPages",
"private:resource/toolpanel/UsedMasterPages",
"private:resource/toolpanel/Layouts",
"private:resource/toolpanel/TableDesign",
"private:resource/toolpanel/CustomAnimations",
"private:resource/toolpanel/SlideTransitions" });
try
{
@ -148,18 +142,14 @@ void SAL_CALL ModuleController::requestResource (const OUString& rsResourceURL)
::comphelper::getProcessComponentContext();
// Create the factory service.
Sequence<Any> aArguments{ Any(uno::Reference<XControllerManager>(mxController)) };
try
{
xFactory = xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
iFactory->second,
aArguments,
xContext);
}
catch (const Exception&)
{
TOOLS_WARN_EXCEPTION("sd.fwk", "caught exception while creating factory");
}
if (iFactory->second == "com.sun.star.drawing.framework.BasicPaneFactory")
xFactory = uno::Reference<css::drawing::framework::XResourceFactory>(new BasicPaneFactory(xContext, mxController));
else if (iFactory->second == "com.sun.star.drawing.framework.BasicViewFactory")
xFactory = uno::Reference<css::drawing::framework::XResourceFactory>(new BasicViewFactory(mxController));
else if (iFactory->second == "com.sun.star.drawing.framework.BasicToolBarFactory")
xFactory = uno::Reference<css::drawing::framework::XResourceFactory>(new BasicToolBarFactory(mxController));
else
throw RuntimeException("unknown factory");
// Remember that this factory has been instanced.
maLoadedFactories[iFactory->second] = xFactory;

View file

@ -24,6 +24,7 @@
#include <com/sun/star/lang/XInitialization.hpp>
#include <comphelper/compbase.hxx>
#include <cppuhelper/weakref.hxx>
#include <rtl/ref.hxx>
#include <memory>
@ -31,14 +32,13 @@ namespace com::sun::star::drawing::framework { class XConfigurationController; }
namespace com::sun::star::uno { class XComponentContext; }
namespace sd {
class DrawController;
class ViewShellBase;
}
namespace sd::framework {
typedef comphelper::WeakComponentImplHelper <
css::lang::XInitialization,
css::drawing::framework::XResourceFactory,
css::drawing::framework::XConfigurationChangeListener
> BasicPaneFactoryInterfaceBase;
@ -56,16 +56,12 @@ class BasicPaneFactory
{
public:
explicit BasicPaneFactory (
const css::uno::Reference<css::uno::XComponentContext>& rxContext);
const css::uno::Reference<css::uno::XComponentContext>& rxContext,
const rtl::Reference<::sd::DrawController>& rxController);
virtual ~BasicPaneFactory() override;
virtual void disposing(std::unique_lock<std::mutex>&) override;
// XInitialization
virtual void SAL_CALL initialize(
const css::uno::Sequence<css::uno::Any>& aArguments) override;
// XResourceFactory
virtual css::uno::Reference<css::drawing::framework::XResource>

View file

@ -22,16 +22,17 @@
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/drawing/framework/XResourceFactory.hpp>
#include <comphelper/compbase.hxx>
#include <rtl/ref.hxx>
namespace com::sun::star::frame { class XController; }
namespace com::sun::star::drawing::framework { class XResourceId; }
namespace com::sun::star::drawing::framework { class XConfigurationController; }
namespace sd { class DrawController; }
namespace sd::framework {
typedef comphelper::WeakComponentImplHelper <
css::drawing::framework::XResourceFactory,
css::lang::XInitialization,
css::lang::XEventListener
> BasicToolBarFactoryInterfaceBase;
@ -42,7 +43,7 @@ class BasicToolBarFactory
: public BasicToolBarFactoryInterfaceBase
{
public:
BasicToolBarFactory ();
BasicToolBarFactory (const rtl::Reference<::sd::DrawController>& rxController);
virtual ~BasicToolBarFactory() override;
virtual void disposing(std::unique_lock<std::mutex>&) override;
@ -59,11 +60,6 @@ public:
const css::uno::Reference<css::drawing::framework::XResource>&
rxToolBar) override;
// XInitialization
virtual void SAL_CALL initialize(
const css::uno::Sequence<css::uno::Any>& aArguments) override;
// lang::XEventListener
virtual void SAL_CALL disposing (
@ -71,7 +67,7 @@ public:
private:
css::uno::Reference<css::drawing::framework::XConfigurationController> mxConfigurationController;
css::uno::Reference<css::frame::XController> mxController;
rtl::Reference<::sd::DrawController> mxController;
void Shutdown();

View file

@ -23,6 +23,7 @@
#include <com/sun/star/lang/XInitialization.hpp>
#include <comphelper/compbase.hxx>
#include <rtl/ref.hxx>
#include <vcl/vclptr.hxx>
#include <memory>
@ -31,6 +32,7 @@ namespace com::sun::star::drawing::framework { class XConfigurationController; }
namespace com::sun::star::drawing::framework { class XPane; }
namespace sd {
class DrawController;
class ViewShell;
class ViewShellBase;
class FrameView;
@ -41,8 +43,7 @@ namespace vcl { class Window; }
namespace sd::framework {
typedef comphelper::WeakComponentImplHelper <
css::drawing::framework::XResourceFactory,
css::lang::XInitialization
css::drawing::framework::XResourceFactory
> BasicViewFactoryInterfaceBase;
/** Factory for the frequently used standard views of the drawing framework:
@ -61,7 +62,7 @@ class BasicViewFactory
: public BasicViewFactoryInterfaceBase
{
public:
BasicViewFactory ();
BasicViewFactory(const rtl::Reference<::sd::DrawController>& rxController);
virtual ~BasicViewFactory() override;
virtual void disposing(std::unique_lock<std::mutex>&) override;
@ -75,11 +76,6 @@ public:
virtual void SAL_CALL releaseResource (
const css::uno::Reference<css::drawing::framework::XResource>& xView) override;
// XInitialization
virtual void SAL_CALL initialize(
const css::uno::Sequence<css::uno::Any>& aArguments) override;
private:
css::uno::Reference<css::drawing::framework::XConfigurationController>
mxConfigurationController;

View file

@ -45,18 +45,6 @@
constructor="com_sun_star_comp_Draw_SlideRenderer_get_implementation">
<service name="com.sun.star.drawing.SlideRenderer"/>
</implementation>
<implementation name="com.sun.star.comp.Draw.framework.BasicPaneFactory"
constructor="com_sun_star_comp_Draw_framework_BasicPaneFactory_get_implementation">
<service name="com.sun.star.drawing.framework.BasicPaneFactory"/>
</implementation>
<implementation name="com.sun.star.comp.Draw.framework.BasicToolBarFactory"
constructor="com_sun_star_comp_Draw_framework_BasicToolBarFactory_get_implementation">
<service name="com.sun.star.drawing.framework.BasicToolBarFactory"/>
</implementation>
<implementation name="com.sun.star.comp.Draw.framework.BasicViewFactory"
constructor="com_sun_star_comp_Draw_framework_BasicViewFactory_get_implementation">
<service name="com.sun.star.drawing.framework.BasicViewFactory"/>
</implementation>
<implementation name="com.sun.star.comp.Draw.framework.ResourceId"
constructor="com_sun_star_comp_Draw_framework_ResourceID_get_implementation">
<service name="com.sun.star.drawing.framework.ResourceId"/>

View file

@ -700,9 +700,6 @@ draw_constructor_list = [
"com_sun_star_comp_sd_SlideLayoutController_get_implementation",
"com_sun_star_comp_sd_DisplayModeController_get_implementation",
"RandomAnimationNode_get_implementation",
"com_sun_star_comp_Draw_framework_BasicPaneFactory_get_implementation",
"com_sun_star_comp_Draw_framework_BasicToolBarFactory_get_implementation",
"com_sun_star_comp_Draw_framework_BasicViewFactory_get_implementation",
"com_sun_star_comp_Draw_framework_ResourceID_get_implementation",
"org_openoffice_comp_Draw_framework_PanelFactory_get_implementation",
"css_comp_Impress_oox_PowerPointExport",

View file

@ -9690,11 +9690,8 @@ sd/source/ui/framework/configuration/ResourceFactoryManager.hxx
sd/source/ui/framework/configuration/ResourceId.cxx
sd/source/ui/framework/configuration/UpdateRequest.hxx
sd/source/ui/framework/factories/BasicPaneFactory.cxx
sd/source/ui/framework/factories/BasicPaneFactory.hxx
sd/source/ui/framework/factories/BasicToolBarFactory.cxx
sd/source/ui/framework/factories/BasicToolBarFactory.hxx
sd/source/ui/framework/factories/BasicViewFactory.cxx
sd/source/ui/framework/factories/BasicViewFactory.hxx
sd/source/ui/framework/factories/ChildWindowPane.cxx
sd/source/ui/framework/factories/ChildWindowPane.hxx
sd/source/ui/framework/factories/FullScreenPane.cxx
@ -9829,6 +9826,9 @@ sd/source/ui/inc/framework/Pane.hxx
sd/source/ui/inc/framework/PresentationFactory.hxx
sd/source/ui/inc/framework/ResourceId.hxx
sd/source/ui/inc/framework/ViewShellWrapper.hxx
sd/source/ui/inc/framework/factories/BasicPaneFactory.hxx
sd/source/ui/inc/framework/factories/BasicToolBarFactory.hxx
sd/source/ui/inc/framework/factories/BasicViewFactory.hxx
sd/source/ui/inc/fuarea.hxx
sd/source/ui/inc/fubullet.hxx
sd/source/ui/inc/fuchar.hxx