xmloff/source/draw/animationexport.cxx |   34 +++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)

New commits:
commit dc9bcbd50f79811787202429b49fe855c2d643be
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Sun Apr 6 16:45:40 2025 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Sun Apr 6 20:36:09 2025 +0200

    crashtesting: unable to reimport odp export of fdo72444-1.pptx
    
    There is a smil:values / smil:keyTimes count mismatch where the original
    pppx has: <p:tavLst><p:tav tm="0"><p:val></p:val></p:tav> so p:val is
    present but empty which results in an empty Any so the matching
    smil:values at export of the odp is empty while a smil:keyValues is
    exported, resulting in AnimationNodeContext::init_node throwing
    css::io::WrongFormatException from the mismatch of
    xAnimate->getValues().getLength() != xAnimate->getKeyTimes().getLength()
    
    exporting to pptx and then converting that to odp just drops the
    smil:values + smil:keyTimes, so solve this by only exporting
    smil:keyTimes if there was a successful export of smil:values.
    
    Change-Id: I5577a6671bfcebecf995afeea90e2d701f33eab1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183761
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Tested-by: Jenkins

diff --git a/xmloff/source/draw/animationexport.cxx 
b/xmloff/source/draw/animationexport.cxx
index 64fee6b8ef4c..d8171be53b53 100644
--- a/xmloff/source/draw/animationexport.cxx
+++ b/xmloff/source/draw/animationexport.cxx
@@ -441,7 +441,7 @@ public:
     static Reference< XInterface > getParagraphTarget( const ParagraphTarget& 
pTarget );
 
     static void convertPath( OUStringBuffer& sTmp, const Any& rPath );
-    void convertValue( XMLTokenEnum eAttributeName, OUStringBuffer& sTmp, 
const Any& rValue ) const;
+    bool convertValue( XMLTokenEnum eAttributeName, OUStringBuffer& sTmp, 
const Any& rValue ) const;
     void convertTiming( OUStringBuffer& sTmp, const Any& rTiming ) const;
     void convertTarget( OUStringBuffer& sTmp, const Any& rTarget ) const;
 
@@ -1123,12 +1123,15 @@ void AnimationsExporterImpl::exportAnimate( const 
Reference< XAnimate >& xAnimat
             }
         }
 
+        bool bExportedValues = false;
         Sequence< Any > aValues( xAnimate->getValues() );
         if( aValues.hasElements() )
         {
             aTemp <<= aValues;
-            convertValue( eAttributeName, sTmp, aTemp );
-            mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_VALUES, 
sTmp.makeStringAndClear() );
+            bExportedValues = convertValue(eAttributeName, sTmp, aTemp);
+            SAL_WARN_IF(!bExportedValues, "xmloff", "exportAnimate(), unable 
to export smil:values");
+            if (bExportedValues)
+                mxExport->AddAttribute(XML_NAMESPACE_SMIL, XML_VALUES, 
sTmp.makeStringAndClear());
         }
         else
         {
@@ -1157,7 +1160,8 @@ void AnimationsExporterImpl::exportAnimate( const 
Reference< XAnimate >& xAnimat
         if(nNodeType != AnimationNodeType::SET)
         {
             const Sequence< double > aKeyTimes( xAnimate->getKeyTimes() );
-            if( aKeyTimes.hasElements() )
+            SAL_WARN_IF(aKeyTimes.hasElements() && !bExportedValues, "xmloff", 
"exportAnimate() no smil:values exported so skipping smil:keyTimes");
+            if (aKeyTimes.hasElements() && bExportedValues)
             {
                 for( const auto& rKeyTime : aKeyTimes )
                 {
@@ -1457,17 +1461,18 @@ void AnimationsExporterImpl::convertPath( 
OUStringBuffer& sTmp, const Any& rPath
     sTmp = aStr;
 }
 
-void AnimationsExporterImpl::convertValue( XMLTokenEnum eAttributeName, 
OUStringBuffer& sTmp, const Any& rValue ) const
+bool AnimationsExporterImpl::convertValue( XMLTokenEnum eAttributeName, 
OUStringBuffer& sTmp, const Any& rValue ) const
 {
     if( !rValue.hasValue() )
-        return;
+        return false;
 
+    bool bSuccess = true;
     if( auto pValuePair = o3tl::tryAccess<ValuePair>(rValue) )
     {
         OUStringBuffer sTmp2;
-        convertValue( eAttributeName, sTmp, pValuePair->First );
+        bSuccess &= convertValue( eAttributeName, sTmp, pValuePair->First );
         sTmp.append( ',' );
-        convertValue( eAttributeName, sTmp2, pValuePair->Second );
+        bSuccess &= convertValue( eAttributeName, sTmp2, pValuePair->Second );
         sTmp.append( sTmp2 );
     }
     else if( auto pSequence = o3tl::tryAccess<Sequence<Any>>(rValue) )
@@ -1482,7 +1487,7 @@ void AnimationsExporterImpl::convertValue( XMLTokenEnum 
eAttributeName, OUString
         {
             if( !sTmp.isEmpty() )
                 sTmp.append( ';' );
-            convertValue( eAttributeName, sTmp2, *pAny );
+            bSuccess &= convertValue( eAttributeName, sTmp2, *pAny );
             sTmp.append( sTmp2 );
             sTmp2.setLength(0);
         }
@@ -1512,8 +1517,9 @@ void AnimationsExporterImpl::convertValue( XMLTokenEnum 
eAttributeName, OUString
             else
             {
                 OSL_FAIL( "xmloff::AnimationsExporterImpl::convertValue(), 
invalid value type!" );
+                bSuccess = false;
             }
-            return;
+            return bSuccess;
         }
 
         case XML_SKEWX:
@@ -1539,13 +1545,17 @@ void AnimationsExporterImpl::convertValue( XMLTokenEnum 
eAttributeName, OUString
 
         //const XMLPropertyHandler* pHandler = 
static_cast<SdXMLExport*>(&mrExport)->GetSdPropHdlFactory()->GetPropertyHandler(
 nType );
         const XMLPropertyHandler* pHandler = 
mxSdPropHdlFactory->GetPropertyHandler( nType );
-        if( pHandler )
+        if (!pHandler)
+            bSuccess = false;
+        else
         {
             OUString aString;
-            pHandler->exportXML( aString, rValue, 
mxExport->GetMM100UnitConverter() );
+            bSuccess = pHandler->exportXML( aString, rValue, 
mxExport->GetMM100UnitConverter() );
             sTmp.append( aString );
         }
     }
+
+    return bSuccess;
 }
 
 void AnimationsExporterImpl::convertTiming( OUStringBuffer& sTmp, const Any& 
rValue ) const

Reply via email to