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));
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));
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));
219
217
body->addAttribute("svg:x", EMU_TO_CM_STRING(m_svgX));
220
218
body->addAttribute("svg:y", EMU_TO_CM_STRING(m_svgY));
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;
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;
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;
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);
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);
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);
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);
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));
861
840
#warning TODO: docx
863
842
#endif // PPTXXMLSLIDEREADER_H
866
KoFilter::ConversionStatus MSOOXML_CURRENT_CLASS::generatePlaceHolderSp()
868
#ifdef PPTXXMLSLIDEREADER_CPP
869
const QString styleId(d->phStyleId());
871
kDebug() << "styleId:" << styleId << "d->phType:" << d->phType << "d->phIdx:" << d->phIdx;
873
if (m_context->type == SlideLayout) {
874
PptxShapeProperties* masterShapeProperties = 0;
875
if (!styleId.isEmpty()) {
876
masterShapeProperties = m_context->slideProperties->shapesMap.value(styleId);
878
else if (d->shapeNumber < (uint)m_context->slideProperties->shapes.count()) {
879
masterShapeProperties = m_context->slideProperties->shapes[d->shapeNumber];
881
kDebug() << "masterShapeProperties:" << masterShapeProperties;
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;
893
if (!d->phType.isEmpty()) {
894
m_context->slideLayoutProperties->shapesMap[d->phType] = m_currentShapeProperties;
896
if (!d->phIdx.isEmpty()) {
897
m_context->slideLayoutProperties->shapesMap[d->phIdx] = m_currentShapeProperties;
899
m_context->slideLayoutProperties->shapes.append(m_currentShapeProperties);
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;
906
if (!d->phIdx.isEmpty()) {
907
m_context->slideProperties->shapesMap[d->phIdx] = m_currentShapeProperties;
909
m_context->slideProperties->shapes.append(m_currentShapeProperties);
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;
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;
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;
933
else if (m_currentShapeProperties && m_currentShapeProperties->width >= 0) {
934
kDebug() << "copying geometry from master to placeholder";
935
placeholder = new PptxPlaceholder(*m_currentShapeProperties);
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;
943
kDebug() << "adding placeholder" << presentationObject << "phStyleId:" << phStyleId;
944
m_context->slideLayoutProperties->placeholders.insert(phStyleId, placeholder);
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));
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;
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);
964
m_placeholderElWriter->endElement();
969
#ifdef PPTXXMLSLIDEREADER_CPP
970
m_currentShapeProperties = 0; // Making sure that nothing uses them.
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
975
856
#undef CURRENT_EL
1007
m_outputDrawFrame = true;
888
body = drawFrameBuf.originalWriter();
892
(void)drawFrameBuf.releaseWriter();
893
body->endElement(); //draw:frame, //draw:line
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;
1019
if (m_outputDrawFrame) {
1020
body = drawFrameBuf.originalWriter();
1024
(void)drawFrameBuf.releaseWriter();
1025
body->endElement(); //draw:frame, //draw:line
1028
896
KoFilter::ConversionStatus stat = generatePlaceHolderSp();
1029
897
if (stat != KoFilter::OK) {
1033
902
popCurrentDrawStyle();
1110
m_outputDrawFrame = true;
980
body = drawFrameBuf.originalWriter();
984
(void)drawFrameBuf.releaseWriter();
985
body->endElement(); //draw:frame, //draw:line
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;
1122
if (m_outputDrawFrame) {
1123
body = drawFrameBuf.originalWriter();
1127
(void)drawFrameBuf.releaseWriter();
1128
body->endElement(); //draw:frame, //draw:line
1131
988
KoFilter::ConversionStatus stat = generatePlaceHolderSp();
1132
989
if (stat != KoFilter::OK) {
1136
994
popCurrentDrawStyle();
1272
#ifdef PPTXXMLSLIDEREADER_CPP
1273
const QString styleId(d->phStyleId());
1274
kDebug() << "styleId:" << styleId;
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);
1282
else if(d->shapeNumber >= 1 && d->shapeNumber <= (uint)m_context->slideLayoutProperties->shapes.count())
1284
props = m_context->slideLayoutProperties->shapes[d->shapeNumber - 1];
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);
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");
1297
m_svgWidth = props->width;
1298
m_svgHeight = props->height;
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;
1641
1470
m_previousListWasAltered = false;
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));
1644
1481
if (m_listStylePropertiesAltered) {
1482
m_currentListStyle = KoGenStyle(KoGenStyle::ListAutoStyle, "list");
1484
// For now we take a stand that any altered style makes its own list.
1485
m_currentBulletProperties.m_level = m_currentListLevel;
1487
m_currentListStyle.addChildElement("list-style-properties",
1488
m_currentBulletProperties.convertToListProperties());
1645
1489
m_previousListWasAltered = true;
2214
2041
//! @todo add ELSE_WRONG_FORMAT
2218
if (m_context->type == Slide) { // load values from master is needed
2220
m_svgX = m_currentShapeProperties->x;
2221
m_svgY = m_currentShapeProperties->y;
2222
kDebug() << "Inherited svg:x/y from master (m_currentShapeProperties)";
2225
m_svgWidth = m_currentShapeProperties->width;
2226
m_svgHeight = m_currentShapeProperties->y;
2227
kDebug() << "Inherited svg:width/height from master (m_currentShapeProperties)";
2230
#ifdef PPTXXMLSLIDEREADER_CPP
2231
if (m_context->type == SlideMaster) { // save
2233
raiseElNotFoundError("a:off");
2234
return KoFilter::WrongFormat;
2237
raiseElNotFoundError("a:ext");
2238
return KoFilter::WrongFormat;
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;
2251
2044
kDebug() << "svg:x" << m_svgX << "svg:y" << m_svgY << "svg:width" << m_svgWidth << "svg:height" << m_svgHeight << "rotation" << m_rot;
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:
2118
- [done] xfrm (§21.3.2.28)
2119
- [done] xfrm (§20.1.7.5)
2338
2120
- [done] xfrm (§20.1.7.6)
2121
- [done] xfrm (§20.5.2.36)
2122
- [done] xfrm (§19.3.1.53)
2342
2124
No child elements.
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.
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()
4115
3887
#undef CURRENT_EL
3888
#define CURRENT_EL prstClr
3889
//! prstClr (preset color)
3890
KoFilter::ConversionStatus MSOOXML_CURRENT_CLASS::read_prstClr()
3893
const QXmlStreamAttributes attrs(attributes());
3895
TRY_READ_ATTR_WITHOUT_NS(val)
3897
// TODO support all of them..
3898
if (!val.isEmpty()) {
3899
if (val == "aliceBlue") {
3900
m_currentColor = QColor(240, 248, 255);
3902
else if (val == "antiqueWhite") {
3903
m_currentColor = QColor(250, 235, 215);
3905
else if (val == "black") {
3906
m_currentColor = QColor(0, 0, 0);
3908
else if (val == "blue") {
3909
m_currentColor = QColor(0, 0, 215);
3911
else if (val == "green") {
3912
m_currentColor = QColor(0, 255, 0);
3914
else if (val == "red") {
3915
m_currentColor = QColor(255, 0, 0);
3917
else if (val == "violet") {
3918
m_currentColor = QColor(238, 130, 238);
3920
else if (val == "wheat") {
3921
m_currentColor = QColor(245, 222, 179);
3923
else if (val == "white") {
3924
m_currentColor = QColor(255, 255, 255);
3926
else if (val == "whiteSmoke") {
3927
m_currentColor = QColor(245, 245, 245);
3929
else if (val == "yellow") {
3930
m_currentColor = QColor(255, 255, 0);
3932
else if (val == "yellowGreen") {
3933
m_currentColor = QColor(154, 205, 50);
3937
//TODO: all the color transformations
3940
BREAK_IF_END_OF(CURRENT_EL);
3941
if (isStartElement()) {
3943
ELSE_TRY_READ_IF(shade)
3944
ELSE_TRY_READ_IF(satMod)
3945
ELSE_TRY_READ_IF(alpha)
3949
MSOOXML::Utils::modifyColor(m_currentColor, m_currentTint, m_currentShadeLevel, m_currentSatMod);
4116
3955
#define CURRENT_EL sysClr
4117
3956
//! sysClr handler
4118
3957
// SysClr is bit controversial, it is supposed to use
4503
4352
#undef CURRENT_EL
4353
#define CURRENT_EL buSzPct
4354
//! buSzPct - bullet size
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)
4372
KoFilter::ConversionStatus MSOOXML_CURRENT_CLASS::read_buSzPct()
4375
const QXmlStreamAttributes attrs(attributes());
4376
TRY_READ_ATTR_WITHOUT_NS(val)
4378
if (!val.isEmpty()) {
4380
m_currentBulletProperties.setBulletRelativeSize(val.toInt()/1000);
4504
4388
#define CURRENT_EL buFont
4505
4389
//! buFont - bullet font