[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - oox/source sd/qa
oox/source/drawingml/table/predefined-table-styles.cxx |6 +-- sd/qa/unit/data/pptx/tdf132472.pptx|binary sd/qa/unit/export-tests-ooxml2.cxx | 31 + 3 files changed, 34 insertions(+), 3 deletions(-) New commits: commit b20c3473a9ba9ca0f96e9d004989233a32d3853c Author: Xisco Fauli AuthorDate: Thu Apr 22 14:10:57 2021 +0200 Commit: Xisco Fauli CommitDate: Mon Apr 26 16:37:59 2021 +0200 tdf#132472: do not set text color when table style is 'Themed-Style-2' and it has no Accent Regression from 2c3f7d4ee0a0b2bf6efc41670645bd361f1b76ef < tdf#107604 Handle predefined table styles. > Change-Id: Id9ab5b20825e2eaf8cc138c108608fe446f33db4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114477 Tested-by: Jenkins Reviewed-by: Xisco Fauli (cherry picked from commit 54f7c32beca5a9c99d7316dc38818edad55f7415) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114497 Reviewed-by: Miklos Vajna Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114649 diff --git a/oox/source/drawingml/table/predefined-table-styles.cxx b/oox/source/drawingml/table/predefined-table-styles.cxx index 4a8aec4cef1a..ea6892a0 100644 --- a/oox/source/drawingml/table/predefined-table-styles.cxx +++ b/oox/source/drawingml/table/predefined-table-styles.cxx @@ -516,11 +516,11 @@ std::unique_ptr CreateTableStyle(const OUString& styleId) } else if (style_name == "Themed-Style-2") { -wholeTblTextColor.setSchemeClr(XML_lt1); -firstRowTextColor.setSchemeClr(XML_lt1); - if (!accent_name.isEmpty()) { +wholeTblTextColor.setSchemeClr(XML_lt1); +firstRowTextColor.setSchemeClr(XML_lt1); + accent_val = tokens[mStyleIdMap[styleId].second]; pTblBgFillProperties->maFillColor.setSchemeClr(accent_val); diff --git a/sd/qa/unit/data/pptx/tdf132472.pptx b/sd/qa/unit/data/pptx/tdf132472.pptx new file mode 100644 index ..e7873dcd5090 Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf132472.pptx differ diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index c6d2f48aedde..553262385796 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -92,6 +92,7 @@ public: void testTdf119015(); void testTdf123090(); void testTdf126324(); +void testTdf132472(); void testTdf80224(); void testExportTransitionsPPTX(); void testPresetShapesExport(); @@ -208,6 +209,7 @@ public: CPPUNIT_TEST(testTdf119015); CPPUNIT_TEST(testTdf123090); CPPUNIT_TEST(testTdf126324); +CPPUNIT_TEST(testTdf132472); CPPUNIT_TEST(testTdf80224); CPPUNIT_TEST(testExportTransitionsPPTX); CPPUNIT_TEST(testPresetShapesExport); @@ -570,6 +572,35 @@ void SdOOXMLExportTest2::testTdf126324() xDocShRef->DoClose(); } +void SdOOXMLExportTest2::testTdf132472() +{ +sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf132472.pptx"), PPTX ); +const SdrPage *pPage = GetPage( 1, xDocShRef ); + +sdr::table::SdrTableObj *pTableObj = dynamic_cast(pPage->GetObj(0)); +CPPUNIT_ASSERT( pTableObj ); + +uno::Reference< table::XCellRange > xTable(pTableObj->getTable(), uno::UNO_QUERY_THROW); +uno::Reference< beans::XPropertySet > xCell; +Color nColor; + +xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW); +xCell->getPropertyValue("FillColor") >>= nColor; +CPPUNIT_ASSERT_EQUAL(Color(0x729fcf), nColor); + +uno::Reference xParagraph(getParagraphFromShape(0, xCell)); +uno::Reference xRun(getRunFromParagraph(0, xParagraph)); +uno::Reference xPropSet(xRun, uno::UNO_QUERY); +xPropSet->getPropertyValue("CharColor") >>= nColor; + +// Without the fix in place, this test would have failed with +// - Expected: Color: R:0 G:0 B:0 A:0 +// - Actual : Color: R:255 G:255 B:255 A:0 +CPPUNIT_ASSERT_EQUAL(COL_BLACK, nColor); + +xDocShRef->DoClose(); +} + void SdOOXMLExportTest2::testTdf80224() { ::sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/odp/tdf80224.odp"), ODP); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - oox/source sd/qa
oox/source/ppt/timenode.cxx | 57 ++-- sd/qa/unit/data/pptx/tdf128550.pptx |binary sd/qa/unit/export-tests.cxx | 14 3 files changed, 63 insertions(+), 8 deletions(-) New commits: commit d56e4aea5fd5d777204f9f4e4b14cf0047348beb Author: Mark Hung AuthorDate: Sat Jan 16 23:48:56 2021 +0800 Commit: Xisco Fauli CommitDate: Thu Jan 21 15:30:11 2021 +0100 tdf#128550 set sub item on the ancestor node. The target of a animation node may resolved to a subitem. However it only has effect on a iterate container or animate node, not on any other containers. Subitem setting like background and paragraph got ignored, so everything were shown together. The patch find the ancestor node that is iterate container or animate, and set the subitem on it. Change-Id: Iaaa52aed3a34eb2d70b3b318b8336246e17e1e98 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109444 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit 9b19bf0283b569a5c134de6b5cce1d72d8f37879) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109679 Reviewed-by: Michael Stahl Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109754 diff --git a/oox/source/ppt/timenode.cxx b/oox/source/ppt/timenode.cxx index 41fb39fba150..4071f8b6a8b8 100644 --- a/oox/source/ppt/timenode.cxx +++ b/oox/source/ppt/timenode.cxx @@ -51,8 +51,37 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::animations; using namespace ::com::sun::star::presentation; -namespace oox::ppt { +namespace { + +void lcl_setAncestorSubItem( const Reference& xParent, sal_Int16 nSubItem ) +{ + +Reference xNode = xParent; + +while ( xNode.is() ) +{ +if ( xNode->getType() == AnimationNodeType::ANIMATE ) +{ +Reference xAnimate( xNode, UNO_QUERY ); +if ( xAnimate.is() ) +xAnimate->setSubItem( nSubItem ); +break; +} +else if ( xNode->getType() == AnimationNodeType::ITERATE ) +{ +Reference xIterateContainer( xNode, UNO_QUERY ); +if ( xIterateContainer.is() ) +xIterateContainer->setSubItem( nSubItem ); +break; +} + +xNode.set( xNode->getParent(), UNO_QUERY ); +} +} + +} +namespace oox::ppt { OUString TimeNode::getServiceName( sal_Int16 nNodeType ) { OUString sServiceName; @@ -225,11 +254,17 @@ namespace oox::ppt { if( mpTarget ) { -sal_Int16 nSubType(0); -maNodeProperties[ NP_TARGET ] = mpTarget->convert( pSlide, nSubType ); +sal_Int16 nSubItem(0); +maNodeProperties[ NP_TARGET ] = mpTarget->convert( pSlide, nSubItem ); if( mpTarget->mnType == XML_spTgt ) { -maNodeProperties[ NP_SUBITEM ] <<= nSubType; +if ( xNode->getType() == AnimationNodeType::ANIMATE || +xNode->getType() == AnimationNodeType::ITERATE ) +{ +maNodeProperties[ NP_SUBITEM ] <<= nSubItem; +} +else +lcl_setAncestorSubItem( xParent, nSubItem ); } } @@ -338,15 +373,21 @@ namespace oox::ppt { } break; case NP_SUBITEM: -if( xAnimate.is() ) +if( aValue >>= nInt16 ) { -if( aValue >>= nInt16 ) +if( xAnimate.is() ) +{ xAnimate->setSubItem( nInt16 ); -else +} +else if ( xIterateContainer.is() ) { -SAL_INFO("oox.ppt","any >>= failed " << __LINE__ ); +xIterateContainer->setSubItem( nInt16 ); } } +else +{ +SAL_INFO("oox.ppt","any >>= failed " << __LINE__ ); +} break; case NP_ATTRIBUTENAME: if( xAnimate.is() ) diff --git a/sd/qa/unit/data/pptx/tdf128550.pptx b/sd/qa/unit/data/pptx/tdf128550.pptx new file mode 100755 index ..e2be342b2e51 Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf128550.pptx differ diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index a2186fae62af..b5db56f0bf7a 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -76,6 +76,7 @@ public: void
[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - 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 21755f2ab58cc053f9555c3d77241689c225d233 Author: Miklos Vajna AuthorDate: Tue Jan 12 10:13:14 2021 +0100 Commit: Xisco Fauli CommitDate: Wed Jan 13 08:53:38 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/+/109120 Tested-by: Jenkins Reviewed-by: Xisco Fauli diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index 7f926cc9a5e8..24acaf176491 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -1286,7 +1286,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 4fe544a86000..b243a2bc395f 100644 --- a/sd/qa/unit/import-tests-smartart.cxx +++ b/sd/qa/unit/import-tests-smartart.cxx @@ -75,6 +75,7 @@ public: void testRotation(); void testTextAutoRotation(); void testPyramid(); +void testPyramidOneChild(); void testChevron(); void testCycle(); void testvenndiagram(); @@ -125,6 +126,7 @@ public: CPPUNIT_TEST(testRotation); CPPUNIT_TEST(testTextAutoRotation); CPPUNIT_TEST(testPyramid); +CPPUNIT_TEST(testPyramidOneChild); CPPUNIT_TEST(testChevron); CPPUNIT_TEST(testCycle); CPPUNIT_TEST(testHierarchy); @@ -429,6 +431,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 'libreoffice-7-0' - 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 8753e4e3ac000d325aedc9bb004c271f2e18e8c2 Author: Miklos Vajna AuthorDate: Mon Oct 19 21:07:10 2020 +0200 Commit: Xisco Fauli CommitDate: Tue Oct 20 13:45:41 2020 +0200 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/+/104550 Tested-by: Jenkins Reviewed-by: Xisco Fauli diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index 5de660a3b6e4..7f926cc9a5e8 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -1045,6 +1045,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 cd59f646a5e4..4fe544a86000 100644 --- a/sd/qa/unit/import-tests-smartart.cxx +++ b/sd/qa/unit/import-tests-smartart.cxx @@ -110,6 +110,7 @@ public: void testTdf131553(); void testFillColorList(); void testLinearRule(); +void testLinearRuleVert(); void testAutofitSync(); void testSnakeRows(); @@ -159,6 +160,7 @@ public: CPPUNIT_TEST(testTdf131553); CPPUNIT_TEST(testFillColorList); CPPUNIT_TEST(testLinearRule); +CPPUNIT_TEST(testLinearRuleVert); CPPUNIT_TEST(testAutofitSync); CPPUNIT_TEST(testSnakeRows); @@ -1552,6 +1554,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 'libreoffice-7-0' - oox/source sd/qa
oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 34 sd/qa/unit/import-tests-smartart.cxx|8 +--- 2 files changed, 31 insertions(+), 11 deletions(-) New commits: commit 90b4308f0a7a38ac2ffdcbbed8d4378daf2f45f1 Author: Miklos Vajna AuthorDate: Wed Sep 30 12:41:15 2020 +0200 Commit: Caolán McNamara CommitDate: Wed Sep 30 21:14:07 2020 +0200 oox smartart: snake algo: make sure child shape height stays within parent 1) When applying double outside spacing, introduced with commit 0a29c928afa74123bca05dc089c751603d368467 (oox smartart, picture strip: fix lack of spacing around the picture list, 2019-02-26), make sure that is only applied in the direction of a signle row: i.e. the bugdoc case is left/right outer spacing, but no top/bottom spacing. 2) If a child shape has an aspect ratio request, make sure that it only decreases what would be allocated by default, so the children never leave the parent's rectangle. 3) Fix a mis-match between the first and second row, the unexpected small left padding in the second row was because code assumed that all child shapes have the same width; which is not true, when widths come from constraints. With this in place, we finally do a good rendering of the bugdoc, and child shapes are always within the bounds of the background. (cherry picked from commit 71303c5c23bdb385e9f12c0dbe5d2a0818b836ec) Change-Id: Ia2606dcd945402f7dfe17c6e2f261bfd98667022 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103697 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index bed2ae4ef172..5de660a3b6e4 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -1384,12 +1384,13 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector& const sal_Int32 nDir = maMap.count(XML_grDir) ? maMap.find(XML_grDir)->second : XML_tL; sal_Int32 nIncX = 1; sal_Int32 nIncY = 1; +bool bHorizontal = true; switch (nDir) { case XML_tL: nIncX = 1; nIncY = 1; break; case XML_tR: nIncX = -1; nIncY = 1; break; -case XML_bL: nIncX = 1; nIncY = -1; break; -case XML_bR: nIncX = -1; nIncY = -1; break; +case XML_bL: nIncX = 1; nIncY = -1; bHorizontal = false; break; +case XML_bR: nIncX = -1; nIncY = -1; bHorizontal = false; break; } sal_Int32 nCount = rShape->getChildren().size(); @@ -1453,6 +1454,8 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector& static_cast(nHeight * fChildAspectRatio)); aChildSize = awt::Size(nWidth, nHeight); } + +bHorizontal = false; } awt::Point aCurrPos(0, 0); @@ -1461,8 +1464,13 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector& if (nIncY == -1) aCurrPos.Y = rShape->getSize().Height - aChildSize.Height; else if (bSpaceFromConstraints) -// Initial vertical offset to have upper spacing (outside, so double amount). -aCurrPos.Y = aChildSize.Height * fSpace * 2; +{ +if (!bHorizontal) +{ +// Initial vertical offset to have upper spacing (outside, so double amount). +aCurrPos.Y = aChildSize.Height * fSpace * 2; +} +} sal_Int32 nStartX = aCurrPos.X; sal_Int32 nColIdx = 0,index = 0; @@ -1481,7 +1489,8 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector& // aShapeWidths items are a portion of nMaxRowWidth. We want the same ratio, // based on the original parent width, ignoring the aspect ratio request. double fWidthFactor = static_cast(aShapeWidths[index]) / nMaxRowWidth; -if (nCount >= 2 && rShape->getChildren()[1]->getDataNodeType() == XML_sibTrans) +bool bWidthsFromConstraints = nCount >= 2 && rShape->getChildren()[1]->getDataNodeType() == XML_sibTrans; +if (bWidthsFromConstraints) { // We can only work from constraints if spacing is represented by a real // child shape. @@ -1490,6 +1499,9 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector& if (fChildAspectRatio) { aCurrSize.Height = aCurrSize.Width / fChildAspectRatio; + +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - oox/source sd/qa
oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 57 sd/qa/unit/import-tests-smartart.cxx| 13 +++- 2 files changed, 56 insertions(+), 14 deletions(-) New commits: commit 6eb7158e2b9049587f79e2225964ada1746bd83c Author: Miklos Vajna AuthorDate: Tue Sep 29 17:41:12 2020 +0200 Commit: Caolán McNamara CommitDate: Wed Sep 30 21:13:38 2020 +0200 oox smartart: snake algo: apply constraints on child shape widths This requires tracking what is the total of the width request of child shapes, then scaling them according to what is the total available width. Additionally, the height of child shapes should be adjusted based on their aspect ratio requests. A related trap is when an (invisible) spacing shape is at the end of the row, that would result in smaller spacing between the rows, so track the max height of shapes inside a single row. With this, finally the 6 child shapes are arranged on 2 rows, not 3 ones. (cherry picked from commit 5d899bf3ee59a226f855c8c56389344862efaa95) Change-Id: I4eb2f06676df11c1432e0934ca3a0ec8891c5843 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103696 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index ae9a13df1f80..bed2ae4ef172 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -1308,7 +1308,7 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector& fShapeWidth = fShapeHeight * fChildAspectRatio; } -double fSpaceFromConstraint = 0; +double fSpaceFromConstraint = 1.0; LayoutPropertyMap aPropertiesByName; std::map aPropertiesByType; LayoutProperty& rParent = aPropertiesByName[""]; @@ -1316,7 +1316,7 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector& rParent[XML_h] = fShapeHeight; for (const auto& rConstr : rConstraints) { -if (rConstr.mnRefType == XML_h) +if (rConstr.mnRefType == XML_w || rConstr.mnRefType == XML_h) { if (rConstr.mnType == XML_sp && rConstr.msForName.isEmpty()) fSpaceFromConstraint = rConstr.mfFactor; @@ -1379,7 +1379,7 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector& aShapeWidths[i] = it->second; } -bool bSpaceFromConstraints = fSpaceFromConstraint != 0; +bool bSpaceFromConstraints = fSpaceFromConstraint != 1.0; const sal_Int32 nDir = maMap.count(XML_grDir) ? maMap.find(XML_grDir)->second : XML_tL; sal_Int32 nIncX = 1; @@ -1399,6 +1399,7 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector& sal_Int32 nCol = 1; sal_Int32 nRow = 1; +sal_Int32 nMaxRowWidth = 0; if (nCount <= fChildAspectRatio) // Child aspect ratio request (width/height) is N, and we have at most N shapes. // This means we don't need multiple columns. @@ -1408,8 +1409,22 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector& for ( ; nRow(nCount) / nRow); -if ((fShapeHeight * nRow) / (fShapeWidth * nCol) >= fAspectRatio) +sal_Int32 nRowWidth = 0; +for (sal_Int32 i = 0; i < nCol; ++i) { +if (i >= nCount) +{ +break; +} + +nRowWidth += aShapeWidths[i]; +} +if ((fShapeHeight * nRow) / nRowWidth >= fAspectRatio) +{ +if (nRowWidth > nMaxRowWidth) +{ +nMaxRowWidth = nRowWidth; +} break; } } @@ -1457,35 +1472,57 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector& switch(aContDir) { case XML_sameDir: +{ +sal_Int32 nRowHeight = 0; for (auto & aCurrShape : rShape->getChildren()) { aCurrShape->setPosition(aCurrPos); -aCurrShape->setSize(aChildSize); -aCurrShape->setChildSize(aChildSize); +awt::Size aCurrSize(aChildSize); +// aShapeWidths items are a portion of nMaxRowWidth. We want the same ratio, +// based on the original parent width, ignoring the aspect ratio request. +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - 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 e342038e3e9c2e592a91c9c29153381f49290f00 Author: Miklos Vajna AuthorDate: Fri Sep 25 17:27:03 2020 +0200 Commit: Caolán McNamara CommitDate: Wed Sep 30 18:23:36 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/+/103694 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index e68f4e4bdf44..7dc5c5d70cd2 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -1321,11 +1321,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 187b8a9fea56..70f11844a0fd 100644 --- a/sd/qa/unit/import-tests-smartart.cxx +++ b/sd/qa/unit/import-tests-smartart.cxx @@ -111,6 +111,7 @@ public: void testFillColorList(); void testLinearRule(); void testAutofitSync(); +void testSnakeRows(); CPPUNIT_TEST_SUITE(SdImportTestSmartArt); @@ -159,6 +160,7 @@ public: CPPUNIT_TEST(testFillColorList); CPPUNIT_TEST(testLinearRule); CPPUNIT_TEST(testAutofitSync); +CPPUNIT_TEST(testSnakeRows); CPPUNIT_TEST_SUITE_END(); }; @@ -1589,6 +1591,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 'libreoffice-7-0' - 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 5f305e6792c1c166b2a44a1e5085f42f53db50ea Author: Gülşah Köse AuthorDate: Sun Aug 23 22:32:53 2020 +0300 Commit: Andras Timar CommitDate: Tue Aug 25 14:26:42 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/+/101164 Reviewed-by: Andras Timar diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index 7082cbee0186..d62aa714da50 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -71,6 +72,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) { @@ -748,6 +765,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 3fedf4dbb761..3e919af5be80 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -1034,6 +1034,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 && 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 cec91cfb6387..632872f40084 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -199,6 +199,7 @@ public: void testTdf100065(); void testTdf90626(); void testTdf114488(); +void testTdf134174(); void testTdf114913(); void testTdf114821(); void testTdf115394(); @@ -308,6 +309,7 @@ public: CPPUNIT_TEST(testTdf100065); CPPUNIT_TEST(testTdf90626); CPPUNIT_TEST(testTdf114488); +CPPUNIT_TEST(testTdf134174); CPPUNIT_TEST(testTdf114913); CPPUNIT_TEST(testTdf114821); CPPUNIT_TEST(testTdf115394); @@ -2611,6 +2613,23 @@ void SdImportTest::testTdf114488() xDocShRef->DoClose(); } +void SdImportTest::testTdf134174() +{ +sd::DrawDocShellRef xDocShRef =
[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - 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 855420811e13d620dd1d0f016ac4f7da9535954c Author: Regina Henschel AuthorDate: Tue Jul 14 22:52:56 2020 +0200 Commit: Miklos Vajna CommitDate: Fri Aug 7 13:44:19 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: sd/qa/unit/export-tests-ooxml1.cxx Change-Id: I4243656821629f90125d0408a38165a8a29e6e24 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100282 Tested-by: Jenkins Reviewed-by: Miklos Vajna diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index 963c4009becf..f203e9e2823e 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -537,10 +537,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 8a49546c94bd..14910f759598 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -397,8 +397,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 ); @@ -578,25 +608,25 @@ void DrawingML::WriteGrabBagGradientFill( const Sequence< PropertyValue >& aGrad void
[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - 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 84a3c0a924dd074c2c3255739e037f475b7238a5 Author: Miklos Vajna AuthorDate: Fri Jul 31 11:04:02 2020 +0200 Commit: Miklos Vajna CommitDate: Wed Aug 5 11:25:42 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) Change-Id: I352443277e88be0eb711659489587127727a258f Conflicts: sd/qa/unit/import-tests-smartart.cxx Change-Id: I352443277e88be0eb711659489587127727a258f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100102 Tested-by: Jenkins Reviewed-by: Gülşah Köse diff --git a/oox/source/drawingml/diagram/diagram.cxx b/oox/source/drawingml/diagram/diagram.cxx index 5a4fef99cfcb..8265ae7b3a88 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 = std::make_shared("com.sun.star.drawing.CustomShape"); diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index 73f97c0b21cf..42508f5984de 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 @@ -478,10 +480,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: @@ -928,6 +941,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. +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - 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 802fa332fc05a119c525f20a46ac3aaea7900602 Author: Gülşah Köse AuthorDate: Sat Aug 1 01:39:26 2020 +0300 Commit: Xisco Fauli CommitDate: Wed Aug 5 10:23:32 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 (cherry picked from commit e0018be102edd6e376e0622e0a9384176d2f119c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100052 Reviewed-by: Xisco Fauli diff --git a/oox/source/ppt/pptshapecontext.cxx b/oox/source/ppt/pptshapecontext.cxx index 25bcc9200bef..72c96dd8d9c2 100644 --- a/oox/source/ppt/pptshapecontext.cxx +++ b/oox/source/ppt/pptshapecontext.cxx @@ -65,10 +65,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() ); @@ -125,7 +143,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 ) { 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 bc80fb5e3ca3..cec91cfb6387 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -133,6 +133,7 @@ public: void testN828390_2(); void testN828390_3(); void testFdo68594(); +void testPlaceholderPriority(); void testFdo72998(); void testFdo77027(); void testStrictOOXML(); @@ -240,6 +241,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); @@ -686,6 +688,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 'libreoffice-7-0' - oox/source sd/qa
oox/source/drawingml/lineproperties.cxx | 24 - oox/source/export/drawingml.cxx | 49 sd/qa/unit/data/pptx/tdf134053_dashdot.pptx |binary sd/qa/unit/uiimpress.cxx| 34 +++ 4 files changed, 91 insertions(+), 16 deletions(-) New commits: commit 1cbdc101c72309a97e9ee09c77f4fd36fbd71314 Author: Regina Henschel AuthorDate: Sat Jun 20 15:08:12 2020 +0200 Commit: Adolfo Jayme Barrientos CommitDate: Tue Jun 23 16:58:18 2020 +0200 tdf#134053 tweak dash and space length for ooxml OOXML does not specify how line caps are applied to dashes. MS Office keeps dash and space length for preset dash styles and for round custom dash styles and add them for square line caps on custom dash styles. ODF specifies, that the linecaps are added to the dashes and the spaces are reduced, so that the dash-space pair keeps its length. This patch changes the dash and space length on import and export so, that they look nearly the same in LibreOffice as in MS Office. For custom dash styles with square line cap the first dash is longer as in MS Office. I have no solution for that. But I consider it as minor problem, because MS Office has not even an UI for that case. It should not hinder the improvement for the usual cases. Change-Id: I3e3e4b7c9d71e440ed301d2be423100440cb688b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96769 Tested-by: Jenkins Reviewed-by: Regina Henschel (cherry picked from commit 3f3b50015e4fd9efc3459612a70409fca49cf390) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96796 Reviewed-by: Adolfo Jayme Barrientos diff --git a/oox/source/drawingml/lineproperties.cxx b/oox/source/drawingml/lineproperties.cxx index 3183d5ce4c24..451da4c6aa26 100644 --- a/oox/source/drawingml/lineproperties.cxx +++ b/oox/source/drawingml/lineproperties.cxx @@ -443,6 +443,11 @@ void LineProperties::pushToPropMap( ShapePropertyMap& rPropMap, sal_Int32 nLineWidth = getLineWidth(); // includes conversion from EMUs to 1/100mm rPropMap.setProperty( ShapeProperty::LineWidth, nLineWidth ); +// line cap type +LineCap eLineCap = moLineCap.has() ? lclGetLineCap( moLineCap.get() ) : LineCap_BUTT; +if( moLineCap.has() ) +rPropMap.setProperty( ShapeProperty::LineCap, eLineCap ); + // create line dash from preset dash token or dash stop vector (not for invisible line) if( (eLineStyle != drawing::LineStyle_NONE) && (moPresetDash.differsFrom( XML_solid ) || !maCustomDash.empty()) ) { @@ -456,12 +461,25 @@ void LineProperties::pushToPropMap( ShapePropertyMap& rPropMap, lclConvertCustomDash(aLineDash, maCustomDash); lclRecoverStandardDashStyles(aLineDash, nLineWidth); } + +// In MS Office (2020) for preset dash style line caps round and square are included in dash length. +// For custom dash style round line cap is included, square line cap is added. In ODF line caps are +// always added to dash length. Tweak the length accordingly. +if (eLineCap == LineCap_ROUND || (eLineCap == LineCap_SQUARE && maCustomDash.empty())) +{ +// Cannot use -100 because that results in 0 length in some cases and +// LibreOffice interprets 0 length as 100%. +if (aLineDash.DotLen >= 100 || aLineDash.DashLen >= 100) +aLineDash.Distance += 99; +if (aLineDash.DotLen >= 100) +aLineDash.DotLen -= 99; +if (aLineDash.DashLen >= 100) +aLineDash.DashLen -= 99; +} + if( rPropMap.setProperty( ShapeProperty::LineDash, aLineDash ) ) eLineStyle = drawing::LineStyle_DASH; } -// line cap type -if( moLineCap.has() ) -rPropMap.setProperty( ShapeProperty::LineCap, lclGetLineCap( moLineCap.get() ) ); // set final line style property rPropMap.setProperty( ShapeProperty::LineStyle, eLineStyle ); diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index f14129d0a2e8..607db7a33ae7 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -733,10 +733,11 @@ void DrawingML::WriteLineArrow( const Reference< XPropertySet >& rXPropSet, bool void DrawingML::WriteOutline( const Reference& rXPropSet, Reference< frame::XModel > const & xModel ) { drawing::LineStyle aLineStyle( drawing::LineStyle_NONE ); - if (GetProperty(rXPropSet, "LineStyle")) mAny >>= aLineStyle; +const LineCap aLineCap = GetProperty(rXPropSet, "LineCap") ? mAny.get() : LineCap_BUTT; + sal_uInt32 nLineWidth = 0; sal_uInt32 nEmuLineWidth = 0; ::Color nColor; @@ -747,6 +748,7 @@ void DrawingML::WriteOutline( const Reference& rXPropSet, Referenc bool bDashSet = false; bool bNoFill = false; + // get InteropGrabBag
[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - 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 a65dc39cb1589bede8d5220fb1a60487c8537ab4 Author: Miklos Vajna AuthorDate: Wed Jun 10 14:51:04 2020 +0200 Commit: Miklos Vajna CommitDate: Mon Jun 15 09:53:44 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. Change-Id: Ic35063545a56eec9eaf885bbd397a854705d134f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96025 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit b00e43fa5848be0cc7ba81b185021511d94cdc00) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96097 diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index fc5807ee61ba..f14129d0a2e8 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1443,6 +1443,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); @@ -1538,6 +1544,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 5de8eaf770c6..f7cec3010dc7 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(); @@ -1070,6 +1072,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(); + +xmlDocUniquePtr 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();