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

Generated by: LCOV version 1.10