summaryrefslogtreecommitdiff
path: root/test/source/sheet
diff options
context:
space:
mode:
authorJens Carl <j.carl43@gmx.de>2018-03-22 06:13:33 +0000
committerJens Carl <j.carl43@gmx.de>2018-03-22 16:56:04 +0100
commitb910203239f29d886c698377fa40185998adbae3 (patch)
tree2b85ccf189815d97b9e5213ef363c3691e8141e5 /test/source/sheet
parent3228251663fa866c3cc84bc19d64f77f13e99eef (diff)
tdf#45904 Move _SpreadsheetDocumentSettings Java test to C++
Change-Id: Ic6bde95d0d4255e082a60e41a117365422b22aa8 Reviewed-on: https://gerrit.libreoffice.org/51724 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jens Carl <j.carl43@gmx.de>
Diffstat (limited to 'test/source/sheet')
-rw-r--r--test/source/sheet/spreadsheetdocumentsettings.cxx190
1 files changed, 190 insertions, 0 deletions
diff --git a/test/source/sheet/spreadsheetdocumentsettings.cxx b/test/source/sheet/spreadsheetdocumentsettings.cxx
new file mode 100644
index 000000000000..c57c5b911fe3
--- /dev/null
+++ b/test/source/sheet/spreadsheetdocumentsettings.cxx
@@ -0,0 +1,190 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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 <unoapi_property_testers.hxx>
+#include <test/sheet/spreadsheetdocumentsettings.hxx>
+
+#include <com/sun/star/awt/XDevice.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/i18n/XForbiddenCharacters.hpp>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/extensions/HelperMacros.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void SpreadsheetDocumentSettings::testSpreadsheetDocumentSettingsProperties()
+{
+ uno::Reference<beans::XPropertySet> xSpreadsheetDocumentSettings(init(), UNO_QUERY_THROW);
+ OUString propName;
+ uno::Any aNewValue;
+
+ propName = "IsIterationEnabled";
+ testBooleanProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "IterationCount";
+ testLongProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "IterationEpsilon";
+ testDoubleProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "StandardDecimals";
+ testShortProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "NullDate";
+ util::Date aNullDateGet;
+ util::Date aNullDateSet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: NullDate",
+ xSpreadsheetDocumentSettings->getPropertyValue(propName)
+ >>= aNullDateGet);
+
+ aNewValue <<= util::Date(1, 1, 2000);
+ xSpreadsheetDocumentSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetDocumentSettings->getPropertyValue(propName) >>= aNullDateSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unabel to set PropertyValue: NullDate", sal_Int16(2000),
+ aNullDateSet.Year);
+
+ propName = "DefaultTabStop";
+ testShortProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "IgnoreCase";
+ testBooleanProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "CalcAsShown";
+ testBooleanProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "MatchWholeCell";
+ testBooleanProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "SpellOnline";
+ testBooleanProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "LookUpLabels";
+ testBooleanProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "RegularExpressions";
+ testBooleanProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "ForbiddenCharacters";
+ uno::Reference<i18n::XForbiddenCharacters> xForbiddenCharactersGet;
+ uno::Reference<i18n::XForbiddenCharacters> xForbiddenCharactersSet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: ForbiddenCharacters",
+ xSpreadsheetDocumentSettings->getPropertyValue(propName)
+ >>= xForbiddenCharactersGet);
+
+ lang::Locale aForbiddenCharactersLocale;
+ aForbiddenCharactersLocale.Language = "ru";
+ aForbiddenCharactersLocale.Country = "RU";
+
+ uno::Reference<i18n::XForbiddenCharacters> xForbiddenCharactersNew;
+ aNewValue <<= xForbiddenCharactersNew;
+ xSpreadsheetDocumentSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetDocumentSettings->getPropertyValue(propName)
+ >>= xForbiddenCharactersSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "Able to set PropertyValue: ForbiddenCharacters",
+ xForbiddenCharactersGet->hasForbiddenCharacters(aForbiddenCharactersLocale),
+ xForbiddenCharactersSet->hasForbiddenCharacters(aForbiddenCharactersLocale));
+
+ propName = "HasDrawPages";
+ testBooleanReadonlyProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "CharLocale";
+ lang::Locale aCharLocaleGet;
+ lang::Locale aCharLocaleSet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: CharLocale",
+ xSpreadsheetDocumentSettings->getPropertyValue(propName)
+ >>= aCharLocaleGet);
+
+ lang::Locale aCharLocaleNew;
+ aCharLocaleNew.Language = "en";
+ aCharLocaleNew.Country = "CA";
+ aNewValue <<= aCharLocaleNew;
+ xSpreadsheetDocumentSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetDocumentSettings->getPropertyValue(propName) >>= aCharLocaleSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue: CharLocale", aCharLocaleNew.Country,
+ aCharLocaleSet.Country);
+
+ propName = "CharLocaleAsian";
+ lang::Locale aCharLocaleAsianGet;
+ lang::Locale aCharLocaleAsianSet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: CharLocaleAsian",
+ xSpreadsheetDocumentSettings->getPropertyValue(propName)
+ >>= aCharLocaleAsianGet);
+
+ lang::Locale aCharLocaleAsianNew;
+ aCharLocaleAsianNew.Language = "en";
+ aCharLocaleAsianNew.Country = "CA";
+ aNewValue <<= aCharLocaleAsianNew;
+ xSpreadsheetDocumentSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetDocumentSettings->getPropertyValue(propName)
+ >>= aCharLocaleAsianSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue: CharLocaleAsian",
+ aCharLocaleAsianNew.Country, aCharLocaleAsianSet.Country);
+
+ propName = "CharLocaleComplex";
+ lang::Locale aCharLocaleComplexGet;
+ lang::Locale aCharLocaleComplexSet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: CharLocaleComplex",
+ xSpreadsheetDocumentSettings->getPropertyValue(propName)
+ >>= aCharLocaleComplexGet);
+
+ lang::Locale aCharLocaleComplexNew;
+ aCharLocaleComplexNew.Language = "en";
+ aCharLocaleComplexNew.Country = "CA";
+ aNewValue <<= aCharLocaleComplexNew;
+ xSpreadsheetDocumentSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetDocumentSettings->getPropertyValue(propName)
+ >>= aCharLocaleComplexSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue: CharLocaleComplex",
+ aCharLocaleComplexNew.Country, aCharLocaleComplexSet.Country);
+
+ propName = "IsLoaded";
+ testBooleanProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "IsUndoEnabled";
+ testBooleanProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "IsAdjustHeightEnabled";
+ testBooleanProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "IsExecuteLinkEnabled";
+ testBooleanProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "ReferenceDevice";
+ uno::Reference<awt::XDevice> xDeviceGet;
+ uno::Reference<awt::XDevice> xDeviceSet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: ReferenceDevice",
+ xSpreadsheetDocumentSettings->getPropertyValue(propName) >>= xDeviceGet);
+
+ uno::Reference<awt::XDevice> xDeviceNew;
+ aNewValue <<= xDeviceNew;
+ xSpreadsheetDocumentSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetDocumentSettings->getPropertyValue(propName) >>= xDeviceSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Able to set PropertyValue: ReferenceDevice",
+ xDeviceSet->getInfo().Width, xDeviceGet->getInfo().Width);
+
+ propName = "RecordChanges";
+ testBooleanProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "IsRecordChangesProtected";
+ testBooleanReadonlyProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "Wildcards";
+ testBooleanProperty(xSpreadsheetDocumentSettings, propName);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */