LCOV - code coverage report
Current view: top level - sc/source/ui/vba - vbasheetobject.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 216 0.5 %
Date: 2014-11-03 Functions: 2 61 3.3 %
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 "vbasheetobject.hxx"
      21             : #include <com/sun/star/awt/TextAlign.hpp>
      22             : #include <com/sun/star/container/XIndexContainer.hpp>
      23             : #include <com/sun/star/drawing/XControlShape.hpp>
      24             : #include <com/sun/star/script/ScriptEventDescriptor.hpp>
      25             : #include <com/sun/star/script/XEventAttacherManager.hpp>
      26             : #include <com/sun/star/style/VerticalAlignment.hpp>
      27             : #include <ooo/vba/excel/Constants.hpp>
      28             : #include <ooo/vba/excel/XlOrientation.hpp>
      29             : #include <ooo/vba/excel/XlPlacement.hpp>
      30             : #include <rtl/ustrbuf.hxx>
      31             : #include <filter/msfilter/msvbahelper.hxx>
      32             : #include <svx/unoshape.hxx>
      33             : #include "vbafont.hxx"
      34             : #include "drwlayer.hxx"
      35             : 
      36             : using namespace ::com::sun::star;
      37             : using namespace ::ooo::vba;
      38             : 
      39           0 : ScVbaButtonCharacters::ScVbaButtonCharacters(
      40             :         const uno::Reference< XHelperInterface >& rxParent,
      41             :         const uno::Reference< uno::XComponentContext >& rxContext,
      42             :         const uno::Reference< beans::XPropertySet >& rxPropSet,
      43             :         const ScVbaPalette& rPalette,
      44             :         const uno::Any& rStart,
      45             :         const uno::Any& rLength ) throw (uno::RuntimeException) :
      46             :     ScVbaButtonCharacters_BASE( rxParent, rxContext ),
      47             :     maPalette( rPalette ),
      48           0 :     mxPropSet( rxPropSet, uno::UNO_SET_THROW )
      49             : {
      50             :     // extract optional start parameter (missing or invalid -> from beginning)
      51           0 :     if( !(rStart >>= mnStart) || (mnStart < 1) )
      52           0 :         mnStart = 1;
      53           0 :     --mnStart;  // VBA is 1-based, rtl string is 0-based
      54             : 
      55             :     // extract optional length parameter (missing or invalid -> to end)
      56           0 :     if( !(rLength >>= mnLength) || (mnLength < 1) )
      57           0 :         mnLength = SAL_MAX_INT32;
      58           0 : }
      59             : 
      60           0 : ScVbaButtonCharacters::~ScVbaButtonCharacters()
      61             : {
      62           0 : }
      63             : 
      64             : // XCharacters attributes
      65             : 
      66           0 : OUString SAL_CALL ScVbaButtonCharacters::getCaption() throw (uno::RuntimeException, std::exception)
      67             : {
      68             :     // ignore invalid mnStart and/or mnLength members
      69           0 :     OUString aString = getFullString();
      70           0 :     sal_Int32 nStart = ::std::min( mnStart, aString.getLength() );
      71           0 :     sal_Int32 nLength = ::std::min( mnLength, aString.getLength() - nStart );
      72           0 :     return aString.copy( nStart, nLength );
      73             : }
      74             : 
      75           0 : void SAL_CALL ScVbaButtonCharacters::setCaption( const OUString& rCaption ) throw (uno::RuntimeException, std::exception)
      76             : {
      77             :     /*  Replace the covered text with the passed text, ignore invalid mnStart
      78             :         and/or mnLength members. This operation does not affect the mnLength
      79             :         parameter. If the inserted text is longer than mnLength, the additional
      80             :         characters are not covered by this object. If the inserted text is
      81             :         shorter than mnLength, other uncovered characters from the original
      82             :         string will be covered now, thus may be changed with subsequent
      83             :         operations. */
      84           0 :     OUString aString = getFullString();
      85           0 :     sal_Int32 nStart = ::std::min( mnStart, aString.getLength() );
      86           0 :     sal_Int32 nLength = ::std::min( mnLength, aString.getLength() - nStart );
      87           0 :     setFullString( aString.replaceAt( nStart, nLength, rCaption ) );
      88           0 : }
      89             : 
      90           0 : sal_Int32 SAL_CALL ScVbaButtonCharacters::getCount() throw (uno::RuntimeException, std::exception)
      91             : {
      92             :     // always return the total length of the caption
      93           0 :     return getFullString().getLength();
      94             : }
      95             : 
      96           0 : OUString SAL_CALL ScVbaButtonCharacters::getText() throw (uno::RuntimeException, std::exception)
      97             : {
      98             :     // Text attribute same as Caption attribute?
      99           0 :     return getCaption();
     100             : }
     101             : 
     102           0 : void SAL_CALL ScVbaButtonCharacters::setText( const OUString& rText ) throw (uno::RuntimeException, std::exception)
     103             : {
     104             :     // Text attribute same as Caption attribute?
     105           0 :     setCaption( rText );
     106           0 : }
     107             : 
     108           0 : uno::Reference< excel::XFont > SAL_CALL ScVbaButtonCharacters::getFont() throw (uno::RuntimeException, std::exception)
     109             : {
     110           0 :     return new ScVbaFont( this, mxContext, maPalette, mxPropSet, 0, true );
     111             : }
     112             : 
     113           0 : void SAL_CALL ScVbaButtonCharacters::setFont( const uno::Reference< excel::XFont >& /*rxFont*/ ) throw (uno::RuntimeException, std::exception)
     114             : {
     115             :     // TODO
     116           0 : }
     117             : 
     118             : // XCharacters methods
     119             : 
     120           0 : void SAL_CALL ScVbaButtonCharacters::Insert( const OUString& rString ) throw (uno::RuntimeException, std::exception)
     121             : {
     122             :     /*  The Insert() operation is in fact "replace covered characters", at
     123             :         least for buttons... It seems there is no easy way to really insert a
     124             :         substring. This operation does not affect the mnLength parameter. */
     125           0 :     setCaption( rString );
     126           0 : }
     127             : 
     128           0 : void SAL_CALL ScVbaButtonCharacters::Delete() throw (uno::RuntimeException, std::exception)
     129             : {
     130             :     /*  The Delete() operation is nothing else than "replace with empty string".
     131             :         This does not affect the mnLength parameter, multiple calls of Delete()
     132             :         will remove characters as long as there are some more covered by this
     133             :         object. */
     134           0 :     setCaption( OUString() );
     135           0 : }
     136             : 
     137             : // XHelperInterface
     138             : 
     139           0 : VBAHELPER_IMPL_XHELPERINTERFACE( ScVbaButtonCharacters, "ooo.vba.excel.Characters" )
     140             : 
     141             : // private
     142             : 
     143           0 : OUString ScVbaButtonCharacters::getFullString() const throw (uno::RuntimeException)
     144             : {
     145           0 :     return mxPropSet->getPropertyValue( "Label" ).get< OUString >();
     146             : }
     147             : 
     148           0 : void ScVbaButtonCharacters::setFullString( const OUString& rString ) throw (uno::RuntimeException)
     149             : {
     150           0 :     mxPropSet->setPropertyValue( "Label", uno::Any( rString ) );
     151           0 : }
     152             : 
     153           0 : ScVbaSheetObjectBase::ScVbaSheetObjectBase(
     154             :         const uno::Reference< XHelperInterface >& rxParent,
     155             :         const uno::Reference< uno::XComponentContext >& rxContext,
     156             :         const uno::Reference< frame::XModel >& rxModel,
     157             :         const uno::Reference< drawing::XShape >& rxShape ) throw (uno::RuntimeException) :
     158             :     ScVbaSheetObject_BASE( rxParent, rxContext ),
     159             :     maPalette( rxModel ),
     160             :     mxModel( rxModel, uno::UNO_SET_THROW ),
     161             :     mxShape( rxShape, uno::UNO_SET_THROW ),
     162           0 :     mxShapeProps( rxShape, uno::UNO_QUERY_THROW )
     163             : {
     164           0 : }
     165             : 
     166             : // XSheetObject attributes
     167             : 
     168           0 : double SAL_CALL ScVbaSheetObjectBase::getLeft() throw (uno::RuntimeException, std::exception)
     169             : {
     170           0 :     return HmmToPoints( mxShape->getPosition().X );
     171             : }
     172             : 
     173           0 : void SAL_CALL ScVbaSheetObjectBase::setLeft( double fLeft ) throw (uno::RuntimeException, std::exception)
     174             : {
     175           0 :     if( fLeft < 0.0 )
     176           0 :         throw uno::RuntimeException();
     177           0 :     mxShape->setPosition( awt::Point( PointsToHmm( fLeft ), mxShape->getPosition().Y ) );
     178           0 : }
     179             : 
     180           0 : double SAL_CALL ScVbaSheetObjectBase::getTop() throw (uno::RuntimeException, std::exception)
     181             : {
     182           0 :     return HmmToPoints( mxShape->getPosition().Y );
     183             : }
     184             : 
     185           0 : void SAL_CALL ScVbaSheetObjectBase::setTop( double fTop ) throw (uno::RuntimeException, std::exception)
     186             : {
     187           0 :     if( fTop < 0.0 )
     188           0 :         throw uno::RuntimeException();
     189           0 :     mxShape->setPosition( awt::Point( mxShape->getPosition().X, PointsToHmm( fTop ) ) );
     190           0 : }
     191             : 
     192           0 : double SAL_CALL ScVbaSheetObjectBase::getWidth() throw (uno::RuntimeException, std::exception)
     193             : {
     194           0 :     return HmmToPoints( mxShape->getSize().Width );
     195             : }
     196             : 
     197           0 : void SAL_CALL ScVbaSheetObjectBase::setWidth( double fWidth ) throw (uno::RuntimeException, std::exception)
     198             : {
     199           0 :     if( fWidth <= 0.0 )
     200           0 :         throw uno::RuntimeException();
     201           0 :     mxShape->setSize( awt::Size( PointsToHmm( fWidth ), mxShape->getSize().Height ) );
     202           0 : }
     203             : 
     204           0 : double SAL_CALL ScVbaSheetObjectBase::getHeight() throw (uno::RuntimeException, std::exception)
     205             : {
     206           0 :     return HmmToPoints( mxShape->getSize().Height );
     207             : }
     208             : 
     209           0 : void SAL_CALL ScVbaSheetObjectBase::setHeight( double fHeight ) throw (uno::RuntimeException, std::exception)
     210             : {
     211           0 :     if( fHeight <= 0.0 )
     212           0 :         throw uno::RuntimeException();
     213           0 :     mxShape->setSize( awt::Size( mxShape->getSize().Width, PointsToHmm( fHeight ) ) );
     214           0 : }
     215             : 
     216           0 : OUString SAL_CALL ScVbaSheetObjectBase::getName() throw (uno::RuntimeException, std::exception)
     217             : {
     218           0 :     return mxShapeProps->getPropertyValue( "Name" ).get< OUString >();
     219             : }
     220             : 
     221           0 : void SAL_CALL ScVbaSheetObjectBase::setName( const OUString& rName ) throw (uno::RuntimeException, std::exception)
     222             : {
     223           0 :     mxShapeProps->setPropertyValue( "Name", uno::Any( rName ) );
     224           0 : }
     225             : 
     226           0 : sal_Int32 SAL_CALL ScVbaSheetObjectBase::getPlacement() throw (uno::RuntimeException, std::exception)
     227             : {
     228           0 :     sal_Int32 nRet = excel::XlPlacement::xlMoveAndSize;
     229             : #if 0 // TODO: not working at the moment.
     230             :     SvxShape* pShape = SvxShape::getImplementation( mxShape );
     231             :     if(pShape)
     232             :     {
     233             :         SdrObject* pObj = pShape->GetSdrObject();
     234             :         if (pObj)
     235             :         {
     236             :             ScAnchorType eType = ScDrawLayer::GetAnchor(pObj);
     237             :             if (eType == SCA_PAGE)
     238             :                 nRet = excel::XlPlacement::xlFreeFloating;
     239             :         }
     240             :     }
     241             : #endif
     242           0 :     return nRet;
     243             : }
     244             : 
     245           0 : void SAL_CALL ScVbaSheetObjectBase::setPlacement( sal_Int32 /*nPlacement*/ ) throw (uno::RuntimeException, std::exception)
     246             : {
     247             : #if 0 // TODO: not working at the moment.
     248             :     SvxShape* pShape = SvxShape::getImplementation( mxShape );
     249             :     if(pShape)
     250             :     {
     251             :         SdrObject* pObj = pShape->GetSdrObject();
     252             :         if (pObj)
     253             :         {
     254             :             ScAnchorType eType = SCA_CELL;
     255             :             if ( nPlacement == excel::XlPlacement::xlFreeFloating )
     256             :                 eType = SCA_PAGE;
     257             : 
     258             :             // xlMove is not supported, treated as SCA_CELL (xlMoveAndSize)
     259             : 
     260             :             ScDrawLayer::SetAnchor(pObj, eType);
     261             :         }
     262             :     }
     263             : #endif
     264           0 : }
     265             : 
     266           0 : sal_Bool SAL_CALL ScVbaSheetObjectBase::getPrintObject() throw (uno::RuntimeException, std::exception)
     267             : {
     268             :     // not supported
     269           0 :     return sal_True;
     270             : }
     271             : 
     272           0 : void SAL_CALL ScVbaSheetObjectBase::setPrintObject( sal_Bool /*bPrintObject*/ ) throw (uno::RuntimeException, std::exception)
     273             : {
     274             :     // not supported
     275           0 : }
     276             : 
     277             : // private
     278             : 
     279           0 : void ScVbaSheetObjectBase::setDefaultProperties( sal_Int32 nIndex ) throw (uno::RuntimeException)
     280             : {
     281           0 :     OUString aName = OUStringBuffer( implGetBaseName() ).append( ' ' ).append( nIndex + 1 ).makeStringAndClear();
     282           0 :     setName( aName );
     283           0 :     implSetDefaultProperties();
     284           0 : }
     285             : 
     286           0 : void ScVbaSheetObjectBase::implSetDefaultProperties() throw (uno::RuntimeException)
     287             : {
     288           0 : }
     289             : 
     290           0 : ScVbaControlObjectBase::ScVbaControlObjectBase(
     291             :         const uno::Reference< XHelperInterface >& rxParent,
     292             :         const uno::Reference< uno::XComponentContext >& rxContext,
     293             :         const uno::Reference< frame::XModel >& rxModel,
     294             :         const uno::Reference< container::XIndexContainer >& rxFormIC,
     295             :         const uno::Reference< drawing::XControlShape >& rxControlShape,
     296             :         ListenerType eListenerType ) throw (uno::RuntimeException) :
     297             :     ScVbaControlObject_BASE( rxParent, rxContext, rxModel, uno::Reference< drawing::XShape >( rxControlShape, uno::UNO_QUERY_THROW ) ),
     298             :     mxFormIC( rxFormIC, uno::UNO_SET_THROW ),
     299           0 :     mxControlProps( rxControlShape->getControl(), uno::UNO_QUERY_THROW )
     300             : {
     301             :     // set listener and event name to be used for OnAction attribute
     302           0 :     switch( eListenerType )
     303             :     {
     304             :         case LISTENER_ACTION:
     305           0 :             maListenerType = "XActionListener";
     306           0 :             maEventMethod = "actionPerformed";
     307           0 :         break;
     308             :         case LISTENER_MOUSE:
     309           0 :             maListenerType = "XMouseListener";
     310           0 :             maEventMethod = "mouseReleased";
     311           0 :         break;
     312             :         case LISTENER_TEXT:
     313           0 :             maListenerType = "XTextListener";
     314           0 :             maEventMethod = "textChanged";
     315           0 :         break;
     316             :         case LISTENER_VALUE:
     317           0 :             maListenerType = "XAdjustmentListener";
     318           0 :             maEventMethod = "adjustmentValueChanged";
     319           0 :         break;
     320             :         case LISTENER_CHANGE:
     321           0 :             maListenerType = "XChangeListener";
     322           0 :             maEventMethod = "changed";
     323           0 :         break;
     324             :         // no default, to let the compiler complain about missing case
     325             :     }
     326           0 : }
     327             : 
     328             : // XSheetObject attributes
     329             : 
     330           0 : OUString SAL_CALL ScVbaControlObjectBase::getName() throw (uno::RuntimeException, std::exception)
     331             : {
     332           0 :     return mxControlProps->getPropertyValue( "Name" ).get< OUString >();
     333             : }
     334             : 
     335           0 : void SAL_CALL ScVbaControlObjectBase::setName( const OUString& rName ) throw (uno::RuntimeException, std::exception)
     336             : {
     337           0 :     mxControlProps->setPropertyValue( "Name", uno::Any( rName ) );
     338           0 : }
     339             : 
     340           0 : OUString SAL_CALL ScVbaControlObjectBase::getOnAction() throw (uno::RuntimeException, std::exception)
     341             : {
     342           0 :     uno::Reference< script::XEventAttacherManager > xEventMgr( mxFormIC, uno::UNO_QUERY_THROW );
     343           0 :     sal_Int32 nIndex = getModelIndexInForm();
     344           0 :     uno::Sequence< script::ScriptEventDescriptor > aEvents = xEventMgr->getScriptEvents( nIndex );
     345           0 :     if( aEvents.hasElements() )
     346             :     {
     347           0 :         const script::ScriptEventDescriptor* pEvent = aEvents.getConstArray();
     348           0 :         const script::ScriptEventDescriptor* pEventEnd = pEvent + aEvents.getLength();
     349           0 :         const OUString aScriptType = "Script";
     350           0 :         for( ; pEvent < pEventEnd; ++pEvent )
     351           0 :             if( (pEvent->ListenerType == maListenerType) && (pEvent->EventMethod == maEventMethod) && (pEvent->ScriptType == aScriptType) )
     352           0 :                 return extractMacroName( pEvent->ScriptCode );
     353             :     }
     354           0 :     return OUString();
     355             : }
     356             : 
     357           0 : void SAL_CALL ScVbaControlObjectBase::setOnAction( const OUString& rMacroName ) throw (uno::RuntimeException, std::exception)
     358             : {
     359           0 :     uno::Reference< script::XEventAttacherManager > xEventMgr( mxFormIC, uno::UNO_QUERY_THROW );
     360           0 :     sal_Int32 nIndex = getModelIndexInForm();
     361             : 
     362             :     // first, remove a registered event (try/catch just in case implementation throws)
     363           0 :     try { xEventMgr->revokeScriptEvent( nIndex, maListenerType, maEventMethod, OUString() ); } catch( uno::Exception& ) {}
     364             : 
     365             :     // if a macro name has been passed, try to attach it to the event
     366           0 :     if( !rMacroName.isEmpty() )
     367             :     {
     368           0 :         MacroResolvedInfo aResolvedMacro = resolveVBAMacro( getSfxObjShell( mxModel ), rMacroName );
     369           0 :         if( !aResolvedMacro.mbFound )
     370           0 :             throw uno::RuntimeException();
     371           0 :         script::ScriptEventDescriptor aDescriptor;
     372           0 :         aDescriptor.ListenerType = maListenerType;
     373           0 :         aDescriptor.EventMethod = maEventMethod;
     374           0 :         aDescriptor.ScriptType = "Script";
     375           0 :         aDescriptor.ScriptCode = makeMacroURL( aResolvedMacro.msResolvedMacro );
     376           0 :         xEventMgr->registerScriptEvent( nIndex, aDescriptor );
     377           0 :     }
     378           0 : }
     379             : 
     380           0 : sal_Bool SAL_CALL ScVbaControlObjectBase::getPrintObject() throw (uno::RuntimeException, std::exception)
     381             : {
     382           0 :     return mxControlProps->getPropertyValue( "Printable" ).get< sal_Bool >();
     383             : }
     384             : 
     385           0 : void SAL_CALL ScVbaControlObjectBase::setPrintObject( sal_Bool bPrintObject ) throw (uno::RuntimeException, std::exception)
     386             : {
     387           0 :     mxControlProps->setPropertyValue( "Printable", uno::Any( bPrintObject ) );
     388           0 : }
     389             : 
     390             : // XControlObject attributes
     391             : 
     392           0 : sal_Bool SAL_CALL ScVbaControlObjectBase::getAutoSize() throw (uno::RuntimeException, std::exception)
     393             : {
     394             :     // not supported
     395           0 :     return false;
     396             : }
     397             : 
     398           0 : void SAL_CALL ScVbaControlObjectBase::setAutoSize( sal_Bool /*bAutoSize*/ ) throw (uno::RuntimeException, std::exception)
     399             : {
     400             :     // not supported
     401           0 : }
     402             : 
     403             : // private
     404             : 
     405           0 : sal_Int32 ScVbaControlObjectBase::getModelIndexInForm() const throw (uno::RuntimeException)
     406             : {
     407           0 :     for( sal_Int32 nIndex = 0, nCount = mxFormIC->getCount(); nIndex < nCount; ++nIndex )
     408             :     {
     409           0 :         uno::Reference< beans::XPropertySet > xProps( mxFormIC->getByIndex( nIndex ), uno::UNO_QUERY_THROW );
     410           0 :         if( mxControlProps.get() == xProps.get() )
     411           0 :             return nIndex;
     412           0 :     }
     413           0 :     throw uno::RuntimeException();
     414             : }
     415             : 
     416           0 : ScVbaButton::ScVbaButton(
     417             :         const uno::Reference< XHelperInterface >& rxParent,
     418             :         const uno::Reference< uno::XComponentContext >& rxContext,
     419             :         const uno::Reference< frame::XModel >& rxModel,
     420             :         const uno::Reference< container::XIndexContainer >& rxFormIC,
     421             :         const uno::Reference< drawing::XControlShape >& rxControlShape ) throw (uno::RuntimeException) :
     422           0 :     ScVbaButton_BASE( rxParent, rxContext, rxModel, rxFormIC, rxControlShape, LISTENER_ACTION )
     423             : {
     424           0 : }
     425             : 
     426             : // XButton attributes
     427             : 
     428           0 : OUString SAL_CALL ScVbaButton::getCaption() throw (uno::RuntimeException, std::exception)
     429             : {
     430           0 :     return mxControlProps->getPropertyValue( "Label" ).get< OUString >();
     431             : }
     432             : 
     433           0 : void SAL_CALL ScVbaButton::setCaption( const OUString& rCaption ) throw (uno::RuntimeException, std::exception)
     434             : {
     435           0 :     mxControlProps->setPropertyValue( "Label", uno::Any( rCaption ) );
     436           0 : }
     437             : 
     438           0 : uno::Reference< excel::XFont > SAL_CALL ScVbaButton::getFont() throw (uno::RuntimeException, std::exception)
     439             : {
     440           0 :     return new ScVbaFont( this, mxContext, maPalette, mxControlProps, 0, true );
     441             : }
     442             : 
     443           0 : void SAL_CALL ScVbaButton::setFont( const uno::Reference< excel::XFont >& /*rxFont*/ ) throw (uno::RuntimeException, std::exception)
     444             : {
     445             :     // TODO
     446           0 : }
     447             : 
     448           0 : sal_Int32 SAL_CALL ScVbaButton::getHorizontalAlignment() throw (uno::RuntimeException, std::exception)
     449             : {
     450           0 :     switch( mxControlProps->getPropertyValue( "Align" ).get< sal_Int16 >() )
     451             :     {
     452           0 :         case awt::TextAlign::LEFT:      return excel::Constants::xlLeft;
     453           0 :         case awt::TextAlign::RIGHT:     return excel::Constants::xlRight;
     454           0 :         case awt::TextAlign::CENTER:    return excel::Constants::xlCenter;
     455             :     }
     456           0 :     return excel::Constants::xlCenter;
     457             : }
     458             : 
     459           0 : void SAL_CALL ScVbaButton::setHorizontalAlignment( sal_Int32 nAlign ) throw (uno::RuntimeException, std::exception)
     460             : {
     461           0 :     sal_Int32 nAwtAlign = awt::TextAlign::CENTER;
     462           0 :     switch( nAlign )
     463             :     {
     464           0 :         case excel::Constants::xlLeft:      nAwtAlign = awt::TextAlign::LEFT;   break;
     465           0 :         case excel::Constants::xlRight:     nAwtAlign = awt::TextAlign::RIGHT;  break;
     466           0 :         case excel::Constants::xlCenter:    nAwtAlign = awt::TextAlign::CENTER; break;
     467             :     }
     468             :     // form controls expect short value
     469           0 :     mxControlProps->setPropertyValue( "Align", uno::Any( static_cast< sal_Int16 >( nAwtAlign ) ) );
     470           0 : }
     471             : 
     472           0 : sal_Int32 SAL_CALL ScVbaButton::getVerticalAlignment() throw (uno::RuntimeException, std::exception)
     473             : {
     474           0 :     switch( mxControlProps->getPropertyValue( "VerticalAlign" ).get< style::VerticalAlignment >() )
     475             :     {
     476           0 :         case style::VerticalAlignment_TOP:      return excel::Constants::xlTop;
     477           0 :         case style::VerticalAlignment_BOTTOM:   return excel::Constants::xlBottom;
     478           0 :         case style::VerticalAlignment_MIDDLE:   return excel::Constants::xlCenter;
     479             :         default:;
     480             :     }
     481           0 :     return excel::Constants::xlCenter;
     482             : }
     483             : 
     484           0 : void SAL_CALL ScVbaButton::setVerticalAlignment( sal_Int32 nAlign ) throw (uno::RuntimeException, std::exception)
     485             : {
     486           0 :     style::VerticalAlignment eAwtAlign = style::VerticalAlignment_MIDDLE;
     487           0 :     switch( nAlign )
     488             :     {
     489           0 :         case excel::Constants::xlTop:       eAwtAlign = style::VerticalAlignment_TOP;       break;
     490           0 :         case excel::Constants::xlBottom:    eAwtAlign = style::VerticalAlignment_BOTTOM;    break;
     491           0 :         case excel::Constants::xlCenter:    eAwtAlign = style::VerticalAlignment_MIDDLE;    break;
     492             :     }
     493           0 :     mxControlProps->setPropertyValue( "VerticalAlign", uno::Any( eAwtAlign ) );
     494           0 : }
     495             : 
     496           0 : sal_Int32 SAL_CALL ScVbaButton::getOrientation() throw (uno::RuntimeException, std::exception)
     497             : {
     498             :     // not supported
     499           0 :     return excel::XlOrientation::xlHorizontal;
     500             : }
     501             : 
     502           0 : void SAL_CALL ScVbaButton::setOrientation( sal_Int32 /*nOrientation*/ ) throw (uno::RuntimeException, std::exception)
     503             : {
     504             :     // not supported
     505           0 : }
     506             : 
     507             : // XButton methods
     508             : 
     509           0 : uno::Reference< excel::XCharacters > SAL_CALL ScVbaButton::Characters( const uno::Any& rStart, const uno::Any& rLength ) throw (uno::RuntimeException, std::exception)
     510             : {
     511           0 :     return new ScVbaButtonCharacters( this, mxContext, mxControlProps, maPalette, rStart, rLength );
     512             : }
     513             : 
     514             : // XHelperInterface
     515             : 
     516           0 : VBAHELPER_IMPL_XHELPERINTERFACE( ScVbaButton, "ooo.vba.excel.Button" )
     517             : 
     518             : // private
     519             : 
     520           0 : OUString ScVbaButton::implGetBaseName() const
     521             : {
     522           0 :     return OUString( "Button" );
     523             : }
     524             : 
     525           0 : void ScVbaButton::implSetDefaultProperties() throw (uno::RuntimeException)
     526             : {
     527           0 :     setCaption( getName() );
     528          12 : }
     529             : 
     530             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10