LCOV - code coverage report
Current view: top level - vbahelper/source/msforms - vbatextbox.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 44 79 55.7 %
Date: 2015-06-13 12:38:46 Functions: 9 23 39.1 %
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          33 : 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          33 : }
      32             : 
      33             : // Attributes
      34             : uno::Any SAL_CALL
      35          16 : ScVbaTextBox::getValue() throw (css::uno::RuntimeException, std::exception)
      36             : {
      37          16 :     return uno::makeAny( getText() );
      38             : }
      39             : 
      40             : void SAL_CALL
      41           6 : ScVbaTextBox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeException, std::exception)
      42             : {
      43             :     // booleans are converted to uppercase strings
      44           6 :     OUString sVal = extractStringFromAny( _value, true );
      45           6 :     setText( sVal );
      46           6 : }
      47             : 
      48             : //getString() will cause some imfo lose.
      49             : OUString SAL_CALL
      50          22 : ScVbaTextBox::getText() throw (css::uno::RuntimeException, std::exception)
      51             : {
      52          22 :     uno::Any aValue;
      53          22 :     aValue = m_xProps->getPropertyValue( "Text" );
      54          22 :     OUString sString;
      55          22 :     aValue >>= sString;
      56          22 :     return sString;
      57             : }
      58             : 
      59             : void SAL_CALL
      60           6 : ScVbaTextBox::setText( const OUString& _text ) throw (css::uno::RuntimeException, std::exception)
      61             : {
      62           6 :     OUString oldText( getText() );
      63           6 :     if ( !mbDialog )
      64             :     {
      65           3 :         uno::Reference< text::XTextRange > xTextRange( m_xProps, uno::UNO_QUERY_THROW );
      66           3 :         xTextRange->setString( _text );
      67             :     }
      68             :     else
      69           3 :         m_xProps->setPropertyValue( "Text" , uno::makeAny( _text ) );
      70           6 :     if ( oldText != _text )
      71           6 :         fireChangeEvent();
      72           6 : }
      73             : 
      74             : sal_Int32 SAL_CALL
      75           4 : ScVbaTextBox::getMaxLength() throw (css::uno::RuntimeException, std::exception)
      76             : {
      77           4 :     uno::Any aValue;
      78           4 :     aValue = m_xProps->getPropertyValue( "MaxTextLen" );
      79           4 :     sal_Int16 nMaxLength = 0;
      80           4 :     aValue >>= nMaxLength;
      81           4 :     return (sal_Int32)nMaxLength;
      82             : }
      83             : 
      84             : void SAL_CALL
      85           4 : ScVbaTextBox::setMaxLength( sal_Int32 _maxlength ) throw (css::uno::RuntimeException, std::exception)
      86             : {
      87           4 :     sal_Int16 nTmp( _maxlength );
      88           4 :     uno::Any aValue( nTmp );
      89           4 :     m_xProps->setPropertyValue( "MaxTextLen" , aValue);
      90           4 : }
      91             : 
      92             : sal_Bool SAL_CALL
      93           4 : ScVbaTextBox::getMultiline() throw (css::uno::RuntimeException, std::exception)
      94             : {
      95           4 :     uno::Any aValue;
      96           4 :     aValue = m_xProps->getPropertyValue( "MultiLine" );
      97           4 :     bool bRet = false;
      98           4 :     aValue >>= bRet;
      99           4 :     return bRet;
     100             : }
     101             : 
     102             : void SAL_CALL
     103           4 : ScVbaTextBox::setMultiline( sal_Bool _multiline ) throw (css::uno::RuntimeException, std::exception)
     104             : {
     105           4 :     uno::Any aValue( _multiline );
     106           4 :     m_xProps->setPropertyValue( "MultiLine" , aValue);
     107           4 : }
     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             : }
     186             : 
     187             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11