/* -*- 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/.
*/
// Without the fix in place, this test would have failed with // Expected: transparence value: 100% // Actual : transparence value: 0%
CPPUNIT_ASSERT_EQUAL(sal_Int16(100), nTransparence1);
// Without the fix in place, this test would have failed with // Expected: transparence value: 100% // Actual : transparence value: 0%
CPPUNIT_ASSERT_EQUAL(sal_Int16(100), nTransparence2);
}
// Without the fix in place, this test would have failed with // Expected: placeholder height: 3726 // Actual : placeholder height: 3476
CPPUNIT_ASSERT_EQUAL(sal_Int32(3726), nHeight1);
// Without the fix in place, this test would have failed with // Expected: placeholder height: 3365 // Actual : placeholder height: 3116
CPPUNIT_ASSERT_EQUAL(sal_Int32(3365), nHeight2);
}
uno::Reference<container::XIndexAccess> xGroupShape(getShapeFromPage(0, 0),
uno::UNO_QUERY_THROW);
uno::Reference<drawing::XShape> xShape(xGroupShape->getByIndex(0), uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT(xShape.is()); // Without the fix in place, this test would have failed with // Expected: shape height: 3597 // Actual : shape height: 3
CPPUNIT_ASSERT_EQUAL(sal_Int32(3597), xShape->getSize().Height);
CPPUNIT_ASSERT_EQUAL(sal_Int32(6592), xShape->getSize().Width);
xShape.set(xGroupShape->getByIndex(1), uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT(xShape.is()); // Without the fix in place, this test would have failed with // Expected: shape height: 3597 // Actual : shape height: 3
CPPUNIT_ASSERT_EQUAL(sal_Int32(3597), xShape->getSize().Height);
CPPUNIT_ASSERT_EQUAL(sal_Int32(6402), xShape->getSize().Width);
}
// Without the fix in place, this test would have failed with // Expected: placeholder height: 2795 // Actual : placeholder height: 3435
CPPUNIT_ASSERT_EQUAL(sal_Int32(2795), nHeight1);
// Without the fix in place, this test would have failed with // Expected: placeholder height: 1271 // Actual : placeholder height: 11303
CPPUNIT_ASSERT_EQUAL(sal_Int32(1271), nHeight2);
}
CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf152186)
{
createSdImpressDoc("pptx/tdf152186.pptx");
saveAndReload(u"Impress MS PowerPoint 2007 XML"_ustr);
bool bHasShadow = bool(); const SdrPage* pPage = GetPage(1); for (size_t i = 0; i < pPage->GetObjCount(); ++i)
{
uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(i, 0));
CPPUNIT_ASSERT(xShape->getPropertyValue(u"Shadow"_ustr) >>= bHasShadow);
CPPUNIT_ASSERT(!bHasShadow);
}
}
// Without the fix in place, this test would have failed with // - Expected: Color: R:255 G:255 B:255 A:255 // - Actual : Color: R:161 G:70 B:126 A:0
CPPUNIT_ASSERT_EQUAL(COL_AUTO, nCharUnderlineColor);
// Check character color
Color nCharColor;
xShape->getPropertyValue(u"CharColor"_ustr) >>= nCharColor;
CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED, nCharColor);
}
Color nCharColor;
xPropSet->getPropertyValue(u"CharColor"_ustr) >>= nCharColor;
CPPUNIT_ASSERT_EQUAL(COL_AUTO, nCharColor);
xRun.set(getRunFromParagraph(1, xParagraph));
// Without the fix in place, this test would have failed with // - Expected: colored_text // - Actual : colored_text)
CPPUNIT_ASSERT_EQUAL(u"colored_text"_ustr, xRun->getString());
// Get first paragraph of the text
uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, xShape));
// Get first run of the paragraph
uno::Reference<text::XTextRange> xRun(getRunFromParagraph(0, xParagraph));
uno::Reference<beans::XPropertySet> xPropSet(xRun, uno::UNO_QUERY_THROW);
sal_Int16 nTransparency = 0;
xPropSet->getPropertyValue(u"CharTransparence"_ustr) >>= nTransparency;
// Import noFill color as 99% transparency
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(99), nTransparency);
}
// Get first paragraph of the text
uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, xShape));
// Get first run of the paragraph
uno::Reference<text::XTextRange> xRun(getRunFromParagraph(0, xParagraph));
uno::Reference<beans::XPropertySet> xPropSet(xRun, uno::UNO_QUERY_THROW);
sal_Int16 nTransparency = 0;
xPropSet->getPropertyValue(u"CharTransparence"_ustr) >>= nTransparency;
// First shape has red fill, but this should be overwritten by green group fill
{
SdrObject* const pObj = pPage->GetObj(0);
CPPUNIT_ASSERT_MESSAGE("Wrong object", pObj != nullptr); const XFillStyleItem& rStyleItem = pObj->GetMergedItem(XATTR_FILLSTYLE);
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rStyleItem.GetValue()); const XFillColorItem& rColorItem = pObj->GetMergedItem(XATTR_FILLCOLOR);
CPPUNIT_ASSERT_EQUAL(COL_LIGHTGREEN, rColorItem.GetColorValue());
} // Second shape has blue fill, but this should be overwritten by green group fill
{
SdrObject* const pObj = pPage->GetObj(0);
CPPUNIT_ASSERT_MESSAGE("Wrong object", pObj != nullptr); const XFillStyleItem& rStyleItem = pObj->GetMergedItem(XATTR_FILLSTYLE);
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rStyleItem.GetValue()); const XFillColorItem& rColorItem = pObj->GetMergedItem(XATTR_FILLCOLOR);
CPPUNIT_ASSERT_EQUAL(COL_LIGHTGREEN, rColorItem.GetColorValue());
}
}
sal_UCS4 aBullet2 = rNumFmt.GetNumRule().GetLevel(1).GetBulletChar(); // Without the fix in place, this test would have failed with // - Expected: 8211 // - Actual : 9679 // - Fails on level 2
CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsg.getStr(), sal_UCS4(0x2013), aBullet2);
CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf105150)
{
createSdImpressDoc("pptx/tdf105150.pptx"); const SdrPage* pPage = GetPage(1); const SdrObject* pObj = pPage->GetObj(1); auto& rFillStyleItem = pObj->GetMergedItem(XATTR_FILLSTYLE); // This was drawing::FillStyle_NONE, <p:sp useBgFill="1"> was ignored when // the slide didn't have an explicit background fill.
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, rFillStyleItem.GetValue()); auto& rFillBackgroundItem = pObj->GetMergedItem(XATTR_FILLUSESLIDEBACKGROUND);
CPPUNIT_ASSERT_EQUAL(true, rFillBackgroundItem.GetValue());
}
CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf123684)
{
createSdImpressDoc("pptx/tdf123684.pptx"); const SdrPage* pPage = GetPage(1); const SdrObject* pObj = pPage->GetObj(0); auto& rFillStyleItem = pObj->GetMergedItem(XATTR_FILLSTYLE); // Without the accompanying fix in place, this test would have failed with 'Expected: 0; Actual: // 1', i.e. the shape's fill was FillStyle_SOLID, making the text of the shape unreadable.
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, rFillStyleItem.GetValue());
}
CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf105150PPT)
{
createSdImpressDoc("ppt/tdf105150.ppt"); const SdrPage* pPage = GetPage(1); const SdrObject* pObj = pPage->GetObj(1); // This was drawing::FillStyle_NONE, the shape's mso_fillBackground was // ignored when the slide didn't have an explicit background fill. auto& rFillStyleItem = pObj->GetMergedItem(XATTR_FILLSTYLE);
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, rFillStyleItem.GetValue()); auto& rFillBackgroundItem = pObj->GetMergedItem(XATTR_FILLUSESLIDEBACKGROUND);
CPPUNIT_ASSERT_EQUAL(true, rFillBackgroundItem.GetValue());
}
CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf104445)
{ // Extra bullets were added to the first shape
createSdImpressDoc("pptx/tdf104445.pptx");
// First shape should not have bullet
{
uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0));
uno::Reference<text::XText> xText
= uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText();
CPPUNIT_ASSERT_MESSAGE("Not a text shape", xText.is());
uno::Reference<beans::XPropertySet> xPropSet(xText, uno::UNO_QUERY_THROW);
for (beans::PropertyValue const& rProp : aBulletProps)
{ if (rProp.Name == "NumberingType")
CPPUNIT_ASSERT_EQUAL(sal_Int16(style::NumberingType::NUMBER_NONE),
rProp.Value.get<sal_Int16>()); if (rProp.Name == "LeftMargin")
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rProp.Value.get<sal_Int32>());
}
} // Second shape should have bullet set
{
uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(1, 0));
uno::Reference<text::XText> xText
= uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText();
CPPUNIT_ASSERT_MESSAGE("Not a text shape", xText.is());
uno::Reference<beans::XPropertySet> xPropSet(xText, uno::UNO_QUERY_THROW);
/* Test checks that importing a PPT file with all supported fill patterns is * correctly imported as a tiled fill bitmap with the expected pattern.
*/
CPPUNIT_TEST_FIXTURE(SdImportTest2, testPatternImport)
{
createSdImpressDoc("ppt/FillPatterns.ppt");
CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf108925)
{ // Test document contains bulleting with too small bullet size (1%) which breaks the lower constraint // So it should be converted to the lowest allowed value (25%).
// Second object should be imported as an empty presentation shape
uno::Reference<beans::XPropertySet> xPresentationShape(xNotesPage->getByIndex(1),
uno::UNO_QUERY);
CPPUNIT_ASSERT(xPresentationShape.is()); bool bIsEmptyPresObject = false;
xPresentationShape->getPropertyValue(u"IsEmptyPresentationObject"_ustr) >>= bIsEmptyPresObject;
CPPUNIT_ASSERT(bIsEmptyPresObject);
}
// Without the fix in place, this test would have failed with // - Expected: 148 // - Actual : 444
CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(148),
pNumFmt->GetNumRule().GetLevel(0).GetGraphicSize().getWidth(),
tools::Long(1));
}
}
CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf114488)
{ // This doc has two images - one WMF and the other PNG (fallback image). // When loading this doc, the WMF image should be preferred over the PNG image.
uno::Reference<chart2::XDataSeriesContainer> xDSCnt(xCTCnt->getChartTypes()[0], uno::UNO_QUERY);
CPPUNIT_ASSERT_MESSAGE("failed to load data series", xDSCnt.is());
uno::Sequence<uno::Reference<chart2::XDataSeries>> aSeriesSeq(xDSCnt->getDataSeries());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Invalid Series count", static_cast<sal_Int32>(1),
aSeriesSeq.getLength());
// These Labels have custom position, so the exported LabelPlacement (reference point) by MSO is OUTSIDE/OUTEND // Check the first label const css::uno::Reference<css::beans::XPropertySet> aPropSet0(
aSeriesSeq[0]->getDataPointByIndex(0));
CPPUNIT_ASSERT(aPropSet0.is());
sal_Int32 aPlacement;
aPropSet0->getPropertyValue(u"LabelPlacement"_ustr) >>= aPlacement;
CPPUNIT_ASSERT_EQUAL(css::chart::DataLabelPlacement::OUTSIDE, aPlacement);
// Check the second label const css::uno::Reference<css::beans::XPropertySet> aPropSet1(
aSeriesSeq[0]->getDataPointByIndex(1));
CPPUNIT_ASSERT(aPropSet1.is());
aPropSet1->getPropertyValue(u"LabelPlacement"_ustr) >>= aPlacement;
CPPUNIT_ASSERT_EQUAL(css::chart::DataLabelPlacement::OUTSIDE, aPlacement);
// Check the third label const css::uno::Reference<css::beans::XPropertySet> aPropSet2(
aSeriesSeq[0]->getDataPointByIndex(2));
CPPUNIT_ASSERT(aPropSet2.is());
aPropSet2->getPropertyValue(u"LabelPlacement"_ustr) >>= aPlacement;
CPPUNIT_ASSERT_EQUAL(css::chart::DataLabelPlacement::OUTSIDE, aPlacement);
}
// 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);
// First paragraph has a 90% line spacing set on master slide
uno::Reference<text::XTextRange> xParagraph(getParagraphFromShape(0, xShape));
uno::Reference<beans::XPropertySet> xPropSet(xParagraph, uno::UNO_QUERY_THROW);
css::style::LineSpacing aSpacing;
xPropSet->getPropertyValue(u"ParaLineSpacing"_ustr) >>= aSpacing;
CPPUNIT_ASSERT_EQUAL(css::style::LineSpacingMode::PROP, aSpacing.Mode);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(90), aSpacing.Height);
// Second paragraph has a 125% line spacing set on slide layout
xParagraph.set(getParagraphFromShape(1, xShape));
xPropSet.set(xParagraph, uno::UNO_QUERY_THROW);
xPropSet->getPropertyValue(u"ParaLineSpacing"_ustr) >>= aSpacing;
CPPUNIT_ASSERT_EQUAL(css::style::LineSpacingMode::PROP, aSpacing.Mode);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(125), aSpacing.Height);
// Third paragraph has a 70% line spacing set directly on normal slide (master slide property is overridden)
xParagraph.set(getParagraphFromShape(2, xShape));
xPropSet.set(xParagraph, uno::UNO_QUERY_THROW);
xPropSet->getPropertyValue(u"ParaLineSpacing"_ustr) >>= aSpacing;
CPPUNIT_ASSERT_EQUAL(css::style::LineSpacingMode::PROP, aSpacing.Mode);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(70), aSpacing.Height);
// Fourth paragraph has a 190% line spacing set directly on normal slide (slide layout property is overridden)
xParagraph.set(getParagraphFromShape(3, xShape));
xPropSet.set(xParagraph, uno::UNO_QUERY_THROW);
xPropSet->getPropertyValue(u"ParaLineSpacing"_ustr) >>= aSpacing;
CPPUNIT_ASSERT_EQUAL(css::style::LineSpacingMode::PROP, aSpacing.Mode);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(190), aSpacing.Height);
}
CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf116899)
{ // This is a PPT created in Impress and roundtripped in PP, the key times become [1, -1] in PP, // a time of -1 (-1000) in PPT means key times have to be distributed evenly between 0 and 1
createSdImpressDoc("ppt/tdf116899.ppt");
uno::Reference<drawing::XDrawPagesSupplier> xDoc(mxComponent, uno::UNO_QUERY_THROW);
uno::Reference<drawing::XDrawPage> xPage(xDoc->getDrawPages()->getByIndex(0),
uno::UNO_QUERY_THROW);
uno::Reference<animations::XAnimationNodeSupplier> xAnimNodeSupplier(xPage,
uno::UNO_QUERY_THROW);
uno::Reference<animations::XAnimationNode> xRootNode(xAnimNodeSupplier->getAnimationNode());
std::vector<uno::Reference<animations::XAnimationNode>> aAnimVector;
anim::create_deep_vector(xRootNode, aAnimVector);
uno::Reference<animations::XAnimate> xNode(aAnimVector[8], uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Number of key times in the animation node isn't 2.", static_cast<sal_Int32>(2), xNode->getKeyTimes().getLength());
CPPUNIT_ASSERT_EQUAL_MESSAGE( "First key time in the animation node isn't 0, key times aren't normalized.", 0.,
xNode->getKeyTimes()[0]);
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Second key time in the animation node isn't 1, key times aren't normalized.", 1.,
xNode->getKeyTimes()[1]);
}
CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf77747)
{
createSdImpressDoc("ppt/tdf77747.ppt");
SdrTextObj* pTxtObj = DynCastSdrTextObj(GetPage(1)->GetObj(0));
CPPUNIT_ASSERT_MESSAGE("No text object", pTxtObj != nullptr); const SvxNumBulletItem* pNumFmt
= pTxtObj->GetOutlinerParaObject()->GetTextObject().GetParaAttribs(0).GetItem(
EE_PARA_NUMBULLET);
CPPUNIT_ASSERT(pNumFmt);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Bullet's suffix is wrong!", u"-"_ustr,
pNumFmt->GetNumRule().GetLevel(0).GetSuffix());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Bullet's numbering type is wrong!", SVX_NUM_NUMBER_HEBREW,
pNumFmt->GetNumRule().GetLevel(0).GetNumberingType());
}
CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf116266)
{
createSdImpressDoc("odp/tdf116266.odp");
SdXImpressDocument* pXImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
CPPUNIT_ASSERT(pXImpressDocument);
SdDrawDocument* pDoc = pXImpressDocument->GetDoc();
sfx2::LinkManager* rLinkManager = pDoc->GetLinkManager(); // The document contains one SVG stored as a link.
CPPUNIT_ASSERT_EQUAL(size_t(1), rLinkManager->GetLinks().size());
}
// Without the fix in place, this test would have failed with // - Expected: 5937 // - Actual : 0
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(5937), aCrop.Bottom);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), aCrop.Left);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), aCrop.Right);
}
CPPUNIT_TEST_FIXTURE(SdImportTest2, testtdf163852)
{ // Check that the svg image is cropped
createSdImpressDoc("pptx/tdf163852.pptx");
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), aCrop.Top);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), aCrop.Left);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), aCrop.Right); // Without the fix in place, this test would have failed with // - Expected: 702 // - Actual : 0
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(702), aCrop.Bottom);
}
CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf149785)
{ // Without the fix in place, this test would have failed to load the file
createSdImpressDoc("pptx/tdf149785.pptx");
¤ 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.0.27Bemerkung:
(vorverarbeitet)
¤
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.