|
|
@ -2268,50 +2268,22 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::textItemToSvg(UBGraphicsTextItem* it |
|
|
|
, "fill-on-light-background", colorLightBg.name()); |
|
|
|
, "fill-on-light-background", colorLightBg.name()); |
|
|
|
|
|
|
|
|
|
|
|
//for new documents from version 4.5.0
|
|
|
|
//for new documents from version 4.5.0
|
|
|
|
if (true) { |
|
|
|
|
|
|
|
mXmlWriter.writeStartElement("itemTextContent"); |
|
|
|
mXmlWriter.writeStartElement("itemTextContent"); |
|
|
|
mXmlWriter.writeCDATA(item->toHtml()); |
|
|
|
|
|
|
|
mXmlWriter.writeEndElement(); //itemTextContent
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//tracking for back capability with older versions
|
|
|
|
|
|
|
|
} else if (false) { |
|
|
|
|
|
|
|
mXmlWriter.writeStartElement(nsXHtml, "body"); |
|
|
|
|
|
|
|
mXmlWriter.writeStartElement(nsXHtml, "div"); |
|
|
|
|
|
|
|
mXmlWriter.writeStartElement(nsXHtml, "font"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QFont font = item->font(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mXmlWriter.writeAttribute("face", font.family()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QFontInfo fi(font); |
|
|
|
//TODO:
|
|
|
|
int pixelSize = fi.pixelSize(); |
|
|
|
// This is only a workaround that works quite well. The font sizes are expressed on
|
|
|
|
|
|
|
|
// px instead of pt because px is less sensitive to the physicalDPI of the Os. The
|
|
|
|
mXmlWriter.writeAttribute("style", sFontSizePrefix + QString(" %1").arg(pixelSize) + sPixelUnit + "; " + |
|
|
|
// main problem in fact appears when the file is used on another platform than the
|
|
|
|
sFontWeightPrefix + " " + (fi.bold() ? "bold" : "normal") + "; " + |
|
|
|
// one used to create it.
|
|
|
|
sFontStylePrefix + " " + (fi.italic() ? "italic" : "normal") + ";"); |
|
|
|
// But a different solution has to be implemented to avoid some annoying case that
|
|
|
|
mXmlWriter.writeAttribute("color", item->defaultTextColor().name()); |
|
|
|
// are already present with this hack.
|
|
|
|
|
|
|
|
QString htmlString = item->toHtml(); |
|
|
|
QString text = item->toPlainText(); |
|
|
|
QRegExp regExp("font-size:([0-9]{,3})pt"); |
|
|
|
QStringList lines = text.split("\n"); |
|
|
|
htmlString = htmlString.replace(regExp,"font-size:\\1px"); |
|
|
|
|
|
|
|
mXmlWriter.writeCDATA(htmlString); |
|
|
|
for (int i = 0; i < lines.length() ; i++) |
|
|
|
mXmlWriter.writeEndElement(); //itemTextContent
|
|
|
|
{ |
|
|
|
|
|
|
|
mXmlWriter.writeCharacters(lines.at(i)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (i < lines.length() - 1) |
|
|
|
|
|
|
|
mXmlWriter.writeEmptyElement(nsXHtml, "br"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mXmlWriter.writeEndElement(); //font
|
|
|
|
|
|
|
|
mXmlWriter.writeEndElement(); //div
|
|
|
|
|
|
|
|
mXmlWriter.writeEndElement(); //body
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mXmlWriter.writeEndElement(); //foreignObject
|
|
|
|
mXmlWriter.writeEndElement(); //foreignObject
|
|
|
|
|
|
|
|
|
|
|
|
// QtLogger::start("/home/ilia/Documents/tmp/10/log.log");
|
|
|
|
|
|
|
|
// QtLogger::appendl(item->toHtml());
|
|
|
|
|
|
|
|
// QtLogger::finish();
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg() |
|
|
|
UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg() |
|
|
@ -2361,7 +2333,6 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg() |
|
|
|
text = mXmlReader.readElementText(); |
|
|
|
text = mXmlReader.readElementText(); |
|
|
|
textItem->setHtml(text); |
|
|
|
textItem->setHtml(text); |
|
|
|
textItem->resize(width, height); |
|
|
|
textItem->resize(width, height); |
|
|
|
|
|
|
|
|
|
|
|
if (textItem->toPlainText().isEmpty()) { |
|
|
|
if (textItem->toPlainText().isEmpty()) { |
|
|
|
delete textItem; |
|
|
|
delete textItem; |
|
|
|
textItem = 0; |
|
|
|
textItem = 0; |
|
|
|