[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - xmloff/source
David Tardon
dtardon at redhat.com
Tue Jan 6 09:04:06 PST 2015
xmloff/source/style/XMLFontStylesContext.cxx | 27 +++++++++++++++++++---
xmloff/source/style/XMLFontStylesContext_impl.hxx | 8 ++++++
2 files changed, 32 insertions(+), 3 deletions(-)
New commits:
commit a9d191857372847fe198cb6036a9db2877289b4b
Author: David Tardon <dtardon at redhat.com>
Date: Mon Jan 5 16:45:25 2015 +0100
read embedded fonts from Flat ODF
Change-Id: Ic94608f4afac9d8ac05ec3140d195b0526e9420a
(cherry picked from commit 0a0496858905622374f9880b21b35ac1943c7a19)
Reviewed-on: https://gerrit.libreoffice.org/13751
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/xmloff/source/style/XMLFontStylesContext.cxx b/xmloff/source/style/XMLFontStylesContext.cxx
index 5f7dfa8..373e116 100644
--- a/xmloff/source/style/XMLFontStylesContext.cxx
+++ b/xmloff/source/style/XMLFontStylesContext.cxx
@@ -24,6 +24,8 @@
#include <com/sun/star/awt/FontPitch.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
+#include <comphelper/seqstream.hxx>
+
#include <osl/file.hxx>
#include <vcl/embeddedfontshelper.hxx>
@@ -33,6 +35,7 @@
#include "fonthdl.hxx"
#include <xmloff/xmlimp.hxx>
#include <xmloff/maptype.hxx>
+#include <xmloff/XMLBase64ImportContext.hxx>
using namespace ::com::sun::star;
@@ -251,6 +254,12 @@ SvXMLImportContext * XMLFontStyleContextFontFaceUri::CreateChildContext(
{
if( nPrefix == XML_NAMESPACE_SVG && IsXMLToken( rLocalName, XML_FONT_FACE_FORMAT ))
return new XMLFontStyleContextFontFaceFormat( GetImport(), nPrefix, rLocalName, xAttrList, *this );
+ if( linkPath.isEmpty() && ( nPrefix == XML_NAMESPACE_OFFICE ) && IsXMLToken( rLocalName, XML_BINARY_DATA ) )
+ {
+ mxBase64Stream.set( new comphelper::OSequenceOutputStream( maFontData ) );
+ if( mxBase64Stream.is() )
+ return new XMLBase64ImportContext( GetImport(), nPrefix, rLocalName, xAttrList, mxBase64Stream );
+ }
return SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
}
@@ -276,9 +285,9 @@ const char* EOT_FORMAT = "embedded-opentype";
void XMLFontStyleContextFontFaceUri::EndElement()
{
- if( linkPath.getLength() == 0 )
+ if( ( linkPath.getLength() == 0 ) && ( maFontData.getLength() == 0 ) )
{
- SAL_WARN( "xmloff", "svg:font-face-uri tag with no link; ignoring." );
+ SAL_WARN( "xmloff", "svg:font-face-uri tag with no link or base64 data; ignoring." );
return;
}
bool eot;
@@ -298,7 +307,10 @@ void XMLFontStyleContextFontFaceUri::EndElement()
SAL_WARN( "xmloff", "Unknown format of embedded font; assuming TTF." );
eot = false;
}
- handleEmbeddedFont( linkPath, eot );
+ if ( maFontData.getLength() == 0 )
+ handleEmbeddedFont( linkPath, eot );
+ else
+ handleEmbeddedFont( maFontData, eot );
}
void XMLFontStyleContextFontFaceUri::handleEmbeddedFont( const OUString& url, bool eot )
@@ -328,6 +340,15 @@ void XMLFontStyleContextFontFaceUri::handleEmbeddedFont( const OUString& url, bo
SAL_WARN( "xmloff", "External URL for font file not handled." );
}
+void XMLFontStyleContextFontFaceUri::handleEmbeddedFont( const ::css::uno::Sequence< sal_Int8 >& rData, const bool eot )
+{
+ const uno::Reference< io::XInputStream > xInput( new comphelper::SequenceInputStream( rData ) );
+ const OUString fontName = font.familyName();
+ if( EmbeddedFontsHelper::addEmbeddedFont( xInput, fontName, "?", std::vector< unsigned char >(), eot ) )
+ GetImport().NotifyEmbeddedFontRead();
+ xInput->closeInput();
+}
+
SvXMLStyleContext *XMLFontStylesContext::CreateStyleChildContext(
sal_uInt16 nPrefix,
const OUString& rLocalName,
diff --git a/xmloff/source/style/XMLFontStylesContext_impl.hxx b/xmloff/source/style/XMLFontStylesContext_impl.hxx
index 3938aa6..a1cfc11 100644
--- a/xmloff/source/style/XMLFontStylesContext_impl.hxx
+++ b/xmloff/source/style/XMLFontStylesContext_impl.hxx
@@ -22,6 +22,10 @@
#include <xmloff/xmlstyle.hxx>
+namespace com { namespace sun { namespace star { namespace io {
+ class XOutputStream;
+} } } }
+
/// Handles <style:font-face>
class XMLFontStyleContextFontFace : public SvXMLStyleContext
{
@@ -91,7 +95,11 @@ class XMLFontStyleContextFontFaceUri : public SvXMLStyleContext
const XMLFontStyleContextFontFace& font;
OUString format;
OUString linkPath;
+ ::css::uno::Sequence< sal_Int8 > maFontData;
+ ::css::uno::Reference< ::css::io::XOutputStream > mxBase64Stream;
+
void handleEmbeddedFont( const OUString& url, bool eot );
+ void handleEmbeddedFont( const ::css::uno::Sequence< sal_Int8 >& rData, bool eot );
public:
TYPEINFO_OVERRIDE();
More information about the Libreoffice-commits
mailing list