LCOV - code coverage report
Current view: top level - vbahelper/source/vbahelper - vbacolorformat.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 60 0.0 %
Date: 2012-08-25 Functions: 0 8 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 76 0.0 %

           Branch data     Line data    Source code
       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                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      20                 :            : #include <ooo/vba/msforms/XLineFormat.hpp>
      21                 :            : #include "vbacolorformat.hxx"
      22                 :            : 
      23                 :            : using namespace ooo::vba;
      24                 :            : using namespace com::sun::star;
      25                 :            : 
      26                 :            : sal_Int32
      27                 :          0 : MsoColorIndizes::getColorIndex( sal_Int32 nIndex )
      28                 :            : {
      29                 :            :     const static sal_Int32 COLORINDIZES[56] =
      30                 :            :     {   HAPICOLOR_BLACK, HAPICOLOR_WITHE, HAPICOLOR_RED, HAPICOLOR_BRIGHTGREEN, HAPICOLOR_BLUE, HAPICOLOR_YELLOW, HAPICOLOR_PINK,
      31                 :            :         HAPICOLOR_TURQUOISE, HAPICOLOR_DARKRED, HAPICOLOR_GREEN, HAPICOLOR_DARKBLUE, HAPICOLOR_DARKYELLOW, HAPICOLOR_VIOLET,
      32                 :            :         HAPICOLOR_TEAL, HAPICOLOR_GRAY_25_PERCENT, HAPICOLOR_GRAY_50_PERCENT, HAPICOLOR_PERIWINCKLE, HAPICOLOR_PLUM,
      33                 :            :         HAPICOLOR_IVORY, HAPICOLOR_LIGHTTURQUOISE, HAPICOLOR_DARKPRUPLE, HAPICOLOR_CORAL, HAPICOLOR_OCEANBLUE, HAPICOLOR_ICEBLUE,
      34                 :            :         HAPICOLOR_GREEN, HAPICOLOR_PINK, HAPICOLOR_YELLOW, HAPICOLOR_TURQUOISE, HAPICOLOR_VIOLET, HAPICOLOR_DARKRED, HAPICOLOR_TEAL,
      35                 :            :         HAPICOLOR_BLUE, HAPICOLOR_SKYBLUE, HAPICOLOR_LIGHTTURQUOISE, HAPICOLOR_LIGHTGREEN, HAPICOLOR_LIGHTYELLOW, HAPICOLOR_PALEBLUE,
      36                 :            :         HAPICOLOR_ROSE, HAPICOLOR_LAVENDER, HAPICOLOR_TAN, HAPICOLOR_LIGHTBLUE, HAPICOLOR_AQUA, HAPICOLOR_LIME, HAPICOLOR_GOLD,
      37                 :            :         HAPICOLOR_LIGHTORANGE, HAPICOLOR_ORANGE, HAPICOLOR_BLUEGRAY, HAPICOLOR_GRAY_40_PERCENT, HAPICOLOR_DARKTEAL,
      38                 :            :         HAPICOLOR_SEAGREEN, HAPICOLOR_NONAME, HAPICOLOR_OLIVEGREEN, HAPICOLOR_BROWN, HAPICOLOR_PLUM, HAPICOLOR_INDIGO,
      39                 :            :         HAPICOLOR_GRAY_80_PERCENT
      40                 :            :     };
      41                 :          0 :     return COLORINDIZES[nIndex];
      42                 :            : }
      43                 :          0 : ScVbaColorFormat::ScVbaColorFormat( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< 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 )
      44                 :            : {
      45         [ #  # ]:          0 :     m_xPropertySet.set( xShape, uno::UNO_QUERY_THROW );
      46                 :          0 :     m_nFillFormatBackColor = 0;
      47                 :            :     try
      48                 :            :     {
      49         [ #  # ]:          0 :         uno::Reference< ov::msforms::XFillFormat > xFillFormat( xInternalParent, uno::UNO_QUERY_THROW );
      50 [ #  # ][ #  # ]:          0 :         m_pFillFormat = ( ScVbaFillFormat* )( xFillFormat.get() );
                 [ #  # ]
      51         [ #  # ]:          0 :     }catch ( uno::RuntimeException& )
      52                 :            :     {
      53                 :          0 :         m_pFillFormat = NULL;
      54                 :            :     }
      55                 :          0 : }
      56                 :            : 
      57                 :            : // Attribute
      58                 :            : sal_Int32 SAL_CALL
      59                 :          0 : ScVbaColorFormat::getRGB() throw (uno::RuntimeException)
      60                 :            : {
      61                 :          0 :     sal_Int32 nRGB = 0;
      62   [ #  #  #  #  :          0 :     switch( m_nColorFormatType )
                      # ]
      63                 :            :     {
      64                 :            :     case ColorFormatType::LINEFORMAT_FORECOLOR:
      65 [ #  # ][ #  # ]:          0 :         m_xPropertySet->getPropertyValue( rtl::OUString("LineColor") ) >>= nRGB;
      66                 :          0 :         break;
      67                 :            :     case ColorFormatType::LINEFORMAT_BACKCOLOR:
      68                 :            :         //TODO BackColor not supported
      69                 :            :         // m_xPropertySet->setPropertyValue( rtl::OUString("Color"), uno::makeAny( nRGB ) );
      70                 :          0 :         break;
      71                 :            :     case ColorFormatType::FILLFORMAT_FORECOLOR:
      72 [ #  # ][ #  # ]:          0 :         m_xPropertySet->getPropertyValue( rtl::OUString("FillColor") ) >>= nRGB;
      73                 :          0 :         break;
      74                 :            :     case ColorFormatType::FILLFORMAT_BACKCOLOR:
      75                 :          0 :         nRGB = m_nFillFormatBackColor;
      76                 :          0 :         break;
      77                 :            :     default:
      78         [ #  # ]:          0 :         throw uno::RuntimeException( rtl::OUString("Second parameter of ColorFormat is wrong."), uno::Reference< uno::XInterface >() );
      79                 :            :     }
      80         [ #  # ]:          0 :     nRGB = OORGBToXLRGB( nRGB );
      81                 :          0 :     return nRGB;
      82                 :            : }
      83                 :            : 
      84                 :            : void SAL_CALL
      85                 :          0 : ScVbaColorFormat::setRGB( sal_Int32 _rgb ) throw (uno::RuntimeException)
      86                 :            : {
      87         [ #  # ]:          0 :     sal_Int32 nRGB = XLRGBToOORGB( _rgb );
      88   [ #  #  #  #  :          0 :     switch( m_nColorFormatType )
                      # ]
      89                 :            :     {
      90                 :            :     case ColorFormatType::LINEFORMAT_FORECOLOR:
      91 [ #  # ][ #  # ]:          0 :         m_xPropertySet->setPropertyValue( rtl::OUString("LineColor"), uno::makeAny( nRGB ) );
                 [ #  # ]
      92                 :          0 :         break;
      93                 :            :     case ColorFormatType::LINEFORMAT_BACKCOLOR:
      94                 :            :         // TODO BackColor not supported
      95                 :          0 :         break;
      96                 :            :     case ColorFormatType::FILLFORMAT_FORECOLOR:
      97 [ #  # ][ #  # ]:          0 :         m_xPropertySet->setPropertyValue( rtl::OUString("FillColor"), uno::makeAny( nRGB ) );
                 [ #  # ]
      98         [ #  # ]:          0 :         if( m_pFillFormat )
      99                 :            :         {
     100         [ #  # ]:          0 :             m_pFillFormat->setForeColorAndInternalStyle(nRGB);
     101                 :            :         }
     102                 :          0 :         break;
     103                 :            :     case ColorFormatType::FILLFORMAT_BACKCOLOR:
     104                 :          0 :         m_nFillFormatBackColor = nRGB;
     105         [ #  # ]:          0 :         if( m_pFillFormat )
     106                 :            :         {
     107         [ #  # ]:          0 :             m_pFillFormat->setForeColorAndInternalStyle(nRGB);
     108                 :            :         }
     109                 :          0 :         break;
     110                 :            :     default:
     111         [ #  # ]:          0 :         throw uno::RuntimeException( rtl::OUString("Second parameter of ColorFormat is wrong."), uno::Reference< uno::XInterface >() );
     112                 :            :     }
     113                 :          0 : }
     114                 :            : 
     115                 :            : sal_Int32 SAL_CALL
     116                 :          0 : ScVbaColorFormat::getSchemeColor() throw (uno::RuntimeException)
     117                 :            : {
     118                 :          0 :     sal_Int32 nColor = getRGB();
     119                 :            :     // #TODO I guess the number of elements is determined by the correct scheme
     120                 :            :     // the implementation here seems to be a rehash of color index ( which seems to be a
     121                 :            :     // different thing ) - I would guess we need to know/import etc. the correct color scheme
     122                 :            :     // or at least find out a little more
     123                 :          0 :     sal_Int32 i = 0;
     124         [ #  # ]:          0 :     for( ; i < 56; i++ )
     125                 :            :     {
     126         [ #  # ]:          0 :         if( nColor == MsoColorIndizes::getColorIndex(i) )
     127                 :          0 :        break;
     128                 :            :     }
     129                 :            : 
     130         [ #  # ]:          0 :     if( i == 56 ) // this is most likely an error condition
     131                 :          0 :         --i;
     132                 :          0 :     return i;
     133                 :            :     // #TODO figure out what craziness is this,
     134                 :            :     // the 56 colors seems incorrect, as in default XL ( 2003 ) there are 80 colors
     135                 :            : /*
     136                 :            :     if( i == 56 )
     137                 :            :     {
     138                 :            :         i = -2;
     139                 :            :     }
     140                 :            : 
     141                 :            :     return ( i + 2 );
     142                 :            : */
     143                 :            : }
     144                 :            : 
     145                 :            : void SAL_CALL
     146                 :          0 : ScVbaColorFormat::setSchemeColor( sal_Int32 _schemecolor ) throw (uno::RuntimeException)
     147                 :            : {
     148                 :            :     // the table is 0 based
     149                 :          0 :     sal_Int32 nColor = MsoColorIndizes::getColorIndex( _schemecolor );
     150                 :            :     // nColor is already xl RGB
     151                 :          0 :     setRGB( nColor );
     152                 :          0 : }
     153                 :            : 
     154                 :            : rtl::OUString
     155                 :          0 : ScVbaColorFormat::getServiceImplName()
     156                 :            : {
     157                 :          0 :     return rtl::OUString("ScVbaColorFormat");
     158                 :            : }
     159                 :            : 
     160                 :            : uno::Sequence< rtl::OUString >
     161                 :          0 : ScVbaColorFormat::getServiceNames()
     162                 :            : {
     163 [ #  # ][ #  # ]:          0 :     static uno::Sequence< rtl::OUString > aServiceNames;
         [ #  # ][ #  # ]
     164         [ #  # ]:          0 :     if ( aServiceNames.getLength() == 0 )
     165                 :            :     {
     166                 :          0 :         aServiceNames.realloc( 1 );
     167         [ #  # ]:          0 :         aServiceNames[ 0 ] = rtl::OUString( "ooo.vba.msforms.ColorFormat"  );
     168                 :            :     }
     169                 :          0 :     return aServiceNames;
     170                 :            : }
     171                 :            : 
     172                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10