summaryrefslogtreecommitdiff
path: root/sc/qa/unit
diff options
context:
space:
mode:
authorSerge Krot <Serge.Krot@cib.de>2020-07-10 11:09:35 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2020-09-09 09:16:47 +0200
commit03f601d10c8fe8772dcb8542e1d44f2d2e87fbb4 (patch)
treecb48fe6e475eaf06995be75ed2a31c140bdefcf8 /sc/qa/unit
parente6bdfaaf572b592f7e8b510cb38f82a4aca41593 (diff)
tdf#108673 XLSX: Don't export invalid sheet references in cell validation
Change-Id: Id9d88f5e34f3017516f693505df4c3ce82b1890f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98479 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com> (cherry picked from commit a3b4831208da615789bd1e2d5660dd130807f504) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102127 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'sc/qa/unit')
-rw-r--r--sc/qa/unit/data/ods/validation-copypaste.odsbin0 -> 9868 bytes
-rw-r--r--sc/qa/unit/subsequent_export-test.cxx39
2 files changed, 39 insertions, 0 deletions
diff --git a/sc/qa/unit/data/ods/validation-copypaste.ods b/sc/qa/unit/data/ods/validation-copypaste.ods
new file mode 100644
index 000000000000..55f8d823b88b
--- /dev/null
+++ b/sc/qa/unit/data/ods/validation-copypaste.ods
Binary files differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 2f0a7c7fdd0e..9647d0964277 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -43,6 +43,7 @@
#include <scmod.hxx>
#include <dpcache.hxx>
#include <dpobject.hxx>
+#include <clipparam.hxx>
#include <svx/svdpage.hxx>
#include <svx/svdograf.hxx>
@@ -247,6 +248,7 @@ public:
void testTdf126177XLSX();
void testCommentTextVAlignment();
void testCommentTextHAlignment();
+ void testValidationCopyPaste();
void testXltxExport();
void testRotatedImageODS();
@@ -398,6 +400,7 @@ public:
CPPUNIT_TEST(testTdf126177XLSX);
CPPUNIT_TEST(testCommentTextVAlignment);
CPPUNIT_TEST(testCommentTextHAlignment);
+ CPPUNIT_TEST(testValidationCopyPaste);
CPPUNIT_TEST(testXltxExport);
CPPUNIT_TEST(testRotatedImageODS);
@@ -4797,6 +4800,42 @@ void ScExportTest::testTdf91634XLSX()
xDocSh->DoClose();
}
+void ScExportTest::testValidationCopyPaste()
+{
+ ScDocShellRef xDocSh = loadDoc("validation-copypaste.", FORMAT_ODS);
+ CPPUNIT_ASSERT(xDocSh.is());
+ ScDocument& rSrcDoc = xDocSh->GetDocument();
+
+ // Copy B1 from src doc to clip
+ ScDocument aClipDoc(SCDOCMODE_CLIP);
+ ScRange aSrcRange(1, 0, 1);
+ ScClipParam aClipParam(aSrcRange, false);
+ ScMarkData aMark(rSrcDoc.GetSheetLimits().mnMaxRow, rSrcDoc.GetSheetLimits().mnMaxCol);
+ aMark.SetMarkArea(aSrcRange);
+ rSrcDoc.CopyToClip(aClipParam, &aClipDoc, &aMark, false, false);
+
+ // Create second document, paste B1 from clip
+ ScDocShell* pShell2
+ = new ScDocShell(SfxModelFlags::EMBEDDED_OBJECT | SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS
+ | SfxModelFlags::DISABLE_DOCUMENT_RECOVERY);
+ pShell2->DoInitNew();
+ ScDocument& rDestDoc = pShell2->GetDocument();
+ ScRange aDstRange(1, 0, 0);
+ ScMarkData aMark2(rDestDoc.GetSheetLimits().mnMaxRow, rDestDoc.GetSheetLimits().mnMaxCol);
+ aMark2.SetMarkArea(aDstRange);
+ rDestDoc.CopyFromClip(aDstRange, aMark2, InsertDeleteFlags::ALL, nullptr, &aClipDoc);
+
+ // save as XLSX
+ std::shared_ptr<utl::TempFile> pXPathFile
+ = ScBootstrapFixture::exportTo(&(*pShell2), FORMAT_XLSX);
+
+ // check validation
+ xmlDocUniquePtr pDoc
+ = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/sheet1.xml");
+ CPPUNIT_ASSERT(pDoc);
+ assertXPathContent(pDoc, "/x:worksheet/x:dataValidations/x:dataValidation/x:formula1", "#REF!");
+}
+
void ScExportTest::testTdf115159()
{
ScDocShellRef xShell = loadDoc("tdf115159.", FORMAT_XLSX);