summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2022-06-15 13:15:15 +0200
committerRegina Henschel <rb.henschel@t-online.de>2022-06-16 00:57:51 +0200
commitaca189d118d4351b293c089cb26584eb898e1849 (patch)
treeca05db5f69959247d4e7d92dfda7d4f8b91fa232 /xmloff
parent513ae848b668647093ae4161718b2585d80fdb7a (diff)
tdf#149551 write draw:text-rotate-angle only once
The attributes 'vert' and 'vert270' set property TextPreRotateAngle on import from OOXML. The property TextRotateAngle can be set by macro. Both were written to file as 'draw:text-rotate-angle' attribute. So we got a file format error 'duplicate attribute'. The values are now added and the sum is written. That gives the same rendering as after applying a macro. Using the sum is a workaround. We have currently no way to save the direction specified by 'vert' and 'vert270' as style:writing-mode to ODF. Change-Id: I93fd8ca42b82c1ed7f1bf6e33d932e5510615b2f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135901 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/qa/unit/data/tdf149551_verticalText.pptxbin0 -> 16078 bytes
-rw-r--r--xmloff/qa/unit/draw.cxx32
-rw-r--r--xmloff/source/draw/shapeexport.cxx18
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
new file mode 100644
index 000000000000..b142a2e83420
--- /dev/null
+++ b/xmloff/qa/unit/data/tdf149551_verticalText.pptx
Binary files differ
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