diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2020-08-17 11:38:54 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2020-08-17 22:03:34 +0200 |
commit | d7d9d3cf1a529cfe99fb1b5ae65967c54e9f23bb (patch) | |
tree | 0e329095bed13ec6f97276a105f698355d885ccf /sc | |
parent | b6e508fc47ecb3650fd82c5e174e6d6a084e9ec6 (diff) |
tdf#135799: properly load arrays in user-defined types from image
This requires to reset Fixed flag temporarily, as in SbiParser::DefType
for non-image case.
And save the dimensions of the arrays in the custom types correctly:
the dimensions are numbered from 1, not from 0.
The existing unit test (that happened to not test anything actually)
was fixed.
Change-Id: I48c6b6d5d735d9972a2c0dd40345d5db75f87f39
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100877
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/extras/macros-test.cxx | 63 | ||||
-rw-r--r-- | sc/qa/extras/testdocuments/ProtectedArrayInCustomType.ods | bin | 0 -> 14327 bytes | |||
-rw-r--r-- | sc/qa/extras/testdocuments/testTypePassword.ods | bin | 27812 -> 31223 bytes |
3 files changed, 62 insertions, 1 deletions
diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx index d158d8c412c5..df2a1583edd4 100644 --- a/sc/qa/extras/macros-test.cxx +++ b/sc/qa/extras/macros-test.cxx @@ -43,6 +43,7 @@ public: void testRowColumn(); void testTdf131562(); void testPasswordProtectedUnicodeString(); + void testPasswordProtectedArrayInUserType(); void testTdf107902(); void testTdf131296_legacy(); void testTdf131296_new(); @@ -58,6 +59,7 @@ public: CPPUNIT_TEST(testRowColumn); CPPUNIT_TEST(testTdf131562); CPPUNIT_TEST(testPasswordProtectedUnicodeString); + CPPUNIT_TEST(testPasswordProtectedArrayInUserType); CPPUNIT_TEST(testTdf107902); CPPUNIT_TEST(testTdf131296_legacy); CPPUNIT_TEST(testTdf131296_new); @@ -143,7 +145,7 @@ void ScMacrosTest::testPasswordProtectedStarBasic() SfxObjectShell::CallXScript( xComponent, - "vnd.sun.Star.script:MyLibrary.Module1.Main?language=Basic&location=document", + "vnd.sun.Star.script:Standard.Module1.LoadAndExecuteTest?language=Basic&location=document", aParams, aRet, aOutParamIndex, aOutParam); OUString aValue = rDoc.GetString(0,0,0); @@ -550,6 +552,65 @@ void ScMacrosTest::testPasswordProtectedUnicodeString() xCloseable->close(true); } +void ScMacrosTest::testPasswordProtectedArrayInUserType() +{ + const OUString sMacroURL( + "vnd.sun.Star.script:Protected.Module1.TestMyType?language=Basic&location=document"); + const OUString sLibName("Protected"); + + OUString aFileName; + createFileURL("ProtectedArrayInCustomType.ods", aFileName); + auto xComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); + CPPUNIT_ASSERT(xComponent); + + // Check that loading password-protected macro image correctly loads array bounds + { + Any aRet; + Sequence<sal_Int16> aOutParamIndex; + Sequence<Any> aOutParam; + Sequence<uno::Any> aParams; + + SfxObjectShell::CallXScript(xComponent, sMacroURL, aParams, aRet, aOutParamIndex, + aOutParam); + + sal_Int16 nReturnValue; + aRet >>= nReturnValue; + CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nReturnValue); + } + + // Unlock and load the library, to regenerate the image on save + css::uno::Reference<css::document::XEmbeddedScripts> xES(xComponent, UNO_QUERY_THROW); + css::uno::Reference<css::script::XLibraryContainer> xLC(xES->getBasicLibraries(), + UNO_QUERY_THROW); + css::uno::Reference<css::script::XLibraryContainerPassword> xPasswd(xLC, UNO_QUERY_THROW); + CPPUNIT_ASSERT(xPasswd->isLibraryPasswordProtected(sLibName)); + CPPUNIT_ASSERT(!xPasswd->isLibraryPasswordVerified(sLibName)); + CPPUNIT_ASSERT(xPasswd->verifyLibraryPassword(sLibName, "password")); + xLC->loadLibrary(sLibName); + CPPUNIT_ASSERT(xLC->isLibraryLoaded(sLibName)); + + // Now check that saving stores array bounds correctly + saveAndReload(xComponent, "calc8"); + CPPUNIT_ASSERT(xComponent); + + { + Any aRet; + Sequence<sal_Int16> aOutParamIndex; + Sequence<Any> aOutParam; + Sequence<uno::Any> aParams; + + SfxObjectShell::CallXScript(xComponent, sMacroURL, aParams, aRet, aOutParamIndex, + aOutParam); + + sal_Int16 nReturnValue; + aRet >>= nReturnValue; + CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nReturnValue); + } + + css::uno::Reference<css::util::XCloseable> xCloseable(xComponent, css::uno::UNO_QUERY_THROW); + xCloseable->close(true); +} + void ScMacrosTest::testTdf114427() { OUString aFileName; diff --git a/sc/qa/extras/testdocuments/ProtectedArrayInCustomType.ods b/sc/qa/extras/testdocuments/ProtectedArrayInCustomType.ods Binary files differnew file mode 100644 index 000000000000..5d7b1a4c2791 --- /dev/null +++ b/sc/qa/extras/testdocuments/ProtectedArrayInCustomType.ods diff --git a/sc/qa/extras/testdocuments/testTypePassword.ods b/sc/qa/extras/testdocuments/testTypePassword.ods Binary files differindex 7f249bc95a6e..d75c17ace5b8 100644 --- a/sc/qa/extras/testdocuments/testTypePassword.ods +++ b/sc/qa/extras/testdocuments/testTypePassword.ods |