/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ #include <com/sun/star/beans/XPropertySet.hpp> #include"vbacolorformat.hxx"
// Attribute
sal_Int32 SAL_CALL
ScVbaColorFormat::getRGB()
{
sal_Int32 nRGB = 0; switch( m_nColorFormatType )
{ case ColorFormatType::LINEFORMAT_FORECOLOR:
m_xPropertySet->getPropertyValue( u"LineColor"_ustr ) >>= nRGB; break; case ColorFormatType::LINEFORMAT_BACKCOLOR: //TODO BackColor not supported // m_xPropertySet->setPropertyValue("Color", uno::makeAny( nRGB ) ); break; case ColorFormatType::FILLFORMAT_FORECOLOR:
m_xPropertySet->getPropertyValue( u"FillColor"_ustr ) >>= nRGB; break; case ColorFormatType::FILLFORMAT_BACKCOLOR:
nRGB = m_nFillFormatBackColor; break; default: throw uno::RuntimeException( u"Second parameter of ColorFormat is wrong."_ustr );
}
nRGB = OORGBToXLRGB( Color(ColorTransparency, nRGB) ); return nRGB;
}
void SAL_CALL
ScVbaColorFormat::setRGB( sal_Int32 _rgb )
{
sal_Int32 nRGB = XLRGBToOORGB( _rgb ); switch( m_nColorFormatType )
{ case ColorFormatType::LINEFORMAT_FORECOLOR:
m_xPropertySet->setPropertyValue( u"LineColor"_ustr , uno::Any( nRGB ) ); break; case ColorFormatType::LINEFORMAT_BACKCOLOR: // TODO BackColor not supported break; case ColorFormatType::FILLFORMAT_FORECOLOR:
m_xPropertySet->setPropertyValue( u"FillColor"_ustr , uno::Any( 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( u"Second parameter of ColorFormat is wrong."_ustr );
}
}
sal_Int32 SAL_CALL
ScVbaColorFormat::getSchemeColor()
{
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 == MsoColorIndices::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 )
{ // the table is 0 based
sal_Int32 nColor = MsoColorIndices::getColorIndex( _schemecolor ); // nColor is already xl RGB
setRGB( nColor );
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.