Kaydet (Commit) d0014dae authored tarafından Radek Doulik's avatar Radek Doulik

better pptx custom shape presets import/export

 - sometimes we produced unreadable pptx document with custom shape presets
 - fixes part of n#760997
 - before we rely on simple rule that adjustments were named
   adj1, adj2, ... in case of multiple adjustments and named
   adj in case there was only one. there are few exceptions though,
   so now we use exact adjustment names defined in presetShapeDefinitions.xml
 - TODO: there still might be problem when exporting custom shapes, which
   didn't originated in pptx import

Change-Id: Ic9517a69145a295ba6f680ddc3cc30fc771db3fd
üst 1964eff6
...@@ -36,6 +36,11 @@ struct EnhancedCustomShapeAdjustmentValue ...@@ -36,6 +36,11 @@ struct EnhancedCustomShapeAdjustmentValue
/** /**
*/ */
::com::sun::star::beans::PropertyState State; ::com::sun::star::beans::PropertyState State;
/** optional name, used by pptx import/export for custom shape presets
*/
string Name;
}; };
......
...@@ -31,14 +31,17 @@ class ShapeCstar5 : public CustomShapeProvider ...@@ -31,14 +31,17 @@ class ShapeCstar5 : public CustomShapeProvider
{ {
Any aAny ((sal_Int32) 19098); Any aAny ((sal_Int32) 19098);
aAdjSequence [0].Value = aAny; aAdjSequence [0].Value = aAny;
aAdjSequence [0].Name = CREATE_OUSTRING ("adj");
} }
{ {
Any aAny ((sal_Int32) 105146); Any aAny ((sal_Int32) 105146);
aAdjSequence [1].Value = aAny; aAdjSequence [1].Value = aAny;
aAdjSequence [1].Name = CREATE_OUSTRING ("hf");
} }
{ {
Any aAny ((sal_Int32) 110557); Any aAny ((sal_Int32) 110557);
aAdjSequence [2].Value = aAny; aAdjSequence [2].Value = aAny;
aAdjSequence [2].Name = CREATE_OUSTRING ("vf");
} }
aPropertyMap [PROP_AdjustmentValues] <<= aAdjSequence; aPropertyMap [PROP_AdjustmentValues] <<= aAdjSequence;
} }
...@@ -410,10 +413,12 @@ class ShapeCstripedRightArrow : public CustomShapeProvider ...@@ -410,10 +413,12 @@ class ShapeCstripedRightArrow : public CustomShapeProvider
{ {
Any aAny ((sal_Int32) 50000); Any aAny ((sal_Int32) 50000);
aAdjSequence [0].Value = aAny; aAdjSequence [0].Value = aAny;
aAdjSequence [0].Name = CREATE_OUSTRING ("adj1");
} }
{ {
Any aAny ((sal_Int32) 50000); Any aAny ((sal_Int32) 50000);
aAdjSequence [1].Value = aAny; aAdjSequence [1].Value = aAny;
aAdjSequence [1].Name = CREATE_OUSTRING ("adj2");
} }
aPropertyMap [PROP_AdjustmentValues] <<= aAdjSequence; aPropertyMap [PROP_AdjustmentValues] <<= aAdjSequence;
} }
...@@ -674,34 +679,42 @@ class ShapeCcallout3 : public CustomShapeProvider ...@@ -674,34 +679,42 @@ class ShapeCcallout3 : public CustomShapeProvider
{ {
Any aAny ((sal_Int32) 18750); Any aAny ((sal_Int32) 18750);
aAdjSequence [0].Value = aAny; aAdjSequence [0].Value = aAny;
aAdjSequence [0].Name = CREATE_OUSTRING ("adj1");
} }
{ {
Any aAny ((sal_Int32) -8333); Any aAny ((sal_Int32) -8333);
aAdjSequence [1].Value = aAny; aAdjSequence [1].Value = aAny;
aAdjSequence [1].Name = CREATE_OUSTRING ("adj2");
} }
{ {
Any aAny ((sal_Int32) 18750); Any aAny ((sal_Int32) 18750);
aAdjSequence [2].Value = aAny; aAdjSequence [2].Value = aAny;
aAdjSequence [2].Name = CREATE_OUSTRING ("adj3");
} }
{ {
Any aAny ((sal_Int32) -16667); Any aAny ((sal_Int32) -16667);
aAdjSequence [3].Value = aAny; aAdjSequence [3].Value = aAny;
aAdjSequence [3].Name = CREATE_OUSTRING ("adj4");
} }
{ {
Any aAny ((sal_Int32) 100000); Any aAny ((sal_Int32) 100000);
aAdjSequence [4].Value = aAny; aAdjSequence [4].Value = aAny;
aAdjSequence [4].Name = CREATE_OUSTRING ("adj5");
} }
{ {
Any aAny ((sal_Int32) -16667); Any aAny ((sal_Int32) -16667);
aAdjSequence [5].Value = aAny; aAdjSequence [5].Value = aAny;
aAdjSequence [5].Name = CREATE_OUSTRING ("adj6");
} }
{ {
Any aAny ((sal_Int32) 112963); Any aAny ((sal_Int32) 112963);
aAdjSequence [6].Value = aAny; aAdjSequence [6].Value = aAny;
aAdjSequence [6].Name = CREATE_OUSTRING ("adj7");
} }
{ {
Any aAny ((sal_Int32) -8333); Any aAny ((sal_Int32) -8333);
aAdjSequence [7].Value = aAny; aAdjSequence [7].Value = aAny;
aAdjSequence [7].Name = CREATE_OUSTRING ("adj8");
} }
aPropertyMap [PROP_AdjustmentValues] <<= aAdjSequence; aPropertyMap [PROP_AdjustmentValues] <<= aAdjSequence;
} }
...@@ -1073,14 +1086,17 @@ class ShapeCbentUpArrow : public CustomShapeProvider ...@@ -1073,14 +1086,17 @@ class ShapeCbentUpArrow : public CustomShapeProvider
{ {
Any aAny ((sal_Int32) 25000); Any aAny ((sal_Int32) 25000);
aAdjSequence [0].Value = aAny; aAdjSequence [0].Value = aAny;
aAdjSequence [0].Name = CREATE_OUSTRING ("adj1");
} }
{ {
Any aAny ((sal_Int32) 25000); Any aAny ((sal_Int32) 25000);
aAdjSequence [1].Value = aAny; aAdjSequence [1].Value = aAny;
aAdjSequence [1].Name = CREATE_OUSTRING ("adj2");
} }
{ {
Any aAny ((sal_Int32) 25000); Any aAny ((sal_Int32) 25000);
aAdjSequence [2].Value = aAny; aAdjSequence [2].Value = aAny;
aAdjSequence [2].Name = CREATE_OUSTRING ("adj3");
} }
aPropertyMap [PROP_AdjustmentValues] <<= aAdjSequence; aPropertyMap [PROP_AdjustmentValues] <<= aAdjSequence;
} }
...@@ -1340,6 +1356,7 @@ class ShapeCnoSmoking : public CustomShapeProvider ...@@ -1340,6 +1356,7 @@ class ShapeCnoSmoking : public CustomShapeProvider
{ {
Any aAny ((sal_Int32) 18750); Any aAny ((sal_Int32) 18750);
aAdjSequence [0].Value = aAny; aAdjSequence [0].Value = aAny;
aAdjSequence [0].Name = CREATE_OUSTRING ("adj");
} }
aPropertyMap [PROP_AdjustmentValues] <<= aAdjSequence; aPropertyMap [PROP_AdjustmentValues] <<= aAdjSequence;
} }
...@@ -1592,6 +1609,7 @@ class ShapeCtrapezoid : public CustomShapeProvider ...@@ -1592,6 +1609,7 @@ class ShapeCtrapezoid : public CustomShapeProvider
{ {
Any aAny ((sal_Int32) 25000); Any aAny ((sal_Int32) 25000);
aAdjSequence [0].Value = aAny; aAdjSequence [0].Value = aAny;
aAdjSequence [0].Name = CREATE_OUSTRING ("adj");
} }
aPropertyMap [PROP_AdjustmentValues] <<= aAdjSequence; aPropertyMap [PROP_AdjustmentValues] <<= aAdjSequence;
} }
...@@ -1753,10 +1771,12 @@ class ShapeCcloudCallout : public CustomShapeProvider ...@@ -1753,10 +1771,12 @@ class ShapeCcloudCallout : public CustomShapeProvider
{ {
Any aAny ((sal_Int32) -20833); Any aAny ((sal_Int32) -20833);
aAdjSequence [0].Value = aAny; aAdjSequence [0].Value = aAny;
aAdjSequence [0].Name = CREATE_OUSTRING ("adj1");
} }
{ {
Any aAny ((sal_Int32) 62500); Any aAny ((sal_Int32) 62500);
aAdjSequence [1].Value = aAny; aAdjSequence [1].Value = aAny;
aAdjSequence [1].Name = CREATE_OUSTRING ("adj2");
} }
aPropertyMap [PROP_AdjustmentValues] <<= aAdjSequence; aPropertyMap [PROP_AdjustmentValues] <<= aAdjSequence;
} }
...@@ -2397,18 +2417,22 @@ class ShapeCcallout1 : public CustomShapeProvider ...@@ -2397,18 +2417,22 @@ class ShapeCcallout1 : public CustomShapeProvider
{ {
Any aAny ((sal_Int32) 18750); Any aAny ((sal_Int32) 18750);
aAdjSequence [0].Value = aAny; aAdjSequence [0].Value = aAny;
aAdjSequence [0].Name = CREATE_OUSTRING ("adj1");
} }
{ {
Any aAny ((sal_Int32) -8333); Any aAny ((sal_Int32) -8333);
aAdjSequence [1].Value = aAny; aAdjSequence [1].Value = aAny;
aAdjSequence [1].Name = CREATE_OUSTRING ("adj2");
} }
{ {
Any aAny ((sal_Int32) 112500); Any aAny ((sal_Int32) 112500);
aAdjSequence [2].Value = aAny; aAdjSequence [2].Value = aAny;
aAdjSequence [2].Name = CREATE_OUSTRING ("adj3");
} }
{ {
Any aAny ((sal_Int32) -38333); Any aAny ((sal_Int32) -38333);
aAdjSequence [3].Value = aAny; aAdjSequence [3].Value = aAny;
aAdjSequence [3].Name = CREATE_OUSTRING ("adj4");
} }
aPropertyMap [PROP_AdjustmentValues] <<= aAdjSequence; aPropertyMap [PROP_AdjustmentValues] <<= aAdjSequence;
} }
...@@ -2654,10 +2678,12 @@ class ShapeCribbon : public CustomShapeProvider ...@@ -2654,10 +2678,12 @@ class ShapeCribbon : public CustomShapeProvider
{ {
Any aAny ((sal_Int32) 16667); Any aAny ((sal_Int32) 16667);
aAdjSequence [0].Value = aAny; aAdjSequence [0].Value = aAny;
aAdjSequence [0].Name = CREATE_OUSTRING ("adj1");
} }
{ {
Any aAny ((sal_Int32) 50000); Any aAny ((sal_Int32) 50000);
aAdjSequence [1].Value = aAny; aAdjSequence [1].Value = aAny;
aAdjSequence [1].Name = CREATE_OUSTRING ("adj2");
} }
aPropertyMap [PROP_AdjustmentValues] <<= aAdjSequence; aPropertyMap [PROP_AdjustmentValues] <<= aAdjSequence;
} }
......
...@@ -182,12 +182,14 @@ void CustomShapeProperties::pushToPropSet( const ::oox::core::FilterBase& /* rFi ...@@ -182,12 +182,14 @@ void CustomShapeProperties::pushToPropSet( const ::oox::core::FilterBase& /* rFi
EnhancedCustomShapeAdjustmentValue aAdjustmentVal; EnhancedCustomShapeAdjustmentValue aAdjustmentVal;
aAdjustmentVal.Value <<= (*aIter).maFormula.toInt32(); aAdjustmentVal.Value <<= (*aIter).maFormula.toInt32();
aAdjustmentVal.State = PropertyState_DIRECT_VALUE; aAdjustmentVal.State = PropertyState_DIRECT_VALUE;
aAdjustmentVal.Name = (*aIter).maName;
aAdjustmentSeq[ nAdjustmentIndex ] = aAdjustmentVal; aAdjustmentSeq[ nAdjustmentIndex ] = aAdjustmentVal;
} }
} else if ( aAdjustmentSeq.getLength() > 0 ) { } else if ( aAdjustmentSeq.getLength() > 0 ) {
EnhancedCustomShapeAdjustmentValue aAdjustmentVal; EnhancedCustomShapeAdjustmentValue aAdjustmentVal;
aAdjustmentVal.Value <<= (*aIter).maFormula.toInt32(); aAdjustmentVal.Value <<= (*aIter).maFormula.toInt32();
aAdjustmentVal.State = PropertyState_DIRECT_VALUE; aAdjustmentVal.State = PropertyState_DIRECT_VALUE;
aAdjustmentVal.Name = (*aIter).maName;
aAdjustmentSeq[ 0 ] = aAdjustmentVal; aAdjustmentSeq[ 0 ] = aAdjustmentVal;
} }
aIter++; aIter++;
...@@ -224,6 +226,7 @@ void CustomShapeProperties::pushToPropSet( const ::oox::core::FilterBase& /* rFi ...@@ -224,6 +226,7 @@ void CustomShapeProperties::pushToPropSet( const ::oox::core::FilterBase& /* rFi
EnhancedCustomShapeAdjustmentValue aAdjustmentVal; EnhancedCustomShapeAdjustmentValue aAdjustmentVal;
aAdjustmentVal.Value <<= maAdjustmentGuideList[ i ].maFormula.toInt32(); aAdjustmentVal.Value <<= maAdjustmentGuideList[ i ].maFormula.toInt32();
aAdjustmentVal.State = PropertyState_DIRECT_VALUE; aAdjustmentVal.State = PropertyState_DIRECT_VALUE;
aAdjustmentVal.Name = maAdjustmentGuideList[ i ].maName;
aAdjustmentValues[ i ] = aAdjustmentVal; aAdjustmentValues[ i ] = aAdjustmentVal;
} }
aPropertyMap[ PROP_AdjustmentValues ] <<= aAdjustmentValues; aPropertyMap[ PROP_AdjustmentValues ] <<= aAdjustmentValues;
......
...@@ -1314,7 +1314,7 @@ void DrawingML::WritePresetShape( const char* pShape, MSO_SPT eShapeType, sal_Bo ...@@ -1314,7 +1314,7 @@ void DrawingML::WritePresetShape( const char* pShape, MSO_SPT eShapeType, sal_Bo
for( sal_Int32 i=0; i < nLength; i++ ) for( sal_Int32 i=0; i < nLength; i++ )
if( EscherPropertyContainer::GetAdjustmentValue( aAdjustmentSeq[ i ], i, nAdjustmentsWhichNeedsToBeConverted, nValue ) ) if( EscherPropertyContainer::GetAdjustmentValue( aAdjustmentSeq[ i ], i, nAdjustmentsWhichNeedsToBeConverted, nValue ) )
mpFS->singleElementNS( XML_a, XML_gd, mpFS->singleElementNS( XML_a, XML_gd,
XML_name, nLength > 1 ? ( OString( "adj" ) + OString::valueOf( i + 1 ) ).getStr() : "adj", XML_name, aAdjustmentSeq[ i ].Name.getLength() > 0 ? USS(aAdjustmentSeq[ i ].Name) : (nLength > 1 ? ( OString( "adj" ) + OString::valueOf( i + 1 ) ).getStr() : "adj"),
XML_fmla, (OString("val ") + OString::valueOf( nValue )).getStr(), XML_fmla, (OString("val ") + OString::valueOf( nValue )).getStr(),
FSEND ); FSEND );
} }
......
...@@ -631,6 +631,10 @@ static const char* lclDumpAnyValueCode( Any value, int level = 0) ...@@ -631,6 +631,10 @@ static const char* lclDumpAnyValueCode( Any value, int level = 0)
const char *var = lclDumpAnyValueCode( makeAny (adjArray[i].Value), level + 1 ); const char *var = lclDumpAnyValueCode( makeAny (adjArray[i].Value), level + 1 );
printLevel (level + 1); printLevel (level + 1);
fprintf (stderr, "aAdjSequence [%d].Value = %s;\n", i, var); fprintf (stderr, "aAdjSequence [%d].Value = %s;\n", i, var);
if (adjArray[i].Name.getLength() > 0) {
printLevel (level + 1);
fprintf (stderr, "aAdjSequence [%d].Name = CREATE_OUSTRING (\"%s\");\n", i, USS (adjArray[i].Name));
}
printLevel (level); printLevel (level);
fprintf (stderr, "}\n"); fprintf (stderr, "}\n");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment