~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to plugins/pathshapes/enhancedpath/EnhancedPathShape.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-10-27 17:52:57 UTC
  • mfrom: (0.12.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101027175257-s04zqqk5bs8ckm9o
Tags: 1:2.2.83-0ubuntu1
* Merge with Debian git remaining changes:
 - Add build-deps on librcps-dev, opengtl-dev, libqtgtl-dev, freetds-dev,
   create-resources, libspnav-dev
 - Remove needless build-dep on libwv2-dev
 - koffice-libs recommends create-resources
 - krita recommends pstoedit
 - Keep our patches
* New upstream release 2.3 beta 3
  - Remove debian/patches fixed by upstream
  - Update install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include <KoXmlWriter.h>
32
32
#include <KoXmlReader.h>
33
33
#include <KoShapeSavingContext.h>
 
34
#include <KoTextOnShapeContainer.h>
34
35
#include <KoUnit.h>
35
36
#include <KoOdfWorkaround.h>
36
37
#include <KoPathPoint.h>
80
81
 
81
82
    m_viewBound = outline().boundingRect();
82
83
 
83
 
    QMatrix matrix;
 
84
    QTransform matrix;
84
85
    matrix.translate(m_viewBoxOffset.x(), m_viewBoxOffset.y());
85
86
    matrix = m_viewMatrix * matrix;
86
87
 
363
364
 
364
365
        context.xmlWriter().endElement(); // draw:enhanced-geometry
365
366
        saveOdfCommonChildElements(context);
 
367
        if (parent())
 
368
            parent()->saveOdfChildElements(context);
366
369
        context.xmlWriter().endElement(); // draw:custom-shape
367
370
 
368
371
        if (m_mirrorHorizontally) {
380
383
{
381
384
    reset();
382
385
 
383
 
    KoXmlElement child;
384
 
    forEachElement(child, element) {
385
 
        if (child.localName() == "enhanced-geometry" && child.namespaceURI() == KoXmlNS::draw) {
386
 
            // load the viewbox
387
 
            QRectF viewBox = loadOdfViewbox(child);
388
 
            if (! viewBox.isEmpty())
389
 
                m_viewBox = viewBox;
390
 
 
391
 
            // load the modifiers
392
 
            QString modifiers = child.attributeNS(KoXmlNS::draw, "modifiers", "");
393
 
            if (! modifiers.isEmpty()) {
394
 
                addModifiers(modifiers);
395
 
            }
396
 
 
397
 
            KoXmlElement grandChild;
398
 
            forEachElement(grandChild, child) {
399
 
                if (grandChild.namespaceURI() != KoXmlNS::draw)
400
 
                    continue;
401
 
                if (grandChild.localName() == "equation") {
402
 
                    QString name = grandChild.attributeNS(KoXmlNS::draw, "name");
403
 
                    QString formula = grandChild.attributeNS(KoXmlNS::draw, "formula");
404
 
                    addFormula(name, formula);
405
 
                } else if (grandChild.localName() == "handle") {
406
 
                    EnhancedPathHandle * handle = new EnhancedPathHandle(this);
407
 
                    if (handle->loadOdf(grandChild, context)) {
408
 
                        m_enhancedHandles.append(handle);
409
 
                        evaluateHandles();
410
 
                    } else {
411
 
                        delete handle;
412
 
                    }
 
386
    const KoXmlElement enhancedGeometry(KoXml::namedItemNS(element, KoXmlNS::draw, "enhanced-geometry" ) );
 
387
    if (!enhancedGeometry.isNull() ) {
 
388
        // load the modifiers
 
389
        QString modifiers = enhancedGeometry.attributeNS(KoXmlNS::draw, "modifiers", "");
 
390
        if (! modifiers.isEmpty()) {
 
391
            addModifiers(modifiers);
 
392
        }
 
393
 
 
394
        KoXmlElement grandChild;
 
395
        forEachElement(grandChild, enhancedGeometry) {
 
396
            if (grandChild.namespaceURI() != KoXmlNS::draw)
 
397
                continue;
 
398
            if (grandChild.localName() == "equation") {
 
399
                QString name = grandChild.attributeNS(KoXmlNS::draw, "name");
 
400
                QString formula = grandChild.attributeNS(KoXmlNS::draw, "formula");
 
401
                addFormula(name, formula);
 
402
            } else if (grandChild.localName() == "handle") {
 
403
                EnhancedPathHandle * handle = new EnhancedPathHandle(this);
 
404
                if (handle->loadOdf(grandChild, context)) {
 
405
                    m_enhancedHandles.append(handle);
 
406
                    evaluateHandles();
 
407
                } else {
 
408
                    delete handle;
413
409
                }
 
410
            }
414
411
 
415
 
            }
416
 
            // load the enhanced path data
417
 
            QString path = child.attributeNS(KoXmlNS::draw, "enhanced-path", "");
 
412
        }
 
413
        // load the enhanced path data
 
414
        QString path = enhancedGeometry.attributeNS(KoXmlNS::draw, "enhanced-path", "");
418
415
#ifndef NWORKAROUND_ODF_BUGS
419
 
            KoOdfWorkaround::fixEnhancedPath(path, child, context);
 
416
        KoOdfWorkaround::fixEnhancedPath(path, enhancedGeometry, context);
420
417
#endif
421
 
            if (!path.isEmpty()) {
422
 
                parsePathData(path);
423
 
            }
424
 
 
425
 
            setMirrorHorizontally( child.attributeNS(KoXmlNS::draw, "mirror-horizontal") == "true");
426
 
            setMirrorVertically( child.attributeNS(KoXmlNS::draw, "mirror-vertical") == "true");
427
 
        }
 
418
        if (!path.isEmpty()) {
 
419
            parsePathData(path);
 
420
        }
 
421
 
 
422
        // load the viewbox
 
423
        QRectF viewBox = loadOdfViewbox(enhancedGeometry);
 
424
        if (! viewBox.isEmpty()) {
 
425
            m_viewBox = viewBox;
 
426
        }
 
427
        else {
 
428
            // if there is no view box defined make it is big as the path.
 
429
            m_viewBox = m_viewBound;
 
430
        }
 
431
 
 
432
        setMirrorHorizontally(enhancedGeometry.attributeNS(KoXmlNS::draw, "mirror-horizontal") == "true");
 
433
        setMirrorVertically(enhancedGeometry.attributeNS(KoXmlNS::draw, "mirror-vertical") == "true");
428
434
    }
429
435
 
430
436
    QSizeF size;
439
445
    QPointF pos;
440
446
    pos.setX(KoUnit::parseValue(element.attributeNS(KoXmlNS::svg, "x", QString())));
441
447
    pos.setY(KoUnit::parseValue(element.attributeNS(KoXmlNS::svg, "y", QString())));
442
 
    setPosition(pos);
 
448
    setPosition(pos - m_viewMatrix.map(QPointF(0, 0)) - m_viewBoxOffset);
443
449
 
444
450
    loadOdfAttributes(element, context, OdfMandatories | OdfTransformation | OdfAdditionalAttributes | OdfCommonChildElements);
445
451
 
 
452
    KoTextOnShapeContainer::tryWrapShape(this, element, context);
 
453
 
446
454
    return true;
447
455
}
448
456
 
455
463
    bool separator = true;
456
464
    for (int i = 0; i < data.length(); ++i) {
457
465
        QChar ch = data.at(i);
458
 
        if (separator && (ch.unicode() == 'M' || ch.unicode() == 'L'
459
 
            || ch.unicode() == 'C' || ch.unicode() == 'Z'
460
 
            || ch.unicode() == 'N' || ch.unicode() == 'F'
461
 
            || ch.unicode() == 'S' || ch.unicode() == 'T'
462
 
            || ch.unicode() == 'U' || ch.unicode() == 'A'
463
 
            || ch.unicode() == 'B' || ch.unicode() == 'W'
464
 
            || ch.unicode() == 'V' || ch.unicode() == 'X'
465
 
            || ch.unicode() == 'Y' || ch.unicode() == 'Q')) {
 
466
        ushort uni_ch = ch.unicode();
 
467
        if (separator && (uni_ch == 'M' || uni_ch == 'L'
 
468
            || uni_ch == 'C' || uni_ch == 'Z'
 
469
            || uni_ch == 'N' || uni_ch == 'F'
 
470
            || uni_ch == 'S' || uni_ch == 'T'
 
471
            || uni_ch == 'U' || uni_ch == 'A'
 
472
            || uni_ch == 'B' || uni_ch == 'W'
 
473
            || uni_ch == 'V' || uni_ch == 'X'
 
474
            || uni_ch == 'Y' || uni_ch == 'Q')) {
466
475
            if (start != -1) { // process last chars
467
 
                addCommand(data.mid(start, i - start));
 
476
                addCommand(data.mid(start, i - start), false);
468
477
            }
469
478
            start = i;
470
479
        }