|
|
@ -53,6 +53,7 @@ |
|
|
|
#include "pdf/PDFRenderer.h" |
|
|
|
#include "pdf/PDFRenderer.h" |
|
|
|
|
|
|
|
|
|
|
|
#include "core/memcheck.h" |
|
|
|
#include "core/memcheck.h" |
|
|
|
|
|
|
|
//#include "qtlogger.h"
|
|
|
|
|
|
|
|
|
|
|
|
const QString UBSvgSubsetAdaptor::nsSvg = "http://www.w3.org/2000/svg"; |
|
|
|
const QString UBSvgSubsetAdaptor::nsSvg = "http://www.w3.org/2000/svg"; |
|
|
|
const QString UBSvgSubsetAdaptor::nsXHtml = "http://www.w3.org/1999/xhtml"; |
|
|
|
const QString UBSvgSubsetAdaptor::nsXHtml = "http://www.w3.org/1999/xhtml"; |
|
|
@ -2216,38 +2217,51 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::textItemToSvg(UBGraphicsTextItem* it |
|
|
|
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri |
|
|
|
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri |
|
|
|
, "fill-on-light-background", colorLightBg.name()); |
|
|
|
, "fill-on-light-background", colorLightBg.name()); |
|
|
|
|
|
|
|
|
|
|
|
mXmlWriter.writeStartElement(nsXHtml, "body"); |
|
|
|
//for new documents from version 4.5.0
|
|
|
|
mXmlWriter.writeStartElement(nsXHtml, "div"); |
|
|
|
if (true) { |
|
|
|
mXmlWriter.writeStartElement(nsXHtml, "font"); |
|
|
|
mXmlWriter.writeStartElement("itemTextContent"); |
|
|
|
|
|
|
|
mXmlWriter.writeCDATA(item->toHtml()); |
|
|
|
|
|
|
|
mXmlWriter.writeEndElement(); //itemTextContent
|
|
|
|
|
|
|
|
|
|
|
|
QFont font = item->font(); |
|
|
|
//tracking for back capability with older versions
|
|
|
|
|
|
|
|
} else if (false) { |
|
|
|
|
|
|
|
mXmlWriter.writeStartElement(nsXHtml, "body"); |
|
|
|
|
|
|
|
mXmlWriter.writeStartElement(nsXHtml, "div"); |
|
|
|
|
|
|
|
mXmlWriter.writeStartElement(nsXHtml, "font"); |
|
|
|
|
|
|
|
|
|
|
|
mXmlWriter.writeAttribute("face", font.family()); |
|
|
|
QFont font = item->font(); |
|
|
|
|
|
|
|
|
|
|
|
QFontInfo fi(font); |
|
|
|
mXmlWriter.writeAttribute("face", font.family()); |
|
|
|
int pixelSize = fi.pixelSize(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mXmlWriter.writeAttribute("style", sFontSizePrefix + QString(" %1").arg(pixelSize) + sPixelUnit + "; " + |
|
|
|
QFontInfo fi(font); |
|
|
|
sFontWeightPrefix + " " + (fi.bold() ? "bold" : "normal") + "; " + |
|
|
|
int pixelSize = fi.pixelSize(); |
|
|
|
sFontStylePrefix + " " + (fi.italic() ? "italic" : "normal") + ";"); |
|
|
|
|
|
|
|
mXmlWriter.writeAttribute("color", item->defaultTextColor().name()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString text = item->toPlainText(); |
|
|
|
mXmlWriter.writeAttribute("style", sFontSizePrefix + QString(" %1").arg(pixelSize) + sPixelUnit + "; " + |
|
|
|
QStringList lines = text.split("\n"); |
|
|
|
sFontWeightPrefix + " " + (fi.bold() ? "bold" : "normal") + "; " + |
|
|
|
|
|
|
|
sFontStylePrefix + " " + (fi.italic() ? "italic" : "normal") + ";"); |
|
|
|
|
|
|
|
mXmlWriter.writeAttribute("color", item->defaultTextColor().name()); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < lines.length() ; i++) |
|
|
|
QString text = item->toPlainText(); |
|
|
|
{ |
|
|
|
QStringList lines = text.split("\n"); |
|
|
|
mXmlWriter.writeCharacters(lines.at(i)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (i < lines.length() - 1) |
|
|
|
for (int i = 0; i < lines.length() ; i++) |
|
|
|
mXmlWriter.writeEmptyElement(nsXHtml, "br"); |
|
|
|
{ |
|
|
|
} |
|
|
|
mXmlWriter.writeCharacters(lines.at(i)); |
|
|
|
|
|
|
|
|
|
|
|
mXmlWriter.writeEndElement(); //font
|
|
|
|
if (i < lines.length() - 1) |
|
|
|
mXmlWriter.writeEndElement(); //div
|
|
|
|
mXmlWriter.writeEmptyElement(nsXHtml, "br"); |
|
|
|
mXmlWriter.writeEndElement(); //body
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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() |
|
|
@ -2275,39 +2289,41 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg() |
|
|
|
mXmlReader.readNext(); |
|
|
|
mXmlReader.readNext(); |
|
|
|
if (mXmlReader.isStartElement()) |
|
|
|
if (mXmlReader.isStartElement()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (mXmlReader.name() == "font") |
|
|
|
//for new documents from version 4.5.0
|
|
|
|
{ |
|
|
|
if (true) { |
|
|
|
|
|
|
|
if (mXmlReader.name() == "itemTextContent") { |
|
|
|
|
|
|
|
QString text = mXmlReader.readElementText(); |
|
|
|
|
|
|
|
// QtLogger::start("/home/ilia/Documents/tmp/10/log.log");
|
|
|
|
|
|
|
|
// QtLogger::appendl(text);
|
|
|
|
|
|
|
|
// QtLogger::finish();
|
|
|
|
|
|
|
|
// textItem->setPlainText("");
|
|
|
|
|
|
|
|
textItem->setHtml(text); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//tracking for back capability with older versions
|
|
|
|
|
|
|
|
} else if (mXmlReader.name() == "font") { |
|
|
|
QFont font = textItem->font(); |
|
|
|
QFont font = textItem->font(); |
|
|
|
|
|
|
|
|
|
|
|
QStringRef fontFamily = mXmlReader.attributes().value("face"); |
|
|
|
QStringRef fontFamily = mXmlReader.attributes().value("face"); |
|
|
|
|
|
|
|
|
|
|
|
if (!fontFamily.isNull()) |
|
|
|
if (!fontFamily.isNull()) { |
|
|
|
{ |
|
|
|
|
|
|
|
font.setFamily(fontFamily.toString()); |
|
|
|
font.setFamily(fontFamily.toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QStringRef fontStyle = mXmlReader.attributes().value("style"); |
|
|
|
QStringRef fontStyle = mXmlReader.attributes().value("style"); |
|
|
|
if (!fontStyle.isNull()) |
|
|
|
if (!fontStyle.isNull()) { |
|
|
|
{ |
|
|
|
foreach (QString styleToken, fontStyle.toString().split(";")) { |
|
|
|
foreach (QString styleToken, fontStyle.toString().split(";")) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
styleToken = styleToken.trimmed(); |
|
|
|
styleToken = styleToken.trimmed(); |
|
|
|
if (styleToken.startsWith(sFontSizePrefix) && styleToken.endsWith(sPixelUnit)) |
|
|
|
if (styleToken.startsWith(sFontSizePrefix) && styleToken.endsWith(sPixelUnit)) { |
|
|
|
{ |
|
|
|
|
|
|
|
int fontSize = styleToken.mid( |
|
|
|
int fontSize = styleToken.mid( |
|
|
|
sFontSizePrefix.length(), |
|
|
|
sFontSizePrefix.length(), |
|
|
|
styleToken.length() - sFontSizePrefix.length() - sPixelUnit.length()).toInt(); |
|
|
|
styleToken.length() - sFontSizePrefix.length() - sPixelUnit.length()).toInt(); |
|
|
|
font.setPixelSize(fontSize); |
|
|
|
font.setPixelSize(fontSize); |
|
|
|
} |
|
|
|
} else if (styleToken.startsWith(sFontWeightPrefix)) { |
|
|
|
else if (styleToken.startsWith(sFontWeightPrefix)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QString fontWeight = styleToken.mid( |
|
|
|
QString fontWeight = styleToken.mid( |
|
|
|
sFontWeightPrefix.length(), |
|
|
|
sFontWeightPrefix.length(), |
|
|
|
styleToken.length() - sFontWeightPrefix.length()); |
|
|
|
styleToken.length() - sFontWeightPrefix.length()); |
|
|
|
font.setBold(fontWeight.contains("bold")); |
|
|
|
font.setBold(fontWeight.contains("bold")); |
|
|
|
} |
|
|
|
} else if (styleToken.startsWith(sFontStylePrefix)) { |
|
|
|
else if (styleToken.startsWith(sFontStylePrefix)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QString fontStyle = styleToken.mid( |
|
|
|
QString fontStyle = styleToken.mid( |
|
|
|
sFontStylePrefix.length(), |
|
|
|
sFontStylePrefix.length(), |
|
|
|
styleToken.length() - sFontStylePrefix.length()); |
|
|
|
styleToken.length() - sFontStylePrefix.length()); |
|
|
@ -2319,15 +2335,13 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg() |
|
|
|
textItem->setFont(font); |
|
|
|
textItem->setFont(font); |
|
|
|
|
|
|
|
|
|
|
|
QStringRef fill = mXmlReader.attributes().value("color"); |
|
|
|
QStringRef fill = mXmlReader.attributes().value("color"); |
|
|
|
if (!fill.isNull()) |
|
|
|
if (!fill.isNull()) { |
|
|
|
{ |
|
|
|
|
|
|
|
QColor textColor; |
|
|
|
QColor textColor; |
|
|
|
textColor.setNamedColor(fill.toString()); |
|
|
|
textColor.setNamedColor(fill.toString()); |
|
|
|
textItem->setDefaultTextColor(textColor); |
|
|
|
textItem->setDefaultTextColor(textColor); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!ubFillOnDarkBackground.isNull()) |
|
|
|
if (!ubFillOnDarkBackground.isNull()) { |
|
|
|
{ |
|
|
|
|
|
|
|
QColor color; |
|
|
|
QColor color; |
|
|
|
color.setNamedColor(ubFillOnDarkBackground.toString()); |
|
|
|
color.setNamedColor(ubFillOnDarkBackground.toString()); |
|
|
|
if (!color.isValid()) |
|
|
|
if (!color.isValid()) |
|
|
@ -2335,8 +2349,7 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg() |
|
|
|
textItem->setColorOnDarkBackground(color); |
|
|
|
textItem->setColorOnDarkBackground(color); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!ubFillOnLightBackground.isNull()) |
|
|
|
if (!ubFillOnLightBackground.isNull()) { |
|
|
|
{ |
|
|
|
|
|
|
|
QColor color; |
|
|
|
QColor color; |
|
|
|
color.setNamedColor(ubFillOnLightBackground.toString()); |
|
|
|
color.setNamedColor(ubFillOnLightBackground.toString()); |
|
|
|
if (!color.isValid()) |
|
|
|
if (!color.isValid()) |
|
|
@ -2344,20 +2357,16 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg() |
|
|
|
textItem->setColorOnLightBackground(color); |
|
|
|
textItem->setColorOnLightBackground(color); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
while (!(mXmlReader.isEndElement() && mXmlReader.name() == "font")) |
|
|
|
while (!(mXmlReader.isEndElement() && mXmlReader.name() == "font")) { |
|
|
|
{ |
|
|
|
if (mXmlReader.hasError()) { |
|
|
|
if (mXmlReader.hasError()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
QXmlStreamReader::TokenType tt = mXmlReader.readNext(); |
|
|
|
QXmlStreamReader::TokenType tt = mXmlReader.readNext(); |
|
|
|
if (tt == QXmlStreamReader::Characters) |
|
|
|
if (tt == QXmlStreamReader::Characters) { |
|
|
|
{ |
|
|
|
|
|
|
|
text += mXmlReader.text().toString(); |
|
|
|
text += mXmlReader.text().toString(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (mXmlReader.isStartElement() && mXmlReader.name() == "br") |
|
|
|
if (mXmlReader.isStartElement() && mXmlReader.name() == "br") { |
|
|
|
{ |
|
|
|
|
|
|
|
text += "\n"; |
|
|
|
text += "\n"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -2365,16 +2374,16 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (text.isEmpty()) |
|
|
|
if (false) { |
|
|
|
{ |
|
|
|
if (text.isEmpty()) { |
|
|
|
delete textItem; |
|
|
|
delete textItem; |
|
|
|
textItem = 0; |
|
|
|
textItem = 0; |
|
|
|
} |
|
|
|
} else { |
|
|
|
else |
|
|
|
textItem->setPlainText(text); |
|
|
|
{ |
|
|
|
textItem->resize(width, height); |
|
|
|
textItem->setPlainText(text); |
|
|
|
} |
|
|
|
textItem->resize(width, height); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
textItem->resize(width, height); |
|
|
|
|
|
|
|
|
|
|
|
return textItem; |
|
|
|
return textItem; |
|
|
|
} |
|
|
|
} |
|
|
@ -2412,6 +2421,7 @@ UBGraphicsCurtainItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::curtainItemFromSvg |
|
|
|
QRectF rect = curtainItem->rect(); |
|
|
|
QRectF rect = curtainItem->rect(); |
|
|
|
rect.setWidth(svgWidth.toString().toFloat()); |
|
|
|
rect.setWidth(svgWidth.toString().toFloat()); |
|
|
|
rect.setHeight(svgHeight.toString().toFloat()); |
|
|
|
rect.setHeight(svgHeight.toString().toFloat()); |
|
|
|
|
|
|
|
rect.translate(- rect.center()); |
|
|
|
|
|
|
|
|
|
|
|
curtainItem->setRect(rect); |
|
|
|
curtainItem->setRect(rect); |
|
|
|
|
|
|
|
|
|
|
|