diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-10-28 15:11:36 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-10-29 10:14:16 +0100 |
commit | 388735924392027eb6a8e722083e6496b92a40fa (patch) | |
tree | 112aaf7591c9fef82d3415fe8e16c0263a1a2383 /include | |
parent | e58592414da353aaef9432277d7155fc0c0f0213 (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 'include')
-rw-r--r-- | include/vcl/embeddedfontshelper.hxx | 29 | ||||
-rw-r--r-- | include/xmloff/xmlimp.hxx | 12 |
2 files changed, 33 insertions, 8 deletions
diff --git a/include/vcl/embeddedfontshelper.hxx b/include/vcl/embeddedfontshelper.hxx index e1f2e5c28ece..c1c98eaf0694 100644 --- a/include/vcl/embeddedfontshelper.hxx +++ b/include/vcl/embeddedfontshelper.hxx @@ -26,6 +26,18 @@ namespace com::sun::star::uno { template <typename > class Reference; } */ class VCL_DLLPUBLIC EmbeddedFontsHelper { +private: + std::vector<std::pair<OUString, OUString>> m_aAccumulatedFonts; + + /** + Adds the given font to the list of known fonts. The font is used only until application + exit. + + @param fontName name of the font (e.g. 'Times New Roman') + @param fileUrl URL of the font file + */ + static void activateFont( const OUString& fontName, const OUString& fileUrl ); + public: /// Specification of what kind of operation is allowed when embedding a font enum class FontRights @@ -41,14 +53,15 @@ public: FontWeight weight, FontPitch pitch, FontRights rights ); /** - Reads a font from the input stream, saves it to a temporary font file and activates the font. + Reads a font from the input stream, saves it to a temporary font file and adds it to the list of + fonts that activateFonts will activate. @param stream stream of font data @param fontName name of the font (e.g. 'Times New Roman') @param extra additional text to use for name (e.g. to distinguish regular from bold, italic,...), "?" for unique @param key key to xor the data with, from the start until the key's length (not repeated) @param eot whether the data is compressed in Embedded OpenType format */ - static bool addEmbeddedFont( const css::uno::Reference< css::io::XInputStream >& stream, + bool addEmbeddedFont( const css::uno::Reference< css::io::XInputStream >& stream, const OUString& fontName, const char* extra, std::vector< unsigned char > key, bool eot = false); @@ -63,13 +76,10 @@ public: static OUString fileUrlForTemporaryFont( const OUString& fontName, const char* extra ); /** - Adds the given font to the list of known fonts. The font is used only until application + Adds the accumulated fonts to the list of known fonts. The fonts are used only until application exit. - - @param fontName name of the font (e.g. 'Times New Roman') - @param fileUrl URL of the font file */ - static void activateFont( const OUString& fontName, const OUString& fileUrl ); + void activateFonts(); /** Returns if the restrictions specified in the font (if present) allow embedding @@ -85,6 +95,11 @@ public: @internal */ static void clearTemporaryFontFiles(); + + ~EmbeddedFontsHelper() + { + activateFonts(); + } }; #endif diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx index bfc2cbeb028f..48d4425edee1 100644 --- a/include/xmloff/xmlimp.hxx +++ b/include/xmloff/xmlimp.hxx @@ -74,7 +74,7 @@ namespace xmloff { namespace xmloff::token { class FastTokenHandler; } - +class EmbeddedFontsHelper; class ProgressBarHelper; class SvXMLNamespaceMap; class SvXMLImport_Impl; @@ -246,6 +246,10 @@ class XMLOFF_DLLPUBLIC SvXMLImport : public cppu::WeakImplHelper< css::uno::Reference< css::task::XStatusIndicator > mxStatusIndicator; + // tdf#69060 & tdf#137643 import embedded fonts and activate them in a + // batch in EmbeddedFontsHelper's dtor + std::unique_ptr<EmbeddedFontsHelper> mxEmbeddedFontHelper; + protected: bool mbIsFormsSupported; bool mbIsTableShapeSupported; @@ -582,7 +586,13 @@ public: */ bool embeddedFontAlreadyProcessed( const OUString& url ); + // see EmbeddedFontsHelper::addEmbeddedFont + bool addEmbeddedFont( const css::uno::Reference< css::io::XInputStream >& stream, + const OUString& fontName, const char* extra, + std::vector< unsigned char > key, bool eot); + virtual void NotifyEmbeddedFontRead() {}; + // something referencing a macro/script was imported void NotifyMacroEventRead(); |