fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / vba / vbapalette.cxx
blob2d52843d511ac5297faf886a3222dfeab903f9cf
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
22 #include <sal/macros.h>
23 #include <cppuhelper/implbase1.hxx>
24 #include <com/sun/star/beans/XPropertySet.hpp>
25 #include <com/sun/star/container/XIndexAccess.hpp>
26 #include "excelvbahelper.hxx"
28 using namespace ::com::sun::star;
29 using namespace ::ooo::vba;
31 /** Standard EGA colors, bright. */
32 #define EXC_PALETTE_EGA_COLORS_LIGHT \
33 0x000000, 0xFFFFFF, 0xFF0000, 0x00FF00, 0x0000FF, 0xFFFF00, 0xFF00FF, 0x00FFFF
34 /** Standard EGA colors, dark. */
35 #define EXC_PALETTE_EGA_COLORS_DARK \
36 0x800000, 0x008000, 0x000080, 0x808000, 0x800080, 0x008080, 0xC0C0C0, 0x808080
38 static const ColorData spnDefColorTable8[] =
40 /* 8 */ EXC_PALETTE_EGA_COLORS_LIGHT,
41 /* 16 */ EXC_PALETTE_EGA_COLORS_DARK,
42 /* 24 */ 0x9999FF, 0x993366, 0xFFFFCC, 0xCCFFFF, 0x660066, 0xFF8080, 0x0066CC, 0xCCCCFF,
43 /* 32 */ 0x000080, 0xFF00FF, 0xFFFF00, 0x00FFFF, 0x800080, 0x800000, 0x008080, 0x0000FF,
44 /* 40 */ 0x00CCFF, 0xCCFFFF, 0xCCFFCC, 0xFFFF99, 0x99CCFF, 0xFF99CC, 0xCC99FF, 0xFFCC99,
45 /* 48 */ 0x3366FF, 0x33CCCC, 0x99CC00, 0xFFCC00, 0xFF9900, 0xFF6600, 0x666699, 0x969696,
46 /* 56 */ 0x003366, 0x339966, 0x003300, 0x333300, 0x993300, 0x993366, 0x333399, 0x333333
49 typedef ::cppu::WeakImplHelper1< container::XIndexAccess > XIndexAccess_BASE;
51 class DefaultPalette : public XIndexAccess_BASE
53 public:
54 DefaultPalette(){}
56 // Methods XIndexAccess
57 virtual ::sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
59 return sizeof(spnDefColorTable8) / sizeof(spnDefColorTable8[0]);
62 virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE
64 if ( Index < 0 || Index >= getCount() )
65 throw lang::IndexOutOfBoundsException();
66 return uno::makeAny( sal_Int32( spnDefColorTable8[ Index ] ) );
69 // Methods XElementAcess
70 virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
72 return ::cppu::UnoType<sal_Int32>::get();
74 virtual sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
76 return sal_True;
81 ScVbaPalette::ScVbaPalette( const uno::Reference< frame::XModel >& rxModel ) :
82 m_pShell( excel::getDocShell( rxModel ) )
86 uno::Reference< container::XIndexAccess >
87 ScVbaPalette::getDefaultPalette()
89 return new DefaultPalette();
92 uno::Reference< container::XIndexAccess >
93 ScVbaPalette::getPalette() const
95 uno::Reference< container::XIndexAccess > xIndex;
96 uno::Reference< beans::XPropertySet > xProps;
97 if ( m_pShell )
98 xProps.set( m_pShell->GetModel(), uno::UNO_QUERY_THROW );
99 else
100 throw uno::RuntimeException("Can't extract palette, no doc shell" );
101 xIndex.set( xProps->getPropertyValue("ColorPalette"), uno::UNO_QUERY );
102 if ( !xIndex.is() )
103 return new DefaultPalette();
104 return xIndex;
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */