/* -*- 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/.
*/
class SdOOXMLExportTest2 : public SdModelTestBase
{ public:
SdOOXMLExportTest2()
: SdModelTestBase(u"/sd/qa/unit/data/"_ustr)
{
}
};
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testRepeatBitmapMode)
{ // FIXME: the DPI check should be removed when either (1) the test is fixed to work with // non-default DPI; or (2) unit tests on Windows are made to use svp VCL plugin. if (!IsDefaultDPI()) return;
createSdImpressDoc("odp/repeatBitmapMode.odp");
save(u"Impress Office Open XML"_ustr);
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testBnc822341)
{ // Check import / export of embedded text document
createSdImpressDoc("odp/bnc822341.odp");
save(u"Impress Office Open XML"_ustr);
// Export an LO specific ole object (imported from an ODP document)
{
xmlDocUniquePtr pXmlDocCT = parseExport(u"[Content_Types].xml"_ustr);
assertXPath(pXmlDocCT, "/ContentType:Types/ContentType:Override[@ContentType='application/" "vnd.openxmlformats-officedocument.wordprocessingml.document']", "PartName", u"/ppt/embeddings/oleObject1.docx");
// Export an MS specific ole object (imported from a PPTX document)
{
xmlDocUniquePtr pXmlDocCT = parseExport(u"[Content_Types].xml"_ustr);
assertXPath(pXmlDocCT, "/ContentType:Types/ContentType:Override[@ContentType='application/" "vnd.openxmlformats-officedocument.wordprocessingml.document']", "PartName", u"/ppt/embeddings/oleObject1.docx");
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testMathObject)
{ // Check import / export of math object
createSdImpressDoc("odp/math.odp");
save(u"Impress Office Open XML"_ustr);
// Export an LO specific ole object (imported from an ODP document)
{
xmlDocUniquePtr pXmlDocContent = parseExport(u"ppt/slides/slide1.xml"_ustr);
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/mc:AlternateContent/mc:Choice", "Requires", u"a14");
assertXPathContent(pXmlDocContent, "/p:sld/p:cSld/p:spTree/mc:AlternateContent/mc:Choice/p:sp/p:txBody/a:p/" "a14:m/m:oMath/m:r[1]/m:t",
u"a");
// Export an MS specific ole object (imported from a PPTX document)
{
xmlDocUniquePtr pXmlDocContent = parseExport(u"ppt/slides/slide1.xml"_ustr);
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/mc:AlternateContent/mc:Choice", "Requires", u"a14");
assertXPathContent(pXmlDocContent, "/p:sld/p:cSld/p:spTree/mc:AlternateContent/mc:Choice/p:sp/p:txBody/a:p/" "a14:m/m:oMath/m:r[1]/m:t",
u"a");
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testTdf119015)
{
createSdImpressDoc("pptx/tdf119015.pptx");
saveAndReload(u"Impress Office Open XML"_ustr);
const SdrPage* pPage = GetPage(1);
sdr::table::SdrTableObj* pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
CPPUNIT_ASSERT(pTableObj); // The position was previously not properly initialized: (0, 0, 100, 100)
CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(6991, 6902), Size(14099, 2000)),
pTableObj->GetLogicRect());
uno::Reference<table::XTable> xTable(pTableObj->getTable());
// Test that we actually have three cells: this threw css.lang.IndexOutOfBoundsException
uno::Reference<text::XTextRange> xTextRange(xTable->getCellByPosition(1, 0),
uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL(u"A3"_ustr, xTextRange->getString());
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testTdf123090)
{
createSdImpressDoc("pptx/tdf123090.pptx");
saveAndReload(u"Impress Office Open XML"_ustr);
// Test that we actually have two cells: this threw css.lang.IndexOutOfBoundsException
uno::Reference<text::XTextRange> xTextRange(xTable->getCellByPosition(1, 0),
uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL(u"aaa"_ustr, xTextRange->getString());
// Without the fix in place, this test would have failed with // - Expected: Color: R:0 G:0 B:0 A:0 // - Actual : Color: R:255 G:255 B:255 A:0
CPPUNIT_ASSERT_EQUAL(COL_BLACK, nColor);
}
// OVAL VERTICAL - cannot be exported to PPTX so fallback to circle //CPPUNIT_ASSERT(checkTransitionOnPage(xDoc, 76, TransitionType::ELLIPSEWIPE, TransitionSubType::VERTICAL));
CPPUNIT_ASSERT(
checkTransitionOnPage(xDoc, 76, TransitionType::ELLIPSEWIPE, TransitionSubType::CIRCLE));
}
size_t i = 0; while (i < SAL_N_ELEMENTS(sShapeTypeAndValues))
{
OString sType(sShapeTypeAndValues[i++]); for (size_t j = 1; i < SAL_N_ELEMENTS(sShapeTypeAndValues)
&& o3tl::starts_with(sShapeTypeAndValues[i], "adj");
++j)
{
OString sXPath
= "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:prstGeom[@prst='_T_']/a:avLst/a:gd[_N_]"_ostr
.replaceFirst(sT, sType)
.replaceFirst(sN, OString::number(j));
assertXPath(pXmlDocCT, sXPath, "name",
OUString::createFromAscii(sShapeTypeAndValues[i++]));
assertXPath(pXmlDocCT, sXPath, "fmla",
OUString::createFromAscii(sShapeTypeAndValues[i++]));
}
}
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testTdf92527)
{ // We draw a diamond in an empty document. // If custom shape has name and preset information in OOXML, should be export as preset shape.
createSdImpressDoc("empty.fodp");
uno::Reference<drawing::XDrawPage> xPage1(getPage(0));
uno::Reference<css::lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY);
uno::Reference<drawing::XShape> xShape1(
xFactory->createInstance(u"com.sun.star.drawing.CustomShape"_ustr), uno::UNO_QUERY);
xPage1->add(xShape1);
xShape1->setSize(awt::Size(10000, 10000));
xShape1->setPosition(awt::Point(1000, 1000));
uno::Sequence<beans::PropertyValue> aShapeGeometry(comphelper::InitPropertySequence({
{ "Type", uno::Any(u"diamond"_ustr) },
}));
uno::Reference<beans::XPropertySet> xPropertySet1(xShape1, uno::UNO_QUERY);
xPropertySet1->setPropertyValue(u"CustomShapeGeometry"_ustr, uno::Any(aShapeGeometry));
for (sal_uInt16 i = 0; i <= 3; ++i)
{
uno::Reference<text::XTextField> xField = getTextFieldFromPage(0, 0, i, 0);
CPPUNIT_ASSERT_MESSAGE("Where is the text field?", xField.is());
uno::Reference<beans::XPropertySet> xPropSet(xField, uno::UNO_QUERY_THROW);
sal_Int32 nNumFmt;
xPropSet->getPropertyValue(u"FileFormat"_ustr) >>= nNumFmt; switch (i)
{ case 0: // Path/File name
CPPUNIT_ASSERT_EQUAL_MESSAGE("File formats don't match", sal_Int32(0), nNumFmt); break; case 1: // Path
CPPUNIT_ASSERT_EQUAL_MESSAGE("File formats don't match", sal_Int32(1), nNumFmt); break; case 2: // File name without extension
CPPUNIT_ASSERT_EQUAL_MESSAGE("File formats don't match", sal_Int32(2), nNumFmt); break; case 3: // File name with extension
CPPUNIT_ASSERT_EQUAL_MESSAGE("File formats don't match", sal_Int32(3), nNumFmt);
}
}
}
uno::Reference<text::XTextField> xField = getTextFieldFromPage(0, 0, 0, 0);
CPPUNIT_ASSERT_MESSAGE("Where is the text field?", xField.is());
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testTdf99224)
{
createSdImpressDoc("odp/tdf99224.odp");
saveAndReload(u"Impress Office Open XML"_ustr);
uno::Reference<drawing::XDrawPage> xPage = getPage(0); // This was 0: the image with text was lost on export.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xPage->getCount());
}
// Without the fix to tdf#168754 the special characters would cause errors during parsing
assertXPathContent(pXmlDocRels, "/p:cmLst/p:cm/p:text",
u"Test for creator-initials\n< > & \"'");
// Without the fix in place, the comment position would have been 0,0
assertXPath(pXmlDocRels, "/p:cmLst/p:cm/p:pos", "x", u"2032");
assertXPath(pXmlDocRels, "/p:cmLst/p:cm/p:pos", "y", u"1029");
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testTdf105739)
{ // Gradient was lost during saving to ODP
createSdImpressDoc("pptx/tdf105739.pptx");
save(u"impress8"_ustr);
uno::Reference<drawing::XDrawPage> xPage = getPage(0);
uno::Reference<beans::XPropertySet> xPropSet(xPage, uno::UNO_QUERY);
uno::Any aAny = xPropSet->getPropertyValue(u"Background"_ustr);
CPPUNIT_ASSERT(aAny.hasValue()); if (aAny.hasValue())
{
uno::Reference<beans::XPropertySet> aXBackgroundPropSet;
aAny >>= aXBackgroundPropSet;
// Test fill type
drawing::FillStyle aFillStyle(drawing::FillStyle_NONE);
aXBackgroundPropSet->getPropertyValue(u"FillStyle"_ustr) >>= aFillStyle;
CPPUNIT_ASSERT_EQUAL(int(drawing::FillStyle_GRADIENT), static_cast<int>(aFillStyle));
// Test gradient properties
css::awt::Gradient2 aFillGradient;
aXBackgroundPropSet->getPropertyValue(u"FillGradient"_ustr) >>= aFillGradient;
// MCGR: Use the completely imported gradient to check for correctness const basegfx::BColorStops aColorStops
= model::gradient::getColorStopsFromUno(aFillGradient.ColorStops);
saveAndReload(u"impress8"_ustr);
uno::Reference<drawing::XDrawPagesSupplier> xDoc(mxComponent, uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be exactly one page", static_cast<sal_Int32>(1),
xDoc->getDrawPages()->getCount());
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testPptmContentType)
{
createSdImpressDoc("pptm/macro.pptm");
save(u"Impress MS PowerPoint 2007 XML VBA"_ustr);
// Assert that the content type is the one of PPTM
xmlDocUniquePtr pXmlContentType = parseExport(u"[Content_Types].xml"_ustr);
assertXPath(pXmlContentType, "/ContentType:Types/ContentType:Override[@PartName='/ppt/presentation.xml']", "ContentType", u"application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml");
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testPptmVBAStream)
{
createSdImpressDoc("pptm/macro.pptm");
save(u"Impress MS PowerPoint 2007 XML VBA"_ustr);
uno::Reference<packages::zip::XZipFileAccess2> xNameAccess
= packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory),
maTempFile.GetURL()); // This failed: VBA stream was not roundtripped
CPPUNIT_ASSERT(xNameAccess->hasByName(u"ppt/vbaProject.bin"_ustr));
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testTdf111863)
{
createSdImpressDoc("pptx/tdf111863.pptx");
save(u"Impress Office Open XML"_ustr);
// check that transition attribute didn't change from 'out' to 'in'
xmlDocUniquePtr pXmlDocContent = parseExport(u"ppt/slides/slide1.xml"_ustr);
assertXPath(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:animEffect", "transition", u"out");
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testTdf111518)
{
createSdImpressDoc("pptx/tdf111518.pptx");
save(u"Impress Office Open XML"_ustr);
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[5]/p:spPr/a:custGeom/a:pathLst/a:path/a:close", 0);
assertXPathNoAttribute(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[5]/p:spPr/a:ln", "cap"); // by default it is "flat" cap style
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[5]/p:spPr/a:ln/a:bevel", 1);
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[6]/p:spPr/a:custGeom/a:pathLst/a:path/a:close", 0);
assertXPathNoAttribute(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[5]/p:spPr/a:ln", "cap"); // by default it is "flat" cap style
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[6]/p:spPr/a:ln/a:round", 1);
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testTdf106867)
{
createSdImpressDoc("pptx/tdf106867.pptx");
save(u"Impress Office Open XML"_ustr);
const SdrPage* pPage = GetPage(1);
// first check that we have the media object const SdrMediaObj* pMediaObj = dynamic_cast<SdrMediaObj*>(pPage->GetObj(2));
CPPUNIT_ASSERT_MESSAGE("no media object", pMediaObj != nullptr);
CPPUNIT_ASSERT_EQUAL(u"vnd.sun.star.Package:ppt/media/media1.avi"_ustr, pMediaObj->getURL());
// additional checks of the output file
uno::Reference<packages::zip::XZipFileAccess2> xNameAccess
= packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory),
maTempFile.GetURL()); // check that the document contains the video stream
CPPUNIT_ASSERT(xNameAccess->hasByName(u"ppt/media/media1.avi"_ustr));
// both the ooxml and the extended markup
xmlDocUniquePtr pXmlDocContent = parseExport(u"ppt/slides/slide1.xml"_ustr);
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:pic/p:nvPicPr/p:nvPr/a:videoFile");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:pic/p:nvPicPr/p:nvPr/p:extLst/p:ext/p14:media");
// target the shape with the video in the command
assertXPath(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:cmd/" "p:cBhvr/p:tgtEl/p:spTgt", "spid", u"61");
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testTdf112280)
{
createSdImpressDoc("pptx/tdf112280.pptx");
save(u"Impress Office Open XML"_ustr);
// check the animRot value
xmlDocUniquePtr pXmlDocContent = parseExport(u"ppt/slides/slide1.xml"_ustr);
assertXPath(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:animRot", "by", u"21600000");
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testTdf112088)
{
createSdImpressDoc("pptx/tdf112088.pptx");
save(u"Impress Office Open XML"_ustr);
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testTdf112552)
{ // Background fill was not displayed, but it was because of the wrong geometry
createSdImpressDoc("odp/tdf112552.odp");
save(u"Impress Office Open XML"_ustr);
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testTdf112557)
{ // Subtitle shape should be skipped by export.
createSdImpressDoc("odp/tdf112557.odp");
save(u"Impress Office Open XML"_ustr);
xmlDocUniquePtr pXmlDocContent = parseExport(u"ppt/slideMasters/slideMaster1.xml"_ustr);
assertXPath(pXmlDocContent, "/p:sldMaster/p:cSld/p:spTree/p:sp", 2); // title and object
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testTdf128049)
{
createSdImpressDoc("odp/tdf128049.odp");
save(u"Impress Office Open XML"_ustr);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.