summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorAndreas Heinisch <andreas.heinisch@yahoo.de>2023-04-10 19:44:38 +0200
committerAndreas Heinisch <andreas.heinisch@yahoo.de>2023-04-12 11:36:39 +0200
commite8de03a18ed8684ed94d93b09aa1662ba799e877 (patch)
treef35443b9c8bb0fd6059839e93232df48b279d254 /sc
parent505647d63726ce526d9ecd544954f3ce3e1af95a (diff)
tdf#116127 - Add EDITATTR to ALL flags to check for valid function inputs
Otherwise, the function clearcontents does not accept the EDITATTR flag as a valid input. Change-Id: I8381014da7110d060167a814d9ea02e347d5a92b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150191 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/global.hxx3
-rw-r--r--sc/qa/extras/macros-test.cxx37
2 files changed, 39 insertions, 1 deletions
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index 1e42e6060d0e..fb5af9e3e451 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -165,7 +165,8 @@ enum class InsertDeleteFlags : sal_uInt16
FORGETCAPTIONS = 0x2000, /// Internal use only (d&d undo): do not delete caption objects of cell notes.
ATTRIB = HARDATTR | STYLES,
CONTENTS = VALUE | DATETIME | STRING | NOTE | FORMULA | OUTLINE | SPARKLINES,
- ALL = CONTENTS | ATTRIB | OBJECTS | SPARKLINES,
+ // tdf#116127 - add EDITATTR to ALL flags in order to check for valid function inputs
+ ALL = CONTENTS | ATTRIB | OBJECTS | SPARKLINES | EDITATTR,
/// Copy flags for auto/series fill functions: do not touch notes and drawing objects.
AUTOFILL = ALL & ~(NOTE | OBJECTS)
};
diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index ec41a2fbe4a9..caa788e7a1f6 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -911,6 +911,43 @@ CPPUNIT_TEST_FIXTURE(ScMacrosTest, testTdf147122)
CPPUNIT_ASSERT_EQUAL(Any(OUString("This is a test")), aRet);
}
+CPPUNIT_TEST_FIXTURE(ScMacrosTest, testTdf116127)
+{
+ mxComponent = loadFromDesktop("private:factory/scalc");
+
+ css::uno::Reference<css::document::XEmbeddedScripts> xDocScr(mxComponent, UNO_QUERY_THROW);
+ auto xLibs = xDocScr->getBasicLibraries();
+ auto xLibrary = xLibs->createLibrary("TestLibrary");
+ xLibrary->insertByName(
+ "TestModule",
+ uno::Any(OUString(
+ "Function TestClearContents\n"
+ // Insert test string into cell A1
+ " oActiveSheet = ThisComponent.CurrentController.ActiveSheet\n"
+ " oActiveCell = oActiveSheet.getCellRangeByName(\"A1\")\n"
+ " oActiveCell.setString(\"Italic Test\")\n"
+ // Create a text cursor and and change the first letter to italic
+ " oCursor = oActiveCell.Text.createTextCursor()\n"
+ " oCursor.gotoStart(False)\n"
+ " oCursor.goRight(1, True)\n"
+ " oCursor.CharPosture = com.sun.star.awt.FontSlant.ITALIC\n"
+ // Clear contents using EDITATTR cell flag to clear the italic char posture
+ " oActiveCell.clearContents(com.sun.star.sheet.CellFlags.EDITATTR)\n"
+ // Check the char posture of the first letter
+ " oCursor.gotoStart(False)\n"
+ " oCursor.goRight(1, True)\n"
+ " TestClearContents = oCursor.CharPosture <> com.sun.star.awt.FontSlant.ITALIC\n"
+ "End Function\n")));
+
+ Any aRet = executeMacro("vnd.sun.Star.script:TestLibrary.TestModule.TestClearContents?"
+ "language=Basic&location=document");
+ // Without the fix in place, this test would have failed with
+ // - Expected : true
+ // - Actual : false
+ // i.e. the formatting within parts of the cell contents (EDITATTR) were not deleted
+ CPPUNIT_ASSERT_EQUAL(Any(true), aRet);
+}
+
ScMacrosTest::ScMacrosTest()
: UnoApiXmlTest("/sc/qa/extras/testdocuments")
{