Exemplo n.º 1
0
void HSSFunction::setScope(HSSSimpleSelection::p newScope)
{
    this->scope = newScope;
    std::deque<HSSParserNode::p>::const_iterator it;
    for (it = this->_arguments.begin(); it != this->_arguments.end(); ++it)
    {
        const HSSParserNode::p node = (*it);
        switch (node->getType())
        {
        case HSSParserNodeTypeFunctionCall:
        {
            HSSFunction::p func = qSharedPointerCast<HSSFunction > (node);
            func->setScope(newScope);
            break;
        }

        case HSSParserNodeTypeExpression:
        {
            HSSExpression::p exp = qSharedPointerCast<HSSExpression > (node);
            exp->setScope(newScope);
            break;
        }

        default:
            break;
        }

        switch (node->getStatementType())
        {
        case HSSStatementTypeObjectDefinition:
        {
            HSSObjectDefinition::p objdef = qSharedPointerCast<HSSObjectDefinition > (node);
            objdef->setScope(newScope);
            break;
        }

        default:
            break;
        }
    }
}
Exemplo n.º 2
0
void HSSColorStop::setDColor(HSSParserNode::p value)
{
    bool valid = false;

    switch (value->getType())
    {
    case HSSParserNodeTypeObjectNameConstant:
    {
        this->dColor = value;
        try
        {
            HSSObjectNameConstant::p objname = qSharedPointerCast<HSSObjectNameConstant > (value);
            HSSObjectDefinition::p objdef = this->getController()->objectTreeGet(objname->getValue());
            this->setDColor(objdef);
            valid = true;

        }
        catch (const AXRError &e)
        {
            e.raise();
        }

        break;
    }


    case HSSParserNodeTypeFunctionCall:
    {
        this->dColor = value;
        HSSFunction::p fnct = qSharedPointerCast<HSSFunction > (value)->clone();
        if (fnct && fnct->isA(HSSFunctionTypeRef))
        {
            fnct->setScope(this->scope);
            fnct->setThisObj(this->getThisObj());
            QVariant remoteValue = fnct->evaluate();
            if (remoteValue.canConvert<HSSRgb::p>())
            {
                this->color = remoteValue.value<HSSRgb::p>();
                valid = true;
            }

            fnct->observe(HSSObservablePropertyValue, HSSObservablePropertyColor, this, new HSSValueChangedCallback<HSSColorStop > (this, &HSSColorStop::colorChanged));
        }
        break;
    }

    case HSSParserNodeTypeKeywordConstant:
    {
        HSSKeywordConstant::p theKW = qSharedPointerCast<HSSKeywordConstant>(value);
        AXRString kwValue = theKW->getValue();

        if (kwValue == "black")
        {
            this->color = HSSRgb::blackColor(this->getController());
            valid = true;
        }
        else if (kwValue == "white")
        {
            this->color = HSSRgb::whiteColor(this->getController());
            valid = true;
        }
        else if (kwValue == "transparent")
        {
            //the color will remain empty for transparent
            this->color.clear();
            valid = true;
        }

        break;
    }

    default:
        break;
    }

    switch (value->getStatementType())
    {
    case HSSStatementTypeObjectDefinition:
    {
        this->dColor = value;
        HSSObjectDefinition::p objdef = qSharedPointerCast<HSSObjectDefinition > (value);
        objdef->setScope(this->scope);
        objdef->setThisObj(this->getThisObj());
        objdef->apply();
        HSSObject::p theobj = objdef->getObject();
        if (theobj && theobj->isA(HSSObjectTypeRgb))
        {
            this->color = qSharedPointerCast<HSSRgb > (theobj);
            valid = true;
        }

        break;
    }

    default:
        break;
    }

    if (!valid)
        throw AXRWarning("HSSColorStop", "Invalid value for color of " + this->name);

    this->notifyObservers(HSSObservablePropertyColor, &this->color);
    this->notifyObservers(HSSObservablePropertyValue, NULL);
}