patrik08
13th July 2007, 22:29
I work on XSL-FO (to play exact invoice print) format http://xmlgraphics.apache.org/fop/ to parse all on
QTextDocument && dispay on QTextBrowser or QGraphicsScene .
i found em unit nummer is this same as inch? or how is the faktor to convert on point?
<fo:block>
<fo:block font-size="16pt" font-weight="bold" space-before.minimum="1em" space-before.optimum="1.5em" space-before.maximum="2em">Sized</fo:block>
<fo:block>
The image
(<fo:external-graphic width="150pt" height="50pt" src="images/fop.jpg"/>)
has the width and height set.
</fo:block>
</fo:block>
is the faktor here correct or mistake?
double FopFormat::ConvertUnit( const QString &data )
{
#define MM_TO_POINT(mm) ((mm)*2.83465058)
#define CM_TO_POINT(cm) ((cm)*28.3465058)
#define DM_TO_POINT(dm) ((dm)*283.465058)
#define INCH_TO_POINT(inch) ((inch)*72.0)
#define PI_TO_POINT(pi) ((pi)*12)
#define DD_TO_POINT(dd) ((dd)*154.08124)
#define CC_TO_POINT(cc) ((cc)*12.840103)
#define EM_TO_POINT(em) ((em)*25.02)
double points = 0;
if ( data.endsWith( "pt" ) ) {
points = data.left( data.length() - 2 ).toDouble();
} else if ( data.endsWith( "cm" ) ) {
double value = data.left( data.length() - 2 ).toDouble();
points = CM_TO_POINT( value );
} else if ( data.endsWith( "em" ) ) {
double value = data.left( data.length() - 2 ).toDouble();
points = EM_TO_POINT( value );
} else if ( data.endsWith( "mm" ) ) {
double value = data.left( data.length() - 2 ).toDouble();
points = MM_TO_POINT( value );
} else if ( data.endsWith( "dm" ) ) {
double value = data.left( data.length() - 2 ).toDouble();
points = DM_TO_POINT( value );
} else if ( data.endsWith( "in" ) ) {
double value = data.left( data.length() - 2 ).toDouble();
points = INCH_TO_POINT( value );
} else if ( data.endsWith( "inch" ) ) {
double value = data.left( data.length() - 4 ).toDouble();
points = INCH_TO_POINT( value );
} else if ( data.endsWith( "pi" ) ) {
double value = data.left( data.length() - 4 ).toDouble();
points = PI_TO_POINT( value );
} else if ( data.endsWith( "dd" ) ) {
double value = data.left( data.length() - 4 ).toDouble();
points = DD_TO_POINT( value );
} else if ( data.endsWith( "cc" ) ) {
double value = data.left( data.length() - 4 ).toDouble();
points = CC_TO_POINT( value );
} else {
points = 12;
qDebug( "unknown unit %s", qPrintable( data ) );
}
return points;
}
QTextDocument && dispay on QTextBrowser or QGraphicsScene .
i found em unit nummer is this same as inch? or how is the faktor to convert on point?
<fo:block>
<fo:block font-size="16pt" font-weight="bold" space-before.minimum="1em" space-before.optimum="1.5em" space-before.maximum="2em">Sized</fo:block>
<fo:block>
The image
(<fo:external-graphic width="150pt" height="50pt" src="images/fop.jpg"/>)
has the width and height set.
</fo:block>
</fo:block>
is the faktor here correct or mistake?
double FopFormat::ConvertUnit( const QString &data )
{
#define MM_TO_POINT(mm) ((mm)*2.83465058)
#define CM_TO_POINT(cm) ((cm)*28.3465058)
#define DM_TO_POINT(dm) ((dm)*283.465058)
#define INCH_TO_POINT(inch) ((inch)*72.0)
#define PI_TO_POINT(pi) ((pi)*12)
#define DD_TO_POINT(dd) ((dd)*154.08124)
#define CC_TO_POINT(cc) ((cc)*12.840103)
#define EM_TO_POINT(em) ((em)*25.02)
double points = 0;
if ( data.endsWith( "pt" ) ) {
points = data.left( data.length() - 2 ).toDouble();
} else if ( data.endsWith( "cm" ) ) {
double value = data.left( data.length() - 2 ).toDouble();
points = CM_TO_POINT( value );
} else if ( data.endsWith( "em" ) ) {
double value = data.left( data.length() - 2 ).toDouble();
points = EM_TO_POINT( value );
} else if ( data.endsWith( "mm" ) ) {
double value = data.left( data.length() - 2 ).toDouble();
points = MM_TO_POINT( value );
} else if ( data.endsWith( "dm" ) ) {
double value = data.left( data.length() - 2 ).toDouble();
points = DM_TO_POINT( value );
} else if ( data.endsWith( "in" ) ) {
double value = data.left( data.length() - 2 ).toDouble();
points = INCH_TO_POINT( value );
} else if ( data.endsWith( "inch" ) ) {
double value = data.left( data.length() - 4 ).toDouble();
points = INCH_TO_POINT( value );
} else if ( data.endsWith( "pi" ) ) {
double value = data.left( data.length() - 4 ).toDouble();
points = PI_TO_POINT( value );
} else if ( data.endsWith( "dd" ) ) {
double value = data.left( data.length() - 4 ).toDouble();
points = DD_TO_POINT( value );
} else if ( data.endsWith( "cc" ) ) {
double value = data.left( data.length() - 4 ).toDouble();
points = CC_TO_POINT( value );
} else {
points = 12;
qDebug( "unknown unit %s", qPrintable( data ) );
}
return points;
}