xref: /aoo41x/main/sw/source/ui/vba/vbapalette.cxx (revision efeef26f)
1*efeef26fSAndrew Rist /**************************************************************
2*efeef26fSAndrew Rist  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*efeef26fSAndrew Rist  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19*efeef26fSAndrew Rist  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22cdf0e10cSrcweir #include "vbapalette.hxx"
23cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
24cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
25cdf0e10cSrcweir #include <ooo/vba/word/WdColor.hpp>
26cdf0e10cSrcweir #include <ooo/vba/word/WdColorIndex.hpp>
27cdf0e10cSrcweir 
28cdf0e10cSrcweir using namespace ::ooo::vba;
29cdf0e10cSrcweir using namespace ::ooo::vba::word;
30cdf0e10cSrcweir using namespace ::com::sun::star;
31cdf0e10cSrcweir 
32cdf0e10cSrcweir static const sal_Int32 ColorTable[] =
33cdf0e10cSrcweir {
34cdf0e10cSrcweir WdColor::wdColorAutomatic, // 0
35cdf0e10cSrcweir WdColor::wdColorBlack,             // 1
36cdf0e10cSrcweir WdColor::wdColorBlue,               // 2
37cdf0e10cSrcweir WdColor::wdColorTurquoise,     // 3
38cdf0e10cSrcweir WdColor::wdColorBrightGreen, // 4
39cdf0e10cSrcweir WdColor::wdColorPink,               // 5
40cdf0e10cSrcweir WdColor::wdColorRed,                 // 6
41cdf0e10cSrcweir WdColor::wdColorYellow,           // 7
42cdf0e10cSrcweir WdColor::wdColorWhite,             // 8
43cdf0e10cSrcweir WdColor::wdColorDarkBlue,       // 9
44cdf0e10cSrcweir WdColor::wdColorTeal,               // 10
45cdf0e10cSrcweir WdColor::wdColorGreen,             // 11
46cdf0e10cSrcweir WdColor::wdColorViolet,           // 12
47cdf0e10cSrcweir WdColor::wdColorDarkRed,         // 13
48cdf0e10cSrcweir WdColor::wdColorDarkYellow,   // 14
49cdf0e10cSrcweir WdColor::wdColorGray50,           // 15
50cdf0e10cSrcweir WdColor::wdColorGray25,           // 16
51cdf0e10cSrcweir };
52cdf0e10cSrcweir 
53cdf0e10cSrcweir typedef ::cppu::WeakImplHelper1< container::XIndexAccess > XIndexAccess_BASE;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir class DefaultPalette : public XIndexAccess_BASE
56cdf0e10cSrcweir {
57cdf0e10cSrcweir public:
DefaultPalette()58cdf0e10cSrcweir    DefaultPalette(){}
59cdf0e10cSrcweir 
60cdf0e10cSrcweir     // Methods XIndexAccess
getCount()61cdf0e10cSrcweir     virtual ::sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException)
62cdf0e10cSrcweir     {
63cdf0e10cSrcweir         return sizeof(ColorTable) / sizeof(ColorTable[0]);
64cdf0e10cSrcweir     }
65cdf0e10cSrcweir 
getByIndex(::sal_Int32 Index)66cdf0e10cSrcweir     virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
67cdf0e10cSrcweir     {
68cdf0e10cSrcweir 	if ( Index < 0 || Index >= getCount() )
69cdf0e10cSrcweir 		throw lang::IndexOutOfBoundsException();
70cdf0e10cSrcweir         return uno::makeAny( sal_Int32( ColorTable[ Index ] ) );
71cdf0e10cSrcweir     }
72cdf0e10cSrcweir 
73cdf0e10cSrcweir     // Methods XElementAcess
getElementType()74cdf0e10cSrcweir     virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException)
75cdf0e10cSrcweir     {
76cdf0e10cSrcweir         return ::getCppuType( (sal_Int32*)0 );
77cdf0e10cSrcweir     }
hasElements()78cdf0e10cSrcweir     virtual ::sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException)
79cdf0e10cSrcweir     {
80cdf0e10cSrcweir         return sal_True;
81cdf0e10cSrcweir     }
82cdf0e10cSrcweir 
83cdf0e10cSrcweir };
84cdf0e10cSrcweir 
VbaPalette()85cdf0e10cSrcweir VbaPalette::VbaPalette()
86cdf0e10cSrcweir {
87cdf0e10cSrcweir     mxPalette = new DefaultPalette();
88cdf0e10cSrcweir }
89cdf0e10cSrcweir 
90cdf0e10cSrcweir uno::Reference< container::XIndexAccess >
getPalette() const91cdf0e10cSrcweir VbaPalette::getPalette() const
92cdf0e10cSrcweir {
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 	return mxPalette;
95cdf0e10cSrcweir }
96cdf0e10cSrcweir 
97