LCOV - code coverage report
Current view: top level - vbahelper/source/vbahelper - vbashapes.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 131 217 60.4 %
Date: 2014-11-03 Functions: 16 28 57.1 %
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 <com/sun/star/container/XNamed.hpp>
      20             : #include <com/sun/star/view/XSelectionSupplier.hpp>
      21             : #include <com/sun/star/text/WrapTextMode.hpp>
      22             : #include <ooo/vba/msforms/XShapeRange.hpp>
      23             : #include <ooo/vba/office/MsoAutoShapeType.hpp>
      24             : #include <ooo/vba/office/MsoTextOrientation.hpp>
      25             : #include <com/sun/star/lang/XServiceInfo.hpp>
      26             : #include <com/sun/star/text/XText.hpp>
      27             : #include <com/sun/star/text/XTextDocument.hpp>
      28             : #include <com/sun/star/text/XTextContent.hpp>
      29             : #include <com/sun/star/text/TextContentAnchorType.hpp>
      30             : #include <com/sun/star/text/HoriOrientation.hpp>
      31             : #include <com/sun/star/text/VertOrientation.hpp>
      32             : #include <com/sun/star/text/RelOrientation.hpp>
      33             : #include <com/sun/star/text/SizeType.hpp>
      34             : #include <com/sun/star/text/WritingMode.hpp>
      35             : #include <com/sun/star/drawing/LineStyle.hpp>
      36             : 
      37             : #include <vbahelper/vbahelper.hxx>
      38             : #include <vbahelper/vbashape.hxx>
      39             : #include <vbahelper/vbashapes.hxx>
      40             : #include <vbahelper/vbashaperange.hxx>
      41             : 
      42             : using namespace ::ooo::vba;
      43             : using namespace ::com::sun::star;
      44             : 
      45           0 : class VbShapeEnumHelper : public EnumerationHelper_BASE
      46             : {
      47             :         uno::Reference<msforms::XShapes > m_xParent;
      48             :         uno::Reference<container::XIndexAccess > m_xIndexAccess;
      49             :         sal_Int32 nIndex;
      50             : public:
      51           0 :     VbShapeEnumHelper( const uno::Reference< msforms::XShapes >& xParent,  const uno::Reference< container::XIndexAccess >& xIndexAccess ) : m_xParent( xParent ), m_xIndexAccess( xIndexAccess ), nIndex( 0 ) {}
      52           0 :         virtual sal_Bool SAL_CALL hasMoreElements(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
      53             :         {
      54           0 :                 return ( nIndex < m_xIndexAccess->getCount() );
      55             :         }
      56           0 :         virtual uno::Any SAL_CALL nextElement(  ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE
      57             :         {
      58           0 :                 ScVbaShapes* pShapes = dynamic_cast< ScVbaShapes* >(m_xParent.get());
      59           0 :                 if ( pShapes && hasMoreElements() )
      60           0 :                     return pShapes->createCollectionObject(  m_xIndexAccess->getByIndex( nIndex++ ) );
      61           0 :                 throw container::NoSuchElementException();
      62             :         }
      63             : 
      64             : };
      65             : 
      66          84 : void ScVbaShapes::initBaseCollection()
      67             : {
      68          84 :     if ( m_xNameAccess.is() ) // already has NameAccess
      69          84 :         return;
      70             :     // no NameAccess then use ShapeCollectionHelper
      71          84 :     XNamedObjectCollectionHelper< drawing::XShape >::XNamedVec mShapes;
      72          84 :     sal_Int32 nLen = m_xIndexAccess->getCount();
      73          84 :     mShapes.reserve( nLen );
      74         348 :     for ( sal_Int32 index=0; index<nLen; ++index )
      75         264 :         mShapes.push_back( uno::Reference< drawing::XShape >( m_xIndexAccess->getByIndex( index ) , uno::UNO_QUERY ) );
      76         168 :     uno::Reference< container::XIndexAccess > xShapes( new XNamedObjectCollectionHelper< drawing::XShape >( mShapes ) );
      77          84 :     m_xIndexAccess.set( xShapes, uno::UNO_QUERY );
      78         168 :     m_xNameAccess.set( xShapes, uno::UNO_QUERY );
      79             : }
      80             : 
      81          84 : ScVbaShapes::ScVbaShapes( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess > xShapes, const uno::Reference< frame::XModel>& xModel ): ScVbaShapes_BASE( xParent, xContext, xShapes, true ), m_nNewShapeCount(0), m_xModel( xModel )
      82             : {
      83          84 :     m_xShapes.set( xShapes, uno::UNO_QUERY_THROW );
      84          84 :     m_xDrawPage.set( xShapes, uno::UNO_QUERY_THROW );
      85          84 :     initBaseCollection();
      86          84 : }
      87             : 
      88             : uno::Reference< container::XEnumeration >
      89           0 : ScVbaShapes::createEnumeration() throw (uno::RuntimeException)
      90             : {
      91           0 :     return new VbShapeEnumHelper( this,  m_xIndexAccess );
      92             : }
      93             : 
      94             : uno::Any
      95          66 : ScVbaShapes::createCollectionObject( const css::uno::Any& aSource ) throw (uno::RuntimeException)
      96             : {
      97          66 :     if( aSource.hasValue() )
      98             :     {
      99          66 :         uno::Reference< drawing::XShape > xShape( aSource, uno::UNO_QUERY_THROW );
     100          66 :         return uno::makeAny( uno::Reference< msforms::XShape >( new ScVbaShape( getParent(), mxContext, xShape, m_xShapes, m_xModel, ScVbaShape::getType( xShape ) ) ) );
     101             :     }
     102           0 :     return uno::Any();
     103             : }
     104             : 
     105             : uno::Type
     106           0 : ScVbaShapes::getElementType() throw (uno::RuntimeException)
     107             : {
     108           0 :     return cppu::UnoType<ooo::vba::msforms::XShape>::get();
     109             : }
     110             : 
     111             : OUString
     112           0 : ScVbaShapes::getServiceImplName()
     113             : {
     114           0 :     return OUString("ScVbaShapes");
     115             : }
     116             : 
     117             : uno::Sequence< OUString >
     118           0 : ScVbaShapes::getServiceNames()
     119             : {
     120           0 :     static uno::Sequence< OUString > aServiceNames;
     121           0 :     if ( aServiceNames.getLength() == 0 )
     122             :     {
     123           0 :         aServiceNames.realloc( 1 );
     124           0 :         aServiceNames[ 0 ] =  "ooo.vba.msform.Shapes";
     125             :     }
     126           0 :     return aServiceNames;
     127             : }
     128             : 
     129             : css::uno::Reference< css::container::XIndexAccess >
     130          12 : ScVbaShapes::getShapesByArrayIndices( const uno::Any& Index  ) throw (uno::RuntimeException)
     131             : {
     132          12 :     if ( Index.getValueTypeClass() != uno::TypeClass_SEQUENCE )
     133           0 :         throw uno::RuntimeException();
     134             : 
     135          12 :     uno::Reference< script::XTypeConverter > xConverter = getTypeConverter(mxContext);
     136          24 :     uno::Any aConverted;
     137          12 :     aConverted = xConverter->convertTo( Index, getCppuType((uno::Sequence< uno::Any >*)0) );
     138             : 
     139          24 :     uno::Sequence< uno::Any > sIndices;
     140          12 :     aConverted >>= sIndices;
     141          24 :     XNamedObjectCollectionHelper< drawing::XShape >::XNamedVec mShapes;
     142          12 :     sal_Int32 nElems = sIndices.getLength();
     143          32 :     for( sal_Int32 index = 0; index < nElems; ++index )
     144             :     {
     145          20 :         uno::Reference< drawing::XShape > xShape;
     146          20 :         if ( sIndices[ index ].getValueTypeClass() == uno::TypeClass_STRING )
     147             :         {
     148           6 :             OUString sName;
     149           6 :             sIndices[ index ] >>= sName;
     150           6 :             xShape.set( m_xNameAccess->getByName( sName ), uno::UNO_QUERY );
     151             :         }
     152             :         else
     153             :         {
     154          14 :             sal_Int32 nIndex = 0;
     155          14 :             sIndices[ index ] >>= nIndex;
     156             :             // adjust for 1 based mso indexing
     157          14 :             xShape.set( m_xIndexAccess->getByIndex( nIndex - 1 ), uno::UNO_QUERY );
     158             : 
     159             :         }
     160             :         // populate map with drawing::XShapes
     161          20 :         if ( xShape.is() )
     162          20 :             mShapes.push_back( xShape );
     163          20 :     }
     164          12 :     uno::Reference< container::XIndexAccess > xIndexAccess( new XNamedObjectCollectionHelper< drawing::XShape >( mShapes ) );
     165          24 :     return xIndexAccess;
     166             : }
     167             : 
     168             : uno::Any SAL_CALL
     169          66 : ScVbaShapes::Item(const uno::Any& Index, const uno::Any& Index2)
     170             :     throw (lang::IndexOutOfBoundsException, script::BasicErrorException, uno::RuntimeException)
     171             : {
     172             :     // I don't think we need to support Array of indices for shapes
     173             : /*
     174             :     if ( Index.getValueTypeClass() == uno::TypeClass_SEQUENCE )
     175             :     {
     176             :         uno::Reference< container::XIndexAccess > xIndexAccess( getShapesByArrayIndices( Index ) );
     177             :         // return new collection instance
     178             :         uno::Reference< XCollection > xShapesCollection(  new ScVbaShapes( this->getParent(), mxContext, xIndexAccess ) );
     179             :         return uno::makeAny( xShapesCollection );
     180             :     }
     181             : */
     182          66 :     return  ScVbaShapes_BASE::Item( Index, Index2 );
     183             : }
     184             : 
     185             : uno::Reference< msforms::XShapeRange > SAL_CALL
     186          12 : ScVbaShapes::Range( const uno::Any& shapes ) throw (css::uno::RuntimeException, std::exception)
     187             : {
     188             :     // shapes, can be an index or an array of indices
     189          12 :     uno::Reference< container::XIndexAccess > xShapes;
     190          12 :     if ( shapes.getValueTypeClass() == uno::TypeClass_SEQUENCE )
     191           6 :         xShapes = getShapesByArrayIndices( shapes );
     192             :     else
     193             :     {
     194             :         // wrap single index into a sequence
     195           6 :         uno::Sequence< uno::Any > sIndices(1);
     196           6 :         sIndices[ 0 ] = shapes;
     197          12 :         uno::Any aIndex;
     198           6 :         aIndex <<= sIndices;
     199          12 :         xShapes = getShapesByArrayIndices( aIndex );
     200             :     }
     201          12 :     return new ScVbaShapeRange(  getParent(), mxContext, xShapes, m_xDrawPage, m_xModel );
     202             : }
     203             : 
     204             : void SAL_CALL
     205           2 : ScVbaShapes::SelectAll() throw (uno::RuntimeException, std::exception)
     206             : {
     207           2 :     uno::Reference< view::XSelectionSupplier > xSelectSupp( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW );
     208             :     try
     209             :     {
     210           4 :         xSelectSupp->select( uno::makeAny( m_xShapes ) );
     211             :     }
     212             :     // viewuno.cxx ScTabViewObj::select will throw IllegalArgumentException
     213             :     // if one of the shapes is no 'markable' e.g. a button
     214             :     // the method still works
     215           2 :     catch(const lang::IllegalArgumentException&)
     216             :     {
     217           2 :     }
     218           2 : }
     219             : 
     220             : uno::Reference< drawing::XShape >
     221           4 : ScVbaShapes::createShape( const OUString& service ) throw (css::uno::RuntimeException)
     222             : {
     223           4 :     uno::Reference< lang::XMultiServiceFactory > xMSF( m_xModel, uno::UNO_QUERY_THROW );
     224           4 :     uno::Reference< drawing::XShape > xShape( xMSF->createInstance( service ), uno::UNO_QUERY_THROW );
     225           4 :     return xShape;
     226             : }
     227             : 
     228             : uno::Any
     229           2 : ScVbaShapes::AddRectangle( sal_Int32 startX, sal_Int32 startY, sal_Int32 nLineWidth, sal_Int32 nLineHeight, uno::Any aRange ) throw (css::uno::RuntimeException)
     230             : {
     231           2 :     OUString sCreateShapeName( "com.sun.star.drawing.RectangleShape" );
     232           2 :     sal_Int32 nXPos = Millimeter::getInHundredthsOfOneMillimeter( startX );
     233           2 :     sal_Int32 nYPos = Millimeter::getInHundredthsOfOneMillimeter( startY );
     234           2 :     sal_Int32 nWidth = Millimeter::getInHundredthsOfOneMillimeter( nLineWidth );
     235           2 :     sal_Int32 nHeight = Millimeter::getInHundredthsOfOneMillimeter( nLineHeight );
     236             : 
     237           4 :     uno::Reference< drawing::XShape > xShape( createShape( sCreateShapeName ), uno::UNO_QUERY_THROW );
     238           2 :     m_xShapes->add( xShape );
     239             : 
     240           4 :     OUString sName(createName( "Rectangle" ));
     241           2 :     setDefaultShapeProperties( xShape );
     242           2 :     setShape_NameProperty( xShape, sName );
     243             : 
     244           2 :     awt::Point aMovePositionIfRange(0, 0);
     245           2 :     awt::Point position;
     246           2 :     position.X = nXPos - aMovePositionIfRange.X;
     247           2 :     position.Y = nYPos - aMovePositionIfRange.Y;
     248           2 :     xShape->setPosition( position );
     249             : 
     250           2 :     awt::Size size;
     251           2 :     size.Height = nHeight;
     252           2 :     size.Width = nWidth;
     253           2 :     xShape->setSize( size );
     254             : 
     255           2 :     ScVbaShape *pScVbaShape = new ScVbaShape( getParent(), mxContext, xShape, m_xShapes, m_xModel, ScVbaShape::getType( xShape ) );
     256           2 :     pScVbaShape->setRange( aRange );
     257           4 :     return uno::makeAny( uno::Reference< msforms::XShape > ( pScVbaShape ) );
     258             : }
     259             : 
     260             : uno::Any
     261           0 : ScVbaShapes::AddEllipse( sal_Int32 startX, sal_Int32 startY, sal_Int32 nLineWidth, sal_Int32 nLineHeight, uno::Any aRange ) throw (css::uno::RuntimeException)
     262             : {
     263           0 :     OUString sCreateShapeName( "com.sun.star.drawing.EllipseShape" );
     264           0 :     sal_Int32 nXPos = Millimeter::getInHundredthsOfOneMillimeter( startX );
     265           0 :     sal_Int32 nYPos = Millimeter::getInHundredthsOfOneMillimeter( startY );
     266           0 :     sal_Int32 nWidth = Millimeter::getInHundredthsOfOneMillimeter( nLineWidth );
     267           0 :     sal_Int32 nHeight = Millimeter::getInHundredthsOfOneMillimeter( nLineHeight );
     268             : 
     269           0 :     uno::Reference< drawing::XShape > xShape( createShape( sCreateShapeName ), uno::UNO_QUERY_THROW );
     270           0 :     m_xShapes->add( xShape );
     271             : 
     272           0 :     awt::Point aMovePositionIfRange( 0, 0 );
     273             :     //TODO helperapi using a writer document
     274             :     /*
     275             :     XDocument xDocument = (XDocument)getParent();
     276             :     if (AnyConverter.isVoid(_aRange))
     277             :     {
     278             :         _aRange = xDocument.Range(new Integer(0), new Integer(1));
     279             :         // Top&Left in Word is Top&Left of the paper and not the writeable area.
     280             :         aMovePositionIfRange = calculateTopLeftMargin((HelperInterfaceAdaptor)xDocument);
     281             :     }
     282             : 
     283             :     setShape_AnchorTypeAndRangeProperty(xShape, _aRange);
     284             :     */
     285           0 :     OUString name(createName( "Oval" ));
     286           0 :     setDefaultShapeProperties(xShape);
     287           0 :     setShape_NameProperty(xShape, name);
     288             : 
     289           0 :     awt::Point position;
     290           0 :     position.X = nXPos - aMovePositionIfRange.X;
     291           0 :     position.Y = nYPos - aMovePositionIfRange.Y;
     292           0 :     xShape->setPosition(position);
     293             : 
     294           0 :     awt::Size size;
     295           0 :     size.Height = nHeight;
     296           0 :     size.Width = nWidth;
     297           0 :     xShape->setSize(size);
     298             : 
     299           0 :     ScVbaShape *pScVbaShape = new ScVbaShape( getParent(), mxContext, xShape, m_xShapes, m_xModel, ScVbaShape::getType( xShape ) );
     300           0 :     pScVbaShape->setRange( aRange );
     301           0 :     return uno::makeAny( uno::Reference< msforms::XShape > ( pScVbaShape ) );
     302             : }
     303             : 
     304             : //helpeapi calc
     305             : uno::Any SAL_CALL
     306           2 : ScVbaShapes::AddLine( sal_Int32 StartX, sal_Int32 StartY, sal_Int32 endX, sal_Int32 endY ) throw (uno::RuntimeException, std::exception)
     307             : {
     308           2 :     sal_Int32 nLineWidth = endX - StartX;
     309           2 :     sal_Int32 nLineHeight = endY - StartY;
     310             : 
     311           2 :     sal_Int32 nHeight = Millimeter::getInHundredthsOfOneMillimeter( nLineHeight );
     312           2 :     sal_Int32 nWidth = Millimeter::getInHundredthsOfOneMillimeter( nLineWidth );
     313           2 :     sal_Int32 nXPos = Millimeter::getInHundredthsOfOneMillimeter( StartX );
     314           2 :     sal_Int32 nYPos = Millimeter::getInHundredthsOfOneMillimeter( StartY );
     315             : 
     316           2 :     uno::Reference< drawing::XShape > xShape( createShape( "com.sun.star.drawing.LineShape" ), uno::UNO_QUERY_THROW );
     317           2 :     m_xShapes->add( xShape );
     318             : 
     319           2 :     awt::Point aMovePositionIfRange( 0, 0 );
     320             : 
     321           4 :     OUString name(createName( "Line" ));
     322           2 :     setDefaultShapeProperties(xShape);
     323           2 :     setShape_NameProperty(xShape, name);
     324             : 
     325           2 :     awt::Point position;
     326           2 :     position.X = nXPos - aMovePositionIfRange.X;
     327           2 :     position.Y = nYPos - aMovePositionIfRange.Y;
     328           2 :     xShape->setPosition(position);
     329             : 
     330           2 :     awt::Size size;
     331           2 :     size.Height = nHeight;
     332           2 :     size.Width = nWidth;
     333           2 :     xShape->setSize(size);
     334             : 
     335           2 :     ScVbaShape *pScVbaShape = new ScVbaShape( getParent(), mxContext, xShape, m_xShapes, m_xModel, ScVbaShape::getType( xShape ) );
     336           4 :     return uno::makeAny( uno::Reference< msforms::XShape > ( pScVbaShape ) );
     337             : }
     338             : 
     339             : uno::Any SAL_CALL
     340           2 : ScVbaShapes::AddShape( sal_Int32 _nType, sal_Int32 _nLeft, sal_Int32 _nTop, sal_Int32 _nWidth, sal_Int32 _nHeight ) throw (uno::RuntimeException, std::exception)
     341             : {
     342           2 :     uno::Any _aAnchor;
     343           2 :     if (_nType == office::MsoAutoShapeType::msoShapeRectangle)
     344             :     {
     345           2 :         return AddRectangle(_nLeft, _nTop, _nWidth, _nHeight, _aAnchor);
     346             :     }
     347           0 :     else if (_nType == office::MsoAutoShapeType::msoShapeOval)
     348             :     {
     349           0 :         return AddEllipse(_nLeft, _nTop, _nWidth, _nHeight, _aAnchor);
     350             :     }
     351           0 :     return uno::Any();
     352             : }
     353             : 
     354             : uno::Any SAL_CALL
     355           0 : ScVbaShapes::AddTextbox( sal_Int32 _nOrientation, sal_Int32 _nLeft, sal_Int32 _nTop, sal_Int32 _nWidth, sal_Int32 _nHeight ) throw (uno::RuntimeException, std::exception)
     356             : {
     357           0 :     uno::Reference< lang::XServiceInfo > xServiceInfo( m_xModel, uno::UNO_QUERY_THROW );
     358           0 :     if( xServiceInfo->supportsService( "com.sun.star.text.TextDocument" ) )
     359             :     {
     360           0 :         return AddTextboxInWriter( _nOrientation, _nLeft, _nTop, _nWidth, _nHeight );
     361             :     }
     362           0 :     throw uno::RuntimeException( "Not implemented" );
     363             : }
     364             : 
     365             : uno::Any
     366           0 : ScVbaShapes::AddTextboxInWriter( sal_Int32 /*_nOrientation*/, sal_Int32 _nLeft, sal_Int32 _nTop, sal_Int32 _nWidth, sal_Int32 _nHeight ) throw (uno::RuntimeException)
     367             : {
     368           0 :     OUString sCreateShapeName( "com.sun.star.drawing.TextShape" );
     369           0 :     sal_Int32 nXPos = Millimeter::getInHundredthsOfOneMillimeter( _nLeft );
     370           0 :     sal_Int32 nYPos = Millimeter::getInHundredthsOfOneMillimeter( _nTop );
     371           0 :     sal_Int32 nWidth = Millimeter::getInHundredthsOfOneMillimeter( _nWidth );
     372           0 :     sal_Int32 nHeight = Millimeter::getInHundredthsOfOneMillimeter( _nHeight );
     373             : 
     374           0 :     uno::Reference< drawing::XShape > xShape( createShape( sCreateShapeName ), uno::UNO_QUERY_THROW );
     375           0 :     m_xShapes->add( xShape );
     376             : 
     377           0 :     setDefaultShapeProperties(xShape);
     378             : 
     379           0 :     OUString sName(createName( "Text Box" ));
     380           0 :     setShape_NameProperty( xShape, sName );
     381             : 
     382           0 :     awt::Size size;
     383           0 :     size.Height = nHeight;
     384           0 :     size.Width = nWidth;
     385           0 :     xShape->setSize(size);
     386             : 
     387           0 :     uno::Reference< beans::XPropertySet > xShapeProps( xShape, uno::UNO_QUERY_THROW );
     388           0 :     xShapeProps->setPropertyValue( "AnchorType", uno::makeAny( text::TextContentAnchorType_AT_PAGE ) );
     389           0 :     xShapeProps->setPropertyValue( "HoriOrientRelation", uno::makeAny( text::RelOrientation::PAGE_LEFT ) );
     390           0 :     xShapeProps->setPropertyValue( "HoriOrient", uno::makeAny( text::HoriOrientation::NONE ) );
     391           0 :     xShapeProps->setPropertyValue( "HoriOrientPosition", uno::makeAny( nXPos ) );
     392             : 
     393           0 :     xShapeProps->setPropertyValue( "VertOrientRelation", uno::makeAny( text::RelOrientation::PAGE_FRAME ) );
     394           0 :     xShapeProps->setPropertyValue( "VertOrient", uno::makeAny( text::VertOrientation::NONE ) );
     395           0 :     xShapeProps->setPropertyValue( "VertOrientPosition", uno::makeAny( nYPos ) );
     396             : 
     397             :     // set to visible
     398           0 :     drawing::LineStyle aLineStyle = drawing::LineStyle_SOLID;
     399           0 :     xShapeProps->setPropertyValue( "LineStyle", uno::makeAny( aLineStyle ) );
     400             :     // set to font
     401           0 :     sal_Int16 nLayerId = 1;
     402           0 :     OUString sLayerName("Heaven");
     403           0 :     xShapeProps->setPropertyValue( "LayerID", uno::makeAny( nLayerId ) );
     404           0 :     xShapeProps->setPropertyValue( "LayerName", uno::makeAny( sLayerName ) );
     405             : 
     406             : 
     407           0 :     ScVbaShape *pScVbaShape = new ScVbaShape( getParent(), mxContext, xShape, m_xShapes, m_xModel, ScVbaShape::getType( xShape ) );
     408           0 :     return uno::makeAny( uno::Reference< msforms::XShape > ( pScVbaShape ) );
     409             : }
     410             : 
     411             : void
     412           4 : ScVbaShapes::setDefaultShapeProperties( uno::Reference< drawing::XShape > xShape ) throw (uno::RuntimeException)
     413             : {
     414           4 :     uno::Reference< beans::XPropertySet > xPropertySet( xShape, uno::UNO_QUERY_THROW );
     415           4 :     xPropertySet->setPropertyValue( "FillStyle", uno::makeAny( OUString("SOLID") ) );
     416           4 :     xPropertySet->setPropertyValue( "FillColor", uno::makeAny( sal_Int32(0xFFFFFF) )  );
     417           4 :     xPropertySet->setPropertyValue( "TextWordWrap", uno::makeAny( text::WrapTextMode_THROUGHT )  );
     418             :     //not find in OOo2.3
     419             :     //xPropertySet->setPropertyValue("Opaque", uno::makeAny( sal_True )  );
     420           4 : }
     421             : 
     422             : void
     423           4 : ScVbaShapes::setShape_NameProperty( uno::Reference< css::drawing::XShape > xShape, const OUString& sName )
     424             : {
     425           4 :     uno::Reference< beans::XPropertySet > xPropertySet( xShape, uno::UNO_QUERY_THROW );
     426             :     try
     427             :     {
     428           4 :         xPropertySet->setPropertyValue( "Name", uno::makeAny( sName ) );
     429             :     }
     430           0 :     catch(const script::BasicErrorException&)
     431             :     {
     432           4 :     }
     433           4 : }
     434             : 
     435             : OUString
     436           4 : ScVbaShapes::createName( const OUString& sName )
     437             : {
     438           4 :     sal_Int32 nActNumber = 1 + m_nNewShapeCount;
     439           4 :     m_nNewShapeCount++;
     440           4 :     return sName + OUString::number( nActNumber );
     441         480 : }
     442             : 
     443             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10