268
308
double y2 = Item->BoundingY;
269
309
double w2 = Item->BoundingW;
270
310
double h2 = Item->BoundingH;
271
if (!( QMAX( x, x2 ) <= QMIN( x+w, x2+w2 ) && QMAX( y, y2 ) <= QMIN( y+h, y2+h2 )))
311
if (!( qMax( x, x2 ) <= qMin( x+w, x2+w2 ) && qMax( y, y2 ) <= qMin( y+h, y2+h2 )))
273
if ((Item->fillColor() != CommonStrings::None) || (Item->GrType != 0))
313
if (Item->isGroupControl)
275
fill = "fill:"+SetFarbe(Item->fillColor(), Item->fillShade())+";";
276
if (Item->GrType != 0)
278
defi = docu->createElement("defs");
279
if ((Item->GrType == 5) || (Item->GrType == 7))
280
grad = docu->createElement("radialGradient");
282
grad = docu->createElement("linearGradient");
283
grad.setAttribute("id", gradi+IToStr(GradCount));
284
grad.setAttribute("gradientUnits", "userSpaceOnUse");
285
switch (Item->GrType)
288
grad.setAttribute("x1", "0");
289
grad.setAttribute("y1", FToStr(Item->height() / 2));
290
grad.setAttribute("x2", FToStr(Item->width()));
291
grad.setAttribute("y2", FToStr(Item->height() / 2));
294
grad.setAttribute("x1", FToStr(Item->width()/ 2));
295
grad.setAttribute("y1", "0");
296
grad.setAttribute("x2", FToStr(Item->width()/ 2));
297
grad.setAttribute("y2", FToStr(Item->height()));
300
grad.setAttribute("x1", "0");
301
grad.setAttribute("y1", "0");
302
grad.setAttribute("x2", FToStr(Item->width()));
303
grad.setAttribute("y2", FToStr(Item->height()));
306
grad.setAttribute("x1", "0");
307
grad.setAttribute("y1", FToStr(Item->height()));
308
grad.setAttribute("x2", FToStr(Item->width()));
309
grad.setAttribute("y2", "0");
312
grad.setAttribute("r", FToStr(QMAX(Item->width() / 2, Item->height() / 2)));
313
grad.setAttribute("cx", FToStr(Item->width() / 2));
314
grad.setAttribute("cy", FToStr(Item->height() / 2));
317
grad.setAttribute("x1", FToStr(Item->GrStartX));
318
grad.setAttribute("y1", FToStr(Item->GrStartY));
319
grad.setAttribute("x2", FToStr(Item->GrEndX));
320
grad.setAttribute("y2", FToStr(Item->GrEndY));
323
grad.setAttribute("r", FToStr(QMAX(Item->width() / 2, Item->height() / 2)));
324
grad.setAttribute("cx", FToStr(Item->GrStartX));
325
grad.setAttribute("cy", FToStr(Item->GrStartY));
328
QPtrVector<VColorStop> cstops = Item->fill_gradient.colorStops();
329
for (uint cst = 0; cst < Item->fill_gradient.Stops(); ++cst)
331
QDomElement itcl = docu->createElement("stop");
332
itcl.setAttribute("offset", FToStr(cstops.at(cst)->rampPoint*100)+"%");
333
itcl.setAttribute("stop-opacity", FToStr(cstops.at(cst)->opacity));
334
itcl.setAttribute("stop-color", SetFarbe(cstops.at(cst)->name, cstops.at(cst)->shade));
335
grad.appendChild(itcl);
337
defi.appendChild(grad);
338
fill = "fill:url(#"+gradi+IToStr(GradCount)+");";
342
fill += " fill-rule:evenodd;";
344
fill += " fill-rule:nonzero;";
315
groupStack.push(Item->groupsLastItem);
316
groupStack2.push(layerGroup);
317
layerGroup = docu.createElement("g");
319
layerGroup.setAttribute("id", Item->itemName());
345
320
if (Item->fillTransparency() != 0)
346
fill += " fill-opacity:"+FToStr(1.0 - Item->fillTransparency())+";";
350
if (Item->lineColor() != CommonStrings::None)
352
stroke = "stroke:"+SetFarbe(Item->lineColor(), Item->lineShade())+";";
353
if (Item->lineTransparency() != 0)
354
stroke += " stroke-opacity:"+FToStr(1.0 - Item->lineTransparency())+";";
357
stroke = "stroke:none;";
358
trans = "translate("+FToStr(Item->xPos()-Seite->xOffset())+", "+FToStr(Item->yPos()-Seite->yOffset())+")";
359
if (Item->rotation() != 0)
360
trans += " rotate("+FToStr(Item->rotation())+")";
361
strokeW = "stroke-width:"+FToStr(Item->lineWidth())+"pt;";
362
strokeLC = "stroke-linecap:";
363
switch (Item->PLineEnd)
369
strokeLC += "square;";
372
strokeLC += "round;";
378
strokeLJ = "stroke-linejoin:";
379
switch (Item->PLineJoin)
382
strokeLJ += "miter;";
385
strokeLJ += "bevel;";
388
strokeLJ += "round;";
391
strokeLJ += "miter;";
394
strokeDA = "stroke-dasharray:";
395
if (Item->DashValues.count() != 0)
397
QValueList<double>::iterator it;
398
for ( it = Item->DashValues.begin(); it != Item->DashValues.end(); ++it )
400
strokeDA += IToStr(static_cast<int>(*it))+" ";
402
strokeDA += "; stroke-dashoffset:"+IToStr(static_cast<int>(Item->DashOffset))+";";
406
QString Dt = FToStr(QMAX(2*Item->lineWidth(), 1));
407
QString Da = FToStr(QMAX(6*Item->lineWidth(), 1));
408
switch (Item->PLineArt)
414
strokeDA += Da+","+Dt+";";
419
case Qt::DashDotLine:
420
strokeDA += Da+","+Dt+","+Dt+","+Dt+";";
422
case Qt::DashDotDotLine:
423
strokeDA += Da+","+Dt+","+Dt+","+Dt+","+Dt+","+Dt+";";
430
gr = docu->createElement("g");
431
gr.setAttribute("transform", trans);
432
if (!Item->asTextFrame())
434
if (Item->NamedLStyle.isEmpty())
436
if (Item->asPathText())
437
gr.setAttribute("style", "fill:none; "+stroke+" "+strokeW+" "+strokeLC+" "+strokeLJ+" "+strokeDA);
439
gr.setAttribute("style", fill+" "+stroke+" "+strokeW+" "+strokeLC+" "+strokeLJ+" "+strokeDA);
442
switch (Item->itemType())
444
/* Item types 3 and 1 are OBSOLETE: CR 2005-02-06
448
case PageItem::Polygon:
449
if (Item->NamedLStyle.isEmpty())
451
ob = docu->createElement("path");
452
ob.setAttribute("d", SetClipPath(Item)+"Z");
456
ob = docu->createElement("path");
457
ob.setAttribute("d", SetClipPath(Item)+"Z");
458
ob.setAttribute("style", fill);
460
multiLine ml = m_Doc->MLineStyles[Item->NamedLStyle];
461
for (int it = ml.size()-1; it > -1; it--)
463
if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
465
ob = docu->createElement("path");
466
ob.setAttribute("d", SetClipPath(Item)+"Z");
467
ob.setAttribute("style", GetMultiStroke(&ml[it], Item));
473
case PageItem::ImageFrame:
474
if ((Item->fillColor() != CommonStrings::None) || (Item->GrType != 0))
476
ob = docu->createElement("path");
477
ob.setAttribute("d", SetClipPath(Item)+"Z");
478
ob.setAttribute("style", fill);
481
if ((Item->PicAvail) && (!Item->Pfile.isEmpty()))
483
ob = docu->createElement("clipPath");
484
ob.setAttribute("id", Clipi+IToStr(ClipCount));
485
ob.setAttribute("clipPathUnits", "userSpaceOnUse");
486
ob.setAttribute("clip-rule", "evenodd");
487
QDomElement cl = docu->createElement("path");
488
if (Item->imageClip.size() != 0)
489
cl.setAttribute("d", SetClipPathImage(Item)+"Z");
491
cl.setAttribute("d", SetClipPath(Item)+"Z");
495
CMSettings cms(m_Doc, Item->IProfile, Item->IRender);
496
img.LoadPicture(Item->Pfile, cms, Item->UseEmbedded, true, ScImage::RGBProof, 72);
497
img.applyEffect(Item->effectsInUse, m_Doc->PageColors, true);
498
QFileInfo fi = QFileInfo(Item->Pfile);
499
img.qImage().save(fi.baseName()+".png", "PNG");
500
ob = docu->createElement("image");
501
ob.setAttribute("clip-path", "url(#"+Clipi+IToStr(ClipCount)+")");
502
ob.setAttribute("xlink:href", fi.baseName()+".png");
503
ob.setAttribute("x", "0pt");
504
ob.setAttribute("y", "0pt");
505
ob.setAttribute("width", FToStr(Item->width())+"pt");
506
ob.setAttribute("height", FToStr(Item->height())+"pt");
510
if (Item->NamedLStyle.isEmpty())
512
ob = docu->createElement("path");
513
ob.setAttribute("d", SetClipPath(Item)+"Z");
514
ob.setAttribute("style", "fill:none; "+stroke+" "+strokeW+" "+strokeLC+" "+strokeLJ+" "+strokeDA);
518
multiLine ml = m_Doc->MLineStyles[Item->NamedLStyle];
519
for (int it = ml.size()-1; it > -1; it--)
521
if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
523
ob = docu->createElement("path");
524
ob.setAttribute("d", SetClipPath(Item)+"Z");
525
ob.setAttribute("style", "fill:none; "+GetMultiStroke(&ml[it], Item));
531
case PageItem::PolyLine:
532
if (Item->NamedLStyle.isEmpty())
534
ob = docu->createElement("path");
535
ob.setAttribute("d", SetClipPath(Item));
539
multiLine ml = m_Doc->MLineStyles[Item->NamedLStyle];
540
for (int it = ml.size()-1; it > -1; it--)
542
if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
544
ob = docu->createElement("path");
545
ob.setAttribute("d", SetClipPath(Item));
546
ob.setAttribute("style", GetMultiStroke(&ml[it], Item));
552
case PageItem::TextFrame:
553
if ((Item->fillColor() != CommonStrings::None) || (Item->GrType != 0))
555
ob = docu->createElement("path");
556
ob.setAttribute("d", SetClipPath(Item)+"Z");
557
ob.setAttribute("style", fill);
560
ob = docu->createElement("text");
561
for (d = 0; d < Item->itemText.length() && ! Item->frameDisplays(d); ++d)
563
for (; d < Item->itemText.length() && Item->frameDisplays(d); ++d)
565
hl = Item->itemText.item(d);
566
if ((hl->ch == QChar(13)) || (hl->ch == QChar(10)) || (hl->ch == QChar(9)) || (hl->ch == QChar(28)))
568
if (hl->glyph.yoffset == 0)
570
if (hl->ch == QChar(29))
574
tp = docu->createElement("tspan");
575
tp.setAttribute("x", FToStr(hl->glyph.xoffset)+"pt");
576
tp.setAttribute("y", FToStr(hl->glyph.yoffset)+"pt");
577
SetTextProps(&tp, hl);
578
tp1 = docu->createTextNode(chx);
584
if (Item->NamedLStyle.isEmpty())
586
ob = docu->createElement("path");
587
ob.setAttribute("d", "M 0 0 L "+FToStr(Item->width())+" 0");
591
multiLine ml = m_Doc->MLineStyles[Item->NamedLStyle];
592
for (int it = ml.size()-1; it > -1; it--)
594
if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
596
ob = docu->createElement("path");
597
ob.setAttribute("d", "M 0 0 L "+FToStr(Item->width())+" 0");
598
ob.setAttribute("style", GetMultiStroke(&ml[it], Item));
604
case PageItem::PathText:
607
if (Item->NamedLStyle.isEmpty())
609
ob = docu->createElement("path");
610
ob.setAttribute("d", SetClipPath(Item));
615
multiLine ml = m_Doc->MLineStyles[Item->NamedLStyle];
616
for (int it = ml.size()-1; it > -1; it--)
618
if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
620
ob = docu->createElement("path");
621
ob.setAttribute("d", SetClipPath(Item));
622
ob.setAttribute("style", GetMultiStroke(&ml[it], Item));
628
ob = docu->createElement("text");
629
for (d = 0; d < Item->itemText.length() && !Item->frameDisplays(d); ++d)
631
for (; d < Item->itemText.length() && Item->frameDisplays(d); ++d)
633
hl = Item->itemText.item(d);
634
if ((hl->ch == QChar(13)) || (hl->ch == QChar(10)) || (hl->ch == QChar(9)) || (hl->ch == QChar(25)) || (hl->ch == QChar(28)))
636
if (hl->ch == QChar(29))
640
tp = docu->createElement("tspan");
641
tp.setAttribute("x", FToStr(hl->PtransX)+"pt");
642
tp.setAttribute("y", FToStr(hl->PtransY)+"pt");
643
tp.setAttribute("rotate", hl->PRot);
644
tp2 = docu->createElement("tspan");
645
tp2.setAttribute("dx", FToStr(hl->glyph.xoffset)+"pt");
646
tp2.setAttribute("dy", FToStr(hl->glyph.yoffset)+"pt");
647
SetTextProps(&tp2, hl);
648
tp1 = docu->createTextNode(chx);
649
tp2.appendChild(tp1);
657
if (Item->GrType != 0)
658
elem->appendChild(defi);
660
elem->appendChild(gr);
321
layerGroup.setAttribute("opacity", FToStr(1.0 - Item->fillTransparency()));
322
QDomElement ob = docu.createElement("clipPath");
323
ob.setAttribute("id", "Clip"+IToStr(ClipCount));
324
QDomElement cl = docu.createElement("path");
325
cl.setAttribute("d", SetClipPath(&Item->PoLine, true));
326
QString trans = "translate("+FToStr(Item->xPos()-Seite->xOffset())+", "+FToStr(Item->yPos()-Seite->yOffset())+")";
327
if (Item->rotation() != 0)
328
trans += " rotate("+FToStr(Item->rotation())+")";
329
cl.setAttribute("transform", trans);
331
globalDefs.appendChild(ob);
332
layerGroup.setAttribute("clip-path", "url(#Clip"+IToStr(ClipCount)+")");
336
ProcessItemOnPage(Item->xPos()-Seite->xOffset(), Item->yPos()-Seite->yOffset(), Item, &layerGroup);
337
if (groupStack.count() != 0)
339
while (Item == groupStack.top())
342
groupStack2.top().appendChild(layerGroup);
343
layerGroup = groupStack2.pop();
344
if (groupStack.count() == 0)
349
for(int j = 0; j < Items.count(); ++j)
352
if (Item->LayerNr != ll.LNr)
354
if (!Item->printEnabled())
356
double x = Seite->xOffset();
357
double y = Seite->yOffset();
358
double w = Seite->width();
359
double h = Seite->height();
360
double x2 = Item->BoundingX;
361
double y2 = Item->BoundingY;
362
double w2 = Item->BoundingW;
363
double h2 = Item->BoundingH;
364
if (!( qMax( x, x2 ) <= qMin( x+w, x2+w2 ) && qMax( y, y2 ) <= qMin( y+h, y2+h2 )))
366
if (!Item->isTableItem)
368
if ((Item->lineColor() == CommonStrings::None) || (Item->lineWidth() == 0.0))
370
if ((Item->TopLine) || (Item->RightLine) || (Item->BottomLine) || (Item->LeftLine))
372
QString trans = "translate("+FToStr(Item->xPos()-Seite->xOffset())+", "+FToStr(Item->yPos()-Seite->yOffset())+")";
373
if (Item->rotation() != 0)
374
trans += " rotate("+FToStr(Item->rotation())+")";
375
QString stroke = getStrokeStyle(Item);
376
QDomElement ob = docu.createElement("path");
377
ob.setAttribute("transform", trans);
378
ob.setAttribute("style", "fill:none; " + stroke);
379
QString pathAttr = "";
381
pathAttr += "M 0 0 L "+FToStr(Item->width())+" 0";
383
pathAttr += " M " + FToStr(Item->width()) + "0 L "+FToStr(Item->width())+" "+FToStr(Item->height());
384
if (Item->BottomLine)
385
pathAttr += " M 0 " + FToStr(Item->height()) + " L "+FToStr(Item->width())+" "+FToStr(Item->height());
387
pathAttr += " M 0 0 L 0 "+FToStr(Item->height());
388
ob.setAttribute("d", pathAttr);
389
layerGroup.appendChild(ob);
392
docElement.appendChild(layerGroup);
665
396
m_Doc->setCurrentPage(SavedAct);
668
QString SVGExPlug::SetClipPath(PageItem *ite)
673
if (ite->PoLine.size() > 3)
675
for (uint poi=0; poi<ite->PoLine.size()-3; poi += 4)
677
if (ite->PoLine.point(poi).x() > 900000)
685
np = ite->PoLine.point(poi);
686
tmp += "M"+FToStr(np.x())+" "+FToStr(np.y())+" ";
689
np = ite->PoLine.point(poi+1);
690
tmp += "C"+FToStr(np.x())+" "+FToStr(np.y())+" ";
691
np1 = ite->PoLine.point(poi+3);
692
tmp += FToStr(np1.x())+" "+FToStr(np1.y())+" ";
693
np2 = ite->PoLine.point(poi+2);
694
tmp += FToStr(np2.x())+" "+FToStr(np2.y())+" ";
700
QString SVGExPlug::SetClipPathImage(PageItem *ite)
705
if (ite->imageClip.size() > 3)
707
for (uint poi=0; poi<ite->imageClip.size()-3; poi += 4)
709
if (ite->imageClip.point(poi).x() > 900000)
717
np = ite->imageClip.point(poi);
718
tmp += "M"+FToStr(np.x())+" "+FToStr(np.y())+" ";
721
np = ite->imageClip.point(poi+1);
722
tmp += "C"+FToStr(np.x())+" "+FToStr(np.y())+" ";
723
np1 = ite->imageClip.point(poi+3);
724
tmp += FToStr(np1.x())+" "+FToStr(np1.y())+" ";
725
np2 = ite->imageClip.point(poi+2);
726
tmp += FToStr(np2.x())+" "+FToStr(np2.y())+" ";
399
void SVGExPlug::ProcessItemOnPage(double xOffset, double yOffset, PageItem *Item, QDomElement *parentElem)
402
QString trans = "translate("+FToStr(xOffset)+", "+FToStr(yOffset)+")";
403
if (Item->rotation() != 0)
404
trans += " rotate("+FToStr(Item->rotation())+")";
405
QString fill = getFillStyle(Item);
406
QString stroke = "stroke:none";
407
if (!Item->isTableItem)
408
stroke = getStrokeStyle(Item);
409
switch (Item->itemType())
411
case PageItem::Polygon:
412
case PageItem::PolyLine:
413
ob = processPolyItem(Item, trans, fill, stroke);
414
if ((Item->lineColor() != CommonStrings::None) && ((Item->startArrowIndex() != 0) || (Item->endArrowIndex() != 0)))
415
ob = processArrows(Item, ob, trans);
418
ob = processLineItem(Item, trans, stroke);
419
if ((Item->lineColor() != CommonStrings::None) && ((Item->startArrowIndex() != 0) || (Item->endArrowIndex() != 0)))
420
ob = processArrows(Item, ob, trans);
422
case PageItem::ImageFrame:
423
case PageItem::LatexFrame:
424
ob = processImageItem(Item, trans, fill, stroke);
426
case PageItem::TextFrame:
427
ob = processTextItem(Item, trans, fill, stroke);
429
case PageItem::PathText:
430
ob = processPathTextItem(Item, trans, stroke);
436
ob.setAttribute("id", Item->itemName());
437
parentElem->appendChild(ob);
440
QDomElement SVGExPlug::processPolyItem(PageItem *Item, QString trans, QString fill, QString stroke)
444
if (Item->itemType() == PageItem::Polygon)
448
if (Item->NamedLStyle.isEmpty())
450
ob = docu.createElement("path");
451
ob.setAttribute("d", SetClipPath(&Item->PoLine, closedPath));
452
ob.setAttribute("transform", trans);
453
ob.setAttribute("style", fill + stroke);
457
ob = docu.createElement("g");
458
ob.setAttribute("transform", trans);
459
QDomElement ob2 = docu.createElement("path");
460
ob2.setAttribute("d", SetClipPath(&Item->PoLine, closedPath));
461
ob2.setAttribute("style", fill);
463
multiLine ml = m_Doc->MLineStyles[Item->NamedLStyle];
464
for (int it = ml.size()-1; it > -1; it--)
466
if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
468
QDomElement ob3 = docu.createElement("path");
469
ob3.setAttribute("d", SetClipPath(&Item->PoLine, closedPath));
470
ob3.setAttribute("style", GetMultiStroke(&ml[it], Item));
478
QDomElement SVGExPlug::processLineItem(PageItem *Item, QString trans, QString stroke)
481
if (Item->NamedLStyle.isEmpty())
483
ob = docu.createElement("path");
484
ob.setAttribute("d", "M 0 0 L "+FToStr(Item->width())+" 0");
485
ob.setAttribute("transform", trans);
486
ob.setAttribute("style", stroke);
490
ob = docu.createElement("g");
491
ob.setAttribute("transform", trans);
492
multiLine ml = m_Doc->MLineStyles[Item->NamedLStyle];
493
for (int it = ml.size()-1; it > -1; it--)
495
if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
497
QDomElement ob2 = docu.createElement("path");
498
ob2.setAttribute("d", "M 0 0 L "+FToStr(Item->width())+" 0");
499
ob2.setAttribute("style", GetMultiStroke(&ml[it], Item));
507
QDomElement SVGExPlug::processImageItem(PageItem *Item, QString trans, QString fill, QString stroke)
510
ob = docu.createElement("g");
511
ob.setAttribute("transform", trans);
512
if ((Item->fillColor() != CommonStrings::None) || (Item->GrType != 0))
514
QDomElement ob1 = docu.createElement("path");
515
ob1.setAttribute("d", SetClipPath(&Item->PoLine, true));
516
ob1.setAttribute("style", fill);
519
if ((Item->PictureIsAvailable) && (!Item->Pfile.isEmpty()))
521
QDomElement ob2 = docu.createElement("clipPath");
522
ob2.setAttribute("id", "Clip"+IToStr(ClipCount));
523
ob2.setAttribute("clipPathUnits", "userSpaceOnUse");
524
ob2.setAttribute("clip-rule", "evenodd");
525
QDomElement cl = docu.createElement("path");
526
if (Item->imageClip.size() != 0)
527
cl.setAttribute("d", SetClipPath(&Item->imageClip, true));
529
cl.setAttribute("d", SetClipPath(&Item->PoLine, true));
531
globalDefs.appendChild(ob2);
532
QDomElement ob3 = docu.createElement("image");
533
ob3.setAttribute("clip-path", "url(#Clip"+IToStr(ClipCount)+")");
535
CMSettings cms(m_Doc, Item->IProfile, Item->IRender);
536
img.LoadPicture(Item->Pfile, Item->pixm.imgInfo.actualPageNumber, cms, Item->UseEmbedded, true, ScImage::RGBProof, 72);
537
img.applyEffect(Item->effectsInUse, m_Doc->PageColors, true);
538
if (Options.inlineImages)
541
buffer.open(QIODevice::WriteOnly);
542
img.qImage().save(&buffer, "PNG");
543
QByteArray ba = buffer.buffer().toBase64();
545
ob3.setAttribute("xlink:href", "data:image/png;base64,"+QString(ba));
549
QFileInfo fi = QFileInfo(Item->Pfile);
550
QString imgFileName = baseDir + "/" + fi.baseName()+".png";
551
QFileInfo im = QFileInfo(imgFileName);
553
imgFileName = baseDir + "/" + fi.baseName()+"_copy.png";
554
img.qImage().save(imgFileName, "PNG");
555
QFileInfo fi2 = QFileInfo(imgFileName);
556
ob3.setAttribute("xlink:href", fi2.baseName()+".png");
558
ob3.setAttribute("x", FToStr(Item->imageXOffset() * Item->imageXScale()));
559
ob3.setAttribute("y", FToStr(Item->imageYOffset() * Item->imageYScale()));
560
ob3.setAttribute("width", FToStr(img.width() * Item->imageXScale()));
561
ob3.setAttribute("height", FToStr(img.height() * Item->imageYScale()));
563
if (Item->imageFlippedH())
565
mpa.translate(Item->width(), 0);
568
if (Item->imageFlippedV())
570
mpa.translate(0, Item->height());
573
ob3.setAttribute("transform", MatrixToStr(mpa));
577
if (Item->NamedLStyle.isEmpty())
579
QDomElement ob4 = docu.createElement("path");
580
ob4.setAttribute("d", SetClipPath(&Item->PoLine, true));
581
ob4.setAttribute("style", "fill:none; "+stroke);
586
multiLine ml = m_Doc->MLineStyles[Item->NamedLStyle];
587
for (int it = ml.size()-1; it > -1; it--)
589
if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
591
QDomElement ob5 = docu.createElement("path");
592
ob5.setAttribute("d", SetClipPath(&Item->PoLine, true));
593
ob5.setAttribute("style", "fill:none; "+GetMultiStroke(&ml[it], Item));
601
QDomElement SVGExPlug::processTextItem(PageItem *Item, QString trans, QString fill, QString stroke)
604
ob = docu.createElement("g");
605
ob.setAttribute("transform", trans);
606
if ((Item->fillColor() != CommonStrings::None) || (Item->GrType != 0))
608
QDomElement ob1 = docu.createElement("path");
609
ob1.setAttribute("d", SetClipPath(&Item->PoLine, true));
610
ob1.setAttribute("style", fill);
615
for (uint ll=0; ll < Item->itemText.lines(); ++ll)
617
LineSpec ls = Item->itemText.line(ll);
619
for (int a = ls.firstItem; a <= ls.lastItem; ++a)
623
ScText * hl = Item->itemText.item(a);
624
const CharStyle& charStyle(Item->itemText.charStyle(a));
625
chstr = Item->itemText.text(a,1);
626
if ((chstr == QChar(13)) || (chstr == QChar(29)))
628
if (chstr == QChar(29))
629
CurX += hl->glyph.wide();
632
if (chstr == QChar(30))
634
chstr = Item->ExpandToken(a);
635
if (chstr == QChar(32))
637
CurX += hl->glyph.wide();
641
double chs = charStyle.fontSize();
642
if (hl->effects() & ScStyle_SmallCaps)
644
if (chstr.toUpper() != chstr)
646
chs = qMax(static_cast<int>(hl->fontSize() * m_Doc->typographicSettings.valueSmallCaps / 100), 1);
647
chstr = chstr.toUpper();
650
else if (hl->effects() & ScStyle_AllCaps)
651
chstr = chstr.toUpper();
652
uint chr = chstr[0].unicode();
653
QMatrix chma, chma2, chma3, chma4, chma6;
654
QMatrix trafo = QMatrix( 1, 0, 0, 1, CurX, ls.y );
655
if (Item->rotation() != 0)
658
sca.translate(-Item->xPos(), -Item->yPos());
661
chma.scale(hl->glyph.scaleH * charStyle.fontSize() / 100.00, hl->glyph.scaleV * charStyle.fontSize() / 100.0);
662
if (Item->reversed())
664
if (a < Item->itemText.length()-1)
665
wide = hl->font().charWidth(chstr[0], hl->fontSize(), Item->itemText.text(a+1));
667
wide = hl->font().charWidth(chstr[0], hl->fontSize());
669
chma3.translate(-wide, 0);
671
chma4.translate(0, Item->BaseOffs - (charStyle.fontSize() / 10.0) * hl->glyph.scaleV);
672
if (charStyle.effects() & (ScStyle_Subscript | ScStyle_Superscript))
673
chma6.translate(0, hl->glyph.yoffset);
674
if (hl->baselineOffset() != 0)
675
chma6.translate(0, (-charStyle.fontSize() / 10.0) * (charStyle.baselineOffset() / 1000.0));
676
QMatrix finalMat = QMatrix(chma * chma2 * chma3 * chma4 * chma6 * trafo);
677
if (Item->rotation() != 0)
680
sca.translate(Item->xPos(), Item->yPos());
683
if ((hl->ch == SpecialChars::OBJECT) && (hl->embedded.hasItem()))
685
ob.appendChild(processInlineItem(CurX + hl->glyph.xoffset, ls.y + hl->glyph.yoffset, finalMat, hl, false, trans));
686
InlineFrame& embedded(const_cast<InlineFrame&>(hl->embedded));
687
CurX += (embedded.getItem()->gWidth + embedded.getItem()->lineWidth()) * hl->glyph.scaleH;
691
QString glName = handleGlyph(chr, hl);
692
if ((charStyle.effects() & ScStyle_Shadowed) && (charStyle.strokeColor() != CommonStrings::None) && (chstr != QChar(32)))
694
QMatrix sha = finalMat;
696
shad.translate(charStyle.fontSize() * charStyle.shadowXOffset() / 10000.0, -charStyle.fontSize() * charStyle.shadowYOffset() / 10000.0);
698
QDomElement ob2 = docu.createElement("use");
699
ob2.setAttribute("xlink:href", "#" + glName);
700
ob2.setAttribute("transform", MatrixToStr(sha));
701
ob2.setAttribute("style", "fill:"+SetColor(hl->strokeColor(), hl->strokeShade())+";" + "stroke:none;");
704
QChar chstc = hl->ch;
705
if (((charStyle.effects() & ScStyle_Underline) && !SpecialChars::isBreak(chstc))
706
|| ((charStyle.effects() & ScStyle_UnderlineWords) && !chstc.isSpace() && !SpecialChars::isBreak(chstc)))
710
double Ulen = hl->glyph.xadvance;
711
double Upos, lw, kern;
712
if (charStyle.effects() & ScStyle_StartOfLine)
715
kern = charStyle.fontSize() * charStyle.tracking() / 10000.0;
716
if ((charStyle.underlineOffset() != -1) || (charStyle.underlineWidth() != -1))
718
if (charStyle.underlineOffset() != -1)
719
Upos = (charStyle.underlineOffset() / 1000.0) * (charStyle.font().descent(charStyle.fontSize() / 10.0));
721
Upos = charStyle.font().underlinePos(charStyle.fontSize() / 10.0);
722
if (charStyle.underlineWidth() != -1)
723
lw = (charStyle.underlineWidth() / 1000.0) * (charStyle.fontSize() / 10.0);
725
lw = qMax(charStyle.font().strokeWidth(charStyle.fontSize() / 10.0), 1.0);
729
Upos = charStyle.font().underlinePos(charStyle.fontSize() / 10.0);
730
lw = qMax(charStyle.font().strokeWidth(charStyle.fontSize() / 10.0), 1.0);
732
if (charStyle.baselineOffset() != 0)
733
Upos += (charStyle.fontSize() / 10.0) * (charStyle.baselineOffset() / 1000.0);
734
QDomElement ob6 = docu.createElement("path");
735
if (charStyle.effects() & ScStyle_Subscript)
736
ob6.setAttribute("d", QString("M %1 %2 L%3 %4").arg(x + hl->glyph.xoffset-kern).arg(y + hl->glyph.yoffset - Upos).arg(x + hl->glyph.xoffset+Ulen).arg(y + hl->glyph.yoffset - Upos));
738
ob6.setAttribute("d", QString("M %1 %2 L%3 %4").arg(x + hl->glyph.xoffset-kern).arg(y - Upos).arg(x + hl->glyph.xoffset+Ulen).arg(y - Upos));
739
QString sT = "stroke:none;";
740
if (charStyle.fillColor() != CommonStrings::None)
742
sT = "stroke:"+SetColor(charStyle.fillColor(), charStyle.fillShade())+";";
743
sT += " stroke-width:"+FToStr(lw)+";";
745
ob6.setAttribute("style", "fill:none;" + sT);
748
if (chstr != QChar(32))
750
QDomElement ob3 = docu.createElement("use");
751
ob3.setAttribute("xlink:href", "#" + glName);
752
ob3.setAttribute("transform", MatrixToStr(finalMat));
753
QString fT = "fill:"+SetColor(hl->fillColor(), hl->fillShade())+";";
754
QString sT = "stroke:none;";
755
if (charStyle.effects() & ScStyle_Outline)
757
sT = "stroke:"+SetColor(hl->strokeColor(), hl->strokeShade())+";";
758
sT += " stroke-width:"+FToStr(chs * hl->outlineWidth() / 10000.0)+";";
760
ob3.setAttribute("style", fT + sT);
763
if (charStyle.effects() & ScStyle_Strikethrough)
767
double Ulen = hl->glyph.xadvance;
768
double Upos, lw, kern;
769
if (charStyle.effects() & ScStyle_StartOfLine)
772
kern = charStyle.fontSize() * charStyle.tracking() / 10000.0;
773
if ((charStyle.strikethruOffset() != -1) || (charStyle.strikethruWidth() != -1))
775
if (charStyle.strikethruOffset() != -1)
776
Upos = (charStyle.strikethruOffset() / 1000.0) * (charStyle.font().ascent(charStyle.fontSize() / 10.0));
778
Upos = charStyle.font().strikeoutPos(charStyle.fontSize() / 10.0);
779
if (charStyle.strikethruWidth() != -1)
780
lw = (charStyle.strikethruWidth() / 1000.0) * (charStyle.fontSize() / 10.0);
782
lw = qMax(charStyle.font().strokeWidth(charStyle.fontSize() / 10.0), 1.0);
786
Upos = charStyle.font().strikeoutPos(charStyle.fontSize() / 10.0);
787
lw = qMax(charStyle.font().strokeWidth(charStyle.fontSize() / 10.0), 1.0);
789
if (charStyle.baselineOffset() != 0)
790
Upos += (charStyle.fontSize() / 10.0) * hl->glyph.scaleV * (charStyle.baselineOffset() / 1000.0);
791
QDomElement ob7 = docu.createElement("path");
792
ob7.setAttribute("d", QString("M %1 %2 L%3 %4").arg(x + hl->glyph.xoffset-kern).arg(y + hl->glyph.yoffset - Upos).arg(x + hl->glyph.xoffset+Ulen).arg(y + hl->glyph.yoffset - Upos));
793
QString sT = "stroke:none;";
794
if (charStyle.fillColor() != CommonStrings::None)
796
sT = "stroke:"+SetColor(charStyle.fillColor(), charStyle.fillShade())+";";
797
sT += " stroke-width:"+FToStr(lw)+";";
799
ob7.setAttribute("style", "fill:none;" + sT);
802
CurX += hl->glyph.wide();
806
if (Item->NamedLStyle.isEmpty())
808
QDomElement ob4 = docu.createElement("path");
809
ob4.setAttribute("d", SetClipPath(&Item->PoLine, true));
810
ob4.setAttribute("style", "fill:none; "+stroke);
815
multiLine ml = m_Doc->MLineStyles[Item->NamedLStyle];
816
for (int it = ml.size()-1; it > -1; it--)
818
if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
820
QDomElement ob5 = docu.createElement("path");
821
ob5.setAttribute("d", SetClipPath(&Item->PoLine, true));
822
ob5.setAttribute("style", "fill:none; "+GetMultiStroke(&ml[it], Item));
830
QDomElement SVGExPlug::processPathTextItem(PageItem *Item, QString trans, QString stroke)
833
ob = docu.createElement("g");
834
ob.setAttribute("transform", trans);
837
if (Item->NamedLStyle.isEmpty())
839
QDomElement ob4 = docu.createElement("path");
840
ob4.setAttribute("d", SetClipPath(&Item->PoLine, false));
841
ob4.setAttribute("style", "fill:none; "+stroke);
846
multiLine ml = m_Doc->MLineStyles[Item->NamedLStyle];
847
for (int it = ml.size()-1; it > -1; it--)
849
if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
851
QDomElement ob5 = docu.createElement("path");
852
ob5.setAttribute("d", SetClipPath(&Item->PoLine, false));
853
ob5.setAttribute("style", "fill:none; "+GetMultiStroke(&ml[it], Item));
861
for (int a = 0; a < Item->itemText.length(); ++a)
865
ScText *hl = Item->itemText.item(a);
866
const CharStyle& charStyle(Item->itemText.charStyle(a));
867
chstr = Item->itemText.text(a,1);
868
if ((chstr == QChar(13)) || (chstr == QChar(29)))
870
if (chstr == QChar(30))
872
chstr = Item->ExpandToken(a);
873
if (chstr == QChar(32))
876
double chs = charStyle.fontSize();
877
if (hl->effects() & ScStyle_SmallCaps)
879
if (chstr.toUpper() != chstr)
881
chs = qMax(static_cast<int>(hl->fontSize() * m_Doc->typographicSettings.valueSmallCaps / 100), 1);
882
chstr = chstr.toUpper();
885
else if (hl->effects() & ScStyle_AllCaps)
886
chstr = chstr.toUpper();
887
uint chr = chstr[0].unicode();
888
QPointF tangt = QPointF( cos(hl->PRot), sin(hl->PRot) );
889
QMatrix chma, chma2, chma3, chma4, chma6;
890
QMatrix trafo = QMatrix( 1, 0, 0, -1, -hl->PDx, 0 );
891
if (Item->textPathFlipped)
892
trafo *= QMatrix(1, 0, 0, -1, 0, 0);
893
if (Item->textPathType == 0)
894
trafo *= QMatrix( tangt.x(), tangt.y(), tangt.y(), -tangt.x(), hl->PtransX, hl->PtransY );
895
else if (Item->textPathType == 1)
896
trafo *= QMatrix(1, 0, 0, -1, hl->PtransX, hl->PtransY );
897
else if (Item->textPathType == 2)
906
if (fabs(tangt.x()) > 0.1)
907
trafo *= QMatrix( a, (tangt.y() / tangt.x()) * b, 0, -1, hl->PtransX, hl->PtransY ); // ID's Skew mode
909
trafo *= QMatrix( a, 6 * b, 0, -1, hl->PtransX, hl->PtransY );
911
if ((hl->ch == SpecialChars::OBJECT) && (hl->embedded.hasItem()))
913
QMatrix finalMat = QMatrix(chma * chma2 * chma3 * chma4 * chma6 * trafo);
914
ob.appendChild(processInlineItem(0, 0, finalMat, hl, true, trans));
918
if (Item->rotation() != 0)
921
sca.translate(-Item->xPos(), -Item->yPos());
924
chma.scale(hl->glyph.scaleH * charStyle.fontSize() / 100.00, hl->glyph.scaleV * charStyle.fontSize() / 100.0);
925
if (Item->reversed())
927
if (a < Item->itemText.length()-1)
928
wide = hl->font().charWidth(chstr[0], hl->fontSize(), Item->itemText.text(a+1));
930
wide = hl->font().charWidth(chstr[0], hl->fontSize());
932
chma3.translate(-wide, 0);
934
chma4.translate(0, Item->BaseOffs - (charStyle.fontSize() / 10.0) * hl->glyph.scaleV);
935
if (charStyle.effects() & (ScStyle_Subscript | ScStyle_Superscript))
936
chma6.translate(0, hl->glyph.yoffset);
937
if (hl->baselineOffset() != 0)
938
chma6.translate(0, (-charStyle.fontSize() / 10.0) * (charStyle.baselineOffset() / 1000.0));
939
QMatrix finalMat = QMatrix(chma * chma2 * chma3 * chma4 * chma6 * trafo);
940
if (Item->rotation() != 0)
943
sca.translate(Item->xPos(), Item->yPos());
946
QChar chstc = hl->ch;
947
if (((charStyle.effects() & ScStyle_Underline) && !SpecialChars::isBreak(chstc))
948
|| ((charStyle.effects() & ScStyle_UnderlineWords) && !chstc.isSpace() && !SpecialChars::isBreak(chstc)))
950
QMatrix stro = QMatrix(chma2 * chma3 * chma6 * trafo);
951
if (Item->rotation() != 0)
954
sca.translate(Item->xPos(), Item->yPos());
957
double Ulen = hl->glyph.xadvance;
958
double Upos, Uwid, kern;
959
if (hl->effects() & ScStyle_StartOfLine)
962
kern = charStyle.fontSize() * charStyle.tracking() / 10000.0;
963
if ((charStyle.underlineOffset() != -1) || (charStyle.underlineWidth() != -1))
965
if (charStyle.underlineOffset() != -1)
966
Upos = (charStyle.underlineOffset() / 1000.0) * (charStyle.font().descent(charStyle.fontSize() / 10.0));
968
Upos = charStyle.font().underlinePos(charStyle.fontSize() / 10.0);
969
if (charStyle.underlineWidth() != -1)
970
Uwid = (charStyle.underlineWidth() / 1000.0) * (charStyle.fontSize() / 10.0);
972
Uwid = qMax(charStyle.font().strokeWidth(charStyle.fontSize() / 10.0), 1.0);
976
Upos = charStyle.font().underlinePos(charStyle.fontSize() / 10.0);
977
Uwid = qMax(charStyle.font().strokeWidth(charStyle.fontSize() / 10.0), 1.0);
979
if (charStyle.baselineOffset() != 0)
980
Upos += (charStyle.fontSize() / 10.0) * (charStyle.baselineOffset() / 1000.0);
981
QDomElement ob8 = docu.createElement("path");
982
ob8.setAttribute("transform", MatrixToStr(stro));
983
if (charStyle.effects() & ScStyle_Subscript)
984
ob8.setAttribute("d", QString("M %1 %2 L%3 %4").arg(hl->glyph.xoffset-kern).arg(-Upos).arg(hl->glyph.xoffset+Ulen).arg(-Upos));
986
ob8.setAttribute("d", QString("M %1 %2 L%3 %4").arg(hl->glyph.xoffset-kern).arg(-(Upos + hl->glyph.yoffset)).arg(hl->glyph.xoffset+Ulen).arg(-(Upos + hl->glyph.yoffset)));
987
QString sT = "stroke:none;";
988
if (charStyle.fillColor() != CommonStrings::None)
990
sT = "stroke:"+SetColor(charStyle.fillColor(), charStyle.fillShade())+";";
991
sT += " stroke-width:"+FToStr(Uwid)+";";
993
ob8.setAttribute("style", "fill:none;" + sT);
996
if (chstr != QChar(32))
998
QString glName = handleGlyph(chr, hl);
999
if ((charStyle.effects() & ScStyle_Shadowed) && (charStyle.strokeColor() != CommonStrings::None))
1001
QMatrix sha = finalMat;
1003
shad.translate(charStyle.fontSize() * charStyle.shadowXOffset() / 10000.0, -charStyle.fontSize() * charStyle.shadowYOffset() / 10000.0);
1005
QDomElement ob2 = docu.createElement("use");
1006
ob2.setAttribute("xlink:href", "#" + glName);
1007
ob2.setAttribute("transform", MatrixToStr(sha));
1008
ob2.setAttribute("style", "fill:"+SetColor(hl->strokeColor(), hl->strokeShade())+";" + "stroke:none;");
1009
ob.appendChild(ob2);
1011
QDomElement ob1 = docu.createElement("use");
1012
ob1.setAttribute("xlink:href", "#" + glName);
1013
ob1.setAttribute("transform", MatrixToStr(finalMat));
1014
QString fT = "fill:"+SetColor(hl->fillColor(), hl->fillShade())+";";
1015
QString sT = "stroke:none;";
1016
if (charStyle.effects() & ScStyle_Outline)
1018
sT = "stroke:"+SetColor(hl->strokeColor(), hl->strokeShade())+";";
1019
sT += " stroke-width:"+FToStr(chs * hl->outlineWidth() / 10000.0)+";";
1021
ob1.setAttribute("style", fT + sT);
1022
ob.appendChild(ob1);
1024
if (charStyle.effects() & ScStyle_Strikethrough)
1026
QMatrix stro = QMatrix(chma2 * chma3 * chma6 * trafo);
1027
if (Item->rotation() != 0)
1030
sca.translate(Item->xPos(), Item->yPos());
1033
double Ulen = hl->glyph.xadvance;
1034
double Upos, Uwid, kern;
1035
if (hl->effects() & ScStyle_StartOfLine)
1038
kern = charStyle.fontSize() * charStyle.tracking() / 10000.0;
1039
if ((charStyle.strikethruOffset() != -1) || (charStyle.strikethruWidth() != -1))
1041
if (charStyle.strikethruOffset() != -1)
1042
Upos = (charStyle.strikethruOffset() / 1000.0) * (charStyle.font().ascent(charStyle.fontSize() / 10.0));
1044
Upos = charStyle.font().strikeoutPos(charStyle.fontSize() / 10.0);
1045
if (charStyle.strikethruWidth() != -1)
1046
Uwid = (charStyle.strikethruWidth() / 1000.0) * (charStyle.fontSize() / 10.0);
1048
Uwid = qMax(charStyle.font().strokeWidth(charStyle.fontSize() / 10.0), 1.0);
1052
Upos = charStyle.font().strikeoutPos(charStyle.fontSize() / 10.0);
1053
Uwid = qMax(charStyle.font().strokeWidth(charStyle.fontSize() / 10.0), 1.0);
1055
if (charStyle.baselineOffset() != 0)
1056
Upos += (charStyle.fontSize() / 10.0) * (charStyle.baselineOffset() / 1000.0);
1057
QDomElement ob7 = docu.createElement("path");
1058
ob7.setAttribute("transform", MatrixToStr(stro));
1059
ob7.setAttribute("d", QString("M %1 %2 L%3 %4").arg(hl->glyph.xoffset-kern).arg(-Upos).arg(hl->glyph.xoffset+Ulen).arg(-Upos));
1060
QString sT = "stroke:none;";
1061
if (charStyle.fillColor() != CommonStrings::None)
1063
sT = "stroke:"+SetColor(charStyle.fillColor(), charStyle.fillShade())+";";
1064
sT += " stroke-width:"+FToStr(Uwid)+";";
1066
ob7.setAttribute("style", "fill:none;" + sT);
1067
ob.appendChild(ob7);
1074
QDomElement SVGExPlug::processInlineItem(double xpos, double ypos, QMatrix &finalMat, ScText *hl, bool pathT, QString trans)
1076
const CharStyle & charStyle(*hl);
1077
QList<PageItem*> emG = hl->embedded.getGroupedItems();
1078
QStack<PageItem*> groupStack;
1079
QStack<QDomElement> groupStack2;
1080
QDomElement layerGroup = docu.createElement("g");
1082
layerGroup.setAttribute("transform", MatrixToStr(finalMat));
1083
for (int em = 0; em < emG.count(); ++em)
1085
PageItem* embedded = emG.at(em);
1086
if (embedded->isGroupControl)
1088
groupStack.push(embedded->groupsLastItem);
1089
groupStack2.push(layerGroup);
1090
layerGroup = docu.createElement("g");
1091
if (embedded->fillTransparency() != 0)
1092
layerGroup.setAttribute("opacity", FToStr(1.0 - embedded->fillTransparency()));
1093
QDomElement ob = docu.createElement("clipPath");
1094
ob.setAttribute("id", "Clip"+IToStr(ClipCount));
1095
QDomElement cl = docu.createElement("path");
1096
cl.setAttribute("d", SetClipPath(&embedded->PoLine, true));
1098
mm.translate(xpos + embedded->gXpos * (charStyle.scaleH() / 1000.0), (ypos - (embedded->gHeight * (charStyle.scaleV() / 1000.0)) + embedded->gYpos * (charStyle.scaleV() / 1000.0)));
1099
if (charStyle.baselineOffset() != 0)
1100
mm.translate(0, embedded->gHeight * (charStyle.baselineOffset() / 1000.0));
1101
if (charStyle.scaleH() != 1000)
1102
mm.scale(charStyle.scaleH() / 1000.0, 1);
1103
if (charStyle.scaleV() != 1000)
1104
mm.scale(1, charStyle.scaleV() / 1000.0);
1105
mm.rotate(embedded->rotation());
1106
cl.setAttribute("transform", MatrixToStr(mm));
1108
globalDefs.appendChild(ob);
1109
layerGroup.setAttribute("clip-path", "url(#Clip"+IToStr(ClipCount)+")");
1114
QString fill = getFillStyle(embedded);
1115
QString stroke = "stroke:none";
1116
if (!embedded->isTableItem)
1117
stroke = getStrokeStyle(embedded);
1118
switch (embedded->itemType())
1120
case PageItem::Polygon:
1121
case PageItem::PolyLine:
1122
obE = processPolyItem(embedded, trans, fill, stroke);
1123
if ((embedded->lineColor() != CommonStrings::None) && ((embedded->startArrowIndex() != 0) || (embedded->endArrowIndex() != 0)))
1124
obE = processArrows(embedded, obE, trans);
1126
case PageItem::Line:
1127
obE = processLineItem(embedded, trans, stroke);
1128
if ((embedded->lineColor() != CommonStrings::None) && ((embedded->startArrowIndex() != 0) || (embedded->endArrowIndex() != 0)))
1129
obE = processArrows(embedded, obE, trans);
1131
case PageItem::ImageFrame:
1132
case PageItem::LatexFrame:
1133
obE = processImageItem(embedded, trans, fill, stroke);
1135
case PageItem::TextFrame:
1136
obE = processTextItem(embedded, trans, fill, stroke);
1138
case PageItem::PathText:
1139
obE = processPathTextItem(embedded, trans, stroke);
1145
mm.translate(xpos + embedded->gXpos * (charStyle.scaleH() / 1000.0), (ypos - (embedded->gHeight * (charStyle.scaleV() / 1000.0)) + embedded->gYpos * (charStyle.scaleV() / 1000.0)));
1146
if (charStyle.baselineOffset() != 0)
1147
mm.translate(0, embedded->gHeight * (charStyle.baselineOffset() / 1000.0));
1148
if (charStyle.scaleH() != 1000)
1149
mm.scale(charStyle.scaleH() / 1000.0, 1);
1150
if (charStyle.scaleV() != 1000)
1151
mm.scale(1, charStyle.scaleV() / 1000.0);
1152
mm.rotate(embedded->rotation());
1153
obE.setAttribute("transform", MatrixToStr(mm));
1154
layerGroup.appendChild(obE);
1155
if (groupStack.count() != 0)
1157
while (embedded == groupStack.top())
1160
groupStack2.top().appendChild(layerGroup);
1161
layerGroup = groupStack2.pop();
1162
if (groupStack.count() == 0)
1167
for (int em = 0; em < emG.count(); ++em)
1169
PageItem* embedded = emG.at(em);
1170
if (!embedded->isTableItem)
1172
if ((embedded->lineColor() == CommonStrings::None) || (embedded->lineWidth() == 0.0))
1174
if ((embedded->TopLine) || (embedded->RightLine) || (embedded->BottomLine) || (embedded->LeftLine))
1177
mm.translate(xpos + embedded->gXpos * (charStyle.scaleH() / 1000.0), (ypos - (embedded->gHeight * (charStyle.scaleV() / 1000.0)) + embedded->gYpos * (charStyle.scaleV() / 1000.0)));
1178
if (charStyle.baselineOffset() != 0)
1179
mm.translate(0, embedded->gHeight * (charStyle.baselineOffset() / 1000.0));
1180
if (charStyle.scaleH() != 1000)
1181
mm.scale(charStyle.scaleH() / 1000.0, 1);
1182
if (charStyle.scaleV() != 1000)
1183
mm.scale(1, charStyle.scaleV() / 1000.0);
1184
mm.rotate(embedded->rotation());
1185
QString stroke = getStrokeStyle(embedded);
1186
QDomElement obL = docu.createElement("path");
1187
obL.setAttribute("transform", MatrixToStr(mm));
1188
obL.setAttribute("style", "fill:none; " + stroke);
1189
QString pathAttr = "";
1190
if (embedded->TopLine)
1191
pathAttr += "M 0 0 L "+FToStr(embedded->width())+" 0";
1192
if (embedded->RightLine)
1193
pathAttr += " M " + FToStr(embedded->width()) + "0 L "+FToStr(embedded->width())+" "+FToStr(embedded->height());
1194
if (embedded->BottomLine)
1195
pathAttr += " M 0 " + FToStr(embedded->height()) + " L "+FToStr(embedded->width())+" "+FToStr(embedded->height());
1196
if (embedded->LeftLine)
1197
pathAttr += " M 0 0 L 0 "+FToStr(embedded->height());
1198
obL.setAttribute("d", pathAttr);
1199
layerGroup.appendChild(obL);
1205
QString SVGExPlug::handleGlyph(uint chr, ScText *hl)
1209
QString glName = QString("Gl%1%2").arg(hl->font().psName().simplified().replace(QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )).arg(chr);
1210
if (glyphNames.contains(glName))
1212
uint gl = hl->font().char2CMap(chr);
1213
FPointArray pts = hl->font().glyphOutline(gl);
1214
QDomElement ob = docu.createElement("path");
1215
ob.setAttribute("d", SetClipPath(&pts, true));
1216
ob.setAttribute("id", glName);
1217
globalDefs.appendChild(ob);
1218
glyphNames.append(glName);
1222
QDomElement SVGExPlug::processArrows(PageItem *Item, QDomElement line, QString trans)
1225
gr = docu.createElement("g");
1226
gr.appendChild(line);
1227
if (Item->startArrowIndex() != 0)
1230
FPointArray arrow = m_Doc->arrowStyles.at(Item->startArrowIndex()-1).points.copy();
1231
if (Item->itemType() == PageItem::Line)
1233
arrowTrans.translate(0, 0);
1234
if (Item->lineWidth() != 0.0)
1235
arrowTrans.scale(Item->lineWidth(), Item->lineWidth());
1236
arrowTrans.scale(-1,1);
1240
FPoint Start = Item->PoLine.point(0);
1241
for (uint xx = 1; xx < Item->PoLine.size(); xx += 2)
1243
FPoint Vector = Item->PoLine.point(xx);
1244
if ((Start.x() != Vector.x()) || (Start.y() != Vector.y()))
1246
double r = atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI);
1247
arrowTrans.translate(Start.x(), Start.y());
1248
arrowTrans.rotate(r);
1249
if (Item->lineWidth() != 0.0)
1250
arrowTrans.scale(Item->lineWidth(), Item->lineWidth());
1255
arrow.map(arrowTrans);
1256
ob = docu.createElement("path");
1257
ob.setAttribute("d", SetClipPath(&arrow, true));
1258
ob.setAttribute("transform", trans);
1259
QString aFill = "fill:"+SetColor(Item->lineColor(), Item->lineShade())+";";
1260
if (Item->lineTransparency() != 0)
1261
aFill += " stroke-opacity:"+FToStr(1.0 - Item->lineTransparency())+";";
1262
ob.setAttribute("style", aFill + " stroke:none;");
1265
if (Item->endArrowIndex() != 0)
1268
FPointArray arrow = m_Doc->arrowStyles.at(Item->endArrowIndex()-1).points.copy();
1269
if (Item->itemType() == PageItem::Line)
1271
arrowTrans.translate(Item->width(), 0);
1272
if (Item->lineWidth() != 0.0)
1273
arrowTrans.scale(Item->lineWidth(), Item->lineWidth());
1277
FPoint End = Item->PoLine.point(Item->PoLine.size()-2);
1278
for (uint xx = Item->PoLine.size()-1; xx > 0; xx -= 2)
1280
FPoint Vector = Item->PoLine.point(xx);
1281
if ((End.x() != Vector.x()) || (End.y() != Vector.y()))
1283
double r = atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI);
1284
arrowTrans.translate(End.x(), End.y());
1285
arrowTrans.rotate(r);
1286
if (Item->lineWidth() != 0.0)
1287
arrowTrans.scale(Item->lineWidth(), Item->lineWidth());
1292
arrow.map(arrowTrans);
1293
ob = docu.createElement("path");
1294
ob.setAttribute("d", SetClipPath(&arrow, true));
1295
ob.setAttribute("transform", trans);
1296
QString aFill = "fill:"+SetColor(Item->lineColor(), Item->lineShade())+";";
1297
if (Item->lineTransparency() != 0)
1298
aFill += " stroke-opacity:"+FToStr(1.0 - Item->lineTransparency())+";";
1299
ob.setAttribute("style", aFill + " stroke:none;");
1305
QString SVGExPlug::getFillStyle(PageItem *Item)
1309
if (Item->asPathText())
1310
return "fill:none;";
1311
if ((Item->fillColor() != CommonStrings::None) || (Item->GrType != 0))
1313
fill = "fill:"+SetColor(Item->fillColor(), Item->fillShade())+";";
1314
if (Item->GrType != 0)
1316
if (Item->GrType == 8)
1318
QStack<PageItem*> groupStack;
1319
QStack<QDomElement> groupStack2;
1320
QString pattID = Item->pattern()+IToStr(PattCount);
1322
ScPattern pa = m_Doc->docPatterns[Item->pattern()];
1323
QDomElement patt = docu.createElement("pattern");
1324
patt.setAttribute("id", pattID);
1325
patt.setAttribute("height", pa.height);
1326
patt.setAttribute("width", pa.width);
1327
patt.setAttribute("patternUnits", "userSpaceOnUse");
1328
double patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation;
1329
Item->patternTransform(patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation);
1331
mpa.translate(patternOffsetX, patternOffsetY);
1332
mpa.rotate(patternRotation);
1333
mpa.scale(pa.scaleX, pa.scaleY);
1334
mpa.scale(patternScaleX / 100.0 , patternScaleY / 100.0);
1335
patt.setAttribute("patternTransform", MatrixToStr(mpa));
1336
for (int em = 0; em < pa.items.count(); ++em)
1338
PageItem* Item = pa.items.at(em);
1339
if (Item->isGroupControl)
1341
groupStack.push(Item->groupsLastItem);
1342
groupStack2.push(patt);
1343
patt = docu.createElement("g");
1344
if (Item->fillTransparency() != 0)
1345
patt.setAttribute("opacity", FToStr(1.0 - Item->fillTransparency()));
1346
QDomElement ob = docu.createElement("clipPath");
1347
ob.setAttribute("id", "Clip"+IToStr(ClipCount));
1348
QDomElement cl = docu.createElement("path");
1349
cl.setAttribute("d", SetClipPath(&Item->PoLine, true));
1350
QString trans = "translate("+FToStr(Item->gXpos)+", "+FToStr(Item->gYpos)+")";
1351
if (Item->rotation() != 0)
1352
trans += " rotate("+FToStr(Item->rotation())+")";
1353
cl.setAttribute("transform", trans);
1355
globalDefs.appendChild(ob);
1356
patt.setAttribute("clip-path", "url(#Clip"+IToStr(ClipCount)+")");
1360
ProcessItemOnPage(Item->gXpos, Item->gYpos, Item, &patt);
1361
if (groupStack.count() != 0)
1363
while (Item == groupStack.top())
1366
groupStack2.top().appendChild(patt);
1367
patt = groupStack2.pop();
1368
if (groupStack.count() == 0)
1373
for (int em = 0; em < pa.items.count(); ++em)
1375
PageItem* embedded = pa.items.at(em);
1376
QString trans = "translate("+FToStr(embedded->gXpos)+", "+FToStr(embedded->gYpos)+")";
1377
if (embedded->rotation() != 0)
1378
trans += " rotate("+FToStr(embedded->rotation())+")";
1379
if (!embedded->isTableItem)
1381
if ((embedded->lineColor() == CommonStrings::None) || (embedded->lineWidth() == 0.0))
1383
if ((embedded->TopLine) || (embedded->RightLine) || (embedded->BottomLine) || (embedded->LeftLine))
1385
QString stroke = getStrokeStyle(embedded);
1386
QDomElement obL = docu.createElement("path");
1387
obL.setAttribute("transform", trans);
1388
obL.setAttribute("style", "fill:none; " + stroke);
1389
QString pathAttr = "";
1390
if (embedded->TopLine)
1391
pathAttr += "M 0 0 L "+FToStr(embedded->width())+" 0";
1392
if (embedded->RightLine)
1393
pathAttr += " M " + FToStr(embedded->width()) + "0 L "+FToStr(embedded->width())+" "+FToStr(embedded->height());
1394
if (embedded->BottomLine)
1395
pathAttr += " M 0 " + FToStr(embedded->height()) + " L "+FToStr(embedded->width())+" "+FToStr(embedded->height());
1396
if (embedded->LeftLine)
1397
pathAttr += " M 0 0 L 0 "+FToStr(embedded->height());
1398
obL.setAttribute("d", pathAttr);
1399
patt.appendChild(obL);
1402
globalDefs.appendChild(patt);
1403
fill = "fill:url(#"+pattID+");";
1407
if ((Item->GrType == 5) || (Item->GrType == 7))
1408
grad = docu.createElement("radialGradient");
1410
grad = docu.createElement("linearGradient");
1411
grad.setAttribute("id", "Grad"+IToStr(GradCount));
1412
grad.setAttribute("gradientUnits", "userSpaceOnUse");
1413
switch (Item->GrType)
1416
grad.setAttribute("x1", "0");
1417
grad.setAttribute("y1", FToStr(Item->height() / 2.0));
1418
grad.setAttribute("x2", FToStr(Item->width()));
1419
grad.setAttribute("y2", FToStr(Item->height() / 2.0));
1422
grad.setAttribute("x1", FToStr(Item->width()/ 2.0));
1423
grad.setAttribute("y1", "0");
1424
grad.setAttribute("x2", FToStr(Item->width()/ 2.0));
1425
grad.setAttribute("y2", FToStr(Item->height()));
1428
grad.setAttribute("x1", "0");
1429
grad.setAttribute("y1", "0");
1430
grad.setAttribute("x2", FToStr(Item->width()));
1431
grad.setAttribute("y2", FToStr(Item->height()));
1434
grad.setAttribute("x1", "0");
1435
grad.setAttribute("y1", FToStr(Item->height()));
1436
grad.setAttribute("x2", FToStr(Item->width()));
1437
grad.setAttribute("y2", "0");
1440
grad.setAttribute("r", FToStr(qMax(Item->width() / 2.0, Item->height() / 2.0)));
1441
grad.setAttribute("cx", FToStr(Item->width() / 2.0));
1442
grad.setAttribute("cy", FToStr(Item->height() / 2.0));
1445
grad.setAttribute("x1", FToStr(Item->GrStartX));
1446
grad.setAttribute("y1", FToStr(Item->GrStartY));
1447
grad.setAttribute("x2", FToStr(Item->GrEndX));
1448
grad.setAttribute("y2", FToStr(Item->GrEndY));
1451
grad.setAttribute("r", FToStr(qMax(Item->width() / 2.0, Item->height() / 2.0)));
1452
grad.setAttribute("cx", FToStr(Item->GrStartX));
1453
grad.setAttribute("cy", FToStr(Item->GrStartY));
1456
QList<VColorStop*> cstops = Item->fill_gradient.colorStops();
1457
for (uint cst = 0; cst < Item->fill_gradient.Stops(); ++cst)
1459
QDomElement itcl = docu.createElement("stop");
1460
itcl.setAttribute("offset", FToStr(cstops.at(cst)->rampPoint*100)+"%");
1461
itcl.setAttribute("stop-opacity", FToStr(cstops.at(cst)->opacity));
1462
itcl.setAttribute("stop-color", SetColor(cstops.at(cst)->name, cstops.at(cst)->shade));
1463
grad.appendChild(itcl);
1465
globalDefs.appendChild(grad);
1466
fill = "fill:url(#Grad"+IToStr(GradCount)+");";
1471
fill += " fill-rule:evenodd;";
1473
fill += " fill-rule:nonzero;";
1474
if (Item->fillTransparency() != 0)
1475
fill += " fill-opacity:"+FToStr(1.0 - Item->fillTransparency())+";";
1478
fill = "fill:none;";
1482
QString SVGExPlug::getStrokeStyle(PageItem *Item)
1484
QString stroke = "";
1485
if (Item->lineColor() != CommonStrings::None)
1487
stroke = "stroke:"+SetColor(Item->lineColor(), Item->lineShade())+";";
1488
if (Item->lineTransparency() != 0)
1489
stroke += " stroke-opacity:"+FToStr(1.0 - Item->lineTransparency())+";";
1490
if (Item->lineWidth() != 0.0)
1491
stroke += " stroke-width:"+FToStr(Item->lineWidth())+";";
1493
stroke += " stroke-width:1px;";
1494
stroke += " stroke-linecap:";
1495
switch (Item->PLineEnd)
1501
stroke += "square;";
1510
stroke += " stroke-linejoin:";
1511
switch (Item->PLineJoin)
1526
stroke += " stroke-dasharray:";
1527
if (Item->DashValues.count() != 0)
1529
QVector<double>::iterator it;
1530
for ( it = Item->DashValues.begin(); it != Item->DashValues.end(); ++it )
1532
stroke += IToStr(static_cast<int>(*it))+" ";
1534
stroke += "; stroke-dashoffset:"+IToStr(static_cast<int>(Item->DashOffset))+";";
1538
if (Item->PLineArt == Qt::SolidLine)
1542
QString Da = getDashString(Item->PLineArt, Item->lineWidth());
1546
stroke += Da.replace(" ", ", ")+";";
1551
stroke = "stroke:none;";
1555
QString SVGExPlug::SetClipPath(FPointArray *ite, bool closed)
1558
FPoint np, np1, np2, np3;
1560
if (ite->size() > 3)
1562
for (uint poi=0; poi<ite->size()-3; poi += 4)
1564
if (ite->point(poi).x() > 900000)
1572
np = ite->point(poi);
1573
tmp += QString("M%1 %2 ").arg(np.x()).arg(np.y());
1576
np = ite->point(poi);
1577
np1 = ite->point(poi+1);
1578
np2 = ite->point(poi+3);
1579
np3 = ite->point(poi+2);
1580
if ((np == np1) && (np2 == np3))
1581
tmp += QString("L%1 %2 ").arg(np3.x()).arg(np3.y());
1583
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());