LCOV - code coverage report
Current view: top level - vbahelper/source/msforms - vbatextbox.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 45 80 56.2 %
Date: 2014-11-03 Functions: 11 25 44.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 "vbatextbox.hxx"
      21             : #include "vbanewfont.hxx"
      22             : #include <com/sun/star/text/XTextRange.hpp>
      23             : #include <ooo/vba/msforms/fmBorderStyle.hpp>
      24             : #include <ooo/vba/msforms/fmSpecialEffect.hpp>
      25             : 
      26             : using namespace com::sun::star;
      27             : using namespace ooo::vba;
      28             : 
      29          66 : ScVbaTextBox::ScVbaTextBox( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper, bool bDialog ) : TextBoxImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ), mbDialog( bDialog )
      30             : {
      31          66 : }
      32             : 
      33             : // Attributes
      34             : uno::Any SAL_CALL
      35          32 : ScVbaTextBox::getValue() throw (css::uno::RuntimeException, std::exception)
      36             : {
      37          32 :     return uno::makeAny( getText() );
      38             : }
      39             : 
      40             : void SAL_CALL
      41          12 : ScVbaTextBox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeException, std::exception)
      42             : {
      43             :     // booleans are converted to uppercase strings
      44          12 :     OUString sVal = extractStringFromAny( _value, true );
      45          12 :     setText( sVal );
      46          12 : }
      47             : 
      48             : //getString() will cause some imfo lose.
      49             : OUString SAL_CALL
      50          44 : ScVbaTextBox::getText() throw (css::uno::RuntimeException, std::exception)
      51             : {
      52          44 :     uno::Any aValue;
      53          44 :     aValue = m_xProps->getPropertyValue( "Text" );
      54          44 :     OUString sString;
      55          44 :     aValue >>= sString;
      56          44 :     return sString;
      57             : }
      58             : 
      59             : void SAL_CALL
      60          12 : ScVbaTextBox::setText( const OUString& _text ) throw (css::uno::RuntimeException, std::exception)
      61             : {
      62          12 :     OUString oldText( getText() );
      63          12 :     if ( !mbDialog )
      64             :     {
      65           6 :         uno::Reference< text::XTextRange > xTextRange( m_xProps, uno::UNO_QUERY_THROW );
      66           6 :         xTextRange->setString( _text );
      67             :     }
      68             :     else
      69           6 :         m_xProps->setPropertyValue( "Text" , uno::makeAny( _text ) );
      70          12 :     if ( oldText != _text )
      71          12 :         fireChangeEvent();
      72          12 : }
      73             : 
      74             : sal_Int32 SAL_CALL
      75           8 : ScVbaTextBox::getMaxLength() throw (css::uno::RuntimeException, std::exception)
      76             : {
      77           8 :     uno::Any aValue;
      78           8 :     aValue = m_xProps->getPropertyValue( "MaxTextLen" );
      79           8 :     sal_Int16 nMaxLength = 0;
      80           8 :     aValue >>= nMaxLength;
      81           8 :     return (sal_Int32)nMaxLength;
      82             : }
      83             : 
      84             : void SAL_CALL
      85           8 : ScVbaTextBox::setMaxLength( sal_Int32 _maxlength ) throw (css::uno::RuntimeException, std::exception)
      86             : {
      87           8 :     sal_Int16 nTmp( _maxlength );
      88           8 :     uno::Any aValue( nTmp );
      89           8 :     m_xProps->setPropertyValue( "MaxTextLen" , aValue);
      90           8 : }
      91             : 
      92             : sal_Bool SAL_CALL
      93           8 : ScVbaTextBox::getMultiline() throw (css::uno::RuntimeException, std::exception)
      94             : {
      95           8 :     uno::Any aValue;
      96           8 :     aValue = m_xProps->getPropertyValue( "MultiLine" );
      97           8 :     bool bRet = false;
      98           8 :     aValue >>= bRet;
      99           8 :     return bRet;
     100             : }
     101             : 
     102             : void SAL_CALL
     103           8 : ScVbaTextBox::setMultiline( sal_Bool _multiline ) throw (css::uno::RuntimeException, std::exception)
     104             : {
     105           8 :     uno::Any aValue( _multiline );
     106           8 :     m_xProps->setPropertyValue( "MultiLine" , aValue);
     107           8 : }
     108             : 
     109           0 : sal_Int32 SAL_CALL ScVbaTextBox::getSpecialEffect() throw (uno::RuntimeException, std::exception)
     110             : {
     111           0 :     return msforms::fmSpecialEffect::fmSpecialEffectSunken;
     112             : }
     113             : 
     114           0 : void SAL_CALL ScVbaTextBox::setSpecialEffect( sal_Int32 /*nSpecialEffect*/ ) throw (uno::RuntimeException, std::exception)
     115             : {
     116             :     // #STUB
     117           0 : }
     118             : 
     119           0 : sal_Int32 SAL_CALL ScVbaTextBox::getBorderStyle() throw (uno::RuntimeException, std::exception)
     120             : {
     121           0 :     return msforms::fmBorderStyle::fmBorderStyleNone;
     122             : }
     123             : 
     124           0 : void SAL_CALL ScVbaTextBox::setBorderStyle( sal_Int32 /*nBorderStyle*/ ) throw (uno::RuntimeException, std::exception)
     125             : {
     126             :     // #STUB
     127           0 : }
     128             : 
     129           0 : sal_Int32 SAL_CALL ScVbaTextBox::getTextLength() throw (uno::RuntimeException, std::exception)
     130             : {
     131           0 :     return getText().getLength();
     132             : }
     133             : 
     134           0 : uno::Reference< msforms::XNewFont > SAL_CALL ScVbaTextBox::getFont() throw (uno::RuntimeException, std::exception)
     135             : {
     136           0 :     return new VbaNewFont( m_xProps );
     137             : }
     138             : 
     139           0 : sal_Int32 SAL_CALL ScVbaTextBox::getBackColor() throw (uno::RuntimeException, std::exception)
     140             : {
     141           0 :     return ScVbaControl::getBackColor();
     142             : }
     143             : 
     144           0 : void SAL_CALL ScVbaTextBox::setBackColor( sal_Int32 nBackColor ) throw (uno::RuntimeException, std::exception)
     145             : {
     146           0 :     ScVbaControl::setBackColor( nBackColor );
     147           0 : }
     148             : 
     149           0 : sal_Bool SAL_CALL ScVbaTextBox::getAutoSize() throw (uno::RuntimeException, std::exception)
     150             : {
     151           0 :     return ScVbaControl::getAutoSize();
     152             : }
     153             : 
     154           0 : void SAL_CALL ScVbaTextBox::setAutoSize( sal_Bool bAutoSize ) throw (uno::RuntimeException, std::exception)
     155             : {
     156           0 :     ScVbaControl::setAutoSize( bAutoSize );
     157           0 : }
     158             : 
     159           0 : sal_Bool SAL_CALL ScVbaTextBox::getLocked() throw (uno::RuntimeException, std::exception)
     160             : {
     161           0 :     return ScVbaControl::getLocked();
     162             : }
     163             : 
     164           0 : void SAL_CALL ScVbaTextBox::setLocked( sal_Bool bLocked ) throw (uno::RuntimeException, std::exception)
     165             : {
     166           0 :     ScVbaControl::setLocked( bLocked );
     167           0 : }
     168             : 
     169             : OUString
     170           0 : ScVbaTextBox::getServiceImplName()
     171             : {
     172           0 :     return OUString( "ScVbaTextBox" );
     173             : }
     174             : 
     175             : uno::Sequence< OUString >
     176           0 : ScVbaTextBox::getServiceNames()
     177             : {
     178           0 :     static uno::Sequence< OUString > aServiceNames;
     179           0 :     if ( aServiceNames.getLength() == 0 )
     180             :     {
     181           0 :         aServiceNames.realloc( 1 );
     182           0 :         aServiceNames[ 0 ] = "ooo.vba.msforms.TextBox";
     183             :     }
     184           0 :     return aServiceNames;
     185           6 : }
     186             : 
     187             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10