QDomNode StyleStack::childNode(const QString & name) const
{
    QList<QDomElement>::ConstIterator it = m_stack.end();
    while ( it != m_stack.begin() )
    {
        --it;
        QDomElement properties = searchAttribute( *it, m_nodeNames, name );
        if ( !properties.namedItem( name ).isNull() )
            return properties.namedItem( name );
    }

    return QDomNode();          // a null node
}
QString StyleStack::attribute( const QString& name ) const
{
    // TODO: has to be fixed for complex styles like list-styles
    QList<QDomElement>::ConstIterator it = m_stack.end();
    while ( it != m_stack.begin() )
    {
        --it;
        QDomElement properties = searchAttribute( *it, m_nodeNames, name );
        if ( properties.hasAttribute( name ) )
            return properties.attribute( name );
    }

    return QString::null;
}
bool StyleStack::hasAttribute( const QString& name, const QString& detail ) const
{
    QString fullName( name );
    fullName += '-';
    fullName += detail;
    QList<QDomElement>::ConstIterator it = m_stack.end();
    while ( it != m_stack.begin() )
    {
        --it;
		QDomElement properties = searchAttribute( *it, m_nodeNames, name, fullName );
        if ( properties.hasAttribute( name ) || properties.hasAttribute( fullName ) )
            return true;
    }

    return false;
}
// Font size is a bit special. "115%" applies to "the fontsize of the parent style".
// This can be generalized though (hasAttributeThatCanBePercentOfParent() ? :)
// Although, if we also add support for fo:font-size-rel here then it's not general anymore.
double StyleStack::fontSize() const
{
    QString name = "fo:font-size";
    double percent = 1;
    QList<QDomElement>::ConstIterator it = m_stack.end();
    while ( it != m_stack.begin() )
    {
        --it;
        QDomElement properties = searchAttribute( *it, m_nodeNames, name );
        if ( properties.hasAttribute( name ) ) {
            QString value = properties.attribute( name );
            if ( value.endsWith( "%" ) )
				percent *= ScCLocale::toDoubleC(value) / 100.0;
            else
                return percent * OODPlug::parseUnit( value ); // e.g. 12pt
        }
    }
    return 0;
}
Exemple #5
0
void TextUI::setPrimaryKey()
{
	string entityNodeID;
	vector<int> primaryKeys;

	cout << _presentationModel->displayEntityTable_TextUI() << endl;

	// 輸入Entity
	cout << TEXT_SETPRIMARYKEY_ENTERNODEID;
	entityNodeID = searchEntity(PARAMETER_ENTITY);

	// 顯示該Entity擁有的Attribute Component
	cout << _presentationModel->displayAttributeTable_TextUI(atoi(entityNodeID.c_str())) << endl;
	
	// 輸入primary keys 並檢查正確
	primaryKeys = searchAttribute(entityNodeID);

	cout << _presentationModel->setPrimaryKeys_TextUI(atoi(entityNodeID.c_str()), primaryKeys) << endl;
}