reportdesign/inc/ReportDefinition.hxx | 3 reportdesign/inc/xmlExport.hxx | 10 + reportdesign/source/core/api/ReportDefinition.cxx | 41 ++++---- reportdesign/source/filter/xml/xmlExport.cxx | 81 +++++----------- reportdesign/source/filter/xml/xmlfilter.cxx | 16 +-- reportdesign/source/ui/inspection/DefaultInspection.cxx | 8 - reportdesign/util/rpt.component | 16 --- 7 files changed, 74 insertions(+), 101 deletions(-)
New commits: commit 4fa6ea96dbb978a7f3e9d354765de610a98be026 Author: Michael Weghorn <[email protected]> AuthorDate: Tue Jul 15 15:26:36 2025 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Wed Jul 16 07:48:06 2025 +0200 reportdesign: Avoid runtime const char* -> OUString conversion Change-Id: Ie4b2dc2577804d8c62be1fc8273996305bb78247 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187916 Reviewed-by: Michael Weghorn <[email protected]> Tested-by: Jenkins diff --git a/reportdesign/source/ui/inspection/DefaultInspection.cxx b/reportdesign/source/ui/inspection/DefaultInspection.cxx index e7430f74dbf9..547bede49afd 100644 --- a/reportdesign/source/ui/inspection/DefaultInspection.cxx +++ b/reportdesign/source/ui/inspection/DefaultInspection.cxx @@ -158,12 +158,12 @@ namespace rptui const struct { - const char* programmaticName; + OUString programmaticName; TranslateId uiNameResId; OUString helpId; } aCategories[] = { - { "General", RID_STR_PROPPAGE_DEFAULT, HID_RPT_PROPDLG_TAB_GENERAL }, - { "Data", RID_STR_PROPPAGE_DATA, HID_RPT_PROPDLG_TAB_DATA }, + { u"General"_ustr, RID_STR_PROPPAGE_DEFAULT, HID_RPT_PROPDLG_TAB_GENERAL }, + { u"Data"_ustr, RID_STR_PROPPAGE_DATA, HID_RPT_PROPDLG_TAB_DATA }, }; const size_t nCategories = SAL_N_ELEMENTS( aCategories ); @@ -171,7 +171,7 @@ namespace rptui PropertyCategoryDescriptor* pReturn = aReturn.getArray(); for ( size_t i=0; i<nCategories; ++i, ++pReturn ) { - pReturn->ProgrammaticName = OUString::createFromAscii( aCategories[i].programmaticName ); + pReturn->ProgrammaticName = aCategories[i].programmaticName; pReturn->UIName = RptResId( aCategories[i].uiNameResId ); pReturn->HelpURL = HelpIdUrl::getHelpURL( aCategories[i].helpId ); } commit 2e011532fe5e2f613835bf70f5d5dcb3b8812882 Author: Michael Weghorn <[email protected]> AuthorDate: Tue Jul 15 15:13:39 2025 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Wed Jul 16 07:48:00 2025 +0200 reportdesign: Switch const char* param to const OUString& Change-Id: I336f28c0741362b9f91e57ba9239f462ddf279c7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187915 Reviewed-by: Michael Weghorn <[email protected]> Tested-by: Jenkins diff --git a/reportdesign/source/filter/xml/xmlfilter.cxx b/reportdesign/source/filter/xml/xmlfilter.cxx index 793f1dfe1098..3249b15641a3 100644 --- a/reportdesign/source/filter/xml/xmlfilter.cxx +++ b/reportdesign/source/filter/xml/xmlfilter.cxx @@ -167,7 +167,7 @@ static ErrCode ReadThroughComponent( static ErrCode ReadThroughComponent( const uno::Reference< embed::XStorage >& xStorage, const uno::Reference<XComponent>& xModelComponent, - const char* pStreamName, + const OUString& rStreamName, const uno::Reference<XComponentContext> & rxContext, const Reference<document::XGraphicStorageHandler> & rxGraphicStorageHandler, const Reference<document::XEmbeddedObjectResolver>& _xEmbeddedObjectResolver, @@ -175,7 +175,6 @@ static ErrCode ReadThroughComponent( ,const uno::Reference<beans::XPropertySet>& _xProp) { OSL_ENSURE( xStorage.is(), "Need storage!"); - OSL_ENSURE(nullptr != pStreamName, "Please, please, give me a name!"); if ( !xStorage ) // TODO/LATER: better error handling @@ -186,15 +185,14 @@ static ErrCode ReadThroughComponent( try { // open stream (and set parser input) - OUString sStreamName = OUString::createFromAscii(pStreamName); - if ( !xStorage->hasByName( sStreamName ) || !xStorage->isStreamElement( sStreamName ) ) + if (!xStorage->hasByName(rStreamName) || !xStorage->isStreamElement(rStreamName)) { // stream name not found! return immediately with OK signal return ERRCODE_NONE; } // get input stream - xDocStream = xStorage->openStreamElement( sStreamName, embed::ElementModes::READ ); + xDocStream = xStorage->openStreamElement(rStreamName, embed::ElementModes::READ); } catch (const packages::WrongPasswordException&) { @@ -437,7 +435,7 @@ bool ORptFilter::implImport( const Sequence< PropertyValue >& rDescriptor ) xProp->setPropertyValue(s_sStreamName, uno::Any(s_sMeta)); ErrCode nRet = ReadThroughComponent( xStorage ,xModel - ,"meta.xml" + , u"meta.xml"_ustr ,GetComponentContext() ,xGraphicStorageHandler ,xEmbeddedObjectResolver @@ -460,7 +458,7 @@ bool ORptFilter::implImport( const Sequence< PropertyValue >& rDescriptor ) xProp->setPropertyValue(s_sStreamName, uno::Any(u"settings.xml"_ustr)); nRet = ReadThroughComponent( xStorage ,xModel - ,"settings.xml" + , u"settings.xml"_ustr ,GetComponentContext() ,xGraphicStorageHandler ,xEmbeddedObjectResolver @@ -473,7 +471,7 @@ bool ORptFilter::implImport( const Sequence< PropertyValue >& rDescriptor ) xProp->setPropertyValue(s_sStreamName, uno::Any(u"styles.xml"_ustr)); nRet = ReadThroughComponent(xStorage ,xModel - ,"styles.xml" + , u"styles.xml"_ustr ,GetComponentContext() ,xGraphicStorageHandler ,xEmbeddedObjectResolver @@ -486,7 +484,7 @@ bool ORptFilter::implImport( const Sequence< PropertyValue >& rDescriptor ) xProp->setPropertyValue(s_sStreamName, uno::Any(u"content.xml"_ustr)); nRet = ReadThroughComponent( xStorage ,xModel - ,"content.xml" + , u"content.xml"_ustr ,GetComponentContext() ,xGraphicStorageHandler ,xEmbeddedObjectResolver commit 7189ad0d3617c86b5eb2571d1bdf1d5f3cc436cd Author: Michael Weghorn <[email protected]> AuthorDate: Tue Jul 15 14:53:43 2025 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Wed Jul 16 07:47:54 2025 +0200 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 <[email protected]> Reviewed-by: Michael Weghorn <[email protected]> diff --git a/reportdesign/inc/ReportDefinition.hxx b/reportdesign/inc/ReportDefinition.hxx index 8a25cfd9404f..ff80cc485636 100644 --- a/reportdesign/inc/ReportDefinition.hxx +++ b/reportdesign/inc/ReportDefinition.hxx @@ -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); diff --git a/reportdesign/inc/xmlExport.hxx b/reportdesign/inc/xmlExport.hxx index 788227cc7caa..37425ed843fc 100644 --- a/reportdesign/inc/xmlExport.hxx +++ b/reportdesign/inc/xmlExport.hxx @@ -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); }; diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx index 1585d161f99c..f68d7d34de17 100644 --- a/reportdesign/source/core/api/ReportDefinition.cxx +++ b/reportdesign/source/core/api/ReportDefinition.cxx @@ -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 diff --git a/reportdesign/source/filter/xml/xmlExport.cxx b/reportdesign/source/filter/xml/xmlExport.cxx index 145e632bd695..3cddcab63761 100644 --- a/reportdesign/source/filter/xml/xmlExport.cxx +++ b/reportdesign/source/filter/xml/xmlExport.cxx @@ -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 diff --git a/reportdesign/util/rpt.component b/reportdesign/util/rpt.component index 26c8e879cc6b..857c2c2f00c6 100644 --- a/reportdesign/util/rpt.component +++ b/reportdesign/util/rpt.component @@ -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>
