LCOV - code coverage report
Current view: top level - vbahelper/source/msforms - vbanewfont.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 56 0.0 %
Date: 2014-04-14 Functions: 0 19 0.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             : 
      20             : #include <rtl/tencinfo.h>
      21             : #include <vbanewfont.hxx>
      22             : #include <com/sun/star/awt/FontWeight.hpp>
      23             : #include <com/sun/star/awt/FontSlant.hpp>
      24             : #include <com/sun/star/awt/FontStrikeout.hpp>
      25             : #include <com/sun/star/awt/FontUnderline.hpp>
      26             : 
      27             : using namespace ::com::sun::star;
      28             : using namespace ::ooo::vba;
      29             : 
      30             : 
      31             : 
      32           0 : VbaNewFont::VbaNewFont(
      33             :         const uno::Reference< XHelperInterface >& rxParent,
      34             :         const uno::Reference< uno::XComponentContext >& rxContext,
      35             :         const uno::Reference< beans::XPropertySet >& rxModelProps ) throw (uno::RuntimeException) :
      36             :     VbaNewFont_BASE( rxParent, rxContext ),
      37           0 :     mxProps( rxModelProps, uno::UNO_SET_THROW )
      38             : {
      39           0 : }
      40             : 
      41             : // XNewFont attributes
      42             : 
      43           0 : OUString SAL_CALL VbaNewFont::getName() throw (uno::RuntimeException, std::exception)
      44             : {
      45           0 :     uno::Any aAny = mxProps->getPropertyValue( "FontName" );
      46           0 :     return aAny.get< OUString >();
      47             : }
      48             : 
      49           0 : void SAL_CALL VbaNewFont::setName( const OUString& rName ) throw (uno::RuntimeException, std::exception)
      50             : {
      51           0 :     mxProps->setPropertyValue( "FontName" , uno::Any( rName ) );
      52           0 : }
      53             : 
      54           0 : double SAL_CALL VbaNewFont::getSize() throw (uno::RuntimeException, std::exception)
      55             : {
      56           0 :     uno::Any aAny = mxProps->getPropertyValue( "FontHeight" );
      57           0 :     return aAny.get< float >();
      58             : }
      59             : 
      60           0 : void SAL_CALL VbaNewFont::setSize( double fSize ) throw (uno::RuntimeException, std::exception)
      61             : {
      62           0 :     mxProps->setPropertyValue( "FontHeight" , uno::Any( static_cast< float >( fSize ) ) );
      63           0 : }
      64             : 
      65           0 : sal_Int16 SAL_CALL VbaNewFont::getCharset() throw (uno::RuntimeException, std::exception)
      66             : {
      67           0 :     uno::Any aAny = mxProps->getPropertyValue( "FontCharset" );
      68           0 :     return rtl_getBestWindowsCharsetFromTextEncoding( static_cast< rtl_TextEncoding >( aAny.get< sal_Int16 >() ) );
      69             : }
      70             : 
      71           0 : void SAL_CALL VbaNewFont::setCharset( sal_Int16 nCharset ) throw (uno::RuntimeException, std::exception)
      72             : {
      73           0 :     rtl_TextEncoding eFontEnc = RTL_TEXTENCODING_DONTKNOW;
      74           0 :     if( (0 <= nCharset) && (nCharset <= SAL_MAX_UINT8) )
      75           0 :         eFontEnc = rtl_getTextEncodingFromWindowsCharset( static_cast< sal_uInt8 >( nCharset ) );
      76           0 :     if( eFontEnc == RTL_TEXTENCODING_DONTKNOW )
      77           0 :         throw uno::RuntimeException();
      78           0 :     mxProps->setPropertyValue( "FontCharset" , uno::Any( static_cast< sal_Int16 >( eFontEnc ) ) );
      79           0 : }
      80             : 
      81           0 : sal_Int16 SAL_CALL VbaNewFont::getWeight() throw (uno::RuntimeException, std::exception)
      82             : {
      83           0 :     return getBold() ? 700 : 400;
      84             : }
      85             : 
      86           0 : void SAL_CALL VbaNewFont::setWeight( sal_Int16 nWeight ) throw (uno::RuntimeException, std::exception)
      87             : {
      88           0 :     setBold( nWeight >= 700 );
      89           0 : }
      90             : 
      91           0 : sal_Bool SAL_CALL VbaNewFont::getBold() throw (uno::RuntimeException, std::exception)
      92             : {
      93           0 :     uno::Any aAny = mxProps->getPropertyValue( "FontWeight" );
      94           0 :     return aAny.get< float >() > awt::FontWeight::NORMAL;
      95             : }
      96             : 
      97           0 : void SAL_CALL VbaNewFont::setBold( sal_Bool bBold ) throw (uno::RuntimeException, std::exception)
      98             : {
      99           0 :     mxProps->setPropertyValue( "FontWeight" , uno::Any( bBold ? awt::FontWeight::BOLD : awt::FontWeight::NORMAL ) );
     100           0 : }
     101             : 
     102           0 : sal_Bool SAL_CALL VbaNewFont::getItalic() throw (uno::RuntimeException, std::exception)
     103             : {
     104           0 :     uno::Any aAny = mxProps->getPropertyValue( "FontSlant" );
     105           0 :     return aAny.get< awt::FontSlant >() != awt::FontSlant_NONE;
     106             : }
     107             : 
     108           0 : void SAL_CALL VbaNewFont::setItalic( sal_Bool bItalic ) throw (uno::RuntimeException, std::exception)
     109             : {
     110           0 :     mxProps->setPropertyValue( "FontSlant" , uno::Any( bItalic ? awt::FontSlant_ITALIC : awt::FontSlant_NONE ) );
     111           0 : }
     112             : 
     113           0 : sal_Bool SAL_CALL VbaNewFont::getUnderline() throw (uno::RuntimeException, std::exception)
     114             : {
     115           0 :     uno::Any aAny = mxProps->getPropertyValue("FontUnderline" );
     116           0 :     return aAny.get< sal_Int16 >() != awt::FontUnderline::NONE;
     117             : }
     118             : 
     119           0 : void SAL_CALL VbaNewFont::setUnderline( sal_Bool bUnderline ) throw (uno::RuntimeException, std::exception)
     120             : {
     121           0 :     mxProps->setPropertyValue("FontUnderline" , uno::Any( bUnderline ? awt::FontUnderline::SINGLE : awt::FontUnderline::NONE ) );
     122           0 : }
     123             : 
     124           0 : sal_Bool SAL_CALL VbaNewFont::getStrikethrough() throw (uno::RuntimeException, std::exception)
     125             : {
     126           0 :     uno::Any aAny = mxProps->getPropertyValue( "FontStrikeout" );
     127           0 :     return aAny.get< sal_Int16 >() != awt::FontStrikeout::NONE;
     128             : }
     129             : 
     130           0 : void SAL_CALL VbaNewFont::setStrikethrough( sal_Bool bStrikethrough ) throw (uno::RuntimeException, std::exception)
     131             : {
     132           0 :     mxProps->setPropertyValue( "FontStrikeout" ,uno::Any( bStrikethrough ? awt::FontStrikeout::SINGLE : awt::FontStrikeout::NONE ) );
     133           0 : }
     134             : 
     135             : // XHelperInterface
     136             : 
     137           0 : VBAHELPER_IMPL_XHELPERINTERFACE( VbaNewFont, "ooo.vba.msforms.NewFont" )
     138             : 
     139             : 
     140             : 
     141             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10