当前位置: 首页>>代码示例>>C++>>正文


C++ Conversion::twipsToPt方法代码示例

本文整理汇总了C++中Conversion::twipsToPt方法的典型用法代码示例。如果您正苦于以下问题:C++ Conversion::twipsToPt方法的具体用法?C++ Conversion::twipsToPt怎么用?C++ Conversion::twipsToPt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Conversion的用法示例。


在下文中一共展示了Conversion::twipsToPt方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: insertEmptyInlineFrame

void WordsGraphicsHandler::insertEmptyInlineFrame(DrawingWriter& out)
{
    if (m_objectType != Inline) return;

    QString styleName;
    KoGenStyle style(KoGenStyle::GraphicAutoStyle, "graphic");
    style.setAutoStyleInStylesDotXml(out.stylesxml);

    DrawStyle ds;
    DrawClient drawclient(this);
    ODrawToOdf odrawtoodf(drawclient);
    odrawtoodf.defineGraphicProperties(style, ds, out.styles);
    definePositionAttributes(style, ds);
    defineWrappingAttributes(style, ds);
    styleName = out.styles.insert(style);

    out.xml.startElement("draw:frame");
    out.xml.addAttribute("draw:style-name", styleName);
    setAnchorTypeAttribute(out);
    setZIndexAttribute(out);
    double hscale = m_picf->mx / 1000.0;
    double vscale = m_picf->my / 1000.0;
    out.xml.addAttributePt("svg:width", twipsToPt(m_picf->dxaGoal) * hscale);
    out.xml.addAttributePt("svg:height", twipsToPt(m_picf->dyaGoal) * vscale);
    out.xml.endElement(); //draw:frame
}
开发者ID:KDE,项目名称:calligra,代码行数:26,代码来源:graphicshandler.cpp

示例2: tableRowStart

void WordsTableHandler::tableRowStart(wvWare::SharedPtr<const wvWare::Word97::TAP> tap)
{
    kDebug(30513) ;
    if (m_row == -2) {
        kWarning(30513) << "tableRowStart: tableStart not called previously!";
        return;
    }
    Q_ASSERT(m_currentTable);
    Q_ASSERT(!m_currentTable->name.isEmpty());
    m_row++;
    m_column = -1;
    m_tap = tap;
    KoXmlWriter*  writer = currentWriter();
    //kDebug(30513) << "tableRowStart row=" << m_row
    //            << ", number of cells: " << tap->itcMac;

    KoGenStyle rowStyle(KoGenStyle::TableRowAutoStyle, "table-row");

    //in case a header or footer is processed, save the style into styles.xml
    if (document()->writingHeader()) {
        rowStyle.setAutoStyleInStylesDotXml(true);
    }

    // The 6 BRC objects are for top, left, bottom, right,
    // insidehorizontal, insidevertical (default values).
    for (int i = 0; i < 6; i++) {
        const wvWare::Word97::BRC& brc = tap->rgbrcTable[i];
        //kDebug(30513) << "default border" << brc.brcType << (brc.dptLineWidth / 8.0);
        m_borderStyle[i] = Conversion::setBorderAttributes(brc);
        m_margin[i] = QString::number(brc.dptSpace) + "pt";
    }
    // We ignore brc.dptSpace (spacing), brc.fShadow (shadow), and brc.fFrame (?)
    QString rowHeightString = QString::number(twipsToPt(qAbs(tap->dyaRowHeight)), 'f').append("pt");

    if (tap->dyaRowHeight > 0) {
        rowStyle.addProperty("style:min-row-height", rowHeightString);
    } else if (tap->dyaRowHeight < 0) {
        rowStyle.addProperty("style:row-height", rowHeightString);
    }

    if (tap->fCantSplit) {
        rowStyle.addProperty("fo:keep-together", "always");
    }

    QString rowStyleName = m_mainStyles->insert(rowStyle, QLatin1String("row"));

    //start table row in content
    writer->startElement("table:table-row");
    writer->addAttribute("table:style-name", rowStyleName.toUtf8());
}
开发者ID:TheTypoMaster,项目名称:calligra,代码行数:50,代码来源:tablehandler.cpp

示例3: tableStart

// Called by Document before invoking the table-row-functors
void KWordTableHandler::tableStart(KWord::Table* table)
{
    kDebug(30513);

    Q_ASSERT(table);
    Q_ASSERT(!table->name.isEmpty());

    KXmlWriter*  writer = currentWriter();
    wvWare::SharedPtr<const wvWare::Word97::TAP> tap = table->tap;

    m_currentTable = table;
    m_cellOpen = false;

#if 0
    for (unsigned int i = 0; i < (unsigned int)table->m_cellEdges.size(); i++)
        kDebug(30513) << table->m_cellEdges[i];
#endif

    m_row = -1;
    m_currentY = 0;

    //check if the table is inside of an absolutely positioned frame
    if ( (tap->dxaAbs != 0 || tap->dyaAbs) )
    {
        KOdfGenericStyle userStyle(KOdfGenericStyle::GraphicAutoStyle, "graphic");
        QString drawStyleName;
        int dxaAbs = 0;

        writer->startElement("text:p", false);
        writer->addAttribute("text:style-name", "Standard");

        //process wrapping information
        if (tap->textWrap) {
            //right aligned
            if (tap->dxaAbs == -8) {
                userStyle.addProperty("style:wrap", "left");
            }
            //left aligned
            else if (tap->dxaAbs == 0) {
                userStyle.addProperty("style:wrap", "right");
            } else {
                userStyle.addProperty("style:wrap", "parallel");
            }
           //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}
            userStyle.addProperty("style:number-wrapped-paragraphs", "no-limit");
        } else {
            userStyle.addProperty("style:wrap", "none");
        }

        //margin information is related to wrapping of text around the table
        userStyle.addPropertyPt("fo:margin-left", twipsToPt(tap->dxaFromText));
        userStyle.addPropertyPt("fo:margin-right", twipsToPt(tap->dxaFromTextRight));
        userStyle.addPropertyPt("fo:margin-top", twipsToPt(tap->dyaFromText));
        userStyle.addPropertyPt("fo:margin-bottom", twipsToPt(tap->dyaFromTextBottom));

        //MS-DOC - sprmPDxaAbs - relative horizontal position to anchor
        // (-4) - center, (-8) - right, (-12) - inside, (-16) - outside
        if (tap->dxaAbs == -4) {
            userStyle.addProperty("style:horizontal-pos","center");
        }
        else if (tap->dxaAbs == -8)  {
            userStyle.addProperty("style:horizontal-pos","right");
            userStyle.addPropertyPt("fo:margin-right", 0);
        }
        else if (tap->dxaAbs == -12) {
            userStyle.addProperty("style:horizontal-pos","inside");
        }
        else if (tap->dxaAbs == -16) {
            userStyle.addProperty("style:horizontal-pos","outside");
        }
        else {
            dxaAbs = tap->dxaAbs;
            userStyle.addProperty("style:horizontal-pos","from-left");
            userStyle.addPropertyPt("fo:margin-left", 0);
        }

        int dyaAbs = 0;
        //MS-DOC - sprmPDyaAbs - relative vertical position to anchor
        // (-4) - top, (-8) - middle, (-12) - bottom, (-16) - inside,
        // (-20) - outside
        if (tap->dyaAbs == -4) {
            userStyle.addProperty("style:vertical-pos","top");
        }
        else if (tap->dyaAbs == -8) {
            userStyle.addProperty("style:vertical-pos","middle");
        }
        else if (tap->dyaAbs == -12) {
            userStyle.addProperty("style:vertical-pos","bottom");
        }
        else if (tap->dyaAbs == -16) {
            userStyle.addProperty("style:vertical-pos","inline");
        }
        else if (tap->dyaAbs == -20) {
            userStyle.addProperty("style:vertical-pos","inline");
        }
        else {
            dyaAbs = tap->dyaAbs;
//.........这里部分代码省略.........
开发者ID:KDE,项目名称:koffice,代码行数:101,代码来源:tablehandler.cpp

示例4: tableCellStart


//.........这里部分代码省略.........

    //top left to bottom right
    if (brcTL2BR.brcType > 0 && brcTL2BR.brcType < 64) {
        cellStyle.addProperty("style:diagonal-tl-br", Conversion::setBorderAttributes(brcTL2BR));
        QString kba = Conversion::borderKOfficeAttributes(brcTL2BR);
        if (!kba.isEmpty()) {
            cellStyle.addProperty("koffice:specialborder-tl-br",kba);
        }
        QString dba = Conversion::setDoubleBorderAttributes(brcTL2BR);
        if (!dba.isEmpty()) {
            cellStyle.addProperty("style:diagonal-tl-br-widths", dba);
        }
    }

    //top right to bottom left
    if (brcTR2BL.brcType > 0 && brcTR2BL.brcType < 64) {
        cellStyle.addProperty("style:diagonal-bl-tr", Conversion::setBorderAttributes(brcTR2BL));
        QString kba = Conversion::borderKOfficeAttributes(brcTR2BL);
        if (!kba.isEmpty()) {
            cellStyle.addProperty("koffice:specialborder-tr-bl",kba);
        }
        QString dba = Conversion::setDoubleBorderAttributes(brcTR2BL);
        if (!dba.isEmpty()) {
            cellStyle.addProperty("style:diagonal-bl-tr-widths", dba);
        }
    }

    //check if we have to ignore the shading information
    if (!shd.shdAutoOrNill) {
        QString color = QString('#');
        //ipatPct5 to ipatPct90
        if (shd.ipat >= 0x02 && shd.ipat <= 0x0d) {
            //get the color from the shading pattern
            uint grayColor = Conversion::shadingPatternToColor(shd.ipat);
            color.append(QString::number(grayColor | 0xff000000, 16).right(6).toUpper());
        }
        //ipatSolid or ipatnil means that no pattern is applied, but only color
        //The case of neither color nor pattern is tested above by the shdAutoOrNill
        else if (shd.ipat == 0x01 || shd.ipat == 0x00) {
            color.append(QString::number(shd.cvBack | 0xff000000, 16).right(6).toUpper());
        }
        else {
            kDebug(30513) << "Warning: Unsupported shading pattern, using current background-color";
            color = document()->currentBgColor();
        }
        cellStyle.addProperty("fo:background-color", color);

        //add the current background-color to stack
        document()->addBgColor(color);
    }

    //text direction
    //if(tc.fVertical) {
    //    cellStyle.addProperty("style:direction", "ttb");
    //}

    //process vertical alignment information 
    QString align;
    switch (tc.vertAlign) {
    case wvWare::vAlignTop:
        align = QString("top");
        break;
    case wvWare::vAlignMiddle:
        align = QString("middle");
        break;
    case wvWare::vAlignBottom:
        align = QString("bottom");
        break;
    }
    cellStyle.addProperty("style:vertical-align", align);

    //process cell padding information
    qreal padVert = twipsToPt(m_tap->padVert);
    qreal padHorz = twipsToPt(m_tap->padHorz);
    cellStyle.addPropertyPt("fo:padding-top", padVert);
    cellStyle.addPropertyPt("fo:padding-bottom", padVert);
    cellStyle.addPropertyPt("fo:padding-left", padHorz);
    cellStyle.addPropertyPt("fo:padding-right", padHorz);

    QString cellStyleName = m_mainStyles->insert(cellStyle, QLatin1String("cell"));

    //emit sigTableCellStart( m_row, leftCellNumber, rowSpan, colSpan, cellRect, m_currentTable->name, brcTop, brcBottom, brcLeft, brcRight, m_tap->rgshd[ m_column ] );

    // Start a table cell in the content.
    writer->startElement("table:table-cell");
    m_cellOpen = true;
    writer->addAttribute("table:style-name", cellStyleName.toUtf8());

    if (rowSpan > 1) {
        writer->addAttribute("table:number-rows-spanned", rowSpan);
    }
    if (colSpan > 1) {
        writer->addAttribute("table:number-columns-spanned", colSpan);
        m_colSpan = colSpan;
    } else {
        // If we don't set it to colSpan, we still need to (re)set it
        // to a known value.
        m_colSpan = 1;
    }
}
开发者ID:KDE,项目名称:koffice,代码行数:101,代码来源:tablehandler.cpp

示例5: tableStart

// Called by Document before invoking the table-row-functors
void WordsTableHandler::tableStart(Words::Table* table)
{
    kDebug(30513);

    Q_ASSERT(table);
    Q_ASSERT(!table->name.isEmpty());

    wvWare::SharedPtr<const wvWare::Word97::TAP> tap = table->tap;
    KoXmlWriter* writer = currentWriter();

    m_currentTable = table;
    m_cellOpen = false;
    m_row = -1;
    m_currentY = 0;

#ifdef DEBUG_TABLEHANDLER
    for (unsigned int i = 0; i < (unsigned int)table->m_cellEdges.size(); i++) {
        kDebug(30513) << table->m_cellEdges[i];
    }
#endif

    if (m_currentTable->floating) {
        const KoGenStyle::PropertyType gt = KoGenStyle::GraphicType;
        KoGenStyle style(KoGenStyle::GraphicAutoStyle, "graphic");
        if (document()->writingHeader()) {
            style.setAutoStyleInStylesDotXml(true);
        }

        //style:wrap
        if (tap->textWrap) {
            if (tap->dxaAbs == -8) {
                style.addProperty("style:wrap", "left", gt);
            }
            else if (tap->dxaAbs == 0) {
                style.addProperty("style:wrap", "right", gt);
            } else {
                style.addProperty("style:wrap", "parallel", gt);
            }
            //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}.
            style.addProperty("style:number-wrapped-paragraphs", "no-limit", gt);
        } else {
            style.addProperty("style:wrap", "none", gt);
        }
        //fo:margin
        style.addPropertyPt("fo:margin-left", twipsToPt(tap->dxaFromText), gt);
        style.addPropertyPt("fo:margin-right", twipsToPt(tap->dxaFromTextRight), gt);
        style.addPropertyPt("fo:margin-top", twipsToPt(tap->dyaFromText), gt);
        style.addPropertyPt("fo:margin-bottom", twipsToPt(tap->dyaFromTextBottom), gt);

        int dxaAbs = 0;
        int dyaAbs = 0;

        //style:horizontal-pos - horizontal position of the anchor
        QString pos = Conversion::getHorizontalPos(tap->dxaAbs);
        style.addProperty("style:horizontal-pos", pos, gt);
        if (pos == "from-left") {
            dxaAbs = tap->dxaAbs;
        }
        //style:vertical-pos - vertical position of the anchor
        pos = Conversion::getVerticalPos(tap->dyaAbs);
        style.addProperty("style:vertical-pos", pos, gt);
        if (pos == "from-top") {
            dyaAbs = tap->dyaAbs;
        }
        //style:vertical-rel - relative vertical position of the anchor
        pos = Conversion::getVerticalRel(tap->pcVert);
	if (!pos.isEmpty()) {
            style.addProperty("style:vertical-rel", pos, gt);
        }
        //style:horizontal-rel - relative horizontal position of the anchor
        pos = Conversion::getHorizontalRel(tap->pcHorz);
        if (!pos.isEmpty()) {
            style.addProperty("style:horizontal-rel", pos, gt);
        }
        //draw:auto-grow-height
        style.addProperty("draw:auto-grow-height", "true", gt);

        const QString drawStyleName = m_mainStyles->insert(style);

        writer->startElement("draw:frame");
        writer->addAttribute("draw:style-name", drawStyleName.toUtf8());
        writer->addAttribute("text:anchor-type", "paragraph");

        int width = table->m_cellEdges[table->m_cellEdges.size() - 1] - table->m_cellEdges[0];
        writer->addAttributePt("svg:width", twipsToPt(width));

        if (style.property("style:horizontal-pos", gt) == "from-left") {
            writer->addAttributePt("svg:x", twipsToPt(dxaAbs + tap->rgdxaCenter[0]));
        }

        writer->addAttributePt("svg:y", twipsToPt(dyaAbs));
        writer->startElement("draw:text-box");
    } //absolutely positioned table

    KoGenStyle tableStyle(KoGenStyle::TableAutoStyle, "table");
    if (document()->writingHeader()) {
        tableStyle.setAutoStyleInStylesDotXml(true);
//.........这里部分代码省略.........
开发者ID:TheTypoMaster,项目名称:calligra,代码行数:101,代码来源:tablehandler.cpp

示例6: tableCellStart


//.........这里部分代码省略.........
        cellStyle.addProperty("fo:border-bottom", Conversion::setBorderAttributes(brcBottom));
        QString kba = Conversion::borderCalligraAttributes(brcBottom);
        if (!kba.isEmpty()) {
            cellStyle.addProperty("calligra:specialborder-bottom",kba);
        }
        QString dba = Conversion::setDoubleBorderAttributes(brcBottom);
        if (!dba.isEmpty()) {
            cellStyle.addProperty("style:border-line-width-bottom", dba);
        }
    }

    //right
    if (brcRight.brcType > 0 && brcRight.brcType < 64) {
        cellStyle.addProperty("fo:border-right", Conversion::setBorderAttributes(brcRight));
        QString kba = Conversion::borderCalligraAttributes(brcRight);
        if (!kba.isEmpty()) {
            cellStyle.addProperty("calligra:specialborder-right",kba);
        }
        QString dba = Conversion::setDoubleBorderAttributes(brcRight);
        if (!dba.isEmpty()) {
            cellStyle.addProperty("style:border-line-width-right", dba);
        }
    }

    //top left to bottom right
    if (brcTL2BR.brcType > 0 && brcTL2BR.brcType < 64) {
        cellStyle.addProperty("style:diagonal-tl-br", Conversion::setBorderAttributes(brcTL2BR));
        QString kba = Conversion::borderCalligraAttributes(brcTL2BR);
        if (!kba.isEmpty()) {
            cellStyle.addProperty("calligra:specialborder-tl-br",kba);
        }
        QString dba = Conversion::setDoubleBorderAttributes(brcTL2BR);
        if (!dba.isEmpty()) {
            cellStyle.addProperty("style:diagonal-tl-br-widths", dba);
        }
    }

    //top right to bottom left
    if (brcTR2BL.brcType > 0 && brcTR2BL.brcType < 64) {
        cellStyle.addProperty("style:diagonal-bl-tr", Conversion::setBorderAttributes(brcTR2BL));
        QString kba = Conversion::borderCalligraAttributes(brcTR2BL);
        if (!kba.isEmpty()) {
            cellStyle.addProperty("calligra:specialborder-tr-bl",kba);
        }
        QString dba = Conversion::setDoubleBorderAttributes(brcTR2BL);
        if (!dba.isEmpty()) {
            cellStyle.addProperty("style:diagonal-bl-tr-widths", dba);
        }
    }

    //text direction
    //if(tc.fVertical) {
    //    cellStyle.addProperty("style:direction", "ttb");
    //}

    //process vertical alignment information
    QString align;
    switch (tc.vertAlign) {
    case vAlignTop:
        align = QString("top");
        break;
    case vAlignMiddle:
        align = QString("middle");
        break;
    case vAlignBottom:
        align = QString("bottom");
        break;
    }
    cellStyle.addProperty("style:vertical-align", align);

    //process cell padding information
    qreal padVert = twipsToPt(m_tap->padVert);
    qreal padHorz = twipsToPt(m_tap->padHorz);
    cellStyle.addPropertyPt("fo:padding-top", padVert);
    cellStyle.addPropertyPt("fo:padding-bottom", padVert);
    cellStyle.addPropertyPt("fo:padding-left", padHorz);
    cellStyle.addPropertyPt("fo:padding-right", padHorz);

    QString cellStyleName = m_mainStyles->insert(cellStyle, "cell");

//     emit sigTableCellStart( m_row, leftCellNumber, rowSpan, colSpan, cellRect, m_currentTable->name,
//                             brcTop, brcBottom, brcLeft, brcRight, m_tap->rgshd[ m_column ] );

    // Start a table cell in the content.
    writer->startElement("table:table-cell");
    m_cellOpen = true;
    writer->addAttribute("table:style-name", cellStyleName.toUtf8());

    if (rowSpan > 1) {
        writer->addAttribute("table:number-rows-spanned", rowSpan);
    }
    if (colSpan > 1) {
        writer->addAttribute("table:number-columns-spanned", colSpan);
        m_colSpan = colSpan;
    } else {
        // If not set to colSpan, we need to (re)set it to a known value.
        m_colSpan = 1;
    }
    m_cellStyleName = cellStyleName;
}
开发者ID:TheTypoMaster,项目名称:calligra,代码行数:101,代码来源:tablehandler.cpp

示例7: processFloatingPictureFrame

void WordsGraphicsHandler::processFloatingPictureFrame(const MSO::OfficeArtSpContainer& o, DrawingWriter& out)
{
    debugMsDoc ;

    const MSO::OfficeArtDggContainer *dgg = 0;
#ifdef USE_OFFICEARTDGG_CONTAINER
    dgg = &m_officeArtDggContainer;
#endif
    DrawStyle ds(dgg, 0, &o);

    // A value of 0x00000000 MUST be ignored.  [MS-ODRAW] — v20101219
    if (!ds.pib()) return;

    QString styleName;
    KoGenStyle style(KoGenStyle::GraphicAutoStyle, "graphic");
    style.setAutoStyleInStylesDotXml(out.stylesxml);

    DrawClient drawclient(this);
    ODrawToOdf odrawtoodf(drawclient);
    odrawtoodf.defineGraphicProperties(style, ds, out.styles);
    definePositionAttributes(style, ds);
    defineWrappingAttributes(style, ds);
    styleName = out.styles.insert(style);

    out.xml.startElement("draw:frame");
    out.xml.addAttribute("draw:style-name", styleName);
    setAnchorTypeAttribute(out);
    setZIndexAttribute(out);

    out.xml.addAttribute("svg:width", mm(out.hLength()));
    out.xml.addAttribute("svg:height", mm(out.vLength()));
    out.xml.addAttribute("svg:x", mm(out.hOffset()));
    out.xml.addAttribute("svg:y", mm(out.vOffset()));

    QString url = getPicturePath(ds.pib());

    //if the image cannot be found, just place an empty frame
    if (url.isEmpty()) {
        out.xml.endElement(); //draw:frame
        return;
    }
    out.xml.startElement("draw:image");
    out.xml.addAttribute("xlink:href", url);
    out.xml.addAttribute("xlink:type", "simple");
    out.xml.addAttribute("xlink:show", "embed");
    out.xml.addAttribute("xlink:actuate", "onLoad");
    out.xml.endElement(); //draw:image

    //check for user edited wrap points
#if 0
    if (ds.fEditedWrap()) {
        QString points;
        IMsoArray _v = ds.pWrapPolygonVertices_complex();
        if (_v.data.size()) {
            //_v.data is an array of POINTs, MS-ODRAW, page 89
            QByteArray a, a2;
            int* p;

            for (int i = 0, offset = 0; i < _v.nElems; i++, offset += _v.cbElem) {
                // x coordinate of this point
                a = _v.data.mid(offset, _v.cbElem);
                a2 = a.mid(0, _v.cbElem / 2);
                p = (int*) a2.data();
                points.append(QString::number(twipsToPt(*p), 'f'));
                points.append(",");
                // y coordinate of this point
                a2 = a.mid(_v.cbElem / 2, _v.cbElem / 2);
                p = (int*) a2.data();
                points.append(QString::number(twipsToPt(*p), 'f'));
                points.append(" ");
            }
            points.chop(1); //remove last space
        }
        out.xml.startElement("draw:contour-polygon");
        out.xml.addAttribute("draw:points", points);
        out.xml.endElement(); //draw:contour-polygon
    }
#endif
    out.xml.endElement(); //draw:frame
    return;
}
开发者ID:KDE,项目名称:calligra,代码行数:81,代码来源:graphicshandler.cpp

示例8: processInlinePictureFrame

void WordsGraphicsHandler::processInlinePictureFrame(const MSO::OfficeArtSpContainer& o, DrawingWriter& out)
{
    debugMsDoc ;

    // Shape instance contained in OfficeArtInlineSpContainer.  BLIP properties
    // contained in o.shapePrimaryOptions or o.shapeTertiaryOptions1 are stored
    // in the order they are encountered, and the property values
    // OfficeArtFOPTE.opid.fBid, OfficeArtFOPTE.opid.fComplex, and
    // OfficeArtFOPTE.op MUST be ignored.  [MS-ODRAW] — v20101219

    QString styleName;
    KoGenStyle style(KoGenStyle::GraphicAutoStyle, "graphic");
    style.setAutoStyleInStylesDotXml(out.stylesxml);

    const MSO::OfficeArtDggContainer *dgg = 0;
#ifdef USE_OFFICEARTDGG_CONTAINER
    dgg = &m_officeArtDggContainer;
#endif

    DrawStyle ds(dgg, 0, &o);
    DrawClient drawclient(this);
    ODrawToOdf odrawtoodf(drawclient);
    odrawtoodf.defineGraphicProperties(style, ds, out.styles);
    definePositionAttributes(style, ds);

    style.addProperty("fo:border-top", Conversion::setBorderAttributes(m_picf->brcTop));
    style.addProperty("fo:border-left", Conversion::setBorderAttributes(m_picf->brcLeft));
    style.addProperty("fo:border-bottom", Conversion::setBorderAttributes(m_picf->brcBottom));
    style.addProperty("fo:border-right", Conversion::setBorderAttributes(m_picf->brcRight));

    // NOTE: The default margin-left/margin-right values DO NOT make sense for
    // inline pictures, also after conversion of test files to DOCX, both
    // attributes were set to ZEROs.  Default margin-top/margin-bottom is ZERO.
    style.addPropertyPt("fo:margin", 0);

    styleName = out.styles.insert(style);

    // A diagram drawing canvas placed inline with surrounding text.
    if (ds.fPseudoInline()) {
        out.xml.startElement("draw:rect");
    } else {
        out.xml.startElement("draw:frame");
    }
    out.xml.addAttribute("draw:style-name", styleName);
    setAnchorTypeAttribute(out);
    setZIndexAttribute(out);

    double hscale = m_picf->mx / 1000.0;
    double vscale = m_picf->my / 1000.0;
    out.xml.addAttributePt("svg:width", twipsToPt(m_picf->dxaGoal) * hscale);
    out.xml.addAttributePt("svg:height", twipsToPt(m_picf->dyaGoal) * vscale);

    QString name = m_picNames.value(m_rgbUid);
    QString url;
    if (!name.isEmpty()) {
        url.append("Pictures/");
        url.append(name);
    } else {
        // if the image cannot be found, just place an empty frame
        out.xml.endElement(); //draw:frame (draw:rect)
        return;
    }
    //TODO: process border information (complex properties)

    out.xml.startElement("draw:image");
    out.xml.addAttribute("xlink:href", url);
    out.xml.addAttribute("xlink:type", "simple");
    out.xml.addAttribute("xlink:show", "embed");
    out.xml.addAttribute("xlink:actuate", "onLoad");
    out.xml.endElement(); //draw:image
    out.xml.endElement(); //draw:frame
    return;
}
开发者ID:KDE,项目名称:calligra,代码行数:73,代码来源:graphicshandler.cpp


注:本文中的Conversion::twipsToPt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。