1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "vbapalette.hxx"
21 #include <cppuhelper/implbase.hxx>
22 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
23 #include <ooo/vba/word/WdColor.hpp>
24 #include <sal/macros.h>
26 using namespace ::ooo::vba
;
27 using namespace ::ooo::vba::word
;
28 using namespace ::com::sun::star
;
30 const sal_Int32 ColorTable
[] =
32 WdColor::wdColorAutomatic
, // 0
33 WdColor::wdColorBlack
, // 1
34 WdColor::wdColorBlue
, // 2
35 WdColor::wdColorTurquoise
, // 3
36 WdColor::wdColorBrightGreen
, // 4
37 WdColor::wdColorPink
, // 5
38 WdColor::wdColorRed
, // 6
39 WdColor::wdColorYellow
, // 7
40 WdColor::wdColorWhite
, // 8
41 WdColor::wdColorDarkBlue
, // 9
42 WdColor::wdColorTeal
, // 10
43 WdColor::wdColorGreen
, // 11
44 WdColor::wdColorViolet
, // 12
45 WdColor::wdColorDarkRed
, // 13
46 WdColor::wdColorDarkYellow
, // 14
47 WdColor::wdColorGray50
, // 15
48 WdColor::wdColorGray25
, // 16
51 typedef ::cppu::WeakImplHelper
< container::XIndexAccess
> XIndexAccess_BASE
;
55 class DefaultPalette
: public XIndexAccess_BASE
60 // Methods XIndexAccess
61 virtual ::sal_Int32 SAL_CALL
getCount() override
63 return SAL_N_ELEMENTS(ColorTable
);
66 virtual uno::Any SAL_CALL
getByIndex( ::sal_Int32 Index
) override
68 if ( Index
< 0 || Index
>= getCount() )
69 throw lang::IndexOutOfBoundsException();
70 return uno::Any( sal_Int32( ColorTable
[ Index
] ) );
73 // Methods XElementAccess
74 virtual uno::Type SAL_CALL
getElementType() override
76 return ::cppu::UnoType
<sal_Int32
>::get();
78 virtual sal_Bool SAL_CALL
hasElements() override
87 VbaPalette::VbaPalette()
88 : mxPalette(new DefaultPalette())
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */