xmloff/qa/unit/data/tdf149551_verticalText.pptx |binary
 xmloff/qa/unit/draw.cxx                         |   32 ++++++++++++++++++++++++
 xmloff/source/draw/shapeexport.cxx              |   18 +++++++------
 3 files changed, 42 insertions(+), 8 deletions(-)

New commits:
commit aca189d118d4351b293c089cb26584eb898e1849
Author:     Regina Henschel <[email protected]>
AuthorDate: Wed Jun 15 13:15:15 2022 +0200
Commit:     Regina Henschel <[email protected]>
CommitDate: Thu Jun 16 00:57:51 2022 +0200

    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 <[email protected]>

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
Binary files /dev/null and b/xmloff/qa/unit/data/tdf149551_verticalText.pptx 
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

Reply via email to