office-gobmx/sd/qa/unit/export-tests-ooxml3.cxx
Henry Castro d590f094cc tdf#155512: sd: filter: eppt: add "SlideLayout" property to Slide Master
If it is importing all Slide Master from pptx file, unfortunately
it breaks the exporting to pptx due to save and reload unit test failures

According to the documentation
http://officeopenxml.com/prSlideLayout.php, so the file pptx has a
relationship Slide -> Slide Layout -> Slide Master

The Slide Layout is a template an unique to be reused
with Slide Master, so exporting requires to compare
the templates due to LibreOffice relation Slide -> Slide Master

Adjust unit test values:

SdOOXMLExportTest2::testTdf106867
revert adcde78935

SdOOXMLExportTest2::testTdf112280
revert adcde78935

SdOOXMLExportTest2::testThemeColors and
SdOOXMLExportTest3::testTdf114848
The file tdf84205.pptx does not contain theme2.xml,
and save and reload it does not caintain theme2.xml too
fix "An uncaught exception of type com.sun.star.container.NoSuchElementException"

Signed-off-by: Henry Castro <hcastro@collabora.com>
Change-Id: I622e9d5d68c406ff520387f3903808613d1cd3d9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158084
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158676
Tested-by: Jenkins
2023-10-31 12:01:43 +01:00

969 lines
41 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <officecfg/Office/Common.hxx>
#include "sdmodeltestbase.hxx"
#include <comphelper/sequence.hxx>
#include <editeng/unoprnms.hxx>
#include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
#include <sdpage.hxx>
class SdOOXMLExportTest3 : public SdModelTestBase
{
public:
SdOOXMLExportTest3()
: SdModelTestBase("/sd/qa/unit/data/")
{
}
int testTdf115005_FallBack_Images(bool bAddReplacementImages);
};
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf153105)
{
createSdImpressDoc("odp/tdf153105.odp");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDoc1 = parseExport("ppt/slides/slide1.xml");
assertXPath(pXmlDoc1, "/p:sld/p:cSld/p:bg/p:bgPr/a:blipFill/a:stretch/a:fillRect", "l",
"20000");
assertXPath(pXmlDoc1, "/p:sld/p:cSld/p:bg/p:bgPr/a:blipFill/a:stretch/a:fillRect", "t",
"30000");
assertXPath(pXmlDoc1, "/p:sld/p:cSld/p:bg/p:bgPr/a:blipFill/a:stretch/a:fillRect", "r",
"20000");
assertXPath(pXmlDoc1, "/p:sld/p:cSld/p:bg/p:bgPr/a:blipFill/a:stretch/a:fillRect", "b",
"30000");
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf92222)
{
createSdImpressDoc("pptx/tdf92222.pptx");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDocTheme = parseExport("ppt/theme/theme1.xml");
assertXPath(pXmlDocTheme, "/a:theme/a:themeElements/a:fmtScheme/a:lnStyleLst/a:ln[1]", "w",
"6350");
assertXPath(pXmlDocTheme, "/a:theme/a:themeElements/a:fmtScheme/a:lnStyleLst/a:ln[2]", "w",
"12700");
assertXPath(pXmlDocTheme, "/a:theme/a:themeElements/a:fmtScheme/a:lnStyleLst/a:ln[3]", "w",
"19050");
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf129430)
{
createSdImpressDoc("odp/tdf129430.odp");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDoc1 = parseExport("ppt/slides/slide1.xml");
assertXPath(pXmlDoc1, "/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p[2]/a:pPr/a:lnSpc/a:spcPct",
"val", "100000");
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf114848)
{
createSdImpressDoc("pptx/tdf114848.pptx");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDocTheme1 = parseExport("ppt/theme/theme1.xml");
assertXPath(pXmlDocTheme1, "/a:theme/a:themeElements/a:clrScheme/a:dk2/a:srgbClr", "val",
"1f497d");
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf147586)
{
createSdImpressDoc("pptx/tdf147586.pptx");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDocContent = parseExport("ppt/slides/slide1.xml");
// Without the fix in place, this test would have failed with
// - Expected: 227fc7
// - Actual : 4f4f4f
assertXPath(pXmlDocContent,
"/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:p[1]/a:pPr/a:buClr/a:srgbClr", "val",
"227fc7");
assertXPath(pXmlDocContent,
"/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:p[2]/a:pPr/a:buClr/a:srgbClr", "val",
"227fc7");
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf68759)
{
createSdImpressDoc("odp/tdf68759.odp");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDocContent = parseExport("ppt/slides/slide1.xml");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:pic[1]/p:spPr/a:xfrm/a:off", "x",
"1687320");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:pic[1]/p:spPr/a:xfrm/a:off", "y",
"1615320");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:pic[2]/p:spPr/a:xfrm", "flipH", "1");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:pic[2]/p:spPr/a:xfrm", "rot", "9600000");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:pic[2]/p:spPr/a:xfrm/a:off", "x",
"3847320");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:pic[2]/p:spPr/a:xfrm/a:off", "y",
"1614600");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:pic[3]/p:spPr/a:xfrm", "flipH", "1");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:pic[3]/p:spPr/a:xfrm/a:off", "x",
"5934960");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:pic[3]/p:spPr/a:xfrm/a:off", "y",
"1615320");
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf127901)
{
createSdImpressDoc("odp/tdf127901.odp");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDocContent1 = parseExport("ppt/slides/slide1.xml");
assertXPath(pXmlDocContent1, "/p:sld/p:cSld/p:spTree/p:pic/p:blipFill/a:blip/a:lum", "bright",
"70000");
assertXPath(pXmlDocContent1, "/p:sld/p:cSld/p:spTree/p:pic/p:blipFill/a:blip/a:lum", "contrast",
"-70000");
xmlDocUniquePtr pXmlDocContent2 = parseExport("ppt/slides/slide2.xml");
assertXPath(pXmlDocContent2, "/p:sld/p:cSld/p:spTree/p:pic/p:blipFill/a:blip/a:grayscl", 1);
xmlDocUniquePtr pXmlDocContent3 = parseExport("ppt/slides/slide3.xml");
assertXPath(pXmlDocContent3, "/p:sld/p:cSld/p:spTree/p:pic/p:blipFill/a:blip/a:biLevel",
"thresh", "50000");
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf48735)
{
createSdImpressDoc("odp/tdf48735.odp");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDocContent1 = parseExport("ppt/slides/slide1.xml");
assertXPath(pXmlDocContent1, "/p:sld/p:cSld/p:spTree/p:pic/p:blipFill/a:srcRect", "b", "23627");
assertXPath(pXmlDocContent1, "/p:sld/p:cSld/p:spTree/p:pic/p:blipFill/a:srcRect", "l", "23627");
assertXPath(pXmlDocContent1, "/p:sld/p:cSld/p:spTree/p:pic/p:blipFill/a:srcRect", "r", "23627");
assertXPath(pXmlDocContent1, "/p:sld/p:cSld/p:spTree/p:pic/p:blipFill/a:srcRect", "t", "18842");
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf90626)
{
createSdImpressDoc("odp/tdf90626.odp");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDocContent = parseExport("ppt/slides/slide1.xml");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[1]/a:pPr/a:buSzPct",
"val", "100000");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[2]/a:pPr/a:buSzPct",
"val", "150142");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[3]/a:pPr/a:buSzPct",
"val", "100000");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[4]/a:pPr/a:buSzPct",
"val", "150142");
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf107608)
{
createSdImpressDoc("pptx/tdf107608.pptx");
save("Impress Office Open XML");
uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0));
uno::Reference<beans::XPropertySet> xPropSet(xShape, uno::UNO_SET_THROW);
drawing::FillStyle aFillStyle(drawing::FillStyle_NONE);
xPropSet->getPropertyValue("FillStyle") >>= aFillStyle;
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_HATCH, aFillStyle);
bool bBackgroundFill = false;
xPropSet->getPropertyValue("FillBackground") >>= bBackgroundFill;
CPPUNIT_ASSERT(bBackgroundFill);
Color nBackgroundColor;
xPropSet->getPropertyValue("FillColor") >>= nBackgroundColor;
CPPUNIT_ASSERT_EQUAL(Color(0x92D050), nBackgroundColor);
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf111786)
{
// Export line transparency with the color
createSdImpressDoc("pptx/tdf111786.pptx");
save("Impress Office Open XML");
uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0));
uno::Reference<beans::XPropertySet> xPropSet(xShape, uno::UNO_SET_THROW);
Color nLineColor;
xPropSet->getPropertyValue("LineColor") >>= nLineColor;
CPPUNIT_ASSERT_EQUAL(Color(0x3465A4), nLineColor);
sal_Int16 nTransparency;
xPropSet->getPropertyValue("LineTransparence") >>= nTransparency;
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(33), nTransparency);
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testFontScale)
{
createSdImpressDoc("pptx/font-scale.pptx");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDocContent = parseExport("ppt/slides/slide1.xml");
// Rounding errors possible, approximate value (+/- 1%)
OUString sScale = getXPath(
pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:bodyPr/a:normAutofit", "fontScale");
CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(81111), sScale.toInt32(), 1000);
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testShapeAutofitPPTX)
{
createSdImpressDoc("pptx/testShapeAutofit.pptx");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDocContent = parseExport("ppt/slides/slide1.xml");
CPPUNIT_ASSERT(pXmlDocContent);
// TextAutoGrowHeight --> "Resize shape to fit text" --> true
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:bodyPr/a:spAutoFit", 1);
// TextAutoGrowHeight --> "Resize shape to fit text" --> false
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:bodyPr/a:noAutofit", 1);
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testLegacyShapeAutofitPPTX)
{
createSdImpressDoc("odp/testLegacyShapeAutofit.odp");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDocContent = parseExport("ppt/slides/slide1.xml");
CPPUNIT_ASSERT(pXmlDocContent);
// Text in a legacy rectangle
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:bodyPr/a:noAutofit", 1);
// Text in (closed) Polygon
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:bodyPr/a:noAutofit", 1);
// Text in a legacy ellipse
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[3]/p:txBody/a:bodyPr/a:noAutofit", 1);
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf115394)
{
createSdImpressDoc("pptx/tdf115394.pptx");
save("Impress Office Open XML");
SdXImpressDocument* pXImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
CPPUNIT_ASSERT(pXImpressDocument);
SdDrawDocument* pDoc = pXImpressDocument->GetDoc();
double fTransitionDuration;
// Slow in MS formats
SdPage* pPage1 = pDoc->GetSdPage(0, PageKind::Standard);
fTransitionDuration = pPage1->getTransitionDuration();
CPPUNIT_ASSERT_EQUAL(1.0, fTransitionDuration);
// Medium in MS formats
SdPage* pPage2 = pDoc->GetSdPage(1, PageKind::Standard);
fTransitionDuration = pPage2->getTransitionDuration();
CPPUNIT_ASSERT_EQUAL(0.75, fTransitionDuration);
// Fast in MS formats
SdPage* pPage3 = pDoc->GetSdPage(2, PageKind::Standard);
fTransitionDuration = pPage3->getTransitionDuration();
CPPUNIT_ASSERT_EQUAL(0.5, fTransitionDuration);
// Custom values
SdPage* pPage4 = pDoc->GetSdPage(3, PageKind::Standard);
fTransitionDuration = pPage4->getTransitionDuration();
CPPUNIT_ASSERT_EQUAL(0.25, fTransitionDuration);
SdPage* pPage5 = pDoc->GetSdPage(4, PageKind::Standard);
fTransitionDuration = pPage5->getTransitionDuration();
CPPUNIT_ASSERT_EQUAL(4.25, fTransitionDuration);
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf115394Zero)
{
createSdImpressDoc("pptx/tdf115394-zero.pptx");
save("Impress Office Open XML");
double fTransitionDuration;
SdXImpressDocument* pXImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
CPPUNIT_ASSERT(pXImpressDocument);
SdDrawDocument* pDoc = pXImpressDocument->GetDoc();
SdPage* pPage = pDoc->GetSdPage(0, PageKind::Standard);
fTransitionDuration = pPage->getTransitionDuration();
CPPUNIT_ASSERT_EQUAL(0.01, fTransitionDuration);
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf115005)
{
createSdImpressDoc("odp/tdf115005.odp");
save("impress8");
// additional checks of the output file
uno::Reference<packages::zip::XZipFileAccess2> xNameAccess
= packages::zip::ZipFileAccess::createWithURL(mxComponentContext, maTempFile.GetURL());
// check that the document contains original vector images
const uno::Sequence<OUString> names = xNameAccess->getElementNames();
int nSVMFiles = 0;
for (OUString const& s : names)
{
if (s.endsWith(".svm"))
nSVMFiles++;
}
CPPUNIT_ASSERT_EQUAL(3, nSVMFiles);
}
int SdOOXMLExportTest3::testTdf115005_FallBack_Images(bool bAddReplacementImages)
{
createSdImpressDoc("odp/tdf115005_no_fallback_images.odp");
// check if fallback images were not created if AddReplacementImages=true/false
// set AddReplacementImages
{
std::shared_ptr<comphelper::ConfigurationChanges> batch(
comphelper::ConfigurationChanges::create());
if (!officecfg::Office::Common::Save::Graphic::AddReplacementImages::isReadOnly())
officecfg::Office::Common::Save::Graphic::AddReplacementImages::set(
bAddReplacementImages, batch);
batch->commit();
}
// save the file with already set options
save("impress8");
// additional checks of the output file
uno::Reference<packages::zip::XZipFileAccess2> xNameAccess
= packages::zip::ZipFileAccess::createWithURL(mxComponentContext, maTempFile.GetURL());
// check that the document contains original vector images
const uno::Sequence<OUString> names = xNameAccess->getElementNames();
int nSVMFiles = 0;
int nPNGFiles = 0;
for (OUString const& n : names)
{
if (n.endsWith(".svm"))
nSVMFiles++;
if (n.endsWith(".png") && n != "Thumbnails/thumbnail.png") // Ignore the thumbnail
nPNGFiles++;
}
// check results
CPPUNIT_ASSERT_EQUAL(1, nSVMFiles);
return nPNGFiles;
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf115005_FallBack_Images_On)
{
const int nPNGFiles = testTdf115005_FallBack_Images(true);
CPPUNIT_ASSERT_EQUAL(1, nPNGFiles);
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf115005_FallBack_Images_Off)
{
const int nPNGFiles = testTdf115005_FallBack_Images(false);
CPPUNIT_ASSERT_EQUAL(0, nPNGFiles);
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf118806)
{
createSdImpressDoc("odp/tdf118806.odp");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDocContent = parseExport("ppt/slides/slide1.xml");
assertXPath(pXmlDocContent, "//p:animMotion", "origin", "layout");
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf130058)
{
createSdImpressDoc("pptx/tdf130058.pptx");
save("Impress Office Open XML");
uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0));
bool bHasShadow = false;
xShape->getPropertyValue("Shadow") >>= bHasShadow;
CPPUNIT_ASSERT(bHasShadow);
double fShadowDist = 0.0;
xShape->getPropertyValue("ShadowXDistance") >>= fShadowDist;
CPPUNIT_ASSERT_EQUAL(static_cast<double>(0), fShadowDist);
xShape->getPropertyValue("ShadowYDistance") >>= fShadowDist;
CPPUNIT_ASSERT_EQUAL(static_cast<double>(141), fShadowDist);
Color nColor;
xShape->getPropertyValue("ShadowColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(COL_BLACK, nColor);
sal_Int32 nTransparency = 0;
xShape->getPropertyValue("ShadowTransparence") >>= nTransparency;
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(57), nTransparency);
double fShadowSizeX = 0.0;
xShape->getPropertyValue("ShadowSizeX") >>= fShadowSizeX;
CPPUNIT_ASSERT_EQUAL(static_cast<double>(1000), fShadowSizeX);
double fShadowSizeY = 0.0;
xShape->getPropertyValue("ShadowSizeY") >>= fShadowSizeY;
CPPUNIT_ASSERT_EQUAL(static_cast<double>(1000), fShadowSizeY);
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf111789)
{
// Shadow properties were not exported for text shapes.
createSdImpressDoc("pptx/tdf111789.pptx");
save("Impress Office Open XML");
// First text shape has some shadow
{
uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0));
bool bHasShadow = false;
xShape->getPropertyValue("Shadow") >>= bHasShadow;
CPPUNIT_ASSERT(bHasShadow);
double fShadowDist = 0.0;
xShape->getPropertyValue("ShadowXDistance") >>= fShadowDist;
CPPUNIT_ASSERT_EQUAL(static_cast<double>(274), fShadowDist);
xShape->getPropertyValue("ShadowYDistance") >>= fShadowDist;
CPPUNIT_ASSERT_EQUAL(static_cast<double>(274), fShadowDist);
Color nColor;
xShape->getPropertyValue("ShadowColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(Color(0xFF0000), nColor);
sal_Int32 nTransparency = 0;
xShape->getPropertyValue("ShadowTransparence") >>= nTransparency;
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(7), nTransparency);
double fShadowSizeX = 0.0;
xShape->getPropertyValue("ShadowSizeX") >>= fShadowSizeX;
CPPUNIT_ASSERT_EQUAL(static_cast<double>(100000), fShadowSizeX);
double fShadowSizeY = 0.0;
xShape->getPropertyValue("ShadowSizeY") >>= fShadowSizeY;
CPPUNIT_ASSERT_EQUAL(static_cast<double>(100000), fShadowSizeY);
}
// Second text shape has no shadow
{
uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(1, 0));
bool bHasShadow = false;
xShape->getPropertyValue("Shadow") >>= bHasShadow;
CPPUNIT_ASSERT(!bHasShadow);
}
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf145162)
{
createSdImpressDoc("pptx/tdf145162.pptx");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDocContent = parseExport("ppt/slides/slide1.xml");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[2]/a:pPr/a:buNone");
// Before the fix, that tag was missing so PP put bullet to each para.
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testZeroIndentExport)
{
// Load the bugdoc and save to pptx then.
createSdImpressDoc("odp/testZeroIndent.odp");
save("Impress Office Open XML");
// There are 3 slides, get them
xmlDocUniquePtr pSlide1 = parseExport("ppt/slides/slide1.xml");
xmlDocUniquePtr pSlide2 = parseExport("ppt/slides/slide2.xml");
xmlDocUniquePtr pSlide3 = parseExport("ppt/slides/slide3.xml");
CPPUNIT_ASSERT(pSlide1);
CPPUNIT_ASSERT(pSlide2);
CPPUNIT_ASSERT(pSlide3);
// Each slide has 3 paragraphs, one full line, an empty and a normal para.
// Check the indent and bullet. These have to match with PP. Before the fix,
// they were different.
assertXPath(pSlide1, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[2]/a:pPr/a:buNone");
assertXPath(pSlide2, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[1]/a:pPr/a:buNone");
assertXPath(pSlide2, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[1]/a:pPr", "indent", "0");
assertXPath(pSlide2, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[2]/a:pPr/a:buNone");
assertXPath(pSlide2, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[2]/a:pPr", "indent", "0");
assertXPath(pSlide2, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[3]/a:pPr/a:buNone");
assertXPath(pSlide2, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[3]/a:pPr", "indent", "0");
assertXPath(pSlide3, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[1]/a:pPr", "indent", "0");
assertXPath(pSlide3, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[2]/a:pPr/a:buNone");
assertXPath(pSlide3, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[2]/a:pPr", "indent", "0");
assertXPath(pSlide3, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[3]/a:pPr", "indent", "0");
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf100348_convert_Fontwork2TextWarp)
{
createSdImpressDoc("odp/tdf100348_Fontwork2TextWarp.odp");
save("Impress Office Open XML");
// Resulting pptx has to contain the TextWarp shape
xmlDocUniquePtr pXmlDocContent = parseExport("ppt/slides/slide1.xml");
static constexpr OString sPathStart(
"/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:bodyPr/a:prstTxWarp"_ostr);
assertXPath(pXmlDocContent, sPathStart + "[@prst='textWave1']");
const OString sPathAdj(sPathStart + "/a:avLst/a:gd");
assertXPath(pXmlDocContent, sPathAdj + "[@name='adj1' and @fmla='val 18750']");
assertXPath(pXmlDocContent, sPathAdj + "[@name='adj2' and @fmla='val -7500']");
// Reloading has to get the Fontwork shape back
// TextPath makes a custom shape to a Fontwork shape, so must exist
uno::Reference<beans::XPropertySet> xShapeWavePropSet(getShapeFromPage(0, 0));
auto aGeomPropSeq = xShapeWavePropSet->getPropertyValue("CustomShapeGeometry")
.get<uno::Sequence<beans::PropertyValue>>();
auto aGeomPropVec
= comphelper::sequenceToContainer<std::vector<beans::PropertyValue>>(aGeomPropSeq);
OUString sName = "TextPath";
auto aIterator = std::find_if(
aGeomPropVec.begin(), aGeomPropVec.end(),
[sName](const beans::PropertyValue& rValue) { return rValue.Name == sName; });
CPPUNIT_ASSERT_MESSAGE("No TextPath", aIterator != aGeomPropVec.end());
// Type has to be same as in original document on roundtrip.
sName = "Type";
auto aIterator2 = std::find_if(
aGeomPropVec.begin(), aGeomPropVec.end(),
[sName](const beans::PropertyValue& rValue) { return rValue.Name == sName; });
CPPUNIT_ASSERT_MESSAGE("No Type", aIterator2 != aGeomPropVec.end());
OUString sOwnName;
aIterator2->Value >>= sOwnName;
CPPUNIT_ASSERT_EQUAL(OUString("fontwork-wave"), sOwnName);
// Adjustmentvalues need to be the same.
sName = "AdjustmentValues";
auto aIterator3 = std::find_if(
aGeomPropVec.begin(), aGeomPropVec.end(),
[sName](const beans::PropertyValue& rValue) { return rValue.Name == sName; });
CPPUNIT_ASSERT_MESSAGE("No AdjustmentValues", aIterator3 != aGeomPropVec.end());
uno::Sequence<drawing::EnhancedCustomShapeAdjustmentValue> aAdjValueSeq;
aIterator3->Value >>= aAdjValueSeq;
double fAdj1;
aAdjValueSeq[0].Value >>= fAdj1;
double fAdj2;
aAdjValueSeq[1].Value >>= fAdj2;
CPPUNIT_ASSERT_EQUAL(4050.0, fAdj1); // odp values, not pptx values
CPPUNIT_ASSERT_EQUAL(9180.0, fAdj2);
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf125573_FontWorkScaleX)
{
createSdImpressDoc("pptx/tdf125573_FontWorkScaleX.pptx");
save("Impress Office Open XML");
// Error was, that attribute 'fromWordArt' was ignored
// ensure, resulting pptx has fromWordArt="1" on textArchDown shape
xmlDocUniquePtr pXmlDocContent = parseExport("ppt/slides/slide1.xml");
assertXPath(pXmlDocContent,
"/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:bodyPr[@fromWordArt='1']");
// Error was, that text in legacy shapes of category "Follow Path" was not scaled to the path.
uno::Reference<beans::XPropertySet> xShapeArchProps(getShapeFromPage(0, 0));
awt::Rectangle aBoundRectArch;
xShapeArchProps->getPropertyValue(UNO_NAME_MISC_OBJ_BOUNDRECT) >>= aBoundRectArch;
// BoundRect is DPI dependent, thus allow some range.
// Expected width is 13139 in 96dpi and is 13106 in 120 dpi, for example
// (Without fix Expected less than: 85 Actual : 10432)
CPPUNIT_ASSERT_LESS(sal_Int32(85), std::abs(aBoundRectArch.Width - 13139));
// Error was, that text in shapes of category "Warp" was not scaled to the path.
uno::Reference<beans::XPropertySet> xShapeWaveProps(getShapeFromPage(0, 1));
awt::Rectangle aBoundRectWave;
xShapeWaveProps->getPropertyValue(UNO_NAME_MISC_OBJ_BOUNDRECT) >>= aBoundRectWave;
// BoundRect is DPI dependent, thus allow some range.
// Expected with is 11576 in 96dpt and is 11578 in 120dpi, for example
CPPUNIT_ASSERT_LESS(sal_Int32(85), std::abs(aBoundRectWave.Width - 11576));
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf99497_keepAppearanceOfCircleKind)
{
// Error was, that all CircleKind were exported to 'ellipse'.
// Resulting pptx has to contain the customshapes of the corresponding kind
// slide 1 ARC -> arc, slide 2 CUT -> chord, slide 3 SECTION -> pie
// Adjustment values need to exist and their values need to correspond to the
// original angles. Shape 'arc' needs to be unfilled.
createSdImpressDoc("odp/tdf99497_CircleKind.odp");
save("Impress Office Open XML");
// slide 1 45° -> adj1 = 20493903, 270° -> adj2 = 5400000, <a:noFill/> exists
xmlDocUniquePtr pXmlDocContent1 = parseExport("ppt/slides/slide1.xml");
static constexpr OString sPathStart1("/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:prstGeom"_ostr);
assertXPath(pXmlDocContent1, sPathStart1 + "[@prst='arc']");
const OString sPathAdj1(sPathStart1 + "/a:avLst/a:gd");
assertXPath(pXmlDocContent1, sPathAdj1 + "[@name='adj1' and @fmla='val 20493903']");
assertXPath(pXmlDocContent1, sPathAdj1 + "[@name='adj2' and @fmla='val 5400000']");
assertXPath(pXmlDocContent1, "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:noFill");
// slide 2 270° -> adj1 = 5400000, 180° -> adj2 = 10800000
xmlDocUniquePtr pXmlDocContent2 = parseExport("ppt/slides/slide2.xml");
static constexpr OString sPathStart2("/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:prstGeom"_ostr);
assertXPath(pXmlDocContent2, sPathStart2 + "[@prst='chord']");
const OString sPathAdj2(sPathStart2 + "/a:avLst/a:gd");
assertXPath(pXmlDocContent2, sPathAdj2 + "[@name='adj1' and @fmla='val 5400000']");
assertXPath(pXmlDocContent2, sPathAdj2 + "[@name='adj2' and @fmla='val 10800000']");
// slide 3 120° -> adj1 = 12600000, 30° -> adj2 = 20946396
xmlDocUniquePtr pXmlDocContent3 = parseExport("ppt/slides/slide3.xml");
static constexpr OString sPathStart3("/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:prstGeom"_ostr);
assertXPath(pXmlDocContent3, sPathStart3 + "[@prst='pie']");
const OString sPathAdj3(sPathStart3 + "/a:avLst/a:gd");
assertXPath(pXmlDocContent3, sPathAdj3 + "[@name='adj1' and @fmla='val 12600000']");
assertXPath(pXmlDocContent3, sPathAdj3 + "[@name='adj2' and @fmla='val 20946396']");
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf104792)
{
createSdImpressDoc("pptx/tdf104792-smart-art-animation.pptx");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDocContent = parseExport("ppt/slides/slide1.xml");
assertXPath(pXmlDocContent,
"/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst[1]/p:seq/p:cTn/p:childTnLst[1]/"
"p:par[1]/p:cTn/p:childTnLst[1]/p:par/p:cTn/p:childTnLst[1]/p:par/p:cTn/"
"p:childTnLst[1]/p:set/p:cBhvr/p:tgtEl/p:spTgt",
1);
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf90627)
{
createSdImpressDoc("odp/tdf90627.odp");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDocContent = parseExport("ppt/slides/slide1.xml");
// Don't export empty endCondLst without cond.
assertXPath(pXmlDocContent,
"/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst[1]/p:seq/p:cTn/p:childTnLst[1]/"
"p:par[2]/p:cTn/p:childTnLst[1]/p:par/p:cTn/p:childTnLst[1]/p:par/p:cTn/"
"p:endCondLst[not(*)]",
0);
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf104786)
{
createSdImpressDoc("pptx/tdf104786.pptx");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDocContent = parseExport("ppt/slides/slide2.xml");
// Don't export empty 'to'
assertXPath(pXmlDocContent,
"/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst[1]/p:seq/p:cTn/p:childTnLst[1]/"
"p:par[2]/p:cTn/p:childTnLst[1]/p:par/p:cTn/p:childTnLst[1]/p:par/p:cTn/"
"p:childTnLst/p:set[2]/p:to",
0);
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf118783)
{
createSdImpressDoc("odp/tdf118783.odp");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDocContent = parseExport("ppt/slides/slide1.xml");
OUString sAttributeName
= getXPathContent(pXmlDocContent, "//p:animRot/p:cBhvr/p:attrNameLst/p:attrName");
CPPUNIT_ASSERT_EQUAL(OUString("r"), sAttributeName);
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf104789)
{
createSdImpressDoc("pptx/tdf104789.pptx");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDocContent = parseExport("ppt/slides/slide1.xml");
OUString sAttributeName = getXPathContent(
pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/"
"p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/"
"p:childTnLst/p:set/p:cBhvr/p:attrNameLst/p:attrName");
CPPUNIT_ASSERT_EQUAL(OUString("style.opacity"), sAttributeName);
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testOpenDocumentAsReadOnly)
{
createSdImpressDoc("pptx/open-as-read-only.pptx");
SdXImpressDocument* pXImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
CPPUNIT_ASSERT(pXImpressDocument);
sd::DrawDocShell* pDocShell = pXImpressDocument->GetDocShell();
CPPUNIT_ASSERT(pDocShell->IsSecurityOptOpenReadOnly());
save("Impress Office Open XML");
pXImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
CPPUNIT_ASSERT(pXImpressDocument);
pDocShell = pXImpressDocument->GetDocShell();
CPPUNIT_ASSERT(pDocShell->IsSecurityOptOpenReadOnly());
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf118835)
{
createSdImpressDoc("odp/tdf118835.odp");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDocContent = parseExport("ppt/slides/slide1.xml");
assertXPath(pXmlDocContent, "(//p:animClr)[1]", "clrSpc", "rgb");
assertXPathContent(pXmlDocContent, "(//p:animClr)[1]//p:attrName", "style.color");
assertXPath(pXmlDocContent, "(//p:animClr)[1]//p:to/a:srgbClr", "val", "ed1c24");
assertXPath(pXmlDocContent, "(//p:animClr)[2]", "clrSpc", "rgb");
assertXPathContent(pXmlDocContent, "(//p:animClr)[2]//p:attrName", "stroke.color");
assertXPath(pXmlDocContent, "(//p:animClr)[2]//p:to/a:srgbClr", "val", "333399");
assertXPath(pXmlDocContent, "(//p:animClr)[3]", "clrSpc", "rgb");
assertXPathContent(pXmlDocContent, "(//p:animClr)[3]//p:attrName", "fillcolor");
assertXPath(pXmlDocContent, "(//p:animClr)[3]//p:to/a:srgbClr", "val", "fcd3c1");
assertXPath(pXmlDocContent, "(//p:animClr)[5]", "clrSpc", "hsl");
assertXPathContent(pXmlDocContent, "(//p:animClr)[5]//p:attrName", "fillcolor");
assertXPath(pXmlDocContent, "(//p:animClr)[5]//p:by/p:hsl", "h", "10800000");
assertXPath(pXmlDocContent, "(//p:animClr)[5]//p:by/p:hsl", "s", "0");
assertXPath(pXmlDocContent, "(//p:animClr)[5]//p:by/p:hsl", "l", "0");
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf118768)
{
createSdImpressDoc("odp/tdf118768-brake.odp");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDocContent = parseExport("ppt/slides/slide1.xml");
assertXPath(pXmlDocContent, "//p:anim[1]", "from", "(-#ppt_w/2)");
assertXPath(pXmlDocContent, "//p:anim[1]", "to", "(#ppt_x)");
assertXPath(pXmlDocContent, "//p:anim[2]", "from", "0");
assertXPath(pXmlDocContent, "//p:anim[2]", "to", "-1");
assertXPath(pXmlDocContent, "//p:anim[2]/p:cBhvr/p:cTn", "autoRev", "1");
assertXPath(pXmlDocContent, "//p:anim[3]", "by", "(#ppt_h/3+#ppt_w*0.1)");
assertXPath(pXmlDocContent, "//p:anim[3]/p:cBhvr/p:cTn", "autoRev", "1");
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf118836)
{
createSdImpressDoc("odp/tdf118836.odp");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDocContent = parseExport("ppt/slides/slide1.xml");
assertXPath(pXmlDocContent, "//p:animScale/p:by", "x", "250000");
assertXPath(pXmlDocContent, "//p:animScale/p:by", "y", "250000");
}
static double getAdjustmentValue(const uno::Reference<beans::XPropertySet>& xSet)
{
auto aGeomPropSeq
= xSet->getPropertyValue("CustomShapeGeometry").get<uno::Sequence<beans::PropertyValue>>();
auto aGeomPropVec
= comphelper::sequenceToContainer<std::vector<beans::PropertyValue>>(aGeomPropSeq);
auto aIterator = std::find_if(
aGeomPropVec.begin(), aGeomPropVec.end(),
[](const beans::PropertyValue& rValue) { return rValue.Name == "AdjustmentValues"; });
if (aIterator != aGeomPropVec.end())
{
uno::Sequence<drawing::EnhancedCustomShapeAdjustmentValue> aAdjustment;
double fResult = 0.0;
aIterator->Value >>= aAdjustment;
aAdjustment[0].Value >>= fResult;
return fResult;
}
return -1.0;
}
static bool getScaleXValue(const uno::Reference<beans::XPropertySet>& xSet)
{
bool bScaleX = false;
auto aGeomPropSeq
= xSet->getPropertyValue("CustomShapeGeometry").get<uno::Sequence<beans::PropertyValue>>();
auto aGeomPropVec
= comphelper::sequenceToContainer<std::vector<beans::PropertyValue>>(aGeomPropSeq);
auto aIterator = std::find_if(
aGeomPropVec.begin(), aGeomPropVec.end(),
[](const beans::PropertyValue& rValue) { return rValue.Name == "TextPath"; });
if (aIterator != aGeomPropVec.end())
{
uno::Sequence<beans::PropertyValue> aTextPathProperties;
aIterator->Value >>= aTextPathProperties;
auto aIterator2 = std::find_if(
std::cbegin(aTextPathProperties), std::cend(aTextPathProperties),
[](const beans::PropertyValue& rValue) { return rValue.Name == "ScaleX"; });
if (aIterator2 != std::cend(aTextPathProperties))
{
aIterator2->Value >>= bScaleX;
}
}
return bScaleX;
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf116350TextEffects)
{
createSdImpressDoc("pptx/tdf116350-texteffects.pptx");
// Default angle for ArchUp
uno::Reference<beans::XPropertySet> xShape0(getShapeFromPage(0, 0));
double fAdjust = getAdjustmentValue(xShape0);
CPPUNIT_ASSERT_EQUAL(180.0, fAdjust);
bool bScaleX = getScaleXValue(xShape0);
CPPUNIT_ASSERT_EQUAL(true, bScaleX);
// Default angle for ArchDown
uno::Reference<beans::XPropertySet> xShape14(getShapeFromPage(14, 0));
fAdjust = getAdjustmentValue(xShape14);
CPPUNIT_ASSERT_EQUAL(0.0, fAdjust);
bScaleX = getScaleXValue(xShape14);
CPPUNIT_ASSERT_EQUAL(true, bScaleX);
// Angle directly set
uno::Reference<beans::XPropertySet> xShape1(getShapeFromPage(1, 0));
fAdjust = getAdjustmentValue(xShape1);
CPPUNIT_ASSERT_EQUAL(213.25, fAdjust);
bScaleX = getScaleXValue(xShape1);
CPPUNIT_ASSERT_EQUAL(true, bScaleX);
// Export
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDocContent = parseExport("ppt/slides/slide1.xml");
assertXPath(pXmlDocContent, "//p:sp[1]/p:txBody/a:bodyPr/a:prstTxWarp", "prst", "textArchUp");
assertXPath(pXmlDocContent, "//p:sp[14]/p:txBody/a:bodyPr/a:prstTxWarp", "prst", "textCircle");
assertXPath(pXmlDocContent, "//p:sp[14]/p:spPr/a:solidFill/a:srgbClr", 0);
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf128096)
{
createSdImpressDoc("odp/tdf128096.odp");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDocContent1 = parseExport("ppt/slides/slide1.xml");
assertXPath(pXmlDocContent1,
"//p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:highlight/a:srgbClr", "val",
"ffff00");
// Check that underlined content is also highlighted
xmlDocUniquePtr pXmlDocContent2 = parseExport("ppt/slides/slide2.xml");
assertXPath(pXmlDocContent2,
"//p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:highlight/a:srgbClr", "val",
"ffff00");
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf120573)
{
createSdImpressDoc("pptx/tdf120573.pptx");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
assertXPath(pXmlDoc, "//p:sld/p:cSld/p:spTree/p:pic/p:nvPicPr/p:nvPr/a:audioFile", 1);
assertXPath(pXmlDoc, "//p:sld/p:cSld/p:spTree/p:pic/p:nvPicPr/p:nvPr/a:videoFile", 0);
xmlDocUniquePtr pXmlDocRels = parseExport("ppt/slides/_rels/slide1.xml.rels");
assertXPath(pXmlDocRels,
"(/rels:Relationships/rels:Relationship[@Target='../media/media1.wav'])[1]", "Type",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio");
xmlDocUniquePtr pXmlContentType = parseExport("[Content_Types].xml");
assertXPath(pXmlContentType,
"/ContentType:Types/ContentType:Override[@PartName='/ppt/media/media1.wav']",
"ContentType", "audio/x-wav");
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf119118)
{
createSdImpressDoc("pptx/tdf119118.pptx");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDocContent = parseExport("ppt/slides/slide1.xml");
assertXPath(pXmlDocContent, "//p:iterate", "type", "lt");
assertXPath(pXmlDocContent, "//p:tmAbs", "val", "200");
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf99213)
{
createSdImpressDoc("odp/tdf99213-target-missing.odp");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDocContent = parseExport("ppt/slides/slide1.xml");
// Number of nodes with p:attrNameLst was 3, including one that missed tgtEl
assertXPath(pXmlDocContent, "//p:attrNameLst", 2);
// Timenode that miss its target element should be filtered.
assertXPath(pXmlDocContent, "//p:attrNameLst/preceding-sibling::p:tgtEl", 2);
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testPotxExport)
{
// Create new document
createSdImpressDoc();
// Export as a POTM template
save("Impress Office Open XML Template");
// Load and check content type
xmlDocUniquePtr pContentTypes = parseExport("[Content_Types].xml");
CPPUNIT_ASSERT(pContentTypes);
assertXPath(pContentTypes,
"/ContentType:Types/ContentType:Override[@PartName='/ppt/presentation.xml']",
"ContentType",
"application/vnd.openxmlformats-officedocument.presentationml.template.main+xml");
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf44223)
{
createSdImpressDoc("pptx/tdf44223.pptx");
save("Impress Office Open XML");
std::unique_ptr<SvStream> const pStream1(
parseExportStream(maTempFile.GetURL(), "ppt/media/audio1.wav"));
CPPUNIT_ASSERT_EQUAL(sal_uInt64(11140), pStream1->remainingSize());
std::unique_ptr<SvStream> const pStream2(
parseExportStream(maTempFile.GetURL(), "ppt/media/audio2.wav"));
CPPUNIT_ASSERT_EQUAL(sal_uInt64(28074), pStream2->remainingSize());
xmlDocUniquePtr pXmlContentType = parseExport("[Content_Types].xml");
assertXPath(pXmlContentType,
"/ContentType:Types/ContentType:Override[@PartName='/ppt/media/audio1.wav']",
"ContentType", "audio/x-wav");
assertXPath(pXmlContentType,
"/ContentType:Types/ContentType:Override[@PartName='/ppt/media/audio2.wav']",
"ContentType", "audio/x-wav");
xmlDocUniquePtr pDoc1 = parseExport("ppt/slides/slide1.xml");
// tdf#124230 all nodes were under p:childTnLst, but event triggered nodes need
// to be under p:subTnLst, especially for audio to work correctly.
// Start condition: 0s after timenode id 5 begins.
assertXPath(pDoc1, "//p:subTnLst/p:audio/p:cMediaNode/p:cTn/p:stCondLst/p:cond", "evt",
"begin");
assertXPath(pDoc1, "//p:subTnLst/p:audio/p:cMediaNode/p:cTn/p:stCondLst/p:cond", "delay", "0");
assertXPath(pDoc1, "//p:subTnLst/p:audio/p:cMediaNode/p:cTn/p:stCondLst/p:cond/p:tn", "val",
"5");
xmlDocUniquePtr pDoc2 = parseExport("ppt/slides/slide2.xml");
assertXPath(pDoc2, "//p:transition/p:sndAc/p:stSnd/p:snd[@r:embed]", 2);
xmlDocUniquePtr pRels1 = parseExport("ppt/slides/_rels/slide1.xml.rels");
assertXPath(pRels1, "//rels:Relationship[@Id='rId1']", "Type",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio");
assertXPath(pRels1, "//rels:Relationship[@Id='rId1']", "Target", "../media/audio1.wav");
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf135843)
{
createSdImpressDoc("pptx/tdf135843_export.pptx");
save("Impress Office Open XML");
xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
static constexpr OString sPathStart(
"/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData/a:tbl"_ostr);
assertXPath(pXmlDoc, sPathStart + "/a:tr[1]/a:tc[1]/a:tcPr/a:lnL/a:solidFill");
assertXPath(pXmlDoc, sPathStart + "/a:tr[1]/a:tc[1]/a:tcPr/a:lnR/a:solidFill");
assertXPath(pXmlDoc, sPathStart + "/a:tr[1]/a:tc[1]/a:tcPr/a:lnT/a:solidFill");
assertXPath(pXmlDoc, sPathStart + "/a:tr[1]/a:tc[1]/a:tcPr/a:lnB/a:solidFill");
assertXPath(pXmlDoc, sPathStart + "/a:tr[2]/a:tc[1]/a:tcPr/a:lnL/a:solidFill");
assertXPath(pXmlDoc, sPathStart + "/a:tr[2]/a:tc[1]/a:tcPr/a:lnR/a:solidFill");
assertXPath(pXmlDoc, sPathStart + "/a:tr[2]/a:tc[1]/a:tcPr/a:lnT/a:solidFill");
assertXPath(pXmlDoc, sPathStart + "/a:tr[2]/a:tc[1]/a:tcPr/a:lnB/a:solidFill");
assertXPath(pXmlDoc, sPathStart + "/a:tr[3]/a:tc[1]/a:tcPr/a:lnL/a:solidFill");
assertXPath(pXmlDoc, sPathStart + "/a:tr[3]/a:tc[1]/a:tcPr/a:lnR/a:solidFill");
assertXPath(pXmlDoc, sPathStart + "/a:tr[3]/a:tc[1]/a:tcPr/a:lnT/a:solidFill");
assertXPath(pXmlDoc, sPathStart + "/a:tr[3]/a:tc[1]/a:tcPr/a:lnB/a:solidFill");
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */