コード例 #1
0
ファイル: KoTosContainer.cpp プロジェクト: AninaRJ/krita
QString KoTosContainer::saveStyle(KoGenStyle &style, KoShapeSavingContext &context) const
{
    Qt::Alignment alignment = textAlignment();
    QString verticalAlignment = "top";
    Qt::Alignment vAlignment(alignment & Qt::AlignVertical_Mask);
    if (vAlignment == Qt::AlignBottom) {
        verticalAlignment = "bottom";
    } else if (vAlignment == Qt::AlignVCenter || vAlignment == Qt::AlignCenter) {
        verticalAlignment = "middle";
    }

    style.addProperty("draw:textarea-vertical-align", verticalAlignment);

    QString horizontalAlignment = "left";
    Qt::Alignment hAlignment(alignment & Qt::AlignHorizontal_Mask);
    if (hAlignment == Qt::AlignCenter || hAlignment == Qt::AlignHCenter) {
        horizontalAlignment = "center";
    } else if (hAlignment == Qt::AlignJustify) {
        horizontalAlignment = "justify";
    } else if (hAlignment == Qt::AlignRight) {
        horizontalAlignment = "right";
    }

    style.addProperty("draw:textarea-horizontal-align", horizontalAlignment);

    return KoShapeContainer::saveStyle(style, context);
}
コード例 #2
0
ファイル: Objects.cpp プロジェクト: TheTypoMaster/calligra
QString Extrude::saveStyle(KoGenStyle& style, KoShapeSavingContext& context) const
{
    style.addProperty("dr3d:depth", QString("%1").arg(m_depth));

    style.addProperty("dr3d:close-front", m_closeFront);
    style.addProperty("dr3d:close-back",  m_closeBack);

    if (m_backScale != 1.0) {
        style.addProperty("dr3d:back-scale", QString("%1").arg(m_backScale));
    }

    return KoShape::saveStyle(style, context);
}
コード例 #3
0
void KoShapeShadow::fillStyle(KoGenStyle &style, KoShapeSavingContext &context)
{
    Q_UNUSED(context);

    style.addProperty("draw:shadow", d->visible ? "visible" : "hidden", KoGenStyle::GraphicType);
    style.addProperty("draw:shadow-color", d->color.name(), KoGenStyle::GraphicType);
    if (d->color.alphaF() != 1.0)
        style.addProperty("draw:shadow-opacity", QString("%1%").arg(d->color.alphaF() * 100.0), KoGenStyle::GraphicType);
    style.addProperty("draw:shadow-offset-x", QString("%1pt").arg(d->offset.x()), KoGenStyle::GraphicType);
    style.addProperty("draw:shadow-offset-y", QString("%1pt").arg(d->offset.y()), KoGenStyle::GraphicType);
    if (d->blur != 0)
        style.addProperty("calligra:shadow-blur-radius", QString("%1pt").arg(d->blur), KoGenStyle::GraphicType);
}
コード例 #4
0
void KoPatternBackground::fillStyle(KoGenStyle &style, KoShapeSavingContext &context)
{
    Q_D(KoPatternBackground);
    if (! d->imageData)
        return;

    switch (d->repeat) {
    case Original:
        style.addProperty("style:repeat", "no-repeat");
        break;
    case Tiled:
        style.addProperty("style:repeat", "repeat");
        break;
    case Stretched:
        style.addProperty("style:repeat", "stretch");
        break;
    }

    if (d->repeat == Tiled) {
        QString refPointId = "top-left";
        switch (d->refPoint) {
        case TopLeft: refPointId = "top-left"; break;
        case Top: refPointId = "top"; break;
        case TopRight: refPointId = "top-right"; break;
        case Left: refPointId = "left"; break;
        case Center: refPointId = "center"; break;
        case Right: refPointId = "right"; break;
        case BottomLeft: refPointId = "bottom-left"; break;
        case Bottom: refPointId = "bottom"; break;
        case BottomRight: refPointId = "bottom-right"; break;
        }
        style.addProperty("draw:fill-image-ref-point", refPointId);
        if (d->refPointOffsetPercent.x() > 0.0)
            style.addProperty("draw:fill-image-ref-point-x", QString("%1%").arg(d->refPointOffsetPercent.x()));
        if (d->refPointOffsetPercent.y() > 0.0)
            style.addProperty("draw:fill-image-ref-point-y", QString("%1%").arg(d->refPointOffsetPercent.y()));
    }

    if (d->repeat != Stretched) {
        QSizeF targetSize = d->targetSize();
        QSizeF imageSize = d->imageData->imageSize();
        if (targetSize.height() != imageSize.height())
            style.addPropertyPt("draw:fill-image-height", targetSize.height());
        if (targetSize.width() != imageSize.width())
            style.addPropertyPt("draw:fill-image-width", targetSize.width());
    }

    KoGenStyle patternStyle(KoGenStyle::FillImageStyle /*no family name*/);
    patternStyle.addAttribute("xlink:show", "embed");
    patternStyle.addAttribute("xlink:actuate", "onLoad");
    patternStyle.addAttribute("xlink:type", "simple");
    patternStyle.addAttribute("xlink:href", context.imageHref(d->imageData));

    QString patternStyleName = context.mainStyles().insert(patternStyle, "picture");
    style.addProperty("draw:fill", "bitmap");
    style.addProperty("draw:fill-image-name", patternStyleName);

    context.addDataCenter(d->imageCollection);
}
コード例 #5
0
void KoTableRowStyle::saveOdf(KoGenStyle &style) const
{
    QList<int> keys = d->stylesPrivate.keys();
    foreach(int key, keys) {
        if (key == QTextFormat::BackgroundBrush) {
            QBrush backBrush = background();
            if (backBrush.style() != Qt::NoBrush)
                style.addProperty("fo:background-color", backBrush.color().name(), KoGenStyle::TableRowType);
            else
                style.addProperty("fo:background-color", "transparent", KoGenStyle::TableRowType);
        } else if (key == MinimumRowHeight) {
            style.addPropertyPt("style:min-row-height", minimumRowHeight(), KoGenStyle::TableRowType);
        } else if (key == RowHeight) {
            style.addPropertyPt("style:row-height", rowHeight(), KoGenStyle::TableRowType);
        } else if (key == UseOptimalHeight) {
            style.addProperty("style:use-optimal-row-height", useOptimalHeight(), KoGenStyle::TableRowType);
        } else if (key == BreakBefore) {
            style.addProperty("fo:break-before", KoText::textBreakToString(breakBefore()), KoGenStyle::TableRowType);
        } else if (key == BreakAfter) {
            style.addProperty("fo:break-after", KoText::textBreakToString(breakAfter()), KoGenStyle::TableRowType);
        } else if (key == KeepTogether) {
            if (keepTogether())
                style.addProperty("fo:keep-together", "always", KoGenStyle::TableRowType);
            else
                style.addProperty("fo:keep-together", "auto", KoGenStyle::TableRowType);
        }
    }
}
コード例 #6
0
void WordsTableHandler::tableCellEnd()
{
    kDebug(30513);

    if (!m_cellOpen) {
        kDebug(30513) << "BUG: !m_cellOpen";
        return;
    }

    // Text lists aren't closed explicitly so we have to close them
    // when something happens like a new paragraph or, in this case,
    // the table cell ends.
    if (document()->textHandler()->listIsOpen()) {
        document()->textHandler()->closeList();
    }
    KoXmlWriter*  writer = currentWriter();


    QList<const char*> openTags = writer->tagHierarchy();
    for (int i = 0; i < openTags.size(); ++i) {
        kDebug(30513) << openTags[i];
    }
    writer->endElement();//table:table-cell
    m_cellOpen = false;

    // If this cell covers other cells (i.e. is merged), then create as many
    // table:covered-table-cell tags as there are covered columns.
    for (int i = 1; i < m_colSpan; i++) {
        writer->startElement("table:covered-table-cell");
        writer->endElement();
    }
    m_colSpan = 1;

    //Leaving out the table:style-name attribute and creation of the
    //corresponding style for covered table cells in the tableCellStart f.
    if (!m_tap || m_cellStyleName.isEmpty()) {
        return;
    }

    //process shading information
    const wvWare::Word97::SHD& shd = m_tap->rgshd[ m_column ];
    QString color = Conversion::shdToColorStr(shd,
                                              document()->textHandler()->paragraphBgColor(),
                                              document()->textHandler()->paragraphBaseFontColorBkp());

    if (!color.isNull()) {
        KoGenStyle* cellStyle = m_mainStyles->styleForModification(m_cellStyleName, "table-cell");
        Q_ASSERT(cellStyle);
        if (cellStyle) {
            cellStyle->addProperty("fo:background-color", color, KoGenStyle::TableCellType);
        }
        m_cellStyleName.clear();

        //add the current background-color to stack
//         document()->pushBgColor(color);
    }
}
コード例 #7
0
void KPrPageEffect::saveOdfSmilAttributes( KoGenStyle & style ) const
{
    QString speed("slow");
    if (m_duration < 2500) {
        speed = "fast";
    }
    else if (m_duration < 7500) {
        speed = "medium";
    }
    style.addProperty("presentation:transition-speed", speed);
    return m_strategy->saveOdfSmilAttributes(style);
}
コード例 #8
0
void KoColumnStyle::prepareStyle(KoGenStyle& style) const
{
    if(m_breakAfter != NoBreak) {
        style.addProperty("fo:break-after", breakStyleMap.value(m_breakAfter));
    }
    if(m_breakBefore != NoBreak) {
        style.addProperty("fo:break-before", breakStyleMap.value(m_breakBefore));
    }

    switch(m_widthType) {
        case MinimumWidth:
            style.addPropertyPt("style:min-column-width", m_width);
            break;
        case ExactWidth:
            style.addPropertyPt("style:column-width", m_width);
            break;
        case OptimalWidth:
            style.addProperty("style:use-optimal-column-width", "true");
            break;
    }
}
コード例 #9
0
void KoSectionStyle::saveOdf(KoGenStyle &style)
{
    // only custom style have a displayname. automatic styles don't have a name set.
    if (!d->name.isEmpty() && !style.isDefaultStyle()) {
        style.addAttribute("style:display-name", d->name);
    }

    QList<int> keys = d->stylesPrivate.keys();
    foreach(int key, keys) {
        if (key == KoSectionStyle::TextProgressionDirection) {
            int directionValue = 0;
            bool ok = false;
            directionValue = d->stylesPrivate.value(key).toInt(&ok);
            if (ok) {
                QString direction;
                if (directionValue == KoText::LeftRightTopBottom)
                    direction = "lr-tb";
                else if (directionValue == KoText::RightLeftTopBottom)
                    direction = "rl-tb";
                else if (directionValue == KoText::TopBottomRightLeft)
                    direction = "tb-lr";
                else if (directionValue == KoText::InheritDirection)
                    direction = "page";
                if (!direction.isEmpty())
                    style.addProperty("style:writing-mode", direction, KoGenStyle::DefaultType);
            }
        } else if (key == QTextFormat::BackgroundBrush) {
            QBrush backBrush = background();
            if (backBrush.style() != Qt::NoBrush)
                style.addProperty("fo:background-color", backBrush.color().name(), KoGenStyle::ParagraphType);
            else
                style.addProperty("fo:background-color", "transparent", KoGenStyle::DefaultType);
        } else if (key == QTextFormat::BlockLeftMargin) {
            style.addPropertyPt("fo:margin-left", leftMargin(), KoGenStyle::DefaultType);
        } else if (key == QTextFormat::BlockRightMargin) {
            style.addPropertyPt("fo:margin-right", rightMargin(), KoGenStyle::DefaultType);
      }
    }
}
コード例 #10
0
ファイル: KoTblStyle.cpp プロジェクト: KDE/calligra
void KoTblStyle::prepareStyle(KoGenStyle& style) const
{
    if(m_backgroundColor.isValid()) {
        style.addProperty("fo:background-color", m_backgroundColor.name());
    }
    if (m_breakAfter != KoTblStyle::NoBreak) {
        style.addProperty("fo:break-after", breakStyleMap.value(m_breakAfter));
    }
    if (m_breakBefore != KoTblStyle::NoBreak) {
        style.addProperty("fo:break-before", breakStyleMap.value(m_breakBefore));
    }
    style.addProperty("fo:keep-with-next", keepWithNextMap.value(m_keepWithNext));

    style.addPropertyPt("fo:margin-top", m_topMargin);
    style.addPropertyPt("fo:margin-right", m_rightMargin);
    style.addPropertyPt("fo:margin-bottom", m_bottomMargin);
    style.addPropertyPt("fo:margin-left", m_leftMargin);

    // style:width may not be 0, use style:rel-width if width is 0
    if (m_widthUnit == PercentageUnit || m_width <= 0) {
        style.addProperty("style:rel-width", QString::number(m_width) + QLatin1Char('%'));
    } else {
        style.addPropertyPt("style:width", m_width);
    }

    style.addProperty("style:may-break-between-rows", m_allowBreakBetweenRows ? "true" : "false");
    style.addProperty("style:writing-mode", writingModeMap.value(m_writingMode));
    style.addProperty("table:align", horizontalAlignMap.value(m_horizontalAlign));
    style.addProperty("table:border-model", borderModelMap.value(m_borderModel));

    if(!m_display) {
        style.addProperty("table:display", "false");
    }

    if(!m_masterPageName.isEmpty()) {
        style.addAttribute("style:master-page-name", m_masterPageName);
    }
}
コード例 #11
0
ファイル: KoGenStyle.cpp プロジェクト: ChrisJong/krita
void KoGenStyle::copyPropertiesFromStyle(const KoGenStyle &sourceStyle, KoGenStyle &targetStyle, PropertyType type)
{
    if (type == DefaultType) {
        type = sourceStyle.m_propertyType;
    }

    const StyleMap& map = sourceStyle.m_properties[type];
    if (!map.isEmpty()) {
        QMap<QString, QString>::const_iterator it = map.constBegin();
        const QMap<QString, QString>::const_iterator end = map.constEnd();
        for (; it != end; ++it) {
            targetStyle.addProperty(it.key(), it.value(), type);
        }
    }
}
コード例 #12
0
ファイル: graphicshandler.cpp プロジェクト: KDE/calligra
void WordsGraphicsHandler::definePositionAttributes(KoGenStyle& style, const DrawStyle& ds)
{
    if (m_processingGroup) return;

    const KoGenStyle::PropertyType gt = KoGenStyle::GraphicType;
    if (m_objectType == Inline) {
        style.addProperty("style:vertical-rel", "baseline", gt);
        style.addProperty("style:vertical-pos", "top", gt);
    } else {
        style.addProperty("style:horizontal-pos", getHorizontalPos(ds.posH()), gt);
        style.addProperty("style:horizontal-rel", getHorizontalRel(ds.posRelH()), gt);
        style.addProperty("style:vertical-pos", getVerticalPos(ds.posV()), gt);
        style.addProperty("style:vertical-rel", getVerticalRel(ds.posRelV()), gt);
    }
}
コード例 #13
0
ファイル: Objects.cpp プロジェクト: TheTypoMaster/calligra
QString Rotate::saveStyle(KoGenStyle& style, KoShapeSavingContext& context) const
{
    if (m_horizontalSegments != -1) {
        style.addProperty("dr3d:horizontal-segments", QString("%1").arg(m_horizontalSegments));
    }
    if (m_verticalSegments != -1) {
        style.addProperty("dr3d:vertical-segments", QString("%1").arg(m_verticalSegments));
    }

    if (m_endAngle != 360.0) {
        style.addProperty("dr3d:end-angle", QString("%1").arg(m_endAngle));
    }

    style.addProperty("dr3d:close-front", m_closeFront);
    style.addProperty("dr3d:close-back",  m_closeBack);

    if (m_backScale != 1.0) {
        style.addProperty("dr3d:back-scale", QString("%1").arg(m_backScale));
    }

    return KoShape::saveStyle(style, context);
}
コード例 #14
0
void KoOdfGraphicStyles::saveOdfStrokeStyle(KoGenStyle &styleStroke, KoGenStyles &mainStyles, const QPen &pen)
{
    // TODO implement all possibilities
    switch (pen.style()) {
    case Qt::NoPen:
        styleStroke.addProperty("draw:stroke", "none", KoGenStyle::GraphicType);
        return;
    case Qt::SolidLine:
        styleStroke.addProperty("draw:stroke", "solid", KoGenStyle::GraphicType);
        break;
    default: { // must be a dashed line
        styleStroke.addProperty("draw:stroke", "dash", KoGenStyle::GraphicType);
        // save stroke dash (14.14.7) which is severly limited, but still
        KoGenStyle dashStyle(KoGenStyle::StrokeDashStyle);
        dashStyle.addAttribute("draw:style", "rect");
        QVector<qreal> dashes = pen.dashPattern();
        dashStyle.addAttribute("draw:dots1", static_cast<int>(1));
        dashStyle.addAttributePt("draw:dots1-length", dashes[0]*pen.widthF());
        dashStyle.addAttributePt("draw:distance", dashes[1]*pen.widthF());
        if (dashes.size() > 2) {
            dashStyle.addAttribute("draw:dots2", static_cast<int>(1));
            dashStyle.addAttributePt("draw:dots2-length", dashes[2]*pen.widthF());
        }
        QString dashStyleName = mainStyles.insert(dashStyle, "dash");
        styleStroke.addProperty("draw:stroke-dash", dashStyleName, KoGenStyle::GraphicType);
        break;
    }
    }

    if (pen.brush().gradient()) {
        styleStroke.addProperty("calligra:stroke-gradient", saveOdfGradientStyle(mainStyles, pen.brush()), KoGenStyle::GraphicType);
    }
    else {
        styleStroke.addProperty("svg:stroke-color", pen.color().name(), KoGenStyle::GraphicType);
        styleStroke.addProperty("svg:stroke-opacity", QString("%1").arg(pen.color().alphaF()), KoGenStyle::GraphicType);
    }
    styleStroke.addPropertyPt("svg:stroke-width", pen.widthF(), KoGenStyle::GraphicType);

    switch (pen.joinStyle()) {
    case Qt::MiterJoin:
        styleStroke.addProperty("draw:stroke-linejoin", "miter", KoGenStyle::GraphicType);
        break;
    case Qt::BevelJoin:
        styleStroke.addProperty("draw:stroke-linejoin", "bevel", KoGenStyle::GraphicType);
        break;
    case Qt::RoundJoin:
        styleStroke.addProperty("draw:stroke-linejoin", "round", KoGenStyle::GraphicType);
        break;
    default:
        styleStroke.addProperty("draw:stroke-linejoin", "miter", KoGenStyle::GraphicType);
        styleStroke.addProperty("calligra:stroke-miterlimit", QString("%1").arg(pen.miterLimit()), KoGenStyle::GraphicType);
        break;
    }
    switch (pen.capStyle()) {
    case Qt::RoundCap:
        styleStroke.addProperty("svg:stroke-linecap", "round", KoGenStyle::GraphicType);
        break;
    case Qt::SquareCap:
        styleStroke.addProperty("svg:stroke-linecap", "square", KoGenStyle::GraphicType);
        break;
    default:
        styleStroke.addProperty("svg:stroke-linecap", "butt", KoGenStyle::GraphicType);
        break;
    }
}
コード例 #15
0
void KoOdfGraphicStyles::saveOdfFillStyle(KoGenStyle &styleFill, KoGenStyles& mainStyles, const QBrush & brush)
{
    switch (brush.style()) {
    case Qt::Dense1Pattern:
        styleFill.addProperty("draw:transparency", "94%");
        styleFill.addProperty("draw:fill", "solid");
        styleFill.addProperty("draw:fill-color", brush.color().name());
        break;
    case Qt::Dense2Pattern:
        styleFill.addProperty("draw:transparency", "88%");
        styleFill.addProperty("draw:fill", "solid");
        styleFill.addProperty("draw:fill-color", brush.color().name());
        break;
    case Qt::Dense3Pattern:
        styleFill.addProperty("draw:transparency", "63%");
        styleFill.addProperty("draw:fill", "solid");
        styleFill.addProperty("draw:fill-color", brush.color().name());
        break;
    case Qt::Dense4Pattern:
        styleFill.addProperty("draw:transparency", "50%");
        styleFill.addProperty("draw:fill", "solid");
        styleFill.addProperty("draw:fill-color", brush.color().name());
        break;
    case Qt::Dense5Pattern:
        styleFill.addProperty("draw:transparency", "37%");
        styleFill.addProperty("draw:fill", "solid");
        styleFill.addProperty("draw:fill-color", brush.color().name());
        break;
    case Qt::Dense6Pattern:
        styleFill.addProperty("draw:transparency", "12%");
        styleFill.addProperty("draw:fill", "solid");
        styleFill.addProperty("draw:fill-color", brush.color().name());
        break;
    case Qt::Dense7Pattern:
        styleFill.addProperty("draw:transparency", "6%");
        styleFill.addProperty("draw:fill", "solid");
        styleFill.addProperty("draw:fill-color", brush.color().name());
        break;
    case Qt::LinearGradientPattern:
    case Qt::RadialGradientPattern:
    case Qt::ConicalGradientPattern:
        styleFill.addProperty("draw:fill", "gradient");
        styleFill.addProperty("draw:fill-gradient-name", saveOdfGradientStyle(mainStyles, brush));
        break;
    case Qt::HorPattern:
    case Qt::VerPattern:
    case Qt::CrossPattern:
    case Qt::BDiagPattern:
    case Qt::FDiagPattern:
    case Qt::DiagCrossPattern:
        styleFill.addProperty("draw:fill", "hatch");
        styleFill.addProperty("draw:fill-hatch-name", saveOdfHatchStyle(mainStyles, brush));
        break;
    case Qt::SolidPattern:
        styleFill.addProperty("draw:fill", "solid");
        styleFill.addProperty("draw:fill-color", brush.color().name());
        if (! brush.isOpaque())
            styleFill.addProperty("draw:opacity", QString("%1%").arg(brush.color().alphaF() * 100.0));
        break;
    case Qt::NoBrush:
    default:
        styleFill.addProperty("draw:fill", "none");
        break;
    }
}
コード例 #16
0
ファイル: graphicshandler.cpp プロジェクト: KDE/calligra
void WordsGraphicsHandler::defineWrappingAttributes(KoGenStyle& style, const DrawStyle& ds)
{
    if (m_processingGroup) return;
    if (m_objectType == Inline) return;

    const KoGenStyle::PropertyType gt = KoGenStyle::GraphicType;
    wvWare::Word97::FSPA* spa = m_pSpa;

    // style:number-wrapped-paragraphs
    // style:run-through
    // style:wrap
    // style:wrap-contour
    // style:wrap-contour-mode
    // style:wrap-dynamic-threshold
    if (spa != 0) {
        bool check_wrk = false;
        switch (spa->wr) {
        case 0: //wrap around the object
        case 2: //square wrapping
            check_wrk = true;
            break;
        case 1: //top and bottom wrapping
            style.addProperty("style:wrap", "none", gt);
            break;
        case 3: //in front or behind the text
            style.addProperty("style:wrap", "run-through", gt);
            //check if shape is behind the text
            if ((spa->fBelowText == 1) || (ds.fBehindDocument())) {
                style.addProperty("style:run-through", "background", gt);
            } else {
                style.addProperty("style:run-through", "foreground", gt);
            }
            break;
        case 4: //tight wrapping
            check_wrk = true;
            style.addProperty("style:wrap-contour", "true", gt);
            style.addProperty("style:wrap-contour-mode", "outside", gt);
            break;
        case 5: //through wrapping
            check_wrk = true;
            style.addProperty("style:wrap-contour", "true", gt);
            style.addProperty("style:wrap-contour-mode", "full", gt);
            break;
        }
        //check details of the text wrapping around this shape
        if (check_wrk) {
            switch (spa->wrk) {
            case 0:
                style.addProperty("style:wrap", "parallel", gt);
                break;
            case 1:
                style.addProperty("style:wrap", "left", gt);
                break;
            case 2:
                style.addProperty("style:wrap", "right", gt);
                break;
            case 3:
                style.addProperty("style:wrap", "biggest", gt);
                break;
            }
        }
        // ODF-1.2: specifies the number of paragraphs that can wrap around a
        // frame if wrap mode is in {left, right, parallel, dynamic} and anchor
        // type is in {char, paragraph}
        if ((spa->wr != 1) && (spa->wr != 3)) {
            style.addProperty("style:number-wrapped-paragraphs", "no-limit");
        }
    } else {
        style.addProperty("style:wrap", "run-through", gt);
        if (ds.fBehindDocument()) {
            style.addProperty("style:run-through", "background", gt);
        } else {
            style.addProperty("style:run-through", "foreground", gt);
        }
    }
}
コード例 #17
0
void KPrFadeOverColorStrategy::saveOdfSmilAttributes(KoGenStyle & style) const
{
    KPrPageEffectStrategy::saveOdfSmilAttributes(style);
    style.addProperty("smil:fadeColor", m_fadeColor.name());
}
コード例 #18
0
QString PictureShape::saveStyle(KoGenStyle& style, KoShapeSavingContext& context) const
{
    if(transparency() > 0.0) {
        style.addProperty("draw:image-opacity", QString("%1%").arg((1.0 - transparency()) * 100.0));
    }

    // this attribute is need to work around a bug in LO 3.4 to make it recognice us as an
    // image and not just any shape. But we shouldn't produce illegal odf so: only for testing!
    // style.addAttribute("style:parent-style-name", "dummy");

    // Mirroring
    if (m_mirrorMode != MirrorNone) {
        QString mode;

        if (m_mirrorMode & MirrorHorizontal)
            mode = "horizontal";
        else if (m_mirrorMode & MirrorHorizontalOnEven)
            mode = "horizontal-on-even";
        else if (m_mirrorMode & MirrorHorizontalOnOdd)
            mode = "horizontal-on-odd";

        if (m_mirrorMode & MirrorVertical) {
            if (!mode.isEmpty())
                mode += ' ';
            mode += "vertical";
        }

        style.addProperty("style:mirror", mode);
    }

    switch(m_colorMode)
    {
    case Standard:
        style.addProperty("draw:color-mode", "standard");
        break;
    case Greyscale:
        style.addProperty("draw:color-mode", "greyscale");
        break;
    case Watermark:
        style.addProperty("draw:color-mode", "watermark");
        break;
    case Mono:
        style.addProperty("draw:color-mode", "mono");
        break;
    }

    KoImageData *imageData = qobject_cast<KoImageData*>(userData());

    if (imageData != 0) {
        QSizeF imageSize = imageData->imageSize();
        ClippingRect rect = m_clippingRect;

        rect.normalize(imageSize);
        rect.bottom = 1.0 - rect.bottom;
        rect.right = 1.0 - rect.right;

        if (!qFuzzyCompare(rect.left + rect.right + rect.top + rect.bottom, qreal(0))) {
            style.addProperty("fo:clip", QString("rect(%1pt, %2pt, %3pt, %4pt)")
                .arg(rect.top * imageSize.height())
                .arg(rect.right * imageSize.width())
                .arg(rect.bottom * imageSize.height())
                .arg(rect.left * imageSize.width())
            );
        }
    }

    return KoTosContainer::saveStyle(style, context);
}
コード例 #19
0
void KoOdfGraphicStyles::saveOdfFillStyle(KoGenStyle &styleFill, KoGenStyles& mainStyles, const QBrush & brush)
{
    KoGenStyle::Type type = styleFill.type();
    KoGenStyle::PropertyType propertyType = (type == KoGenStyle::GraphicStyle || type == KoGenStyle::GraphicAutoStyle ||
                                             type == KoGenStyle::DrawingPageStyle || type == KoGenStyle::DrawingPageAutoStyle )
                                            ? KoGenStyle::DefaultType : KoGenStyle::GraphicType;
    switch (brush.style()) {
    case Qt::Dense1Pattern:
        styleFill.addProperty("draw:opacity", "6%", propertyType);
        styleFill.addProperty("draw:fill", "solid", propertyType);
        styleFill.addProperty("draw:fill-color", brush.color().name(), propertyType);
        break;
    case Qt::Dense2Pattern:
        styleFill.addProperty("draw:opacity", "12%", propertyType);
        styleFill.addProperty("draw:fill", "solid", propertyType);
        styleFill.addProperty("draw:fill-color", brush.color().name(), propertyType);
        break;
    case Qt::Dense3Pattern:
        styleFill.addProperty("draw:opacity", "37%", propertyType);
        styleFill.addProperty("draw:fill", "solid", propertyType);
        styleFill.addProperty("draw:fill-color", brush.color().name(), propertyType);
        break;
    case Qt::Dense4Pattern:
        styleFill.addProperty("draw:opacity", "50%", propertyType);
        styleFill.addProperty("draw:fill", "solid", propertyType);
        styleFill.addProperty("draw:fill-color", brush.color().name(), propertyType);
        break;
    case Qt::Dense5Pattern:
        styleFill.addProperty("draw:opacity", "63%", propertyType);
        styleFill.addProperty("draw:fill", "solid", propertyType);
        styleFill.addProperty("draw:fill-color", brush.color().name(), propertyType);
        break;
    case Qt::Dense6Pattern:
        styleFill.addProperty("draw:opacity", "88%", propertyType);
        styleFill.addProperty("draw:fill", "solid", propertyType);
        styleFill.addProperty("draw:fill-color", brush.color().name(), propertyType);
        break;
    case Qt::Dense7Pattern:
        styleFill.addProperty("draw:opacity", "94%", propertyType);
        styleFill.addProperty("draw:fill", "solid", propertyType);
        styleFill.addProperty("draw:fill-color", brush.color().name(), propertyType);
        break;
    case Qt::LinearGradientPattern:
    case Qt::RadialGradientPattern:
    case Qt::ConicalGradientPattern:
        styleFill.addProperty("draw:fill", "gradient", propertyType);
        styleFill.addProperty("draw:fill-gradient-name", saveOdfGradientStyle(mainStyles, brush), propertyType);
        break;
    case Qt::HorPattern:
    case Qt::VerPattern:
    case Qt::CrossPattern:
    case Qt::BDiagPattern:
    case Qt::FDiagPattern:
    case Qt::DiagCrossPattern:
        styleFill.addProperty("draw:fill", "hatch", propertyType);
        styleFill.addProperty("draw:fill-hatch-name", saveOdfHatchStyle(mainStyles, brush), propertyType);
        break;
    case Qt::SolidPattern:
        styleFill.addProperty("draw:fill", "solid", propertyType);
        styleFill.addProperty("draw:fill-color", brush.color().name(), propertyType);
        if (! brush.isOpaque())
            styleFill.addProperty("draw:opacity", QString("%1%").arg(brush.color().alphaF() * 100.0), propertyType);
        break;
    case Qt::NoBrush:
    default:
        styleFill.addProperty("draw:fill", "none", propertyType);
        break;
    }
}
コード例 #20
0
QString KoPathShape::saveStyle(KoGenStyle &style, KoShapeSavingContext &context) const
{
    style.addProperty("svg:fill-rule", d->fillRule == Qt::OddEvenFill ? "evenodd" : "nonzero");

    return KoShape::saveStyle(style, context);
}