|
|
@ -48,6 +48,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include "frameworks/UBFileSystemUtils.h" |
|
|
|
#include "frameworks/UBFileSystemUtils.h" |
|
|
|
#include "frameworks/UBStringUtils.h" |
|
|
|
#include "frameworks/UBStringUtils.h" |
|
|
|
|
|
|
|
#include "frameworks/UBFileSystemUtils.h" |
|
|
|
|
|
|
|
|
|
|
|
#include "core/UBSettings.h" |
|
|
|
#include "core/UBSettings.h" |
|
|
|
#include "core/UBSetting.h" |
|
|
|
#include "core/UBSetting.h" |
|
|
@ -79,6 +80,7 @@ const QString UBSvgSubsetAdaptor::sFormerUniboardDocumentNamespaceUri = "http:// |
|
|
|
|
|
|
|
|
|
|
|
const QString tElement = "element"; |
|
|
|
const QString tElement = "element"; |
|
|
|
const QString tGroup = "group"; |
|
|
|
const QString tGroup = "group"; |
|
|
|
|
|
|
|
const QString tStrokeGroup = "strokeGroup"; |
|
|
|
const QString tGroups = "groups"; |
|
|
|
const QString tGroups = "groups"; |
|
|
|
const QString aId = "id"; |
|
|
|
const QString aId = "id"; |
|
|
|
|
|
|
|
|
|
|
@ -1152,10 +1154,20 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex) |
|
|
|
QGraphicsItem *item = items.takeFirst(); |
|
|
|
QGraphicsItem *item = items.takeFirst(); |
|
|
|
|
|
|
|
|
|
|
|
// Is the item a strokes group?
|
|
|
|
// Is the item a strokes group?
|
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsStrokesGroup* strokesGroupItem = qgraphicsitem_cast<UBGraphicsStrokesGroup*>(item); |
|
|
|
UBGraphicsStrokesGroup* strokesGroupItem = qgraphicsitem_cast<UBGraphicsStrokesGroup*>(item); |
|
|
|
|
|
|
|
|
|
|
|
if(strokesGroupItem && strokesGroupItem->isVisible()){ |
|
|
|
if(strokesGroupItem && strokesGroupItem->isVisible()){ |
|
|
|
mXmlWriter.writeStartElement("g"); |
|
|
|
QDomElement newGroupElement; |
|
|
|
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "uuid", UBStringUtils::toCanonicalUuid(strokesGroupItem->uuid())); |
|
|
|
if (!strokesGroupItem->parentItem() && strokesGroupItem->childItems().count()) { |
|
|
|
|
|
|
|
newGroupElement = groupDomDocument.createElement(tGroup); |
|
|
|
|
|
|
|
newGroupElement.setAttribute(aId, strokesGroupItem->uuid().toString()); |
|
|
|
|
|
|
|
groupRoot.appendChild(newGroupElement); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//disabling g section parsing as a group of elements. Use groups refs instead
|
|
|
|
|
|
|
|
// mXmlWriter.writeStartElement("g");
|
|
|
|
|
|
|
|
// mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "uuid", UBStringUtils::toCanonicalUuid(strokesGroupItem->uuid()));
|
|
|
|
QMatrix matrix = item->sceneMatrix(); |
|
|
|
QMatrix matrix = item->sceneMatrix(); |
|
|
|
if (!matrix.isIdentity()){ |
|
|
|
if (!matrix.isIdentity()){ |
|
|
|
mXmlWriter.writeAttribute("transform", toSvgTransform(matrix)); |
|
|
|
mXmlWriter.writeAttribute("transform", toSvgTransform(matrix)); |
|
|
@ -1163,14 +1175,21 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex) |
|
|
|
|
|
|
|
|
|
|
|
// Add the polygons
|
|
|
|
// Add the polygons
|
|
|
|
foreach(QGraphicsItem* item, strokesGroupItem->childItems()){ |
|
|
|
foreach(QGraphicsItem* item, strokesGroupItem->childItems()){ |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsPolygonItem* poly = qgraphicsitem_cast<UBGraphicsPolygonItem*>(item); |
|
|
|
UBGraphicsPolygonItem* poly = qgraphicsitem_cast<UBGraphicsPolygonItem*>(item); |
|
|
|
if(NULL != poly){ |
|
|
|
if(NULL != poly){ |
|
|
|
polygonItemToSvgPolygon(poly, true); |
|
|
|
polygonItemToSvgPolygon(poly, true); |
|
|
|
|
|
|
|
if (!newGroupElement.isNull()) { |
|
|
|
|
|
|
|
QDomElement curPolygonElement = groupDomDocument.createElement(tElement); |
|
|
|
|
|
|
|
curPolygonElement.setAttribute(aId, strokesGroupItem->uuid().toString() |
|
|
|
|
|
|
|
+ poly->uuid().toString()); |
|
|
|
|
|
|
|
newGroupElement.appendChild(curPolygonElement); |
|
|
|
|
|
|
|
} |
|
|
|
items.removeOne(poly); |
|
|
|
items.removeOne(poly); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mXmlWriter.writeEndElement(); //g
|
|
|
|
// mXmlWriter.writeEndElement(); //g
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Is the item a polygon?
|
|
|
|
// Is the item a polygon?
|
|
|
@ -1401,12 +1420,12 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex) |
|
|
|
QDomElement curElement = groupRoot.firstChildElement(); |
|
|
|
QDomElement curElement = groupRoot.firstChildElement(); |
|
|
|
while (!curElement.isNull()) { |
|
|
|
while (!curElement.isNull()) { |
|
|
|
if (curElement.hasAttribute(aId)) { |
|
|
|
if (curElement.hasAttribute(aId)) { |
|
|
|
mXmlWriter.writeStartElement(tGroup); |
|
|
|
mXmlWriter.writeStartElement(curElement.tagName()); |
|
|
|
mXmlWriter.writeAttribute(aId, curElement.attribute(aId)); |
|
|
|
mXmlWriter.writeAttribute(aId, curElement.attribute(aId)); |
|
|
|
QDomElement curSubElement = curElement.firstChildElement(); |
|
|
|
QDomElement curSubElement = curElement.firstChildElement(); |
|
|
|
while (!curSubElement.isNull()) { |
|
|
|
while (!curSubElement.isNull()) { |
|
|
|
if (curSubElement.hasAttribute(aId)) { |
|
|
|
if (curSubElement.hasAttribute(aId)) { |
|
|
|
mXmlWriter.writeStartElement(tElement); |
|
|
|
mXmlWriter.writeStartElement(curSubElement.tagName()); |
|
|
|
mXmlWriter.writeAttribute(aId, curSubElement.attribute(aId)); |
|
|
|
mXmlWriter.writeAttribute(aId, curSubElement.attribute(aId)); |
|
|
|
mXmlWriter.writeEndElement(); |
|
|
|
mXmlWriter.writeEndElement(); |
|
|
|
curSubElement = curSubElement.nextSiblingElement(); |
|
|
|
curSubElement = curSubElement.nextSiblingElement(); |
|
|
@ -1454,8 +1473,16 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistGroupToDom(QGraphicsItem *gro |
|
|
|
if (!tmpUuid.isNull()) { |
|
|
|
if (!tmpUuid.isNull()) { |
|
|
|
if (item->type() == UBGraphicsGroupContainerItem::Type && item->childItems().count()) { |
|
|
|
if (item->type() == UBGraphicsGroupContainerItem::Type && item->childItems().count()) { |
|
|
|
persistGroupToDom(item, curParent, groupDomDocument); |
|
|
|
persistGroupToDom(item, curParent, groupDomDocument); |
|
|
|
|
|
|
|
} else if (item->type() == UBGraphicsStrokesGroup::Type) { |
|
|
|
|
|
|
|
foreach (QGraphicsItem *polygonItem, item->childItems()) { |
|
|
|
|
|
|
|
QDomElement curPolygonElement = groupDomDocument->createElement(tElement); |
|
|
|
|
|
|
|
curPolygonElement.setAttribute(aId, tmpUuid.toString() |
|
|
|
|
|
|
|
+ UBGraphicsItem::getOwnUuid(polygonItem).toString()); |
|
|
|
|
|
|
|
curGroupElement.appendChild(curPolygonElement); |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
QDomElement curSubElement = groupDomDocument->createElement(tGroup); |
|
|
|
QDomElement curSubElement = groupDomDocument->createElement(tElement); |
|
|
|
|
|
|
|
|
|
|
|
curSubElement.setAttribute(aId, tmpUuid); |
|
|
|
curSubElement.setAttribute(aId, tmpUuid); |
|
|
|
curGroupElement.appendChild(curSubElement); |
|
|
|
curGroupElement.appendChild(curSubElement); |
|
|
|
} |
|
|
|
} |
|
|
@ -1464,6 +1491,27 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistGroupToDom(QGraphicsItem *gro |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistStrokeToDom(QGraphicsItem *strokeItem, QDomElement *curParent, QDomDocument *curDomDocument) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QUuid uuid = UBGraphicsScene::getPersonalUuid(strokeItem); |
|
|
|
|
|
|
|
if (!uuid.isNull()) { |
|
|
|
|
|
|
|
QDomElement curStrokesGroupElement = curDomDocument->createElement(tStrokeGroup); |
|
|
|
|
|
|
|
curStrokesGroupElement.setAttribute(aId, uuid); |
|
|
|
|
|
|
|
curParent->appendChild(curStrokesGroupElement); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (QGraphicsItem *item, strokeItem->childItems()) { |
|
|
|
|
|
|
|
QUuid tmpUuid = UBGraphicsScene::getPersonalUuid(item); |
|
|
|
|
|
|
|
if (!tmpUuid.isNull()) { |
|
|
|
|
|
|
|
if (item->type() == UBGraphicsPolygonItem::Type && item->childItems().count()) { |
|
|
|
|
|
|
|
QDomElement curSubElement = curDomDocument->createElement(tElement); |
|
|
|
|
|
|
|
curSubElement.setAttribute(aId, tmpUuid); |
|
|
|
|
|
|
|
curStrokesGroupElement.appendChild(curSubElement); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBSvgSubsetAdaptor::UBSvgSubsetWriter::polygonItemToSvgLine(UBGraphicsPolygonItem* polygonItem, bool groupHoldsInfo) |
|
|
|
void UBSvgSubsetAdaptor::UBSvgSubsetWriter::polygonItemToSvgLine(UBGraphicsPolygonItem* polygonItem, bool groupHoldsInfo) |
|
|
|
{ |
|
|
|
{ |
|
|
|
mXmlWriter.writeStartElement("line"); |
|
|
|
mXmlWriter.writeStartElement("line"); |
|
|
@ -1615,6 +1663,8 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::polygonItemToSvgPolygon(UBGraphicsPo |
|
|
|
, "fill-on-light-background", polygonItem->colorOnLightBackground().name()); |
|
|
|
, "fill-on-light-background", polygonItem->colorOnLightBackground().name()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "uuid", UBStringUtils::toCanonicalUuid(polygonItem->uuid())); |
|
|
|
|
|
|
|
|
|
|
|
mXmlWriter.writeEndElement(); |
|
|
|
mXmlWriter.writeEndElement(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|