summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/core/xmltoken.cxx1
-rw-r--r--xmloff/source/style/XMLFontStylesContext.cxx67
-rw-r--r--xmloff/source/style/XMLFontStylesContext_impl.hxx33
3 files changed, 97 insertions, 4 deletions
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 40511048b7a9..dedb2b48ec49 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -2486,6 +2486,7 @@ namespace xmloff { namespace token {
TOKEN( "font-face", XML_FONT_FACE ),
TOKEN( "font-face-src", XML_FONT_FACE_SRC ),
TOKEN( "font-face-uri", XML_FONT_FACE_URI ),
+ TOKEN( "font-face-format", XML_FONT_FACE_FORMAT ),
TOKEN( "font-adornments", XML_FONT_ADORNMENTS ),
TOKEN( "inch", XML_INCH ),
TOKEN( "space-after", XML_SPACE_AFTER ),
diff --git a/xmloff/source/style/XMLFontStylesContext.cxx b/xmloff/source/style/XMLFontStylesContext.cxx
index 33f998a2579c..29f480864a29 100644
--- a/xmloff/source/style/XMLFontStylesContext.cxx
+++ b/xmloff/source/style/XMLFontStylesContext.cxx
@@ -190,6 +190,26 @@ OUString XMLFontStyleContextFontFace::familyName() const
return ret;
}
+TYPEINIT1( XMLFontStyleContextFontFaceFormat, SvXMLStyleContext );
+
+XMLFontStyleContextFontFaceFormat::XMLFontStyleContextFontFaceFormat( SvXMLImport& rImport,
+ sal_uInt16 nPrfx, const OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > &xAttrList,
+ XMLFontStyleContextFontFaceUri& _uri )
+ : SvXMLStyleContext( rImport, nPrfx, rLName, xAttrList)
+ , uri(_uri)
+{
+}
+
+void XMLFontStyleContextFontFaceFormat::SetAttribute( sal_uInt16 nPrefixKey, const OUString& rLocalName,
+ const OUString& rValue )
+{
+ if( nPrefixKey == XML_NAMESPACE_SVG && IsXMLToken( rLocalName, XML_STRING ))
+ uri.SetFormat(rValue);
+ else
+ SvXMLStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
+}
TYPEINIT1( XMLFontStyleContextFontFaceSrc, SvXMLImportContext );
@@ -224,16 +244,57 @@ XMLFontStyleContextFontFaceUri::XMLFontStyleContextFontFaceUri( SvXMLImport& rIm
{
}
+SvXMLImportContext * XMLFontStyleContextFontFaceUri::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList )
+{
+ if( nPrefix == XML_NAMESPACE_SVG && IsXMLToken( rLocalName, XML_FONT_FACE_FORMAT ))
+ return new XMLFontStyleContextFontFaceFormat( GetImport(), nPrefix, rLocalName, xAttrList, *this );
+ return SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
+}
+
void XMLFontStyleContextFontFaceUri::SetAttribute( sal_uInt16 nPrefixKey, const OUString& rLocalName,
const OUString& rValue )
{
if( nPrefixKey == XML_NAMESPACE_XLINK && IsXMLToken( rLocalName, XML_HREF ))
- handleEmbeddedFont( rValue );
+ linkPath = rValue;
else
SvXMLStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
}
-void XMLFontStyleContextFontFaceUri::handleEmbeddedFont( const OUString& url )
+void XMLFontStyleContextFontFaceUri::SetFormat( const OUString& rFormat )
+{
+ format = rFormat;
+}
+void XMLFontStyleContextFontFaceUri::EndElement()
+{
+ if( linkPath.getLength() == 0 )
+ {
+ SAL_WARN( "xmloff", "svg:font-face-uri tag with no link; ignoring." );
+ return;
+ }
+ bool eot;
+ // Assume by default that the font is not compressed.
+ if( format.getLength() == 0
+ || format.equalsAscii( OPENTYPE_FORMAT )
+ || format.equalsAscii( TRUETYPE_FORMAT ))
+ {
+ eot = false;
+ }
+ else if( format.equalsAscii( EOT_FORMAT ))
+ {
+ eot = true;
+ }
+ else
+ {
+ SAL_WARN( "xmloff", "Unknown format of embedded font; assuming TTF." );
+ eot = false;
+ }
+ handleEmbeddedFont( linkPath, eot );
+}
+
+void XMLFontStyleContextFontFaceUri::handleEmbeddedFont( const OUString& url, bool eot )
{
if( GetImport().embeddedFontAlreadyProcessed( url ))
{
@@ -252,7 +313,7 @@ void XMLFontStyleContextFontFaceUri::handleEmbeddedFont( const OUString& url )
uno::Reference< io::XInputStream > inputStream;
inputStream.set( storage->openStreamElement( url.copy( url.indexOf( '/' ) + 1 ), ::embed::ElementModes::READ ),
UNO_QUERY_THROW );
- if( EmbeddedFontsHelper::addEmbeddedFont( inputStream, fontName, "?" ))
+ if( EmbeddedFontsHelper::addEmbeddedFont( inputStream, fontName, "?", std::vector< unsigned char >(), eot ))
GetImport().NotifyEmbeddedFontRead();
inputStream->closeInput();
}
diff --git a/xmloff/source/style/XMLFontStylesContext_impl.hxx b/xmloff/source/style/XMLFontStylesContext_impl.hxx
index 81e1b7afdaa2..6ad621f265e3 100644
--- a/xmloff/source/style/XMLFontStylesContext_impl.hxx
+++ b/xmloff/source/style/XMLFontStylesContext_impl.hxx
@@ -88,8 +88,16 @@ public:
/// Handles <style:font-face-uri>
class XMLFontStyleContextFontFaceUri : public SvXMLStyleContext
{
+ // the CSS2 standard ( http://www.w3.org/TR/2008/REC-CSS2-20080411/fonts.html#referencing )
+ // defines these format strings.
+ const char* OPENTYPE_FORMAT = "opentype";
+ const char* TRUETYPE_FORMAT = "truetype";
+ const char* EOT_FORMAT = "embedded-opentype";
+
const XMLFontStyleContextFontFace& font;
- void handleEmbeddedFont( const OUString& url );
+ OUString format;
+ OUString linkPath;
+ void handleEmbeddedFont( const OUString& url, bool eot );
public:
TYPEINFO();
@@ -102,6 +110,29 @@ public:
virtual void SetAttribute( sal_uInt16 nPrefixKey, const OUString& rLocalName,
const OUString& rValue );
+ void SetFormat( const OUString& rFormat );
+ void EndElement();
+ SvXMLImportContext * CreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
+};
+
+/// Handles <svg:font-face-format>
+class XMLFontStyleContextFontFaceFormat : public SvXMLStyleContext
+{
+ XMLFontStyleContextFontFaceUri& uri;
+public:
+ TYPEINFO();
+
+ XMLFontStyleContextFontFaceFormat( SvXMLImport& rImport, sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
+ XMLFontStyleContextFontFaceUri& uri );
+
+ void SetAttribute( sal_uInt16 nPrefixKey, const OUString& rLocalName,
+ const OUString& rValue );
};
#endif