summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-01-07 11:29:33 +0100
committerLuboš Luňák <l.lunak@collabora.com>2022-01-09 15:43:22 +0100
commit74a37dce322d56251edfa49e7b98a2195f8c8e45 (patch)
tree60412ef68dc590345969d21e3171a72bf89fecd6 /svx
parentafda77cd6565e53a356c0b0be93d708808079e49 (diff)
make SdrCustomShapeGeometryItem internal data consistent
The PutValue() function didn't update the property map properly the same way the constructor and other functions do. Change-Id: I107f7095077d888cd9701d87a6e536339b0257b1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128104 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/items/customshapeitem.cxx66
1 files changed, 31 insertions, 35 deletions
diff --git a/svx/source/items/customshapeitem.cxx b/svx/source/items/customshapeitem.cxx
index d4e164ff5c88..733b30f29e47 100644
--- a/svx/source/items/customshapeitem.cxx
+++ b/svx/source/items/customshapeitem.cxx
@@ -35,30 +35,7 @@ SdrCustomShapeGeometryItem::SdrCustomShapeGeometryItem()
SdrCustomShapeGeometryItem::SdrCustomShapeGeometryItem( const uno::Sequence< beans::PropertyValue >& rVal )
: SfxPoolItem( SDRATTR_CUSTOMSHAPE_GEOMETRY )
{
- sal_Int32 i, j;
- aPropSeq = rVal;
-
- for ( i = 0; i < aPropSeq.getLength(); i++ )
- {
- const beans::PropertyValue& rPropVal = aPropSeq[ i ];
- std::pair<PropertyHashMap::iterator, bool> const ret(
- aPropHashMap.insert(std::make_pair(rPropVal.Name, i)));
- assert(ret.second); // serious bug: duplicate xml attribute exported
- if (!ret.second)
- {
- throw uno::RuntimeException(
- "CustomShapeGeometry has duplicate property " + rPropVal.Name);
- }
- if (auto rPropSeq = o3tl::tryAccess<uno::Sequence<beans::PropertyValue>>(
- rPropVal.Value))
- {
- for ( j = 0; j < rPropSeq->getLength(); j++ )
- {
- beans::PropertyValue const & rPropVal2 = (*rPropSeq)[ j ];
- aPropPairHashMap[ PropertyPair( rPropVal.Name, rPropVal2.Name ) ] = j;
- }
- }
- }
+ SetPropSeq( rVal );
}
css::uno::Any* SdrCustomShapeGeometryItem::GetPropertyValueByName( const OUString& rPropName )
@@ -275,24 +252,43 @@ bool SdrCustomShapeGeometryItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMember
bool SdrCustomShapeGeometryItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
{
- if ( ! ( rVal >>= aPropSeq ) )
+ css::uno::Sequence< css::beans::PropertyValue > propSeq;
+ if ( ! ( rVal >>= propSeq ) )
return false;
- for (sal_Int32 i = 0; i < aPropSeq.getLength(); ++i)
+ SetPropSeq( propSeq );
+ return true;
+}
+
+void SdrCustomShapeGeometryItem::SetPropSeq( const css::uno::Sequence< css::beans::PropertyValue >& rVal )
+{
+ if( aPropSeq == rVal )
+ return;
+
+ aPropSeq = rVal;
+ aPropHashMap.clear();
+ aPropPairHashMap.clear();
+ for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
{
- const auto& rName = aPropSeq[i].Name;
- bool isDuplicated = std::any_of(std::next(std::cbegin(aPropSeq), i + 1), std::cend(aPropSeq),
- [&rName](const css::beans::PropertyValue& rProp) { return rProp.Name == rName; });
- if (isDuplicated)
+ const beans::PropertyValue& rPropVal = aPropSeq[ i ];
+ std::pair<PropertyHashMap::iterator, bool> const ret(
+ aPropHashMap.insert(std::make_pair(rPropVal.Name, i)));
+ assert(ret.second); // serious bug: duplicate xml attribute exported
+ if (!ret.second)
{
- assert(false); // serious bug: duplicate xml attribute exported
- OUString const name(aPropSeq[i].Name);
- aPropSeq.realloc(0);
throw uno::RuntimeException(
- "CustomShapeGeometry has duplicate property " + name);
+ "CustomShapeGeometry has duplicate property " + rPropVal.Name);
+ }
+ if (auto rPropSeq = o3tl::tryAccess<uno::Sequence<beans::PropertyValue>>(
+ rPropVal.Value))
+ {
+ for ( sal_Int32 j = 0; j < rPropSeq->getLength(); j++ )
+ {
+ beans::PropertyValue const & rPropVal2 = (*rPropSeq)[ j ];
+ aPropPairHashMap[ PropertyPair( rPropVal.Name, rPropVal2.Name ) ] = j;
+ }
}
}
- return true;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */