summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--offapi/com/sun/star/sheet/SpreadsheetDocumentSettings.idl15
-rw-r--r--sc/CppunitTest_sc_recordchanges.mk110
-rw-r--r--sc/Module_sc.mk1
-rw-r--r--sc/inc/unonames.hxx3
-rw-r--r--sc/qa/extras/recordchanges-test.cxx108
-rw-r--r--sc/qa/extras/testdocuments/RecordChangesProtected.odsbin0 -> 14217 bytes
-rw-r--r--sc/source/ui/unoobj/docuno.cxx21
7 files changed, 258 insertions, 0 deletions
diff --git a/offapi/com/sun/star/sheet/SpreadsheetDocumentSettings.idl b/offapi/com/sun/star/sheet/SpreadsheetDocumentSettings.idl
index 8b0d301987e0..50c67dfb649a 100644
--- a/offapi/com/sun/star/sheet/SpreadsheetDocumentSettings.idl
+++ b/offapi/com/sun/star/sheet/SpreadsheetDocumentSettings.idl
@@ -193,6 +193,21 @@ published service SpreadsheetDocumentSettings
*/
[readonly, optional, property] com::sun::star::awt::XDevice ReferenceDevice;
+ /** specifies whether changes record is enabled.
+
+ <p>No modification applied if the record changes protection is activated
+ information given by SpreadsheetDocumentSettings::IsRecordChangesProtected</p>
+
+ @since LibreOffice 4.5
+ */
+ [optional, property] boolean RecordChanges;
+
+ /** specifies whether changes record is protected.
+
+ @since LibreOffice 4.5
+ */
+ [readonly,optional, property] boolean IsRecordChangesProtected;
+
};
diff --git a/sc/CppunitTest_sc_recordchanges.mk b/sc/CppunitTest_sc_recordchanges.mk
new file mode 100644
index 000000000000..58ec52f57c5f
--- /dev/null
+++ b/sc/CppunitTest_sc_recordchanges.mk
@@ -0,0 +1,110 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,sc_recordchanges))
+
+$(eval $(call gb_CppunitTest_use_external,sc_recordchanges,boost_headers))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sc_recordchanges, \
+ sc/qa/extras/recordchanges-test \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sc_recordchanges, \
+ basegfx \
+ comphelper \
+ cppu \
+ cppuhelper \
+ drawinglayer \
+ editeng \
+ for \
+ forui \
+ i18nlangtag \
+ msfilter \
+ oox \
+ sal \
+ salhelper \
+ sax \
+ sb \
+ sc \
+ sfx \
+ sot \
+ subsequenttest \
+ svl \
+ svt \
+ svx \
+ svxcore \
+ test \
+ tk \
+ tl \
+ ucbhelper \
+ unotest \
+ utl \
+ vbahelper \
+ vcl \
+ xo \
+ $(gb_UWINAPI) \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sc_recordchanges,\
+ -I$(SRCDIR)/sc/source/ui/inc \
+ -I$(SRCDIR)/sc/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,sc_recordchanges,\
+ offapi \
+ udkapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,sc_recordchanges))
+$(eval $(call gb_CppunitTest_use_vcl,sc_recordchanges))
+
+$(eval $(call gb_CppunitTest_use_components,sc_recordchanges,\
+ basic/util/sb \
+ comphelper/util/comphelp \
+ configmgr/source/configmgr \
+ dbaccess/util/dba \
+ filter/source/config/cache/filterconfig1 \
+ filter/source/storagefilterdetect/storagefd \
+ forms/util/frm \
+ framework/util/fwk \
+ i18npool/util/i18npool \
+ linguistic/source/lng \
+ oox/util/oox \
+ package/source/xstor/xstor \
+ package/util/package2 \
+ sax/source/expatwrap/expwrap \
+ scripting/source/basprov/basprov \
+ scripting/util/scriptframe \
+ sc/util/sc \
+ sc/util/scd \
+ sc/util/scfilt \
+ $(call gb_Helper_optional,SCRIPTING, \
+ sc/util/vbaobj) \
+ sfx2/util/sfx \
+ sot/util/sot \
+ svl/source/fsstor/fsstorage \
+ toolkit/util/tk \
+ ucb/source/core/ucb1 \
+ ucb/source/ucp/file/ucpfile1 \
+ ucb/source/ucp/tdoc/ucptdoc1 \
+ unotools/util/utl \
+ unoxml/source/rdf/unordf \
+ unoxml/source/service/unoxml \
+ xmloff/util/xo \
+ svtools/util/svt \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sc_recordchanges))
+
+$(eval $(call gb_CppunitTest_use_unittest_configuration,sc_recordchanges))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index 83a97427e6d8..c25151f1a89f 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -70,6 +70,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
JunitTest_sc_unoapi \
CppunitTest_sc_outlineobj \
CppunitTest_sc_styleloaderobj \
+ CppunitTest_sc_recordchanges \
CppunitTest_sc_annotationobj \
CppunitTest_sc_annotationsobj \
CppunitTest_sc_cellrangeobj \
diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx
index 73ab29378b32..f21ed9e06587 100644
--- a/sc/inc/unonames.hxx
+++ b/sc/inc/unonames.hxx
@@ -506,6 +506,9 @@
#define SC_UNO_REFERENCEDEVICE "ReferenceDevice"
#define SC_UNO_CODENAME "CodeName"
#define SC_UNO_INTEROPGRABBAG "InteropGrabBag"
+#define SC_UNO_RECORDCHANGES "RecordChanges"
+#define SC_UNO_ISRECORDCHANGESPROTECTED "IsRecordChangesProtected"
+
// document properties from FormModel
#define SC_UNO_APPLYFMDES "ApplyFormDesignMode"
diff --git a/sc/qa/extras/recordchanges-test.cxx b/sc/qa/extras/recordchanges-test.cxx
new file mode 100644
index 000000000000..67e84e335c26
--- /dev/null
+++ b/sc/qa/extras/recordchanges-test.cxx
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/unoapi_test.hxx>
+
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include <rtl/ustring.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+/* Implementation of calc Record Changes test */
+
+class ScRecordChangesTest : public UnoApiTest
+{
+public:
+ ScRecordChangesTest();
+
+ void testSetRecordChanges();
+ void testCheckRecordChangesProtection();
+
+ CPPUNIT_TEST_SUITE(ScRecordChangesTest);
+ CPPUNIT_TEST(testSetRecordChanges);
+ CPPUNIT_TEST(testCheckRecordChangesProtection);
+ CPPUNIT_TEST_SUITE_END();
+
+};
+
+void ScRecordChangesTest::testSetRecordChanges()
+{
+
+ uno::Reference< com::sun::star::lang::XComponent > xComponent = loadFromDesktop("private:factory/scalc");
+
+ uno::Reference< sheet::XSpreadsheetDocument > xDoc(xComponent, UNO_QUERY_THROW);
+ uno::Reference< beans::XPropertySet > xDocSettingsPropSet (xDoc, UNO_QUERY_THROW);
+
+ bool recordChangesValue;
+ bool protectionValue;
+
+ CPPUNIT_ASSERT(xDocSettingsPropSet->getPropertyValue("RecordChanges") >>= recordChangesValue);
+ CPPUNIT_ASSERT(xDocSettingsPropSet->getPropertyValue("IsRecordChangesProtected") >>= protectionValue);
+
+ CPPUNIT_ASSERT_MESSAGE("a new document does not record changes", !recordChangesValue);
+ CPPUNIT_ASSERT_MESSAGE("a new document does not protect record changes", !protectionValue);
+
+ // now activate recording
+ uno::Any xValue;;
+ xValue <<= true;
+ xDocSettingsPropSet->setPropertyValue("RecordChanges", xValue);
+
+ CPPUNIT_ASSERT(xDocSettingsPropSet->getPropertyValue("RecordChanges") >>= recordChangesValue);
+ CPPUNIT_ASSERT_MESSAGE("the document should record changes", recordChangesValue);
+
+ closeDocument(xComponent);
+}
+
+void ScRecordChangesTest::testCheckRecordChangesProtection()
+{
+ // test with protected changes
+ OUString aFileName;
+ createFileURL( "RecordChangesProtected.ods", aFileName);
+ uno::Reference< com::sun::star::lang::XComponent > xComponent = loadFromDesktop(aFileName);
+
+ uno::Reference< sheet::XSpreadsheetDocument > xDoc(xComponent, UNO_QUERY_THROW);
+ uno::Reference< beans::XPropertySet > xDocSettingsPropSet (xDoc, UNO_QUERY_THROW);
+
+ bool recordChangesValue;
+ bool protectionValue;
+
+ CPPUNIT_ASSERT(xDocSettingsPropSet->getPropertyValue("RecordChanges") >>= recordChangesValue);
+ CPPUNIT_ASSERT(xDocSettingsPropSet->getPropertyValue("IsRecordChangesProtected") >>= protectionValue);
+
+ CPPUNIT_ASSERT_MESSAGE("the document should be recording changes", recordChangesValue);
+ CPPUNIT_ASSERT_MESSAGE("the protection should be active", protectionValue);
+
+ // try to de-activate recording
+ uno::Any xValue;;
+ xValue <<= false;
+ xDocSettingsPropSet->setPropertyValue("RecordChanges", xValue);
+
+ CPPUNIT_ASSERT(xDocSettingsPropSet->getPropertyValue("RecordChanges") >>= recordChangesValue);
+ CPPUNIT_ASSERT(xDocSettingsPropSet->getPropertyValue("IsRecordChangesProtected") >>= protectionValue);
+
+ // this document should still record changes as protection is set
+ CPPUNIT_ASSERT_MESSAGE("the document should still be recording changes", recordChangesValue);
+ CPPUNIT_ASSERT_MESSAGE("the protection should still be active", protectionValue);
+
+ closeDocument(xComponent);
+}
+
+ScRecordChangesTest::ScRecordChangesTest()
+ : UnoApiTest("/sc/qa/extras/testdocuments")
+{
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScRecordChangesTest);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/extras/testdocuments/RecordChangesProtected.ods b/sc/qa/extras/testdocuments/RecordChangesProtected.ods
new file mode 100644
index 000000000000..fac012d84c2a
--- /dev/null
+++ b/sc/qa/extras/testdocuments/RecordChangesProtected.ods
Binary files differ
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 8fe23683128f..478787402aed 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -150,6 +150,8 @@ static const SfxItemPropertyMapEntry* lcl_GetDocOptPropertyMap()
{OUString(SC_UNO_HASVALIDSIGNATURES), 0, getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0},
{OUString(SC_UNO_ISLOADED), 0, getBooleanCppuType(), 0, 0},
{OUString(SC_UNO_ISUNDOENABLED), 0, getBooleanCppuType(), 0, 0},
+ {OUString(SC_UNO_RECORDCHANGES), 0, getBooleanCppuType(), 0, 0},
+ {OUString(SC_UNO_ISRECORDCHANGESPROTECTED),0, getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0},
{OUString(SC_UNO_ISADJUSTHEIGHTENABLED), 0, getBooleanCppuType(), 0, 0},
{OUString(SC_UNO_ISEXECUTELINKENABLED), 0, getBooleanCppuType(), 0, 0},
{OUString(SC_UNO_ISCHANGEREADONLYENABLED), 0, getBooleanCppuType(), 0, 0},
@@ -1742,6 +1744,17 @@ void SAL_CALL ScModelObj::setPropertyValue(
bUndoEnabled
? officecfg::Office::Common::Undo::Steps::get() : 0);
}
+ else if ( aString == SC_UNO_RECORDCHANGES )
+ {
+ bool bRecordChangesEnabled = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+
+ bool bChangeAllowed = true;
+ if (!bRecordChangesEnabled)
+ bChangeAllowed = !pDocShell->HasChangeRecordProtection();
+
+ if (bChangeAllowed)
+ pDocShell->SetChangeRecording(bRecordChangesEnabled);
+ }
else if ( aString == SC_UNO_ISADJUSTHEIGHTENABLED )
{
bool bOldAdjustHeightEnabled = rDoc.IsAdjustHeightEnabled();
@@ -1925,6 +1938,14 @@ uno::Any SAL_CALL ScModelObj::getPropertyValue( const OUString& aPropertyName )
{
ScUnoHelpFunctions::SetBoolInAny( aRet, rDoc.IsUndoEnabled() );
}
+ else if ( aString == SC_UNO_RECORDCHANGES )
+ {
+ ScUnoHelpFunctions::SetBoolInAny( aRet, pDocShell->IsChangeRecording() );
+ }
+ else if ( aString == SC_UNO_ISRECORDCHANGESPROTECTED )
+ {
+ ScUnoHelpFunctions::SetBoolInAny( aRet, pDocShell->HasChangeRecordProtection() );
+ }
else if ( aString == SC_UNO_ISADJUSTHEIGHTENABLED )
{
ScUnoHelpFunctions::SetBoolInAny( aRet, rDoc.IsAdjustHeightEnabled() );