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

2022-01-05 Thread Dhiraj Holden (via logerrit)
 svx/qa/unit/classicshapes.cxx  |   42 -
 svx/qa/unit/data/tdf130076_FlipOnSectorSection.odg |binary
 xmloff/source/draw/ximpshap.cxx|   25 
 3 files changed, 65 insertions(+), 2 deletions(-)

New commits:
commit 207d202ed2f1f44e5b62157b5a92ee5e8cc2c3e5
Author: Dhiraj Holden 
AuthorDate: Sat Jan 1 20:14:33 2022 -0500
Commit: Regina Henschel 
CommitDate: Wed Jan 5 15:31:58 2022 +0100

tdf#130076 Fixed flip not working properly from file

Added code to check whether the angles need to be changed when the
section is flipped.

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

diff --git a/svx/qa/unit/classicshapes.cxx b/svx/qa/unit/classicshapes.cxx
index 8d8ed8bd74e4..d9e0fc18c7c1 100644
--- a/svx/qa/unit/classicshapes.cxx
+++ b/svx/qa/unit/classicshapes.cxx
@@ -181,6 +181,46 @@ CPPUNIT_TEST_FIXTURE(ClassicshapesTest, 
testTdf98583ShearHorizontal)
 
 CPPUNIT_ASSERT_EQUAL(OUString(), sErrors);
 }
-}
 
+CPPUNIT_TEST_FIXTURE(ClassicshapesTest, testTdf130076Flip)
+{
+// The document contains sections of a circle, one of which is scaled
+// (1, -1), one of which is scaled (-1,1), one of which is transformed
+// by a matrix equivalent to a vertical flip, and another which is
+// transformed by a matrix equivalent to a horizontal flip. Error was
+// that the transformation was made before the CircleKind was set,
+// resulting in the flip being performed incorrectly.
+const OUString sURL(m_directories.getURLFromSrc(sDataDirectory)
++ "tdf130076_FlipOnSectorSection.odg");
+mxComponent = loadFromDesktop(sURL, 
"com.sun.star.comp.drawing.DrawingDocument");
+
+OUString sErrors; // sErrors collects the errors and should be empty in 
case all is OK.
+
+for (sal_uInt8 nPageIndex = 0; nPageIndex < 2; ++nPageIndex)
+{
+sal_Int32 angle1, angle2;
+const sal_Int32 goodAngle1 = 26000;
+const sal_Int32 goodAngle2 = 26000;
+uno::Reference xShape(getShape(1, nPageIndex));
+uno::Reference xShapeProps(xShape, 
uno::UNO_QUERY);
+uno::Reference xShape2(getShape(2, nPageIndex));
+uno::Reference xShapeProps2(xShape2, 
uno::UNO_QUERY);
+xShapeProps->getPropertyValue("CircleStartAngle") >>= angle1;
+xShapeProps2->getPropertyValue("CircleStartAngle") >>= angle2;
+if (angle1 != goodAngle1)
+{
+sErrors += "page " + OUString::number(nPageIndex)
+   + " expected vertical flip starting angle " + 
OUString::number(goodAngle1)
+   + " actual " + OUString::number(angle1) + "\n";
+}
+if (angle2 != goodAngle2)
+{
+sErrors += "page " + OUString::number(nPageIndex)
+   + " expected horizontal flip starting angle " + 
OUString::number(goodAngle2)
+   + " actual " + OUString::number(angle2) + "\n";
+}
+}
+CPPUNIT_ASSERT_EQUAL(OUString(), sErrors);
+}
+}
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/qa/unit/data/tdf130076_FlipOnSectorSection.odg 
b/svx/qa/unit/data/tdf130076_FlipOnSectorSection.odg
new file mode 100644
index ..058e7e0443f9
Binary files /dev/null and b/svx/qa/unit/data/tdf130076_FlipOnSectorSection.odg 
differ
diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx
index 4d2dec38a3c8..a19a6c19d936 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -1172,7 +1172,6 @@ void SdXMLEllipseShapeContext::startFastElement 
(sal_Int32 nElement,
 maPosition.X = mnCX - mnRX;
 maPosition.Y = mnCY - mnRY;
 }
-
 // set pos, size, shear and rotate
 SetTransformation();
 
@@ -1181,6 +1180,30 @@ void SdXMLEllipseShapeContext::startFastElement 
(sal_Int32 nElement,
 uno::Reference< beans::XPropertySet > xPropSet( mxShape, 
uno::UNO_QUERY );
 if( xPropSet.is() )
 {
+// calculate the correct start and end angle
+sal_Int32 mnOldStartAngle = mnStartAngle;
+sal_Int32 mnOldEndAngle = mnEndAngle;
+basegfx::B2DTuple aScale;
+basegfx::B2DTuple aTranslate;
+double fRotate;
+double fShearX;
+maUsedTransformation.decompose(aScale, aTranslate, fRotate, 
fShearX);
+if (aScale.getX() < 0 || aScale.getY() < 0)
+{
+// The angle for a horizontal flip is the same as the angle 
for a
+// vertical flip because a vertical flip is treated as a 
horizontal
+// flip plus a rotation.
+
+// To perform the flip, the start and end angle are switched 
and we
+// use the fact performing a horizontal flip on a shape will 
change

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

2021-04-03 Thread Regina Henschel (via logerrit)
 dev/null   |binary
 svx/qa/unit/customshapes.cxx   |   18 --
 xmloff/source/draw/ximpcustomshape.cxx |9 -
 3 files changed, 27 deletions(-)

New commits:
commit f1b55d3f8e963069fc798bcf559ae9af2bf18b64
Author: Regina Henschel 
AuthorDate: Sat Apr 3 13:56:22 2021 +0200
Commit: Regina Henschel 
CommitDate: Sat Apr 3 18:15:12 2021 +0200

Revert "tdf#141127 Use ODF default values for draw:extrusion-skew"

This reverts commit 2bf8c1e0e211601a70b6b28fdb92f636c7969513.

Reason for revert: tdf#141268 LibreOffice uses -135deg skew angle as 
internal default. If a user does not touch the direction, the value is not 
written to file, although that would be necessary because it is not ODF 
default. With the patch applied the missing value will be interpreted as 45deg 
on opening. So the first step is, to write -135deg to file. And then after some 
time, when wrong files are unlikely, the patch can be applied.
A suggestion for writing -135deg is from Julien Nabet in  
https://gerrit.libreoffice.org/c/core/+/113257. From code it looks good to me, 
but I have not tested it yet. I would only add some comments to explain the 
situation.

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

diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx
index 811b4489569c..4e3f76db74ec 100644
--- a/svx/qa/unit/customshapes.cxx
+++ b/svx/qa/unit/customshapes.cxx
@@ -940,24 +940,6 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf136176)
 }
 }
 }
-
-CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf141127WrongSkewDefault)
-{
-// Load a document that has a shape in extrusion mode, but no 
draw:extrusion-skew attribute.
-// Error was, that the shape uses the MS Office binary defaults and so the 
extruded side faces
-// were not left/bottom, but top/right.
-OUString sURL = m_directories.getURLFromSrc(sDataDirectory) + 
"tdf141127_defaultSkewAngle.odp";
-mxComponent = loadFromDesktop(sURL, 
"com.sun.star.comp.presentation.PresentationDocument");
-CPPUNIT_ASSERT_MESSAGE("Could not load document", mxComponent.is());
-uno::Reference xShape(getShape(0));
-SdrObjCustomShape& rSdrCustomShape(
-static_cast(*GetSdrObjectFromXShape(xShape)));
-
-// Check left/bottom of bound rect. Without fix it would be left=15994, 
bottom=6999.
-tools::Rectangle aBoundRect(rSdrCustomShape.GetCurrentBoundRect());
-CPPUNIT_ASSERT_EQUAL(tools::Long(15371), aBoundRect.Left());
-CPPUNIT_ASSERT_EQUAL(tools::Long(7622), aBoundRect.Bottom());
-}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/qa/unit/data/tdf141127_defaultSkewAngle.odp 
b/svx/qa/unit/data/tdf141127_defaultSkewAngle.odp
deleted file mode 100644
index 5cd0da96ec20..
Binary files a/svx/qa/unit/data/tdf141127_defaultSkewAngle.odp and /dev/null 
differ
diff --git a/xmloff/source/draw/ximpcustomshape.cxx 
b/xmloff/source/draw/ximpcustomshape.cxx
index 15d296187348..ebaf15651950 100644
--- a/xmloff/source/draw/ximpcustomshape.cxx
+++ b/xmloff/source/draw/ximpcustomshape.cxx
@@ -1286,15 +1286,6 @@ void 
XMLEnhancedCustomShapeContext::endFastElement(sal_Int32 )
 }
 }
 
-//tdf#141127 Add ODF default values. Otherwise defaults from MS Office 
binary format are used.
-if (!maExtrusion.empty())
-{
-auto it = std::find_if(maExtrusion.begin(), maExtrusion.end(), 
-[](css::beans::PropertyValue& rProp){return EASGet(rProp.Name) == 
EAS_Skew;} );
-if (it == maExtrusion.end())
-GetEnhancedParameterPair(maExtrusion, "50 45", EAS_Skew);
-}
-
 SdXMLCustomShapePropertyMerge( mrCustomShapeGeometry, maExtrusion, EASGet( 
EAS_Extrusion ) );
 SdXMLCustomShapePropertyMerge( mrCustomShapeGeometry, maPath,  EASGet( 
EAS_Path ) );
 SdXMLCustomShapePropertyMerge( mrCustomShapeGeometry, maTextPath,  EASGet( 
EAS_TextPath ) );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2021-03-22 Thread Regina Henschel (via logerrit)
 svx/qa/unit/customshapes.cxx|   18 ++
 svx/qa/unit/data/tdf141127_defaultSkewAngle.odp |binary
 xmloff/source/draw/ximpcustomshape.cxx  |9 +
 3 files changed, 27 insertions(+)

New commits:
commit 2bf8c1e0e211601a70b6b28fdb92f636c7969513
Author: Regina Henschel 
AuthorDate: Sat Mar 20 20:05:19 2021 +0100
Commit: Regina Henschel 
CommitDate: Mon Mar 22 19:08:27 2021 +0100

tdf#141127 Use ODF default values for draw:extrusion-skew

The default value for extrusion skew angle is 45 in ODF and -135 in
binary MS Office. LO had used -135 in case the draw:extrusion-skew
attribute was missing on import. This could be fixed in GetSkew() in
EnhancedCustomShape3d.cxx#92. But that would break import of ppt files.
So I have decided not to search, were the binary import would need to
be tweaked, but I set the default values directly in file open in case
the attribute is missing.

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

diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx
index 4e3f76db74ec..811b4489569c 100644
--- a/svx/qa/unit/customshapes.cxx
+++ b/svx/qa/unit/customshapes.cxx
@@ -940,6 +940,24 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf136176)
 }
 }
 }
+
+CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf141127WrongSkewDefault)
+{
+// Load a document that has a shape in extrusion mode, but no 
draw:extrusion-skew attribute.
+// Error was, that the shape uses the MS Office binary defaults and so the 
extruded side faces
+// were not left/bottom, but top/right.
+OUString sURL = m_directories.getURLFromSrc(sDataDirectory) + 
"tdf141127_defaultSkewAngle.odp";
+mxComponent = loadFromDesktop(sURL, 
"com.sun.star.comp.presentation.PresentationDocument");
+CPPUNIT_ASSERT_MESSAGE("Could not load document", mxComponent.is());
+uno::Reference xShape(getShape(0));
+SdrObjCustomShape& rSdrCustomShape(
+static_cast(*GetSdrObjectFromXShape(xShape)));
+
+// Check left/bottom of bound rect. Without fix it would be left=15994, 
bottom=6999.
+tools::Rectangle aBoundRect(rSdrCustomShape.GetCurrentBoundRect());
+CPPUNIT_ASSERT_EQUAL(tools::Long(15371), aBoundRect.Left());
+CPPUNIT_ASSERT_EQUAL(tools::Long(7622), aBoundRect.Bottom());
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/qa/unit/data/tdf141127_defaultSkewAngle.odp 
b/svx/qa/unit/data/tdf141127_defaultSkewAngle.odp
new file mode 100644
index ..5cd0da96ec20
Binary files /dev/null and b/svx/qa/unit/data/tdf141127_defaultSkewAngle.odp 
differ
diff --git a/xmloff/source/draw/ximpcustomshape.cxx 
b/xmloff/source/draw/ximpcustomshape.cxx
index ebaf15651950..15d296187348 100644
--- a/xmloff/source/draw/ximpcustomshape.cxx
+++ b/xmloff/source/draw/ximpcustomshape.cxx
@@ -1286,6 +1286,15 @@ void 
XMLEnhancedCustomShapeContext::endFastElement(sal_Int32 )
 }
 }
 
+//tdf#141127 Add ODF default values. Otherwise defaults from MS Office 
binary format are used.
+if (!maExtrusion.empty())
+{
+auto it = std::find_if(maExtrusion.begin(), maExtrusion.end(), 
+[](css::beans::PropertyValue& rProp){return EASGet(rProp.Name) == 
EAS_Skew;} );
+if (it == maExtrusion.end())
+GetEnhancedParameterPair(maExtrusion, "50 45", EAS_Skew);
+}
+
 SdXMLCustomShapePropertyMerge( mrCustomShapeGeometry, maExtrusion, EASGet( 
EAS_Extrusion ) );
 SdXMLCustomShapePropertyMerge( mrCustomShapeGeometry, maPath,  EASGet( 
EAS_Path ) );
 SdXMLCustomShapePropertyMerge( mrCustomShapeGeometry, maTextPath,  EASGet( 
EAS_TextPath ) );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2019-01-28 Thread Libreoffice Gerrit user
 svx/qa/unit/customshapes.cxx  |   29 ++
 svx/qa/unit/data/tdf122964_MultipleMoveTo.odg |binary
 xmloff/source/draw/ximpcustomshape.cxx|   29 --
 3 files changed, 52 insertions(+), 6 deletions(-)

New commits:
commit 76c7a6c39d769cb9bdb9b951d9f95507c0139372
Author: Regina Henschel 
AuthorDate: Fri Jan 25 00:30:57 2019 +0100
Commit: Thorsten Behrens 
CommitDate: Tue Jan 29 01:16:51 2019 +0100

Improve ODF enhanced-path command moveTo to follow spec

ODF 1.2 section 19.145 says 'If a moveto is followed by multiple
pairs of coordinates, they are treated as lineto.' The patch does
this on import.

Change-Id: Ib493ca49288cdb2d34b7ee801bd052281617d2e8
Reviewed-on: https://gerrit.libreoffice.org/66888
Tested-by: Jenkins
Reviewed-by: Regina Henschel 

diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx
old mode 100644
new mode 100755
index d3f63dffe2a9..a0c256b5d6e0
--- a/svx/qa/unit/customshapes.cxx
+++ b/svx/qa/unit/customshapes.cxx
@@ -50,11 +50,13 @@ public:
 void testViewBoxLeftTop();
 void testAccuracyCommandX();
 void testToggleCommandXY();
+void testMultipleMoveTo();
 
 CPPUNIT_TEST_SUITE(CustomshapesTest);
 CPPUNIT_TEST(testViewBoxLeftTop);
 CPPUNIT_TEST(testAccuracyCommandX);
 CPPUNIT_TEST(testToggleCommandXY);
+CPPUNIT_TEST(testMultipleMoveTo);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -161,6 +163,33 @@ void CustomshapesTest::testToggleCommandXY()
 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("segment height out of tolerance", 
5871.0, fHeight, 16.0);
 }
 
+void CustomshapesTest::testMultipleMoveTo()
+{
+// tdf122964 Multiple moveTo has to be treated as lineTo in 
draw:enhanced-path
+// Load a document with path "M 0 0 5 10 10 0 N"
+OUString aURL = m_directories.getURLFromSrc(sDataDirectory) + 
"tdf122964_MultipleMoveTo.odg";
+mxComponent = loadFromDesktop(aURL, 
"com.sun.star.comp.drawing.DrawingDocument");
+CPPUNIT_ASSERT_MESSAGE("Could not load document", mxComponent.is());
+
+uno::Reference xDrawPagesSupplier(mxComponent,
+   
uno::UNO_QUERY_THROW);
+CPPUNIT_ASSERT_MESSAGE("Could not get XDrawPagesSupplier", 
xDrawPagesSupplier.is());
+uno::Reference 
xDrawPages(xDrawPagesSupplier->getDrawPages());
+uno::Reference xDrawPage(xDrawPages->getByIndex(0), 
uno::UNO_QUERY_THROW);
+
+// Error was, that the second and further parameter pairs were treated as 
moveTo,
+// and so the generated path was empty, resulting in zero width and height 
of the
+// bounding box. It has to be treated same as "M 0 0 L 5 10 10 0 N".
+uno::Reference xShape(xDrawPage->getByIndex(0), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_MESSAGE("Could not get the shape", xShape.is());
+uno::Reference xShapeProps(xShape, uno::UNO_QUERY);
+CPPUNIT_ASSERT_MESSAGE("Could not get the shape properties", 
xShapeProps.is());
+awt::Rectangle aBoundRect;
+xShapeProps->getPropertyValue(UNO_NAME_MISC_OBJ_BOUNDRECT) >>= aBoundRect;
+bool bIsZero(aBoundRect.Height == 0 && aBoundRect.Width == 0);
+CPPUNIT_ASSERT_MESSAGE("Path is empty", !bIsZero);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(CustomshapesTest);
 }
 
diff --git a/svx/qa/unit/data/tdf122964_MultipleMoveTo.odg 
b/svx/qa/unit/data/tdf122964_MultipleMoveTo.odg
new file mode 100644
index ..63d80fd06736
Binary files /dev/null and b/svx/qa/unit/data/tdf122964_MultipleMoveTo.odg 
differ
diff --git a/xmloff/source/draw/ximpcustomshape.cxx 
b/xmloff/source/draw/ximpcustomshape.cxx
index da15e3458cbb..35de24ba2562 100644
--- a/xmloff/source/draw/ximpcustomshape.cxx
+++ b/xmloff/source/draw/ximpcustomshape.cxx
@@ -792,16 +792,33 @@ static void GetEnhancedPath( std::vector< 
css::beans::PropertyValue >& rDest,
 }
 else if ( nParameterCount >= nParametersNeeded )
 {
-// check if the last command is identical,
-// if so, we just need to increment the count
-if ( !vSegments.empty() && ( vSegments[ vSegments.size() - 1 
].Command == nLatestSegmentCommand ) )
-vSegments[ vSegments.size() -1 ].Count++;
-else
+// Special rule for moveto in ODF 1.2 section 19.145
+// "If a moveto is followed by multiple pairs of coordinates, they 
are treated as lineto."
+if ( nLatestSegmentCommand == 
css::drawing::EnhancedCustomShapeSegmentCommand::MOVETO )
 {
 css::drawing::EnhancedCustomShapeSegment aSegment;
-aSegment.Command = nLatestSegmentCommand;
+aSegment.Command = 
css::drawing::EnhancedCustomShapeSegmentCommand::MOVETO;
 aSegment.Count = 1;
 vSegments.push_back( aSegment );
+nIndex--;
+nLatestSegmentCommand = 
css::drawing::EnhancedCustomShapeSegmentCommand::LINET