~ubuntu-branches/ubuntu/raring/koffice/raring

« back to all changes in this revision

Viewing changes to filters/libmsooxml/MsooXmlCommonReaderDrawingMLImpl.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-12-06 15:30:09 UTC
  • mfrom: (0.13.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101206153009-yf0dqbp9l7fzwxi8
Tags: 1:2.2.91-0ubuntu1
New upstream RC release

Show diffs side-by-side

added added

removed removed

Lines of Context:
153
153
    m_flipH = false;
154
154
    m_flipV = false;
155
155
    m_rot = 0;
156
 
    m_isPlaceHolder = false;
157
156
 
158
157
#ifndef DOCXXMLDOCREADER_CPP
159
158
    // Create a new drawing style for this picture
199
198
    if (m_rot == 0) {
200
199
#if defined(XLSXXMLDRAWINGREADER_CPP)
201
200
    if (m_currentDrawingObject->m_positions.contains(XlsxDrawingObject::FromAnchor)) {  // if we got 'from' cell
202
 
        if (m_currentDrawingObject->m_positions[XlsxDrawingObject::FromAnchor].m_col > 0) {
 
201
        if (m_currentDrawingObject->m_positions[XlsxDrawingObject::FromAnchor].m_col >= 0) {
203
202
            body->addAttributePt("svg:x", EMU_TO_POINT(m_currentDrawingObject->m_positions[XlsxDrawingObject::FromAnchor].m_colOff));
204
203
            body->addAttributePt("svg:y", EMU_TO_POINT(m_currentDrawingObject->m_positions[XlsxDrawingObject::FromAnchor].m_rowOff));
205
204
        }
206
205
        else {
207
 
            body->addAttribute("svg:x", EMU_TO_POINT(m_svgX));
208
 
            body->addAttribute("svg:y", EMU_TO_POINT(m_svgY));
 
206
            body->addAttributePt("svg:x", EMU_TO_POINT(m_svgX));
 
207
            body->addAttributePt("svg:y", EMU_TO_POINT(m_svgY));
209
208
        }
210
 
        if (m_currentDrawingObject->m_positions[XlsxDrawingObject::ToAnchor].m_col > 0) {
 
209
        if (m_currentDrawingObject->m_positions[XlsxDrawingObject::ToAnchor].m_col >= 0) {
211
210
            body->addAttribute("table:end-cell-address", KSpread::Util::encodeColumnLabelText(m_currentDrawingObject->m_positions[XlsxDrawingObject::ToAnchor].m_col+1) +
212
211
                QString::number(m_currentDrawingObject->m_positions[XlsxDrawingObject::ToAnchor].m_row+1));
213
212
            body->addAttributePt("table:end-x", EMU_TO_POINT(m_currentDrawingObject->m_positions[XlsxDrawingObject::ToAnchor].m_colOff));
214
213
            body->addAttributePt("table:end-y", EMU_TO_POINT(m_currentDrawingObject->m_positions[XlsxDrawingObject::ToAnchor].m_rowOff));
215
214
        }
216
215
    }
217
 
 
218
216
#else
219
217
        body->addAttribute("svg:x", EMU_TO_CM_STRING(m_svgX));
220
218
        body->addAttribute("svg:y", EMU_TO_CM_STRING(m_svgY));
289
287
        m_currentDrawingObject->setPicture(picture);
290
288
#endif
291
289
 
292
 
#ifndef DOCXXMLDOCREADER_H
 
290
#ifndef DOCXXMLDOCREADER_CPP
293
291
    popCurrentDrawStyle();
294
292
#endif
295
293
 
474
472
 
475
473
 Child elements:
476
474
 - contentPart (Content Part) §19.3.1.14
477
 
 - cxnSp (Connection Shape) §19.3.1.19
 
475
 - [done] cxnSp (Connection Shape) §19.3.1.19
478
476
 - extLst (Extension List with Modification Flag) §19.3.1.20
479
477
 - [done] graphicFrame (Graphic Frame) §19.3.1.21
480
478
 - [done] grpSp (Group Shape) §19.3.1.22
502
500
            ELSE_TRY_READ_IF(pic)
503
501
            ELSE_TRY_READ_IF(sp)
504
502
            ELSE_TRY_READ_IF(grpSpPr)
 
503
            ELSE_TRY_READ_IF(cxnSp)
505
504
#ifdef PPTXXMLSLIDEREADER_CPP
506
505
            ELSE_TRY_READ_IF(graphicFrame)
507
506
#endif
691
690
        // moved down
692
691
        m_currentShapeProperties = 0;
693
692
    }
694
 
    m_isPlaceHolder = false;
695
 
    ++d->shapeNumber;
696
693
#endif
697
694
 
698
695
    m_cNvPrId.clear();
699
696
    m_cNvPrName.clear();
700
697
    m_cNvPrDescr.clear();
701
 
    m_rot = 0;
702
698
}
703
699
 
704
700
void MSOOXML_CURRENT_CLASS::generateFrameSp()
705
701
{
706
702
#ifdef PPTXXMLSLIDEREADER_CPP
707
 
    const QString styleId(d->phStyleId());
708
 
 
709
703
    kDebug() << "outputDrawFrame for" << (m_context->type == SlideLayout ? "SlideLayout" : "Slide");
710
704
 
711
705
    inheritDefaultBodyProperties();
712
706
    inheritBodyProperties(); // Properties may or may not override default ones.
713
 
#else
 
707
 
 
708
    if (m_normAutoFit == MSOOXML::Utils::autoFitOn) {
 
709
        m_currentPresentationStyle.addProperty("draw:fit-to-size", "true", KoGenStyle::GraphicType);
 
710
    }
714
711
#endif
715
 
    if (m_contentType == "line") {
 
712
    // Arc and straight connector are now simpilified to be a line, fix later
 
713
    if (m_contentType == "line" || m_contentType == "arc" || m_contentType.startsWith("straightConnector")) {
716
714
        body->startElement("draw:line");
717
715
    }
718
716
    else {
729
727
    m_currentDrawStyle->addProperty("fo:margin-bottom", EMU_TO_CM_STRING(m_shapeTextBottomOff.toInt()));
730
728
 
731
729
    const QString styleName(mainStyles->insert(*m_currentDrawStyle, "gr"));
 
730
    body->addAttribute("draw:style-name", styleName);
732
731
 
733
732
#ifdef PPTXXMLSLIDEREADER_CPP
734
733
    if (m_context->type == SlideMaster) {
735
734
        mainStyles->markStyleForStylesXml(styleName);
736
735
    }
737
 
#endif
738
 
    body->addAttribute("draw:style-name", styleName);
739
 
 
740
 
#ifdef PPTXXMLSLIDEREADER_CPP
741
736
 
742
737
    const QString presentationClass(MSOOXML::Utils::ST_PlaceholderType_to_ODF(d->phType));
743
738
 
746
741
    }
747
742
    else {
748
743
        body->addAttribute("draw:layer", "backgroundobjects");
749
 
        // StyleID will be empty for any text that is in masterslide that is wanted
 
744
        // Phtype will be empty for any text that is in masterslide that is wanted
750
745
        // to be shown in the actual slides, such as company names etc.
751
 
        if (!styleId.isEmpty()) {
 
746
        if (!d->phType.isEmpty()) {
752
747
            body->addAttribute("presentation:placeholder", "true");
753
748
            body->addAttribute("presentation:class", presentationClass);
754
749
        }
766
761
        body->addAttribute("presentation:style-name", presentationStyleName);
767
762
    }
768
763
 
 
764
    // Inheriting shape placement information from layout/master
 
765
    inheritShapePosition();
 
766
 
769
767
    if (m_context->type == Slide) {
770
768
        // CASE #P476
771
769
        body->addAttribute("draw:id", m_cNvPrId);
773
771
        kDebug() << "presentationClass:" << d->phType << "->" << presentationClass;
774
772
        kDebug() << "m_svgWidth:" << m_svgWidth << "m_svgHeight:" << m_svgHeight
775
773
                 << "m_svgX:" << m_svgX << "m_svgY:" << m_svgY;
776
 
        PptxPlaceholder *placeholder = m_context->slideLayoutProperties->placeholders.value(presentationClass);
777
 
        kDebug() << "m_context->slideLayoutProperties:" << m_context->slideLayoutProperties
778
 
                 << QString("m_context->slideLayoutProperties->placeholders.value(\"%1\")")
779
 
                   .arg(presentationClass) << placeholder;
780
 
        if (!placeholder) {
781
 
            kDebug() << "trying placeholder for id:" << d->phIdx;
782
 
            placeholder = m_context->slideLayoutProperties->placeholders.value(d->phIdx);
783
 
            kDebug() << "m_context->slideLayoutProperties:" << m_context->slideLayoutProperties
784
 
                << QString("m_context->slideLayoutProperties->placeholders.value(\"%1\")")
785
 
                   .arg(d->phIdx) << placeholder;
786
 
        }
787
 
        if (!m_xfrm_read && m_context->slideLayoutProperties && placeholder) {
788
 
            kDebug() << "Copying attributes from slide layout:" << m_context->slideLayoutProperties->pageLayoutStyleName;
789
 
            m_svgX = placeholder->x;
790
 
            m_svgY = placeholder->y;
791
 
            m_svgWidth = placeholder->width;
792
 
            m_svgHeight = placeholder->height;
793
 
            m_rot = placeholder->rot;
794
 
        }
795
774
    }
796
775
    if (m_svgWidth > -1 && m_svgHeight > -1) {
797
776
        body->addAttribute("presentation:user-transformed", MsooXmlReader::constTrue);
798
 
        if (m_contentType == "line") {
 
777
        if (m_contentType == "line" || m_contentType == "arc" || m_contentType.startsWith("straightConnector")) {
799
778
            QString y1 = EMU_TO_CM_STRING(m_svgY);
800
779
            QString y2 = EMU_TO_CM_STRING(m_svgY + m_svgHeight);
801
780
            QString x1 = EMU_TO_CM_STRING(m_svgX);
802
781
            QString x2 = EMU_TO_CM_STRING(m_svgX + m_svgWidth);
803
 
        if (m_rot != 0) {
804
 
            qreal angle, xDiff, yDiff;
805
 
            MSOOXML::Utils::rotateString(m_rot, m_svgWidth, m_svgHeight, angle, xDiff, yDiff, m_flipH, m_flipV);
806
 
            //! @todo, in case of connector, these should maybe be reversed?
807
 
            x1 = EMU_TO_CM_STRING(m_svgX + xDiff);
808
 
            y1 = EMU_TO_CM_STRING(m_svgY + yDiff);
809
 
            x2 = EMU_TO_CM_STRING(m_svgX + m_svgWidth - xDiff);
810
 
            y2 = EMU_TO_CM_STRING(m_svgY + m_svgHeight - yDiff);
811
 
        }
812
 
        if (m_flipV) {
813
 
            QString temp = y2;
814
 
            y2 = y1;
815
 
            y1 = temp;
816
 
        }
817
 
        if (m_flipH) {
818
 
            QString temp = x2;
819
 
            x2 = x1;
820
 
            x1 = temp;
821
 
        }
 
782
            if (m_rot != 0) {
 
783
                qreal angle, xDiff, yDiff;
 
784
                MSOOXML::Utils::rotateString(m_rot, m_svgWidth, m_svgHeight, angle, xDiff, yDiff, m_flipH, m_flipV);
 
785
                //! @todo, in case of connector, these should maybe be reversed?
 
786
                x1 = EMU_TO_CM_STRING(m_svgX + xDiff);
 
787
                y1 = EMU_TO_CM_STRING(m_svgY + yDiff);
 
788
                x2 = EMU_TO_CM_STRING(m_svgX + m_svgWidth - xDiff);
 
789
                y2 = EMU_TO_CM_STRING(m_svgY + m_svgHeight - yDiff);
 
790
            }
 
791
            if (m_flipV) {
 
792
                QString temp = y2;
 
793
                y2 = y1;
 
794
                y1 = temp;
 
795
            }
 
796
            if (m_flipH) {
 
797
                QString temp = x2;
 
798
                x2 = x1;
 
799
                x1 = temp;
 
800
            }
822
801
            body->addAttribute("svg:x1", x1);
823
802
            body->addAttribute("svg:y1", y1);
824
803
            body->addAttribute("svg:x2", x2);
825
804
            body->addAttribute("svg:y2", y2);
826
805
        }
827
 
        if (m_contentType != "line") {
 
806
        if (m_contentType != "line" && m_contentType != "arc" && !m_contentType.startsWith("straightConnector")) {
828
807
            if (m_rot == 0) {
829
808
                body->addAttribute("svg:x", EMU_TO_CM_STRING(m_svgX));
830
809
                body->addAttribute("svg:y", EMU_TO_CM_STRING(m_svgY));
832
811
            body->addAttribute("svg:width", EMU_TO_CM_STRING(m_svgWidth));
833
812
            body->addAttribute("svg:height", EMU_TO_CM_STRING(m_svgHeight));
834
813
        }
835
 
        if (m_rot != 0 && m_contentType != "line") {
 
814
        if (m_rot != 0 && m_contentType != "line" && m_contentType != "arc" && !m_contentType.startsWith("straightConnector")) {
836
815
            // m_rot is in 1/60,000th of a degree
837
816
            qreal angle, xDiff, yDiff;
838
817
            MSOOXML::Utils::rotateString(m_rot, m_svgWidth, m_svgHeight, angle, xDiff, yDiff, m_flipH, m_flipV);
861
840
#warning TODO: docx
862
841
#endif
863
842
#endif // PPTXXMLSLIDEREADER_H
864
 
}
865
 
 
866
 
KoFilter::ConversionStatus MSOOXML_CURRENT_CLASS::generatePlaceHolderSp()
867
 
{
868
 
#ifdef PPTXXMLSLIDEREADER_CPP
869
 
    const QString styleId(d->phStyleId());
870
 
 
871
 
    kDebug() << "styleId:" << styleId << "d->phType:" << d->phType << "d->phIdx:" << d->phIdx;
872
 
 
873
 
    if (m_context->type == SlideLayout) {
874
 
        PptxShapeProperties* masterShapeProperties = 0;
875
 
        if (!styleId.isEmpty()) {
876
 
            masterShapeProperties = m_context->slideProperties->shapesMap.value(styleId);
877
 
        }
878
 
        else if (d->shapeNumber < (uint)m_context->slideProperties->shapes.count()) {
879
 
            masterShapeProperties = m_context->slideProperties->shapes[d->shapeNumber];
880
 
        }
881
 
        kDebug() << "masterShapeProperties:" << masterShapeProperties;
882
 
 
883
 
        if (masterShapeProperties) {
884
 
            m_currentShapeProperties = new PptxShapeProperties(*masterShapeProperties);
885
 
        } else { // Case where it was not present in master slide at all
886
 
            m_currentShapeProperties = new PptxShapeProperties;
887
 
            m_currentShapeProperties->x = m_svgX;
888
 
            m_currentShapeProperties->y = m_svgY;
889
 
            m_currentShapeProperties->width = m_svgWidth;
890
 
            m_currentShapeProperties->height = m_svgHeight;
891
 
            m_currentShapeProperties->rot = m_rot;
892
 
        }
893
 
        if (!d->phType.isEmpty()) {
894
 
            m_context->slideLayoutProperties->shapesMap[d->phType] = m_currentShapeProperties;
895
 
        }
896
 
        if (!d->phIdx.isEmpty()) {
897
 
            m_context->slideLayoutProperties->shapesMap[d->phIdx] = m_currentShapeProperties;
898
 
        }
899
 
        m_context->slideLayoutProperties->shapes.append(m_currentShapeProperties); 
900
 
    }
901
 
    else if (m_context->type == SlideMaster) {
902
 
        kDebug() << "m_context->slideProperties->shapesMap insert:" << styleId;
903
 
        if (!styleId.isEmpty()) {
904
 
            m_context->slideProperties->shapesMap[styleId] = m_currentShapeProperties;
905
 
        }
906
 
        if (!d->phIdx.isEmpty()) {
907
 
            m_context->slideProperties->shapesMap[d->phIdx] = m_currentShapeProperties;
908
 
        }
909
 
        m_context->slideProperties->shapes.append(m_currentShapeProperties);
910
 
    }
911
 
    if (!m_outputDrawFrame && m_context->type == SlideLayout) {
912
 
        // presentation:placeholder
913
 
        Q_ASSERT(m_placeholderElWriter);
914
 
        QString presentationObject;
915
 
        presentationObject = MSOOXML::Utils::ST_PlaceholderType_to_ODF(d->phType);
916
 
        QString phStyleId = d->phType;
917
 
        if (phStyleId.isEmpty()) {
918
 
            // were indexing placeholders by id if type is not present, so shaped can refer to them by id
919
 
            phStyleId = d->phIdx;
920
 
        }
921
 
 
922
 
        // Keep this placeholder information for reuse in slides because ODF requires
923
 
        // not only reference but redundant copy of the properties to be present in slides.
924
 
        PptxPlaceholder *placeholder;
925
 
        if (m_xfrm_read) {
926
 
            placeholder = new PptxPlaceholder();
927
 
            placeholder->x = m_svgX;
928
 
            placeholder->y = m_svgY;
929
 
            placeholder->width = m_svgWidth;
930
 
            placeholder->height = m_svgHeight;
931
 
            placeholder->rot = m_rot;
932
 
        }
933
 
        else if (m_currentShapeProperties && m_currentShapeProperties->width >= 0) {
934
 
            kDebug() << "copying geometry from master to placeholder";
935
 
            placeholder = new PptxPlaceholder(*m_currentShapeProperties);
936
 
        }
937
 
        else {
938
 
            // We should never come here, as this means that values were not defined in the layout nor
939
 
            // in the masterslide
940
 
            kDebug() << "Xfrm values not defined neither in layout or masterslide";
941
 
            return KoFilter::WrongFormat;
942
 
        }
943
 
        kDebug() << "adding placeholder" << presentationObject << "phStyleId:" << phStyleId;
944
 
        m_context->slideLayoutProperties->placeholders.insert(phStyleId, placeholder);
945
 
 
946
 
        m_placeholderElWriter->startElement("presentation:placeholder");
947
 
        m_placeholderElWriter->addAttribute("presentation:object", presentationObject);
948
 
        if (placeholder->rot == 0) {
949
 
            m_placeholderElWriter->addAttribute("svg:x", EMU_TO_CM_STRING(placeholder->x));
950
 
            m_placeholderElWriter->addAttribute("svg:y", EMU_TO_CM_STRING(placeholder->y));
951
 
        }
952
 
        m_placeholderElWriter->addAttribute("svg:width", EMU_TO_CM_STRING(placeholder->width));
953
 
        m_placeholderElWriter->addAttribute("svg:height", EMU_TO_CM_STRING(placeholder->height));
954
 
        m_rot = placeholder->rot;
955
 
        if (m_rot != 0) {
956
 
            qreal angle, xDiff, yDiff;
957
 
            MSOOXML::Utils::rotateString(m_rot, m_svgWidth, m_svgHeight, angle, xDiff, yDiff, m_flipH, m_flipV);
958
 
            QString rotString = QString("rotate(%1) translate(%2cm %3cm)")
959
 
                                .arg(angle).arg((m_svgX + xDiff)/360000).arg((m_svgY + yDiff)/360000);
960
 
            m_placeholderElWriter->addAttribute("draw:transform", rotString);
961
 
 
962
 
        }
963
 
 
964
 
        m_placeholderElWriter->endElement();
965
 
    }
966
 
 
967
 
#endif
968
 
 
969
 
#ifdef PPTXXMLSLIDEREADER_CPP
970
 
    m_currentShapeProperties = 0; // Making sure that nothing uses them.
971
 
#endif
972
 
    return KoFilter::OK;
 
843
    // In case of a blipFill
 
844
    if (!m_xlinkHref.isEmpty()) {
 
845
        body->startElement("draw:image");
 
846
        body->addAttribute("xlink:href", m_xlinkHref);
 
847
        body->addAttribute("xlink:type", "simple");
 
848
        body->addAttribute("xlink:show", "embed");
 
849
        body->addAttribute("xlink:actuate", "onLoad");
 
850
        body->endElement(); //draw:image
 
851
        m_xlinkHref.clear();
 
852
    }
 
853
 
973
854
}
974
855
 
975
856
#undef CURRENT_EL
1004
885
        }
1005
886
    }
1006
887
 
1007
 
    m_outputDrawFrame = true;
 
888
    body = drawFrameBuf.originalWriter();
 
889
 
 
890
    generateFrameSp();
 
891
 
 
892
    (void)drawFrameBuf.releaseWriter();
 
893
    body->endElement(); //draw:frame, //draw:line
1008
894
 
1009
895
#ifdef PPTXXMLSLIDEREADER_CPP
1010
 
    const QString styleId(d->phStyleId());
1011
 
    if (m_context->type == SlideLayout && !styleId.isEmpty()) {
1012
 
        m_outputDrawFrame = false;
1013
 
        body = drawFrameBuf.originalWriter();
1014
 
        drawFrameBuf.clear();
1015
 
        kDebug() << "giving up outputDrawFrame for because ph@type is not empty:" << d->phType << "m_context->type=" << m_context->type;
1016
 
    }
1017
 
#endif
1018
 
 
1019
 
    if (m_outputDrawFrame) {
1020
 
        body = drawFrameBuf.originalWriter();
1021
 
 
1022
 
        generateFrameSp();
1023
 
 
1024
 
        (void)drawFrameBuf.releaseWriter();
1025
 
        body->endElement(); //draw:frame, //draw:line
1026
 
    }
1027
 
 
1028
896
    KoFilter::ConversionStatus stat = generatePlaceHolderSp();
1029
897
    if (stat != KoFilter::OK) {
1030
898
        return stat;
1031
899
    }
 
900
#endif
1032
901
 
1033
902
    popCurrentDrawStyle();
1034
903
 
1044
913
 defined using the DrawingML framework.
1045
914
 
1046
915
 Parent elements:
1047
 
    - grpSp (§19.3.1.22)
1048
 
    - grpSp (§20.1.2.2.20) - DrawingML
 
916
    - [done] grpSp (§19.3.1.22)
 
917
    - [done] grpSp (§20.1.2.2.20) - DrawingML
1049
918
    - lockedCanvas (§20.3.2.1) - DrawingML
1050
919
    - [done] spTree (§19.3.1.45)
1051
920
 Child elements:
1072
941
    READ_PROLOGUE
1073
942
 
1074
943
    m_contentType.clear();
 
944
    m_xlinkHref.clear();
1075
945
 
1076
946
#if defined(XLSXXMLDRAWINGREADER_CPP)
1077
947
    KoXmlWriter *bodyBackup = body;
1107
977
        }
1108
978
    }
1109
979
 
1110
 
    m_outputDrawFrame = true;
 
980
    body = drawFrameBuf.originalWriter();
 
981
 
 
982
    generateFrameSp();
 
983
 
 
984
    (void)drawFrameBuf.releaseWriter();
 
985
    body->endElement(); //draw:frame, //draw:line
1111
986
 
1112
987
#ifdef PPTXXMLSLIDEREADER_CPP
1113
 
    const QString styleId(d->phStyleId());
1114
 
    if (m_context->type == SlideLayout && !styleId.isEmpty()) {
1115
 
        m_outputDrawFrame = false;
1116
 
        body = drawFrameBuf.originalWriter();
1117
 
        drawFrameBuf.clear();
1118
 
        kDebug() << "giving up outputDrawFrame for because ph@type is not empty:" << d->phType << "m_context->type=" << m_context->type;
1119
 
    }
1120
 
#endif
1121
 
 
1122
 
    if (m_outputDrawFrame) {
1123
 
        body = drawFrameBuf.originalWriter();
1124
 
 
1125
 
        generateFrameSp();
1126
 
 
1127
 
        (void)drawFrameBuf.releaseWriter();
1128
 
        body->endElement(); //draw:frame, //draw:line
1129
 
    }
1130
 
 
1131
988
    KoFilter::ConversionStatus stat = generatePlaceHolderSp();
1132
989
    if (stat != KoFilter::OK) {
1133
990
        return stat;
1134
991
    }
 
992
#endif
1135
993
 
1136
994
    popCurrentDrawStyle();
1137
995
 
1191
1049
 These properties include the shape fill, outline, geometry, effects, and 3D orientation.
1192
1050
 
1193
1051
 Parent elements:
1194
 
    - cxnSp (§19.3.1.19)
1195
 
    - cxnSp (§20.1.2.2.10) - DrawingML
 
1052
    - [done] cxnSp (§19.3.1.19)
 
1053
    - [done] cxnSp (§20.1.2.2.10) - DrawingML
1196
1054
    - lnDef (§20.1.4.1.20) - DrawingML
1197
1055
    - [done] pic (§19.3.1.37)
1198
1056
    - [done] pic (§20.1.2.2.30) - DrawingML
1202
1060
    - txDef (§20.1.4.1.28) - DrawingML
1203
1061
 
1204
1062
 Child elements:
1205
 
    - blipFill (Picture Fill) §20.1.8.14
 
1063
    - [done] blipFill (Picture Fill) §20.1.8.14
1206
1064
    - custGeom (Custom Geometry) §20.1.9.8
1207
1065
    - effectDag (Effect Container) §20.1.8.25
1208
1066
    - effectLst (Effect Container) §20.1.8.26
1209
 
    - extLst (Extension List) §20.1.2.2.15
 
1067
    - [done] extLst (Extension List) §20.1.2.2.15
1210
1068
    - [done] gradFill (Gradient Fill) §20.1.8.33
1211
1069
    - grpFill (Group Fill) §20.1.8.35
1212
1070
    - ln (Outline) §20.1.2.2.24
1235
1093
                TRY_READ(xfrm)
1236
1094
                m_xfrm_read = true;
1237
1095
            }
 
1096
            else if (qualifiedName() == QLatin1String("a:extLst")) {
 
1097
                TRY_READ(extLst)
 
1098
            }
1238
1099
            else if (qualifiedName() == QLatin1String("a:solidFill")) {
1239
1100
#ifdef PPTXXMLSLIDEREADER_CPP
1240
1101
                d->textBoxHasContent = true; // We count normal fill and gardient as content
1254
1115
            else if (qualifiedName() == QLatin1String("a:prstGeom")) {
1255
1116
                TRY_READ(prstGeom)
1256
1117
            }
 
1118
            else if (qualifiedName() == QLatin1String("a:blipFill")) {
 
1119
                TRY_READ_IN_CONTEXT(blipFill)
 
1120
            }
1257
1121
            else if (qualifiedName() == QLatin1String("a:gradFill")) {
1258
1122
#ifdef PPTXXMLSLIDEREADER_CPP
1259
1123
                d->textBoxHasContent = true;
1269
1133
        }
1270
1134
    }
1271
1135
 
1272
 
#ifdef PPTXXMLSLIDEREADER_CPP
1273
 
    const QString styleId(d->phStyleId());
1274
 
    kDebug() << "styleId:" << styleId;
1275
 
 
1276
 
    if (m_context->type == Slide && !m_xfrm_read) { // loading values from slideLayout is needed
1277
 
        //Q_ASSERT(d->shapeNumber >= 1 && d->shapeNumber <= m_context->slideLayoutProperties->shapes.count());
1278
 
        PptxShapeProperties* props = 0;
1279
 
        if (!styleId.isEmpty()) {
1280
 
            props = m_context->slideLayoutProperties->shapesMap.value(styleId);
1281
 
        }
1282
 
        else if(d->shapeNumber >= 1 && d->shapeNumber <= (uint)m_context->slideLayoutProperties->shapes.count())
1283
 
        {
1284
 
            props = m_context->slideLayoutProperties->shapes[d->shapeNumber - 1];
1285
 
        }
1286
 
        if (!props) { // It was not present in layout, we need to get the place from slideMaster
1287
 
            props = m_context->slideProperties->shapesMap.value(styleId);
1288
 
            if (!props) {
1289
 
                // In case there was nothing for this even in slideMaster, let's default to 'body' text position
1290
 
                // Spec doesn't say anything about this case, but in reality there are such documents
1291
 
                props = m_context->slideProperties->shapesMap.value("body");
1292
 
            }
1293
 
        }
1294
 
        if (props) {
1295
 
            m_svgX = props->x;
1296
 
            m_svgY = props->y;
1297
 
            m_svgWidth = props->width;
1298
 
            m_svgHeight = props->height;
1299
 
            m_rot = props->rot;
1300
 
            m_isPlaceHolder = props->isPlaceHolder;
1301
 
            kDebug() << "Copied from PptxShapeProperties:"
1302
 
                << "d->shapeNumber:" << d->shapeNumber
1303
 
                << "m_svgWidth:" << m_svgWidth << "m_svgHeight:" << m_svgHeight
1304
 
                << "m_svgX:" << m_svgX << "m_svgY:" << m_svgY;
1305
 
        }
1306
 
    }
1307
 
#endif
1308
 
 
1309
1136
    READ_EPILOGUE
1310
1137
}
1311
1138
 
1354
1181
        chartexport->m_width = m_svgWidth > 0 ? EMU_TO_POINT(m_svgWidth) : 100;
1355
1182
        chartexport->m_height = m_svgHeight > 0 ? EMU_TO_POINT(m_svgHeight) : 100;
1356
1183
#endif
1357
 
        
 
1184
 
1358
1185
        KoStore* storeout = m_context->import->outputStore();
1359
1186
        QScopedPointer<XlsxXmlChartReaderContext> context(new XlsxXmlChartReaderContext(storeout, chartexport));
1360
1187
        XlsxXmlChartReader reader(this);
1404
1231
 
1405
1232
 Child elements:
1406
1233
 - hslClr (Hue, Saturation, Luminance Color Model) §20.1.2.3.13
1407
 
 - prstClr (Preset Color) §20.1.2.3.22
 
1234
 - [done] prstClr (Preset Color) §20.1.2.3.22
1408
1235
 - [done] schemeClr (Scheme Color) §20.1.2.3.29
1409
1236
 - [done] scrgbClr (RGB Color Model - Percentage Variant) §20.1.2.3.30
1410
1237
 - [done] srgbClr (RGB Color Model - Hex Variant) §20.1.2.3.32
1425
1252
            ELSE_TRY_READ_IF(scrgbClr)
1426
1253
            ELSE_TRY_READ_IF(sysClr)
1427
1254
            ELSE_TRY_READ_IF(srgbClr)
 
1255
            ELSE_TRY_READ_IF(prstClr)
1428
1256
//! @todo add ELSE_WRONG_FORMAT
1429
1257
        }
1430
1258
    }
1431
1259
 
1432
 
 
1433
1260
    m_currentDrawStyle->addProperty("draw:fill", QLatin1String("solid"));
1434
1261
    m_currentDrawStyle->addProperty("draw:fill-color", m_currentColor.name());
1435
1262
 
1451
1278
 
1452
1279
 Child elements:
1453
1280
 - hslClr (Hue, Saturation, Luminance Color Model) §20.1.2.3.13
1454
 
 - prstClr (Preset Color) §20.1.2.3.22
 
1281
 - [done] prstClr (Preset Color) §20.1.2.3.22
1455
1282
 - [done] schemeClr (Scheme Color) §20.1.2.3.29
1456
1283
 - [done] scrgbClr (RGB Color Model - Percentage Variant) §20.1.2.3.30
1457
1284
 - [done] srgbClr (RGB Color Model - Hex Variant) §20.1.2.3.32
1471
1298
            ELSE_TRY_READ_IF(srgbClr)
1472
1299
            ELSE_TRY_READ_IF(sysClr)
1473
1300
            ELSE_TRY_READ_IF(scrgbClr)
 
1301
            ELSE_TRY_READ_IF(prstClr)
1474
1302
//! @todo add ELSE_WRONG_FORMAT
1475
1303
        }
1476
1304
    }
1541
1369
 - [done] br (Text Line Break) §21.1.2.2.1
1542
1370
 - endParaRPr (End Paragraph Run Properties) §21.1.2.2.3
1543
1371
 - [done] fld (Text Field) §21.1.2.2.4
1544
 
 - pPr (Text Paragraph Properties) §21.1.2.2.7
 
1372
 - [done] pPr (Text Paragraph Properties) §21.1.2.2.7
1545
1373
 - [done] r (Text Run) §21.1.2.3.8
1546
1374
*/
1547
1375
//! @todo support all elements
1617
1445
    if (!pprRead) {
1618
1446
        inheritDefaultParagraphStyle(m_currentParagraphStyle);
1619
1447
        inheritParagraphStyle(m_currentParagraphStyle);
 
1448
        m_currentBulletProperties = m_currentCombinedBulletProperties[m_currentListLevel];
1620
1449
    }
1621
1450
    if (!rRead) {
1622
1451
        // We are inheriting to paragraph's text-properties because there is no text
1640
1469
        }
1641
1470
        m_previousListWasAltered = false;
1642
1471
    }
1643
 
 
 
1472
    if (m_currentBulletProperties.bulletRelativeSize() != "UNUSED") {
 
1473
        m_listStylePropertiesAltered = true;
 
1474
        QString textSize = m_currentTextStyle.property("fo:font-size");
 
1475
        if (!textSize.isEmpty()) {
 
1476
            textSize = textSize.left(textSize.length() - 2); // removes 'pt'
 
1477
            qreal convertedSize = textSize.toDouble() * m_currentBulletProperties.bulletRelativeSize().toDouble()/100;
 
1478
            m_currentBulletProperties.setBulletSize(QSize(convertedSize, convertedSize));
 
1479
        }
 
1480
    }
1644
1481
    if (m_listStylePropertiesAltered) {
 
1482
        m_currentListStyle = KoGenStyle(KoGenStyle::ListAutoStyle, "list");
 
1483
 
 
1484
        // For now we take a stand that any altered style makes its own list.
 
1485
        m_currentBulletProperties.m_level = m_currentListLevel;
 
1486
 
 
1487
        m_currentListStyle.addChildElement("list-style-properties",
 
1488
            m_currentBulletProperties.convertToListProperties());
1645
1489
        m_previousListWasAltered = true;
1646
1490
    }
1647
1491
 
1650
1494
        // we don't output a bullet to it
1651
1495
        m_currentListLevel = 0;
1652
1496
    }
1653
 
    else if (m_currentCombinedBulletProperties.value(m_currentListLevel).isEmpty() && !m_listStylePropertiesAltered) {
 
1497
    else if ((m_currentCombinedBulletProperties.value(m_currentListLevel).isEmpty() && !m_listStylePropertiesAltered) ||
 
1498
             (m_currentBulletProperties.isEmpty() && m_listStylePropertiesAltered)) {
1654
1499
        m_currentListLevel = 0;
1655
1500
    }
1656
1501
 
1897
1742
            TRY_READ_IF(latin)
1898
1743
            ELSE_TRY_READ_IF_IN_CONTEXT(blipFill)
1899
1744
            ELSE_TRY_READ_IF(solidFill)
1900
 
            ELSE_TRY_READ_IF(gradFill)
 
1745
            // As odf does not support gradFill for text, it's better to not use it at all, as relying on the first color
 
1746
            // can create bad results.
 
1747
            //ELSE_TRY_READ_IF(gradFill)
1901
1748
            ELSE_TRY_READ_IF_IN_CONTEXT(noFill)
1902
1749
            else if (QUALIFIED_NAME_IS(highlight)) {
1903
1750
                TRY_READ(DrawingML_highlight)
2052
1899
  - [done] buFont (Specified) §21.1.2.4.6
2053
1900
  - buFontTx (Follow text) §21.1.2.4.7
2054
1901
  - [done] buNone (No Bullet) §21.1.2.4.8
2055
 
  - buSzPct (Bullet Size Percentage) §21.1.2.4.9
 
1902
  - [done] buSzPct (Bullet Size Percentage) §21.1.2.4.9
2056
1903
  - buSzPts (Bullet Size Points) §21.1.2.4.10
2057
1904
  - buSzTx (Bullet Size Follows Text) §21.1.2.4.11
2058
1905
  - defRPr (Default Text Run Properties) §21.1.2.3.2
2120
1967
            ELSE_TRY_READ_IF(buClr)
2121
1968
            ELSE_TRY_READ_IF(buFont)
2122
1969
            ELSE_TRY_READ_IF(buBlip)
 
1970
            ELSE_TRY_READ_IF(buSzPct)
2123
1971
            else if (QUALIFIED_NAME_IS(spcBef)) {
2124
1972
                m_currentSpacingType = spacingMarginTop;
2125
1973
                TRY_READ(spcBef)
2135
1983
        }
2136
1984
    }
2137
1985
 
2138
 
    if (m_currentBulletProperties.bulletFont().startsWith("Wingdings") && m_currentBulletProperties.bulletChar() != "") {
2139
 
        // Ooxml files have very often wingdings fonts, but usually they are not installed
2140
 
        // Making the bullet character look ugly, thus defaulting to "-"
2141
 
        m_listStylePropertiesAltered = true;
2142
 
        m_currentBulletProperties.setBulletChar("-");
2143
 
    }
2144
 
 
2145
 
    if (m_listStylePropertiesAltered) {
2146
 
        m_currentListStyle = KoGenStyle(KoGenStyle::ListAutoStyle, "list");
2147
 
 
2148
 
        // For now we take a stand that any altered style makes its own list.
2149
 
        m_currentBulletProperties.m_level = m_currentListLevel;
2150
 
 
2151
 
        m_currentListStyle.addChildElement("list-style-properties",
2152
 
            m_currentBulletProperties.convertToListProperties());
2153
 
    }
2154
 
 
2155
1986
    READ_EPILOGUE
2156
1987
}
2157
1988
 
2162
1993
/*! This element represents 2-D transforms for ordinary shapes.
2163
1994
 
2164
1995
 Parent elements:
2165
 
    - graphicFrame (§20.1.2.2.18)
 
1996
    - [done] graphicFrame (§20.1.2.2.18)
2166
1997
    - spPr (§21.2.2.197)
2167
1998
    - spPr (§21.3.2.23)
2168
1999
    - spPr (§21.4.3.7)
2195
2026
    TRY_READ_ATTR_WITHOUT_NS(rot)
2196
2027
    STRING_TO_INT(rot, m_rot, "xfrm@rot")
2197
2028
 
2198
 
    bool off_read = false;
2199
 
    bool ext_read = false;
2200
2029
    while (!atEnd()) {
2201
2030
        readNext();
2202
2031
        BREAK_IF_END_OF(CURRENT_EL);
2203
2032
        if (isStartElement()) {
2204
2033
            if (QUALIFIED_NAME_IS(off)) {
2205
2034
                TRY_READ(off);
2206
 
                off_read = true;
2207
2035
            } else if (QUALIFIED_NAME_IS(ext)) {
2208
2036
                TRY_READ(ext);
2209
 
                ext_read = true;
2210
2037
            }
2211
2038
            ELSE_TRY_READ_IF(chOff)
2212
2039
            ELSE_TRY_READ_IF(chExt)
2214
2041
//! @todo add ELSE_WRONG_FORMAT
2215
2042
    }
2216
2043
 
2217
 
    /*//! @todo
2218
 
        if (m_context->type == Slide) { // load values from master is needed
2219
 
            if (!off_read) {
2220
 
                m_svgX = m_currentShapeProperties->x;
2221
 
                m_svgY = m_currentShapeProperties->y;
2222
 
                kDebug() << "Inherited svg:x/y from master (m_currentShapeProperties)";
2223
 
            }
2224
 
            if (!ext_read) {
2225
 
                m_svgWidth = m_currentShapeProperties->width;
2226
 
                m_svgHeight = m_currentShapeProperties->y;
2227
 
                kDebug() << "Inherited svg:width/height from master (m_currentShapeProperties)";
2228
 
            }
2229
 
        }*/
2230
 
#ifdef PPTXXMLSLIDEREADER_CPP
2231
 
    if (m_context->type == SlideMaster) { // save
2232
 
        if (!off_read) {
2233
 
            raiseElNotFoundError("a:off");
2234
 
            return KoFilter::WrongFormat;
2235
 
        }
2236
 
        if (!ext_read) {
2237
 
            raiseElNotFoundError("a:ext");
2238
 
            return KoFilter::WrongFormat;
2239
 
        }
2240
 
    }
2241
 
    if (m_currentShapeProperties && (m_context->type == SlideMaster || m_context->type == SlideLayout)) {
2242
 
        m_currentShapeProperties->x = m_svgX;
2243
 
        m_currentShapeProperties->y = m_svgY;
2244
 
        m_currentShapeProperties->width = m_svgWidth;
2245
 
        m_currentShapeProperties->height = m_svgHeight;
2246
 
        m_currentShapeProperties->rot = m_rot;
2247
 
        m_currentShapeProperties->isPlaceHolder = m_isPlaceHolder;
2248
 
    }
2249
 
#endif
2250
 
 
2251
2044
    kDebug() << "svg:x" << m_svgX << "svg:y" << m_svgY << "svg:width" << m_svgWidth << "svg:height" << m_svgHeight << "rotation" << m_rot;
2252
2045
 
2253
2046
    READ_EPILOGUE
2262
2055
    Effects on an object are not included in this bounding box.
2263
2056
 
2264
2057
 Parent elements:
2265
 
    - xfrm (§21.3.2.28)
2266
 
    - xfrm (§20.1.7.5)
 
2058
    - [done] xfrm (§21.3.2.28)
 
2059
    - [done] xfrm (§20.1.7.5)
2267
2060
    - [done] xfrm (§20.1.7.6)
2268
 
    - xfrm (§20.5.2.36)
2269
 
    - xfrm (§19.3.1.53)
 
2061
    - [done] xfrm (§20.5.2.36)
 
2062
    - [done] xfrm (§19.3.1.53)
2270
2063
 
2271
2064
 No child elements.
2272
2065
 
2273
2066
 Attributes:
2274
2067
    - [done] x (X-Axis Coordinate)
2275
 
    - [done] y (Y-Axis Coordinate)
2276
 
*/
2277
 
//! @todo support all elements
 
2068
    - [done] y (Y-Axis Coordinate) */ //! @todo support all elements
2278
2069
#undef CURRENT_EL
2279
2070
#define CURRENT_EL off
2280
2071
KoFilter::ConversionStatus MSOOXML_CURRENT_CLASS::read_off()
2298
2089
        }
2299
2090
    }
2300
2091
 
2301
 
    while (true) {
2302
 
        readNext();
2303
 
        BREAK_IF_END_OF(CURRENT_EL);
2304
 
    }
2305
 
 
 
2092
    readNext();
2306
2093
    READ_EPILOGUE
2307
2094
}
2308
2095
 
2320
2107
    READ_ATTR_WITHOUT_NS(y)
2321
2108
    STRING_TO_INT(y, m_svgChY, "chOff@y")
2322
2109
 
2323
 
 
2324
 
    while (true) {
2325
 
        readNext();
2326
 
        BREAK_IF_END_OF(CURRENT_EL);
2327
 
    }
2328
 
 
 
2110
    readNext();
2329
2111
    READ_EPILOGUE
2330
2112
}
2331
2113
 
2333
2115
//! DrawingML ECMA-376, 20.1.7.3, p. 3185.
2334
2116
/*! This element specifies the size of the bounding box enclosing the referenced object.
2335
2117
 Parent elements:
2336
 
 - xfrm (§21.3.2.28)
2337
 
 - xfrm (§20.1.7.5)
 
2118
 - [done] xfrm (§21.3.2.28)
 
2119
 - [done] xfrm (§20.1.7.5)
2338
2120
 - [done] xfrm (§20.1.7.6)
2339
 
 - xfrm (§20.5.2.36)
2340
 
 - xfrm (§19.3.1.53)
 
2121
 - [done] xfrm (§20.5.2.36)
 
2122
 - [done] xfrm (§19.3.1.53)
2341
2123
 
2342
2124
 No child elements.
2343
2125
 
2344
2126
 Attributes:
2345
 
 - cx (Extent Length) Specifies the length of the extents rectangle in EMUs. This rectangle shall dictate
 
2127
 - [done] cx (Extent Length) Specifies the length of the extents rectangle in EMUs. This rectangle shall dictate
2346
2128
      the size of the object as displayed (the result of any scaling to the original object).
2347
 
 - cy (Extent Width) Specifies the width of the extents rectangle in EMUs.
 
2129
 - [done] cy (Extent Width) Specifies the width of the extents rectangle in EMUs.
2348
2130
*/
2349
 
//! @todo support all child elements
2350
2131
#undef CURRENT_EL
2351
2132
#define CURRENT_EL ext
2352
2133
KoFilter::ConversionStatus MSOOXML_CURRENT_CLASS::read_ext()
2371
2152
        }
2372
2153
    }
2373
2154
 
2374
 
    while (true) {
2375
 
        readNext();
2376
 
        BREAK_IF_END_OF(CURRENT_EL);
2377
 
    }
2378
 
 
 
2155
    readNext();
2379
2156
    READ_EPILOGUE
2380
2157
}
2381
2158
 
2393
2170
    READ_ATTR_WITHOUT_NS(cy)
2394
2171
    STRING_TO_INT(cy, m_svgChHeight, "chExt@cy")
2395
2172
 
2396
 
    while (true) {
2397
 
        readNext();
2398
 
        BREAK_IF_END_OF(CURRENT_EL);
2399
 
    }
 
2173
    readNext();
2400
2174
 
2401
2175
    READ_EPILOGUE
2402
2176
}
2429
2203
    - clrChange (Color Change Effect) §20.1.8.16
2430
2204
    - clrRepl (Solid Color Replacement) §20.1.8.18
2431
2205
    - duotone (Duotone Effect) §20.1.8.23
2432
 
    - extLst (Extension List) §20.1.2.2.15
 
2206
    - [done] extLst (Extension List) §20.1.2.2.15
2433
2207
    - fillOverlay (Fill Overlay Effect) §20.1.8.29
2434
2208
    - [done] grayscl (Gray Scale Effect) §20.1.8.34
2435
2209
    - hsl (Hue Saturation Luminance Effect) §20.1.8.39
2446
2220
{
2447
2221
    READ_PROLOGUE
2448
2222
 
2449
 
    m_xlinkHref.clear();
2450
 
 
2451
2223
    // Read attributes.
2452
2224
    const QXmlStreamAttributes attrs(attributes());
2453
2225
//! @todo more attrs
2481
2253
            TRY_READ_IF(biLevel)
2482
2254
            ELSE_TRY_READ_IF(grayscl)
2483
2255
            ELSE_TRY_READ_IF(lum)
 
2256
            ELSE_TRY_READ_IF(extLst)
2484
2257
//! @todo add ELSE_WRONG_FORMAT
2485
2258
        }
2486
2259
    }
2640
2413
 is tiled across the bounding box to fill the entire area.
2641
2414
 
2642
2415
 Parent elements:
2643
 
 - blipFill (§21.3.2.2)
2644
 
 - blipFill (§20.1.8.14)
2645
 
 - blipFill (§20.2.2.1)
2646
 
 - blipFill (§20.5.2.2)
2647
 
 - blipFill (§19.3.1.4)
 
2416
 - [done] blipFill (§21.3.2.2)
 
2417
 - [done] blipFill (§20.1.8.14)
 
2418
 - [done] blipFill (§20.2.2.1)
 
2419
 - [done] blipFill (§20.5.2.2)
 
2420
 - [done] blipFill (§19.3.1.4)
2648
2421
 
2649
2422
 No child elements.
2650
2423
*/
2663
2436
//! @todo tx
2664
2437
//! @todo ty
2665
2438
 
2666
 
    while (!atEnd()) {
2667
 
        readNext();
2668
 
        BREAK_IF_END_OF(CURRENT_EL);
2669
 
    }
 
2439
    readNext();
2670
2440
    READ_EPILOGUE
2671
2441
}
2672
2442
 
2704
2474
//MSOOXML_EXPORT qreal ST_Percentage_withMsooxmlFix_to_double(const QString& val, bool& ok);
2705
2475
 
2706
2476
    //m_fillImageRenderingStyle = QLatin1String("stretch");
2707
 
    while (!atEnd()) {
2708
 
        readNext();
2709
 
        kDebug() << *this;
2710
 
        BREAK_IF_END_OF(CURRENT_EL);
2711
 
    }
 
2477
 
 
2478
    readNext();
2712
2479
    READ_EPILOGUE
2713
2480
}
2714
2481
 
2725
2492
 
2726
2493
 Parent elements:
2727
2494
 - [done] anchor (§20.4.2.3)
2728
 
 - graphicFrame (§21.3.2.12)
2729
 
 - graphicFrame (§20.1.2.2.18)
2730
 
 - graphicFrame (§20.5.2.16)
2731
 
 - graphicFrame (§19.3.1.21)
 
2495
 - [done] graphicFrame (§21.3.2.12)
 
2496
 - [done] graphicFrame (§20.1.2.2.18)
 
2497
 - [done] graphicFrame (§20.5.2.16)
 
2498
 - [done] graphicFrame (§19.3.1.21)
2732
2499
 - [done] inline (§20.4.2.8)
2733
2500
 
2734
2501
 Child elements:
2845
2612
//! @todo support all elements
2846
2613
KoFilter::ConversionStatus MSOOXML_CURRENT_CLASS::read_blipFill(blipFillCaller caller)
2847
2614
{
2848
 
    kDebug() << "Caller:" << (char)caller;
 
2615
    kDebug() << "Blip Caller:" << (char)caller;
2849
2616
    // we do not use READ_PROLOGUE because namespace depends on caller here
2850
2617
    PUSH_NAME_INTERNAL
2851
2618
    QString ns;
3022
2789
 
3023
2790
#ifdef PPTXXMLSLIDEREADER_CPP
3024
2791
    inheritListStyles();
3025
 
    // Only slidemaster needs to inherit, this because first there is bodyStyle,
3026
 
    // then there can be a body frame, the frame must have properties from bodyStyle and it must not
3027
 
    // overwrite them, where as in case of slide/slideLayout there is no style in their files
3028
 
    // Note also that we do not inherit defaultStyles, we only save the changes that this lvl creates
3029
 
    // Default styles are used when we actually create the content
3030
 
    if (m_context->type == SlideMaster) {
 
2792
    if (m_context->type == SlideMaster || m_context->type == SlideLayout) {
3031
2793
        inheritAllTextAndParagraphStyles();
3032
2794
    }
3033
2795
#endif
3151
2913
 
3152
2914
 Child elements:
3153
2915
 - hslClr (Hue, Saturation, Luminance Color Model) §20.1.2.3.13
3154
 
 - prstClr (Preset Color) §20.1.2.3.22
 
2916
 - [done] prstClr (Preset Color) §20.1.2.3.22
3155
2917
 - [done] schemeClr (Scheme Color) §20.1.2.3.29
3156
2918
 - [done] scrgbClr (RGB Color Model - Percentage Variant) §20.1.2.3.30
3157
2919
 - [done] srgbClr (RGB Color Model - Hex Variant) §20.1.2.3.32
3170
2932
            ELSE_TRY_READ_IF(scrgbClr)
3171
2933
            ELSE_TRY_READ_IF(srgbClr)
3172
2934
            ELSE_TRY_READ_IF(sysClr)
 
2935
            ELSE_TRY_READ_IF(prstClr)
3173
2936
//! @todo add ELSE_WRONG_FORMAT
3174
2937
        }
3175
2938
    }
3224
2987
 
3225
2988
 Child elements:
3226
2989
    - hslClr (Hue, Saturation, Luminance Color Model) §20.1.2.3.13
3227
 
    - prstClr (Preset Color) §20.1.2.3.22
 
2990
    - [done] prstClr (Preset Color) §20.1.2.3.22
3228
2991
    - [done] schemeClr (Scheme Color) §20.1.2.3.29
3229
2992
    - [done] scrgbClr (RGB Color Model - Percentage Variant) §20.1.2.3.30
3230
2993
    - [done] srgbClr (RGB Color Model - Hex Variant) §20.1.2.3.32
3244
3007
        kDebug() << *this;
3245
3008
        BREAK_IF_END_OF(CURRENT_EL);
3246
3009
        if (isStartElement()) {
3247
 
            //scheme color
3248
3010
            TRY_READ_IF(schemeClr)
3249
 
//             rgb percentage
3250
3011
            ELSE_TRY_READ_IF(scrgbClr)
3251
3012
            //TODO hslClr hue, saturation, luminecence color
3252
 
            //TODO prstClr preset color
3253
3013
            ELSE_TRY_READ_IF(srgbClr)
3254
3014
            ELSE_TRY_READ_IF(sysClr)
3255
 
            //TODO stsClr system color
 
3015
            ELSE_TRY_READ_IF(prstClr)
3256
3016
//! @todo add ELSE_WRONG_FORMAT
3257
3017
        }
3258
3018
    }
3415
3175
 
3416
3176
 Child Elements:
3417
3177
 - hslClr (Hue, Saturation, Luminance Color Model) §20.1.2.3.13
3418
 
 - prstClr (Preset Color) §20.1.2.3.22
 
3178
 - [done] prstClr (Preset Color) §20.1.2.3.22
3419
3179
 - [done] schemeClr (Scheme Color) §20.1.2.3.29
3420
3180
 - [done] scrgbClr (RGB Color Model - Percentage Variant) §20.1.2.3.30
3421
3181
 - [done] srgbClr (RGB Color Model - Hex Variant) §20.1.2.3.32
3438
3198
            ELSE_TRY_READ_IF(srgbClr)
3439
3199
            ELSE_TRY_READ_IF(sysClr)
3440
3200
            ELSE_TRY_READ_IF(scrgbClr)
 
3201
            ELSE_TRY_READ_IF(prstClr)
3441
3202
        }
3442
3203
    }
3443
3204
    READ_EPILOGUE
3967
3728
}
3968
3729
 
3969
3730
#undef CURRENT_EL
 
3731
#define CURRENT_EL extLst
 
3732
KoFilter::ConversionStatus MSOOXML_CURRENT_CLASS::read_extLst()
 
3733
{
 
3734
    READ_PROLOGUE
 
3735
    // This element can contain all kinds of extensions, but we do not support any of them
 
3736
    // atm, and therefore skip it, reading this element however is needed in order to not
 
3737
    // read elements indside of this elemetn by accident
 
3738
    skipCurrentElement();
 
3739
 
 
3740
    READ_EPILOGUE
 
3741
}
 
3742
 
 
3743
#undef CURRENT_EL
3970
3744
#define CURRENT_EL scrgbClr
3971
3745
//! RGB Color Model - Percentage Variant
3972
3746
//! DrawingML ECMA-376 20.1.2.3.30, p. 3074.
4018
3792
    READ_ATTR_WITHOUT_NS(g)
4019
3793
    READ_ATTR_WITHOUT_NS(b)
4020
3794
 
4021
 
    bool okR;
4022
 
    bool okG;
4023
 
    bool okB;
 
3795
    bool okR, okG, okB;
4024
3796
 
4025
3797
    m_currentColor = QColor::fromRgbF(qreal(MSOOXML::Utils::ST_Percentage_to_double(r, okR)),
4026
3798
                                      qreal(MSOOXML::Utils::ST_Percentage_to_double(g, okG)),
4113
3885
}
4114
3886
 
4115
3887
#undef CURRENT_EL
 
3888
#define CURRENT_EL prstClr
 
3889
//! prstClr (preset color)
 
3890
KoFilter::ConversionStatus MSOOXML_CURRENT_CLASS::read_prstClr()
 
3891
{
 
3892
    READ_PROLOGUE
 
3893
    const QXmlStreamAttributes attrs(attributes());
 
3894
 
 
3895
    TRY_READ_ATTR_WITHOUT_NS(val)
 
3896
 
 
3897
    // TODO support all of them..
 
3898
    if (!val.isEmpty()) {
 
3899
        if (val == "aliceBlue") {
 
3900
            m_currentColor = QColor(240, 248, 255);
 
3901
        }
 
3902
        else if (val == "antiqueWhite") {
 
3903
            m_currentColor = QColor(250, 235, 215);
 
3904
        }
 
3905
        else if (val == "black") {
 
3906
            m_currentColor = QColor(0, 0, 0);
 
3907
        }
 
3908
        else if (val == "blue") {
 
3909
            m_currentColor = QColor(0, 0, 215);
 
3910
        }
 
3911
        else if (val == "green") {
 
3912
            m_currentColor = QColor(0, 255, 0);
 
3913
        }
 
3914
        else if (val == "red") {
 
3915
            m_currentColor = QColor(255, 0, 0);
 
3916
        }
 
3917
        else if (val == "violet") {
 
3918
            m_currentColor = QColor(238, 130, 238);
 
3919
        }
 
3920
        else if (val == "wheat") {
 
3921
            m_currentColor = QColor(245, 222, 179);
 
3922
        }
 
3923
        else if (val == "white") {
 
3924
            m_currentColor = QColor(255, 255, 255);
 
3925
        }
 
3926
        else if (val == "whiteSmoke") {
 
3927
            m_currentColor = QColor(245, 245, 245);
 
3928
        }
 
3929
        else if (val == "yellow") {
 
3930
            m_currentColor = QColor(255, 255, 0);
 
3931
        }
 
3932
        else if (val == "yellowGreen") {
 
3933
            m_currentColor = QColor(154, 205, 50);
 
3934
        }
 
3935
    }
 
3936
 
 
3937
    //TODO: all the color transformations
 
3938
    while (true) {
 
3939
        readNext();
 
3940
        BREAK_IF_END_OF(CURRENT_EL);
 
3941
        if (isStartElement()) {
 
3942
            TRY_READ_IF(tint)
 
3943
            ELSE_TRY_READ_IF(shade)
 
3944
            ELSE_TRY_READ_IF(satMod)
 
3945
            ELSE_TRY_READ_IF(alpha)
 
3946
        }
 
3947
    }
 
3948
 
 
3949
    MSOOXML::Utils::modifyColor(m_currentColor, m_currentTint, m_currentShadeLevel, m_currentSatMod);
 
3950
 
 
3951
    READ_EPILOGUE
 
3952
}
 
3953
 
 
3954
#undef CURRENT_EL
4116
3955
#define CURRENT_EL sysClr
4117
3956
//! sysClr handler
4118
3957
// SysClr is bit controversial, it is supposed to use
4165
4004
    // Number 3 makes eg. lvl4 -> 4
4166
4005
    m_currentListLevel = QString(level.at(3)).toInt();
4167
4006
 
 
4007
    m_currentBulletProperties = m_currentCombinedBulletProperties[m_currentListLevel];
 
4008
 
4168
4009
    Q_ASSERT(m_currentListLevel > 0);
4169
4010
    m_currentBulletProperties.m_level = m_currentListLevel;
4170
4011
 
4176
4017
    bool ok = false;
4177
4018
 
4178
4019
    m_currentParagraphStyle = KoGenStyle(KoGenStyle::ParagraphAutoStyle, "text");
 
4020
    m_currentTextStyle = KoGenStyle(KoGenStyle::TextAutoStyle, "text");
 
4021
 
 
4022
#ifdef PPTXXMLSLIDEREADER_CPP
 
4023
    inheritDefaultTextStyle(m_currentTextStyle);
 
4024
    inheritTextStyle(m_currentTextStyle);
 
4025
#endif
4179
4026
 
4180
4027
    if (!marR.isEmpty()) {
4181
4028
        const qreal marginal = qreal(EMU_TO_POINT(marR.toDouble(&ok)));
4197
4044
    TRY_READ_ATTR_WITHOUT_NS(algn)
4198
4045
    algnToODF("fo:text-align", algn);
4199
4046
 
4200
 
    m_currentTextStyle = KoGenStyle(KoGenStyle::TextAutoStyle, "text");
4201
 
 
4202
4047
    while (!atEnd()) {
4203
4048
        readNext();
4204
4049
        kDebug() << *this;
4213
4058
            ELSE_TRY_READ_IF(buFont)
4214
4059
            ELSE_TRY_READ_IF(buBlip)
4215
4060
            ELSE_TRY_READ_IF(buClr)
 
4061
            ELSE_TRY_READ_IF(buSzPct)
4216
4062
            else if (QUALIFIED_NAME_IS(spcBef)) {
4217
4063
                m_currentSpacingType = spacingMarginTop;
4218
4064
                TRY_READ(spcBef)
4270
4116
  - [done] buFont (Specified)                   §21.1.2.4.6
4271
4117
  - buFontTx (Follow text)               §21.1.2.4.7
4272
4118
  - [done] buNone (No Bullet)                   §21.1.2.4.8
4273
 
  - buSzPct (Bullet Size Percentage)     §21.1.2.4.9
 
4119
  - [done] buSzPct (Bullet Size Percentage)     §21.1.2.4.9
4274
4120
  - buSzPts (Bullet Size Points)         §21.1.2.4.10
4275
4121
  - buSzTx (Bullet Size Follows Text)    §21.1.2.4.11
4276
4122
  - [done] defRPr (Default Text Run Properties) §21.1.2.3.2
4301
4147
 
4302
4148
#undef CURRENT_EL
4303
4149
#define CURRENT_EL lvl3pPr
4304
 
//! Look for lvl1pPr documentation  
 
4150
//! Look for lvl1pPr documentation
4305
4151
KoFilter::ConversionStatus MSOOXML_CURRENT_CLASS::read_lvl3pPr()
4306
4152
{
4307
4153
    READ_PROLOGUE
4407
4253
 
4408
4254
    if (!m_xlinkHref.isEmpty()) {
4409
4255
        m_currentBulletProperties.setPicturePath(m_xlinkHref);
4410
 
        m_currentBulletProperties.setPictureSize(m_imageSize);
 
4256
        m_currentBulletProperties.setBulletSize(m_imageSize);
4411
4257
        m_listStylePropertiesAltered = true;
4412
4258
    }
4413
4259
 
 
4260
    m_xlinkHref.clear();
 
4261
 
4414
4262
    READ_EPILOGUE
4415
4263
}
4416
4264
 
4467
4315
 
4468
4316
 Child elements:
4469
4317
 - hslClr (Hue, Saturation, Luminance Color Model) §20.1.2.3.13
4470
 
 - prstClr (Preset Color) §20.1.2.3.22
 
4318
 - [done] prstClr (Preset Color) §20.1.2.3.22
4471
4319
 - [done]schemeClr (Scheme Color) §20.1.2.3.29
4472
4320
 - [done] scrgbClr (RGB Color Model - Percentage Variant) §20.1.2.3.30
4473
4321
 - [done]srgbClr (RGB Color Model - Hex Variant) §20.1.2.3.32
4489
4337
            ELSE_TRY_READ_IF(schemeClr)
4490
4338
            ELSE_TRY_READ_IF(scrgbClr)
4491
4339
            ELSE_TRY_READ_IF(sysClr)
 
4340
            ELSE_TRY_READ_IF(prstClr)
4492
4341
        }
4493
4342
    }
4494
4343
    if (m_currentColor.isValid()) {
4501
4350
}
4502
4351
 
4503
4352
#undef CURRENT_EL
 
4353
#define CURRENT_EL buSzPct
 
4354
//! buSzPct - bullet size
 
4355
/*!
 
4356
 Parent elements:
 
4357
 - defPPr  (§21.1.2.2.2)
 
4358
 - [done] lvl1pPr (§21.1.2.4.13)
 
4359
 - [done] lvl2pPr (§21.1.2.4.14)
 
4360
 - [done] lvl3pPr (§21.1.2.4.15)
 
4361
 - [done] lvl4pPr (§21.1.2.4.16)
 
4362
 - [done] lvl5pPr (§21.1.2.4.17)
 
4363
 - [done] lvl6pPr (§21.1.2.4.18)
 
4364
 - [done] lvl7pPr (§21.1.2.4.19)
 
4365
 - [done] lvl8pPr (§21.1.2.4.20)
 
4366
 - [done] lvl9pPr (§21.1.2.4.21)
 
4367
 - [done] pPr (§21.1.2.2.7)
 
4368
 
 
4369
 Child elements:
 
4370
 - none
 
4371
*/
 
4372
KoFilter::ConversionStatus MSOOXML_CURRENT_CLASS::read_buSzPct()
 
4373
{
 
4374
    READ_PROLOGUE
 
4375
    const QXmlStreamAttributes attrs(attributes());
 
4376
    TRY_READ_ATTR_WITHOUT_NS(val)
 
4377
 
 
4378
    if (!val.isEmpty()) {
 
4379
        // As percentage
 
4380
        m_currentBulletProperties.setBulletRelativeSize(val.toInt()/1000);
 
4381
    }
 
4382
 
 
4383
    readNext();
 
4384
    READ_EPILOGUE
 
4385
}
 
4386
 
 
4387
#undef CURRENT_EL
4504
4388
#define CURRENT_EL buFont
4505
4389
//! buFont - bullet font
4506
4390
/*!
4701
4585
 Parent elements:
4702
4586
 
4703
4587
 - defPPr (§21.1.2.2.2)
4704
 
 - lvl1pPr (§21.1.2.4.13)
4705
 
 - lvl2pPr (§21.1.2.4.14)
4706
 
 - lvl3pPr (§21.1.2.4.15)
4707
 
 - lvl4pPr (§21.1.2.4.16)
4708
 
 - lvl5pPr (§21.1.2.4.17)
4709
 
 - lvl6pPr (§21.1.2.4.18)
4710
 
 - lvl7pPr (§21.1.2.4.19)
4711
 
 - lvl8pPr (§21.1.2.4.20)
4712
 
 - lvl9pPr (§21.1.2.4.21)
 
4588
 - [done] lvl1pPr (§21.1.2.4.13)
 
4589
 - [done] lvl2pPr (§21.1.2.4.14)
 
4590
 - [done] lvl3pPr (§21.1.2.4.15)
 
4591
 - [done] lvl4pPr (§21.1.2.4.16)
 
4592
 - [done] lvl5pPr (§21.1.2.4.17)
 
4593
 - [done] lvl6pPr (§21.1.2.4.18)
 
4594
 - [done] lvl7pPr (§21.1.2.4.19)
 
4595
 - [done] lvl8pPr (§21.1.2.4.20)
 
4596
 - [done] lvl9pPr (§21.1.2.4.21)
4713
4597
 - [done] pPr (§21.1.2.2.7)
4714
4598
 
4715
4599
 Child elements:
4909
4793
 
4910
4794
    TRY_READ_ATTR_WITHOUT_NS(startAt)
4911
4795
    if (!startAt.isEmpty()) {
4912
 
        m_currentBulletProperties.m_startValue = startAt.toInt();
 
4796
        m_currentBulletProperties.setStartValue(startAt);
4913
4797
    }
4914
4798
 
4915
4799
    m_listStylePropertiesAltered = true;
4948
4832
     - highlight (Highlight Color)                     §21.1.2.3.4
4949
4833
     - hlinkClick (Click Hyperlink)                    §21.1.2.3.5
4950
4834
     - hlinkMouseOver (Mouse-Over Hyperlink)           §21.1.2.3.6
4951
 
     - latin (Latin Font)                              §21.1.2.3.7
 
4835
     - [done] latin (Latin Font)                              §21.1.2.3.7
4952
4836
     - ln (Outline)                                    §20.1.2.2.24
4953
4837
     - noFill (No Fill)                                §20.1.8.44
4954
4838
     - pattFill (Pattern Fill)                         §20.1.8.47
5069
4953
 - flatTx (No text in 3D scene) §20.1.5.8
5070
4954
 - noAutofit (No AutoFit) §21.1.2.1.2
5071
4955
 - [done] normAutofit (Normal AutoFit) §21.1.2.1.3
5072
 
 - prstTxWarp (Preset Text Warp) §20.1.9.19
 
4956
 - [done] prstTxWarp (Preset Text Warp) §20.1.9.19
5073
4957
 - scene3d (3D Scene Properties) §20.1.4.1.26
5074
4958
 - sp3d (Apply 3D shape properties) §20.1.5.12
5075
4959
 - [done] spAutoFit (Shape AutoFit) §21.1.2.1.4
5103
4987
    m_shapeTextLeftOff.clear();
5104
4988
    m_shapeTextRightOff.clear();
5105
4989
 
5106
 
#ifdef PPTXXMLSLIDEREADER_CPP
5107
 
    inheritBodyProperties();
5108
 
#endif
 
4990
    m_normAutoFit =  MSOOXML::Utils::autoFitUnUsed;
5109
4991
 
5110
4992
    if (!lIns.isEmpty()) {
5111
4993
        m_shapeTextLeftOff = lIns;
5138
5020
//! @todo more atributes
5139
5021
 
5140
5022
    bool spAutoFit = false;
5141
 
    bool normAutoFit = false;
5142
5023
    while (!atEnd()) {
5143
5024
        readNext();
5144
5025
        BREAK_IF_END_OF(CURRENT_EL);
5146
5027
            if (qualifiedName() == QLatin1String("a:spAutoFit")) {
5147
5028
                TRY_READ(spAutoFit)
5148
5029
                spAutoFit = true;
 
5030
                m_normAutoFit = MSOOXML::Utils::autoFitOn;
5149
5031
            }
5150
5032
            else if (qualifiedName() == QLatin1String("a:normAutofit")) {
5151
 
                normAutoFit = true;
 
5033
                m_normAutoFit = MSOOXML::Utils::autoFitOn;
 
5034
            }
 
5035
            else if (qualifiedName() == QLatin1String("a:prstTxWarp")) {
 
5036
                // The handling here is not correct but better than nothing
 
5037
                // Also normAutoFit = true seems to be correct for value 'textNoShape'
 
5038
                m_normAutoFit = MSOOXML::Utils::autoFitOn;
5152
5039
            }
5153
5040
        }
5154
5041
    }
5155
5042
 
5156
5043
#ifdef PPTXXMLSLIDEREADER_CPP
5157
 
 
5158
5044
    saveBodyProperties();
5159
5045
 
5160
5046
    m_currentPresentationStyle.addProperty("draw:auto-grow-height",
5165
5051
    // text in shape
5166
5052
    m_currentPresentationStyle.addProperty("fo:wrap-option",
5167
5053
        wrap == QLatin1String("none") ? QLatin1String("no-wrap") : QLatin1String("wrap"), KoGenStyle::GraphicType);
5168
 
    if (normAutoFit) {
5169
 
        m_currentPresentationStyle.addProperty("draw:fit-to-size", "true", KoGenStyle::GraphicType);
5170
 
    }
5171
5054
#endif
5172
5055
    READ_EPILOGUE
5173
5056
}
5189
5072
KoFilter::ConversionStatus MSOOXML_CURRENT_CLASS::read_spAutoFit()
5190
5073
{
5191
5074
    READ_PROLOGUE
5192
 
    skipCurrentElement();
 
5075
    readNext();
5193
5076
    READ_EPILOGUE
5194
5077
}
5195
5078
 
5215
5098
    m_currentListLevel = 0;
5216
5099
    m_pPr_lvl = 0;
5217
5100
 
5218
 
    MSOOXML::Utils::XmlWriteBuffer listBuf;
5219
 
    body = listBuf.setWriter(body);
5220
 
 
5221
5101
    while (!atEnd()) {
5222
5102
        readNext();
5223
5103
        kDebug() << *this;
5231
5111
//! @todo add ELSE_WRONG_FORMAT
5232
5112
        }
5233
5113
    }
5234
 
 
5235
5114
    if (m_prevListLevel > 0) {
5236
5115
        // Ending our current level
5237
5116
        body->endElement(); // text:list