tdf#119112: during epub export, each svg image appears twice

It's because by default LO also insert replacement image since svg is a vector format
but for epub we shouldn't use this mechanism.
So retrieve the old value of AddReplacementImages option and set it to false temporarily.

Change-Id: I5156c386a089fa0f88018872e546afc3a1e0b5f6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205807
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
This commit is contained in:
Julien Nabet
2026-05-28 17:32:33 +02:00
parent 3bfc07df1c
commit dd769ab47f
2 changed files with 21 additions and 1 deletions
+4
View File
@@ -35,6 +35,10 @@ $(eval $(call gb_Library_use_sdk_api,wpftwriter))
$(eval $(call gb_Library_use_common_precompiled_header,wpftwriter))
$(eval $(call gb_Library_use_custom_headers,wpftwriter,\
officecfg/registry \
))
$(eval $(call gb_Library_use_libraries,wpftwriter,\
comphelper \
cppu \
@@ -24,6 +24,7 @@
#include <comphelper/propertysetinfo.hxx>
#include <comphelper/sequenceashashmap.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <officecfg/Office/Common.hxx>
#include <svtools/DocumentToGraphicRenderer.hxx>
#include <vcl/filter/SvmWriter.hxx>
#include <vcl/gdimtf.hxx>
@@ -128,7 +129,22 @@ sal_Bool EPUBExportFilter::filter(const uno::Sequence<beans::PropertyValue>& rDe
xExporter->setSourceDocument(mxSourceDocument);
uno::Reference<document::XFilter> xFilter(xInitialization, uno::UNO_QUERY);
return xFilter->filter(rDescriptor);
// tdf#119112: when svg format is used, the image appears twice in the generated epub
// it's because by default LO also insert replacement image since svg is a vector format
// but for epub we shouldn't use this mechanism.
// So retrieve the old value of AddReplacementImages option and set it to false temporarily
bool bOldValue = officecfg::Office::Common::Save::Graphic::AddReplacementImages::get();
auto xChanges = comphelper::ConfigurationChanges::create();
officecfg::Office::Common::Save::Graphic::AddReplacementImages::set(false, xChanges);
xChanges->commit();
bool bReturn = xFilter->filter(rDescriptor);
officecfg::Office::Common::Save::Graphic::AddReplacementImages::set(bOldValue, xChanges);
xChanges->commit();
return bReturn;
}
void EPUBExportFilter::CreateMetafiles(std::vector<exp::FixedLayoutPage>& rPageMetafiles)