|
|
|
@ -1041,54 +1041,12 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene() |
|
|
|
|
openStroke = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBGraphicsGroupContainerItem *groupItem = qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(item); |
|
|
|
|
|
|
|
|
|
if (groupItem && groupItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
qDebug() << "came across the group during the parsing"; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
parseCommonItems(item); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (openStroke) |
|
|
|
|
{ |
|
|
|
|
mXmlWriter.writeEndElement(); |
|
|
|
|
groupHoldsInfo = false; |
|
|
|
|
openStroke = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
mXmlWriter.writeEndDocument(); |
|
|
|
|
QString fileName = mDocumentPath + UBFileSystemUtils::digitFileFormat("/page%1.svg", mPageIndex + 1); |
|
|
|
|
QFile file(fileName); |
|
|
|
|
|
|
|
|
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) |
|
|
|
|
{ |
|
|
|
|
qCritical() << "cannot open " << fileName << " for writing ..."; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
file.write(buffer.data()); |
|
|
|
|
file.flush(); |
|
|
|
|
file.close(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
qDebug() << "ignoring unmodified page" << mPageIndex + 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::parseCommonItems(QGraphicsItem *item) |
|
|
|
|
{ |
|
|
|
|
UBGraphicsPixmapItem *pixmapItem = qgraphicsitem_cast<UBGraphicsPixmapItem*> (item); |
|
|
|
|
|
|
|
|
|
if (pixmapItem && pixmapItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
pixmapItemToLinkedImage(pixmapItem); |
|
|
|
|
return true; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBGraphicsSvgItem *svgItem = qgraphicsitem_cast<UBGraphicsSvgItem*> (item); |
|
|
|
@ -1096,7 +1054,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::parseCommonItems(QGraphicsItem *item |
|
|
|
|
if (svgItem && svgItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
svgItemToLinkedSvg(svgItem); |
|
|
|
|
return true; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBGraphicsVideoItem *videoItem = qgraphicsitem_cast<UBGraphicsVideoItem*> (item); |
|
|
|
@ -1104,13 +1062,13 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::parseCommonItems(QGraphicsItem *item |
|
|
|
|
if (videoItem && videoItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
videoItemToLinkedVideo(videoItem); |
|
|
|
|
return true; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBGraphicsAudioItem* audioItem = qgraphicsitem_cast<UBGraphicsAudioItem*> (item); |
|
|
|
|
if (audioItem && audioItem->isVisible()) { |
|
|
|
|
audioItemToLinkedAudio(audioItem); |
|
|
|
|
return true; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBGraphicsAppleWidgetItem *appleWidgetItem = qgraphicsitem_cast<UBGraphicsAppleWidgetItem*> (item); |
|
|
|
@ -1118,7 +1076,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::parseCommonItems(QGraphicsItem *item |
|
|
|
|
if (appleWidgetItem && appleWidgetItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
graphicsAppleWidgetToSvg(appleWidgetItem); |
|
|
|
|
return true; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBGraphicsW3CWidgetItem *w3cWidgetItem = qgraphicsitem_cast<UBGraphicsW3CWidgetItem*> (item); |
|
|
|
@ -1126,7 +1084,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::parseCommonItems(QGraphicsItem *item |
|
|
|
|
if (w3cWidgetItem && w3cWidgetItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
graphicsW3CWidgetToSvg(w3cWidgetItem); |
|
|
|
|
return true; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBGraphicsPDFItem *pdfItem = qgraphicsitem_cast<UBGraphicsPDFItem*> (item); |
|
|
|
@ -1134,7 +1092,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::parseCommonItems(QGraphicsItem *item |
|
|
|
|
if (pdfItem && pdfItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
pdfItemToLinkedPDF(pdfItem); |
|
|
|
|
return true; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBGraphicsTextItem *textItem = qgraphicsitem_cast<UBGraphicsTextItem*> (item); |
|
|
|
@ -1142,7 +1100,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::parseCommonItems(QGraphicsItem *item |
|
|
|
|
if (textItem && textItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
textItemToSvg(textItem); |
|
|
|
|
return true; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBGraphicsCurtainItem *curtainItem = qgraphicsitem_cast<UBGraphicsCurtainItem*> (item); |
|
|
|
@ -1150,7 +1108,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::parseCommonItems(QGraphicsItem *item |
|
|
|
|
if (curtainItem && curtainItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
curtainItemToSvg(curtainItem); |
|
|
|
|
return true; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBGraphicsRuler *ruler = qgraphicsitem_cast<UBGraphicsRuler*> (item); |
|
|
|
@ -1158,14 +1116,14 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::parseCommonItems(QGraphicsItem *item |
|
|
|
|
if (ruler && ruler->isVisible()) |
|
|
|
|
{ |
|
|
|
|
rulerToSvg(ruler); |
|
|
|
|
return true; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBGraphicsCache* cache = qgraphicsitem_cast<UBGraphicsCache*>(item); |
|
|
|
|
if(cache && cache->isVisible()) |
|
|
|
|
{ |
|
|
|
|
cacheToSvg(cache); |
|
|
|
|
return true; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBGraphicsCompass *compass = qgraphicsitem_cast<UBGraphicsCompass*> (item); |
|
|
|
@ -1173,7 +1131,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::parseCommonItems(QGraphicsItem *item |
|
|
|
|
if (compass && compass->isVisible()) |
|
|
|
|
{ |
|
|
|
|
compassToSvg(compass); |
|
|
|
|
return true; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBGraphicsProtractor *protractor = qgraphicsitem_cast<UBGraphicsProtractor*> (item); |
|
|
|
@ -1181,7 +1139,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::parseCommonItems(QGraphicsItem *item |
|
|
|
|
if (protractor && protractor->isVisible()) |
|
|
|
|
{ |
|
|
|
|
protractorToSvg(protractor); |
|
|
|
|
return true; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBGraphicsTriangle *triangle = qgraphicsitem_cast<UBGraphicsTriangle*> (item); |
|
|
|
@ -1189,13 +1147,46 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::parseCommonItems(QGraphicsItem *item |
|
|
|
|
if (triangle && triangle->isVisible()) |
|
|
|
|
{ |
|
|
|
|
triangleToSvg(triangle); |
|
|
|
|
return true; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
UBGraphicsGroupContainerItem *groupItem = qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(item); |
|
|
|
|
|
|
|
|
|
if (groupItem && groupItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
qDebug() << "came across the group during the parsing"; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (openStroke) |
|
|
|
|
{ |
|
|
|
|
mXmlWriter.writeEndElement(); |
|
|
|
|
groupHoldsInfo = false; |
|
|
|
|
openStroke = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
mXmlWriter.writeEndDocument(); |
|
|
|
|
QString fileName = mDocumentPath + UBFileSystemUtils::digitFileFormat("/page%1.svg", mPageIndex + 1); |
|
|
|
|
QFile file(fileName); |
|
|
|
|
|
|
|
|
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) |
|
|
|
|
{ |
|
|
|
|
qCritical() << "cannot open " << fileName << " for writing ..."; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
file.write(buffer.data()); |
|
|
|
|
file.flush(); |
|
|
|
|
file.close(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
qDebug() << "ignoring unmodified page" << mPageIndex + 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UBSvgSubsetAdaptor::UBSvgSubsetWriter::polygonItemToSvgLine(UBGraphicsPolygonItem* polygonItem, bool groupHoldsInfo) |
|
|
|
|
{ |
|
|
|
|