include/svx/svdobj.hxx | 6 ++++++ svx/source/svdraw/svdobj.cxx | 5 +++++ sw/source/core/layout/anchoreddrawobject.cxx | 17 ++++++++++++++++- sw/source/core/unocore/unodraw.cxx | 19 ++++++++++++++++--- sw/source/core/unocore/unomap.cxx | 2 ++ 5 files changed, 45 insertions(+), 4 deletions(-)
New commits: commit 90519c0436bacc50136b33039bd107e4f6bdb24c Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Feb 20 12:18:23 2014 +0100 SwAnchoredDrawObject: respect SdrObject::GetRelativeWidth/HeightRelation() Change-Id: Ie107ea749a1f4c261106f0f18f3818b85d65e9b4 diff --git a/sw/source/core/layout/anchoreddrawobject.cxx b/sw/source/core/layout/anchoreddrawobject.cxx index 65416d4..e9630a9 100644 --- a/sw/source/core/layout/anchoreddrawobject.cxx +++ b/sw/source/core/layout/anchoreddrawobject.cxx @@ -630,16 +630,31 @@ const SwRect SwAnchoredDrawObject::GetObjBoundRect() const // Resize objects with relative width or height if ( !bGroupShape && GetPageFrm( ) && ( GetDrawObj( )->GetRelativeWidth( ) || GetDrawObj()->GetRelativeHeight( ) ) ) { - Rectangle aPageRect = GetPageFrm( )->GetBoundRect( ).SVRect(); Rectangle aCurrObjRect = GetDrawObj()->GetCurrentBoundRect(); long nTargetWidth = aCurrObjRect.GetWidth( ); if ( GetDrawObj( )->GetRelativeWidth( ) ) + { + Rectangle aPageRect; + if (GetDrawObj()->GetRelativeWidthRelation() == text::RelOrientation::FRAME) + // Exclude margins. + aPageRect = GetPageFrm()->Prt().SVRect(); + else + aPageRect = GetPageFrm( )->GetBoundRect( ).SVRect(); nTargetWidth = aPageRect.GetWidth( ) * GetDrawObj( )->GetRelativeWidth( ).get( ); + } long nTargetHeight = aCurrObjRect.GetHeight( ); if ( GetDrawObj( )->GetRelativeHeight( ) ) + { + Rectangle aPageRect; + if (GetDrawObj()->GetRelativeHeightRelation() == text::RelOrientation::FRAME) + // Exclude margins. + aPageRect = GetPageFrm()->Prt().SVRect(); + else + aPageRect = GetPageFrm( )->GetBoundRect( ).SVRect(); nTargetHeight = aPageRect.GetHeight( ) * GetDrawObj( )->GetRelativeHeight( ).get( ); + } if ( nTargetWidth != aCurrObjRect.GetWidth( ) || nTargetHeight != aCurrObjRect.GetHeight( ) ) { commit b548b2efb1a8aafcd5e56a1d26b933354ff02a47 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Feb 20 12:07:51 2014 +0100 sw: enable Relative{Height,Width}Relation UNO properties for shapes Change-Id: I40080bd9b096b9fa5d660b11c4e5821db31fd412 diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 4b48e46..b3c7c0c 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -1258,7 +1258,9 @@ void SwXShape::setPropertyValue(const OUString& rPropertyName, const uno::Any& a } } else if( RES_FRM_SIZE == pEntry->nWID && - ( pEntry->nMemberId == MID_FRMSIZE_REL_HEIGHT || pEntry->nMemberId == MID_FRMSIZE_REL_WIDTH ) ) + ( pEntry->nMemberId == MID_FRMSIZE_REL_HEIGHT || pEntry->nMemberId == MID_FRMSIZE_REL_WIDTH + || pEntry->nMemberId == MID_FRMSIZE_REL_HEIGHT_RELATION + || pEntry->nMemberId == MID_FRMSIZE_REL_WIDTH_RELATION ) ) { SvxShape* pSvxShape = GetSvxShape(); SAL_WARN_IF(!pSvxShape, "sw.uno", "No SvxShape found!"); @@ -1267,10 +1269,21 @@ void SwXShape::setPropertyValue(const OUString& rPropertyName, const uno::Any& a SdrObject* pObj = pSvxShape->GetSdrObject(); sal_Int16 nPercent(100); aValue >>= nPercent; - if ( pEntry->nMemberId == MID_FRMSIZE_REL_WIDTH ) + switch (pEntry->nMemberId) + { + case MID_FRMSIZE_REL_WIDTH: pObj->SetRelativeWidth( nPercent / 100.0 ); - else + break; + case MID_FRMSIZE_REL_HEIGHT: pObj->SetRelativeHeight( nPercent / 100.0 ); + break; + case MID_FRMSIZE_REL_WIDTH_RELATION: + pObj->SetRelativeWidthRelation(nPercent); + break; + case MID_FRMSIZE_REL_HEIGHT_RELATION: + pObj->SetRelativeHeightRelation(nPercent); + break; + } } } else diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx index eac4e79..1c59657 100644 --- a/sw/source/core/unocore/unomap.cxx +++ b/sw/source/core/unocore/unomap.cxx @@ -1328,7 +1328,9 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s // missing map entry for property <PageToogle> { OUString(UNO_NAME_PAGE_TOGGLE), RES_HORI_ORIENT, cppu::UnoType<bool>::get(), PROPERTY_NONE ,MID_HORIORIENT_PAGETOGGLE }, { OUString(UNO_NAME_RELATIVE_HEIGHT), RES_FRM_SIZE, cppu::UnoType<sal_Int16>::get() , PROPERTY_NONE, MID_FRMSIZE_REL_HEIGHT }, + { OUString(UNO_NAME_RELATIVE_HEIGHT_RELATION), RES_FRM_SIZE, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_FRMSIZE_REL_HEIGHT_RELATION }, { OUString(UNO_NAME_RELATIVE_WIDTH), RES_FRM_SIZE, cppu::UnoType<sal_Int16>::get() , PROPERTY_NONE, MID_FRMSIZE_REL_WIDTH }, + { OUString(UNO_NAME_RELATIVE_WIDTH_RELATION), RES_FRM_SIZE, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_FRMSIZE_REL_WIDTH_RELATION }, { OUString(), 0, css::uno::Type(), 0, 0 } }; aMapEntriesArr[nPropertyId] = aShapeMap_Impl; commit b0bf124360730e79366e1be73383d4639e608a4c Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Feb 20 11:14:14 2014 +0100 SdrObject: add meRelativeWidth/HeightRelation Similar to Writer TextBoxes, this member is supposed to store the "relation" (text::RelOrientation constants) of the relative width/height, so far the layout always assumed "relative to page". Change-Id: I5100745314e45ad322bff2b761e3722459aba014 diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx index efc5a0e..611b365 100644 --- a/include/svx/svdobj.hxx +++ b/include/svx/svdobj.hxx @@ -413,13 +413,19 @@ protected: private: static SdrItemPool* mpGlobalItemPool; boost::optional<double> mnRelativeWidth; + sal_Int16 meRelativeWidthRelation; boost::optional<double> mnRelativeHeight; + sal_Int16 meRelativeHeightRelation; public: static SdrItemPool& GetGlobalDrawObjectItemPool(); void SetRelativeWidth( double nValue ) { mnRelativeWidth.reset( nValue ); } + void SetRelativeWidthRelation( sal_Int16 eValue ) { meRelativeWidthRelation = eValue; } void SetRelativeHeight( double nValue ) { mnRelativeHeight.reset( nValue ); } + void SetRelativeHeightRelation( sal_Int16 eValue ) { meRelativeHeightRelation = eValue; } boost::optional<double> GetRelativeWidth( ) const { return mnRelativeWidth; } + sal_Int16 GetRelativeWidthRelation() const { return meRelativeWidthRelation; } boost::optional<double> GetRelativeHeight( ) const { return mnRelativeHeight; } + sal_Int16 GetRelativeHeightRelation() const { return meRelativeHeightRelation; } // evil calc grid/shape drawlayer syncing Point GetGridOffset() const { return aGridOffset; } void SetGridOffset( const Point& rGridOffset ){ aGridOffset = rGridOffset; } diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index 9999a46..4a0d63c 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -20,6 +20,7 @@ #include "sal/config.h" #include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/text/RelOrientation.hpp> #include "svdconv.hxx" @@ -437,6 +438,8 @@ SdrObject::SdrObject() ,pGrabBagItem(NULL) ,mnNavigationPosition(SAL_MAX_UINT32) ,mnLayerID(0) + ,meRelativeWidthRelation(text::RelOrientation::PAGE_FRAME) + ,meRelativeHeightRelation(text::RelOrientation::PAGE_FRAME) ,mpSvxShape( NULL ) ,maWeakUnoShape() ,mbDoNotInsertIntoPageAutomatically(false) @@ -1615,6 +1618,8 @@ void SdrObject::Resize(const Point& rRef, const Fraction& xFact, const Fraction& if (bUnsetRelative) { mnRelativeWidth.reset( ); + meRelativeWidthRelation = text::RelOrientation::PAGE_FRAME; + meRelativeHeightRelation = text::RelOrientation::PAGE_FRAME; mnRelativeHeight.reset( ); } Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits