r16251 by fschmid - Reduced size of saved files by not writing attributes which have the default value specified in the loader.
scribus-commit
scribus-commit at lists.scribus.net
Sat Jan 15 00:32:42 CET 2011
Author: fschmid
Date: Fri Jan 14 23:32:41 2011
New Revision: 16251
URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=16251
Log:
Reduced size of saved files by not writing attributes which have the default value specified in the loader.
Modified:
trunk/Scribus/scribus/fpointarray.cpp
trunk/Scribus/scribus/fpointarray.h
trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
Modified: trunk/Scribus/scribus/fpointarray.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16251&path=/trunk/Scribus/scribus/fpointarray.cpp
==============================================================================
--- trunk/Scribus/scribus/fpointarray.cpp (original)
+++ trunk/Scribus/scribus/fpointarray.cpp Fri Jan 14 23:32:41 2011
@@ -514,11 +514,12 @@
};
-QString FPointArray::svgPath() const
+QString FPointArray::svgPath(bool closed) const
{
QString tmp = "";
- FPoint np, np1, np2;
+ FPoint np, np1, np2, np3;
bool nPath = true;
+ bool first = true;
if (size() > 3)
{
for (uint poi=0; poi < size()-3; poi += 4)
@@ -532,58 +533,24 @@
if (nPath)
{
np = point(poi);
+ if ((!first) && (closed))
+ tmp += "Z ";
tmp += "M"+QString::number(np.x())+" "+QString::number(np.y())+" ";
nPath = false;
}
- np = point(poi+1);
- tmp += "C"+QString::number(np.x())+" "+QString::number(np.y())+" ";
- np1 = point(poi+3);
- tmp += QString::number(np1.x())+" "+QString::number(np1.y())+" ";
- np2 = point(poi+2);
- tmp += QString::number(np2.x())+" "+QString::number(np2.y())+" ";
- }
+ np = point(poi);
+ np1 = point(poi+1);
+ np2 = point(poi+3);
+ np3 = point(poi+2);
+ if ((np == np1) && (np2 == np3))
+ tmp += QString("L%1 %2 ").arg(np3.x()).arg(np3.y());
+ else
+ tmp += QString("C%1 %2 %3 %4 %5 %6 ").arg(np1.x()).arg(np1.y()).arg(np2.x()).arg(np2.y()).arg(np3.x()).arg(np3.y());
+ }
+ if (closed)
+ tmp += "Z";
}
return tmp;
-/* Xml_string result;
- bool hasPoint = false;
- double x, y, x1, y1, x2, y2, xe=0, ye=0;
- uint i=0;
- while (i < size())
- {
- point(i++, &x, &y);
- if (x > 900000 && y > 900000) // marker for closepath
- {
- hasPoint = false;
- continue;
- }
- if (!hasPoint || x != xe || y != ye) // start a subpath
- {
- result += "M";
- result += QString::number(x);
- result += " ";
- result += QString::number(y);
- result += "C";
- hasPoint = true;
- }
- else
- result += " ";
-
- point(i++, &x1, &y1);
- point(i++, &x2, &y2);
- point(i++, &xe, &ye);
- result += QString::number(x1);
- result += " ";
- result += QString::number(y1);
- result += " ";
- result += QString::number(x2);
- result += " ";
- result += QString::number(y2);
- result += " ";
- result += QString::number(xe);
- result += " ";
- result += QString::number(ye);
- }
- return result; */
}
QPainterPath FPointArray::toQPainterPath(bool closed)
Modified: trunk/Scribus/scribus/fpointarray.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16251&path=/trunk/Scribus/scribus/fpointarray.h
==============================================================================
--- trunk/Scribus/scribus/fpointarray.h (original)
+++ trunk/Scribus/scribus/fpointarray.h Fri Jan 14 23:32:41 2011
@@ -84,7 +84,7 @@
void svgClosePath();
void calculateArc(bool relative, double &curx, double &cury, double angle, double x, double y, double r1, double r2, bool largeArcFlag, bool sweepFlag);
bool parseSVG(const QString& svgPath);
- QString svgPath() const;
+ QString svgPath(bool closed = false) const;
QPainterPath toQPainterPath(bool closed);
void fromQPainterPath(QPainterPath &path);
private:
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16251&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp Fri Jan 14 23:32:41 2011
@@ -3396,7 +3396,7 @@
currItem->setStartArrowScale(attrs.valueAsInt("startArrowScale", 100));
currItem->setEndArrowScale(attrs.valueAsInt("endArrowScale", 100));
currItem->NamedLStyle = attrs.valueAsString("NAMEDLST", "");
- currItem->isBookmark = attrs.valueAsInt("BOOKMARK");
+ currItem->isBookmark = attrs.valueAsInt("BOOKMARK", 0);
if ((currItem->isBookmark) && (doc->BookMarks.count() == 0))
doc->OldBM = true;
currItem->setImageFlippedH( attrs.valueAsInt("FLIPPEDH", 0));
@@ -3405,8 +3405,8 @@
currItem->ClipEdited = attrs.valueAsInt("CLIPEDIT", 0);
currItem->setFillColor(Pcolor);
currItem->setLineColor(Pcolor2);
- currItem->setFillShade(attrs.valueAsInt("SHADE"));
- currItem->setLineShade(attrs.valueAsInt("SHADE2"));
+ currItem->setFillShade(attrs.valueAsInt("SHADE", 100));
+ currItem->setLineShade(attrs.valueAsInt("SHADE2", 100));
ParagraphStyle pstyle;
if (attrs.hasAttribute("LINESP"))
@@ -3481,7 +3481,7 @@
currItem->itemText.setDefaultStyle(defStyle);
}
}
- currItem->setRotation( attrs.valueAsDouble("ROT") );
+ currItem->setRotation( attrs.valueAsDouble("ROT", 0.0) );
currItem->setTextToFrameDist(attrs.valueAsDouble("EXTRA", 1.0),
attrs.valueAsDouble("REXTRA", 1.0),
attrs.valueAsDouble("TEXTRA", 1.0),
@@ -3491,7 +3491,7 @@
currItem->PLineArt = Qt::PenStyle(attrs.valueAsInt("PLINEART", 0));
currItem->PLineEnd = Qt::PenCapStyle(attrs.valueAsInt("PLINEEND", 0));
currItem->PLineJoin = Qt::PenJoinStyle(attrs.valueAsInt("PLINEJOIN", 0));
- currItem->setPrintEnabled( attrs.valueAsInt("PRINTABLE"));
+ currItem->setPrintEnabled( attrs.valueAsInt("PRINTABLE", 1));
currItem->setIsAnnotation( attrs.valueAsInt("ANNOTATION", 0));
currItem->annotation().setType( attrs.valueAsInt("ANTYPE", 0));
QString AnName = attrs.valueAsString("ANNAME","");
@@ -3582,7 +3582,7 @@
currItem->textPathFlipped = attrs.valueAsBool("textPathFlipped", false);
if ( attrs.hasAttribute("TEXTFLOWMODE") )
currItem->setTextFlowMode((PageItem::TextFlowMode) attrs.valueAsInt("TEXTFLOWMODE", 0));
- else if ( attrs.valueAsInt("TEXTFLOW") )
+ else if ( attrs.valueAsInt("TEXTFLOW", 0) != 0)
{
if (attrs.valueAsInt("TEXTFLOW2", 0))
currItem->setTextFlowMode(PageItem::TextFlowUsesBoundingBox);
@@ -3593,13 +3593,12 @@
}
else
currItem->setTextFlowMode(PageItem::TextFlowDisabled);
- currItem->DashOffset = attrs.valueAsDouble("DASHOFF", 0.0);
currItem->setReversed(attrs.valueAsBool("REVERS", false));
currItem->setLocked (attrs.valueAsBool("LOCK", false));
currItem->setSizeLocked(attrs.valueAsBool("LOCKR", false));
- currItem->setFillTransparency(attrs.valueAsDouble("TransValue", 0.0));
currItem->fillRule = attrs.valueAsBool("fillRule", true);
currItem->doOverprint = attrs.valueAsBool("doOverprint", false);
+ currItem->setFillTransparency(attrs.valueAsDouble("TransValue", 0.0));
if (attrs.hasAttribute("TransValueS"))
currItem->setLineTransparency(attrs.valueAsDouble("TransValueS", 0.0));
else
@@ -3628,6 +3627,7 @@
}
else
currItem->DashValues.clear();
+ currItem->DashOffset = attrs.valueAsDouble("DASHOFF", 0.0);
tmp = "";
if (attrs.hasAttribute("NUMPO"))
@@ -3644,7 +3644,10 @@
}
}
else
+ {
currItem->PoLine.resize(0);
+ currItem->PoLine.parseSVG(attrs.valueAsString("path"));
+ }
tmp = "";
if (attrs.hasAttribute("NUMCO"))
@@ -3660,6 +3663,8 @@
currItem->ContourLine.setPoint(cx, xf, yf);
}
}
+ else if (attrs.hasAttribute("copath"))
+ currItem->ContourLine.parseSVG(attrs.valueAsString("path"));
else
currItem->ContourLine = currItem->PoLine.copy();
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16251&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp Fri Jan 14 23:32:41 2011
@@ -1279,13 +1279,17 @@
docu.writeAttribute("YPOS", item->yPos());
}
SetItemProps(docu, item, baseDir, true);
- docu.writeAttribute("OnMasterPage", item->OnMasterPage);
- docu.writeAttribute("ImageClip", item->pixm.imgInfo.usedPath);
+ if (!item->OnMasterPage.isEmpty())
+ docu.writeAttribute("OnMasterPage", item->OnMasterPage);
+ if (!item->pixm.imgInfo.usedPath.isEmpty())
+ docu.writeAttribute("ImageClip", item->pixm.imgInfo.usedPath);
docu.writeAttribute("ImageRes", item->pixm.imgInfo.lowResType);
docu.writeAttribute("Pagenumber", item->pixm.imgInfo.actualPageNumber);
docu.writeAttribute("isInline", static_cast<int>(item->isEmbedded));
- docu.writeAttribute("fillRule", static_cast<int>(item->fillRule));
- docu.writeAttribute("doOverprint", static_cast<int>(item->doOverprint));
+ if (!item->fillRule)
+ docu.writeAttribute("fillRule", 0);
+ if (item->doOverprint)
+ docu.writeAttribute("doOverprint", 1);
docu.writeAttribute("gXpos", item->gXpos);
docu.writeAttribute("gYpos", item->gYpos);
docu.writeAttribute("gWidth", item->gWidth);
@@ -1393,9 +1397,9 @@
docu.writeAttribute("pMirrorYS" , mirrorY);
docu.writeAttribute("pAtPathS" , atPath);
}
- docu.writeAttribute("GRTYPM", item->GrMask);
if (item->GrMask > 0)
{
+ docu.writeAttribute("GRTYPM", item->GrMask);
docu.writeAttribute("GRSTARTXM", item->GrMaskStartX);
docu.writeAttribute("GRSTARTYM", item->GrMaskStartY);
docu.writeAttribute("GRENDXM", item->GrMaskEndX);
@@ -1428,7 +1432,8 @@
docu.writeAttribute("ALIGN", item->itemText.defaultStyle().alignment());
docu.writeAttribute("LAYER", item->LayerID);
- docu.writeAttribute("BOOKMARK", item->isBookmark ? 1 : 0);
+ if (item->isBookmark)
+ docu.writeAttribute("BOOKMARK", 1);
if (item->asTextFrame() || item->asPathText() || item->asImageFrame())
{
@@ -1645,33 +1650,50 @@
void Scribus150Format::SetItemProps(ScXmlStreamWriter& docu, PageItem* item, const QString& baseDir, bool newFormat)
{
- double xf, yf;
+// double xf, yf;
QString tmp, tmpy;
if (newFormat)
docu.writeAttribute("OwnPage", item->OwnPage);
docu.writeAttribute("PTYPE",item->realItemType());
docu.writeAttribute("WIDTH",item->width());
docu.writeAttribute("HEIGHT",item->height());
- docu.writeAttribute("RADRECT",item->cornerRadius());
+ if (item->cornerRadius() != 0)
+ docu.writeAttribute("RADRECT",item->cornerRadius());
docu.writeAttribute("FRTYPE", item->FrameType);
docu.writeAttribute("CLIPEDIT", item->ClipEdited ? 1 : 0);
- docu.writeAttribute("GRTYP",item->GrType);
- docu.writeAttribute("GRTYPS",item->GrTypeStroke);
- docu.writeAttribute("ROT",item->rotation());
- docu.writeAttribute("PRINTABLE", item->printEnabled() ? 1 : 0);
- docu.writeAttribute("FLIPPEDH", item->imageFlippedH());
- docu.writeAttribute("FLIPPEDV", item->imageFlippedV());
+ if (item->GrType != 0)
+ docu.writeAttribute("GRTYP",item->GrType);
+ if (item->GrTypeStroke != 0)
+ docu.writeAttribute("GRTYPS",item->GrTypeStroke);
+ if (item->rotation() != 0)
+ docu.writeAttribute("ROT",item->rotation());
+ if (!item->printEnabled())
+ docu.writeAttribute("PRINTABLE", 0);
+ if (item->imageFlippedH())
+ docu.writeAttribute("FLIPPEDH", 1);
+ if (item->imageFlippedV())
+ docu.writeAttribute("FLIPPEDV", 1);
if (!(item->isGroup() || item->isSymbol()))
{
docu.writeAttribute("PWIDTH",item->lineWidth());
- docu.writeAttribute("PCOLOR",item->fillColor());
- docu.writeAttribute("PCOLOR2",item->lineColor());
- docu.writeAttribute("NAMEDLST",item->NamedLStyle);
- docu.writeAttribute("SHADE",item->fillShade());
- docu.writeAttribute("SHADE2",item->lineShade());
- docu.writeAttribute("PLINEART",item->PLineArt);
- docu.writeAttribute("PLINEEND", item->PLineEnd);
- docu.writeAttribute("PLINEJOIN", item->PLineJoin);
+ if (item->fillColor() != CommonStrings::None)
+ {
+ docu.writeAttribute("PCOLOR",item->fillColor());
+ docu.writeAttribute("SHADE",item->fillShade());
+ }
+ if (item->lineColor() != CommonStrings::None)
+ {
+ docu.writeAttribute("PCOLOR2",item->lineColor());
+ docu.writeAttribute("SHADE2",item->lineShade());
+ }
+ if (!item->NamedLStyle.isEmpty())
+ docu.writeAttribute("NAMEDLST",item->NamedLStyle);
+ if (item->PLineArt != 0)
+ docu.writeAttribute("PLINEART",item->PLineArt);
+ if (item->PLineEnd != 0)
+ docu.writeAttribute("PLINEEND", item->PLineEnd);
+ if (item->PLineJoin != 0)
+ docu.writeAttribute("PLINEJOIN", item->PLineJoin);
}
if (item->asRegularPolygon())
{
@@ -1732,16 +1754,16 @@
docu.writeAttribute("ANPLACE", item->annotation().IPlace());
docu.writeAttribute("ANSCALE", item->annotation().ScaleW());
}
- else
- docu.writeAttribute("ANNOTATION",0);
- docu.writeAttribute("ANNAME", !item->AutoName ? item->itemName() : QString(""));
+ if (!item->AutoName)
+ docu.writeAttribute("ANNAME", item->itemName());
// "TEXTFLOWMODE" succeed to "TEXTFLOW" "TEXTFLOW2" and "TEXTFLOW3" attributes
- docu.writeAttribute("TEXTFLOWMODE", (int) item->textFlowMode() );
+ if (item->textFlowMode() != 0)
+ docu.writeAttribute("TEXTFLOWMODE", (int) item->textFlowMode() );
// Set "TEXTFLOW" "TEXTFLOW2" and "TEXTFLOW3" attributes for compatibility
// with versions prior to 1.3.4
- docu.writeAttribute("TEXTFLOW" , item->textFlowAroundObject() ? 1 : 0);
- docu.writeAttribute("TEXTFLOW2", item->textFlowUsesBoundingBox() ? 1 : 0);
- docu.writeAttribute("TEXTFLOW3", item->textFlowUsesContourLine() ? 1 : 0);
+// docu.writeAttribute("TEXTFLOW" , item->textFlowAroundObject() ? 1 : 0);
+// docu.writeAttribute("TEXTFLOW2", item->textFlowUsesBoundingBox() ? 1 : 0);
+// docu.writeAttribute("TEXTFLOW3", item->textFlowUsesContourLine() ? 1 : 0);
if (item->asTextFrame() || item->asPathText() || item->asImageFrame())
{
docu.writeAttribute("LOCALSCX",item->imageXScale());
@@ -1871,16 +1893,10 @@
}
}
#endif
- else
- docu.writeAttribute("PFILE","");
if (!item->Pfile2.isEmpty())
docu.writeAttribute("PFILE2",Path2Relative(item->Pfile2, baseDir));
- else
- docu.writeAttribute("PFILE2","");
if (!item->Pfile3.isEmpty())
docu.writeAttribute("PFILE3",Path2Relative(item->Pfile3, baseDir));
- else
- docu.writeAttribute("PFILE3","");
docu.writeAttribute("PRFILE",item->IProfile);
docu.writeAttribute("EPROF", item->EmProfile);
docu.writeAttribute("IRENDER",item->IRender);
@@ -1892,16 +1908,23 @@
if (item->OverrideCompressionQuality)
docu.writeAttribute("COMPRESSIONQUALITY", item->CompressionQualityIndex);
}
- docu.writeAttribute("LOCK", item->locked() ? 1 : 0);
- docu.writeAttribute("LOCKR", item->sizeLocked() ? 1 : 0);
- docu.writeAttribute("REVERS", item->reversed() ? 1 : 0);
- docu.writeAttribute("TransValue", item->fillTransparency());
- docu.writeAttribute("TransValueS", item->lineTransparency());
- docu.writeAttribute("TransBlend", item->fillBlendmode());
- docu.writeAttribute("TransBlendS", item->lineBlendmode());
- docu.writeAttribute("isTableItem", static_cast<int>(item->isTableItem));
+ if (item->locked())
+ docu.writeAttribute("LOCK", 1);
+ if (item->sizeLocked())
+ docu.writeAttribute("LOCKR", 1);
+ if (item->reversed())
+ docu.writeAttribute("REVERS", 1);
+ if (item->fillTransparency() != 0)
+ docu.writeAttribute("TransValue", item->fillTransparency());
+ if (item->lineTransparency() != 0)
+ docu.writeAttribute("TransValueS", item->lineTransparency());
+ if (item->fillBlendmode() != 0)
+ docu.writeAttribute("TransBlend", item->fillBlendmode());
+ if (item->lineBlendmode() != 0)
+ docu.writeAttribute("TransBlendS", item->lineBlendmode());
if (item->isTableItem)
{
+ docu.writeAttribute("isTableItem", 1);
docu.writeAttribute("TopLine", static_cast<int>(item->TopLine));
docu.writeAttribute("LeftLine", static_cast<int>(item->LeftLine));
docu.writeAttribute("RightLine", static_cast<int>(item->RightLine));
@@ -1929,34 +1952,29 @@
docu.writeAttribute("groupWidth", item->groupWidth);
docu.writeAttribute("groupHeight", item->groupHeight);
}
- docu.writeAttribute("NUMDASH", static_cast<int>(item->DashValues.count()));
- QString dlp = "";
- QVector<double>::Iterator dax;
- for (dax = item->DashValues.begin(); dax != item->DashValues.end(); ++dax)
- dlp += tmp.setNum((*dax)) + " ";
- docu.writeAttribute("DASHS", dlp);
- docu.writeAttribute("DASHOFF", item->DashOffset);
- docu.writeAttribute("NUMPO",item->PoLine.size());
- QString polp = "";
- for (uint nxx=0; nxx<item->PoLine.size(); ++nxx)
- {
- item->PoLine.point(nxx, &xf, &yf);
- polp += tmp.setNum(xf) + " " + tmpy.setNum(yf) + " ";
- }
- docu.writeAttribute("POCOOR", polp);
- docu.writeAttribute("NUMCO",item->ContourLine.size());
- QString colp = "";
- for (uint nxx=0; nxx<item->ContourLine.size(); ++nxx)
- {
- item->ContourLine.point(nxx, &xf, &yf);
- colp += tmp.setNum(xf) + " " + tmpy.setNum(yf) + " ";
- }
- docu.writeAttribute("COCOOR", colp);
+ if (item->DashValues.count() != 0)
+ {
+ docu.writeAttribute("NUMDASH", static_cast<int>(item->DashValues.count()));
+ QString dlp = "";
+ QVector<double>::Iterator dax;
+ for (dax = item->DashValues.begin(); dax != item->DashValues.end(); ++dax)
+ dlp += tmp.setNum((*dax)) + " ";
+ docu.writeAttribute("DASHS", dlp);
+ docu.writeAttribute("DASHOFF", item->DashOffset);
+ }
+ docu.writeAttribute("path", item->PoLine.svgPath(!item->isPolyLine()));
+ QString colp = item->ContourLine.svgPath(true);
+ if (!colp.isEmpty())
+ docu.writeAttribute("copath", colp);
if (item->asLine() || item->asPolyLine())
{
- docu.writeAttribute("startArrowIndex", item->startArrowIndex());
- docu.writeAttribute("endArrowIndex", item->endArrowIndex());
- docu.writeAttribute("startArrowScale", item->startArrowScale());
- docu.writeAttribute("endArrowScale", item->endArrowScale());
- }
-}
+ if (item->startArrowIndex() != 0)
+ docu.writeAttribute("startArrowIndex", item->startArrowIndex());
+ if (item->endArrowIndex() != 0)
+ docu.writeAttribute("endArrowIndex", item->endArrowIndex());
+ if (item->startArrowScale() != 100)
+ docu.writeAttribute("startArrowScale", item->startArrowScale());
+ if (item->endArrowScale() != 100)
+ docu.writeAttribute("endArrowScale", item->endArrowScale());
+ }
+}
More information about the scribus-commit
mailing list