600,8 → 600,8 |
PageItem* endArrow = nullptr; |
SvgStyle *gc = m_gc.top(); |
QTransform gcm = gc->matrix; |
double BaseX = m_Doc->currentPage()->xOffset(); |
double BaseY = m_Doc->currentPage()->yOffset(); |
double baseX = m_Doc->currentPage()->xOffset(); |
double baseY = m_Doc->currentPage()->yOffset(); |
double coeff1 = sqrt(gcm.m11() * gcm.m11() + gcm.m12() * gcm.m12()); |
double coeff2 = sqrt(gcm.m21() * gcm.m21() + gcm.m22() * gcm.m22()); |
switch (item->itemType()) |
693,8 → 693,8 |
QTransform mm = gc->matrixgf; |
double rot = getRotationFromMatrix(mm, 0.0) * 180 / M_PI; |
mm.rotate(rot); |
double patDx = (item->xPos() - BaseX) - mm.dx(); |
double patDy = (item->yPos() - BaseY) - mm.dy(); |
double patDx = (item->xPos() - baseX) - mm.dx(); |
double patDy = (item->yPos() - baseY) - mm.dy(); |
item->setPatternTransform(mm.m11() * 100.0, mm.m22() * 100.0, patDx, patDy, -rot, 0, 0); |
} |
else |
740,12 → 740,12 |
FPointArray gra; |
gra.setPoints(3, gc->GradFillX1, gc->GradFillY1, gc->GradFillX2, gc->GradFillY2, gc->GradFillFX, gc->GradFillFY); |
gra.map(mm); |
item->GrStartX = gra.point(0).x() - item->xPos() + BaseX; |
item->GrStartY = gra.point(0).y() - item->yPos() + BaseY; |
item->GrEndX = gra.point(1).x() - item->xPos() + BaseX; |
item->GrEndY = gra.point(1).y() - item->yPos() + BaseY; |
item->GrFocalX = gra.point(2).x() - item->xPos() + BaseX; |
item->GrFocalY = gra.point(2).y() - item->yPos() + BaseY; |
item->GrStartX = gra.point(0).x() - item->xPos() + baseX; |
item->GrStartY = gra.point(0).y() - item->yPos() + baseY; |
item->GrEndX = gra.point(1).x() - item->xPos() + baseX; |
item->GrEndY = gra.point(1).y() - item->yPos() + baseY; |
item->GrFocalX = gra.point(2).x() - item->xPos() + baseX; |
item->GrFocalY = gra.point(2).y() - item->yPos() + baseY; |
double ScaleX = 1.0; |
double ScaleY = 1.0; |
getScaleFromMatrix(mm, ScaleX, ScaleY); |
772,8 → 772,8 |
QTransform mm = gc->matrixgs; |
double rot = getRotationFromMatrix(mm, 0.0) * 180 / M_PI; |
mm.rotate(rot); |
double patDx = (item->xPos() - BaseX) - mm.dx(); |
double patDy = (item->yPos() - BaseY) - mm.dy(); |
double patDx = (item->xPos() - baseX) - mm.dx(); |
double patDy = (item->yPos() - baseY) - mm.dy(); |
item->setStrokePatternTransform(mm.m11() * 100.0, mm.m22() * 100.0, patDx, patDy, -rot, 0, 0, 1); |
} |
else |
819,12 → 819,12 |
FPointArray gra; |
gra.setPoints(3, gc->GradStrokeX1, gc->GradStrokeY1, gc->GradStrokeX2, gc->GradStrokeY2, gc->GradStrokeFX, gc->GradStrokeFY); |
gra.map(mm); |
item->GrStrokeStartX = gra.point(0).x() - item->xPos() + BaseX; |
item->GrStrokeStartY = gra.point(0).y() - item->yPos() + BaseY; |
item->GrStrokeEndX = gra.point(1).x() - item->xPos() + BaseX; |
item->GrStrokeEndY = gra.point(1).y() - item->yPos() + BaseY; |
item->GrStrokeFocalX = gra.point(2).x() - item->xPos() + BaseX; |
item->GrStrokeFocalY = gra.point(2).y() - item->yPos() + BaseY; |
item->GrStrokeStartX = gra.point(0).x() - item->xPos() + baseX; |
item->GrStrokeStartY = gra.point(0).y() - item->yPos() + baseY; |
item->GrStrokeEndX = gra.point(1).x() - item->xPos() + baseX; |
item->GrStrokeEndY = gra.point(1).y() - item->yPos() + baseY; |
item->GrStrokeFocalX = gra.point(2).x() - item->xPos() + baseX; |
item->GrStrokeFocalY = gra.point(2).y() - item->yPos() + baseY; |
} |
item->GrTypeStroke = gc->StrokeGradientType; |
} |
1243,13 → 1243,13 |
} |
else |
{ |
double BaseX = m_Doc->currentPage()->xOffset(); |
double BaseY = m_Doc->currentPage()->yOffset(); |
double baseX = m_Doc->currentPage()->xOffset(); |
double baseY = m_Doc->currentPage()->yOffset(); |
groupLevel++; |
setupNode(e); |
parseClipPathAttr(e, clipPath); |
m_gc.top()->forGroup = true; |
int z = m_Doc->itemAdd(PageItem::Group, PageItem::Rectangle, BaseX, BaseY, 1, 1, 0, CommonStrings::None, CommonStrings::None); |
int z = m_Doc->itemAdd(PageItem::Group, PageItem::Rectangle, baseX, baseY, 1, 1, 0, CommonStrings::None, CommonStrings::None); |
PageItem *neu = m_Doc->Items->at(z); |
for ( QDomNode n = e.firstChild(); !n.isNull(); n = n.nextSibling() ) |
{ |
1316,7 → 1316,7 |
QTransform mm = gc->matrix; |
neu->PoLine = clipPath.copy(); |
neu->PoLine.map(mm); |
neu->PoLine.translate(-gx + BaseX, -gy + BaseY); |
neu->PoLine.translate(-gx + baseX, -gy + baseY); |
clipPath.resize(0); |
neu->Clip = FlattenPath(neu->PoLine, neu->Segments); |
} |
1525,14 → 1525,14 |
QList<PageItem*> SVGPlug::parseCircle(const QDomElement &e) |
{ |
QList<PageItem*> CElements; |
double BaseX = m_Doc->currentPage()->xOffset(); |
double BaseY = m_Doc->currentPage()->yOffset(); |
double baseX = m_Doc->currentPage()->xOffset(); |
double baseY = m_Doc->currentPage()->yOffset(); |
double r = parseUnit( e.attribute( "r" ) ); |
double x = parseUnit( e.attribute( "cx" ) ) - r; |
double y = parseUnit( e.attribute( "cy" ) ) - r; |
setupNode(e); |
SvgStyle *gc = m_gc.top(); |
int z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Ellipse, BaseX, BaseY, r * 2.0, r * 2.0, gc->LWidth, gc->FillCol, gc->StrokeCol); |
int z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Ellipse, baseX, baseY, r * 2.0, r * 2.0, gc->LWidth, gc->FillCol, gc->StrokeCol); |
PageItem* ite = m_Doc->Items->at(z); |
QTransform mm = QTransform(); |
mm.translate(x, y); |
1548,8 → 1548,8 |
QList<PageItem*> SVGPlug::parseEllipse(const QDomElement &e) |
{ |
QList<PageItem*> EElements; |
double BaseX = m_Doc->currentPage()->xOffset(); |
double BaseY = m_Doc->currentPage()->yOffset(); |
double baseX = m_Doc->currentPage()->xOffset(); |
double baseY = m_Doc->currentPage()->yOffset(); |
double rx = parseUnit( e.attribute( "rx" ) ); |
double ry = parseUnit( e.attribute( "ry" ) ); |
double x = parseUnit( e.attribute( "cx" ) ) - rx; |
1556,7 → 1556,7 |
double y = parseUnit( e.attribute( "cy" ) ) - ry; |
setupNode(e); |
SvgStyle *gc = m_gc.top(); |
int z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Ellipse, BaseX, BaseY, rx * 2.0, ry * 2.0, gc->LWidth, gc->FillCol, gc->StrokeCol); |
int z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Ellipse, baseX, baseY, rx * 2.0, ry * 2.0, gc->LWidth, gc->FillCol, gc->StrokeCol); |
PageItem* ite = m_Doc->Items->at(z); |
QTransform mm = QTransform(); |
mm.translate(x, y); |
1574,8 → 1574,8 |
FPointArray clipPath; |
QList<PageItem*> IElements; |
QString fname = e.attribute("xlink:href"); |
double BaseX = m_Doc->currentPage()->xOffset(); |
double BaseY = m_Doc->currentPage()->yOffset(); |
double baseX = m_Doc->currentPage()->xOffset(); |
double baseY = m_Doc->currentPage()->yOffset(); |
double x = e.attribute( "x" ).isEmpty() ? 0.0 : parseUnit( e.attribute( "x" ) ); |
double y = e.attribute( "y" ).isEmpty() ? 0.0 : parseUnit( e.attribute( "y" ) ); |
double w = e.attribute( "width" ).isEmpty() ? 1.0 : parseUnit( e.attribute( "width" ) ); |
1582,7 → 1582,7 |
double h = e.attribute( "height" ).isEmpty() ? 1.0 : parseUnit( e.attribute( "height" ) ); |
setupNode(e); |
parseClipPathAttr(e, clipPath); |
int z = m_Doc->itemAdd(PageItem::ImageFrame, PageItem::Unspecified, BaseX, BaseY, w, h, 1, m_Doc->itemToolPrefs().imageFillColor, m_Doc->itemToolPrefs().imageStrokeColor); |
int z = m_Doc->itemAdd(PageItem::ImageFrame, PageItem::Unspecified, baseX, baseY, w, h, 1, m_Doc->itemToolPrefs().imageFillColor, m_Doc->itemToolPrefs().imageStrokeColor); |
PageItem* ite = m_Doc->Items->at(z); |
if (!fname.isEmpty()) |
{ |
1625,8 → 1625,8 |
QList<PageItem*> SVGPlug::parseLine(const QDomElement &e) |
{ |
QList<PageItem*> LElements; |
double BaseX = m_Doc->currentPage()->xOffset(); |
double BaseY = m_Doc->currentPage()->yOffset(); |
double baseX = m_Doc->currentPage()->xOffset(); |
double baseY = m_Doc->currentPage()->yOffset(); |
double x1 = e.attribute( "x1" ).isEmpty() ? 0.0 : parseUnit( e.attribute( "x1" ) ); |
double y1 = e.attribute( "y1" ).isEmpty() ? 0.0 : parseUnit( e.attribute( "y1" ) ); |
double x2 = e.attribute( "x2" ).isEmpty() ? 0.0 : parseUnit( e.attribute( "x2" ) ); |
1633,7 → 1633,7 |
double y2 = e.attribute( "y2" ).isEmpty() ? 0.0 : parseUnit( e.attribute( "y2" ) ); |
setupNode(e); |
SvgStyle *gc = m_gc.top(); |
int z = m_Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, BaseX, BaseY, 10, 10, gc->LWidth, gc->FillCol, gc->StrokeCol); |
int z = m_Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, baseX, baseY, 10, 10, gc->LWidth, gc->FillCol, gc->StrokeCol); |
PageItem* ite = m_Doc->Items->at(z); |
ite->PoLine.resize(4); |
ite->PoLine.setPoint(0, FPoint(x1, y1)); |
1681,12 → 1681,12 |
{ |
FPointArray pArray; |
QList<PageItem*> PElements; |
double BaseX = m_Doc->currentPage()->xOffset(); |
double BaseY = m_Doc->currentPage()->yOffset(); |
double baseX = m_Doc->currentPage()->xOffset(); |
double baseY = m_Doc->currentPage()->yOffset(); |
setupNode(e); |
SvgStyle *gc = m_gc.top(); |
PageItem::ItemType itype = parseSVG(e.attribute("d"), &pArray) ? PageItem::PolyLine : PageItem::Polygon; |
int z = m_Doc->itemAdd(itype, PageItem::Unspecified, BaseX, BaseY, 10, 10, gc->LWidth, gc->FillCol, gc->StrokeCol); |
int z = m_Doc->itemAdd(itype, PageItem::Unspecified, baseX, baseY, 10, 10, gc->LWidth, gc->FillCol, gc->StrokeCol); |
PageItem* ite = m_Doc->Items->at(z); |
ite->fillRule = (gc->fillRule != "nonzero"); |
ite->PoLine = pArray; |
1711,8 → 1711,8 |
{ |
int z; |
QList<PageItem*> PElements; |
double BaseX = m_Doc->currentPage()->xOffset(); |
double BaseY = m_Doc->currentPage()->yOffset(); |
double baseX = m_Doc->currentPage()->xOffset(); |
double baseY = m_Doc->currentPage()->yOffset(); |
setupNode(e); |
SvgStyle *gc = m_gc.top(); |
QString points = e.attribute( "points" ); |
1722,9 → 1722,9 |
points = points.simplified().replace(',', " "); |
QStringList pointList = points.split( ' ', QString::SkipEmptyParts ); |
if ((STag == "polygon" ) && (pointList.count() > 4)) |
z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, BaseX, BaseY, 10, 10, gc->LWidth, gc->FillCol, gc->StrokeCol); |
z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, baseX, baseY, 10, 10, gc->LWidth, gc->FillCol, gc->StrokeCol); |
else |
z = m_Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, BaseX, BaseY, 10, 10, gc->LWidth, gc->FillCol, gc->StrokeCol); |
z = m_Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, baseX, baseY, 10, 10, gc->LWidth, gc->FillCol, gc->StrokeCol); |
PageItem* ite = m_Doc->Items->at(z); |
ite->fillRule = (gc->fillRule != "nonzero"); |
ite->PoLine.resize(0); |
1768,8 → 1768,8 |
QList<PageItem*> SVGPlug::parseRect(const QDomElement &e) |
{ |
QList<PageItem*> RElements; |
double BaseX = m_Doc->currentPage()->xOffset(); |
double BaseY = m_Doc->currentPage()->yOffset(); |
double baseX = m_Doc->currentPage()->xOffset(); |
double baseY = m_Doc->currentPage()->yOffset(); |
double x = parseUnit( e.attribute( "x" ) ); |
double y = parseUnit( e.attribute( "y" ) ); |
double width = parseUnit( e.attribute( "width" )); |
1778,7 → 1778,7 |
double ry = e.attribute( "ry" ).isEmpty() ? 0.0 : parseUnit( e.attribute( "ry" ) ); |
setupNode(e); |
SvgStyle *gc = m_gc.top(); |
int z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, BaseX, BaseY, width, height, gc->LWidth, gc->FillCol, gc->StrokeCol); |
int z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, baseX, baseY, width, height, gc->LWidth, gc->FillCol, gc->StrokeCol); |
PageItem* ite = m_Doc->Items->at(z); |
if ((rx != 0) || (ry != 0)) |
{ |
1866,9 → 1866,9 |
QList<PageItem*> SVGPlug::parseTextNode(const QDomText& e, FPoint& currentPos, double chunkW) |
{ |
QList<PageItem*> GElements; |
double BaseX = m_Doc->currentPage()->xOffset(); |
double BaseY = m_Doc->currentPage()->yOffset(); |
double StartX = currentPos.x(), StartY = currentPos.y(); |
double baseX = m_Doc->currentPage()->xOffset(); |
double baseY = m_Doc->currentPage()->yOffset(); |
double startX = currentPos.x(), startY = currentPos.y(); |
|
QString textString = e.data().simplified(); |
if ( textString.isEmpty() ) |
1880,20 → 1880,22 |
double width = fm.width(textString); |
|
if (gc->textAnchor == "middle") |
StartX -= chunkW / 2.0; |
startX -= chunkW / 2.0; |
else if (gc->textAnchor == "end") |
StartX -= chunkW; |
startX -= chunkW; |
|
FPointArray textPath; |
QString textFillColor = gc->FillCol; |
QString textStrokeColor = gc->StrokeCol; |
|
QPainterPath painterPath; |
painterPath.addText( StartX, StartY, textFont, textString ); |
painterPath.addText(startX, startY, textFont, textString); |
|
textPath.fromQPainterPath(painterPath); |
if (!textPath.empty()) |
{ |
// double lineWidth = 0.0; |
int z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, BaseX, BaseY, 10, 10, gc->LWidth, textFillColor, textStrokeColor); |
int z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, baseX, baseY, 10, 10, gc->LWidth, textFillColor, textStrokeColor); |
PageItem* ite = m_Doc->Items->at(z); |
ite->PoLine = textPath; |
finishNode(e, ite); |
2338,23 → 2340,23 |
{ |
QString parse = s.trimmed(); |
QStringList colors = parse.split(',', QString::SkipEmptyParts); |
QString r = colors[0].right( ( colors[0].length() - 4 ) ); |
QString r = colors[0].right(colors[0].length() - 4); |
QString g = colors[1]; |
QString b = colors[2].left( ( colors[2].length() - 1 ) ); |
QString b = colors[2].left(colors[2].length() - 1); |
if (r.contains( "%" )) |
{ |
r.chop(1); |
r = QString::number( static_cast<int>( ( static_cast<double>( 255 * ScCLocale::toDoubleC(r) ) / 100.0 ) ) ); |
r = QString::number( static_cast<int>((255.0 * ScCLocale::toDoubleC(r)) / 100.0) ); |
} |
if (g.contains( "%" )) |
{ |
g.chop(1); |
g = QString::number( static_cast<int>( ( static_cast<double>( 255 * ScCLocale::toDoubleC(g) ) / 100.0 ) ) ); |
g = QString::number( static_cast<int>((255.0 * ScCLocale::toDoubleC(g)) / 100.0) ); |
} |
if (b.contains( "%" )) |
{ |
b.chop(1); |
b = QString::number( static_cast<int>( ( static_cast<double>( 255 * ScCLocale::toDoubleC(b) ) / 100.0 ) ) ); |
b = QString::number( static_cast<int>((255.0 * ScCLocale::toDoubleC(b)) / 100.0) ); |
} |
c = QColor(r.toInt(), g.toInt(), b.toInt()); |
} |