diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2007-12-07 09:47:56 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2007-12-07 09:47:56 +0000 |
commit | c6db9f155d563e6b59be4d380613698b1601828c (patch) | |
tree | d6a3a1c363116fdf784cdb1b14cad3c2f4dff154 /sc/source/ui | |
parent | f34f24332d1adefac886a2c4597adbf2cc0803f0 (diff) |
INTEGRATION: CWS npower8 (1.1.2); FILE ADDED
2007/10/16 09:36:58 npower 1.1.2.4: #i77189#
2007/07/18 13:46:45 npower 1.1.2.3: #i77189# sync ooo-build and this module
2007/05/13 07:34:00 npower 1.1.2.2: Add licence info
2007/05/10 11:21:45 npower 1.1.2.1: -m#i77189#
Diffstat (limited to 'sc/source/ui')
-rw-r--r-- | sc/source/ui/vba/vbacolorformat.cxx | 195 |
1 files changed, 195 insertions, 0 deletions
diff --git a/sc/source/ui/vba/vbacolorformat.cxx b/sc/source/ui/vba/vbacolorformat.cxx new file mode 100644 index 000000000000..051ddbb9d368 --- /dev/null +++ b/sc/source/ui/vba/vbacolorformat.cxx @@ -0,0 +1,195 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: vbacolorformat.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: vg $ $Date: 2007-12-07 10:47:56 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +#include <com/sun/star/beans/XPropertySet.hpp> +#include <org/openoffice/msforms/XLineFormat.hpp> +#include "vbacolorformat.hxx" + +using namespace org::openoffice; +using namespace com::sun::star; + +const sal_Int32 +MsoColorIndizes::getColorIndex( sal_Int32 nIndex ) +{ + const static sal_Int32 COLORINDIZES[56] = + { HAPICOLOR_BLACK, HAPICOLOR_WITHE, HAPICOLOR_RED, HAPICOLOR_BRIGHTGREEN, HAPICOLOR_BLUE, HAPICOLOR_YELLOW, HAPICOLOR_PINK, + HAPICOLOR_TURQUOISE, HAPICOLOR_DARKRED, HAPICOLOR_GREEN, HAPICOLOR_DARKBLUE, HAPICOLOR_DARKYELLOW, HAPICOLOR_VIOLET, + HAPICOLOR_TEAL, HAPICOLOR_GRAY_25_PERCENT, HAPICOLOR_GRAY_50_PERCENT, HAPICOLOR_PERIWINCKLE, HAPICOLOR_PLUM, + HAPICOLOR_IVORY, HAPICOLOR_LIGHTTURQUOISE, HAPICOLOR_DARKPRUPLE, HAPICOLOR_CORAL, HAPICOLOR_OCEANBLUE, HAPICOLOR_ICEBLUE, + HAPICOLOR_GREEN, HAPICOLOR_PINK, HAPICOLOR_YELLOW, HAPICOLOR_TURQUOISE, HAPICOLOR_VIOLET, HAPICOLOR_DARKRED, HAPICOLOR_TEAL, + HAPICOLOR_BLUE, HAPICOLOR_SKYBLUE, HAPICOLOR_LIGHTTURQUOISE, HAPICOLOR_LIGHTGREEN, HAPICOLOR_LIGHTYELLOW, HAPICOLOR_PALEBLUE, + HAPICOLOR_ROSE, HAPICOLOR_LAVENDER, HAPICOLOR_TAN, HAPICOLOR_LIGHTBLUE, HAPICOLOR_AQUA, HAPICOLOR_LIME, HAPICOLOR_GOLD, + HAPICOLOR_LIGHTORANGE, HAPICOLOR_ORANGE, HAPICOLOR_BLUEGRAY, HAPICOLOR_GRAY_40_PERCENT, HAPICOLOR_DARKTEAL, + HAPICOLOR_SEAGREEN, HAPICOLOR_NONAME, HAPICOLOR_OLIVEGREEN, HAPICOLOR_BROWN, HAPICOLOR_PLUM, HAPICOLOR_INDIGO, + HAPICOLOR_GRAY_80_PERCENT + }; + return COLORINDIZES[nIndex]; +} +ScVbaColorFormat::ScVbaColorFormat( const uno::Reference< vba::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< vba::XHelperInterface > xInternalParent, const uno::Reference< drawing::XShape > xShape, const sal_Int16 nColorFormatType ) : ScVbaColorFormat_BASE( xParent, xContext ), m_xInternalParent( xInternalParent ), m_xShape( xShape ), m_nColorFormatType( nColorFormatType ) +{ + m_xPropertySet.set( xShape, uno::UNO_QUERY_THROW ); + m_nFillFormatBackColor = 0; + try + { + uno::Reference< oo::msforms::XFillFormat > xFillFormat( xInternalParent, uno::UNO_QUERY_THROW ); + m_pFillFormat = ( ScVbaFillFormat* )( xFillFormat.get() ); + }catch ( uno::RuntimeException e ) + { + m_pFillFormat = NULL; + } +} + +void +ScVbaColorFormat::setColorFormat( sal_Int16 _ntype ) +{ + m_nColorFormatType = _ntype; +} + +// Attribute +sal_Int32 SAL_CALL +ScVbaColorFormat::getRGB() throw (uno::RuntimeException) +{ + sal_Int32 nRGB = 0; + switch( m_nColorFormatType ) + { + case ColorFormatType::LINEFORMAT_FORECOLOR: + m_xPropertySet->getPropertyValue( rtl::OUString::createFromAscii("LineColor") ) >>= nRGB; + break; + case ColorFormatType::LINEFORMAT_BACKCOLOR: + //TODO BackColor not supported + // m_xPropertySet->setPropertyValue( rtl::OUString::createFromAscii("Color"), uno::makeAny( nRGB ) ); + break; + case ColorFormatType::FILLFORMAT_FORECOLOR: + m_xPropertySet->getPropertyValue( rtl::OUString::createFromAscii("FillColor") ) >>= nRGB; + break; + case ColorFormatType::FILLFORMAT_BACKCOLOR: + nRGB = m_nFillFormatBackColor; + break; + default: + throw uno::RuntimeException( rtl::OUString::createFromAscii("Second parameter of ColorFormat is wrong."), uno::Reference< uno::XInterface >() ); + } + nRGB = OORGBToXLRGB( nRGB ); + return nRGB; +} + +void SAL_CALL +ScVbaColorFormat::setRGB( sal_Int32 _rgb ) throw (uno::RuntimeException) +{ + sal_Int32 nRGB = XLRGBToOORGB( _rgb ); + switch( m_nColorFormatType ) + { + case ColorFormatType::LINEFORMAT_FORECOLOR: + m_xPropertySet->setPropertyValue( rtl::OUString::createFromAscii( "LineColor" ), uno::makeAny( nRGB ) ); + break; + case ColorFormatType::LINEFORMAT_BACKCOLOR: + // TODO BackColor not supported + break; + case ColorFormatType::FILLFORMAT_FORECOLOR: + m_xPropertySet->setPropertyValue( rtl::OUString::createFromAscii( "FillColor" ), uno::makeAny( nRGB ) ); + if( m_pFillFormat ) + { + m_pFillFormat->setForeColorAndInternalStyle(nRGB); + } + break; + case ColorFormatType::FILLFORMAT_BACKCOLOR: + m_nFillFormatBackColor = nRGB; + if( m_pFillFormat ) + { + m_pFillFormat->setForeColorAndInternalStyle(nRGB); + } + break; + default: + throw uno::RuntimeException( rtl::OUString::createFromAscii("Second parameter of ColorFormat is wrong."), uno::Reference< uno::XInterface >() ); + } +} + +sal_Int32 SAL_CALL +ScVbaColorFormat::getSchemeColor() throw (uno::RuntimeException) +{ + sal_Int32 nColor = getRGB(); + // #TODO I guess the number of elements is determined by the correct scheme + // the implementation here seems to be a rehash of color index ( which seems to be a + // different thing ) - I would guess we need to know/import etc. the correct color scheme + // or at least find out a little more + sal_Int32 i = 0; + for( ; i < 56; i++ ) + { + if( nColor == MsoColorIndizes::getColorIndex(i) ) + break; + } + + if( i == 56 ) // this is most likely an error condition + --i; + return i; + // #TODO figure out what craziness is this, + // the 56 colors seems incorrect, as in default XL ( 2003 ) there are 80 colors +/* + if( i == 56 ) + { + i = -2; + } + + return ( i + 2 ); +*/ +} + +void SAL_CALL +ScVbaColorFormat::setSchemeColor( sal_Int32 _schemecolor ) throw (uno::RuntimeException) +{ + // the table is 0 based + sal_Int32 nColor = MsoColorIndizes::getColorIndex( _schemecolor ); + // nColor is already xl RGB + setRGB( nColor ); +} + + +rtl::OUString& +ScVbaColorFormat::getServiceImplName() +{ + static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaColorFormat") ); + return sImplName; +} + +uno::Sequence< rtl::OUString > +ScVbaColorFormat::getServiceNames() +{ + static uno::Sequence< rtl::OUString > aServiceNames; + if ( aServiceNames.getLength() == 0 ) + { + aServiceNames.realloc( 1 ); + aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.msforms.ColorFormat" ) ); + } + return aServiceNames; +} + |