LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/vbahelper/source/vbahelper - vbafillformat.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 64 87 73.6 %
Date: 2013-07-09 Functions: 12 15 80.0 %
Legend: Lines: hit not hit

          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 <com/sun/star/awt/Gradient.hpp>
      21             : #include <com/sun/star/awt/GradientStyle.hpp>
      22             : #include <ooo/vba/office/MsoGradientStyle.hpp>
      23             : #include "vbafillformat.hxx"
      24             : #include "vbacolorformat.hxx"
      25             : 
      26             : using namespace ooo::vba;
      27             : using namespace com::sun::star;
      28             : 
      29          11 : ScVbaFillFormat::ScVbaFillFormat( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< drawing::XShape > xShape ) : ScVbaFillFormat_BASE( xParent, xContext ), m_xShape( xShape )
      30             : {
      31          11 :     m_xPropertySet.set( xShape, uno::UNO_QUERY_THROW );
      32          11 :     m_nFillStyle = drawing::FillStyle_SOLID;
      33          11 :     m_nForeColor = 0;
      34          11 :     m_nBackColor = 0;
      35          11 :     m_nGradientAngle = 0;
      36          11 : }
      37             : 
      38             : void
      39           5 : ScVbaFillFormat::setFillStyle( drawing::FillStyle nFillStyle ) throw (uno::RuntimeException)
      40             : {
      41           5 :     m_nFillStyle = nFillStyle;
      42           5 :     if( m_nFillStyle == drawing::FillStyle_GRADIENT )
      43             :     {
      44           1 :         m_xPropertySet->setPropertyValue( "FillStyle" , uno::makeAny( drawing::FillStyle_GRADIENT ) );
      45           1 :         awt::Gradient aGradient;
      46             :         // AXIAL
      47             :         // RADIAL
      48             :         // ELLIPTICAL
      49             :         // SQUARE
      50             :         // RECT
      51           1 :         aGradient.Style = awt::GradientStyle_LINEAR;
      52           1 :         aGradient.StartColor = ForeColor()->getRGB();
      53           1 :         aGradient.EndColor = BackColor()->getRGB();
      54           1 :         aGradient.Angle = m_nGradientAngle;
      55           1 :         aGradient.Border = 0;
      56           1 :         aGradient.XOffset = 0;
      57           1 :         aGradient.YOffset = 0;
      58           1 :         aGradient.StartIntensity = 100;
      59           1 :         aGradient.EndIntensity = 100;
      60           1 :         aGradient.StepCount = 1;
      61           1 :         m_xPropertySet->setPropertyValue( "FillGradient" , uno::makeAny( aGradient ) );
      62             :     }
      63           4 :     else if( m_nFillStyle == drawing::FillStyle_SOLID )
      64             :     {
      65           4 :         m_xPropertySet->setPropertyValue( "FillStyle" , uno::makeAny(drawing::FillStyle_SOLID) );
      66             :     }
      67           5 : }
      68             : 
      69             : void
      70           4 : ScVbaFillFormat::setForeColorAndInternalStyle( sal_Int32 nForeColor ) throw (css::uno::RuntimeException)
      71             : {
      72           4 :     m_nForeColor = nForeColor;
      73           4 :     setFillStyle( m_nFillStyle );
      74           4 : }
      75             : 
      76             : // Attributes
      77             : sal_Bool SAL_CALL
      78           1 : ScVbaFillFormat::getVisible() throw (uno::RuntimeException)
      79             : {
      80             :     drawing::FillStyle nFillStyle;
      81           1 :     m_xPropertySet->getPropertyValue( "FillStyle" ) >>= nFillStyle;
      82           1 :     if( nFillStyle == drawing::FillStyle_NONE )
      83           0 :         return sal_False;
      84           1 :     return sal_True;
      85             : }
      86             : 
      87             : void SAL_CALL
      88           1 : ScVbaFillFormat::setVisible( sal_Bool _visible ) throw (uno::RuntimeException)
      89             : {
      90             :     drawing::FillStyle aFillStyle;
      91           1 :     m_xPropertySet->getPropertyValue( "FillStyle" ) >>= aFillStyle;
      92           1 :     if( !_visible )
      93             :     {
      94           0 :         m_xPropertySet->setPropertyValue( "FillStyle" , uno::makeAny( drawing::FillStyle_NONE ) );
      95             :     }
      96             :     else
      97             :     {
      98           1 :         if( aFillStyle == drawing::FillStyle_NONE )
      99             :         {
     100           0 :             setFillStyle( m_nFillStyle );
     101             :         }
     102             :     }
     103           1 : }
     104             : 
     105             : double SAL_CALL
     106           1 : ScVbaFillFormat::getTransparency() throw (uno::RuntimeException)
     107             : {
     108           1 :     sal_Int16 nTransparence = 0;
     109           1 :     double dTransparence = 0;
     110           1 :     m_xPropertySet->getPropertyValue( "FillTransparence" ) >>= nTransparence;
     111           1 :     dTransparence = static_cast<double>( nTransparence );
     112           1 :     dTransparence /= 100;
     113           1 :     return dTransparence;
     114             : }
     115             : 
     116             : void SAL_CALL
     117           1 : ScVbaFillFormat::setTransparency( double _transparency ) throw (uno::RuntimeException)
     118             : {
     119           1 :     sal_Int16 nTransparence = static_cast< sal_Int16 >( _transparency * 100 );
     120           1 :     m_xPropertySet->setPropertyValue( "FillTransparence" , uno::makeAny( nTransparence ) );
     121           1 : }
     122             : 
     123             : 
     124             : // Methods
     125             : void SAL_CALL
     126           0 : ScVbaFillFormat::Solid() throw (uno::RuntimeException)
     127             : {
     128           0 :     setFillStyle( drawing::FillStyle_SOLID );
     129           0 : }
     130             : 
     131             : void SAL_CALL
     132           1 : ScVbaFillFormat::TwoColorGradient( sal_Int32 style, sal_Int32 /*variant*/ ) throw (uno::RuntimeException)
     133             : {
     134           1 :     if( style == office::MsoGradientStyle::msoGradientHorizontal )
     135             :     {
     136           1 :         m_nGradientAngle = 0;
     137           1 :         setFillStyle( drawing::FillStyle_GRADIENT );
     138             :     }
     139           0 :     else if( style == office::MsoGradientStyle::msoGradientVertical )
     140             :     {
     141           0 :         m_nGradientAngle = 900;
     142           0 :         setFillStyle( drawing::FillStyle_GRADIENT );
     143             :     }
     144           0 :     else if( style == office::MsoGradientStyle::msoGradientDiagonalDown )
     145             :     {
     146           0 :         m_nGradientAngle = 450;
     147           0 :         setFillStyle( drawing::FillStyle_GRADIENT );
     148             :     }
     149           0 :     else if( style == office::MsoGradientStyle::msoGradientDiagonalUp )
     150             :     {
     151           0 :         m_nGradientAngle = 900 + 450;
     152           0 :         setFillStyle( drawing::FillStyle_GRADIENT );
     153             :     }
     154           1 : }
     155             : 
     156             : uno::Reference< msforms::XColorFormat > SAL_CALL
     157           3 : ScVbaFillFormat::BackColor() throw (uno::RuntimeException)
     158             : {
     159           3 :     if( !m_xColorFormat.is() )
     160           2 :         m_xColorFormat.set( new ScVbaColorFormat( getParent(), mxContext, this, m_xShape, ColorFormatType::FILLFORMAT_BACKCOLOR ) );
     161           3 :     return m_xColorFormat;
     162             : }
     163             : 
     164             : uno::Reference< msforms::XColorFormat > SAL_CALL
     165           5 : ScVbaFillFormat::ForeColor() throw (uno::RuntimeException)
     166             : {
     167           5 :     if( !m_xColorFormat.is() )
     168           5 :         m_xColorFormat.set( new ScVbaColorFormat( getParent(), mxContext, this, m_xShape, ColorFormatType::FILLFORMAT_FORECOLOR ) );
     169           5 :     return m_xColorFormat;
     170             : }
     171             : 
     172             : OUString
     173           0 : ScVbaFillFormat::getServiceImplName()
     174             : {
     175           0 :     return OUString("ScVbaFillFormat");
     176             : }
     177             : 
     178             : uno::Sequence< OUString >
     179           0 : ScVbaFillFormat::getServiceNames()
     180             : {
     181           0 :     static uno::Sequence< OUString > aServiceNames;
     182           0 :     if ( aServiceNames.getLength() == 0 )
     183             :     {
     184           0 :         aServiceNames.realloc( 1 );
     185           0 :         aServiceNames[ 0 ] = "ooo.vba.msforms.FillFormat";
     186             :     }
     187           0 :     return aServiceNames;
     188         186 : }
     189             : 
     190             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10