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

Generated by: LCOV version 1.10