sc/qa/unit/subsequent_export_test2.cxx             |    2 +-
 sc/source/filter/xml/XMLTableShapeImportHelper.cxx |    3 +++
 sc/source/ui/unoobj/shapeuno.cxx                   |    2 ++
 3 files changed, 6 insertions(+), 1 deletion(-)

New commits:
commit c1820235a4d5ace6b395dac889a4dc0dae5d5a68
Author:     Justin Luth <[email protected]>
AuthorDate: Thu Dec 18 14:52:53 2025 -0500
Commit:     Justin Luth <[email protected]>
CommitDate: Thu Dec 18 23:10:48 2025 +0100

    tdf#170012 sc: never SetCellAnchored without SetNonRotatedAnchored
    
    This allows cell-anchored form controls
    to be round-tripped in ODS.
    
    Before this patch, they were (always?) reverting to SCA_PAGE.
    
    Either call SetCellAnchoredFromPosition,
    or else also explicitly call NonRotatedAnchored.
    
    Of course, I could make the one call the other,
    but some places already do both separately,
    so just make a copy/pasta routine out if it.
    (Otherwise, pass a 'bool bWillSetNonRotatedAnchorSeparately'.)
    
    make CppunitTest_sc_subsequent_export_test2 \
        CPPUNIT_TEST_NAME=testTdf170012_cellAnchor
    
    Change-Id: Ic68bb32f059400e1617953401a71d0068decd439
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195821
    Reviewed-by: Justin Luth <[email protected]>
    Tested-by: Jenkins

diff --git a/sc/qa/unit/subsequent_export_test2.cxx 
b/sc/qa/unit/subsequent_export_test2.cxx
index 0b1962a4125f..cc95f804e473 100644
--- a/sc/qa/unit/subsequent_export_test2.cxx
+++ b/sc/qa/unit/subsequent_export_test2.cxx
@@ -121,7 +121,7 @@ CPPUNIT_TEST_FIXTURE(ScExportTest2, 
testTdf170012_cellAnchor)
 
     pPage = getScDoc()->GetDrawLayer()->GetPage(0);
     anchorType = ScDrawLayer::GetAnchorType(*pPage->GetObj(0));
-    CPPUNIT_ASSERT_EQUAL(SCA_PAGE, anchorType); // fallback to page anchor 
when invalid cell anchor
+    CPPUNIT_ASSERT_EQUAL(SCA_CELL_RESIZE, anchorType);
 }
 
 CPPUNIT_TEST_FIXTURE(ScExportTest2, testFreezePaneStartCellXLSX)
diff --git a/sc/source/filter/xml/XMLTableShapeImportHelper.cxx 
b/sc/source/filter/xml/XMLTableShapeImportHelper.cxx
index 003b84a0e488..e3a891ca7c9c 100644
--- a/sc/source/filter/xml/XMLTableShapeImportHelper.cxx
+++ b/sc/source/filter/xml/XMLTableShapeImportHelper.cxx
@@ -139,7 +139,10 @@ void XMLTableShapeImportHelper::finishShape(
             if (SdrObject* pSdrObj = SdrObject::getSdrObjectFromXShape(rShape))
             {
                 if (!bOnTable)
+                {
                     ScDrawLayer::SetCellAnchored(*pSdrObj, aAnchor);
+                    ScDrawLayer::SetNonRotatedAnchor(*pSdrObj, aAnchor);
+                }
                 else
                     ScDrawLayer::SetPageAnchored(*pSdrObj);
             }
diff --git a/sc/source/ui/unoobj/shapeuno.cxx b/sc/source/ui/unoobj/shapeuno.cxx
index bc5b09423dde..1c91cecffe68 100644
--- a/sc/source/ui/unoobj/shapeuno.cxx
+++ b/sc/source/ui/unoobj/shapeuno.cxx
@@ -475,6 +475,7 @@ void SAL_CALL ScShapeObj::setPropertyValue(const OUString& 
aPropertyName, const
                                     //Currently we've only got a start anchor, 
not an end-anchor, so generate that now
                                     
ScDrawLayer::UpdateCellAnchorFromPositionEnd(*pObj, aAnchor, *pDoc, 
aAddress.Sheet);
                                     ScDrawLayer::SetCellAnchored(*pObj, 
aAnchor);
+                                    ScDrawLayer::SetNonRotatedAnchor(*pObj, 
aAnchor);
                                 }
                             }
                         }
@@ -501,6 +502,7 @@ void SAL_CALL ScShapeObj::setPropertyValue(const OUString& 
aPropertyName, const
 
         aValue >>= pDrawObjData->mbResizeWithCell;
         ScDrawLayer::SetCellAnchored(*pObj, *pDrawObjData);
+        ScDrawLayer::SetNonRotatedAnchor(*pObj, *pDrawObjData);
     }
     else if ( aPropertyName == SC_UNONAME_IMAGEMAP )
     {

Reply via email to