/* -*- 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");
CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf149985)
{ // Without the fix in place, this test would have failed to load the file
createSdImpressDoc("pptx/tdf149985.pptx");
CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf150770)
{ // Without the fix in place, this test would have failed to load the file
createSdImpressDoc("pptx/tdf150770.pptx");
uno::Reference<drawing::XDrawPagesSupplier> xDoc(mxComponent, uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xDoc->getDrawPages()->getCount());
}
CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf120028)
{ // Check that the text shape has 4 columns.
createSdImpressDoc("pptx/tdf120028.pptx");
uno::Reference<drawing::XDrawPagesSupplier> xDoc(mxComponent, uno::UNO_QUERY);
CPPUNIT_ASSERT(xDoc.is());
auto retVal = xPresentationProps->getPropertyValue(u"Pause"_ustr); return retVal.get<sal_Int32>();
};
// 1. Check that presentation:pause attribute is imported correctly
CPPUNIT_ASSERT_EQUAL(sal_Int32(10), GetPause(u"odp/loopPause10.odp"_ustr));
// 2. ODF compliance: if presentation:pause attribute is absent, it must be treated as 0
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), GetPause(u"odp/loopNoPause.odp"_ustr));
// 3. Import PPT: pause should be 0
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), GetPause(u"ppt/loopNoPause.ppt"_ustr));
}
// Check that we import "loop" attribute of the presentation, and don't introduce any pauses
CPPUNIT_ASSERT(bEndlessVal);
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nPauseVal);
}
CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf122899)
{ // tdf122899 FILEOPEN: ppt: old kind arc from MS Office 97 is broken // Error was, that the path coordinates of a mso_sptArc shape were read as sal_Int16 // although they are unsigned 16 bit. This leads to wrong positions of start and end // point and results to a huge shape width in the test document.
createSdImpressDoc("ppt/tdf122899_Arc_90_to_91_clockwise.ppt");
uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent,
uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_MESSAGE("Could not get XDrawPagesSupplier", xDrawPagesSupplier.is());
uno::Reference<drawing::XDrawPages> xDrawPages(xDrawPagesSupplier->getDrawPages());
uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(0), uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_MESSAGE("Could not get xDrawPage", xDrawPage.is());
uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
CPPUNIT_ASSERT_MESSAGE("Could not get xShape", xShape.is());
awt::Rectangle aFrameRect;
uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY);
CPPUNIT_ASSERT_MESSAGE("Could not get the shape properties", xShapeProps.is());
xShapeProps->getPropertyValue(UNO_NAME_MISC_OBJ_FRAMERECT) >>= aFrameRect; // original width is 9cm, add some tolerance
CPPUNIT_ASSERT_LESS(static_cast<sal_Int32>(9020), aFrameRect.Width);
}
bool bTheme = false; for (beans::PropertyValue const& prop : aGrabBag)
{ if (prop.Name == "OOXTheme")
{
bTheme = true;
uno::Reference<xml::dom::XDocument> aThemeDom;
CPPUNIT_ASSERT(prop.Value >>= aThemeDom); // PropertyValue of proper type
CPPUNIT_ASSERT(aThemeDom); // Reference not empty
}
}
CPPUNIT_ASSERT(bTheme); // Grab Bag has all the expected elements
}
CPPUNIT_TEST_FIXTURE(SdImportTest2, testCropToShape)
{
createSdImpressDoc("pptx/crop-to-shape.pptx");
uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent,
uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_MESSAGE("Could not get XDrawPagesSupplier", xDrawPagesSupplier.is());
uno::Reference<drawing::XDrawPages> xDrawPages(xDrawPagesSupplier->getDrawPages());
uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(0), uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_MESSAGE("Could not get xDrawPage", xDrawPage.is());
uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(u"com.sun.star.drawing.CustomShape"_ustr, xShape->getShapeType());
CPPUNIT_ASSERT_MESSAGE("Could not get xShape", xShape.is());
uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY);
css::drawing::FillStyle fillStyle;
xShapeProps->getPropertyValue(u"FillStyle"_ustr) >>= fillStyle;
CPPUNIT_ASSERT_EQUAL(css::drawing::FillStyle_BITMAP, fillStyle);
css::drawing::BitmapMode bitmapmode;
xShapeProps->getPropertyValue(u"FillBitmapMode"_ustr) >>= bitmapmode;
CPPUNIT_ASSERT_EQUAL(css::drawing::BitmapMode_STRETCH, bitmapmode);
}
// The rest characters that do not use Wingding.
CPPUNIT_ASSERT(xTextCursor->goRight(45, true));
xPropSet->getPropertyValue(u"CharFontName"_ustr) >>= aCharFontName;
CPPUNIT_ASSERT(aCharFontName != "Wingdings");
}
CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf134210CropPosition)
{ // We are testing crop position of bitmap in custom shapes. We should see only green with proper fix.
// Without the accompanying fix in place, this test would have failed with: // - Expected: Color: R:132 G:132 B:132 A:0 // - Actual : Color: R:21 G:170 B:236 A:0 // i.e. the image color was blue instead of grey.
CPPUNIT_ASSERT_EQUAL(Color(0x848484), aBitmap.GetPixelColor(0, 0));
}
CPPUNIT_TEST_FIXTURE(SdImportTest2, testCropToZero)
{ // Must not crash because of division by zero // Also must not fail assertions because of passing negative value to CropQuotientsFromSrcRect
createSdImpressDoc("pptx/croppedTo0.pptx");
}
// Without the accompanying fix in place, this test would have failed with: // - Expected: 7885 // - Actual : 4595 // i.e. the table height wasn't corrected by expanding less than minimum sized rows.
CPPUNIT_ASSERT_EQUAL(sal_Int32(7885), xTableShape->getSize().Height);
}
CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf89928BlackWhiteThreshold)
{ // A slide with two graphics, one with color HSV{0,0,74%} and one with HSV{0,0,76%} // where both have an applied 75% Black/White Color Effect.
// Without the accompanying fix in place, this test would have failed with: // - Expected: Color: R:0 G:0 B:0 A:0 // - Actual : Color: R:189 G:189 B:189 A:0
CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency, 0x000000), aBitmap.GetPixelColor(0, 0));
}
// Second graphic should appear white
{
uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(1, 0), uno::UNO_SET_THROW);
uno::Reference<graphic::XGraphic> xGraphic;
xShape->getPropertyValue(u"Graphic"_ustr) >>= xGraphic;
CPPUNIT_ASSERT(xGraphic.is());
Color nCharColor;
xPropSet->getPropertyValue(u"CharColor"_ustr) >>= nCharColor; // Without the accompanying fix in place, this test would have failed with: // - Expected: Color: R:255 G:255 B:254 A:255 // - Actual : Color: R:255 G:255 B:255 A:255 // i.e. fully transparent white text color was interpreted as COL_AUTO
CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency, 0xFFFFFFFE), nCharColor);
}
// Spacing doesn't change when it is scaled
CPPUNIT_ASSERT_EQUAL(sal_Int32(3175), pNumFmt->GetNumRule().GetLevel(0).GetAbsLSpace());
CPPUNIT_ASSERT_EQUAL(sal_Int32(-3175),
pNumFmt->GetNumRule().GetLevel(0).GetFirstLineOffset());
}
}
CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf149588TransparentSolidFill)
{
createSdImpressDoc("pptx/tdf149588_transparentSolidFill.pptx");
saveAndReload(u"Impress MS PowerPoint 2007 XML"_ustr);
Color nCharColor;
xPropSet->getPropertyValue(u"CharColor"_ustr) >>= nCharColor; // Without the accompanying fix in place, this test would have failed with: // - Expected: Color: R:99 G:99 B:99 A 51 (T:204) // - Actual : Color: R:99 G:99 B:99 A: 255 (T: 0)
CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency, 0xCC636363), nCharColor);
}
CPPUNIT_TEST_FIXTURE(SdImportTest2, testOverflowBehaviorClip)
{
createSdImpressDoc("odp/style-overflow-behavior-clip.fodp");
{
uno::Reference<beans::XPropertySet> xPropSet(getShapeFromPage(0, 0)); // Without the accompanying fix in place, this test would have failed with: // - Expected: 1 // - Actual : 0
CPPUNIT_ASSERT_EQUAL( true, xPropSet->getPropertyValue(u"TextClipVerticalOverflow"_ustr).get<bool>());
}
CPPUNIT_TEST_FIXTURE(SdImportTest2, test_srcRect_smallNegBound)
{ // Given a cropped custom shape, with a srcRect having a small negative value in one of bounds
createSdImpressDoc("pptx/tdf153008-srcRect-smallNegBound.pptx");
// Properly cropped bitmap should have black pixels close to left edge, near vertical center. // Before the fix, the gear was distorted, and this area was white. auto yMiddle = aBitmap.GetSizePixel().Height() / 2; auto x5Percent = aBitmap.GetSizePixel().Width() / 20;
CPPUNIT_ASSERT(aBitmap.GetPixelColor(x5Percent, yMiddle).IsDark()); // Just in case, check that the corner is bright (it is in fact yellow)
CPPUNIT_ASSERT(aBitmap.GetPixelColor(0, 0).IsBright());
}
CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf153012)
{ // Given a chart with a data point with solid fill of "Background 1, Darker 15%" color, // where the 'bg1' is mapped in the slide to "dk1", but in the chart to "lt1":
createSdImpressDoc("pptx/chart_pt_color_bg1.pptx");
css::uno::Reference<css::beans::XPropertySet> xPropSet1(aSeriesSeq[0]->getDataPointByIndex(1),
uno::UNO_SET_THROW);
Color aFillColor;
xPropSet1->getPropertyValue(u"FillColor"_ustr) >>= aFillColor; // The color must arrive correctly. Without the fix, it would fail: // - Expected: rgba[d9d9d9ff] // - Actual : rgba[000000ff]
CPPUNIT_ASSERT_EQUAL(Color(0xd9d9d9), aFillColor);
}
CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf161023)
{ // Given a shape with three paragraphs (18pt), all directly assigned a smaller font (10pt)
createSdImpressDoc("odp/tdf161023.fodp"); auto shape = getShapeFromPage(0, 0);
// 1st paragraph, not empty
{ auto paragraph(getParagraphFromShape(0, shape));
CPPUNIT_ASSERT_EQUAL(u"a"_ustr, paragraph->getString()); auto run(getRunFromParagraph(0, paragraph));
CPPUNIT_ASSERT_EQUAL(u"a"_ustr, run->getString());
uno::Reference<beans::XPropertySet> xPropSet(run, uno::UNO_QUERY_THROW); double fCharHeight = 0;
xPropSet->getPropertyValue(u"CharHeight"_ustr) >>= fCharHeight;
CPPUNIT_ASSERT_EQUAL(10.0, fCharHeight); // No more runs
CPPUNIT_ASSERT_THROW(getRunFromParagraph(1, paragraph), container::NoSuchElementException);
}
// Empty 2nd paragraph, consisting of a single span: this span was treated as "paragraph mark"
{ auto paragraph(getParagraphFromShape(1, shape));
CPPUNIT_ASSERT_EQUAL(u""_ustr, paragraph->getString()); auto run(getRunFromParagraph(0, paragraph));
CPPUNIT_ASSERT_EQUAL(u""_ustr, run->getString());
uno::Reference<beans::XPropertySet> xPropSet(run, uno::UNO_QUERY_THROW); double fCharHeight = 0;
xPropSet->getPropertyValue(u"CharHeight"_ustr) >>= fCharHeight; // Without the fix, this would fail with // - Expected: 10 // - Actual : 18
CPPUNIT_ASSERT_EQUAL(10.0, fCharHeight); // No more runs
CPPUNIT_ASSERT_THROW(getRunFromParagraph(1, paragraph), container::NoSuchElementException);
}
// 3rd paragraph, not empty
{ auto paragraph(getParagraphFromShape(2, shape));
CPPUNIT_ASSERT_EQUAL(u"c"_ustr, paragraph->getString()); auto run(getRunFromParagraph(0, paragraph));
CPPUNIT_ASSERT_EQUAL(u"c"_ustr, run->getString());
uno::Reference<beans::XPropertySet> xPropSet(run, uno::UNO_QUERY_THROW); double fCharHeight = 0;
xPropSet->getPropertyValue(u"CharHeight"_ustr) >>= fCharHeight;
CPPUNIT_ASSERT_EQUAL(10.0, fCharHeight); // No more runs
CPPUNIT_ASSERT_THROW(getRunFromParagraph(1, paragraph), container::NoSuchElementException);
}
}
CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf161430)
{ // Without the bug fix this opens with the classic solid 'blue' background used in "Outline 1" // as seen in slide 3
createSdImpressDoc("odp/tdf161430.odp");
SdXImpressDocument* pXImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
CPPUNIT_ASSERT(pXImpressDocument);
SdDrawDocument* pDoc = pXImpressDocument->GetDoc();
CPPUNIT_TEST_FIXTURE(SdImportTest2, tdf158512)
{ // First shape on first slide should have no fill to avoid hiding background
createSdImpressDoc("pptx/tdf158512.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.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.