Kaydet (Commit) 2b4f9d0b authored tarafından Mark Hung's avatar Mark Hung

Convert handles of built-in shapes in Impress when exporting to PPTX.

For those shapes exported as OOXML preset shapes, their AdjustmentValues
property was exported as the list of adjustment values ( avLst )
in the exported PPTX file. This works for shapes imported from
PPTX, whose AdjustmentValues is exactly the same as avLst of the
original PPTX file.

For built-in shapes in Impress, avLst and AdjustmentValues would not
be the same because the path and the equation created by LibreOffice
and OOXML are not the same.

This patch convert position of handles to adjustment values according to
the shape type case by case. It also adds default values if the built-in
shape in Impress has fewer handles then the exported preset shape because
Powerpoint seems to be very strict about the number of values in avLst,
and deemed the file as corrupted if any of defined adjustment values is
missing.

Round-rectangular-callouts, rectangular-callout, and round-callouts
are added to the blacklist so that they are exported as preset shapes.

Change-Id: Icd1284790607e927b6a9a614ac463a96cadedd81
Reviewed-on: https://gerrit.libreoffice.org/26479Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMark Hung <marklh9@gmail.com>
üst c878bfc8
......@@ -201,6 +201,7 @@ public:
void WriteRun( const css::uno::Reference< css::text::XTextRange >& rRun );
void WriteRunProperties( const css::uno::Reference< css::beans::XPropertySet >& rRun, bool bIsField, sal_Int32 nElement = XML_rPr ,bool bCheckDirect = true);
void WritePresetShape( const char* pShape , std::vector< std::pair<sal_Int32,sal_Int32>> & rAvList );
void WritePresetShape( const char* pShape );
void WritePresetShape( const char* pShape, MSO_SPT eShapeType, bool bPredefinedHandlesUsed, sal_Int32 nAdjustmentsWhichNeedsToBeConverted, const css::beans::PropertyValue& rProp );
void WriteCustomGeometry( const css::uno::Reference<css::drawing::XShape>& rXShape );
......
......@@ -2189,6 +2189,33 @@ void DrawingML::WriteText( const Reference< XInterface >& rXIface, const OUStrin
}
void DrawingML::WritePresetShape( const char* pShape , std::vector< std::pair<sal_Int32,sal_Int32>> & rAvList )
{
mpFS->startElementNS( XML_a, XML_prstGeom,
XML_prst, pShape,
FSEND );
if ( !rAvList.empty() )
{
mpFS->startElementNS( XML_a, XML_avLst, FSEND );
for(auto iter = rAvList.begin() ; iter != rAvList.end() ; ++iter)
{
OString sName = OString("adj") + ( ( iter->first > 0 ) ? OString::number(iter->first) : OString("") );
OString sFmla = OString("val ") + OString::number( iter->second );
mpFS->singleElementNS( XML_a, XML_gd,
XML_name, sName.getStr(),
XML_fmla, sFmla.getStr(),
FSEND );
}
mpFS->endElementNS( XML_a, XML_avLst );
}
else
mpFS->singleElementNS( XML_a, XML_avLst, FSEND );
mpFS->endElementNS( XML_a, XML_prstGeom );
}
void DrawingML::WritePresetShape( const char* pShape )
{
mpFS->startElementNS( XML_a, XML_prstGeom,
......
This diff is collapsed.
......@@ -90,6 +90,7 @@ public:
void testMathObjectPPT2010();
void testTdf80224();
void testExportTransitionsPPTX();
void testPresetShapesExport();
void testTdf92527();
void testDatetimeFieldNumberFormat();
void testDatetimeFieldNumberFormatPPTX();
......@@ -113,6 +114,7 @@ public:
CPPUNIT_TEST(testMathObjectPPT2010);
CPPUNIT_TEST(testTdf80224);
CPPUNIT_TEST(testExportTransitionsPPTX);
CPPUNIT_TEST(testPresetShapesExport);
CPPUNIT_TEST(testTdf92527);
CPPUNIT_TEST(testDatetimeFieldNumberFormat);
CPPUNIT_TEST(testDatetimeFieldNumberFormatPPTX);
......@@ -438,6 +440,85 @@ void SdOOXMLExportTest2::testExportTransitionsPPTX()
xDocShRef->DoClose();
}
void SdOOXMLExportTest2::testPresetShapesExport()
{
::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/odp/preset-shapes-export.odp"), ODP);
const sal_Char *sShapeTypeAndValues[] =
{
"wedgeEllipseCallout",
"adj1","val 45310",
"adj2","val 97194",
"wedgeRoundRectCallout",
"adj1","val 46694",
"adj2","val 129726",
"adj3","val 16667",
"wedgeRectCallout",
"adj1","val 40037",
"adj2","val 111694",
"smileyFace",
"adj","val -9282",
"can",
"adj","val 50000",
"frame",
"adj1","val 10490",
"donut",
"adj","val 9601",
"noSmoking",
"adj","val 16118",
"bevel",
"adj","val 42587",
"foldedCorner",
"adj","val 10750",
"verticalScroll",
"adj","val 25000",
"horizontalScroll",
"adj","val 25000",
"cube",
"adj","val 85129",
"bracketPair",
"adj","val 50000",
"sun",
"adj","val 12500",
"bracePair",
"adj","val 25000",
"cloudCallout",
"adj1","val 77611",
"adj2","val -47819",
"borderCallout1",
"adj1","val 18750",
"adj2","val -8333",
"adj3","val 170013",
"adj4","val 143972",
"borderCallout2",
"adj1","val 18750",
"adj2","val -8333",
"adj3","val 113768",
"adj4","val -81930",
"adj5","val -22375",
"adj6","val -134550",
};
utl::TempFile tempFile;
xDocShRef = saveAndReload( xDocShRef, PPTX, &tempFile );
xmlDocPtr pXmlDocCT = parseExport(tempFile, "ppt/slides/slide1.xml");
const OString sPattern( "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:prstGeom[@prst='_T_']/a:avLst/a:gd[_N_]" );
const OString sT( "_T_" );
const OString sN( "_N_" );
const OString sPropertyName("name");
const OString sPropertyFmla("fmla");
size_t i = 0;
while(i < SAL_N_ELEMENTS( sShapeTypeAndValues )) {
OString sType = OString( sShapeTypeAndValues[ i++ ] );
for ( size_t j = 1 ; i < SAL_N_ELEMENTS( sShapeTypeAndValues ) && OString(sShapeTypeAndValues[i]).startsWith("adj") ; ++j ) {
OString sXPath= sPattern.replaceFirst( sT, sType).replaceFirst( sN, OString::number(j) );
assertXPath(pXmlDocCT, sXPath, sPropertyName , OUString::createFromAscii(sShapeTypeAndValues[ i++ ]) );
assertXPath(pXmlDocCT, sXPath, sPropertyFmla , OUString::createFromAscii(sShapeTypeAndValues[ i++ ]) );
}
}
}
void SdOOXMLExportTest2::testTdf92527()
{
// We draw a diamond in an empty document. A newly created diamond shape does not have
......
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