summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2021-02-23 21:39:00 +0100
committerAdolfo Jayme Barrientos <fitojb@ubuntu.com>2021-03-03 09:22:19 +0100
commit6c86b57a746ab8941ae1c4b0dd1a10c381395eed (patch)
tree3fe8154cc865ae9cc35a5a08ed98003f2d8a989b
parented7a3dabc8c35b8b33bad33fc26ebd8fb80b0cbd (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> (cherry picked from commit b2848591ca529004fcfef9bd0f3650750b3735d7) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111425 Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
-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 47837905f407..be7ef0f96a0c 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -298,6 +298,7 @@ public:
void testDrawCircleInMergeCells();
void testDeleteCirclesInRowAndCol();
void testTdf129940();
+ void testTdf139763ShapeAnchor();
CPPUNIT_TEST_SUITE(ScFiltersTest);
CPPUNIT_TEST(testCondFormatFormulaIsXLSX);
@@ -481,6 +482,7 @@ public:
CPPUNIT_TEST(testDrawCircleInMergeCells);
CPPUNIT_TEST(testDeleteCirclesInRowAndCol);
CPPUNIT_TEST(testTdf129940);
+ CPPUNIT_TEST(testTdf139763ShapeAnchor);
CPPUNIT_TEST_SUITE_END();
@@ -5388,6 +5390,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 ):
{