summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2021-02-23 21:39:00 +0100
committerRegina Henschel <rb.henschel@t-online.de>2021-02-24 00:40:15 +0100
commitb2848591ca529004fcfef9bd0f3650750b3735d7 (patch)
tree9d75f0b37ee405f47bc5d1d0452870c47d9b1305
parent3d33e4ce3987ea17e73a72e84f7f0df7af8101a6 (diff)
tdf#139763 set anchor type in meEditAs in all cases
OOXML specifies a shape anchor type with xdr:absoluteAnchor and xdr:oneCellAnchor, or with xdr:twoCellAnchor and the attribute editAs with values 'absolute' and 'oneCell'. For our UI the member meEditAs is used. But only in case twoCellAnchor it was set. The patch adds the missing assignments. Change-Id: Iceffd4c5c7640e4d9a614cd52cb491774989595f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111436 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
-rw-r--r--sc/qa/unit/data/xlsx/tdf139763ShapeAnchor.xlsxbin0 -> 15734 bytes
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx32
-rw-r--r--sc/source/filter/oox/drawingbase.cxx2
3 files changed, 34 insertions, 0 deletions
diff --git a/sc/qa/unit/data/xlsx/tdf139763ShapeAnchor.xlsx b/sc/qa/unit/data/xlsx/tdf139763ShapeAnchor.xlsx
new file mode 100644
index 000000000000..9c255c3ee836
--- /dev/null
+++ b/sc/qa/unit/data/xlsx/tdf139763ShapeAnchor.xlsx
Binary files differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index b70777b1c176..b5f9d0f12fd4 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -306,6 +306,7 @@ public:
void testDrawCircleInMergeCells();
void testDeleteCirclesInRowAndCol();
void testTdf129940();
+ void testTdf139763ShapeAnchor();
CPPUNIT_TEST_SUITE(ScFiltersTest);
CPPUNIT_TEST(testCondFormatOperatorsSameRangeXLSX);
@@ -495,6 +496,7 @@ public:
CPPUNIT_TEST(testDrawCircleInMergeCells);
CPPUNIT_TEST(testDeleteCirclesInRowAndCol);
CPPUNIT_TEST(testTdf129940);
+ CPPUNIT_TEST(testTdf139763ShapeAnchor);
CPPUNIT_TEST_SUITE_END();
@@ -5491,6 +5493,36 @@ void ScFiltersTest::testTdf129940()
xDocSh->DoClose();
}
+void ScFiltersTest::testTdf139763ShapeAnchor()
+{
+ ScDocShellRef xDocSh = loadDoc(u"tdf139763ShapeAnchor.", FORMAT_XLSX);
+ CPPUNIT_ASSERT_MESSAGE("Failed to load cell-anchored-shapes.xlsx", xDocSh.is());
+
+ // There are two objects on the first sheet, anchored to page by element xdr:absoluteAnchor
+ // and anchored to cell by element xdr:oneCellAnchor. Error was, that they were imported as
+ // "anchor to cell (resize with cell".
+ ScDocument& rDoc = xDocSh->GetDocument();
+
+ CPPUNIT_ASSERT_MESSAGE("There should be at least one sheet.", rDoc.GetTableCount() > 0);
+
+ ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
+ SdrPage* pPage = pDrawLayer->GetPage(0);
+ CPPUNIT_ASSERT_MESSAGE("draw page for sheet 1 should exist.", pPage);
+ // There should be 2 shapes
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), pPage->GetObjCount());
+
+ SdrObject* pObj = pPage->GetObj(0);
+ CPPUNIT_ASSERT_MESSAGE("Failed to get page anchored object.", pObj);
+ CPPUNIT_ASSERT_MESSAGE("Shape must be page anchored", !ScDrawLayer::IsCellAnchored(*pObj));
+
+ pObj = pPage->GetObj(1);
+ CPPUNIT_ASSERT_MESSAGE("Failed to get cell anchored object.", pObj);
+ CPPUNIT_ASSERT_MESSAGE("Shape must be anchored to cell.", ScDrawLayer::IsCellAnchored(*pObj));
+ CPPUNIT_ASSERT_MESSAGE("Shape must not resize with cell.", !ScDrawLayer::IsResizeWithCell(*pObj));
+
+ xDocSh->DoClose();
+}
+
ScFiltersTest::ScFiltersTest()
: ScBootstrapFixture( "sc/qa/unit/data" )
{
diff --git a/sc/source/filter/oox/drawingbase.cxx b/sc/source/filter/oox/drawingbase.cxx
index 29ef7d4b53c4..938f3fa67fcc 100644
--- a/sc/source/filter/oox/drawingbase.cxx
+++ b/sc/source/filter/oox/drawingbase.cxx
@@ -75,9 +75,11 @@ void ShapeAnchor::importAnchor( sal_Int32 nElement, const AttributeList& rAttrib
{
case XDR_TOKEN( absoluteAnchor ):
meAnchorType = ANCHOR_ABSOLUTE;
+ meEditAs = ANCHOR_ABSOLUTE;
break;
case XDR_TOKEN( oneCellAnchor ):
meAnchorType = ANCHOR_ONECELL;
+ meEditAs = ANCHOR_ONECELL;
break;
case XDR_TOKEN( twoCellAnchor ):
{