12#include <libepubgen/EPUBTextGenerator.h>
13#include <libepubgen/libepubgen-decls.h>
15#include <com/sun/star/beans/PropertyAttribute.hpp>
16#include <com/sun/star/beans/XPropertySet.hpp>
17#include <com/sun/star/frame/XModel.hpp>
18#include <com/sun/star/lang/XInitialization.hpp>
19#include <com/sun/star/text/XPageCursor.hpp>
20#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
21#include <com/sun/star/uno/XComponentContext.hpp>
47 return libepubgen::EPUB_SPLIT_METHOD_HEADING;
52 return libepubgen::EPUB_LAYOUT_METHOD_REFLOWABLE;
61 OUString aFilterOptions;
62 for (
const auto& rProp : rDescriptor)
64 if (rProp.Name ==
"FilterData")
65 rProp.Value >>= aFilterData;
66 else if (rProp.Name ==
"FilterOptions")
67 rProp.Value >>= aFilterOptions;
70 if (aFilterOptions ==
"layout=fixed")
71 nLayoutMethod = libepubgen::EPUB_LAYOUT_METHOD_FIXED;
73 for (
const auto& rProp : std::as_const(aFilterData))
75 if (rProp.Name ==
"EPUBVersion")
77 else if (rProp.Name ==
"EPUBSplitMethod")
78 rProp.Value >>= nSplitMethod;
79 else if (rProp.Name ==
"EPUBLayoutMethod")
80 rProp.Value >>= nLayoutMethod;
87 libepubgen::EPUBTextGenerator aGenerator(&aPackage,
nVersion);
88 aGenerator.setOption(libepubgen::EPUB_GENERATOR_OPTION_SPLIT, nSplitMethod);
89 aGenerator.setOption(libepubgen::EPUB_GENERATOR_OPTION_LAYOUT, nLayoutMethod);
92 if (xSourceModel.is())
93 aSourceURL = xSourceModel->getURL();
95 std::vector<exp::FixedLayoutPage> aPageMetafiles;
96 if (nLayoutMethod == libepubgen::EPUB_LAYOUT_METHOD_FIXED)
103 mxContext->getServiceManager()->createInstanceWithContext(
104 "com.sun.star.comp.Writer.XMLOasisExporter",
mxContext),
110 beans::PropertyAttribute::MAYBEVOID, 0 } };
113 xInfoSet->setPropertyValue(
"BaseURI",
uno::Any(aSourceURL));
115 xInitialization->initialize({
uno::Any(xExportHandler),
uno::Any(xInfoSet) });
120 return xFilter->filter(rDescriptor);
131 xModel->getCurrentController(), uno::UNO_QUERY);
132 if (!xTextViewCursorSupplier.is())
140 xCursor->jumpToLastPage();
141 sal_Int16 nPages = xCursor->getPage();
142 for (sal_Int16 nPage = 1; nPage <= nPages; ++nPage)
147 Size aCss(
static_cast<double>(aLogic.
getWidth()) / 26.4583,
148 static_cast<double>(aLogic.
getHeight()) / 26.4583);
157 rGDIMetaFile.SetPrefMapMode(aMapMode);
158 rGDIMetaFile.SetPrefSize(aLogic);
162 aWriter.
Write(rGDIMetaFile);
164 aMemoryStream.
Tell());
170 rPageMetafiles.push_back(aPage);
183 return "com.sun.star.comp.Writer.EPUBExportFilter";
197extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
Size getDocumentSizeIn100mm(sal_Int32 nCurrentPage, Point *pDocumentPosition=nullptr, Point *pCalcPagePosition=nullptr, Size *pCalcPageSize=nullptr)
const std::vector< OUString > & getChapterNames() const
Graphic renderToGraphic(sal_Int32 nCurrentPage, Size aDocumentSizePixel, Size aTargetSizePixel, Color aPageColor, bool bExtOutDevData)
Size getDocumentSizeInPixels(sal_Int32 nCurrentPage)
const GDIMetaFile & GetGDIMetaFile() const
void SetMapUnit(MapUnit eUnit)
constexpr tools::Long getHeight() const
constexpr tools::Long getWidth() const
SvStream & Write(const GDIMetaFile &rMetaFile)
css::uno::Type const & get()
EPUB export XFilter implementation.
css::uno::Reference< css::lang::XComponent > mxSourceDocument
static sal_Int32 GetDefaultSplitMethod()
Gives the default split method.
void CreateMetafiles(std::vector< exp::FixedLayoutPage > &rPageMetafiles)
Create page metafiles in case of fixed layout.
OUString SAL_CALL getImplementationName() override
void SAL_CALL cancel() override
static sal_Int32 GetDefaultVersion()
Gives the default EPUB version.
static sal_Int32 GetDefaultLayoutMethod()
Gives the default layout method.
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
sal_Bool SAL_CALL filter(const css::uno::Sequence< css::beans::PropertyValue > &rDescriptor) override
void SAL_CALL setSourceDocument(const css::uno::Reference< css::lang::XComponent > &xDocument) override
EPUBExportFilter(css::uno::Reference< css::uno::XComponentContext > xContext)
css::uno::Reference< css::uno::XComponentContext > mxContext
The epub package has direct access to the resulting ZIP file.
ODT export feeds this class to make librevenge calls.
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
COMPHELPER_DLLPUBLIC css::uno::Reference< css::beans::XPropertySet > GenericPropertySet_CreateInstance(PropertySetInfo *pInfo)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Writer_EPUBExportFilter_get_implementation(uno::XComponentContext *pContext, uno::Sequence< uno::Any > const &)
Contains info about a fixed-layout page.
std::vector< OUString > aChapterNames
css::uno::Sequence< sal_Int8 > aMetafile
Reference< XModel > xModel