summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 ):
{