sc/qa/unit/data/xlsx/tdf139763ShapeAnchor.xlsx |binary
 sc/qa/unit/subsequent_filters-test.cxx         |   32 +++++++++++++++++++++++++
 sc/source/filter/oox/drawingbase.cxx           |    2 +
 3 files changed, 34 insertions(+)

New commits:
commit b2848591ca529004fcfef9bd0f3650750b3735d7
Author:     Regina Henschel <rb.hensc...@t-online.de>
AuthorDate: Tue Feb 23 21:39:00 2021 +0100
Commit:     Regina Henschel <rb.hensc...@t-online.de>
CommitDate: Wed Feb 24 00:40:15 2021 +0100

    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.hensc...@t-online.de>

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
Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf139763ShapeAnchor.xlsx 
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 ):
         {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to