summaryrefslogtreecommitdiff
path: root/include/vcl/embeddedfontshelper.hxx
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 /include/vcl/embeddedfontshelper.hxx
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 'include/vcl/embeddedfontshelper.hxx')
-rw-r--r--include/vcl/embeddedfontshelper.hxx29
1 files changed, 22 insertions, 7 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