diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2012-03-27 14:34:35 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2012-03-28 10:27:46 +0200 |
commit | 559ecabbfc6d78df995c899ba996a470e241b76c (patch) | |
tree | 340451adcd9251f9b0b02bea11c2b01eda5dd9ee /oox | |
parent | 8b8fad38b2de3f037f628fea1f0f00fcb280be0d (diff) |
n#751117 oox: implement VML import of v:line token
Diffstat (limited to 'oox')
-rw-r--r-- | oox/inc/oox/vml/vmlshape.hxx | 15 | ||||
-rw-r--r-- | oox/inc/oox/vml/vmlshapecontext.hxx | 4 | ||||
-rw-r--r-- | oox/source/vml/vmlshape.cxx | 21 | ||||
-rw-r--r-- | oox/source/vml/vmlshapecontext.cxx | 18 |
4 files changed, 57 insertions, 1 deletions
diff --git a/oox/inc/oox/vml/vmlshape.hxx b/oox/inc/oox/vml/vmlshape.hxx index c00625c5a6fa..bde882374e49 100644 --- a/oox/inc/oox/vml/vmlshape.hxx +++ b/oox/inc/oox/vml/vmlshape.hxx @@ -186,6 +186,8 @@ struct ShapeModel TextBoxPtr mxTextBox; /// Text contents and properties. ClientDataPtr mxClientData; /// Excel specific client data. ::rtl::OUString maLegacyDiagramPath;/// Legacy Diagram Fragment Path + ::rtl::OUString maFrom; /// Start point for line shape. + ::rtl::OUString maTo; /// End point for line shape. explicit ShapeModel(); ~ShapeModel(); @@ -312,6 +314,19 @@ protected: const ::com::sun::star::awt::Rectangle& rShapeRect ) const; }; +/** A Line shape object. */ +class LineShape : public SimpleShape +{ +public: + explicit LineShape( Drawing& rDrawing ); + +protected: + /** Creates the corresponding XShape and inserts it into the passed container. */ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > + implConvertAndInsert( + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes, + const ::com::sun::star::awt::Rectangle& rShapeRect ) const; +}; // ============================================================================ /** A shape object with custom geometry. */ diff --git a/oox/inc/oox/vml/vmlshapecontext.hxx b/oox/inc/oox/vml/vmlshapecontext.hxx index 08df6d33a713..13c77d3ecd18 100644 --- a/oox/inc/oox/vml/vmlshapecontext.hxx +++ b/oox/inc/oox/vml/vmlshapecontext.hxx @@ -139,6 +139,10 @@ public: private: /** Processes the 'points' attribute. */ void setPoints( const ::rtl::OUString& rPoints ); + /** Processes the 'from' attribute. */ + void setFrom( const ::rtl::OUString& rPoints ); + /** Processes the 'to' attribute. */ + void setTo( const ::rtl::OUString& rPoints ); protected: ShapeBase& mrShape; diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index 8c27d76b85b2..ad508c68ad96 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -45,6 +45,7 @@ #include <com/sun/star/text/TextContentAnchorType.hpp> #include <rtl/math.hxx> #include <rtl/ustrbuf.hxx> +#include <rtl/oustringostreaminserter.hxx> #include "oox/drawingml/shapepropertymap.hxx" #include "oox/helper/graphichelper.hxx" #include "oox/helper/propertyset.hxx" @@ -428,6 +429,26 @@ Reference< XShape > PolyLineShape::implConvertAndInsert( const Reference< XShape return xShape; } +LineShape::LineShape(Drawing& rDrawing) + : SimpleShape(rDrawing, "com.sun.star.drawing.LineShape") +{ +} + +Reference<XShape> LineShape::implConvertAndInsert(const Reference<XShapes>& rxShapes, const Rectangle& rShapeRect) const +{ + const GraphicHelper& rGraphicHelper = mrDrawing.getFilter().getGraphicHelper(); + Rectangle aShapeRect(rShapeRect); + sal_Int32 nIndex = 0; + + aShapeRect.X = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, maShapeModel.maFrom.getToken(0, ',', nIndex), 0, true, true); + aShapeRect.Y = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, maShapeModel.maFrom.getToken(0, ',', nIndex), 0, true, true); + nIndex = 0; + aShapeRect.Width = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, maShapeModel.maTo.getToken(0, ',', nIndex), 0, true, true) - aShapeRect.X; + aShapeRect.Height = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, maShapeModel.maTo.getToken(0, ',', nIndex), 0, true, true) - aShapeRect.Y; + + return SimpleShape::implConvertAndInsert(rxShapes, aShapeRect); +} + // ============================================================================ CustomShape::CustomShape( Drawing& rDrawing ) : diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx index f6f6ac91c9f7..fb10331e8362 100644 --- a/oox/source/vml/vmlshapecontext.cxx +++ b/oox/source/vml/vmlshapecontext.cxx @@ -234,11 +234,12 @@ ShapeContextBase::ShapeContextBase( ContextHandler2Helper& rParent ) : return new ShapeContext( rParent, rShapes.createShape< EllipseShape >(), rAttribs ); case VML_TOKEN( polyline ): return new ShapeContext( rParent, rShapes.createShape< PolyLineShape >(), rAttribs ); + case VML_TOKEN( line ): + return new ShapeContext( rParent, rShapes.createShape< LineShape >(), rAttribs ); // TODO: case VML_TOKEN( arc ): case VML_TOKEN( curve ): - case VML_TOKEN( line ): case VML_TOKEN( diagram ): case VML_TOKEN( image ): return new ShapeContext( rParent, rShapes.createShape< ComplexShape >(), rAttribs ); @@ -364,6 +365,9 @@ ShapeContext::ShapeContext( ContextHandler2Helper& rParent, ShapeBase& rShape, c mrShapeModel.maType = rAttribs.getXString( XML_type, OUString() ); // polyline path setPoints( rAttribs.getString( XML_points, OUString() ) ); + // line start and end positions + setFrom(rAttribs.getString(XML_from, OUString())); + setTo(rAttribs.getString(XML_to, OUString())); } ContextHandlerRef ShapeContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) @@ -402,6 +406,18 @@ void ShapeContext::setPoints( const OUString& rPoints ) } } +void ShapeContext::setFrom( const OUString& rPoints ) +{ + if (!rPoints.isEmpty()) + mrShapeModel.maFrom = rPoints; +} + +void ShapeContext::setTo( const OUString& rPoints ) +{ + if (!rPoints.isEmpty()) + mrShapeModel.maTo = rPoints; +} + // ============================================================================ GroupShapeContext::GroupShapeContext( ContextHandler2Helper& rParent, GroupShape& rShape, const AttributeList& rAttribs ) : |