[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - oox/source sd/qa

2023-04-18 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 |   26 +
 4 files changed, 65 insertions(+), 13 deletions(-)

New commits:
commit 756e7701486318e72dce823f3946b7b2ea350132
Author: Tibor Nagy 
AuthorDate: Wed Mar 29 09:00:47 2023 +0200
Commit: Xisco Fauli 
CommitDate: Tue Apr 18 09:27:32 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 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150202
Tested-by: Jenkins

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index a77ee85b8b92..ec2ebd54d56c 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 7298eea1247c..349262fc6b8f 100644
--- a/oox/source/ppt/slidepersist.cxx
+++ b/oox/source/ppt/slidepersist.cxx
@@ -654,11 +654,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 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - oox/source sd/qa

2023-01-31 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 34ca1dca73ca03cbec1cfeab79f2e11e36af1280
Author: Tünde Tóth 
AuthorDate: Tue Jan 24 15:02:09 2023 +0100
Commit: Xisco Fauli 
CommitDate: Tue Jan 31 11:36:41 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 
(cherry picked from commit f589d7e769bee4b82826a944fed3cf2382d84fb2)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146319
Reviewed-by: Michael Stahl 

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 4b41f56d79cd..4ef05ba80cab 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -2601,49 +2601,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);
@@ -2681,7 +2692,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 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - 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 a44ab07e05521b987c842265184240661e330ea4
Author: Attila Szűcs 
AuthorDate: Mon Jan 16 04:13:07 2023 +0100
Commit: Xisco Fauli 
CommitDate: Thu Jan 19 11:13:11 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 
(cherry picked from commit 17c68fad2aef917adfdd3d4d651da786e620699c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145728

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;
+  

[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - oox/source sd/qa

2023-01-06 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 c27ba904366a966c2f4cc8fe2a04d47a41b3cc1d
Author: Attila Szűcs 
AuthorDate: Wed Jan 4 00:40:23 2023 +0100
Commit: Andras Timar 
CommitDate: Fri Jan 6 09:29:22 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 
(cherry picked from commit 0cc9aaae5dc6655490513e8e4a93967f6248e23c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145004

diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index a9b869e86af2..059785edf6e5 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -852,6 +852,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: Branch 'libreoffice-7-5' - oox/source sd/qa

2022-12-20 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 63baa8c2450e2333fa343f8ddedad5f5908234e6
Author: Tibor Nagy 
AuthorDate: Mon Dec 5 09:21:51 2022 +0100
Commit: Xisco Fauli 
CommitDate: Tue Dec 20 08:49:00 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 
(cherry picked from commit b12e38c1ccb388e62e35d856d4a575e1724a10e9)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144493
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

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 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - oox/source sd/qa

2022-12-19 Thread Tibor Nagy (via logerrit)
 oox/source/ppt/slidepersist.cxx |   12 
 sd/qa/unit/data/pptx/tdf152434.pptx |binary
 sd/qa/unit/import-tests.cxx |   13 +
 3 files changed, 21 insertions(+), 4 deletions(-)

New commits:
commit d67b38039c672c8f88d2a668312dbcdbaea4297a
Author: Tibor Nagy 
AuthorDate: Mon Dec 12 16:44:07 2022 +0100
Commit: Xisco Fauli 
CommitDate: Mon Dec 19 19:58:32 2022 +

tdf#152434 PPTX import: fix lost shapes with connectors

Regression from commit eec48130271188cab63665acedbabf1ff5e850a2
"tdf#148926 tdf#151678 PPTX import: position of standard connector
 - part1".

Change-Id: Ib9381403f7c0edf9a06e3d98965067a51b4797d8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144000
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit c3f1ec60569727d8aba50b2f59882e13a8443880)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144485
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx
index 9d2ad58b5be2..c875239aac46 100644
--- a/oox/source/ppt/slidepersist.cxx
+++ b/oox/source/ppt/slidepersist.cxx
@@ -504,10 +504,14 @@ void SlidePersist::createConnectorShapeConnection()
 }
 }
 }
-ConnectorType aConnectorType;
-xPropertySet->getPropertyValue("EdgeKind") >>= aConnectorType;
-if (aConnectorType == ConnectorType_STANDARD)
-lcl_SetEdgeLineValue(xConnector, pIt->second);
+uno::Reference xPropInfo = 
xPropertySet->getPropertySetInfo();
+if (xPropInfo->hasPropertyByName("EdgeKind"))
+{
+ConnectorType aConnectorType;
+xPropertySet->getPropertyValue("EdgeKind") >>= aConnectorType;
+if (aConnectorType == ConnectorType_STANDARD)
+lcl_SetEdgeLineValue(xConnector, pIt->second);
+}
 }
 }
 maConnectorShapeId.clear();
diff --git a/sd/qa/unit/data/pptx/tdf152434.pptx 
b/sd/qa/unit/data/pptx/tdf152434.pptx
new file mode 100644
index ..f0716a92fe1b
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf152434.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index eb125a46834f..abd21782bf68 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -83,6 +83,7 @@ public:
 }
 
 void testDocumentLayout();
+void testTdf152434();
 void testConnectors();
 void testTdf150719();
 void testTdf149314();
@@ -157,6 +158,7 @@ public:
 CPPUNIT_TEST_SUITE(SdImportTest);
 
 CPPUNIT_TEST(testDocumentLayout);
+CPPUNIT_TEST(testTdf152434);
 CPPUNIT_TEST(testConnectors);
 CPPUNIT_TEST(testTdf150719);
 CPPUNIT_TEST(testTdf149314);
@@ -338,6 +340,17 @@ void SdImportTest::testDocumentLayout()
 }
 }
 
+void SdImportTest::testTdf152434()
+{
+createSdImpressDoc("pptx/tdf152434.pptx");
+
+SdXImpressDocument* pXImpressDocument = 
dynamic_cast(mxComponent.get());
+CPPUNIT_ASSERT(pXImpressDocument);
+SdDrawDocument* pDoc = pXImpressDocument->GetDoc();
+const SdrPage* pPage = pDoc->GetPage(1);
+CPPUNIT_ASSERT_EQUAL(size_t(1), pPage->GetObjCount());
+}
+
 void SdImportTest::testConnectors()
 {
 createSdImpressDoc("pptx/connectors.pptx");