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 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  {
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 
86 {
87  mxPalette = new DefaultPalette();
88 }
89 
90 
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
virtual uno::Type SAL_CALL getElementType() override
css::uno::Reference< css::container::XIndexAccess > mxPalette
Definition: vbapalette.hxx:27
::cppu::WeakImplHelper< container::XIndexAccess > XIndexAccess_BASE
#define SAL_N_ELEMENTS(arr)
virtual uno::Any SAL_CALL getByIndex(::sal_Int32 Index) override
unsigned char sal_Bool
static const sal_Int32 ColorTable[]
Definition: vbapalette.cxx:32
virtual ::sal_Int32 SAL_CALL getCount() override
::cppu::WeakImplHelper< container::XIndexAccess > XIndexAccess_BASE
Definition: vbapalette.cxx:53
virtual sal_Bool SAL_CALL hasElements() override