21#include <com/sun/star/lang/XServiceInfo.hpp>
22#include <com/sun/star/container/XNameContainer.hpp>
23#include <com/sun/star/uno/XComponentContext.hpp>
33class SvxUnoColorTable :
public cppu::WeakImplHelper< container::XNameContainer, lang::XServiceInfo >
47 virtual void SAL_CALL insertByName(
const OUString& aName,
const uno::Any& aElement )
override;
48 virtual void SAL_CALL removeByName(
const OUString& Name )
override;
51 virtual void SAL_CALL replaceByName(
const OUString& aName,
const uno::Any& aElement )
override;
54 virtual uno::Any SAL_CALL getByName(
const OUString& aName )
override;
56 virtual uno::Sequence< OUString > SAL_CALL getElementNames()
override;
58 virtual sal_Bool SAL_CALL hasByName(
const OUString& aName )
override;
61 virtual uno::Type SAL_CALL getElementType()
override;
62 virtual sal_Bool SAL_CALL hasElements()
override;
65SvxUnoColorTable::SvxUnoColorTable()
72sal_Bool SAL_CALL SvxUnoColorTable::supportsService(
const OUString& ServiceName )
77OUString SAL_CALL SvxUnoColorTable::getImplementationName()
79 return "com.sun.star.drawing.SvxUnoColorTable";
82uno::Sequence< OUString > SAL_CALL SvxUnoColorTable::getSupportedServiceNames()
84 uno::Sequence<OUString> aSNS {
"com.sun.star.drawing.ColorTable" };
89void SAL_CALL SvxUnoColorTable::insertByName(
const OUString& aName,
const uno::Any& aElement )
91 if( hasByName( aName ) )
92 throw container::ElementExistException();
95 if( !(aElement >>= aColor) )
96 throw lang::IllegalArgumentException();
100 pList->Insert(std::make_unique<XColorEntry>(aColor, aName));
104void SAL_CALL SvxUnoColorTable::removeByName(
const OUString& Name )
108 throw container::NoSuchElementException();
110 pList->Remove( nIndex );
114void SAL_CALL SvxUnoColorTable::replaceByName(
const OUString& aName,
const uno::Any& aElement )
117 if( !(aElement >>= nColor) )
118 throw lang::IllegalArgumentException();
122 throw container::NoSuchElementException();
124 pList->Replace(nIndex, std::make_unique<XColorEntry>(nColor, aName ));
128uno::Any SAL_CALL SvxUnoColorTable::getByName(
const OUString& aName )
132 throw container::NoSuchElementException();
138uno::Sequence< OUString > SAL_CALL SvxUnoColorTable::getElementNames()
142 uno::Sequence< OUString >
aSeq( nCount );
143 OUString* pStrings =
aSeq.getArray();
154sal_Bool SAL_CALL SvxUnoColorTable::hasByName(
const OUString& aName )
161uno::Type SAL_CALL SvxUnoColorTable::getElementType()
163 return ::cppu::UnoType<sal_Int32>::get();
166sal_Bool SAL_CALL SvxUnoColorTable::hasElements()
168 return pList.is() && pList->Count() != 0;
173extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
175 css::uno::XComponentContext *,
176 css::uno::Sequence<css::uno::Any>
const &)
178 return cppu::acquire(
new SvxUnoColorTable);
Color GetRGBColor() const
const Color & GetColor() const
const OUString & GetName() const
Sequence< sal_Int8 > aSeq
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_drawing_SvxUnoColorTable_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)