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/beans/XPropertySet.hpp>
23 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
24 #include <ooo/vba/word/WdColor.hpp>
25 #include <ooo/vba/word/WdColorIndex.hpp>
26 #include <sal/macros.h>
27 
28 using namespace ::ooo::vba;
29 using namespace ::ooo::vba::word;
30 using namespace ::com::sun::star;
31 
32 static const sal_Int32 ColorTable[] =
33 {
34 WdColor::wdColorAutomatic, // 0
35 WdColor::wdColorBlack, // 1
36 WdColor::wdColorBlue, // 2
37 WdColor::wdColorTurquoise, // 3
38 WdColor::wdColorBrightGreen, // 4
39 WdColor::wdColorPink, // 5
40 WdColor::wdColorRed, // 6
41 WdColor::wdColorYellow, // 7
42 WdColor::wdColorWhite, // 8
43 WdColor::wdColorDarkBlue, // 9
44 WdColor::wdColorTeal, // 10
45 WdColor::wdColorGreen, // 11
46 WdColor::wdColorViolet, // 12
47 WdColor::wdColorDarkRed, // 13
48 WdColor::wdColorDarkYellow, // 14
49 WdColor::wdColorGray50, // 15
50 WdColor::wdColorGray25, // 16
51 };
52 
53 typedef ::cppu::WeakImplHelper< container::XIndexAccess > XIndexAccess_BASE;
54 
55 namespace {
56 
57 class DefaultPalette : public XIndexAccess_BASE
58 {
59 public:
60  DefaultPalette(){}
61 
62  // Methods XIndexAccess
63  virtual ::sal_Int32 SAL_CALL getCount() override
64  {
65  return SAL_N_ELEMENTS(ColorTable);
66  }
67 
68  virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) override
69  {
70  if ( Index < 0 || Index >= getCount() )
71  throw lang::IndexOutOfBoundsException();
72  return uno::makeAny( sal_Int32( ColorTable[ Index ] ) );
73  }
74 
75  // Methods XElementAccess
76  virtual uno::Type SAL_CALL getElementType() override
77  {
79  }
80  virtual sal_Bool SAL_CALL hasElements() override
81  {
82  return true;
83  }
84 
85 };
86 
87 }
88 
90  : mxPalette(new DefaultPalette())
91 {
92 }
93 
94 
95 /* 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
static const sal_Int32 ColorTable[]
Definition: vbapalette.cxx:32
::cppu::WeakImplHelper< container::XIndexAccess > XIndexAccess_BASE
Definition: vbapalette.cxx:53
struct _ADOIndex Index