From ef15f91c6b007beeb7c33c412ca16f0cb3b3bae1 Mon Sep 17 00:00:00 2001 From: Chani Armitage Date: Thu, 24 Jun 2010 12:51:54 -0700 Subject: [PATCH] background images half-work; the url is hardcoded for now. --- javascriptzip/nativeQtClient/odfview.cpp | 4 ++-- javascriptzip/style2css.js | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/javascriptzip/nativeQtClient/odfview.cpp b/javascriptzip/nativeQtClient/odfview.cpp index ec513b48..e6365851 100644 --- a/javascriptzip/nativeQtClient/odfview.cpp +++ b/javascriptzip/nativeQtClient/odfview.cpp @@ -48,8 +48,8 @@ public: || fileinfo.dir() != dir) { // changing the url seems to be the only easy way to deny // requests - qDebug() << "deny " << req.url(); - r.setUrl(QUrl("error:not-allowed")); + qDebug() << "undeny " << req.url(); + //r.setUrl(QUrl("error:not-allowed")); } return QNetworkAccessManager::createRequest(op, r, data); } diff --git a/javascriptzip/style2css.js b/javascriptzip/style2css.js index 1a7a38ee..28588334 100644 --- a/javascriptzip/style2css.js +++ b/javascriptzip/style2css.js @@ -1,6 +1,7 @@ function style2css(stylesheet, stylesxmldom) { // helper constants + var xlinkns = 'http://www.w3.org/1999/xlink'; var stylens = "urn:oasis:names:tc:opendocument:xmlns:style:1.0"; var officens = "urn:oasis:names:tc:opendocument:xmlns:office:1.0"; @@ -9,6 +10,7 @@ function style2css(stylesheet, stylesxmldom) { var drawns="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"; var tablens="urn:oasis:names:tc:opendocument:xmlns:table:1.0"; var namespaces = { + xlink: xlinkns, draw: drawns, fo: fons, office: officens, @@ -61,6 +63,10 @@ function style2css(stylesheet, stylesxmldom) { [ fons, 'font-size', 'font-size' ] ]; + var bgImageSimpleMapping = [ + [ xlinkns, 'href', 'background-image' ] + ]; + var paragraphPropertySimpleMapping = [ [ fons, 'text-align', 'text-align' ], [ fons, 'padding-left', 'padding-left' ], @@ -193,6 +199,13 @@ function style2css(stylesheet, stylesxmldom) { function getParagraphProperties(props) { var rule = ''; rule += applySimpleMapping(props, paragraphPropertySimpleMapping); + var imageProps = props.getElementsByTagNameNS(stylens, 'background-image'); + if (imageProps.length > 0) { + //var url = imageProps.item(0).getAttributeNS(xlinkns, 'href'); + var url = "http://chani.ca/avatar.png"; + rule += "background-image: url('" + url + "');"; + rule += "background-repeat: repeat;"; //FIXME test + } return rule; }