[Libreoffice-commits] core.git: writerperfect/source
Miklos Vajna
vmiklos at collabora.co.uk
Tue Aug 1 14:46:05 UTC 2017
writerperfect/source/writer/EPUBExportFilter.cxx | 25 +++++++++++++++++------
writerperfect/source/writer/EPUBExportFilter.hxx | 4 ++-
2 files changed, 22 insertions(+), 7 deletions(-)
New commits:
commit a0abb2f6a4e2392ce44634a58f3a5d1af1868499
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Aug 1 15:09:03 2017 +0200
EPUB export: invoke the underlying ODT exporter
The document handler is still missing, though.
Change-Id: I26aa9c2211fafb311e297f48d4301c0c26ec8edf
Reviewed-on: https://gerrit.libreoffice.org/40636
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
diff --git a/writerperfect/source/writer/EPUBExportFilter.cxx b/writerperfect/source/writer/EPUBExportFilter.cxx
index d7fb0cac0e0d..36cff7ab9dd6 100644
--- a/writerperfect/source/writer/EPUBExportFilter.cxx
+++ b/writerperfect/source/writer/EPUBExportFilter.cxx
@@ -9,7 +9,9 @@
#include "EPUBExportFilter.hxx"
+#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
#include <cppuhelper/supportsservice.hxx>
@@ -18,14 +20,25 @@ using namespace com::sun::star;
namespace writerperfect
{
-EPUBExportFilter::EPUBExportFilter()
+EPUBExportFilter::EPUBExportFilter(const uno::Reference<uno::XComponentContext> &xContext)
+ : mxContext(xContext)
{
}
-sal_Bool EPUBExportFilter::filter(const uno::Sequence<beans::PropertyValue> &/*rDescriptor*/)
+sal_Bool EPUBExportFilter::filter(const uno::Sequence<beans::PropertyValue> &rDescriptor)
{
- SAL_WARN("writerperfect", "EPUBExportFilter::filter: implement me");
- return true;
+ // Create ODT exporter, this will feed our document handler.
+ uno::Reference<lang::XInitialization> xInitialization(mxContext->getServiceManager()->createInstanceWithContext("com.sun.star.comp.Writer.XMLOasisExporter", mxContext), uno::UNO_QUERY);
+
+ // The document handler will make the calls on the text interface provided by the EPUB export.
+ uno::Reference<xml::sax::XDocumentHandler> xExportHandler;
+
+ // Let the ODT exporter read the doc model and invoke the doc handler.
+ xInitialization->initialize({uno::makeAny(xExportHandler)});
+ uno::Reference<document::XExporter> xExporter(xInitialization, uno::UNO_QUERY);
+ xExporter->setSourceDocument(mxSourceDocument);
+ uno::Reference<document::XFilter> xFilter(xInitialization, uno::UNO_QUERY);
+ return xFilter->filter(rDescriptor);
}
void EPUBExportFilter::cancel()
@@ -56,9 +69,9 @@ uno::Sequence<OUString> EPUBExportFilter::getSupportedServiceNames()
return aRet;
}
-extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface *SAL_CALL com_sun_star_comp_Writer_EPUBExportFilter_get_implementation(uno::XComponentContext *, uno::Sequence<uno::Any> const &)
+extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface *SAL_CALL com_sun_star_comp_Writer_EPUBExportFilter_get_implementation(uno::XComponentContext *pContext, uno::Sequence<uno::Any> const &)
{
- return cppu::acquire(new EPUBExportFilter);
+ return cppu::acquire(new EPUBExportFilter(pContext));
}
} // namespace writerperfect
diff --git a/writerperfect/source/writer/EPUBExportFilter.hxx b/writerperfect/source/writer/EPUBExportFilter.hxx
index 101a4f85bf42..10f39dcfbef4 100644
--- a/writerperfect/source/writer/EPUBExportFilter.hxx
+++ b/writerperfect/source/writer/EPUBExportFilter.hxx
@@ -15,6 +15,7 @@
#include <com/sun/star/document/XFilter.hpp>
#include <com/sun/star/document/XExporter.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
namespace writerperfect
{
@@ -27,10 +28,11 @@ class EPUBExportFilter : public cppu::WeakImplHelper
css::lang::XServiceInfo
>
{
+ css::uno::Reference<css::uno::XComponentContext> mxContext;
css::uno::Reference<css::lang::XComponent> mxSourceDocument;
public:
- EPUBExportFilter();
+ EPUBExportFilter(const css::uno::Reference<css::uno::XComponentContext> &xContext);
// XFilter
sal_Bool SAL_CALL filter(const css::uno::Sequence<css::beans::PropertyValue> &rDescriptor) override;
More information about the Libreoffice-commits
mailing list