xref: /AOO41X/main/sw/source/ui/vba/vbapalette.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir #include "vbapalette.hxx"
2*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
3*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
4*cdf0e10cSrcweir #include <ooo/vba/word/WdColor.hpp>
5*cdf0e10cSrcweir #include <ooo/vba/word/WdColorIndex.hpp>
6*cdf0e10cSrcweir 
7*cdf0e10cSrcweir using namespace ::ooo::vba;
8*cdf0e10cSrcweir using namespace ::ooo::vba::word;
9*cdf0e10cSrcweir using namespace ::com::sun::star;
10*cdf0e10cSrcweir 
11*cdf0e10cSrcweir static const sal_Int32 ColorTable[] =
12*cdf0e10cSrcweir {
13*cdf0e10cSrcweir WdColor::wdColorAutomatic, // 0
14*cdf0e10cSrcweir WdColor::wdColorBlack,             // 1
15*cdf0e10cSrcweir WdColor::wdColorBlue,               // 2
16*cdf0e10cSrcweir WdColor::wdColorTurquoise,     // 3
17*cdf0e10cSrcweir WdColor::wdColorBrightGreen, // 4
18*cdf0e10cSrcweir WdColor::wdColorPink,               // 5
19*cdf0e10cSrcweir WdColor::wdColorRed,                 // 6
20*cdf0e10cSrcweir WdColor::wdColorYellow,           // 7
21*cdf0e10cSrcweir WdColor::wdColorWhite,             // 8
22*cdf0e10cSrcweir WdColor::wdColorDarkBlue,       // 9
23*cdf0e10cSrcweir WdColor::wdColorTeal,               // 10
24*cdf0e10cSrcweir WdColor::wdColorGreen,             // 11
25*cdf0e10cSrcweir WdColor::wdColorViolet,           // 12
26*cdf0e10cSrcweir WdColor::wdColorDarkRed,         // 13
27*cdf0e10cSrcweir WdColor::wdColorDarkYellow,   // 14
28*cdf0e10cSrcweir WdColor::wdColorGray50,           // 15
29*cdf0e10cSrcweir WdColor::wdColorGray25,           // 16
30*cdf0e10cSrcweir };
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir typedef ::cppu::WeakImplHelper1< container::XIndexAccess > XIndexAccess_BASE;
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir class DefaultPalette : public XIndexAccess_BASE
35*cdf0e10cSrcweir {
36*cdf0e10cSrcweir public:
37*cdf0e10cSrcweir    DefaultPalette(){}
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir     // Methods XIndexAccess
40*cdf0e10cSrcweir     virtual ::sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException)
41*cdf0e10cSrcweir     {
42*cdf0e10cSrcweir         return sizeof(ColorTable) / sizeof(ColorTable[0]);
43*cdf0e10cSrcweir     }
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir     virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
46*cdf0e10cSrcweir     {
47*cdf0e10cSrcweir 	if ( Index < 0 || Index >= getCount() )
48*cdf0e10cSrcweir 		throw lang::IndexOutOfBoundsException();
49*cdf0e10cSrcweir         return uno::makeAny( sal_Int32( ColorTable[ Index ] ) );
50*cdf0e10cSrcweir     }
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir     // Methods XElementAcess
53*cdf0e10cSrcweir     virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException)
54*cdf0e10cSrcweir     {
55*cdf0e10cSrcweir         return ::getCppuType( (sal_Int32*)0 );
56*cdf0e10cSrcweir     }
57*cdf0e10cSrcweir     virtual ::sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException)
58*cdf0e10cSrcweir     {
59*cdf0e10cSrcweir         return sal_True;
60*cdf0e10cSrcweir     }
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir };
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir VbaPalette::VbaPalette()
65*cdf0e10cSrcweir {
66*cdf0e10cSrcweir     mxPalette = new DefaultPalette();
67*cdf0e10cSrcweir }
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir uno::Reference< container::XIndexAccess >
70*cdf0e10cSrcweir VbaPalette::getPalette() const
71*cdf0e10cSrcweir {
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir 	return mxPalette;
74*cdf0e10cSrcweir }
75*cdf0e10cSrcweir 
76