|
|
@ -1041,54 +1041,12 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene() |
|
|
|
openStroke = 0; |
|
|
|
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); |
|
|
|
UBGraphicsPixmapItem *pixmapItem = qgraphicsitem_cast<UBGraphicsPixmapItem*> (item); |
|
|
|
|
|
|
|
|
|
|
|
if (pixmapItem && pixmapItem->isVisible()) |
|
|
|
if (pixmapItem && pixmapItem->isVisible()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
pixmapItemToLinkedImage(pixmapItem); |
|
|
|
pixmapItemToLinkedImage(pixmapItem); |
|
|
|
return true; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsSvgItem *svgItem = qgraphicsitem_cast<UBGraphicsSvgItem*> (item); |
|
|
|
UBGraphicsSvgItem *svgItem = qgraphicsitem_cast<UBGraphicsSvgItem*> (item); |
|
|
@ -1096,7 +1054,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::parseCommonItems(QGraphicsItem *item |
|
|
|
if (svgItem && svgItem->isVisible()) |
|
|
|
if (svgItem && svgItem->isVisible()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
svgItemToLinkedSvg(svgItem); |
|
|
|
svgItemToLinkedSvg(svgItem); |
|
|
|
return true; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsVideoItem *videoItem = qgraphicsitem_cast<UBGraphicsVideoItem*> (item); |
|
|
|
UBGraphicsVideoItem *videoItem = qgraphicsitem_cast<UBGraphicsVideoItem*> (item); |
|
|
@ -1104,13 +1062,13 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::parseCommonItems(QGraphicsItem *item |
|
|
|
if (videoItem && videoItem->isVisible()) |
|
|
|
if (videoItem && videoItem->isVisible()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
videoItemToLinkedVideo(videoItem); |
|
|
|
videoItemToLinkedVideo(videoItem); |
|
|
|
return true; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsAudioItem* audioItem = qgraphicsitem_cast<UBGraphicsAudioItem*> (item); |
|
|
|
UBGraphicsAudioItem* audioItem = qgraphicsitem_cast<UBGraphicsAudioItem*> (item); |
|
|
|
if (audioItem && audioItem->isVisible()) { |
|
|
|
if (audioItem && audioItem->isVisible()) { |
|
|
|
audioItemToLinkedAudio(audioItem); |
|
|
|
audioItemToLinkedAudio(audioItem); |
|
|
|
return true; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsAppleWidgetItem *appleWidgetItem = qgraphicsitem_cast<UBGraphicsAppleWidgetItem*> (item); |
|
|
|
UBGraphicsAppleWidgetItem *appleWidgetItem = qgraphicsitem_cast<UBGraphicsAppleWidgetItem*> (item); |
|
|
@ -1118,7 +1076,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::parseCommonItems(QGraphicsItem *item |
|
|
|
if (appleWidgetItem && appleWidgetItem->isVisible()) |
|
|
|
if (appleWidgetItem && appleWidgetItem->isVisible()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
graphicsAppleWidgetToSvg(appleWidgetItem); |
|
|
|
graphicsAppleWidgetToSvg(appleWidgetItem); |
|
|
|
return true; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsW3CWidgetItem *w3cWidgetItem = qgraphicsitem_cast<UBGraphicsW3CWidgetItem*> (item); |
|
|
|
UBGraphicsW3CWidgetItem *w3cWidgetItem = qgraphicsitem_cast<UBGraphicsW3CWidgetItem*> (item); |
|
|
@ -1126,7 +1084,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::parseCommonItems(QGraphicsItem *item |
|
|
|
if (w3cWidgetItem && w3cWidgetItem->isVisible()) |
|
|
|
if (w3cWidgetItem && w3cWidgetItem->isVisible()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
graphicsW3CWidgetToSvg(w3cWidgetItem); |
|
|
|
graphicsW3CWidgetToSvg(w3cWidgetItem); |
|
|
|
return true; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsPDFItem *pdfItem = qgraphicsitem_cast<UBGraphicsPDFItem*> (item); |
|
|
|
UBGraphicsPDFItem *pdfItem = qgraphicsitem_cast<UBGraphicsPDFItem*> (item); |
|
|
@ -1134,7 +1092,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::parseCommonItems(QGraphicsItem *item |
|
|
|
if (pdfItem && pdfItem->isVisible()) |
|
|
|
if (pdfItem && pdfItem->isVisible()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
pdfItemToLinkedPDF(pdfItem); |
|
|
|
pdfItemToLinkedPDF(pdfItem); |
|
|
|
return true; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsTextItem *textItem = qgraphicsitem_cast<UBGraphicsTextItem*> (item); |
|
|
|
UBGraphicsTextItem *textItem = qgraphicsitem_cast<UBGraphicsTextItem*> (item); |
|
|
@ -1142,7 +1100,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::parseCommonItems(QGraphicsItem *item |
|
|
|
if (textItem && textItem->isVisible()) |
|
|
|
if (textItem && textItem->isVisible()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
textItemToSvg(textItem); |
|
|
|
textItemToSvg(textItem); |
|
|
|
return true; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsCurtainItem *curtainItem = qgraphicsitem_cast<UBGraphicsCurtainItem*> (item); |
|
|
|
UBGraphicsCurtainItem *curtainItem = qgraphicsitem_cast<UBGraphicsCurtainItem*> (item); |
|
|
@ -1150,7 +1108,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::parseCommonItems(QGraphicsItem *item |
|
|
|
if (curtainItem && curtainItem->isVisible()) |
|
|
|
if (curtainItem && curtainItem->isVisible()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
curtainItemToSvg(curtainItem); |
|
|
|
curtainItemToSvg(curtainItem); |
|
|
|
return true; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsRuler *ruler = qgraphicsitem_cast<UBGraphicsRuler*> (item); |
|
|
|
UBGraphicsRuler *ruler = qgraphicsitem_cast<UBGraphicsRuler*> (item); |
|
|
@ -1158,14 +1116,14 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::parseCommonItems(QGraphicsItem *item |
|
|
|
if (ruler && ruler->isVisible()) |
|
|
|
if (ruler && ruler->isVisible()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
rulerToSvg(ruler); |
|
|
|
rulerToSvg(ruler); |
|
|
|
return true; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsCache* cache = qgraphicsitem_cast<UBGraphicsCache*>(item); |
|
|
|
UBGraphicsCache* cache = qgraphicsitem_cast<UBGraphicsCache*>(item); |
|
|
|
if(cache && cache->isVisible()) |
|
|
|
if(cache && cache->isVisible()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
cacheToSvg(cache); |
|
|
|
cacheToSvg(cache); |
|
|
|
return true; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsCompass *compass = qgraphicsitem_cast<UBGraphicsCompass*> (item); |
|
|
|
UBGraphicsCompass *compass = qgraphicsitem_cast<UBGraphicsCompass*> (item); |
|
|
@ -1173,7 +1131,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::parseCommonItems(QGraphicsItem *item |
|
|
|
if (compass && compass->isVisible()) |
|
|
|
if (compass && compass->isVisible()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
compassToSvg(compass); |
|
|
|
compassToSvg(compass); |
|
|
|
return true; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsProtractor *protractor = qgraphicsitem_cast<UBGraphicsProtractor*> (item); |
|
|
|
UBGraphicsProtractor *protractor = qgraphicsitem_cast<UBGraphicsProtractor*> (item); |
|
|
@ -1181,7 +1139,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::parseCommonItems(QGraphicsItem *item |
|
|
|
if (protractor && protractor->isVisible()) |
|
|
|
if (protractor && protractor->isVisible()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
protractorToSvg(protractor); |
|
|
|
protractorToSvg(protractor); |
|
|
|
return true; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsTriangle *triangle = qgraphicsitem_cast<UBGraphicsTriangle*> (item); |
|
|
|
UBGraphicsTriangle *triangle = qgraphicsitem_cast<UBGraphicsTriangle*> (item); |
|
|
@ -1189,13 +1147,46 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::parseCommonItems(QGraphicsItem *item |
|
|
|
if (triangle && triangle->isVisible()) |
|
|
|
if (triangle && triangle->isVisible()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
triangleToSvg(triangle); |
|
|
|
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) |
|
|
|
void UBSvgSubsetAdaptor::UBSvgSubsetWriter::polygonItemToSvgLine(UBGraphicsPolygonItem* polygonItem, bool groupHoldsInfo) |
|
|
|
{ |
|
|
|
{ |
|
|
|