summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/test/sheet/xstyleloader.hxx45
-rw-r--r--include/test/style/xstyleloader.hxx50
-rw-r--r--sc/CppunitTest_sc_styleloaderobj.mk43
-rw-r--r--sc/Module_sc.mk1
-rw-r--r--sc/qa/extras/scstylefamiliesobj.cxx37
-rw-r--r--sc/qa/extras/scstyleloaderobj.cxx99
-rw-r--r--sc/qa/extras/testdocuments/ScStyleFamiliesObj.ods (renamed from sc/qa/extras/testdocuments/ScStyleLoaderObj.ods)bin12488 -> 12488 bytes
-rw-r--r--solenv/clang-format/blacklist3
-rw-r--r--test/Library_subsequenttest.mk2
-rw-r--r--test/source/sheet/xstyleloader.cxx97
-rw-r--r--test/source/style/xstyleloader.cxx93
11 files changed, 180 insertions, 290 deletions
diff --git a/include/test/sheet/xstyleloader.hxx b/include/test/sheet/xstyleloader.hxx
deleted file mode 100644
index 02ec28e5bf0e..000000000000
--- a/include/test/sheet/xstyleloader.hxx
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- 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/.
- */
-
-#ifndef INCLUDED_TEST_SHEET_XSTYLELOADER_HXX
-#define INCLUDED_TEST_SHEET_XSTYLELOADER_HXX
-
-#include <rtl/ustring.hxx>
-#include <com/sun/star/style/XStyleLoader2.hpp>
-#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
-
-#include <test/testdllapi.hxx>
-
-namespace apitest {
-
-class OOO_DLLPUBLIC_TEST XStyleLoader
-{
-public:
- virtual css::uno::Reference< css::uno::XInterface > init() = 0;
-
- virtual OUString getTestURL() = 0;
- virtual css::uno::Reference< css::lang::XComponent > getTargetComponent() = 0;
- virtual css::uno::Reference< css::lang::XComponent > getSourceComponent() = 0;
-
- // XStyleLoader
- void testLoadStylesFromURL();
- // XStyleLoader2
- void testLoadStylesFromDocument();
-
-private:
- static void checkStyleProperties(css::uno::Reference< css::style::XStyleFamiliesSupplier > const & xFamilySupplier);
-
-protected:
- ~XStyleLoader() {}
-
-};
-
-}
-
-#endif // INCLUDED_TEST_SHEET_XSTYLELOADER_HXX
diff --git a/include/test/style/xstyleloader.hxx b/include/test/style/xstyleloader.hxx
new file mode 100644
index 000000000000..4077d30327d0
--- /dev/null
+++ b/include/test/style/xstyleloader.hxx
@@ -0,0 +1,50 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_TEST_STYLE_XSTYLELOADER_HXX
+#define INCLUDED_TEST_STYLE_XSTYLELOADER_HXX
+
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+#include <com/sun/star/uno/XInterface.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <rtl/ustring.hxx>
+#include <test/testdllapi.hxx>
+
+namespace apitest
+{
+class OOO_DLLPUBLIC_TEST XStyleLoader
+{
+public:
+ virtual css::uno::Reference<css::uno::XInterface> init() = 0;
+ virtual css::uno::Reference<css::sheet::XSpreadsheetDocument> getTargetDoc() = 0;
+ virtual css::uno::Reference<css::lang::XComponent> getSourceComponent() = 0;
+ virtual OUString getTestURL() = 0;
+
+ // XStyleLoader
+ void testLoadStylesFromURL();
+ // XStyleLoader2
+ void testLoadStylesFromDocument();
+
+private:
+ static void checkStyleProperties(
+ css::uno::Reference<css::style::XStyleFamiliesSupplier> const& xFamilySupplier);
+
+protected:
+ ~XStyleLoader() {}
+};
+
+} // namespace apitest
+
+#endif // INCLUDED_TEST_STYLE_XSTYLELOADER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sc/CppunitTest_sc_styleloaderobj.mk b/sc/CppunitTest_sc_styleloaderobj.mk
deleted file mode 100644
index 61e1bdb552bf..000000000000
--- a/sc/CppunitTest_sc_styleloaderobj.mk
+++ /dev/null
@@ -1,43 +0,0 @@
-# -*- 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_styleloaderobj))
-
-$(eval $(call gb_CppunitTest_use_external,sc_styleloaderobj,boost_headers))
-
-$(eval $(call gb_CppunitTest_add_exception_objects,sc_styleloaderobj, \
- sc/qa/extras/scstyleloaderobj \
-))
-
-$(eval $(call gb_CppunitTest_use_libraries,sc_styleloaderobj, \
- cppu \
- sal \
- subsequenttest \
- test \
- unotest \
-))
-
-$(eval $(call gb_CppunitTest_set_include,sc_styleloaderobj,\
- $$(INCLUDE) \
-))
-
-$(eval $(call gb_CppunitTest_use_sdk_api,sc_styleloaderobj))
-
-$(eval $(call gb_CppunitTest_use_ure,sc_styleloaderobj))
-$(eval $(call gb_CppunitTest_use_vcl,sc_styleloaderobj))
-
-$(eval $(call gb_CppunitTest_use_components,sc_styleloaderobj,\
- $(sc_unoapi_common_components) \
-))
-
-$(eval $(call gb_CppunitTest_use_configuration,sc_styleloaderobj))
-
-# vim: set noet sw=4 ts=4:
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index dab235dbf863..6ee193103f70 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -178,7 +178,6 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
CppunitTest_sc_spreadsheetsettings \
CppunitTest_sc_spreadsheetsettingsobj \
CppunitTest_sc_stylefamiliesobj \
- CppunitTest_sc_styleloaderobj \
CppunitTest_sc_subtotaldescriptorbaseobj \
CppunitTest_sc_subtotalfieldobj \
CppunitTest_sc_tableconditionalentryobj \
diff --git a/sc/qa/extras/scstylefamiliesobj.cxx b/sc/qa/extras/scstylefamiliesobj.cxx
index 2cbed4673dd4..d972fe6a6148 100644
--- a/sc/qa/extras/scstylefamiliesobj.cxx
+++ b/sc/qa/extras/scstylefamiliesobj.cxx
@@ -12,6 +12,7 @@
#include <test/container/xindexaccess.hxx>
#include <test/container/xnameaccess.hxx>
#include <test/lang/xserviceinfo.hxx>
+#include <test/style/xstyleloader.hxx>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
@@ -33,12 +34,17 @@ class ScStyleFamiliesObj : public CalcUnoApiTest,
public apitest::XElementAccess,
public apitest::XIndexAccess,
public apitest::XNameAccess,
- public apitest::XServiceInfo
+ public apitest::XServiceInfo,
+ public apitest::XStyleLoader
{
public:
ScStyleFamiliesObj();
virtual uno::Reference<uno::XInterface> init() override;
+ virtual uno::Reference<sheet::XSpreadsheetDocument> getTargetDoc() override;
+ virtual uno::Reference<lang::XComponent> getSourceComponent() override;
+ virtual OUString getTestURL() override;
+
virtual void setUp() override;
virtual void tearDown() override;
@@ -62,10 +68,15 @@ public:
CPPUNIT_TEST(testGetSupportedServiceNames);
CPPUNIT_TEST(testSupportsService);
+ // XStyleLoader
+ CPPUNIT_TEST(testLoadStylesFromDocument);
+ CPPUNIT_TEST(testLoadStylesFromURL);
+
CPPUNIT_TEST_SUITE_END();
private:
uno::Reference<lang::XComponent> m_xComponent;
+ uno::Reference<lang::XComponent> m_xSrcComponent;
};
ScStyleFamiliesObj::ScStyleFamiliesObj()
@@ -88,17 +99,41 @@ uno::Reference<uno::XInterface> ScStyleFamiliesObj::init()
return xNA;
}
+uno::Reference<sheet::XSpreadsheetDocument> ScStyleFamiliesObj::getTargetDoc()
+{
+ uno::Reference<sheet::XSpreadsheetDocument> xDoc(m_xComponent, uno::UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc.is());
+
+ return xDoc;
+}
+
+uno::Reference<lang::XComponent> ScStyleFamiliesObj::getSourceComponent()
+{
+ return m_xSrcComponent;
+}
+
+OUString ScStyleFamiliesObj::getTestURL()
+{
+ OUString aFileURL;
+ createFileURL("ScStyleFamiliesObj.ods", aFileURL);
+ return aFileURL;
+}
+
void ScStyleFamiliesObj::setUp()
{
CalcUnoApiTest::setUp();
// create a calc document
m_xComponent = loadFromDesktop("private:factory/scalc");
CPPUNIT_ASSERT_MESSAGE("no component", m_xComponent.is());
+
+ m_xSrcComponent = loadFromDesktop(getTestURL());
+ CPPUNIT_ASSERT_MESSAGE("no src component", m_xSrcComponent.is());
}
void ScStyleFamiliesObj::tearDown()
{
closeDocument(m_xComponent);
+ closeDocument(m_xSrcComponent);
CalcUnoApiTest::tearDown();
}
diff --git a/sc/qa/extras/scstyleloaderobj.cxx b/sc/qa/extras/scstyleloaderobj.cxx
deleted file mode 100644
index ef4e9d5e9bfe..000000000000
--- a/sc/qa/extras/scstyleloaderobj.cxx
+++ /dev/null
@@ -1,99 +0,0 @@
-/* -*- 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/calc_unoapi_test.hxx>
-#include <test/sheet/xstyleloader.hxx>
-
-#include <com/sun/star/lang/XComponent.hpp>
-#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
-
-using namespace css;
-using namespace css::uno;
-
-namespace sc_apitest {
-
-class ScStyleLoaderObj : public CalcUnoApiTest, public apitest::XStyleLoader
-{
-public:
- ScStyleLoaderObj();
-
- virtual void setUp() override;
- virtual void tearDown() override;
-
- virtual uno::Reference< uno::XInterface > init() override;
- virtual uno::Reference< lang::XComponent > getTargetComponent() override;
- virtual uno::Reference< lang::XComponent > getSourceComponent() override;
- virtual OUString getTestURL() override;
-
- CPPUNIT_TEST_SUITE(ScStyleLoaderObj);
-
- // XStyleLoader
- CPPUNIT_TEST(testLoadStylesFromURL);
- CPPUNIT_TEST(testLoadStylesFromDocument);
-
- CPPUNIT_TEST_SUITE_END();
-private:
- uno::Reference< lang::XComponent > mxSourceComponent;
- uno::Reference< lang::XComponent > mxTargetComponent;
-};
-
-ScStyleLoaderObj::ScStyleLoaderObj()
- : CalcUnoApiTest("sc/qa/extras/testdocuments")
-{
-}
-
-uno::Reference< uno::XInterface > ScStyleLoaderObj::init()
-{
- return getTargetComponent();
-}
-
-uno::Reference< lang::XComponent > ScStyleLoaderObj::getTargetComponent()
-{
- // target is always an empty document
- return mxTargetComponent;
-}
-
-uno::Reference< lang::XComponent > ScStyleLoaderObj::getSourceComponent()
-{
- CPPUNIT_ASSERT_MESSAGE("Component not loaded",mxSourceComponent.is());
- return mxSourceComponent;
-}
-
-OUString ScStyleLoaderObj::getTestURL()
-{
- OUString aFileURL;
- createFileURL("ScStyleLoaderObj.ods", aFileURL);
- return aFileURL;
-}
-
-void ScStyleLoaderObj::setUp()
-{
- CalcUnoApiTest::setUp();
-
- mxTargetComponent = loadFromDesktop("private:factory/scalc");
- // get the test file url
- OUString aFileURL = getTestURL();
- mxSourceComponent = loadFromDesktop(aFileURL);
-}
-
-void ScStyleLoaderObj::tearDown()
-{
- closeDocument(mxSourceComponent);
- closeDocument(mxTargetComponent);
- CalcUnoApiTest::tearDown();
-}
-
-CPPUNIT_TEST_SUITE_REGISTRATION(ScStyleLoaderObj);
-
-}
-
-CPPUNIT_PLUGIN_IMPLEMENT();
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/extras/testdocuments/ScStyleLoaderObj.ods b/sc/qa/extras/testdocuments/ScStyleFamiliesObj.ods
index 0cc718c98bfe..0cc718c98bfe 100644
--- a/sc/qa/extras/testdocuments/ScStyleLoaderObj.ods
+++ b/sc/qa/extras/testdocuments/ScStyleFamiliesObj.ods
Binary files differ
diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist
index 87f88d633832..d582d0a1d68e 100644
--- a/solenv/clang-format/blacklist
+++ b/solenv/clang-format/blacklist
@@ -7615,7 +7615,6 @@ include/test/sheet/xspreadsheet.hxx
include/test/sheet/xspreadsheetdocument.hxx
include/test/sheet/xspreadsheets.hxx
include/test/sheet/xspreadsheets2.hxx
-include/test/sheet/xstyleloader.hxx
include/test/sheet/xsubtotalcalculatable.hxx
include/test/sheet/xsubtotaldescriptor.hxx
include/test/sheet/xsubtotalfield.hxx
@@ -10152,7 +10151,6 @@ sc/qa/extras/scmodelobj.cxx
sc/qa/extras/scnamedrangeobj.cxx
sc/qa/extras/scnamedrangesobj.cxx
sc/qa/extras/scoutlineobj.cxx
-sc/qa/extras/scstyleloaderobj.cxx
sc/qa/extras/scsubtotaldescriptorbaseobj.cxx
sc/qa/extras/scsubtotalfieldobj.cxx
sc/qa/extras/sctablesheetobj.cxx
@@ -16609,7 +16607,6 @@ test/source/sheet/xspreadsheet.cxx
test/source/sheet/xspreadsheetdocument.cxx
test/source/sheet/xspreadsheets.cxx
test/source/sheet/xspreadsheets2.cxx
-test/source/sheet/xstyleloader.cxx
test/source/sheet/xsubtotalcalculatable.cxx
test/source/sheet/xsubtotaldescriptor.cxx
test/source/sheet/xsubtotalfield.cxx
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index 8895df3e24a0..081763980f95 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -144,7 +144,6 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/sheet/xspreadsheets \
test/source/sheet/xspreadsheets2 \
test/source/sheet/xspreadsheetview \
- test/source/sheet/xstyleloader \
test/source/sheet/xsubtotalcalculatable \
test/source/sheet/xsubtotaldescriptor \
test/source/sheet/xsubtotalfield \
@@ -153,6 +152,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/sheet/xviewfreezable \
test/source/sheet/xviewpane \
test/source/sheet/xviewsplitable \
+ test/source/style/xstyleloader \
test/source/table/xcell \
test/source/table/xcellcursor \
test/source/table/xcolumnrowrange \
diff --git a/test/source/sheet/xstyleloader.cxx b/test/source/sheet/xstyleloader.cxx
deleted file mode 100644
index ce019a9e7c5f..000000000000
--- a/test/source/sheet/xstyleloader.cxx
+++ /dev/null
@@ -1,97 +0,0 @@
-/* -*- 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/sheet/xstyleloader.hxx>
-
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
-
-#include <com/sun/star/container/XNameContainer.hpp>
-
-#include <com/sun/star/style/XStyleLoader.hpp>
-#include <com/sun/star/style/XStyleLoader2.hpp>
-
-#include <com/sun/star/style/XStyle.hpp>
-
-#include <rtl/ustring.hxx>
-#include <cppunit/extensions/HelperMacros.h>
-
-using namespace css;
-using namespace css::uno;
-
-namespace apitest {
-
-
-void XStyleLoader::testLoadStylesFromURL()
-{
-
- uno::Reference< sheet::XSpreadsheetDocument > xTargetDoc(init(), UNO_QUERY_THROW);
-
- OUString aFileURL = getTestURL();
-
- uno::Reference< style::XStyleFamiliesSupplier > xFamilySupplier (xTargetDoc, UNO_QUERY_THROW);
- uno::Reference< style::XStyleLoader > xTargetStyleLoader (xFamilySupplier->getStyleFamilies(), UNO_QUERY_THROW);
-
- uno::Sequence< beans::PropertyValue > aOptions = xTargetStyleLoader->getStyleLoaderOptions();
-
- xTargetStyleLoader->loadStylesFromURL(aFileURL, aOptions);
-
- checkStyleProperties(xFamilySupplier);
-
-}
-
-void XStyleLoader::testLoadStylesFromDocument()
-{
-
- uno::Reference< sheet::XSpreadsheetDocument > xTargetDoc(init(), UNO_QUERY_THROW);
-
- uno::Reference< lang::XComponent > xSourceDoc (getSourceComponent(), UNO_QUERY_THROW);
-
- uno::Reference< style::XStyleFamiliesSupplier > xFamilySupplier (xTargetDoc, UNO_QUERY_THROW);
- uno::Reference< style::XStyleLoader2 > xTargetStyleLoader (xFamilySupplier->getStyleFamilies(), UNO_QUERY_THROW);
-
- uno::Sequence< beans::PropertyValue > aOptions = xTargetStyleLoader->getStyleLoaderOptions();
-
- xTargetStyleLoader->loadStylesFromDocument(xSourceDoc, aOptions);
-
- checkStyleProperties(xFamilySupplier);
-
-}
-
-void XStyleLoader::checkStyleProperties( uno::Reference< style::XStyleFamiliesSupplier > const & xFamilySupplier)
-{
- // check if targetDocument has myStyle
- uno::Reference< container::XNameAccess > xFamilies(xFamilySupplier->getStyleFamilies(), UNO_QUERY_THROW);
- uno::Reference< container::XNameContainer > xCellStyles(xFamilies->getByName("CellStyles"), UNO_QUERY_THROW);
-
- CPPUNIT_ASSERT_MESSAGE("Style not imported", xCellStyles->hasByName("myStyle"));
-
- // test the backgroundcolor is correctly imported
- uno::Reference< style::XStyle > xMyStyle (xCellStyles->getByName("myStyle"), UNO_QUERY_THROW);
- uno::Reference< beans::XPropertySet > xPropSet (xMyStyle, UNO_QUERY_THROW);
-
- uno::Any aBackColor = xPropSet->getPropertyValue("CellBackColor");
- uno::Any expectedBackColor(sal_Int32(16724787));
-
- CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong CellBackColor" , expectedBackColor, aBackColor);
-
- // test default pageStyle
-
- uno::Reference< container::XNameContainer > xPageStyles(xFamilies->getByName("PageStyles"), UNO_QUERY_THROW);
- uno::Reference<beans::XPropertySet> xPagePropSet(xPageStyles->getByName("Default"), UNO_QUERY_THROW);
-
- uno::Any aPageBackColor = xPagePropSet->getPropertyValue("BackColor");
- uno::Any expectedPageBackColor(sal_Int32(13434879));
-
- CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong page style BackColor" , expectedPageBackColor, aPageBackColor);
-}
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/style/xstyleloader.cxx b/test/source/style/xstyleloader.cxx
new file mode 100644
index 000000000000..5b684eab16a8
--- /dev/null
+++ b/test/source/style/xstyleloader.cxx
@@ -0,0 +1,93 @@
+/* -*- 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/style/xstyleloader.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/style/XStyle.hpp>
+#include <com/sun/star/style/XStyleLoader2.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <rtl/ustring.hxx>
+#include <cppunit/extensions/HelperMacros.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XStyleLoader::testLoadStylesFromURL()
+{
+ uno::Reference<style::XStyleLoader2> xStyleLoader(init(), uno::UNO_QUERY_THROW);
+
+ uno::Reference<sheet::XSpreadsheetDocument> xDoc(getTargetDoc(), uno::UNO_QUERY_THROW);
+ const OUString aFileURL = getTestURL();
+
+ uno::Sequence<beans::PropertyValue> aOptions = xStyleLoader->getStyleLoaderOptions();
+ xStyleLoader->loadStylesFromURL(aFileURL, aOptions);
+
+ uno::Reference<style::XStyleFamiliesSupplier> xFamilySupplier(xDoc, UNO_QUERY_THROW);
+ checkStyleProperties(xFamilySupplier);
+}
+
+void XStyleLoader::testLoadStylesFromDocument()
+{
+ uno::Reference<style::XStyleLoader2> xStyleLoader(init(), uno::UNO_QUERY_THROW);
+
+ uno::Reference<sheet::XSpreadsheetDocument> xDoc(getTargetDoc(), uno::UNO_QUERY_THROW);
+ uno::Reference<lang::XComponent> xSrcComponent(getSourceComponent(), UNO_QUERY_THROW);
+
+ uno::Sequence<beans::PropertyValue> aOptions = xStyleLoader->getStyleLoaderOptions();
+ xStyleLoader->loadStylesFromDocument(xSrcComponent, aOptions);
+
+ uno::Reference<style::XStyleFamiliesSupplier> xFamilySupplier(xDoc, UNO_QUERY_THROW);
+ checkStyleProperties(xFamilySupplier);
+}
+
+void XStyleLoader::checkStyleProperties(
+ uno::Reference<style::XStyleFamiliesSupplier> const& xFamilySupplier)
+{
+ // check if targetDocument has myStyle
+ uno::Reference<container::XNameAccess> xFamilies(xFamilySupplier->getStyleFamilies(),
+ UNO_QUERY_THROW);
+ uno::Reference<container::XNameContainer> xCellStyles(xFamilies->getByName("CellStyles"),
+ UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_MESSAGE("Style not imported", xCellStyles->hasByName("myStyle"));
+
+ // test the backgroundcolor is correctly imported
+ uno::Reference<style::XStyle> xMyStyle(xCellStyles->getByName("myStyle"), UNO_QUERY_THROW);
+ uno::Reference<beans::XPropertySet> xPropSet(xMyStyle, UNO_QUERY_THROW);
+
+ uno::Any aBackColor = xPropSet->getPropertyValue("CellBackColor");
+ uno::Any expectedBackColor(sal_Int32(16724787));
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong CellBackColor", expectedBackColor, aBackColor);
+
+ // test default pageStyle
+
+ uno::Reference<container::XNameContainer> xPageStyles(xFamilies->getByName("PageStyles"),
+ UNO_QUERY_THROW);
+ uno::Reference<beans::XPropertySet> xPagePropSet(xPageStyles->getByName("Default"),
+ UNO_QUERY_THROW);
+
+ uno::Any aPageBackColor = xPagePropSet->getPropertyValue("BackColor");
+ uno::Any expectedPageBackColor(sal_Int32(13434879));
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong page style BackColor", expectedPageBackColor,
+ aPageBackColor);
+}
+
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */