Kaydet (Commit) d6015719 authored tarafından Laurent Godard's avatar Laurent Godard Kaydeden (comit) Eike Rathke

calc : add UNO properties for "Record changes"

with unit testing

Change-Id: I2a0e09f699c8489f61453b4144dd6181bd9b47fd
Reviewed-on: https://gerrit.libreoffice.org/14603Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
Tested-by: 's avatarEike Rathke <erack@redhat.com>
üst 98444584
...@@ -193,6 +193,21 @@ published service SpreadsheetDocumentSettings ...@@ -193,6 +193,21 @@ published service SpreadsheetDocumentSettings
*/ */
[readonly, optional, property] com::sun::star::awt::XDevice ReferenceDevice; [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;
}; };
......
# -*- 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:
...@@ -70,6 +70,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\ ...@@ -70,6 +70,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
JunitTest_sc_unoapi \ JunitTest_sc_unoapi \
CppunitTest_sc_outlineobj \ CppunitTest_sc_outlineobj \
CppunitTest_sc_styleloaderobj \ CppunitTest_sc_styleloaderobj \
CppunitTest_sc_recordchanges \
CppunitTest_sc_annotationobj \ CppunitTest_sc_annotationobj \
CppunitTest_sc_annotationsobj \ CppunitTest_sc_annotationsobj \
CppunitTest_sc_cellrangeobj \ CppunitTest_sc_cellrangeobj \
......
...@@ -506,6 +506,9 @@ ...@@ -506,6 +506,9 @@
#define SC_UNO_REFERENCEDEVICE "ReferenceDevice" #define SC_UNO_REFERENCEDEVICE "ReferenceDevice"
#define SC_UNO_CODENAME "CodeName" #define SC_UNO_CODENAME "CodeName"
#define SC_UNO_INTEROPGRABBAG "InteropGrabBag" #define SC_UNO_INTEROPGRABBAG "InteropGrabBag"
#define SC_UNO_RECORDCHANGES "RecordChanges"
#define SC_UNO_ISRECORDCHANGESPROTECTED "IsRecordChangesProtected"
// document properties from FormModel // document properties from FormModel
#define SC_UNO_APPLYFMDES "ApplyFormDesignMode" #define SC_UNO_APPLYFMDES "ApplyFormDesignMode"
......
/* -*- 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: */
...@@ -150,6 +150,8 @@ static const SfxItemPropertyMapEntry* lcl_GetDocOptPropertyMap() ...@@ -150,6 +150,8 @@ static const SfxItemPropertyMapEntry* lcl_GetDocOptPropertyMap()
{OUString(SC_UNO_HASVALIDSIGNATURES), 0, getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0}, {OUString(SC_UNO_HASVALIDSIGNATURES), 0, getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0},
{OUString(SC_UNO_ISLOADED), 0, getBooleanCppuType(), 0, 0}, {OUString(SC_UNO_ISLOADED), 0, getBooleanCppuType(), 0, 0},
{OUString(SC_UNO_ISUNDOENABLED), 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_ISADJUSTHEIGHTENABLED), 0, getBooleanCppuType(), 0, 0},
{OUString(SC_UNO_ISEXECUTELINKENABLED), 0, getBooleanCppuType(), 0, 0}, {OUString(SC_UNO_ISEXECUTELINKENABLED), 0, getBooleanCppuType(), 0, 0},
{OUString(SC_UNO_ISCHANGEREADONLYENABLED), 0, getBooleanCppuType(), 0, 0}, {OUString(SC_UNO_ISCHANGEREADONLYENABLED), 0, getBooleanCppuType(), 0, 0},
...@@ -1742,6 +1744,17 @@ void SAL_CALL ScModelObj::setPropertyValue( ...@@ -1742,6 +1744,17 @@ void SAL_CALL ScModelObj::setPropertyValue(
bUndoEnabled bUndoEnabled
? officecfg::Office::Common::Undo::Steps::get() : 0); ? 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 ) else if ( aString == SC_UNO_ISADJUSTHEIGHTENABLED )
{ {
bool bOldAdjustHeightEnabled = rDoc.IsAdjustHeightEnabled(); bool bOldAdjustHeightEnabled = rDoc.IsAdjustHeightEnabled();
...@@ -1925,6 +1938,14 @@ uno::Any SAL_CALL ScModelObj::getPropertyValue( const OUString& aPropertyName ) ...@@ -1925,6 +1938,14 @@ uno::Any SAL_CALL ScModelObj::getPropertyValue( const OUString& aPropertyName )
{ {
ScUnoHelpFunctions::SetBoolInAny( aRet, rDoc.IsUndoEnabled() ); 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 ) else if ( aString == SC_UNO_ISADJUSTHEIGHTENABLED )
{ {
ScUnoHelpFunctions::SetBoolInAny( aRet, rDoc.IsAdjustHeightEnabled() ); ScUnoHelpFunctions::SetBoolInAny( aRet, rDoc.IsAdjustHeightEnabled() );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment