[Libreoffice-commits] core.git: sc/qa sd/qa sw/qa

László Németh nemeth at numbertext.org
Thu Jun 28 14:36:27 UTC 2018


 sc/qa/unit/data/xlsx/open-as-read-only.xlsx          |binary
 sc/qa/unit/subsequent_export-test.cxx                |   12 ++++++++++++
 sd/qa/unit/data/pptx/open-as-read-only.pptx          |binary
 sd/qa/unit/export-tests-ooxml2.cxx                   |   12 ++++++++++++
 sw/qa/extras/ooxmlexport/data/open-as-read-only.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx           |    7 +++++++
 6 files changed, 31 insertions(+)

New commits:
commit bbdb6cb8ed0d77eeb2e413b38f29d2084bd8257b
Author: László Németh <nemeth at numbertext.org>
Date:   Tue Jun 26 15:01:05 2018 +0200

    tdf#107690 DOCX, XLSX and PPTX unit tests for "Open as read-only"
    
    ie. OOXML export/import of "_MarkAsFinal" MSO document property.
    
    Change-Id: I01f0702d5467e78eb93ce8dce8ba25874839c3e3
    Reviewed-on: https://gerrit.libreoffice.org/56475
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/sc/qa/unit/data/xlsx/open-as-read-only.xlsx b/sc/qa/unit/data/xlsx/open-as-read-only.xlsx
new file mode 100644
index 000000000000..e871a95d3997
Binary files /dev/null and b/sc/qa/unit/data/xlsx/open-as-read-only.xlsx differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 046ce15783d8..105852550b6c 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -207,6 +207,7 @@ public:
 
     void testHiddenRepeatedRowsODS();
     void testHyperlinkTargetFrameODS();
+    void testOpenDocumentAsReadOnly();
 
     CPPUNIT_TEST_SUITE(ScExportTest);
     CPPUNIT_TEST(test);
@@ -313,6 +314,7 @@ public:
 
     CPPUNIT_TEST(testHiddenRepeatedRowsODS);
     CPPUNIT_TEST(testHyperlinkTargetFrameODS);
+    CPPUNIT_TEST(testOpenDocumentAsReadOnly);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -4023,6 +4025,16 @@ void ScExportTest::testHyperlinkTargetFrameODS()
     CPPUNIT_ASSERT_EQUAL(OUString("_blank"), aTargetFrameExport);
 }
 
+void ScExportTest::testOpenDocumentAsReadOnly()
+{
+    ScDocShellRef xDocSh = loadDoc("open-as-read-only.", FORMAT_XLSX);
+    CPPUNIT_ASSERT(xDocSh->IsSecurityOptOpenReadOnly());
+    ScDocShellRef xDocSh2 = saveAndReload(xDocSh.get(), FORMAT_XLSX);
+    CPPUNIT_ASSERT(xDocSh2->IsSecurityOptOpenReadOnly());
+    xDocSh->DoClose();
+    xDocSh2->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sd/qa/unit/data/pptx/open-as-read-only.pptx b/sd/qa/unit/data/pptx/open-as-read-only.pptx
new file mode 100644
index 000000000000..57a4d32de7f4
Binary files /dev/null and b/sd/qa/unit/data/pptx/open-as-read-only.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx
index 01ca434b33b3..6ca55d72a4e3 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -145,6 +145,7 @@ public:
     void testTdf90627();
     void testTdf104786();
     void testTdf104789();
+    void testOpenDocumentAsReadOnly();
 
     CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
 
@@ -211,6 +212,7 @@ public:
     CPPUNIT_TEST(testTdf90627);
     CPPUNIT_TEST(testTdf104786);
     CPPUNIT_TEST(testTdf104789);
+    CPPUNIT_TEST(testOpenDocumentAsReadOnly);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -1682,6 +1684,16 @@ void SdOOXMLExportTest2::testTdf104789()
     xDocShRef->DoClose();
 }
 
+void SdOOXMLExportTest2::testOpenDocumentAsReadOnly()
+{
+    ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/open-as-read-only.pptx"), PPTX);
+    CPPUNIT_ASSERT(xDocShRef->IsSecurityOptOpenReadOnly());
+    utl::TempFile tempFile;
+    xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
+    CPPUNIT_ASSERT(xDocShRef->IsSecurityOptOpenReadOnly());
+    xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/qa/extras/ooxmlexport/data/open-as-read-only.docx b/sw/qa/extras/ooxmlexport/data/open-as-read-only.docx
new file mode 100644
index 000000000000..057c67ff6dfe
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/open-as-read-only.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index 730765a8c9ff..3e1c80d23ace 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -408,6 +408,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf107969, "tdf107969.docx")
     // SAXParseException: '[word/document.xml line 2]: Extra content at the end of the document', Stream 'word/document.xml'.
 }
 
+DECLARE_OOXMLEXPORT_TEST(testOpenDocumentAsReadOnly, "open-as-read-only.docx")
+{
+    SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
+    CPPUNIT_ASSERT(pTextDoc);
+    CPPUNIT_ASSERT(pTextDoc->GetDocShell()->IsSecurityOptOpenReadOnly());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list