oox/source/drawingml/customshapeproperties.cxx |   20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)

New commits:
commit 8ae857370192e0b2490d88b54751641073ccee6f
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Fri Nov 5 15:14:11 2021 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Mon Nov 8 12:08:20 2021 +0100

    Drop code that modified type for no good reason
    
    The code was there at least since 3381981e76873304b171f7df900561dac681d2af.
    Alteady there it was wrong, relying on the order of the properties in the
    aGeoPropSeq: if "Type" appeared prior to "AdjustmentValues", the type name
    was changed by this code; otherwise, "AdjustmentValues" was modified, and
    the sequence set as xPropSet's "CustomShapeGeometry" value. Also the code
    relied on the detail discussed in fb3c04bd1930eedacd406874e1a285d62bbf27d9,
    and the "Type" was not updated when appeared after "AdjustmentValues" only
    because of accidental use of non-const operator[] in another place.
    
    Then in commits starting from 226ff96a88876d34f7fa30148150b6aa5a7f5a7c,
    a new code for presets, including their types, was introduced before the
    loop (see GetConnectorShapeType and maPresetDataMap uses). This presumably
    has obsoleted this code setting "Type" completely.
    
    This change drops this obsoleted code.
    It reverts part of commit fb3c04bd1930eedacd406874e1a285d62bbf27d9 in
    oox/source/drawingml/customshapeproperties.cxx.
    
    It is possible that we should write "ooxml-CustomShape" type in some cases
    when there's no type yet - but that should be done when the conditions for
    that are clear.
    
    Another possible TODO is to move the code defining "AdjustmentValues" up,
    set in in aPropertyMap before writing it into aPropSet.
    
    Change-Id: Ib22a838ca8008b181b3eee2dabdbbc14861a0f71
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124749
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/oox/source/drawingml/customshapeproperties.cxx 
b/oox/source/drawingml/customshapeproperties.cxx
index e1d32a992619..ac11d2d7eaa6 100644
--- a/oox/source/drawingml/customshapeproperties.cxx
+++ b/oox/source/drawingml/customshapeproperties.cxx
@@ -158,16 +158,12 @@ void CustomShapeProperties::pushToPropSet(
         {
             static const OUStringLiteral 
sCustomShapeGeometry(u"CustomShapeGeometry");
             static const OUStringLiteral 
sAdjustmentValues(u"AdjustmentValues");
-            static const OUStringLiteral sType = u"Type";
             uno::Any aGeoPropSet = xPropSet->getPropertyValue( 
sCustomShapeGeometry );
             uno::Sequence< beans::PropertyValue > aGeoPropSeq;
             if ( aGeoPropSet >>= aGeoPropSeq )
             {
-                // aGeoPropSeq gets modified in the loop, and gets copied 
elsewhere;
-                // don't use range-based for here
-                for ( sal_Int32 i = 0; i < aGeoPropSeq.getLength(); ++i )
+                for ( auto& rGeoProp : asNonConstRange(aGeoPropSeq) )
                 {
-                    const auto& rGeoProp = aGeoPropSeq[i];
                     if ( rGeoProp.Name == sAdjustmentValues )
                     {
                         uno::Sequence< 
css::drawing::EnhancedCustomShapeAdjustmentValue > aAdjustmentSeq;
@@ -200,21 +196,11 @@ void CustomShapeProperties::pushToPropSet(
                                     }
                                 }
                             }
-                            // getArray ensures COW here - there may be copies 
of aGeoPropSeq from
-                            // prior calls to xPropSet->setPropertyValue, so 
getArray can't be
-                            // moved out of the loop:
-                            aGeoPropSeq.getArray()[i].Value <<= aAdjustmentSeq;
+                            rGeoProp.Value <<= aAdjustmentSeq;
                             xPropSet->setPropertyValue( sCustomShapeGeometry, 
Any( aGeoPropSeq ) );
+                            break;
                         }
                     }
-                    else if ( rGeoProp.Name == sType )
-                    {
-                        // getArray ensures COW here - there may be copies of 
aGeoPropSeq:
-                        if ( sConnectorShapeType.getLength() > 0 )
-                            aGeoPropSeq.getArray()[i].Value <<= 
sConnectorShapeType;
-                        else
-                            aGeoPropSeq.getArray()[i].Value <<= OUString( 
"ooxml-CustomShape" );
-                    }
                 }
             }
         }

Reply via email to