summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAttila Bakos (NISZ) <bakos.attilakaroly@nisz.hu>2022-04-05 10:13:02 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2022-04-07 11:33:04 +0200
commite342185c4650ca2678ccbea92770e1ae147d08bc (patch)
treee10bd0518b2d93f92f94051dd607f0daf77ef9c9
parenttdf#148382: Keep first entry selected when address field is not set (diff)
downloadcore-e342185c4650ca2678ccbea92770e1ae147d08bc.tar.gz
core-e342185c4650ca2678ccbea92770e1ae147d08bc.zip
tdf#148342 docx export: fix puzzle shape
There is an exporter class for preset shapes, namely the DMLPresetShapeExporter, which in its ctor calls the msfilter::GetShapeName() converter method where the puzzle cause exception. To avoid this return with false to export it with custgeom in time. Change-Id: I8d29bf551638a66abf381c9cb8f6a0eebc881195 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132567 Tested-by: Jenkins Reviewed-by: Attila Bakos <bakos.attilakaroly@nisz.hu> Reviewed-by: Regina Henschel <rb.henschel@t-online.de> (cherry picked from commit 9592da0a8e596869a1cd0859619dd28a541d7234) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132606 Tested-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--oox/source/export/shapes.cxx3
-rw-r--r--sw/qa/extras/ooxmlexport/data/TestPuzzleExport.odtbin0 -> 15349 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport10.cxx30
3 files changed, 32 insertions, 1 deletions
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 86ca6264129d..138106938ee2 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -928,7 +928,8 @@ ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape )
// as preset ones with parameters. Try that with this converter class.
if (!sShapeType.startsWith("ooxml") && sShapeType != "non-primitive"
&& GetDocumentType() == DOCUMENT_DOCX && !mbUserShapes
- && xShape->getShapeType() == "com.sun.star.drawing.CustomShape")
+ && xShape->getShapeType() == "com.sun.star.drawing.CustomShape"
+ && !lcl_IsOnAllowlist(sShapeType))
{
DMLPresetShapeExporter aCustomShapeConverter(this, xShape);
bPresetWriteSuccessful = aCustomShapeConverter.WriteShape();
diff --git a/sw/qa/extras/ooxmlexport/data/TestPuzzleExport.odt b/sw/qa/extras/ooxmlexport/data/TestPuzzleExport.odt
new file mode 100644
index 000000000000..6f7a62deecd2
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/TestPuzzleExport.odt
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index 633aa6ddb4eb..c97acffdc038 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -1292,6 +1292,36 @@ DECLARE_OOXMLEXPORT_TEST( testTableCellMargin, "table-cell-margin.docx" )
}
}
+DECLARE_OOXMLEXPORT_TEST(TestPuzzleExport, "TestPuzzleExport.odt")
+{
+ // See tdf#148342 fo details
+ // Get the doc
+ uno::Reference< text::XTextDocument > xTextDoc(mxComponent, uno::UNO_QUERY_THROW);
+ auto pSwDoc = dynamic_cast<SwXTextDocument*>(xTextDoc.get());
+ CPPUNIT_ASSERT(pSwDoc);
+ // Create a metafile
+ auto pMeta = pSwDoc->GetDocShell()->GetPreviewMetaFile();
+ CPPUNIT_ASSERT(pMeta);
+ MetafileXmlDump aDumper;
+ auto pMetaXml = dumpAndParse(aDumper, *pMeta);
+ CPPUNIT_ASSERT(pMetaXml);
+ // After parsing check that node...
+ auto pXNode = getXPathNode(pMetaXml, "/metafile/push/push/push/push[4]/push/push/polypolygon/polygon");
+ CPPUNIT_ASSERT(pXNode);
+ auto pNode = pXNode->nodesetval->nodeTab[0];
+ CPPUNIT_ASSERT(pNode);
+ auto it = pNode->children;
+ int nCount = 0;
+ // .. and count the children
+ while (it != nullptr)
+ {
+ nCount++;
+ it = it->next;
+ }
+ // In case of puzzle thre will be so many... Without the fix there was a rectangle with 4 points.
+ CPPUNIT_ASSERT_GREATER(300, nCount);
+}
+
// tdf#106742 for DOCX with compatibility level <= 14 (MS Word up to and incl. ver.2010), we should use cell margins when calculating table left border position
DECLARE_OOXMLEXPORT_TEST( testTablePosition14, "table-position-14.docx" )
{