LCOV - code coverage report
Current view: top level - vbahelper/source/vbahelper - vbashape.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 128 330 38.8 %
Date: 2014-11-03 Functions: 30 52 57.7 %
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             : #include <ooo/vba/office/MsoZOrderCmd.hpp>
      20             : #include <ooo/vba/office/MsoScaleFrom.hpp>
      21             : #include <com/sun/star/container/XNamed.hpp>
      22             : #include <com/sun/star/drawing/ConnectorType.hpp>
      23             : #include <com/sun/star/lang/XEventListener.hpp>
      24             : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
      25             : #include <com/sun/star/drawing/XDrawPages.hpp>
      26             : #include <com/sun/star/view/XSelectionSupplier.hpp>
      27             : #include <com/sun/star/lang/XServiceInfo.hpp>
      28             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      29             : #include <com/sun/star/text/TextContentAnchorType.hpp>
      30             : #include <com/sun/star/text/RelOrientation.hpp>
      31             : #include <ooo/vba/word/WdRelativeHorizontalPosition.hpp>
      32             : #include <ooo/vba/word/WdRelativeVerticalPosition.hpp>
      33             : 
      34             : #include <comphelper/processfactory.hxx>
      35             : #include <osl/mutex.hxx>
      36             : #include <vcl/svapp.hxx>
      37             : #include <svx/unopage.hxx>
      38             : #include <svx/unoshape.hxx>
      39             : 
      40             : #include <vbahelper/vbashape.hxx>
      41             : #include <vbahelper/vbatextframe.hxx>
      42             : #include "vbalineformat.hxx"
      43             : #include "vbafillformat.hxx"
      44             : #include "vbapictureformat.hxx"
      45             : #include <vbahelper/vbashaperange.hxx>
      46             : 
      47             : using namespace ::ooo::vba;
      48             : using namespace ::com::sun::star;
      49             : 
      50         100 : ScVbaShape::ScVbaShape( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< drawing::XShape >& xShape, const uno::Reference< drawing::XShapes >& xShapes, const uno::Reference< frame::XModel >& xModel, sal_Int32 nType )
      51             :     throw (lang::IllegalArgumentException, uno::RuntimeException)
      52         100 :     : ScVbaShape_BASE( xParent, xContext ), m_xShape( xShape ), m_xShapes( xShapes ), m_nType( nType ), m_xModel( xModel )
      53             : {
      54         100 :     m_xPropertySet.set( m_xShape, uno::UNO_QUERY_THROW );
      55         100 :     m_pShapeHelper.reset( new ShapeHelper( m_xShape ) );
      56         100 :     addListeners();
      57         100 : }
      58             : 
      59         140 : ScVbaShape::~ScVbaShape()
      60             : {
      61         140 : }
      62             : 
      63             : void SAL_CALL
      64         170 : ScVbaShape::disposing( const lang::EventObject& rEventObject ) throw( uno::RuntimeException, std::exception )
      65             : {
      66             :     try
      67             :     {
      68         170 :     uno::Reference< drawing::XShapes > xShapes( rEventObject.Source, uno::UNO_QUERY );
      69         340 :     uno::Reference< drawing::XShape > xShape( rEventObject.Source, uno::UNO_QUERY );
      70         170 :     if ( xShapes.is() )
      71          70 :         removeShapesListener();
      72         170 :     if ( xShape.is() )
      73         270 :         removeShapeListener();
      74             :     }
      75           0 :     catch( uno::Exception& )
      76             :     {
      77             :     }
      78         170 : }
      79             : 
      80             : 
      81         100 : void ScVbaShape::addListeners()
      82             : {
      83         100 :     uno::Reference< lang::XComponent > xComponent( m_xShape, uno::UNO_QUERY );
      84         100 :     if ( xComponent.is() )
      85         100 :         xComponent->addEventListener( this );
      86             : 
      87         100 :     xComponent.set( m_xShapes, uno::UNO_QUERY );
      88         100 :     if ( xComponent.is() )
      89         100 :         xComponent->addEventListener( this );
      90         100 : }
      91             : 
      92             : void
      93         100 : ScVbaShape::removeShapeListener() throw( uno::RuntimeException )
      94             : {
      95         100 :     if( m_xShape.is() )
      96             :     {
      97         100 :         uno::Reference< lang::XComponent > xComponent( m_xShape, uno::UNO_QUERY_THROW );
      98         100 :         xComponent->removeEventListener( this );
      99             :     }
     100         100 :     m_xShape = NULL;
     101         100 :     m_xPropertySet = NULL;
     102         100 : }
     103             : 
     104             : void
     105          70 : ScVbaShape::removeShapesListener() throw( uno::RuntimeException )
     106             : {
     107          70 :     if( m_xShapes.is() )
     108             :     {
     109          70 :         uno::Reference< lang::XComponent > xComponent( m_xShapes, uno::UNO_QUERY_THROW );
     110          70 :         xComponent->removeEventListener( this );
     111             :     }
     112          70 :     m_xShapes = NULL;
     113          70 : }
     114             : 
     115             : sal_Int32
     116         104 : ScVbaShape::getType( const css::uno::Reference< drawing::XShape > xShape ) throw (uno::RuntimeException)
     117             : {
     118         104 :     OUString sShapeType;
     119         208 :     uno::Reference< drawing::XShapeDescriptor > xShapeDescriptor( xShape, uno::UNO_QUERY_THROW );
     120         104 :     sShapeType = xShapeDescriptor->getShapeType();
     121             :     SAL_INFO("vbahelper", "ScVbaShape::getType: " << sShapeType);
     122             :     // office::MsoShapeType::msoDiagram to "com.sun.star.drawing.GroupShape"
     123         104 :     if( sShapeType == "com.sun.star.drawing.GroupShape" )
     124           0 :         return office::MsoShapeType::msoGroup;
     125         104 :     else if( sShapeType == "com.sun.star.drawing.GraphicObjectShape" )
     126           2 :         return office::MsoShapeType::msoPicture;
     127         102 :     else if( sShapeType == "com.sun.star.drawing.ControlShape" || sShapeType == "FrameShape" )
     128           0 :         return office::MsoShapeType::msoOLEControlObject;
     129             :     // OOo don't support office::MsoShapeType::msoComment as a Shape.
     130         102 :     else if( sShapeType == "com.sun.star.drawing.OLE2Shape" )
     131           0 :         return office::MsoShapeType::msoChart;
     132             :     // Art characters office::MsoShapeType::msoTextEffect, in OOo corresponding to "com.sun.star.drawing.CustomShape"
     133         102 :     else if( sShapeType == "com.sun.star.drawing.ConnectorShape" )
     134             :     {
     135             :         enum drawing::ConnectorType connectorType;
     136           0 :         uno::Reference< beans::XPropertySet > xPropertySet( xShape, uno::UNO_QUERY_THROW );
     137           0 :         xPropertySet->getPropertyValue( "EdgeKind" ) >>= connectorType;
     138           0 :         if( connectorType == drawing::ConnectorType_CURVE )
     139           0 :             return office::MsoShapeType::msoFreeform;
     140           0 :         else if( connectorType == drawing::ConnectorType_LINE )
     141           0 :             return office::MsoShapeType::msoLine;
     142             :         else
     143           0 :             return office::MsoShapeType::msoAutoShape;
     144             :     }
     145         102 :     else if( sShapeType == "com.sun.star.drawing.LineShape" )
     146          26 :         return office::MsoShapeType::msoLine;
     147          76 :     else if( sShapeType == "com.sun.star.drawing.CustomShape" || sShapeType == "com.sun.star.drawing.RectangleShape" )
     148          76 :         return office::MsoShapeType::msoAutoShape;
     149           0 :     else if( sShapeType == "com.sun.star.drawing.TextShape" )
     150           0 :         return office::MsoShapeType::msoTextBox;
     151             :     else
     152         104 :         throw uno::RuntimeException("the shape type do not be supported: " + sShapeType );
     153             : }
     154             : 
     155             : // Attributes
     156             : OUString SAL_CALL
     157          18 : ScVbaShape::getName() throw (uno::RuntimeException, std::exception)
     158             : {
     159          18 :     OUString sName;
     160          36 :     uno::Reference< container::XNamed > xNamed( m_xShape, uno::UNO_QUERY_THROW );
     161          18 :     sName = xNamed->getName();
     162          36 :     return sName;
     163             : }
     164             : 
     165             : void SAL_CALL
     166           0 : ScVbaShape::setName( const OUString& _name ) throw (uno::RuntimeException, std::exception)
     167             : {
     168           0 :     uno::Reference< container::XNamed > xNamed( m_xShape, uno::UNO_QUERY_THROW );
     169           0 :     xNamed->setName( _name );
     170           0 : }
     171             : 
     172             : OUString SAL_CALL
     173           0 : ScVbaShape::getAlternativeText() throw (uno::RuntimeException, std::exception)
     174             : {
     175           0 :     OUString sAltText;
     176           0 :     uno::Reference< beans::XPropertySet > xProps( m_xShape, uno::UNO_QUERY_THROW );
     177           0 :     xProps->getPropertyValue("Title") >>= sAltText;
     178           0 :     return sAltText;
     179             : }
     180             : 
     181             : void SAL_CALL
     182           0 : ScVbaShape::setAlternativeText( const OUString& sAltText ) throw (uno::RuntimeException, std::exception)
     183             : {
     184           0 :     uno::Reference< beans::XPropertySet > xProps( m_xShape, uno::UNO_QUERY_THROW );
     185           0 :     xProps->setPropertyValue("Title", uno::Any( sAltText ) );
     186           0 : }
     187             : 
     188             : double SAL_CALL
     189           4 : ScVbaShape::getHeight() throw (uno::RuntimeException, std::exception)
     190             : {
     191           4 :     return m_pShapeHelper->getHeight();
     192             : }
     193             : 
     194             : void SAL_CALL
     195           2 : ScVbaShape::setHeight(double _height)
     196             :     throw (uno::RuntimeException, std::exception)
     197             : {
     198           2 :     m_pShapeHelper->setHeight( _height );
     199           2 : }
     200             : 
     201             : double SAL_CALL
     202           4 : ScVbaShape::getWidth() throw (uno::RuntimeException, std::exception)
     203             : {
     204           4 :     return m_pShapeHelper->getWidth();
     205             : }
     206             : 
     207             : void SAL_CALL
     208           2 : ScVbaShape::setWidth(double _width)
     209             :     throw (uno::RuntimeException, std::exception)
     210             : {
     211           2 :     m_pShapeHelper->setWidth( _width );
     212           2 : }
     213             : 
     214             : double SAL_CALL
     215          22 : ScVbaShape::getLeft() throw (uno::RuntimeException, std::exception)
     216             : {
     217          22 :     double left = 0;
     218             :     try
     219             :     {
     220          22 :         left = m_pShapeHelper->getLeft();
     221             :     }
     222           0 :     catch( uno::Exception& )
     223             :     {
     224             :         // fail to get position by using XShape::getPosition()
     225           0 :         sal_Int32 nLeft = 0;
     226           0 :         m_xPropertySet->getPropertyValue( "HoriOrientPosition" ) >>= nLeft;
     227           0 :         left = Millimeter::getInPoints( nLeft );
     228             :     }
     229          22 :     return left;
     230             : }
     231             : 
     232             : void SAL_CALL
     233           8 : ScVbaShape::setLeft( double _left ) throw (uno::RuntimeException, std::exception)
     234             : {
     235             :     try
     236             :     {
     237           8 :         m_pShapeHelper->setLeft( _left );
     238             :     }
     239           0 :     catch( uno::Exception& )
     240             :     {
     241           0 :         sal_Int32 nLeft = 0;
     242           0 :         nLeft = Millimeter::getInHundredthsOfOneMillimeter( _left );
     243           0 :         m_xPropertySet->setPropertyValue( "HoriOrientPosition" , uno::makeAny( nLeft ) );
     244             :     }
     245           8 : }
     246             : 
     247             : double SAL_CALL
     248          22 : ScVbaShape::getTop() throw (uno::RuntimeException, std::exception)
     249             : {
     250          22 :     double top = 0;
     251             :     try
     252             :     {
     253          22 :         top = m_pShapeHelper->getTop();
     254             :     }
     255           0 :     catch( uno::Exception& )
     256             :     {
     257           0 :         sal_Int32 nTop = 0;
     258           0 :         m_xPropertySet->getPropertyValue( "VertOrientPosition" ) >>= nTop;
     259           0 :         top = Millimeter::getInPoints( nTop );
     260             :     }
     261          22 :     return top;
     262             : }
     263             : 
     264             : void SAL_CALL
     265           8 : ScVbaShape::setTop( double _top ) throw (uno::RuntimeException, std::exception)
     266             : {
     267             :     try
     268             :     {
     269           8 :         m_pShapeHelper->setTop( _top );
     270             :     }
     271           0 :     catch( uno::Exception& )
     272             :     {
     273           0 :         sal_Int32 nTop = 0;
     274           0 :         nTop = Millimeter::getInHundredthsOfOneMillimeter( _top );
     275           0 :         m_xPropertySet->setPropertyValue( "VertOrientPosition" , uno::makeAny( nTop ) );
     276             :     }
     277           8 : }
     278             : 
     279             : sal_Bool SAL_CALL
     280           4 : ScVbaShape::getVisible() throw (uno::RuntimeException, std::exception)
     281             : {
     282             :     // #STUB
     283             :     //UNO Shapes are always visible
     284           4 :     return sal_True;
     285             : }
     286             : 
     287             : void SAL_CALL
     288           0 : ScVbaShape::setVisible( sal_Bool /*_visible*/ ) throw (uno::RuntimeException, std::exception)
     289             : {
     290             :     // #STUB
     291             :     //UNO Shapes are always visible
     292           0 : }
     293             : 
     294             : sal_Int32 SAL_CALL
     295           0 : ScVbaShape::getZOrderPosition() throw (uno::RuntimeException, std::exception)
     296             : {
     297           0 :     sal_Int32 nZOrderPosition = 0;
     298           0 :     uno::Any aZOrderPosition =  m_xPropertySet->getPropertyValue( "ZOrder" );
     299           0 :     aZOrderPosition >>= nZOrderPosition;
     300           0 :     return nZOrderPosition + 1;
     301             : }
     302             : 
     303             : sal_Int32 SAL_CALL
     304           0 : ScVbaShape::getType() throw (uno::RuntimeException, std::exception)
     305             : {
     306           0 :     return m_nType;
     307             : }
     308             : 
     309             : double SAL_CALL
     310          24 : ScVbaShape::getRotation() throw (uno::RuntimeException, std::exception)
     311             : {
     312          24 :     double dRotation = 0;
     313          24 :     sal_Int32 nRotation = 0;
     314          24 :     m_xPropertySet->getPropertyValue( "RotateAngle" ) >>= nRotation;
     315          24 :     dRotation = static_cast< double >( nRotation /100 );
     316          24 :     return dRotation;
     317             : }
     318             : 
     319             : void SAL_CALL
     320           8 : ScVbaShape::setRotation( double _rotation ) throw (uno::RuntimeException, std::exception)
     321             : {
     322           8 :     sal_Int32 nRotation = static_cast < sal_Int32 > ( _rotation * 100 );
     323           8 :     m_xPropertySet->setPropertyValue( "RotateAngle" , uno::makeAny( nRotation ) );
     324           8 : }
     325             : 
     326             : uno::Reference< msforms::XLineFormat > SAL_CALL
     327          24 : ScVbaShape::getLine() throw (uno::RuntimeException, std::exception)
     328             : {
     329             :     // TODO should ongly return line
     330          24 :     return uno::Reference< msforms::XLineFormat >( new ScVbaLineFormat( this, mxContext, m_xShape ) );
     331             : }
     332             : 
     333             : uno::Reference< msforms::XFillFormat > SAL_CALL
     334          22 : ScVbaShape::getFill() throw (uno::RuntimeException, std::exception)
     335             : {
     336          22 :     return uno::Reference< msforms::XFillFormat >( new ScVbaFillFormat( this, mxContext, m_xShape ) );
     337             : }
     338             : 
     339             : uno::Reference<  msforms::XPictureFormat > SAL_CALL
     340           4 : ScVbaShape::getPictureFormat() throw (uno::RuntimeException, std::exception)
     341             : {
     342           4 :     return uno::Reference< msforms::XPictureFormat >( new ScVbaPictureFormat( this, mxContext, m_xShape ) );
     343             : }
     344             : 
     345             : // Methods
     346             : uno::Any SAL_CALL
     347           6 : ScVbaShape::TextFrame() throw (uno::RuntimeException, std::exception)
     348             : {
     349           6 :     uno::Reference< lang::XServiceInfo > xServiceInfo( m_xModel, uno::UNO_QUERY_THROW );
     350           6 :     if( xServiceInfo->supportsService( "com.sun.star.sheet.SpreadsheetDocument" ) )
     351             :     {
     352           6 :         uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
     353          12 :         uno::Sequence< uno::Any > aArgs(2);
     354           6 :         aArgs[0] = uno::makeAny( getParent() );
     355           6 :         aArgs[1] <<= m_xShape;
     356          12 :         uno::Reference< uno::XInterface > xTextFrame = xContext->getServiceManager()->createInstanceWithArgumentsAndContext( "ooo.vba.excel.TextFrame" , aArgs, xContext );
     357          12 :         return uno::makeAny( xTextFrame );
     358             :     }
     359             : 
     360           0 :     return uno::makeAny( uno::Reference< msforms::XTextFrame >( new VbaTextFrame( this, mxContext, m_xShape ) ) );
     361             : }
     362             : 
     363             : void SAL_CALL
     364           0 : ScVbaShape::Delete() throw (uno::RuntimeException, std::exception)
     365             : {
     366           0 :     SolarMutexGuard aGuard;
     367           0 :     m_xShapes->remove( m_xShape );
     368           0 : }
     369             : 
     370             : void SAL_CALL
     371           0 : ScVbaShape::ZOrder( sal_Int32 ZOrderCmd ) throw (uno::RuntimeException, std::exception)
     372             : {
     373             :     sal_Int32 nOrderPositon;
     374           0 :     uno::Any aOrderPostion = m_xPropertySet->getPropertyValue( "ZOrder" );
     375           0 :     aOrderPostion >>= nOrderPositon;
     376           0 :     switch( ZOrderCmd )
     377             :     {
     378             :     case office::MsoZOrderCmd::msoBringToFront:
     379           0 :         m_xPropertySet->setPropertyValue( "ZOrder" , uno::makeAny( SAL_MAX_INT32 ) );
     380           0 :         break;
     381             :     case office::MsoZOrderCmd::msoSendToBack:
     382           0 :         m_xPropertySet->setPropertyValue( "ZOrder" , uno::makeAny( (sal_Int32)0 ) );
     383           0 :         break;
     384             :     case office::MsoZOrderCmd::msoBringForward:
     385           0 :         nOrderPositon += 1;
     386           0 :         m_xPropertySet->setPropertyValue( "ZOrder" , uno::makeAny( nOrderPositon ) );
     387           0 :         break;
     388             :     case office::MsoZOrderCmd::msoSendBackward:
     389           0 :         if( nOrderPositon > 0 )
     390             :         {
     391           0 :             nOrderPositon -= 1;
     392           0 :             m_xPropertySet->setPropertyValue( "ZOrder" , uno::makeAny( nOrderPositon ) );
     393             :         }
     394           0 :         break;
     395             :     // below two commands use with Writer for text and image object.
     396             :     case office::MsoZOrderCmd::msoBringInFrontOfText:
     397             :     case office::MsoZOrderCmd::msoSendBehindText:
     398           0 :         throw uno::RuntimeException( "This ZOrderCmd is not implemented, it is use with writer." );
     399             :     default:
     400           0 :         throw uno::RuntimeException( "Invalid Parameter." );
     401           0 :     }
     402           0 : }
     403             : 
     404             : void SAL_CALL
     405           6 : ScVbaShape::IncrementRotation( double Increment ) throw (uno::RuntimeException, std::exception)
     406             : {
     407           6 :     double nCurrentRotation = getRotation();
     408           6 :     nCurrentRotation += Increment;
     409           6 :     setRotation(nCurrentRotation);
     410           6 : }
     411             : 
     412             : void SAL_CALL
     413           6 : ScVbaShape::IncrementLeft( double Increment ) throw (uno::RuntimeException, std::exception)
     414             : {
     415           6 :     double nCurrentLeft = getLeft();
     416           6 :     nCurrentLeft += Increment;
     417           6 :     setLeft(nCurrentLeft);
     418           6 : }
     419             : 
     420             : void SAL_CALL
     421           6 : ScVbaShape::IncrementTop( double Increment ) throw (uno::RuntimeException, std::exception)
     422             : {
     423           6 :     double nCurrentTop = getTop();
     424           6 :     nCurrentTop += Increment;
     425           6 :     setTop(nCurrentTop);
     426           6 : }
     427             : 
     428             : void SAL_CALL
     429           0 : ScVbaShape::ScaleHeight( double Factor, sal_Bool /*RelativeToOriginalSize*/, sal_Int32 Scale ) throw (uno::RuntimeException, std::exception)
     430             : {
     431           0 :     double nHeight = getHeight();
     432           0 :     double nNewHeight = nHeight * Factor;
     433           0 :     if( Scale == office::MsoScaleFrom::msoScaleFromTopLeft )
     434             :     {
     435           0 :         setHeight(nNewHeight);
     436             :     }
     437           0 :     else if( Scale == office::MsoScaleFrom::msoScaleFromBottomRight )
     438             :     {
     439           0 :         double nDeltaHeight = nNewHeight - nHeight;
     440           0 :         double nNewTop = getTop() - nDeltaHeight;
     441           0 :         setTop(nNewTop);
     442           0 :         setHeight(nNewHeight);
     443             :     }
     444           0 :     else if( Scale == office::MsoScaleFrom::msoScaleFromMiddle )
     445             :     {
     446           0 :         double nDeltaHeight = (nNewHeight - nHeight) / 2;
     447           0 :         double nNewTop = getTop() - nDeltaHeight;
     448           0 :         setTop(nNewTop);
     449           0 :         setHeight(nNewHeight);
     450             :     }
     451             :     else
     452             :     {
     453           0 :         throw uno::RuntimeException( "ScaleHeight.Scale wrong value is given." );
     454             :     }
     455           0 : }
     456             : 
     457             : void SAL_CALL
     458           0 : ScVbaShape::ScaleWidth( double Factor, sal_Bool /*RelativeToOriginalSize*/, sal_Int32 Scale ) throw (uno::RuntimeException, std::exception)
     459             : {
     460           0 :     double nWidth = getWidth();
     461           0 :     double nNewWidth = nWidth * Factor;
     462           0 :     if( Scale == office::MsoScaleFrom::msoScaleFromTopLeft )
     463             :     {
     464           0 :         setWidth(nNewWidth);
     465             :     }
     466           0 :     else if( Scale == office::MsoScaleFrom::msoScaleFromBottomRight )
     467             :     {
     468           0 :         double nDeltaWidth = nNewWidth - nWidth;
     469           0 :         double nNewLeft = getLeft() - nDeltaWidth;
     470           0 :         setLeft(nNewLeft);
     471           0 :         setWidth(nNewWidth);
     472             :     }
     473           0 :     else if( Scale == office::MsoScaleFrom::msoScaleFromMiddle )
     474             :     {
     475           0 :         double nDeltaWidth = (nNewWidth - nWidth) / 2;
     476           0 :         double nNewLeft = getLeft() - nDeltaWidth;
     477           0 :         setLeft(nNewLeft);
     478           0 :         setWidth(nNewWidth);
     479             :     }
     480             :     else
     481             :     {
     482           0 :         throw uno::RuntimeException( "ScaleHeight.Scale wrong value is given." );
     483             :     }
     484           0 : }
     485             : 
     486             : void SAL_CALL
     487           2 : ScVbaShape::Select( const uno::Any& /*Replace*/ ) throw ( uno::RuntimeException, std::exception )
     488             : {
     489           2 :     uno::Reference< view::XSelectionSupplier > xSelectSupp( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW );
     490           2 :     xSelectSupp->select( uno::makeAny( m_xShape ) );
     491           2 : }
     492             : 
     493             : // This method should not be part of Shape, what we reall need to do is...
     494             : // dynamically create the appropriate objects e.g. TextBox, Oval, Picture etc.
     495             : // ( e.g. the ones that really do have ShapeRange as an attribute )
     496             : uno::Any SAL_CALL
     497           0 : ScVbaShape::ShapeRange( const uno::Any& index ) throw ( uno::RuntimeException, std::exception )
     498             : {
     499             :     // perhaps we should store a reference to the Shapes Collection
     500             :     // in this class
     501             :     // but anyway this method should not even be in this class
     502             :     // #TODO not sure what the parent of the Shapes collection should be
     503             : 
     504           0 :     XNamedObjectCollectionHelper< drawing::XShape >::XNamedVec aVec;
     505           0 :     aVec.push_back( m_xShape );
     506           0 :     uno::Reference< container::XIndexAccess > xIndexAccess( new XNamedObjectCollectionHelper< drawing::XShape >( aVec ) );
     507           0 :     uno::Reference< container::XChild > xChild( m_xShape, uno::UNO_QUERY_THROW );
     508             :     // #FIXME for want of a better parent, setting this
     509           0 :     uno::Reference< msforms::XShapeRange > xShapeRange( new ScVbaShapeRange( mxParent, mxContext, xIndexAccess,  uno::Reference< drawing::XDrawPage >( xChild->getParent(), uno::UNO_QUERY_THROW ), m_xModel ) );
     510           0 :     if ( index.hasValue() )
     511           0 :         return xShapeRange->Item( index, uno::Any() );
     512           0 :     return uno::makeAny( xShapeRange );
     513             : }
     514             : 
     515             : sal_Bool SAL_CALL
     516           0 : ScVbaShape::getLockAspectRatio() throw (uno::RuntimeException, std::exception)
     517             : {
     518             :     // #STUB
     519           0 :     return sal_False;
     520             : }
     521             : 
     522             : void SAL_CALL
     523           0 : ScVbaShape::setLockAspectRatio( sal_Bool /*_lockaspectratio*/ ) throw (uno::RuntimeException, std::exception)
     524             : {
     525             :     // #STUB
     526           0 : }
     527             : 
     528             : sal_Bool SAL_CALL
     529           0 : ScVbaShape::getLockAnchor() throw (uno::RuntimeException, std::exception)
     530             : {
     531             :     // #STUB
     532           0 :     return sal_True;
     533             : }
     534             : 
     535             : void SAL_CALL
     536           0 : ScVbaShape::setLockAnchor( sal_Bool /*_lockanchor*/ ) throw (uno::RuntimeException, std::exception)
     537             : {
     538             :     // #STUB
     539           0 : }
     540             : 
     541             : sal_Int32 SAL_CALL
     542           0 : ScVbaShape::getRelativeHorizontalPosition() throw (uno::RuntimeException, std::exception)
     543             : {
     544           0 :     sal_Int32 nRelativeHorizontalPosition = word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionMargin;
     545           0 :     sal_Int16 nType = text::RelOrientation::PAGE_LEFT;
     546           0 :     m_xPropertySet->getPropertyValue( "HoriOrientRelation" ) >>= nType;
     547             : 
     548           0 :     switch( nType )
     549             :     {
     550             :         case text::RelOrientation::FRAME:
     551             :         {
     552           0 :             nRelativeHorizontalPosition = word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionColumn;
     553           0 :             break;
     554             :         }
     555             :         case text::RelOrientation::PAGE_FRAME:
     556             :         {
     557           0 :             nRelativeHorizontalPosition = word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionPage;
     558           0 :             break;
     559             :         }
     560             :         case text::RelOrientation::CHAR:
     561             :         {
     562           0 :             nRelativeHorizontalPosition = word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionCharacter;
     563           0 :             break;
     564             :         }
     565             :         case text::RelOrientation::PAGE_PRINT_AREA:
     566             :         {
     567           0 :             nRelativeHorizontalPosition = word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionMargin;
     568           0 :             break;
     569             :         }
     570             :         default:
     571             :         {
     572           0 :             throw  uno::RuntimeException( "Shape::RelativeHorizontalPosition: not implemented" );
     573             :         }
     574             :     }
     575           0 :     return nRelativeHorizontalPosition;
     576             : }
     577             : 
     578             : void SAL_CALL
     579           0 : ScVbaShape::setRelativeHorizontalPosition(::sal_Int32 _relativehorizontalposition)
     580             :     throw (uno::RuntimeException, std::exception)
     581             : {
     582           0 :     sal_Int16 nType = text::RelOrientation::PAGE_FRAME;
     583           0 :     switch( _relativehorizontalposition )
     584             :     {
     585             :         case word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionCharacter:
     586             :         {
     587           0 :             nType = text::RelOrientation::CHAR;
     588           0 :             break;
     589             :         }
     590             :         case word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionColumn:
     591             :         {
     592           0 :             nType = text::RelOrientation::PAGE_FRAME;
     593           0 :             break;
     594             :         }
     595             :         case word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionMargin:
     596             :         {
     597           0 :             nType = text::RelOrientation::PAGE_PRINT_AREA;
     598           0 :             break;
     599             :         }
     600             :         case word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionPage:
     601             :         {
     602           0 :             nType = text::RelOrientation::PAGE_FRAME;
     603           0 :             break;
     604             :         }
     605             :         default:
     606             :         {
     607           0 :             DebugHelper::runtimeexception(SbERR_BAD_ARGUMENT, OUString());
     608             :         }
     609             :     }
     610           0 :     m_xPropertySet->setPropertyValue( "HoriOrientRelation" , uno::makeAny( nType ) );
     611           0 : }
     612             : 
     613             : sal_Int32 SAL_CALL
     614           0 : ScVbaShape::getRelativeVerticalPosition() throw (uno::RuntimeException, std::exception)
     615             : {
     616           0 :     sal_Int32 nRelativeVerticalPosition = word::WdRelativeVerticalPosition::wdRelativeVerticalPositionMargin;
     617           0 :     sal_Int16 nType = text::RelOrientation::PAGE_FRAME;
     618           0 :     m_xPropertySet->getPropertyValue( "VertOrientRelation" ) >>= nType;
     619             : 
     620           0 :     switch( nType )
     621             :     {
     622             :         case text::RelOrientation::FRAME:
     623             :         {
     624           0 :             nRelativeVerticalPosition = word::WdRelativeVerticalPosition::wdRelativeVerticalPositionParagraph;
     625           0 :             break;
     626             :         }
     627             :         case text::RelOrientation::PAGE_FRAME:
     628             :         {
     629           0 :             nRelativeVerticalPosition = word::WdRelativeVerticalPosition::wdRelativeVerticalPositionPage;
     630           0 :             break;
     631             :         }
     632             :         case text::RelOrientation::TEXT_LINE:
     633             :         {
     634           0 :             nRelativeVerticalPosition = word::WdRelativeVerticalPosition::wdRelativeVerticalPositionLine;
     635           0 :             break;
     636             :         }
     637             :         case text::RelOrientation::PAGE_PRINT_AREA:
     638             :         {
     639           0 :             nRelativeVerticalPosition = word::WdRelativeVerticalPosition::wdRelativeVerticalPositionMargin;
     640           0 :             break;
     641             :         }
     642             :         default:
     643             :         {
     644           0 :             throw  uno::RuntimeException( "Shape::RelativeVerticalPosition: not implemented" );
     645             :         }
     646             :     }
     647           0 :     return nRelativeVerticalPosition;
     648             : }
     649             : 
     650             : void SAL_CALL
     651           0 : ScVbaShape::setRelativeVerticalPosition(::sal_Int32 _relativeverticalposition)
     652             :     throw (uno::RuntimeException, std::exception)
     653             : {
     654           0 :     sal_Int16 nType = text::RelOrientation::PAGE_FRAME;
     655           0 :     switch( _relativeverticalposition )
     656             :     {
     657             :         case word::WdRelativeVerticalPosition::wdRelativeVerticalPositionLine:
     658             :         {
     659           0 :             nType = text::RelOrientation::TEXT_LINE;
     660           0 :             break;
     661             :         }
     662             :         case word::WdRelativeVerticalPosition::wdRelativeVerticalPositionParagraph:
     663             :         {
     664           0 :             nType = text::RelOrientation::FRAME;
     665           0 :             break;
     666             :         }
     667             :         case word::WdRelativeVerticalPosition::wdRelativeVerticalPositionMargin:
     668             :         {
     669           0 :             nType = text::RelOrientation::PAGE_PRINT_AREA;
     670           0 :             break;
     671             :         }
     672             :         case word::WdRelativeVerticalPosition::wdRelativeVerticalPositionPage:
     673             :         {
     674           0 :             nType = text::RelOrientation::PAGE_FRAME;
     675           0 :             break;
     676             :         }
     677             :         default:
     678             :         {
     679           0 :             DebugHelper::runtimeexception(SbERR_BAD_ARGUMENT, OUString());
     680             :         }
     681             :     }
     682           0 :     m_xPropertySet->setPropertyValue( "VertOrientRelation" , uno::makeAny( nType ) );
     683           0 : }
     684             : 
     685             : uno::Any SAL_CALL
     686           0 : ScVbaShape::WrapFormat() throw (uno::RuntimeException, std::exception)
     687             : {
     688           0 :     uno::Reference< lang::XServiceInfo > xServiceInfo( m_xModel, uno::UNO_QUERY_THROW );
     689           0 :     if( xServiceInfo->supportsService( "com.sun.star.text.TextDocument" ))
     690             :     {
     691           0 :         uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
     692           0 :         uno::Sequence< uno::Any > aArgs(2);
     693           0 :         aArgs[0] = uno::makeAny( getParent() );
     694           0 :         aArgs[1] <<= m_xShape;
     695           0 :         uno::Reference< uno::XInterface > xWrapFormat = xContext->getServiceManager()->createInstanceWithArgumentsAndContext( "ooo.vba.word.WrapFormat" , aArgs, xContext );
     696           0 :         return uno::makeAny( xWrapFormat );
     697             :     }
     698           0 :     throw uno::RuntimeException( "Not implemented" );
     699             : }
     700             : 
     701             : OUString
     702           0 : ScVbaShape::getServiceImplName()
     703             : {
     704           0 :     return OUString("ScVbaShape");
     705             : }
     706             : 
     707             : uno::Sequence< OUString >
     708           0 : ScVbaShape::getServiceNames()
     709             : {
     710           0 :     static uno::Sequence< OUString > aServiceNames;
     711           0 :     if ( aServiceNames.getLength() == 0 )
     712             :     {
     713           0 :         aServiceNames.realloc( 1 );
     714           0 :         aServiceNames[ 0 ] = "ooo.vba.msform.Shape";
     715             :     }
     716           0 :     return aServiceNames;
     717         480 : }
     718             : 
     719             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10