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

Generated by: LCOV version 1.10