19#include <com/sun/star/beans/XPropertySet.hpp>
20#include <com/sun/star/xml/AttributeData.hpp>
22#include <ooo/vba/excel/XlColorIndex.hpp>
23#include <ooo/vba/excel/XlPattern.hpp>
31#include <document.hxx>
33#include <frozen/bits/defines.h>
34#include <frozen/bits/elsa_std.h>
35#include <frozen/map.h>
39using namespace ::ooo::vba::excel::XlPattern;
45constexpr auto aPatternMap = frozen::make_map<sal_Int32, sal_Int32>({
46 { xlPatternAutomatic, 0 },
47 { xlPatternChecker, 9 },
48 { xlPatternCrissCross, 16 },
50 { xlPatternGray16, 17 },
51 { xlPatternGray25, 4 },
52 { xlPatternGray50, 2 },
53 { xlPatternGray75, 3 },
54 { xlPatternGray8, 18 },
55 { xlPatternGrid, 15 },
56 { xlPatternHorizontal, 5 },
57 { xlPatternLightDown, 13 },
58 { xlPatternLightHorizontal, 11 },
59 { xlPatternLightUp, 14 },
60 { xlPatternLightVertical, 12 },
62 { xlPatternSemiGray75, 10 },
63 { xlPatternSolid, 0 },
65 { xlPatternVertical, 6 }
74 throw lang::IllegalArgumentException(
"properties", uno::Reference< uno::XInterface >(), 2 );
87 if( _color >>= nColor )
103 sal_Int32 nPattern = 0;
106 nPattern = it->second;
120 aMixedColor =
GetPatternColor( nPatternColor, aBackColor,
static_cast<sal_uInt32
>(nPattern) );
122 aMixedColor =
GetPatternColor( aBackColor, aBackColor,
static_cast<sal_uInt32
>(nPattern) );
127uno::Reference< container::XIndexAccess >
131 throw uno::RuntimeException();
144 if(
nIndex == excel::XlColorIndex::xlColorIndexNone )
159 sal_Int32
nIndex = nColorIndex;
162 if ( !
nIndex || (
nIndex == excel::XlColorIndex::xlColorIndexAutomatic ) || (
nIndex == excel::XlColorIndex::xlColorIndexNone ) )
165 uno::Reference< container::XIndexAccess > xIndex =
getPalette();
166 return xIndex->getByIndex(
nIndex );
172 uno::Reference< container::XIndexAccess > xIndex =
getPalette();
173 sal_Int32 nElems = xIndex->getCount();
177 sal_Int32 nPaletteColor = 0;
178 xIndex->getByIndex(
count ) >>= nPaletteColor;
179 if ( nPaletteColor == nColor )
191 sal_Int32 nColor = 0;
194 if( ( aColor >>= nColor ) && ( nColor == -1 ) )
196 nColor = excel::XlColorIndex::xlColorIndexNone;
215 0x80, 0x00, 0x40, 0x20, 0x60, 0x40, 0x40, 0x40,
216 0x40, 0x40, 0x20, 0x60, 0x60, 0x60, 0x60, 0x48,
220 GetMixedColor( rPattColor, rBackColor, pnRatioTable[ nXclPattern ] ) : rPattColor;
234 sal_uInt32 nTemp = ((
static_cast< sal_Int32
>( nBack ) - nFore) * nTrans) / 0x80 + nFore;
235 return static_cast< sal_uInt8 >( nTemp );
237uno::Reference< container::XNameContainer >
240 return uno::Reference < container::XNameContainer > (
m_xProps->getPropertyValue(
"UserDefinedAttributes"), uno::UNO_QUERY_THROW );
245 xml::AttributeData aDataValue;
246 if( aValue >>= aDataValue )
248 return aDataValue.Value.toInt32();
255 xml::AttributeData aAttributeData;
256 aAttributeData.Type =
"sal_Int32";
257 aAttributeData.Value = OUString::number(
nValue );
263 uno::Reference< container::XNameContainer > xNameContainer(
GetAttributeContainer(), uno::UNO_SET_THROW );
264 if( xNameContainer->hasByName(
sName ) )
266 return xNameContainer->getByName(
sName );
275 uno::Reference< container::XNameContainer > xNameContainer(
GetAttributeContainer(), uno::UNO_SET_THROW );
276 if( xNameContainer->hasByName(
sName ) )
277 xNameContainer->removeByName(
sName );
278 xNameContainer->insertByName(
sName, aValue );
279 m_xProps->setPropertyValue(
"UserDefinedAttributes",
uno::Any( xNameContainer ) );
290 return uno::Any( excel::XlPattern::xlPatternNone );
296 throw uno::RuntimeException(
"Invalid Pattern index" );
305 sal_Int32 nColor = 0;
316 if( aAny >>= nColor )
340 sal_Int32 nPattColor = 0;
341 if( !(_patterncolor >>= nPattColor) )
342 throw uno::RuntimeException(
"Invalid Pattern Color" );
351 sal_Int32 nColor = 0;
359 sal_Int32 nColorIndex = 0;
360 if( !(_patterncolorindex >>= nColorIndex) )
361 throw uno::RuntimeException(
"Invalid Pattern Color" );
363 if( nColorIndex == 0 )
374 return uno::Any(
static_cast<sal_Int32
>(0));
385 return uno::Any(
static_cast<double>(0));
396 return uno::Any(
static_cast<double>(0));
407 return "ScVbaInterior";
410uno::Sequence< OUString >
415 "ooo.vba.excel.Interior"
Color GetRGBColor() const
sal_uInt8 GetBlue() const
sal_uInt8 GetGreen() const
SfxObjectShell * GetDocumentShell() const
virtual void SAL_CALL setColorIndex(const css::uno::Any &_colorindex) override
sal_Int32 GetColorIndex(const sal_Int32 nColor)
static css::uno::Any SetAttributeData(sal_Int32 nValue)
css::uno::Reference< css::container::XIndexAccess > getPalette() const
virtual css::uno::Any SAL_CALL getPatternColorIndex() override
css::uno::Any GetIndexColor(sal_Int32 nColorIndex)
static sal_uInt8 GetMixedColorComp(sal_uInt8 nFore, sal_uInt8 nBack, sal_uInt8 nTrans)
virtual css::uno::Any SAL_CALL getPatternColor() override
virtual css::uno::Sequence< OUString > getServiceNames() override
virtual css::uno::Any SAL_CALL getPattern() override
void SAL_CALL setTintAndShade(const css::uno::Any &rAny) override
virtual void SAL_CALL setPattern(const css::uno::Any &_pattern) override
ScVbaInterior(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, css::uno::Reference< css::beans::XPropertySet > xProps, ScDocument *pScDoc=nullptr)
static sal_Int32 GetAttributeData(css::uno::Any const &aValue)
css::uno::Reference< css::beans::XPropertySet > m_xProps
virtual OUString getServiceImplName() override
virtual void SAL_CALL setColor(const css::uno::Any &_color) override
void SetUserDefinedAttributes(const OUString &sName, const css::uno::Any &aValue)
virtual css::uno::Any SAL_CALL getColorIndex() override
virtual void SAL_CALL setPatternColorIndex(const css::uno::Any &_patterncolorindex) override
css::uno::Any SAL_CALL getThemeColor() override
static Color GetPatternColor(const Color &rPattColor, const Color &rBackColor, sal_uInt32 nXclPattern)
static Color GetMixedColor(const Color &rFore, const Color &rBack, sal_uInt8 nTrans)
virtual void SAL_CALL setPatternColor(const css::uno::Any &_patterncolor) override
void SAL_CALL setThemeColor(const css::uno::Any &rAny) override
css::uno::Any SAL_CALL getTintAndShade() override
css::uno::Reference< css::container::XNameContainer > GetAttributeContainer()
css::uno::Any GetUserDefinedAttributes(const OUString &sName)
css::uno::Any SAL_CALL getPatternTintAndShade() override
void SAL_CALL setPatternTintAndShade(const css::uno::Any &rAny) override
virtual css::uno::Any SAL_CALL getColor() override
css::uno::Reference< css::container::XIndexAccess > getPalette() const
Sequence< OUString > aServiceNames
#define SAL_N_ELEMENTS(arr)
sal_Int32 XLRGBToOORGB(sal_Int32 nCol)
sal_Int32 OORGBToXLRGB(sal_Int32 nCol)
constexpr OUStringLiteral BACKCOLOR
constexpr OUStringLiteral PATTERN
constexpr OUStringLiteral PATTERNCOLOR
constexpr auto aPatternMap