summaryrefslogtreecommitdiff
path: root/vbahelper
diff options
context:
space:
mode:
authorTamas Bunth <tamas.bunth@collabora.co.uk>2017-09-07 22:00:01 +0200
committerTamás Bunth <btomi96@gmail.com>2017-09-08 09:29:36 +0200
commit8e8c789742874ac823e68f6154050c64b6fc5b85 (patch)
tree39c3f0bbb622a215c76f1dc73c7ed78ecf420667 /vbahelper
parent2e0a25ce2b87d3a4bbf944025fc3720933fb391d (diff)
oovbaapi: create XOval and XLine shape types
This is needed in order to make "TypeOf myLine Is Line" or similar expressions return the expected "true" value. The implementation of the basic interpreter of TypeOf uses XTypeProvider to determine the type of an object by getting the last part of the type name. E.g. "ooo:vba::msforms::XLine" is determined as a "Line". That's why I created the XLine and XOval blank classes. TypeOf doc: https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/operators/typeof-operator Change-Id: Ia49cc92d672e30d0126f02d61a55a956ac1425f0 Reviewed-on: https://gerrit.libreoffice.org/42083 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tamás Bunth <btomi96@gmail.com>
Diffstat (limited to 'vbahelper')
-rw-r--r--vbahelper/source/vbahelper/vbashape.cxx42
1 files changed, 42 insertions, 0 deletions
diff --git a/vbahelper/source/vbahelper/vbashape.cxx b/vbahelper/source/vbahelper/vbashape.cxx
index ca012370267c..e7aed451efe2 100644
--- a/vbahelper/source/vbahelper/vbashape.cxx
+++ b/vbahelper/source/vbahelper/vbashape.cxx
@@ -29,6 +29,7 @@
#include <com/sun/star/text/TextContentAnchorType.hpp>
#include <com/sun/star/text/RelOrientation.hpp>
#include <ooo/vba/office/MsoShapeType.hpp>
+#include <ooo/vba/office/MsoAutoShapeType.hpp>
#include <ooo/vba/word/WdRelativeHorizontalPosition.hpp>
#include <ooo/vba/word/WdRelativeVerticalPosition.hpp>
@@ -154,6 +155,47 @@ ScVbaShape::getType( const css::uno::Reference< drawing::XShape >& xShape )
throw uno::RuntimeException("the shape type do not be supported: " + sShapeType );
}
+sal_Int32 ScVbaShape::getAutoShapeType(const css::uno::Reference< drawing::XShape >& xShape)
+{
+ assert( ScVbaShape::getType( xShape ) == office::MsoShapeType::msoAutoShape );
+
+ OUString sShapeType;
+ uno::Reference< drawing::XShapeDescriptor > xShapeDescriptor( xShape, uno::UNO_QUERY_THROW );
+ sShapeType = xShapeDescriptor->getShapeType();
+ SAL_INFO("vbahelper", "ScVbaShape::getAutoShapeType: " << sShapeType);
+
+ if( sShapeType == "com.sun.star.drawing.EllipseShape" )
+ return office::MsoAutoShapeType::msoShapeOval;
+ else if ( sShapeType == "com.sun.star.drawing.RectangleShape" )
+ return office::MsoAutoShapeType::msoShapeRectangle;
+ else if ( sShapeType == "com.sun.star.drawing.CustomShape" )
+ {
+ uno::Reference< beans::XPropertySet > aXPropSet( xShape, uno::UNO_QUERY );
+ uno::Any aGeoPropSet = aXPropSet->getPropertyValue( "CustomShapeGeometry" );
+ uno::Sequence< beans::PropertyValue > aGeoPropSeq;
+ if ( aGeoPropSet >>= aGeoPropSeq )
+ {
+ for( const auto& rProp : aGeoPropSeq )
+ {
+ if( rProp.Name == "Type" )
+ {
+ OUString sType;
+ if( rProp.Value >>= sType )
+ {
+ if( sType.endsWith( "ellipse" ) )
+ return office::MsoAutoShapeType::msoShapeOval;
+ // TODO other custom shapes here
+ }
+ }
+ }
+ }
+ }
+
+ SAL_WARN( "vbahelper", "ScVbaShape::getAutoShapeType: unknown auto type" );
+ return -1; // could not decide
+
+}
+
// Attributes
OUString SAL_CALL
ScVbaShape::getName()