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