diff options
-rw-r--r-- | oox/inc/oox/vml/vmlshape.hxx | 4 | ||||
-rw-r--r-- | oox/source/token/properties.txt | 2 | ||||
-rw-r--r-- | oox/source/vml/vmlshape.cxx | 26 | ||||
-rw-r--r-- | oox/source/vml/vmlshapecontext.cxx | 4 | ||||
-rw-r--r-- | svx/inc/svx/svdoashp.hxx | 2 | ||||
-rw-r--r-- | svx/inc/svx/svdobj.hxx | 9 | ||||
-rw-r--r-- | svx/inc/svx/svdogrp.hxx | 2 | ||||
-rw-r--r-- | svx/inc/svx/svdovirt.hxx | 2 | ||||
-rw-r--r-- | svx/source/svdraw/svdoashp.cxx | 4 | ||||
-rw-r--r-- | svx/source/svdraw/svdobj.cxx | 7 | ||||
-rw-r--r-- | svx/source/svdraw/svdogrp.cxx | 6 | ||||
-rw-r--r-- | svx/source/svdraw/svdovirt.cxx | 4 | ||||
-rw-r--r-- | sw/inc/dcontact.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/draw/dcontact.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/draw/dflyobj.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/inc/dflyobj.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/layout/anchoreddrawobject.cxx | 23 | ||||
-rw-r--r-- | sw/source/core/unocore/unodraw.cxx | 16 | ||||
-rw-r--r-- | sw/source/core/unocore/unomap.cxx | 2 |
19 files changed, 106 insertions, 17 deletions
diff --git a/oox/inc/oox/vml/vmlshape.hxx b/oox/inc/oox/vml/vmlshape.hxx index 385f9eaf6745..c7f288d36aa8 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 ff4e47b09f34..c925d1fe7b1e 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 7d8d1660a42e..7773d8a50243 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 01543c31e8d8..35525e69f76f 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 0f540190493a..8b91894485c5 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 e0fac2681272..6c5b67b05f02 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 3e8318e88c17..ed04fb8cb99f 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 a2f66e795805..03311b69adf8 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 dab7b9feaf62..4236d4bab00d 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 9cc99b17bbed..d0206fd9933a 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 bf8552521be6..6bf8ba187a5d 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 3534ff43eb7d..0452a168423c 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 2984872917a7..f0d7ab30a578 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 ff2f27b7430b..6f72799d998d 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 19ec682bf011..d8bddbce0edf 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 fed3affe24d8..3ef6a226d24b 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 735878f98ea9..c36a49170c0b 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 2e37dd618573..8b141e438b58 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 26348ed67236..a6832a9e1c20 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; |