12#include <com/sun/star/beans/XPropertySet.hpp>
13#include <com/sun/star/container/XNameContainer.hpp>
14#include <com/sun/star/io/XInputStream.hpp>
15#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
16#include <com/sun/star/style/XStyle.hpp>
17#include <com/sun/star/style/XStyleLoader2.hpp>
19#include <com/sun/star/uno/Any.hxx>
20#include <com/sun/star/uno/Reference.hxx>
21#include <com/sun/star/uno/Sequence.hxx>
23#include <rtl/ustring.hxx>
24#include <cppunit/TestAssert.h>
30using namespace css::uno;
36 uno::Reference<style::XStyleLoader2> xStyleLoader(
init(), uno::UNO_QUERY_THROW);
38 uno::Reference<sheet::XSpreadsheetDocument> xDoc(
getTargetDoc(), uno::UNO_SET_THROW);
41 uno::Sequence<beans::PropertyValue> aOptions = xStyleLoader->getStyleLoaderOptions();
42 xStyleLoader->loadStylesFromURL(aFileURL, aOptions);
44 uno::Reference<style::XStyleFamiliesSupplier> xFamilySupplier(xDoc, UNO_QUERY_THROW);
50 uno::Reference<style::XStyleLoader2> xStyleLoader(
init(), uno::UNO_QUERY_THROW);
52 uno::Reference<sheet::XSpreadsheetDocument> xDoc(
getTargetDoc(), uno::UNO_SET_THROW);
55 uno::Sequence<beans::PropertyValue> aOptions = xStyleLoader->getStyleLoaderOptions();
56 xStyleLoader->loadStylesFromDocument(xSrcComponent, aOptions);
58 uno::Reference<style::XStyleFamiliesSupplier> xFamilySupplier(xDoc, UNO_QUERY_THROW);
64 uno::Reference<style::XStyleLoader2> xStyleLoader(
init(), uno::UNO_QUERY_THROW);
66 uno::Reference<sheet::XSpreadsheetDocument> xDoc(
getTargetDoc(), uno::UNO_SET_THROW);
68 const uno::Reference<io::XInputStream> xInputStream
71 uno::Sequence<beans::PropertyValue> aOptions = xStyleLoader->getStyleLoaderOptions();
72 auto nLength = aOptions.getLength();
74 beans::PropertyValue aInputStream;
75 aInputStream.Name =
"InputStream";
77 aTmp <<= xInputStream;
78 aInputStream.
Value = aTmp;
79 aOptions.getArray()[
nLength] = aInputStream;
81 xStyleLoader->loadStylesFromURL(
"private:stream", aOptions);
83 uno::Reference<style::XStyleFamiliesSupplier> xFamilySupplier(xDoc, UNO_QUERY_THROW);
88 uno::Reference<style::XStyleFamiliesSupplier>
const& xFamilySupplier)
91 uno::Reference<container::XNameAccess> xFamilies(xFamilySupplier->getStyleFamilies(),
93 uno::Reference<container::XNameContainer> xCellStyles(xFamilies->getByName(
"CellStyles"),
96 CPPUNIT_ASSERT_MESSAGE(
"Style not imported", xCellStyles->hasByName(
"myStyle"));
99 uno::Reference<style::XStyle> xMyStyle(xCellStyles->getByName(
"myStyle"), UNO_QUERY_THROW);
100 uno::Reference<beans::XPropertySet> xPropSet(xMyStyle, UNO_QUERY_THROW);
102 uno::Any aBackColor = xPropSet->getPropertyValue(
"CellBackColor");
103 uno::Any expectedBackColor(sal_Int32(16724787));
105 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Wrong CellBackColor", expectedBackColor, aBackColor);
109 uno::Reference<container::XNameContainer> xPageStyles(xFamilies->getByName(
"PageStyles"),
111 uno::Reference<beans::XPropertySet> xPagePropSet(xPageStyles->getByName(
"Default"),
114 uno::Any aPageBackColor = xPagePropSet->getPropertyValue(
"BackColor");
115 uno::Any expectedPageBackColor(sal_Int32(13434879));
117 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Wrong page style BackColor", expectedPageBackColor,
void testLoadStylesFromURL()
virtual css::uno::Reference< css::uno::XInterface > init()=0
void testLoadStylesFromDocument()
void testLoadStylesFromStream()
static void checkStyleProperties(css::uno::Reference< css::style::XStyleFamiliesSupplier > const &xFamilySupplier)
virtual OUString getTestURL()=0
virtual css::uno::Reference< css::sheet::XSpreadsheetDocument > getTargetDoc()=0
virtual css::uno::Reference< css::lang::XComponent > getSourceComponent()=0
Reference< XComponentContext > getProcessComponentContext()