Improved html parser.

Transformations adjusted to iwb specification.
preferencesAboutTextFull
Aleksei Kanash 13 years ago
parent 82c155ca28
commit 2a1a6ebf46
  1. 20
      plugins/cffadaptor/src/UBCFFAdaptor.cpp

@ -443,7 +443,6 @@ bool UBCFFAdaptor::UBToCFFConverter::parseMetadata()
QSize tmpSize = getSVGDimentions(nextInElement.text()); QSize tmpSize = getSVGDimentions(nextInElement.text());
if (!tmpSize.isNull()) { if (!tmpSize.isNull()) {
mSVGSize = tmpSize; mSVGSize = tmpSize;
mViewbox.setRect(0,0, tmpSize.width(), tmpSize.height());
} else { } else {
qDebug() << "can't interpret svg section size"; qDebug() << "can't interpret svg section size";
errorStr = "InterpretSvgSizeError"; errorStr = "InterpretSvgSizeError";
@ -487,6 +486,11 @@ bool UBCFFAdaptor::UBToCFFConverter::parseContent() {
} }
if (QRect() == mViewbox)
{
mViewbox.setRect(0,0, mSVGSize.width(), mSVGSize.height());
}
svgDocumentSection.setAttribute(aIWBViewBox, rectToIWBAttr(mViewbox)); svgDocumentSection.setAttribute(aIWBViewBox, rectToIWBAttr(mViewbox));
svgDocumentSection.setAttribute(aWidth, QString("%1").arg(mViewbox.width())); svgDocumentSection.setAttribute(aWidth, QString("%1").arg(mViewbox.width()));
svgDocumentSection.setAttribute(aHeight, QString("%1").arg(mViewbox.height())); svgDocumentSection.setAttribute(aHeight, QString("%1").arg(mViewbox.height()));
@ -639,7 +643,7 @@ QDomElement UBCFFAdaptor::UBToCFFConverter::parseSvgPageSection(const QDomElemen
void UBCFFAdaptor::UBToCFFConverter::writeQDomElementToXML(const QDomNode &node) void UBCFFAdaptor::UBToCFFConverter::writeQDomElementToXML(const QDomNode &node)
{ {
if (!node.isNull()){ if (!node.isNull())
if (node.isText()) if (node.isText())
{ {
mIWBContentWriter->writeCharacters(node.nodeValue()); mIWBContentWriter->writeCharacters(node.nodeValue());
@ -662,7 +666,6 @@ void UBCFFAdaptor::UBToCFFConverter::writeQDomElementToXML(const QDomNode &node)
mIWBContentWriter->writeEndElement(); mIWBContentWriter->writeEndElement();
} }
}
} }
bool UBCFFAdaptor::UBToCFFConverter::writeExtendedIwbSection() bool UBCFFAdaptor::UBToCFFConverter::writeExtendedIwbSection()
@ -1025,8 +1028,6 @@ void UBCFFAdaptor::UBToCFFConverter::setCoordinatesFromUBZ(const QDomElement &ub
item.setRect(0,0, width, height); item.setRect(0,0, width, height);
item.setTransform(tr); item.setTransform(tr);
item.setTransformOriginPoint(item.boundingRect().center());
item.setRotation(-alpha); item.setRotation(-alpha);
QMatrix sceneMatrix = item.sceneMatrix(); QMatrix sceneMatrix = item.sceneMatrix();
@ -1107,6 +1108,9 @@ bool UBCFFAdaptor::UBToCFFConverter::setContentFromUBZ(const QDomElement &ubzEle
svgElement.setAttribute(aSVGRequiredExtension, svgRequiredExtensionPrefix+fePng); svgElement.setAttribute(aSVGRequiredExtension, svgRequiredExtensionPrefix+fePng);
} }
} }
}else
{
bRet = false;
} }
if (!bRet) if (!bRet)
@ -1142,7 +1146,6 @@ void UBCFFAdaptor::UBToCFFConverter::setCFFTextFromHTMLTextNode(const QDomElemen
QDomNode spanNode = htmlPNode.firstChild(); QDomNode spanNode = htmlPNode.firstChild();
while (!spanNode.isNull()) while (!spanNode.isNull())
{ {
if (spanNode.isText()) if (spanNode.isText())
@ -1153,7 +1156,10 @@ void UBCFFAdaptor::UBToCFFConverter::setCFFTextFromHTMLTextNode(const QDomElemen
else else
if (spanNode.isElement()) if (spanNode.isElement())
{ {
QDomElement pElementIwb;
QDomElement spanElement = textDoc.createElementNS(svgIWBNS,svgIWBNSPrefix + ":" + tIWBTspan); QDomElement spanElement = textDoc.createElementNS(svgIWBNS,svgIWBNSPrefix + ":" + tIWBTspan);
setCommonAttributesFromUBZ(htmlPNode.toElement(), pElementIwb, spanElement);
if (spanNode.hasAttributes()) if (spanNode.hasAttributes())
{ {
int attrCount = spanNode.attributes().count(); int attrCount = spanNode.attributes().count();
@ -1196,6 +1202,8 @@ QString UBCFFAdaptor::UBToCFFConverter::ubzAttrNameToCFFAttrName(QString cffAttr
QString sRet = cffAttrName; QString sRet = cffAttrName;
if (QString("color") == cffAttrName) if (QString("color") == cffAttrName)
sRet = QString("fill"); sRet = QString("fill");
if (QString("align") == cffAttrName)
sRet = QString("text-align");
return sRet; return sRet;
} }

Loading…
Cancel
Save