tdf#169496 oox: hidden images in PPTX/XLSX shown after roundtrip
Because 'hidden' attribute of 'cNvPr' wasn't exported. Change-Id: I5f8a79232e3b76f04269caae0631ba5b9710443a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194142 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Aron Budea <aron.budea@collabora.com>
This commit is contained in:
@@ -1418,11 +1418,14 @@ void ShapeExport::WriteGraphicObjectShapePart( const Reference< XShape >& xShape
|
||||
|
||||
presentation::ClickAction eClickAction = presentation::ClickAction_NONE;
|
||||
OUString sDescr, sURL, sBookmark, sPPAction;
|
||||
bool bVisible = true;
|
||||
|
||||
if ( GetProperty( xShapeProps, u"Description"_ustr ) )
|
||||
mAny >>= sDescr;
|
||||
if ( GetProperty( xShapeProps, u"URL"_ustr ) )
|
||||
mAny >>= sURL;
|
||||
if ( GetProperty( xShapeProps, u"Visible"_ustr ) )
|
||||
mAny >>= bVisible;
|
||||
if (GetProperty(xShapeProps, u"Bookmark"_ustr))
|
||||
mAny >>= sBookmark;
|
||||
if (GetProperty(xShapeProps, u"OnClick"_ustr))
|
||||
@@ -1431,7 +1434,8 @@ void ShapeExport::WriteGraphicObjectShapePart( const Reference< XShape >& xShape
|
||||
pFS->startElementNS( mnXmlNamespace, XML_cNvPr,
|
||||
XML_id, OString::number(GetNewShapeID(xShape)),
|
||||
XML_name, GetShapeName(xShape),
|
||||
XML_descr, sax_fastparser::UseIf(sDescr, !sDescr.isEmpty()));
|
||||
XML_descr, sax_fastparser::UseIf(sDescr, !sDescr.isEmpty()),
|
||||
XML_hidden, sax_fastparser::UseIf("1", !bVisible));
|
||||
|
||||
if (eClickAction != presentation::ClickAction_NONE)
|
||||
{
|
||||
|
||||
Binary file not shown.
@@ -935,6 +935,45 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf139258_rotated_image)
|
||||
assertXPathContent(pDrawing, "/xdr:wsDr/xdr:twoCellAnchor/xdr:to/xdr:row", u"25");
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(ScExportTest4, testtdf169496_hidden_graphic)
|
||||
{
|
||||
createScDoc("xlsx/tdf169496_hidden_graphic.xlsx");
|
||||
|
||||
save(u"Calc Office Open XML"_ustr);
|
||||
|
||||
xmlDocUniquePtr pDrawing = parseExport(u"xl/drawings/drawing1.xml"_ustr);
|
||||
CPPUNIT_ASSERT(pDrawing);
|
||||
|
||||
// Graphic 4 is hidden and Graphic 3 is visible, but their order might change in the XML
|
||||
// Without the fix the hidden attribute wasn't exported
|
||||
OUString sName1 = getXPath(
|
||||
pDrawing, "/xdr:wsDr/xdr:twoCellAnchor[1]/xdr:pic/xdr:nvPicPr/xdr:cNvPr", "name");
|
||||
OUString sName2 = getXPath(
|
||||
pDrawing, "/xdr:wsDr/xdr:twoCellAnchor[2]/xdr:pic/xdr:nvPicPr/xdr:cNvPr", "name");
|
||||
if (sName1 == "Graphic 4" && sName2 == "Graphic 3")
|
||||
{
|
||||
OUString aHidden = getXPath(
|
||||
pDrawing, "/xdr:wsDr/xdr:twoCellAnchor[1]/xdr:pic/xdr:nvPicPr/xdr:cNvPr", "hidden");
|
||||
bool bHidden = aHidden == u"true"_ustr || aHidden == u"1";
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE("Graphic 3 is supposed to be hidden", true, bHidden);
|
||||
|
||||
assertXPathNoAttribute(
|
||||
pDrawing, "/xdr:wsDr/xdr:twoCellAnchor[2]/xdr:pic/xdr:nvPicPr/xdr:cNvPr", "hidden");
|
||||
}
|
||||
else if (sName1 == "Graphic 3" && sName2 == "Graphic 4")
|
||||
{
|
||||
assertXPathNoAttribute(
|
||||
pDrawing, "/xdr:wsDr/xdr:twoCellAnchor[1]/xdr:pic/xdr:nvPicPr/xdr:cNvPr", "hidden");
|
||||
|
||||
OUString aHidden = getXPath(
|
||||
pDrawing, "/xdr:wsDr/xdr:twoCellAnchor[2]/xdr:pic/xdr:nvPicPr/xdr:cNvPr", "hidden");
|
||||
bool bHidden = aHidden == u"true"_ustr || aHidden == u"1";
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE("Graphic 4 is supposed to be hidden", true, bHidden);
|
||||
}
|
||||
else
|
||||
CPPUNIT_FAIL("Names of graphics is incorrect");
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf144642_RowHeightRounding)
|
||||
{
|
||||
// MS Excel round down row heights to 0.75pt
|
||||
|
||||
Binary file not shown.
@@ -1606,6 +1606,43 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest4, testOLEObjectAnimationTarget)
|
||||
"spid", sOleId);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest4, testtdf169496_hidden_graphic)
|
||||
{
|
||||
createSdImpressDoc("pptx/tdf169496_hidden_graphic.pptx");
|
||||
save(u"Impress Office Open XML"_ustr);
|
||||
|
||||
xmlDocUniquePtr pXmlDoc = parseExport(u"ppt/slides/slide1.xml"_ustr);
|
||||
|
||||
// Graphic 5 is hidden and Graphic 4 is visible, but their order might change in the XML
|
||||
// Without the fix the hidden attribute wasn't exported
|
||||
OUString sName1
|
||||
= getXPath(pXmlDoc, "/p:sld/p:cSld/p:spTree/p:pic[1]/p:nvPicPr/p:cNvPr", "name");
|
||||
OUString sName2
|
||||
= getXPath(pXmlDoc, "/p:sld/p:cSld/p:spTree/p:pic[2]/p:nvPicPr/p:cNvPr", "name");
|
||||
if (sName1 == "Graphic 5" && sName2 == "Graphic 4")
|
||||
{
|
||||
OUString aHidden
|
||||
= getXPath(pXmlDoc, "/p:sld/p:cSld/p:spTree/p:pic[1]/p:nvPicPr/p:cNvPr", "hidden");
|
||||
bool bHidden = aHidden == u"true"_ustr || aHidden == u"1";
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE("Graphic 3 is supposed to be hidden", true, bHidden);
|
||||
|
||||
assertXPathNoAttribute(pXmlDoc, "/p:sld/p:cSld/p:spTree/p:pic[2]/p:nvPicPr/p:cNvPr",
|
||||
"hidden");
|
||||
}
|
||||
else if (sName1 == "Graphic 4" && sName2 == "Graphic 5")
|
||||
{
|
||||
assertXPathNoAttribute(pXmlDoc, "/p:sld/p:cSld/p:spTree/p:pic[1]/p:nvPicPr/p:cNvPr",
|
||||
"hidden");
|
||||
|
||||
OUString aHidden
|
||||
= getXPath(pXmlDoc, "/p:sld/p:cSld/p:spTree/p:pic[2]/p:nvPicPr/p:cNvPr", "hidden");
|
||||
bool bHidden = aHidden == u"true"_ustr || aHidden == u"1";
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE("Graphic 4 is supposed to be hidden", true, bHidden);
|
||||
}
|
||||
else
|
||||
CPPUNIT_FAIL("Names of graphics is incorrect");
|
||||
}
|
||||
|
||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
Reference in New Issue
Block a user