summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorSzabolcs Toth <toth.szabolcs@nisz.hu>2020-12-31 10:31:30 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2021-01-19 11:43:42 +0100
commitaa23da6b9e935fbfcb0b432d43c72f7a6db50657 (patch)
tree32246d670b1c40c1d81ad8ac4ae3228ce0d89bc8 /sc
parent3b481336018d274384b7ade7c2c5e858f24f0e8c (diff)
tdf#139258 XLSX export: fix position of rotated images
Follow-up of commit a4eec60c388cc65ae0b4c8ea0fd7235f520a749d (tdf#123613 XLSX export: fix position of rotated shapes) and commit 368c56144aab5794c39d5bc2082d9b3d6d7cebdb (refactor for xlsx shape export). Change-Id: If5a79685efa1a80ea82eac19aed12bb426d10987 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108533 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org> (cherry picked from commit fddad2ed797f1773ed5be979a0b05d3f976b744e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109517 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
-rwxr-xr-xsc/qa/unit/data/ods/tdf139258_rotated_image.odsbin0 -> 8856 bytes
-rw-r--r--sc/qa/unit/subsequent_export-test.cxx21
-rw-r--r--sc/source/filter/xcl97/xcl97rec.cxx11
3 files changed, 25 insertions, 7 deletions
diff --git a/sc/qa/unit/data/ods/tdf139258_rotated_image.ods b/sc/qa/unit/data/ods/tdf139258_rotated_image.ods
new file mode 100755
index 000000000000..a90537c14bd9
--- /dev/null
+++ b/sc/qa/unit/data/ods/tdf139258_rotated_image.ods
Binary files differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 054452eb6784..e2da767d9bbb 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -278,6 +278,7 @@ public:
void testTdf129969();
void testTdf84874();
void testTdf136721_paper_size();
+ void testTdf139258_rotated_image();
CPPUNIT_TEST_SUITE(ScExportTest);
CPPUNIT_TEST(test);
@@ -454,6 +455,7 @@ public:
CPPUNIT_TEST(testTdf129969);
CPPUNIT_TEST(testTdf84874);
CPPUNIT_TEST(testTdf136721_paper_size);
+ CPPUNIT_TEST(testTdf139258_rotated_image);
CPPUNIT_TEST_SUITE_END();
@@ -5778,6 +5780,25 @@ void ScExportTest::testTdf136721_paper_size()
assertXPath(pDoc, "/x:worksheet/x:pageSetup", "paperSize", "70");
}
+void ScExportTest::testTdf139258_rotated_image()
+{
+ // Check that the topleft position of the image is correct.
+ ScDocShellRef xShell = loadDoc(u"tdf139258_rotated_image.", FORMAT_ODS);
+ CPPUNIT_ASSERT(xShell.is());
+
+ std::shared_ptr<utl::TempFile> pXPathFile
+ = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
+
+ xmlDocUniquePtr pDrawing
+ = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/drawings/drawing1.xml");
+ CPPUNIT_ASSERT(pDrawing);
+
+ assertXPathContent(pDrawing, "/xdr:wsDr/xdr:twoCellAnchor/xdr:from/xdr:col", "1");
+ assertXPathContent(pDrawing, "/xdr:wsDr/xdr:twoCellAnchor/xdr:from/xdr:row", "12");
+ assertXPathContent(pDrawing, "/xdr:wsDr/xdr:twoCellAnchor/xdr:to/xdr:col", "6");
+ assertXPathContent(pDrawing, "/xdr:wsDr/xdr:twoCellAnchor/xdr:to/xdr:row", "25");
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx
index 1fde9272f3f5..2eacb3edf28b 100644
--- a/sc/source/filter/xcl97/xcl97rec.cxx
+++ b/sc/source/filter/xcl97/xcl97rec.cxx
@@ -1109,13 +1109,10 @@ void XclObjAny::WriteFromTo( XclExpXmlStream& rStrm, const Reference< XShape >&
{
sal_Int16 nHalfWidth = aSize.Width / 2;
sal_Int16 nHalfHeight = aSize.Height / 2;
- // aTopLeft needs correction for rotated customshapes
- if (pObj->GetObjIdentifier() == OBJ_CUSTOMSHAPE)
- {
- const tools::Rectangle& aSnapRect(pObj->GetSnapRect()); // bounding box of the rotated shape
- aTopLeft.X = aSnapRect.getX() + (aSnapRect.GetWidth() / 2) - nHalfWidth;
- aTopLeft.Y = aSnapRect.getY() + (aSnapRect.GetHeight() / 2) - nHalfHeight;
- }
+
+ const tools::Rectangle& aSnapRect(pObj->GetSnapRect()); // bounding box of the rotated shape
+ aTopLeft.X = aSnapRect.getX() + (aSnapRect.GetWidth() / 2) - nHalfWidth;
+ aTopLeft.Y = aSnapRect.getY() + (aSnapRect.GetHeight() / 2) - nHalfHeight;
// MSO changes the anchor positions at these angles and that does an extra 90 degrees
// rotation on our shapes, so we output it in such position that MSO