[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - oox/source sd/qa
oox/source/drawingml/textfield.cxx | 23 --- oox/source/export/drawingml.cxx|4 +++- sd/qa/unit/data/odp/numfmt.odp |binary sd/qa/unit/data/pptx/numfmt.pptx |binary sd/qa/unit/export-tests-ooxml2.cxx | 32 5 files changed, 35 insertions(+), 24 deletions(-) New commits: commit cfec09ebd15a301555a7c3d01bc0ed25aafc2dcc Author: Sarper Akdemir AuthorDate: Tue Jun 29 13:33:52 2021 +0300 Commit: Jan Holesovsky CommitDate: Wed Jun 30 10:09:22 2021 +0200 tdf#59323 tdf#142221: fix pptx datetime import export format fixed some problems from the original implementation of pptx datetime field formatting (2b0669eec0d86e973a7d8def8744c522bbf8af8b) also the comments on tests seemed to be based on en-IN which seems to differ a lot for SvxDateFormat::StdBig. So converted them to en-US's StdBig. expanded the tests, so it covers previously poorly imported types. Also made them use the SvxDateFormat and SvxTimeFormat Change-Id: I675c482d3095b5373975abb2e6e7eca2d353243d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118104 Tested-by: Jenkins CollaboraOffice Reviewed-by: Jan Holesovsky diff --git a/oox/source/drawingml/textfield.cxx b/oox/source/drawingml/textfield.cxx index d3fb06f94fc8..a8e058603f7a 100644 --- a/oox/source/drawingml/textfield.cxx +++ b/oox/source/drawingml/textfield.cxx @@ -220,21 +220,22 @@ SvxDateFormat TextField::getLODateFormat(std::u16string_view rDateTimeType) switch( nDateTimeNum ) { case 1: // Date dd/mm/ -case 2: // Date Day, Month dd, -case 5: // Date dd-Mon-yy -case 6: // Date Month yy -case 7: // Date Mon-yy case 8: // DateTime dd/mm/ H:MM PM case 9: // DateTime dd/mm/ H:MM:SS PM return SvxDateFormat::B; -case 3: // Date dd Month +case 2: // Date Day, Month dd, return SvxDateFormat::StdBig; -case 4: // Date Month dd, -return SvxDateFormat::StdSmall; -case 10: // Time H:MM -case 11: // Time H:MM:SS -case 12: // Time H:MM PM -case 13: // Time H:MM:SS PM +case 3: // Date dd Month +case 4: // Date Month dd, - no exact map +case 6: // Date Month yy - no exact map +return SvxDateFormat::D; +case 5: // Date dd-Mon-yy - no exact map +case 7: // Date Mon-yy - no exact map +return SvxDateFormat::C; +case 10: // Time H:MM - not a date format +case 11: // Time H:MM:SS - not a date format +case 12: // Time H:MM PM - not a date format +case 13: // Time H:MM:SS PM - not a date format default: return SvxDateFormat::AppDefault; } diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 87898bb7d9d2..dacfe516585c 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -2193,11 +2193,13 @@ OUString DrawingML::GetDatetimeTypeFromDateTime(SvxDateFormat eDate, SvxTimeForm case SvxDateFormat::B: aDateField = "datetime1"; // 13/02/1996 break; -case SvxDateFormat::StdBig: case SvxDateFormat::C: +aDateField = "datetime5"; +break; case SvxDateFormat::D: aDateField = "datetime3"; // 13 February 1996 break; +case SvxDateFormat::StdBig: case SvxDateFormat::E: case SvxDateFormat::F: aDateField = "datetime2"; diff --git a/sd/qa/unit/data/odp/numfmt.odp b/sd/qa/unit/data/odp/numfmt.odp index 6fd32ce0a66d..51227ea091d9 100644 Binary files a/sd/qa/unit/data/odp/numfmt.odp and b/sd/qa/unit/data/odp/numfmt.odp differ diff --git a/sd/qa/unit/data/pptx/numfmt.pptx b/sd/qa/unit/data/pptx/numfmt.pptx index e5f0f5cf151a..f855fbbeb12c 100644 Binary files a/sd/qa/unit/data/pptx/numfmt.pptx and b/sd/qa/unit/data/pptx/numfmt.pptx differ diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index 747168ba6940..f005e4800e8e 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -751,26 +752,33 @@ void matchNumberFormat( int nPage, uno::Reference< text::XTextField > const & xF xPropSet->getPropertyValue("NumberFormat") >>= nNumFmt; switch( nPage ) { -case 0: // 13/02/96 -CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Date fields don't match", sal_Int32(2), nNumFmt); +case 0: // 13/02/96 (StdSmall) +CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Date fields don't match", sal_Int32(SvxDateFormat::StdSmall), nNumFmt); break; case 1: // 13/02/1996 -CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Date fields don't match", sal_Int32(5), nNumFmt); +
[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - oox/source sd/qa
oox/source/drawingml/textcharacterproperties.cxx |2 + sd/qa/unit/data/pptx/tdf96061.pptx |binary sd/qa/unit/export-tests-ooxml2.cxx | 35 +++ 3 files changed, 37 insertions(+) New commits: commit e61bdbf41cf925147eee7f92142089f8adf0a237 Author: Gülşah Köse AuthorDate: Wed May 19 14:37:36 2021 +0300 Commit: Andras Timar CommitDate: Sat May 29 23:32:40 2021 +0200 tdf#96061 Unset the highlight property When we have highlight property on specific part of the text the following texts were highligthing. To prevent this we unset the highlight property when we have not highlight property anymore. Change-Id: I802cde1c784afe47201a9ba4f41827dd0c705035 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115800 Tested-by: Jenkins Reviewed-by: Gülşah Köse Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116176 Reviewed-by: Andras Timar Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116333 Tested-by: Jenkins CollaboraOffice diff --git a/oox/source/drawingml/textcharacterproperties.cxx b/oox/source/drawingml/textcharacterproperties.cxx index de47058e60ca..6b55c5326455 100644 --- a/oox/source/drawingml/textcharacterproperties.cxx +++ b/oox/source/drawingml/textcharacterproperties.cxx @@ -178,6 +178,8 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFil if( maHighlightColor.isUsed() ) rPropMap.setProperty( PROP_CharBackColor, maHighlightColor.getColor( rFilter.getGraphicHelper() )); +else +rPropMap.setProperty( PROP_CharBackColor, sal_Int32(-1)); } static void pushToGrabBag( PropertySet& rPropSet, const std::vector& aVectorOfProperyValues ) diff --git a/sd/qa/unit/data/pptx/tdf96061.pptx b/sd/qa/unit/data/pptx/tdf96061.pptx new file mode 100644 index ..c6e6aa5ae16f Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf96061.pptx differ diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index 399bd4657861..27d42132557f 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -188,6 +188,7 @@ public: void testTdf131554(); void testTdf132282(); void testTdf128213ShapeRot(); +void testTdf96061_textHighlight(); CPPUNIT_TEST_SUITE(SdOOXMLExportTest2); @@ -294,6 +295,7 @@ public: CPPUNIT_TEST(testTdf131554); CPPUNIT_TEST(testTdf132282); CPPUNIT_TEST(testTdf128213ShapeRot); +CPPUNIT_TEST(testTdf96061_textHighlight); CPPUNIT_TEST_SUITE_END(); @@ -2752,6 +2754,39 @@ void SdOOXMLExportTest2::testTdf128213ShapeRot() assertXPath(pXmlDocRels, "/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:bodyPr/a:scene3d/a:camera/a:rot", "rev", "540"); } +void SdOOXMLExportTest2::testTdf96061_textHighlight() +{ +::sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf96061.pptx"), PPTX); + +uno::Reference xShape(getShapeFromPage(0, 0, xDocShRef)); +uno::Reference const xParagraph1(getParagraphFromShape(0, xShape)); +uno::Reference xRun1(getRunFromParagraph(0, xParagraph1)); +uno::Reference< beans::XPropertySet> xPropSet1(xRun1, uno::UNO_QUERY_THROW); +sal_Int32 aColor; +xPropSet1->getPropertyValue("CharBackColor") >>= aColor; +CPPUNIT_ASSERT_EQUAL(sal_Int32(16776960), aColor); + +uno::Reference const xParagraph2(getParagraphFromShape(1, xShape)); +uno::Reference xRun2(getRunFromParagraph(0, xParagraph2)); +uno::Reference< beans::XPropertySet> xPropSet2(xRun2, uno::UNO_QUERY_THROW); +xPropSet2->getPropertyValue("CharBackColor") >>= aColor; +CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), aColor); + +xDocShRef = saveAndReload( xDocShRef.get(), PPTX ); + +uno::Reference xShape2(getShapeFromPage(0, 0, xDocShRef)); +uno::Reference const xParagraph3(getParagraphFromShape(0, xShape2)); +uno::Reference xRun3(getRunFromParagraph(0, xParagraph3)); +uno::Reference< beans::XPropertySet> xPropSet3(xRun3, uno::UNO_QUERY_THROW); +xPropSet3->getPropertyValue("CharBackColor") >>= aColor; +CPPUNIT_ASSERT_EQUAL(sal_Int32(16776960), aColor); + +uno::Reference const xParagraph4(getParagraphFromShape(1, xShape2)); +uno::Reference xRun4(getRunFromParagraph(0, xParagraph4)); +uno::Reference< beans::XPropertySet> xPropSet4(xRun4, uno::UNO_QUERY_THROW); +xPropSet4->getPropertyValue("CharBackColor") >>= aColor; +CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), aColor); +} CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - oox/source sd/qa
oox/source/drawingml/shape.cxx |6 -- sd/qa/unit/data/pptx/tdf140714.pptx |binary sd/qa/unit/export-tests.cxx | 16 3 files changed, 20 insertions(+), 2 deletions(-) New commits: commit eea9c8069cbd1deeca5af6866090984f28892ac8 Author: Gülşah Köse AuthorDate: Mon Mar 22 23:39:17 2021 +0300 Commit: Jan Holesovsky CommitDate: Thu Mar 25 22:39:59 2021 +0100 tdf#140714 Import graphics cropped into custom geometry as custom shapes. Change-Id: I2054d24ce41c9f0d6cc1675f461274067c3b2898 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112943 Tested-by: Jenkins Reviewed-by: Jan Holesovsky Reviewed-by: Gülşah Köse Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113003 Tested-by: Jenkins CollaboraOffice diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 9e324ef69ed1..803e130b349a 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -726,8 +726,10 @@ Reference< XShape > const & Shape::createAndInsert( } // Use custom shape instead of GraphicObjectShape if the image is cropped to // shape. Except rectangle, which does not require further cropping -bool bIsCroppedGraphic = (aServiceName == "com.sun.star.drawing.GraphicObjectShape" && mpCustomShapePropertiesPtr->getShapePresetType() >= 0 -&& mpCustomShapePropertiesPtr->getShapePresetType() != XML_Rect && mpCustomShapePropertiesPtr->getShapePresetType() != XML_rect); +bool bIsCroppedGraphic = (aServiceName == "com.sun.star.drawing.GraphicObjectShape" && + (mpCustomShapePropertiesPtr->getShapePresetType() >= 0 || mpCustomShapePropertiesPtr->getPath2DList().size() > 0) && + mpCustomShapePropertiesPtr->getShapePresetType() != XML_Rect && + mpCustomShapePropertiesPtr->getShapePresetType() != XML_rect); bool bIsCustomShape = ( aServiceName == "com.sun.star.drawing.CustomShape" || aServiceName == "com.sun.star.drawing.ConnectorShape" || bIsCroppedGraphic); diff --git a/sd/qa/unit/data/pptx/tdf140714.pptx b/sd/qa/unit/data/pptx/tdf140714.pptx new file mode 100644 index ..6f5e98ec66f1 Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf140714.pptx differ diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index f1d5f65c36ac..fdad324b216a 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -72,6 +72,7 @@ public: void testTdf123557(); void testTdf113822(); void testTdf126761(); +void testTdf140714(); CPPUNIT_TEST_SUITE(SdExportTest); @@ -105,6 +106,7 @@ public: CPPUNIT_TEST(testTdf123557); CPPUNIT_TEST(testTdf113822); CPPUNIT_TEST(testTdf126761); +CPPUNIT_TEST(testTdf140714); CPPUNIT_TEST_SUITE_END(); @@ -1213,6 +1215,20 @@ void SdExportTest::testTdf126761() xDocShRef->DoClose(); } +void SdExportTest::testTdf140714() +{ +//Without the fix in place, shape will be imported as GraphicObjectShape instead of CustomShape. + +auto xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf140714.pptx"), PPTX); +utl::TempFile tempFile; +xDocShRef = saveAndReload(xDocShRef.get(), PPTX, ); + +uno::Reference xShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(OUString{"com.sun.star.drawing.CustomShape"}, xShape->getShapeType()); + +xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - oox/source sd/qa
oox/source/drawingml/fillproperties.cxx | 19 +++ sd/qa/unit/data/pptx/greysscale-graphic.pptx |binary sd/qa/unit/import-tests.cxx | 16 3 files changed, 35 insertions(+) New commits: commit 11c5329669e7a908b43a3fe51a673e8d78740f8c Author: Gülşah Köse AuthorDate: Mon Feb 8 13:30:39 2021 +0300 Commit: Miklos Vajna CommitDate: Wed Feb 17 09:14:25 2021 +0100 tdf#134210 Handle greyscale effect on bitmap filled custom shapes. Change-Id: Ia4a0828dad80e32cc0c7fe12227ffca717d62e03 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110572 Tested-by: Jenkins Reviewed-by: Gülşah Köse Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110965 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index 5ac24b948f98..bdd81e1d0434 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -172,6 +172,22 @@ Reference< XGraphic > lclMirrorGraphic(uno::Reference const & return aReturnGraphic.GetXGraphic(); } +Reference< XGraphic > lclGreysScaleGraphic(uno::Reference const & xGraphic) +{ +::Graphic aGraphic(xGraphic); +::Graphic aReturnGraphic; + +assert (aGraphic.GetType() == GraphicType::Bitmap); + +BitmapEx aBitmapEx(aGraphic.GetBitmapEx()); +aBitmapEx.Convert(BmpConversion::N8BitGreys); + +aReturnGraphic = ::Graphic(aBitmapEx); +aReturnGraphic.setOriginURL(aGraphic.getOriginURL()); + +return aReturnGraphic.GetXGraphic(); +} + Reference< XGraphic > lclCheckAndApplyChangeColorTransform(const BlipFillProperties , uno::Reference const & xGraphic, const GraphicHelper& rGraphicHelper, const ::Color nPhClr) { @@ -887,6 +903,9 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelpe if(bFlipH || bFlipV) xGraphic = lclMirrorGraphic(xGraphic, bFlipH, bFlipV ); +if(eColorMode == ColorMode_GREYS) +xGraphic = lclGreysScaleGraphic( xGraphic ); + rPropMap.setProperty(PROP_FillBitmap, xGraphic); } else diff --git a/sd/qa/unit/data/pptx/greysscale-graphic.pptx b/sd/qa/unit/data/pptx/greysscale-graphic.pptx new file mode 100644 index ..547b60c10269 Binary files /dev/null and b/sd/qa/unit/data/pptx/greysscale-graphic.pptx differ diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index e0c725031f10..6b52466c2513 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -210,6 +210,7 @@ public: void testTdf119187(); void testMirroredGraphic(); void testCropPositionGraphic(); +void testGreysScaleGraphic(); bool checkPattern(sd::DrawDocShellRef const & rDocRef, int nShapeNumber, std::vector& rExpected); void testPatternImport(); @@ -338,6 +339,7 @@ public: CPPUNIT_TEST(testTdf119187); CPPUNIT_TEST(testMirroredGraphic); CPPUNIT_TEST(testCropPositionGraphic); +CPPUNIT_TEST(testGreysScaleGraphic); CPPUNIT_TEST_SUITE_END(); }; @@ -3254,6 +3256,20 @@ void SdImportTest::testCropPositionGraphic() xDocShRef->DoClose(); } +void SdImportTest::testGreysScaleGraphic() +{ +sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/greysscale-graphic.pptx"), PPTX); +uno::Reference xShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_SET_THROW); +CPPUNIT_ASSERT(xShape.is()); +uno::Reference xGraphic; +xShape->getPropertyValue("FillBitmap") >>= xGraphic; +CPPUNIT_ASSERT(xGraphic.is()); +Graphic aGraphic(xGraphic); +BitmapEx aBitmap(aGraphic.GetBitmapEx()); +CPPUNIT_ASSERT_EQUAL( Color(3947580), aBitmap.GetPixelColor( 0, 0 )); +xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest); CPPUNIT_PLUGIN_IMPLEMENT(); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - oox/source sd/qa
oox/source/drawingml/fillproperties.cxx | 84 oox/source/export/drawingml.cxx | 23 ++-- sd/qa/unit/data/pptx/crop-position.pptx |binary sd/qa/unit/export-tests-ooxml1.cxx | 29 +-- sd/qa/unit/import-tests.cxx | 16 ++ 5 files changed, 121 insertions(+), 31 deletions(-) New commits: commit 363b2d374be736e713c4b8aa0f7b9fda8849335b Author: Gülşah Köse AuthorDate: Mon Feb 1 17:03:33 2021 +0300 Commit: Miklos Vajna CommitDate: Wed Feb 17 09:13:32 2021 +0100 tdf#134210 Import crop position of bitmap filled shape. Change-Id: I6a62d68cd0f57e53934851a2f53dae05bf7d3730 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110262 Tested-by: Jenkins Reviewed-by: Gülşah Köse Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110964 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index f17a613b444e..5ac24b948f98 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -93,6 +93,30 @@ Reference< XGraphic > lclRotateGraphic(uno::Reference const & return aReturnGraphic.GetXGraphic(); } +void lclCalculateCropPercentage(uno::Reference const & xGraphic, geometry::IntegerRectangle2D ) +{ +::Graphic aGraphic(xGraphic); +assert (aGraphic.GetType() == GraphicType::Bitmap); + +BitmapEx aBitmapEx(aGraphic.GetBitmapEx()); + +sal_Int32 nScaledWidth = aBitmapEx.GetSizePixel().Width(); +sal_Int32 nScaledHeight = aBitmapEx.GetSizePixel().Height(); + +sal_Int32 nOrigWidth = (nScaledWidth * (10 - aFillRect.X1 - aFillRect.X2)) / 10; +sal_Int32 nOrigHeight = (nScaledHeight * (10 - aFillRect.Y1 - aFillRect.Y2)) / 10; + +sal_Int32 nLeftPercentage = nScaledWidth * aFillRect.X1 / nOrigWidth; +sal_Int32 nRightPercentage = nScaledWidth * aFillRect.X2 / nOrigWidth; +sal_Int32 nTopPercentage = nScaledHeight * aFillRect.Y1 / nOrigHeight; +sal_Int32 nBottomPercentage = nScaledHeight * aFillRect.Y2 / nOrigHeight; + +aFillRect.X1 = -nLeftPercentage; +aFillRect.X2 = -nRightPercentage; +aFillRect.Y1 = -nTopPercentage; +aFillRect.Y2 = -nBottomPercentage; +} + Reference< XGraphic > lclCropGraphic(uno::Reference const & xGraphic, geometry::IntegerRectangle2D aFillRect) { ::Graphic aGraphic(xGraphic); @@ -109,8 +133,15 @@ Reference< XGraphic > lclCropGraphic(uno::Reference const & x sal_Int32 nBottomCorr = nOrigHeight * -1 * static_cast(aFillRect.Y2) / 10; nHeight += nBottomCorr; -aBitmapEx.Scale(Size(aBitmapEx.GetSizePixel().Width(), nHeight)); -aBitmapEx.Crop(tools::Rectangle(Point(0, nTopCorr), Size(aBitmapEx.GetSizePixel().Width(), nOrigHeight))); +sal_Int32 nOrigWidth = aBitmapEx.GetSizePixel().Width(); +sal_Int32 nWidth = nOrigWidth; +sal_Int32 nLeftCorr = nOrigWidth * -1 * static_cast(aFillRect.X1) / 10; +nWidth += nLeftCorr; +sal_Int32 nRightCorr = nOrigWidth * -1 * static_cast(aFillRect.X2) / 10; +nWidth += nRightCorr; + +aBitmapEx.Scale(Size(nWidth, nHeight)); +aBitmapEx.Crop(tools::Rectangle(Point(nLeftCorr, nTopCorr), Size(nOrigWidth, nOrigHeight))); aReturnGraphic = ::Graphic(aBitmapEx); aReturnGraphic.setOriginURL(aGraphic.getOriginURL()); @@ -807,6 +838,36 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelpe nContrast = 0; } +// cropping +if ( maBlipProps.moClipRect.has() ) +{ +geometry::IntegerRectangle2D oClipRect( maBlipProps.moClipRect.get() ); +awt::Size aOriginalSize( rGraphicHelper.getOriginalSize( xGraphic ) ); +if ( aOriginalSize.Width && aOriginalSize.Height ) +{ +text::GraphicCrop aGraphCrop( 0, 0, 0, 0 ); +if ( oClipRect.X1 ) +aGraphCrop.Left = rtl::math::round( ( static_cast< double >( aOriginalSize.Width ) * oClipRect.X1 ) / 10 ); +if ( oClipRect.Y1 ) +aGraphCrop.Top = rtl::math::round( ( static_cast< double >( aOriginalSize.Height ) * oClipRect.Y1 ) / 10 ); +if ( oClipRect.X2 ) +aGraphCrop.Right = rtl::math::round( ( static_cast< double >( aOriginalSize.Width ) * oClipRect.X2 ) / 10 ); +if ( oClipRect.Y2 ) +aGraphCrop.Bottom = rtl::math::round( ( static_cast< double >( aOriginalSize.Height ) * oClipRect.Y2 ) / 10 ); +rPropMap.setProperty(PROP_GraphicCrop, aGraphCrop); +} + +if(mbIsCustomShape) +{ +geometry::IntegerRectangle2D aCropRect = oClipRect; +lclCalculateCropPercentage(xGraphic, aCropRect); +xGraphic = lclCropGraphic(xGraphic, aCropRect); + +
[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - oox/source sd/qa
oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 42 +++ sd/qa/unit/data/pptx/smartart-composite-infer-right.pptx |binary sd/qa/unit/import-tests-smartart.cxx | 26 + 3 files changed, 68 insertions(+) New commits: commit 51b0a654b2c75c7b4e42763603a4e23c25317dc5 Author: Miklos Vajna AuthorDate: Tue Jan 19 16:59:38 2021 +0100 Commit: Miklos Vajna CommitDate: Wed Jan 20 14:57:24 2021 +0100 oox smartart: composite algo: handle right constraint when left+width is given The bugdoc had this constraint: While img has no "r", it has: Which is enough to fix the x position of the text to not overlap with img. (cherry picked from commit 1359e8c566970fcef860f7ba7f54a07d8e6e0513) Change-Id: I80db290bd1695884ffb7b1eabaffa09462e8883d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109703 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index 6e9626c2f9fe..410b2c9e677e 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -820,6 +820,37 @@ sal_Int32 AlgAtom::getVerticalShapesCount(const ShapePtr& rShape) namespace { +/** + * Decides if a certain reference type (e.g. "right") can be inferred from the available properties + * in rMap (e.g. left and width). Returns true if rValue is written to. + */ +bool InferFromLayoutProperty(const LayoutProperty& rMap, sal_Int32 nRefType, sal_Int32& rValue) +{ +switch (nRefType) +{ +case XML_r: +{ +auto it = rMap.find(XML_l); +if (it == rMap.end()) +{ +return false; +} +sal_Int32 nLeft = it->second; +it = rMap.find(XML_w); +if (it == rMap.end()) +{ +return false; +} +rValue = nLeft + it->second; +return true; +} +default: +break; +} + +return false; +} + /** * Apply rConstraint to the rProperties shared layout state. * @@ -840,11 +871,22 @@ void ApplyConstraintToLayout(const Constraint& rConstraint, LayoutPropertyMap& r return; const LayoutProperty::const_iterator aRefType = aRef->second.find(rConstraint.mnRefType); +sal_Int32 nInferredValue = 0; if (aRefType != aRef->second.end()) +{ +// Reference is found directly. rProperties[rConstraint.msForName][rConstraint.mnType] = aRefType->second * rConstraint.mfFactor; +} +else if (InferFromLayoutProperty(aRef->second, rConstraint.mnRefType, nInferredValue)) +{ +// Reference can be inferred. +rProperties[rConstraint.msForName][rConstraint.mnType] += nInferredValue * rConstraint.mfFactor; +} else { +// Reference not found, assume a fixed value. // Values are never in EMU, while oox::drawingml::Shape position and size are always in // EMU. double fUnitFactor = 0; diff --git a/sd/qa/unit/data/pptx/smartart-composite-infer-right.pptx b/sd/qa/unit/data/pptx/smartart-composite-infer-right.pptx new file mode 100644 index ..ca417499fa16 Binary files /dev/null and b/sd/qa/unit/data/pptx/smartart-composite-infer-right.pptx differ diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx index edb8edaed9f2..35920ae76ac0 100644 --- a/sd/qa/unit/import-tests-smartart.cxx +++ b/sd/qa/unit/import-tests-smartart.cxx @@ -111,6 +111,7 @@ public: void testLinearRuleVert(); void testAutofitSync(); void testSnakeRows(); +void testCompositeInferRight(); CPPUNIT_TEST_SUITE(SdImportTestSmartArt); @@ -161,6 +162,7 @@ public: CPPUNIT_TEST(testLinearRuleVert); CPPUNIT_TEST(testAutofitSync); CPPUNIT_TEST(testSnakeRows); +CPPUNIT_TEST(testCompositeInferRight); CPPUNIT_TEST_SUITE_END(); }; @@ -1637,6 +1639,30 @@ void SdImportTestSmartArt::testSnakeRows() xDocShRef->DoClose(); } +void SdImportTestSmartArt::testCompositeInferRight() +{ +// Load a smartart which contains a composite algorithm. +// One contraint says that the left of the text should be the right of the image. +sd::DrawDocShellRef xDocShRef = loadURL( + m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/smartart-composite-infer-right.pptx"), +PPTX); + +uno::Reference xDiagram(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY); +uno::Reference xMiddle = getChildShape(xDiagram, 1); +uno::Reference xImage = getChildShape(xMiddle, 1); +uno::Reference xText = getChildShape(xMiddle, 2); +sal_Int32 nRightOfImage = xImage->getPosition().X + xImage->getSize().Width; +sal_Int32 nLeftOfText = xText->getPosition().X;
[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - oox/source sd/qa
oox/source/drawingml/diagram/diagramlayoutatoms.cxx |5 - sd/qa/unit/data/pptx/smartart-pyramid-1child.pptx |binary sd/qa/unit/import-tests-smartart.cxx| 15 +++ 3 files changed, 19 insertions(+), 1 deletion(-) New commits: commit 877235b01d6b87ae037c98f4da34f9fa3a48c714 Author: Miklos Vajna AuthorDate: Tue Jan 12 10:13:14 2021 +0100 Commit: Miklos Vajna CommitDate: Wed Jan 13 16:59:10 2021 +0100 oox smartart: fix crash in pyra algorithm with a single child shape Regression from commit 14a56533ff2c9c859d22cd3039ada75b99e94bc0 (SmartArt Pyramid: Now lays out shapes, 2018-07-10), the added pyramid algorithm by first centering the topmost children, then decrementing the horizontal postion of each additional shape, with the end goal of having 0 horizontal position of the last children. This means that simply avoiding the division in the 1-child case leads to correct results, because in this case the only child is also the last child at the sane time. (cherry picked from commit f2e04fe98e313cffa3f98d55eae641415142a431) Change-Id: Ifd0027e9616b0909dbfde43e1555427b50de4dad Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109223 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index bfed9676d7c1..6a33148a7993 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -1617,7 +1617,10 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector& for (auto & aCurrShape : rShape->getChildren()) { aCurrShape->setPosition(aCurrPos); -aCurrPos.X -= aChildSize.Height/(nCount-1); +if (nCount > 1) +{ +aCurrPos.X -= aChildSize.Height / (nCount - 1); +} aChildSize.Width += aChildSize.Height; aCurrShape->setSize(aChildSize); aCurrShape->setChildSize(aChildSize); diff --git a/sd/qa/unit/data/pptx/smartart-pyramid-1child.pptx b/sd/qa/unit/data/pptx/smartart-pyramid-1child.pptx new file mode 100644 index ..42e43c54bbc4 Binary files /dev/null and b/sd/qa/unit/data/pptx/smartart-pyramid-1child.pptx differ diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx index d558f9c447df..edb8edaed9f2 100644 --- a/sd/qa/unit/import-tests-smartart.cxx +++ b/sd/qa/unit/import-tests-smartart.cxx @@ -73,6 +73,7 @@ public: void testRotation(); void testTextAutoRotation(); void testPyramid(); +void testPyramidOneChild(); void testChevron(); void testCycle(); void testvenndiagram(); @@ -122,6 +123,7 @@ public: CPPUNIT_TEST(testRotation); CPPUNIT_TEST(testTextAutoRotation); CPPUNIT_TEST(testPyramid); +CPPUNIT_TEST(testPyramidOneChild); CPPUNIT_TEST(testChevron); CPPUNIT_TEST(testCycle); CPPUNIT_TEST(testHierarchy); @@ -425,6 +427,19 @@ void SdImportTestSmartArt::testPyramid() //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet. } +void SdImportTestSmartArt::testPyramidOneChild() +{ +// Load a document with a pyra algorithm in it. +// Without the accompanying fix in place, this test would have crashed. +sd::DrawDocShellRef xDocShRef = loadURL( + m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/smartart-pyramid-1child.pptx"), PPTX); +uno::Reference xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY); +uno::Reference xText(getChildShape(getChildShape(xGroup, 1), 1), + uno::UNO_QUERY); +// Verify that the text of the only child is imported correctly. +CPPUNIT_ASSERT_EQUAL(OUString("A"), xText->getString()); +} + void SdImportTestSmartArt::testChevron() { sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-chevron.pptx"), PPTX); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - oox/source sd/qa
oox/source/drawingml/diagram/diagramlayoutatoms.cxx |6 + sd/qa/unit/data/pptx/smartart-linear-rule-vert.pptx |binary sd/qa/unit/import-tests-smartart.cxx| 22 3 files changed, 28 insertions(+) New commits: commit 5f6e5c33e0911d8d19d2d8e934e7199e850870cd Author: Miklos Vajna AuthorDate: Mon Oct 19 21:07:10 2020 +0200 Commit: Miklos Vajna CommitDate: Wed Jan 13 14:21:23 2021 +0100 tdf#137417 oox smartart: avoid considering rules in vertical linear layouts Regression from commit 0024c48b4822062995effed7db4f1281196384bb (oox smartart: consider rules when scaling in linear layout, 2020-07-31), the problem is that I only tested horizontal layouts and this is not working for vertical layouts. Just disable the vertical case for now, to avoid unwanted side effects. (cherry picked from commit c719db99166a7b4770855a9599ec65c70cd256c5) Change-Id: I31a894157996a2371b8d0ec482ee91dc4d5b053e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109222 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index ebcc09e3fc16..bfed9676d7c1 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -1376,6 +1376,12 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector& aChildrenToShrink.insert(rRule.msForName); } +if (nDir == XML_fromT || nDir == XML_fromB) +{ +// TODO consider rules for vertical linear layout as well. +aChildrenToShrink.clear(); +} + if (!aChildrenToShrink.empty()) { // Have scaling info from rules: then only count scaled children. diff --git a/sd/qa/unit/data/pptx/smartart-linear-rule-vert.pptx b/sd/qa/unit/data/pptx/smartart-linear-rule-vert.pptx new file mode 100644 index ..cf1a23a6151e Binary files /dev/null and b/sd/qa/unit/data/pptx/smartart-linear-rule-vert.pptx differ diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx index 6af86e6a5343..d558f9c447df 100644 --- a/sd/qa/unit/import-tests-smartart.cxx +++ b/sd/qa/unit/import-tests-smartart.cxx @@ -107,6 +107,7 @@ public: void testOrgChart2(); void testFillColorList(); void testLinearRule(); +void testLinearRuleVert(); void testAutofitSync(); void testSnakeRows(); @@ -155,6 +156,7 @@ public: CPPUNIT_TEST(testOrgChart2); CPPUNIT_TEST(testFillColorList); CPPUNIT_TEST(testLinearRule); +CPPUNIT_TEST(testLinearRuleVert); CPPUNIT_TEST(testAutofitSync); CPPUNIT_TEST(testSnakeRows); @@ -1534,6 +1536,26 @@ void SdImportTestSmartArt::testLinearRule() xDocShRef->DoClose(); } +void SdImportTestSmartArt::testLinearRuleVert() +{ +sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-linear-rule-vert.pptx"), PPTX); + +uno::Reference xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY); +// Get the P1 shape. +uno::Reference xShape = getChildShape(getChildShape(xGroup, 1), 1); +uno::Reference xShapeText(xShape, uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(OUString("P1"), xShapeText->getString()); + +// Without the accompanying fix in place, this test would have failed with: +// - Expected: 2020 +// - Actual : 10308 +// i.e. the first item on the vertical linear layout used ~all space, the other items were not +// visible. +CPPUNIT_ASSERT_EQUAL(static_cast(2020), xShape->getSize().Height); + +xDocShRef->DoClose(); +} + void SdImportTestSmartArt::testAutofitSync() { sd::DrawDocShellRef xDocShRef = loadURL( ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - oox/source sd/qa
oox/source/export/drawingml.cxx |2 +- sd/qa/unit/data/pptx/tdf128213.pptx |binary sd/qa/unit/export-tests-ooxml2.cxx | 12 3 files changed, 13 insertions(+), 1 deletion(-) New commits: commit e9f2f9e83fc12b577b13d618bde591222d4fdba9 Author: Gülşah Köse AuthorDate: Thu Nov 5 14:19:03 2020 +0300 Commit: Gülşah Köse CommitDate: Thu Nov 5 22:19:31 2020 +0100 tdf#128213 Fix export rotation problem. Export code has written for case that we have normal rotation angle and camera z rotation together. If object has not normal rotation but have camera z rotation, problem occurs. Camera z rotation info is already exist between tags. If we have not (normal rotation angle) we shouldn't add camera rotation here. Change-Id: I1819953c937783d30b6e7ced978758300bb56d7e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105341 Tested-by: Jenkins Reviewed-by: Gülşah Köse Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105350 Tested-by: Jenkins CollaboraOffice diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 264bf3a5e55f..977a1ccfa3b1 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1708,7 +1708,7 @@ void DrawingML::WriteShapeTransformation( const Reference< XShape >& rXShape, sa if (xPropertySetInfo->hasPropertyByName("RotateAngle")) xPropertySet->getPropertyValue("RotateAngle") >>= nRotation; // tdf#133037: restore original rotate angle before output -if (xPropertySetInfo->hasPropertyByName(UNO_NAME_MISC_OBJ_INTEROPGRABBAG)) +if (nRotation != 0 && xPropertySetInfo->hasPropertyByName(UNO_NAME_MISC_OBJ_INTEROPGRABBAG)) { uno::Sequence aGrabBagProps; xPropertySet->getPropertyValue(UNO_NAME_MISC_OBJ_INTEROPGRABBAG) >>= aGrabBagProps; diff --git a/sd/qa/unit/data/pptx/tdf128213.pptx b/sd/qa/unit/data/pptx/tdf128213.pptx new file mode 100644 index ..1f308128c367 Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf128213.pptx differ diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index 7a188b885d08..a4040be04fbc 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -183,6 +183,7 @@ public: void testTdf127379(); void testTdf98603(); void testTdf79082(); +void testTdf128213(); void testTdf119087(); void testTdf131554(); void testTdf132282(); @@ -287,6 +288,7 @@ public: CPPUNIT_TEST(testTdf127379); CPPUNIT_TEST(testTdf98603); CPPUNIT_TEST(testTdf79082); +CPPUNIT_TEST(testTdf128213); CPPUNIT_TEST(testTdf119087); CPPUNIT_TEST(testTdf131554); CPPUNIT_TEST(testTdf132282); @@ -2641,6 +2643,16 @@ void SdOOXMLExportTest2::testTdf98603() CPPUNIT_ASSERT_EQUAL(OUString("IL"), aLocale.Country); } +void SdOOXMLExportTest2::testTdf128213() +{ +::sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf128213.pptx"), PPTX); +utl::TempFile tempFile; +xDocShRef = saveAndReload( xDocShRef.get(), PPTX, ); + +xmlDocPtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml"); +assertXPathNoAttribute(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:xfrm", "rot"); +} + void SdOOXMLExportTest2::testTdf79082() { ::sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf79082.pptx"), PPTX); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - oox/source sd/qa
oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 11 ++-- sd/qa/unit/data/pptx/smartart-snake-rows.pptx |binary sd/qa/unit/import-tests-smartart.cxx| 26 3 files changed, 35 insertions(+), 2 deletions(-) New commits: commit 8e29b74a755ba9fd73d8b62667c70ce3d6552cf4 Author: Miklos Vajna AuthorDate: Fri Sep 25 17:27:03 2020 +0200 Commit: Miklos Vajna CommitDate: Wed Sep 30 17:25:14 2020 +0200 oox smartart: snake algo: consider child's aspect ratio request for cols/rows If the child's aspect ratio request will shrink the width, then take that into account when calculating how many rows / cols we need. This reduces the number of columns for the bugdoc from 4 to 3, which is needed, but not enough to render it correctly. (cherry picked from commit acc9aead3cc5162379d34a455aa15f7b13907cf1) Change-Id: I1d02df4834b8a2ce97d5e006db0e3135d3d42917 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103700 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index 6175832a426d..3ab17ec6904a 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -1322,11 +1322,18 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector& nRow = nCount; else { +double fShapeHeight = rShape->getSize().Height; +double fShapeWidth = rShape->getSize().Width; +// Check if we have a child aspect ratio. If so, need to shrink one dimension to +// achieve that ratio. +if (fChildAspectRatio && fShapeHeight && fChildAspectRatio < (fShapeWidth/fShapeHeight)) +{ +fShapeWidth = fShapeHeight * fChildAspectRatio; +} + for ( ; nRowgetSize().Height; -const double fShapeWidth = rShape->getSize().Width; if ((fShapeHeight / nCol) / (fShapeWidth / nRow) >= fAspectRatio) break; } diff --git a/sd/qa/unit/data/pptx/smartart-snake-rows.pptx b/sd/qa/unit/data/pptx/smartart-snake-rows.pptx new file mode 100644 index ..7f5e82df3eaf Binary files /dev/null and b/sd/qa/unit/data/pptx/smartart-snake-rows.pptx differ diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx index 4844afe5a84e..1746b7c58f4a 100644 --- a/sd/qa/unit/import-tests-smartart.cxx +++ b/sd/qa/unit/import-tests-smartart.cxx @@ -108,6 +108,7 @@ public: void testFillColorList(); void testLinearRule(); void testAutofitSync(); +void testSnakeRows(); CPPUNIT_TEST_SUITE(SdImportTestSmartArt); @@ -155,6 +156,7 @@ public: CPPUNIT_TEST(testFillColorList); CPPUNIT_TEST(testLinearRule); CPPUNIT_TEST(testAutofitSync); +CPPUNIT_TEST(testSnakeRows); CPPUNIT_TEST_SUITE_END(); }; @@ -1571,6 +1573,30 @@ void SdImportTestSmartArt::testAutofitSync() xDocShRef->DoClose(); } +void SdImportTestSmartArt::testSnakeRows() +{ +// Load a smartart which contains a snake algorithm. +// The expected layout of the 6 children is a 3x2 grid. +sd::DrawDocShellRef xDocShRef = loadURL( + m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-snake-rows.pptx"), PPTX); + +uno::Reference xDiagram(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY); +std::set aYPositions; +for (sal_Int32 nChild = 0; nChild < xDiagram->getCount(); ++nChild) +{ +uno::Reference xChild(xDiagram->getByIndex(nChild), uno::UNO_QUERY); +aYPositions.insert(xChild->getPosition().Y); +} + +// Without the accompanying fix in place, this test would have failed with: +// - Expected: 3 +// - Actual : 4 +// i.e. one more unwanted row appeared. This is better, but the ideal would be just 2 rows. +CPPUNIT_ASSERT_EQUAL(static_cast(3), aYPositions.size()); + +xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTestSmartArt); CPPUNIT_PLUGIN_IMPLEMENT(); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - oox/source sd/qa
oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 56 +++- sd/qa/unit/data/pptx/smartart-autofit-sync.pptx |binary sd/qa/unit/import-tests-smartart.cxx| 11 +++ 3 files changed, 66 insertions(+), 1 deletion(-) New commits: commit 1333c831b511e38ec114f51b4bf5e6fef3d7b30e Author: Miklos Vajna AuthorDate: Mon Sep 14 16:58:38 2020 +0200 Commit: Miklos Vajna CommitDate: Tue Sep 15 18:09:58 2020 +0200 oox smartart: handle Which defines that a data node has text properties as direct formatting, so autoscale should not happen. We decide autofit at a shape level, smartart defines custom text props at a data node level. So take the shape, go to its first presentation node, get its data node and see if it has custom text props. If not, continue to scale text down till it fits. smartart-autofit-sync.pptx is extended to contain a 3rd shape: the first two have their autofit scaling synchronized, while the 3rd has a fixed font size of 10pt. (cherry picked from commit 89b385c2336e5b3868d2a040e11134b349b7d010) Change-Id: I6caacdaab9a36072b9ad5021bd217c955b09b790 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102727 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index 6823e45b3043..6175832a426d 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -479,6 +479,54 @@ void ApplyConstraintToLayout(const Constraint& rConstraint, LayoutPropertyMap& r } } } + +/// Does the first data node of this shape have customized text properties? +bool HasCustomText(const ShapePtr& rShape, LayoutNode& rLayoutNode) +{ +const PresPointShapeMap& rPresPointShapeMap += rLayoutNode.getDiagram().getLayout()->getPresPointShapeMap(); +const DiagramData::StringMap& rPresOfNameMap += rLayoutNode.getDiagram().getData()->getPresOfNameMap(); +const DiagramData::PointNameMap& rPointNameMap += rLayoutNode.getDiagram().getData()->getPointNameMap(); +// Get the first presentation node of the shape. +const dgm::Point* pPresNode = nullptr; +for (const auto& rPair : rPresPointShapeMap) +{ +if (rPair.second == rShape) +{ +pPresNode = rPair.first; +break; +} +} +// Get the first data node of the presentation node. +dgm::Point* pDataNode = nullptr; +if (pPresNode) +{ +auto itPresToData = rPresOfNameMap.find(pPresNode->msModelId); +if (itPresToData != rPresOfNameMap.end()) +{ +for (const auto& rPair : itPresToData->second) +{ +const DiagramData::SourceIdAndDepth& rItem = rPair.second; +auto it = rPointNameMap.find(rItem.msSourceId); +if (it != rPointNameMap.end()) +{ +pDataNode = it->second; +break; +} +} +} +} + +// If we have a data node, see if its text is customized or not. +if (pDataNode) +{ +return pDataNode->mbCustomText; +} + +return false; +} } void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector& rConstraints, @@ -1453,7 +1501,13 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector& if (!aRun->getTextCharacterProperties().moHeight.has()) aRun->getTextCharacterProperties().moHeight = fFontSize * 100; } - pTextBody->getTextProperties().maPropertyMap.setProperty(PROP_TextFitToSize, drawing::TextFitToSizeType_AUTOFIT); + +if (!HasCustomText(rShape, getLayoutNode())) +{ +// No customized text properties: enable autofit. +pTextBody->getTextProperties().maPropertyMap.setProperty( +PROP_TextFitToSize, drawing::TextFitToSizeType_AUTOFIT); +} // ECMA-376-1:2016 21.4.7.5 ST_AutoTextRotation (Auto Text Rotation) const sal_Int32 nautoTxRot = maMap.count(XML_autoTxRot) ? maMap.find(XML_autoTxRot)->second : XML_upr; diff --git a/sd/qa/unit/data/pptx/smartart-autofit-sync.pptx b/sd/qa/unit/data/pptx/smartart-autofit-sync.pptx index f682c143f584..9a6ce0f494c5 100644 Binary files a/sd/qa/unit/data/pptx/smartart-autofit-sync.pptx and b/sd/qa/unit/data/pptx/smartart-autofit-sync.pptx differ diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx index 0d41e3094052..4844afe5a84e 100644 --- a/sd/qa/unit/import-tests-smartart.cxx +++ b/sd/qa/unit/import-tests-smartart.cxx @@ -1557,6 +1557,17 @@ void SdImportTestSmartArt::testAutofitSync() // requested that their scaling matches.
[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - oox/source sd/qa
oox/source/drawingml/fillproperties.cxx | 26 ++ oox/source/drawingml/shape.cxx |2 ++ sd/qa/unit/data/pptx/tdf134174.pptx |binary sd/qa/unit/import-tests.cxx | 19 +++ 4 files changed, 47 insertions(+) New commits: commit 558a72adc294efb9e62e24f3419369c7e9d48edf Author: Gülşah Köse AuthorDate: Sun Aug 23 22:32:53 2020 +0300 Commit: Andras Timar CommitDate: Tue Aug 25 08:40:52 2020 +0200 tdf#134174 Fix the rotation of bitmap filled custom shapes. During import we were rotating only custom shape. Not its bitmap. Custom shape and its bitmap rotated with same rotation value in that commit. Change-Id: I02d19c820670df7b4d1622836156c6bf8ed1c154 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101255 Tested-by: Jenkins Reviewed-by: Gülşah Köse (cherry picked from commit 9fe881410909c5273cef517433411bc4eceee294) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101161 Tested-by: Jenkins CollaboraOffice Reviewed-by: Andras Timar diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index ce6cb1f931e4..863d3b846c60 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -76,6 +77,22 @@ Reference< XGraphic > lclCheckAndApplyDuotoneTransform(const BlipFillProperties& return xGraphic; } +Reference< XGraphic > lclRotateGraphic(uno::Reference const & xGraphic, long nRotation) +{ +::Graphic aGraphic(xGraphic); +::Graphic aReturnGraphic; + +assert (aGraphic.GetType() == GraphicType::Bitmap); + +BitmapEx aBitmapEx(aGraphic.GetBitmapEx()); +const ::Color& aColor = ::Color(0x00); +aBitmapEx.Rotate(nRotation, aColor); +aReturnGraphic = ::Graphic(aBitmapEx); +aReturnGraphic.setOriginURL(aGraphic.getOriginURL()); + +return aReturnGraphic.GetXGraphic(); +} + Reference< XGraphic > lclCheckAndApplyChangeColorTransform(const BlipFillProperties , uno::Reference const & xGraphic, const GraphicHelper& rGraphicHelper, const ::Color nPhClr) { @@ -741,6 +758,15 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelpe // it is a cropped graphic. rPropMap.setProperty(PROP_FillStyle, FillStyle_BITMAP); rPropMap.setProperty(PROP_FillBitmapMode, BitmapMode_STRETCH); + +// It is a bitmap filled and rotated graphic. +// When custom shape is rotated, bitmap have to be rotated too. +if(rPropMap.hasProperty(PROP_RotateAngle)) +{ +long nAngle = rPropMap.getProperty(PROP_RotateAngle).get(); +xGraphic = lclRotateGraphic(xGraphic, nAngle/10 ); +} + rPropMap.setProperty(PROP_FillBitmap, xGraphic); } else diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 8cb3d00df231..2e100a41c309 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -1036,6 +1036,8 @@ Reference< XShape > const & Shape::createAndInsert( // applying properties aShapeProps.assignUsed( getShapeProperties() ); aShapeProps.assignUsed( maDefaultShapeProperties ); +if(mnRotation != 0 && bIsCustomShape) +aShapeProps.setProperty( PROP_RotateAngle, sal_Int32( NormAngle36000( mnRotation / -600 ) )); if ( bIsEmbMedia || aServiceName == "com.sun.star.drawing.GraphicObjectShape" || aServiceName == "com.sun.star.drawing.OLE2Shape" || bIsCustomShape ) mpGraphicPropertiesPtr->pushToPropMap( aShapeProps, rGraphicHelper ); if ( mpTablePropertiesPtr.get() && aServiceName == "com.sun.star.drawing.TableShape" ) diff --git a/sd/qa/unit/data/pptx/tdf134174.pptx b/sd/qa/unit/data/pptx/tdf134174.pptx new file mode 100644 index ..ef722dc501a8 Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf134174.pptx differ diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 85fac6becdd1..9ebb55d39a21 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -195,6 +195,7 @@ public: void testTdf100065(); void testTdf90626(); void testTdf114488(); +void testTdf134174(); void testTdf114913(); void testTdf114821(); void testTdf115394(); @@ -305,6 +306,7 @@ public: CPPUNIT_TEST(testTdf100065); CPPUNIT_TEST(testTdf90626); CPPUNIT_TEST(testTdf114488); +CPPUNIT_TEST(testTdf134174); CPPUNIT_TEST(testTdf114913); CPPUNIT_TEST(testTdf114821); CPPUNIT_TEST(testTdf115394); @@ -2590,6 +2592,23 @@ void SdImportTest::testTdf114488() xDocShRef->DoClose(); } +void SdImportTest::testTdf134174() +{ +sd::DrawDocShellRef xDocShRef =
[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - oox/source sd/qa
oox/source/drawingml/fillproperties.cxx |6 oox/source/export/drawingml.cxx | 106 +- sd/qa/unit/data/odp/tdf128345_FullTransparentGradient.odp |binary sd/qa/unit/data/odp/tdf128345_GradientAxial.odp |binary sd/qa/unit/data/odp/tdf128345_GradientLinear.odp |binary sd/qa/unit/data/odp/tdf128345_GradientRadial.odp |binary sd/qa/unit/export-tests-ooxml1.cxx| 80 ++ 7 files changed, 155 insertions(+), 37 deletions(-) New commits: commit 0ff6f5ad44a5fb9903c9a905d2ec55248ee75315 Author: Regina Henschel AuthorDate: Tue Jul 14 22:52:56 2020 +0200 Commit: Miklos Vajna CommitDate: Fri Aug 7 10:29:11 2020 +0200 tdf#128345 pptx export: add transparence gradient in solid fill In case of solid color fill a transparence gradient was not saved. OOXML has no separate element for gradient transparency but has transparency in color gradient stop elements. The patch detects a transparence gradient, combines it with the fill color and exports it as gradFill element. The import was already correct, besides a wrong start or end value in case of a symmetric gradient, which becomes AXIAL in LibreOffice. (cherry picked from commit d187f22b7ff73954e1da39fb954c64bc315298cb) Conflicts: oox/source/drawingml/fillproperties.cxx sd/qa/unit/export-tests-ooxml1.cxx Change-Id: I4243656821629f90125d0408a38165a8a29e6e24 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100286 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index caa54b82ca34..f963f103d2c8 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -529,10 +529,8 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap, aGradient.StartColor = sal_Int32(aStartColor.getColor( rGraphicHelper, nPhClr )); aGradient.EndColor = sal_Int32(aEndColor.getColor( rGraphicHelper, nPhClr )); -if( aStartColor.hasTransparency() ) -nStartTrans = aStartColor.getTransparency()*255/100; -if( aEndColor.hasTransparency() ) -nEndTrans = aEndColor.getTransparency()*255/100; +nStartTrans = aStartColor.hasTransparency() ? aStartColor.getTransparency()*255/100 : 0; +nEndTrans = aEndColor.hasTransparency() ? aEndColor.getTransparency()*255/100 : 0; aGradient.Border = rtl::math::round(100*nBorder); } diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 327d5a27931a..b9c6403caff2 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -405,8 +405,38 @@ void DrawingML::WriteSolidFill( const Reference< XPropertySet >& rXPropSet ) nAlpha = (MAX_PERCENT - ( PER_PERCENT * nTransparency ) ); } +// OOXML has no separate transparence gradient but uses transparency in the gradient stops. +// So we merge transparency and color and use gradient fill in such case. +awt::Gradient aTransparenceGradient; +bool bNeedGradientFill(false); +if (GetProperty(rXPropSet, "FillTransparenceGradient")) +{ +mAny >>= aTransparenceGradient; +if (aTransparenceGradient.StartColor != aTransparenceGradient.EndColor) +bNeedGradientFill = true; +else if (aTransparenceGradient.StartColor != 0) +nAlpha = GetAlphaFromTransparenceGradient(aTransparenceGradient, true); +} + // write XML -if ( nFillColor != nOriginalColor ) +if (bNeedGradientFill) +{ +awt::Gradient aPseudoColorGradient; +aPseudoColorGradient.XOffset = aTransparenceGradient.XOffset; +aPseudoColorGradient.YOffset = aTransparenceGradient.YOffset; +aPseudoColorGradient.StartIntensity = 100; +aPseudoColorGradient.EndIntensity = 100; +aPseudoColorGradient.Angle = aTransparenceGradient.Angle; +aPseudoColorGradient.Border = aTransparenceGradient.Border; +aPseudoColorGradient.Style = aTransparenceGradient.Style; +aPseudoColorGradient.StartColor = nFillColor; +aPseudoColorGradient.EndColor = nFillColor; +aPseudoColorGradient.StepCount = aTransparenceGradient.StepCount; +mpFS->startElementNS(XML_a, XML_gradFill, XML_rotWithShape, "0"); +WriteGradientFill(aPseudoColorGradient, aTransparenceGradient); +mpFS->endElementNS( XML_a, XML_gradFill ); +} +else if ( nFillColor != nOriginalColor ) { // the user has set a different color for the shape WriteSolidFill( ::Color(nFillColor & 0xff), nAlpha ); @@ -586,25 +616,25 @@ void
[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - oox/source sd/qa
oox/source/ppt/pptshapecontext.cxx| 21 +++-- sd/qa/unit/data/ppt/placeholder-priority.pptx |binary sd/qa/unit/import-tests.cxx | 20 3 files changed, 39 insertions(+), 2 deletions(-) New commits: commit ad48ab32a3a083741bc003da7d6b3115f7f6cd33 Author: Gülşah Köse AuthorDate: Sat Aug 1 01:39:26 2020 +0300 Commit: Andras Timar CommitDate: Thu Aug 6 10:47:28 2020 +0200 tdf#133687 Fix the placeholders priority order. When we don't have type attribute on slide but have on slidelayout we have to use it instead of default type. Change-Id: Ibb874b5ee39c48641484fe1a8686f66c31695f76 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99904 Tested-by: Jenkins Reviewed-by: Gülşah Köse Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100097 Tested-by: Jenkins CollaboraOffice Reviewed-by: Andras Timar diff --git a/oox/source/ppt/pptshapecontext.cxx b/oox/source/ppt/pptshapecontext.cxx index c0c81effba0c..44dbac4d8994 100644 --- a/oox/source/ppt/pptshapecontext.cxx +++ b/oox/source/ppt/pptshapecontext.cxx @@ -77,10 +77,28 @@ ContextHandlerRef PPTShapeContext::onCreateContext( sal_Int32 aElementToken, con } case PPT_TOKEN( ph ): { +SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() ); +OptValue< sal_Int32 > oSubType( rAttribs.getToken( XML_type) ); sal_Int32 nSubType( rAttribs.getToken( XML_type, XML_obj ) ); +sal_Int32 nSubTypeIndex; +oox::drawingml::ShapePtr pTmpPlaceholder; + mpShapePtr->setSubType( nSubType ); + if( rAttribs.hasAttribute( XML_idx ) ) -mpShapePtr->setSubTypeIndex( rAttribs.getString( XML_idx ).get().toInt32() ); +{ +nSubTypeIndex = rAttribs.getString( XML_idx ).get().toInt32(); +mpShapePtr->setSubTypeIndex( nSubTypeIndex ); + +if(!oSubType.has() && pMasterPersist) +{ +pTmpPlaceholder = PPTShape::findPlaceholderByIndex( nSubTypeIndex, pMasterPersist->getShapes()->getChildren() ); + +if(pTmpPlaceholder) +nSubType = pTmpPlaceholder->getSubType(); // When we don't have type attribute on slide but have on slidelayout we have to use it instead of default type +} +} + if ( nSubType ) { PPTShape* pPPTShapePtr = dynamic_cast< PPTShape* >( mpShapePtr.get() ); @@ -137,7 +155,6 @@ ContextHandlerRef PPTShapeContext::onCreateContext( sal_Int32 aElementToken, con } else if ( eShapeLocation == Slide ) // normal slide shapes have to search within the corresponding master tree for referenced objects { - SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() ); if ( pMasterPersist.get() ) { pPlaceholder = PPTShape::findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, diff --git a/sd/qa/unit/data/ppt/placeholder-priority.pptx b/sd/qa/unit/data/ppt/placeholder-priority.pptx new file mode 100644 index ..d11dc4785f54 Binary files /dev/null and b/sd/qa/unit/data/ppt/placeholder-priority.pptx differ diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index bd719567104c..793f99c6cd8f 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -129,6 +129,7 @@ public: void testN828390_2(); void testN828390_3(); void testFdo68594(); +void testPlaceholderPriority(); void testFdo72998(); void testFdo77027(); void testStrictOOXML(); @@ -236,6 +237,7 @@ public: CPPUNIT_TEST(testN828390_2); CPPUNIT_TEST(testN828390_3); CPPUNIT_TEST(testFdo68594); +CPPUNIT_TEST(testPlaceholderPriority); CPPUNIT_TEST(testFdo72998); CPPUNIT_TEST(testFdo77027); CPPUNIT_TEST(testStrictOOXML); @@ -683,6 +685,24 @@ void SdImportTest::testFdo68594() xDocShRef->DoClose(); } +void SdImportTest::testPlaceholderPriority() +{ +sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/ppt/placeholder-priority.pptx"), PPTX); + +const SdrPage* pPage = GetPage( 1, xDocShRef ); +CPPUNIT_ASSERT_EQUAL_MESSAGE("Missing placeholder", sal_uInt32(2), sal_uInt32(pPage->GetObjCount())); + +tools::Rectangle pObj1Rect(9100, 3500, 29619, 4038); +SdrObject *pObj1 = pPage->GetObj(0); +CPPUNIT_ASSERT_EQUAL_MESSAGE("Placeholder position is wrong, check the placeholder priority", pObj1Rect, pObj1->GetCurrentBoundRect()); + +tools::Rectangle pObj2Rect(9102, 8643, 29619, 12642); +SdrObject *pObj2 = pPage->GetObj(1); +
[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - oox/source sd/qa
oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 22 oox/source/drawingml/diagram/diagramlayoutatoms.hxx |1 oox/source/drawingml/diagram/layoutnodecontext.cxx | 19 - sd/qa/unit/import-tests-smartart.cxx|5 ++-- 4 files changed, 44 insertions(+), 3 deletions(-) New commits: commit 8c653a9badf2b3383215ac5cfd2630a7af1853e7 Author: Miklos Vajna AuthorDate: Tue Aug 4 10:58:00 2020 +0200 Commit: Miklos Vajna CommitDate: Wed Aug 5 10:46:31 2020 +0200 oox smartart: add support for This changes the order of children, which matters when they have no explicit ZOrder. With this, the text shapes on the arrow shape are on top of the arrow, not behind it. The trick is that nominally chOrder can be "t"(op) or "b"(ottom), defaulting to bottom, but there is a difference between an explicit "b" and not setting it. When not setting it, the layout node is expected to inherit it from its parent layout node, recursively. This would probably make sense for other algorithms as well, but set it only for the linear algorithm for now, as that's where we have a bug document showing the PowerPoint behavior. (cherry picked from commit 3c185bf386b4c9609ab32d19bf95b83fe0a3) Change-Id: I433f92c620149ef5590aebc8cbf43110e1d2fb85 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100115 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index 13e684d7b76f..44a66f819e98 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -1147,6 +1147,28 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector& if (aCurrShape->getSubType() == XML_conn) aCurrShape->setRotation(nConnectorAngle * PER_DEGREE); } + +// Newer shapes are behind older ones by default. Reverse this if requested. +sal_Int32 nChildOrder = XML_b; +const LayoutNode* pParentLayoutNode = nullptr; +for (LayoutAtomPtr pAtom = getParent(); pAtom; pAtom = pAtom->getParent()) +{ +auto pLayoutNode = dynamic_cast(pAtom.get()); +if (pLayoutNode) +{ +pParentLayoutNode = pLayoutNode; +break; +} +} +if (pParentLayoutNode) +{ +nChildOrder = pParentLayoutNode->getChildOrder(); +} +if (nChildOrder == XML_t) +{ +std::reverse(rShape->getChildren().begin(), rShape->getChildren().end()); +} + break; } diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx index 8904e525a181..ab152bed0b70 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx @@ -272,6 +272,7 @@ public: { msStyleLabel = sLabel; } void setChildOrder( sal_Int32 nOrder ) { mnChildOrder = nOrder; } +sal_Int32 getChildOrder() const { return mnChildOrder; } void setExistingShape( const ShapePtr& pShape ) { mpExistingShape = pShape; } const ShapePtr& getExistingShape() const diff --git a/oox/source/drawingml/diagram/layoutnodecontext.cxx b/oox/source/drawingml/diagram/layoutnodecontext.cxx index 7157176053d8..f7308b6623bf 100644 --- a/oox/source/drawingml/diagram/layoutnodecontext.cxx +++ b/oox/source/drawingml/diagram/layoutnodecontext.cxx @@ -195,7 +195,24 @@ LayoutNodeContext::onCreateContext( ::sal_Int32 aElement, { LayoutNodePtr pNode( new LayoutNode(mpNode->getLayoutNode().getDiagram()) ); LayoutAtom::connect(mpNode, pNode); -pNode->setChildOrder( rAttribs.getToken( XML_chOrder, XML_b ) ); + +if (rAttribs.hasAttribute(XML_chOrder)) +{ +pNode->setChildOrder(rAttribs.getToken(XML_chOrder, XML_b)); +} +else +{ +for (LayoutAtomPtr pAtom = mpNode; pAtom; pAtom = pAtom->getParent()) +{ +auto pLayoutNode = dynamic_cast(pAtom.get()); +if (pLayoutNode) +{ +pNode->setChildOrder(pLayoutNode->getChildOrder()); +break; +} +} +} + pNode->setMoveWith( rAttribs.getString( XML_moveWith ).get() ); pNode->setStyleLabel( rAttribs.getString( XML_styleLbl ).get() ); return new LayoutNodeContext( *this, rAttribs, pNode ); diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx index 4425c560d676..110b7d2c81ea 100644 ---
[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - oox/source sd/qa
oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 48 sd/qa/unit/data/pptx/smartart-linear-rule.pptx |binary sd/qa/unit/import-tests-smartart.cxx|8 +++ 3 files changed, 48 insertions(+), 8 deletions(-) New commits: commit b193ca37569f0e916a9d827e8a78ebbba4577a5b Author: Miklos Vajna AuthorDate: Fri Jul 31 15:59:10 2020 +0200 Commit: Miklos Vajna CommitDate: Wed Aug 5 10:45:38 2020 +0200 oox smartart, linear layout: correctly scale spacings wrt constraints and rules When constraints request a width which is larger than 100%, we scale down. Then rules decide which children should be scaled down and which ones stay as-is. This commit adjusts the size of children which have no rule, but their size has a constraint that they're a fraction of a scaled down child. (cherry picked from commit 91f0f7e5e0a55cb1dbd729a1d7de52388b1cfb15) Change-Id: I0a007d82f49f18951215afb1bfe8c0f1328ecd41 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100111 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index b748298f7c1c..fc1b58e24d27 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -906,7 +906,7 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector& const sal_Int32 nIncX = nDir==XML_fromL ? 1 : (nDir==XML_fromR ? -1 : 0); const sal_Int32 nIncY = nDir==XML_fromT ? 1 : (nDir==XML_fromB ? -1 : 0); -sal_Int32 nCount = rShape->getChildren().size(); +double fCount = rShape->getChildren().size(); sal_Int32 nConnectorAngle = 0; switch (nDir) { @@ -953,18 +953,50 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector& if (!aChildrenToShrink.empty()) { // Have scaling info from rules: then only count scaled children. +// Also count children which are a fraction of a scaled child. +std::set aChildrenToShrinkDeps; for (auto& aCurrShape : rShape->getChildren()) { if (aChildrenToShrink.find(aCurrShape->getInternalName()) == aChildrenToShrink.end()) { -if (nCount > 1) +if (fCount > 1.0) { ---nCount; +fCount -= 1.0; + +for (const auto& rConstraint : rConstraints) +{ +if (rConstraint.msForName != aCurrShape->getInternalName()) +{ +continue; +} + +if (aChildrenToShrink.find(rConstraint.msRefForName) == aChildrenToShrink.end()) +{ +continue; +} + +if ((nDir == XML_fromL || nDir == XML_fromR) && rConstraint.mnType != XML_w) +{ +continue; +} +if ((nDir == XML_fromT || nDir == XML_fromB) && rConstraint.mnType != XML_h) +{ +continue; +} + +// At this point we have a child with a size which is a factor of an +// other child which will be scaled. +fCount += rConstraint.mfFactor; + aChildrenToShrinkDeps.insert(aCurrShape->getInternalName()); +break; +} } } } +aChildrenToShrink.insert(aChildrenToShrinkDeps.begin(), aChildrenToShrinkDeps.end()); + // No manual spacing: spacings are children as well. aSpaceSize = awt::Size(); } @@ -979,13 +1011,13 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector& && aChild->getChildren().empty(); }), rShape->getChildren().end()); -nCount = rShape->getChildren().size(); +fCount = rShape->getChildren().size(); } awt::Size aChildSize = rShape->getSize(); if (nDir == XML_fromL || nDir == XML_fromR) -aChildSize.Width /= nCount; +aChildSize.Width
[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - oox/source sd/qa
oox/source/drawingml/diagram/diagram.cxx| 20 + oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 72 ++-- oox/source/drawingml/diagram/layoutatomvisitors.cxx |6 - sd/qa/unit/data/pptx/smartart-linear-rule.pptx |binary sd/qa/unit/import-tests-smartart.cxx| 19 + 5 files changed, 106 insertions(+), 11 deletions(-) New commits: commit a7e1a2c2bb6b02a41b9eb1d2dccbbd28e0eac49b Author: Miklos Vajna AuthorDate: Fri Jul 31 11:04:02 2020 +0200 Commit: Miklos Vajna CommitDate: Wed Aug 5 08:54:56 2020 +0200 oox smartart: consider rules when scaling in linear layout The bugdoc has an arrow shape which is 100% wide, and there are multiple shapes before it, which also have a 100% wide constraint. The reason PowerPoint scales down the shapes (but not the arrow) is because rules declare it should happen this way. So start taking rules into account in linear layouts. (cherry picked from commit 0024c48b4822062995effed7db4f1281196384bb) Conflicts: sd/qa/unit/import-tests-smartart.cxx Change-Id: I352443277e88be0eb711659489587127727a258f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100110 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/oox/source/drawingml/diagram/diagram.cxx b/oox/source/drawingml/diagram/diagram.cxx index a03a06c39125..509a1f845e25 100644 --- a/oox/source/drawingml/diagram/diagram.cxx +++ b/oox/source/drawingml/diagram/diagram.cxx @@ -82,6 +82,25 @@ static void sortChildrenByZOrder(const ShapePtr& pShape) sortChildrenByZOrder(rChild); } +/// Removes empty group shapes, now that their spacing influenced the layout. +static void removeUnneededGroupShapes(const ShapePtr& pShape) +{ +std::vector& rChildren = pShape->getChildren(); + +rChildren.erase(std::remove_if(rChildren.begin(), rChildren.end(), + [](const ShapePtr& aChild) { + return aChild->getServiceName() + == "com.sun.star.drawing.GroupShape" + && aChild->getChildren().empty(); + }), +rChildren.end()); + +for (const auto& pChild : rChildren) +{ +removeUnneededGroupShapes(pChild); +} +} + void Diagram::addTo( const ShapePtr & pParentShape ) { if (pParentShape->getSize().Width == 0 || pParentShape->getSize().Height == 0) @@ -103,6 +122,7 @@ void Diagram::addTo( const ShapePtr & pParentShape ) mpLayout->getNode()->accept(aLayoutingVisitor); sortChildrenByZOrder(pParentShape); +removeUnneededGroupShapes(pParentShape); } ShapePtr pBackground(new Shape("com.sun.star.drawing.CustomShape")); diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index 82e826da0dda..b748298f7c1c 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -19,6 +19,8 @@ #include "diagramlayoutatoms.hxx" +#include + #include "layoutatomvisitorbase.hxx" #include @@ -479,10 +481,21 @@ void ApplyConstraintToLayout(const Constraint& rConstraint, LayoutPropertyMap& r } } -void AlgAtom::layoutShape( const ShapePtr& rShape, - const std::vector& rConstraints, - const std::vector& /*rRules*/ ) +void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector& rConstraints, + const std::vector& rRules) { +if (mnType != XML_lin) +{ +// TODO Handle spacing from constraints for non-lin algorithms as well. +rShape->getChildren().erase( +std::remove_if(rShape->getChildren().begin(), rShape->getChildren().end(), + [](const ShapePtr& aChild) { + return aChild->getServiceName() == "com.sun.star.drawing.GroupShape" + && aChild->getChildren().empty(); + }), +rShape->getChildren().end()); +} + switch(mnType) { case XML_composite: @@ -929,6 +942,45 @@ void AlgAtom::layoutShape( const ShapePtr& rShape, } // first approximation of children size +std::set aChildrenToShrink; +for (const auto& rRule : rRules) +{ +// Consider rules: when scaling down, only change children where the rule allows +// doing so. +aChildrenToShrink.insert(rRule.msForName); +} + +if (!aChildrenToShrink.empty()) +{ +// Have scaling info from rules: then only count scaled children. +for (auto& aCurrShape : rShape->getChildren()) +
[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - oox/source sd/qa
oox/source/export/drawingml.cxx | 13 +++ sd/qa/unit/data/pptx/customshape-bitmapfill-srcrect.pptx |binary sd/qa/unit/export-tests-ooxml1.cxx | 25 +++ 3 files changed, 38 insertions(+) New commits: commit 34dbd676ffb38fdd2f3a49dcff54925b98486eb2 Author: Miklos Vajna AuthorDate: Wed Jun 10 14:51:04 2020 +0200 Commit: Miklos Vajna CommitDate: Mon Jun 15 10:24:01 2020 +0200 PPTX export, custom shape, bitmap fill: fix source vs fill rect confusion Commit 682ab832522b1349f1714bcb16f6e83468ea2920 (drawingML export\import: cropping of shape's fill texture, 2014-02-12) improved the DOCX filter, so the fill rectangle of a custom shape with bitmap fill is handled. The problem is drawingML has a source rectangle (similar to our crop rect) to limit the usage of the bitmap, and also it has a fill rectangle in case some margin is wanted around a stretched bitmap. We don't have a mapping for the later. Fix the problem by limiting the above work for DOCX, this way PPTX's source rectangle won't be turned into a stretch's fill rectangle. This way no unwanted margins will appear around the image -- those margins can be large enough that the image effectively disappears on export. (cherry picked from commit b00e43fa5848be0cc7ba81b185021511d94cdc00) Change-Id: Ic35063545a56eec9eaf885bbd397a854705d134f diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 8ca75aaa9522..327d5a27931a 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1455,6 +1455,12 @@ void DrawingML::WriteXGraphicBlipFill(uno::Reference const WriteXGraphicBlip(rXPropSet, rxGraphic, bRelPathToMedia); +if (GetDocumentType() != DOCUMENT_DOCX) +{ +// Write the crop rectangle of Impress as a source rectangle. +WriteSrcRectXGraphic(rXPropSet, rxGraphic); +} + if (bWriteMode) { WriteXGraphicBlipMode(rXPropSet, rxGraphic); @@ -1550,6 +1556,13 @@ void DrawingML::WriteSrcRectXGraphic(uno::Reference const & void DrawingML::WriteXGraphicStretch(uno::Reference const & rXPropSet, uno::Reference const & rxGraphic) { +if (GetDocumentType() != DOCUMENT_DOCX) +{ +// Limiting the area used for stretching is not supported in Impress. +mpFS->singleElementNS(XML_a, XML_stretch); +return; +} + mpFS->startElementNS(XML_a, XML_stretch); bool bCrop = false; diff --git a/sd/qa/unit/data/pptx/customshape-bitmapfill-srcrect.pptx b/sd/qa/unit/data/pptx/customshape-bitmapfill-srcrect.pptx new file mode 100644 index ..e162f7e9923f Binary files /dev/null and b/sd/qa/unit/data/pptx/customshape-bitmapfill-srcrect.pptx differ diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx index 769bf6e52456..0da3de5332b6 100644 --- a/sd/qa/unit/export-tests-ooxml1.cxx +++ b/sd/qa/unit/export-tests-ooxml1.cxx @@ -90,6 +90,7 @@ public: void testRoundtripOwnLineStyles(); void testRoundtripPrstDash(); void testDashOnHairline(); +void testCustomshapeBitmapfillSrcrect(); CPPUNIT_TEST_SUITE(SdOOXMLExportTest1); @@ -129,6 +130,7 @@ public: CPPUNIT_TEST(testRoundtripOwnLineStyles); CPPUNIT_TEST(testRoundtripPrstDash); CPPUNIT_TEST(testDashOnHairline); +CPPUNIT_TEST(testCustomshapeBitmapfillSrcrect); CPPUNIT_TEST_SUITE_END(); @@ -1071,6 +1073,29 @@ void SdOOXMLExportTest1::testDashOnHairline() assertXPath(pXmlDoc, sXmlPath, 11); } +void SdOOXMLExportTest1::testCustomshapeBitmapfillSrcrect() +{ +::sd::DrawDocShellRef xDocShRef = loadURL( + m_directories.getURLFromSrc("sd/qa/unit/data/pptx/customshape-bitmapfill-srcrect.pptx"), +PPTX); +utl::TempFile tempFile; +xDocShRef = saveAndReload(xDocShRef.get(), PPTX, ); +xDocShRef->DoClose(); + +xmlDocPtr pXmlDoc = parseExport(tempFile, "ppt/slides/slide1.xml"); +const OString sXmlPath = "//a:blipFill/a:srcRect"; +// Without the accompanying fix in place, this test would have failed with: +// - Expected: 1 +// - Actual : 0 +// - XPath '//a:blipFill/a:srcRect' number of nodes is incorrect +// i.e. was exported as in , which made part of the image +// invisible. +double fLeftPercent = std::round(getXPath(pXmlDoc, sXmlPath, "l").toDouble() / 1000); +CPPUNIT_ASSERT_EQUAL(4.0, fLeftPercent); +double fRightPercent = std::round(getXPath(pXmlDoc, sXmlPath, "r").toDouble() / 1000); +CPPUNIT_ASSERT_EQUAL(4.0, fRightPercent); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest1); CPPUNIT_PLUGIN_IMPLEMENT(); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits