diff options
author | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2012-09-24 18:01:05 +0200 |
---|---|---|
committer | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2012-09-27 09:23:19 +0200 |
commit | 0f581ab761cefde208e576661850b57f2846fdb4 (patch) | |
tree | 6639ba32278a1fe0533d9b147b4f25adee525e8d /oox | |
parent | 8cb7464130634551fd2f043efc14f8f8f8bdf447 (diff) |
n#779627: VML: import mso-position-vertical:center and friends
This allows to properly position objects that are vertically and/or
horizontally centered relatively to the page.
Change-Id: I1f7e78c5b828679817cdfc72e4d90a0850b242fa
Diffstat (limited to 'oox')
-rw-r--r-- | oox/inc/oox/vml/vmlshape.hxx | 2 | ||||
-rw-r--r-- | oox/source/token/properties.txt | 2 | ||||
-rw-r--r-- | oox/source/vml/vmlshape.cxx | 28 | ||||
-rw-r--r-- | oox/source/vml/vmlshapecontext.cxx | 2 |
4 files changed, 25 insertions, 9 deletions
diff --git a/oox/inc/oox/vml/vmlshape.hxx b/oox/inc/oox/vml/vmlshape.hxx index a09192a42ce7..385f9eaf6745 100644 --- a/oox/inc/oox/vml/vmlshape.hxx +++ b/oox/inc/oox/vml/vmlshape.hxx @@ -70,8 +70,10 @@ struct ShapeTypeModel ::rtl::OUString maHeight; ///< Height of the shape bounding box (number with unit). ::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 maPositionHorizontalRelative; ///< The X position is relative to this. ::rtl::OUString maPositionVerticalRelative; ///< The Y position is relative to this. ::rtl::OUString maPositionHorizontal; ///< The X position orientation (default: absolute). + ::rtl::OUString maPositionVertical; ///< The Y position orientation. ::rtl::OUString maRotation; ///< Rotation of the shape, in degrees. ::rtl::OUString maFlip; ///< Flip type of the shape (can be "x" or "y"). sal_Bool mbAutoHeight; ///< If true, the height value is a minimum value (mostly used for textboxes) diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index 3fed5300c428..ff4e47b09f34 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -223,6 +223,7 @@ HoriJustify HoriJustifyMethod HoriOrient HoriOrientPosition +HoriOrientRelation HorizontalSplitMode HorizontalSplitPositionTwips IgnoreBlankCells @@ -517,6 +518,7 @@ VertJustifyMethod VerticalAlign VerticalSplitMode VerticalSplitPositionTwips +VertOrient VertOrientPosition VertOrientRelation ViewBox diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index c9096eb37ebb..7d8d1660a42e 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -381,6 +381,15 @@ SimpleShape::SimpleShape( Drawing& rDrawing, const OUString& rService ) : void lcl_SetAnchorType(PropertySet& rPropSet, const ShapeTypeModel& rTypeModel) { + if ( rTypeModel.maPositionHorizontal == "center" ) + rPropSet.setAnyProperty(PROP_HoriOrient, makeAny(text::HoriOrientation::CENTER)); + + if ( rTypeModel.maPositionHorizontalRelative == "page" ) + rPropSet.setAnyProperty(PROP_HoriOrientRelation, makeAny(text::RelOrientation::PAGE_FRAME)); + + if ( rTypeModel.maPositionVertical == "center" ) + rPropSet.setAnyProperty(PROP_VertOrient, makeAny(text::VertOrientation::CENTER)); + if ( rTypeModel.maPosition == "absolute" ) { if (rTypeModel.moWrapAnchorX.get() == "page" && rTypeModel.moWrapAnchorY.get() == "page") @@ -395,8 +404,16 @@ void lcl_SetAnchorType(PropertySet& rPropSet, const ShapeTypeModel& rTypeModel) // Map to as-character by default, that fixes vertical position of some textframes. rPropSet.setProperty(PROP_AnchorType, text::TextContentAnchorType_AT_CHARACTER); } - // Vertical placement relative to margin, because parent style must not modify vertical position - rPropSet.setProperty(PROP_VertOrientRelation, text::RelOrientation::FRAME); + + if ( rTypeModel.maPositionVerticalRelative == "page" ) + { + rPropSet.setProperty(PROP_VertOrientRelation, text::RelOrientation::PAGE_FRAME); + } + else + { + // Vertical placement relative to margin, because parent style must not modify vertical position + rPropSet.setProperty(PROP_VertOrientRelation, text::RelOrientation::FRAME); + } } else if( rTypeModel.maPosition == "relative" ) { // I'm not very sure this is correct either. @@ -432,8 +449,6 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes { PropertySet( xShape ).setAnyProperty( PROP_FrameIsAutomaticHeight, makeAny( maTypeModel.mbAutoHeight ) ); PropertySet( xShape ).setAnyProperty( PROP_SizeType, makeAny( maTypeModel.mbAutoHeight ? SizeType::MIN : SizeType::FIX ) ); - if (maTypeModel.maPositionHorizontal == "center") - PropertySet(xShape).setAnyProperty(PROP_HoriOrient, makeAny(text::HoriOrientation::CENTER)); } // Import Legacy Fragments (if any) @@ -479,11 +494,6 @@ Reference< XShape > SimpleShape::createPictureObject( const Reference< XShapes > } lcl_SetAnchorType(aPropSet, maTypeModel); - - if ( maTypeModel.maPositionVerticalRelative == "page" ) - { - aPropSet.setProperty(PROP_VertOrientRelation, text::RelOrientation::PAGE_FRAME); - } } return xShape; } diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx index 165aee501540..01543c31e8d8 100644 --- a/oox/source/vml/vmlshapecontext.cxx +++ b/oox/source/vml/vmlshapecontext.cxx @@ -361,7 +361,9 @@ void ShapeTypeContext::setStyle( const OUString& rStyle ) else if( aName == "margin-left" ) mrTypeModel.maMarginLeft = aValue; else if( aName == "margin-top" ) mrTypeModel.maMarginTop = aValue; else if( aName == "mso-position-vertical-relative" ) mrTypeModel.maPositionVerticalRelative = aValue; + else if( aName == "mso-position-horizontal-relative" ) mrTypeModel.maPositionHorizontalRelative = aValue; else if( aName == "mso-position-horizontal" ) mrTypeModel.maPositionHorizontal = aValue; + else if( aName == "mso-position-vertical" ) mrTypeModel.maPositionVertical = aValue; else if( aName == "mso-fit-shape-to-text" ) mrTypeModel.mbAutoHeight = sal_True; else if( aName == "rotation" ) mrTypeModel.maRotation = aValue; else if( aName == "flip" ) mrTypeModel.maFlip = aValue; |