summaryrefslogtreecommitdiff
path: root/writerfilter/source/dmapper
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-10-28 15:11:36 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-10-29 10:14:16 +0100
commit388735924392027eb6a8e722083e6496b92a40fa (patch)
tree112aaf7591c9fef82d3415fe8e16c0263a1a2383 /writerfilter/source/dmapper
parente58592414da353aaef9432277d7155fc0c0f0213 (diff)
tdf#137643 alternative solution to activate embedded fonts in one batch
Change-Id: Ib5ffb2b8a31f237d5d2e465bf3f777590e0bfade Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104947 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'writerfilter/source/dmapper')
-rw-r--r--writerfilter/source/dmapper/FontTable.cxx17
-rw-r--r--writerfilter/source/dmapper/FontTable.hxx9
2 files changed, 21 insertions, 5 deletions
diff --git a/writerfilter/source/dmapper/FontTable.cxx b/writerfilter/source/dmapper/FontTable.cxx
index 3c74e97d0adc..c98177db5959 100644
--- a/writerfilter/source/dmapper/FontTable.cxx
+++ b/writerfilter/source/dmapper/FontTable.cxx
@@ -32,6 +32,7 @@ namespace writerfilter::dmapper
struct FontTable_Impl
{
+ std::unique_ptr<EmbeddedFontsHelper> xEmbeddedFontHelper;
std::vector< FontEntry::Pointer_t > aFontEntries;
FontEntry::Pointer_t pCurrentEntry;
FontTable_Impl() {}
@@ -115,7 +116,7 @@ void FontTable::lcl_sprm(Sprm& rSprm)
writerfilter::Reference< Properties >::Pointer_t pProperties = rSprm.getProps();
if( pProperties )
{
- EmbeddedFontHandler handler( m_pImpl->pCurrentEntry->sFontName,
+ EmbeddedFontHandler handler(*this, m_pImpl->pCurrentEntry->sFontName,
nSprmId == NS_ooxml::LN_CT_Font_embedRegular ? ""
: nSprmId == NS_ooxml::LN_CT_Font_embedBold ? "b"
: nSprmId == NS_ooxml::LN_CT_Font_embedItalic ? "i"
@@ -222,8 +223,18 @@ sal_uInt32 FontTable::size()
return m_pImpl->aFontEntries.size();
}
-EmbeddedFontHandler::EmbeddedFontHandler( const OUString& _fontName, const char* _style )
+bool FontTable::addEmbeddedFont(const css::uno::Reference<css::io::XInputStream>& stream,
+ const OUString& fontName, const char* extra,
+ std::vector<unsigned char> key)
+{
+ if (!m_pImpl->xEmbeddedFontHelper)
+ m_pImpl->xEmbeddedFontHelper.reset(new EmbeddedFontsHelper);
+ return m_pImpl->xEmbeddedFontHelper->addEmbeddedFont(stream, fontName, extra, key);
+}
+
+EmbeddedFontHandler::EmbeddedFontHandler(FontTable& rFontTable, const OUString& _fontName, const char* _style )
: LoggedProperties("EmbeddedFontHandler")
+, fontTable( rFontTable )
, fontName( _fontName )
, style( _style )
{
@@ -252,7 +263,7 @@ EmbeddedFontHandler::~EmbeddedFontHandler()
key[ i + 16 ] = val;
}
}
- EmbeddedFontsHelper::addEmbeddedFont( inputStream, fontName, style, key );
+ fontTable.addEmbeddedFont( inputStream, fontName, style, key );
inputStream->closeInput();
}
diff --git a/writerfilter/source/dmapper/FontTable.hxx b/writerfilter/source/dmapper/FontTable.hxx
index e81876e4abdf..1569ebf56e48 100644
--- a/writerfilter/source/dmapper/FontTable.hxx
+++ b/writerfilter/source/dmapper/FontTable.hxx
@@ -21,6 +21,7 @@
#define INCLUDED_WRITERFILTER_SOURCE_DMAPPER_FONTTABLE_HXX
#include <memory>
+#include <vector>
#include "LoggedResources.hxx"
#include <com/sun/star/io/XInputStream.hpp>
@@ -51,6 +52,10 @@ class FontTable : public LoggedProperties, public LoggedTable
sal_uInt32 size();
FontEntry::Pointer_t getFontEntry(sal_uInt32 nIndex);
+ bool addEmbeddedFont(const css::uno::Reference<css::io::XInputStream>& stream,
+ const OUString& fontName, const char* extra,
+ std::vector<unsigned char> key);
+
private:
// Properties
virtual void lcl_attribute(Id Name, Value & val) override;
@@ -76,18 +81,18 @@ class FontTable : public LoggedProperties, public LoggedTable
::writerfilter::Reference<Stream>::Pointer_t ref) override;
virtual void lcl_startShape(css::uno::Reference<css::drawing::XShape> const& xShape) override;
virtual void lcl_endShape( ) override;
-
};
typedef tools::SvRef< FontTable > FontTablePtr;
class EmbeddedFontHandler : public LoggedProperties
{
public:
- EmbeddedFontHandler( const OUString& fontName, const char* style );
+ EmbeddedFontHandler(FontTable& rFontTable, const OUString& fontName, const char* style);
virtual ~EmbeddedFontHandler() override;
private:
virtual void lcl_attribute( Id name, Value& val ) override;
virtual void lcl_sprm( Sprm& rSprm ) override;
+ FontTable& fontTable;
OUString fontName;
const char* const style;
OUString fontKey;