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