Пример #1
0
PHISlideAnimation::PHISlideAnimation(PHIBaseItem *item, qreal orgHeight, bool upDir )
    : QPropertyAnimation( item ), _item( item ), _orgHeight( orgHeight ), _upDir( upDir )
{
    setTargetObject( item );
    setPropertyName( "_height" );
    connect( this, &QPropertyAnimation::finished, this, &PHISlideAnimation::slotFinished );
    connect( this, &QPropertyAnimation::stateChanged, this, &PHISlideAnimation::slotStateChanged );
    if ( _upDir ) {
        setStartValue( _orgHeight );
        setEndValue( 0 );
    } else {
        setStartValue( 0 );
        setEndValue( _orgHeight );
    }
}
Пример #2
0
void ViewportView::zoomTo(Node* n)
{
    // Find all ControlInstances that are declared by this node
    QList<ControlInstance*> instances;
    for (auto i : items())
    {
        if (auto c = dynamic_cast<ControlInstance*>(i))
        {
            if (c->getNode() == n)
            {
                instances.push_back(c);
            }
        }
    }

    // Find a weighted sum of central points
    QVector3D pos;
    float area_sum = 0;
    for (auto i : instances)
    {
        const float area = i->boundingRect().width() *
                           i->boundingRect().height();
        pos += i->getControl()->pos() * area;
        area_sum += area;
    }
    pos /= area_sum;

    auto a = new QPropertyAnimation(this, "_center");
    a->setDuration(100);
    a->setStartValue(center);
    a->setEndValue(pos);

    a->start(QPropertyAnimation::DeleteWhenStopped);
}
Пример #3
0
LineAnimation::LineAnimation(QGraphicsLineItem *item, const QLineF &target,
                             QObject *parent)
    : QVariantAnimation(parent), item(item)
{
    setStartValue(item->line());
    setEndValue(target);
}
Пример #4
0
RevealAnimator::RevealAnimator(int centerX, int centerY,
        float startValue, float finalValue)
        : BaseRenderNodeAnimator(finalValue)
        , mCenterX(centerX)
        , mCenterY(centerY) {
    setStartValue(startValue);
}
Пример #5
0
bool CFitItem::elevateChildren()
{
  // The functionality of SavedValue is no handled more transparently
  // through the StartValue. Therefore, in case we encounter an old file
  // we need to copy its value.
  CCopasiParameter *pSavedValue = getParameter("SavedValue");

  if (pSavedValue)
    {
      setStartValue(*pSavedValue->getValue().pDOUBLE);
      removeParameter("SavedValue");
    }

  mpGrpAffectedExperiments =
    elevate<CCopasiParameterGroup, CCopasiParameterGroup>(mpGrpAffectedExperiments);

  if (!mpGrpAffectedExperiments) return false;

  mpGrpAffectedCrossValidations =
    elevate<CCopasiParameterGroup, CCopasiParameterGroup>(mpGrpAffectedCrossValidations);

  if (!mpGrpAffectedCrossValidations) return false;

  return true;
}
Пример #6
0
QScrollbarStyleAnimation::QScrollbarStyleAnimation(Mode mode, QObject *target) : QNumberStyleAnimation(target), _mode(mode), _active(false)
{
    switch (mode) {
    case Activating:
        setDuration(ScrollBarFadeOutDuration);
        setStartValue(0.0);
        setEndValue(1.0);
        break;
    case Deactivating:
        setDuration(ScrollBarFadeOutDelay + ScrollBarFadeOutDuration);
        setDelay(ScrollBarFadeOutDelay);
        setStartValue(1.0);
        setEndValue(0.0);
        break;
    }
}
Пример #7
0
 bool CCScore::init(cocos2d::__String *id, cocos2d::__String *name, cocos2d::__Bool *higherBetter) {
     bool result = CCSoomlaEntity::init(id, name);
     if (result) {
         setStartValue(__Double::create(0));
         setHigherBetter(higherBetter ? higherBetter : __Bool::create(true));
         return true;
     }
     return result;
 }
short ElemDDLSGOptions::importSGO(const ElemDDLSGOptions *sgo)
{
  if (sgo->isStartValueSpecified())
    {
      setStartValueSpec(TRUE);
      setStartValue(sgo->getStartValue());
    }

  if (sgo->isIncrementSpecified())
    {
      setIncrementSpec(TRUE);
      setIncrement(sgo->getIncrement());
    }

  if (sgo->isMinValueSpecified())
    {
      setMinValueSpec(TRUE);
      
      if (sgo->isNoMinValue())
        setNoMinValue(TRUE);
      else
        setMinValue(sgo->getMinValue());
    }

  if (sgo->isMaxValueSpecified())
    {
      setMaxValueSpec(TRUE);

      if (sgo->isNoMaxValue())
        setNoMaxValue(TRUE);
      else
        setMaxValue(sgo->getMaxValue());
    }

  if (sgo->isCacheSpecified())
    {
      setCacheSpec(TRUE);
      setCache(sgo->getCache());
    }

  if (sgo->isCycleSpecified())
    {
      setCycleSpec(TRUE);
      setCycle(sgo->isCycle());
    }

  if (sgo->isResetSpecified())
    {
      setResetSpec();
      setReset(sgo->isReset());
    }

  return 0;
}
Пример #9
0
void MythUIAnimation::CopyFrom(const MythUIAnimation* animation)
{
    m_type = animation->m_type;
    m_value = animation->m_value;
    m_trigger = animation->m_trigger;
    m_looped = animation->m_looped;
    m_reversible = animation->m_reversible;
    m_centre = animation->m_centre;

    setStartValue(animation->startValue());
    setEndValue(animation->endValue());
    setEasingCurve(animation->easingCurve());
    setDuration(animation->duration());
    if (m_looped)
        setLoopCount(-1);
}
Пример #10
0
/*!
    Rotates item with an animation.
*/
void ImageDocumentItem::rotate(Qt::Axis axis, qreal delta)
{
    const auto oldRotation = rotation(axis);
    const auto newRotation = oldRotation + delta;
    const auto animation = new AxisAnimation(this, axis, d->document);
    animation->setStartValue(oldRotation);
    animation->setEndValue(newRotation);
    animation->setDuration(75);
    animation->setEasingCurve(QEasingCurve::Linear);
    if (!d->animationGroup) {
        d->animationGroup = new QSequentialAnimationGroup(d->document);
    }
    d->animationGroup->addAnimation(animation);
    d->animationGroup->start(QAbstractAnimation::DeleteWhenStopped);
    setRotation(axis, newRotation);
}
short ElemDDLSGOptions::importSGA(const SequenceGeneratorAttributes *sga)
{
  initializeDataMembers();

  setFSDataType(sga->getSGFSDataType());
  setStartValue(sga->getSGStartValue());
  setIncrement(sga->getSGIncrement());
  setMinValue(sga->getSGMinValue());
  setMaxValue(sga->getSGMaxValue());

  setCache(sga->getSGCache());
  setCycle(sga->getSGCycleOption());

  setReset(sga->getSGResetOption());

  return 0;
}
Пример #12
0
void Viewport::onJumpTo(Node* n)
{
    auto proxies = getControlProxies(n);
    float area_sum = 0;
    if (!proxies.length())
        return;

    QVector3D pos;
    for (auto p : proxies)
    {
        const float area = p->boundingRect().width() *
                           p->boundingRect().height();
        pos += p->getControl()->pos() * area;
        area_sum += area;
    }
    pos /= area_sum;

    auto a = new QPropertyAnimation(this, "center");
    a->setDuration(100);
    a->setStartValue(center);
    a->setEndValue(pos);

    a->start(QPropertyAnimation::DeleteWhenStopped);
}
// queryType:  0, create sequence.  1, alter sequence.  2, IDENTITY col.
short ElemDDLSGOptions::validate(short queryType)
{
  char queryTypeStr[40];

  if (queryType == 0)
    strcpy(queryTypeStr, "CREATE SEQUENCE");
  else if (queryType == 1)
    strcpy(queryTypeStr, "ALTER SEQUENCE");
  else
    strcpy(queryTypeStr, "IDENTITY column");

  Int64 minValue = 0;
  Int64 startValue = 0;
  Int64 increment = 0;
  Int64 maxValue = LONG_MAX - 1;

  NAString dtStr;
  if (fsDataType_ != COM_UNKNOWN_FSDT)
    {
      switch (fsDataType_)
        {
        case COM_UNSIGNED_BIN16_FSDT:
          maxValue = USHRT_MAX;
          dtStr = COM_SMALLINT_UNSIGNED_SDT_LIT;
          break;
        case COM_UNSIGNED_BIN32_FSDT:
          maxValue = UINT_MAX;
          dtStr = COM_INTEGER_UNSIGNED_SDT_LIT;
          break;
        case COM_SIGNED_BIN64_FSDT:
          maxValue = LONG_MAX - 1;
          dtStr =  COM_LARGEINT_SIGNED_SDT_LIT;
          break;
        default:
          *CmpCommon::diags() << DgSqlCode(-1510);
          return -1;
        }
    }

  if (queryType == 1) // alter
    {
      if ((isMinValueSpecified()|| isStartValueSpecified()))
        {
          *CmpCommon::diags() << DgSqlCode(-1592)
                              << (isMinValueSpecified() ? DgString0("MINVALUE") : DgString0("START WITH"))
                              << DgString1(queryTypeStr);
          
          return -1;
        }
      
      minValue = getMinValue();
      startValue = getStartValue();
      increment = getIncrement();

      if (isMaxValueSpecified() && (NOT isNoMaxValue()))
        {
          if ((fsDataType_ != COM_UNKNOWN_FSDT) &&
              (getMaxValue() > maxValue))
            {
              *CmpCommon::diags() << DgSqlCode(-1576)
                                  << DgString0("MAXVALUE")
                                  << DgString1(dtStr);
              
              return -1;
            }
        }

      maxValue = getMaxValue();
    } // alter
  else
    {
      if (isResetSpecified())
        {
          *CmpCommon::diags() << DgSqlCode(-1592)
                              << DgString0("RESET") 
                              << DgString1(queryTypeStr);
          
          return -1;
        }
 
      minValue = ((isMinValueSpecified() && (NOT isNoMinValue())) ? 
                  getMinValue() : 1LL); 
      startValue = (isStartValueSpecified() ? getStartValue() : minValue);
      increment = (isIncrementSpecified() ? getIncrement() : 1LL);
    } //else

  if (isMaxValueSpecified() && (NOT isNoMaxValue()))
    {
      if ((fsDataType_ != COM_UNKNOWN_FSDT) &&
          (getMaxValue() > maxValue))
        {
          *CmpCommon::diags() << DgSqlCode(-1576)
                              << DgString0("MAXVALUE")
                              << DgString1(dtStr);
          
          return -1;
        }

      maxValue = getMaxValue();
    }

  if (minValue == 0)
    {
      *CmpCommon::diags() << DgSqlCode(-1571)
			  << DgString0("MINVALUE")
			  << DgString1(queryTypeStr);
      
      return -1;
    }

  if (minValue < 0)
    {
      *CmpCommon::diags() << DgSqlCode(-1572)
			  << DgString0("MINVALUE")
			  << DgString1(queryTypeStr);
      
      return -1;
    }

  if (maxValue == 0)
    {
      *CmpCommon::diags() << DgSqlCode(-1571)
			  << DgString0("MAXVALUE")
			  << DgString1(queryTypeStr);
      
      return -1;
    }

  if (maxValue < 0)
    {
      *CmpCommon::diags() << DgSqlCode(-1572)
			  << DgString0("MAXVALUE")
			  << DgString1(queryTypeStr);
      
      return -1;
    }

  if (increment == 0)
    {
      *CmpCommon::diags() << DgSqlCode(-1571)
			  << DgString0("INCREMENT BY")
			  << DgString1(queryTypeStr);
      
      return -1;
    }

  if (increment < 0)
    {
      *CmpCommon::diags() << DgSqlCode(-1572)
			  << DgString0("INCREMENT BY")
			  << DgString1(queryTypeStr);  
      return -1;
    }

  if (startValue < 0)
    {
      *CmpCommon::diags() << DgSqlCode(-1572)
			  << DgString0("START WITH")
			  << DgString1(queryTypeStr);
      
      return -1;
    }

  if (maxValue <= minValue)
    {
      *CmpCommon::diags() << DgSqlCode(-1570)
			  << DgString0(queryTypeStr);      
      return -1;
    }

  if (startValue > maxValue)
    {
      *CmpCommon::diags() << DgSqlCode(-1573)
			  << DgString0(queryTypeStr);      
      return -1;
    }

  if (startValue < minValue)
    {
      *CmpCommon::diags() << DgSqlCode(-1573)
			  << DgString0(queryTypeStr);      
      return -1;
    }

  if (increment > (maxValue - minValue))
    {
      *CmpCommon::diags() << DgSqlCode(-1575)
			  << DgString0(queryTypeStr);      
      return -1;
    }

  Int64 cache = 0;
  Int64 minVal = MAXOF(startValue, minValue);
  Int64 rangeOfVals = (maxValue-minVal)/increment + 1;

  if (isCacheSpecified())
    cache = getCache();
  else
    cache = MINOF(rangeOfVals, 25);

  if (NOT isNoCache())
    {
      if ((cache <= 1) ||
	  (cache > rangeOfVals))
	{
	  *CmpCommon::diags() << DgSqlCode(-1577)
			      << DgString0(queryTypeStr);	  
	  return -1;
	}
    }
  
  cache = MINOF(rangeOfVals, cache);

  setStartValue(startValue);
  setIncrement(increment);
  setMinValue(minValue);
  setMaxValue(maxValue);
  if (NOT isCacheSpecified())
    setCache(cache);

  return 0;
}
Пример #14
0
void ColorPicker::changeColorWheel(ELayoutColorPicker oldLayout, ELayoutColorPicker newLayout, bool skipAnimation) {

    //------------------
    // get resources
    //------------------

    // get paths to resources for two color wheels
    QString oldLayoutResource = getWheelPixmapPath(oldLayout);
    QString newLayoutResource = getWheelPixmapPath(newLayout);

    // get pixmaps for two color wheels
    QPixmap oldPixmap(oldLayoutResource);
    QPixmap newPixmap(newLayoutResource);

    //------------------
    // resize and set pixmaps
    //------------------
    int wheelSize = int(this->size().height() * 0.55f);
    if (wheelSize > this->size().width() * 0.85f) {
        wheelSize = int(this->size().width() * 0.85f);
    }
    mTempWheel->setPixmap(oldPixmap.scaled(wheelSize,
                                           wheelSize,
                                           Qt::KeepAspectRatio,
                                           Qt::SmoothTransformation));
    mColorWheel->setPixmap(newPixmap.scaled(wheelSize,
                                            wheelSize,
                                            Qt::KeepAspectRatio,
                                            Qt::SmoothTransformation));


    const int animationMsec = 250;

    //------------------
    // Animate if needed
    //------------------

    if (!skipAnimation) {
        // check if a new color wheel is being added. if the two resources don't match
        // do a fade in/fade out between the color wheels.
        if (oldLayoutResource.compare(newLayoutResource) != 0) {
            // make temp wheel visible and overlapping the color wheel
            mTempWheel->setVisible(true);
            mTempWheel->setGeometry(mColorWheel->geometry());

            auto fadeOutEffect = new QGraphicsOpacityEffect(mTempWheel);
            mTempWheel->setGraphicsEffect(fadeOutEffect);
            auto fadeOutAnimation = new QPropertyAnimation(fadeOutEffect, "opacity");
            fadeOutAnimation->setDuration(animationMsec);
            fadeOutAnimation->setStartValue(mWheelOpacity);
            fadeOutAnimation->setEndValue(0.0f);
            connect(fadeOutAnimation, SIGNAL(finished()), this, SLOT(hideTempWheel()));

            auto fadeInEffect = new QGraphicsOpacityEffect(mColorWheel);
            mColorWheel->setGraphicsEffect(fadeInEffect);
            auto fadeInAnimation = new QPropertyAnimation(fadeInEffect, "opacity");
            fadeInAnimation->setDuration(animationMsec);
            fadeInAnimation->setStartValue(0.0f);
            mWheelOpacity = 1.0;
            // catch edge case wehre multi color picker is sometimes disabled by default
            if (newLayout == ELayoutColorPicker::multiColorLayout
                    && (mCustomColorPicker->palette()->selectedCount() == 0)) {
                mWheelOpacity = 0.333;
            }
            fadeInAnimation->setEndValue(mWheelOpacity);

            auto group = new QParallelAnimationGroup;
            group->addAnimation(fadeInAnimation);
            group->addAnimation(fadeOutAnimation);
            group->start(QAbstractAnimation::DeleteWhenStopped);
        } else if (mCustomColorPicker->palette()->selectedCount() == 0
                       && (newLayout == ELayoutColorPicker::multiColorLayout
                           || oldLayout == ELayoutColorPicker::multiColorLayout)
                       && (newLayout != oldLayout)) {
            mTempWheel->setVisible(false);

            // If the resources match but its either changing from or changing to a multi layout
            // and no indices are selected so the multi layout should be opaque.
            float startOpacity;
            // don't need two animations, just do one.
            if (newLayout == ELayoutColorPicker::multiColorLayout) {
                startOpacity = 1.0f;
                mWheelOpacity = 0.333;
            } else if (oldLayout == ELayoutColorPicker::multiColorLayout) {
                startOpacity = 0.333f;
                mWheelOpacity = 1.0;
            } else {
                startOpacity = 0.0f;
                mWheelOpacity = 0.0;
                qDebug() << "WARNING: shouldn't get here...";
            }

            if (oldLayout == ELayoutColorPicker::multiColorLayout) {
                // just set opacity here immediately cause of weird bug...
                mWheelOpacity = 1.0;
                // un-fade out the wheel
                auto effect = new QGraphicsOpacityEffect(mColorWheel);
                effect->setOpacity(mWheelOpacity);
                mColorWheel->setGraphicsEffect(effect);
            } else {
                auto fadeEffect = new QGraphicsOpacityEffect(mColorWheel);
                mColorWheel->setGraphicsEffect(fadeEffect);
                auto fadeAnimation = new QPropertyAnimation(fadeEffect, "opacity");
                fadeAnimation->setDuration(animationMsec);
                fadeAnimation->setStartValue(startOpacity);
                fadeAnimation->setEndValue(mWheelOpacity);
                fadeAnimation->start();
            }

        }
    } else {
        mTempWheel->setVisible(false);
    }

}
Пример #15
0
void KoListLevelProperties::loadOdf(KoShapeLoadingContext& scontext, const KoXmlElement& style)
{
    KoOdfLoadingContext &context = scontext.odfLoadingContext();

    // The text:level attribute specifies the level of the number list
    // style. It can be used on all list-level styles.
    const int level = qMax(1, style.attributeNS(KoXmlNS::text, "level", QString()).toInt());
    // The text:display-levels attribute specifies the number of
    // levels whose numbers are displayed at the current level.
    const QString displayLevel = style.attributeNS(KoXmlNS::text,
                                 "display-levels", QString());

    const QString styleName = style.attributeNS(KoXmlNS::text, "style-name", QString());
    KoCharacterStyle *cs = 0;
    if (!styleName.isEmpty()) {
//         kDebug(32500) << "Should use the style =>" << styleName << "<=";

        KoSharedLoadingData *sharedData = scontext.sharedData(KOTEXT_SHARED_LOADING_ID);
        KoTextSharedLoadingData *textSharedData = 0;
        if (sharedData) {
            textSharedData = dynamic_cast<KoTextSharedLoadingData *>(sharedData);
        }
        if (textSharedData) {
            cs = textSharedData->characterStyle(styleName, context.useStylesAutoStyles());
            if (!cs) {
               kWarning(32500) << "Missing KoCharacterStyle!";
            }
            else {
//                kDebug(32500) << "==> cs.name:" << cs->name();
//                kDebug(32500) << "==> cs.styleId:" << cs->styleId();
                setCharacterStyleId(cs->styleId());
            }
        }
    }

    if (style.localName() == "list-level-style-bullet") {   // list with bullets
        // special case bullets:
        //qDebug() << QChar(0x2202) << QChar(0x25CF) << QChar(0xF0B7) << QChar(0xE00C)
        //<< QChar(0xE00A) << QChar(0x27A2)<< QChar(0x2794) << QChar(0x2714) << QChar(0x2d) << QChar(0x2717);

        //1.6: KoParagCounter::loadOasisListStyle
        QString bulletChar = style.attributeNS(KoXmlNS::text, "bullet-char", QString());
//         kDebug(32500) << "style.localName()=" << style.localName() << "level=" << level << "displayLevel=" << displayLevel << "bulletChar=" << bulletChar;
        if (bulletChar.isEmpty()) {  // list without any visible bullets
            setStyle(KoListStyle::CustomCharItem);
            setBulletCharacter(QChar());
        } else { // try to determinate the bullet we should use
            switch (bulletChar[0].unicode()) {
            case 0x2022: // bullet, a small disc -> circle
                setStyle(KoListStyle::Bullet);
                break;
            case 0x25CF: // black circle, large disc -> disc
                setStyle(KoListStyle::BlackCircle);
                break;
            case 0x25CB:           //white circle, no fill
                setStyle(KoListStyle::CircleItem);
                break;
            case 0x25C6: // losange => rhombus
                setStyle(KoListStyle::RhombusItem);
                break;
            case 0x25A0: // square. Not in OASIS (reserved Unicode area!), but used in both OOo and kotext.
                setStyle(KoListStyle::SquareItem);
                break;
            case 0x27A2: // two-colors right-pointing triangle
                setStyle(KoListStyle::RightArrowHeadItem);
                break;
            case 0x2794: // arrow to right
                setStyle(KoListStyle::RightArrowItem);
                break;
            case 0x2714: // checkmark
                setStyle(KoListStyle::HeavyCheckMarkItem);
                break;
            case 0x2d: // minus
                setStyle(KoListStyle::CustomCharItem);
                break;
            case 0x2717: // cross
                setStyle(KoListStyle::BallotXItem);
                break;
            default:
                QChar customBulletChar = bulletChar[0];
                kDebug(32500) << "Unhandled bullet code 0x" << QString::number((uint)customBulletChar.unicode(), 16) << bulletChar;
                kDebug(32500) << "Should use the style =>" << style.attributeNS(KoXmlNS::text, "style-name", QString()) << "<=";
                setStyle(KoListStyle::CustomCharItem);
                /*
                QString customBulletFont;
                // often StarSymbol when it comes from OO; doesn't matter, Qt finds it in another font if needed.
                if ( listStyleProperties.hasAttributeNS( KoXmlNS::style, "font-name" ) )
                {
                    customBulletFont = listStyleProperties.attributeNS( KoXmlNS::style, "font-name", QString() );
                    kDebug(32500) <<"customBulletFont style:font-name =" << listStyleProperties.attributeNS( KoXmlNS::style,"font-name", QString() );
                }
                else if ( listStyleTextProperties.hasAttributeNS( KoXmlNS::fo, "font-family" ) )
                {
                    customBulletFont = listStyleTextProperties.attributeNS( KoXmlNS::fo, "font-family", QString() );
                    kDebug(32500) <<"customBulletFont fo:font-family =" << listStyleTextProperties.attributeNS( KoXmlNS::fo,"font-family", QString() );
                }
                // ## TODO in fact we're supposed to read it from the style pointed to by text:style-name
                */
//                     setStyle(KoListStyle::BoxItem); //fallback
                break;
            } // switch
            setBulletCharacter(bulletChar[0]);
        }
        QString size = style.attributeNS(KoXmlNS::text, "bullet-relative-size", QString());
        if (!size.isEmpty()) {
            setRelativeBulletSize(size.remove('%').toInt());
        }

    } else if (style.localName() == "list-level-style-number" || style.localName() == "outline-level-style") { // it's a numbered list

        if (style.localName() == "outline-level-style") {
            setOutlineList(true);
        }
        setRelativeBulletSize(100); //arbitrary value for numbered list

        KoOdfNumberDefinition numberDefinition;
        numberDefinition.loadOdf(style);

        switch(numberDefinition.formatSpecification()) {
        case KoOdfNumberDefinition::Empty:
            setStyle(KoListStyle::None);
            break;
        case KoOdfNumberDefinition::AlphabeticLowerCase:
            setStyle(KoListStyle::AlphaLowerItem);
            break;
        case KoOdfNumberDefinition::AlphabeticUpperCase:
            setStyle(KoListStyle::UpperAlphaItem);
            break;
        case KoOdfNumberDefinition::RomanLowerCase:
            setStyle(KoListStyle::RomanLowerItem);
            break;
        case KoOdfNumberDefinition::RomanUpperCase:
            setStyle(KoListStyle::UpperRomanItem);
            break;
        case KoOdfNumberDefinition::ArabicAlphabet:
                    setStyle(KoListStyle::ArabicAlphabet);
                    break;
        case KoOdfNumberDefinition::Thai:
            setStyle(KoListStyle::Thai);
            break;
        case KoOdfNumberDefinition::Abjad:
            setStyle(KoListStyle::Abjad);
            break;
        case KoOdfNumberDefinition::AbjadMinor:
            setStyle(KoListStyle::AbjadMinor);
            break;
        case KoOdfNumberDefinition::Tibetan:
            setStyle(KoListStyle::Tibetan);
            break;
        case KoOdfNumberDefinition::Telugu:
            setStyle(KoListStyle::Telugu);
            break;
        case KoOdfNumberDefinition::Tamil:
            setStyle(KoListStyle::Tamil);
            break;
        case KoOdfNumberDefinition::Oriya:
            setStyle(KoListStyle::Oriya);
            break;
        case KoOdfNumberDefinition::Malayalam:
            setStyle(KoListStyle::Malayalam);
            break;
        case KoOdfNumberDefinition::Kannada:
            setStyle(KoListStyle::Kannada);
            break;
        case KoOdfNumberDefinition::Gurumukhi:
            setStyle(KoListStyle::Gurumukhi);
            break;
        case KoOdfNumberDefinition::Gujarati:
            setStyle(KoListStyle::Gujarati);
            break;
        case KoOdfNumberDefinition::Bengali:
            setStyle(KoListStyle::Bengali);
            break;
        case KoOdfNumberDefinition::Numeric:
        default:
            setStyle(KoListStyle::DecimalItem);
        }

        if (!numberDefinition.prefix().isNull()) {
            setListItemPrefix(numberDefinition.prefix());
        }

        if (!numberDefinition.suffix().isNull()) {
            setListItemSuffix(numberDefinition.suffix());
        }
        const QString startValue = style.attributeNS(KoXmlNS::text, "start-value", QString("1"));
        setStartValue(startValue.toInt());
    }
    else if (style.localName() == "list-level-style-image") {   // list with image
        setStyle(KoListStyle::ImageItem);
        KoImageCollection *imageCollection = scontext.imageCollection();
        const QString href = style.attribute("href");
        if(imageCollection) {
            if (!href.isEmpty()) {
                KoStore *store = context.store();
                setBulletImage(imageCollection->createImageData(href, store));
            } else {
                // check if we have an office:binary data element containing the image data
                const KoXmlElement &binaryData(KoXml::namedItemNS(style, KoXmlNS::office, "binary-data"));
                if (!binaryData.isNull()) {
                    QImage image;
                    if (image.loadFromData(QByteArray::fromBase64(binaryData.text().toLatin1()))) {
                        setBulletImage(imageCollection->createImageData(image));
                    }
                }
            }
        }
    }
    else { // if not defined, we have do nothing
//         kDebug(32500) << "stylename else:" << style.localName() << "level=" << level << "displayLevel=" << displayLevel;
        setStyle(KoListStyle::DecimalItem);
        setListItemSuffix(".");
    }

    setLevel(level);
    if (!displayLevel.isEmpty())
        setDisplayLevel(displayLevel.toInt());

    KoXmlElement property;
    forEachElement(property, style) {
        if (property.namespaceURI() != KoXmlNS::style)
            continue;
        const QString localName = property.localName();
        if (localName == "list-level-properties") {
            QString mode(property.attributeNS(KoXmlNS::text, "list-level-position-and-space-mode"));
            if (mode == "label-alignment") {
                QString textAlign(property.attributeNS(KoXmlNS::fo, "text-align"));
                setAlignment(textAlign.isEmpty() ? Qt::AlignLeft : KoText::alignmentFromString(textAlign));

                KoXmlElement p;
                forEachElement(p, property) {
                     if (p.namespaceURI() == KoXmlNS::style && p.localName() == "list-level-label-alignment") {
                        // The <style:list-level-label-alignment> element and the fo:text-align attribute are used to define
                        // the position and spacing of the list label and the list item. The values of the attributes for
                        // text:space-before, text:min-label-width and text:min-label-distance are assumed to be 0.
                        setAlignmentMode(true);

                        QString textindent(p.attributeNS(KoXmlNS::fo, "text-indent"));
                        QString marginleft(p.attributeNS(KoXmlNS::fo, "margin-left"));
                        qreal ti = textindent.isEmpty() ? 0 : KoUnit::parseValue(textindent);
                        qreal ml = marginleft.isEmpty() ? 0 : KoUnit::parseValue(marginleft);
                        setTextIndent(ti);
                        setMargin(ml);

                        QString labelFollowedBy(p.attributeNS(KoXmlNS::text, "label-followed-by","space"));
                        if(labelFollowedBy.compare("listtab",Qt::CaseInsensitive)==0) {

                            setLabelFollowedBy(KoListStyle::ListTab);

                            // list tab position is evaluated only if label is followed by listtab
                            // the it is only evaluated if there is a list-tab-stop-position specified
                            // if not specified use the fo:margin-left:
                            QString tabStop(p.attributeNS(KoXmlNS::text, "list-tab-stop-position"));
                            if (!tabStop.isEmpty()) {
                                qreal tabStopPos = KoUnit::parseValue(tabStop);
                                setTabStopPosition(qMax<qreal>(0.0, tabStopPos));
                            }

                        }else if(labelFollowedBy.compare("nothing",Qt::CaseInsensitive)==0) {

                            setLabelFollowedBy(KoListStyle::Nothing);

                        }else {

                            setLabelFollowedBy(KoListStyle::Space);

                        }

                        setMinimumWidth(0);
                        setMinimumDistance(0);

                        //TODO support ODF 18.829 text:label-followed-by and 18.832 text:list-tab-stop-position
                     }
                }
            }

            if(alignmentMode()!=true ){ // default is mode == "label-width-and-position"
                // The text:space-before, text:min-label-width, text:minimum-label-distance and fo:text-align attributes
                // are used to define the position and spacing of the list label and the list item.

                setAlignmentMode(false);

                QString spaceBefore(property.attributeNS(KoXmlNS::text, "space-before"));
                if (!spaceBefore.isEmpty())
                    setIndent(KoUnit::parseValue(spaceBefore));

                QString minLableWidth(property.attributeNS(KoXmlNS::text, "min-label-width"));
                if (!minLableWidth.isEmpty())
                    setMinimumWidth(KoUnit::parseValue(minLableWidth));

                QString textAlign(property.attributeNS(KoXmlNS::fo, "text-align"));
                if (!textAlign.isEmpty())
                    setAlignment(KoText::alignmentFromString(textAlign));

                QString minLableDistance(property.attributeNS(KoXmlNS::text, "min-label-distance"));
                if (!minLableDistance.isEmpty())
                    setMinimumDistance(KoUnit::parseValue(minLableDistance));               
            }

            QString width(property.attributeNS(KoXmlNS::fo, "width"));
            if (!width.isEmpty())
                setWidth(KoUnit::parseValue(width));

            QString height(property.attributeNS(KoXmlNS::fo, "height"));
            if (!height.isEmpty())
                setHeight(KoUnit::parseValue(height));

        } else if (localName == "text-properties") {
Пример #16
0
void RenderPropertyAnimator::onAttached() {
    if (!mHasStartValue
            && mTarget->isPropertyFieldDirty(mPropertyAccess->dirtyMask)) {
        setStartValue((mTarget->stagingProperties().*mPropertyAccess->getter)());
    }
}
Пример #17
0
void KoListLevelProperties::loadOdf(KoShapeLoadingContext& scontext, const KoXmlElement& style)
{
    KoOdfLoadingContext &context = scontext.odfLoadingContext();

    // The text:level attribute specifies the level of the number list
    // style. It can be used on all list-level styles.
    const int level = qMax(1, style.attributeNS(KoXmlNS::text, "level", QString()).toInt());
    // The text:display-levels attribute specifies the number of
    // levels whose numbers are displayed at the current level.
    const QString displayLevel = style.attributeNS(KoXmlNS::text,
                                 "display-levels", QString());

    if (style.localName() == "list-level-style-bullet") {   // list with bullets

        //1.6: KoParagCounter::loadOasisListStyle
        QString bulletChar = style.isNull() ? QString() : style.attributeNS(KoXmlNS::text, "bullet-char", QString());
        kDebug(32500) << "style.localName()=" << style.localName() << "level=" << level << "displayLevel=" << displayLevel << "bulletChar=" << bulletChar;
        if (bulletChar.isEmpty()) {  // list without any visible bullets
            setStyle(KoListStyle::CustomCharItem);
            setBulletCharacter(QChar());
        } else { // try to determinate the bullet we should use
            switch (bulletChar[0].unicode()) {
            case 0x2022: // bullet, a small disc -> circle
                //TODO use BulletSize to differ between small and large discs
                setStyle(KoListStyle::DiscItem);
                break;
            case 0x25CF: // black circle, large disc -> disc
            case 0xF0B7: // #113361
                setStyle(KoListStyle::DiscItem);
                break;
            case 0xE00C: // losange => rhombus
                setStyle(KoListStyle::RhombusItem);
                break;
            case 0xE00A: // square. Not in OASIS (reserved Unicode area!), but used in both OOo and kotext.
                setStyle(KoListStyle::SquareItem);
                break;
            case 0x27A2: // two-colors right-pointing triangle
                setStyle(KoListStyle::RightArrowHeadItem);
                break;
            case 0x2794: // arrow to right
                setStyle(KoListStyle::RightArrowItem);
                break;
            case 0x2714: // checkmark
                setStyle(KoListStyle::HeavyCheckMarkItem);
                break;
            case 0x2d: // minus
                setStyle(KoListStyle::CustomCharItem);
                break;
            case 0x2717: // cross
                setStyle(KoListStyle::BallotXItem);
                break;
            default:
                QChar customBulletChar = bulletChar[0];
                kDebug(32500) << "Unhandled bullet code 0x" << QString::number((uint)customBulletChar.unicode(), 16);
                kDebug(32500) << "Should use the style =>" << style.attributeNS(KoXmlNS::text, "style-name", QString()) << "<=";
                setStyle(KoListStyle::CustomCharItem);
                /*
                QString customBulletFont;
                // often StarSymbol when it comes from OO; doesn't matter, Qt finds it in another font if needed.
                if ( listStyleProperties.hasAttributeNS( KoXmlNS::style, "font-name" ) )
                {
                    customBulletFont = listStyleProperties.attributeNS( KoXmlNS::style, "font-name", QString::null );
                    kDebug(32500) <<"customBulletFont style:font-name =" << listStyleProperties.attributeNS( KoXmlNS::style,"font-name", QString::null );
                }
                else if ( listStyleTextProperties.hasAttributeNS( KoXmlNS::fo, "font-family" ) )
                {
                    customBulletFont = listStyleTextProperties.attributeNS( KoXmlNS::fo, "font-family", QString::null );
                    kDebug(32500) <<"customBulletFont fo:font-family =" << listStyleTextProperties.attributeNS( KoXmlNS::fo,"font-family", QString::null );
                }
                // ## TODO in fact we're supposed to read it from the style pointed to by text:style-name
                */
//                     setStyle(KoListStyle::BoxItem); //fallback
                break;
            } // switch
            setBulletCharacter(bulletChar[0]);
        }

    } else if (style.localName() == "list-level-style-number" || style.localName() == "outline-level-style") { // it's a numbered list

        KoOdfNumberDefinition numberDefinition;
        numberDefinition.loadOdf(style);

        switch(numberDefinition.formatSpecification()) {
        case KoOdfNumberDefinition::Empty:
            setStyle(KoListStyle::CustomCharItem);
            setBulletCharacter(QChar());
            break;
        case KoOdfNumberDefinition::AlphabeticLowerCase:
            setStyle(KoListStyle::AlphaLowerItem);
            break;
        case KoOdfNumberDefinition::AlphabeticUpperCase:
            setStyle(KoListStyle::UpperAlphaItem);
            break;
        case KoOdfNumberDefinition::RomanLowerCase:
            setStyle(KoListStyle::RomanLowerItem);
            break;
        case KoOdfNumberDefinition::RomanUpperCase:
            setStyle(KoListStyle::UpperRomanItem);
            break;
        case KoOdfNumberDefinition::Numeric:
        default:
            setStyle(KoListStyle::DecimalItem);
        }

        if (!numberDefinition.prefix().isNull()) {
            setListItemPrefix(numberDefinition.prefix());
        }

        if (!numberDefinition.suffix().isNull()) {
            setListItemSuffix(numberDefinition.suffix());
        }
        const QString startValue = style.attributeNS(KoXmlNS::text, "start-value", QString("1"));
        setStartValue(startValue.toInt());
    }
    else if (style.localName() == "list-level-style-image") {   // list with image
        setStyle(KoListStyle::ImageItem);
        KoImageCollection *imageCollection = scontext.imageCollection();
        const QString href = style.attribute("href");
        if(imageCollection) {
            if (!href.isEmpty()) {
                KoStore *store = context.store();
                setBulletImage(imageCollection->createImageData(href, store));
            } else {
                // check if we have an office:binary data element containing the image data
                const KoXmlElement &binaryData(KoXml::namedItemNS(style, KoXmlNS::office, "binary-data"));
                if (!binaryData.isNull()) {
                    QImage image;
                    if (image.loadFromData(QByteArray::fromBase64(binaryData.text().toLatin1()))) {
                        setBulletImage(imageCollection->createImageData(image));
                    }
                }
            }
        }
    }
    else { // if not defined, we have do nothing
        kDebug(32500) << "stylename else:" << style.localName() << "level=" << level << "displayLevel=" << displayLevel;
        setStyle(KoListStyle::DecimalItem);
        setListItemSuffix(".");
    }

    setLevel(level);
    if (!displayLevel.isEmpty())
        setDisplayLevel(displayLevel.toInt());

    KoXmlElement property;
    forEachElement(property, style) {
        if (property.namespaceURI() != KoXmlNS::style)
            continue;
        const QString localName = property.localName();
        if (localName == "list-level-properties") {
            QString mode(property.attributeNS(KoXmlNS::text, "list-level-position-and-space-mode"));
            if (mode == "label-alignment") {
                KoXmlElement p;
                forEachElement(p, property) {
                     if (p.namespaceURI() == KoXmlNS::style && p.localName() == "list-level-label-alignment") {
                        // The <style:list-level-label-alignment> element and the fo:text-align attribute are used to define
                        // the position and spacing of the list label and the list item. The values of the attributes for
                        // text:space-before, text:min-label-width and text:min-label-distance are assumed to be 0.

                        QString textAlign(p.attributeNS(KoXmlNS::fo, "text-align"));
                        setAlignment(textAlign.isEmpty() ? Qt::AlignLeft : KoText::alignmentFromString(textAlign));

                        QString textindent(p.attributeNS(KoXmlNS::fo, "text-indent"));
                        QString marginleft(p.attributeNS(KoXmlNS::fo, "margin-left"));
                        qreal ti = textindent.isEmpty() ? 0 : KoUnit::parseValue(textindent);
                        qreal ml = marginleft.isEmpty() ? 0 : KoUnit::parseValue(marginleft);
                        setIndent(qMax(0.0, ti + ml));
                
                        setMinimumWidth(0);
                        setMinimumDistance(0);
                        
                        //TODO support ODF 18.829 text:label-followed-by and 18.832 text:list-tab-stop-position
                     }   
                }
            } else { // default is mode == "label-width-and-position"