diff options
-rw-r--r-- | xmloff/qa/unit/data/tdf149551_verticalText.pptx | bin | 0 -> 16078 bytes | |||
-rw-r--r-- | xmloff/qa/unit/draw.cxx | 32 | ||||
-rw-r--r-- | xmloff/source/draw/shapeexport.cxx | 18 |
3 files changed, 42 insertions, 8 deletions
diff --git a/xmloff/qa/unit/data/tdf149551_verticalText.pptx b/xmloff/qa/unit/data/tdf149551_verticalText.pptx Binary files differnew file mode 100644 index 000000000000..b142a2e83420 --- /dev/null +++ b/xmloff/qa/unit/data/tdf149551_verticalText.pptx diff --git a/xmloff/qa/unit/draw.cxx b/xmloff/qa/unit/draw.cxx index fdfc6e98aa02..e8462ccc6181 100644 --- a/xmloff/qa/unit/draw.cxx +++ b/xmloff/qa/unit/draw.cxx @@ -25,6 +25,8 @@ #include <com/sun/star/text/XTextRange.hpp> #include <com/sun/star/text/XTextTable.hpp> +#include <comphelper/propertyvalue.hxx> +#include <comphelper/sequence.hxx> #include <unotools/mediadescriptor.hxx> #include <unotools/tempfile.hxx> #include <unotools/ucbstreamhelper.hxx> @@ -501,6 +503,36 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTdf148714_CurvedArrowsOld) } } } + +CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTextRotationPlusPre) +{ + // import + getComponent() = loadFromDesktop(m_directories.getURLFromSrc(DATA_DIRECTORY) + + "tdf149551_verticalText.pptx", + "com.sun.star.presentation.PresentationDocument"); + // The file has a shape with attribute vert="vert" in <bodyPr> element. That generates a + // TextPreRotateAngle attribute in CustomShapeGeometry. + + // Add a TextRotateAngle attribute. + uno::Reference<drawing::XShape> xShape(getShape(0)); + uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aGeomSeq; + xShapeProps->getPropertyValue("CustomShapeGeometry") >>= aGeomSeq; + auto aGeomVec(comphelper::sequenceToContainer<std::vector<beans::PropertyValue>>(aGeomSeq)); + aGeomVec.push_back(comphelper::makePropertyValue("TextRotateAngle", sal_Int32(45))); + aGeomSeq = comphelper::containerToSequence(aGeomVec); + xShapeProps->setPropertyValue("CustomShapeGeometry", uno::Any(aGeomSeq)); + + // Save to ODF. Without the fix, a file format error was produced, because attribute + // draw:text-rotate-angle was written twice, one from TextPreRotateAngle and the other from + // TextRotateAngle. + utl::TempFile aTempFile; + // This should already catch the format error, but does not, see tdf#149567 + save("impress8", aTempFile); + // But reload catches it. + getComponent()->dispose(); + getComponent() = loadFromDesktop(aTempFile.GetURL()); +} CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx index 89eceb95982c..ebe9f7b4a71d 100644 --- a/xmloff/source/draw/shapeexport.cxx +++ b/xmloff/source/draw/shapeexport.cxx @@ -4226,6 +4226,7 @@ static void ImpExportEnhancedGeometry( SvXMLExport& rExport, const uno::Referenc OUString aStr; OUStringBuffer aStrBuffer; + double fTextRotateAngle(0.0); // sum TextRotateAngle and TextPreRotateAngle SvXMLUnitConverter& rUnitConverter = rExport.GetMM100UnitConverter(); uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); @@ -4280,14 +4281,9 @@ static void ImpExportEnhancedGeometry( SvXMLExport& rExport, const uno::Referenc case EAS_TextPreRotateAngle : case EAS_TextRotateAngle : { - double fTextRotateAngle = 0; - if ( ( rGeoProp.Value >>= fTextRotateAngle ) && fTextRotateAngle != 0 ) - { - ::sax::Converter::convertDouble( - aStrBuffer, fTextRotateAngle ); - aStr = aStrBuffer.makeStringAndClear(); - rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_TEXT_ROTATE_ANGLE, aStr ); - } + double fAngle = 0.0; + rGeoProp.Value >>= fAngle; + fTextRotateAngle += fAngle; } break; case EAS_Extrusion : @@ -4864,6 +4860,12 @@ static void ImpExportEnhancedGeometry( SvXMLExport& rExport, const uno::Referenc break; } } // for + if (fTextRotateAngle != 0) + { + ::sax::Converter::convertDouble( aStrBuffer, fTextRotateAngle ); + aStr = aStrBuffer.makeStringAndClear(); + rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_TEXT_ROTATE_ANGLE, aStr ); + } rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_TYPE, aCustomShapeType ); // adjustments |