LibreOffice Module sw (master)  1
vbapalette.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
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>
25 
26 using namespace ::ooo::vba;
27 using namespace ::ooo::vba::word;
28 using namespace ::com::sun::star;
29 
30 const sal_Int32 ColorTable[] =
31 {
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
49 };
50 
51 typedef ::cppu::WeakImplHelper< container::XIndexAccess > XIndexAccess_BASE;
52 
53 namespace {
54 
55 class DefaultPalette : public XIndexAccess_BASE
56 {
57 public:
58  DefaultPalette(){}
59 
60  // Methods XIndexAccess
61  virtual ::sal_Int32 SAL_CALL getCount() override
62  {
63  return SAL_N_ELEMENTS(ColorTable);
64  }
65 
66  virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) override
67  {
68  if ( Index < 0 || Index >= getCount() )
69  throw lang::IndexOutOfBoundsException();
70  return uno::makeAny( sal_Int32( ColorTable[ Index ] ) );
71  }
72 
73  // Methods XElementAccess
74  virtual uno::Type SAL_CALL getElementType() override
75  {
77  }
78  virtual sal_Bool SAL_CALL hasElements() override
79  {
80  return true;
81  }
82 
83 };
84 
85 }
86 
88  : mxPalette(new DefaultPalette())
89 {
90 }
91 
92 
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
::cppu::WeakImplHelper< container::XIndexAccess > XIndexAccess_BASE
#define SAL_N_ELEMENTS(arr)
unsigned char sal_Bool
const sal_Int32 ColorTable[]
Definition: vbapalette.cxx:30
::cppu::WeakImplHelper< container::XIndexAccess > XIndexAccess_BASE
Definition: vbapalette.cxx:51
struct _ADOIndex Index