reportdesign: Create XML exporters without UNO ctors
So far, the XML exporters used in OReportDefinition::storeToStorage and OReportDefinition::WriteThroughComponent were created using UNO service constructors. Move away from that approach/indirection: Add static helper methods to ORptExport that can be used to create ORptExport instances with the relevant parameters (that were previously passed to the ctor by the UNO service constructors) and call these directly to receive the relevant instances. Drop the now unused UNO constructors. Pass the `rtl::Reference<rptxml::ORptExport>&` to OReportDefinition::WriteThroughComponent, which also avoids the need to query for the relevant interfaces. No change in user-observable behavior intended or seen in a quick test of generating a report in Base. Change-Id: Ia84319009e71ef432077a60dd7e44003126334d6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187914 Tested-by: Jenkins Reviewed-by: Adam Seskunas <adamseskunas@gmail.com> Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include "dllapi.h"
|
||||
|
||||
#include "ReportHelperDefines.hxx"
|
||||
#include "xmlExport.hxx"
|
||||
|
||||
#include <com/sun/star/datatransfer/XTransferable.hpp>
|
||||
#include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
|
||||
@@ -132,7 +133,7 @@ namespace reportdesign
|
||||
/// the component we export
|
||||
const css::uno::Reference< css::lang::XComponent> & xComponent,
|
||||
const OUString& rStreamName, /// the stream name
|
||||
const OUString& rServiceName, /// service name of the component
|
||||
const rtl::Reference<rptxml::ORptExport>& pExporter, /// the exporter
|
||||
/// the argument (XInitialization)
|
||||
const css::uno::Sequence< css::uno::Any> & rArguments,
|
||||
const css::uno::Reference< css::embed::XStorage >& _xStorageToSaveTo);
|
||||
|
||||
@@ -147,6 +147,16 @@ public:
|
||||
const Reference<XReportDefinition>& getReportDefinition() const { return m_xReportDefinition; }
|
||||
|
||||
const rtl::Reference < XMLPropertySetMapper >& GetCellStylePropertyMapper() const { return m_xCellStylesPropertySetMapper;}
|
||||
|
||||
// Helper methods to create exporters
|
||||
static rtl::Reference<ORptExport>
|
||||
createSettingsExporter(const Reference<XComponentContext>& rxContext);
|
||||
static rtl::Reference<ORptExport>
|
||||
createStylesExporter(const Reference<XComponentContext>& rxContext);
|
||||
static rtl::Reference<ORptExport>
|
||||
createMetaExporter(const Reference<XComponentContext>& rxContext);
|
||||
static rtl::Reference<ORptExport>
|
||||
createExportFilter(const Reference<XComponentContext>& rxContext);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1342,20 +1342,28 @@ void SAL_CALL OReportDefinition::storeToStorage( const uno::Reference< embed::XS
|
||||
// Try to write to settings.xml, meta.xml, and styles.xml; only really care about success of
|
||||
// write to content.xml (keeping logic of commit 94ccba3eebc83b58e74e18f0e028c6a995ce6aa6)
|
||||
xInfoSet->setPropertyValue(u"StreamName"_ustr, uno::Any(u"settings.xml"_ustr));
|
||||
WriteThroughComponent(xCom, u"settings.xml"_ustr, u"com.sun.star.comp.report.XMLSettingsExporter"_ustr,
|
||||
aDelegatorArguments, _xStorageToSaveTo);
|
||||
rtl::Reference<rptxml::ORptExport> pSettingsExporter
|
||||
= rptxml::ORptExport::createSettingsExporter(m_aProps->m_xContext);
|
||||
WriteThroughComponent(xCom, u"settings.xml"_ustr, pSettingsExporter, aDelegatorArguments,
|
||||
_xStorageToSaveTo);
|
||||
|
||||
xInfoSet->setPropertyValue(u"StreamName"_ustr, uno::Any(u"meta.xml"_ustr));
|
||||
WriteThroughComponent(xCom, u"meta.xml"_ustr, u"com.sun.star.comp.report.XMLMetaExporter"_ustr,
|
||||
aDelegatorArguments, _xStorageToSaveTo);
|
||||
rtl::Reference<rptxml::ORptExport> pMetaExporter
|
||||
= rptxml::ORptExport::createMetaExporter(m_aProps->m_xContext);
|
||||
WriteThroughComponent(xCom, u"meta.xml"_ustr, pMetaExporter, aDelegatorArguments,
|
||||
_xStorageToSaveTo);
|
||||
|
||||
xInfoSet->setPropertyValue(u"StreamName"_ustr, uno::Any(u"styles.xml"_ustr));
|
||||
WriteThroughComponent(xCom, u"styles.xml"_ustr, u"com.sun.star.comp.report.XMLStylesExporter"_ustr,
|
||||
aDelegatorArguments, _xStorageToSaveTo);
|
||||
rtl::Reference<rptxml::ORptExport> pStylesExporter
|
||||
= rptxml::ORptExport::createStylesExporter(m_aProps->m_xContext);
|
||||
WriteThroughComponent(xCom, u"styles.xml"_ustr, pStylesExporter, aDelegatorArguments,
|
||||
_xStorageToSaveTo);
|
||||
|
||||
xInfoSet->setPropertyValue(u"StreamName"_ustr, uno::Any(u"content.xml"_ustr));
|
||||
bool bOk = WriteThroughComponent(xCom, u"content.xml"_ustr, u"com.sun.star.comp.report.ExportFilter"_ustr,
|
||||
aDelegatorArguments, _xStorageToSaveTo);
|
||||
rtl::Reference<rptxml::ORptExport> pExportFilter
|
||||
= rptxml::ORptExport::createExportFilter(m_aProps->m_xContext);
|
||||
bool bOk = WriteThroughComponent(xCom, u"content.xml"_ustr, pExportFilter, aDelegatorArguments,
|
||||
_xStorageToSaveTo);
|
||||
|
||||
uno::Any aImage;
|
||||
uno::Reference< embed::XVisualObject > xCurrentController(getCurrentController(),uno::UNO_QUERY);
|
||||
@@ -1445,11 +1453,12 @@ void SAL_CALL OReportDefinition::removeStorageChangeListener( const uno::Referen
|
||||
bool OReportDefinition::WriteThroughComponent(
|
||||
const uno::Reference<lang::XComponent> & xComponent,
|
||||
const OUString& rStreamName,
|
||||
const OUString& rServiceName,
|
||||
const rtl::Reference<rptxml::ORptExport>& pExporter,
|
||||
const uno::Sequence<uno::Any> & rArguments,
|
||||
const uno::Reference<embed::XStorage>& _xStorageToSaveTo)
|
||||
{
|
||||
OSL_ENSURE( xComponent.is(), "Need component!" );
|
||||
assert(pExporter.is());
|
||||
|
||||
// open stream
|
||||
uno::Reference<io::XStream> xStream = _xStorageToSaveTo->openStreamElement(rStreamName,
|
||||
@@ -1489,22 +1498,14 @@ bool OReportDefinition::WriteThroughComponent(
|
||||
*pArgs <<= xSaxWriter;
|
||||
std::copy(rArguments.begin(), rArguments.end(), std::next(pArgs));
|
||||
|
||||
// get filter component
|
||||
uno::Reference< document::XExporter > xExporter(
|
||||
m_aProps->m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
|
||||
rServiceName, aArgs, m_aProps->m_xContext), uno::UNO_QUERY);
|
||||
OSL_ENSURE( xExporter.is(),
|
||||
"can't instantiate export filter component" );
|
||||
if( !xExporter.is() )
|
||||
return false;
|
||||
pExporter->initialize(aArgs);
|
||||
|
||||
// connect model and filter
|
||||
xExporter->setSourceDocument( xComponent );
|
||||
pExporter->setSourceDocument(xComponent);
|
||||
|
||||
// filter!
|
||||
uno::Sequence<beans::PropertyValue> aMediaDesc;
|
||||
uno::Reference<document::XFilter> xFilter( xExporter, uno::UNO_QUERY );
|
||||
return xFilter->filter(aMediaDesc);
|
||||
return pExporter->filter(aMediaDesc);
|
||||
}
|
||||
|
||||
// XLoadable
|
||||
|
||||
@@ -57,47 +57,6 @@ namespace rptxml
|
||||
using namespace ::com::sun::star::uno;
|
||||
using namespace ::com::sun::star::util;
|
||||
|
||||
|
||||
/** Exports only settings
|
||||
* \ingroup reportdesign_source_filter_xml
|
||||
*
|
||||
*/
|
||||
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
|
||||
reportdesign_ORptExportHelper_get_implementation(
|
||||
css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
|
||||
{
|
||||
return cppu::acquire(new ORptExport(context,
|
||||
u"com.sun.star.comp.report.XMLSettingsExporter"_ustr,
|
||||
SvXMLExportFlags::SETTINGS ));
|
||||
}
|
||||
|
||||
/** Exports only styles
|
||||
* \ingroup reportdesign_source_filter_xml
|
||||
*
|
||||
*/
|
||||
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
|
||||
reportdesign_ORptStylesExportHelper_get_implementation(
|
||||
css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
|
||||
{
|
||||
return cppu::acquire(new ORptExport(context,
|
||||
u"com.sun.star.comp.report.XMLStylesExporter"_ustr,
|
||||
SvXMLExportFlags::STYLES | SvXMLExportFlags::MASTERSTYLES | SvXMLExportFlags::AUTOSTYLES |
|
||||
SvXMLExportFlags::FONTDECLS|SvXMLExportFlags::OASIS ));
|
||||
}
|
||||
|
||||
/** Exports only meta data
|
||||
* \ingroup reportdesign_source_filter_xml
|
||||
*
|
||||
*/
|
||||
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
|
||||
reportdesign_ORptMetaExportHelper_get_implementation(
|
||||
css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
|
||||
{
|
||||
return cppu::acquire(new ORptExport(context,
|
||||
u"com.sun.star.comp.report.XMLMetaExporter"_ustr,
|
||||
SvXMLExportFlags::META ));
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class OSpecialHandleXMLExportPropertyMapper : public SvXMLExportPropertyMapper
|
||||
@@ -245,16 +204,6 @@ ORptExport::ORptExport(const Reference< XComponentContext >& _rxContext, OUStrin
|
||||
m_xTableStylesExportPropertySetMapper, XML_STYLE_FAMILY_TABLE_TABLE_STYLES_PREFIX);
|
||||
}
|
||||
|
||||
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
|
||||
reportdesign_ORptExport_get_implementation(
|
||||
css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
|
||||
{
|
||||
return cppu::acquire(new ORptExport(context,
|
||||
u"com.sun.star.comp.report.ExportFilter"_ustr,
|
||||
SvXMLExportFlags::CONTENT | SvXMLExportFlags::AUTOSTYLES | SvXMLExportFlags::FONTDECLS));
|
||||
}
|
||||
|
||||
|
||||
void ORptExport::exportFunctions(const Reference<XIndexAccess>& _xFunctions)
|
||||
{
|
||||
const sal_Int32 nCount = _xFunctions->getCount();
|
||||
@@ -1502,6 +1451,36 @@ void ORptExport::exportGroupsExpressionAsFunction(const Reference< XGroups>& _xG
|
||||
}
|
||||
}
|
||||
|
||||
rtl::Reference<ORptExport>
|
||||
ORptExport::createSettingsExporter(const Reference<XComponentContext>& rxContext)
|
||||
{
|
||||
return new ORptExport(rxContext, u"com.sun.star.comp.report.XMLSettingsExporter"_ustr,
|
||||
SvXMLExportFlags::SETTINGS);
|
||||
}
|
||||
|
||||
rtl::Reference<ORptExport>
|
||||
ORptExport::createStylesExporter(const Reference<XComponentContext>& rxContext)
|
||||
{
|
||||
return new ORptExport(rxContext, u"com.sun.star.comp.report.XMLStylesExporter"_ustr,
|
||||
SvXMLExportFlags::STYLES | SvXMLExportFlags::MASTERSTYLES
|
||||
| SvXMLExportFlags::AUTOSTYLES | SvXMLExportFlags::FONTDECLS
|
||||
| SvXMLExportFlags::OASIS);
|
||||
}
|
||||
|
||||
rtl::Reference<ORptExport>
|
||||
ORptExport::createMetaExporter(const Reference<XComponentContext>& rxContext)
|
||||
{
|
||||
return new ORptExport(rxContext, u"com.sun.star.comp.report.XMLMetaExporter"_ustr,
|
||||
SvXMLExportFlags::META);
|
||||
}
|
||||
|
||||
rtl::Reference<ORptExport>
|
||||
ORptExport::createExportFilter(const Reference<XComponentContext>& rxContext)
|
||||
{
|
||||
return new ORptExport(rxContext, u"com.sun.star.comp.report.ExportFilter"_ustr,
|
||||
SvXMLExportFlags::CONTENT | SvXMLExportFlags::AUTOSTYLES
|
||||
| SvXMLExportFlags::FONTDECLS);
|
||||
}
|
||||
|
||||
}// rptxml
|
||||
|
||||
|
||||
@@ -66,10 +66,6 @@
|
||||
constructor="reportdesign_ExportDocumentHandler_get_implementation">
|
||||
<service name="com.sun.star.report.ExportDocumentHandler"/>
|
||||
</implementation>
|
||||
<implementation name="com.sun.star.comp.report.ExportFilter"
|
||||
constructor="reportdesign_ORptExport_get_implementation">
|
||||
<service name="com.sun.star.document.ExportFilter"/>
|
||||
</implementation>
|
||||
<implementation name="com.sun.star.comp.report.ImportDocumentHandler"
|
||||
constructor="reportdesign_ImportDocumentHandler_get_implementation">
|
||||
<service name="com.sun.star.report.ImportDocumentHandler"/>
|
||||
@@ -82,16 +78,4 @@
|
||||
constructor="reportdesign_ORptTypeDetection_get_implementation">
|
||||
<service name="com.sun.star.document.ExtendedTypeDetection"/>
|
||||
</implementation>
|
||||
<implementation name="com.sun.star.comp.report.XMLMetaExporter"
|
||||
constructor="reportdesign_ORptMetaExportHelper_get_implementation">
|
||||
<service name="com.sun.star.document.ExportFilter"/>
|
||||
</implementation>
|
||||
<implementation name="com.sun.star.comp.report.XMLSettingsExporter"
|
||||
constructor="reportdesign_ORptExportHelper_get_implementation">
|
||||
<service name="com.sun.star.document.ExportFilter"/>
|
||||
</implementation>
|
||||
<implementation name="com.sun.star.comp.report.XMLStylesExporter"
|
||||
constructor="reportdesign_ORptStylesExportHelper_get_implementation">
|
||||
<service name="com.sun.star.document.ExportFilter"/>
|
||||
</implementation>
|
||||
</component>
|
||||
|
||||
Reference in New Issue
Block a user