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