Kaydet (Commit) 559ecabb authored tarafından Miklos Vajna's avatar Miklos Vajna

n#751117 oox: implement VML import of v:line token

üst 8b8fad38
...@@ -186,6 +186,8 @@ struct ShapeModel ...@@ -186,6 +186,8 @@ struct ShapeModel
TextBoxPtr mxTextBox; /// Text contents and properties. TextBoxPtr mxTextBox; /// Text contents and properties.
ClientDataPtr mxClientData; /// Excel specific client data. ClientDataPtr mxClientData; /// Excel specific client data.
::rtl::OUString maLegacyDiagramPath;/// Legacy Diagram Fragment Path ::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(); explicit ShapeModel();
~ShapeModel(); ~ShapeModel();
...@@ -312,6 +314,19 @@ protected: ...@@ -312,6 +314,19 @@ protected:
const ::com::sun::star::awt::Rectangle& rShapeRect ) const; 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. */ /** A shape object with custom geometry. */
......
...@@ -139,6 +139,10 @@ public: ...@@ -139,6 +139,10 @@ public:
private: private:
/** Processes the 'points' attribute. */ /** Processes the 'points' attribute. */
void setPoints( const ::rtl::OUString& rPoints ); 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: protected:
ShapeBase& mrShape; ShapeBase& mrShape;
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include <com/sun/star/text/TextContentAnchorType.hpp> #include <com/sun/star/text/TextContentAnchorType.hpp>
#include <rtl/math.hxx> #include <rtl/math.hxx>
#include <rtl/ustrbuf.hxx> #include <rtl/ustrbuf.hxx>
#include <rtl/oustringostreaminserter.hxx>
#include "oox/drawingml/shapepropertymap.hxx" #include "oox/drawingml/shapepropertymap.hxx"
#include "oox/helper/graphichelper.hxx" #include "oox/helper/graphichelper.hxx"
#include "oox/helper/propertyset.hxx" #include "oox/helper/propertyset.hxx"
...@@ -428,6 +429,26 @@ Reference< XShape > PolyLineShape::implConvertAndInsert( const Reference< XShape ...@@ -428,6 +429,26 @@ Reference< XShape > PolyLineShape::implConvertAndInsert( const Reference< XShape
return 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 ) : CustomShape::CustomShape( Drawing& rDrawing ) :
......
...@@ -234,11 +234,12 @@ ShapeContextBase::ShapeContextBase( ContextHandler2Helper& rParent ) : ...@@ -234,11 +234,12 @@ ShapeContextBase::ShapeContextBase( ContextHandler2Helper& rParent ) :
return new ShapeContext( rParent, rShapes.createShape< EllipseShape >(), rAttribs ); return new ShapeContext( rParent, rShapes.createShape< EllipseShape >(), rAttribs );
case VML_TOKEN( polyline ): case VML_TOKEN( polyline ):
return new ShapeContext( rParent, rShapes.createShape< PolyLineShape >(), rAttribs ); return new ShapeContext( rParent, rShapes.createShape< PolyLineShape >(), rAttribs );
case VML_TOKEN( line ):
return new ShapeContext( rParent, rShapes.createShape< LineShape >(), rAttribs );
// TODO: // TODO:
case VML_TOKEN( arc ): case VML_TOKEN( arc ):
case VML_TOKEN( curve ): case VML_TOKEN( curve ):
case VML_TOKEN( line ):
case VML_TOKEN( diagram ): case VML_TOKEN( diagram ):
case VML_TOKEN( image ): case VML_TOKEN( image ):
return new ShapeContext( rParent, rShapes.createShape< ComplexShape >(), rAttribs ); return new ShapeContext( rParent, rShapes.createShape< ComplexShape >(), rAttribs );
...@@ -364,6 +365,9 @@ ShapeContext::ShapeContext( ContextHandler2Helper& rParent, ShapeBase& rShape, c ...@@ -364,6 +365,9 @@ ShapeContext::ShapeContext( ContextHandler2Helper& rParent, ShapeBase& rShape, c
mrShapeModel.maType = rAttribs.getXString( XML_type, OUString() ); mrShapeModel.maType = rAttribs.getXString( XML_type, OUString() );
// polyline path // polyline path
setPoints( rAttribs.getString( XML_points, OUString() ) ); 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 ) ContextHandlerRef ShapeContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
...@@ -402,6 +406,18 @@ void ShapeContext::setPoints( const OUString& rPoints ) ...@@ -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 ) : GroupShapeContext::GroupShapeContext( ContextHandler2Helper& rParent, GroupShape& rShape, const AttributeList& rAttribs ) :
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment