/* QGraphicsTextItem document() to div layer QFileInfo f destination file html
to save external image if exist..
*/
{
///// #define POINT_TO_MM(mm) ((mm)/2.83465058) point px mm ?? ////
#define ALPHAHTML(alpha) ((alpha)/254.99999999)
QString masterpath
= f.
absolutePath()+"/"+FOPIMAGEDIR;
/* Paint QGraphicsTextItem style to html css inline */
.
arg(pos
().
y())+"; left:"+QString("%1px") .
arg(pos
().
x())+"; width:"+QString("%1px") .
arg(wi
)+"; height:"+QString("%1px") .arg(hi)+"; ";
if (AlphaColor < 44) {
styles.
append(QString("background-color:transparent; ") );
} else {
styles.
append(QString("background-color:%1; ").
arg( BGColor.
name() ) );
}
/* AlphaColor = backgroundqcolor.alpha(); */
int alFaCol = qBound(0,AlphaColor,256);
qreal percentos = ALPHAHTML( alFaCol );
if (percentos < 1 && AlphaColor > 44) {
styles.
append(QString("opacity:%1; filter: alpha(opacity=%1); -moz-opacity:%1; ").
arg( Tnetto
) );
}
/* insert border having? */
if (BorderDicks > 0 ) {
styles.
append(QString("border:%2px solid %1; ").
arg(MarginColor.
name()).
arg(BorderDicks
));
}
/* IE !zindex qreal play as int zValue() */
styles.
append(QString("z-index:%1;").
arg(QString("%1").
arg(zValue
()).
replace(".",
"")));
blox.
setAttribute ("id",
QString("layer_%1").
arg(id
));
blox.setAttribute ("style",styles);
doc.appendChild(blox);
int errorLine, errorColumn;
if (!exdoc.setContent(document()->toHtml(),false, &errorStr, &errorLine, &errorColumn)) {
return doc.toString(5);
}
ImageFindertoHtml(e,masterpath); /* rewrite image href to new qfileinfo path image folder and write svg to png */
/* import html to new QDomDocument to reformat later */
child = e.firstChild();
while ( !child.isNull() ) {
if ( child.isElement() ) {
blox.appendChild(doc.importNode(child,true).toElement());
} else if (child.isText()) {
blox.appendChild(doc.createTextNode(child.toText().data()));
}
child = child.nextSibling();
}
return doc.toString(5);
}
/* QGraphicsTextItem document() to div layer QFileInfo f destination file html
to save external image if exist..
*/
QString FloatDiagram::toDivHtml( QFileInfo f )
{
///// #define POINT_TO_MM(mm) ((mm)/2.83465058) point px mm ?? ////
#define ALPHAHTML(alpha) ((alpha)/254.99999999)
QString masterpath = f.absolutePath()+"/"+FOPIMAGEDIR;
/* Paint QGraphicsTextItem style to html css inline */
QString styles = "position:absolute; top:"+QString("%1px")
.arg(pos().y())+"; left:"+QString("%1px")
.arg(pos().x())+"; width:"+QString("%1px")
.arg(wi)+"; height:"+QString("%1px")
.arg(hi)+"; ";
if (AlphaColor < 44) {
styles.append(QString("background-color:transparent; ") );
} else {
styles.append(QString("background-color:%1; ").arg( BGColor.name() ) );
}
/* AlphaColor = backgroundqcolor.alpha(); */
int alFaCol = qBound(0,AlphaColor,256);
qreal percentos = ALPHAHTML( alFaCol );
if (percentos < 1 && AlphaColor > 44) {
QString Tnetto = QString("%1").arg(percentos, 0, 'f', 4);
styles.append(QString("opacity:%1; filter: alpha(opacity=%1); -moz-opacity:%1; ").arg( Tnetto) );
}
/* insert border having? */
if (BorderDicks > 0 ) {
styles.append(QString("border:%2px solid %1; ").arg(MarginColor.name()).arg(BorderDicks));
}
/* IE !zindex qreal play as int zValue() */
styles.append(QString("z-index:%1;").arg(QString("%1").arg(zValue()).replace(".","")));
QDomDocument doc;
QDomElement blox = doc.createElement("div");
blox.setAttribute ("id",QString("layer_%1").arg(id));
blox.setAttribute ("style",styles);
doc.appendChild(blox);
QString errorStr;
int errorLine, errorColumn;
QDomDocument exdoc;
if (!exdoc.setContent(document()->toHtml(),false, &errorStr, &errorLine, &errorColumn)) {
return doc.toString(5);
}
QDomElement root = exdoc.documentElement();
QDomNode child;
QDomElement e = root.firstChildElement("body");
ImageFindertoHtml(e,masterpath); /* rewrite image href to new qfileinfo path image folder and write svg to png */
/* import html to new QDomDocument to reformat later */
child = e.firstChild();
while ( !child.isNull() ) {
if ( child.isElement() ) {
blox.appendChild(doc.importNode(child,true).toElement());
} else if (child.isText()) {
blox.appendChild(doc.createTextNode(child.toText().data()));
}
child = child.nextSibling();
}
return doc.toString(5);
}
To copy to clipboard, switch view to plain text mode
Bookmarks