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