oox/inc/oox/vml/vmlshape.hxx | 6 +++ oox/source/token/properties.txt | 4 ++ oox/source/vml/vmlshape.cxx | 54 ++++++++++++++++++++++----- oox/source/vml/vmlshapecontext.cxx | 6 +++ svx/inc/svx/svdoashp.hxx | 2 - svx/inc/svx/svdobj.hxx | 9 ++++ svx/inc/svx/svdogrp.hxx | 2 - svx/inc/svx/svdovirt.hxx | 2 - svx/source/svdraw/svdoashp.cxx | 4 +- svx/source/svdraw/svdobj.cxx | 7 +++ svx/source/svdraw/svdogrp.cxx | 6 +-- svx/source/svdraw/svdovirt.cxx | 4 +- sw/inc/dcontact.hxx | 2 - sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 22 ++++++++++- sw/source/core/draw/dcontact.cxx | 4 +- sw/source/core/draw/dflyobj.cxx | 2 - sw/source/core/inc/dflyobj.hxx | 2 - sw/source/core/layout/anchoreddrawobject.cxx | 23 +++++++++++ sw/source/core/unocore/unodraw.cxx | 16 ++++++++ sw/source/core/unocore/unomap.cxx | 2 + 20 files changed, 152 insertions(+), 27 deletions(-)
New commits: commit d4474dd0411d7de29ce42e181c97cbf032bf57ea Author: Cédric Bosdonnat <[email protected]> Date: Wed Sep 26 13:10:31 2012 +0200 sw: implement page-relative size for drawing objects and import them from docx Change-Id: I98b5c53d4860278e3646324ca045114e37b4cf61 diff --git a/oox/inc/oox/vml/vmlshape.hxx b/oox/inc/oox/vml/vmlshape.hxx index 385f9ea..c7f288d 100644 --- a/oox/inc/oox/vml/vmlshape.hxx +++ b/oox/inc/oox/vml/vmlshape.hxx @@ -74,6 +74,10 @@ struct ShapeTypeModel ::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 maWidthPercent; ///< The width in percents of the WidthRelative + ::rtl::OUString maHeightPercent; ///< The height in percents of the HeightRelative + ::rtl::OUString maWidthRelative; ///< To what the width is relative + ::rtl::OUString maHeightRelative; ///< To what the height is relative ::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 ff4e47b..c925d1f 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -374,9 +374,11 @@ ReferenceSheet RefreshPeriod RegularExpressions RelId +RelativeHeight RelativeHorizontalTabbarWidth RelativePosition RelativeSize +RelativeWidth Repeat RepeatDelay Representation diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index 7d8d166..7773d8a 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -450,6 +450,32 @@ 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 ) ); } + else + { + // FIXME Setting the relative width/heigh only for everything but text frames as + // TextFrames already have relative widht/heigh feature... but currently not working + // in the way we need. + + // Set the relative width / height if any + if ( !maTypeModel.maWidthPercent.isEmpty( ) ) + { + // Only page-relative width is supported ATM + if ( maTypeModel.maWidthRelative.isEmpty() || maTypeModel.maWidthRelative == "page" ) + { + sal_Int16 nWidth = maTypeModel.maWidthPercent.toInt32() / 10; + PropertySet( xShape ).setAnyProperty(PROP_RelativeWidth, makeAny( nWidth ) ); + } + } + if ( !maTypeModel.maHeightPercent.isEmpty( ) ) + { + // Only page-relative height is supported ATM + if ( maTypeModel.maHeightRelative.isEmpty() || maTypeModel.maHeightRelative == "page" ) + { + sal_Int16 nHeight = maTypeModel.maHeightPercent.toInt32() / 10; + PropertySet( xShape ).setAnyProperty(PROP_RelativeHeight, makeAny( nHeight ) ); + } + } + } // Import Legacy Fragments (if any) if( xShape.is() && !maShapeModel.maLegacyDiagramPath.isEmpty() ) diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx index 01543c3..35525e6 100644 --- a/oox/source/vml/vmlshapecontext.cxx +++ b/oox/source/vml/vmlshapecontext.cxx @@ -364,6 +364,10 @@ void ShapeTypeContext::setStyle( const OUString& rStyle ) 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-width-percent" ) mrTypeModel.maWidthPercent = aValue; + else if( aName == "mso-width-relative" ) mrTypeModel.maWidthRelative = aValue; + else if( aName == "mso-height-percent" ) mrTypeModel.maHeightPercent = aValue; + else if( aName == "mso-height-relative" ) mrTypeModel.maHeightRelative = 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; diff --git a/svx/inc/svx/svdoashp.hxx b/svx/inc/svx/svdoashp.hxx index 0f54019..8b91894 100644 --- a/svx/inc/svx/svdoashp.hxx +++ b/svx/inc/svx/svdoashp.hxx @@ -188,7 +188,7 @@ public: virtual const Rectangle& GetLogicRect() const; virtual void Move(const Size& rSiz); - virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact); + virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative = true); virtual void Shear(const Point& rRef, long nWink, double tn, bool bVShear); virtual void SetSnapRect(const Rectangle& rRect); virtual void SetLogicRect(const Rectangle& rRect); diff --git a/svx/inc/svx/svdobj.hxx b/svx/inc/svx/svdobj.hxx index e0fac26..6c5b67b 100644 --- a/svx/inc/svx/svdobj.hxx +++ b/svx/inc/svx/svdobj.hxx @@ -47,6 +47,7 @@ #include "svx/svxdllapi.h" #include "svx/shapeproperty.hxx" +#include <boost/optional.hpp> #include <boost/ptr_container/ptr_vector.hpp> //************************************************************ @@ -451,8 +452,14 @@ protected: // global static ItemPool for not-yet-insetred items private: static SdrItemPool* mpGlobalItemPool; + boost::optional<double> mnRelativeWidth; + boost::optional<double> mnRelativeHeight; public: static SdrItemPool& GetGlobalDrawObjectItemPool(); + void SetRelativeWidth( double nValue ) { mnRelativeWidth.reset( nValue ); } + void SetRelativeHeight( double nValue ) { mnRelativeHeight.reset( nValue ); } + boost::optional<double> GetRelativeWidth( ) const { return mnRelativeWidth; } + boost::optional<double> GetRelativeHeight( ) const { return mnRelativeHeight; } protected: void ImpDeleteUserData(); SdrObjUserData* ImpGetMacroUserData() const; @@ -721,7 +728,7 @@ public: virtual void NbcShear (const Point& rRef, long nWink, double tn, bool bVShear); virtual void Move (const Size& rSiz); - virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact); + virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative = true); virtual void Rotate(const Point& rRef, long nWink, double sn, double cs); virtual void Mirror(const Point& rRef1, const Point& rRef2); virtual void Shear (const Point& rRef, long nWink, double tn, bool bVShear); diff --git a/svx/inc/svx/svdogrp.hxx b/svx/inc/svx/svdogrp.hxx index 3e8318e..ed04fb8 100644 --- a/svx/inc/svx/svdogrp.hxx +++ b/svx/inc/svx/svdogrp.hxx @@ -97,7 +97,7 @@ public: virtual long GetShearAngle(bool bVertical = false) const; virtual void Move(const Size& rSiz); - virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact); + virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative = true); virtual void Rotate(const Point& rRef, long nWink, double sn, double cs); virtual void Mirror(const Point& rRef1, const Point& rRef2); virtual void Shear(const Point& rRef, long nWink, double tn, bool bVShear); diff --git a/svx/inc/svx/svdovirt.hxx b/svx/inc/svx/svdovirt.hxx index a2f66e7..03311b6 100644 --- a/svx/inc/svx/svdovirt.hxx +++ b/svx/inc/svx/svdovirt.hxx @@ -116,7 +116,7 @@ public: virtual void NbcShear(const Point& rRef, long nWink, double tn, bool bVShear); virtual void Move(const Size& rSiz); - virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact); + virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative = true); virtual void Rotate(const Point& rRef, long nWink, double sn, double cs); virtual void Mirror(const Point& rRef1, const Point& rRef2); virtual void Shear(const Point& rRef, long nWink, double tn, bool bVShear); diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx index dab7b9f..4236d4b 100644 --- a/svx/source/svdraw/svdoashp.cxx +++ b/svx/source/svdraw/svdoashp.cxx @@ -1534,9 +1534,9 @@ void SdrObjCustomShape::NbcMove( const Size& rSiz ) mpLastShadowGeometry->NbcMove( rSiz ); } } -void SdrObjCustomShape::Resize( const Point& rRef, const Fraction& xFact, const Fraction& yFact ) +void SdrObjCustomShape::Resize( const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative ) { - SdrTextObj::Resize( rRef, xFact, yFact ); + SdrTextObj::Resize( rRef, xFact, yFact, bUnsetRelative ); } void SdrObjCustomShape::NbcResize( const Point& rRef, const Fraction& rxFact, const Fraction& ryFact ) diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index 9cc99b1..d0206fd 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -1556,9 +1556,14 @@ void SdrObject::Move(const Size& rSiz) } } -void SdrObject::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) +void SdrObject::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative) { if (xFact.GetNumerator()!=xFact.GetDenominator() || yFact.GetNumerator()!=yFact.GetDenominator()) { + if (bUnsetRelative) + { + mnRelativeWidth.reset( ); + mnRelativeHeight.reset( ); + } Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect(); NbcResize(rRef,xFact,yFact); SetChanged(); diff --git a/svx/source/svdraw/svdogrp.cxx b/svx/source/svdraw/svdogrp.cxx index bf85525..6bf8ba1 100644 --- a/svx/source/svdraw/svdogrp.cxx +++ b/svx/source/svdraw/svdogrp.cxx @@ -584,7 +584,7 @@ void SdrObjGroup::Move(const Size& rSiz) } -void SdrObjGroup::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) +void SdrObjGroup::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative) { if (xFact.GetNumerator()!=xFact.GetDenominator() || yFact.GetNumerator()!=yFact.GetDenominator()) { bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0); @@ -611,11 +611,11 @@ void SdrObjGroup::Resize(const Point& rRef, const Fraction& xFact, const Fractio sal_uIntPtr i; for (i=0; i<nObjAnz; i++) { SdrObject* pObj=pOL->GetObj(i); - if (pObj->IsEdgeObj()) pObj->Resize(rRef,xFact,yFact); + if (pObj->IsEdgeObj()) pObj->Resize(rRef,xFact,yFact,bUnsetRelative); } for (i=0; i<nObjAnz; i++) { SdrObject* pObj=pOL->GetObj(i); - if (!pObj->IsEdgeObj()) pObj->Resize(rRef,xFact,yFact); + if (!pObj->IsEdgeObj()) pObj->Resize(rRef,xFact,yFact,bUnsetRelative); } } else { ResizeRect(aOutRect,rRef,xFact,yFact); diff --git a/svx/source/svdraw/svdovirt.cxx b/svx/source/svdraw/svdovirt.cxx index 3534ff4..0452a16 100644 --- a/svx/source/svdraw/svdovirt.cxx +++ b/svx/source/svdraw/svdovirt.cxx @@ -412,11 +412,11 @@ void SdrVirtObj::Move(const Size& rSiz) } } -void SdrVirtObj::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) +void SdrVirtObj::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative) { if (xFact.GetNumerator()!=xFact.GetDenominator() || yFact.GetNumerator()!=yFact.GetDenominator()) { Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect(); - rRefObj.Resize(rRef-aAnchor,xFact,yFact); + rRefObj.Resize(rRef-aAnchor,xFact,yFact, bUnsetRelative); SetRectsDirty(); SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0); } diff --git a/sw/inc/dcontact.hxx b/sw/inc/dcontact.hxx index 2984872..f0d7ab3 100644 --- a/sw/inc/dcontact.hxx +++ b/sw/inc/dcontact.hxx @@ -303,7 +303,7 @@ class SwDrawVirtObj : public SdrVirtObj virtual void NbcMirror(const Point& rRef1, const Point& rRef2); virtual void NbcShear(const Point& rRef, long nWink, double tn, bool bVShear); virtual void Move(const Size& rSiz); - virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact); + virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative = true); virtual void Rotate(const Point& rRef, long nWink, double sn, double cs); virtual void Mirror(const Point& rRef1, const Point& rRef2); virtual void Shear(const Point& rRef, long nWink, double tn, bool bVShear); diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index ff2f27b..6f72799 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -2472,12 +2472,12 @@ void SwDrawVirtObj::Move(const Size& rSiz) SdrObject::Move( rSiz ); } -void SwDrawVirtObj::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) +void SwDrawVirtObj::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative) { if(xFact.GetNumerator() != xFact.GetDenominator() || yFact.GetNumerator() != yFact.GetDenominator()) { Rectangle aBoundRect0; if(pUserCall) aBoundRect0 = GetLastBoundRect(); - rRefObj.Resize(rRef - GetOffset(), xFact, yFact); + rRefObj.Resize(rRef - GetOffset(), xFact, yFact, bUnsetRelative); SetRectsDirty(); SendUserCall(SDRUSERCALL_RESIZE, aBoundRect0); } diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx index 19ec682..d8bddbc 100644 --- a/sw/source/core/draw/dflyobj.cxx +++ b/sw/source/core/draw/dflyobj.cxx @@ -923,7 +923,7 @@ void SwVirtFlyDrawObj::Move(const Size& rSiz) void SwVirtFlyDrawObj::Resize(const Point& rRef, - const Fraction& xFact, const Fraction& yFact) + const Fraction& xFact, const Fraction& yFact, bool /*bUnsetRelative*/) { NbcResize( rRef, xFact, yFact ); SetChanged(); diff --git a/sw/source/core/inc/dflyobj.hxx b/sw/source/core/inc/dflyobj.hxx index fed3aff..3ef6a22 100644 --- a/sw/source/core/inc/dflyobj.hxx +++ b/sw/source/core/inc/dflyobj.hxx @@ -112,7 +112,7 @@ public: const Fraction& yFact); virtual void Move (const Size& rSiz); virtual void Resize(const Point& rRef, const Fraction& xFact, - const Fraction& yFact); + const Fraction& yFact, bool bUnsetRelative = true); const SwFrmFmt *GetFmt() const; SwFrmFmt *GetFmt(); diff --git a/sw/source/core/layout/anchoreddrawobject.cxx b/sw/source/core/layout/anchoreddrawobject.cxx index 735878f..c36a491 100644 --- a/sw/source/core/layout/anchoreddrawobject.cxx +++ b/sw/source/core/layout/anchoreddrawobject.cxx @@ -659,6 +659,29 @@ const SwRect SwAnchoredDrawObject::GetObjRect() const // --> #i70122# const SwRect SwAnchoredDrawObject::GetObjBoundRect() const { + // Resize objects with relative width or height +#if 1 + if ( GetDrawObj( )->GetRelativeWidth( ) || GetDrawObj()->GetRelativeHeight( ) ) + { + Rectangle aPageRect = GetPageFrm( )->GetBoundRect( ).SVRect(); + Rectangle aCurrObjRect = GetDrawObj()->GetCurrentBoundRect(); + + long nTargetWidth = aCurrObjRect.GetWidth( ); + if ( GetDrawObj( )->GetRelativeWidth( ) ) + nTargetWidth = aPageRect.GetWidth( ) * GetDrawObj( )->GetRelativeWidth( ).get( ); + + long nTargetHeight = aCurrObjRect.GetHeight( ); + if ( GetDrawObj( )->GetRelativeHeight( ) ) + nTargetHeight = aPageRect.GetHeight( ) * GetDrawObj( )->GetRelativeHeight( ).get( ); + + if ( nTargetWidth != aCurrObjRect.GetWidth( ) || nTargetHeight != aCurrObjRect.GetHeight( ) ) + { + const_cast< SdrObject* >( GetDrawObj() )->Resize( aCurrObjRect.TopLeft(), + Fraction( nTargetWidth, aCurrObjRect.GetWidth() ), + Fraction( nTargetHeight, aCurrObjRect.GetHeight() ), false ); + } + } +#endif return GetDrawObj()->GetCurrentBoundRect(); } diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 2e37dd6..8b141e4 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -1265,6 +1265,22 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A pFmt->SetFmtAttr(aSet); } } + else if( RES_FRM_SIZE == pEntry->nWID && + ( pEntry->nMemberId == MID_FRMSIZE_REL_HEIGHT || pEntry->nMemberId == MID_FRMSIZE_REL_WIDTH ) ) + { + SvxShape* pSvxShape = GetSvxShape(); + SAL_WARN_IF(!pSvxShape, "sw.uno", "No SvxShape found!"); + if(pSvxShape) + { + SdrObject* pObj = pSvxShape->GetSdrObject(); + sal_Int16 nPercent; + aValue >>= nPercent; + if ( pEntry->nMemberId == MID_FRMSIZE_REL_WIDTH ) + pObj->SetRelativeWidth( nPercent / 100.0 ); + else + pObj->SetRelativeHeight( nPercent / 100.0 ); + } + } else { m_pPropSet->setPropertyValue( *pEntry, aValue, aSet ); diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx index 26348ed..a6832a9 100644 --- a/sw/source/core/unocore/unomap.cxx +++ b/sw/source/core/unocore/unomap.cxx @@ -1183,6 +1183,8 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s // #i71182# // missing map entry for property <PageToogle> { SW_PROP_NMID(UNO_NAME_PAGE_TOGGLE), RES_HORI_ORIENT, CPPU_E2T(CPPUTYPE_BOOLEAN), PROPERTY_NONE ,MID_HORIORIENT_PAGETOGGLE }, + { SW_PROP_NMID(UNO_NAME_RELATIVE_HEIGHT), RES_FRM_SIZE, CPPU_E2T(CPPUTYPE_INT16) , PROPERTY_NONE, MID_FRMSIZE_REL_HEIGHT }, + { SW_PROP_NMID(UNO_NAME_RELATIVE_WIDTH), RES_FRM_SIZE, CPPU_E2T(CPPUTYPE_INT16) , PROPERTY_NONE, MID_FRMSIZE_REL_WIDTH }, {0,0,0,0,0,0} }; aMapEntriesArr[nPropertyId] = aShapeMap_Impl; commit 0f581ab761cefde208e576661850b57f2846fdb4 Author: Cédric Bosdonnat <[email protected]> Date: Mon Sep 24 18:01:05 2012 +0200 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 diff --git a/oox/inc/oox/vml/vmlshape.hxx b/oox/inc/oox/vml/vmlshape.hxx index a09192a..385f9ea 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 3fed530..ff4e47b 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 c9096eb..7d8d166 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 165aee5..01543c3 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; diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 92452dd..5214b49 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -35,8 +35,10 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <com/sun/star/text/HoriOrientation.hpp> +#include <com/sun/star/text/RelOrientation.hpp> #include <com/sun/star/text/SetVariableType.hpp> #include <com/sun/star/text/TextContentAnchorType.hpp> +#include <com/sun/star/text/VertOrientation.hpp> #include <com/sun/star/text/WrapTextMode.hpp> #include <com/sun/star/text/XDependentTextField.hpp> #include <com/sun/star/text/XFormField.hpp> @@ -890,7 +892,25 @@ void Test::testN779627() uno::Any aValue = xTableProperties->getPropertyValue("LeftMargin"); sal_Int32 nLeftMargin; aValue >>= nLeftMargin; - CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nLeftMargin); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Left margin shouldn't take tableCellMar into account in nested tables", + sal_Int32(0), nLeftMargin); + + /* + * Another problem tested with this document is that the roundrect is + * centered vertically and horizontally. + */ + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xShapeProperties( xDraws->getByIndex(2), uno::UNO_QUERY ); + sal_Int16 nValue; + xShapeProperties->getPropertyValue("HoriOrient") >>= nValue; + CPPUNIT_ASSERT_EQUAL_MESSAGE("Not centered horizontally", text::HoriOrientation::CENTER, nValue); + xShapeProperties->getPropertyValue("HoriOrientRelation") >>= nValue; + CPPUNIT_ASSERT_EQUAL_MESSAGE("Not centered horizontally relatively to page", text::RelOrientation::PAGE_FRAME, nValue); + xShapeProperties->getPropertyValue("VertOrient") >>= nValue; + CPPUNIT_ASSERT_EQUAL_MESSAGE("Not centered vertically", text::VertOrientation::CENTER, nValue); + xShapeProperties->getPropertyValue("VertOrientRelation") >>= nValue; + CPPUNIT_ASSERT_EQUAL_MESSAGE("Not centered vertically relatively to page", text::RelOrientation::PAGE_FRAME, nValue); } void Test::testFdo55187()
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
