[Libreoffice-commits] core.git: oox/source sd/qa sd/source

2023-10-31 Thread Henry Castro (via logerrit)
 oox/source/ppt/presentationfragmenthandler.cxx |6 +
 sd/qa/unit/export-tests-ooxml2.cxx |6 -
 sd/qa/unit/export-tests-ooxml3.cxx |4 
 sd/source/filter/eppt/epptooxml.hxx|4 
 sd/source/filter/eppt/pptx-epptooxml.cxx   |  128 +++--
 sd/source/ui/inc/unopage.hxx   |1 
 sd/source/ui/unoidl/unopage.cxx|   13 ++
 7 files changed, 147 insertions(+), 15 deletions(-)

New commits:
commit d590f094ccd28ca449eff91692c2178058d5c621
Author: Henry Castro 
AuthorDate: Tue Oct 17 07:42:52 2023 -0400
Commit: Henry Castro 
CommitDate: Tue Oct 31 12:01:43 2023 +0100

tdf#155512: sd: filter: eppt: add "SlideLayout" property to Slide Master

If it is importing all Slide Master from pptx file, unfortunately
it breaks the exporting to pptx due to save and reload unit test failures

According to the documentation
http://officeopenxml.com/prSlideLayout.php, so the file pptx has a
relationship Slide -> Slide Layout -> Slide Master

The Slide Layout is a template an unique to be reused
with Slide Master, so exporting requires to compare
the templates due to LibreOffice relation Slide -> Slide Master

Adjust unit test values:

SdOOXMLExportTest2::testTdf106867
revert adcde78935fb8ca2b93322aa3a558d0b3ccdbfad

SdOOXMLExportTest2::testTdf112280
revert adcde78935fb8ca2b93322aa3a558d0b3ccdbfad

SdOOXMLExportTest2::testThemeColors and
SdOOXMLExportTest3::testTdf114848
The file tdf84205.pptx does not contain theme2.xml,
and save and reload it does not caintain theme2.xml too
fix "An uncaught exception of type 
com.sun.star.container.NoSuchElementException"

Signed-off-by: Henry Castro 
Change-Id: I622e9d5d68c406ff520387f3903808613d1cd3d9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158084
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Caolán McNamara 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158676
Tested-by: Jenkins

diff --git a/oox/source/ppt/presentationfragmenthandler.cxx 
b/oox/source/ppt/presentationfragmenthandler.cxx
index 8c5fbf261414..edb523161c9e 100644
--- a/oox/source/ppt/presentationfragmenthandler.cxx
+++ b/oox/source/ppt/presentationfragmenthandler.cxx
@@ -230,6 +230,9 @@ SlidePersistPtr 
PresentationFragmentHandler::importMasterSlide(const ReferencegetFragmentPathFromRelation(rEntry.second);
 
 sal_Int32 nIndex;
@@ -286,6 +289,9 @@ SlidePersistPtr 
PresentationFragmentHandler::importMasterSlide(const ReferencecreateBackground( rFilter );
 pMasterPersistPtr->createXShapes( rFilter );
 
+uno::Reference< beans::XPropertySet > 
xSet(pMasterPersistPtr->getPage(), uno::UNO_QUERY_THROW);
+xSet->setPropertyValue("SlideLayout", 
Any(pMasterPersistPtr->getLayoutFromValueToken()));
+
 oox::drawingml::ThemePtr pTheme = pMasterPersistPtr->getTheme();
 if (pTheme)
 {
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx 
b/sd/qa/unit/export-tests-ooxml2.cxx
index 625c04953006..30301c6e4c16 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -1313,7 +1313,7 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testTdf106867)
 
"/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/"
 
"p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:cmd/"
 "p:cBhvr/p:tgtEl/p:spTgt",
-"spid", "491");
+"spid", "42");
 }
 
 CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testTdf112280)
@@ -1694,7 +1694,7 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testAccentColor)
 "70ad47");
 xmlDocUniquePtr pXmlDocTheme2 = parseExport("ppt/theme/theme2.xml");
 assertXPath(pXmlDocTheme2, 
"/a:theme/a:themeElements/a:clrScheme/a:accent6/a:srgbClr", "val",
-"70ad47");
+"deb340");
 
 // Without the accompanying fix in place, this test would have failed with:
 // - Expected: Motyw pakietu Office
@@ -1709,7 +1709,7 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testThemeColors)
 createSdImpressDoc("pptx/tdf84205.pptx");
 save("Impress Office Open XML");
 
-xmlDocUniquePtr pXmlDocTheme2 = parseExport("ppt/theme/theme2.xml");
+xmlDocUniquePtr pXmlDocTheme2 = parseExport("ppt/theme/theme1.xml");
 assertXPath(pXmlDocTheme2, 
"/a:theme/a:themeElements/a:clrScheme/a:dk2/a:srgbClr", "val",
 "44546a");
 assertXPath(pXmlDocTheme2, 
"/a:theme/a:themeElements/a:clrScheme/a:accent3/a:srgbClr", "val",
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index 409a8affc8d5..74bcfebb40a5 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -75,10 +75,6 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf114848)
 xmlDocUniquePtr pXmlDocTheme1 = 

[Libreoffice-commits] core.git: oox/source sd/qa

2023-09-08 Thread Sarper Akdemir (via logerrit)
 oox/source/drawingml/fillproperties.cxx |4 +++-
 sd/qa/unit/data/pptx/tdf156649.pptx |binary
 sd/qa/unit/export-tests.cxx |   14 ++
 3 files changed, 17 insertions(+), 1 deletion(-)

New commits:
commit b0e8ce9967acf3a759e5b85c4a0d16d7dad275fe
Author: Sarper Akdemir 
AuthorDate: Thu Sep 7 13:53:25 2023 +0300
Commit: Sarper Akdemir 
CommitDate: Fri Sep 8 08:58:02 2023 +0200

tdf#156649: oox: correct import alphaModFix for custom shapes

alphaModFix should be imported into PROP_FillTransparency
for custom shapes.

Change-Id: I19621e424a64b097d5e6881877d60de253be636d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156660
Tested-by: Jenkins
Reviewed-by: Sarper Akdemir 

diff --git a/oox/source/drawingml/fillproperties.cxx 
b/oox/source/drawingml/fillproperties.cxx
index 9f18e7d65f7d..ff78f3183831 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -866,7 +866,9 @@ void GraphicProperties::pushToPropMap( PropertyMap& 
rPropMap, const GraphicHelpe
 
 if ( maBlipProps.moAlphaModFix.has_value() )
 {
-rPropMap.setProperty(PROP_Transparency, static_cast(100 
- (maBlipProps.moAlphaModFix.value() / PER_PERCENT)));
+rPropMap.setProperty(
+mbIsCustomShape ? PROP_FillTransparence : PROP_Transparency,
+static_cast(100 - 
(maBlipProps.moAlphaModFix.value() / PER_PERCENT)));
 }
 }
 rPropMap.setProperty(PROP_GraphicColorMode, eColorMode);
diff --git a/sd/qa/unit/data/pptx/tdf156649.pptx 
b/sd/qa/unit/data/pptx/tdf156649.pptx
new file mode 100644
index ..2b3b12a9a092
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf156649.pptx differ
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index 61f6736fc33f..92971d4b4221 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -1577,6 +1577,20 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf140714)
 CPPUNIT_ASSERT_EQUAL(OUString{ "com.sun.star.drawing.CustomShape" }, 
xShape->getShapeType());
 }
 
+CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf156649)
+{
+createSdImpressDoc("pptx/tdf156649.pptx");
+saveAndReload("Impress Office Open XML");
+
+auto xShapeProps(getShapeFromPage(0, 0));
+// Without the fix in place, this test would have failed with
+//- Expected: 55
+//- Actual  : 0
+// i.e. alphaModFix wasn't imported as fill transparency for the custom 
shape
+CPPUNIT_ASSERT_EQUAL(sal_Int16(55),
+ 
xShapeProps->getPropertyValue("FillTransparence").get());
+}
+
 CPPUNIT_TEST_FIXTURE(SdExportTest, testMasterPageBackgroundFullSize)
 {
 createSdImpressDoc("odp/background.odp");


[Libreoffice-commits] core.git: oox/source sd/qa svx/source

2023-08-30 Thread Tibor Nagy (via logerrit)
 oox/source/drawingml/customshapeproperties.cxx|   16 
 oox/source/token/properties.txt   |1 
 sd/qa/unit/data/pptx/tdf156829.pptx   |binary
 sd/qa/unit/data/xml/n762695_0.xml |1 
 sd/qa/unit/data/xml/n762695_1.xml |2 +
 sd/qa/unit/data/xml/tdf109317_0.xml   |3 ++
 sd/qa/unit/import-tests.cxx   |   28 ++
 svx/source/customshapes/EnhancedCustomShape2d.cxx |2 -
 8 files changed, 52 insertions(+), 1 deletion(-)

New commits:
commit 7b93531ba7f3edf98a54392cfc83dcf3185888bd
Author: Tibor Nagy 
AuthorDate: Sun Aug 27 18:39:17 2023 +0200
Commit: László Németh 
CommitDate: Wed Aug 30 11:57:11 2023 +0200

tdf#156829 PPTX import: fix connector regression at missing glue points

Glue points weren't imported if the custom shape type is
"non-primitive", resulting broken line connectors, moreover
broken graphic design, as attached to the original bug report.

~Regression from commit cbf66ec3e60d07efb7c3cceed9b4f0fb4f0510c8
"tdf#89449 PPTX import: fix line connectors".

Change-Id: I9908a23f8e6997bc1384aaeb3e8ba43c08d20d42
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156171
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/drawingml/customshapeproperties.cxx 
b/oox/source/drawingml/customshapeproperties.cxx
index ac6fba8e7d53..766876385c64 100644
--- a/oox/source/drawingml/customshapeproperties.cxx
+++ b/oox/source/drawingml/customshapeproperties.cxx
@@ -228,6 +228,22 @@ void CustomShapeProperties::pushToPropSet(
 aPath.setProperty( PROP_TextFrames, aTextFrames);
 }
 
+if (!maConnectionSiteList.empty())
+{
+css::uno::Sequence seqGluePoints;
+seqGluePoints.realloc(maConnectionSiteList.size());
+sal_Int32 nId = 0;
+for (auto& rGluePoint : asNonConstRange(seqGluePoints))
+{
+rGluePoint.First.Value = 
maConnectionSiteList[nId].pos.First.Value;
+rGluePoint.First.Type = 
maConnectionSiteList[nId].pos.First.Type;
+rGluePoint.Second.Value = 
maConnectionSiteList[nId].pos.Second.Value;
+rGluePoint.Second.Type = 
maConnectionSiteList[nId].pos.Second.Type;
+nId++;
+}
+aPath.setProperty(PROP_GluePoints, seqGluePoints);
+}
+
 sal_uInt32 nParameterPairs = 0;
 for ( auto const & i: maPath2DList )
 nParameterPairs += i.parameter.size();
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index a6de5458b663..b5a3478f45b0 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -224,6 +224,7 @@ GenerateVbaEvents
 Geometry3D
 GlowEffect
 GlowEffectRadius
+GluePoints
 GradientName
 HatchName
 Graphic
diff --git a/sd/qa/unit/data/pptx/tdf156829.pptx 
b/sd/qa/unit/data/pptx/tdf156829.pptx
new file mode 100644
index ..423588377279
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf156829.pptx differ
diff --git a/sd/qa/unit/data/xml/n762695_0.xml 
b/sd/qa/unit/data/xml/n762695_0.xml
index ae755e644de7..59b226e0d5f8 100644
--- a/sd/qa/unit/data/xml/n762695_0.xml
+++ b/sd/qa/unit/data/xml/n762695_0.xml
@@ -63,6 +63,7 @@

   
  
+ 
  
   

diff --git a/sd/qa/unit/data/xml/n762695_1.xml 
b/sd/qa/unit/data/xml/n762695_1.xml
index a43924138f45..02d3b735da86 100644
--- a/sd/qa/unit/data/xml/n762695_1.xml
+++ b/sd/qa/unit/data/xml/n762695_1.xml
@@ -67,6 +67,7 @@

   
  
+ 
  
   

@@ -151,6 +152,7 @@

   
  
+ 
  
   

diff --git a/sd/qa/unit/data/xml/tdf109317_0.xml 
b/sd/qa/unit/data/xml/tdf109317_0.xml
index f34beafbdc80..74559e74 100644
--- a/sd/qa/unit/data/xml/tdf109317_0.xml
+++ b/sd/qa/unit/data/xml/tdf109317_0.xml
@@ -22,6 +22,7 @@


 
+ 
  
  
  
@@ -130,6 +131,7 @@


 
+ 
  
  
  
@@ -406,6 +408,7 @@


 
+ 
  
  
  
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 2345e17ee7a4..adc7c12e4632 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -203,6 +203,34 @@ CPPUNIT_TEST_FIXTURE(SdImportTest, testDocumentLayout)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(SdImportTest, testFreeformShapeGluePoints)
+{
+createSdImpressDoc("pptx/tdf156829.pptx");
+uno::Reference xFreeformShape(getShapeFromPage(0, 0));
+uno::Sequence aProps;
+xFreeformShape->getPropertyValue("CustomShapeGeometry") >>= aProps;
+
+uno::Sequence aPathProps;
+for (beans::PropertyValue const& rProp : std::as_const(aProps))
+{
+if (rProp.Name == "Path")
+aPathProps = 
rProp.Value.get>();
+}
+
+uno::Sequence seqGluePoints;
+for (beans::PropertyValue 

[Libreoffice-commits] core.git: oox/source sd/qa

2023-08-25 Thread Samuel Mehrbrodt (via logerrit)
 oox/source/export/drawingml.cxx|2 +-
 sd/qa/unit/data/odp/tdf150316.odp  |binary
 sd/qa/unit/export-tests-ooxml1.cxx |9 +
 3 files changed, 10 insertions(+), 1 deletion(-)

New commits:
commit 6e042b1e26bedcc8d8bdcf105ec750b03665c7b0
Author: Samuel Mehrbrodt 
AuthorDate: Fri Aug 25 15:05:42 2023 +0200
Commit: Samuel Mehrbrodt 
CommitDate: Fri Aug 25 20:50:00 2023 +0200

tdf#150316 Fix missing first line indent in pptx export

Change-Id: Ib2cac800b151823b77e44831100c2de9bbda8a16
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156107
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 1230517eda81..98496aa2c1f8 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -3440,7 +3440,7 @@ bool DrawingML::WriteParagraphProperties(const 
Reference& rParagra
 mpFS->startElementNS( XML_a, nElement,
XML_lvl, 
sax_fastparser::UseIf(OString::number(nLevel), nLevel > 0),
XML_marL, 
sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nParaLeftMargin)),
 nParaLeftMargin > 0),
-   XML_indent, 
sax_fastparser::UseIf(OString::number(!bForceZeroIndent ? 
oox::drawingml::convertHmmToEmu(nParaFirstLineIndent) : 0), (bForceZeroIndent 
|| (nParaFirstLineIndent != 0))),
+   XML_indent, 
sax_fastparser::UseIf(OString::number((bForceZeroIndent && nParaFirstLineIndent 
== 0) ? 0 : oox::drawingml::convertHmmToEmu(nParaFirstLineIndent)), 
(bForceZeroIndent || nParaFirstLineIndent != 0)),
XML_algn, GetAlignment( nAlignment ),
XML_defTabSz, 
sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nParaDefaultTabSize)),
 nParaDefaultTabSize > 0),
XML_rtl, sax_fastparser::UseIf(ToPsz10(bRtl), 
bRtl));
diff --git a/sd/qa/unit/data/odp/tdf150316.odp 
b/sd/qa/unit/data/odp/tdf150316.odp
new file mode 100644
index ..dab2971711f8
Binary files /dev/null and b/sd/qa/unit/data/odp/tdf150316.odp differ
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx 
b/sd/qa/unit/export-tests-ooxml1.cxx
index 2962456ffd49..0a9f82a27e59 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -1588,6 +1588,15 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest1, 
testNarrationMimeType)
 assertXPath(pSlideDoc, "//p:childTnLst/p:audio", "isNarration", "1");
 }
 
+CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest1, testTdf150316)
+{
+createSdImpressDoc("odp/tdf150316.odp");
+save("Impress Office Open XML");
+
+xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
+assertXPath(pXmlDoc, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:p/a:pPr", 
"indent", "-343080");
+}
+
 CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest1, testTdf140865Wordart3D)
 {
 createSdImpressDoc("pptx/tdf140865Wordart3D.pptx");


[Libreoffice-commits] core.git: oox/source sd/qa

2023-08-18 Thread Samuel Mehrbrodt (via logerrit)
 oox/source/export/drawingml.cxx|   15 +++
 sd/qa/unit/data/pptx/tdf151134.odp |binary
 sd/qa/unit/export-tests-ooxml1.cxx |9 +
 3 files changed, 20 insertions(+), 4 deletions(-)

New commits:
commit 0367a168cd01f4a2c16101726714f696ba023a6f
Author: Samuel Mehrbrodt 
AuthorDate: Fri Aug 18 13:42:23 2023 +0200
Commit: Samuel Mehrbrodt 
CommitDate: Fri Aug 18 22:15:59 2023 +0200

tdf#151134 Always write inset properties when exporting placeholder shapes

The default value works for text boxes, but not for these special
presentation placeholder objects - here the values need to be written
explicitly.

Change-Id: Id606bd5e6b63dee2fd3b385435ce13ecec63b5f1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155838
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 351c1b7cf265..6b464cf774ba 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -4010,6 +4010,9 @@ void DrawingML::WriteText(const Reference& 
rXIface, bool bBodyPr, bo
 sVertOverflow = "clip";
 }
 
+// tdf#151134 When writing placeholder shapes, inset must be 
explicitly specified
+bool bRequireInset = GetProperty(rXPropSet, "IsPresentationObject") && 
rXPropSet->getPropertyValue("IsPresentationObject").get();
+
 mpFS->startElementNS( (nXmlNamespace ? nXmlNamespace : XML_a), 
XML_bodyPr,
XML_numCol, 
sax_fastparser::UseIf(OString::number(nCols), nCols > 0),
XML_spcCol, 
sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nColSpacing)),
 nCols > 0 && nColSpacing >= 0),
@@ -4017,10 +4020,14 @@ void DrawingML::WriteText(const Reference& 
rXIface, bool bBodyPr, bo
XML_horzOverflow, sHorzOverflow,
XML_vertOverflow, sVertOverflow,
XML_fromWordArt, sax_fastparser::UseIf("1", 
bFromWordArt),
-   XML_lIns, 
sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nLeft)), 
nLeft != constDefaultLeftRightInset),
-   XML_rIns, 
sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nRight)), 
nRight != constDefaultLeftRightInset),
-   XML_tIns, 
sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nTop)), 
nTop != constDefaultTopBottomInset),
-   XML_bIns, 
sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nBottom)),
 nBottom != constDefaultTopBottomInset),
+   XML_lIns, 
sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nLeft)),
+   bRequireInset 
|| nLeft != constDefaultLeftRightInset),
+   XML_rIns, 
sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nRight)),
+   bRequireInset 
|| nRight != constDefaultLeftRightInset),
+   XML_tIns, 
sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nTop)),
+   bRequireInset 
|| nTop != constDefaultTopBottomInset),
+   XML_bIns, 
sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nBottom)),
+   bRequireInset 
|| nBottom != constDefaultTopBottomInset),
XML_anchor, sAnchor,
XML_anchorCtr, sax_fastparser::UseIf("1", 
bAnchorCtr),
XML_vert, sWritingMode,
diff --git a/sd/qa/unit/data/pptx/tdf151134.odp 
b/sd/qa/unit/data/pptx/tdf151134.odp
new file mode 100644
index ..56ea86a3144c
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf151134.odp differ
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx 
b/sd/qa/unit/export-tests-ooxml1.cxx
index ffc3530f40b6..1e7c05390d39 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -1666,6 +1666,15 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest1, testTdf137675)
 "none");
 }
 
+CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest1, testTdf151134)
+{
+createSdImpressDoc("pptx/tdf151134.odp");
+save("Impress Office Open XML");
+
+xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
+assertXPath(pXmlDoc, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:bodyPr", 
"lIns", "91440");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


[Libreoffice-commits] core.git: oox/source sd/qa

2023-08-15 Thread Mike Kaganski (via logerrit)
 oox/source/drawingml/fillproperties.cxx   |   10 ++-
 sd/qa/unit/data/pptx/tdf153008-srcRect-smallNegBound.pptx |binary
 sd/qa/unit/import-tests2.cxx  |   19 ++
 3 files changed, 23 insertions(+), 6 deletions(-)

New commits:
commit 6c06c8a2be3d8cbbcb8ab1aaaeb04db95114dfcb
Author: Mike Kaganski 
AuthorDate: Tue Aug 15 14:42:20 2023 +0300
Commit: Mike Kaganski 
CommitDate: Tue Aug 15 16:45:47 2023 +0200

tdf#153008: srcRect may have some members negative

The overly strict check (implying that all members must be non-negative,
to perform the crop) excluded valid cases where some of the members were
negative, and some positive.

Change-Id: I629689bdccedf9e37632a9fe14654778c0f14a6f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155717
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/oox/source/drawingml/fillproperties.cxx 
b/oox/source/drawingml/fillproperties.cxx
index 7e2f5185b7f6..5edc71b8bc12 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -826,13 +826,11 @@ void GraphicProperties::pushToPropMap( PropertyMap& 
rPropMap, const GraphicHelpe
 aGraphCrop.Bottom = rtl::math::round( ( static_cast< 
double >( aOriginalSize.Height ) * oClipRect.Y2 ) / 10 );
 rPropMap.setProperty(PROP_GraphicCrop, aGraphCrop);
 
-bool bHasCropValues = aGraphCrop.Left != 0 || aGraphCrop.Right 
!=0 || aGraphCrop.Top != 0 || aGraphCrop.Bottom != 0;
-// Positive GraphicCrop values means "crop" here.
-bool bNeedCrop = aGraphCrop.Left >= 0 && aGraphCrop.Right >= 0 
&& aGraphCrop.Top >= 0 && aGraphCrop.Bottom >= 0;
-
-if(mbIsCustomShape && bHasCropValues && bNeedCrop)
+if(mbIsCustomShape)
 {
-xGraphic = lclCropGraphic(xGraphic, 
CropQuotientsFromSrcRect(oClipRect));
+// Positive GraphicCrop values means "crop" here.
+if (aGraphCrop.Left > 0 || aGraphCrop.Right > 0 || 
aGraphCrop.Top > 0 || aGraphCrop.Bottom > 0)
+xGraphic = lclCropGraphic(xGraphic, 
CropQuotientsFromSrcRect(oClipRect));
 }
 }
 }
diff --git a/sd/qa/unit/data/pptx/tdf153008-srcRect-smallNegBound.pptx 
b/sd/qa/unit/data/pptx/tdf153008-srcRect-smallNegBound.pptx
new file mode 100644
index ..9870e3f2e2e9
Binary files /dev/null and 
b/sd/qa/unit/data/pptx/tdf153008-srcRect-smallNegBound.pptx differ
diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx
index 4d197b364449..4e535c7749c7 100644
--- a/sd/qa/unit/import-tests2.cxx
+++ b/sd/qa/unit/import-tests2.cxx
@@ -1918,6 +1918,25 @@ CPPUNIT_TEST_FIXTURE(SdImportTest2, 
testIndentDuplication)
 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nIndent2);
 }
 
+CPPUNIT_TEST_FIXTURE(SdImportTest2, test_srcRect_smallNegBound)
+{
+// Given a cropped custom shape, with a srcRect having a small negative 
value in one of bounds
+createSdImpressDoc("pptx/tdf153008-srcRect-smallNegBound.pptx");
+
+uno::Reference xGraphic(
+getShapeFromPage(0, 0)->getPropertyValue("FillBitmap"), 
uno::UNO_QUERY_THROW);
+
+BitmapEx aBitmap(Graphic(xGraphic).GetBitmapEx());
+
+// Properly cropped bitmap should have black pixels close to left edge, 
near vertical center.
+// Before the fix, the gear was distorted, and this area was white.
+auto yMiddle = aBitmap.GetSizePixel().Height() / 2;
+auto x5Percent = aBitmap.GetSizePixel().Width() / 20;
+CPPUNIT_ASSERT(aBitmap.GetPixelColor(x5Percent, yMiddle).IsDark());
+// Just in case, check that the corner is bright (it is in fact yellow)
+CPPUNIT_ASSERT(aBitmap.GetPixelColor(0, 0).IsBright());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


[Libreoffice-commits] core.git: oox/source sd/qa

2023-04-26 Thread Sarper Akdemir (via logerrit)
 oox/source/drawingml/drawingmltypes.cxx |4 ++--
 sd/qa/unit/export-tests-ooxml3.cxx  |4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 7dd994f8303a2b9396ed3848104028ff724e3bab
Author: Sarper Akdemir 
AuthorDate: Tue Apr 25 08:48:36 2023 +0300
Commit: Sarper Akdemir 
CommitDate: Wed Apr 26 21:13:31 2023 +0200

pptx export: fix export of vertical table text

The mapping (implemented in 77655fc3dca05d4bb2366e67ccea228e3886bfe2)
used on export and the accompanying roundtrip test was incorrect. This
patch fixes both.

Rotation value of
- 9000 maps to vert270
- 27000 maps to vert

Change-Id: I9a9f889a2bff0241e62ee685492034eec6d0cccf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150955
Tested-by: Jenkins
Reviewed-by: Sarper Akdemir 

diff --git a/oox/source/drawingml/drawingmltypes.cxx 
b/oox/source/drawingml/drawingmltypes.cxx
index ff8c46050c15..30fed83f4391 100644
--- a/oox/source/drawingml/drawingmltypes.cxx
+++ b/oox/source/drawingml/drawingmltypes.cxx
@@ -382,9 +382,9 @@ std::optional GetTextVerticalType(sal_Int32 
nRotateAngle)
 switch (nRotateAngle)
 {
   case 9000:
-  return "vert";
-  case 27000:
   return "vert270";
+  case 27000:
+  return "vert";
   default:
   return {};
 }
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index d8d92ca54ae8..6fdf10a5bcce 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -1991,8 +1991,8 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, 
testTableCellVerticalPropertyRoundtrip)
 
 xmlDocUniquePtr pXml = parseExport("ppt/slides/slide1.xml");
 
-assertXPath(pXml, "(//a:tcPr)[1]", "vert", "vert270");
-assertXPath(pXml, "(//a:tcPr)[2]", "vert", "vert");
+assertXPath(pXml, "(//a:tcPr)[1]", "vert", "vert");
+assertXPath(pXml, "(//a:tcPr)[2]", "vert", "vert270");
 assertXPath(pXml, "(//a:tcPr)[3]", "vert", "wordArtVert");
 }
 


[Libreoffice-commits] core.git: oox/source sd/qa

2023-04-21 Thread Sarper Akdemir (via logerrit)
 oox/source/drawingml/table/tablecell.cxx |   37 +++
 sd/qa/unit/layout-tests.cxx  |   14 +++
 2 files changed, 33 insertions(+), 18 deletions(-)

New commits:
commit 4232907e0a8a5bd87c673afd9df0031dce74d798
Author: Sarper Akdemir 
AuthorDate: Thu Apr 20 23:31:20 2023 +0300
Commit: Sarper Akdemir 
CommitDate: Fri Apr 21 10:02:00 2023 +0200

related tdf#154501: pptx import: push cell's RotateAngle after text

It appears to matter whether "RotateAngle" property is set
before or after insertion of the text for cells.

It only renders correctly when it is pushed after the text insertion.

RotateAngle appears to end up in the property set either way with
correct values, so I don't really know why this is the case.

Adds a unit test that covers rendering of vertical text in table cells
on import from an example pptx file.

Change-Id: Ifb8caa0b74920758fea2815b16dae7fd60587cc7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150712
Tested-by: Jenkins
Reviewed-by: Sarper Akdemir 

diff --git a/oox/source/drawingml/table/tablecell.cxx 
b/oox/source/drawingml/table/tablecell.cxx
index b0849b7002f3..9d16bce09d17 100644
--- a/oox/source/drawingml/table/tablecell.cxx
+++ b/oox/source/drawingml/table/tablecell.cxx
@@ -569,7 +569,24 @@ void TableCell::pushToXCell( const 
::oox::core::XmlFilterBase& rFilterBase, cons
 {
 xPropSet->setPropertyValue("TextWritingMode", 
Any(css::text::WritingMode_TB_RL));
 }
-else if ( getVertToken() == XML_vert )
+
+getTextBody()->insertAt( rFilterBase, xText, xAt, aTextStyleProps, 
pMasterTextListStyle );
+
+// tdf#144092 For empty cells push character styles & endParaRPr to the 
Cell's properties
+const TextParagraphVector& rParagraphs = getTextBody()->getParagraphs();
+if (rParagraphs.size() == 1)
+{
+const auto pFirstParagraph = rParagraphs.at(0);
+if (pFirstParagraph->getRuns().empty())
+{
+TextCharacterProperties aTextCharacterProps{ 
pFirstParagraph->getCharacterStyle(
+aTextStyleProps, *pMasterTextListStyle, 
getTextBody()->getTextListStyle()) };
+
aTextCharacterProps.assignUsed(pFirstParagraph->getEndProperties());
+aTextCharacterProps.pushToPropSet(aPropSet, rFilterBase);
+}
+}
+
+if ( getVertToken() == XML_vert )
 {
 xPropSet->setPropertyValue("RotateAngle", Any(short(27000)));
 }
@@ -577,7 +594,7 @@ void TableCell::pushToXCell( const 
::oox::core::XmlFilterBase& rFilterBase, cons
 {
 xPropSet->setPropertyValue("RotateAngle", Any(short(9000)));
 }
-else if ( getVertToken() != XML_horz )
+else if ( getVertToken() != XML_horz && getVertToken() != XML_eaVert )
 {
 // put the vert value in the grab bag for roundtrip
 const Sequence& aTokenNameSeq = 
StaticTokenMap().getUtf8TokenName(getVertToken());
@@ -599,22 +616,6 @@ void TableCell::pushToXCell( const 
::oox::core::XmlFilterBase& rFilterBase, cons
 }
 xPropSet->setPropertyValue("CellInteropGrabBag", Any(aGrabBag));
 }
-
-getTextBody()->insertAt( rFilterBase, xText, xAt, aTextStyleProps, 
pMasterTextListStyle );
-
-// tdf#144092 For empty cells push character styles & endParaRPr to the 
Cell's properties
-const TextParagraphVector& rParagraphs = getTextBody()->getParagraphs();
-if (rParagraphs.size() == 1)
-{
-const auto pFirstParagraph = rParagraphs.at(0);
-if (pFirstParagraph->getRuns().empty())
-{
-TextCharacterProperties aTextCharacterProps{ 
pFirstParagraph->getCharacterStyle(
-aTextStyleProps, *pMasterTextListStyle, 
getTextBody()->getTextListStyle()) };
-
aTextCharacterProps.assignUsed(pFirstParagraph->getEndProperties());
-aTextCharacterProps.pushToPropSet(aPropSet, rFilterBase);
-}
-}
 }
 
 }
diff --git a/sd/qa/unit/layout-tests.cxx b/sd/qa/unit/layout-tests.cxx
index e401f2d0822b..5e9d0e26537b 100644
--- a/sd/qa/unit/layout-tests.cxx
+++ b/sd/qa/unit/layout-tests.cxx
@@ -340,6 +340,20 @@ CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTdf148966)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTableVerticalText)
+{
+xmlDocUniquePtr pXmlDoc = load("pptx/tcPr-vert-roundtrip.pptx");
+
+// Without the accompanying fix, would fail with:
+// - Expected: -900
+// - Actual  : 0
+// - In <>, attribute 'orientation' of '//font[1]' incorrect value.
+// i.e. table cell text that was supposed to be vertical (rotated 90
+// degrees) was not vertical.
+assertXPath(pXmlDoc, "//font[1]", "orientation", "-900");
+assertXPath(pXmlDoc, "//font[2]", "orientation", "900");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


[Libreoffice-commits] core.git: oox/source sd/qa

2023-04-11 Thread Tibor Nagy (via logerrit)
 oox/source/export/shapes.cxx|   37 
 oox/source/ppt/slidepersist.cxx |   15 +-
 sd/qa/unit/data/pptx/tdf154363.pptx |binary
 sd/qa/unit/import-tests.cxx |   24 +++
 4 files changed, 63 insertions(+), 13 deletions(-)

New commits:
commit b7c542b5085374f1d031183cb86ceeefcf24964d
Author: Tibor Nagy 
AuthorDate: Wed Mar 29 09:00:47 2023 +0200
Commit: László Németh 
CommitDate: Tue Apr 11 19:32:45 2023 +0200

tdf#154363 sd: fix line connectors regression of mirrored shapes

caused by commit cbf66ec3e60d07efb7c3cceed9b4f0fb4f0510c8
(tdf#89449 PPTX import: fix line connectors).

Note: partial revert of commit 9ab16e2738b4b9bd324c9aded8acb2ecba0fd2b0
"oox: fix crash in lcl_GetGluePointId by removing unused code".

Change-Id: Icc45c93c4fa3a22c0f34866ccb64ea6b9037d936
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149676
Reviewed-by: László Németh 
Tested-by: László Németh 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 372b4376fe22..eab82a86336d 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1640,17 +1640,38 @@ static void lcl_GetConnectorAdjustValue(const 
Reference& xShape, tools::
 }
 }
 
-static sal_Int32 lcl_GetGluePointId(sal_Int32 nGluePointId)
+static sal_Int32 lcl_GetGluePointId(const Reference& xShape, sal_Int32 
nGluePointId)
 {
 if (nGluePointId > 3)
 return nGluePointId - 4;
 else
 {
-// change id of the bounding box (1 <-> 3)
-if (nGluePointId == 1)
-return 3; // Right
-else if (nGluePointId == 3)
-return 1; // Left
+bool bFlipH = false;
+bool bFlipV = false;
+Reference xShapeProps(xShape, UNO_QUERY);
+if 
(xShapeProps->getPropertySetInfo()->hasPropertyByName("CustomShapeGeometry"))
+{
+Sequence aGeometrySeq;
+xShapeProps->getPropertyValue("CustomShapeGeometry") >>= 
aGeometrySeq;
+for (int i = 0; i < aGeometrySeq.getLength(); i++)
+{
+const PropertyValue& rProp = aGeometrySeq[i];
+if (rProp.Name == "MirroredX")
+rProp.Value >>= bFlipH;
+
+if (rProp.Name == "MirroredY")
+rProp.Value >>= bFlipV;
+}
+}
+
+if ((!bFlipH && !bFlipV) || (bFlipH && bFlipV))
+{
+// change id of the bounding box (1 <-> 3)
+if (nGluePointId == 1)
+nGluePointId = 3; // Right
+else if (nGluePointId == 3)
+nGluePointId = 1; // Left
+}
 }
 
 return nGluePointId;
@@ -1708,12 +1729,12 @@ ShapeExport& ShapeExport::WriteConnectorShape( const 
Reference< XShape >& xShape
 if (GetProperty(rXPropSet, "StartGluePointIndex"))
 mAny >>= nStartGlueId;
 if (nStartGlueId != -1)
-nStartGlueId = lcl_GetGluePointId(nStartGlueId);
+nStartGlueId = lcl_GetGluePointId(rXShapeA, nStartGlueId);
 
 if (GetProperty(rXPropSet, "EndGluePointIndex"))
 mAny >>= nEndGlueId;
 if (nEndGlueId != -1)
-nEndGlueId = lcl_GetGluePointId(nEndGlueId);
+nEndGlueId = lcl_GetGluePointId(rXShapeB, nEndGlueId);
 
 // Position is relative to group in Word, but relative to anchor of group 
in API.
 if (GetDocumentType() == DOCUMENT_DOCX && !mbUserShapes && m_xParent.is())
diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx
index bb673b52442e..0f7479e8ede9 100644
--- a/oox/source/ppt/slidepersist.cxx
+++ b/oox/source/ppt/slidepersist.cxx
@@ -659,11 +659,16 @@ void SlidePersist::createConnectorShapeConnection()
 nGlueId += 4;
 else
 {
-// change id of the left and right glue points of the 
bounding box (1 <-> 3)
-if (nGlueId == 1)
-nGlueId = 3; // Right
-else if (nGlueId == 3)
-nGlueId = 1; // Left
+bool bFlipH = pShape->second->getFlipH();
+bool bFlipV = pShape->second->getFlipV();
+if ((!bFlipH && !bFlipV) || (bFlipH && bFlipV))
+{
+// change id of the left and right glue points of 
the bounding box (1 <-> 3)
+if (nGlueId == 1)
+nGlueId = 3; // Right
+else if (nGlueId == 3)
+nGlueId = 1; // Left
+}
 }
 
 bool bStart = aConnectorShapeProperties[j].mbStartShape;
diff --git a/sd/qa/unit/data/pptx/tdf154363.pptx 
b/sd/qa/unit/data/pptx/tdf154363.pptx
new file mode 100644
index ..b549fda90135
Binary files 

[Libreoffice-commits] core.git: oox/source sd/qa

2023-03-16 Thread Sarper Akdemir (via logerrit)
 oox/source/export/drawingml.cxx|6 ++
 sd/qa/unit/data/pptx/tdf102261_testParaTabStopDefaultDistance.pptx |binary
 sd/qa/unit/export-tests-ooxml3.cxx |   22 
++
 3 files changed, 28 insertions(+)

New commits:
commit f039fe0da31907a58a4c3b6717cf29caf2685101
Author: Sarper Akdemir 
AuthorDate: Fri Mar 3 19:22:30 2023 +0300
Commit: Miklos Vajna 
CommitDate: Thu Mar 16 15:47:29 2023 +

tdf#102261: pptx export: implement defTabSz ParaTabStopDefaultDistance

Adds export of ParaTabStopDefaultDistance property into defTabSz.

Also adds a unit test that checks pptx roundtrip of the property.

Change-Id: I5be9ea88b15e3e8cab25af79488983a71b96dae1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148539
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 8f16b1ebc95e..5335dca58486 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -3290,6 +3290,10 @@ bool DrawingML::WriteParagraphProperties(const 
Reference& rParagra
 return false;
 }
 
+sal_Int32 nParaDefaultTabSize = 0;
+if (GetProperty(rXPropSet, "ParaTabStopDefaultDistance"))
+mAny >>= nParaDefaultTabSize;
+
 // for autofitted textboxes, scale the indents
 if (GetProperty(rXShapePropSet, "TextFitToSize") && 
mAny.get() == TextFitToSizeType_AUTOFIT)
 {
@@ -3314,6 +3318,7 @@ bool DrawingML::WriteParagraphProperties(const 
Reference& rParagra
XML_marL, 
sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nParaLeftMargin)),
 nParaLeftMargin > 0),
XML_indent, 
sax_fastparser::UseIf(OString::number(!bForceZeroIndent ? 
oox::drawingml::convertHmmToEmu(nParaFirstLineIndent) : 0), (bForceZeroIndent 
|| (nParaFirstLineIndent != 0))),
XML_algn, GetAlignment( nAlignment ),
+   XML_defTabSz, 
sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nParaDefaultTabSize)),
 nParaDefaultTabSize > 0),
XML_rtl, sax_fastparser::UseIf(ToPsz10(bRtl), 
bRtl));
 else
 mpFS->startElementNS( XML_a, nElement,
@@ -3321,6 +3326,7 @@ bool DrawingML::WriteParagraphProperties(const 
Reference& rParagra
XML_marL, 
sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nLeftMargin)),
 nLeftMargin > 0),
XML_indent, 
sax_fastparser::UseIf(OString::number(!bForceZeroIndent ? 
oox::drawingml::convertHmmToEmu(nLineIndentation) : 0), (bForceZeroIndent || ( 
nLineIndentation != 0))),
XML_algn, GetAlignment( nAlignment ),
+   XML_defTabSz, 
sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nParaDefaultTabSize)),
 nParaDefaultTabSize > 0),
XML_rtl, sax_fastparser::UseIf(ToPsz10(bRtl), 
bRtl));
 
 
diff --git a/sd/qa/unit/data/pptx/tdf102261_testParaTabStopDefaultDistance.pptx 
b/sd/qa/unit/data/pptx/tdf102261_testParaTabStopDefaultDistance.pptx
new file mode 100644
index ..88438d7b5494
Binary files /dev/null and 
b/sd/qa/unit/data/pptx/tdf102261_testParaTabStopDefaultDistance.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index 997dd15009fd..ccbfc6e35335 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -1965,6 +1965,28 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testLinkedOLE)
 assertXPath(pXml, "//p:oleObj", 1);
 }
 
+CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, 
testTdf102261_testParaTabStopDefaultDistance)
+{
+createSdImpressDoc("pptx/tdf102261_testParaTabStopDefaultDistance.pptx");
+saveAndReload("Impress Office Open XML");
+
+uno::Reference xShape(getShapeFromPage(0, 0));
+{
+uno::Reference xPropSet(getParagraphFromShape(0, 
xShape),
+ uno::UNO_QUERY_THROW);
+CPPUNIT_ASSERT_EQUAL(
+sal_Int32{ 1270 },
+
xPropSet->getPropertyValue("ParaTabStopDefaultDistance").get());
+}
+{
+uno::Reference xPropSet(getParagraphFromShape(1, 
xShape),
+ uno::UNO_QUERY_THROW);
+CPPUNIT_ASSERT_EQUAL(
+sal_Int32{ 2540 },
+
xPropSet->getPropertyValue("ParaTabStopDefaultDistance").get());
+}
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


[Libreoffice-commits] core.git: oox/source sd/qa

2023-01-30 Thread Tünde Tóth (via logerrit)
 oox/source/export/shapes.cxx   |   64 ++---
 sd/qa/unit/data/odp/linked_ole.odp |binary
 sd/qa/unit/export-tests-ooxml3.cxx |   18 ++
 3 files changed, 57 insertions(+), 25 deletions(-)

New commits:
commit f589d7e769bee4b82826a944fed3cf2382d84fb2
Author: Tünde Tóth 
AuthorDate: Tue Jan 24 15:02:09 2023 +0100
Commit: László Németh 
CommitDate: Mon Jan 30 11:25:32 2023 +

tdf#153185 PPTX: fix export of linked OLE objects

Linked OLE objects were not exported.

Change-Id: If6e8c6e0d0c9917e8ec476ad14dcaa1602c74b29
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146073
Tested-by: Jenkins
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index d6b3a9e9ef99..1c828d438653 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -2602,49 +2602,60 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const 
Reference< XShape >& xShape )
 OUString sRelationType;
 OUString sSuffix;
 const char * pProgID(nullptr);
+OString anotherProgID;
 
 uno::Reference const xInStream =
 oox::GetOLEObjectStream(
 mpFB->getComponentContext(), xObj, progID,
 sMediaType, sRelationType, sSuffix, pProgID);
 
+OUString sURL;
+OUString sRelId;
 if (!xInStream.is())
 {
-return *this;
-}
+xPropSet->getPropertyValue("LinkURL") >>= sURL;
+if (sURL.isEmpty())
+return *this;
 
-OString anotherProgID;
-if (!pProgID && !progID.isEmpty())
-{
-anotherProgID = OUStringToOString(progID, RTL_TEXTENCODING_UTF8);
-pProgID = anotherProgID.getStr();
+sRelId = mpFB->addRelation(mpFS->getOutputStream(),
+   
oox::getRelationship(Relationship::OLEOBJECT), sURL, true);
 }
+else
+{
+if (!pProgID && !progID.isEmpty())
+{
+anotherProgID = OUStringToOString(progID, RTL_TEXTENCODING_UTF8);
+pProgID = anotherProgID.getStr();
+}
+
+assert(!sMediaType.isEmpty());
+assert(!sRelationType.isEmpty());
+assert(!sSuffix.isEmpty());
 
-assert(!sMediaType.isEmpty());
-assert(!sRelationType.isEmpty());
-assert(!sSuffix.isEmpty());
+OUString sFileName
+= "embeddings/oleObject" + OUString::number(++m_nEmbeddedObjects) 
+ "." + sSuffix;
+uno::Reference const 
xOutStream(mpFB->openFragmentStream(
+OUString::createFromAscii(GetComponentDir()) + "/" + sFileName, 
sMediaType));
+assert(xOutStream.is()); // no reason why that could fail
 
-OUString sFileName = "embeddings/oleObject" + 
OUString::number(++m_nEmbeddedObjects) + "." + sSuffix;
-uno::Reference const xOutStream(
-mpFB->openFragmentStream(
-OUString::createFromAscii(GetComponentDir()) + "/" + sFileName,
-sMediaType));
-assert(xOutStream.is()); // no reason why that could fail
+try
+{
+::comphelper::OStorageHelper::CopyInputToOutput(xInStream, 
xOutStream);
+}
+catch (uno::Exception const&)
+{
+TOOLS_WARN_EXCEPTION("oox.shape", "ShapeExport::WriteOLEObject");
+}
 
-try {
-::comphelper::OStorageHelper::CopyInputToOutput(xInStream, xOutStream);
-} catch (uno::Exception const&) {
-TOOLS_WARN_EXCEPTION("oox.shape", "ShapeExport::WriteOLEObject");
+sRelId = mpFB->addRelation(
+mpFS->getOutputStream(), sRelationType,
+Concat2View(OUString::createFromAscii(GetRelationCompPrefix()) + 
sFileName));
 }
 
 sal_Int64 nAspect;
 bool bShowAsIcon = (xPropSet->getPropertyValue("Aspect") >>= nAspect)
&& nAspect == embed::Aspects::MSOLE_ICON;
 
-OUString const sRelId = mpFB->addRelation(
-mpFS->getOutputStream(), sRelationType,
-Concat2View(OUString::createFromAscii(GetRelationCompPrefix()) + 
sFileName));
-
 mpFS->startElementNS(mnXmlNamespace, XML_graphicFrame);
 
 mpFS->startElementNS(mnXmlNamespace, XML_nvGraphicFramePr);
@@ -2682,7 +2693,10 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const 
Reference< XShape >& xShape )
   XML_spid, "" );
 }
 
-mpFS->singleElementNS( mnXmlNamespace, XML_embed );
+if (sURL.isEmpty())
+mpFS->singleElementNS(mnXmlNamespace, XML_embed);
+else
+mpFS->singleElementNS(mnXmlNamespace, XML_link, XML_updateAutomatic, 
"1");
 
 // pic element
 SdrObject* pSdrOLE2(SdrObject::getSdrObjectFromXShape(xShape));
diff --git a/sd/qa/unit/data/odp/linked_ole.odp 
b/sd/qa/unit/data/odp/linked_ole.odp
new file mode 100644
index ..13fb0a845a13
Binary files /dev/null and b/sd/qa/unit/data/odp/linked_ole.odp differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index 

[Libreoffice-commits] core.git: oox/source sd/qa

2023-01-19 Thread Attila Szűcs (via logerrit)
 oox/source/ppt/slidepersist.cxx   |   72 +-
 sd/qa/unit/data/pptx/tdf153036_resizedConnectorL.pptx |binary
 sd/qa/unit/import-tests.cxx   |   16 
 3 files changed, 68 insertions(+), 20 deletions(-)

New commits:
commit 17c68fad2aef917adfdd3d4d651da786e620699c
Author: Attila Szűcs 
AuthorDate: Mon Jan 16 04:13:07 2023 +0100
Commit: Andras Timar 
CommitDate: Thu Jan 19 08:27:39 2023 +

tdf#153036 PPTX import resized connector broken

Fixed the EdgeLine1Delta calculation in case of bentConnector2.
(when L shape imported as a special Z shape)

Co-authored-by: Tibor Nagy (NISZ)
Change-Id: I08c92e63adc744322061e4e433bfdc512745eda1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145548
Tested-by: Jenkins
Reviewed-by: Andras Timar 

diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx
index c875239aac46..ca296561a52f 100644
--- a/oox/source/ppt/slidepersist.cxx
+++ b/oox/source/ppt/slidepersist.cxx
@@ -341,6 +341,36 @@ void SlidePersist::hideShapesAsMasterShapes()
 }
 }
 
+// This angle determines in the direction of the line
+static sal_Int32 lcl_GetAngle(uno::Reference& rXShape, 
awt::Point& rPt)
+{
+SdrObject* pObj = SdrObject::getSdrObjectFromXShape(rXShape);
+tools::Rectangle aR(pObj->GetSnapRect());
+sal_Int32 nLeftX = rPt.X - aR.Left();
+sal_Int32 nTopY = rPt.Y - aR.Top();
+sal_Int32 nRightX = aR.Right() - rPt.X;
+sal_Int32 nBottomY = aR.Bottom() - rPt.Y;
+sal_Int32 nX = std::min(nLeftX, nRightX);
+sal_Int32 nY = std::min(nTopY, nBottomY);
+
+sal_Int32 nAngle;
+if (nX < nY)
+{
+if (nLeftX < nRightX)
+nAngle = 180; // Left
+else
+nAngle = 0; // Right
+}
+else
+{
+if (nTopY < nBottomY)
+nAngle = 270; // Top
+else
+nAngle = 90; // Bottom
+}
+return nAngle;
+}
+
 Reference SlidePersist::getAnimationNode(const OUString& sId) 
const
 {
 const auto& pIter = maAnimNodesMap.find(sId);
@@ -372,6 +402,8 @@ static void 
lcl_SetEdgeLineValue(uno::Reference& rXConnector,
 SdrObject* pEndObj = xEndSp.is() ? 
SdrObject::getSdrObjectFromXShape(xEndSp) : nullptr;
 
 sal_Int32 nStartSpLineW = 0;
+sal_Int32 nStartA = -1;
+sal_Int32 nEndA = -1;
 if (pStartObj)
 {
 aStartRect = pStartObj->GetSnapRect();
@@ -379,6 +411,7 @@ static void 
lcl_SetEdgeLineValue(uno::Reference& rXConnector,
 xPropxStartSp->getPropertyValue("LineWidth") >>= nStartSpLineW;
 if (nStartSpLineW)
 nStartSpLineW = nStartSpLineW / 2;
+nStartA = lcl_GetAngle(xStartSp, aStartPt);
 }
 sal_Int32 nEndSpLineW = 0;
 if (pEndObj)
@@ -388,6 +421,7 @@ static void 
lcl_SetEdgeLineValue(uno::Reference& rXConnector,
 xPropxEndSp->getPropertyValue("LineWidth") >>= nEndSpLineW;
 if (nEndSpLineW)
 nEndSpLineW = nEndSpLineW / 2;
+nEndA = lcl_GetAngle(xEndSp, aEndPt);
 }
 
 const OUString sConnectorName = rShapePtr->getConnectorName();
@@ -396,27 +430,25 @@ static void 
lcl_SetEdgeLineValue(uno::Reference& rXConnector,
 awt::Size aConnSize = rXConnector->getSize();
 if (xStartSp.is() || xEndSp.is())
 {
-if (aConnSize.Height < aConnSize.Width)
+if (nStartA >= 0)
 {
-if (xStartSp.is())
-nEdge = (aStartPt.Y > aEndPt.Y)
-? (nStartSpLineW - (aStartRect.Top() - 
aEndPt.Y))
-: ((aEndPt.Y - aStartRect.Bottom()) - 
nStartSpLineW);
-else
-nEdge = (aStartPt.Y > aEndPt.Y)
-? ((aStartPt.Y - aEndRect.Bottom()) - 
nEndSpLineW)
-: (nEndSpLineW - (aEndRect.Top() - 
aStartPt.Y));
-}
-else
-{
-if (xStartSp.is())
-nEdge = (aStartPt.X > aEndPt.X)
-? (nStartSpLineW - (aStartRect.Left() - 
aEndPt.X))
-: ((aEndPt.X - aStartRect.Right()) - 
nStartSpLineW);
-else
-nEdge = (aStartPt.X > aEndPt.X)
-? ((aStartPt.X - aEndRect.Right()) - 
nEndSpLineW)
-: (nEndSpLineW - (aEndRect.Left() - 
aStartPt.X));
+switch (nStartA)
+{
+case 0: nEdge = aEndPt.X - aStartRect.Right();  break;
+case 180:   nEdge = aEndPt.X - aStartRect.Left();   break;
+case 90:nEdge = aEndPt.Y - aStartRect.Bottom(); break;
+case 270:   nEdge = aEndPt.Y - aStartRect.Top();break;
+}
+nEdge += nStartSpLineW * (nStartA >= 180 ? +1 : -1);
+} else {
+switch 

[Libreoffice-commits] core.git: oox/source sd/qa

2023-01-04 Thread Attila Szűcs (via logerrit)
 oox/source/drawingml/shape.cxx   |6 
 sd/qa/unit/data/pptx/tdf149588_transparentSolidFill.pptx |binary
 sd/qa/unit/import-tests2.cxx |   20 +++
 3 files changed, 26 insertions(+)

New commits:
commit 0cc9aaae5dc6655490513e8e4a93967f6248e23c
Author: Attila Szűcs 
AuthorDate: Wed Jan 4 00:40:23 2023 +0100
Commit: Andras Timar 
CommitDate: Wed Jan 4 20:38:38 2023 +

tdf#149588 pptx import: transparency at SolidFill

When copied color (RGB) property from text content to shape,
copy alpha component as well. (If text color have alpha component)

Change-Id: Ib86c48ab7b2d3c5f9491a2211b05e90b2c2ea10f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145031
Tested-by: Jenkins
Reviewed-by: Andras Timar 

diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index fcc1e9016170..7cd02f77f91f 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -708,6 +708,12 @@ static void lcl_copyCharPropsToShape(const 
uno::Reference& xSha
 aFillColor = static_cast(
 
rCharProps.maFillProperties.maFillColor.getColor(rFilter.getGraphicHelper())
 .GetRGBColor());
+if (rCharProps.maFillProperties.maFillColor.hasTransparency())
+{
+const sal_Int16 aTransparence
+= 
rCharProps.maFillProperties.maFillColor.getTransparency();
+xSet->setPropertyValue(UNO_NAME_FILL_TRANSPARENCE, 
uno::Any(aTransparence));
+}
 }
 xSet->setPropertyValue(UNO_NAME_FILLCOLOR, uno::Any(aFillColor));
 
diff --git a/sd/qa/unit/data/pptx/tdf149588_transparentSolidFill.pptx 
b/sd/qa/unit/data/pptx/tdf149588_transparentSolidFill.pptx
new file mode 100644
index ..8967590b9284
Binary files /dev/null and 
b/sd/qa/unit/data/pptx/tdf149588_transparentSolidFill.pptx differ
diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx
index b258c535e2c6..5d5864a2891e 100644
--- a/sd/qa/unit/import-tests2.cxx
+++ b/sd/qa/unit/import-tests2.cxx
@@ -145,6 +145,7 @@ public:
 void testTdf89928BlackWhiteThreshold();
 void testTdf151547TransparentWhiteText();
 void testTdf149961AutofitIndentation();
+void testTdf149588TransparentSolidFill();
 
 CPPUNIT_TEST_SUITE(SdImportTest2);
 
@@ -223,6 +224,7 @@ public:
 CPPUNIT_TEST(testTdf89928BlackWhiteThreshold);
 CPPUNIT_TEST(testTdf151547TransparentWhiteText);
 CPPUNIT_TEST(testTdf149961AutofitIndentation);
+CPPUNIT_TEST(testTdf149588TransparentSolidFill);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -2009,6 +2011,24 @@ void SdImportTest2::testTdf149961AutofitIndentation()
 }
 }
 
+void SdImportTest2::testTdf149588TransparentSolidFill()
+{
+createSdImpressDoc("pptx/tdf149588_transparentSolidFill.pptx");
+saveAndReload("Impress MS PowerPoint 2007 XML");
+
+uno::Reference xShape(getShapeFromPage(6, 0));
+uno::Reference xParagraph(getParagraphFromShape(0, 
xShape));
+uno::Reference xRun(getRunFromParagraph(0, xParagraph));
+uno::Reference xPropSet(xRun, uno::UNO_QUERY_THROW);
+
+Color nCharColor;
+xPropSet->getPropertyValue("CharColor") >>= nCharColor;
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: Color: R:99 G:99 B:99 A   51  (T:204)
+// - Actual  : Color: R:99 G:99 B:99 A: 255  (T:  0)
+CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency, 0xCC636363), nCharColor);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest2);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


[Libreoffice-commits] core.git: oox/source sd/qa

2022-12-19 Thread Tibor Nagy (via logerrit)
 oox/source/drawingml/fillproperties.cxx |5 +++--
 oox/source/export/drawingml.cxx |   26 --
 sd/qa/unit/data/pptx/tdf152070.pptx |binary
 sd/qa/unit/import-tests.cxx |   20 
 4 files changed, 39 insertions(+), 12 deletions(-)

New commits:
commit b12e38c1ccb388e62e35d856d4a575e1724a10e9
Author: Tibor Nagy 
AuthorDate: Mon Dec 5 09:21:51 2022 +0100
Commit: László Németh 
CommitDate: Mon Dec 19 12:11:48 2022 +

tdf#152070 PPTX import: fix offset of tile background image

by using bitmap image sizes instead of the original ones.

Change-Id: Id6f2777bf6803bca7252878203a12ab796ac33dc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143766
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/drawingml/fillproperties.cxx 
b/oox/source/drawingml/fillproperties.cxx
index c68568096fd8..2627a1861850 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -831,10 +831,11 @@ void FillProperties::pushToPropMap( ShapePropertyMap& 
rPropMap,
 sal_Int32 nFillBmpSizeY = getLimitedValue< 
sal_Int32, double >( aOriginalSize.Height * fScaleY, 1, SAL_MAX_INT32 );
 rPropMap.setProperty( 
ShapeProperty::FillBitmapSizeY, nFillBmpSizeY );
 
+awt::Size aBmpSize(nFillBmpSizeX, nFillBmpSizeY);
 // offset of the first bitmap tile (given as 
EMUs), convert to percent
-sal_Int16 nTileOffsetX = getDoubleIntervalValue< 
sal_Int16 >(std::round(maBlipProps.moTileOffsetX.value_or( 0 ) / 3.6 / 
aOriginalSize.Width), 0, 100 );
+sal_Int16 nTileOffsetX = getDoubleIntervalValue< 
sal_Int16 >(std::round(maBlipProps.moTileOffsetX.value_or( 0 ) / 3.6 / 
aBmpSize.Width), 0, 100 );
 rPropMap.setProperty( 
ShapeProperty::FillBitmapOffsetX, nTileOffsetX );
-sal_Int16 nTileOffsetY = getDoubleIntervalValue< 
sal_Int16 >(std::round(maBlipProps.moTileOffsetY.value_or( 0 ) / 3.6 / 
aOriginalSize.Height), 0, 100 );
+sal_Int16 nTileOffsetY = getDoubleIntervalValue< 
sal_Int16 >(std::round(maBlipProps.moTileOffsetY.value_or( 0 ) / 3.6 / 
aBmpSize.Height), 0, 100 );
 rPropMap.setProperty( 
ShapeProperty::FillBitmapOffsetY, nTileOffsetY );
 }
 }
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 3418a125fac5..86b9b5ac91dc 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1887,19 +1887,18 @@ void 
DrawingML::WriteXGraphicTile(uno::Reference const& rXP
 if (rMapMode.GetMapUnit() == MapUnit::MapPixel)
 aOriginalSize = 
Application::GetDefaultDevice()->PixelToLogic(aOriginalSize,
   
MapMode(MapUnit::Map100thMM));
-sal_Int32 nOffsetX = 0;
-if (GetProperty(rXPropSet, "FillBitmapPositionOffsetX"))
-nOffsetX = (*o3tl::doAccess(mAny)) * aOriginalSize.Width() 
* 3.6;
-
-sal_Int32 nOffsetY = 0;
-if (GetProperty(rXPropSet, "FillBitmapPositionOffsetY"))
-nOffsetY = (*o3tl::doAccess(mAny)) * aOriginalSize.Height() 
* 3.6;
-
-// convert the X size of bitmap to a percentage
 sal_Int32 nSizeX = 0;
+sal_Int32 nOffsetX = 0;
 if (GetProperty(rXPropSet, "FillBitmapSizeX"))
 {
 mAny >>= nSizeX;
+if (GetProperty(rXPropSet, "FillBitmapPositionOffsetX"))
+{
+sal_Int32 nX = (nSizeX != 0) ? nSizeX : aOriginalSize.Width();
+nOffsetX = (*o3tl::doAccess(mAny)) * nX * 3.6;
+}
+
+// convert the X size of bitmap to a percentage
 if (nSizeX > 0)
 nSizeX = double(nSizeX) / aOriginalSize.Width() * 10;
 else if (nSizeX < 0)
@@ -1908,11 +1907,18 @@ void 
DrawingML::WriteXGraphicTile(uno::Reference const& rXP
 nSizeX = 10;
 }
 
-// convert the Y size of bitmap to a percentage
 sal_Int32 nSizeY = 0;
+sal_Int32 nOffsetY = 0;
 if (GetProperty(rXPropSet, "FillBitmapSizeY"))
 {
 mAny >>= nSizeY;
+if (GetProperty(rXPropSet, "FillBitmapPositionOffsetY"))
+{
+sal_Int32 nY = (nSizeY != 0) ? nSizeY : aOriginalSize.Height();
+nOffsetY = (*o3tl::doAccess(mAny)) * nY * 3.6;
+}
+
+// convert the Y size of bitmap to a percentage
 if (nSizeY > 0)
 nSizeY = double(nSizeY) / aOriginalSize.Height() * 10;
 else if (nSizeY < 0)
diff --git a/sd/qa/unit/data/pptx/tdf152070.pptx 
b/sd/qa/unit/data/pptx/tdf152070.pptx
new file mode 100644
index ..1fbc8016d149
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf152070.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx 

[Libreoffice-commits] core.git: oox/source sd/qa

2022-12-19 Thread Tünde Tóth (via logerrit)
 oox/source/export/shapes.cxx  |   10 ++
 sd/qa/unit/data/pptx/ole-emf_min.pptx |binary
 sd/qa/unit/export-tests-ooxml3.cxx|   11 +++
 3 files changed, 21 insertions(+)

New commits:
commit 907da02bf8b33c080538731864225b3c44251328
Author: Tünde Tóth 
AuthorDate: Tue Dec 13 11:08:52 2022 +0100
Commit: László Németh 
CommitDate: Mon Dec 19 11:47:09 2022 +

tdf#152436 PPTX export regression: fix lost shape at missing object

If the object is missing, it's still possible to keep its shape
by exporting its preview graphic, as before the regression.

Regression from commit adc042f95d3dbd65b778260025d59283146916e5
"tdf#124333 PPTX import: fix Z-order of embedded OLE objects".

Change-Id: Ib2fd00f53a80572cfc9acaefea55015780c57da8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144040
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 125ea39e2970..137c69fe7c33 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -2538,6 +2538,16 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const 
Reference< XShape >& xShape )
 if (!xObj.is())
 {
 SAL_WARN("oox.shape", "ShapeExport::WriteOLE2Shape: no object");
+
+// tdf#152436 Export the preview graphic of the object if the object 
is missing.
+SdrObject* pSdrOLE2(SdrObject::getSdrObjectFromXShape(xShape));
+if (auto pOle2Obj = dynamic_cast(pSdrOLE2))
+{
+const Graphic* pGraphic = pOle2Obj->GetGraphic();
+if (pGraphic)
+WriteGraphicObjectShapePart(xShape, pGraphic);
+}
+
 return *this;
 }
 
diff --git a/sd/qa/unit/data/pptx/ole-emf_min.pptx 
b/sd/qa/unit/data/pptx/ole-emf_min.pptx
new file mode 100644
index ..0f97208fbebc
Binary files /dev/null and b/sd/qa/unit/data/pptx/ole-emf_min.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index 2e6a600ec686..309709317821 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -130,6 +130,7 @@ public:
 void testTdf124333();
 void testAutofittedTextboxIndent();
 void testTdf151622_oleIcon();
+void testTdf152436();
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest3);
 
@@ -221,6 +222,7 @@ public:
 CPPUNIT_TEST(testTdf124333);
 CPPUNIT_TEST(testAutofittedTextboxIndent);
 CPPUNIT_TEST(testTdf151622_oleIcon);
+CPPUNIT_TEST(testTdf152436);
 CPPUNIT_TEST_SUITE_END();
 
 virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override
@@ -2105,6 +2107,15 @@ void SdOOXMLExportTest3::testTdf151622_oleIcon()
 assertXPath(pXml, "//p:oleObj", "showAsIcon", "1");
 }
 
+void SdOOXMLExportTest3::testTdf152436()
+{
+createSdImpressDoc("pptx/ole-emf_min.pptx");
+saveAndReload("Impress Office Open XML");
+
+// Check number of shapes after export.
+CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getPage(0)->getCount());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest3);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


[Libreoffice-commits] core.git: oox/source sd/qa

2022-12-05 Thread Tibor Nagy (via logerrit)
 oox/source/ppt/slidepersist.cxx  |   34 ++
 sd/qa/unit/data/pptx/connectors.pptx |binary
 sd/qa/unit/import-tests.cxx  |4 ++--
 3 files changed, 28 insertions(+), 10 deletions(-)

New commits:
commit 400e44cebd993f4b9b3d878fb9264f99e005c9fb
Author: Tibor Nagy 
AuthorDate: Tue Nov 29 15:43:58 2022 +0100
Commit: László Németh 
CommitDate: Mon Dec 5 11:20:11 2022 +

tdf#152211 PPTX import: fix connector position based on line width

Thick shape line changed the connector, e.g. direction of
its arrow head.

Follow-up to commit d8c89fb920af747ec51ce966b5d7b65e9340afbd
"tdf#151891 PPTX import: fix regression of connector position"

Regression from commit cbf66ec3e60d07efb7c3cceed9b4f0fb4f0510c8
"tdf#89449 PPTX import: fix line connectors".

Change-Id: I99d22409ec65e10609b1e371cc4d301fd73c7c82
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143467
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx
index 3b9a93ded03c..9d2ad58b5be2 100644
--- a/oox/source/ppt/slidepersist.cxx
+++ b/oox/source/ppt/slidepersist.cxx
@@ -371,10 +371,24 @@ static void 
lcl_SetEdgeLineValue(uno::Reference& rXConnector,
 SdrObject* pStartObj = xStartSp.is() ? 
SdrObject::getSdrObjectFromXShape(xStartSp) : nullptr;
 SdrObject* pEndObj = xEndSp.is() ? 
SdrObject::getSdrObjectFromXShape(xEndSp) : nullptr;
 
+sal_Int32 nStartSpLineW = 0;
 if (pStartObj)
+{
 aStartRect = pStartObj->GetSnapRect();
+uno::Reference xPropxStartSp(xStartSp, 
uno::UNO_QUERY);
+xPropxStartSp->getPropertyValue("LineWidth") >>= nStartSpLineW;
+if (nStartSpLineW)
+nStartSpLineW = nStartSpLineW / 2;
+}
+sal_Int32 nEndSpLineW = 0;
 if (pEndObj)
+{
 aEndRect = pEndObj->GetSnapRect();
+uno::Reference xPropxEndSp(xEndSp, 
uno::UNO_QUERY);
+xPropxEndSp->getPropertyValue("LineWidth") >>= nEndSpLineW;
+if (nEndSpLineW)
+nEndSpLineW = nEndSpLineW / 2;
+}
 
 const OUString sConnectorName = rShapePtr->getConnectorName();
 if (sConnectorName == "bentConnector2")
@@ -385,20 +399,24 @@ static void 
lcl_SetEdgeLineValue(uno::Reference& rXConnector,
 if (aConnSize.Height < aConnSize.Width)
 {
 if (xStartSp.is())
-nEdge -= (aStartPt.Y > aEndPt.Y) ? (aStartRect.Top() - 
aEndPt.Y)
- : (aStartRect.Bottom() - 
aEndPt.Y);
+nEdge = (aStartPt.Y > aEndPt.Y)
+? (nStartSpLineW - (aStartRect.Top() - 
aEndPt.Y))
+: ((aEndPt.Y - aStartRect.Bottom()) - 
nStartSpLineW);
 else
-nEdge -= (aStartPt.Y > aEndPt.Y) ? (aEndRect.Bottom() - 
aStartPt.Y)
- : (aEndRect.Top() - 
aStartPt.Y);
+nEdge = (aStartPt.Y > aEndPt.Y)
+? ((aStartPt.Y - aEndRect.Bottom()) - 
nEndSpLineW)
+: (nEndSpLineW - (aEndRect.Top() - 
aStartPt.Y));
 }
 else
 {
 if (xStartSp.is())
-nEdge -= (aStartPt.X > aEndPt.X) ? (aStartRect.Left() - 
aEndPt.X)
- : (aStartRect.Right() - 
aEndPt.X);
+nEdge = (aStartPt.X > aEndPt.X)
+? (nStartSpLineW - (aStartRect.Left() - 
aEndPt.X))
+: ((aEndPt.X - aStartRect.Right()) - 
nStartSpLineW);
 else
-nEdge -= (aStartPt.X > aEndPt.X) ? (aEndRect.Right() - 
aStartPt.X)
- : (aEndRect.Left() - 
aStartPt.X);
+nEdge = (aStartPt.X > aEndPt.X)
+? ((aStartPt.X - aEndRect.Right()) - 
nEndSpLineW)
+: (nEndSpLineW - (aEndRect.Left() - 
aStartPt.X));
 }
 }
 else
diff --git a/sd/qa/unit/data/pptx/connectors.pptx 
b/sd/qa/unit/data/pptx/connectors.pptx
index ba959068663c..2f65acba13b8 100644
Binary files a/sd/qa/unit/data/pptx/connectors.pptx and 
b/sd/qa/unit/data/pptx/connectors.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 3f3aafcbe0e8..eb125a46834f 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -342,8 +342,8 @@ void SdImportTest::testConnectors()
 {
 createSdImpressDoc("pptx/connectors.pptx");
 
-sal_Int32 aEdgeValue[] = { -1167, -1167, -1591, 1476,  1356, -1357, 1604,  
-1540,
-   607,   1296,  -1638, -1060, -522, 1578,  -1291, 
333 };
+sal_Int32 aEdgeValue[] = { -1123, -1123, -1547, 1432,  1356, -1357, 

[Libreoffice-commits] core.git: oox/source sd/qa

2022-11-21 Thread Tibor Nagy (via logerrit)
 oox/source/export/shapes.cxx|   13 +++--
 sd/qa/unit/data/pptx/tdf149803.pptx |binary
 sd/qa/unit/export-tests-ooxml1.cxx  |   11 +++
 3 files changed, 22 insertions(+), 2 deletions(-)

New commits:
commit ab10008ecaa33228838115a0b714e4f118c07ac1
Author: Tibor Nagy 
AuthorDate: Wed Nov 9 14:08:02 2022 +0100
Commit: László Németh 
CommitDate: Mon Nov 21 10:04:36 2022 +0100

tdf#149803 tdf#128150 PPTX: export UseBgFill of custom shapes

Fixing tdf#128150 the UseBgFill property of shapes can
be saved to PPTX, but not in the case of custom shapes.

Follow-up to commits c4cf2e82e8d0aaef9b1daedc033d6edf647e5284
(tdf#128150 Add OOXML import/export for "use background fill"),
commit 50394abcc36a73c0205e6cb69d925c66c25f81f2,
(tdf#128150 Implement/add SlideBackgroundFill visualization") and
commit  9c2c48f14535e58cad0453fef584400ee703aecc
"tdf#128150 xmloff: ODF import/export of fill-use-slide-background".

Change-Id: Ib88f236d2533ef71ea66718d380e83d9a0685c3e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142489
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 9d00dff8348c..70466d17fdb1 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -812,11 +812,17 @@ ShapeExport& ShapeExport::WriteCustomShape( const 
Reference< XShape >& xShape )
 }
 
 FSHelperPtr pFS = GetFS();
-pFS->startElementNS(mnXmlNamespace, (GetDocumentType() != DOCUMENT_DOCX || 
mbUserShapes ? XML_sp : XML_wsp));
-
 // non visual shape properties
 if (GetDocumentType() != DOCUMENT_DOCX || mbUserShapes)
 {
+bool bUseBackground = false;
+if (GETA(FillUseSlideBackground))
+mAny >>= bUseBackground;
+if (bUseBackground)
+mpFS->startElementNS(mnXmlNamespace, XML_sp, XML_useBgFill, "1");
+else
+mpFS->startElementNS(mnXmlNamespace, XML_sp);
+
 bool isVisible = true ;
 if( GETA (Visible))
 {
@@ -904,7 +910,10 @@ ShapeExport& ShapeExport::WriteCustomShape( const 
Reference< XShape >& xShape )
 pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
 }
 else
+{
+pFS->startElementNS(mnXmlNamespace, XML_wsp);
 pFS->singleElementNS(mnXmlNamespace, XML_cNvSpPr);
+}
 
 // visual shape properties
 pFS->startElementNS(mnXmlNamespace, XML_spPr);
diff --git a/sd/qa/unit/data/pptx/tdf149803.pptx 
b/sd/qa/unit/data/pptx/tdf149803.pptx
new file mode 100644
index ..a3a16cc23fdc
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf149803.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx 
b/sd/qa/unit/export-tests-ooxml1.cxx
index 97d2b80902c8..866cd331dc68 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -53,6 +53,7 @@ public:
 {
 }
 
+void testTdf149803();
 void testTdf149311();
 void testTdf149128();
 void testTdf66228();
@@ -126,6 +127,7 @@ public:
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest1);
 
+CPPUNIT_TEST(testTdf149803);
 CPPUNIT_TEST(testTdf149311);
 CPPUNIT_TEST(testTdf149128);
 CPPUNIT_TEST(testTdf66228);
@@ -225,6 +227,15 @@ void checkFontAttributes(const SdrTextObj* pObj, ItemValue 
nVal, sal_uInt32 nId)
 }
 }
 
+void SdOOXMLExportTest1::testTdf149803()
+{
+loadFromURL(u"pptx/tdf149803.pptx");
+save("Impress Office Open XML");
+
+xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
+assertXPath(pXmlDoc, "/p:sld/p:cSld/p:spTree/p:sp", "useBgFill", "1");
+}
+
 void SdOOXMLExportTest1::testTdf149311()
 {
 loadFromURL(u"odp/tdf149311.odp");


[Libreoffice-commits] core.git: oox/source sd/qa

2022-11-14 Thread Tibor Nagy (via logerrit)
 oox/source/ppt/slidepersist.cxx  |   24 +++-
 sd/qa/unit/data/pptx/connectors.pptx |binary
 sd/qa/unit/import-tests.cxx  |   16 
 3 files changed, 31 insertions(+), 9 deletions(-)

New commits:
commit d8c89fb920af747ec51ce966b5d7b65e9340afbd
Author: Tibor Nagy 
AuthorDate: Fri Nov 4 20:58:36 2022 +0100
Commit: László Németh 
CommitDate: Mon Nov 14 13:31:36 2022 +0100

tdf#151891 PPTX import: fix regression of connector position

If the connector shape is connected to the glue point which there
is inside the bounding box, then the position of connector appear
incorrectly, for example different direction of the arrow head.

Regression likely from commit cbf66ec3e60d07efb7c3cceed9b4f0fb4f0510c8
"tdf#89449 PPTX import: fix line connectors", as tdf#148926.

Follow-up to commit eec48130271188cab63665acedbabf1ff5e850a2
"tdf#148926 tdf#151678 PPTX import: position of standard connector
 - part1".

Change-Id: I5671bc70e663a979c43bad1b786118a6a9e92972
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142293
Reviewed-by: László Németh 
Tested-by: László Németh 

diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx
index 126fc664bd3a..3b9a93ded03c 100644
--- a/oox/source/ppt/slidepersist.cxx
+++ b/oox/source/ppt/slidepersist.cxx
@@ -46,6 +46,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace ::com::sun::star;
 using namespace ::oox::core;
@@ -355,6 +356,7 @@ static void 
lcl_SetEdgeLineValue(uno::Reference& rXConnector,
 {
 sal_Int32 nEdge = 0;
 awt::Point aStartPt, aEndPt;
+tools::Rectangle aStartRect, aEndRect;
 uno::Reference xStartSp, xEndSp;
 uno::Reference xPropSet(rXConnector, uno::UNO_QUERY);
 xPropSet->getPropertyValue("EdgeStartPoint") >>= aStartPt;
@@ -366,6 +368,14 @@ static void 
lcl_SetEdgeLineValue(uno::Reference& rXConnector,
 xPropSet->setPropertyValue("EdgeNode2HorzDist", Any(sal_Int32(0)));
 xPropSet->setPropertyValue("EdgeNode2VertDist", Any(sal_Int32(0)));
 
+SdrObject* pStartObj = xStartSp.is() ? 
SdrObject::getSdrObjectFromXShape(xStartSp) : nullptr;
+SdrObject* pEndObj = xEndSp.is() ? 
SdrObject::getSdrObjectFromXShape(xEndSp) : nullptr;
+
+if (pStartObj)
+aStartRect = pStartObj->GetSnapRect();
+if (pEndObj)
+aEndRect = pEndObj->GetSnapRect();
+
 const OUString sConnectorName = rShapePtr->getConnectorName();
 if (sConnectorName == "bentConnector2")
 {
@@ -375,16 +385,20 @@ static void 
lcl_SetEdgeLineValue(uno::Reference& rXConnector,
 if (aConnSize.Height < aConnSize.Width)
 {
 if (xStartSp.is())
-nEdge = (aStartPt.Y > aEndPt.Y) ? -aConnSize.Height : 
aConnSize.Height;
+nEdge -= (aStartPt.Y > aEndPt.Y) ? (aStartRect.Top() - 
aEndPt.Y)
+ : (aStartRect.Bottom() - 
aEndPt.Y);
 else
-nEdge = (aStartPt.Y > aEndPt.Y) ? aConnSize.Height : 
-aConnSize.Height;
+nEdge -= (aStartPt.Y > aEndPt.Y) ? (aEndRect.Bottom() - 
aStartPt.Y)
+ : (aEndRect.Top() - 
aStartPt.Y);
 }
 else
 {
 if (xStartSp.is())
-nEdge = (aStartPt.X > aEndPt.X) ? -aConnSize.Width : 
aConnSize.Width;
+nEdge -= (aStartPt.X > aEndPt.X) ? (aStartRect.Left() - 
aEndPt.X)
+ : (aStartRect.Right() - 
aEndPt.X);
 else
-nEdge = (aStartPt.X > aEndPt.X) ? aConnSize.Width : 
-aConnSize.Width;
+nEdge -= (aStartPt.X > aEndPt.X) ? (aEndRect.Right() - 
aStartPt.X)
+ : (aEndRect.Left() - 
aStartPt.X);
 }
 }
 else
@@ -395,7 +409,7 @@ static void 
lcl_SetEdgeLineValue(uno::Reference& rXConnector,
 if (aConnSize.Height < aConnSize.Width)
 {
 if ((nConnectorAngle == 90 && bFlipH && bFlipV) || 
(nConnectorAngle == 180)
-|| (nConnectorAngle == 180 && bFlipV) || (nConnectorAngle 
== 270 && bFlipH))
+|| (nConnectorAngle == 270 && bFlipH))
 nEdge -= aConnSize.Width;
 else
 nEdge += aConnSize.Width;
diff --git a/sd/qa/unit/data/pptx/connectors.pptx 
b/sd/qa/unit/data/pptx/connectors.pptx
index fa03ef0f6046..ba959068663c 100644
Binary files a/sd/qa/unit/data/pptx/connectors.pptx and 
b/sd/qa/unit/data/pptx/connectors.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 6e10700d5671..34523fa136cd 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -344,12 +344,20 @@ void SdImportTest::testConnectors()
 {
 

[Libreoffice-commits] core.git: oox/source sd/qa

2022-11-14 Thread Xisco Fauli (via logerrit)
 oox/source/export/shapes.cxx   |7 +++
 sd/qa/unit/data/odp/ole_icon.odp   |binary
 sd/qa/unit/export-tests-ooxml3.cxx |   17 +
 3 files changed, 24 insertions(+)

New commits:
commit 0b224cc5f3c896d8b0064d5cbadc6fce66c8beb9
Author: Xisco Fauli 
AuthorDate: Wed Nov 2 09:30:30 2022 +0100
Commit: László Németh 
CommitDate: Mon Nov 14 12:19:11 2022 +0100

Revert "Revert "tdf#151622 PPTX: fix export of show as icon option""

This reverts commit b652ebda7fa4e6c8db2f934bf4c8d2927f5c2332.

Adapt unittest to UnoApiTest

Change-Id: I6a1e42d4b445efdb48dab35f0bd5110aa52b0d74
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142156
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 
Reviewed-by: László Németh 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 88be4362b228..9d00dff8348c 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -47,6 +47,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2616,6 +2617,10 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const 
Reference< XShape >& xShape )
 TOOLS_WARN_EXCEPTION("oox.shape", "ShapeExport::WriteOLEObject");
 }
 
+sal_Int64 nAspect;
+bool bShowAsIcon = (xPropSet->getPropertyValue("Aspect") >>= nAspect)
+   && nAspect == embed::Aspects::MSOLE_ICON;
+
 OUString const sRelId = mpFB->addRelation(
 mpFS->getOutputStream(), sRelationType,
 Concat2View(OUString::createFromAscii(GetRelationCompPrefix()) + 
sFileName));
@@ -2642,6 +2647,7 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const 
Reference< XShape >& xShape )
 if (pProgID)
 {
 mpFS->startElementNS( mnXmlNamespace, XML_oleObj,
+  XML_showAsIcon, sax_fastparser::UseIf("1", 
bShowAsIcon),
   XML_progId, pProgID,
   FSNS(XML_r, XML_id), sRelId,
   XML_spid, "" );
@@ -2650,6 +2656,7 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const 
Reference< XShape >& xShape )
 {
 mpFS->startElementNS( mnXmlNamespace, XML_oleObj,
 //?  XML_name, "Document",
+  XML_showAsIcon, sax_fastparser::UseIf("1", 
bShowAsIcon),
   FSNS(XML_r, XML_id), sRelId,
   // The spec says that this is a required attribute, 
but PowerPoint can only handle an empty value.
   XML_spid, "" );
diff --git a/sd/qa/unit/data/odp/ole_icon.odp b/sd/qa/unit/data/odp/ole_icon.odp
new file mode 100644
index ..073899c6e564
Binary files /dev/null and b/sd/qa/unit/data/odp/ole_icon.odp differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index e5e8cee6c390..c32055df3f42 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -129,6 +129,7 @@ public:
 void testTdf94122_autoColor();
 void testTdf124333();
 void testAutofittedTextboxIndent();
+void testTdf151622_oleIcon();
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest3);
 
@@ -218,6 +219,7 @@ public:
 CPPUNIT_TEST(testTdf94122_autoColor);
 CPPUNIT_TEST(testTdf124333);
 CPPUNIT_TEST(testAutofittedTextboxIndent);
+CPPUNIT_TEST(testTdf151622_oleIcon);
 CPPUNIT_TEST_SUITE_END();
 
 virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override
@@ -2074,6 +2076,21 @@ void SdOOXMLExportTest3::testAutofittedTextboxIndent()
 "712800");
 }
 
+void SdOOXMLExportTest3::testTdf151622_oleIcon()
+{
+loadFromURL(u"odp/ole_icon.odp");
+
+utl::TempFileNamed tmpfile = save("Impress Office Open XML");
+
+xmlDocUniquePtr pXml = parseExport(tmpfile, "ppt/slides/slide1.xml");
+
+// Without the accompanying fix in place, this test would have failed with:
+// - Expression: prop
+// - In ..., XPath '//p:oleObj' no attribute 'showAsIcon' exist
+// i.e. show as icon option wasn't exported.
+assertXPath(pXml, "//p:oleObj", "showAsIcon", "1");
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest3);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


[Libreoffice-commits] core.git: oox/source sd/qa

2022-11-14 Thread Tibor Nagy (via logerrit)
 oox/source/export/shapes.cxx|   27 ++-
 sd/qa/unit/data/pptx/tdt142291.pptx |binary
 sd/qa/unit/export-tests-ooxml2.cxx  |   30 ++
 3 files changed, 56 insertions(+), 1 deletion(-)

New commits:
commit 1b167f3e0b1afec7c257f458db7505d8d8f177b3
Author: Tibor Nagy 
AuthorDate: Thu Nov 3 16:10:11 2022 +0100
Commit: László Németh 
CommitDate: Mon Nov 14 12:15:01 2022 +0100

tdf#142291 PPTX export: fix table border styles

Export border style subset used by the PPTX
import, ::table::BorderLineStyle::SOLID, DOTTED,
DASHED, DASH_DOT and DASH_DOT_DOT.

See also tablecell.cxx:applyLineAttributes().

Change-Id: I5e4d631f7ca410beb76155579ea5b21a6eb66350
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142240
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index d102880af7bd..88be4362b228 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -24,6 +24,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -65,6 +66,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2290,7 +2292,30 @@ void ShapeExport::WriteBorderLine(const sal_Int32 
XML_line, const BorderLine2& r
 mpFS->singleElementNS(XML_a, XML_noFill);
 else
 DrawingML::WriteSolidFill( ::Color(ColorTransparency, 
rBorderLine.Color) );
-mpFS->endElementNS( XML_a, XML_line );
+
+OUString sBorderStyle;
+sal_Int16 nStyle = rBorderLine.LineStyle;
+mAny.setValue(, cppu::UnoType::get());
+switch (*o3tl::doAccess(mAny))
+{
+case ::table::BorderLineStyle::SOLID:
+sBorderStyle = "solid";
+break;
+case ::table::BorderLineStyle::DOTTED:
+sBorderStyle = "dot";
+break;
+case ::table::BorderLineStyle::DASHED:
+sBorderStyle = "dash";
+break;
+case ::table::BorderLineStyle::DASH_DOT:
+sBorderStyle = "dashDot";
+break;
+case ::table::BorderLineStyle::DASH_DOT_DOT:
+sBorderStyle = "sysDashDotDot";
+break;
+}
+mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, sBorderStyle);
+mpFS->endElementNS(XML_a, XML_line);
 }
 else if( nBorderWidth == 0)
 {
diff --git a/sd/qa/unit/data/pptx/tdt142291.pptx 
b/sd/qa/unit/data/pptx/tdt142291.pptx
new file mode 100644
index ..eb5a17eebe88
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdt142291.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx 
b/sd/qa/unit/export-tests-ooxml2.cxx
index f7866c70a154..69f50c016315 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -76,6 +76,7 @@ public:
 {
 }
 
+void testTdf142291();
 void testTdf151492();
 void testTdf149697();
 void testTdf149126();
@@ -146,6 +147,7 @@ public:
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
 
+CPPUNIT_TEST(testTdf142291);
 CPPUNIT_TEST(testTdf151492);
 CPPUNIT_TEST(testTdf149697);
 CPPUNIT_TEST(testTdf149126);
@@ -222,6 +224,34 @@ public:
 }
 };
 
+void SdOOXMLExportTest2::testTdf142291()
+{
+loadFromURL(u"pptx/tdt142291.pptx");
+utl::TempFileNamed tempFile = save("Impress Office Open XML");
+
+xmlDocUniquePtr pXmlDocContent = parseExport(tempFile.GetURL(), 
"ppt/slides/slide1.xml");
+assertXPath(pXmlDocContent,
+
"/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData/a:tbl/a:tr/a:tc[1]/"
+"a:tcPr/a:lnL/a:prstDash",
+"val", "sysDashDotDot");
+assertXPath(pXmlDocContent,
+
"/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData/a:tbl/a:tr/a:tc[1]/"
+"a:tcPr/a:lnR/a:prstDash",
+"val", "dot");
+assertXPath(pXmlDocContent,
+
"/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData/a:tbl/a:tr/a:tc[1]/"
+"a:tcPr/a:lnT/a:prstDash",
+"val", "solid");
+assertXPath(pXmlDocContent,
+
"/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData/a:tbl/a:tr/a:tc[1]/"
+"a:tcPr/a:lnB/a:prstDash",
+"val", "dash");
+assertXPath(pXmlDocContent,
+
"/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData/a:tbl/a:tr/a:tc[2]/"
+"a:tcPr/a:lnR/a:prstDash",
+"val", "dashDot");
+}
+
 void SdOOXMLExportTest2::testTdf151492()
 {
 loadFromURL(u"odp/tdf151492.odp");


[Libreoffice-commits] core.git: oox/source sd/qa sw/qa

2022-11-03 Thread Regina Henschel (via logerrit)
 oox/source/export/drawingml.cxx   |   23 ---
 sd/qa/unit/ShapeImportExportTest.cxx  |   44 +-
 sd/qa/unit/data/odp/tdf150966_hugeInset.odp   |binary
 sw/qa/extras/ooxmlexport/data/tdf150966_regularInset.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx|   18 +
 5 files changed, 63 insertions(+), 22 deletions(-)

New commits:
commit 933768ffcd8617942f45481de77e656ded9dcfe2
Author: Regina Henschel 
AuthorDate: Wed Nov 2 22:34:16 2022 +0100
Commit: Regina Henschel 
CommitDate: Thu Nov 3 16:28:31 2022 +0100

tdf#150966 oox export avoid bottom above top for text area

If bottom and top insets set so that the bottom edge of the resulting
text area is above the top edge, then LO and MS Office behave different
in how this is rendered. With commit e2169886 insets are converted on
import to make rendering in LO similar to MS Office, but the
implemented export has some problems, see analysis in bug report.

LibreOffice normalizes the resulting text area in case bottom edge is
above top edge. So this patch exports the insets so, that MS Office
gets a normalized resulting text area and will not apply its special
rules.

A roundtrip starting with pptx will not regenerate the old values but
will produce inset values, which give same rendering in MS Office than
in LO. Because the method is different now, the inset values have
changed and test testTextDistancesOOXML_Export is adapted. When you
compare the result with the screenshot on slide 2, you see that the
new method works as well.

The old method did not work for exporting an odp file. That is covered
by the new unit test. The docx unit test file covers the case, that
the export tweak was erroneously triggered.

Change-Id: I0091f284d9bdd635dd87ddb9e9b0e415cc0cc51e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142185
Tested-by: Jenkins
Reviewed-by: Regina Henschel 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 8939a5415683..80d38e8dfc79 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -110,6 +110,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -3335,21 +3336,27 @@ void DrawingML::WriteText(const Reference& 
rXIface, bool bBodyPr, bo
 // Transform the text distance values so they are compatible with OOXML 
insets
 if (xShape.is())
 {
-sal_Int32 nTextHeight = xShape->getSize().Width;
+sal_Int32 nTextHeight = xShape->getSize().Height; // Hmm, default
 
-auto* pCustomShape = 
dynamic_cast(SdrObject::getSdrObjectFromXShape(xShape));
+// CustomShape can have text area different from shape rectangle
+auto* pCustomShape
+= 
dynamic_cast(SdrObject::getSdrObjectFromXShape(xShape));
 if (pCustomShape)
 {
-tools::Rectangle aAnchorRect;
-pCustomShape->TakeTextAnchorRect(aAnchorRect);
-nTextHeight = aAnchorRect.GetSize().getHeight();
+const EnhancedCustomShape2d aCustomShape2d(*pCustomShape);
+nTextHeight = aCustomShape2d.GetTextRect().getOpenHeight();
+if (DOCUMENT_DOCX == meDocumentType)
+nTextHeight = convertTwipToMm100(nTextHeight);
 }
 
 if (nTop + nBottom >= nTextHeight)
 {
-sal_Int32 nDiff = std::abs(std::min(nTop, nBottom));
-nTop += nDiff;
-nBottom += nDiff;
+// Effective bottom would be above effective top of text area. LO 
normalizes the
+// effective text area in such case implicitely for rendering. MS 
needs indents so that
+// the result is the normalized effective text area.
+std::swap(nTop, nBottom);
+nTop = nTextHeight - nTop;
+nBottom = nTextHeight - nBottom;
 }
 }
 
diff --git a/sd/qa/unit/ShapeImportExportTest.cxx 
b/sd/qa/unit/ShapeImportExportTest.cxx
index a0e6b63b4ccb..ce972e0a38cc 100644
--- a/sd/qa/unit/ShapeImportExportTest.cxx
+++ b/sd/qa/unit/ShapeImportExportTest.cxx
@@ -30,11 +30,13 @@ public:
 void testTextDistancesOOXML();
 void testTextDistancesOOXML_LargerThanTextAreaSpecialCase();
 void testTextDistancesOOXML_Export();
+void testTextDistancesODP_OOXML_Export();
 
 CPPUNIT_TEST_SUITE(ShapeImportExportTest);
 CPPUNIT_TEST(testTextDistancesOOXML);
 CPPUNIT_TEST(testTextDistancesOOXML_LargerThanTextAreaSpecialCase);
 CPPUNIT_TEST(testTextDistancesOOXML_Export);
+CPPUNIT_TEST(testTextDistancesODP_OOXML_Export);
 CPPUNIT_TEST_SUITE_END();
 
 virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override
@@ -267,28 +269,28 @@ void 
ShapeImportExportTest::testTextDistancesOOXML_Export()
 //Check shape Top/Bottom - 0cm, 4cm
 assertXPath(pXmlDoc, 

[Libreoffice-commits] core.git: oox/source sd/qa

2022-11-02 Thread László Németh (via logerrit)
 dev/null   |binary
 oox/source/export/shapes.cxx   |7 ---
 sd/qa/unit/export-tests-ooxml3.cxx |   19 ---
 3 files changed, 26 deletions(-)

New commits:
commit b652ebda7fa4e6c8db2f934bf4c8d2927f5c2332
Author: László Németh 
AuthorDate: Wed Nov 2 09:08:50 2022 +0100
Commit: László Németh 
CommitDate: Wed Nov 2 09:09:21 2022 +0100

Revert "tdf#151622 PPTX: fix export of show as icon option"

This reverts commit ea62cacd129f03813d7d3d214bf9aa2ae60bbef4.

Reason for revert: not declared macros ODP & PPTX in unit test

Change-Id: Ic2c3a39ff36401f49f3d759eb60645ed239b1d4c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142142
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 541f54a0fdb8..d102880af7bd 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -46,7 +46,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -2592,10 +2591,6 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const 
Reference< XShape >& xShape )
 TOOLS_WARN_EXCEPTION("oox.shape", "ShapeExport::WriteOLEObject");
 }
 
-sal_Int64 nAspect;
-bool bShowAsIcon = (xPropSet->getPropertyValue("Aspect") >>= nAspect)
-   && nAspect == embed::Aspects::MSOLE_ICON;
-
 OUString const sRelId = mpFB->addRelation(
 mpFS->getOutputStream(), sRelationType,
 Concat2View(OUString::createFromAscii(GetRelationCompPrefix()) + 
sFileName));
@@ -2622,7 +2617,6 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const 
Reference< XShape >& xShape )
 if (pProgID)
 {
 mpFS->startElementNS( mnXmlNamespace, XML_oleObj,
-  XML_showAsIcon, sax_fastparser::UseIf("1", 
bShowAsIcon),
   XML_progId, pProgID,
   FSNS(XML_r, XML_id), sRelId,
   XML_spid, "" );
@@ -2631,7 +2625,6 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const 
Reference< XShape >& xShape )
 {
 mpFS->startElementNS( mnXmlNamespace, XML_oleObj,
 //?  XML_name, "Document",
-  XML_showAsIcon, sax_fastparser::UseIf("1", 
bShowAsIcon),
   FSNS(XML_r, XML_id), sRelId,
   // The spec says that this is a required attribute, 
but PowerPoint can only handle an empty value.
   XML_spid, "" );
diff --git a/sd/qa/unit/data/odp/ole_icon.odp b/sd/qa/unit/data/odp/ole_icon.odp
deleted file mode 100644
index 073899c6e564..
Binary files a/sd/qa/unit/data/odp/ole_icon.odp and /dev/null differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index 93c8a3ac908e..a4e5d882d8e6 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -129,7 +129,6 @@ public:
 void testTdf94122_autoColor();
 void testTdf124333();
 void testAutofittedTextboxIndent();
-void testTdf151622_oleIcon();
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest3);
 
@@ -219,7 +218,6 @@ public:
 CPPUNIT_TEST(testTdf94122_autoColor);
 CPPUNIT_TEST(testTdf124333);
 CPPUNIT_TEST(testAutofittedTextboxIndent);
-CPPUNIT_TEST(testTdf151622_oleIcon);
 CPPUNIT_TEST_SUITE_END();
 
 virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override
@@ -2073,23 +2071,6 @@ void SdOOXMLExportTest3::testAutofittedTextboxIndent()
 "691200");
 }
 
-void SdOOXMLExportTest3::testTdf151622_oleIcon()
-{
-auto xDocShRef = 
loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/odp/ole_icon.odp"), ODP);
-
-utl::TempFileNamed tmpfile;
-xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
-xDocShRef->DoClose();
-
-xmlDocUniquePtr pXml = parseExport(tmpfile, "ppt/slides/slide1.xml");
-
-// Without the accompanying fix in place, this test would have failed with:
-// - Expression: prop
-// - In ..., XPath '//p:oleObj' no attribute 'showAsIcon' exist
-// i.e. show as icon option wasn't exported.
-assertXPath(pXml, "//p:oleObj", "showAsIcon", "1");
-}
-
 CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest3);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


[Libreoffice-commits] core.git: oox/source sd/qa

2022-11-02 Thread Tünde Tóth (via logerrit)
 oox/source/export/shapes.cxx   |7 +++
 sd/qa/unit/data/odp/ole_icon.odp   |binary
 sd/qa/unit/export-tests-ooxml3.cxx |   19 +++
 3 files changed, 26 insertions(+)

New commits:
commit ea62cacd129f03813d7d3d214bf9aa2ae60bbef4
Author: Tünde Tóth 
AuthorDate: Tue Oct 18 16:20:43 2022 +0200
Commit: László Németh 
CommitDate: Wed Nov 2 08:03:40 2022 +0100

tdf#151622 PPTX: fix export of show as icon option

Embedded OLE object wasn't look like an icon after its opening
because of missing showAsIcon="1" of p:oleObj.

Change-Id: I21dbd1e31f7e1de78d8bf548ca6f3619eb3e4a10
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141505
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index d102880af7bd..541f54a0fdb8 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -46,6 +46,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2591,6 +2592,10 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const 
Reference< XShape >& xShape )
 TOOLS_WARN_EXCEPTION("oox.shape", "ShapeExport::WriteOLEObject");
 }
 
+sal_Int64 nAspect;
+bool bShowAsIcon = (xPropSet->getPropertyValue("Aspect") >>= nAspect)
+   && nAspect == embed::Aspects::MSOLE_ICON;
+
 OUString const sRelId = mpFB->addRelation(
 mpFS->getOutputStream(), sRelationType,
 Concat2View(OUString::createFromAscii(GetRelationCompPrefix()) + 
sFileName));
@@ -2617,6 +2622,7 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const 
Reference< XShape >& xShape )
 if (pProgID)
 {
 mpFS->startElementNS( mnXmlNamespace, XML_oleObj,
+  XML_showAsIcon, sax_fastparser::UseIf("1", 
bShowAsIcon),
   XML_progId, pProgID,
   FSNS(XML_r, XML_id), sRelId,
   XML_spid, "" );
@@ -2625,6 +2631,7 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const 
Reference< XShape >& xShape )
 {
 mpFS->startElementNS( mnXmlNamespace, XML_oleObj,
 //?  XML_name, "Document",
+  XML_showAsIcon, sax_fastparser::UseIf("1", 
bShowAsIcon),
   FSNS(XML_r, XML_id), sRelId,
   // The spec says that this is a required attribute, 
but PowerPoint can only handle an empty value.
   XML_spid, "" );
diff --git a/sd/qa/unit/data/odp/ole_icon.odp b/sd/qa/unit/data/odp/ole_icon.odp
new file mode 100644
index ..073899c6e564
Binary files /dev/null and b/sd/qa/unit/data/odp/ole_icon.odp differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index a4e5d882d8e6..93c8a3ac908e 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -129,6 +129,7 @@ public:
 void testTdf94122_autoColor();
 void testTdf124333();
 void testAutofittedTextboxIndent();
+void testTdf151622_oleIcon();
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest3);
 
@@ -218,6 +219,7 @@ public:
 CPPUNIT_TEST(testTdf94122_autoColor);
 CPPUNIT_TEST(testTdf124333);
 CPPUNIT_TEST(testAutofittedTextboxIndent);
+CPPUNIT_TEST(testTdf151622_oleIcon);
 CPPUNIT_TEST_SUITE_END();
 
 virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override
@@ -2071,6 +2073,23 @@ void SdOOXMLExportTest3::testAutofittedTextboxIndent()
 "691200");
 }
 
+void SdOOXMLExportTest3::testTdf151622_oleIcon()
+{
+auto xDocShRef = 
loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/odp/ole_icon.odp"), ODP);
+
+utl::TempFileNamed tmpfile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+xDocShRef->DoClose();
+
+xmlDocUniquePtr pXml = parseExport(tmpfile, "ppt/slides/slide1.xml");
+
+// Without the accompanying fix in place, this test would have failed with:
+// - Expression: prop
+// - In ..., XPath '//p:oleObj' no attribute 'showAsIcon' exist
+// i.e. show as icon option wasn't exported.
+assertXPath(pXml, "//p:oleObj", "showAsIcon", "1");
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest3);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


[Libreoffice-commits] core.git: oox/source sd/qa

2022-10-27 Thread Tibor Nagy (via logerrit)
 oox/source/drawingml/table/predefined-table-styles.cxx |2 
 oox/source/drawingml/table/tablecell.cxx   |   59 ++---
 sd/qa/unit/data/pptx/tdf151767.pptx|binary
 sd/qa/unit/export-tests-ooxml3.cxx |   28 
 sd/qa/unit/import-tests.cxx|   30 
 5 files changed, 83 insertions(+), 36 deletions(-)

New commits:
commit d83a016823dceaeb48f34d4e94f9a230bebd9169
Author: Tibor Nagy 
AuthorDate: Wed Oct 26 16:44:01 2022 +0200
Commit: László Németh 
CommitDate: Thu Oct 27 20:35:01 2022 +0200

tdf#151767 PPTX import: fix table border width

There is a "Clear Table" function in PP. In this case,
the table uses the default border value of MSO, which
was imported as missing table border.

(Note: commit ff0387e726b59e374029d2f635ce00308d99eff6
"tdf#135843: sd_export_tests-ooxml3: Add unittest for the
export part" If attachment from tdf#106011 is opened in
PowerPoint, the table is visible it, but was not in LO.
This patch fixed that. Therefore the borders of table are
not missing after export.)

Change-Id: I92dfe2e42f5f58b15af23cc24e931fb12d7c2794
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141880
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/drawingml/table/predefined-table-styles.cxx 
b/oox/source/drawingml/table/predefined-table-styles.cxx
index 7d420038856a..531e20b14512 100644
--- a/oox/source/drawingml/table/predefined-table-styles.cxx
+++ b/oox/source/drawingml/table/predefined-table-styles.cxx
@@ -884,6 +884,8 @@ std::unique_ptr CreateTableStyle(const 
OUString& styleId)
 // End to handle all style groups.
 
 // Create a TableStyle from handled properties.
+pTableStyle->getStyleId() = styleId;
+pTableStyle->getStyleName() = style_name;
 
 pTableStyle->getWholeTbl().getTextColor() = wholeTblTextColor;
 pTableStyle->getFirstRow().getTextColor() = firstRowTextColor;
diff --git a/oox/source/drawingml/table/tablecell.cxx 
b/oox/source/drawingml/table/tablecell.cxx
index 77b69b8e4e3e..17b13526084d 100644
--- a/oox/source/drawingml/table/tablecell.cxx
+++ b/oox/source/drawingml/table/tablecell.cxx
@@ -61,26 +61,41 @@ TableCell::TableCell()
 {
 }
 
-static void applyLineAttributes( const ::oox::core::XmlFilterBase& rFilterBase,
-Reference< XPropertySet > const & rxPropSet, 
oox::drawingml::LineProperties const & rLineProperties,
-sal_Int32 nPropId )
+static void applyLineAttributes(const ::oox::core::XmlFilterBase& rFilterBase,
+Reference const& rxPropSet,
+oox::drawingml::table::TableStyle const& 
rTableStyle,
+oox::drawingml::LineProperties const& 
rLineProperties,
+sal_Int32 nPropId)
 {
 BorderLine2 aBorderLine;
-if ( rLineProperties.maLineFill.moFillType.has_value() && 
rLineProperties.maLineFill.moFillType.value() != XML_noFill )
+TableStyle& rTable(const_cast(rTableStyle));
+if (!rTable.getStyleId().isEmpty())
 {
 Color aColor = rLineProperties.maLineFill.getBestSolidColor();
-aBorderLine.Color = sal_Int32(aColor.getColor( 
rFilterBase.getGraphicHelper() ));
-aBorderLine.OuterLineWidth = static_cast< sal_Int16 >( GetCoordinate( 
rLineProperties.moLineWidth.value_or( 0 ) ) / 4 );
-aBorderLine.InnerLineWidth = static_cast< sal_Int16 >( GetCoordinate( 
rLineProperties.moLineWidth.value_or( 0 ) ) / 4 );
-aBorderLine.LineWidth = static_cast< sal_Int16 >( GetCoordinate( 
rLineProperties.moLineWidth.value_or( 0 ) ) / 2 );
+aBorderLine.Color = 
sal_Int32(aColor.getColor(rFilterBase.getGraphicHelper()));
+aBorderLine.OuterLineWidth = 
static_cast(GetCoordinate(rLineProperties.moLineWidth.value_or(0)) / 
4);
+aBorderLine.InnerLineWidth = 
static_cast(GetCoordinate(rLineProperties.moLineWidth.value_or(0)) / 
4);
+aBorderLine.LineWidth = 
static_cast(GetCoordinate(rLineProperties.moLineWidth.value_or(0)) / 
2);
 aBorderLine.LineDistance = 0;
 }
 else
 {
-aBorderLine.Color = sal_Int32( COL_AUTO );
-aBorderLine.OuterLineWidth = static_cast< sal_Int16 >( GetCoordinate( 
rLineProperties.moLineWidth.value_or( 0 ) ) / 4 );
-aBorderLine.InnerLineWidth = static_cast< sal_Int16 >( GetCoordinate( 
rLineProperties.moLineWidth.value_or( 0 ) ) / 4 );
-aBorderLine.LineWidth = static_cast< sal_Int16 >( GetCoordinate( 
rLineProperties.moLineWidth.value_or( 0 ) ) / 2 );
+if (rLineProperties.maLineFill.moFillType.has_value())
+{
+if (rLineProperties.maLineFill.moFillType.value() != XML_noFill)
+{
+Color aColor = rLineProperties.maLineFill.getBestSolidColor();
+aBorderLine.Color = 
sal_Int32(aColor.getColor(rFilterBase.getGraphicHelper()));
+ 

[Libreoffice-commits] core.git: oox/source sd/qa

2022-10-27 Thread Tibor Nagy (via logerrit)
 oox/source/export/shapes.cxx   |3 +--
 sd/qa/unit/data/odp/tdf151492.odp  |binary
 sd/qa/unit/export-tests-ooxml2.cxx |   16 
 3 files changed, 17 insertions(+), 2 deletions(-)

New commits:
commit 097a2de6428f834d28fa78af203d3c0b6577656e
Author: Tibor Nagy 
AuthorDate: Sun Oct 16 09:32:33 2022 +0200
Commit: László Németh 
CommitDate: Thu Oct 27 18:17:26 2022 +0200

tdf#151492 PPTX export: fix connection points regression

caused by commit 4d153517183193f468dee9148c94fe9d874bacb3
(tdf#149697 PPTX export: fix changing place of connection points).

Change-Id: I6134f18f3c32182a2f5d7295e2511da192dd20c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141427
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index c7b563f4..d102880af7bd 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1643,8 +1643,7 @@ static sal_Int32 lcl_GetGluePointId(const 
Reference& xShape, sal_Int32&
 uno::Reference xSupplier(xShape, 
uno::UNO_QUERY);
 uno::Reference 
xGluePoints(xSupplier->getGluePoints(),
  uno::UNO_QUERY);
-sal_uInt32 nCount = xGluePoints->getIdentifiers().size();
-if (nCount > 4)
+if (nGluePointId > 3)
 nGluePointId -= 4;
 else
 {
diff --git a/sd/qa/unit/data/odp/tdf151492.odp 
b/sd/qa/unit/data/odp/tdf151492.odp
new file mode 100644
index ..6928dac5982d
Binary files /dev/null and b/sd/qa/unit/data/odp/tdf151492.odp differ
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx 
b/sd/qa/unit/export-tests-ooxml2.cxx
index 928ecab95997..6b7e934a176f 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -70,6 +70,7 @@ static void assertMotionPath(std::u16string_view rStr1, 
std::u16string_view rStr
 class SdOOXMLExportTest2 : public SdModelTestBaseXML
 {
 public:
+void testTdf151492();
 void testTdf149697();
 void testTdf149126();
 void testTdf131905();
@@ -139,6 +140,7 @@ public:
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
 
+CPPUNIT_TEST(testTdf151492);
 CPPUNIT_TEST(testTdf149697);
 CPPUNIT_TEST(testTdf149126);
 CPPUNIT_TEST(testTdf131905);
@@ -214,6 +216,20 @@ public:
 }
 };
 
+void SdOOXMLExportTest2::testTdf151492()
+{
+::sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf151492.odp"), 
ODP);
+utl::TempFileNamed tempFile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+
+xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, 
"ppt/slides/slide1.xml");
+assertXPath(pXmlDocContent, 
"/p:sld/p:cSld/p:spTree/p:cxnSp/p:nvCxnSpPr/p:cNvCxnSpPr/a:stCxn",
+"idx", "0");
+
+xDocShRef->DoClose();
+}
+
 void SdOOXMLExportTest2::testTdf149697()
 {
 ::sd::DrawDocShellRef xDocShRef


[Libreoffice-commits] core.git: oox/source sd/qa

2022-10-24 Thread Sarper Akdemir (via logerrit)
 oox/source/drawingml/textcharacterproperties.cxx   |8 +++-
 sd/qa/unit/data/pptx/tdf151547-transparent-white-text.pptx |binary
 sd/qa/unit/import-tests2.cxx   |   23 +
 3 files changed, 30 insertions(+), 1 deletion(-)

New commits:
commit adfdd2bee4d1d59bf1ee372d9c242cf0b691e423
Author: Sarper Akdemir 
AuthorDate: Mon Oct 17 09:06:20 2022 +0300
Commit: Miklos Vajna 
CommitDate: Mon Oct 24 15:11:04 2022 +0200

tdf#151547 pptx import: workaround for COL_AUTO collision

In the current implementation of ::Color, it is not possible
to have fully transparent white text (since it collides with
COL_AUTO and gets interpreted as Automatic Color).

Implement a workaround for import of fully transparent white
text color so that it isn't interpreted as the magic value
COL_AUTO (i.e. instead of fully transparent #FF import
as fully transparent #FE).

Change-Id: Ide750093ef8a89f1424ddd8f4e9ee1e18209f2ad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141439
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/oox/source/drawingml/textcharacterproperties.cxx 
b/oox/source/drawingml/textcharacterproperties.cxx
index c38906308ddd..3bc65ec1bb3d 100644
--- a/oox/source/drawingml/textcharacterproperties.cxx
+++ b/oox/source/drawingml/textcharacterproperties.cxx
@@ -142,7 +142,13 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& 
rPropMap, const XmlFil
 
 if (aColor.hasTransparency())
 {
-rPropMap.setProperty(PROP_CharTransparence, 
aColor.getTransparency());
+const auto nTransparency = aColor.getTransparency();
+rPropMap.setProperty(PROP_CharTransparence, nTransparency);
+
+// WORKAROUND: Fully transparent white has the same value as 
COL_AUTO, avoid collision
+if (nTransparency == 100
+&& aColor.getColor(rFilter.getGraphicHelper()).GetRGBColor() 
== COL_AUTO.GetRGBColor())
+rPropMap.setProperty(PROP_CharColor, 
::Color(ColorTransparency, 0xFFFE));
 }
 }
 
diff --git a/sd/qa/unit/data/pptx/tdf151547-transparent-white-text.pptx 
b/sd/qa/unit/data/pptx/tdf151547-transparent-white-text.pptx
new file mode 100644
index ..1bb723c2afe0
Binary files /dev/null and 
b/sd/qa/unit/data/pptx/tdf151547-transparent-white-text.pptx differ
diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx
index bf4939c39365..b95f2e3197e6 100644
--- a/sd/qa/unit/import-tests2.cxx
+++ b/sd/qa/unit/import-tests2.cxx
@@ -142,6 +142,7 @@ public:
 void testCropToZero();
 void testTdf144092TableHeight();
 void testTdf89928BlackWhiteThreshold();
+void testTdf151547TransparentWhiteText();
 
 CPPUNIT_TEST_SUITE(SdImportTest2);
 
@@ -217,6 +218,7 @@ public:
 CPPUNIT_TEST(testCropToZero);
 CPPUNIT_TEST(testTdf144092TableHeight);
 CPPUNIT_TEST(testTdf89928BlackWhiteThreshold);
+CPPUNIT_TEST(testTdf151547TransparentWhiteText);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -2166,6 +2168,27 @@ void SdImportTest2::testTdf89928BlackWhiteThreshold()
 xDocShRef->DoClose();
 }
 
+void SdImportTest2::testTdf151547TransparentWhiteText()
+{
+sd::DrawDocShellRef xDocShRef = loadURL(
+
m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf151547-transparent-white-text.pptx"),
+PPTX);
+
+uno::Reference xShape(getShapeFromPage(0, 0, 
xDocShRef));
+uno::Reference xParagraph(getParagraphFromShape(0, 
xShape));
+uno::Reference xRun(getRunFromParagraph(0, xParagraph));
+uno::Reference xPropSet(xRun, uno::UNO_QUERY_THROW);
+
+Color nCharColor;
+xPropSet->getPropertyValue("CharColor") >>= nCharColor;
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: Color: R:255 G:255 B:254 A:255
+// - Actual  : Color: R:255 G:255 B:255 A:255
+// i.e. fully transparent white text color was interpreted as COL_AUTO
+CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency, 0xFFFE), nCharColor);
+xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest2);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


[Libreoffice-commits] core.git: oox/source sd/qa

2022-09-20 Thread Sarper Akdemir (via logerrit)
 oox/source/export/drawingml.cxx|   17 +++
 sd/qa/unit/data/odp/tdf94122_autocolor.odp |binary
 sd/qa/unit/export-tests-ooxml3.cxx |   42 +
 3 files changed, 59 insertions(+)

New commits:
commit 79ea27ec4418b82af5ba2187ae59cd9c0874060b
Author: Sarper Akdemir 
AuthorDate: Fri Sep 16 03:46:45 2022 +0300
Commit: Miklos Vajna 
CommitDate: Tue Sep 20 08:23:01 2022 +0200

tdf#94122 pptx export: fix automatic text color export

MS Powerpoint doesn't have automatic colors unlike Word or Excel.

Therefore on export the automatic text color should be first resolved
and then exported.

Change-Id: Ied2c3a4235da403350d8518a3414ff6a372b57a8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140059
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 85e73eb35c85..387bbf5c8d6d 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2299,6 +2299,23 @@ void DrawingML::WriteRunProperties( const Reference< 
XPropertySet >& rRun, bool
 WriteSolidFill(color, nTransparency);
 }
 }
+else if (GetDocumentType() == DOCUMENT_PPTX)
+{
+// Resolve COL_AUTO for PPTX since MS Powerpoint doesn't have 
automatic colors.
+bool bIsTextBackgroundDark = mbIsBackgroundDark;
+if (rXShapePropSet.is() && GetProperty(rXShapePropSet, 
"FillStyle")
+&& mAny.get() != FillStyle_NONE
+&& GetProperty(rXShapePropSet, "FillColor"))
+{
+::Color aShapeFillColor(ColorTransparency, 
mAny.get());
+bIsTextBackgroundDark = aShapeFillColor.IsDark();
+}
+
+if (bIsTextBackgroundDark)
+WriteSolidFill(COL_WHITE);
+else
+WriteSolidFill(COL_BLACK);
+}
 }
 }
 
diff --git a/sd/qa/unit/data/odp/tdf94122_autocolor.odp 
b/sd/qa/unit/data/odp/tdf94122_autocolor.odp
new file mode 100644
index ..921533cbead6
Binary files /dev/null and b/sd/qa/unit/data/odp/tdf94122_autocolor.odp differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index dd79bb47f6a7..c12a1f0ec4bd 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -121,6 +121,7 @@ public:
 void testTdf144092_emptyShapeTextProps();
 void testTdf149551_tbrl90();
 void testTdf149551_btlr();
+void testTdf94122_autoColor();
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest3);
 
@@ -207,6 +208,7 @@ public:
 CPPUNIT_TEST(testTdf144092_emptyShapeTextProps);
 CPPUNIT_TEST(testTdf149551_tbrl90);
 CPPUNIT_TEST(testTdf149551_btlr);
+CPPUNIT_TEST(testTdf94122_autoColor);
 CPPUNIT_TEST_SUITE_END();
 
 virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override
@@ -2218,6 +2220,46 @@ void SdOOXMLExportTest3::testTdf149551_btlr()
 xDocShRef->DoClose();
 }
 
+void SdOOXMLExportTest3::testTdf94122_autoColor()
+{
+// Document contains three pages, with different scenarios for automatic
+// color export to pptx.
+// - First page: Page background light, automatic colored text on a 
FillType_NONE shape
+// - Second page: Page background dark, automatic colored text on a 
FillType_NONE shape
+// - Third page: Page background light, automatic colored text on a dark 
colored fill
+//   and another automatic colored text on a light colored fill
+::sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/odp/tdf94122_autocolor.odp"),
 ODP);
+
+utl::TempFile tempFile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+xDocShRef->DoClose();
+
+// Without the accompanying fix in place, these tests would have failed 
with:
+// - Expected: 1
+// - Actual  : 0
+// - In ..., XPath 
'/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:srgbClr' 
number of nodes is incorrect
+// i.e. automatic color wasn't resolved & exported
+
+xmlDocUniquePtr pXmlDocContent1 = parseExport(tempFile, 
"ppt/slides/slide1.xml");
+assertXPath(pXmlDocContent1,
+
"/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:srgbClr", 
"val",
+"00");
+
+xmlDocUniquePtr pXmlDocContent2 = parseExport(tempFile, 
"ppt/slides/slide2.xml");
+assertXPath(pXmlDocContent2,
+
"/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:srgbClr", 
"val",
+"ff");
+
+xmlDocUniquePtr pXmlDocContent3 = parseExport(tempFile, 
"ppt/slides/slide3.xml");
+assertXPath(pXmlDocContent3,
+
"/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:srgbClr",
+"val", 

[Libreoffice-commits] core.git: oox/source sd/qa

2022-08-31 Thread Sarper Akdemir (via logerrit)
 oox/source/export/drawingml.cxx |   18 +++
 oox/source/export/shapes.cxx|   11 +++-
 sd/qa/unit/data/pptx/tdf144092-emptyShapeTextProps.pptx |binary
 sd/qa/unit/data/xml/tdf90338_0.xml  |2 
 sd/qa/unit/data/xml/tdf92001_0.xml  |2 
 sd/qa/unit/export-tests-ooxml3.cxx  |   40 
 6 files changed, 68 insertions(+), 5 deletions(-)

New commits:
commit aebd3c4a7def4476f34e171fce395d6ba70e3e1e
Author: Sarper Akdemir 
AuthorDate: Sun Aug 28 09:17:24 2022 +0300
Commit: Miklos Vajna 
CommitDate: Wed Aug 31 13:36:10 2022 +0200

tdf#144092 pptx export: export endParaRPr for empty shape & cells

Alters ShapeExport::WriteTextBox so that when it is called with an empty
text (on PPTX export) an attempt to export empty text's char properties
(stored in the Shape or Cell's properties directly) made on
ShapeExport::WriteText.

These properties are exported into endParaRPr.

Implementing this caused some tests that contain connector shapes fail
with XML schema validation errors, therefore disabled export of txBody
inside cxnSp tags.

Also adds a unit test that checks roundtrip of empty shape or cell's
endParaRPr.

Change-Id: I3e3feda802f42560fa7fecc9c0b1afe73a900a84
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138960
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 2a536b809220..51ac5f660237 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -3781,6 +3781,24 @@ void DrawingML::WriteText(const Reference& 
rXIface, bool bBodyPr, bo
 sal_Int32 nCharHeight = -1;
 bool bFirstParagraph = true;
 
+// tdf#144092 For shapes without text: Export run properties (into
+// endParaRPr) from the shape's propset instead of the paragraph's.
+if(xXText->getString().isEmpty() && enumeration->hasMoreElements())
+{
+Any aAny (enumeration->nextElement());
+Reference xParagraph;
+if( aAny >>= xParagraph )
+{
+mpFS->startElementNS(XML_a, XML_p);
+WriteParagraphProperties(xParagraph, nCharHeight, XML_pPr);
+sal_Int16 nDummy = -1;
+WriteRunProperties(rXPropSet, false, XML_endParaRPr, false,
+   bOverridingCharHeight, nCharHeight, nDummy, 
rXPropSet);
+mpFS->endElementNS(XML_a, XML_p);
+}
+return;
+}
+
 while( enumeration->hasMoreElements() )
 {
 Reference< XTextContent > paragraph;
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 79258d7d10e2..90e4ad86926f 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1797,8 +1797,12 @@ ShapeExport& ShapeExport::WriteConnectorShape( const 
Reference< XShape >& xShape
 WriteOutline( xShapeProps );
 pFS->endElementNS( mnXmlNamespace, XML_spPr );
 
-// write text
-WriteTextBox( xShape, mnXmlNamespace );
+// connector shape (cxnSp) cannot contain text (txBody) (according to 
schema)
+if( nShapeNode != XML_cxnSp )
+{
+// write text
+WriteTextBox( xShape, mnXmlNamespace );
+}
 
 pFS->endElementNS(mnXmlNamespace, nShapeNode);
 
@@ -2025,7 +2029,8 @@ ShapeExport& ShapeExport::WriteTextBox( const Reference< 
XInterface >& xIface, s
 }
 
 Reference< XText > xXText( xIface, UNO_QUERY );
-if( NonEmptyText( xIface ) && xXText.is() )
+if( (NonEmptyText( xIface ) || GetDocumentType() == DOCUMENT_PPTX)
+&& xXText.is() )
 {
 FSHelperPtr pFS = GetFS();
 
diff --git a/sd/qa/unit/data/pptx/tdf144092-emptyShapeTextProps.pptx 
b/sd/qa/unit/data/pptx/tdf144092-emptyShapeTextProps.pptx
new file mode 100644
index ..5d75c87d52de
Binary files /dev/null and 
b/sd/qa/unit/data/pptx/tdf144092-emptyShapeTextProps.pptx differ
diff --git a/sd/qa/unit/data/xml/tdf90338_0.xml 
b/sd/qa/unit/data/xml/tdf90338_0.xml
index 8bff66067c28..741d6ca08071 100644
--- a/sd/qa/unit/data/xml/tdf90338_0.xml
+++ b/sd/qa/unit/data/xml/tdf90338_0.xml
@@ -1,6 +1,6 @@
 
 
- 
+ 
   
   
   
diff --git a/sd/qa/unit/data/xml/tdf92001_0.xml 
b/sd/qa/unit/data/xml/tdf92001_0.xml
index 08d9622583d3..d67952eb1fe5 100644
--- a/sd/qa/unit/data/xml/tdf92001_0.xml
+++ b/sd/qa/unit/data/xml/tdf92001_0.xml
@@ -1,6 +1,6 @@
 
 
- 
+ 
   
   
   
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index d20c56d71766..6d3026326b17 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -116,6 +117,7 @@ public:
 void testTdf74670();
 void testTdf109169_OctagonBevel();
 void testTdf109169_DiamondBevel();
+void 

[Libreoffice-commits] core.git: oox/source sd/qa

2022-08-29 Thread Sarper Akdemir (via logerrit)
 oox/source/drawingml/shape.cxx   |   11 +++
 oox/source/drawingml/table/tablecell.cxx |   19 +
 sd/qa/unit/data/xml/n762695_0.xml|6 -
 sd/qa/unit/data/xml/n762695_1.xml|   10 +--
 sd/qa/unit/data/xml/n819614_0.xml|2 
 sd/qa/unit/data/xml/n820786_0.xml|  102 +++
 sd/qa/unit/data/xml/tdf109317_0.xml  |   12 +--
 7 files changed, 95 insertions(+), 67 deletions(-)

New commits:
commit 57f9b4b7d1ad164c56af12009ef1dafbc1be8369
Author: Sarper Akdemir 
AuthorDate: Mon Aug 15 21:35:52 2022 +0300
Commit: Miklos Vajna 
CommitDate: Mon Aug 29 09:42:34 2022 +0200

tdf#144092 pptx import: fix import of empty cell and shape text properties

For table cells and shapes without any text, text properties weren't
correctly imported. Both the master styles and properties defined in
the endParaRPr were ignored.

It appears the current implementation does attempt to import those in
TextParagraph::insertAt(...), after the attempt they end up in the
TextRange('s nodes) but they are ignored.

This commit implements a fix by: If the cell or shape has no text, the
text properties are also pushed into the shape or cell's propset
directly

Change-Id: Ie425b3e9a73937a2503e47322e25f37ed9a2a6be
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138651
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index bd4d773c15d0..3e81a1b95a27 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1800,6 +1800,17 @@ Reference< XShape > const & Shape::createAndInsert(
 aPropertySet.setAnyProperty(PROP_ParaAdjust, 
uno::Any(eAdjust));
 }
 }
+
+// tdf#144092 For empty textboxes push character styles &
+// endParaRPr into the Shape's properties
+if (rParagraphs.size() == 1 && 
pParagraph->getRuns().empty())
+{
+TextCharacterProperties aTextCharacterProps{ 
pParagraph->getCharacterStyle(
+aCharStyleProperties, *mpMasterTextListStyle,
+getTextBody()->getTextListStyle()) };
+
aTextCharacterProps.assignUsed(pParagraph->getEndProperties());
+aTextCharacterProps.pushToPropSet(aPropertySet, 
rFilterBase);
+}
 }
 }
 }
diff --git a/oox/source/drawingml/table/tablecell.cxx 
b/oox/source/drawingml/table/tablecell.cxx
index d979fb54e63f..77b69b8e4e3e 100644
--- a/oox/source/drawingml/table/tablecell.cxx
+++ b/oox/source/drawingml/table/tablecell.cxx
@@ -22,6 +22,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -542,7 +544,8 @@ void TableCell::pushToXCell( const 
::oox::core::XmlFilterBase& rFilterBase, cons
 
 // TODO: phClr?
 aFillProperties.pushToPropMap( aPropMap, rFilterBase.getGraphicHelper() );
-PropertySet( xPropSet ).setProperties( aPropMap );
+PropertySet aPropSet{xPropSet};
+aPropSet.setProperties( aPropMap );
 
 if ( getVertToken() == XML_eaVert )
 {
@@ -551,6 +554,20 @@ void TableCell::pushToXCell( const 
::oox::core::XmlFilterBase& rFilterBase, cons
 
 getTextBody()->insertAt( rFilterBase, xText, xAt, aTextStyleProps, 
pMasterTextListStyle );
 
+// tdf#144092 For empty cells push character styles & endParaRPr to the 
Cell's properties
+const TextParagraphVector& rParagraphs = getTextBody()->getParagraphs();
+if (rParagraphs.size() == 1)
+{
+const auto pFirstParagraph = rParagraphs.at(0);
+if (pFirstParagraph->getRuns().empty())
+{
+TextCharacterProperties aTextCharacterProps{ 
pFirstParagraph->getCharacterStyle(
+aTextStyleProps, *pMasterTextListStyle, 
getTextBody()->getTextListStyle()) };
+
aTextCharacterProps.assignUsed(pFirstParagraph->getEndProperties());
+aTextCharacterProps.pushToPropSet(aPropSet, rFilterBase);
+}
+}
+
 if (getVertToken() == XML_vert)
 xPropSet->setPropertyValue("RotateAngle", Any(short(27000)));
 else if (getVertToken() == XML_vert270)
diff --git a/sd/qa/unit/data/xml/n762695_0.xml 
b/sd/qa/unit/data/xml/n762695_0.xml
index 02b3074e92f1..ae755e644de7 100644
--- a/sd/qa/unit/data/xml/n762695_0.xml
+++ b/sd/qa/unit/data/xml/n762695_0.xml
@@ -1,6 +1,6 @@
 
 
- 
+ 
   
   
   
@@ -84,7 +84,7 @@

   
  
- 
+ 
   
   
   
@@ -161,7 +161,7 @@

   
  
- 
+ 
   
   
   
diff --git a/sd/qa/unit/data/xml/n762695_1.xml 
b/sd/qa/unit/data/xml/n762695_1.xml
index f0798923fed9..a43924138f45 100644
--- a/sd/qa/unit/data/xml/n762695_1.xml
+++ b/sd/qa/unit/data/xml/n762695_1.xml
@@ -1,6 +1,6 @@
 
 
- 
+ 
   
   
   
@@ -84,7 +84,7 @@

   
  

[Libreoffice-commits] core.git: oox/source sd/qa

2022-07-25 Thread Regina Henschel (via logerrit)
 oox/source/drawingml/transform2dcontext.cxx   |   88 +++---
 sd/qa/unit/data/pptx/tdf132302_SmartArt_rightArrow.pptx   |binary
 sd/qa/unit/data/pptx/tdf135953_SmartArt_textposition.pptx |binary
 sd/qa/unit/import-tests-smartart.cxx  |   58 +
 4 files changed, 129 insertions(+), 17 deletions(-)

New commits:
commit 5df1bb4b1b222be00d25097660c4ee33542896ea
Author: Regina Henschel 
AuthorDate: Sun Jul 24 01:23:32 2022 +0200
Commit: Regina Henschel 
CommitDate: Mon Jul 25 23:07:28 2022 +0200

tdf#135953 move txXfrm to compensate TextRotateAngle

The text rectangle specified by the txXfrm element rotates around its
center. We not directly use this rectangle but we use the text area
rectangle of the preset geometry and crop it by setting distances so,
that the result equals the txXfrm rectangle. But the text area
rectangle still rotates at its original center. So we shift the txXfrm
rectangle so, that it would be at it original place, when rotated with
TextRotateAngle. We then can use the shifted one to calculate the
needed distance values.

This patch contains the calculation of the text area rectangle for
type 'rightArrow' in addition. That fixes tdf#132302.

Change-Id: I59d9aecaaa7ce2ef4502651088ff9576b90873f7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137396
Tested-by: Jenkins
Reviewed-by: Regina Henschel 

diff --git a/oox/source/drawingml/transform2dcontext.cxx 
b/oox/source/drawingml/transform2dcontext.cxx
index 4c98db7592b5..da4ad10a168b 100644
--- a/oox/source/drawingml/transform2dcontext.cxx
+++ b/oox/source/drawingml/transform2dcontext.cxx
@@ -20,10 +20,14 @@
 #include 
 
 #include 
-#include 
-#include 
+
+#include 
+#include 
+#include 
 #include 
 #include 
+#include 
+#include 
 #include 
 
 #include 
@@ -190,7 +194,7 @@ bool ConstructPresetTextRectangle(Shape& rShape, 
awt::Rectangle& rRect)
 return false;
 double fMaxAdj = 5.0 * nWidth / std::min(nWidth, nHeight);
 fAdj = std::clamp(fAdj, 0, fMaxAdj);
-double fFactor = fAdj/fMaxAdj/6.0 + 1.0/12.0;
+double fFactor = fAdj / fMaxAdj / 6.0 + 1.0 / 12.0;
 sal_Int32 nTextLeft = nWidth * fFactor;
 sal_Int32 nTextTop = nHeight * fFactor;
 rRect.X = rShape.getPosition().X + nTextLeft;
@@ -215,15 +219,51 @@ bool ConstructPresetTextRectangle(Shape& rShape, 
awt::Rectangle& rRect)
 rRect.Height = nHeight;
 return true;
 }
+case XML_rightArrow:
+{
+// The identifiers here reflect the guides name value in 
presetShapeDefinitions.xml
+sal_Int32 nWidth = rShape.getSize().Width;
+sal_Int32 nHeight = rShape.getSize().Height;
+if (nWidth == 0 || nHeight == 0)
+return false;
+double a1(5.0);
+double a2(5.0);
+auto aAdjGdList = 
rShape.getCustomShapeProperties()->getAdjustmentGuideList();
+if (aAdjGdList.size() == 2)
+{
+a1 = aAdjGdList[0].maFormula.toDouble();
+a2 = aAdjGdList[1].maFormula.toDouble();
+a1 = std::clamp(a1, 0, 10);
+}
+double maxAdj2 = 10.0 * nWidth / std::min(nWidth, nHeight);
+a2 = std::clamp(a2, 0, maxAdj2);
+double dx1 = std::min(nWidth, nHeight) * a2 / 10.0;
+double x1 = nWidth - dx1;
+double dy1 = nHeight * a1 / 20.0;
+double y1 = nHeight / 2.0 - dy1; // top
+double y2 = nHeight / 2.0 + dy1; // bottom
+double dx2 = y1 * dx1 / (nHeight / 2.0);
+double x2 = x1 + dx2; // right
+rRect.X = rShape.getPosition().X; // left = 0
+rRect.Y = rShape.getPosition().Y + y1;
+rRect.Width = x2;
+rRect.Height = y2 - y1;
+return true;
+}
 default:
 return false;
 }
 }
+
+basegfx::B2DPoint getCenter(const awt::Rectangle& rRect)
+{
+return basegfx::B2DPoint(rRect.X + rRect.Width / 2.0, rRect.Y + 
rRect.Height / 2.0);
 }
+} // end namespace
 
 ContextHandlerRef Transform2DContext::onCreateContext( sal_Int32 
aElementToken, const AttributeList& rAttribs )
 {
-if( mbtxXfrm )
+if (mbtxXfrm)
 {
 // The child elements  and  of a  element 
describe the position and
 // size of the text area rectangle. We cannot change the text area 
rectangle directly, because
@@ -232,7 +272,7 @@ ContextHandlerRef Transform2DContext::onCreateContext( 
sal_Int32 aElementToken,
 // and used in TextBodyProperties::pushTextDistances().
 awt::Rectangle aPresetTextRectangle;
 if (!ConstructPresetTextRectangle(mrShape, aPresetTextRectangle))
-return nullptr; // faulty shape or corrections from txXfrm not 
needed.
+return nullptr; 

[Libreoffice-commits] core.git: oox/source sd/qa

2022-07-21 Thread Regina Henschel (via logerrit)
 oox/source/drawingml/transform2dcontext.cxx |   16 
 sd/qa/unit/data/pptx/tdf145528_SmartArt_Matrix.pptx |binary
 sd/qa/unit/import-tests-smartart.cxx|   36 
 3 files changed, 52 insertions(+)

New commits:
commit c6965c5bcc95430c2a2d01051791d23f2c2f5a5b
Author: Regina Henschel 
AuthorDate: Thu Jul 21 10:51:47 2022 +0200
Commit: Regina Henschel 
CommitDate: Thu Jul 21 12:41:01 2022 +0200

tdf#145528 add round1Rect to SmartArt text area corrections

Some SmartArt types use text area rectangles different from defaults.
The new rectangle is available in element . This patch adds the
needed corrections for type round1Rect. It is four times used in
SmartArt 'Titled Matrix' with rotations 0deg, 90deg, 180deg and 270deg.

Change-Id: I8c82b446a982ad93026e976b2a47d509b858858d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137287
Tested-by: Jenkins
Reviewed-by: Regina Henschel 

diff --git a/oox/source/drawingml/transform2dcontext.cxx 
b/oox/source/drawingml/transform2dcontext.cxx
index 446acf4ef07b..ade77ad0e4fa 100644
--- a/oox/source/drawingml/transform2dcontext.cxx
+++ b/oox/source/drawingml/transform2dcontext.cxx
@@ -199,6 +199,22 @@ bool ConstructPresetTextRectangle(Shape& rShape, 
awt::Rectangle& rRect)
 rRect.Height = nHeight - 2 * nTextTop;
 return true;
 }
+case XML_round1Rect:
+{
+sal_Int32 nWidth = rShape.getSize().Width;
+sal_Int32 nHeight = rShape.getSize().Height;
+if (nWidth == 0 || nHeight == 0)
+return false;
+auto aAdjGdList = 
rShape.getCustomShapeProperties()->getAdjustmentGuideList();
+double fAdj = aAdjGdList.empty() ? 16667.0 : 
aAdjGdList[0].maFormula.toDouble();
+std::clamp(fAdj, 0.0, 5.0);
+double fDx = std::min(nWidth, nHeight) * fAdj / 10.0 * 0.29289;
+rRect.X = rShape.getPosition().X;
+rRect.Y = rShape.getPosition().Y;
+rRect.Width = nWidth - fDx;
+rRect.Height = nHeight;
+return true;
+}
 default:
 return false;
 }
diff --git a/sd/qa/unit/data/pptx/tdf145528_SmartArt_Matrix.pptx 
b/sd/qa/unit/data/pptx/tdf145528_SmartArt_Matrix.pptx
new file mode 100644
index ..b48cc223cf0e
Binary files /dev/null and 
b/sd/qa/unit/data/pptx/tdf145528_SmartArt_Matrix.pptx differ
diff --git a/sd/qa/unit/import-tests-smartart.cxx 
b/sd/qa/unit/import-tests-smartart.cxx
index 8c28518c3b70..1d2728b5bee4 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -124,6 +124,7 @@ public:
 void testTdf149551Pyramid();
 void testTdf149551Venn();
 void testTdf149551Gear();
+void testTdf145528Matrix();
 
 CPPUNIT_TEST_SUITE(SdImportTestSmartArt);
 
@@ -183,6 +184,7 @@ public:
 CPPUNIT_TEST(testTdf149551Pyramid);
 CPPUNIT_TEST(testTdf149551Venn);
 CPPUNIT_TEST(testTdf149551Gear);
+CPPUNIT_TEST(testTdf145528Matrix);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -1950,6 +1952,40 @@ void SdImportTestSmartArt::testTdf149551Gear()
 xDocShRef->DoClose();
 }
 
+void SdImportTestSmartArt::testTdf145528Matrix()
+{
+// The file contains a diagram of type "Titled Matrix". Such is build from 
shapes of type
+// 'round1Rect'.
+sd::DrawDocShellRef xDocShRef = loadURL(
+
m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf145528_SmartArt_Matrix.pptx"),
 PPTX);
+uno::Reference xGroup(getShapeFromPage(0, 0, xDocShRef), 
uno::UNO_QUERY);
+// expected values
+sal_Int32 nLeft[]{ 4001, 12001, 12001, 18501 };
+sal_Int32 nTop[]{ , 1999, 12499, 5999 };
+// nWidth = 10292, nHeight = 4499
+// Without the fix in place the values were
+// nLeft {2001, 12001, 12001, 22001}
+// nTop {7999. 1999, 13999, 7999}
+// nWidth {6000, 1, 1, 6000}
+// nHeight {1, 6000, 6000, 1}
+tools::Rectangle aTextRect;
+for (auto i : { 1, 2, 3, 4 }) // shape at index 0 is the background shape
+{
+uno::Reference xShape = getChildShape(xGroup, i);
+CPPUNIT_ASSERT(xShape.is());
+auto pCustomShape
+= 
dynamic_cast(SdrObject::getSdrObjectFromXShape(xShape));
+CPPUNIT_ASSERT(pCustomShape);
+pCustomShape->TakeTextAnchorRect(aTextRect);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(nLeft[i - 1], 
sal_Int32(aTextRect.Left()), 4);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(nTop[i - 1], sal_Int32(aTextRect.Top()), 
4);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(10293), 
sal_Int32(aTextRect.GetWidth()), 4);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(4500), 
sal_Int32(aTextRect.GetHeight()), 4);
+}
+
+xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTestSmartArt);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


[Libreoffice-commits] core.git: oox/source sd/qa

2022-06-27 Thread Mike Kaganski (via logerrit)
 oox/source/drawingml/fillproperties.cxx |   12 
 sd/qa/unit/data/pptx/croppedTo0.pptx|binary
 sd/qa/unit/import-tests2.cxx|1 +
 3 files changed, 9 insertions(+), 4 deletions(-)

New commits:
commit 2d9f3c066a065d6aa98f1e594dcf8a091fec2bde
Author: Mike Kaganski 
AuthorDate: Mon Jun 27 15:29:25 2022 +0300
Commit: Caolán McNamara 
CommitDate: Mon Jun 27 18:57:23 2022 +0200

Integer division could cancel small values of wrong sign

... as seen at some documents where the values are like -1. There
the checks in pushToPropMap may pass (the division result would be 0),
but the original small negative values would fail the asserts that
were introduced in commit 5772cef244dbee5834efbc693bc714d89ae6301d
  Author Mike Kaganski 
  Date   Wed Jun 15 18:33:38 2022 +0300
tdf#134210: Reimplement cropping from srcRect and fillRect

Change-Id: I114588862b5cfd2b2e4491424430cc139bdbaae9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136492
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/oox/source/drawingml/fillproperties.cxx 
b/oox/source/drawingml/fillproperties.cxx
index 11f42457bc8d..f7dc16bf231b 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -97,8 +97,10 @@ Quotients getQuotients(geometry::IntegerRectangle2D 
aRelRect, double hDiv, doubl
 // ECMA-376 Part 1 20.1.8.55 srcRect (Source Rectangle)
 std::optional CropQuotientsFromSrcRect(geometry::IntegerRectangle2D 
aSrcRect)
 {
-// Currently the following precondition is guaranteed in 
GraphicProperties::pushToPropMap
-assert(aSrcRect.X1 >= 0 && aSrcRect.X2 >= 0 && aSrcRect.Y1 >= 0 && 
aSrcRect.Y2 >= 0);
+aSrcRect.X1 = std::max(aSrcRect.X1, sal_Int32(0));
+aSrcRect.X2 = std::max(aSrcRect.X2, sal_Int32(0));
+aSrcRect.Y1 = std::max(aSrcRect.Y1, sal_Int32(0));
+aSrcRect.Y2 = std::max(aSrcRect.Y2, sal_Int32(0));
 if (aSrcRect.X1 + aSrcRect.X2 >= 100'000 || aSrcRect.Y1 + aSrcRect.Y2 >= 
100'000)
 return {}; // Cropped everything
 return getQuotients(aSrcRect, 100'000.0, 100'000.0);
@@ -107,8 +109,10 @@ std::optional 
CropQuotientsFromSrcRect(geometry::IntegerRectangle2D a
 // ECMA-376 Part 1 20.1.8.30 fillRect (Fill Rectangle)
 std::optional 
CropQuotientsFromFillRect(geometry::IntegerRectangle2D aFillRect)
 {
-// Currently the following precondition is guaranteed in 
FillProperties::pushToPropMap
-assert(aFillRect.X1 <= 0 && aFillRect.X2 <= 0 && aFillRect.Y1 <= 0 && 
aFillRect.Y2 <= 0);
+aFillRect.X1 = std::min(aFillRect.X1, sal_Int32(0));
+aFillRect.X2 = std::min(aFillRect.X2, sal_Int32(0));
+aFillRect.Y1 = std::min(aFillRect.Y1, sal_Int32(0));
+aFillRect.Y2 = std::min(aFillRect.Y2, sal_Int32(0));
 // Negative divisor and negative relative offset give positive value 
wanted in lclCropGraphic
 return getQuotients(aFillRect, -100'000.0 + aFillRect.X1 + aFillRect.X2,
 -100'000.0 + aFillRect.Y1 + aFillRect.Y2);
diff --git a/sd/qa/unit/data/pptx/croppedTo0.pptx 
b/sd/qa/unit/data/pptx/croppedTo0.pptx
index fecf53559b1f..081661f48601 100644
Binary files a/sd/qa/unit/data/pptx/croppedTo0.pptx and 
b/sd/qa/unit/data/pptx/croppedTo0.pptx differ
diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx
index 7bf052ca0bdc..33bbcca615b7 100644
--- a/sd/qa/unit/import-tests2.cxx
+++ b/sd/qa/unit/import-tests2.cxx
@@ -2056,6 +2056,7 @@ void SdImportTest2::testDefaultTabStop()
 void SdImportTest2::testCropToZero()
 {
 // Must not crash because of division by zero
+// Also must not fail assertions because of passing negative value to 
CropQuotientsFromSrcRect
 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/croppedTo0.pptx"), 
PPTX);
 }
 


[Libreoffice-commits] core.git: oox/source sd/qa

2022-06-24 Thread Tibor Nagy (via logerrit)
 oox/source/export/drawingml.cxx|8 +++-
 sd/qa/unit/data/odp/tdf149311.odp  |binary
 sd/qa/unit/export-tests-ooxml1.cxx |   16 
 3 files changed, 23 insertions(+), 1 deletion(-)

New commits:
commit a761a51d9db3a2771ca9fd6ab233c513aa5d8ecf
Author: Tibor Nagy 
AuthorDate: Wed Jun 1 18:05:03 2022 +0200
Commit: László Németh 
CommitDate: Fri Jun 24 11:18:24 2022 +0200

tdf#149311 PPTX export: fix internal hyperlink on texts

by converting "Slide [digits]" URLs to slide[digits].xml

See also commit 4142d728f003166ebe520bfdaf672505e585b807
"tdf#149314 PPTX import: fix internal hyperlink on texts".

Change-Id: I39e095c960b04e728b3e28fa0a657d37d9c71ba1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135250
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 8d16911311ec..fe6635dc23f2 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1984,7 +1984,7 @@ void DrawingML::WriteShapeTransformation( const 
Reference< XShape >& rXShape, sa
 bFlipHWrite, bFlipVWrite, ExportRotateClockwisify(nRotation + 
nCameraRotation), IsGroupShape( rXShape ));
 }
 
-static OUString lcl_GetTarget(const css::uno::Reference& 
xModel, std::u16string_view rURL)
+static OUString lcl_GetTarget(const css::uno::Reference& 
xModel, OUString& rURL)
 {
 Reference xDPS(xModel, uno::UNO_QUERY_THROW);
 Reference xDrawPages(xDPS->getDrawPages(), 
uno::UNO_SET_THROW);
@@ -2005,6 +2005,12 @@ static OUString lcl_GetTarget(const 
css::uno::Reference& xMo
 break;
 }
 }
+if (sTarget.isEmpty())
+{
+sal_Int32 nSplit = rURL.lastIndexOf(' ');
+if (nSplit > -1)
+sTarget = OUString::Concat("slide") + rURL.subView(nSplit + 1) + 
".xml";
+}
 
 return sTarget;
 }
diff --git a/sd/qa/unit/data/odp/tdf149311.odp 
b/sd/qa/unit/data/odp/tdf149311.odp
new file mode 100644
index ..2500ed5e7a51
Binary files /dev/null and b/sd/qa/unit/data/odp/tdf149311.odp differ
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx 
b/sd/qa/unit/export-tests-ooxml1.cxx
index 01d0e9b3336f..c5a2c2ebc7e8 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -48,6 +48,7 @@ using namespace css;
 class SdOOXMLExportTest1 : public SdModelTestBaseXML
 {
 public:
+void testTdf149311();
 void testTdf149128();
 void testTdf66228();
 void testTdf147919();
@@ -120,6 +121,7 @@ public:
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest1);
 
+CPPUNIT_TEST(testTdf149311);
 CPPUNIT_TEST(testTdf149128);
 CPPUNIT_TEST(testTdf66228);
 CPPUNIT_TEST(testTdf147919);
@@ -219,6 +221,20 @@ void checkFontAttributes( const SdrTextObj* pObj, 
ItemValue nVal, sal_uInt32 nId
 
 }
 
+void SdOOXMLExportTest1::testTdf149311()
+{
+sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf149311.odp"), 
ODP);
+utl::TempFile tempFile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+xDocShRef->DoClose();
+
+xmlDocUniquePtr pRelsDoc = parseExport(tempFile, 
"ppt/slides/_rels/slide1.xml.rels");
+
+assertXPath(pRelsDoc, "/rels:Relationships/rels:Relationship[@Id='rId1']", 
"Target",
+"slide2.xml");
+}
+
 void SdOOXMLExportTest1::testTdf149128()
 {
 sd::DrawDocShellRef xDocShRef


[Libreoffice-commits] core.git: oox/source sd/qa

2022-06-23 Thread Tibor Nagy (via logerrit)
 oox/source/export/shapes.cxx   |3 -
 sd/qa/unit/data/odp/tdf149126.odp  |binary
 sd/qa/unit/data/xml/tdf92001_0.xml |   32 +++-
 sd/qa/unit/export-tests-ooxml2.cxx |   59 -
 4 files changed, 51 insertions(+), 43 deletions(-)

New commits:
commit db39e5359d7f9b4e42c6101dd75bc5e8d809ad41
Author: Tibor Nagy 
AuthorDate: Fri Jun 3 15:32:50 2022 +0200
Commit: László Németh 
CommitDate: Thu Jun 23 16:02:58 2022 +0200

tdf#149126 fix export of PPTX preset shapes

Follow-up to commit 63cd67e5e18f01aca303131e148c80398a181a41
"tdf#92525 tdf#142398: fix export of simple custom shapes" and
commit 744e6c0b758fefe6011f09860b44f03ab70fbcfe
"tdf#147459 PPTX: add "glue points" to some basic shapes".

Thanks to Regina Henschel for the code pointer.

Change-Id: I378c2ba09fcffcaa4e5dcf74bfd19e9f704d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135361
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 305bc2e78f53..79691c338985 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -926,8 +926,7 @@ ShapeExport& ShapeExport::WriteCustomShape( const 
Reference< XShape >& xShape )
 bool bPresetWriteSuccessful = false;
 // Let the custom shapes what has name and preset information in OOXML, to 
be written
 // as preset ones with parameters. Try that with this converter class.
-if (!sShapeType.startsWith("ooxml") && sShapeType != "non-primitive"
-&& GetDocumentType() == DOCUMENT_DOCX && !mbUserShapes
+if (!sShapeType.startsWith("ooxml") && sShapeType != "non-primitive" && 
!mbUserShapes
 && xShape->getShapeType() == "com.sun.star.drawing.CustomShape"
 && !lcl_IsOnAllowlist(sShapeType))
 {
diff --git a/sd/qa/unit/data/odp/tdf149126.odp 
b/sd/qa/unit/data/odp/tdf149126.odp
new file mode 100644
index ..1d9c3c8c2318
Binary files /dev/null and b/sd/qa/unit/data/odp/tdf149126.odp differ
diff --git a/sd/qa/unit/data/xml/tdf92001_0.xml 
b/sd/qa/unit/data/xml/tdf92001_0.xml
index 1bacf2f2559c..08d9622583d3 100644
--- a/sd/qa/unit/data/xml/tdf92001_0.xml
+++ b/sd/qa/unit/data/xml/tdf92001_0.xml
@@ -15,7 +15,10 @@
   
   

-
+
+ 
+ 
+



@@ -27,31 +30,31 @@
   

 
-
+


-
-
+
+


-
+
 


-
-
+
+


-
-
+
+


-
-
+
+


 
-
+

   
  
@@ -63,11 +66,12 @@

   
  
- 
  
 

-   
+   
+   
+   

 

diff --git a/sd/qa/unit/export-tests-ooxml2.cxx 
b/sd/qa/unit/export-tests-ooxml2.cxx
index b9c1f437c64c..0029f882463b 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -70,6 +70,7 @@ static void assertMotionPath(std::u16string_view rStr1, 
std::u16string_view rStr
 class SdOOXMLExportTest2 : public SdModelTestBaseXML
 {
 public:
+void testTdf149126();
 void testTdf131905();
 void testTdf93883();
 void testTdf91378();
@@ -137,6 +138,7 @@ public:
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
 
+CPPUNIT_TEST(testTdf149126);
 CPPUNIT_TEST(testTdf131905);
 CPPUNIT_TEST(testTdf93883);
 CPPUNIT_TEST(testTdf91378);
@@ -210,6 +212,20 @@ public:
 }
 };
 
+void SdOOXMLExportTest2::testTdf149126()
+{
+::sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf149126.odp"), 
ODP);
+utl::TempFile tempFile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+
+xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, 
"ppt/slides/slide1.xml");
+assertXPath(pXmlDocContent, 
"/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:prstGeom", "prst",
+"triangle");
+
+xDocShRef->DoClose();
+}
+
 void SdOOXMLExportTest2::testTdf131905()
 {
 ::sd::DrawDocShellRef xDocShRef
@@ -661,7 +677,7 @@ void SdOOXMLExportTest2::testPresetShapesExport()
 "donut",
 "adj","val 9601",
 "bevel",
-"adj","val 42587",
+"adj","val 42592",
 "foldedCorner",
 "adj","val 10750",
 "verticalScroll",
@@ -692,9 +708,9 @@ void SdOOXMLExportTest2::testPresetShapesExport()
 "adj5","val -22375",
 "adj6","val -134550",
 "blockArc",
-"adj1","val 1302",
-"adj2","val 1938",
-"adj3","val 3773",
+"adj1","val 12975429",
+"adj2","val 19424571",
+"adj3","val 3770",
 };
 
 utl::TempFile tempFile;
@@ -720,9 +736,8 @@ void SdOOXMLExportTest2::testPresetShapesExport()
 
 void SdOOXMLExportTest2::testTdf92527()
 {
-// We draw a 

[Libreoffice-commits] core.git: oox/source sd/qa

2022-06-17 Thread Mike Kaganski (via logerrit)
 oox/source/drawingml/fillproperties.cxx |   92 +---
 sd/qa/unit/data/pptx/croppedTo0.pptx|binary
 sd/qa/unit/import-tests2.cxx|   10 +++
 3 files changed, 48 insertions(+), 54 deletions(-)

New commits:
commit 5772cef244dbee5834efbc693bc714d89ae6301d
Author: Mike Kaganski 
AuthorDate: Wed Jun 15 18:33:38 2022 +0300
Commit: Mike Kaganski 
CommitDate: Fri Jun 17 14:25:54 2022 +0200

tdf#134210: Reimplement cropping from srcRect and fillRect

This avoids the scaling after the crop, since scaling is performed
anyway when applying BitmapMode_STRETCH. This improves resulting
bitmap quality.

Also consider the "crop to zero" case (when the sum of cropped
parts is equal to 100%). In that case, just use an empty graphic
as the fill bitmap.

This makes the differences between srcRect and fillRect processing
explicit, simplifies the code, avoids extra rounding inaccuracies,
and takes care of the edge cases that were considered in commit
2859ec288f2c1323ea3123d82cb1684b349ff598
  Author Miklos Vajna 
  Date   Wed Jun 15 15:52:18 2022 +0200
oox: fix div by zero in lclCalculateCropPercentage()

The change in SdImportTest2::testTdf134210 is because we now don't
scale the cropped image. The previous value was an interpolated
color, while the new value is the actual color of pixel [0, 41] of
the original image.

Change-Id: I24fa9928cff32bcaa6a7b3e34def14700fddd7ca
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135917
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/oox/source/drawingml/fillproperties.cxx 
b/oox/source/drawingml/fillproperties.cxx
index 93fea51194ef..9270201920b3 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -88,67 +88,55 @@ Reference< XGraphic > 
lclRotateGraphic(uno::Reference const &
 return aReturnGraphic.GetXGraphic();
 }
 
-void lclCalculateCropPercentage(uno::Reference const & 
xGraphic, geometry::IntegerRectangle2D )
+using Quotients = std::tuple;
+Quotients getQuotients(geometry::IntegerRectangle2D aRelRect, double hDiv, 
double vDiv)
 {
-::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;
-if (nOrigWidth == 0)
-{
-nOrigWidth = 1;
-}
-sal_Int32 nOrigHeight = (nScaledHeight * (10 - aFillRect.Y1 - 
aFillRect.Y2)) / 10;
-if (nOrigHeight == 0)
-{
-nOrigHeight = 1;
-}
+return { aRelRect.X1 / hDiv, aRelRect.Y1 / vDiv, aRelRect.X2 / hDiv, 
aRelRect.Y2 / vDiv };
+}
 
-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;
+// ECMA-376 Part 1 20.1.8.55 srcRect (Source Rectangle)
+std::optional CropQuotientsFromSrcRect(geometry::IntegerRectangle2D 
aSrcRect)
+{
+// Currently the following precondition is guaranteed in 
GraphicProperties::pushToPropMap
+assert(aSrcRect.X1 >= 0 && aSrcRect.X2 >= 0 && aSrcRect.Y1 >= 0 && 
aSrcRect.Y2 >= 0);
+if (aSrcRect.X1 + aSrcRect.X2 >= 100'000 || aSrcRect.Y1 + aSrcRect.Y2 >= 
100'000)
+return {}; // Cropped everything
+return getQuotients(aSrcRect, 100'000.0, 100'000.0);
+}
 
-aFillRect.X1 = -nLeftPercentage;
-aFillRect.X2 = -nRightPercentage;
-aFillRect.Y1 = -nTopPercentage;
-aFillRect.Y2 = -nBottomPercentage;
+// ECMA-376 Part 1 20.1.8.30 fillRect (Fill Rectangle)
+std::optional 
CropQuotientsFromFillRect(geometry::IntegerRectangle2D aFillRect)
+{
+// Currently the following precondition is guaranteed in 
FillProperties::pushToPropMap
+assert(aFillRect.X1 <= 0 && aFillRect.X2 <= 0 && aFillRect.Y1 <= 0 && 
aFillRect.Y2 <= 0);
+// Negative divisor and negative relative offset give positive value 
wanted in lclCropGraphic
+return getQuotients(aFillRect, -100'000.0 + aFillRect.X1 + aFillRect.X2,
+-100'000.0 + aFillRect.Y1 + aFillRect.Y2);
 }
 
-// Crops a piece of the bitmap. Takes negative aFillRect values. Negative 
values means "crop",
-// positive values means "grow" bitmap with empty spaces. lclCropGraphic 
doesn't handle growing.
-Reference< XGraphic > lclCropGraphic(uno::Reference const & 
xGraphic, geometry::IntegerRectangle2D aFillRect)
+// Crops a piece of the bitmap. lclCropGraphic doesn't handle growing.
+Reference lclCropGraphic(uno::Reference const& 
xGraphic,
+   std::optional quotients)
 {
 

[Libreoffice-commits] core.git: oox/source sd/qa

2022-05-30 Thread Tibor Nagy (via logerrit)
 oox/source/export/shapes.cxx   |   13 +
 sd/qa/unit/data/odp/tdf149128.odp  |binary
 sd/qa/unit/export-tests-ooxml1.cxx |   17 +
 3 files changed, 26 insertions(+), 4 deletions(-)

New commits:
commit c3f73f75772d076dfb2ed0538e7d515503edc038
Author: Tibor Nagy 
AuthorDate: Wed May 25 12:29:10 2022 +0200
Commit: László Németh 
CommitDate: Mon May 30 12:48:03 2022 +0200

tdf#149128 PPTX export: fix  and  connector properties

to avoid of detaching connections between shapes,
when these connections were created in Impress.

Change-Id: I1bc90bb8a408546b303b70bcfb27d3549d5e72d3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134940
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 284daea2db21..9854c98a584e 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -818,10 +818,10 @@ ShapeExport& ShapeExport::WriteCustomShape( const 
Reference< XShape >& xShape )
 mAny >>= isVisible;
 }
 pFS->startElementNS( mnXmlNamespace, XML_nvSpPr );
-pFS->startElementNS( mnXmlNamespace, XML_cNvPr,
-XML_id, OString::number(GetNewShapeID(xShape)),
-XML_name, GetShapeName(xShape),
-XML_hidden, sax_fastparser::UseIf("1", !isVisible));
+pFS->startElementNS(
+mnXmlNamespace, XML_cNvPr, XML_id,
+OString::number(GetShapeID(xShape) == -1 ? GetNewShapeID(xShape) : 
GetShapeID(xShape)),
+XML_name, GetShapeName(xShape), XML_hidden, 
sax_fastparser::UseIf("1", !isVisible));
 
 if( GETA( URL ) )
 {
@@ -1745,6 +1745,11 @@ ShapeExport& ShapeExport::WriteConnectorShape( const 
Reference< XShape >& xShape
 XML_name, GetShapeName(xShape));
 // non visual connector shape drawing properties
 pFS->startElementNS(mnXmlNamespace, XML_cNvCxnSpPr);
+
+if (GetShapeID(rXShapeA) == -1)
+GetNewShapeID(rXShapeA);
+if (GetShapeID(rXShapeB) == -1)
+GetNewShapeID(rXShapeB);
 WriteConnectorConnections(aConnectorEntry, GetShapeID(rXShapeA), 
GetShapeID(rXShapeB));
 pFS->endElementNS(mnXmlNamespace, XML_cNvCxnSpPr);
 if (GetDocumentType() == DOCUMENT_PPTX)
diff --git a/sd/qa/unit/data/odp/tdf149128.odp 
b/sd/qa/unit/data/odp/tdf149128.odp
new file mode 100644
index ..0c26fdd6b3a7
Binary files /dev/null and b/sd/qa/unit/data/odp/tdf149128.odp differ
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx 
b/sd/qa/unit/export-tests-ooxml1.cxx
index 70c64d793084..01d0e9b3336f 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -48,6 +48,7 @@ using namespace css;
 class SdOOXMLExportTest1 : public SdModelTestBaseXML
 {
 public:
+void testTdf149128();
 void testTdf66228();
 void testTdf147919();
 void testTdf130165();
@@ -119,6 +120,7 @@ public:
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest1);
 
+CPPUNIT_TEST(testTdf149128);
 CPPUNIT_TEST(testTdf66228);
 CPPUNIT_TEST(testTdf147919);
 CPPUNIT_TEST(testTdf130165);
@@ -217,6 +219,21 @@ void checkFontAttributes( const SdrTextObj* pObj, 
ItemValue nVal, sal_uInt32 nId
 
 }
 
+void SdOOXMLExportTest1::testTdf149128()
+{
+sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf149128.odp"), 
ODP);
+utl::TempFile tempFile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+xDocShRef->DoClose();
+
+xmlDocUniquePtr pXmlDoc = parseExport(tempFile, "ppt/slides/slide1.xml");
+assertXPath(pXmlDoc, 
"/p:sld/p:cSld/p:spTree/p:cxnSp/p:nvCxnSpPr/p:cNvCxnSpPr/a:stCxn", "id", "42");
+assertXPath(pXmlDoc, 
"/p:sld/p:cSld/p:spTree/p:cxnSp/p:nvCxnSpPr/p:cNvCxnSpPr/a:stCxn", "idx", "0");
+assertXPath(pXmlDoc, 
"/p:sld/p:cSld/p:spTree/p:cxnSp/p:nvCxnSpPr/p:cNvCxnSpPr/a:endCxn", "id", "43");
+assertXPath(pXmlDoc, 
"/p:sld/p:cSld/p:spTree/p:cxnSp/p:nvCxnSpPr/p:cNvCxnSpPr/a:endCxn", "idx", "2");
+}
+
 void SdOOXMLExportTest1::testTdf66228()
 {
 sd::DrawDocShellRef xDocShRef


[Libreoffice-commits] core.git: oox/source sd/qa

2022-05-27 Thread Tibor Nagy (via logerrit)
 oox/source/ppt/slidepersist.cxx |8 
 sd/qa/unit/data/pptx/tdf149124.pptx |binary
 sd/qa/unit/import-tests.cxx |   18 ++
 3 files changed, 26 insertions(+)

New commits:
commit 25e747ed39a3742d26c1128b6823679de279d5df
Author: Tibor Nagy 
AuthorDate: Wed May 25 15:52:55 2022 +0200
Commit: László Németh 
CommitDate: Fri May 27 09:59:59 2022 +0200

tdf#149124 PPTX import: fix broken connectors in grouped shapes

Previously connector lines of grouped shapes were detached
after the import losing the original layout (without
ungrouping and moving the shapes).

Change-Id: I660629d9d1c2cb0ab68de275ca5406f4c48e9145
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134943
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx
index 81a0fd7991a7..24ce2f9da464 100644
--- a/oox/source/ppt/slidepersist.cxx
+++ b/oox/source/ppt/slidepersist.cxx
@@ -150,6 +150,14 @@ void SlidePersist::createXShapes( XmlFilterBase& 
rFilterBase )
 pPPTShape->addShape( rFilterBase, *this, getTheme().get(), 
xShapes, aTransformation, () );
 if (pPPTShape->isConnectorShape())
 maConnectorShapeId.push_back(pPPTShape->getId());
+if (!pPPTShape->getChildren().empty())
+{
+for (size_t i = 0; i < pPPTShape->getChildren().size(); 
i++)
+{
+if (pPPTShape->getChildren()[i]->isConnectorShape())
+
maConnectorShapeId.push_back(pPPTShape->getChildren()[i]->getId());
+}
+}
 }
 else
 child->addShape( rFilterBase, getTheme().get(), xShapes, 
aTransformation, maShapesPtr->getFillProperties(), () );
diff --git a/sd/qa/unit/data/pptx/tdf149124.pptx 
b/sd/qa/unit/data/pptx/tdf149124.pptx
new file mode 100644
index ..9c43c43ce09b
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf149124.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 100c9e784875..9e60c8886dec 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -81,6 +81,7 @@ public:
 virtual void setUp() override;
 
 void testDocumentLayout();
+void testTdf149124();
 void testTdf89449();
 void testTdf147459();
 void testTdf146223();
@@ -149,6 +150,7 @@ public:
 CPPUNIT_TEST_SUITE(SdImportTest);
 
 CPPUNIT_TEST(testDocumentLayout);
+CPPUNIT_TEST(testTdf149124);
 CPPUNIT_TEST(testTdf89449);
 CPPUNIT_TEST(testTdf147459);
 CPPUNIT_TEST(testTdf146223);
@@ -295,6 +297,22 @@ void SdImportTest::testDocumentLayout()
 }
 }
 
+void SdImportTest::testTdf149124()
+{
+sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf149124.pptx"), 
PPTX);
+
+uno::Reference xGroupShape(getShapeFromPage(0, 0, 
xDocShRef), uno::UNO_QUERY_THROW);
+uno::Reference 
xStandardConnector(xGroupShape->getByIndex(2), uno::UNO_QUERY_THROW);
+
+sal_Int32 nStartGlueId = 
xStandardConnector->getPropertyValue("StartGluePointIndex").get();
+CPPUNIT_ASSERT_EQUAL(sal_Int32(2), nStartGlueId);
+sal_Int32 nEndGlueId = 
xStandardConnector->getPropertyValue("EndGluePointIndex").get();
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nEndGlueId);
+
+xDocShRef->DoClose();
+}
+
 void SdImportTest::testTdf89449()
 {
 sd::DrawDocShellRef xDocShRef


[Libreoffice-commits] core.git: oox/source sd/qa

2022-05-23 Thread Tibor Nagy (via logerrit)
 oox/source/export/shapes.cxx   |4 ++--
 sd/qa/unit/data/odp/tdf66228.odp   |binary
 sd/qa/unit/export-tests-ooxml1.cxx |   15 +++
 3 files changed, 17 insertions(+), 2 deletions(-)

New commits:
commit f4efaf455136c3a0db8dfd3f1afc0db827192147
Author: Tibor Nagy 
AuthorDate: Fri May 13 14:09:35 2022 +0200
Commit: László Németh 
CommitDate: Mon May 23 10:59:10 2022 +0200

tdf#66228 PPTX export: fix lost U-shaped connectors

which were replaced with straight connector lines.

The "Line Connector" has no equivalent in OOXML. So far it has
been saved as a "Straight connector". In most cases, the better
solution is to change it to "Standard connector", keeping
the original layout with U-shaped connectors.

Change-Id: I9d6b6174d0556ba2478c6a9837c500b3cc794c82
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134284
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index ed129784ba51..284daea2db21 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1662,12 +1662,12 @@ ShapeExport& ShapeExport::WriteConnectorShape( const 
Reference< XShape >& xShape
 case ConnectorType_CURVE:
 sGeometry = "curvedConnector";
 break;
+case ConnectorType_LINES:
 case ConnectorType_STANDARD:
 sGeometry = "bentConnector";
 break;
 default:
 case ConnectorType_LINE:
-case ConnectorType_LINES:
 sGeometry = "straightConnector1";
 break;
 }
@@ -1692,7 +1692,7 @@ ShapeExport& ShapeExport::WriteConnectorShape( const 
Reference< XShape >& xShape
 }
 EscherConnectorListEntry aConnectorEntry( xShape, aStartPoint, rXShapeA, 
aEndPoint, rXShapeB );
 
-if (eConnectorType == ConnectorType_CURVE || eConnectorType == 
ConnectorType_STANDARD)
+if (eConnectorType != ConnectorType_LINE)
 {
 tools::PolyPolygon aPolyPolygon = 
EscherPropertyContainer::GetPolyPolygon(xShape);
 if (aPolyPolygon.Count() > 0)
diff --git a/sd/qa/unit/data/odp/tdf66228.odp b/sd/qa/unit/data/odp/tdf66228.odp
new file mode 100644
index ..a34c6fc65270
Binary files /dev/null and b/sd/qa/unit/data/odp/tdf66228.odp differ
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx 
b/sd/qa/unit/export-tests-ooxml1.cxx
index a1dac4fbf63c..70c64d793084 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -48,6 +48,7 @@ using namespace css;
 class SdOOXMLExportTest1 : public SdModelTestBaseXML
 {
 public:
+void testTdf66228();
 void testTdf147919();
 void testTdf130165();
 void testTdf124781();
@@ -118,6 +119,7 @@ public:
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest1);
 
+CPPUNIT_TEST(testTdf66228);
 CPPUNIT_TEST(testTdf147919);
 CPPUNIT_TEST(testTdf130165);
 CPPUNIT_TEST(testTdf124781);
@@ -215,6 +217,19 @@ void checkFontAttributes( const SdrTextObj* pObj, 
ItemValue nVal, sal_uInt32 nId
 
 }
 
+void SdOOXMLExportTest1::testTdf66228()
+{
+sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf66228.odp"), ODP);
+utl::TempFile tempFile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+xDocShRef->DoClose();
+
+xmlDocUniquePtr pXmlDoc = parseExport(tempFile, "ppt/slides/slide1.xml");
+assertXPath(pXmlDoc, "/p:sld/p:cSld/p:spTree/p:cxnSp/p:spPr/a:prstGeom", 
"prst",
+"bentConnector3");
+}
+
 void SdOOXMLExportTest1::testTdf147919()
 {
 sd::DrawDocShellRef xDocShRef


[Libreoffice-commits] core.git: oox/source sd/qa

2022-05-10 Thread Tibor Nagy (via logerrit)
 oox/source/export/shapes.cxx   |  306 +
 sd/qa/unit/data/odp/tdf147919.odp  |binary
 sd/qa/unit/export-tests-ooxml1.cxx |   62 +++
 3 files changed, 340 insertions(+), 28 deletions(-)

New commits:
commit 4cc3a144ef2ecc019da42bb9b115267a18e9559f
Author: Tibor Nagy 
AuthorDate: Fri Apr 29 14:08:17 2022 +0200
Commit: László Németh 
CommitDate: Tue May 10 16:51:54 2022 +0200

tdf#147919 PPTX export: fix curved and bent connector shape

by calculating and exporting adjustment values to avoid
of connector lines with bad turns overlapping the
connected shapes.

Change-Id: I0441508f4fe98b3482e2955df5f41f2cfc2ffb4e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134109
Tested-by: Jenkins
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 3308d5ab4492..ed129784ba51 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1411,49 +1411,276 @@ void ShapeExport::WriteGraphicObjectShapePart( const 
Reference< XShape >& xShape
 pFS->endElementNS( mnXmlNamespace, XML_pic );
 }
 
+static void lcl_Rotate(sal_Int32 nAngle, Point center, awt::Point& pt)
+{
+sal_Int16 nCos, nSin;
+switch (nAngle)
+{
+case 90:
+nCos = 0;
+nSin = 1;
+break;
+case 180:
+nCos = -1;
+nSin = 0;
+break;
+case 270:
+nCos = 0;
+nSin = -1;
+break;
+default:
+return;
+}
+sal_Int32 x = pt.X - center.X();
+sal_Int32 y = pt.Y - center.Y();
+pt.X = center.X() + x * nCos - y * nSin;
+pt.Y = center.Y() + y * nCos + x * nSin;
+}
+
+static void lcl_FlipHFlipV(tools::Polygon aPoly, sal_Int32 nAngle, bool& 
rFlipH, bool& rFlipV)
+{
+Point aStart = aPoly[0];
+Point aEnd = aPoly[aPoly.GetSize() - 1];
+
+if (aStart.X() > aEnd.X() && aStart.Y() > aEnd.Y())
+{
+if (nAngle)
+{
+if (nAngle == 90)
+rFlipH = true;
+if (nAngle == 270)
+rFlipV = true;
+}
+else // 0°
+{
+rFlipH = true;
+rFlipV = true;
+}
+}
+
+if (aStart.X() < aEnd.X() && aStart.Y() < aEnd.Y())
+{
+if (nAngle)
+{
+if (nAngle != 270)
+{
+rFlipH = true;
+rFlipV = true;
+}
+else
+rFlipH = true;
+}
+}
+
+if (aStart.Y() < aEnd.Y() && aStart.X() > aEnd.X())
+{
+if (nAngle)
+{
+if (nAngle == 180)
+rFlipV = true;
+if (nAngle == 270)
+{
+rFlipV = true;
+rFlipH = true;
+}
+}
+else // 0°
+{
+rFlipH = true;
+}
+}
+
+if (aStart.Y() > aEnd.Y() && aStart.X() < aEnd.X())
+{
+if (nAngle)
+{
+if (nAngle == 90)
+{
+rFlipH = true;
+rFlipV = true;
+}
+if (nAngle == 180)
+rFlipH = true;
+}
+else // 0°
+rFlipV = true;
+}
+}
+
+static sal_Int32 lcl_GetAngle(tools::Polygon aPoly)
+{
+sal_Int32 nAngle;
+Point aStartPoint = aPoly[0];
+Point aEndPoint = aPoly[aPoly.GetSize() - 1];
+if (aStartPoint.X() == aPoly[1].X())
+{
+if ((aStartPoint.X() < aEndPoint.X() && aStartPoint.Y() > 
aEndPoint.Y())
+|| (aStartPoint.X() > aEndPoint.X() && aStartPoint.Y() < 
aEndPoint.Y()))
+{
+nAngle = 90;
+}
+else
+nAngle = 270;
+}
+else
+{
+if (aStartPoint.X() > aPoly[1].X())
+nAngle = 180;
+else
+nAngle = 0;
+}
+
+return nAngle;
+}
+
+// Adjust value decide the position, where the connector should turn.
+static void lcl_GetConnectorAdjustValue(const Reference& xShape, 
tools::Polygon aPoly,
+ConnectorType eConnectorType,
+std::vector>& rAvList)
+{
+sal_Int32 nAdjCount = 0;
+if (eConnectorType == ConnectorType_CURVE)
+{
+if (aPoly.GetSize() == 4)
+{
+if ((aPoly[0].X() == aPoly[1].X() && aPoly[2].X() == aPoly[3].X())
+|| (aPoly[0].Y() == aPoly[1].Y() && aPoly[2].Y() == 
aPoly[3].Y()))
+{
+nAdjCount = 1; // curvedConnector3
+}
+else
+nAdjCount = 0; // curvedConnector2
+}
+else if (aPoly.GetSize() > 4)
+{
+if ((aPoly[2].X() == aPoly[3].X() && aPoly[3].X() == aPoly[4].X())
+|| (aPoly[2].Y() == aPoly[3].Y() && aPoly[3].Y() == 
aPoly[4].Y()))
+{
+nAdjCount = 

[Libreoffice-commits] core.git: oox/source sd/qa

2022-05-07 Thread Stephan Bergmann (via logerrit)
 dev/null   |binary
 oox/source/export/shapes.cxx   |  306 +++--
 sd/qa/unit/export-tests-ooxml1.cxx |   62 ---
 3 files changed, 28 insertions(+), 340 deletions(-)

New commits:
commit 323df76698be1e554ba3342f56a812517a25437a
Author: Stephan Bergmann 
AuthorDate: Sat May 7 14:26:09 2022 +0200
Commit: Stephan Bergmann 
CommitDate: Sat May 7 15:40:49 2022 +0200

Revert "tdf#147919 PPTX export: fix curved and bent connector shape"

This reverts commit 1f8c6efbfea10997f188962d036f5c7db4c13f8a, as it caues

> warn:legacy.tools:12871:12871:tools/source/generic/poly.cxx:1581: 
Polygon::[]: nPos >= nPoints
> =
> ==12871==ERROR: AddressSanitizer: heap-buffer-overflow on address 
0x603000445080 at pc 0x7f6303ec7854 bp 0x7ffd23271600 sp 0x7ffd232715f8
> READ of size 8 at 0x603000445080 thread T0
> #0 0x7f6303ec7853 in Point::X() const /include/tools/gen.hxx:83:51
> #1 0x7f63045baaa1 in 
oox::drawingml::lcl_GetConnectorAdjustValue(com::sun::star::uno::Reference
 const&, tools::Polygon, com::sun::star::drawing::ConnectorType, 
std::__debug::vector, std::allocator > 
>&) /oox/source/export/shapes.cxx:1556:27
> #2 0x7f63045b731f in 
oox::drawingml::ShapeExport::WriteConnectorShape(com::sun::star::uno::Reference
 const&) /oox/source/export/shapes.cxx:1701:13
> #3 0x7f63045984e7 in 
oox::drawingml::ShapeExport::WriteShape(com::sun::star::uno::Reference
 const&) /oox/source/export/shapes.cxx:1956:5
> #4 0x7f62b399ad3b in 
oox::core::PowerPointExport::WriteShapeTree(std::shared_ptr
 const&, PageType, bool) /sd/source/filter/eppt/pptx-epptooxml.cxx:1658:22

during CppunitTest_sd_export_tests-ooxml3
CPPUNIT_TEST_NAME=SdOOXMLExportTest3::testTdf114848

()

Change-Id: I7eab9d3ef8e6604a57d3e59a77905edf6ce6e6ac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133870
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index de1527ecda0f..3308d5ab4492 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1411,276 +1411,49 @@ void ShapeExport::WriteGraphicObjectShapePart( const 
Reference< XShape >& xShape
 pFS->endElementNS( mnXmlNamespace, XML_pic );
 }
 
-static void lcl_Rotate(sal_Int32 nAngle, Point center, awt::Point& pt)
-{
-sal_Int16 nCos, nSin;
-switch (nAngle)
-{
-case 90:
-nCos = 0;
-nSin = 1;
-break;
-case 180:
-nCos = -1;
-nSin = 0;
-break;
-case 270:
-nCos = 0;
-nSin = -1;
-break;
-default:
-return;
-}
-sal_Int32 x = pt.X - center.X();
-sal_Int32 y = pt.Y - center.Y();
-pt.X = center.X() + x * nCos - y * nSin;
-pt.Y = center.Y() + y * nCos + x * nSin;
-}
-
-static void lcl_FlipHFlipV(tools::Polygon aPoly, sal_Int32 nAngle, bool& 
rFlipH, bool& rFlipV)
-{
-Point aStart = aPoly[0];
-Point aEnd = aPoly[aPoly.GetSize() - 1];
-
-if (aStart.X() > aEnd.X() && aStart.Y() > aEnd.Y())
-{
-if (nAngle)
-{
-if (nAngle == 90)
-rFlipH = true;
-if (nAngle == 270)
-rFlipV = true;
-}
-else // 0°
-{
-rFlipH = true;
-rFlipV = true;
-}
-}
-
-if (aStart.X() < aEnd.X() && aStart.Y() < aEnd.Y())
-{
-if (nAngle)
-{
-if (nAngle != 270)
-{
-rFlipH = true;
-rFlipV = true;
-}
-else
-rFlipH = true;
-}
-}
-
-if (aStart.Y() < aEnd.Y() && aStart.X() > aEnd.X())
-{
-if (nAngle)
-{
-if (nAngle == 180)
-rFlipV = true;
-if (nAngle == 270)
-{
-rFlipV = true;
-rFlipH = true;
-}
-}
-else // 0°
-{
-rFlipH = true;
-}
-}
-
-if (aStart.Y() > aEnd.Y() && aStart.X() < aEnd.X())
-{
-if (nAngle)
-{
-if (nAngle == 90)
-{
-rFlipH = true;
-rFlipV = true;
-}
-if (nAngle == 180)
-rFlipH = true;
-}
-else // 0°
-rFlipV = true;
-}
-}
-
-static sal_Int32 lcl_GetAngle(tools::Polygon aPoly)
-{
-sal_Int32 nAngle;
-Point aStartPoint = aPoly[0];
-Point aEndPoint = aPoly[aPoly.GetSize() - 1];
-if (aStartPoint.X() == aPoly[1].X())
-{
-if ((aStartPoint.X() < aEndPoint.X() && aStartPoint.Y() > 
aEndPoint.Y())
-|| 

[Libreoffice-commits] core.git: oox/source sd/qa

2022-05-04 Thread Tibor Nagy (via logerrit)
 oox/source/export/shapes.cxx   |  306 +
 sd/qa/unit/data/odp/tdf147919.odp  |binary
 sd/qa/unit/export-tests-ooxml1.cxx |   62 +++
 3 files changed, 340 insertions(+), 28 deletions(-)

New commits:
commit 1f8c6efbfea10997f188962d036f5c7db4c13f8a
Author: Tibor Nagy 
AuthorDate: Fri Apr 29 14:08:17 2022 +0200
Commit: László Németh 
CommitDate: Wed May 4 12:46:36 2022 +0200

tdf#147919 PPTX export: fix curved and bent connector shape

by calculating and exporting adjustment values to avoid
of connector lines with bad turns overlapping the
connected shapes.

Change-Id: I615a20f3ba3c5d03ae73d87848dc41e9ecd29ae5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133635
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 3308d5ab4492..de1527ecda0f 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1411,49 +1411,276 @@ void ShapeExport::WriteGraphicObjectShapePart( const 
Reference< XShape >& xShape
 pFS->endElementNS( mnXmlNamespace, XML_pic );
 }
 
+static void lcl_Rotate(sal_Int32 nAngle, Point center, awt::Point& pt)
+{
+sal_Int16 nCos, nSin;
+switch (nAngle)
+{
+case 90:
+nCos = 0;
+nSin = 1;
+break;
+case 180:
+nCos = -1;
+nSin = 0;
+break;
+case 270:
+nCos = 0;
+nSin = -1;
+break;
+default:
+return;
+}
+sal_Int32 x = pt.X - center.X();
+sal_Int32 y = pt.Y - center.Y();
+pt.X = center.X() + x * nCos - y * nSin;
+pt.Y = center.Y() + y * nCos + x * nSin;
+}
+
+static void lcl_FlipHFlipV(tools::Polygon aPoly, sal_Int32 nAngle, bool& 
rFlipH, bool& rFlipV)
+{
+Point aStart = aPoly[0];
+Point aEnd = aPoly[aPoly.GetSize() - 1];
+
+if (aStart.X() > aEnd.X() && aStart.Y() > aEnd.Y())
+{
+if (nAngle)
+{
+if (nAngle == 90)
+rFlipH = true;
+if (nAngle == 270)
+rFlipV = true;
+}
+else // 0°
+{
+rFlipH = true;
+rFlipV = true;
+}
+}
+
+if (aStart.X() < aEnd.X() && aStart.Y() < aEnd.Y())
+{
+if (nAngle)
+{
+if (nAngle != 270)
+{
+rFlipH = true;
+rFlipV = true;
+}
+else
+rFlipH = true;
+}
+}
+
+if (aStart.Y() < aEnd.Y() && aStart.X() > aEnd.X())
+{
+if (nAngle)
+{
+if (nAngle == 180)
+rFlipV = true;
+if (nAngle == 270)
+{
+rFlipV = true;
+rFlipH = true;
+}
+}
+else // 0°
+{
+rFlipH = true;
+}
+}
+
+if (aStart.Y() > aEnd.Y() && aStart.X() < aEnd.X())
+{
+if (nAngle)
+{
+if (nAngle == 90)
+{
+rFlipH = true;
+rFlipV = true;
+}
+if (nAngle == 180)
+rFlipH = true;
+}
+else // 0°
+rFlipV = true;
+}
+}
+
+static sal_Int32 lcl_GetAngle(tools::Polygon aPoly)
+{
+sal_Int32 nAngle;
+Point aStartPoint = aPoly[0];
+Point aEndPoint = aPoly[aPoly.GetSize() - 1];
+if (aStartPoint.X() == aPoly[1].X())
+{
+if ((aStartPoint.X() < aEndPoint.X() && aStartPoint.Y() > 
aEndPoint.Y())
+|| (aStartPoint.X() > aEndPoint.X() && aStartPoint.Y() < 
aEndPoint.Y()))
+{
+nAngle = 90;
+}
+else
+nAngle = 270;
+}
+else
+{
+if (aStartPoint.X() > aPoly[1].X())
+nAngle = 180;
+else
+nAngle = 0;
+}
+
+return nAngle;
+}
+
+// Adjust value decide the position, where the connector should turn.
+static void lcl_GetConnectorAdjustValue(const Reference& xShape, 
tools::Polygon aPoly,
+ConnectorType eConnectorType,
+std::vector>& rAvList)
+{
+sal_Int32 nAdjCount = 0;
+if (eConnectorType == ConnectorType_CURVE)
+{
+if (aPoly.GetSize() == 4)
+{
+if ((aPoly[0].X() == aPoly[1].X() && aPoly[2].X() == aPoly[3].X())
+|| (aPoly[0].Y() == aPoly[1].Y() && aPoly[2].Y() == 
aPoly[3].Y()))
+{
+nAdjCount = 1; // curvedConnector3
+}
+else
+nAdjCount = 0; // curvedConnector2
+}
+else
+{
+if ((aPoly[2].X() == aPoly[3].X() && aPoly[3].X() == aPoly[4].X())
+|| (aPoly[2].Y() == aPoly[3].Y() && aPoly[3].Y() == 
aPoly[4].Y()))
+{
+nAdjCount = 3; // curvedConnector5
+}
+   

[Libreoffice-commits] core.git: oox/source sd/qa

2022-04-26 Thread Tünde Tóth (via logerrit)
 oox/source/drawingml/fillproperties.cxx  |6 ++---
 oox/source/drawingml/graphicshapecontext.cxx |   32 ---
 sd/qa/unit/export-tests-ooxml2.cxx   |   19 +++-
 3 files changed, 45 insertions(+), 12 deletions(-)

New commits:
commit 9564747d2fd5d2c859a359dd7fa6242c6859c0d7
Author: Tünde Tóth 
AuthorDate: Wed Apr 6 16:18:29 2022 +0200
Commit: László Németh 
CommitDate: Tue Apr 26 17:41:27 2022 +0200

tdf#53970 PPTX: fix import of linked media files

Linked media files were imported as images in documents
created with Impress after PPTX export.

Change-Id: If4920c2e40f45fff73eca4a5fa987d524177597e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132635
Tested-by: Jenkins
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/drawingml/fillproperties.cxx 
b/oox/source/drawingml/fillproperties.cxx
index 9589a7388bd5..a6d5250f 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -963,11 +963,11 @@ void GraphicProperties::pushToPropMap( PropertyMap& 
rPropMap, const GraphicHelpe
 rPropMap.setProperty(PROP_AdjustContrast, nContrast);
 
 // Media content
-assert(m_xMediaStream.is() != m_sMediaPackageURL.isEmpty());
-if (m_xMediaStream.is() && !m_sMediaPackageURL.isEmpty())
+if (!m_sMediaPackageURL.isEmpty())
 {
-rPropMap.setProperty(PROP_PrivateStream, m_xMediaStream);
 rPropMap.setProperty(PROP_MediaURL, m_sMediaPackageURL);
+if (m_xMediaStream.is())
+rPropMap.setProperty(PROP_PrivateStream, m_xMediaStream);
 }
 }
 
diff --git a/oox/source/drawingml/graphicshapecontext.cxx 
b/oox/source/drawingml/graphicshapecontext.cxx
index 3ed00edfd28c..d90980a87824 100644
--- a/oox/source/drawingml/graphicshapecontext.cxx
+++ b/oox/source/drawingml/graphicshapecontext.cxx
@@ -84,10 +84,12 @@ ContextHandlerRef GraphicShapeContext::onCreateContext( 
sal_Int32 aElementToken,
 case XML_wavAudioFile:
 {
 OUString const path(getEmbeddedWAVAudioFile(getRelations(), 
rAttribs));
-mpShapePtr->getGraphicProperties().m_xMediaStream =
-lcl_GetMediaStream(path, getFilter());
-mpShapePtr->getGraphicProperties().m_sMediaPackageURL =
-lcl_GetMediaReference(path);
+Reference xMediaStream = lcl_GetMediaStream(path, 
getFilter());
+if (xMediaStream.is())
+{
+mpShapePtr->getGraphicProperties().m_xMediaStream = 
xMediaStream;
+mpShapePtr->getGraphicProperties().m_sMediaPackageURL = 
lcl_GetMediaReference(path);
+}
 }
 break;
 case XML_audioFile:
@@ -95,10 +97,24 @@ ContextHandlerRef GraphicShapeContext::onCreateContext( 
sal_Int32 aElementToken,
 {
 OUString rPath = getRelations().getFragmentPathFromRelId(
 rAttribs.getString(R_TOKEN(link)).get() );
-mpShapePtr->getGraphicProperties().m_xMediaStream =
-lcl_GetMediaStream(rPath, getFilter());
-mpShapePtr->getGraphicProperties().m_sMediaPackageURL =
-lcl_GetMediaReference(rPath);
+if (!rPath.isEmpty())
+{
+Reference xMediaStream = 
lcl_GetMediaStream(rPath, getFilter());
+if (xMediaStream.is()) // embedded media file
+{
+mpShapePtr->getGraphicProperties().m_xMediaStream = 
xMediaStream;
+mpShapePtr->getGraphicProperties().m_sMediaPackageURL
+= lcl_GetMediaReference(rPath);
+}
+}
+else
+{
+rPath = getRelations().getExternalTargetFromRelId(
+rAttribs.getString(R_TOKEN(link)).get());
+if (!rPath.isEmpty()) // linked media file
+mpShapePtr->getGraphicProperties().m_sMediaPackageURL
+= getFilter().getAbsoluteUrl(rPath);
+}
 }
 break;
 }
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx 
b/sd/qa/unit/export-tests-ooxml2.cxx
index 8ad1872d2c52..56ff8b067763 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -1823,11 +1823,28 @@ void SdOOXMLExportTest2::testTdf53970()
 
m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf53970_linked.odp"), ODP);
 utl::TempFile tempFile;
 xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
-xDocShRef->DoClose();
 
 xmlDocUniquePtr pXmlRels = parseExport(tempFile, 
"ppt/slides/_rels/slide1.xml.rels");
 CPPUNIT_ASSERT(pXmlRels);
 assertXPath(pXmlRels, 
"/rels:Relationships/rels:Relationship[@TargetMode='External']", 2);
+
+uno::Reference xShape(getShape(0, getPage(0, 
xDocShRef)));
+CPPUNIT_ASSERT(xShape.is());
+OUString 

[Libreoffice-commits] core.git: oox/source sd/qa

2022-04-26 Thread Xisco Fauli (via logerrit)
 oox/source/drawingml/textparagraphproperties.cxx |3 ++-
 sd/qa/unit/data/pptx/tdf147586.pptx  |binary
 sd/qa/unit/export-tests-ooxml3.cxx   |   22 ++
 3 files changed, 24 insertions(+), 1 deletion(-)

New commits:
commit a0bae88a9cd47185a71cbfd4c86bbd86ae44d30e
Author: Xisco Fauli 
AuthorDate: Tue Apr 26 00:00:18 2022 +0200
Commit: Xisco Fauli 
CommitDate: Tue Apr 26 08:50:56 2022 +0200

tdf#147586: Initialize mbBulletColorFollowText to false

Otherwise, once it's set to true, it's never reset

Change-Id: Ie8a752da4162775f40c2f84f480e6a103eb55942
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133422
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/oox/source/drawingml/textparagraphproperties.cxx 
b/oox/source/drawingml/textparagraphproperties.cxx
index 75dbf6bcea4a..ce40f69eb4f6 100644
--- a/oox/source/drawingml/textparagraphproperties.cxx
+++ b/oox/source/drawingml/textparagraphproperties.cxx
@@ -58,7 +58,8 @@ using ::com::sun::star::awt::FontDescriptor;
 namespace oox::drawingml {
 
 BulletList::BulletList( )
-: maBulletColorPtr( std::make_shared() )
+: maBulletColorPtr( std::make_shared() ),
+  mbBulletColorFollowText ( false )
 {
 }
 
diff --git a/sd/qa/unit/data/pptx/tdf147586.pptx 
b/sd/qa/unit/data/pptx/tdf147586.pptx
new file mode 100644
index ..723facf82071
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf147586.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index 7a6cad3f9124..63c7ea278595 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -36,6 +36,7 @@ class SdOOXMLExportTest3 : public SdModelTestBaseXML
 public:
 void testTdf129430();
 void testTdf114848();
+void testTdf147586();
 void testTdf68759();
 void testTdf127901();
 void testTdf48735();
@@ -118,6 +119,7 @@ public:
 
 CPPUNIT_TEST(testTdf129430);
 CPPUNIT_TEST(testTdf114848);
+CPPUNIT_TEST(testTdf147586);
 CPPUNIT_TEST(testTdf68759);
 CPPUNIT_TEST(testTdf127901);
 CPPUNIT_TEST(testTdf48735);
@@ -231,6 +233,26 @@ void SdOOXMLExportTest3::testTdf114848()
 "1f497d");
 }
 
+void SdOOXMLExportTest3::testTdf147586()
+{
+::sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf147586.pptx"), 
PPTX);
+utl::TempFile tempFile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+xDocShRef->DoClose();
+
+xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, 
"ppt/slides/slide1.xml");
+// Without the fix in place, this test would have failed with
+// - Expected: 227fc7
+// - Actual  : 4f4f4f
+assertXPath(pXmlDocContent,
+
"/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:p[1]/a:pPr/a:buClr/a:srgbClr", "val",
+"227fc7");
+assertXPath(pXmlDocContent,
+
"/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:p[2]/a:pPr/a:buClr/a:srgbClr", "val",
+"227fc7");
+}
+
 void SdOOXMLExportTest3::testTdf68759()
 {
 ::sd::DrawDocShellRef xDocShRef


[Libreoffice-commits] core.git: oox/source sd/qa

2022-04-22 Thread Xisco Fauli (via logerrit)
 oox/source/drawingml/textcharacterproperties.cxx |6 +++
 sd/qa/unit/data/pptx/tdf148685.pptx  |binary
 sd/qa/unit/import-tests2.cxx |   43 +++
 3 files changed, 49 insertions(+)

New commits:
commit 1c924efe1f80207a5e104d755615b1eb9a91d418
Author: Xisco Fauli 
AuthorDate: Wed Apr 20 17:58:15 2022 +0200
Commit: Xisco Fauli 
CommitDate: Fri Apr 22 19:37:36 2022 +0200

tdf#148685: Unset CharUnderlineColor and CharUnderlineHasColor properties

Change-Id: Iebf482434cd393f55ae3e4690580b573624d78b1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133219
Tested-by: Xisco Fauli 
Reviewed-by: Xisco Fauli 

diff --git a/oox/source/drawingml/textcharacterproperties.cxx 
b/oox/source/drawingml/textcharacterproperties.cxx
index 9d568cd5cabb..fc8214db42fe 100644
--- a/oox/source/drawingml/textcharacterproperties.cxx
+++ b/oox/source/drawingml/textcharacterproperties.cxx
@@ -201,6 +201,12 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& 
rPropMap, const XmlFil
 rPropMap.setProperty( PROP_CharUnderlineHasColor, true);
 rPropMap.setProperty( PROP_CharUnderlineColor, 
maUnderlineColor.getColor( rFilter.getGraphicHelper() ));
 }
+else
+{
+rPropMap.setProperty( PROP_CharUnderlineHasColor, false);
+rPropMap.setProperty( PROP_CharUnderlineColor, sal_Int32(-1));
+}
+
 // TODO If bUnderlineFillFollowText uFillTx 
(CT_TextUnderlineFillFollowText) is set, fill color of the underline should be 
the same color as the text
 
 if (maHighlightColor.isUsed() && maHighlightColor.getTransparency() != 100)
diff --git a/sd/qa/unit/data/pptx/tdf148685.pptx 
b/sd/qa/unit/data/pptx/tdf148685.pptx
new file mode 100644
index ..80af5a9bbf46
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf148685.pptx differ
diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx
index 0bb99100b9dd..b06a699b04bd 100644
--- a/sd/qa/unit/import-tests2.cxx
+++ b/sd/qa/unit/import-tests2.cxx
@@ -72,6 +72,7 @@ public:
 void testAoo124143();
 void testTdf103567();
 void testTdf103792();
+void testTdf148685();
 void testTdf103876();
 void testTdf79007();
 void testTdf119649();
@@ -142,6 +143,7 @@ public:
 CPPUNIT_TEST(testAoo124143);
 CPPUNIT_TEST(testTdf103567);
 CPPUNIT_TEST(testTdf103792);
+CPPUNIT_TEST(testTdf148685);
 CPPUNIT_TEST(testTdf103876);
 CPPUNIT_TEST(testTdf79007);
 CPPUNIT_TEST(testTdf119649);
@@ -436,6 +438,47 @@ void SdImportTest2::testTdf103792()
 xDocShRef->DoClose();
 }
 
+void SdImportTest2::testTdf148685()
+{
+sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf148685.pptx"), 
PPTX);
+uno::Reference xShape(getShapeFromPage(1, 0, 
xDocShRef));
+
+uno::Reference const xParagraph(getParagraphFromShape(0, 
xShape));
+
+uno::Reference xRun(getRunFromParagraph(0, xParagraph));
+CPPUNIT_ASSERT_EQUAL(OUString("TEXT "), xRun->getString());
+
+uno::Reference xPropSet(xRun, uno::UNO_QUERY_THROW);
+
+Color nCharUnderlineColor;
+xPropSet->getPropertyValue("CharUnderlineColor") >>= nCharUnderlineColor;
+CPPUNIT_ASSERT_EQUAL(Color(0xA1467E), nCharUnderlineColor);
+
+xRun.set(getRunFromParagraph(1, xParagraph));
+
+CPPUNIT_ASSERT_EQUAL(OUString("TE"), xRun->getString());
+
+xPropSet.set(xRun, uno::UNO_QUERY_THROW);
+
+xPropSet->getPropertyValue("CharUnderlineColor") >>= nCharUnderlineColor;
+
+// Without the fix in place, this test would have failed with
+// - Expected: Color: R:255 G:255 B:255 A:255
+// - Actual  : Color: R:161 G:70 B:126 A:0
+CPPUNIT_ASSERT_EQUAL(COL_AUTO, nCharUnderlineColor);
+
+xRun.set(getRunFromParagraph(2, xParagraph));
+CPPUNIT_ASSERT_EQUAL(OUString("XT"), xRun->getString());
+
+xPropSet.set(xRun, uno::UNO_QUERY_THROW);
+
+xPropSet->getPropertyValue("CharUnderlineColor") >>= nCharUnderlineColor;
+CPPUNIT_ASSERT_EQUAL(COL_AUTO, nCharUnderlineColor);
+
+xDocShRef->DoClose();
+}
+
 void SdImportTest2::testTdf103876()
 {
 // Title text shape's placeholder text did not inherit the corresponding 
text properties


[Libreoffice-commits] core.git: oox/source sd/qa

2022-04-15 Thread Regina Henschel (via logerrit)
 oox/source/export/shapes.cxx  |6 +--
 sd/qa/unit/data/odp/tdf109169_Diamond.odp |binary
 sd/qa/unit/data/odp/tdf109169_Octagon.odp |binary
 sd/qa/unit/export-tests-ooxml3.cxx|   46 ++
 4 files changed, 49 insertions(+), 3 deletions(-)

New commits:
commit b195cf4db4c21da3cf754689fb22f0b6a904a03e
Author: Regina Henschel 
AuthorDate: Fri Apr 15 15:04:16 2022 +0200
Commit: Regina Henschel 
CommitDate: Fri Apr 15 22:16:40 2022 +0200

tdf#109169 use custGeom for Octagon Bevel shape

The shapes 'Octagon Bevel', type col_60da8460, and 'Diamond Bevel',
type col-502ad400, are LO specific preset shapes. They have neither a
counterpart in MS binary nor in OOXML. So they need to be exported
with custGeom. To force custGeom these shape types are moved from
vDenylist to vAllowlist.
These shapes were exported as prst='rect' before.

Change-Id: I9619345812b6dba8f14ec2cc6a92ae808a56b595
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133069
Tested-by: Jenkins
Reviewed-by: Regina Henschel 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index e4d378bd6111..3308d5ab4492 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -551,8 +551,6 @@ static bool lcl_IsOnDenylist(OUString const & rShapeType)
 u"flower",
 u"bracket-pair",
 u"brace-pair",
-u"col-60da8460",
-u"col-502ad400",
 u"quad-bevel",
 u"round-rectangular-callout",
 u"rectangular-callout",
@@ -605,7 +603,9 @@ static bool lcl_IsOnAllowlist(OUString const & rShapeType)
 {
 static const std::initializer_list vAllowlist = {
 u"heart",
-u"puzzle"
+u"puzzle",
+u"col-60da8460",
+u"col-502ad400"
 };
 
 return std::find(vAllowlist.begin(), vAllowlist.end(), rShapeType) != 
vAllowlist.end();
diff --git a/sd/qa/unit/data/odp/tdf109169_Diamond.odp 
b/sd/qa/unit/data/odp/tdf109169_Diamond.odp
new file mode 100644
index ..cd6a18d1b318
Binary files /dev/null and b/sd/qa/unit/data/odp/tdf109169_Diamond.odp differ
diff --git a/sd/qa/unit/data/odp/tdf109169_Octagon.odp 
b/sd/qa/unit/data/odp/tdf109169_Octagon.odp
new file mode 100644
index ..f35e746f3b28
Binary files /dev/null and b/sd/qa/unit/data/odp/tdf109169_Octagon.odp differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index 3f4bec336ef1..23486c66f254 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -11,6 +11,7 @@
 #include 
 #include "sdmodeltestbase.hxx"
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -21,6 +22,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -107,6 +109,8 @@ public:
 void testTdf140912_PicturePlaceholder();
 void testEnhancedPathViewBox();
 void testTdf74670();
+void testTdf109169_OctagonBevel();
+void testTdf109169_DiamondBevel();
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest3);
 
@@ -184,6 +188,8 @@ public:
 CPPUNIT_TEST(testTdf140912_PicturePlaceholder);
 CPPUNIT_TEST(testEnhancedPathViewBox);
 CPPUNIT_TEST(testTdf74670);
+CPPUNIT_TEST(testTdf109169_OctagonBevel);
+CPPUNIT_TEST(testTdf109169_DiamondBevel);
 CPPUNIT_TEST_SUITE_END();
 
 virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override
@@ -1919,6 +1925,46 @@ void SdOOXMLExportTest3::testTdf74670()
 CPPUNIT_ASSERT_EQUAL(1, nImageFiles);
 }
 
+void SdOOXMLExportTest3::testTdf109169_OctagonBevel()
+{
+// The document has a shape 'Octagon Bevel'. It consists of an octagon 
with 8 points and eight
+// facets with 4 points each, total 8+8*4=40 points. Without the patch it 
was exported as
+// rectangle and thus had 4 points.
+::sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/odp/tdf109169_Octagon.odp"),
 ODP);
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX);
+
+auto xPropSet(getShapeFromPage(0, 0, xDocShRef));
+auto aGeomPropSeq = xPropSet->getPropertyValue("CustomShapeGeometry")
+.get>();
+comphelper::SequenceAsHashMap aCustomShapeGeometry(aGeomPropSeq);
+auto 
aPathSeq((aCustomShapeGeometry["Path"]).get>());
+comphelper::SequenceAsHashMap aPath(aPathSeq);
+auto aCoordinates(
+
(aPath["Coordinates"]).get>());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(40), aCoordinates.getLength());
+}
+
+void SdOOXMLExportTest3::testTdf109169_DiamondBevel()
+{
+// The document has a shape 'Diamond Bevel'. It consists of a diamond with 
4 points and four
+// facets with 4 points each, total 4+4*4=20 points. Without the patch it 
was exported as
+// rectangle and thus had 4 points.
+::sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/odp/tdf109169_Diamond.odp"),
 ODP);
+xDocShRef = 

[Libreoffice-commits] core.git: oox/source sd/qa

2022-04-04 Thread Tünde Tóth (via logerrit)
 oox/source/export/drawingml.cxx |4 ++--
 sd/qa/unit/data/odp/tdf53970_linked.odp |binary
 sd/qa/unit/export-tests-ooxml2.cxx  |   27 +--
 3 files changed, 23 insertions(+), 8 deletions(-)

New commits:
commit c2e8a96a8107a37901e475c65a8e61211fc3b132
Author: Tünde Tóth 
AuthorDate: Thu Mar 31 13:11:04 2022 +0200
Commit: László Németh 
CommitDate: Mon Apr 4 13:01:08 2022 +0200

tdf#53970 PPTX: fix broken export of linked media files

Missing TargetMode="External" in the export of
linked media files resulted corrupted PPTX.

Change-Id: I76246db331d199810a5b413d44bec95283e88e47
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132402
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index a99a0474a458..54f94278d782 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1490,8 +1490,8 @@ void DrawingML::WriteMediaNonVisualProperties(const 
css::uno::ReferenceaddRelation(mpFS->getOutputStream(), 
oox::getRelationship(eMediaType), rURL);
-aMediaRelId = mpFB->addRelation(mpFS->getOutputStream(), 
oox::getRelationship(Relationship::MEDIA), rURL);
+aVideoFileRelId = mpFB->addRelation(mpFS->getOutputStream(), 
oox::getRelationship(eMediaType), rURL, true);
+aMediaRelId = mpFB->addRelation(mpFS->getOutputStream(), 
oox::getRelationship(Relationship::MEDIA), rURL, true);
 }
 
 GetFS()->startElementNS(XML_p, XML_nvPr);
diff --git a/sd/qa/unit/data/odp/tdf53970_linked.odp 
b/sd/qa/unit/data/odp/tdf53970_linked.odp
new file mode 100644
index ..3ddb7933463f
Binary files /dev/null and b/sd/qa/unit/data/odp/tdf53970_linked.odp differ
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx 
b/sd/qa/unit/export-tests-ooxml2.cxx
index a620386ad22d..5fac35ea1833 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -1804,15 +1804,30 @@ void SdOOXMLExportTest2::testTdf59323_slideFooters()
 
 void SdOOXMLExportTest2::testTdf53970()
 {
-::sd::DrawDocShellRef xDocShRef
-= 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf53970.odp"), ODP);
-xDocShRef = saveAndReload(xDocShRef.get(), PPTX);
+// Embedded media file
+{
+::sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf53970.odp"), ODP);
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX);
 
+// Without fix in place, the media shape was lost on export.
+CPPUNIT_ASSERT(getPage(0, xDocShRef)->hasElements());
 
-// Without fix in place, the media shape was lost on export.
-CPPUNIT_ASSERT(getPage(0, xDocShRef)->hasElements());
+xDocShRef->DoClose();
+}
 
-xDocShRef->DoClose();
+// Linked media file
+{
+::sd::DrawDocShellRef xDocShRef = loadURL(
+
m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf53970_linked.odp"), ODP);
+utl::TempFile tempFile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+xDocShRef->DoClose();
+
+xmlDocUniquePtr pXmlRels = parseExport(tempFile, 
"ppt/slides/_rels/slide1.xml.rels");
+CPPUNIT_ASSERT(pXmlRels);
+assertXPath(pXmlRels, 
"/rels:Relationships/rels:Relationship[@TargetMode='External']", 2);
+}
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2);


[Libreoffice-commits] core.git: oox/source sd/qa

2022-03-30 Thread Caolán McNamara (via logerrit)
 oox/source/ppt/slidepersist.cxx   |2 ++
 sd/qa/unit/data/pptx/pass/ofz46160-1.pptx |binary
 2 files changed, 2 insertions(+)

New commits:
commit 254d0e17dcd9a6bce536057b020292ac0ab2e48e
Author: Caolán McNamara 
AuthorDate: Wed Mar 30 08:53:58 2022 +0100
Commit: Caolán McNamara 
CommitDate: Wed Mar 30 12:19:50 2022 +0200

ofz#46160 Null-dereference READ

Change-Id: Id33a39a7a65849a4ca98b43a88e60d5a96eaf5de
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132297
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx
index 061dda725551..e90f2365fefc 100644
--- a/oox/source/ppt/slidepersist.cxx
+++ b/oox/source/ppt/slidepersist.cxx
@@ -347,6 +347,8 @@ void SlidePersist::createConnectorShapeConnection()
 for (sal_Int32 i = 0; i < nConnectorShapeCount; i++)
 {
 const auto& pIt = maShapeMap.find(maConnectorShapeId[i]);
+if (pIt == maShapeMap.end())
+continue;
 oox::drawingml::ConnectorShapePropertiesList aConnectorShapeProperties
 = pIt->second->getConnectorShapeProperties();
 uno::Reference xConnector(pIt->second->getXShape(), 
uno::UNO_QUERY);
diff --git a/sd/qa/unit/data/pptx/pass/ofz46160-1.pptx 
b/sd/qa/unit/data/pptx/pass/ofz46160-1.pptx
new file mode 100644
index ..721d1d87d8f0
Binary files /dev/null and b/sd/qa/unit/data/pptx/pass/ofz46160-1.pptx differ


[Libreoffice-commits] core.git: oox/source sd/qa

2022-03-29 Thread Tünde Tóth (via logerrit)
 oox/source/export/drawingml.cxx  |5 +
 oox/source/export/shapes.cxx |1 +
 sd/qa/unit/data/odp/tdf53970.odp |binary
 3 files changed, 6 insertions(+)

New commits:
commit bc72514f90d90e1ab3fed8167663e835edf03508
Author: Tünde Tóth 
AuthorDate: Thu Mar 24 16:54:01 2022 +0100
Commit: László Németh 
CommitDate: Tue Mar 29 12:59:55 2022 +0200

tdf#53970 PPTX: fix export of embedded media files

Embedded media files lost in documents created
with Impress after PPTX export.

Change-Id: I453b58f9cfa6a33653e9216fb82b66970a9ec31b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132095
Tested-by: Jenkins
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 912f3921d406..ff092b44641c 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1428,6 +1428,11 @@ void DrawingML::WriteMediaNonVisualProperties(const 
css::uno::Reference

[Libreoffice-commits] core.git: oox/source sd/qa

2022-03-17 Thread Gülşah Köse (via logerrit)
 oox/source/drawingml/table/tablecell.cxx |   10 +-
 oox/source/export/shapes.cxx |6 ++
 sd/qa/unit/export-tests.cxx  |3 ++-
 sd/qa/unit/import-tests.cxx  |2 +-
 4 files changed, 10 insertions(+), 11 deletions(-)

New commits:
commit f8ac4be066b9277cf2f893b581adc33de841bb9e
Author: Gülşah Köse 
AuthorDate: Mon Mar 14 14:52:59 2022 +0300
Commit: Gülşah Köse 
CommitDate: Thu Mar 17 08:05:06 2022 +0100

tdf#147766 Export empty lines as line with noFill

We have a case that 0 width line but has auto color. If that case
exported there is no line over there, LO handles normally but MSO draws
back borders as default. To prevent this we have to export them as line
with noFill.

testTableBorderLineStyle change reverts a workaround for
3faf005a367cbd28077403bf93810bbaf4805851

testBnc480256 Cell(1,0) still invisible. We are just checking
this with another way.

Change-Id: If5f6d2dbdba5c295d58307fcfe3b37629ede8a8e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131532
Tested-by: Jenkins
Reviewed-by: Justin Luth 
Reviewed-by: Gülşah Köse 

diff --git a/oox/source/drawingml/table/tablecell.cxx 
b/oox/source/drawingml/table/tablecell.cxx
index 15ab06303e3b..fdf7950dcf2c 100644
--- a/oox/source/drawingml/table/tablecell.cxx
+++ b/oox/source/drawingml/table/tablecell.cxx
@@ -73,20 +73,12 @@ static void applyLineAttributes( const 
::oox::core::XmlFilterBase& rFilterBase,
 aBorderLine.LineWidth = static_cast< sal_Int16 >( GetCoordinate( 
rLineProperties.moLineWidth.get( 0 ) ) / 2 );
 aBorderLine.LineDistance = 0;
 }
-else if ( rLineProperties.moLineWidth.get(0)!=0 )
-{
-aBorderLine.Color = sal_Int32( COL_AUTO );
-aBorderLine.OuterLineWidth = static_cast< sal_Int16 >( GetCoordinate( 
rLineProperties.moLineWidth.get( 0 ) ) / 4 );
-aBorderLine.InnerLineWidth = static_cast< sal_Int16 >( GetCoordinate( 
rLineProperties.moLineWidth.get( 0 ) ) / 4 );
-aBorderLine.LineWidth = static_cast< sal_Int16 >( GetCoordinate( 
rLineProperties.moLineWidth.get( 0 ) ) / 2 );
-aBorderLine.LineDistance = 0;
-}
 else
 {
 aBorderLine.Color = sal_Int32( COL_AUTO );
 aBorderLine.OuterLineWidth = static_cast< sal_Int16 >( GetCoordinate( 
rLineProperties.moLineWidth.get( 0 ) ) / 4 );
 aBorderLine.InnerLineWidth = static_cast< sal_Int16 >( GetCoordinate( 
rLineProperties.moLineWidth.get( 0 ) ) / 4 );
-aBorderLine.LineWidth = 12700;
+aBorderLine.LineWidth = static_cast< sal_Int16 >( GetCoordinate( 
rLineProperties.moLineWidth.get( 0 ) ) / 2 );
 aBorderLine.LineDistance = 0;
 }
 
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 719836e77b70..04e65e013608 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1995,6 +1995,12 @@ void ShapeExport::WriteBorderLine(const sal_Int32 
XML_line, const BorderLine2& r
 DrawingML::WriteSolidFill( ::Color(ColorTransparency, 
rBorderLine.Color) );
 mpFS->endElementNS( XML_a, XML_line );
 }
+else if( nBorderWidth == 0)
+{
+mpFS->startElementNS(XML_a, XML_line);
+mpFS->singleElementNS(XML_a, XML_noFill);
+mpFS->endElementNS( XML_a, XML_line );
+}
 }
 
 void ShapeExport::WriteTableCellBorders(const Reference< XPropertySet>& 
xCellPropSet)
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index fd2380af5cf9..be1b2d08c6ab 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -602,9 +602,10 @@ void SdExportTest::testBnc480256()
 xCell->getPropertyValue("FillColor") >>= nColor;
 CPPUNIT_ASSERT_EQUAL(Color(0x4697e0), nColor);
 
+// This border should be invisible.
 xCell.set(xTable->getCellByPosition(1, 0), uno::UNO_QUERY_THROW);
 xCell->getPropertyValue("BottomBorder") >>= aBorderLine;
-CPPUNIT_ASSERT_EQUAL(COL_AUTO, Color(ColorTransparency, 
aBorderLine.Color));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), sal_Int32(aBorderLine.LineWidth));
 
 xDocShRef->DoClose();
 }
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 26abc2ece38c..215d668b2f3f 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -1456,7 +1456,7 @@ void SdImportTest::testTableBorderLineStyle()
 xTable.set(pTableObj->getTable(), uno::UNO_QUERY_THROW);
 xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
 xCell->getPropertyValue("TopBorder") >>= aBorderLine;
-if (aBorderLine.Color != -1) {
+if (aBorderLine.LineWidth > 0) {
 CPPUNIT_ASSERT_EQUAL(nObjBorderLineStyles[i], 
aBorderLine.LineStyle);
 }
 }


[Libreoffice-commits] core.git: oox/source sd/qa

2022-03-01 Thread Tibor Nagy (via logerrit)
 oox/source/drawingml/customshapepresetdata.cxx |   67 +
 oox/source/drawingml/customshapes/oox-drawingml-cs-presets |   22 ++--
 sd/qa/unit/data/pptx/tdf147459.pptx|binary
 sd/qa/unit/data/xml/n820786_0.xml  |2 
 sd/qa/unit/data/xml/tdf109317_0.xml|3 
 sd/qa/unit/import-tests.cxx|   35 ++
 6 files changed, 118 insertions(+), 11 deletions(-)

New commits:
commit 744e6c0b758fefe6011f09860b44f03ab70fbcfe
Author: Tibor Nagy 
AuthorDate: Mon Feb 21 14:07:51 2022 +0100
Commit: László Németh 
CommitDate: Tue Mar 1 13:45:48 2022 +0100

tdf#147459 PPTX: add "glue points" to some basic shapes

(ellipse, triangle, right triangle, trapezoid,
parallelogram, diamond, pentagon, hexagon, heptagon,
octagon).

These glue points allow to add and use connectors
on basic shapes, e.g. by specifying 8 glue points on
outline of ellipses (and not 4 glue points only on
their bounding boxes).

Usage: insert a basic shape from the list above,
select it, and click on the icon Connectors to
show and use the new glue points on the outline of
the shape.

Note: PPTX import doesn't import connectors
connected to the glue points – only ODP export keeps
them for the planned editing, i.e. moving the connected
shapes without losing the connecting lines and arrows.

Change-Id: Iaef21ce8dc3f6677fa2fd6a484adf6d546e72ad1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130281
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/drawingml/customshapepresetdata.cxx 
b/oox/source/drawingml/customshapepresetdata.cxx
index a80ddeacae21..ea1fcbb41362 100644
--- a/oox/source/drawingml/customshapepresetdata.cxx
+++ b/oox/source/drawingml/customshapepresetdata.cxx
@@ -507,6 +507,71 @@ void 
lcl_parsePathCoordinates(std::vector& rPath, const OS
 }
 }
 
+void lcl_parsePathGluePointsValues(std::vector& rPath, 
const OString& rValue)
+{
+std::vector aPairs;
+sal_Int32 nLevel = 0;
+sal_Int32 nStart = 0;
+for (sal_Int32 i = 0; i < rValue.getLength(); ++i)
+{
+if (rValue[i] == '{')
+{
+if (!nLevel)
+nStart = i;
+nLevel++;
+}
+else if (rValue[i] == '}')
+{
+nLevel--;
+if (!nLevel)
+aPairs.push_back(lcl_parseEnhancedCustomShapeParameterPair(
+rValue.copy(nStart + strlen("{ "), i - nStart - strlen(" 
},";
+}
+}
+
+beans::PropertyValue aPropertyValue;
+aPropertyValue.Name = "GluePoints";
+aPropertyValue.Value <<= comphelper::containerToSequence(aPairs);
+rPath.push_back(aPropertyValue);
+}
+
+void lcl_parsePathGluePoints(std::vector& rPath, const 
OString& rValue)
+{
+sal_Int32 nLevel = 0;
+bool bIgnore = false;
+sal_Int32 nStart = 0;
+for (sal_Int32 i = 0; i < rValue.getLength(); ++i)
+{
+if (rValue[i] == '{')
+{
+if (!nLevel)
+bIgnore = true;
+nLevel++;
+}
+else if (rValue[i] == '}')
+{
+nLevel--;
+if (!nLevel)
+bIgnore = false;
+}
+else if (rValue[i] == ',' && !bIgnore)
+{
+OString aToken = rValue.copy(nStart, i - nStart);
+static const char aExpectedPrefix[]
+= "Value = (any) { 
([]com.sun.star.drawing.EnhancedCustomShapeParameterPair) { ";
+if (aToken.startsWith(aExpectedPrefix))
+{
+aToken = aToken.copy(strlen(aExpectedPrefix),
+ aToken.getLength() - 
strlen(aExpectedPrefix) - strlen(" } }"));
+lcl_parsePathGluePointsValues(rPath, aToken);
+}
+else if (!aToken.startsWith("Name =") && 
!aToken.startsWith("Handle ="))
+SAL_WARN("oox", "lcl_parsePathGluePoints: unexpected token: " 
<< aToken);
+nStart = i + strlen(", ");
+}
+}
+}
+
 void lcl_parsePathSegmentValues(std::vector& rPath, 
const OString& rValue)
 {
 std::vector aSegments;
@@ -725,6 +790,8 @@ void lcl_parsePath(std::vector& 
rPath, const OString& rVal
 OString aToken = rValue.copy(nStart + strlen("{ "), i - nStart 
- strlen(" },"));
 if (aToken.startsWith("Name = \"Coordinates\""))
 lcl_parsePathCoordinates(rPath, aToken);
+else if (aToken.startsWith("Name = \"GluePoints\""))
+lcl_parsePathGluePoints(rPath, aToken);
 else if (aToken.startsWith("Name = \"Segments\""))
 lcl_parsePathSegments(rPath, aToken);
 else if (aToken.startsWith("Name = \"TextFrames\""))
diff --git a/oox/source/drawingml/customshapes/oox-drawingml-cs-presets 

[Libreoffice-commits] core.git: oox/source sd/qa

2022-02-28 Thread Attila Bakos (NISZ) (via logerrit)
 oox/source/export/drawingml.cxx |   15 ++-
 sd/qa/unit/data/pptx/tdf147121.pptx |binary
 sd/qa/unit/export-tests-ooxml3.cxx  |   32 
 3 files changed, 46 insertions(+), 1 deletion(-)

New commits:
commit f29c14e8c36819296d0c66bb995201acf0a2647e
Author: Attila Bakos (NISZ) 
AuthorDate: Wed Feb 16 16:09:00 2022 +0100
Commit: László Németh 
CommitDate: Mon Feb 28 14:53:55 2022 +0100

tdf#147121 PPTX: fix regression of font size export of empty lines

If the empty line has got direct formatted font size,
don't forget to export it, unless the master setting
is applied.

Regression from commit b6b02e0b4c9d739836e1f61a886ea45b01e6696e
"tdf#111903 tdf#137152 PPTX export: fix placeholders".

Change-Id: If686e487bca9c198fd7c96860a21e4efe91381bb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130005
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 6e4197fa69c3..835654d7f3a2 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2534,6 +2534,10 @@ void DrawingML::WriteRun( const Reference< XTextRange >& 
rRun,
 if (GetProperty(rXPropSet, "NumberingIsNumber"))
 mAny >>= bNumberingIsNumber;
 
+float nFontSize = -1;
+if (GetProperty(rXPropSet, "CharHeight"))
+mAny >>= nFontSize;
+
 bool bIsURLField = false;
 OUString sFieldValue = GetFieldValue( rRun, bIsURLField );
 bool bWriteField  = !( sFieldValue.isEmpty() || bIsURLField );
@@ -2566,7 +2570,16 @@ void DrawingML::WriteRun( const Reference< XTextRange >& 
rRun,
 
 if (sText == "\n")
 {
-mpFS->singleElementNS(XML_a, XML_br);
+// Empty run? Do not forget to write the font size in case of pptx:
+if ((GetDocumentType() == DOCUMENT_PPTX) && (nFontSize != -1))
+{
+mpFS->startElementNS(XML_a, XML_br);
+mpFS->singleElementNS(XML_a, XML_rPr, XML_sz,
+  OString::number(nFontSize * 100).getStr());
+mpFS->endElementNS(XML_a, XML_br);
+}
+else
+mpFS->singleElementNS(XML_a, XML_br);
 }
 else
 {
diff --git a/sd/qa/unit/data/pptx/tdf147121.pptx 
b/sd/qa/unit/data/pptx/tdf147121.pptx
new file mode 100644
index ..5762a4b9216b
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf147121.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index cb1ad50ac2ed..58b4d3680da9 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -103,6 +103,7 @@ public:
 void testTdf143222_embeddedWorksheet();
 void testTdf142235_TestPlaceholderTextAlignment();
 void testTdf143315();
+void testTdf147121();
 void testTdf140912_PicturePlaceholder();
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest3);
@@ -177,6 +178,7 @@ public:
 CPPUNIT_TEST(testTdf143222_embeddedWorksheet);
 CPPUNIT_TEST(testTdf142235_TestPlaceholderTextAlignment);
 CPPUNIT_TEST(testTdf143315);
+CPPUNIT_TEST(testTdf147121);
 CPPUNIT_TEST(testTdf140912_PicturePlaceholder);
 CPPUNIT_TEST_SUITE_END();
 
@@ -1828,6 +1830,36 @@ void SdOOXMLExportTest3::testTdf143315()
 assertXPath(pXml, 
"/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:pPr/a:buChar", 0);
 }
 
+void SdOOXMLExportTest3::testTdf147121()
+{
+// Get the bugdoc
+::sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf147121.pptx"), 
PPTX);
+
+CPPUNIT_ASSERT(xDocShRef);
+// Get the second line props of the placeholder
+uno::Reference xPage(getPage(0, xDocShRef));
+uno::Reference xShape(xPage->getByIndex(0), 
uno::UNO_QUERY_THROW);
+uno::Reference xRun(
+getRunFromParagraph(2, getParagraphFromShape(0, xShape)), 
uno::UNO_QUERY_THROW);
+
+// Save the font size
+const auto nFontSizeBefore = 
xRun->getPropertyValue("CharHeight").get() * 100;
+
+// Save and reload
+utl::TempFile tmpfile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+xDocShRef->DoClose();
+
+// Parse the export
+xmlDocUniquePtr pXml = parseExport(tmpfile, "ppt/slides/slide1.xml");
+const auto nFontSizeAfter
+= getXPath(pXml, 
"/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:br[1]/a:rPr", "sz").toFloat();
+
+// The font size was not saved before now it must be equal with the saved 
one.
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected font size", nFontSizeBefore, 
nFontSizeAfter);
+}
+
 void SdOOXMLExportTest3::testTdf140912_PicturePlaceholder()
 {
 ::sd::DrawDocShellRef xDocShRef = loadURL(


[Libreoffice-commits] core.git: oox/source sd/qa

2022-02-28 Thread Tünde Tóth (via logerrit)
 oox/source/drawingml/fillproperties.cxx |4 +++-
 sd/qa/unit/data/pptx/tdf128596.pptx |binary
 sd/qa/unit/import-tests2.cxx|   17 +
 3 files changed, 20 insertions(+), 1 deletion(-)

New commits:
commit 259a8e59107bb0a3d4f4f4bb7e056ce1e4231da2
Author: Tünde Tóth 
AuthorDate: Thu Feb 3 15:13:33 2022 +0100
Commit: László Németh 
CommitDate: Mon Feb 28 14:15:22 2022 +0100

tdf#128596 PPTX import: fix default tiled bitmap fill

OOXML bitmap fill element a:blipFill has got default tiled
area setting without explicit a:tile in MSO. Previous import
of bitmap fill as "BitmapMode_NO_REPEAT" instead of
BitmapMode_REPEAT resulted missing or incomplete area fill
of shapes and other objects.

Change-Id: Idf94f4450980f67172a0126784b3e08cc5c178c2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129483
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/drawingml/fillproperties.cxx 
b/oox/source/drawingml/fillproperties.cxx
index 2b682bcd1b99..49906cc9b10f 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -221,7 +221,9 @@ BitmapMode lclGetBitmapMode( sal_Int32 nToken )
 case XML_tile:  return BitmapMode_REPEAT;
 case XML_stretch:   return BitmapMode_STRETCH;
 }
-return BitmapMode_NO_REPEAT;
+
+// tdf#128596 Default value is XML_tile for MSO.
+return BitmapMode_REPEAT;
 }
 
 RectanglePoint lclGetRectanglePoint( sal_Int32 nToken )
diff --git a/sd/qa/unit/data/pptx/tdf128596.pptx 
b/sd/qa/unit/data/pptx/tdf128596.pptx
new file mode 100644
index ..62a166308dc2
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf128596.pptx differ
diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx
index 7c0844e354b9..2654e6f6290e 100644
--- a/sd/qa/unit/import-tests2.cxx
+++ b/sd/qa/unit/import-tests2.cxx
@@ -128,6 +128,7 @@ public:
 void testTdf103347();
 void testHyperlinksOnShapes();
 void testTdf112209();
+void testTdf128596();
 
 CPPUNIT_TEST_SUITE(SdImportTest2);
 
@@ -192,6 +193,7 @@ public:
 CPPUNIT_TEST(testTdf103347);
 CPPUNIT_TEST(testHyperlinksOnShapes);
 CPPUNIT_TEST(testTdf112209);
+CPPUNIT_TEST(testTdf128596);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -1890,6 +1892,21 @@ void SdImportTest2::testTdf112209()
 xDocShRef->DoClose();
 }
 
+void SdImportTest2::testTdf128596()
+{
+sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf128596.pptx"), 
PPTX);
+uno::Reference xShape(getShapeFromPage(0, 0, 
xDocShRef),
+   uno::UNO_SET_THROW);
+CPPUNIT_ASSERT(xShape.is());
+
+css::drawing::BitmapMode bitmapmode;
+xShape->getPropertyValue("FillBitmapMode") >>= bitmapmode;
+CPPUNIT_ASSERT_EQUAL(css::drawing::BitmapMode_REPEAT, bitmapmode);
+
+xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest2);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


[Libreoffice-commits] core.git: oox/source sd/qa

2022-02-02 Thread Tünde Tóth (via logerrit)
 oox/source/drawingml/fillproperties.cxx |3 +++
 sd/qa/unit/data/pptx/tdf112209.pptx |binary
 sd/qa/unit/import-tests2.cxx|   26 ++
 3 files changed, 29 insertions(+)

New commits:
commit 1bce0e3004e3ec9d62a3c43801f8f2e8ef5f7fdb
Author: Tünde Tóth 
AuthorDate: Wed Jan 19 14:53:50 2022 +0100
Commit: László Németh 
CommitDate: Wed Feb 2 17:27:00 2022 +0100

tdf#112209 PPTX import: fix grayscale effect on image filled shape

Some image filled shapes with grayscale effect in PPTX documents
created with PowerPoint were not grayscale in Impress.

Change-Id: I0a89f283f525eb47c21c5d5fa788484d8074a7e4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128616
Tested-by: Jenkins
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/drawingml/fillproperties.cxx 
b/oox/source/drawingml/fillproperties.cxx
index 480bbe641737..5d17c321d0f8 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -722,6 +722,9 @@ void FillProperties::pushToPropMap( ShapePropertyMap& 
rPropMap,
 
 if (xGraphic.is())
 {
+if (maBlipProps.moColorEffect.get(XML_TOKEN_INVALID) == 
XML_grayscl)
+xGraphic = lclGreysScaleGraphic(xGraphic);
+
 if 
(rPropMap.supportsProperty(ShapeProperty::FillBitmapName) &&
 rPropMap.setProperty(ShapeProperty::FillBitmapName, 
xGraphic))
 {
diff --git a/sd/qa/unit/data/pptx/tdf112209.pptx 
b/sd/qa/unit/data/pptx/tdf112209.pptx
new file mode 100644
index ..80865820dfad
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf112209.pptx differ
diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx
index 04e365bfa130..7c0844e354b9 100644
--- a/sd/qa/unit/import-tests2.cxx
+++ b/sd/qa/unit/import-tests2.cxx
@@ -127,6 +127,7 @@ public:
 void testTdf49856();
 void testTdf103347();
 void testHyperlinksOnShapes();
+void testTdf112209();
 
 CPPUNIT_TEST_SUITE(SdImportTest2);
 
@@ -190,6 +191,7 @@ public:
 CPPUNIT_TEST(testTdf134210CropPosition);
 CPPUNIT_TEST(testTdf103347);
 CPPUNIT_TEST(testHyperlinksOnShapes);
+CPPUNIT_TEST(testTdf112209);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -1864,6 +1866,30 @@ void SdImportTest2::testHyperlinksOnShapes()
 xDocShRef->DoClose();
 }
 
+void SdImportTest2::testTdf112209()
+{
+sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf112209.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());
+
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: Color: R:132 G:132 B:132 A:0
+// - Actual  : Color: R:21 G:170 B:236 A:0
+// i.e. the image color was blue instead of grey.
+CPPUNIT_ASSERT_EQUAL(Color(0x848484), aBitmap.GetPixelColor(0, 0));
+
+xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest2);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


[Libreoffice-commits] core.git: oox/source sd/qa

2022-02-02 Thread Tibor Nagy (via logerrit)
 oox/source/export/drawingml.cxx |6 ++
 sd/qa/unit/data/pptx/tdf137675.pptx |binary
 sd/qa/unit/export-tests-ooxml1.cxx  |   14 ++
 3 files changed, 20 insertions(+)

New commits:
commit 22b66d4083d34cbce2b7b48daeed3152bf9877b7
Author: Tibor Nagy 
AuthorDate: Tue Jan 4 14:38:47 2022 +0100
Commit: László Németh 
CommitDate: Wed Feb 2 11:37:07 2022 +0100

tdf#137675 PPTX export: adding missing fill="none" to a:path

Follow-up to commit 9310e47e2ce71348a16e5412131946348833f4b2
"tdf#101122 DOCX custom shape export: remove bad fill".

Change-Id: I2acdae3964c31ee366387d9938fe366405dcace9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127944
Tested-by: Jenkins
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index cdc026375d10..09ca9c22915a 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -3796,9 +3796,14 @@ bool DrawingML::WriteCustomGeometry(
   XML_r, "r", XML_b, "b");
 mpFS->startElementNS(XML_a, XML_pathLst);
 
+std::optional sFill;
+if (HasEnhancedCustomShapeSegmentCommand(rXShape, 
css::drawing::EnhancedCustomShapeSegmentCommand::NOFILL))
+sFill = "none"; // for possible values see ST_PathFillMode 
in OOXML standard
+
 if ( aPathSize.hasElements() )
 {
 mpFS->startElementNS( XML_a, XML_path,
+  XML_fill, sFill,
   XML_w, OString::number(aPathSize[0].Width),
   XML_h, OString::number(aPathSize[0].Height) );
 }
@@ -3825,6 +3830,7 @@ bool DrawingML::WriteCustomGeometry(
 nYMax = nY;
 }
 mpFS->startElementNS( XML_a, XML_path,
+  XML_fill, sFill,
   XML_w, OString::number(nXMax - nXMin),
   XML_h, OString::number(nYMax - nYMin) );
 }
diff --git a/sd/qa/unit/data/pptx/tdf137675.pptx 
b/sd/qa/unit/data/pptx/tdf137675.pptx
new file mode 100644
index ..d4d767aa5246
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf137675.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx 
b/sd/qa/unit/export-tests-ooxml1.cxx
index 76e54f62ea1b..db33355b9bc6 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -113,6 +113,7 @@ public:
 void testTdf143126();
 void testTdf143129();
 void testTdf118045();
+void testTdf137675();
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest1);
 
@@ -181,6 +182,7 @@ public:
 CPPUNIT_TEST(testTdf143126);
 CPPUNIT_TEST(testTdf143129);
 CPPUNIT_TEST(testTdf118045);
+CPPUNIT_TEST(testTdf137675);
 
 CPPUNIT_TEST_SUITE_END();
 
@@ -1749,6 +1751,18 @@ void SdOOXMLExportTest1::testTdf118045()
 "11");
 }
 
+void SdOOXMLExportTest1::testTdf137675()
+{
+sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf137675.pptx"), 
PPTX);
+utl::TempFile tempFile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+xDocShRef->DoClose();
+
+xmlDocUniquePtr pXmlDoc = parseExport(tempFile, "ppt/slides/slide1.xml");
+assertXPath(pXmlDoc, 
"/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:custGeom/a:pathLst/a:path", "fill", 
"none");
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest1);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


[Libreoffice-commits] core.git: oox/source sd/qa

2022-01-03 Thread Tünde Tóth (via logerrit)
 oox/source/drawingml/textcharacterproperties.cxx |8 +-
 oox/source/export/drawingml.cxx  |   24 +-
 sd/qa/unit/uiimpress.cxx |   91 +--
 3 files changed, 117 insertions(+), 6 deletions(-)

New commits:
commit 678790f292b63c9def1f0427df20028a1f734c15
Author: Tünde Tóth 
AuthorDate: Thu Dec 16 15:10:33 2021 +0100
Commit: László Németh 
CommitDate: Mon Jan 3 14:40:09 2022 +0100

tdf#127696 PPTX export: fix lost outline character formatting

Now outline font property export is supported partially in PPTX
export and in text shape export in other OOXML formats.

Note: OOXML/MSO has customizable Text Fill and Text Outline in
Format Text Effects, while LO has only simple and buggy outline
character formatting property, showing only white or completely
transparent outline fill color. Transparency issues and the buggy
outline font handling of LO (e.g. 1% font color (line) transparency
results 100% fill transparency of the outline text) haven't been
handled yet.

Change-Id: Ic34bce4efd4a544d799b1d89af1107c4918061d8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126996
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/drawingml/textcharacterproperties.cxx 
b/oox/source/drawingml/textcharacterproperties.cxx
index 7ffeaeba8da2..9d568cd5cabb 100644
--- a/oox/source/drawingml/textcharacterproperties.cxx
+++ b/oox/source/drawingml/textcharacterproperties.cxx
@@ -111,6 +111,7 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& 
rPropMap, const XmlFil
 if ( maFillProperties.moFillType.has() )
 {
 Color aColor = maFillProperties.getBestSolidColor();
+bool bContoured = false;
 
 // noFill doesn't exist for characters. Map noFill to 99% transparency
 if (maFillProperties.moFillType.get() == XML_noFill)
@@ -124,7 +125,11 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& 
rPropMap, const XmlFil
 {
 Color aLineColor = 
moTextOutlineProperties.get().maLineFill.getBestSolidColor();
 sal_Int16 nLineTransparency = aLineColor.getTransparency();
-if (nLineTransparency < aColor.getTransparency())
+
+// tdf#127696 If the text color is white (and the outline color 
doesn't dominate),
+//then this is contoured text in LO.
+if (nLineTransparency < aColor.getTransparency()
+|| (bContoured = aColor.getColor(rFilter.getGraphicHelper()) 
== COL_WHITE))
 aColor = aLineColor;
 }
 rPropMap.setProperty(PROP_CharColor, 
aColor.getColor(rFilter.getGraphicHelper()));
@@ -133,6 +138,7 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& 
rPropMap, const XmlFil
 rPropMap.setProperty(PROP_CharColorTintOrShade, 
aColor.getTintOrShade());
 rPropMap.setProperty(PROP_CharColorLumMod, aColor.getLumMod());
 rPropMap.setProperty(PROP_CharColorLumOff, aColor.getLumOff());
+rPropMap.setProperty(PROP_CharContoured, bContoured);
 
 if (aColor.hasTransparency())
 {
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 8581535357a0..d87c6cccddee 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2201,9 +2201,31 @@ void DrawingML::WriteRunProperties( const Reference< 
XPropertySet >& rRun, bool
 nTransparency = MAX_PERCENT - (nTransparency * PER_PERCENT);
 }
 
+bool bContoured = false;
+if (GetProperty(rXPropSet, "CharContoured"))
+bContoured = *o3tl::doAccess(mAny);
+
+// tdf#127696 If the CharContoured is true, then the text color is 
white and the outline color is the CharColor.
+if (bContoured)
+{
+mpFS->startElementNS(XML_a, XML_ln);
+if (color == COL_AUTO)
+{
+mbIsBackgroundDark ? WriteSolidFill(COL_WHITE) : 
WriteSolidFill(COL_BLACK);
+}
+else
+{
+color.SetAlpha(255);
+if (!WriteCharColor(rXPropSet))
+WriteSolidFill(color, nTransparency);
+}
+mpFS->endElementNS(XML_a, XML_ln);
+
+WriteSolidFill(COL_WHITE);
+}
 // tdf#104219 In LibreOffice and MS Office, there are two types of 
colors:
 // Automatic and Fixed. OOXML is setting automatic color, by not 
providing color.
-if( color != COL_AUTO )
+else if( color != COL_AUTO )
 {
 color.SetAlpha(255);
 // TODO: special handle embossed/engraved
diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx
index 2ea61ea63e94..5a773aa8ced6 100644
--- a/sd/qa/unit/uiimpress.cxx
+++ 

[Libreoffice-commits] core.git: oox/source sd/qa

2022-01-03 Thread Tibor Nagy (via logerrit)
 oox/source/ppt/slidefragmenthandler.cxx |5 +
 sd/qa/unit/data/pptx/tdf146223.pptx |binary
 sd/qa/unit/import-tests.cxx |   20 
 3 files changed, 25 insertions(+)

New commits:
commit 4574a1ea408c2ac30042dca32d02207ec7add4da
Author: Tibor Nagy 
AuthorDate: Tue Dec 14 14:44:15 2021 +0100
Commit: László Németh 
CommitDate: Mon Jan 3 13:41:41 2022 +0100

tdf#146223 PPTX import: fix master objects visible property

Master objects were always visible after the import, which
could change the background of the slides.

Change-Id: Idc5260718f2916e207f751286044e9a7fabdee89
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126833
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/ppt/slidefragmenthandler.cxx 
b/oox/source/ppt/slidefragmenthandler.cxx
index 4512ee156261..79ea427b5227 100644
--- a/oox/source/ppt/slidefragmenthandler.cxx
+++ b/oox/source/ppt/slidefragmenthandler.cxx
@@ -78,9 +78,14 @@ SlideFragmentHandler::~SlideFragmentHandler()
 case PPT_TOKEN( sld ):  // CT_CommonSlideData
 {
 Reference< XDrawPage > xSlide( mpSlidePersistPtr->getPage() );
+Reference< css::beans::XPropertySet > xSet(xSlide, UNO_QUERY);
 PropertyMap aPropMap;
 PropertySet aSlideProp( xSlide );
 
+OptValue aShowMasterShapes = rAttribs.getBool(XML_showMasterSp);
+if (aShowMasterShapes.has() && !aShowMasterShapes.get())
+xSet->setPropertyValue("IsBackgroundObjectsVisible", Any(false));
+
 aPropMap.setProperty( PROP_Visible, rAttribs.getBool( XML_show, true 
));
 aSlideProp.setProperties( aPropMap );
 
diff --git a/sd/qa/unit/data/pptx/tdf146223.pptx 
b/sd/qa/unit/data/pptx/tdf146223.pptx
new file mode 100644
index ..73d5eea144cc
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf146223.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 92b08ef32094..303ab76bed7b 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -123,6 +123,7 @@ public:
 virtual void setUp() override;
 
 void testDocumentLayout();
+void testTdf146223();
 void testTdf144918();
 void testTdf144917();
 void testHyperlinkOnImage();
@@ -190,6 +191,7 @@ public:
 CPPUNIT_TEST_SUITE(SdImportTest);
 
 CPPUNIT_TEST(testDocumentLayout);
+CPPUNIT_TEST(testTdf146223);
 CPPUNIT_TEST(testTdf144918);
 CPPUNIT_TEST(testTdf144917);
 CPPUNIT_TEST(testHyperlinkOnImage);
@@ -335,6 +337,24 @@ void SdImportTest::testDocumentLayout()
 }
 }
 
+void SdImportTest::testTdf146223()
+{
+sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf146223.pptx"), 
PPTX);
+
+uno::Reference 
xDoc(xDocShRef->GetDoc()->getUnoModel(),
+ uno::UNO_QUERY_THROW);
+
+uno::Reference 
xPage1(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
+uno::Reference xSet(xPage1, uno::UNO_QUERY_THROW);
+
+bool bBackgroundObjectsVisible;
+xSet->getPropertyValue("IsBackgroundObjectsVisible") >>= 
bBackgroundObjectsVisible;
+CPPUNIT_ASSERT_EQUAL(false, bBackgroundObjectsVisible);
+
+xDocShRef->DoClose();
+}
+
 void SdImportTest::testTdf144918()
 {
 sd::DrawDocShellRef xDocShRef


[Libreoffice-commits] core.git: oox/source sd/qa

2021-12-09 Thread Attila Bakos (NISZ) (via logerrit)
 oox/source/export/drawingml.cxx |6 ++
 sd/qa/unit/data/pptx/tdf145162.pptx |binary
 sd/qa/unit/export-tests-ooxml3.cxx  |   16 
 3 files changed, 22 insertions(+)

New commits:
commit f57cfddb51b7d7409b7b425dc200aa73406a13bd
Author: Attila Bakos (NISZ) 
AuthorDate: Wed Dec 8 10:22:37 2021 +0100
Commit: László Németh 
CommitDate: Thu Dec 9 12:14:51 2021 +0100

tdf#145162 PPTX export: fix extra bullet regression

Placeholders have bullet by default in MSO, so
write  for paragraphs where numbering/bullet
is disabled to avoid extra bullets in Impress.

Regression from commit b6b02e0b4c9d739836e1f61a886ea45b01e6696e
(tdf#111903 tdf#137152 PPTX export: fix placeholders).

Change-Id: Ib4c563cba475d61bc475ca05623e7c7b20fded30
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126528
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 249c897740a9..8581535357a0 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2613,7 +2613,13 @@ static OUString GetAutoNumType(SvxNumType 
nNumberingType, bool bSDot, bool bPBeh
 void DrawingML::WriteParagraphNumbering(const Reference< XPropertySet >& 
rXPropSet, float fFirstCharHeight, sal_Int16 nLevel )
 {
 if (nLevel < 0 || !GetProperty(rXPropSet, "NumberingRules"))
+{
+if (GetDocumentType() == DOCUMENT_PPTX)
+{
+mpFS->singleElementNS(XML_a, XML_buNone);
+}
 return;
+}
 
 Reference< XIndexAccess > rXIndexAccess;
 
diff --git a/sd/qa/unit/data/pptx/tdf145162.pptx 
b/sd/qa/unit/data/pptx/tdf145162.pptx
new file mode 100644
index ..3746740f327c
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf145162.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index 375922511661..1650680a2c30 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -71,6 +71,7 @@ public:
 void testTdf118806();
 void testTdf130058();
 void testTdf111789();
+void testTdf145162();
 void testTdf100348_convert_Fontwork2TextWarp();
 void testTdf1225573_FontWorkScaleX();
 void testTdf99497_keepAppearanceOfCircleKind();
@@ -145,6 +146,7 @@ public:
 CPPUNIT_TEST(testTdf118806);
 CPPUNIT_TEST(testTdf130058);
 CPPUNIT_TEST(testTdf111789);
+CPPUNIT_TEST(testTdf145162);
 CPPUNIT_TEST(testTdf100348_convert_Fontwork2TextWarp);
 CPPUNIT_TEST(testTdf1225573_FontWorkScaleX);
 CPPUNIT_TEST(testTdf99497_keepAppearanceOfCircleKind);
@@ -627,6 +629,20 @@ void SdOOXMLExportTest3::testTdf111789()
 xDocShRef->DoClose();
 }
 
+void SdOOXMLExportTest3::testTdf145162()
+{
+sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf145162.pptx"), 
PPTX);
+utl::TempFile tempFile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, 
"ppt/slides/slide1.xml");
+
+assertXPath(pXmlDocContent, 
"/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[2]/a:pPr/a:buNone");
+// Before the fix, that tag was missing so PP put bullet to each para.
+
+xDocShRef->DoClose();
+}
+
 void SdOOXMLExportTest3::testTdf100348_convert_Fontwork2TextWarp()
 {
 ::sd::DrawDocShellRef xDocShRef = loadURL(


[Libreoffice-commits] core.git: oox/source sd/qa

2021-12-01 Thread gulsahkose (via logerrit)
 oox/source/drawingml/shape.cxx  |   30 
 oox/source/token/properties.txt |1 
 sd/qa/unit/data/pptx/tdfpictureplaceholder.pptx |binary
 sd/qa/unit/export-tests-ooxml3.cxx  |   20 
 4 files changed, 51 insertions(+)

New commits:
commit 7b3be7f6f3d800e2ad86f5a043e6e9b21ed4409f
Author: gulsahkose 
AuthorDate: Wed Dec 1 10:46:41 2021 +0300
Commit: Miklos Vajna 
CommitDate: Wed Dec 1 14:11:36 2021 +0100

tdf#140912 Better handling of the picture placeholders.

To see icon and placeholder text at the center of picture
placeholder shape, we set the TextContourFrame and GraphicCrop
properties.

Change-Id: I49e3d08c9020e593232c60c97af3f45fb620075e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126165
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 9aed4d3588d0..78a27f8a0c9c 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -88,6 +88,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1337,6 +1338,35 @@ Reference< XShape > const & Shape::createAndInsert(
 
propertySet->setPropertyValue("InteropGrabBag",uno::makeAny(aGrabBag));
 }
 
+// If the shape is a picture placeholder.
+if (aServiceName == "com.sun.star.presentation.GraphicObjectShape" 
&& !bClearText)
+{
+// Placeholder text should be in center of the shape.
+aShapeProps.setProperty(PROP_TextContourFrame, false);
+
+/* Placeholder icon should be at the center of the parent 
shape.
+ * We use negative graphic crop property because of that we 
don't
+ * have padding support.
+ */
+uno::Reference 
xGraphic(xSet->getPropertyValue("Graphic"), uno::UNO_QUERY);
+if (xGraphic.is())
+{
+awt::Size aBitmapSize;
+xGraphic->getPropertyValue("Size100thMM") >>= aBitmapSize;
+sal_Int32 nXMargin = (aShapeRectHmm.Width - 
aBitmapSize.Width) / 2;
+sal_Int32 nYMargin = (aShapeRectHmm.Height - 
aBitmapSize.Height) / 2;
+if (nXMargin > 0 && nYMargin > 0)
+{
+text::GraphicCrop aGraphicCrop;
+aGraphicCrop.Top = nYMargin * -1;
+aGraphicCrop.Bottom = nYMargin * -1;
+aGraphicCrop.Left = nXMargin * -1;
+aGraphicCrop.Right = nXMargin * -1;
+aShapeProps.setProperty(PROP_GraphicCrop, 
aGraphicCrop);
+}
+}
+}
+
 PropertySet( xSet ).setProperties( aShapeProps );
 if (mbLockedCanvas)
 {
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index 5d261469ca42..87a6700bd35a 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -541,6 +541,7 @@ TextBreak
 TextCameraZRotateAngle
 TextColor
 TextColumns
+TextContourFrame
 TextFitToSize
 TextFrames
 TextHorizontalAdjust
diff --git a/sd/qa/unit/data/pptx/tdfpictureplaceholder.pptx 
b/sd/qa/unit/data/pptx/tdfpictureplaceholder.pptx
new file mode 100644
index ..d681c749cab0
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdfpictureplaceholder.pptx 
differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index a9a740eb4588..900716e20093 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -38,6 +38,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -120,6 +121,7 @@ public:
 void testTdf143222_embeddedWorksheet();
 void testTdf142235_TestPlaceholderTextAlignment();
 void testTdf143315();
+void testTdf140912_PicturePlaceholder();
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest3);
 
@@ -191,6 +193,7 @@ public:
 CPPUNIT_TEST(testTdf143222_embeddedWorksheet);
 CPPUNIT_TEST(testTdf142235_TestPlaceholderTextAlignment);
 CPPUNIT_TEST(testTdf143315);
+CPPUNIT_TEST(testTdf140912_PicturePlaceholder);
 CPPUNIT_TEST_SUITE_END();
 
 virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override
@@ -1813,6 +1816,23 @@ void SdOOXMLExportTest3::testTdf143315()
 assertXPath(pXml, 
"/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:pPr/a:buChar", 0);
 }
 
+void SdOOXMLExportTest3::testTdf140912_PicturePlaceholder()
+{
+::sd::DrawDocShellRef xDocShRef = loadURL(
+
m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdfpictureplaceholder.pptx"),
 PPTX);
+
+uno::Reference xShapeProps(getShapeFromPage(0, 0, 
xDocShRef));
+bool bTextContourFrame = true;
+xShapeProps->getPropertyValue("TextContourFrame") >>= 

[Libreoffice-commits] core.git: oox/source sd/qa

2021-11-28 Thread Tibor Nagy (via logerrit)
 oox/source/export/drawingml.cxx|7 +--
 sd/qa/unit/data/odp/tdf118045.odp  |binary
 sd/qa/unit/export-tests-ooxml1.cxx |   15 +++
 3 files changed, 20 insertions(+), 2 deletions(-)

New commits:
commit 5db7694a6377d32bdef293b4ece27b471c3ea427
Author: Tibor Nagy 
AuthorDate: Thu Nov 18 09:05:30 2021 +0100
Commit: László Németh 
CommitDate: Mon Nov 29 08:50:47 2021 +0100

tdf#118045 PPTX export: fix proportional line spacing

If line spacing differs from the default 100%, export it
as direct paragraph formatting (similar to the
other paragraph style properties).

Change-Id: Id5db9ae36018c8a20b832470685bdfbba19d80f3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125438
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index af96b14f1ac6..fbe13359dd9b 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2877,8 +2877,11 @@ bool DrawingML::WriteParagraphProperties( const 
Reference< XTextContent >& rPara
 bool bHasLinespacing = false;
 LineSpacing aLineSpacing;
 if (GetPropertyAndState(rXPropSet, rXPropState, "ParaLineSpacing", eState)
-&& eState == beans::PropertyState_DIRECT_VALUE)
-bHasLinespacing = ( mAny >>= aLineSpacing );
+&& (mAny >>= aLineSpacing)
+&& (eState == beans::PropertyState_DIRECT_VALUE ||
+// only export if it differs from the default 100% line spacing
+aLineSpacing.Mode != LineSpacingMode::PROP || aLineSpacing.Height 
!= 100))
+bHasLinespacing = true;
 
 bool bRtl = false;
 if (GetProperty(rXPropSet, "WritingMode"))
diff --git a/sd/qa/unit/data/odp/tdf118045.odp 
b/sd/qa/unit/data/odp/tdf118045.odp
new file mode 100644
index ..8b5fac36af4f
Binary files /dev/null and b/sd/qa/unit/data/odp/tdf118045.odp differ
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx 
b/sd/qa/unit/export-tests-ooxml1.cxx
index 52b580a95e05..9efb79ae9cf1 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -124,6 +124,7 @@ public:
 void testPlaceholderFillAndOutlineExport();
 void testTdf143126();
 void testTdf143129();
+void testTdf118045();
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest1);
 
@@ -190,6 +191,7 @@ public:
 CPPUNIT_TEST(testPlaceholderFillAndOutlineExport);
 CPPUNIT_TEST(testTdf143126);
 CPPUNIT_TEST(testTdf143129);
+CPPUNIT_TEST(testTdf118045);
 
 CPPUNIT_TEST_SUITE_END();
 
@@ -1733,6 +1735,19 @@ void SdOOXMLExportTest1::testTdf143129()
 assertXPath(pXmlDoc, "/p:presentationPr/p:showPr/p:custShow", "id", "0" );
 }
 
+void SdOOXMLExportTest1::testTdf118045()
+{
+sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf118045.odp"), 
ODP);
+utl::TempFile tempFile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+xDocShRef->DoClose();
+
+xmlDocUniquePtr pXmlDoc1 = parseExport(tempFile, "ppt/slides/slide1.xml");
+assertXPath(pXmlDoc1, 
"/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:pPr/a:lnSpc/a:spcPct", "val",
+"11");
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest1);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


[Libreoffice-commits] core.git: oox/source sd/qa

2021-11-24 Thread Tibor Nagy (via logerrit)
 oox/source/export/drawingml.cxx|   27 ++-
 sd/qa/unit/data/odp/tdf124781.odp  |binary
 sd/qa/unit/export-tests-ooxml1.cxx |   19 +++
 3 files changed, 41 insertions(+), 5 deletions(-)

New commits:
commit 98fedbc8501b53a199afa4a879707bf89a7f84e5
Author: Tibor Nagy 
AuthorDate: Tue Nov 16 12:51:37 2021 +0100
Commit: László Németh 
CommitDate: Wed Nov 24 14:38:14 2021 +0100

tdf#124781 PPTX export: fix superscript and subscript positions

"Raise/lower by" character settings were saved incorrectly when
the automatic checkbox is checked.

Change-Id: Ia7260504cde85e14867936c83eaf8735142e2c53
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125302
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 3371c04eac8e..af96b14f1ac6 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -121,6 +121,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1906,6 +1907,7 @@ void DrawingML::WriteRunProperties( const Reference< 
XPropertySet >& rRun, bool
 sal_Int32 nSize = 1800;
 sal_Int32 nCharEscapement = 0;
 sal_Int32 nCharKerning = 0;
+sal_Int32 nCharEscapementHeight = 0;
 
 if ( nElement == XML_endParaRPr && rbOverridingCharHeight )
 {
@@ -2059,12 +2061,27 @@ void DrawingML::WriteRunProperties( const Reference< 
XPropertySet >& rRun, bool
 && eState == beans::PropertyState_DIRECT_VALUE)
 mAny >>= nCharEscapement;
 
-if (nCharEscapement
-&& (GetPropertyAndState(rXPropSet, rXPropState, 
"CharEscapementHeight", eState)
-&& eState == beans::PropertyState_DIRECT_VALUE))
-{
-sal_uInt32 nCharEscapementHeight = 0;
+if (GetPropertyAndState(rXPropSet, rXPropState, "CharEscapementHeight", 
eState)
+&& eState == beans::PropertyState_DIRECT_VALUE)
 mAny >>= nCharEscapementHeight;
+
+if (DFLT_ESC_AUTO_SUPER == nCharEscapement)
+{
+// Raised by the differences between the ascenders (ascent = baseline 
to top of highest letter).
+// The ascent is generally about 80% of the total font height.
+// That is why DFLT_ESC_PROP (58) leads to 33% (DFLT_ESC_SUPER)
+nCharEscapement = .8 * (100 - nCharEscapementHeight);
+}
+else if (DFLT_ESC_AUTO_SUB == nCharEscapement)
+{
+// Lowered by the differences between the descenders (descent = 
baseline to bottom of lowest letter).
+// The descent is generally about 20% of the total font height.
+// That is why DFLT_ESC_PROP (58) leads to 8% (DFLT_ESC_SUB)
+nCharEscapement = .2 * -(100 - nCharEscapementHeight);
+}
+
+if (nCharEscapement && nCharEscapementHeight)
+{
 nSize = (nSize * nCharEscapementHeight) / 100;
 // MSO uses default ~58% size
 nSize = (nSize / 0.58);
diff --git a/sd/qa/unit/data/odp/tdf124781.odp 
b/sd/qa/unit/data/odp/tdf124781.odp
new file mode 100644
index ..199287db51d3
Binary files /dev/null and b/sd/qa/unit/data/odp/tdf124781.odp differ
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx 
b/sd/qa/unit/export-tests-ooxml1.cxx
index a1512615ed8f..52b580a95e05 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -61,6 +61,7 @@ using namespace css;
 class SdOOXMLExportTest1 : public SdModelTestBaseXML
 {
 public:
+void testTdf124781();
 void testTdf144914();
 void testTdf124232();
 void testTdf143624();
@@ -126,6 +127,7 @@ public:
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest1);
 
+CPPUNIT_TEST(testTdf124781);
 CPPUNIT_TEST(testTdf144914);
 CPPUNIT_TEST(testTdf124232);
 CPPUNIT_TEST(testTdf143624);
@@ -218,6 +220,23 @@ void checkFontAttributes( const SdrTextObj* pObj, 
ItemValue nVal, sal_uInt32 nId
 
 }
 
+void SdOOXMLExportTest1::testTdf124781()
+{
+sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf124781.odp"), 
ODP);
+utl::TempFile tempFile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+xDocShRef->DoClose();
+
+xmlDocUniquePtr pXmlDoc1 = parseExport(tempFile, "ppt/slides/slide1.xml");
+assertXPath(pXmlDoc1, 
"/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p[1]/a:r[2]/a:rPr", "baseline",
+"33000");
+
+xmlDocUniquePtr pXmlDoc2 = parseExport(tempFile, "ppt/slides/slide1.xml");
+assertXPath(pXmlDoc2, 
"/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p[2]/a:r[2]/a:rPr", "baseline",
+"-8000");
+}
+
 void SdOOXMLExportTest1::testTdf144914()
 {
 sd::DrawDocShellRef xDocShRef


[Libreoffice-commits] core.git: oox/source sd/qa

2021-11-20 Thread Justin Luth (via logerrit)
 oox/source/drawingml/textcharacterproperties.cxx |5 +
 sd/qa/unit/data/pptx/tdf118776.pptx  |binary
 sd/qa/unit/import-tests2.cxx |   23 +++
 3 files changed, 28 insertions(+)

New commits:
commit 823a351adb0384598304d597ae7f637079ca6175
Author: Justin Luth 
AuthorDate: Tue Nov 16 13:46:07 2021 +0200
Commit: Justin Luth 
CommitDate: Sat Nov 20 15:13:02 2021 +0100

tdf#118776 drawingml: treat XML_nofill as (mostly) transparent

100% transparent typically ends up as COL_AUTO which
certainly doesn't do what is intended.
So set as 99% transparent to get effectively
the same invisible effect.

Adapted patch and re-used unit test from an earlier
commit authored by Xisco. This depends on tdf#137438
not spamming the text properties with outline props.

Only one existing unit test that matched this condition:
-export-tests-ooxml1.cxx customxml.pptx
   -empty textbox - text entered here SHOULD be invisible.

Change-Id: I077b748e500713188421f0eeefdfd85c46555e84
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125301
Tested-by: Jenkins
Tested-by: Xisco Fauli 
Reviewed-by: Xisco Fauli 
Reviewed-by: Justin Luth 

diff --git a/oox/source/drawingml/textcharacterproperties.cxx 
b/oox/source/drawingml/textcharacterproperties.cxx
index 9200e9666cbf..a34cb14af639 100644
--- a/oox/source/drawingml/textcharacterproperties.cxx
+++ b/oox/source/drawingml/textcharacterproperties.cxx
@@ -111,6 +111,11 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& 
rPropMap, const XmlFil
 if ( maFillProperties.moFillType.has() )
 {
 Color aColor = maFillProperties.getBestSolidColor();
+
+// noFill doesn't exist for characters. Map noFill to 99% transparency
+if (maFillProperties.moFillType.get() == XML_noFill)
+aColor.addTransformation(XML_alpha, 1000);
+
 // tdf#137438 Emulate text outline color/transparency.
 // If the outline color dominates, then use it as the text color.
 if (moTextOutlineProperties.has()
diff --git a/sd/qa/unit/data/pptx/tdf118776.pptx 
b/sd/qa/unit/data/pptx/tdf118776.pptx
new file mode 100644
index ..8df94522ab29
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf118776.pptx differ
diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx
index 9a5021f533b6..c299ad4303dd 100644
--- a/sd/qa/unit/import-tests2.cxx
+++ b/sd/qa/unit/import-tests2.cxx
@@ -118,6 +118,7 @@ public:
 void testTdf103792();
 void testTdf103876();
 void testTdf79007();
+void testTdf118776();
 void testTdf129686();
 void testTdf104015();
 void testTdf104201();
@@ -183,6 +184,7 @@ public:
 CPPUNIT_TEST(testTdf103792);
 CPPUNIT_TEST(testTdf103876);
 CPPUNIT_TEST(testTdf79007);
+CPPUNIT_TEST(testTdf118776);
 CPPUNIT_TEST(testTdf129686);
 CPPUNIT_TEST(testTdf104015);
 CPPUNIT_TEST(testTdf104201);
@@ -547,6 +549,27 @@ void SdImportTest2::testTdf79007()
 xDocShRef->DoClose();
 }
 
+void SdImportTest2::testTdf118776()
+{
+sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf118776.pptx"), 
PPTX);
+uno::Reference xShape(getShapeFromPage(0, 0, 
xDocShRef));
+
+// Get first paragraph of the text
+uno::Reference const xParagraph(getParagraphFromShape(0, 
xShape));
+
+// Get first run of the paragraph
+uno::Reference xRun(getRunFromParagraph(0, xParagraph));
+uno::Reference xPropSet(xRun, uno::UNO_QUERY_THROW);
+sal_Int16 nTransparency = 0;
+xPropSet->getPropertyValue("CharTransparence") >>= nTransparency;
+
+// Import noFill color as 99% transparency
+CPPUNIT_ASSERT_EQUAL(static_cast(99), nTransparency);
+
+xDocShRef->DoClose();
+}
+
 void SdImportTest2::testTdf129686()
 {
 sd::DrawDocShellRef xDocShRef


[Libreoffice-commits] core.git: oox/source sd/qa

2021-11-04 Thread Tibor Nagy (via logerrit)
 oox/source/ppt/pptshape.cxx |   18 ++
 sd/qa/unit/data/pptx/tdf144918.pptx |binary
 sd/qa/unit/import-tests.cxx |   28 
 3 files changed, 46 insertions(+)

New commits:
commit cec1f712c87e557e1b7313e0dbef4a635f69d953
Author: Tibor Nagy 
AuthorDate: Mon Oct 25 09:15:20 2021 +0200
Commit: László Németh 
CommitDate: Thu Nov 4 11:50:51 2021 +0100

tdf#144918 PPTX import: fix internal hyperlink on shapes

Slide names in internal hyperlinks of shapes could be replaced
with the placeholder name 'Slide n', resulting non-functioning
hyperlink during the slideshow.

Follow-up to commit 83d92437e05a9ec872d9303953fa408dd4dcbcde
"tdf#144616 PPTX import: fix hyperlinks on shapes".

Change-Id: I733ddcdcdf92b32c4e6272d3cf48da872a63cd47
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124135
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx
index 2a134ada4a0c..b703f615d0cf 100644
--- a/oox/source/ppt/pptshape.cxx
+++ b/oox/source/ppt/pptshape.cxx
@@ -592,7 +592,25 @@ void PPTShape::addShape(
 if (!sURL.startsWith("#"))
 meClickAction = ClickAction_DOCUMENT;
 else
+{
 sURL = sURL.copy(1);
+sal_Int32 nPageNumber = 0;
+static const OUStringLiteral sSlide = u"Slide ";
+if (sURL.match(sSlide))
+nPageNumber = 
sURL.copy(sSlide.getLength()).toInt32();
+Reference 
xDPS(rFilterBase.getModel(),
+
uno::UNO_QUERY_THROW);
+Reference 
xDrawPages(xDPS->getDrawPages(),
+  
uno::UNO_SET_THROW);
+sal_Int32 nMaxPages = xDrawPages->getCount();
+if (nPageNumber && nPageNumber <= nMaxPages)
+{
+Reference xDrawPage;
+xDrawPages->getByIndex(nPageNumber - 1) >>= 
xDrawPage;
+Reference xNamed(xDrawPage, 
UNO_QUERY);
+sURL = xNamed->getName();
+}
+}
 nPropertyCount += 1;
 }
 
diff --git a/sd/qa/unit/data/pptx/tdf144918.pptx 
b/sd/qa/unit/data/pptx/tdf144918.pptx
new file mode 100644
index ..54f862bd1b48
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf144918.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index e1b71fd788cf..92b08ef32094 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -123,6 +123,7 @@ public:
 virtual void setUp() override;
 
 void testDocumentLayout();
+void testTdf144918();
 void testTdf144917();
 void testHyperlinkOnImage();
 void testTdf142645();
@@ -189,6 +190,7 @@ public:
 CPPUNIT_TEST_SUITE(SdImportTest);
 
 CPPUNIT_TEST(testDocumentLayout);
+CPPUNIT_TEST(testTdf144918);
 CPPUNIT_TEST(testTdf144917);
 CPPUNIT_TEST(testHyperlinkOnImage);
 CPPUNIT_TEST(testTdf142645);
@@ -333,6 +335,32 @@ void SdImportTest::testDocumentLayout()
 }
 }
 
+void SdImportTest::testTdf144918()
+{
+sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf144918.pptx"), 
PPTX);
+
+uno::Reference< beans::XPropertySet > xShape1(getShapeFromPage(0, 1, 
xDocShRef));
+uno::Reference xEventsSupplier1(xShape1, 
uno::UNO_QUERY);
+uno::Reference 
xEvents1(xEventsSupplier1->getEvents());
+uno::Sequence props1;
+xEvents1->getByName("OnClick") >>= props1;
+comphelper::SequenceAsHashMap map1(props1);
+auto iter1(map1.find("Bookmark"));
+CPPUNIT_ASSERT_EQUAL(OUString("First slide"), 
iter1->second.get());
+
+uno::Reference< beans::XPropertySet > xShape2(getShapeFromPage(1, 1, 
xDocShRef));
+uno::Reference xEventsSupplier2(xShape2, 
uno::UNO_QUERY);
+uno::Reference 
xEvents2(xEventsSupplier2->getEvents());
+uno::Sequence props2;
+xEvents2->getByName("OnClick") >>= props2;
+comphelper::SequenceAsHashMap map2(props2);
+auto iter2(map2.find("Bookmark"));
+CPPUNIT_ASSERT_EQUAL(OUString("Third slide"), 
iter2->second.get());
+
+xDocShRef->DoClose();
+}
+
 void SdImportTest::testTdf144917()
 {
 sd::DrawDocShellRef xDocShRef


[Libreoffice-commits] core.git: oox/source sd/qa

2021-11-03 Thread Tibor Nagy (via logerrit)
 oox/source/export/shapes.cxx   |   56 +
 sd/qa/unit/export-tests-ooxml1.cxx |   45 +
 2 files changed, 101 insertions(+)

New commits:
commit 4bfe8304a5600e236043e4ad7c6dc75fd05c937b
Author: Tibor Nagy 
AuthorDate: Mon Oct 18 14:51:05 2021 +0200
Commit: László Németh 
CommitDate: Wed Nov 3 15:01:31 2021 +0100

tdf#144914 PPTX export: fix interactions and hyperlinks on shapes

Follow-up to commit 83d92437e05a9ec872d9303953fa408dd4dcbcde
"tdf#144616 PPTX import: fix hyperlinks on shapes"

Change-Id: I56538da8d97e052af03c78e8d7eaa16c5c2fde1e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123748
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 1dd77a34b2ab..776f8df83472 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -837,6 +837,62 @@ ShapeExport& ShapeExport::WriteCustomShape( const 
Reference< XShape >& xShape )
 mpFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, 
XML_id), sRelId);
 }
 }
+
+OUString sBookmark;
+if (GETA(Bookmark))
+mAny >>= sBookmark;
+
+if (GETA(OnClick))
+{
+OUString sPPAction;
+presentation::ClickAction eClickAction = 
presentation::ClickAction_NONE;
+mAny >>= eClickAction;
+if (eClickAction != presentation::ClickAction_NONE)
+{
+switch (eClickAction)
+{
+case presentation::ClickAction_STOPPRESENTATION:
+sPPAction = "ppaction://hlinkshowjump?jump=endshow";
+break;
+case presentation::ClickAction_NEXTPAGE:
+sPPAction = "ppaction://hlinkshowjump?jump=nextslide";
+break;
+case presentation::ClickAction_LASTPAGE:
+sPPAction = "ppaction://hlinkshowjump?jump=lastslide";
+break;
+case presentation::ClickAction_PREVPAGE:
+sPPAction = 
"ppaction://hlinkshowjump?jump=previousslide";
+break;
+case presentation::ClickAction_FIRSTPAGE:
+sPPAction = "ppaction://hlinkshowjump?jump=firstslide";
+break;
+case presentation::ClickAction_BOOKMARK:
+sBookmark = "#" + sBookmark;
+break;
+default:
+break;
+}
+}
+if (!sPPAction.isEmpty())
+pFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, 
XML_id), "", XML_action,
+ sPPAction);
+}
+if (!sBookmark.isEmpty())
+{
+bool bExtURL = URLTransformer().isExternalURL(sBookmark);
+sBookmark = bExtURL ? sBookmark : 
lcl_GetTarget(GetFB()->getModel(), sBookmark);
+
+OUString sRelId
+= mpFB->addRelation(mpFS->getOutputStream(),
+bExtURL ? 
oox::getRelationship(Relationship::HYPERLINK)
+: 
oox::getRelationship(Relationship::SLIDE),
+sBookmark, bExtURL);
+if (bExtURL)
+mpFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, 
XML_id), sRelId);
+else
+mpFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, 
XML_id), sRelId,
+  XML_action, "ppaction://hlinksldjump");
+}
 pFS->endElementNS(mnXmlNamespace, XML_cNvPr);
 pFS->singleElementNS(mnXmlNamespace, XML_cNvSpPr);
 WriteNonVisualProperties( xShape );
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx 
b/sd/qa/unit/export-tests-ooxml1.cxx
index 07c0011bec40..a1512615ed8f 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -61,6 +61,7 @@ using namespace css;
 class SdOOXMLExportTest1 : public SdModelTestBaseXML
 {
 public:
+void testTdf144914();
 void testTdf124232();
 void testTdf143624();
 void testTdf142648();
@@ -125,6 +126,7 @@ public:
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest1);
 
+CPPUNIT_TEST(testTdf144914);
 CPPUNIT_TEST(testTdf124232);
 CPPUNIT_TEST(testTdf143624);
 CPPUNIT_TEST(testTdf142648);
@@ -216,6 +218,49 @@ void checkFontAttributes( const SdrTextObj* pObj, 
ItemValue nVal, sal_uInt32 nId
 
 }
 
+void SdOOXMLExportTest1::testTdf144914()
+{
+sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf144616.pptx"), 
PPTX);
+utl::TempFile tempFile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+xDocShRef->DoClose();
+
+   

[Libreoffice-commits] core.git: oox/source sd/qa

2021-10-20 Thread Tibor Nagy (via logerrit)
 oox/source/ppt/pptshape.cxx |  143 
 sd/qa/unit/data/pptx/tdf144917.pptx |binary
 sd/qa/unit/import-tests.cxx |   21 +
 3 files changed, 101 insertions(+), 63 deletions(-)

New commits:
commit 378e8396223a80b96262d7b638a066eb83ba88d6
Author: Tibor Nagy 
AuthorDate: Wed Oct 6 09:31:37 2021 +0200
Commit: László Németh 
CommitDate: Wed Oct 20 12:30:21 2021 +0200

tdf#144917 PPTX import: fix hyperlinks on grouped shapes

Hyperlinks on the shapes of a group shape weren't imported.
Now all of them are imported correctly.

Change-Id: Ic42892650a3492958600232bd7038585f9aa6ae1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123127
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx
index bbc7d2585fd8..2a134ada4a0c 100644
--- a/oox/source/ppt/pptshape.cxx
+++ b/oox/source/ppt/pptshape.cxx
@@ -518,6 +518,8 @@ void PPTShape::addShape(
 }
 }
 
+OUString sURL;
+std::vector>> aURLShapes;
 // if this is a group shape, we have to add also each child shape
 Reference xShapes(xShape, UNO_QUERY);
 if (xShapes.is())
@@ -531,6 +533,15 @@ void PPTShape::addShape(
 {
 rFilterBase.setDiagramFontHeights(nullptr);
 }
+for (size_t i = 0; i < this->getChildren().size(); i++)
+{
+
this->getChildren()[i]->getShapeProperties().getProperty(PROP_URL) >>= sURL;
+if (!sURL.isEmpty())
+{
+Reference xChild = 
this->getChildren()[i]->getXShape();
+aURLShapes.push_back({ sURL, xChild });
+}
+}
 }
 
 if (meFrameType == FRAMETYPE_DIAGRAM)
@@ -539,77 +550,83 @@ void PPTShape::addShape(
 syncDiagramFontHeights();
 }
 
-OUString sURL;
 getShapeProperties().getProperty(PROP_URL) >>= sURL;
-if (!sURL.isEmpty())
+if (!sURL.isEmpty() && !xShapes.is())
+aURLShapes.push_back({ sURL, xShape });
+
+if (!aURLShapes.empty())
 {
-Reference xEventsSupplier(xShape, UNO_QUERY);
-if (!xEventsSupplier.is())
-return;
-
-Reference xEvents(xEventsSupplier->getEvents());
-if (!xEvents.is())
-return;
-
-OUString sAPIEventName;
-sal_Int32 nPropertyCount = 2;
-css::presentation::ClickAction meClickAction;
-uno::Sequence aProperties;
-
-std::map ActionMap = 
{
-{ "#action?jump=nextslide", ClickAction_NEXTPAGE },
-{ "#action?jump=previousslide", ClickAction_PREVPAGE },
-{ "#action?jump=firstslide", ClickAction_FIRSTPAGE },
-{ "#action?jump=lastslide", ClickAction_LASTPAGE },
-{ "#action?jump=endshow", ClickAction_STOPPRESENTATION },
-};
-
-std::map::const_iterator aIt
-= ActionMap.find(sURL);
-aIt != ActionMap.end() ? meClickAction = aIt->second
-   : meClickAction = ClickAction_BOOKMARK;
-
-// ClickAction_BOOKMARK and ClickAction_DOCUMENT share the 
same event
-// so check here if it's a bookmark or a document
-if (meClickAction == ClickAction_BOOKMARK)
+for (auto const& URLShape : aURLShapes)
 {
-if (!sURL.startsWith("#"))
-meClickAction = ClickAction_DOCUMENT;
-else
-sURL = sURL.copy(1);
-nPropertyCount += 1;
-}
+Reference 
xEventsSupplier(URLShape.second, UNO_QUERY);
+if (!xEventsSupplier.is())
+return;
+
+Reference 
xEvents(xEventsSupplier->getEvents());
+if (!xEvents.is())
+return;
+
+OUString sAPIEventName;
+sal_Int32 nPropertyCount = 2;
+css::presentation::ClickAction meClickAction;
+uno::Sequence aProperties;
+
+std::map 
ActionMap = {
+{ "#action?jump=nextslide", ClickAction_NEXTPAGE },
+{ "#action?jump=previousslide", ClickAction_PREVPAGE },
+{ "#action?jump=firstslide", ClickAction_FIRSTPAGE },
+{ "#action?jump=lastslide", ClickAction_LASTPAGE },
+{ "#action?jump=endshow", ClickAction_STOPPRESENTATION 
},
+   

[Libreoffice-commits] core.git: oox/source sd/qa

2021-10-13 Thread Tibor Nagy (via logerrit)
 oox/source/export/shapes.cxx   |   88 ++---
 sd/qa/unit/export-tests-ooxml1.cxx |   44 ++
 2 files changed, 127 insertions(+), 5 deletions(-)

New commits:
commit 73f26b73aaf562bf934249460480b4a60937a438
Author: Tibor Nagy 
AuthorDate: Mon Sep 27 16:48:14 2021 +0200
Commit: László Németh 
CommitDate: Wed Oct 13 16:40:05 2021 +0200

tdf#124232 PPTX export: fix interactions and hyperlinks on images

Follow-up to commit 9bb91441b46d677860530d8bf9597c96561a1b0a
"tdf#141704 PPTX import: fix hyperlinks on images"

Change-Id: If29241ea06253e503dae27f8dc762574a5a634de
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122717
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index dca1775112bb..1dd77a34b2ab 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -58,6 +58,10 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -696,6 +700,32 @@ static sal_Int32 
lcl_CircleAngle2CustomShapeEllipseAngleOOX(const sal_Int32 nInt
 return 0;
 }
 
+static OUString lcl_GetTarget(const css::uno::Reference& 
xModel,
+  std::u16string_view rURL)
+{
+Reference xDPS(xModel, uno::UNO_QUERY_THROW);
+Reference xDrawPages(xDPS->getDrawPages(), 
uno::UNO_SET_THROW);
+sal_uInt32 nPageCount = xDrawPages->getCount();
+OUString sTarget;
+
+for (sal_uInt32 i = 0; i < nPageCount; ++i)
+{
+Reference xDrawPage;
+xDrawPages->getByIndex(i) >>= xDrawPage;
+Reference xNamed(xDrawPage, UNO_QUERY);
+if (!xNamed)
+continue;
+OUString sSlideName = "#" + xNamed->getName();
+if (rURL == sSlideName)
+{
+sTarget = "slide" + OUString::number(i + 1) + ".xml";
+break;
+}
+}
+
+return sTarget;
+}
+
 ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape )
 {
 SAL_INFO("oox.shape", "write custom shape");
@@ -1195,24 +1225,55 @@ void ShapeExport::WriteGraphicObjectShapePart( const 
Reference< XShape >& xShape
 
 pFS->startElementNS(mnXmlNamespace, XML_nvPicPr);
 
-OUString sDescr, sURL;
+presentation::ClickAction eClickAction = presentation::ClickAction_NONE;
+OUString sDescr, sURL, sBookmark, sPPAction;
 bool bHaveDesc;
 
 if ( ( bHaveDesc = GetProperty( xShapeProps, "Description" ) ) )
 mAny >>= sDescr;
 if ( GetProperty( xShapeProps, "URL" ) )
 mAny >>= sURL;
+if (GetProperty(xShapeProps, "Bookmark"))
+mAny >>= sBookmark;
+if (GetProperty(xShapeProps, "OnClick"))
+mAny >>= eClickAction;
 
 pFS->startElementNS( mnXmlNamespace, XML_cNvPr,
   XML_id, OString::number(GetNewShapeID(xShape)),
   XML_name,   GetShapeName(xShape),
   XML_descr,  sax_fastparser::UseIf(sDescr, 
bHaveDesc));
 
+if (eClickAction != presentation::ClickAction_NONE)
+{
+switch (eClickAction)
+{
+case presentation::ClickAction_STOPPRESENTATION:
+sPPAction = "ppaction://hlinkshowjump?jump=endshow";
+break;
+case presentation::ClickAction_NEXTPAGE:
+sPPAction = "ppaction://hlinkshowjump?jump=nextslide";
+break;
+case presentation::ClickAction_LASTPAGE:
+sPPAction = "ppaction://hlinkshowjump?jump=lastslide";
+break;
+case presentation::ClickAction_PREVPAGE:
+sPPAction = "ppaction://hlinkshowjump?jump=previousslide";
+break;
+case presentation::ClickAction_FIRSTPAGE:
+sPPAction = "ppaction://hlinkshowjump?jump=firstslide";
+break;
+case presentation::ClickAction_BOOKMARK:
+sBookmark = "#" + sBookmark;
+break;
+default:
+break;
+}
+}
+
 // OOXTODO: //cNvPr children: XML_extLst, XML_hlinkHover
-if (bHasMediaURL)
-pFS->singleElementNS(XML_a, XML_hlinkClick,
- FSNS(XML_r, XML_id), "",
- XML_action, "ppaction://media");
+if (bHasMediaURL || !sPPAction.isEmpty())
+pFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, XML_id), "", 
XML_action,
+ bHasMediaURL ? "ppaction://media" : sPPAction);
 if( !sURL.isEmpty() )
 {
 OUString sRelId = mpFB->addRelation( mpFS->getOutputStream(),
@@ -1222,6 +1283,23 @@ void ShapeExport::WriteGraphicObjectShapePart( const 
Reference< XShape >& xShape
 
 mpFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, XML_id), 
sRelId);
 }
+
+if (!sBookmark.isEmpty())
+{
+bool bExtURL = 

[Libreoffice-commits] core.git: oox/source sd/qa sd/source

2021-10-13 Thread Tünde Tóth (via logerrit)
 oox/source/ppt/presentationfragmenthandler.cxx |   76 +
 sd/qa/uitest/impress_tests/data/tdf144943.pptx |binary
 sd/qa/uitest/impress_tests/tdf144943.py|   29 +
 sd/source/ui/unoidl/UnoDocumentSettings.cxx|2 
 4 files changed, 107 insertions(+)

New commits:
commit 5697e09b3e726a38b58ce31ac0c3a97e7871c74a
Author: Tünde Tóth 
AuthorDate: Wed Oct 6 10:19:05 2021 +0200
Commit: László Németh 
CommitDate: Wed Oct 13 14:45:30 2021 +0200

tdf#144943 PPTX import: fix permission for editing

The passwords for editing in PPTX documents
created with PowerPoint weren't asked and verified.

Change-Id: I62eb4fd68aac6422c1221a639f4815459ab556c9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123130
Tested-by: Jenkins
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/ppt/presentationfragmenthandler.cxx 
b/oox/source/ppt/presentationfragmenthandler.cxx
index 9aabd45d18af..95eb5fdb53c0 100644
--- a/oox/source/ppt/presentationfragmenthandler.cxx
+++ b/oox/source/ppt/presentationfragmenthandler.cxx
@@ -37,6 +37,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -598,6 +599,81 @@ void PresentationFragmentHandler::finalizeImport()
 return new CustomShowListContext( *this, maCustomShowList );
 case PPT_TOKEN( defaultTextStyle ):
 return new TextListStyleContext( *this, *mpTextListStyle );
+case PPT_TOKEN( modifyVerifier ):
+OUString sAlgorithmClass = rAttribs.getString(XML_cryptAlgorithmClass, 
OUString());
+OUString sAlgorithmType = rAttribs.getString(XML_cryptAlgorithmType, 
OUString());
+sal_Int32 nAlgorithmSid = rAttribs.getInteger(XML_cryptAlgorithmSid, 
0);
+sal_Int32 nSpinCount = rAttribs.getInteger(XML_spinCount, 0);
+OUString sSalt = rAttribs.getString(XML_saltData, OUString());
+OUString sHash = rAttribs.getString(XML_hashData, OUString());
+if (sAlgorithmClass == "hash" && sAlgorithmType == "typeAny" && 
nAlgorithmSid != 0
+&& !sSalt.isEmpty() && !sHash.isEmpty())
+{
+OUString sAlgorithmName;
+switch (nAlgorithmSid)
+{
+case 1:
+sAlgorithmName = "MD2";
+break;
+case 2:
+sAlgorithmName = "MD4";
+break;
+case 3:
+sAlgorithmName = "MD5";
+break;
+case 4:
+sAlgorithmName = "SHA-1";
+break;
+case 5:
+sAlgorithmName = "MAC";
+break;
+case 6:
+sAlgorithmName = "RIPEMD";
+break;
+case 7:
+sAlgorithmName = "RIPEMD-160";
+break;
+case 9:
+sAlgorithmName = "HMAC";
+break;
+case 12:
+sAlgorithmName = "SHA-256";
+break;
+case 13:
+sAlgorithmName = "SHA-384";
+break;
+case 14:
+sAlgorithmName = "SHA-512";
+break;
+default:; // 8, 10, 11, any other value: Undefined.
+}
+
+if (!sAlgorithmName.isEmpty())
+{
+uno::Sequence aResult;
+aResult.realloc(4);
+aResult[0].Name = "algorithm-name";
+aResult[0].Value <<= sAlgorithmName;
+aResult[1].Name = "salt";
+aResult[1].Value <<= sSalt;
+aResult[2].Name = "iteration-count";
+aResult[2].Value <<= nSpinCount;
+aResult[3].Name = "hash";
+aResult[3].Value <<= sHash;
+try
+{
+uno::Reference xDocSettings(
+getFilter().getModelFactory()->createInstance(
+"com.sun.star.document.Settings"),
+uno::UNO_QUERY);
+xDocSettings->setPropertyValue("ModifyPasswordInfo", 
uno::makeAny(aResult));
+}
+catch (const uno::Exception&)
+{
+}
+}
+}
+return this;
 }
 return this;
 }
diff --git a/sd/qa/uitest/impress_tests/data/tdf144943.pptx 
b/sd/qa/uitest/impress_tests/data/tdf144943.pptx
new file mode 100644
index ..e03788fbadb1
Binary files /dev/null and b/sd/qa/uitest/impress_tests/data/tdf144943.pptx 
differ
diff --git a/sd/qa/uitest/impress_tests/tdf144943.py 
b/sd/qa/uitest/impress_tests/tdf144943.py
new file mode 100644
index ..7c63dfab8637
--- /dev/null
+++ b/sd/qa/uitest/impress_tests/tdf144943.py
@@ -0,0 +1,29 @@
+# -*- tab-width: 4; 

[Libreoffice-commits] core.git: oox/source sd/qa

2021-10-01 Thread Tibor Nagy (via logerrit)
 oox/source/ppt/pptshapecontext.cxx  |2 -
 sd/qa/unit/data/pptx/tdf144616.pptx |binary
 sd/qa/unit/import-tests.cxx |   59 
 3 files changed, 60 insertions(+), 1 deletion(-)

New commits:
commit 83d92437e05a9ec872d9303953fa408dd4dcbcde
Author: Tibor Nagy 
AuthorDate: Sat Sep 25 20:12:27 2021 +0200
Commit: László Németh 
CommitDate: Fri Oct 1 17:29:14 2021 +0200

tdf#144616 PPTX import: fix hyperlinks on shapes

Follow-up to commit 6e200689eb309cdbe1e4f08311a400835de19bfb
"tdf#141704 PPTX import: fix hyperlinks on images"

Change-Id: Ie9f1ba56d03462bb8d7ab376e23c89c921a8bcd6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122610
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/ppt/pptshapecontext.cxx 
b/oox/source/ppt/pptshapecontext.cxx
index 62351c913567..d7f3d90f2d0f 100644
--- a/oox/source/ppt/pptshapecontext.cxx
+++ b/oox/source/ppt/pptshapecontext.cxx
@@ -187,7 +187,7 @@ ContextHandlerRef PPTShapeContext::onCreateContext( 
sal_Int32 aElementToken, con
 }
 }
 
-return this;
+return ShapeContext::onCreateContext(aElementToken, rAttribs);
 }
 
 }
diff --git a/sd/qa/unit/data/pptx/tdf144616.pptx 
b/sd/qa/unit/data/pptx/tdf144616.pptx
new file mode 100644
index ..bb153dcff904
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf144616.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index edf69608092a..9bae1492fbca 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -243,6 +243,7 @@ public:
 void testTdf113198();
 void testTdf49856();
 void testTdf103347();
+void testHyperlinksOnShapes();
 
 CPPUNIT_TEST_SUITE(SdImportTest);
 
@@ -366,6 +367,7 @@ public:
 CPPUNIT_TEST(testGreysScaleGraphic);
 CPPUNIT_TEST(testTdf134210CropPosition);
 CPPUNIT_TEST(testTdf103347);
+CPPUNIT_TEST(testHyperlinksOnShapes);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -3601,6 +3603,63 @@ void SdImportTest::testTdf103347()
 xDocShRef->DoClose();
 }
 
+void SdImportTest::testHyperlinksOnShapes()
+{
+sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf144616.pptx"), 
PPTX);
+
+for (sal_Int32 i = 0; i < 7; i++)
+{
+uno::Reference xShape(getShapeFromPage(i, 0, 
xDocShRef));
+uno::Reference xEventsSupplier(xShape, 
uno::UNO_QUERY);
+uno::Reference 
xEvents(xEventsSupplier->getEvents());
+
+uno::Sequence props;
+xEvents->getByName("OnClick") >>= props;
+comphelper::SequenceAsHashMap map(props);
+auto iter(map.find("ClickAction"));
+switch (i)
+{
+case 0:
+CPPUNIT_ASSERT_EQUAL(css::presentation::ClickAction_FIRSTPAGE,
+iter->second.get());
+break;
+case 1:
+CPPUNIT_ASSERT_EQUAL(css::presentation::ClickAction_LASTPAGE,
+iter->second.get());
+break;
+case 2:
+CPPUNIT_ASSERT_EQUAL(css::presentation::ClickAction_NEXTPAGE,
+iter->second.get());
+break;
+case 3:
+CPPUNIT_ASSERT_EQUAL(css::presentation::ClickAction_PREVPAGE,
+iter->second.get());
+break;
+case 4:
+{
+auto iter2(map.find("Bookmark"));
+CPPUNIT_ASSERT_EQUAL(OUString("Second slide"), 
iter2->second.get());
+}
+break;
+case 5:
+
CPPUNIT_ASSERT_EQUAL(css::presentation::ClickAction_STOPPRESENTATION,
+iter->second.get());
+break;
+case 6:
+{
+auto iter1(map.find("Bookmark"));
+CPPUNIT_ASSERT_EQUAL(OUString("http://www.example.com/;), 
iter1->second.get());
+}
+break;
+default:
+break;
+}
+}
+
+xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


[Libreoffice-commits] core.git: oox/source sd/qa

2021-09-27 Thread Tibor Nagy (via logerrit)
 oox/source/ppt/pptgraphicshapecontext.cxx  |3 ++
 oox/source/ppt/pptshape.cxx|6 ++---
 sd/qa/unit/data/pptx/hyperlinkOnImage.pptx |binary
 sd/qa/unit/import-tests.cxx|   30 +
 4 files changed, 36 insertions(+), 3 deletions(-)

New commits:
commit 6e200689eb309cdbe1e4f08311a400835de19bfb
Author: Tibor Nagy 
AuthorDate: Wed Sep 22 13:25:00 2021 +0200
Commit: László Németh 
CommitDate: Mon Sep 27 17:04:13 2021 +0200

tdf#141704 PPTX import: fix hyperlinks on images added via placeholder

Note: see "Interaction..." in the local menu of the image
of the first slide for manual checking of the fix.

See commit 9bb91441b46d677860530d8bf9597c96561a1b0a
"tdf#141704 PPTX import: fix hyperlinks on images"

Change-Id: Iba372c095f76b263575d261a7a0fc98eda449bce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122429
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/ppt/pptgraphicshapecontext.cxx 
b/oox/source/ppt/pptgraphicshapecontext.cxx
index 296263762897..254f44809c85 100644
--- a/oox/source/ppt/pptgraphicshapecontext.cxx
+++ b/oox/source/ppt/pptgraphicshapecontext.cxx
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace oox::core;
 using namespace ::com::sun::star;
@@ -152,6 +153,8 @@ ContextHandlerRef PPTGraphicShapeContext::onCreateContext( 
sal_Int32 aElementTok
 case XML_pic :
 bUseText = false;
 }
+pPlaceholder->getShapeProperties().setAnyProperty(
+PROP_URL, 
mpShapePtr->getShapeProperties().getProperty(PROP_URL));
 mpShapePtr->applyShapeReference( *pPlaceholder, bUseText );
 PPTShape* pPPTShape = dynamic_cast< PPTShape* >( 
pPlaceholder.get() );
 if ( pPPTShape )
diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx
index 757aab1bb3e0..bbc7d2585fd8 100644
--- a/oox/source/ppt/pptshape.cxx
+++ b/oox/source/ppt/pptshape.cxx
@@ -539,7 +539,9 @@ void PPTShape::addShape(
 syncDiagramFontHeights();
 }
 
-if (getShapeProperties().hasProperty(PROP_URL))
+OUString sURL;
+getShapeProperties().getProperty(PROP_URL) >>= sURL;
+if (!sURL.isEmpty())
 {
 Reference xEventsSupplier(xShape, UNO_QUERY);
 if (!xEventsSupplier.is())
@@ -549,7 +551,6 @@ void PPTShape::addShape(
 if (!xEvents.is())
 return;
 
-OUString sURL;
 OUString sAPIEventName;
 sal_Int32 nPropertyCount = 2;
 css::presentation::ClickAction meClickAction;
@@ -563,7 +564,6 @@ void PPTShape::addShape(
 { "#action?jump=endshow", ClickAction_STOPPRESENTATION },
 };
 
-getShapeProperties().getProperty(PROP_URL) >>= sURL;
 std::map::const_iterator aIt
 = ActionMap.find(sURL);
 aIt != ActionMap.end() ? meClickAction = aIt->second
diff --git a/sd/qa/unit/data/pptx/hyperlinkOnImage.pptx 
b/sd/qa/unit/data/pptx/hyperlinkOnImage.pptx
new file mode 100644
index ..38832da5eb25
Binary files /dev/null and b/sd/qa/unit/data/pptx/hyperlinkOnImage.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 7bad28a80c86..edf69608092a 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -122,6 +122,7 @@ public:
 virtual void setUp() override;
 
 void testDocumentLayout();
+void testHyperlinkOnImage();
 void testTdf142645();
 void testTdf141704();
 void testTdf142915();
@@ -246,6 +247,7 @@ public:
 CPPUNIT_TEST_SUITE(SdImportTest);
 
 CPPUNIT_TEST(testDocumentLayout);
+CPPUNIT_TEST(testHyperlinkOnImage);
 CPPUNIT_TEST(testTdf142645);
 CPPUNIT_TEST(testTdf141704);
 CPPUNIT_TEST(testTdf142915);
@@ -446,6 +448,34 @@ void SdImportTest::testDocumentLayout()
 }
 }
 
+void SdImportTest::testHyperlinkOnImage()
+{
+sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/hyperlinkOnImage.pptx"),
 PPTX);
+
+uno::Reference< beans::XPropertySet > xShape1(getShapeFromPage(1, 0, 
xDocShRef));
+uno::Reference xEventsSupplier1(xShape1, 
uno::UNO_QUERY);
+uno::Reference 
xEvents1(xEventsSupplier1->getEvents());
+uno::Sequence props1;
+xEvents1->getByName("OnClick") >>= props1;
+comphelper::SequenceAsHashMap map1(props1);
+auto iter1(map1.find("ClickAction"));
+CPPUNIT_ASSERT_EQUAL(css::presentation::ClickAction_LASTPAGE,
+iter1->second.get());
+
+uno::Reference< beans::XPropertySet > xShape2(getShapeFromPage(1, 1, 
xDocShRef));
+uno::Reference xEventsSupplier2(xShape2, 
uno::UNO_QUERY);
+

[Libreoffice-commits] core.git: oox/source sd/qa

2021-09-14 Thread Tibor Nagy (via logerrit)
 oox/source/ppt/pptshape.cxx |   80 
 sd/qa/unit/data/pptx/tdf141704.pptx |binary
 sd/qa/unit/import-tests.cxx |   59 ++
 3 files changed, 139 insertions(+)

New commits:
commit 9bb91441b46d677860530d8bf9597c96561a1b0a
Author: Tibor Nagy 
AuthorDate: Tue Aug 31 13:15:01 2021 +0200
Commit: László Németh 
CommitDate: Tue Sep 14 15:23:27 2021 +0200

tdf#141704 PPTX import: fix hyperlinks on images

Hyperlinks on images pointing to the "first/last/
previous/next" slides and "exit presentation/go to
the website/go to the slide" weren't imported.

Note: images added via the Content placeholder
will be fixed later.

Change-Id: Idda1ff6fd3243b06262637c7c8e579e78309e317
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121369
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx
index 80f165d6f085..757aab1bb3e0 100644
--- a/oox/source/ppt/pptshape.cxx
+++ b/oox/source/ppt/pptshape.cxx
@@ -34,10 +34,14 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 using namespace ::oox::core;
 using namespace ::oox::drawingml;
@@ -47,6 +51,9 @@ using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::beans;
 using namespace ::com::sun::star::text;
 using namespace ::com::sun::star::drawing;
+using namespace ::com::sun::star::document;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::presentation;
 
 namespace oox::ppt {
 
@@ -531,6 +538,79 @@ void PPTShape::addShape(
 keepDiagramCompatibilityInfo();
 syncDiagramFontHeights();
 }
+
+if (getShapeProperties().hasProperty(PROP_URL))
+{
+Reference xEventsSupplier(xShape, UNO_QUERY);
+if (!xEventsSupplier.is())
+return;
+
+Reference xEvents(xEventsSupplier->getEvents());
+if (!xEvents.is())
+return;
+
+OUString sURL;
+OUString sAPIEventName;
+sal_Int32 nPropertyCount = 2;
+css::presentation::ClickAction meClickAction;
+uno::Sequence aProperties;
+
+std::map ActionMap = 
{
+{ "#action?jump=nextslide", ClickAction_NEXTPAGE },
+{ "#action?jump=previousslide", ClickAction_PREVPAGE },
+{ "#action?jump=firstslide", ClickAction_FIRSTPAGE },
+{ "#action?jump=lastslide", ClickAction_LASTPAGE },
+{ "#action?jump=endshow", ClickAction_STOPPRESENTATION },
+};
+
+getShapeProperties().getProperty(PROP_URL) >>= sURL;
+std::map::const_iterator aIt
+= ActionMap.find(sURL);
+aIt != ActionMap.end() ? meClickAction = aIt->second
+   : meClickAction = ClickAction_BOOKMARK;
+
+// ClickAction_BOOKMARK and ClickAction_DOCUMENT share the 
same event
+// so check here if it's a bookmark or a document
+if (meClickAction == ClickAction_BOOKMARK)
+{
+if (!sURL.startsWith("#"))
+meClickAction = ClickAction_DOCUMENT;
+else
+sURL = sURL.copy(1);
+nPropertyCount += 1;
+}
+
+aProperties.realloc(nPropertyCount);
+beans::PropertyValue* pProperties = aProperties.getArray();
+
+pProperties->Name = "EventType";
+pProperties->Handle = -1;
+pProperties->Value <<= OUString("Presentation");
+pProperties->State = beans::PropertyState_DIRECT_VALUE;
+pProperties++;
+
+pProperties->Name = "ClickAction";
+pProperties->Handle = -1;
+pProperties->Value <<= meClickAction;
+pProperties->State = beans::PropertyState_DIRECT_VALUE;
+pProperties++;
+
+switch (meClickAction)
+{
+case ClickAction_BOOKMARK:
+case ClickAction_DOCUMENT:
+pProperties->Name = "Bookmark";
+pProperties->Handle = -1;
+pProperties->Value <<= sURL;
+pProperties->State = beans::PropertyState_DIRECT_VALUE;
+break;
+default:
+break;
+}
+
+sAPIEventName = "OnClick";
+xEvents->replaceByName(sAPIEventName, uno::Any(aProperties));
+}
 }
 }
 catch (const Exception&)
diff --git 

[Libreoffice-commits] core.git: oox/source sd/qa

2021-08-31 Thread Tibor Nagy (via logerrit)
 oox/source/ppt/pptshape.cxx |2 +-
 sd/qa/unit/data/pptx/tdf142645.pptx |binary
 sd/qa/unit/import-tests.cxx |   16 
 3 files changed, 17 insertions(+), 1 deletion(-)

New commits:
commit e5cfda76aefd6996813f461198816be24cd6ad43
Author: Tibor Nagy 
AuthorDate: Mon Aug 30 12:26:39 2021 +0200
Commit: László Németh 
CommitDate: Tue Aug 31 14:57:57 2021 +0200

tdf#142645 PPTX import: convert "ctrTitle" text to slide name

(i.e. centered title) similar to .

See commit 7eb0e52527e729a21973e70d5be8e0a6779ec748
"tdf#142648 PPTX: import long slide names to avoid broken link export",
commit 253bee65bc24d999c3629a4d503d0fa01b355cfc
"tdf#142646 PPTX import: count repeating slide names" etc.

Change-Id: I5f25f04f23981ce2ff64dc792fe8464682d749a2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121295
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx
index 7e120b8ec36e..80f165d6f085 100644
--- a/oox/source/ppt/pptshape.cxx
+++ b/oox/source/ppt/pptshape.cxx
@@ -426,7 +426,7 @@ void PPTShape::addShape(
 
 Reference< XShape > xShape( createAndInsert( rFilterBase, 
sServiceName, pTheme, rxShapes, bClearText, bool(mpPlaceholder), 
aTransformation, getFillProperties() ) );
 // if exists and not duplicated, try to use the title text as 
slide name to help its re-use on UI
-if (!rSlidePersist.isMasterPage() && rSlidePersist.getPage().is() 
&& mnSubType == XML_title)
+if (!rSlidePersist.isMasterPage() && rSlidePersist.getPage().is() 
&& (mnSubType == XML_title || mnSubType == XML_ctrTitle))
 {
 try
 {
diff --git a/sd/qa/unit/data/pptx/tdf142645.pptx 
b/sd/qa/unit/data/pptx/tdf142645.pptx
new file mode 100644
index ..e57bd9ee176e
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf142645.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 79122bb60afa..482520908849 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -122,6 +122,7 @@ public:
 virtual void setUp() override;
 
 void testDocumentLayout();
+void testTdf142645();
 void testTdf142915();
 void testTdf142913();
 void testTdf142590();
@@ -244,6 +245,7 @@ public:
 CPPUNIT_TEST_SUITE(SdImportTest);
 
 CPPUNIT_TEST(testDocumentLayout);
+CPPUNIT_TEST(testTdf142645);
 CPPUNIT_TEST(testTdf142915);
 CPPUNIT_TEST(testTdf142913);
 CPPUNIT_TEST(testTdf142590);
@@ -442,6 +444,20 @@ void SdImportTest::testDocumentLayout()
 }
 }
 
+void SdImportTest::testTdf142645()
+{
+sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf142645.pptx"), 
PPTX);
+uno::Reference 
xDoc(xDocShRef->GetDoc()->getUnoModel(),
+ uno::UNO_QUERY_THROW);
+
+uno::Reference 
xPage1(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
+uno::Reference xNamed1(xPage1, uno::UNO_QUERY_THROW);
+CPPUNIT_ASSERT_EQUAL(OUString("Hello"), xNamed1->getName());
+
+xDocShRef->DoClose();
+}
+
 void SdImportTest::testTdf142915()
 {
 ::sd::DrawDocShellRef xDocShRef


[Libreoffice-commits] core.git: oox/source sd/qa

2021-07-20 Thread Tibor Nagy (via logerrit)
 oox/source/ppt/pptshape.cxx |7 ---
 sd/qa/unit/data/pptx/tdf142648.pptx |binary
 sd/qa/unit/export-tests-ooxml1.cxx  |   23 +++
 3 files changed, 27 insertions(+), 3 deletions(-)

New commits:
commit 7eb0e52527e729a21973e70d5be8e0a6779ec748
Author: Tibor Nagy 
AuthorDate: Wed Jul 7 10:10:21 2021 +0200
Commit: László Németh 
CommitDate: Tue Jul 20 18:50:17 2021 +0200

tdf#142648 PPTX: import long slide names to avoid broken link export

PPTX import renames the slides using their short title text.
Apply this for the titles with 64 or more characters, too,
abbreviating the title text instead of using the default
slide name "page1", "page2" etc., because the default slide
names result broken hyperlinks during the PPTX export.

To test the fix manually, create a new hyperlink
using text selection and Insert Hyperlink (Ctrl-K),
clicking on Target in Document button on the Document pane,
and selecting a slide name.

Note: the problem still exists for the duplicated
or newly inserted slides, which get default slide names.

Change-Id: Iec1fab5a2ee862353766ed7e13b1501b3a325d0e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118548
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx
index 8b25523e5c3d..4b735ea59c01 100644
--- a/oox/source/ppt/pptshape.cxx
+++ b/oox/source/ppt/pptshape.cxx
@@ -439,9 +439,10 @@ void PPTShape::addShape(
 Reference 
xDPS(rFilterBase.getModel(), uno::UNO_QUERY_THROW);
 Reference 
xDrawPages(xDPS->getDrawPages(), uno::UNO_SET_THROW);
 sal_uInt32 nMaxPages = xDrawPages->getCount();
-bool bUseTitleAsSlideName = !aTitleText.isEmpty() &&
-  // just a magic value, but we don't want to set 
slide names which are too long
-  aTitleText.getLength() < 64;
+// just a magic value but we don't want to drop out slide 
names which are too long
+if (aTitleText.getLength() > 63)
+aTitleText = aTitleText.copy(0, 63);
+bool bUseTitleAsSlideName = !aTitleText.isEmpty();
 // check duplicated title name
 if (bUseTitleAsSlideName)
 {
diff --git a/sd/qa/unit/data/pptx/tdf142648.pptx 
b/sd/qa/unit/data/pptx/tdf142648.pptx
new file mode 100644
index ..fc470530fc94
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf142648.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx 
b/sd/qa/unit/export-tests-ooxml1.cxx
index a450e6d890eb..15832942c2a8 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -61,6 +61,7 @@ using namespace css;
 class SdOOXMLExportTest1 : public SdModelTestBaseXML
 {
 public:
+void testTdf142648();
 void testTdf47365();
 void testTdf125071();
 void testTdf54037();
@@ -120,6 +121,7 @@ public:
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest1);
 
+CPPUNIT_TEST(testTdf142648);
 CPPUNIT_TEST(testTdf47365);
 CPPUNIT_TEST(testTdf125071);
 CPPUNIT_TEST(testTdf54037);
@@ -206,6 +208,27 @@ void checkFontAttributes( const SdrTextObj* pObj, 
ItemValue nVal, sal_uInt32 nId
 
 }
 
+void SdOOXMLExportTest1::testTdf142648()
+{
+sd::DrawDocShellRef xDocShRef = loadURL( 
m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf142648.pptx"), PPTX );
+utl::TempFile tempFile;
+
+uno::Reference 
xDPS(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW);
+uno::Reference xDrawPages(xDPS->getDrawPages(), 
uno::UNO_SET_THROW);
+uno::Reference xDrawPage;
+xDrawPages->getByIndex(0) >>= xDrawPage;
+uno::Reference xNamed(xDrawPage, uno::UNO_QUERY_THROW);
+xNamed->setName("#Slide 1");
+
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+xDocShRef->DoClose();
+
+xmlDocUniquePtr pRelsDoc = parseExport(tempFile, 
"ppt/slides/_rels/slide2.xml.rels");
+
+assertXPath(pRelsDoc, "/rels:Relationships/rels:Relationship[@Id='rId1']", 
"Target",
+"slide1.xml");
+}
+
 void SdOOXMLExportTest1::testTdf47365()
 {
 sd::DrawDocShellRef xDocShRef = loadURL( 
m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/loopNoPause.pptx"), PPTX );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: oox/source sd/qa

2021-07-19 Thread Sarper Akdemir (via logerrit)
 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 7ec4a0872d16eb20d790eb8079ba538898fd2ff6
Author: Sarper Akdemir 
AuthorDate: Tue Jun 29 13:33:52 2021 +0300
Commit: Jan Holesovsky 
CommitDate: Mon Jul 19 16:47:10 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/+/118135
Tested-by: Jenkins
Reviewed-by: Jan Holesovsky 

diff --git a/oox/source/drawingml/textfield.cxx 
b/oox/source/drawingml/textfield.cxx
index e590c5c7a2cb..0d33da71266d 100644
--- a/oox/source/drawingml/textfield.cxx
+++ b/oox/source/drawingml/textfield.cxx
@@ -218,21 +218,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 7c6754a35f6d..e45c5c52e8c5 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2355,11 +2355,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 e2cdef3d76f6..b7d6e0ca5554 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 
@@ -787,26 +788,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: oox/source sd/qa sd/source

2021-07-02 Thread Attila Bakos (NISZ) (via logerrit)
 oox/source/export/drawingml.cxx   |3 --
 sd/qa/unit/data/odp/placeholder-box-textalignment.odp |binary
 sd/qa/unit/export-tests-ooxml3.cxx|   20 +
 sd/source/filter/eppt/pptx-epptooxml.cxx  |   21 +-
 4 files changed, 37 insertions(+), 7 deletions(-)

New commits:
commit dbdcceb9d77c602ea1161ab0f4e3899071333a92
Author: Attila Bakos (NISZ) 
AuthorDate: Tue Jun 8 12:25:41 2021 +0200
Commit: László Németh 
CommitDate: Fri Jul 2 14:23:17 2021 +0200

tdf#142235 PPTX export: fix styles with placeholders

inserting icons and alignment.

Regression from commit b6b02e0b4c9d739836e1f61a886ea45b01e6696e
(tdf#111903 tdf#137152 PPTX export: fix placeholders).

Note: in the unit test document, check fixed vertical position
of the second text boxes of Slide 2–4.

Change-Id: I3c649db69f94a2e9f49ae7aa11d9cd9d9f6d80d7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116828
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 455e50159612..140445a5ee0f 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -3081,8 +3081,7 @@ void DrawingML::WriteText(const Reference& 
rXIface, bool bBodyPr, bo
 const char* sVerticalAlignment = nullptr;
 if (GetProperty(rXPropSet, "TextVerticalAdjust"))
 mAny >>= eVerticalAlignment;
-if( eVerticalAlignment != TextVerticalAdjust_TOP )
-sVerticalAlignment = GetTextVerticalAdjust(eVerticalAlignment);
+sVerticalAlignment = GetTextVerticalAdjust(eVerticalAlignment);
 
 const char* sWritingMode = nullptr;
 bool bVertical = false;
diff --git a/sd/qa/unit/data/odp/placeholder-box-textalignment.odp 
b/sd/qa/unit/data/odp/placeholder-box-textalignment.odp
new file mode 100644
index ..df33291fbd40
Binary files /dev/null and 
b/sd/qa/unit/data/odp/placeholder-box-textalignment.odp differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index fb2db18e8d22..6632934e430e 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -116,6 +116,7 @@ public:
 void testTdf125560_textDeflate();
 void testTdf125560_textInflateTop();
 void testTdf96061_textHighlight();
+void testTdf142235_TestPlaceholderTextAlignment();
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest3);
 
@@ -184,6 +185,7 @@ public:
 CPPUNIT_TEST(testTdf125560_textDeflate);
 CPPUNIT_TEST(testTdf125560_textInflateTop);
 CPPUNIT_TEST(testTdf96061_textHighlight);
+CPPUNIT_TEST(testTdf142235_TestPlaceholderTextAlignment);
 CPPUNIT_TEST_SUITE_END();
 
 virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override
@@ -1688,6 +1690,24 @@ void SdOOXMLExportTest3::testTdf125560_textInflateTop()
 "type", "mso-spt164");
 }
 
+void SdOOXMLExportTest3::testTdf142235_TestPlaceholderTextAlignment()
+{
+auto xDocShRef = loadURL(
+
m_directories.getURLFromSrc(u"sd/qa/unit/data/odp/placeholder-box-textalignment.odp"),
 ODP);
+
+utl::TempFile tmpfile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+xDocShRef->DoClose();
+
+xmlDocUniquePtr pXml1 = parseExport(tmpfile, "ppt/slides/slide2.xml");
+xmlDocUniquePtr pXml2 = parseExport(tmpfile, "ppt/slides/slide3.xml");
+
+// Without the fix in place many of these asserts failed, because 
alignment was bad.
+
+assertXPath(pXml1, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:bodyPr", 
"anchor", "t");
+assertXPath(pXml2, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:bodyPr", 
"anchor", "t");
+}
+
 void SdOOXMLExportTest3::testTdf96061_textHighlight()
 {
 ::sd::DrawDocShellRef xDocShRef
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx 
b/sd/source/filter/eppt/pptx-epptooxml.cxx
index d26cf6b0d061..ac7449fd38a6 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -1568,14 +1568,25 @@ ShapeExport& 
PowerPointShapeExport::WritePlaceholderShape(const Reference< XShap
 SAL_INFO("sd.eppt", "write placeholder " << pType);
 if (bUsePlaceholderIndex)
 {
-mpFS->singleElementNS(
-XML_p, XML_ph, XML_type, pType, XML_idx,
-OString::number(
-
static_cast(GetFB())->CreateNewPlaceholderIndex(xShape)));
+if ((mePageType == PageType::LAYOUT || mePageType == PageType::NORMAL)
+&& ePlaceholder == Outliner)
+mpFS->singleElementNS(
+XML_p, XML_ph, XML_idx,
+OString::number(
+
static_cast(GetFB())->CreateNewPlaceholderIndex(xShape)));
+else
+mpFS->singleElementNS(
+XML_p, XML_ph, XML_type, pType, XML_idx,
+OString::number(
+
static_cast(GetFB())->CreateNewPlaceholderIndex(xShape)));

[Libreoffice-commits] core.git: oox/source sd/qa

2021-06-28 Thread Tibor Nagy (via logerrit)
 oox/source/ppt/pptshape.cxx |   25 -
 sd/qa/unit/import-tests.cxx |4 ++--
 2 files changed, 18 insertions(+), 11 deletions(-)

New commits:
commit 253bee65bc24d999c3629a4d503d0fa01b355cfc
Author: Tibor Nagy 
AuthorDate: Wed Jun 16 11:02:48 2021 +0200
Commit: László Németh 
CommitDate: Mon Jun 28 09:01:58 2021 +0200

tdf#142646 PPTX import: count repeating slide names

instead of using the default slide name "Slide n".

PPTX slides are named after their titles. Now repeating
titles got a number instead of using the default slide
name "Slide n". E.g. "Title", "Title", "Title" will be
slide names "Title", "Title (2)", Title (3)", and not
"Title", "Slide 2", "Slide 3".

Follow-up to commit I98511c3c9a59598ea113e7387db5202d7f8a7cd4
"tdf#103347: PTX import: fix duplicated slide name"

Change-Id: I449d6f7d7599291b3dae7df65ad6ff86a4269fb8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117317
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx
index 7f3786c41992..8b25523e5c3d 100644
--- a/oox/source/ppt/pptshape.cxx
+++ b/oox/source/ppt/pptshape.cxx
@@ -432,6 +432,7 @@ void PPTShape::addShape(
 {
 try
 {
+sal_Int32 nCount = 1;
 OUString aTitleText;
 Reference xText(xShape, UNO_QUERY_THROW);
 aTitleText = xText->getString();
@@ -442,17 +443,23 @@ void PPTShape::addShape(
   // just a magic value, but we don't want to set 
slide names which are too long
   aTitleText.getLength() < 64;
 // check duplicated title name
-for (sal_uInt32 nPage = 0; bUseTitleAsSlideName && nPage < 
nMaxPages; ++nPage)
-{
-Reference 
xDrawPage(xDrawPages->getByIndex(nPage), uno::UNO_QUERY);
-Reference xNamed(xDrawPage, 
UNO_QUERY_THROW);
-if ( xNamed->getName() == aTitleText )
-bUseTitleAsSlideName = false;
-}
-if ( bUseTitleAsSlideName )
+if (bUseTitleAsSlideName)
 {
+for (sal_uInt32 nPage = 0; nPage < nMaxPages; ++nPage)
+{
+Reference 
xDrawPage(xDrawPages->getByIndex(nPage), uno::UNO_QUERY);
+Reference xNamed(xDrawPage, 
UNO_QUERY_THROW);
+OUString sRest;
+if (xNamed->getName().startsWith(aTitleText, 
)
+&& (sRest.isEmpty()
+|| (sRest.startsWith(" (") && 
sRest.endsWith(")")
+&& sRest.copy(2, sRest.getLength() - 
3).toInt32() > 0)))
+nCount++;
+}
 Reference 
xName(rSlidePersist.getPage(), UNO_QUERY_THROW);
-xName->setName(aTitleText);
+xName->setName(
+aTitleText
++ (nCount == 1 ? OUString("") : " (" + 
OUString::number(nCount) + ")"));
 }
 }
 catch (uno::Exception&)
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 7637700eac1f..8723c0ee53b8 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -3449,11 +3449,11 @@ void SdImportTest::testTdf103347()
 
 uno::Reference 
xPage2(xDoc->getDrawPages()->getByIndex(1), uno::UNO_QUERY);
 uno::Reference xNamed2(xPage2, uno::UNO_QUERY_THROW);
-CPPUNIT_ASSERT_EQUAL(OUString("page2"), xNamed2->getName());
+CPPUNIT_ASSERT_EQUAL(OUString("Hello (2)"), xNamed2->getName());
 
 uno::Reference 
xPage3(xDoc->getDrawPages()->getByIndex(2), uno::UNO_QUERY);
 uno::Reference xNamed3(xPage3, uno::UNO_QUERY_THROW);
-CPPUNIT_ASSERT_EQUAL(OUString("page3"), xNamed3->getName());
+CPPUNIT_ASSERT_EQUAL(OUString("Hello (3)"), xNamed3->getName());
 
 xDocShRef->DoClose();
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: oox/source sd/qa

2021-05-26 Thread Gülşah Köse (via logerrit)
 oox/source/drawingml/textcharacterproperties.cxx |2 +
 sd/qa/unit/data/pptx/tdf96061.pptx   |binary
 sd/qa/unit/export-tests-ooxml2.cxx   |   36 +++
 3 files changed, 38 insertions(+)

New commits:
commit 1cd26a9ab64482daf4de08f5bb7730d0a991bbce
Author: Gülşah Köse 
AuthorDate: Wed May 19 14:37:36 2021 +0300
Commit: Gülşah Köse 
CommitDate: Wed May 26 10:14:57 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 

diff --git a/oox/source/drawingml/textcharacterproperties.cxx 
b/oox/source/drawingml/textcharacterproperties.cxx
index 20965e33abb1..4eb5acaffb56 100644
--- a/oox/source/drawingml/textcharacterproperties.cxx
+++ b/oox/source/drawingml/textcharacterproperties.cxx
@@ -177,6 +177,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& aVectorOfPropertyValues )
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 6c12ac08928c..973503cc3b80 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -212,6 +212,7 @@ public:
 void testTdf128213ShapeRot();
 void testTdf125560_textDeflate();
 void testTdf125560_textInflateTop();
+void testTdf96061_textHighlight();
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
 
@@ -338,6 +339,7 @@ public:
 CPPUNIT_TEST(testTdf128213ShapeRot);
 CPPUNIT_TEST(testTdf125560_textDeflate);
 CPPUNIT_TEST(testTdf125560_textInflateTop);
+CPPUNIT_TEST(testTdf96061_textHighlight);
 
 CPPUNIT_TEST_SUITE_END();
 
@@ -3191,6 +3193,40 @@ void SdOOXMLExportTest2::testTdf125560_textInflateTop()
 assertXPath(pXmlDocRels, 
"/office:document-content/office:body/office:presentation/draw:page/draw:custom-shape/draw:enhanced-geometry",
 "type", "mso-spt164");
 }
 
+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);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: oox/source sd/qa

2021-05-04 Thread Tibor Nagy (via logerrit)
 oox/source/export/drawingml.cxx|   65 -
 sd/qa/unit/data/pptx/tdf54037.pptx |binary
 sd/qa/unit/export-tests-ooxml1.cxx |   22 
 3 files changed, 79 insertions(+), 8 deletions(-)

New commits:
commit 3a24211a1d49f33ca52e4fb2c927d50304f005df
Author: Tibor Nagy 
AuthorDate: Thu Apr 29 17:26:59 2021 +0200
Commit: László Németh 
CommitDate: Tue May 4 17:53:22 2021 +0200

tdf#54037 PPTX export: fix internal hyperlinks

exported as external by accident: after reloading the bad
export, clicking on the hyperlink opened the same file
in another document, because the exported link contained
also the full file name reference instead of the slide name,
according to the OOXML Relationship TargetMode="External".

Change-Id: I08cf1537cd307b0b6f51ba1c3f61d89e220d44fd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114891
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index bfe44e32b098..b84a77f085a0 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -93,6 +93,10 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
 
 #include 
 #include 
@@ -156,9 +160,12 @@ OUString URLTransformer::getTransformedString(const 
OUString& rString) const
 return rString;
 }
 
-bool URLTransformer::isExternalURL(const OUString& /*rURL*/) const
+bool URLTransformer::isExternalURL(const OUString& rURL) const
 {
-return true;
+bool bExternal = true;
+if (rURL.startsWith("#"))
+bExternal = false;
+return bExternal;
 }
 
 static css::uno::Any getLineDash( const 
css::uno::Reference& xModel, const OUString& rDashName )
@@ -1842,6 +1849,29 @@ void DrawingML::WriteShapeTransformation( const 
Reference< XShape >& rXShape, sa
 bFlipHWrite, bFlipVWrite, ExportRotateClockwisify(nRotation + 
nCameraRotation), IsGroupShape( rXShape ));
 }
 
+static OUString lcl_GetTarget(const css::uno::Reference& 
xModel, OUString& rURL)
+{
+Reference xDPS(xModel, uno::UNO_QUERY_THROW);
+Reference xDrawPages(xDPS->getDrawPages(), 
uno::UNO_SET_THROW);
+sal_uInt32 nPageCount = xDrawPages->getCount();
+OUString sTarget;
+
+for (sal_uInt32 i = 0; i < nPageCount; ++i)
+{
+Reference xDrawPage;
+xDrawPages->getByIndex(i) >>= xDrawPage;
+Reference xNamed(xDrawPage, UNO_QUERY_THROW);
+OUString sSlideName = "#" + xNamed->getName();
+if (rURL == sSlideName)
+{
+sTarget = "slide" + OUString::number(i + 1) + ".xml";
+break;
+}
+}
+
+return sTarget;
+}
+
 void DrawingML::WriteRunProperties( const Reference< XPropertySet >& rRun, 
bool bIsField, sal_Int32 nElement,
 bool bCheckDirect,bool& 
rbOverridingCharHeight, sal_Int32& rnCharHeight,
 sal_Int16 nScriptType, const Reference< 
XPropertySet >& rXShapePropSet)
@@ -2177,15 +2207,34 @@ void DrawingML::WriteRunProperties( const Reference< 
XPropertySet >& rRun, bool
 OUString sURL;
 
 mAny >>= sURL;
-if( !sURL.isEmpty() ) {
-OUString sRelId = mpFB->addRelation( mpFS->getOutputStream(),
-  
oox::getRelationship(Relationship::HYPERLINK),
-  sURL, true );
+if (!sURL.isEmpty())
+{
+if (!sURL.match("#action?jump="))
+{
+bool bExtURL = URLTransformer().isExternalURL(sURL);
+sURL = bExtURL ? sURL : lcl_GetTarget(GetFB()->getModel(), 
sURL);
+
+OUString sRelId
+= mpFB->addRelation(mpFS->getOutputStream(),
+bExtURL ? 
oox::getRelationship(Relationship::HYPERLINK)
+: 
oox::getRelationship(Relationship::SLIDE),
+sURL, bExtURL);
 
-mpFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, XML_id), 
sRelId);
+if (bExtURL)
+mpFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, 
XML_id), sRelId);
+else
+mpFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, 
XML_id), sRelId,
+  XML_action, 
"ppaction://hlinksldjump");
+}
+else
+{
+sal_Int32 nIndex = sURL.indexOf('=');
+OUString aDestination(sURL.copy(nIndex + 1));
+mpFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, 
XML_id), "", XML_action,
+  "ppaction://hlinkshowjump?jump=" + 
aDestination);
+}
 }
 }
-
 mpFS->endElementNS( XML_a, nElement );
 }
 
diff --git a/sd/qa/unit/data/pptx/tdf54037.pptx 

[Libreoffice-commits] core.git: oox/source sd/qa

2021-05-04 Thread Tibor Nagy (via logerrit)
 oox/source/ppt/pptshape.cxx |   21 +++--
 sd/qa/unit/data/pptx/tdf103347.pptx |binary
 sd/qa/unit/import-tests.cxx |   25 +
 3 files changed, 44 insertions(+), 2 deletions(-)

New commits:
commit cfa672013a1a75ff53993084ae5e69fcd985d010
Author: Tibor Nagy 
AuthorDate: Wed Apr 28 13:10:59 2021 +0200
Commit: László Németh 
CommitDate: Tue May 4 17:27:55 2021 +0200

tdf#103347 PPTX import: fix duplicated slide name

PPTX import uses title text as slide names, but this resulted
duplicated slide names in the case of repeating title
text, which forbidden by UNO API:

== GenericDrawPage.idl ==

/** Gets or sets the name of this page.

Duplicated page names inside a document are not allowed.
 */
[optional] interface com::sun::star::container::XNamed;

Now the import code skips the duplicated title text,
resulting default numbered slide names instead of the
duplicated title names.

Note: it seems, this hasn't fixed the jumping slide selection,
e.g. sometimes pressing Shift-F5 still presents the first slide
instead of the actual one.

Change-Id: I98511c3c9a59598ea113e7387db5202d7f8a7cd4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114810
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx
index 62a070e5c840..2f346cca2192 100644
--- a/oox/source/ppt/pptshape.cxx
+++ b/oox/source/ppt/pptshape.cxx
@@ -26,6 +26,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -363,14 +365,29 @@ void PPTShape::addShape(
 setMasterTextListStyle( aMasterTextListStyle );
 
 Reference< XShape > xShape( createAndInsert( rFilterBase, 
sServiceName, pTheme, rxShapes, bClearText, bool(mpPlaceholder), 
aTransformation, getFillProperties() ) );
+// if exists and not duplicated, try to use the title text as 
slide name to help its re-use on UI
 if (!rSlidePersist.isMasterPage() && rSlidePersist.getPage().is() 
&& mnSubType == XML_title)
- {
+{
 try
 {
 OUString aTitleText;
 Reference xText(xShape, UNO_QUERY_THROW);
 aTitleText = xText->getString();
-if (!aTitleText.isEmpty() && (aTitleText.getLength() < 
64))// just a magic value, but we don't want to set slide names which are 
too long
+Reference 
xDPS(rFilterBase.getModel(), uno::UNO_QUERY_THROW);
+Reference 
xDrawPages(xDPS->getDrawPages(), uno::UNO_SET_THROW);
+sal_uInt32 nMaxPages = xDrawPages->getCount();
+bool bUseTitleAsSlideName = !aTitleText.isEmpty() &&
+  // just a magic value, but we don't want to set 
slide names which are too long
+  aTitleText.getLength() < 64;
+// check duplicated title name
+for (sal_uInt32 nPage = 0; bUseTitleAsSlideName && nPage < 
nMaxPages; ++nPage)
+{
+Reference 
xDrawPage(xDrawPages->getByIndex(nPage), uno::UNO_QUERY);
+Reference xNamed(xDrawPage, 
UNO_QUERY_THROW);
+if ( xNamed->getName() == aTitleText )
+bUseTitleAsSlideName = false;
+}
+if ( bUseTitleAsSlideName )
 {
 Reference 
xName(rSlidePersist.getPage(), UNO_QUERY_THROW);
 xName->setName(aTitleText);
diff --git a/sd/qa/unit/data/pptx/tdf103347.pptx 
b/sd/qa/unit/data/pptx/tdf103347.pptx
new file mode 100755
index ..12078519076a
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf103347.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index bbdc8b5a19cd..bf539dfdd08d 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -85,6 +85,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -233,6 +234,7 @@ public:
 void testTdf106638();
 void testTdf113198();
 void testTdf49856();
+void testTdf103347();
 
 CPPUNIT_TEST_SUITE(SdImportTest);
 
@@ -349,6 +351,7 @@ public:
 CPPUNIT_TEST(testMirroredGraphic);
 CPPUNIT_TEST(testGreysScaleGraphic);
 CPPUNIT_TEST(testTdf134210CropPosition);
+CPPUNIT_TEST(testTdf103347);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -3443,6 +3446,28 @@ void SdImportTest::testGreysScaleGraphic()
 xDocShRef->DoClose();
 }
 
+void SdImportTest::testTdf103347()
+{
+sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf103347.pptx"), 
PPTX);
+uno::Reference 
xDoc(xDocShRef->GetDoc()->getUnoModel(),
+  

[Libreoffice-commits] core.git: oox/source sd/qa

2021-04-29 Thread Luboš Luňák (via logerrit)
 oox/source/drawingml/lineproperties.cxx |4 ++--
 oox/source/export/drawingml.cxx |4 ++--
 sd/qa/unit/uiimpress.cxx|   14 ++
 3 files changed, 6 insertions(+), 16 deletions(-)

New commits:
commit 5d4e450a7d64d3dc1caf34544dbfa35f4641d5c3
Author: Luboš Luňák 
AuthorDate: Mon Apr 26 15:16:49 2021 +0200
Commit: Luboš Luňák 
CommitDate: Thu Apr 29 16:05:34 2021 +0200

Revert "tdf#136957 Use bigger dots for better handling in presentation 
mode."

This change was a workaround and a follow-up commit will handle the problem
in a better way.

This reverts commit 5d80f679e1891f98ef964efa1166c90d001c5806.

Change-Id: I24a98a0828d3b6fbd014d58f37bf4da40d7dfdfd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114711
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/oox/source/drawingml/lineproperties.cxx 
b/oox/source/drawingml/lineproperties.cxx
index 87c502f96f6b..451da4c6aa26 100644
--- a/oox/source/drawingml/lineproperties.cxx
+++ b/oox/source/drawingml/lineproperties.cxx
@@ -470,9 +470,9 @@ void LineProperties::pushToPropMap( ShapePropertyMap& 
rPropMap,
 // 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 += 96;
+aLineDash.Distance += 99;
 if (aLineDash.DotLen >= 100)
-aLineDash.DotLen -= 96;
+aLineDash.DotLen -= 99;
 if (aLineDash.DashLen >= 100)
 aLineDash.DashLen -= 99;
 }
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 07dad1fb8b75..5b16931da1d3 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -974,8 +974,8 @@ void DrawingML::WriteOutline( const 
Reference& rXPropSet, Referenc
 sal_uInt32 nDistance = aLineDash.Distance;
 if (aLineCap != LineCap_BUTT && nDistance >= 99)
 {
-nDistance -= 96;
-nDotLen += 96;
+nDistance -= 99;
+nDotLen += 99;
 if (nDashLen > 0)
 nDashLen += 99;
 }
diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx
index 4f2501da991a..9a1ab0a52c82 100644
--- a/sd/qa/unit/uiimpress.cxx
+++ b/sd/qa/unit/uiimpress.cxx
@@ -650,19 +650,9 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf134053)
 // Because 0% is not possible as dash length (as of June 2020) 1% is used 
in the fix.
 // For that a larger delta is here allowed to the ideal value than needed 
for
 // rounding errors.
+CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Distance", 2117, fDistance, 12);
 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Dot length", 706, fDotLength, 12);
-
-// tdf#136957 (dotted lines are  disappearing in presentation mode)
-// Test value used as 2089 instead of 2117 for tdf#136957 workaround.
-// If this test fails as Expected: 2089 Actual:2117
-// plaese test tdf#136957 manually and use 2117 as test value again.
-CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Distance", 2089, fDistance, 12);
-
-// tdf#136957 (dotted lines are  disappearing in presentation mode)
-// Test value used as 2854 instead of 2822 for tdf#136957 workaround.
-// If this test fails as Expected: 2854 Actual:2822
-// plaese test tdf#136957 manually and use 2822 as test value again.
-CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Dash length", 2854, fDashLength, 12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Dash length", 2822, fDashLength, 12);
 }
 
 CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testSpellOnlineParameter)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: oox/source sd/qa

2021-04-29 Thread Tibor Nagy (via logerrit)
 oox/source/drawingml/hyperlinkcontext.cxx |2 +-
 sd/qa/unit/data/pptx/tdf65724.pptx|binary
 sd/qa/unit/import-tests.cxx   |   28 
 3 files changed, 29 insertions(+), 1 deletion(-)

New commits:
commit d0550d1c5d0e27b8fe9d93e2c7a6dc7ffc4f8c21
Author: Tibor Nagy 
AuthorDate: Thu Apr 15 12:12:47 2021 +0200
Commit: László Németh 
CommitDate: Thu Apr 29 11:03:09 2021 +0200

tdf#65724 PPTX import: fix internal hyperlink to slide

Internal hyperlinks were lost, if they refer slides
using their names.

Change-Id: Ic464300adb1e6e50bd4d61d957306592b7b22b14
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114139
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/drawingml/hyperlinkcontext.cxx 
b/oox/source/drawingml/hyperlinkcontext.cxx
index 7ea5d5d10b53..0221e3875d31 100644
--- a/oox/source/drawingml/hyperlinkcontext.cxx
+++ b/oox/source/drawingml/hyperlinkcontext.cxx
@@ -96,7 +96,7 @@ HyperLinkContext::HyperLinkContext( ContextHandler2Helper 
const & rParent,
 }
 else if ( aPPAction.match( "hlinksldjump" ) )
 {
-sURL.clear();
+sHref = sURL;
 
 sal_Int32 nIndex2 = 0;
 while ( nIndex2 < sHref.getLength() )
diff --git a/sd/qa/unit/data/pptx/tdf65724.pptx 
b/sd/qa/unit/data/pptx/tdf65724.pptx
new file mode 100644
index ..fef2d9f2dde7
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf65724.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index cbe6c061d90e..bbdc8b5a19cd 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -119,6 +119,7 @@ public:
 virtual void setUp() override;
 
 void testDocumentLayout();
+void testInternalHyperlink();
 void testHyperlinkColor();
 void testSmoketest();
 void testTdf131269();
@@ -236,6 +237,7 @@ public:
 CPPUNIT_TEST_SUITE(SdImportTest);
 
 CPPUNIT_TEST(testDocumentLayout);
+CPPUNIT_TEST(testInternalHyperlink);
 CPPUNIT_TEST(testHyperlinkColor);
 CPPUNIT_TEST(testSmoketest);
 CPPUNIT_TEST(testTdf131269);
@@ -429,6 +431,32 @@ void SdImportTest::testDocumentLayout()
 }
 }
 
+void SdImportTest::testInternalHyperlink()
+{
+::sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf65724.pptx"), 
PPTX);
+
+uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 1, 0, 
xDocShRef ) );
+
+// Get first paragraph
+uno::Reference const xParagraph( getParagraphFromShape( 
0, xShape ) );
+
+// first chunk of text
+uno::Reference xRun( getRunFromParagraph( 0, xParagraph 
) );
+uno::Reference< beans::XPropertySet > xPropSet( xRun, uno::UNO_QUERY_THROW 
);
+
+uno::Reference xField;
+xPropSet->getPropertyValue("TextField") >>= xField;
+CPPUNIT_ASSERT_MESSAGE("The text field is missing!", xField.is() );
+
+xPropSet.set(xField, uno::UNO_QUERY);
+OUString aURL;
+xPropSet->getPropertyValue("URL") >>= aURL;
+CPPUNIT_ASSERT_EQUAL_MESSAGE("URLs don't match", OUString("#Slide2"), 
aURL);
+
+xDocShRef->DoClose();
+}
+
 void SdImportTest::testHyperlinkColor()
 {
 ::sd::DrawDocShellRef xDocShRef = 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf137367.pptx"), 
PPTX);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: oox/source sd/qa

2021-04-22 Thread Xisco Fauli (via logerrit)
 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 54f7c32beca5a9c99d7316dc38818edad55f7415
Author: Xisco Fauli 
AuthorDate: Thu Apr 22 14:10:57 2021 +0200
Commit: Xisco Fauli 
CommitDate: Thu Apr 22 16:28:17 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 

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 64b44c559b6c..d3ec0063f9d2 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -97,6 +97,7 @@ public:
 void testTdf123090();
 void testTdf126324();
 void testTdf119187();
+void testTdf132472();
 void testTdf80224();
 void testExportTransitionsPPTX();
 void testPresetShapesExport();
@@ -224,6 +225,7 @@ public:
 CPPUNIT_TEST(testTdf123090);
 CPPUNIT_TEST(testTdf126324);
 CPPUNIT_TEST(testTdf119187);
+CPPUNIT_TEST(testTdf132472);
 CPPUNIT_TEST(testTdf80224);
 CPPUNIT_TEST(testExportTransitionsPPTX);
 CPPUNIT_TEST(testPresetShapesExport);
@@ -648,6 +650,35 @@ void SdOOXMLExportTest2::testTdf119187()
 }
 }
 
+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(u"/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: oox/source sd/qa

2021-03-29 Thread Gabor Kelemen (via logerrit)
 oox/source/drawingml/presetgeometrynames.cxx  |4 +--
 sd/qa/unit/data/pptx/ShapePlusImage.pptx  |binary
 sd/qa/unit/data/pptx/ShapeTextInflateTop.pptx |binary
 sd/qa/unit/export-tests-ooxml2.cxx|   34 ++
 4 files changed, 36 insertions(+), 2 deletions(-)

New commits:
commit 9083ed07950d8c9f3e5f2f8bba7f07862c6433e2
Author: Gabor Kelemen 
AuthorDate: Fri Jan 29 17:25:17 2021 +0100
Commit: László Németh 
CommitDate: Mon Mar 29 17:04:43 2021 +0200

tdf#125560 PPTX import: fix WordArt effect textDeflate and textInflateTop

These effects were mapped incorrectly, resulting missing display
and after ODP round-trip, changed effects.

Code pointers and test documents by Regina Henschel.

Change-Id: I8a05702b1c48492b9542dd827b1ac1daf2423bfd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112786
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/drawingml/presetgeometrynames.cxx 
b/oox/source/drawingml/presetgeometrynames.cxx
index d74cd352b282..04dff605c629 100644
--- a/oox/source/drawingml/presetgeometrynames.cxx
+++ b/oox/source/drawingml/presetgeometrynames.cxx
@@ -52,10 +52,10 @@ const PresetGeometryName pPresetGeometryNameArray[]
 { "textDoubleWave1", "mso-spt158" },
 { "textWave4", "mso-spt159" },
 { "textInflate", "fontwork-inflate" },
-{ "textDeflate", "fontwork-inflate" },
+{ "textDeflate", "mso-spt161" },
 { "textInflateBottom", "mso-spt162" },
 { "textDeflateBottom", "mso-spt163" },
-{ "textInflateTop", "mso-spt163" },
+{ "textInflateTop", "mso-spt164" },
 { "textDeflateTop", "mso-spt165" },
 { "textDeflateInflate", "mso-spt166" },
 { "textDeflateInflateDeflate", "mso-spt167" },
diff --git a/sd/qa/unit/data/pptx/ShapePlusImage.pptx 
b/sd/qa/unit/data/pptx/ShapePlusImage.pptx
new file mode 100644
index ..dd9424d172ce
Binary files /dev/null and b/sd/qa/unit/data/pptx/ShapePlusImage.pptx differ
diff --git a/sd/qa/unit/data/pptx/ShapeTextInflateTop.pptx 
b/sd/qa/unit/data/pptx/ShapeTextInflateTop.pptx
new file mode 100644
index ..cc8fd027909f
Binary files /dev/null and b/sd/qa/unit/data/pptx/ShapeTextInflateTop.pptx 
differ
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx 
b/sd/qa/unit/export-tests-ooxml2.cxx
index 839b9553a00e..432bd79d1993 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -209,6 +209,8 @@ public:
 void testShapeShadowBlurEffect();
 void testTdf119223();
 void testTdf128213ShapeRot();
+void testTdf125560_textDeflate();
+void testTdf125560_textInflateTop();
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
 
@@ -332,6 +334,8 @@ public:
 CPPUNIT_TEST(testShapeShadowBlurEffect);
 CPPUNIT_TEST(testTdf119223);
 CPPUNIT_TEST(testTdf128213ShapeRot);
+CPPUNIT_TEST(testTdf125560_textDeflate);
+CPPUNIT_TEST(testTdf125560_textInflateTop);
 
 CPPUNIT_TEST_SUITE_END();
 
@@ -357,6 +361,9 @@ public:
 { "wps", 
"http://schemas.microsoft.com/office/word/2010/wordprocessingShape; },
 { "wpg", 
"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup; },
 { "dgm", 
"http://schemas.openxmlformats.org/drawingml/2006/diagram; },
+// ODF
+{ "office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0" },
+{ "draw", "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" },
 };
 for (size_t i = 0; i < SAL_N_ELEMENTS(namespaces); ++i)
 {
@@ -3125,6 +3132,33 @@ 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::testTdf125560_textDeflate()
+{
+auto xDocShRef
+= loadURL( 
m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/ShapePlusImage.pptx"), PPTX 
);
+utl::TempFile tempFile;
+
+// This problem did not affect the pptx export, only the ODP so assert that
+xDocShRef = saveAndReload(xDocShRef.get(), ODP, );
+xDocShRef->DoClose();
+
+xmlDocUniquePtr pXmlDocRels = parseExport(tempFile, "content.xml");
+assertXPath(pXmlDocRels, 
"/office:document-content/office:body/office:presentation/draw:page/draw:custom-shape/draw:enhanced-geometry",
 "type", "mso-spt161");
+}
+
+void SdOOXMLExportTest2::testTdf125560_textInflateTop()
+{
+auto xDocShRef
+= loadURL( 
m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/ShapeTextInflateTop.pptx"), 
PPTX );
+utl::TempFile tempFile;
+
+// This problem did not affect the pptx export, only the ODP so assert that
+xDocShRef = saveAndReload(xDocShRef.get(), ODP, );
+xDocShRef->DoClose();
+
+xmlDocUniquePtr pXmlDocRels = parseExport(tempFile, "content.xml");
+assertXPath(pXmlDocRels, 

[Libreoffice-commits] core.git: oox/source sd/qa

2021-03-29 Thread Tibor Nagy (via logerrit)
 oox/source/drawingml/hyperlinkcontext.cxx |3 +-
 oox/source/drawingml/textrun.cxx  |4 ++
 sd/qa/unit/data/pptx/tdf137367.pptx   |binary
 sd/qa/unit/import-tests.cxx   |   41 ++
 4 files changed, 46 insertions(+), 2 deletions(-)

New commits:
commit f35e0b2cbfd6e7150aeb5699e1db1d7c13fdb935
Author: Tibor Nagy 
AuthorDate: Fri Mar 12 11:35:53 2021 +0100
Commit: László Németh 
CommitDate: Mon Mar 29 16:55:57 2021 +0200

tdf#137367 PPTX import: fix lost direct hyperlink colors

Regression from commit 92f74f6ccb5a55807724db85815f7ea0c49370e0
(bnc#887230: always use theme color for hyperlinks in Impress)

Testing: direct color of the first text line is theme based
(a:rPr/a:solidFill/a:schemeClr), the second line contains
a direct color (a:rPr/a:solidFill/a:srgbClr), the third one
contains a theme based direct color darkened by 25.000%
(val=75000 of a:rPr/a:solidFill/a:schemeClr/a:lumMod).

Note: overwriting default theme based hyperlink colors is
also supported by Google Docs, Office 365 and MS Office 2019.

Change-Id: I1e3e78fac729a97f42c8dddcffd877a16383adbf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112377
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/drawingml/hyperlinkcontext.cxx 
b/oox/source/drawingml/hyperlinkcontext.cxx
index be2336be5ba7..7ea5d5d10b53 100644
--- a/oox/source/drawingml/hyperlinkcontext.cxx
+++ b/oox/source/drawingml/hyperlinkcontext.cxx
@@ -150,7 +150,8 @@ ContextHandlerRef HyperLinkContext::onCreateContext(
 switch( aElement )
 {
 case A_TOKEN( extLst ):
-return nullptr;
+maProperties.setProperty(PROP_CharColor, XML_fillcolor);
+break;
 case A_TOKEN( snd ):
 // TODO use getEmbeddedWAVAudioFile() here
 break;
diff --git a/oox/source/drawingml/textrun.cxx b/oox/source/drawingml/textrun.cxx
index 8b34fd99082e..ab87fb732141 100644
--- a/oox/source/drawingml/textrun.cxx
+++ b/oox/source/drawingml/textrun.cxx
@@ -148,7 +148,9 @@ sal_Int32 TextRun::insertAt(
 
 xTextFieldCursor->gotoEnd( true );
 
-aTextCharacterProps.maFillProperties.maFillColor.setSchemeClr( 
XML_hlink );
+if 
(!maTextCharacterProperties.maHyperlinkPropertyMap.hasProperty(PROP_CharColor))
+
aTextCharacterProps.maFillProperties.maFillColor.setSchemeClr(XML_hlink);
+
 
aTextCharacterProps.maFillProperties.moFillType.set(XML_solidFill);
 if ( !maTextCharacterProperties.moUnderline.has() )
 aTextCharacterProps.moUnderline.set( XML_sng );
diff --git a/sd/qa/unit/data/pptx/tdf137367.pptx 
b/sd/qa/unit/data/pptx/tdf137367.pptx
new file mode 100644
index ..cf6aa086d9a8
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf137367.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 64c215d9b02a..1b36fc2ba866 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -118,6 +118,7 @@ public:
 virtual void setUp() override;
 
 void testDocumentLayout();
+void testHyperlinkColor();
 void testSmoketest();
 void testTdf131269();
 void testN759180();
@@ -236,6 +237,7 @@ public:
 CPPUNIT_TEST_SUITE(SdImportTest);
 
 CPPUNIT_TEST(testDocumentLayout);
+CPPUNIT_TEST(testHyperlinkColor);
 CPPUNIT_TEST(testSmoketest);
 CPPUNIT_TEST(testTdf131269);
 CPPUNIT_TEST(testN759180);
@@ -430,6 +432,45 @@ void SdImportTest::testDocumentLayout()
 }
 }
 
+void SdImportTest::testHyperlinkColor()
+{
+::sd::DrawDocShellRef xDocShRef = 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf137367.pptx"), 
PPTX);
+
+uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, 
xDocShRef ) );
+
+// Get first paragraph of the text
+uno::Reference const xParagraph1( getParagraphFromShape( 
0, xShape ) );
+// Get second paragraph of the text
+uno::Reference const xParagraph2( getParagraphFromShape( 
1, xShape ) );
+// Get third paragraph of the text
+uno::Reference const xParagraph3( getParagraphFromShape( 
2, xShape ) );
+
+// Get run of the first paragraph
+uno::Reference xRun1( getRunFromParagraph (0, 
xParagraph1 ) );
+uno::Reference< beans::XPropertySet > xPropSet1( xRun1, 
uno::UNO_QUERY_THROW );
+sal_Int32 nCharColorBlue;
+xPropSet1->getPropertyValue( "CharColor" ) >>= nCharColorBlue;
+
+// Get run of the second paragraph
+uno::Reference xRun2( getRunFromParagraph (1, 
xParagraph2 ) );
+uno::Reference< beans::XPropertySet > xPropSet2( xRun2, 
uno::UNO_QUERY_THROW );
+sal_Int32 nCharColorRed;
+xPropSet2->getPropertyValue( "CharColor" ) >>= nCharColorRed;
+
+// Get run of the third paragraph
+uno::Reference xRun3( getRunFromParagraph (2, 
xParagraph3 ) );
+uno::Reference< beans::XPropertySet 

[Libreoffice-commits] core.git: oox/source sd/qa

2021-03-23 Thread Gülşah Köse (via logerrit)
 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 db39b68c3c85531744ddeb8105b3ddb9b2dab099
Author: Gülşah Köse 
AuthorDate: Mon Mar 22 23:39:17 2021 +0300
Commit: Gülşah Köse 
CommitDate: Tue Mar 23 09:32:22 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 

diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 45a7a7e64307..b11ccbb5f97c 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -727,8 +727,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 e101731d0238..73201189ab81 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -81,6 +81,7 @@ public:
 void testShadowBlur();
 void testRhbz1870501();
 void testTdf128550();
+void testTdf140714();
 
 CPPUNIT_TEST_SUITE(SdExportTest);
 
@@ -120,6 +121,7 @@ public:
 CPPUNIT_TEST(testShadowBlur);
 CPPUNIT_TEST(testRhbz1870501);
 CPPUNIT_TEST(testTdf128550);
+CPPUNIT_TEST(testTdf140714);
 
 CPPUNIT_TEST_SUITE_END();
 
@@ -1351,6 +1353,20 @@ void SdExportTest::testTdf128550()
 
 }
 
+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: oox/source sd/qa

2021-03-19 Thread Tibor Nagy (via logerrit)
 oox/source/export/shapes.cxx|8 +++-
 sd/qa/unit/data/pptx/tdf131905.pptx |binary
 sd/qa/unit/export-tests-ooxml2.cxx  |   28 
 3 files changed, 35 insertions(+), 1 deletion(-)

New commits:
commit 48f6ce530f3546570eabdf398388185ab988636b
Author: Tibor Nagy 
AuthorDate: Mon Mar 8 16:07:59 2021 +0100
Commit: László Németh 
CommitDate: Fri Mar 19 16:55:03 2021 +0100

tdf#131905 PPTX table export: fix vertical alignment

Table cells lost their vertical alignment.

Change-Id: Id5ca22550b5613566d7ea2a93e8a36fdca31860d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112171
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 13c52d22c56e..e889901c477c 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1780,6 +1780,8 @@ void ShapeExport::WriteTable( const Reference< XShape >& 
rXShape  )
 void ShapeExport::WriteTableCellProperties(const Reference< XPropertySet>& 
xCellPropSet)
 {
 sal_Int32 nLeftMargin(0), nRightMargin(0);
+TextVerticalAdjust eVerticalAlignment;
+const char* sVerticalAlignment;
 
 Any aLeftMargin = xCellPropSet->getPropertyValue("TextLeftDistance");
 aLeftMargin >>= nLeftMargin;
@@ -1787,7 +1789,11 @@ void ShapeExport::WriteTableCellProperties(const 
Reference< XPropertySet>& xCell
 Any aRightMargin = xCellPropSet->getPropertyValue("TextRightDistance");
 aRightMargin >>= nRightMargin;
 
-mpFS->startElementNS(XML_a, XML_tcPr,
+Any aVerticalAlignment = 
xCellPropSet->getPropertyValue("TextVerticalAdjust");
+aVerticalAlignment >>= eVerticalAlignment;
+sVerticalAlignment = GetTextVerticalAdjust(eVerticalAlignment);
+
+mpFS->startElementNS(XML_a, XML_tcPr, XML_anchor, sVerticalAlignment,
 XML_marL, 
sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nLeftMargin)),
 nLeftMargin > 0),
 XML_marR, 
sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nRightMargin)),
 nRightMargin > 0));
 
diff --git a/sd/qa/unit/data/pptx/tdf131905.pptx 
b/sd/qa/unit/data/pptx/tdf131905.pptx
new file mode 100644
index ..4d203510f093
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf131905.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx 
b/sd/qa/unit/export-tests-ooxml2.cxx
index 9523d5718a46..3d8e93b8b003 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -87,6 +87,7 @@ static void assertMotionPath(const OUString , const 
OUString , const
 class SdOOXMLExportTest2 : public SdModelTestBaseXML
 {
 public:
+void testTdf131905();
 void testTdf93883();
 void testTdf91378();
 void testBnc822341();
@@ -211,6 +212,7 @@ public:
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
 
+CPPUNIT_TEST(testTdf131905);
 CPPUNIT_TEST(testTdf93883);
 CPPUNIT_TEST(testTdf91378);
 CPPUNIT_TEST(testBnc822341);
@@ -366,6 +368,32 @@ public:
 
 };
 
+void SdOOXMLExportTest2::testTdf131905()
+{
+::sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf131905.pptx"), 
PPTX);
+utl::TempFile tempFile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+
+xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, 
"ppt/slides/slide1.xml");
+assertXPath(
+pXmlDocContent,
+
"/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData/a:tbl/a:tr[1]/a:tc/a:tcPr",
+"anchor", "t");
+
+assertXPath(
+pXmlDocContent,
+
"/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData/a:tbl/a:tr[2]/a:tc/a:tcPr",
+"anchor", "ctr");
+
+assertXPath(
+pXmlDocContent,
+
"/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData/a:tbl/a:tr[3]/a:tc/a:tcPr",
+"anchor", "b");
+
+xDocShRef->DoClose();
+}
+
 void SdOOXMLExportTest2::testTdf93883()
 {
 ::sd::DrawDocShellRef xDocShRef = loadURL( 
m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf93883.odp"), ODP);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: oox/source sd/qa

2021-03-10 Thread Regina Henschel (via logerrit)
 oox/source/drawingml/scene3dcontext.cxx|   24 +
 oox/source/drawingml/textbodypropertiescontext.cxx |   16 ++
 sd/qa/unit/data/pptx/tdf140865Wordart3D.pptx   |binary
 sd/qa/unit/export-tests-ooxml1.cxx |   24 +
 4 files changed, 64 insertions(+)

New commits:
commit dbbb8cafcb801638bde3b21796eaebfc807acbdc
Author: Regina Henschel 
AuthorDate: Mon Mar 8 17:28:27 2021 +0100
Commit: Regina Henschel 
CommitDate: Wed Mar 10 12:33:38 2021 +0100

tdf#140865 roundtrip pptx wordart 3D, add sp3d

Change-Id: I446ae4e8c9dd5f2fbf3efe289681339f967c515a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112185
Tested-by: Jenkins
Reviewed-by: Regina Henschel 

diff --git a/oox/source/drawingml/scene3dcontext.cxx 
b/oox/source/drawingml/scene3dcontext.cxx
index 91b73f0bbd95..813f9442c901 100644
--- a/oox/source/drawingml/scene3dcontext.cxx
+++ b/oox/source/drawingml/scene3dcontext.cxx
@@ -92,6 +92,30 @@ ContextHandlerRef 
SceneText3DPropertiesContext::onCreateContext( sal_Int32 aElem
 case A_TOKEN( backdrop ):
 case A_TOKEN( extLst ):
 return nullptr; // TODO: later (backdrop is not supported by core 
anyway)
+
+case A_TOKEN( bevelT ):
+case A_TOKEN( bevelB ):
+{
+BevelProperties aProps;
+if( rAttribs.hasAttribute( XML_w ) )
+aProps.mnWidth = rAttribs.getInteger( XML_w, 0 );
+if( rAttribs.hasAttribute( XML_h ) )
+aProps.mnHeight = rAttribs.getInteger( XML_h, 0 );
+if( rAttribs.hasAttribute( XML_prst ) )
+aProps.mnPreset = rAttribs.getToken( XML_prst, XML_none );
+
+if( aElementToken == A_TOKEN( bevelT ) )
+mr3DProperties.maTopBevelProperties.set( aProps );
+else
+mr3DProperties.maBottomBevelProperties.set( aProps );
+break;
+}
+
+case A_TOKEN( extrusionClr ):
+return new ColorContext( *this, mr3DProperties.maExtrusionColor );
+
+case A_TOKEN( contourClr ):
+return new ColorContext( *this, mr3DProperties.maContourColor );
 }
 return nullptr;
 }
diff --git a/oox/source/drawingml/textbodypropertiescontext.cxx 
b/oox/source/drawingml/textbodypropertiescontext.cxx
index 5bc244b73fc2..4d94191dcfc7 100644
--- a/oox/source/drawingml/textbodypropertiescontext.cxx
+++ b/oox/source/drawingml/textbodypropertiescontext.cxx
@@ -177,6 +177,22 @@ ContextHandlerRef 
TextBodyPropertiesContext::onCreateContext( sal_Int32 aElement
 
 // EG_Text3D
 case A_TOKEN( sp3d ):   // CT_Shape3D
+{
+if (mpShapePtr && mpShapePtr->getServiceName() == 
"com.sun.star.drawing.CustomShape")
+{
+if (rAttribs.hasAttribute(XML_extrusionH))
+
mpShapePtr->getTextBody()->get3DProperties().mnExtrusionH = 
rAttribs.getInteger(XML_extrusionH, 0);
+if (rAttribs.hasAttribute(XML_contourW))
+
mpShapePtr->getTextBody()->get3DProperties().mnContourW = 
rAttribs.getInteger(XML_contourW, 0);
+if (rAttribs.hasAttribute(XML_z))
+mpShapePtr->getTextBody()->get3DProperties().mnShapeZ 
= rAttribs.getInteger(XML_z, 0);
+if (rAttribs.hasAttribute(XML_prstMaterial))
+
mpShapePtr->getTextBody()->get3DProperties().mnMaterial = 
rAttribs.getToken(XML_prstMaterial, XML_none);
+return new SceneText3DPropertiesContext(*this, 
mpShapePtr->getTextBody()->get3DProperties());
+}
+break;
+}
+
 case A_TOKEN( flatTx ): // CT_FlatText
 
 break;
diff --git a/sd/qa/unit/data/pptx/tdf140865Wordart3D.pptx 
b/sd/qa/unit/data/pptx/tdf140865Wordart3D.pptx
new file mode 100644
index ..e55bc43800b4
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf140865Wordart3D.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx 
b/sd/qa/unit/export-tests-ooxml1.cxx
index 7c3739fa1a7d..1e5f673428c2 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -109,6 +109,7 @@ public:
 void testTdf136911();
 void testArcTo();
 void testNarrationMimeType();
+void testTdf140865Wordart3D();
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest1);
 
@@ -160,6 +161,7 @@ public:
 CPPUNIT_TEST(testTdf136911);
 CPPUNIT_TEST(testArcTo);
 CPPUNIT_TEST(testNarrationMimeType);
+CPPUNIT_TEST(testTdf140865Wordart3D);
 
 CPPUNIT_TEST_SUITE_END();
 
@@ -1380,6 +1382,28 @@ void SdOOXMLExportTest1::testNarrationMimeType()
 xDocShRef->DoClose();
 }
 
+void SdOOXMLExportTest1::testTdf140865Wordart3D()
+{
+sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf140865Wordart3D.pptx"),
 PPTX);
+utl::TempFile aTempFile;
+xDocShRef = saveAndReload(xDocShRef.get(), 

[Libreoffice-commits] core.git: oox/source sd/qa

2021-02-09 Thread Gülşah Köse (via logerrit)
 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 b7189e1a9aef85ac2e3423cc4c136d97ebf0a58b
Author: Gülşah Köse 
AuthorDate: Mon Feb 8 13:30:39 2021 +0300
Commit: Gülşah Köse 
CommitDate: Wed Feb 10 08:08:35 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 

diff --git a/oox/source/drawingml/fillproperties.cxx 
b/oox/source/drawingml/fillproperties.cxx
index 6feeb1c9991d..2022df1d335a 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -166,6 +166,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)
 {
@@ -899,6 +915,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 8af1b3000e9b..617580ff7f56 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -214,6 +214,7 @@ public:
 void testShapeBlurPPTXImport();
 void testMirroredGraphic();
 void testCropPositionGraphic();
+void testGreysScaleGraphic();
 
 bool checkPattern(sd::DrawDocShellRef const & rDocRef, int nShapeNumber, 
std::vector& rExpected);
 void testPatternImport();
@@ -344,6 +345,7 @@ public:
 CPPUNIT_TEST(testShapeBlurPPTXImport);
 CPPUNIT_TEST(testMirroredGraphic);
 CPPUNIT_TEST(testCropPositionGraphic);
+CPPUNIT_TEST(testGreysScaleGraphic);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -3337,6 +3339,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: oox/source sd/qa

2021-02-09 Thread Gülşah Köse (via logerrit)
 oox/source/drawingml/fillproperties.cxx |   84 
 oox/source/export/drawingml.cxx |   39 +-
 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, 129 insertions(+), 39 deletions(-)

New commits:
commit ccdee8eebaa56619248e35001017226eecfe4e83
Author: Gülşah Köse 
AuthorDate: Mon Feb 1 17:03:33 2021 +0300
Commit: Gülşah Köse 
CommitDate: Wed Feb 10 07:04:38 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 

diff --git a/oox/source/drawingml/fillproperties.cxx 
b/oox/source/drawingml/fillproperties.cxx
index 6d537097a206..6feeb1c9991d 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -87,6 +87,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);
@@ -103,8 +127,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());
@@ -819,6 +850,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);
+
+rPropMap.setProperty(PROP_FillBitmap, xGraphic);
+}
+
+}
+
 if(mbIsCustomShape)
 {
  

[Libreoffice-commits] core.git: oox/source sd/qa sd/source

2021-01-22 Thread Miklos Vajna (via logerrit)
 oox/source/ppt/timenodelistcontext.cxx|2 +-
 sd/qa/unit/export-tests-ooxml1.cxx|5 +
 sd/source/filter/eppt/pptx-animations.cxx |   30 --
 3 files changed, 30 insertions(+), 7 deletions(-)

New commits:
commit 6b15a8658f369e4144251854bcdb736acb595f47
Author: Miklos Vajna 
AuthorDate: Fri Jan 22 17:13:59 2021 +0100
Commit: Miklos Vajna 
CommitDate: Fri Jan 22 19:47:33 2021 +0100

PPTX filter: fix playFrom command handling for slide narrations

The import side went wrong in commit
812ee7a6dc29b55acfbeaa1a43e632adbaf72e6b (Removal rtl and string
cleanup, 2012-12-31), which turned a prefix check into an equality
check.

The export side ignored the command parameters, now we write 'playFrom'
instead of 'play' in case we have a start timestamp.

Change-Id: Ia7e058e17400b1efbf7a6254355a70c4a5e15dbe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109825
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/oox/source/ppt/timenodelistcontext.cxx 
b/oox/source/ppt/timenodelistcontext.cxx
index 017b95673c84..3b40af62f2d0 100644
--- a/oox/source/ppt/timenodelistcontext.cxx
+++ b/oox/source/ppt/timenodelistcontext.cxx
@@ -297,7 +297,7 @@ namespace oox::ppt {
 {
 nCommand = EffectCommands::PLAY;
 }
-else if( msCommand == "playFrom" )
+else if (msCommand.startsWith("playFrom"))
 {
 const OUString aMediaTime( msCommand.copy( 9, 
msCommand.getLength() - 10 ) );
 rtl_math_ConversionStatus eStatus;
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx 
b/sd/qa/unit/export-tests-ooxml1.cxx
index e6b32ff357ca..e87c04a06cbb 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -1342,6 +1342,11 @@ void SdOOXMLExportTest1::testNarrationMimeType()
 // i.e. p:blipFill was missing its a:stretch child element, so the shape 
was invisible.
 assertXPath(pSlideDoc, 
"/p:sld/p:cSld/p:spTree/p:pic/p:blipFill/a:stretch/a:fillRect", 1);
 
+// Without the accompanying fix in place, this test would have failed with:
+// - ... no attribute 'cmd' exist
+// i.e. '' was written instead of ''.
+assertXPath(pSlideDoc, "//p:cmd", "cmd", "playFrom(0.0)");
+
 xDocShRef->DoClose();
 }
 
diff --git a/sd/source/filter/eppt/pptx-animations.cxx 
b/sd/source/filter/eppt/pptx-animations.cxx
index bc36afb1283a..533f4804df81 100644
--- a/sd/source/filter/eppt/pptx-animations.cxx
+++ b/sd/source/filter/eppt/pptx-animations.cxx
@@ -22,6 +22,8 @@
 #include "epptooxml.hxx"
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -60,6 +62,7 @@
 #include "pptx-animations.hxx"
 #include "../ppt/pptanimations.hxx"
 
+using namespace ::com::sun::star;
 using namespace ::com::sun::star::animations;
 using namespace ::com::sun::star::container;
 using namespace ::com::sun::star::presentation;
@@ -1137,28 +1140,43 @@ void PPTXAnimationExport::WriteAnimationNodeCommand()
 return;
 
 const char* pType = "call";
-const char* pCommand = nullptr;
+OString aCommand;
 switch (xCommand->getCommand())
 {
 case EffectCommands::VERB:
 pType = "verb";
-pCommand = "1"; /* FIXME hardcoded viewing */
+aCommand = "1"; /* FIXME hardcoded viewing */
 break;
 case EffectCommands::PLAY:
-pCommand = "play";
+{
+aCommand = "play";
+uno::Sequence aParamSeq;
+xCommand->getParameter() >>= aParamSeq;
+comphelper::SequenceAsHashMap aMap(aParamSeq);
+auto it = aMap.find("MediaTime");
+if (it != aMap.end())
+{
+double fMediaTime = 0;
+it->second >>= fMediaTime;
+// PowerPoint represents 0 as 0.0, so just use a single 
decimal.
+OString aMediaTime
+= rtl::math::doubleToString(fMediaTime, 
rtl_math_StringFormat_F, 1, '.');
+aCommand += "From(" + aMediaTime + ")";
+}
 break;
+}
 case EffectCommands::TOGGLEPAUSE:
-pCommand = "togglePause";
+aCommand = "togglePause";
 break;
 case EffectCommands::STOP:
-pCommand = "stop";
+aCommand = "stop";
 break;
 default:
 SAL_WARN("sd.eppt", "unknown command: " << xCommand->getCommand());
 break;
 }
 
-mpFS->startElementNS(XML_p, XML_cmd, XML_type, pType, XML_cmd, pCommand);
+mpFS->startElementNS(XML_p, XML_cmd, XML_type, pType, XML_cmd, 
aCommand.getStr());
 
 WriteAnimationNodeAnimateInside(false);
 mpFS->startElementNS(XML_p, XML_cBhvr);
___
Libreoffice-commits 

[Libreoffice-commits] core.git: oox/source sd/qa

2021-01-22 Thread Miklos Vajna (via logerrit)
 oox/source/export/shapes.cxx   |8 
 sd/qa/unit/export-tests-ooxml1.cxx |6 ++
 2 files changed, 14 insertions(+)

New commits:
commit a02ea004c35edeb4e93b1cdcaa087e8bdcf1ee47
Author: Miklos Vajna 
AuthorDate: Fri Jan 22 09:19:00 2021 +0100
Commit: Miklos Vajna 
CommitDate: Fri Jan 22 11:02:27 2021 +0100

PPTX export: fix size of shape for slide narrations

This was invisible in PowerPoint without explicit stretching.

Change-Id: I29b9f23eba6d59436cb1b6d15c9840794f932e69
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109778
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 9033e1d40d88..13c52d22c56e 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1238,6 +1238,14 @@ void ShapeExport::WriteGraphicObjectShapePart( const 
Reference< XShape >& xShape
 if ( pGraphic || bStretch )
 pFS->singleElementNS(XML_a, XML_stretch);
 
+if (bHasMediaURL)
+{
+// Graphic of media shapes is always stretched.
+pFS->startElementNS(XML_a, XML_stretch);
+pFS->singleElementNS(XML_a, XML_fillRect);
+pFS->endElementNS(XML_a, XML_stretch);
+}
+
 pFS->endElementNS( mnXmlNamespace, XML_blipFill );
 
 // visual shape properties
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx 
b/sd/qa/unit/export-tests-ooxml1.cxx
index 91ce68e20a50..e6b32ff357ca 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -1336,6 +1336,12 @@ void SdOOXMLExportTest1::testNarrationMimeType()
 // i.e. the bitmap of the narration was lost, some default placeholder was 
exported instead.
 CPPUNIT_ASSERT_EQUAL(static_cast(256), 
aBitmapEx.GetSizePixel().Height());
 
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 1
+// - Actual  : 0
+// i.e. p:blipFill was missing its a:stretch child element, so the shape 
was invisible.
+assertXPath(pSlideDoc, 
"/p:sld/p:cSld/p:spTree/p:pic/p:blipFill/a:stretch/a:fillRect", 1);
+
 xDocShRef->DoClose();
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: oox/source sd/qa

2021-01-20 Thread Mark Hung (via logerrit)
 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 9b19bf0283b569a5c134de6b5cce1d72d8f37879
Author: Mark Hung 
AuthorDate: Sat Jan 16 23:48:56 2021 +0800
Commit: Mark Hung 
CommitDate: Wed Jan 20 12:14:21 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 

diff --git a/oox/source/ppt/timenode.cxx b/oox/source/ppt/timenode.cxx
index 3e08a6716d74..132c54b79f4a 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 );
 }
 }
 
@@ -320,15 +355,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 56227498f2e5..e101731d0238 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -80,6 +80,7 @@ public:
 void testSoftEdges();
 void testShadowBlur();
 void testRhbz1870501();
+void testTdf128550();
 
 CPPUNIT_TEST_SUITE(SdExportTest);
 
@@ -118,6 +119,7 @@ public:
 CPPUNIT_TEST(testSoftEdges);
 CPPUNIT_TEST(testShadowBlur);
 

[Libreoffice-commits] core.git: oox/source sd/qa

2021-01-19 Thread Miklos Vajna (via logerrit)
 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 1359e8c566970fcef860f7ba7f54a07d8e6e0513
Author: Miklos Vajna 
AuthorDate: Tue Jan 19 16:59:38 2021 +0100
Commit: Miklos Vajna 
CommitDate: Tue Jan 19 21:35: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.

Change-Id: I80db290bd1695884ffb7b1eabaffa09462e8883d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109642
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 5a9fad2a3e73..562c20d05e7f 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 37e6941c997c..ecd881330f63 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -116,6 +116,7 @@ public:
 void testLinearRuleVert();
 void testAutofitSync();
 void testSnakeRows();
+void testCompositeInferRight();
 
 CPPUNIT_TEST_SUITE(SdImportTestSmartArt);
 
@@ -168,6 +169,7 @@ public:
 CPPUNIT_TEST(testLinearRuleVert);
 CPPUNIT_TEST(testAutofitSync);
 CPPUNIT_TEST(testSnakeRows);
+CPPUNIT_TEST(testCompositeInferRight);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -1726,6 +1728,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;
+
+// Without the accompanying fix in place, this test would have failed with:
+// - 

[Libreoffice-commits] core.git: oox/source sd/qa

2021-01-15 Thread Miklos Vajna (via logerrit)
 oox/source/export/drawingml.cxx |5 +
 sd/qa/unit/data/pptx/narration.pptx |binary
 sd/qa/unit/export-tests-ooxml1.cxx  |   19 +++
 3 files changed, 24 insertions(+)

New commits:
commit 56f26399df894d05f24874a3cdc90694158e03bc
Author: Miklos Vajna 
AuthorDate: Fri Jan 15 15:53:19 2021 +0100
Commit: Miklos Vajna 
CommitDate: Sat Jan 16 01:18:31 2021 +0100

PPTX export: fix mime type of slide narrations

Import was working already for the audio stream.

Change-Id: I43ac6561c4e39decfd99587e489cb205bb0c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109374
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 8e8acb50cc92..897fb0ff42a8 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1322,6 +1322,11 @@ void DrawingML::WriteMediaNonVisualProperties(const 
css::uno::ReferenceDoClose();
+}
+
 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


[Libreoffice-commits] core.git: oox/source sd/qa

2021-01-15 Thread Tünde Tóth (via logerrit)
 oox/source/export/drawingml.cxx |   28 +++-
 sd/qa/unit/data/pptx/arc-validiert.pptx |binary
 sd/qa/unit/export-tests-ooxml1.cxx  |   18 ++
 3 files changed, 45 insertions(+), 1 deletion(-)

New commits:
commit 7337e7e74d8bde77a56552bcb7b40bf1668c87b7
Author: Tünde Tóth 
AuthorDate: Wed Jan 6 13:24:10 2021 +0100
Commit: László Németh 
CommitDate: Fri Jan 15 10:49:54 2021 +0100

tdf#61028 OOXML export: fix lost arcTo shape

a:custGeom was exported without the a:arcTo element
and its attributes.

Note: see customshapegeometry.cxx for import of a:arcTo
attributes.

Change-Id: I611ea9fb6a81d45cfd52a16abbb37071ea0ce7d1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108874
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index c63e7d4181f1..8e8acb50cc92 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -3589,7 +3589,33 @@ bool DrawingML::WriteCustomGeometry(
 }
 case 
drawing::EnhancedCustomShapeSegmentCommand::ARCANGLETO :
 {
-nPairIndex += 2;
+if (nPairIndex + 1 >= aPairs.getLength())
+bOK = false;
+else
+{
+const EnhancedCustomShape2d aCustoShape2d(
+
const_cast(rSdrObjCustomShape));
+double fWR = 0.0;
+aCustoShape2d.GetParameter(fWR, 
aPairs[nPairIndex].First, false,
+   false);
+double fHR = 0.0;
+aCustoShape2d.GetParameter(fHR, 
aPairs[nPairIndex].Second,
+   false, false);
+double fStartAngle = 0.0;
+aCustoShape2d.GetParameter(
+fStartAngle, aPairs[nPairIndex + 
1].First, false, false);
+sal_Int32 
nStartAng(std::lround(fStartAngle * 6));
+double fSwingAng = 0.0;
+aCustoShape2d.GetParameter(
+fSwingAng, aPairs[nPairIndex + 
1].Second, false, false);
+sal_Int32 nSwingAng(std::lround(fSwingAng 
* 6));
+mpFS->singleElement(FSNS(XML_a, XML_arcTo),
+XML_wR, 
OString::number(fWR),
+XML_hR, 
OString::number(fHR),
+XML_stAng, 
OString::number(nStartAng),
+XML_swAng, 
OString::number(nSwingAng));
+nPairIndex += 2;
+}
 break;
 }
 default:
diff --git a/sd/qa/unit/data/pptx/arc-validiert.pptx 
b/sd/qa/unit/data/pptx/arc-validiert.pptx
new file mode 100644
index ..163f187b0bcc
Binary files /dev/null and b/sd/qa/unit/data/pptx/arc-validiert.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx 
b/sd/qa/unit/export-tests-ooxml1.cxx
index ba04f02911be..6b782c3067a6 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -105,6 +105,7 @@ public:
 void testTdf128345GradientAxial();
 void testTdf134969TransparencyOnColorGradient();
 void testTdf136911();
+void testArcTo();
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest1);
 
@@ -154,6 +155,7 @@ public:
 CPPUNIT_TEST(testTdf128345GradientAxial);
 CPPUNIT_TEST(testTdf134969TransparencyOnColorGradient);
 CPPUNIT_TEST(testTdf136911);
+CPPUNIT_TEST(testArcTo);
 
 CPPUNIT_TEST_SUITE_END();
 
@@ -1279,6 +1281,22 @@ void 
SdOOXMLExportTest1::testTdf134969TransparencyOnColorGradient()
 assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[2]/a:srgbClr/a:alpha", 
"val", "6");
 }
 
+void SdOOXMLExportTest1::testArcTo()
+{
+::sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/arc-validiert.pptx"),
 PPTX);
+utl::TempFile tempFile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+xDocShRef->DoClose();
+
+xmlDocUniquePtr pXmlDoc = parseExport(tempFile, "ppt/slides/slide1.xml");
+const OString sPath("//a:custGeom/a:pathLst/a:path/a:arcTo");
+assertXPath(pXmlDoc, sPath, "wR", "3");
+assertXPath(pXmlDoc, 

[Libreoffice-commits] core.git: oox/source sd/qa

2021-01-12 Thread Miklos Vajna (via logerrit)
 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 f2e04fe98e313cffa3f98d55eae641415142a431
Author: Miklos Vajna 
AuthorDate: Tue Jan 12 10:13:14 2021 +0100
Commit: Miklos Vajna 
CommitDate: Tue Jan 12 15:40:43 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.

Change-Id: Ifd0027e9616b0909dbfde43e1555427b50de4dad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109161
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index cc2d176a4020..8e65a2161180 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 d63c21f7f5bb..37e6941c997c 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -76,6 +76,7 @@ public:
 void testRotation();
 void testTextAutoRotation();
 void testPyramid();
+void testPyramidOneChild();
 void testChevron();
 void testCycle();
 void testvenndiagram();
@@ -127,6 +128,7 @@ public:
 CPPUNIT_TEST(testRotation);
 CPPUNIT_TEST(testTextAutoRotation);
 CPPUNIT_TEST(testPyramid);
+CPPUNIT_TEST(testPyramidOneChild);
 CPPUNIT_TEST(testChevron);
 CPPUNIT_TEST(testCycle);
 CPPUNIT_TEST(testHierarchy);
@@ -451,6 +453,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
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: oox/source sd/qa

2020-12-02 Thread Gülşah Köse (via logerrit)
 oox/source/drawingml/lineproperties.cxx |4 ++--
 oox/source/export/drawingml.cxx |4 ++--
 sd/qa/unit/uiimpress.cxx|   14 --
 3 files changed, 16 insertions(+), 6 deletions(-)

New commits:
commit 5d80f679e1891f98ef964efa1166c90d001c5806
Author: Gülşah Köse 
AuthorDate: Mon Nov 30 13:29:19 2020 +0300
Commit: Gülşah Köse 
CommitDate: Wed Dec 2 14:06:46 2020 +0100

tdf#136957 Use bigger dots for better handling in presentation mode.

3 pt bigger dots are used. Human eye can't catch this
change so we will see same dots in edit mode and presentation mode.

Change-Id: I4a56406f4eb7a6832075a09a4d2f092bd689e9cb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106855
Tested-by: Jenkins
Reviewed-by: Gülşah Köse 

diff --git a/oox/source/drawingml/lineproperties.cxx 
b/oox/source/drawingml/lineproperties.cxx
index 451da4c6aa26..87c502f96f6b 100644
--- a/oox/source/drawingml/lineproperties.cxx
+++ b/oox/source/drawingml/lineproperties.cxx
@@ -470,9 +470,9 @@ void LineProperties::pushToPropMap( ShapePropertyMap& 
rPropMap,
 // 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;
+aLineDash.Distance += 96;
 if (aLineDash.DotLen >= 100)
-aLineDash.DotLen -= 99;
+aLineDash.DotLen -= 96;
 if (aLineDash.DashLen >= 100)
 aLineDash.DashLen -= 99;
 }
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index eca53a92d5a8..f309e1541409 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -966,8 +966,8 @@ void DrawingML::WriteOutline( const 
Reference& rXPropSet, Referenc
 sal_uInt32 nDistance = aLineDash.Distance;
 if (aLineCap != LineCap_BUTT && nDistance >= 99)
 {
-nDistance -= 99;
-nDotLen += 99;
+nDistance -= 96;
+nDotLen += 96;
 if (nDashLen > 0)
 nDashLen += 99;
 }
diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx
index fbd23a24eda0..2b492be3fffd 100644
--- a/sd/qa/unit/uiimpress.cxx
+++ b/sd/qa/unit/uiimpress.cxx
@@ -375,9 +375,19 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf134053)
 // Because 0% is not possible as dash length (as of June 2020) 1% is used 
in the fix.
 // For that a larger delta is here allowed to the ideal value than needed 
for
 // rounding errors.
-CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Distance", 2117, fDistance, 12);
 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Dot length", 706, fDotLength, 12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Dash length", 2822, fDashLength, 12);
+
+// tdf#136957 (dotted lines are  disappearing in presentation mode)
+// Test value used as 2089 instead of 2117 for tdf#136957 workaround.
+// If this test fails as Expected: 2089 Actual:2117
+// plaese test tdf#136957 manually and use 2117 as test value again.
+CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Distance", 2089, fDistance, 12);
+
+// tdf#136957 (dotted lines are  disappearing in presentation mode)
+// Test value used as 2854 instead of 2822 for tdf#136957 workaround.
+// If this test fails as Expected: 2854 Actual:2822
+// plaese test tdf#136957 manually and use 2822 as test value again.
+CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Dash length", 2854, fDashLength, 12);
 }
 
 CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testSpellOnlineParameter)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: oox/source sd/qa

2020-11-05 Thread Gülşah Köse (via logerrit)
 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 9f3b85dc29326e779ccc6be3b649b7fb24571ee0
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 17:05:46 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 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 8908af370e0b..d8615d79300e 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1747,7 +1747,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 9f967b7963b9..e71c4f5ec904 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -193,6 +193,7 @@ public:
 void testTdf127379();
 void testTdf98603();
 void testTdf79082();
+void testTdf128213();
 void testTdf129372();
 void testShapeGlowEffect();
 void testTdf119087();
@@ -312,6 +313,7 @@ public:
 CPPUNIT_TEST(testTdf127379);
 CPPUNIT_TEST(testTdf98603);
 CPPUNIT_TEST(testTdf79082);
+CPPUNIT_TEST(testTdf128213);
 CPPUNIT_TEST(testTdf129372);
 CPPUNIT_TEST(testShapeGlowEffect);
 CPPUNIT_TEST(testTdf119087);
@@ -2842,6 +2844,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,  );
+
+xmlDocUniquePtr 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: oox/source sd/qa

2020-10-20 Thread Miklos Vajna (via logerrit)
 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 c719db99166a7b4770855a9599ec65c70cd256c5
Author: Miklos Vajna 
AuthorDate: Mon Oct 19 21:07:10 2020 +0200
Commit: Miklos Vajna 
CommitDate: Tue Oct 20 09:01:34 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.

Change-Id: I31a894157996a2371b8d0ec482ee91dc4d5b053e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104541
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 644c31790d64..5071a7bd52d4 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 f9ec7c430fb0..4a7da0915f24 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 testTdf134221();
 void testLinearRule();
+void testLinearRuleVert();
 void testAutofitSync();
 void testSnakeRows();
 
@@ -161,6 +162,7 @@ public:
 CPPUNIT_TEST(testFillColorList);
 CPPUNIT_TEST(testTdf134221);
 CPPUNIT_TEST(testLinearRule);
+CPPUNIT_TEST(testLinearRuleVert);
 CPPUNIT_TEST(testAutofitSync);
 CPPUNIT_TEST(testSnakeRows);
 
@@ -1568,6 +1570,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: oox/source sd/qa

2020-09-30 Thread Miklos Vajna (via logerrit)
 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 71303c5c23bdb385e9f12c0dbe5d2a0818b836ec
Author: Miklos Vajna 
AuthorDate: Wed Sep 30 12:41:15 2020 +0200
Commit: Miklos Vajna 
CommitDate: Wed Sep 30 14:50:23 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.

Change-Id: Ia2606dcd945402f7dfe17c6e2f261bfd98667022
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103680
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index f4ca071976fa..d9d905066733 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;
+
+// Child shapes are not allowed to leave their parent.
+

[Libreoffice-commits] core.git: oox/source sd/qa

2020-09-29 Thread Miklos Vajna (via logerrit)
 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 5d899bf3ee59a226f855c8c56389344862efaa95
Author: Miklos Vajna 
AuthorDate: Tue Sep 29 17:41:12 2020 +0200
Commit: Miklos Vajna 
CommitDate: Tue Sep 29 21:05:54 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.

Change-Id: I4eb2f06676df11c1432e0934ca3a0ec8891c5843
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103629
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 052dc19b1361..f4ca071976fa 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.
+double fWidthFactor = 
static_cast(aShapeWidths[index]) / nMaxRowWidth;
+

[Libreoffice-commits] core.git: oox/source sd/qa

2020-09-25 Thread Miklos Vajna (via logerrit)
 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 acc9aead3cc5162379d34a455aa15f7b13907cf1
Author: Miklos Vajna 
AuthorDate: Fri Sep 25 17:27:03 2020 +0200
Commit: Miklos Vajna 
CommitDate: Fri Sep 25 19:43:29 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.

Change-Id: I1d02df4834b8a2ce97d5e006db0e3135d3d42917
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103411
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 8f261f625d5a..b0aed039ba94 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 616f18f0b5f0..72d8811571fb 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -112,6 +112,7 @@ public:
 void testTdf134221();
 void testLinearRule();
 void testAutofitSync();
+void testSnakeRows();
 
 CPPUNIT_TEST_SUITE(SdImportTestSmartArt);
 
@@ -161,6 +162,7 @@ public:
 CPPUNIT_TEST(testTdf134221);
 CPPUNIT_TEST(testLinearRule);
 CPPUNIT_TEST(testAutofitSync);
+CPPUNIT_TEST(testSnakeRows);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -1605,6 +1607,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


  1   2   3   >