fix: subtract margin from boundingRect in UBSvgSubsetAdaptor

preferencesAboutTextFull
letsfindaway 3 years ago
parent ebae317723
commit 8803239d84
  1. 56
      src/adaptors/UBSvgSubsetAdaptor.cpp

@ -355,7 +355,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene(UBDocumentProx
time.start(); time.start();
mScene = 0; mScene = 0;
UBGraphicsWidgetItem *currentWidget = 0; UBGraphicsWidgetItem *currentWidget = 0;
bool pageDpiSpecified = true; //bool pageDpiSpecified = true;
saveSceneAfterLoading = false; saveSceneAfterLoading = false;
mFileVersion = 40100; // default to 4.1.0 mFileVersion = 40100; // default to 4.1.0
@ -443,7 +443,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene(UBDocumentProx
else if (proxy->pageDpi() == 0) { else if (proxy->pageDpi() == 0) {
proxy->setPageDpi((UBApplication::desktop()->physicalDpiX() + UBApplication::desktop()->physicalDpiY())/2); proxy->setPageDpi((UBApplication::desktop()->physicalDpiX() + UBApplication::desktop()->physicalDpiY())/2);
pageDpiSpecified = false; //pageDpiSpecified = false;
} }
bool darkBackground = false; bool darkBackground = false;
@ -909,9 +909,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene(UBDocumentProx
if (textDelegate) if (textDelegate)
{ {
QDesktopWidget* desktop = UBApplication::desktop(); //QDesktopWidget* desktop = UBApplication::desktop();
qreal currentDpi = (desktop->physicalDpiX() + desktop->physicalDpiY()) / 2; //qreal currentDpi = (desktop->physicalDpiX() + desktop->physicalDpiY()) / 2;
qreal textSizeMultiplier = qreal(proxy->pageDpi())/currentDpi; //qreal textSizeMultiplier = qreal(proxy->pageDpi())/currentDpi;
//textDelegate->scaleTextSize(textSizeMultiplier); //textDelegate->scaleTextSize(textSizeMultiplier);
} }
@ -2390,8 +2390,9 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::graphicsItemToSvg(QGraphicsItem* ite
mXmlWriter.writeAttribute("x", "0"); mXmlWriter.writeAttribute("x", "0");
mXmlWriter.writeAttribute("y", "0"); mXmlWriter.writeAttribute("y", "0");
mXmlWriter.writeAttribute("width", QString("%1").arg(item->boundingRect().width())); QRectF rect = item->boundingRect() - QMarginsF(0.5, 0.5, 0.5, 0.5);
mXmlWriter.writeAttribute("height", QString("%1").arg(item->boundingRect().height())); mXmlWriter.writeAttribute("width", QString("%1").arg(rect.width()));
mXmlWriter.writeAttribute("height", QString("%1").arg(rect.height()));
mXmlWriter.writeAttribute("transform", toSvgTransform(item->sceneMatrix())); mXmlWriter.writeAttribute("transform", toSvgTransform(item->sceneMatrix()));
@ -2487,8 +2488,9 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::graphicsWidgetToSvg(UBGraphicsWidget
mXmlWriter.writeStartElement(nsXHtml, "iframe"); mXmlWriter.writeStartElement(nsXHtml, "iframe");
mXmlWriter.writeAttribute("style", "border: none"); mXmlWriter.writeAttribute("style", "border: none");
mXmlWriter.writeAttribute("width", QString("%1").arg(item->boundingRect().width())); QRectF rect = item->boundingRect() - QMarginsF(0.5, 0.5, 0.5, 0.5);
mXmlWriter.writeAttribute("height", QString("%1").arg(item->boundingRect().height())); mXmlWriter.writeAttribute("width", QString("%1").arg(rect.width()));
mXmlWriter.writeAttribute("height", QString("%1").arg(rect.height()));
QString startFileUrl; QString startFileUrl;
if (item->mainHtmlFileName().startsWith("http://")) if (item->mainHtmlFileName().startsWith("http://"))
@ -2817,10 +2819,11 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::curtainItemToSvg(UBGraphicsCurtainIt
*/ */
mXmlWriter.writeStartElement(UBSettings::uniboardDocumentNamespaceUri, "curtain"); mXmlWriter.writeStartElement(UBSettings::uniboardDocumentNamespaceUri, "curtain");
mXmlWriter.writeAttribute("x", QString("%1").arg(curtainItem->boundingRect().center().x())); QRectF rect = curtainItem->boundingRect() - QMarginsF(0.5, 0.5, 0.5, 0.5);
mXmlWriter.writeAttribute("y", QString("%1").arg(curtainItem->boundingRect().center().y())); mXmlWriter.writeAttribute("x", QString("%1").arg(rect.center().x()));
mXmlWriter.writeAttribute("width", QString("%1").arg(curtainItem->boundingRect().width())); mXmlWriter.writeAttribute("y", QString("%1").arg(rect.center().y()));
mXmlWriter.writeAttribute("height", QString("%1").arg(curtainItem->boundingRect().height())); mXmlWriter.writeAttribute("width", QString("%1").arg(rect.width()));
mXmlWriter.writeAttribute("height", QString("%1").arg(rect.height()));
mXmlWriter.writeAttribute("transform", toSvgTransform(curtainItem->sceneMatrix())); mXmlWriter.writeAttribute("transform", toSvgTransform(curtainItem->sceneMatrix()));
//graphicsItemToSvg(curtainItem); //graphicsItemToSvg(curtainItem);
@ -2877,10 +2880,11 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::rulerToSvg(UBGraphicsRuler* item)
*/ */
mXmlWriter.writeStartElement(UBSettings::uniboardDocumentNamespaceUri, "ruler"); mXmlWriter.writeStartElement(UBSettings::uniboardDocumentNamespaceUri, "ruler");
mXmlWriter.writeAttribute("x", QString("%1").arg(item->boundingRect().x())); QRectF rect = item->boundingRect() - QMarginsF(0.5, 0.5, 0.5, 0.5);
mXmlWriter.writeAttribute("y", QString("%1").arg(item->boundingRect().y())); mXmlWriter.writeAttribute("x", QString("%1").arg(rect.x()));
mXmlWriter.writeAttribute("width", QString("%1").arg(item->boundingRect().width())); mXmlWriter.writeAttribute("y", QString("%1").arg(rect.y()));
mXmlWriter.writeAttribute("height", QString("%1").arg(item->boundingRect().height())); mXmlWriter.writeAttribute("width", QString("%1").arg(rect.width()));
mXmlWriter.writeAttribute("height", QString("%1").arg(rect.height()));
mXmlWriter.writeAttribute("transform", toSvgTransform(item->sceneMatrix())); mXmlWriter.writeAttribute("transform", toSvgTransform(item->sceneMatrix()));
QString zs; QString zs;
@ -3005,10 +3009,11 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::compassToSvg(UBGraphicsCompass* item
*/ */
mXmlWriter.writeStartElement(UBSettings::uniboardDocumentNamespaceUri, "compass"); mXmlWriter.writeStartElement(UBSettings::uniboardDocumentNamespaceUri, "compass");
mXmlWriter.writeAttribute("x", QString("%1").arg(item->boundingRect().x())); QRectF rect = item->boundingRect() - QMarginsF(0.5, 0.5, 0.5, 0.5);
mXmlWriter.writeAttribute("y", QString("%1").arg(item->boundingRect().y())); mXmlWriter.writeAttribute("x", QString("%1").arg(rect.x()));
mXmlWriter.writeAttribute("width", QString("%1").arg(item->boundingRect().width())); mXmlWriter.writeAttribute("y", QString("%1").arg(rect.y()));
mXmlWriter.writeAttribute("height", QString("%1").arg(item->boundingRect().height())); mXmlWriter.writeAttribute("width", QString("%1").arg(rect.width()));
mXmlWriter.writeAttribute("height", QString("%1").arg(rect.height()));
mXmlWriter.writeAttribute("transform", toSvgTransform(item->sceneMatrix())); mXmlWriter.writeAttribute("transform", toSvgTransform(item->sceneMatrix()));
QString zs; QString zs;
@ -3139,10 +3144,11 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::triangleToSvg(UBGraphicsTriangle *it
*/ */
mXmlWriter.writeStartElement(UBSettings::uniboardDocumentNamespaceUri, "triangle"); mXmlWriter.writeStartElement(UBSettings::uniboardDocumentNamespaceUri, "triangle");
mXmlWriter.writeAttribute("x", QString("%1").arg(item->boundingRect().x())); QRectF rect = item->boundingRect() - QMarginsF(0.5, 0.5, 0.5, 0.5);
mXmlWriter.writeAttribute("y", QString("%1").arg(item->boundingRect().y())); mXmlWriter.writeAttribute("x", QString("%1").arg(rect.x()));
mXmlWriter.writeAttribute("width", QString("%1").arg(item->boundingRect().width())); mXmlWriter.writeAttribute("y", QString("%1").arg(rect.y()));
mXmlWriter.writeAttribute("height", QString("%1").arg(item->boundingRect().height())); mXmlWriter.writeAttribute("width", QString("%1").arg(rect.width()));
mXmlWriter.writeAttribute("height", QString("%1").arg(rect.height()));
mXmlWriter.writeAttribute("transform", toSvgTransform(item->sceneMatrix())); mXmlWriter.writeAttribute("transform", toSvgTransform(item->sceneMatrix()));
mXmlWriter.writeAttribute("orientation", UBGraphicsTriangle::orientationToStr(item->getOrientation())); mXmlWriter.writeAttribute("orientation", UBGraphicsTriangle::orientationToStr(item->getOrientation()));

Loading…
Cancel
Save