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>
35 using namespace ::ooo::vba::excel::XlPattern;
38 constexpr OUStringLiteral
PATTERN =
u"Pattern";
41 static std::map< sal_Int32, sal_Int32 >
aPatternMap {
42 { xlPatternAutomatic, 0 },
43 { xlPatternChecker, 9 },
44 { xlPatternCrissCross, 16 },
46 { xlPatternGray16, 17 },
47 { xlPatternGray25, 4 },
48 { xlPatternGray50, 2 },
49 { xlPatternGray75, 3 },
50 { xlPatternGray8, 18 },
51 { xlPatternGrid, 15 },
52 { xlPatternHorizontal, 5 },
53 { xlPatternLightDown, 13 },
54 { xlPatternLightHorizontal, 11 },
55 { xlPatternLightUp, 14 },
56 { xlPatternLightVertical, 12 },
58 { xlPatternSemiGray75, 10 },
59 { xlPatternSolid, 0 },
61 { xlPatternVertical, 6 }
70 throw lang::IllegalArgumentException(
"properties", uno::Reference< uno::XInterface >(), 2 );
83 if( _color >>= nColor )
113 aMixedColor =
GetPatternColor( nPatternColor, aBackColor, static_cast<sal_uInt32>(nPattern) );
115 aMixedColor =
GetPatternColor( aBackColor, aBackColor, static_cast<sal_uInt32>(nPattern) );
120 uno::Reference< container::XIndexAccess >
124 throw uno::RuntimeException();
134 _colorindex >>= nIndex;
137 if( nIndex == excel::XlColorIndex::xlColorIndexNone )
152 sal_Int32
nIndex = nColorIndex;
155 if ( !nIndex || ( nIndex == excel::XlColorIndex::xlColorIndexAutomatic ) || ( nIndex == excel::XlColorIndex::xlColorIndexNone ) )
158 uno::Reference< container::XIndexAccess > xIndex =
getPalette();
159 return xIndex->getByIndex( nIndex );
165 uno::Reference< container::XIndexAccess > xIndex =
getPalette();
166 sal_Int32 nElems = xIndex->getCount();
170 sal_Int32 nPaletteColor = 0;
171 xIndex->getByIndex(
count ) >>= nPaletteColor;
172 if ( nPaletteColor == nColor )
184 sal_Int32 nColor = 0;
187 if( ( aColor >>= nColor ) && ( nColor == -1 ) )
189 nColor = excel::XlColorIndex::xlColorIndexNone;
190 return uno::makeAny( nColor );
208 0x80, 0x00, 0x40, 0x20, 0x60, 0x40, 0x40, 0x40,
209 0x40, 0x40, 0x20, 0x60, 0x60, 0x60, 0x60, 0x48,
213 GetMixedColor( rPattColor, rBackColor, pnRatioTable[ nXclPattern ] ) : rPattColor;
227 sal_uInt32 nTemp = ((
static_cast< sal_Int32
>( nBack ) - nFore) * nTrans) / 0x80 + nFore;
228 return static_cast< sal_uInt8 >( nTemp );
230 uno::Reference< container::XNameContainer >
233 return uno::Reference < container::XNameContainer > (
m_xProps->getPropertyValue(
"UserDefinedAttributes"), uno::UNO_QUERY_THROW );
238 xml::AttributeData aDataValue;
239 if( aValue >>= aDataValue )
241 return aDataValue.Value.toInt32();
248 xml::AttributeData aAttributeData;
249 aAttributeData.Type =
"sal_Int32";
250 aAttributeData.Value = OUString::number( nValue );
251 return uno::makeAny( aAttributeData );
256 uno::Reference< container::XNameContainer > xNameContainer(
GetAttributeContainer(), uno::UNO_SET_THROW );
257 if( xNameContainer->hasByName( sName ) )
259 return xNameContainer->getByName( sName );
268 uno::Reference< container::XNameContainer > xNameContainer(
GetAttributeContainer(), uno::UNO_SET_THROW );
269 if( xNameContainer->hasByName( sName ) )
270 xNameContainer->removeByName( sName );
271 xNameContainer->insertByName( sName, aValue );
272 m_xProps->setPropertyValue(
"UserDefinedAttributes", uno::makeAny( xNameContainer ) );
283 return uno::makeAny( excel::XlPattern::xlPatternNone );
289 throw uno::RuntimeException(
"Invalid Pattern index" );
298 sal_Int32 nColor = 0;
304 aBackColor =
Color(nColor);
309 if( aAny >>= nColor )
312 aBackColor =
Color(nColor);
328 return uno::makeAny( sal_Int32( 0 ) );
333 sal_Int32 nPattColor = 0;
334 if( !(_patterncolor >>= nPattColor) )
335 throw uno::RuntimeException(
"Invalid Pattern Color" );
344 sal_Int32 nColor = 0;
352 sal_Int32 nColorIndex = 0;
353 if( !(_patterncolorindex >>= nColorIndex) )
354 throw uno::RuntimeException(
"Invalid Pattern Color" );
356 if( nColorIndex == 0 )
367 return uno::makeAny(static_cast<sal_Int32>(0));
378 return uno::makeAny(static_cast<double>(0));
389 return uno::makeAny(static_cast<double>(0));
400 return "ScVbaInterior";
403 uno::Sequence< OUString >
408 "ooo.vba.excel.Interior"
static sal_Int32 GetAttributeData(css::uno::Any const &aValue)
const size_t count(pCandidateA->getBorderLines().size())
css::uno::Any GetUserDefinedAttributes(const OUString &sName)
virtual css::uno::Any SAL_CALL getColorIndex() override
constexpr OUStringLiteral BACKCOLOR
static Color GetMixedColor(const Color &rFore, const Color &rBack, sal_uInt8 nTrans)
virtual OUString getServiceImplName() override
Sequence< OUString > aServiceNames
sal_Int32 XLRGBToOORGB(sal_Int32 nCol)
Color GetRGBColor() const
virtual void SAL_CALL setPatternColorIndex(const css::uno::Any &_patterncolorindex) override
sal_uInt8 GetBlue() const
css::uno::Reference< css::beans::XPropertySet > m_xProps
virtual css::uno::Sequence< OUString > getServiceNames() override
#define SAL_N_ELEMENTS(arr)
css::uno::Any SAL_CALL getTintAndShade() override
virtual void SAL_CALL setPatternColor(const css::uno::Any &_patterncolor) override
constexpr OUStringLiteral PATTERN
css::uno::Any SAL_CALL getPatternTintAndShade() override
void SAL_CALL setTintAndShade(const css::uno::Any &rAny) override
void SAL_CALL setPatternTintAndShade(const css::uno::Any &rAny) override
sal_Int32 OORGBToXLRGB(sal_Int32 nCol)
virtual void SAL_CALL setColorIndex(const css::uno::Any &_colorindex) override
css::uno::Reference< css::container::XIndexAccess > getPalette() const
static css::uno::Any SetAttributeData(sal_Int32 nValue)
void SetUserDefinedAttributes(const OUString &sName, const css::uno::Any &aValue)
void SAL_CALL setThemeColor(const css::uno::Any &rAny) override
css::uno::Any GetIndexColor(sal_Int32 nColorIndex)
virtual css::uno::Any SAL_CALL getPatternColorIndex() override
static std::map< sal_Int32, sal_Int32 > aPatternMap
sal_uInt8 GetGreen() const
virtual css::uno::Any SAL_CALL getColor() override
css::uno::Reference< css::container::XNameContainer > GetAttributeContainer()
virtual css::uno::Any SAL_CALL getPattern() override
ScVbaInterior(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::beans::XPropertySet > &xProps, ScDocument *pScDoc=nullptr)
static Color GetPatternColor(const Color &rPattColor, const Color &rBackColor, sal_uInt32 nXclPattern)
virtual void SAL_CALL setColor(const css::uno::Any &_color) override
virtual void SAL_CALL setPattern(const css::uno::Any &_pattern) override
virtual css::uno::Any SAL_CALL getPatternColor() override
static sal_uInt8 GetMixedColorComp(sal_uInt8 nFore, sal_uInt8 nBack, sal_uInt8 nTrans)
SfxObjectShell * GetDocumentShell() const
sal_Int32 GetColorIndex(const sal_Int32 nColor)
constexpr OUStringLiteral PATTERNCOLOR
css::uno::Any SAL_CALL getThemeColor() override
css::uno::Reference< css::container::XIndexAccess > getPalette() const