Kaydet (Commit) 454ec6e7 authored tarafından Laurent Godard's avatar Laurent Godard Kaydeden (comit) David Tardon

XStyleLoader2 : enhance unit test to PageStyle

and remove duplicate code

Change-Id: Ib9e3568c860fe5cd3f11374a1c61dff101e33a18
Reviewed-on: https://gerrit.libreoffice.org/10832Reviewed-by: 's avatarDavid Tardon <dtardon@redhat.com>
Tested-by: 's avatarDavid Tardon <dtardon@redhat.com>
üst 8d10b737
......@@ -12,6 +12,8 @@
#include <rtl/ustring.hxx>
#include <com/sun/star/style/XStyleLoader2.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <test/testdllapi.hxx>
namespace apitest {
......@@ -30,6 +32,9 @@ public:
// XStyleLoader2
void testLoadStylesFromDocument();
private:
void checkStyleProperties(css::uno::Reference< css::style::XStyleFamiliesSupplier > xFamilySupplier);
protected:
~XStyleLoader() {}
......
......@@ -12,7 +12,6 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/style/XStyleLoader.hpp>
......@@ -20,7 +19,6 @@
#include <com/sun/star/style/XStyle.hpp>
#include <rtl/ustring.hxx>
#include "cppunit/extensions/HelperMacros.h"
......@@ -44,22 +42,7 @@ void XStyleLoader::testLoadStylesFromURL()
xTargetStyleLoader->loadStylesFromURL(aFileURL, aOptions);
// 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);
OUString aCellStyleName("CellBackColor");
uno::Any aBackColor = xPropSet->getPropertyValue(aCellStyleName);
uno::Any expectedBackColor(sal_Int32(16724787));
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong CellBackColor" , expectedBackColor, aBackColor);
checkStyleProperties(xFamilySupplier);
}
......@@ -77,6 +60,12 @@ void XStyleLoader::testLoadStylesFromDocument()
xTargetStyleLoader->loadStylesFromDocument(xSourceDoc, aOptions);
checkStyleProperties(xFamilySupplier);
}
void XStyleLoader::checkStyleProperties( uno::Reference< style::XStyleFamiliesSupplier > 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);
......@@ -93,6 +82,15 @@ void XStyleLoader::testLoadStylesFromDocument()
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);
}
}
......
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