Kaydet (Commit) 0a049685 authored tarafından David Tardon's avatar David Tardon

read embedded fonts from Flat ODF

Change-Id: Ic94608f4afac9d8ac05ec3140d195b0526e9420a
üst 02266c33
......@@ -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;
}
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,
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment