You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
625 lines
20 KiB
625 lines
20 KiB
15 years ago
|
/* This file is part of the KDE project
|
||
|
Copyright (C) 2006 Alfredo Beaumont Sainz <alfredo.beaumont@gmail.com>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
* Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
14 years ago
|
#include <tqpainter.h>
|
||
15 years ago
|
|
||
|
#include "basicelement.h"
|
||
|
#include "tokenstyleelement.h"
|
||
|
|
||
|
KFORMULA_NAMESPACE_BEGIN
|
||
|
|
||
14 years ago
|
TokenStyleElement::TokenStyleElement( BasicElement* parent ) : SequenceElement( parent ),
|
||
15 years ago
|
m_mathSizeType ( NoSize ),
|
||
|
m_charStyle( anyChar ),
|
||
|
m_charFamily( anyFamily ),
|
||
|
m_mathColor( "#000000" ),
|
||
|
m_mathBackground( "#FFFFFF" ),
|
||
|
m_fontSizeType( NoSize ),
|
||
|
m_customMathVariant( false ),
|
||
|
m_customMathColor( false ),
|
||
|
m_customMathBackground( false ),
|
||
|
m_customFontWeight( false ),
|
||
|
m_customFontStyle( false ),
|
||
|
m_customFontFamily( false ),
|
||
|
m_customColor( false )
|
||
|
{
|
||
|
}
|
||
|
|
||
|
void TokenStyleElement::calcSizes( const ContextStyle& context,
|
||
|
ContextStyle::TextStyle tstyle,
|
||
|
ContextStyle::IndexStyle istyle,
|
||
|
StyleAttributes& style )
|
||
|
{
|
||
|
setStyleSize( context, style );
|
||
|
setStyleVariant( style );
|
||
|
setStyleColor( style );
|
||
|
setStyleBackground( style );
|
||
|
inherited::calcSizes( context, tstyle, istyle, style );
|
||
|
resetStyle( style );
|
||
|
}
|
||
|
|
||
14 years ago
|
void TokenStyleElement::draw( TQPainter& painter, const LuPixelRect& r,
|
||
15 years ago
|
const ContextStyle& context,
|
||
|
ContextStyle::TextStyle tstyle,
|
||
|
ContextStyle::IndexStyle istyle,
|
||
|
StyleAttributes& style,
|
||
14 years ago
|
const LuPixelPoint& parentOrigin )
|
||
15 years ago
|
{
|
||
|
setStyleSize( context, style );
|
||
|
setStyleVariant( style );
|
||
|
setStyleColor( style );
|
||
|
setStyleBackground( style );
|
||
14 years ago
|
if ( style.background() != TQt::color0 ) {
|
||
14 years ago
|
painter.fillRect( context.layoutUnitToPixelX( parentOrigin.x() + getX() ),
|
||
|
context.layoutUnitToPixelY( parentOrigin.y() + getY() ),
|
||
|
context.layoutUnitToPixelX( getWidth() ),
|
||
|
context.layoutUnitToPixelY( getHeight() ),
|
||
15 years ago
|
style.background() );
|
||
|
}
|
||
14 years ago
|
inherited::draw( painter, r, context, tstyle, istyle, style, parentOrigin );
|
||
15 years ago
|
resetStyle( style );
|
||
|
}
|
||
|
|
||
14 years ago
|
bool TokenStyleElement::readAttributesFromMathMLDom( const TQDomElement& element )
|
||
15 years ago
|
{
|
||
|
if ( !BasicElement::readAttributesFromMathMLDom( element ) ) {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
// MathML Section 3.2.2
|
||
14 years ago
|
TQString variantStr = element.attribute( "mathvariant" );
|
||
15 years ago
|
if ( !variantStr.isNull() ) {
|
||
|
if ( variantStr == "normal" ) {
|
||
|
setCharStyle( normalChar );
|
||
|
setCharFamily( normalFamily );
|
||
|
}
|
||
|
else if ( variantStr == "bold" ) {
|
||
|
setCharStyle( boldChar );
|
||
|
setCharFamily( normalFamily );
|
||
|
}
|
||
|
else if ( variantStr == "italic" ) {
|
||
|
setCharStyle( italicChar );
|
||
|
setCharFamily( normalFamily );
|
||
|
}
|
||
|
else if ( variantStr == "bold-italic" ) {
|
||
|
setCharStyle( boldItalicChar );
|
||
|
setCharFamily( normalFamily );
|
||
|
}
|
||
|
else if ( variantStr == "double-struck" ) {
|
||
|
setCharStyle( normalChar );
|
||
|
setCharFamily( doubleStruckFamily );
|
||
|
}
|
||
|
else if ( variantStr == "bold-fraktur" ) {
|
||
|
setCharStyle( boldChar );
|
||
|
setCharFamily( frakturFamily );
|
||
|
}
|
||
|
else if ( variantStr == "script" ) {
|
||
|
setCharStyle( normalChar );
|
||
|
setCharFamily( scriptFamily );
|
||
|
}
|
||
|
else if ( variantStr == "bold-script" ) {
|
||
|
setCharStyle( boldChar );
|
||
|
setCharFamily( scriptFamily );
|
||
|
}
|
||
|
else if ( variantStr == "fraktur" ) {
|
||
|
setCharStyle( boldChar );
|
||
|
setCharFamily( frakturFamily );
|
||
|
}
|
||
|
else if ( variantStr == "sans-serif" ) {
|
||
|
setCharStyle( normalChar );
|
||
|
setCharFamily( sansSerifFamily );
|
||
|
}
|
||
|
else if ( variantStr == "bold-sans-serif" ) {
|
||
|
setCharStyle( boldChar );
|
||
|
setCharFamily( sansSerifFamily );
|
||
|
}
|
||
|
else if ( variantStr == "sans-serif-italic" ) {
|
||
|
setCharStyle( italicChar );
|
||
|
setCharFamily( sansSerifFamily );
|
||
|
}
|
||
|
else if ( variantStr == "sans-serif-bold-italic" ) {
|
||
|
setCharStyle( boldItalicChar );
|
||
|
setCharFamily( sansSerifFamily );
|
||
|
}
|
||
|
else if ( variantStr == "monospace" ) {
|
||
|
setCharStyle( normalChar );
|
||
|
setCharFamily( monospaceFamily );
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
TQString sizeStr = element.attribute( "mathsize" );
|
||
15 years ago
|
if ( !sizeStr.isNull() ) {
|
||
|
if ( sizeStr == "small" ) {
|
||
|
setRelativeSize( 0.8 ); // ### Arbitrary size
|
||
|
}
|
||
|
else if ( sizeStr == "normal" ) {
|
||
|
setRelativeSize( 1.0 );
|
||
|
}
|
||
|
else if ( sizeStr == "big" ) {
|
||
|
setRelativeSize( 1.2 ); // ### Arbitrary size
|
||
|
}
|
||
|
else {
|
||
|
double s = getSize( sizeStr, &m_mathSizeType );
|
||
|
switch ( m_mathSizeType ) {
|
||
|
case AbsoluteSize:
|
||
|
setAbsoluteSize( s );
|
||
|
break;
|
||
|
case RelativeSize:
|
||
|
setRelativeSize( s );
|
||
|
break;
|
||
|
case PixelSize:
|
||
|
setPixelSize( s );
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
TQString colorStr = element.attribute( "mathcolor" );
|
||
15 years ago
|
if ( !colorStr.isNull() ) {
|
||
|
if ( colorStr[0] != '#' ) {
|
||
14 years ago
|
setMathColor( TQColor( getHtmlColor( colorStr ) ) );
|
||
15 years ago
|
}
|
||
|
else {
|
||
14 years ago
|
setMathColor( TQColor( colorStr ) );
|
||
15 years ago
|
}
|
||
|
}
|
||
14 years ago
|
TQString backgroundStr = element.attribute( "mathbackground" );
|
||
15 years ago
|
if ( !backgroundStr.isNull() ) {
|
||
|
if ( backgroundStr[0] != '#' ) {
|
||
14 years ago
|
setMathBackground( TQColor( getHtmlColor( backgroundStr ) ) );
|
||
15 years ago
|
}
|
||
|
else {
|
||
14 years ago
|
setMathBackground( TQColor( backgroundStr ) );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
// Deprecated attributes. See Section 3.2.2.1
|
||
|
|
||
|
sizeStr = element.attribute( "fontsize" );
|
||
|
if ( ! sizeStr.isNull() ) {
|
||
|
if ( sizeStr == "small" ) {
|
||
|
setRelativeSize( 0.8, true ); // ### Arbitrary size
|
||
|
}
|
||
|
else if ( sizeStr == "normal" ) {
|
||
|
setRelativeSize( 1.0, true );
|
||
|
}
|
||
|
else if ( sizeStr == "big" ) {
|
||
|
setRelativeSize( 1.2, true ); // ### Arbitrary size
|
||
|
}
|
||
|
else {
|
||
|
double s = getSize( sizeStr, &m_fontSizeType );
|
||
|
switch ( m_fontSizeType ) {
|
||
|
case AbsoluteSize:
|
||
|
setAbsoluteSize( s, true );
|
||
|
break;
|
||
|
case RelativeSize:
|
||
|
setRelativeSize( s, true );
|
||
|
break;
|
||
|
case PixelSize:
|
||
|
setPixelSize( s, true );
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
TQString styleStr = element.attribute( "fontstyle" );
|
||
15 years ago
|
if ( ! styleStr.isNull() ) {
|
||
|
if ( styleStr.lower() == "italic" ) {
|
||
|
setFontStyle( true );
|
||
|
}
|
||
|
else {
|
||
|
setFontStyle( false );
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
TQString weightStr = element.attribute( "fontweight" );
|
||
15 years ago
|
if ( ! weightStr.isNull() ) {
|
||
|
if ( weightStr.lower() == "bold" ) {
|
||
|
setFontWeight( true );
|
||
|
}
|
||
|
else {
|
||
|
setFontWeight( false );
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
TQString familyStr = element.attribute( "fontfamily" );
|
||
15 years ago
|
if ( ! familyStr.isNull() ) {
|
||
|
setFontFamily( familyStr );
|
||
|
}
|
||
|
|
||
|
colorStr = element.attribute( "color" );
|
||
|
if ( ! colorStr.isNull() ) {
|
||
|
if ( colorStr[0] != '#' ) {
|
||
14 years ago
|
setColor( TQColor( getHtmlColor( colorStr ) ) );
|
||
15 years ago
|
}
|
||
|
else {
|
||
14 years ago
|
setColor( TQColor( colorStr ) );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
14 years ago
|
void TokenStyleElement::writeMathMLAttributes( TQDomElement& element ) const
|
||
15 years ago
|
{
|
||
|
// mathvariant attribute
|
||
|
if ( customMathVariant() ) {
|
||
|
if ( charFamily() == normalFamily ) {
|
||
|
if ( charStyle() == normalChar ) {
|
||
|
element.setAttribute( "mathvariant", "normal" );
|
||
|
}
|
||
|
else if ( charStyle() == boldChar ) {
|
||
|
element.setAttribute( "mathvariant", "bold" );
|
||
|
}
|
||
|
else if ( charStyle() == italicChar ) {
|
||
|
element.setAttribute( "mathvariant", "italic" );
|
||
|
}
|
||
|
else if ( charStyle() == boldItalicChar ) {
|
||
|
element.setAttribute( "mathvariant", "bold-italic" );
|
||
|
}
|
||
|
else { // anyChar or unknown, it's always an error
|
||
|
kdWarning( DEBUGID ) << "Mathvariant: unknown style for normal family\n";
|
||
|
}
|
||
|
}
|
||
|
else if ( charFamily() == doubleStruckFamily ) {
|
||
|
if ( charStyle() == normalChar ) {
|
||
|
element.setAttribute( "mathvariant", "double-struck" );
|
||
|
}
|
||
|
else { // Shouldn't happen, it's a bug
|
||
|
kdWarning( DEBUGID ) << "Mathvariant: unknown style for double-struck family\n";
|
||
|
}
|
||
|
}
|
||
|
else if ( charFamily() == frakturFamily ) {
|
||
|
if ( charStyle() == normalChar ) {
|
||
|
element.setAttribute( "mathvariant", "fraktur" );
|
||
|
}
|
||
|
else if ( charStyle() == boldChar ) {
|
||
|
element.setAttribute( "mathvariant", "bold-fraktur" );
|
||
|
}
|
||
|
else {
|
||
|
kdWarning( DEBUGID ) << "Mathvariant: unknown style for fraktur family\n";
|
||
|
}
|
||
|
}
|
||
|
else if ( charFamily() == scriptFamily ) {
|
||
|
if ( charStyle() == normalChar ) {
|
||
|
element.setAttribute( "mathvariant", "script" );
|
||
|
}
|
||
|
else if ( charStyle() == boldChar ) {
|
||
|
element.setAttribute( "mathvariant", "bold-script" );
|
||
|
}
|
||
|
else { // Shouldn't happen, it's a bug
|
||
|
kdWarning( DEBUGID ) << "Mathvariant: unknown style for script family\n";
|
||
|
}
|
||
|
}
|
||
|
else if ( charFamily() == sansSerifFamily ) {
|
||
|
if ( charStyle() == normalChar ) {
|
||
|
element.setAttribute( "mathvariant", "sans-serif" );
|
||
|
}
|
||
|
else if ( charStyle() == boldChar ) {
|
||
|
element.setAttribute( "mathvariant", "bold-sans-serif" );
|
||
|
}
|
||
|
else if ( charStyle() == italicChar ) {
|
||
|
element.setAttribute( "mathvariant", "sans-serif-italic" );
|
||
|
}
|
||
|
else if ( charStyle() == boldItalicChar ) {
|
||
|
element.setAttribute( "mathvariant", "sans-serif-bold-italic" );
|
||
|
}
|
||
|
else {
|
||
|
kdWarning( DEBUGID ) << "Mathvariant: unknown style for sans serif family\n";
|
||
|
}
|
||
|
}
|
||
|
else if ( charFamily() == monospaceFamily ) {
|
||
|
if ( charStyle() == normalChar ) {
|
||
|
element.setAttribute( "mathvariant", "monospace" );
|
||
|
}
|
||
|
else {
|
||
|
kdWarning( DEBUGID ) << "Mathvariant: unknown style for monospace family\n";
|
||
|
}
|
||
|
}
|
||
|
else {
|
||
|
kdWarning( DEBUGID ) << "Mathvariant: unknown family\n";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// mathsize attribute
|
||
|
switch ( m_mathSizeType ) {
|
||
|
case AbsoluteSize:
|
||
13 years ago
|
element.setAttribute( "mathsize", TQString( "%1pt" ).arg( m_mathSize ) );
|
||
15 years ago
|
break;
|
||
|
case RelativeSize:
|
||
13 years ago
|
element.setAttribute( "mathsize", TQString( "%1%" ).arg( m_mathSize * 100.0 ) );
|
||
15 years ago
|
break;
|
||
|
case PixelSize:
|
||
13 years ago
|
element.setAttribute( "mathsize", TQString( "%1px" ).arg( m_mathSize ) );
|
||
15 years ago
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
// mathcolor attribute
|
||
|
if ( customMathColor() ) {
|
||
|
element.setAttribute( "mathcolor", mathColor().name() );
|
||
|
}
|
||
|
|
||
|
// mathbackground attribute
|
||
|
if ( customMathBackground() ) {
|
||
|
element.setAttribute( "mathbackground", mathBackground().name() );
|
||
|
}
|
||
|
|
||
|
// Deprecated MathML 1.01 Attributes
|
||
|
// fontsize attribute
|
||
|
switch ( m_fontSizeType ) {
|
||
|
case AbsoluteSize:
|
||
13 years ago
|
element.setAttribute( "fontsize", TQString( "%1pt" ).arg( m_fontSize ) );
|
||
15 years ago
|
break;
|
||
|
case RelativeSize:
|
||
13 years ago
|
element.setAttribute( "fontsize", TQString( "%1%" ).arg( m_fontSize * 100.0 ) );
|
||
15 years ago
|
break;
|
||
|
case PixelSize:
|
||
13 years ago
|
element.setAttribute( "fontsize", TQString( "%3px" ).arg( m_fontSize ) );
|
||
15 years ago
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
// fontweight attribute
|
||
|
if ( customFontWeight() ) {
|
||
|
element.setAttribute( "fontweight", fontWeight() ? "bold" : "normal" );
|
||
|
}
|
||
|
|
||
|
// fontstyle attribute
|
||
|
if ( customFontStyle() ) {
|
||
|
element.setAttribute( "fontstyle", fontStyle() ? "italic" : "normal" );
|
||
|
}
|
||
|
|
||
|
// fontfamily attribute
|
||
|
if ( customFontFamily() ) {
|
||
|
element.setAttribute( "fontfamily", fontFamily() );
|
||
|
}
|
||
|
|
||
|
// color attribute
|
||
|
if ( customColor() ) {
|
||
|
element.setAttribute( "color", color().name() );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void TokenStyleElement::setAbsoluteSize( double s, bool fontsize )
|
||
|
{
|
||
|
kdDebug( DEBUGID) << "Setting absolute size: " << s << endl;
|
||
|
if ( fontsize ) {
|
||
|
m_fontSizeType = AbsoluteSize;
|
||
|
m_fontSize = s;
|
||
|
}
|
||
|
else {
|
||
|
m_mathSizeType = AbsoluteSize;
|
||
|
m_mathSize = s;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void TokenStyleElement::setRelativeSize( double f, bool fontsize )
|
||
|
{
|
||
|
kdDebug( DEBUGID) << "Setting relative size: " << f << endl;
|
||
|
if ( fontsize ) {
|
||
|
m_fontSizeType = RelativeSize;
|
||
|
m_fontSize = f;
|
||
|
}
|
||
|
else {
|
||
|
m_mathSizeType = RelativeSize;
|
||
|
m_mathSize = f;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void TokenStyleElement::setPixelSize( double px, bool fontsize )
|
||
|
{
|
||
|
kdDebug( DEBUGID) << "Setting pixel size: " << px << endl;
|
||
|
if ( fontsize ) {
|
||
|
m_fontSizeType = PixelSize;
|
||
|
m_fontSize = px;
|
||
|
}
|
||
|
else {
|
||
|
m_mathSizeType = PixelSize;
|
||
|
m_mathSize = px;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void TokenStyleElement::setStyleSize( const ContextStyle& context, StyleAttributes& style )
|
||
|
{
|
||
|
style.setSizeFactor( sizeFactor( context, style.sizeFactor() ) );
|
||
|
}
|
||
|
|
||
|
void TokenStyleElement::setStyleVariant( StyleAttributes& style )
|
||
|
{
|
||
|
if ( customMathVariant() || style.customMathVariant() ) {
|
||
|
style.setCustomMathVariant ( true );
|
||
|
style.setCustomFontWeight( false );
|
||
|
style.setCustomFontStyle( false );
|
||
|
style.setCustomFont( false );
|
||
|
if ( customMathVariant() ) {
|
||
|
style.setCharFamily ( charFamily() );
|
||
|
style.setCharStyle( charStyle() );
|
||
|
}
|
||
|
else {
|
||
|
style.setCharFamily( style.charFamily() );
|
||
|
style.setCharStyle( style.charStyle() );
|
||
|
}
|
||
|
}
|
||
|
else {
|
||
|
style.setCustomMathVariant( false );
|
||
|
if ( customFontFamily() ) {
|
||
|
style.setCustomFont( true );
|
||
14 years ago
|
style.setFont( TQFont(fontFamily()) );
|
||
15 years ago
|
}
|
||
|
|
||
|
bool fontweight = false;
|
||
|
if ( customFontWeight() || style.customFontWeight() ) {
|
||
|
style.setCustomFontWeight( true );
|
||
|
if ( customFontWeight() ) {
|
||
|
fontweight = fontWeight();
|
||
|
}
|
||
|
else {
|
||
|
fontweight = style.fontWeight();
|
||
|
}
|
||
|
style.setFontWeight( fontweight );
|
||
|
}
|
||
|
else {
|
||
|
style.setCustomFontWeight( false );
|
||
|
}
|
||
|
|
||
|
bool fontstyle = false;
|
||
|
if ( style.customFontStyle() ) {
|
||
|
style.setCustomFontStyle( true );
|
||
|
fontstyle = style.fontStyle();
|
||
|
style.setFontStyle( fontstyle );
|
||
|
}
|
||
|
else {
|
||
|
style.setCustomFontStyle( false );
|
||
|
}
|
||
|
if ( customFontStyle() ) {
|
||
|
fontstyle = fontStyle();
|
||
|
}
|
||
|
|
||
|
if ( fontweight && fontstyle ) {
|
||
|
style.setCharStyle( boldItalicChar );
|
||
|
}
|
||
|
else if ( fontweight && ! fontstyle ) {
|
||
|
style.setCharStyle( boldChar );
|
||
|
}
|
||
|
else if ( ! fontweight && fontstyle ) {
|
||
|
style.setCharStyle( italicChar );
|
||
|
}
|
||
|
else {
|
||
|
style.setCharStyle( normalChar );
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void TokenStyleElement::setStyleColor( StyleAttributes& style )
|
||
|
{
|
||
|
if ( customMathColor() ) {
|
||
|
style.setColor( mathColor() );
|
||
|
}
|
||
|
else if ( customColor() ) {
|
||
|
style.setColor( color() );
|
||
|
}
|
||
|
else {
|
||
|
style.setColor( style.color() );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void TokenStyleElement::setStyleBackground( StyleAttributes& style )
|
||
|
{
|
||
|
if ( customMathBackground() ) {
|
||
|
style.setBackground( mathBackground() );
|
||
|
}
|
||
|
else {
|
||
|
style.setBackground( style.background() );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void TokenStyleElement::resetStyle( StyleAttributes& style )
|
||
|
{
|
||
|
style.resetSize();
|
||
|
style.resetCharStyle();
|
||
|
style.resetCharFamily();
|
||
|
style.resetColor();
|
||
|
style.resetBackground();
|
||
|
style.resetFontFamily();
|
||
|
style.resetFontWeight();
|
||
|
style.resetFontStyle();
|
||
|
}
|
||
|
|
||
|
double TokenStyleElement::sizeFactor( const ContextStyle& context, double factor )
|
||
|
{
|
||
14 years ago
|
double basesize = context.layoutUnitPtToPt( context.getBaseSize() );
|
||
15 years ago
|
switch ( m_mathSizeType ) {
|
||
|
case AbsoluteSize:
|
||
|
return m_mathSize / basesize;
|
||
|
case RelativeSize:
|
||
|
return m_mathSize;
|
||
|
case PixelSize:
|
||
|
// 3.2.2 says v-unit instead of h-unit, that's why we use Y and not X
|
||
|
return context.pixelYToPt( m_mathSize ) / basesize;
|
||
|
case NoSize:
|
||
|
switch ( m_fontSizeType ) {
|
||
|
case AbsoluteSize:
|
||
|
return m_fontSize / basesize;
|
||
|
case RelativeSize:
|
||
|
return m_fontSize;
|
||
|
case PixelSize:
|
||
|
return context.pixelYToPt( m_fontSize ) / basesize;
|
||
|
default:
|
||
|
return factor;
|
||
|
}
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
kdWarning( DEBUGID ) << k_funcinfo << " Unknown SizeType\n";
|
||
|
return factor;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Return RGB string from HTML Colors. See HTML Spec, section 6.5
|
||
|
*/
|
||
14 years ago
|
TQString TokenStyleElement::getHtmlColor( const TQString& colorStr ){
|
||
15 years ago
|
|
||
14 years ago
|
TQString colorname = colorStr.lower();
|
||
15 years ago
|
|
||
|
if ( colorname == "black" )
|
||
|
return "#000000";
|
||
|
if ( colorname == "silver" )
|
||
|
return "#C0C0C0";
|
||
|
if ( colorname == "gray" )
|
||
|
return "#808080";
|
||
|
if ( colorname == "white" )
|
||
|
return "#FFFFFF";
|
||
|
if ( colorname == "maroon" )
|
||
|
return "#800000";
|
||
|
if ( colorname == "red" )
|
||
|
return "#FF0000";
|
||
|
if ( colorname == "purple" )
|
||
|
return "#800080";
|
||
|
if ( colorname == "fuchsia" )
|
||
|
return "#FF00FF";
|
||
|
if ( colorname == "green" )
|
||
|
return "#008000";
|
||
|
if ( colorname == "lime" )
|
||
|
return "#00FF00";
|
||
|
if ( colorname == "olive" )
|
||
|
return "#808000";
|
||
|
if ( colorname == "yellow" )
|
||
|
return "#FFFF00";
|
||
|
if ( colorname == "navy" )
|
||
|
return "#000080";
|
||
|
if ( colorname == "blue")
|
||
|
return "#0000FF";
|
||
|
if ( colorname == "teal" )
|
||
|
return "#008080";
|
||
|
if ( colorname == "aqua" )
|
||
|
return "#00FFFF";
|
||
|
kdWarning( DEBUGID ) << "Invalid HTML color: " << colorname << endl;
|
||
|
return "#FFFFFF"; // ### Arbitrary selection of default color
|
||
|
}
|
||
|
|
||
|
|
||
|
KFORMULA_NAMESPACE_END
|