diff options
author | Regina Henschel <rb.henschel@t-online.de> | 2023-01-18 20:19:51 +0100 |
---|---|---|
committer | Regina Henschel <rb.henschel@t-online.de> | 2023-01-22 10:39:27 +0000 |
commit | 7eac3e78abcdece849b8bac61545b0d3ddf5800c (patch) | |
tree | 1f8338714b48f9eaa35b4141b4a3f24054e4b989 /oox/qa | |
parent | a00556ada3214d7584bebd4d6ac33bf5c25a3467 (diff) |
tdf#128568 Improve export to docx of Fontwork with bitmap fill
The modern 'abc transform' in Word is not able to use bitmap fill, but
it is possible in legacy VML. Thus use VML in such cases.
A WordArt shape in VML has the text not in a <txbxContent> element but
as string='...' attribute in the <v:textpath> element. To detect
whether a custom shape is a Fontwork in an easy way without cast, I
have added the already for custom shapes existing method IsTextPath()
to the basis class SdrObject.
Using VML for Fontwork with bitmap fill, errors in the VML code become
visible:
* Using <v:imagedata> element results in Word in a picture of the shape.
The shape itself was lost. A bitmap fill of a shape has to be written
with the <v:fill> element.
* Mode 'stretched' in LO UI becomes type='frame' attribute in VML.
I have adapted the unit test NoFillAttrInImagedata in ooxmlexport2.cxx
in sw. The source file has the background image in a v:fill element.
If you replace the 'wps' namespace with a 'my' namespace in the file
generated by LO and so force Word to use the Fallback, you will see
that with v:imagedata Word does not show a background image. Thus the
assumption in the test was wrong, that there has to be a v:imagedata
element.
Change-Id: I6b2b5b8bb19adcee3b41e536419556465e85d135
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145823
Tested-by: Jenkins
Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'oox/qa')
-rw-r--r-- | oox/qa/unit/data/tdf128568_FontworkBitmapFill.odt | bin | 0 -> 17770 bytes | |||
-rw-r--r-- | oox/qa/unit/export.cxx | 30 |
2 files changed, 30 insertions, 0 deletions
diff --git a/oox/qa/unit/data/tdf128568_FontworkBitmapFill.odt b/oox/qa/unit/data/tdf128568_FontworkBitmapFill.odt Binary files differnew file mode 100644 index 000000000000..30a0730a10e7 --- /dev/null +++ b/oox/qa/unit/data/tdf128568_FontworkBitmapFill.odt diff --git a/oox/qa/unit/export.cxx b/oox/qa/unit/export.cxx index fdf97b328f45..7c312798270a 100644 --- a/oox/qa/unit/export.cxx +++ b/oox/qa/unit/export.cxx @@ -768,6 +768,36 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf151008VertAnchor) assertXPath(pXmlDoc, "//p:spTree/p:sp[6]/p:txBody/a:bodyPr", "anchor", "b"); assertXPath(pXmlDoc, "//p:spTree/p:sp[6]/p:txBody/a:bodyPr", "anchorCtr", "1"); } + +CPPUNIT_TEST_FIXTURE(Test, testFontworkBitmapFill) +{ + // The document has a Fontwork shape with bitmap fill. + loadFromURL(u"tdf128568_FontworkBitmapFill.odt"); + + // FIXME: validation error in OOXML export: Errors: 1 + // Attribute ID is not allowed in element v:shape + skipValidation(); + + // Saving that to DOCX: + save("Office Open XML Text"); + + // Make sure it is exported to VML and has no txbxContent but a textpath element. Without fix it + // was exported as DML 'abc transform', but that is not able to use bitmap fill in Word. + xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); + assertXPath(pXmlDoc, "//mc:alternateContent", 0); + assertXPath(pXmlDoc, "//v:shape/v:textbox/v:txbxContent", 0); + assertXPath(pXmlDoc, "//v:shape/v:textpath", 1); + + // Without fix the bitmap was referenced by v:imagedata element. But that produces a picture + // in Word not a WordArt shape. Instead a v:fill has to be used. + assertXPath(pXmlDoc, "//v:shape/v:imagedata", 0); + assertXPath(pXmlDoc, "//v:shape/v:fill", 1); + assertXPath(pXmlDoc, "//v:shape/v:fill[@r:id]", 1); + + // The fill is set to 'stretched' in LO, that is type="frame" in VML. That was not implemented + // in VML export. + assertXPath(pXmlDoc, "//v:shape/v:fill", "type", "frame"); +} } CPPUNIT_PLUGIN_IMPLEMENT(); |