oox/inc/oox/vml/vmlshape.hxx | 17 ++++++++ oox/inc/oox/vml/vmlshapecontext.hxx | 4 + oox/source/vml/vmlshape.cxx | 42 +++++++++++++++++++- oox/source/vml/vmlshapecontext.cxx | 20 +++++++++ writerfilter/source/Makefile | 4 - writerfilter/source/ooxml/gperffasttokenhandler.xsl | 13 ++---- 6 files changed, 89 insertions(+), 11 deletions(-)
New commits: commit 4159a4e6ce38b333ced3ba5f75e28473605633e8 Author: Miklos Vajna <vmik...@suse.cz> Date: Tue Mar 27 18:39:04 2012 +0200 n#751117 oox: implement VML import of shape style 'flip' diff --git a/oox/inc/oox/vml/vmlshape.hxx b/oox/inc/oox/vml/vmlshape.hxx index bde8823..c4ab2cd 100644 --- a/oox/inc/oox/vml/vmlshape.hxx +++ b/oox/inc/oox/vml/vmlshape.hxx @@ -81,6 +81,7 @@ struct ShapeTypeModel ::rtl::OUString maMarginTop; ///< Y position of the shape bounding box to shape anchor (number with unit). ::rtl::OUString maPositionVerticalRelative; ///< The Y position is relative to this. ::rtl::OUString maRotation; ///< Rotation of the shape, in degrees. + ::rtl::OUString maFlip; ///< Rotation of the shape, in degrees. sal_Bool mbAutoHeight; ///< If true, the height value is a minimum value (mostly used for textboxes) StrokeModel maStrokeModel; ///< Border line formatting. diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index ad508c6..37e6431 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -367,7 +367,22 @@ SimpleShape::SimpleShape( Drawing& rDrawing, const OUString& rService ) : Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes >& rxShapes, const Rectangle& rShapeRect ) const { - Reference< XShape > xShape = mrDrawing.createAndInsertXShape( maService, rxShapes, rShapeRect ); + Rectangle aShapeRect(rShapeRect); + if (!maTypeModel.maFlip.isEmpty()) + { + if (maTypeModel.maFlip.equalsAscii("x")) + { + aShapeRect.X += aShapeRect.Width; + aShapeRect.Width *= -1; + } + else if (maTypeModel.maFlip.equalsAscii("y")) + { + aShapeRect.Y += aShapeRect.Height; + aShapeRect.Height *= -1; + } + } + + Reference< XShape > xShape = mrDrawing.createAndInsertXShape( maService, rxShapes, aShapeRect ); convertShapeProperties( xShape ); if ( maService.equalsAscii( "com.sun.star.text.TextFrame" ) ) diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx index fb10331..57a85e9 100644 --- a/oox/source/vml/vmlshapecontext.cxx +++ b/oox/source/vml/vmlshapecontext.cxx @@ -350,6 +350,7 @@ void ShapeTypeContext::setStyle( const OUString& rStyle ) else if( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "mso-position-vertical-relative" ) ) ) mrTypeModel.maPositionVerticalRelative = aValue; else if( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "mso-fit-shape-to-text" ) ) ) mrTypeModel.mbAutoHeight = sal_True; else if( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "rotation" ) ) ) mrTypeModel.maRotation = aValue; + else if( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "flip" ) ) ) mrTypeModel.maFlip = aValue; } } } commit 559ecabbfc6d78df995c899ba996a470e241b76c Author: Miklos Vajna <vmik...@suse.cz> Date: Tue Mar 27 14:34:35 2012 +0200 n#751117 oox: implement VML import of v:line token diff --git a/oox/inc/oox/vml/vmlshape.hxx b/oox/inc/oox/vml/vmlshape.hxx index c00625c..bde8823 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 08df6d3..13c77d3 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 8c27d76..ad508c6 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 f6f6ac9..fb10331 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 ) : commit 8b8fad38b2de3f037f628fea1f0f00fcb280be0d Author: Miklos Vajna <vmik...@suse.cz> Date: Tue Mar 27 11:32:19 2012 +0200 n#751117 oox: implement VML import of shape style 'rotation' diff --git a/oox/inc/oox/vml/vmlshape.hxx b/oox/inc/oox/vml/vmlshape.hxx index 946af36..c00625c 100644 --- a/oox/inc/oox/vml/vmlshape.hxx +++ b/oox/inc/oox/vml/vmlshape.hxx @@ -80,6 +80,7 @@ struct ShapeTypeModel ::rtl::OUString maMarginLeft; ///< X position of the shape bounding box to shape anchor (number with unit). ::rtl::OUString maMarginTop; ///< Y position of the shape bounding box to shape anchor (number with unit). ::rtl::OUString maPositionVerticalRelative; ///< The Y position is relative to this. + ::rtl::OUString maRotation; ///< Rotation of the shape, in degrees. sal_Bool mbAutoHeight; ///< If true, the height value is a minimum value (mostly used for textboxes) StrokeModel maStrokeModel; ///< Border line formatting. diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index ec34f0e..8c27d76 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -382,6 +382,10 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes if( xInStrm.is() ) PropertySet( xShape ).setProperty( PROP_LegacyFragment, xInStrm ); } + + if (xShape.is() && !maTypeModel.maRotation.isEmpty()) + PropertySet(xShape).setAnyProperty(PROP_RotateAngle, makeAny(maTypeModel.maRotation.toInt32() * 100)); + return xShape; } diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx index 12d2dc4..f6f6ac9 100644 --- a/oox/source/vml/vmlshapecontext.cxx +++ b/oox/source/vml/vmlshapecontext.cxx @@ -348,6 +348,7 @@ void ShapeTypeContext::setStyle( const OUString& rStyle ) else if( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "margin-top" ) ) ) mrTypeModel.maMarginTop = aValue; else if( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "mso-position-vertical-relative" ) ) ) mrTypeModel.maPositionVerticalRelative = aValue; else if( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "mso-fit-shape-to-text" ) ) ) mrTypeModel.mbAutoHeight = sal_True; + else if( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "rotation" ) ) ) mrTypeModel.maRotation = aValue; } } } commit b4f5c3fea2428fff9f470b6cde86b867787128d8 Author: Miklos Vajna <vmik...@suse.cz> Date: Tue Mar 27 09:57:25 2012 +0200 n#751117 writerfilter: include all oox tokens in gperffasttoken.hxx Without that, the following happens: 1) ShapeTypeContext::onCreateContext() in oox calls rAttribs.getToken() 2) FastAttributeList::getOptionalValueToken() in sax calls mxTokenHandler->getTokenFromUTF8() 3) OOXMLFastTokenHandler::getTokenFromUTF8() won't find the oox token and return OOXML_FAST_TOKENS_END I verified that the new gperf input just adds tokens to the hash, doesn't remove any. diff --git a/writerfilter/source/Makefile b/writerfilter/source/Makefile index 240893c..2b10ae9 100644 --- a/writerfilter/source/Makefile +++ b/writerfilter/source/Makefile @@ -140,9 +140,9 @@ $(wf_GEN_ooxml_NamespaceIds_hxx) : $(wf_SRC_ooxml_NamespaceIds_xsl) $(wf_GEN_oox $(call gb_Output_announce,$@,build,XSL,1) $(call gb_Helper_abbreviate_dirs_native, $(gb_XSLTPROC) $(wf_SRC_ooxml_NamespaceIds_xsl) $(wf_GEN_ooxml_Model_processed)) > $@ -$(wf_GEN_ooxml_GperfFastToken_hxx) : $(wf_SRC_ooxml_GperfFastTokenHandler_xsl) $(wf_GEN_ooxml_Model_processed) +$(wf_GEN_ooxml_GperfFastToken_hxx) : $(wf_SRC_ooxml_GperfFastTokenHandler_xsl) $(wf_GEN_ooxml_token_xml) $(call gb_Output_announce,$@,build,GPF,1) - $(call gb_Helper_abbreviate_dirs_native, $(gb_XSLTPROC) $(wf_SRC_ooxml_GperfFastTokenHandler_xsl) $(wf_GEN_ooxml_Model_processed)) \ + $(call gb_Helper_abbreviate_dirs_native, $(gb_XSLTPROC) $(wf_SRC_ooxml_GperfFastTokenHandler_xsl) $(wf_GEN_ooxml_token_xml)) \ | tr -d '\r' | $(GPERF) -I -t -E -S1 -c -G -LC++ > $@ $(wf_GEN_ooxml_Model_analyzed): $(wf_SRC_ooxml_Analyze_model_xsl) $(wf_SRC_ooxml_Model) diff --git a/writerfilter/source/ooxml/gperffasttokenhandler.xsl b/writerfilter/source/ooxml/gperffasttokenhandler.xsl index d14db04..648342d 100644 --- a/writerfilter/source/ooxml/gperffasttokenhandler.xsl +++ b/writerfilter/source/ooxml/gperffasttokenhandler.xsl @@ -77,15 +77,14 @@ namespace writerfilter { namespace ooxml { namespace tokenmap { %} struct token { const char * name; Token_t nToken; }; %%</xsl:text> - <xsl:for-each select=".//rng:element|.//rng:attribute"> - <xsl:if test="generate-id(.) = generate-id(key('same-token-name', @localname)[1])"> - <xsl:text>
</xsl:text> - <xsl:value-of select="@localname"/> - <xsl:text>, </xsl:text> - <xsl:call-template name="fastlocalname"/> - </xsl:if> + <xsl:for-each select="/model/fasttoken"> + <xsl:text>
</xsl:text> + <xsl:value-of select="translate(., '-', '_')"/> + <xsl:text>, OOXML_</xsl:text> + <xsl:value-of select="translate(., '-', '_')"/> </xsl:for-each> <xsl:text> +FAST_TOKENS_END, OOXML_FAST_TOKENS_END %%
</xsl:text> }}}
</xsl:template> _______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits