|
|
@ -30,6 +30,7 @@ |
|
|
|
#include "domain/UBAbstractWidget.h" |
|
|
|
#include "domain/UBAbstractWidget.h" |
|
|
|
#include "domain/UBGraphicsStroke.h" |
|
|
|
#include "domain/UBGraphicsStroke.h" |
|
|
|
#include "domain/UBGraphicsStrokesGroup.h" |
|
|
|
#include "domain/UBGraphicsStrokesGroup.h" |
|
|
|
|
|
|
|
#include "domain/ubgraphicsgroupcontaineritem.h" |
|
|
|
#include "domain/UBItem.h" |
|
|
|
#include "domain/UBItem.h" |
|
|
|
|
|
|
|
|
|
|
|
#include "tools/UBGraphicsRuler.h" |
|
|
|
#include "tools/UBGraphicsRuler.h" |
|
|
@ -929,8 +930,13 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::writeSvgElement() |
|
|
|
|
|
|
|
|
|
|
|
bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene() |
|
|
|
bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mScene->isModified()) |
|
|
|
if (mScene->isModified()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
static int i = 0; |
|
|
|
|
|
|
|
qDebug() << "persist call no is " << ++i; |
|
|
|
|
|
|
|
|
|
|
|
QBuffer buffer; |
|
|
|
QBuffer buffer; |
|
|
|
buffer.open(QBuffer::WriteOnly); |
|
|
|
buffer.open(QBuffer::WriteOnly); |
|
|
|
mXmlWriter.setDevice(&buffer); |
|
|
|
mXmlWriter.setDevice(&buffer); |
|
|
@ -1035,12 +1041,54 @@ 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); |
|
|
|
continue; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsSvgItem *svgItem = qgraphicsitem_cast<UBGraphicsSvgItem*> (item); |
|
|
|
UBGraphicsSvgItem *svgItem = qgraphicsitem_cast<UBGraphicsSvgItem*> (item); |
|
|
@ -1048,7 +1096,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene() |
|
|
|
if (svgItem && svgItem->isVisible()) |
|
|
|
if (svgItem && svgItem->isVisible()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
svgItemToLinkedSvg(svgItem); |
|
|
|
svgItemToLinkedSvg(svgItem); |
|
|
|
continue; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsVideoItem *videoItem = qgraphicsitem_cast<UBGraphicsVideoItem*> (item); |
|
|
|
UBGraphicsVideoItem *videoItem = qgraphicsitem_cast<UBGraphicsVideoItem*> (item); |
|
|
@ -1056,13 +1104,13 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene() |
|
|
|
if (videoItem && videoItem->isVisible()) |
|
|
|
if (videoItem && videoItem->isVisible()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
videoItemToLinkedVideo(videoItem); |
|
|
|
videoItemToLinkedVideo(videoItem); |
|
|
|
continue; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsAudioItem* audioItem = qgraphicsitem_cast<UBGraphicsAudioItem*> (item); |
|
|
|
UBGraphicsAudioItem* audioItem = qgraphicsitem_cast<UBGraphicsAudioItem*> (item); |
|
|
|
if (audioItem && audioItem->isVisible()) { |
|
|
|
if (audioItem && audioItem->isVisible()) { |
|
|
|
audioItemToLinkedAudio(audioItem); |
|
|
|
audioItemToLinkedAudio(audioItem); |
|
|
|
continue; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsAppleWidgetItem *appleWidgetItem = qgraphicsitem_cast<UBGraphicsAppleWidgetItem*> (item); |
|
|
|
UBGraphicsAppleWidgetItem *appleWidgetItem = qgraphicsitem_cast<UBGraphicsAppleWidgetItem*> (item); |
|
|
@ -1070,7 +1118,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene() |
|
|
|
if (appleWidgetItem && appleWidgetItem->isVisible()) |
|
|
|
if (appleWidgetItem && appleWidgetItem->isVisible()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
graphicsAppleWidgetToSvg(appleWidgetItem); |
|
|
|
graphicsAppleWidgetToSvg(appleWidgetItem); |
|
|
|
continue; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsW3CWidgetItem *w3cWidgetItem = qgraphicsitem_cast<UBGraphicsW3CWidgetItem*> (item); |
|
|
|
UBGraphicsW3CWidgetItem *w3cWidgetItem = qgraphicsitem_cast<UBGraphicsW3CWidgetItem*> (item); |
|
|
@ -1078,7 +1126,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene() |
|
|
|
if (w3cWidgetItem && w3cWidgetItem->isVisible()) |
|
|
|
if (w3cWidgetItem && w3cWidgetItem->isVisible()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
graphicsW3CWidgetToSvg(w3cWidgetItem); |
|
|
|
graphicsW3CWidgetToSvg(w3cWidgetItem); |
|
|
|
continue; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsPDFItem *pdfItem = qgraphicsitem_cast<UBGraphicsPDFItem*> (item); |
|
|
|
UBGraphicsPDFItem *pdfItem = qgraphicsitem_cast<UBGraphicsPDFItem*> (item); |
|
|
@ -1086,7 +1134,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene() |
|
|
|
if (pdfItem && pdfItem->isVisible()) |
|
|
|
if (pdfItem && pdfItem->isVisible()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
pdfItemToLinkedPDF(pdfItem); |
|
|
|
pdfItemToLinkedPDF(pdfItem); |
|
|
|
continue; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsTextItem *textItem = qgraphicsitem_cast<UBGraphicsTextItem*> (item); |
|
|
|
UBGraphicsTextItem *textItem = qgraphicsitem_cast<UBGraphicsTextItem*> (item); |
|
|
@ -1094,7 +1142,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene() |
|
|
|
if (textItem && textItem->isVisible()) |
|
|
|
if (textItem && textItem->isVisible()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
textItemToSvg(textItem); |
|
|
|
textItemToSvg(textItem); |
|
|
|
continue; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsCurtainItem *curtainItem = qgraphicsitem_cast<UBGraphicsCurtainItem*> (item); |
|
|
|
UBGraphicsCurtainItem *curtainItem = qgraphicsitem_cast<UBGraphicsCurtainItem*> (item); |
|
|
@ -1102,7 +1150,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene() |
|
|
|
if (curtainItem && curtainItem->isVisible()) |
|
|
|
if (curtainItem && curtainItem->isVisible()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
curtainItemToSvg(curtainItem); |
|
|
|
curtainItemToSvg(curtainItem); |
|
|
|
continue; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsRuler *ruler = qgraphicsitem_cast<UBGraphicsRuler*> (item); |
|
|
|
UBGraphicsRuler *ruler = qgraphicsitem_cast<UBGraphicsRuler*> (item); |
|
|
@ -1110,14 +1158,14 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene() |
|
|
|
if (ruler && ruler->isVisible()) |
|
|
|
if (ruler && ruler->isVisible()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
rulerToSvg(ruler); |
|
|
|
rulerToSvg(ruler); |
|
|
|
continue; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsCache* cache = qgraphicsitem_cast<UBGraphicsCache*>(item); |
|
|
|
UBGraphicsCache* cache = qgraphicsitem_cast<UBGraphicsCache*>(item); |
|
|
|
if(cache && cache->isVisible()) |
|
|
|
if(cache && cache->isVisible()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
cacheToSvg(cache); |
|
|
|
cacheToSvg(cache); |
|
|
|
continue; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsCompass *compass = qgraphicsitem_cast<UBGraphicsCompass*> (item); |
|
|
|
UBGraphicsCompass *compass = qgraphicsitem_cast<UBGraphicsCompass*> (item); |
|
|
@ -1125,7 +1173,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene() |
|
|
|
if (compass && compass->isVisible()) |
|
|
|
if (compass && compass->isVisible()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
compassToSvg(compass); |
|
|
|
compassToSvg(compass); |
|
|
|
continue; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsProtractor *protractor = qgraphicsitem_cast<UBGraphicsProtractor*> (item); |
|
|
|
UBGraphicsProtractor *protractor = qgraphicsitem_cast<UBGraphicsProtractor*> (item); |
|
|
@ -1133,7 +1181,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene() |
|
|
|
if (protractor && protractor->isVisible()) |
|
|
|
if (protractor && protractor->isVisible()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
protractorToSvg(protractor); |
|
|
|
protractorToSvg(protractor); |
|
|
|
continue; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsTriangle *triangle = qgraphicsitem_cast<UBGraphicsTriangle*> (item); |
|
|
|
UBGraphicsTriangle *triangle = qgraphicsitem_cast<UBGraphicsTriangle*> (item); |
|
|
@ -1141,40 +1189,14 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene() |
|
|
|
if (triangle && triangle->isVisible()) |
|
|
|
if (triangle && triangle->isVisible()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
triangleToSvg(triangle); |
|
|
|
triangleToSvg(triangle); |
|
|
|
continue; |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBSvgSubsetAdaptor::UBSvgSubsetWriter::polygonItemToSvgLine(UBGraphicsPolygonItem* polygonItem, bool groupHoldsInfo) |
|
|
|
void UBSvgSubsetAdaptor::UBSvgSubsetWriter::polygonItemToSvgLine(UBGraphicsPolygonItem* polygonItem, bool groupHoldsInfo) |
|
|
|
{ |
|
|
|
{ |
|
|
|
mXmlWriter.writeStartElement("line"); |
|
|
|
mXmlWriter.writeStartElement("line"); |
|
|
|